mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-06 05:25:41 -05:00
brightness: rename logarithmic to exponential
This commit is contained in:
@@ -60,7 +60,7 @@ Singleton {
|
||||
property bool showThirdPartyPlugins: false
|
||||
property string launchPrefix: ""
|
||||
property string lastBrightnessDevice: ""
|
||||
property var brightnessLogarithmicDevices: ({})
|
||||
property var brightnessExponentialDevices: ({})
|
||||
property var brightnessUserSetValues: ({})
|
||||
|
||||
property int selectedGpuIndex: 0
|
||||
@@ -109,7 +109,7 @@ Singleton {
|
||||
wallpaperPathDark = settings.wallpaperPathDark !== undefined ? settings.wallpaperPathDark : ""
|
||||
monitorWallpapersLight = settings.monitorWallpapersLight !== undefined ? settings.monitorWallpapersLight : {}
|
||||
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 : {}
|
||||
doNotDisturb = settings.doNotDisturb !== undefined ? settings.doNotDisturb : false
|
||||
nightModeEnabled = settings.nightModeEnabled !== undefined ? settings.nightModeEnabled : false
|
||||
@@ -189,7 +189,7 @@ Singleton {
|
||||
"wallpaperPathDark": wallpaperPathDark,
|
||||
"monitorWallpapersLight": monitorWallpapersLight,
|
||||
"monitorWallpapersDark": monitorWallpapersDark,
|
||||
"brightnessLogarithmicDevices": brightnessLogarithmicDevices,
|
||||
"brightnessExponentialDevices": brightnessExponentialDevices,
|
||||
"brightnessUserSetValues": brightnessUserSetValues,
|
||||
"doNotDisturb": doNotDisturb,
|
||||
"nightModeEnabled": nightModeEnabled,
|
||||
@@ -274,7 +274,7 @@ Singleton {
|
||||
}
|
||||
|
||||
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 {
|
||||
const content = settingsFile.text()
|
||||
@@ -662,14 +662,14 @@ Singleton {
|
||||
saveSettings()
|
||||
}
|
||||
|
||||
function setBrightnessLogarithmic(deviceName, enabled) {
|
||||
var newSettings = Object.assign({}, brightnessLogarithmicDevices)
|
||||
function setBrightnessExponential(deviceName, enabled) {
|
||||
var newSettings = Object.assign({}, brightnessExponentialDevices)
|
||||
if (enabled) {
|
||||
newSettings[deviceName] = true
|
||||
} else {
|
||||
delete newSettings[deviceName]
|
||||
}
|
||||
brightnessLogarithmicDevices = newSettings
|
||||
brightnessExponentialDevices = newSettings
|
||||
saveSettings()
|
||||
|
||||
if (typeof DisplayService !== "undefined") {
|
||||
@@ -677,8 +677,8 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
function getBrightnessLogarithmic(deviceName) {
|
||||
return brightnessLogarithmicDevices[deviceName] === true
|
||||
function getBrightnessExponential(deviceName) {
|
||||
return brightnessExponentialDevices[deviceName] === true
|
||||
}
|
||||
|
||||
function setBrightnessUserSetValue(deviceName, value) {
|
||||
|
||||
@@ -316,7 +316,7 @@ Rectangle {
|
||||
width: parent.width
|
||||
height: 24
|
||||
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 {
|
||||
anchors.centerIn: parent
|
||||
@@ -325,14 +325,14 @@ Rectangle {
|
||||
DankIcon {
|
||||
name: "show_chart"
|
||||
size: 14
|
||||
color: SessionData.getBrightnessLogarithmic(modelData.name) ? Theme.primary : Theme.surfaceText
|
||||
color: SessionData.getBrightnessExponential(modelData.name) ? Theme.primary : Theme.surfaceText
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: SessionData.getBrightnessLogarithmic(modelData.name) ? "Logarithmic" : "Linear"
|
||||
text: SessionData.getBrightnessExponential(modelData.name) ? "Exponential" : "Linear"
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -341,8 +341,8 @@ Rectangle {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
const currentState = SessionData.getBrightnessLogarithmic(modelData.name)
|
||||
SessionData.setBrightnessLogarithmic(modelData.name, !currentState)
|
||||
const currentState = SessionData.getBrightnessExponential(modelData.name)
|
||||
SessionData.setBrightnessExponential(modelData.name, !currentState)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,16 +148,16 @@ Row {
|
||||
enabled: DisplayService.brightnessAvailable && targetDeviceName.length > 0
|
||||
minimum: {
|
||||
if (!targetDevice) return 1
|
||||
const isLogarithmic = SessionData.getBrightnessLogarithmic(targetDevice.id)
|
||||
if (isLogarithmic) {
|
||||
const isExponential = SessionData.getBrightnessExponential(targetDevice.id)
|
||||
if (isExponential) {
|
||||
return 1
|
||||
}
|
||||
return (targetDevice.class === "backlight" || targetDevice.class === "ddc") ? 1 : 0
|
||||
}
|
||||
maximum: {
|
||||
if (!targetDevice) return 100
|
||||
const isLogarithmic = SessionData.getBrightnessLogarithmic(targetDevice.id)
|
||||
if (isLogarithmic) {
|
||||
const isExponential = SessionData.getBrightnessExponential(targetDevice.id)
|
||||
if (isExponential) {
|
||||
return 100
|
||||
}
|
||||
return targetDevice.displayMax || 100
|
||||
@@ -166,8 +166,8 @@ Row {
|
||||
showValue: true
|
||||
unit: {
|
||||
if (!targetDevice) return "%"
|
||||
const isLogarithmic = SessionData.getBrightnessLogarithmic(targetDevice.id)
|
||||
if (isLogarithmic) {
|
||||
const isExponential = SessionData.getBrightnessExponential(targetDevice.id)
|
||||
if (isExponential) {
|
||||
return "%"
|
||||
}
|
||||
return targetDevice.class === "ddc" ? "" : "%"
|
||||
|
||||
@@ -65,8 +65,8 @@ DankOSD {
|
||||
minimum: {
|
||||
const deviceInfo = DisplayService.getCurrentDeviceInfo()
|
||||
if (!deviceInfo) return 1
|
||||
const isLogarithmic = SessionData.getBrightnessLogarithmic(deviceInfo.id)
|
||||
if (isLogarithmic) {
|
||||
const isExponential = SessionData.getBrightnessExponential(deviceInfo.id)
|
||||
if (isExponential) {
|
||||
return 1
|
||||
}
|
||||
return (deviceInfo.class === "backlight" || deviceInfo.class === "ddc") ? 1 : 0
|
||||
@@ -74,8 +74,8 @@ DankOSD {
|
||||
maximum: {
|
||||
const deviceInfo = DisplayService.getCurrentDeviceInfo()
|
||||
if (!deviceInfo) return 100
|
||||
const isLogarithmic = SessionData.getBrightnessLogarithmic(deviceInfo.id)
|
||||
if (isLogarithmic) {
|
||||
const isExponential = SessionData.getBrightnessExponential(deviceInfo.id)
|
||||
if (isExponential) {
|
||||
return 100
|
||||
}
|
||||
return deviceInfo.displayMax || 100
|
||||
@@ -85,8 +85,8 @@ DankOSD {
|
||||
unit: {
|
||||
const deviceInfo = DisplayService.getCurrentDeviceInfo()
|
||||
if (!deviceInfo) return "%"
|
||||
const isLogarithmic = SessionData.getBrightnessLogarithmic(deviceInfo.id)
|
||||
if (isLogarithmic) {
|
||||
const isExponential = SessionData.getBrightnessExponential(deviceInfo.id)
|
||||
if (isExponential) {
|
||||
return "%"
|
||||
}
|
||||
return deviceInfo.class === "ddc" ? "" : "%"
|
||||
|
||||
@@ -64,15 +64,15 @@ Singleton {
|
||||
devices = newDevices
|
||||
}
|
||||
|
||||
const isLogarithmic = SessionData.getBrightnessLogarithmic(device.id)
|
||||
const isExponential = SessionData.getBrightnessExponential(device.id)
|
||||
const userSetValue = deviceBrightnessUserSet[device.id]
|
||||
|
||||
let displayValue = device.currentPercent
|
||||
if (isLogarithmic) {
|
||||
if (isExponential) {
|
||||
if (userSetValue !== undefined) {
|
||||
displayValue = userSetValue
|
||||
} else {
|
||||
displayValue = linearToLogarithmic(device.currentPercent)
|
||||
displayValue = linearToExponential(device.currentPercent)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,14 +110,14 @@ Singleton {
|
||||
|
||||
const newBrightness = {}
|
||||
for (const device of state.devices) {
|
||||
const isLogarithmic = SessionData.getBrightnessLogarithmic(device.id)
|
||||
const isExponential = SessionData.getBrightnessExponential(device.id)
|
||||
const userSetValue = deviceBrightnessUserSet[device.id]
|
||||
|
||||
if (isLogarithmic) {
|
||||
if (isExponential) {
|
||||
if (userSetValue !== undefined) {
|
||||
newBrightness[device.id] = userSetValue
|
||||
} else {
|
||||
newBrightness[device.id] = linearToLogarithmic(device.currentPercent)
|
||||
newBrightness[device.id] = linearToExponential(device.currentPercent)
|
||||
}
|
||||
} else {
|
||||
newBrightness[device.id] = device.currentPercent
|
||||
@@ -155,12 +155,12 @@ Singleton {
|
||||
}
|
||||
|
||||
const deviceInfo = getCurrentDeviceInfoByName(actualDevice)
|
||||
const isLogarithmic = SessionData.getBrightnessLogarithmic(actualDevice)
|
||||
const isExponential = SessionData.getBrightnessExponential(actualDevice)
|
||||
|
||||
let minValue = 0
|
||||
let maxValue = 100
|
||||
|
||||
if (isLogarithmic) {
|
||||
if (isExponential) {
|
||||
minValue = 1
|
||||
maxValue = 100
|
||||
} else {
|
||||
@@ -185,7 +185,7 @@ Singleton {
|
||||
deviceBrightness = newBrightness
|
||||
brightnessVersion++
|
||||
|
||||
if (isLogarithmic) {
|
||||
if (isExponential) {
|
||||
const newUserSet = Object.assign({}, deviceBrightnessUserSet)
|
||||
newUserSet[actualDevice] = clampedValue
|
||||
deviceBrightnessUserSet = newUserSet
|
||||
@@ -200,8 +200,8 @@ Singleton {
|
||||
"device": actualDevice,
|
||||
"percent": clampedValue
|
||||
}
|
||||
if (isLogarithmic) {
|
||||
params.logarithmic = true
|
||||
if (isExponential) {
|
||||
params.exponential = true
|
||||
}
|
||||
|
||||
DMSService.sendRequest("brightness.setBrightness", params, response => {
|
||||
@@ -239,10 +239,10 @@ Singleton {
|
||||
return 50
|
||||
}
|
||||
|
||||
function linearToLogarithmic(linearPercent) {
|
||||
function linearToExponential(linearPercent) {
|
||||
const normalized = linearPercent / 100.0
|
||||
const logPercent = Math.pow(normalized, 2.0) * 100.0
|
||||
return Math.round(logPercent)
|
||||
const expPercent = Math.pow(normalized, 2.0) * 100.0
|
||||
return Math.round(expPercent)
|
||||
}
|
||||
|
||||
function getDefaultDevice() {
|
||||
@@ -735,12 +735,12 @@ Singleton {
|
||||
root.setCurrentDevice(actualDevice, false)
|
||||
}
|
||||
|
||||
const isLogarithmic = SessionData.getBrightnessLogarithmic(actualDevice)
|
||||
const isExponential = SessionData.getBrightnessExponential(actualDevice)
|
||||
const currentBrightness = root.getDeviceBrightness(actualDevice)
|
||||
const deviceInfo = root.getCurrentDeviceInfoByName(actualDevice)
|
||||
|
||||
let maxValue = 100
|
||||
if (isLogarithmic) {
|
||||
if (isExponential) {
|
||||
maxValue = 100
|
||||
} else {
|
||||
maxValue = deviceInfo?.displayMax || 100
|
||||
@@ -772,12 +772,12 @@ Singleton {
|
||||
root.setCurrentDevice(actualDevice, false)
|
||||
}
|
||||
|
||||
const isLogarithmic = SessionData.getBrightnessLogarithmic(actualDevice)
|
||||
const isExponential = SessionData.getBrightnessExponential(actualDevice)
|
||||
const currentBrightness = root.getDeviceBrightness(actualDevice)
|
||||
const deviceInfo = root.getCurrentDeviceInfoByName(actualDevice)
|
||||
|
||||
let minValue = 0
|
||||
if (isLogarithmic) {
|
||||
if (isExponential) {
|
||||
minValue = 1
|
||||
} else {
|
||||
minValue = (deviceInfo && (deviceInfo.class === "backlight" || deviceInfo.class === "ddc")) ? 1 : 0
|
||||
@@ -805,13 +805,13 @@ Singleton {
|
||||
|
||||
let result = "Available devices:\n"
|
||||
for (const device of root.devices) {
|
||||
const isLog = SessionData.getBrightnessLogarithmic(device.id)
|
||||
result += device.id + " (" + device.class + ")" + (isLog ? " [logarithmic]" : "") + "\n"
|
||||
const isExp = SessionData.getBrightnessExponential(device.id)
|
||||
result += device.id + " (" + device.class + ")" + (isExp ? " [exponential]" : "") + "\n"
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function enableLogarithmic(device: string): string {
|
||||
function enableExponential(device: string): string {
|
||||
const targetDevice = device || root.currentDevice
|
||||
if (!targetDevice) {
|
||||
return "No device specified"
|
||||
@@ -821,11 +821,11 @@ Singleton {
|
||||
return "Device not found: " + targetDevice
|
||||
}
|
||||
|
||||
SessionData.setBrightnessLogarithmic(targetDevice, true)
|
||||
return "Logarithmic mode enabled for " + targetDevice
|
||||
SessionData.setBrightnessExponential(targetDevice, true)
|
||||
return "Exponential mode enabled for " + targetDevice
|
||||
}
|
||||
|
||||
function disableLogarithmic(device: string): string {
|
||||
function disableExponential(device: string): string {
|
||||
const targetDevice = device || root.currentDevice
|
||||
if (!targetDevice) {
|
||||
return "No device specified"
|
||||
@@ -835,11 +835,11 @@ Singleton {
|
||||
return "Device not found: " + targetDevice
|
||||
}
|
||||
|
||||
SessionData.setBrightnessLogarithmic(targetDevice, false)
|
||||
return "Logarithmic mode disabled for " + targetDevice
|
||||
SessionData.setBrightnessExponential(targetDevice, false)
|
||||
return "Exponential mode disabled for " + targetDevice
|
||||
}
|
||||
|
||||
function toggleLogarithmic(device: string): string {
|
||||
function toggleExponential(device: string): string {
|
||||
const targetDevice = device || root.currentDevice
|
||||
if (!targetDevice) {
|
||||
return "No device specified"
|
||||
@@ -849,9 +849,9 @@ Singleton {
|
||||
return "Device not found: " + targetDevice
|
||||
}
|
||||
|
||||
const currentState = SessionData.getBrightnessLogarithmic(targetDevice)
|
||||
SessionData.setBrightnessLogarithmic(targetDevice, !currentState)
|
||||
return "Logarithmic mode " + (!currentState ? "enabled" : "disabled") + " for " + targetDevice
|
||||
const currentState = SessionData.getBrightnessExponential(targetDevice)
|
||||
SessionData.setBrightnessExponential(targetDevice, !currentState)
|
||||
return "Exponential mode " + (!currentState ? "enabled" : "disabled") + " for " + targetDevice
|
||||
}
|
||||
|
||||
target: "brightness"
|
||||
|
||||
Reference in New Issue
Block a user