Merge pull request #65 from mentalfl0w/dev

Imporve FluContentDialog and add relative example.
This commit is contained in:
zhuzichu 2023-04-20 18:49:53 +08:00 committed by GitHub
commit 689843fbef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 142 additions and 43 deletions

View File

@ -21,9 +21,9 @@ FluScrollablePage{
FluButton{
anchors.verticalCenter: parent.verticalCenter
Layout.topMargin: 20
text:"Show Dialog"
text:"Show Double Button Dialog"
onClicked: {
dialog.open()
double_btn_dialog.open()
}
}
}
@ -35,6 +35,7 @@ FluScrollablePage{
title:"友情提示"
message:"确定要退出程序么?"
negativeText:"取消"
buttonFlags: FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
onNegativeClicked:{
showSuccess("点击取消按钮")
}
@ -43,14 +44,14 @@ FluScrollablePage{
showSuccess("点击确定按钮")
}
}
dialog.open()
'
dialog.open()'
}
FluContentDialog{
id:dialog
id:double_btn_dialog
title:"友情提示"
message:"确定要退出程序么?"
buttonFlags: FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
negativeText:"取消"
onNegativeClicked:{
showSuccess("点击取消按钮")
@ -61,5 +62,61 @@ dialog.open()
}
}
FluArea{
Layout.fillWidth: true
height: 68
paddings: 10
Layout.topMargin: 20
FluButton{
anchors.verticalCenter: parent.verticalCenter
Layout.topMargin: 20
text:"Show Triple Button Dialog"
onClicked: {
triple_btn_dialog.open()
}
}
}
CodeExpander{
Layout.fillWidth: true
Layout.topMargin: -1
code:'FluContentDialog{
id:dialog
title:"友情提示"
message:"确定要退出程序么?"
negativeText:"取消"
buttonFlags: FluContentDialog.NeutralButton | FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
negativeText:"取消"
onNegativeClicked:{
showSuccess("点击取消按钮")
}
positiveText:"确定"
onPositiveClicked:{
showSuccess("点击确定按钮")
}
neutralText:"最小化"
onNeutralClicked:{
showSuccess("点击最小化按钮")
}
}
dialog.open()'
}
FluContentDialog{
id:triple_btn_dialog
title:"友情提示"
message:"确定要退出程序么?"
buttonFlags: FluContentDialog.NeutralButton | FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
negativeText:"取消"
onNegativeClicked:{
showSuccess("点击取消按钮")
}
positiveText:"确定"
onPositiveClicked:{
showSuccess("点击确定按钮")
}
neutralText:"最小化"
onNeutralClicked:{
showSuccess("点击最小化按钮")
}
}
}

View File

@ -46,6 +46,32 @@ FluWindow {
}
}
FluContentDialog{
id:close_app
title:"退出"
message:"确定要退出程序吗?"
negativeText:"最小化"
buttonFlags: FluContentDialog.NeutralButton | FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
onNegativeClicked:{
showSuccess("最小化成功")
window.hide()
}
positiveText:"退出"
neutralText:"取消"
onPositiveClicked:{
window.destoryWindow()
FluApp.closeApp()
}
}
onClosing:
{
window.show()
window.raise()
window.requestActivate()
close_app.open()
}
FluNavigationView{
id:nav_view

View File

@ -7,11 +7,19 @@ Popup {
id: popup
property string title: "Title"
property string message: "Messaeg"
property string message: "Message"
property string neutralText: "Neutral"
property string negativeText: "Negative"
property string positiveText: "Positive"
signal neutralClicked
signal negativeClicked
signal positiveClicked
enum ButtonFlag{
NegativeButton=1
,NeutralButton=2
,PositiveButton=4
}
property int buttonFlags: FluContentDialog.NegativeButton | FluContentDialog.PositiveButton
property var minWidth: {
if(Window.window==null)
return 400
@ -74,21 +82,31 @@ Popup {
right: parent.right
}
Item {
id:divider
width: 1
height: parent.height
anchors.centerIn: parent
RowLayout{
anchors
{
centerIn: parent
margins: spacing
fill: parent
}
spacing: 15
FluButton{
id:neutral_btn
Layout.fillWidth: true
Layout.fillHeight: true
visible: popup.buttonFlags&FluContentDialog.NeutralButton
text: neutralText
onClicked: {
popup.close()
neutralClicked()
}
}
FluButton{
anchors{
left: parent.left
leftMargin: 20
rightMargin: 10
right: divider.left
verticalCenter: parent.verticalCenter
}
id:negative_btn
Layout.fillWidth: true
Layout.fillHeight: true
visible: popup.buttonFlags&FluContentDialog.NegativeButton
text: negativeText
onClicked: {
popup.close()
@ -97,13 +115,10 @@ Popup {
}
FluFilledButton{
anchors{
right: parent.right
left: divider.right
rightMargin: 20
leftMargin: 10
verticalCenter: parent.verticalCenter
}
id:positive_btn
Layout.fillWidth: true
Layout.fillHeight: true
visible: popup.buttonFlags&FluContentDialog.PositiveButton
text: positiveText
onClicked: {
popup.close()
@ -113,3 +128,4 @@ Popup {
}
}
}
}