mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-06-13 16:34:34 +12:00
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.
This commit is contained in:
parent
7f1671db0c
commit
932550be89
|
@ -98,7 +98,8 @@ class fullScreenEditor(QWidget):
|
||||||
# self.lstThemes.setCurrentText(settings.fullScreenTheme)
|
# self.lstThemes.setCurrentText(settings.fullScreenTheme)
|
||||||
self.lstThemes.currentTextChanged.connect(self.setTheme)
|
self.lstThemes.currentTextChanged.connect(self.setTheme)
|
||||||
self.lstThemes.setMaximumSize(QSize(300, QFontMetrics(qApp.font()).height()))
|
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().addWidget(self.lstThemes)
|
||||||
self.bottomPanel.layout().addStretch(1)
|
self.bottomPanel.layout().addStretch(1)
|
||||||
|
|
||||||
|
@ -111,6 +112,9 @@ class fullScreenEditor(QWidget):
|
||||||
self.updateStatusBar()
|
self.updateStatusBar()
|
||||||
|
|
||||||
self.bottomPanel.layout().addSpacing(24)
|
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
|
# Connection
|
||||||
self._index.model().dataChanged.connect(self.dataChanged)
|
self._index.model().dataChanged.connect(self.dataChanged)
|
||||||
|
@ -360,6 +364,7 @@ class myPanel(QWidget):
|
||||||
self.setAttribute(Qt.WA_TranslucentBackground)
|
self.setAttribute(Qt.WA_TranslucentBackground)
|
||||||
self._autoHide = True
|
self._autoHide = True
|
||||||
self._m = None
|
self._m = None
|
||||||
|
self._displays = []
|
||||||
|
|
||||||
if not vertical:
|
if not vertical:
|
||||||
self.setLayout(QHBoxLayout())
|
self.setLayout(QHBoxLayout())
|
||||||
|
@ -378,6 +383,13 @@ class myPanel(QWidget):
|
||||||
def setAutoHide(self, value):
|
def setAutoHide(self, value):
|
||||||
self._autoHide = 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):
|
def mouseReleaseEvent(self, event):
|
||||||
if event.button() == Qt.RightButton:
|
if event.button() == Qt.RightButton:
|
||||||
if self._m:
|
if self._m:
|
||||||
|
@ -388,5 +400,13 @@ class myPanel(QWidget):
|
||||||
a.setChecked(self._autoHide)
|
a.setChecked(self._autoHide)
|
||||||
a.toggled.connect(self.setAutoHide)
|
a.toggled.connect(self.setAutoHide)
|
||||||
m.addAction(a)
|
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()))
|
m.popup(self.mapToGlobal(event.pos()))
|
||||||
self._m = m
|
self._m = m
|
||||||
|
|
Loading…
Reference in a new issue