Warning, /maui/nomad-style/TabButton.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  * Copyright 2017 Marco Martin <mart@kde.org>
0003  * Copyright 2017 The Qt Company Ltd.
0004  *
0005  * GNU Lesser General Public License Usage
0006  * Alternatively, this file may be used under the terms of the GNU Lesser
0007  * General Public License version 3 as published by the Free Software
0008  * Foundation and appearing in the file LICENSE.LGPLv3 included in the
0009  * packaging of this file. Please review the following information to
0010  * ensure the GNU Lesser General Public License version 3 requirements
0011  * will be met: https://www.gnu.org/licenses/lgpl.html.
0012  *
0013  * GNU General Public License Usage
0014  * Alternatively, this file may be used under the terms of the GNU
0015  * General Public License version 2.0 or later as published by the Free
0016  * Software Foundation and appearing in the file LICENSE.GPL included in
0017  * the packaging of this file. Please review the following information to
0018  * ensure the GNU General Public License version 2.0 requirements will be
0019  * met: http://www.gnu.org/licenses/gpl-2.0.html.
0020  */
0021 
0022 
0023 import QtQuick 2.6
0024 import QtQml.Models 2.1
0025 //for TabBar.*
0026 import QtQuick.Controls 2.3
0027 import org.kde.qqc2desktopstyle.private 1.0 as StylePrivate
0028 import QtQuick.Templates 2.3 as T
0029 import org.kde.kirigami 2.2 as Kirigami
0030 
0031 T.TabButton {
0032     id: controlRoot
0033 
0034     //Some qstyles like fusion don't have correct pixel metrics here and just return 0
0035     implicitWidth: Math.max(styleitem.implicitWidth, textMetrics.width + Kirigami.Units.gridUnit * 2)
0036     implicitHeight: styleitem.implicitHeight || Kirigami.Units.gridUnit * 2
0037     baselineOffset: contentItem.y + contentItem.baselineOffset
0038 
0039     //This width: is important to make the tabbar internals not assume
0040     //all tabs have the same width
0041     width: implicitWidth
0042     padding: 0
0043 
0044     hoverEnabled: true
0045 
0046     contentItem: Item {}
0047 
0048     background: StylePrivate.StyleItem {
0049         id: styleitem
0050 
0051         TextMetrics {
0052             id: textMetrics
0053             font.capitalization: Kirigami.Theme.defaultFont.capitalization
0054             font.family: Kirigami.Theme.defaultFont.family
0055             font.italic: Kirigami.Theme.defaultFont.italic
0056             font.letterSpacing: Kirigami.Theme.defaultFont.letterSpacing
0057             font.pointSize: Kirigami.Theme.defaultFont.pointSize
0058             font.strikeout: Kirigami.Theme.defaultFont.strikeout
0059             font.underline: Kirigami.Theme.defaultFont.underline
0060             font.weight: Kirigami.Theme.defaultFont.weight
0061             font.wordSpacing: Kirigami.Theme.defaultFont.wordSpacing
0062             text: controlRoot.text
0063         }
0064 
0065         control: controlRoot
0066         anchors.fill: parent
0067         elementType: "tab"
0068         paintMargins: 0
0069         property Item tabBar: controlRoot.parent.parent.parent
0070 
0071         property string orientation: tabBar.position == TabBar.Header ? "Top" : "Bottom"
0072         property string selectedpos: tabBar.currentIndex == controlRoot.ObjectModel.index + 1 ? "next" :
0073                                     tabBar.currentIndex == controlRoot.ObjectModel.index - 1 ? "previous" : ""
0074         property string tabpos: tabBar.count === 1 ? "only" : controlRoot.ObjectModel.index === 0 ? "beginning" : controlRoot.ObjectModel.index === tabBar.count - 1 ? "end" : "middle"
0075 
0076         properties: {
0077             "hasFrame" : true,
0078             "orientation": orientation,
0079             "tabpos": tabpos,
0080             "selectedpos": selectedpos
0081         }
0082 
0083         enabled: controlRoot.enabled
0084         selected: controlRoot.checked
0085         text: controlRoot.text
0086         hover: controlRoot.hovered
0087         hasFocus: controlRoot.activeFocus
0088     }
0089 }