Exemplo n.º 1
0
    def mousePressEvent(self, event):

        self.old_position = event.globalPos()

        button = event.button()

        if button == Qt.MiddleButton:
            self.rotate(QCursor.pos())
 def help_on_current_widget(self):
     """Display help on widget under mouse"""
     w = QApplication.widgetAt(QCursor.pos(self.screen()))
     while w:  # Skip over internal widgets
         name = w.objectName()
         if name and not name.startswith("qt_"):
             launch_help(w)
             break
         w = w.parentWidget()
Exemplo n.º 3
0
    def keyPressEvent(self, event):

        key = event.key()
        modifiers = event.modifiers()

        if key == Qt.Key_O and modifiers == Qt.AltModifier:
            self.openOptions()

        elif key == Qt.Key_R and modifiers == Qt.AltModifier:
            self.rotate(QCursor.pos())
Exemplo n.º 4
0
    def moveWindow(self, event):
        """ Window is dragged with the top bar """
        if event.buttons() == Qt.LeftButton:
            # maximized > restore to drag
            if self.isMaximized is True:
                self.maximize_restore()
                p = self.setMousetoTitleBar()
                self.dragPos = QCursor.pos()

            p = self.getGlobalPosition(event)
            self.window.move(self.window.pos() + p - self.dragPos)
            self.dragPos = p
            event.accept()
Exemplo n.º 5
0
 def _getPixelRatio():
     if PyQtImpl in ["PyQt5", "PySide2", "PySide6"]:
         # Source: https://stackoverflow.com/a/40053864/3388962
         pos = QCursor.pos()
         for screen in QApplication.screens():
             rect = screen.geometry()
             if rect.contains(pos):
                 return screen.devicePixelRatio()
         # Should never happen, but try to find a good fallback.
         return QApplication.instance().devicePixelRatio()
     else:
         # Qt4 seems not to provide any cross-platform means to get the
         # pixel ratio.
         return 1.
Exemplo n.º 6
0
    def context_menu(self, point):

        selected = self.keyListView.selectedIndexes()
        if not selected:
            return

        index = selected[0]
        item = self.list_model.item(index.row())
        key = item.data()

        pop_menu = QMenu()

        _set_default_key_action = pop_menu.addAction(
            qta.icon('fa.check',
                     color=icon_color['color'],
                     color_active=icon_color['active']), '设为默认')
        if key_cache.is_cur_key(key) or key.timeout:
            _set_default_key_action.setEnabled(False)

        pop_menu.addSeparator()
        _encrypt_files_action = pop_menu.addAction(
            qta.icon('ei.lock',
                     color=icon_color['color'],
                     color_active=icon_color['active']), "加密文件")
        _decrypt_files_action = pop_menu.addAction(
            qta.icon('ei.unlock',
                     color=icon_color['color'],
                     color_active=icon_color['active']), "解密文件")
        pop_menu.addSeparator()

        _reload_key_action = pop_menu.addAction(
            qta.icon('fa.refresh',
                     color=icon_color['color'],
                     color_active=icon_color['active']), "重新加载")
        _reload_key_action.setEnabled(key.timeout)

        selected_action = pop_menu.exec_(QCursor.pos())
        if selected_action == _encrypt_files_action:
            self.encrypt_files_action()
        elif selected_action == _set_default_key_action:
            self.set_default_key_action()
        elif selected_action == _reload_key_action:
            self.reload_key_action()
        elif selected_action == _decrypt_files_action:
            self.decrypt_files_action()
Exemplo n.º 7
0
 def contextMenuEvent(self, event):
     self.category_tree_menu.popup(QCursor.pos())
Exemplo n.º 8
0
 def contextMenuEvent(self, event):
     self.tablewidget_menu.popup(QCursor.pos())
Exemplo n.º 9
0
        def rotate():
            mousePosition = QCursor.pos()

            self.rotate(mousePosition)