ProgressBar connections modified + Progress Bar class itself updated
authorJan Lapinkataja <jan.lapinkataja@ixonos.com>
Wed, 20 May 2009 11:51:06 +0000 (14:51 +0300)
committerJan Lapinkataja <jan.lapinkataja@ixonos.com>
Wed, 20 May 2009 11:51:06 +0000 (14:51 +0300)
src/BusinessLogic/Engine.cpp
src/IO/DeviceControl/DeviceManager.cpp
src/IO/DeviceControl/DeviceManager.h
src/UserInterface/Utils/PasswordDialog.cpp
src/UserInterface/Utils/ProgressBar.cpp
src/UserInterface/Utils/ProgressBar.h
src/UserInterface/WindowManager.cpp
src/UserInterface/WindowManager.h

index e529799..2f9d3cd 100644 (file)
@@ -21,6 +21,7 @@ const int IDLE_TIME_MULTIPLIER = 60000; // Multiplies milliseconds to minutes
 Engine::Engine() :
                iClock( 0 ), iConfiguration( Configuration::instance() ), iCommunication( 0 )
 {
+       qDebug() << "Engine::Engine()";
        // if reading of configuration fails, signal that initialization failed
        if ( iConfiguration == 0 )
        {
@@ -37,7 +38,7 @@ Engine::Engine() :
        connect( iWindowManager, SIGNAL( shownWeekChanged( QDate ) ), this, SLOT( shownWeekChanged( QDate ) ) );
        connect( iWindowManager, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ),
                        this, SLOT( passwordEntered( PasswordDialog::PasswordStatus ) ) );
-       connect( iWindowManager, SIGNAL( progressBarCancelled() ), this, SLOT( progressBarCancelled() ) );
+
        
        // initialize communication
        iCommunication = new CommunicationManager( *(iConfiguration->connectionSettings()) );
@@ -83,6 +84,7 @@ Engine::Engine() :
 
 Engine::~Engine()
 {
+       qDebug() << "Engine::~Engine()";
        while ( !iMeetings.isEmpty() )
                delete iMeetings.takeFirst();
        iIdleTimeCounter->stop();
@@ -105,6 +107,7 @@ void Engine::closeApplication()
 
 void Engine::observedEventDetected()
 {
+       qDebug() << "Engine::observedEventDetected()";
        iWindowManager->showWeeklyView();
        // prepare to restart idle counter
        if ( iIdleTimeCounter->isActive() )
@@ -117,11 +120,13 @@ void Engine::observedEventDetected()
 
 Room* Engine::defaultRoom()
 {
+       qDebug() << "Engine::defaultRoom()";
        return iConfiguration->defaultRoom();
 }
 
 void Engine::checkStatusOfAllRooms()
 {
+       qDebug() << "Engine::checkStatusOfAllRooms()";
        // iterate trough on the rooms
        for ( int i = 0; i < iConfiguration->rooms().count(); i++ )
        {
@@ -132,6 +137,7 @@ void Engine::checkStatusOfAllRooms()
 
 int Engine::indexOfMeetingAt( Room *aRoom, QDateTime aAt )
 {
+       qDebug() << "Engine::indexOfMeetingAt( Room *, QDateTime )";
        for ( int i = 0; i < iMeetings.count(); i++ )
        {
                // exchange server ensures that there is only one meeting in a room at a specified time
@@ -147,6 +153,7 @@ int Engine::indexOfMeetingAt( Room *aRoom, QDateTime aAt )
 
 int Engine::indexOfMeetingAfter( Room *aRoom, QDateTime aAfter )
 {
+       qDebug() << "Engine::indexOfMeetingAfter( Room *, QDateTime )";
        // seeks for the next meeting on the SAME DAY
        int min = -1;
        for ( int i = 0; i < iMeetings.count(); i++ )
@@ -169,6 +176,7 @@ int Engine::indexOfMeetingAfter( Room *aRoom, QDateTime aAfter )
 
 void Engine::roomStatusInfoNeeded( Room *aRoom )
 {
+       qDebug() << "Engine::roomStatusInfoNeeded( Room * )";
        if ( aRoom == 0 )
        {
                return;
@@ -198,11 +206,13 @@ void Engine::fetchMeetings()
 
 void Engine::fetchMeetingDetails( Meeting *aMeeting )
 {
+       qDebug() << "Engine::fetchMeetingDetails( Meeting* )";
        iCommunication->fetchMeetingDetails( *aMeeting );
 }
 
 bool Engine::isMeetingInList( const QList<Meeting*> &aList, const Meeting *aMeeting )
 {
+       qDebug() << "Engine::isMeetingInList( const QList<Meeting*> &, const Meeting * )";
        for ( int i = 0; i < aList.count(); i++ )
        {
                if ( aMeeting->equals( *(aList.at( i )) ) )
@@ -215,6 +225,7 @@ bool Engine::isMeetingInList( const QList<Meeting*> &aList, const Meeting *aMeet
 
 void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
 {
+       qDebug() << "Engine::meetingsFetched( const QList<Meeting*> & )";
        // check if there is any new meeting in the list came from the server -> added
        for ( int i = 0; i < aMeetings.count(); i++ )
        {
@@ -249,6 +260,7 @@ void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
 
 void Engine::meetingDetailsFetched( Meeting &aDetailedMeeting )
 {
+       qDebug() << "Engine::meetingDetailsFetched( Meeting & )";
        iWindowManager->showMeetingInfo( &aDetailedMeeting );
 }
 
@@ -271,12 +283,13 @@ void Engine::currentRoomChanged( Room *aCurrentRoom )
 
 void Engine::fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn )
 {
-       qDebug() << "Engine::fetchMeetings";
+       qDebug() << "Engine::fetchMeetings( const QDateTime &, const QDateTime &, const Room * )";
        iCommunication->fetchMeetings( aFrom, aUntil, *aIn );
 }
 
 void Engine::shownWeekChanged( QDate aFrom )
 {
+       qDebug() << "Engine::shownWeekChanged( QDate )";
        QDateTime from( aFrom );
        QDateTime to( aFrom.addDays( 7 ), QTime( 23, 59 ) );
        qDebug() << "Engine::shownWeekChanged " << aFrom.toString( "d.m. h:mm" ) << " to " << to.toString( "d.m. h:mm" );
@@ -284,7 +297,8 @@ void Engine::shownWeekChanged( QDate aFrom )
 }
 
 void Engine::changeModeOrdered( DeviceManager::OperationMode aMode )
-{
+{      
+       qDebug() << "Engine::changeModeOrdered( DeviceManager::OperationMode )";
        QString message = tr( "You are about to change operation mode to %1." )
                                .arg( iDevice->operationModeToString( aMode ) );
        
@@ -301,24 +315,29 @@ void Engine::passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus )
                case PasswordDialog::Correct :
                {
                        iWindowManager->showProgressBar( "Changing current operation mode." );
+                       connect( iWindowManager, SIGNAL( progressBarCancelled() ), this, SLOT( progressBarCancelled() ) );
+                       connect( iDevice, SIGNAL( changingMode( const QString & ) ),
+                                       iWindowManager, SLOT( updateProgressBar( const QString & ) ) );
+                       iDevice->changeMode( true );
                        break;
                }
                case PasswordDialog::Incorrect :
                {
                        iWindowManager->error( tr( "Incorrect password." ) );
-                       iDevice->handleKeyPresses( true );
+                       iDevice->changeMode( false );
                        break;
                }
                default : //case PasswordDialog::Canceled
                {
-                       iDevice->handleKeyPresses( true );
+                       iDevice->changeMode( false );
                }
        }
 }
 
 void Engine::progressBarCancelled()
 {
+       qDebug() << "Engine::progressBarCancelled()";
        //TODO: cancel the on-going event
        iWindowManager->closeProgressBar();
-       iDevice->handleKeyPresses( true );
+       iDevice->changeMode( false );
 }
index ed5a66a..c38647c 100644 (file)
@@ -68,7 +68,7 @@ void DeviceManager::changeMode( bool aChange )
                handleKeyPresses( true );
                return;
        }
-
+       
        switch ( iMode )
        {
                case EmptyMode:
@@ -79,6 +79,8 @@ void DeviceManager::changeMode( bool aChange )
                case StandAloneMode:
 
                        // change to KioskMode
+                       emit changingMode( "Changing to Kiosk mode" );
+                       while( 1 );
 
                        // check if auto turn on/off functionality enabled and send turn on/off alarm events to alarm daemon
                        if ( iSettings->isPowersavingEnabled() )
index e65f714..d318482 100644 (file)
@@ -84,13 +84,6 @@ public:
         * \return QString value of the current operation mode.
         */
        QString operationModeToString( OperationMode aMode );
-       //! Connects/disconnects the HWKeyListener signals to the private HWKeyFullScreenPressed() slot.
-       /*!
-        * Connects/disconnects the HWKeyListener signals to the private HWKeyFullScreenPressed() slot. In case
-        * a signal is caught the connection is disabled until the signal handling is finished.
-        * \param aHandle indicates if the signals should be connected or not.
-        */
-       void handleKeyPresses( bool aHandle );
        //! Changes the operation mode.
        /*!
         * Changes the operation mode.
@@ -112,6 +105,8 @@ signals:
         * \param aAddInfo Possible additional information.
         */
        void error( int aCode, const QString &aAddInfo );
+       
+       void changingMode( const QString &aMessage );
 
 private slots:
        //! Slot. Handles "full screen"-hardware key presses.
@@ -153,6 +148,13 @@ 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;
index 778d32a..a31616b 100644 (file)
@@ -1,4 +1,5 @@
 #include "PasswordDialog.h"
+
 #include <QLineEdit>
 #include <QPushButton>
 #include <QVBoxLayout>
@@ -49,7 +50,7 @@ PasswordDialog::PasswordDialog( const QString &aPassword, const QString &aText,
        layout->addSpacing( 5 );
        layout->addLayout( buttonLayout );
 
-       // Connect the buttons pressed signals to corresponding slots
+       // Connect the user action signals to corresponding slots
        connect( buttonOK, SIGNAL( pressed() ), this, SLOT( okButtonPressed() ) );
        connect( buttonCancel, SIGNAL( pressed() ), this, SLOT( cancelButtonPressed() ) );
 
index a43098d..30f6056 100755 (executable)
@@ -1,12 +1,17 @@
 #include "ProgressBar.h"
+#include "ObservedWidget.h"
 
 #include <QProgressBar>
-#include <QBoxLayout>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
 #include <QPushButton>
+#include <QLabel>
+#include <QtDebug>
 
-ProgressBar::ProgressBar( const QString &aText, QWidget *aParent ) :
+ProgressBar::ProgressBar( const QString &aText, bool aCancellable, QWidget *aParent ) :
        QDialog( aParent )
 {
+       qDebug() << "ProgressBar::ProgressBar( const QString &, bool, QWidget *)";
        setWindowTitle( aText );
        setModal( true );
 
@@ -14,21 +19,29 @@ ProgressBar::ProgressBar( const QString &aText, QWidget *aParent ) :
        iProgress->setMinimumWidth( 200 );
        iProgress->setMaximum( 0 );
        iProgress->setTextVisible( false );
-
-       QBoxLayout* layout = new QBoxLayout( QBoxLayout::LeftToRight, this );
-       layout->setSizeConstraint( QLayout::SetDefaultConstraint );
-       layout->addWidget( iProgress, 0, Qt::AlignHCenter );
-       
-       QPushButton *buttonCancel = new QPushButton( tr( "Cancel" ) );
-       layout->addSpacing( 5 );
-       layout->addWidget( buttonCancel );
        
-       connect( buttonCancel, SIGNAL( pressed() ), this, SIGNAL( cancel() ) );
-       connect( iProgress, SIGNAL( valueChanged( int ) ), this, SIGNAL( started() ) );
+       QVBoxLayout *mainLayout = new QVBoxLayout;
+       iLabel = new QLabel();
+       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() ) );
+       }
        
-       setLayout( layout );
+       setLayout( mainLayout );
 }
 
 ProgressBar::~ProgressBar()
 {
+       qDebug() << "ProgressBar::~ProgressBar()";
 }
+
+void ProgressBar::update( const QString &aMessage )
+{
+       qDebug() << "ProgressBar::update( const QString & )";
+       iLabel->setText( aMessage );
+}
\ No newline at end of file
index a247cf3..bf573cd 100755 (executable)
@@ -4,6 +4,7 @@
 #include <QDialog>
 
 class QProgressBar;
+class QLabel;
 
 //! UserInterface class.
 /*!
@@ -21,9 +22,11 @@ public:
         * \param aParent Parent object.
         * \param aText Title string to be set to the progress bar.
         */
-       ProgressBar( const QString &aText, QWidget *aParent = 0 );
+       ProgressBar( const QString &aText, bool aCancellable = false, QWidget *aParent = 0 );
        //! Destructor.
        virtual ~ProgressBar();
+       
+       void update( const QString &aMessage );
 
 signals:
        //! Signal. Emitted if user presses cancel button.
@@ -35,6 +38,7 @@ signals:
 
 private:
        QProgressBar *iProgress;
+       QLabel *iLabel;
 
 };
 
index 3a593a9..45d8b72 100644 (file)
@@ -19,6 +19,7 @@
 WindowManager::WindowManager( Configuration *aConfiguration ) :
                QObject(),
                iApplicationName( tr( "Qt Meetings" ) ),
+               iFullScreen( false ),
                iConfiguration( aConfiguration ),
                iWeeklyView( 0 ),
                iRoomStatusView( 0 ),
@@ -70,6 +71,8 @@ void WindowManager::roomStatusChanged( Room *aRoom, Room::Status aStatus, QTime
        {
                iRoomStatusView = new RoomStatusIndicatorWidget( aRoom, aStatus, aTime, iConfiguration->displaySettings()->timeFormat() );
                iRoomStatusView->setWindowTitle( iApplicationName );
+               if( iFullScreen )
+                       iRoomStatusView->setWindowState( Qt::WindowFullScreen );
                connect( iRoomStatusView, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );
        }
        else
@@ -119,8 +122,11 @@ void WindowManager::showWeeklyView()
 
 void WindowManager::fullScreen()
 {
-       iRoomStatusView->setWindowState( Qt::WindowFullScreen );
-       iWeeklyView->setWindowState( Qt::WindowFullScreen );
+       if ( iRoomStatusView != 0 )
+               iRoomStatusView->setWindowState( Qt::WindowFullScreen );
+       if ( iWeeklyView != 0 )
+               iWeeklyView->setWindowState( Qt::WindowFullScreen );
+       iFullScreen = true;
 }
 
 void WindowManager::insertMeeting( Meeting *aMeeting )
@@ -166,6 +172,8 @@ void WindowManager::showPasswordDialog( QByteArray aAdminPassword, const QString
        connect( iPasswordDialog, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ),
                        this, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ) );
        iPasswordDialog->show();
+       
+       //TODO connect connect( iWeeklyView, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );
 }
 
 void WindowManager::closePasswordDialog()
@@ -183,11 +191,21 @@ void WindowManager::showProgressBar( const QString &aText )
                iProgressBar->show();
                connect( iProgressBar, SIGNAL( cancel() ), this, SIGNAL( progressBarCancelled() ) );
        }
+       
+       //TODO connect connect( iWeeklyView, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );
 }
 
 void WindowManager::closeProgressBar()
 {
+       qDebug() << "WindowManager::closeProgressBar()";
        iProgressBar->close();
        delete iProgressBar;
        iProgressBar = 0;
 }
+
+void WindowManager::updateProgressBar( const QString &aMessage )
+{
+       qDebug() << "WindowManager::updateProgressBar( const QString & )";
+       if( iProgressBar != 0 )
+               iProgressBar->update( aMessage );
+}
index 6a56e77..1e460c0 100644 (file)
@@ -154,6 +154,8 @@ public slots:
         */\r
        void distributeDateTimeInfo( QDateTime aCurrentDateTime );\r
        \r
+       void updateProgressBar( const QString &aMessage );\r
+       \r
 private slots:\r
        //! Displays the settings view\r
        void showSettingsView();\r
@@ -161,6 +163,8 @@ private slots:
 private:\r
        //! Name of the application.\r
        QString iApplicationName;\r
+       //! Defines whether the views should be shown as full screen \r
+       bool iFullScreen;\r
        //! Pointer to the configuration.\r
        Configuration *iConfiguration;\r
        //! Pointer to the weekly view.\r