FluentUI/example/qml/page/T_TabView.qml

129 lines
3.6 KiB
QML
Raw Normal View History

2023-08-24 15:50:37 +08:00
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import FluentUI 1.0
2023-08-26 17:20:30 +08:00
import "../component"
2023-03-27 18:24:35 +08:00
FluScrollablePage{
2023-03-30 11:43:35 +08:00
property var colors : [FluColors.Yellow,FluColors.Orange,FluColors.Red,FluColors.Magenta,FluColors.Purple,FluColors.Blue,FluColors.Teal,FluColors.Green]
2024-03-09 15:35:48 +08:00
title: qsTr("TabView")
2023-05-11 18:24:58 +08:00
2023-03-27 22:58:33 +08:00
Component{
id:com_page
Rectangle{
anchors.fill: parent
2024-03-07 13:58:23 +08:00
color: argument.normal
2023-03-27 22:58:33 +08:00
}
}
2023-03-30 11:43:35 +08:00
function newTab(){
2024-03-09 15:35:48 +08:00
tab_view.appendTab("qrc:/example/res/image/favicon.ico",qsTr("Document ")+tab_view.count(),com_page,colors[Math.floor(Math.random() * 8)])
2023-03-30 11:43:35 +08:00
}
2023-03-27 22:58:33 +08:00
Component.onCompleted: {
2023-03-30 11:43:35 +08:00
newTab()
newTab()
newTab()
2023-03-27 22:58:33 +08:00
}
2023-03-27 18:24:35 +08:00
2024-03-29 16:56:09 +08:00
FluFrame{
2023-04-03 09:32:06 +08:00
Layout.fillWidth: true
2024-03-29 16:23:16 +08:00
Layout.preferredHeight: 50
padding: 10
2023-03-30 11:43:35 +08:00
RowLayout{
spacing: 14
FluDropDownButton{
id:btn_tab_width_behavior
Layout.preferredWidth: 140
text:"Equal"
2023-06-18 13:56:30 +08:00
FluMenuItem{
text:"Equal"
onClicked: {
btn_tab_width_behavior.text = text
2023-07-18 18:24:06 +08:00
tab_view.tabWidthBehavior = FluTabViewType.Equal
2023-03-30 11:43:35 +08:00
}
2023-06-18 13:56:30 +08:00
}
FluMenuItem{
text:"SizeToContent"
onClicked: {
btn_tab_width_behavior.text = text
2023-07-18 18:24:06 +08:00
tab_view.tabWidthBehavior = FluTabViewType.SizeToContent
2023-06-18 13:56:30 +08:00
}
}
FluMenuItem{
text:"Compact"
onClicked: {
btn_tab_width_behavior.text = text
2023-07-18 18:24:06 +08:00
tab_view.tabWidthBehavior = FluTabViewType.Compact
2023-06-18 13:56:30 +08:00
}
}
2023-03-30 11:43:35 +08:00
}
FluDropDownButton{
id:btn_close_button_visibility
text:"Always"
2023-04-03 09:32:06 +08:00
Layout.preferredWidth: 120
2023-06-18 13:56:30 +08:00
FluMenuItem{
2024-01-02 22:55:17 +08:00
text:"Never"
2023-06-18 13:56:30 +08:00
onClicked: {
btn_close_button_visibility.text = text
2024-01-02 22:55:17 +08:00
tab_view.closeButtonVisibility = FluTabViewType.Never
2023-06-18 13:56:30 +08:00
}
}
FluMenuItem{
text:"Always"
onClicked: {
btn_close_button_visibility.text = text
2023-07-18 18:24:06 +08:00
tab_view.closeButtonVisibility = FluTabViewType.Always
2023-06-18 13:56:30 +08:00
}
}
FluMenuItem{
text:"OnHover"
onClicked: {
btn_close_button_visibility.text = text
2023-07-18 18:24:06 +08:00
tab_view.closeButtonVisibility = FluTabViewType.OnHover
2023-03-30 11:43:35 +08:00
}
2023-06-18 13:56:30 +08:00
}
2023-03-30 11:43:35 +08:00
}
}
}
2023-03-27 18:24:35 +08:00
2024-03-29 16:56:09 +08:00
FluFrame{
2023-04-03 09:32:06 +08:00
Layout.fillWidth: true
2023-04-06 17:32:21 +08:00
Layout.topMargin: 15
2024-03-29 16:23:16 +08:00
Layout.preferredHeight: 400
padding: 10
2023-03-27 18:24:35 +08:00
FluTabView{
2023-03-27 22:58:33 +08:00
id:tab_view
2023-03-30 11:43:35 +08:00
onNewPressed:{
newTab()
}
2023-03-27 18:24:35 +08:00
}
}
2023-04-06 17:32:21 +08:00
CodeExpander{
Layout.fillWidth: true
2024-03-29 16:23:16 +08:00
Layout.topMargin: -6
2023-04-06 17:32:21 +08:00
code:'FluTabView{
anchors.fill: parent
Component.onCompleted: {
newTab()
newTab()
newTab()
}
Component{
id:com_page
Rectangle{
anchors.fill: parent
color: argument
}
}
function newTab(){
2023-04-27 09:38:57 +08:00
tab_view.appendTab("qrc:/example/res/image/favicon.ico","Document 1",com_page,argument)
2023-04-06 17:32:21 +08:00
}
}
'
}
2023-03-27 18:24:35 +08:00
}