示例#1
0
    def addTargetActions(self, menu: QMenu):
        selected_items = [
            i.text() for i in self.list_input_files.selectedItems()
        ]
        selected_items += [
            self.currentOutputList[i.row()]
            for i in self.currentOutputListView.selectedIndexes()
        ]

        menu.addSeparator()
        # cannot use default arg to force coping the type here, since the signal also provides other inputs
        func_create = lambda _t, items: lambda: self.currentOutputList.appendTarget(
            _t(items))
        for t in target_types:
            if t.validate(selected_items):
                create_action = QAction(t.description, menu)
                create_action.triggered.connect(func_create(t, selected_items))
                menu.addAction(create_action)

        menu.addSeparator()
        func_create_batch = lambda _t, items: lambda: self.currentOutputList.extendTargets(
            [_t(i) for i in items])
        for t in target_types:
            if all(t.validate([item]) for item in selected_items):
                create_action = QAction("Batch " + t.description, menu)
                create_action.triggered.connect(
                    func_create_batch(t, selected_items))
                menu.addAction(create_action)
 def _handle_tab_context_menu(self, point):
     index = self.tabBar().tabAt(point)
     if index < 0:
         return
     tab_count = len(self._webengineviews)
     context_menu = QMenu()
     duplicate_tab_action = context_menu.addAction("Duplicate Tab")
     close_other_tabs_action = context_menu.addAction("Close Other Tabs")
     close_other_tabs_action.setEnabled(tab_count > 1)
     close_tabs_to_the_right_action = context_menu.addAction("Close Tabs to the Right")
     close_tabs_to_the_right_action.setEnabled(index < tab_count - 1)
     close_tab_action = context_menu.addAction("&Close Tab")
     chosen_action = context_menu.exec_(self.tabBar().mapToGlobal(point))
     if chosen_action == duplicate_tab_action:
         current_url = self.url()
         self.add_browser_tab().load(current_url)
     elif chosen_action == close_other_tabs_action:
         for t in range(tab_count - 1, -1, -1):
             if t != index:
                 self.handle_tab_close_request(t)
     elif chosen_action == close_tabs_to_the_right_action:
         for t in range(tab_count - 1, index, -1):
             self.handle_tab_close_request(t)
     elif chosen_action == close_tab_action:
         self.handle_tab_close_request(index)
示例#3
0
    def _setup_difficulties_menu(self, game: RandovaniaGame,
                                 menu: QtWidgets.QMenu):
        from randovania.game_description import default_database
        game = default_database.game_description_for(game)
        tricks_in_use = used_tricks(game)

        menu.clear()
        for trick in sorted(game.resource_database.trick,
                            key=lambda _trick: _trick.long_name):
            if trick not in tricks_in_use:
                continue

            trick_menu = QtWidgets.QMenu(self)
            trick_menu.setTitle(_t(trick.long_name))
            menu.addAction(trick_menu.menuAction())

            used_difficulties = difficulties_for_trick(game, trick)
            for trick_level in enum_lib.iterate_enum(LayoutTrickLevel):
                if trick_level in used_difficulties:
                    difficulty_action = QtGui.QAction(self)
                    difficulty_action.setText(trick_level.long_name)
                    trick_menu.addAction(difficulty_action)
                    difficulty_action.triggered.connect(
                        functools.partial(self._open_trick_details_popup, game,
                                          trick, trick_level))
示例#4
0
    def show_tray(self):
        if QSystemTrayIcon.isSystemTrayAvailable:
            # create tray menu
            traymenu = QMenu('AyoShalat', self)
            openwin_menu = traymenu.addAction('Show me!')
            openwin_menu.triggered.connect(self.show)

            playazan_menu = traymenu.addAction('Play Azan')
            playazan_menu.triggered.connect(self.playAzan)
            
            stop_azan_menu = traymenu.addAction('Stop Azan')
            stop_azan_menu.triggered.connect(self.stopAzan)

            traymenu.addSeparator()

            exit_menu = traymenu.addAction('Exit')
            exit_menu.triggered.connect(self.exit)

            # create tray icon
            qtray = QSystemTrayIcon(self)

            qtray.setIcon(QIcon(self.icopath))
            qtray.setVisible(True)
            qtray.setContextMenu(traymenu)
            qtray.show()
