def init_search_box_mixin(self): self.search.initialize('main_search_history', colorize=True, help_text=_('Search (For advanced search click the gear icon to the left)')) self.search.cleared.connect(self.search_box_cleared) # Queued so that search.current_text will be correct self.search.changed.connect(self.search_box_changed, type=Qt.ConnectionType.QueuedConnection) self.search.focus_to_library.connect(self.focus_to_library) self.advanced_search_toggle_action.triggered.connect(self.do_advanced_search) self.search.clear() self.search.setMaximumWidth(self.width()-150) self.action_focus_search = QAction(self) shortcuts = list( map(lambda x:unicode_type(x.toString(QKeySequence.SequenceFormat.PortableText)), QKeySequence.keyBindings(QKeySequence.StandardKey.Find))) shortcuts += ['/', 'Alt+S'] self.keyboard.register_shortcut('start search', _('Start search'), default_keys=shortcuts, action=self.action_focus_search) self.action_focus_search.triggered.connect(self.focus_search_box) self.addAction(self.action_focus_search) self.search.setStatusTip(re.sub(r'<\w+>', ' ', unicode_type(self.search.toolTip()))) self.set_highlight_only_button_icon() self.highlight_only_button.clicked.connect(self.highlight_only_clicked) tt = _('Enable or disable search highlighting.') + '<br><br>' tt += config.help('highlight_search_matches') self.highlight_only_button.setToolTip(tt) self.highlight_only_action = ac = QAction(self) self.addAction(ac), ac.triggered.connect(self.highlight_only_clicked) self.keyboard.register_shortcut('highlight search results', _('Highlight search results'), action=self.highlight_only_action)
def __init__(self, text, key, ascending, parent): QAction.__init__(self, text, parent) self.key, self.ascending = key, ascending self.triggered.connect(self) ic = category_icon_map['custom:'] if self.key.startswith('#') else category_icon_map.get(key) if ic: self.setIcon(QIcon.ic(ic))
def __init__(self, parent): QTabBar.__init__(self, parent) self.setDocumentMode(True) self.setDrawBase(False) self.setMovable(True) self.setTabsClosable(gprefs['vl_tabs_closable']) self.gui = parent self.ignore_tab_changed = False self.currentChanged.connect(self.tab_changed) self.tabMoved.connect(self.tab_moved, type=Qt.ConnectionType.QueuedConnection) self.tabCloseRequested.connect(self.tab_close) self.setVisible(gprefs['show_vl_tabs']) self.next_action = a = QAction(self) a.triggered.connect(partial(self.next_tab, delta=1)), self.gui.addAction(a) self.previous_action = a = QAction(self) a.triggered.connect(partial(self.next_tab, delta=-1)), self.gui.addAction(a) self.gui.keyboard.register_shortcut( 'virtual-library-tab-bar-next', _('Next Virtual library'), action=self.next_action, default_keys=('Ctrl+Right',), description=_('Switch to the next Virtual library in the Virtual library tab bar') ) self.gui.keyboard.register_shortcut( 'virtual-library-tab-bar-previous', _('Previous Virtual library'), action=self.previous_action, default_keys=('Ctrl+Left',), description=_('Switch to the previous Virtual library in the Virtual library tab bar') )
def __init__(self, parent, cover_flow): QDialog.__init__(self, parent) self._layout = QStackedLayout() self.setLayout(self._layout) self.setWindowTitle(_('Browse by covers')) self.layout().addWidget(cover_flow) geom = gprefs.get('cover_browser_dialog_geometry', None) if not geom or not QApplication.instance().safe_restore_geometry(self, geom): h, w = available_height()-60, int(available_width()/1.5) self.resize(w, h) self.action_fs_toggle = a = QAction(self) self.addAction(a) a.setShortcuts([QKeySequence('F11', QKeySequence.SequenceFormat.PortableText), QKeySequence('Ctrl+Shift+F', QKeySequence.SequenceFormat.PortableText)]) a.triggered.connect(self.toggle_fullscreen) self.action_esc_fs = a = QAction(self) a.triggered.connect(self.show_normal) self.addAction(a) a.setShortcuts([QKeySequence('Esc', QKeySequence.SequenceFormat.PortableText)]) self.pre_fs_geom = None cover_flow.setFocus(Qt.FocusReason.OtherFocusReason) self.view_action = a = QAction(self) iactions = parent.iactions self.addAction(a) a.setShortcuts(list(iactions['View'].menuless_qaction.shortcuts())+ [QKeySequence(Qt.Key.Key_Space)]) a.triggered.connect(iactions['View'].menuless_qaction.trigger) self.sd_action = a = QAction(self) self.addAction(a) a.setShortcuts(list(iactions['Send To Device']. menuless_qaction.shortcuts())) a.triggered.connect(iactions['Send To Device'].menuless_qaction.trigger)
def __init__(self, clone, parent, is_top_level=False, clone_shortcuts=True): QAction.__init__(self, clone.text().replace('&&', '&'), parent) self.setMenuRole(QAction.MenuRole.NoRole) # ensure this action is not moved around by Qt self.is_top_level = is_top_level self.clone_shortcuts = clone_shortcuts self.clone = clone clone.changed.connect(self.clone_changed) self.clone_changed() self.triggered.connect(self.do_trigger)
def __init__(self, parent=None): QListWidget.__init__(self, parent) self.setAlternatingRowColors(True) self.setStyleSheet('QListView::item { padding: 0.5ex }') self.setContextMenuPolicy(Qt.ContextMenuPolicy.ActionsContextMenu) self.ac_edit = ac = QAction(QIcon(I('edit_input.png')), _('Rename this bookmark'), self) self.addAction(ac) self.ac_delete = ac = QAction(QIcon(I('trash.png')), _('Remove this bookmark'), self) self.addAction(ac)
def __init__(self, vertical, parent=None): HTMLDisplay.__init__(self, parent) self.vertical = vertical self.anchor_clicked.connect(self.link_activated) for x, icon in [ ('remove_format', 'trash.png'), ('save_format', 'save.png'), ('restore_format', 'edit-undo.png'), ('copy_link','edit-copy.png'), ('compare_format', 'diff.png'), ('set_cover_format', 'default_cover.png'), ('find_in_tag_browser', 'search.png') ]: ac = QAction(QIcon(I(icon)), '', self) ac.current_fmt = None ac.current_url = None ac.triggered.connect(getattr(self, '%s_triggerred'%x)) setattr(self, '%s_action'%x, ac) self.manage_action = QAction(self) self.manage_action.current_fmt = self.manage_action.current_url = None self.manage_action.triggered.connect(self.manage_action_triggered) self.edit_identifiers_action = QAction(QIcon(I('identifiers.png')), _('Edit identifiers for this book'), self) self.edit_identifiers_action.triggered.connect(self.edit_identifiers) self.remove_item_action = ac = QAction(QIcon(I('minus.png')), '...', self) ac.data = (None, None, None) ac.triggered.connect(self.remove_item_triggered) self.copy_identifiers_url_action = ac = QAction(QIcon(I('edit-copy.png')), _('Identifier &URL'), self) ac.triggered.connect(self.copy_id_url_triggerred) ac.current_url = ac.current_fmt = None self.setFocusPolicy(Qt.FocusPolicy.NoFocus) self.setDefaultStyleSheet(css())
def __init__(self, parent=None): QListWidget.__init__(self, parent) self.setAlternatingRowColors(True) self.setStyleSheet('QListView::item { padding: 0.5ex }') self.setContextMenuPolicy(Qt.ContextMenuPolicy.ActionsContextMenu) self.ac_edit = ac = QAction(QIcon(I('edit_input.png')), _('Rename this bookmark'), self) self.addAction(ac) self.ac_delete = ac = QAction(QIcon(I('trash.png')), _('Remove this bookmark'), self) self.addAction(ac) self.gesture_manager = GestureManager(self) self.setVerticalScrollMode(QAbstractItemView.ScrollMode.ScrollPerPixel)
def __init__(self, name, label, icon, initial_show=True, initial_side_size=120, connect_button=True, orientation=Qt.Orientation.Horizontal, side_index=0, parent=None, shortcut=None, hide_handle_on_single_panel=True): QSplitter.__init__(self, parent) self.reapply_sizes.connect(self.setSizes, type=Qt.ConnectionType.QueuedConnection) self.hide_handle_on_single_panel = hide_handle_on_single_panel if hide_handle_on_single_panel: self.state_changed.connect(self.update_handle_width) self.original_handle_width = self.handleWidth() self.resize_timer = QTimer(self) self.resize_timer.setSingleShot(True) self.desired_side_size = initial_side_size self.desired_show = initial_show self.resize_timer.setInterval(5) self.resize_timer.timeout.connect(self.do_resize) self.setOrientation(orientation) self.side_index = side_index self._name = name self.label = label self.initial_side_size = initial_side_size self.initial_show = initial_show self.splitterMoved.connect(self.splitter_moved, type=Qt.ConnectionType.QueuedConnection) self.button = LayoutButton(icon, label, self, shortcut=shortcut) if connect_button: self.button.clicked.connect(self.double_clicked) if shortcut is not None: self.action_toggle = QAction(QIcon(icon), _('Toggle') + ' ' + label, self) self.action_toggle.changed.connect(self.update_shortcut) self.action_toggle.triggered.connect(self.toggle_triggered) if parent is not None: parent.addAction(self.action_toggle) if hasattr(parent, 'keyboard'): parent.keyboard.register_shortcut( 'splitter %s %s' % (name, label), str(self.action_toggle.text()), default_keys=(shortcut, ), action=self.action_toggle) else: self.action_toggle.setShortcut(shortcut) else: self.action_toggle.setShortcut(shortcut)
def __init__(self, gui): sc = 'Alt+Shift+G' LayoutButton.__init__(self, I('grid.png'), _('Cover grid'), parent=gui, shortcut=sc) self.set_state_to_show() self.action_toggle = QAction(self.icon(), _('Toggle') + ' ' + self.label, self) gui.addAction(self.action_toggle) gui.keyboard.register_shortcut('grid view toggle' + self.label, unicode_type(self.action_toggle.text()), default_keys=(sc,), action=self.action_toggle) self.action_toggle.triggered.connect(self.toggle) self.action_toggle.changed.connect(self.update_shortcut) self.toggled.connect(self.update_state)
def __init__(self, gui): sc = 'Alt+Shift+F' LayoutButton.__init__(self, I('search.png'), _('Search bar'), parent=gui, shortcut=sc) self.set_state_to_hide() self.action_toggle = QAction(self.icon(), _('Toggle') + ' ' + self.label, self) gui.addAction(self.action_toggle) gui.keyboard.register_shortcut('search bar toggle' + self.label, str(self.action_toggle.text()), default_keys=(sc,), action=self.action_toggle) self.action_toggle.triggered.connect(self.toggle) self.action_toggle.changed.connect(self.update_shortcut) self.toggled.connect(self.update_state)
def genesis(self): self.gui.keyboard.register_shortcut( 'Toggle Quickview', _('Toggle Quickview'), description=_('Open/close the Quickview panel/window'), default_keys=('Q', ), action=self.qaction, group=self.action_spec[0]) self.focus_action = QAction(self.gui) self.gui.addAction(self.focus_action) self.gui.keyboard.register_shortcut( 'Focus To Quickview', _('Focus to Quickview'), description=_('Move the focus to the Quickview panel/window'), default_keys=('Shift+Q', ), action=self.focus_action, group=self.action_spec[0]) self.focus_action.triggered.connect(self.focus_quickview) self.focus_bl_action = QAction(self.gui) self.gui.addAction(self.focus_bl_action) self.gui.keyboard.register_shortcut( 'Focus from Quickview', _('Focus from Quickview to the book list'), description=_('Move the focus from Quickview to the book list'), default_keys=('Shift+Alt+Q', ), action=self.focus_bl_action, group=self.action_spec[0]) self.focus_bl_action.triggered.connect(self.focus_booklist) self.focus_refresh_action = QAction(self.gui) self.gui.addAction(self.focus_refresh_action) self.gui.keyboard.register_shortcut( 'Refresh from Quickview', _('Refresh Quickview'), description=_( 'Refresh the information shown in the Quickview panel'), action=self.focus_refresh_action, group=self.action_spec[0]) self.focus_refresh_action.triggered.connect(self.refill_quickview) self.search_action = QAction(self.gui) self.gui.addAction(self.search_action) self.gui.keyboard.register_shortcut( 'Search from Quickview', _('Search from Quickview'), description=_('Search for the currently selected Quickview item'), default_keys=('Shift+S', ), action=self.search_action, group=self.action_spec[0]) self.search_action.triggered.connect(self.search_quickview) self.qv_button = QuickviewButton(self.gui, self)
def r(name, icon, text, checkable=False, shortcut=None): ac = QAction(QIcon(I(icon + '.png')), text, self) ac.setShortcutContext(Qt.ShortcutContext.WidgetWithChildrenShortcut) if checkable: ac.setCheckable(checkable) setattr(self, 'action_'+name, ac) ac.triggered.connect(getattr(self, 'do_' + name)) if shortcut is not None: sc = shortcut if isinstance(shortcut, QKeySequence) else QKeySequence(shortcut) ac.setShortcut(sc) ac.setToolTip(text + f' [{sc.toString(QKeySequence.SequenceFormat.NativeText)}]') self.addAction(ac)
def __init__(self, location_manager, parent): QObject.__init__(self, parent) self.gui = parent self.location_manager = location_manager self.added_actions = [] self.last_actions = [] self.donate_action = QAction(_('Donate'), self) self.donate_menu = QMenu() self.donate_menu.addAction(self.gui.donate_action) self.donate_action.setMenu(self.donate_menu) self.refresh_timer = t = QTimer(self) t.setInterval(200), t.setSingleShot(True), t.timeout.connect(self.refresh_bar)
def __init__(self, location_manager, parent): QObject.__init__(self, parent) self.menu_bar = QMenuBar(parent) self.menu_bar.is_native_menubar = False parent.setMenuBar(self.menu_bar) self.gui = parent self.location_manager = location_manager self.added_actions = [] self.donate_action = QAction(_('Donate'), self) self.donate_menu = QMenu() self.donate_menu.addAction(self.gui.donate_action) self.donate_action.setMenu(self.donate_menu)
def __init__(self, location_manager, parent): QObject.__init__(self, parent) f = factory(app_id='com.calibre-ebook.gui') self.menu_bar = f.create_window_menubar(parent) self.is_native_menubar = self.menu_bar.is_native_menubar self.gui = parent self.location_manager = location_manager self.added_actions = [] self.donate_action = QAction(_('Donate'), self) self.donate_menu = QMenu() self.donate_menu.addAction(self.gui.donate_action) self.donate_action.setMenu(self.donate_menu)
def reg(icon, text, target, sid, keys, description, toolbar_allowed=False): if not isinstance(icon, QIcon): icon = QIcon(I(icon)) ac = actions[sid] = QAction(icon, text, self) if icon else QAction(text, self) ac.setObjectName('action-' + sid) if toolbar_allowed: toolbar_actions[sid] = ac if target is not None: ac.triggered.connect(target) if isinstance(keys, unicode_type): keys = (keys,) self.keyboard.register_shortcut( sid, unicode_type(ac.text()).replace('&', ''), default_keys=keys, description=description, action=ac, group=group) self.addAction(ac) return ac
class SearchBarButton(LayoutButton): # {{{ def __init__(self, gui): sc = 'Alt+Shift+F' LayoutButton.__init__(self, I('search.png'), _('Search bar'), parent=gui, shortcut=sc) self.set_state_to_hide() self.action_toggle = QAction(self.icon(), _('Toggle') + ' ' + self.label, self) gui.addAction(self.action_toggle) gui.keyboard.register_shortcut('search bar toggle' + self.label, str(self.action_toggle.text()), default_keys=(sc,), action=self.action_toggle) self.action_toggle.triggered.connect(self.toggle) self.action_toggle.changed.connect(self.update_shortcut) self.toggled.connect(self.update_state) def update_state(self, checked): if checked: self.set_state_to_hide() else: self.set_state_to_show() def save_state(self): gprefs['search bar visible'] = bool(self.isChecked()) def restore_state(self): self.setChecked(bool(gprefs.get('search bar visible', True)))
class GridViewButton(LayoutButton): # {{{ def __init__(self, gui): sc = 'Alt+Shift+G' LayoutButton.__init__(self, I('grid.png'), _('Cover grid'), parent=gui, shortcut=sc) self.set_state_to_show() self.action_toggle = QAction(self.icon(), _('Toggle') + ' ' + self.label, self) gui.addAction(self.action_toggle) gui.keyboard.register_shortcut('grid view toggle' + self.label, str(self.action_toggle.text()), default_keys=(sc,), action=self.action_toggle) self.action_toggle.triggered.connect(self.toggle) self.action_toggle.changed.connect(self.update_shortcut) self.toggled.connect(self.update_state) def update_state(self, checked): if checked: self.set_state_to_hide() else: self.set_state_to_show() def save_state(self): gprefs['grid view visible'] = bool(self.isChecked()) def restore_state(self): if gprefs.get('grid view visible', False): self.toggle()
def register_keyboard_shortcuts(gui=None, finalize=False): if gui is None: from calibre.gui2.ui import get_gui gui = get_gui() if gui is None: return for unique_name, action in iteritems(registered_shortcuts): gui.keyboard.unregister_shortcut(unique_name) gui.removeAction(action) registered_shortcuts.clear() for filetype, applications in iteritems(oprefs['entries']): for application in applications: text = entry_to_icon_text(application, only_text=True) t = _('cover image') if filetype.upper() == 'COVER_IMAGE' else filetype.upper() name = _('Open {0} files with {1}').format(t, text) ac = QAction(gui) unique_name = application['uuid'] func = partial(gui.open_with_action_triggerred, filetype, application) ac.triggered.connect(func) gui.keyboard.register_shortcut(unique_name, name, action=ac, group=_('Open with')) gui.addAction(ac) registered_shortcuts[unique_name] = ac if finalize: gui.keyboard.finalize()
def create_shortcut_action(self, name): a = getattr(all_actions(), name) sc = a.shortcut_action a = QAction(a.icon, a.text, self) connect_lambda(a.triggered, self, lambda self: self.action_triggered.emit(sc)) self.shortcut_actions[sc] = a return a
def init_search_restriction_mixin(self): self.checked = QIcon(I('ok.png')) self.empty = QIcon(I('blank.png')) self.current_search_action = QAction(self.empty, _('*current search'), self) self.current_search_action.triggered.connect(partial(self.apply_virtual_library, library='*')) self.addAction(self.current_search_action) self.keyboard.register_shortcut( 'vl-from-current-search', _('Virtual library from current search'), description=_( 'Create a temporary Virtual library from the current search'), group=pgettext('search restriction group name', 'Miscellaneous'), default_keys=('Ctrl+*',), action=self.current_search_action) self.search_based_vl_name = None self.search_based_vl = None self.virtual_library_menu = QMenu(self.virtual_library) self.virtual_library.setMenu(self.virtual_library_menu) self.virtual_library_menu.aboutToShow.connect(self.virtual_library_menu_about_to_show) self.clear_vl.clicked.connect(lambda x: (self.apply_virtual_library(), self.clear_additional_restriction())) self.virtual_library_tooltip = \ _('Use a "Virtual library" to show only a subset of the books present in this library') self.virtual_library.setToolTip(self.virtual_library_tooltip) self.search_restriction = ComboBoxWithHelp(self) self.search_restriction.setVisible(False) self.clear_vl.setText(_("(all books)")) self.ar_menu = QMenu(_('Additional restriction'), self.virtual_library_menu) self.edit_menu = QMenu(_('Edit Virtual library'), self.virtual_library_menu) self.rm_menu = QMenu(_('Remove Virtual library'), self.virtual_library_menu) self.search_restriction_list_built = False
def __init__(self, parent=None): QWidget.__init__(self, parent) self.num_jobs = 0 self.mouse_over = False self.pi = ProgressIndicator(self, self.style().pixelMetric(QStyle.PixelMetric.PM_ToolBarIconSize)) self.pi.setVisible(False) self._jobs = QLabel('') self._jobs.mouseReleaseEvent = self.mouseReleaseEvent self.update_label() 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.PixelMetric.PM_DefaultFrameWidth) self.layout().setContentsMargins(m, m, m, m) self._jobs.setSizePolicy(QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Minimum) self.setCursor(Qt.CursorShape.PointingHandCursor) b = _('Click to see list of jobs') self.setToolTip(b + _(' [Alt+Shift+J]')) 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 __init__(self, parent=None): QWidget.__init__(self, parent) self.l = l = QGridLayout(self) self.toc_title = None self.setLayout(l) l.setContentsMargins(0, 0, 0, 0) self.view = make_view_use_window_background(QTreeWidget(self)) self.delegate = Delegate(self.view) self.view.setItemDelegate(self.delegate) self.view.setHeaderHidden(True) self.view.setAnimated(True) self.view.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.view.customContextMenuRequested.connect( self.show_context_menu, type=Qt.ConnectionType.QueuedConnection) self.view.itemActivated.connect(self.emit_navigate) self.view.itemPressed.connect(self.item_pressed) set_no_activate_on_click(self.view) self.view.itemDoubleClicked.connect(self.emit_navigate) l.addWidget(self.view) self.refresh_action = QAction(QIcon(I('view-refresh.png')), _('&Refresh'), self) self.refresh_action.triggered.connect(self.refresh) self.refresh_timer = t = QTimer(self) t.setInterval(1000), t.setSingleShot(True) t.timeout.connect(self.auto_refresh) self.toc_name = None self.currently_editing = None
def genesis(self): self.menu = m = self.qaction.menu() m.aboutToShow.connect(self.about_to_show_menu) self.qs_action = QAction(self.gui) self.gui.addAction(self.qs_action) self.qs_action.triggered.connect(self.gui.choose_vl_triggerred) self.gui.keyboard.register_shortcut(self.unique_name + ' - ' + 'quick-select-vl', _('Quick select Virtual library'), default_keys=('Ctrl+T',), action=self.qs_action, description=_('Quick select a Virtual library'), group=self.action_spec[0])
def tag_browser_context_action(self, index): ''' Called when displaying the context menu in the Tag browser. ``index`` is the QModelIndex that points to the Tag browser item that was right clicked. Test it for validity with index.valid() and get the underlying TagTreeItem object with index.data(Qt.ItemDataRole.UserRole). Any action objects yielded by this method will be added to the context menu. ''' if False: yield QAction()
def adapt_for_dialog(self, enter): def ac(text, key, role=QAction.MenuRole.TextHeuristicRole): ans = QAction(text, self) ans.setMenuRole(role) ans.setShortcut(QKeySequence(key)) self.edit_menu.addAction(ans) return ans mb = self.native_menubar if enter: self.clear_bar(mb) self.edit_menu = QMenu() self.edit_action = QAction(_('Edit'), self) self.edit_action.setMenu(self.edit_menu) ac(_('Copy'), QKeySequence.StandardKey.Copy), ac(_('Paste'), QKeySequence.StandardKey.Paste), ac(_('Select all'), QKeySequence.StandardKey.SelectAll), mb.addAction(self.edit_action) self.added_actions = [self.edit_action] else: self.refresh_bar()
def __init__(self, parent, db): QObject.__init__(self, parent) self.internet_connection_failed = False self._parent = parent self.no_internet_msg = _( 'Cannot download news as no internet connection ' 'is active') self.no_internet_dialog = d = error_dialog(self._parent, self.no_internet_msg, _('No internet connection'), show_copy_button=False) d.setModal(False) self.recipe_model = RecipeModel() self.db = db self.lock = QMutex(QMutex.RecursionMode.Recursive) self.download_queue = set() self.news_menu = QMenu() self.news_icon = QIcon(I('news.png')) self.scheduler_action = QAction(QIcon(I('scheduler.png')), _('Schedule news download'), self) self.news_menu.addAction(self.scheduler_action) self.scheduler_action.triggered[bool].connect(self.show_dialog) self.cac = QAction(QIcon(I('user_profile.png')), _('Add or edit a custom news source'), self) self.cac.triggered[bool].connect(self.customize_feeds) self.news_menu.addAction(self.cac) self.news_menu.addSeparator() self.all_action = self.news_menu.addAction( QIcon.ic('download-metadata.png'), _('Download all scheduled news sources'), self.download_all_scheduled) self.timer = QTimer(self) self.timer.start(int(self.INTERVAL * 60 * 1000)) self.timer.timeout.connect(self.check) self.oldest = gconf['oldest_news'] QTimer.singleShot(5 * 1000, self.oldest_check)
def create_action(self, for_toolbar=True): # Create an action, this will be added to the plugins toolbar and # the plugins menu ac = QAction(get_icons('images/icon.png'), 'Magnify fonts', self.gui) # noqa if not for_toolbar: # Register a keyboard shortcut for this toolbar action. We only # register it for the action created for the menu, not the toolbar, # to avoid a double trigger self.register_shortcut(ac, 'magnify-fonts-tool', default_keys=('Ctrl+Shift+Alt+D', )) ac.triggered.connect(self.ask_user) return ac
def __init__(self, id_, title, parent): QAction.__init__(self, title, parent) self.id = id_ self.triggered.connect(self._triggered)