summaryrefslogtreecommitdiff
authorzecke <zecke>2004-10-22 15:15:01 (UTC)
committer zecke <zecke>2004-10-22 15:15:01 (UTC)
commitf2a2eca1870e1fd88c82a6ccb039610949daa72c (patch) (side-by-side diff)
tree9ca204b4cddfee6272cfc8d5e55b27b60a0743d0
parent0a3ab70a5be70bb04691a2a566ce63719e57f83e (diff)
downloadopie-f2a2eca1870e1fd88c82a6ccb039610949daa72c.zip
opie-f2a2eca1870e1fd88c82a6ccb039610949daa72c.tar.gz
opie-f2a2eca1870e1fd88c82a6ccb039610949daa72c.tar.bz2
Write the hardware clock after setting the datetime. This way we can
gurantee it is set while opiealarm has not run.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/timetabwidget.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/noncore/settings/netsystemtime/timetabwidget.cpp b/noncore/settings/netsystemtime/timetabwidget.cpp
index 1ea460e..3cc127d 100644
--- a/noncore/settings/netsystemtime/timetabwidget.cpp
+++ b/noncore/settings/netsystemtime/timetabwidget.cpp
@@ -56,33 +56,33 @@ static const int ValuePM = 1;
TimeTabWidget::TimeTabWidget( QWidget *parent )
: QWidget( parent, 0x0, 0 )
{
// Synchronize HW clock to systemtime
// This app will update systemtime
// - if Cancel is clicked, will reset systemtime to HW clock's time
// - if Ok is clicked, will leave systemtime as is
system("/sbin/hwclock --systohc --utc");
QVBoxLayout *tmpvb = new QVBoxLayout( this );
QScrollView *sv = new QScrollView( this );
tmpvb->addWidget( sv, 0, 0 );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
QWidget *container = new QWidget( sv->viewport() );
sv->addChild( container );
-
+
QGridLayout *layout = new QGridLayout( container );
layout->setMargin( 2 );
layout->setSpacing( 4 );
// Hours
layout->addMultiCellWidget( new QLabel( tr( "Hour" ), container ), 1, 1, 0, 1 );
sbHour = new QSpinBox( container );
sbHour->setWrapping( TRUE );
layout->addMultiCellWidget( sbHour, 2, 2, 0, 1 );
// Minutes
layout->addMultiCellWidget( new QLabel( tr( "Minute" ), container ), 1, 1, 2, 3 );
sbMin = new QSpinBox( container );
sbMin->setWrapping( TRUE );
sbMin->setMinValue( 0 );
sbMin->setMaxValue( 59 );
@@ -174,56 +174,62 @@ void TimeTabWidget::setDateTime( const QDateTime &dt )
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::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 );
+ ::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 )
{
show_hour -= 12;
cbAmpm->setCurrentItem( ValuePM );
}
else
{