示例#5
0
class TableWidget(QTableWidget):
    def __init__(self, parent: Optional[QWidget] = None) -> None:
        super().__init__(parent)
        self._context_menu = QMenu(self)
        self._copy_table_action = self._context_menu.addAction('Copy table to clipboard',
                                                               self._copyTableActionTriggered)
        self._copy_row_action = self._context_menu.addAction('Copy row to clipboard',
                                                             self._copyRowActionTriggered)
        self.addActions((self._copy_table_action, self._copy_row_action))

    def contextMenuEvent(self, event: QEvent) -> None:
        self._copy_table_action.setEnabled(bool(self.rowCount()))
        self._copy_row_action.setEnabled(bool(self.selectedItems()))
        self._context_menu.exec_(self.viewport().mapToGlobal(event.pos()))

    def _copyRowsToClipboard(self, rows: Iterable[int]) -> None:
        if not rows or not self.columnCount():
            return

        rows_text = ['\t'.join(self.model().headerData(column, Qt.Horizontal) for column in range(self.columnCount()))]

        for row in rows:
            rows_text.append('\t'.join(self.item(row, column).text() for column in range(self.columnCount())))

        QApplication.clipboard().setText('\n'.join(rows_text))

    def _copyTableActionTriggered(self) -> None:
        self._copyRowsToClipboard(tuple(range(self.rowCount())))

    def _copyRowActionTriggered(self) -> None:
        selected_rows = sorted({self.row(selected_item) for selected_item in self.selectedItems()})
        self._copyRowsToClipboard(selected_rows)
 def create_upload_nintendont_action(self, menu: QtWidgets.QMenu):
     self.upload_nintendont_action = QtGui.QAction(menu)
     self.upload_nintendont_action.setText(
         "Upload Nintendont to Homebrew Channel")
     self.upload_nintendont_action.triggered.connect(
         self.on_upload_nintendont_action)
     menu.addAction(self.upload_nintendont_action)
示例#7
0
文件: main.py 项目: KDAB/KDChart
 def slotHeaderMenu(self, pt):
     menu = QMenu()
     menu.addAction("This")
     menu.addAction("is")
     menu.addAction("just")
     menu.addAction("a")
     menu.addAction("test")
     menu.exec_(pt)
示例#8
0
    def showContextMenu(self, pos):
        if not self.ui.ganttView.leftView().indexAt(pos).isValid():
            self.ui.ganttView.selectionModel().clearSelection()

        menu = QMenu(self.ui.ganttView.leftView())
        menu.addAction(self.newEntryAction)
        menu.addAction(self.removeEntryAction)
        menu.exec_(self.ui.ganttView.leftView().viewport().mapToGlobal(pos))
示例#9
0
 def contextMenuEvent(self, e):
     context = QMenu(self)
     crap = QAction("thisone", self)
     crap.triggered.connect(self.fuckthisshit)
     context.addAction(crap)
     context.addAction(QAction("test 2", self))
     context.addAction(QAction("test 3", self))
     context.exec_(e.globalPos())
示例#10
0
    def inputContextMenu(self, pos: QPoint):
        menu = QMenu()
        preview_action = QAction("Preview", menu)
        preview_action.triggered.connect(
            lambda: self.previewInput(self.list_input_files.currentItem()))
        menu.addAction(preview_action)

        self.addTargetActions(menu)
        action = menu.exec_(self.list_input_files.mapToGlobal(pos))
