From b1eca89a058a884967ad4535ee66400cc0d1b257 Mon Sep 17 00:00:00 2001
From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com>
Date: Tue, 9 Feb 2021 18:28:22 +0100
Subject: [PATCH] Switch icon when session timer is paused
---
nw/assets/icons/fallback/status_idle-dark.svg | 31 +++++++++++++++++++
nw/assets/icons/fallback/status_idle.svg | 31 +++++++++++++++++++
nw/gui/statusbar.py | 19 +++++++++++-
nw/gui/theme.py | 1 +
nw/guimain.py | 3 ++
5 files changed, 84 insertions(+), 1 deletion(-)
create mode 100644 nw/assets/icons/fallback/status_idle-dark.svg
create mode 100644 nw/assets/icons/fallback/status_idle.svg
diff --git a/nw/assets/icons/fallback/status_idle-dark.svg b/nw/assets/icons/fallback/status_idle-dark.svg
new file mode 100644
index 00000000..b0480586
--- /dev/null
+++ b/nw/assets/icons/fallback/status_idle-dark.svg
@@ -0,0 +1,31 @@
+
+
diff --git a/nw/assets/icons/fallback/status_idle.svg b/nw/assets/icons/fallback/status_idle.svg
new file mode 100644
index 00000000..deafb10d
--- /dev/null
+++ b/nw/assets/icons/fallback/status_idle.svg
@@ -0,0 +1,31 @@
+
+
diff --git a/nw/gui/statusbar.py b/nw/gui/statusbar.py
index ebc0593a..b7723963 100644
--- a/nw/gui/statusbar.py
+++ b/nw/gui/statusbar.py
@@ -48,6 +48,7 @@ class GuiMainStatus(QStatusBar):
self.theParent = theParent
self.theTheme = theParent.theTheme
self.refTime = None
+ self.userIdle = False
colNone = QColor(*self.theTheme.statNone)
colTrue = QColor(*self.theTheme.statUnsaved)
@@ -96,9 +97,12 @@ class GuiMainStatus(QStatusBar):
## The Session Clock
### Set the mimimum width so the label doesn't rescale every second
+ self.timePixmap = self.theTheme.getPixmap("status_time", (iPx, iPx))
+ self.idlePixmap = self.theTheme.getPixmap("status_idle", (iPx, iPx))
+
self.timeIcon = QLabel()
self.timeText = QLabel("")
- self.timeIcon.setPixmap(self.theTheme.getPixmap("status_time", (iPx, iPx)))
+ self.timeIcon.setPixmap(self.timePixmap)
self.timeText.setToolTip("Session Time")
self.timeText.setMinimumWidth(self.theTheme.getTextWidth("00:00:00:"))
self.timeIcon.setContentsMargins(0, 0, 0, 0)
@@ -175,6 +179,19 @@ class GuiMainStatus(QStatusBar):
self.statsText.setToolTip("Project word count (session change)")
return
+ def setUserIdle(self, userIdle):
+ """Change the idle status icon.
+ """
+ if self.userIdle != userIdle:
+ if userIdle:
+ self.timeIcon.setPixmap(self.idlePixmap)
+ else:
+ self.timeIcon.setPixmap(self.timePixmap)
+
+ self.userIdle = userIdle
+
+ return
+
def updateTime(self, idleTime=0.0):
"""Update the session clock.
"""
diff --git a/nw/gui/theme.py b/nw/gui/theme.py
index 14ce5ec3..9ec6018e 100644
--- a/nw/gui/theme.py
+++ b/nw/gui/theme.py
@@ -539,6 +539,7 @@ class GuiIcons:
"proj_nwx" : (None, None),
"status_lang" : (None, None),
"status_time" : (None, None),
+ "status_idle" : (None, None),
"status_stats" : (None, None),
"status_lines" : (None, None),
"doc_h0" : (QStyle.SP_FileIcon, "x-office-document"),
diff --git a/nw/guimain.py b/nw/guimain.py
index 37dca06b..344bafbd 100644
--- a/nw/guimain.py
+++ b/nw/guimain.py
@@ -1437,6 +1437,9 @@ class GuiMain(QMainWindow):
if editIdle or userIdle:
self.idleTime += currTime - self.idleRefTime
+ self.statusBar.setUserIdle(True)
+ else:
+ self.statusBar.setUserIdle(False)
self.idleRefTime = currTime
self.statusBar.updateTime(idleTime=self.idleTime)