Ejemplo n.º 1
0
    def setupInterface(self, main):
        # Dock widget
        action = QAction("Sample Python Plugin", main)
        action.setCheckable(True)
        widget = FortuneWidget(main, action)
        main.addPluginDockWidget(widget, action)

        # Dissassembly context menu
        menu = main.getContextMenuExtensions(
            cutter.MainWindow.ContextMenuType.Disassembly)
        self.disas_action = menu.addAction(
            "CutterSamplePlugin dissassembly action")
        self.disas_action.triggered.connect(self.handle_disassembler_action)
        self.main = main

        # Context menu for tables with addressable items like Flags,Functions,Strings,Search results,...
        addressable_item_menu = main.getContextMenuExtensions(
            cutter.MainWindow.ContextMenuType.Addressable)
        self.addr_submenu = addressable_item_menu.addMenu(
            "CutterSamplePlugin")  # create submenu
        adrr_action = self.addr_submenu.addAction("Action 1")
        self.addr_submenu.addSeparator(
        )  # can use separator and other qt functionality
        adrr_action2 = self.addr_submenu.addAction("Action 2")
        adrr_action.triggered.connect(self.handle_addressable_item_action)
        adrr_action2.triggered.connect(self.handle_addressable_item_action)
Ejemplo n.º 2
0
    def setupInterface(self, main):
        action = QAction("JIR2 String Decoder", main)
        action.setCheckable(False)
        action.triggered.connect(self.decodeAll)

        pluginsMenu = main.getMenuByType(main.MenuType.Plugins)
        pluginsMenu.addAction(action)
Ejemplo n.º 3
0
    def add_menu_density(self, parent, menu):
        """"""
        self.menu_density_ = menu
        action_group = QActionGroup(menu)

        try:
            action_group.setExclusive(True)
        except:
            action_group.exclusive = True

        for density in map(str, range(-3, 4)):
            action = QAction(parent)
            # action.triggered.connect(self._wrapper(parent, density, self.extra_values, self.update_buttons))
            action.triggered.connect(lambda: self.update_theme_event(parent))
            try:
                action.setText(density)
                action.setCheckable(True)
                action.setChecked(density == '0')
                action.setActionGroup(action_group)
                menu.addAction(action)
                action_group.addAction(action)
            except:  # snake_case, true_property
                action.text = density
                action.checkable = True
                action.checked = density == '0'
                action.action_group = action_group
                menu.add_action(action)
                action_group.add_action(action)
Ejemplo n.º 4
0
 def get_synchronize_with_submenu(self) -> QMenu:
     """
     Get submenu for 'Synchronize with' context menu.
     """
     mnu = QMenu("&Synchronize with", self)
     groups = {
         v.sync_state
         for v in self.workspace.view_manager.views
         if (v is not self) and isinstance(v, SynchronizedView)
     }
     if len(groups) == 0:
         act = QAction('None available', self)
         act.setEnabled(False)
         mnu.addAction(act)
     else:
         for group in groups:
             act = QAction(
                 ', '.join(
                     [v.caption for v in group.views if v is not self]),
                 self)
             act.setCheckable(True)
             act.setChecked(group is self.sync_state)
             act.toggled.connect(
                 lambda checked, s=group: self.sync_with_state_object(
                     s if checked else None))
             mnu.addAction(act)
     return mnu
Ejemplo n.º 5
0
 def init_toolbar(self):
     for button in self.tag_button_group.buttons():
         self.tag_button_group.removeButton(button)
     for action in self.actions:
         self.removeAction(action)
     action = QAction("untagged")
     self.insertAction(self.empty_action, action)
     action.setCheckable(True)
     button = self.widgetForAction(action)
     self.tag_button_group.addButton(button, id=0)
     self.actions = [action]
     self.db_map_ids = [[(db_map, 0) for db_map in self.db_maps]]
     tag_data = {}
     for db_map in self.db_maps:
         for parameter_tag in self.db_mngr.get_items(db_map, "parameter tag"):
             tag_data.setdefault(parameter_tag["tag"], {})[db_map] = parameter_tag["id"]
     for tag, db_map_data in tag_data.items():
         action = QAction(tag)
         self.insertAction(self.empty_action, action)
         action.setCheckable(True)
         button = self.widgetForAction(action)
         self.tag_button_group.addButton(button, id=len(self.db_map_ids))
         self.actions.append(action)
         self.db_map_ids.append(list(db_map_data.items()))
     self.tag_button_group.buttonToggled["int", "bool"].connect(
         lambda i, checked: self.tag_button_toggled.emit(self.db_map_ids[i], checked)
     )
