From 2d754641b534b0aa5ad02a8c9e599afc1613127a Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Mon, 8 Feb 2021 23:40:21 +0100 Subject: [PATCH] Add a switch to hide the idle time column --- nw/core/options.py | 1 + nw/gui/writingstats.py | 28 +++++++++++++++++++++++++++- nw/guimain.py | 1 - 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/nw/core/options.py b/nw/core/options.py index b7d0e752..c7849bb0 100644 --- a/nw/core/options.py +++ b/nw/core/options.py @@ -55,6 +55,7 @@ class OptionState(): "hideZeros", "hideNegative", "groupByDay", + "showIdleTime", "histMax", }, "GuiDocSplit": { diff --git a/nw/gui/writingstats.py b/nw/gui/writingstats.py index f0114b75..6063ecf1 100644 --- a/nw/gui/writingstats.py +++ b/nw/gui/writingstats.py @@ -204,17 +204,25 @@ class GuiWritingStats(QDialog): ) self.groupByDay.clicked.connect(self._updateListBox) + self.showIdleTime = QSwitch(width=2*sPx, height=sPx) + self.showIdleTime.setChecked( + self.optState.getBool("GuiWritingStats", "showIdleTime", False) + ) + self.showIdleTime.clicked.connect(self._idleTimeVisibility) + self.filterForm.addWidget(QLabel("Count novel files"), 0, 0) self.filterForm.addWidget(QLabel("Count note files"), 1, 0) self.filterForm.addWidget(QLabel("Hide zero word count"), 2, 0) self.filterForm.addWidget(QLabel("Hide negative word count"), 3, 0) self.filterForm.addWidget(QLabel("Group entries by day"), 4, 0) + self.filterForm.addWidget(QLabel("Show idle time column"), 5, 0) self.filterForm.addWidget(self.incNovel, 0, 1) self.filterForm.addWidget(self.incNotes, 1, 1) self.filterForm.addWidget(self.hideZeros, 2, 1) self.filterForm.addWidget(self.hideNegative, 3, 1) self.filterForm.addWidget(self.groupByDay, 4, 1) - self.filterForm.setRowStretch(5, 1) + self.filterForm.addWidget(self.showIdleTime, 5, 1) + self.filterForm.setRowStretch(6, 1) # Settings self.histMax = QSpinBox(self) @@ -263,6 +271,9 @@ class GuiWritingStats(QDialog): self.setLayout(self.outerBox) + # Finalise + self._idleTimeVisibility(None) + logger.debug("GuiWritingStats initialisation complete") return @@ -298,8 +309,12 @@ class GuiWritingStats(QDialog): hideZeros = self.hideZeros.isChecked() hideNegative = self.hideNegative.isChecked() groupByDay = self.groupByDay.isChecked() + showIdleTime = self.showIdleTime.isChecked() histMax = self.histMax.value() + if not showIdleTime: + widthCol2 = 80 + self.optState.setValue("GuiWritingStats", "winWidth", winWidth) self.optState.setValue("GuiWritingStats", "winHeight", winHeight) self.optState.setValue("GuiWritingStats", "widthCol0", widthCol0) @@ -313,6 +328,7 @@ class GuiWritingStats(QDialog): self.optState.setValue("GuiWritingStats", "hideZeros", hideZeros) self.optState.setValue("GuiWritingStats", "hideNegative", hideNegative) self.optState.setValue("GuiWritingStats", "groupByDay", groupByDay) + self.optState.setValue("GuiWritingStats", "showIdleTime", showIdleTime) self.optState.setValue("GuiWritingStats", "histMax", histMax) self.optState.saveSettings() @@ -477,6 +493,16 @@ class GuiWritingStats(QDialog): return True + ## + # Slots + ## + + def _idleTimeVisibility(self, dummyVar=None): + """ + """ + self.listBox.setColumnHidden(self.C_IDLE, not self.showIdleTime.isChecked()) + return + def _updateListBox(self, dummyVar=None): """Load/reload the content of the list box. The dummyVar variable captures the variable sent from the widgets connecting diff --git a/nw/guimain.py b/nw/guimain.py index 816856a0..37dca06b 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -1440,7 +1440,6 @@ class GuiMain(QMainWindow): self.idleRefTime = currTime self.statusBar.updateTime(idleTime=self.idleTime) - # print(editIdle, userIdle, self.idleTime) return