Exemple #1
0
    def contextMenuEvent(self, event):
        index = self.indexAt(event.pos())
        item = self.model().get_item(index)
        children = item.child_count()

        if index.column() == KEY_COL and children:
            menu = QMenu(self)
            collapse = menu.addAction('Collapse All')
            expand = menu.addAction('Expand All')
            check = None
            uncheck = None
            if children:
                menu.addSeparator()
                check = menu.addAction('Check All')
                uncheck = menu.addAction('Uncheck All')
            action = menu.exec_(QCursor.pos())

            if action == collapse:
                self.collapse_selection(item, index)
            elif action == expand:
                self.expand_selection(item, index)
            elif action == check:
                self.itemDelegateForColumn(STATUS_COL).setChildData(
                    item, True)
                self.itemDelegateForColumn(STATUS_COL).updateModel(index)
            elif action == uncheck:
                self.itemDelegateForColumn(STATUS_COL).setChildData(
                    item, False)
                self.itemDelegateForColumn(STATUS_COL).updateModel(index)
Exemple #2
0
    def _create_tray_icon(self):
        menu = QMenu()

        self._mode_group = QActionGroup(menu)
        self._mode_group.triggered.connect(self._mode_changed)

        self._mode_off = QAction("&Off", parent=menu)
        self._mode_off.setCheckable(True)
        self._mode_off.setChecked(True)
        self._mode_group.addAction(self._mode_off)
        menu.addAction(self._mode_off)

        self._mode_enabled = QAction("&Enabled", parent=menu)
        self._mode_enabled.setCheckable(True)
        self._mode_group.addAction(self._mode_enabled)
        menu.addAction(self._mode_enabled)

        self._mode_training = QAction("&Training mode", parent=menu)
        self._mode_training.setCheckable(True)
        self._mode_group.addAction(self._mode_training)
        menu.addAction(self._mode_training)

        menu.addSeparator()
        menu.addAction("&Preferences", self.open_preferences)
        menu.addSeparator()
        menu.addAction("E&xit", self.exit)

        pixmap = QPixmap(32, 32)
        pixmap.fill(Qt.white)
        icon = QIcon(pixmap)

        self._tray_icon = QSystemTrayIcon(parent=self)
        self._tray_icon.setContextMenu(menu)
        self._tray_icon.setIcon(icon)
        self._tray_icon.show()
Exemple #3
0
 def _show_table_context_menu(self, pos):
     menu = QMenu(self._ui.map_table_view)
     menu.addAction("Insert row before")
     menu.addAction("Insert row after")
     menu.addAction("Remove row")
     menu.addSeparator()
     menu.addAction("Append column")
     menu.addAction("Trim columns")
     global_pos = self._ui.map_table_view.mapToGlobal(pos)
     action = menu.exec_(global_pos)
     if action is None:
         return
     action_text = action.text()
     selected_indexes = self._ui.map_table_view.selectedIndexes()
     selected_rows = sorted([index.row() for index in selected_indexes])
     first_row = selected_rows[0]
     if action_text == "Insert row before":
         self._model.insertRows(first_row, 1)
     elif action_text == "Insert row after":
         self._model.insertRows(first_row + 1, 1)
     elif action_text == "Remove row":
         self._model.removeRows(first_row, 1)
     elif action_text == "Append column":
         self._model.append_column()
     elif action_text == "Trim columns":
         self._model.trim_columns()
Exemple #4
0
class SystemTray(QSystemTrayIcon):
    def __init__(self, app):
        super(SystemTray, self).__init__()
        self.app = app
        self.systemTray = QSystemTrayIcon(
            QIcon(f"{sys.argv[0]}/assets/app_icon.png"))
        self.trayMenu = QMenu()
        self.systemTray.setContextMenu(self.trayMenu)
        self.menu_title_setup()
        self.open_action_setup()
        self.exit_action_setup()
        self.systemTray.show()

    def menu_title_setup(self):
        self.trayMenu.menuTitle = self.trayMenu.addAction("Saharah Paper")
        self.trayMenu.menuTitle.setEnabled(False)
        self.trayMenu.addSeparator()

    def open_action_setup(self):
        self.trayMenu.openAction = self.trayMenu.addAction("Settings")
        self.trayMenu.openAction.triggered.connect(self.handle_open)

    def handle_open(self):
        self.app.mainWindow.show()

    def exit_action_setup(self):
        self.trayMenu.exitAction = self.trayMenu.addAction("Exit")
        self.trayMenu.exitAction.triggered.connect(self.app.quit)
