NepomukDaemons
systray.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "systray.h"
00020 #include "indexscheduler.h"
00021
00022 #include <KMenu>
00023 #include <KToggleAction>
00024 #include <KLocale>
00025 #include <KCMultiDialog>
00026 #include <KIcon>
00027
00028
00029
00030 Nepomuk::SystemTray::SystemTray( IndexScheduler* scheduler, QWidget* parent )
00031 : KSystemTrayIcon( "nepomuk", parent ),
00032 m_indexScheduler( scheduler )
00033 {
00034 KMenu* menu = new KMenu;
00035 menu->addTitle( i18n( "Strigi File Indexing" ) );
00036
00037 m_suspendResumeAction = new KToggleAction( i18n( "Suspend Strigi Indexing" ), menu );
00038 m_suspendResumeAction->setCheckedState( KGuiItem( i18n( "Resume Strigi Indexing" ) ) );
00039 m_suspendResumeAction->setToolTip( i18n( "Suspend or resume the Strigi file indexer manually" ) );
00040 connect( m_suspendResumeAction, SIGNAL( toggled( bool ) ),
00041 m_indexScheduler, SLOT( setSuspended( bool ) ) );
00042
00043 KAction* configAction = new KAction( menu );
00044 configAction->setText( i18n( "Configure Strigi" ) );
00045 configAction->setIcon( KIcon( "configure" ) );
00046 connect( configAction, SIGNAL( triggered() ),
00047 this, SLOT( slotConfigure() ) );
00048
00049 menu->addAction( m_suspendResumeAction );
00050 menu->addAction( configAction );
00051
00052 setContextMenu( menu );
00053
00054 connect( m_indexScheduler, SIGNAL( indexingStarted() ),
00055 this, SLOT( slotUpdateStrigiStatus() ) );
00056 connect( m_indexScheduler, SIGNAL( indexingStopped() ),
00057 this, SLOT( slotUpdateStrigiStatus() ) );
00058 connect( m_indexScheduler, SIGNAL( indexingFolder(QString) ),
00059 this, SLOT( slotUpdateStrigiStatus() ) );
00060 }
00061
00062
00063 Nepomuk::SystemTray::~SystemTray()
00064 {
00065 }
00066
00067
00068 void Nepomuk::SystemTray::slotUpdateStrigiStatus()
00069 {
00070 bool indexing = m_indexScheduler->isIndexing();
00071 bool suspended = m_indexScheduler->isSuspended();
00072 QString folder = m_indexScheduler->currentFolder();
00073
00074 if ( suspended )
00075 setToolTip( i18n( "File indexer is suspended" ) );
00076 else if ( indexing )
00077 setToolTip( i18n( "Strigi is currently indexing files in folder %1", folder ) );
00078 else
00079 setToolTip( i18n( "File indexer is idle" ) );
00080
00081 m_suspendResumeAction->setChecked( suspended );
00082 }
00083
00084
00085 void Nepomuk::SystemTray::slotConfigure()
00086 {
00087 KCMultiDialog dlg;
00088 dlg.addModule( "kcm_nepomuk" );
00089 dlg.exec();
00090 }
00091
00092 #include "systray.moc"