1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -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.Services
import qs.Widgets
import qs.Modules.Settings.Widgets
Item {
id: root
@@ -96,47 +97,39 @@ Item {
rightPadding: Theme.spacingM
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
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")
currentValue: SessionData.nightModeTemperature + "K"
options: {
var temps = [];
for (var i = 2500; i <= 6000; i += 500) {
temps.push(i + "K");
}
return temps;
}
onValueChanged: value => {
var temp = parseInt(value.replace("K", ""));
SessionData.setNightModeTemperature(temp);
if (SessionData.nightModeHighTemperature < temp) {
SessionData.setNightModeHighTemperature(temp);
}
minimum: 2500
maximum: 6000
step: 100
unit: "K"
value: SessionData.nightModeTemperature
onSliderValueChanged: newValue => {
SessionData.setNightModeTemperature(newValue);
if (SessionData.nightModeHighTemperature < newValue)
SessionData.setNightModeHighTemperature(newValue);
}
}
DankDropdown {
SettingsSliderRow {
id: dayTempSlider
settingKey: "nightModeHighTemperature"
tags: ["gamma", "day", "temperature", "kelvin", "color"]
width: parent.width - parent.leftPadding - parent.rightPadding
text: I18n.tr("Day Temperature")
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
options: {
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);
}
}
onSliderValueChanged: newValue => SessionData.setNightModeHighTemperature(newValue)
}
}

View File

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

View File

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

View File

@@ -748,6 +748,32 @@
],
"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",
"label": "Show All Tags",
@@ -793,26 +819,6 @@
"description": "Display only workspaces that contain windows",
"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",
"label": "Show Workspace Apps",
@@ -1565,24 +1571,6 @@
"theme"
]
},
{
"section": "matugenTemplateZenBrowser",
"label": "Zen Browser",
"tabIndex": 10,
"category": "Theme & Colors",
"keywords": [
"appearance",
"colors",
"zen",
"zenbrowser",
"look",
"matugen",
"scheme",
"style",
"template",
"theme"
]
},
{
"section": "matugenTemplateGtk",
"label": "GTK",
@@ -2360,6 +2348,23 @@
"vesktop"
]
},
{
"section": "matugenTemplateZenBrowser",
"label": "zenbrowser",
"tabIndex": 10,
"category": "Theme & Colors",
"keywords": [
"appearance",
"colors",
"look",
"matugen",
"scheme",
"style",
"template",
"theme",
"zenbrowser"
]
},
{
"section": "lockScreenActiveMonitor",
"label": "Active Lock Screen Monitor",
@@ -3582,16 +3587,18 @@
"cliphist",
"copy",
"disable",
"entirely",
"disk",
"history",
"linux",
"manager",
"nothing",
"os",
"paste",
"system"
"saved",
"system",
"works"
],
"icon": "tune",
"description": "Disable clipboard manager entirely (requires restart)"
"description": "Clipboard works but nothing saved to disk"
},
{
"section": "autoClearDays",
@@ -3633,29 +3640,6 @@
"icon": "settings",
"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",
"label": "History Settings",
@@ -3700,5 +3684,57 @@
"system"
],
"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"
}
]