本文整理汇总了Python中calibre.gui2.progress_indicator.ProgressIndicator.isAnimated方法的典型用法代码示例。如果您正苦于以下问题:Python ProgressIndicator.isAnimated方法的具体用法?Python ProgressIndicator.isAnimated怎么用?Python ProgressIndicator.isAnimated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类calibre.gui2.progress_indicator.ProgressIndicator
的用法示例。
在下文中一共展示了ProgressIndicator.isAnimated方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SearchDialog
# 需要导入模块: from calibre.gui2.progress_indicator import ProgressIndicator [as 别名]
# 或者: from calibre.gui2.progress_indicator.ProgressIndicator import isAnimated [as 别名]
#.........这里部分代码省略.........
geometry = self.config.get('config_dialog_geometry', None)
if geometry:
d.restoreGeometry(geometry)
else:
d.resize(800, 600)
tab_index = self.config.get('config_dialog_tab_index', 0)
tab_index = min(tab_index, tab_widget.count() - 1)
tab_widget.setCurrentIndex(tab_index)
d.exec_()
# Save dialog state.
self.config['config_dialog_geometry'] = bytearray(d.saveGeometry())
self.config['config_dialog_tab_index'] = tab_widget.currentIndex()
search_config_widget.save_settings()
self.config_changed()
self.gui.load_store_plugins()
self.setup_store_checks()
def config_changed(self):
self.load_settings()
self.open_external.setChecked(self.should_open_external)
self.search_pool.set_thread_count(self.search_thread_count)
self.cache_pool.set_thread_count(self.cache_thread_count)
self.results_view.model().cover_pool.set_thread_count(self.cover_thread_count)
self.results_view.model().details_pool.set_thread_count(self.details_thread_count)
def get_results(self):
# We only want the search plugins to run
# a maximum set amount of time before giving up.
self.hang_check += 1
if self.hang_check >= self.hang_time:
self.search_pool.abort()
self.checker.stop()
else:
# Stop the checker if not threads are running.
if not self.search_pool.threads_running() and not self.search_pool.has_tasks():
self.checker.stop()
while self.search_pool.has_results():
res, store_plugin = self.search_pool.get_result()
if res:
self.results_view.model().add_result(res, store_plugin)
if not self.search_pool.threads_running() and not self.results_view.model().has_results():
info_dialog(self, _('No matches'), _('Couldn\'t find any books matching your query.'), show=True, show_copy_button=False)
def update_book_total(self, total):
self.total.setText('%s' % total)
def result_item_activated(self, index):
result = self.results_view.model().get_result(index)
if result.downloads:
self.download_book(result)
else:
self.open_store(result)
def download_book(self, result):
d = ChooseFormatDialog(self, _('Choose format to download to your library.'), result.downloads.keys())
if d.exec_() == d.Accepted:
ext = d.format()
fname = result.title[:60] + '.' + ext.lower()
fname = ascii_filename(fname)
self.gui.download_ebook(result.downloads[ext], filename=fname)
def open_store(self, result):
self.gui.istores[result.store_name].open(self, result.detail_item, self.open_external.isChecked())
def check_progress(self):
if not self.search_pool.threads_running() and not self.results_view.model().cover_pool.threads_running() and not self.results_view.model().details_pool.threads_running():
self.pi.stopAnimation()
else:
if not self.pi.isAnimated():
self.pi.startAnimation()
def stores_select_all(self):
for check in self.store_checks.values():
check.setChecked(True)
def stores_select_invert(self):
for check in self.store_checks.values():
check.setChecked(not check.isChecked())
def stores_select_none(self):
for check in self.store_checks.values():
check.setChecked(False)
def dialog_closed(self, result):
self.results_view.model().closing()
self.search_pool.abort()
self.cache_pool.abort()
self.save_state()
def exec_(self):
if unicode(self.search_edit.text()).strip() or unicode(self.search_title.text()).strip() or unicode(self.search_author.text()).strip():
self.do_search()
return QDialog.exec_(self)
示例2: JobsButton
# 需要导入模块: from calibre.gui2.progress_indicator import ProgressIndicator [as 别名]
# 或者: from calibre.gui2.progress_indicator.ProgressIndicator import isAnimated [as 别名]
class JobsButton(QWidget): # {{{
tray_tooltip_updated = pyqtSignal(object)
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.mouse_over = False
self.pi = ProgressIndicator(self, self.style().pixelMetric(QStyle.PM_ToolBarIconSize))
self._jobs = QLabel('<b>'+_('Jobs:')+' 0 ')
self._jobs.mouseReleaseEvent = self.mouseReleaseEvent
self.shortcut = 'Alt+Shift+J'
self.l = l = QHBoxLayout(self)
l.setSpacing(3)
l.addWidget(self.pi)
l.addWidget(self._jobs)
m = self.style().pixelMetric(QStyle.PM_DefaultFrameWidth)
self.layout().setContentsMargins(m, m, m, m)
self._jobs.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
self.setCursor(Qt.PointingHandCursor)
b = _('Click to see list of jobs')
self.setToolTip(b + u' [%s]'%self.shortcut)
self.action_toggle = QAction(b, parent)
parent.addAction(self.action_toggle)
self.action_toggle.triggered.connect(self.toggle)
if hasattr(parent, 'keyboard'):
parent.keyboard.register_shortcut('toggle jobs list', _('Show/hide the Jobs List'), default_keys=(self.shortcut,), action=self.action_toggle)
def event(self, ev):
m = None
et = ev.type()
if et == ev.Enter:
m = True
elif et == ev.Leave:
m = False
if m is not None and m != self.mouse_over:
self.mouse_over = m
self.update()
return QWidget.event(self, ev)
def initialize(self, jobs_dialog, job_manager):
self.jobs_dialog = jobs_dialog
job_manager.job_added.connect(self.job_added)
job_manager.job_done.connect(self.job_done)
self.jobs_dialog.addAction(self.action_toggle)
def mouseReleaseEvent(self, event):
self.toggle()
def toggle(self, *args):
if self.jobs_dialog.isVisible():
self.jobs_dialog.hide()
else:
self.jobs_dialog.show()
@property
def is_running(self):
return self.pi.isAnimated()
def start(self):
self.pi.startAnimation()
def stop(self):
self.pi.stopAnimation()
def jobs(self):
src = unicode(self._jobs.text())
return int(re.search(r'\d+', src).group())
def tray_tooltip(self, num=0):
if num == 0:
text = _('No running jobs')
elif num == 1:
text = _('One running job')
else:
text = _('%d running jobs') % num
if not (islinux or isbsd):
text = 'calibre: ' + text
return text
def job_added(self, nnum):
jobs = self._jobs
src = unicode(jobs.text())
num = self.jobs()
text = src.replace(str(num), str(nnum))
jobs.setText(text)
self.start()
self.tray_tooltip_updated.emit(self.tray_tooltip(nnum))
def job_done(self, nnum):
jobs = self._jobs
src = unicode(jobs.text())
num = self.jobs()
text = src.replace(str(num), str(nnum))
jobs.setText(text)
if nnum == 0:
self.no_more_jobs()
self.tray_tooltip_updated.emit(self.tray_tooltip(nnum))
def no_more_jobs(self):
#.........这里部分代码省略.........
示例3: JobsButton
# 需要导入模块: from calibre.gui2.progress_indicator import ProgressIndicator [as 别名]
# 或者: from calibre.gui2.progress_indicator.ProgressIndicator import isAnimated [as 别名]
class JobsButton(QFrame): # {{{
def __init__(self, horizontal=False, size=48, parent=None):
QFrame.__init__(self, parent)
if horizontal:
size = 24
self.pi = ProgressIndicator(self, size)
self._jobs = QLabel('<b>'+_('Jobs:')+' 0')
self._jobs.mouseReleaseEvent = self.mouseReleaseEvent
self.shortcut = _('Shift+Alt+J')
if horizontal:
self.setLayout(QHBoxLayout())
self.layout().setDirection(self.layout().RightToLeft)
else:
self.setLayout(QVBoxLayout())
self._jobs.setAlignment(Qt.AlignHCenter|Qt.AlignBottom)
self.layout().addWidget(self.pi)
self.layout().addWidget(self._jobs)
if not horizontal:
self.layout().setAlignment(self._jobs, Qt.AlignHCenter)
self._jobs.setMargin(0)
self.layout().setMargin(0)
self._jobs.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
self.setCursor(Qt.PointingHandCursor)
b = _('Click to see list of jobs')
self.setToolTip(b + u' (%s)'%self.shortcut)
self.action_toggle = QAction(b, parent)
parent.addAction(self.action_toggle)
self.action_toggle.setShortcut(self.shortcut)
self.action_toggle.triggered.connect(self.toggle)
def initialize(self, jobs_dialog, job_manager):
self.jobs_dialog = jobs_dialog
job_manager.job_added.connect(self.job_added)
job_manager.job_done.connect(self.job_done)
self.jobs_dialog.addAction(self.action_toggle)
def mouseReleaseEvent(self, event):
self.toggle()
def toggle(self, *args):
if self.jobs_dialog.isVisible():
self.jobs_dialog.hide()
else:
self.jobs_dialog.show()
@property
def is_running(self):
return self.pi.isAnimated()
def start(self):
self.pi.startAnimation()
def stop(self):
self.pi.stopAnimation()
def jobs(self):
src = unicode(self._jobs.text())
return int(re.search(r'\d+', src).group())
def job_added(self, nnum):
jobs = self._jobs
src = unicode(jobs.text())
num = self.jobs()
text = src.replace(str(num), str(nnum))
jobs.setText(text)
self.start()
def job_done(self, nnum):
jobs = self._jobs
src = unicode(jobs.text())
num = self.jobs()
text = src.replace(str(num), str(nnum))
jobs.setText(text)
if nnum == 0:
self.no_more_jobs()
def no_more_jobs(self):
if self.is_running:
self.stop()
QCoreApplication.instance().alert(self, 5000)
示例4: JobsButton
# 需要导入模块: from calibre.gui2.progress_indicator import ProgressIndicator [as 别名]
# 或者: from calibre.gui2.progress_indicator.ProgressIndicator import isAnimated [as 别名]
class JobsButton(QFrame): # {{{
tray_tooltip_updated = pyqtSignal(object)
def __init__(self, horizontal=False, size=48, parent=None):
QFrame.__init__(self, parent)
if horizontal:
size = 24
self.pi = ProgressIndicator(self, size)
self._jobs = QLabel('<b>'+_('Jobs:')+' 0')
self._jobs.mouseReleaseEvent = self.mouseReleaseEvent
self.shortcut = 'Shift+Alt+J'
if horizontal:
self.setLayout(QHBoxLayout())
self.layout().setDirection(self.layout().RightToLeft)
else:
self.setLayout(QVBoxLayout())
self._jobs.setAlignment(Qt.AlignHCenter|Qt.AlignBottom)
self.layout().addWidget(self.pi)
self.layout().addWidget(self._jobs)
if not horizontal:
self.layout().setAlignment(self._jobs, Qt.AlignHCenter)
self._jobs.setMargin(0)
self.layout().setContentsMargins(0, 0, 0, 0)
self._jobs.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
self.setCursor(Qt.PointingHandCursor)
b = _('Click to see list of jobs')
self.setToolTip(b + u' (%s)'%self.shortcut)
self.action_toggle = QAction(b, parent)
parent.addAction(self.action_toggle)
self.action_toggle.triggered.connect(self.toggle)
if hasattr(parent, 'keyboard'):
parent.keyboard.register_shortcut('toggle jobs list', _('Show/hide the Jobs List'), default_keys=(self.shortcut,), action=self.action_toggle)
def initialize(self, jobs_dialog, job_manager):
self.jobs_dialog = jobs_dialog
job_manager.job_added.connect(self.job_added)
job_manager.job_done.connect(self.job_done)
self.jobs_dialog.addAction(self.action_toggle)
def mouseReleaseEvent(self, event):
self.toggle()
def toggle(self, *args):
if self.jobs_dialog.isVisible():
self.jobs_dialog.hide()
else:
self.jobs_dialog.show()
@property
def is_running(self):
return self.pi.isAnimated()
def start(self):
self.pi.startAnimation()
def stop(self):
self.pi.stopAnimation()
def jobs(self):
src = unicode(self._jobs.text())
return int(re.search(r'\d+', src).group())
def tray_tooltip(self, num=0):
if num == 0:
text = _('No running jobs')
elif num == 1:
text = _('One running job')
else:
text = _('%d running jobs') % num
if not (islinux or isbsd):
text = 'calibre: ' + text
return text
def job_added(self, nnum):
jobs = self._jobs
src = unicode(jobs.text())
num = self.jobs()
text = src.replace(str(num), str(nnum))
jobs.setText(text)
self.start()
self.tray_tooltip_updated.emit(self.tray_tooltip(nnum))
def job_done(self, nnum):
jobs = self._jobs
src = unicode(jobs.text())
num = self.jobs()
text = src.replace(str(num), str(nnum))
jobs.setText(text)
if nnum == 0:
self.no_more_jobs()
self.tray_tooltip_updated.emit(self.tray_tooltip(nnum))
def no_more_jobs(self):
if self.is_running:
self.stop()
QCoreApplication.instance().alert(self, 5000)