summaryrefslogtreecommitdiff
path: root/noncore
authorllornkcor <llornkcor>2002-06-27 17:43:22 (UTC)
committer llornkcor <llornkcor>2002-06-27 17:43:22 (UTC)
commitc2d32ceea75df8ad2e81c676acd8234597a89635 (patch) (unidiff)
treefbf407510d7e2540cbe0d0452def6d21146d389d /noncore
parent63d7fd9b233a5b6a9e3670b6ef1c09a2e87ffa42 (diff)
downloadopie-c2d32ceea75df8ad2e81c676acd8234597a89635.zip
opie-c2d32ceea75df8ad2e81c676acd8234597a89635.tar.gz
opie-c2d32ceea75df8ad2e81c676acd8234597a89635.tar.bz2
added mp3 alarm.. will refine later
Diffstat (limited to 'noncore') (more/less context) (show whitespace changes)
-rw-r--r--noncore/tools/clock/clock.cpp9
-rw-r--r--noncore/tools/clock/setAlarm.cpp35
-rw-r--r--noncore/tools/clock/setAlarm.h4
3 files changed, 44 insertions, 4 deletions
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp
index a47793b..69d8214 100644
--- a/noncore/tools/clock/clock.cpp
+++ b/noncore/tools/clock/clock.cpp
@@ -378,27 +378,36 @@ void Clock::alarmOff()
378 "alarm(QDateTime,int)", warn ); 378 "alarm(QDateTime,int)", warn );
379 qDebug("Alarm Off "+ when.toString()); 379 qDebug("Alarm Off "+ when.toString());
380 setCaption("Clock"); 380 setCaption("Clock");
381} 381}
382 382
383void Clock::appMessage(const QCString& msg, const QByteArray& data) 383void Clock::appMessage(const QCString& msg, const QByteArray& data)
384{ 384{
385 int stopTimer = 0; 385 int stopTimer = 0;
386 int timerStay = 5000; 386 int timerStay = 5000;
387 bSound=TRUE; 387 bSound=TRUE;
388 qDebug("Message received in clock"); 388 qDebug("Message received in clock");
389 if ( msg == "alarm(QDateTime,int)" ) { 389 if ( msg == "alarm(QDateTime,int)" ) {
390 Config config( "qpe" );
391 config.setGroup("Time");
392 if(config.readBoolEntry("mp3Alarm",0)){
393
394 QCopEnvelope e("QPE/Application/opieplayer","setDocument(QString)");
395 e<<config.readEntry("mp3File","");
396 } else {
397
390 Sound::soundAlarm(); 398 Sound::soundAlarm();
391 stopTimer = startTimer( timerStay); 399 stopTimer = startTimer( timerStay);
392 } 400 }
401 }
393 show(); 402 show();
394 raise(); 403 raise();
395 QPEApplication::setKeepRunning(); 404 QPEApplication::setKeepRunning();
396 setActiveWindow(); 405 setActiveWindow();
397} 406}
398 407
399void Clock::timerEvent( QTimerEvent *e ) 408void Clock::timerEvent( QTimerEvent *e )
400{ 409{
401 static int stop = 0; 410 static int stop = 0;
402 if ( stop < 120 && bSound) { 411 if ( stop < 120 && bSound) {
403 Sound::soundAlarm(); 412 Sound::soundAlarm();
404 stop++; 413 stop++;
diff --git a/noncore/tools/clock/setAlarm.cpp b/noncore/tools/clock/setAlarm.cpp
index 990ff81..38de396 100644
--- a/noncore/tools/clock/setAlarm.cpp
+++ b/noncore/tools/clock/setAlarm.cpp
@@ -5,47 +5,50 @@
5// copyright : (C) 2002 by ljp 5// copyright : (C) 2002 by ljp
6// email : ljp@llornkcor.com 6// email : ljp@llornkcor.com
7// 7//
8*************************************************************************** 8***************************************************************************
9 * This program is free software; you can redistribute it and/or modify * 9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by * 10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or * 11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. * 12 * (at your option) any later version. *
13 ***************************************************************************/ 13 ***************************************************************************/
14 14
15#include "setAlarm.h" 15#include "setAlarm.h"
16 16
17#include <qpe/config.h> 17#include <opie/ofileselector.h>
18#include <opie/ofiledialog.h>
18 19
20#include <qpe/config.h>
19#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
20#include <qstring.h> 22#include <qstring.h>
21#include <qlabel.h> 23#include <qlabel.h>
22#include <qlcdnumber.h> 24#include <qlcdnumber.h>
23#include <qpushbutton.h> 25#include <qpushbutton.h>
24#include <qradiobutton.h> 26#include <qradiobutton.h>
25#include <qslider.h> 27#include <qslider.h>
26#include <qlayout.h> 28#include <qlayout.h>
27#include <qvariant.h> 29#include <qvariant.h>
28#include <qtooltip.h> 30#include <qtooltip.h>
29#include <qwhatsthis.h> 31#include <qwhatsthis.h>
30#include <qbuttongroup.h> 32#include <qbuttongroup.h>
33#include <qcheckbox.h>
31 34
32Set_Alarm::Set_Alarm( QWidget* parent, const char* name, bool modal, WFlags fl ) 35Set_Alarm::Set_Alarm( QWidget* parent, const char* name, bool modal, WFlags fl )
33 : QDialog( parent, name, modal, fl ) 36 : QDialog( parent, name, modal, fl )
34{ 37{
35 if ( !name ) 38 if ( !name )
36 setName( "Set_Alarm" ); 39 setName( "Set_Alarm" );
37 resize( 240, 101 ); 40 resize( 240, 101 );
38 setMaximumSize( QSize( 240, 320 ) ); 41 setMaximumSize( QSize( 240, 320 ) );
39 move(0,48); 42 move(0,45);
40 setCaption( tr( "Set Alarm" ) ); 43 setCaption( tr( "Set Alarm" ) );
41 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); 44 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
42 45
43 Set_AlarmLayout = new QGridLayout( this ); 46 Set_AlarmLayout = new QGridLayout( this );
44 Set_AlarmLayout->setSpacing( 6 ); 47 Set_AlarmLayout->setSpacing( 6 );
45 Set_AlarmLayout->setMargin( 11 ); 48 Set_AlarmLayout->setMargin( 11 );
46 49
47 TextLabel1 = new QLabel( this, "TextLabel1" ); 50 TextLabel1 = new QLabel( this, "TextLabel1" );
48 TextLabel1->setText( tr( "Hour" ) ); 51 TextLabel1->setText( tr( "Hour" ) );
49 52
50 Set_AlarmLayout->addWidget( TextLabel1, 0, 0 ); 53 Set_AlarmLayout->addWidget( TextLabel1, 0, 0 );
51 54
@@ -88,42 +91,48 @@ Set_Alarm::Set_Alarm( QWidget* parent, const char* name, bool modal, WFlags fl
88 Am_RadioButton->setChecked(TRUE); 91 Am_RadioButton->setChecked(TRUE);
89 connect( Am_RadioButton, SIGNAL(toggled(bool)),this,SLOT( amButtonToggled(bool))); 92 connect( Am_RadioButton, SIGNAL(toggled(bool)),this,SLOT( amButtonToggled(bool)));
90 93
91 Set_AlarmLayout->addMultiCellWidget( Am_RadioButton, 0, 1, 3, 4 ); 94 Set_AlarmLayout->addMultiCellWidget( Am_RadioButton, 0, 1, 3, 4 );
92 95
93 96
94 Pm_RadioButton = new QRadioButton( this, "Pm_RadioButton" ); 97 Pm_RadioButton = new QRadioButton( this, "Pm_RadioButton" );
95 Pm_RadioButton->setText( tr( "PM" ) ); 98 Pm_RadioButton->setText( tr( "PM" ) );
96 connect( Pm_RadioButton, SIGNAL(toggled(bool)),this,SLOT( pmButtonToggled(bool))); 99 connect( Pm_RadioButton, SIGNAL(toggled(bool)),this,SLOT( pmButtonToggled(bool)));
97 100
98 Set_AlarmLayout->addMultiCellWidget(Pm_RadioButton, 1, 2, 3, 4 ); 101 Set_AlarmLayout->addMultiCellWidget(Pm_RadioButton, 1, 2, 3, 4 );
99 102
103 useMp3Check = new QCheckBox ( tr( "mp3 alarm" ), this );
104 useMp3Check-> setFocusPolicy ( QWidget::NoFocus );
105 Set_AlarmLayout->addMultiCellWidget( useMp3Check, 2, 3, 3, 4 );
106
107
108
100 TextLabel3 = new QLabel( this, "TextLabel3" ); 109 TextLabel3 = new QLabel( this, "TextLabel3" );
101 TextLabel3->setText( tr( "Snooze Delay\n(minutes)" ) ); 110 TextLabel3->setText( tr( "Snooze Delay\n(minutes)" ) );
102 111
103 Set_AlarmLayout->addMultiCellWidget( TextLabel3, 3, 3, 0, 1 ); 112 Set_AlarmLayout->addMultiCellWidget( TextLabel3, 3, 3, 0, 1 );
104 113
105 Snooze_LCDNumber = new QLCDNumber( this, "Snooze_LCDNumber" ); 114 Snooze_LCDNumber = new QLCDNumber( this, "Snooze_LCDNumber" );
106 Snooze_LCDNumber->setFrameShape( QLCDNumber::Box ); 115 Snooze_LCDNumber->setFrameShape( QLCDNumber::Box );
107 Snooze_LCDNumber->setFrameShadow( QLCDNumber::Plain ); 116 Snooze_LCDNumber->setFrameShadow( QLCDNumber::Plain );
108 Snooze_LCDNumber->setSegmentStyle( QLCDNumber::Flat ); 117 Snooze_LCDNumber->setSegmentStyle( QLCDNumber::Flat );
109 118
110 Set_AlarmLayout->addMultiCellWidget( Snooze_LCDNumber, 3, 3, 1, 2 ); 119 Set_AlarmLayout->addMultiCellWidget( Snooze_LCDNumber, 3, 3, 1, 2 );
111 120
112 SnoozeSlider = new QSlider( this, "SnoozeSlider" ); 121 SnoozeSlider = new QSlider( this, "SnoozeSlider" );
113 SnoozeSlider->setMaxValue( 60 ); 122 SnoozeSlider->setMaxValue( 60 );
114 SnoozeSlider->setOrientation( QSlider::Horizontal ); 123 SnoozeSlider->setOrientation( QSlider::Horizontal );
115 connect(SnoozeSlider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeSnooze(int))); 124 connect(SnoozeSlider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeSnooze(int)));
116 125
117 Set_AlarmLayout->addMultiCellWidget( SnoozeSlider, 3, 3, 3, 4 ); 126 Set_AlarmLayout->addMultiCellWidget( SnoozeSlider, 4, 4, 1, 2 );
118 127
119 Config config( "qpe" ); 128 Config config( "qpe" );
120 config.setGroup("Time"); 129 config.setGroup("Time");
121 130
122 bool ok; 131 bool ok;
123 bool ampm = config.readBoolEntry( "AMPM", TRUE ); 132 bool ampm = config.readBoolEntry( "AMPM", TRUE );
124 QString alarmHour=config.readEntry("clockAlarmHour","8"); 133 QString alarmHour=config.readEntry("clockAlarmHour","8");
125 int i_alarmHour = alarmHour.toInt(&ok,10); 134 int i_alarmHour = alarmHour.toInt(&ok,10);
126 QString alarmMinute=config.readEntry("clockAlarmMinute","0"); 135 QString alarmMinute=config.readEntry("clockAlarmMinute","0");
127 QString snoozeTime=config.readEntry("clockAlarmSnooze","0"); 136 QString snoozeTime=config.readEntry("clockAlarmSnooze","0");
128 if(ampm) { 137 if(ampm) {
129 Hour_Slider->setMaxValue( 12); 138 Hour_Slider->setMaxValue( 12);
@@ -139,25 +148,29 @@ Set_Alarm::Set_Alarm( QWidget* parent, const char* name, bool modal, WFlags fl
139 Hour_Slider->setValue( i_alarmHour ); 148 Hour_Slider->setValue( i_alarmHour );
140 Minute_Slider->setValue( alarmMinute.toInt(&ok,10) ); 149 Minute_Slider->setValue( alarmMinute.toInt(&ok,10) );
141 SnoozeSlider->setValue( snoozeTime.toInt(&ok,10) ); 150 SnoozeSlider->setValue( snoozeTime.toInt(&ok,10) );
142 } else { 151 } else {
143 Hour_Slider->setMaxValue( 23); 152 Hour_Slider->setMaxValue( 23);
144 Hour_Slider->setMinValue( 0); 153 Hour_Slider->setMinValue( 0);
145 Hour_Slider->setValue( i_alarmHour); 154 Hour_Slider->setValue( i_alarmHour);
146 Minute_Slider->setValue( alarmMinute.toInt(&ok,10) ); 155 Minute_Slider->setValue( alarmMinute.toInt(&ok,10) );
147 SnoozeSlider->setValue( snoozeTime.toInt(&ok,10) ); 156 SnoozeSlider->setValue( snoozeTime.toInt(&ok,10) );
148 Am_RadioButton->hide(); 157 Am_RadioButton->hide();
149 Pm_RadioButton->hide(); 158 Pm_RadioButton->hide();
150 } 159 }
160 if( config.readBoolEntry("mp3Alarm") )
161 useMp3Check->setChecked(true);
162
151 // signals and slots connections 163 // signals and slots connections
164 connect(useMp3Check,SIGNAL(toggled(bool)),this,SLOT(slotChangemp3CkeckBox(bool)));
152} 165}
153 166
154Set_Alarm::~Set_Alarm() 167Set_Alarm::~Set_Alarm()
155{ 168{
156 169
157} 170}
158 171
159void Set_Alarm::slotChangeHour(int hour) 172void Set_Alarm::slotChangeHour(int hour)
160{ 173{
161 Hour_LCDNumber->display(hour); 174 Hour_LCDNumber->display(hour);
162} 175}
163 176
@@ -177,12 +190,28 @@ void Set_Alarm::amButtonToggled(bool b)
177 Pm_RadioButton->setChecked(FALSE); 190 Pm_RadioButton->setChecked(FALSE);
178} 191}
179 192
180void Set_Alarm::pmButtonToggled(bool b) 193void Set_Alarm::pmButtonToggled(bool b)
181{ 194{
182 if (b) 195 if (b)
183 Am_RadioButton->setChecked(FALSE); 196 Am_RadioButton->setChecked(FALSE);
184} 197}
185 198
186void Set_Alarm::cleanUp() 199void Set_Alarm::cleanUp()
187{ 200{
188} 201}
202
203void Set_Alarm::slotChangemp3CkeckBox(bool b) {
204 Config config( "qpe" );
205 config.setGroup("Time");
206 if(b) {
207 QString str = OFileDialog::getOpenFileName( 2,"/");//,"", "*", this );
208 if(!str.isEmpty() ) {
209 qDebug(str);
210 config.writeEntry("mp3Alarm",1);
211 config.writeEntry("mp3File",str);
212 }
213 } else {
214 config.writeEntry("mp3Alarm",0);
215 config.writeEntry("mp3File","");
216 }
217}
diff --git a/noncore/tools/clock/setAlarm.h b/noncore/tools/clock/setAlarm.h
index 7d63237..a21af05 100644
--- a/noncore/tools/clock/setAlarm.h
+++ b/noncore/tools/clock/setAlarm.h
@@ -17,41 +17,43 @@
17 17
18#include <qvariant.h> 18#include <qvariant.h>
19#include <qdialog.h> 19#include <qdialog.h>
20 20
21class QVBoxLayout; 21class QVBoxLayout;
22class QHBoxLayout; 22class QHBoxLayout;
23class QGridLayout; 23class QGridLayout;
24class QLCDNumber; 24class QLCDNumber;
25class QLabel; 25class QLabel;
26class QRadioButton; 26class QRadioButton;
27class QSlider; 27class QSlider;
28class QButtonGroup; 28class QButtonGroup;
29 29class QCheckBox;
30class Set_Alarm : public QDialog 30class Set_Alarm : public QDialog
31{ 31{
32 Q_OBJECT 32 Q_OBJECT
33 33
34public: 34public:
35 Set_Alarm( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 35 Set_Alarm( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
36 ~Set_Alarm(); 36 ~Set_Alarm();
37 37
38 QLabel *TextLabel1, *TextLabel2, *TextLabel3; 38 QLabel *TextLabel1, *TextLabel2, *TextLabel3;
39 QSlider *Hour_Slider, *Minute_Slider, *SnoozeSlider; 39 QSlider *Hour_Slider, *Minute_Slider, *SnoozeSlider;
40 QLCDNumber *Hour_LCDNumber, *Minute_LCDNumber, *Snooze_LCDNumber; 40 QLCDNumber *Hour_LCDNumber, *Minute_LCDNumber, *Snooze_LCDNumber;
41 41
42 QRadioButton* Am_RadioButton; 42 QRadioButton* Am_RadioButton;
43 43
44 QRadioButton* Pm_RadioButton; 44 QRadioButton* Pm_RadioButton;
45 QButtonGroup *ButtonGroup1; 45 QButtonGroup *ButtonGroup1;
46 QCheckBox *useMp3Check;
46protected slots: 47protected slots:
48 void slotChangemp3CkeckBox(bool);
47 void slotChangeHour(int); 49 void slotChangeHour(int);
48 void slotChangeMinute(int); 50 void slotChangeMinute(int);
49 void slotChangeSnooze(int); 51 void slotChangeSnooze(int);
50 void amButtonToggled(bool); 52 void amButtonToggled(bool);
51 void pmButtonToggled(bool); 53 void pmButtonToggled(bool);
52 void cleanUp(); 54 void cleanUp();
53protected: 55protected:
54 QGridLayout* Set_AlarmLayout; 56 QGridLayout* Set_AlarmLayout;
55}; 57};
56 58
57#endif // SET_ALARM_H 59#endif // SET_ALARM_H