alarmdockwindow.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <stdlib.h>
00028
00029 #include <qtooltip.h>
00030 #include <qfile.h>
00031
00032 #include <kapplication.h>
00033 #include <kdebug.h>
00034 #include <klocale.h>
00035 #include <kiconloader.h>
00036 #include <kprocess.h>
00037 #include <kconfig.h>
00038 #include <kmessagebox.h>
00039 #include <kurl.h>
00040 #include <kstandarddirs.h>
00041 #include <dcopclient.h>
00042
00043 #include "koalarmclient.h"
00044 #include "alarmdaemoniface_stub.h"
00045
00046 #include "alarmdockwindow.h"
00047 #include "alarmdockwindow.moc"
00048
00049
00050 AlarmDockWindow::AlarmDockWindow(KOAlarmClient *client, QWidget *parent,
00051 const char *name)
00052 : KSystemTray(parent, name),
00053 mAlarmGui(client)
00054 {
00055
00056 KConfig* config = kapp->config();
00057 config->setGroup("General");
00058 bool autostartGui = config->readBoolEntry( "Autostart", true );
00059 bool alarmsEnabled = config->readBoolEntry( "Enabled", true );
00060
00061
00062 KGlobal::iconLoader()->addAppDir( "kalarmdgui" );
00063 mPixmapEnabled = BarIcon( "kalarmdgui" );
00064 mPixmapDisabled = BarIcon( "kalarmdgui_disabled" );
00065
00066 setPixmap( alarmsEnabled ? mPixmapEnabled : mPixmapDisabled );
00067
00068
00069 mAlarmsEnabledId = contextMenu()->insertItem(i18n("Alarms Enabled"),
00070 this, SLOT(toggleAlarmsEnabled()));
00071 mAutostartGuiId = contextMenu()->insertItem(i18n("Start Alarm Client at Login"),
00072 this, SLOT(toggleGuiAutostart()));
00073 contextMenu()->insertItem( i18n("Configure Alarm Client..."), this,
00074 SLOT( configureAlarmDaemon() ) );
00075
00076 contextMenu()->setItemChecked(mAutostartGuiId, autostartGui);
00077 contextMenu()->setItemChecked(mAlarmsEnabledId, alarmsEnabled);
00078 }
00079
00080 AlarmDockWindow::~AlarmDockWindow()
00081 {
00082 }
00083
00084
00085
00086
00087
00088 void AlarmDockWindow::toggleAlarmsEnabled()
00089 {
00090 kdDebug() << "AlarmDockWindow::toggleAlarmsEnabled()" << endl;
00091
00092 KConfig* config = kapp->config();
00093 config->setGroup("General");
00094
00095 bool enabled = !contextMenu()->isItemChecked( mAlarmsEnabledId );
00096 contextMenu()->setItemChecked( mAlarmsEnabledId, enabled );
00097 setPixmap( enabled ? mPixmapEnabled : mPixmapDisabled );
00098
00099 config->writeEntry( "Enabled", enabled );
00100 config->sync();
00101 }
00102
00103
00104
00105
00106
00107 void AlarmDockWindow::setGuiAutostart(bool on)
00108 {
00109 kdDebug() << "setGuiAutostart()=" << int(on) << endl;
00110
00111 KConfig* config = kapp->config();
00112 config->setGroup("General");
00113 config->writeEntry("Autostart", on);
00114 config->sync();
00115
00116 contextMenu()->setItemChecked(mAutostartGuiId, on);
00117 }
00118
00119
00120
00121
00122
00123 void AlarmDockWindow::mousePressEvent(QMouseEvent* e)
00124 {
00125 if ( e->button() == LeftButton ) {
00126 kapp->startServiceByDesktopName( "korganizer", QString::null );
00127 } else {
00128 KSystemTray::mousePressEvent( e );
00129 }
00130 }
00131
00132
00133 void AlarmDockWindow::closeEvent(QCloseEvent*)
00134 {
00135 kapp->quit();
00136 }
00137
00138 void AlarmDockWindow::configureAlarmDaemon()
00139 {
00140 kapp->startServiceByDesktopName( "kcmkded", QString::null );
00141 }
This file is part of the documentation for kdelibs Version 3.1.5.