示例#11
0
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        if not MainWindow.objectName():
            MainWindow.setObjectName(u"MainWindow")
        MainWindow.resize(353, 223)
        self.actionsetting = QAction(MainWindow)
        self.actionsetting.setObjectName(u"actionsetting")
        self.actionabout = QAction(MainWindow)
        self.actionabout.setObjectName(u"actionabout")
        self.actionimg_convert = QAction(MainWindow)
        self.actionimg_convert.setObjectName(u"actionimg_convert")
        self.centralwidget = QWidget(MainWindow)
        self.centralwidget.setObjectName(u"centralwidget")
        self.gridLayout_4 = QGridLayout(self.centralwidget)
        self.gridLayout_4.setObjectName(u"gridLayout_4")
        self.gridLayout_3 = QGridLayout()
        self.gridLayout_3.setObjectName(u"gridLayout_3")
        self.stackedWidget = QStackedWidget(self.centralwidget)
        self.stackedWidget.setObjectName(u"stackedWidget")
        self.stackedWidget.setMinimumSize(QSize(0, 0))

        self.gridLayout_3.addWidget(self.stackedWidget, 0, 0, 1, 1)


        self.gridLayout_4.addLayout(self.gridLayout_3, 0, 0, 1, 1)

        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QMenuBar(MainWindow)
        self.menubar.setObjectName(u"menubar")
        self.menubar.setGeometry(QRect(0, 0, 353, 22))
        self.menuabout = QMenu(self.menubar)
        self.menuabout.setObjectName(u"menuabout")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(MainWindow)
        self.statusbar.setObjectName(u"statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.menubar.addAction(self.menuabout.menuAction())
        self.menuabout.addAction(self.actionabout)

        self.retranslateUi(MainWindow)

        self.stackedWidget.setCurrentIndex(-1)


        QMetaObject.connectSlotsByName(MainWindow)
    # setupUi

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"Waifu2x-GUI", None))
        self.actionsetting.setText(QCoreApplication.translate("MainWindow", u"setting", None))
        self.actionabout.setText(QCoreApplication.translate("MainWindow", u"about", None))
        self.actionimg_convert.setText(QCoreApplication.translate("MainWindow", u"img convert", None))
        self.menuabout.setTitle(QCoreApplication.translate("MainWindow", u"\u5de5\u5177", None))
示例#12
0
 def populate(self) -> None:
     for menu_name in self._my_sorted(self.d.keys()):
         subreddit_list = self.d[menu_name]
         menu = QMenu(self.root_menu)
         menu.setTitle(menu_name)
         self.root_menu.addMenu(menu)
         for subreddit in self._my_sorted(subreddit_list):
             act = QAction(subreddit, self.parent)
             act.triggered.connect(
                 partial(self.open_subreddit_fn, subreddit))
             menu.addAction(act)
示例#13
0
    def menu_button(self):
        sleep_btn = QPushButton('Sleep Button', self)
        # sleep_btn = QPushButton('&Sleep Button', self)  # Alt + S
        sleep_btn.setToolTip('This is a menu')
        sleep_btn.resize(sleep_btn.sizeHint())
        sleep_btn.move(200, 50)

        menu = QMenu("kek", self)
        menu.addAction(self.new_action('1', shortcut="Ctrl+A"))
        menu.addAction(self.new_action('2'))

        sleep_btn.setMenu(menu)
示例#14
0
    def create_tray_icon(self):
        tray_icon = QSystemTrayIcon(QIcon(str(pkg_data.LOGO)))
        tray_icon.activated.connect(self.tray_icon_clicked)

        menu = QMenu(self)
        open_action = menu.addAction("Open")
        open_action.triggered.connect(self.show_window)
        menu.addSeparator()
        menu.addAction(self.action_exit)

        tray_icon.setContextMenu(menu)
        return tray_icon