Ejemplo n.º 6
0
    def add_menu_theme(self, parent, menu):
        """"""
        self.menu_theme_ = menu
        action_group = QActionGroup(menu)
        try:
            action_group.setExclusive(True)
        except:
            action_group.exclusive = True

        for i, theme in enumerate(['default'] + list_themes()):
            action = QAction(parent)
            # action.triggered.connect(self._wrapper(parent, theme, self.extra_values, self.update_buttons))
            action.triggered.connect(lambda: self.update_theme_event(parent))
            try:
                action.setText(theme)
                action.setCheckable(True)
                action.setChecked(not bool(i))
                action.setActionGroup(action_group)
                menu.addAction(action)
                action_group.addAction(action)
            except:  # snake_case, true_property
                action.text = theme
                action.checkable = True
                action.checked = not bool(i)
                action.action_group = action_group
                menu.add_action(action)
                action_group.add_action(action)
    def __init__(self):
        super().__init__()

        self.setWindowTitle("My App")

        label = QLabel("Hello!")
        label.setAlignment(Qt.AlignCenter)

        self.setCentralWidget(label)

        toolbar = QToolBar("My main toolbar")
        toolbar.setIconSize(QSize(16, 16))
        self.addToolBar(toolbar)

        button_action = QAction(QIcon("bug.png"), "Your button", self)
        button_action.setStatusTip("This is your button")
        button_action.triggered.connect(self.onMyToolBarButtonClick)
        button_action.setCheckable(True)
        toolbar.addAction(button_action)

        toolbar.addSeparator()

        button_action2 = QAction(QIcon("bug.png"), "Your button2", self)
        button_action2.setStatusTip("This is your button2")
        button_action2.triggered.connect(self.onMyToolBarButtonClick)
        button_action2.setCheckable(True)
        toolbar.addAction(button_action2)

        toolbar.addWidget(QLabel("Hello"))
        toolbar.addWidget(QCheckBox())

        self.setStatusBar(QStatusBar(self))
Ejemplo n.º 8
0
 def __init__(self):
     self.ctrlcv = ControlCV()
     QMainWindow.__init__(self)
     self.setWindowFlags(Qt.WindowStaysOnTopHint
                         | Qt.WindowMinimizeButtonHint
                         | Qt.WindowCloseButtonHint
                         | Qt.MSWindowsFixedSizeDialogHint)
     self.setWindowTitle("ClipBoard")
     self.menu = self.menuBar()
     self.file_menu = self.menu.addMenu("File")
     self.action_menu = self.menu.addMenu("Action")
     exit_action = QAction("Exit", self)
     exit_action.setShortcut("Ctrl+Q")
     exit_action.triggered.connect(self.exit_app)
     self.file_menu.addAction(exit_action)
     load_action = QAction("Load", self)
     load_action.triggered.connect(self.load_from_file)
     self.file_menu.addAction(load_action)
     switch_action = QAction("Switch", self)
     switch_action.setCheckable(True)
     switch_action.triggered.connect(self.switch_window)
     self.action_menu.addAction(switch_action)
     resize_action = QAction("Resize", self)
     resize_action.setCheckable(True)
     resize_action.triggered.connect(self.resize_window)
     self.action_menu.addAction(resize_action)
     main_widget = QWidget()
     layout = QGridLayout()
     main_widget.setLayout(layout)
     self.clip_panel = [QLabel('') for i in range(9)]
     for i in range(9):
         self.clip_panel[i].setText('')
         self.clip_panel[i].setStyleSheet("border:0.51px solid grey;")
         layout.addWidget(self.clip_panel[i], int(i / 3), i % 3, 1, 1)
     self.setCentralWidget(main_widget)
