example: Add RibbonTour example.

This commit is contained in:
Mentalflow 2024-05-08 09:34:12 +08:00
parent 300d93e2bc
commit 7f32cf62ec
Signed by: Mentalflow
GPG Key ID: 5AE68D4401A2EE71
1 changed files with 88 additions and 4 deletions

View File

@ -1,4 +1,5 @@
import QtQuick import QtQuick
import QtQuick.Window
import QtQuick.Layouts import QtQuick.Layouts
import QtQuick.Controls import QtQuick.Controls
import RibbonUI import RibbonUI
@ -10,10 +11,87 @@ RibbonWindow {
title: qsTr("RibbonUI APP") title: qsTr("RibbonUI APP")
comfirmed_quit: true comfirmed_quit: true
property bool modern_style: RibbonTheme.modern_style property bool modern_style: RibbonTheme.modern_style
RibbonTour{
id: tour
targetList: [
{
title: qsTr("Tab Bar"),
text: qsTr("A tab bar for window, let user choose the controllers."),
target: tab_bar
},
{
title: qsTr("Tab Bar Buttons"),
text: qsTr("Tool buttons at the top of tab bar."),
target: tab_bar_tool
},
{
title: qsTr("Sliders"),
text: qsTr("Vertical/Horizental sliders with/without buttons."),
target: slider_layout,
enter_func: ()=>{
slider_with_btn.value = 70
slider_without_btn.value = 70
},
exit_func: ()=>{
slider_with_btn.value = 50
slider_without_btn.value = 50
}
},
{
title: qsTr("Switch Buttons"),
text: qsTr("Switch buttons with/without background color or grabber text."),
target: switch_layout,
enter_func: ()=>btn_with_color_and_grabber_text.checked = true,
exit_func: ()=>btn_with_color_and_grabber_text.checked = false
},
{
title: qsTr("CheckBoxs"),
text: qsTr("CheckBoxs with colorful background or with/without label text."),
target: checkbox_layout
},
{
title: qsTr("Buttons"),
text: qsTr("Buttons with/without background or label text."),
target: button_layout,
enter_func: ()=>btn_without_bg_and_label.checked = true,
exit_func: ()=>btn_without_bg_and_label.checked = false
},
{
title: qsTr("Push Buttons"),
text: qsTr("Push buttons with/without sub menu."),
target: pushbutton_layout
},
{
title: qsTr("Line Edits"),
text: qsTr("Line edits with/without icon."),
target: lineedit_layout,
enter_func: ()=>{
tab_bar.setPage(1)
lineedit_with_icon.text = "Line Edit with icon."
tour.refresh(300)
},
exit_func: ()=>{
tab_bar.setPage(0)
lineedit_with_icon.clear()
tour.refresh(300)
}
},
{
title: qsTr("Bottom Bar"),
text: qsTr("A bottom bar for window."),
target: bottom_bar
},
]
target: window_items
blur_enabled: true
target_rect: Qt.rect(window_items.x + x, window_items.y + y, width, height)
}
Component.onCompleted: tour.open()
RibbonTabBar { RibbonTabBar {
id: tab_bar id: tab_bar
modern_style: root.modern_style modern_style: root.modern_style
right_tool_bar: RowLayout{ right_tool_bar: RowLayout{
id: tab_bar_tool
spacing: 10 spacing: 10
RibbonButton{ RibbonButton{
text:"Test Button 1" text:"Test Button 1"
@ -37,12 +115,14 @@ RibbonWindow {
height: parent.height height: parent.height
spacing: 0 spacing: 0
RibbonSlider{ RibbonSlider{
id: slider_with_btn
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
slide_width: 40 slide_width: 40
horizontal: false horizontal: false
value: 20 value: 20
} }
RibbonSlider{ RibbonSlider{
id: slider_without_btn
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
slide_width: 40 slide_width: 40
horizontal: false horizontal: false
@ -77,6 +157,7 @@ RibbonWindow {
ColumnLayout{ ColumnLayout{
spacing: 5 spacing: 5
RibbonSwitchButton{ RibbonSwitchButton{
id: btn_with_color_and_grabber_text
text: "Button" text: "Button"
grabber_checked_color: "red" grabber_checked_color: "red"
checked: true checked: true
@ -192,6 +273,7 @@ RibbonWindow {
ColumnLayout{ ColumnLayout{
spacing: 10 spacing: 10
RibbonButton{ RibbonButton{
id: btn_without_bg_and_label
show_bg:false show_bg:false
icon_source: RibbonIcons.Badge icon_source: RibbonIcons.Badge
icon_source_filled: RibbonIcons_Filled.Badge icon_source_filled: RibbonIcons_Filled.Badge
@ -228,6 +310,7 @@ RibbonWindow {
icon_source: RibbonIcons.AttachText icon_source: RibbonIcons.AttachText
} }
RibbonPushButton{ RibbonPushButton{
id: push_btn_with_menu
text: qsTr("Menu") text: qsTr("Menu")
icon_source: RibbonIcons.MeetNow icon_source: RibbonIcons.MeetNow
Action{ Action{
@ -282,6 +365,7 @@ RibbonWindow {
spacing: 10 spacing: 10
Layout.fillHeight: true Layout.fillHeight: true
RibbonLineEdit{ RibbonLineEdit{
id: lineedit_with_icon
icon_source:RibbonIcons.Search icon_source:RibbonIcons.Search
} }
RibbonLineEdit{ RibbonLineEdit{
@ -708,14 +792,14 @@ RibbonWindow {
} }
RibbonButton{ RibbonButton{
show_bg:false show_bg:false
icon_source: RibbonIcons.CalendarStar icon_source: RibbonIcons.Map
icon_source_filled: RibbonIcons_Filled.CalendarStar icon_source_filled: RibbonIcons_Filled.Map
checkable: true tip_text: qsTr("Tour")
tip_text: "Test Button 11"
hover_color: Qt.rgba(0,0,0, 0.3) hover_color: Qt.rgba(0,0,0, 0.3)
pressed_color: Qt.rgba(0,0,0, 0.4) pressed_color: Qt.rgba(0,0,0, 0.4)
text_color: title_bar.title_text_color text_color: title_bar.title_text_color
text_color_reverse: false text_color_reverse: false
onClicked: tour.open()
} }
} }