mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #841588 (Jobs shows "can't stop device tasks" for every stopped device job)
This commit is contained in:
parent
a7254ffc1d
commit
88187c98d3
@ -21,7 +21,7 @@ from calibre.utils.ipc.job import ParallelJob
|
|||||||
from calibre.gui2 import Dispatcher, error_dialog, question_dialog, NONE, config, gprefs
|
from calibre.gui2 import Dispatcher, error_dialog, question_dialog, NONE, config, gprefs
|
||||||
from calibre.gui2.device import DeviceJob
|
from calibre.gui2.device import DeviceJob
|
||||||
from calibre.gui2.dialogs.jobs_ui import Ui_JobsDialog
|
from calibre.gui2.dialogs.jobs_ui import Ui_JobsDialog
|
||||||
from calibre import __appname__
|
from calibre import __appname__, as_unicode
|
||||||
from calibre.gui2.dialogs.job_view_ui import Ui_Dialog
|
from calibre.gui2.dialogs.job_view_ui import Ui_Dialog
|
||||||
from calibre.gui2.progress_indicator import ProgressIndicator
|
from calibre.gui2.progress_indicator import ProgressIndicator
|
||||||
from calibre.gui2.threaded_jobs import ThreadedJobServer, ThreadedJob
|
from calibre.gui2.threaded_jobs import ThreadedJobServer, ThreadedJob
|
||||||
@ -264,6 +264,26 @@ class JobManager(QAbstractTableModel): # {{{
|
|||||||
_('This job cannot be stopped'), show=True)
|
_('This job cannot be stopped'), show=True)
|
||||||
self._kill_job(job)
|
self._kill_job(job)
|
||||||
|
|
||||||
|
def kill_multiple_jobs(self, rows, view):
|
||||||
|
jobs = [self.jobs[row] for row in rows]
|
||||||
|
devjobs = [j for j in jobs is isinstance(j, DeviceJob)]
|
||||||
|
if devjobs:
|
||||||
|
error_dialog(view, _('Cannot kill job'),
|
||||||
|
_('Cannot kill jobs that communicate with the device')).exec_()
|
||||||
|
jobs = [j for j in jobs if not isinstance(j, DeviceJob)]
|
||||||
|
jobs = [j for j in jobs if j.duration is None]
|
||||||
|
unkillable = [j for j in jobs if not getattr(j, 'killable', True)]
|
||||||
|
if unkillable:
|
||||||
|
names = u'\n'.join(as_unicode(j.description) for j in unkillable)
|
||||||
|
error_dialog(view, _('Cannot kill job'),
|
||||||
|
_('Some of the jobs cannot be stopped. Click Show details'
|
||||||
|
' to see the list of unstoppable jobs.'), det_msg=names,
|
||||||
|
show=True)
|
||||||
|
jobs = [j for j in jobs if getattr(j, 'killable', True)]
|
||||||
|
jobs = [j for j in jobs if j.duration is None]
|
||||||
|
for j in jobs:
|
||||||
|
self._kill_job(j)
|
||||||
|
|
||||||
def kill_all_jobs(self):
|
def kill_all_jobs(self):
|
||||||
for job in self.jobs:
|
for job in self.jobs:
|
||||||
if (isinstance(job, DeviceJob) or job.duration is not None or
|
if (isinstance(job, DeviceJob) or job.duration is not None or
|
||||||
@ -484,8 +504,10 @@ class JobsDialog(QDialog, Ui_JobsDialog):
|
|||||||
ngettext('Do you really want to stop the selected job?',
|
ngettext('Do you really want to stop the selected job?',
|
||||||
'Do you really want to stop all the selected jobs?',
|
'Do you really want to stop all the selected jobs?',
|
||||||
len(rows))):
|
len(rows))):
|
||||||
for row in rows:
|
if len(rows) > 1:
|
||||||
self.model.kill_job(row, self)
|
self.model.kill_multiple_jobs(rows, self)
|
||||||
|
else:
|
||||||
|
self.model.kill_job(rows[0], self)
|
||||||
|
|
||||||
def kill_all_jobs(self, *args):
|
def kill_all_jobs(self, *args):
|
||||||
if question_dialog(self, _('Are you sure?'),
|
if question_dialog(self, _('Are you sure?'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user