Corrected the password dialog and progress bar related errors. Texts and titles of...
authorJan Lapinkataja <jan.lapinkataja@ixonos.com>
Thu, 28 May 2009 12:26:57 +0000 (15:26 +0300)
committerJan Lapinkataja <jan.lapinkataja@ixonos.com>
Thu, 28 May 2009 12:26:57 +0000 (15:26 +0300)
src/BusinessLogic/UIManager.cpp
src/BusinessLogic/UIManager.h
src/IO/DeviceControl/DeviceManager.cpp
src/IO/DeviceControl/DeviceManager.h
src/IO/DeviceControl/HWKeyListener.cpp
src/UserInterface/Utils/PasswordDialog.cpp
src/UserInterface/Utils/PasswordDialog.h
src/UserInterface/Utils/ProgressBar.cpp
src/UserInterface/Utils/ProgressBar.h

index d6d16b3..35f5da0 100644 (file)
@@ -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<QDialog *>( iProgressBar ), false, false );
                iEngine->stopIdleTimeCounter();
        }
@@ -226,13 +217,12 @@ void UIManager::progressBarCancelled()
 void UIManager::changeModeOrdered( DeviceManager::OperationMode aMode )
 {
        qDebug() << "[UIManager::changeModeOrdered] <Invoked>";
-       
-       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<QDialog *>( 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<QDialog *>( iProgressBar ), false );
                        }
                        // ... and initiate the mode changing
index de123b6..a672381 100644 (file)
@@ -29,7 +29,6 @@ public:
        void connectDeviceManager( DeviceManager *aDeviceManager );
        void connectCommunicationManager( CommunicationManager *aCommunicationManager );
        void showMainView();
-       void showProgressBar( QString aText );
 
 signals:
        
index 3db5db7..2180083 100644 (file)
@@ -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;
 }
index 267cf96..d6d4d41 100644 (file)
@@ -182,6 +182,7 @@ private:
 
        OperationMode iMode;
        bool iSendErrorMessages;
+       bool iIgnoreHWKeyPresses;
 
 };
 
index 2029f79..648934b 100644 (file)
@@ -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<QKeyEvent *>( e );
                switch ( keyEvent->key() )
index a31616b..9041ecf 100644 (file)
@@ -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 );
+}
index 686523b..c62223c 100644 (file)
@@ -4,6 +4,7 @@
 #include <QDialog>
 
 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;
 };
 
index 6ab9fe2..198fb65 100755 (executable)
@@ -8,11 +8,11 @@
 #include <QLabel>
 #include <QtDebug>
 
-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 );
 }
index bf573cd..ec52bf5 100755 (executable)
@@ -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;
 
 };