aboutsummaryrefslogtreecommitdiffstats
path: root/mail-overview/Button.qml
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-09-12 10:20:05 +0200
committerDanilo M. <danix@danix.xyz>2026-09-12 10:20:05 +0200
commitb0f4607376bec0506b22bf0303011a9d94ff44ce (patch)
tree8a8f0f6962894f40d5bd1095148a663844cd482e /mail-overview/Button.qml
parent2b4e1bb2d62c464d9eb949dc7c60cac8dd57f638 (diff)
downloadquickshell-b0f4607376bec0506b22bf0303011a9d94ff44ce.tar.gz
quickshell-b0f4607376bec0506b22bf0303011a9d94ff44ce.zip
feat(mail-overview): the drawer
Builds the panel body on the house idiom the other two components already use: a fullscreen transparent PanelWindow holding a dim backdrop, with the real content as a Rectangle anchored inside it. The idiom is worth the seemingly oversized window because it hands us two behaviours for free. Click-outside-to-close is just a MouseArea filling the backdrop, and the drawer only needs its own MouseArea to swallow clicks so they do not fall through. Escape works because the window actually covers the screen and can take exclusive keyboard focus. exclusionMode is Normal here, unlike the Ignore the other two components set. Waybar claims an exclusive zone at the top of this screen, and the mail icon lives in it, so respecting that zone positions the drawer immediately below the bar without this file hardcoding, or even knowing, the bar's height. It also means the backdrop begins below waybar, so the bar itself does not dim while its own drawer is open, which reads correctly: the icon you clicked stays lit. Focus sits on an inner Item with focus: true, not on the window. Setting WlrLayershell.keyboardFocus is necessary but not sufficient, because key events in QML are delivered to a focused item and never to a window, so Keys.onEscapePressed on the PanelWindow would never fire. This cost time in the vm-manager panel and the same shape is used here deliberately. Thread rows are deliberately read-only, with no click handler. qtmaildir takes no arguments, so there is no way to ask it to open a particular thread and a clickable row would promise navigation it cannot deliver. The rows are a preview; the button opens the client at its own idea of where to start. show() refreshes before opening rather than relying on a timer. The panel is opened rarely and the shell is autostarted for the whole session, so the counts are almost always stale by the time anyone looks at them, and a refresh on open is both cheaper and fresher than polling. Also removes the temporary console probe from shell.qml, which existed only to verify the account model parsed and counted correctly. The drawer now displays the same data, so the probe has no job left. Dropping it also drops the QtQuick import, which nothing else in that file needed. Button.qml is an unmodified copy of vm-manager's. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WWL8JYHu7yhAdtx5pU9PMU
Diffstat (limited to 'mail-overview/Button.qml')
-rw-r--r--mail-overview/Button.qml45
1 files changed, 45 insertions, 0 deletions
diff --git a/mail-overview/Button.qml b/mail-overview/Button.qml
new file mode 100644
index 0000000..d6ca78f
--- /dev/null
+++ b/mail-overview/Button.qml
@@ -0,0 +1,45 @@
+// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+import QtQuick
+
+Rectangle {
+ id: btn
+ property alias text: label.text
+ property bool danger: false
+ property bool enabled: true
+ signal clicked
+
+ implicitWidth: label.implicitWidth + 22
+ implicitHeight: label.implicitHeight + 12
+ radius: 7
+ opacity: enabled ? 1 : 0.4
+ color: area.containsMouse && enabled
+ ? Qt.alpha(danger ? Theme.red : Theme.accent, 0.25)
+ : Qt.alpha(Theme.surface, 0.8)
+ border.width: 1
+ border.color: Qt.alpha(danger ? Theme.red : Theme.text, 0.2)
+
+ Text {
+ id: label
+ anchors.centerIn: parent
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2 }
+ color: danger ? Theme.red : Theme.text
+ }
+
+ MouseArea {
+ id: area
+ anchors.fill: parent
+ hoverEnabled: true
+ cursorShape: btn.enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
+ onClicked: if (btn.enabled) btn.clicked()
+ }
+}