From 5b267c9a463954224cfdbf3190bdfda737e4544c Mon Sep 17 00:00:00 2001 From: Ming Rui Zhang Date: Tue, 21 Sep 2021 15:38:30 -0400 Subject: [PATCH] dialog: use popup dialogs to replace the existing Qt.labs.platform ones Dialog in Qt.labs.platform which is used to be native in Qt 5.15 cannnot be accessed in Qt 6.2 for now, use popup dialogs instead 1. Add tittle 2. DropShadow revisit 3. Dim properly Change-Id: I8804ae0c30e3450c9a800d9a1c3946ff0bf44b46 --- qml.qrc | 3 +- src/DaemonReconnectWindow.qml | 11 - src/MainApplicationWindow.qml | 11 - src/commoncomponents/BaseDialog.qml | 26 - .../{ModalPopup.qml => BaseModalDialog.qml} | 61 +- src/commoncomponents/DaemonReconnectPopup.qml | 102 ++-- src/commoncomponents/DeleteAccountDialog.qml | 229 ++++---- src/commoncomponents/PasswordDialog.qml | 286 +++++---- src/commoncomponents/SimpleMessageDialog.qml | 145 +++-- src/constant/JamiStrings.qml | 1 + src/constant/JamiTheme.qml | 3 + src/mainview/components/AboutPopUp.qml | 370 ++++++------ src/mainview/components/UserProfile.qml | 17 +- .../components/WelcomePageQrDialog.qml | 29 +- .../components/CurrentAccountSettings.qml | 2 +- .../components/LinkDeviceDialog.qml | 549 +++++++++--------- src/settingsview/components/LinkedDevices.qml | 6 +- .../components/NameRegistrationDialog.qml | 383 ++++++------ .../components/RevokeDevicePasswordDialog.qml | 175 +++--- src/wizardview/components/BackupKeyPage.qml | 8 +- 20 files changed, 1190 insertions(+), 1227 deletions(-) delete mode 100644 src/commoncomponents/BaseDialog.qml rename src/commoncomponents/{ModalPopup.qml => BaseModalDialog.qml} (56%) diff --git a/qml.qrc b/qml.qrc index b096a67f..1718e8d4 100644 --- a/qml.qrc +++ b/qml.qrc @@ -21,8 +21,7 @@ src/commoncomponents/UsernameLineEdit.qml src/commoncomponents/Scaffold.qml src/commoncomponents/LineEditContextMenu.qml - src/commoncomponents/BaseDialog.qml - src/commoncomponents/ModalPopup.qml + src/commoncomponents/BaseModalDialog.qml src/commoncomponents/SimpleMessageDialog.qml src/commoncomponents/ResponsiveImage.qml src/commoncomponents/PresenceIndicator.qml diff --git a/src/DaemonReconnectWindow.qml b/src/DaemonReconnectWindow.qml index 9890ba28..30df00b2 100644 --- a/src/DaemonReconnectWindow.qml +++ b/src/DaemonReconnectWindow.qml @@ -198,17 +198,6 @@ ApplicationWindow { } } - Overlay.modal: ColorOverlay { - source: root.contentItem - color: "transparent" - - // Color animation for overlay when pop up is shown. - ColorAnimation on color { - to: Qt.rgba(0, 0, 0, 0.33) - duration: 500 - } - } - Component.onCompleted: { DBusErrorHandler.setActive(true) diff --git a/src/MainApplicationWindow.qml b/src/MainApplicationWindow.qml index 5efde197..85e19cf7 100644 --- a/src/MainApplicationWindow.qml +++ b/src/MainApplicationWindow.qml @@ -202,17 +202,6 @@ ApplicationWindow { } } - Overlay.modal: ColorOverlay { - source: root.contentItem - color: "transparent" - - // Color animation for overlay when pop up is shown. - ColorAnimation on color { - to: Qt.rgba(0, 0, 0, 0.33) - duration: 500 - } - } - onClosing: root.close() onScreenChanged: JamiQmlUtils.mainApplicationScreen = root.screen diff --git a/src/commoncomponents/BaseDialog.qml b/src/commoncomponents/BaseDialog.qml deleted file mode 100644 index fba27716..00000000 --- a/src/commoncomponents/BaseDialog.qml +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2020 by Savoir-faire Linux - * Author: Albert BabĂ­ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import QtQuick -import QtQuick.Controls - -Dialog { - id: root - - visible: false -} diff --git a/src/commoncomponents/ModalPopup.qml b/src/commoncomponents/BaseModalDialog.qml similarity index 56% rename from src/commoncomponents/ModalPopup.qml rename to src/commoncomponents/BaseModalDialog.qml index fe8b6460..074c6855 100644 --- a/src/commoncomponents/ModalPopup.qml +++ b/src/commoncomponents/BaseModalDialog.qml @@ -18,6 +18,7 @@ import QtQuick import QtQuick.Controls +import QtQuick.Layouts import Qt5Compat.GraphicalEffects import net.jami.Constants 1.1 @@ -28,6 +29,12 @@ Popup { // convient access to closePolicy property bool autoClose: true property alias backgroundColor: container.color + property alias title: titleText.text + property var popupContentLoader: containerSubContentLoader + property alias popupContentLoadStatus: containerSubContentLoader.status + property alias popupContent: containerSubContentLoader.sourceComponent + property int popupContentPreferredHeight: 0 + property int popupContentPreferredWidth: 0 parent: Overlay.overlay @@ -37,20 +44,64 @@ Popup { modal: true + padding: 0 + // A popup is invisible until opened. visible: false closePolicy: autoClose ? (Popup.CloseOnEscape | Popup.CloseOnPressOutside) : Popup.NoAutoClose - padding: 0 - - background: Rectangle { + Rectangle { id: container + anchors.fill: parent + + ColumnLayout { + anchors.fill: parent + + spacing: 0 + + Text { + id: titleText + + Layout.alignment: Qt.AlignTop | Qt.AlignLeft + Layout.margins: text.length === 0 ? 0 : 10 + + Layout.preferredHeight: text.length === 0 ? 0 : contentHeight + + font.pointSize: 12 + color: JamiTheme.textColor + } + + Loader { + id: containerSubContentLoader + + Layout.alignment: Qt.AlignCenter + + Layout.fillWidth: popupContentPreferredWidth === 0 + Layout.fillHeight: popupContentPreferredHeight === 0 + Layout.preferredHeight: popupContentPreferredHeight + Layout.preferredWidth: popupContentPreferredWidth + } + } + radius: JamiTheme.modalPopupRadius - width: root.width - height: root.height + color: JamiTheme.secondaryBackgroundColor + } + + 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 { diff --git a/src/commoncomponents/DaemonReconnectPopup.qml b/src/commoncomponents/DaemonReconnectPopup.qml index 8753fd19..eb592fb8 100644 --- a/src/commoncomponents/DaemonReconnectPopup.qml +++ b/src/commoncomponents/DaemonReconnectPopup.qml @@ -23,7 +23,7 @@ import QtQuick.Layouts import net.jami.Constants 1.1 import net.jami.Models 1.1 -ModalPopup { +BaseModalDialog { id: root property bool connectionFailed: false @@ -31,73 +31,69 @@ ModalPopup { autoClose: false - contentItem: Rectangle { - id: contentRect + onPopupContentLoadStatusChanged: { + if (popupContentLoadStatus === Loader.Ready) { + root.height = Qt.binding(function() { + return popupContentLoader.item.implicitHeight + 50 + }) + root.width = Qt.binding(function() { + return popupContentLoader.item.implicitWidth + 50 + }) + } + } - implicitHeight: daemonReconnectPopupColumnLayout.implicitHeight + 50 + popupContent: ColumnLayout { + id: daemonReconnectPopupColumnLayout - color: JamiTheme.secondaryBackgroundColor + spacing: 0 - ColumnLayout { - id: daemonReconnectPopupColumnLayout + Text { + id: daemonReconnectPopupTextLabel - anchors.fill: parent + Layout.alignment: Qt.AlignHCenter | Qt.AlignTop + Layout.topMargin: preferredMargin - spacing: 0 + text: connectionFailed ? JamiStrings.reconnectionFailed : + JamiStrings.reconnectDaemon + font.pointSize: JamiTheme.textFontSize + 2 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: JamiTheme.textColor + } - Text { - id: daemonReconnectPopupTextLabel + AnimatedImage { + Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom + Layout.preferredHeight: 30 + Layout.preferredWidth: 30 + Layout.bottomMargin: preferredMargin - Layout.alignment: Qt.AlignHCenter | Qt.AlignTop - Layout.topMargin: preferredMargin + visible: !connectionFailed - text: connectionFailed ? JamiStrings.reconnectionFailed : - JamiStrings.reconnectDaemon - font.pointSize: JamiTheme.textFontSize + 2 - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - color: JamiTheme.textColor + source: JamiResources.jami_rolling_spinner_gif - Component.onCompleted: { - contentRect.implicitWidth = JamiQmlUtils.getTextBoundingRect( - font, text).width + 100 - } - } + playing: true + paused: false + mipmap: true + smooth: true + fillMode: Image.PreserveAspectFit + } - AnimatedImage { - Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom - Layout.preferredHeight: 30 - Layout.preferredWidth: 30 - Layout.bottomMargin: preferredMargin + MaterialButton { + id: btnOk - visible: !connectionFailed + Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom - source: JamiResources.jami_rolling_spinner_gif + preferredWidth: JamiTheme.preferredFieldWidth / 2 - playing: true - paused: false - mipmap: true - smooth: true - fillMode: Image.PreserveAspectFit - } + visible: connectionFailed - MaterialButton { - id: btnOk + text: JamiStrings.optionOk + color: JamiTheme.buttonTintedBlue + hoveredColor: JamiTheme.buttonTintedBlueHovered + pressedColor: JamiTheme.buttonTintedBluePressed + outlined: true - Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - - visible: connectionFailed - - text: qsTr("Ok") - color: JamiTheme.buttonTintedBlue - hoveredColor: JamiTheme.buttonTintedBlueHovered - pressedColor: JamiTheme.buttonTintedBluePressed - outlined: true - - onClicked: Qt.quit() - } + onClicked: Qt.quit() } } } diff --git a/src/commoncomponents/DeleteAccountDialog.qml b/src/commoncomponents/DeleteAccountDialog.qml index d908b8d6..5e1bf6b4 100644 --- a/src/commoncomponents/DeleteAccountDialog.qml +++ b/src/commoncomponents/DeleteAccountDialog.qml @@ -26,7 +26,7 @@ import net.jami.Constants 1.1 import "../commoncomponents" -BaseDialog { +BaseModalDialog { id: root property bool isSIP: { @@ -42,140 +42,131 @@ BaseDialog { title: JamiStrings.deleteAccount - contentItem: Rectangle { - id: deleteAccountContentRect + width: JamiTheme.preferredDialogWidth + height: JamiTheme.preferredDialogHeight - implicitWidth: JamiTheme.preferredDialogWidth - implicitHeight: JamiTheme.preferredDialogHeight - color: JamiTheme.secondaryBackgroundColor + popupContent: ColumnLayout { + id: deleteAccountContentColumnLayout - ColumnLayout { - anchors.centerIn: parent - anchors.fill: parent - anchors.margins: JamiTheme.preferredMarginSize + Label { + id: labelDeletion - Label { - id: labelDeletion + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: deleteAccountContentColumnLayout.width - + JamiTheme.preferredMarginSize * 2 + + color: JamiTheme.textColor + text: JamiStrings.confirmDeleteQuestion + + font.pointSize: JamiTheme.textFontSize + font.kerning: true + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: Text.Wrap + } + + Label { + id: labelBestId + + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: deleteAccountContentColumnLayout.width - + JamiTheme.preferredMarginSize * 2 + + color: JamiTheme.textColor + text: CurrentAccount.bestName + + font.pointSize: JamiTheme.textFontSize + font.kerning: true + font.bold: true + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: Text.Wrap + } + + Label { + id: labelAccountHash + + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: deleteAccountContentColumnLayout.width - + JamiTheme.preferredMarginSize * 2 + + color: JamiTheme.textColor + text: CurrentAccount.uri + + font.pointSize: JamiTheme.textFontSize + font.kerning: true + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: Text.Wrap + } + + Label { + id: labelWarning + + visible: !isSIP + + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: deleteAccountContentColumnLayout.width - + JamiTheme.preferredMarginSize * 2 + + text: JamiStrings.deleteAccountInfos + + font.pointSize: JamiTheme.textFontSize + font.kerning: true + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: Text.Wrap + + color: JamiTheme.redColor + } + + RowLayout { + spacing: 16 + Layout.fillWidth: true + Layout.alignment: Qt.AlignCenter + + MaterialButton { + id: btnDelete Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: deleteAccountContentRect.width - - JamiTheme.preferredMarginSize * 2 - color: JamiTheme.textColor - text: JamiStrings.confirmDeleteQuestion + preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 + preferredHeight: JamiTheme.preferredFieldHeight - font.pointSize: JamiTheme.textFontSize - font.kerning: true + color: JamiTheme.buttonTintedRed + hoveredColor: JamiTheme.buttonTintedRedHovered + pressedColor: JamiTheme.buttonTintedRedPressed + outlined: true - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - wrapMode: Text.Wrap - } + text: JamiStrings.optionDelete - Label { - id: labelBestId - - Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: deleteAccountContentRect.width - - JamiTheme.preferredMarginSize * 2 - - color: JamiTheme.textColor - text: CurrentAccount.bestName - - font.pointSize: JamiTheme.textFontSize - font.kerning: true - font.bold: true - - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - wrapMode: Text.Wrap - } - - Label { - id: labelAccountHash - - Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: deleteAccountContentRect.width - - JamiTheme.preferredMarginSize * 2 - - color: JamiTheme.textColor - text: CurrentAccount.uri - - font.pointSize: JamiTheme.textFontSize - font.kerning: true - - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - wrapMode: Text.Wrap - } - - Label { - id: labelWarning - - visible: !isSIP - - Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: deleteAccountContentRect.width - - JamiTheme.preferredMarginSize * 2 - - text: JamiStrings.deleteAccountInfos - - font.pointSize: JamiTheme.textFontSize - font.kerning: true - - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - wrapMode: Text.Wrap - - color: "red" - } - - RowLayout { - spacing: 16 - Layout.fillWidth: true - Layout.alignment: Qt.AlignCenter - - MaterialButton { - id: btnDelete - - Layout.alignment: Qt.AlignHCenter - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - preferredHeight: JamiTheme.preferredFieldHeight - - color: JamiTheme.buttonTintedRed - hoveredColor: JamiTheme.buttonTintedRedHovered - pressedColor: JamiTheme.buttonTintedRedPressed - outlined: true - - text: qsTr("Delete") - - onClicked: { - AccountAdapter.deleteCurrentAccount() - accepted() - close() - } + onClicked: { + AccountAdapter.deleteCurrentAccount() + accepted() + close() } + } - MaterialButton { - id: btnCancel + MaterialButton { + id: btnCancel - Layout.alignment: Qt.AlignHCenter + Layout.alignment: Qt.AlignHCenter - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - preferredHeight: JamiTheme.preferredFieldHeight + preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 + preferredHeight: JamiTheme.preferredFieldHeight - color: JamiTheme.buttonTintedBlack - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - outlined: true + color: JamiTheme.buttonTintedBlack + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true - text: qsTr("Cancel") + text: JamiStrings.optionCancel - onClicked: { - close() - } - } + onClicked: close() } } } diff --git a/src/commoncomponents/PasswordDialog.qml b/src/commoncomponents/PasswordDialog.qml index 97b68053..871beb0e 100644 --- a/src/commoncomponents/PasswordDialog.qml +++ b/src/commoncomponents/PasswordDialog.qml @@ -23,7 +23,7 @@ import net.jami.Adapters 1.1 import net.jami.Constants 1.1 // PasswordDialog for changing password and exporting account -BaseDialog { +BaseModalDialog { id: root enum PasswordEnteringPurpose { @@ -40,52 +40,12 @@ BaseDialog { function openDialog(purposeIn, exportPathIn = "") { purpose = purposeIn path = exportPathIn - currentPasswordEdit.clear() - passwordEdit.clear() - confirmPasswordEdit.clear() - validatePassword() + open() } - function validatePassword() { - switch (purpose) { - case PasswordDialog.ExportAccount: - btnConfirm.enabled = currentPasswordEdit.length > 0 - break - case PasswordDialog.SetPassword: - btnConfirm.enabled = passwordEdit.length > 0 && - passwordEdit.text === confirmPasswordEdit.text - break - default: - btnConfirm.enabled = currentPasswordEdit.length > 0 && - passwordEdit.text === confirmPasswordEdit.text - } - } - - function exportAccountQML() { - var success = false - if (path.length > 0) { - success = AccountAdapter.exportToFile( - LRCInstance.currentAccountId, - path, - currentPasswordEdit.text) - } - doneSignal(success, purpose) - close() - } - - function savePasswordQML() { - var success = false - success = AccountAdapter.savePassword( - LRCInstance.currentAccountId, - currentPasswordEdit.text, - passwordEdit.text) - if (success) { - AccountAdapter.setArchiveHasPassword(passwordEdit.text.length !== 0) - } - doneSignal(success, purpose) - close() - } + height: JamiTheme.preferredDialogHeight + width: JamiTheme.preferredDialogWidth title: { switch(purpose){ @@ -98,131 +58,161 @@ BaseDialog { } } - Timer { - id: timerToOperate + popupContent: ColumnLayout { + id: popupContentColumnLayout - interval: 200 - repeat: false + spacing: 0 - onTriggered: { - if (purpose === PasswordDialog.ExportAccount) { - exportAccountQML() - } else { - savePasswordQML() + function validatePassword() { + switch (purpose) { + case PasswordDialog.ExportAccount: + btnConfirm.enabled = currentPasswordEdit.length > 0 + break + case PasswordDialog.SetPassword: + btnConfirm.enabled = passwordEdit.length > 0 && + passwordEdit.text === confirmPasswordEdit.text + break + default: + btnConfirm.enabled = currentPasswordEdit.length > 0 && + passwordEdit.text === confirmPasswordEdit.text } } - } - contentItem: Rectangle { - id: passwordDialogContentRect + function exportAccountQML() { + var success = false + if (path.length > 0) { + success = AccountAdapter.exportToFile( + LRCInstance.currentAccountId, + path, + currentPasswordEdit.text) + } + doneSignal(success, purpose) + close() + } - implicitWidth: JamiTheme.preferredDialogWidth - implicitHeight: JamiTheme.preferredDialogHeight - color: JamiTheme.secondaryBackgroundColor + function savePasswordQML() { + var success = false + success = AccountAdapter.savePassword( + LRCInstance.currentAccountId, + currentPasswordEdit.text, + passwordEdit.text) + if (success) { + AccountAdapter.setArchiveHasPassword(passwordEdit.text.length !== 0) + } + doneSignal(success, purpose) + close() + } - ColumnLayout { - anchors.centerIn: parent - anchors.fill: parent - anchors.margins: JamiTheme.preferredMarginSize + onVisibleChanged: validatePassword() - MaterialLineEdit { - id: currentPasswordEdit + Timer { + id: timerToOperate + + interval: 200 + repeat: false + + onTriggered: { + if (purpose === PasswordDialog.ExportAccount) { + popupContentColumnLayout.exportAccountQML() + } else { + popupContentColumnLayout.savePasswordQML() + } + } + } + + MaterialLineEdit { + id: currentPasswordEdit + + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth + Layout.preferredHeight: visible ? 48 : 0 + + visible: purpose === PasswordDialog.ChangePassword || + purpose === PasswordDialog.ExportAccount + echoMode: TextInput.Password + placeholderText: JamiStrings.enterCurrentPassword + + onVisibleChanged: clear() + + onTextChanged: popupContentColumnLayout.validatePassword() + } + + MaterialLineEdit { + id: passwordEdit + + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth + Layout.preferredHeight: visible ? 48 : 0 + + visible: purpose === PasswordDialog.ChangePassword || + purpose === PasswordDialog.SetPassword + echoMode: TextInput.Password + placeholderText: JamiStrings.enterNewPassword + + onVisibleChanged: clear() + + onTextChanged: popupContentColumnLayout.validatePassword() + } + + MaterialLineEdit { + id: confirmPasswordEdit + + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth + Layout.preferredHeight: visible ? 48 : 0 + + visible: purpose === PasswordDialog.ChangePassword || + purpose === PasswordDialog.SetPassword + echoMode: TextInput.Password + placeholderText: JamiStrings.confirmNewPassword + + onVisibleChanged: clear() + + onTextChanged: popupContentColumnLayout.validatePassword() + } + + RowLayout { + spacing: 16 + Layout.fillWidth: true + Layout.alignment: Qt.AlignCenter + + MaterialButton { + id: btnConfirm Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: JamiTheme.preferredFieldWidth - Layout.preferredHeight: visible ? 48 : 0 - visible: purpose === PasswordDialog.ChangePassword || - purpose === PasswordDialog.ExportAccount - echoMode: TextInput.Password - placeholderText: JamiStrings.enterCurrentPassword + preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - onTextChanged: { - validatePassword() + color: enabled? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true + enabled: purpose === PasswordDialog.SetPassword + + text: (purpose === PasswordDialog.ExportAccount) ? JamiStrings.exportAccount : + JamiStrings.change + + onClicked: { + btnConfirm.enabled = false + timerToOperate.restart() } } - MaterialLineEdit { - id: passwordEdit + MaterialButton { + id: btnCancel Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: JamiTheme.preferredFieldWidth - Layout.preferredHeight: visible ? 48 : 0 - visible: purpose === PasswordDialog.ChangePassword || - purpose === PasswordDialog.SetPassword - echoMode: TextInput.Password + preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - placeholderText: JamiStrings.enterNewPassword + color: JamiTheme.buttonTintedBlack + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true - onTextChanged: { - validatePassword() - } - } + text: JamiStrings.optionCancel - MaterialLineEdit { - id: confirmPasswordEdit - - Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: JamiTheme.preferredFieldWidth - Layout.preferredHeight: visible ? 48 : 0 - - visible: purpose === PasswordDialog.ChangePassword || - purpose === PasswordDialog.SetPassword - echoMode: TextInput.Password - - placeholderText: JamiStrings.confirmNewPassword - - onTextChanged: { - validatePassword() - } - } - - RowLayout { - spacing: 16 - Layout.fillWidth: true - Layout.alignment: Qt.AlignCenter - - MaterialButton { - id: btnConfirm - - Layout.alignment: Qt.AlignHCenter - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - - color: enabled? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - outlined: true - enabled: purpose === PasswordDialog.SetPassword - - text: (purpose === PasswordDialog.ExportAccount) ? JamiStrings.exportAccount : - JamiStrings.change - - onClicked: { - btnConfirm.enabled = false - timerToOperate.restart() - } - } - - MaterialButton { - id: btnCancel - - Layout.alignment: Qt.AlignHCenter - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - - color: JamiTheme.buttonTintedBlack - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - outlined: true - - text: qsTr("Cancel") - - onClicked: { - close() - } - } + onClicked: close() } } } diff --git a/src/commoncomponents/SimpleMessageDialog.qml b/src/commoncomponents/SimpleMessageDialog.qml index 80c710f3..c848ddbe 100644 --- a/src/commoncomponents/SimpleMessageDialog.qml +++ b/src/commoncomponents/SimpleMessageDialog.qml @@ -23,7 +23,7 @@ import QtQuick.Layouts import net.jami.Adapters 1.1 import net.jami.Constants 1.1 -BaseDialog { +BaseModalDialog { id: root // TODO: make MaterialButton ButtonStyle @@ -36,8 +36,8 @@ BaseDialog { property var buttonTitles: [] property var buttonCallBacks: [] property var buttonStyles: [] - property alias infoText: infoText.text - property alias innerContentData: innerContent.data + property string infoText: "" + property var innerContentData: [] function openWithParameters(title, info = "") { root.title = title @@ -46,94 +46,89 @@ BaseDialog { open() } - contentItem: Rectangle { - id: container + width: Math.max(JamiTheme.preferredDialogWidth, + buttonTitles.length * (JamiTheme.preferredFieldWidth / 2 + + JamiTheme.preferredMarginSize)) + height: JamiTheme.preferredDialogHeight / 2 - JamiTheme.preferredMarginSize - implicitWidth: Math.max(JamiTheme.preferredDialogWidth, - buttonTitles.length * (JamiTheme.preferredFieldWidth / 2 - + JamiTheme.preferredMarginSize)) - implicitHeight: JamiTheme.preferredDialogHeight / 2 - JamiTheme.preferredMarginSize + popupContent: ColumnLayout { + Label { + id: infoTextLabel - color: JamiTheme.secondaryBackgroundColor + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: JamiTheme.preferredDialogWidth - JamiTheme.preferredMarginSize - ColumnLayout { - anchors.fill: parent + text: infoText + font.pointSize: JamiTheme.menuFontSize - 2 + wrapMode: Text.WordWrap + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: JamiTheme.textColor + } - Label { - id: infoText + Item { + id: innerContent - Layout.alignment: Qt.AlignCenter - Layout.preferredWidth: JamiTheme.preferredDialogWidth - JamiTheme.preferredMarginSize - Layout.topMargin: JamiTheme.preferredMarginSize + Layout.topMargin: JamiTheme.preferredMarginSize / 2 + Layout.fillWidth: true + Layout.fillHeight: true - font.pointSize: JamiTheme.menuFontSize - 2 - wrapMode: Text.WordWrap - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - color: JamiTheme.textColor - } + data: innerContentData + } - Item { - id: innerContent - Layout.topMargin: JamiTheme.preferredMarginSize / 2 - Layout.fillWidth: true - Layout.fillHeight: true - } + RowLayout { + spacing: JamiTheme.preferredMarginSize - RowLayout { - spacing: JamiTheme.preferredMarginSize + Layout.fillWidth: true + Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom + Layout.bottomMargin: JamiTheme.preferredMarginSize - Layout.fillWidth: true - Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom - Layout.bottomMargin: JamiTheme.preferredMarginSize + Repeater { + model: buttonTitles.length + MaterialButton { + Layout.alignment: Qt.AlignVCenter - Repeater { - model: buttonTitles.length - MaterialButton { - Layout.alignment: Qt.AlignVCenter + preferredWidth: JamiTheme.preferredFieldWidth / 2 + preferredHeight: JamiTheme.preferredFieldHeight - preferredWidth: JamiTheme.preferredFieldWidth / 2 - preferredHeight: JamiTheme.preferredFieldHeight - - 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 - } + 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 - } + } + 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 - } + } + 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 } - outlined: true + } + outlined: true - text: buttonTitles[modelData] + text: buttonTitles[modelData] - onClicked: { - if (buttonCallBacks[modelData]) - buttonCallBacks[modelData]() - close() - } + onClicked: { + if (buttonCallBacks[modelData]) + buttonCallBacks[modelData]() + close() } } } diff --git a/src/constant/JamiStrings.qml b/src/constant/JamiStrings.qml index 4029dd75..df49e861 100644 --- a/src/constant/JamiStrings.qml +++ b/src/constant/JamiStrings.qml @@ -544,6 +544,7 @@ Item { property string optionCancel: qsTr("Cancel") property string optionUpgrade: qsTr("Upgrade") property string optionLater: qsTr("Later") + property string optionDelete: qsTr("Delete") // Conference moderation property string setModerator: qsTr("Set moderator") diff --git a/src/constant/JamiTheme.qml b/src/constant/JamiTheme.qml index 4d4a4030..fc71dea5 100644 --- a/src/constant/JamiTheme.qml +++ b/src/constant/JamiTheme.qml @@ -54,6 +54,8 @@ Item { property color editBackgroundColor: darkTheme ? "#373737" : lightGrey_ property color textColor: primaryForegroundColor property color tabbarBorderColor: darkTheme ? blackColor : "#e3e3e3" + property color popupOverlayColor: darkTheme ? Qt.rgba(255, 255, 255, 0.22) : + Qt.rgba(0, 0, 0, 0.33) // Side panel property color presenceGreen: "#4cd964" @@ -206,6 +208,7 @@ Item { property int smartListTransitionDuration: 120 // Sizes + property real qrCodeImageSize: 256 property real splitViewHandlePreferredWidth: 4 property real indicatorFontSize: 6 property real tinyFontSize: 7 diff --git a/src/mainview/components/AboutPopUp.qml b/src/mainview/components/AboutPopUp.qml index 6e2a3295..73bd3f93 100644 --- a/src/mainview/components/AboutPopUp.qml +++ b/src/mainview/components/AboutPopUp.qml @@ -26,221 +26,219 @@ import net.jami.Constants 1.1 import "../../commoncomponents" -ModalPopup { +BaseModalDialog { id: root - property alias preferredHeight: aboutPopUpContentRectColumnLayout.implicitHeight + property int preferredHeight: 0 - contentItem: Rectangle { - id: contentRect + width: 400 - implicitWidth: 400 - color: JamiTheme.backgroundColor + onPopupContentLoadStatusChanged: { + if (popupContentLoadStatus === Loader.Ready) + preferredHeight = Qt.binding(function() { + return popupContentLoader.item.contentHeight + }) + } - JamiFlickable { - id: aboutPopUpScrollView + popupContent: JamiFlickable { + id: aboutPopUpScrollView - anchors.fill: parent + contentHeight: aboutPopUpContentRectColumnLayout.implicitHeight - contentHeight: aboutPopUpContentRectColumnLayout.implicitHeight + ColumnLayout { + id: aboutPopUpContentRectColumnLayout - ColumnLayout { - id: aboutPopUpContentRectColumnLayout + width: Math.max(root.width, implicitWidth) + height: Math.max(aboutPopUpScrollView.height, implicitHeight) - width: Math.max(root.width, implicitWidth) - height: Math.max(aboutPopUpScrollView.height, implicitHeight) + ResponsiveImage { + id: aboutPopUPJamiLogoImage - ResponsiveImage { - id: aboutPopUPJamiLogoImage + Layout.alignment: Qt.AlignCenter + Layout.topMargin: JamiTheme.preferredMarginSize + Layout.preferredWidth: 250 + Layout.preferredHeight: 88 - Layout.alignment: Qt.AlignCenter - Layout.topMargin: JamiTheme.preferredMarginSize - Layout.preferredWidth: 250 - Layout.preferredHeight: 88 + source: JamiTheme.darkTheme ? + JamiResources.logo_jami_standard_coul_white_svg : + JamiResources.logo_jami_standard_coul_svg + } - source: JamiTheme.darkTheme ? - JamiResources.logo_jami_standard_coul_white_svg : - JamiResources.logo_jami_standard_coul_svg + MaterialLineEdit { + id: jamiVersionText + + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: aboutPopUpScrollView.width + + font.pointSize: JamiTheme.textFontSize + + padding: 0 + readOnly: true + selectByMouse: true + + text: JamiStrings.version + ": " + UtilsAdapter.getVersionStr() + color: JamiTheme.textColor + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + + Label { + id: jamiSlogansText + + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: aboutPopUpScrollView.width + Layout.preferredHeight: textMetricsjamiSlogansText.boundingRect.height + Layout.topMargin: 5 + + wrapMode: Text.WordWrap + font.pointSize: JamiTheme.textFontSize + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + + text: textMetricsjamiSlogansText.text + color: JamiTheme.textColor + + TextMetrics { + id: textMetricsjamiSlogansText + font: jamiSlogansText.font + text: JamiStrings.slogan + } + } + + Label { + id: jamiDeclarationText + + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: aboutPopUpScrollView.width + Layout.preferredHeight: 40 + Layout.topMargin: 5 + + wrapMode: Text.WordWrap + font.pointSize: JamiTheme.textFontSize + color: JamiTheme.textColor + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + + // TextMetrics does not work for multi-line. + text: JamiStrings.declaration + } + + Label { + id: jamiDeclarationHyperText + + Layout.alignment: Qt.AlignCenter + + // Strangely, hoveredLink works badly when width grows too large + Layout.preferredWidth: 50 + Layout.preferredHeight: textMetricsjamiDeclarationHyperText.boundingRect.height + Layout.topMargin: 5 + Layout.bottomMargin: 5 + color: JamiTheme.textColor + + font.pointSize: JamiTheme.textFontSize + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + + text: textMetricsjamiDeclarationHyperText.text + onLinkActivated: Qt.openUrlExternally(link) + + TextMetrics { + id: textMetricsjamiDeclarationHyperText + font: jamiDeclarationHyperText.font + text: 'jami.net' } - MaterialLineEdit { - id: jamiVersionText + MouseArea { + anchors.fill: parent - Layout.alignment: Qt.AlignCenter - Layout.preferredWidth: contentRect.width + // We don't want to eat clicks on the Text. + acceptedButtons: Qt.NoButton + cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor + } + } - font.pointSize: JamiTheme.textFontSize + Label { + id: jamiDeclarationYearText - padding: 0 - readOnly: true - selectByMouse: true + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: aboutPopUpScrollView.width + Layout.preferredHeight: textMetricsjamiDeclarationYearText.boundingRect.height + Layout.bottomMargin: 5 - text: JamiStrings.version + ": " + UtilsAdapter.getVersionStr() - color: JamiTheme.textColor + font.pointSize: JamiTheme.textFontSize + color: JamiTheme.textColor - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + + text: textMetricsjamiDeclarationYearText.text + + TextMetrics { + id: textMetricsjamiDeclarationYearText + font: jamiDeclarationYearText.font + text: JamiStrings.companyDeclarationYear + } + } + + Label { + id: jamiNoneWarrantyHyperText + + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: 300 + Layout.preferredHeight: textMetricsjamiNoneWarrantyHyperText.boundingRect.height * 2 + Layout.bottomMargin: 10 + + wrapMode: Text.WordWrap + font.pointSize: JamiTheme.tinyFontSize + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: JamiTheme.textColor + + text: textMetricsjamiNoneWarrantyHyperText.text + onLinkActivated: Qt.openUrlExternally(link) + + TextMetrics { + id: textMetricsjamiNoneWarrantyHyperText + font: jamiDeclarationHyperText.font + text: 'This program comes with absolutely no warranty.See the GNU General Public License, version 3 or later for details.' } - Label { - id: jamiSlogansText - - Layout.alignment: Qt.AlignCenter - Layout.preferredWidth: contentRect.width - Layout.preferredHeight: textMetricsjamiSlogansText.boundingRect.height - Layout.topMargin: 5 - - wrapMode: Text.WordWrap - font.pointSize: JamiTheme.textFontSize - - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - - text: textMetricsjamiSlogansText.text - color: JamiTheme.textColor - - TextMetrics { - id: textMetricsjamiSlogansText - font: jamiSlogansText.font - text: JamiStrings.slogan - } + MouseArea { + anchors.fill: parent + acceptedButtons: Qt.NoButton + cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor } + } - Label { - id: jamiDeclarationText + ProjectCreditsScrollView { + id: projectCreditsScrollView - Layout.alignment: Qt.AlignCenter - Layout.preferredWidth: contentRect.width - Layout.preferredHeight: 40 - Layout.topMargin: 5 + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: aboutPopUpScrollView.width - JamiTheme.preferredMarginSize * 2 + Layout.preferredHeight: 128 + Layout.margins: JamiTheme.preferredMarginSize + } - wrapMode: Text.WordWrap - font.pointSize: JamiTheme.textFontSize - color: JamiTheme.textColor + MaterialButton { + id: btnClose - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter + Layout.alignment: Qt.AlignHCenter + Layout.bottomMargin: JamiTheme.preferredMarginSize - // TextMetrics does not work for multi-line. - text: JamiStrings.declaration - } + preferredWidth: JamiTheme.preferredFieldWidth / 2 + preferredHeight: JamiTheme.preferredFieldHeight - Label { - id: jamiDeclarationHyperText + text: JamiStrings.close + color: enabled ? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true - Layout.alignment: Qt.AlignCenter - - // Strangely, hoveredLink works badly when width grows too large - Layout.preferredWidth: 50 - Layout.preferredHeight: textMetricsjamiDeclarationHyperText.boundingRect.height - Layout.topMargin: 5 - Layout.bottomMargin: 5 - color: JamiTheme.textColor - - font.pointSize: JamiTheme.textFontSize - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - - text: textMetricsjamiDeclarationHyperText.text - onLinkActivated: Qt.openUrlExternally(link) - - TextMetrics { - id: textMetricsjamiDeclarationHyperText - font: jamiDeclarationHyperText.font - text: 'jami.net' - } - - MouseArea { - anchors.fill: parent - - // We don't want to eat clicks on the Text. - acceptedButtons: Qt.NoButton - cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor - } - } - - Label { - id: jamiDeclarationYearText - - Layout.alignment: Qt.AlignCenter - Layout.preferredWidth: contentRect.width - Layout.preferredHeight: textMetricsjamiDeclarationYearText.boundingRect.height - Layout.bottomMargin: 5 - - font.pointSize: JamiTheme.textFontSize - color: JamiTheme.textColor - - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - - text: textMetricsjamiDeclarationYearText.text - - TextMetrics { - id: textMetricsjamiDeclarationYearText - font: jamiDeclarationYearText.font - text: JamiStrings.companyDeclarationYear - } - } - - Label { - id: jamiNoneWarrantyHyperText - - Layout.alignment: Qt.AlignCenter - Layout.preferredWidth: 300 - Layout.preferredHeight: textMetricsjamiNoneWarrantyHyperText.boundingRect.height * 2 - Layout.bottomMargin: 10 - - wrapMode: Text.WordWrap - font.pointSize: JamiTheme.tinyFontSize - - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - color: JamiTheme.textColor - - text: textMetricsjamiNoneWarrantyHyperText.text - onLinkActivated: Qt.openUrlExternally(link) - - TextMetrics { - id: textMetricsjamiNoneWarrantyHyperText - font: jamiDeclarationHyperText.font - text: 'This program comes with absolutely no warranty.See the GNU General Public License, version 3 or later for details.' - } - - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.NoButton - cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor - } - } - - ProjectCreditsScrollView { - id: projectCreditsScrollView - - Layout.alignment: Qt.AlignCenter - Layout.preferredWidth: contentRect.width - JamiTheme.preferredMarginSize * 2 - Layout.preferredHeight: 128 - Layout.margins: JamiTheme.preferredMarginSize - } - - MaterialButton { - id: btnClose - - Layout.alignment: Qt.AlignHCenter - Layout.bottomMargin: JamiTheme.preferredMarginSize - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - preferredHeight: JamiTheme.preferredFieldHeight - - text: qsTr("Close") - color: enabled ? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - outlined: true - - onClicked: { - close() - } - } + onClicked: close() } } } diff --git a/src/mainview/components/UserProfile.qml b/src/mainview/components/UserProfile.qml index 0a82fbd4..9e3e795e 100644 --- a/src/mainview/components/UserProfile.qml +++ b/src/mainview/components/UserProfile.qml @@ -24,7 +24,7 @@ import net.jami.Constants 1.1 import "../../commoncomponents" -BaseDialog { +BaseModalDialog { id: root property string convId @@ -35,13 +35,14 @@ BaseDialog { property int preferredImgSize: 80 - contentItem: Rectangle { + width: 480 + height: 480 + + popupContent: Rectangle { id: userProfileContentRect - implicitWidth: 480 - implicitHeight: 400 - color: JamiTheme.backgroundColor + radius: JamiTheme.modalPopupRadius GridLayout { id: userProfileDialogLayout @@ -143,7 +144,7 @@ BaseDialog { id: textMetricsContactDisplayNameText font: contactDisplayName.font text: registeredNameText - elideWidth: userProfileContentRect.width-200 + elideWidth: userProfileContentRect.width - 200 elide: Qt.ElideMiddle } } @@ -236,9 +237,7 @@ BaseDialog { text: JamiStrings.close - onClicked: { - close() - } + onClicked: close() } } } diff --git a/src/mainview/components/WelcomePageQrDialog.qml b/src/mainview/components/WelcomePageQrDialog.qml index 5efd84cb..0e877fa0 100644 --- a/src/mainview/components/WelcomePageQrDialog.qml +++ b/src/mainview/components/WelcomePageQrDialog.qml @@ -19,33 +19,28 @@ import QtQuick import net.jami.Adapters 1.1 +import net.jami.Constants 1.1 import "../../commoncomponents" -ModalPopup { +BaseModalDialog { id: root - modal: true - //Content height + margin. - property int size: userQrImage.height + 30 + property int size: JamiTheme.qrCodeImageSize + 30 + width: size height: size - Item { - anchors.fill: parent + backgroundColor: JamiTheme.whiteColor - Image { - id: userQrImage + popupContentPreferredHeight: JamiTheme.qrCodeImageSize + popupContentPreferredWidth: JamiTheme.qrCodeImageSize + popupContent: Image { + id: userQrImage - anchors.centerIn: parent - - width: 256 - height: 256 - smooth: false - - fillMode: Image.PreserveAspectFit - source: "image://qrImage/account_" + CurrentAccount.id - } + smooth: false + fillMode: Image.PreserveAspectFit + source: "image://qrImage/account_" + CurrentAccount.id } } diff --git a/src/settingsview/components/CurrentAccountSettings.qml b/src/settingsview/components/CurrentAccountSettings.qml index d71b5cc3..636808d2 100644 --- a/src/settingsview/components/CurrentAccountSettings.qml +++ b/src/settingsview/components/CurrentAccountSettings.qml @@ -101,7 +101,7 @@ Rectangle { PasswordDialog { id: passwordDialog - onDoneSignal: { + onDoneSignal: function (success, currentPurpose) { var title = success ? qsTr("Success") : qsTr("Error") var info diff --git a/src/settingsview/components/LinkDeviceDialog.qml b/src/settingsview/components/LinkDeviceDialog.qml index 1cdff81e..22468695 100644 --- a/src/settingsview/components/LinkDeviceDialog.qml +++ b/src/settingsview/components/LinkDeviceDialog.qml @@ -27,329 +27,326 @@ import net.jami.Constants 1.1 import "../../commoncomponents" -BaseDialog { +BaseModalDialog { id: root signal accepted - function openLinkDeviceDialog() { - infoLabel.text = JamiStrings.pinTimerInfos - passwordEdit.clear() - - open() - - if(AccountAdapter.hasPassword()) { - stackedWidget.currentIndex = enterPasswordPage.pageIndex - passwordEdit.forceActiveFocus() - } else { - setGeneratingPage() - } - } - - function setGeneratingPage() { - if(passwordEdit.length === 0 && AccountAdapter.hasPassword()){ - setExportPage(NameDirectory.ExportOnRingStatus.WRONG_PASSWORD, "") - return - } - - stackedWidget.currentIndex = exportingSpinnerPage.pageIndex - spinnerMovie.playing = true - - timerForExport.restart() - } - - function setExportPage(status, pin) { - if (status === NameDirectory.ExportOnRingStatus.SUCCESS) { - infoLabel.success = true - infoLabelsRowLayout.visible = true - infoLabel.text = JamiStrings.pinTimerInfos - exportedPIN.text = pin - } else { - infoLabel.success = false - infoLabelsRowLayout.visible = false - - switch(status) { - case NameDirectory.ExportOnRingStatus.WRONG_PASSWORD: - infoLabel.text = JamiStrings.incorrectPassword - break - case NameDirectory.ExportOnRingStatus.NETWORK_ERROR: - infoLabel.text = JamiStrings.linkDeviceNetWorkError - break - case NameDirectory.ExportOnRingStatus.INVALID: - infoLabel.text = JamiStrings.somethingWentWrong - break - } - } - stackedWidget.currentIndex = exportingInfoPage.pageIndex - } - title: JamiStrings.addDevice - Timer{ - id: timerForExport + width: JamiTheme.preferredDialogWidth + height: JamiTheme.preferredDialogHeight - repeat: false - interval: 200 + popupContent: StackLayout { + id: stackedWidget - onTriggered: { - AccountAdapter.model.exportOnRing(LRCInstance.currentAccountId, - passwordEdit.text) + function setGeneratingPage() { + if(passwordEdit.length === 0 && AccountAdapter.hasPassword()){ + setExportPage(NameDirectory.ExportOnRingStatus.WRONG_PASSWORD, "") + return + } + + stackedWidget.currentIndex = exportingSpinnerPage.pageIndex + spinnerMovie.playing = true + + timerForExport.restart() } - } - Connections { - target: NameDirectory + function setExportPage(status, pin) { + if (status === NameDirectory.ExportOnRingStatus.SUCCESS) { + infoLabel.success = true + infoLabelsRowLayout.visible = true + infoLabel.text = JamiStrings.pinTimerInfos + exportedPIN.text = pin + } else { + infoLabel.success = false + infoLabelsRowLayout.visible = false - function onExportOnRingEnded(status, pin) { - setExportPage(status, pin) + switch(status) { + case NameDirectory.ExportOnRingStatus.WRONG_PASSWORD: + infoLabel.text = JamiStrings.incorrectPassword + break + case NameDirectory.ExportOnRingStatus.NETWORK_ERROR: + infoLabel.text = JamiStrings.linkDeviceNetWorkError + break + case NameDirectory.ExportOnRingStatus.INVALID: + infoLabel.text = JamiStrings.somethingWentWrong + break + } + } + stackedWidget.currentIndex = exportingInfoPage.pageIndex } - } - contentItem: Rectangle { - id: linkDeviceContentRect + Timer{ + id: timerForExport - color: JamiTheme.secondaryBackgroundColor - implicitWidth: JamiTheme.preferredDialogWidth - implicitHeight: JamiTheme.preferredDialogHeight + repeat: false + interval: 200 - StackLayout { - id: stackedWidget + onTriggered: { + AccountAdapter.model.exportOnRing(LRCInstance.currentAccountId, + passwordEdit.text) + } + } - anchors.centerIn: parent - anchors.fill: parent - anchors.margins: JamiTheme.preferredMarginSize + Connections { + target: NameDirectory - // Index = 0 - Item { - id: enterPasswordPage + function onExportOnRingEnded(status, pin) { + stackedWidget.setExportPage(status, pin) + } + } - readonly property int pageIndex: 0 + onVisibleChanged: { + if (visible) { + infoLabel.text = JamiStrings.pinTimerInfos + passwordEdit.clear() - ColumnLayout { - anchors.fill: parent + if(AccountAdapter.hasPassword()) { + stackedWidget.currentIndex = enterPasswordPage.pageIndex + passwordEdit.forceActiveFocus() + } else { + setGeneratingPage() + } + } + } + // Index = 0 + Item { + id: enterPasswordPage + + readonly property int pageIndex: 0 + + ColumnLayout { + anchors.fill: parent + + spacing: 16 + + Label { + Layout.alignment: Qt.AlignHCenter + + text: JamiStrings.enterAccountPassword + color: JamiTheme.textColor + font.pointSize: JamiTheme.textFontSize + font.kerning: true + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + + MaterialLineEdit { + id: passwordEdit + + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth + Layout.preferredHeight: 48 + + echoMode: TextInput.Password + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + + placeholderText: JamiStrings.enterCurrentPassword + + onTextChanged: { + btnConfirm.enabled = text.length > 0 + } + + onAccepted: btnConfirm.clicked() + } + + RowLayout { + Layout.alignment: Qt.AlignCenter + Layout.fillWidth: true spacing: 16 - Label { + MaterialButton { + id: btnConfirm + Layout.alignment: Qt.AlignHCenter - text: JamiStrings.enterAccountPassword + preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 + preferredHeight: JamiTheme.preferredFieldHeight + + color: enabled? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true + enabled: false + + text: JamiStrings.exportAccount + + onClicked: stackedWidget.setGeneratingPage() + } + + MaterialButton { + id: btnCancel + + Layout.alignment: Qt.AlignHCenter + + preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 + preferredHeight: JamiTheme.preferredFieldHeight + + color: JamiTheme.buttonTintedBlack + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true + enabled: true + + text: JamiStrings.optionCancel + + onClicked: close() + } + } + } + } + + // Index = 1 + Item { + id: exportingSpinnerPage + + readonly property int pageIndex: 1 + + ColumnLayout { + anchors.fill: parent + + spacing: 16 + + Label { + Layout.alignment: Qt.AlignCenter + + text: JamiStrings.backupAccount + color: JamiTheme.textColor + font.pointSize: JamiTheme.headerFontSize + font.kerning: true + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } + + AnimatedImage { + id: spinnerMovie + + Layout.alignment: Qt.AlignCenter + + Layout.preferredWidth: 30 + Layout.preferredHeight: 30 + + source: JamiResources.jami_rolling_spinner_gif + playing: visible + fillMode: Image.PreserveAspectFit + mipmap: true + } + } + } + + // Index = 2 + Item { + id: exportingInfoPage + + readonly property int pageIndex: 2 + + ColumnLayout { + anchors.fill: parent + + spacing: 16 + + Item { + id: infoLabelsRowLayout + + Layout.alignment: Qt.AlignCenter + Layout.margins: JamiTheme.preferredMarginSize + Layout.preferredWidth: yourPinLabel.contentWidth + + exportedPIN.contentWidth + 5 + Label { + id: yourPinLabel + + anchors.left: infoLabelsRowLayout.left + anchors.verticalCenter: infoLabelsRowLayout.verticalCenter + + text: JamiStrings.yourPinIs color: JamiTheme.textColor - font.pointSize: JamiTheme.textFontSize + font.pointSize: JamiTheme.headerFontSize font.kerning: true horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter } MaterialLineEdit { - id: passwordEdit + id: exportedPIN - Layout.alignment: Qt.AlignCenter - Layout.preferredWidth: JamiTheme.preferredFieldWidth - Layout.preferredHeight: 48 + anchors.left: yourPinLabel.right + anchors.leftMargin: 5 + anchors.verticalCenter: infoLabelsRowLayout.verticalCenter - echoMode: TextInput.Password - horizontalAlignment: Text.AlignLeft - verticalAlignment: Text.AlignVCenter + padding: 0 - placeholderText: JamiStrings.enterCurrentPassword + text: JamiStrings.pin + wrapMode: Text.NoWrap - onTextChanged: { - btnConfirm.enabled = text.length > 0 - } - - onAccepted: btnConfirm.clicked() - } - - RowLayout { - Layout.alignment: Qt.AlignCenter - Layout.fillWidth: true - spacing: 16 - - MaterialButton { - id: btnConfirm - - Layout.alignment: Qt.AlignHCenter - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - preferredHeight: JamiTheme.preferredFieldHeight - - color: enabled? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - outlined: true - enabled: false - - text: JamiStrings.exportAccount - - onClicked: setGeneratingPage() - } - - MaterialButton { - id: btnCancel - - Layout.alignment: Qt.AlignHCenter - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - preferredHeight: JamiTheme.preferredFieldHeight - - color: JamiTheme.buttonTintedBlack - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - outlined: true - enabled: true - - text: JamiStrings.optionCancel - - onClicked: close() - } - } - } - } - - // Index = 1 - Item { - id: exportingSpinnerPage - - readonly property int pageIndex: 1 - - ColumnLayout { - anchors.fill: parent - - spacing: 16 - - Label { - Layout.alignment: Qt.AlignCenter - - text: JamiStrings.backupAccount color: JamiTheme.textColor + selectByMouse: true + readOnly: true font.pointSize: JamiTheme.headerFontSize font.kerning: true - horizontalAlignment: Text.AlignLeft - verticalAlignment: Text.AlignVCenter - } - - AnimatedImage { - id: spinnerMovie - - Layout.alignment: Qt.AlignCenter - - Layout.preferredWidth: 30 - Layout.preferredHeight: 30 - - source: JamiResources.jami_rolling_spinner_gif - playing: visible - fillMode: Image.PreserveAspectFit - mipmap: true - } - } - } - - // Index = 2 - Item { - id: exportingInfoPage - - readonly property int pageIndex: 2 - - ColumnLayout { - anchors.fill: parent - - spacing: 16 - - RowLayout { - id: infoLabelsRowLayout - - Layout.alignment: Qt.AlignCenter - Layout.fillWidth: true - Layout.margins: JamiTheme.preferredMarginSize - - spacing: 16 - - Label { - id: yourPinLabel - - Layout.alignment: Qt.AlignHCenter - - text: JamiStrings.yourPinIs - color: JamiTheme.textColor - font.pointSize: JamiTheme.headerFontSize - font.kerning: true - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - - MaterialLineEdit { - id: exportedPIN - - Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: fieldLayoutWidth - - text: JamiStrings.pin - color: JamiTheme.textColor - selectByMouse: true - readOnly: true - font.pointSize: JamiTheme.headerFontSize - font.kerning: true - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - } - - Label { - id: infoLabel - - property bool success: false - property int borderWidth : success? 1 : 0 - property int borderRadius : success? 15 : 0 - property string backgroundColor : success? "whitesmoke" : "transparent" - property string borderColor : success? "lightgray" : "transparent" - - Layout.maximumWidth: linkDeviceContentRect.width - - JamiTheme.preferredMarginSize * 2 - - Layout.alignment: Qt.AlignCenter - - color: success ? JamiTheme.successLabelColor : JamiTheme.redColor - padding: success ? 8 : 0 - - wrapMode: Text.Wrap - text: JamiStrings.pinTimerInfos - font.pointSize: JamiTheme.textFontSize - font.kerning: true horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter - - background: Rectangle { - id: infoLabelBackground - - border.width: infoLabel.borderWidth - border.color: infoLabel.borderColor - radius: infoLabel.borderRadius - color: JamiTheme.secondaryBackgroundColor - } } + } - MaterialButton { - id: btnCloseExportDialog + Label { + id: infoLabel - Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom + property bool success: false + property int borderWidth : success? 1 : 0 + property int borderRadius : success? 15 : 0 + property string backgroundColor : success? "whitesmoke" : "transparent" + property string borderColor : success? "lightgray" : "transparent" - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - preferredHeight: JamiTheme.preferredFieldHeight + Layout.maximumWidth: stackedWidget.width - + JamiTheme.preferredMarginSize * 2 - color: enabled ? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - outlined: true - enabled: true + Layout.alignment: Qt.AlignCenter - text: JamiStrings.close + color: success ? JamiTheme.successLabelColor : JamiTheme.redColor + padding: success ? 8 : 0 - onClicked: { - if (infoLabel.success) - accepted() - close() - } + wrapMode: Text.Wrap + text: JamiStrings.pinTimerInfos + font.pointSize: success ? JamiTheme.textFontSize : + JamiTheme.textFontSize + 3 + font.kerning: true + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + + background: Rectangle { + id: infoLabelBackground + + border.width: infoLabel.borderWidth + border.color: infoLabel.borderColor + radius: infoLabel.borderRadius + color: JamiTheme.secondaryBackgroundColor + } + } + + MaterialButton { + id: btnCloseExportDialog + + Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom + Layout.bottomMargin: JamiTheme.preferredMarginSize + + preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 + preferredHeight: JamiTheme.preferredFieldHeight + + color: enabled ? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true + enabled: true + + text: JamiStrings.close + + onClicked: { + if (infoLabel.success) + accepted() + close() } } } diff --git a/src/settingsview/components/LinkedDevices.qml b/src/settingsview/components/LinkedDevices.qml index a35eaced..b897a000 100644 --- a/src/settingsview/components/LinkedDevices.qml +++ b/src/settingsview/components/LinkedDevices.qml @@ -48,7 +48,9 @@ ColumnLayout { RevokeDevicePasswordDialog{ id: revokeDevicePasswordDialog - onRevokeDeviceWithPassword: deviceItemListModel.sourceModel.revokeDevice(idOfDevice, password) + onRevokeDeviceWithPassword: function(idOfDevice, password) { + deviceItemListModel.sourceModel.revokeDevice(idOfDevice, password) + } } SimpleMessageDialog { @@ -121,6 +123,6 @@ ColumnLayout { text: JamiStrings.linkAnotherDevice - onClicked: linkDeviceDialog.openLinkDeviceDialog() + onClicked: linkDeviceDialog.open() } } diff --git a/src/settingsview/components/NameRegistrationDialog.qml b/src/settingsview/components/NameRegistrationDialog.qml index 96d62ed7..53bc51e7 100644 --- a/src/settingsview/components/NameRegistrationDialog.qml +++ b/src/settingsview/components/NameRegistrationDialog.qml @@ -27,7 +27,7 @@ import net.jami.Constants 1.1 import "../../commoncomponents" -BaseDialog { +BaseModalDialog { id: root property string registerdName : "" @@ -36,224 +36,139 @@ BaseDialog { function openNameRegistrationDialog(registerNameIn) { registerdName = registerNameIn - lblRegistrationError.text = JamiStrings.somethingWentWrong - passwordEdit.clear() open() - - if(AccountAdapter.hasPassword()){ - stackedWidget.currentIndex = nameRegisterEnterPasswordPage.pageIndex - passwordEdit.forceActiveFocus() - } else { - startRegistration() - } } - function startRegistration() { - stackedWidget.currentIndex = nameRegisterSpinnerPage.pageIndex - spinnerMovie.visible = true - - timerForStartRegistration.restart() - } - - Timer { - id: timerForStartRegistration - - interval: 100 - repeat: false - - onTriggered: { - AccountAdapter.model.registerName(LRCInstance.currentAccountId, - passwordEdit.text, registerdName) - } - } - - Connections{ - target: NameDirectory - - function onNameRegistrationEnded(status, name) { - switch(status) { - case NameDirectory.RegisterNameStatus.SUCCESS: - accepted() - close() - return - case NameDirectory.RegisterNameStatus.WRONG_PASSWORD: - lblRegistrationError.text = JamiStrings.incorrectPassword - break - case NameDirectory.RegisterNameStatus.NETWORK_ERROR: - lblRegistrationError.text = JamiStrings.networkError - break - default: - break - } - - stackedWidget.currentIndex = nameRegisterErrorPage.pageIndex - } - } + width: JamiTheme.preferredDialogWidth + height: JamiTheme.preferredDialogHeight title: JamiStrings.setUsername - contentItem: Rectangle { - id: nameRegistrationContentRect + popupContent: StackLayout { + id: stackedWidget - implicitWidth: JamiTheme.preferredDialogWidth - implicitHeight: JamiTheme.preferredDialogHeight + function startRegistration() { + stackedWidget.currentIndex = nameRegisterSpinnerPage.pageIndex + spinnerMovie.visible = true - color: JamiTheme.primaryBackgroundColor + timerForStartRegistration.restart() + } - StackLayout { - id: stackedWidget + Timer { + id: timerForStartRegistration - anchors.fill: parent - anchors.margins: JamiTheme.preferredMarginSize + interval: 100 + repeat: false - // Index = 0 - Item { - id: nameRegisterEnterPasswordPage + onTriggered: { + AccountAdapter.model.registerName(LRCInstance.currentAccountId, + passwordEdit.text, registerdName) + } + } - readonly property int pageIndex: 0 + Connections{ + target: NameDirectory - ColumnLayout { - anchors.fill: parent + function onNameRegistrationEnded(status, name) { + switch(status) { + case NameDirectory.RegisterNameStatus.SUCCESS: + accepted() + close() + return + case NameDirectory.RegisterNameStatus.WRONG_PASSWORD: + lblRegistrationError.text = JamiStrings.incorrectPassword + break + case NameDirectory.RegisterNameStatus.NETWORK_ERROR: + lblRegistrationError.text = JamiStrings.networkError + break + default: + break + } + stackedWidget.currentIndex = nameRegisterErrorPage.pageIndex + } + } + + onVisibleChanged: { + if (visible) { + lblRegistrationError.text = JamiStrings.somethingWentWrong + passwordEdit.clear() + + if (AccountAdapter.hasPassword()){ + stackedWidget.currentIndex = nameRegisterEnterPasswordPage.pageIndex + passwordEdit.forceActiveFocus() + } else { + startRegistration() + } + } + } + + // Index = 0 + Item { + id: nameRegisterEnterPasswordPage + + readonly property int pageIndex: 0 + + ColumnLayout { + anchors.fill: parent + + spacing: 16 + + Label { + Layout.alignment: Qt.AlignCenter + + text: JamiStrings.enterAccountPassword + color: JamiTheme.textColor + font.pointSize: JamiTheme.textFontSize + font.kerning: true + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + + MaterialLineEdit { + id: passwordEdit + + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth + Layout.preferredHeight: 48 + + 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 - Label { - Layout.alignment: Qt.AlignCenter + MaterialButton { + id: btnRegister - text: JamiStrings.enterAccountPassword - color: JamiTheme.textColor - font.pointSize: JamiTheme.textFontSize - font.kerning: true - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - - MaterialLineEdit { - id: passwordEdit - - Layout.alignment: Qt.AlignCenter - Layout.preferredWidth: JamiTheme.preferredFieldWidth - Layout.preferredHeight: 48 - - 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 + preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 + preferredHeight: JamiTheme.preferredFieldHeight - Layout.alignment: Qt.AlignHCenter + color: enabled? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true + enabled: false - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - preferredHeight: JamiTheme.preferredFieldHeight + text: JamiStrings.register - color: enabled? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - outlined: true - enabled: false - - text: JamiStrings.register - - onClicked: startRegistration() - } - - MaterialButton { - id: btnCancel - - Layout.alignment: Qt.AlignHCenter - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - preferredHeight: JamiTheme.preferredFieldHeight - - color: JamiTheme.buttonTintedBlack - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - outlined: true - - text: JamiStrings.optionCancel - - onClicked: close() - } - } - } - } - - // Index = 1 - Item { - id: nameRegisterSpinnerPage - - readonly property int pageIndex: 1 - - ColumnLayout { - anchors.fill: parent - - spacing: 16 - - Label { - Layout.alignment: Qt.AlignCenter - - text: JamiStrings.registeringName - color: JamiTheme.textColor - font.pointSize: JamiTheme.textFontSize - font.kerning: true - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - - AnimatedImage { - id: spinnerMovie - - Layout.alignment: Qt.AlignCenter - - Layout.preferredWidth: 30 - Layout.preferredHeight: 30 - - source: JamiResources.jami_rolling_spinner_gif - playing: visible - fillMode: Image.PreserveAspectFit - mipmap: true - } - } - } - - // Index = 2 - Item { - id: nameRegisterErrorPage - - readonly property int pageIndex: 2 - - ColumnLayout { - anchors.fill: parent - - spacing: 16 - - Label { - id: lblRegistrationError - - Layout.alignment: Qt.AlignCenter - text: JamiStrings.somethingWentWrong - font.pointSize: JamiTheme.textFontSize - font.kerning: true - color: JamiTheme.redColor - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter + onClicked: stackedWidget.startRegistration() } MaterialButton { - id: btnClose + id: btnCancel - Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom + Layout.alignment: Qt.AlignHCenter preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 preferredHeight: JamiTheme.preferredFieldHeight @@ -263,12 +178,94 @@ BaseDialog { pressedColor: JamiTheme.buttonTintedBlackPressed outlined: true - text: JamiStrings.close + text: JamiStrings.optionCancel onClicked: close() } } } } + + // Index = 1 + Item { + id: nameRegisterSpinnerPage + + readonly property int pageIndex: 1 + + ColumnLayout { + anchors.fill: parent + + spacing: 16 + + Label { + Layout.alignment: Qt.AlignCenter + + text: JamiStrings.registeringName + color: JamiTheme.textColor + font.pointSize: JamiTheme.textFontSize + 3 + font.kerning: true + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + + AnimatedImage { + id: spinnerMovie + + Layout.alignment: Qt.AlignCenter + + Layout.preferredWidth: 30 + Layout.preferredHeight: 30 + + source: JamiResources.jami_rolling_spinner_gif + playing: visible + fillMode: Image.PreserveAspectFit + mipmap: true + } + } + } + + // Index = 2 + Item { + id: nameRegisterErrorPage + + readonly property int pageIndex: 2 + + ColumnLayout { + anchors.fill: parent + + spacing: 16 + + Label { + id: lblRegistrationError + + Layout.alignment: Qt.AlignCenter + text: JamiStrings.somethingWentWrong + font.pointSize: JamiTheme.textFontSize + 3 + font.kerning: true + color: JamiTheme.redColor + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + + MaterialButton { + id: btnClose + + Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom + Layout.bottomMargin: JamiTheme.preferredMarginSize + + preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 + preferredHeight: JamiTheme.preferredFieldHeight + + color: JamiTheme.buttonTintedBlack + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true + + text: JamiStrings.close + + onClicked: close() + } + } + } } } diff --git a/src/settingsview/components/RevokeDevicePasswordDialog.qml b/src/settingsview/components/RevokeDevicePasswordDialog.qml index e5e4362c..cc3a56c9 100644 --- a/src/settingsview/components/RevokeDevicePasswordDialog.qml +++ b/src/settingsview/components/RevokeDevicePasswordDialog.qml @@ -25,7 +25,7 @@ import net.jami.Constants 1.1 import "../../commoncomponents" -BaseDialog { +BaseModalDialog { id: root property string deviceId : "" @@ -34,105 +34,100 @@ BaseDialog { function openRevokeDeviceDialog(deviceIdIn) { deviceId = deviceIdIn - passwordEdit.clear() + open() } - title: qsTr("Remove device") + width: JamiTheme.preferredDialogWidth + height: JamiTheme.preferredDialogHeight - contentItem: Rectangle { - id: revokeDeviceContentRect + title: JamiStrings.removeDevice - color: JamiTheme.secondaryBackgroundColor - implicitWidth: JamiTheme.preferredDialogWidth - implicitHeight: JamiTheme.preferredDialogHeight + popupContent: ColumnLayout { + id: revokeDeviceContentColumnLayout - ColumnLayout { - anchors.centerIn: parent - anchors.fill: parent - anchors.margins: JamiTheme.preferredMarginSize - spacing: 16 + spacing: 16 - Label { - id: labelDeletion + Label { + id: labelDeletion - Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: revokeDeviceContentRect.width - JamiTheme.preferredMarginSize * 2 + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: revokeDeviceContentColumnLayout.width - + JamiTheme.preferredMarginSize * 2 - color: JamiTheme.textColor - text: JamiStrings.confirmRemoval - font.pointSize: JamiTheme.textFontSize - font.kerning: true - wrapMode: Text.Wrap + text: JamiStrings.confirmRemoval + color: JamiTheme.textColor + font.pointSize: JamiTheme.textFontSize + font.kerning: true + wrapMode: Text.Wrap - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - - MaterialLineEdit { - id: passwordEdit - - Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: JamiTheme.preferredFieldWidth - Layout.preferredHeight: visible ? 48 : 0 - - echoMode: TextInput.Password - placeholderText: JamiStrings.enterCurrentPassword - - onTextChanged: { - btnRemove.enabled = text.length > 0 - } - } - - RowLayout { - spacing: 16 - Layout.alignment: Qt.AlignHCenter - - Layout.fillWidth: true - - MaterialButton { - id: btnRemove - - Layout.alignment: Qt.AlignHCenter - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - preferredHeight: JamiTheme.preferredFieldHeight - - color: enabled? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - outlined: true - enabled: false - - text: qsTr("Remove") - - onClicked: { - revokeDeviceWithPassword(deviceId, passwordEdit.text) - close() - } - } - - MaterialButton { - id: btnCancel - - Layout.alignment: Qt.AlignHCenter - - preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 - preferredHeight: JamiTheme.preferredFieldHeight - - color: JamiTheme.buttonTintedBlack - hoveredColor: JamiTheme.buttonTintedBlackHovered - pressedColor: JamiTheme.buttonTintedBlackPressed - outlined: true - enabled: true - - text: qsTr("Cancel") - - onClicked: { - close() - } - } - } + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter } + + MaterialLineEdit { + id: passwordEdit + + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: JamiTheme.preferredFieldWidth + Layout.preferredHeight: visible ? 48 : 0 + + echoMode: TextInput.Password + placeholderText: JamiStrings.enterCurrentPassword + + onVisibleChanged: passwordEdit.clear() + + onTextChanged: { + btnRemove.enabled = text.length > 0 + } + } + + RowLayout { + spacing: 16 + Layout.alignment: Qt.AlignHCenter + + Layout.fillWidth: true + + MaterialButton { + id: btnRemove + + Layout.alignment: Qt.AlignHCenter + + preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 + preferredHeight: JamiTheme.preferredFieldHeight + + color: enabled? JamiTheme.buttonTintedBlack : JamiTheme.buttonTintedGrey + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true + enabled: false + + text: qsTr("Remove") + + onClicked: { + revokeDeviceWithPassword(deviceId, passwordEdit.text) + close() + } + } + + MaterialButton { + id: btnCancel + + Layout.alignment: Qt.AlignHCenter + + preferredWidth: JamiTheme.preferredFieldWidth / 2 - 8 + preferredHeight: JamiTheme.preferredFieldHeight + + color: JamiTheme.buttonTintedBlack + hoveredColor: JamiTheme.buttonTintedBlackHovered + pressedColor: JamiTheme.buttonTintedBlackPressed + outlined: true + enabled: true + + text: JamiStrings.optionCancel + + onClicked: close() + } + } } } diff --git a/src/wizardview/components/BackupKeyPage.qml b/src/wizardview/components/BackupKeyPage.qml index a73d2f6f..1f22da0d 100644 --- a/src/wizardview/components/BackupKeyPage.qml +++ b/src/wizardview/components/BackupKeyPage.qml @@ -59,8 +59,8 @@ Rectangle { buttonTitles: [JamiStrings.optionOk] buttonStyles: [SimpleMessageDialog.ButtonStyle.TintedBlue] - onVisibleChanged: { - if (title === JamiStrings.success && !visible) + onClosed: { + if (title === JamiStrings.success) WizardViewStepModel.nextStep() } } @@ -71,7 +71,9 @@ Rectangle { visible: false purpose: PasswordDialog.ExportAccount - onDoneSignal: showBackupStatusDialog(success) + onDoneSignal: function (success) { + showBackupStatusDialog(success) + } } // JamiFileDialog for exporting account