30 #include <KActionCollection>
31 #include <KConfigGroup>
33 #include <KIconEffect>
34 #include <KIconLoader>
36 #include <KMessageBox>
38 #include <KStandardAction>
39 #include <KToolInvocation>
45 KConfigGroup config( KGlobal::config(),
"General" );
46 bool autostartSet = config.hasKey(
"Autostart" );
47 bool autostart = config.readEntry(
"Autostart",
true );
48 bool alarmsEnabled = config.readEntry(
"Enabled",
true );
50 mName = i18nc(
"@title:window",
"KOrganizer Reminder Daemon" );
51 setToolTipTitle( mName );
52 setToolTipIconByName( QLatin1String(
"korgac") );
55 KIconLoader::global()->addAppDir( QLatin1String(
"korgac") );
56 KIconLoader::global()->addAppDir( QLatin1String(
"kdepim") );
57 QString iconPath = KIconLoader::global()->iconPath( QLatin1String(
"korgac"), KIconLoader::Panel );
58 QIcon iconEnabled = QIcon( iconPath );
59 if ( iconEnabled.isNull() ) {
60 KMessageBox::sorry( associatedWidget(),
61 i18nc(
"@info",
"Cannot load system tray icon." ) );
65 iconEnabled.pixmap( loader.currentSize( KIconLoader::Panel ) ).toImage();
66 KIconEffect::toGray( iconDisabled, 1.0 );
67 mIconDisabled = QIcon( QPixmap::fromImage( iconDisabled ) );
70 changeSystrayIcon( alarmsEnabled );
74 contextMenu()->addAction( i18nc(
"@action:inmenu",
"Suspend All Reminders" ),
this,
77 contextMenu()->addAction( i18nc(
"@action:inmenu",
"Dismiss All Reminders" ),
this,
79 mSuspendAll->setEnabled(
false );
80 mDismissAll->setEnabled(
false );
82 contextMenu()->addSeparator();
84 contextMenu()->addAction( i18nc(
"@action:inmenu",
"Enable Reminders" ) );
86 mAlarmsEnabled->setCheckable(
true );
89 contextMenu()->addAction( i18nc(
"@action:inmenu",
"Start Reminder Daemon at Login" ) );
90 connect( mAutostart, SIGNAL(toggled(
bool)), SLOT(
toggleAutostart(
bool)) );
91 mAutostart->setCheckable(
true );
93 mAlarmsEnabled->setChecked( alarmsEnabled );
94 mAutostart->setChecked( autostart );
98 KActionCollection *ac = actionCollection();
99 const char *quitName = KStandardAction::name( KStandardAction::Quit );
100 QAction *quit = ac->action( QLatin1String(quitName) );
102 kDebug() <<
"No Quit standard action.";
104 quit->disconnect( SIGNAL(triggered(
bool)),
this, SLOT(maybeQuit()) );
105 connect( quit, SIGNAL(activated()), SLOT(
slotQuit()) );
108 mAutostartSet = autostartSet;
117 bool actif = ( reminders > 0 );
118 mSuspendAll->setEnabled( actif );
119 mDismissAll->setEnabled( actif );
121 setToolTip( QLatin1String(
"korgac"), mName, i18ncp(
"@info:status",
122 "There is 1 active reminder.",
123 "There are %1 active reminders.", reminders ) );
125 setToolTip( QLatin1String(
"korgac"), mName, i18nc(
"@info:status",
"No active reminders." ) );
131 changeSystrayIcon( checked );
133 KConfigGroup config( KGlobal::config(),
"General" );
134 config.writeEntry(
"Enabled", checked );
141 mAutostartSet =
true;
157 KConfigGroup config( KGlobal::config(),
"General" );
158 config.writeEntry(
"Autostart", enable );
165 KToolInvocation::startServiceByDesktopName( QLatin1String(
"korganizer"), QString() );
170 if ( mAutostartSet ==
true ) {
171 int result = KMessageBox::warningContinueCancel(
174 "Do you want to quit the KOrganizer reminder daemon?<nl/>"
175 "<note> you will not get calendar reminders unless the daemon is running.</note>" ),
176 i18nc(
"@title:window",
"Close KOrganizer Reminder Daemon" ),
177 KStandardGuiItem::quit() );
179 if ( result == KMessageBox::Continue ) {
183 int result = KMessageBox::questionYesNoCancel(
186 "Do you want to start the KOrganizer reminder daemon at login?<nl/>"
187 "<note> you will not get calendar reminders unless the daemon is running.</note>" ),
188 i18nc(
"@title:window",
"Close KOrganizer Reminder Daemon" ),
189 KGuiItem( i18nc(
"@action:button start the reminder daemon",
"Start" ) ),
190 KGuiItem( i18nc(
"@action:button do not start the reminder daemon",
"Do Not Start" ) ),
191 KStandardGuiItem::cancel(),
192 QString::fromLatin1(
"AskForStartAtLogin" ) );
194 bool autostart =
true;
195 if ( result == KMessageBox::No ) {
200 if ( result != KMessageBox::Cancel ) {
206 void AlarmDockWindow::changeSystrayIcon(
bool alarmsEnabled )
208 if ( alarmsEnabled ) {
209 setIconByName( QLatin1String(
"korgac") );
211 setIconByPixmap( mIconDisabled.pixmap( 22, 22 ) );
215 #include "alarmdockwindow.moc"
virtual void activate(const QPoint &pos)
void slotUpdate(int reminders)
void enableAutostart(bool enabled)
void toggleAutostart(bool checked)
void toggleAlarmsEnabled(bool checked)
virtual ~AlarmDockWindow()