本文整理汇总了Python中calibre.gui2.tweak_book.boss.Boss.shutdown方法的典型用法代码示例。如果您正苦于以下问题:Python Boss.shutdown方法的具体用法?Python Boss.shutdown怎么用?Python Boss.shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类calibre.gui2.tweak_book.boss.Boss
的用法示例。
在下文中一共展示了Boss.shutdown方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Main
# 需要导入模块: from calibre.gui2.tweak_book.boss import Boss [as 别名]
# 或者: from calibre.gui2.tweak_book.boss.Boss import shutdown [as 别名]
#.........这里部分代码省略.........
b.setToolTip(_('Donate to support calibre development'))
QTimer.singleShot(10, b.start_animation)
self.global_bar.addWidget(w)
self.global_bar.addAction(self.action_insert_char)
a(self.action_help)
a = create(_('Polish book tool bar'), 'polish').addAction
for x in ('embed_fonts', 'subset_fonts', 'smarten_punctuation', 'remove_unused_css'):
a(getattr(self, 'action_' + x))
def create_docks(self):
def create(name, oname):
oname += '-dock'
d = QDockWidget(name, self)
d.setObjectName(oname) # Needed for saveState
ac = d.toggleViewAction()
desc = _('Toggle %s') % name.replace('&', '')
self.keyboard.register_shortcut(
oname, desc, description=desc, action=ac, group=_('Windows'))
actions[oname] = ac
setattr(self, oname.replace('-', '_'), d)
return d
d = create(_('Files Browser'), 'files-browser')
d.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
self.file_list = FileListWidget(d)
d.setWidget(self.file_list)
self.addDockWidget(Qt.LeftDockWidgetArea, d)
d = create(_('File Preview'), 'preview')
d.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
self.preview = Preview(d)
d.setWidget(self.preview)
self.addDockWidget(Qt.RightDockWidgetArea, d)
d = create(_('Check Book'), 'check-book')
d.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea | Qt.BottomDockWidgetArea | Qt.TopDockWidgetArea)
d.setWidget(self.check_book)
self.addDockWidget(Qt.TopDockWidgetArea, d)
d.close() # By default the check window is closed
d = create(_('Inspector'), 'inspector')
d.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea | Qt.BottomDockWidgetArea | Qt.TopDockWidgetArea)
d.setWidget(self.preview.inspector)
self.preview.inspector.setParent(d)
self.addDockWidget(Qt.BottomDockWidgetArea, d)
d.close() # By default the inspector window is closed
d.setFeatures(d.DockWidgetClosable | d.DockWidgetMovable) # QWebInspector does not work in a floating dock
d = create(_('Table of Contents'), 'toc-viewer')
d.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea | Qt.BottomDockWidgetArea | Qt.TopDockWidgetArea)
d.setWidget(self.toc_view)
self.addDockWidget(Qt.LeftDockWidgetArea, d)
d.close() # Hidden by default
d.visibilityChanged.connect(self.toc_view.visibility_changed)
d = create(_('Checkpoints'), 'checkpoints')
d.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea | Qt.BottomDockWidgetArea | Qt.TopDockWidgetArea)
self.checkpoints = CheckpointView(self.boss.global_undo, parent=d)
d.setWidget(self.checkpoints)
self.addDockWidget(Qt.LeftDockWidgetArea, d)
d.close() # Hidden by default
def resizeEvent(self, ev):
self.blocking_job.resize(ev.size())
return super(Main, self).resizeEvent(ev)
def update_window_title(self):
fname = os.path.basename(current_container().path_to_ebook)
self.setWindowTitle(self.current_metadata.title + ' [%s] :: %s :: %s' %(current_container().book_type.upper(), fname, self.APP_NAME))
def closeEvent(self, e):
if not self.boss.confirm_quit():
e.ignore()
return
try:
self.boss.shutdown()
except:
import traceback
traceback.print_exc()
e.accept()
def save_state(self):
tprefs.set('main_window_geometry', bytearray(self.saveGeometry()))
tprefs.set('main_window_state', bytearray(self.saveState(self.STATE_VERSION)))
self.central.save_state()
self.check_book.save_state()
def restore_state(self):
geom = tprefs.get('main_window_geometry', None)
if geom is not None:
self.restoreGeometry(geom)
state = tprefs.get('main_window_state', None)
if state is not None:
self.restoreState(state, self.STATE_VERSION)
self.central.restore_state()
def contextMenuEvent(self, ev):
ev.ignore()
示例2: Main
# 需要导入模块: from calibre.gui2.tweak_book.boss import Boss [as 别名]
# 或者: from calibre.gui2.tweak_book.boss.Boss import shutdown [as 别名]
#.........这里部分代码省略.........
self.create_menubar()
self.create_toolbar()
self.create_docks()
self.status_bar = self.statusBar()
self.l = QLabel('Placeholder')
self.status_bar.addPermanentWidget(self.boss.save_manager.status_widget)
self.status_bar.addWidget(QLabel(_('{0} {1} created by {2}').format(__appname__, get_version(), 'Kovid Goyal')))
f = self.status_bar.font()
f.setBold(True)
self.status_bar.setFont(f)
self.setCentralWidget(self.l)
self.boss(self)
g = QApplication.instance().desktop().availableGeometry(self)
self.resize(g.width()-50, g.height()-50)
self.restore_state()
self.keyboard.finalize()
def create_actions(self):
group = _('Global Actions')
def reg(icon, text, target, sid, keys, description):
ac = QAction(QIcon(I(icon)), text, self)
ac.setObjectName('action-' + sid)
ac.triggered.connect(target)
if isinstance(keys, type('')):
keys = (keys,)
self.keyboard.register_shortcut(
sid, unicode(ac.text()), default_keys=keys, description=description, action=ac, group=group)
self.addAction(ac)
return ac
self.action_open_book = reg('document_open.png', _('Open &book'), self.boss.open_book, 'open-book', 'Ctrl+O', _('Open a new book'))
self.action_global_undo = reg('back.png', _('&Revert to before'), self.boss.do_global_undo, 'global-undo', 'Ctrl+Left',
_('Revert book to before the last action (Undo)'))
self.action_global_redo = reg('forward.png', _('&Revert to after'), self.boss.do_global_redo, 'global-redo', 'Ctrl+Right',
_('Revert book state to after the next action (Redo)'))
self.action_save = reg('save.png', _('&Save'), self.boss.save_book, 'save-book', 'Ctrl+S', _('Save book'))
self.action_save.setEnabled(False)
self.action_quit = reg('quit.png', _('&Quit'), self.boss.quit, 'quit', 'Ctrl+Q', _('Quit'))
def create_menubar(self):
b = self.menuBar()
f = b.addMenu(_('&File'))
f.addAction(self.action_open_book)
f.addAction(self.action_save)
f.addAction(self.action_quit)
e = b.addMenu(_('&Edit'))
e.addAction(self.action_global_undo)
e.addAction(self.action_global_redo)
def create_toolbar(self):
self.global_bar = b = self.addToolBar(_('Global'))
b.setObjectName('global_bar') # Needed for saveState
b.addAction(self.action_open_book)
b.addAction(self.action_global_undo)
b.addAction(self.action_global_redo)
b.addAction(self.action_save)
def create_docks(self):
self.file_list_dock = d = QDockWidget(_('&Files Browser'), self)
d.setObjectName('file_list_dock') # Needed for saveState
d.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
self.file_list = FileListWidget(d)
d.setWidget(self.file_list)
self.addDockWidget(Qt.LeftDockWidgetArea, d)
def resizeEvent(self, ev):
self.blocking_job.resize(ev.size())
return super(Main, self).resizeEvent(ev)
def update_window_title(self):
self.setWindowTitle(self.current_metadata.title + ' [%s] - %s' %(current_container().book_type.upper(), self.APP_NAME))
def closeEvent(self, e):
if not self.boss.confirm_quit():
e.ignore()
return
try:
self.boss.shutdown()
except:
import traceback
traceback.print_exc()
e.accept()
def save_state(self):
tprefs.set('main_window_geometry', bytearray(self.saveGeometry()))
tprefs.set('main_window_state', bytearray(self.saveState(self.STATE_VERSION)))
def restore_state(self):
geom = tprefs.get('main_window_geometry', None)
if geom is not None:
self.restoreGeometry(geom)
state = tprefs.get('main_window_state', None)
if state is not None:
self.restoreState(state, self.STATE_VERSION)
示例3: Main
# 需要导入模块: from calibre.gui2.tweak_book.boss import Boss [as 别名]
# 或者: from calibre.gui2.tweak_book.boss.Boss import shutdown [as 别名]
#.........这里部分代码省略.........
e.addSeparator()
a(self.action_find_next)
a(self.action_find_previous)
e.addSeparator()
a(self.action_replace)
a(self.action_replace_next)
a(self.action_replace_previous)
a(self.action_replace_all)
e.addSeparator()
a(self.action_count)
e.addSeparator()
a(self.action_mark)
e.addSeparator()
a(self.action_go_to_line)
def create_toolbars(self):
def create(text, name):
name += '-bar'
b = self.addToolBar(text)
b.setObjectName(name) # Needed for saveState
setattr(self, name.replace('-', '_'), b)
actions[name] = b.toggleViewAction()
return b
a = create(_('Book tool bar'), 'global').addAction
for x in ('new_file', 'open_book', 'global_undo', 'global_redo', 'save', 'create_checkpoint', 'toc'):
a(getattr(self, 'action_' + x))
a = create(_('Polish book tool bar'), 'polish').addAction
for x in ('embed_fonts', 'subset_fonts', 'smarten_punctuation'):
a(getattr(self, 'action_' + x))
def create_docks(self):
def create(name, oname):
oname += '-dock'
d = QDockWidget(name, self)
d.setObjectName(oname) # Needed for saveState
ac = d.toggleViewAction()
desc = _('Toggle %s') % name.replace('&', '')
self.keyboard.register_shortcut(
oname, desc, description=desc, action=ac, group=_('Windows'))
actions[oname] = ac
setattr(self, oname.replace('-', '_'), d)
return d
d = create(_('&Files Browser'), 'files-browser')
d.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
self.file_list = FileListWidget(d)
d.setWidget(self.file_list)
self.addDockWidget(Qt.LeftDockWidgetArea, d)
d = create(_('File &Preview'), 'preview')
d.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
self.preview = Preview(d)
d.setWidget(self.preview)
self.addDockWidget(Qt.RightDockWidgetArea, d)
d = create(_('&Inspector'), 'inspector')
d.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea | Qt.BottomDockWidgetArea | Qt.TopDockWidgetArea)
d.setWidget(self.preview.inspector)
self.preview.inspector.setParent(d)
self.addDockWidget(Qt.BottomDockWidgetArea, d)
def resizeEvent(self, ev):
self.blocking_job.resize(ev.size())
return super(Main, self).resizeEvent(ev)
def update_window_title(self):
self.setWindowTitle(self.current_metadata.title + ' [%s] - %s' %(current_container().book_type.upper(), self.APP_NAME))
def closeEvent(self, e):
if not self.boss.confirm_quit():
e.ignore()
return
try:
self.boss.shutdown()
except:
import traceback
traceback.print_exc()
e.accept()
def save_state(self):
tprefs.set('main_window_geometry', bytearray(self.saveGeometry()))
tprefs.set('main_window_state', bytearray(self.saveState(self.STATE_VERSION)))
self.central.save_state()
def restore_state(self):
geom = tprefs.get('main_window_geometry', None)
if geom is not None:
self.restoreGeometry(geom)
state = tprefs.get('main_window_state', None)
if state is not None:
self.restoreState(state, self.STATE_VERSION)
self.central.restore_state()
# We never want to start with the inspector showing
self.inspector_dock.close()
def contextMenuEvent(self, ev):
ev.ignore()
示例4: Main
# 需要导入模块: from calibre.gui2.tweak_book.boss import Boss [as 别名]
# 或者: from calibre.gui2.tweak_book.boss.Boss import shutdown [as 别名]
#.........这里部分代码省略.........
actions[oname] = ac
setattr(self, oname.replace("-", "_"), d)
return d
d = create(_("Files Browser"), "files-browser")
d.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
self.file_list = FileListWidget(d)
d.setWidget(self.file_list)
self.addDockWidget(Qt.LeftDockWidgetArea, d)
d = create(_("File Preview"), "preview")
d.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
self.preview = Preview(d)
d.setWidget(self.preview)
self.addDockWidget(Qt.RightDockWidgetArea, d)
d = create(_("Live CSS"), "live-css")
d.setAllowedAreas(
Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea | Qt.BottomDockWidgetArea | Qt.TopDockWidgetArea
)
self.live_css = LiveCSS(self.preview, parent=d)
d.setWidget(self.live_css)
self.addDockWidget(Qt.RightDockWidgetArea, d)
d.close() # Hidden by default
d = create(_("Check Book"), "check-book")
d.setAllowedAreas(
Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea | Qt.BottomDockWidgetArea | Qt.TopDockWidgetArea
)
d.setWidget(self.check_book)
self.addDockWidget(Qt.TopDockWidgetArea, d)
d.close() # By default the check window is closed
d = create(_("Inspector"), "inspector")
d.setAllowedAreas(
Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea | Qt.BottomDockWidgetArea | Qt.TopDockWidgetArea
)
d.setWidget(self.preview.inspector)
self.preview.inspector.setParent(d)
self.addDockWidget(Qt.BottomDockWidgetArea, d)
d.close() # By default the inspector window is closed
d.setFeatures(d.DockWidgetClosable | d.DockWidgetMovable) # QWebInspector does not work in a floating dock
d = create(_("Table of Contents"), "toc-viewer")
d.setAllowedAreas(
Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea | Qt.BottomDockWidgetArea | Qt.TopDockWidgetArea
)
d.setWidget(self.toc_view)
self.addDockWidget(Qt.LeftDockWidgetArea, d)
d.close() # Hidden by default
d = create(_("Checkpoints"), "checkpoints")
d.setAllowedAreas(
Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea | Qt.BottomDockWidgetArea | Qt.TopDockWidgetArea
)
self.checkpoints = CheckpointView(self.boss.global_undo, parent=d)
d.setWidget(self.checkpoints)
self.addDockWidget(Qt.LeftDockWidgetArea, d)
d.close() # Hidden by default
def resizeEvent(self, ev):
self.blocking_job.resize(ev.size())
return super(Main, self).resizeEvent(ev)
def update_window_title(self):
fname = os.path.basename(current_container().path_to_ebook)
self.setWindowTitle(
self.current_metadata.title
+ " [%s] :: %s :: %s" % (current_container().book_type.upper(), fname, self.APP_NAME)
)
def closeEvent(self, e):
if not self.boss.confirm_quit():
e.ignore()
return
try:
self.boss.shutdown()
except:
import traceback
traceback.print_exc()
e.accept()
def save_state(self):
tprefs.set("main_window_geometry", bytearray(self.saveGeometry()))
tprefs.set("main_window_state", bytearray(self.saveState(self.STATE_VERSION)))
self.central.save_state()
self.check_book.save_state()
def restore_state(self):
geom = tprefs.get("main_window_geometry", None)
if geom is not None:
self.restoreGeometry(geom)
state = tprefs.get("main_window_state", None)
if state is not None:
self.restoreState(state, self.STATE_VERSION)
self.central.restore_state()
def contextMenuEvent(self, ev):
ev.ignore()