From dc9413fa7e735b5a4cd84b68dbfdbd3b62bf81ca Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sun, 29 Dec 2024 17:30:03 +0100 Subject: [PATCH] Show or hide the status bar timer when it is clicked --- novelwriter/config.py | 3 +++ novelwriter/gui/statusbar.py | 21 +++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/novelwriter/config.py b/novelwriter/config.py index d1ae57b5..bbe8ebd2 100644 --- a/novelwriter/config.py +++ b/novelwriter/config.py @@ -194,6 +194,7 @@ class Config: # State self.showViewerPanel = True # The panel for the viewer is visible self.showEditToolBar = False # The document editor toolbar visibility + self.showSessionTime = True # Show the session time in the status bar self.viewComments = True # Comments are shown in the viewer self.viewSynopsis = True # Synopsis is shown in the viewer @@ -674,6 +675,7 @@ class Config: sec = "State" self.showViewerPanel = conf.rdBool(sec, "showviewerpanel", self.showViewerPanel) self.showEditToolBar = conf.rdBool(sec, "showedittoolbar", self.showEditToolBar) + self.showSessionTime = conf.rdBool(sec, "showsessiontime", self.showSessionTime) self.viewComments = conf.rdBool(sec, "viewcomments", self.viewComments) self.viewSynopsis = conf.rdBool(sec, "viewsynopsis", self.viewSynopsis) self.searchCase = conf.rdBool(sec, "searchcase", self.searchCase) @@ -784,6 +786,7 @@ class Config: conf["State"] = { "showviewerpanel": str(self.showViewerPanel), "showedittoolbar": str(self.showEditToolBar), + "showsessiontime": str(self.showSessionTime), "viewcomments": str(self.viewComments), "viewsynopsis": str(self.viewSynopsis), "searchcase": str(self.searchCase), diff --git a/novelwriter/gui/statusbar.py b/novelwriter/gui/statusbar.py index e7459c53..6b2b727e 100644 --- a/novelwriter/gui/statusbar.py +++ b/novelwriter/gui/statusbar.py @@ -35,6 +35,7 @@ from novelwriter import CONFIG, SHARED from novelwriter.common import formatTime from novelwriter.constants import nwConst from novelwriter.enum import nwTrinary +from novelwriter.extensions.modified import NClickableLabel from novelwriter.extensions.statusled import StatusLED logger = logging.getLogger(__name__) @@ -92,12 +93,16 @@ class GuiMainStatus(QStatusBar): # The Session Clock # Set the minimum width so the label doesn't rescale every second - self.timeIcon = QLabel(self) - self.timeText = QLabel("", self) + self.timeIcon = NClickableLabel(self) + self.timeIcon.mouseClick.connect(self._onClickTimerLabel) + + self.timeText = NClickableLabel("", self) self.timeText.setToolTip(self.tr("Session Time")) self.timeText.setMinimumWidth(SHARED.theme.getTextWidth("00:00:00:")) self.timeIcon.setContentsMargins(0, 0, 0, 0) self.timeText.setContentsMargins(0, 0, 0, 0) + self.timeText.setVisible(CONFIG.showSessionTime) + self.timeText.mouseClick.connect(self._onClickTimerLabel) self.addPermanentWidget(self.timeIcon) self.addPermanentWidget(self.timeText) @@ -224,6 +229,18 @@ class GuiMainStatus(QStatusBar): self.setDocumentStatus(nwTrinary.NEGATIVE if status else nwTrinary.POSITIVE) return + ## + # Private Slots + ## + + @pyqtSlot() + def _onClickTimerLabel(self) -> None: + """Process mouse click on timer label.""" + state = not CONFIG.showSessionTime + self.timeText.setVisible(state) + CONFIG.showSessionTime = state + return + ## # Debug ##