summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/netsystemtime.pro6
-rw-r--r--noncore/settings/netsystemtime/ntpbase.cpp328
-rw-r--r--noncore/settings/netsystemtime/ntpbase.h93
-rw-r--r--noncore/settings/netsystemtime/settime.cpp8
4 files changed, 428 insertions, 7 deletions
diff --git a/noncore/settings/netsystemtime/netsystemtime.pro b/noncore/settings/netsystemtime/netsystemtime.pro
index 026b8da..0530ea5 100644
--- a/noncore/settings/netsystemtime/netsystemtime.pro
+++ b/noncore/settings/netsystemtime/netsystemtime.pro
@@ -1,26 +1,26 @@
TEMPLATE = app
CONFIG = qt warn_on debug
#CONFIG = qt warn_on release
-HEADERS = ntp.h settime.h
-SOURCES = main.cpp ntp.cpp settime.cpp
+HEADERS = ntp.h settime.h ntpbase.h
+SOURCES = main.cpp ntp.cpp settime.cpp ntpbase.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopie
-INTERFACES = ntpbase.ui
+INTERFACES =
DESTDIR = $(OPIEDIR)/bin
TARGET = netsystemtime
TRANSLATIONS = ../../../i18n/de/netsystemtime.ts \
../../../i18n/en/netsystemtime.ts \
../../../i18n/es/netsystemtime.ts \
../../../i18n/fr/netsystemtime.ts \
../../../i18n/hu/netsystemtime.ts \
../../../i18n/ja/netsystemtime.ts \
../../../i18n/ko/netsystemtime.ts \
../../../i18n/no/netsystemtime.ts \
../../../i18n/pl/netsystemtime.ts \
../../../i18n/pt/netsystemtime.ts \
../../../i18n/pt_BR/netsystemtime.ts \
../../../i18n/sl/netsystemtime.ts \
../../../i18n/zh_CN/netsystemtime.ts \
../../../i18n/zh_TW/netsystemtime.ts
diff --git a/noncore/settings/netsystemtime/ntpbase.cpp b/noncore/settings/netsystemtime/ntpbase.cpp
new file mode 100644
index 0000000..7762e93
--- a/dev/null
+++ b/noncore/settings/netsystemtime/ntpbase.cpp
@@ -0,0 +1,328 @@
+/****************************************************************************
+** Form implementation generated from reading ui file 'ntpbase.ui'
+**
+** Created: Mon Oct 21 21:06:08 2002
+** by: The User Interface Compiler (uic)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+#include "ntpbase.h"
+
+#include <qcombobox.h>
+#include <qframe.h>
+#include <qlabel.h>
+#include <qmultilineedit.h>
+#include <qpushbutton.h>
+#include <qspinbox.h>
+#include <qtable.h>
+#include <qtabwidget.h>
+#include <qlayout.h>
+#include <qvariant.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+
+/*
+ * Constructs a NtpBase which is a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'
+ */
+NtpBase::NtpBase( QWidget* parent, const char* name, WFlags fl )
+ : QWidget( parent, name, fl )
+{
+ if ( !name )
+ setName( "NtpBase" );
+ resize( 320, 411 );
+ setCaption( tr( "Network Time" ) );
+ NtpBaseLayout = new QGridLayout( this );
+ NtpBaseLayout->setSpacing( 2 );
+ NtpBaseLayout->setMargin( 2 );
+
+ TabWidgetMain = new QTabWidget( this, "TabWidgetMain" );
+
+ tabMain = new QWidget( TabWidgetMain, "tabMain" );
+ tabMainLayout = new QGridLayout( tabMain );
+ tabMainLayout->setSpacing( 2 );
+ tabMainLayout->setMargin( 2 );
+
+ FrameSystemTime = new QFrame( tabMain, "FrameSystemTime" );
+ FrameSystemTime->setFrameShape( QFrame::StyledPanel );
+ FrameSystemTime->setFrameShadow( QFrame::Raised );
+
+ tabMainLayout->addWidget( FrameSystemTime, 0, 0 );
+
+ tabNtp = new QWidget( TabWidgetMain, "tabNtp" );
+ tabNtpLayout = new QGridLayout( tabNtp );
+ tabNtpLayout->setSpacing( 2 );
+ tabNtpLayout->setMargin( 1 );
+
+ runNtp = new QPushButton( tabNtp, "runNtp" );
+ runNtp->setText( tr( "Get time from network" ) );
+
+ tabNtpLayout->addWidget( runNtp, 1, 0 );
+
+ FrameNtp = new QFrame( tabNtp, "FrameNtp" );
+ FrameNtp->setFrameShape( QFrame::StyledPanel );
+ FrameNtp->setFrameShadow( QFrame::Raised );
+ FrameNtpLayout = new QGridLayout( FrameNtp );
+ FrameNtpLayout->setSpacing( 2 );
+ FrameNtpLayout->setMargin( 2 );
+
+ Layout4 = new QVBoxLayout;
+ Layout4->setSpacing( 6 );
+ Layout4->setMargin( 0 );
+
+ TextLabel1 = new QLabel( FrameNtp, "TextLabel1" );
+ TextLabel1->setAutoMask( FALSE );
+ TextLabel1->setText( tr( "Start Time:" ) );
+ Layout4->addWidget( TextLabel1 );
+
+ TextLabelStartTime = new QLabel( FrameNtp, "TextLabelStartTime" );
+ TextLabelStartTime->setText( tr( "nan" ) );
+ Layout4->addWidget( TextLabelStartTime );
+
+ TextLabel3 = new QLabel( FrameNtp, "TextLabel3" );
+ TextLabel3->setText( tr( "Time Shift:" ) );
+ Layout4->addWidget( TextLabel3 );
+
+ TextLabelTimeShift = new QLabel( FrameNtp, "TextLabelTimeShift" );
+ TextLabelTimeShift->setText( tr( "nan" ) );
+ Layout4->addWidget( TextLabelTimeShift );
+
+ TextLabel5 = new QLabel( FrameNtp, "TextLabel5" );
+ TextLabel5->setText( tr( "New Time:" ) );
+ Layout4->addWidget( TextLabel5 );
+
+ TextLabelNewTime = new QLabel( FrameNtp, "TextLabelNewTime" );
+ TextLabelNewTime->setText( tr( "nan" ) );
+ Layout4->addWidget( TextLabelNewTime );
+ QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ Layout4->addItem( spacer );
+
+ FrameNtpLayout->addLayout( Layout4, 0, 0 );
+
+ MultiLineEditntpOutPut = new QMultiLineEdit( FrameNtp, "MultiLineEditntpOutPut" );
+ QFont MultiLineEditntpOutPut_font( MultiLineEditntpOutPut->font() );
+ MultiLineEditntpOutPut_font.setPointSize( 7 );
+ MultiLineEditntpOutPut->setFont( MultiLineEditntpOutPut_font );
+ MultiLineEditntpOutPut->setWordWrap( QMultiLineEdit::WidgetWidth );
+ MultiLineEditntpOutPut->setText( tr( "" ) );
+
+ FrameNtpLayout->addWidget( MultiLineEditntpOutPut, 1, 0 );
+
+ tabNtpLayout->addWidget( FrameNtp, 0, 0 );
+
+ tabPredict = new QWidget( TabWidgetMain, "tabPredict" );
+ tabPredictLayout = new QGridLayout( tabPredict );
+ tabPredictLayout->setSpacing( 6 );
+ tabPredictLayout->setMargin( 5 );
+
+ TableLookups = new QTable( tabPredict, "TableLookups" );
+ QFont TableLookups_font( TableLookups->font() );
+ TableLookups_font.setPointSize( 8 );
+ TableLookups->setFont( TableLookups_font );
+ TableLookups->setNumRows( 2 );
+ TableLookups->setNumCols( 2 );
+
+ tabPredictLayout->addWidget( TableLookups, 0, 0 );
+
+ Layout9 = new QGridLayout;
+ Layout9->setSpacing( 6 );
+ Layout9->setMargin( 0 );
+
+ TextLabelShift = new QLabel( tabPredict, "TextLabelShift" );
+ TextLabelShift->setText( tr( "nan" ) );
+
+ Layout9->addWidget( TextLabelShift, 0, 1 );
+
+ TextLabel4 = new QLabel( tabPredict, "TextLabel4" );
+ TextLabel4->setText( tr( "Esimated Shift:" ) );
+
+ Layout9->addWidget( TextLabel4, 1, 0 );
+
+ TextLabelEstimatedShift = new QLabel( tabPredict, "TextLabelEstimatedShift" );
+ TextLabelEstimatedShift->setText( tr( "nan" ) );
+
+ Layout9->addWidget( TextLabelEstimatedShift, 1, 1 );
+
+ TextLabel3_2 = new QLabel( tabPredict, "TextLabel3_2" );
+ TextLabel3_2->setText( tr( "Predicted Time:" ) );
+
+ Layout9->addWidget( TextLabel3_2, 2, 0 );
+
+ Mean_shift_label = new QLabel( tabPredict, "Mean_shift_label" );
+ Mean_shift_label->setText( tr( "Mean shift:" ) );
+
+ Layout9->addWidget( Mean_shift_label, 0, 0 );
+
+ TextLabelPredTime = new QLabel( tabPredict, "TextLabelPredTime" );
+ TextLabelPredTime->setText( tr( "nan" ) );
+
+ Layout9->addWidget( TextLabelPredTime, 2, 1 );
+
+ tabPredictLayout->addLayout( Layout9, 1, 0 );
+
+ Layout11 = new QHBoxLayout;
+ Layout11->setSpacing( 6 );
+ Layout11->setMargin( 0 );
+
+ PushButtonSetPredTime = new QPushButton( tabPredict, "PushButtonSetPredTime" );
+ PushButtonSetPredTime->setText( tr( "Set predicted time" ) );
+ Layout11->addWidget( PushButtonSetPredTime );
+
+ PushButtonPredict = new QPushButton( tabPredict, "PushButtonPredict" );
+ PushButtonPredict->setText( tr( "Predict time" ) );
+ Layout11->addWidget( PushButtonPredict );
+
+ tabPredictLayout->addLayout( Layout11, 2, 0 );
+
+ TabSettings = new QWidget( TabWidgetMain, "TabSettings" );
+ TabSettingsLayout = new QGridLayout( TabSettings );
+ TabSettingsLayout->setSpacing( 2 );
+ TabSettingsLayout->setMargin( 2 );
+
+ FrameSettings = new QFrame( TabSettings, "FrameSettings" );
+ FrameSettings->setFrameShape( QFrame::StyledPanel );
+ FrameSettings->setFrameShadow( QFrame::Raised );
+ FrameSettingsLayout = new QGridLayout( FrameSettings );
+ FrameSettingsLayout->setSpacing( 11 );
+ FrameSettingsLayout->setMargin( 3 );
+
+ Layout6 = new QGridLayout;
+ Layout6->setSpacing( 6 );
+ Layout6->setMargin( 0 );
+
+ TextLabel7_2 = new QLabel( FrameSettings, "TextLabel7_2" );
+ TextLabel7_2->setText( tr( "Use" ) );
+
+ Layout6->addWidget( TextLabel7_2, 0, 0 );
+
+ TextLabel2_2 = new QLabel( FrameSettings, "TextLabel2_2" );
+ TextLabel2_2->setText( tr( "as" ) );
+
+ Layout6->addWidget( TextLabel2_2, 0, 2 );
+
+ TextLabel1_3 = new QLabel( FrameSettings, "TextLabel1_3" );
+ TextLabel1_3->setText( tr( "NTP server to get the time from the network." ) );
+ TextLabel1_3->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) );
+
+ Layout6->addMultiCellWidget( TextLabel1_3, 1, 1, 0, 1 );
+
+ ComboNtpSrv = new QComboBox( FALSE, FrameSettings, "ComboNtpSrv" );
+ ComboNtpSrv->setEditable( TRUE );
+
+ Layout6->addWidget( ComboNtpSrv, 0, 1 );
+
+ FrameSettingsLayout->addLayout( Layout6, 0, 0 );
+ QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ FrameSettingsLayout->addItem( spacer_2, 3, 0 );
+
+ Layout7 = new QGridLayout;
+ Layout7->setSpacing( 6 );
+ Layout7->setMargin( 0 );
+
+ TextLabel1_2 = new QLabel( FrameSettings, "TextLabel1_2" );
+ TextLabel1_2->setText( tr( "Insure a delay of" ) );
+
+ Layout7->addWidget( TextLabel1_2, 0, 0 );
+
+ TextLabel2 = new QLabel( FrameSettings, "TextLabel2" );
+ TextLabel2->setText( tr( "minutes until" ) );
+
+ Layout7->addWidget( TextLabel2, 0, 2 );
+
+ TextLabel3_3 = new QLabel( FrameSettings, "TextLabel3_3" );
+ TextLabel3_3->setText( tr( "a new NTP lookup will be used to predict the time." ) );
+ TextLabel3_3->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) );
+
+ Layout7->addMultiCellWidget( TextLabel3_3, 1, 1, 0, 2 );
+
+ SpinBoxMinLookupDelay = new QSpinBox( FrameSettings, "SpinBoxMinLookupDelay" );
+ SpinBoxMinLookupDelay->setMaxValue( 9999999 );
+ SpinBoxMinLookupDelay->setMinValue( 42 );
+
+ Layout7->addWidget( SpinBoxMinLookupDelay, 0, 1 );
+
+ FrameSettingsLayout->addLayout( Layout7, 2, 0 );
+
+ Layout7_2 = new QGridLayout;
+ Layout7_2->setSpacing( 6 );
+ Layout7_2->setMargin( 0 );
+
+ TextLabel1_2_2 = new QLabel( FrameSettings, "TextLabel1_2_2" );
+ TextLabel1_2_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, TextLabel1_2_2->sizePolicy().hasHeightForWidth() ) );
+ TextLabel1_2_2->setText( tr( "Wait for " ) );
+
+ Layout7_2->addWidget( TextLabel1_2_2, 0, 0 );
+
+ TextLabel2_3 = new QLabel( FrameSettings, "TextLabel2_3" );
+ TextLabel2_3->setText( tr( "minutes until" ) );
+
+ Layout7_2->addWidget( TextLabel2_3, 0, 2 );
+
+ TextLabel3_3_2 = new QLabel( FrameSettings, "TextLabel3_3_2" );
+ TextLabel3_3_2->setText( tr( "NTP tries to syncronises the clock with the network." ) );
+ TextLabel3_3_2->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter | QLabel::AlignLeft ) );
+
+ Layout7_2->addMultiCellWidget( TextLabel3_3_2, 1, 1, 0, 2 );
+
+ SpinBoxNtpDelay = new QSpinBox( FrameSettings, "SpinBoxNtpDelay" );
+ SpinBoxNtpDelay->setMaxValue( 9999999 );
+ SpinBoxNtpDelay->setMinValue( 0 );
+
+ Layout7_2->addWidget( SpinBoxNtpDelay, 0, 1 );
+
+ FrameSettingsLayout->addLayout( Layout7_2, 1, 0 );
+
+ TabSettingsLayout->addWidget( FrameSettings, 0, 0 );
+
+ tabManualSetTime = new QWidget( TabWidgetMain, "tabManualSetTime" );
+ tabManualSetTimeLayout = new QVBoxLayout( tabManualSetTime );
+ tabManualSetTimeLayout->setSpacing( 2 );
+ tabManualSetTimeLayout->setMargin( 2 );
+
+ FrameSetTime = new QFrame( tabManualSetTime, "FrameSetTime" );
+ FrameSetTime->setFrameShape( QFrame::StyledPanel );
+ FrameSetTime->setFrameShadow( QFrame::Raised );
+ tabManualSetTimeLayout->addWidget( FrameSetTime );
+
+ PushButtonSetManualTime = new QPushButton( tabManualSetTime, "PushButtonSetManualTime" );
+ PushButtonSetManualTime->setText( tr( "Set time" ) );
+ tabManualSetTimeLayout->addWidget( PushButtonSetManualTime );
+
+ TabWidgetMain->insertTab( tabMain, tr( "Main" ) );
+
+ TabWidgetMain->insertTab( tabManualSetTime, tr( "Manual" ) );
+
+ TabWidgetMain->insertTab( TabSettings, tr( "Settings" ) );
+
+ TabWidgetMain->insertTab( tabNtp, tr( "NTP" ) );
+ TabWidgetMain->insertTab( tabPredict, tr( "Predict" ) );
+
+ NtpBaseLayout->addWidget( TabWidgetMain, 0, 0 );
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+NtpBase::~NtpBase()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+/*
+ * Main event handler. Reimplemented to handle application
+ * font changes
+ */
+bool NtpBase::event( QEvent* ev )
+{
+ bool ret = QWidget::event( ev );
+ if ( ev->type() == QEvent::ApplicationFontChange ) {
+ QFont MultiLineEditntpOutPut_font( MultiLineEditntpOutPut->font() );
+ MultiLineEditntpOutPut_font.setPointSize( 7 );
+ MultiLineEditntpOutPut->setFont( MultiLineEditntpOutPut_font );
+ QFont TableLookups_font( TableLookups->font() );
+ TableLookups_font.setPointSize( 8 );
+ TableLookups->setFont( TableLookups_font );
+ }
+ return ret;
+}
+
diff --git a/noncore/settings/netsystemtime/ntpbase.h b/noncore/settings/netsystemtime/ntpbase.h
new file mode 100644
index 0000000..b337822
--- a/dev/null
+++ b/noncore/settings/netsystemtime/ntpbase.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+** Form interface generated from reading ui file 'ntpbase.ui'
+**
+** Created: Mon Oct 21 21:05:47 2002
+** by: The User Interface Compiler (uic)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+#ifndef NTPBASE_H
+#define NTPBASE_H
+
+#include <qvariant.h>
+#include <qwidget.h>
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QComboBox;
+class QFrame;
+class QLabel;
+class QMultiLineEdit;
+class QPushButton;
+class QSpinBox;
+class QTabWidget;
+class QTable;
+
+class NtpBase : public QWidget
+{
+ Q_OBJECT
+
+public:
+ NtpBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
+ ~NtpBase();
+
+ QTabWidget* TabWidgetMain;
+ QWidget* tabMain;
+ QFrame* FrameSystemTime;
+ QWidget* tabNtp;
+ QPushButton* runNtp;
+ QFrame* FrameNtp;
+ QLabel* TextLabel1;
+ QLabel* TextLabelStartTime;
+ QLabel* TextLabel3;
+ QLabel* TextLabelTimeShift;
+ QLabel* TextLabel5;
+ QLabel* TextLabelNewTime;
+ QMultiLineEdit* MultiLineEditntpOutPut;
+ QWidget* tabPredict;
+ QTable* TableLookups;
+ QLabel* TextLabelShift;
+ QLabel* TextLabel4;
+ QLabel* TextLabelEstimatedShift;
+ QLabel* TextLabel3_2;
+ QLabel* Mean_shift_label;
+ QLabel* TextLabelPredTime;
+ QPushButton* PushButtonSetPredTime;
+ QPushButton* PushButtonPredict;
+ QWidget* TabSettings;
+ QFrame* FrameSettings;
+ QLabel* TextLabel7_2;
+ QLabel* TextLabel2_2;
+ QLabel* TextLabel1_3;
+ QComboBox* ComboNtpSrv;
+ QLabel* TextLabel1_2;
+ QLabel* TextLabel2;
+ QLabel* TextLabel3_3;
+ QSpinBox* SpinBoxMinLookupDelay;
+ QLabel* TextLabel1_2_2;
+ QLabel* TextLabel2_3;
+ QLabel* TextLabel3_3_2;
+ QSpinBox* SpinBoxNtpDelay;
+ QWidget* tabManualSetTime;
+ QFrame* FrameSetTime;
+ QPushButton* PushButtonSetManualTime;
+
+protected:
+ QGridLayout* NtpBaseLayout;
+ QGridLayout* tabMainLayout;
+ QGridLayout* tabNtpLayout;
+ QGridLayout* FrameNtpLayout;
+ QVBoxLayout* Layout4;
+ QGridLayout* tabPredictLayout;
+ QGridLayout* Layout9;
+ QHBoxLayout* Layout11;
+ QGridLayout* TabSettingsLayout;
+ QGridLayout* FrameSettingsLayout;
+ QGridLayout* Layout6;
+ QGridLayout* Layout7;
+ QGridLayout* Layout7_2;
+ QVBoxLayout* tabManualSetTimeLayout;
+ bool event( QEvent* );
+};
+
+#endif // NTPBASE_H
diff --git a/noncore/settings/netsystemtime/settime.cpp b/noncore/settings/netsystemtime/settime.cpp
index f6e02d5..949fcb3 100644
--- a/noncore/settings/netsystemtime/settime.cpp
+++ b/noncore/settings/netsystemtime/settime.cpp
@@ -1,502 +1,502 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "settime.h"
#include <qpe/alarmserver.h>
#include <qpe/qpeapplication.h>
#include <qpe/config.h>
#include <qpe/datebookdb.h>
#include <qpe/datebookmonth.h>
#include <qpe/global.h>
#include <qpe/resource.h>
#include <qpe/timeconversion.h>
#include <qpe/tzselect.h>
#include <qpe/timestring.h>
#include <qpe/qpedialog.h>
#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
#include <qpe/qcopenvelope_qws.h>
#endif
#include <qbuttongroup.h>
#include <qcheckbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qradiobutton.h>
#include <qspinbox.h>
#include <qtoolbutton.h>
#include <qwindowsystem_qws.h>
#include <qcombobox.h>
#include <sys/time.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f )
: NtpBase( parent, name, f )
{
// setCaption( tr("Set System Time") );
// QVBoxLayout *vb = new QVBoxLayout( this, 5 );
QVBoxLayout *vb = new QVBoxLayout( FrameSystemTime, 5 );
QVBoxLayout *vb2 = new QVBoxLayout( FrameSetTime, 5 );
-# TextLabelMainPredTime = new QLabel( FrameSystemTime );
-# vb->addWidget( TextLabelMainPredTime, 1, 0 );
+ TextLabelMainPredTime = new QLabel( FrameSystemTime );
+ vb->addWidget( TextLabelMainPredTime, 1, 0 );
QHBoxLayout *hb = new QHBoxLayout( vb, -1, "timezone layout" );
QLabel *lblZone = new QLabel( tr( "Time Zone" ), FrameSystemTime, "timezone label" );
lblZone->setMaximumSize( lblZone->sizeHint() );
hb->addWidget( lblZone );
tz = new TimeZoneSelector( FrameSystemTime, "Timezone choices" );
tz->setMinimumSize( tz->sizeHint() );
hb->addWidget( tz );
timeButton = new SetTime( FrameSetTime );
vb2->addWidget( timeButton );
QHBoxLayout *db = new QHBoxLayout( vb2 );
QLabel *dateLabel = new QLabel( tr("Date"), FrameSetTime );
db->addWidget( dateLabel, 1 );
dateButton = new DateButton( TRUE, FrameSetTime );
db->addWidget( dateButton, 2 );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
vb2->addItem( spacer );
- hline = new QFrame( FrameSystemTime );
+ QFrame *hline = new QFrame( FrameSystemTime );
hline->setFrameStyle( QFrame::HLine | QFrame::Sunken );
vb->addWidget( hline );
Config config("qpe");
config.setGroup( "Time" );
QHBoxLayout *hb1 = new QHBoxLayout( vb );
QLabel *l = new QLabel( tr("Time format"), FrameSystemTime );
hb1->addWidget( l, 1 );
ampmCombo = new QComboBox( FrameSystemTime );
ampmCombo->insertItem( tr("24 hour"), 0 );
ampmCombo->insertItem( tr("12 hour"), 1 );
hb1->addWidget( ampmCombo, 2 );
int show12hr = config.readBoolEntry("AMPM") ? 1 : 0;
ampmCombo->setCurrentItem( show12hr );
timeButton->show12hourTime( show12hr );
connect(ampmCombo, SIGNAL(activated(int)),
timeButton, SLOT(show12hourTime(int)));
QHBoxLayout *hb2 = new QHBoxLayout( vb );
l = new QLabel( tr("Weeks start on" ), FrameSystemTime );
//l->setAlignment( AlignRight | AlignVCenter );
hb2->addWidget( l, 1 );
weekStartCombo = new QComboBox( FrameSystemTime );
weekStartCombo->insertItem( tr("Sunday"), 0 );
weekStartCombo->insertItem( tr("Monday"), 1 );
hb2->addWidget( weekStartCombo, 2 );
int startMonday = config.readBoolEntry("MONDAY") ? 1 : 0;
dateButton->setWeekStartsMonday( startMonday );
weekStartCombo->setCurrentItem( startMonday );
connect( weekStartCombo, SIGNAL( activated(int)),
dateButton, SLOT(setWeekStartsMonday(int)));
QHBoxLayout *hb3 = new QHBoxLayout( vb );
l = new QLabel( tr("Date format" ), FrameSystemTime );
hb3->addWidget( l, 1 );
dateFormatCombo = new QComboBox( FrameSystemTime );
hb3->addWidget( dateFormatCombo, 2 );
config.setGroup( "Date" );
DateFormat df(QChar(config.readEntry("Separator", "/")[0]),
(DateFormat::Order)config .readNumEntry("ShortOrder", DateFormat::DayMonthYear),
(DateFormat::Order)config.readNumEntry("LongOrder", DateFormat::DayMonthYear));
int currentdf = 0;
date_formats[0] = DateFormat('/', DateFormat::MonthDayYear);
dateFormatCombo->insertItem( tr( date_formats[0].toNumberString()) );
date_formats[1] = DateFormat('.', DateFormat::DayMonthYear);
if (df == date_formats[1])
currentdf = 1;
dateFormatCombo->insertItem( tr( date_formats[1].toNumberString() ) );
date_formats[2] = DateFormat('-', DateFormat::YearMonthDay,
DateFormat::DayMonthYear);
if (df == date_formats[2])
currentdf = 2;
dateFormatCombo->insertItem( tr( date_formats[2].toNumberString() ) ); //ISO8601
date_formats[3] = DateFormat('/', DateFormat::DayMonthYear);
if (df == date_formats[3])
currentdf = 3;
dateFormatCombo->insertItem( tr( date_formats[3].toNumberString() ) );
dateFormatCombo->setCurrentItem( currentdf );
dateButton->setDateFormat( df );
connect( dateFormatCombo, SIGNAL( activated(int)),
SLOT(formatChanged(int)));
QHBoxLayout *hb4 = new QHBoxLayout( vb );
l = new QLabel( tr("Applet format" ), FrameSystemTime );
hb4->addWidget( l, 1 );
clockAppletCombo = new QComboBox( FrameSystemTime );
clockAppletCombo->insertItem( tr("hh:mm"), 0 );
clockAppletCombo->insertItem( tr("D/M hh:mm"), 1 );
clockAppletCombo->insertItem( tr("M/D hh:mm"), 2 );
hb4->addWidget( clockAppletCombo, 2 );
int clockApplet = config.readNumEntry("ClockApplet",0);
clockAppletCombo->setCurrentItem( clockApplet );
vb->addStretch( 0 );
- QFrame *hline = new QFrame( FrameSystemTime );
+ hline = new QFrame( FrameSystemTime );
hline->setFrameStyle( QFrame::HLine | QFrame::Sunken );
vb->addWidget( hline );
ButtonSetTime = new QPushButton( FrameSystemTime );
vb->addWidget( ButtonSetTime, 1, 0 );
QObject::connect( PushButtonSetManualTime, SIGNAL(clicked()),
this, SLOT(commitTime()));
QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ),
timeButton, SLOT( slotTzChange( const QString& ) ) );
QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ),
SLOT( tzChange( const QString& ) ) );
QObject::connect( weekStartCombo, SIGNAL( activated ( int )),
SLOT(updateSystem(int ) ));
QObject::connect( ampmCombo, SIGNAL( activated ( int )),
SLOT(updateSystem(int ) ));
QObject::connect( dateFormatCombo, SIGNAL( activated ( int )),
SLOT(updateSystem(int ) ));
QObject::connect( clockAppletCombo, SIGNAL( activated ( int )),
SLOT(updateSystem(int ) ));
}
SetDateTime::~SetDateTime()
{
writeSettings();
}
void SetDateTime::writeSettings()
{
Config config("qpe");
config.setGroup( "Time" );
config.writeEntry( "AMPM", ampmCombo->currentItem() );
config.writeEntry( "MONDAY", weekStartCombo->currentItem() );
config.setGroup( "Date" );
DateFormat df = date_formats[dateFormatCombo->currentItem()];
config.writeEntry( "Separator", QString(df.separator()));
config.writeEntry( "ShortOrder", df.shortOrder());
config.writeEntry( "LongOrder", df.longOrder());
config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() );
Config lconfig("locale");
lconfig.setGroup( "Location" );
lconfig.writeEntry( "Timezone", tz->currentZone() );
}
void SetDateTime::commitTime()
{
Config cfg("ntp",Config::User);
cfg.setGroup("lookups");
cfg.writeEntry("lastNtp",false);
tz->setFocus();
// Need to process the QCOP event generated above before proceeding
qApp->processEvents();
// before we progress further, set our TZ!
setenv( "TZ", tz->currentZone(), 1 );
// now set the time...
QDateTime dt( dateButton->date(), timeButton->time() );
if ( dt.isValid() ) setTime(dt);
}
void SetDateTime::setTime(QDateTime dt)
{
// really turn off the screensaver before doing anything
{
// Needs to be encased in { } so that it deconstructs and sends
QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
disableScreenSaver << 0 << 0 << 0;
}
Config cfg("ntp",Config::User);
cfg.setGroup("correction");
int t = TimeConversion::toUTC(dt);
struct timeval myTv;
myTv.tv_sec = t;
cfg.writeEntry("time", t );
myTv.tv_usec = 0;
if ( myTv.tv_sec != -1 )
::settimeofday( &myTv, 0 );
Global::writeHWClock();
// since time has changed quickly load in the datebookdb
// to allow the alarm server to get a better grip on itself
// (example re-trigger alarms for when we travel back in time)
DateBookDB db;
//QCopEnvelope timeApplet( "QPE/TaskBar", "reloadApplets()" );
//timeApplet << "";
// Restore screensaver
QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
enableScreenSaver << -1 << -1 << -1;
}
void SetDateTime::updateSystem(int i)
{
// really turn off the screensaver before doing anything
{
// Needs to be encased in { } so that it deconstructs and sends
QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
disableScreenSaver << 0 << 0 << 0;
}
qDebug("SetDateTime::updateSystem(int %i)",i);
writeSettings();
// set the timezone for everyone else...
QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" );
setTimeZone << tz->currentZone();
// AM/PM setting and notify time changed
QCopEnvelope setClock( "QPE/System", "clockChange(bool)" );
setClock << ampmCombo->currentItem();
// Notify everyone what day we prefer to start the week on.
QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" );
setWeek << weekStartCombo->currentItem();
// Notify everyone what date format to use
QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" );
setDateFormat << date_formats[dateFormatCombo->currentItem()];
// Restore screensaver
QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
enableScreenSaver << -1 << -1 << -1;
// since time has changed quickly load in the datebookdb
// to allow the alarm server to get a better grip on itself
// (example re-trigger alarms for when we travel back in time)
DateBookDB db;
}
void SetDateTime::tzChange( const QString &tz )
{
// set the TZ get the time and leave gracefully...
QString strSave;
strSave = getenv( "TZ" );
setenv( "TZ", tz, 1 );
QDate d = QDate::currentDate();
// reset the time.
if ( !strSave.isNull() ) {
setenv( "TZ", strSave, 1 );
}
dateButton->setDate( d );
updateSystem();
}
void SetDateTime::formatChanged(int i)
{
dateButton->setDateFormat(date_formats[i]);
}
static const int ValueAM = 0;
static const int ValuePM = 1;
SetTime::SetTime( QWidget *parent, const char *name )
: QWidget( parent, name )
{
use12hourTime = FALSE;
QTime currTime = QTime::currentTime();
hour = currTime.hour();
minute = currTime.minute();
QHBoxLayout *hb2 = new QHBoxLayout( this );
hb2->setSpacing( 3 );
QLabel *l = new QLabel( tr("Hour"), this );
// l->setAlignment( AlignRight | AlignVCenter );
hb2->addWidget( l );
sbHour = new QSpinBox( this );
sbHour->setMinimumWidth( 30 );
if(use12hourTime) {
sbHour->setMinValue(1);
sbHour->setMaxValue( 12 );
int show_hour = hour;
if (hour > 12)
show_hour -= 12;
if (show_hour == 0)
show_hour = 12;
sbHour->setValue( show_hour );
} else {
sbHour->setMinValue( 0 );
sbHour->setMaxValue( 23 );
sbHour->setValue( hour );
}
sbHour->setWrapping(TRUE);
connect( sbHour, SIGNAL(valueChanged(int)), this, SLOT(hourChanged(int)) );
hb2->addWidget( sbHour );
hb2->addStretch( 1 );
l = new QLabel( tr("Minute"), this );
//l->setAlignment( AlignRight | AlignVCenter );
hb2->addWidget( l );
sbMin = new QSpinBox( this );
sbMin->setMinValue( 0 );
sbMin->setMaxValue( 59 );
sbMin->setWrapping(TRUE);
sbMin->setValue( minute );
sbMin->setMinimumWidth( 30 );
connect( sbMin, SIGNAL(valueChanged(int)), this, SLOT(minuteChanged(int)) );
hb2->addWidget( sbMin );
hb2->addStretch( 1 );
ampm = new QComboBox( this );
ampm->insertItem( tr("AM"), ValueAM );
ampm->insertItem( tr("PM"), ValuePM );
connect( ampm, SIGNAL(activated(int)), this, SLOT(checkedPM(int)) );
hb2->addWidget( ampm );
hb2->addStretch( 1 );
}
QTime SetTime::time() const
{
return QTime( hour, minute, 0 );
}
void SetTime::hourChanged( int value )
{
if(use12hourTime) {
int realhour = value;
if (realhour == 12)
realhour = 0;
if (ampm->currentItem() == ValuePM )
realhour += 12;
hour = realhour;
} else
hour = value;
}
void SetTime::minuteChanged( int value )
{
minute = value;
}
void SetTime::show12hourTime( int on )
{
use12hourTime = on;
ampm->setEnabled(on);
int show_hour = hour;
if ( on ) {
/* this might change the value of hour */
sbHour->setMinValue(1);
sbHour->setMaxValue( 12 );
/* so use one we saved earlier */
if (show_hour >= 12) {
show_hour -= 12;
ampm->setCurrentItem( ValuePM );
} else {
ampm->setCurrentItem( ValueAM );
}
if (show_hour == 0)
show_hour = 12;
} else {
sbHour->setMinValue( 0 );
sbHour->setMaxValue( 23 );
}
sbHour->setValue( show_hour );
}
void SetTime::checkedPM( int c )
{
int show_hour = sbHour->value();
if (show_hour == 12)
show_hour = 0;
if ( c == ValuePM )
show_hour += 12;
hour = show_hour;
}
void SetTime::slotTzChange( const QString &tz )
{
// set the TZ get the time and leave gracefully...
QString strSave;
strSave = getenv( "TZ" );
setenv( "TZ", tz, 1 );
QTime t = QTime::currentTime();
// reset the time.
if ( !strSave.isNull() ) {
setenv( "TZ", strSave, 1 );
}
// just set the spinboxes and let it propage through
if(use12hourTime) {
int show_hour = t.hour();
if (t.hour() >= 12) {
show_hour -= 12;
ampm->setCurrentItem( ValuePM );
} else {
ampm->setCurrentItem( ValueAM );
}
if (show_hour == 0)
show_hour = 12;
sbHour->setValue( show_hour );
} else {
sbHour->setValue( t.hour() );
}
sbMin->setValue( t.minute() );
}