def assign_shortcuts(self): """assign shortcuts""" QShortcut(QKeySequence(settings.custom_shortcut['key_tabcon_menumgtmonsun_view']), self.menudetail_tab_1, self.row_selected) QShortcut(QKeySequence(settings.custom_shortcut['key_tabcon_menumgtmonsun_refresh']), self.menudetail_tab_1, self.update_menu) QShortcut(QKeySequence(settings.custom_shortcut['key_tabcon_menumgtmonsun_add']), self.menudetail_tab_1, self.add_menu)
def createShortcuts(self): QShortcut(QKeySequence(Qt.Key_Escape), self, self.close) QShortcut(QKeySequence("Alt+Left"), self, self.browser.back) QShortcut(QKeySequence("Alt+Right"), self, self.browser.forward) QShortcut(QKeySequence("Alt+Home"), self, self.contentsButton.click) QShortcut(QKeySequence("Ctrl++"), self, self.zoomInButton.click) QShortcut(QKeySequence("Ctrl+="), self, self.zoomInButton.click) QShortcut(QKeySequence("Ctrl+-"), self, self.zoomOutButton.click) QShortcut(QKeySequence("F3"), self, self.search) QShortcut(QKeySequence("Ctrl+F"), self, self.search) if self.debug: QShortcut(QKeySequence(Qt.Key_F5), self, self.browser.reload)
def __init__(self, parent=None, list=[]): QComboBox.__init__(self, parent) self.setEditable(True) self.setInsertPolicy(QComboBox.NoInsert) self.addItems(list) autoCompleteModel = QStringListModel(list) completer = QCompleter() completer.setModel(autoCompleteModel) completer.setCaseSensitivity(Qt.CaseInsensitive) self.setCompleter(completer) self.setEditText("") self.__textChangeStatus = True self.editTextChanged.connect(self.__onTextChange) shortcut = QShortcut(QKeySequence(Qt.Key_Return), self, self.__onEnter) shortcut = QShortcut(QKeySequence(Qt.Key_Enter), self, self.__onEnter)
def searchCompletion(self): """Searches for possible completion from QCompleter to the current text position""" tc = self.getWidget().textCursor() tc.movePosition(QTextCursor.PreviousCharacter, QTextCursor.KeepAnchor) if tc.selectedText() in string.whitespace: self.completer.popup().hide() return tc.movePosition(QTextCursor.StartOfWord, QTextCursor.KeepAnchor) beginning = tc.selectedText() if len(beginning) >= 3: self.completer.setCompletionPrefix(beginning) self.completer.complete() shortcut = QShortcut(QKeySequence("Ctrl+Enter"), self.getWidget(), self.insertCompletion)
def _init_interface(self): self.ui = Ui_List() self.ui.setupUi(self) self.setWindowIcon(get_icon()) self.setWindowTitle(self.tr("Everpad / All Notes")) self.ui.newNotebookBtn.setIcon(QIcon.fromTheme('folder-new')) self.ui.newNotebookBtn.clicked.connect(self.new_notebook) self.ui.newNoteBtn.setIcon(QIcon.fromTheme('document-new')) self.ui.newNoteBtn.clicked.connect(self.new_note) self.ui.newNoteBtn.setShortcut(QKeySequence(self.tr('Ctrl+n'))) self.ui.newNotebookBtn.setShortcut( QKeySequence(self.tr('Ctrl+Shift+n'))) QShortcut(QKeySequence(self.tr('Ctrl+q')), self, self.close)
def _init_shortcuts(self): for key, action in ( ('Ctrl+b', QWebPage.ToggleBold), ('Ctrl+i', QWebPage.ToggleItalic), ('Ctrl+u', QWebPage.ToggleUnderline), ('Ctrl+Shift+b', QWebPage.InsertUnorderedList), ('Ctrl+Shift+o', QWebPage.InsertOrderedList), ('Ctrl+shift+v', QWebPage.PasteAndMatchStyle), ): QShortcut( QKeySequence(self.app.tr(key)), self.widget, ).activated.connect( Slot()(partial(self._action_for_key, action)), )
def __init__(self, state, parent=None): super().__init__(parent) Lib.prepareModalDialog(self) self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding) self.setWindowTitle("Copy Character — {}".format( QApplication.applicationName())) QShortcut(QKeySequence(QKeySequence.FindNext), self, self.findNext) self.state = state self.createWidgets() self.layoutWidgets() self.createConnections() self.findSizes(self.fontComboBox.currentFont()) self.setToFamily(self.state.stdFontFamily) self.setToNearestSize(self.state.stdFontSize) settings = QSettings() self.updateToolTips( bool( int( settings.value(Gopt.Key.ShowDialogToolTips, Gopt.Default.ShowDialogToolTips))))
def __init__(self, app, *args, **kwargs): QDialog.__init__(self, *args, **kwargs) self.app = app self.closed = False self.sort_order = None self.ui = Ui_List() self.ui.setupUi(self) self.setWindowIcon(get_icon()) self.notebooksModel = QStandardItemModel() self.ui.notebooksList.setModel(self.notebooksModel) self.ui.notebooksList.selection.connect(self.selection_changed) self.ui.notebooksList.setContextMenuPolicy(Qt.CustomContextMenu) self.ui.notebooksList.customContextMenuRequested.connect( self.notebook_context_menu) self.notesModel = QStandardItemModel() self.notesModel.setHorizontalHeaderLabels( [self.tr('Title'), self.tr('Last Updated')]) self.ui.notesList.setModel(self.notesModel) self.ui.notesList.doubleClicked.connect(self.note_dblclicked) self.ui.notesList.setContextMenuPolicy(Qt.CustomContextMenu) self.ui.notesList.customContextMenuRequested.connect( self.note_context_menu) self.ui.notesList.header().sortIndicatorChanged.connect( self.sort_order_updated) self.ui.newNotebookBtn.setIcon(QIcon.fromTheme('folder-new')) self.ui.newNotebookBtn.clicked.connect(self.new_notebook) self.ui.newNoteBtn.setIcon(QIcon.fromTheme('document-new')) self.ui.newNoteBtn.clicked.connect(self.new_note) self.ui.newNoteBtn.setShortcut(QKeySequence(self.tr('Ctrl+n'))) self.ui.newNotebookBtn.setShortcut( QKeySequence(self.tr('Ctrl+Shift+n'))) QShortcut(QKeySequence(self.tr('Ctrl+q')), self, self.close)
def _init_shortcuts(self): for key, action in ( ('Ctrl+b', QWebPage.ToggleBold), ('Ctrl+i', QWebPage.ToggleItalic), ('Ctrl+u', QWebPage.ToggleUnderline), ('Ctrl+Shift+b', QWebPage.InsertUnorderedList), ('Ctrl+Shift+o', QWebPage.InsertOrderedList), ('Ctrl+Shift+v', QWebPage.PasteAndMatchStyle), ('Ctrl+k', self.link_action), ('Ctrl+Shift+k', self.change_link), ('Ctrl+l', QWebPage.AlignLeft), ('Ctrl+r', QWebPage.AlignRight), ('Ctrl+e', QWebPage.AlignCenter), ('Ctrl+j', QWebPage.AlignJustified), ('Ctrl+t', QWebPage.ToggleStrikethrough), ('Ctrl+Space', QWebPage.RemoveFormat), ('Ctrl+Shift+c', self.check_action), ): QShortcut( QKeySequence(self.app.tr(key)), self.widget, ).activated.connect(Slot()(partial(self._action_for_key, action)), )
def createConnections(self): QShortcut(QKeySequence(Qt.CTRL + Qt.Key_T), self, self.state.viewAllPanel.gotoLineEdit.setFocus) self.state.viewAllPanel.view.selectedEidChanged.connect( self.state.updateUi) self.state.viewAllPanel.view.circledEidChanged.connect( self.state.updateUi) self.state.viewAllPanel.view.refreshed.connect( self.modifyActions.updateUi) self.state.viewFilteredPanel.view.refreshed.connect( self.entryActions.updateUi) self.state.viewFilteredPanel.view.refreshed.connect( self.modifyActions.updateUi) self.state.viewFilteredPanel.view.refreshed.connect( self.updateFilteredGotoActions) self.state.viewFilteredPanel.view.refreshed.connect( self.state.replacePanel.updateUi) self.state.model.changed.connect(self.state.updateUi) self.state.model.edited.connect(self.state.refreshEntry) self.state.model.can_undo.connect(self.indexActions.updateUndo) self.state.model.can_redo.connect(self.indexActions.updateRedo) self.state.model.group_changed.connect( self.state.groupsPanel.updateGroups) self.workTimer.timeout.connect(self.updateWorkTime) self.editActions.connectEditors() self.state.entryPanel.xrefList.itemDoubleClicked.connect( self.gotoActions.gotoXRef) self.state.entryPanel.xrefList.currentRowChanged.connect( self.updateXRefGotoActions) self.gotoToolBar4.orientationChanged.connect( self.gotoToolBar4.setOrientation) self.gotoToolBar4.clicked.connect(self.gotoActions.gotoPrefix) for menu in self.menuBar().findChildren(QMenu): for action in menu.actions(): if bool(action.toolTip()): action.hovered.connect( lambda action=action: self.menuHovered(action))
def assign_shortcuts(self): """assigns the shortcuts""" QShortcut(QKeySequence(settings.custom_shortcut['key_tabs_inventory']), self.mainwindow.mainwindow, lambda: self.goto_widget('event', 0)) QShortcut(QKeySequence(settings.custom_shortcut['key_tabs_billing']), self.mainwindow.mainwindow, lambda: self.goto_widget('event', 1)) QShortcut(QKeySequence(settings.custom_shortcut['key_tabs_menu']), self.mainwindow.mainwindow, lambda: self.goto_widget('event', 3)) QShortcut(QKeySequence(settings.custom_shortcut['key_tabs_employee']), self.mainwindow.mainwindow, lambda: self.goto_widget('event', 2)) QShortcut(QKeySequence(settings.custom_shortcut['key_tabs_report']), self.mainwindow.mainwindow, lambda: self.goto_widget('event', 4)) QShortcut(QKeySequence(settings.custom_shortcut['key_tabs_waste']), self.mainwindow.mainwindow, lambda: self.goto_widget('event', 5))
def init_shortcuts(self): self.save_btn.setShortcut(QKeySequence('Ctrl+s')) self.close_btn.setShortcut(QKeySequence('Ctrl+q')) self.email_btn.setShortcut(QKeySequence('Ctrl+Shift+e')) self.print_btn.setShortcut(QKeySequence(self.tr('Ctrl+p'))) QShortcut(QKeySequence(self.tr('Ctrl+w')), self, self.save_and_close)
def prepareModalDialog(self): self.setWindowModality(Qt.WindowModal) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) QShortcut(QKeySequence(QKeySequence.HelpContents), self, self.help)
def __add_delete_shortcut(widget, callback): shortcut = QShortcut(QKeySequence.Delete, widget) shortcut.setContext(Qt.WidgetWithChildrenShortcut) shortcut.activated.connect(callback)