settings
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import qs.Components
|
||||
import qs.Config
|
||||
import qs.Modules.Settings.Controls
|
||||
|
||||
ColumnLayout {
|
||||
id: root
|
||||
|
||||
function addTimeoutEntry() {
|
||||
let list = [...Config.general.idle.timeouts];
|
||||
|
||||
list.push({
|
||||
name: "New Entry",
|
||||
timeout: 600,
|
||||
idleAction: "lock"
|
||||
});
|
||||
|
||||
Config.general.idle.timeouts = list;
|
||||
Config.save();
|
||||
}
|
||||
|
||||
function updateTimeoutEntry(i, key, value) {
|
||||
const list = [...Config.general.idle.timeouts];
|
||||
let entry = list[i];
|
||||
|
||||
entry[key] = value;
|
||||
list[i] = entry;
|
||||
|
||||
Config.general.idle.timeouts = list;
|
||||
Config.save();
|
||||
}
|
||||
|
||||
Layout.fillWidth: true
|
||||
spacing: Appearance.spacing.smaller
|
||||
|
||||
Settings {
|
||||
name: "Idle Monitors"
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: [...Config.general.idle.timeouts]
|
||||
|
||||
SettingList {
|
||||
Layout.fillWidth: true
|
||||
|
||||
onAddActiveActionRequested: {
|
||||
root.updateTimeoutEntry(index, "activeAction", "");
|
||||
}
|
||||
onFieldEdited: function (key, value) {
|
||||
root.updateTimeoutEntry(index, key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IconButton {
|
||||
font.pointSize: Appearance.font.size.large
|
||||
icon: "add"
|
||||
|
||||
onClicked: root.addTimeoutEntry()
|
||||
}
|
||||
|
||||
component Settings: CustomRect {
|
||||
id: settingsItem
|
||||
|
||||
required property string name
|
||||
|
||||
Layout.preferredHeight: 60
|
||||
Layout.preferredWidth: 200
|
||||
|
||||
CustomText {
|
||||
id: text
|
||||
|
||||
anchors.fill: parent
|
||||
font.bold: true
|
||||
font.pointSize: Appearance.font.size.large * 2
|
||||
text: settingsItem.name
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user