mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #8174 (Persist plugin configuration dialog size/position)
This commit is contained in:
parent
67c9bec212
commit
5c6a17b25b
@ -110,10 +110,21 @@ class Plugin(object): # {{{
|
|||||||
'''
|
'''
|
||||||
from PyQt4.Qt import QDialog, QDialogButtonBox, QVBoxLayout, \
|
from PyQt4.Qt import QDialog, QDialogButtonBox, QVBoxLayout, \
|
||||||
QLabel, Qt, QLineEdit
|
QLabel, Qt, QLineEdit
|
||||||
|
from calibre.gui2 import gprefs
|
||||||
|
|
||||||
|
prefname = 'plugin config dialog:'+self.type + ':' + self.name
|
||||||
|
geom = gprefs.get(prefname, None)
|
||||||
|
|
||||||
config_dialog = QDialog(parent)
|
config_dialog = QDialog(parent)
|
||||||
button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
||||||
v = QVBoxLayout(config_dialog)
|
v = QVBoxLayout(config_dialog)
|
||||||
|
|
||||||
|
def size_dialog():
|
||||||
|
if geom is None:
|
||||||
|
config_dialog.resize(config_dialog.sizeHint())
|
||||||
|
else:
|
||||||
|
config_dialog.restoreGeometry(geom)
|
||||||
|
|
||||||
button_box.accepted.connect(config_dialog.accept)
|
button_box.accepted.connect(config_dialog.accept)
|
||||||
button_box.rejected.connect(config_dialog.reject)
|
button_box.rejected.connect(config_dialog.reject)
|
||||||
config_dialog.setWindowTitle(_('Customize') + ' ' + self.name)
|
config_dialog.setWindowTitle(_('Customize') + ' ' + self.name)
|
||||||
@ -125,6 +136,7 @@ class Plugin(object): # {{{
|
|||||||
if config_widget is not None:
|
if config_widget is not None:
|
||||||
v.addWidget(config_widget)
|
v.addWidget(config_widget)
|
||||||
v.addWidget(button_box)
|
v.addWidget(button_box)
|
||||||
|
size_dialog()
|
||||||
config_dialog.exec_()
|
config_dialog.exec_()
|
||||||
|
|
||||||
if config_dialog.result() == QDialog.Accepted:
|
if config_dialog.result() == QDialog.Accepted:
|
||||||
@ -150,12 +162,16 @@ class Plugin(object): # {{{
|
|||||||
sc = QLineEdit(sc, config_dialog)
|
sc = QLineEdit(sc, config_dialog)
|
||||||
v.addWidget(sc)
|
v.addWidget(sc)
|
||||||
v.addWidget(button_box)
|
v.addWidget(button_box)
|
||||||
|
size_dialog()
|
||||||
config_dialog.exec_()
|
config_dialog.exec_()
|
||||||
|
|
||||||
if config_dialog.result() == QDialog.Accepted:
|
if config_dialog.result() == QDialog.Accepted:
|
||||||
sc = unicode(sc.text()).strip()
|
sc = unicode(sc.text()).strip()
|
||||||
customize_plugin(self, sc)
|
customize_plugin(self, sc)
|
||||||
|
|
||||||
|
geom = bytearray(config_dialog.saveGeometry())
|
||||||
|
gprefs[prefname] = geom
|
||||||
|
|
||||||
return config_dialog.result()
|
return config_dialog.result()
|
||||||
|
|
||||||
def load_resources(self, names):
|
def load_resources(self, names):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user