Add custom shortcut for launcher, dashboard and osd all in one (#53)

* Add custom shortcut for launcher, dashboard and osd all in one

* Fix Shortcut description

* shortcuts: fix showall

Some fixes:
 - no need for the complex shortcut
 - fix formatting
 - fix unqualified access

---------

Co-authored-by: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
This commit is contained in:
Tim Hämisch 2025-06-13 16:08:02 +02:00 committed by GitHub
parent 5da1b64da0
commit 4621c3695e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 89 additions and 6 deletions

View file

@ -8,6 +8,15 @@ Scope {
property bool launcherInterrupted
CustomShortcut {
name: "showall"
description: "Toggle launcher, dashboard and osd"
onPressed: {
const v = Visibilities.getForActive();
v.launcher = v.dashboard = v.osd = !(v.launcher || v.dashboard || v.osd);
}
}
CustomShortcut {
name: "session"
description: "Toggle session menu"

View file

@ -16,6 +16,8 @@ MouseArea {
property bool osdHovered
property point dragStart
property bool dashboardShortcutActive
property bool osdShortcutActive
function withinPanelHeight(panel: Item, x: real, y: real): bool {
const panelY = BorderConfig.thickness + panel.y;
@ -37,9 +39,14 @@ MouseArea {
onPressed: event => dragStart = Qt.point(event.x, event.y)
onContainsMouseChanged: {
if (!containsMouse) {
visibilities.osd = false;
osdHovered = false;
visibilities.dashboard = false;
// Only hide if not activated by shortcut
if (!osdShortcutActive) {
visibilities.osd = false;
osdHovered = false;
}
if (!dashboardShortcutActive) {
visibilities.dashboard = false;
}
popouts.hasCurrent = false;
}
}
@ -47,8 +54,16 @@ MouseArea {
onPositionChanged: ({x, y}) => {
// Show osd on hover
const showOsd = inRightPanel(panels.osd, x, y);
visibilities.osd = showOsd;
osdHovered = showOsd;
// Always update visibility based on hover if not in shortcut mode
if (!osdShortcutActive) {
visibilities.osd = showOsd;
osdHovered = showOsd;
} else if (showOsd) {
// If hovering over OSD area while in shortcut mode, transition to hover control
osdShortcutActive = false;
osdHovered = true;
}
// Show/hide session on drag
if (pressed && withinPanelHeight(panels.session, x, y)) {
@ -60,7 +75,15 @@ MouseArea {
}
// Show dashboard on hover
visibilities.dashboard = inTopPanel(panels.dashboard, x, y);
const showDashboard = inTopPanel(panels.dashboard, x, y);
// Always update visibility based on hover if not in shortcut mode
if (!dashboardShortcutActive) {
visibilities.dashboard = showDashboard;
} else if (showDashboard) {
// If hovering over dashboard area while in shortcut mode, transition to hover control
dashboardShortcutActive = false;
}
// Show popouts on hover
const popout = panels.popouts;
@ -75,6 +98,57 @@ MouseArea {
popouts.hasCurrent = false;
}
// Monitor individual visibility changes
Connections {
target: root.visibilities
function onLauncherChanged() {
// If launcher is hidden, clear shortcut flags for dashboard and OSD
if (!root.visibilities.launcher) {
root.dashboardShortcutActive = false;
root.osdShortcutActive = false;
// Also hide dashboard and OSD if they're not being hovered
const inDashboardArea = root.inTopPanel(root.panels.dashboard, root.mouseX, root.mouseY);
const inOsdArea = root.inRightPanel(root.panels.osd, root.mouseX, root.mouseY);
if (!inDashboardArea) {
root.visibilities.dashboard = false;
}
if (!inOsdArea) {
root.visibilities.osd = false;
root.osdHovered = false;
}
}
}
function onDashboardChanged() {
if (root.visibilities.dashboard) {
// Dashboard became visible, immediately check if this should be shortcut mode
const inDashboardArea = root.inTopPanel(root.panels.dashboard, root.mouseX, root.mouseY);
if (!inDashboardArea) {
root.dashboardShortcutActive = true;
}
} else {
// Dashboard hidden, clear shortcut flag
root.dashboardShortcutActive = false;
}
}
function onOsdChanged() {
if (root.visibilities.osd) {
// OSD became visible, immediately check if this should be shortcut mode
const inOsdArea = root.inRightPanel(root.panels.osd, root.mouseX, root.mouseY);
if (!inOsdArea) {
root.osdShortcutActive = true;
}
} else {
// OSD hidden, clear shortcut flag
root.osdShortcutActive = false;
}
}
}
Osd.Interactions {
screen: root.screen
visibilities: root.visibilities