Re: [PATCH] Improve timezone & date/time settings
Paul Eggleton <[email protected]> Fri, 5 Jan 2007 18:54:08 +1300
| Newsgroups | gmane.comp.handhelds.opie.devel |
|---|---|
| Message-ID | <[email protected]> |
On Thursday 04 January 2007 20:41, Paul Eggleton wrote: > The attached patches do several things: Re-based patches are attached. 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_launcher2.patch
(text/x-diff, 1.8 KB)
Index: core/launcher/main.cpp
===================================================================
RCS file: /cvs/opie/core/launcher/main.cpp,v
retrieving revision 1.45
diff -u -B -b -r1.45 main.cpp
--- core/launcher/main.cpp 26 Jun 2005 12:34:25 -0000 1.45
+++ core/launcher/main.cpp 5 Jan 2007 05:49:48 -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_systemtime2.patch
(text/x-diff, 4.4 KB)
Index: noncore/settings/netsystemtime/settingstabwidget.cpp
===================================================================
RCS file: /cvs/opie/noncore/settings/netsystemtime/settingstabwidget.cpp,v
retrieving revision 1.5
diff -u -B -b -r1.5 settingstabwidget.cpp
--- noncore/settings/netsystemtime/settingstabwidget.cpp 15 Jun 2005 18:52:47 -0000 1.5
+++ noncore/settings/netsystemtime/settingstabwidget.cpp 5 Jan 2007 05:51:52 -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: noncore/settings/netsystemtime/settingstabwidget.h
===================================================================
RCS file: /cvs/opie/noncore/settings/netsystemtime/settingstabwidget.h,v
retrieving revision 1.2
diff -u -B -b -r1.2 settingstabwidget.h
--- noncore/settings/netsystemtime/settingstabwidget.h 15 Jun 2005 18:52:47 -0000 1.2
+++ noncore/settings/netsystemtime/settingstabwidget.h 5 Jan 2007 05:51:52 -0000
@@ -52,6 +52,7 @@
QComboBox *cbTimeServer;
QSpinBox *sbNtpDelay;
QSpinBox *sbPredictDelay;
+ QCheckBox *chShowOnRestart;
QCheckBox *chNtpTab;
QCheckBox *chPredictTab;
Index: noncore/settings/netsystemtime/timetabwidget.cpp
===================================================================
RCS file: /cvs/opie/noncore/settings/netsystemtime/timetabwidget.cpp,v
retrieving revision 1.5
diff -u -B -b -r1.5 timetabwidget.cpp
--- noncore/settings/netsystemtime/timetabwidget.cpp 15 Jun 2005 18:52:47 -0000 1.5
+++ noncore/settings/netsystemtime/timetabwidget.cpp 5 Jan 2007 05:51:52 -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 );
+ }
}