def clone_action(ac, parent): if ac.isSeparator(): ans = QAction(parent) ans.setSeparator(True) return ans sc = ac.shortcut() sc = '' if sc.isEmpty() else sc.toString(sc.NativeText) ans = QAction(ac.icon(), ac.text() + '\t' + sc, parent) ans.triggered.connect(ac.trigger) ans.setEnabled(ac.isEnabled()) ans.setStatusTip(ac.statusTip()) ans.setVisible(ac.isVisible()) return ans
def clone_action(ac, parent): if ac.isSeparator(): ans = QAction(parent) ans.setSeparator(True) return ans sc = ac.shortcut() sc = '' if sc.isEmpty() else sc.toString(sc.NativeText) text = ac.text() if '\t' not in text: text += '\t' + sc ans = QAction(ac.icon(), text, parent) ans.triggered.connect(ac.trigger) ans.setEnabled(ac.isEnabled()) ans.setStatusTip(ac.statusTip()) ans.setVisible(ac.isVisible()) return ans
def _create_context_menu(self): self.plugin_view.setContextMenuPolicy( Qt.ContextMenuPolicy.ActionsContextMenu) self.install_action = QAction( QIcon(I('plugins/plugin_upgrade_ok.png')), _('&Install'), self) self.install_action.setToolTip(_('Install the selected plugin')) self.install_action.triggered.connect(self._install_clicked) self.install_action.setEnabled(False) self.plugin_view.addAction(self.install_action) self.forum_action = QAction(QIcon(I('plugins/mobileread.png')), _('Plugin &forum thread'), self) self.forum_action.triggered.connect(self._forum_label_activated) self.forum_action.setEnabled(False) self.plugin_view.addAction(self.forum_action) sep1 = QAction(self) sep1.setSeparator(True) self.plugin_view.addAction(sep1) self.toggle_enabled_action = QAction(_('Enable/&disable plugin'), self) self.toggle_enabled_action.setToolTip( _('Enable or disable this plugin')) self.toggle_enabled_action.triggered.connect( self._toggle_enabled_clicked) self.toggle_enabled_action.setEnabled(False) self.plugin_view.addAction(self.toggle_enabled_action) self.uninstall_action = QAction(_('&Remove plugin'), self) self.uninstall_action.setToolTip(_('Uninstall the selected plugin')) self.uninstall_action.triggered.connect(self._uninstall_clicked) self.uninstall_action.setEnabled(False) self.plugin_view.addAction(self.uninstall_action) sep2 = QAction(self) sep2.setSeparator(True) self.plugin_view.addAction(sep2) self.donate_enabled_action = QAction(QIcon(I('donate.png')), _('Donate to developer'), self) self.donate_enabled_action.setToolTip( _('Donate to the developer of this plugin')) self.donate_enabled_action.triggered.connect(self._donate_clicked) self.donate_enabled_action.setEnabled(False) self.plugin_view.addAction(self.donate_enabled_action) sep3 = QAction(self) sep3.setSeparator(True) self.plugin_view.addAction(sep3) self.configure_action = QAction(QIcon(I('config.png')), _('&Customize plugin'), self) self.configure_action.setToolTip( _('Customize the options for this plugin')) self.configure_action.triggered.connect(self._configure_clicked) self.configure_action.setEnabled(False) self.plugin_view.addAction(self.configure_action)
def _create_context_menu(self): self.plugin_view.setContextMenuPolicy(Qt.ActionsContextMenu) self.install_action = QAction(QIcon(I('plugins/plugin_upgrade_ok.png')), _('&Install'), self) self.install_action.setToolTip(_('Install the selected plugin')) self.install_action.triggered.connect(self._install_clicked) self.install_action.setEnabled(False) self.plugin_view.addAction(self.install_action) self.history_action = QAction(QIcon(I('chapters.png')), _('Version &history'), self) self.history_action.setToolTip(_('Show history of changes to this plugin')) self.history_action.triggered.connect(self._history_clicked) self.history_action.setEnabled(False) self.plugin_view.addAction(self.history_action) self.forum_action = QAction(QIcon(I('plugins/mobileread.png')), _('Plugin &forum thread'), self) self.forum_action.triggered.connect(self._forum_label_activated) self.forum_action.setEnabled(False) self.plugin_view.addAction(self.forum_action) sep1 = QAction(self) sep1.setSeparator(True) self.plugin_view.addAction(sep1) self.toggle_enabled_action = QAction(_('Enable/&disable plugin'), self) self.toggle_enabled_action.setToolTip(_('Enable or disable this plugin')) self.toggle_enabled_action.triggered.connect(self._toggle_enabled_clicked) self.toggle_enabled_action.setEnabled(False) self.plugin_view.addAction(self.toggle_enabled_action) self.uninstall_action = QAction(_('&Remove plugin'), self) self.uninstall_action.setToolTip(_('Uninstall the selected plugin')) self.uninstall_action.triggered.connect(self._uninstall_clicked) self.uninstall_action.setEnabled(False) self.plugin_view.addAction(self.uninstall_action) sep2 = QAction(self) sep2.setSeparator(True) self.plugin_view.addAction(sep2) self.donate_enabled_action = QAction(QIcon(I('donate.png')), _('Donate to developer'), self) self.donate_enabled_action.setToolTip(_('Donate to the developer of this plugin')) self.donate_enabled_action.triggered.connect(self._donate_clicked) self.donate_enabled_action.setEnabled(False) self.plugin_view.addAction(self.donate_enabled_action) sep3 = QAction(self) sep3.setSeparator(True) self.plugin_view.addAction(sep3) self.configure_action = QAction(QIcon(I('config.png')), _('&Customize plugin'), self) self.configure_action.setToolTip(_('Customize the options for this plugin')) self.configure_action.triggered.connect(self._configure_clicked) self.configure_action.setEnabled(False) self.plugin_view.addAction(self.configure_action)
def create_context_menu(self): self.setContextMenuPolicy(Qt.ActionsContextMenu) self.assign_original_index_action = QAction('Lock old series index', self) self.assign_original_index_action.setIcon(get_icon('images/lock.png')) self.assign_original_index_action.triggered.connect( self.parent().assign_original_index) self.addAction(self.assign_original_index_action) self.assign_index_action = QAction('Lock series index...', self) self.assign_index_action.setIcon(get_icon('images/lock.png')) self.assign_index_action.triggered.connect(self.parent().assign_index) self.addAction(self.assign_index_action) self.clear_index_action = QAction('Unlock series index', self) self.clear_index_action.setIcon(get_icon('images/lock_delete.png')) self.clear_index_action.triggered.connect( partial(self.parent().clear_index, all_rows=False)) self.addAction(self.clear_index_action) self.clear_all_index_action = QAction('Unlock all series index', self) self.clear_all_index_action.setIcon(get_icon('images/lock_open.png')) self.clear_all_index_action.triggered.connect( partial(self.parent().clear_index, all_rows=True)) self.addAction(self.clear_all_index_action) sep1 = QAction(self) sep1.setSeparator(True) self.addAction(sep1) self.add_empty_action = QAction('Add empty books...', self) self.add_empty_action.setIcon(get_icon('add_book.png')) self.add_empty_action.triggered.connect(self.parent().add_empty_book) self.addAction(self.add_empty_action) sep2 = QAction(self) sep2.setSeparator(True) self.addAction(sep2) for name in [ 'PubDate', 'Original Series Index', 'Original Series Name' ]: sort_action = QAction('Sort by ' + name, self) sort_action.setIcon(get_icon('images/sort.png')) sort_action.triggered.connect(partial(self.parent().sort_by, name)) self.addAction(sort_action) sep3 = QAction(self) sep3.setSeparator(True) self.addAction(sep3) for name, icon in [('FantasticFiction', 'images/ms_ff.png'), ('Goodreads', 'images/ms_goodreads.png'), ('Google', 'images/ms_google.png'), ('Wikipedia', 'images/ms_wikipedia.png')]: menu_action = QAction('Search %s' % name, self) menu_action.setIcon(get_icon(icon)) menu_action.triggered.connect( partial(self.parent().search_web, name)) self.addAction(menu_action)