Files
glassMxrph/quickshell/compat/noctalia/Widgets/NTabButton.qml
T
mxandClaude Opus 5.5 99e64a7713 Add glassMxrph shell sources
Initial commit of the Quickshell desktop suite: bar, dock, launcher,
settings, Control Center, dashboard, OSD, lock screen, desktop widgets,
plugin host with the vendored Noctalia/Omarchy compatibility layer,
helpers, packaging, tests and phase documentation.

Includes the optimization work so far: usage widgets and dashboard
gauges no longer animate continuously, desktop widgets pause while
covered, system controls stop flickering on background polls, dock app
matching uses an indexed catalog, and workspace ghosts are created only
for occupied slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 22:36:17 +02:00

128 lines
3.4 KiB
QML

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import qs.compat.noctalia.Commons
import qs.compat.noctalia.Services.UI
import qs.compat.noctalia.Widgets
Rectangle {
id: root
// Public properties
property string text: ""
property string icon: ""
property var tooltipText
property bool checked: false
property int tabIndex: 0
property real pointSize: Style.fontSizeM
property bool isFirst: false
property bool isLast: false
// Internal state
property bool isHovered: false
signal clicked
// Sizing
Layout.fillHeight: true
implicitWidth: contentLayout.implicitWidth + Style.margin2M
topLeftRadius: isFirst ? Style.iRadiusM : Style.iRadiusXXXS
bottomLeftRadius: isFirst ? Style.iRadiusM : Style.iRadiusXXXS
topRightRadius: isLast ? Style.iRadiusM : Style.iRadiusXXXS
bottomRightRadius: isLast ? Style.iRadiusM : Style.iRadiusXXXS
color: root.isHovered ? Color.mHover : (root.checked ? Color.mPrimary : Color.smartAlpha(Color.mSurface))
border.color: root.checked ? Color.mPrimary : Color.mOutline
border.width: Style.borderS
Behavior on color {
enabled: !Color.isTransitioning
ColorAnimation {
duration: Style.animationFast
easing.type: Easing.OutCubic
}
}
// Content
RowLayout {
id: contentLayout
anchors.centerIn: parent
width: Math.min(implicitWidth, parent.width - Style.margin2S)
spacing: (root.icon !== "" && root.text !== "") ? Style.marginXS : 0
NIcon {
visible: root.icon !== ""
Layout.alignment: Qt.AlignVCenter
icon: root.icon
pointSize: root.pointSize * 1.2
color: root.isHovered ? Color.mOnHover : (root.checked ? Color.mOnPrimary : Color.mOnSurface)
Behavior on color {
enabled: !Color.isTransitioning
ColorAnimation {
duration: Style.animationFast
easing.type: Easing.OutCubic
}
}
}
NText {
id: tabText
visible: root.text !== ""
Layout.alignment: Qt.AlignVCenter
text: root.text
pointSize: root.pointSize
font.weight: Style.fontWeightSemiBold
color: root.isHovered ? Color.mOnHover : (root.checked ? Color.mOnPrimary : Color.mOnSurface)
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
Behavior on color {
enabled: !Color.isTransitioning
ColorAnimation {
duration: Style.animationFast
easing.type: Easing.OutCubic
}
}
}
}
// Tooltip
Timer {
id: tooltipTimer
interval: 500
onTriggered: {
if (root.isHovered && root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) {
TooltipService.show(root, root.tooltipText);
}
}
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onEntered: {
root.isHovered = true;
if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) {
tooltipTimer.start();
}
}
onExited: {
root.isHovered = false;
tooltipTimer.stop();
if (root.tooltipText && (!Array.isArray(root.tooltipText) || root.tooltipText.length > 0)) {
TooltipService.hide();
}
}
onClicked: {
root.clicked();
// Update parent NTabBar's currentIndex
if (root.parent && root.parent.parent && root.parent.parent.currentIndex !== undefined) {
root.parent.parent.currentIndex = root.tabIndex;
}
}
}
}