From: Zoltan Papp Date: Tue, 19 May 2009 13:41:28 +0000 (+0300) Subject: Moved the logicasl part of the progresbar/password dialog from WindowManager to Engin... X-Git-Url: https://vcs.maemo.org/git/?p=qtmeetings;a=commitdiff_plain;h=1148d4487882be86017d0210a61d3d1b60d86676 Moved the logicasl part of the progresbar/password dialog from WindowManager to Engine (related to tasks 1168 and 1169) --- diff --git a/src/BusinessLogic/Engine.cpp b/src/BusinessLogic/Engine.cpp index 6e677c4..e529799 100644 --- a/src/BusinessLogic/Engine.cpp +++ b/src/BusinessLogic/Engine.cpp @@ -35,6 +35,9 @@ Engine::Engine() : connect( iWindowManager, SIGNAL( meetingActivated( Meeting * ) ), this, SLOT( fetchMeetingDetails( Meeting * ) ) ); connect( iWindowManager, SIGNAL( currentRoomChanged( Room * ) ), this, SLOT( currentRoomChanged( Room * ) ) ); connect( iWindowManager, SIGNAL( shownWeekChanged( QDate ) ), this, SLOT( shownWeekChanged( QDate ) ) ); + connect( iWindowManager, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ), + this, SLOT( passwordEntered( PasswordDialog::PasswordStatus ) ) ); + connect( iWindowManager, SIGNAL( progressBarCancelled() ), this, SLOT( progressBarCancelled() ) ); // initialize communication iCommunication = new CommunicationManager( *(iConfiguration->connectionSettings()) ); @@ -287,3 +290,35 @@ void Engine::changeModeOrdered( DeviceManager::OperationMode aMode ) iWindowManager->showPasswordDialog( iConfiguration->adminPassword(), message ); } + +void Engine::passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus ) +{ + qDebug() << "Engine::passwordEntered( PasswordDialog::PasswordStatus )"; + iWindowManager->closePasswordDialog(); + + switch ( aPasswordStatus ) + { + case PasswordDialog::Correct : + { + iWindowManager->showProgressBar( "Changing current operation mode." ); + break; + } + case PasswordDialog::Incorrect : + { + iWindowManager->error( tr( "Incorrect password." ) ); + iDevice->handleKeyPresses( true ); + break; + } + default : //case PasswordDialog::Canceled + { + iDevice->handleKeyPresses( true ); + } + } +} + +void Engine::progressBarCancelled() +{ + //TODO: cancel the on-going event + iWindowManager->closeProgressBar(); + iDevice->handleKeyPresses( true ); +} diff --git a/src/BusinessLogic/Engine.h b/src/BusinessLogic/Engine.h index bec1f3b..457d6ba 100644 --- a/src/BusinessLogic/Engine.h +++ b/src/BusinessLogic/Engine.h @@ -113,6 +113,19 @@ private slots: * \param aMeeting The meeting. */ void fetchMeetingDetails( Meeting *aMeeting ); + //! Slot for receiving the status of the entered password + /*! + * Slot. Receives the status of the entered password and makes the DeviceManager to change the + * operation mode if the password is correct. + * \param aPasswordStatus The status of the password. + */ + void passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus ); + //! Slot for receiving the cancel event of the progress bar. + /*! + * Slot. Receives the cancel event of the progress bar. + */ + void progressBarCancelled(); + private: //! Provides the index of the Meeting instance which is at the specified time. /*! diff --git a/src/IO/DeviceControl/DeviceManager.h b/src/IO/DeviceControl/DeviceManager.h index f3f89dc..e65f714 100644 --- a/src/IO/DeviceControl/DeviceManager.h +++ b/src/IO/DeviceControl/DeviceManager.h @@ -84,6 +84,19 @@ public: * \return QString value of the current operation mode. */ QString operationModeToString( OperationMode aMode ); + //! Connects/disconnects the HWKeyListener signals to the private HWKeyFullScreenPressed() slot. + /*! + * Connects/disconnects the HWKeyListener signals to the private HWKeyFullScreenPressed() slot. In case + * a signal is caught the connection is disabled until the signal handling is finished. + * \param aHandle indicates if the signals should be connected or not. + */ + void handleKeyPresses( bool aHandle ); + //! Changes the operation mode. + /*! + * Changes the operation mode. + * \param aChange To indicate if the mode should be changed or not + */ + void changeMode( bool aChange ); signals: //! Signal. Emitted if user tries to change the operation mode. @@ -100,14 +113,6 @@ signals: */ void error( int aCode, const QString &aAddInfo ); -public slots: - //! Slot. Changes the operation mode. - /*! - * Slot. Changes the operation mode. - * \param aChange To indicate if the mode should be changed or not - */ - void changeMode( bool aChange ); - private slots: //! Slot. Handles "full screen"-hardware key presses. /*! @@ -148,13 +153,6 @@ private: * \return True if operation mode storing and deactivation of the init script succeed; otherwise, false. */ bool finalizeStandAloneMode(); - //! Connects/disconnects the HWKeyListener signals to the private HWKeyFullScreenPressed() slot. - /*! - * Connects/disconnects the HWKeyListener signals to the private HWKeyFullScreenPressed() slot. In case - * a signal is caught the connection is disabled until the signal handling is finished. - * \param aHandle indicates if the signals should be connected or not. - */ - void handleKeyPresses( bool aHandle ); private: AlarmSender *iAlarmSender; diff --git a/src/UserInterface/Utils/PasswordDialog.cpp b/src/UserInterface/Utils/PasswordDialog.cpp index 3a8590f..778d32a 100644 --- a/src/UserInterface/Utils/PasswordDialog.cpp +++ b/src/UserInterface/Utils/PasswordDialog.cpp @@ -13,12 +13,6 @@ PasswordDialog::PasswordDialog( const QString &aPassword, const QString &aText, setWindowTitle( aTitle.isNull() ? tr( "Enter password" ) : aTitle ); setModal( true ); - // Store the password hash to iPasswordHash - // ( aPassword should be allready encoded ) -// QCryptographicHash *hash = new QCryptographicHash( QCryptographicHash::Md5 ); -// hash->addData( aPassword.toUtf8() ); -// iPasswordHash = hash->result(); -// delete hash; iPasswordHash = aPassword.toUtf8(); /* Create the layout: @@ -61,13 +55,10 @@ PasswordDialog::PasswordDialog( const QString &aPassword, const QString &aText, // Enable the layout setLayout( layout ); - - show(); } PasswordDialog::~PasswordDialog() { - close(); } void PasswordDialog::okButtonPressed() diff --git a/src/UserInterface/Utils/PasswordDialog.h b/src/UserInterface/Utils/PasswordDialog.h index 86879c9..686523b 100644 --- a/src/UserInterface/Utils/PasswordDialog.h +++ b/src/UserInterface/Utils/PasswordDialog.h @@ -27,18 +27,6 @@ public: Canceled }; - //! Creates a new PasswordDialog instance and shows the dialog on the screen. - /*! - * Creates a new Password query dialog. - * \param aParent The parent object. - * \param aPassword The password. - * \param aText Optional. Text displayed in the dialog. - * \param aTitle Optional. Dialog title, defaults to "Enter password". - * \return The instance which was created. - static PasswordDialog * query( QWidget *aParent, const QString &aPassword, - const QString &aText = 0, const QString &aTitle = 0 ); - */ - signals: //! Signals the authenticity of the password when the uuser dismisses the dialog. /*! diff --git a/src/UserInterface/Utils/ProgressBar.cpp b/src/UserInterface/Utils/ProgressBar.cpp new file mode 100755 index 0000000..a43098d --- /dev/null +++ b/src/UserInterface/Utils/ProgressBar.cpp @@ -0,0 +1,34 @@ +#include "ProgressBar.h" + +#include +#include +#include + +ProgressBar::ProgressBar( const QString &aText, QWidget *aParent ) : + QDialog( aParent ) +{ + setWindowTitle( aText ); + setModal( true ); + + iProgress = new QProgressBar(); + iProgress->setMinimumWidth( 200 ); + iProgress->setMaximum( 0 ); + iProgress->setTextVisible( false ); + + QBoxLayout* layout = new QBoxLayout( QBoxLayout::LeftToRight, this ); + layout->setSizeConstraint( QLayout::SetDefaultConstraint ); + layout->addWidget( iProgress, 0, Qt::AlignHCenter ); + + QPushButton *buttonCancel = new QPushButton( tr( "Cancel" ) ); + layout->addSpacing( 5 ); + layout->addWidget( buttonCancel ); + + connect( buttonCancel, SIGNAL( pressed() ), this, SIGNAL( cancel() ) ); + connect( iProgress, SIGNAL( valueChanged( int ) ), this, SIGNAL( started() ) ); + + setLayout( layout ); +} + +ProgressBar::~ProgressBar() +{ +} diff --git a/src/UserInterface/Utils/ProgressBar.h b/src/UserInterface/Utils/ProgressBar.h new file mode 100755 index 0000000..a247cf3 --- /dev/null +++ b/src/UserInterface/Utils/ProgressBar.h @@ -0,0 +1,41 @@ +#ifndef PROGRESSBAR_H_ +#define PROGRESSBAR_H_ + +#include + +class QProgressBar; + +//! UserInterface class. +/*! + * UserInterface class which launches a modal progress bar during application events that might take + * some time + */ +class ProgressBar : public QDialog +{ + Q_OBJECT + +public: + //! Constructor. + /*! + * Constructor to initialize the StatusWidget instance. + * \param aParent Parent object. + * \param aText Title string to be set to the progress bar. + */ + ProgressBar( const QString &aText, QWidget *aParent = 0 ); + //! Destructor. + virtual ~ProgressBar(); + +signals: + //! Signal. Emitted if user presses cancel button. + /*! + * Signal. Emitted if user presses cancel button. + */ + void cancel(); + void started(); + +private: + QProgressBar *iProgress; + +}; + +#endif /*PROGRESSBAR_H_*/ diff --git a/src/UserInterface/WindowManager.cpp b/src/UserInterface/WindowManager.cpp index 8107fbb..3a593a9 100644 --- a/src/UserInterface/WindowManager.cpp +++ b/src/UserInterface/WindowManager.cpp @@ -160,53 +160,34 @@ void WindowManager::error( const QString &aErrorMessage ) PopUpMessageBox::error( 0, aErrorMessage ); } -void WindowManager::passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus ) -{ - delete iPasswordDialog; - iPasswordDialog = 0; - - switch ( aPasswordStatus ) - { - case PasswordDialog::Correct : - { - progressBar( tr( "Changing operation mode" ), true ); - iProgressBar->show(); - while(1); - break; - } - case PasswordDialog::Incorrect : - { - error( tr( "Incorrect password." ) ); - break; - } - default : //case PasswordDialog::Canceled - { - } - } -} - void WindowManager::showPasswordDialog( QByteArray aAdminPassword, const QString &aMessage ) { iPasswordDialog = new PasswordDialog( aAdminPassword, aMessage ); + connect( iPasswordDialog, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ), + this, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ) ); iPasswordDialog->show(); } +void WindowManager::closePasswordDialog() +{ + iPasswordDialog->close(); + delete iPasswordDialog; + iPasswordDialog = 0; +} -void WindowManager::progressBar( const QString &aText, bool aStart ) +void WindowManager::showProgressBar( const QString &aText ) { - qDebug() << "WindowManager::progressBar( const QString &, bool)"; - if( aStart ) { - if( iProgressBar == 0 ) { - iProgressBar = new ProgressBar( aText ); - connect( iProgressBar, SIGNAL( cancel() ), this, SLOT( progressBar() ) ); - connect( iProgressBar, SIGNAL( started() ), this, SLOT( changeMode() ) ); - } - } - else { - if( iProgressBar != 0 ) { - delete iProgressBar; - iProgressBar = 0; - } + qDebug() << "WindowManager::showProgressBar( const QString & )"; + if( iProgressBar == 0 ) { + iProgressBar = new ProgressBar( aText ); + iProgressBar->show(); + connect( iProgressBar, SIGNAL( cancel() ), this, SIGNAL( progressBarCancelled() ) ); } } +void WindowManager::closeProgressBar() +{ + iProgressBar->close(); + delete iProgressBar; + iProgressBar = 0; +} diff --git a/src/UserInterface/WindowManager.h b/src/UserInterface/WindowManager.h index 0c85515..6a56e77 100644 --- a/src/UserInterface/WindowManager.h +++ b/src/UserInterface/WindowManager.h @@ -57,6 +57,11 @@ public: * \param aMessage The message to be shown in the password dialog. */ void showPasswordDialog( QByteArray aAdminPassword, const QString &aMessage ); + //! Closes the password dialog. + /*! + * Closes the password dialog. + */ + void closePasswordDialog(); //! Displays the weekly view. /*! * Displays the weekly view. @@ -78,6 +83,17 @@ public: * Switches the views to full screen. */ void fullScreen(); + //! Shows the progress bar. + /*! + * Starts showing the progress bar. + * \param aText The text to be shown in progress bar. + */ + void showProgressBar( const QString &aText ); + //! Closes the progress bar. + /*! + * Closes the progress bar. + */ + void closeProgressBar(); void insertMeeting( Meeting *aMeeting ); @@ -113,6 +129,17 @@ signals: * \param aRoom Selected meeting room. */ void currentRoomChanged( Room *aRoom ); + //! Signals when the password dialog buttons are clicked. + /*! + * Signal is emitted when the password dialog buttons are clicked. + * \param aPasswordStatus The status of the password. + */ + void passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus ); + //! Signals when the cancel button in the progress bar is clicked. + /*! + * Signal is emitted when the cancel button in the progress bar is clicked. + */ + void progressBarCancelled(); public slots: //! Slot for displaying the screensaver (room status view). @@ -130,20 +157,6 @@ public slots: private slots: //! Displays the settings view void showSettingsView(); - //! Slot for receiving the status of the entered password - /*! - * Slot. Receives the status of the entered password and makes the DeviceManager to change the - * operation mode if the password is correct. - * \param aPasswordStatus The status of the password. - */ - void passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus ); - //! Slot for showing/hiding the progress bar. - /*! - * Slot. Starts showing or hides the progress bar. - * \param aText The text to be shown in progress bar. - * \param aStart to indicate whether the progress bar is wanted to shown or hidden - */ - void progressBar( const QString &aText = "", bool aStart = false ); private: //! Name of the application.