-rw-r--r-- | kalarmd/simplealarmdaemonimpl.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/kalarmd/simplealarmdaemonimpl.cpp b/kalarmd/simplealarmdaemonimpl.cpp index c747dfd..37e7d0d 100644 --- a/kalarmd/simplealarmdaemonimpl.cpp +++ b/kalarmd/simplealarmdaemonimpl.cpp | |||
@@ -1,690 +1,696 @@ | |||
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( "Todo List", 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 | mPopUp->setFont( fon ); | 73 | mPopUp->setFont( fon ); |
74 | mBeepPopUp = new QPopupMenu( this ); | 74 | mBeepPopUp = new QPopupMenu( this ); |
75 | mSoundPopUp = new QPopupMenu( this ); | 75 | mSoundPopUp = new QPopupMenu( this ); |
76 | mPausePopUp = new QPopupMenu( this ); | 76 | mPausePopUp = new QPopupMenu( this ); |
77 | QPopupMenu* savePopUp = new QPopupMenu( this ); | 77 | QPopupMenu* savePopUp = new QPopupMenu( this ); |
78 | savePopUp->insertItem( "Save", 0 ); | 78 | savePopUp->insertItem( "Save", 0 ); |
79 | savePopUp->insertItem( "Load", 1 ); | 79 | savePopUp->insertItem( "Load", 1 ); |
80 | mSoundPopUp->insertItem( "Buzzer", 0 ); | 80 | mSoundPopUp->insertItem( "Buzzer", 0 ); |
81 | mSoundPopUp->insertItem( "Wav file", 1 ); | 81 | mSoundPopUp->insertItem( "Wav file", 1 ); |
82 | mPausePopUp->insertItem( " 1 sec", 1 ); | 82 | mPausePopUp->insertItem( " 1 sec", 1 ); |
83 | mPausePopUp->insertItem( " 2 sec", 2 ); | 83 | mPausePopUp->insertItem( " 2 sec", 2 ); |
84 | mPausePopUp->insertItem( " 3 sec", 3 ); | 84 | mPausePopUp->insertItem( " 3 sec", 3 ); |
85 | mPausePopUp->insertItem( " 5 sec", 5 ); | 85 | mPausePopUp->insertItem( " 5 sec", 5 ); |
86 | mPausePopUp->insertItem( "10 sec", 10 ); | 86 | mPausePopUp->insertItem( "10 sec", 10 ); |
87 | mPausePopUp->insertItem( "30 sec", 30 ); | 87 | mPausePopUp->insertItem( "30 sec", 30 ); |
88 | mPausePopUp->insertItem( " 1 min", 60 ); | 88 | mPausePopUp->insertItem( " 1 min", 60 ); |
89 | mPausePopUp->insertItem( " 5 min", 300 ); | 89 | mPausePopUp->insertItem( " 5 min", 300 ); |
90 | mPausePopUp->insertItem( "10 min", 600 ); | 90 | mPausePopUp->insertItem( "10 min", 600 ); |
91 | mSuspendPopUp = new QPopupMenu( this ); | 91 | mSuspendPopUp = new QPopupMenu( this ); |
92 | mSuspendPopUp->insertItem( "Off", 0 ); | 92 | mSuspendPopUp->insertItem( "Off", 0 ); |
93 | mSuspendPopUp->insertItem( " 1x", 1 ); | 93 | mSuspendPopUp->insertItem( " 1x", 1 ); |
94 | mSuspendPopUp->insertItem( " 2x", 2 ); | 94 | mSuspendPopUp->insertItem( " 2x", 2 ); |
95 | mSuspendPopUp->insertItem( " 3x", 3 ); | 95 | mSuspendPopUp->insertItem( " 3x", 3 ); |
96 | mSuspendPopUp->insertItem( " 5x", 5 ); | 96 | mSuspendPopUp->insertItem( " 5x", 5 ); |
97 | mSuspendPopUp->insertItem( "10x", 10 ); | 97 | mSuspendPopUp->insertItem( "10x", 10 ); |
98 | mSuspendPopUp->insertItem( "20x", 20 ); | 98 | mSuspendPopUp->insertItem( "20x", 20 ); |
99 | mSuspendPopUp->insertItem( "30x", 30 ); | 99 | mSuspendPopUp->insertItem( "30x", 30 ); |
100 | mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); | 100 | mBeepPopUp->insertItem( "Auto suspend",mSuspendPopUp ); |
101 | mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); | 101 | mBeepPopUp->insertItem( "Beep interval",mPausePopUp ); |
102 | mBeepPopUp->insertItem( "Replay",mSoundPopUp ); | 102 | mBeepPopUp->insertItem( "Replay",mSoundPopUp ); |
103 | mBeepPopUp->insertItem( "Config",savePopUp ); | 103 | mBeepPopUp->insertItem( "Config",savePopUp ); |
104 | mBeepPopUp->insertItem( "300", 300 ); | 104 | mBeepPopUp->insertItem( "300", 300 ); |
105 | mBeepPopUp->insertItem( "180", 180 ); | 105 | mBeepPopUp->insertItem( "180", 180 ); |
106 | mBeepPopUp->insertItem( "60", 60 ); | 106 | mBeepPopUp->insertItem( "60", 60 ); |
107 | mBeepPopUp->insertItem( "30", 30 ); | 107 | mBeepPopUp->insertItem( "30", 30 ); |
108 | mBeepPopUp->insertItem( "10", 10 ); | 108 | mBeepPopUp->insertItem( "10", 10 ); |
109 | mBeepPopUp->insertItem( "3", 3 ); | 109 | mBeepPopUp->insertItem( "3", 3 ); |
110 | mBeepPopUp->insertItem( "1", 1 ); | 110 | mBeepPopUp->insertItem( "1", 1 ); |
111 | mBeepPopUp->insertItem( "Off", 0 ); | 111 | mBeepPopUp->insertItem( "Off", 0 ); |
112 | mBeepPopUp->insertSeparator(); | ||
113 | mBeepPopUp->insertItem( "Simulate", 1000 ); | ||
112 | mBeepPopUp->setCheckable( true ); | 114 | mBeepPopUp->setCheckable( true ); |
113 | mPopUp->insertSeparator(); | 115 | mPopUp->insertSeparator(); |
114 | mPopUp->insertItem( "Play beeps", mBeepPopUp ); | 116 | mPopUp->insertItem( "Play beeps", mBeepPopUp ); |
115 | mPopUp->insertSeparator(); | 117 | mPopUp->insertSeparator(); |
116 | mPopUp->insertItem( "Timer", mTimerPopUp ); | 118 | mPopUp->insertItem( "Timer", mTimerPopUp ); |
117 | mPopUp->insertSeparator(); | 119 | //mPopUp->insertSeparator(); |
118 | mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); | 120 | //mPopUp->insertItem( "Simulate", this, SLOT ( simulate() ) ); |
119 | 121 | ||
120 | mPopUp->resize( mPopUp->sizeHint() ); | 122 | mPopUp->resize( mPopUp->sizeHint() ); |
121 | mPlayBeeps = 60; | 123 | mPlayBeeps = 60; |
122 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); | 124 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); |
123 | connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); | 125 | connect ( mBeepPopUp, SIGNAL( activated ( int ) ), this, SLOT (slotPlayBeep( int ) ) ); |
124 | connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); | 126 | connect ( mTimerPopUp, SIGNAL( activated ( int ) ), this, SLOT (confTimer( int ) ) ); |
125 | connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); | 127 | connect ( mTimerPopUp, SIGNAL(aboutToShow() ), this, SLOT ( showTimer( ) ) ); |
126 | connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); | 128 | connect ( mSoundPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSound( int ) ) ); |
127 | connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); | 129 | connect ( mPausePopUp, SIGNAL( activated ( int ) ), this, SLOT (confPause( int ) ) ); |
128 | connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); | 130 | connect ( mSuspendPopUp, SIGNAL( activated ( int ) ), this, SLOT (confSuspend( int ) ) ); |
129 | connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); | 131 | connect ( savePopUp, SIGNAL( activated ( int ) ), this, SLOT (saveSlot( int ) ) ); |
130 | mTimerTime = 0; | 132 | mTimerTime = 0; |
131 | mCustomText = "Custom Text"; | 133 | mCustomText = "Custom Text"; |
132 | mCustomMinutes = 7; | 134 | mCustomMinutes = 7; |
133 | mTimerPopupConf = 1; | 135 | mTimerPopupConf = 1; |
134 | fillTimerPopUp(); | 136 | fillTimerPopUp(); |
135 | mPausePlay = 0; | 137 | mPausePlay = 0; |
136 | confPause( 1 ); | 138 | confPause( 1 ); |
137 | mSuspend = 0; | 139 | mSuspend = 0; |
138 | confSuspend( 0 ); | 140 | confSuspend( 0 ); |
139 | if ( QApplication::desktop()->width() < 480 ) { | 141 | if ( QApplication::desktop()->width() < 480 ) { |
140 | wavAlarm = false; | 142 | wavAlarm = false; |
141 | mSoundPopUp->setItemChecked ( 0, true ); | 143 | mSoundPopUp->setItemChecked ( 0, true ); |
142 | } | 144 | } |
143 | else { | 145 | else { |
144 | wavAlarm = true; | 146 | wavAlarm = true; |
145 | mSoundPopUp->setItemChecked ( 1, true ); | 147 | mSoundPopUp->setItemChecked ( 1, true ); |
146 | } | 148 | } |
147 | saveSlot( 1 ); | 149 | saveSlot( 1 ); |
148 | } | 150 | } |
149 | 151 | ||
150 | SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() | 152 | SimpleAlarmDaemonImpl::~SimpleAlarmDaemonImpl() |
151 | { | 153 | { |
152 | //delete mPopUp; | 154 | //delete mPopUp; |
153 | delete mAlarmDialog; | 155 | delete mAlarmDialog; |
154 | } | 156 | } |
155 | void SimpleAlarmDaemonImpl::saveSlot( int load ) | 157 | void SimpleAlarmDaemonImpl::saveSlot( int load ) |
156 | { | 158 | { |
157 | QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; | 159 | QString fileName = QDir::homeDirPath() +"/.kopialarmrc"; |
158 | //qDebug("save %d ", load ); | 160 | //qDebug("save %d ", load ); |
159 | QFile file( fileName ); | 161 | QFile file( fileName ); |
160 | if ( load ) { | 162 | if ( load ) { |
161 | if( !QFile::exists( fileName) ) | 163 | if( !QFile::exists( fileName) ) |
162 | return; | 164 | return; |
163 | if (!file.open( IO_ReadOnly ) ) { | 165 | if (!file.open( IO_ReadOnly ) ) { |
164 | return ; | 166 | return ; |
165 | } | 167 | } |
166 | QString line; | 168 | QString line; |
167 | bool ok; | 169 | bool ok; |
168 | int val; | 170 | int val; |
169 | int len; | 171 | int len; |
170 | while ( file.readLine( line, 1024 ) > 0 ) { | 172 | while ( file.readLine( line, 1024 ) > 0 ) { |
171 | //qDebug("read %s ", line.latin1()); | 173 | //qDebug("read %s ", line.latin1()); |
172 | len = line.length(); | 174 | len = line.length(); |
173 | if ( line.left(4 ) == "PPAU" ) { | 175 | if ( line.left(4 ) == "PPAU" ) { |
174 | val = line.mid( 4,len-5).toInt( &ok ); | 176 | val = line.mid( 4,len-5).toInt( &ok ); |
175 | if ( ok ) { | 177 | if ( ok ) { |
176 | confPause( val ); | 178 | confPause( val ); |
177 | } | 179 | } |
178 | } | 180 | } |
179 | if ( line.left(4 ) == "SUCO" ) { | 181 | if ( line.left(4 ) == "SUCO" ) { |
180 | val = line.mid( 4,len-5).toInt( &ok ); | 182 | val = line.mid( 4,len-5).toInt( &ok ); |
181 | if ( ok ) | 183 | if ( ok ) |
182 | confSuspend ( val ); | 184 | confSuspend ( val ); |
183 | } | 185 | } |
184 | if ( line.left(4 ) == "WAAL" ) { | 186 | if ( line.left(4 ) == "WAAL" ) { |
185 | val = line.mid( 4,len-5).toInt( &ok ); | 187 | val = line.mid( 4,len-5).toInt( &ok ); |
186 | if ( ok ) | 188 | if ( ok ) |
187 | confSound( val ); | 189 | confSound( val ); |
188 | 190 | ||
189 | } | 191 | } |
190 | if ( line.left(4 ) == "PLBE" ) { | 192 | if ( line.left(4 ) == "PLBE" ) { |
191 | val = line.mid( 4,len-5).toInt( &ok ); | 193 | val = line.mid( 4,len-5).toInt( &ok ); |
192 | if ( ok ) | 194 | if ( ok ) |
193 | slotPlayBeep( val ); | 195 | slotPlayBeep( val ); |
194 | 196 | ||
195 | } | 197 | } |
196 | if ( line.left(4 ) == "CUTE" ) { | 198 | if ( line.left(4 ) == "CUTE" ) { |
197 | mCustomText = line.mid( 5,len-6); | 199 | mCustomText = line.mid( 5,len-6); |
198 | // qDebug("text ***%s*** ",mCustomText.latin1() ); | 200 | // qDebug("text ***%s*** ",mCustomText.latin1() ); |
199 | 201 | ||
200 | } | 202 | } |
201 | if ( line.left(4 ) == "CUMI" ) { | 203 | if ( line.left(4 ) == "CUMI" ) { |
202 | val = line.mid( 4,len-5).toInt( &ok ); | 204 | val = line.mid( 4,len-5).toInt( &ok ); |
203 | if ( ok ) | 205 | if ( ok ) |
204 | mCustomMinutes = val; | 206 | mCustomMinutes = val; |
205 | 207 | ||
206 | } | 208 | } |
207 | if ( line.left(4 ) == "SUTI" ) { | 209 | if ( line.left(4 ) == "SUTI" ) { |
208 | val = line.mid( 4,len-5).toInt( &ok ); | 210 | val = line.mid( 4,len-5).toInt( &ok ); |
209 | if ( ok ) | 211 | if ( ok ) |
210 | mAlarmDialog->setSuspendTime( val );; | 212 | mAlarmDialog->setSuspendTime( val );; |
211 | 213 | ||
212 | } | 214 | } |
213 | } | 215 | } |
214 | file.close(); | 216 | file.close(); |
215 | } else { | 217 | } else { |
216 | if (!file.open( IO_WriteOnly ) ) { | 218 | if (!file.open( IO_WriteOnly ) ) { |
217 | return; | 219 | return; |
218 | } | 220 | } |
219 | QString configString ; | 221 | QString configString ; |
220 | configString += "PPAU " + QString::number( mPausePlay ) + "\n"; | 222 | configString += "PPAU " + QString::number( mPausePlay ) + "\n"; |
221 | configString += "SUCO " + QString::number( mSuspend ) + "\n"; | 223 | configString += "SUCO " + QString::number( mSuspend ) + "\n"; |
222 | configString += "WAAL " + QString::number( wavAlarm ) + "\n"; | 224 | configString += "WAAL " + QString::number( wavAlarm ) + "\n"; |
223 | configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; | 225 | configString += "PLBE " + QString::number( mPlayBeeps ) + "\n"; |
224 | configString += "CUTE " + mCustomText + "\n"; | 226 | configString += "CUTE " + mCustomText + "\n"; |
225 | configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; | 227 | configString += "CUMI " + QString::number( mCustomMinutes ) + "\n"; |
226 | configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; | 228 | configString += "SUTI " + QString::number( mAlarmDialog->getSuspendTime( )) + "\n"; |
227 | QTextStream ts( &file ); | 229 | QTextStream ts( &file ); |
228 | ts << configString ; | 230 | ts << configString ; |
229 | file.close(); | 231 | file.close(); |
230 | } | 232 | } |
231 | 233 | ||
232 | } | 234 | } |
233 | void SimpleAlarmDaemonImpl::confSuspend( int num ) | 235 | void SimpleAlarmDaemonImpl::confSuspend( int num ) |
234 | { | 236 | { |
235 | mSuspendPopUp->setItemChecked ( mSuspend,false ); | 237 | mSuspendPopUp->setItemChecked ( mSuspend,false ); |
236 | mSuspend = num; | 238 | mSuspend = num; |
237 | mSuspendPopUp->setItemChecked ( mSuspend,true ); | 239 | mSuspendPopUp->setItemChecked ( mSuspend,true ); |
238 | } | 240 | } |
239 | void SimpleAlarmDaemonImpl::confPause( int num ) | 241 | void SimpleAlarmDaemonImpl::confPause( int num ) |
240 | { | 242 | { |
241 | mPausePopUp->setItemChecked ( mPausePlay,false ); | 243 | mPausePopUp->setItemChecked ( mPausePlay,false ); |
242 | mPausePlay = num; | 244 | mPausePlay = num; |
243 | mPausePopUp->setItemChecked ( mPausePlay,true ); | 245 | mPausePopUp->setItemChecked ( mPausePlay,true ); |
244 | } | 246 | } |
245 | void SimpleAlarmDaemonImpl::confSound( int num ) | 247 | void SimpleAlarmDaemonImpl::confSound( int num ) |
246 | { | 248 | { |
247 | if ( num == 0 ) { | 249 | if ( num == 0 ) { |
248 | wavAlarm = false; | 250 | wavAlarm = false; |
249 | mSoundPopUp->setItemChecked ( 0, true ); | 251 | mSoundPopUp->setItemChecked ( 0, true ); |
250 | mSoundPopUp->setItemChecked ( 1, false ); | 252 | mSoundPopUp->setItemChecked ( 1, false ); |
251 | } else { | 253 | } else { |
252 | wavAlarm = true; | 254 | wavAlarm = true; |
253 | mSoundPopUp->setItemChecked ( 0, false ); | 255 | mSoundPopUp->setItemChecked ( 0, false ); |
254 | mSoundPopUp->setItemChecked ( 1, true ); | 256 | mSoundPopUp->setItemChecked ( 1, true ); |
255 | } | 257 | } |
256 | } | 258 | } |
257 | void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) | 259 | void SimpleAlarmDaemonImpl::slotPlayBeep( int num ) |
258 | { | 260 | { |
261 | if ( num == 1000 ) { | ||
262 | simulate(); | ||
263 | return; | ||
264 | } | ||
259 | mBeepPopUp->setItemChecked ( mPlayBeeps,false ); | 265 | mBeepPopUp->setItemChecked ( mPlayBeeps,false ); |
260 | mPlayBeeps = num; | 266 | mPlayBeeps = num; |
261 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); | 267 | mBeepPopUp->setItemChecked ( mPlayBeeps, true ); |
262 | } | 268 | } |
263 | 269 | ||
264 | void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) | 270 | void SimpleAlarmDaemonImpl::recieve( const QCString& msg, const QByteArray& ) |
265 | { | 271 | { |
266 | //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); | 272 | //qDebug("SimpleAlarmDaemonImpl::ALARM RECEIVED! %s", msg.data()); |
267 | QString mess = msg; | 273 | QString mess = msg; |
268 | mAlarmMessage = mess.mid( 9 ); | 274 | mAlarmMessage = mess.mid( 9 ); |
269 | QString filename = getenv("QPEDIR") ; | 275 | QString filename = getenv("QPEDIR") ; |
270 | filename += "/pics/kdepim/korganizer/koalarm.wav"; | 276 | filename += "/pics/kdepim/korganizer/koalarm.wav"; |
271 | QString tempfilename; | 277 | QString tempfilename; |
272 | if ( mess.left( 13 ) == "suspend_alarm") { | 278 | if ( mess.left( 13 ) == "suspend_alarm") { |
273 | bool error = false; | 279 | bool error = false; |
274 | int len = mess.mid( 13 ).find("+++"); | 280 | int len = mess.mid( 13 ).find("+++"); |
275 | if ( len < 2 ) | 281 | if ( len < 2 ) |
276 | error = true; | 282 | error = true; |
277 | else { | 283 | else { |
278 | tempfilename = mess.mid( 13, len ); | 284 | tempfilename = mess.mid( 13, len ); |
279 | if ( !QFile::exists( tempfilename ) ) | 285 | if ( !QFile::exists( tempfilename ) ) |
280 | error = true; | 286 | error = true; |
281 | } | 287 | } |
282 | if ( ! error ) { | 288 | if ( ! error ) { |
283 | filename = tempfilename; | 289 | filename = tempfilename; |
284 | } | 290 | } |
285 | mAlarmMessage = mess.mid( 13+len+3 ); | 291 | mAlarmMessage = mess.mid( 13+len+3 ); |
286 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 292 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
287 | startAlarm( mAlarmMessage, filename); | 293 | startAlarm( mAlarmMessage, filename); |
288 | return; | 294 | return; |
289 | } | 295 | } |
290 | if ( mess.left( 11 ) == "timer_alarm") { | 296 | if ( mess.left( 11 ) == "timer_alarm") { |
291 | mTimerTime = 0; | 297 | mTimerTime = 0; |
292 | startAlarm( mess.mid( 11 ), filename ); | 298 | startAlarm( mess.mid( 11 ), filename ); |
293 | return; | 299 | return; |
294 | } | 300 | } |
295 | if ( mess.left( 10 ) == "proc_alarm") { | 301 | if ( mess.left( 10 ) == "proc_alarm") { |
296 | bool error = false; | 302 | bool error = false; |
297 | int len = mess.mid( 10 ).find("+++"); | 303 | int len = mess.mid( 10 ).find("+++"); |
298 | if ( len < 2 ) | 304 | if ( len < 2 ) |
299 | error = true; | 305 | error = true; |
300 | else { | 306 | else { |
301 | tempfilename = mess.mid( 10, len ); | 307 | tempfilename = mess.mid( 10, len ); |
302 | if ( !QFile::exists( tempfilename ) ) | 308 | if ( !QFile::exists( tempfilename ) ) |
303 | error = true; | 309 | error = true; |
304 | } | 310 | } |
305 | if ( error ) { | 311 | if ( error ) { |
306 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 312 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
307 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 313 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
308 | } else { | 314 | } else { |
309 | { | 315 | { |
310 | QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 316 | QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
311 | } | 317 | } |
312 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 318 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
313 | if ( vfork () == 0 ) { | 319 | if ( vfork () == 0 ) { |
314 | execl ( tempfilename.latin1(), 0 ); | 320 | execl ( tempfilename.latin1(), 0 ); |
315 | return; | 321 | return; |
316 | } | 322 | } |
317 | return; | 323 | return; |
318 | } | 324 | } |
319 | 325 | ||
320 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 326 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
321 | } | 327 | } |
322 | if ( mess.left( 11 ) == "audio_alarm") { | 328 | if ( mess.left( 11 ) == "audio_alarm") { |
323 | bool error = false; | 329 | bool error = false; |
324 | int len = mess.mid( 11 ).find("+++"); | 330 | int len = mess.mid( 11 ).find("+++"); |
325 | if ( len < 2 ) | 331 | if ( len < 2 ) |
326 | error = true; | 332 | error = true; |
327 | else { | 333 | else { |
328 | tempfilename = mess.mid( 11, len ); | 334 | tempfilename = mess.mid( 11, len ); |
329 | if ( !QFile::exists( tempfilename ) ) | 335 | if ( !QFile::exists( tempfilename ) ) |
330 | error = true; | 336 | error = true; |
331 | } | 337 | } |
332 | if ( ! error ) { | 338 | if ( ! error ) { |
333 | filename = tempfilename; | 339 | filename = tempfilename; |
334 | } | 340 | } |
335 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 341 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
336 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 342 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
337 | } | 343 | } |
338 | if ( mess.left( 9 ) == "cal_alarm") { | 344 | if ( mess.left( 9 ) == "cal_alarm") { |
339 | mAlarmMessage = mess.mid( 9 ) ; | 345 | mAlarmMessage = mess.mid( 9 ) ; |
340 | } | 346 | } |
341 | 347 | ||
342 | writeFile(); | 348 | writeFile(); |
343 | startAlarm( mAlarmMessage, filename ); | 349 | startAlarm( mAlarmMessage, filename ); |
344 | 350 | ||
345 | } | 351 | } |
346 | 352 | ||
347 | int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) | 353 | int SimpleAlarmDaemonImpl::getFileNameLen( QString mess ) |
348 | { | 354 | { |
349 | return 0; | 355 | return 0; |
350 | } | 356 | } |
351 | void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) | 357 | void SimpleAlarmDaemonImpl::startAlarm( QString mess, QString filename ) |
352 | { | 358 | { |
353 | //mAlarmDialog->show(); | 359 | //mAlarmDialog->show(); |
354 | //mAlarmDialog->raise(); | 360 | //mAlarmDialog->raise(); |
355 | mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); | 361 | mAlarmDialog->eventNotification( mess, mPlayBeeps, filename, wavAlarm,mPausePlay ,mSuspend ); |
356 | } | 362 | } |
357 | 363 | ||
358 | 364 | ||
359 | void SimpleAlarmDaemonImpl::fillTimerPopUp() | 365 | void SimpleAlarmDaemonImpl::fillTimerPopUp() |
360 | { | 366 | { |
361 | 367 | ||
362 | // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); | 368 | // qDebug(" timer %d %d ",mTimerPopupConf, mTimerTime ); |
363 | if ( mTimerPopupConf == mTimerTime ) { | 369 | if ( mTimerPopupConf == mTimerTime ) { |
364 | if ( mTimerTime ) { | 370 | if ( mTimerTime ) { |
365 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); | 371 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); |
366 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); | 372 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); |
367 | mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); | 373 | mTimerPopUp->changeItem ( 1 , t.toString() + " (countdown)"); |
368 | } | 374 | } |
369 | else { | 375 | else { |
370 | QString text = mCustomText.stripWhiteSpace (); | 376 | QString text = mCustomText.stripWhiteSpace (); |
371 | int in = text.find( " " ); | 377 | int in = text.find( " " ); |
372 | text = text.left ( in ); | 378 | text = text.left ( in ); |
373 | mTimerPopUp->changeItem ( 3, text ); | 379 | mTimerPopUp->changeItem ( 3, text ); |
374 | } | 380 | } |
375 | return; | 381 | return; |
376 | } | 382 | } |
377 | mTimerPopupConf = mTimerTime; | 383 | mTimerPopupConf = mTimerTime; |
378 | mTimerPopUp->clear(); | 384 | mTimerPopUp->clear(); |
379 | if ( mTimerTime ) { | 385 | if ( mTimerTime ) { |
380 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); | 386 | int secs = QDateTime::currentDateTime().secsTo ( mRunningTimer ); |
381 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); | 387 | QTime t ( secs/3600, (secs/60)%60, secs%60 ); |
382 | 388 | ||
383 | 389 | ||
384 | mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); | 390 | mTimerPopUp->insertItem( "Stop timer "+ mRunningTimerText , 0 ); |
385 | mTimerPopUp->insertItem( t.toString() + " (countdown)",1); | 391 | mTimerPopUp->insertItem( t.toString() + " (countdown)",1); |
386 | mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2); | 392 | mTimerPopUp->insertItem( mRunningTimer.time().toString() + " (alarm)",2); |
387 | } else { | 393 | } else { |
388 | 394 | ||
389 | QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; | 395 | QString fileName = QDir::homeDirPath() +"/.kopialarmtimerrc"; |
390 | QFile file( fileName ); | 396 | QFile file( fileName ); |
391 | if( !QFile::exists( fileName) ) { | 397 | if( !QFile::exists( fileName) ) { |
392 | // write defaults | 398 | // write defaults |
393 | if (!file.open( IO_WriteOnly ) ) { | 399 | if (!file.open( IO_WriteOnly ) ) { |
394 | return; | 400 | return; |
395 | } | 401 | } |
396 | QString configString ; | 402 | QString configString ; |
397 | configString += "#config file for kopi alarm timer\n"; | 403 | configString += "#config file for kopi alarm timer\n"; |
398 | configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; | 404 | configString += "#format: <Text for popup menu>;<timer countdown in minutes>\n"; |
399 | configString += "#NOTE: minimum value for timer are 3 minutes!\n"; | 405 | configString += "#NOTE: minimum value for timer are 3 minutes!\n"; |
400 | configString += "24 h; 1440\n"; | 406 | configString += "24 h; 1440\n"; |
401 | configString += " 8 h; 480\n"; | 407 | configString += " 8 h; 480\n"; |
402 | configString += " 5 h; 300\n"; | 408 | configString += " 5 h; 300\n"; |
403 | configString += " 1 h; 60\n"; | 409 | configString += " 1 h; 60\n"; |
404 | configString += "30 min; 30\n"; | 410 | configString += "30 min; 30\n"; |
405 | configString += "15 min; 15\n"; | 411 | configString += "15 min; 15\n"; |
406 | configString += "SEPARATOR\n"; | 412 | configString += "SEPARATOR\n"; |
407 | configString += "Pizza; 22\n"; | 413 | configString += "Pizza; 22\n"; |
408 | configString += "Nap; 45\n"; | 414 | configString += "Nap; 45\n"; |
409 | configString += "Tea; 5\n"; | 415 | configString += "Tea; 5\n"; |
410 | QTextStream ts( &file ); | 416 | QTextStream ts( &file ); |
411 | ts << configString ; | 417 | ts << configString ; |
412 | file.close(); | 418 | file.close(); |
413 | } | 419 | } |
414 | 420 | ||
415 | if (!file.open( IO_ReadOnly ) ) { | 421 | if (!file.open( IO_ReadOnly ) ) { |
416 | return ; | 422 | return ; |
417 | } | 423 | } |
418 | QString line; | 424 | QString line; |
419 | bool ok; | 425 | bool ok; |
420 | while ( file.readLine( line, 1024 ) > 0 ) { | 426 | while ( file.readLine( line, 1024 ) > 0 ) { |
421 | //qDebug("read %s ", line.latin1()); | 427 | //qDebug("read %s ", line.latin1()); |
422 | if ( line.left(1 ) != "#" ) { | 428 | if ( line.left(1 ) != "#" ) { |
423 | // no comment | 429 | // no comment |
424 | if ( line.left(9 ) == "SEPARATOR" ) { | 430 | if ( line.left(9 ) == "SEPARATOR" ) { |
425 | mTimerPopUp->insertSeparator(); | 431 | mTimerPopUp->insertSeparator(); |
426 | } else { | 432 | } else { |
427 | QStringList li = QStringList::split(";",line); | 433 | QStringList li = QStringList::split(";",line); |
428 | ok = false; | 434 | ok = false; |
429 | if ( li.count() == 2 ) { | 435 | if ( li.count() == 2 ) { |
430 | int val = li[1].toInt( &ok ); | 436 | int val = li[1].toInt( &ok ); |
431 | if ( ok && val > 2 ) { | 437 | if ( ok && val > 2 ) { |
432 | mTimerPopUp->insertItem( li[0], val); | 438 | mTimerPopUp->insertItem( li[0], val); |
433 | } | 439 | } |
434 | } | 440 | } |
435 | } | 441 | } |
436 | } | 442 | } |
437 | } | 443 | } |
438 | file.close(); | 444 | file.close(); |
439 | #if 0 | 445 | #if 0 |
440 | mTimerPopUp->insertItem( "24 h", 1440 ); | 446 | mTimerPopUp->insertItem( "24 h", 1440 ); |
441 | // mTimerPopUp->insertItem( i18n("12 h"), 720 ); | 447 | // mTimerPopUp->insertItem( i18n("12 h"), 720 ); |
442 | mTimerPopUp->insertItem( " 8 h", 480 ); | 448 | mTimerPopUp->insertItem( " 8 h", 480 ); |
443 | mTimerPopUp->insertItem( " 5 h", 300 ); | 449 | mTimerPopUp->insertItem( " 5 h", 300 ); |
444 | // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); | 450 | // mTimerPopUp->insertItem( i18n(" 2 h"), 120 ); |
445 | mTimerPopUp->insertItem( " 1 h", 60 ); | 451 | mTimerPopUp->insertItem( " 1 h", 60 ); |
446 | mTimerPopUp->insertItem( "30 min", 30 ); | 452 | mTimerPopUp->insertItem( "30 min", 30 ); |
447 | mTimerPopUp->insertItem( "15 min", 15 ); | 453 | mTimerPopUp->insertItem( "15 min", 15 ); |
448 | mTimerPopUp->insertItem( "10 min", 10 ); | 454 | mTimerPopUp->insertItem( "10 min", 10 ); |
449 | //mTimerPopUp->insertItem( " 5 min", 5 ); | 455 | //mTimerPopUp->insertItem( " 5 min", 5 ); |
450 | mTimerPopUp->insertSeparator(); | 456 | mTimerPopUp->insertSeparator(); |
451 | mTimerPopUp->insertItem( "Pizza", 22 ); | 457 | mTimerPopUp->insertItem( "Pizza", 22 ); |
452 | mTimerPopUp->insertItem( "Nap", 45 ); | 458 | mTimerPopUp->insertItem( "Nap", 45 ); |
453 | mTimerPopUp->insertItem( "Tea", 5 ); | 459 | mTimerPopUp->insertItem( "Tea", 5 ); |
454 | #endif | 460 | #endif |
455 | QString text = mCustomText.stripWhiteSpace (); | 461 | QString text = mCustomText.stripWhiteSpace (); |
456 | int in = text.find( " " ); | 462 | int in = text.find( " " ); |
457 | text = text.left ( in ); | 463 | text = text.left ( in ); |
458 | mTimerPopUp->insertItem( text, 3 ); | 464 | mTimerPopUp->insertItem( text, 3 ); |
459 | mTimerPopUp->insertSeparator(); | 465 | mTimerPopUp->insertSeparator(); |
460 | mTimerPopUp->insertItem( "Customize", 2 ); | 466 | mTimerPopUp->insertItem( "Customize", 2 ); |
461 | } | 467 | } |
462 | 468 | ||
463 | } | 469 | } |
464 | 470 | ||
465 | void SimpleAlarmDaemonImpl::showTimer() | 471 | void SimpleAlarmDaemonImpl::showTimer() |
466 | { | 472 | { |
467 | fillTimerPopUp(); | 473 | fillTimerPopUp(); |
468 | } | 474 | } |
469 | 475 | ||
470 | void SimpleAlarmDaemonImpl::confTimer( int time ) | 476 | void SimpleAlarmDaemonImpl::confTimer( int time ) |
471 | { | 477 | { |
472 | //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); | 478 | //qDebug("impleAlarmDaemonImpl::confTimer() %d ", time ); |
473 | int minutes = time; | 479 | int minutes = time; |
474 | if ( minutes == 0 ) { | 480 | if ( minutes == 0 ) { |
475 | if ( ! mTimerTime ) | 481 | if ( ! mTimerTime ) |
476 | return; | 482 | return; |
477 | 483 | ||
478 | QDialog dia ( 0, ("Stop Timer" ), true ); | 484 | QDialog dia ( 0, ("Stop Timer" ), true ); |
479 | QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia ); | 485 | QLabel lab (("Really stop the timer?\n\n"+ mRunningTimerText+"\n"), &dia ); |
480 | lab.setAlignment( AlignCenter ); | 486 | lab.setAlignment( AlignCenter ); |
481 | dia.setCaption(("KO/Pi Timer Stop" )); | 487 | dia.setCaption(("KO/Pi Timer Stop" )); |
482 | QVBoxLayout lay( &dia ); | 488 | QVBoxLayout lay( &dia ); |
483 | lay.addWidget( &lab); | 489 | lay.addWidget( &lab); |
484 | QPushButton ok ( "Stop timer!", &dia); | 490 | QPushButton ok ( "Stop timer!", &dia); |
485 | QFont fo = dia.font(); | 491 | QFont fo = dia.font(); |
486 | fo.setPointSize( 36 ); | 492 | fo.setPointSize( 36 ); |
487 | ok.setFont( fo ); | 493 | ok.setFont( fo ); |
488 | lay.addWidget( &ok); | 494 | lay.addWidget( &ok); |
489 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); | 495 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); |
490 | QPushButton con ( "Continue timer!", &dia); | 496 | QPushButton con ( "Continue timer!", &dia); |
491 | fo.setPointSize( 36 ); | 497 | fo.setPointSize( 36 ); |
492 | con.setFont( fo ); | 498 | con.setFont( fo ); |
493 | lay.addWidget( &con); | 499 | lay.addWidget( &con); |
494 | connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); | 500 | connect ( &con, SIGNAL (clicked()), &dia, SLOT ( reject() ) ); |
495 | lay.setMargin(5); | 501 | lay.setMargin(5); |
496 | lay.setSpacing(5); | 502 | lay.setSpacing(5); |
497 | dia.resize(dia.sizeHint() ); | 503 | dia.resize(dia.sizeHint() ); |
498 | 504 | ||
499 | if ( !dia.exec() ) | 505 | if ( !dia.exec() ) |
500 | return; | 506 | return; |
501 | 507 | ||
502 | AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() ); | 508 | AlarmServer::deleteAlarm ( mRunningTimer,"koalarm" , timerMesssage.latin1() ); |
503 | mTimerTime = 0; | 509 | mTimerTime = 0; |
504 | return; | 510 | return; |
505 | } | 511 | } |
506 | if ( mTimerTime ) | 512 | if ( mTimerTime ) |
507 | return; | 513 | return; |
508 | if ( minutes == 1 ) { | 514 | if ( minutes == 1 ) { |
509 | return; | 515 | return; |
510 | } | 516 | } |
511 | QString mess = "timer_alarm"; | 517 | QString mess = "timer_alarm"; |
512 | mess += ("Timer Alarm!\n"); | 518 | mess += ("Timer Alarm!\n"); |
513 | if ( minutes == 22 ) { | 519 | if ( minutes == 22 ) { |
514 | mess += ( "Pizza is ready"); | 520 | mess += ( "Pizza is ready"); |
515 | mRunningTimerText = "Pizza"; | 521 | mRunningTimerText = "Pizza"; |
516 | } | 522 | } |
517 | else if ( minutes == 45 ) { | 523 | else if ( minutes == 45 ) { |
518 | mess += ( "Please wake up!"); | 524 | mess += ( "Please wake up!"); |
519 | mRunningTimerText = "Nap"; | 525 | mRunningTimerText = "Nap"; |
520 | } | 526 | } |
521 | else if ( minutes == 5 ) { | 527 | else if ( minutes == 5 ) { |
522 | mess += ( "Tea is ready"); | 528 | mess += ( "Tea is ready"); |
523 | mRunningTimerText = "Tea"; | 529 | mRunningTimerText = "Tea"; |
524 | } | 530 | } |
525 | else if ( minutes == 3 ) { | 531 | else if ( minutes == 3 ) { |
526 | mess += mCustomText; | 532 | mess += mCustomText; |
527 | minutes = mCustomMinutes ; | 533 | minutes = mCustomMinutes ; |
528 | mRunningTimerText = mCustomText.stripWhiteSpace (); | 534 | mRunningTimerText = mCustomText.stripWhiteSpace (); |
529 | int in = mRunningTimerText.find( " " ); | 535 | int in = mRunningTimerText.find( " " ); |
530 | mRunningTimerText = mRunningTimerText.left ( in ); | 536 | mRunningTimerText = mRunningTimerText.left ( in ); |
531 | } | 537 | } |
532 | else { | 538 | else { |
533 | if ( minutes == 2 ) { | 539 | if ( minutes == 2 ) { |
534 | // ask time | 540 | // ask time |
535 | QDialog dia ( 0, ("Customize Timer" ), true ); | 541 | QDialog dia ( 0, ("Customize Timer" ), true ); |
536 | QLabel lab (("Message Text:"), &dia ); | 542 | QLabel lab (("Message Text:"), &dia ); |
537 | dia.setCaption(("KO/Pi Timer" )); | 543 | dia.setCaption(("KO/Pi Timer" )); |
538 | QVBoxLayout lay( &dia ); | 544 | QVBoxLayout lay( &dia ); |
539 | lay.setMargin(5); | 545 | lay.setMargin(5); |
540 | lay.setSpacing(5); | 546 | lay.setSpacing(5); |
541 | lay.addWidget( &lab); | 547 | lay.addWidget( &lab); |
542 | QLineEdit lEdit( mCustomText, &dia ); | 548 | QLineEdit lEdit( mCustomText, &dia ); |
543 | lay.addWidget( &lEdit); | 549 | lay.addWidget( &lEdit); |
544 | QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); | 550 | QLabel lab2 (("Countdown time (1 min - 24 h):"), &dia ); |
545 | lay.addWidget( &lab2); | 551 | lay.addWidget( &lab2); |
546 | QHBox hbox1 ( &dia ); | 552 | QHBox hbox1 ( &dia ); |
547 | lay.addWidget( &hbox1); | 553 | lay.addWidget( &hbox1); |
548 | QLabel lab3 (("Hours"), &hbox1 ); | 554 | QLabel lab3 (("Hours"), &hbox1 ); |
549 | QLabel lab4 (("Minutes"), &hbox1 ); | 555 | QLabel lab4 (("Minutes"), &hbox1 ); |
550 | QHBox hbox ( &dia ); | 556 | QHBox hbox ( &dia ); |
551 | QSpinBox spinh( 0, 24, 1,& hbox ); | 557 | QSpinBox spinh( 0, 24, 1,& hbox ); |
552 | QFont fo = dia.font(); | 558 | QFont fo = dia.font(); |
553 | fo.setPointSize( 36 ); | 559 | fo.setPointSize( 36 ); |
554 | QSpinBox spinm( 0, 59, 1,&hbox ); | 560 | QSpinBox spinm( 0, 59, 1,&hbox ); |
555 | spinm.setFont( fo ); | 561 | spinm.setFont( fo ); |
556 | spinh.setFont( fo ); | 562 | spinh.setFont( fo ); |
557 | spinh.setButtonSymbols( QSpinBox::PlusMinus ); | 563 | spinh.setButtonSymbols( QSpinBox::PlusMinus ); |
558 | spinm.setButtonSymbols( QSpinBox::PlusMinus ); | 564 | spinm.setButtonSymbols( QSpinBox::PlusMinus ); |
559 | spinh.upButton ()->setFixedSize( QSize( 48, 30 )); | 565 | spinh.upButton ()->setFixedSize( QSize( 48, 30 )); |
560 | spinh.downButton ()->setFixedSize( QSize( 48, 30 )); | 566 | spinh.downButton ()->setFixedSize( QSize( 48, 30 )); |
561 | //spinh.editor ()->setFixedSize( QSize( 50, 100 )); | 567 | //spinh.editor ()->setFixedSize( QSize( 50, 100 )); |
562 | spinh.setFixedSize( 100,62 ); | 568 | spinh.setFixedSize( 100,62 ); |
563 | spinm.upButton ()->setFixedSize( QSize( 48, 30 )); | 569 | spinm.upButton ()->setFixedSize( QSize( 48, 30 )); |
564 | spinm.downButton ()->setFixedSize( QSize( 48, 30 )); | 570 | spinm.downButton ()->setFixedSize( QSize( 48, 30 )); |
565 | spinm.downButton ()->setGeometry( 50,50,50,50); | 571 | spinm.downButton ()->setGeometry( 50,50,50,50); |
566 | // spinm.setSuffix( " m" ); | 572 | // spinm.setSuffix( " m" ); |
567 | //spinh.setSuffix( " h" ); | 573 | //spinh.setSuffix( " h" ); |
568 | spinm.setWrapping ( true ); | 574 | spinm.setWrapping ( true ); |
569 | //spinm.editor ()->setFixedSize( QSize( 50, 100 )); | 575 | //spinm.editor ()->setFixedSize( QSize( 50, 100 )); |
570 | spinm.setLineStep( 1 ); | 576 | spinm.setLineStep( 1 ); |
571 | spinm.setFixedSize( 110,62 ); | 577 | spinm.setFixedSize( 110,62 ); |
572 | lay.addWidget( &hbox); | 578 | lay.addWidget( &hbox); |
573 | QLabel lab5 ("Timer fires at:", &dia ); | 579 | QLabel lab5 ("Timer fires at:", &dia ); |
574 | lab5.setAlignment( AlignCenter ); | 580 | lab5.setAlignment( AlignCenter ); |
575 | lay.addWidget( &lab5); | 581 | lay.addWidget( &lab5); |
576 | KODateLabel dl ( &dia ); | 582 | KODateLabel dl ( &dia ); |
577 | dl.setAlignment( AlignCenter ); | 583 | dl.setAlignment( AlignCenter ); |
578 | dl.setFont( fo ); | 584 | dl.setFont( fo ); |
579 | connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) ); | 585 | connect ( &spinh, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_hours( int ) ) ); |
580 | connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) ); | 586 | connect ( &spinm, SIGNAL ( valueChanged (int)), &dl, SLOT ( slot_minutes( int ) ) ); |
581 | lay.addWidget( &dl); | 587 | lay.addWidget( &dl); |
582 | spinh.setValue( mCustomMinutes/60 ); | 588 | spinh.setValue( mCustomMinutes/60 ); |
583 | spinm.setValue( mCustomMinutes%60 ); | 589 | spinm.setValue( mCustomMinutes%60 ); |
584 | QPushButton ok ( "Start timer", &dia); | 590 | QPushButton ok ( "Start timer", &dia); |
585 | ok.setDefault( true ); | 591 | ok.setDefault( true ); |
586 | ok.setFont( fo ); | 592 | ok.setFont( fo ); |
587 | spinh.setFocus(); | 593 | spinh.setFocus(); |
588 | lay.addWidget( &ok); | 594 | lay.addWidget( &ok); |
589 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); | 595 | connect ( &ok, SIGNAL (clicked()), &dia, SLOT ( accept() ) ); |
590 | dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); | 596 | dia.resize( dia.sizeHint().width(), dia.sizeHint().height() ); |
591 | 597 | ||
592 | if ( !dia.exec() ) | 598 | if ( !dia.exec() ) |
593 | return; | 599 | return; |
594 | mCustomText = lEdit.text(); | 600 | mCustomText = lEdit.text(); |
595 | mCustomMinutes = spinh.value()*60+spinm.value(); | 601 | mCustomMinutes = spinh.value()*60+spinm.value(); |
596 | if ( mCustomMinutes == 0 ) | 602 | if ( mCustomMinutes == 0 ) |
597 | mCustomMinutes = 1; | 603 | mCustomMinutes = 1; |
598 | if ( mCustomMinutes > 1440 ) | 604 | if ( mCustomMinutes > 1440 ) |
599 | mCustomMinutes = 1440; | 605 | mCustomMinutes = 1440; |
600 | mess += mCustomText; | 606 | mess += mCustomText; |
601 | minutes = mCustomMinutes; | 607 | minutes = mCustomMinutes; |
602 | mRunningTimerText = mCustomText.stripWhiteSpace (); | 608 | mRunningTimerText = mCustomText.stripWhiteSpace (); |
603 | int in = mRunningTimerText.find( " " ); | 609 | int in = mRunningTimerText.find( " " ); |
604 | mRunningTimerText = mRunningTimerText.left ( in ); | 610 | mRunningTimerText = mRunningTimerText.left ( in ); |
605 | } | 611 | } |
606 | else { | 612 | else { |
607 | mess+= QString::number ( minutes ) + ( " minutes are past!"); | 613 | mess+= QString::number ( minutes ) + ( " minutes are past!"); |
608 | int min = minutes; | 614 | int min = minutes; |
609 | if ( min % 60 == 0 ) | 615 | if ( min % 60 == 0 ) |
610 | mRunningTimerText = QString::number ( min/60 ) + ( " hours"); | 616 | mRunningTimerText = QString::number ( min/60 ) + ( " hours"); |
611 | else | 617 | else |
612 | mRunningTimerText = QString::number ( minutes ) + ( " minutes"); | 618 | mRunningTimerText = QString::number ( minutes ) + ( " minutes"); |
613 | } | 619 | } |
614 | } | 620 | } |
615 | //minutes = 1; | 621 | //minutes = 1; |
616 | 622 | ||
617 | mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); | 623 | mRunningTimer = QDateTime::currentDateTime().addSecs( minutes * 60 ); |
618 | timerMesssage = mess; | 624 | timerMesssage = mess; |
619 | AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1()); | 625 | AlarmServer::addAlarm ( mRunningTimer,"koalarm",timerMesssage.latin1()); |
620 | mTimerTime = 1; | 626 | mTimerTime = 1; |
621 | } | 627 | } |
622 | 628 | ||
623 | void SimpleAlarmDaemonImpl::writeFile() | 629 | void SimpleAlarmDaemonImpl::writeFile() |
624 | { | 630 | { |
625 | QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 631 | QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
626 | //QCopEnvelope e("QPE/Application/kopi", "-writeFile"); | 632 | //QCopEnvelope e("QPE/Application/kopi", "-writeFile"); |
627 | } | 633 | } |
628 | void SimpleAlarmDaemonImpl::showWN() | 634 | void SimpleAlarmDaemonImpl::showWN() |
629 | { | 635 | { |
630 | QCopEnvelope e("QPE/Application/kopi", "-showWN"); | 636 | QCopEnvelope e("QPE/Application/kopi", "-showWN"); |
631 | } | 637 | } |
632 | void SimpleAlarmDaemonImpl::newTodo() | 638 | void SimpleAlarmDaemonImpl::newTodo() |
633 | { | 639 | { |
634 | QCopEnvelope e("QPE/Application/kopi", "-newTodo"); | 640 | QCopEnvelope e("QPE/Application/kopi", "-newTodo"); |
635 | } | 641 | } |
636 | 642 | ||
637 | void SimpleAlarmDaemonImpl::newEvent() | 643 | void SimpleAlarmDaemonImpl::newEvent() |
638 | { | 644 | { |
639 | QCopEnvelope e("QPE/Application/kopi", "-newEvent"); | 645 | QCopEnvelope e("QPE/Application/kopi", "-newEvent"); |
640 | 646 | ||
641 | } | 647 | } |
642 | void SimpleAlarmDaemonImpl::newMail() | 648 | void SimpleAlarmDaemonImpl::newMail() |
643 | { | 649 | { |
644 | QCopEnvelope e("QPE/Application/ompi", "newMail()"); | 650 | QCopEnvelope e("QPE/Application/ompi", "newMail()"); |
645 | } | 651 | } |
646 | void SimpleAlarmDaemonImpl::showAdd() | 652 | void SimpleAlarmDaemonImpl::showAdd() |
647 | { | 653 | { |
648 | QCopEnvelope e("QPE/Application/kapi", "raise()"); | 654 | QCopEnvelope e("QPE/Application/kapi", "raise()"); |
649 | } | 655 | } |
650 | void SimpleAlarmDaemonImpl::ringSync() | 656 | void SimpleAlarmDaemonImpl::ringSync() |
651 | { | 657 | { |
652 | QCopEnvelope e("QPE/Application/kopi", "-ringSync"); | 658 | QCopEnvelope e("QPE/Application/kopi", "-ringSync"); |
653 | 659 | ||
654 | } | 660 | } |
655 | void SimpleAlarmDaemonImpl::newCountdown() | 661 | void SimpleAlarmDaemonImpl::newCountdown() |
656 | { | 662 | { |
657 | //recieve("cal_alarm", 10 ); | 663 | //recieve("cal_alarm", 10 ); |
658 | } | 664 | } |
659 | void SimpleAlarmDaemonImpl::simulate() | 665 | void SimpleAlarmDaemonImpl::simulate() |
660 | { | 666 | { |
661 | writeFile(); | 667 | writeFile(); |
662 | QString filename = getenv("QPEDIR") ; | 668 | QString filename = getenv("QPEDIR") ; |
663 | filename += "/pics/kdepim/korganizer/koalarm.wav"; | 669 | filename += "/pics/kdepim/korganizer/koalarm.wav"; |
664 | startAlarm("Alarm simulation", filename ); | 670 | startAlarm("Alarm simulation", filename ); |
665 | } | 671 | } |
666 | void SimpleAlarmDaemonImpl::showKO() | 672 | void SimpleAlarmDaemonImpl::showKO() |
667 | { | 673 | { |
668 | QCopEnvelope e("QPE/Application/kopi", "-showKO"); | 674 | QCopEnvelope e("QPE/Application/kopi", "-showKO"); |
669 | // testing only | 675 | // testing only |
670 | //QCopEnvelope e("QPE/Application/kopi", "nextView()"); | 676 | //QCopEnvelope e("QPE/Application/kopi", "nextView()"); |
671 | 677 | ||
672 | } | 678 | } |
673 | void SimpleAlarmDaemonImpl::showTodo() | 679 | void SimpleAlarmDaemonImpl::showTodo() |
674 | { | 680 | { |
675 | QCopEnvelope e("QPE/Application/kopi", "-showTodo"); | 681 | QCopEnvelope e("QPE/Application/kopi", "-showTodo"); |
676 | 682 | ||
677 | } | 683 | } |
678 | void SimpleAlarmDaemonImpl::writeJournal() | 684 | void SimpleAlarmDaemonImpl::writeJournal() |
679 | { | 685 | { |
680 | QCopEnvelope e("QPE/Application/kopi", "-showJournal"); | 686 | QCopEnvelope e("QPE/Application/kopi", "-showJournal"); |
681 | 687 | ||
682 | } | 688 | } |
683 | 689 | ||
684 | void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) | 690 | void SimpleAlarmDaemonImpl::mousePressEvent( QMouseEvent * ) |
685 | { | 691 | { |
686 | 692 | ||
687 | mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); | 693 | mPopUp->popup(mapToGlobal(QPoint (0, -mPopUp->height() ))); |
688 | 694 | ||
689 | } | 695 | } |
690 | 696 | ||