Make the tailnet label open the panel
The label was a plain Text with its own MouseArea, which is not registered in bar.clickTargets. While a panel is open, KeyboardPanel puts a full-screen overlay above everything and forwards clicks landing in the bar strip only to registered targets — so a left click opened the panel and then had the same click treated as "outside", dismissing it. It looked like nothing happened. Right click was unaffected because toggleOffscale() never involves the panel. Use a WidgetButton instead: it registers itself via syncClickRegistration() and renders the label text natively, so both the Text and the MouseArea go away. Left toggles the panel, right toggles Offscale, middle refreshes — the same three buttons as the icon, so the widget reads as one target. `dimmed` handles the inactive state rather than darkening the colour, since Qt.darker on yellow shifts the hue to olive. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -403,18 +403,31 @@ Panel {
|
||||
anchors.fill: parent
|
||||
spacing: Style.space(4)
|
||||
|
||||
Text {
|
||||
// A WidgetButton rather than a plain Text with a MouseArea, because
|
||||
// WidgetButton registers itself in bar.clickTargets. That registration is
|
||||
// what makes left-click work: while a panel is open, KeyboardPanel puts a
|
||||
// full-screen overlay above everything and forwards clicks in the bar strip
|
||||
// only to registered targets. An unregistered MouseArea would open the
|
||||
// panel on press and then have the same click treated as "outside" and
|
||||
// dismiss it — the panel appeared not to open at all.
|
||||
WidgetButton {
|
||||
id: tailnetLabel
|
||||
visible: text !== ""
|
||||
bar: root.bar
|
||||
text: root.tailnetName
|
||||
// Brand yellow. Dimmed by opacity rather than by darkening the colour
|
||||
// when Tailscale is off — Qt.darker on yellow slides the hue to olive
|
||||
// instead of just quietening it, the same trap as the IP/DNS subtitle.
|
||||
color: root.accent
|
||||
opacity: tailscale.active ? 1.0 : 0.5
|
||||
font.family: root.fontFamily
|
||||
font.pixelSize: Style.bar.iconFont
|
||||
// Brand yellow. `dimmed` fades the whole button when Tailscale is off,
|
||||
// rather than darkening the colour — Qt.darker on yellow slides the hue
|
||||
// to olive instead of quietening it, the same trap as the IP/DNS line.
|
||||
foreground: root.accent
|
||||
useActiveColor: false
|
||||
dimmed: !tailscale.active
|
||||
fontSize: Style.bar.iconFont
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
onPressed: function(buttonCode) {
|
||||
if (buttonCode === Qt.RightButton) tailscale.toggleOffscale()
|
||||
else if (buttonCode === Qt.MiddleButton) tailscale.refresh()
|
||||
else root.toggle()
|
||||
}
|
||||
}
|
||||
|
||||
BarIconButton {
|
||||
|
||||
Reference in New Issue
Block a user