75 lines
3.1 KiB
QML
75 lines
3.1 KiB
QML
pragma ComponentBehavior: Bound
|
|
import QtQuick
|
|
import QtQuick.Controls.Material
|
|
import QtQuick.Controls
|
|
import QtQuick.Layouts
|
|
import "services"
|
|
import "services/HardwarePolicy.js" as HardwarePolicy
|
|
import "components"
|
|
|
|
Item {
|
|
id: settings
|
|
signal navigate(string name)
|
|
Material.theme: Theme.dark ? Material.Dark : Material.Light
|
|
Material.accent: Theme.primary
|
|
property bool active: visible
|
|
readonly property bool wide: width >= 700
|
|
// Keep a stable identifier when devices appear/disappear. Never persist a
|
|
// numeric index: hotplug would otherwise open an unrelated settings page.
|
|
property string selectedSection: "appearance"
|
|
readonly property var sections: HardwarePolicy.visibleSettingsSections(
|
|
Hardware.outputs.length > 0 || Hardware.inputs.length > 0 || Hardware.sink !== null || Hardware.source !== null,
|
|
Hardware.networkReady && (Hardware.networks.length > 0 || Hardware.wifiPresent),
|
|
Hardware.bluetoothAdapters.length > 0, Modems.present, Hardware.batteries.length > 0)
|
|
readonly property int selectedIndex: HardwarePolicy.sectionIndex(sections, selectedSection)
|
|
readonly property string currentSection: selectedIndex >= 0 ? selectedSection : "appearance"
|
|
readonly property int currentPage: HardwarePolicy.pageIndex(currentSection)
|
|
|
|
RowLayout {
|
|
anchors.fill: parent
|
|
spacing: 24
|
|
ColumnLayout {
|
|
visible: settings.wide
|
|
Layout.preferredWidth: 190
|
|
Layout.fillHeight: true
|
|
Repeater {
|
|
model: settings.sections
|
|
ActionButton {
|
|
required property var modelData
|
|
Layout.fillWidth: true
|
|
text: modelData.title
|
|
checked: settings.currentSection === modelData.id
|
|
onClicked: settings.selectedSection = modelData.id
|
|
}
|
|
}
|
|
Item { Layout.fillHeight: true }
|
|
}
|
|
ColumnLayout {
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
ComboBox {
|
|
visible: !settings.wide
|
|
Layout.fillWidth: true
|
|
textRole: "title"
|
|
model: settings.sections
|
|
currentIndex: settings.selectedIndex >= 0 ? settings.selectedIndex : 0
|
|
onActivated: index => settings.selectedSection = settings.sections[index].id
|
|
}
|
|
StackLayout {
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
currentIndex: settings.currentPage
|
|
AppearanceSettings { onNavigate: name => settings.navigate(name) }
|
|
AudioSettings {}
|
|
NetworkSettings { active: settings.active && settings.currentSection === "network" }
|
|
WallpaperSettings {}
|
|
BluetoothSettings { active: settings.active && settings.currentSection === "bluetooth" }
|
|
ModemSettings {}
|
|
SystemSettings {}
|
|
BatterySettings {}
|
|
DisplaySettings {}
|
|
}
|
|
}
|
|
}
|
|
}
|