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:26:58 -0500
committerKen Moore <ken@ixsystems.com>2018-02-01 09:26:58 -0500
commit18330354e918d7fd369a6b6273da023b86a6242c (patch)
tree8c6f4a00cedc456acc8d62428facb25e875a41fd /src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp
parentAnother large batch of work on Lumina 2. (diff)
downloadlumina-18330354e918d7fd369a6b6273da023b86a6242c.tar.gz
lumina-18330354e918d7fd369a6b6273da023b86a6242c.tar.bz2
lumina-18330354e918d7fd369a6b6273da023b86a6242c.zip
Get a unified system clock setup within the RootDesktopObject.
This can be used for any number of display clocks as needed without extra overhead
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.cpp29
1 files changed, 29 insertions, 0 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 77dd2d79..0585ae2c 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
@@ -16,6 +16,8 @@ RootDesktopObject::RootDesktopObject(QObject *parent) : QObject(parent){
last_window_up = 0;
updateScreens(); //make sure the internal list is updated right away
connect(this, SIGNAL(changePanels(QStringList)), this, SLOT(setPanels(QStringList)) );
+ currentTimeTimer = new QTimer(this);
+ connect(currentTimeTimer, SIGNAL(timeout()), this, SLOT(updateCurrentTime()) );
}
RootDesktopObject::~RootDesktopObject(){
@@ -105,6 +107,10 @@ bool RootDesktopObject::hasTrayWindows(){
return !tray_window_objects.isEmpty();
}
+QString RootDesktopObject::currentTime(){
+ return currentTimeString;
+}
+
OSInterface* RootDesktopObject::os_interface(){
return OSInterface::instance();
}
@@ -175,6 +181,18 @@ void RootDesktopObject::setTrayWindows(QList<NativeWindowObject*> list){
mousePositionChanged(true);
}
+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
+ //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
+ updateCurrentTime(); //refresh the currently-available time
+ currentTimeTimer->start();//start the update timer
+}
void RootDesktopObject::logout(){
//Emit the logout signal in a few ms (let the display close/sync first)
@@ -246,3 +264,14 @@ QString RootDesktopObject::CurrentWallpaper(QString screen){
// === PRIVATE ===
+
+// === PRIVATE SLOTS ===
+void RootDesktopObject::updateCurrentTime(){
+ QString tmp;
+ if(currentTimeFormat.isEmpty()){ tmp = QDateTime::currentDateTime().toString(Qt::DefaultLocaleShortDate); }
+ else{ tmp = QDateTime::currentDateTime().toString(currentTimeFormat); }
+ if(tmp!=currentTimeString){ //prevent sending signals to update the interface if nothing changed
+ currentTimeString = tmp;
+ emit currentTimeChanged();
+ }
+}
bgstack15