diff options
Diffstat (limited to 'korganizer/korgac')
-rw-r--r-- | korganizer/korgac/Makefile.am | 28 | ||||
-rw-r--r-- | korganizer/korgac/alarmclientiface.h | 40 | ||||
-rw-r--r-- | korganizer/korgac/alarmdialog.cpp | 444 | ||||
-rw-r--r-- | korganizer/korgac/alarmdialog.h | 86 | ||||
-rw-r--r-- | korganizer/korgac/alarmdockwindow.cpp | 195 | ||||
-rw-r--r-- | korganizer/korgac/alarmdockwindow.h | 70 | ||||
-rw-r--r-- | korganizer/korgac/koalarmclient.cpp | 210 | ||||
-rw-r--r-- | korganizer/korgac/koalarmclient.h | 84 | ||||
-rw-r--r-- | korganizer/korgac/korgac.desktop | 98 | ||||
-rw-r--r-- | korganizer/korgac/korgacmain.cpp | 86 | ||||
-rw-r--r-- | korganizer/korgac/pixmaps/Makefile.am | 2 | ||||
-rw-r--r-- | korganizer/korgac/pixmaps/cr22-action-korgac.png | bin | 0 -> 1156 bytes | |||
-rw-r--r-- | korganizer/korgac/pixmaps/cr22-action-korgac_disabled.png | bin | 0 -> 758 bytes | |||
-rw-r--r-- | korganizer/korgac/testalarmdlg.cpp | 71 |
14 files changed, 1414 insertions, 0 deletions
diff --git a/korganizer/korgac/Makefile.am b/korganizer/korgac/Makefile.am new file mode 100644 index 000000000..ac56f3640 --- /dev/null +++ b/korganizer/korgac/Makefile.am @@ -0,0 +1,28 @@ +INCLUDES= -I$(top_srcdir) -I$(top_srcdir)/korganizer $(all_includes) + +bin_PROGRAMS = korgac + +korgac_LDFLAGS = $(all_libraries) $(KDE_RPATH) +korgac_LDADD = $(LIB_KDEUI) \ + $(top_builddir)/korganizer/libkorganizer_eventviewer.la +korgac_SOURCES = korgacmain.cpp alarmdialog.cpp \ + alarmdockwindow.cpp koalarmclient.cpp \ + alarmclientiface.skel + +check_PROGRAMS = testalarmdlg + +testalarmdlg_LDFLAGS = $(all_libraries) $(KDE_RPATH) +testalarmdlg_LDADD = $(LIB_KDEUI) $(top_builddir)/libkcal/libkcal.la \ + $(top_builddir)/korganizer/libkorganizer_eventviewer.la +testalarmdlg_SOURCES = testalarmdlg.cpp alarmdialog.cpp + +noinst_HEADERS = alarmclientiface.h alarmdialog.h \ + alarmdockwindow.h koalarmclient.h + +METASOURCES = AUTO + +SUBDIRS = pixmaps + +autostart_DATA = korgac.desktop +autostartdir = $(datadir)/autostart + diff --git a/korganizer/korgac/alarmclientiface.h b/korganizer/korgac/alarmclientiface.h new file mode 100644 index 000000000..c4edd9f43 --- /dev/null +++ b/korganizer/korgac/alarmclientiface.h @@ -0,0 +1,40 @@ +/* + This file is part of the KOrganizer alarm client. + + Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#ifndef ALARMCLIENTIFACE_H +#define ALARMCLIENTIFACE_H + +#include <dcopobject.h> +#include <qstringlist.h> + +class AlarmClientIface : virtual public DCOPObject +{ + K_DCOP + k_dcop: + virtual ASYNC quit() = 0; + + virtual ASYNC forceAlarmCheck() = 0; + virtual ASYNC dumpDebug() = 0; + virtual QStringList dumpAlarms() = 0; + + virtual void debugShowDialog() = 0; +}; + +#endif diff --git a/korganizer/korgac/alarmdialog.cpp b/korganizer/korgac/alarmdialog.cpp new file mode 100644 index 000000000..68e1822dc --- /dev/null +++ b/korganizer/korgac/alarmdialog.cpp @@ -0,0 +1,444 @@ +/* + This file is part of the KOrganizer alarm daemon. + + Copyright (c) 2000,2003 Cornelius Schumacher <schumacher@kde.org> + + 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 Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +#include <qhbox.h> +#include <qvbox.h> +#include <qlabel.h> +#include <qfile.h> +#include <qspinbox.h> +#include <qlayout.h> +#include <qpushbutton.h> +#include <qcstring.h> +#include <qdatastream.h> + +#include <kapplication.h> +#include <kconfig.h> +#include <kiconloader.h> +#include <dcopclient.h> +#include <klocale.h> +#include <kprocess.h> +#include <kaudioplayer.h> +#include <kdebug.h> +#include <kmessagebox.h> +#include <knotifyclient.h> +#include <kcombobox.h> +#include <klistview.h> +#include <kwin.h> +#include <klockfile.h> + +#include <libkcal/event.h> + +#include "koeventviewer.h" + +#include "alarmdialog.h" +#include "alarmdialog.moc" + +class AlarmListItem : public KListViewItem +{ + public: + AlarmListItem( Incidence *incidence, QListView *parent ) : + KListViewItem( parent ), + mIncidence( incidence->clone() ), + mNotified( false ) + {} + + ~AlarmListItem() + { + delete mIncidence; + } + + Incidence *mIncidence; + QDateTime mRemindAt; + bool mNotified; +}; + +typedef QValueList<AlarmListItem*> ItemList; + +AlarmDialog::AlarmDialog( QWidget *parent, const char *name ) + : KDialogBase( Plain, WType_TopLevel | WStyle_Customize | WStyle_StaysOnTop | + WStyle_DialogBorder, + parent, name, false, i18n("Reminder"), Ok | User1 | User2 | User3, User1/*3*/, + false, i18n("Dismiss all"), i18n("Edit..."), i18n("Suspend") ), + mSuspendTimer(this) +{ + KGlobal::iconLoader()->addAppDir( "kdepim" ); + setButtonOK( i18n( "Dismiss" ) ); + + QWidget *topBox = plainPage(); + QBoxLayout *topLayout = new QVBoxLayout( topBox ); + topLayout->setSpacing( spacingHint() ); + + QLabel *label = new QLabel( i18n("The following events triggered reminders:"), + topBox ); + topLayout->addWidget( label ); + + mIncidenceListView = new KListView( topBox ); + mIncidenceListView->addColumn( i18n( "Summary" ) ); + mIncidenceListView->addColumn( i18n( "Due" ) ); + mIncidenceListView->setAllColumnsShowFocus( true ); + mIncidenceListView->setSelectionMode( QListView::Extended ); + topLayout->addWidget( mIncidenceListView ); + connect( mIncidenceListView, SIGNAL(selectionChanged()), SLOT(updateButtons()) ); + connect( mIncidenceListView, SIGNAL(doubleClicked(QListViewItem*)), SLOT(slotUser2()) ); + connect( mIncidenceListView, SIGNAL(currentChanged(QListViewItem*)), SLOT(showDetails()) ); + connect( mIncidenceListView, SIGNAL(selectionChanged()), SLOT(showDetails()) ); + + mDetailView = new KOEventViewer( topBox ); + topLayout->addWidget( mDetailView ); + + QHBox *suspendBox = new QHBox( topBox ); + suspendBox->setSpacing( spacingHint() ); + topLayout->addWidget( suspendBox ); + + QLabel *l = new QLabel( i18n("Suspend &duration:"), suspendBox ); + mSuspendSpin = new QSpinBox( 1, 9999, 1, suspendBox ); + mSuspendSpin->setValue( 5 ); // default suspend duration + l->setBuddy( mSuspendSpin ); + + mSuspendUnit = new KComboBox( suspendBox ); + mSuspendUnit->insertItem( i18n("minute(s)") ); + mSuspendUnit->insertItem( i18n("hour(s)") ); + mSuspendUnit->insertItem( i18n("day(s)") ); + mSuspendUnit->insertItem( i18n("week(s)") ); + connect( &mSuspendTimer, SIGNAL(timeout()), SLOT(wakeUp()) ); + + // showButton( User2/*3*/, false ); + + setMinimumSize( 300, 200 ); +} + +AlarmDialog::~AlarmDialog() +{ + mIncidenceListView->clear(); +} + +void AlarmDialog::addIncidence( Incidence *incidence, const QDateTime &reminderAt ) +{ + AlarmListItem *item = new AlarmListItem( incidence, mIncidenceListView ); + item->setText( 0, incidence->summary() ); + item->mRemindAt = reminderAt; + Todo *todo; + if ( dynamic_cast<Event*>( incidence ) ) { + item->setPixmap( 0, SmallIcon( "appointment" ) ); + if ( incidence->doesRecur() ) { + QDateTime nextStart = incidence->recurrence()->getNextDateTime( reminderAt ); + if ( nextStart.isValid() ) + item->setText( 1, KGlobal::locale()->formatDateTime( nextStart ) ); + } + if ( item->text( 1 ).isEmpty() ) + item->setText( 1, incidence->dtStartStr() ); + } else if ( (todo = dynamic_cast<Todo*>( incidence )) ) { + item->setPixmap( 0, SmallIcon( "todo" ) ); + item->setText( 1, todo->dtDueStr() ); + } + if ( activeCount() == 1 ) {// previously empty + mIncidenceListView->clearSelection(); + item->setSelected( true ); + } + showDetails(); +} + +void AlarmDialog::slotOk() +{ + ItemList selection = selectedItems(); + for ( ItemList::Iterator it = selection.begin(); it != selection.end(); ++it ) { + if ( (*it)->itemBelow() ) + (*it)->itemBelow()->setSelected( true ); + else if ( (*it)->itemAbove() ) + (*it)->itemAbove()->setSelected( true ); + delete *it; + } + if ( activeCount() == 0 ) + accept(); + else { + updateButtons(); + showDetails(); + } + emit reminderCount( activeCount() ); +} + +void AlarmDialog::slotUser1() +{ + dismissAll(); +} + +void AlarmDialog::suspend() +{ + if ( !isVisible() ) + return; + + int unit=1; + switch (mSuspendUnit->currentItem()) { + case 3: // weeks + unit *= 7; + case 2: // days + unit *= 24; + case 1: // hours + unit *= 60; + case 0: // minutes + unit *= 60; + default: + break; + } + + for ( QListViewItemIterator it( mIncidenceListView ) ; it.current() ; ++it ) { + AlarmListItem * item = static_cast<AlarmListItem*>( it.current() ); + if ( item->isSelected() && item->isVisible() ) { + item->setVisible( false ); + item->setSelected( false ); + item->mRemindAt = QDateTime::currentDateTime().addSecs( unit * mSuspendSpin->value() ); + item->mNotified = false; + } + } + + setTimer(); + if ( activeCount() == 0 ) + accept(); + else { + updateButtons(); + showDetails(); + } + emit reminderCount( activeCount() ); +} + +void AlarmDialog::setTimer() +{ + int nextReminderAt = -1; + for ( QListViewItemIterator it( mIncidenceListView ) ; it.current() ; ++it ) { + AlarmListItem * item = static_cast<AlarmListItem*>( it.current() ); + if ( item->mRemindAt > QDateTime::currentDateTime() ) { + int secs = QDateTime::currentDateTime().secsTo( item->mRemindAt ); + nextReminderAt = nextReminderAt <= 0 ? secs : QMIN( nextReminderAt, secs ); + } + } + + if ( nextReminderAt >= 0 ) { + mSuspendTimer.stop(); + mSuspendTimer.start( 1000 * (nextReminderAt + 1), true ); + } +} + +void AlarmDialog::slotUser2() +{ + ItemList selection = selectedItems(); + if ( selection.count() != 1 ) + return; + Incidence *incidence = selection.first()->mIncidence; + + if ( !kapp->dcopClient()->isApplicationRegistered( "korganizer" ) ) { + if ( kapp->startServiceByDesktopName( "korganizer", QString::null ) ) + KMessageBox::error( 0, i18n("Could not start KOrganizer.") ); + } + + kapp->dcopClient()->send( "korganizer", "KOrganizerIface", + "editIncidence(QString)", + incidence->uid() ); + + // get desktop # where korganizer (or kontact) runs + QByteArray replyData; + QCString object, replyType; + object = kapp->dcopClient()->isApplicationRegistered( "kontact" ) ? + "kontact-mainwindow#1" : "KOrganizer MainWindow"; + if (!kapp->dcopClient()->call( "korganizer", object, + "getWinID()", 0, replyType, replyData, true, -1 ) ) { + } + + if ( replyType == "int" ) { + int desktop, window; + QDataStream ds( replyData, IO_ReadOnly ); + ds >> window; + desktop = KWin::windowInfo( window ).desktop(); + + if ( KWin::currentDesktop() == desktop ) { + KWin::iconifyWindow( winId(), false ); + } + else + KWin::setCurrentDesktop( desktop ); + + KWin::activateWindow( KWin::transientFor( window ) ); + } +} + +void AlarmDialog::slotUser3() +{ + suspend(); +} + +void AlarmDialog::dismissAll() +{ + for ( QListViewItemIterator it( mIncidenceListView ) ; it.current() ; ) { + AlarmListItem *item = static_cast<AlarmListItem*>( it.current() ); + if ( !item->isVisible() ) { + ++it; + continue; + } + delete item; + } + setTimer(); + accept(); + emit reminderCount( activeCount() ); +} + +void AlarmDialog::show() +{ + mIncidenceListView->clearSelection(); + if ( mIncidenceListView->firstChild() ) + mIncidenceListView->firstChild()->setSelected( true ); + updateButtons(); + KDialogBase::show(); + KWin::setState( winId(), NET::KeepAbove ); + KWin::setOnAllDesktops( winId(), true ); + eventNotification(); +} + +void AlarmDialog::eventNotification() +{ + bool beeped = false, found = false; + + QValueList<AlarmListItem*> list; + for ( QListViewItemIterator it( mIncidenceListView ) ; it.current() ; ++it ) { + AlarmListItem *item = static_cast<AlarmListItem*>( it.current() ); + if ( !item->isVisible() || item->mNotified ) + continue; + found = true; + item->mNotified = true; + Alarm::List alarms = item->mIncidence->alarms(); + Alarm::List::ConstIterator it; + for ( it = alarms.begin(); it != alarms.end(); ++it ) { + Alarm *alarm = *it; + // FIXME: Check whether this should be done for all multiple alarms + if (alarm->type() == Alarm::Procedure) { + // FIXME: Add a message box asking whether the procedure should really be executed + kdDebug(5890) << "Starting program: '" << alarm->programFile() << "'" << endl; + KProcess proc; + proc << QFile::encodeName(alarm->programFile()); + proc.start(KProcess::DontCare); + } + else if (alarm->type() == Alarm::Audio) { + beeped = true; + KAudioPlayer::play(QFile::encodeName(alarm->audioFile())); + } + } + } + + if ( !beeped && found ) { + KNotifyClient::beep(); + } +} + +void AlarmDialog::wakeUp() +{ + bool activeReminders = false; + for ( QListViewItemIterator it( mIncidenceListView ) ; it.current() ; ++it ) { + AlarmListItem * item = static_cast<AlarmListItem*>( it.current() ); + if ( item->mRemindAt <= QDateTime::currentDateTime() ) { + if ( !item->isVisible() ) { + item->setVisible( true ); + item->setSelected( false ); + } + activeReminders = true; + } else { + item->setVisible( false ); + } + } + + if ( activeReminders ) + show(); + setTimer(); + showDetails(); + emit reminderCount( activeCount() ); +} + +void AlarmDialog::slotSave() +{ + KConfig *config = kapp->config(); + KLockFile::Ptr lock = config->lockFile(); + if ( lock.data()->lock() != KLockFile::LockOK ) + return; + + config->setGroup( "General" ); + int numReminders = config->readNumEntry("Reminders", 0); + + for ( QListViewItemIterator it( mIncidenceListView ) ; it.current() ; ++it ) { + AlarmListItem * item = static_cast<AlarmListItem*>( it.current() ); + config->setGroup( QString("Incidence-%1").arg(numReminders) ); + config->writeEntry( "UID", item->mIncidence->uid() ); + config->writeEntry( "RemindAt", item->mRemindAt ); + ++numReminders; + } + + config->setGroup( "General" ); + config->writeEntry( "Reminders", numReminders ); + config->sync(); + lock.data()->unlock(); +} + +void AlarmDialog::updateButtons() +{ + ItemList selection = selectedItems(); + enableButton( User2, selection.count() == 1 ); + enableButton( Ok, selection.count() > 0 ); + enableButton( User3, selection.count() > 0 ); +} + +QValueList< AlarmListItem * > AlarmDialog::selectedItems() const +{ + QValueList<AlarmListItem*> list; + for ( QListViewItemIterator it( mIncidenceListView ) ; it.current() ; ++it ) { + if ( it.current()->isSelected() ) + list.append( static_cast<AlarmListItem*>( it.current() ) ); + } + return list; +} + +int AlarmDialog::activeCount() +{ + int count = 0; + for ( QListViewItemIterator it( mIncidenceListView ) ; it.current() ; ++it ) { + AlarmListItem * item = static_cast<AlarmListItem*>( it.current() ); + if ( item->isVisible() ) + ++count; + } + return count; +} + +void AlarmDialog::suspendAll() +{ + mIncidenceListView->clearSelection(); + for ( QListViewItemIterator it( mIncidenceListView ) ; it.current() ; ++it ) { + if ( it.current()->isVisible() ) + it.current()->setSelected( true ); + } + suspend(); +} + +void AlarmDialog::showDetails() +{ + mDetailView->clearEvents( true ); + mDetailView->clear(); + AlarmListItem *item = static_cast<AlarmListItem*>( mIncidenceListView->currentItem() ); + if ( !item || !item->isVisible() ) + return; + mDetailView->appendIncidence( item->mIncidence ); +} diff --git a/korganizer/korgac/alarmdialog.h b/korganizer/korgac/alarmdialog.h new file mode 100644 index 000000000..085ae8a9b --- /dev/null +++ b/korganizer/korgac/alarmdialog.h @@ -0,0 +1,86 @@ +/* + This file is part of the KDE alarm daemon. + Copyright (c) 2000 Cornelius Schumacher <schumacher@kde.org> + + 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 Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ +#ifndef ALARMDIALOG_H +#define ALARMDIALOG_H +// +// Alarm dialog. +// +#include <qtimer.h> +#include <qdatetime.h> + +#include <kdialogbase.h> + +#include <libkcal/event.h> +#include <libkcal/calendarlocal.h> + +using namespace KCal; + +class KOEventViewer; +class QSpinBox; +class KComboBox; +class KListView; +class AlarmListItem; + +class AlarmDialog : public KDialogBase { + Q_OBJECT + public: + AlarmDialog( QWidget *parent = 0, const char *name = 0 ); + virtual ~AlarmDialog(); + + void addIncidence( Incidence *incidence, const QDateTime &reminderAt ); + void eventNotification(); + + public slots: + void slotOk(); + void slotUser1(); + void slotUser2(); + void slotUser3(); + void slotSave(); + void wakeUp(); + void show(); + void suspend(); + void suspendAll(); + void dismissAll(); + + signals: + void reminderCount( int count ); + + private slots: + void updateButtons(); + void showDetails(); + + private: + bool startKOrganizer(); + void setTimer(); + int activeCount(); + QValueList<AlarmListItem*> selectedItems() const; + + KListView *mIncidenceListView; + KOEventViewer *mDetailView; + + QSpinBox *mSuspendSpin; + KComboBox *mSuspendUnit; + QTimer mSuspendTimer; +}; + +#endif diff --git a/korganizer/korgac/alarmdockwindow.cpp b/korganizer/korgac/alarmdockwindow.cpp new file mode 100644 index 000000000..5f2c419c7 --- /dev/null +++ b/korganizer/korgac/alarmdockwindow.cpp @@ -0,0 +1,195 @@ +/* + This file is part of KOrganizer. + + Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> + + 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 Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +#include "alarmdockwindow.h" +#include "koalarmclient.h" + +#include <kapplication.h> +#include <kdebug.h> +#include <kdeversion.h> +#include <klocale.h> +#include <kiconloader.h> +#include <kconfig.h> +#include <kurl.h> +#include <kstandarddirs.h> +#include <dcopclient.h> +#include <kpopupmenu.h> +#include <kmessagebox.h> +#include <kaction.h> +#include <kstdaction.h> + +#include <qtooltip.h> +#include <qfile.h> + +#include <stdlib.h> + +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 = loadIcon( "korgac" ); + mPixmapDisabled = loadIcon( "korgac_disabled" ); + + setPixmap( alarmsEnabled ? mPixmapEnabled : mPixmapDisabled ); + + // Set up the context menu + mSuspendAll = contextMenu()->insertItem( i18n("Suspend All"), this, SLOT( slotSuspendAll() ) ); + mDismissAll = contextMenu()->insertItem( i18n("Dismiss All"), this, SLOT( slotDismissAll() ) ); + contextMenu()->setItemEnabled( mSuspendAll, false ); + contextMenu()->setItemEnabled( mDismissAll, false ); + + contextMenu()->insertSeparator(); + mAlarmsEnabledId = contextMenu()->insertItem( i18n("Reminders Enabled"), this, + SLOT( toggleAlarmsEnabled() ) ); + mAutostartId = contextMenu()->insertItem( i18n("Start Reminder Daemon at Login"), this, + 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( SIGNAL( activated() ), this, + SLOT( maybeQuit() ) ); + connect( quit, SIGNAL( activated() ), SLOT( slotQuit() ) ); + } +#else //FIXME: remove for KDE 4.0 + quit->disconnect( SIGNAL( activated() ), qApp, + SLOT( closeAllWindows() ) ); + } + connect( this, SIGNAL( quitSelected() ), SLOT( slotQuit() ) ); +#endif + + QToolTip::add(this, mName ); +} + +AlarmDockWindow::~AlarmDockWindow() +{ +} + +void AlarmDockWindow::slotUpdate( int reminders ) +{ + QToolTip::remove( this ); + if ( reminders > 0 ) + { + QToolTip::add( this, i18n( "There is 1 active reminder.", + "There are %n active reminders.", reminders ) ); + contextMenu()->setItemEnabled( mSuspendAll, true ); + contextMenu()->setItemEnabled( mDismissAll, true ); + } + else + { + QToolTip::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( QMouseEvent *e ) +{ + if ( e->button() == LeftButton ) { + kapp->startServiceByDesktopName( "korganizer", QString::null ); + } else { + KSystemTray::mousePressEvent( e ); + } +} + +//void AlarmDockWindow::closeEvent( QCloseEvent * ) +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"), + QString::fromLatin1("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..5671b92f7 --- /dev/null +++ b/korganizer/korgac/alarmdockwindow.h @@ -0,0 +1,70 @@ +/* + This file is part of KOrganizer. + + Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> + + 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 Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ +#ifndef ALARMDOCKWINDOW_H +#define ALARMDOCKWINDOW_H + +#include <ksystemtray.h> + +#include <qpixmap.h> + +class AlarmDockWindow : public KSystemTray +{ + Q_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( QMouseEvent * ); +// void closeEvent( QCloseEvent * ); + + protected slots: + void slotQuit(); + void slotSuspendAll(); + void slotDismissAll(); + + private: + QPixmap mPixmapEnabled; + QPixmap mPixmapDisabled; + QString mName; + + int mAlarmsEnabledId; + int mAutostartId; + int mSuspendAll; + int mDismissAll; +}; + +#endif diff --git a/korganizer/korgac/koalarmclient.cpp b/korganizer/korgac/koalarmclient.cpp new file mode 100644 index 000000000..c4ef2de82 --- /dev/null +++ b/korganizer/korgac/koalarmclient.cpp @@ -0,0 +1,210 @@ +/* + KOrganizer Alarm Daemon Client. + + This file is part of KOrganizer. + + Copyright (c) 2002,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 Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +#include "koalarmclient.h" + +#include "alarmdockwindow.h" +#include "alarmdialog.h" + +#include <libkcal/calendarresources.h> + +#include <kstandarddirs.h> +#include <kdebug.h> +#include <klocale.h> +#include <kapplication.h> +#include <kwin.h> + +#include <qpushbutton.h> + +KOAlarmClient::KOAlarmClient( QObject *parent, const char *name ) + : DCOPObject( "ac" ), QObject( parent, name ), mDialog( 0 ) +{ + kdDebug(5890) << "KOAlarmClient::KOAlarmClient()" << endl; + + mDocker = new AlarmDockWindow; + mDocker->show(); + connect( this, SIGNAL( reminderCount( int ) ), mDocker, SLOT( slotUpdate( int ) ) ); + connect( mDocker, SIGNAL( quitSignal() ), SLOT( slotQuit() ) ); + + KConfig c( locate( "config", "korganizerrc" ) ); + c.setGroup( "Time & Date" ); + QString tz = c.readEntry( "TimeZoneId" ); + kdDebug(5890) << "TimeZone: " << tz << endl; + + mCalendar = new CalendarResources( tz ); + mCalendar->readConfig(); + mCalendar->load(); + + connect( &mCheckTimer, SIGNAL( timeout() ), SLOT( checkAlarms() ) ); + + KConfig *config = kapp->config(); + config->setGroup( "Alarms" ); + int interval = config->readNumEntry( "Interval", 60 ); + kdDebug(5890) << "KOAlarmClient check interval: " << interval << " seconds." + << endl; + mLastChecked = config->readDateTimeEntry( "CalendarsLastChecked" ); + + // load reminders that were active when quitting + config->setGroup( "General" ); + int numReminders = config->readNumEntry( "Reminders", 0 ); + for ( int i=1; i<=numReminders; ++i ) + { + QString group( QString( "Incidence-%1" ).arg( i ) ); + config->setGroup( group ); + QString uid = config->readEntry( "UID" ); + QDateTime dt = config->readDateTimeEntry( "RemindAt" ); + if ( !uid.isEmpty() ) + createReminder( mCalendar->incidence( uid ), dt ); + config->deleteGroup( group ); + } + config->setGroup( "General" ); + if (numReminders) { + config->writeEntry( "Reminders", 0 ); + config->sync(); + } + + checkAlarms(); + mCheckTimer.start( 1000 * interval ); // interval in seconds +} + +KOAlarmClient::~KOAlarmClient() +{ + delete mCalendar; + delete mDocker; + delete mDialog; +} + +void KOAlarmClient::checkAlarms() +{ + KConfig *cfg = kapp->config(); + + cfg->setGroup( "General" ); + if ( !cfg->readBoolEntry( "Enabled", true ) ) return; + + QDateTime from = mLastChecked.addSecs( 1 ); + mLastChecked = QDateTime::currentDateTime(); + + kdDebug(5891) << "Check: " << from.toString() << " - " << mLastChecked.toString() << endl; + + QValueList<Alarm *> alarms = mCalendar->alarms( from, mLastChecked ); + + QValueList<Alarm *>::ConstIterator it; + for( it = alarms.begin(); it != alarms.end(); ++it ) { + kdDebug(5891) << "REMINDER: " << (*it)->parent()->summary() << endl; + Incidence *incidence = mCalendar->incidence( (*it)->parent()->uid() ); + createReminder( incidence, QDateTime::currentDateTime() ); + } +} + +void KOAlarmClient::createReminder( KCal::Incidence *incidence, QDateTime dt ) +{ + if ( !incidence ) + return; + + if ( !mDialog ) { + mDialog = new AlarmDialog(); + connect( mDialog, SIGNAL(reminderCount(int)), mDocker, SLOT(slotUpdate(int)) ); + connect( mDocker, SIGNAL(suspendAllSignal()), mDialog, SLOT(suspendAll()) ); + connect( mDocker, SIGNAL(dismissAllSignal()), mDialog, SLOT(dismissAll()) ); + connect( this, SIGNAL( saveAllSignal() ), mDialog, SLOT( slotSave() ) ); + } + + mDialog->addIncidence( incidence, dt ); + mDialog->wakeUp(); + saveLastCheckTime(); +} + +void KOAlarmClient::slotQuit() +{ + emit saveAllSignal(); + saveLastCheckTime(); + quit(); +} + +void KOAlarmClient::saveLastCheckTime() +{ + KConfigGroup cg( KGlobal::config(), "Alarms"); + cg.writeEntry( "CalendarsLastChecked", mLastChecked ); + KGlobal::config()->sync(); +} + +void KOAlarmClient::quit() +{ + kdDebug(5890) << "KOAlarmClient::quit()" << endl; + kapp->quit(); +} + +bool KOAlarmClient::commitData( QSessionManager& ) +{ + emit saveAllSignal(); + saveLastCheckTime(); + return true; +} + +void KOAlarmClient::forceAlarmCheck() +{ + checkAlarms(); + saveLastCheckTime(); +} + +void KOAlarmClient::dumpDebug() +{ + KConfig *cfg = kapp->config(); + + cfg->setGroup( "Alarms" ); + QDateTime lastChecked = cfg->readDateTimeEntry( "CalendarsLastChecked" ); + + kdDebug(5890) << "Last Check: " << lastChecked << endl; +} + +QStringList KOAlarmClient::dumpAlarms() +{ + QDateTime start = QDateTime( QDateTime::currentDateTime().date(), + QTime( 0, 0 ) ); + QDateTime end = start.addDays( 1 ).addSecs( -1 ); + + QStringList lst; + // Don't translate, this is for debugging purposes. + lst << QString("AlarmDeamon::dumpAlarms() from ") + start.toString()+ " to " + + end.toString(); + + QValueList<Alarm*> alarms = mCalendar->alarms( start, end ); + QValueList<Alarm*>::ConstIterator it; + for( it = alarms.begin(); it != alarms.end(); ++it ) { + Alarm *a = *it; + lst << QString(" ") + a->parent()->summary() + " (" + + a->time().toString() + ")"; + } + + return lst; +} + +void KOAlarmClient::debugShowDialog() +{ +// showAlarmDialog(); +} + +#include "koalarmclient.moc" diff --git a/korganizer/korgac/koalarmclient.h b/korganizer/korgac/koalarmclient.h new file mode 100644 index 000000000..241a3eda8 --- /dev/null +++ b/korganizer/korgac/koalarmclient.h @@ -0,0 +1,84 @@ +/* + KOrganizer Alarm Daemon Client. + + This file is part of KOrganizer. + + Copyright (c) 2002,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 Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ +#ifndef KOALARMCLIENT_H +#define KOALARMCLIENT_H + +#include "alarmclientiface.h" + +#include <kapplication.h> + +#include <qtimer.h> +#include <qdatetime.h> + +class AlarmDialog; +class AlarmDockWindow; + +namespace KCal { +class CalendarResources; +class Incidence; +} + +class KOAlarmClient : public QObject, virtual public AlarmClientIface, public KSessionManaged +{ + Q_OBJECT + public: + KOAlarmClient( QObject *parent = 0, const char *name = 0 ); + ~KOAlarmClient(); + + bool commitData( QSessionManager & ); + + // DCOP interface + void quit(); + void forceAlarmCheck(); + void dumpDebug(); + QStringList dumpAlarms(); + + void debugShowDialog(); + + public slots: + void slotQuit(); + + protected slots: + void checkAlarms(); + + signals: + void reminderCount( int ); + void saveAllSignal(); + + private: + void createReminder( KCal::Incidence *incidence, QDateTime dt ); + void saveLastCheckTime(); + + AlarmDockWindow *mDocker; // the panel icon + KCal::CalendarResources *mCalendar; + + QDateTime mLastChecked; + QTimer mCheckTimer; + + AlarmDialog *mDialog; +}; + +#endif diff --git a/korganizer/korgac/korgac.desktop b/korganizer/korgac/korgac.desktop new file mode 100644 index 000000000..cad7d7e5e --- /dev/null +++ b/korganizer/korgac/korgac.desktop @@ -0,0 +1,98 @@ +# KDE Config File +[Desktop Entry] +Name=KOrganizer Reminder Client +Name[af]=KOrganizer herhinner kliënt +Name[ar]=زبون المنبه لِــ KOrganizer +Name[bg]=Аларма на KOrganizer +Name[ca]=Client de l'alarma de KOrganizer +Name[cs]=Klient upomínek KOrganizeru +Name[da]=KOrganizer-påmindelsesklient +Name[de]=KOrganizer Erinnerungsfunktion +Name[el]=Πελάτης υπενθύμισης του KOrganizer +Name[eo]=Alarmilo por Organizilo +Name[es]=Cliente de recordatorio para KOrganizer +Name[et]=KOrganizeri meeldetuletuse klientprogramm +Name[eu]=KOrganizer-en oroigarrien bezeroa +Name[fa]=کارخواه یادآوریکنندۀ KOrganizer +Name[fi]=KOrganizer-hälytysasiakas +Name[fr]=Client d'alarme de KOrganizer +Name[fy]=KOrganizer omtinkerdaemon +Name[gl]=Cliente de Lembranzas de KOrganizer +Name[hu]=KOrganizer-emlékeztető kliens +Name[is]=Áminningarforrit fyrir KOrganizer +Name[it]=Client degli avvisi di KOrganizer +Name[ja]=KOrganizer リマインダクライアント +Name[ka]=KOrganizer შემხსენებელის კლიენტი +Name[kk]=KOrganizer-дің еске салу клиенті +Name[km]=កម្មវិធីរំលឹករបស់ KOrganizer +Name[lt]=KOrganizer priminimų klientas +Name[mk]=Клиент за потсетување во КОрганизатор +Name[nb]=KOrganizer klient for påminning +Name[nds]=KOrganizer-Anstöötgever +Name[ne]=केडीई आयोजक रिमाइन्डर क्लाइन्ट +Name[nl]=KOrganizer herinneringsdaemon +Name[nn]=Alarmklient for KOrganizer +Name[pl]=Klient przypominania KOrganizera +Name[pt]=Cliente de Avisos do KOrganizer +Name[pt_BR]=Cliente do Alarme do KOrganizer +Name[ru]=Уведомления KOrganizer +Name[sk]=Klient pripomienok pre KOrganizer +Name[sl]=Odjemalec za opomnik KOrganizerja +Name[sr]=Клијент подсетника KOrganizer-а +Name[sr@Latn]=Klijent podsetnika KOrganizer-a +Name[sv]=Korganizer-påminnelseklient +Name[tr]=KOrganizer Hatırlatma İstemcisi +Name[uk]=Клієнт нагадувань KOrganizer +Name[zh_CN]=KOrganizer 定时器客户端程序 +Name[zh_TW]=KOrganizer 提醒客戶端程式 +Exec=korgac --miniicon korganizer +Icon=korganizer +Type=Application +GenericName=KOrganizer Reminder Daemon Client +GenericName[af]=Korganizer herhinner bediener kliënt +GenericName[bg]=Демон за алармата на KOrganizer +GenericName[ca]=Client del dimoni d'alarma de KOrganizer +GenericName[cs]=Klient démona přípomínek KOrganizeru +GenericName[da]=KOrganizer-påmindelsesklient +GenericName[de]=Hintergrund-Erinnerungsfunktion für KOrganizer +GenericName[el]=Δαίμονας πελάτη υπενθύμισης του KOrganizer +GenericName[eo]=Kliento por la alarmo-demono de Organizilo +GenericName[es]=Cliente del daemon de recordatorio para KOrganizer +GenericName[et]=KOrganizeri meeldetuletusdeemoni klientprogramm +GenericName[eu]=KOrganizer-en oroigarrien deabruaren bezeroa +GenericName[fa]=کارخواه شبح یادآوری KOrganizer +GenericName[fi]=KOrganizer hälytyspalvelimen asiakas +GenericName[fr]=Client pour le démon d'alarme de KOrganizer +GenericName[fy]=KOrganizer omtinkerdaemon +GenericName[gl]=Daemon do Cliente de Lembranzas de KOrganizer +GenericName[hu]=KOrganizer emlékeztető szolgáltatás kliense +GenericName[is]=Áminningarpúki fyrir KOrganizer +GenericName[it]=Client del demone degli avvisi di KOrganizer +GenericName[ja]=KOrganizer リマインダデーモンクライアント +GenericName[ka]=KOrganizer შემხსენებელის დემონის კლიენტი +GenericName[kk]=Organizer-дің еске салу қызметінің клиенті +GenericName[km]=កម្មវិធីដេមិនអ្នករំលឹករបស់ KOrganizer +GenericName[lt]=KOrganizer priminimų tarnybos klientas +GenericName[nb]=KOrganizer klient for påminningstjenesten +GenericName[nds]=Client för den Anstötendämoon vun KOrganizer +GenericName[ne]=केडीई आयोजक रिमाइन्डर डेइमन क्लाइन्ट +GenericName[nl]=KOrganizer herinneringsdaemon +GenericName[nn]=Alarmnisseklient for KOrganizer +GenericName[pl]=Klient demona przypominania KOrganizera +GenericName[pt]=Cliente do Servidor de Avisos do KOrganizer +GenericName[pt_BR]=Cliente do Servidor de Alarme do KOrganizer +GenericName[ru]=Клиент службы уведомлений KOrganizer +GenericName[sk]=Klient KOrganizer pre démona pripomienok +GenericName[sl]=Pritajeni odjemalec za opomnik KOrganizerja +GenericName[sr]=Клијент демона подсетника KOrganizer-а +GenericName[sr@Latn]=Klijent demona podsetnika KOrganizer-a +GenericName[sv]=Korganizer-alarmdemonklient +GenericName[tr]=KOrganizer Hatırlatma Servisi İstemcisi +GenericName[uk]=Демон клієнта нагадування для KOrganizer +GenericName[zh_CN]=KOrganizer 定时守护进程的客户端程序 +GenericName[zh_TW]=KOrganizr 提醒守護程式客戶端 +Terminal=false +X-KDE-autostart-after=panel +X-KDE-autostart-condition=korgacrc:General:Autostart:true +NoDisplay=true +OnlyShowIn=KDE; diff --git a/korganizer/korgac/korgacmain.cpp b/korganizer/korgac/korgacmain.cpp new file mode 100644 index 000000000..b4c9df7f6 --- /dev/null +++ b/korganizer/korgac/korgacmain.cpp @@ -0,0 +1,86 @@ +/* + This file is part of the KOrganizer alarm client. + + Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> + + 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 Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +#include <stdlib.h> + +#include <kglobal.h> +#include <kdebug.h> +#include <klocale.h> +#include <kcmdlineargs.h> +#include <kaboutdata.h> +#include <kuniqueapplication.h> + +#include "koalarmclient.h" + +class MyApp : public KUniqueApplication +{ + public: + MyApp() : mClient( 0 ) {} + int newInstance() + { + // Check if we already have a running alarm daemon widget + if ( mClient ) return 0; + + mClient = new KOAlarmClient; + + return 0; + } + + private: + KOAlarmClient *mClient; +}; + + +static const char korgacVersion[] = "0.9"; + +static const KCmdLineOptions options[] = +{ + { 0, 0, 0 } +}; + +int main( int argc, char **argv ) +{ + KLocale::setMainCatalogue( "korganizer" ); + KAboutData aboutData( "korgac", I18N_NOOP("KOrganizer Reminder Daemon"), + korgacVersion, I18N_NOOP("KOrganizer Reminder Daemon"), + KAboutData::License_GPL, + "(c) 2003 Cornelius Schumacher", + 0, "http://pim.kde.org" ); + aboutData.addAuthor( "Cornelius Schumacher", I18N_NOOP("Maintainer"), + "schumacher@kde.org" ); + aboutData.addAuthor( "Reinhold Kainhofer", I18N_NOOP("Maintainer"), + "kainhofer@kde.org" ); + + KCmdLineArgs::init( argc, argv, &aboutData ); + KCmdLineArgs::addCmdLineOptions( options ); + KUniqueApplication::addCmdLineOptions(); + + if ( !MyApp::start() ) exit( 0 ); + + MyApp app; + app.disableSessionManagement(); + KGlobal::locale()->insertCatalogue( "libkcal" ); + + return app.exec(); +} diff --git a/korganizer/korgac/pixmaps/Makefile.am b/korganizer/korgac/pixmaps/Makefile.am new file mode 100644 index 000000000..504e613ac --- /dev/null +++ b/korganizer/korgac/pixmaps/Makefile.am @@ -0,0 +1,2 @@ +korgacicondir = $(kde_datadir)/korgac/icons +korgacicon_ICON = AUTO diff --git a/korganizer/korgac/pixmaps/cr22-action-korgac.png b/korganizer/korgac/pixmaps/cr22-action-korgac.png Binary files differnew file mode 100644 index 000000000..304a02b10 --- /dev/null +++ b/korganizer/korgac/pixmaps/cr22-action-korgac.png diff --git a/korganizer/korgac/pixmaps/cr22-action-korgac_disabled.png b/korganizer/korgac/pixmaps/cr22-action-korgac_disabled.png Binary files differnew file mode 100644 index 000000000..fa1ae2852 --- /dev/null +++ b/korganizer/korgac/pixmaps/cr22-action-korgac_disabled.png diff --git a/korganizer/korgac/testalarmdlg.cpp b/korganizer/korgac/testalarmdlg.cpp new file mode 100644 index 000000000..69352a175 --- /dev/null +++ b/korganizer/korgac/testalarmdlg.cpp @@ -0,0 +1,71 @@ +/* + This file is part of KOrganizer. + + Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> + + 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 Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +#include <qwidget.h> + +#include <kaboutdata.h> +#include <kapplication.h> +#include <kdebug.h> +#include <klocale.h> +#include <kcmdlineargs.h> + +#include "alarmdialog.h" + +int main(int argc,char **argv) +{ + KAboutData aboutData("testkabc",I18N_NOOP("TestKabc"),"0.1"); + KCmdLineArgs::init(argc,argv,&aboutData); + + KApplication app; + + Event *e1 = new Event; + e1->setSummary( "This is a summary." ); + QDateTime now = QDateTime::currentDateTime(); + e1->setDtStart( now ); + e1->setDtEnd( now.addDays( 1 ) ); + Alarm *a = e1->newAlarm(); +// a->setProcedureAlarm( "/usr/X11R6/bin/xeyes" ); + a->setAudioAlarm( "/opt/kde/share/apps/korganizer/sounds/spinout.wav" ); + + Todo *t1 = new Todo; + t1->setSummary( "To-do A" ); + t1->setDtDue( now ); + t1->newAlarm(); + + Event *e2 = new Event; + e2->setSummary( "This is another summary." ); + e2->setDtStart( now ); + e2->setDtEnd( now.addDays( 1 ) ); + e2->newAlarm(); + + AlarmDialog dlg; + app.setMainWidget( &dlg ); + dlg.addIncidence( e1, QDateTime::currentDateTime() ); + dlg.addIncidence( t1, QDateTime::currentDateTime() ); + dlg.addIncidence( e2, QDateTime::currentDateTime() ); + dlg.show(); + dlg.eventNotification(); + + app.exec(); +} |