Warning, /frameworks/qqc2-desktop-style/org.kde.desktop/TabBar.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2017 Marco Martin <mart@kde.org>
0003     SPDX-FileCopyrightText: 2017 The Qt Company Ltd.
0004     SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk>
0005 
0006     SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-or-later
0007 */
0008 
0009 
0010 import QtQuick 2.6
0011 import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate
0012 import org.kde.kirigami 2.4 as Kirigami
0013 import QtQuick.Templates 2.15 as T
0014 
0015 T.TabBar {
0016     id: controlRoot
0017 
0018     palette: Kirigami.Theme.inherit ? Kirigami.Theme.palette : undefined
0019     Kirigami.Theme.colorSet: Kirigami.Theme.Window
0020     Kirigami.Theme.inherit: false
0021 
0022     //Some QStyles seem to not return sensible pixelmetrics here
0023     implicitWidth: Math.max(Kirigami.Units.gridUnit * 6, contentItem.implicitWidth)
0024     implicitHeight: contentItem.implicitHeight
0025 
0026     spacing: 0
0027 
0028     contentItem: ListView {
0029         implicitWidth: contentWidth
0030         // The binding to contentModel.count is so it updates when the TabBar is populated on demand
0031         implicitHeight: controlRoot.contentModel.get(controlRoot.contentModel.count * 0).height
0032 
0033         model: controlRoot.contentModel
0034         currentIndex: controlRoot.currentIndex
0035 
0036         spacing: -styleItem.pixelMetric("tabOverlap")
0037         orientation: ListView.Horizontal
0038         boundsBehavior: Flickable.StopAtBounds
0039         flickableDirection: Flickable.AutoFlickIfNeeded
0040         snapMode: ListView.SnapToItem
0041 
0042         highlightMoveDuration: 0
0043         highlightRangeMode: ListView.ApplyRange
0044         preferredHighlightBegin: 40
0045         preferredHighlightEnd: width - 40
0046     }
0047 
0048     StylePrivate.StyleItem {
0049         id: styleItem
0050         control: controlRoot
0051         visible: false
0052         elementType: "tabframe"
0053         properties: {
0054             "orientation": controlRoot.position === T.TabBar.Header ? "Top" : "Bottom"
0055         }
0056     }
0057 
0058     background: MouseArea {
0059         acceptedButtons: Qt.NoButton
0060         onWheel: {
0061             if (wheel.pixelDelta.y < 0 || wheel.angleDelta.y < 0) {
0062                 controlRoot.currentIndex = Math.min(controlRoot.currentIndex + 1, controlRoot.contentModel.count - 1);
0063             } else {
0064                 controlRoot.currentIndex = Math.max(controlRoot.currentIndex - 1, 0);
0065             }
0066         }
0067     }
0068 }