From efcf2c3f220e74c4f7a77b833e7ea9d11d114196 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Tue, 14 Jun 2022 10:48:11 +0200 Subject: [PATCH] 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). --- .../modules/Common/Dialog/ConfirmDialog.qml | 41 +++++++++++-------- .../ui/modules/Common/Form/ActionButton.qml | 29 +++++++++++-- .../Linphone/TelKeypad/TelKeypadButton.qml | 24 +++++------ .../ui/views/App/Main/Conversation.qml | 18 +++++++- 4 files changed, 77 insertions(+), 35 deletions(-) diff --git a/linphone-app/ui/modules/Common/Dialog/ConfirmDialog.qml b/linphone-app/ui/modules/Common/Dialog/ConfirmDialog.qml index 35a38f0c9..f6e7b3a80 100644 --- a/linphone-app/ui/modules/Common/Dialog/ConfirmDialog.qml +++ b/linphone-app/ui/modules/Common/Dialog/ConfirmDialog.qml @@ -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 } diff --git a/linphone-app/ui/modules/Common/Form/ActionButton.qml b/linphone-app/ui/modules/Common/Form/ActionButton.qml index 85cb2482f..ca8914fcc 100644 --- a/linphone-app/ui/modules/Common/Form/ActionButton.qml +++ b/linphone-app/ui/modules/Common/Form/ActionButton.qml @@ -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 diff --git a/linphone-app/ui/modules/Linphone/TelKeypad/TelKeypadButton.qml b/linphone-app/ui/modules/Linphone/TelKeypad/TelKeypadButton.qml index 2dac83638..3dd2ddd4e 100644 --- a/linphone-app/ui/modules/Linphone/TelKeypad/TelKeypadButton.qml +++ b/linphone-app/ui/modules/Linphone/TelKeypad/TelKeypadButton.qml @@ -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 { diff --git a/linphone-app/ui/views/App/Main/Conversation.qml b/linphone-app/ui/views/App/Main/Conversation.qml index f1c1c7b80..2b1e90f4e 100644 --- a/linphone-app/ui/views/App/Main/Conversation.qml +++ b/linphone-app/ui/views/App/Main/Conversation.qml @@ -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 + }) + } + } } }