summaryrefslogtreecommitdiff
authorzecke <zecke>2002-05-21 14:21:59 (UTC)
committer zecke <zecke>2002-05-21 14:21:59 (UTC)
commitd65dc25caec62d4c554c99fbc151bf4d07c63b72 (patch) (side-by-side diff)
tree37485591f8cd642df0177ea77b860f8d4432e9ef
parent3eb1e88e5915c9dbd521a150cc5dd7eb7dbb3663 (diff)
downloadopie-d65dc25caec62d4c554c99fbc151bf4d07c63b72.zip
opie-d65dc25caec62d4c554c99fbc151bf4d07c63b72.tar.gz
opie-d65dc25caec62d4c554c99fbc151bf4d07c63b72.tar.bz2
usbaility updates a clock should be able to set the time
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/clock/clock.cpp24
-rw-r--r--noncore/tools/clock/clock.h1
-rw-r--r--noncore/tools/clock/clock.pro2
3 files changed, 20 insertions, 7 deletions
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp
index a21a061..ea8e8ca 100644
--- a/noncore/tools/clock/clock.cpp
+++ b/noncore/tools/clock/clock.cpp
@@ -26,16 +26,18 @@
#include <qpe/config.h>
#include <qpe/timestring.h>
#include <qpe/alarmserver.h>
#include <qpe/sound.h>
#include <qpe/resource.h>
#include <qsound.h>
#include <qtimer.h>
+#include <opie/oclickablelabel.h>
+
#include <qlcdnumber.h>
#include <qslider.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qtimer.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qbuttongroup.h>
@@ -87,17 +89,17 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f )
space = new QWidget( hb );
date = new QLabel( this );
date->setAlignment( AlignHCenter | AlignVCenter );
date->setFont( QFont( "Helvetica", 14, QFont::Bold ) );
date->setText( TimeString::longDateString( QDate::currentDate() ) );
QWidget *controls = new QWidget( this );
- QGridLayout *gl = new QGridLayout( controls, 2, 2, 6, 4 );
+ QGridLayout *gl = new QGridLayout( controls, 3, 2, 6, 4 );
QButtonGroup *grp = new QButtonGroup( controls );
grp->setRadioButtonExclusive( true );
grp->hide();
clockRB = new QRadioButton ( tr( "Clock" ), controls );
gl->addWidget( clockRB, 0, 0 );
grp->insert( clockRB );
@@ -126,16 +128,21 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f )
// alarmOffBtn->setMaximumSize(60,30);
gl->addWidget( alarmOffBtn, 0, 2 );
alarmBtn = new QPushButton ( controls );
// alarmBtn->setMaximumSize(60,30);
gl->addWidget( alarmBtn, 1, 2 );
alarmBtn->setText( tr( "Set Alarm" ) );
+ OClickableLabel *click = new OClickableLabel(controls, "label" );
+ click->setText(tr("Set date and time." ) );
+ gl->addMultiCellWidget( click, 3, 3, 0, 2, AlignHCenter);
+ connect( click, SIGNAL(clicked() ), this, SLOT(slotAdjustTime() ) );
+
connect( set, SIGNAL( pressed() ), SLOT( slotSet() ) );
connect( reset, SIGNAL( clicked() ), SLOT( slotReset() ) );
connect( alarmBtn, SIGNAL( clicked() ), SLOT( slotSetAlarm() ) );
connect( snoozeBtn, SIGNAL( clicked() ), SLOT( slotSnooze() ) );
connect( alarmOffBtn, SIGNAL( clicked() ), SLOT( slotToggleAlarm() ) );
connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
@@ -162,34 +169,34 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f )
alarmOffBtn->setText( tr( "Alarm Is On" ) );
alarmBool=TRUE;
snoozeBtn->show();
} else {
alarmOffBtn->setText( tr( "Alarm Is Off" ) );
alarmBool=FALSE;
snoozeBtn->hide();
}
-
+
QTimer::singleShot( 0, this, SLOT(updateClock()) );
modeSelect(0);
}
Clock::~Clock()
{
toggleScreenSaver( true );
}
void Clock::updateClock()
{
if ( clockRB->isChecked() ) {
QTime tm = QDateTime::currentDateTime().time();
QString s;
if ( ampm ) {
int hour = tm.hour();
- if (hour == 0)
+ if (hour == 0)
hour = 12;
if (hour > 12)
hour -= 12;
s.sprintf( "%2d%c%02d", hour, ':', tm.minute() );
ampmLabel->setText( (tm.hour() >= 12) ? "PM" : "AM" );
ampmLabel->show();
} else {
s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() );
@@ -276,17 +283,17 @@ void Clock::modeSelect( int m )
set->setEnabled( FALSE );
reset->setEnabled( FALSE );
t->start(1000);
}
updateClock();
}
//this sets the alarm time
-void Clock::slotSetAlarm()
+void Clock::slotSetAlarm()
{
if( !snoozeBtn->isHidden())
slotToggleAlarm();
Set_Alarm *setAlarmDlg;
setAlarmDlg = new Set_Alarm(this,"SetAlarm", TRUE);
int result = setAlarmDlg->exec();
if(result == 1) {
Config config( "qpe" );
@@ -298,34 +305,34 @@ void Clock::slotSetAlarm()
if(ampm) {
if(setAlarmDlg->Pm_RadioButton->isChecked() && hour < 12 )
hour+=12;
}
config.writeEntry("clockAlarmHour", tmp.setNum( hour ),10);
config.writeEntry("clockAlarmMinute",tmp.setNum( minute ),10);
config.writeEntry("clockAlarmSnooze",tmp.setNum( snoozeTime ),10);
config.write();
- }
+ }
}
void Clock::slotSnooze()
{
bSound=FALSE;
int warn;
QTime t = QTime::currentTime();
QDateTime whenl( when.date(), t.addSecs( snoozeTime*60));
when=whenl;
AlarmServer::addAlarm( when,
"QPE/Application/clock",
"alarm(QDateTime,int)", warn );
}
//toggles alarm on/off
-void Clock::slotToggleAlarm()
+void Clock::slotToggleAlarm()
{
Config config( "qpe" );
config.setGroup("Time");
if(alarmBool) {
config.writeEntry("clockAlarmSet","FALSE");
alarmOffBtn->setText( tr( "Alarm Is Off" ) );
snoozeBtn->hide();
alarmBool=FALSE;
@@ -469,8 +476,13 @@ QPoint AnalogClock::rotate( QPoint c, QPoint p, int a )
{
double angle = deg2rad * ( - a + 180 );
double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) -
( p.y() - c.y() ) * sin( angle );
double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) +
( p.x() - c.x() ) * sin( angle );
return QPoint( nx, ny );
}
+void Clock::slotAdjustTime()
+{
+ QCopEnvelope e("QPE/System", "execute(QString)");
+ e << QString("systemtime");
+}
diff --git a/noncore/tools/clock/clock.h b/noncore/tools/clock/clock.h
index 9b756b5..024dd28 100644
--- a/noncore/tools/clock/clock.h
+++ b/noncore/tools/clock/clock.h
@@ -71,16 +71,17 @@ private slots:
void changeClock( bool );
void slotSetAlarm();
void slotSnooze();
void slotToggleAlarm();
void alarmOn();
void alarmOff();
void appMessage(const QCString& msg, const QByteArray& data);
void timerEvent( QTimerEvent *e );
+ void slotAdjustTime();
private:
void clearClock();
bool alarmBool;
QTimer *t;
QLCDNumber *lcd;
QLabel *date;
diff --git a/noncore/tools/clock/clock.pro b/noncore/tools/clock/clock.pro
index 5373515..7eecce1 100644
--- a/noncore/tools/clock/clock.pro
+++ b/noncore/tools/clock/clock.pro
@@ -1,17 +1,17 @@
TEMPLATE = app
CONFIG = qt warn_on release
DESTDIR = $(OPIEDIR)/bin
HEADERS = clock.h setAlarm.h
SOURCES = clock.cpp setAlarm.cpp \
main.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe
+LIBS += -lqpe -lopie
INTERFACES =
TARGET = clock
TRANSLATIONS = ../i18n/de/clock.ts
TRANSLATIONS += ../i18n/pt_BR/clock.ts
TRANSLATIONS += ../i18n/en/clock.ts
TRANSLATIONS += ../i18n/hu/clock.ts
TRANSLATIONS += ../i18n/sl/clock.ts