Ejemplo n.º 9
0
    def create_scene_action(self, scene_name: str, is_active: bool):
        s = QAction(IconRsc.get_icon('document'), scene_name, self.action_grp)
        s.setCheckable(True)
        s.setChecked(is_active)
        s.triggered.connect(self._toggle_scene)

        self.addAction(s)
Ejemplo n.º 10
0
 def register_menu_command(self, cmd):
     menu_path = cmd.menu.split("/")
     menu = self._ensure_menu(menu_path)
     label = cmd.item_label
     if cmd.item_shortcut:
         label += "\t%s" % cmd.item_shortcut
     item = QAction(label, self._key_capturer)
     item.setShortcutContext(Qt.WidgetShortcut)
     # We must add a separate action to the menu, otherwise the shortcut is being triggered even when the menubar is focused.
     menu_action = menu.addAction(label)
     self._key_capturer.addAction(item)
     item.triggered.connect(cmd)
     menu_action.triggered.connect(cmd)
     item.setCheckable(cmd.checkable)
     menu_action.setCheckable(cmd.checkable)
     if cmd.item_shortcut:
         seq = QKeySequence(cmd.item_shortcut)
         item.setShortcut(seq)
     if cmd.item_name:
         self._menu_items_by_name[cmd.item_name] = menu_action
     if cmd.checkable:
         item.toggled.connect(
             lambda checked, mi=menu_action: safe_set_checked(mi, checked))
         menu_action.toggled.connect(
             lambda checked, si=item: safe_set_checked(si, checked))
Ejemplo n.º 11
0
    def __init__(self):
        super().__init__()

        widget = QWidget()
        self.setCentralWidget(widget)

        menubar = self.menuBar()
        menu = menubar.addMenu("&Menu")  # "&"" allows short cut access "alt+M"

        action_text = QAction("텍스트", self)
        menu.addAction(action_text)

        action_text.setCheckable(True)

        menu.addSeparator()
        submenu = menu.addMenu("submenu")

        action_icon = QAction(QIcon("icon.png"), "아이콘", self)
        submenu.addAction(action_icon)

        action_icon.triggered.connect(self.on_click)
        action_icon.setCheckable(True)

        self.setStatusBar(QStatusBar(self))
        action_text.setStatusTip("액션_텍스트")
        action_icon.setStatusTip("액션_아이콘")
Ejemplo n.º 12
0
    def create_action(self, icon, name, short_cut, checkable=False):
        """Create an action an return"""
        action = QAction(QIcon('./media/{}'.format(icon)), name, self._window)
        action.setShortcut(short_cut)
        action.setCheckable(checkable)
        action.setToolTip(name)

        return action
