mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Make the list of plugboards clickable by changing to a listwidget
This commit is contained in:
parent
dfd5048322
commit
46fbd2586e
@ -6,6 +6,7 @@ __copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
|||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
from PyQt4.Qt import Qt
|
||||||
|
|
||||||
from calibre.gui2 import error_dialog
|
from calibre.gui2 import error_dialog
|
||||||
from calibre.gui2.preferences import ConfigWidgetBase, test_widget
|
from calibre.gui2.preferences import ConfigWidgetBase, test_widget
|
||||||
@ -75,6 +76,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
self.edit_format.currentIndexChanged[str].connect(self.edit_format_changed)
|
self.edit_format.currentIndexChanged[str].connect(self.edit_format_changed)
|
||||||
self.new_device.currentIndexChanged[str].connect(self.new_device_changed)
|
self.new_device.currentIndexChanged[str].connect(self.new_device_changed)
|
||||||
self.new_format.currentIndexChanged[str].connect(self.new_format_changed)
|
self.new_format.currentIndexChanged[str].connect(self.new_format_changed)
|
||||||
|
self.existing_plugboards.itemClicked.connect(self.existing_pb_clicked)
|
||||||
self.ok_button.clicked.connect(self.ok_clicked)
|
self.ok_button.clicked.connect(self.ok_clicked)
|
||||||
self.del_button.clicked.connect(self.del_clicked)
|
self.del_button.clicked.connect(self.del_clicked)
|
||||||
|
|
||||||
@ -257,6 +259,11 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
self.changed_signal.emit()
|
self.changed_signal.emit()
|
||||||
self.refill_all_boxes()
|
self.refill_all_boxes()
|
||||||
|
|
||||||
|
def existing_pb_clicked(self, Qitem):
|
||||||
|
item = Qitem.data(Qt.UserRole).toPyObject()
|
||||||
|
self.edit_format.setCurrentIndex(self.edit_format.findText(item[0]))
|
||||||
|
self.edit_device.setCurrentIndex(self.edit_device.findText(item[1]))
|
||||||
|
|
||||||
def refill_all_boxes(self):
|
def refill_all_boxes(self):
|
||||||
if self.refilling:
|
if self.refilling:
|
||||||
return
|
return
|
||||||
@ -272,7 +279,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
self.edit_device.clear()
|
self.edit_device.clear()
|
||||||
self.ok_button.setEnabled(False)
|
self.ok_button.setEnabled(False)
|
||||||
self.del_button.setEnabled(False)
|
self.del_button.setEnabled(False)
|
||||||
txt = ''
|
self.existing_plugboards.clear()
|
||||||
for f in self.formats:
|
for f in self.formats:
|
||||||
if f not in self.current_plugboards:
|
if f not in self.current_plugboards:
|
||||||
continue
|
continue
|
||||||
@ -281,9 +288,11 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
continue
|
continue
|
||||||
ops = []
|
ops = []
|
||||||
for op in self.current_plugboards[f][d]:
|
for op in self.current_plugboards[f][d]:
|
||||||
ops.append('[' + op[0] + '] -> ' + op[1])
|
ops.append('([' + op[0] + '] -> ' + op[1] + ')')
|
||||||
txt += '%s:%s %s\n'%(f, d, ', '.join(ops))
|
txt = '%s:%s = %s\n'%(f, d, ', '.join(ops))
|
||||||
self.existing_plugboards.setPlainText(txt)
|
item = QtGui.QListWidgetItem(txt)
|
||||||
|
item.setData(Qt.UserRole, (f, d))
|
||||||
|
self.existing_plugboards.addItem(item)
|
||||||
self.refilling = False
|
self.refilling = False
|
||||||
|
|
||||||
def restore_defaults(self):
|
def restore_defaults(self):
|
||||||
|
@ -99,12 +99,12 @@ One possible use for a plugboard is to alter the title to contain series informa
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1" colspan="2">
|
<item row="3" column="1" colspan="2">
|
||||||
<widget class="QPlainTextEdit" name="existing_plugboards">
|
<widget class="QListWidget" name="existing_plugboards">
|
||||||
<property name="lineWrapMode">
|
<property name="sizeIncrement">
|
||||||
<enum>QPlainTextEdit::NoWrap</enum>
|
<size>
|
||||||
</property>
|
<width>0</width>
|
||||||
<property name="readOnly">
|
<height>0</height>
|
||||||
<bool>true</bool>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user