more fixes for menu and tooltip
This commit is contained in:
parent
df58449ef5
commit
e7abfebe49
2 changed files with 29 additions and 52 deletions
|
|
@ -1,24 +1,24 @@
|
|||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import Quickshell
|
||||
import Quickshell.Wayland
|
||||
import "." as M
|
||||
|
||||
// Per-icon context menu popup window.
|
||||
// Covers the full screen on the Overlay layer so clicking anywhere outside
|
||||
// Covers the screen on the Overlay layer so clicking anywhere outside
|
||||
// the menu panel dismisses it. Created on demand by Tray.qml delegates.
|
||||
PanelWindow {
|
||||
id: menuWindow
|
||||
|
||||
required property QsMenuHandle handle
|
||||
required property var handle
|
||||
required property var screen
|
||||
// Global x of the icon center (from mapToGlobal), used to position the panel
|
||||
required property real anchorX
|
||||
|
||||
signal menuClosed()
|
||||
|
||||
// Current menu level — swapped when entering/leaving submenus
|
||||
property var _currentHandle: handle
|
||||
property var _handleStack: []
|
||||
|
||||
visible: true
|
||||
color: "transparent"
|
||||
|
||||
|
|
@ -42,15 +42,15 @@ PanelWindow {
|
|||
id: panel
|
||||
|
||||
x: Math.max(0, Math.min(
|
||||
Math.round(menuWindow.anchorX - menuStack.width / 2),
|
||||
menuWindow.width - menuStack.width
|
||||
Math.round(menuWindow.anchorX - menuCol.width / 2),
|
||||
menuWindow.width - menuCol.width
|
||||
))
|
||||
y: 0
|
||||
|
||||
width: menuStack.width
|
||||
height: menuStack.height
|
||||
width: menuCol.width
|
||||
height: menuCol.height
|
||||
|
||||
// Eat clicks inside the panel so they don't reach the dismiss area above
|
||||
// Eat clicks inside the panel
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
|
@ -65,33 +65,8 @@ PanelWindow {
|
|||
bottomRightRadius: M.Theme.radius
|
||||
}
|
||||
|
||||
StackView {
|
||||
id: menuStack
|
||||
|
||||
width: currentItem ? currentItem.width : 0
|
||||
height: currentItem ? currentItem.height : 0
|
||||
|
||||
// Push the root page once the stack is ready
|
||||
Component.onCompleted: {
|
||||
menuStack.push(menuPageComp, { handle: menuWindow.handle, isRoot: true }, StackView.Immediate);
|
||||
}
|
||||
|
||||
pushEnter: Transition {}
|
||||
pushExit: Transition {}
|
||||
popEnter: Transition {}
|
||||
popExit: Transition {}
|
||||
}
|
||||
}
|
||||
|
||||
// Reusable menu page component — used for both root and submenus
|
||||
Component {
|
||||
id: menuPageComp
|
||||
|
||||
Column {
|
||||
id: page
|
||||
|
||||
required property QsMenuHandle handle
|
||||
property bool isRoot: false
|
||||
id: menuCol
|
||||
|
||||
width: 220
|
||||
topPadding: 4
|
||||
|
|
@ -100,14 +75,14 @@ PanelWindow {
|
|||
|
||||
QsMenuOpener {
|
||||
id: opener
|
||||
menu: page.handle
|
||||
menu: menuWindow._currentHandle
|
||||
}
|
||||
|
||||
// Back button (shown only in submenus)
|
||||
// Back button (submenus only)
|
||||
Item {
|
||||
visible: !page.isRoot
|
||||
width: page.width
|
||||
height: 28
|
||||
visible: menuWindow._handleStack.length > 0
|
||||
width: menuCol.width
|
||||
height: visible ? 28 : 0
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
|
|
@ -121,7 +96,7 @@ PanelWindow {
|
|||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 12
|
||||
text: "‹ " + qsTr("Back")
|
||||
text: "\u2039 Back"
|
||||
color: M.Theme.base05
|
||||
font.pixelSize: M.Theme.fontSize
|
||||
font.family: M.Theme.fontFamily
|
||||
|
|
@ -131,7 +106,11 @@ PanelWindow {
|
|||
id: backArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onClicked: menuStack.pop()
|
||||
onClicked: {
|
||||
const stack = menuWindow._handleStack.slice();
|
||||
menuWindow._currentHandle = stack.pop();
|
||||
menuWindow._handleStack = stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -143,10 +122,10 @@ PanelWindow {
|
|||
|
||||
required property QsMenuEntry modelData
|
||||
|
||||
width: page.width
|
||||
width: menuCol.width
|
||||
height: modelData.isSeparator ? 9 : 28
|
||||
|
||||
// Separator line
|
||||
// Separator
|
||||
Rectangle {
|
||||
visible: entryItem.modelData.isSeparator
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
|
@ -204,7 +183,7 @@ PanelWindow {
|
|||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 12
|
||||
text: "›"
|
||||
text: "\u203A"
|
||||
color: entryItem.modelData.enabled ? M.Theme.base05 : M.Theme.base03
|
||||
font.pixelSize: M.Theme.fontSize
|
||||
font.family: M.Theme.fontFamily
|
||||
|
|
@ -217,10 +196,8 @@ PanelWindow {
|
|||
enabled: !entryItem.modelData.isSeparator && entryItem.modelData.enabled
|
||||
onClicked: {
|
||||
if (entryItem.modelData.hasChildren) {
|
||||
menuStack.push(menuPageComp, {
|
||||
handle: entryItem.modelData,
|
||||
isRoot: false
|
||||
}, StackView.Immediate);
|
||||
menuWindow._handleStack = menuWindow._handleStack.concat([menuWindow._currentHandle]);
|
||||
menuWindow._currentHandle = entryItem.modelData;
|
||||
} else {
|
||||
entryItem.modelData.triggered();
|
||||
menuWindow.menuClosed();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue