From: Jan Lapinkataja Date: Thu, 28 May 2009 12:26:57 +0000 (+0300) Subject: Corrected the password dialog and progress bar related errors. Texts and titles of... X-Git-Url: https://vcs.maemo.org/git/?p=qtmeetings;a=commitdiff_plain;h=eb6ca54521e6bef025029bab59bea3b76f7daa40 Corrected the password dialog and progress bar related errors. Texts and titles of those were incorrect and cancel button was visible during operation mode change. --- diff --git a/src/BusinessLogic/UIManager.cpp b/src/BusinessLogic/UIManager.cpp index d6d16b3..35f5da0 100644 --- a/src/BusinessLogic/UIManager.cpp +++ b/src/BusinessLogic/UIManager.cpp @@ -67,15 +67,6 @@ void UIManager::showMainView() iWindowManager->showView( iWeeklyView ); } -void UIManager::showProgressBar( QString aText ) -{ - if ( iProgressBar != 0 ) - { - iProgressBar->update( aText ); - iWindowManager->showDialog( iProgressBar ); - } -} - // =============================================== // INITIALIZE THE UIMANAGER void UIManager::createWeeklyView() @@ -107,8 +98,7 @@ void UIManager::createRoomStatusIndicator() void UIManager::createPasswordDialog() { - iPasswordDialog = new PasswordDialog( iEngine->iConfiguration->adminPassword(), tr("UIManager::createPasswordDialog"), tr("UIManager::createPasswordDialog") ); - + iPasswordDialog = new PasswordDialog( iEngine->iConfiguration->adminPassword(), "", tr("Enter password") ); connect( iPasswordDialog, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ), this, SLOT( passwordEntered( PasswordDialog::PasswordStatus ) ) ); } @@ -177,7 +167,8 @@ void UIManager::showMeetingProgressBar( Meeting *aMeeting ) { if ( iProgressBar != 0 ) { - iProgressBar->update( tr("Fetching meeting info...") ); + iProgressBar->update( tr( "Fetching meeting info..." ), tr( "Please wait" ) ); + iProgressBar->toggleCancellable( true ); iWindowManager->showDialog( static_cast( iProgressBar ), false, false ); iEngine->stopIdleTimeCounter(); } @@ -226,13 +217,12 @@ void UIManager::progressBarCancelled() void UIManager::changeModeOrdered( DeviceManager::OperationMode aMode ) { qDebug() << "[UIManager::changeModeOrdered] "; - - QString message = tr( "You are about to change operation mode to %1." ) - .arg( iEngine->iDevice->operationModeToString( aMode ) ); if ( iPasswordDialog != 0 ) { - // TODO : Set the new text for password dialog + QString text = tr( "You are about to change operation mode to %1." ) + .arg( iEngine->iDevice->operationModeToString( aMode ) ); + iPasswordDialog->update( text ); iWindowManager->showDialog( static_cast( iPasswordDialog ) ); } } @@ -263,6 +253,8 @@ void UIManager::passwordEntered( PasswordDialog::PasswordStatus aStatus ) // Show the progress bar.. if ( iProgressBar != 0 ) { + iProgressBar->update( tr( "" ), tr( "Changing operation mode" ) ); + iProgressBar->toggleCancellable( false ); iWindowManager->showDialog( static_cast( iProgressBar ), false ); } // ... and initiate the mode changing diff --git a/src/BusinessLogic/UIManager.h b/src/BusinessLogic/UIManager.h index de123b6..a672381 100644 --- a/src/BusinessLogic/UIManager.h +++ b/src/BusinessLogic/UIManager.h @@ -29,7 +29,6 @@ public: void connectDeviceManager( DeviceManager *aDeviceManager ); void connectCommunicationManager( CommunicationManager *aCommunicationManager ); void showMainView(); - void showProgressBar( QString aText ); signals: diff --git a/src/IO/DeviceControl/DeviceManager.cpp b/src/IO/DeviceControl/DeviceManager.cpp index 3db5db7..2180083 100644 --- a/src/IO/DeviceControl/DeviceManager.cpp +++ b/src/IO/DeviceControl/DeviceManager.cpp @@ -51,7 +51,9 @@ void DeviceManager::initDeviceManager() iMode = EmptyMode; iHWKeyListener = new HWKeyListener(); - handleKeyPresses( true ); + connect( iHWKeyListener, SIGNAL( HWKeyFullScreenPressed() ), this, SLOT( HWKeyFullScreenPressed() ) ); + //handleKeyPresses( true ); + iIgnoreHWKeyPresses = false; } DeviceManager::OperationMode DeviceManager::currentOperationMode() @@ -76,7 +78,8 @@ void DeviceManager::changeMode( bool aChange ) { qDebug() << "void DeviceManager::changeMode()"; if( !aChange ) { - handleKeyPresses( true ); + //handleKeyPresses( true ); + iIgnoreHWKeyPresses = false; return; } iModeToggler = new OperationModeToggler( iMode, iSettings, iAlarmSender, iConfigurator, iDataStorage ); @@ -140,25 +143,27 @@ void DeviceManager::HWKeyFullScreenPressed() qDebug() << "DeviceManager::HWKeyFullScreenPressed()"; // no more key presses before this one is handled - handleKeyPresses( false ); - - OperationMode nextMode; - switch ( iMode ) - { - case KioskMode: - nextMode = StandAloneMode; - break; - case StandAloneMode: - nextMode = KioskMode; - break; - default: - nextMode = EmptyMode; - break; + //handleKeyPresses( false ); + if( !iIgnoreHWKeyPresses ) { + iIgnoreHWKeyPresses = true; + OperationMode nextMode; + switch ( iMode ) + { + case KioskMode: + nextMode = StandAloneMode; + break; + case StandAloneMode: + nextMode = KioskMode; + break; + default: + nextMode = EmptyMode; + break; + } + if ( nextMode != EmptyMode ) + emit changeModeOrdered( nextMode ); + else + iIgnoreHWKeyPresses = false; } - if ( nextMode != EmptyMode ) - emit changeModeOrdered( nextMode ); - else - handleKeyPresses( true ); } void DeviceManager::errorSender( DeviceManager::ErrorCode aErrorCode, const QString &aAddInfo ) @@ -190,5 +195,5 @@ void DeviceManager::modeChanged() } //in case device restarting fails we just continue - handleKeyPresses( true ); + iIgnoreHWKeyPresses = false; } diff --git a/src/IO/DeviceControl/DeviceManager.h b/src/IO/DeviceControl/DeviceManager.h index 267cf96..d6d4d41 100644 --- a/src/IO/DeviceControl/DeviceManager.h +++ b/src/IO/DeviceControl/DeviceManager.h @@ -182,6 +182,7 @@ private: OperationMode iMode; bool iSendErrorMessages; + bool iIgnoreHWKeyPresses; }; diff --git a/src/IO/DeviceControl/HWKeyListener.cpp b/src/IO/DeviceControl/HWKeyListener.cpp index 2029f79..648934b 100644 --- a/src/IO/DeviceControl/HWKeyListener.cpp +++ b/src/IO/DeviceControl/HWKeyListener.cpp @@ -17,7 +17,7 @@ HWKeyListener::~HWKeyListener() bool HWKeyListener::eventFilter( QObject*, QEvent* e ) { - if ( e->type() == QEvent::KeyPress ) + if ( e->type() == QEvent::KeyRelease ) { QKeyEvent *keyEvent = static_cast( e ); switch ( keyEvent->key() ) diff --git a/src/UserInterface/Utils/PasswordDialog.cpp b/src/UserInterface/Utils/PasswordDialog.cpp index a31616b..9041ecf 100644 --- a/src/UserInterface/Utils/PasswordDialog.cpp +++ b/src/UserInterface/Utils/PasswordDialog.cpp @@ -28,12 +28,9 @@ PasswordDialog::PasswordDialog( const QString &aPassword, const QString &aText, QVBoxLayout *layout = new QVBoxLayout; - if ( !aText.isNull() ) - { - QLabel *text = new QLabel( aText ); - layout->addWidget( text ); - layout->addStretch(); - } + iText = new QLabel( aText ); + layout->addWidget( iText ); + layout->addStretch(); iPasswordEdit = new QLineEdit; iPasswordEdit->setEchoMode( QLineEdit::Password ); @@ -95,3 +92,8 @@ void PasswordDialog::cancelButtonPressed() emit passwordEntered( PasswordDialog::Canceled ); } +void PasswordDialog::update( const QString &aText ) +{ + qDebug() << "PasswordDialog::update()"; + iText->setText( aText ); +} diff --git a/src/UserInterface/Utils/PasswordDialog.h b/src/UserInterface/Utils/PasswordDialog.h index 686523b..c62223c 100644 --- a/src/UserInterface/Utils/PasswordDialog.h +++ b/src/UserInterface/Utils/PasswordDialog.h @@ -4,6 +4,7 @@ #include class QLineEdit; +class QLabel; class QByteArray; //! UserInterface class. Responsible for poping-up password query on the screen. @@ -26,6 +27,22 @@ public: Incorrect, /*!< Incorrect password. */ Canceled }; + + //! Constructor. + /*! + * Constructor to initialize a PasswordDialog instance. + * \param aParent The parent object. + * \param aPassword The password. + */ + PasswordDialog( const QString &aPassword, const QString &aText, const QString &aTitle = "", QWidget *aParent = 0 ); + //! Destructor. + virtual ~PasswordDialog(); + //! Updates the text of the password dialog label. + /*! + * Updates the text of the password dialog label. + * \param aText The text for the label. + */ + void update( const QString &aText ); signals: //! Signals the authenticity of the password when the uuser dismisses the dialog. @@ -39,18 +56,9 @@ private slots: void okButtonPressed(); void cancelButtonPressed(); -public: - //! Constructor. - /*! - * Constructor to initialize a PasswordDialog instance. - * \param aParent The parent object. - * \param aPassword The password. - */ - PasswordDialog( const QString &aPassword, const QString &aText, const QString &aTitle = "", QWidget *aParent = 0 ); - //! Destructor. - virtual ~PasswordDialog(); - +private: QLineEdit *iPasswordEdit; + QLabel *iText; QByteArray iPasswordHash; }; diff --git a/src/UserInterface/Utils/ProgressBar.cpp b/src/UserInterface/Utils/ProgressBar.cpp index 6ab9fe2..198fb65 100755 --- a/src/UserInterface/Utils/ProgressBar.cpp +++ b/src/UserInterface/Utils/ProgressBar.cpp @@ -8,11 +8,11 @@ #include #include -ProgressBar::ProgressBar( const QString &aText, bool aCancellable, QWidget *aParent ) : +ProgressBar::ProgressBar( const QString &aTitle, bool aCancellable, QWidget *aParent ) : QDialog( aParent ) { qDebug() << "ProgressBar::ProgressBar( const QString &, bool, QWidget *)"; - setWindowTitle( aText ); + setWindowTitle( aTitle ); setModal( true ); iProgress = new QProgressBar(); @@ -26,12 +26,15 @@ ProgressBar::ProgressBar( const QString &aText, bool aCancellable, QWidget *aPar mainLayout->addWidget( iLabel ); QHBoxLayout *subLayout = new QHBoxLayout; subLayout->addWidget( iProgress ); - if( aCancellable ) { - QPushButton *buttonCancel = new QPushButton( tr( "Cancel" ) ); - subLayout->addSpacing( 5 ); - subLayout->addWidget( buttonCancel ); - connect( buttonCancel, SIGNAL( pressed() ), this, SIGNAL( cancel() ) ); + + iButton = new QPushButton( tr( "Cancel" ) ); + subLayout->addSpacing( 5 ); + subLayout->addWidget( iButton ); + connect( iButton, SIGNAL( pressed() ), this, SIGNAL( cancel() ) ); + if( !aCancellable ) { + iButton->setVisible( false ); } + mainLayout->addLayout( subLayout ); mainLayout->setAlignment( Qt::AlignCenter ); setLayout( mainLayout ); @@ -42,8 +45,18 @@ ProgressBar::~ProgressBar() qDebug() << "ProgressBar::~ProgressBar()"; } -void ProgressBar::update( const QString &aMessage ) +void ProgressBar::update( const QString &aMessage, const QString &aTitle ) { qDebug() << "ProgressBar::update( const QString & )"; iLabel->setText( aMessage ); + if( aTitle != "" ) + setWindowTitle( aTitle ); +} + +void ProgressBar::toggleCancellable( bool aEnable ) +{ + if( aEnable ) + iButton->setVisible( true ); + else + iButton->setVisible( false ); } diff --git a/src/UserInterface/Utils/ProgressBar.h b/src/UserInterface/Utils/ProgressBar.h index bf573cd..ec52bf5 100755 --- a/src/UserInterface/Utils/ProgressBar.h +++ b/src/UserInterface/Utils/ProgressBar.h @@ -5,6 +5,7 @@ class QProgressBar; class QLabel; +class QPushButton; //! UserInterface class. /*! @@ -20,13 +21,20 @@ public: /*! * Constructor to initialize the StatusWidget instance. * \param aParent Parent object. - * \param aText Title string to be set to the progress bar. + * \param aTitle Title string to be set to the progress bar. */ - ProgressBar( const QString &aText, bool aCancellable = false, QWidget *aParent = 0 ); + ProgressBar( const QString &aTitle, bool aCancellable = false, QWidget *aParent = 0 ); //! Destructor. virtual ~ProgressBar(); + //! Updates the text fields of progress bar dialog. + /*! + * Updates the text fields of progress bar dialog. + * \param aMessage The text for the label of the dialog. + * \param aTitle Title string to be set to the progress bar. + */ + void update( const QString &aMessage, const QString &aTitle = "" ); - void update( const QString &aMessage ); + void toggleCancellable( bool aEnable ); signals: //! Signal. Emitted if user presses cancel button. @@ -39,6 +47,7 @@ signals: private: QProgressBar *iProgress; QLabel *iLabel; + QPushButton *iButton; };