Ejemplo n.º 13
0
class Profiling(ProfilingService):
    """
    GUI part of the nexxT profiling service.
    """
    def __init__(self):
        super().__init__()
        srv = Services.getService("MainWindow")
        profMenu = srv.menuBar().addMenu("Pr&ofiling")

        self.loadDockWidget = srv.newDockWidget("Load", None,
                                                Qt.BottomDockWidgetArea)
        self.loadDisplay = LoadDisplayWidget(self.loadDockWidget)
        self.loadDockWidget.setWidget(self.loadDisplay)
        self.loadDataUpdated.connect(self.loadDisplay.newLoadData)
        self.threadDeregistered.connect(self.loadDisplay.removeThread)

        self.spanDockWidget = srv.newDockWidget("Profiling", None,
                                                Qt.BottomDockWidgetArea)
        self.spanDisplay = SpanDisplayWidget(self.spanDockWidget)
        self.spanDockWidget.setWidget(self.spanDisplay)
        self.spanDataUpdated.connect(self.spanDisplay.newSpanData)
        self.threadDeregistered.connect(self.spanDisplay.removeThread)

        self.actLoadEnabled = QAction("Enable Load Monitor")
        self.actLoadEnabled.setCheckable(True)
        self.actLoadEnabled.setChecked(True)
        self.actLoadEnabled.toggled.connect(self.setLoadMonitorEnabled)

        self.actProfEnabled = QAction("Enable Port Profiling")
        self.actProfEnabled.setCheckable(True)
        self.actProfEnabled.setChecked(False)
        self.actProfEnabled.toggled.connect(self.setPortProfilingEnabled)

        self.setLoadMonitorEnabled(True)
        self.setPortProfilingEnabled(False)

        profMenu.addAction(self.actLoadEnabled)
        profMenu.addAction(self.actProfEnabled)

    def setLoadMonitorEnabled(self, enabled):
        """
        called when the corresponding QAction is toggled

        :param enabled: boolean
        :return:
        """
        self.actProfEnabled.setEnabled(enabled)
        super().setLoadMonitorEnabled(enabled)

    def setPortProfilingEnabled(self, enabled):
        """
        called when the corresponding QAction is toggled

        :param enabled: boolean
        :return:
        """
        self.actLoadEnabled.setEnabled(not enabled)
        super().setPortProfilingEnabled(enabled)
Ejemplo n.º 14
0
    def __init__(self):
        super().__init__()
        srv = Services.getService("MainWindow")
        self.dockWidget = srv.newDockWidget(
            "Log",
            parent=None,
            defaultArea=Qt.BottomDockWidgetArea,
            allowedArea=Qt.LeftDockWidgetArea | Qt.BottomDockWidgetArea)
        self.logWidget = LogView()
        self.dockWidget.setWidget(self.logWidget)
        logMenu = srv.menuBar().addMenu("&Log")
        mainLogger = logging.getLogger()
        self.handler = LogHandler(self.logWidget)
        mainLogger.addHandler(self.handler)
        self.logWidget.destroyed.connect(
            lambda: mainLogger.removeHandler(self.handler))

        self.actFollow = QAction("Follow")
        self.actFollow.setCheckable(True)
        self.actFollow.setChecked(True)
        self.actClear = QAction("Clear")
        self.actSingleLine = QAction("Single Line")
        self.actSingleLine.setCheckable(True)
        self.actSingleLine.setChecked(True)
        self.logWidget.setUniformRowHeights(True)

        self.actFollow.toggled.connect(self.logWidget.setFollow)
        self.actClear.triggered.connect(self.logWidget.clear)
        self.actSingleLine.toggled.connect(self.logWidget.setUniformRowHeights)

        self.actDisable = QAction("Disable")
        self.actDisable.triggered.connect(self.setLogLevel)

        self.actGroup = QActionGroup(self)
        self.actGroup.setExclusive(True)
        levelno = mainLogger.level

        self.loglevelMap = {}
        for lv in ["INTERNAL", "DEBUG", "INFO", "WARNING", "ERROR"]:
            a = QAction(lv[:1] + lv[1:].lower())
            a.setCheckable(True)
            loglevel = getattr(logging, lv)
            self.loglevelMap[a] = loglevel
            setattr(self, "setLogLevel_" + lv, self.setLogLevel)
            a.triggered.connect(getattr(self, "setLogLevel_" + lv))
            self.actGroup.addAction(a)
            if levelno == loglevel:
                a.setChecked(True)
            else:
                a.setChecked(False)
            logMenu.addAction(a)
        self.loglevelMap[self.actDisable] = 100
        logMenu.addAction(self.actDisable)
        logMenu.addSeparator()
        logMenu.addAction(self.actClear)
        logMenu.addAction(self.actFollow)
        logMenu.addAction(self.actSingleLine)
