From 932550be89002045ee155812007c8e7f85e43a59 Mon Sep 17 00:00:00 2001 From: Youness Alaoui Date: Thu, 21 Feb 2019 20:07:59 -0500 Subject: [PATCH] fullscreen: Add 'displays' to the bottom panel that can be shown/hidden. This is an experimental idea. We can add to a myPanel a list of widgets to show/hide if the user wants to, via the context menu. This can be very useful for a user who wants to disable auto-hide for the bottom panel but remove the theme selector which can be useless to have open permanently. This is the first step in fixing #234. Would need the auto-hide and the displays configurations to be saved in settings though before it can become usable. --- manuskript/ui/editors/fullScreenEditor.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/manuskript/ui/editors/fullScreenEditor.py b/manuskript/ui/editors/fullScreenEditor.py index 1f6ee258..1f47984c 100644 --- a/manuskript/ui/editors/fullScreenEditor.py +++ b/manuskript/ui/editors/fullScreenEditor.py @@ -98,7 +98,8 @@ class fullScreenEditor(QWidget): # self.lstThemes.setCurrentText(settings.fullScreenTheme) self.lstThemes.currentTextChanged.connect(self.setTheme) self.lstThemes.setMaximumSize(QSize(300, QFontMetrics(qApp.font()).height())) - self.bottomPanel.layout().addWidget(QLabel(self.tr("Theme:"), self)) + themeLabel = QLabel(self.tr("Theme:"), self) + self.bottomPanel.layout().addWidget(themeLabel) self.bottomPanel.layout().addWidget(self.lstThemes) self.bottomPanel.layout().addStretch(1) @@ -111,6 +112,9 @@ class fullScreenEditor(QWidget): self.updateStatusBar() self.bottomPanel.layout().addSpacing(24) + self.bottomPanel.addDisplay(self.tr("Theme selector"), (self.lstThemes, themeLabel)) + self.bottomPanel.addDisplay(self.tr("Word count"), (self.lblWC, )) + self.bottomPanel.addDisplay(self.tr("Progress"), (self.lblProgress, )) # Connection self._index.model().dataChanged.connect(self.dataChanged) @@ -360,6 +364,7 @@ class myPanel(QWidget): self.setAttribute(Qt.WA_TranslucentBackground) self._autoHide = True self._m = None + self._displays = [] if not vertical: self.setLayout(QHBoxLayout()) @@ -378,6 +383,13 @@ class myPanel(QWidget): def setAutoHide(self, value): self._autoHide = value + def addDisplay(self, name, widgets): + self._displays.append((name, widgets)) + + def setDisplay(self, value, widgets): + for w in widgets: + w.show() if value else w.hide() + def mouseReleaseEvent(self, event): if event.button() == Qt.RightButton: if self._m: @@ -388,5 +400,13 @@ class myPanel(QWidget): a.setChecked(self._autoHide) a.toggled.connect(self.setAutoHide) m.addAction(a) + for item in self._displays: + a = QAction(item[0], m) + a.setCheckable(True) + a.setChecked(item[1][0].isVisible()) + def gen_cb(w): + return lambda v: self.setDisplay(v, w) + a.toggled.connect(gen_cb(item[1])) + m.addAction(a) m.popup(self.mapToGlobal(event.pos())) self._m = m