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
+260 -189
View File
@@ -6,6 +6,7 @@ import QtQuick.Controls
import QtQuick.Effects
import QtQuick.Layouts
import qs.Config
import qs.Helpers
Scope {
id: root
@@ -187,8 +188,8 @@ Scope {
Rectangle {
id: appListRect
x: Math.round(( parent.width - width ) / 2 )
implicitWidth: backgroundRect.implicitWidth
implicitHeight: appListView.implicitHeight + 20
implicitWidth: appListContainer.implicitWidth + 20
implicitHeight: appListContainer.implicitHeight + 20
anchors.bottom: backgroundRect.top
anchors.bottomMargin: -1
color: backgroundRect.color
@@ -204,217 +205,287 @@ Scope {
}
Item {
anchors.fill: parent
anchors.centerIn: parent
id: appListContainer
visible: appListView.count > 0
anchors.margins: 10
clip: true
ListView {
id: appListView
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
model: ScriptModel {
id: appModel
sourceComponent: ListView {
id: wallpaperPickerView
anchors.fill: parent
model: ScriptModel {
id: wallpaperModel
readonly property string search: searchInput.text.split(" ").slice(1).join(" ")
onValuesChanged: {
appListView.currentIndex = 0;
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
anchors.fill: parent
model: ScriptModel {
id: appModel
verticalLayoutDirection: ListView.BottomToTop
implicitHeight: Math.min( count, Config.appCount ) * 48
onValuesChanged: {
appListView.currentIndex = 0;
}
}
preferredHighlightBegin: 0
preferredHighlightEnd: appListView.height
highlightFollowsCurrentItem: false
highlightRangeMode: ListView.ApplyRange
focus: true
highlight: Rectangle {
radius: 4
color: "#FFFFFF"
opacity: 0.08
verticalLayoutDirection: ListView.BottomToTop
implicitHeight: Math.min( count, Config.appCount ) * 48
y: appListView.currentItem?.y
implicitWidth: appListView.width
implicitHeight: appListView.currentItem?.implicitHeight ?? 0
preferredHighlightBegin: 0
preferredHighlightEnd: appListView.height
highlightFollowsCurrentItem: false
highlightRangeMode: ListView.ApplyRange
focus: true
highlight: Rectangle {
radius: 4
color: "#FFFFFF"
opacity: 0.08
Behavior on y {
y: appListView.currentItem?.y
implicitWidth: appListView.width
implicitHeight: appListView.currentItem?.implicitHeight ?? 0
Behavior on y {
Anim {
duration: MaterialEasing.expressiveEffectsTime
easing.bezierCurve: MaterialEasing.expressiveEffects
}
}
}
property list<var> search: Search.search( searchInput.text )
state: {
const text = searchInput.text
if ( search.length === 0 ) {
return "noresults"
} else {
return "apps"
}
}
states: [
State {
name: "apps"
PropertyChanges {
appModel.values: Search.search(searchInput.text)
appListView.delegate: appItem
}
},
State {
name: "noresults"
PropertyChanges {
appModel.values: [1]
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 {
id: appItem
AppItem {
}
}
Component {
id: noResultsItem
Item {
width: appListView.width
height: 48
Text {
id: icon
anchors.verticalCenter: parent.verticalCenter
property real fill: 0
text: "\ue000"
color: "#cccccc"
renderType: Text.NativeRendering
font.pointSize: 28
font.family: "Material Symbols Outlined"
font.variableAxes: ({
FILL: fill.toFixed(1),
GRAD: -25,
opsz: fontInfo.pixelSize,
wght: fontInfo.weight
})
}
Text {
anchors.left: icon.right
anchors.leftMargin: 10
anchors.verticalCenter: parent.verticalCenter
text: "No results found"
color: "#cccccc"
renderType: Text.NativeRendering
font.pointSize: 12
font.family: "Rubik"
}
}
}
Component {
id: wallpaperItem
WallpaperItem { }
}
transitions: Transition {
SequentialAnimation {
ParallelAnimation {
Anim {
target: appListView
property: "opacity"
from: 1
to: 0
duration: 200
easing.bezierCurve: MaterialEasing.standardAccel
}
Anim {
target: appListView
property: "scale"
from: 1
to: 0.9
duration: 200
easing.bezierCurve: MaterialEasing.standardAccel
}
}
PropertyAction {
targets: [model, appListView]
properties: "values,delegate"
}
ParallelAnimation {
Anim {
target: appListView
property: "opacity"
from: 0
to: 1
duration: 200
easing.bezierCurve: MaterialEasing.standardDecel
}
Anim {
target: appListView
property: "scale"
from: 0.9
to: 1
duration: 200
easing.bezierCurve: MaterialEasing.standardDecel
}
}
PropertyAction {
targets: [appListView.add, appListView.remove]
property: "enabled"
value: true
}
}
}
add: Transition {
enabled: !appListView.state
Anim {
duration: MaterialEasing.expressiveEffectsTime
easing.bezierCurve: MaterialEasing.expressiveEffects
}
}
}
property list<var> search: Search.search( searchInput.text )
state: search.length === 0 ? "noresults" : "apps"
states: [
State {
name: "apps"
PropertyChanges {
appModel.values: Search.search(searchInput.text)
appListView.delegate: appItem
}
},
State {
name: "noresults"
PropertyChanges {
appModel.values: [1]
appListView.delegate: noResultsItem
}
}
]
Component {
id: appItem
AppItem {
}
}
Component {
id: noResultsItem
Item {
width: appListView.width
height: 48
Text {
id: icon
anchors.verticalCenter: parent.verticalCenter
property real fill: 0
text: "\ue000"
color: "#cccccc"
renderType: Text.NativeRendering
font.pointSize: 28
font.family: "Material Symbols Outlined"
font.variableAxes: ({
FILL: fill.toFixed(1),
GRAD: -25,
opsz: fontInfo.pixelSize,
wght: fontInfo.weight
})
properties: "opacity"
from: 0
to: 1
}
Text {
anchors.left: icon.right
anchors.leftMargin: 10
anchors.verticalCenter: parent.verticalCenter
text: "No results found"
color: "#cccccc"
renderType: Text.NativeRendering
font.pointSize: 12
font.family: "Rubik"
Anim {
properties: "scale"
from: 0.95
to: 1
}
}
}
transitions: Transition {
SequentialAnimation {
ParallelAnimation {
Anim {
target: appListView
property: "opacity"
from: 1
to: 0
duration: 200
easing.bezierCurve: MaterialEasing.standardAccel
}
Anim {
target: appListView
property: "scale"
from: 1
to: 0.9
duration: 200
easing.bezierCurve: MaterialEasing.standardAccel
}
remove: Transition {
enabled: !appListView.state
Anim {
properties: "opacity"
from: 1
to: 0
}
PropertyAction {
targets: [model, appListView]
properties: "values,delegate"
}
ParallelAnimation {
Anim {
target: appListView
property: "opacity"
from: 0
to: 1
duration: 200
easing.bezierCurve: MaterialEasing.standardDecel
}
Anim {
target: appListView
property: "scale"
from: 0.9
to: 1
duration: 200
easing.bezierCurve: MaterialEasing.standardDecel
}
}
PropertyAction {
targets: [appListView.add, appListView.remove]
property: "enabled"
value: true
Anim {
properties: "scale"
from: 1
to: 0.95
}
}
}
add: Transition {
enabled: !appListView.state
Anim {
properties: "opacity"
from: 0
to: 1
move: Transition {
Anim {
property: "y"
}
Anim {
properties: "opacity,scale"
to: 1
}
}
Anim {
properties: "scale"
from: 0.95
to: 1
}
}
remove: Transition {
enabled: !appListView.state
Anim {
properties: "opacity"
from: 1
to: 0
addDisplaced: Transition {
Anim {
property: "y"
duration: 200
}
Anim {
properties: "opacity,scale"
to: 1
}
}
Anim {
properties: "scale"
from: 1
to: 0.95
}
}
move: Transition {
Anim {
property: "y"
}
Anim {
properties: "opacity,scale"
to: 1
}
}
addDisplaced: Transition {
Anim {
property: "y"
duration: 200
}
Anim {
properties: "opacity,scale"
to: 1
}
}
displaced: Transition {
Anim {
property: "y"
}
Anim {
properties: "opacity,scale"
to: 1
displaced: Transition {
Anim {
property: "y"
}
Anim {
properties: "opacity,scale"
to: 1
}
}
}
}