author | zautrix <zautrix> | 2005-07-01 17:57:30 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-01 17:57:30 (UTC) |
commit | 98d29d15275c4b8e9a3348742925f6e6d03f7a07 (patch) (unidiff) | |
tree | ea0af6d2100287c696bb00e1197d6c99f29f41e8 /kalarmd | |
parent | f330b9d0a7f755660ddd59739e3ab9b98d60bc18 (diff) | |
download | kdepimpi-98d29d15275c4b8e9a3348742925f6e6d03f7a07.zip kdepimpi-98d29d15275c4b8e9a3348742925f6e6d03f7a07.tar.gz kdepimpi-98d29d15275c4b8e9a3348742925f6e6d03f7a07.tar.bz2 |
fixx
-rw-r--r-- | kalarmd/alarmdialog.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/kalarmd/alarmdialog.cpp b/kalarmd/alarmdialog.cpp index 17d4afa..ddb125a 100644 --- a/kalarmd/alarmdialog.cpp +++ b/kalarmd/alarmdialog.cpp | |||
@@ -1,228 +1,233 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the KDE alarm daemon. | 2 | This file is part of the KDE alarm daemon. |
3 | Copyright (c) 2000 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
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 | 23 | ||
24 | // $Id$ | 24 | // $Id$ |
25 | 25 | ||
26 | #include <qhbox.h> | 26 | #include <qhbox.h> |
27 | #include <qvbox.h> | 27 | #include <qvbox.h> |
28 | #include <qapp.h> | 28 | #include <qapp.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qsound.h> | 33 | #include <qsound.h> |
34 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | #ifndef DESKTOP_VERSION | 36 | #ifndef DESKTOP_VERSION |
37 | #define protected public | 37 | #define protected public |
38 | #include <qspinbox.h> | 38 | #include <qspinbox.h> |
39 | #undef protected | 39 | #undef protected |
40 | #else | 40 | #else |
41 | #include <qspinbox.h> | 41 | #include <qspinbox.h> |
42 | #endif | 42 | #endif |
43 | #include <stdlib.h> | 43 | #include <stdlib.h> |
44 | #ifndef _WIN32_ | 44 | #ifndef _WIN32_ |
45 | #include <unistd.h> | 45 | #include <unistd.h> |
46 | #include <sys/ioctl.h> | 46 | #include <sys/ioctl.h> |
47 | #endif | 47 | #endif |
48 | #include <stdio.h> | 48 | #include <stdio.h> |
49 | #include <fcntl.h> | 49 | #include <fcntl.h> |
50 | 50 | ||
51 | #ifndef DESKTOP_VERSION | 51 | #ifndef DESKTOP_VERSION |
52 | #include <qtopia/alarmserver.h> | 52 | #include <qtopia/alarmserver.h> |
53 | #include <qpe/resource.h> | 53 | #include <qpe/resource.h> |
54 | #include <qtopia/sound.h> | 54 | #include <qtopia/sound.h> |
55 | 55 | ||
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | #include "alarmdialog.h" | 58 | #include "alarmdialog.h" |
59 | 59 | ||
60 | 60 | ||
61 | AlarmDialog::AlarmDialog(QWidget *parent,const char *name) | 61 | AlarmDialog::AlarmDialog(QWidget *parent,const char *name) |
62 | : QDialog (parent, name ,false, Qt::WStyle_StaysOnTop ) | 62 | : QDialog (parent, name ,false, Qt::WStyle_StaysOnTop ) |
63 | { | 63 | { |
64 | setCaption( "KO/Pi Alarm!" ); | 64 | setCaption( "KO/Pi Alarm!" ); |
65 | QVBoxLayout* layout = new QVBoxLayout( this); | 65 | QVBoxLayout* layout = new QVBoxLayout( this); |
66 | QLabel* l = new QLabel("The following event triggered alarm:",this); | 66 | QLabel* l = new QLabel("The following event triggered alarm:",this); |
67 | layout->addWidget ( l ); | 67 | layout->addWidget ( l ); |
68 | l->setAlignment( AlignCenter); | 68 | l->setAlignment( AlignCenter); |
69 | mMessage = new QLabel ( " ", this ); | 69 | mMessage = new QLabel ( " ", this ); |
70 | int fs = 18; | 70 | int fs = 18; |
71 | int fs2 = 12; | 71 | int fs2 = 12; |
72 | int baseSize = 6; | 72 | int baseSize = 6; |
73 | if ( QApplication::desktop()->width() < 480 ) { | 73 | if ( QApplication::desktop()->width() < 480 ) { |
74 | fs2 = 10; | 74 | fs2 = 10; |
75 | fs = 12; | 75 | fs = 12; |
76 | baseSize = 4; | 76 | baseSize = 4; |
77 | } | 77 | } |
78 | layout->setSpacing( 3 ); | 78 | layout->setSpacing( 3 ); |
79 | layout->setMargin( 3 ); | 79 | layout->setMargin( 3 ); |
80 | QFont fo = QApplication::font(); | 80 | QFont fo = QApplication::font(); |
81 | fo.setBold( true ); | 81 | fo.setBold( true ); |
82 | fo.setPointSize( fs2 ); | 82 | fo.setPointSize( fs2 ); |
83 | l->setFont( fo ); | 83 | l->setFont( fo ); |
84 | fo.setPointSize( fs ); | 84 | fo.setPointSize( fs ); |
85 | mMessage->setFont(fo ); | 85 | mMessage->setFont(fo ); |
86 | mMessage->setAlignment( AlignCenter); | 86 | mMessage->setAlignment( AlignCenter); |
87 | layout->addWidget ( mMessage ); | 87 | layout->addWidget ( mMessage ); |
88 | mMissedAlarms= new QLabel ( "(No missed Alarms)", this ); | 88 | mMissedAlarms= new QLabel ( "(No missed Alarms)", this ); |
89 | mMissedAlarms->setAlignment( AlignCenter); | 89 | mMissedAlarms->setAlignment( AlignCenter); |
90 | 90 | ||
91 | playSoundTimer = new QTimer( this ); | 91 | playSoundTimer = new QTimer( this ); |
92 | connect ( playSoundTimer, SIGNAL( timeout() ), this, SLOT (playSound() ) ); | 92 | connect ( playSoundTimer, SIGNAL( timeout() ), this, SLOT (playSound() ) ); |
93 | 93 | ||
94 | playSoundTimer->stop(); | 94 | playSoundTimer->stop(); |
95 | 95 | ||
96 | layout->addWidget ( mMissedAlarms ); | 96 | layout->addWidget ( mMissedAlarms ); |
97 | mMissedAlarmsCombo = new QComboBox ( this ); | 97 | mMissedAlarmsCombo = new QComboBox ( this ); |
98 | layout->addWidget ( mMissedAlarmsCombo ); | 98 | layout->addWidget ( mMissedAlarmsCombo ); |
99 | 99 | ||
100 | QLabel* labb = new QLabel("Suspend\nduration\n(minutes):",this); | 100 | QLabel* labb = new QLabel("Suspend\nduration\n(minutes):",this); |
101 | #ifdef DESKTOP_VERSION | ||
102 | fo = font(); | ||
103 | fo.setPointSize( 12 ); | ||
104 | labb->setFont ( fo ); | ||
105 | #endif | ||
101 | labb->setAlignment(AlignCenter); | 106 | labb->setAlignment(AlignCenter); |
102 | //layout->addWidget ( labb ); | 107 | //layout->addWidget ( labb ); |
103 | fo = font(); | 108 | fo = font(); |
104 | int pointSize = 36; | 109 | int pointSize = 36; |
105 | if ( QApplication::desktop()->width() <= 320 ) | 110 | if ( QApplication::desktop()->width() <= 320 ) |
106 | pointSize = 18; | 111 | pointSize = 18; |
107 | fo.setPointSize( pointSize ); | 112 | fo.setPointSize( pointSize ); |
108 | mSuspendSpin = new QSpinBox(1,1440,1,this); | 113 | mSuspendSpin = new QSpinBox(1,1440,1,this); |
109 | mSuspendSpin->setFont( fo ); | 114 | mSuspendSpin->setFont( fo ); |
110 | mSuspendSpin->setValue(7); // default suspend duration | 115 | mSuspendSpin->setValue(7); // default suspend duration |
111 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); | 116 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); |
112 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); | 117 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); |
113 | 118 | ||
114 | #if QT_VERSION < 0x030000 | 119 | #if QT_VERSION < 0x030000 |
115 | mSuspendSpin->upButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); | 120 | mSuspendSpin->upButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); |
116 | mSuspendSpin->downButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); | 121 | mSuspendSpin->downButton ()->setFixedSize( QSize( 8*baseSize, 5*baseSize )); |
117 | #endif | 122 | #endif |
118 | mSuspendSpin->setFixedSize( 18*baseSize, 10*baseSize+2 ); | 123 | mSuspendSpin->setFixedSize( 18*baseSize, 10*baseSize+2 ); |
119 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); | 124 | mSuspendSpin->setButtonSymbols( QSpinBox::PlusMinus ); |
120 | QHBoxLayout* layoutSpin = new QHBoxLayout( layout ); | 125 | QHBoxLayout* layoutSpin = new QHBoxLayout( layout ); |
121 | layoutSpin->addStretch (); | 126 | layoutSpin->addStretch (); |
122 | layoutSpin->addWidget ( labb ); | 127 | layoutSpin->addWidget ( labb ); |
123 | layoutSpin->addWidget ( mSuspendSpin ); | 128 | layoutSpin->addWidget ( mSuspendSpin ); |
124 | layoutSpin->addStretch (); | 129 | layoutSpin->addStretch (); |
125 | 130 | ||
126 | QVBox * bbox = new QVBox ( this ); | 131 | QVBox * bbox = new QVBox ( this ); |
127 | layout->addWidget ( bbox ); | 132 | layout->addWidget ( bbox ); |
128 | bbox->layout()->setSpacing( 2 ); | 133 | bbox->layout()->setSpacing( 2 ); |
129 | labb = new QLabel("Press \"Cancel\" or \"Esc\" to suspend!",bbox); | 134 | labb = new QLabel("Press \"Cancel\" or \"Esc\" to suspend!",bbox); |
130 | labb->setAlignment(AlignCenter); | 135 | labb->setAlignment(AlignCenter); |
131 | mSuspendButton = new QPushButton( "Suspend", bbox); | 136 | mSuspendButton = new QPushButton( "Suspend", bbox); |
132 | QPushButton* silen = new QPushButton( " Stop sound ", bbox); | 137 | QPushButton* silen = new QPushButton( " Stop sound ", bbox); |
133 | okbut = new QPushButton( "Ok", bbox); | 138 | okbut = new QPushButton( "Ok", bbox); |
134 | mSuspendButton->setFont( fo ); | 139 | mSuspendButton->setFont( fo ); |
135 | silen->setFont( fo ); | 140 | silen->setFont( fo ); |
136 | okbut->setFont( fo ); | 141 | okbut->setFont( fo ); |
137 | okbut->setDefault( true ); | 142 | okbut->setDefault( true ); |
138 | connect (silen , SIGNAL( clicked() ), this, SLOT (silent() ) ); | 143 | connect (silen , SIGNAL( clicked() ), this, SLOT (silent() ) ); |
139 | connect (mSuspendButton, SIGNAL( clicked() ), this, SLOT (slotSuspend() ) ); | 144 | connect (mSuspendButton, SIGNAL( clicked() ), this, SLOT (slotSuspend() ) ); |
140 | connect (okbut , SIGNAL( clicked() ), this, SLOT (slotOk() ) ); | 145 | connect (okbut , SIGNAL( clicked() ), this, SLOT (slotOk() ) ); |
141 | connect (mSuspendSpin , SIGNAL( valueChanged ( int ) ), this, SLOT ( spinBoxChanged( int ) ) ); | 146 | connect (mSuspendSpin , SIGNAL( valueChanged ( int ) ), this, SLOT ( spinBoxChanged( int ) ) ); |
142 | #ifndef _WIN32_ | 147 | #ifndef _WIN32_ |
143 | if ( QFile::exists ( "/dev/sharp_led" ) ) | 148 | if ( QFile::exists ( "/dev/sharp_led" ) ) |
144 | fd_led = open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 149 | fd_led = open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
145 | else | 150 | else |
146 | #endif | 151 | #endif |
147 | fd_led = 0; | 152 | fd_led = 0; |
148 | statusLED.which = SHARP_LED_SALARM; | 153 | statusLED.which = SHARP_LED_SALARM; |
149 | mSilent = false; | 154 | mSilent = false; |
150 | mSuspendCounter = 0; | 155 | mSuspendCounter = 0; |
151 | setServerNotification( true ); | 156 | setServerNotification( true ); |
152 | } | 157 | } |
153 | void AlarmDialog::reject () | 158 | void AlarmDialog::reject () |
154 | { | 159 | { |
155 | QTimer::singleShot ( 3000, this, SLOT (suspend()) ); | 160 | QTimer::singleShot ( 3000, this, SLOT (suspend()) ); |
156 | slotSuspend(); | 161 | slotSuspend(); |
157 | } | 162 | } |
158 | AlarmDialog::~AlarmDialog() | 163 | AlarmDialog::~AlarmDialog() |
159 | { | 164 | { |
160 | } | 165 | } |
161 | void AlarmDialog::silent () | 166 | void AlarmDialog::silent () |
162 | { | 167 | { |
163 | mSilent = true; | 168 | mSilent = true; |
164 | } | 169 | } |
165 | void AlarmDialog::accept() | 170 | void AlarmDialog::accept() |
166 | { | 171 | { |
167 | slotOk(); | 172 | slotOk(); |
168 | } | 173 | } |
169 | 174 | ||
170 | void AlarmDialog::suspend() | 175 | void AlarmDialog::suspend() |
171 | { | 176 | { |
172 | #ifdef DESKTOP_VERSION | 177 | #ifdef DESKTOP_VERSION |
173 | 178 | ||
174 | #else | 179 | #else |
175 | Sound::soundAlarm (); | 180 | Sound::soundAlarm (); |
176 | #endif | 181 | #endif |
177 | } | 182 | } |
178 | void AlarmDialog::slotOk() | 183 | void AlarmDialog::slotOk() |
179 | { | 184 | { |
180 | mStopAlarm = true; | 185 | mStopAlarm = true; |
181 | mMissedAlarms->setText("(No missed Alarms)"); | 186 | mMissedAlarms->setText("(No missed Alarms)"); |
182 | mMessage->setText(""); | 187 | mMessage->setText(""); |
183 | mMissedAlarmsCombo->clear(); | 188 | mMissedAlarmsCombo->clear(); |
184 | #ifndef _WIN32_ | 189 | #ifndef _WIN32_ |
185 | if ( fd_led > 0 ) { | 190 | if ( fd_led > 0 ) { |
186 | statusLED.status = LED_SALARM_OFF ; | 191 | statusLED.status = LED_SALARM_OFF ; |
187 | ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); | 192 | ioctl (fd_led, SHARP_LED_SETSTATUS, &statusLED); |
188 | } | 193 | } |
189 | #endif | 194 | #endif |
190 | QDialog::accept(); | 195 | QDialog::accept(); |
191 | } | 196 | } |
192 | 197 | ||
193 | void AlarmDialog::slotSuspend() | 198 | void AlarmDialog::slotSuspend() |
194 | { | 199 | { |
195 | //qDebug("AlarmDialog::suspend() "); // emit suspendSignal(mSuspendSpin->value()); | 200 | //qDebug("AlarmDialog::suspend() "); // emit suspendSignal(mSuspendSpin->value()); |
196 | mStopAlarm = true; | 201 | mStopAlarm = true; |
197 | QDateTime nextA = QDateTime::currentDateTime().addSecs( mSuspendSpin->value() * 60 ); | 202 | QDateTime nextA = QDateTime::currentDateTime().addSecs( mSuspendSpin->value() * 60 ); |
198 | QString mess = "suspend_alarm" +mFileName+"+++" ; | 203 | QString mess = "suspend_alarm" +mFileName+"+++" ; |
199 | if ( mMessage->text().left( 10 ) !="Suspended:" ) | 204 | if ( mMessage->text().left( 10 ) !="Suspended:" ) |
200 | mess += "Suspended:\n"; | 205 | mess += "Suspended:\n"; |
201 | mess +=mMessage->text(); | 206 | mess +=mMessage->text(); |
202 | #ifndef DESKTOP_VERSION | 207 | #ifndef DESKTOP_VERSION |
203 | if ( mServerNotification ) | 208 | if ( mServerNotification ) |
204 | AlarmServer::addAlarm ( nextA,"koalarm",mess.latin1()); | 209 | AlarmServer::addAlarm ( nextA,"koalarm",mess.latin1()); |
205 | #endif | 210 | #endif |
206 | emit addAlarm( nextA , mess ); | 211 | emit addAlarm( nextA , mess ); |
207 | slotOk(); | 212 | slotOk(); |
208 | } | 213 | } |
209 | 214 | ||
210 | void AlarmDialog::setServerNotification( bool b ) | 215 | void AlarmDialog::setServerNotification( bool b ) |
211 | { | 216 | { |
212 | mServerNotification = b; | 217 | mServerNotification = b; |
213 | } | 218 | } |
214 | int AlarmDialog::getSuspendTime( ) | 219 | int AlarmDialog::getSuspendTime( ) |
215 | { | 220 | { |
216 | return mSuspendSpin->value(); | 221 | return mSuspendSpin->value(); |
217 | 222 | ||
218 | } | 223 | } |
219 | void AlarmDialog::setSuspendTime( int val ) | 224 | void AlarmDialog::setSuspendTime( int val ) |
220 | { | 225 | { |
221 | mSuspendSpin->setValue( val ); | 226 | mSuspendSpin->setValue( val ); |
222 | } | 227 | } |
223 | bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, bool playwav, int pause , int suspendtimes) | 228 | bool AlarmDialog::eventNotification( QString mess, int replay , QString fn, bool playwav, int pause , int suspendtimes) |
224 | { | 229 | { |
225 | if ( mess.left( 9) != "Suspended" ) | 230 | if ( mess.left( 9) != "Suspended" ) |
226 | mSuspendCounter = suspendtimes; | 231 | mSuspendCounter = suspendtimes; |
227 | mPauseCount = pause; | 232 | mPauseCount = pause; |
228 | mFileName = fn; | 233 | mFileName = fn; |