Diffstat (limited to 'kalarmd/simplealarmdaemonimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kalarmd/simplealarmdaemonimpl.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp index b3da428..294ce7d 100644 --- a/kalarmd/simplealarmdaemonimpl.cpp +++ b/kalarmd/simplealarmdaemonimpl.cpp | |||
@@ -1,571 +1,571 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the KOrganizer alarm daemon. | 2 | This file is part of the KOrganizer alarm daemon. |
3 | Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2002 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 | #include "simplealarmdaemonimpl.h" | 24 | #include "simplealarmdaemonimpl.h" |
25 | 25 | ||
26 | #include "alarmdialog.h" | 26 | #include "alarmdialog.h" |
27 | #include <qpopupmenu.h> | 27 | #include <qpopupmenu.h> |
28 | #include <qapp.h> | 28 | #include <qapp.h> |
29 | #include <qdir.h> | 29 | #include <qdir.h> |
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qhbox.h> | 31 | #include <qhbox.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qdatetime.h> | 34 | #include <qdatetime.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
38 | #include <qdialog.h> | 38 | #include <qdialog.h> |
39 | #define protected public | 39 | #define protected public |
40 | #include <qspinbox.h> | 40 | #include <qspinbox.h> |
41 | #undef protected | 41 | #undef protected |
42 | #include <qtextstream.h> | 42 | #include <qtextstream.h> |
43 | #include <qtopia/qcopenvelope_qws.h> | 43 | #include <qtopia/qcopenvelope_qws.h> |
44 | #include <qtopia/alarmserver.h> | 44 | #include <qtopia/alarmserver.h> |
45 | 45 | ||
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | #include <unistd.h> | 48 | #include <unistd.h> |
49 | 49 | ||
50 | 50 | ||
51 | SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) | 51 | SimpleAlarmDaemonImpl::SimpleAlarmDaemonImpl( QWidget *parent ) |
52 | : QLabel( parent ) | 52 | : QLabel( parent ) |
53 | { | 53 | { |
54 | mAlarmDialog = new AlarmDialog( 0 ); | 54 | mAlarmDialog = new AlarmDialog( 0 ); |
55 | mPopUp = new QPopupMenu( this ); | 55 | mPopUp = new QPopupMenu( this ); |
56 | mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) ); | 56 | mPopUp->insertItem( "What's Next?", this, SLOT ( showWN() ) ); |
57 | mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) ); | 57 | mPopUp->insertItem( "Next Days!", this, SLOT ( showKO() ) ); |
58 | mPopUp->insertSeparator(); | 58 | mPopUp->insertSeparator(); |
59 | mPopUp->insertItem( "What's Todo?", this, SLOT ( showTodo() ) ); | 59 | mPopUp->insertItem( "Todo List", this, SLOT ( showTodo() ) ); |
60 | mPopUp->insertSeparator(); | 60 | mPopUp->insertSeparator(); |
61 | mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) ); | 61 | mPopUp->insertItem( "Addresses", this, SLOT ( showAdd() ) ); |
62 | mPopUp->insertSeparator(); | 62 | mPopUp->insertSeparator(); |
63 | mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) ); | 63 | mPopUp->insertItem( "Edit Journal", this, SLOT ( writeJournal() ) ); |
64 | mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) ); | 64 | mPopUp->insertItem( "New Event", this, SLOT ( newEvent() ) ); |
65 | mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) ); | 65 | mPopUp->insertItem( "New Todo", this, SLOT ( newTodo() ) ); |
66 | mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) ); | 66 | mPopUp->insertItem( "New Mail", this, SLOT ( newMail() ) ); |
67 | mPopUp->insertSeparator(); | 67 | mPopUp->insertSeparator(); |
68 | mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) ); | 68 | mPopUp->insertItem( "Multi Sync", this, SLOT ( ringSync() ) ); |
69 | mTimerPopUp = new QPopupMenu( this ); | 69 | mTimerPopUp = new QPopupMenu( this ); |
70 | QFont fon = mTimerPopUp->font(); | 70 | QFont fon = mTimerPopUp->font(); |
71 | fon.setPointSize( fon.pointSize() *3/2 ); | 71 | fon.setPointSize( fon.pointSize() *3/2 ); |
72 | mTimerPopUp->setFont( fon ); | 72 | mTimerPopUp->setFont( fon ); |
73 | mBeepPopUp = new QPopupMenu( this ); | 73 | mBeepPopUp = new QPopupMenu( this ); |
74 | mSoundPopUp = new QPopupMenu( this ); | 74 | mSoundPopUp = new QPopupMenu( this ); |
75 | mPausePopUp = new QPopupMenu( this ); | 75 | mPausePopUp = new QPopupMenu( this ); |
76 | QPopupMenu* savePopUp = new QPopupMenu( this ); | 76 | QPopupMenu* savePopUp = new QPopupMenu( this ); |
77 | savePopUp->insertItem( "Save", 0 ); | 77 | savePopUp->insertItem( "Save", 0 ); |
78 | savePopUp->insertItem( "Load", 1 ); | 78 | savePopUp->insertItem( "Load", 1 ); |
79 | mSoundPopUp->insertItem( "Buzzer", 0 ); | 79 | mSoundPopUp->insertItem( "Buzzer", 0 ); |
80 | mSoundPopUp->insertItem( "Wav file", 1 ); | 80 | mSoundPopUp->insertItem( "Wav file", 1 ); |
81 | mPausePopUp->insertItem( " 1 sec", 1 ); | 81 | mPausePopUp->insertItem( " 1 sec", 1 ); |
82 | mPausePopUp->insertItem( " 2 sec", 2 ); | 82 | mPausePopUp->insertItem( " 2 sec", 2 ); |
83 | mPausePopUp->insertItem( " 3 sec", 3 ); | 83 | mPausePopUp->insertItem( " 3 sec", 3 ); |
84 | mPausePopUp->insertItem( " 5 sec", 5 ); | 84 | mPausePopUp->insertItem( " 5 sec", 5 ); |
85 | mPausePopUp->insertItem( "10 sec", 10 ); | 85 | mPausePopUp->insertItem( "10 sec", 10 ); |
86 | mPausePopUp->insertItem( "30 sec", 30 ); | 86 | mPausePopUp->insertItem( "30 sec", 30 ); |
87 | mPausePopUp->insertItem( " 1 min", 60 ); | 87 | mPausePopUp->insertItem( " 1 min", 60 ); |
88 | mPausePopUp->insertItem( " 5 min", 300 ); | 88 | mPausePopUp->insertItem( " 5 min", 300 ); |
89 | mPausePopUp->insertItem( "10 min", 600 ); | 89 | mPausePopUp->insertItem( "10 min", 600 ); |
90 | mSuspendPopUp = new QPopupMenu( this ); | 90 | mSuspendPopUp = new QPopupMenu( this ); |
91 | mSuspendPopUp->insertItem( "Off", 0 ); | 91 | mSuspendPopUp->insertItem( "Off", 0 ); |
92 | mSuspendPopUp->insertItem( " 1x", 1 ); | 92 | mSuspendPopUp->insertItem( " 1x", 1 ); |
93 | mSuspendPopUp->insertItem( " 2x", 2 ); | 93 | mSuspendPopUp->insertItem( " 2x", 2 ); |
94 | mSuspendPopUp->insertItem( " 3x", 3 ); | 94 | mSuspendPopUp->insertItem( " 3x", 3 ); |
95 | mSuspendPopUp->insertItem( " 5x", 5 ); | 95 | mSuspendPopUp->insertItem( " 5x", 5 ); |
96 | mSuspendPopUp->insertItem( "10x", 10 ); | 96 | mSuspendPopUp->insertItem( "10x", 10 ); |
97 | mSuspendPopUp->insertItem( "20x", 20 ); | 97 | mSuspendPopUp->insertItem( "20x", 20 ); |
98 | mSuspendPopUp->insertItem( "30x", 30 ); | 98 | mSuspendPopUp->insertItem( "30x", 30 ); |
99 | mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); | 99 | mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); |
100 | mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); | 100 | mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); |
101 | mBeepPopUp->insertItem( "Replay",mSoundPopUp ); | 101 | mBeepPopUp->insertItem( "Replay",mSoundPopUp ); |
102 | mBeepPopUp->insertItem( "Config",savePopUp ); | 102 | mBeepPopUp->insertItem( "Config",savePopUp ); |
103 | mBeepPopUp->insertItem( "300", 300 ); | 103 | mBeepPopUp->insertItem( "300", 300 ); |
104 | mBeepPopUp->insertItem( "180", 180 ); | 104 | mBeepPopUp->insertItem( "180", 180 ); |
105 | mBeepPopUp->insertItem( "60", 60 ); | 105 | mBeepPopUp->insertItem( "60", 60 ); |
106 | mBeepPopUp->insertItem( "30", 30 ); | 106 | mBeepPopUp->insertItem( "30", 30 ); |
107 | mBeepPopUp->insertItem( "10", 10 ); | 107 | mBeepPopUp->insertItem( "10", 10 ); |
108 | mBeepPopUp->insertItem( "3", 3 ); | 108 | mBeepPopUp->insertItem( "3", 3 ); |
109 | mBeepPopUp->insertItem( "1", 1 ); | 109 | mBeepPopUp->insertItem( "1", 1 ); |
110 | mBeepPopUp->insertItem( "Off", 0 ); | 110 | mBeepPopUp->insertItem( "Off", 0 ); |
111 | mBeepPopUp->setCheckable( true ); | 111 | mBeepPopUp->setCheckable( true ); |
112 | mPopUp->insertSeparator(); | 112 | mPopUp->insertSeparator(); |
113 | mPopUp->insertItem( "Play beeps", mBeepPopUp ); | 113 | mPopUp->insertItem( "Play beeps", mBeepPopUp ); |
114 | mPopUp->insertSeparator(); | 114 | mPopUp->insertSeparator(); |
115 | mPopUp->insertItem( "Timer", mTimerPopUp ); | 115 | mPopUp->insertItem( "Timer", mTimerPopUp ); |
116 | mPopUp->insertSeparator(); | 116 | mPopUp->insertSeparator(); |
117 | mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); | 117 | mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); |
118 | 118 | ||
119 | mPopUp->resize( mPopUp->sizeHint() ); | 119 | mPopUp->resize( mPopUp->sizeHint() ); |
120 | mPlayBeeps = 60; | 120 | mPlayBeeps = 60; |
121 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); | 121 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); |
122 | connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); | 122 | connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); |
123 | connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); | 123 | connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); |
124 | connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); | 124 | connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); |
125 | connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); | 125 | connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); |
126 | connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); | 126 | connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); |
127 | connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); | 127 | connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); |
128 | connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); | 128 | connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); |
129 | mTimerTime = 0; | 129 | mTimerTime = 0; |
130 | mCustomText = "Custom Text"; | 130 | mCustomText = "Custom Text"; |
131 | mCustomMinutes = 7; | 131 | mCustomMinutes = 7; |
132 | mTimerPopupConf = 1; | 132 | mTimerPopupConf = 1; |
133 | fillTimerPopUp(); | 133 | fillTimerPopUp(); |
134 | mPausePlay = 0; | 134 | mPausePlay = 0; |
135 | confPause( 1 ); | 135 | confPause( 1 ); |
136 | mSuspend = 0; | 136 | mSuspend = 0; |
137 | confSuspend( 0 ); | 137 | confSuspend( 0 ); |
138 | if ( QApplication::desktop()->width() < 480 ) { | 138 | if ( QApplication::desktop()->width() < 480 ) { |
139 | wavAlarm = false; | 139 | wavAlarm = false; |
140 | mSoundPopUp->setItemChecked ( 0, true ); | 140 | mSoundPopUp->setItemChecked ( 0, true ); |
141 | } | 141 | } |
142 | else { | 142 | else { |
143 | wavAlarm = true; | 143 | wavAlarm = true; |
144 | mSoundPopUp->setItemChecked ( 1, true ); | 144 | mSoundPopUp->setItemChecked ( 1, true ); |
145 | } | 145 | } |
146 | saveSlot( 1 ); | 146 | saveSlot( 1 ); |
147 | } | 147 | } |
148 | 148 | ||
149 | SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() | 149 | SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() |
150 | { | 150 | { |
151 | //delete mPopUp; | 151 | //delete mPopUp; |
152 | delete mAlarmDialog; | 152 | delete mAlarmDialog; |
153 | } | 153 | } |
154 | void SimpleAlarmDaemonImpl::saveSlot( int load ) | 154 | void SimpleAlarmDaemonImpl::saveSlot( int load ) |
155 | { | 155 | { |
156 | QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; | 156 | QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; |
157 | //qDebug("save %d ", load ); | 157 | //qDebug("save %d ", load ); |
158 | QFile file( fileName ); | 158 | QFile file( fileName ); |
159 | if ( load ) { | 159 | if ( load ) { |
160 | if( !QFile::exists( fileName) ) | 160 | if( !QFile::exists( fileName) ) |
161 | return; | 161 | return; |
162 | if (!file.open( IO_ReadOnly ) ) { | 162 | if (!file.open( IO_ReadOnly ) ) { |
163 | return ; | 163 | return ; |
164 | } | 164 | } |
165 | QString line; | 165 | QString line; |
166 | bool ok; | 166 | bool ok; |
167 | int val; | 167 | int val; |
168 | int len; | 168 | int len; |
169 | while ( file.readLine( line, 1024 ) > 0 ) { | 169 | while ( file.readLine( line, 1024 ) > 0 ) { |
170 | //qDebug("read %s ", line.latin1()); | 170 | //qDebug("read %s ", line.latin1()); |
171 | len = line.length(); | 171 | len = line.length(); |
172 | if ( line.left(4 ) == "PPAU" ) { | 172 | if ( line.left(4 ) == "PPAU" ) { |
173 | val = line.mid( 4,len-5).toInt( &ok ); | 173 | val = line.mid( 4,len-5).toInt( &ok ); |
174 | if ( ok ) { | 174 | if ( ok ) { |
175 | confPause( val ); | 175 | confPause( val ); |
176 | } | 176 | } |
177 | } | 177 | } |
178 | if ( line.left(4 ) == "SUCO" ) { | 178 | if ( line.left(4 ) == "SUCO" ) { |
179 | val = line.mid( 4,len-5).toInt( &ok ); | 179 | val = line.mid( 4,len-5).toInt( &ok ); |
180 | if ( ok ) | 180 | if ( ok ) |
181 | confSuspend ( val ); | 181 | confSuspend ( val ); |
182 | } | 182 | } |
183 | if ( line.left(4 ) == "WAAL" ) { | 183 | if ( line.left(4 ) == "WAAL" ) { |
184 | val = line.mid( 4,len-5).toInt( &ok ); | 184 | val = line.mid( 4,len-5).toInt( &ok ); |
185 | if ( ok ) | 185 | if ( ok ) |
186 | confSound( val ); | 186 | confSound( val ); |
187 | 187 | ||
188 | } | 188 | } |
189 | if ( line.left(4 ) == "PLBE" ) { | 189 | if ( line.left(4 ) == "PLBE" ) { |
190 | val = line.mid( 4,len-5).toInt( &ok ); | 190 | val = line.mid( 4,len-5).toInt( &ok ); |
191 | if ( ok ) | 191 | if ( ok ) |
192 | slotPlayBeep( val ); | 192 | slotPlayBeep( val ); |
193 | 193 | ||
194 | } | 194 | } |
195 | if ( line.left(4 ) == "CUTE" ) { | 195 | if ( line.left(4 ) == "CUTE" ) { |
196 | mCustomText = line.mid( 5,len-6); | 196 | mCustomText = line.mid( 5,len-6); |
197 | // qDebug("text ***%s*** ",mCustomText.latin1() ); | 197 | // qDebug("text ***%s*** ",mCustomText.latin1() ); |
198 | 198 | ||
199 | } | 199 | } |
200 | if ( line.left(4 ) == "CUMI" ) { | 200 | if ( line.left(4 ) == "CUMI" ) { |
201 | val = line.mid( 4,len-5).toInt( &ok ); | 201 | val = line.mid( 4,len-5).toInt( &ok ); |
202 | if ( ok ) | 202 | if ( ok ) |
203 | mCustomMinutes = val; | 203 | mCustomMinutes = val; |
204 | 204 | ||
205 | } | 205 | } |
206 | if ( line.left(4 ) == "SUTI" ) { | 206 | if ( line.left(4 ) == "SUTI" ) { |
207 | val = line.mid( 4,len-5).toInt( &ok ); | 207 | val = line.mid( 4,len-5).toInt( &ok ); |
208 | if ( ok ) | 208 | if ( ok ) |
209 | mAlarmDialog->setSuspendTime( val );; | 209 | mAlarmDialog->setSuspendTime( val );; |
210 | 210 | ||
211 | } | 211 | } |
212 | } | 212 | } |
213 | file.close(); | 213 | file.close(); |
214 | } else { | 214 | } else { |
215 | if (!file.open( IO_WriteOnly ) ) { | 215 | if (!file.open( IO_WriteOnly ) ) { |
216 | return; | 216 | return; |
217 | } | 217 | } |
218 | QString configString ; | 218 | QString configString ; |
219 | configString += "PPAU " + QString::number( mPausePlay ) + "\n"; | 219 | configString += "PPAU " + QString::number( mPausePlay ) + "\n"; |
220 | configString += "SUCO " + QString::number( mSuspend ) + "\n"; | 220 | configString += "SUCO " + QString::number( mSuspend ) + "\n"; |
221 | configString += "WAAL " + QString::number( wavAlarm ) + "\n"; | 221 | configString += "WAAL " + QString::number( wavAlarm ) + "\n"; |
222 | configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; | 222 | configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; |
223 | configString += "CUTE " + mCustomText + "\n"; | 223 | configString += "CUTE " + mCustomText + "\n"; |
224 | configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; | 224 | configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; |
225 | configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; | 225 | configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; |
226 | QTextStream ts( &file ); | 226 | QTextStream ts( &file ); |
227 | ts << configString ; | 227 | ts << configString ; |
228 | file.close(); | 228 | file.close(); |
229 | } | 229 | } |
230 | 230 | ||
231 | } | 231 | } |
232 | void SimpleAlarmDaemonImpl::confSuspend( int num ) | 232 | void SimpleAlarmDaemonImpl::confSuspend( int num ) |
233 | { | 233 | { |
234 | mSuspendPopUp->setItemChecked ( mSuspend,false ); | 234 | mSuspendPopUp->setItemChecked ( mSuspend,false ); |
235 | mSuspend = num; | 235 | mSuspend = num; |
236 | mSuspendPopUp->setItemChecked ( mSuspend,true ); | 236 | mSuspendPopUp->setItemChecked ( mSuspend,true ); |
237 | } | 237 | } |
238 | void SimpleAlarmDaemonImpl::confPause( int num ) | 238 | void SimpleAlarmDaemonImpl::confPause( int num ) |
239 | { | 239 | { |
240 | mPausePopUp->setItemChecked ( mPausePlay,false ); | 240 | mPausePopUp->setItemChecked ( mPausePlay,false ); |
241 | mPausePlay = num; | 241 | mPausePlay = num; |
242 | mPausePopUp->setItemChecked ( mPausePlay,true ); | 242 | mPausePopUp->setItemChecked ( mPausePlay,true ); |
243 | } | 243 | } |
244 | void SimpleAlarmDaemonImpl::confSound( int num ) | 244 | void SimpleAlarmDaemonImpl::confSound( int num ) |
245 | { | 245 | { |
246 | if ( num == 0 ) { | 246 | if ( num == 0 ) { |
247 | wavAlarm = false; | 247 | wavAlarm = false; |
248 | mSoundPopUp->setItemChecked ( 0, true ); | 248 | mSoundPopUp->setItemChecked ( 0, true ); |
249 | mSoundPopUp->setItemChecked ( 1, false ); | 249 | mSoundPopUp->setItemChecked ( 1, false ); |
250 | } else { | 250 | } else { |
251 | wavAlarm = true; | 251 | wavAlarm = true; |
252 | mSoundPopUp->setItemChecked ( 0, false ); | 252 | mSoundPopUp->setItemChecked ( 0, false ); |
253 | mSoundPopUp->setItemChecked ( 1, true ); | 253 | mSoundPopUp->setItemChecked ( 1, true ); |
254 | } | 254 | } |
255 | } | 255 | } |
256 | void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) | 256 | void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) |
257 | { | 257 | { |
258 | mBeepPopUp->setItemChecked ( mPlayBeeps,false ); | 258 | mBeepPopUp->setItemChecked ( mPlayBeeps,false ); |
259 | mPlayBeeps = num; | 259 | mPlayBeeps = num; |
260 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); | 260 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); |
261 | } | 261 | } |
262 | 262 | ||
263 | void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) | 263 | void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) |
264 | { | 264 | { |
265 | //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); | 265 | //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); |
266 | QString mess = msg; | 266 | QString mess = msg; |
267 | mAlarmMessage = mess.mid( 9 ); | 267 | mAlarmMessage = mess.mid( 9 ); |
268 | QString filename = getenv("QPEDIR") ; | 268 | QString filename = getenv("QPEDIR") ; |
269 | filename += "/pics/kdepim/korganizer/koalarm.wav"; | 269 | filename += "/pics/kdepim/korganizer/koalarm.wav"; |
270 | QString tempfilename; | 270 | QString tempfilename; |
271 | if ( mess.left( 13 ) == "suspend_alarm") { | 271 | if ( mess.left( 13 ) == "suspend_alarm") { |
272 | bool error = false; | 272 | bool error = false; |
273 | int len = mess.mid( 13 ).find("+++"); | 273 | int len = mess.mid( 13 ).find("+++"); |
274 | if ( len < 2 ) | 274 | if ( len < 2 ) |
275 | error = true; | 275 | error = true; |
276 | else { | 276 | else { |
277 | tempfilename = mess.mid( 13, len ); | 277 | tempfilename = mess.mid( 13, len ); |
278 | if ( !QFile::exists( tempfilename ) ) | 278 | if ( !QFile::exists( tempfilename ) ) |
279 | error = true; | 279 | error = true; |
280 | } | 280 | } |
281 | if ( ! error ) { | 281 | if ( ! error ) { |
282 | filename = tempfilename; | 282 | filename = tempfilename; |
283 | } | 283 | } |
284 | mAlarmMessage = mess.mid( 13+len+3 ); | 284 | mAlarmMessage = mess.mid( 13+len+3 ); |
285 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 285 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
286 | startAlarm( mAlarmMessage, filename); | 286 | startAlarm( mAlarmMessage, filename); |
287 | return; | 287 | return; |
288 | } | 288 | } |
289 | if ( mess.left( 11 ) == "timer_alarm") { | 289 | if ( mess.left( 11 ) == "timer_alarm") { |
290 | mTimerTime = 0; | 290 | mTimerTime = 0; |
291 | startAlarm( mess.mid( 11 ), filename ); | 291 | startAlarm( mess.mid( 11 ), filename ); |
292 | return; | 292 | return; |
293 | } | 293 | } |
294 | if ( mess.left( 10 ) == "proc_alarm") { | 294 | if ( mess.left( 10 ) == "proc_alarm") { |
295 | bool error = false; | 295 | bool error = false; |
296 | int len = mess.mid( 10 ).find("+++"); | 296 | int len = mess.mid( 10 ).find("+++"); |
297 | if ( len < 2 ) | 297 | if ( len < 2 ) |
298 | error = true; | 298 | error = true; |
299 | else { | 299 | else { |
300 | tempfilename = mess.mid( 10, len ); | 300 | tempfilename = mess.mid( 10, len ); |
301 | if ( !QFile::exists( tempfilename ) ) | 301 | if ( !QFile::exists( tempfilename ) ) |
302 | error = true; | 302 | error = true; |
303 | } | 303 | } |
304 | if ( error ) { | 304 | if ( error ) { |
305 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 305 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
306 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 306 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
307 | } else { | 307 | } else { |
308 | QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 308 | QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
309 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 309 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
310 | if ( vfork () == 0 ) { | 310 | if ( vfork () == 0 ) { |
311 | execl ( tempfilename.latin1(), 0 ); | 311 | execl ( tempfilename.latin1(), 0 ); |
312 | return; | 312 | return; |
313 | } | 313 | } |
314 | return; | 314 | return; |
315 | } | 315 | } |
316 | 316 | ||
317 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 317 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
318 | } | 318 | } |
319 | if ( mess.left( 11 ) == "audio_alarm") { | 319 | if ( mess.left( 11 ) == "audio_alarm") { |
320 | bool error = false; | 320 | bool error = false; |
321 | int len = mess.mid( 11 ).find("+++"); | 321 | int len = mess.mid( 11 ).find("+++"); |
322 | if ( len < 2 ) | 322 | if ( len < 2 ) |
323 | error = true; | 323 | error = true; |
324 | else { | 324 | else { |
325 | tempfilename = mess.mid( 11, len ); | 325 | tempfilename = mess.mid( 11, len ); |
326 | if ( !QFile::exists( tempfilename ) ) | 326 | if ( !QFile::exists( tempfilename ) ) |
327 | error = true; | 327 | error = true; |
328 | } | 328 | } |
329 | if ( ! error ) { | 329 | if ( ! error ) { |
330 | filename = tempfilename; | 330 | filename = tempfilename; |
331 | } | 331 | } |
332 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 332 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
333 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 333 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
334 | } | 334 | } |
335 | if ( mess.left( 9 ) == "cal_alarm") { | 335 | if ( mess.left( 9 ) == "cal_alarm") { |
336 | mAlarmMessage = mess.mid( 9 ) ; | 336 | mAlarmMessage = mess.mid( 9 ) ; |
337 | } | 337 | } |
338 | 338 | ||
339 | writeFile(); | 339 | writeFile(); |
340 | startAlarm( mAlarmMessage, filename ); | 340 | startAlarm( mAlarmMessage, filename ); |
341 | 341 | ||
342 | } | 342 | } |
343 | 343 | ||
344 | int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) | 344 | int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) |
345 | { | 345 | { |
346 | return 0; | 346 | return 0; |
347 | } | 347 | } |
348 | void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) | 348 | void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) |
349 | { | 349 | { |
350 | //mAlarmDialog->show(); | 350 | //mAlarmDialog->show(); |
351 | //mAlarmDialog->raise(); | 351 | //mAlarmDialog->raise(); |
352 | mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); | 352 | mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); |
353 | } | 353 | } |
354 | 354 | ||
355 | 355 | ||
356 | void SimpleAlarmDaemonImpl::fillTimerPopUp() | 356 | void SimpleAlarmDaemonImpl::fillTimerPopUp() |
357 | { | 357 | { |
358 | 358 | ||
359 | // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); | 359 | // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); |
360 | if ( mTimerPopupConf == mTimerTime ) { | 360 | if ( mTimerPopupConf == mTimerTime ) { |
361 | if ( mTimerTime ) { | 361 | if ( mTimerTime ) { |
362 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); | 362 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); |
363 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); | 363 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); |
364 | mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); | 364 | mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); |
365 | } | 365 | } |
366 | else { | 366 | else { |
367 | QString text = mCustomText.stripWhiteSpace (); | 367 | QString text = mCustomText.stripWhiteSpace (); |
368 | int in = text.find( " " ); | 368 | int in = text.find( " " ); |
369 | text = text.left ( in ); | 369 | text = text.left ( in ); |
370 | mTimerPopUp->changeItem ( 3, text ); | 370 | mTimerPopUp->changeItem ( 3, text ); |
371 | } | 371 | } |
372 | return; | 372 | return; |
373 | } | 373 | } |
374 | mTimerPopupConf = mTimerTime; | 374 | mTimerPopupConf = mTimerTime; |
375 | mTimerPopUp->clear(); | 375 | mTimerPopUp->clear(); |
376 | if ( mTimerTime ) { | 376 | if ( mTimerTime ) { |
377 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); | 377 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); |
378 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); | 378 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); |
379 | 379 | ||
380 | 380 | ||
381 | mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); | 381 | mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); |
382 | mTimerPopUp->insertItem( t.toString() + " (countdown)",1); | 382 | mTimerPopUp->insertItem( t.toString() + " (countdown)",1); |
383 | mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2); | 383 | mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2); |
384 | } else { | 384 | } else { |
385 | 385 | ||
386 | QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; | 386 | QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; |
387 | QFile file( fileName ); | 387 | QFile file( fileName ); |
388 | if( !QFile::exists( fileName) ) { | 388 | if( !QFile::exists( fileName) ) { |
389 | // write defaults | 389 | // write defaults |
390 | if (!file.open( IO_WriteOnly ) ) { | 390 | if (!file.open( IO_WriteOnly ) ) { |
391 | return; | 391 | return; |
392 | } | 392 | } |
393 | QString configString ; | 393 | QString configString ; |
394 | configString += "#config file for kopi alarm timer\n"; | 394 | configString += "#config file for kopi alarm timer\n"; |
395 | configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; | 395 | configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; |
396 | configString += "#NOTE: minimum value for timer are 3 minutes!\n"; | 396 | configString += "#NOTE: minimum value for timer are 3 minutes!\n"; |
397 | configString += "24 h; 1440\n"; | 397 | configString += "24 h; 1440\n"; |
398 | configString += " 8 h; 480\n"; | 398 | configString += " 8 h; 480\n"; |
399 | configString += " 5 h; 300\n"; | 399 | configString += " 5 h; 300\n"; |
400 | configString += " 1 h; 60\n"; | 400 | configString += " 1 h; 60\n"; |
401 | configString += "30 min; 30\n"; | 401 | configString += "30 min; 30\n"; |
402 | configString += "15 min; 15\n"; | 402 | configString += "15 min; 15\n"; |
403 | configString += "SEPARATOR\n"; | 403 | configString += "SEPARATOR\n"; |
404 | configString += "Pizza; 22\n"; | 404 | configString += "Pizza; 22\n"; |
405 | configString += "Nap; 45\n"; | 405 | configString += "Nap; 45\n"; |
406 | configString += "Tea; 5\n"; | 406 | configString += "Tea; 5\n"; |
407 | QTextStream ts( &file ); | 407 | QTextStream ts( &file ); |
408 | ts << configString ; | 408 | ts << configString ; |
409 | file.close(); | 409 | file.close(); |
410 | } | 410 | } |
411 | 411 | ||
412 | if (!file.open( IO_ReadOnly ) ) { | 412 | if (!file.open( IO_ReadOnly ) ) { |
413 | return ; | 413 | return ; |
414 | } | 414 | } |
415 | QString line; | 415 | QString line; |
416 | bool ok; | 416 | bool ok; |
417 | while ( file.readLine( line, 1024 ) > 0 ) { | 417 | while ( file.readLine( line, 1024 ) > 0 ) { |
418 | //qDebug("read %s ", line.latin1()); | 418 | //qDebug("read %s ", line.latin1()); |
419 | if ( line.left(1 ) != "#" ) { | 419 | if ( line.left(1 ) != "#" ) { |
420 | // no comment | 420 | // no comment |
421 | if ( line.left(9 ) == "SEPARATOR" ) { | 421 | if ( line.left(9 ) == "SEPARATOR" ) { |
422 | mTimerPopUp->insertSeparator(); | 422 | mTimerPopUp->insertSeparator(); |
423 | } else { | 423 | } else { |
424 | QStringList li = QStringList::split(";",line); | 424 | QStringList li = QStringList::split(";",line); |
425 | ok = false; | 425 | ok = false; |
426 | if ( li.count() == 2 ) { | 426 | if ( li.count() == 2 ) { |
427 | int val = li[1].toInt( &ok ); | 427 | int val = li[1].toInt( &ok ); |
428 | if ( ok && val > 2 ) { | 428 | if ( ok && val > 2 ) { |
429 | mTimerPopUp->insertItem( li[0], val); | 429 | mTimerPopUp->insertItem( li[0], val); |
430 | } | 430 | } |
431 | } | 431 | } |
432 | } | 432 | } |
433 | } | 433 | } |
434 | } | 434 | } |
435 | file.close(); | 435 | file.close(); |
436 | #if 0 | 436 | #if 0 |
437 | mTimerPopUp->insertItem( "24 h", 1440 ); | 437 | mTimerPopUp->insertItem( "24 h", 1440 ); |
438 | // mTimerPopUp->insertItem( i18n("12 h"), 720 ); | 438 | // mTimerPopUp->insertItem( i18n("12 h"), 720 ); |
439 | mTimerPopUp->insertItem( " 8 h", 480 ); | 439 | mTimerPopUp->insertItem( " 8 h", 480 ); |
440 | mTimerPopUp->insertItem( " 5 h", 300 ); | 440 | mTimerPopUp->insertItem( " 5 h", 300 ); |
441 | // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); | 441 | // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); |
442 | mTimerPopUp->insertItem( " 1 h", 60 ); | 442 | mTimerPopUp->insertItem( " 1 h", 60 ); |
443 | mTimerPopUp->insertItem( "30 min", 30 ); | 443 | mTimerPopUp->insertItem( "30 min", 30 ); |
444 | mTimerPopUp->insertItem( "15 min", 15 ); | 444 | mTimerPopUp->insertItem( "15 min", 15 ); |
445 | mTimerPopUp->insertItem( "10 min", 10 ); | 445 | mTimerPopUp->insertItem( "10 min", 10 ); |
446 | //mTimerPopUp->insertItem( " 5 min", 5 ); | 446 | //mTimerPopUp->insertItem( " 5 min", 5 ); |
447 | mTimerPopUp->insertSeparator(); | 447 | mTimerPopUp->insertSeparator(); |
448 | mTimerPopUp->insertItem( "Pizza", 22 ); | 448 | mTimerPopUp->insertItem( "Pizza", 22 ); |
449 | mTimerPopUp->insertItem( "Nap", 45 ); | 449 | mTimerPopUp->insertItem( "Nap", 45 ); |
450 | mTimerPopUp->insertItem( "Tea", 5 ); | 450 | mTimerPopUp->insertItem( "Tea", 5 ); |
451 | #endif | 451 | #endif |
452 | QString text = mCustomText.stripWhiteSpace (); | 452 | QString text = mCustomText.stripWhiteSpace (); |
453 | int in = text.find( " " ); | 453 | int in = text.find( " " ); |
454 | text = text.left ( in ); | 454 | text = text.left ( in ); |
455 | mTimerPopUp->insertItem( text, 3 ); | 455 | mTimerPopUp->insertItem( text, 3 ); |
456 | mTimerPopUp->insertSeparator(); | 456 | mTimerPopUp->insertSeparator(); |
457 | mTimerPopUp->insertItem( "Customize", 2 ); | 457 | mTimerPopUp->insertItem( "Customize", 2 ); |
458 | } | 458 | } |
459 | 459 | ||
460 | } | 460 | } |
461 | 461 | ||
462 | void SimpleAlarmDaemonImpl::showTimer() | 462 | void SimpleAlarmDaemonImpl::showTimer() |
463 | { | 463 | { |
464 | fillTimerPopUp(); | 464 | fillTimerPopUp(); |
465 | } | 465 | } |
466 | 466 | ||
467 | void SimpleAlarmDaemonImpl::confTimer( int time ) | 467 | void SimpleAlarmDaemonImpl::confTimer( int time ) |
468 | { | 468 | { |
469 | //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); | 469 | //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); |
470 | int minutes = time; | 470 | int minutes = time; |
471 | if ( minutes == 0 ) { | 471 | if ( minutes == 0 ) { |
472 | if ( ! mTimerTime ) | 472 | if ( ! mTimerTime ) |
473 | return; | 473 | return; |
474 | 474 | ||
475 | QDialog dia ( 0, ("Stop Timer" ), true ); | 475 | QDialog dia ( 0, ("Stop Timer" ), true ); |
476 | QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia ); | 476 | QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia ); |
477 | lab.setAlignment( AlignCenter ); | 477 | lab.setAlignment( AlignCenter ); |
478 | dia.setCaption(("KO/Pi Timer Stop" )); | 478 | dia.setCaption(("KO/Pi Timer Stop" )); |
479 | QVBoxLayout lay( &dia ); | 479 | QVBoxLayout lay( &dia ); |
480 | lay.addWidget( &lab); | 480 | lay.addWidget( &lab); |
481 | QPushButton ok ( "Stop timer!", &dia); | 481 | QPushButton ok ( "Stop timer!", &dia); |
482 | QFont fo = dia.font(); | 482 | QFont fo = dia.font(); |
483 | fo.setPointSize( 36 ); | 483 | fo.setPointSize( 36 ); |
484 | ok.setFont( fo ); | 484 | ok.setFont( fo ); |
485 | lay.addWidget( &ok); | 485 | lay.addWidget( &ok); |
486 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); | 486 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); |
487 | QPushButton con ( "Continue timer!", &dia); | 487 | QPushButton con ( "Continue timer!", &dia); |
488 | fo.setPointSize( 36 ); | 488 | fo.setPointSize( 36 ); |
489 | con.setFont( fo ); | 489 | con.setFont( fo ); |
490 | lay.addWidget( &con); | 490 | lay.addWidget( &con); |
491 | connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); | 491 | connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); |
492 | lay.setMargin(5); | 492 | lay.setMargin(5); |
493 | lay.setSpacing(5); | 493 | lay.setSpacing(5); |
494 | dia.resize(dia.sizeHint() ); | 494 | dia.resize(dia.sizeHint() ); |
495 | 495 | ||
496 | if ( !dia.exec() ) | 496 | if ( !dia.exec() ) |
497 | return; | 497 | return; |
498 | 498 | ||
499 | AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() ); | 499 | AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() ); |
500 | mTimerTime = 0; | 500 | mTimerTime = 0; |
501 | return; | 501 | return; |
502 | } | 502 | } |
503 | if ( mTimerTime ) | 503 | if ( mTimerTime ) |
504 | return; | 504 | return; |
505 | if ( minutes == 1 ) { | 505 | if ( minutes == 1 ) { |
506 | return; | 506 | return; |
507 | } | 507 | } |
508 | QString mess = "timer_alarm"; | 508 | QString mess = "timer_alarm"; |
509 | mess += ("Timer Alarm!\n"); | 509 | mess += ("Timer Alarm!\n"); |
510 | if ( minutes == 22 ) { | 510 | if ( minutes == 22 ) { |
511 | mess += ( "Pizza is ready"); | 511 | mess += ( "Pizza is ready"); |
512 | mRunningTimerText = "Pizza"; | 512 | mRunningTimerText = "Pizza"; |
513 | } | 513 | } |
514 | else if ( minutes == 45 ) { | 514 | else if ( minutes == 45 ) { |
515 | mess += ( "Please wake up!"); | 515 | mess += ( "Please wake up!"); |
516 | mRunningTimerText = "Nap"; | 516 | mRunningTimerText = "Nap"; |
517 | } | 517 | } |
518 | else if ( minutes == 5 ) { | 518 | else if ( minutes == 5 ) { |
519 | mess += ( "Tea is ready"); | 519 | mess += ( "Tea is ready"); |
520 | mRunningTimerText = "Tea"; | 520 | mRunningTimerText = "Tea"; |
521 | } | 521 | } |
522 | else if ( minutes == 3 ) { | 522 | else if ( minutes == 3 ) { |
523 | mess += mCustomText; | 523 | mess += mCustomText; |
524 | minutes = mCustomMinutes ; | 524 | minutes = mCustomMinutes ; |
525 | mRunningTimerText = mCustomText.stripWhiteSpace (); | 525 | mRunningTimerText = mCustomText.stripWhiteSpace (); |
526 | int in = mRunningTimerText.find( " " ); | 526 | int in = mRunningTimerText.find( " " ); |
527 | mRunningTimerText = mRunningTimerText.left ( in ); | 527 | mRunningTimerText = mRunningTimerText.left ( in ); |
528 | } | 528 | } |
529 | else { | 529 | else { |
530 | if ( minutes == 2 ) { | 530 | if ( minutes == 2 ) { |
531 | // ask time | 531 | // ask time |
532 | QDialog dia ( 0, ("Customize Timer" ), true ); | 532 | QDialog dia ( 0, ("Customize Timer" ), true ); |
533 | QLabel lab (("Message Text:"), &dia ); | 533 | QLabel lab (("Message Text:"), &dia ); |
534 | dia.setCaption(("KO/Pi Timer" )); | 534 | dia.setCaption(("KO/Pi Timer" )); |
535 | QVBoxLayout lay( &dia ); | 535 | QVBoxLayout lay( &dia ); |
536 | lay.setMargin(5); | 536 | lay.setMargin(5); |
537 | lay.setSpacing(5); | 537 | lay.setSpacing(5); |
538 | lay.addWidget( &lab); | 538 | lay.addWidget( &lab); |
539 | QLineEdit lEdit( mCustomText, &dia ); | 539 | QLineEdit lEdit( mCustomText, &dia ); |
540 | lay.addWidget( &lEdit); | 540 | lay.addWidget( &lEdit); |
541 | QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); | 541 | QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); |
542 | lay.addWidget( &lab2); | 542 | lay.addWidget( &lab2); |
543 | QHBox hbox1 ( &dia ); | 543 | QHBox hbox1 ( &dia ); |
544 | lay.addWidget( &hbox1); | 544 | lay.addWidget( &hbox1); |
545 | QLabel lab3 (("Hours"), &hbox1 ); | 545 | QLabel lab3 (("Hours"), &hbox1 ); |
546 | QLabel lab4 (("Minutes"), &hbox1 ); | 546 | QLabel lab4 (("Minutes"), &hbox1 ); |
547 | QHBox hbox ( &dia ); | 547 | QHBox hbox ( &dia ); |
548 | QSpinBox spinh( 0, 24, 1,& hbox ); | 548 | QSpinBox spinh( 0, 24, 1,& hbox ); |
549 | QFont fo = dia.font(); | 549 | QFont fo = dia.font(); |
550 | fo.setPointSize( 36 ); | 550 | fo.setPointSize( 36 ); |
551 | QSpinBox spinm( 0, 59, 1,&hbox ); | 551 | QSpinBox spinm( 0, 59, 1,&hbox ); |
552 | spinm.setFont( fo ); | 552 | spinm.setFont( fo ); |
553 | spinh.setFont( fo ); | 553 | spinh.setFont( fo ); |
554 | spinh.setButtonSymbols( QSpinBox::PlusMinus ); | 554 | spinh.setButtonSymbols( QSpinBox::PlusMinus ); |
555 | spinm.setButtonSymbols( QSpinBox::PlusMinus ); | 555 | spinm.setButtonSymbols( QSpinBox::PlusMinus ); |
556 | spinh.upButton ()->setFixedSize( QSize( 48, 30 )); | 556 | spinh.upButton ()->setFixedSize( QSize( 48, 30 )); |
557 | spinh.downButton ()->setFixedSize( QSize( 48, 30 )); | 557 | spinh.downButton ()->setFixedSize( QSize( 48, 30 )); |
558 | //spinh.editor ()->setFixedSize( QSize( 50, 100 )); | 558 | //spinh.editor ()->setFixedSize( QSize( 50, 100 )); |
559 | spinh.setFixedSize( 100,62 ); | 559 | spinh.setFixedSize( 100,62 ); |
560 | spinm.upButton ()->setFixedSize( QSize( 48, 30 )); | 560 | spinm.upButton ()->setFixedSize( QSize( 48, 30 )); |
561 | spinm.downButton ()->setFixedSize( QSize( 48, 30 )); | 561 | spinm.downButton ()->setFixedSize( QSize( 48, 30 )); |
562 | spinm.downButton ()->setGeometry( 50,50,50,50); | 562 | spinm.downButton ()->setGeometry( 50,50,50,50); |
563 | // spinm.setSuffix( " m" ); | 563 | // spinm.setSuffix( " m" ); |
564 | //spinh.setSuffix( " h" ); | 564 | //spinh.setSuffix( " h" ); |
565 | spinm.setWrapping ( true ); | 565 | spinm.setWrapping ( true ); |
566 | //spinm.editor ()->setFixedSize( QSize( 50, 100 )); | 566 | //spinm.editor ()->setFixedSize( QSize( 50, 100 )); |
567 | spinm.setLineStep( 1 ); | 567 | spinm.setLineStep( 1 ); |
568 | spinm.setFixedSize( 110,62 ); | 568 | spinm.setFixedSize( 110,62 ); |
569 | lay.addWidget( &hbox); | 569 | lay.addWidget( &hbox); |
570 | QLabel lab5 ("Timer fires at:", &dia ); | 570 | QLabel lab5 ("Timer fires at:", &dia ); |
571 | lab5.setAlignment( AlignCenter ); | 571 | lab5.setAlignment( AlignCenter ); |