Show or hide the status bar timer when it is clicked

This commit is contained in:
Veronica Berglyd Olsen
2024-12-29 17:30:03 +01:00
parent 1b34bc30c7
commit dc9413fa7e
2 changed files with 22 additions and 2 deletions
+3
View File
@@ -194,6 +194,7 @@ class Config:
# State # State
self.showViewerPanel = True # The panel for the viewer is visible self.showViewerPanel = True # The panel for the viewer is visible
self.showEditToolBar = False # The document editor toolbar visibility 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.viewComments = True # Comments are shown in the viewer
self.viewSynopsis = True # Synopsis is shown in the viewer self.viewSynopsis = True # Synopsis is shown in the viewer
@@ -674,6 +675,7 @@ class Config:
sec = "State" sec = "State"
self.showViewerPanel = conf.rdBool(sec, "showviewerpanel", self.showViewerPanel) self.showViewerPanel = conf.rdBool(sec, "showviewerpanel", self.showViewerPanel)
self.showEditToolBar = conf.rdBool(sec, "showedittoolbar", self.showEditToolBar) 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.viewComments = conf.rdBool(sec, "viewcomments", self.viewComments)
self.viewSynopsis = conf.rdBool(sec, "viewsynopsis", self.viewSynopsis) self.viewSynopsis = conf.rdBool(sec, "viewsynopsis", self.viewSynopsis)
self.searchCase = conf.rdBool(sec, "searchcase", self.searchCase) self.searchCase = conf.rdBool(sec, "searchcase", self.searchCase)
@@ -784,6 +786,7 @@ class Config:
conf["State"] = { conf["State"] = {
"showviewerpanel": str(self.showViewerPanel), "showviewerpanel": str(self.showViewerPanel),
"showedittoolbar": str(self.showEditToolBar), "showedittoolbar": str(self.showEditToolBar),
"showsessiontime": str(self.showSessionTime),
"viewcomments": str(self.viewComments), "viewcomments": str(self.viewComments),
"viewsynopsis": str(self.viewSynopsis), "viewsynopsis": str(self.viewSynopsis),
"searchcase": str(self.searchCase), "searchcase": str(self.searchCase),
+19 -2
View File
@@ -35,6 +35,7 @@ from novelwriter import CONFIG, SHARED
from novelwriter.common import formatTime from novelwriter.common import formatTime
from novelwriter.constants import nwConst from novelwriter.constants import nwConst
from novelwriter.enum import nwTrinary from novelwriter.enum import nwTrinary
from novelwriter.extensions.modified import NClickableLabel
from novelwriter.extensions.statusled import StatusLED from novelwriter.extensions.statusled import StatusLED
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -92,12 +93,16 @@ class GuiMainStatus(QStatusBar):
# The Session Clock # The Session Clock
# Set the minimum width so the label doesn't rescale every second # Set the minimum width so the label doesn't rescale every second
self.timeIcon = QLabel(self) self.timeIcon = NClickableLabel(self)
self.timeText = QLabel("", self) self.timeIcon.mouseClick.connect(self._onClickTimerLabel)
self.timeText = NClickableLabel("", self)
self.timeText.setToolTip(self.tr("Session Time")) self.timeText.setToolTip(self.tr("Session Time"))
self.timeText.setMinimumWidth(SHARED.theme.getTextWidth("00:00:00:")) self.timeText.setMinimumWidth(SHARED.theme.getTextWidth("00:00:00:"))
self.timeIcon.setContentsMargins(0, 0, 0, 0) self.timeIcon.setContentsMargins(0, 0, 0, 0)
self.timeText.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.timeIcon)
self.addPermanentWidget(self.timeText) self.addPermanentWidget(self.timeText)
@@ -224,6 +229,18 @@ class GuiMainStatus(QStatusBar):
self.setDocumentStatus(nwTrinary.NEGATIVE if status else nwTrinary.POSITIVE) self.setDocumentStatus(nwTrinary.NEGATIVE if status else nwTrinary.POSITIVE)
return 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 # Debug
## ##