Exemple #5
0
    def _make_docks_menu(self):
        """Returns a menu with all dock toggle/view actions. Called by ``self.add_main_menu()``.

        Returns:
            QMenu
        """
        menu = QMenu(self)
        menu.addAction(self.ui.dockWidget_relationship_tree.toggleViewAction())
        menu.addSeparator()
        menu.addAction(
            self.ui.dockWidget_object_parameter_value.toggleViewAction())
        menu.addAction(
            self.ui.dockWidget_object_parameter_definition.toggleViewAction())
        menu.addAction(
            self.ui.dockWidget_relationship_parameter_value.toggleViewAction())
        menu.addAction(self.ui.dockWidget_relationship_parameter_definition.
                       toggleViewAction())
        menu.addSeparator()
        menu.addAction(self.ui.dockWidget_pivot_table.toggleViewAction())
        menu.addAction(self.ui.dockWidget_frozen_table.toggleViewAction())
        menu.addSeparator()
        menu.addAction(self.ui.dockWidget_entity_graph.toggleViewAction())
        menu.addSeparator()
        menu.addAction(self.ui.dockWidget_tool_feature_tree.toggleViewAction())
        menu.addAction(
            self.ui.dockWidget_parameter_value_list.toggleViewAction())
        menu.addAction(
            self.ui.dockWidget_alternative_scenario_tree.toggleViewAction())
        menu.addAction(self.ui.dockWidget_parameter_tag.toggleViewAction())
        menu.addSeparator()
        menu.addAction(self.ui.dockWidget_exports.toggleViewAction())
        return menu
Exemple #6
0
    def contextMenuEvent(self, event):
        """Context menu of tab options. """
        tab_index = self.tabBar().tabAt(event.pos())
        tab_menu = None
        # Currently over a tab
        if tab_index > -1:
            #rename_action = QAction("Rename", self)
            #rename_action.triggered.connect(self._setNewTabName(tab_index))
            remove_tab_action = QAction(
                QIcon(os.path.join('images', 'edit-delete.png')), "Close",
                self)
            remove_tab_action.triggered.connect(
                self._removeSelectedTab(tab_index))
            tab_menu = QMenu(self)
            #tab_menu.addAction(rename_action)
            tab_menu.addSeparator()
            tab_menu.addAction(remove_tab_action)
            if tab_index == 0:
                remove_tab_action.setDisabled(True)
        # In tab bar, but not over any tabs
        else:
            new_page_action = QAction("Insert New Page", self)
            new_page_action.triggered.connect(self.newPage)
            tab_menu = QMenu(self)
            tab_menu.addAction(new_page_action)

        tab_menu.exec_(event.globalPos())
        self.focusInEvent(QFocusEvent(QEvent.FocusIn))
Exemple #7
0
    def contextMenuRequested(self, point):
        menu = QMenu()
        actionFile = menu.addAction(QIcon.fromTheme("video-x-generic"),
                                    "open File (o)")
        actionclipboard = menu.addSeparator()
        actionURL = menu.addAction(QIcon.fromTheme("browser"),
                                   "URL from Clipboard (u)")
        actionclipboard = menu.addSeparator()
        actionYTurl = menu.addAction(QIcon.fromTheme("youtube"),
                                     "URL from YouTube (y)")
        actionclipboard = menu.addSeparator()
        actionToggle = menu.addAction(QIcon.fromTheme("next"),
                                      "show / hide Slider (s)")
        actionFull = menu.addAction(QIcon.fromTheme("view-fullscreen"),
                                    "Fullscreen (f)")
        action169 = menu.addAction(QIcon.fromTheme("tv-symbolic"), "16 : 9")
        action43 = menu.addAction(QIcon.fromTheme("tv-symbolic"), "4 : 3")
        actionSep = menu.addSeparator()
        actionInfo = menu.addAction(QIcon.fromTheme("help-about"), "Info (i)")
        action5 = menu.addSeparator()
        actionQuit = menu.addAction(QIcon.fromTheme("application-exit"),
                                    "Exit (q)")

        actionFile.triggered.connect(self.openFile)
        actionQuit.triggered.connect(self.handleQuit)
        actionFull.triggered.connect(self.handleFullscreen)
        actionInfo.triggered.connect(self.handleInfo)
        actionToggle.triggered.connect(self.toggleSlider)
        actionURL.triggered.connect(self.playFromURL)
        actionYTurl.triggered.connect(self.getYTUrl)
        action169.triggered.connect(self.screen169)
        action43.triggered.connect(self.screen43)
        menu.exec_(self.mapToGlobal(point))
