antiflashbang: add dedicated toggle, make disabling also restore brightness
Comment on Discussion When sdata/dist-arch/ Changes / comment_on_discussion (push) Waiting to run

This commit is contained in:
end-4
2025-11-03 21:48:26 +01:00
parent 22fb48cd0a
commit f23e9e5da9
5 changed files with 48 additions and 3 deletions
@@ -102,7 +102,7 @@ WindowDialog {
right: parent.right right: parent.right
} }
iconSize: Appearance.font.pixelSize.larger iconSize: Appearance.font.pixelSize.larger
buttonIcon: "destruction" buttonIcon: "flash_off"
text: Translation.tr("Enable") text: Translation.tr("Enable")
checked: Config.options.light.antiFlashbang.enable checked: Config.options.light.antiFlashbang.enable
onCheckedChanged: { onCheckedChanged: {
@@ -29,7 +29,7 @@ AbstractQuickPanel {
readonly property real baseCellHeight: 56 readonly property real baseCellHeight: 56
// Toggles // Toggles
readonly property list<string> availableToggleTypes: ["network", "bluetooth", "idleInhibitor", "easyEffects", "nightLight", "darkMode", "cloudflareWarp", "gameMode", "screenSnip", "colorPicker", "onScreenKeyboard", "mic", "audio", "notifications", "powerProfile","musicRecognition"] readonly property list<string> availableToggleTypes: ["network", "bluetooth", "idleInhibitor", "easyEffects", "nightLight", "darkMode", "cloudflareWarp", "gameMode", "screenSnip", "colorPicker", "onScreenKeyboard", "mic", "audio", "notifications", "powerProfile","musicRecognition", "antiFlashbang"]
readonly property int columns: Config.options.sidebar.quickToggles.android.columns readonly property int columns: Config.options.sidebar.quickToggles.android.columns
readonly property list<var> toggles: Config.ready ? Config.options.sidebar.quickToggles.android.toggles : [] readonly property list<var> toggles: Config.ready ? Config.options.sidebar.quickToggles.android.toggles : []
readonly property list<var> toggleRows: toggleRowsForList(toggles) readonly property list<var> toggleRows: toggleRowsForList(toggles)
@@ -0,0 +1,29 @@
import qs.modules.common
import qs.modules.common.widgets
import qs.services
import QtQuick
import Quickshell
AndroidQuickToggleButton {
id: root
property bool auto: Config.options.light.night.automatic
name: Translation.tr("Anti-flashbang")
toggled: Config.options.light.antiFlashbang.enable
buttonIcon: "flash_off"
mainAction: () => {
Config.options.light.antiFlashbang.enable = !Config.options.light.antiFlashbang.enable;
}
altAction: () => {
root.openMenu()
}
StyledToolTip {
text: Translation.tr("Anti-flashbang")
}
}
@@ -245,4 +245,20 @@ DelegateChooser {
cellSize: modelData.size cellSize: modelData.size
} } } }
DelegateChoice { roleValue: "antiFlashbang"; AndroidAntiFlashbangToggle {
required property int index
required property var modelData
buttonIndex: root.startingIndex + index
buttonData: modelData
editMode: root.editMode
expandedSize: modelData.size > 1
baseCellWidth: root.baseCellWidth
baseCellHeight: root.baseCellHeight
cellSpacing: root.spacing
cellSize: modelData.size
onOpenMenu: {
root.openNightLightDialog()
}
} }
} }
@@ -86,7 +86,7 @@ Singleton {
property int rawMaxBrightness: 100 property int rawMaxBrightness: 100
property real brightness property real brightness
property real brightnessMultiplier: 1.0 property real brightnessMultiplier: 1.0
property real multipliedBrightness: Math.max(0, Math.min(1, brightness * brightnessMultiplier)) property real multipliedBrightness: Math.max(0, Math.min(1, brightness * (Config.options.light.antiFlashbang.enable ? brightnessMultiplier : 1)))
property bool ready: false property bool ready: false
property bool animateChanges: !monitor.isDdc property bool animateChanges: !monitor.isDdc