From 23413a8f4563ab2f75c65030f6ef7baa75d6816a Mon Sep 17 00:00:00 2001 From: cberthet <capucine.berthet@savoirfairelinux.com> Date: Tue, 7 Nov 2023 11:29:49 -0500 Subject: [PATCH] BaseModalDialog: redesign popups and add standard buttons GitLab: #1417 Change-Id: I8693ff36d313c730b6d8fa2ea7586d1a71d582d7 --- src/app/MainApplicationWindow.qml | 6 +- src/app/commoncomponents/BaseModalDialog.qml | 107 +++++++++--- .../commoncomponents/ChangePttKeyPopup.qml | 45 ++--- src/app/commoncomponents/ConfirmDialog.qml | 59 ++----- .../commoncomponents/DaemonReconnectPopup.qml | 28 +-- .../commoncomponents/DeleteAccountDialog.qml | 96 +++-------- src/app/commoncomponents/EditedPopup.qml | 9 +- src/app/commoncomponents/PasswordDialog.qml | 42 ++--- .../commoncomponents/SimpleMessageDialog.qml | 98 +++++------ src/app/constant/JamiStrings.qml | 5 +- src/app/constant/JamiTheme.qml | 2 + .../mainview/components/DevicesListPopup.qml | 111 +++++------- src/app/mainview/components/HostPopup.qml | 76 ++++----- .../components/WelcomePageQrDialog.qml | 13 +- src/app/qmlregister.cpp | 2 +- src/app/qmlregister.h | 2 +- .../components/InstallManuallyView.qml | 3 +- .../components/LinkedDevicesBase.qml | 3 +- .../components/ManageAccountPage.qml | 3 +- .../components/NameRegistrationDialog.qml | 84 ++------- .../components/PluginAvailableDelegate.qml | 3 +- .../components/PluginPreferencesListView.qml | 3 +- .../components/PluginPreferencesView.qml | 3 +- .../components/RevokeDevicePasswordDialog.qml | 65 ++----- .../components/UpdateDownloadDialog.qml | 6 + .../map/StopSharingPositionPopup.qml | 160 ++---------------- .../wizardview/components/NoUsernamePopup.qml | 152 ++--------------- tests/qml/main.cpp | 2 +- 28 files changed, 378 insertions(+), 810 deletions(-) diff --git a/src/app/MainApplicationWindow.qml b/src/app/MainApplicationWindow.qml index 55776ccac..76e4e1905 100644 --- a/src/app/MainApplicationWindow.qml +++ b/src/app/MainApplicationWindow.qml @@ -273,7 +273,8 @@ ApplicationWindow { "infoText": infoText, "buttonTitles": [JamiStrings.optionOk], "buttonStyles": [SimpleMessageDialog.ButtonStyle.TintedBlue], - "buttonCallBacks": [] + "buttonCallBacks": [], + "buttonRoles": [DialogButtonBox.AcceptRole] }); } @@ -285,7 +286,8 @@ ApplicationWindow { "buttonStyles": [SimpleMessageDialog.ButtonStyle.TintedBlue, SimpleMessageDialog.ButtonStyle.TintedBlue], "buttonCallBacks": [function () { AppVersionManager.applyUpdates(switchToBeta); - }] + }], + "buttonRoles": [DialogButtonBox.AcceptRole, DialogButtonBox.RejectRole] }); } diff --git a/src/app/commoncomponents/BaseModalDialog.qml b/src/app/commoncomponents/BaseModalDialog.qml index 4259c68f0..60d7dc784 100644 --- a/src/app/commoncomponents/BaseModalDialog.qml +++ b/src/app/commoncomponents/BaseModalDialog.qml @@ -30,15 +30,24 @@ Popup { property alias backgroundColor: container.color property alias title: titleText.text property var popupcontainerSubContentLoader: containerSubContentLoader - property bool topLayoutVisible: true + + property bool closeButtonVisible: true + property int button1Role + property int button2Role + + property alias button1: action1 + property alias button2: action2 + property alias popupContentLoadStatus: containerSubContentLoader.status property alias popupContent: containerSubContentLoader.sourceComponent - property int popupContentMargins: JamiTheme.preferredMarginSize + + property int popupMargins: 30 + property int buttonMargin: 20 + property int maximumPopupWidth: 600 parent: Overlay.overlay anchors.centerIn: parent modal: true - padding: popupContentMargins focus: true closePolicy: autoClose ? (Popup.CloseOnEscape | Popup.CloseOnPressOutside) : Popup.NoAutoClose @@ -47,13 +56,13 @@ Popup { id: container property color color: JamiTheme.secondaryBackgroundColor - padding: popupContentMargins - anchors.margins: popupContentMargins anchors.centerIn: parent + leftPadding: popupMargins + bottomPadding: action1.visible || action2.visible ? 10 :popupMargins background: Rectangle { id: bgRect - radius: JamiTheme.modalPopupRadius + radius: 5 color: container.color layer.enabled: true layer.effect: DropShadow { @@ -70,37 +79,85 @@ Popup { contentItem: ColumnLayout { id: contentLayout - RowLayout { - Layout.preferredWidth: parent.width - Layout.bottomMargin: JamiTheme.preferredMarginSize - visible: topLayoutVisible + JamiPushButton { + id: closeButton - Label { - id: titleText + visible: closeButtonVisible - Layout.alignment: Qt.AlignTop | Qt.AlignLeft - font.pointSize: JamiTheme.menuFontSize - color: JamiTheme.textColor + Layout.alignment: Qt.AlignRight | Qt.AlignTop + Layout.preferredHeight: 20 + Layout.preferredWidth: 20 + Layout.topMargin: 5 + Layout.rightMargin: 5 + imageColor: hovered ? JamiTheme.textColor : JamiTheme.buttonTintedGreyHovered + normalColor: "transparent" - visible: text.length > 0 - } + source: JamiResources.round_close_24dp_svg + onClicked: close() + } - JamiPushButton { - id: closeButton - Layout.alignment: Qt.AlignRight - imageColor: "grey" - normalColor: "transparent" + Label { + id: titleText - source: JamiResources.round_close_24dp_svg - onClicked: close() - } + Layout.rightMargin: popupMargins + Layout.bottomMargin: 20 + Layout.topMargin: closeButtonVisible ? 0 : 30 + Layout.alignment: Qt.AlignLeft + + font.pointSize: JamiTheme.menuFontSize + color: JamiTheme.textColor + font.bold: true + + visible: text.length > 0 } Loader { id: containerSubContentLoader + Layout.rightMargin: popupMargins Layout.alignment: Qt.AlignCenter + Layout.maximumWidth: maximumPopupWidth - 2 * popupMargins + } + + DialogButtonBox { + id: buttonBox + Layout.alignment: Qt.AlignRight + spacing: 1.5 + + background: Rectangle { + + color: "transparent" + width: buttonBox.childrenRect.width + height: buttonBox.childrenRect.height + } + + visible: action1.text.length > 0 + contentHeight: childrenRect.height + 14 + + MaterialButton { + id: action1 + + visible: text.length > 0 + rightPadding: buttonMargin + leftPadding: buttonMargin + tertiary: true + autoAccelerator: true + + DialogButtonBox.buttonRole: root.button1Role + } + + MaterialButton { + id: action2 + + visible: text.length > 0 + rightPadding: buttonMargin + leftPadding: buttonMargin + tertiary: true + autoAccelerator: true + + DialogButtonBox.buttonRole: root.button2Role + } } } } diff --git a/src/app/commoncomponents/ChangePttKeyPopup.qml b/src/app/commoncomponents/ChangePttKeyPopup.qml index b785e6af0..c5b29e057 100644 --- a/src/app/commoncomponents/ChangePttKeyPopup.qml +++ b/src/app/commoncomponents/ChangePttKeyPopup.qml @@ -28,6 +28,22 @@ BaseModalDialog { property string accountId: "" property int pressedKey: Qt.Key_unknown + closeButtonVisible: false + + button1.text: JamiStrings.assign + button2.text: JamiStrings.cancel + + button1Role: DialogButtonBox.ApplyRole + button2Role: DialogButtonBox.RejectRole + button1.onClicked: { + if (!(pressedKey === Qt.Key_unknown)){ + PttListener.setPttKey(pressedKey); + choiceMade(pressedKey); + } + close(); + } + button2.onClicked: close(); + signal accepted signal choiceMade(int chosenKey) @@ -80,33 +96,6 @@ BaseModalDialog { border.color: JamiTheme.darkGreyColor radius: 4 } - - } - - MaterialButton { - id: btnAssign - - Layout.alignment: Qt.AlignHCenter - Layout.topMargin: JamiTheme.preferredMarginSize - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - buttontextHeightMargin: JamiTheme.buttontextHeightMargin - - color: JamiTheme.buttonTintedBlack - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - secondary: true - - text: JamiStrings.assign - autoAccelerator: true - - onClicked: { - if (!(pressedKey === Qt.Key_unknown)){ - PttListener.setPttKey(pressedKey); - choiceMade(pressedKey); - } - close(); - } } Item { @@ -118,6 +107,4 @@ BaseModalDialog { } } } - - } diff --git a/src/app/commoncomponents/ConfirmDialog.qml b/src/app/commoncomponents/ConfirmDialog.qml index fb3c5942b..ea6b38f01 100644 --- a/src/app/commoncomponents/ConfirmDialog.qml +++ b/src/app/commoncomponents/ConfirmDialog.qml @@ -30,6 +30,19 @@ BaseModalDialog { property string confirmLabel: "" property string textLabel: "" + closeButtonVisible: false + button1.text: confirmLabel + button1.contentColorProvider: JamiTheme.redButtonColor + button1.onClicked: { + close(); + accepted(); + } + button2.text: JamiStrings.optionCancel + button2.onClicked: close() + + button1Role: DialogButtonBox.AcceptRole + button2Role: DialogButtonBox.RejectRole + popupContent: ColumnLayout { id: column @@ -49,51 +62,5 @@ BaseModalDialog { verticalAlignment: Text.AlignVCenter wrapMode: Text.Wrap } - - RowLayout { - spacing: 16 - Layout.alignment: Qt.AlignCenter - Layout.topMargin: JamiTheme.preferredMarginSize - - MaterialButton { - id: primaryBtn - - Layout.alignment: Qt.AlignHCenter - text: root.confirmLabel - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - buttontextHeightMargin: JamiTheme.buttontextHeightMargin - - color: JamiTheme.buttonTintedRed - hoveredColor: JamiTheme.buttonTintedRedHovered - pressedColor: JamiTheme.buttonTintedRedPressed - secondary: true - autoAccelerator: true - - onClicked: { - close(); - accepted(); - } - } - - MaterialButton { - id: btnCancel - - Layout.alignment: Qt.AlignHCenter - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - buttontextHeightMargin: JamiTheme.buttontextHeightMargin - - color: JamiTheme.buttonTintedBlack - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - secondary: true - autoAccelerator: true - - text: JamiStrings.optionCancel - - onClicked: close() - } - } } } diff --git a/src/app/commoncomponents/DaemonReconnectPopup.qml b/src/app/commoncomponents/DaemonReconnectPopup.qml index 6cf50caf5..7172defb6 100644 --- a/src/app/commoncomponents/DaemonReconnectPopup.qml +++ b/src/app/commoncomponents/DaemonReconnectPopup.qml @@ -29,6 +29,11 @@ BaseModalDialog { autoClose: false + button1.text: JamiStrings.optionOk + button1Role: DialogButtonBox.AcceptRole + button1.visible: connectionFailed + button1.onClicked: Qt.quit() + Connections { target: { if (Qt.platform.os.toString() !== "windows" && Qt.platform.os.toString() !== "osx") @@ -51,10 +56,10 @@ BaseModalDialog { onPopupContentLoadStatusChanged: { if (popupContentLoadStatus === Loader.Ready) { root.height = Qt.binding(function () { - return popupContentLoader.item.implicitHeight + 50; + return popupContent.implicitHeight + 50; }); root.width = Qt.binding(function () { - return popupContentLoader.item.implicitWidth + 50; + return popupContent.implicitWidth + 50; }); } } @@ -94,24 +99,5 @@ BaseModalDialog { smooth: true fillMode: Image.PreserveAspectFit } - - MaterialButton { - id: btnOk - - Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - - visible: connectionFailed - - text: JamiStrings.optionOk - color: JamiTheme.buttonTintedBlue - hoveredColor: JamiTheme.buttonTintedBlueHovered - pressedColor: JamiTheme.buttonTintedBluePressed - secondary: true - autoAccelerator: true - - onClicked: Qt.quit() - } } } diff --git a/src/app/commoncomponents/DeleteAccountDialog.qml b/src/app/commoncomponents/DeleteAccountDialog.qml index 7d508a571..8dedfbe42 100644 --- a/src/app/commoncomponents/DeleteAccountDialog.qml +++ b/src/app/commoncomponents/DeleteAccountDialog.qml @@ -33,6 +33,31 @@ BaseModalDialog { title: JamiStrings.deleteAccount + closeButtonVisible: false + button1.text: JamiStrings.optionDelete + button1Role: DialogButtonBox.DestructiveRole + button1.onClicked: { + button1.enabled = false; + busyInd.running = true; + AccountAdapter.deleteCurrentAccount(); + close(); + accepted(); + } + button2.text: JamiStrings.optionCancel + button2Role: DialogButtonBox.RejectRole + button2.onClicked: close(); + + BusyIndicator { + id: busyInd + running: false + Connections { + target: root + function onClosed() { + busyInd.running = false; + } + } + } + popupContent: ColumnLayout { id: deleteAccountContentColumnLayout anchors.centerIn: parent @@ -101,76 +126,5 @@ BaseModalDialog { color: JamiTheme.redColor } - - RowLayout { - spacing: 16 - Layout.fillWidth: true - Layout.alignment: Qt.AlignCenter - - MaterialButton { - id: btnDelete - - Layout.alignment: Qt.AlignHCenter - Layout.topMargin: JamiTheme.preferredMarginSize - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - buttontextHeightMargin: JamiTheme.buttontextHeightMargin - - color: JamiTheme.buttonTintedRed - hoveredColor: JamiTheme.buttonTintedRedHovered - pressedColor: JamiTheme.buttonTintedRedPressed - secondary: true - autoAccelerator: true - - text: JamiStrings.optionDelete - - Connections { - target: root - function onClosed() { - btnDelete.enabled = true; - } - } - - onClicked: { - btnDelete.enabled = false; - busyInd.running = true; - AccountAdapter.deleteCurrentAccount(); - close(); - accepted(); - } - } - - BusyIndicator { - id: busyInd - running: false - - Connections { - target: root - function onClosed() { - busyInd.running = false; - } - } - } - - MaterialButton { - id: btnCancel - - Layout.alignment: Qt.AlignHCenter - Layout.topMargin: JamiTheme.preferredMarginSize - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - buttontextHeightMargin: JamiTheme.buttontextHeightMargin - - color: JamiTheme.buttonTintedBlack - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - secondary: true - - text: JamiStrings.optionCancel - autoAccelerator: true - - onClicked: close() - } - } } } diff --git a/src/app/commoncomponents/EditedPopup.qml b/src/app/commoncomponents/EditedPopup.qml index 49bab54da..a398a2dd7 100644 --- a/src/app/commoncomponents/EditedPopup.qml +++ b/src/app/commoncomponents/EditedPopup.qml @@ -25,25 +25,23 @@ import net.jami.Constants 1.1 BaseModalDialog { id: root - width: JamiTheme.secondaryDialogDimension - property var previousBodies: undefined popupContent: JamiListView { - width: root.width - 4 * JamiTheme.preferredMarginSize + width: 400 - 2 * root.popupMargins + height: Math.min(count * 50, 150) model: root.previousBodies delegate: Rectangle { - width: root.width - 2 * JamiTheme.preferredMarginSize + width: 400 - 2 * root.popupMargins height: Math.max(JamiTheme.menuItemsPreferredHeight, rowBody.implicitHeight) color: index % 2 === 0 ? JamiTheme.backgroundColor : JamiTheme.secondaryBackgroundColor RowLayout { id: rowBody spacing: JamiTheme.preferredMarginSize - width: parent.width anchors.centerIn: parent Text { @@ -58,7 +56,6 @@ BaseModalDialog { Text { Layout.alignment: Qt.AlignLeft - Layout.fillWidth: true TextMetrics { id: metrics diff --git a/src/app/commoncomponents/PasswordDialog.qml b/src/app/commoncomponents/PasswordDialog.qml index f008ec844..f9f31e15b 100644 --- a/src/app/commoncomponents/PasswordDialog.qml +++ b/src/app/commoncomponents/PasswordDialog.qml @@ -64,11 +64,17 @@ BaseModalDialog { "title": title, "infoText": info, "buttonTitles": [JamiStrings.optionOk], - "buttonStyles": [SimpleMessageDialog.ButtonStyle.TintedBlue] + "buttonStyles": [SimpleMessageDialog.ButtonStyle.TintedBlue], + "buttonRoles": [DialogButtonBox.AcceptRole] }); done(success, purpose); } + button1.text: (purpose === PasswordDialog.ExportAccount) ? JamiStrings.exportAccount : JamiStrings.change + button1Role: DialogButtonBox.ApplyRole + button1.enabled: purpose === PasswordDialog.SetPassword + + popupContent: ColumnLayout { id: popupContentColumnLayout @@ -77,13 +83,13 @@ BaseModalDialog { function validatePassword() { switch (purpose) { case PasswordDialog.ExportAccount: - btnConfirm.enabled = currentPasswordEdit.dynamicText.length > 0; + button1.enabled = currentPasswordEdit.dynamicText.length > 0; break; case PasswordDialog.SetPassword: - btnConfirm.enabled = passwordEdit.dynamicText.length > 0 && passwordEdit.dynamicText === confirmPasswordEdit.dynamicText; + button1.enabled = passwordEdit.dynamicText.length > 0 && passwordEdit.dynamicText === confirmPasswordEdit.dynamicText; break; default: - btnConfirm.enabled = currentPasswordEdit.dynamicText.length > 0 && passwordEdit.dynamicText === confirmPasswordEdit.dynamicText; + button1.enabled = currentPasswordEdit.dynamicText.length > 0 && passwordEdit.dynamicText === confirmPasswordEdit.dynamicText; } } @@ -104,6 +110,13 @@ BaseModalDialog { onVisibleChanged: validatePassword() + Component.onCompleted: { + root.button1.clicked.connect(function() { + button1.enabled = false; + timerToOperate.restart(); + }); + } + Timer { id: timerToOperate @@ -165,26 +178,5 @@ BaseModalDialog { onDynamicTextChanged: popupContentColumnLayout.validatePassword() } - - MaterialButton { - id: btnConfirm - - Layout.alignment: Qt.AlignHCenter - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - - color: enabled ? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - secondary: true - autoAccelerator: true - enabled: purpose === PasswordDialog.SetPassword - - text: (purpose === PasswordDialog.ExportAccount) ? JamiStrings.exportAccount : JamiStrings.change - - onClicked: { - btnConfirm.enabled = false; - timerToOperate.restart(); - } - } } } diff --git a/src/app/commoncomponents/SimpleMessageDialog.qml b/src/app/commoncomponents/SimpleMessageDialog.qml index a47e9110d..15421e5a4 100644 --- a/src/app/commoncomponents/SimpleMessageDialog.qml +++ b/src/app/commoncomponents/SimpleMessageDialog.qml @@ -36,6 +36,7 @@ BaseModalDialog { property var buttonStyles: [] property string infoText: "" property var innerContentData: [] + property int buttonRoles: [] function openWithParameters(title, info = "") { root.title = title; @@ -44,6 +45,45 @@ BaseModalDialog { open(); } + button1.text: buttonTitles[0] + button1Role: buttonRoles[0] + button2.text: buttonTitles[1] ? buttonTitles[1] : null + button2Role: buttonRoles[1] + button1.onClicked: { + if (buttonCallBacks[0]) + buttonCallBacks[0](); + close(); + } + button2.onClicked: { + if (buttonCallBacks[1]) + buttonCallBacks[1](); + close(); + } + + Component.onCompleted: { + for (var i = 0; i < buttonStyles.length; i++){ + + switch (buttonStyles[i]) { + + case SimpleMessageDialog.ButtonStyle.TintedBlue: + button1.color = JamiTheme.buttonTintedBlue; + button1.hoveredColor = JamiTheme.buttonTintedBlueHovered; + button1.pressedColor = JamiTheme.buttonTintedBluePressed; + break; + case SimpleMessageDialog.ButtonStyle.TintedBlack: + button1.color = JamiTheme.buttonTintedBlack; + button1.hoveredColor = JamiTheme.buttonTintedBlackHovered; + button1.pressedColor = JamiTheme.buttonTintedBlackPressed; + break; + case SimpleMessageDialog.ButtonStyle.TintedRed: + button1.color = JamiTheme.buttonTintedRed; + button1.hoveredColor = JamiTheme.buttonTintedRedHovered; + button1.pressedColor = JamiTheme.buttonTintedRedPressed; + break; + } + } + } + popupContent: ColumnLayout { Label { id: infoTextLabel @@ -69,63 +109,5 @@ BaseModalDialog { data: innerContentData } - RowLayout { - spacing: JamiTheme.preferredMarginSize - - Layout.fillWidth: true - Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom - Layout.bottomMargin: JamiTheme.preferredMarginSize - - Repeater { - model: buttonTitles.length - MaterialButton { - Layout.alignment: Qt.AlignVCenter - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - buttontextHeightMargin: JamiTheme.buttontextHeightMargin - - color: { - switch (buttonStyles[modelData]) { - case SimpleMessageDialog.ButtonStyle.TintedBlue: - return JamiTheme.buttonTintedBlue; - case SimpleMessageDialog.ButtonStyle.TintedBlack: - return JamiTheme.buttonTintedBlack; - case SimpleMessageDialog.ButtonStyle.TintedRed: - return JamiTheme.buttonTintedRed; - } - } - hoveredColor: { - switch (buttonStyles[modelData]) { - case SimpleMessageDialog.ButtonStyle.TintedBlue: - return JamiTheme.buttonTintedBlueHovered; - case SimpleMessageDialog.ButtonStyle.TintedBlack: - return JamiTheme.buttonTintedBlackHovered; - case SimpleMessageDialog.ButtonStyle.TintedRed: - return JamiTheme.buttonTintedRedHovered; - } - } - pressedColor: { - switch (buttonStyles[modelData]) { - case SimpleMessageDialog.ButtonStyle.TintedBlue: - return JamiTheme.buttonTintedBluePressed; - case SimpleMessageDialog.ButtonStyle.TintedBlack: - return JamiTheme.buttonTintedBlackPressed; - case SimpleMessageDialog.ButtonStyle.TintedRed: - return JamiTheme.buttonTintedRedPressed; - } - } - secondary: true - autoAccelerator: true - - text: buttonTitles[modelData] - - onClicked: { - if (buttonCallBacks[modelData]) - buttonCallBacks[modelData](); - close(); - } - } - } - } } } diff --git a/src/app/constant/JamiStrings.qml b/src/app/constant/JamiStrings.qml index dd4879a0c..ccc9d2967 100644 --- a/src/app/constant/JamiStrings.qml +++ b/src/app/constant/JamiStrings.qml @@ -769,8 +769,9 @@ Item { property string joinCall: qsTr("Join call") property string wantToJoin: qsTr("A call is in progress. Do you want to join the call?") property string needsHost: qsTr("Current host for this swarm seems unreachable. Do you want to host the call?") - property string chooseHoster: qsTr("Choose a dedicated device for hosting future calls in this swarm. If not set, the device starting a call will host it.") - property string chooseThisDevice: qsTr("Choose this device") + property string selectHost: qsTr("Select dedicated device for hosting future calls in this swarm. If not set, the host will be the device starting a call.") + property string selectThisDevice: qsTr("Select this device") + property string selectDevice: qsTr("Select device") property string removeCurrentDevice: qsTr("Remove current device") property string becomeHostOneCall: qsTr("Host only this call") property string hostThisCall: qsTr("Host this call") diff --git a/src/app/constant/JamiTheme.qml b/src/app/constant/JamiTheme.qml index 64163825c..042484f4b 100644 --- a/src/app/constant/JamiTheme.qml +++ b/src/app/constant/JamiTheme.qml @@ -138,6 +138,8 @@ Item { property color secAndTertiHoveredBackgroundColor: darkTheme ? "#123F4A" : "#E5EEF5" property color closeButtonLighterBlack: "#4c4c4c" + property color redButtonColor: darkTheme ? "#FA2E30" : "#CC0022" + // Jami switch property color switchBackgroundCheckedColor: "#8dbaea" property color switchBackgroundColor: darkTheme ? "#626262" : "#E5EEF5" diff --git a/src/app/mainview/components/DevicesListPopup.qml b/src/app/mainview/components/DevicesListPopup.qml index 3c5efabc7..1d2830c11 100644 --- a/src/app/mainview/components/DevicesListPopup.qml +++ b/src/app/mainview/components/DevicesListPopup.qml @@ -29,25 +29,45 @@ BaseModalDialog { width: JamiTheme.secondaryDialogDimension + property string currentDeviceId + title: JamiStrings.defaultCallHost + button1.text: JamiStrings.selectDevice + button1Role: DialogButtonBox.AcceptRole + button1.toolTipText: JamiStrings.selectThisDevice + button1.enabled: false + button1.onClicked : { + CurrentConversation.setInfo("rdvAccount", CurrentAccount.uri); + CurrentConversation.setInfo("rdvDevice", currentDeviceId); + root.close(); + } + + button2.text: JamiStrings.removeDevice + button2Role: DialogButtonBox.ResetRole + button2.toolTipText: JamiStrings.removeCurrentDevice + button2.enabled: CurrentConversation.rdvAccount !== "" + button2.onClicked: { + CurrentConversation.setInfo("rdvAccount", ""); + CurrentConversation.setInfo("rdvDevice", ""); + close(); + } + popupContent: ColumnLayout { id: mainLayout anchors.centerIn: parent - anchors.margins: JamiTheme.preferredMarginSize - spacing: JamiTheme.preferredMarginSize - + spacing: 10 + width: JamiTheme.preferredDialogWidth Label { id: informativeLabel Layout.alignment: Qt.AlignCenter - Layout.topMargin: JamiTheme.preferredMarginSize - Layout.preferredWidth: root.width - 4*JamiTheme.preferredMarginSize + Layout.fillWidth: true wrapMode: Text.Wrap - text: JamiStrings.chooseHoster + text: JamiStrings.selectHost color: JamiTheme.primaryForegroundColor } @@ -79,15 +99,27 @@ BaseModalDialog { property bool isCurrent: DeviceName implicitWidth: devicesListView.width - width: root.width - 4*JamiTheme.preferredMarginSize height: 70 - highlighted: ListView.isCurrentItem + highlighted: CurrentConversation.rdvDevice === deviceId MouseArea { anchors.fill: parent onClicked: { - devicesListView.currentIndex = index; + if (!highlighted){ + devicesListView.currentIndex = index; + for (var i = 0; i < devicesListView.count; i++) { + devicesListView.itemAtIndex(i).highlighted = false; + } + currentDeviceId = deviceId; + button1.enabled = true; + } + else { + devicesListView.currentIndex = -1; + button1.enabled = false; + } + + item.highlighted = !item.highlighted; } } @@ -154,65 +186,6 @@ BaseModalDialog { } } } - - ColumnLayout { - id: buttonLayout - spacing: JamiTheme.preferredMarginSize - Layout.preferredWidth: root.width - 240 - - MaterialButton { - id: chooseBtn - - TextMetrics { - id: chooseBtnTextSize - font.weight: Font.Bold - font.pixelSize: JamiTheme.wizardViewButtonFontPixelSize - font.capitalization: Font.AllUppercase - text: chooseBtn.text - } - - Layout.alignment: Qt.AlignCenter - Layout.fillWidth: true - - primary: true - enabled: devicesListView.currentItem - - text: JamiStrings.chooseThisDevice - toolTipText: JamiStrings.chooseThisDevice - - onClicked: { - CurrentConversation.setInfo("rdvAccount", CurrentAccount.uri); - CurrentConversation.setInfo("rdvDevice", devicesListView.currentItem.deviceId); - close(); - } - } - - MaterialButton { - id: rmDeviceBtn - - TextMetrics { - id: rmDeviceBtnTextSize - font.weight: Font.Bold - font.pixelSize: JamiTheme.wizardViewButtonFontPixelSize - font.capitalization: Font.AllUppercase - text: rmDeviceBtn.text - } - - Layout.alignment: Qt.AlignCenter - Layout.fillWidth: true - primary: true - enabled: devicesListView.currentItem - - text: JamiStrings.removeCurrentDevice - toolTipText: JamiStrings.removeCurrentDevice - - onClicked: { - CurrentConversation.setInfo("rdvAccount", ""); - CurrentConversation.setInfo("rdvDevice", ""); - close(); - } - } - } } - } +} diff --git a/src/app/mainview/components/HostPopup.qml b/src/app/mainview/components/HostPopup.qml index b278f87bf..d63a29f37 100644 --- a/src/app/mainview/components/HostPopup.qml +++ b/src/app/mainview/components/HostPopup.qml @@ -31,55 +31,39 @@ BaseModalDialog { return role === Member.Role.ADMIN; } - popupContent: ColumnLayout { - id: mainLayout - spacing: JamiTheme.preferredMarginSize - - Label { - id: informativeLabel - - Layout.alignment: Qt.AlignCenter - Layout.fillWidth: true - Layout.maximumWidth: root.parent.width - 4*JamiTheme.preferredMarginSize - wrapMode: Text.WordWrap - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - text: JamiStrings.needsHost - color: JamiTheme.primaryForegroundColor - } - - MaterialButton { - id: becomeHostBtn - - Layout.alignment: Qt.AlignCenter - - Layout.margins: JamiTheme.preferredMarginSize - text: isAdmin ? JamiStrings.becomeHostOneCall : JamiStrings.hostThisCall - - onClicked: { - MessagesAdapter.joinCall(CurrentAccount.uri, CurrentAccount.deviceId, "0"); - close(); - } - } - - MaterialButton { - id: becomeDefaultHostBtn + button1.text: isAdmin ? JamiStrings.becomeHostOneCall : JamiStrings.hostThisCall + button1Role: DialogButtonBox.ApplyRole + button1.onClicked: { + MessagesAdapter.joinCall(CurrentAccount.uri, CurrentAccount.deviceId, "0"); + close(); + } - Layout.alignment: Qt.AlignCenter - Layout.margins: JamiTheme.preferredMarginSize + button2.text: JamiStrings.becomeDefaultHost + button2Role: DialogButtonBox.ApplyRole + button2.visible: isAdmin + button2.toolTipText: JamiStrings.becomeDefaultHost + button2.onClicked: { + CurrentConversation.setInfo("rdvAccount", CurrentAccount.uri); + CurrentConversation.setInfo("rdvDevice", CurrentAccount.deviceId); + MessagesAdapter.joinCall(CurrentAccount.uri, CurrentAccount.deviceId, "0"); + close(); + } - text: JamiStrings.becomeDefaultHost - toolTipText: JamiStrings.becomeDefaultHost + popupContent: ColumnLayout { + id: mainLayout - visible: isAdmin + Label { + id: informativeLabel - onClicked: { - CurrentConversation.setInfo("rdvAccount", CurrentAccount.uri); - CurrentConversation.setInfo("rdvDevice", devicesListView.currentItem.deviceId); - MessagesAdapter.joinCall(CurrentAccount.uri, CurrentAccount.deviceId, "0"); - close(); - } - } + Layout.alignment: Qt.AlignCenter + Layout.bottomMargin: 10 + Layout.fillWidth: true + Layout.maximumWidth: root.parent.width - 4*JamiTheme.preferredMarginSize + wrapMode: Text.WordWrap + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + text: JamiStrings.needsHost + color: JamiTheme.primaryForegroundColor } } -//} +} diff --git a/src/app/mainview/components/WelcomePageQrDialog.qml b/src/app/mainview/components/WelcomePageQrDialog.qml index 1712941b5..2d61e5348 100644 --- a/src/app/mainview/components/WelcomePageQrDialog.qml +++ b/src/app/mainview/components/WelcomePageQrDialog.qml @@ -24,20 +24,25 @@ import "../../commoncomponents" BaseModalDialog { id: root - topLayoutVisible: false + backgroundColor: JamiTheme.darkTheme ? JamiTheme.blackColor : JamiTheme.whiteColor - backgroundColor: JamiTheme.whiteColor + popupContent: Rectangle{ + anchors.centerIn: parent + width: userQrImage.width + 10 + height: userQrImage.height + 10 + color: JamiTheme.whiteColor + radius: 5 - popupContent: Image { + Image { id: userQrImage property int size: JamiTheme.qrCodeImageSize width: size height: size anchors.centerIn: parent - smooth: false fillMode: Image.PreserveAspectFit source: "image://qrImage/account_" + CurrentAccount.id + } } } diff --git a/src/app/qmlregister.cpp b/src/app/qmlregister.cpp index da5681b3e..478482564 100644 --- a/src/app/qmlregister.cpp +++ b/src/app/qmlregister.cpp @@ -109,7 +109,7 @@ registerTypes(QQmlEngine* engine, AppSettingsManager* settingsManager, ConnectivityMonitor* connectivityMonitor, ScreenInfo* screenInfo, - MainApplication* app) + QObject* app) { // setup the adapters (their lifetimes are that of MainApplication) auto callAdapter = new CallAdapter(settingsManager, systemTray, lrcInstance, engine); diff --git a/src/app/qmlregister.h b/src/app/qmlregister.h index 41b8f2f8b..008c3be51 100644 --- a/src/app/qmlregister.h +++ b/src/app/qmlregister.h @@ -68,5 +68,5 @@ void registerTypes(QQmlEngine* engine, AppSettingsManager* appSettingsManager, ConnectivityMonitor* connectivityMonitor, ScreenInfo* screenInfo, - MainApplication* app); + QObject* app); } diff --git a/src/app/settingsview/components/InstallManuallyView.qml b/src/app/settingsview/components/InstallManuallyView.qml index 5c0d02eaf..950813571 100644 --- a/src/app/settingsview/components/InstallManuallyView.qml +++ b/src/app/settingsview/components/InstallManuallyView.qml @@ -32,7 +32,8 @@ ColumnLayout { "infoText": JamiStrings.pluginInstallationFailed, "buttonStyles": [SimpleMessageDialog.ButtonStyle.TintedBlue], "buttonTitles": [JamiStrings.optionOk], - "buttonCallBacks": [] + "buttonCallBacks": [], + "buttonRoles": [DialogButtonBox.AcceptRole] }); } diff --git a/src/app/settingsview/components/LinkedDevicesBase.qml b/src/app/settingsview/components/LinkedDevicesBase.qml index 1f6a1824d..7e631edf4 100644 --- a/src/app/settingsview/components/LinkedDevicesBase.qml +++ b/src/app/settingsview/components/LinkedDevicesBase.qml @@ -49,7 +49,8 @@ ColumnLayout { "buttonStyles": [SimpleMessageDialog.ButtonStyle.TintedBlue, SimpleMessageDialog.ButtonStyle.TintedBlack], "buttonCallBacks": [function () { DeviceItemListModel.revokeDevice(deviceId, ""); - }] + }], + "buttonRoles": [DialogButtonBox.AcceptRole, DialogButtonBox.RejectRole] }); } } diff --git a/src/app/settingsview/components/ManageAccountPage.qml b/src/app/settingsview/components/ManageAccountPage.qml index 9c4487832..8cbd7cdb3 100644 --- a/src/app/settingsview/components/ManageAccountPage.qml +++ b/src/app/settingsview/components/ManageAccountPage.qml @@ -366,7 +366,8 @@ SettingsPageBase { "title": success ? JamiStrings.success : JamiStrings.error, "infoText": success ? JamiStrings.backupSuccessful : JamiStrings.backupFailed, "buttonTitles": [JamiStrings.optionOk], - "buttonStyles": [SimpleMessageDialog.ButtonStyle.TintedBlue] + "buttonStyles": [SimpleMessageDialog.ButtonStyle.TintedBlue], + "buttonRoles": [DialogButtonBox.AcceptRole] }); } }); diff --git a/src/app/settingsview/components/NameRegistrationDialog.qml b/src/app/settingsview/components/NameRegistrationDialog.qml index f596b11fe..2d673bd0b 100644 --- a/src/app/settingsview/components/NameRegistrationDialog.qml +++ b/src/app/settingsview/components/NameRegistrationDialog.qml @@ -33,6 +33,8 @@ BaseModalDialog { title: JamiStrings.setUsername + button2.onClicked: close() + popupContent: StackLayout { id: stackedWidget @@ -74,6 +76,10 @@ BaseModalDialog { break; } stackedWidget.currentIndex = nameRegisterErrorPage.pageIndex; + root.button1.text = JamiStrings.close; + button1Role = DialogButtonBox.RejectRole; + root.button1.onClicked = close() + root.button2.visible = false; } } @@ -83,6 +89,16 @@ BaseModalDialog { passwordEdit.clear(); if (CurrentAccount.hasArchivePassword) { stackedWidget.currentIndex = nameRegisterEnterPasswordPage.pageIndex; + root.button1.text = JamiStrings.register; + button1Role = DialogButtonBox.AcceptRole; + root.button1.enabled = false + root.button1.clicked.connect(function() { + stackedWidget.startRegistration(); + }); + + root.button2.text = JamiStrings.optionCancel; + root.button2Role = DialogButtonBox.RejectRole + passwordEdit.forceActiveFocus(); } else { startRegistration(); @@ -124,52 +140,9 @@ BaseModalDialog { echoMode: TextInput.Password placeholderText: JamiStrings.password - onTextChanged: btnRegister.enabled = (text.length > 0) - - onAccepted: btnRegister.clicked() - } - - RowLayout { - spacing: 16 - Layout.alignment: Qt.AlignHCenter - Layout.fillWidth: true - - MaterialButton { - id: btnRegister - - Layout.alignment: Qt.AlignHCenter - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - buttontextHeightMargin: JamiTheme.buttontextHeightMargin - - color: enabled ? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - secondary: true - enabled: false - - text: JamiStrings.register - - onClicked: stackedWidget.startRegistration() - } - - MaterialButton { - id: btnCancel + onTextChanged: root.button1.enabled = (text.length > 0) - Layout.alignment: Qt.AlignHCenter - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - buttontextHeightMargin: JamiTheme.buttontextHeightMargin - - color: JamiTheme.buttonTintedBlack - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - secondary: true - - text: JamiStrings.optionCancel - - onClicked: close() - } + onAccepted: root.button1.clicked() } } } @@ -225,8 +198,6 @@ BaseModalDialog { ColumnLayout { - spacing: 16 - Label { id: lblRegistrationError @@ -238,25 +209,6 @@ BaseModalDialog { horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } - - MaterialButton { - id: btnClose - - Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom - Layout.bottomMargin: JamiTheme.preferredMarginSize - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - buttontextHeightMargin: JamiTheme.buttontextHeightMargin - - color: JamiTheme.buttonTintedBlack - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - secondary: true - - text: JamiStrings.close - - onClicked: close() - } } } } diff --git a/src/app/settingsview/components/PluginAvailableDelegate.qml b/src/app/settingsview/components/PluginAvailableDelegate.qml index ee0a9ea9c..e8ae7dcac 100644 --- a/src/app/settingsview/components/PluginAvailableDelegate.qml +++ b/src/app/settingsview/components/PluginAvailableDelegate.qml @@ -62,7 +62,8 @@ ItemDelegate { "infoText": JamiStrings.pluginInstallationFailed, "buttonStyles": [SimpleMessageDialog.ButtonStyle.TintedBlue], "buttonTitles": [JamiStrings.optionOk], - "buttonCallBacks": [] + "buttonCallBacks": [], + "buttonRoles": [DialogButtonBox.AcceptRole] }); } diff --git a/src/app/settingsview/components/PluginPreferencesListView.qml b/src/app/settingsview/components/PluginPreferencesListView.qml index b47bc3ef1..41a20633f 100644 --- a/src/app/settingsview/components/PluginPreferencesListView.qml +++ b/src/app/settingsview/components/PluginPreferencesListView.qml @@ -288,7 +288,8 @@ Rectangle { } preferencesPerCategoryModel.reset(); generalPreferencesModel.reset(); - }] + }], + "buttonRoles": [DialogButtonBox.AcceptRole, DialogButtonBox.RejectRole] }) } } diff --git a/src/app/settingsview/components/PluginPreferencesView.qml b/src/app/settingsview/components/PluginPreferencesView.qml index 79d8163ec..e17074b82 100644 --- a/src/app/settingsview/components/PluginPreferencesView.qml +++ b/src/app/settingsview/components/PluginPreferencesView.qml @@ -295,7 +295,8 @@ Item { PluginAdapter.getPluginsFromStore(); // could not call root from here settings.ListView.view.parent.closed(); - }] + }], + "buttonRoles": [DialogButtonBox.AcceptRole, DialogButtonBox.RejectRole] }) } } diff --git a/src/app/settingsview/components/RevokeDevicePasswordDialog.qml b/src/app/settingsview/components/RevokeDevicePasswordDialog.qml index aae59f874..655960974 100644 --- a/src/app/settingsview/components/RevokeDevicePasswordDialog.qml +++ b/src/app/settingsview/components/RevokeDevicePasswordDialog.qml @@ -30,6 +30,19 @@ BaseModalDialog { title: JamiStrings.removeDevice + closeButtonVisible: false + + button1.text: JamiStrings.optionRemove + button1Role: DialogButtonBox.DestructiveRole + button1.enabled: false + button1.onClicked: { + DeviceItemListModel.revokeDevice(deviceId, passwordEdit.dynamicText); + close(); + } + button2.text: JamiStrings.optionCancel + button2Role: DialogButtonBox.RejectRole + button2.onClicked: close() + popupContent: ColumnLayout { id: revokeDeviceContentColumnLayout @@ -60,57 +73,7 @@ BaseModalDialog { placeholderText: JamiStrings.enterCurrentPassword - onDynamicTextChanged: btnRemove.enabled = dynamicText.length > 0 - } - - RowLayout { - spacing: 16 - Layout.alignment: Qt.AlignHCenter - - Layout.fillWidth: true - - MaterialButton { - id: btnRemove - - Layout.alignment: Qt.AlignHCenter - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - buttontextHeightMargin: JamiTheme.buttontextHeightMargin - - color: enabled ? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - secondary: true - autoAccelerator: true - enabled: false - - text: JamiStrings.optionRemove - - onClicked: { - DeviceItemListModel.revokeDevice(deviceId, passwordEdit.dynamicText); - close(); - } - } - - MaterialButton { - id: btnCancel - - Layout.alignment: Qt.AlignHCenter - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - buttontextHeightMargin: JamiTheme.buttontextHeightMargin - - color: JamiTheme.buttonTintedBlack - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - secondary: true - autoAccelerator: true - enabled: true - - text: JamiStrings.optionCancel - - onClicked: close() - } + onDynamicTextChanged: root.button1.enabled = dynamicText.length > 0 } } } diff --git a/src/app/settingsview/components/UpdateDownloadDialog.qml b/src/app/settingsview/components/UpdateDownloadDialog.qml index 9607f7621..5b91cee2f 100644 --- a/src/app/settingsview/components/UpdateDownloadDialog.qml +++ b/src/app/settingsview/components/UpdateDownloadDialog.qml @@ -33,6 +33,12 @@ SimpleMessageDialog { property string hTotalBytes: UtilsAdapter.humanFileSize(totalBytes) property alias progressBarValue: progressBar.value + closeButtonVisible: false + + button1.text: JamiStrings.optionCancel + button1Role: DialogButtonBox.RejectRole + button1.onClicked: function () { AppVersionManager.cancelUpdate();} + Connections { target: AppVersionManager diff --git a/src/app/webengine/map/StopSharingPositionPopup.qml b/src/app/webengine/map/StopSharingPositionPopup.qml index 153d81efc..61a201f38 100644 --- a/src/app/webengine/map/StopSharingPositionPopup.qml +++ b/src/app/webengine/map/StopSharingPositionPopup.qml @@ -24,151 +24,21 @@ import net.jami.Adapters 1.1 import net.jami.Constants 1.1 import "../../commoncomponents" -Popup { +BaseModalDialog { id: root - - width: popupContent.width - height: popupContent.height - - parent: Overlay.overlay - - // center in parent - x: Math.round((parent.width - width) / 2) - y: Math.round((parent.height - height) / 2) - - signal joinClicked - - modal: true - padding: 0 - - visible: false - focus: true - closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside - Rectangle { - id: container - - anchors.fill: parent - radius: JamiTheme.modalPopupRadius - color: JamiTheme.secondaryBackgroundColor - - ColumnLayout { - id: popupContent - - Layout.alignment: Qt.AlignCenter - - PushButton { - id: btnClose - - Layout.alignment: Qt.AlignRight - width: 30 - height: 30 - imageContainerWidth: 30 - imageContainerHeight: 30 - Layout.margins: 8 - radius: 5 - imageColor: "grey" - normalColor: JamiTheme.transparentColor - source: JamiResources.round_close_24dp_svg - onClicked: { - root.visible = false; - } - } - - Text { - Layout.leftMargin: 20 - Layout.rightMargin: 20 - Layout.fillWidth: true - Layout.alignment: Qt.AlignCenter - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - font.pixelSize: JamiTheme.popuptextSize - font.weight: Font.Medium - wrapMode: Text.WordWrap - color: JamiTheme.textColor - text: JamiStrings.stopSharingPopupBody - } - - RowLayout { - Layout.margins: JamiTheme.popupButtonsMargin - Layout.alignment: Qt.AlignCenter - - MaterialButton { - preferredWidth: text.contentWidth - textLeftPadding: JamiTheme.buttontextPadding - textRightPadding: JamiTheme.buttontextPadding - - color: JamiTheme.buttonTintedBlue - hoveredColor: JamiTheme.buttonTintedBlueHovered - pressedColor: JamiTheme.buttonTintedBluePressed - text: JamiStrings.stopConvSharing.arg(PositionManager.getmapTitle(attachedAccountId, CurrentConversation.id)) - - onClicked: { - PositionManager.stopSharingPosition(attachedAccountId, CurrentConversation.id); - root.close(); - } - } - - MaterialButton { - preferredWidth: text.contentWidth - textLeftPadding: JamiTheme.buttontextPadding - textRightPadding: JamiTheme.buttontextPadding - - color: JamiTheme.buttonTintedRed - hoveredColor: JamiTheme.buttonTintedRedHovered - pressedColor: JamiTheme.buttonTintedRedPressed - - text: JamiStrings.stopAllSharings - - onClicked: { - PositionManager.stopSharingPosition(); - root.close(); - } - } - } - } - } - - background: Rectangle { - color: JamiTheme.transparentColor + title: JamiStrings.stopSharingPopupBody + button1.text: JamiStrings.stopConvSharing.arg(PositionManager.getmapTitle(attachedAccountId, CurrentConversation.id)) + button1Role: DialogButtonBox.AcceptRole + button2.text: JamiStrings.stopAllSharings + button2Role: DialogButtonBox.DestructiveRole + button2.contentColorProvider: JamiTheme.redButtonColor + button1.onClicked: function() { + PositionManager.stopSharingPosition(attachedAccountId, CurrentConversation.id); + root.close(); } - - Overlay.modal: Rectangle { - color: JamiTheme.transparentColor - // Color animation for overlay when pop up is shown. - ColorAnimation on color { - to: JamiTheme.popupOverlayColor - duration: 500 - } + button2.onClicked: function() { + PositionManager.stopSharingPosition(); + root.close(); } - - DropShadow { - z: -1 - width: root.width - height: root.height - horizontalOffset: 3.0 - verticalOffset: 3.0 - radius: container.radius * 4 - color: JamiTheme.shadowColor - source: container - transparentBorder: true - samples: radius + 1 - } - - enter: Transition { - NumberAnimation { - properties: "opacity" - from: 0.0 - to: 1.0 - duration: JamiTheme.shortFadeDuration - } - } - - exit: Transition { - NumberAnimation { - properties: "opacity" - from: 1.0 - to: 0.0 - duration: JamiTheme.shortFadeDuration - } - } -} + signal joinClicked + } diff --git a/src/app/wizardview/components/NoUsernamePopup.qml b/src/app/wizardview/components/NoUsernamePopup.qml index 4bf79a2c7..a225097cf 100644 --- a/src/app/wizardview/components/NoUsernamePopup.qml +++ b/src/app/wizardview/components/NoUsernamePopup.qml @@ -24,17 +24,11 @@ import net.jami.Constants 1.1 import Qt5Compat.GraphicalEffects import "../../commoncomponents" -Popup { +BaseModalDialog { id: root - width: popupContent.width - height: popupContent.height - - parent: Overlay.overlay - - // center in parent - x: Math.round((parent.width - width) / 2) - y: Math.round((parent.height - height) / 2) + title: JamiStrings.chooseAUsername + closeButtonVisible: false signal joinClicked @@ -45,140 +39,28 @@ Popup { focus: true closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside - Rectangle { - id: container - - anchors.fill: parent - radius: JamiTheme.modalPopupRadius - color: JamiTheme.secondaryBackgroundColor - - ColumnLayout { - id: popupContent - - Layout.alignment: Qt.AlignCenter - - PushButton { - id: btnClose - - Layout.alignment: Qt.AlignRight - width: 30 - height: 30 - imageContainerWidth: 30 - imageContainerHeight: 30 - Layout.margins: 8 - radius: 5 - imageColor: "grey" - normalColor: JamiTheme.transparentColor - source: JamiResources.round_close_24dp_svg - onClicked: { - root.visible = false; - } - } + button1.text: JamiStrings.chooseAUsername + button1Role: DialogButtonBox.NoRole + button2.text: JamiStrings.joinJami + button2Role: DialogButtonBox.YesRole + button2.objectName: "joinButton" + button2.onClicked: { + root.joinClicked(); + WizardViewStepModel.nextStep(); + root.close(); + } + button1.onClicked: root.close() - Text { + popupContent: Text { + Layout.fillWidth: true Layout.preferredWidth: 280 Layout.leftMargin: 20 Layout.rightMargin: 20 - Layout.alignment: Qt.AlignCenter - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter + Layout.alignment: Qt.AlignLeft font.pixelSize: JamiTheme.popuptextSize lineHeight: JamiTheme.wizardViewTextLineHeight wrapMode: Text.WordWrap color: JamiTheme.textColor text: JamiStrings.joinJamiNoPassword - } - - RowLayout { - Layout.topMargin: JamiTheme.popupButtonsMargin - Layout.bottomMargin: JamiTheme.popupButtonsMargin - - Layout.alignment: Qt.AlignCenter - spacing: JamiTheme.popupButtonsMargin - - MaterialButton { - - TextMetrics { - id: joinJamiSize - font.weight: Font.Bold - font.pixelSize: JamiTheme.wizardViewButtonFontPixelSize - text: JamiStrings.joinJami - } - - Layout.leftMargin: JamiTheme.popupButtonsMargin - objectName: "joinButton" - preferredWidth: joinJamiSize.width + 2 * (JamiTheme.buttontextWizzardPadding + 1) - textLeftPadding: JamiTheme.buttontextWizzardPadding - textRightPadding: JamiTheme.buttontextWizzardPadding - secondary: true - text: JamiStrings.joinJami - onClicked: { - root.joinClicked(); - WizardViewStepModel.nextStep(); - root.close(); - } - } - - MaterialButton { - - TextMetrics { - id: chooseAUsernameSize - font.weight: Font.Bold - font.pixelSize: JamiTheme.wizardViewButtonFontPixelSize - text: JamiStrings.chooseAUsername - } - - Layout.rightMargin: JamiTheme.popupButtonsMargin - preferredWidth: chooseAUsernameSize.width + 2 * JamiTheme.buttontextWizzardPadding - primary: true - text: JamiStrings.chooseAUsername - onClicked: root.close() - } - } - } - } - - background: Rectangle { - color: JamiTheme.transparentColor - } - - Overlay.modal: Rectangle { - color: JamiTheme.transparentColor - // Color animation for overlay when pop up is shown. - ColorAnimation on color { - to: JamiTheme.popupOverlayColor - duration: 500 - } - } - - DropShadow { - z: -1 - width: root.width - height: root.height - horizontalOffset: 3.0 - verticalOffset: 3.0 - radius: container.radius * 4 - color: JamiTheme.shadowColor - source: container - transparentBorder: true - samples: radius + 1 - } - - enter: Transition { - NumberAnimation { - properties: "opacity" - from: 0.0 - to: 1.0 - duration: JamiTheme.shortFadeDuration - } - } - - exit: Transition { - NumberAnimation { - properties: "opacity" - from: 1.0 - to: 0.0 - duration: JamiTheme.shortFadeDuration } } -} diff --git a/tests/qml/main.cpp b/tests/qml/main.cpp index 23edaa66a..da9d78fae 100644 --- a/tests/qml/main.cpp +++ b/tests/qml/main.cpp @@ -87,8 +87,8 @@ public Q_SLOTS: // Expose custom types to the QML engine. Utils::registerTypes(engine, - systemTray_.get(), lrcInstance_.get(), + systemTray_.get(), settingsManager_.get(), connectivityMonitor_.get(), &screenInfo_, -- GitLab