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