Exemple #1
0
    def __init__(self,
                 parent=None,
                 option_group=None,
                 override_profiles=None,
                 override_settings=None):
        super().__init__(parent=parent)
        self.option_group = option_group
        self.ui = Ui_AttachedProfilesDialog()
        self.ui.setupUi(self)
        self.ui.buttonBox.addButton(StandardButton(StandardButton.CLOSE),
                                    QtWidgets.QDialogButtonBox.RejectRole)
        self.ui.buttonBox.rejected.connect(self.close_window)

        config = get_config()
        if override_profiles is None or override_settings is None:
            self.profiles = config.profiles[SettingConfigSection.PROFILES_KEY]
            self.settings = config.profiles[SettingConfigSection.SETTINGS_KEY]
        else:
            self.profiles = override_profiles
            self.settings = override_settings

        self.populate_table()

        self.ui.buttonBox.setFocus()
        self.setModal(True)
Exemple #2
0
    def __init__(self, parent=None, option_group=None):
        super().__init__(parent=parent)
        self.option_group = option_group
        self.ui = Ui_AttachedProfilesDialog()
        self.ui.setupUi(self)
        self.ui.buttonBox.addButton(StandardButton(StandardButton.CLOSE),
                                    QtWidgets.QDialogButtonBox.RejectRole)
        self.ui.buttonBox.rejected.connect(self.close_window)

        self.populate_table()

        self.ui.buttonBox.setFocus()
        self.setModal(True)
Exemple #3
0
class AttachedProfilesDialog(PicardDialog):
    NAME = 'attachedprofiles'
    TITLE = N_('Attached Profiles')

    def __init__(self,
                 parent=None,
                 option_group=None,
                 override_profiles=None,
                 override_settings=None):
        super().__init__(parent=parent)
        self.option_group = option_group
        self.ui = Ui_AttachedProfilesDialog()
        self.ui.setupUi(self)
        self.ui.buttonBox.addButton(StandardButton(StandardButton.CLOSE),
                                    QtWidgets.QDialogButtonBox.RejectRole)
        self.ui.buttonBox.rejected.connect(self.close_window)

        config = get_config()
        if override_profiles is None or override_settings is None:
            self.profiles = config.profiles[SettingConfigSection.PROFILES_KEY]
            self.settings = config.profiles[SettingConfigSection.SETTINGS_KEY]
        else:
            self.profiles = override_profiles
            self.settings = override_settings

        self.populate_table()

        self.ui.buttonBox.setFocus()
        self.setModal(True)

    def populate_table(self):
        model = QtGui.QStandardItemModel()
        model.setColumnCount(2)
        header_names = [_("Option Setting"), _("Attached Profiles")]
        model.setHorizontalHeaderLabels(header_names)

        group = UserProfileGroups.SETTINGS_GROUPS[self.option_group]
        group_title = group["title"]
        group_options = group["settings"]

        window_title = _(
            "Profiles Attached to Options in %s Section") % group_title
        self.setWindowTitle(window_title)

        for name, title, object_name in group_options:
            option_item = QtGui.QStandardItem(_(title))
            option_item.setEditable(False)
            row = [option_item]
            attached = []
            for profile in self.profiles:
                if name in self.settings[profile["id"]]:
                    attached.append("{0}{1}".format(
                        profile["title"],
                        _(" [Enabled]") if profile["enabled"] else "",
                    ))
            attached_profiles = "\n".join(attached) if attached else _("None")
            profile_item = QtGui.QStandardItem(attached_profiles)
            profile_item.setEditable(False)
            row.append(profile_item)
            model.appendRow(row)

        self.ui.options_list.setModel(model)
        self.ui.options_list.resizeColumnsToContents()
        self.ui.options_list.resizeRowsToContents()
        self.ui.options_list.horizontalHeader().setStretchLastSection(True)

    def close_window(self):
        """Close the script metadata editor window.
        """
        self.close()