mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #1865915 [[Enhancement] Change list order by drag and drop](https://bugs.launchpad.net/calibre/+bug/1865915)
This commit is contained in:
parent
2742fa1f96
commit
14025af9e6
@ -7,6 +7,7 @@ __copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import re
|
||||
from functools import partial
|
||||
|
||||
from PyQt5.Qt import Qt, QListWidgetItem
|
||||
|
||||
@ -22,6 +23,13 @@ from calibre.utils.icu import sort_key
|
||||
from polyglot.builtins import unicode_type, range
|
||||
|
||||
|
||||
def input_order_drop_event(self, ev):
|
||||
ret = self.opt_input_order.__class__.dropEvent(self.opt_input_order, ev)
|
||||
if ev.isAccepted():
|
||||
self.changed_signal.emit()
|
||||
return ret
|
||||
|
||||
|
||||
class OutputFormatSetting(Setting):
|
||||
|
||||
CHOICES_SEARCH_FLAGS = Qt.MatchFixedString
|
||||
@ -62,6 +70,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
|
||||
self.input_up_button.clicked.connect(self.up_input)
|
||||
self.input_down_button.clicked.connect(self.down_input)
|
||||
self.opt_input_order.dropEvent = partial(input_order_drop_event, self)
|
||||
for signal in ('Activated', 'Changed', 'DoubleClicked', 'Clicked'):
|
||||
signal = getattr(self.opt_internally_viewed_formats, 'item'+signal)
|
||||
signal.connect(self.internally_viewed_formats_changed)
|
||||
@ -147,7 +156,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
for format in input_map + list(all_formats.difference(input_map)):
|
||||
item = QListWidgetItem(format, self.opt_input_order)
|
||||
item.setData(Qt.UserRole, (format))
|
||||
item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable)
|
||||
item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable|Qt.ItemIsDragEnabled)
|
||||
|
||||
def up_input(self, *args):
|
||||
idx = self.opt_input_order.currentRow()
|
||||
@ -175,6 +184,6 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from PyQt5.Qt import QApplication
|
||||
app = QApplication([])
|
||||
from calibre.gui2 import Application
|
||||
app = Application([])
|
||||
test_widget('Interface', 'Behavior')
|
||||
|
@ -104,6 +104,15 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="dragEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::InternalMove</enum>
|
||||
</property>
|
||||
<property name="defaultDropAction">
|
||||
<enum>Qt::MoveAction</enum>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
Loading…
x
Reference in New Issue
Block a user