From: Risto Lintinen Date: Fri, 21 Aug 2009 09:05:25 +0000 (+0300) Subject: User interface update X-Git-Url: http://git.maemo.org/git/?p=qtmeetings;a=commitdiff_plain;h=663a2fc8ce3a0b8b987655fe709a831a3db9b315 User interface update --- diff --git a/QtMeetings.pro b/QtMeetings.pro index b4c6c65..e46c741 100644 --- a/QtMeetings.pro +++ b/QtMeetings.pro @@ -13,7 +13,8 @@ INCLUDEPATH += src/Domain/ \ src/UserInterface/Components/ \ src/UserInterface/Utils/ \ src/UserInterface/Views/ -HEADERS += src/BusinessLogic/UIManager.h \ +HEADERS += src/UserInterface/Components/BorderedBarWidget.h \ + src/BusinessLogic/UIManager.h \ src/IO/DeviceControl/OperationModeToggler.h \ src/UserInterface/Utils/ProgressBar.h \ src/Domain/Room.h \ @@ -48,7 +49,8 @@ HEADERS += src/BusinessLogic/UIManager.h \ src/UserInterface/Views/SettingsView.h \ src/UserInterface/WindowManager.h \ src/UserInterface/Views/ViewBase.h -SOURCES += src/BusinessLogic/UIManager.cpp \ +SOURCES += src/UserInterface/Components/BorderedBarWidget.cpp \ + src/BusinessLogic/UIManager.cpp \ src/IO/DeviceControl/OperationModeToggler.cpp \ src/UserInterface/Utils/ProgressBar.cpp \ src/Domain/Room.cpp \ diff --git a/resources/UserInterface.qrc b/resources/UserInterface.qrc index dc3301b..6f125d3 100644 --- a/resources/UserInterface.qrc +++ b/resources/UserInterface.qrc @@ -12,5 +12,6 @@ icons/popup_ok.png icons/popup_question.png icons/popup_warning.png + icons/ixonos_logo.png diff --git a/resources/icons/ixonos_logo.png b/resources/icons/ixonos_logo.png new file mode 100644 index 0000000..d04b1bd Binary files /dev/null and b/resources/icons/ixonos_logo.png differ diff --git a/resources/icons/roomstatus_busy.png b/resources/icons/roomstatus_busy.png index d735440..d69d8ba 100644 Binary files a/resources/icons/roomstatus_busy.png and b/resources/icons/roomstatus_busy.png differ diff --git a/resources/icons/roomstatus_free.png b/resources/icons/roomstatus_free.png index 14aa52f..2c6edce 100644 Binary files a/resources/icons/roomstatus_free.png and b/resources/icons/roomstatus_free.png differ diff --git a/src/BusinessLogic/Engine.cpp b/src/BusinessLogic/Engine.cpp index c7aad8b..e46ddc9 100644 --- a/src/BusinessLogic/Engine.cpp +++ b/src/BusinessLogic/Engine.cpp @@ -53,9 +53,12 @@ Engine::Engine() : // Create auto refresh timer iAutoRefresh = new QTimer; - iAutoRefresh->setInterval(iConfiguration->connectionSettings()->refreshInterval() * 1000); + + iAutoRefresh->setInterval(Configuration::instance()->getRefreshinterval() * 1000); + iAutoRefresh->start(); connect( iAutoRefresh, SIGNAL( timeout() ), iAutoRefresh, SLOT( start() ) ); + connect( iAutoRefresh, SIGNAL( timeout() ), this, SLOT( updateRoomInfo() ) ); // connect( iAutoRefresh, SIGNAL( timeout() ), this, SLOT( fetchMeetings() ) ); if( iDevice->currentOperationMode() == DeviceManager::KioskMode ) @@ -64,7 +67,7 @@ Engine::Engine() : } connectSignals(); - + connect( Configuration::instance(), SIGNAL( configurationChanged() ), this, SLOT( configurationChanged() ) ); // QTimer::singleShot( 0, this, SLOT( fetchMeetings() ) ); // TODO: continue implementation @@ -105,7 +108,6 @@ Room* Engine::defaultRoom() void Engine::checkStatusOfAllRooms() { // TODO: Check if date has changed - // qDebug() << "Engine::checkStatusOfAllRooms()"; // iterate trough on the rooms for (int i = 0; i < iConfiguration->rooms().count(); i++) { @@ -211,7 +213,11 @@ void Engine::errorHandler( int aCode, const QString &aAddInfo ) if( aCode >= 100 && aCode < 150 ) { iCommunicationFailed = true; - if ( iUIManager != 0 ) iUIManager->connectionLost(); + + if ( iUIManager != 0 ) + { + iUIManager->connectionLost(); + } } if ( iWindowManager != 0 ) { @@ -308,7 +314,7 @@ void Engine::connectSignals() void Engine::initCommunication() { // initialize communication - iCommunication = new CommunicationManager( *(iConfiguration->connectionSettings()) ); + iCommunication = new CommunicationManager(/* *(iConfiguration->connectionSettings()) */); connect( iCommunication, SIGNAL( error( int, CommunicationManager::CommunicationType ) ), this, SLOT( errorHandler( int ) ) ); connect( iCommunication, SIGNAL( meetingsFetched( const QList& ) ), @@ -385,4 +391,16 @@ void Engine::tick( QDateTime aCurrentDateTime ) } } iCurrentDate = aCurrentDateTime.date(); -} \ No newline at end of file +} + + +void Engine::updateRoomInfo() +{ + qDebug() << "ENGINE::: updateMeetings"; + roomStatusInfoNeeded(iCurrentRoom); +} + +void Engine::configurationChanged() +{ + iAutoRefresh->setInterval(Configuration::instance()->getRefreshinterval() * 1000); +} diff --git a/src/BusinessLogic/Engine.h b/src/BusinessLogic/Engine.h index c58e423..87625a3 100644 --- a/src/BusinessLogic/Engine.h +++ b/src/BusinessLogic/Engine.h @@ -122,6 +122,15 @@ private slots: void tick( QDateTime aCurrentDateTime ); + /** + * Updates the current rooms info. + */ + void updateRoomInfo(); + /** + * + */ + void configurationChanged(); + private: // Make the UIManager as friendly class so it can connect to private slots. friend class UIManager; diff --git a/src/BusinessLogic/UIManager.cpp b/src/BusinessLogic/UIManager.cpp index eb80616..6adc9e5 100644 --- a/src/BusinessLogic/UIManager.cpp +++ b/src/BusinessLogic/UIManager.cpp @@ -37,8 +37,9 @@ UIManager::UIManager( Engine *aEngine, WindowManager *aWindowManager ) : if ( iEngine == 0 ) return; if ( iWindowManager == 0 ) return; + connect(iWindowManager, SIGNAL(showSettingsClicked()), this, SLOT(settingsViewRequest())); + createWeeklyView(); - createSettingsView(); createRoomStatusIndicator(); createPasswordDialog(); createProgressBar(); @@ -134,12 +135,11 @@ void UIManager::connectCommunicationManager( CommunicationManager *aCommunicatio // UIMANAGER SLOTS void UIManager::settingsViewRequest() { + createSettingsView(); + // Show the settings view and stop the idle timer - if ( iSettingsView != 0 ) - { - iWindowManager->showView( static_cast( iSettingsView ) ); - iEngine->stopIdleTimeCounter(); - } + iWindowManager->showView( static_cast( iSettingsView ) ); + iEngine->stopIdleTimeCounter(); } void UIManager::settingsOkClicked() @@ -148,7 +148,9 @@ void UIManager::settingsOkClicked() if ( iWeeklyView != 0 ) { iWindowManager->showView( static_cast( iWeeklyView ) ); + QT_DELETE(iSettingsView); iEngine->startIdleTimeCounter(); + currentRoomChanged(iWeeklyView->currentRoom()); } } @@ -227,7 +229,6 @@ void UIManager::connectionLost() { qDebug() << "UIManager::connectionLost()"; iWeeklyView->connectionLost(); - iSettingsView->connectionLost(); iRoomStatusIndicator->connectionLost(); } @@ -235,7 +236,6 @@ void UIManager::connectionEstablished() { qDebug() << "UIManager::connectionEstablished()"; iWeeklyView->connectionEstablished(); - iSettingsView->connectionEstablished(); iRoomStatusIndicator->connectionEstablished(); } @@ -313,6 +313,7 @@ void UIManager::settingsCancelClicked() if ( iWeeklyView != 0 ) { iWindowManager->showView( static_cast( iWeeklyView ) ); + QT_DELETE(iSettingsView); iEngine->startIdleTimeCounter(); } -} \ No newline at end of file +} diff --git a/src/Domain/Configuration/Configuration.cpp b/src/Domain/Configuration/Configuration.cpp index 2a33998..ae3c431 100644 --- a/src/Domain/Configuration/Configuration.cpp +++ b/src/Domain/Configuration/Configuration.cpp @@ -11,96 +11,109 @@ #include #include +#include +#include Configuration * Configuration::sInstance = 0; QString Configuration::sConfigurationPath = "/etc/QtMeetings.conf"; Configuration::Configuration() : - iConnectionSettings( 0 ), - iStartupSettings( 0 ), - iDisplaySettings( 0 ), - iDateTimeSettings( 0 ) -{ + iConnectionSettings(0), iStartupSettings(0), iDisplaySettings(0), + iDateTimeSettings(0) { } -Configuration::~Configuration() -{ +Configuration::~Configuration() { delete iConnectionSettings; delete iStartupSettings; delete iDisplaySettings; delete iDateTimeSettings; - while ( !iRooms.isEmpty() ) - { + while (!iRooms.isEmpty()) { delete iRooms.takeFirst(); } } -Configuration* Configuration::instance() -{ - if ( sInstance == 0 ) - { - sInstance = readFromXML( sConfigurationPath ); - if( !sInstance ) - { - qDebug() << "FATAL: Configuration cannot be read from:" << Configuration::sConfigurationPath; - } - } +Configuration* Configuration::instance() { + if (sInstance == 0) { + qDebug() << "HERE"; + sInstance = new Configuration(); + sInstance->readFromXML(sConfigurationPath); + if (!sInstance) { + qDebug() << "FATAL: Configuration cannot be read from:" + << Configuration::sConfigurationPath; + } + } return sInstance; } -ConnectionSettings* Configuration::connectionSettings() -{ - return iConnectionSettings; -} +/*ConnectionSettings* Configuration::connectionSettings() + { + return iConnectionSettings; + }*/ -StartupSettings * Configuration::startupSettings() -{ +StartupSettings * Configuration::startupSettings() { return iStartupSettings; } -DisplaySettings * Configuration::displaySettings() -{ +DisplaySettings * Configuration::displaySettings() { return iDisplaySettings; } -DateTimeSettings * Configuration::dateTimeSettings() -{ +DateTimeSettings * Configuration::dateTimeSettings() { return iDateTimeSettings; } -Room* Configuration::defaultRoom() -{ +Room* Configuration::defaultRoom() { // default room is stored as the first element of the list - return ( iRooms.count() == 0 ) ? 0 : iRooms.at( 0 ); + return (iRooms.count() == 0) ? 0 : iRooms.at(0); } -QString Configuration::languageCode() -{ +QString Configuration::languageCode() { return iLanguageCode; } -QList Configuration::rooms() -{ +QList Configuration::rooms() { return iRooms; } -QByteArray Configuration::adminPassword() -{ +QByteArray Configuration::adminPassword() { return iAdminPassword; } +QUrl Configuration::getServerUrl() { + return iConnectionSettings->serverUrl(); +} -void Configuration::save() -{ - QDomDocument doc; - QFile file( sConfigurationPath ); +QString Configuration::getUsername() { + return iConnectionSettings->username(); +} +QString Configuration::getPassword() { + return iConnectionSettings->password(); +} + +unsigned int Configuration::getRefreshinterval() { + return iConnectionSettings->refreshInterval(); +} - if ( !file.open( QIODevice::ReadWrite ) ) - { +void Configuration::setServerUrl(QUrl serverUrl) { + iConnectionSettings->setServerUrl(serverUrl); +} +void Configuration::setUsername(QString username) { + iConnectionSettings->setUsername(username); +} +void Configuration::setPassword(QString password) { + iConnectionSettings->setPassword(password); +} +void Configuration::setRefreshinterval(unsigned int refreshinterval) { + iConnectionSettings->setRefreshInterval(refreshinterval); +} + +void Configuration::save() { + QDomDocument doc; + QFile file(sConfigurationPath); + if (!file.open(QIODevice::ReadWrite)) { return; } - if ( !doc.setContent( &file ) ) - { + if (!doc.setContent(&file)) { file.close(); return; } @@ -108,110 +121,89 @@ void Configuration::save() QDomElement root = doc.documentElement(); // Save all attributes to document - saveAdminPassword( root ); + saveAdminPassword(root); - for ( QDomNode node = root.firstChild(); !node.isNull(); node = node.nextSibling() ) - { + for (QDomNode node = root.firstChild(); !node.isNull(); node + = node.nextSibling()) { QDomElement e = node.toElement(); QString tagName = e.tagName().toLower(); - - if ( tagName == QString( "connection" ) ) - { - saveConnectionSettings( node ); - } - else if ( tagName == QString( "rooms" ) ) - { - saveRooms( node ); - } - else if ( tagName == QString( "language" ) ) - { - saveLanguageCode( node ); - } - else if ( tagName == QString( "startup" ) ) - { - saveStartupSettings( node ); - } - else if ( tagName == QString( "display" ) ) - { - saveDisplaySettings( node ); - } - else if (tagName == QString( "daylight_saving_time" ) ) - { - saveDateTimeSettings( node ); + if (tagName == QString("connection")) { + saveConnectionSettings(node); + } else if (tagName == QString("rooms")) { + saveRooms(node); + } else if (tagName == QString("language")) { + saveLanguageCode(node); + } else if (tagName == QString("startup")) { + saveStartupSettings(node); + } else if (tagName == QString("display")) { + saveDisplaySettings(node); + } else if (tagName == QString("daylight_saving_time")) { + saveDateTimeSettings(node); } } //! Empty the file from previous content and write again with new one - file.resize( 0 ); - file.write( doc.toByteArray( 4 ) ); //! 4 as intent + file.resize(0); + file.write(doc.toByteArray(4)); //! 4 as intent file.close(); - + emit configurationChanged(); } -void Configuration::saveConnectionSettings( const QDomNode &aXML ) -{ - for ( QDomNode node = aXML.firstChild(); !node.isNull(); node = node.nextSibling() ) - { +void Configuration::saveConnectionSettings(const QDomNode &aXML) { + QDomElement e = aXML.firstChild().toElement(); + QString tagName = e.tagName().toLower(); + qDebug() << tagName; + for (QDomNode node = aXML.firstChild(); !node.isNull(); node + = node.nextSibling()) { QDomElement e = node.toElement(); QString tagName = e.tagName().toLower(); - if ( tagName == QString( "serverurl" ) ) - { - QDomText t = node.ownerDocument().createTextNode( iConnectionSettings->serverUrl().toString() ); - if ( e.hasChildNodes() ) - { - e.replaceChild( t, e.firstChild() ); + qDebug() << tagName; + if (tagName == QString("serverurl")) { + QDomText t = node.ownerDocument().createTextNode( + iConnectionSettings->serverUrl().toString()); + if (e.hasChildNodes()) { + + e.replaceChild(t, e.firstChild()); + } else { + e.appendChild(t); } - else - { - e.appendChild( e.firstChild() ); + } else if (tagName == QString("username")) { + QDomText t = node.ownerDocument().createTextNode( + iConnectionSettings->username()); + if (e.hasChildNodes()) { + e.replaceChild(t, e.firstChild()); + } else { + e.appendChild(t); } - } - else if ( tagName == QString( "username" ) ) - { - QDomText t = node.ownerDocument().createTextNode( iConnectionSettings->username() ); - if ( e.hasChildNodes() ) - { - e.replaceChild( t, e.firstChild() ); - } - else - { - e.appendChild( e.firstChild() ); - } - } - else if ( tagName == QString( "password" ) ) - { - QDomText t = node.ownerDocument().createTextNode( iConnectionSettings->password() ); - if ( e.hasChildNodes() ) - { - e.replaceChild( t, e.firstChild() ); - } - else - { - e.appendChild( e.firstChild() ); + + } else if (tagName == QString("password")) { + QDomText t = node.ownerDocument().createTextNode( + iConnectionSettings->password()); + if (e.hasChildNodes()) { + e.replaceChild(t, e.firstChild()); + } else { + e.appendChild(t); } - } - else if ( tagName == QString( "refreshinterval" ) ) - { - QString s = QString( "%1" ).arg( iConnectionSettings->refreshInterval() ); - QDomText t = node.ownerDocument().createTextNode( s ); - e.replaceChild( t, e.firstChild() ); + } else if (tagName == QString("refreshinterval")) { + QString s = QString("%1").arg( + iConnectionSettings->refreshInterval()); + QDomText t = node.ownerDocument().createTextNode(s); + e.replaceChild(t, e.firstChild()); } } } -void Configuration::saveRooms( const QDomNode &aXML ) -{ +void Configuration::saveRooms(const QDomNode &aXML) { //! List of rooms must be cleared and rewritten again QDomDocument doc = aXML.ownerDocument(); - QDomNode root = aXML; + QDomNode root = aXML; // Remove child nodes... int count = root.childNodes().count(); QDomNode node = root.firstChild(); QDomNode next; - for (int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { qDebug() << "remove " << node.toElement().text(); next = node.nextSibling(); node = root.removeChild(node); @@ -220,264 +212,219 @@ void Configuration::saveRooms( const QDomNode &aXML ) node = aXML; QList::iterator i; - for ( i = iRooms.begin(); i != iRooms.end(); ++i ) - { - QDomElement tag = doc.createElement( "room" ); - node.appendChild( tag ); + for (i = iRooms.begin(); i != iRooms.end(); ++i) { + QDomElement tag = doc.createElement("room"); + node.appendChild(tag); // First room in the list is a dafault room - if ( i == iRooms.begin() ) - { - tag.setAttribute( "default", "true" ); + if (i == iRooms.begin()) { + tag.setAttribute("default", "true"); } - QDomElement ename = doc.createElement( "name" ); - QDomText tname = node.ownerDocument().createTextNode(( *i )->name() ); - ename.appendChild( tname ); - tag.appendChild( ename ); + QDomElement ename = doc.createElement("name"); + QDomText tname = node.ownerDocument().createTextNode((*i)->name()); + ename.appendChild(tname); + tag.appendChild(ename); - QDomElement eaddress = doc.createElement( "address" ); - QDomText taddress = node.ownerDocument().createTextNode(( *i )->address() ); - eaddress.appendChild( taddress ); - tag.appendChild( eaddress ); + QDomElement eaddress = doc.createElement("address"); + QDomText taddress = + node.ownerDocument().createTextNode((*i)->address()); + eaddress.appendChild(taddress); + tag.appendChild(eaddress); } } -void Configuration::saveLanguageCode( const QDomNode &aXML ) -{ +void Configuration::saveLanguageCode(const QDomNode &aXML) { QDomElement e = aXML.toElement(); - e.setAttribute( "code", languageCode() ); + e.setAttribute("code", languageCode()); } -void Configuration::saveStartupSettings( const QDomNode &aXML ) -{ +void Configuration::saveStartupSettings(const QDomNode &aXML) { QDomElement e = aXML.toElement(); - for ( QDomNode node = aXML.firstChild(); !node.isNull(); node = node.nextSibling() ) - { + for (QDomNode node = aXML.firstChild(); !node.isNull(); node + = node.nextSibling()) { e = node.toElement(); QString tagName = e.tagName().toLower(); - if ( tagName == QString( "powersaving" ) ) - { - ( iStartupSettings->isPowersavingEnabled() ? - e.setAttribute( "enabled", "true" ) : - e.setAttribute( "enabled", "false" ) ); + if (tagName == QString("powersaving")) { + (iStartupSettings->isPowersavingEnabled() ? e.setAttribute( + "enabled", "true") : e.setAttribute("enabled", "false")); - e.setAttribute( "on", iStartupSettings->turnOnAt().toString( "hh:mm" ) ); - e.setAttribute( "off", iStartupSettings->turnOffAt().toString( "hh:mm" ) ); + e.setAttribute("on", iStartupSettings->turnOnAt().toString("hh:mm")); + e.setAttribute("off", iStartupSettings->turnOffAt().toString( + "hh:mm")); } } } -void Configuration::saveDisplaySettings( const QDomNode &aXML ) -{ - for ( QDomNode node = aXML.firstChild(); !node.isNull(); node = node.nextSibling() ) - { +void Configuration::saveDisplaySettings(const QDomNode &aXML) { + for (QDomNode node = aXML.firstChild(); !node.isNull(); node + = node.nextSibling()) { QDomElement e = node.toElement(); QString tagName = e.tagName().toLower(); - if ( tagName == QString( "schedule" ) ) - { - for ( QDomNode scheduleNode = node.firstChild(); !scheduleNode.isNull(); scheduleNode = scheduleNode.nextSibling() ) - { + if (tagName == QString("schedule")) { + for (QDomNode scheduleNode = node.firstChild(); !scheduleNode.isNull(); scheduleNode + = scheduleNode.nextSibling()) { QDomElement scheduleElem = scheduleNode.toElement(); tagName = scheduleElem.tagName().toLower(); - if ( tagName == QString( "week" ) ) - { - scheduleElem.setAttribute( "days", iDisplaySettings->daysInSchedule() ); - } - else if ( tagName == QString( "day" ) ) - { - scheduleElem.setAttribute( "startsat", iDisplaySettings->dayStartsAt().toString( "hh:mm" ) ); - scheduleElem.setAttribute( "endsat", iDisplaySettings->dayEndsAt().toString( "hh:mm" ) ); + if (tagName == QString("week")) { + scheduleElem.setAttribute("days", + iDisplaySettings->daysInSchedule()); + } else if (tagName == QString("day")) { + scheduleElem.setAttribute("startsat", + iDisplaySettings->dayStartsAt().toString("hh:mm")); + scheduleElem.setAttribute("endsat", + iDisplaySettings->dayEndsAt().toString("hh:mm")); } - } // end of for - } // end of schedule - else if ( tagName == QString( "dateformat" ) ) - { - QDomText t = node.ownerDocument().createTextNode( iDisplaySettings->dateFormat() ); - e.replaceChild( t, e.firstChild() ); - } - else if ( tagName == QString( "timeformat" ) ) - { - QDomText t = node.ownerDocument().createTextNode( iDisplaySettings->timeFormat() ); - e.replaceChild( t, e.firstChild() ); - } - else if ( tagName == QString( "screensaver" ) ) - { - QString s = QString( "%1" ).arg( iDisplaySettings->screensaver() ); - QDomText t = node.ownerDocument().createTextNode( s ); - e.replaceChild( t, e.firstChild() ); + } // end of for + } // end of schedule + else if (tagName == QString("dateformat")) { + QDomText t = node.ownerDocument().createTextNode( + iDisplaySettings->dateFormat()); + e.replaceChild(t, e.firstChild()); + } else if (tagName == QString("timeformat")) { + QDomText t = node.ownerDocument().createTextNode( + iDisplaySettings->timeFormat()); + e.replaceChild(t, e.firstChild()); + } else if (tagName == QString("screensaver")) { + QString s = QString("%1").arg(iDisplaySettings->screensaver()); + QDomText t = node.ownerDocument().createTextNode(s); + e.replaceChild(t, e.firstChild()); } } } -void Configuration::saveDateTimeSettings( const QDomNode &aXML ) -{ - for ( QDomNode node = aXML.firstChild(); !node.isNull(); node = node.nextSibling() ) - { +void Configuration::saveDateTimeSettings(const QDomNode &aXML) { + for (QDomNode node = aXML.firstChild(); !node.isNull(); node + = node.nextSibling()) { QDomElement e = node.toElement(); QString tagName = e.tagName().toLower(); - if ( tagName == QString( "dayofweek" ) ) - { - QDomText t = node.ownerDocument().createTextNode( iDateTimeSettings->switchDay() ); - e.replaceChild( t, e.firstChild() ); - } - else if( tagName == QString( "StandardTimeChangeMoment" ) ) - { - QDomText t = node.ownerDocument().createTextNode( iDateTimeSettings->STDDateTime().toString("ddMMyyyyhhmmss")); - e.replaceChild( t, e.firstChild() ); - } - else if( tagName == QString( "DaylightSaveTimeChangeMoment" ) ) - { - QDomText t = node.ownerDocument().createTextNode( iDateTimeSettings->DSTDateTime().toString("ddMMyyyyhhmmss")); - e.replaceChild( t, e.firstChild() ); + if (tagName == QString("dayofweek")) { + QDomText t = node.ownerDocument().createTextNode( + iDateTimeSettings->switchDay()); + e.replaceChild(t, e.firstChild()); + } else if (tagName == QString("StandardTimeChangeMoment")) { + QDomText t = + node.ownerDocument().createTextNode( + iDateTimeSettings->STDDateTime().toString( + "ddMMyyyyhhmmss")); + e.replaceChild(t, e.firstChild()); + } else if (tagName == QString("DaylightSaveTimeChangeMoment")) { + QDomText t = + node.ownerDocument().createTextNode( + iDateTimeSettings->DSTDateTime().toString( + "ddMMyyyyhhmmss")); + e.replaceChild(t, e.firstChild()); } } } -void Configuration::saveAdminPassword( const QDomNode &aXML ) -{ +void Configuration::saveAdminPassword(const QDomNode &aXML) { QDomElement e = aXML.toElement(); - e.setAttribute( "password", QString( adminPassword() ) ); + e.setAttribute("password", QString(adminPassword())); } - -Configuration* Configuration::readFromXML( const QString &aPath ) -{ +void Configuration::readFromXML(const QString &aPath) { QDomDocument doc; - QFile file( aPath ); + QFile file(aPath); - if ( !file.open( QIODevice::ReadOnly ) ) - { - return 0; + if (!file.open(QIODevice::ReadOnly)) { + return; } - if ( !doc.setContent( &file ) ) - { + if (!doc.setContent(&file)) { file.close(); - return 0; + return; } file.close(); QDomElement root = doc.documentElement(); // check if the file is the one we need - if ( root.tagName().toLower() != QString( "configuration" ) ) - { - return 0; + if (root.tagName().toLower() != QString("configuration")) { + return; } - Configuration* conf = new Configuration(); + iAdminPassword = /*Configuration::*/readAdminPassword(root); - conf->iAdminPassword = Configuration::readAdminPassword( root ); - - for ( QDomNode node = root.firstChild(); !node.isNull(); node = node.nextSibling() ) - { + for (QDomNode node = root.firstChild(); !node.isNull(); node + = node.nextSibling()) { QDomElement e = node.toElement(); QString tagName = e.tagName().toLower(); - if ( tagName == QString( "connection" ) ) - { - conf->iConnectionSettings = Configuration::readConnectionSettings( node ); - } - else if ( tagName == QString( "rooms" ) ) - { - conf->iRooms = Configuration::readRooms( node ); - } - else if ( tagName == QString( "language" ) ) - { - conf->iLanguageCode = Configuration::readLanguageCode( node ); - } - else if ( tagName == QString( "startup" ) ) - { - conf->iStartupSettings = Configuration::readStartupSettings( node ); - } - else if ( tagName == QString( "display" ) ) - { - conf->iDisplaySettings = Configuration::readDisplaySettings( node ); - } - else if ( tagName == QString( "daylight_saving_time" ) ) - { - conf->iDateTimeSettings = Configuration::readDateTimeSettings(node); + if (tagName == QString("connection")) { + iConnectionSettings = readConnectionSettings(node); + + } else if (tagName == QString("rooms")) { + iRooms = readRooms(node); + } else if (tagName == QString("language")) { + iLanguageCode = readLanguageCode(node); + } else if (tagName == QString("startup")) { + iStartupSettings = readStartupSettings(node); + } else if (tagName == QString("display")) { + iDisplaySettings = readDisplaySettings(node); + } else if (tagName == QString("daylight_saving_time")) { + iDateTimeSettings = /*Configuration::*/readDateTimeSettings(node); } } - - return conf; } -ConnectionSettings* Configuration::readConnectionSettings( const QDomNode &aXML ) -{ +ConnectionSettings* Configuration::readConnectionSettings(const QDomNode &aXML) { QString server, username, password; unsigned int interval = Configuration::sDefaultInterval; - for ( QDomNode node = aXML.firstChild(); !node.isNull(); node = node.nextSibling() ) - { + for (QDomNode node = aXML.firstChild(); !node.isNull(); node + = node.nextSibling()) { QDomElement e = node.toElement(); QString tagName = e.tagName().toLower(); - if ( tagName == QString( "serverurl" ) ) - { + if (tagName == QString("serverurl")) { server = e.text(); - } - else if ( tagName == QString( "username" ) ) - { + } else if (tagName == QString("username")) { username = e.text(); - } - else if ( tagName == QString( "password" ) ) - { + } else if (tagName == QString("password")) { password = e.text(); - } - else if ( tagName == QString( "refreshinterval" ) ) - { + } else if (tagName == QString("refreshinterval")) { bool success = false; - unsigned int intervalTMP = e.text().toUInt( &success ); - if ( success ) - { + unsigned int intervalTMP = e.text().toUInt(&success); + if (success) { interval = intervalTMP; } } } - return new ConnectionSettings( server, username, password, interval ); + return new ConnectionSettings(server, username, password, interval); } -QList Configuration::readRooms( const QDomNode &aXML ) -{ +QList Configuration::readRooms(const QDomNode &aXML) { QList rooms; - for ( QDomNode node = aXML.firstChild(); !node.isNull(); node = node.nextSibling() ) - { + for (QDomNode node = aXML.firstChild(); !node.isNull(); node + = node.nextSibling()) { QDomElement e = node.toElement(); QString tagName = e.tagName().toLower(); - if ( tagName == QString( "room" ) ) - { + if (tagName == QString("room")) { QString name, address; - for ( QDomNode roomNode = node.firstChild(); !roomNode.isNull(); roomNode = roomNode.nextSibling() ) - { + for (QDomNode roomNode = node.firstChild(); !roomNode.isNull(); roomNode + = roomNode.nextSibling()) { QDomElement roomElem = roomNode.toElement(); tagName = roomElem.tagName().toLower(); - if ( tagName == QString( "name" ) ) - { + if (tagName == QString("name")) { name = roomElem.text(); - } - else if ( tagName == QString( "address" ) ) - { + } else if (tagName == QString("address")) { address = roomElem.text(); } } - Room* room = new Room( name, address ); - QString defaultAttr = e.attribute( "default" ).toLower(); - if ( defaultAttr == QString( "true" ) ) - { - rooms.insert( 0, room ); - } - else - { - rooms.append( room ); + Room* room = new Room(name, address); + QString defaultAttr = e.attribute("default").toLower(); + if (defaultAttr == QString("true")) { + rooms.insert(0, room); + } else { + rooms.append(room); } } } @@ -485,217 +432,200 @@ QList Configuration::readRooms( const QDomNode &aXML ) return rooms; } -QString Configuration::readLanguageCode( const QDomNode &aXML ) -{ +QString Configuration::readLanguageCode(const QDomNode &aXML) { QDomElement e = aXML.toElement(); QString tagName = e.tagName().toLower(); - if ( e.hasAttribute( "code" ) ) - { - return e.attribute( "code" ); - } - else - { + if (e.hasAttribute("code")) { + return e.attribute("code"); + } else { // default language is English return "EN"; } } -StartupSettings * Configuration::readStartupSettings( const QDomNode &aXML ) -{ +StartupSettings * Configuration::readStartupSettings(const QDomNode &aXML) { QDomElement e = aXML.toElement(); bool isPowersavingEnabled = false; QTime turnOnAt, turnOffAt; - for ( QDomNode node = aXML.firstChild(); !node.isNull(); node = node.nextSibling() ) - { + for (QDomNode node = aXML.firstChild(); !node.isNull(); node + = node.nextSibling()) { e = node.toElement(); QString tagName = e.tagName().toLower(); - if ( tagName == QString( "powersaving" ) ) - { - if ( e.hasAttribute( "enabled" ) && - e.attribute( "enabled" ) == QString( "true" ) ) - { + if (tagName == QString("powersaving")) { + if (e.hasAttribute("enabled") && e.attribute("enabled") == QString( + "true")) { isPowersavingEnabled = true; } - if ( e.hasAttribute( "on" ) ) - { - QString on = e.attribute( "on" ); - turnOnAt = QTime::fromString( on, "hh:mm" ); + if (e.hasAttribute("on")) { + QString on = e.attribute("on"); + turnOnAt = QTime::fromString(on, "hh:mm"); } - if ( e.hasAttribute( "off" ) ) - { - QString off = e.attribute( "off" ); - turnOffAt = QTime::fromString( off, "hh:mm" ); + if (e.hasAttribute("off")) { + QString off = e.attribute("off"); + turnOffAt = QTime::fromString(off, "hh:mm"); } } } - return new StartupSettings( isPowersavingEnabled, turnOnAt, turnOffAt ); + return new StartupSettings(isPowersavingEnabled, turnOnAt, turnOffAt); } -DisplaySettings * Configuration::readDisplaySettings( const QDomNode &aXML ) -{ - DisplaySettings::DaysInSchedule daysInSchedule = DisplaySettings::WeekdaysInSchedule; +DisplaySettings * Configuration::readDisplaySettings(const QDomNode &aXML) { + DisplaySettings::DaysInSchedule daysInSchedule = + DisplaySettings::WeekdaysInSchedule; QTime dayStartsAt, dayEndsAt; DisplaySettings::DateFormat dateformat = DisplaySettings::ShortDateFormat; - DisplaySettings::TimeFormat timeformat = DisplaySettings::TwentyFourHoursTimeFormat; - int screensaver = 1; //! Default value for screensaver wait time + DisplaySettings::TimeFormat timeformat = + DisplaySettings::TwentyFourHoursTimeFormat; + int screensaver = 1; //! Default value for screensaver wait time - for ( QDomNode node = aXML.firstChild(); !node.isNull(); node = node.nextSibling() ) - { + for (QDomNode node = aXML.firstChild(); !node.isNull(); node + = node.nextSibling()) { QDomElement e = node.toElement(); QString tagName = e.tagName().toLower(); - if ( tagName == QString( "schedule" ) ) - { - for ( QDomNode scheduleNode = node.firstChild(); !scheduleNode.isNull(); scheduleNode = scheduleNode.nextSibling() ) - { + if (tagName == QString("schedule")) { + for (QDomNode scheduleNode = node.firstChild(); !scheduleNode.isNull(); scheduleNode + = scheduleNode.nextSibling()) { QDomElement scheduleElem = scheduleNode.toElement(); tagName = scheduleElem.tagName().toLower(); - if ( tagName == QString( "week" ) ) - { - if ( scheduleElem.hasAttribute( "days" ) ) - { + if (tagName == QString("week")) { + if (scheduleElem.hasAttribute("days")) { // default value is 5, only other supported possibility is 7 bool success = false; - unsigned int days = scheduleElem.attribute( "days" ).toUInt( &success ); - daysInSchedule = ( success && days == 7 ) ? DisplaySettings::WholeWeekInSchedule : DisplaySettings::WeekdaysInSchedule; + unsigned int days = + scheduleElem.attribute("days").toUInt(&success); + daysInSchedule + = (success && days == 7) ? DisplaySettings::WholeWeekInSchedule + : DisplaySettings::WeekdaysInSchedule; } - } - else if ( tagName == QString( "day" ) ) - { - if ( scheduleElem.hasAttribute( "startsat" ) ) - { - QString time = scheduleElem.attribute( "startsat" ); - dayStartsAt = QTime::fromString( time, "hh:mm" ); + } else if (tagName == QString("day")) { + if (scheduleElem.hasAttribute("startsat")) { + QString time = scheduleElem.attribute("startsat"); + dayStartsAt = QTime::fromString(time, "hh:mm"); } - if ( scheduleElem.hasAttribute( "endsat" ) ) - { - QString time = scheduleElem.attribute( "endsat" ); - dayEndsAt = QTime::fromString( time, "hh:mm" ); + if (scheduleElem.hasAttribute("endsat")) { + QString time = scheduleElem.attribute("endsat"); + dayEndsAt = QTime::fromString(time, "hh:mm"); } } - } // end of for - } // end of schedule - else if ( tagName == QString( "dateformat" ) ) - { + } // end of for + } // end of schedule + else if (tagName == QString("dateformat")) { //! Not able to display long format anyway at the moment /* - if ( e.text() == QObject::tr( "dddd d MMMM yyyy" ) ) - dateformat = DisplaySettings::LongDateFormat; - else - dateformat = DisplaySettings::ShortDateFormat; - */ + if ( e.text() == QObject::tr( "dddd d MMMM yyyy" ) ) + dateformat = DisplaySettings::LongDateFormat; + else + dateformat = DisplaySettings::ShortDateFormat; + */ dateformat = DisplaySettings::ShortDateFormat; - } - else if ( tagName == QString( "timeformat" ) ) - { + } else if (tagName == QString("timeformat")) { //! Not able to display "TwelveHoursTimeFormat" anyway at the moment /* - if ( e.text() == QObject::tr( "hh:mm ap" ) ) - timeformat = DisplaySettings::TwelveHoursTimeFormat; - else - timeformat = DisplaySettings::TwentyFourHoursTimeFormat; - */ + if ( e.text() == QObject::tr( "hh:mm ap" ) ) + timeformat = DisplaySettings::TwelveHoursTimeFormat; + else + timeformat = DisplaySettings::TwentyFourHoursTimeFormat; + */ timeformat = DisplaySettings::TwentyFourHoursTimeFormat; - } - else if ( tagName == QString( "screensaver" ) ) - { + } else if (tagName == QString("screensaver")) { bool success = false; - unsigned int screensaverTMP = e.text().toUInt( &success ); - if ( success ) - { + unsigned int screensaverTMP = e.text().toUInt(&success); + if (success) { screensaver = screensaverTMP; } } } - return new DisplaySettings( dateformat, timeformat, daysInSchedule, dayStartsAt, dayEndsAt, screensaver ); + return new DisplaySettings(dateformat, timeformat, daysInSchedule, + dayStartsAt, dayEndsAt, screensaver); } -DateTimeSettings * Configuration::readDateTimeSettings( const QDomNode &aXML ) -{ +DateTimeSettings * Configuration::readDateTimeSettings(const QDomNode &aXML) { // Set defaults.. - QDateTime standardTimeChangeMoment = QDateTime::fromString("05.10.2009 04:00:00", "dd'.'MM'.'yyyy' 'hh:mm:ss"); - QDateTime daylightSaveTimeChangeMoment = QDateTime::fromString("01.04.2010 03:00:00", "dd'.'MM'.'yyyy' 'hh:mm:ss"); + QDateTime standardTimeChangeMoment = QDateTime::fromString( + "05.10.2009 04:00:00", "dd'.'MM'.'yyyy' 'hh:mm:ss"); + QDateTime daylightSaveTimeChangeMoment = QDateTime::fromString( + "01.04.2010 03:00:00", "dd'.'MM'.'yyyy' 'hh:mm:ss"); DateTimeSettings::weekDay dayOfWeek = DateTimeSettings::Sunday; - - for ( QDomNode node = aXML.firstChild(); !node.isNull(); node = node.nextSibling() ) - { + + for (QDomNode node = aXML.firstChild(); !node.isNull(); node + = node.nextSibling()) { QDomElement e = node.toElement(); QString tagName = e.tagName().toLower(); - if ( tagName == QString( "dayofweek" ) ) - { - qDebug() << "Configuration::readDateTimeSettings: " +e.text(); - + if (tagName == QString("dayofweek")) { + qDebug() << "Configuration::readDateTimeSettings: " + e.text(); + bool success = false; - unsigned int weekDayTmp = e.text().toUInt( &success ); - if( success && weekDayTmp < 7 ) - { - dayOfWeek = (DateTimeSettings::weekDay)weekDayTmp; + unsigned int weekDayTmp = e.text().toUInt(&success); + if (success && weekDayTmp < 7) { + dayOfWeek = (DateTimeSettings::weekDay) weekDayTmp; } - } - else if( tagName == QString( "standardtimechangemoment" ) ) - { - standardTimeChangeMoment = QDateTime::fromString(e.text(), "dd'.'MM'.'yyyy' 'hh:mm:ss"); - qDebug() << "Configuration::readDateTimeSettings: " +standardTimeChangeMoment.toString("dd.MM.yyyy hh:mm:ss"); - } - else if( tagName == QString( "daylightsavetimechangemoment" ) ) - { - daylightSaveTimeChangeMoment = QDateTime::fromString(e.text(), "dd'.'MM'.'yyyy' 'hh:mm:ss"); - qDebug() << "Configuration::readDateTimeSettings: " +daylightSaveTimeChangeMoment.toString("dd.MM.yyyy hh:mm:ss"); + } else if (tagName == QString("standardtimechangemoment")) { + standardTimeChangeMoment = QDateTime::fromString(e.text(), + "dd'.'MM'.'yyyy' 'hh:mm:ss"); + qDebug() << "Configuration::readDateTimeSettings: " + + standardTimeChangeMoment.toString("dd.MM.yyyy hh:mm:ss"); + } else if (tagName == QString("daylightsavetimechangemoment")) { + daylightSaveTimeChangeMoment = QDateTime::fromString(e.text(), + "dd'.'MM'.'yyyy' 'hh:mm:ss"); + qDebug() << "Configuration::readDateTimeSettings: " + + daylightSaveTimeChangeMoment.toString( + "dd.MM.yyyy hh:mm:ss"); } } - - return new DateTimeSettings(standardTimeChangeMoment, daylightSaveTimeChangeMoment, dayOfWeek); + + return new DateTimeSettings(standardTimeChangeMoment, + daylightSaveTimeChangeMoment, dayOfWeek); } -QByteArray Configuration::readAdminPassword( const QDomNode &aXML ) -{ +QByteArray Configuration::readAdminPassword(const QDomNode &aXML) { QDomElement e = aXML.toElement(); QString tagName = e.tagName().toLower(); - if ( e.hasAttribute( "password" ) ) - { - QString pw = e.attribute( "password" ); + if (e.hasAttribute("password")) { + QString pw = e.attribute("password"); // Check if the password is default uncrypted "admin" - if ( pw == QString( "admin" ) ) - { + + int x = QString::compare(pw, "admin", Qt::CaseInsensitive); // x == 0 + + if (x == 0) { // uncrypted password needs to be encoded - QCryptographicHash *hash = new QCryptographicHash( QCryptographicHash::Md5 ); - hash->addData( pw.toUtf8() ); - pw = QString( hash->result() ); + QCryptographicHash *hash = new QCryptographicHash( + QCryptographicHash::Md5); + hash->addData(pw.toUtf8()); + pw = QString(hash->result()); delete hash; + return (pw.toAscii()).toHex(); } - return ( pw.toAscii() ).toHex(); - - } - else - { + + return (pw.toAscii()); + + } else { return 0; } } -void Configuration::setRooms( const QList aRooms ) -{ +void Configuration::setRooms(const QList aRooms) { iRooms = aRooms; } -QString Configuration::hashPassword( const QString aPassword ) -{ - QCryptographicHash *hash = new QCryptographicHash( QCryptographicHash::Md5 ); - hash->addData( aPassword.toUtf8() ); +QString Configuration::hashPassword(const QString aPassword) { + QCryptographicHash *hash = new QCryptographicHash(QCryptographicHash::Md5); + hash->addData(aPassword.toUtf8()); QByteArray password = hash->result(); delete hash; - return QString( password ); + return QString(password); } diff --git a/src/Domain/Configuration/Configuration.h b/src/Domain/Configuration/Configuration.h index 5cd7e6d..45f9912 100644 --- a/src/Domain/Configuration/Configuration.h +++ b/src/Domain/Configuration/Configuration.h @@ -5,6 +5,7 @@ #include #include #include +#include class ConnectionSettings; class StartupSettings; @@ -19,8 +20,7 @@ class DateTimeSettings; * file at initialization time. Since there is one appliation per device normally running, therefore * there is only one instance of this class, which is accessible by using a statis getter method. */ -class Configuration : public QObject -{ +class Configuration: public QObject { Q_OBJECT private: @@ -46,7 +46,39 @@ public: * Gets the connection settings. * \return Pointer to ConnectionSettings instance. */ - ConnectionSettings* connectionSettings(); + //ConnectionSettings* connectionSettings(); + /** + * Returns the current server URL + */ + QUrl getServerUrl(); + /** + * Returns the current username + */ + QString getUsername(); + /** + * Returns the current users password + */ + QString getPassword(); + /** + * Returns the refresh interval + */ + unsigned int getRefreshinterval(); + /** + * Sets the current server URL + */ + void setServerUrl(QUrl serverUrl); + /** + * Sets the current username + */ + void setUsername(QString username); + /** + * Sets the current users password + */ + void setPassword(QString password); + /** + * Sets the refresh interval + */ + void setRefreshinterval(unsigned int refreshinterval); //! Gets the detault room. /*! * Gets the default meeting room. @@ -96,6 +128,9 @@ public: */ void setRooms(const QList aRooms); +signals: + void configurationChanged(); + public slots: //! Saves setting values to file. @@ -111,7 +146,7 @@ private: * \param aPath path and name of configuration file * \return Configuration object. */ - static Configuration* readFromXML(const QString &aPath); + void readFromXML(const QString &aPath); //! Static. Reads settings of connection from and XML node. /*! * Static. Reads settings of connection from an XML node. diff --git a/src/IO/Communication/Communication.cpp b/src/IO/Communication/Communication.cpp index 5c3b924..04a26e2 100644 --- a/src/IO/Communication/Communication.cpp +++ b/src/IO/Communication/Communication.cpp @@ -1,14 +1,16 @@ #include "Communication.h" #include "ConnectionSettings.h" #include +#include "Configuration.h" +#include -Communication::Communication( const ConnectionSettings &aConnection ) : + +Communication::Communication() : iCurrentRequest(0), iAuthFailCount(0) { - iConnectionSettings = new ConnectionSettings( aConnection ); + iHttp = new QHttp(Configuration::instance()->getServerUrl().toString()/*Configuration::instance()->getServerUrl().toString()*/, QHttp::ConnectionModeHttps ); - iHttp = new QHttp( iConnectionSettings->serverUrl().toString(), QHttp::ConnectionModeHttps ); connect( iHttp, SIGNAL( readyRead( const QHttpResponseHeader& ) ), @@ -39,11 +41,12 @@ Communication::Communication( const ConnectionSettings &aConnection ) : iHttp, SLOT( ignoreSslErrors() )/*this, SLOT( notifySsl( const QList& ) )*/ ); + connect(Configuration::instance(),SIGNAL(configrationChanged()), SLOT(configurationChanged())); } Communication::~Communication() { - delete iConnectionSettings; + //delete iConnectionSettings; delete iHttp; QList responses = iResponses.values(); while(!responses.isEmpty()) @@ -86,8 +89,9 @@ void Communication::handleResults( int aId, bool /*aError*/ ) void Communication::handleAuthentication( const QString& /*aHost*/, quint16 /*aPort*/, QAuthenticator* aAuthenticator ) { - aAuthenticator->setPassword( iConnectionSettings->password() ); - aAuthenticator->setUser( iConnectionSettings->username() ); + + aAuthenticator->setPassword( Configuration::instance()->getPassword() ); + aAuthenticator->setUser( Configuration::instance()->getUsername() ); iAuthFailCount++; if( iAuthFailCount > 1 ) { @@ -99,9 +103,12 @@ int Communication::request( const QString &aCommand, const QByteArray &aContent { if( iAuthFailCount > 1 ) return 0; - + + iHttp->setHost(Configuration::instance()->getServerUrl().toString(),QHttp::ConnectionModeHttps); QHttpRequestHeader header( QString( "POST" ), QString( "/ews/exchange.asmx" ) ); - header.setValue( "Host", iConnectionSettings->serverUrl().toString() ); + + header.setValue( "Host",Configuration::instance()->getServerUrl().toString() ); + QString command = aCommand; header.setContentType( command ); @@ -131,3 +138,8 @@ void Communication::handleReadProgress( int aDone, int aTotal ) { emit readProgress( iCurrentRequest, aDone, aTotal ); } + +void Communication::configurationChanged() +{ + iHttp->setHost(Configuration::instance()->getServerUrl().toString(),QHttp::ConnectionModeHttps ); +} diff --git a/src/IO/Communication/Communication.h b/src/IO/Communication/Communication.h index 41dedb5..07c6601 100644 --- a/src/IO/Communication/Communication.h +++ b/src/IO/Communication/Communication.h @@ -23,7 +23,7 @@ public: * \param aConnection Reference to ConnectionSettings which holds * the server to connect to and authentication information. */ - Communication( const ConnectionSettings &aConnection ); + Communication(/* const ConnectionSettings &aConnection*/ ); virtual ~Communication(); //! Returns the response of a request identified by aRequestId. @@ -40,6 +40,8 @@ public: */ int request( const QString &aCommand, const QByteArray &aContent ); + + signals: //! Emitted when a request ongoing. Reports the bytes read from the server. /*! @@ -71,12 +73,15 @@ protected slots: void handleRequestStarted( int aRequestId ); //! Connected to QHttp::dataReadProgress void handleReadProgress( int aDone, int aTotal ); + //!Called when the settings are changed by the user + void configurationChanged(); + private: /*! * Instance of Connection settings of the communication */ - ConnectionSettings *iConnectionSettings; + //ConnectionSettings *iConnectionSettings; /*! * Instance of QHttp */ diff --git a/src/IO/Communication/CommunicationManager.cpp b/src/IO/Communication/CommunicationManager.cpp index 2f340a0..32d6ed9 100644 --- a/src/IO/Communication/CommunicationManager.cpp +++ b/src/IO/Communication/CommunicationManager.cpp @@ -6,14 +6,17 @@ #include #include #include +#include "../../Domain/Configuration/Configuration.h"; static const int ERROR_BASE=100; -CommunicationManager::CommunicationManager( const ConnectionSettings &aConnection ) + +CommunicationManager::CommunicationManager() { - iConnectionSettings = new ConnectionSettings( aConnection ); + iModifyingCommunication = NULL; - iFetchingCommunication = new Communication( aConnection ); + + iFetchingCommunication = new Communication(); if ( iFetchingCommunication ) { @@ -28,11 +31,12 @@ CommunicationManager::CommunicationManager( const ConnectionSettings &aConnectio SLOT( requestFinished( int, int ) ) ); } + } CommunicationManager::~CommunicationManager() { - delete iConnectionSettings; + //delete iConnectionSettings; delete iModifyingCommunication; delete iFetchingCommunication; while ( !iMeetings.isEmpty() ) @@ -150,6 +154,9 @@ void CommunicationManager::requestFinished( int aRequestId, int aError ) err = 10; delete rd; emit error( ERROR_BASE+(int)err, CommunicationManager::FetchingCommunication ); + while ( !iMeetings.isEmpty() ) + delete iMeetings.takeFirst(); + emit meetingsFetched( iMeetings ); return; } @@ -164,9 +171,17 @@ void CommunicationManager::requestFinished( int aRequestId, int aError ) int err = msg.getMeetingsFromResponse( iMeetings, *(rd->room) ); if( err ) + { emit error( ERROR_BASE+8, CommunicationManager::FetchingCommunication ); + while ( !iMeetings.isEmpty() ) + delete iMeetings.takeFirst(); + emit meetingsFetched( iMeetings ); + } else + { + qDebug("*** COMMUNICATIONMANAGER ::: Meetings fetched!"); emit meetingsFetched( iMeetings ); + } break; } case ConvertId: @@ -185,7 +200,13 @@ void CommunicationManager::requestFinished( int aRequestId, int aError ) ResMsgGetCalendarItem msg( *response ); int err = msg.getMeetingDetailsFromResponse( *(rd->meeting) ); if( err ) + { emit error( ERROR_BASE+9, CommunicationManager::FetchingCommunication ); + while ( !iMeetings.isEmpty() ) + delete iMeetings.takeFirst(); + emit meetingsFetched( iMeetings ); + } + else emit meetingDetailsFetched( *(rd->meeting) ); break; @@ -235,3 +256,4 @@ const CommunicationManager::RequestData* CommunicationManager::findRequest( Requ } return NULL; } + diff --git a/src/IO/Communication/CommunicationManager.h b/src/IO/Communication/CommunicationManager.h index 4dfd00b..abfce60 100644 --- a/src/IO/Communication/CommunicationManager.h +++ b/src/IO/Communication/CommunicationManager.h @@ -36,7 +36,7 @@ public: /*! * \param aConnection Reference to the fetching ConnectionSettings. */ - CommunicationManager( const ConnectionSettings &aConnection ); + CommunicationManager( /*const ConnectionSettings &aConnection*/ ); virtual ~CommunicationManager(); //! Starts fetching meetings. Meetings are returned by the meetingsFetched signal. /*! @@ -157,7 +157,7 @@ protected: private: //! Instance of Connection settings of the fetching communication - ConnectionSettings *iConnectionSettings; + //ConnectionSettings *iConnectionSettings; //! Instance of the fetching communication Communication* iFetchingCommunication; //! Instance of the modifying communication diff --git a/src/UserInterface/Components/BorderedBarWidget.cpp b/src/UserInterface/Components/BorderedBarWidget.cpp new file mode 100644 index 0000000..67356e4 --- /dev/null +++ b/src/UserInterface/Components/BorderedBarWidget.cpp @@ -0,0 +1,165 @@ +#include +#include "BorderedBarWidget.h" + +BorderedBarWidget::BorderedBarWidget( QWidget *aParent ) : + QWidget( aParent ){ + iCenterLabel = new QLabel(this); + iCenterLabel->setAlignment( Qt::AlignCenter ); + iLeftLabel = new QLabel(this); + iLeftLabel->setAlignment( Qt::AlignLeading | Qt::AlignVCenter); + iRightLabel = new QLabel(this); + iRightLabel->setAlignment( Qt::AlignTrailing | Qt::AlignVCenter); +} + +BorderedBarWidget::~BorderedBarWidget() { + delete iCenterLabel; + delete iLeftLabel; + delete iRightLabel; +} + +QColor BorderedBarWidget::backgroundColor() +{ + return iPalette.color( QPalette::Window );; +} + +QColor BorderedBarWidget::faceColor() +{ + return iPalette.color( QPalette::WindowText );; +} + +int BorderedBarWidget::borderWidth() +{ + return iBorderWidth; +} + +QString BorderedBarWidget::text( TextPosition aPos ) +{ + if ( aPos == CenterAlign ) + return iCenterLabel->text(); + else if ( aPos == LeftAlign ) + return iLeftLabel->text(); + else if ( aPos == RightAlign ) + return iRightLabel->text(); + return ""; +} + +void BorderedBarWidget::setBackgroundColor( QColor aColor ) +{ + iPalette.setColor( QPalette::Window, aColor ); + iCenterLabel->setPalette( iPalette ); + iLeftLabel->setPalette( iPalette ); + iRightLabel->setPalette( iPalette ); +} + +void BorderedBarWidget::setFaceColor( QColor aColor ) +{ + iPalette.setColor( QPalette::WindowText, aColor ); + iCenterLabel->setPalette( iPalette ); + iLeftLabel->setPalette( iPalette ); + iRightLabel->setPalette( iPalette ); +} + +void BorderedBarWidget::setBorderWidth( int aWidth ) +{ + iBorderWidth = aWidth; + iRightLabel->setMargin( 2*iBorderWidth ); + iLeftLabel->setMargin( 2*iBorderWidth ); +} + +void BorderedBarWidget::setText( QString aText, TextPosition aPos ) +{ + if ( aPos == CenterAlign ) + iCenterLabel->setText( aText ); + else if ( aPos == LeftAlign ) + iLeftLabel->setText( aText ); + else if ( aPos == RightAlign ) + iRightLabel->setText( aText ); +} + +void BorderedBarWidget::setPixmap( QPixmap aPixmap, TextPosition aPos ) +{ + if ( aPos == CenterAlign ) + iCenterLabel->setPixmap( aPixmap ); + else if ( aPos == LeftAlign ) + iLeftLabel->setPixmap( aPixmap ); + else if ( aPos == RightAlign ) + iRightLabel->setPixmap( aPixmap ); +} + +void BorderedBarWidget::paintEvent(QPaintEvent *) +{ + drawBorder(); + iCenterLabel->setGeometry( rect() ); + iLeftLabel->setGeometry( rect() ); + iRightLabel->setGeometry( rect() ); +} + +void BorderedBarWidget::drawCorner( QPainter &aPainter, QPoint &aCenter ) +{ + QRadialGradient radialGrad(QPointF(aCenter), iBorderWidth); + radialGrad.setColorAt(0, iPalette.color( QPalette::WindowText)); + radialGrad.setColorAt(1, iPalette.color( QPalette::Window)); + aPainter.setBrush(radialGrad); + aPainter.drawEllipse(QPoint(aCenter), iBorderWidth, iBorderWidth); +} + +void BorderedBarWidget::drawSide( QPainter &aPainter, QPoint aStartPoint, QPoint aEndPoint ) +{ + QPoint d = aEndPoint - aStartPoint; + QPoint gradEnd = aStartPoint; + if ( abs( d.x() ) < abs( d.y() ) ) + gradEnd.setX( aEndPoint.x()+1 ); + else + gradEnd.setY( aEndPoint.y()+1 ); + + QLinearGradient linearGradTop(aStartPoint, gradEnd); + linearGradTop.setColorAt(0, iPalette.color( QPalette::Window)); + linearGradTop.setColorAt(1, iPalette.color( QPalette::WindowText)); + aPainter.setBrush(linearGradTop); + aPainter.drawRect( QRect(aStartPoint,aEndPoint) ); +} + +void BorderedBarWidget::drawBorder() +{ + QPainter painter(this); + painter.setPen(Qt::NoPen); + painter.setRenderHint(QPainter::Antialiasing, true); + + /*top left corner*/ + QPoint center(iBorderWidth,iBorderWidth); + drawCorner( painter, center ); + + /*top right corner*/ + center.setX( this->rect().right()-iBorderWidth ); + center.setY( iBorderWidth ); + drawCorner( painter, center ); + + /*bottom left corner*/ + center.setX( iBorderWidth ); + center.setY( this->rect().bottom()-iBorderWidth ); + drawCorner( painter, center ); + + /*bottom right corner*/ + center.setX( this->rect().right()-iBorderWidth ); + center.setY( this->rect().bottom()-iBorderWidth ); + drawCorner( painter, center ); + + /*top*/ + drawSide( painter, QPoint(iBorderWidth,0), QPoint(this->rect().right()-(iBorderWidth+1),(iBorderWidth-1)) ); + + /*right*/ + drawSide( painter, QPoint(this->rect().right(),this->rect().bottom()-iBorderWidth), QPoint(this->rect().right()-(iBorderWidth+1),iBorderWidth-1) ); + + /*bottom*/ + drawSide( painter, QPoint(this->rect().right()-iBorderWidth, this->rect().bottom()), QPoint((iBorderWidth-1),this->rect().bottom()-(iBorderWidth+1)) ); + + /*left*/ + drawSide( painter, QPoint(0,iBorderWidth), QPoint((iBorderWidth-1), this->rect().bottom()-(iBorderWidth+1)) ); + + /*inside*/ + QBrush brush( iPalette.color( QPalette::Window ) ); + painter.setBrush(brush); + QRect inside(iBorderWidth,iBorderWidth,this->rect().right()-2*iBorderWidth,this->rect().bottom()-2*iBorderWidth); + painter.drawRoundRect(inside,iBorderWidth,iBorderWidth); + +} diff --git a/src/UserInterface/Components/BorderedBarWidget.h b/src/UserInterface/Components/BorderedBarWidget.h new file mode 100644 index 0000000..c97b18a --- /dev/null +++ b/src/UserInterface/Components/BorderedBarWidget.h @@ -0,0 +1,131 @@ +#ifndef BORDEREDBARWIDGET_H_ +#define BORDEREDBARWIDGET_H_ + +#include +#include + +//! Userinterface class. Displays text or images with a gradient border. +/*! + * Userinterface class. Displays text or images with a gradient border. Inherits QWidget and + * diplays content in QLabel. + */ +class BorderedBarWidget : public QWidget { + + Q_OBJECT; + +public: + enum TextPosition + { + LeftAlign, /*!< Indicates that the item inserted should be aligned to the left. */ + CenterAlign, /*!< Indicates that the item inserted should be aligned to the center. */ + RightAlign /*!< Indicates that the item inserted should be aligned to the right. */ + }; + +public: + //! Constructor. + /*! + * Constructor to initialize a BorderedBarWidget instance. + * \param aParent Parent widget. Optional. + */ + BorderedBarWidget( QWidget *aParent = 0 ); + //! Destructor. + virtual ~BorderedBarWidget(); + + //! Returns background color. + /*! + * \return The background color of the widget. + */ + QColor backgroundColor(); + //! Returns face color. + /*! + * \return The text and border color. + */ + QColor faceColor(); + //! Returns border width. + /*! + * \return The border width. + */ + int borderWidth(); + //! Returns text. + /*! + * \param aPos Text position. Optional. + * \return The text at a position. + */ + QString text( TextPosition aPos = CenterAlign ); + + //! Sets background color. + /*! + * Sets the background color of the widget. + * \param aColor The new color. + */ + void setBackgroundColor( QColor aColor); + //! Sets face color. + /*! + * Sets the text and border color of the widget. + * \param aColor The new color. + */ + void setFaceColor( QColor aColor ); + //! Sets border width. + /*! + * Sets the width of the border. + * \param aWidth The new width in pixels. + */ + void setBorderWidth( int aWidth ); + //! Sets text. + /*! + * Sets text to a certain position in a bar. + * \param aText The new text. + * \param aPos The position of the text. Optional. + */ + void setText( QString aText, TextPosition aPos = CenterAlign ); + //! Sets pixmap. + /*! + * Sets pixmap to a certain position in a bar. + * \param aPixmap The new pixmap. + * \param aPos The position of the pixmap. Optional. + */ + void setPixmap( QPixmap aPixmap, TextPosition aPos = RightAlign ); + +private: + //! Draws the borders. + /*! + * Handles drawing of the borders. + */ + void drawBorder(); + //! Draws corner. + /*! + * Handles drawing of a corner. + * \param aPainter Painter used for drawing. + * \param aCenter Inner corner of the widget. + */ + void drawCorner( QPainter &aPainter, QPoint &aCenter ); + //! Draws side. + /*! + * Handles drawing of a single side. + * \param aPainter Painter used for drawing. + * \param aStartPoint Start point of drawing area. + * \param aEndPoint End point of drawing area. + */ + void drawSide( QPainter &aPainter, QPoint aStartPoint, QPoint aEndPoint ); + +protected: + //! Handles drawing of the widget. + /*! + * Handles drawing of the widget. + */ + virtual void paintEvent(QPaintEvent *); + +private: + //! Palette for storing colors. + QPalette iPalette; + //! Border width. + int iBorderWidth; + //! Label for left aligned content. + QLabel *iLeftLabel; + //! Label for center aligned content. + QLabel *iCenterLabel; + //! Label for right aligned content. + QLabel *iRightLabel; +}; + +#endif /* BORDEREDBARWIDGET_H_ */ diff --git a/src/UserInterface/Components/MeetingRoomCombo.cpp b/src/UserInterface/Components/MeetingRoomCombo.cpp index fad0493..defd64f 100644 --- a/src/UserInterface/Components/MeetingRoomCombo.cpp +++ b/src/UserInterface/Components/MeetingRoomCombo.cpp @@ -13,8 +13,9 @@ MeetingRoomCombo::MeetingRoomCombo( QList aRooms, QWidget *aParent ) : qSort( iRooms.begin(), iRooms.end(), Room::caseInsensitiveLessThan ); QFont regularTextFont; - regularTextFont.setBold( false ); - regularTextFont.setPointSize( 12 ); + regularTextFont.setStyleHint( QFont::Helvetica ); + regularTextFont.setBold( true ); + regularTextFont.setPixelSize( 18 ); iRoomCombo = new QComboBox( this ); for ( int i = 0; i < iRooms.count(); i++ ) @@ -22,6 +23,7 @@ MeetingRoomCombo::MeetingRoomCombo( QList aRooms, QWidget *aParent ) : iRoomCombo->addItem( iRooms.at( i )->name() ); } iRoomCombo->setFont( regularTextFont ); + iRoomCombo->setFixedHeight( 46 ); connect( iRoomCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setCurrentIndex( int ) ) ); connect( iRoomCombo, SIGNAL( currentIndexChanged( const QString & ) ), this, SLOT( setCurrentRoomBy( const QString & ) ) ); diff --git a/src/UserInterface/Components/ScheduleWidget.cpp b/src/UserInterface/Components/ScheduleWidget.cpp index 0d68da6..65ca353 100644 --- a/src/UserInterface/Components/ScheduleWidget.cpp +++ b/src/UserInterface/Components/ScheduleWidget.cpp @@ -9,11 +9,12 @@ #include #include "Meeting.h" -const QColor ScheduleWidget::sFreeBackground = QColor( 192, 238, 189 ); +const QColor ScheduleWidget::sFreeBackground = QColor( Qt::white ); const QColor ScheduleWidget::sBusyBackground = QColor( 238, 147, 17 ); +const QColor ScheduleWidget::sBusyBackgroundStart = QColor( 254, 193, 104 ); const QColor ScheduleWidget::sHeaderBackground = QColor( Qt::white ); const QColor ScheduleWidget::sDayHighlightColor = QColor( 255, 235, 160 ); -const QColor ScheduleWidget::sTimeHighlightColor = QColor( Qt::blue ); +const QColor ScheduleWidget::sTimeHighlightColor = QColor( Qt::black ); const QColor ScheduleWidget::sMainGridColor = QColor( 140, 140, 140 ); const QColor ScheduleWidget::sHalfGridColor = QColor( 195, 195, 195 ); const QColor ScheduleWidget::sFrameColor = QColor( Qt::black ); @@ -94,8 +95,6 @@ void ScheduleTableWidget::paintEvent( QPaintEvent* aEvent ) } // draw meetings - QBrush brush( ScheduleWidget::sBusyBackground ); - painter.setBrush( brush ); painter.setRenderHint( QPainter::Antialiasing ); painter.setPen( ScheduleWidget::sFrameColor ); populateMeetingList(); @@ -104,6 +103,11 @@ void ScheduleTableWidget::paintEvent( QPaintEvent* aEvent ) { for ( int i = 0; i < iMeetingsByDay[day].size(); ++i ) { + QLinearGradient linearGrad( QPoint(iMeetingsByDay[day][i].rect.x(),iMeetingsByDay[day][i].rect.y()) , QPoint(iMeetingsByDay[day][i].rect.x(),iMeetingsByDay[day][i].rect.bottom()) ); + linearGrad.setColorAt(0, ScheduleWidget::sBusyBackgroundStart); + linearGrad.setColorAt(1, ScheduleWidget::sBusyBackground); + painter.setBrush(linearGrad); + painter.drawRoundRect( iMeetingsByDay[day][i].rect, 20, 20 ); } } @@ -346,7 +350,11 @@ ScheduleWidget::ScheduleWidget( QDateTime aCurrentDateTime, DisplaySettings *aSe ScheduleWidget::~ScheduleWidget() { - delete iScheduleTable; + if ( iScheduleTable ) + { + delete iScheduleTable; + iScheduleTable = 0; + } } QDate ScheduleWidget::beginningOfShownWeek() diff --git a/src/UserInterface/Components/ScheduleWidget.h b/src/UserInterface/Components/ScheduleWidget.h index 47b8e3f..c0269dd 100644 --- a/src/UserInterface/Components/ScheduleWidget.h +++ b/src/UserInterface/Components/ScheduleWidget.h @@ -261,6 +261,9 @@ private: static const QColor sFreeBackground; //! Color for a busy cell. + static const QColor sBusyBackgroundStart; + + //! Color for a busy cell. static const QColor sBusyBackground; //! Color for headers. diff --git a/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp b/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp index ebe2a90..ca53b9d 100644 --- a/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp +++ b/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp @@ -3,7 +3,8 @@ #include #include #include -#include "DigitalTimeDisplayWidget.h" +#include "BorderedBarWidget.h" + #include "ToolBox.h" #include @@ -15,68 +16,80 @@ 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 clockFont; + clockFont.setStyleHint( QFont::Helvetica ); + clockFont.setBold( true ); + clockFont.setPixelSize( 36 ); + + QFont textFont; + textFont.setStyleHint( QFont::Helvetica ); + textFont.setBold( true ); + textFont.setPixelSize( 48 ); - QFont regularTextFont; - //regularTextFont.setBold( true ); - regularTextFont.setPointSize( 12); + QFont statusBarFont; + statusBarFont.setStyleHint( QFont::Helvetica ); + statusBarFont.setPixelSize( 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); + iTimeDisplay = new BorderedBarWidget( this ); + iTimeDisplay->setFaceColor( Qt::darkGray ); + iTimeDisplay->setBackgroundColor( Qt::white ); + iTimeDisplay->setBorderWidth( 6 ); + iTimeDisplay->setFixedWidth( 170 ); + iTimeDisplay->setFixedHeight( 50 ); + iTimeDisplay->setFont( clockFont ); + + iStatusBar = new BorderedBarWidget( this ); + iStatusBar->setFaceColor( Qt::darkGray ); + iStatusBar->setBackgroundColor( Qt::white ); + iStatusBar->setBorderWidth( 4 ); + iStatusBar->setFont(statusBarFont); + iStatusBar->setFixedHeight( 28 ); + QPixmap pixmap(":ixonos_logo"); + iStatusBar->setPixmap( pixmap ); + iStatusBar->setText( tr("Disconnected"), BorderedBarWidget::LeftAlign ); // Pegasus iDefaultRoomLabel - = ToolBox::createLabel(aDefaultRoom->name(), importantTextFont); - iDefaultRoomLabel->setAlignment(Qt::AlignHCenter); - iDefaultRoomLabel->setHidden( true); + = ToolBox::createLabel(aDefaultRoom->name(), textFont); + iDefaultRoomLabel->setAlignment( Qt::AlignHCenter ); + 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); + iStatusLabel = ToolBox::createLabel(tr( "is %1" ).arg(statusToText(aStatus) ), textFont); + iStatusLabel->setAlignment( Qt::AlignHCenter ); + 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(); + = ToolBox::createLabel(tr( "until %1" ).arg(aUntil.toString(iTimeFormat) ), textFont); + iUntilTextLabel->setAlignment( Qt::AlignHCenter ); + iUntilTextLabel->setHidden( true ); + + QHBoxLayout *topLayout = new QHBoxLayout; 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); + + QVBoxLayout *textLayout = new QVBoxLayout; + textLayout->addWidget(iDefaultRoomLabel); + textLayout->addWidget(iStatusLabel); + textLayout->addWidget(iUntilTextLabel); + textLayout->addSpacing( 250 ); + + QHBoxLayout *centerLayout = new QHBoxLayout; + centerLayout->addLayout( textLayout ); + centerLayout->addSpacing( 250 ); + + QHBoxLayout *bottomLayout = new QHBoxLayout; + bottomLayout->addSpacing( 56 ); + bottomLayout->addWidget( iStatusBar ); + bottomLayout->addSpacing( 56 ); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addLayout( topLayout ); + mainLayout->addSpacing( 50 ); + mainLayout->addLayout( centerLayout ); + mainLayout->addLayout( bottomLayout ); setLayout(mainLayout); statusChanged(aStatus, aUntil); @@ -95,6 +108,9 @@ RoomStatusIndicatorWidget::~RoomStatusIndicatorWidget() { delete iTimeDisplay; iTimeDisplay = 0; + + delete iStatusBar; + iStatusBar = 0; } QString RoomStatusIndicatorWidget::statusToText(const Room::Status aStatus) @@ -130,14 +146,14 @@ QPalette RoomStatusIndicatorWidget::createPalette(Room::Status aStatus) QPalette palette; palette.setColor( QPalette::Window, Qt::white ); - palette.setColor( QPalette::WindowText, Qt::darkGray ); + palette.setColor( QPalette::WindowText, Qt::black ); palette.setBrush( QPalette::Window, brush ); return palette; } void RoomStatusIndicatorWidget::setCurrentTime(QTime aCurrentTime) { - iTimeDisplay->setTime(aCurrentTime); + iTimeDisplay->setText( aCurrentTime.toString( iTimeFormat ) ); } void RoomStatusIndicatorWidget::statusChanged(const Room::Status aStatus, const QTime aUntil) @@ -164,11 +180,11 @@ bool RoomStatusIndicatorWidget::event(QEvent *event) switch (event->type()) { case QEvent::Paint: - qDebug() << "[RoomStatusIndicatorWidget::event] "; + //qDebug() << "[RoomStatusIndicatorWidget::event] "; break; case QEvent::PaletteChange: - qDebug() - << "[RoomStatusIndicatorWidget::event] "; + //qDebug() + // << "[RoomStatusIndicatorWidget::event] "; break; default: break; @@ -192,11 +208,11 @@ void RoomStatusIndicatorWidget::connectionEstablished() qDebug() << "RoomStatusIndicatorWidget::connectionEstablished()"; } ViewBase::connectionEstablished(); - iConnectionLabel->setHidden( true); + iStatusBar->setText( tr("Connected"), BorderedBarWidget::LeftAlign ); } void RoomStatusIndicatorWidget::connectionLost() { ViewBase::connectionLost(); - iConnectionLabel->setHidden( false); + iStatusBar->setText( tr("Disconnected"), BorderedBarWidget::LeftAlign ); } diff --git a/src/UserInterface/Views/RoomStatusIndicatorWidget.h b/src/UserInterface/Views/RoomStatusIndicatorWidget.h index 643160a..64978b0 100644 --- a/src/UserInterface/Views/RoomStatusIndicatorWidget.h +++ b/src/UserInterface/Views/RoomStatusIndicatorWidget.h @@ -10,7 +10,7 @@ class QLabel; class QVBoxLayout; -class TimeDisplayWidget; +class BorderedBarWidget; class QEvent; @@ -88,8 +88,9 @@ private: QLabel *iDefaultRoomLabel; QLabel *iStatusLabel; QLabel *iUntilTextLabel; - QLabel *iConnectionLabel; - TimeDisplayWidget *iTimeDisplay; + BorderedBarWidget *iTimeDisplay; + BorderedBarWidget *iStatusBar; + QString iTimeFormat; static QTime endOfTheDay; diff --git a/src/UserInterface/Views/SettingsView.cpp b/src/UserInterface/Views/SettingsView.cpp index 30ab301..0cdb380 100644 --- a/src/UserInterface/Views/SettingsView.cpp +++ b/src/UserInterface/Views/SettingsView.cpp @@ -20,9 +20,18 @@ #include "DisplaySettings.h" #include "ConnectionSettings.h" #include "StartupSettings.h" +#include #include +#define QT_DELETE(X) \ + if ( X != 0 ) \ + { \ + qDebug() << "delete " << X; \ + delete X; \ + X = 0; \ + } + SettingsView::SettingsView( QWidget *aParent ) : ViewBase( ViewBase::NormalView, aParent ) { @@ -66,96 +75,25 @@ SettingsView::SettingsView( QWidget *aParent ) : SettingsView::~SettingsView() { - if ( iTabWidget != 0 ) - { - delete iTabWidget; - iTabWidget = 0; - } - if ( iOkButton != 0 ) - { - delete iOkButton; - iOkButton = 0; - } - if ( iCancelButton != 0 ) - { - delete iCancelButton; - iCancelButton = 0; - } - if ( iSettingsTab != 0 ) - { - delete iSettingsTab; - iSettingsTab = 0; - } - if ( iWeekViewTab != 0 ) - { - delete iWeekViewTab; - iWeekViewTab = 0; - } - if ( iResourcesTab != 0 ) - { - delete iResourcesTab; - iResourcesTab = 0; - } - if ( iKioskModeTab != 0 ) - { - delete iKioskModeTab; - iKioskModeTab = 0; - } - if ( iUserName != 0 ) - { - delete iUserName; - iUserName = 0; - } - if ( iPassword != 0 ) - { - delete iPassword; - iPassword = 0; - } - if ( iServerAddress != 0 ) - { - delete iServerAddress; - iServerAddress = 0; - } - if ( iDayStartTime != 0 ) - { - delete iDayStartTime; - iDayStartTime = 0; - } - if ( iDayEndTime != 0 ) - { - delete iDayEndTime; - iDayEndTime = 0; - } - if ( iFiveDays != 0 ) - { - delete iFiveDays; - iFiveDays = 0; - } - if ( iSevenDays != 0 ) - { - delete iSevenDays; - iSevenDays = 0; - } - if ( iRefreshInterval != 0 ) - { - delete iRefreshInterval; - iRefreshInterval = 0; - } - if ( iPowerSaveEnabled != 0 ) - { - delete iPowerSaveEnabled; - iPowerSaveEnabled = 0; - } - if ( iPowerSaveStartTime != 0 ) - { - delete iPowerSaveStartTime; - iPowerSaveStartTime = 0; - } - if ( iPowerSaveEndTime != 0 ) - { - delete iPowerSaveEndTime; - iPowerSaveEndTime = 0; - } + QT_DELETE(iOkButton); + QT_DELETE(iCancelButton); + QT_DELETE(iUserName); + QT_DELETE(iPassword); + QT_DELETE(iServerAddress); + QT_DELETE(iDayStartTime); + QT_DELETE(iDayEndTime); + QT_DELETE(iFiveDays); + QT_DELETE(iSevenDays); + QT_DELETE(iRefreshInterval); + QT_DELETE(iPowerSaveEnabled); + QT_DELETE(iPowerSaveStartTime); + QT_DELETE(iPowerSaveEndTime); + QT_DELETE(iSettingsTab); + QT_DELETE(iWeekViewTab); + QT_DELETE(iResourcesTab); + QT_DELETE(iKioskModeTab); + QT_DELETE(iTabWidget); + } QWidget *SettingsView::initSettingsTab() @@ -208,7 +146,9 @@ QWidget *SettingsView::initSettingsTab() widget->setLayout( mainLayout ); - return widget; + QScrollArea *scroll = new QScrollArea; + scroll->setWidget(widget); + return scroll; } QWidget *SettingsView::initWeekViewTab() @@ -251,7 +191,9 @@ QWidget *SettingsView::initWeekViewTab() widget->setLayout( mainLayout ); - return widget; + QScrollArea *scroll = new QScrollArea; + scroll->setWidget(widget); + return scroll; } QWidget *SettingsView::initResourcesTab() @@ -298,7 +240,9 @@ QWidget *SettingsView::initResourcesTab() widget->setLayout( mainLayout ); - return widget; + QScrollArea *scroll = new QScrollArea; + scroll->setWidget(widget); + return scroll; } QWidget *SettingsView::initKioskModeTab() @@ -369,7 +313,9 @@ QWidget *SettingsView::initKioskModeTab() widget->setLayout( mainLayout ); - return widget; + QScrollArea *scroll = new QScrollArea; + scroll->setWidget(widget); + return scroll; } void SettingsView::handleOkClicked() @@ -394,14 +340,14 @@ void SettingsView::handleOkClicked() // set values to Configuration // set user information - Configuration::instance()->connectionSettings()->setUsername( userName ); - Configuration::instance()->connectionSettings()->setPassword( password ); + Configuration::instance()->setUsername(userName);//connectionSettings()->setUsername( userName ); + Configuration::instance()->setPassword(password);//connectionSettings()->setPassword( password ); // set server information - Configuration::instance()->connectionSettings()->setServerUrl( serverAddress ); + Configuration::instance()->setServerUrl(serverAddress);//connectionSettings()->setServerUrl( serverAddress ); if ( ok ) { - Configuration::instance()->connectionSettings()->setRefreshInterval( refreshInterval ); + Configuration::instance()->setRefreshinterval(refreshInterval);//connectionSettings()->setRefreshInterval( refreshInterval ); } // set weekly view settings @@ -448,12 +394,12 @@ void SettingsView::handleCancelClicked() void SettingsView::setValues() { // set user information - iUserName->setText( Configuration::instance()->connectionSettings()->username() ); - iPassword->setText( Configuration::instance()->connectionSettings()->password() ); + iUserName->setText( Configuration::instance()->getUsername() ); + iPassword->setText( Configuration::instance()->getPassword());//connectionSettings()->password() ); // set server information - iServerAddress->setText( Configuration::instance()->connectionSettings()->serverUrl().toString() ); + iServerAddress->setText( Configuration::instance()->getServerUrl().toString());//connectionSettings()->serverUrl().toString() ); QString refreshIntervalStr; - refreshIntervalStr.setNum( Configuration::instance()->connectionSettings()->refreshInterval() ); + refreshIntervalStr.setNum( Configuration::instance()->getRefreshinterval());//connectionSettings()->refreshInterval() ); iRefreshInterval->setText( refreshIntervalStr ); // set weekly view display settings if ( Configuration::instance()->displaySettings()->daysInSchedule() == DisplaySettings::WeekdaysInSchedule ) diff --git a/src/UserInterface/Views/WeeklyViewWidget.cpp b/src/UserInterface/Views/WeeklyViewWidget.cpp index 643732e..6c8b75c 100644 --- a/src/UserInterface/Views/WeeklyViewWidget.cpp +++ b/src/UserInterface/Views/WeeklyViewWidget.cpp @@ -16,6 +16,7 @@ #include "ScheduleWidget.h" #include "ToolBox.h" #include "MeetingInfoDialog.h" +#include "BorderedBarWidget.h" #include @@ -33,6 +34,20 @@ WeeklyViewWidget::WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *a regularTextFont.setBold( true ); regularTextFont.setPointSize( 12 ); + QFont clockFont; + clockFont.setStyleHint( QFont::Helvetica ); + clockFont.setBold( true ); + clockFont.setPixelSize( 36 ); + + QFont statusBarFont; + statusBarFont.setStyleHint( QFont::Helvetica ); + statusBarFont.setPixelSize( 12 ); + + QFont buttonFont; + buttonFont.setStyleHint( QFont::Helvetica ); + buttonFont.setBold( true ); + buttonFont.setPixelSize( 18 ); + iSettingsButton = new QPushButton; iSettingsButton->setIcon( QPixmap( ":button_settings" ) ); iSettingsButton->setFixedWidth( 36 ); @@ -41,57 +56,89 @@ WeeklyViewWidget::WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *a iCurrentDayLabel = ToolBox::createLabel( aCurrentDateTime.toString( iConfiguration->displaySettings()->dateFormat() ), regularTextFont ); iCurrentWeekLabel = ToolBox::createLabel( tr( "Wk %1" ).arg( aCurrentDateTime.date().weekNumber() ), regularTextFont ); + iTimeDisplay = new BorderedBarWidget( this ); + iTimeDisplay->setFaceColor( Qt::darkGray ); + iTimeDisplay->setBackgroundColor( Qt::white); + iTimeDisplay->setBorderWidth( 6 ); + iTimeDisplay->setFixedWidth( 170 ); + iTimeDisplay->setFixedHeight( 50 ); + iTimeDisplay->setFont( clockFont ); + iRoomsCombo = new MeetingRoomCombo( iConfiguration->rooms(), this ); iRoomsCombo->setCurrentRoom( iConfiguration->defaultRoom() ); connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( currentRoomChanged( Room * ) ) ); - iTimeDisplay = new DigitalTimeDisplayWidget( aCurrentDateTime.time(), iConfiguration->displaySettings()->timeFormat(), this ); - iTimeDisplay->setFrameVisible( false ); - iTimeDisplay->setFont( regularTextFont ); + iStatusBar = new BorderedBarWidget( this ); + iStatusBar->setFaceColor( Qt::darkGray ); + iStatusBar->setBackgroundColor( Qt::white ); + iStatusBar->setBorderWidth( 4 ); + iStatusBar->setFont(statusBarFont); + iStatusBar->setFixedHeight( 28 ); + QPixmap pixmap(":ixonos_logo"); + iStatusBar->setPixmap( pixmap ); iSchedule = new ScheduleWidget( aCurrentDateTime, iConfiguration->displaySettings(), this ); connect( iSchedule, SIGNAL( shownWeekChanged( QDate ) ), this, SIGNAL( shownWeekChanged( QDate ) ) ); connect( iSchedule, SIGNAL( meetingActivated( Meeting* ) ), this, SIGNAL( meetingActivated( Meeting* ) ) ); iPreviousWeekButton = new QPushButton( this ); - iPreviousWeekButton->setText( tr( "<<" ) ); - iPreviousWeekButton->setFixedWidth( 60 ); + iPreviousWeekButton->setText( tr( "<" ) ); + iPreviousWeekButton->setFixedWidth( 50 ); + iPreviousWeekButton->setFixedHeight( 100 ); + iPreviousWeekButton->setFont( buttonFont ); connect( iPreviousWeekButton, SIGNAL( clicked() ), iSchedule, SLOT( showPreviousWeek() ) ); iCurrentWeekButton = new QPushButton( this ); iCurrentWeekButton->setFixedWidth( 100 ); - iCurrentWeekButton->setText( tr( "Current" ) ); + iCurrentWeekButton->setFixedHeight( 46 ); + iCurrentWeekButton->setText( tr( "Today" ) ); + iCurrentWeekButton->setFont( buttonFont ); + connect( iCurrentWeekButton, SIGNAL( clicked() ), iSchedule, SLOT( showCurrentWeek() ) ); iNextWeekButton = new QPushButton( this ); - iNextWeekButton->setFixedWidth( 60 ); - iNextWeekButton->setText( tr( ">>" ) ); + iNextWeekButton->setFixedWidth( 50 ); + iNextWeekButton->setFixedHeight( 100 ); + iNextWeekButton->setText( tr( ">" ) ); + iNextWeekButton->setFont( buttonFont ); connect( iNextWeekButton, SIGNAL( clicked() ), iSchedule, SLOT( showNextWeek() ) ); // ********************************** // Create the view's layout + QVBoxLayout *leftLayout = new QVBoxLayout; + QVBoxLayout *centerLayout = new QVBoxLayout; + QVBoxLayout *rightLayout = new QVBoxLayout; + + leftLayout->addWidget( iPreviousWeekButton ); + rightLayout->addWidget( iNextWeekButton ); + QHBoxLayout *tableLayout = new QHBoxLayout; tableLayout->addWidget( iSchedule ); - QHBoxLayout *bottomLayout = new QHBoxLayout; - bottomLayout->addWidget( iRoomsCombo ); - bottomLayout->addWidget( iTimeDisplay ); - QVBoxLayout *dateLayout = new QVBoxLayout; - dateLayout->addWidget( iCurrentDayLabel ); - dateLayout->addWidget( iCurrentWeekLabel ); - bottomLayout->addLayout( dateLayout ); - bottomLayout->addWidget( iPreviousWeekButton ); - bottomLayout->addWidget( iCurrentWeekButton ); - bottomLayout->addWidget( iNextWeekButton ); - bottomLayout->addWidget( iSettingsButton ); - - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addLayout( tableLayout ); - mainLayout->addLayout( bottomLayout ); + QGridLayout *naviLayout = new QGridLayout; + naviLayout->addWidget( iCurrentWeekButton, 0, 0, Qt::AlignLeft ); + naviLayout->addWidget( iTimeDisplay, 0, 1, Qt::AlignCenter ); + naviLayout->addWidget( iRoomsCombo, 0, 2, Qt::AlignRight ); + +// QVBoxLayout *dateLayout = new QVBoxLayout; +// dateLayout->addWidget( iCurrentDayLabel ); +// dateLayout->addWidget( iCurrentWeekLabel ); +// bottomLayout->addLayout( dateLayout ); +// bottomLayout->addWidget( iSettingsButton ); + + centerLayout->addLayout( naviLayout ); + centerLayout->addLayout( tableLayout ); + centerLayout->addWidget( iStatusBar ); + + QHBoxLayout *mainLayout = new QHBoxLayout; + mainLayout->addLayout( leftLayout ); + mainLayout->addLayout( centerLayout ); + mainLayout->addLayout( rightLayout ); setLayout( mainLayout ); // Set child observing observeChild( iRoomsCombo ); + observeChild( iStatusBar ); observeChild( iTimeDisplay ); observeChild( iCurrentDayLabel ); observeChild( iCurrentWeekLabel ); @@ -102,7 +149,7 @@ WeeklyViewWidget::WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *a QPalette palette; palette.setColor( QPalette::Window, Qt::white ); - palette.setColor( QPalette::WindowText, Qt::darkGray ); + palette.setColor( QPalette::Foreground, Qt::darkGray ); setPalette( palette ); setAutoFillBackground( true ); @@ -132,6 +179,12 @@ WeeklyViewWidget::~WeeklyViewWidget() delete iTimeDisplay; iTimeDisplay = 0; } + if ( iStatusBar ) + { + delete iStatusBar; + iStatusBar = 0; + } + if ( iSchedule ) { delete iSchedule; @@ -180,7 +233,7 @@ void WeeklyViewWidget::setCurrentDateTime( QDateTime aCurrentDateTime ) iCurrentWeekLabel->setText( tr( "Wk %1" ).arg( aCurrentDateTime.date().weekNumber() ) ); - iTimeDisplay->setTime( aCurrentDateTime.time() ); + iTimeDisplay->setText( aCurrentDateTime.toString( iConfiguration->displaySettings()->timeFormat() ) ); iSchedule->setCurrentDateTime( aCurrentDateTime ); } @@ -205,3 +258,16 @@ void WeeklyViewWidget::setDefaultRoom() { iRoomsCombo->setCurrentRoom( iConfiguration->defaultRoom() ); } + +void WeeklyViewWidget::connectionEstablished() +{ + ViewBase::connectionEstablished(); + qDebug() << "WeeklyViewWidget::connectionEstablished"; + iStatusBar->setText( tr("Connected"), BorderedBarWidget::LeftAlign ); +} + +void WeeklyViewWidget::connectionLost() +{ + ViewBase::connectionLost(); + iStatusBar->setText( tr("Disconnected"), BorderedBarWidget::LeftAlign ); +} diff --git a/src/UserInterface/Views/WeeklyViewWidget.h b/src/UserInterface/Views/WeeklyViewWidget.h index 055617b..79a1fee 100644 --- a/src/UserInterface/Views/WeeklyViewWidget.h +++ b/src/UserInterface/Views/WeeklyViewWidget.h @@ -1,155 +1,162 @@ -#ifndef WEEKLYVIEWWIDGET_H_ -#define WEEKLYVIEWWIDGET_H_ - -#include "ViewBase.h" -#include - -class QLabel; -class QPushButton; -class MeetingRoomCombo; -class TimeDisplayWidget; -class ScheduleWidget; -class Configuration; -class Meeting; -class Room; - -//! Userinterface class. Shows a weekly calendar for the selected room, provides date and time information. -/*! - * UserInterface class. Shows the current date and time and selected week's calendar for - * selected meeting room. User can select meeting room, browse weeks back and forth, and can navigate - * back to the current week. - */ -class WeeklyViewWidget : public ViewBase -{ - Q_OBJECT - -public: - //! Constructor. - /*! - * Constructor to initialize an WeeklyViewWidget instance. - * \param aCurrentDateTime - * \param aConfiguration Pointer to the configuration object. Not owned. - * \param aParent Pointer to the parent widget. - */ - WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *aConfiguration, QWidget *aParent = 0 ); - //! Destructor. - virtual ~WeeklyViewWidget(); - - //! Current room - /*! - * Returns the currently selected meeting room. - * \return Selected meeting room. - */ - Room* currentRoom(); - - //! First day of week currently displayd - /*! - * Returns the first day of week currently displayd. - * \return First day of week. - */ - QDate beginnigOfShownWeek(); - //! Sends the refresh command to schedule widget. - /*! - * Sends the refresh command to schedule widget. - * \param aMeetings The list of meetings. - */ - void refreshMeetings( const QList &aMeetings ); - - void showCurrentWeek(); - - void setDefaultRoom(); - -signals: - //! Signals change of the meeting room. - /*! - * Signal is emited when meeting room is changed. - * \param aNewRoom Selected meeting room. - */ - void currentRoomChanged( Room *aNewRoom ); - //! Meeting activated. - /*! - * Signal is emitted when a meeting is clicked by the user. - * \param aMeeting actived meeting. - */ - void meetingActivated( Meeting *aMeeting ); - //! Signals creation of new meeting. - /*! - * Signal is emited when new meeting is created. - * \param aMeeting Meeting that has been created. - * \param aUsername User who created the meeting. - * \param aPassword Password of the "aUsername" - */ - void meetingToCreate( Meeting *aMeeting, const QString &aUsername, const QString &aPassword ); - //! Signals deletion of a meeting. - /*! - * Signal is emited when meeting is deleted. - * \param aMeeting Deleted meeting. - * \param aUsername User who deleted the meeting. - * \param aPassword Password of the "aUsername" - */ - void meetingToDelete( Meeting *aMeeting, const QString &aUsername, const QString &aPassword ); - //! Signals modifications of a meeting. - /*! - * Signal is emited when meeting is modified. - * \param aMeeting Modified meeting. - * \param aUsername User who modified the meeting. - * \param aPassword Password of the "aUsername" - */ - void meetingToUpdate( Meeting *aMeeting, const QString &aUsername, const QString &aPassword ); - - //! Signals - /*! - * Signal is emited when settings button is clicked. - */ - void settingsButtonClicked(); - - //! Signal. Emitted if the shown week has been changed. - /*! +#ifndef WEEKLYVIEWWIDGET_H_ +#define WEEKLYVIEWWIDGET_H_ + +#include "ViewBase.h" +#include + +class QLabel; +class QPushButton; +class MeetingRoomCombo; +class TimeDisplayWidget; +class ScheduleWidget; +class Configuration; +class Meeting; +class Room; +class BorderedBarWidget; + +//! Userinterface class. Shows a weekly calendar for the selected room, provides date and time information. +/*! + * UserInterface class. Shows the current date and time and selected week's calendar for + * selected meeting room. User can select meeting room, browse weeks back and forth, and can navigate + * back to the current week. + */ +class WeeklyViewWidget : public ViewBase +{ + Q_OBJECT + +public: + //! Constructor. + /*! + * Constructor to initialize an WeeklyViewWidget instance. + * \param aCurrentDateTime + * \param aConfiguration Pointer to the configuration object. Not owned. + * \param aParent Pointer to the parent widget. + */ + WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *aConfiguration, QWidget *aParent = 0 ); + //! Destructor. + virtual ~WeeklyViewWidget(); + + //! Current room + /*! + * Returns the currently selected meeting room. + * \return Selected meeting room. + */ + Room* currentRoom(); + + //! First day of week currently displayd + /*! + * Returns the first day of week currently displayd. + * \return First day of week. + */ + QDate beginnigOfShownWeek(); + //! Sends the refresh command to schedule widget. + /*! + * Sends the refresh command to schedule widget. + * \param aMeetings The list of meetings. + */ + void refreshMeetings( const QList &aMeetings ); + + void showCurrentWeek(); + + void setDefaultRoom(); + +signals: + //! Signals change of the meeting room. + /*! + * Signal is emited when meeting room is changed. + * \param aNewRoom Selected meeting room. + */ + void currentRoomChanged( Room *aNewRoom ); + //! Meeting activated. + /*! + * Signal is emitted when a meeting is clicked by the user. + * \param aMeeting actived meeting. + */ + void meetingActivated( Meeting *aMeeting ); + //! Signals creation of new meeting. + /*! + * Signal is emited when new meeting is created. + * \param aMeeting Meeting that has been created. + * \param aUsername User who created the meeting. + * \param aPassword Password of the "aUsername" + */ + void meetingToCreate( Meeting *aMeeting, const QString &aUsername, const QString &aPassword ); + //! Signals deletion of a meeting. + /*! + * Signal is emited when meeting is deleted. + * \param aMeeting Deleted meeting. + * \param aUsername User who deleted the meeting. + * \param aPassword Password of the "aUsername" + */ + void meetingToDelete( Meeting *aMeeting, const QString &aUsername, const QString &aPassword ); + //! Signals modifications of a meeting. + /*! + * Signal is emited when meeting is modified. + * \param aMeeting Modified meeting. + * \param aUsername User who modified the meeting. + * \param aPassword Password of the "aUsername" + */ + void meetingToUpdate( Meeting *aMeeting, const QString &aUsername, const QString &aPassword ); + + //! Signals + /*! + * Signal is emited when settings button is clicked. + */ + void settingsButtonClicked(); + + //! Signal. Emitted if the shown week has been changed. + /*! * Signal. Emitted if the shown week has been changed. * \param aDate The first date of the shown week. */ - void shownWeekChanged( QDate aDate ); - -public slots: - //! Sets the date and time - /*! - * Sets the current date and time - * \param aCurrentDateTime Date and time to be displayd. - */ - void setCurrentDateTime( QDateTime aCurrentDateTime ); - //! Handle resizing - /*! - * Handle possible resize changes after the view is resized - * to match the window managers client area. - */ - void viewResized(const QSize &newSize, const QSize &oldSize) { } - -private: - //! Displays the selectable meeting rooms. - MeetingRoomCombo *iRoomsCombo; - //! Displays the time. - TimeDisplayWidget *iTimeDisplay; - //! Displays the calendar. - ScheduleWidget *iSchedule; - //! Displays the date. - QLabel *iCurrentDayLabel; - //! Displays the week number. - QLabel *iCurrentWeekLabel; - //! Button used to display previous week's calendar. - QPushButton *iPreviousWeekButton; - //! Button used to display current week's calendar. - QPushButton *iCurrentWeekButton; - //! Button used to display next week's calendar. - QPushButton *iNextWeekButton; - //! Settings button. TODO : Correct widget is needed!! - QPushButton *iSettingsButton; - //! About button. TODO : Correct widget is needed!! - QPushButton *iAboutButton; - /* ! - * Pointer to configuration object. - * Contains configurable data and IS NOT OWNED by the widget. - */ - Configuration *iConfiguration; -}; - -#endif /*WEEKLYVIEWWIDGET_H_*/ + void shownWeekChanged( QDate aDate ); + +public slots: + //! Sets the date and time + /*! + * Sets the current date and time + * \param aCurrentDateTime Date and time to be displayd. + */ + void setCurrentDateTime( QDateTime aCurrentDateTime ); + //! Handle resizing + /*! + * Handle possible resize changes after the view is resized + * to match the window managers client area. + */ + void viewResized(const QSize &newSize, const QSize &oldSize) { } + + void connectionEstablished(); + + void connectionLost(); + +private: + //! Displays the selectable meeting rooms. + MeetingRoomCombo *iRoomsCombo; + //! Displays the time. + BorderedBarWidget *iTimeDisplay; + //! Displays the status. + BorderedBarWidget *iStatusBar; + //! Displays the calendar. + ScheduleWidget *iSchedule; + //! Displays the date. + QLabel *iCurrentDayLabel; + //! Displays the week number. + QLabel *iCurrentWeekLabel; + //! Button used to display previous week's calendar. + QPushButton *iPreviousWeekButton; + //! Button used to display current week's calendar. + QPushButton *iCurrentWeekButton; + //! Button used to display next week's calendar. + QPushButton *iNextWeekButton; + //! Settings button. TODO : Correct widget is needed!! + QPushButton *iSettingsButton; + //! About button. TODO : Correct widget is needed!! + QPushButton *iAboutButton; + /* ! + * Pointer to configuration object. + * Contains configurable data and IS NOT OWNED by the widget. + */ + Configuration *iConfiguration; +}; + +#endif /*WEEKLYVIEWWIDGET_H_*/ diff --git a/src/UserInterface/WindowManager.cpp b/src/UserInterface/WindowManager.cpp index af006f1..d7a1252 100644 --- a/src/UserInterface/WindowManager.cpp +++ b/src/UserInterface/WindowManager.cpp @@ -2,17 +2,21 @@ #include #include +#include #include "ViewBase.h" #include "PopUpMessageBox.h" #include WindowManager::WindowManager( QWidget *aParent ) : - QWidget( aParent ), + QMainWindow( aParent ), iApplicationName( tr( "Qt Meetings" ) ), iCurrentView( 0 ) { this->setWindowTitle( iApplicationName ); + settingsAction = new QAction(tr("&Settings"), this); + connect(settingsAction, SIGNAL(triggered()), this, SIGNAL(showSettingsClicked())); + menuBar()->addAction(settingsAction); } WindowManager::~WindowManager() @@ -44,8 +48,12 @@ void WindowManager::showView( ViewBase *view ) iCurrentView = view; connect( iCurrentView, SIGNAL( eventDetected() ), this, SLOT( viewEventDetected() ) ); connect( this, SIGNAL( viewResized(const QSize &, const QSize &) ), iCurrentView, SLOT( viewResized( const QSize &, const QSize & ) ) ); - view->resize( this->size() ); - + if (((QWidget*)view) != this) + { + this->adjustSize(); + } + view->resize(this->size()); + //view->adjustSize(); view->show(); // Disconnect old connections and hide the view diff --git a/src/UserInterface/WindowManager.h b/src/UserInterface/WindowManager.h index aa736cf..d110767 100644 --- a/src/UserInterface/WindowManager.h +++ b/src/UserInterface/WindowManager.h @@ -1,7 +1,7 @@ #ifndef WINDOWMANAGER_H_ #define WINDOWMANAGER_H_ -#include +#include #include // Forward declarations @@ -18,7 +18,7 @@ class QString; * 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 +class WindowManager : public QMainWindow { Q_OBJECT @@ -58,6 +58,8 @@ signals: */ void previousViewRestored(); + void showSettingsClicked(); + void dialogActivated(); void dialogDeactivated(); @@ -102,6 +104,7 @@ private: //! Stack of views previously displayed. QStack iViewList; + QAction *settingsAction; }; #endif /*WINDOWMANAGER_H_*/