author | drw <drw> | 2005-02-23 16:14:09 (UTC) |
---|---|---|
committer | drw <drw> | 2005-02-23 16:14:09 (UTC) |
commit | e5b1e010c321ba1edac704f9d668df75b22fd074 (patch) (side-by-side diff) | |
tree | c76221c7d8292f66ef05040721edf816a04fbeba | |
parent | 30857db6ca3f355aa3d50b59f03a13c82f265af2 (diff) | |
download | opie-e5b1e010c321ba1edac704f9d668df75b22fd074.zip opie-e5b1e010c321ba1edac704f9d668df75b22fd074.tar.gz opie-e5b1e010c321ba1edac704f9d668df75b22fd074.tar.bz2 |
Fix UI to prevent error dialog from displaying when it shouldn't
-rw-r--r-- | noncore/settings/netsystemtime/mainwindow.cpp | 61 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/ntptabwidget.cpp | 53 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/ntptabwidget.h | 46 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/timetabwidget.cpp | 55 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/timetabwidget.h | 47 |
5 files changed, 147 insertions, 115 deletions
diff --git a/noncore/settings/netsystemtime/mainwindow.cpp b/noncore/settings/netsystemtime/mainwindow.cpp index 385d355..486257f 100644 --- a/noncore/settings/netsystemtime/mainwindow.cpp +++ b/noncore/settings/netsystemtime/mainwindow.cpp @@ -1,31 +1,31 @@ /* - This file is part of the OPIE Project + This file is part of the OPIE Project =. - .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> - .>+-= - _;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU General Public -.="- .-=="i, .._ License as published by the Free Software - - . .-<_> .<> Foundation; either version 2 of the License, - ._= =} : or (at your option) any later version. - .%`+i> _;_. - .i_,=:_. -<s. This file is distributed in the hope that - + . -:. = it will be useful, but WITHOUT ANY WARRANTY; - : .. .:, . . . without even the implied warranty of - =_ + =;=|` MERCHANTABILITY or FITNESS FOR A - _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General -..}^=.= = ; Public License for more details. -++= -. .` .: - : = ...= . :.=- You should have received a copy of the GNU - -. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., + .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> + .>+-= +_;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software +- . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: +: = ...= . :.=- You should have received a copy of the GNU +-. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "mainwindow.h" #include "timetabwidget.h" #include "formattabwidget.h" @@ -46,17 +46,17 @@ #include <qmessagebox.h> #include <qsocket.h> #include <qstring.h> #include <qtimer.h> using namespace Opie::Ui; using namespace Opie::Core; MainWindow::MainWindow( QWidget *parent , const char *name, bool modal, WFlags f ) - : QDialog( 0x0, 0x0, TRUE, 0 ) + : QDialog( parent, name, modal, f ) { setCaption( tr( "SystemTime" ) ); QVBoxLayout *layout = new QVBoxLayout( this ); layout->setMargin( 2 ); layout->setSpacing( 4 ); // Create main tabbed control @@ -182,16 +182,21 @@ void MainWindow::runNTP() if ( ntpTabEnabled ) { ntpTab->setStartTime( QDateTime::currentDateTime().toString() ); QString output = tr( "Running:\nntpdate " ); output.append( srv ); ntpTab->addNtpOutput( output ); } + // Disable set time buttons & change app caption to indicate time update is happening + ntpTab->setNTPBtnEnabled( false ); + timeTab->setNTPBtnEnabled( false ); + setCaption( tr( "Retrieving time from network..." ) ); + if ( !ntpProcess ) { ntpProcess = new OProcess(); connect( ntpProcess, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), this, SLOT(slotNtpOutput(Opie::Core::OProcess*,char*,int)) ); connect( ntpProcess, SIGNAL(processExited(Opie::Core::OProcess*)), this, SLOT(slotNtpFinished(Opie::Core::OProcess*)) ); } @@ -201,16 +206,21 @@ void MainWindow::runNTP() *ntpProcess << "ntpdate" << srv; bool ret = ntpProcess->start( OProcess::NotifyOnExit, OProcess::AllOutput ); if ( !ret ) { QMessageBox::critical( this, tr( "Error" ), tr( "Error while getting time from network." ) ); if ( ntpTabEnabled ) ntpTab->addNtpOutput( tr( "Error while executing ntpdate" ) ); + + // Re-enable set time buttons & change app caption to indicate time update is happening + ntpTab->setNTPBtnEnabled( true ); + timeTab->setNTPBtnEnabled( true ); + setCaption( tr( "SystemTime" ) ); } } bool MainWindow::ntpDelayElapsed() { // Determine if time elapsed is greater than time delay Config config( "ntp" ); config.setGroup( "lookups" ); @@ -293,16 +303,21 @@ void MainWindow::slotNtpOutput( OProcess *, char *buffer, int buflen ) ntpTab->addNtpOutput( output ); } void MainWindow::slotNtpFinished( OProcess *p ) { QString output; QDateTime dt = QDateTime::currentDateTime(); + // Re-enable set time buttons & change app caption to indicate time update is happening + ntpTab->setNTPBtnEnabled( true ); + timeTab->setNTPBtnEnabled( true ); + setCaption( tr( "SystemTime" ) ); + // Verify run was successful if ( p->exitStatus() != 0 || !p->normalExit() ) { if ( isVisible() && ntpInteractive ) { output = tr( "Error while getting time from\n server: " ); output.append( settingsTab->ntpServer() ); QMessageBox::critical(this, tr( "Error" ), output ); @@ -346,17 +361,17 @@ void MainWindow::slotNtpFinished( OProcess *p ) ntpTab->setNewTime( dt.toString() ); } if ( lastNtp && lastLookup > 0 && secsSinceLast > 60 * ntpDelay ) { QString grpname = QString( "lookup_" ).append( QString::number( lookupCount ) ); config.setGroup( grpname ); lookupCount++; - predictTab->setShiftPerSec( timeShift / secsSinceLast ); + predictTab->setShiftPerSec( (int)(timeShift / secsSinceLast) ); config.writeEntry( "secsSinceLast", secsSinceLast ); config.writeEntry( "timeShift", QString::number( timeShift ) ); config.setGroup( "lookups" ); config.writeEntry( "count", lookupCount ); config.writeEntry( "lastNtp", TRUE ); } } diff --git a/noncore/settings/netsystemtime/ntptabwidget.cpp b/noncore/settings/netsystemtime/ntptabwidget.cpp index d71c230..616bc22 100644 --- a/noncore/settings/netsystemtime/ntptabwidget.cpp +++ b/noncore/settings/netsystemtime/ntptabwidget.cpp @@ -1,31 +1,31 @@ /* - This file is part of the OPIE Project + This file is part of the OPIE Project =. - .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> - .>+-= - _;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU General Public -.="- .-=="i, .._ License as published by the Free Software - - . .-<_> .<> Foundation; either version 2 of the License, - ._= =} : or (at your option) any later version. - .%`+i> _;_. - .i_,=:_. -<s. This file is distributed in the hope that - + . -:. = it will be useful, but WITHOUT ANY WARRANTY; - : .. .:, . . . without even the implied warranty of - =_ + =;=|` MERCHANTABILITY or FITNESS FOR A - _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General -..}^=.= = ; Public License for more details. -++= -. .` .: - : = ...= . :.=- You should have received a copy of the GNU - -. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., + .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> + .>+-= +_;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software +- . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: +: = ...= . :.=- You should have received a copy of the GNU +-. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "ntptabwidget.h" #include <qpe/resource.h> @@ -70,20 +70,20 @@ NTPTabWidget::NTPTabWidget( QWidget *parent ) mleNtpOutput = new QMultiLineEdit( container ); QFont font( mleNtpOutput->font() ); font.setPointSize( 7 ); mleNtpOutput->setFont( font ); mleNtpOutput->setWordWrap( QMultiLineEdit::WidgetWidth ); layout->addMultiCellWidget( mleNtpOutput, 3, 3, 0, 1 ); // Set NTP time button - QPushButton *pb = new QPushButton( Resource::loadPixmap( "netsystemtime/ntptab" ), + m_ntpBtn = new QPushButton( Resource::loadPixmap( "netsystemtime/ntptab" ), tr( "Get time from the network" ), container ); - connect( pb, SIGNAL(clicked()), this, SIGNAL(getNTPTime()) ); - layout->addMultiCellWidget( pb, 4, 4, 0, 1 ); + connect( m_ntpBtn, SIGNAL(clicked()), this, SIGNAL(getNTPTime()) ); + layout->addMultiCellWidget( m_ntpBtn, 4, 4, 0, 1 ); } NTPTabWidget::~NTPTabWidget() { } void NTPTabWidget::setStartTime( const QString &str ) { @@ -100,8 +100,13 @@ void NTPTabWidget::setNewTime( const QString &str ) lblNewTime->setText( str ); } void NTPTabWidget::addNtpOutput( const QString &str ) { mleNtpOutput->append( str ); mleNtpOutput->setCursorPosition( mleNtpOutput->numLines() + 1, 0, FALSE ); } + +void NTPTabWidget::setNTPBtnEnabled( bool enabled ) +{ + m_ntpBtn->setEnabled( enabled ); +} diff --git a/noncore/settings/netsystemtime/ntptabwidget.h b/noncore/settings/netsystemtime/ntptabwidget.h index 811c57e..f05482e 100644 --- a/noncore/settings/netsystemtime/ntptabwidget.h +++ b/noncore/settings/netsystemtime/ntptabwidget.h @@ -1,60 +1,64 @@ /* - This file is part of the OPIE Project + This file is part of the OPIE Project =. - .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> - .>+-= - _;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU General Public -.="- .-=="i, .._ License as published by the Free Software - - . .-<_> .<> Foundation; either version 2 of the License, - ._= =} : or (at your option) any later version. - .%`+i> _;_. - .i_,=:_. -<s. This file is distributed in the hope that - + . -:. = it will be useful, but WITHOUT ANY WARRANTY; - : .. .:, . . . without even the implied warranty of - =_ + =;=|` MERCHANTABILITY or FITNESS FOR A - _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General -..}^=.= = ; Public License for more details. -++= -. .` .: - : = ...= . :.=- You should have received a copy of the GNU - -. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., + .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> + .>+-= +_;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software +- . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: +: = ...= . :.=- You should have received a copy of the GNU +-. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef NTPTABWIDGET_H #define NTPTABWIDGET_H #include <qwidget.h> class QLabel; class QMultiLineEdit; +class QPushButton; class NTPTabWidget : public QWidget { Q_OBJECT public: NTPTabWidget( QWidget * = 0x0 ); ~NTPTabWidget(); void setStartTime( const QString & ); void setTimeShift( const QString & ); void setNewTime( const QString & ); void addNtpOutput( const QString & ); + void setNTPBtnEnabled( bool enabled ); private: QLabel *lblStartTime; QLabel *lblTimeShift; QLabel *lblNewTime; QMultiLineEdit *mleNtpOutput; + QPushButton *m_ntpBtn; + signals: void getNTPTime(); }; #endif diff --git a/noncore/settings/netsystemtime/timetabwidget.cpp b/noncore/settings/netsystemtime/timetabwidget.cpp index 3cc127d..905461f 100644 --- a/noncore/settings/netsystemtime/timetabwidget.cpp +++ b/noncore/settings/netsystemtime/timetabwidget.cpp @@ -1,31 +1,31 @@ /* - This file is part of the OPIE Project + This file is part of the OPIE Project =. - .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> - .>+-= - _;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU General Public -.="- .-=="i, .._ License as published by the Free Software - - . .-<_> .<> Foundation; either version 2 of the License, - ._= =} : or (at your option) any later version. - .%`+i> _;_. - .i_,=:_. -<s. This file is distributed in the hope that - + . -:. = it will be useful, but WITHOUT ANY WARRANTY; - : .. .:, . . . without even the implied warranty of - =_ + =;=|` MERCHANTABILITY or FITNESS FOR A - _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General -..}^=.= = ; Public License for more details. -++= -. .` .: - : = ...= . :.=- You should have received a copy of the GNU - -. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., + .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> + .>+-= +_;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software +- . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: +: = ...= . :.=- You should have received a copy of the GNU +-. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "timetabwidget.h" #include <qpe/config.h> @@ -104,23 +104,23 @@ TimeTabWidget::TimeTabWidget( QWidget *parent ) selTimeZone = new TimeZoneSelector( container ); connect( selTimeZone, SIGNAL(signalNewTz(const QString&)), this, SLOT(slotTZChanged(const QString&)) ); layout->addMultiCellWidget( selTimeZone, 6, 6, 2, 5 ); // Space filler layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 7, 0 ); // Set NTP time button - QPushButton *pb = new QPushButton( Resource::loadPixmap( "netsystemtime/ntptab" ), + m_ntpBtn = new QPushButton( Resource::loadPixmap( "netsystemtime/ntptab" ), tr( "Get time from the network" ), container ); - connect( pb, SIGNAL(clicked()), this, SIGNAL(getNTPTime()) ); - layout->addMultiCellWidget( pb, 8, 8, 0, 5 ); + connect( m_ntpBtn, SIGNAL(clicked()), this, SIGNAL(getNTPTime()) ); + layout->addMultiCellWidget( m_ntpBtn, 8, 8, 0, 5 ); // Set predicted time button - pb = new QPushButton( Resource::loadPixmap( "netsystemtime/predicttab" ), tr( "Set predicted time" ), + QPushButton *pb = new QPushButton( Resource::loadPixmap( "netsystemtime/predicttab" ), tr( "Set predicted time" ), container ); connect( pb, SIGNAL(clicked()), this, SIGNAL(getPredictedTime()) ); layout->addMultiCellWidget( pb, 9, 9, 0, 5 ); // Space filler at bottom of widget layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ), 10, 0 ); // Initialize values @@ -187,16 +187,21 @@ void TimeTabWidget::setDateTime( const QDateTime &dt ) 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; diff --git a/noncore/settings/netsystemtime/timetabwidget.h b/noncore/settings/netsystemtime/timetabwidget.h index f44a1da..949535d 100644 --- a/noncore/settings/netsystemtime/timetabwidget.h +++ b/noncore/settings/netsystemtime/timetabwidget.h @@ -1,65 +1,68 @@ /* - This file is part of the OPIE Project + This file is part of the OPIE Project =. - .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> - .>+-= - _;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU General Public -.="- .-=="i, .._ License as published by the Free Software - - . .-<_> .<> Foundation; either version 2 of the License, - ._= =} : or (at your option) any later version. - .%`+i> _;_. - .i_,=:_. -<s. This file is distributed in the hope that - + . -:. = it will be useful, but WITHOUT ANY WARRANTY; - : .. .:, . . . without even the implied warranty of - =_ + =;=|` MERCHANTABILITY or FITNESS FOR A - _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General -..}^=.= = ; Public License for more details. -++= -. .` .: - : = ...= . :.=- You should have received a copy of the GNU - -. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., + .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> + .>+-= +_;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software +- . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: +: = ...= . :.=- You should have received a copy of the GNU +-. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef TIMETABWIDGET_H #define TIMETABWIDGET_H #include <qwidget.h> class DateButton; class DateFormat; class QComboBox; class QDateTime; +class QPushButton; class QSpinBox; class TimeZoneSelector; class TimeTabWidget : public QWidget { Q_OBJECT public: - TimeTabWidget( QWidget * = 0x0 ); + TimeTabWidget( QWidget * = 0l ); ~TimeTabWidget(); void saveSettings( bool ); void setDateTime( const QDateTime & ); + void setNTPBtnEnabled( bool enabled ); private: QSpinBox *sbHour; QSpinBox *sbMin; QComboBox *cbAmpm; DateButton *btnDate; TimeZoneSelector *selTimeZone; + QPushButton *m_ntpBtn; bool use12HourTime; void setSystemTime( const QDateTime & ); signals: void tzChanged( const QString & ); void getNTPTime(); |