From f902a21a9d18bf6f92a114f86ac4c39d00fff4dc Mon Sep 17 00:00:00 2001 From: Zoltan Papp Date: Thu, 28 May 2009 13:11:27 +0300 Subject: [PATCH] Changes to screen saver mode connection status handling --- src/BusinessLogic/Engine.cpp | 11 ++++---- src/BusinessLogic/Engine.h | 1 + src/BusinessLogic/UIManager.cpp | 16 +++++++++++ src/BusinessLogic/UIManager.h | 6 +++++ .../Views/RoomStatusIndicatorWidget.cpp | 28 +++++++++++++++++++- .../Views/RoomStatusIndicatorWidget.h | 4 +++ src/UserInterface/Views/ViewBase.cpp | 12 +++++++++ src/UserInterface/Views/ViewBase.h | 8 +++++- src/UserInterface/WindowManager.cpp | 13 --------- src/UserInterface/WindowManager.h | 7 ----- 10 files changed, 79 insertions(+), 27 deletions(-) diff --git a/src/BusinessLogic/Engine.cpp b/src/BusinessLogic/Engine.cpp index 195b0aa..3a5d24f 100644 --- a/src/BusinessLogic/Engine.cpp +++ b/src/BusinessLogic/Engine.cpp @@ -33,6 +33,7 @@ Engine::Engine() : { qDebug() << "Engine::Engine()"; iCommunicationFailed = false; + iCurrentWeekFetched = false; initConfiguration(); initDevice(); @@ -196,10 +197,12 @@ void Engine::fetchMeetingDetails( Meeting *aMeeting ) void Engine::meetingsFetched( const QList &aMeetings ) { qDebug() << "Engine::meetingsFetched( const QList & )"; - if( iCommunicationFailed ) + // TODO: should check if this week's meetings were fetched + if( iCommunicationFailed || !iCurrentWeekFetched ) { + iCurrentWeekFetched = true; iCommunicationFailed = false; - iWindowManager->connectionEstablished(); + iUIManager->connectionEstablished(); } for ( int i = 0; i < iMeetings.count(); ++i ) @@ -222,8 +225,7 @@ void Engine::errorHandler( int aCode, const QString &aAddInfo ) if( aCode >= 100 && aCode < 150 ) { iCommunicationFailed = true; - //TODO: Call window manager - //if ( iWindowManager != 0 ) iWindowManager->connectionLost(); + if ( iUIManager != 0 ) iUIManager->connectionLost(); } if ( iWindowManager != 0 ) { @@ -256,7 +258,6 @@ void Engine::shownWeekChanged( QDate aFrom ) void Engine::changeDeviceMode( bool aChange ) { if ( aChange ) - } { connect( iDevice, SIGNAL( changingModeFailed() ), this, SLOT( changeModeFailed() ) ); iAutoRefresh->stop(); // Stop the meeting update diff --git a/src/BusinessLogic/Engine.h b/src/BusinessLogic/Engine.h index 69239d4..b0be476 100644 --- a/src/BusinessLogic/Engine.h +++ b/src/BusinessLogic/Engine.h @@ -207,6 +207,7 @@ private: Room *iCurrentRoom; bool iCommunicationFailed; + bool iCurrentWeekFetched; }; #endif /*ENGINE_H_*/ diff --git a/src/BusinessLogic/UIManager.cpp b/src/BusinessLogic/UIManager.cpp index d6d16b3..a540f96 100644 --- a/src/BusinessLogic/UIManager.cpp +++ b/src/BusinessLogic/UIManager.cpp @@ -237,6 +237,22 @@ void UIManager::changeModeOrdered( DeviceManager::OperationMode aMode ) } } +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) { if ( iWeeklyView != 0 ) diff --git a/src/BusinessLogic/UIManager.h b/src/BusinessLogic/UIManager.h index de123b6..6721510 100644 --- a/src/BusinessLogic/UIManager.h +++ b/src/BusinessLogic/UIManager.h @@ -40,6 +40,12 @@ public slots: void roomStatusIndicatorRequested(); void previousViewRestored(); void changeModeOrdered( DeviceManager::OperationMode aMode ); + + //! Shows any view specific indicators for connection error + void connectionLost(); + + //! Removes any view specific indicators for connection error + void connectionEstablished(); private slots: diff --git a/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp b/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp index ce5c8eb..60d9253 100644 --- a/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp +++ b/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp @@ -31,15 +31,19 @@ RoomStatusIndicatorWidget::RoomStatusIndicatorWidget( Room *aDefaultRoom, Room:: 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"; @@ -50,7 +54,8 @@ RoomStatusIndicatorWidget::RoomStatusIndicatorWidget( Room *aDefaultRoom, Room:: iConnectionLabel->setWordWrap( true ); iConnectionLabel->setStyleSheet( "background-color: transparent; color: red; text-decoration:blink; max-width: 250px" ); connectionLabelFrame->setFixedSize( iConnectionLabel->sizeHint() ); - //iConnectionLabel->setHidden( true ); + if( connectedOnce && !connectionError ) iConnectionLabel->setHidden( true ); + QVBoxLayout *topLayout = new QVBoxLayout; topLayout->addStretch(); @@ -133,3 +138,24 @@ void RoomStatusIndicatorWidget::statusChanged( const Room::Status aStatus, const } setPalette( createPalette( aStatus ) ); } + +void RoomStatusIndicatorWidget::connectionEstablished() +{ + if( !connectedOnce ) + { + // Just got the required meetings for the first time + qDebug() << "RoomStatusIndicatorWidget::connectionEstablished() first call"; + iDefaultRoomLabel->setHidden( false ); + iUntilTextLabel->setHidden( false ); + iStatusLabel->setHidden( false ); + } + ViewBase::connectionEstablished(); + iConnectionLabel->setHidden( true ); +} + +void RoomStatusIndicatorWidget::connectionLost() +{ + ViewBase::connectionLost(); + iConnectionLabel->setHidden( false ); +} + diff --git a/src/UserInterface/Views/RoomStatusIndicatorWidget.h b/src/UserInterface/Views/RoomStatusIndicatorWidget.h index 465c6e1..736d230 100644 --- a/src/UserInterface/Views/RoomStatusIndicatorWidget.h +++ b/src/UserInterface/Views/RoomStatusIndicatorWidget.h @@ -58,6 +58,10 @@ public slots: void viewResized(const QSize &newSize, const QSize &oldSize) { } + void connectionEstablished(); + + void connectionLost(); + private: //! Translates the status into human readable text. /*! diff --git a/src/UserInterface/Views/ViewBase.cpp b/src/UserInterface/Views/ViewBase.cpp index 24d6461..902f177 100644 --- a/src/UserInterface/Views/ViewBase.cpp +++ b/src/UserInterface/Views/ViewBase.cpp @@ -25,6 +25,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.cpp b/src/UserInterface/WindowManager.cpp index f4b7aea..af006f1 100644 --- a/src/UserInterface/WindowManager.cpp +++ b/src/UserInterface/WindowManager.cpp @@ -126,16 +126,3 @@ void WindowManager::setFullscreen() this->setWindowState( Qt::WindowFullScreen ); // Resize event handles the rest. } - -void WindowManager::connectionLost() -{ - //TODO: Inform all views - qDebug() << "WindowManager::connectionLost()"; -} - -void WindowManager::connectionEstablished() -{ - //TODO: Inform all views - qDebug() << "WindowManager::connectionEstablished()"; -} - diff --git a/src/UserInterface/WindowManager.h b/src/UserInterface/WindowManager.h index a3f7440..aa736cf 100644 --- a/src/UserInterface/WindowManager.h +++ b/src/UserInterface/WindowManager.h @@ -33,13 +33,6 @@ public: virtual bool event(QEvent *event); - - //! Shows any view specific indicators for connection error - void connectionLost(); - - //! Removes any view specific indicators for connection error - void connectionEstablished(); - signals: //! Request current status of the room. /*! -- 1.7.9.5