示例#15
0
 def context_menu_event(self, event):
     context_menu = QMenu()
     open_in_new_tab_action = context_menu.addAction("Open in New Tab")
     remove_action = context_menu.addAction("Remove...")
     current_item = self._current_item()
     open_in_new_tab_action.setEnabled(current_item is not None)
     remove_action.setEnabled(current_item is not None)
     chosen_action = context_menu.exec_(event.globalPos())
     if chosen_action == open_in_new_tab_action:
         self.open_bookmarkInNewTab.emit(current_item.data(_url_role))
     elif chosen_action == remove_action:
         self._remove_item(current_item)
示例#16
0
 def add_menu(self, title, actions):
     menu = QMenu()
     menu.setTitle(title)
     for item in actions:
         icon, name, key, callback = item
         action = QAction(QIcon(icon), name, self)
         if key:
             action.setShortcut(key)
         if callback:
             action.triggered.connect(callback)
         menu.addAction(action)
     self.menuBar().addMenu(menu)
示例#17
0
    def __init__(self, parent=None):
        QSystemTrayIcon.__init__(self, QIcon(resource_path("icons/logo.png")), parent)
        self.setVisible(True)
        self.setToolTip("SSD: Zextras Drive Desktop")

        menu = QMenu()
        self.show_option = QAction("Mostra")
        self.exit_option = QAction("Esci")

        menu.addAction(self.show_option)
        menu.addAction(self.exit_option)

        self.setContextMenu(menu)
示例#18
0
文件: holdings.py 项目: flmnvd/jal
 def onHoldingsContextMenu(self, pos):
     index = self.HoldingsTableView.indexAt(pos)
     contextMenu = QMenu(self.HoldingsTableView)
     actionShowChart = QAction(text=self.tr("Show Price Chart"),
                               parent=self.HoldingsTableView)
     actionShowChart.triggered.connect(partial(self.showPriceChart, index))
     contextMenu.addAction(actionShowChart)
     actionEstimateTax = QAction(text=self.tr("Estimate Russian Tax"),
                                 parent=self.HoldingsTableView)
     actionEstimateTax.triggered.connect(
         partial(self.estimateRussianTax, index))
     contextMenu.addAction(actionEstimateTax)
     contextMenu.popup(self.HoldingsTableView.viewport().mapToGlobal(pos))
示例#19
0
    def on_context_menu(self, pos: QPoint):
        index = self.indexAt(pos)
        menu = QMenu(self)

        meta_action = menu.addAction("View metadata")
        meta_action.triggered.connect(
            lambda chk=False, index=index: self.show_metadata_menu(index))

        remove_action = menu.addAction("Remove")
        remove_action.setShortcut(QKeySequence(QKeySequence.Delete))
        remove_action.triggered.connect(self.remove_selected_items)

        menu.popup(self.viewport().mapToGlobal(pos))
示例#20
0
    def eventFilter(self, source, event):
        if(event.type() == QtCore.QEvent.MouseButtonPress and
           event.buttons() == QtCore.Qt.RightButton and
           source is self.ui.table.viewport()):

            item = self.ui.table.itemAt(event.position().toPoint())
            if item is not None:
                menu = QMenu()
                menu.addAction('Copy password',lambda: self.copy(item.row()))
                menu.addAction('Add new',lambda: self.ui.stacked_wid.setCurrentIndex(3))
                menu.exec(event.globalPosition().toPoint())

        return super().eventFilter(source,event)
示例#21
0
    def constructContextMenu(self, position):
        globalPosition = self.mapToGlobal(position)

        menu = QMenu()

        optionsEntry = QAction('Options', menu)
        optionsEntry.setData(self.openOptions)

        def rotate():
            mousePosition = QCursor.pos()

            self.rotate(mousePosition)

        rotateEntry = QAction('Rotate', menu)
        rotateEntry.setData(rotate)

        aboutEntry = QAction('About', menu)
        aboutEntry.setData(self.openAbout)

        quitEntry = QAction('Close', menu)
        quitEntry.setData(self.quit)

        menu.addAction(optionsEntry)
        menu.addAction(rotateEntry)
        menu.addAction(aboutEntry)
        menu.addAction(quitEntry)

        selectedItem = menu.exec_(globalPosition)
        """:type : QAction"""

        if selectedItem:
            selectedItem.data()()
