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'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
from PyQt5.Qt import Qt, QListWidgetItem
|
from PyQt5.Qt import Qt, QListWidgetItem
|
||||||
|
|
||||||
@ -22,6 +23,13 @@ from calibre.utils.icu import sort_key
|
|||||||
from polyglot.builtins import unicode_type, range
|
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):
|
class OutputFormatSetting(Setting):
|
||||||
|
|
||||||
CHOICES_SEARCH_FLAGS = Qt.MatchFixedString
|
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_up_button.clicked.connect(self.up_input)
|
||||||
self.input_down_button.clicked.connect(self.down_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'):
|
for signal in ('Activated', 'Changed', 'DoubleClicked', 'Clicked'):
|
||||||
signal = getattr(self.opt_internally_viewed_formats, 'item'+signal)
|
signal = getattr(self.opt_internally_viewed_formats, 'item'+signal)
|
||||||
signal.connect(self.internally_viewed_formats_changed)
|
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)):
|
for format in input_map + list(all_formats.difference(input_map)):
|
||||||
item = QListWidgetItem(format, self.opt_input_order)
|
item = QListWidgetItem(format, self.opt_input_order)
|
||||||
item.setData(Qt.UserRole, (format))
|
item.setData(Qt.UserRole, (format))
|
||||||
item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable)
|
item.setFlags(Qt.ItemIsEnabled|Qt.ItemIsSelectable|Qt.ItemIsDragEnabled)
|
||||||
|
|
||||||
def up_input(self, *args):
|
def up_input(self, *args):
|
||||||
idx = self.opt_input_order.currentRow()
|
idx = self.opt_input_order.currentRow()
|
||||||
@ -175,6 +184,6 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from PyQt5.Qt import QApplication
|
from calibre.gui2 import Application
|
||||||
app = QApplication([])
|
app = Application([])
|
||||||
test_widget('Interface', 'Behavior')
|
test_widget('Interface', 'Behavior')
|
||||||
|
@ -104,6 +104,15 @@
|
|||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</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">
|
<property name="alternatingRowColors">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user