class ViewMenuButton(QPushButton):

    sig_action = None

    def __init__(self, btn_name: str, show_field, actions_map: list):
        """
        Creates a QPushButton with a dropdown menu on it.

        :param btn_name: Button name (always displayed)
        :type btn_name: str
        :param actions_map: list of actions to put in the dropdown menu [(action_name, action_key), (separator_name), ...]
        :type actions_map: list
        :param show_field: entry field to display on create operations
        :type show_field: function
        """
        QPushButton.__init__(self, btn_name)

        self.menu = QMenu(self)

        for a in actions_map:
            if a == 'sep':  # This is a separator
                self.menu.addSeparator()
            else:  # Regular action
                t, k = a
                if k.startswith(
                        'create_'
                ):  # If we have a create feature, we display the entry field
                    self.menu.addAction(t, lambda k=k: show_field(k))
                else:
                    self.menu.addAction(t, lambda k=k: self.sig_action.emit(k))

        self.setMenu(self.menu)
        self.menu.setStyleSheet(get_stylesheet("menu"))
    def _build_menu(self):
        menu = QMenu()

        self.connect_action = QAction('Connect')
        self.disconnect_action = QAction('Disconnect')
        self.config_action = QAction('Config')
        self.logs_action = QAction('Logs')
        self.exit_action = QAction('Exit')

        self.disconnect_action.setDisabled(True)

        self.connect_action.triggered.connect(self._click_connect)
        self.disconnect_action.triggered.connect(self._click_disconnect)
        self.config_action.triggered.connect(self._click_config)
        self.logs_action.triggered.connect(self._click_logs)
        self.exit_action.triggered.connect(self._click_exit)

        menu.addAction(self.connect_action)
        menu.addAction(self.disconnect_action)
        menu.addSeparator()
        menu.addAction(self.config_action)
        menu.addAction(self.logs_action)
        menu.addSeparator()
        menu.addAction(self.exit_action)

        return menu
Exemple #10
0
    def __init__(self, parent=None):
        QSystemTrayIcon.__init__(self, parent)

        # タスクトレイアイコン クリックメニュー登録
        menu = QMenu(parent)
        qt_action = menu.addAction("Status")
        qt_action.triggered.connect(self.Message)
        menu.addSeparator()
        quit_action = menu.addAction("&Quit")
        quit_action.triggered.connect(self.Quit)

        # タスクトレイアイコン クリックメニュー設定
        self.setContextMenu(menu)

        # 初期アイコン設定
        self.setIcon(QIcon(str(Path(script_path / 'icon.jpg').resolve())))

        # run competitive companion server
        if not shutil.which('node'):
            QMessageBox.critical(None, "error", "node not found",
                                 QMessageBox.Ok)
            sys.exit()
        # elif socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect_ex(('127.0.0.1', 8080)) != 0:
        #     QMessageBox.critical(None, "error", "port:8080 is alreday in use", QMessageBox.Ok)
        #     sys.exit()
        else:
            self.proc = subprocess.Popen(
                ['node', str(Path(script_path / 'index.js').resolve())])
Exemple #11
0
    def create_menu(self, parent):
        menu = QMenu(parent)

        open_window = menu.addAction("Open")
        # connect

        menu.addSeparator()

        start_item = menu.addAction("Start")
        start_item.setIcon(QIcon("images/start.svg"))
        start_item.setDisabled(clash_started)
        start_item.triggered.connect(self.start_clash)
        self.start_item = start_item

        stop_item = menu.addAction("Stop")
        stop_item.setIcon(QIcon("images/stop.svg"))
        stop_item.setDisabled(not clash_started)
        stop_item.triggered.connect(self.stop_clash)
        self.stop_item = stop_item

        menu.addSeparator()

        exit_item = menu.addAction("Exit")
        exit_item.triggered.connect(self.exit_clash)

        self.setContextMenu(menu)
    def qmenu(self):
        if self._qmenu is not None:
            return self._qmenu

        if self.parent is not None:
            menu = QMenu(self.caption, self.parent)
        else:
            menu = QMenu(self.caption)

        for entry in self.entries:
            if isinstance(entry, MenuEntry):
                action = menu.addAction(entry.caption,
                                        entry.action)  # type: QAction
                if entry.shortcut is not None:
                    action.setShortcut(entry.shortcut)
                if entry.checkable:
                    action.setCheckable(True)
                    action.setChecked(entry.checked_initially)
                if not entry.default_enabled:
                    action.setDisabled(True)
                entry.qaction = action
            elif isinstance(entry, MenuSeparator):
                menu.addSeparator()
            else:
                raise Exception('Unsupported type %s' % type(entry))

        self._qmenu = menu

        return menu
