mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #810349 (The ability to stop multiple selected jobs)
This commit is contained in:
parent
79b1c42db0
commit
ba574b6cc0
@ -29,9 +29,6 @@
|
|||||||
<property name="alternatingRowColors">
|
<property name="alternatingRowColors">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="selectionMode">
|
|
||||||
<enum>QAbstractItemView::SingleSelection</enum>
|
|
||||||
</property>
|
|
||||||
<property name="selectionBehavior">
|
<property name="selectionBehavior">
|
||||||
<enum>QAbstractItemView::SelectRows</enum>
|
<enum>QAbstractItemView::SelectRows</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -46,7 +43,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="kill_button">
|
<widget class="QPushButton" name="kill_button">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Stop selected job</string>
|
<string>&Stop selected jobs</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -268,7 +268,8 @@ class JobManager(QAbstractTableModel): # {{{
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# Jobs UI {{{
|
# Jobs UI {{{
|
||||||
class ProgressBarDelegate(QAbstractItemDelegate):
|
|
||||||
|
class ProgressBarDelegate(QAbstractItemDelegate): # {{{
|
||||||
|
|
||||||
def sizeHint(self, option, index):
|
def sizeHint(self, option, index):
|
||||||
return QSize(120, 30)
|
return QSize(120, 30)
|
||||||
@ -285,8 +286,9 @@ class ProgressBarDelegate(QAbstractItemDelegate):
|
|||||||
opts.progress = percent
|
opts.progress = percent
|
||||||
opts.text = QString(_('Unavailable') if percent == 0 else '%d%%'%percent)
|
opts.text = QString(_('Unavailable') if percent == 0 else '%d%%'%percent)
|
||||||
QApplication.style().drawControl(QStyle.CE_ProgressBar, opts, painter)
|
QApplication.style().drawControl(QStyle.CE_ProgressBar, opts, painter)
|
||||||
|
# }}}
|
||||||
|
|
||||||
class DetailView(QDialog, Ui_Dialog):
|
class DetailView(QDialog, Ui_Dialog): # {{{
|
||||||
|
|
||||||
def __init__(self, parent, job):
|
def __init__(self, parent, job):
|
||||||
QDialog.__init__(self, parent)
|
QDialog.__init__(self, parent)
|
||||||
@ -319,8 +321,9 @@ class DetailView(QDialog, Ui_Dialog):
|
|||||||
self.next_pos = f.tell()
|
self.next_pos = f.tell()
|
||||||
if more:
|
if more:
|
||||||
self.log.appendPlainText(more.decode('utf-8', 'replace'))
|
self.log.appendPlainText(more.decode('utf-8', 'replace'))
|
||||||
|
# }}}
|
||||||
|
|
||||||
class JobsButton(QFrame):
|
class JobsButton(QFrame): # {{{
|
||||||
|
|
||||||
def __init__(self, horizontal=False, size=48, parent=None):
|
def __init__(self, horizontal=False, size=48, parent=None):
|
||||||
QFrame.__init__(self, parent)
|
QFrame.__init__(self, parent)
|
||||||
@ -405,6 +408,7 @@ class JobsButton(QFrame):
|
|||||||
self.stop()
|
self.stop()
|
||||||
QCoreApplication.instance().alert(self, 5000)
|
QCoreApplication.instance().alert(self, 5000)
|
||||||
|
|
||||||
|
# }}}
|
||||||
|
|
||||||
class JobsDialog(QDialog, Ui_JobsDialog):
|
class JobsDialog(QDialog, Ui_JobsDialog):
|
||||||
|
|
||||||
@ -447,7 +451,6 @@ class JobsDialog(QDialog, Ui_JobsDialog):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def show_job_details(self, index):
|
def show_job_details(self, index):
|
||||||
row = index.row()
|
row = index.row()
|
||||||
job = self.jobs_view.model().row_to_job(row)
|
job = self.jobs_view.model().row_to_job(row)
|
||||||
@ -456,18 +459,23 @@ class JobsDialog(QDialog, Ui_JobsDialog):
|
|||||||
d.timer.stop()
|
d.timer.stop()
|
||||||
|
|
||||||
def show_details(self, *args):
|
def show_details(self, *args):
|
||||||
for index in self.jobs_view.selectedIndexes():
|
index = self.jobs_view.currentIndex()
|
||||||
|
if index.isValid():
|
||||||
self.show_job_details(index)
|
self.show_job_details(index)
|
||||||
return
|
|
||||||
|
|
||||||
def kill_job(self, *args):
|
def kill_job(self, *args):
|
||||||
if question_dialog(self, _('Are you sure?'), _('Do you really want to stop the selected job?')):
|
rows = [index.row() for index in
|
||||||
for index in self.jobs_view.selectionModel().selectedRows():
|
self.jobs_view.selectionModel().selectedRows()]
|
||||||
row = index.row()
|
if question_dialog(self, _('Are you sure?'),
|
||||||
|
ngettext('Do you really want to stop the selected job?',
|
||||||
|
'Do you really want to stop all the selected jobs?',
|
||||||
|
len(rows))):
|
||||||
|
for row in rows:
|
||||||
self.model.kill_job(row, self)
|
self.model.kill_job(row, self)
|
||||||
|
|
||||||
def kill_all_jobs(self, *args):
|
def kill_all_jobs(self, *args):
|
||||||
if question_dialog(self, _('Are you sure?'), _('Do you really want to stop all non-device jobs?')):
|
if question_dialog(self, _('Are you sure?'),
|
||||||
|
_('Do you really want to stop all non-device jobs?')):
|
||||||
self.model.kill_all_jobs()
|
self.model.kill_all_jobs()
|
||||||
|
|
||||||
def closeEvent(self, e):
|
def closeEvent(self, e):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user