mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-10-18 09:14:01 -04:00
deprecation notice to plugin compatibility shims - When qml-common became a thing, we left qs.Widgets shims in place for plugin compatibility - It's annoying to need to maintain them when qml-common has any change, add a warning so we can safely deprecate them in the future - One shot rename the common stuff to D to make it shorter and nicer to write
69 lines
2.0 KiB
QML
69 lines
2.0 KiB
QML
pragma ComponentBehavior: Bound
|
|
|
|
import QtQuick
|
|
import qs.Common
|
|
import qs.Services
|
|
import "../../../DCommon/Common/MaterialWallpaper.js" as Art
|
|
|
|
SettingsSwatchGrid {
|
|
id: root
|
|
|
|
property string seed: Art.defaultSeed
|
|
property bool light: SessionData.isLightMode
|
|
readonly property var candidates: Art.seedCandidates().map(candidate => ({
|
|
value: candidate.seed,
|
|
label: MaterialWallpaperOptions.label(MaterialWallpaperOptions.seedHues, candidate.slot)
|
|
}))
|
|
readonly property bool customSeed: !candidates.some(candidate => candidate.value === seed)
|
|
readonly property string previewKey: MatugenPreviewService.keySuffix
|
|
readonly property bool matugenAvailable: Theme.matugenAvailable
|
|
|
|
signal seedSelected(string seed)
|
|
|
|
options: customSeed ? [
|
|
{
|
|
value: seed,
|
|
label: I18n.tr("Current")
|
|
}
|
|
].concat(candidates) : candidates
|
|
currentValue: seed
|
|
resolveOption: option => {
|
|
const palette = MatugenPreviewService.seedPalette(option.value, root.light);
|
|
if (!palette)
|
|
return {
|
|
primary: option.value,
|
|
secondary: option.value,
|
|
tertiary: option.value
|
|
};
|
|
return {
|
|
primary: palette.primary,
|
|
secondary: palette.secondary,
|
|
tertiary: palette.tertiary
|
|
};
|
|
}
|
|
onSelected: value => {
|
|
if (value === root.seed)
|
|
return;
|
|
root.seedSelected(value);
|
|
}
|
|
onSeedChanged: request()
|
|
onPreviewKeyChanged: request()
|
|
onMatugenAvailableChanged: request()
|
|
onVisibleChanged: request()
|
|
Component.onCompleted: request()
|
|
|
|
function wantedSeeds() {
|
|
return candidates.map(candidate => candidate.value).concat([seed]);
|
|
}
|
|
|
|
function request() {
|
|
if (!visible)
|
|
return;
|
|
MatugenPreviewService.requestSeeds(wantedSeeds());
|
|
}
|
|
|
|
function retry() {
|
|
MatugenPreviewService.retrySeeds(wantedSeeds());
|
|
}
|
|
}
|