Exemple #13
0
    def show_rightclick_menu(self):
        """

        :type self: SteamAccountSwitcherGui
        """

        right_menu = QMenu()

        selected = self.accounts_list.currentItem()
        if not self.accounts_list.selectedItems():
            add_account_action = QAction(_("Add account"), self)
            add_account_action.triggered.connect(
                lambda: self.account_dialog(True))
            right_menu.addAction(add_account_action)
            right_menu.exec_(QCursor.pos())
            return
        login_name = selected.data(5)
        account = self.switcher.settings["users"].get(login_name, {})

        login_action = QAction(_("Login"), self)
        edit_action = QAction(_("Edit"), self)
        delete_action = QAction(_("Delete"), self)
        open_profile_action = QAction(_("Steam profile"), self)
        steampage_menu = QMenu(_("Steam profile"), self)

        edit_action.setIcon(QIcon.fromTheme("document-edit"))
        delete_action.setIcon(QIcon.fromTheme("edit-delete"))
        open_profile_action.setIcon(QIcon.fromTheme("internet-web-browser"))

        right_menu.addActions([login_action, edit_action, delete_action])
        right_menu.addSeparator()
        right_menu.addAction(open_profile_action)
        right_menu.addMenu(steampage_menu)

        login_action.triggered.connect(lambda: self.steam_login(login_name))
        edit_action.triggered.connect(lambda: self.account_dialog())
        delete_action.triggered.connect(
            lambda: self.remove_account(login_name))

        open_profile_action.triggered.connect(
            lambda: self.open_steam_profile(account))

        steampage_menu.triggered.connect(
            lambda: self.open_steam_profile(account))

        steampage_menu_actions = QActionGroup(steampage_menu)
        steampage_menu_inventory = QAction(_('Inventory'),
                                           steampage_menu_actions,
                                           checkable=True,
                                           data="nothing")

        open_profile_action.setDisabled(True)
        if account.get("steam_user", {}).get("profileurl"):
            open_profile_action.setEnabled(True)
            steampage_menu.addActions([steampage_menu_inventory])

        if self.accounts_list.selectedItems():
            right_menu.exec_(QCursor.pos())
Exemple #14
0
    def contextMenuEvent(self, event):
        contextMenu = QMenu()
        zoomOut = contextMenu.addAction("Zoom out")
        clear = contextMenu.addAction("Clear")
        unitMenu = contextMenu.addMenu("Unit")

        def addUnit(unit):
            action = unitMenu.addAction(unit)
            action.setCheckable(True)
            action.setChecked(unit == self.unit)
            return action

        units_actions = [addUnit(menuUnits[i]) for i in range(len(menuUnits))]

        for s in range(1, self._maxSensor + 1):
            for a in ["X", "Y", "Z"]:
                name = f"{s} {a}"
                action = contextMenu.addAction(name)
                action.setCheckable(True)
                action.setChecked(self.chart().findSerie(name) is not None)

        if isinstance(self._serieType, QtCharts.QLineSeries):
            contextMenu.addSeparator()
            logX = contextMenu.addAction("Log X")
            logX.setCheckable(True)
            logX.setChecked(self.logX)

            logY = contextMenu.addAction("Log Y")
            logY.setCheckable(True)
            logY.setChecked(self.logY)

        else:
            logX = None
            logY = None

        action = contextMenu.exec_(event.globalPos())
        # conversions
        if action is None:
            return
        elif action == zoomOut:
            self.chart().zoomReset()
        elif action == clear:
            self.clear()
        elif action in units_actions:
            self.unit = action.text()
            self.unitChanged.emit(units[menuUnits.index(self.unit)])
        elif action == logX:
            self.logX = action.isChecked()
            self.axisChanged.emit(self.logX, self.logY)
        elif action == logY:
            self.logY = action.isChecked()
            self.axisChanged.emit(self.logX, self.logY)
        else:
            name = action.text()
            if action.isChecked():
                self.addSerie(name)
            else:
                self.removeSerie(name)
def _add_menu_items(
    menu: QMenu,
    items: List[Union[str, QAction]],
) -> None:
    for item in items:
        if item == _MENU_SEPARATOR:
            menu.addSeparator()
        elif isinstance(item, QAction):
            menu.addAction(item)
Exemple #16
0
 def on_context_menu(self, point):
     """Called when the mouse is right clicked on the remote control."""
     menu = QMenu(self)
     menu.addAction(self.current_channel)
     menu.addSeparator()
     menu.addAction(self.select_tivo)
     menu.addAction(self.input_text)
     menu.addAction(self.change_channel)
     menu.exec_(self.mapToGlobal(point))
