Warning, /frameworks/qqc2-desktop-style/org.kde.desktop/TabButton.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 0011 import QtQml.Models 0012 //for TabBar.* 0013 import QtQuick.Controls 0014 import QtQuick.Templates as T 0015 import org.kde.kirigami as Kirigami 0016 import org.kde.qqc2desktopstyle.private as StylePrivate 0017 0018 T.TabButton { 0019 id: controlRoot 0020 0021 //Some qstyles like fusion don't have correct pixel metrics here and just return 0 0022 implicitWidth: Math.max(styleitem.implicitWidth, textMetrics.width + Kirigami.Units.gridUnit * 2) 0023 implicitHeight: styleitem.implicitHeight || Kirigami.Units.gridUnit * 2 0024 baselineOffset: contentItem.y + contentItem.baselineOffset 0025 0026 //This width: is important to make the tabbar internals not assume 0027 //all tabs have the same width 0028 width: implicitWidth 0029 padding: 0 0030 0031 hoverEnabled: true 0032 0033 contentItem: Item {} 0034 0035 Kirigami.MnemonicData.enabled: enabled && visible 0036 Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.SecondaryControl 0037 Kirigami.MnemonicData.label: text 0038 Shortcut { 0039 //in case of explicit & the button manages it by itself 0040 enabled: !(RegExp(/\&[^\&]/).test(controlRoot.text)) 0041 sequence: controlRoot.Kirigami.MnemonicData.sequence 0042 onActivated: controlRoot.checked = true; 0043 } 0044 background: StylePrivate.StyleItem { 0045 id: styleitem 0046 0047 TextMetrics { 0048 id: textMetrics 0049 font: Kirigami.Theme.defaultFont 0050 text: controlRoot.text 0051 } 0052 0053 control: controlRoot 0054 anchors.fill: parent 0055 elementType: "tab" 0056 paintMargins: 0 0057 0058 readonly property TabBar tabBar: controlRoot.TabBar.tabBar 0059 0060 property string orientation: controlRoot.TabBar.position === TabBar.Header ? "Top" : "Bottom" 0061 property string selectedpos: { 0062 if (tabBar) { 0063 switch (tabBar.currentIndex) { 0064 case (controlRoot.TabBar.index + 1): return "next"; 0065 case (controlRoot.TabBar.index - 1): return "previous"; 0066 } 0067 } 0068 return ""; 0069 } 0070 property string tabpos: { 0071 if (tabBar) { 0072 if (tabBar.count === 1) { 0073 return "only"; 0074 } 0075 switch (controlRoot.TabBar.index) { 0076 case 0: return "beginning"; 0077 case (tabBar.count - 1): return "end"; 0078 } 0079 } 0080 return "middle"; 0081 } 0082 0083 properties: { 0084 "icon": controlRoot.display !== T.AbstractButton.TextOnly 0085 ? (controlRoot.icon.name !== "" ? controlRoot.icon.name : controlRoot.icon.source) : null, 0086 "iconColor": Qt.colorEqual(controlRoot.icon.color, "transparent") ? Kirigami.Theme.textColor : controlRoot.icon.color, 0087 "iconWidth": controlRoot.icon.width, 0088 "iconHeight": controlRoot.icon.height, 0089 0090 "hasFrame" : true, 0091 "orientation": orientation, 0092 "tabpos": tabpos, 0093 "selectedpos": selectedpos, 0094 } 0095 0096 enabled: controlRoot.enabled 0097 selected: controlRoot.checked 0098 text: controlRoot.Kirigami.MnemonicData.mnemonicLabel 0099 hover: controlRoot.hovered 0100 hasFocus: controlRoot.activeFocus 0101 } 0102 }