mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Content server preferences widget: Make files based settings browse-able
This commit is contained in:
parent
a8f697a762
commit
8a907cacd9
@ -13,7 +13,7 @@ from PyQt5.Qt import (
|
|||||||
QCheckBox, QComboBox, QDialog, QDialogButtonBox, QDoubleSpinBox, QFormLayout,
|
QCheckBox, QComboBox, QDialog, QDialogButtonBox, QDoubleSpinBox, QFormLayout,
|
||||||
QFrame, QHBoxLayout, QIcon, QLabel, QLineEdit, QListWidget, QPlainTextEdit,
|
QFrame, QHBoxLayout, QIcon, QLabel, QLineEdit, QListWidget, QPlainTextEdit,
|
||||||
QPushButton, QScrollArea, QSize, QSizePolicy, QSpinBox, Qt, QTabWidget, QTimer,
|
QPushButton, QScrollArea, QSize, QSizePolicy, QSpinBox, Qt, QTabWidget, QTimer,
|
||||||
QUrl, QVBoxLayout, QWidget, pyqtSignal
|
QToolButton, QUrl, QVBoxLayout, QWidget, pyqtSignal
|
||||||
)
|
)
|
||||||
|
|
||||||
from calibre import as_unicode
|
from calibre import as_unicode
|
||||||
@ -31,7 +31,6 @@ from calibre.srv.users import (
|
|||||||
)
|
)
|
||||||
from calibre.utils.icu import primary_sort_key
|
from calibre.utils.icu import primary_sort_key
|
||||||
|
|
||||||
|
|
||||||
# Advanced {{{
|
# Advanced {{{
|
||||||
|
|
||||||
|
|
||||||
@ -104,6 +103,7 @@ class Text(QLineEdit):
|
|||||||
|
|
||||||
def __init__(self, name, layout):
|
def __init__(self, name, layout):
|
||||||
QLineEdit.__init__(self)
|
QLineEdit.__init__(self)
|
||||||
|
self.setClearButtonEnabled(True)
|
||||||
opt = options[name]
|
opt = options[name]
|
||||||
self.textChanged.connect(self.changed_signal.emit)
|
self.textChanged.connect(self.changed_signal.emit)
|
||||||
init_opt(self, opt, layout)
|
init_opt(self, opt, layout)
|
||||||
@ -115,6 +115,40 @@ class Text(QLineEdit):
|
|||||||
self.setText(type(u'')(val or ''))
|
self.setText(type(u'')(val or ''))
|
||||||
|
|
||||||
|
|
||||||
|
class Path(QWidget):
|
||||||
|
|
||||||
|
changed_signal = pyqtSignal()
|
||||||
|
|
||||||
|
def __init__(self, name, layout):
|
||||||
|
QWidget.__init__(self)
|
||||||
|
self.dname = name
|
||||||
|
opt = options[name]
|
||||||
|
self.l = l = QHBoxLayout(self)
|
||||||
|
l.setContentsMargins(0, 0, 0, 0)
|
||||||
|
self.text = t = QLineEdit(self)
|
||||||
|
t.setClearButtonEnabled(True)
|
||||||
|
t.textChanged.connect(self.changed_signal.emit)
|
||||||
|
l.addWidget(t)
|
||||||
|
|
||||||
|
self.b = b = QToolButton(self)
|
||||||
|
l.addWidget(b)
|
||||||
|
b.setIcon(QIcon(I('document_open.png')))
|
||||||
|
b.setToolTip(_("Browse for the file"))
|
||||||
|
b.clicked.connect(self.choose)
|
||||||
|
init_opt(self, opt, layout)
|
||||||
|
|
||||||
|
def get(self):
|
||||||
|
return self.text.text().strip() or None
|
||||||
|
|
||||||
|
def set(self, val):
|
||||||
|
self.text.setText(type(u'')(val or ''))
|
||||||
|
|
||||||
|
def choose(self):
|
||||||
|
ans = choose_files(self, 'choose_path_srv_opts_' + self.dname, _('Choose a file'), select_only_single_file=True)
|
||||||
|
if ans:
|
||||||
|
self.set(ans[0])
|
||||||
|
|
||||||
|
|
||||||
class Choices(QComboBox):
|
class Choices(QComboBox):
|
||||||
|
|
||||||
changed_signal = pyqtSignal()
|
changed_signal = pyqtSignal()
|
||||||
@ -162,6 +196,8 @@ class AdvancedTab(QWidget):
|
|||||||
w = Float
|
w = Float
|
||||||
else:
|
else:
|
||||||
w = Text
|
w = Text
|
||||||
|
if name in ('ssl_certfile', 'ssl_keyfile'):
|
||||||
|
w = Path
|
||||||
w = w(name, l)
|
w = w(name, l)
|
||||||
setattr(self, 'opt_' + name, w)
|
setattr(self, 'opt_' + name, w)
|
||||||
self.widgets.append(w)
|
self.widgets.append(w)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user