def handle_table_context_menu(click_pos, table_view, model, parent_widget):
    """
    Shows a context menu for parameter value tables and handles the selection.

    Args:
        click_pos {QPoint): position from the context menu event
        table_view (QTableView): the table widget
        model (TimePatternModel, TimeSeriesModelFixedResolution, TimeSeriesModelVariableResolution): a model
        parent_widget (QWidget: context menu's parent widget
    """
    INSERT_SINGLE_AFTER = "Insert row after"
    INSERT_MULTI_AFTER = "Insert multiple rows after"
    INSERT_SINGLE_BEFORE = "Insert row before"
    INSERT_MULTI_BEFORE = "Insert multiple rows before"
    REMOVE = "Remove rows"
    column = table_view.columnAt(click_pos.x())
    row = table_view.rowAt(click_pos.y())
    if column < 0 or row < 0:
        return
    menu = QMenu(parent_widget)
    menu.addAction(INSERT_SINGLE_BEFORE)
    menu.addAction(INSERT_MULTI_BEFORE)
    menu.addSeparator()
    menu.addAction(INSERT_SINGLE_AFTER)
    menu.addAction(INSERT_MULTI_AFTER)
    menu.addSeparator()
    menu.addAction(REMOVE)
    global_pos = table_view.mapToGlobal(click_pos)
    action = menu.exec_(global_pos)
    if action is None:
        return
    action_text = action.text()
    selected_indexes = table_view.selectedIndexes()
    selected_rows = sorted([index.row() for index in selected_indexes])
    first_row = selected_rows[0]
    if action_text == INSERT_SINGLE_BEFORE:
        model.insertRows(first_row, 1)
    elif action_text == INSERT_MULTI_BEFORE:
        row_count, accepted = QInputDialog.getInt(parent_widget,
                                                  "Enter number of rows",
                                                  "Number of rows to insert",
                                                  minValue=1)
        if accepted:
            model.insertRows(first_row, row_count)
    elif action_text == INSERT_SINGLE_AFTER:
        model.insertRows(first_row + 1, 1)
    elif action_text == INSERT_MULTI_AFTER:
        row_count, accepted = QInputDialog.getInt(parent_widget,
                                                  "Enter number of rows",
                                                  "Number of rows to insert",
                                                  minValue=1)
        if accepted:
            model.insertRows(first_row + 1, row_count)
    elif action_text == REMOVE:
        _remove_rows(selected_rows, model)
Exemple #18
0
 def contextMenuEvent(self, event):
     menu = QMenu(self)
     menu.addAction(self.actionCopy)
     menu.addAction(self.actionSelectAll)
     menu.addAction(self.actionScrollToEnd)
     menu.addSeparator()
     self.actionWordWrap.setChecked(
         self.wordWrapMode() != QTextOption.NoWrap)
     menu.addAction(self.actionWordWrap)
     menu.addAction(self.actionClear)
     menu.exec_(event.globalPos())
    def build_menu_stimuli(self, visualization: bool, debugger: Optional[bool] = False) -> None:
        """Menu for stimuli delivery."""
        self.menubar = QMenuBar(self)
        self.menubar.clear()

        self.accent_menubar = QMenuBar(self)
        self.accent_menubar.clear()
        self.menubar.setMinimumWidth(1e4)

        # Title
        if debugger:
            menu_stimuli = QMenu(f"Debugging: {visualization}")
        else:
            if visualization:
                menu_stimuli = QMenu(visualization + ' 🞃')
            else:
                menu_stimuli = QMenu('Stimuli' + ' 🞃')

        for viz, path in self.extensions_list:
            if viz != visualization:
                menu_stimuli.addAction(QAction(viz, menu_stimuli,
                                               triggered=self.set_extension(path)))
        # self.menubar.addMenu(menu_stimuli)
        self.accent_menubar.addMenu(menu_stimuli)

        self.accent_menubar.setStyleSheet(f"""
        QMenuBar::item {{
            background-color: {os.getenv('QTMATERIAL_PRIMARYCOLOR', '#ffffff')};
            color: {os.getenv('QTMATERIAL_PRIMARYTEXTCOLOR', '#ffffff')};
        }}

        """)

        # self.menubar.addMenu(menu_stimuli)
        self.menubar.setCornerWidget(
            self.accent_menubar, corner=Qt.TopLeftCorner)

        # View
        menu_view = QMenu("View")
        if visualization:

            menu_view.addAction(
                QAction('Reload', menu_view, triggered=self.reload))

            if debugger:
                menu_view.addAction(
                    QAction('Open subwindow delivery', menu_view, triggered=debugger.open_subwindow))
            if not debugger:
                menu_view.addSeparator()
                menu_view.addAction(
                    QAction('Close', menu_view, triggered=self.remove))
        else:
            menu_view.setEnabled(False)
        self.menubar.addMenu(menu_view)
