wallpaper picker
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
pragma Singleton
|
||||||
|
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Io
|
||||||
|
|
||||||
|
Singleton {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property alias currentWallpaperPath: adapter.currentWallpaperPath
|
||||||
|
|
||||||
|
FileView {
|
||||||
|
id: fileView
|
||||||
|
path: Quickshell.env("HOME") + "/.local/state/z-bar/wallpaper_path.json"
|
||||||
|
|
||||||
|
watchChanges: true
|
||||||
|
onFileChanged: reload()
|
||||||
|
onAdapterUpdated: writeAdapter()
|
||||||
|
JsonAdapter {
|
||||||
|
id: adapter
|
||||||
|
property string currentWallpaperPath: ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import Quickshell
|
import Quickshell
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
|
import qs.Helpers
|
||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
id: root
|
id: root
|
||||||
@@ -63,15 +64,25 @@ TextField {
|
|||||||
|
|
||||||
Keys.onPressed: {
|
Keys.onPressed: {
|
||||||
if ( event.key === Qt.Key_Down ) {
|
if ( event.key === Qt.Key_Down ) {
|
||||||
appListView.decrementCurrentIndex();
|
if ( appListLoader.active ) {
|
||||||
|
appListLoader.item.decrementCurrentIndex();
|
||||||
|
} else {
|
||||||
|
wallpaperPickerLoader.item.decrementCurrentIndex();
|
||||||
|
}
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
} else if ( event.key === Qt.Key_Up ) {
|
} else if ( event.key === Qt.Key_Up ) {
|
||||||
appListView.incrementCurrentIndex();
|
if ( appListLoader.active ) {
|
||||||
|
appListLoader.item.incrementCurrentIndex();
|
||||||
|
} else {
|
||||||
|
wallpaperPickerLoader.item.incrementCurrentIndex();
|
||||||
|
}
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
} else if ( event.key === Qt.Key_Return || event.key === Qt.Key_Enter ) {
|
} else if ( event.key === Qt.Key_Return || event.key === Qt.Key_Enter ) {
|
||||||
if ( appListView.currentItem ) {
|
if ( appListLoader.active ) {
|
||||||
Search.launch(appListView.currentItem.modelData);
|
Search.launch(appListLoader.item.currentItem.modelData);
|
||||||
launcherWindow.visible = false;
|
launcherWindow.visible = false;
|
||||||
|
} else if ( wallpaperPickerLoader.active ) {
|
||||||
|
WallpaperPath.currentWallpaperPath = wallpaperPickerLoader.item.currentItem.modelData.path;
|
||||||
}
|
}
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
} else if ( event.key === Qt.Key_Escape ) {
|
} else if ( event.key === Qt.Key_Escape ) {
|
||||||
|
|||||||
+47
-14
@@ -55,7 +55,7 @@ Scope {
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
id: shadowRect
|
id: shadowRect
|
||||||
anchors {
|
anchors {
|
||||||
top: appListView.count > 0 ? appListRect.top : backgroundRect.top
|
top: appListRect.top
|
||||||
bottom: backgroundRect.bottom
|
bottom: backgroundRect.bottom
|
||||||
left: appListRect.left
|
left: appListRect.left
|
||||||
right: appListRect.right
|
right: appListRect.right
|
||||||
@@ -85,7 +85,7 @@ Scope {
|
|||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
anchors.bottomMargin: -1
|
anchors.bottomMargin: -1
|
||||||
implicitHeight: mainLayout.childrenRect.height + 20
|
implicitHeight: mainLayout.childrenRect.height + 20
|
||||||
implicitWidth: 600
|
implicitWidth: appListRect.implicitWidth
|
||||||
x: Math.round(( parent.width - width ) / 2 )
|
x: Math.round(( parent.width - width ) / 2 )
|
||||||
color: "#d01a1a1a"
|
color: "#d01a1a1a"
|
||||||
opacity: 1
|
opacity: 1
|
||||||
@@ -100,7 +100,7 @@ Scope {
|
|||||||
easing.bezierCurve: MaterialEasing.expressiveDefaultSpatial
|
easing.bezierCurve: MaterialEasing.expressiveDefaultSpatial
|
||||||
property: "implicitHeight"
|
property: "implicitHeight"
|
||||||
from: 40
|
from: 40
|
||||||
to: appListView.implicitHeight + 20
|
to: appListContainer.implicitHeight + 20
|
||||||
}
|
}
|
||||||
Anim {
|
Anim {
|
||||||
target: appListRect
|
target: appListRect
|
||||||
@@ -135,7 +135,7 @@ Scope {
|
|||||||
duration: MaterialEasing.expressiveFastSpatialTime
|
duration: MaterialEasing.expressiveFastSpatialTime
|
||||||
easing.bezierCurve: MaterialEasing.expressiveDefaultSpatial
|
easing.bezierCurve: MaterialEasing.expressiveDefaultSpatial
|
||||||
property: "implicitHeight"
|
property: "implicitHeight"
|
||||||
from: appListView.implicitHeight
|
from: appListContainer.implicitHeight
|
||||||
to: 40
|
to: 40
|
||||||
}
|
}
|
||||||
SequentialAnimation {
|
SequentialAnimation {
|
||||||
@@ -196,6 +196,7 @@ Scope {
|
|||||||
topRightRadius: 8
|
topRightRadius: 8
|
||||||
topLeftRadius: 8
|
topLeftRadius: 8
|
||||||
border.color: backgroundRect.border.color
|
border.color: backgroundRect.border.color
|
||||||
|
clip: true
|
||||||
|
|
||||||
Behavior on implicitHeight {
|
Behavior on implicitHeight {
|
||||||
Anim {
|
Anim {
|
||||||
@@ -204,10 +205,17 @@ Scope {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Behavior on implicitWidth {
|
||||||
|
Anim {
|
||||||
|
duration: MaterialEasing.expressiveFastSpatialTime
|
||||||
|
easing.bezierCurve: MaterialEasing.expressiveDefaultSpatial
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
id: appListContainer
|
id: appListContainer
|
||||||
visible: appListView.count > 0
|
visible: true
|
||||||
clip: true
|
clip: true
|
||||||
property var showWallpapers: searchInput.text.startsWith(">")
|
property var showWallpapers: searchInput.text.startsWith(">")
|
||||||
state: showWallpapers ? "wallpaperpicker" : "apps"
|
state: showWallpapers ? "wallpaperpicker" : "apps"
|
||||||
@@ -216,7 +224,7 @@ Scope {
|
|||||||
name: "apps"
|
name: "apps"
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
appListLoader.active: true
|
appListLoader.active: true
|
||||||
appListContainer.implicitHeight: appListView.implicitHeight + 20
|
appListContainer.implicitHeight: appListLoader.implicitHeight
|
||||||
appListContainer.implicitWidth: 600
|
appListContainer.implicitWidth: 600
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -224,8 +232,8 @@ Scope {
|
|||||||
name: "wallpaperpicker"
|
name: "wallpaperpicker"
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
wallpaperPickerLoader.active: true
|
wallpaperPickerLoader.active: true
|
||||||
appListContainer.implicitHeight: wallpaperPickerView.implicitHeight + 20
|
appListContainer.implicitHeight: wallpaperPickerLoader.implicitHeight
|
||||||
appListContainer.implicitWidth: wallpaperPickerView.implicitWidth + 20
|
appListContainer.implicitWidth: wallpaperPickerLoader.implicitWidth
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -233,7 +241,7 @@ Scope {
|
|||||||
id: wallpaperPickerLoader
|
id: wallpaperPickerLoader
|
||||||
active: false
|
active: false
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
sourceComponent: ListView {
|
sourceComponent: PathView {
|
||||||
id: wallpaperPickerView
|
id: wallpaperPickerView
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
model: ScriptModel {
|
model: ScriptModel {
|
||||||
@@ -243,15 +251,40 @@ Scope {
|
|||||||
values: SearchWallpapers.query( search )
|
values: SearchWallpapers.query( search )
|
||||||
}
|
}
|
||||||
|
|
||||||
orientation: ListView.Horizontal
|
cacheItemCount: 5
|
||||||
spacing: 10
|
snapMode: PathView.SnapToItem
|
||||||
implicitHeight: 300
|
preferredHighlightBegin: 0.5
|
||||||
implicitWidth: Math.min( wallpaperModel.count, 7 ) * 192 + Math.max(0, wallpaperModel.count -1) * 10
|
preferredHighlightEnd: 0.5
|
||||||
|
highlightRangeMode: PathView.StrictlyEnforceRange
|
||||||
|
|
||||||
|
pathItemCount: 7
|
||||||
|
implicitHeight: 212
|
||||||
|
implicitWidth: Math.min( wallpaperModel.values.length, 7 ) * 192 + Math.max(0, wallpaperModel.values.length -1) * 10
|
||||||
|
|
||||||
|
path: Path {
|
||||||
|
startY: wallpaperPickerView.height / 2
|
||||||
|
|
||||||
|
PathAttribute {
|
||||||
|
name: "z"
|
||||||
|
value: 0
|
||||||
|
}
|
||||||
|
PathLine {
|
||||||
|
x: wallpaperPickerView.width / 2
|
||||||
|
relativeY: 0
|
||||||
|
}
|
||||||
|
PathAttribute {
|
||||||
|
name: "z"
|
||||||
|
value: 1
|
||||||
|
}
|
||||||
|
PathLine {
|
||||||
|
x: wallpaperPickerView.width
|
||||||
|
relativeY: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
focus: true
|
focus: true
|
||||||
|
|
||||||
delegate: WallpaperItem { }
|
delegate: WallpaperItem { }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loader {
|
Loader {
|
||||||
|
|||||||
@@ -1,18 +1,44 @@
|
|||||||
import Quickshell
|
import Quickshell
|
||||||
|
import Quickshell.Widgets
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Caelestia.Models
|
import Caelestia.Models
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
required property FileSystemEntry modelData
|
required property FileSystemEntry modelData
|
||||||
implicitWidth: 192
|
implicitWidth: 288
|
||||||
implicitHeight: 108
|
implicitHeight: 162
|
||||||
|
|
||||||
|
scale: 0.5
|
||||||
|
opacity: 0
|
||||||
|
z: PathView.z ?? 0
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
scale = Qt.binding(() => PathView.isCurrentItem ? 1 : PathView.onPath ? 0.8 : 0);
|
||||||
|
opacity = Qt.binding(() => PathView.onPath ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ClippingRectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
radius: 8
|
||||||
|
color: "#10FFFFFF"
|
||||||
Image {
|
Image {
|
||||||
id: thumbnailImage
|
id: thumbnailImage
|
||||||
|
|
||||||
|
asynchronous: true
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
fillMode: Image.PreserveAspectCrop
|
fillMode: Image.PreserveAspectCrop
|
||||||
source: root.modelData.path
|
source: root.modelData.path
|
||||||
|
sourceSize.width: 960
|
||||||
|
sourceSize.height: 540
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on scale {
|
||||||
|
Anim {}
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on opacity {
|
||||||
|
Anim {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -1,6 +1,7 @@
|
|||||||
import Quickshell
|
import Quickshell
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell.Wayland
|
import Quickshell.Wayland
|
||||||
|
import qs.Helpers
|
||||||
|
|
||||||
Scope {
|
Scope {
|
||||||
Variants {
|
Variants {
|
||||||
@@ -21,8 +22,8 @@ Scope {
|
|||||||
Image {
|
Image {
|
||||||
id: wallpaperImage
|
id: wallpaperImage
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
source: "/mnt/IronWolf/SDImages/SWWW_Wals/ComfyUI_00037_.png"
|
source: WallpaperPath.currentWallpaperPath
|
||||||
fillMode: Image.PreserveAspectFit
|
fillMode: Image.PreserveAspectCrop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user