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()) );
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 );
+}
* \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.
/*!
* \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.
*/
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.
/*!
* \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;
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:
// Enable the layout
setLayout( layout );
-
- show();
}
PasswordDialog::~PasswordDialog()
{
- close();
}
void PasswordDialog::okButtonPressed()
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.
/*!
--- /dev/null
+#include "ProgressBar.h"
+
+#include <QProgressBar>
+#include <QBoxLayout>
+#include <QPushButton>
+
+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()
+{
+}
--- /dev/null
+#ifndef PROGRESSBAR_H_
+#define PROGRESSBAR_H_
+
+#include <QDialog>
+
+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_*/
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;
+}
* \param aMessage The message to be shown in the password dialog.\r
*/\r
void showPasswordDialog( QByteArray aAdminPassword, const QString &aMessage );\r
+ //! Closes the password dialog.\r
+ /*!\r
+ * Closes the password dialog.\r
+ */\r
+ void closePasswordDialog();\r
//! Displays the weekly view.\r
/*!\r
* Displays the weekly view.\r
* Switches the views to full screen.\r
*/\r
void fullScreen();\r
+ //! Shows the progress bar.\r
+ /*!\r
+ * Starts showing the progress bar.\r
+ * \param aText The text to be shown in progress bar.\r
+ */\r
+ void showProgressBar( const QString &aText );\r
+ //! Closes the progress bar.\r
+ /*!\r
+ * Closes the progress bar.\r
+ */\r
+ void closeProgressBar();\r
\r
void insertMeeting( Meeting *aMeeting );\r
\r
* \param aRoom Selected meeting room.\r
*/\r
void currentRoomChanged( Room *aRoom );\r
+ //! Signals when the password dialog buttons are clicked.\r
+ /*!\r
+ * Signal is emitted when the password dialog buttons are clicked.\r
+ * \param aPasswordStatus The status of the password.\r
+ */\r
+ void passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus );\r
+ //! Signals when the cancel button in the progress bar is clicked.\r
+ /*!\r
+ * Signal is emitted when the cancel button in the progress bar is clicked.\r
+ */\r
+ void progressBarCancelled();\r
\r
public slots:\r
//! Slot for displaying the screensaver (room status view).\r
private slots:\r
//! Displays the settings view\r
void showSettingsView();\r
- //! Slot for receiving the status of the entered password\r
- /*!\r
- * Slot. Receives the status of the entered password and makes the DeviceManager to change the\r
- * operation mode if the password is correct.\r
- * \param aPasswordStatus The status of the password.\r
- */\r
- void passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus );\r
- //! Slot for showing/hiding the progress bar.\r
- /*!\r
- * Slot. Starts showing or hides the progress bar.\r
- * \param aText The text to be shown in progress bar.\r
- * \param aStart to indicate whether the progress bar is wanted to shown or hidden\r
- */\r
- void progressBar( const QString &aText = "", bool aStart = false );\r
\r
private:\r
//! Name of the application.\r