[PATCH] Improve timezone & date/time settings
Paul Eggleton <[email protected]> Thu, 4 Jan 2007 20:41:56 +1300
| Newsgroups | gmane.comp.handhelds.opie.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi there, The attached patches do several things: 1) Add an option to always show the date/time settings on restart. This helps on devices where the time slips or gets reset on reboot. This option is ignored if the first time wizard has been shown. 2) Reinstate the check on the system year on startup that was silently disabled in a previous commit (why was that?) and update the year to 2007. 3) Do a simple check when selecting a time zone in the date/time settings to see if the appropriate time zone file exists in /usr/share/zoneinfo. If it does not exist, a warning message is shown telling the user they need to install it. Cheers, Paul _______________________________________________ http://opie.handhelds.org/cgi-bin/moin.cgi/DeveloperWikiIndex Opie-devel mailing list [email protected] https://handhelds.org/mailman/listinfo/opie-devel
timerestart_launcher.patch
(text/x-diff, 1.7 KB)
Index: main.cpp
===================================================================
RCS file: /cvs/opie/core/launcher/main.cpp,v
retrieving revision 1.45
diff -u -d -b -B -r1.45 main.cpp
--- main.cpp 26 Jun 2005 12:34:25 -0000 1.45
+++ main.cpp 4 Jan 2007 07:29:51 -0000
@@ -152,7 +152,8 @@
ServerApplication a( argc, argv, QApplication::GuiServer );
initKeyboard();
- if ( firstUse() )
+ bool firstUseShown = firstUse();
+ if ( firstUseShown )
{
a.restart();
return 0;
@@ -171,18 +172,28 @@
#endif
s->show();
-#if 0
- if ( QDate::currentDate().year() < 2005 )
+ if ( !firstUseShown ) {
+ Config config( "qpe" );
+ config.setGroup( "Startup" );
+ bool showTimeSettings = config.readBoolEntry( "ShowTimeSettings", FALSE );
+
+ if ( !showTimeSettings && QDate::currentDate().year() < 2007 )
{
if ( QMessageBox::information ( 0, ServerApplication::tr( "Information" ),
ServerApplication::tr( "<p>The system date doesn't seem to be valid.\n(%1)</p><p>Do you want to correct the clock ?</p>" )
- .arg( TimeString::dateString( QDate::currentDate())), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
+ .arg( TimeString::dateString( QDate::currentDate())),
+ QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes )
+ {
+ showTimeSettings = TRUE;
+ }
+ }
+
+ if ( showTimeSettings )
{
QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" );
e << QString ( );
}
}
-#endif
create_pidfile();
odebug << "--> mainloop in" << oendl;
timerestart_systemtime.patch
(text/x-diff, 4.1 KB)
Index: settingstabwidget.cpp
===================================================================
RCS file: /cvs/opie/noncore/settings/netsystemtime/settingstabwidget.cpp,v
retrieving revision 1.5
diff -u -d -b -B -r1.5 settingstabwidget.cpp
--- settingstabwidget.cpp 15 Jun 2005 18:52:47 -0000 1.5
+++ settingstabwidget.cpp 4 Jan 2007 07:31:34 -0000
@@ -78,18 +78,22 @@
// Space filler
layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 4, 0 );
+ // Show system time options on every restart
+ chShowOnRestart = new QCheckBox( tr( "Show time settings on every restart" ), container );
+ layout->addMultiCellWidget( chShowOnRestart, 5, 5, 0, 1 );
+
// Display time server information selector
chNtpTab = new QCheckBox( tr( "Display time server information" ), container );
connect( chNtpTab, SIGNAL( toggled(bool) ), this, SIGNAL( displayNTPTab(bool) ) );
- layout->addMultiCellWidget( chNtpTab, 5, 5, 0, 1 );
+ layout->addMultiCellWidget( chNtpTab, 6, 6, 0, 1 );
// Display time prediction information selector
chPredictTab = new QCheckBox( tr( "Display time prediction information" ), container );
connect( chPredictTab, SIGNAL( toggled(bool) ), this, SIGNAL( displayPredictTab(bool) ) );
- layout->addMultiCellWidget( chPredictTab, 6, 6, 0, 1 );
+ layout->addMultiCellWidget( chPredictTab, 7, 7, 0, 1 );
// Space filler
- layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 7, 0 );
+ layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 8, 0 );
// Initialize values
QString ntpSrvsFile = QPEApplication::qpeDir();
@@ -114,6 +118,10 @@
cbTimeServer->setCurrentItem( config.readNumEntry( "ntpServer", 0 ) );
chNtpTab->setChecked( config.readBoolEntry( "displayNtpTab", FALSE ) );
chPredictTab->setChecked( config.readBoolEntry( "displayPredictTab", FALSE ) );
+
+ Config config_qpe( "qpe" );
+ config_qpe.setGroup( "Startup" );
+ chPredictTab->setChecked( config_qpe.readBoolEntry( "ShowTimeSettings", FALSE ) );
}
SettingsTabWidget::~SettingsTabWidget()
@@ -155,6 +163,10 @@
config.writeEntry( "ntpRefreshFreq", sbNtpDelay->value() );
config.writeEntry( "displayNtpTab", chNtpTab->isChecked() );
config.writeEntry( "displayPredictTab", chPredictTab->isChecked() );
+
+ Config config_qpe( "qpe" );
+ config_qpe.setGroup( "Startup" );
+ config_qpe.writeEntry( "ShowTimeSettings", chShowOnRestart->isChecked() );
}
QString SettingsTabWidget::ntpServer()
Index: settingstabwidget.h
===================================================================
RCS file: /cvs/opie/noncore/settings/netsystemtime/settingstabwidget.h,v
retrieving revision 1.2
diff -u -d -b -B -r1.2 settingstabwidget.h
--- settingstabwidget.h 15 Jun 2005 18:52:47 -0000 1.2
+++ settingstabwidget.h 4 Jan 2007 07:31:34 -0000
@@ -52,6 +52,7 @@
QComboBox *cbTimeServer;
QSpinBox *sbNtpDelay;
QSpinBox *sbPredictDelay;
+ QCheckBox *chShowOnRestart;
QCheckBox *chNtpTab;
QCheckBox *chPredictTab;
Index: timetabwidget.cpp
===================================================================
RCS file: /cvs/opie/noncore/settings/netsystemtime/timetabwidget.cpp,v
retrieving revision 1.5
diff -u -d -b -B -r1.5 timetabwidget.cpp
--- timetabwidget.cpp 15 Jun 2005 18:52:47 -0000 1.5
+++ timetabwidget.cpp 4 Jan 2007 07:31:35 -0000
@@ -50,6 +50,8 @@
#include <qpushbutton.h>
#include <qscrollview.h>
#include <qspinbox.h>
+#include <qmessagebox.h>
+#include <qfile.h>
#include <stdlib.h>
#include <sys/time.h>
@@ -277,6 +279,12 @@
void TimeTabWidget::slotTZChanged( const QString &newtz )
{
+ // Check timezone has a valid file in /usr/share/zoneinfo
+ if(!QFile::exists("/usr/share/zoneinfo/" + newtz)) {
+ QMessageBox::warning(this, tr("Time zone file missing"),
+ (tr("There is no time zone file for the\nselected time zone (%1).\nYou will need to install it before the\nsystem time zone can be set correctly.")).arg(newtz));
+ }
+ else {
// If controls have a valid date & time, update systemtime
int hour = sbHour->value();
if ( use12HourTime && cbAmpm->currentItem() == ValuePM )
@@ -306,4 +314,5 @@
setDateTime( dt );
emit tzChanged( newtz );
+ }
}