summaryrefslogtreecommitdiff
authorerik <erik>2007-04-23 20:38:22 (UTC)
committer erik <erik>2007-04-23 20:38:22 (UTC)
commitd38e40fe9ee475230425fa83e924c49e5946b87c (patch) (side-by-side diff)
treef10fceda92538e1bc9cee66f82062773974ec092
parent1edbb754d3c8cfccf1630e2ad1e531e907555cbd (diff)
downloadopie-d38e40fe9ee475230425fa83e924c49e5946b87c.zip
opie-d38e40fe9ee475230425fa83e924c49e5946b87c.tar.gz
opie-d38e40fe9ee475230425fa83e924c49e5946b87c.tar.bz2
Fix for bug 1848 where the outcome of setting the time to 12:00AM did not
work. This commit is based on a patch submitted by harlekin. Thank you!
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/timetabwidget.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/settings/netsystemtime/timetabwidget.cpp b/noncore/settings/netsystemtime/timetabwidget.cpp
index 895514b..e6fcf7f 100644
--- a/noncore/settings/netsystemtime/timetabwidget.cpp
+++ b/noncore/settings/netsystemtime/timetabwidget.cpp
@@ -132,159 +132,159 @@ TimeTabWidget::TimeTabWidget( QWidget *parent )
layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 10, 0 );
// Initialize values
Config config( "locale" );
config.setGroup( "Location" );
selTimeZone->setCurrentZone( config.readEntry( "Timezone", "America/New_York" ) );
use12HourTime = FALSE;
setDateTime( QDateTime::currentDateTime() );
}
TimeTabWidget::~TimeTabWidget()
{
}
void TimeTabWidget::saveSettings( bool commit )
{
if ( commit )
{
// Set timezone and announce to world
QString tz = selTimeZone->currentZone();
Config config("locale");
config.setGroup( "Location" );
config.writeEntry( "Timezone", tz );
setenv( "TZ", tz, 1 );
QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" );
setTimeZone << tz;
// 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 );
}
else
{
// Reset systemtime to hardware clock (i.e. undo any changes made by this app)
system("/sbin/hwclock --hctosys --utc");
}
}
void TimeTabWidget::setDateTime( const QDateTime &dt )
{
// Set time
QTime t = dt.time();
if( use12HourTime )
{
int show_hour = t.hour();
- if ( t.hour() >= 12 )
+ if ( t.hour() > 12 )
{
show_hour -= 12;
cbAmpm->setCurrentItem( ValuePM );
}
else
{
cbAmpm->setCurrentItem( ValueAM );
}
if ( show_hour == 0 )
show_hour = 12;
sbHour->setValue( show_hour );
}
else
{
sbHour->setValue( t.hour() );
}
sbMin->setValue( t.minute() );
// Set date
btnDate->setDate( dt.date() );
}
void TimeTabWidget::setNTPBtnEnabled( bool enabled )
{
m_ntpBtn->setEnabled( enabled );
}
void TimeTabWidget::setSystemTime( const QDateTime &dt )
{
// Set system clock
if ( dt.isValid() )
{
struct timeval myTv;
int t = TimeConversion::toUTC( dt );
myTv.tv_sec = t;
myTv.tv_usec = 0;
if ( myTv.tv_sec != -1 )
::settimeofday( &myTv, 0 );
/*
* Commit the datetime to the 'hardware'
* as Global::writeHWClock() is a NOOP with Opie Alarm
*/
system("/sbin/hwclock --systohc --utc");
}
}
void TimeTabWidget::slotUse12HourTime( int i )
{
use12HourTime = (i == 1);
cbAmpm->setEnabled( use12HourTime );
int show_hour = sbHour->value();
if ( use12HourTime )
{
sbHour->setMinValue( 1 );
sbHour->setMaxValue( 12 );
- if ( show_hour >= 12 )
+ if ( show_hour > 12 )
{
show_hour -= 12;
cbAmpm->setCurrentItem( ValuePM );
}
else
{
cbAmpm->setCurrentItem( ValueAM );
}
if ( show_hour == 0 )
show_hour = 12;
}
else
{
sbHour->setMinValue( 0 );
sbHour->setMaxValue( 23 );
if ( cbAmpm->currentItem() == ValuePM )
{
show_hour += 12;
if ( show_hour == 24 )
show_hour = 0;
}
}
sbHour->setValue( show_hour );
}
void TimeTabWidget::slotDateFormatChanged( const DateFormat &df )
{
btnDate->setDateFormat( df );
}
void TimeTabWidget::slotWeekStartChanged( int monday )
{
btnDate->setWeekStartsMonday( monday );
}
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 )