Exemple #20
0
    def initUi(self):
        self.setFixedSize(300, 450)
        self.center()
        self.setWindowTitle('timer')
        self.setWindowIcon(QIcon(':/images/timer.png'))

        self.menu_control = self.menuBar().addMenu(self.tr('Control'))
        self.act_countDownBeep = self.menu_control.addAction(
            self.tr('set countdown action is make a beep sound(default)'))
        self.act_countDownShutdown = self.menu_control.addAction(
            self.tr('set countdown action is shutdown the system'))
        self.act_countDownBeep.triggered.connect(self.set_act_beep)
        self.act_countDownShutdown.triggered.connect(self.set_act_shutdown)
        self.menu_control.addSeparator()

        self.act_quit = self.menu_control.addAction(self.tr('quit'))
        self.act_quit.triggered.connect(self.menu_exit)

        self.menu_language = self.menuBar().addMenu(self.tr('Language'))
        act_chinese = self.menu_language.addAction('中文')
        act_chinese.triggered.connect(self.change_lang_chinese)
        act_english = self.menu_language.addAction('english')
        act_english.triggered.connect(self.change_lang_english)

        self.menu_help = self.menuBar().addMenu(self.tr('Help'))
        self.act_show_running_log = self.menu_help.addAction(self.tr('running log'))
        self.act_show_running_record = self.menu_help.addAction(self.tr("running record"))
        self.act_show_running_log.triggered.connect(self.show_running_log)
        self.act_show_running_record.triggered.connect(self.show_running_record)

        self.menu_help.addSeparator()
        self.act_about = self.menu_help.addAction(self.tr('about this program'))
        self.act_about.triggered.connect(self.about)
        act_aboutqt = self.menu_help.addAction('aboutqt')
        act_aboutqt.triggered.connect(QApplication.instance().aboutQt)

        self.mywidget = MainWidget(self)
        self.setCentralWidget(self.mywidget)

        self.mysystemTrayIcon = SystemTrayIcon(self, icon=":/images/timer.png")
        menu1 = QMenu(self)
        menu_systemTrayIcon_open = menu1.addAction(self.tr('open'))
        menu_systemTrayIcon_open.triggered.connect(self.reopen)
        menu1.addSeparator()
        menu_systemTrayIcon_exit = menu1.addAction(self.tr("exit"))
        menu_systemTrayIcon_exit.triggered.connect(self.menu_exit)
        self.mysystemTrayIcon.setContextMenu(menu1)
        self.mysystemTrayIcon.show()

        # 状态栏
        self.statusBar().showMessage(self.tr('program is ready...'))
        self.statusBar().setSizeGripEnabled(False)

        self.show()
Exemple #21
0
 def contextMenuEvent(self, event):
     menu = QMenu(self)
     menu.addAction(self.action_delete)
     menu.addAction(self.action_create_links)
     menu.addAction(self.action_import_tags)
     menu.addSeparator()
     menu.addAction(self.action_ACI)
     menu.addAction(self.action_calculate_activity)
     menu.addAction(self.action_export_song_events)
     menu.addAction(self.action_evaluate_detector)
     menu.exec_(event.globalPos())
Exemple #22
0
 def contextMenuEvent(self, event):
     selected_rows = {i.row() for i in self.selectedIndexes()}
     breakpoints = [self.breakpoint_mgr.breakpoints[r] for r in selected_rows]
     menu = QMenu("", self)
     if len(breakpoints):
         if len(breakpoints) == 1:
             menu.addAction('Edit breakpoint', lambda: self.edit_breakpoint(breakpoints[0]))
         menu.addAction('Remove breakpoint' + ('s' if len(breakpoints) > 1 else ''),
                        lambda: self.remove_breakpoints(breakpoints))
         menu.addSeparator()
     menu.addAction('New breakpoint', self.new_breakpoint)
     menu.exec_(event.globalPos())
Exemple #23
0
 def _make_menu(self):
     menu = QMenu(self._spine_db_editor)
     menu.addAction(self._spine_db_editor.ui.actionSave_positions)
     menu.addAction(self._spine_db_editor.ui.actionClear_positions)
     menu.addSeparator()
     menu.addAction(self._spine_db_editor.ui.actionHide_selected)
     menu.addAction(self._spine_db_editor.ui.actionPrune_selected_entities)
     menu.addAction(self._spine_db_editor.ui.actionPrune_selected_classes)
     menu.addSeparator()
     menu.addAction(self._spine_db_editor.ui.actionEdit_selected)
     menu.addAction(self._spine_db_editor.ui.actionRemove_selected)
     return menu
