author | zautrix <zautrix> | 2005-09-18 23:40:38 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-09-18 23:40:38 (UTC) |
commit | 2d346e4052fd726e657daee4ac3f2bcc7103f5fb (patch) (side-by-side diff) | |
tree | 9952b888e0790bc032ba4e0c3c4165ec283a4139 /kalarmd | |
parent | 06ebec95579816144ee65981835e6e3482e20a28 (diff) | |
download | kdepimpi-2d346e4052fd726e657daee4ac3f2bcc7103f5fb.zip kdepimpi-2d346e4052fd726e657daee4ac3f2bcc7103f5fb.tar.gz kdepimpi-2d346e4052fd726e657daee4ac3f2bcc7103f5fb.tar.bz2 |
wn
-rw-r--r-- | kalarmd/alarmdialog.cpp | 12 | ||||
-rw-r--r-- | kalarmd/simplealarmdaemonimpl.cpp | 11 |
2 files changed, 16 insertions, 7 deletions
diff --git a/kalarmd/alarmdialog.cpp b/kalarmd/alarmdialog.cpp index ddb125a..18ce9da 100644 --- a/kalarmd/alarmdialog.cpp +++ b/kalarmd/alarmdialog.cpp @@ -190,150 +190,154 @@ void AlarmDialog::slotOk() if ( fd_led > 0 ) { statusLED.status = LED_SALARM_OFF ; ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); } #endif QDialog::accept(); } void AlarmDialog::slotSuspend() { //qDebug("AlarmDialog::suspend() "); // emit suspendSignal(mSuspendSpin->value()); mStopAlarm = true; QDateTime nextA = QDateTime::currentDateTime().addSecs( mSuspendSpin->value() * 60 ); QString mess = "suspend_alarm" +mFileName+"+++" ; if ( mMessage->text().left( 10 ) !="Suspended:" ) mess += "Suspended:\n"; mess +=mMessage->text(); #ifndef DESKTOP_VERSION if ( mServerNotification ) AlarmServer::addAlarm ( nextA,"koalarm",mess.latin1()); #endif emit addAlarm( nextA , mess ); slotOk(); } void AlarmDialog::setServerNotification( bool b ) { mServerNotification = b; } int AlarmDialog::getSuspendTime( ) { return mSuspendSpin->value(); } void AlarmDialog::setSuspendTime( int val ) { mSuspendSpin->setValue( val ); } bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, bool playwav, int pause , int suspendtimes) { if ( mess.left( 9) != "Suspended" ) mSuspendCounter = suspendtimes; mPauseCount = pause; mFileName = fn; mPlayWav = playwav; if ( !QFile::exists( fn ) ) mFileName = ""; alarmCounter = 0 ; maxAlarmReplay = replay ; mStopAlarm = false; mSilent = false; if ( !mMessage->text().stripWhiteSpace().isEmpty() ) { mMissedAlarmsCombo->show(); QString newItem = mMessage->text().stripWhiteSpace(); newItem.replace( QRegExp("\n"), QString(" ") ); mMissedAlarmsCombo->insertItem( newItem ); mMissedAlarms->setText( "Missed alarms:"); } else mMissedAlarmsCombo->hide(); mMessage->setText(mess); int w = minimumSizeHint().width() ; int h = minimumSizeHint().height() ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); + if ( w < 220 ) w = 220; + if ( h < 220 ) h = 220; setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); - hide(); + showNormal(); + setActiveWindow(); + raise(); + setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); + //hide(); #ifndef _WIN32_ if ( fd_led > 0 ) { statusLED.status = LED_SALARM_ON ; ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); } #endif okbut->setDefault( true ); QTimer::singleShot( 1, this, SLOT ( forceRepaint() ) ); // playSoundTimer->start( 1000, true ); return true; } void AlarmDialog::forceRepaint() { - - showNormal(); setActiveWindow(); - raise(); + repaint(); mSuspendSpin->setFocus(); playSoundTimer->start( 1000, true ); } void AlarmDialog::spinBoxChanged( int v ) { okbut->setDefault( false ); mSilent = true; } void AlarmDialog::playSound () { if (mStopAlarm ) return; if ( mSilent ) return; //showNormal(); setActiveWindow(); //raise(); mSuspendSpin->setFocus(); if ( alarmCounter < maxAlarmReplay && ! mSilent) { ++alarmCounter; #ifdef DESKTOP_VERSION mPlayWav = true; #endif if ( !mPlayWav || mFileName.length() < 2 ) { #ifdef DESKTOP_VERSION qDebug("Sound play not possible - file not found"); #else Sound::soundAlarm (); #endif } else { #ifdef DESKTOP_VERSION #ifdef _WIN32_ QSound::play ( mFileName ); #else QString command = "playwave -r 22050 " + mFileName; qDebug("KO: Playing file %s with 22kHz",mFileName.latin1() ); int ret = system ( command.latin1() ); if ( ret != 0 ) { qDebug("Sound play command failed: %s ",command.latin1() ); } #endif #else QSound::play ( mFileName ); #endif qDebug("BEEP!"); } } else { if ( ! mSilent && mSuspendCounter > 0 ) { --mSuspendCounter; reject (); hide(); return; } } playSoundTimer->start( mPauseCount * 1000, true ); diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp index a0ac232..8ea8a73 100644 --- a/kalarmd/simplealarmdaemonimpl.cpp +++ b/kalarmd/simplealarmdaemonimpl.cpp @@ -6,128 +6,133 @@ 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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 "simplealarmdaemonimpl.h" #include "alarmdialog.h" #include <qpopupmenu.h> #include <qapp.h> #include <qdir.h> #include <qfile.h> #include <qhbox.h> #include <qtimer.h> #include <qfile.h> #include <qdatetime.h> #include <qpushbutton.h> #include <qlayout.h> #include <qlineedit.h> #include <qdialog.h> #define protected public #include <qspinbox.h> #undef protected #include <qtextstream.h> #include <qtopia/qcopenvelope_qws.h> #include <qtopia/alarmserver.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h> SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) : QLabel( parent ) { mAlarmDialog = new AlarmDialog( 0 ); 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; @@ -252,155 +257,155 @@ void SimpleAlarmDaemonImpl::confSound( int num ) mSoundPopUp->setItemChecked ( 1, true ); } } void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) { if ( num == 1000 ) { simulate(); return; } mBeepPopUp->setItemChecked ( mPlayBeeps,false ); mPlayBeeps = num; mBeepPopUp->setItemChecked ( mPlayBeeps, true ); } void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) { //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); QString mess = QString::fromUtf8(msg.data()); mAlarmMessage = mess.mid( 9 ); QString filename = getenv("QPEDIR") ; filename += "/pics/kdepim/korganizer/koalarm.wav"; QString tempfilename; if ( mess.left( 13 ) == "suspend_alarm") { bool error = false; int len = mess.mid( 13 ).find("+++"); if ( len < 2 ) error = true; else { tempfilename = mess.mid( 13, len ); if ( !QFile::exists( tempfilename ) ) error = true; } if ( ! error ) { filename = tempfilename; } mAlarmMessage = mess.mid( 13+len+3 ); //qDebug("suspend file %s ",tempfilename.latin1() ); startAlarm( mAlarmMessage, filename); return; } if ( mess.left( 11 ) == "timer_alarm") { mTimerTime = 0; startAlarm( mess.mid( 11 ), filename ); return; } if ( mess.left( 10 ) == "proc_alarm") { bool error = false; int len = mess.mid( 10 ).find("+++"); if ( len < 2 ) error = true; else { tempfilename = mess.mid( 10, len ); if ( !QFile::exists( tempfilename ) ) error = true; } if ( error ) { mAlarmMessage = "Procedure Alarm\nError - File not found\n"; mAlarmMessage += mess.mid( 10+len+3+9 ); } else { //qDebug("-----system command %s ",tempfilename.latin1() ); if ( vfork () == 0 ) { execl ( tempfilename.latin1(), 0 ); return; } - QTimer::singleShot( 10000, this, SLOT ( writeFile() ) ); + QTimer::singleShot( 5000, this, SLOT ( writeFile() ) ); return; } //qDebug("+++++++system command %s ",tempfilename.latin1() ); } if ( mess.left( 11 ) == "audio_alarm") { bool error = false; int len = mess.mid( 11 ).find("+++"); if ( len < 2 ) error = true; else { tempfilename = mess.mid( 11, len ); if ( !QFile::exists( tempfilename ) ) error = true; } if ( ! error ) { filename = tempfilename; } mAlarmMessage = mess.mid( 11+len+3+9 ); //qDebug("audio file command %s ",tempfilename.latin1() ); } if ( mess.left( 9 ) == "cal_alarm") { mAlarmMessage = mess.mid( 9 ) ; } - QTimer::singleShot( 10000, this, SLOT ( writeFile() ) ); + QTimer::singleShot( 5000, this, SLOT ( writeFile() ) ); startAlarm( mAlarmMessage, filename ); } int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) { return 0; } void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) { //mAlarmDialog->show(); //mAlarmDialog->raise(); mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); } void SimpleAlarmDaemonImpl::fillTimerPopUp() { // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); if ( mTimerPopupConf == mTimerTime ) { if ( mTimerTime ) { int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); QTime t ( secs/3600, (secs/60)%60, secs%60 ); mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); } else { QString text = mCustomText.stripWhiteSpace (); int in = text.find( " " ); text = text.left ( in ); mTimerPopUp->changeItem ( 3, text ); } return; } 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 += "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"; @@ -581,94 +586,94 @@ void SimpleAlarmDaemonImpl::confTimer( int time ) mCustomText = lEdit.text(); mCustomMinutes = spinh.value()*60+spinm.value(); if ( mCustomMinutes == 0 ) mCustomMinutes = 1; if ( mCustomMinutes > 1440 ) mCustomMinutes = 1440; mess += mCustomText; minutes = mCustomMinutes; mRunningTimerText = mCustomText.stripWhiteSpace (); int in = mRunningTimerText.find( " " ); mRunningTimerText = mRunningTimerText.left ( in ); } else { mess += 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()); 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( 10000, this, SLOT ( writeFile() ) ); + 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() ))); } |