Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
065b728af6 | ||
|
|
415b1b3cd6 | ||
|
|
1f029922ec | ||
|
|
5e56abd877 | ||
|
|
bb429cb9d9 | ||
|
|
af81bf9c90 | ||
|
|
52a0e29959 | ||
|
|
f65c475455 |
No files matched your search
+29
-2
@@ -1,6 +1,7 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Shapes
|
import QtQuick.Shapes
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
import Quickshell.Hyprland
|
||||||
import Quickshell.Wayland
|
import Quickshell.Wayland
|
||||||
import "../components"
|
import "../components"
|
||||||
import "../notch"
|
import "../notch"
|
||||||
@@ -18,7 +19,10 @@ PanelWindow {
|
|||||||
readonly property int outerMargin: BarDrawers.margin
|
readonly property int outerMargin: BarDrawers.margin
|
||||||
// The window reaches below the bar (input is masked to the bar) so the
|
// The window reaches below the bar (input is masked to the bar) so the
|
||||||
// HyprGlass layer edge is not on the bar's bottom edge, where drawers join.
|
// HyprGlass layer edge is not on the bar's bottom edge, where drawers join.
|
||||||
implicitHeight: BarDrawers.bottom + BarDrawers.overhang
|
// While the launcher is open in the notch, the window is tall enough for
|
||||||
|
// it to grow down; input stays masked to the shapes.
|
||||||
|
readonly property bool tall: notch && (notchPill.searching || notchPill.height > BarDrawers.bottom + 1)
|
||||||
|
implicitHeight: tall ? Math.ceil(BarDrawers.bottom + notchPill.maxBodyHeight + 40) : BarDrawers.bottom + BarDrawers.overhang
|
||||||
// Notch mode splits the bar into a left island, the centre notch and a
|
// Notch mode splits the bar into a left island, the centre notch and a
|
||||||
// right island; only those take input.
|
// right island; only those take input.
|
||||||
readonly property bool notch: ShellState.notchMode
|
readonly property bool notch: ShellState.notchMode
|
||||||
@@ -33,6 +37,29 @@ PanelWindow {
|
|||||||
exclusionMode: ExclusionMode.Normal
|
exclusionMode: ExclusionMode.Normal
|
||||||
exclusiveZone: BarDrawers.bottom
|
exclusiveZone: BarDrawers.bottom
|
||||||
WlrLayershell.namespace: "glassMxrph-bar"
|
WlrLayershell.namespace: "glassMxrph-bar"
|
||||||
|
// The notch's search takes the keyboard while it is open on this screen;
|
||||||
|
// a click anywhere else closes it.
|
||||||
|
readonly property bool searching: notch && ShellState.notchLauncher && ScreenService.current(ShellState.launcherScreen) === screen
|
||||||
|
WlrLayershell.keyboardFocus: searching ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
|
||||||
|
// The grab starts once the bar holds the keyboard; started together with
|
||||||
|
// the focus change, Hyprland clears it at once and the search closes.
|
||||||
|
property bool grabbing: false
|
||||||
|
onSearchingChanged: {
|
||||||
|
grabbing = false;
|
||||||
|
if (searching)
|
||||||
|
grabStart.restart();
|
||||||
|
}
|
||||||
|
Timer {
|
||||||
|
id: grabStart
|
||||||
|
interval: 150
|
||||||
|
onTriggered: root.grabbing = root.searching
|
||||||
|
}
|
||||||
|
HyprlandFocusGrab {
|
||||||
|
windows: [root]
|
||||||
|
active: root.grabbing
|
||||||
|
onCleared: if (root.grabbing)
|
||||||
|
ShellState.launcherOpen = false
|
||||||
|
}
|
||||||
Component.onCompleted: TrayService.registerBar(root)
|
Component.onCompleted: TrayService.registerBar(root)
|
||||||
Component.onDestruction: TrayService.unregisterBar(root)
|
Component.onDestruction: TrayService.unregisterBar(root)
|
||||||
GlassPanel {
|
GlassPanel {
|
||||||
@@ -112,6 +139,6 @@ PanelWindow {
|
|||||||
width: implicitWidth
|
width: implicitWidth
|
||||||
height: implicitHeight
|
height: implicitHeight
|
||||||
// The open notch window draws over this spot on its own screen.
|
// The open notch window draws over this spot on its own screen.
|
||||||
visible: root.notch && !(ShellState.notchWindow && ShellState.notchWindow.visible && ShellState.notchWindow.screen === root.screen) && !(ShellState.launcherOpen && ScreenService.current(ShellState.launcherScreen) === root.screen) && !(ShellState.wallpaperWindow && ShellState.wallpaperWindow.visible && ShellState.wallpaperWindow.screen === root.screen)
|
visible: root.notch && !(ShellState.notchWindow && ShellState.notchWindow.visible && ShellState.notchWindow.screen === root.screen) && !(ShellState.wallpaperWindow && ShellState.wallpaperWindow.visible && ShellState.wallpaperWindow.screen === root.screen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Widgets
|
||||||
|
import "../services"
|
||||||
|
import "../theme"
|
||||||
|
|
||||||
|
// What the collapsed notch shows: the time, plus cover art and a small
|
||||||
|
// visualizer while audio plays. Shared by the pill and by the launcher, which
|
||||||
|
// fades it out as it grows out of the notch.
|
||||||
|
Row {
|
||||||
|
id: root
|
||||||
|
property bool playing: MediaService.playing
|
||||||
|
spacing: 10
|
||||||
|
ClippingRectangle {
|
||||||
|
visible: root.playing
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
width: 22
|
||||||
|
height: 22
|
||||||
|
radius: 6
|
||||||
|
color: Theme.fill
|
||||||
|
Image {
|
||||||
|
anchors.fill: parent
|
||||||
|
source: MediaService.artwork
|
||||||
|
sourceSize: Qt.size(44, 44)
|
||||||
|
fillMode: Image.PreserveAspectCrop
|
||||||
|
asynchronous: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
text: Qt.formatDateTime(clock.date, ConfigService.ready && !ConfigService.data.bar.clock.use24Hour ? "h:mm" : "HH:mm")
|
||||||
|
color: Theme.text
|
||||||
|
font.pixelSize: 14
|
||||||
|
font.weight: Font.DemiBold
|
||||||
|
font.features: {
|
||||||
|
"tnum": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Row {
|
||||||
|
visible: root.playing
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
height: 16
|
||||||
|
spacing: 2
|
||||||
|
Repeater {
|
||||||
|
model: 8
|
||||||
|
Rectangle {
|
||||||
|
required property int index
|
||||||
|
// Every third Cava band, so the eight span the spectrum.
|
||||||
|
readonly property real level: CavaService.bars[index * 3] || 0
|
||||||
|
width: 3
|
||||||
|
height: Math.max(3, 16 * level)
|
||||||
|
y: 16 - height
|
||||||
|
radius: 1.5
|
||||||
|
color: Theme.accent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SystemClock {
|
||||||
|
id: clock
|
||||||
|
precision: SystemClock.Minutes
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -272,6 +272,7 @@
|
|||||||
"opacity": 0,
|
"opacity": 0,
|
||||||
"color": "",
|
"color": "",
|
||||||
"glassOnOpen": false,
|
"glassOnOpen": false,
|
||||||
|
"launcherMatch": true,
|
||||||
"openSpeed": 100,
|
"openSpeed": 100,
|
||||||
"closeSpeed": 100,
|
"closeSpeed": 100,
|
||||||
"colorSpeed": 100,
|
"colorSpeed": 100,
|
||||||
|
|||||||
@@ -128,6 +128,8 @@ Singleton {
|
|||||||
// "emoji" is the Emoji Picker.
|
// "emoji" is the Emoji Picker.
|
||||||
// Changing it on an open launcher switches in place.
|
// Changing it on an open launcher switches in place.
|
||||||
property string launcherMode: "apps"
|
property string launcherMode: "apps"
|
||||||
|
// Notch mode opens the launcher inside the notch itself (every mode).
|
||||||
|
readonly property bool notchLauncher: notchMode && launcherOpen
|
||||||
function activeScreen() {
|
function activeScreen() {
|
||||||
return ScreenService.active;
|
return ScreenService.active;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
pragma ComponentBehavior: Bound
|
pragma ComponentBehavior: Bound
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
|
||||||
import QtQuick.Layouts
|
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Wayland
|
import Quickshell.Wayland
|
||||||
import "../components"
|
import "../components"
|
||||||
import "../services"
|
|
||||||
import "../theme"
|
import "../theme"
|
||||||
import "../core"
|
import "../core"
|
||||||
|
|
||||||
@@ -16,6 +13,8 @@ import "../core"
|
|||||||
// in the same bar, newest first, without closing the window to switch.
|
// in the same bar, newest first, without closing the window to switch.
|
||||||
// Emoji mode (>emoji, `glassmxrph emoji`) shows a searchable emoji grid the
|
// Emoji mode (>emoji, `glassmxrph emoji`) shows a searchable emoji grid the
|
||||||
// same way; the selected emoji's name is the section label.
|
// same way; the selected emoji's name is the section label.
|
||||||
|
// The contents are LauncherView; in notch mode the notch hosts that instead
|
||||||
|
// and this window stays closed.
|
||||||
// Runtime selects the concrete Wayland layer implementation.
|
// Runtime selects the concrete Wayland layer implementation.
|
||||||
// qmllint disable uncreatable-type
|
// qmllint disable uncreatable-type
|
||||||
PanelWindow {
|
PanelWindow {
|
||||||
@@ -28,166 +27,23 @@ PanelWindow {
|
|||||||
left: true
|
left: true
|
||||||
right: true
|
right: true
|
||||||
}
|
}
|
||||||
visible: ShellState.launcherOpen || panel.opacity > 0.01
|
readonly property bool open: ShellState.launcherOpen && !ShellState.notchMode
|
||||||
|
visible: open || panel.opacity > 0.01
|
||||||
color: Theme.transparent
|
color: Theme.transparent
|
||||||
exclusionMode: ExclusionMode.Ignore
|
exclusionMode: ExclusionMode.Ignore
|
||||||
WlrLayershell.namespace: "glassMxrph-launcher"
|
WlrLayershell.namespace: "glassMxrph-launcher"
|
||||||
WlrLayershell.layer: WlrLayer.Overlay
|
WlrLayershell.layer: WlrLayer.Overlay
|
||||||
WlrLayershell.keyboardFocus: ShellState.launcherOpen ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
|
WlrLayershell.keyboardFocus: open ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
|
||||||
readonly property var options: ConfigService.ready ? ConfigService.data.launcher : ({
|
readonly property var options: view.options
|
||||||
width: 680,
|
|
||||||
maxResults: 50,
|
|
||||||
showDescriptions: true
|
|
||||||
})
|
|
||||||
readonly property string query: search.text.trim()
|
|
||||||
readonly property bool clipboardMode: ShellState.launcherMode === "clipboard"
|
|
||||||
readonly property bool emojiMode: ShellState.launcherMode === "emoji"
|
|
||||||
readonly property bool commandMode: !clipboardMode && !emojiMode && query.startsWith(">")
|
|
||||||
property bool browsing: false
|
|
||||||
readonly property bool showList: clipboardMode || !emojiMode && query !== ""
|
|
||||||
readonly property bool showGrid: !showList && !emojiMode && browsing
|
|
||||||
// Arrow keys move through whichever grid is showing.
|
|
||||||
readonly property int columns: emojiMode ? emojiColumns : showGrid ? gridColumns : 1
|
|
||||||
readonly property var allApps: ApplicationsService.launchable.map(entry => ({
|
|
||||||
id: entry.id,
|
|
||||||
title: entry.name,
|
|
||||||
description: entry.genericName || entry.comment || entry.id,
|
|
||||||
entry: entry
|
|
||||||
}))
|
|
||||||
readonly property var clipboardResults: clipboardMode && ShellState.launcherOpen ? ClipboardService.filter(query).map(e => ({
|
|
||||||
id: e.id,
|
|
||||||
title: e.text.replace(/\s+/g, " ").trim(),
|
|
||||||
description: "",
|
|
||||||
clip: e
|
|
||||||
})) : []
|
|
||||||
readonly property var emojiResults: emojiMode && ShellState.launcherOpen ? EmojiService.filter(query).map(e => ({
|
|
||||||
id: e.emoji,
|
|
||||||
title: e.name,
|
|
||||||
description: "",
|
|
||||||
glyph: e
|
|
||||||
})) : []
|
|
||||||
readonly property var results: clipboardMode ? clipboardResults : emojiMode ? emojiResults : showList ? (commandMode ? commands.results : apps.results) : showGrid ? allApps : []
|
|
||||||
property int selectedIndex: 0
|
|
||||||
property string launchError: ""
|
|
||||||
// Room is kept for the mode pills on the right of the bar.
|
// Room is kept for the mode pills on the right of the bar.
|
||||||
readonly property int pillSize: 48
|
readonly property int pillSize: 48
|
||||||
readonly property real pillsWidth: 2 * pillSize + 2 * 10
|
readonly property real pillsWidth: 2 * pillSize + 2 * 10
|
||||||
readonly property real targetWidth: Math.min(options.width, root.width - 40 - (notch ? 0 : 2 * pillsWidth))
|
readonly property real targetWidth: Math.min(options.width, root.width - 40 - 2 * pillsWidth)
|
||||||
// A hovered mode pill names itself in the empty search bar.
|
|
||||||
property string pillHover: ""
|
|
||||||
readonly property int barHeight: 60
|
|
||||||
// Notch mode: the launcher drops out of the notch at the top edge. The
|
|
||||||
// panel's top corners sit above the screen and concave ears join it there.
|
|
||||||
readonly property bool notch: ShellState.notchMode
|
|
||||||
// Pills sit inside the search bar in notch mode, smaller.
|
|
||||||
readonly property int notchPill: 36
|
|
||||||
readonly property real maxBodyHeight: Math.min(460, root.height * 0.78 - barHeight - (notch ? 0 : root.height * 0.22))
|
|
||||||
// Clipboard mode shows the latest five rows; the rest scroll.
|
|
||||||
readonly property real clipboardRows: 5 * 48 - 2
|
|
||||||
// Emoji mode shows six rows of the grid; the rest scroll.
|
|
||||||
readonly property int emojiCell: 52
|
|
||||||
readonly property int emojiColumns: Math.max(1, Math.floor((targetWidth - 24) / emojiCell))
|
|
||||||
readonly property real emojiRows: 6 * emojiCell
|
|
||||||
readonly property real bodyHeight: emojiMode ? Math.min(maxBodyHeight, Math.max(84, Math.min(emojiGrid.contentHeight, emojiRows) + 42)) : showList ? Math.min(maxBodyHeight, Math.max(84, (clipboardMode ? Math.min(list.contentHeight, clipboardRows) : list.contentHeight) + 46 + (launchError ? 22 : 0))) : showGrid ? Math.min(maxBodyHeight, grid.contentHeight + 46) : 0
|
|
||||||
// Mode switches resize without animating, so >clipboard lands in place.
|
|
||||||
property bool snapping: false
|
|
||||||
Timer {
|
|
||||||
id: unsnap
|
|
||||||
interval: 120
|
|
||||||
onTriggered: root.snapping = false
|
|
||||||
}
|
|
||||||
readonly property int gridColumns: Math.max(1, Math.floor((targetWidth - 24) / 112))
|
|
||||||
onResultsChanged: {
|
|
||||||
selectedIndex = 0;
|
|
||||||
list.contentY = 0;
|
|
||||||
grid.contentY = 0;
|
|
||||||
emojiGrid.contentY = 0;
|
|
||||||
emojiGrid.hovered = "";
|
|
||||||
}
|
|
||||||
function select(offset) {
|
|
||||||
if (!results.length)
|
|
||||||
return;
|
|
||||||
selectedIndex = Math.max(0, Math.min(results.length - 1, selectedIndex + offset));
|
|
||||||
if (emojiMode)
|
|
||||||
emojiGrid.positionViewAtIndex(selectedIndex, GridView.Contain);
|
|
||||||
else if (showGrid)
|
|
||||||
grid.positionViewAtIndex(selectedIndex, GridView.Contain);
|
|
||||||
else
|
|
||||||
list.positionViewAtIndex(selectedIndex, ListView.Contain);
|
|
||||||
}
|
|
||||||
function activate(index) {
|
|
||||||
const result = results[index];
|
|
||||||
if (!result)
|
|
||||||
return;
|
|
||||||
if (result.clip) {
|
|
||||||
ClipboardService.copy(result.clip);
|
|
||||||
ShellState.launcherOpen = false;
|
|
||||||
} else if (result.glyph) {
|
|
||||||
EmojiService.copy(result.glyph);
|
|
||||||
ShellState.launcherOpen = false;
|
|
||||||
} else if (result.command) {
|
|
||||||
const command = CommandRegistry.commands.find(c => c.id === result.id);
|
|
||||||
if (!command || !command.stay)
|
|
||||||
ShellState.launcherOpen = false;
|
|
||||||
CommandRegistry.execute(result.id);
|
|
||||||
} else if (ApplicationsService.launch(result.entry, null))
|
|
||||||
ShellState.launcherOpen = false;
|
|
||||||
else
|
|
||||||
launchError = ApplicationsService.error;
|
|
||||||
}
|
|
||||||
function toggleBrowse() {
|
function toggleBrowse() {
|
||||||
if (clipboardMode || emojiMode) {
|
view.toggleBrowse();
|
||||||
ShellState.launcherMode = "apps";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
browsing = !browsing;
|
|
||||||
if (browsing)
|
|
||||||
search.clear();
|
|
||||||
selectedIndex = 0;
|
|
||||||
search.forceActiveFocus();
|
|
||||||
}
|
}
|
||||||
Component.onCompleted: LauncherState.window = root
|
Component.onCompleted: LauncherState.window = root
|
||||||
Component.onDestruction: LauncherState.window = null
|
Component.onDestruction: LauncherState.window = null
|
||||||
Connections {
|
|
||||||
target: ShellState
|
|
||||||
function onLauncherOpenChanged() {
|
|
||||||
if (ShellState.launcherOpen) {
|
|
||||||
search.text = "";
|
|
||||||
root.browsing = false;
|
|
||||||
root.launchError = "";
|
|
||||||
root.selectedIndex = 0;
|
|
||||||
ClipboardService.refresh();
|
|
||||||
if (root.emojiMode)
|
|
||||||
EmojiService.load();
|
|
||||||
Qt.callLater(() => search.forceActiveFocus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function onLauncherModeChanged() {
|
|
||||||
if (root.emojiMode)
|
|
||||||
EmojiService.load();
|
|
||||||
if (!ShellState.launcherOpen)
|
|
||||||
return;
|
|
||||||
root.snapping = true;
|
|
||||||
unsnap.restart();
|
|
||||||
search.text = "";
|
|
||||||
root.browsing = false;
|
|
||||||
root.launchError = "";
|
|
||||||
root.selectedIndex = 0;
|
|
||||||
search.forceActiveFocus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AppSearch {
|
|
||||||
id: apps
|
|
||||||
enabled: ShellState.launcherOpen && root.showList && !root.commandMode
|
|
||||||
query: search.text
|
|
||||||
limit: root.options.maxResults
|
|
||||||
}
|
|
||||||
CommandSearch {
|
|
||||||
id: commands
|
|
||||||
enabled: ShellState.launcherOpen && root.commandMode
|
|
||||||
query: search.text
|
|
||||||
limit: root.options.maxResults
|
|
||||||
}
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: ShellState.launcherOpen = false
|
onClicked: ShellState.launcherOpen = false
|
||||||
@@ -197,38 +53,24 @@ PanelWindow {
|
|||||||
Row {
|
Row {
|
||||||
id: pills
|
id: pills
|
||||||
objectName: "launcherPills"
|
objectName: "launcherPills"
|
||||||
x: root.notch ? panel.x + panel.width - width - 14 : panel.x + panel.width + 10
|
x: panel.x + panel.width + 10
|
||||||
y: panel.y + (root.barHeight - (root.notch ? root.notchPill : root.pillSize)) / 2
|
y: panel.y + (view.barHeight - root.pillSize) / 2
|
||||||
z: 1
|
z: 1
|
||||||
spacing: root.notch ? 6 : 10
|
spacing: 10
|
||||||
opacity: panel.opacity
|
opacity: panel.opacity
|
||||||
scale: panel.scale
|
scale: panel.scale
|
||||||
Repeater {
|
Repeater {
|
||||||
model: [
|
model: view.modes
|
||||||
{
|
|
||||||
mode: "clipboard",
|
|
||||||
label: "Clipboard",
|
|
||||||
glyph: "",
|
|
||||||
fallback: "⎘"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
mode: "emoji",
|
|
||||||
label: "Emoji",
|
|
||||||
glyph: "",
|
|
||||||
fallback: "☺"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
GlassPanel {
|
GlassPanel {
|
||||||
id: pill
|
id: pill
|
||||||
required property var modelData
|
required property var modelData
|
||||||
readonly property bool active: ShellState.launcherMode === modelData.mode
|
readonly property bool active: ShellState.launcherMode === modelData.mode
|
||||||
objectName: "launcherPill-" + modelData.mode
|
objectName: "launcherPill-" + modelData.mode
|
||||||
width: root.notch ? root.notchPill : root.pillSize
|
width: root.pillSize
|
||||||
height: width
|
height: width
|
||||||
radius: width / 2
|
radius: width / 2
|
||||||
color: active ? Theme.accent : root.notch ? (pillArea.containsMouse ? Theme.hover : Theme.fill) : Qt.alpha(Theme.surface, Math.min(1, surfaceOpacity + (pillArea.containsMouse ? 0.18 : 0)))
|
color: active ? Theme.accent : Qt.alpha(Theme.surface, Math.min(1, surfaceOpacity + (pillArea.containsMouse ? 0.18 : 0)))
|
||||||
border.color: root.notch ? Theme.hairline : Theme.border
|
border.color: Theme.border
|
||||||
plain: root.notch
|
|
||||||
Accessible.role: Accessible.Button
|
Accessible.role: Accessible.Button
|
||||||
Accessible.name: modelData.label
|
Accessible.name: modelData.label
|
||||||
scale: pillArea.pressed ? 0.92 : 1
|
scale: pillArea.pressed ? 0.92 : 1
|
||||||
@@ -242,7 +84,7 @@ PanelWindow {
|
|||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: Icons.available ? pill.modelData.glyph : pill.modelData.fallback
|
text: Icons.available ? pill.modelData.glyph : pill.modelData.fallback
|
||||||
font.family: Icons.available ? Icons.family : ""
|
font.family: Icons.available ? Icons.family : ""
|
||||||
font.pixelSize: root.notch ? 17 : 21
|
font.pixelSize: 21
|
||||||
color: pill.active ? Theme.accentText : Theme.text
|
color: pill.active ? Theme.accentText : Theme.text
|
||||||
}
|
}
|
||||||
MouseArea {
|
MouseArea {
|
||||||
@@ -252,441 +94,57 @@ PanelWindow {
|
|||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onContainsMouseChanged: {
|
onContainsMouseChanged: {
|
||||||
if (containsMouse)
|
if (containsMouse)
|
||||||
root.pillHover = pill.modelData.label;
|
view.pillHover = pill.modelData.label;
|
||||||
else if (root.pillHover === pill.modelData.label)
|
else if (view.pillHover === pill.modelData.label)
|
||||||
root.pillHover = "";
|
view.pillHover = "";
|
||||||
}
|
|
||||||
onClicked: {
|
|
||||||
ShellState.launcherMode = pill.active ? "apps" : pill.modelData.mode;
|
|
||||||
search.forceActiveFocus();
|
|
||||||
}
|
}
|
||||||
|
onClicked: view.toggleMode(pill.modelData.mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Notch mode: the notch's own shape (ears at the top edge) behind the
|
|
||||||
// panel, which then draws no glass of its own.
|
|
||||||
DrawerShape {
|
|
||||||
visible: root.notch
|
|
||||||
x: panel.x - BarDrawers.ear
|
|
||||||
y: 0
|
|
||||||
opacity: panel.opacity
|
|
||||||
bodyWidth: panel.width
|
|
||||||
bodyHeight: panel.height
|
|
||||||
ear: BarDrawers.ear
|
|
||||||
radius: panel.radius
|
|
||||||
// Docked colour, turning to the open fill as the launcher unfolds.
|
|
||||||
fillColor: ShellState.launcherOpen ? Theme.notchOpenFill : Theme.notchFill
|
|
||||||
Behavior on fillColor {
|
|
||||||
ColorAnimation {
|
|
||||||
duration: ShellState.launcherOpen ? Theme.notchColorDuration : Math.min(Theme.notchColorDuration, Theme.notchCloseDuration)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GlassPanel {
|
GlassPanel {
|
||||||
id: panel
|
id: panel
|
||||||
objectName: "launcherSurface"
|
objectName: "launcherSurface"
|
||||||
x: Math.round((root.width - width) / 2)
|
x: Math.round((root.width - width) / 2)
|
||||||
y: root.notch ? 0 : Math.round(root.height * 0.22)
|
y: Math.round(root.height * 0.22)
|
||||||
// Notch mode grows out of the collapsed notch and shrinks back into it.
|
width: root.open ? root.targetWidth : Math.min(320, root.targetWidth)
|
||||||
width: ShellState.launcherOpen ? root.targetWidth : root.notch ? ShellState.notchPillWidth : Math.min(320, root.targetWidth)
|
height: view.barHeight + view.bodyHeight
|
||||||
height: root.notch && !ShellState.launcherOpen ? BarDrawers.bottom : root.barHeight + root.bodyHeight
|
color: Qt.alpha(Theme.surface, surfaceOpacity)
|
||||||
color: root.notch ? Theme.transparent : Qt.alpha(Theme.surface, surfaceOpacity)
|
border.width: 1
|
||||||
border.width: root.notch ? 0 : 1
|
radius: Math.min(Theme.radius + 6, view.barHeight / 2)
|
||||||
plain: root.notch
|
opacity: root.open ? 1 : 0
|
||||||
radius: Math.min(Theme.radius + 6, root.barHeight / 2)
|
scale: root.open ? 1 : 1 - 0.04 * Theme.intensity
|
||||||
opacity: ShellState.launcherOpen ? 1 : 0
|
|
||||||
scale: ShellState.launcherOpen || root.notch ? 1 : 1 - 0.04 * Theme.intensity
|
|
||||||
clip: true
|
clip: true
|
||||||
Behavior on width {
|
Behavior on width {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
duration: !root.notch ? Theme.duration : ShellState.launcherOpen ? Theme.notchOpenDuration : Theme.notchCloseDuration
|
duration: Theme.duration
|
||||||
easing.type: Easing.OutCubic
|
easing.type: Easing.OutCubic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Behavior on height {
|
Behavior on height {
|
||||||
enabled: !root.snapping
|
enabled: !view.snapping
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
duration: !root.notch ? Theme.duration : ShellState.launcherOpen ? Theme.notchOpenDuration : Theme.notchCloseDuration
|
duration: Theme.duration
|
||||||
easing.type: Easing.OutCubic
|
easing.type: Easing.OutCubic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Behavior on opacity {
|
Behavior on opacity {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
duration: !root.notch ? Theme.duration : ShellState.launcherOpen ? Theme.notchOpenDuration : Theme.notchCloseDuration
|
duration: Theme.duration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Behavior on scale {
|
Behavior on scale {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
duration: !root.notch ? Theme.duration : ShellState.launcherOpen ? Theme.notchOpenDuration : Theme.notchCloseDuration
|
duration: Theme.duration
|
||||||
easing.type: Easing.OutCubic
|
easing.type: Easing.OutCubic
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MouseArea {
|
LauncherView {
|
||||||
|
id: view
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
} // Consume inside clicks without dismissing.
|
active: root.open
|
||||||
|
maxBodyHeight: Math.min(460, root.height * 0.78 - barHeight - root.height * 0.22)
|
||||||
// Search bar
|
|
||||||
RowLayout {
|
|
||||||
id: bar
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.top: parent.top
|
|
||||||
height: root.barHeight
|
|
||||||
anchors.leftMargin: 12
|
|
||||||
// Room for the mode pills inside the bar in notch mode.
|
|
||||||
anchors.rightMargin: root.notch ? 18 + 2 * root.notchPill + 6 + 8 : 18
|
|
||||||
spacing: 10
|
|
||||||
Rectangle {
|
|
||||||
objectName: "launcherBrowse"
|
|
||||||
Layout.preferredWidth: 38
|
|
||||||
Layout.preferredHeight: 38
|
|
||||||
radius: 12
|
|
||||||
color: root.browsing ? Theme.accent : browseArea.containsMouse ? Theme.hover : Theme.transparent
|
|
||||||
Accessible.role: Accessible.Button
|
|
||||||
Accessible.name: root.clipboardMode || root.emojiMode ? "Back to search" : root.browsing ? "Hide applications" : "Show all applications"
|
|
||||||
Behavior on color {
|
|
||||||
ColorAnimation {
|
|
||||||
duration: Theme.duration / 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Text {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: root.commandMode ? ">" : !Icons.available ? (root.clipboardMode ? "⎘" : root.emojiMode ? "☺" : "⌕") : root.clipboardMode ? "" : root.emojiMode ? "" : ""
|
|
||||||
font.family: Icons.available && !root.commandMode ? Icons.family : ""
|
|
||||||
color: root.browsing ? Theme.accentText : Theme.textSecondary
|
|
||||||
font.pixelSize: 20
|
|
||||||
}
|
|
||||||
MouseArea {
|
|
||||||
id: browseArea
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
onClicked: root.toggleBrowse()
|
|
||||||
}
|
|
||||||
GlassToolTip {
|
|
||||||
visible: browseArea.containsMouse
|
|
||||||
delay: 600
|
|
||||||
text: root.clipboardMode || root.emojiMode ? "Back to search" : root.browsing ? "Hide applications" : "All applications"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TextField {
|
|
||||||
id: search
|
|
||||||
objectName: "launcherSearch"
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.preferredHeight: 40
|
|
||||||
placeholderText: root.pillHover || (root.clipboardMode ? "Clipboard History" : root.emojiMode ? "Search emoji" : root.browsing ? "Search applications" : "Search :3")
|
|
||||||
color: Theme.text
|
|
||||||
placeholderTextColor: Theme.textSecondary
|
|
||||||
selectByMouse: true
|
|
||||||
font.pixelSize: 22
|
|
||||||
font.weight: Font.Light
|
|
||||||
background: Item {}
|
|
||||||
padding: 0
|
|
||||||
maximumLength: 256
|
|
||||||
onTextEdited: root.launchError = ""
|
|
||||||
Keys.onEscapePressed: {
|
|
||||||
if (text !== "")
|
|
||||||
clear();
|
|
||||||
else if (root.browsing)
|
|
||||||
root.browsing = false;
|
|
||||||
else
|
|
||||||
ShellState.launcherOpen = false;
|
|
||||||
}
|
|
||||||
Keys.onDownPressed: {
|
|
||||||
if (!root.showList && !root.browsing && !root.emojiMode)
|
|
||||||
root.browsing = true;
|
|
||||||
else
|
|
||||||
root.select(root.columns);
|
|
||||||
}
|
|
||||||
Keys.onUpPressed: root.select(-root.columns)
|
|
||||||
Keys.onRightPressed: event => {
|
|
||||||
if (root.columns > 1 || event.modifiers & Qt.ControlModifier)
|
|
||||||
root.select(1);
|
|
||||||
else
|
|
||||||
event.accepted = false;
|
|
||||||
}
|
|
||||||
Keys.onLeftPressed: event => {
|
|
||||||
if (root.columns > 1 || event.modifiers & Qt.ControlModifier)
|
|
||||||
root.select(-1);
|
|
||||||
else
|
|
||||||
event.accepted = false;
|
|
||||||
}
|
|
||||||
// Shift+Delete removes the selected clipboard entry from history.
|
|
||||||
Keys.onDeletePressed: event => {
|
|
||||||
if (root.clipboardMode && event.modifiers & Qt.ShiftModifier && root.results[root.selectedIndex])
|
|
||||||
ClipboardService.remove(root.results[root.selectedIndex].clip);
|
|
||||||
else
|
|
||||||
event.accepted = false;
|
|
||||||
}
|
|
||||||
Keys.onTabPressed: root.select(1)
|
|
||||||
Keys.onBacktabPressed: root.select(-1)
|
|
||||||
Keys.onReturnPressed: root.activate(root.selectedIndex)
|
|
||||||
Keys.onEnterPressed: root.activate(root.selectedIndex)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Results (typing) or the application grid (magnifying glass).
|
|
||||||
Item {
|
|
||||||
id: body
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.top: bar.bottom
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
visible: root.bodyHeight > 0 || panel.height > root.barHeight + 1
|
|
||||||
Rectangle {
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.leftMargin: 14
|
|
||||||
anchors.rightMargin: 14
|
|
||||||
height: 1
|
|
||||||
color: Theme.border
|
|
||||||
}
|
|
||||||
Text {
|
|
||||||
id: section
|
|
||||||
x: 22
|
|
||||||
y: 12
|
|
||||||
text: root.emojiMode ? (emojiGrid.hovered || (root.results[root.selectedIndex] || {}).title || "") : root.clipboardMode ? (!root.results.length ? "" : root.query ? "Matches" : "Recent") : root.showGrid ? "Applications" : root.commandMode ? "Settings" : root.results.length ? "Top hits" : ""
|
|
||||||
color: Theme.textSecondary
|
|
||||||
font.pixelSize: 11
|
|
||||||
font.weight: Font.DemiBold
|
|
||||||
}
|
|
||||||
ListView {
|
|
||||||
id: list
|
|
||||||
objectName: "launcherResults"
|
|
||||||
visible: root.showList
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.topMargin: 32
|
|
||||||
anchors.leftMargin: 8
|
|
||||||
anchors.rightMargin: 8
|
|
||||||
anchors.bottomMargin: root.launchError ? 30 : 8
|
|
||||||
clip: true
|
|
||||||
model: root.showList ? root.results : []
|
|
||||||
spacing: 2
|
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
|
||||||
ScrollBar.vertical: ScrollBar {}
|
|
||||||
delegate: Rectangle {
|
|
||||||
id: resultRow
|
|
||||||
required property var modelData
|
|
||||||
required property int index
|
|
||||||
readonly property bool selected: root.selectedIndex === index
|
|
||||||
width: list.width
|
|
||||||
height: 46
|
|
||||||
radius: 10
|
|
||||||
color: selected ? Theme.accent : mouse.containsMouse ? Theme.hover : Theme.transparent
|
|
||||||
RowLayout {
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.leftMargin: 10
|
|
||||||
anchors.rightMargin: 12
|
|
||||||
spacing: 12
|
|
||||||
Item {
|
|
||||||
readonly property var copied: resultRow.modelData.clip
|
|
||||||
// Copied images get a wider thumbnail slot.
|
|
||||||
Layout.preferredWidth: copied && copied.thumb ? 52 : 30
|
|
||||||
Layout.preferredHeight: 30
|
|
||||||
Image {
|
|
||||||
id: icon
|
|
||||||
anchors.fill: parent
|
|
||||||
source: parent.copied ? (parent.copied.thumb ? "file://" + parent.copied.thumb : "") : resultRow.modelData.entry ? ApplicationsService.icon(resultRow.modelData.entry) : ""
|
|
||||||
sourceSize: parent.copied ? Qt.size(104, 60) : Qt.size(60, 60)
|
|
||||||
fillMode: Image.PreserveAspectFit
|
|
||||||
asynchronous: !!parent.copied
|
|
||||||
}
|
|
||||||
Text {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
visible: icon.source.toString() === "" || icon.status === Image.Error
|
|
||||||
text: parent.copied ? (Icons.available ? (parent.copied.image ? "" : "") : "¶") : resultRow.modelData.command ? "⚙" : resultRow.modelData.title.slice(0, 2).toUpperCase()
|
|
||||||
font.family: parent.copied && Icons.available ? Icons.family : ""
|
|
||||||
color: resultRow.selected ? Theme.accentText : Theme.textSecondary
|
|
||||||
font.pixelSize: parent.copied ? 18 : 16
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Text {
|
|
||||||
text: resultRow.modelData.title
|
|
||||||
// Clipboard text is shown as is, never as markup.
|
|
||||||
textFormat: Text.PlainText
|
|
||||||
Layout.fillWidth: !!resultRow.modelData.clip
|
|
||||||
elide: Text.ElideRight
|
|
||||||
color: resultRow.selected ? Theme.accentText : Theme.text
|
|
||||||
font.pixelSize: 14
|
|
||||||
font.weight: Font.Medium
|
|
||||||
}
|
|
||||||
Text {
|
|
||||||
visible: root.options.showDescriptions && !resultRow.modelData.clip
|
|
||||||
text: "— " + resultRow.modelData.description
|
|
||||||
Layout.fillWidth: true
|
|
||||||
elide: Text.ElideRight
|
|
||||||
color: resultRow.selected ? Qt.alpha(Theme.accentText, 0.75) : Theme.textSecondary
|
|
||||||
font.pixelSize: 12
|
|
||||||
}
|
|
||||||
Item {
|
|
||||||
visible: !root.options.showDescriptions && !resultRow.modelData.clip
|
|
||||||
Layout.fillWidth: true
|
|
||||||
}
|
|
||||||
Text {
|
|
||||||
text: resultRow.modelData.clip ? (resultRow.modelData.clip.image ? "Image" : "Text") : resultRow.modelData.command ? resultRow.modelData.kind : "Application"
|
|
||||||
color: resultRow.selected ? Qt.alpha(Theme.accentText, 0.75) : Theme.textSecondary
|
|
||||||
font.pixelSize: 11
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MouseArea {
|
|
||||||
id: mouse
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
// Hover highlights locally; only keys change keyboard selection.
|
|
||||||
// Layout/scroll movement under a stationary pointer must not steal it.
|
|
||||||
onClicked: root.activate(resultRow.index)
|
|
||||||
}
|
|
||||||
Accessible.role: Accessible.Button
|
|
||||||
Accessible.name: modelData.title
|
|
||||||
Accessible.onPressAction: root.activate(index)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GridView {
|
|
||||||
id: grid
|
|
||||||
objectName: "launcherApps"
|
|
||||||
visible: root.showGrid
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.topMargin: 32
|
|
||||||
anchors.leftMargin: 12
|
|
||||||
anchors.rightMargin: 12
|
|
||||||
anchors.bottomMargin: 10
|
|
||||||
clip: true
|
|
||||||
model: root.showGrid ? root.results : []
|
|
||||||
cellWidth: Math.floor(width / root.gridColumns)
|
|
||||||
cellHeight: 100
|
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
|
||||||
ScrollBar.vertical: ScrollBar {}
|
|
||||||
delegate: Item {
|
|
||||||
id: tile
|
|
||||||
required property var modelData
|
|
||||||
required property int index
|
|
||||||
readonly property bool selected: root.selectedIndex === index
|
|
||||||
width: grid.cellWidth
|
|
||||||
height: grid.cellHeight
|
|
||||||
Rectangle {
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.margins: 4
|
|
||||||
radius: 14
|
|
||||||
color: tile.selected ? Qt.alpha(Theme.accent, 0.35) : tileArea.containsMouse ? Theme.hover : Theme.transparent
|
|
||||||
border.width: tile.selected ? 1 : 0
|
|
||||||
border.color: Theme.accentVivid
|
|
||||||
}
|
|
||||||
Column {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
spacing: 6
|
|
||||||
Image {
|
|
||||||
id: tileIcon
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
|
||||||
width: 52
|
|
||||||
height: 52
|
|
||||||
source: ApplicationsService.icon(tile.modelData.entry)
|
|
||||||
sourceSize: Qt.size(104, 104)
|
|
||||||
fillMode: Image.PreserveAspectFit
|
|
||||||
asynchronous: true
|
|
||||||
Text {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
visible: tileIcon.source.toString() === "" || tileIcon.status === Image.Error
|
|
||||||
text: tile.modelData.title.slice(0, 2).toUpperCase()
|
|
||||||
color: Theme.textSecondary
|
|
||||||
font.pixelSize: 18
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Text {
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
|
||||||
width: grid.cellWidth - 12
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
text: tile.modelData.title
|
|
||||||
elide: Text.ElideRight
|
|
||||||
color: Theme.text
|
|
||||||
font.pixelSize: 11
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MouseArea {
|
|
||||||
id: tileArea
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
onClicked: root.activate(tile.index)
|
|
||||||
}
|
|
||||||
Accessible.role: Accessible.Button
|
|
||||||
Accessible.name: modelData.title
|
|
||||||
Accessible.onPressAction: root.activate(index)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GridView {
|
|
||||||
id: emojiGrid
|
|
||||||
objectName: "launcherEmoji"
|
|
||||||
// Name of the emoji under the pointer, shown instead of the selection's.
|
|
||||||
property string hovered: ""
|
|
||||||
visible: root.emojiMode
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.topMargin: 32
|
|
||||||
anchors.leftMargin: 12
|
|
||||||
anchors.rightMargin: 12
|
|
||||||
anchors.bottomMargin: 10
|
|
||||||
clip: true
|
|
||||||
model: root.emojiMode ? root.results : []
|
|
||||||
cellWidth: Math.floor(width / root.emojiColumns)
|
|
||||||
cellHeight: root.emojiCell
|
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
|
||||||
ScrollBar.vertical: ScrollBar {}
|
|
||||||
delegate: Item {
|
|
||||||
id: glyph
|
|
||||||
required property var modelData
|
|
||||||
required property int index
|
|
||||||
readonly property bool selected: root.selectedIndex === index
|
|
||||||
width: emojiGrid.cellWidth
|
|
||||||
height: emojiGrid.cellHeight
|
|
||||||
Rectangle {
|
|
||||||
anchors.fill: parent
|
|
||||||
anchors.margins: 3
|
|
||||||
radius: 12
|
|
||||||
color: glyph.selected ? Qt.alpha(Theme.accent, 0.35) : glyphArea.containsMouse ? Theme.hover : Theme.transparent
|
|
||||||
border.width: glyph.selected ? 1 : 0
|
|
||||||
border.color: Theme.accentVivid
|
|
||||||
}
|
|
||||||
Text {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: glyph.modelData.id
|
|
||||||
textFormat: Text.PlainText
|
|
||||||
font.pixelSize: 28
|
|
||||||
}
|
|
||||||
MouseArea {
|
|
||||||
id: glyphArea
|
|
||||||
anchors.fill: parent
|
|
||||||
hoverEnabled: true
|
|
||||||
onContainsMouseChanged: {
|
|
||||||
if (containsMouse)
|
|
||||||
emojiGrid.hovered = glyph.modelData.title;
|
|
||||||
else if (emojiGrid.hovered === glyph.modelData.title)
|
|
||||||
emojiGrid.hovered = "";
|
|
||||||
}
|
|
||||||
onClicked: root.activate(glyph.index)
|
|
||||||
}
|
|
||||||
Accessible.role: Accessible.Button
|
|
||||||
Accessible.name: modelData.title
|
|
||||||
Accessible.onPressAction: root.activate(index)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Text {
|
|
||||||
anchors.centerIn: parent
|
|
||||||
anchors.verticalCenterOffset: 12
|
|
||||||
visible: (root.showList || root.emojiMode) && root.results.length === 0
|
|
||||||
text: root.emojiMode ? (EmojiService.loaded ? "No matching emoji" : "Loading…") : root.clipboardMode ? (ClipboardService.error || (root.query ? "No matches" : ClipboardService.loaded ? "Clipboard history is empty" : "Loading…")) : root.commandMode ? "No matching settings" : "No results"
|
|
||||||
color: Theme.textSecondary
|
|
||||||
font.pixelSize: 13
|
|
||||||
}
|
|
||||||
Text {
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.bottom: parent.bottom
|
|
||||||
anchors.margins: 12
|
|
||||||
visible: !!root.launchError
|
|
||||||
elide: Text.ElideRight
|
|
||||||
text: root.launchError
|
|
||||||
color: Theme.urgent
|
|
||||||
font.pixelSize: 12
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,618 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import "../components"
|
||||||
|
import "../services"
|
||||||
|
import "../theme"
|
||||||
|
import "../core"
|
||||||
|
|
||||||
|
// Everything the launcher shows and does, without a window: the search bar,
|
||||||
|
// ranked results, the application grid (magnifying glass, or ↓ in an empty
|
||||||
|
// bar), commands (>), Clipboard History and the Emoji Picker. The launcher
|
||||||
|
// window hosts it normally; in notch mode the notch hosts it, so every mode
|
||||||
|
// lives in the one launcher either way.
|
||||||
|
//
|
||||||
|
// The host sizes it: width is the launcher's width, and the host gives it
|
||||||
|
// barHeight + bodyHeight of height. maxBodyHeight caps the body.
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
// Whether the launcher is showing here; it resets each time it opens.
|
||||||
|
property bool active: false
|
||||||
|
// Notch layout: a shorter bar in the notch's band, with room on the left
|
||||||
|
// (barInset) for the notch's clock, and the mode pills inside the bar.
|
||||||
|
property bool notch: false
|
||||||
|
property real band: 60
|
||||||
|
property real barInset: 0
|
||||||
|
property real maxBodyHeight: 460
|
||||||
|
|
||||||
|
readonly property var options: ConfigService.ready ? ConfigService.data.launcher : ({
|
||||||
|
width: 680,
|
||||||
|
maxResults: 50,
|
||||||
|
showDescriptions: true
|
||||||
|
})
|
||||||
|
readonly property string query: search.text.trim()
|
||||||
|
readonly property bool clipboardMode: ShellState.launcherMode === "clipboard"
|
||||||
|
readonly property bool emojiMode: ShellState.launcherMode === "emoji"
|
||||||
|
readonly property bool commandMode: !clipboardMode && !emojiMode && query.startsWith(">")
|
||||||
|
property bool browsing: false
|
||||||
|
readonly property bool showList: clipboardMode || !emojiMode && query !== ""
|
||||||
|
readonly property bool showGrid: !showList && !emojiMode && browsing
|
||||||
|
// Arrow keys move through whichever grid is showing.
|
||||||
|
readonly property int columns: emojiMode ? emojiColumns : showGrid ? gridColumns : 1
|
||||||
|
readonly property var allApps: ApplicationsService.launchable.map(entry => ({
|
||||||
|
id: entry.id,
|
||||||
|
title: entry.name,
|
||||||
|
description: entry.genericName || entry.comment || entry.id,
|
||||||
|
entry: entry
|
||||||
|
}))
|
||||||
|
readonly property var clipboardResults: clipboardMode && active ? ClipboardService.filter(query).map(e => ({
|
||||||
|
id: e.id,
|
||||||
|
title: e.text.replace(/\s+/g, " ").trim(),
|
||||||
|
description: "",
|
||||||
|
clip: e
|
||||||
|
})) : []
|
||||||
|
readonly property var emojiResults: emojiMode && active ? EmojiService.filter(query).map(e => ({
|
||||||
|
id: e.emoji,
|
||||||
|
title: e.name,
|
||||||
|
description: "",
|
||||||
|
glyph: e
|
||||||
|
})) : []
|
||||||
|
readonly property var results: clipboardMode ? clipboardResults : emojiMode ? emojiResults : showList ? (commandMode ? commands.results : apps.results) : showGrid ? allApps : []
|
||||||
|
property int selectedIndex: 0
|
||||||
|
property string launchError: ""
|
||||||
|
// A hovered mode pill names itself in the empty search bar.
|
||||||
|
property string pillHover: ""
|
||||||
|
|
||||||
|
readonly property real barHeight: notch ? band : 60
|
||||||
|
// Controls in the bar scale down to fit a short notch band.
|
||||||
|
readonly property real buttonSize: notch ? Math.min(34, band - 8) : 38
|
||||||
|
readonly property real pillSize: notch ? Math.min(32, band - 10) : 36
|
||||||
|
readonly property int fontSize: notch ? Math.max(13, Math.min(20, Math.round(band * 0.45))) : 22
|
||||||
|
// Clipboard mode shows the latest five rows; the rest scroll.
|
||||||
|
readonly property real clipboardRows: 5 * 48 - 2
|
||||||
|
// Emoji mode shows six rows of the grid; the rest scroll.
|
||||||
|
readonly property int emojiCell: 52
|
||||||
|
readonly property int emojiColumns: Math.max(1, Math.floor((width - 24) / emojiCell))
|
||||||
|
readonly property real emojiRows: 6 * emojiCell
|
||||||
|
readonly property int gridColumns: Math.max(1, Math.floor((width - 24) / 112))
|
||||||
|
readonly property real bodyHeight: emojiMode ? Math.min(maxBodyHeight, Math.max(84, Math.min(emojiGrid.contentHeight, emojiRows) + 42)) : showList ? Math.min(maxBodyHeight, Math.max(84, (clipboardMode ? Math.min(list.contentHeight, clipboardRows) : list.contentHeight) + 46 + (launchError ? 22 : 0))) : showGrid ? Math.min(maxBodyHeight, grid.contentHeight + 46) : 0
|
||||||
|
// Mode switches resize without animating, so >clipboard lands in place.
|
||||||
|
property bool snapping: false
|
||||||
|
Timer {
|
||||||
|
id: unsnap
|
||||||
|
interval: 120
|
||||||
|
onTriggered: root.snapping = false
|
||||||
|
}
|
||||||
|
onResultsChanged: {
|
||||||
|
selectedIndex = 0;
|
||||||
|
list.contentY = 0;
|
||||||
|
grid.contentY = 0;
|
||||||
|
emojiGrid.contentY = 0;
|
||||||
|
emojiGrid.hovered = "";
|
||||||
|
}
|
||||||
|
onActiveChanged: reset()
|
||||||
|
function select(offset) {
|
||||||
|
if (!results.length)
|
||||||
|
return;
|
||||||
|
selectedIndex = Math.max(0, Math.min(results.length - 1, selectedIndex + offset));
|
||||||
|
if (emojiMode)
|
||||||
|
emojiGrid.positionViewAtIndex(selectedIndex, GridView.Contain);
|
||||||
|
else if (showGrid)
|
||||||
|
grid.positionViewAtIndex(selectedIndex, GridView.Contain);
|
||||||
|
else
|
||||||
|
list.positionViewAtIndex(selectedIndex, ListView.Contain);
|
||||||
|
}
|
||||||
|
function activate(index) {
|
||||||
|
const result = results[index];
|
||||||
|
if (!result)
|
||||||
|
return;
|
||||||
|
if (result.clip) {
|
||||||
|
ClipboardService.copy(result.clip);
|
||||||
|
ShellState.launcherOpen = false;
|
||||||
|
} else if (result.glyph) {
|
||||||
|
EmojiService.copy(result.glyph);
|
||||||
|
ShellState.launcherOpen = false;
|
||||||
|
} else if (result.command) {
|
||||||
|
const command = CommandRegistry.commands.find(c => c.id === result.id);
|
||||||
|
if (!command || !command.stay)
|
||||||
|
ShellState.launcherOpen = false;
|
||||||
|
CommandRegistry.execute(result.id);
|
||||||
|
} else if (ApplicationsService.launch(result.entry, null))
|
||||||
|
ShellState.launcherOpen = false;
|
||||||
|
else
|
||||||
|
launchError = ApplicationsService.error;
|
||||||
|
}
|
||||||
|
// Fresh state each time it opens.
|
||||||
|
function reset() {
|
||||||
|
if (!active)
|
||||||
|
return;
|
||||||
|
search.text = "";
|
||||||
|
browsing = false;
|
||||||
|
launchError = "";
|
||||||
|
selectedIndex = 0;
|
||||||
|
ClipboardService.refresh();
|
||||||
|
if (emojiMode)
|
||||||
|
EmojiService.load();
|
||||||
|
Qt.callLater(() => search.forceActiveFocus());
|
||||||
|
}
|
||||||
|
function focusSearch() {
|
||||||
|
search.forceActiveFocus();
|
||||||
|
}
|
||||||
|
function toggleBrowse() {
|
||||||
|
if (clipboardMode || emojiMode) {
|
||||||
|
ShellState.launcherMode = "apps";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
browsing = !browsing;
|
||||||
|
if (browsing)
|
||||||
|
search.clear();
|
||||||
|
selectedIndex = 0;
|
||||||
|
search.forceActiveFocus();
|
||||||
|
}
|
||||||
|
// A mode pill: toggles its mode; the active one is filled.
|
||||||
|
function toggleMode(mode) {
|
||||||
|
ShellState.launcherMode = ShellState.launcherMode === mode ? "apps" : mode;
|
||||||
|
search.forceActiveFocus();
|
||||||
|
}
|
||||||
|
readonly property var modes: [
|
||||||
|
{
|
||||||
|
mode: "clipboard",
|
||||||
|
label: "Clipboard",
|
||||||
|
glyph: "",
|
||||||
|
fallback: "⎘"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
mode: "emoji",
|
||||||
|
label: "Emoji",
|
||||||
|
glyph: "",
|
||||||
|
fallback: "☺"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
Connections {
|
||||||
|
target: ShellState
|
||||||
|
function onLauncherModeChanged() {
|
||||||
|
if (root.emojiMode)
|
||||||
|
EmojiService.load();
|
||||||
|
if (!root.active)
|
||||||
|
return;
|
||||||
|
root.snapping = true;
|
||||||
|
unsnap.restart();
|
||||||
|
search.text = "";
|
||||||
|
root.browsing = false;
|
||||||
|
root.launchError = "";
|
||||||
|
root.selectedIndex = 0;
|
||||||
|
search.forceActiveFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AppSearch {
|
||||||
|
id: apps
|
||||||
|
enabled: root.active && root.showList && !root.commandMode
|
||||||
|
query: search.text
|
||||||
|
limit: root.options.maxResults
|
||||||
|
}
|
||||||
|
CommandSearch {
|
||||||
|
id: commands
|
||||||
|
enabled: root.active && root.commandMode
|
||||||
|
query: search.text
|
||||||
|
limit: root.options.maxResults
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
} // Consume inside clicks without dismissing.
|
||||||
|
|
||||||
|
// Search bar
|
||||||
|
RowLayout {
|
||||||
|
id: bar
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: parent.top
|
||||||
|
height: root.barHeight
|
||||||
|
anchors.leftMargin: root.barInset + 12
|
||||||
|
anchors.rightMargin: root.notch ? 14 : 18
|
||||||
|
spacing: 10
|
||||||
|
Rectangle {
|
||||||
|
objectName: "launcherBrowse"
|
||||||
|
Layout.preferredWidth: root.buttonSize
|
||||||
|
Layout.preferredHeight: root.buttonSize
|
||||||
|
radius: root.buttonSize * 0.32
|
||||||
|
color: root.browsing ? Theme.accent : browseArea.containsMouse ? Theme.hover : Theme.transparent
|
||||||
|
Accessible.role: Accessible.Button
|
||||||
|
Accessible.name: root.clipboardMode || root.emojiMode ? "Back to search" : root.browsing ? "Hide applications" : "Show all applications"
|
||||||
|
Behavior on color {
|
||||||
|
ColorAnimation {
|
||||||
|
duration: Theme.duration / 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: root.commandMode ? ">" : !Icons.available ? (root.clipboardMode ? "⎘" : root.emojiMode ? "☺" : "⌕") : root.clipboardMode ? "" : root.emojiMode ? "" : ""
|
||||||
|
font.family: Icons.available && !root.commandMode ? Icons.family : ""
|
||||||
|
color: root.browsing ? Theme.accentText : Theme.textSecondary
|
||||||
|
font.pixelSize: Math.round(root.buttonSize * 0.53)
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: browseArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: root.toggleBrowse()
|
||||||
|
}
|
||||||
|
GlassToolTip {
|
||||||
|
visible: browseArea.containsMouse
|
||||||
|
delay: 600
|
||||||
|
text: root.clipboardMode || root.emojiMode ? "Back to search" : root.browsing ? "Hide applications" : "All applications"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TextField {
|
||||||
|
id: search
|
||||||
|
objectName: "launcherSearch"
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.preferredHeight: Math.min(40, root.barHeight - 4)
|
||||||
|
placeholderText: root.pillHover || (root.clipboardMode ? "Clipboard History" : root.emojiMode ? "Search emoji" : root.browsing ? "Search applications" : "Search :3")
|
||||||
|
color: Theme.text
|
||||||
|
placeholderTextColor: Theme.textSecondary
|
||||||
|
selectByMouse: true
|
||||||
|
font.pixelSize: root.fontSize
|
||||||
|
font.weight: Font.Light
|
||||||
|
background: Item {}
|
||||||
|
padding: 0
|
||||||
|
verticalAlignment: TextInput.AlignVCenter
|
||||||
|
maximumLength: 256
|
||||||
|
onTextEdited: root.launchError = ""
|
||||||
|
Keys.onEscapePressed: {
|
||||||
|
if (text !== "")
|
||||||
|
clear();
|
||||||
|
else if (root.browsing)
|
||||||
|
root.browsing = false;
|
||||||
|
else
|
||||||
|
ShellState.launcherOpen = false;
|
||||||
|
}
|
||||||
|
Keys.onDownPressed: {
|
||||||
|
if (!root.showList && !root.browsing && !root.emojiMode)
|
||||||
|
root.browsing = true;
|
||||||
|
else
|
||||||
|
root.select(root.columns);
|
||||||
|
}
|
||||||
|
Keys.onUpPressed: root.select(-root.columns)
|
||||||
|
Keys.onRightPressed: event => {
|
||||||
|
if (root.columns > 1 || event.modifiers & Qt.ControlModifier)
|
||||||
|
root.select(1);
|
||||||
|
else
|
||||||
|
event.accepted = false;
|
||||||
|
}
|
||||||
|
Keys.onLeftPressed: event => {
|
||||||
|
if (root.columns > 1 || event.modifiers & Qt.ControlModifier)
|
||||||
|
root.select(-1);
|
||||||
|
else
|
||||||
|
event.accepted = false;
|
||||||
|
}
|
||||||
|
// Shift+Delete removes the selected clipboard entry from history.
|
||||||
|
Keys.onDeletePressed: event => {
|
||||||
|
if (root.clipboardMode && event.modifiers & Qt.ShiftModifier && root.results[root.selectedIndex])
|
||||||
|
ClipboardService.remove(root.results[root.selectedIndex].clip);
|
||||||
|
else
|
||||||
|
event.accepted = false;
|
||||||
|
}
|
||||||
|
Keys.onTabPressed: root.select(1)
|
||||||
|
Keys.onBacktabPressed: root.select(-1)
|
||||||
|
Keys.onReturnPressed: root.activate(root.selectedIndex)
|
||||||
|
Keys.onEnterPressed: root.activate(root.selectedIndex)
|
||||||
|
}
|
||||||
|
// In the notch the mode pills sit in the bar; the window puts its own
|
||||||
|
// beside the panel.
|
||||||
|
Row {
|
||||||
|
id: pills
|
||||||
|
objectName: "launcherPills"
|
||||||
|
visible: root.notch
|
||||||
|
spacing: 6
|
||||||
|
Repeater {
|
||||||
|
model: root.notch ? root.modes : []
|
||||||
|
GlassPanel {
|
||||||
|
id: pill
|
||||||
|
required property var modelData
|
||||||
|
readonly property bool active: ShellState.launcherMode === modelData.mode
|
||||||
|
objectName: "launcherPill-" + modelData.mode
|
||||||
|
width: root.pillSize
|
||||||
|
height: width
|
||||||
|
radius: width / 2
|
||||||
|
color: active ? Theme.accent : pillArea.containsMouse ? Theme.hover : Theme.fill
|
||||||
|
border.color: Theme.hairline
|
||||||
|
plain: true
|
||||||
|
Accessible.role: Accessible.Button
|
||||||
|
Accessible.name: modelData.label
|
||||||
|
scale: pillArea.pressed ? 0.92 : 1
|
||||||
|
Behavior on scale {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.duration / 2
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: Icons.available ? pill.modelData.glyph : pill.modelData.fallback
|
||||||
|
font.family: Icons.available ? Icons.family : ""
|
||||||
|
font.pixelSize: Math.round(root.pillSize * 0.47)
|
||||||
|
color: pill.active ? Theme.accentText : Theme.text
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: pillArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onContainsMouseChanged: {
|
||||||
|
if (containsMouse)
|
||||||
|
root.pillHover = pill.modelData.label;
|
||||||
|
else if (root.pillHover === pill.modelData.label)
|
||||||
|
root.pillHover = "";
|
||||||
|
}
|
||||||
|
onClicked: root.toggleMode(pill.modelData.mode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Results (typing) or the application grid (magnifying glass).
|
||||||
|
Item {
|
||||||
|
id: body
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.top: bar.bottom
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
visible: root.bodyHeight > 0 || root.height > root.barHeight + 1
|
||||||
|
Rectangle {
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.leftMargin: 14
|
||||||
|
anchors.rightMargin: 14
|
||||||
|
height: 1
|
||||||
|
color: root.notch ? Theme.hairline : Theme.border
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
id: section
|
||||||
|
x: 22
|
||||||
|
y: 12
|
||||||
|
text: root.emojiMode ? (emojiGrid.hovered || (root.results[root.selectedIndex] || {}).title || "") : root.clipboardMode ? (!root.results.length ? "" : root.query ? "Matches" : "Recent") : root.showGrid ? "Applications" : root.commandMode ? "Settings" : root.results.length ? "Top hits" : ""
|
||||||
|
color: Theme.textSecondary
|
||||||
|
font.pixelSize: 11
|
||||||
|
font.weight: Font.DemiBold
|
||||||
|
}
|
||||||
|
ListView {
|
||||||
|
id: list
|
||||||
|
objectName: "launcherResults"
|
||||||
|
visible: root.showList
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.topMargin: 32
|
||||||
|
anchors.leftMargin: 8
|
||||||
|
anchors.rightMargin: 8
|
||||||
|
anchors.bottomMargin: root.launchError ? 30 : 8
|
||||||
|
clip: true
|
||||||
|
model: root.showList ? root.results : []
|
||||||
|
spacing: 2
|
||||||
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
|
ScrollBar.vertical: ScrollBar {}
|
||||||
|
delegate: Rectangle {
|
||||||
|
id: resultRow
|
||||||
|
required property var modelData
|
||||||
|
required property int index
|
||||||
|
readonly property bool selected: root.selectedIndex === index
|
||||||
|
width: list.width
|
||||||
|
height: 46
|
||||||
|
radius: 10
|
||||||
|
color: selected ? Theme.accent : mouse.containsMouse ? Theme.hover : Theme.transparent
|
||||||
|
RowLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.leftMargin: 10
|
||||||
|
anchors.rightMargin: 12
|
||||||
|
spacing: 12
|
||||||
|
Item {
|
||||||
|
readonly property var copied: resultRow.modelData.clip
|
||||||
|
// Copied images get a wider thumbnail slot.
|
||||||
|
Layout.preferredWidth: copied && copied.thumb ? 52 : 30
|
||||||
|
Layout.preferredHeight: 30
|
||||||
|
Image {
|
||||||
|
id: icon
|
||||||
|
anchors.fill: parent
|
||||||
|
source: parent.copied ? (parent.copied.thumb ? "file://" + parent.copied.thumb : "") : resultRow.modelData.entry ? ApplicationsService.icon(resultRow.modelData.entry) : ""
|
||||||
|
sourceSize: parent.copied ? Qt.size(104, 60) : Qt.size(60, 60)
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
|
asynchronous: !!parent.copied
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
visible: icon.source.toString() === "" || icon.status === Image.Error
|
||||||
|
text: parent.copied ? (Icons.available ? (parent.copied.image ? "" : "") : "¶") : resultRow.modelData.command ? "⚙" : resultRow.modelData.title.slice(0, 2).toUpperCase()
|
||||||
|
font.family: parent.copied && Icons.available ? Icons.family : ""
|
||||||
|
color: resultRow.selected ? Theme.accentText : Theme.textSecondary
|
||||||
|
font.pixelSize: parent.copied ? 18 : 16
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
text: resultRow.modelData.title
|
||||||
|
// Clipboard text is shown as is, never as markup.
|
||||||
|
textFormat: Text.PlainText
|
||||||
|
Layout.fillWidth: !!resultRow.modelData.clip
|
||||||
|
elide: Text.ElideRight
|
||||||
|
color: resultRow.selected ? Theme.accentText : Theme.text
|
||||||
|
font.pixelSize: 14
|
||||||
|
font.weight: Font.Medium
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
visible: root.options.showDescriptions && !resultRow.modelData.clip
|
||||||
|
text: "— " + resultRow.modelData.description
|
||||||
|
Layout.fillWidth: true
|
||||||
|
elide: Text.ElideRight
|
||||||
|
color: resultRow.selected ? Qt.alpha(Theme.accentText, 0.75) : Theme.textSecondary
|
||||||
|
font.pixelSize: 12
|
||||||
|
}
|
||||||
|
Item {
|
||||||
|
visible: !root.options.showDescriptions && !resultRow.modelData.clip
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
text: resultRow.modelData.clip ? (resultRow.modelData.clip.image ? "Image" : "Text") : resultRow.modelData.command ? resultRow.modelData.kind : "Application"
|
||||||
|
color: resultRow.selected ? Qt.alpha(Theme.accentText, 0.75) : Theme.textSecondary
|
||||||
|
font.pixelSize: 11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: mouse
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
// Hover highlights locally; only keys change keyboard selection.
|
||||||
|
// Layout/scroll movement under a stationary pointer must not steal it.
|
||||||
|
onClicked: root.activate(resultRow.index)
|
||||||
|
}
|
||||||
|
Accessible.role: Accessible.Button
|
||||||
|
Accessible.name: modelData.title
|
||||||
|
Accessible.onPressAction: root.activate(index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GridView {
|
||||||
|
id: grid
|
||||||
|
objectName: "launcherApps"
|
||||||
|
visible: root.showGrid
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.topMargin: 32
|
||||||
|
anchors.leftMargin: 12
|
||||||
|
anchors.rightMargin: 12
|
||||||
|
anchors.bottomMargin: 10
|
||||||
|
clip: true
|
||||||
|
model: root.showGrid ? root.results : []
|
||||||
|
cellWidth: Math.floor(width / root.gridColumns)
|
||||||
|
cellHeight: 100
|
||||||
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
|
ScrollBar.vertical: ScrollBar {}
|
||||||
|
delegate: Item {
|
||||||
|
id: tile
|
||||||
|
required property var modelData
|
||||||
|
required property int index
|
||||||
|
readonly property bool selected: root.selectedIndex === index
|
||||||
|
width: grid.cellWidth
|
||||||
|
height: grid.cellHeight
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: 4
|
||||||
|
radius: 14
|
||||||
|
color: tile.selected ? Qt.alpha(Theme.accent, 0.35) : tileArea.containsMouse ? Theme.hover : Theme.transparent
|
||||||
|
border.width: tile.selected ? 1 : 0
|
||||||
|
border.color: Theme.accentVivid
|
||||||
|
}
|
||||||
|
Column {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
spacing: 6
|
||||||
|
Image {
|
||||||
|
id: tileIcon
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
width: 52
|
||||||
|
height: 52
|
||||||
|
source: ApplicationsService.icon(tile.modelData.entry)
|
||||||
|
sourceSize: Qt.size(104, 104)
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
|
asynchronous: true
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
visible: tileIcon.source.toString() === "" || tileIcon.status === Image.Error
|
||||||
|
text: tile.modelData.title.slice(0, 2).toUpperCase()
|
||||||
|
color: Theme.textSecondary
|
||||||
|
font.pixelSize: 18
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
width: grid.cellWidth - 12
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
text: tile.modelData.title
|
||||||
|
elide: Text.ElideRight
|
||||||
|
color: Theme.text
|
||||||
|
font.pixelSize: 11
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: tileArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
onClicked: root.activate(tile.index)
|
||||||
|
}
|
||||||
|
Accessible.role: Accessible.Button
|
||||||
|
Accessible.name: modelData.title
|
||||||
|
Accessible.onPressAction: root.activate(index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GridView {
|
||||||
|
id: emojiGrid
|
||||||
|
objectName: "launcherEmoji"
|
||||||
|
// Name of the emoji under the pointer, shown instead of the selection's.
|
||||||
|
property string hovered: ""
|
||||||
|
visible: root.emojiMode
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.topMargin: 32
|
||||||
|
anchors.leftMargin: 12
|
||||||
|
anchors.rightMargin: 12
|
||||||
|
anchors.bottomMargin: 10
|
||||||
|
clip: true
|
||||||
|
model: root.emojiMode ? root.results : []
|
||||||
|
cellWidth: Math.floor(width / root.emojiColumns)
|
||||||
|
cellHeight: root.emojiCell
|
||||||
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
|
ScrollBar.vertical: ScrollBar {}
|
||||||
|
delegate: Item {
|
||||||
|
id: glyph
|
||||||
|
required property var modelData
|
||||||
|
required property int index
|
||||||
|
readonly property bool selected: root.selectedIndex === index
|
||||||
|
width: emojiGrid.cellWidth
|
||||||
|
height: emojiGrid.cellHeight
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: 3
|
||||||
|
radius: 12
|
||||||
|
color: glyph.selected ? Qt.alpha(Theme.accent, 0.35) : glyphArea.containsMouse ? Theme.hover : Theme.transparent
|
||||||
|
border.width: glyph.selected ? 1 : 0
|
||||||
|
border.color: Theme.accentVivid
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: glyph.modelData.id
|
||||||
|
textFormat: Text.PlainText
|
||||||
|
font.pixelSize: 28
|
||||||
|
}
|
||||||
|
MouseArea {
|
||||||
|
id: glyphArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
onContainsMouseChanged: {
|
||||||
|
if (containsMouse)
|
||||||
|
emojiGrid.hovered = glyph.modelData.title;
|
||||||
|
else if (emojiGrid.hovered === glyph.modelData.title)
|
||||||
|
emojiGrid.hovered = "";
|
||||||
|
}
|
||||||
|
onClicked: root.activate(glyph.index)
|
||||||
|
}
|
||||||
|
Accessible.role: Accessible.Button
|
||||||
|
Accessible.name: modelData.title
|
||||||
|
Accessible.onPressAction: root.activate(index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
anchors.verticalCenterOffset: 12
|
||||||
|
visible: (root.showList || root.emojiMode) && root.results.length === 0
|
||||||
|
text: root.emojiMode ? (EmojiService.loaded ? "No matching emoji" : "Loading…") : root.clipboardMode ? (ClipboardService.error || (root.query ? "No matches" : ClipboardService.loaded ? "Clipboard history is empty" : "Loading…")) : root.commandMode ? "No matching settings" : "No results"
|
||||||
|
color: Theme.textSecondary
|
||||||
|
font.pixelSize: 13
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
anchors.margins: 12
|
||||||
|
visible: !!root.launchError
|
||||||
|
elide: Text.ElideRight
|
||||||
|
text: root.launchError
|
||||||
|
color: Theme.urgent
|
||||||
|
font.pixelSize: 12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,3 +3,4 @@ singleton LauncherState 1.0 LauncherState.qml
|
|||||||
AppSearch 1.0 AppSearch.qml
|
AppSearch 1.0 AppSearch.qml
|
||||||
CommandSearch 1.0 CommandSearch.qml
|
CommandSearch 1.0 CommandSearch.qml
|
||||||
Launcher 1.0 Launcher.qml
|
Launcher 1.0 Launcher.qml
|
||||||
|
LauncherView 1.0 LauncherView.qml
|
||||||
+256
-61
@@ -1,32 +1,64 @@
|
|||||||
pragma ComponentBehavior: Bound
|
pragma ComponentBehavior: Bound
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
|
||||||
import Quickshell.Widgets
|
|
||||||
import "../components"
|
import "../components"
|
||||||
import "../core"
|
import "../core"
|
||||||
|
import "../launcher"
|
||||||
import "../services"
|
import "../services"
|
||||||
import "../theme"
|
import "../theme"
|
||||||
|
|
||||||
// The collapsed notch: a glass island hanging from the screen's top edge with
|
// The collapsed notch: a glass island hanging from the screen's top edge with
|
||||||
// concave ears, showing the time, plus cover art and a small visualizer while
|
// concave ears, showing the time, plus cover art and a small visualizer while
|
||||||
// audio plays. Clicking it opens the notch panel.
|
// audio plays. Clicking it opens the notch panel. A new notification widens
|
||||||
|
// it: the clock and media keep the left end, the banner takes the right. The
|
||||||
|
// launcher opens the same way, as one more face of the notch (the pocket-dots
|
||||||
|
// way): its search sits in the band beside the clock, and the notch grows
|
||||||
|
// down to fit the results, clipboard history or emoji below it.
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
property var barScreen
|
property var barScreen
|
||||||
readonly property real bodyWidth: ShellState.notchPillWidth
|
|
||||||
readonly property bool playing: MediaService.playing
|
readonly property bool playing: MediaService.playing
|
||||||
|
// Newest banner, shown on the screen that was active when it arrived.
|
||||||
|
readonly property var latest: ShellState.notchMode && !ShellState.notchOpen && NotificationService.active ? NotificationService.popups[0] || null : null
|
||||||
|
property bool owner: false
|
||||||
|
property bool hadLatest: false
|
||||||
|
onLatestChanged: {
|
||||||
|
if (latest && !hadLatest)
|
||||||
|
owner = ScreenService.active === barScreen;
|
||||||
|
hadLatest = !!latest;
|
||||||
|
if (latest)
|
||||||
|
notice = latest;
|
||||||
|
}
|
||||||
|
readonly property bool searching: ShellState.notchLauncher && ScreenService.current(ShellState.launcherScreen) === barScreen
|
||||||
|
readonly property bool showing: !!latest && owner && visible && !searching
|
||||||
|
// Holds the last banner while the notch closes around it.
|
||||||
|
property var notice: null
|
||||||
|
readonly property int noticeWidth: 340
|
||||||
|
readonly property int searchWidth: ConfigService.ready ? ConfigService.data.launcher.width : 680
|
||||||
|
readonly property real band: BarDrawers.bottom
|
||||||
|
readonly property real bodyWidth: ShellState.notchPillWidth + (searching ? searchWidth : showing ? noticeWidth : 0)
|
||||||
|
// The launcher's results hang below the band.
|
||||||
|
readonly property real bodyHeight: band + (searching ? launcher.bodyHeight : 0)
|
||||||
|
// Tallest the launcher may grow; the bar window reserves this while open.
|
||||||
|
readonly property real maxBodyHeight: Math.min(460, (barScreen ? barScreen.height : 1080) * 0.6)
|
||||||
implicitWidth: bodyWidth + 2 * BarDrawers.ear
|
implicitWidth: bodyWidth + 2 * BarDrawers.ear
|
||||||
implicitHeight: BarDrawers.bottom
|
implicitHeight: bodyHeight
|
||||||
|
// Springs, as on pocket-dots: the width arrives quickly and stays, the
|
||||||
|
// height follows with a little slack, so the notch widens and then drops.
|
||||||
|
// The notch speed settings stiffen or soften them.
|
||||||
|
readonly property real springScale: Theme.duration / (searching || showing ? Theme.notchOpenDuration : Theme.notchCloseDuration)
|
||||||
Behavior on implicitWidth {
|
Behavior on implicitWidth {
|
||||||
NumberAnimation {
|
SpringAnimation {
|
||||||
duration: Theme.notchDuration * 1.6
|
spring: 5.2 * root.springScale
|
||||||
easing.type: Easing.BezierSpline
|
damping: 0.58
|
||||||
easing.bezierCurve: [0.2, 0, 0, 1, 1, 1]
|
epsilon: 0.25
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SystemClock {
|
Behavior on implicitHeight {
|
||||||
id: clock
|
SpringAnimation {
|
||||||
precision: SystemClock.Minutes
|
spring: 3.1 * root.springScale
|
||||||
|
damping: 0.34
|
||||||
|
epsilon: 0.25
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Demand {
|
Demand {
|
||||||
service: CavaService
|
service: CavaService
|
||||||
@@ -38,56 +70,23 @@ Item {
|
|||||||
bodyHeight: root.height
|
bodyHeight: root.height
|
||||||
ear: BarDrawers.ear
|
ear: BarDrawers.ear
|
||||||
radius: Math.min(Theme.radius, root.height / 2)
|
radius: Math.min(Theme.radius, root.height / 2)
|
||||||
fillColor: Theme.notchFill
|
fillColor: root.searching ? Theme.notchLauncherFill : Theme.notchFill
|
||||||
|
Behavior on fillColor {
|
||||||
|
ColorAnimation {
|
||||||
|
duration: root.searching ? Theme.notchColorDuration : Math.min(Theme.notchColorDuration, Theme.notchCloseDuration)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Row {
|
// The pill's own width at the left end; its contents stay centred there.
|
||||||
id: content
|
Item {
|
||||||
anchors.centerIn: parent
|
id: lead
|
||||||
spacing: 10
|
x: BarDrawers.ear
|
||||||
ClippingRectangle {
|
width: ShellState.notchPillWidth
|
||||||
visible: root.playing
|
height: root.band
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
}
|
||||||
width: 22
|
NotchGlance {
|
||||||
height: 22
|
anchors.centerIn: lead
|
||||||
radius: 6
|
playing: root.playing
|
||||||
color: Theme.fill
|
|
||||||
Image {
|
|
||||||
anchors.fill: parent
|
|
||||||
source: MediaService.artwork
|
|
||||||
sourceSize: Qt.size(44, 44)
|
|
||||||
fillMode: Image.PreserveAspectCrop
|
|
||||||
asynchronous: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Text {
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
text: Qt.formatDateTime(clock.date, ConfigService.ready && !ConfigService.data.bar.clock.use24Hour ? "h:mm" : "HH:mm")
|
|
||||||
color: Theme.text
|
|
||||||
font.pixelSize: 14
|
|
||||||
font.weight: Font.DemiBold
|
|
||||||
font.features: {
|
|
||||||
"tnum": 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Row {
|
|
||||||
visible: root.playing
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
height: 16
|
|
||||||
spacing: 2
|
|
||||||
Repeater {
|
|
||||||
model: 8
|
|
||||||
Rectangle {
|
|
||||||
required property int index
|
|
||||||
// Every third Cava band, so the eight span the spectrum.
|
|
||||||
readonly property real level: CavaService.bars[index * 3] || 0
|
|
||||||
width: 3
|
|
||||||
height: Math.max(3, 16 * level)
|
|
||||||
y: 16 - height
|
|
||||||
radius: 1.5
|
|
||||||
color: Theme.accent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -109,4 +108,200 @@ Item {
|
|||||||
AudioService.volume(false, audio.volume + (wheel.angleDelta.y > 0 ? 1 : -1) * step / 100);
|
AudioService.volume(false, audio.volume + (wheel.angleDelta.y > 0 ? 1 : -1) * step / 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Item {
|
||||||
|
id: banner
|
||||||
|
objectName: "notchNotice"
|
||||||
|
x: lead.x + lead.width
|
||||||
|
width: Math.max(0, root.width - BarDrawers.ear - x)
|
||||||
|
height: root.band
|
||||||
|
clip: true
|
||||||
|
visible: width > 1
|
||||||
|
opacity: root.showing ? 1 : 0
|
||||||
|
Behavior on opacity {
|
||||||
|
NumberAnimation {
|
||||||
|
duration: root.showing ? Theme.notchDuration * 1.6 : Theme.notchDuration * 0.6
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
readonly property var n: root.notice
|
||||||
|
readonly property int more: Math.max(0, NotificationService.popups.length - 1)
|
||||||
|
Accessible.role: Accessible.Button
|
||||||
|
Accessible.name: n ? NotificationService.appLabel(n) + ": " + n.summary : ""
|
||||||
|
HoverHandler {
|
||||||
|
id: bannerHover
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
width: 1
|
||||||
|
height: parent.height * 0.5
|
||||||
|
color: Theme.hairline
|
||||||
|
}
|
||||||
|
// Laid out at full width so text does not reflow while the notch grows.
|
||||||
|
Row {
|
||||||
|
x: 14
|
||||||
|
width: root.noticeWidth - 26
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
spacing: 10
|
||||||
|
Rectangle {
|
||||||
|
id: badge
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
width: 30
|
||||||
|
height: 30
|
||||||
|
radius: 8
|
||||||
|
color: noticeIcon.status === Image.Ready ? Theme.transparent : Theme.surfaceVariant
|
||||||
|
border.width: banner.n && NotificationService.critical(banner.n) ? 1.5 : 0
|
||||||
|
border.color: Theme.urgent
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
visible: noticeIcon.status !== Image.Ready
|
||||||
|
text: Icons.available ? "" : "!"
|
||||||
|
font.family: Icons.available ? Icons.family : ""
|
||||||
|
color: Theme.text
|
||||||
|
font.pixelSize: 15
|
||||||
|
}
|
||||||
|
Image {
|
||||||
|
id: noticeIcon
|
||||||
|
anchors.fill: parent
|
||||||
|
source: banner.n ? NotificationService.iconFor(banner.n) || NotificationService.imageFor(banner.n) : ""
|
||||||
|
sourceSize: Qt.size(60, 60)
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
|
asynchronous: true
|
||||||
|
smooth: true
|
||||||
|
mipmap: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Column {
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
width: parent.width - badge.width - parent.spacing - (count.visible ? count.width + parent.spacing : 0)
|
||||||
|
spacing: 1
|
||||||
|
Text {
|
||||||
|
objectName: "notchNoticeSummary"
|
||||||
|
width: parent.width
|
||||||
|
text: banner.n ? banner.n.summary || NotificationService.appLabel(banner.n) : ""
|
||||||
|
color: Theme.text
|
||||||
|
font.pixelSize: 13
|
||||||
|
font.weight: Font.DemiBold
|
||||||
|
elide: Text.ElideRight
|
||||||
|
maximumLineCount: 1
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
width: parent.width
|
||||||
|
visible: text !== ""
|
||||||
|
// Bodies may carry markup and line breaks; one plain line fits here.
|
||||||
|
text: banner.n ? (banner.n.body || NotificationService.appLabel(banner.n)).replace(/<[^>]*>/g, "").replace(/\s+/g, " ").trim() : ""
|
||||||
|
color: Theme.textSecondary
|
||||||
|
font.pixelSize: 12
|
||||||
|
elide: Text.ElideRight
|
||||||
|
maximumLineCount: 1
|
||||||
|
textFormat: Text.PlainText
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
id: count
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
visible: banner.more > 0
|
||||||
|
width: Math.max(22, moreText.implicitWidth + 12)
|
||||||
|
height: 20
|
||||||
|
radius: 10
|
||||||
|
color: Theme.surfaceVariant
|
||||||
|
Text {
|
||||||
|
id: moreText
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: "+" + banner.more
|
||||||
|
color: Theme.textSecondary
|
||||||
|
font.pixelSize: 11
|
||||||
|
font.weight: Font.Medium
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Left click runs the default action; right or middle click sends it to
|
||||||
|
// the notch's list.
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
enabled: root.showing
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
acceptedButtons: Qt.LeftButton | Qt.MiddleButton | Qt.RightButton
|
||||||
|
onClicked: mouse => {
|
||||||
|
if (mouse.button === Qt.LeftButton)
|
||||||
|
NotificationService.activate(banner.n);
|
||||||
|
else
|
||||||
|
NotificationService.hidePopup(banner.n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Item {
|
||||||
|
objectName: "notchLauncher"
|
||||||
|
x: BarDrawers.ear
|
||||||
|
width: Math.max(0, root.width - 2 * BarDrawers.ear)
|
||||||
|
height: root.height
|
||||||
|
clip: true
|
||||||
|
// Comes in once the notch has started to widen, and leaves first.
|
||||||
|
opacity: root.searching ? 1 : 0
|
||||||
|
visible: width > 1 && opacity > 0
|
||||||
|
Behavior on opacity {
|
||||||
|
SequentialAnimation {
|
||||||
|
PauseAnimation {
|
||||||
|
duration: root.searching ? Theme.notchOpenDuration * 0.5 : 0
|
||||||
|
}
|
||||||
|
NumberAnimation {
|
||||||
|
duration: root.searching ? Theme.notchOpenDuration : Theme.notchCloseDuration * 0.5
|
||||||
|
easing.type: root.searching ? Easing.OutCubic : Easing.InQuad
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
x: ShellState.notchPillWidth
|
||||||
|
y: root.band * 0.25
|
||||||
|
width: 1
|
||||||
|
height: root.band * 0.5
|
||||||
|
color: Theme.hairline
|
||||||
|
}
|
||||||
|
// Laid out at full size so it does not reflow while the notch grows.
|
||||||
|
LauncherView {
|
||||||
|
id: launcher
|
||||||
|
width: ShellState.notchPillWidth + root.searchWidth
|
||||||
|
height: Math.max(root.band, parent.height)
|
||||||
|
notch: true
|
||||||
|
band: root.band
|
||||||
|
barInset: ShellState.notchPillWidth
|
||||||
|
maxBodyHeight: root.maxBodyHeight
|
||||||
|
active: root.searching
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 0 (critical) stays until dismissed. Each banner's time counts from its
|
||||||
|
// arrival, so older ones revealed by an expiry leave on schedule; hovering
|
||||||
|
// restarts the full time.
|
||||||
|
readonly property int lifetime: notice ? NotificationService.timeoutFor(notice) : 0
|
||||||
|
property int budget: 1
|
||||||
|
function arm(full) {
|
||||||
|
if (!showing || lifetime <= 0 || bannerHover.hovered)
|
||||||
|
return;
|
||||||
|
const at = NotificationService.times[notice.id];
|
||||||
|
budget = Math.max(400, full || at === undefined ? lifetime : lifetime - (Date.now() - at));
|
||||||
|
life.restart();
|
||||||
|
}
|
||||||
|
Timer {
|
||||||
|
id: life
|
||||||
|
interval: root.budget
|
||||||
|
running: root.showing && root.lifetime > 0 && !bannerHover.hovered
|
||||||
|
onTriggered: if (root.showing)
|
||||||
|
NotificationService.hidePopup(root.notice)
|
||||||
|
}
|
||||||
|
onNoticeChanged: arm(false)
|
||||||
|
onShowingChanged: arm(false)
|
||||||
|
Connections {
|
||||||
|
target: bannerHover
|
||||||
|
function onHoveredChanged() {
|
||||||
|
if (!bannerHover.hovered)
|
||||||
|
root.arm(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Connections {
|
||||||
|
target: NotificationService
|
||||||
|
function onPopupShown(n) {
|
||||||
|
if (n === root.notice)
|
||||||
|
root.arm(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -21,10 +21,11 @@ PanelWindow {
|
|||||||
// The OSD capsule takes this spot while it is up; banners wait behind it.
|
// The OSD capsule takes this spot while it is up; banners wait behind it.
|
||||||
readonly property var osd: ShellState.osdWindow
|
readonly property var osd: ShellState.osdWindow
|
||||||
readonly property bool yielding: !!osd && osd.shown && osd.options.position === options.position
|
readonly property bool yielding: !!osd && osd.shown && osd.options.position === options.position
|
||||||
readonly property bool shown: NotificationService.active && items.length > 0 && !yielding && !ShellState.controlCenterOpen && !ShellState.notchOpen
|
readonly property bool shown: NotificationService.active && items.length > 0 && !yielding && !ShellState.controlCenterOpen && !ShellState.notchMode
|
||||||
onItemsChanged: if (items.length > 0 && !drawer.shown)
|
onItemsChanged: if (items.length > 0 && !drawer.shown)
|
||||||
targetScreen = ScreenService.active
|
targetScreen = ScreenService.active
|
||||||
// Control Center lists everything; banners would cover it.
|
// Control Center lists everything; banners would cover it. In notch mode
|
||||||
|
// the notch pill shows banners instead.
|
||||||
Connections {
|
Connections {
|
||||||
target: ShellState
|
target: ShellState
|
||||||
function onControlCenterOpenChanged() {
|
function onControlCenterOpenChanged() {
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ function validate(c) {
|
|||||||
for(const key of ["left","right","strip"]) if(!Array.isArray(c.notch[key]) || c.notch[key].some(id=>typeof id!=="string" || !id))throw Error("Invalid notch modules");
|
for(const key of ["left","right","strip"]) if(!Array.isArray(c.notch[key]) || c.notch[key].some(id=>typeof id!=="string" || !id))throw Error("Invalid notch modules");
|
||||||
if(!Array.isArray(c.notch.controls) || c.notch.controls.some(m=>!m || typeof m.id!=="string" || typeof m.enabled!=="boolean" || ["w","h"].some(k=>m[k]!==undefined && (!Number.isInteger(m[k]) || m[k]<1 || m[k]>4)) || [["x",3],["y",63]].some(([k,max])=>m[k]!==undefined && (!Number.isInteger(m[k]) || m[k]<0 || m[k]>max))))throw Error("Invalid notch controls");
|
if(!Array.isArray(c.notch.controls) || c.notch.controls.some(m=>!m || typeof m.id!=="string" || typeof m.enabled!=="boolean" || ["w","h"].some(k=>m[k]!==undefined && (!Number.isInteger(m[k]) || m[k]<1 || m[k]>4)) || [["x",3],["y",63]].some(([k,max])=>m[k]!==undefined && (!Number.isInteger(m[k]) || m[k]<0 || m[k]>max))))throw Error("Invalid notch controls");
|
||||||
if(!Number.isFinite(c.notch.opacity) || c.notch.opacity<0 || c.notch.opacity>100 || typeof c.notch.color!=="string" || (c.notch.color!=="" && !/^#[0-9a-fA-F]{6}$/.test(c.notch.color)))throw Error("Invalid notch colour");
|
if(!Number.isFinite(c.notch.opacity) || c.notch.opacity<0 || c.notch.opacity>100 || typeof c.notch.color!=="string" || (c.notch.color!=="" && !/^#[0-9a-fA-F]{6}$/.test(c.notch.color)))throw Error("Invalid notch colour");
|
||||||
if(typeof c.notch.glassOnOpen!=="boolean" || ["openSpeed","closeSpeed","colorSpeed"].some(k=>!Number.isFinite(c.notch[k]) || c.notch[k]<25 || c.notch[k]>300))throw Error("Invalid notch animation");
|
if(typeof c.notch.glassOnOpen!=="boolean" || typeof c.notch.launcherMatch!=="boolean" || ["openSpeed","closeSpeed","colorSpeed"].some(k=>!Number.isFinite(c.notch[k]) || c.notch[k]<25 || c.notch[k]>300))throw Error("Invalid notch animation");
|
||||||
if(!["bar","numbers","roman","kanji","dots","pacman"].includes(c.notch.workspaceStyle))throw Error("Invalid notch workspace style");
|
if(!["bar","numbers","roman","kanji","dots","pacman"].includes(c.notch.workspaceStyle))throw Error("Invalid notch workspace style");
|
||||||
if(typeof c.osd.enabled!=="boolean" || !["slide","drop","fade","shrink"].includes(c.osd.animation) || !["top-right","top-center","bottom-center"].includes(c.osd.position) || !Number.isInteger(c.osd.timeout) || c.osd.timeout<500 || c.osd.timeout>5000 || !Number.isInteger(c.osd.step) || c.osd.step<1 || c.osd.step>20)throw Error("Invalid OSD preferences");
|
if(typeof c.osd.enabled!=="boolean" || !["slide","drop","fade","shrink"].includes(c.osd.animation) || !["top-right","top-center","bottom-center"].includes(c.osd.position) || !Number.isInteger(c.osd.timeout) || c.osd.timeout<500 || c.osd.timeout>5000 || !Number.isInteger(c.osd.step) || c.osd.step<1 || c.osd.step>20)throw Error("Invalid OSD preferences");
|
||||||
const notes=c.notifications;
|
const notes=c.notifications;
|
||||||
|
|||||||
@@ -87,10 +87,17 @@ SettingsPage {
|
|||||||
}
|
}
|
||||||
PreferenceToggle {
|
PreferenceToggle {
|
||||||
label: "Glassy when open"
|
label: "Glassy when open"
|
||||||
description: "Keeps the colour and opacity on the docked notch; the open notch and launcher fade back to the normal glass"
|
description: "Keeps the colour and opacity on the docked notch; the open notch fades back to the normal glass"
|
||||||
icon: ""
|
icon: ""
|
||||||
setting: "notch.glassOnOpen"
|
setting: "notch.glassOnOpen"
|
||||||
}
|
}
|
||||||
|
PreferenceToggle {
|
||||||
|
visible: root.options.glassOnOpen
|
||||||
|
label: "Launcher keeps notch colour"
|
||||||
|
description: "Off: the launcher turns glassy when open too"
|
||||||
|
icon: ""
|
||||||
|
setting: "notch.launcherMatch"
|
||||||
|
}
|
||||||
PreferenceSlider {
|
PreferenceSlider {
|
||||||
label: "Opening speed"
|
label: "Opening speed"
|
||||||
description: "Notch and launcher; 100% follows the shell's animation duration"
|
description: "Notch and launcher; 100% follows the shell's animation duration"
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ Singleton {
|
|||||||
}
|
}
|
||||||
// The open notch's fill: the plain glass when "glassy when open" is on.
|
// The open notch's fill: the plain glass when "glassy when open" is on.
|
||||||
readonly property color notchOpenFill: ConfigService.ready && ConfigService.data.notch.glassOnOpen ? Qt.alpha(tint, glassOpacity) : notchFill
|
readonly property color notchOpenFill: ConfigService.ready && ConfigService.data.notch.glassOnOpen ? Qt.alpha(tint, glassOpacity) : notchFill
|
||||||
|
// The launcher keeps the docked notch's colour unless it is set to follow
|
||||||
|
// "glassy when open".
|
||||||
|
readonly property color notchLauncherFill: ConfigService.ready && !ConfigService.data.notch.launcherMatch ? notchOpenFill : notchFill
|
||||||
// Notch animations run at their own speeds (percent; 100 follows the shell),
|
// Notch animations run at their own speeds (percent; 100 follows the shell),
|
||||||
// one for opening and one for closing.
|
// one for opening and one for closing.
|
||||||
readonly property real notchOpenDuration: duration * 100 / (ConfigService.ready ? Math.max(25, ConfigService.data.notch.openSpeed) : 100)
|
readonly property real notchOpenDuration: duration * 100 / (ConfigService.ready ? Math.max(25, ConfigService.data.notch.openSpeed) : 100)
|
||||||
|
|||||||
Reference in new issue
Block a user