From cdabdc21c8338241871430700719acbecf520048 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 8 Nov 2011 00:35:14 -0600 Subject: Fix accidental conversion of dockwin (part 2 of 2) --- korganizer/korgac/alarmdockwindow.cpp | 206 ++++++++++++++++++++++++++++++++++ korganizer/korgac/alarmdockwindow.h | 72 ++++++++++++ korganizer/korgac/alarmdoctwindow.cpp | 206 ---------------------------------- korganizer/korgac/alarmdoctwindow.h | 72 ------------ 4 files changed, 278 insertions(+), 278 deletions(-) create mode 100644 korganizer/korgac/alarmdockwindow.cpp create mode 100644 korganizer/korgac/alarmdockwindow.h delete mode 100644 korganizer/korgac/alarmdoctwindow.cpp delete mode 100644 korganizer/korgac/alarmdoctwindow.h diff --git a/korganizer/korgac/alarmdockwindow.cpp b/korganizer/korgac/alarmdockwindow.cpp new file mode 100644 index 000000000..85673ef03 --- /dev/null +++ b/korganizer/korgac/alarmdockwindow.cpp @@ -0,0 +1,206 @@ +/* + This file is part of KOrganizer. + + Copyright (c) 2003 Cornelius Schumacher + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + As a special exception, permission is given to link this program + with any edition of TQt, and distribute the resulting executable, + without including the source code for TQt in the source distribution. +*/ + +#include "alarmdockwindow.h" +#include "koalarmclient.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +AlarmDockWindow::AlarmDockWindow( const char *name ) + : KSystemTray( 0, name ) +{ + // Read the autostart status from the config file + KConfig *config = kapp->config(); + config->setGroup("General"); + bool autostart = config->readBoolEntry( "Autostart", true ); + bool alarmsEnabled = config->readBoolEntry( "Enabled", true ); + + mName = i18n( "KOrganizer Reminder Daemon" ); + setCaption( mName ); + + // Set up icons + KGlobal::iconLoader()->addAppDir( "korgac" ); + mPixmapEnabled = loadSizedIcon( "korgac", width() ); + mPixmapDisabled = loadSizedIcon( "korgac_disabled", width() ); + + setPixmap( alarmsEnabled ? mPixmapEnabled : mPixmapDisabled ); + + // Set up the context menu + mSuspendAll = contextMenu()->insertItem( i18n("Suspend All"), this, TQT_SLOT( slotSuspendAll() ) ); + mDismissAll = contextMenu()->insertItem( i18n("Dismiss All"), this, TQT_SLOT( slotDismissAll() ) ); + contextMenu()->setItemEnabled( mSuspendAll, false ); + contextMenu()->setItemEnabled( mDismissAll, false ); + + contextMenu()->insertSeparator(); + mAlarmsEnabledId = contextMenu()->insertItem( i18n("Reminders Enabled"), this, + TQT_SLOT( toggleAlarmsEnabled() ) ); + mAutostartId = contextMenu()->insertItem( i18n("Start Reminder Daemon at Login"), this, + TQT_SLOT( toggleAutostart() ) ); + contextMenu()->setItemChecked( mAutostartId, autostart ); + contextMenu()->setItemChecked( mAlarmsEnabledId, alarmsEnabled ); + + // Disable standard quit behaviour. We have to intercept the quit even, if the + // main window is hidden. + KActionCollection *ac = actionCollection(); + const char *quitName = KStdAction::name( KStdAction::Quit ); + KAction *quit = ac->action( quitName ); + if ( !quit ) { + kdDebug(5890) << "No Quit standard action." << endl; + } else { +#if KDE_IS_VERSION(3,3,90) + quit->disconnect( TQT_SIGNAL( activated() ), this, + TQT_SLOT( maybeQuit() ) ); + connect( quit, TQT_SIGNAL( activated() ), TQT_SLOT( slotQuit() ) ); + } +#else //FIXME: remove for KDE 4.0 + quit->disconnect( TQT_SIGNAL( activated() ), tqApp, + TQT_SLOT( closeAllWindows() ) ); + } + connect( this, TQT_SIGNAL( quitSelected() ), TQT_SLOT( slotQuit() ) ); +#endif + + TQToolTip::add(this, mName ); +} + +AlarmDockWindow::~AlarmDockWindow() +{ +} + +void AlarmDockWindow::resizeEvent ( TQResizeEvent * ) +{ + // Honor Free Desktop specifications that allow for arbitrary system tray icon sizes + mPixmapEnabled = loadSizedIcon( "korgac", width() ); + mPixmapDisabled = loadSizedIcon( "korgac_disabled", width() ); + + KConfig *config = kapp->config(); + bool alarmsEnabled = config->readBoolEntry( "Enabled", true ); + setPixmap( alarmsEnabled ? mPixmapEnabled : mPixmapDisabled ); +} + +void AlarmDockWindow::slotUpdate( int reminders ) +{ + TQToolTip::remove( this ); + if ( reminders > 0 ) + { + TQToolTip::add( this, i18n( "There is 1 active reminder.", + "There are %n active reminders.", reminders ) ); + contextMenu()->setItemEnabled( mSuspendAll, true ); + contextMenu()->setItemEnabled( mDismissAll, true ); + } + else + { + TQToolTip::add( this, mName ); + contextMenu()->setItemEnabled( mSuspendAll, false ); + contextMenu()->setItemEnabled( mDismissAll, false ); + } +} + +void AlarmDockWindow::toggleAlarmsEnabled() +{ + kdDebug(5890) << "AlarmDockWindow::toggleAlarmsEnabled()" << endl; + + KConfig *config = kapp->config(); + config->setGroup( "General" ); + + bool enabled = !contextMenu()->isItemChecked( mAlarmsEnabledId ); + contextMenu()->setItemChecked( mAlarmsEnabledId, enabled ); + setPixmap( enabled ? mPixmapEnabled : mPixmapDisabled ); + + config->writeEntry( "Enabled", enabled ); + config->sync(); +} + +void AlarmDockWindow::toggleAutostart() +{ + bool autostart = !contextMenu()->isItemChecked( mAutostartId ); + + enableAutostart( autostart ); +} + +void AlarmDockWindow::slotSuspendAll() +{ + emit suspendAllSignal(); +} + +void AlarmDockWindow::slotDismissAll() +{ + emit dismissAllSignal(); +} + +void AlarmDockWindow::enableAutostart( bool enable ) +{ + KConfig *config = kapp->config(); + config->setGroup( "General" ); + config->writeEntry( "Autostart", enable ); + config->sync(); + + contextMenu()->setItemChecked( mAutostartId, enable ); +} + +void AlarmDockWindow::mousePressEvent( TQMouseEvent *e ) +{ + if ( e->button() == Qt::LeftButton ) { + kapp->startServiceByDesktopName( "korganizer", TQString() ); + } else { + KSystemTray::mousePressEvent( e ); + } +} + +//void AlarmDockWindow::closeEvent( TQCloseEvent * ) +void AlarmDockWindow::slotQuit() +{ + int result = KMessageBox::questionYesNoCancel( this, + i18n("Do you want to start the KOrganizer reminder daemon at login " + "(note that you will not get reminders whilst the daemon is not running)?"), + i18n("Close KOrganizer Reminder Daemon"), + i18n("Start"), i18n("Do Not Start"), + TQString::tqfromLatin1("AskForStartAtLogin") + ); + + bool autostart = true; + if ( result == KMessageBox::No ) autostart = false; + enableAutostart( autostart ); + + if ( result != KMessageBox::Cancel ) + emit quitSignal(); +} + +#include "alarmdockwindow.moc" diff --git a/korganizer/korgac/alarmdockwindow.h b/korganizer/korgac/alarmdockwindow.h new file mode 100644 index 000000000..f73c667b6 --- /dev/null +++ b/korganizer/korgac/alarmdockwindow.h @@ -0,0 +1,72 @@ +/* + This file is part of KOrganizer. + + Copyright (c) 2003 Cornelius Schumacher + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + As a special exception, permission is given to link this program + with any edition of TQt, and distribute the resulting executable, + without including the source code for TQt in the source distribution. +*/ +#ifndef ALARMDOCKWINDOW_H +#define ALARMDOCKWINDOW_H + +#include + +#include + +class AlarmDockWindow : public KSystemTray +{ + Q_OBJECT + TQ_OBJECT + public: + AlarmDockWindow( const char *name = 0 ); + virtual ~AlarmDockWindow(); + + void enableAutostart( bool enabled ); + + public slots: + void toggleAlarmsEnabled(); + void toggleAutostart(); + void slotUpdate( int reminders ); + + signals: + void quitSignal(); + void suspendAllSignal(); + void dismissAllSignal(); + + protected: + void mousePressEvent( TQMouseEvent * ); +// void closeEvent( TQCloseEvent * ); + void resizeEvent ( TQResizeEvent * ); + + protected slots: + void slotQuit(); + void slotSuspendAll(); + void slotDismissAll(); + + private: + TQPixmap mPixmapEnabled; + TQPixmap mPixmapDisabled; + TQString mName; + + int mAlarmsEnabledId; + int mAutostartId; + int mSuspendAll; + int mDismissAll; +}; + +#endif diff --git a/korganizer/korgac/alarmdoctwindow.cpp b/korganizer/korgac/alarmdoctwindow.cpp deleted file mode 100644 index 85673ef03..000000000 --- a/korganizer/korgac/alarmdoctwindow.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* - This file is part of KOrganizer. - - Copyright (c) 2003 Cornelius Schumacher - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - As a special exception, permission is given to link this program - with any edition of TQt, and distribute the resulting executable, - without including the source code for TQt in the source distribution. -*/ - -#include "alarmdockwindow.h" -#include "koalarmclient.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -AlarmDockWindow::AlarmDockWindow( const char *name ) - : KSystemTray( 0, name ) -{ - // Read the autostart status from the config file - KConfig *config = kapp->config(); - config->setGroup("General"); - bool autostart = config->readBoolEntry( "Autostart", true ); - bool alarmsEnabled = config->readBoolEntry( "Enabled", true ); - - mName = i18n( "KOrganizer Reminder Daemon" ); - setCaption( mName ); - - // Set up icons - KGlobal::iconLoader()->addAppDir( "korgac" ); - mPixmapEnabled = loadSizedIcon( "korgac", width() ); - mPixmapDisabled = loadSizedIcon( "korgac_disabled", width() ); - - setPixmap( alarmsEnabled ? mPixmapEnabled : mPixmapDisabled ); - - // Set up the context menu - mSuspendAll = contextMenu()->insertItem( i18n("Suspend All"), this, TQT_SLOT( slotSuspendAll() ) ); - mDismissAll = contextMenu()->insertItem( i18n("Dismiss All"), this, TQT_SLOT( slotDismissAll() ) ); - contextMenu()->setItemEnabled( mSuspendAll, false ); - contextMenu()->setItemEnabled( mDismissAll, false ); - - contextMenu()->insertSeparator(); - mAlarmsEnabledId = contextMenu()->insertItem( i18n("Reminders Enabled"), this, - TQT_SLOT( toggleAlarmsEnabled() ) ); - mAutostartId = contextMenu()->insertItem( i18n("Start Reminder Daemon at Login"), this, - TQT_SLOT( toggleAutostart() ) ); - contextMenu()->setItemChecked( mAutostartId, autostart ); - contextMenu()->setItemChecked( mAlarmsEnabledId, alarmsEnabled ); - - // Disable standard quit behaviour. We have to intercept the quit even, if the - // main window is hidden. - KActionCollection *ac = actionCollection(); - const char *quitName = KStdAction::name( KStdAction::Quit ); - KAction *quit = ac->action( quitName ); - if ( !quit ) { - kdDebug(5890) << "No Quit standard action." << endl; - } else { -#if KDE_IS_VERSION(3,3,90) - quit->disconnect( TQT_SIGNAL( activated() ), this, - TQT_SLOT( maybeQuit() ) ); - connect( quit, TQT_SIGNAL( activated() ), TQT_SLOT( slotQuit() ) ); - } -#else //FIXME: remove for KDE 4.0 - quit->disconnect( TQT_SIGNAL( activated() ), tqApp, - TQT_SLOT( closeAllWindows() ) ); - } - connect( this, TQT_SIGNAL( quitSelected() ), TQT_SLOT( slotQuit() ) ); -#endif - - TQToolTip::add(this, mName ); -} - -AlarmDockWindow::~AlarmDockWindow() -{ -} - -void AlarmDockWindow::resizeEvent ( TQResizeEvent * ) -{ - // Honor Free Desktop specifications that allow for arbitrary system tray icon sizes - mPixmapEnabled = loadSizedIcon( "korgac", width() ); - mPixmapDisabled = loadSizedIcon( "korgac_disabled", width() ); - - KConfig *config = kapp->config(); - bool alarmsEnabled = config->readBoolEntry( "Enabled", true ); - setPixmap( alarmsEnabled ? mPixmapEnabled : mPixmapDisabled ); -} - -void AlarmDockWindow::slotUpdate( int reminders ) -{ - TQToolTip::remove( this ); - if ( reminders > 0 ) - { - TQToolTip::add( this, i18n( "There is 1 active reminder.", - "There are %n active reminders.", reminders ) ); - contextMenu()->setItemEnabled( mSuspendAll, true ); - contextMenu()->setItemEnabled( mDismissAll, true ); - } - else - { - TQToolTip::add( this, mName ); - contextMenu()->setItemEnabled( mSuspendAll, false ); - contextMenu()->setItemEnabled( mDismissAll, false ); - } -} - -void AlarmDockWindow::toggleAlarmsEnabled() -{ - kdDebug(5890) << "AlarmDockWindow::toggleAlarmsEnabled()" << endl; - - KConfig *config = kapp->config(); - config->setGroup( "General" ); - - bool enabled = !contextMenu()->isItemChecked( mAlarmsEnabledId ); - contextMenu()->setItemChecked( mAlarmsEnabledId, enabled ); - setPixmap( enabled ? mPixmapEnabled : mPixmapDisabled ); - - config->writeEntry( "Enabled", enabled ); - config->sync(); -} - -void AlarmDockWindow::toggleAutostart() -{ - bool autostart = !contextMenu()->isItemChecked( mAutostartId ); - - enableAutostart( autostart ); -} - -void AlarmDockWindow::slotSuspendAll() -{ - emit suspendAllSignal(); -} - -void AlarmDockWindow::slotDismissAll() -{ - emit dismissAllSignal(); -} - -void AlarmDockWindow::enableAutostart( bool enable ) -{ - KConfig *config = kapp->config(); - config->setGroup( "General" ); - config->writeEntry( "Autostart", enable ); - config->sync(); - - contextMenu()->setItemChecked( mAutostartId, enable ); -} - -void AlarmDockWindow::mousePressEvent( TQMouseEvent *e ) -{ - if ( e->button() == Qt::LeftButton ) { - kapp->startServiceByDesktopName( "korganizer", TQString() ); - } else { - KSystemTray::mousePressEvent( e ); - } -} - -//void AlarmDockWindow::closeEvent( TQCloseEvent * ) -void AlarmDockWindow::slotQuit() -{ - int result = KMessageBox::questionYesNoCancel( this, - i18n("Do you want to start the KOrganizer reminder daemon at login " - "(note that you will not get reminders whilst the daemon is not running)?"), - i18n("Close KOrganizer Reminder Daemon"), - i18n("Start"), i18n("Do Not Start"), - TQString::tqfromLatin1("AskForStartAtLogin") - ); - - bool autostart = true; - if ( result == KMessageBox::No ) autostart = false; - enableAutostart( autostart ); - - if ( result != KMessageBox::Cancel ) - emit quitSignal(); -} - -#include "alarmdockwindow.moc" diff --git a/korganizer/korgac/alarmdoctwindow.h b/korganizer/korgac/alarmdoctwindow.h deleted file mode 100644 index f73c667b6..000000000 --- a/korganizer/korgac/alarmdoctwindow.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - This file is part of KOrganizer. - - Copyright (c) 2003 Cornelius Schumacher - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - As a special exception, permission is given to link this program - with any edition of TQt, and distribute the resulting executable, - without including the source code for TQt in the source distribution. -*/ -#ifndef ALARMDOCKWINDOW_H -#define ALARMDOCKWINDOW_H - -#include - -#include - -class AlarmDockWindow : public KSystemTray -{ - Q_OBJECT - TQ_OBJECT - public: - AlarmDockWindow( const char *name = 0 ); - virtual ~AlarmDockWindow(); - - void enableAutostart( bool enabled ); - - public slots: - void toggleAlarmsEnabled(); - void toggleAutostart(); - void slotUpdate( int reminders ); - - signals: - void quitSignal(); - void suspendAllSignal(); - void dismissAllSignal(); - - protected: - void mousePressEvent( TQMouseEvent * ); -// void closeEvent( TQCloseEvent * ); - void resizeEvent ( TQResizeEvent * ); - - protected slots: - void slotQuit(); - void slotSuspendAll(); - void slotDismissAll(); - - private: - TQPixmap mPixmapEnabled; - TQPixmap mPixmapDisabled; - TQString mName; - - int mAlarmsEnabledId; - int mAutostartId; - int mSuspendAll; - int mDismissAll; -}; - -#endif -- cgit v1.2.1