Qt 6.12's QtQuick exports a Color singleton, which hides the Omarchy and Noctalia kits' Commons.Color: every Color.foreground read undefined, so plugin buttons, toggles and text fell back to black. The kits now import QtQuick 6.8, which predates it, and the installer pins the same version in plugin files that use Color (reinstall plugins to pick it up). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
128 lines
3.5 KiB
QML
128 lines
3.5 KiB
QML
import QtQuick 6.8 // 6.12 added a QtQuick Color singleton that hides Commons.Color
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|