示例#22
0
class TrayIcon(QSystemTrayIcon):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.caps_ico = resource_path(os.path.join('ico', 'caps.ico'))
        self.small_ico = resource_path(os.path.join('ico', 'small.ico'))
        self.setIcon(QIcon(self.small_ico))
        self.showMenu()
        self.activated.connect(self.iconClied)
        self.check_caps_status()

    def showMenu(self):
        self.menu = QMenu()
        self.quitAction = QAction("退出", self, triggered=self.quit)

        self.menu.addAction(self.quitAction)
        self.setContextMenu(self.menu)

    def check_caps_status(self):
        self.check_thread = check_caps_status_work()

        def set_icon(status):
            if status == 'caps':
                self.setIcon(QIcon(self.caps_ico))
                self.setToolTip('大写')
            else:
                self.setIcon(QIcon(self.small_ico))
                self.setToolTip('小写')

        self.check_thread.signal.connect(set_icon)
        self.check_thread.start()

    def iconClied(self, reason):
        k = keyboard.Controller()
        if reason in (
                PySide6.QtWidgets.QSystemTrayIcon.ActivationReason.Trigger,
                PySide6.QtWidgets.QSystemTrayIcon.ActivationReason.DoubleClick
        ):
            k.press(keyboard.Key.caps_lock)
            k.release(keyboard.Key.caps_lock)

    def quit(self):
        self.setVisible(False)
        if 'check_thread' in dir(self):
            self.check_thread.stop()
        QApplication.quit()
        sys.exit()
示例#23
0
    def _createMenuBar(self):

        # Settings and stuff for the toolbar
        menubar = QMenuBar(self)

        file_menu = QMenu("&File", self)
        file_menu.addAction("Create Team(s)", self.CreateTeamsWindow)
        file_menu.addAction("Edit Team(s)", self.EditTeamsWindow)
        file_menu.addAction("Exit", self.close)
        settings_menu = QMenu("&Settings", self)
        settings_menu.addAction("Version", self.SeeVersion)
        settings_menu.addAction("Help", self.GetHelp)

        menubar.addMenu(file_menu)
        menubar.addMenu(settings_menu)

        self.setMenuBar(menubar)
示例#24
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()
示例#25
0
 def onDataViewContextMenu(self, pos):
     if not self.group_id:
         return
     index = self.DataView.indexAt(pos)
     menu_title = QWidgetAction(self.DataView)
     title_lbl = QLabel()
     title_lbl.setText(self.tr("Change type to:"))
     menu_title.setDefaultWidget(title_lbl)
     contextMenu = QMenu(self.DataView)
     contextMenu.addAction(menu_title)
     contextMenu.addSeparator()
     combo_model = self.GroupCombo.model()
     for i in range(self.GroupCombo.count()):
         type_id = combo_model.data(
             combo_model.index(
                 i, combo_model.fieldIndex(self.group_fkey_field)))
         contextMenu.addAction(self.GroupCombo.itemText(i),
                               partial(self.updateItemType, index, type_id))
     contextMenu.popup(self.DataView.viewport().mapToGlobal(pos))
    def contextMenuEvent(self, event) -> None:
        context_menu = QMenu(self)
        file_is_synced = self.settings_model.is_id_in_sync_list(self.id)

        # se il file non è syncato mostra aggiungi, altrimenti mostra rimuovi
        if file_is_synced is False:
            add_sync_action = context_menu.addAction("Aggiungi a sync")
        else:
            remove_sync_action = context_menu.addAction("Rimuovi da sync")

        # selezione voci menu
        if file_is_synced is False:
            action = context_menu.exec(self.mapToGlobal(event.pos()))
            if action == add_sync_action:
                self.Sg_add_sync_file.emit(self.id)
        else:
            action = context_menu.exec(self.mapToGlobal(event.pos()))
            if action == remove_sync_action:
                self.Sg_remove_sync_file.emit(self.id)
