Files
glassMxrph/quickshell/compat/noctalia/Widgets/NTabBar.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

91 lines
2.3 KiB
QML

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import qs.compat.noctalia.Commons
import qs.compat.noctalia.Widgets
Rectangle {
id: root
objectName: "NTabBar"
// Public properties
property int currentIndex: 0
property real spacing: Style.marginXS
property real margins: 0
property real tabHeight: Style.baseWidgetSize
property bool distributeEvenly: false
default property alias content: tabRow.children
onDistributeEvenlyChanged: _applyDistribution()
Component.onCompleted: _applyDistribution()
function _updateFirstLast() {
// Defensive check for QML initialization timing
if (!tabRow || !tabRow.children) {
return;
}
var kids = tabRow.children;
var len = kids.length;
var firstVisible = -1;
var lastVisible = -1;
for (var i = 0; i < len; i++) {
var child = kids[i];
// Only consider items that have isFirst/isLast (actual tab buttons, not Repeaters)
if (child.visible && "isFirst" in child) {
if (firstVisible === -1)
firstVisible = i;
lastVisible = i;
}
}
for (var i = 0; i < len; i++) {
var child = kids[i];
if ("isFirst" in child)
child.isFirst = (i === firstVisible);
if ("isLast" in child)
child.isLast = (i === lastVisible);
}
}
function _applyDistribution() {
if (!tabRow || !tabRow.children) {
return;
}
if (!distributeEvenly) {
for (var i = 0; i < tabRow.children.length; i++) {
var child = tabRow.children[i];
child.Layout.fillWidth = true;
}
return;
}
for (var i = 0; i < tabRow.children.length; i++) {
var child = tabRow.children[i];
child.Layout.fillWidth = true;
child.Layout.preferredWidth = 1;
}
}
// Styling
Layout.margins: Style.borderS
implicitWidth: tabRow.implicitWidth + (margins * 2)
implicitHeight: tabHeight + (margins * 2)
color: Color.smartAlpha(Color.mSurfaceVariant)
radius: Style.iRadiusM
RowLayout {
id: tabRow
anchors.fill: parent
anchors.margins: margins
spacing: root.spacing
onChildrenChanged: {
for (var i = 0; i < children.length; i++) {
var child = children[i];
child.visibleChanged.connect(root._updateFirstLast);
}
root._updateFirstLast();
root._applyDistribution();
}
}
}