summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/timetabwidget.cpp61
1 files changed, 35 insertions, 26 deletions
diff --git a/noncore/settings/netsystemtime/timetabwidget.cpp b/noncore/settings/netsystemtime/timetabwidget.cpp
index bcfbdf7..895514b 100644
--- a/noncore/settings/netsystemtime/timetabwidget.cpp
+++ b/noncore/settings/netsystemtime/timetabwidget.cpp
@@ -52,2 +52,4 @@
#include <qspinbox.h>
+#include <qmessagebox.h>
+#include <qfile.h>
@@ -279,31 +281,38 @@ void TimeTabWidget::slotTZChanged( const QString &newtz )
{
- // If controls have a valid date & time, update systemtime
- int hour = sbHour->value();
- if ( use12HourTime && cbAmpm->currentItem() == ValuePM )
- hour += 12;
- QDateTime dt( btnDate->date(), QTime ( hour, sbMin->value(), QTime::currentTime().second() ) );
- setSystemTime( dt );
- QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" );
- setTimeZone << newtz;
-
- // Set system timezone
- QString currtz = getenv( "TZ" );
- setenv( "TZ", newtz, 1 );
-
- // Get new date/time
- hour = sbHour->value();
- if ( use12HourTime && cbAmpm->currentItem() == ValuePM )
- hour += 12;
- dt = QDateTime::currentDateTime();
-
- // Reset system timezone
- if ( !currtz.isNull() )
- {
- setenv( "TZ", currtz, 1 );
+ // 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 )
+ hour += 12;
+ QDateTime dt( btnDate->date(), QTime ( hour, sbMin->value(), QTime::currentTime().second() ) );
+ setSystemTime( dt );
+ QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" );
+ setTimeZone << newtz;
- // Set controls to new time
- setDateTime( dt );
+ // Set system timezone
+ QString currtz = getenv( "TZ" );
+ setenv( "TZ", newtz, 1 );
- emit tzChanged( newtz );
+ // Get new date/time
+ hour = sbHour->value();
+ if ( use12HourTime && cbAmpm->currentItem() == ValuePM )
+ hour += 12;
+ dt = QDateTime::currentDateTime();
+
+ // Reset system timezone
+ if ( !currtz.isNull() )
+ {
+ setenv( "TZ", currtz, 1 );
+ }
+
+ // Set controls to new time
+ setDateTime( dt );
+
+ emit tzChanged( newtz );
+ }
}