mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-15 18:32:27 +12:00
Add ability to save fullscreen panel settings
This includes the auto-hide of each panel as well as the shown/hidden status of each of the displays. Now that it's consistent, it makes it so much more useful.
This commit is contained in:
parent
932550be89
commit
58ab998ad9
|
@ -34,6 +34,12 @@ viewSettings = {
|
|||
},
|
||||
}
|
||||
|
||||
fullscreenSettings = {
|
||||
"autohide-top": True,
|
||||
"autohide-bottom": True,
|
||||
"autohide-left": True,
|
||||
}
|
||||
|
||||
# Application
|
||||
spellcheck = False
|
||||
dict = None
|
||||
|
@ -119,10 +125,11 @@ def save(filename=None, protocol=None):
|
|||
global spellcheck, dict, corkSliderFactor, viewSettings, corkSizeFactor, folderView, lastTab, openIndexes, \
|
||||
autoSave, autoSaveDelay, saveOnQuit, autoSaveNoChanges, autoSaveNoChangesDelay, outlineViewColumns, \
|
||||
corkBackground, corkStyle, fullScreenTheme, defaultTextType, textEditor, revisions, frequencyAnalyzer, viewMode, \
|
||||
saveToZip, dontShowDeleteWarning
|
||||
saveToZip, dontShowDeleteWarning, fullscreenSettings
|
||||
|
||||
allSettings = {
|
||||
"viewSettings": viewSettings,
|
||||
"fullscreenSettings": fullscreenSettings,
|
||||
"dict": dict,
|
||||
"spellcheck": spellcheck,
|
||||
"corkSizeFactor": corkSizeFactor,
|
||||
|
@ -199,6 +206,10 @@ def load(string, fromString=False, protocol=None):
|
|||
if not name in viewSettings[cat]:
|
||||
viewSettings[cat][name] = default
|
||||
|
||||
if "fullscreenSettings" in allSettings:
|
||||
global fullscreenSettings
|
||||
fullscreenSettings = allSettings["fullscreenSettings"]
|
||||
|
||||
if "dict" in allSettings:
|
||||
global dict
|
||||
dict = allSettings["dict"]
|
||||
|
|
|
@ -112,9 +112,12 @@ 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, ))
|
||||
self.bottomPanel.addDisplay(self.tr("Theme selector"), 'bottom-theme', (self.lstThemes, themeLabel))
|
||||
self.bottomPanel.addDisplay(self.tr("Word count"), 'bottom-wc', (self.lblWC, ))
|
||||
self.bottomPanel.addDisplay(self.tr("Progress"), 'bottom-progress', (self.lblProgress, ))
|
||||
self.bottomPanel.setAutoHideVariable('autohide-bottom')
|
||||
self.topPanel.setAutoHideVariable('autohide-top')
|
||||
self.leftPanel.setAutoHideVariable('autohide-left')
|
||||
|
||||
# Connection
|
||||
self._index.model().dataChanged.connect(self.dataChanged)
|
||||
|
@ -364,6 +367,7 @@ class myPanel(QWidget):
|
|||
self.setAttribute(Qt.WA_TranslucentBackground)
|
||||
self._autoHide = True
|
||||
self._m = None
|
||||
self._autoHideVar = None
|
||||
self._displays = []
|
||||
|
||||
if not vertical:
|
||||
|
@ -382,13 +386,24 @@ class myPanel(QWidget):
|
|||
|
||||
def setAutoHide(self, value):
|
||||
self._autoHide = value
|
||||
if self._autoHideVar:
|
||||
settings.fullscreenSettings[self._autoHideVar] = value
|
||||
|
||||
def addDisplay(self, name, widgets):
|
||||
self._displays.append((name, widgets))
|
||||
def setAutoHideVariable(self, name):
|
||||
if name:
|
||||
self.setAutoHide(settings.fullscreenSettings[name])
|
||||
self._autoHideVar = name
|
||||
|
||||
def setDisplay(self, value, widgets):
|
||||
for w in widgets:
|
||||
def addDisplay(self, label, config_name, widgets):
|
||||
display = (label, config_name, widgets)
|
||||
self._displays.append(display)
|
||||
if settings.fullscreenSettings.get(config_name, None) is not None:
|
||||
self.setDisplay(settings.fullscreenSettings[config_name], display)
|
||||
|
||||
def setDisplay(self, value, display):
|
||||
for w in display[2]:
|
||||
w.show() if value else w.hide()
|
||||
settings.fullscreenSettings[display[1]] = value
|
||||
|
||||
def mouseReleaseEvent(self, event):
|
||||
if event.button() == Qt.RightButton:
|
||||
|
@ -403,10 +418,10 @@ class myPanel(QWidget):
|
|||
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]))
|
||||
a.setChecked(item[2][0].isVisible())
|
||||
def gen_cb(disp):
|
||||
return lambda v: self.setDisplay(v, disp)
|
||||
a.toggled.connect(gen_cb(item))
|
||||
m.addAction(a)
|
||||
m.popup(self.mapToGlobal(event.pos()))
|
||||
self._m = m
|
||||
|
|
Loading…
Reference in a new issue