You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
3.1 KiB
109 lines
3.1 KiB
/* |
|
SPDX-FileCopyrightText: 2020 Ismael Asensio <isma.af@gmail.com> |
|
|
|
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL |
|
*/ |
|
|
|
import QtQuick |
|
import QtQuick.Layouts |
|
import QtQuick.Controls as QQC2 |
|
import org.kde.kirigami 2.10 as Kirigami |
|
import org.kde.kcmutils as KCM |
|
|
|
QQC2.ItemDelegate { |
|
id: ruleDelegate |
|
|
|
property bool ruleEnabled: model.enabled |
|
|
|
Kirigami.Theme.colorSet: Kirigami.Theme.View |
|
|
|
width: ListView.view.width |
|
highlighted: false |
|
hoverEnabled: false |
|
|
|
contentItem: RowLayout { |
|
|
|
Kirigami.Icon { |
|
id: itemIcon |
|
source: model.icon |
|
Layout.preferredHeight: Kirigami.Units.iconSizes.smallMedium |
|
Layout.preferredWidth: Kirigami.Units.iconSizes.smallMedium |
|
Layout.rightMargin: Kirigami.Units.smallSpacing |
|
Layout.alignment: Qt.AlignVCenter |
|
} |
|
|
|
RowLayout { |
|
Layout.preferredWidth: 10 * Kirigami.Units.gridUnit |
|
spacing: Kirigami.Units.smallSpacing |
|
|
|
QQC2.Label { |
|
text: model.name |
|
horizontalAlignment: Text.AlignLeft |
|
elide: Text.ElideRight |
|
Layout.fillWidth: true |
|
Layout.alignment: Qt.AlignVCenter |
|
} |
|
|
|
KCM.ContextualHelpButton { |
|
Layout.preferredHeight: Kirigami.Units.gridUnit * 2 |
|
Layout.alignment: Qt.AlignVCenter |
|
visible: model.description.length > 0 |
|
toolTipText: model.description |
|
} |
|
} |
|
|
|
RowLayout { |
|
// This layout keeps the width constant between delegates, independent of items visibility |
|
Layout.fillWidth: true |
|
Layout.preferredWidth: 20 * Kirigami.Units.gridUnit |
|
Layout.minimumWidth: 13 * Kirigami.Units.gridUnit |
|
|
|
OptionsComboBox { |
|
id: policyCombo |
|
Layout.preferredWidth: 50 // 50% |
|
Layout.fillWidth: true |
|
Layout.alignment: Qt.AlignVCenter |
|
|
|
visible: count > 0 |
|
enabled: ruleEnabled |
|
|
|
model: policyModel |
|
onActivated: { |
|
policy = currentValue; |
|
} |
|
} |
|
|
|
ValueEditor { |
|
id: valueEditor |
|
Layout.preferredWidth: 50 // 50% |
|
Layout.fillWidth: true |
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight |
|
|
|
enabled: model.enabled |
|
|
|
ruleValue: model.value |
|
ruleOptions: model.options |
|
controlType: model.type |
|
|
|
onValueEdited: (value) => { |
|
model.value = value; |
|
} |
|
} |
|
|
|
QQC2.ToolButton { |
|
id: itemEnabled |
|
icon.name: "edit-delete" |
|
visible: model.selectable |
|
Layout.alignment: Qt.AlignVCenter |
|
onClicked: { |
|
model.enabled = false; |
|
} |
|
} |
|
} |
|
|
|
QQC2.ToolTip { |
|
text: model.description |
|
visible: hovered && (text.length > 0) |
|
} |
|
} |
|
}
|
|
|