sidebar: night light dialog

This commit is contained in:
end-4
2025-10-22 22:16:58 +02:00
parent 6ed9c9869e
commit bb08c61b76
9 changed files with 244 additions and 47 deletions
@@ -7,8 +7,9 @@ Rectangle {
radius: Appearance.rounding.normal
color: Appearance.colors.colLayer1
signal openWifiDialog()
signal openBluetoothDialog()
signal openAudioOutputDialog()
signal openAudioInputDialog()
signal openBluetoothDialog()
signal openNightLightDialog()
signal openWifiDialog()
}
@@ -12,15 +12,23 @@ AbstractQuickPanel {
id: root
property bool editMode: false
Layout.fillWidth: true
implicitHeight: (editMode ? contentItem.implicitHeight : usedRows.implicitHeight) + root.padding * 2
// Sizes
implicitHeight: (editMode ? contentItem.implicitHeight : usedRows.implicitHeight) + root.padding * 2
Behavior on implicitHeight {
animation: Appearance.animation.elementMove.numberAnimation.createObject(this)
}
property real spacing: 6
property real padding: 6
readonly property real baseCellWidth: {
// This is the wrong calculation, but it looks correct in reality???
// (theoretically spacing should be multiplied by 1 column less)
const availableWidth = root.width - (root.padding * 2) - (root.spacing * (root.columns))
return availableWidth / root.columns
}
readonly property real baseCellHeight: 56
// Toggles
readonly property list<string> availableToggleTypes: ["network", "bluetooth", "idleInhibitor", "easyEffects", "nightLight", "darkMode", "cloudflareWarp", "gameMode", "screenSnip", "colorPicker", "onScreenKeyboard", "mic", "audio", "notifications", "powerProfile"]
readonly property int columns: Config.options.sidebar.quickToggles.android.columns
readonly property list<var> toggles: Config.ready ? Config.options.sidebar.quickToggles.android.toggles : []
@@ -30,13 +38,6 @@ AbstractQuickPanel {
return types.map(type => { return { type: type, size: 1 } })
}
readonly property list<var> unusedToggleRows: toggleRowsForList(unusedToggles)
readonly property real baseCellWidth: {
// This is the wrong calculation, but it looks correct in reality???
// (theoretically spacing should be multiplied by 1 column less)
const availableWidth = root.width - (root.padding * 2) - (root.spacing * (root.columns))
return availableWidth / root.columns
}
readonly property real baseCellHeight: 56
function toggleRowsForList(togglesList) {
var rows = [];
@@ -78,7 +79,10 @@ AbstractQuickPanel {
delegate: ButtonGroup {
id: toggleRow
required property int index
property var modelData: root.toggleRows[index]
property var modelData: {
print(JSON.stringify(root.toggleRows[index]))
return root.toggleRows[index]
}
property int startingIndex: {
const rows = root.toggleRows;
let sum = 0;
@@ -100,10 +104,11 @@ AbstractQuickPanel {
baseCellWidth: root.baseCellWidth
baseCellHeight: root.baseCellHeight
spacing: root.spacing
onOpenWifiDialog: root.openWifiDialog()
onOpenBluetoothDialog: root.openBluetoothDialog()
onOpenAudioOutputDialog: root.openAudioOutputDialog()
onOpenAudioInputDialog: root.openAudioInputDialog()
onOpenBluetoothDialog: root.openBluetoothDialog()
onOpenNightLightDialog: root.openNightLightDialog()
onOpenWifiDialog: root.openWifiDialog()
}
}
}
@@ -19,7 +19,7 @@ AndroidQuickToggleButton {
}
altAction: () => {
Config.options.light.night.automatic = !Config.options.light.night.automatic
root.openMenu()
}
Component.onCompleted: {
@@ -27,7 +27,7 @@ AndroidQuickToggleButton {
}
StyledToolTip {
text: Translation.tr("Night Light | Right-click to toggle Auto mode")
text: Translation.tr("Night Light | Right-click to configure")
}
}
@@ -14,10 +14,11 @@ DelegateChooser {
required property real baseCellHeight
required property real spacing
required property int startingIndex
signal openWifiDialog()
signal openBluetoothDialog()
signal openAudioOutputDialog()
signal openAudioInputDialog()
signal openBluetoothDialog()
signal openNightLightDialog()
signal openWifiDialog()
role: "type"
@@ -90,6 +91,9 @@ DelegateChooser {
baseCellHeight: root.baseCellHeight
cellSpacing: root.spacing
cellSize: modelData.size
onOpenMenu: {
root.openNightLightDialog()
}
} }
DelegateChoice { roleValue: "darkMode"; AndroidDarkModeToggle {