示例#27
0
 def populate(self) -> None:
     for category_name in self._my_sorted(self.d.keys()):
         url_list = self.d[category_name]
         menu = QMenu(self.root_menu)
         menu.setToolTipsVisible(True)
         menu.setTitle(category_name)
         self.root_menu.addMenu(menu)
         for entry in self._my_sorted(url_list):
             result = self.extract_parts(entry)
             if result:
                 description, link = result
                 act = QAction(description, self.parent)
                 act.setToolTip(link)
                 act.triggered.connect(partial(self.open_new_browser_tab_fn, link))
                 menu.addAction(act)
             else:
                 if re.search(r"^-{3,}$", entry):    # "---" (with length >= 3) is a separator
                     menu.addSeparator()
                 else:
                     log.warning(f"couldn't parse the bookmark line '{entry}'")
示例#28
0
    def context_menu(self):
        """Add context menu triggered by right click

        The two purpose is to delete the column
        and change tile color
        """

        menu = QMenu(self)

        for color_name in TILE_STYLE:
            label = QLabel(color_name, self)

            label.setStyleSheet(MENU_STYLE[color_name])
            action = QWidgetAction(self)
            action.setDefaultWidget(label)
            action.triggered.connect(
                partial(self.color_change, color=color_name))
            menu.addAction(action)

        return menu
示例#29
0
    def outputContextMenu(self, listview: QListView, pos: QPoint):
        current_model = listview.model()
        menu = QMenu()
        edit_action = QAction(
            "Edit clicked" if len(listview.selectedIndexes()) > 1 else "Edit",
            menu)
        edit_action.triggered.connect(self.editCurrentTarget)
        menu.addAction(edit_action)

        delete_action = QAction("Remove", menu)
        delete_action.triggered.connect(lambda: current_model.__delitem__(
            [i.row() for i in listview.selectedIndexes()]))
        menu.addAction(delete_action)

        selected_istemp = current_model[
            listview.currentIndex().row()].temporary
        mark_temp_action = QAction("Mark temp", menu)
        mark_temp_action.setCheckable(True)
        mark_temp_action.setChecked(selected_istemp)
        mark_temp_action.triggered.connect(lambda: [
            current_model[i.row()].switch_temporary(not selected_istemp)
            for i in listview.selectedIndexes()
        ])
        menu.addAction(mark_temp_action)

        self.addTargetActions(menu)
        menu.exec_(listview.mapToGlobal(pos))
示例#30
0
    def contextMenuEvent(self, event):
        state = self.state()
        context_menu = QMenu()
        launch_action = context_menu.addAction("Launch")
        launch_action.setEnabled(state == QWebEngineDownloadItem.DownloadCompleted)
        show_in_folder_action = context_menu.addAction("Show in Folder")
        show_in_folder_action.setEnabled(state == QWebEngineDownloadItem.DownloadCompleted)
        cancel_action = context_menu.addAction("Cancel")
        cancel_action.setEnabled(state == QWebEngineDownloadItem.DownloadInProgress)
        remove_action = context_menu.addAction("Remove")
        remove_action.setEnabled(state != QWebEngineDownloadItem.DownloadInProgress)

        chosen_action = context_menu.exec_(event.globalPos())
        if chosen_action == launch_action:
            self._launch()
        elif chosen_action == show_in_folder_action:
            path = QFileInfo(self._download_item.path()).absolutePath()
            DownloadWidget.open_file(path)
        elif chosen_action == cancel_action:
            self._download_item.cancel()
        elif chosen_action == remove_action:
            self.remove_requested.emit()