-rw-r--r-- | kalarmd/alarmdialog.cpp | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/kalarmd/alarmdialog.cpp b/kalarmd/alarmdialog.cpp index c939ae0..7ead3b9 100644 --- a/kalarmd/alarmdialog.cpp +++ b/kalarmd/alarmdialog.cpp | |||
@@ -44,12 +44,13 @@ | |||
44 | #include <fcntl.h> | 44 | #include <fcntl.h> |
45 | 45 | ||
46 | #ifndef DESKTOP_VERSION | 46 | #ifndef DESKTOP_VERSION |
47 | #include <qtopia/alarmserver.h> | 47 | #include <qtopia/alarmserver.h> |
48 | #include <qpe/resource.h> | 48 | #include <qpe/resource.h> |
49 | #include <qtopia/sound.h> | 49 | #include <qtopia/sound.h> |
50 | |||
50 | #endif | 51 | #endif |
51 | 52 | ||
52 | #include "alarmdialog.h" | 53 | #include "alarmdialog.h" |
53 | 54 | ||
54 | 55 | ||
55 | AlarmDialog::AlarmDialog(QWidget *parent,const char *name) | 56 | AlarmDialog::AlarmDialog(QWidget *parent,const char *name) |
@@ -88,34 +89,42 @@ AlarmDialog::AlarmDialog(QWidget *parent,const char *name) | |||
88 | 89 | ||
89 | playSoundTimer->stop(); | 90 | playSoundTimer->stop(); |
90 | 91 | ||
91 | layout->addWidget ( mMissedAlarms ); | 92 | layout->addWidget ( mMissedAlarms ); |
92 | mMissedAlarmsCombo = new QComboBox ( this ); | 93 | mMissedAlarmsCombo = new QComboBox ( this ); |
93 | layout->addWidget ( mMissedAlarmsCombo ); | 94 | layout->addWidget ( mMissedAlarmsCombo ); |
94 | QVBox *suspendBox = new QVBox( this ); | 95 | |
95 | suspendBox->setSpacing(3); | 96 | QLabel* labb = new QLabel("Suspend duration (minutes):",this); |
96 | layout->addWidget ( suspendBox ); | ||
97 | QLabel* labb = new QLabel("Suspend duration (minutes):",suspendBox); | ||
98 | labb->setAlignment(AlignCenter); | 97 | labb->setAlignment(AlignCenter); |
98 | layout->addWidget ( labb ); | ||
99 | fo = font(); | 99 | fo = font(); |
100 | fo.setPointSize( 36 ); | 100 | int pointSize = 36; |
101 | mSuspendSpin = new QSpinBox(1,1440,1,suspendBox); | 101 | if ( QApplication::desktop()->width() <= 320 ) |
102 | pointSize = 24; | ||
103 | fo.setPointSize( pointSize ); | ||
104 | mSuspendSpin = new QSpinBox(1,1440,1,this); | ||
102 | mSuspendSpin->setFont( fo ); | 105 | mSuspendSpin->setFont( fo ); |
103 | mSuspendSpin->setValue(7); // default suspend duration | 106 | mSuspendSpin->setValue(7); // default suspend duration |
104 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); | 107 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); |
105 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); | 108 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); |
106 | #if QT_VERSION < 0x030000 | 109 | #if QT_VERSION < 0x030000 |
107 | mSuspendSpin->upButton ()->setFixedSize( QSize( 48, 30 )); | 110 | mSuspendSpin->upButton ()->setFixedSize( QSize( 48, 30 )); |
108 | mSuspendSpin->downButton ()->setFixedSize( QSize( 48, 30 )); | 111 | mSuspendSpin->downButton ()->setFixedSize( QSize( 48, 30 )); |
109 | #endif | 112 | #endif |
110 | mSuspendSpin->setFixedSize( 100,62 ); | 113 | mSuspendSpin->setFixedSize( 100,62 ); |
111 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); | 114 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); |
115 | QHBoxLayout* layoutSpin = new QHBoxLayout( layout ); | ||
116 | layoutSpin->addStretch (); | ||
117 | layoutSpin->addWidget ( mSuspendSpin ); | ||
118 | layoutSpin->addStretch (); | ||
112 | 119 | ||
113 | QVBox * bbox = new QVBox ( this ); | 120 | QVBox * bbox = new QVBox ( this ); |
114 | layout->addWidget ( bbox ); | 121 | layout->addWidget ( bbox ); |
115 | bbox->layout()->setSpacing( 2 ); | 122 | bbox->layout()->setSpacing( 2 ); |
123 | labb = new QLabel("Press \"Cancel\" or \"Esc\" to suspend!",bbox); | ||
124 | labb->setAlignment(AlignCenter); | ||
116 | mSuspendButton = new QPushButton( "Suspend", bbox); | 125 | mSuspendButton = new QPushButton( "Suspend", bbox); |
117 | QPushButton* silen = new QPushButton( " Stop sound ", bbox); | 126 | QPushButton* silen = new QPushButton( " Stop sound ", bbox); |
118 | QPushButton* okbut = new QPushButton( "Ok", bbox); | 127 | QPushButton* okbut = new QPushButton( "Ok", bbox); |
119 | mSuspendButton->setFont( fo ); | 128 | mSuspendButton->setFont( fo ); |
120 | silen->setFont( fo ); | 129 | silen->setFont( fo ); |
121 | okbut->setFont( fo ); | 130 | okbut->setFont( fo ); |
@@ -256,21 +265,44 @@ void AlarmDialog::playSound () | |||
256 | mSuspendSpin->setFocus(); | 265 | mSuspendSpin->setFocus(); |
257 | raise(); | 266 | raise(); |
258 | 267 | ||
259 | qApp->processEvents(); | 268 | qApp->processEvents(); |
260 | if ( alarmCounter < maxAlarmReplay && ! mSilent) { | 269 | if ( alarmCounter < maxAlarmReplay && ! mSilent) { |
261 | ++alarmCounter; | 270 | ++alarmCounter; |
271 | #ifdef DESKTOP_VERSION | ||
272 | mPlayWav = true; | ||
273 | #endif | ||
262 | if ( !mPlayWav || mFileName.length() < 2 ) { | 274 | if ( !mPlayWav || mFileName.length() < 2 ) { |
263 | 275 | ||
264 | #ifndef DESKTOP_VERSION | 276 | #ifdef DESKTOP_VERSION |
277 | qDebug("Sound play not possible - file not found"); | ||
278 | #else | ||
265 | Sound::soundAlarm (); | 279 | Sound::soundAlarm (); |
266 | #endif | 280 | #endif |
267 | } else { | 281 | } else |
282 | |||
283 | { | ||
284 | #ifdef DESKTOP_VERSION | ||
285 | #ifdef _WIN32_ | ||
286 | QSound::play ( mFileName ); | ||
287 | #else | ||
288 | |||
289 | QString command = "playwave -r 22050 " + mFileName; | ||
290 | qDebug("KO: Playing file %s with 22kHz",mFileName.latin1() ); | ||
291 | int ret = system ( command.latin1() ); | ||
292 | if ( ret != 0 ) { | ||
293 | qDebug("Sound play command failed: %s ",command.latin1() ); | ||
294 | } | ||
295 | |||
296 | #endif | ||
297 | |||
298 | #else | ||
268 | QSound::play ( mFileName ); | 299 | QSound::play ( mFileName ); |
300 | #endif | ||
269 | //qDebug("BEEP!"); | 301 | //qDebug("BEEP!"); |
270 | } | 302 | } |
271 | } else { | 303 | } else { |
272 | if ( ! mSilent && mSuspendCounter > 0 ) { | 304 | if ( ! mSilent && mSuspendCounter > 0 ) { |
273 | --mSuspendCounter; | 305 | --mSuspendCounter; |
274 | reject (); | 306 | reject (); |
275 | hide(); | 307 | hide(); |
276 | return; | 308 | return; |