diff --git a/qml.qrc b/qml.qrc index 1d6af2c7d9905e71ac26262461604675faa547cb..db29de3b8b1abe9a38e05d3960851ee564a5efbe 100644 --- a/qml.qrc +++ b/qml.qrc @@ -87,7 +87,6 @@ <file>src/app/wizardview/components/CreateAccountPage.qml</file> <file>src/app/wizardview/components/CreateSIPAccountPage.qml</file> <file>src/app/wizardview/components/ImportFromBackupPage.qml</file> - <file>src/app/wizardview/components/BackupKeyPage.qml</file> <file>src/app/wizardview/components/ImportFromDevicePage.qml</file> <file>src/app/wizardview/components/ConnectToAccountManagerPage.qml</file> <file>src/app/wizardview/components/ProfilePage.qml</file> @@ -201,5 +200,8 @@ <file>src/app/wizardview/components/AdvancedAccountSettings.qml</file> <file>src/app/commoncomponents/InfoBox.qml</file> <file>src/app/mainview/components/TipBox.qml</file> + <file>src/app/mainview/components/CustomizeTipBox.qml</file> + <file>src/app/mainview/components/BackupTipBox.qml</file> + <file>src/app/mainview/components/InformativeTipBox.qml</file> </qresource> </RCC> diff --git a/src/app/constant/JamiStrings.qml b/src/app/constant/JamiStrings.qml index d9bd827be400dc1a03943b12397654064d307cd5..b204361531e68e04fb07fe71a71ee142b405ca72 100644 --- a/src/app/constant/JamiStrings.qml +++ b/src/app/constant/JamiStrings.qml @@ -204,12 +204,12 @@ Item { property string noVideo: qsTr("no video") // BackupKeyPage + property string whyBackupAccount: qsTr("Why should I back-up this account?") property string backupAccountInfos: qsTr("Your account only exists on this device. " + "If you lose your device or uninstall the application, " + "your account will be deleted and CANNOT be recovered. " + - "You can back up your account now or later.") + "You can back up your account now or later (in the Account Settings).") property string backupAccountHere: qsTr("Back up account here") - property string backupAccount: qsTr("Back up your account!") property string backupAccountBtn: qsTr("Back up account") property string skip: qsTr("Skip") property string success: qsTr("Success") diff --git a/src/app/mainview/components/BackupTipBox.qml b/src/app/mainview/components/BackupTipBox.qml new file mode 100644 index 0000000000000000000000000000000000000000..99dfb5a70d0570d059187f5b5963f2b5b43ed68f --- /dev/null +++ b/src/app/mainview/components/BackupTipBox.qml @@ -0,0 +1,162 @@ +/* + * Copyright (C) 2022 Savoir-faire Linux Inc. + * + * 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 <https://www.gnu.org/licenses/>. + */ + +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import Qt.labs.platform + +import net.jami.Models 1.1 +import net.jami.Adapters 1.1 +import net.jami.Constants 1.1 + +import "../../commoncomponents" + +Item { + id: root + width: parent.width + height: backupLayout.height + + signal ignore + + PasswordDialog { + id: passwordDialog + + visible: false + purpose: PasswordDialog.ExportAccount + + onDoneSignal: function (success) { + root.ignore() + } + } + + // JamiFileDialog for exporting account + JamiFileDialog { + id: exportDialog + + mode: JamiFileDialog.SaveFile + + title: JamiStrings.backupAccountHere + folder: StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/Desktop" + + nameFilters: [JamiStrings.jamiArchiveFiles, JamiStrings.allFiles] + + onAccepted: { + // Is there password? If so, go to password dialog, else, go to following directly + if (AccountAdapter.hasPassword()) { + passwordDialog.path = UtilsAdapter.getAbsPath(file) + passwordDialog.open() + } else { + if (file.toString().length > 0) + root.ignore() + } + } + + onVisibleChanged: { + if (!visible) { + rejected() + } + } + + onRejected: { + backupBtn.forceActiveFocus() + } + } + + ColumnLayout { + id: backupLayout + + anchors.top: parent.top + width: parent.width + + RowLayout { + + Layout.leftMargin: 15 + Layout.alignment: Qt.AlignLeft + + ResponsiveImage { + id: icon + + visible: !opened + + Layout.alignment: Qt.AlignLeft + Layout.topMargin: 5 + Layout.preferredWidth: 26 + Layout.preferredHeight: 26 + + containerHeight: Layout.preferredHeight + containerWidth: Layout.preferredWidth + + source: JamiResources.noun_paint_svg + color: "#005699" + } + + Label { + text: JamiStrings.backupAccountBtn + color: JamiTheme.textColor + font.weight: Font.Medium + Layout.topMargin: 5 + visible: !opened + Layout.alignment: Qt.AlignLeft + Layout.leftMargin: 5 + font.pixelSize: JamiTheme.tipBoxTitleFontSize + } + } + + Text { + + Layout.preferredWidth: 170 + Layout.leftMargin: 20 + Layout.topMargin: 8 + Layout.bottomMargin: 15 + font.pixelSize: JamiTheme.tipBoxContentFontSize + visible: !opened + wrapMode: Text.WordWrap + font.weight: Font.Normal + text: JamiStrings.whyBackupAccount + color: JamiTheme.textColor + } + + Text { + Layout.preferredWidth: root.width - 32 + Layout.leftMargin: 20 + Layout.topMargin: 20 + font.pixelSize: JamiTheme.tipBoxContentFontSize + visible: opened + wrapMode: Text.WordWrap + text: JamiStrings.backupAccountInfos + color: JamiTheme.textColor + } + + MaterialButton { + id: backupBtn + + Layout.alignment: Qt.AlignCenter + + preferredWidth: parent.width + visible: opened + + text: JamiStrings.backupAccountBtn + autoAccelerator: true + color: JamiTheme.buttonTintedGrey + hoveredColor: JamiTheme.buttonTintedGreyHovered + pressedColor: JamiTheme.buttonTintedGreyPressed + + onClicked: exportDialog.open() + } + } +} \ No newline at end of file diff --git a/src/app/mainview/components/CustomizeTipBox.qml b/src/app/mainview/components/CustomizeTipBox.qml new file mode 100644 index 0000000000000000000000000000000000000000..aaa3165fed2d16d186f11cc54e3ab43824edcaef --- /dev/null +++ b/src/app/mainview/components/CustomizeTipBox.qml @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2022 Savoir-faire Linux Inc. + * + * 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 <https://www.gnu.org/licenses/>. + */ + +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts + +import net.jami.Models 1.1 +import net.jami.Adapters 1.1 +import net.jami.Constants 1.1 + +import "../../commoncomponents" + +ColumnLayout { + + width: parent.width + + + RowLayout { + + Layout.leftMargin: 15 + Layout.alignment: Qt.AlignLeft + + ResponsiveImage { + id: icon + + visible: !opened + + Layout.alignment: Qt.AlignLeft + Layout.topMargin: 5 + Layout.preferredWidth: 26 + Layout.preferredHeight: 26 + + containerHeight: Layout.preferredHeight + containerWidth: Layout.preferredWidth + + source: JamiResources.noun_paint_svg + color: "#005699" + } + + Label { + text: JamiStrings.customize + color: JamiTheme.textColor + font.weight: Font.Medium + Layout.topMargin: 5 + visible: !opened + Layout.alignment: Qt.AlignLeft + Layout.leftMargin: 5 + font.pixelSize: JamiTheme.tipBoxTitleFontSize + } + } + + Text { + + Layout.preferredWidth: 170 + Layout.leftMargin: 20 + Layout.topMargin: 8 + Layout.bottomMargin: 15 + font.pixelSize: JamiTheme.tipBoxContentFontSize + visible: !opened + wrapMode: Text.WordWrap + font.weight: Font.Normal + text: JamiStrings.customizeText + color: JamiTheme.textColor + } + + + PhotoboothView { + id: setAvatarWidget + Layout.preferredWidth: JamiTheme.accountListAvatarSize + Layout.preferredHeight: JamiTheme.accountListAvatarSize + Layout.topMargin: 10 + Layout.alignment: Qt.AlignHCenter + darkTheme: UtilsAdapter.luma(JamiTheme.primaryBackgroundColor) + visible: opened + enabled: true + buttonSize: 35 + imageId: CurrentAccount.id + avatarSize: 53 + cancelButton: false + + } + + EditableLineEdit { + + id: displayNameLineEdit + + visible: opened + + Layout.alignment: Qt.AlignCenter + Layout.preferredWidth: root.width - 32 + + text: CurrentAccount.alias + placeholderText: JamiStrings.enterNickname + color: JamiTheme.textColor + + fontSize: JamiTheme.tipBoxContentFontSize + + onEditingFinished: { + AccountAdapter.setCurrAccDisplayName(text) + } + + } + + Text { + + Layout.preferredWidth: root.width - 32 + Layout.leftMargin: 20 + Layout.topMargin: 6 + font.pixelSize: JamiTheme.tipBoxContentFontSize + visible: opened + wrapMode: Text.WordWrap + text: JamiStrings.customizationDescription2 + color: JamiTheme.textColor + } +} \ No newline at end of file diff --git a/src/app/mainview/components/InformativeTipBox.qml b/src/app/mainview/components/InformativeTipBox.qml new file mode 100644 index 0000000000000000000000000000000000000000..f323dba458aef8c27006c3668c222e446a725db2 --- /dev/null +++ b/src/app/mainview/components/InformativeTipBox.qml @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2022 Savoir-faire Linux Inc. + * + * 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 <https://www.gnu.org/licenses/>. + */ + +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts + +import net.jami.Models 1.1 +import net.jami.Adapters 1.1 +import net.jami.Constants 1.1 + +import "../../commoncomponents" + + +ColumnLayout { + + width: parent.width + + + RowLayout { + + Layout.leftMargin: 15 + Layout.alignment: Qt.AlignLeft + + ResponsiveImage { + id: icon + + visible: !opened + + Layout.alignment: Qt.AlignLeft + Layout.topMargin: 5 + Layout.preferredWidth: 26 + Layout.preferredHeight: 26 + + containerHeight: Layout.preferredHeight + containerWidth: Layout.preferredWidth + + source: JamiResources.glasses_tips_svg + color: "#005699" + } + + Label { + text: JamiStrings.tip + color: JamiTheme.textColor + font.weight: Font.Medium + Layout.topMargin: 5 + visible: !opened + Layout.alignment: Qt.AlignLeft + Layout.leftMargin: 8 + font.pixelSize: JamiTheme.tipBoxTitleFontSize + } + } + + Text { + + Layout.preferredWidth: opened ? 140 : 150 + Layout.leftMargin: 20 + Layout.topMargin: opened ? 0 : 8 + Layout.bottomMargin: 15 + font.pixelSize: JamiTheme.tipBoxContentFontSize + wrapMode: Text.WordWrap + font.weight: opened ? Font.Medium : Font.Normal + text: root.title + color: JamiTheme.textColor + } + + Text { + Layout.preferredWidth: root.width - 32 + Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter + font.pixelSize: JamiTheme.tipBoxContentFontSize + visible: opened + wrapMode: Text.WordWrap + text: root.description + color: JamiTheme.textColor + } +} \ No newline at end of file diff --git a/src/app/mainview/components/TipBox.qml b/src/app/mainview/components/TipBox.qml index 0d7afe53d29b1a2ef64dac8ed745979b89f852c1..86691dcac543ae1f39f58a5eea8adb94fc526983 100644 --- a/src/app/mainview/components/TipBox.qml +++ b/src/app/mainview/components/TipBox.qml @@ -34,11 +34,20 @@ Item { property var title: "" property var description: "" property int tipId: 0 - property bool isTip : true + property string type : "" property bool hovered: false property bool clicked : false - property bool opened : false - property string alias: "" + property bool opened: false + + property string customizeTip:"CustomizeTipBox {}" + + property string backupTip: "BackupTipBox { + onIgnore: { + root.ignoreClicked() + } + }" + + property string infoTip: "InformativeTipBox {}" width: 200 height: tipColumnLayout.implicitHeight + 2 * JamiTheme.preferredMarginSize @@ -54,122 +63,22 @@ Item { border.color: opened || hovered ? "transparent" : Qt.rgba(0, 0.34,0.6,0.16) radius: 20 - ColumnLayout { - + Column { id: tipColumnLayout anchors.top: parent.top width: parent.width anchors.topMargin: 10 - - RowLayout { - - Layout.leftMargin: 15 - Layout.alignment: Qt.AlignLeft - - ResponsiveImage { - id: icon - - visible: !opened - - Layout.alignment: Qt.AlignLeft - Layout.topMargin: 5 - Layout.preferredWidth: 26 - Layout.preferredHeight: 26 - - containerHeight: Layout.preferredHeight - containerWidth: Layout.preferredWidth - - source: !isTip ? JamiResources.noun_paint_svg : JamiResources.glasses_tips_svg - color: "#005699" - } - - Label { - text: root.isTip ? JamiStrings.tip : JamiStrings.customize - color: JamiTheme.textColor - font.weight: Font.Medium - Layout.topMargin: 5 - visible: !opened - Layout.alignment: Qt.AlignLeft - Layout.leftMargin: isTip ? 8 : 5 - font.pixelSize: JamiTheme.tipBoxTitleFontSize + Component.onCompleted: { + if (type === "customize") { + Qt.createQmlObject(customizeTip, this, 'tip') + } else if (type === "backup") { + Qt.createQmlObject(backupTip, this, 'tip') + } else { + Qt.createQmlObject(infoTip, this, 'tip') } } - - Text { - - Layout.preferredWidth: root.isTip ? opened ? 140 : 150 : 170 - Layout.leftMargin: 20 - Layout.topMargin: root.isTip && opened ? 0 : 8 - Layout.bottomMargin: 15 - font.pixelSize: JamiTheme.tipBoxContentFontSize - visible: !opened || root.isTip - wrapMode: Text.WordWrap - font.weight: root.isTip && opened ? Font.Medium : Font.Normal - text: !isTip ? JamiStrings.customizeText : root.title - color: JamiTheme.textColor - } - - - PhotoboothView { - id: setAvatarWidget - Layout.preferredWidth: JamiTheme.accountListAvatarSize - Layout.preferredHeight: JamiTheme.accountListAvatarSize - Layout.topMargin: 10 - Layout.alignment: Qt.AlignHCenter - darkTheme: UtilsAdapter.luma(JamiTheme.primaryBackgroundColor) - visible: opened &&! isTip - enabled: true - buttonSize: 35 - imageId: CurrentAccount.id - avatarSize: 53 - cancelButton: false - - } - - EditableLineEdit { - - id: displayNameLineEdit - - visible: !isTip && opened - - Layout.alignment: Qt.AlignCenter - Layout.preferredWidth: root.width - 32 - - text: CurrentAccount.alias - placeholderText: JamiStrings.enterNickname - color: JamiTheme.textColor - - fontSize: JamiTheme.tipBoxContentFontSize - - onEditingFinished: root.alias = text - - } - - Text { - - Layout.preferredWidth: root.width - 32 - Layout.leftMargin: 20 - Layout.topMargin: 6 - font.pixelSize: JamiTheme.tipBoxContentFontSize - visible: opened && !isTip - wrapMode: Text.WordWrap - text: JamiStrings.customizationDescription2 - color: JamiTheme.textColor - } - - Text { - Layout.preferredWidth: root.width - 32 - Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter - font.pixelSize: JamiTheme.tipBoxContentFontSize - visible: opened && isTip - wrapMode: Text.WordWrap - text: root.description - color: JamiTheme.textColor - } - } - } HoverHandler { diff --git a/src/app/mainview/components/WelcomePage.qml b/src/app/mainview/components/WelcomePage.qml index ca381fb607123b520b385964c6549e69d107fc53..3b41c3496c4158a7db0ba9278f50a31c27f6fd51 100644 --- a/src/app/mainview/components/WelcomePage.qml +++ b/src/app/mainview/components/WelcomePage.qml @@ -186,8 +186,17 @@ Rectangle { tipId: TipId title: Title description: Description - isTip: IsTip - visible: index < 3 + type: Type + + visible: { + if (type === "backup") { + return LRCInstance.currentAccountType !== Profile.Type.SIP + && CurrentAccount.managerUri.length === 0 + } else if (type === "customize") { + return CurrentAccount.alias.length === 0 + } + return true + } onIgnoreClicked: TipsModel.remove(TipId) } diff --git a/src/app/tipsmodel.cpp b/src/app/tipsmodel.cpp index 767e8f759b40b636e11b64a181c83ed4bce3456d..05849d0618e2db1fdec651d553a9fadfebda5178 100644 --- a/src/app/tipsmodel.cpp +++ b/src/app/tipsmodel.cpp @@ -22,19 +22,20 @@ TipsModel::TipsModel(AppSettingsManager* settingsManager, QObject* parent) : QAbstractListModel(parent) , settingsManager_(settingsManager) { - tips_.append({{"id", "0"}, {"title", tr("Customize")}, {"desc", ""}, {"isTip", "false"}}); + tips_.append({{"id", "0"}, {"title", tr("Customize")}, {"desc", ""}, {"type", "customize"}}); + tips_.append({{"id", "13"}, {"title", tr("Backup account")}, {"desc", ""}, {"type", "backup"}}); tips_.append({{"id", "1"}, {"title", tr("What does Jami mean?")}, {"desc", tr("The choice of the name Jami was inspired by the Swahili word 'jamii', which " "means 'community' as a noun and 'together' as an adverb.")}, - {"isTip", "true"}}); + {"type", "tip"}}); tips_.append({{"id", "2"}, {"title", tr("What is the green dot next to my account?")}, {"desc", tr("A red dot means that your account is disconnected from the network; it " "turns green when it's connected.")}, - {"isTip", "true"}}); + {"type", "tip"}}); tips_.append( {{"id", "3"}, {"title", tr("Why should I back up my account?")}, @@ -42,30 +43,29 @@ TipsModel::TipsModel(AppSettingsManager* settingsManager, QObject* parent) tr("Jami is distributed and your account is only stored locally on your device. If " "you lose your password or your local account data, you WILL NOT be able to " "recover your account if you did not back it up earlier.")}, - {"isTip", "true"}}); + {"type", "tip"}}); tips_.append( {{"id", "4"}, {"title", tr("Can I make a conference call?")}, {"desc", tr("In a call, you can click on \"Add participants\" to add a contact to a call.")}, - {"isTip", "true"}}); - tips_.append( - {{"id", "5"}, - {"title", tr("Does Jami have group chats?")}, - {"desc", tr("In the settings, you can enabled support for groups (experimental).")}, - {"isTip", "true"}}); + {"type", "tip"}}); + tips_.append({{"id", "5"}, + {"title", tr("Does Jami have group chats?")}, + {"desc", tr("In the settings, you can enabled support for groups (experimental)")}, + {"type", "tip"}}); tips_.append({{"id", "6"}, {"title", tr("What is a Jami account?")}, {"desc", tr("A Jami account is an asymmetric encryption key. Your account is identified " "by a Jami ID, which is a fingerprint of your public key.")}, - {"isTip", "true"}}); + {"type", "tip"}}); tips_.append({{"id", "7"}, {"title", tr("What information do I need to provide to create a Jami account?")}, {"desc", tr("When you create a new Jami account, you do not have to provide any private " "information like an email, address, or phone number.")}, - {"isTip", "true"}}); + {"type", "tip"}}); tips_.append( {{"id", "8"}, {"title", tr("Why don't I have to use a password?")}, @@ -73,32 +73,32 @@ TipsModel::TipsModel(AppSettingsManager* settingsManager, QObject* parent) tr("With Jami, your account is stored in a directory on your device. The password " "is only used to encrypt your account in order to protect you from someone " "who has physical access to your device.")}, - {"isTip", "true"}}); + {"type", "tip"}}); tips_.append( {{"id", "9"}, {"title", tr("Why don't I have to register a username?")}, {"desc", tr("The most permanent, secure identifier is your Jami ID, but since these are difficult " "to use for some people, you also have the option of registering a username.")}, - {"isTip", "true"}}); + {"type", "tip"}}); tips_.append( {{"id", "10"}, {"title", tr("How can I back up my account?")}, {"desc", tr("In Account Settings, a button is available to create a backup your account.")}, - {"isTip", "true"}}); + {"type", "tip"}}); tips_.append( {{"id", "11"}, {"title", tr("What happens when I delete my account?")}, {"desc", tr("Your account is only stored on your own devices. If you delete your account " "from all of your devices, the account is gone forever and you CANNOT recover it.")}, - {"isTip", "true"}}); + {"type", "tip"}}); tips_.append({{"id", "12"}, {"title", tr("Can I use my account on multiple devices?")}, {"desc", tr("Yes, you can link your account from the settings, or you can import your " "backup on another device.")}, - {"isTip", "true"}}); + {"type", "tip"}}); QStringList hiddenIds = settingsManager_->getValue(Settings::Key::HiddenTips).toStringList(); @@ -134,8 +134,8 @@ TipsModel::data(const QModelIndex& index, int role) const return QVariant::fromValue(tip["title"]); case Tips::Role::Description: return QVariant::fromValue(tip["desc"]); - case Tips::Role::IsTip: - return QVariant::fromValue(tip["isTip"] == "true"); + case Tips::Role::Type: + return QVariant::fromValue(tip["type"]); } return QVariant(); } diff --git a/src/app/tipsmodel.h b/src/app/tipsmodel.h index 2620bb493bf29f7bc38bac1afe3621ee8b5b7fcb..52a424e8fba00209b410a6c01e0d777f7f4b5173 100644 --- a/src/app/tipsmodel.h +++ b/src/app/tipsmodel.h @@ -28,7 +28,7 @@ X(TipId) \ X(Title) \ X(Description) \ - X(IsTip) + X(Type) namespace Tips { Q_NAMESPACE diff --git a/src/app/wizardview/WizardView.qml b/src/app/wizardview/WizardView.qml index c1d8fbbf7381ceec9cba3f3f8b9d4975312aff2e..b5fa9059ab677e0732ab22f6ca1617a3c319db8c 100644 --- a/src/app/wizardview/WizardView.qml +++ b/src/app/wizardview/WizardView.qml @@ -114,14 +114,6 @@ Rectangle { onShowThisPage: controlPanelStackView.setPage(this) } - BackupKeyPage { - id: backupKeysPage - - objectName: "backupKeysPage" - - onShowThisPage: controlPanelStackView.setPage(this) - } - ImportFromDevicePage { id: importFromDevicePage diff --git a/src/app/wizardview/components/BackupKeyPage.qml b/src/app/wizardview/components/BackupKeyPage.qml deleted file mode 100644 index 2b62bcd89a704e6520b232c4d6b1851596912f6c..0000000000000000000000000000000000000000 --- a/src/app/wizardview/components/BackupKeyPage.qml +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (C) 2021-2022 Savoir-faire Linux Inc. - * Author: Yang Wang <yang.wang@savoirfairelinux.com> - * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> - * - * 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 <https://www.gnu.org/licenses/>. - */ - -import QtQuick -import QtQuick.Layouts -import QtQuick.Controls -import Qt.labs.platform - -import net.jami.Models 1.1 -import net.jami.Adapters 1.1 -import net.jami.Constants 1.1 -import net.jami.Enums 1.1 - -import "../../commoncomponents" -import "../../settingsview/components" - -Rectangle { - id: root - - property int preferredHeight: backupKeysPageColumnLayout.implicitHeight - - signal showThisPage - - function showBackupStatusDialog(success) { - var title = success ? JamiStrings.success : JamiStrings.error - var info = success ? JamiStrings.backupSuccessful : JamiStrings.backupFailed - - msgDialog.openWithParameters(title, info) - } - - Connections { - target: WizardViewStepModel - - function onMainStepChanged() { - if (WizardViewStepModel.mainStep === WizardViewStepModel.MainSteps.BackupKeys) - root.showThisPage() - } - } - - SimpleMessageDialog { - id: msgDialog - - buttonTitles: [JamiStrings.optionOk] - buttonStyles: [SimpleMessageDialog.ButtonStyle.TintedBlue] - - onClosed: { - if (title === JamiStrings.success) - WizardViewStepModel.nextStep() - } - } - - PasswordDialog { - id: passwordDialog - - visible: false - purpose: PasswordDialog.ExportAccount - - onDoneSignal: function (success) { - showBackupStatusDialog(success) - } - } - - // JamiFileDialog for exporting account - JamiFileDialog { - id: exportDialog - - mode: JamiFileDialog.SaveFile - - title: JamiStrings.backupAccountHere - folder: StandardPaths.writableLocation(StandardPaths.HomeLocation) + "/Desktop" - - nameFilters: [JamiStrings.jamiArchiveFiles, JamiStrings.allFiles] - - onAccepted: { - // Is there password? If so, go to password dialog, else, go to following directly - if (AccountAdapter.hasPassword()) { - passwordDialog.path = UtilsAdapter.getAbsPath(file) - passwordDialog.open() - } else { - if (file.toString().length > 0) - showBackupStatusDialog(AccountAdapter.exportToFile( - LRCInstance.currentAccountId, - UtilsAdapter.getAbsPath(file))) - } - } - - onVisibleChanged: { - if (!visible) { - rejected() - } - } - - onRejected: { - backupBtn.forceActiveFocus() - } - } - - color: JamiTheme.backgroundColor - - ColumnLayout { - id: backupKeysPageColumnLayout - - spacing: JamiTheme.wizardViewPageLayoutSpacing - - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - - RowLayout { - spacing: JamiTheme.wizardViewPageLayoutSpacing - - Layout.alignment: Qt.AlignCenter - Layout.topMargin: JamiTheme.wizardViewPageBackButtonMargins - Layout.preferredWidth: backupBtn.width - - Label { - text: JamiStrings.backupAccount - color: JamiTheme.textColor - font.pointSize: JamiTheme.textFontSize + 3 - } - - BubbleLabel { - Layout.alignment: Qt.AlignRight - - text: JamiStrings.recommended - } - } - - Label { - property int preferredHeight: 0 - - Layout.alignment: Qt.AlignCenter - Layout.preferredWidth: backupBtn.width - Layout.preferredHeight: preferredHeight - - text: JamiStrings.backupAccountInfos - color: JamiTheme.textColor - wrapMode: Text.WordWrap - font.pointSize: JamiTheme.textFontSize - - onFontChanged: { - var boundingRect = JamiQmlUtils.getTextBoundingRect(font, text) - preferredHeight = (boundingRect.width / backupBtn.preferredWidth) - * boundingRect.height - } - } - - RowLayout { - spacing: JamiTheme.wizardViewPageLayoutSpacing - - Layout.alignment: Qt.AlignCenter - - Label { - text: JamiStrings.neverShowAgain - color: JamiTheme.textColor - font.pointSize: JamiTheme.textFontSize - } - - JamiSwitch { - id: neverShowMeAgainSwitch - - objectName: "neverShowMeAgainSwitch" - - Layout.alignment: Qt.AlignRight - - focus: visible - - KeyNavigation.tab: backupBtn - KeyNavigation.up: skipBackupBtn - KeyNavigation.down: KeyNavigation.tab - - onToggled: AppSettingsManager.setValue(Settings.NeverShowMeAgain, checked) - } - } - - MaterialButton { - id: backupBtn - - objectName: "backupKeyPageBackupBtn" - - Layout.alignment: Qt.AlignCenter - - preferredWidth: JamiTheme.wizardButtonWidth - - text: JamiStrings.backupAccountBtn - autoAccelerator: true - color: JamiTheme.buttonTintedGrey - hoveredColor: JamiTheme.buttonTintedGreyHovered - pressedColor: JamiTheme.buttonTintedGreyPressed - - KeyNavigation.tab: skipBackupBtn - KeyNavigation.up: neverShowMeAgainSwitch - KeyNavigation.down: KeyNavigation.tab - - onClicked: exportDialog.open() - } - - MaterialButton { - id: skipBackupBtn - - objectName: "backupKeyPageSkipBackupBtn" - - Layout.alignment: Qt.AlignCenter - Layout.bottomMargin: JamiTheme.wizardViewPageBackButtonMargins - - preferredWidth: JamiTheme.wizardButtonWidth - - text: JamiStrings.skip - autoAccelerator: true - color: JamiTheme.buttonTintedGrey - hoveredColor: JamiTheme.buttonTintedGreyHovered - pressedColor: JamiTheme.buttonTintedGreyPressed - secondary: true - - KeyNavigation.tab: neverShowMeAgainSwitch - KeyNavigation.up: backupBtn - KeyNavigation.down: KeyNavigation.tab - - onClicked: WizardViewStepModel.nextStep() - } - } -} diff --git a/src/app/wizardviewstepmodel.cpp b/src/app/wizardviewstepmodel.cpp index e903b2abf41c54f8777c20571aabdb2f2d522f65..e92aa9914a99b64d3ce441cbe4928090558f6e56 100644 --- a/src/app/wizardviewstepmodel.cpp +++ b/src/app/wizardviewstepmodel.cpp @@ -41,16 +41,8 @@ WizardViewStepModel::WizardViewStepModel(LRCInstance* lrcInstance, Q_EMIT closeWizardView(); reset(); } else if (accountCreationOption != AccountCreationOption::None) { - auto showBackup = (accountCreationOption == AccountCreationOption::CreateJamiAccount - || accountCreationOption == AccountCreationOption::CreateRendezVous) - && !appSettingsManager_->getValue(Settings::Key::NeverShowMeAgain) - .toBool(); - if (showBackup) - set_mainStep(MainSteps::BackupKeys); - else { - Q_EMIT closeWizardView(); - reset(); - } + Q_EMIT closeWizardView(); + reset(); } Q_EMIT accountIsReady(accountId); @@ -99,12 +91,9 @@ WizardViewStepModel::nextStep() } break; } - case MainSteps::BackupKeys: { - Q_EMIT closeWizardView(); - reset(); + default: break; } - } } void diff --git a/src/app/wizardviewstepmodel.h b/src/app/wizardviewstepmodel.h index 72da7fe9fc0f17ac369bfec6c9be78dbc87e6617..edb7585757e3244c521233ccd96acac3ea30187b 100644 --- a/src/app/wizardviewstepmodel.h +++ b/src/app/wizardviewstepmodel.h @@ -38,7 +38,6 @@ public: Initial, // Initial welcome step. AccountCreation, // General account creation step. NameRegistration, // Name registration step : CreateJamiAccount, CreateRendezVous - BackupKeys // Backup set up. }; Q_ENUM(MainSteps) diff --git a/tests/qml/src/tst_WizardView.qml b/tests/qml/src/tst_WizardView.qml index ea31ccd749c9504d898abb25e40f601cd8ecc7b9..08698b7a132c01434072b80961a164093c2cc4cb 100644 --- a/tests/qml/src/tst_WizardView.qml +++ b/tests/qml/src/tst_WizardView.qml @@ -1552,10 +1552,6 @@ WizardView { var createAccountButton = findChild(createAccountPage, "createAccountButton") var skipProfileSavingButton = findChild(profilePage, "skipProfileSavingButton") - var neverShowMeAgainSwitch = findChild(backupKeysPage, "neverShowMeAgainSwitch") - var backupKeyPageBackupBtn = findChild(backupKeysPage, "backupKeyPageBackupBtn") - var backupKeyPageSkipBackupBtn = findChild(backupKeysPage, "backupKeyPageSkipBackupBtn") - // WelcomePage initially compare(controlPanelStackView.children[controlPanelStackView.currentIndex], welcomePage) @@ -1580,48 +1576,6 @@ WizardView { skipProfileSavingButton.clicked() - var showBackup = (WizardViewStepModel.accountCreationOption === - WizardViewStepModel.AccountCreationOption.CreateJamiAccount - || WizardViewStepModel.accountCreationOption === - WizardViewStepModel.AccountCreationOption.CreateRendezVous) - && !AppSettingsManager.getValue(Settings.NeverShowMeAgain) - if (showBackup) { - compare(controlPanelStackView.children[controlPanelStackView.currentIndex], - backupKeysPage) - - // Navigation test - compare(neverShowMeAgainSwitch.focus, true) - - keyClick(Qt.Key_Tab) - compare(backupKeyPageBackupBtn.focus, true) - - keyClick(Qt.Key_Tab) - compare(backupKeyPageSkipBackupBtn.focus, true) - - keyClick(Qt.Key_Tab) - compare(neverShowMeAgainSwitch.focus, true) - - keyClick(Qt.Key_Down) - compare(backupKeyPageBackupBtn.focus, true) - - keyClick(Qt.Key_Down) - compare(backupKeyPageSkipBackupBtn.focus, true) - - keyClick(Qt.Key_Down) - compare(neverShowMeAgainSwitch.focus, true) - - keyClick(Qt.Key_Up) - compare(backupKeyPageSkipBackupBtn.focus, true) - - keyClick(Qt.Key_Up) - compare(backupKeyPageBackupBtn.focus, true) - - keyClick(Qt.Key_Up) - compare(neverShowMeAgainSwitch.focus, true) - - WizardViewStepModel.nextStep() - } - spyCloseWizardView.wait() compare(spyCloseWizardView.count, 1)