1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-30 00:12:50 -05:00

gamma: allow steps of 100 with slider

fixes #1216
This commit is contained in:
bbedward
2025-12-31 09:31:16 -05:00
parent 2dbadfe1b5
commit 651672afe2
4 changed files with 178 additions and 147 deletions

View File

@@ -2,6 +2,7 @@ import QtQuick
import qs.Common import qs.Common
import qs.Services import qs.Services
import qs.Widgets import qs.Widgets
import qs.Modules.Settings.Widgets
Item { Item {
id: root id: root
@@ -96,47 +97,39 @@ Item {
rightPadding: Theme.spacingM rightPadding: Theme.spacingM
visible: DisplayService.gammaControlAvailable visible: DisplayService.gammaControlAvailable
DankDropdown { SettingsSliderRow {
id: nightTempSlider
settingKey: "nightModeTemperature"
tags: ["gamma", "night", "temperature", "kelvin", "warm", "color", "blue light"]
width: parent.width - parent.leftPadding - parent.rightPadding width: parent.width - parent.leftPadding - parent.rightPadding
text: SessionData.nightModeAutoEnabled ? I18n.tr("Night Temperature") : I18n.tr("Color Temperature") text: SessionData.nightModeAutoEnabled ? I18n.tr("Night Temperature") : I18n.tr("Color Temperature")
description: SessionData.nightModeAutoEnabled ? I18n.tr("Color temperature for night mode") : I18n.tr("Warm color temperature to apply") description: SessionData.nightModeAutoEnabled ? I18n.tr("Color temperature for night mode") : I18n.tr("Warm color temperature to apply")
currentValue: SessionData.nightModeTemperature + "K" minimum: 2500
options: { maximum: 6000
var temps = []; step: 100
for (var i = 2500; i <= 6000; i += 500) { unit: "K"
temps.push(i + "K"); value: SessionData.nightModeTemperature
} onSliderValueChanged: newValue => {
return temps; SessionData.setNightModeTemperature(newValue);
} if (SessionData.nightModeHighTemperature < newValue)
onValueChanged: value => { SessionData.setNightModeHighTemperature(newValue);
var temp = parseInt(value.replace("K", ""));
SessionData.setNightModeTemperature(temp);
if (SessionData.nightModeHighTemperature < temp) {
SessionData.setNightModeHighTemperature(temp);
}
} }
} }
DankDropdown { SettingsSliderRow {
id: dayTempSlider
settingKey: "nightModeHighTemperature"
tags: ["gamma", "day", "temperature", "kelvin", "color"]
width: parent.width - parent.leftPadding - parent.rightPadding width: parent.width - parent.leftPadding - parent.rightPadding
text: I18n.tr("Day Temperature") text: I18n.tr("Day Temperature")
description: I18n.tr("Color temperature for day time") description: I18n.tr("Color temperature for day time")
currentValue: SessionData.nightModeHighTemperature + "K" minimum: SessionData.nightModeTemperature
maximum: 10000
step: 100
unit: "K"
value: Math.max(SessionData.nightModeHighTemperature, SessionData.nightModeTemperature)
visible: SessionData.nightModeAutoEnabled visible: SessionData.nightModeAutoEnabled
options: { onSliderValueChanged: newValue => SessionData.setNightModeHighTemperature(newValue)
var temps = [];
var minTemp = SessionData.nightModeTemperature;
for (var i = Math.max(2500, minTemp); i <= 10000; i += 500) {
temps.push(i + "K");
}
return temps;
}
onValueChanged: value => {
var temp = parseInt(value.replace("K", ""));
if (temp >= SessionData.nightModeTemperature) {
SessionData.setNightModeHighTemperature(temp);
}
}
} }
} }

View File

@@ -59,6 +59,7 @@ Item {
property alias value: slider.value property alias value: slider.value
property alias minimum: slider.minimum property alias minimum: slider.minimum
property alias maximum: slider.maximum property alias maximum: slider.maximum
property alias step: slider.step
property alias unit: slider.unit property alias unit: slider.unit
property alias wheelEnabled: slider.wheelEnabled property alias wheelEnabled: slider.wheelEnabled
property alias thumbOutlineColor: slider.thumbOutlineColor property alias thumbOutlineColor: slider.thumbOutlineColor

View File

@@ -1,5 +1,4 @@
import QtQuick import QtQuick
import QtQuick.Effects
import qs.Common import qs.Common
import qs.Widgets import qs.Widgets
@@ -9,6 +8,7 @@ Item {
property int value: 50 property int value: 50
property int minimum: 0 property int minimum: 0
property int maximum: 100 property int maximum: 100
property int step: 1
property string leftIcon: "" property string leftIcon: ""
property string rightIcon: "" property string rightIcon: ""
property bool enabled: true property bool enabled: true
@@ -29,11 +29,13 @@ Item {
height: 48 height: 48
function updateValueFromPosition(x) { function updateValueFromPosition(x) {
let ratio = Math.max(0, Math.min(1, (x - sliderHandle.width / 2) / (sliderTrack.width - sliderHandle.width))) let ratio = Math.max(0, Math.min(1, (x - sliderHandle.width / 2) / (sliderTrack.width - sliderHandle.width)));
let newValue = Math.round(minimum + ratio * (maximum - minimum)) let rawValue = minimum + ratio * (maximum - minimum);
let newValue = step > 1 ? Math.round(rawValue / step) * step : Math.round(rawValue);
newValue = Math.max(minimum, Math.min(maximum, newValue));
if (newValue !== value) { if (newValue !== value) {
value = newValue value = newValue;
sliderValueChanged(newValue) sliderValueChanged(newValue);
} }
} }
@@ -68,13 +70,12 @@ Item {
height: parent.height height: parent.height
radius: Theme.cornerRadius radius: Theme.cornerRadius
width: { width: {
const ratio = (slider.value - slider.minimum) / (slider.maximum - slider.minimum) const ratio = (slider.value - slider.minimum) / (slider.maximum - slider.minimum);
const travel = sliderTrack.width - sliderHandle.width const travel = sliderTrack.width - sliderHandle.width;
const center = (travel * ratio) + sliderHandle.width / 2 const center = (travel * ratio) + sliderHandle.width / 2;
return Math.max(0, Math.min(sliderTrack.width, center)) return Math.max(0, Math.min(sliderTrack.width, center));
} }
color: slider.enabled ? Theme.primary : Theme.withAlpha(Theme.onSurface, 0.12) color: slider.enabled ? Theme.primary : Theme.withAlpha(Theme.onSurface, 0.12)
} }
StyledRect { StyledRect {
@@ -86,16 +87,15 @@ Item {
height: 24 height: 24
radius: Theme.cornerRadius radius: Theme.cornerRadius
x: { x: {
const ratio = (slider.value - slider.minimum) / (slider.maximum - slider.minimum) const ratio = (slider.value - slider.minimum) / (slider.maximum - slider.minimum);
const travel = sliderTrack.width - width const travel = sliderTrack.width - width;
return Math.max(0, Math.min(travel, travel * ratio)) return Math.max(0, Math.min(travel, travel * ratio));
} }
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
color: slider.enabled ? Theme.primary : Theme.withAlpha(Theme.onSurface, 0.12) color: slider.enabled ? Theme.primary : Theme.withAlpha(Theme.onSurface, 0.12)
border.width: 3 border.width: 3
border.color: slider.thumbOutlineColor border.color: slider.thumbOutlineColor
StyledRect { StyledRect {
anchors.fill: parent anchors.fill: parent
radius: Theme.cornerRadius radius: Theme.cornerRadius
@@ -126,10 +126,10 @@ Item {
opacity: 0 opacity: 0
function start() { function start() {
opacity = 0.16 opacity = 0.16;
width = 0 width = 0;
height = 0 height = 0;
rippleAnimation.start() rippleAnimation.start();
} }
SequentialAnimation { SequentialAnimation {
@@ -153,12 +153,11 @@ Item {
acceptedButtons: Qt.LeftButton acceptedButtons: Qt.LeftButton
onPressedChanged: { onPressedChanged: {
if (pressed && slider.enabled) { if (pressed && slider.enabled) {
ripple.start() ripple.start();
} }
} }
} }
scale: active ? 1.05 : 1.0 scale: active ? 1.05 : 1.0
Behavior on scale { Behavior on scale {
@@ -188,43 +187,45 @@ Item {
preventStealing: true preventStealing: true
acceptedButtons: Qt.LeftButton acceptedButtons: Qt.LeftButton
onWheel: wheelEvent => { onWheel: wheelEvent => {
if (!slider.wheelEnabled) { if (!slider.wheelEnabled) {
wheelEvent.accepted = false wheelEvent.accepted = false;
return return;
} }
let step = Math.max(0.5, (maximum - minimum) / 100) let wheelStep = slider.step > 1 ? slider.step : Math.max(1, (maximum - minimum) / 100);
let newValue = wheelEvent.angleDelta.y > 0 ? Math.min(maximum, value + step) : Math.max(minimum, value - step) let newValue = wheelEvent.angleDelta.y > 0 ? Math.min(maximum, value + wheelStep) : Math.max(minimum, value - wheelStep);
newValue = Math.round(newValue) if (slider.step > 1)
if (newValue !== value) { newValue = Math.round(newValue / slider.step) * slider.step;
value = newValue newValue = Math.round(newValue);
sliderValueChanged(newValue) if (newValue !== value) {
} value = newValue;
wheelEvent.accepted = true sliderValueChanged(newValue);
} }
wheelEvent.accepted = true;
}
onPressed: mouse => { onPressed: mouse => {
if (slider.enabled) { if (slider.enabled) {
slider.isDragging = true slider.isDragging = true;
sliderMouseArea.isDragging = true sliderMouseArea.isDragging = true;
updateValueFromPosition(mouse.x) updateValueFromPosition(mouse.x);
} }
} }
onReleased: { onReleased: {
if (slider.enabled) { if (slider.enabled) {
slider.isDragging = false slider.isDragging = false;
sliderMouseArea.isDragging = false sliderMouseArea.isDragging = false;
slider.sliderDragFinished(slider.value) slider.sliderDragFinished(slider.value);
} }
} }
onPositionChanged: mouse => { onPositionChanged: mouse => {
if (pressed && slider.isDragging && slider.enabled) { if (pressed && slider.isDragging && slider.enabled) {
updateValueFromPosition(mouse.x) updateValueFromPosition(mouse.x);
} }
} }
onClicked: mouse => { onClicked: mouse => {
if (slider.enabled && !slider.isDragging) { if (slider.enabled && !slider.isDragging) {
updateValueFromPosition(mouse.x) updateValueFromPosition(mouse.x);
} }
} }
} }
} }
@@ -239,7 +240,7 @@ Item {
border.width: 1 border.width: 1
anchors.bottom: parent.top anchors.bottom: parent.top
anchors.bottomMargin: Theme.spacingM anchors.bottomMargin: Theme.spacingM
x: Math.max(0, Math.min(parent.width - width, sliderHandle.x + sliderHandle.width/2 - width/2)) x: Math.max(0, Math.min(parent.width - width, sliderHandle.x + sliderHandle.width / 2 - width / 2))
visible: slider.alwaysShowValue ? slider.showValue : ((sliderMouseArea.containsMouse && slider.showValue) || (slider.isDragging && slider.showValue)) visible: slider.alwaysShowValue ? slider.showValue : ((sliderMouseArea.containsMouse && slider.showValue) || (slider.isDragging && slider.showValue))
opacity: visible ? 1 : 0 opacity: visible ? 1 : 0

View File

@@ -748,6 +748,32 @@
], ],
"description": "Show only workspaces belonging to each specific monitor." "description": "Show only workspaces belonging to each specific monitor."
}, },
{
"section": "reverseScrolling",
"label": "Reverse Scrolling Direction",
"tabIndex": 4,
"category": "Workspaces",
"keywords": [
"desktop",
"direction",
"over",
"panel",
"reverse",
"scroll",
"scrolling",
"spaces",
"statusbar",
"switch",
"taskbar",
"topbar",
"virtual",
"virtual desktops",
"workspace",
"workspaces"
],
"description": "Reverse workspace switch direction when scrolling over the bar",
"conditionKey": "isNiri"
},
{ {
"section": "dwlShowAllTags", "section": "dwlShowAllTags",
"label": "Show All Tags", "label": "Show All Tags",
@@ -793,26 +819,6 @@
"description": "Display only workspaces that contain windows", "description": "Display only workspaces that contain windows",
"conditionKey": "isNiri" "conditionKey": "isNiri"
}, },
{
"section": "reverseScrolling",
"label": "Reverse Scrolling Direction",
"tabIndex": 4,
"category": "Workspaces",
"keywords": [
"active",
"contain",
"desktop",
"desktops",
"scroll",
"scrolling",
"reverse",
"direction",
"windows",
"workspace",
"workspaces"
],
"description": "Display only workspaces that contain windows"
},
{ {
"section": "showWorkspaceApps", "section": "showWorkspaceApps",
"label": "Show Workspace Apps", "label": "Show Workspace Apps",
@@ -1565,24 +1571,6 @@
"theme" "theme"
] ]
}, },
{
"section": "matugenTemplateZenBrowser",
"label": "Zen Browser",
"tabIndex": 10,
"category": "Theme & Colors",
"keywords": [
"appearance",
"colors",
"zen",
"zenbrowser",
"look",
"matugen",
"scheme",
"style",
"template",
"theme"
]
},
{ {
"section": "matugenTemplateGtk", "section": "matugenTemplateGtk",
"label": "GTK", "label": "GTK",
@@ -2360,6 +2348,23 @@
"vesktop" "vesktop"
] ]
}, },
{
"section": "matugenTemplateZenBrowser",
"label": "zenbrowser",
"tabIndex": 10,
"category": "Theme & Colors",
"keywords": [
"appearance",
"colors",
"look",
"matugen",
"scheme",
"style",
"template",
"theme",
"zenbrowser"
]
},
{ {
"section": "lockScreenActiveMonitor", "section": "lockScreenActiveMonitor",
"label": "Active Lock Screen Monitor", "label": "Active Lock Screen Monitor",
@@ -3582,16 +3587,18 @@
"cliphist", "cliphist",
"copy", "copy",
"disable", "disable",
"entirely", "disk",
"history", "history",
"linux", "linux",
"manager", "nothing",
"os", "os",
"paste", "paste",
"system" "saved",
"system",
"works"
], ],
"icon": "tune", "icon": "tune",
"description": "Disable clipboard manager entirely (requires restart)" "description": "Clipboard works but nothing saved to disk"
}, },
{ {
"section": "autoClearDays", "section": "autoClearDays",
@@ -3633,29 +3640,6 @@
"icon": "settings", "icon": "settings",
"description": "Clear all history when server starts" "description": "Clear all history when server starts"
}, },
{
"section": "disableHistory",
"label": "Disable History Persistence",
"tabIndex": 23,
"category": "System",
"keywords": [
"clipboard",
"cliphist",
"copy",
"disable",
"disk",
"history",
"linux",
"nothing",
"os",
"paste",
"persistence",
"saved",
"system",
"works"
],
"description": "Clipboard works but nothing saved to disk"
},
{ {
"section": "maxHistory", "section": "maxHistory",
"label": "History Settings", "label": "History Settings",
@@ -3700,5 +3684,57 @@
"system" "system"
], ],
"description": "Maximum size per clipboard entry" "description": "Maximum size per clipboard entry"
},
{
"section": "nightModeHighTemperature",
"label": "Day Temperature",
"tabIndex": 25,
"category": "Displays",
"keywords": [
"celsius",
"color",
"colour",
"day",
"displays",
"fahrenheit",
"gamma",
"hue",
"kelvin",
"monitor",
"resolution",
"screen",
"temp",
"temperature",
"time",
"tint"
],
"description": "Color temperature for day time"
},
{
"section": "nightModeTemperature",
"label": "Night Temperature",
"tabIndex": 25,
"category": "Displays",
"keywords": [
"blue light",
"celsius",
"color",
"colour",
"displays",
"fahrenheit",
"gamma",
"hue",
"kelvin",
"mode",
"monitor",
"night",
"resolution",
"screen",
"temp",
"temperature",
"tint",
"warm"
],
"description": "Color temperature for night mode"
} }
] ]