opaque/TabBar.qml

44 lines
1.1 KiB
QML

import QtQuick 2.13
import QtQuick.Controls 2.13
import "../opaque/theme"
// Tabs.qml
//
// Example 1:
// Tabs {
// model: [qsTr("tab1-name"), qsTr("tab2-name"), qsTr("tab3-name")]
// onCurrentIndexChanged: {
// //...eg: loader.source = filenames[currentIndex]
// }
// }
ListView {
id: root
// properties
property color highlightColor: Theme.dividerColor
// contents & appearance config
model: ["your", "model", "here"]
delegate: Label {
// contents & appearance config
text: model.modelData
elide: Text.ElideRight
horizontalAlignment: Text.AlignHCenter
color: Theme.mainTextColor
font.pixelSize: Theme.chatMetaTextSize * gcd.themeScale
font.weight: Font.Bold
// functionality
MouseArea { anchors.fill: parent; onClicked: root.currentIndex = index; }
width: root.width / root.model.length
}
highlight: Rectangle { radius: 5; color: root.highlightColor; }
// functionality
height: Theme.secondaryTextSize * gcd.themeScale + 5
orientation: Qt.Horizontal
interactive: true
highlightFollowsCurrentItem: true
boundsBehavior: Flickable.StopAtBounds
}