Add wallpaper mode controls
This commit is contained in:
@@ -68,7 +68,8 @@ Singleton {
|
||||
{ label: "System Health", detail: "Check Panama services, integrations, tools, and recovery actions", page: "services" },
|
||||
{ label: "Copy health report", detail: "Copy a redacted Panama doctor report", page: "services" },
|
||||
{ label: "Lock screen background", detail: "Choose a blurred desktop, wallpaper, or solid colour", page: "appearance" },
|
||||
{ label: "Password field", detail: "Choose whether the empty lock-screen field stays visible", page: "appearance" }
|
||||
{ label: "Password field", detail: "Choose whether the empty lock-screen field stays visible", page: "appearance" },
|
||||
{ label: "Per-display wallpaper", detail: "Assign a different image to each connected display", page: "appearance" }
|
||||
]
|
||||
|
||||
function pageFor(group: string): string {
|
||||
@@ -96,7 +97,8 @@ Singleton {
|
||||
for (const entry of PreferenceSchema.entries) {
|
||||
if (entry.internal)
|
||||
continue;
|
||||
const haystack = `${entry.label} ${entry.detail ?? ""} ${entry.group}`.toLowerCase();
|
||||
const optionLabels = (entry.options ?? []).map(option => option.label).join(" ");
|
||||
const haystack = `${entry.label} ${entry.detail ?? ""} ${entry.group} ${optionLabels}`.toLowerCase();
|
||||
if (haystack.indexOf(needle) >= 0)
|
||||
add(entry.label, entry.detail ?? "", root.pageFor(entry.group), "setting");
|
||||
}
|
||||
@@ -113,8 +115,16 @@ Singleton {
|
||||
|
||||
// Exact prefix matches first: typing "blur" should put "Blur" above
|
||||
// "Blur radius", and both above a setting that merely mentions blur in
|
||||
// its explanation.
|
||||
// its explanation. An exact enum option also leads: "slideshow" is a
|
||||
// mode choice, so Wallpaper mode belongs above the interval row that
|
||||
// merely explains it.
|
||||
return results.sort((a, b) => {
|
||||
const aSpec = PreferenceSchema.entries.find(entry => entry.label === a.label);
|
||||
const bSpec = PreferenceSchema.entries.find(entry => entry.label === b.label);
|
||||
const ao = (aSpec?.options ?? []).some(option => option.label.toLowerCase() === needle);
|
||||
const bo = (bSpec?.options ?? []).some(option => option.label.toLowerCase() === needle);
|
||||
if (ao !== bo)
|
||||
return ao ? -1 : 1;
|
||||
const al = a.label.toLowerCase();
|
||||
const bl = b.label.toLowerCase();
|
||||
const ap = al === needle ? 0 : (al.indexOf(needle) === 0 ? 1 : 2);
|
||||
|
||||
@@ -368,6 +368,55 @@ Singleton {
|
||||
return root.applyPolicy(policy, true, false);
|
||||
}
|
||||
|
||||
function setMode(mode: string): bool {
|
||||
if (!["single", "slideshow", "per-monitor"].includes(mode))
|
||||
return false;
|
||||
const policy = root.currentPolicy();
|
||||
policy.mode = mode;
|
||||
if (mode === "slideshow") {
|
||||
const collection = WallpaperPolicy.validCollection(
|
||||
policy.collection, root.candidates([]));
|
||||
if (!collection.includes(policy.slideshowPath))
|
||||
policy.slideshowPath = collection[0] || policy.globalPath;
|
||||
}
|
||||
return root.applyPolicy(policy, true, false);
|
||||
}
|
||||
|
||||
function setAssignment(output: string, path: string): bool {
|
||||
if (!root.outputNames().includes(output)
|
||||
|| !WallpaperPolicy.validPath(path, root.candidates([])))
|
||||
return false;
|
||||
const policy = root.currentPolicy();
|
||||
policy.mode = "per-monitor";
|
||||
policy.assignments = Object.assign({}, policy.assignments);
|
||||
policy.assignments[output] = path;
|
||||
return root.applyPolicy(policy, true, false);
|
||||
}
|
||||
|
||||
function toggleSlideshowPath(path: string): bool {
|
||||
if (!WallpaperPolicy.validPath(path, root.candidates([])))
|
||||
return false;
|
||||
const policy = root.currentPolicy();
|
||||
const collection = WallpaperPolicy.validCollection(policy.collection, root.candidates([]));
|
||||
policy.collection = collection.includes(path)
|
||||
? collection.filter(candidate => candidate !== path)
|
||||
: collection.concat([path]);
|
||||
policy.mode = "slideshow";
|
||||
if (!policy.collection.includes(policy.slideshowPath))
|
||||
policy.slideshowPath = policy.collection[0] || policy.globalPath;
|
||||
return root.applyPolicy(policy, true, false);
|
||||
}
|
||||
|
||||
function setIntervalMinutes(minutes: int): bool {
|
||||
const value = PreferenceSchema.coerce("wallpaperIntervalMinutes", minutes);
|
||||
return value !== undefined
|
||||
&& DesktopPreferences.set("wallpaperIntervalMinutes", value);
|
||||
}
|
||||
|
||||
function setShuffle(enabled: bool): bool {
|
||||
return DesktopPreferences.set("wallpaperShuffle", enabled === true);
|
||||
}
|
||||
|
||||
// Compatibility boundary used by backup/reset and the existing picker.
|
||||
function set(path: string): bool {
|
||||
return root.setSingle(path);
|
||||
|
||||
Reference in New Issue
Block a user