Python PyQt5.QtCore.Qt.AltModifier() Examples

The following are 7 code examples of PyQt5.QtCore.Qt.AltModifier(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtCore.Qt , or try the search function .
Example #1
Source File: webelem.py    From qutebrowser with GNU General Public License v3.0 8 votes vote down vote up
def _click_fake_event(self, click_target: usertypes.ClickTarget,
                          button: Qt.MouseButton = Qt.LeftButton) -> None:
        """Send a fake click event to the element."""
        pos = self._mouse_pos()

        log.webelem.debug("Sending fake click to {!r} at position {} with "
                          "target {}".format(self, pos, click_target))

        target_modifiers = {
            usertypes.ClickTarget.normal: Qt.NoModifier,
            usertypes.ClickTarget.window: Qt.AltModifier | Qt.ShiftModifier,
            usertypes.ClickTarget.tab: Qt.ControlModifier,
            usertypes.ClickTarget.tab_bg: Qt.ControlModifier,
        }
        if config.val.tabs.background:
            target_modifiers[usertypes.ClickTarget.tab] |= Qt.ShiftModifier
        else:
            target_modifiers[usertypes.ClickTarget.tab_bg] |= Qt.ShiftModifier

        modifiers = typing.cast(Qt.KeyboardModifiers,
                                target_modifiers[click_target])

        events = [
            QMouseEvent(QEvent.MouseMove, pos, Qt.NoButton, Qt.NoButton,
                        Qt.NoModifier),
            QMouseEvent(QEvent.MouseButtonPress, pos, button, button,
                        modifiers),
            QMouseEvent(QEvent.MouseButtonRelease, pos, button, Qt.NoButton,
                        modifiers),
        ]

        for evt in events:
            self._tab.send_event(evt)

        QTimer.singleShot(0, self._move_text_cursor) 
Example #2
Source File: qcheckcombobox.py    From artisan with GNU General Public License v3.0 7 votes vote down vote up
def keyPressEvent(self, event):
        """Reimplemented."""
        # Override the default QComboBox behavior
        if event.key() == Qt.Key_Down and event.modifiers() & Qt.AltModifier:
            self.showPopup()
            return

        ignored = {Qt.Key_Up, Qt.Key_Down,
                   Qt.Key_PageDown, Qt.Key_PageUp,
                   Qt.Key_Home, Qt.Key_End}

        if event.key() in ignored:
            event.ignore()
            return

        super(CheckComboBox, self).keyPressEvent(event) 
Example #3
Source File: qt_helper.py    From uPyLoader with MIT License 5 votes vote down vote up
def key_event_sequence(event):
        val = event.key()
        mod = event.modifiers()
        if mod & Qt.ShiftModifier:
            val += Qt.SHIFT
        if mod & Qt.ControlModifier:
            val += Qt.CTRL
        if mod & Qt.AltModifier:
            val += Qt.ALT
        if mod & Qt.MetaModifier:
            val += Qt.META
        return QKeySequence(val) 
Example #4
Source File: layout.py    From linux-show-player with GNU General Public License v3.0 5 votes vote down vote up
def onKeyPressEvent(self, e):
        if not e.isAutoRepeat():
            keys = e.key()
            modifiers = e.modifiers()

            if modifiers & Qt.ShiftModifier:
                keys += Qt.SHIFT
            if modifiers & Qt.ControlModifier:
                keys += Qt.CTRL
            if modifiers & Qt.AltModifier:
                keys += Qt.ALT
            if modifiers & Qt.MetaModifier:
                keys += Qt.META

            if QKeySequence(keys) in self._go_key_sequence:
                self.go()
            elif e.key() == Qt.Key_Space:
                if qApp.keyboardModifiers() == Qt.ShiftModifier:
                    cue = self.current_cue()
                    if cue is not None:
                        self.edit_cue(cue)
                elif qApp.keyboardModifiers() == Qt.ControlModifier:
                    item = self.current_item()
                    if item is not None:
                        item.selected = not item.selected
            else:
                self.key_pressed.emit(e)

        e.accept() 
Example #5
Source File: controller.py    From artisan with GNU General Public License v3.0 5 votes vote down vote up
def toggle(app_window):
    config.logger.info("controller:toggle()")
    config.app_window = app_window
    modifiers = QApplication.keyboardModifiers()
    if modifiers == Qt.AltModifier:
        # ALT-click (OPTION on macOS) sends the log file by email
        util.sendLog()
    elif modifiers == (Qt.AltModifier | Qt.ControlModifier):
        # ALT+CTR-CLICK (OPTION+COMMAND on macOS) toggles the plus debug logging 
        util.debugLogToggle()
    else:
        if config.app_window.plus_account is None: # @UndefinedVariable
            connect()
            if is_connected() and is_synced() and config.app_window.curFile is not None: # @UndefinedVariable
                sync.sync()         
        else:
            if config.connected:
                if is_synced():
                    # a CTR-click (COMMAND on macOS) logs out and discards the credentials
                    disconnect(interactive=True,remove_credentials=(modifiers == Qt.ControlModifier))
                else:
                    # we (manually) turn syncing for the current roast on
                    if app_window.qmc.checkSaved(allow_discard=False):
                        queue.addRoast()
            else:
                connect(True) # we try to re-connect and disconnect on failure 
Example #6
Source File: roast_properties.py    From artisan with GNU General Public License v3.0 5 votes vote down vote up
def copyEventTabletoClipboard(self,_=False):
        nrows = self.eventtable.rowCount() 
        ncols = self.eventtable.columnCount()
        clipboard = ""
        modifiers = QApplication.keyboardModifiers()
        if modifiers == Qt.AltModifier:  #alt click
            tbl = prettytable.PrettyTable()
            fields = []
            for c in range(ncols):
                fields.append(self.eventtable.horizontalHeaderItem(c).text())
            tbl.field_names = fields
            for i in range(nrows):
                rows = []
                rows.append(self.eventtable.cellWidget(i,0).text())
                rows.append(self.eventtable.cellWidget(i,1).text())
                rows.append(self.eventtable.cellWidget(i,2).text())
                rows.append(self.eventtable.cellWidget(i,3).text())
                rows.append(self.eventtable.cellWidget(i,4).currentText())
                rows.append(self.eventtable.cellWidget(i,5).text())
                tbl.add_row(rows)
            clipboard = tbl.get_string()
        else:
            for c in range(ncols):
                clipboard += self.eventtable.horizontalHeaderItem(c).text()
                if c != (ncols-1):
                    clipboard += '\t'
            clipboard += '\n'
            for r in range(nrows):
                clipboard += self.eventtable.cellWidget(r,0).text() + "\t"
                clipboard += self.eventtable.cellWidget(r,1).text() + "\t"
                clipboard += self.eventtable.cellWidget(r,2).text() + "\t"
                clipboard += self.eventtable.cellWidget(r,3).text() + "\t"
                clipboard += self.eventtable.cellWidget(r,4).currentText() + "\t"
                clipboard += self.eventtable.cellWidget(r,5).text() + "\n"
        # copy to the system clipboard
        sys_clip = QApplication.clipboard()
        sys_clip.setText(clipboard)
        self.aw.sendmessage(QApplication.translate("Message","Event table copied to clipboard",None)) 
Example #7
Source File: console.py    From bluesky with GNU General Public License v3.0 4 votes vote down vote up
def keyPressEvent(self, event):
        ''' Handle keyboard input for bluesky. '''
        # Enter-key: enter command
        if event.key() == Qt.Key_Enter or event.key() == Qt.Key_Return:
            if self.command_line:
                # emit a signal with the command for the simulation thread
                self.stack(self.command_line)
                # Clear any shape command preview on the radar display
                # self.radarwidget.previewpoly(None)
                return

        newcmd = self.command_line
        cursorpos = None
        if event.key() >= Qt.Key_Space and event.key() <= Qt.Key_AsciiTilde:
            pos = self.lineEdit.cursor_pos()
            newcmd = newcmd[:pos] + event.text() + newcmd[pos:]
            # Update the cursor position with the length of the added text
            cursorpos = pos + len(event.text())
        elif event.key() == Qt.Key_Backspace:
            pos = self.lineEdit.cursor_pos()
            newcmd = newcmd[:pos - 1] + newcmd[pos:]
            cursorpos = pos - 1
        elif event.key() == Qt.Key_Tab:
            if newcmd:
                newcmd, displaytext = autocomplete.complete(newcmd)
                if displaytext:
                    self.echo(displaytext)
        elif not event.modifiers() & (Qt.ControlModifier | Qt.ShiftModifier | 
                                        Qt.AltModifier | Qt.MetaModifier):
            if event.key() == Qt.Key_Up:
                if self.history_pos == 0:
                    self.command_mem = newcmd
                if len(self.command_history) >= self.history_pos + 1:
                    self.history_pos += 1
                    newcmd = self.command_history[-self.history_pos]

            elif event.key() == Qt.Key_Down:
                if self.history_pos > 0:
                    self.history_pos -= 1
                    if self.history_pos == 0:
                        newcmd = self.command_mem
                    else:
                        newcmd = self.command_history[-self.history_pos]

            elif event.key() == Qt.Key_Left:
                self.lineEdit.cursor_left()

            elif event.key() == Qt.Key_Right:
                self.lineEdit.cursor_right()
            else:
                # Remaining keys are things like sole modifier keys, and function keys
                super(Console, self).keyPressEvent(event)
        else:
            event.ignore()
            return

        # Final processing of the command line
        self.set_cmdline(newcmd, cursorpos)