mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #2003 (Enclose plugin config widget in a scrollarea)
This commit is contained in:
parent
fd25c117c5
commit
6966986ece
@ -1,9 +1,13 @@
|
|||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
|
|
||||||
import os, sys, zipfile, importlib, enum
|
import enum
|
||||||
|
import importlib
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import zipfile
|
||||||
|
|
||||||
from calibre.constants import numeric_version, iswindows, ismacos
|
from calibre.constants import ismacos, iswindows, numeric_version
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
|
|
||||||
if iswindows:
|
if iswindows:
|
||||||
@ -141,8 +145,11 @@ class Plugin: # {{{
|
|||||||
True if the user clicks OK, False otherwise. The changes are
|
True if the user clicks OK, False otherwise. The changes are
|
||||||
automatically applied.
|
automatically applied.
|
||||||
'''
|
'''
|
||||||
from qt.core import QDialog, QDialogButtonBox, QVBoxLayout, \
|
from qt.core import (
|
||||||
QLabel, Qt, QLineEdit
|
QApplication, QDialog, QDialogButtonBox, QLabel, QLineEdit, QScrollArea, Qt,
|
||||||
|
QVBoxLayout, QSize
|
||||||
|
)
|
||||||
|
|
||||||
from calibre.gui2 import gprefs
|
from calibre.gui2 import gprefs
|
||||||
|
|
||||||
prefname = 'plugin config dialog:'+self.type + ':' + self.name
|
prefname = 'plugin config dialog:'+self.type + ':' + self.name
|
||||||
@ -164,9 +171,18 @@ class Plugin: # {{{
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if config_widget is not None:
|
if config_widget is not None:
|
||||||
v.addWidget(config_widget)
|
class SA(QScrollArea):
|
||||||
|
def sizeHint(self):
|
||||||
|
sz = self.widget().sizeHint()
|
||||||
|
fw = 2 * self.frameWidth()
|
||||||
|
return QSize(sz.width() + self.verticalScrollBar().sizeHint().width() + fw, sz.height() + fw)
|
||||||
|
sa = SA(config_dialog)
|
||||||
|
sa.setWidget(config_widget)
|
||||||
|
sa.setWidgetResizable(True)
|
||||||
|
v.addWidget(sa)
|
||||||
v.addWidget(button_box)
|
v.addWidget(button_box)
|
||||||
config_dialog.restore_geometry(gprefs, prefname)
|
if not config_dialog.restore_geometry(gprefs, prefname):
|
||||||
|
QApplication.instance().ensure_window_on_screen(config_dialog)
|
||||||
config_dialog.exec()
|
config_dialog.exec()
|
||||||
|
|
||||||
if config_dialog.result() == QDialog.DialogCode.Accepted:
|
if config_dialog.result() == QDialog.DialogCode.Accepted:
|
||||||
@ -176,8 +192,7 @@ class Plugin: # {{{
|
|||||||
else:
|
else:
|
||||||
self.save_settings(config_widget)
|
self.save_settings(config_widget)
|
||||||
else:
|
else:
|
||||||
from calibre.customize.ui import plugin_customization, \
|
from calibre.customize.ui import customize_plugin, plugin_customization
|
||||||
customize_plugin
|
|
||||||
help_text = self.customization_help(gui=True)
|
help_text = self.customization_help(gui=True)
|
||||||
help_text = QLabel(help_text, config_dialog)
|
help_text = QLabel(help_text, config_dialog)
|
||||||
help_text.setWordWrap(True)
|
help_text.setWordWrap(True)
|
||||||
@ -273,8 +288,9 @@ class Plugin: # {{{
|
|||||||
import something
|
import something
|
||||||
'''
|
'''
|
||||||
if self.plugin_path is not None:
|
if self.plugin_path is not None:
|
||||||
from calibre.utils.zipfile import ZipFile
|
|
||||||
from importlib.machinery import EXTENSION_SUFFIXES
|
from importlib.machinery import EXTENSION_SUFFIXES
|
||||||
|
|
||||||
|
from calibre.utils.zipfile import ZipFile
|
||||||
with ZipFile(self.plugin_path) as zf:
|
with ZipFile(self.plugin_path) as zf:
|
||||||
extensions = {x.lower() for x in EXTENSION_SUFFIXES}
|
extensions = {x.lower() for x in EXTENSION_SUFFIXES}
|
||||||
zip_safe = True
|
zip_safe = True
|
||||||
|
@ -472,6 +472,6 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from qt.core import QApplication
|
from calibre.gui2 import Application
|
||||||
app = QApplication([])
|
app = Application([])
|
||||||
test_widget('Advanced', 'Plugins')
|
test_widget('Advanced', 'Plugins')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user