summaryrefslogtreecommitdiff
path: root/noncore/tools/clock/setAlarm.cpp
Unidiff
Diffstat (limited to 'noncore/tools/clock/setAlarm.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/clock/setAlarm.cpp183
1 files changed, 183 insertions, 0 deletions
diff --git a/noncore/tools/clock/setAlarm.cpp b/noncore/tools/clock/setAlarm.cpp
new file mode 100644
index 0000000..01e52f6
--- a/dev/null
+++ b/noncore/tools/clock/setAlarm.cpp
@@ -0,0 +1,183 @@
1 /***************************************************************************
2// setAlarm.cpp - description
3// -------------------
4// Created: Wed Mar 13 19:47:24 2002
5// copyright : (C) 2002 by ljp
6// email : ljp@llornkcor.com
7//
8***************************************************************************
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 *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 ***************************************************************************/
14
15#include "setAlarm.h"
16
17#include <qpe/config.h>
18
19#include <qpe/qpeapplication.h>
20#include <qstring.h>
21#include <qlabel.h>
22#include <qlcdnumber.h>
23#include <qpushbutton.h>
24#include <qradiobutton.h>
25#include <qslider.h>
26#include <qlayout.h>
27#include <qvariant.h>
28#include <qtooltip.h>
29#include <qwhatsthis.h>
30#include <qbuttongroup.h>
31
32Set_Alarm::Set_Alarm( QWidget* parent, const char* name, bool modal, WFlags fl )
33 : QDialog( parent, name, modal, fl )
34{
35 if ( !name )
36 setName( "Set_Alarm" );
37 resize( 240, 101 );
38 setMaximumSize( QSize( 240, 320 ) );
39 setCaption( tr( "Set Alarm" ) );
40 connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
41
42 Set_AlarmLayout = new QGridLayout( this );
43 Set_AlarmLayout->setSpacing( 6 );
44 Set_AlarmLayout->setMargin( 11 );
45
46 TextLabel1 = new QLabel( this, "TextLabel1" );
47 TextLabel1->setText( tr( "Hour" ) );
48
49 Set_AlarmLayout->addWidget( TextLabel1, 0, 0 );
50
51 TextLabel2 = new QLabel( this, "TextLabel2" );
52 TextLabel2->setText( tr( "Minute" ) );
53
54 Set_AlarmLayout->addMultiCellWidget( TextLabel2, 0, 0, 1, 2 );
55
56 Hour_Slider = new QSlider( this, "Hour_Slider" );
57 Hour_Slider->setPageStep( 1);
58 Hour_Slider->setOrientation( QSlider::Horizontal );
59 connect(Hour_Slider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeHour(int)));
60
61 Set_AlarmLayout->addWidget( Hour_Slider, 2, 0 );
62
63 Hour_LCDNumber = new QLCDNumber( this, "Hour_LCDNumber" );
64 Hour_LCDNumber->setFrameShape( QLCDNumber::Box );
65 Hour_LCDNumber->setFrameShadow( QLCDNumber::Plain );
66 Hour_LCDNumber->setSegmentStyle( QLCDNumber::Flat );
67
68 Set_AlarmLayout->addWidget( Hour_LCDNumber, 1, 0 );
69
70 Minute_Slider = new QSlider( this, "Minute_Slider" );
71 Minute_Slider->setMaxValue( 59);
72 Minute_Slider->setOrientation( QSlider::Horizontal );
73 connect(Minute_Slider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeMinute(int)));
74
75 Set_AlarmLayout->addMultiCellWidget( Minute_Slider, 2, 2, 1, 2 );
76
77 Minute_LCDNumber = new QLCDNumber( this, "Minute_LCDNumber" );
78 Minute_LCDNumber->setFrameShape( QLCDNumber::Box );
79 Minute_LCDNumber->setFrameShadow( QLCDNumber::Plain );
80 Minute_LCDNumber->setSegmentStyle( QLCDNumber::Flat );
81
82 Set_AlarmLayout->addMultiCellWidget( Minute_LCDNumber, 1, 1, 1, 2 );
83
84 Am_RadioButton = new QRadioButton( this, "Am_RadioButton" );
85 Am_RadioButton->setText( tr( "AM" ) );
86 Am_RadioButton->setChecked(TRUE);
87 connect( Am_RadioButton, SIGNAL(toggled(bool)),this,SLOT( amButtonToggled(bool)));
88
89 Set_AlarmLayout->addMultiCellWidget( Am_RadioButton, 0, 1, 3, 4 );
90
91
92 Pm_RadioButton = new QRadioButton( this, "Pm_RadioButton" );
93 Pm_RadioButton->setText( tr( "PM" ) );
94 connect( Pm_RadioButton, SIGNAL(toggled(bool)),this,SLOT( pmButtonToggled(bool)));
95
96 Set_AlarmLayout->addMultiCellWidget(Pm_RadioButton, 1, 2, 3, 4 );
97
98 TextLabel3 = new QLabel( this, "TextLabel3" );
99 TextLabel3->setText( tr( "Snooze Delay\n(minutes)" ) );
100
101 Set_AlarmLayout->addMultiCellWidget( TextLabel3, 3, 3, 0, 1 );
102
103 Snooze_LCDNumber = new QLCDNumber( this, "Snooze_LCDNumber" );
104 Snooze_LCDNumber->setFrameShape( QLCDNumber::Box );
105 Snooze_LCDNumber->setFrameShadow( QLCDNumber::Plain );
106 Snooze_LCDNumber->setSegmentStyle( QLCDNumber::Flat );
107
108 Set_AlarmLayout->addMultiCellWidget( Snooze_LCDNumber, 3, 3, 1, 2 );
109
110 SnoozeSlider = new QSlider( this, "SnoozeSlider" );
111 SnoozeSlider->setMaxValue( 60 );
112 SnoozeSlider->setOrientation( QSlider::Horizontal );
113 connect(SnoozeSlider, SIGNAL( valueChanged(int)),this,SLOT(slotChangeSnooze(int)));
114
115 Set_AlarmLayout->addMultiCellWidget( SnoozeSlider, 3, 3, 3, 4 );
116
117 Config config( "qpe" );
118 config.setGroup("Time");
119
120 bool ok;
121 bool ampm = config.readBoolEntry( "AMPM", TRUE );
122 QString alarmHour=config.readEntry("clockAlarmHour","8");
123 int i_alarmHour = alarmHour.toInt(&ok,10);
124 QString alarmMinute=config.readEntry("clockAlarmMinute","0");
125 QString snoozeTime=config.readEntry("clockAlarmSnooze","0");
126 if(ampm) {
127 Hour_Slider->setMaxValue( 12);
128 Hour_Slider->setMinValue( 1);
129
130 if( i_alarmHour > 12) {
131 i_alarmHour = i_alarmHour - 12;
132 Pm_RadioButton->setChecked(TRUE);
133 }
134 Hour_Slider->setValue( i_alarmHour);
135 Minute_Slider->setValue( alarmMinute.toInt(&ok,10) );
136 SnoozeSlider->setValue( snoozeTime.toInt(&ok,10) );
137 } else {
138 Hour_Slider->setMaxValue( 23);
139 Hour_Slider->setMinValue( 1);
140 Hour_Slider->setValue( i_alarmHour);
141 Minute_Slider->setValue( alarmMinute.toInt(&ok,10) );
142 SnoozeSlider->setValue( snoozeTime.toInt(&ok,10) );
143 Am_RadioButton->hide();
144 Pm_RadioButton->hide();
145 }
146 // signals and slots connections
147}
148
149Set_Alarm::~Set_Alarm()
150{
151
152}
153
154void Set_Alarm::slotChangeHour(int hour)
155{
156 Hour_LCDNumber->display(hour);
157}
158
159void Set_Alarm::slotChangeMinute(int minute)
160{
161 Minute_LCDNumber->display(minute);
162}
163
164void Set_Alarm::slotChangeSnooze(int minute)
165{
166 Snooze_LCDNumber->display(minute);
167}
168
169void Set_Alarm::amButtonToggled(bool b)
170{
171 if ( b)
172 Pm_RadioButton->setChecked(FALSE);
173}
174
175void Set_Alarm::pmButtonToggled(bool b)
176{
177 if (b)
178 Am_RadioButton->setChecked(FALSE);
179}
180
181void Set_Alarm::cleanUp()
182{
183}