-rw-r--r-- | kalarmd/simplealarmdaemonimpl.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp index c1e064c..553e377 100644 --- a/kalarmd/simplealarmdaemonimpl.cpp +++ b/kalarmd/simplealarmdaemonimpl.cpp @@ -55,194 +55,195 @@ SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) mPopUp = new QPopupMenu( this ); mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) ); mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) ); mPopUp->insertSeparator(); mPopUp->insertItem( "Todo List", this, SLOT ( showTodo() ) ); mPopUp->insertSeparator(); mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) ); mPopUp->insertSeparator(); mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) ); mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) ); mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) ); mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) ); mPopUp->insertSeparator(); mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) ); mTimerPopUp = new QPopupMenu( this ); QFont fon = mTimerPopUp->font(); int points = (fon.pointSize()*4)/3; fon.setPointSize( points ); mTimerPopUp->setFont( fon ); mPopUp->setFont( fon ); mBeepPopUp = new QPopupMenu( this ); mSoundPopUp = new QPopupMenu( this ); mPausePopUp = new QPopupMenu( this ); QPopupMenu* savePopUp = new QPopupMenu( this ); savePopUp->insertItem( "Save", 0 ); savePopUp->insertItem( "Load", 1 ); mSoundPopUp->insertItem( "Buzzer", 0 ); mSoundPopUp->insertItem( "Wav file", 1 ); mPausePopUp->insertItem( " 1 sec", 1 ); mPausePopUp->insertItem( " 2 sec", 2 ); mPausePopUp->insertItem( " 3 sec", 3 ); mPausePopUp->insertItem( " 5 sec", 5 ); mPausePopUp->insertItem( "10 sec", 10 ); mPausePopUp->insertItem( "30 sec", 30 ); mPausePopUp->insertItem( " 1 min", 60 ); mPausePopUp->insertItem( " 5 min", 300 ); mPausePopUp->insertItem( "10 min", 600 ); mSuspendPopUp = new QPopupMenu( this ); mSuspendPopUp->insertItem( "Off", 0 ); mSuspendPopUp->insertItem( " 1x", 1 ); mSuspendPopUp->insertItem( " 2x", 2 ); mSuspendPopUp->insertItem( " 3x", 3 ); mSuspendPopUp->insertItem( " 5x", 5 ); mSuspendPopUp->insertItem( "10x", 10 ); mSuspendPopUp->insertItem( "20x", 20 ); mSuspendPopUp->insertItem( "30x", 30 ); mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); mBeepPopUp->insertItem( "Replay",mSoundPopUp ); mBeepPopUp->insertItem( "Config",savePopUp ); mBeepPopUp->insertItem( "300", 300 ); mBeepPopUp->insertItem( "180", 180 ); mBeepPopUp->insertItem( "60", 60 ); mBeepPopUp->insertItem( "30", 30 ); mBeepPopUp->insertItem( "10", 10 ); mBeepPopUp->insertItem( "3", 3 ); mBeepPopUp->insertItem( "1", 1 ); mBeepPopUp->insertItem( "Off", 0 ); mBeepPopUp->insertSeparator(); mBeepPopUp->insertItem( "Simulate", 1000 ); mBeepPopUp->setCheckable( true ); mPopUp->insertSeparator(); mPopUp->insertItem( "Play beeps", mBeepPopUp ); mPopUp->insertSeparator(); mPopUp->insertItem( "Timer", mTimerPopUp ); //mPopUp->insertSeparator(); //mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); mPopUp->resize( mPopUp->sizeHint() ); mPlayBeeps = 60; mBeepPopUp->setItemChecked ( mPlayBeeps, true ); connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); 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!"); + mTimerStartLabel = new QLabel( 0, 0, WType_Popup ); + //mTimerStartLabel->setCaption( "Timer started!"); + mTimerStartLabel->setAlignment ( Qt::AlignCenter ) ; 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 ); } } if ( line.left(4 ) == "SUCO" ) { val = line.mid( 4,len-5).toInt( &ok ); if ( ok ) confSuspend ( val ); } if ( line.left(4 ) == "WAAL" ) { val = line.mid( 4,len-5).toInt( &ok ); if ( ok ) confSound( val ); } if ( line.left(4 ) == "PLBE" ) { val = line.mid( 4,len-5).toInt( &ok ); if ( ok ) slotPlayBeep( val ); } if ( line.left(4 ) == "CUTE" ) { mCustomText = line.mid( 5,len-6); // qDebug("text ***%s*** ",mCustomText.latin1() ); } if ( line.left(4 ) == "CUMI" ) { val = line.mid( 4,len-5).toInt( &ok ); if ( ok ) mCustomMinutes = val; } if ( line.left(4 ) == "SUTI" ) { val = line.mid( 4,len-5).toInt( &ok ); if ( ok ) mAlarmDialog->setSuspendTime( val );; } } file.close(); } else { if (!file.open( IO_WriteOnly ) ) { return; } QString configString ; configString += "PPAU " + QString::number( mPausePlay ) + "\n"; configString += "SUCO " + QString::number( mSuspend ) + "\n"; configString += "WAAL " + QString::number( wavAlarm ) + "\n"; configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; configString += "CUTE " + mCustomText + "\n"; configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; QTextStream ts( &file ); ts << configString ; file.close(); } } void SimpleAlarmDaemonImpl::confSuspend( int num ) { mSuspendPopUp->setItemChecked ( mSuspend,false ); mSuspend = num; @@ -526,175 +527,175 @@ void SimpleAlarmDaemonImpl::confTimer( int time ) 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 ); 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 ); 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() ; + mTimerStartLabel->setText( disp + "\n\nTimer started!" ); + int w = mTimerStartLabel->sizeHint().width()+20; + int h = mTimerStartLabel->sizeHint().height()+40 ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); mTimerStartLabel->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); mTimerStartLabel->show(); - QTimer::singleShot( 2000, mTimerStartLabel, SLOT ( hide() ) ); + 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() { QCopEnvelope e("QPE/Application/ompi", "newMail()"); } void SimpleAlarmDaemonImpl::showAdd() { QCopEnvelope e("QPE/Application/kapi", "raise()"); } void SimpleAlarmDaemonImpl::ringSync() { QCopEnvelope e("QPE/Application/kopi", "-ringSync"); } void SimpleAlarmDaemonImpl::newCountdown() { //recieve("cal_alarm", 10 ); } void SimpleAlarmDaemonImpl::simulate() { QTimer::singleShot( 5000, this, SLOT ( writeFile() ) ); QString filename = getenv("QPEDIR") ; filename += "/pics/kdepim/korganizer/koalarm.wav"; startAlarm("Alarm simulation", filename ); } void SimpleAlarmDaemonImpl::showKO() { QCopEnvelope e("QPE/Application/kopi", "-showKO"); // testing only //QCopEnvelope e("QPE/Application/kopi", "nextView()"); } void SimpleAlarmDaemonImpl::showTodo() { QCopEnvelope e("QPE/Application/kopi", "-showTodo"); } void SimpleAlarmDaemonImpl::writeJournal() { QCopEnvelope e("QPE/Application/kopi", "-showJournal"); } void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) { mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); } |