author | zautrix <zautrix> | 2005-04-08 23:40:38 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-08 23:40:38 (UTC) |
commit | a74c23d91e80343cd1ccfd1fe712958fad1d5891 (patch) (side-by-side diff) | |
tree | 2dc90dffe822e1425ace17cdbf9e420fa0be6ac7 /kalarmd/alarmdialog.cpp | |
parent | c4bab697d650c249cdff45b753b9e6df2a817877 (diff) | |
download | kdepimpi-a74c23d91e80343cd1ccfd1fe712958fad1d5891.zip kdepimpi-a74c23d91e80343cd1ccfd1fe712958fad1d5891.tar.gz kdepimpi-a74c23d91e80343cd1ccfd1fe712958fad1d5891.tar.bz2 |
ad fix
-rw-r--r-- | kalarmd/alarmdialog.cpp | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/kalarmd/alarmdialog.cpp b/kalarmd/alarmdialog.cpp index 65073f6..d72a8c2 100644 --- a/kalarmd/alarmdialog.cpp +++ b/kalarmd/alarmdialog.cpp @@ -84,65 +84,66 @@ AlarmDialog::AlarmDialog(QWidget *parent,const char *name) fo.setPointSize( fs ); mMessage->setFont(fo ); mMessage->setAlignment( AlignCenter); layout->addWidget ( mMessage ); mMissedAlarms= new QLabel ( "(No missed Alarms)", this ); mMissedAlarms->setAlignment( AlignCenter); playSoundTimer = new QTimer( this ); connect ( playSoundTimer, SIGNAL( timeout() ), this, SLOT (playSound() ) ); playSoundTimer->stop(); layout->addWidget ( mMissedAlarms ); mMissedAlarmsCombo = new QComboBox ( this ); layout->addWidget ( mMissedAlarmsCombo ); - QLabel* labb = new QLabel("Suspend duration (minutes):",this); + QLabel* labb = new QLabel("Suspend\nduration\n(minutes):",this); labb->setAlignment(AlignCenter); - layout->addWidget ( labb ); + //layout->addWidget ( labb ); fo = font(); int pointSize = 36; if ( QApplication::desktop()->width() <= 320 ) pointSize = 18; fo.setPointSize( pointSize ); mSuspendSpin = new QSpinBox(1,1440,1,this); mSuspendSpin->setFont( fo ); mSuspendSpin->setValue(7); // default suspend duration mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); #if QT_VERSION < 0x030000 mSuspendSpin->upButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); mSuspendSpin->downButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); #endif mSuspendSpin->setFixedSize( 18*baseSize, 10*baseSize+2 ); mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); QHBoxLayout* layoutSpin = new QHBoxLayout( layout ); layoutSpin->addStretch (); + layoutSpin->addWidget ( labb ); layoutSpin->addWidget ( mSuspendSpin ); layoutSpin->addStretch (); QVBox * bbox = new QVBox ( this ); layout->addWidget ( bbox ); bbox->layout()->setSpacing( 2 ); labb = new QLabel("Press \"Cancel\" or \"Esc\" to suspend!",bbox); labb->setAlignment(AlignCenter); mSuspendButton = new QPushButton( "Suspend", bbox); QPushButton* silen = new QPushButton( " Stop sound ", bbox); - QPushButton* okbut = new QPushButton( "Ok", bbox); + okbut = new QPushButton( "Ok", bbox); mSuspendButton->setFont( fo ); silen->setFont( fo ); okbut->setFont( fo ); okbut->setDefault( true ); connect (silen , SIGNAL( clicked() ), this, SLOT (silent() ) ); connect (mSuspendButton, SIGNAL( clicked() ), this, SLOT (slotSuspend() ) ); connect (okbut , SIGNAL( clicked() ), this, SLOT (slotOk() ) ); connect (mSuspendSpin , SIGNAL( valueChanged ( int ) ), this, SLOT ( spinBoxChanged( int ) ) ); #ifndef _WIN32_ if ( QFile::exists ( "/dev/sharp_led" ) ) fd_led = open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); else #endif fd_led = 0; statusLED.which = SHARP_LED_SALARM; mSilent = false; @@ -228,73 +229,78 @@ bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, boo 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 =sizeHint().width() ; - int h = sizeHint().height() ; + int w = minimumSizeHint().width() ; + int h = minimumSizeHint().height() ; int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); - show(); - raise(); - //qApp->processEvents(); - //repaint(); - qApp->processEvents(); + hide(); #ifndef _WIN32_ if ( fd_led > 0 ) { statusLED.status = LED_SALARM_ON ; ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); } #endif - playSoundTimer->start( 1000, true ); + okbut->setDefault( true ); + QTimer::singleShot( 1, this, SLOT ( forceRepaint() ) ); + // playSoundTimer->start( 1000, true ); return true; } -void AlarmDialog::spinBoxChanged( int ) +void AlarmDialog::forceRepaint() { + + showNormal(); + setActiveWindow(); + raise(); + 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(); - - - qApp->processEvents(); 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 |