added adaptive quickshell

This commit is contained in:
wt committed 2026-11-17 18:15:16 +07:00
1 parent 6eb56d2065
commit 5b33a73fd8
189 files changed
+8678 -15

No files matched your search

+98
View File
@@ -0,0 +1,98 @@
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Material
import QtQuick.Dialogs
import QtQuick.Layouts
import Quickshell
import "services"
import "services/WallpaperPolicy.js" as Policy
import "components"
ScrollView {
id: page
Material.theme: Theme.dark ? Material.Dark : Material.Light
Material.accent: Theme.primary
contentWidth: availableWidth
clip: true
readonly property var outputs: ["*"].concat(Array.from(new Set(Quickshell.screens.map(s => s.name).concat(Object.keys(Preferences.data.wallpapers || {}).filter(name => name !== "*")))))
property string output: "*"
onOutputsChanged: if (!outputs.includes(output)) output = "*"
onOutputChanged: if (initialized) loadSelection()
property string selected: ""
property string loadedSelection: ""
property bool initialized: false
function loadSelection() { loadedSelection = Wallpapers.sourceFor(output); choose(loadedSelection); }
Connections {
target: Preferences
function onDataChanged() { if (page.initialized && path.text === page.loadedSelection) page.loadSelection(); }
}
function choose(value) { selected = value; path.text = value; }
FileDialog {
id: picker
title: "Выбрать обои"
nameFilters: ["Изображения (*.png *.jpg *.jpeg *.webp *.bmp *.avif)", "Все файлы (*)"]
onAccepted: page.choose(selectedFile.toString())
}
ColumnLayout {
width: page.availableWidth
spacing: 16
Label { text: "Обои"; font.pixelSize: 24; color: Theme.primary }
ComboBox {
id: monitor
Layout.fillWidth: true
model: page.outputs.map(name => name === "*" ? "Общие обои для мониторов" : name + (Quickshell.screens.some(s => s.name === name) ? "" : " (не подключён)"))
currentIndex: page.outputs.indexOf(page.output)
onActivated: page.output = page.outputs[currentIndex] || "*"
Component.onCompleted: { page.initialized = true; page.loadSelection(); }
}
TextField {
id: path
Layout.fillWidth: true
placeholderText: "Абсолютный путь к изображению"
selectByMouse: true
onEditingFinished: page.selected = text
}
ActionButton { text: "Выбрать файл…"; onClicked: picker.open() }
Image {
id: preview
Layout.fillWidth: true
Layout.preferredHeight: 220
source: {
try { return Policy.localUrl(page.selected); } catch (e) { return ""; }
}
asynchronous: true
sourceSize: Qt.size(720, 440)
fillMode: Image.PreserveAspectFit
visible: source !== ""
}
Label { visible: preview.status === Image.Error; text: "Не удалось открыть изображение для предпросмотра"; color: "#ffb4ab"; Layout.fillWidth: true; wrapMode: Text.Wrap }
ActionButton {
text: "Применить"
enabled: Preferences.writable
onClicked: if (Wallpapers.set(page.output, path.text)) page.loadedSelection = Wallpapers.sourceFor(page.output)
}
ActionButton {
text: "Использовать общие обои"
visible: page.output !== "*"
enabled: Preferences.writable
onClicked: { Wallpapers.inherit(page.output); page.choose(Wallpapers.sourceFor(page.output)); }
}
ActionButton {
text: "Использовать прежний фон"
enabled: Preferences.writable
onClicked: { Wallpapers.set(page.output, ""); page.choose(""); }
}
Label { Layout.fillWidth: true; wrapMode: Text.Wrap; visible: (Wallpapers.error || Preferences.error) !== ""; text: Wallpapers.error || Preferences.error; color: Theme.outline }
Repeater {
model: Quickshell.screens
Label {
required property var modelData
Layout.fillWidth: true
wrapMode: Text.Wrap
color: Wallpapers.states[modelData.name]?.state === "error" ? "#ffb4ab" : Theme.outline
text: modelData.name + ": " + ({ready: "Обои загружены", loading: "Загрузка…", disabled: "Обои оболочки не заданы", error: "Не удалось загрузить изображение. Сохранены последние загруженные обои, если они были."})[Wallpapers.states[modelData.name]?.state || "disabled"]
}
}
}
}