launcher: fix state transitions
This commit is contained in:
parent
58826b7deb
commit
6ee0437d4f
3 changed files with 113 additions and 87 deletions
|
|
@ -15,28 +15,9 @@ StyledListView {
|
||||||
required property TextField search
|
required property TextField search
|
||||||
required property PersistentProperties visibilities
|
required property PersistentProperties visibilities
|
||||||
|
|
||||||
property bool isAction: search.text.startsWith(Config.launcher.actionPrefix)
|
|
||||||
property bool isCalc: search.text.startsWith(`${Config.launcher.actionPrefix}calc `)
|
|
||||||
property bool isScheme: search.text.startsWith(`${Config.launcher.actionPrefix}scheme `)
|
|
||||||
property bool isVariant: search.text.startsWith(`${Config.launcher.actionPrefix}variant `)
|
|
||||||
|
|
||||||
function getModelValues() {
|
|
||||||
let text = search.text;
|
|
||||||
if (isCalc)
|
|
||||||
return [0];
|
|
||||||
if (isScheme)
|
|
||||||
return Schemes.query(text);
|
|
||||||
if (isVariant)
|
|
||||||
return M3Variants.query(text);
|
|
||||||
if (isAction)
|
|
||||||
return Actions.query(text);
|
|
||||||
if (text.startsWith(Config.launcher.actionPrefix))
|
|
||||||
text = search.text.slice(Config.launcher.actionPrefix.length);
|
|
||||||
return Apps.query(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
model: ScriptModel {
|
model: ScriptModel {
|
||||||
values: root.getModelValues()
|
id: model
|
||||||
|
|
||||||
onValuesChanged: root.currentIndex = 0
|
onValuesChanged: root.currentIndex = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,21 +34,118 @@ StyledListView {
|
||||||
opacity: 0.08
|
opacity: 0.08
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate: {
|
state: {
|
||||||
if (isCalc)
|
const text = search.text;
|
||||||
return calcItem;
|
const prefix = Config.launcher.actionPrefix;
|
||||||
if (isScheme)
|
if (text.startsWith(prefix)) {
|
||||||
return schemeItem;
|
for (const action of ["calc", "scheme", "variant"])
|
||||||
if (isVariant)
|
if (text.startsWith(`${prefix}${action} `))
|
||||||
return variantItem;
|
return action;
|
||||||
if (isAction)
|
|
||||||
return actionItem;
|
return "actions";
|
||||||
return appItem;
|
}
|
||||||
|
|
||||||
|
return "apps";
|
||||||
|
}
|
||||||
|
|
||||||
|
states: [
|
||||||
|
State {
|
||||||
|
name: "apps"
|
||||||
|
|
||||||
|
PropertyChanges {
|
||||||
|
model.values: Apps.query(search.text)
|
||||||
|
root.delegate: appItem
|
||||||
|
}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "actions"
|
||||||
|
|
||||||
|
PropertyChanges {
|
||||||
|
model.values: Actions.query(search.text)
|
||||||
|
root.delegate: actionItem
|
||||||
|
}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "calc"
|
||||||
|
|
||||||
|
PropertyChanges {
|
||||||
|
model.values: [0]
|
||||||
|
root.delegate: calcItem
|
||||||
|
}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "scheme"
|
||||||
|
|
||||||
|
PropertyChanges {
|
||||||
|
model.values: Schemes.query(search.text)
|
||||||
|
root.delegate: schemeItem
|
||||||
|
}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "variant"
|
||||||
|
|
||||||
|
PropertyChanges {
|
||||||
|
model.values: M3Variants.query(search.text)
|
||||||
|
root.delegate: variantItem
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
transitions: Transition {
|
||||||
|
SequentialAnimation {
|
||||||
|
ParallelAnimation {
|
||||||
|
Anim {
|
||||||
|
target: root
|
||||||
|
property: "opacity"
|
||||||
|
from: 1
|
||||||
|
to: 0
|
||||||
|
duration: Appearance.anim.durations.small
|
||||||
|
easing.bezierCurve: Appearance.anim.curves.standardAccel
|
||||||
|
}
|
||||||
|
Anim {
|
||||||
|
target: root
|
||||||
|
property: "scale"
|
||||||
|
from: 1
|
||||||
|
to: 0.9
|
||||||
|
duration: Appearance.anim.durations.small
|
||||||
|
easing.bezierCurve: Appearance.anim.curves.standardAccel
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PropertyAction {
|
||||||
|
targets: [model, root]
|
||||||
|
properties: "values,delegate"
|
||||||
|
}
|
||||||
|
ParallelAnimation {
|
||||||
|
Anim {
|
||||||
|
target: root
|
||||||
|
property: "opacity"
|
||||||
|
from: 0
|
||||||
|
to: 1
|
||||||
|
duration: Appearance.anim.durations.small
|
||||||
|
easing.bezierCurve: Appearance.anim.curves.standardDecel
|
||||||
|
}
|
||||||
|
Anim {
|
||||||
|
target: root
|
||||||
|
property: "scale"
|
||||||
|
from: 0.9
|
||||||
|
to: 1
|
||||||
|
duration: Appearance.anim.durations.small
|
||||||
|
easing.bezierCurve: Appearance.anim.curves.standardDecel
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PropertyAction {
|
||||||
|
targets: [root.add, root.remove]
|
||||||
|
property: "enabled"
|
||||||
|
value: true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollBar.vertical: StyledScrollBar {}
|
ScrollBar.vertical: StyledScrollBar {}
|
||||||
|
|
||||||
add: Transition {
|
add: Transition {
|
||||||
|
enabled: !root.state
|
||||||
|
|
||||||
Anim {
|
Anim {
|
||||||
properties: "opacity,scale"
|
properties: "opacity,scale"
|
||||||
from: 0
|
from: 0
|
||||||
|
|
@ -76,6 +154,8 @@ StyledListView {
|
||||||
}
|
}
|
||||||
|
|
||||||
remove: Transition {
|
remove: Transition {
|
||||||
|
enabled: !root.state
|
||||||
|
|
||||||
Anim {
|
Anim {
|
||||||
properties: "opacity,scale"
|
properties: "opacity,scale"
|
||||||
from: 1
|
from: 1
|
||||||
|
|
@ -154,62 +234,6 @@ StyledListView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior on isAction {
|
|
||||||
ChangeAnim {}
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on isCalc {
|
|
||||||
ChangeAnim {}
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on isScheme {
|
|
||||||
ChangeAnim {}
|
|
||||||
}
|
|
||||||
|
|
||||||
Behavior on isVariant {
|
|
||||||
ChangeAnim {}
|
|
||||||
}
|
|
||||||
|
|
||||||
component ChangeAnim: SequentialAnimation {
|
|
||||||
ParallelAnimation {
|
|
||||||
Anim {
|
|
||||||
target: root
|
|
||||||
property: "opacity"
|
|
||||||
from: 1
|
|
||||||
to: 0
|
|
||||||
duration: Appearance.anim.durations.small
|
|
||||||
easing.bezierCurve: Appearance.anim.curves.standardAccel
|
|
||||||
}
|
|
||||||
Anim {
|
|
||||||
target: root
|
|
||||||
property: "scale"
|
|
||||||
from: 1
|
|
||||||
to: 0.9
|
|
||||||
duration: Appearance.anim.durations.small
|
|
||||||
easing.bezierCurve: Appearance.anim.curves.standardAccel
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PropertyAction {}
|
|
||||||
ParallelAnimation {
|
|
||||||
Anim {
|
|
||||||
target: root
|
|
||||||
property: "opacity"
|
|
||||||
from: 0
|
|
||||||
to: 1
|
|
||||||
duration: Appearance.anim.durations.small
|
|
||||||
easing.bezierCurve: Appearance.anim.curves.standardDecel
|
|
||||||
}
|
|
||||||
Anim {
|
|
||||||
target: root
|
|
||||||
property: "scale"
|
|
||||||
from: 0.9
|
|
||||||
to: 1
|
|
||||||
duration: Appearance.anim.durations.small
|
|
||||||
easing.bezierCurve: Appearance.anim.curves.standardDecel
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
component Anim: NumberAnimation {
|
component Anim: NumberAnimation {
|
||||||
duration: Appearance.anim.durations.normal
|
duration: Appearance.anim.durations.normal
|
||||||
easing.type: Easing.BezierSpline
|
easing.type: Easing.BezierSpline
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
|
||||||
|
import ".."
|
||||||
import qs.config
|
import qs.config
|
||||||
import qs.utils
|
import qs.utils
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
|
||||||
|
import ".."
|
||||||
import qs.config
|
import qs.config
|
||||||
import qs.utils
|
import qs.utils
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue