コード例 #1
0
    def __init__(self, icon_path, text, toolbar, action_group, iface, settings,
                 controller, plugin_dir):
        super().__init__(icon_path, text, toolbar, action_group, iface,
                         settings, controller, plugin_dir)

        # First add the menu before adding it to the toolbar
        toolbar.removeAction(self.action)

        pg_man = PgMan(controller)
        self.feature_cat = pg_man.manage_feature_cat()

        self.edit = GwEdit(iface, settings, controller, plugin_dir)

        # Get list of different node and arc types
        menu = QMenu()
        # List of nodes from node_type_cat_type - nodes which we are using
        list_feature_cat = self.controller.get_values_from_dictionary(
            self.feature_cat)
        for feature_cat in list_feature_cat:
            if feature_cat.feature_type.upper() == 'ARC':
                obj_action = QAction(str(feature_cat.id), action_group)
                obj_action.setShortcut(
                    QKeySequence(str(feature_cat.shortcut_key)))
                try:
                    obj_action.setShortcutVisibleInContextMenu(True)
                except:
                    pass
                menu.addAction(obj_action)
                obj_action.triggered.connect(
                    partial(self.edit.edit_add_feature, feature_cat))

        self.action.setMenu(menu)
        toolbar.addAction(self.action)
コード例 #2
0
    def _fill_arc_menu(self):
        """ Fill add arc menu """

        # disconnect and remove previuos signals and actions
        actions = self.menu.actions()
        for action in actions:
            action.disconnect()
            self.menu.removeAction(action)
            del action
        action_group = self.action.property('action_group')

        # Update featurecatvalues
        global_vars.feature_cat = tools_gw.manage_feature_cat()

        # Get list of different arc types
        features_cat = global_vars.feature_cat
        if features_cat is not None:
            list_feature_cat = tools_os.get_values_from_dictionary(
                features_cat)
            for feature_cat in list_feature_cat:
                if feature_cat.feature_type.upper() == 'ARC':
                    obj_action = QAction(str(feature_cat.id), action_group)
                    obj_action.setObjectName(feature_cat.id)
                    obj_action.setProperty('action_group', action_group)
                    if f"{feature_cat.shortcut_key}" not in global_vars.shortcut_keys:
                        obj_action.setShortcut(
                            QKeySequence(str(feature_cat.shortcut_key)))
                    try:
                        obj_action.setShortcutVisibleInContextMenu(True)
                    except Exception:
                        pass
                    self.menu.addAction(obj_action)
                    obj_action.triggered.connect(
                        partial(self.info_feature.add_feature, feature_cat))
                    obj_action.triggered.connect(
                        partial(self._save_last_selection, self.menu,
                                feature_cat))