Exemple #24
0
 def _make_menu(self):
     menu = QMenu(self._data_store_form)
     menu.addAction(self._data_store_form.ui.actionSave_positions)
     menu.addAction(self._data_store_form.ui.actionClear_positions)
     menu.addSeparator()
     menu.addAction(self._data_store_form.ui.actionHide_selected)
     menu.addAction(self._data_store_form.ui.actionPrune_selected_entities)
     menu.addAction(self._data_store_form.ui.actionPrune_selected_classes)
     menu.addSeparator()
     menu.addAction(self._data_store_form.ui.actionEdit_selected)
     menu.addAction(self._data_store_form.ui.actionRemove_selected)
     return menu
    def contextMenuVerticalHeader(self, pos):
        """
        Creates a context menu for the vertical header.
        """
        index = self.indexAt(pos)

        # Label
        actionLabelLetter = QAction('Letter', self)
        actionLabelLetter.setStatusTip('Change label to a capital letter')
        actionLabelLetter.setToolTip('Change label to a capital letter')
        actionLabelLetter.triggered.connect( lambda: self.onActionLabelVerticalTriggered(index.row(), Preferences.HeaderLabel.Letter) )

        actionLabelNumber = QAction('Number', self)
        actionLabelNumber.setStatusTip('Change label to a decimal number')
        actionLabelNumber.setToolTip('Change label to a decimal number')
        actionLabelNumber.triggered.connect( lambda: self.onActionLabelVerticalTriggered(index.row(), Preferences.HeaderLabel.Decimal) )

        actionLabelCustom = QAction('Custom…', self)
        actionLabelCustom.setStatusTip('Change label to a user-defined text')
        actionLabelCustom.setToolTip('Change label to a user-defined text')
        actionLabelCustom.triggered.connect( lambda: self.onActionLabelVerticalTriggered(index.row(), Preferences.HeaderLabel.Custom) )

        actionLabelLetters = QAction('Letters', self)
        actionLabelLetters.setStatusTip('Change all labels to capital letters')
        actionLabelLetters.setToolTip('Change all labels to capital letters')
        actionLabelLetters.triggered.connect( lambda: self.onActionLabelAllVerticalTriggered(Preferences.HeaderLabel.Letter) )

        actionLabelNumbers = QAction('Numbers', self)
        actionLabelNumbers.setStatusTip('Change all labels to decimal numbers')
        actionLabelNumbers.setToolTip('Change all labels to decimal numbers')
        actionLabelNumbers.triggered.connect( lambda: self.onActionLabelAllVerticalTriggered(Preferences.HeaderLabel.Decimal) )

        actionLabelCustoms = QAction('Custom…', self)
        actionLabelCustoms.setStatusTip('Change all labels to user-defined texts')
        actionLabelCustoms.setToolTip('Change all labels to user-defined texts')
        actionLabelCustoms.triggered.connect( lambda: self.onActionLabelAllVerticalTriggered(Preferences.HeaderLabel.Custom) )

        # Context menu
        menuLabel = QMenu('Label', self)
        menuLabel.setIcon(QIcon.fromTheme('tag', QIcon(':/icons/actions/16/tag.svg')))
        menuLabel.setStatusTip('Change label')
        menuLabel.setToolTip('Change label')
        menuLabel.addAction(actionLabelLetter)
        menuLabel.addAction(actionLabelNumber)
        menuLabel.addAction(actionLabelCustom)
        menuLabel.addSeparator()
        menuLabel.addAction(actionLabelLetters)
        menuLabel.addAction(actionLabelNumbers)
        menuLabel.addAction(actionLabelCustoms)

        contextMenu = QMenu(self)
        contextMenu.addMenu(menuLabel)
        contextMenu.exec_(self.mapToGlobal(pos))
