-rw-r--r-- | kalarmd/alarmdialog.cpp | 5 | ||||
-rw-r--r-- | kalarmd/alarmdialog.h | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/kalarmd/alarmdialog.cpp b/kalarmd/alarmdialog.cpp index 53ff488..65073f6 100644 --- a/kalarmd/alarmdialog.cpp +++ b/kalarmd/alarmdialog.cpp | |||
@@ -108,64 +108,65 @@ AlarmDialog::AlarmDialog(QWidget *parent,const char *name) | |||
108 | mSuspendSpin = new QSpinBox(1,1440,1,this); | 108 | mSuspendSpin = new QSpinBox(1,1440,1,this); |
109 | mSuspendSpin->setFont( fo ); | 109 | mSuspendSpin->setFont( fo ); |
110 | mSuspendSpin->setValue(7); // default suspend duration | 110 | mSuspendSpin->setValue(7); // default suspend duration |
111 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); | 111 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); |
112 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); | 112 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); |
113 | 113 | ||
114 | #if QT_VERSION < 0x030000 | 114 | #if QT_VERSION < 0x030000 |
115 | mSuspendSpin->upButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); | 115 | mSuspendSpin->upButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); |
116 | mSuspendSpin->downButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); | 116 | mSuspendSpin->downButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); |
117 | #endif | 117 | #endif |
118 | mSuspendSpin->setFixedSize( 18*baseSize, 10*baseSize+2 ); | 118 | mSuspendSpin->setFixedSize( 18*baseSize, 10*baseSize+2 ); |
119 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); | 119 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); |
120 | QHBoxLayout* layoutSpin = new QHBoxLayout( layout ); | 120 | QHBoxLayout* layoutSpin = new QHBoxLayout( layout ); |
121 | layoutSpin->addStretch (); | 121 | layoutSpin->addStretch (); |
122 | layoutSpin->addWidget ( mSuspendSpin ); | 122 | layoutSpin->addWidget ( mSuspendSpin ); |
123 | layoutSpin->addStretch (); | 123 | layoutSpin->addStretch (); |
124 | 124 | ||
125 | QVBox * bbox = new QVBox ( this ); | 125 | QVBox * bbox = new QVBox ( this ); |
126 | layout->addWidget ( bbox ); | 126 | layout->addWidget ( bbox ); |
127 | bbox->layout()->setSpacing( 2 ); | 127 | bbox->layout()->setSpacing( 2 ); |
128 | labb = new QLabel("Press \"Cancel\" or \"Esc\" to suspend!",bbox); | 128 | labb = new QLabel("Press \"Cancel\" or \"Esc\" to suspend!",bbox); |
129 | labb->setAlignment(AlignCenter); | 129 | labb->setAlignment(AlignCenter); |
130 | mSuspendButton = new QPushButton( "Suspend", bbox); | 130 | mSuspendButton = new QPushButton( "Suspend", bbox); |
131 | QPushButton* silen = new QPushButton( " Stop sound ", bbox); | 131 | QPushButton* silen = new QPushButton( " Stop sound ", bbox); |
132 | QPushButton* okbut = new QPushButton( "Ok", bbox); | 132 | QPushButton* okbut = new QPushButton( "Ok", bbox); |
133 | mSuspendButton->setFont( fo ); | 133 | mSuspendButton->setFont( fo ); |
134 | silen->setFont( fo ); | 134 | silen->setFont( fo ); |
135 | okbut->setFont( fo ); | 135 | okbut->setFont( fo ); |
136 | okbut->setDefault( true ); | 136 | okbut->setDefault( true ); |
137 | connect (silen , SIGNAL( clicked() ), this, SLOT (silent() ) ); | 137 | connect (silen , SIGNAL( clicked() ), this, SLOT (silent() ) ); |
138 | connect (mSuspendButton, SIGNAL( clicked() ), this, SLOT (slotSuspend() ) ); | 138 | connect (mSuspendButton, SIGNAL( clicked() ), this, SLOT (slotSuspend() ) ); |
139 | connect (okbut , SIGNAL( clicked() ), this, SLOT (slotOk() ) ); | 139 | connect (okbut , SIGNAL( clicked() ), this, SLOT (slotOk() ) ); |
140 | connect (mSuspendSpin , SIGNAL( valueChanged ( int ) ), this, SLOT ( spinBoxChanged( int ) ) ); | ||
140 | #ifndef _WIN32_ | 141 | #ifndef _WIN32_ |
141 | if ( QFile::exists ( "/dev/sharp_led" ) ) | 142 | if ( QFile::exists ( "/dev/sharp_led" ) ) |
142 | fd_led = open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 143 | fd_led = open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
143 | else | 144 | else |
144 | #endif | 145 | #endif |
145 | fd_led = 0; | 146 | fd_led = 0; |
146 | statusLED.which = SHARP_LED_SALARM; | 147 | statusLED.which = SHARP_LED_SALARM; |
147 | mSilent = false; | 148 | mSilent = false; |
148 | mSuspendCounter = 0; | 149 | mSuspendCounter = 0; |
149 | setServerNotification( true ); | 150 | setServerNotification( true ); |
150 | } | 151 | } |
151 | void AlarmDialog::reject () | 152 | void AlarmDialog::reject () |
152 | { | 153 | { |
153 | QTimer::singleShot ( 3000, this, SLOT (suspend()) ); | 154 | QTimer::singleShot ( 3000, this, SLOT (suspend()) ); |
154 | slotSuspend(); | 155 | slotSuspend(); |
155 | } | 156 | } |
156 | AlarmDialog::~AlarmDialog() | 157 | AlarmDialog::~AlarmDialog() |
157 | { | 158 | { |
158 | } | 159 | } |
159 | void AlarmDialog::silent () | 160 | void AlarmDialog::silent () |
160 | { | 161 | { |
161 | mSilent = true; | 162 | mSilent = true; |
162 | } | 163 | } |
163 | void AlarmDialog::accept() | 164 | void AlarmDialog::accept() |
164 | { | 165 | { |
165 | slotOk(); | 166 | slotOk(); |
166 | } | 167 | } |
167 | 168 | ||
168 | void AlarmDialog::suspend() | 169 | void AlarmDialog::suspend() |
169 | { | 170 | { |
170 | #ifdef DESKTOP_VERSION | 171 | #ifdef DESKTOP_VERSION |
171 | 172 | ||
@@ -233,64 +234,68 @@ bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, boo | |||
233 | mSilent = false; | 234 | mSilent = false; |
234 | if ( !mMessage->text().stripWhiteSpace().isEmpty() ) { | 235 | if ( !mMessage->text().stripWhiteSpace().isEmpty() ) { |
235 | mMissedAlarmsCombo->show(); | 236 | mMissedAlarmsCombo->show(); |
236 | QString newItem = mMessage->text().stripWhiteSpace(); | 237 | QString newItem = mMessage->text().stripWhiteSpace(); |
237 | newItem.replace( QRegExp("\n"), QString(" ") ); | 238 | newItem.replace( QRegExp("\n"), QString(" ") ); |
238 | mMissedAlarmsCombo->insertItem( newItem ); | 239 | mMissedAlarmsCombo->insertItem( newItem ); |
239 | mMissedAlarms->setText( "Missed alarms:"); | 240 | mMissedAlarms->setText( "Missed alarms:"); |
240 | } else | 241 | } else |
241 | mMissedAlarmsCombo->hide(); | 242 | mMissedAlarmsCombo->hide(); |
242 | mMessage->setText(mess); | 243 | mMessage->setText(mess); |
243 | int w =sizeHint().width() ; | 244 | int w =sizeHint().width() ; |
244 | int h = sizeHint().height() ; | 245 | int h = sizeHint().height() ; |
245 | int dw = QApplication::desktop()->width(); | 246 | int dw = QApplication::desktop()->width(); |
246 | int dh = QApplication::desktop()->height(); | 247 | int dh = QApplication::desktop()->height(); |
247 | setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 248 | setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
248 | show(); | 249 | show(); |
249 | raise(); | 250 | raise(); |
250 | //qApp->processEvents(); | 251 | //qApp->processEvents(); |
251 | //repaint(); | 252 | //repaint(); |
252 | qApp->processEvents(); | 253 | qApp->processEvents(); |
253 | 254 | ||
254 | #ifndef _WIN32_ | 255 | #ifndef _WIN32_ |
255 | if ( fd_led > 0 ) { | 256 | if ( fd_led > 0 ) { |
256 | statusLED.status = LED_SALARM_ON ; | 257 | statusLED.status = LED_SALARM_ON ; |
257 | ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); | 258 | ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); |
258 | } | 259 | } |
259 | #endif | 260 | #endif |
260 | playSoundTimer->start( 1000, true ); | 261 | playSoundTimer->start( 1000, true ); |
261 | return true; | 262 | return true; |
262 | 263 | ||
263 | } | 264 | } |
264 | 265 | ||
266 | void AlarmDialog::spinBoxChanged( int ) | ||
267 | { | ||
268 | mSilent = true; | ||
269 | } | ||
265 | 270 | ||
266 | void AlarmDialog::playSound () | 271 | void AlarmDialog::playSound () |
267 | { | 272 | { |
268 | 273 | ||
269 | if (mStopAlarm ) | 274 | if (mStopAlarm ) |
270 | return; | 275 | return; |
271 | if ( mSilent ) | 276 | if ( mSilent ) |
272 | return; | 277 | return; |
273 | showNormal(); | 278 | showNormal(); |
274 | setActiveWindow(); | 279 | setActiveWindow(); |
275 | raise(); | 280 | raise(); |
276 | mSuspendSpin->setFocus(); | 281 | mSuspendSpin->setFocus(); |
277 | 282 | ||
278 | 283 | ||
279 | qApp->processEvents(); | 284 | qApp->processEvents(); |
280 | if ( alarmCounter < maxAlarmReplay && ! mSilent) { | 285 | if ( alarmCounter < maxAlarmReplay && ! mSilent) { |
281 | ++alarmCounter; | 286 | ++alarmCounter; |
282 | #ifdef DESKTOP_VERSION | 287 | #ifdef DESKTOP_VERSION |
283 | mPlayWav = true; | 288 | mPlayWav = true; |
284 | #endif | 289 | #endif |
285 | if ( !mPlayWav || mFileName.length() < 2 ) { | 290 | if ( !mPlayWav || mFileName.length() < 2 ) { |
286 | 291 | ||
287 | #ifdef DESKTOP_VERSION | 292 | #ifdef DESKTOP_VERSION |
288 | qDebug("Sound play not possible - file not found"); | 293 | qDebug("Sound play not possible - file not found"); |
289 | #else | 294 | #else |
290 | Sound::soundAlarm (); | 295 | Sound::soundAlarm (); |
291 | #endif | 296 | #endif |
292 | } else | 297 | } else |
293 | 298 | ||
294 | { | 299 | { |
295 | #ifdef DESKTOP_VERSION | 300 | #ifdef DESKTOP_VERSION |
296 | #ifdef _WIN32_ | 301 | #ifdef _WIN32_ |
diff --git a/kalarmd/alarmdialog.h b/kalarmd/alarmdialog.h index 896cf60..1e4636c 100644 --- a/kalarmd/alarmdialog.h +++ b/kalarmd/alarmdialog.h | |||
@@ -21,64 +21,65 @@ | |||
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef ALARMDIALOG_H | 23 | #ifndef ALARMDIALOG_H |
24 | #define ALARMDIALOG_H | 24 | #define ALARMDIALOG_H |
25 | 25 | ||
26 | 26 | ||
27 | 27 | ||
28 | #include <qdialog.h> | 28 | #include <qdialog.h> |
29 | #include <qdatetime.h> | 29 | #include <qdatetime.h> |
30 | #include <qstring.h> | 30 | #include <qstring.h> |
31 | #include <qcombobox.h> | 31 | #include <qcombobox.h> |
32 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
33 | 33 | ||
34 | #include "sharp_char.h" | 34 | #include "sharp_char.h" |
35 | 35 | ||
36 | 36 | ||
37 | class QSpinBox; | 37 | class QSpinBox; |
38 | class QLabel; | 38 | class QLabel; |
39 | class QString; | 39 | class QString; |
40 | 40 | ||
41 | class AlarmDialog : public QDialog { | 41 | class AlarmDialog : public QDialog { |
42 | Q_OBJECT | 42 | Q_OBJECT |
43 | public: | 43 | public: |
44 | AlarmDialog( QWidget *parent = 0, const char *name = 0 ); | 44 | AlarmDialog( QWidget *parent = 0, const char *name = 0 ); |
45 | virtual ~AlarmDialog(); | 45 | virtual ~AlarmDialog(); |
46 | 46 | ||
47 | bool eventNotification(QString m, int replay , QString m2 , bool, int, int ); | 47 | bool eventNotification(QString m, int replay , QString m2 , bool, int, int ); |
48 | int getSuspendTime( ); | 48 | int getSuspendTime( ); |
49 | void setSuspendTime( int ); | 49 | void setSuspendTime( int ); |
50 | void setServerNotification( bool b ); | 50 | void setServerNotification( bool b ); |
51 | 51 | ||
52 | public slots: | 52 | public slots: |
53 | void spinBoxChanged( int ); | ||
53 | void slotOk(); | 54 | void slotOk(); |
54 | void slotSuspend(); | 55 | void slotSuspend(); |
55 | void reject () ; | 56 | void reject () ; |
56 | void silent () ; | 57 | void silent () ; |
57 | void accept(); | 58 | void accept(); |
58 | void suspend(); | 59 | void suspend(); |
59 | void playSound (); | 60 | void playSound (); |
60 | signals: | 61 | signals: |
61 | // void suspendSignal(int duration); | 62 | // void suspendSignal(int duration); |
62 | void addAlarm(const QDateTime &, const QString & ); | 63 | void addAlarm(const QDateTime &, const QString & ); |
63 | 64 | ||
64 | private: | 65 | private: |
65 | int alarmCounter; | 66 | int alarmCounter; |
66 | int mPauseCount; | 67 | int mPauseCount; |
67 | int mSuspendCounter; | 68 | int mSuspendCounter; |
68 | int maxAlarmReplay; | 69 | int maxAlarmReplay; |
69 | QTimer* playSoundTimer; | 70 | QTimer* playSoundTimer; |
70 | bool mStopAlarm; | 71 | bool mStopAlarm; |
71 | bool mSilent; | 72 | bool mSilent; |
72 | bool mPlayWav; | 73 | bool mPlayWav; |
73 | bool mServerNotification; | 74 | bool mServerNotification; |
74 | QLabel* mMessage; | 75 | QLabel* mMessage; |
75 | QLabel* mMissedAlarms; | 76 | QLabel* mMissedAlarms; |
76 | QSpinBox *mSuspendSpin; | 77 | QSpinBox *mSuspendSpin; |
77 | QComboBox *mMissedAlarmsCombo; | 78 | QComboBox *mMissedAlarmsCombo; |
78 | QPushButton* mSuspendButton; | 79 | QPushButton* mSuspendButton; |
79 | QString mFileName; | 80 | QString mFileName; |
80 | int fd_led; | 81 | int fd_led; |
81 | sharp_led_status statusLED; | 82 | sharp_led_status statusLED; |
82 | }; | 83 | }; |
83 | 84 | ||
84 | #endif | 85 | #endif |