author | tille <tille> | 2002-11-16 16:43:02 (UTC) |
---|---|---|
committer | tille <tille> | 2002-11-16 16:43:02 (UTC) |
commit | 0633fb26123857509c9eb0e0a013b654667ca9ce (patch) (side-by-side diff) | |
tree | 9187213cc22830c65dcba1923be9a8355c673b5a | |
parent | 88435a3192f09453e035a7f1cf73bbc8c24245c9 (diff) | |
download | opie-0633fb26123857509c9eb0e0a013b654667ca9ce.zip opie-0633fb26123857509c9eb0e0a013b654667ca9ce.tar.gz opie-0633fb26123857509c9eb0e0a013b654667ca9ce.tar.bz2 |
usability:
made it a dialog that saves when exiting
clock now running
-rw-r--r-- | noncore/settings/netsystemtime/TODO | 3 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/main.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/ntp.cpp | 56 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/ntp.h | 2 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/ntpbase.cpp | 12 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/ntpbase.h | 9 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/ntpbase.ui | 2 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/settime.cpp | 122 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/settime.h | 8 |
9 files changed, 134 insertions, 82 deletions
diff --git a/noncore/settings/netsystemtime/TODO b/noncore/settings/netsystemtime/TODO new file mode 100644 index 0000000..fb003a2 --- a/dev/null +++ b/noncore/settings/netsystemtime/TODO @@ -0,0 +1,3 @@ +- handle hour > 24 in SetTime::slotClockTick +- improve tz setting + atm the tz gets written to the system as soon as changed... diff --git a/noncore/settings/netsystemtime/main.cpp b/noncore/settings/netsystemtime/main.cpp index c6d5f9a..80fbcb8 100644 --- a/noncore/settings/netsystemtime/main.cpp +++ b/noncore/settings/netsystemtime/main.cpp @@ -6,3 +6,3 @@ int main( int argc, char ** argv ) { - printf("This is netsystemtime\n"); + printf("This is netsystemtime "); printf("$Id$\n"); diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp index c7e3b52..53dbe46 100644 --- a/noncore/settings/netsystemtime/ntp.cpp +++ b/noncore/settings/netsystemtime/ntp.cpp @@ -50,3 +50,3 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) //make tab order - + TabWidgetMain->removePage( tabMain ); @@ -58,3 +58,2 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) TabWidgetMain->insertTab( tabMain, tr( "Main" ) ); - TabWidgetMain->insertTab( tabManualSetTime, tr( "Manual" ) ); TabWidgetMain->insertTab( TabSettings, tr( "Settings" ) ); @@ -98,2 +97,5 @@ Ntp::~Ntp() delete ntpProcess; +} + +void Ntp::saveConfig(){ int srvCount = ComboNtpSrv->count(); @@ -201,16 +203,6 @@ void Ntp::ntpFinished(OProcess *p) QMessageBox::critical(this, tr("ntp error"),tr("Error while getting time form\n server")+getNtpServer()+"\n"+_ntpOutput ); - TabWidgetMain->showPage( tabManualSetTime ); } - +// slotCheckNtp(-1); return; } - - 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 << ""; @@ -308,3 +300,3 @@ void Ntp::preditctTime() TextLabelPredTime->setText(predictedTime.toString()); - TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>"); +// TextLabelMainPredTime->setText(tr("Predicted time:")+"<br><b>"+predictedTime.toString()+"</b>"); } @@ -313,4 +305,5 @@ void Ntp::setPredictTime() { + qDebug("Ntp::setPredictTime"); preditctTime(); - setTime( predictedTime ); + timeButton->setTime( predictedTime ); } @@ -319,5 +312,6 @@ void Ntp::slotCheckNtp(int i) { + qDebug(" Ntp::slotCheckNtp(%i)",i); if (i == 0) { - TextLabelMainPredTime->hide(); +// TextLabelMainPredTime->hide(); ButtonSetTime->setText( tr("Get time from network") ); @@ -325,11 +319,11 @@ void Ntp::slotCheckNtp(int i) if ( ntpDelayElapsed() ) - { - slotRunNtp(); - disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) ); - connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotTimerRunNtp()) ); - }else{ - disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotTimerRunNtp()) ); - connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); - } - }else{ + { + slotRunNtp(); + disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) ); + connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotTimerRunNtp()) ); + }else{ + disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotTimerRunNtp()) ); + connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); + } + }else{ preditctTime(); @@ -420 +414,13 @@ void Ntp::showAdvancedFeatures(bool advMode) } + + +void Ntp::accept( ){ + qDebug("accepted"); + //SetTimeDate + commitTime(); + writeSettings(); + updateSystem(); + // Ntp + saveConfig(); + qApp->quit(); +}
\ No newline at end of file diff --git a/noncore/settings/netsystemtime/ntp.h b/noncore/settings/netsystemtime/ntp.h index 15cddbd..a4573f8 100644 --- a/noncore/settings/netsystemtime/ntp.h +++ b/noncore/settings/netsystemtime/ntp.h @@ -22,2 +22,3 @@ public slots: protected: + virtual void accept( ); QDateTime predictedTime; @@ -40,2 +41,3 @@ private: QString getNtpServer(); + void saveConfig(); private slots: diff --git a/noncore/settings/netsystemtime/ntpbase.cpp b/noncore/settings/netsystemtime/ntpbase.cpp index 0a7a57e..878c158 100644 --- a/noncore/settings/netsystemtime/ntpbase.cpp +++ b/noncore/settings/netsystemtime/ntpbase.cpp @@ -3,3 +3,3 @@ ** -** Created: Sun Nov 10 17:59:14 2002 +** Created: Sat Nov 16 15:49:54 2002 ** by: The User Interface Compiler (uic) @@ -19,2 +19,3 @@ #include <qtabwidget.h> +#include <qwidget.h> #include <qlayout.h> @@ -27,5 +28,8 @@ * name 'name' and widget flags set to 'f' + * + * The dialog will by default be modeless, unless you set 'modal' to + * TRUE to construct a modal dialog. */ -NtpBase::NtpBase( QWidget* parent, const char* name, WFlags fl ) - : QWidget( parent, name, fl ) +NtpBase::NtpBase( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, fl ) { @@ -319,3 +323,3 @@ bool NtpBase::event( QEvent* ev ) { - bool ret = QWidget::event( ev ); + bool ret = QDialog::event( ev ); if ( ev->type() == QEvent::ApplicationFontChange ) { diff --git a/noncore/settings/netsystemtime/ntpbase.h b/noncore/settings/netsystemtime/ntpbase.h index 543cac1..68599c9 100644 --- a/noncore/settings/netsystemtime/ntpbase.h +++ b/noncore/settings/netsystemtime/ntpbase.h @@ -3,3 +3,3 @@ ** -** Created: Sun Nov 10 17:58:48 2002 +** Created: Sat Nov 16 15:49:32 2002 ** by: The User Interface Compiler (uic) @@ -12,3 +12,3 @@ #include <qvariant.h> -#include <qwidget.h> +#include <qdialog.h> class QVBoxLayout; @@ -25,4 +25,5 @@ class QTabWidget; class QTable; +class QWidget; -class NtpBase : public QWidget +class NtpBase : public QDialog { @@ -31,3 +32,3 @@ class NtpBase : public QWidget public: - NtpBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + NtpBase( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); ~NtpBase(); diff --git a/noncore/settings/netsystemtime/ntpbase.ui b/noncore/settings/netsystemtime/ntpbase.ui index 6c38588..8c106be 100644 --- a/noncore/settings/netsystemtime/ntpbase.ui +++ b/noncore/settings/netsystemtime/ntpbase.ui @@ -3,3 +3,3 @@ <widget> - <class>QWidget</class> + <class>QDialog</class> <property stdset="1"> diff --git a/noncore/settings/netsystemtime/settime.cpp b/noncore/settings/netsystemtime/settime.cpp index 949fcb3..36166ae 100644 --- a/noncore/settings/netsystemtime/settime.cpp +++ b/noncore/settings/netsystemtime/settime.cpp @@ -37,2 +37,3 @@ +#include <qtimer.h> #include <qbuttongroup.h> @@ -54,15 +55,29 @@ SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) - : NtpBase( parent, name, f ) + : NtpBase( parent, name, true, f ) { - // setCaption( tr("Set System Time") ); + setCaption( tr("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" ); + timeButton = new SetTime( FrameSystemTime ); + vb->addWidget( timeButton ); + + QHBoxLayout *db = new QHBoxLayout( vb ); + QLabel *dateLabel = new QLabel( tr("Date"), FrameSystemTime ); + db->addWidget( dateLabel, 1 ); + dateButton = new DateButton( TRUE, FrameSystemTime ); + db->addWidget( dateButton, 2 ); + ButtonSetTime = new QPushButton( FrameSystemTime ); + vb->addWidget( ButtonSetTime, 1, 0 ); + + QFrame *hline = new QFrame( FrameSystemTime ); + hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); + vb->addWidget( hline ); + + QHBoxLayout *hb = new QHBoxLayout( vb, -1, "timezone layout" ); + QLabel *lblZone = new QLabel( tr( "Time Zone" ), FrameSystemTime, "timezone label" ); @@ -73,19 +88,10 @@ SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) 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 ); + hb->addWidget( tz ); - QFrame *hline = new QFrame( FrameSystemTime ); + hline = new QFrame( FrameSystemTime ); hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); vb->addWidget( hline ); + + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); + vb->addItem( spacer ); @@ -181,11 +187,9 @@ SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) - hline = new QFrame( FrameSystemTime ); - hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); - vb->addWidget( hline ); +// hline = new QFrame( FrameSystemTime ); +// hline->setFrameStyle( QFrame::HLine | QFrame::Sunken ); +// vb->addWidget( hline ); +// +// ButtonSetTime = new QPushButton( FrameSystemTime ); +// vb->addWidget( ButtonSetTime, 1, 0 ); - ButtonSetTime = new QPushButton( FrameSystemTime ); - vb->addWidget( ButtonSetTime, 1, 0 ); - - QObject::connect( PushButtonSetManualTime, SIGNAL(clicked()), - this, SLOT(commitTime())); @@ -196,10 +200,10 @@ SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) - 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 ) )); +// 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 ) )); } @@ -208,4 +212,2 @@ SetDateTime::~SetDateTime() { - writeSettings(); - } @@ -278,3 +280,3 @@ void SetDateTime::setTime(QDateTime dt) -void SetDateTime::updateSystem(int i) +void SetDateTime::updateSystem() { @@ -286,3 +288,3 @@ void SetDateTime::updateSystem(int i) } - qDebug("SetDateTime::updateSystem(int %i)",i); + qDebug("SetDateTime::updateSystem()"); writeSettings(); @@ -325,3 +327,3 @@ void SetDateTime::tzChange( const QString &tz ) if ( !strSave.isNull() ) { - setenv( "TZ", strSave, 1 ); + setenv( "TZ", strSave, 1 ); } @@ -344,7 +346,11 @@ SetTime::SetTime( QWidget *parent, const char *name ) { + clock = new QTimer(this, "clock" ); + connect(clock, SIGNAL( timeout() ), SLOT(slotClockTick()) ); + clock->start( 1000 * 60 ); + use12hourTime = FALSE; - QTime currTime = QTime::currentTime(); - hour = currTime.hour(); - minute = currTime.minute(); + _time = QDateTime::currentDateTime(); + hour = _time.time().hour(); + minute = _time.time().minute(); @@ -501,2 +507,28 @@ void SetTime::slotTzChange( const QString &tz ) +void SetTime::setTime( QDateTime dt ) +{ + _time = dt; + QTime t = dt.time(); + // 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() ); +} +void SetTime::slotClockTick() +{ + setTime( _time.addSecs(60) ); + qDebug("SetTime::slotClockTick %s",_time.toString().latin1()); +} diff --git a/noncore/settings/netsystemtime/settime.h b/noncore/settings/netsystemtime/settime.h index 778cb9c..3c3a162 100644 --- a/noncore/settings/netsystemtime/settime.h +++ b/noncore/settings/netsystemtime/settime.h @@ -43,2 +43,3 @@ public: QTime time() const; + void setTime( QDateTime ); @@ -49,2 +50,3 @@ public slots: protected slots: + void slotClockTick(); void hourChanged( int value ); @@ -58,2 +60,4 @@ protected: bool use12hourTime; + QDateTime _time; + QTimer *clock; QComboBox *ampm; @@ -76,3 +80,3 @@ protected slots: void formatChanged(int); - void updateSystem(int i=0); + void updateSystem(); @@ -90,3 +94,3 @@ protected: QPushButton *ButtonSetTime; - QLabel *TextLabelMainPredTime; + // QLabel *TextLabelMainPredTime; |