Customizable confirm dialog.

Long pressed event feature on action buttons (default to 500ms).
ChatRoom peer/local addresses debug in conversations (long pressed on dots menu with debug traces enabled).
This commit is contained in:
Julien Wadel 2022-06-14 10:48:11 +02:00
parent f0c6c2e079
commit efcf2c3f22
4 changed files with 77 additions and 35 deletions

View file

@ -1,26 +1,33 @@
import QtQuick.Layouts 1.3
import Common 1.0
import Common.Styles 1.0
// =============================================================================
// A dialog with OK/Cancel buttons.
// =============================================================================
DialogPlus {
buttons: [
TextButtonA {
text: qsTr('cancel')
onClicked: exit(0)
},
TextButtonB {
text: qsTr('confirm')
onClicked: exit(1)
}
]
buttonsAlignment: Qt.AlignCenter
height: DialogStyle.confirmDialog.height + 30
width: DialogStyle.confirmDialog.width
id: mainItem
property int showButtonOnly : -1
property var buttonTexts : [qsTr('cancel')
, qsTr('confirm')]
buttons: [
TextButtonA {
text: mainItem.buttonTexts[0]
visible: mainItem.showButtonOnly<0 || mainItem.showButtonOnly == 0
onClicked: exit(0)
},
TextButtonB {
text: mainItem.buttonTexts[1]
visible: mainItem.showButtonOnly<0 || mainItem.showButtonOnly == 1
onClicked: exit(1)
}
]
buttonsAlignment: Qt.AlignCenter
height: DialogStyle.confirmDialog.height + 30
width: DialogStyle.confirmDialog.width
}

View file

@ -44,6 +44,8 @@ Item {
property int iconWidth: colorSet.iconWidth ? colorSet.iconWidth : 0
readonly property alias hovered: button.hovered
property alias text: button.text
property alias longPressedTimeout: longPressedTimeout.interval // default: 500ms
// Tooltip aliases
property alias tooltipText : tooltip.text
property alias tooltipIsClickable : tooltip.isClickable
@ -83,7 +85,7 @@ Item {
signal clicked(real x, real y)
signal pressed(real x, real y)
signal released(real x, real y)
signal longPressed()
// ---------------------------------------------------------------------------
function _getIcon () {
@ -193,6 +195,7 @@ Item {
height: fitHeight
width: fitWidth
Button {
id: button
@ -213,9 +216,27 @@ Item {
}
}
hoverEnabled: !wrappedButton.updating//|| wrappedButton.autoIcon
onClicked: !wrappedButton.updating && wrappedButton.enabled && wrappedButton.clicked(pressX, pressY)
onPressed: !wrappedButton.updating && wrappedButton.enabled && wrappedButton.pressed(pressX, pressY)
onReleased: !wrappedButton.updating && wrappedButton.enabled && wrappedButton.released(pressX, pressY)
onClicked: {
longPressedTimeout.stop()
if(!wrappedButton.updating && wrappedButton.enabled) wrappedButton.clicked(pressX, pressY)
}
onPressed: if(!wrappedButton.updating && wrappedButton.enabled){
longPressedTimeout.restart()
wrappedButton.pressed(pressX, pressY)
}
onReleased: {
longPressedTimeout.stop()
if(!wrappedButton.updating && wrappedButton.enabled)
wrappedButton.released(pressX, pressY)
}
onHoveredChanged: if(!hovered) longPressedTimeout.stop()
Timer{
id: longPressedTimeout
interval: 500
repeat: false
onTriggered: if(!wrappedButton.updating && wrappedButton.enabled) wrappedButton.longPressed()
}
Rectangle{
id: foregroundColor

View file

@ -37,10 +37,17 @@ Item {
backgroundRadius: width/2
isCustom: true
property bool doNotSend: false
Timer{
id: longPress
interval: 500
onTriggered: { if(actionButton.doNotSend){
onPressed: {actionButton.doNotSend = false}
onReleased: { if(actionButton.doNotSend)
actionButton.doNotSend = false
else {
actionButton.doNotSend = true;
button.sendDtmf(button.text)
}
}
onLongPressed:{
if(actionButton.doNotSend){
actionButton.doNotSend = false
}else{
if( button.auxSymbol != '' && actionButton.hovered) {
@ -48,15 +55,6 @@ Item {
button.sendDtmf(button.auxSymbol)
}
}
}
}
onPressed: {actionButton.doNotSend = false;longPress.start()}
onReleased: { if(actionButton.doNotSend)
actionButton.doNotSend = false
else {
actionButton.doNotSend = true;
button.sendDtmf(button.text)
}
}
ColumnLayout {

View file

@ -1,6 +1,7 @@
import QtQuick 2.7
import QtQuick.Layouts 1.3
import Clipboard 1.0
import Common 1.0
import Linphone 1.0
import Utils 1.0
@ -337,7 +338,7 @@ ColumnLayout {
colorSet: ConversationStyle.bar.actions.openMenu
visible: true //conversationMenu.showGroupInfo || conversationMenu.showDevices || conversationMenu.showEphemerals
toggled: conversationMenu.opened
longPressedTimeout: 3000
onPressed: {// Bug : Not working : Menu is still closed before pressing on button (even with closePolicy)
if( conversationMenu.opened ) {
conversationMenu.close()
@ -345,6 +346,21 @@ ColumnLayout {
conversationMenu.open()
}
}
property string debugData: 'Chat room ID:\n'+chatRoomModel.getFullPeerAddress()
+'\nLocal account:\n'+chatRoomModel.getFullLocalAddress()
onLongPressed:{
if( SettingsModel.logsEnabled){
conversationMenu.close()
window.attachVirtualWindow(Utils.buildCommonDialogUri('ConfirmDialog'), {
descriptionText: debugData,
showButtonOnly: 1,
buttonTexts: ['', 'COPY'],
height:320,
}, function (status) {
Clipboard.text = debugData
})
}
}
}
}