3 3 import Quickshell.Wayland
4 +import Quickshell.Widgets
4 5 import "Util.js" as Util 5 6 import "caldav.js" as Ical 6 7 import "sysinfo.js" as Sys 1578 1579 property var state: launcherService
? Util.parseJson(launcherService.search(query), {
1580 1581 "selectedIndex":
-1,
1581 - "launcherPanelContract": {
1583 - "launcherPreviewPanel": {
1585 - "scrollableListChrome": {
1582 + "providerIntent":
"all",
1589 1586 "selectedIndex":
-1,
1590 - "launcherPanelContract": {
1592 - "launcherPreviewPanel": {
1594 - "scrollableListChrome": {
1587 + "providerIntent":
"all",
1597 1590 readonly property
var results: state.results
|| []
1598 - readonly property
var selected: results.length
> 0 ? results[
Math.
max(
0,
Math.
min(results.length
- 1, state.selectedIndex
|| 0))]
: ({
1600 - readonly property
var preview: state.launcherPreviewPanel
|| ({
1603 - readonly property
var panel: state.launcherPanelContract
|| ({
1592 + readonly property int rowHeight:
54 1593 + readonly property int rowSpacing:
6 1594 + readonly property int rowStride: rowHeight
+ rowSpacing
1607 1597 function refresh() {
1618 1608 function select(index) {
1609 + if (results.length
=== 0)
1619 1612 const i
= Math.
max(
0,
Math.
min(results.length
- 1,
Number(index)));
1620 1613 const next
= Object.
assign({
1622 1615 next.selectedIndex
= i;
1623 - next.scrollableListChrome
= launcherService
? Util.parseJson(launcherService.scrollableListChrome(results.length, i), next.scrollableListChrome
|| {
1624 - })
: next.scrollableListChrome;
1625 - next.launcherPreviewPanel
= launcherService
? Util.parseJson(launcherService.launcherPreviewPanel(results[i]), next.launcherPreviewPanel
|| {
1626 - })
: next.launcherPreviewPanel;
1618 + const top
= i
* rowStride;
1619 + const bottom
= top
+ rowHeight;
1620 + if (top
< resultsFlick.contentY)
1621 + resultsFlick.contentY
= top;
1622 + else if (bottom
> resultsFlick.contentY
+ resultsFlick.height)
1623 + resultsFlick.contentY
= bottom
- resultsFlick.height;
1630 1626 function wheelSelect(deltaY) {
1634 1630 const current
= Math.
max(
0,
Math.
min(results.length
- 1,
Number(state.selectedIndex
|| 0)));
1635 - const direction
= current
<= 0 ? 1 : (
Number(deltaY)
>= 0 ? 1 : -1);
1632 + const direction
= Number(deltaY)
>= 0 ? -1 : 1;
1636 1633 const next
= Math.
max(
0,
Math.
min(results.length
- 1, current
+ direction));
1638 - if (launcherService
&& typeof launcherService.recordWheelSelection
=== "function")
1639 - launcherService.recordWheelSelection(current, next, deltaY);
1643 1637 function providerColor(provider) {
1672 + objectName:
"launcherResultList" 1674 1674 width: parent.width
1677 + height:
Math.
max(
120, (root.parent
? root.parent.height
: 460)
- 84)
1678 + contentHeight: resultColumn.implicitHeight
1679 + interactive:
false 1681 + boundsBehavior:
Flickable.StopAtBounds
1683 + Behavior on contentY {
1685 + duration: root.theme
&& root.theme.lowPowerMode
? 0 : 140 1686 + easing.type:
Easing.OutCubic
1678 - objectName:
"singleResultList" 1679 - width:
Math.
max(
220, parent.width
- 396)
1683 - objectName:
"providerChips" 1684 - width: parent.width
1688 - model: [
"all",
"app",
"action",
"clipboard",
"calculator",
"window"]
1690 - delegate: Rectangle {
1693 - required property string modelData
1695 - width:
Math.
max(
44, label.implicitWidth
+ 16)
1698 - color: root.theme
? root.theme.withAlpha(root.state.providerIntent
=== chip.modelData
? root.theme.ui.focus
: root.theme.ui.minor, root.state.providerIntent
=== chip.modelData
? 0.18 : 0.08)
: "transparent" 1700 - border.color: root.theme
? (root.state.providerIntent
=== chip.modelData
? root.theme.ui.focus
: root.theme.ui.minor)
: "transparent" 1705 - anchors.centerIn: parent
1708 - selected: root.state.providerIntent
=== chip.modelData
1709 - text: chip.modelData
1693 + width: resultsFlick.width
1694 + spacing: root.rowSpacing
1719 - model: root.results.slice(
0,
7)
1697 + model: root.results.slice(
0,
60)
1721 1699 delegate: Rectangle {
1724 1702 required property int index
1725 1703 required property
var modelData
1704 + readonly property bool
isSelected: index
=== (root.state.selectedIndex
|| 0)
1705 + readonly property bool
isCalc: modelData.provider
=== "calculator" 1706 + readonly property color
tint: root.providerColor(modelData.provider)
1727 1708 width: parent.width
1709 + height: root.rowHeight
1730 - color: root.theme
? root.theme.withAlpha(index
=== root.state.selectedIndex
? root.theme.ui.focus
: root.providerColor(row.modelData.provider), index
=== root.state.selectedIndex
? 0.18 : 0.08)
: "transparent" 1732 - border.color: index
=== root.state.selectedIndex
&& root.theme
? root.theme.ui.focus
: root.providerColor(row.modelData.provider)
1714 + color: root.theme
? root.theme.withAlpha(root.theme.ui.backdrop, rrow.isSelected
? 0.82 : 0.55)
: "transparent" 1715 + border.width: rrow.isSelected
? 2 : 1 1716 + border.color: root.theme
? (rrow.isSelected
? root.theme.ui.focus
: root.theme.withAlpha(rrow.tint,
0.45))
: "transparent" 1735 1720 anchors.left: parent.left
1736 - anchors.leftMargin:
8 1737 - anchors.verticalCenter: parent.verticalCenter
1741 - color: root.theme
? root.theme.withAlpha(root.providerColor(row.modelData.provider),
0.18)
: "transparent" 1743 - border.color: root.providerColor(row.modelData.provider)
1721 + anchors.top: parent.top
1722 + anchors.bottom: parent.bottom
1723 + anchors.margins:
2 1727 + opacity: rrow.isSelected
? 1 : 0.7 1737 + anchors.left: parent.left
1738 + anchors.leftMargin:
10 1739 + anchors.verticalCenter: parent.verticalCenter
1746 + anchors.fill: parent
1747 + visible: rrow.modelData.provider
=== "app" && appIcon.status
=== Image.Ready
1748 + source: (rrow.modelData.provider
=== "app" && String(rrow.modelData.icon
|| "").length
> 0)
? Quickshell.iconPath(
String(rrow.modelData.icon),
true)
: "" 1746 1752 anchors.centerIn: parent
1749 - text:
String(row.modelData.iconRole
|| "?").slice(
0,
2)
1753 + visible:
!appIcon.visible
1754 + text:
String(rrow.modelData.glyph
|| "")
1755 + font.family:
"Symbols Nerd Font Mono" 1756 + font.pixelSize:
18 1755 - anchors.left: parent.left
1756 - anchors.leftMargin:
44 1764 + visible: rrow.isCalc
1765 + anchors.left: iconSlot.right
1766 + anchors.leftMargin:
12 1757 1767 anchors.right: parent.right
1758 - anchors.rightMargin:
8 1759 - anchors.top: parent.top
1760 - anchors.topMargin:
6 1762 - selected: index
=== root.state.selectedIndex
1763 - text: row.modelData.title
|| row.modelData.id
|| "result" 1764 - elide:
Text.ElideRight
1768 + anchors.rightMargin:
12 1769 + anchors.verticalCenter: parent.verticalCenter
1775 + text: rrow.modelData.subtitle
|| rrow.modelData.id
|| "expression" 1776 + width: parent.width
1781 + width: parent.width
1782 + text:
String(rrow.modelData.value
|| rrow.modelData.title
|| "0")
1783 + color: rrow.isSelected
&& root.theme
? root.theme.content.backdrop
: (root.theme
? root.theme.content.normal
: "white")
1784 + font.family:
"IBM Plex Mono" 1785 + font.pixelSize:
22 1787 + elide:
Text.ElideRight
1768 - anchors.left: parent.left
1769 - anchors.leftMargin:
44 1794 + visible:
!rrow.isCalc
1795 + anchors.left: iconSlot.right
1796 + anchors.leftMargin:
12 1770 1797 anchors.right: parent.right
1771 - anchors.rightMargin:
8 1772 - anchors.bottom: parent.bottom
1773 - anchors.bottomMargin:
5 1776 - text:
`${row.modelData.verb
|| "activate"}
· ${row.modelData.subtitle
|| row.modelData.provider}
` 1777 - elide:
Text.ElideRight
1798 + anchors.rightMargin:
12 1799 + anchors.verticalCenter: parent.verticalCenter
1804 + selected: rrow.isSelected
1805 + text: rrow.modelData.title
|| rrow.modelData.id
|| "result" 1806 + width: parent.width
1812 + text:
`${rrow.modelData.verb
|| "activate"}
· ${rrow.modelData.subtitle
|| rrow.modelData.provider}
` 1813 + width: parent.width
1782 1820 anchors.fill: parent
1783 - onClicked: root.select(index)
1821 + onClicked: root.select(rrow.index)
1784 1822 onWheel: (wheel)
=> {
1785 1823 wheel.accepted
= true;
1786 1824 root.wheelSelect(wheel.angleDelta.y);
1797 - objectName:
"sidePreviewPanel" 1801 - color: root.theme
? root.theme.withAlpha(root.theme.ui.backdrop,
0.9)
: "transparent" 1803 - border.color: root.theme
? root.theme.ui.accent
: "transparent" 1806 - anchors.fill: parent
1807 - anchors.margins:
12 1814 - color: root.theme
? root.theme.withAlpha(root.providerColor(root.preview.provider
|| root.selected.provider),
0.2)
: "transparent" 1816 - border.color: root.providerColor(root.preview.provider
|| root.selected.provider)
1819 - anchors.centerIn: parent
1822 - text:
String(root.preview.iconRole
|| root.selected.iconRole
|| "?").slice(
0,
2)
1830 - text: root.preview.title
|| "launcher" 1831 - width: parent.width
1832 - elide:
Text.ElideRight
1837 - text: root.preview.subtitle
|| "type to search" 1838 - width: parent.width
1839 - elide:
Text.ElideRight
1843 - width: parent.width
1845 - color: root.theme
? root.theme.ui.accent
: "transparent" 1849 - model: root.preview.actionRows
|| []
1851 - delegate: Rectangle {
1852 - required property
var modelData
1854 - width: parent.width
1857 - color: root.theme
? root.theme.withAlpha(modelData.primaryAction
? root.theme.ui.focus
: root.theme.ui.minor, modelData.primaryAction
? 0.16 : 0.08)
: "transparent" 1859 - border.color: root.theme
? (modelData.primaryAction
? root.theme.ui.focus
: root.theme.ui.minor)
: "transparent" 1862 - anchors.left: parent.left
1863 - anchors.leftMargin:
8 1864 - anchors.verticalCenter: parent.verticalCenter
1867 - selected:
!!modelData.primaryAction
1868 - text:
`${modelData.label}
· ${modelData.verb}
` 1869 - width: parent.width
- 16 1870 - elide:
Text.ElideRight
1932 1885 objectName:
"keyboardNavigation" 1933 1886 theme: root.theme
1934 1887 variant:
"meta" 1935 - text:
`↑↓ select · Enter ${root.preview.keyboardReturnActivates
|| "primaryAction"}
· ${(root.state.scrollableListChrome
&& root.state.scrollableListChrome.scrollHint
&& root.state.scrollableListChrome.scrollHint.visible)
? "scroll" : "fit"}
` 1888 + text:
"↑↓ select · Enter activate" 1936 1889 width: parent.width
1937 1890 elide:
Text.ElideRight