31 #include <KApplication>
36 #include <KMessageBox>
37 #include <KPushButton>
38 #include <KShortcutsDialog>
39 #include <KStandardAction>
41 #include <KXMLGUIFactory>
42 #include <KActionCollection>
43 #include <KPluginLoader>
44 #include <KPluginFactory>
58 kDebug(5970) <<
"Entering function, icsfile is " <<
icsfile;
63 KPluginLoader loader(
"ktimetrackerpart" );
64 KPluginFactory *factory = loader.factory();
74 m_part =
dynamic_cast<ktimetrackerpart*
>( factory->create<KParts::ReadWritePart>( this ) );
80 setCentralWidget(m_part->widget());
83 connect(configureAction, SIGNAL(triggered(
bool)),
90 kError() <<
"Could not find the KTimeTracker part: m_part is 0";
91 KMessageBox::error(
this, i18n(
"Could not create the KTimeTracker part." ));
92 QTimer::singleShot(0, qApp, SLOT(quit()));
100 kError() <<
"Could not find the KTimeTracker part: factory is 0";
101 KMessageBox::error(
this, i18n(
"Could not find the KTimeTracker part." ));
102 QTimer::singleShot(0, qApp, SLOT(quit()));
107 setWindowFlags( windowFlags() | Qt::WindowContextHelpButtonHint );
110 connect( m_part->widget(), SIGNAL(statusBarTextChangeRequested(QString)),
112 connect( m_part->widget(), SIGNAL(setCaption(QString)),
117 connect( m_part->widget(),
118 SIGNAL(contextMenuRequested(QPoint)),
124 connect( m_part->widget(), SIGNAL(timersActive()), _tray, SLOT(startClock()) );
125 connect( m_part->widget(), SIGNAL(timersInactive()), _tray, SLOT(stopClock()) );
126 connect( m_part->widget(), SIGNAL(tasksChanged(QList<Task*>)), _tray, SLOT(updateToolTip(QList<Task*>)));
130 void MainWindow::setupActions()
132 configureAction =
new KAction(
this);
133 configureAction->setText(i18n(
"Configure KTimeTracker..."));
134 actionCollection()->addAction(
"configure_ktimetracker", configureAction);
139 if( cfg.readEntry(
"WindowShown",
true ))
145 cfg.writeEntry(
"WindowShown", isVisible());
155 statusBar()->showMessage(i18n(qs.toUtf8()));
160 kDebug(5970) <<
"MainWindow::~MainWindows: Quitting ktimetracker.";
166 KShortcutsDialog::configure( actionCollection(), KShortcutsEditor::LetterShortcutsAllowed,
this );
169 void MainWindow::makeMenus()
172 actionKeyBindings = KStandardAction::keyBindings(
this, SLOT(
keyBindings()),
173 actionCollection() );
175 actionKeyBindings->setToolTip( i18n(
"Configure key bindings" ) );
176 actionKeyBindings->setWhatsThis( i18n(
"This will let you configure key"
177 "bindings which are specific to ktimetracker" ) );
182 if (initialGeometrySet()) setAutoSaveSettings();
185 KConfigGroup config = KGlobal::config()->group( QString::fromLatin1(
"Main Window Geometry") );
186 int w = config.readEntry( QString::fromLatin1(
"Width"), 100 );
187 int h = config.readEntry( QString::fromLatin1(
"Height"), 100 );
188 w = qMax( w, sizeHint().width() );
189 h = qMax( h, sizeHint().height() );
197 KConfigGroup config = KGlobal::config()->group( QString::fromLatin1(
"Main Window Geometry") );
198 config.writeEntry( QString::fromLatin1(
"Width"), width());
199 config.writeEntry( QString::fromLatin1(
"Height"), height());
205 if ( !kapp->sessionSaving() )
210 return KMainWindow::queryClose();
215 QMenu* pop =
dynamic_cast<QMenu*
>( factory()->container( i18n(
"task_popup" ),
this ) );
220 #include "mainwindow.moc"
void readProperties(const KConfigGroup &config)
virtual bool openFile()
openFile() opens the icalendar file that contains the tasks and events.
static bool trayIcon()
Get trayIcon.
void slotSetCaption(const QString &)
void showSettingsDialog()
void setStatusBar(const QString &)
void saveProperties(KConfigGroup &config)
MainWindow(const QString &icsfile="")
QString icsfile(const KCmdLineArgs *args)
void taskViewCustomContextMenuRequested(const QPoint &)
Main window to tie the application together.