opaque/TabBar.qml

44 lines
1.0 KiB
QML
Raw Normal View History

2020-11-23 23:44:26 +00:00
import QtQuick 2.13
import QtQuick.Controls 2.13
2020-12-15 01:16:49 +00:00
import "." as Opaque
import "./theme"
2020-11-23 23:44:26 +00:00
// Tabs.qml
//
// Example 1:
// Tabs {
// model: [qsTr("tab1-name"), qsTr("tab2-name"), qsTr("tab3-name")]
// onCurrentIndexChanged: {
// //...eg: loader.source = filenames[currentIndex]
// }
// }
ListView {
id: root
2020-11-24 00:19:34 +00:00
// properties
property color highlightColor: Theme.dividerColor
2020-11-23 23:44:26 +00:00
// contents & appearance config
model: ["your", "model", "here"]
2020-12-15 01:16:49 +00:00
delegate: Opaque.Label {
2020-11-23 23:44:26 +00:00
// contents & appearance config
text: model.modelData
elide: Text.ElideRight
horizontalAlignment: Text.AlignHCenter
2020-12-15 01:16:49 +00:00
size: Theme.textSmallPt
bold: true
2020-11-23 23:44:26 +00:00
// functionality
MouseArea { anchors.fill: parent; onClicked: root.currentIndex = index; }
width: root.width / root.model.length
}
2020-12-15 01:16:49 +00:00
highlight: Rectangle { id: hl; radius: 5; color: root.highlightColor; x: 0; width: root.width / root.model.length;}
2020-11-23 23:44:26 +00:00
// functionality
2020-12-15 01:16:49 +00:00
height: Theme.uiIconSizeS
2020-11-23 23:44:26 +00:00
orientation: Qt.Horizontal
interactive: true
highlightFollowsCurrentItem: true
boundsBehavior: Flickable.StopAtBounds
}