aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2018-02-01 09:48:11 -0500
committerKen Moore <ken@ixsystems.com>2018-02-01 09:48:11 -0500
commit9d3f929c27127bbc8f9d4b3d286c5d979f7203e4 (patch)
tree273f7323c6b1acfa690c1e45bc3ee37ca52feb07 /src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp
parentGet a unified system clock setup within the RootDesktopObject. (diff)
downloadlumina-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/src-cpp/RootDesktopObject.cpp')
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp27
1 files changed, 19 insertions, 8 deletions
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();
}
bgstack15