From: itkonma Date: Mon, 1 Jun 2009 08:50:08 +0000 (+0300) Subject: Merge branch 'dev_itkonma' X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;h=a85316b005e03207e250a47aae018cfcd15c7bc7;hp=55915c819fb472acaf93f560bad7a11a4ad89828;p=qtmeetings Merge branch 'dev_itkonma' Conflicts: src/BusinessLogic/UIManager.cpp src/BusinessLogic/UIManager.h src/Domain/Configuration/Configuration.cpp --- 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..aac84d4 100644 --- a/src/BusinessLogic/Engine.cpp +++ b/src/BusinessLogic/Engine.cpp @@ -32,6 +32,8 @@ Engine::Engine() : iWindowManager( 0 ), iUIManager( 0 ) { qDebug() << "Engine::Engine()"; + iCommunicationFailed = false; + iCurrentWeekFetched = false; initConfiguration(); initDevice(); @@ -107,7 +109,7 @@ void Engine::checkStatusOfAllRooms() for (int i = 0; i < iConfiguration->rooms().count(); i++) { // and check the status - roomStatusInfoNeeded(iConfiguration->rooms().at(i) ); + roomStatusInfoNeeded( iConfiguration->rooms().at(i) ); } } @@ -164,39 +166,31 @@ void Engine::roomStatusInfoNeeded(Room *aRoom) ( ( indexOfNextMeeting != -1 ) ? iMeetings.at( indexOfNextMeeting )->startsAt().time() : Engine::endOfTheDay ); //currently works only for deafult room -// if( aRoom->equals( *(defaultRoom() ) ) ) -// iWindowManager->roomStatusChanged( aRoom, status, until ); -} - -/* -void Engine::fetchMeetings() -{ - qDebug() << "Engine::fetchMeetings for " << iCurrentRoom; - QDateTime from( iWindowManager->weeklyView()->beginnigOfShownWeek() ); - QDateTime to( from.addDays( 7 ) ); - // fetchMeetings( from, to, iWindowManager->weeklyView()->currentRoom() ); - // Signal is connected to the currentRoomChanged slot which keeps the iCurrentRoom up to date - fetchMeetings( from, to, iCurrentRoom ); + if ( aRoom->equals( *(iCurrentRoom) ) ) + { + emit roomStatusChanged( status, until ); + } } -*/ void Engine::fetchMeetingDetails( Meeting *aMeeting ) { qDebug() << "Engine::fetchMeetingDetails( Meeting* )"; -/* iWindowManager->showProgressBar(tr("Please Wait"), true); - iWindowManager->updateProgressBar(tr("Fetching Meeting Details...") ); - connect(iWindowManager, - SIGNAL( progressBarCancelled() ), this, - SLOT( fetchMeetingDetailsCancelled() )); - iCommunication->fetchMeetingDetails( *aMeeting); */ iCommunication->fetchMeetingDetails( *aMeeting ); } void Engine::meetingsFetched( const QList &aMeetings ) { qDebug() << "Engine::meetingsFetched( const QList & )"; - - for ( int i = 0; i < iMeetings.count(); ++i ) { + // TODO: should check if this week's meetings were fetched + if( iCommunicationFailed || !iCurrentWeekFetched ) + { + iCurrentWeekFetched = true; + iCommunicationFailed = false; + iUIManager->connectionEstablished(); + } + + for ( int i = 0; i < iMeetings.count(); ++i ) + { Meeting* m = iMeetings.takeAt( i ); delete m; } @@ -207,11 +201,16 @@ void Engine::meetingsFetched( const QList &aMeetings ) } // refresh room status info - roomStatusInfoNeeded( defaultRoom() ); + roomStatusInfoNeeded( iCurrentRoom /*defaultRoom()*/ ); } void Engine::errorHandler( int aCode, const QString &aAddInfo ) { + if( aCode >= 100 && aCode < 150 ) + { + iCommunicationFailed = true; + if ( iUIManager != 0 ) iUIManager->connectionLost(); + } if ( iWindowManager != 0 ) { iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) ); @@ -236,24 +235,19 @@ void Engine::shownWeekChanged( QDate aFrom ) QDateTime from( aFrom ); QDateTime to( aFrom.addDays( 7 ), QTime( 23, 59 ) ); qDebug() << "[Engine::shownWeekChanged] "; - iCommunication->fetchMeetings( from, to, *defaultRoom() ); -// fetchMeetings( from, to, iWindowManager->weeklyView()->currentRoom() ); + iCommunication->fetchMeetings( from, to, *iCurrentRoom/*defaultRoom()*/ ); } -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 +270,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 +366,7 @@ void Engine::startIdleTimeCounter() void Engine::currentRoomChanged(Room *aRoom) { + qDebug() << "[Engine::currentRoomChanged] "; iCurrentRoom = aRoom; -} \ No newline at end of file + roomStatusInfoNeeded( iCurrentRoom ); +} diff --git a/src/BusinessLogic/Engine.h b/src/BusinessLogic/Engine.h index 99992dd..6bacdd8 100644 --- a/src/BusinessLogic/Engine.h +++ b/src/BusinessLogic/Engine.h @@ -41,6 +41,8 @@ public: signals: + void roomStatusChanged( Room::Status aStatus, QTime aUntil ); + private slots: //! Slot. Closes the application. /*! @@ -67,12 +69,6 @@ private slots: * \param aAddInfo Possible addition info. */ void errorHandler( int aCode, const QString &aAddInfo = "" ); - //! Slot. Fetches meetings from the server. - /*! - * Slot. Fetches meetings from the server. Parameters are hard coded: the meetings of the default - * room from current and +/- 2 weeks are fetched. - */ -// void fetchMeetings(); //! Slot. Saves fetched meetings to the current instance's local storage. /*! * Slot. Saves fetched meetings to the current instance's local storage. Meetings are soted in a @@ -120,7 +116,7 @@ private slots: void stopIdleTimeCounter(); void startIdleTimeCounter(); - void changeDeviceMode( bool aChange ); + void changeDeviceMode(); void currentRoomChanged( Room *aRoom ); @@ -206,6 +202,8 @@ private: QList iMeetings; Room *iCurrentRoom; + bool iCommunicationFailed; + bool iCurrentWeekFetched; }; #endif /*ENGINE_H_*/ diff --git a/src/BusinessLogic/UIManager.cpp b/src/BusinessLogic/UIManager.cpp index e4cdc67..59db6d7 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() @@ -103,20 +90,20 @@ void UIManager::createSettingsView() void UIManager::createRoomStatusIndicator() { - iRoomStatusIndicator = new RoomStatusIndicatorWidget( iEngine->defaultRoom(), Room::FreeStatus, QTime::currentTime(), iEngine->iConfiguration->displaySettings()->dateFormat() ); + iRoomStatusIndicator = new RoomStatusIndicatorWidget( iEngine->defaultRoom(), Room::FreeStatus, QTime::currentTime(), iEngine->iConfiguration->displaySettings()->timeFormat() ); + connect( iEngine, SIGNAL( roomStatusChanged( Room::Status, QTime ) ), iRoomStatusIndicator, SLOT( statusChanged( Room::Status, QTime ) ) ); + connect( iWeeklyView, SIGNAL( currentRoomChanged( Room * ) ), iRoomStatusIndicator, SLOT( currentRoomChanged( Room * ) ) ); } 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 +165,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 +207,41 @@ 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::connectionLost() +{ + qDebug() << "UIManager::connectionLost()"; + iWeeklyView->connectionLost(); + iSettingsView->connectionLost(); + iRoomStatusIndicator->connectionLost(); +} + +void UIManager::connectionEstablished() +{ + qDebug() << "UIManager::connectionEstablished()"; + iWeeklyView->connectionEstablished(); + iSettingsView->connectionEstablished(); + iRoomStatusIndicator->connectionEstablished(); +} + void UIManager::currentRoomChanged(Room *aRoom) { + qDebug() << "[UIManager::currentRoomChanged] "; if ( iWeeklyView != 0 ) { QDateTime from = QDateTime( iWeeklyView->beginnigOfShownWeek() ); @@ -254,6 +256,10 @@ void UIManager::updateTime(QDateTime aDateTime) { iWeeklyView->setCurrentDateTime( aDateTime ); } + if ( iRoomStatusIndicator != 0 ) + { + iRoomStatusIndicator->setCurrentTime( aDateTime.time() ); + } } void UIManager::passwordEntered( PasswordDialog::PasswordStatus aStatus ) @@ -264,15 +270,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; } @@ -308,4 +316,4 @@ void UIManager::settingsCancelClicked() iWindowManager->showView( static_cast( iWeeklyView ) ); iEngine->startIdleTimeCounter(); } -} +} \ No newline at end of file diff --git a/src/BusinessLogic/UIManager.h b/src/BusinessLogic/UIManager.h index 0c40c2b..3a17d45 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,87 @@ 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 ); + + //! Shows any view specific indicators for connection error + void connectionLost(); + + //! Removes any view specific indicators for connection error + void connectionEstablished(); + 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/Domain/Configuration/Configuration.cpp b/src/Domain/Configuration/Configuration.cpp index 54648ca..2a33998 100644 --- a/src/Domain/Configuration/Configuration.cpp +++ b/src/Domain/Configuration/Configuration.cpp @@ -155,7 +155,6 @@ void Configuration::saveConnectionSettings( const QDomNode &aXML ) { QDomElement e = node.toElement(); QString tagName = e.tagName().toLower(); - if ( tagName == QString( "serverurl" ) ) { QDomText t = node.ownerDocument().createTextNode( iConnectionSettings->serverUrl().toString() ); @@ -211,7 +210,7 @@ void Configuration::saveRooms( const QDomNode &aXML ) int count = root.childNodes().count(); QDomNode node = root.firstChild(); QDomNode next; - for (int i=0; irequestId; + 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..a1f75a1 100644 --- a/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp +++ b/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp @@ -1,120 +1,165 @@ -#include "RoomStatusIndicatorWidget.h" - -#include -#include -#include -#include "DigitalTimeDisplayWidget.h" -#include "ToolBox.h" - -#include - -QTime RoomStatusIndicatorWidget::endOfTheDay = QTime( 23, 59, 0, 0 ); - -RoomStatusIndicatorWidget::RoomStatusIndicatorWidget( Room *aDefaultRoom, Room::Status aStatus, QTime aUntil, QString aTimeFormat, QWidget *aParent ) : - ViewBase( ViewBase::ObservedView, aParent ), iTimeFormat( aTimeFormat ) -{ - QFont importantTextFont; - //importantTextFont.setBold( true ); - importantTextFont.setPointSize( 20 ); - - QFont regularTextFont; - //regularTextFont.setBold( true ); - regularTextFont.setPointSize( 12 ); - - // display for current time - // Note: the time display receives current time info from Engine::clock() - iTimeDisplay = new DigitalTimeDisplayWidget( QTime::currentTime(), iTimeFormat, this ); - iTimeDisplay->setFrameVisible( false ); - iTimeDisplay->setSize( 250, 120 ); - - // Pegasus - iDefaultRoomLabel = ToolBox::createLabel( aDefaultRoom->name(), importantTextFont ); - iDefaultRoomLabel->setAlignment( Qt::AlignHCenter ); - iDefaultRoomLabel->setStyleSheet( "background-color: transparent" ); - // is busy - iStatusLabel = ToolBox::createLabel( tr( "is %1" ).arg( statusToText( aStatus ) ), importantTextFont ); - iStatusLabel->setAlignment( Qt::AlignHCenter ); - iStatusLabel->setStyleSheet( "background-color: transparent" ); - - // until 13:22 - iUntilTextLabel = ToolBox::createLabel( tr( "until %1" ).arg( aUntil.toString( iTimeFormat ) ), importantTextFont ); - iUntilTextLabel->setAlignment( Qt::AlignHCenter ); - iUntilTextLabel->setStyleSheet( "background-color: transparent" ); - - QVBoxLayout *topLayout = new QVBoxLayout; - topLayout->addStretch(); - topLayout->addWidget( iTimeDisplay ); - topLayout->addWidget( iDefaultRoomLabel ); - topLayout->addWidget( iStatusLabel ); - topLayout->addWidget( iUntilTextLabel ); - topLayout->addStretch(); - - QHBoxLayout *mainLayout = new QHBoxLayout; - mainLayout->addLayout( topLayout ); - mainLayout->addStretch(); - mainLayout->setMargin( 65 ); - setLayout( mainLayout ); - - statusChanged( aStatus, aUntil ); - - setFocusPolicy( Qt::StrongFocus ); - setEnabled( true ); // enable mouse & key events -} - -RoomStatusIndicatorWidget::~RoomStatusIndicatorWidget() -{ - delete iTimeDisplay; - iTimeDisplay = 0; -} - -QString RoomStatusIndicatorWidget::statusToText( const Room::Status aStatus ) -{ - return ( aStatus == Room::BusyStatus ) ? tr( "busy" ) : tr( "free" ); -} - -QPalette RoomStatusIndicatorWidget::createPalette( Room::Status aStatus ) -{ - QPixmap pixmap( 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 ); - - QBrush brush; - if ( windowState() == Qt::WindowFullScreen ) - { - // Use the full image in full screen mode - brush.setTexture( pixmap ); - } - 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 ) ); - } - - QPalette palette; - palette.setBrush( QPalette::Window, brush ); - return palette; -} - -void RoomStatusIndicatorWidget::setCurrentTime( QTime aCurrentTime ) -{ - iTimeDisplay->setTime( aCurrentTime ); -} - -void RoomStatusIndicatorWidget::statusChanged( const Room::Status aStatus, const QTime aUntil ) -{ - iStatusLabel->setText( tr( "is %1" ).arg( statusToText( aStatus ) ) ); - if ( aUntil == RoomStatusIndicatorWidget::endOfTheDay ) - { - iUntilTextLabel->setText( tr( "whole day." ) ); - } - else - { - iUntilTextLabel->setText( tr( "until %1" ).arg( aUntil.toString( iTimeFormat ) ) ); - } - setPalette( createPalette( aStatus ) ); -} +#include "RoomStatusIndicatorWidget.h" + +#include +#include +#include +#include "DigitalTimeDisplayWidget.h" +#include "ToolBox.h" + +#include + +#include + +QTime RoomStatusIndicatorWidget::endOfTheDay = QTime( 23, 59, 0, 0 ); + +RoomStatusIndicatorWidget::RoomStatusIndicatorWidget( Room *aDefaultRoom, Room::Status aStatus, QTime aUntil, QString aTimeFormat, QWidget *aParent ) : + ViewBase( ViewBase::ObservedView, aParent ), iTimeFormat( aTimeFormat ) +{ + QFont importantTextFont; + //importantTextFont.setBold( true ); + importantTextFont.setPointSize( 20 ); + + QFont regularTextFont; + //regularTextFont.setBold( true ); + regularTextFont.setPointSize( 12 ); + + // display for current time + // Note: the time display receives current time info from Engine::clock() + iTimeDisplay = new DigitalTimeDisplayWidget( QTime::currentTime(), iTimeFormat, this ); + iTimeDisplay->setFrameVisible( false ); + iTimeDisplay->setSize( 250, 120 ); + + // Pegasus + iDefaultRoomLabel = ToolBox::createLabel( aDefaultRoom->name(), importantTextFont ); + iDefaultRoomLabel->setAlignment( Qt::AlignHCenter ); + iDefaultRoomLabel->setStyleSheet( "background-color: transparent" ); + iDefaultRoomLabel->setHidden( true ); + + // is busy + iStatusLabel = ToolBox::createLabel( tr( "is %1" ).arg( statusToText( aStatus ) ), importantTextFont ); + iStatusLabel->setAlignment( Qt::AlignHCenter ); + iStatusLabel->setStyleSheet( "background-color: transparent" ); + iStatusLabel->setHidden( true ); + + // until 13:22 + iUntilTextLabel = ToolBox::createLabel( tr( "until %1" ).arg( aUntil.toString( iTimeFormat ) ), importantTextFont ); + iUntilTextLabel->setAlignment( Qt::AlignHCenter ); + iUntilTextLabel->setStyleSheet( "background-color: transparent" ); + iUntilTextLabel->setHidden( true ); + + // No connection to server note + qDebug() << "RoomStatusIndicatorWidget::RoomStatusIndicatorWidget() creating connection label"; + QFrame* connectionLabelFrame = new QFrame( this ); + iConnectionLabel = new QLabel( tr( "No connection to server" ), connectionLabelFrame ); + iConnectionLabel->setFont( importantTextFont ); + iConnectionLabel->setAlignment( Qt::AlignHCenter ); + iConnectionLabel->setWordWrap( true ); + iConnectionLabel->setStyleSheet( "background-color: transparent; color: red; text-decoration:blink; max-width: 250px" ); + connectionLabelFrame->setFixedSize( iConnectionLabel->sizeHint() ); + if( connectedOnce && !connectionError ) iConnectionLabel->setHidden( true ); + + + QVBoxLayout *topLayout = new QVBoxLayout; + topLayout->addStretch(); + topLayout->addWidget( iTimeDisplay ); + topLayout->addSpacing( 28 ); + topLayout->addWidget( iDefaultRoomLabel ); + topLayout->addWidget( iStatusLabel ); + topLayout->addWidget( iUntilTextLabel ); + topLayout->addSpacing( 28 ); + topLayout->addWidget( connectionLabelFrame ); + topLayout->addStretch(); + + QHBoxLayout *mainLayout = new QHBoxLayout; + mainLayout->addLayout( topLayout ); + mainLayout->addStretch(); + //mainLayout->setMargin( 65 ); + mainLayout->setContentsMargins( 65, 65, 65, 0 ); + setLayout( mainLayout ); + + statusChanged( aStatus, aUntil ); + + setFocusPolicy( Qt::StrongFocus ); + setEnabled( true ); // enable mouse & key events +} + +RoomStatusIndicatorWidget::~RoomStatusIndicatorWidget() +{ + delete iTimeDisplay; + iTimeDisplay = 0; +} + +QString RoomStatusIndicatorWidget::statusToText( const Room::Status aStatus ) +{ + return ( aStatus == Room::BusyStatus ) ? tr( "busy" ) : tr( "free" ); +} + +QPalette RoomStatusIndicatorWidget::createPalette( Room::Status aStatus ) +{ + QString image = aStatus == Room::BusyStatus ? ":roomstatus_busy" : ":roomstatus_free"; + QPixmap pixmap( image ); + + // 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 ); + + QBrush brush; + if ( windowState() == Qt::WindowFullScreen ) + { + // Use the full image in full screen mode + brush.setTexture( pixmap ); + } + 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 ) ); + } + + QPalette palette; + palette.setBrush( QPalette::Window, brush ); + return palette; +} + +void RoomStatusIndicatorWidget::setCurrentTime( QTime aCurrentTime ) +{ + iTimeDisplay->setTime( aCurrentTime ); +} + +void RoomStatusIndicatorWidget::statusChanged( const Room::Status aStatus, const QTime aUntil ) +{ + iStatusLabel->setText( tr( "is %1" ).arg( statusToText( aStatus ) ) ); + if ( aUntil == RoomStatusIndicatorWidget::endOfTheDay ) + { + iUntilTextLabel->setText( tr( "whole day." ) ); + } + else + { + 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..643160a 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. @@ -56,8 +60,14 @@ public slots: */ void statusChanged( const Room::Status aStatus, const QTime aUntil ); + void currentRoomChanged( Room *aRoom ); + void viewResized(const QSize &newSize, const QSize &oldSize) { } + void connectionEstablished(); + + void connectionLost(); + private: //! Translates the status into human readable text. /*! @@ -78,6 +88,7 @@ private: QLabel *iDefaultRoomLabel; QLabel *iStatusLabel; QLabel *iUntilTextLabel; + QLabel *iConnectionLabel; TimeDisplayWidget *iTimeDisplay; QString iTimeFormat; diff --git a/src/UserInterface/Views/ViewBase.cpp b/src/UserInterface/Views/ViewBase.cpp index 24d6461..14c51aa 100644 --- a/src/UserInterface/Views/ViewBase.cpp +++ b/src/UserInterface/Views/ViewBase.cpp @@ -12,7 +12,8 @@ ViewBase::ViewBase( ViewBase::ViewMode aMode, QWidget *aParent ) : QWidget( aParent ), iViewMode( aMode ) { - + connectedOnce = false; + connectionError = false; } ViewBase::~ViewBase() @@ -25,6 +26,18 @@ ViewBase::ViewMode ViewBase::viewMode() return iViewMode; } +void ViewBase::connectionEstablished() +{ + connectedOnce = true; + connectionError = false; +} + +void ViewBase::connectionLost() +{ + connectionError = true; +} + + bool ViewBase::event(QEvent *event) { switch( event->type() ) diff --git a/src/UserInterface/Views/ViewBase.h b/src/UserInterface/Views/ViewBase.h index 631a089..2a7b73e 100644 --- a/src/UserInterface/Views/ViewBase.h +++ b/src/UserInterface/Views/ViewBase.h @@ -51,6 +51,10 @@ public slots: */ virtual void viewResized(const QSize &newSize, const QSize &oldSize) = 0; + void connectionEstablished(); + + void connectionLost(); + signals: /*! * This signal indicates that some user initiated event has occured. @@ -60,10 +64,12 @@ signals: protected: void observeChild(QWidget *aChild); + bool connectionError; // true if last connection attempt failed + // TODO: connectedOnce should actually indicate if the current week has been fetched at least once + bool connectedOnce; // true if connection has been formed at least once private: ViewMode iViewMode; - }; #endif /*VIEWBASE_*/ diff --git a/src/UserInterface/WindowManager.h b/src/UserInterface/WindowManager.h index 2f46050..aa736cf 100644 --- a/src/UserInterface/WindowManager.h +++ b/src/UserInterface/WindowManager.h @@ -1,107 +1,107 @@ -#ifndef WINDOWMANAGER_H_ -#define WINDOWMANAGER_H_ - -#include -#include - -// Forward declarations -class ViewBase; -class QEvent; -class QSize; -class QDialog; -class QString; - -//! UserInterface class. Manages displayed views. -/*! - * UserInterface class. WindowManager class is responsible for displaying views that inherit the - * ViewBase class. It also handles dialog showing. Depending on the views type the WindowManager - * can track the views events and restore previous view if the current on is ObservedView. This - * is a handy mechanism for screensaver etc. - */ -class WindowManager : public QWidget -{ - Q_OBJECT - -public: - //! Constructor. - /*! - * Constructor of WindowManager. - */ - WindowManager( QWidget *aParent = 0 ); - //! Destructor. - virtual ~WindowManager(); - - virtual bool event(QEvent *event); - -signals: - //! Request current status of the room. - /*! - * Signal is emitted when there is need to check current status of room aRoom. - * \param aRoom Meetingroom which status is requested. - */ - void eventDetected(); - - //! The view size is changed. - /*! - * This signal is emitted when the window managers view changes, - * i.e. it received resized QEvent. - * \param The new view size. - */ - void viewResized(const QSize &newSize, const QSize &oldSize); - - //! Previous view is restored. - /*! - * This signal is emitted when previously stored view is - * restored. This happens when view with type ViewMode::ObservedView - * is shown and it receives an event that initiates the view - * restoring chain. - */ - void previousViewRestored(); - - void dialogActivated(); - void dialogDeactivated(); - -public slots: - //! Shows the view. - /*! - * Show view that inherits ViewBase class. If the views parent is not - * the WindowManager it will changed within this method. Depeding on the - * views type the currently active view might be stored and restored - * when specific event occurs in the view to be displayed. - */ - void showView( ViewBase *view ); - - //! Shows modal dialog. - /*! - * Shows modal dialog. Emits dialogActivated() signal prior calling - * QDialog's exec() method and emits dialogDeactivated signal when - * the exec() method returns. - */ - void showDialog( QDialog *aDialog, bool blocking = true, bool aSendSignal = true ); - - //! View event is detected. - /*! - * WindowManager connects this slot to ViewBase classes eventDetected() - * signal and either emits eventDetected() signal if the current views - * type is ViewMode::NormalView or restores possible previous view - * if the current views type is ViewMode::ObservedView. - */ - void viewEventDetected(); - - void setFullscreen(); - - void error( const QString &aErrorMessage ); - -private: - //! Name of the application. - QString iApplicationName; - - //! Currently active view. - ViewBase *iCurrentView; - - //! Stack of views previously displayed. - QStack iViewList; - -}; - -#endif /*WINDOWMANAGER_H_*/ +#ifndef WINDOWMANAGER_H_ +#define WINDOWMANAGER_H_ + +#include +#include + +// Forward declarations +class ViewBase; +class QEvent; +class QSize; +class QDialog; +class QString; + +//! UserInterface class. Manages displayed views. +/*! + * UserInterface class. WindowManager class is responsible for displaying views that inherit the + * ViewBase class. It also handles dialog showing. Depending on the views type the WindowManager + * can track the views events and restore previous view if the current on is ObservedView. This + * is a handy mechanism for screensaver etc. + */ +class WindowManager : public QWidget +{ + Q_OBJECT + +public: + //! Constructor. + /*! + * Constructor of WindowManager. + */ + WindowManager( QWidget *aParent = 0 ); + //! Destructor. + virtual ~WindowManager(); + + virtual bool event(QEvent *event); + +signals: + //! Request current status of the room. + /*! + * Signal is emitted when there is need to check current status of room aRoom. + * \param aRoom Meetingroom which status is requested. + */ + void eventDetected(); + + //! The view size is changed. + /*! + * This signal is emitted when the window managers view changes, + * i.e. it received resized QEvent. + * \param The new view size. + */ + void viewResized(const QSize &newSize, const QSize &oldSize); + + //! Previous view is restored. + /*! + * This signal is emitted when previously stored view is + * restored. This happens when view with type ViewMode::ObservedView + * is shown and it receives an event that initiates the view + * restoring chain. + */ + void previousViewRestored(); + + void dialogActivated(); + void dialogDeactivated(); + +public slots: + //! Shows the view. + /*! + * Show view that inherits ViewBase class. If the views parent is not + * the WindowManager it will changed within this method. Depeding on the + * views type the currently active view might be stored and restored + * when specific event occurs in the view to be displayed. + */ + void showView( ViewBase *view ); + + //! Shows modal dialog. + /*! + * Shows modal dialog. Emits dialogActivated() signal prior calling + * QDialog's exec() method and emits dialogDeactivated signal when + * the exec() method returns. + */ + void showDialog( QDialog *aDialog, bool blocking = true, bool aSendSignal = true ); + + //! View event is detected. + /*! + * WindowManager connects this slot to ViewBase classes eventDetected() + * signal and either emits eventDetected() signal if the current views + * type is ViewMode::NormalView or restores possible previous view + * if the current views type is ViewMode::ObservedView. + */ + void viewEventDetected(); + + void setFullscreen(); + + void error( const QString &aErrorMessage ); + +private: + //! Name of the application. + QString iApplicationName; + + //! Currently active view. + ViewBase *iCurrentView; + + //! Stack of views previously displayed. + QStack iViewList; + +}; + +#endif /*WINDOWMANAGER_H_*/