1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-29 16:02:51 -05:00

brightness: rename logarithmic to exponential

This commit is contained in:
bbedward
2025-11-05 10:18:19 -05:00
parent ae5d6c1ba4
commit 8167c432b8
5 changed files with 57 additions and 57 deletions

View File

@@ -60,7 +60,7 @@ Singleton {
property bool showThirdPartyPlugins: false property bool showThirdPartyPlugins: false
property string launchPrefix: "" property string launchPrefix: ""
property string lastBrightnessDevice: "" property string lastBrightnessDevice: ""
property var brightnessLogarithmicDevices: ({}) property var brightnessExponentialDevices: ({})
property var brightnessUserSetValues: ({}) property var brightnessUserSetValues: ({})
property int selectedGpuIndex: 0 property int selectedGpuIndex: 0
@@ -109,7 +109,7 @@ Singleton {
wallpaperPathDark = settings.wallpaperPathDark !== undefined ? settings.wallpaperPathDark : "" wallpaperPathDark = settings.wallpaperPathDark !== undefined ? settings.wallpaperPathDark : ""
monitorWallpapersLight = settings.monitorWallpapersLight !== undefined ? settings.monitorWallpapersLight : {} monitorWallpapersLight = settings.monitorWallpapersLight !== undefined ? settings.monitorWallpapersLight : {}
monitorWallpapersDark = settings.monitorWallpapersDark !== undefined ? settings.monitorWallpapersDark : {} monitorWallpapersDark = settings.monitorWallpapersDark !== undefined ? settings.monitorWallpapersDark : {}
brightnessLogarithmicDevices = settings.brightnessLogarithmicDevices !== undefined ? settings.brightnessLogarithmicDevices : {} brightnessExponentialDevices = settings.brightnessExponentialDevices !== undefined ? settings.brightnessExponentialDevices : (settings.brightnessLogarithmicDevices || {})
brightnessUserSetValues = settings.brightnessUserSetValues !== undefined ? settings.brightnessUserSetValues : {} brightnessUserSetValues = settings.brightnessUserSetValues !== undefined ? settings.brightnessUserSetValues : {}
doNotDisturb = settings.doNotDisturb !== undefined ? settings.doNotDisturb : false doNotDisturb = settings.doNotDisturb !== undefined ? settings.doNotDisturb : false
nightModeEnabled = settings.nightModeEnabled !== undefined ? settings.nightModeEnabled : false nightModeEnabled = settings.nightModeEnabled !== undefined ? settings.nightModeEnabled : false
@@ -189,7 +189,7 @@ Singleton {
"wallpaperPathDark": wallpaperPathDark, "wallpaperPathDark": wallpaperPathDark,
"monitorWallpapersLight": monitorWallpapersLight, "monitorWallpapersLight": monitorWallpapersLight,
"monitorWallpapersDark": monitorWallpapersDark, "monitorWallpapersDark": monitorWallpapersDark,
"brightnessLogarithmicDevices": brightnessLogarithmicDevices, "brightnessExponentialDevices": brightnessExponentialDevices,
"brightnessUserSetValues": brightnessUserSetValues, "brightnessUserSetValues": brightnessUserSetValues,
"doNotDisturb": doNotDisturb, "doNotDisturb": doNotDisturb,
"nightModeEnabled": nightModeEnabled, "nightModeEnabled": nightModeEnabled,
@@ -274,7 +274,7 @@ Singleton {
} }
function cleanupUnusedKeys() { function cleanupUnusedKeys() {
const validKeys = ["isLightMode", "wallpaperPath", "perMonitorWallpaper", "monitorWallpapers", "perModeWallpaper", "wallpaperPathLight", "wallpaperPathDark", "monitorWallpapersLight", "monitorWallpapersDark", "doNotDisturb", "nightModeEnabled", "nightModeTemperature", "nightModeHighTemperature", "nightModeAutoEnabled", "nightModeAutoMode", "nightModeStartHour", "nightModeStartMinute", "nightModeEndHour", "nightModeEndMinute", "latitude", "longitude", "nightModeUseIPLocation", "nightModeLocationProvider", "pinnedApps", "selectedGpuIndex", "nvidiaGpuTempEnabled", "nonNvidiaGpuTempEnabled", "enabledGpuPciIds", "wallpaperCyclingEnabled", "wallpaperCyclingMode", "wallpaperCyclingInterval", "wallpaperCyclingTime", "monitorCyclingSettings", "lastBrightnessDevice", "brightnessLogarithmicDevices", "brightnessUserSetValues", "launchPrefix", "wallpaperTransition", "includedTransitions", "recentColors", "showThirdPartyPlugins", "configVersion"] const validKeys = ["isLightMode", "wallpaperPath", "perMonitorWallpaper", "monitorWallpapers", "perModeWallpaper", "wallpaperPathLight", "wallpaperPathDark", "monitorWallpapersLight", "monitorWallpapersDark", "doNotDisturb", "nightModeEnabled", "nightModeTemperature", "nightModeHighTemperature", "nightModeAutoEnabled", "nightModeAutoMode", "nightModeStartHour", "nightModeStartMinute", "nightModeEndHour", "nightModeEndMinute", "latitude", "longitude", "nightModeUseIPLocation", "nightModeLocationProvider", "pinnedApps", "selectedGpuIndex", "nvidiaGpuTempEnabled", "nonNvidiaGpuTempEnabled", "enabledGpuPciIds", "wallpaperCyclingEnabled", "wallpaperCyclingMode", "wallpaperCyclingInterval", "wallpaperCyclingTime", "monitorCyclingSettings", "lastBrightnessDevice", "brightnessExponentialDevices", "brightnessUserSetValues", "launchPrefix", "wallpaperTransition", "includedTransitions", "recentColors", "showThirdPartyPlugins", "configVersion"]
try { try {
const content = settingsFile.text() const content = settingsFile.text()
@@ -662,14 +662,14 @@ Singleton {
saveSettings() saveSettings()
} }
function setBrightnessLogarithmic(deviceName, enabled) { function setBrightnessExponential(deviceName, enabled) {
var newSettings = Object.assign({}, brightnessLogarithmicDevices) var newSettings = Object.assign({}, brightnessExponentialDevices)
if (enabled) { if (enabled) {
newSettings[deviceName] = true newSettings[deviceName] = true
} else { } else {
delete newSettings[deviceName] delete newSettings[deviceName]
} }
brightnessLogarithmicDevices = newSettings brightnessExponentialDevices = newSettings
saveSettings() saveSettings()
if (typeof DisplayService !== "undefined") { if (typeof DisplayService !== "undefined") {
@@ -677,8 +677,8 @@ Singleton {
} }
} }
function getBrightnessLogarithmic(deviceName) { function getBrightnessExponential(deviceName) {
return brightnessLogarithmicDevices[deviceName] === true return brightnessExponentialDevices[deviceName] === true
} }
function setBrightnessUserSetValue(deviceName, value) { function setBrightnessUserSetValue(deviceName, value) {

View File

@@ -316,7 +316,7 @@ Rectangle {
width: parent.width width: parent.width
height: 24 height: 24
radius: height / 2 radius: height / 2
color: SessionData.getBrightnessLogarithmic(modelData.name) ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : Theme.withAlpha(Theme.surfaceText, 0.05) color: SessionData.getBrightnessExponential(modelData.name) ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : Theme.withAlpha(Theme.surfaceText, 0.05)
Row { Row {
anchors.centerIn: parent anchors.centerIn: parent
@@ -325,14 +325,14 @@ Rectangle {
DankIcon { DankIcon {
name: "show_chart" name: "show_chart"
size: 14 size: 14
color: SessionData.getBrightnessLogarithmic(modelData.name) ? Theme.primary : Theme.surfaceText color: SessionData.getBrightnessExponential(modelData.name) ? Theme.primary : Theme.surfaceText
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
StyledText { StyledText {
text: SessionData.getBrightnessLogarithmic(modelData.name) ? "Logarithmic" : "Linear" text: SessionData.getBrightnessExponential(modelData.name) ? "Exponential" : "Linear"
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
color: SessionData.getBrightnessLogarithmic(modelData.name) ? Theme.primary : Theme.surfaceText color: SessionData.getBrightnessExponential(modelData.name) ? Theme.primary : Theme.surfaceText
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
} }
} }
@@ -341,8 +341,8 @@ Rectangle {
anchors.fill: parent anchors.fill: parent
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
const currentState = SessionData.getBrightnessLogarithmic(modelData.name) const currentState = SessionData.getBrightnessExponential(modelData.name)
SessionData.setBrightnessLogarithmic(modelData.name, !currentState) SessionData.setBrightnessExponential(modelData.name, !currentState)
} }
} }
} }

View File

@@ -148,16 +148,16 @@ Row {
enabled: DisplayService.brightnessAvailable && targetDeviceName.length > 0 enabled: DisplayService.brightnessAvailable && targetDeviceName.length > 0
minimum: { minimum: {
if (!targetDevice) return 1 if (!targetDevice) return 1
const isLogarithmic = SessionData.getBrightnessLogarithmic(targetDevice.id) const isExponential = SessionData.getBrightnessExponential(targetDevice.id)
if (isLogarithmic) { if (isExponential) {
return 1 return 1
} }
return (targetDevice.class === "backlight" || targetDevice.class === "ddc") ? 1 : 0 return (targetDevice.class === "backlight" || targetDevice.class === "ddc") ? 1 : 0
} }
maximum: { maximum: {
if (!targetDevice) return 100 if (!targetDevice) return 100
const isLogarithmic = SessionData.getBrightnessLogarithmic(targetDevice.id) const isExponential = SessionData.getBrightnessExponential(targetDevice.id)
if (isLogarithmic) { if (isExponential) {
return 100 return 100
} }
return targetDevice.displayMax || 100 return targetDevice.displayMax || 100
@@ -166,8 +166,8 @@ Row {
showValue: true showValue: true
unit: { unit: {
if (!targetDevice) return "%" if (!targetDevice) return "%"
const isLogarithmic = SessionData.getBrightnessLogarithmic(targetDevice.id) const isExponential = SessionData.getBrightnessExponential(targetDevice.id)
if (isLogarithmic) { if (isExponential) {
return "%" return "%"
} }
return targetDevice.class === "ddc" ? "" : "%" return targetDevice.class === "ddc" ? "" : "%"

View File

@@ -65,8 +65,8 @@ DankOSD {
minimum: { minimum: {
const deviceInfo = DisplayService.getCurrentDeviceInfo() const deviceInfo = DisplayService.getCurrentDeviceInfo()
if (!deviceInfo) return 1 if (!deviceInfo) return 1
const isLogarithmic = SessionData.getBrightnessLogarithmic(deviceInfo.id) const isExponential = SessionData.getBrightnessExponential(deviceInfo.id)
if (isLogarithmic) { if (isExponential) {
return 1 return 1
} }
return (deviceInfo.class === "backlight" || deviceInfo.class === "ddc") ? 1 : 0 return (deviceInfo.class === "backlight" || deviceInfo.class === "ddc") ? 1 : 0
@@ -74,8 +74,8 @@ DankOSD {
maximum: { maximum: {
const deviceInfo = DisplayService.getCurrentDeviceInfo() const deviceInfo = DisplayService.getCurrentDeviceInfo()
if (!deviceInfo) return 100 if (!deviceInfo) return 100
const isLogarithmic = SessionData.getBrightnessLogarithmic(deviceInfo.id) const isExponential = SessionData.getBrightnessExponential(deviceInfo.id)
if (isLogarithmic) { if (isExponential) {
return 100 return 100
} }
return deviceInfo.displayMax || 100 return deviceInfo.displayMax || 100
@@ -85,8 +85,8 @@ DankOSD {
unit: { unit: {
const deviceInfo = DisplayService.getCurrentDeviceInfo() const deviceInfo = DisplayService.getCurrentDeviceInfo()
if (!deviceInfo) return "%" if (!deviceInfo) return "%"
const isLogarithmic = SessionData.getBrightnessLogarithmic(deviceInfo.id) const isExponential = SessionData.getBrightnessExponential(deviceInfo.id)
if (isLogarithmic) { if (isExponential) {
return "%" return "%"
} }
return deviceInfo.class === "ddc" ? "" : "%" return deviceInfo.class === "ddc" ? "" : "%"

View File

@@ -64,15 +64,15 @@ Singleton {
devices = newDevices devices = newDevices
} }
const isLogarithmic = SessionData.getBrightnessLogarithmic(device.id) const isExponential = SessionData.getBrightnessExponential(device.id)
const userSetValue = deviceBrightnessUserSet[device.id] const userSetValue = deviceBrightnessUserSet[device.id]
let displayValue = device.currentPercent let displayValue = device.currentPercent
if (isLogarithmic) { if (isExponential) {
if (userSetValue !== undefined) { if (userSetValue !== undefined) {
displayValue = userSetValue displayValue = userSetValue
} else { } else {
displayValue = linearToLogarithmic(device.currentPercent) displayValue = linearToExponential(device.currentPercent)
} }
} }
@@ -110,14 +110,14 @@ Singleton {
const newBrightness = {} const newBrightness = {}
for (const device of state.devices) { for (const device of state.devices) {
const isLogarithmic = SessionData.getBrightnessLogarithmic(device.id) const isExponential = SessionData.getBrightnessExponential(device.id)
const userSetValue = deviceBrightnessUserSet[device.id] const userSetValue = deviceBrightnessUserSet[device.id]
if (isLogarithmic) { if (isExponential) {
if (userSetValue !== undefined) { if (userSetValue !== undefined) {
newBrightness[device.id] = userSetValue newBrightness[device.id] = userSetValue
} else { } else {
newBrightness[device.id] = linearToLogarithmic(device.currentPercent) newBrightness[device.id] = linearToExponential(device.currentPercent)
} }
} else { } else {
newBrightness[device.id] = device.currentPercent newBrightness[device.id] = device.currentPercent
@@ -155,12 +155,12 @@ Singleton {
} }
const deviceInfo = getCurrentDeviceInfoByName(actualDevice) const deviceInfo = getCurrentDeviceInfoByName(actualDevice)
const isLogarithmic = SessionData.getBrightnessLogarithmic(actualDevice) const isExponential = SessionData.getBrightnessExponential(actualDevice)
let minValue = 0 let minValue = 0
let maxValue = 100 let maxValue = 100
if (isLogarithmic) { if (isExponential) {
minValue = 1 minValue = 1
maxValue = 100 maxValue = 100
} else { } else {
@@ -185,7 +185,7 @@ Singleton {
deviceBrightness = newBrightness deviceBrightness = newBrightness
brightnessVersion++ brightnessVersion++
if (isLogarithmic) { if (isExponential) {
const newUserSet = Object.assign({}, deviceBrightnessUserSet) const newUserSet = Object.assign({}, deviceBrightnessUserSet)
newUserSet[actualDevice] = clampedValue newUserSet[actualDevice] = clampedValue
deviceBrightnessUserSet = newUserSet deviceBrightnessUserSet = newUserSet
@@ -200,8 +200,8 @@ Singleton {
"device": actualDevice, "device": actualDevice,
"percent": clampedValue "percent": clampedValue
} }
if (isLogarithmic) { if (isExponential) {
params.logarithmic = true params.exponential = true
} }
DMSService.sendRequest("brightness.setBrightness", params, response => { DMSService.sendRequest("brightness.setBrightness", params, response => {
@@ -239,10 +239,10 @@ Singleton {
return 50 return 50
} }
function linearToLogarithmic(linearPercent) { function linearToExponential(linearPercent) {
const normalized = linearPercent / 100.0 const normalized = linearPercent / 100.0
const logPercent = Math.pow(normalized, 2.0) * 100.0 const expPercent = Math.pow(normalized, 2.0) * 100.0
return Math.round(logPercent) return Math.round(expPercent)
} }
function getDefaultDevice() { function getDefaultDevice() {
@@ -735,12 +735,12 @@ Singleton {
root.setCurrentDevice(actualDevice, false) root.setCurrentDevice(actualDevice, false)
} }
const isLogarithmic = SessionData.getBrightnessLogarithmic(actualDevice) const isExponential = SessionData.getBrightnessExponential(actualDevice)
const currentBrightness = root.getDeviceBrightness(actualDevice) const currentBrightness = root.getDeviceBrightness(actualDevice)
const deviceInfo = root.getCurrentDeviceInfoByName(actualDevice) const deviceInfo = root.getCurrentDeviceInfoByName(actualDevice)
let maxValue = 100 let maxValue = 100
if (isLogarithmic) { if (isExponential) {
maxValue = 100 maxValue = 100
} else { } else {
maxValue = deviceInfo?.displayMax || 100 maxValue = deviceInfo?.displayMax || 100
@@ -772,12 +772,12 @@ Singleton {
root.setCurrentDevice(actualDevice, false) root.setCurrentDevice(actualDevice, false)
} }
const isLogarithmic = SessionData.getBrightnessLogarithmic(actualDevice) const isExponential = SessionData.getBrightnessExponential(actualDevice)
const currentBrightness = root.getDeviceBrightness(actualDevice) const currentBrightness = root.getDeviceBrightness(actualDevice)
const deviceInfo = root.getCurrentDeviceInfoByName(actualDevice) const deviceInfo = root.getCurrentDeviceInfoByName(actualDevice)
let minValue = 0 let minValue = 0
if (isLogarithmic) { if (isExponential) {
minValue = 1 minValue = 1
} else { } else {
minValue = (deviceInfo && (deviceInfo.class === "backlight" || deviceInfo.class === "ddc")) ? 1 : 0 minValue = (deviceInfo && (deviceInfo.class === "backlight" || deviceInfo.class === "ddc")) ? 1 : 0
@@ -805,13 +805,13 @@ Singleton {
let result = "Available devices:\n" let result = "Available devices:\n"
for (const device of root.devices) { for (const device of root.devices) {
const isLog = SessionData.getBrightnessLogarithmic(device.id) const isExp = SessionData.getBrightnessExponential(device.id)
result += device.id + " (" + device.class + ")" + (isLog ? " [logarithmic]" : "") + "\n" result += device.id + " (" + device.class + ")" + (isExp ? " [exponential]" : "") + "\n"
} }
return result return result
} }
function enableLogarithmic(device: string): string { function enableExponential(device: string): string {
const targetDevice = device || root.currentDevice const targetDevice = device || root.currentDevice
if (!targetDevice) { if (!targetDevice) {
return "No device specified" return "No device specified"
@@ -821,11 +821,11 @@ Singleton {
return "Device not found: " + targetDevice return "Device not found: " + targetDevice
} }
SessionData.setBrightnessLogarithmic(targetDevice, true) SessionData.setBrightnessExponential(targetDevice, true)
return "Logarithmic mode enabled for " + targetDevice return "Exponential mode enabled for " + targetDevice
} }
function disableLogarithmic(device: string): string { function disableExponential(device: string): string {
const targetDevice = device || root.currentDevice const targetDevice = device || root.currentDevice
if (!targetDevice) { if (!targetDevice) {
return "No device specified" return "No device specified"
@@ -835,11 +835,11 @@ Singleton {
return "Device not found: " + targetDevice return "Device not found: " + targetDevice
} }
SessionData.setBrightnessLogarithmic(targetDevice, false) SessionData.setBrightnessExponential(targetDevice, false)
return "Logarithmic mode disabled for " + targetDevice return "Exponential mode disabled for " + targetDevice
} }
function toggleLogarithmic(device: string): string { function toggleExponential(device: string): string {
const targetDevice = device || root.currentDevice const targetDevice = device || root.currentDevice
if (!targetDevice) { if (!targetDevice) {
return "No device specified" return "No device specified"
@@ -849,9 +849,9 @@ Singleton {
return "Device not found: " + targetDevice return "Device not found: " + targetDevice
} }
const currentState = SessionData.getBrightnessLogarithmic(targetDevice) const currentState = SessionData.getBrightnessExponential(targetDevice)
SessionData.setBrightnessLogarithmic(targetDevice, !currentState) SessionData.setBrightnessExponential(targetDevice, !currentState)
return "Logarithmic mode " + (!currentState ? "enabled" : "disabled") + " for " + targetDevice return "Exponential mode " + (!currentState ? "enabled" : "disabled") + " for " + targetDevice
} }
target: "brightness" target: "brightness"