本文整理汇总了Python中calibre.gui2.viewer.ui.Main类的典型用法代码示例。如果您正苦于以下问题:Python Main类的具体用法?Python Main怎么用?Python Main使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Main类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: closeEvent
def closeEvent(self, e):
if self.closed:
e.ignore()
return
if self.shutdown():
self.closed = True
return MainWindow.closeEvent(self, e)
else:
e.ignore()
示例2: keyPressEvent
def keyPressEvent(self, event):
if event.key() == Qt.Key_Escape:
if self.metadata.isVisible():
self.metadata.setVisible(False)
event.accept()
return
if self.isFullScreen():
self.action_full_screen.trigger()
event.accept()
return
try:
key = self.view.shortcuts.get_match(event)
except AttributeError:
return MainWindow.keyPressEvent(self, event)
try:
bac = self.bookmarks_menu.actions()[0]
except (AttributeError, TypeError, IndexError, KeyError):
bac = None
action = {
'Quit':self.action_quit,
'Show metadata':self.action_metadata,
'Copy':self.view.copy_action,
'Font larger': self.action_font_size_larger,
'Font smaller': self.action_font_size_smaller,
'Fullscreen': self.action_full_screen,
'Find next': self.action_find_next,
'Find previous': self.action_find_previous,
'Search online': self.view.search_online_action,
'Lookup word': self.view.dictionary_action,
'Next occurrence': self.view.search_action,
'Bookmark': bac,
'Reload': self.action_reload,
'Table of Contents': self.action_table_of_contents,
'Print': self.action_print,
}.get(key, None)
if action is not None:
event.accept()
action.trigger()
return
if key == 'Focus Search':
self.search.setFocus(Qt.OtherFocusReason)
return
if not self.view.handle_key_press(event):
event.ignore()
示例3: keyPressEvent
def keyPressEvent(self, event):
if event.key() == Qt.Key_Escape:
if self.metadata.isVisible():
self.metadata.setVisible(False)
event.accept()
return
if self.isFullScreen():
self.action_full_screen.trigger()
event.accept()
return
try:
key = self.view.shortcuts.get_match(event)
except AttributeError:
return MainWindow.keyPressEvent(self, event)
try:
bac = self.bookmarks_menu.actions()[0]
except (AttributeError, TypeError, IndexError, KeyError):
bac = None
action = {
"Quit": self.action_quit,
"Show metadata": self.action_metadata,
"Copy": self.view.copy_action,
"Font larger": self.action_font_size_larger,
"Font smaller": self.action_font_size_smaller,
"Fullscreen": self.action_full_screen,
"Find next": self.action_find_next,
"Find previous": self.action_find_previous,
"Search online": self.view.search_online_action,
"Lookup word": self.view.dictionary_action,
"Next occurrence": self.view.search_action,
"Bookmark": bac,
"Reload": self.action_reload,
"Table of Contents": self.action_table_of_contents,
}.get(key, None)
if action is not None:
event.accept()
action.trigger()
return
if key == "Focus Search":
self.search.setFocus(Qt.OtherFocusReason)
return
if not self.view.handle_key_press(event):
event.ignore()
示例4: __init__
def __init__(self, pathtoebook=None, debug_javascript=False, open_at=None,
start_in_fullscreen=False, continue_reading=False, listener=None):
MainWindow.__init__(self, debug_javascript)
self.view.magnification_changed.connect(self.magnification_changed)
self.closed = False
self.show_toc_on_open = False
self.listener = listener
if listener is not None:
t = Thread(name='ConnListener', target=listen, args=(self,))
t.daemon = True
t.start()
self.msg_from_anotherinstance.connect(self.another_instance_wants_to_talk, type=Qt.QueuedConnection)
self.current_book_has_toc = False
self.iterator = None
self.current_page = None
self.pending_search = None
self.pending_search_dir= None
self.pending_anchor = None
self.pending_reference = None
self.pending_bookmark = None
self.pending_restore = False
self.pending_goto_page = None
self.cursor_hidden = False
self.existing_bookmarks= []
self.selected_text = None
self.was_maximized = False
self.page_position_on_footnote_toggle = []
self.read_settings()
self.autosave_timer = t = QTimer(self)
t.setInterval(self.AUTOSAVE_INTERVAL * 1000), t.setSingleShot(True)
t.timeout.connect(self.autosave)
self.pos.value_changed.connect(self.update_pos_label)
self.pos.value_changed.connect(self.autosave_timer.start)
self.pos.setMinimumWidth(150)
self.setFocusPolicy(Qt.StrongFocus)
self.view.set_manager(self)
self.pi = ProgressIndicator(self)
self.action_quit = QAction(_('&Quit'), self)
self.addAction(self.action_quit)
self.view_resized_timer = QTimer(self)
self.view_resized_timer.timeout.connect(self.viewport_resize_finished)
self.view_resized_timer.setSingleShot(True)
self.resize_in_progress = False
self.action_reload = QAction(_('&Reload book'), self)
self.action_reload.triggered.connect(self.reload_book)
self.action_quit.triggered.connect(self.quit)
self.action_reference_mode.triggered[bool].connect(self.view.reference_mode)
self.action_metadata.triggered[bool].connect(self.metadata.setVisible)
self.action_table_of_contents.toggled[bool].connect(self.set_toc_visible)
self.action_copy.triggered[bool].connect(self.copy)
self.action_font_size_larger.triggered.connect(self.font_size_larger)
self.action_font_size_smaller.triggered.connect(self.font_size_smaller)
self.action_open_ebook.triggered[bool].connect(self.open_ebook)
self.action_next_page.triggered.connect(self.view.next_page)
self.action_previous_page.triggered.connect(self.view.previous_page)
self.action_find_next.triggered.connect(self.find_next)
self.action_find_previous.triggered.connect(self.find_previous)
self.action_full_screen.triggered[bool].connect(self.toggle_fullscreen)
self.action_back.triggered[bool].connect(self.back)
self.action_forward.triggered[bool].connect(self.forward)
self.action_preferences.triggered.connect(self.do_config)
self.pos.editingFinished.connect(self.goto_page_num)
self.vertical_scrollbar.valueChanged[int].connect(lambda
x:self.goto_page(x/100.))
self.search.search.connect(self.find)
self.search.focus_to_library.connect(lambda: self.view.setFocus(Qt.OtherFocusReason))
self.toc.pressed[QModelIndex].connect(self.toc_clicked)
self.toc.searched.connect(partial(self.toc_clicked, force=True))
def toggle_toc(ev):
try:
key = self.view.shortcuts.get_match(ev)
except AttributeError:
pass
if key == 'Table of Contents':
ev.accept()
self.action_table_of_contents.trigger()
return True
return False
self.toc.handle_shortcuts = toggle_toc
self.reference.goto.connect(self.goto)
self.bookmarks.edited.connect(self.bookmarks_edited)
self.bookmarks.activated.connect(self.goto_bookmark)
self.bookmarks.create_requested.connect(self.bookmark)
self.set_bookmarks([])
self.load_theme_menu()
if pathtoebook is not None:
f = functools.partial(self.load_ebook, pathtoebook, open_at=open_at)
QTimer.singleShot(50, f)
elif continue_reading:
QTimer.singleShot(50, self.continue_reading)
self.window_mode_changed = None
self.toggle_toolbar_action = QAction(_('Show/hide controls'), self)
self.toggle_toolbar_action.setCheckable(True)
self.toggle_toolbar_action.triggered.connect(self.toggle_toolbars)
self.toolbar_hidden = None
self.addAction(self.toggle_toolbar_action)
self.full_screen_label_anim = QPropertyAnimation(
self.full_screen_label, b'size')
#.........这里部分代码省略.........
示例5: closeEvent
def closeEvent(self, e):
if self.shutdown():
return MainWindow.closeEvent(self, e)
else:
e.ignore()
示例6: __init__
def __init__(self, pathtoebook=None, debug_javascript=False, open_at=None,
start_in_fullscreen=False):
MainWindow.__init__(self, debug_javascript)
self.view.magnification_changed.connect(self.magnification_changed)
self.show_toc_on_open = False
self.current_book_has_toc = False
self.iterator = None
self.current_page = None
self.pending_search = None
self.pending_search_dir= None
self.pending_anchor = None
self.pending_reference = None
self.pending_bookmark = None
self.pending_restore = False
self.existing_bookmarks= []
self.selected_text = None
self.was_maximized = False
self.read_settings()
self.pos.value_changed.connect(self.update_pos_label)
self.pos.setMinimumWidth(150)
self.setFocusPolicy(Qt.StrongFocus)
self.view.set_manager(self)
self.pi = ProgressIndicator(self)
self.action_quit = QAction(_('&Quit'), self)
self.addAction(self.action_quit)
self.view_resized_timer = QTimer(self)
self.view_resized_timer.timeout.connect(self.viewport_resize_finished)
self.view_resized_timer.setSingleShot(True)
self.resize_in_progress = False
self.action_reload = QAction(_('&Reload book'), self)
self.action_reload.triggered.connect(self.reload_book)
self.action_quit.triggered.connect(self.quit)
self.action_reference_mode.triggered[bool].connect(self.view.reference_mode)
self.action_metadata.triggered[bool].connect(self.metadata.setVisible)
self.action_table_of_contents.toggled[bool].connect(self.set_toc_visible)
self.action_copy.triggered[bool].connect(self.copy)
self.action_font_size_larger.triggered.connect(self.font_size_larger)
self.action_font_size_smaller.triggered.connect(self.font_size_smaller)
self.action_open_ebook.triggered[bool].connect(self.open_ebook)
self.action_next_page.triggered.connect(self.view.next_page)
self.action_previous_page.triggered.connect(self.view.previous_page)
self.action_find_next.triggered.connect(self.find_next)
self.action_find_previous.triggered.connect(self.find_previous)
self.action_full_screen.triggered[bool].connect(self.toggle_fullscreen)
self.action_back.triggered[bool].connect(self.back)
self.action_forward.triggered[bool].connect(self.forward)
self.action_preferences.triggered.connect(self.do_config)
self.pos.editingFinished.connect(self.goto_page_num)
self.vertical_scrollbar.valueChanged[int].connect(lambda
x:self.goto_page(x/100.))
self.search.search.connect(self.find)
self.search.focus_to_library.connect(lambda: self.view.setFocus(Qt.OtherFocusReason))
self.toc.pressed[QModelIndex].connect(self.toc_clicked)
self.reference.goto.connect(self.goto)
self.bookmarks.edited.connect(self.bookmarks_edited)
self.bookmarks.activated.connect(self.goto_bookmark)
self.bookmarks.create_requested.connect(self.bookmark)
self.set_bookmarks([])
self.load_theme_menu()
if pathtoebook is not None:
f = functools.partial(self.load_ebook, pathtoebook, open_at=open_at)
QTimer.singleShot(50, f)
self.window_mode_changed = None
self.toggle_toolbar_action = QAction(_('Show/hide controls'), self)
self.toggle_toolbar_action.setCheckable(True)
self.toggle_toolbar_action.triggered.connect(self.toggle_toolbars)
self.toolbar_hidden = None
self.addAction(self.toggle_toolbar_action)
self.full_screen_label_anim = QPropertyAnimation(
self.full_screen_label, 'size')
self.clock_timer = QTimer(self)
self.clock_timer.timeout.connect(self.update_clock)
self.action_print.triggered.connect(self.print_book)
self.print_menu.actions()[0].triggered.connect(self.print_preview)
self.clear_recent_history_action = QAction(
_('Clear list of recently opened books'), self)
self.clear_recent_history_action.triggered.connect(self.clear_recent_history)
self.build_recent_menu()
self.open_history_menu.triggered.connect(self.open_recent)
for x in ('tool_bar', 'tool_bar2'):
x = getattr(self, x)
for action in x.actions():
# So that the keyboard shortcuts for these actions will
# continue to function even when the toolbars are hidden
self.addAction(action)
for plugin in self.view.document.all_viewer_plugins:
plugin.customize_ui(self)
self.view.document.settings_changed.connect(self.settings_changed)
self.restore_state()
self.settings_changed()
self.action_toggle_paged_mode.toggled[bool].connect(self.toggle_paged_mode)
if (start_in_fullscreen or self.view.document.start_in_fullscreen):
self.action_full_screen.trigger()