add more spacing
[personal-kdebase.git] / runtime / nepomuk / services / strigi / systray.cpp
blob82a6b08f78d6cce30a2fef3f18b22f04867615f4
1 /* This file is part of the KDE Project
2 Copyright (c) 2008 Sebastian Trueg <trueg@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
19 #include "systray.h"
20 #include "indexscheduler.h"
22 #include <KMenu>
23 #include <KToggleAction>
24 #include <KLocale>
25 #include <KCMultiDialog>
26 #include <KIcon>
30 Nepomuk::SystemTray::SystemTray( IndexScheduler* scheduler, QWidget* parent )
31 : KSystemTrayIcon( "nepomuk", parent ),
32 m_indexScheduler( scheduler )
34 KMenu* menu = new KMenu;
35 menu->addTitle( i18n( "Strigi File Indexing" ) );
37 m_suspendResumeAction = new KToggleAction( i18n( "Suspend Strigi Indexing" ), menu );
38 m_suspendResumeAction->setCheckedState( KGuiItem( i18n( "Resume Strigi Indexing" ) ) );
39 m_suspendResumeAction->setToolTip( i18n( "Suspend or resume the Strigi file indexer manually" ) );
40 connect( m_suspendResumeAction, SIGNAL( toggled( bool ) ),
41 m_indexScheduler, SLOT( setSuspended( bool ) ) );
43 KAction* configAction = new KAction( menu );
44 configAction->setText( i18n( "Configure Strigi" ) );
45 configAction->setIcon( KIcon( "configure" ) );
46 connect( configAction, SIGNAL( triggered() ),
47 this, SLOT( slotConfigure() ) );
49 menu->addAction( m_suspendResumeAction );
50 menu->addAction( configAction );
52 setContextMenu( menu );
54 connect( m_indexScheduler, SIGNAL( indexingStarted() ),
55 this, SLOT( slotUpdateStrigiStatus() ) );
56 connect( m_indexScheduler, SIGNAL( indexingStopped() ),
57 this, SLOT( slotUpdateStrigiStatus() ) );
58 connect( m_indexScheduler, SIGNAL( indexingFolder(QString) ),
59 this, SLOT( slotUpdateStrigiStatus() ) );
63 Nepomuk::SystemTray::~SystemTray()
68 void Nepomuk::SystemTray::slotUpdateStrigiStatus()
70 bool indexing = m_indexScheduler->isIndexing();
71 bool suspended = m_indexScheduler->isSuspended();
72 QString folder = m_indexScheduler->currentFolder();
74 if ( suspended )
75 setToolTip( i18n( "File indexer is suspended" ) );
76 else if ( indexing )
77 setToolTip( i18n( "Strigi is currently indexing files in folder %1", folder ) );
78 else
79 setToolTip( i18n( "File indexer is idle" ) );
81 m_suspendResumeAction->setChecked( suspended );
85 void Nepomuk::SystemTray::slotConfigure()
87 KCMultiDialog dlg;
88 dlg.addModule( "kcm_nepomuk" );
89 dlg.exec();
92 #include "systray.moc"