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