change to using loaders

This commit is contained in:
Zacharias-Brohn
2025-11-12 13:16:01 +01:00
parent 01d22e582a
commit 14b01ad539
9 changed files with 350 additions and 208 deletions
+2
View File
@@ -8,6 +8,7 @@ Singleton {
property alias appCount: adapter.appCount property alias appCount: adapter.appCount
property alias baseBgColor: adapter.baseBgColor property alias baseBgColor: adapter.baseBgColor
property alias accentColor: adapter.accentColor property alias accentColor: adapter.accentColor
property alias wallpaperPath: adapter.wallpaperPath
FileView { FileView {
id: root id: root
@@ -23,6 +24,7 @@ Singleton {
JsonAdapter { JsonAdapter {
id: adapter id: adapter
property int appCount: 20 property int appCount: 20
property string wallpaperPath: Quickshell.env("HOME") + "/Pictures/Wallpapers"
property string baseBgColor: "#801a1a1a" property string baseBgColor: "#801a1a1a"
property AccentColor accentColor: AccentColor {} property AccentColor accentColor: AccentColor {}
} }
+22
View File
@@ -0,0 +1,22 @@
pragma Singleton
import Quickshell.Io
import Quickshell
Singleton {
function getInitialTitle(callback) {
initialTitleProc.running = true
initialTitleProc.stdout.streamFinished.connect( function() {
let cleaned = initialTitleProc.stdout.text.trim().replace(/\"/g, "")
callback(cleaned === "null" ? "" : cleaned)
})
}
Process {
id: initialTitleProc
command: ["./scripts/initialTitle.sh"]
running: false
stdout: StdioCollector {
}
}
}
+35
View File
@@ -0,0 +1,35 @@
pragma Singleton
import Quickshell
import Quickshell.Io
import qs.Config
import qs.Modules
import Caelestia.Models
Searcher {
id: root
list: wallpapers.entries
key: "relativePath"
useFuzzy: true
extraOpts: useFuzzy ? ({}) : ({
forward: false
})
// FileView {
// path: root.currentNamePath
// watchChanges: true
// onFileChanged: reload()
// onLoaded: {
// root.actualCurrent = text().trim();
// }
// }
FileSystemModel {
id: wallpapers
recursive: true
path: Config.wallpaperPath
filter: FileSystemModel.Images
}
}
+77 -6
View File
@@ -6,6 +6,7 @@ import QtQuick.Controls
import QtQuick.Effects import QtQuick.Effects
import QtQuick.Layouts import QtQuick.Layouts
import qs.Config import qs.Config
import qs.Helpers
Scope { Scope {
id: root id: root
@@ -187,8 +188,8 @@ Scope {
Rectangle { Rectangle {
id: appListRect id: appListRect
x: Math.round(( parent.width - width ) / 2 ) x: Math.round(( parent.width - width ) / 2 )
implicitWidth: backgroundRect.implicitWidth implicitWidth: appListContainer.implicitWidth + 20
implicitHeight: appListView.implicitHeight + 20 implicitHeight: appListContainer.implicitHeight + 20
anchors.bottom: backgroundRect.top anchors.bottom: backgroundRect.top
anchors.bottomMargin: -1 anchors.bottomMargin: -1
color: backgroundRect.color color: backgroundRect.color
@@ -204,11 +205,60 @@ Scope {
} }
Item { Item {
anchors.fill: parent anchors.centerIn: parent
id: appListContainer
visible: appListView.count > 0 visible: appListView.count > 0
anchors.margins: 10
clip: true clip: true
ListView { property var showWallpapers: searchInput.text.startsWith(">")
state: showWallpapers ? "wallpaperpicker" : "apps"
states: [
State {
name: "apps"
PropertyChanges {
appListLoader.active: true
appListContainer.implicitHeight: appListView.implicitHeight + 20
appListContainer.implicitWidth: 600
}
},
State {
name: "wallpaperpicker"
PropertyChanges {
wallpaperPickerLoader.active: true
appListContainer.implicitHeight: wallpaperPickerView.implicitHeight + 20
appListContainer.implicitWidth: wallpaperPickerView.implicitWidth + 20
}
}
]
Loader {
id: wallpaperPickerLoader
active: false
anchors.fill: parent
sourceComponent: ListView {
id: wallpaperPickerView
anchors.fill: parent
model: ScriptModel {
id: wallpaperModel
readonly property string search: searchInput.text.split(" ").slice(1).join(" ")
values: SearchWallpapers.query( search )
}
orientation: ListView.Horizontal
spacing: 10
implicitHeight: 300
implicitWidth: Math.min( wallpaperModel.count, 7 ) * 192 + Math.max(0, wallpaperModel.count -1) * 10
focus: true
delegate: WallpaperItem { }
}
}
Loader {
id: appListLoader
active: false
anchors.fill: parent
sourceComponent: ListView {
id: appListView id: appListView
anchors.fill: parent anchors.fill: parent
model: ScriptModel { model: ScriptModel {
@@ -246,7 +296,14 @@ Scope {
property list<var> search: Search.search( searchInput.text ) property list<var> search: Search.search( searchInput.text )
state: search.length === 0 ? "noresults" : "apps" state: {
const text = searchInput.text
if ( search.length === 0 ) {
return "noresults"
} else {
return "apps"
}
}
states: [ states: [
State { State {
@@ -263,6 +320,14 @@ Scope {
appListView.delegate: noResultsItem appListView.delegate: noResultsItem
} }
} }
// State {
// name: "wallpaperpicker"
// PropertyChanges {
// appModel.values: SearchWallpapers.query( searchInput.text.split(" ").slice(1).join(" ") )
// appListView.delegate: wallpaperItem
// appListView.orientation: ListView.Horizontal
// }
// }
] ]
Component { Component {
@@ -307,6 +372,11 @@ Scope {
} }
} }
Component {
id: wallpaperItem
WallpaperItem { }
}
transitions: Transition { transitions: Transition {
SequentialAnimation { SequentialAnimation {
ParallelAnimation { ParallelAnimation {
@@ -422,3 +492,4 @@ Scope {
} }
} }
} }
}
+2
View File
@@ -143,6 +143,8 @@ PanelWindow {
Layout.fillWidth: true Layout.fillWidth: true
text: "Do Not Disturb" text: "Do Not Disturb"
focus: false focus: false
activeFocusOnTab: false
focusPolicy: Qt.NoFocus
} }
RowLayout { RowLayout {
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
+3 -1
View File
@@ -59,8 +59,10 @@ MouseArea {
if ( mouse.button === Qt.LeftButton ) { if ( mouse.button === Qt.LeftButton ) {
root.item.activate(); root.item.activate();
} else if ( mouse.button === Qt.RightButton ) { } else if ( mouse.button === Qt.RightButton ) {
trayMenu.visible = !trayMenu.visible; if ( root.item?.menu !== trayMenu.trayMenu ) {
trayMenu.trayMenu = root.item?.menu; trayMenu.trayMenu = root.item?.menu;
}
trayMenu.visible = !trayMenu.visible;
trayMenu.focusGrab = true; trayMenu.focusGrab = true;
} }
} }
+4 -4
View File
@@ -163,15 +163,15 @@ PanelWindow {
Behavior on implicitWidth { Behavior on implicitWidth {
NumberAnimation { NumberAnimation {
duration: MaterialEasing.standardTime duration: MaterialEasing.expressiveEffectsTime
easing.bezierCurve: MaterialEasing.standard easing.bezierCurve: MaterialEasing.expressiveEffects
} }
} }
Behavior on implicitHeight { Behavior on implicitHeight {
NumberAnimation { NumberAnimation {
duration: MaterialEasing.standardTime duration: MaterialEasing.expressiveEffectsTime
easing.bezierCurve: MaterialEasing.standard easing.bezierCurve: MaterialEasing.expressiveEffects
} }
} }
+18
View File
@@ -0,0 +1,18 @@
import Quickshell
import QtQuick
import Caelestia.Models
Item {
id: root
required property FileSystemEntry modelData
implicitWidth: 192
implicitHeight: 108
Image {
id: thumbnailImage
anchors.fill: parent
fillMode: Image.PreserveAspectCrop
source: root.modelData.path
}
}
+4 -14
View File
@@ -1,7 +1,7 @@
import QtQuick import QtQuick
import QtQuick.Layouts import QtQuick.Layouts
import Quickshell.Io
import Quickshell.Hyprland import Quickshell.Hyprland
import qs.Helpers
Item { Item {
id: root id: root
@@ -12,22 +12,12 @@ Item {
property bool showFirst: true property bool showFirst: true
Process {
id: initialTitleProc
command: ["./scripts/initialTitle.sh"]
running: false
stdout: StdioCollector {
onStreamFinished: {
let cleaned = this.text.trim().replace(/\"/g, "")
root.currentTitle = ( cleaned === "null" ) ? "" : cleaned
}
}
}
Component.onCompleted: { Component.onCompleted: {
Hyprland.rawEvent.connect(( event ) => { Hyprland.rawEvent.connect(( event ) => {
if (event.name === "activewindow") { if (event.name === "activewindow") {
initialTitleProc.running = true InitialTitle.getInitialTitle( function( initialTitle ) {
root.currentTitle = initialTitle
})
} }
}) })
} }