update FluContentDialog and FluShortcutPicker

This commit is contained in:
zhuzichu 2023-12-04 17:10:08 +08:00
parent 1a21cd7b31
commit 2428a38194
8 changed files with 572 additions and 231 deletions

View File

@ -151,7 +151,7 @@ FluObject{
onTap:{ navigationView.push(url) }
}
FluPaneItem{
title:"ShortcutPicker(ToDo)"
title:"ShortcutPicker"
menuDelegate: paneItemMenu
url:"qrc:/example/qml/page/T_ShortcutPicker.qml"
onTap:{ navigationView.push(url) }

View File

@ -77,15 +77,23 @@ FluWindow {
}
}
Timer{
id:timer_window_hide_delay
interval: 150
onTriggered: {
window.hide()
}
}
FluContentDialog{
id:dialog_close
title:"退出"
message:"确定要退出程序吗?"
negativeText:"最小化"
buttonFlags: FluContentDialogType.NegativeButton | FluContentDialogType.NeutralButton | FluContentDialogType.PositiveButton
onNegativeClicked:{
window.hide()
onNegativeClicked: {
system_tray.showMessage("友情提示","FluentUI已隐藏至托盘,点击托盘可再次激活窗口");
timer_window_hide_delay.restart()
}
positiveText:"退出"
neutralText:"取消"

View File

@ -151,7 +151,7 @@ FluObject{
onTap:{ navigationView.push(url) }
}
FluPaneItem{
title:"ShortcutPicker(ToDo)"
title:"ShortcutPicker"
menuDelegate: paneItemMenu
url:"qrc:/example/qml/page/T_ShortcutPicker.qml"
onTap:{ navigationView.push(url) }

View File

@ -80,15 +80,23 @@ FluWindow {
}
}
Timer{
id:timer_window_hide_delay
interval: 150
onTriggered: {
window.hide()
}
}
FluContentDialog{
id:dialog_close
title:"退出"
message:"确定要退出程序吗?"
negativeText:"最小化"
buttonFlags: FluContentDialogType.NegativeButton | FluContentDialogType.NeutralButton | FluContentDialogType.PositiveButton
onNegativeClicked:{
window.hide()
onNegativeClicked: {
system_tray.showMessage("友情提示","FluentUI已隐藏至托盘,点击托盘可再次激活窗口");
timer_window_hide_delay.restart()
}
positiveText:"退出"
neutralText:"取消"

View File

@ -5,51 +5,37 @@ import QtQuick.Window 2.15
import FluentUI 1.0
FluPopup {
id: popup
property string title: "Title"
property string message: "Message"
id: control
property string title: ""
property string message: ""
property string neutralText: "Neutral"
property string negativeText: "Negative"
property string positiveText: "Positive"
property alias messageTextFormart: text_message.textFormat
property int messageTextFormart: Text.AutoText
property int delayTime: 100
property int buttonFlags: FluContentDialogType.NegativeButton | FluContentDialogType.PositiveButton
property var contentDelegate: Component{
Item{
}
}
property var onNeutralClickListener
property var onNegativeClickListener
property var onPositiveClickListener
signal neutralClicked
signal negativeClicked
signal positiveClicked
property int buttonFlags: FluContentDialogType.NegativeButton | FluContentDialogType.PositiveButton
focus: true
implicitWidth: 400
implicitHeight: text_title.height + sroll_message.height + layout_actions.height
Rectangle {
id:layout_content
anchors.fill: parent
color: 'transparent'
radius:5
FluText{
id:text_title
font: FluTextStyle.TitleLarge
text:title
topPadding: 20
leftPadding: 20
rightPadding: 20
wrapMode: Text.WrapAnywhere
anchors{
top:parent.top
left: parent.left
right: parent.right
}
}
implicitHeight: layout_content.height
focus: true
Component{
id:com_message
Flickable{
id:sroll_message
contentHeight: text_message.height
contentWidth: width
clip: true
anchors{
top:text_title.bottom
left: parent.left
right: parent.right
}
boundsBehavior:Flickable.StopAtBounds
contentHeight: text_message.height
width: parent.width
height: Math.min(text_message.height,300)
ScrollBar.vertical: FluScrollBar {}
FluText{
@ -58,79 +44,98 @@ FluPopup {
wrapMode: Text.WrapAnywhere
text:message
width: parent.width
topPadding: 14
topPadding: 4
leftPadding: 20
rightPadding: 20
bottomPadding: 14
}
}
Rectangle{
id:layout_actions
height: 60
radius: 5
color: FluTheme.dark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1)
anchors{
top:sroll_message.bottom
left: parent.left
right: parent.right
}
RowLayout{
anchors
{
centerIn: parent
margins: spacing
fill: parent
}
spacing: 15
FluButton{
id:neutral_btn
Layout.fillWidth: true
visible: popup.buttonFlags&FluContentDialogType.NeutralButton
text: neutralText
onClicked: {
popup.close()
timer_delay.targetFlags = FluContentDialogType.NeutralButton
timer_delay.restart()
}
}
FluButton{
id:negative_btn
Layout.fillWidth: true
visible: popup.buttonFlags&FluContentDialogType.NegativeButton
text: negativeText
onClicked: {
popup.close()
timer_delay.targetFlags = FluContentDialogType.NegativeButton
timer_delay.restart()
}
}
FluFilledButton{
id:positive_btn
Layout.fillWidth: true
visible: popup.buttonFlags&FluContentDialogType.PositiveButton
text: positiveText
onClicked: {
popup.close()
timer_delay.targetFlags = FluContentDialogType.PositiveButton
timer_delay.restart()
}
}
bottomPadding: 4
}
}
}
Timer{
property int targetFlags
id:timer_delay
interval: popup.delayTime
onTriggered: {
if(targetFlags === FluContentDialogType.NegativeButton){
negativeClicked()
Rectangle {
id:layout_content
width: parent.width
height: layout_column.childrenRect.height
color: 'transparent'
radius:5
ColumnLayout{
id:layout_column
width: parent.width
FluText{
id:text_title
font: FluTextStyle.Title
text:title
topPadding: 20
leftPadding: 20
rightPadding: 20
wrapMode: Text.WrapAnywhere
}
if(targetFlags === FluContentDialogType.NeutralButton){
neutralClicked()
FluLoader{
sourceComponent: com_message
Layout.fillWidth: true
Layout.preferredHeight: status===Loader.Ready ? item.height : 0
}
if(targetFlags === FluContentDialogType.PositiveButton){
positiveClicked()
FluLoader{
sourceComponent: control.contentDelegate
Layout.fillWidth: true
Layout.preferredHeight: status===Loader.Ready ? item.height : 0
}
Rectangle{
id:layout_actions
Layout.fillWidth: true
Layout.preferredHeight: 60
radius: 5
color: FluTheme.dark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1)
RowLayout{
anchors
{
centerIn: parent
margins: spacing
fill: parent
}
spacing: 15
FluButton{
id:neutral_btn
Layout.fillWidth: true
visible: control.buttonFlags&FluContentDialogType.NeutralButton
text: neutralText
onClicked: {
if(control.onNeutralClickListener){
control.onNeutralClickListener()
}else{
neutralClicked()
control.close()
}
}
}
FluButton{
id:negative_btn
Layout.fillWidth: true
visible: control.buttonFlags&FluContentDialogType.NegativeButton
text: negativeText
onClicked: {
if(control.onNegativeClickListener){
control.onNegativeClickListener()
}else{
negativeClicked()
control.close()
}
}
}
FluFilledButton{
id:positive_btn
Layout.fillWidth: true
visible: control.buttonFlags&FluContentDialogType.PositiveButton
text: positiveText
onClicked: {
if(control.onPositiveClickListener){
control.onPositiveClickListener()
}else{
positiveClicked()
control.close()
}
}
}
}
}
}
}

View File

@ -3,9 +3,115 @@ import QtQuick.Controls 2.15
import FluentUI 1.0
FluIconButton {
id:control
property var current : ["Ctrl","Shift","A"]
property string title: "激活快捷键"
property string message: "按下组合键以更改此快捷键"
property string positiveText: "保存"
property string neutralText: "取消"
property string negativeText: "重置"
signal accepted()
QtObject{
id: d
function keyToString(key_code,shift = true)
{
switch(key_code)
{
case Qt.Key_Period: return ".";
case Qt.Key_Greater: return shift ? ">" : ".";
case Qt.Key_Comma: return ",";
case Qt.Key_Less: return shift ? "<" : ",";
case Qt.Key_Slash: return "/";
case Qt.Key_Question: return shift ? "?" : "/";
case Qt.Key_Semicolon: return ";";
case Qt.Key_Colon: return shift ? ":" : ";";
case Qt.Key_Apostrophe: return "'";
case Qt.Key_QuoteDbl: return shift ? "'" : "\"";
case Qt.Key_QuoteLeft: return "`";
case Qt.Key_AsciiTilde: return shift ? "~" : "`";
case Qt.Key_Minus: return "-";
case Qt.Key_Underscore: return shift ? "_" : "-";
case Qt.Key_Equal: return "=";
case Qt.Key_Plus: return shift ? "+" : "=";
case Qt.Key_BracketLeft: return "[";
case Qt.Key_BraceLeft: return shift ? "{" : "[";
case Qt.Key_BracketRight: return "]";
case Qt.Key_BraceRight: return shift ? "}" : "]";
case Qt.Key_Backslash: return "\\";
case Qt.Key_Bar: return shift ? "|" : "\\";
case Qt.Key_Up: return "Up";
case Qt.Key_Down: return "Down";
case Qt.Key_Right: return "Right";
case Qt.Key_Left: return "Left";
case Qt.Key_Space: return "Space";
case Qt.Key_PageDown: return "PgDown";
case Qt.Key_PageUp: return "PgUp";
case Qt.Key_0: return "0";
case Qt.Key_1: return "1";
case Qt.Key_2: return "2";
case Qt.Key_3: return "3";
case Qt.Key_4: return "4";
case Qt.Key_5: return "5";
case Qt.Key_6: return "6";
case Qt.Key_7: return "7";
case Qt.Key_8: return "8";
case Qt.Key_9: return "9";
case Qt.Key_Exclam: return shift ? "!" : "1";
case Qt.Key_At: return shift ? "@" : "2";
case Qt.Key_NumberSign: return shift ? "#" : "3";
case Qt.Key_Dollar: return shift ? "$" : "4";
case Qt.Key_Percent: return shift ? "%" : "5";
case Qt.Key_AsciiCircum: return shift ? "^" : "6";
case Qt.Key_Ampersand: return shift ? "&" : "7";
case Qt.Key_Asterisk: return shift ? "*" : "8";
case Qt.Key_ParenLeft: return shift ? "(" : "9";
case Qt.Key_ParenRight: return shift ? ")" : "0";
case Qt.Key_A: return "A";
case Qt.Key_B: return "B";
case Qt.Key_C: return "C";
case Qt.Key_D: return "D";
case Qt.Key_E: return "E";
case Qt.Key_F: return "F";
case Qt.Key_G: return "G";
case Qt.Key_H: return "H";
case Qt.Key_I: return "I";
case Qt.Key_J: return "J";
case Qt.Key_K: return "K";
case Qt.Key_L: return "L";
case Qt.Key_M: return "M";
case Qt.Key_N: return "N";
case Qt.Key_O: return "O";
case Qt.Key_P: return "P";
case Qt.Key_Q: return "Q";
case Qt.Key_R: return "R";
case Qt.Key_S: return "S";
case Qt.Key_T: return "T";
case Qt.Key_U: return "U";
case Qt.Key_V: return "V";
case Qt.Key_W: return "W";
case Qt.Key_X: return "X";
case Qt.Key_Y: return "Y";
case Qt.Key_Z: return "Z";
case Qt.Key_F1: return "F1";
case Qt.Key_F2: return "F2";
case Qt.Key_F3: return "F3";
case Qt.Key_F4: return "F4";
case Qt.Key_F5: return "F5";
case Qt.Key_F6: return "F6";
case Qt.Key_F7: return "F7";
case Qt.Key_F8: return "F8";
case Qt.Key_F9: return "F9";
case Qt.Key_F10: return "F10";
case Qt.Key_F11: return "F11";
case Qt.Key_F12: return "F12";
case Qt.Key_Home: return "Home";
case Qt.Key_End: return "End";
case Qt.Key_Insert: return "Insert";
case Qt.Key_Delete: return "Delete";
}
return "";
}
}
background: Rectangle{
border.color: FluTheme.dark ? "#505050" : "#DFDFDF"
border.width: 1
@ -17,7 +123,6 @@ FluIconButton {
visible: control.activeFocus
}
}
component ItemKey:Rectangle{
id:item_key_control
property string text : ""
@ -33,16 +138,15 @@ FluIconButton {
anchors.centerIn: parent
}
}
Row{
id:layout_row
spacing: 5
anchors.centerIn: parent
ItemKey{
text:"Ctrl"
}
ItemKey{
text:"A"
Repeater{
model: control.current
delegate: ItemKey{
text: modelData
}
}
Item{
width: 3
@ -55,16 +159,70 @@ FluIconButton {
verticalCenter: parent.verticalCenter
}
}
}
FluContentDialog{
id:content_dialog
property var keysModel: []
title: control.title
message: control.message
buttonFlags: FluContentDialogType.NegativeButton | FluContentDialogType.PositiveButton | FluContentDialogType.NeutralButton
positiveText: control.positiveText
neutralText: control.neutralText
negativeText: control.negativeText
onVisibleChanged: {
content_dialog.keysModel = control.current
}
onPositiveClicked: {
control.current = content_dialog.keysModel
control.accepted()
}
onNegativeClicked: {
content_dialog.keysModel = control.current
}
contentDelegate: Component{
Item{
width: parent.width
height: 100
Component.onCompleted: {
forceActiveFocus()
}
Keys.enabled: true
Keys.onPressed: {
var keyNames = []
if (event.modifiers & Qt.AltModifier) {
keyNames.push("Alt")
}
if (event.modifiers & Qt.ControlModifier) {
keyNames.push("Ctrl")
}
if (event.modifiers & Qt.ShiftModifier) {
keyNames.push("Shift")
}
var keyName = d.keyToString(event.key,false)
if(keyName!==""){
keyNames.push(keyName)
content_dialog.keysModel = keyNames
}
event.accepted = true
}
Keys.onTabPressed:
(event)=>{
event.accepted = true
}
Row{
spacing: 5
anchors.centerIn: parent
Repeater{
model: content_dialog.keysModel
delegate: ItemKey{
text: modelData
}
}
}
}
}
}
onClicked: {
content_dialog.open()
}
}

View File

@ -5,51 +5,37 @@ import QtQuick.Window
import FluentUI
FluPopup {
id: popup
property string title: "Title"
property string message: "Message"
id: control
property string title: ""
property string message: ""
property string neutralText: "Neutral"
property string negativeText: "Negative"
property string positiveText: "Positive"
property alias messageTextFormart: text_message.textFormat
property int messageTextFormart: Text.AutoText
property int delayTime: 100
property int buttonFlags: FluContentDialogType.NegativeButton | FluContentDialogType.PositiveButton
property var contentDelegate: Component{
Item{
}
}
property var onNeutralClickListener
property var onNegativeClickListener
property var onPositiveClickListener
signal neutralClicked
signal negativeClicked
signal positiveClicked
property int buttonFlags: FluContentDialogType.NegativeButton | FluContentDialogType.PositiveButton
focus: true
implicitWidth: 400
implicitHeight: text_title.height + sroll_message.height + layout_actions.height
Rectangle {
id:layout_content
anchors.fill: parent
color: 'transparent'
radius:5
FluText{
id:text_title
font: FluTextStyle.TitleLarge
text:title
topPadding: 20
leftPadding: 20
rightPadding: 20
wrapMode: Text.WrapAnywhere
anchors{
top:parent.top
left: parent.left
right: parent.right
}
}
implicitHeight: layout_content.height
focus: true
Component{
id:com_message
Flickable{
id:sroll_message
contentHeight: text_message.height
contentWidth: width
clip: true
anchors{
top:text_title.bottom
left: parent.left
right: parent.right
}
boundsBehavior:Flickable.StopAtBounds
contentHeight: text_message.height
width: parent.width
height: Math.min(text_message.height,300)
ScrollBar.vertical: FluScrollBar {}
FluText{
@ -58,79 +44,98 @@ FluPopup {
wrapMode: Text.WrapAnywhere
text:message
width: parent.width
topPadding: 14
topPadding: 4
leftPadding: 20
rightPadding: 20
bottomPadding: 14
}
}
Rectangle{
id:layout_actions
height: 60
radius: 5
color: FluTheme.dark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1)
anchors{
top:sroll_message.bottom
left: parent.left
right: parent.right
}
RowLayout{
anchors
{
centerIn: parent
margins: spacing
fill: parent
}
spacing: 15
FluButton{
id:neutral_btn
Layout.fillWidth: true
visible: popup.buttonFlags&FluContentDialogType.NeutralButton
text: neutralText
onClicked: {
popup.close()
timer_delay.targetFlags = FluContentDialogType.NeutralButton
timer_delay.restart()
}
}
FluButton{
id:negative_btn
Layout.fillWidth: true
visible: popup.buttonFlags&FluContentDialogType.NegativeButton
text: negativeText
onClicked: {
popup.close()
timer_delay.targetFlags = FluContentDialogType.NegativeButton
timer_delay.restart()
}
}
FluFilledButton{
id:positive_btn
Layout.fillWidth: true
visible: popup.buttonFlags&FluContentDialogType.PositiveButton
text: positiveText
onClicked: {
popup.close()
timer_delay.targetFlags = FluContentDialogType.PositiveButton
timer_delay.restart()
}
}
bottomPadding: 4
}
}
}
Timer{
property int targetFlags
id:timer_delay
interval: popup.delayTime
onTriggered: {
if(targetFlags === FluContentDialogType.NegativeButton){
negativeClicked()
Rectangle {
id:layout_content
width: parent.width
height: layout_column.childrenRect.height
color: 'transparent'
radius:5
ColumnLayout{
id:layout_column
width: parent.width
FluText{
id:text_title
font: FluTextStyle.Title
text:title
topPadding: 20
leftPadding: 20
rightPadding: 20
wrapMode: Text.WrapAnywhere
}
if(targetFlags === FluContentDialogType.NeutralButton){
neutralClicked()
FluLoader{
sourceComponent: com_message
Layout.fillWidth: true
Layout.preferredHeight: status===Loader.Ready ? item.height : 0
}
if(targetFlags === FluContentDialogType.PositiveButton){
positiveClicked()
FluLoader{
sourceComponent: control.contentDelegate
Layout.fillWidth: true
Layout.preferredHeight: status===Loader.Ready ? item.height : 0
}
Rectangle{
id:layout_actions
Layout.fillWidth: true
Layout.preferredHeight: 60
radius: 5
color: FluTheme.dark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1)
RowLayout{
anchors
{
centerIn: parent
margins: spacing
fill: parent
}
spacing: 15
FluButton{
id:neutral_btn
Layout.fillWidth: true
visible: control.buttonFlags&FluContentDialogType.NeutralButton
text: neutralText
onClicked: {
if(control.onNeutralClickListener){
control.onNeutralClickListener()
}else{
neutralClicked()
control.close()
}
}
}
FluButton{
id:negative_btn
Layout.fillWidth: true
visible: control.buttonFlags&FluContentDialogType.NegativeButton
text: negativeText
onClicked: {
if(control.onNegativeClickListener){
control.onNegativeClickListener()
}else{
negativeClicked()
control.close()
}
}
}
FluFilledButton{
id:positive_btn
Layout.fillWidth: true
visible: control.buttonFlags&FluContentDialogType.PositiveButton
text: positiveText
onClicked: {
if(control.onPositiveClickListener){
control.onPositiveClickListener()
}else{
positiveClicked()
control.close()
}
}
}
}
}
}
}

View File

@ -3,9 +3,115 @@ import QtQuick.Controls
import FluentUI
FluIconButton {
id:control
property var current : ["Ctrl","Shift","A"]
property string title: "激活快捷键"
property string message: "按下组合键以更改此快捷键"
property string positiveText: "保存"
property string neutralText: "取消"
property string negativeText: "重置"
signal accepted()
QtObject{
id: d
function keyToString(key_code,shift = true)
{
switch(key_code)
{
case Qt.Key_Period: return ".";
case Qt.Key_Greater: return shift ? ">" : ".";
case Qt.Key_Comma: return ",";
case Qt.Key_Less: return shift ? "<" : ",";
case Qt.Key_Slash: return "/";
case Qt.Key_Question: return shift ? "?" : "/";
case Qt.Key_Semicolon: return ";";
case Qt.Key_Colon: return shift ? ":" : ";";
case Qt.Key_Apostrophe: return "'";
case Qt.Key_QuoteDbl: return shift ? "'" : "\"";
case Qt.Key_QuoteLeft: return "`";
case Qt.Key_AsciiTilde: return shift ? "~" : "`";
case Qt.Key_Minus: return "-";
case Qt.Key_Underscore: return shift ? "_" : "-";
case Qt.Key_Equal: return "=";
case Qt.Key_Plus: return shift ? "+" : "=";
case Qt.Key_BracketLeft: return "[";
case Qt.Key_BraceLeft: return shift ? "{" : "[";
case Qt.Key_BracketRight: return "]";
case Qt.Key_BraceRight: return shift ? "}" : "]";
case Qt.Key_Backslash: return "\\";
case Qt.Key_Bar: return shift ? "|" : "\\";
case Qt.Key_Up: return "Up";
case Qt.Key_Down: return "Down";
case Qt.Key_Right: return "Right";
case Qt.Key_Left: return "Left";
case Qt.Key_Space: return "Space";
case Qt.Key_PageDown: return "PgDown";
case Qt.Key_PageUp: return "PgUp";
case Qt.Key_0: return "0";
case Qt.Key_1: return "1";
case Qt.Key_2: return "2";
case Qt.Key_3: return "3";
case Qt.Key_4: return "4";
case Qt.Key_5: return "5";
case Qt.Key_6: return "6";
case Qt.Key_7: return "7";
case Qt.Key_8: return "8";
case Qt.Key_9: return "9";
case Qt.Key_Exclam: return shift ? "!" : "1";
case Qt.Key_At: return shift ? "@" : "2";
case Qt.Key_NumberSign: return shift ? "#" : "3";
case Qt.Key_Dollar: return shift ? "$" : "4";
case Qt.Key_Percent: return shift ? "%" : "5";
case Qt.Key_AsciiCircum: return shift ? "^" : "6";
case Qt.Key_Ampersand: return shift ? "&" : "7";
case Qt.Key_Asterisk: return shift ? "*" : "8";
case Qt.Key_ParenLeft: return shift ? "(" : "9";
case Qt.Key_ParenRight: return shift ? ")" : "0";
case Qt.Key_A: return "A";
case Qt.Key_B: return "B";
case Qt.Key_C: return "C";
case Qt.Key_D: return "D";
case Qt.Key_E: return "E";
case Qt.Key_F: return "F";
case Qt.Key_G: return "G";
case Qt.Key_H: return "H";
case Qt.Key_I: return "I";
case Qt.Key_J: return "J";
case Qt.Key_K: return "K";
case Qt.Key_L: return "L";
case Qt.Key_M: return "M";
case Qt.Key_N: return "N";
case Qt.Key_O: return "O";
case Qt.Key_P: return "P";
case Qt.Key_Q: return "Q";
case Qt.Key_R: return "R";
case Qt.Key_S: return "S";
case Qt.Key_T: return "T";
case Qt.Key_U: return "U";
case Qt.Key_V: return "V";
case Qt.Key_W: return "W";
case Qt.Key_X: return "X";
case Qt.Key_Y: return "Y";
case Qt.Key_Z: return "Z";
case Qt.Key_F1: return "F1";
case Qt.Key_F2: return "F2";
case Qt.Key_F3: return "F3";
case Qt.Key_F4: return "F4";
case Qt.Key_F5: return "F5";
case Qt.Key_F6: return "F6";
case Qt.Key_F7: return "F7";
case Qt.Key_F8: return "F8";
case Qt.Key_F9: return "F9";
case Qt.Key_F10: return "F10";
case Qt.Key_F11: return "F11";
case Qt.Key_F12: return "F12";
case Qt.Key_Home: return "Home";
case Qt.Key_End: return "End";
case Qt.Key_Insert: return "Insert";
case Qt.Key_Delete: return "Delete";
}
return "";
}
}
background: Rectangle{
border.color: FluTheme.dark ? "#505050" : "#DFDFDF"
border.width: 1
@ -17,7 +123,6 @@ FluIconButton {
visible: control.activeFocus
}
}
component ItemKey:Rectangle{
id:item_key_control
property string text : ""
@ -33,16 +138,15 @@ FluIconButton {
anchors.centerIn: parent
}
}
Row{
id:layout_row
spacing: 5
anchors.centerIn: parent
ItemKey{
text:"Ctrl"
}
ItemKey{
text:"A"
Repeater{
model: control.current
delegate: ItemKey{
text: modelData
}
}
Item{
width: 3
@ -55,17 +159,70 @@ FluIconButton {
verticalCenter: parent.verticalCenter
}
}
}
FluContentDialog{
id:content_dialog
property var keysModel: []
title: control.title
message: control.message
buttonFlags: FluContentDialogType.NegativeButton | FluContentDialogType.PositiveButton | FluContentDialogType.NeutralButton
positiveText: control.positiveText
neutralText: control.neutralText
negativeText: control.negativeText
onVisibleChanged: {
content_dialog.keysModel = control.current
}
onPositiveClicked: {
control.current = content_dialog.keysModel
control.accepted()
}
onNegativeClicked: {
content_dialog.keysModel = control.current
}
contentDelegate: Component{
Item{
width: parent.width
height: 100
Component.onCompleted: {
forceActiveFocus()
}
Keys.enabled: true
Keys.onPressed: {
var keyNames = []
if (event.modifiers & Qt.AltModifier) {
keyNames.push("Alt")
}
if (event.modifiers & Qt.ControlModifier) {
keyNames.push("Ctrl")
}
if (event.modifiers & Qt.ShiftModifier) {
keyNames.push("Shift")
}
var keyName = d.keyToString(event.key,false)
if(keyName!==""){
keyNames.push(keyName)
content_dialog.keysModel = keyNames
}
event.accepted = true
}
Keys.onTabPressed:
(event)=>{
event.accepted = true
}
Row{
spacing: 5
anchors.centerIn: parent
Repeater{
model: content_dialog.keysModel
delegate: ItemKey{
text: modelData
}
}
}
}
}
}
onClicked: {
content_dialog.open()
}
}