Ejemplo n.º 15
0
    def translate_element(menu, entry, index=None):
        if index is None:
            before = None
        else:
            try:
                before = menu.actions()[index]
            except IndexError:
                before = None

        if entry is None:
            entry = MenuSeparator()
        elif type(entry) is tuple and len(entry) == 2 and callable(entry[1]):
            entry = MenuEntry(*entry)
        elif type(entry) is tuple and len(entry) == 2 and hasattr(
                entry[1], '__iter__'):
            entry = Menu(*entry)

        if isinstance(entry, MenuEntry):
            action = QAction(entry.caption)
            action.triggered.connect(entry.action)
            entry.qaction = action

            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)

            if before is None:
                menu.addAction(action)
            else:
                menu.insertAction(before, action)
        elif isinstance(entry, MenuSeparator):
            if before is None:
                menu.addSeparator()
            else:
                menu.insertSeparator(before)
        elif isinstance(entry, Menu):
            if before is None:
                menu.addMenu(entry.qmenu())
            else:
                menu.insertMenu(before, entry.qmenu())
        elif isinstance(entry, QMenu):
            if before is None:
                menu.addMenu(entry)
            else:
                menu.insertMenu(before, entry)
        elif isinstance(entry, QAction):
            if before is None:
                menu.addAction(entry)
            else:
                menu.insertAction(before, entry)
        else:
            raise TypeError('Unsupported type', type(entry))
Ejemplo n.º 16
0
    def __initialize_views(self, options, central):
        # Create docks view and main widget
        valid_options = [(View.graph, "Graph"), (View.tree, "Tree"),
                         (View.osg, "3D"), (View.scene, "2D")]

        # Creation of docks and mainwidget
        for widget_type, widget_name in valid_options:
            if widget_type == central and central != View.none:
                viewer = self.__create_widget(widget_type)
                self.window.setCentralWidget(viewer)
                widget_c = WidgetContainer()
                widget_c.widget = viewer
                widget_c.name = widget_name
                widget_c.type = widget_type
                self.widgets[widget_name] = widget_c
                self.widgets_by_type[widget_type] = widget_c
                self.main_widget = viewer
            elif options & widget_type:
                viewer = self.__create_widget(widget_type)
                widget_c = WidgetContainer()
                widget_c.widget = viewer
                widget_c.name = widget_name
                widget_c.type = widget_type
                self.widgets[widget_name] = widget_c
                self.widgets_by_type[widget_type] = widget_c
                self.__create_dock_and_menu(widget_name, viewer)
        if View.graph in self.widgets_by_type:
            new_action = QAction("Animation", self)
            new_action.setStatusTip("Toggle animation")
            new_action.setCheckable(True)
            new_action.setChecked(False)
            self.forces_menu.addAction(new_action)
            new_action.triggered.connect(lambda: self.widgets_by_type[
                View.graph].widget.toggle_animation(True))

        # Tabification of current docks
        previous = None
        for dock_name, dock_widget in self.docks.items():
            if previous:
                self.window.tabifyDockWidget(previous, dock_widget)
            previous = dock_widget

        # Connection of tree to graph signals
        if "Tree" in self.docks:
            if self.main_widget:
                graph_widget = self.main_widget
                if graph_widget:
                    tree_widget = self.docks["Tree"].widget()
                    tree_widget.node_check_state_changed_signal.connect(
                        lambda node_id: graph_widget.hide_show_node_SLOT(
                            node_id, 2))
        if len(self.docks) > 0 or central != None:
            self.window.show()
        else:
            self.window.showMinimized()
Ejemplo n.º 17
0
 def _init_toolbar(self):
     super(MPLNavigationToolbar, self)._init_toolbar()
     self.addSeparator()
     a = QAction('MEAS')
     a.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_A)
     self.insertAction(self._actions['zoom'], a)
     self._actions['measure'] = a
     a.setToolTip('Measure time difference')
     a.setCheckable(True)
     a.triggered.connect(self.measure)
     a.setIcon(QIcon('Resources\\measure.png'))