Exemple #26
0
class TrayIcon(QSystemTrayIcon):
    on_settings = Signal()

    host: "Host"

    def __init__(self, host: "Host"):
        global _tray_icon
        super().__init__(QIcon(":/runekit/ui/trayicon.png"))

        _tray_icon = self

        self.host = host
        self._setup_menu()
        self.setContextMenu(self.menu)

    def _setup_menu(self):
        if not hasattr(self, "menu"):
            self.menu = QMenu("RuneKit")

        self.menu.clear()

        self._setup_app_menu("", self.menu)

        self.menu.addSeparator()
        self.menu_settings = self.menu.addAction("Settings")
        self.menu_settings.triggered.connect(self.on_settings)
        self.menu.addAction(
            QIcon.fromTheme("application-exit"),
            "Exit",
            lambda: QCoreApplication.instance().quit(),
        )

    def _setup_app_menu(self, path: str, menu: QMenu):
        for app_id, manifest in self.host.app_store.list_app(path):
            if manifest is None:
                # Folder
                submenu = menu.addMenu(QIcon.fromTheme("folder"), app_id)
                self._setup_app_menu(app_id, submenu)
                continue

            app_menu = menu.addAction(manifest["appName"])
            app_menu.triggered.connect(
                lambda _=None, app_id=app_id: self.host.launch_app_id(app_id)
            )

            icon = self.host.app_store.icon(app_id)
            if icon:
                app_menu.setIcon(icon)

    @Slot()
    def update_menu(self):
        self._setup_menu()
    def set_context_menu(self):
        stmenu = QMenu()

        action_freeze_new = QAction(self.freeze_icon, "Freeze New", self)
        action_freeze_new.setShortcut(
            QKeySequence(self.prefs["hotkeys"]["value"]["freeze_new"].replace(
                '<', '').replace('>', '')))
        action_freeze_new.triggered.connect(self.freeze_layout)
        stmenu.addAction(action_freeze_new)

        action_freeze_all = QAction("Freeze All", self)
        action_freeze_all.setShortcut(
            QKeySequence(self.prefs["hotkeys"]["value"]["freeze_all"].replace(
                '<', '').replace('>', '')))
        action_freeze_all.triggered.connect(self.freeze_layout_all)
        stmenu.addAction(action_freeze_all)

        action_restore = QAction(self.restore_icon, "Restore Layout", self)
        action_restore.setShortcut(
            QKeySequence(self.prefs["hotkeys"]["value"]["restore"].replace(
                '<', '').replace('>', '')))
        action_restore.triggered.connect(self.restore_layout)
        stmenu.addAction(action_restore)

        stmenu.addSeparator()

        clear_db_submenu = QMenu("Clear Database", stmenu)

        action_clear_db_curr_display_layout = clear_db_submenu.addAction(
            "Current Display Layout")
        action_clear_db_curr_display_layout.triggered.connect(
            self.clear_database_curr_display_layout)

        action_clear_db_all = QAction(self.caution_icon, "Clear Everything",
                                      self)
        action_clear_db_all.triggered.connect(self.clear_database_all)
        clear_db_submenu.addAction(action_clear_db_all)

        stmenu.addMenu(clear_db_submenu)

        action_prefs = stmenu.addAction("Preferences")
        action_prefs.triggered.connect(self.open_preferences)

        action_prefs = stmenu.addAction("About")
        action_prefs.triggered.connect(self.open_about)

        stmenu.addSeparator()

        action_exit = stmenu.addAction("Exit")
        action_exit.triggered.connect(self.app.exit)

        self.setContextMenu(stmenu)
Exemple #28
0
    def contextMenuEvent(self, event):
        sr = self.current_symbols_record()

        menu = QMenu("", self)

        menu.addAction('New Symbol...', self._action_new_symbol)
        menu.addSeparator()

        a = menu.addAction('Delete Symbol', self._action_delete)
        if sr is None:
            a.setDisabled(True)

        menu.exec_(event.globalPos())
 def make_items_menu(self):
     menu = QMenu(self)
     menu.addAction(self._save_pos_action)
     menu.addAction(self._clear_pos_action)
     menu.addSeparator()
     menu.addAction(self._hide_action)
     menu.addAction(self._prune_entities_action)
     menu.addAction(self._prune_classes_action)
     menu.addSeparator()
     menu.addAction("Edit", self.edit_selected)
     menu.addAction("Remove", self.remove_selected)
     menu.aboutToShow.connect(self._update_actions_visibility)
     return menu
Exemple #30
0
class QTreeCustomPrimary(QTreeWidget):
    def __init__(self, parent):
        QTreeWidget.__init__(self, parent)
        self.parent = parent
        self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.contextMenuEvent)

    def contextMenuEvent(self, event):
        """Tests if click was over a valid item."""
        index = self.indexAt(event)
        if index.isValid():
            item = self.itemAt(event)
            name = item.text(0)   # the text of the node
            self.contextMenu1(name=name, event=event)
        else:
            name = None

    def contextMenu1(self, name, event):
        self.menu = QMenu()
        var_name = self.menu.addAction(name)
        f = QtGui.QFont()
        f.setBold(True)
        var_name.setFont(f)
        self.menu.addSeparator()
        act_summary = self.menu.addAction('Summary')
        act_index = self.menu.addAction('Set as Index')
        act_transform = self.menu.addAction('Transform')
        act_groupby = self.menu.addAction('Group-by')
        act_secondary = self.menu.addAction('Move to Secondary')
        act_delete = self.menu.addAction('Delete')

        self.menu.popup(QtGui.QCursor.pos())
        action = self.menu.exec_(self.mapToGlobal(event))

        if action is not None:
            if action.text() == 'Summary':
                print('')
            if action.text() == 'Set as Index':
                pass # self.parent.df.
            if action.text() == 'Transform':
                print('')
            if action.text() == 'Group-by':
                print('')
            if action.text() == 'Move to Secondary':
                move_to_secondary(parent=self.parent, name=name)
            if action.text() == 'Delete':
                self.parent.df.drop(name, axis=1, inplace=True)
                self.parent.primary_names = self.parent.df.keys().tolist()
                self.parent.console.push_vars({'df': self.parent.df})
                self.parent.init_trees()