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