Ejemplo n.º 18
0
 def _registerWindow(self, window, nameChangedSignal):
     act = QAction("<unnamed>", self)
     act.setCheckable(True)
     act.toggled.connect(window.setVisible)
     window.visibleChanged.connect(act.setChecked)
     nameChangedSignal.connect(act.setText)
     self.windows[shiboken2.getCppPointer(window)[0]] = act  # pylint: disable=no-member
     self.menu.addAction(act)
     logger.debug("Registering window %s, new len=%d",
                  shiboken2.getCppPointer(window), len(self.windows))  # pylint: disable=no-member
     window.destroyed.connect(self._windowDestroyed)
        def setupInterface(self, main):
            # Create a new action (menu item)
            action = QAction("APT32 Graph Deobfuscator", main)
            action.setCheckable(False)
            # Connect the action to a function - cleaner.
            # A click on this action will trigger the function
            action.triggered.connect(self.cleaner)

            # Add the action to the "Windows -> Plugins" menu
            pluginsMenu = main.getMenuByType(main.MenuType.Plugins)
            pluginsMenu.addAction(action)
Ejemplo n.º 20
0
    def setupInterface(self, main):
        print("[9] inside setupInterface")

        if self.widget is None:
            action = QAction("IPyCutter", main)
            action.setCheckable(True)

            self.widget = cutter_qtconsole.IPythonConsole(
                self.kernel.connection_file, main, action)
            self.widget.create()
            main.addPluginDockWidget(self.widget, action)
        self.widget.show()
Ejemplo n.º 21
0
    def __init__(self):
        super().__init__()

        self.setWindowTitle("My App")

        label = QLabel("Hello!")

        # The `Qt` namespace has a lot of attributes to customize
        # widgets. See: http://doc.qt.io/qt-5/qt.html
        label.setAlignment(Qt.AlignCenter)

        # Set the central widget of the Window. Widget will expand
        # to take up all the space in the window by default.
        self.setCentralWidget(label)

        toolbar = QToolBar("My main toolbar")
        toolbar.setIconSize(QSize(16, 16))
        self.addToolBar(toolbar)

        button_action = QAction(QIcon("bug.png"), "&Your button", self)
        button_action.setStatusTip("This is your button")
        button_action.triggered.connect(self.onMyToolBarButtonClick)
        button_action.setCheckable(True)
        # You can enter keyboard shortcuts using key names (e.g. Ctrl+p)
        # Qt.namespace identifiers (e.g. Qt.CTRL + Qt.Key_P)
        # or system agnostic identifiers (e.g. QKeySequence.Print)
        button_action.setShortcut(QKeySequence("Ctrl+p"))
        toolbar.addAction(button_action)

        toolbar.addSeparator()

        button_action2 = QAction(QIcon("bug.png"), "Your &button2", self)
        button_action2.setStatusTip("This is your button2")
        button_action2.triggered.connect(self.onMyToolBarButtonClick)
        button_action2.setCheckable(True)
        toolbar.addAction(button_action)

        toolbar.addWidget(QLabel("Hello"))
        toolbar.addWidget(QCheckBox())

        self.setStatusBar(QStatusBar(self))

        menu = self.menuBar()

        file_menu = menu.addMenu("&File")
        file_menu.addAction(button_action)

        file_menu.addSeparator()

        file_submenu = file_menu.addMenu("Submenu")

        file_submenu.addAction(button_action2)
Ejemplo n.º 22
0
    def createLanguageMenu(self):
        langPath = self.own_path + "languages" + os.sep

        langDirectory = QDir(langPath)
        for language_file in langDirectory.entryList(['*.qm']):
            language_code = language_file.split('.')[0]
            language = QLocale.languageToString(QLocale(language_code).language())
            language_icon = QIcon(langPath + language_code + '.png')
            action = QAction(language_icon, language, self)
            action.setCheckable(True)
            action.setData(language_code)
            self.menuLanguage.addAction(action)
            self.langGroup.addAction(action)
