summaryrefslogtreecommitdiffabout
path: root/kalarmd
authorzautrix <zautrix>2005-03-26 20:29:59 (UTC)
committer zautrix <zautrix>2005-03-26 20:29:59 (UTC)
commitc9c3f9e65a72a3c79d7f67eba68fca4537004808 (patch) (side-by-side diff)
tree395970dbf2b5aad3cdafe195e7a9958f5cc8aa15 /kalarmd
parent36dd498ad2f5a2cf43fc08c621669fe42198e5eb (diff)
downloadkdepimpi-c9c3f9e65a72a3c79d7f67eba68fca4537004808.zip
kdepimpi-c9c3f9e65a72a3c79d7f67eba68fca4537004808.tar.gz
kdepimpi-c9c3f9e65a72a3c79d7f67eba68fca4537004808.tar.bz2
better timer
Diffstat (limited to 'kalarmd') (more/less context) (show whitespace changes)
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp102
-rw-r--r--kalarmd/simplealarmdaemonimpl.h33
2 files changed, 121 insertions, 14 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp
index 50c4605..ec7f730 100644
--- a/kalarmd/simplealarmdaemonimpl.cpp
+++ b/kalarmd/simplealarmdaemonimpl.cpp
@@ -33,2 +33,4 @@
#include <qfile.h>
+#include <qdatetime.h>
+#include <qpushbutton.h>
#include <qlayout.h>
@@ -36,3 +38,5 @@
#include <qdialog.h>
+#define protected public
#include <qspinbox.h>
+#undef protected
#include <qtextstream.h>
@@ -65,3 +69,5 @@ SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent )
mTimerPopUp = new QPopupMenu( this );
-
+ QFont fon = mTimerPopUp->font();
+ fon.setPointSize( fon.pointSize() *3/2 );
+ mTimerPopUp->setFont( fon );
mBeepPopUp = new QPopupMenu( this );
@@ -357,3 +363,3 @@ void SimpleAlarmDaemonImpl::fillTimerPopUp()
QTime t ( secs/3600, (secs/60)%60, secs%60 );
- mTimerPopUp->changeItem ( 1 , t.toString());
+ mTimerPopUp->changeItem ( 1 , t.toString() + " (remaining time)");
}
@@ -372,4 +378,7 @@ void SimpleAlarmDaemonImpl::fillTimerPopUp()
QTime t ( secs/3600, (secs/60)%60, secs%60 );
- mTimerPopUp->insertItem( "Stop", 0 );
- mTimerPopUp->insertItem( t.toString(),1);
+
+
+ mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 );
+ mTimerPopUp->insertItem( t.toString() + " (remaining time)",1);
+ mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm time)",2);
} else {
@@ -466,9 +475,21 @@ void SimpleAlarmDaemonImpl::confTimer( int time )
QDialog dia ( 0, ("Stop Timer" ), true );
- QLabel lab (("Really stop the timer?"), &dia );
+ QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia );
+ lab.setAlignment( AlignCenter );
dia.setCaption(("KO/Pi Timer Stop" ));
QVBoxLayout lay( &dia );
+ lay.addWidget( &lab);
+ QPushButton ok ( "Stop timer!", &dia);
+ QFont fo = dia.font();
+ fo.setPointSize( 36 );
+ ok.setFont( fo );
+ lay.addWidget( &ok);
+ connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
+ QPushButton con ( "Continue timer!", &dia);
+ fo.setPointSize( 36 );
+ con.setFont( fo );
+ lay.addWidget( &con);
+ connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) );
lay.setMargin(5);
lay.setSpacing(5);
- lay.addWidget( &lab);
- dia.resize( 200, dia.sizeHint().height() );
+ dia.resize(dia.sizeHint() );
@@ -488,8 +509,14 @@ void SimpleAlarmDaemonImpl::confTimer( int time )
mess += ("Timer Alarm!\n");
- if ( minutes == 22 )
+ if ( minutes == 22 ) {
mess += ( "Pizza is ready");
- else if ( minutes == 45 )
+ mRunningTimerText = "Pizza";
+ }
+ else if ( minutes == 45 ) {
mess += ( "Please wake up!");
- else if ( minutes == 5 )
+ mRunningTimerText = "Nap";
+ }
+ else if ( minutes == 5 ) {
mess += ( "Tea is ready");
+ mRunningTimerText = "Tea";
+ }
else if ( minutes == 3 ) {
@@ -497,2 +524,5 @@ void SimpleAlarmDaemonImpl::confTimer( int time )
minutes = mCustomMinutes ;
+ mRunningTimerText = mCustomText.stripWhiteSpace ();
+ int in = mRunningTimerText.find( " " );
+ mRunningTimerText = mRunningTimerText.left ( in );
}
@@ -512,11 +542,46 @@ void SimpleAlarmDaemonImpl::confTimer( int time )
lay.addWidget( &lab2);
+ QHBox hbox1 ( &dia );
+ lay.addWidget( &hbox1);
+ QLabel lab3 (("Hours"), &hbox1 );
+ QLabel lab4 (("Minutes"), &hbox1 );
QHBox hbox ( &dia );
- QLabel lab3 (("h:"), &hbox );
QSpinBox spinh( 0, 24, 1,& hbox );
- QLabel lab4 ((" min:"), &hbox );
+ QFont fo = dia.font();
+ fo.setPointSize( 36 );
QSpinBox spinm( 0, 59, 1,&hbox );
+ spinm.setFont( fo );
+ spinh.setFont( fo );
+ spinh.setButtonSymbols( QSpinBox::PlusMinus );
+ spinm.setButtonSymbols( QSpinBox::PlusMinus );
+ spinh.upButton ()->setFixedSize( QSize( 48, 30 ));
+ spinh.downButton ()->setFixedSize( QSize( 48, 30 ));
+ //spinh.editor ()->setFixedSize( QSize( 50, 100 ));
+ spinh.setFixedSize( 100,62 );
+ spinm.upButton ()->setFixedSize( QSize( 48, 30 ));
+ spinm.downButton ()->setFixedSize( QSize( 48, 30 ));
+ spinm.downButton ()->setGeometry( 50,50,50,50);
+ spinm.setSuffix( " m" );
+ spinh.setSuffix( " h" );
+ spinm.setWrapping ( true );
+ //spinm.editor ()->setFixedSize( QSize( 50, 100 ));
+ spinm.setLineStep( 1 );
+ spinm.setFixedSize( 110,62 );
+ lay.addWidget( &hbox);
+ QLabel lab5 ("Timer fires at:", &dia );
+ lab5.setAlignment( AlignCenter );
+ lay.addWidget( &lab5);
+ KODateLabel dl ( &dia );
+ dl.setAlignment( AlignCenter );
+ dl.setFont( fo );
+ connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) );
+ connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) );
+ lay.addWidget( &dl);
spinh.setValue( mCustomMinutes/60 );
spinm.setValue( mCustomMinutes%60 );
- lay.addWidget( &hbox);
+ QPushButton ok ( "Start timer", &dia);
+ ok.setFont( fo );
+ lay.addWidget( &ok);
+ connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
dia.resize( dia.sizeHint().width(), dia.sizeHint().height() );
+
if ( !dia.exec() )
@@ -531,5 +596,14 @@ void SimpleAlarmDaemonImpl::confTimer( int time )
minutes = mCustomMinutes;
+ mRunningTimerText = mCustomText.stripWhiteSpace ();
+ int in = mRunningTimerText.find( " " );
+ mRunningTimerText = mRunningTimerText.left ( in );
}
- else
+ else {
mess+= QString::number ( minutes ) + ( " minutes are past!");
+ int min = minutes;
+ if ( min % 60 == 0 )
+ mRunningTimerText = QString::number ( min/60 ) + ( " hours");
+ else
+ mRunningTimerText = QString::number ( minutes ) + ( " minutes");
+ }
}
diff --git a/kalarmd/simplealarmdaemonimpl.h b/kalarmd/simplealarmdaemonimpl.h
index 32a3867..cbdba47 100644
--- a/kalarmd/simplealarmdaemonimpl.h
+++ b/kalarmd/simplealarmdaemonimpl.h
@@ -28,2 +28,3 @@
#include <qlabel.h>
+#include <qtimer.h>
@@ -80,2 +81,3 @@ class SimpleAlarmDaemonImpl : public QLabel
QString mCustomText;
+ QString mRunningTimerText;
int mCustomMinutes;
@@ -84,3 +86,34 @@ class SimpleAlarmDaemonImpl : public QLabel
};
+class KODateLabel : public QLabel
+{
+ Q_OBJECT
+ public:
+ KODateLabel( QWidget *parent=0, const char *name=0 ) :
+ QLabel( parent, name )
+ {
+ hour = 0;
+ minutes = 0;
+ QTimer * ti = new QTimer( this );
+ connect ( ti, SIGNAL ( timeout () ), this, SLOT ( updateText() ));
+ ti->start( 1000 );
+ }
+public slots:
+ void slot_minutes( int m )
+ {
+ minutes = m; updateText();
+ }
+ void slot_hours( int h )
+ {
+ hour = h; updateText();
+ }
+private slots:
+ void updateText()
+ {
+ QDateTime dt = QDateTime::currentDateTime();
+ dt = dt.addSecs( minutes * 60 + hour * 3600 );
+ setText( dt.time().toString() );
+ }
+ int hour, minutes;
+};
#endif