summaryrefslogtreecommitdiffstats
path: root/ktimer
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit2bda8f7717adf28da4af0d34fb82f63d2868c31d (patch)
tree8d927b7b47a90c4adb646482a52613f58acd6f8c /ktimer
downloadtdeutils-2bda8f7717adf28da4af0d34fb82f63d2868c31d.tar.gz
tdeutils-2bda8f7717adf28da4af0d34fb82f63d2868c31d.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeutils@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'ktimer')
-rw-r--r--ktimer/Makefile.am24
-rw-r--r--ktimer/hi128-app-ktimer.pngbin0 -> 17753 bytes
-rw-r--r--ktimer/hi16-app-ktimer.pngbin0 -> 875 bytes
-rw-r--r--ktimer/hi32-app-ktimer.pngbin0 -> 2458 bytes
-rw-r--r--ktimer/hi48-app-ktimer.pngbin0 -> 4736 bytes
-rw-r--r--ktimer/ktimer.cpp516
-rw-r--r--ktimer/ktimer.desktop63
-rw-r--r--ktimer/ktimer.h113
-rw-r--r--ktimer/main.cpp46
-rw-r--r--ktimer/prefwidget.ui278
10 files changed, 1040 insertions, 0 deletions
diff --git a/ktimer/Makefile.am b/ktimer/Makefile.am
new file mode 100644
index 0000000..35d6283
--- /dev/null
+++ b/ktimer/Makefile.am
@@ -0,0 +1,24 @@
+INCLUDES = $(all_includes)
+AM_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+LDADD = $(LIB_KDEUI) $(LIB_KFILE)
+
+bin_PROGRAMS = ktimer
+
+METASOURCES = AUTO
+
+ktimer_SOURCES = main.cpp ktimer.cpp prefwidget.ui
+# ktimer.cpp pref.cpp
+noinst_HEADERS = ktimer.h
+
+KDE_ICON = ktimer
+
+xdg_apps_DATA = ktimer.desktop
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/ktimer.pot
+
+
+srcdoc:
+ kdoc -a -p -H -d $$HOME/web/src/ktimer ktimer *.h -lkdecore -lkdeui -lqt
+
+
diff --git a/ktimer/hi128-app-ktimer.png b/ktimer/hi128-app-ktimer.png
new file mode 100644
index 0000000..692b050
--- /dev/null
+++ b/ktimer/hi128-app-ktimer.png
Binary files differ
diff --git a/ktimer/hi16-app-ktimer.png b/ktimer/hi16-app-ktimer.png
new file mode 100644
index 0000000..dca2c7e
--- /dev/null
+++ b/ktimer/hi16-app-ktimer.png
Binary files differ
diff --git a/ktimer/hi32-app-ktimer.png b/ktimer/hi32-app-ktimer.png
new file mode 100644
index 0000000..0f93b36
--- /dev/null
+++ b/ktimer/hi32-app-ktimer.png
Binary files differ
diff --git a/ktimer/hi48-app-ktimer.png b/ktimer/hi48-app-ktimer.png
new file mode 100644
index 0000000..b974797
--- /dev/null
+++ b/ktimer/hi48-app-ktimer.png
Binary files differ
diff --git a/ktimer/ktimer.cpp b/ktimer/ktimer.cpp
new file mode 100644
index 0000000..2b1b1c8
--- /dev/null
+++ b/ktimer/ktimer.cpp
@@ -0,0 +1,516 @@
+/*
+ * (c) 2001 Stefan Schimanski <1Stein@gmx.de>
+ *
+ * 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.
+ */
+
+#include <qtimer.h>
+#include <qtoolbutton.h>
+#include <qgroupbox.h>
+#include <qlistview.h>
+#include <qspinbox.h>
+#include <qlineedit.h>
+#include <qcheckbox.h>
+#include <qslider.h>
+#include <qlcdnumber.h>
+#include <kurlrequester.h>
+#include <klineedit.h>
+
+#include <kiconloader.h>
+#include <kapplication.h>
+#include <ksystemtray.h>
+#include <kfiledialog.h>
+
+#include "ktimer.h"
+#include <qpushbutton.h>
+
+
+class KTimerJobItem : public QListViewItem {
+public:
+ KTimerJobItem( KTimerJob *job, QListView *parent )
+ : QListViewItem( parent ) {
+ m_job = job;
+ m_error = false;
+ update();
+ };
+
+ KTimerJobItem( KTimerJob *job, QListView *parent, QListViewItem *after )
+ : QListViewItem( parent, after ) {
+ m_job = job;
+ m_error = false;
+ update();
+ };
+
+ virtual ~KTimerJobItem() {
+ delete m_job;
+ };
+
+ KTimerJob *job() { return m_job; };
+
+ void setStatus( bool error ) {
+ m_error = error;
+ update();
+ }
+
+ void update() {
+ setText( 0, QString::number(m_job->value()) );
+
+ if( m_error )
+ setPixmap( 0, SmallIcon("stop") );
+ else
+ setPixmap( 0, QPixmap() );
+
+ setText( 1, QString::number(m_job->delay()) );
+
+ switch( m_job->state() ) {
+ case KTimerJob::Stopped: setPixmap( 2, SmallIcon("player_stop") ); break;
+ case KTimerJob::Paused: setPixmap( 2, SmallIcon("player_pause") ); break;
+ case KTimerJob::Started: setPixmap( 2, SmallIcon("1rightarrow") ); break;
+ }
+
+ setText( 3, m_job->command() );
+ };
+
+private:
+ bool m_error;
+ KTimerJob *m_job;
+};
+
+
+/***************************************************************/
+
+
+struct KTimerPrefPrivate
+{
+ QPtrList<KTimerJob> jobs;
+};
+
+KTimerPref::KTimerPref( QWidget *parent, const char *name )
+ : PrefWidget( parent, name )
+{
+ d = new KTimerPrefPrivate;
+
+ d->jobs.setAutoDelete( true );
+
+ // set icons
+ m_stop->setIconSet( SmallIconSet("player_stop") );
+ m_pause->setIconSet( SmallIconSet("player_pause") );
+ m_start->setIconSet( SmallIconSet("1rightarrow") );
+
+ // create tray icon
+ KSystemTray *tray = new KSystemTray( this, "TimerTray" );
+ tray->show();
+ tray->setPixmap( SmallIcon( "ktimer" ) );
+
+ // connect
+ connect( m_add, SIGNAL(clicked()), SLOT(add()) );
+ connect( m_remove, SIGNAL(clicked()), SLOT(remove()) );
+ connect( m_list, SIGNAL(currentChanged(QListViewItem*)),
+ SLOT(currentChanged(QListViewItem*)) );
+ loadJobs( kapp->config() );
+
+ show();
+}
+
+
+KTimerPref::~KTimerPref()
+{
+ saveJobs( kapp->config() );
+ delete d;
+}
+
+
+void KTimerPref::add()
+{
+ KTimerJob *job = new KTimerJob;
+ KTimerJobItem *item = new KTimerJobItem( job, m_list );
+
+ connect( job, SIGNAL(delayChanged(KTimerJob*,unsigned)),
+ SLOT(jobChanged(KTimerJob*)) );
+ connect( job, SIGNAL(valueChanged(KTimerJob*,unsigned)),
+ SLOT(jobChanged(KTimerJob*)) );
+ connect( job, SIGNAL(stateChanged(KTimerJob*,States)),
+ SLOT(jobChanged(KTimerJob*)) );
+ connect( job, SIGNAL(commandChanged(KTimerJob*,const QString&)),
+ SLOT(jobChanged(KTimerJob*)) );
+ connect( job, SIGNAL(finished(KTimerJob*,bool)),
+ SLOT(jobFinished(KTimerJob*,bool)) );
+
+ job->setUser( item );
+
+ // Qt drops currentChanged signals on first item (bug?)
+ if( m_list->childCount()==1 )
+ currentChanged( item );
+
+ m_list->setCurrentItem( item );
+ m_list->triggerUpdate();
+}
+
+
+void KTimerPref::remove()
+{
+ delete m_list->currentItem();
+ m_list->triggerUpdate();
+}
+
+
+void KTimerPref::currentChanged( QListViewItem *i )
+{
+ KTimerJobItem *item = static_cast<KTimerJobItem*>(i);
+ if( item ) {
+ KTimerJob *job = item->job();
+
+ m_state->setEnabled( true );
+ m_settings->setEnabled( true );
+ m_remove->setEnabled( true );
+
+ m_delay->disconnect();
+ m_loop->disconnect();
+ m_one->disconnect();
+ m_start->disconnect();
+ m_pause->disconnect();
+ m_stop->disconnect();
+ m_counter->disconnect();
+ m_slider->disconnect();
+
+ connect( m_commandLine->lineEdit(), SIGNAL(textChanged(const QString &)),
+ job, SLOT(setCommand(const QString &)) );
+ connect( m_delay, SIGNAL(valueChanged(int)),
+ job, SLOT(setDelay(int)) );
+ connect( m_loop, SIGNAL(toggled(bool)),
+ job, SLOT(setLoop(bool)) );
+ connect( m_one, SIGNAL(toggled(bool)),
+ job, SLOT(setOneInstance(bool)) );
+ connect( m_stop, SIGNAL(clicked()),
+ job, SLOT(stop()) );
+ connect( m_pause, SIGNAL(clicked()),
+ job, SLOT(pause()) );
+ connect( m_start, SIGNAL(clicked()),
+ job, SLOT(start()) );
+ connect( m_slider, SIGNAL(valueChanged(int)),
+ job, SLOT(setValue(int)) );
+
+ m_commandLine->lineEdit()->setText( job->command() );
+ m_delay->setValue( job->delay() );
+ m_loop->setChecked( job->loop() );
+ m_one->setChecked( job->oneInstance() );
+ m_counter->display( (int)job->value() );
+ m_slider->setMaxValue( job->delay() );
+ m_slider->setValue( job->value() );
+
+ } else {
+ m_state->setEnabled( false );
+ m_settings->setEnabled( false );
+ m_remove->setEnabled( false );
+ }
+}
+
+
+void KTimerPref::jobChanged( KTimerJob *job )
+{
+ KTimerJobItem *item = static_cast<KTimerJobItem*>(job->user());
+ if( item ) {
+ item->update();
+ m_list->triggerUpdate();
+
+ if( item==m_list->currentItem() ) {
+
+ // XXX optimize
+ m_slider->setMaxValue( job->delay() );
+ m_slider->setValue( job->value() );
+ m_counter->display( (int)job->value() );
+ }
+ }
+}
+
+
+void KTimerPref::jobFinished( KTimerJob *job, bool error )
+{
+ KTimerJobItem *item = static_cast<KTimerJobItem*>(job->user());
+ item->setStatus( error );
+ m_list->triggerUpdate();
+}
+
+
+void KTimerPref::saveJobs( KConfig *cfg )
+{
+ int num = 0;
+ KTimerJobItem *item = static_cast<KTimerJobItem*>(m_list->firstChild());
+ while( item ) {
+ item->job()->save( cfg, QString("Job%1").arg( num ) );
+ item = static_cast<KTimerJobItem*>(item->nextSibling());
+ num++;
+ }
+
+ cfg->setGroup( "Jobs" );
+ cfg->writeEntry( "Number", num );
+
+ cfg->sync();
+}
+
+
+void KTimerPref::loadJobs( KConfig *cfg )
+{
+ cfg->setGroup( "Jobs" );
+ int num = cfg->readNumEntry( "Number", 0 );
+ for( int n=0; n<num; n++ ) {
+ KTimerJob *job = new KTimerJob;
+ KTimerJobItem *item = new KTimerJobItem( job, m_list );
+
+ connect( job, SIGNAL(delayChanged(KTimerJob*,unsigned)),
+ SLOT(jobChanged(KTimerJob*)) );
+ connect( job, SIGNAL(valueChanged(KTimerJob*,unsigned)),
+ SLOT(jobChanged(KTimerJob*)) );
+ connect( job, SIGNAL(stateChanged(KTimerJob*,States)),
+ SLOT(jobChanged(KTimerJob*)) );
+ connect( job, SIGNAL(commandChanged(KTimerJob*,const QString&)),
+ SLOT(jobChanged(KTimerJob*)) );
+ connect( job, SIGNAL(finished(KTimerJob*,bool)),
+ SLOT(jobFinished(KTimerJob*,bool)) );
+
+ job->load( cfg, QString( "Job%1" ).arg(n) );
+
+ job->setUser( item );
+ }
+
+ m_list->triggerUpdate();
+}
+
+
+/*********************************************************************/
+
+
+struct KTimerJobPrivate {
+ unsigned delay;
+ QString command;
+ bool loop;
+ bool oneInstance;
+ unsigned value;
+ KTimerJob::States state;
+ QPtrList<KProcess> processes;
+ void *user;
+
+ QTimer *timer;
+};
+
+
+KTimerJob::KTimerJob( QObject *parent, const char *name )
+ : QObject( parent, name )
+{
+ d = new KTimerJobPrivate;
+
+ d->delay = 100;
+ d->loop = false;
+ d->oneInstance = true;
+ d->value = 100;
+ d->state = Stopped;
+ d->processes.setAutoDelete( true );
+ d->user = 0;
+
+ d->timer = new QTimer( this );
+ connect( d->timer, SIGNAL(timeout()), SLOT(timeout()) );
+}
+
+
+KTimerJob::~KTimerJob()
+{
+ delete d;
+}
+
+
+void KTimerJob::load( KConfig *cfg, const QString& grp )
+{
+ cfg->setGroup( grp );
+ cfg->writeEntry( "Delay", d->delay );
+ cfg->writePathEntry( "Command", d->command );
+ cfg->writeEntry( "Loop", d->loop );
+ cfg->writeEntry( "OneInstance", d->oneInstance );
+ cfg->writeEntry( "State", (int)d->state );
+}
+
+
+void KTimerJob::save( KConfig *cfg, const QString& grp )
+{
+ cfg->setGroup( grp );
+ setDelay( cfg->readNumEntry( "Delay", 100 ) );
+ setCommand( cfg->readPathEntry( "Command" ) );
+ setLoop( cfg->readBoolEntry( "Loop", false ) );
+ setOneInstance( cfg->readBoolEntry( "OneInstance", d->oneInstance ) );
+ setState( (States)cfg->readNumEntry( "State", (int)Stopped ) );
+}
+
+
+void *KTimerJob::user()
+{
+ return d->user;
+}
+
+
+void KTimerJob::setUser( void *user )
+{
+ d->user = user;
+}
+
+
+unsigned KTimerJob::delay()
+{
+ return d->delay;
+}
+
+
+void KTimerJob::setDelay( unsigned sec )
+{
+ if( d->delay!=sec ) {
+ d->delay = sec;
+
+ if( d->state==Stopped )
+ setValue( sec );
+
+ emit delayChanged( this, sec );
+ emit changed( this );
+ }
+}
+
+
+QString KTimerJob::command()
+{
+ return d->command;
+}
+
+
+void KTimerJob::setCommand( const QString &cmd )
+{
+ if( d->command!=cmd ) {
+ d->command = cmd;
+ emit commandChanged( this, cmd );
+ emit changed( this );
+ }
+}
+
+
+bool KTimerJob::loop()
+{
+ return d->loop;
+}
+
+
+void KTimerJob::setLoop( bool loop )
+{
+ if( d->loop!=loop ) {
+ d->loop = loop;
+ emit loopChanged( this, loop );
+ emit changed( this );
+ }
+}
+
+
+bool KTimerJob::oneInstance()
+{
+ return d->oneInstance;
+}
+
+
+void KTimerJob::setOneInstance( bool one )
+{
+ if( d->oneInstance!=one ) {
+ d->oneInstance = one;
+ emit oneInstanceChanged( this, one );
+ emit changed( this );
+ }
+}
+
+
+unsigned KTimerJob::value()
+{
+ return d->value;
+}
+
+
+void KTimerJob::setValue( unsigned value )
+{
+ if( d->value!=value ) {
+ d->value = value;
+ emit valueChanged( this, value );
+ emit changed( this );
+ }
+}
+
+
+KTimerJob::States KTimerJob::state()
+{
+ return d->state;
+}
+
+
+void KTimerJob::setState( KTimerJob::States state )
+{
+ if( d->state!=state ) {
+ if( state==Started )
+ d->timer->start( 1000 );
+ else
+ d->timer->stop();
+
+ if( state==Stopped )
+ setValue( d->delay );
+
+ d->state = state;
+ emit stateChanged( this, state );
+ emit changed( this );
+ }
+}
+
+
+void KTimerJob::timeout()
+{
+ if( d->state==Started && d->value!=0 ) {
+ setValue( d->value-1 );
+ if( d->value==0 ) {
+ fire();
+ if( d->loop )
+ setValue( d->delay );
+ else
+ stop();
+ }
+ }
+}
+
+
+void KTimerJob::processExited(KProcess *proc)
+{
+ bool ok = proc->exitStatus()==0;
+ d->processes.remove( proc );
+ if( !ok ) emit error( this );
+ emit finished( this, !ok );
+}
+
+
+void KTimerJob::fire()
+{
+ if( !d->oneInstance || d->processes.isEmpty() ) {
+ KShellProcess *proc = new KShellProcess;
+ (*proc) << d->command;
+ d->processes.append( proc );
+ connect( proc, SIGNAL(processExited(KProcess*)),
+ SLOT(processExited(KProcess*)) );
+ bool ok = proc->start( KProcess::NotifyOnExit );
+ emit fired( this );
+ if( !ok ) {
+ d->processes.remove( proc );
+ emit error( this );
+ emit finished( this, true );
+ }
+ }
+}
+#include "ktimer.moc"
diff --git a/ktimer/ktimer.desktop b/ktimer/ktimer.desktop
new file mode 100644
index 0000000..d34c43b
--- /dev/null
+++ b/ktimer/ktimer.desktop
@@ -0,0 +1,63 @@
+[Desktop Entry]
+GenericName=Countdown Launcher
+GenericName[ar]=بادئ العدّ التنازلى
+GenericName[bg]=Хронометър
+GenericName[ca]=Llançador amb compte enrere
+GenericName[cs]=Stopky
+GenericName[cy]=Cychwynydd Cyfrif yn Ôl
+GenericName[da]=Nedtællingsstarter
+GenericName[de]=Startet den Zähler
+GenericName[el]=Αντίστροφη μέτρηση για την ενεργοποίηση λογισμικού
+GenericName[es]=Lanzador de cuenta atrás
+GenericName[et]=Ajaarvestuse käivitaja
+GenericName[eu]=Atzekoz aurrera zenbaketa jaurtitzen du
+GenericName[fa]=راه‌انداز شمارش معکوس
+GenericName[fi]=Lähtölaskenta
+GenericName[fr]=Lanceur de compte à rebours
+GenericName[hu]=Visszaszámláló
+GenericName[is]=Niðurteljari
+GenericName[it]=Conto alla rovescia
+GenericName[ja]=起動マネージャ
+GenericName[kk]=Кері санақ
+GenericName[km]=កម្មវិធី​បើក​រហ័ស​របស់​កម្មវិធី​រាប់ថតក្រោយ
+GenericName[lt]=Laiko skaičiuoklė
+GenericName[nb]=Beskjedverktøy
+GenericName[nds]=Teller starten
+GenericName[ne]=काउन्टडाउन आरम्भकर्ता
+GenericName[nn]=Nedteljing
+GenericName[pl]=Odliczanie
+GenericName[pt]=Contagem Decrescente
+GenericName[pt_BR]=Abre a contador de tempo
+GenericName[ro]=Cronometru
+GenericName[ru]=Обратный отсчёт
+GenericName[sk]=Odpočítavané spúšťanie
+GenericName[sl]=Zaganjalec odštevanja
+GenericName[sr]=Лансер одбројавања
+GenericName[sr@Latn]=Lanser odbrojavanja
+GenericName[sv]=Nerräknande startprogram
+GenericName[ta]= குறிப்பு எடுப்பான் நேரக்குறைப்பான்
+GenericName[tr]=Gerisayım Çalıştırıcı
+GenericName[uk]=Таймер
+GenericName[zh_CN]=倒计时
+GenericName[zh_TW]=倒數發射計時
+Exec=ktimer
+Icon=ktimer
+Type=Application
+Terminal=false
+Name=KTimer
+Name[af]=Ktimer
+Name[eo]=Tempoplanilo
+Name[hi]=के-टाइमर
+Name[lv]=KTaimers
+Name[ne]=केडीई समय सूचक
+Name[pl]=Czasomierz
+Name[sv]=Ktimer
+Name[ta]= Kநேரம் காட்டி
+Name[tg]=KВақтсанҷ
+Name[th]=ตั้งเวลาทำงาน
+Name[ven]=Ratshikhathi wa K
+Name[xh]=Umjongi Wexesha
+Name[zh_TW]=KDE 計時器
+X-KDE-StartupNotify=true
+X-DCOP-ServiceType=Multi
+Categories=Qt;KDE;Utility;X-KDE-More;
diff --git a/ktimer/ktimer.h b/ktimer/ktimer.h
new file mode 100644
index 0000000..3b7c406
--- /dev/null
+++ b/ktimer/ktimer.h
@@ -0,0 +1,113 @@
+/*
+ * (c) 2001 Stefan Schimanski <1Stein@gmx.de>
+ *
+ * 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.
+ */
+
+#ifndef KTIMER_H_INCLUDED
+#define KTIMER_H_INCLUDED
+
+#include <qdialog.h>
+#include <qwidget.h>
+#include <kprocess.h>
+#include <kconfig.h>
+
+#include "prefwidget.h"
+
+
+class KTimerJob : public QObject {
+ Q_OBJECT
+
+ public:
+ KTimerJob( QObject *parent=0, const char *name=0 );
+ virtual ~KTimerJob();
+
+ enum States { Stopped, Paused, Started };
+
+ unsigned delay();
+ QString command();
+ bool loop();
+ bool oneInstance();
+ unsigned value();
+ States state();
+ void *user();
+ void setUser( void *user );
+
+ void load( KConfig *cfg, const QString& grp );
+ void save( KConfig *cfg, const QString& grp );
+
+ public slots:
+ void setDelay( unsigned sec );
+ void setDelay( int sec ) { setDelay( (unsigned)sec ); };
+ void setCommand( const QString &cmd );
+ void setLoop( bool loop );
+ void setOneInstance( bool one );
+ void setValue( unsigned value );
+ void setValue( int value ) { setValue( (unsigned)value ); };
+ void setState( States state );
+
+ void pause() { setState( Paused ); }
+ void stop() { setState( Stopped ); }
+ void start() { setState( Started ); }
+
+ signals:
+ void stateChanged( KTimerJob *job, States state );
+ void delayChanged( KTimerJob *job, unsigned sec );
+ void commandChanged( KTimerJob *job, const QString &cmd );
+ void loopChanged( KTimerJob *job, bool loop );
+ void oneInstanceChanged( KTimerJob *job, bool one );
+ void valueChanged( KTimerJob *job, unsigned value );
+
+ void changed( KTimerJob *job );
+ void fired( KTimerJob *job );
+ void finished( KTimerJob *job, bool error );
+ void error( KTimerJob *job );
+
+ protected slots:
+ virtual void fire();
+
+ private slots:
+ void timeout();
+ void processExited(KProcess *proc);
+
+ private:
+ struct KTimerJobPrivate *d;
+};
+
+
+class KTimerPref : public PrefWidget
+{
+ Q_OBJECT
+ public:
+ KTimerPref( QWidget *parent=0, const char *name = 0 );
+ virtual ~KTimerPref();
+
+ protected slots:
+ void add();
+ void remove();
+ void currentChanged( QListViewItem * );
+
+ void saveJobs( KConfig *cfg );
+ void loadJobs( KConfig *cfg );
+
+ private slots:
+ void jobChanged( KTimerJob *job );
+ void jobFinished( KTimerJob *job, bool error );
+
+ private:
+ struct KTimerPrefPrivate *d;
+};
+
+#endif
diff --git a/ktimer/main.cpp b/ktimer/main.cpp
new file mode 100644
index 0000000..1deb4ac
--- /dev/null
+++ b/ktimer/main.cpp
@@ -0,0 +1,46 @@
+/*
+ * (c) 2001 Stefan Schimanski <schimmi@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.
+ */
+
+#include <kapplication.h>
+#include <klocale.h>
+#include <kcmdlineargs.h>
+#include <kaboutdata.h>
+
+#include "ktimer.h"
+
+static const char description[] =
+ I18N_NOOP("KDE Timer");
+
+static const char version[] = "v0.1";
+
+int main( int argc, char **argv )
+{
+ KAboutData aboutData( "ktimer", I18N_NOOP("KTimer"),
+ version, description, KAboutData::License_GPL,
+ "(c) 2001, Stefan Schimanski");
+ aboutData.addAuthor("Stefan Schimanski",0, "schimmi@kde.org");
+ KCmdLineArgs::init( argc, argv, &aboutData );
+
+ KApplication app;
+
+ KTimerPref *timer = new KTimerPref;
+ app.setMainWidget( timer );
+ app.setTopWidget( timer );
+
+ return app.exec();
+}
diff --git a/ktimer/prefwidget.ui b/ktimer/prefwidget.ui
new file mode 100644
index 0000000..15cee2b
--- /dev/null
+++ b/ktimer/prefwidget.ui
@@ -0,0 +1,278 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>PrefWidget</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>PrefWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>479</width>
+ <height>344</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Timer Settings</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QListView" row="0" column="0" rowspan="3" colspan="1">
+ <column>
+ <property name="text">
+ <string>Counter [s]</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Delay [s]</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>State</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Command</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>m_list</cstring>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="0" column="1">
+ <property name="name">
+ <cstring>m_add</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;New</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="1" column="1">
+ <property name="name">
+ <cstring>m_remove</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Remove</string>
+ </property>
+ </widget>
+ <spacer row="2" column="1">
+ <property name="name">
+ <cstring>Spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QGroupBox" row="4" column="0">
+ <property name="name">
+ <cstring>m_settings</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="title">
+ <string>Settings</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="4">
+ <property name="name">
+ <cstring>m_loop</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Loop</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Delay:</string>
+ </property>
+ </widget>
+ <widget class="QSpinBox" row="1" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>m_delay</cstring>
+ </property>
+ <property name="maxValue">
+ <number>99999</number>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="3" column="0" rowspan="1" colspan="4">
+ <property name="name">
+ <cstring>m_one</cstring>
+ </property>
+ <property name="text">
+ <string>Start only &amp;one instance</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="3">
+ <property name="name">
+ <cstring>TextLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>seconds</string>
+ </property>
+ </widget>
+ <spacer row="1" column="4">
+ <property name="name">
+ <cstring>Spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KURLRequester" row="0" column="2" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>m_commandLine</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Command line:</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="4" column="1">
+ <property name="name">
+ <cstring>m_state</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="title">
+ <string>State</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QSlider" row="2" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>m_slider</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="QLCDNumber" row="1" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>m_counter</cstring>
+ </property>
+ </widget>
+ <widget class="QToolButton" row="0" column="1">
+ <property name="name">
+ <cstring>m_pause</cstring>
+ </property>
+ <property name="text">
+ <string>||</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" row="0" column="2">
+ <property name="name">
+ <cstring>m_start</cstring>
+ </property>
+ <property name="text">
+ <string>&gt;</string>
+ </property>
+ </widget>
+ <widget class="QToolButton" row="0" column="0">
+ <property name="name">
+ <cstring>m_stop</cstring>
+ </property>
+ <property name="text">
+ <string>=</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<includes>
+ <include location="global" impldecl="in declaration">kseparator.h</include>
+</includes>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kurlrequester.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>