diff options
author | Ken Moore <ken@ixsystems.com> | 2018-02-01 09:48:11 -0500 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2018-02-01 09:48:11 -0500 |
commit | 9d3f929c27127bbc8f9d4b3d286c5d979f7203e4 (patch) | |
tree | 273f7323c6b1acfa690c1e45bc3ee37ca52feb07 /src-qt5/core/lumina-desktop-unified/src-desktop | |
parent | Get a unified system clock setup within the RootDesktopObject. (diff) | |
download | lumina-9d3f929c27127bbc8f9d4b3d286c5d979f7203e4.tar.gz lumina-9d3f929c27127bbc8f9d4b3d286c5d979f7203e4.tar.bz2 lumina-9d3f929c27127bbc8f9d4b3d286c5d979f7203e4.zip |
Finish getting the session settings all loaded by the Desktop Manager.
Also ensure the desktop clock is a bit smarter about when it changes it's functionality (just in case the setting did not change).
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified/src-desktop')
4 files changed, 37 insertions, 13 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.cpp index be315596..35bd288d 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.cpp @@ -20,6 +20,7 @@ DesktopManager::~DesktopManager(){ void DesktopManager::start(){ connect(DesktopSettings::instance(), SIGNAL(FileModified(DesktopSettings::File)), this, SLOT(settingsChanged(DesktopSettings::File)) ); //Perform the initial load of the settings files + QTimer::singleShot(0, this, SLOT(updateSessionSettings()) ); QTimer::singleShot(0, this, SLOT(updateDesktopSettings()) ); QTimer::singleShot(0, this, SLOT(updatePanelSettings()) ); QTimer::singleShot(0, this, SLOT(updatePluginSettings()) ); @@ -96,16 +97,18 @@ void DesktopManager::workspaceChanged(int wknum){ void DesktopManager::settingsChanged(DesktopSettings::File type){ switch(type){ + case DesktopSettings::Session: + QTimer::singleShot(0, this, SLOT(updateSessionSettings()) ); case DesktopSettings::Desktop: - QTimer::singleShot(0, this, SLOT(updateDesktopSettings()) ); + QTimer::singleShot(1, this, SLOT(updateDesktopSettings()) ); case DesktopSettings::Panels: - QTimer::singleShot(1, this, SLOT(updatePanelSettings()) ); + QTimer::singleShot(2, this, SLOT(updatePanelSettings()) ); case DesktopSettings::Plugins: - QTimer::singleShot(2, this, SLOT(updatePluginSettings()) ); + QTimer::singleShot(3, this, SLOT(updatePluginSettings()) ); case DesktopSettings::ContextMenu: - QTimer::singleShot(3, this, SLOT(updateMenuSettings()) ); + QTimer::singleShot(4, this, SLOT(updateMenuSettings()) ); case DesktopSettings::Animation: - QTimer::singleShot(4, this, SLOT(updateAnimationSettings()) ); + QTimer::singleShot(5, this, SLOT(updateAnimationSettings()) ); default: break; //Do nothing - not a settings change we care about here @@ -144,6 +147,12 @@ void DesktopManager::syncTrayWindowList(){ } // === PRIVATE SLOTS === +void DesktopManager::updateSessionSettings(){ + qDebug() << "Update Session Settings..."; + + RootDesktopObject::instance()->updateCurrentTimeFormat(DesktopSettings::instance()->value(DesktopSettings::Session, "datetime_format", "").toString()); +} + void DesktopManager::updateDesktopSettings(){ qDebug() << "Update Desktop Settings..."; QList<QScreen*> scrns = QGuiApplication::screens(); diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.h b/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.h index da42e477..b3511318 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/DesktopManager.h @@ -36,6 +36,7 @@ public slots: void syncTrayWindowList(); private slots: + void updateSessionSettings(); void updateDesktopSettings(); void updatePanelSettings(); void updatePluginSettings(); diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp index 0585ae2c..b1bd939b 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp @@ -111,6 +111,10 @@ QString RootDesktopObject::currentTime(){ return currentTimeString; } +QDateTime RootDesktopObject::currentDateTime(){ + return currentDateTimeStruct; +} + OSInterface* RootDesktopObject::os_interface(){ return OSInterface::instance(); } @@ -182,14 +186,19 @@ void RootDesktopObject::setTrayWindows(QList<NativeWindowObject*> list){ } void RootDesktopObject::updateCurrentTimeFormat(QString fmt){ - currentTimeFormat = fmt.simplified(); - if(currentTimeTimer->isActive()){ currentTimeTimer->stop(); } //sanitize the time format as needed - if(fmt.contains("z")){ currentTimeFormat.replace("z",""); } //do not allow millisecond updates - too fast for the desktop + if(fmt.contains("z")){ fmt.replace("z",""); } //do not allow millisecond updates - too fast for the desktop + fmt = fmt.simplified(); + //Verify that anything has changed first + if(currentTimeFormat == fmt && currentTimeTimer->isActive()){ return; } //nothing changed + if(currentTimeTimer->isActive()){ currentTimeTimer->stop(); } //make sure this does not trigger during the changeover + currentTimeFormat = fmt; + int interval = 1000; //default to 1 second intervals //Adjust the refresh time for the clock based on the smallest unit requested - if(fmt.contains("s")){ currentTimeTimer->setInterval(500); } //1/2 second pings for 1-second displays - else if(fmt.contains("m") || currentTimeFormat.isEmpty()){ currentTimeTimer->setInterval(5000); } //5 second pings for 1-minute displays - else{ currentTimeTimer->setInterval(60000); } //1 minute pings for 1-hour displays + if(fmt.contains("s")){ interval=500; } //1/2 second pings for 1-second displays + else if(fmt.contains("m") || currentTimeFormat.isEmpty()){ interval = 5000; } //5 second pings for 1-minute displays + else if(fmt.contains("h")){ interval = 30000; } //30 second pings for 1-hour displays + currentTimeTimer->setInterval(interval); updateCurrentTime(); //refresh the currently-available time currentTimeTimer->start();//start the update timer } @@ -267,10 +276,12 @@ QString RootDesktopObject::CurrentWallpaper(QString screen){ // === PRIVATE SLOTS === void RootDesktopObject::updateCurrentTime(){ + QDateTime DT = QDateTime::currentDateTime(); QString tmp; - if(currentTimeFormat.isEmpty()){ tmp = QDateTime::currentDateTime().toString(Qt::DefaultLocaleShortDate); } - else{ tmp = QDateTime::currentDateTime().toString(currentTimeFormat); } + if(currentTimeFormat.isEmpty()){ tmp = DT.toString(Qt::DefaultLocaleShortDate); } + else{ tmp = DT.toString(currentTimeFormat); } if(tmp!=currentTimeString){ //prevent sending signals to update the interface if nothing changed + currentDateTimeStruct = DT; currentTimeString = tmp; emit currentTimeChanged(); } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h index e7ce50e0..a6a4a236 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h @@ -21,6 +21,7 @@ class RootDesktopObject : public QObject{ Q_PROPERTY( QStringList trayWindows READ trayWindows NOTIFY trayWindowsChanged) Q_PROPERTY( bool hasTrayWindows READ hasTrayWindows NOTIFY trayWindowsChanged) Q_PROPERTY( QString currentTime READ currentTime NOTIFY currentTimeChanged); + Q_PROPERTY( QDateTime currentDateTime READ currentDateTime NOTIFY currentTimeChanged); public: //main contructor/destructor @@ -43,6 +44,7 @@ public: Q_INVOKABLE NativeWindowObject* trayWindow(QString id); Q_INVOKABLE bool hasTrayWindows(); Q_INVOKABLE QString currentTime(); + Q_INVOKABLE QDateTime currentDateTime(); //QML Globals Access Q_INVOKABLE OSInterface* os_interface(); @@ -61,6 +63,7 @@ private: QPointer<NativeWindowObject> last_window_up; QTimer *currentTimeTimer; QString currentTimeFormat, currentTimeString; + QDateTime currentDateTimeStruct; public slots: void updateScreens(); //rescan/update screen objects |