mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
feat(wallpaper): added ability for granular pick of transitions via checkboxes
This commit is contained in:
@@ -205,7 +205,14 @@
|
||||
"wallpaperChangeMode": "random",
|
||||
"randomIntervalSec": 300,
|
||||
"transitionDuration": 1500,
|
||||
"transitionType": "random",
|
||||
"transitionType": [
|
||||
"fade",
|
||||
"disc",
|
||||
"stripes",
|
||||
"wipe",
|
||||
"pixelate",
|
||||
"honeycomb"
|
||||
],
|
||||
"skipStartupTransition": false,
|
||||
"transitionEdgeSmoothness": 0.05,
|
||||
"panelPosition": "follow_bar",
|
||||
|
||||
@@ -2499,7 +2499,7 @@
|
||||
{
|
||||
"labelKey": "panels.wallpaper.look-feel-transition-type-label",
|
||||
"descriptionKey": "panels.wallpaper.look-feel-transition-type-description",
|
||||
"widget": "NComboBox",
|
||||
"widget": "NLabel",
|
||||
"tab": 3,
|
||||
"tabLabel": "common.wallpaper",
|
||||
"subTab": 1,
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import QtQuick
|
||||
|
||||
QtObject {
|
||||
function migrate(adapter, logger, rawJson) {
|
||||
logger.i("Settings", "Migrating settings to v59 (wallpaper.transitionType: string -> array)");
|
||||
|
||||
if (rawJson && rawJson.wallpaper && typeof rawJson.wallpaper.transitionType === "string") {
|
||||
var oldValue = rawJson.wallpaper.transitionType;
|
||||
var newValue;
|
||||
|
||||
if (oldValue === "random") {
|
||||
newValue = ["fade", "disc", "stripes", "wipe", "pixelate", "honeycomb"];
|
||||
} else if (oldValue === "none") {
|
||||
newValue = [];
|
||||
} else {
|
||||
newValue = [oldValue];
|
||||
}
|
||||
|
||||
adapter.wallpaper.transitionType = newValue;
|
||||
logger.i("Settings", "Migrated wallpaper.transitionType:", oldValue, "->", JSON.stringify(newValue));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,8 @@ QtObject {
|
||||
55: migration55Component,
|
||||
56: migration56Component,
|
||||
57: migration57Component,
|
||||
58: migration58Component
|
||||
58: migration58Component,
|
||||
59: migration59Component
|
||||
})
|
||||
|
||||
// Migration components
|
||||
@@ -58,4 +59,5 @@ QtObject {
|
||||
property Component migration56Component: Migration56 {}
|
||||
property Component migration57Component: Migration57 {}
|
||||
property Component migration58Component: Migration58 {}
|
||||
property Component migration59Component: Migration59 {}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ Singleton {
|
||||
- Default cache directory: ~/.cache/noctalia
|
||||
*/
|
||||
readonly property alias data: adapter // Used to access via Settings.data.xxx.yyy
|
||||
readonly property int settingsVersion: 58
|
||||
readonly property int settingsVersion: 59
|
||||
property bool isDebug: Quickshell.env("NOCTALIA_DEBUG") === "1"
|
||||
readonly property string shellName: "noctalia"
|
||||
readonly property string configDir: Quickshell.env("NOCTALIA_CONFIG_DIR") || (Quickshell.env("XDG_CONFIG_HOME") || Quickshell.env("HOME") + "/.config") + "/" + shellName + "/"
|
||||
@@ -389,7 +389,7 @@ Singleton {
|
||||
property string wallpaperChangeMode: "random" // "random" or "alphabetical"
|
||||
property int randomIntervalSec: 300 // 5 min
|
||||
property int transitionDuration: 1500 // 1500 ms
|
||||
property string transitionType: "random"
|
||||
property list<string> transitionType: ["fade", "disc", "stripes", "wipe", "pixelate", "honeycomb"]
|
||||
property bool skipStartupTransition: false
|
||||
property real transitionEdgeSmoothness: 0.05
|
||||
property string panelPosition: "follow_bar"
|
||||
|
||||
@@ -673,12 +673,15 @@ Variants {
|
||||
// ------------------------------------------------------
|
||||
// Main method that actually trigger the wallpaper change
|
||||
function changeWallpaper() {
|
||||
// Get the transitionType from the settings
|
||||
transitionType = Settings.data.wallpaper.transitionType;
|
||||
|
||||
if (transitionType == "random") {
|
||||
var index = Math.floor(Math.random() * allTransitions.length);
|
||||
transitionType = allTransitions[index];
|
||||
// Pick a transition from the user's selected list
|
||||
var selected = Settings.data.wallpaper.transitionType;
|
||||
if (!selected || selected.length === 0) {
|
||||
transitionType = "none";
|
||||
} else if (selected.length === 1) {
|
||||
transitionType = selected[0];
|
||||
} else {
|
||||
var index = Math.floor(Math.random() * selected.length);
|
||||
transitionType = selected[index];
|
||||
}
|
||||
|
||||
// Ensure the transition type really exists
|
||||
@@ -732,12 +735,15 @@ Variants {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the transitionType from the settings
|
||||
transitionType = Settings.data.wallpaper.transitionType;
|
||||
|
||||
if (transitionType == "random") {
|
||||
var index = Math.floor(Math.random() * allTransitions.length);
|
||||
transitionType = allTransitions[index];
|
||||
// Pick a transition from the user's selected list
|
||||
var selected = Settings.data.wallpaper.transitionType;
|
||||
if (!selected || selected.length === 0) {
|
||||
transitionType = "none";
|
||||
} else if (selected.length === 1) {
|
||||
transitionType = selected[0];
|
||||
} else {
|
||||
var index = Math.floor(Math.random() * selected.length);
|
||||
transitionType = selected[index];
|
||||
}
|
||||
|
||||
// Ensure the transition type really exists
|
||||
|
||||
@@ -40,7 +40,7 @@ ColumnLayout {
|
||||
]
|
||||
currentKey: Settings.data.wallpaper.wallpaperChangeMode || "random"
|
||||
onSelected: key => Settings.data.wallpaper.wallpaperChangeMode = key
|
||||
defaultValue: Settings.getDefaultValue("wallpaper.transitionType")
|
||||
defaultValue: Settings.getDefaultValue("wallpaper.wallpaperChangeMode")
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
|
||||
@@ -36,13 +36,46 @@ ColumnLayout {
|
||||
}
|
||||
}
|
||||
|
||||
NComboBox {
|
||||
label: I18n.tr("panels.wallpaper.look-feel-transition-type-label")
|
||||
description: I18n.tr("panels.wallpaper.look-feel-transition-type-description")
|
||||
model: WallpaperService.transitionsModel
|
||||
currentKey: Settings.data.wallpaper.transitionType
|
||||
onSelected: key => Settings.data.wallpaper.transitionType = key
|
||||
defaultValue: Settings.getDefaultValue("wallpaper.transitionType")
|
||||
NDivider {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
spacing: Style.marginS
|
||||
Layout.fillWidth: true
|
||||
|
||||
NLabel {
|
||||
label: I18n.tr("panels.wallpaper.look-feel-transition-type-label")
|
||||
description: I18n.tr("panels.wallpaper.look-feel-transition-type-description")
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: WallpaperService.allTransitions
|
||||
|
||||
NCheckbox {
|
||||
required property string modelData
|
||||
|
||||
label: {
|
||||
var key = "wallpaper.transitions." + modelData;
|
||||
return I18n.tr(key);
|
||||
}
|
||||
checked: Settings.data.wallpaper.transitionType.includes(modelData)
|
||||
onToggled: {
|
||||
var arr = Array.from(Settings.data.wallpaper.transitionType);
|
||||
if (checked) {
|
||||
if (!arr.includes(modelData))
|
||||
arr.push(modelData);
|
||||
} else {
|
||||
arr = arr.filter(k => k !== modelData);
|
||||
}
|
||||
Settings.data.wallpaper.transitionType = arr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NDivider {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
NToggle {
|
||||
|
||||
Reference in New Issue
Block a user