Store addonconf geom and splitter. Tweak font sizes and margins.

This commit is contained in:
Glutanimate 2019-02-23 09:02:06 +01:00
parent ff7b06fbda
commit 1080ae10f9
2 changed files with 16 additions and 3 deletions

View File

@ -11,7 +11,8 @@ from send2trash import send2trash
from aqt.qt import * from aqt.qt import *
from aqt.utils import showInfo, openFolder, isWin, openLink, \ from aqt.utils import showInfo, openFolder, isWin, openLink, \
askUser, restoreGeom, saveGeom, showWarning, tooltip, getFile askUser, restoreGeom, saveGeom, restoreSplitter, saveSplitter, \
showWarning, tooltip, getFile
from zipfile import ZipFile from zipfile import ZipFile
import aqt.forms import aqt.forms
import aqt import aqt
@ -640,6 +641,8 @@ class ConfigEditor(QDialog):
self.setupFonts() self.setupFonts()
self.updateHelp() self.updateHelp()
self.updateText(self.conf) self.updateText(self.conf)
restoreGeom(self, "addonconf")
restoreSplitter(self.form.splitter, "addonconf")
self.show() self.show()
def onRestoreDefaults(self): def onRestoreDefaults(self):
@ -648,6 +651,7 @@ class ConfigEditor(QDialog):
def setupFonts(self): def setupFonts(self):
font_mono = QFontDatabase.systemFont(QFontDatabase.FixedFont) font_mono = QFontDatabase.systemFont(QFontDatabase.FixedFont)
font_mono.setPointSize(font_mono.pointSize() + 1)
self.form.editor.setFont(font_mono) self.form.editor.setFont(font_mono)
def updateHelp(self): def updateHelp(self):
@ -662,6 +666,14 @@ class ConfigEditor(QDialog):
json.dumps(conf, ensure_ascii=False, sort_keys=True, json.dumps(conf, ensure_ascii=False, sort_keys=True,
indent=4, separators=(',', ': '))) indent=4, separators=(',', ': ')))
def onClose(self):
saveGeom(self, "addonconf")
saveSplitter(self.form.splitter, "addonconf")
def reject(self):
self.onClose()
super().reject()
def accept(self): def accept(self):
txt = self.form.editor.toPlainText() txt = self.form.editor.toPlainText()
try: try:
@ -681,4 +693,5 @@ class ConfigEditor(QDialog):
if act: if act:
act(new_conf) act(new_conf)
self.onClose()
super().accept() super().accept()

View File

@ -57,7 +57,7 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin"> <property name="leftMargin">
<number>4</number> <number>6</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>0</number> <number>0</number>