135 lines
4.4 KiB
QML
Raw Normal View History

pragma ComponentBehavior: Bound
import QtQuick.Dialogs
import Quickshell
import qs.settings
import Quickshell.Widgets
2026-01-23 18:29:59 +01:00
import QtQuick
import qs.reusables
import Qt.labs.folderlistmodel 2.10
import Quickshell.Io
import qs
import Quickshell.Hyprland
2026-01-22 10:30:41 +01:00
import QtQuick.Layouts
FloatingWindow {
id: root
2026-01-22 10:30:41 +01:00
implicitHeight: 600
implicitWidth: 900
title: "qs-wallswitcher"
visible: Settings.config.wallSwitcherShown
2026-01-23 18:29:59 +01:00
color: Colors.surface
onClosed: {
Settings.config.wallSwitcherShown = false;
}
Process {
id: wallustRunner
2026-02-03 19:11:47 +01:00
property string cmd: "matugen image " + Settings.config.currentWall
command: ["sh", "-c", cmd]
}
GlobalShortcut {
name: "showWallSwitcher"
onPressed: {
Settings.config.wallSwitcherShown = true;
}
}
2026-01-22 10:30:41 +01:00
ColumnLayout {
id: windowLayout
2026-02-01 23:59:09 +01:00
spacing: 5
anchors.fill: parent
2026-02-01 23:59:09 +01:00
anchors.margins: 5
2026-01-22 10:30:41 +01:00
Rectangle {
id: textWrapper
Layout.fillWidth: true
2026-01-22 19:05:20 +01:00
Layout.margins: 10
2026-01-22 10:30:41 +01:00
Layout.alignment: Qt.AlignCenter
2026-01-22 19:05:20 +01:00
Layout.bottomMargin: 0
2026-02-01 23:59:09 +01:00
topLeftRadius: 12
topRightRadius: 12
bottomLeftRadius: 4
bottomRightRadius: 4
2026-01-22 10:30:41 +01:00
implicitHeight: 30
2026-01-26 18:20:36 +01:00
color: Colors.surfaceContainerLow
2026-01-22 10:30:41 +01:00
CustomText {
id: titleText
2026-01-26 18:20:36 +01:00
font.bold: true
2026-01-22 10:30:41 +01:00
anchors.centerIn: textWrapper
text: "Wallpapers in " + Settings.config.wallDir
}
}
Rectangle {
id: innerWindow
2026-01-22 19:05:20 +01:00
Layout.topMargin: 0
2026-01-22 10:30:41 +01:00
Layout.fillWidth: true
Layout.fillHeight: true
2026-01-22 19:05:20 +01:00
Layout.margins: 10
2026-02-01 23:59:09 +01:00
topLeftRadius: 4
topRightRadius: 4
bottomLeftRadius: 12
bottomRightRadius: 12
2026-01-23 18:29:59 +01:00
color: Colors.surfaceContainerLow
GridView {
id: gridRoot
anchors.margins: 20
2026-01-22 10:30:41 +01:00
property var columns: Math.floor(gridRoot.width / cellWidth)
property var usedWidth: columns * cellWidth
property var emptySpace: width - usedWidth
property var rows: Math.floor(gridRoot.height / cellHeight)
property var usedHeight: rows * cellHeight
property var emptyHeight: height - usedHeight
clip: true
boundsBehavior: Flickable.StopAtBounds
snapMode: GridView.SnapToRow
2026-01-23 18:29:59 +01:00
cellWidth: 130
cellHeight: 90
2026-01-22 10:30:41 +01:00
anchors.fill: innerWindow
anchors.centerIn: innerWindow
leftMargin: emptySpace / 2
model: folderModel
delegate: fileDelegate
FolderListModel {
id: folderModel
folder: Settings.config.wallDir
nameFilters: ["*.png", "*.jpg"]
}
FontDialog {
id: fontPicker
}
Component {
id: fileDelegate
2026-01-23 18:29:59 +01:00
ClippingWrapperRectangle {
id: imageRounder
implicitHeight: 80
implicitWidth: 120
2026-01-26 18:20:36 +01:00
color: "transparent"
required property string filePath
2026-01-23 18:29:59 +01:00
radius: 12
child: Image {
id: wallPreview
asynchronous: true
source: imageRounder.filePath
sourceSize.width: 120
sourceSize.height: 80
MouseArea {
id: wallpaperSetter
acceptedButtons: Qt.LeftButton
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
Settings.config.currentWall = imageRounder.filePath;
if (Settings.config.generateScheme) {
2026-01-26 13:45:24 +01:00
wallustRunner.running = true;
2026-01-23 18:29:59 +01:00
}
}
}
}
}
}
}
}
}
}