FluentUI/example/qml/page/T_InfoBar.qml

127 lines
3.8 KiB
QML
Raw Permalink Normal View History

2023-08-24 15:50:37 +08:00
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import FluentUI 1.0
2023-08-26 17:20:30 +08:00
import "../component"
2023-02-28 18:29:00 +08:00
2023-03-10 18:08:32 +08:00
FluScrollablePage{
2023-03-28 17:53:46 +08:00
2024-03-09 15:35:48 +08:00
title: qsTr("InfoBar")
2023-03-10 18:08:32 +08:00
property var info1
property var info2
property var info3
2024-03-29 16:56:09 +08:00
FluFrame{
2023-04-06 17:32:21 +08:00
Layout.fillWidth: true
Layout.preferredHeight: 350
2024-03-29 16:23:16 +08:00
padding: 10
2023-04-06 17:32:21 +08:00
ColumnLayout{
spacing: 14
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
}
FluButton{
2024-03-09 15:35:48 +08:00
text: qsTr("Info")
2023-04-06 17:32:21 +08:00
onClicked: {
2024-03-09 15:35:48 +08:00
showInfo(qsTr("This is an InfoBar in the Info Style"))
2023-04-06 17:32:21 +08:00
}
}
FluButton{
2024-03-09 15:35:48 +08:00
text: qsTr("Warning")
2023-04-06 17:32:21 +08:00
onClicked: {
2024-03-09 15:35:48 +08:00
showWarning(qsTr("This is an InfoBar in the Warning Style"))
2023-04-06 17:32:21 +08:00
}
}
FluButton{
text:"Error"
onClicked: {
2024-03-09 15:35:48 +08:00
showError(qsTr("This is an InfoBar in the Error Style"))
2023-04-06 17:32:21 +08:00
}
}
FluButton{
text:"Success"
onClicked: {
2024-03-09 15:35:48 +08:00
showSuccess(qsTr("This is an InfoBar in the Success Style"))
2023-04-06 17:32:21 +08:00
}
}
2023-09-15 19:11:55 +08:00
FluButton{
2024-03-09 15:35:48 +08:00
text: qsTr("InfoBar that needs to be turned off manually")
2023-09-15 19:11:55 +08:00
onClicked: {
2024-03-15 12:19:38 +08:00
showInfo(qsTr("This is an InfoBar in the Info Style"),0,qsTr("Manual shutdown is supported"))
2023-09-15 19:11:55 +08:00
}
}
FluText{
wrapMode: Text.WrapAnywhere
width: parent.width
text: qsTr("Manually close the info message box")
}
Row{
spacing: 5
FluButton{
text: (info1 ? qsTr("close '%1'") : qsTr("show '%1")).arg("info1")
onClicked: {
if(info1) {
info1.close()
return
}
info1 = showInfo(qsTr("This is an '%1'").arg("info1"), 0)
2024-09-20 13:38:51 +08:00
info1.close()
}
}
FluButton{
text: (info2 ? qsTr("close '%1'") : qsTr("show '%1")).arg("info2")
onClicked: {
if(info2) {
info2.close()
return
}
info2 = showInfo(qsTr("This is an '%1'").arg("info2"), 0)
}
}
FluButton{
text: (info3 ? qsTr("close '%1'") : qsTr("show '%1")).arg("info3")
onClicked: {
if(info3) {
info3.close()
return
}
info3 = showInfo(qsTr("This is an '%1'").arg("info3"), 0)
}
}
FluButton{
text: qsTr("clear all info")
onClicked: {
clearAllInfo()
}
}
}
2023-07-13 10:20:45 +08:00
FluButton{
text:"Loading"
onClicked: {
2024-03-13 17:54:11 +08:00
showLoading()
2023-07-13 10:20:45 +08:00
}
}
2023-03-10 18:08:32 +08:00
}
2023-03-06 18:08:01 +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
code:`
showInfo(qsTr("This is an InfoBar in the Info Style"))
2023-04-06 17:32:21 +08:00
2024-03-09 15:35:48 +08:00
showWarning(qsTr("This is an InfoBar in the Warning Style"))
2023-04-06 17:32:21 +08:00
2024-03-09 15:35:48 +08:00
showError(qsTr("This is an InfoBar in the Error Style"))
2023-04-06 17:32:21 +08:00
showSuccess(qsTr("This is an InfoBar in the Success Style"))
var info1 = showInfo(qsTr("This is an 'Info1'"), 0)
info1.close()
`
2023-02-28 18:29:00 +08:00
}
}