summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kalarmd/simplealarmdaemonimpl.cpp23
-rw-r--r--kalarmd/simplealarmdaemonimpl.h1
2 files changed, 23 insertions, 1 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp
index 8ea8a73..04b8b21 100644
--- a/kalarmd/simplealarmdaemonimpl.cpp
+++ b/kalarmd/simplealarmdaemonimpl.cpp
@@ -127,55 +127,64 @@ SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent )
connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) );
connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) );
connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) );
connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) );
connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) );
connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) );
mTimerTime = 0;
mCustomText = "Custom Text";
mCustomMinutes = 7;
mTimerPopupConf = 1;
fillTimerPopUp();
mPausePlay = 0;
confPause( 1 );
mSuspend = 0;
confSuspend( 0 );
if ( QApplication::desktop()->width() < 480 ) {
wavAlarm = false;
mSoundPopUp->setItemChecked ( 0, true );
}
else {
wavAlarm = true;
mSoundPopUp->setItemChecked ( 1, true );
}
saveSlot( 1 );
+ mTimerStartLabel = new QLabel( 0 );
+ mTimerStartLabel->setCaption( "Timer started!");
+ fon = mTimerPopUp->font();
+ fon.setBold( true );
+ points = (fon.pointSize()*2);
+ fon.setPointSize( points );
+ mTimerStartLabel->setFont( fon );
}
SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl()
{
//delete mPopUp;
delete mAlarmDialog;
+ delete mTimerStartLabel;
}
+
void SimpleAlarmDaemonImpl::saveSlot( int load )
{
QString fileName = QDir::homeDirPath() +"/.kopialarmrc";
//qDebug("save %d ", load );
QFile file( fileName );
if ( load ) {
if( !QFile::exists( fileName) )
return;
if (!file.open( IO_ReadOnly ) ) {
return ;
}
QString line;
bool ok;
int val;
int len;
while ( file.readLine( line, 1024 ) > 0 ) {
//qDebug("read %s ", line.latin1());
len = line.length();
if ( line.left(4 ) == "PPAU" ) {
val = line.mid( 4,len-5).toInt( &ok );
if ( ok ) {
confPause( val );
}
}
@@ -381,50 +390,50 @@ void SimpleAlarmDaemonImpl::fillTimerPopUp()
}
mTimerPopupConf = mTimerTime;
mTimerPopUp->clear();
if ( mTimerTime ) {
int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer );
QTime t ( secs/3600, (secs/60)%60, secs%60 );
mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 );
mTimerPopUp->insertItem( t.toString() + " (countdown)",1);
mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2);
} else {
QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc";
QFile file( fileName );
if( !QFile::exists( fileName) ) {
// write defaults
if (!file.open( IO_WriteOnly ) ) {
return;
}
QString configString ;
configString += "#config file for kopi alarm timer\n";
configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n";
configString += "24 hours; 1440\n";
+ configString += "9 hours; 540\n";
configString += "8 hours; 480\n";
- configString += "5 hours; 300\n";
configString += "1 hour; 60\n";
configString += "30 min; 30\n";
configString += "15 min; 15\n";
configString += "SEPARATOR\n";
configString += "Pizza; 22\n";
configString += "Nap; 45\n";
configString += "Tea; 5\n";
QTextStream ts( &file );
ts << configString ;
file.close();
}
if (!file.open( IO_ReadOnly ) ) {
return ;
}
QString line;
bool ok;
while ( file.readLine( line, 1024 ) > 0 ) {
//qDebug("read %s ", line.latin1());
if ( line.left(1 ) != "#" ) {
// no comment
if ( line.left(9 ) == "SEPARATOR" ) {
mTimerPopUp->insertSeparator();
} else {
@@ -492,55 +501,57 @@ void SimpleAlarmDaemonImpl::confTimer( int time )
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);
dia.resize(dia.sizeHint() );
if ( !dia.exec() )
return;
AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.utf8() );
mTimerTime = 0;
return;
}
if ( mTimerTime )
return;
if ( minutes == 1 ) {
return;
}
QString mess = "timer_alarm";
+ QString disp;
mess += ("Timer Alarm!\n");
if ( minutes == 3 ) {
mess += mCustomText;
minutes = mCustomMinutes ;
mRunningTimerText = mCustomText.stripWhiteSpace ();
int in = mRunningTimerText.find( " " );
mRunningTimerText = mRunningTimerText.left ( in );
+ disp = mCustomText;
}
else {
if ( minutes == 2 ) {
// ask time
QDialog dia ( 0, ("Customize Timer" ), true );
QLabel lab (("Message Text:"), &dia );
dia.setCaption(("KO/Pi Timer" ));
QVBoxLayout lay( &dia );
lay.setMargin(5);
lay.setSpacing(5);
lay.addWidget( &lab);
QLineEdit lEdit( mCustomText, &dia );
lay.addWidget( &lEdit);
QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia );
lay.addWidget( &lab2);
QHBox hbox1 ( &dia );
lay.addWidget( &hbox1);
QLabel lab3 (("Hours"), &hbox1 );
QLabel lab4 (("Minutes"), &hbox1 );
QHBox hbox ( &dia );
QSpinBox spinh( 0, 24, 1,& hbox );
QFont fo = dia.font();
fo.setPointSize( 36 );
QSpinBox spinm( 0, 59, 1,&hbox );
@@ -569,64 +580,74 @@ void SimpleAlarmDaemonImpl::confTimer( int time )
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 );
QPushButton ok ( "Start timer", &dia);
ok.setDefault( true );
ok.setFont( fo );
spinh.setFocus();
lay.addWidget( &ok);
connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) );
dia.resize( dia.sizeHint().width(), dia.sizeHint().height() );
if ( !dia.exec() )
return;
mCustomText = lEdit.text();
mCustomMinutes = spinh.value()*60+spinm.value();
if ( mCustomMinutes == 0 )
mCustomMinutes = 1;
if ( mCustomMinutes > 1440 )
mCustomMinutes = 1440;
mess += mCustomText;
+ disp = mCustomText;
minutes = mCustomMinutes;
mRunningTimerText = mCustomText.stripWhiteSpace ();
int in = mRunningTimerText.find( " " );
mRunningTimerText = mRunningTimerText.left ( in );
}
else {
mess += mTimerPopUp->text( minutes );
+ disp = mTimerPopUp->text( minutes );
mRunningTimerText = mTimerPopUp->text( minutes );
minutes -= 10;
}
}
//minutes = 1;
mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 );
timerMesssage = mess;
AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.utf8());
+ mTimerStartLabel->setText( disp );
+ int w = 200;
+ int h = mTimerStartLabel->sizeHint().height() ;
+ int dw = QApplication::desktop()->width();
+ int dh = QApplication::desktop()->height();
+ mTimerStartLabel->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
+ mTimerStartLabel->show();
+ QTimer::singleShot( 3000, mTimerStartLabel, SLOT ( hide() ) );
mTimerTime = 1;
}
void SimpleAlarmDaemonImpl::writeFile()
{
QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
//QCopEnvelope e("QPE/Application/kopi", "-writeFile");
}
void SimpleAlarmDaemonImpl::showWN()
{
QCopEnvelope e("QPE/Application/kopi", "-showWN");
}
void SimpleAlarmDaemonImpl::newTodo()
{
QCopEnvelope e("QPE/Application/kopi", "-newTodo");
}
void SimpleAlarmDaemonImpl::newEvent()
{
QCopEnvelope e("QPE/Application/kopi", "-newEvent");
}
void SimpleAlarmDaemonImpl::newMail()
{
diff --git a/kalarmd/simplealarmdaemonimpl.h b/kalarmd/simplealarmdaemonimpl.h
index cbdba47..9b7de94 100644
--- a/kalarmd/simplealarmdaemonimpl.h
+++ b/kalarmd/simplealarmdaemonimpl.h
@@ -47,48 +47,49 @@ class SimpleAlarmDaemonImpl : public QLabel
void newCountdown();
void simulate();
void showKO();
void showWN();
void showAdd();
void newMail();
void ringSync();
void showTodo();
void writeFile();
void writeJournal();
void slotPlayBeep( int );
void showTimer( );
void confPause( int );
void confTimer( int );
void saveSlot( int );
void confSuspend( int );
void confSound( int num );
void startAlarm(QString mess, QString fn );
protected:
void mousePressEvent( QMouseEvent * );
private:
AlarmDialog *mAlarmDialog;
+ QLabel * mTimerStartLabel;
int mPlayBeeps;
int mPausePlay;
int mSuspend;
QString mAlarmMessage;
int mTimerTime;
int getFileNameLen( QString );
QPopupMenu* mPopUp, *mBeepPopUp, *mTimerPopUp, *mSoundPopUp,*mPausePopUp,*mSuspendPopUp;
QDateTime mRunningTimer;
void fillTimerPopUp();
QString timerMesssage;
QString mCustomText;
QString mRunningTimerText;
int mCustomMinutes;
int mTimerPopupConf;
bool wavAlarm;
};
class KODateLabel : public QLabel
{
Q_OBJECT
public:
KODateLabel( QWidget *parent=0, const char *name=0 ) :
QLabel( parent, name )
{
hour = 0;