From: itkonma Date: Mon, 1 Jun 2009 06:09:24 +0000 (+0300) Subject: Merge branch 'master' of https://git.maemo.org/projects/qtmeetings X-Git-Url: https://vcs.maemo.org/git/?p=qtmeetings;a=commitdiff_plain;h=97603680c47945a85e0565c71f2e1e59eec5a9c2 Merge branch 'master' of https://git.maemo.org/projects/qtmeetings Conflicts: src/BusinessLogic/UIManager.h --- diff --git a/resources/xml/errortable.xml b/resources/xml/errortable.xml index 4706fce..841228a 100644 --- a/resources/xml/errortable.xml +++ b/resources/xml/errortable.xml @@ -15,17 +15,17 @@ Communication error Communication: Invalid username or password Device Control: Error creating internal file storage. - Failed to change the operation mode. Error removing old alarm events. - Failed to change the operation mode. Error sending alarm events. %1 - Failed to change the operation mode. Error storing data about sent alarm events. Removing the already sent alarm events. - Error storing data of original automatic screen switching-off and dimming parameter values. Using the default values instead. - Error fetching data of original automatic screen switching-off and dimming parameter values. Using the default values instead. - Failed to change the operation mode. Error changing automatic screen switching-off and dimming parameter values. - Failed to change the operation mode. Error fetching data of original hardware key settings. - Failed to change the operation mode. Error storing data of original hardware key settings. - Failed to change the operation mode. Error changing hardware key settings. - Failed to change the operation mode. Init script to auto launch the application was not installed/removed. - Failed to change the operation mode. The application failed to know the current mode of itself. - Failed to change the operation mode. The application failed to store the current mode of itself. - Failed to change the operation mode. Error restarting the device. Restart device manually. + Device Control: Error removing old alarm events. + Device Control: Error sending alarm events. %1 + Device Control: Error storing data about sent alarm events. Removing the already sent alarm events. + Device Control: Error storing data of original automatic screen switching-off and dimming parameter values. Used the default values instead. + Device Control: Error fetching data of original automatic screen switching-off and dimming parameter values. Used the default values instead. + Device Control: Error changing automatic screen switching-off and dimming parameter values. + Device Control: Error fetching data of original hardware key settings. + Device Control: Error storing data of original hardware key settings. + Device Control: Error changing hardware key settings. + Device Control: Init script to auto launch the application was not installed/removed. + Device Control: The application failed to know the current mode of itself. + Device Control: The application failed to store the current mode of itself. + Device Control: Error restarting the device. Restart device manually to activate operation mode change. diff --git a/src/BusinessLogic/Engine.cpp b/src/BusinessLogic/Engine.cpp index 009dbdd..962da10 100644 --- a/src/BusinessLogic/Engine.cpp +++ b/src/BusinessLogic/Engine.cpp @@ -240,20 +240,16 @@ void Engine::shownWeekChanged( QDate aFrom ) // fetchMeetings( from, to, iWindowManager->weeklyView()->currentRoom() ); } -void Engine::changeDeviceMode( bool aChange ) +void Engine::changeDeviceMode() { - if ( aChange ) - { - connect( iDevice, SIGNAL( changingModeFailed() ), this, SLOT( changeModeFailed() ) ); - iAutoRefresh->stop(); // Stop the meeting update - } - iDevice->changeMode( aChange ); + connect( iDevice, SIGNAL( changeModeFailed() ), this, SLOT( changeModeFailed() ) ); + iAutoRefresh->stop(); // Stop the meeting update + iDevice->changeMode(); } void Engine::changeModeFailed() { qDebug() << "Engine::progressBarCancelled()"; - iDevice->changeMode( false ); iAutoRefresh->start(); //we start the metting updating } @@ -276,12 +272,15 @@ void Engine::initUserInterface() iWindowManager->show(); iUIManager->showMainView(); + // This triggers the meeting fetching + iUIManager->currentRoomChanged( this->iCurrentRoom ); + qDebug() << "[Engine::initUserInterface] "; } void Engine::handleViewEvent() { - if ( iIdleTimeCounter != 0 ) + if ( iIdleTimeCounter != 0 && iIdleTimeCounter->isActive()) { // Restart the idle time counter when view event is received iIdleTimeCounter->stop(); @@ -369,5 +368,6 @@ void Engine::startIdleTimeCounter() void Engine::currentRoomChanged(Room *aRoom) { + qDebug() << "[Engine::currentRoomChanged] "; iCurrentRoom = aRoom; } \ No newline at end of file diff --git a/src/BusinessLogic/Engine.h b/src/BusinessLogic/Engine.h index 99992dd..dc538ec 100644 --- a/src/BusinessLogic/Engine.h +++ b/src/BusinessLogic/Engine.h @@ -120,7 +120,7 @@ private slots: void stopIdleTimeCounter(); void startIdleTimeCounter(); - void changeDeviceMode( bool aChange ); + void changeDeviceMode(); void currentRoomChanged( Room *aRoom ); diff --git a/src/BusinessLogic/UIManager.cpp b/src/BusinessLogic/UIManager.cpp index ab1bad2..a25e1a7 100644 --- a/src/BusinessLogic/UIManager.cpp +++ b/src/BusinessLogic/UIManager.cpp @@ -37,16 +37,12 @@ UIManager::UIManager( Engine *aEngine, WindowManager *aWindowManager ) : if ( iEngine == 0 ) return; if ( iWindowManager == 0 ) return; - qDebug() << "[UIManager::ctor] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"; - createWeeklyView(); createSettingsView(); createRoomStatusIndicator(); createPasswordDialog(); createProgressBar(); createMeetingInfoDialog(); - - qDebug() << "[UIManager::ctor] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"; } UIManager::~UIManager() @@ -67,15 +63,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() @@ -108,15 +95,13 @@ 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 ) ) ); } void UIManager::createProgressBar() { iProgressBar = new ProgressBar( tr("CHANGE THIS"), true ); - // Connect to UIManager connect( iProgressBar, SIGNAL( cancel() ), this, SLOT( progressBarCancelled() ) ); // Connect to Engine @@ -178,9 +163,9 @@ 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(); } } @@ -220,26 +205,25 @@ void UIManager::progressBarCancelled() if ( iProgressBar != 0 ) { iProgressBar->close(); - iEngine->startIdleTimeCounter(); } } 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 ) ); } } void UIManager::currentRoomChanged(Room *aRoom) { + qDebug() << "[UIManager::currentRoomChanged] "; if ( iWeeklyView != 0 ) { QDateTime from = QDateTime( iWeeklyView->beginnigOfShownWeek() ); @@ -264,15 +248,17 @@ void UIManager::passwordEntered( PasswordDialog::PasswordStatus aStatus ) // Show the progress bar.. if ( iProgressBar != 0 ) { - iWindowManager->showDialog( static_cast( iProgressBar ), false ); + iProgressBar->update( tr( "" ), tr( "Changing operation mode" ) ); + iProgressBar->toggleCancellable( false ); + iWindowManager->showDialog( static_cast( iProgressBar ), false, false ); } // ... and initiate the mode changing - iEngine->changeDeviceMode( true ); + iEngine->changeDeviceMode(); break; case PasswordDialog::Incorrect: iWindowManager->error( tr("Incorrect Password") ); + break; case PasswordDialog::Canceled: - iEngine->changeDeviceMode( false ); break; } diff --git a/src/BusinessLogic/UIManager.h b/src/BusinessLogic/UIManager.h index 0c40c2b..a350bd9 100644 --- a/src/BusinessLogic/UIManager.h +++ b/src/BusinessLogic/UIManager.h @@ -18,6 +18,15 @@ class MeetingInfoDialog; class CommunicationManager; class QDateTime; +//! User Interface manager class. +/*! + * User Interface manager class that is responsible for handling + * UI actions. It creates the needed views and connects signals + * accordingly. All interactions with the UI is handled by this + * class. The Engine class handles the basic logic and does not + * know or care about the UI and this class does not know or care + * about the basic logic only UI related actions (signals, events etc.). + */ class UIManager : public QObject { Q_OBJECT @@ -26,27 +35,80 @@ public: UIManager( Engine *aEngine, WindowManager *aWindowManager ); virtual ~UIManager(); + //! Connects Device Managers signals. + /*! + * This method connects Device Managers signals directly to UI + * components or to it selft. + */ void connectDeviceManager( DeviceManager *aDeviceManager ); + //! Connects Communication Managers signals. + /*! + * This method connects Communication Managers signals directly to UI + * components or to it selft. + */ void connectCommunicationManager( CommunicationManager *aCommunicationManager ); + //! Shows the main view. + /*! + * Makes the main view visible trough WindowManager. + */ void showMainView(); - void showProgressBar( QString aText ); signals: public slots: + //! Handles setting view request. + /*! + * Handles request to show settings view. Makes the + * view visible and stops the idle time counter. + */ void settingsViewRequest(); + //! Handles setting views ok clicked. + /*! + * Handles the setting views Ok button clicked + * signal. Sets the weekly view visible and starts + * the idle time counter. + */ void settingsOkClicked(); + //! Handles setting views cancel clicked. + /*! + * Handles the setting views Cancel button clicked + * signal. Sets the weekly view visible and starts + * the idle time counter. + */ void settingsCancelClicked(); + //! Handles room status indicator view request. + /*! + * Handles the request to show room status indicator + * view. Sets the view visible and stops the idle + * time counter. The WindowManager handles restoring + * what ever view was previously visible. + */ void roomStatusIndicatorRequested(); + //! Handles previousViewRestored signal. + /*! + * Handles the restoring of previous view. This is usually + * signaled by WindowManager when room status indicator + * view is being hidden. + */ void previousViewRestored(); + //! Handle change mode order. + /*! + * Handles change mode order. Displays the password query dialog + * and waits for its response. + */ void changeModeOrdered( DeviceManager::OperationMode aMode ); + //! Handles select room change. + /*! + * Handles the changing of currently select room. Engine is requested + * to start fetching new meetings for currently shown week. + */ + void currentRoomChanged( Room *aRoom ); private slots: void meetingsFetched( const QList &aMeetings ); void meetingDetailsFetched( Meeting &aDetailedMeeting ); - void currentRoomChanged( Room *aRoom ); void progressBarCancelled(); void updateTime( QDateTime aDateTime ); void passwordEntered( PasswordDialog::PasswordStatus aStatus ); diff --git a/src/IO/Communication/CommunicationManager.cpp b/src/IO/Communication/CommunicationManager.cpp index 8174ef7..c941c7d 100644 --- a/src/IO/Communication/CommunicationManager.cpp +++ b/src/IO/Communication/CommunicationManager.cpp @@ -93,12 +93,10 @@ void CommunicationManager::fetchMeetingDetails( Meeting& aMeeting ) void CommunicationManager::cancelFetchMeetingDetails() { - const RequestData *rd = NULL; - for( rd = findRequest( GetCalendarItem );rd != NULL; ) - { - int id = rd->requestId; + const RequestData *rd = findRequest( GetCalendarItem ); + if( rd != NULL ) { + int id = rd->requestId; iCancelledRequests.append( id ); - rd = findRequest( GetCalendarItem ); } } diff --git a/src/IO/DeviceControl/DeviceConfigurator.cpp b/src/IO/DeviceControl/DeviceConfigurator.cpp index 76e17ce..4ac495e 100644 --- a/src/IO/DeviceControl/DeviceConfigurator.cpp +++ b/src/IO/DeviceControl/DeviceConfigurator.cpp @@ -19,6 +19,8 @@ DeviceConfigurator::~DeviceConfigurator() bool DeviceConfigurator::toggleScreenSwitchOff( bool aEnable ) { qDebug() << "DeviceConfigurator::toggleScreenSwitchOff( bool )"; + emit configuringError( DeviceManager::ScreenSettingsNotChanged ); + return false; QString command = "gconftool-2"; QStringList args; QByteArray result; diff --git a/src/IO/DeviceControl/DeviceManager.cpp b/src/IO/DeviceControl/DeviceManager.cpp index 3db5db7..518a7d3 100644 --- a/src/IO/DeviceControl/DeviceManager.cpp +++ b/src/IO/DeviceControl/DeviceManager.cpp @@ -9,7 +9,13 @@ #include #include -DeviceManager::DeviceManager( StartupSettings *aSettings ) +DeviceManager::DeviceManager( StartupSettings *aSettings ) : + iAlarmSender( 0 ), + iHWKeyListener( 0 ), + iSettings( 0 ), + iDataStorage( 0 ), + iConfigurator( 0 ), + iModeToggler( 0 ) { qDebug() << "DeviceManager::DeviceManager( StartupSettings * )"; @@ -35,6 +41,9 @@ DeviceManager::~DeviceManager() void DeviceManager::initDeviceManager() { qDebug() << "DeviceManager::init()"; + + qRegisterMetaType("DeviceManager::ErrorCode"); + iDataStorage = new DeviceDataStorage(); connect( iDataStorage, SIGNAL( dataStorageInitFailed( DeviceManager::ErrorCode ) ), this, SLOT( errorSender( DeviceManager::ErrorCode ) ) ); @@ -51,7 +60,7 @@ void DeviceManager::initDeviceManager() iMode = EmptyMode; iHWKeyListener = new HWKeyListener(); - handleKeyPresses( true ); + handleHWKeyPresses( true ); } DeviceManager::OperationMode DeviceManager::currentOperationMode() @@ -72,20 +81,18 @@ QString DeviceManager::operationModeToString( OperationMode aMode ) } } -void DeviceManager::changeMode( bool aChange ) +void DeviceManager::changeMode() { qDebug() << "void DeviceManager::changeMode()"; - if( !aChange ) { - handleKeyPresses( true ); - return; + if( iModeToggler == 0 ) { + iModeToggler = new OperationModeToggler( iMode, iSettings, iAlarmSender, iConfigurator, iDataStorage ); + connect( iModeToggler, SIGNAL( finished() ), this, SLOT( modeChanged() ) ); + connect( iModeToggler, SIGNAL( error( DeviceManager::ErrorCode, const QString & ) ), + this, SLOT( errorSender( DeviceManager::ErrorCode, const QString & ) ) ); + connect( iModeToggler, SIGNAL( changingMode( const QString & ) ), this, SIGNAL( changingMode( const QString & ) ) ); + connect( iModeToggler, SIGNAL( toggleErrorSending( bool ) ), this, SLOT( toggleErrorSending( bool ) ) ); + iModeToggler->start(); } - iModeToggler = new OperationModeToggler( iMode, iSettings, iAlarmSender, iConfigurator, iDataStorage ); - connect( iModeToggler, SIGNAL( finished() ), this, SLOT( modeChanged() ) ); - connect( iModeToggler, SIGNAL( error( DeviceManager::ErrorCode, const QString & ) ), - this, SLOT( errorSender( DeviceManager::ErrorCode, const QString & ) ) ); - connect( iModeToggler, SIGNAL( changingMode( const QString & ) ), this, SIGNAL( changingMode( const QString & ) ) ); - connect( iModeToggler, SIGNAL( toggleErrorSending( bool ) ), this, SLOT( toggleErrorSending( bool ) ) ); - iModeToggler->start(); } bool DeviceManager::setCurrentOperationMode() @@ -126,25 +133,14 @@ bool DeviceManager::finalizeStandAloneMode() return true; } -void DeviceManager::handleKeyPresses( bool aHandle ) -{ - qDebug() << "DeviceManager::handleKeyPresses( bool )"; - if ( !aHandle ) - disconnect( iHWKeyListener, SIGNAL( HWKeyFullScreenPressed() ), this, SLOT( HWKeyFullScreenPressed() ) ); - else - connect( iHWKeyListener, SIGNAL( HWKeyFullScreenPressed() ), this, SLOT( HWKeyFullScreenPressed() ) ); -} - void DeviceManager::HWKeyFullScreenPressed() { qDebug() << "DeviceManager::HWKeyFullScreenPressed()"; - + handleHWKeyPresses( false ); // no more key presses before this one is handled - handleKeyPresses( false ); - + //handleKeyPresses( false ); OperationMode nextMode; - switch ( iMode ) - { + switch ( iMode ) { case KioskMode: nextMode = StandAloneMode; break; @@ -157,8 +153,6 @@ void DeviceManager::HWKeyFullScreenPressed() } if ( nextMode != EmptyMode ) emit changeModeOrdered( nextMode ); - else - handleKeyPresses( true ); } void DeviceManager::errorSender( DeviceManager::ErrorCode aErrorCode, const QString &aAddInfo ) @@ -181,14 +175,24 @@ void DeviceManager::modeChanged() { qDebug() << "DeviceManager::modeChanged()"; if( iModeToggler != 0 ) { - if ( iModeToggler->success() ) //mode changing went well + if ( iModeToggler->success() ) {//mode changing went well + emit changingMode( "Restarting device" ); + sleep( 2 ); iConfigurator->restartDevice(); + } else emit changeModeFailed(); delete iModeToggler; iModeToggler = 0; } - - //in case device restarting fails we just continue - handleKeyPresses( true ); + handleHWKeyPresses( true ); +} + +void DeviceManager::handleHWKeyPresses( bool aToggle ) +{ + qDebug() << "DeviceManager::handleHWKeyPresses( bool )"; + if( aToggle ) + connect( iHWKeyListener, SIGNAL( HWKeyFullScreenPressed() ), this, SLOT( HWKeyFullScreenPressed() ) ); + else + disconnect( iHWKeyListener, SIGNAL( HWKeyFullScreenPressed() ), this, SLOT( HWKeyFullScreenPressed() ) ); } diff --git a/src/IO/DeviceControl/DeviceManager.h b/src/IO/DeviceControl/DeviceManager.h index 267cf96..2c7531a 100644 --- a/src/IO/DeviceControl/DeviceManager.h +++ b/src/IO/DeviceControl/DeviceManager.h @@ -90,9 +90,9 @@ public: //! Changes the operation mode. /*! * Changes the operation mode. - * \param aChange To indicate if the mode should be changed or not */ - void changeMode( bool aChange ); + void changeMode(); + void handleHWKeyPresses( bool aToggle ); signals: //! Signal. Emitted if user tries to change the operation mode. @@ -164,13 +164,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/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/IO/DeviceControl/OperationModeToggler.cpp b/src/IO/DeviceControl/OperationModeToggler.cpp index cfa5d5d..14f13aa 100644 --- a/src/IO/DeviceControl/OperationModeToggler.cpp +++ b/src/IO/DeviceControl/OperationModeToggler.cpp @@ -22,15 +22,6 @@ OperationModeToggler::OperationModeToggler( iSuccess( true ) { qDebug() << "OperationModeToggler::OperationModeToggler( ... )"; - - qRegisterMetaType("DeviceManager::ErrorCode"); - - connect( iAlarmSender, SIGNAL( alarmSendingFailed( DeviceManager::ErrorCode, const QString& ) ), - this, SIGNAL( error( DeviceManager::ErrorCode, const QString& ) ) ); - connect( iConfigurator, SIGNAL( configuringError( DeviceManager::ErrorCode ) ), - this, SLOT( createError( DeviceManager::ErrorCode ) ) ); - connect( iDataStorage, SIGNAL( dataStorageInitFailed( DeviceManager::ErrorCode ) ), - this, SLOT( createError( DeviceManager::ErrorCode ) ) ); } OperationModeToggler::~OperationModeToggler() @@ -58,6 +49,7 @@ void OperationModeToggler::run() if ( !iAlarmSender->sendAlarms( iSettings->turnOnAt(), iSettings->turnOffAt() ) ) { iSuccess = false; + emit changingMode( "Rolling back changes..." ); return; //this is critical so returning if no success } } @@ -95,6 +87,7 @@ void OperationModeToggler::run() // we have to roll back if something fails // of course rolling back may fail as well but it is impossible to catch emit toggleErrorSending( false ); + emit changingMode( "Rolling back changes..." ); iAlarmSender->removeAlarms(); iConfigurator->toggleHWKeys( true ); iConfigurator->toggleInitScript( false ); @@ -139,6 +132,7 @@ void OperationModeToggler::run() // we have to roll back if something fails // of course rolling back may fail as well but it is impossible to catch emit toggleErrorSending( false ); + emit changingMode( "Rolling back changes..." ); iConfigurator->toggleHWKeys( false ); iConfigurator->toggleInitScript( true ); iConfigurator->toggleScreenSwitchOff( false ); diff --git a/src/UserInterface/Utils/PasswordDialog.cpp b/src/UserInterface/Utils/PasswordDialog.cpp index a31616b..064c7d3 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 ); @@ -51,8 +48,8 @@ PasswordDialog::PasswordDialog( const QString &aPassword, const QString &aText, layout->addLayout( buttonLayout ); // Connect the user action signals to corresponding slots - connect( buttonOK, SIGNAL( pressed() ), this, SLOT( okButtonPressed() ) ); - connect( buttonCancel, SIGNAL( pressed() ), this, SLOT( cancelButtonPressed() ) ); + connect( buttonOK, SIGNAL( released() ), this, SLOT( okButtonPressed() ) ); + connect( buttonCancel, SIGNAL( released() ), this, SLOT( cancelButtonPressed() ) ); // Enable the layout setLayout( layout ); @@ -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..dd9f94f 100755 --- a/src/UserInterface/Utils/ProgressBar.cpp +++ b/src/UserInterface/Utils/ProgressBar.cpp @@ -8,11 +8,12 @@ #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 +27,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 +46,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; }; diff --git a/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp b/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp index c903bc0..dbc2b07 100644 --- a/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp +++ b/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp @@ -6,6 +6,8 @@ #include "DigitalTimeDisplayWidget.h" #include "ToolBox.h" +#include + #include QTime RoomStatusIndicatorWidget::endOfTheDay = QTime( 23, 59, 0, 0 ); @@ -74,25 +76,28 @@ QString RoomStatusIndicatorWidget::statusToText( const Room::Status aStatus ) QPalette RoomStatusIndicatorWidget::createPalette( Room::Status aStatus ) { - QPixmap pixmap( aStatus == Room::BusyStatus ? ":roomstatus_busy" : ":roomstatus_free" ); + // QPixmap pixmap( aStatus == Room::BusyStatus ? ":roomstatus_busy" : ":roomstatus_free" ); + QString image = aStatus == Room::BusyStatus ? ":roomstatus_busy" : ":roomstatus_free"; // The image needs to be moved in normal mode so the traffic light not partly outside the screen const int xoffset( 60 ); const int yoffset( 19 ); - int cropwidth( pixmap.width() - xoffset ); - int cropheight( pixmap.height() - yoffset ); +// int cropwidth( pixmap.width() - xoffset ); +// int cropheight( pixmap.height() - yoffset ); QBrush brush; if ( windowState() == Qt::WindowFullScreen ) { // Use the full image in full screen mode - brush.setTexture( pixmap ); +// brush.setTexture( pixmap ); + brush.setTexture( QPixmap(image) ); } else { // Take part of the image so the traffic lights are moved xoffset poxels to left // and yoffset pixels to up - brush.setTexture( pixmap.copy( xoffset, yoffset, cropwidth, cropheight ) ); +// brush.setTexture( pixmap.copy( xoffset, yoffset, cropwidth, cropheight ) ); + brush.setTexture( QPixmap(image) ); } QPalette palette; @@ -117,4 +122,26 @@ void RoomStatusIndicatorWidget::statusChanged( const Room::Status aStatus, const iUntilTextLabel->setText( tr( "until %1" ).arg( aUntil.toString( iTimeFormat ) ) ); } setPalette( createPalette( aStatus ) ); +} + +void RoomStatusIndicatorWidget::currentRoomChanged( Room *aRoom ) +{ + iDefaultRoomLabel->setText( aRoom->name() ); +} + +bool RoomStatusIndicatorWidget::event(QEvent *event) +{ + switch(event->type()) + { + case QEvent::Paint: + qDebug() << "[RoomStatusIndicatorWidget::event] "; + break; + case QEvent::PaletteChange: + qDebug() << "[RoomStatusIndicatorWidget::event] "; + break; + default: + break; + } + + return ViewBase::event( event ); } diff --git a/src/UserInterface/Views/RoomStatusIndicatorWidget.h b/src/UserInterface/Views/RoomStatusIndicatorWidget.h index c20ce45..67d40dc 100644 --- a/src/UserInterface/Views/RoomStatusIndicatorWidget.h +++ b/src/UserInterface/Views/RoomStatusIndicatorWidget.h @@ -12,6 +12,8 @@ class QLabel; class QVBoxLayout; class TimeDisplayWidget; +class QEvent; + //! UserInterface class. Indicates if the default meeting room is busy or not. /*! * UserInterface class. Indicates if the default meeting room is busy or not. This widget @@ -37,6 +39,8 @@ public: RoomStatusIndicatorWidget( Room *aDefaultRoom, Room::Status aStatus, QTime aUntil, QString aTimeFormat, QWidget *aParent = 0 ); //! Destructor. virtual ~RoomStatusIndicatorWidget(); + + bool event(QEvent *event); public slots: //! Slot. Sets current time.