Ejemplo n.º 23
0
class LanguageMenu(QMenu):
    def __init__(self, ui: QMainWindow):
        super(LanguageMenu, self).__init__(_("Sprache"), ui)
        self.ui = ui
        self.en, self.de = QAction(), QAction()
        self.setup()

    def setup(self):
        self.en = QAction('English [en]', self)
        self.en.setCheckable(True)
        en_call = ConnectCall('en',
                              target=self.change_language,
                              parent=self.en)
        self.en.triggered.connect(en_call.call)

        self.de = QAction('Deutsch [de]', self)
        self.de.setCheckable(True)
        de_call = ConnectCall('de',
                              target=self.change_language,
                              parent=self.de)
        self.de.triggered.connect(de_call.call)
        self.addActions([self.de, self.en])

        self.aboutToShow.connect(self.update_menu)

    def change_language(self, l: str):
        if AppSettings.language == l:
            return

        if 'de' == l:
            title = 'Sprache auswählen'
            msg = 'Die Anwendung muss neu gestartet werden um die Sprache auf Deutsch zu aendern.<br>' \
                  'Bitte File > Exit waehlen und Anwendung anschließend erneut starten.'
        else:
            title = 'Change Language'
            msg = 'The Application needs to be restarted to change the language to English.<br>' \
                  'Please choose Datei > Beenden to exit and then start the application again.'

        AppSettings.language = l

        msg_box = GenericMsgBox(self.ui, title, msg)
        msg_box.exec()

    def update_menu(self):
        self.de.setChecked(False)
        self.en.setChecked(False)

        if AppSettings.language.casefold() == 'de':
            self.de.setChecked(True)
        elif AppSettings.language.casefold() == 'en':
            self.en.setChecked(True)
Ejemplo n.º 24
0
    def make_display_rule_action(display_rule,
                                 group: Optional[QActionGroup] = None
                                 ) -> QAction:
        def make_check_closure():
            def closure():
                display_rule.value = action.isChecked()

            return closure

        action = QAction(f"&{display_rule.menu_text}", group)
        action.setCheckable(True)
        action.setChecked(display_rule.value)
        action.toggled.connect(make_check_closure())
        return action
Ejemplo n.º 25
0
class ChartTools(QWidget):
    def __init__(self, chm, algManager, parent=None):
        QWidget.__init__(self, parent)

        self.mainLay = QVBoxLayout(self)

        self.scrollLay = QFormLayout(self)
        self.mainLay.addLayout(self.scrollLay)
        
        self.scrollStepChooser = chm.createScrollStepChooser()
        self.scrollLay.addRow('Scroll Step', self.scrollStepChooser)

        viewRangeChooser = chm.createViewRangeChooser()
        self.scrollLay.addRow('View Range', viewRangeChooser)

        self.chartTimer = QTimer()
        self.chartTimer.timeout.connect(chm.getChart().scrollForward)

        options = {'x1' : 1000,
                   'x2' : 500,
                   'x4' : 250,
                   'x8' : 125}
        self.updateChooser = Chooser(options)
        self.updateChooser.setCurrentText('x1')
        self.chartTimer.setInterval(self.updateChooser.getCurrentValue())
        self.updateChooser.currentValueChanged.connect(self.chartTimer.setInterval)
        self.scrollLay.addRow('Updates Per Sec', self.updateChooser)
        
        self.startBtn = QPushButton('Run')
        self.startBtn.setCheckable(True)
        self.a = QAction('SCROLL')
        self.startBtn.addAction(self.a)
        self.a.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_Space)
        self.a.setCheckable(True)
        self.a.triggered.connect(self.startBtn.toggle)
        self.startBtn.toggled.connect(self.setAutoscroller)
        self.scrollLay.addRow(self.startBtn)
        

        chartSelector = chm.createSelector(algManager)
        self.mainLay.addWidget(chartSelector)

    def setAutoscroller(self, newState):
        if newState:
            self.chartTimer.start()
            self.startBtn.setText('Stop')
        else:
            self.chartTimer.stop()
            self.startBtn.setText('Run')
Ejemplo n.º 26
0
    def __init__(self, mainWin=None):
        """

        @param mainWin: should be the app main window
        @type mainWin:  QMainWindow
        """
        self.mainWin = mainWin
        # init form
        self.initWins()
        actionSub = QAction('Show SubFolders', None)
        actionSub.setCheckable(True)
        actionSub.setChecked(False)
        actionSub.triggered.connect(lambda checked=False, action=actionSub: self.hSubfolders(action))  # named arg checked is always sent
        self.actionSub = actionSub
        # init context menu
        self.initCMenu()
Ejemplo n.º 27
0
 def _add_db_map_tag_actions(self, db_map, parameter_tags):
     action_texts = [a.text() for a in self.actions]
     for parameter_tag in parameter_tags:
         if parameter_tag["tag"] in action_texts:
             # Already a tag named after that, add db_map id information
             i = action_texts.index(parameter_tag["tag"])
             self.db_map_ids[i].append((db_map, parameter_tag["id"]))
         else:
             action = QAction(parameter_tag["tag"])
             self.insertAction(self.empty_action, action)
             action.setCheckable(True)
             button = self.widgetForAction(action)
             self.tag_button_group.addButton(button, id=len(self.db_map_ids))
             self.actions.append(action)
             self.db_map_ids.append([(db_map, parameter_tag["id"])])
             action_texts.append(action.text())
Ejemplo n.º 28
0
 def __initialize_file_menu(self):
     file_menu = self.window.menuBar().addMenu(self.window.tr("&File"))
     file_submenu = file_menu.addMenu("Save")
     save_action = QAction("Save", self)
     file_submenu.addAction(save_action)
     rgbd = QAction("RGBD", self)
     rgbd.setCheckable(True)
     rgbd.setChecked(False)
     file_submenu.addAction(rgbd)
     laser = QAction("Laser", self)
     laser.setCheckable(True)
     laser.setChecked(False)
     file_submenu.addAction(laser)
     # save_action
     save_action.triggered.connect(
         lambda: self.__save_json_file(rgbd, laser))
Ejemplo n.º 29
0
    def __add_project_to_menu(self, project: "Project"):
        """Creates a new entry for the passed project. Clicking on the project will make
        it the active project on the project manager."""
        project_action = QAction(project.name, self)
        project_action.setCheckable(True)

        index = self.__project_manager.projects.index(project)

        project_action.triggered.connect(
            lambda _=False, index=index: self.__project_manager.
            set_active_project(index))

        self.__projects_actions_group.addAction(project_action)
        self.addAction(project_action)

        LOGGER.debug("Created ProjectMenu Action (Index %s): %s", index,
                     project_action)
Ejemplo n.º 30
0
class SettingsMenu(QMenu):
    def __init__(self, ui):
        super(SettingsMenu, self).__init__(_('Einstellungen'), ui)
        self.ui = ui

        check_icon = IconRsc.get_icon('check_box_empty')
        check_icon.addPixmap(IconRsc.get_pixmap('check_box'), QIcon.Normal,
                             QIcon.On)

        self.open_action = QAction(
            check_icon, _('PSD Datei nach dem Erstellen automatisch öffnen'),
            self)
        self.open_action.setCheckable(True)
        self.open_action.setChecked(AppSettings.app['open_editor'])
        self.open_action.toggled.connect(self.toggle_psd_open_action)
        self.addAction(self.open_action)

        self.addSeparator()

        img_icon = IconRsc.get_icon('setting')
        set_ps_path = QAction(img_icon, _('Erweiterte Einstellungen'), self)
        set_ps_path.triggered.connect(self.open_settings_dialog)
        self.addAction(set_ps_path)

    def toggle_psd_open_action(self):
        AppSettings.app['open_editor'] = self.open_action.isChecked()

    def update_btn_desc(self):
        editor = Path(AppSettings.app['editor_path'])

        if editor.exists() and editor.is_file():
            self.ui.lastFileBtn.setDescription(
                _('Mit benutzerdefiniertem Editor öffnen'))
        else:
            self.ui.lastFileBtn.setDescription(
                _('Mit Standardanwendung öffnen'))

        # Update resolution buttons from app settings
        self.ui.update_resolution(from_settings=True)

    def open_settings_dialog(self):
        psd_settings_window = PhotoshopSettings(self.ui)
        psd_settings_window.accepted.connect(self.update_btn_desc)
        psd_settings_window.rejected.connect(self.update_btn_desc)
        psd_settings_window.open()