Andreas Traczyk | 6ace34f | 2018-12-14 14:31:23 -0500 | [diff] [blame] | 1 | /************************************************************************** |
Sébastien Blin | 68abac9 | 2019-01-02 17:41:31 -0500 | [diff] [blame] | 2 | * Copyright (C) 2018-2019 by Savoir-faire Linux * |
Andreas Traczyk | 6ace34f | 2018-12-14 14:31:23 -0500 | [diff] [blame] | 3 | * Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> * |
| 4 | * * |
| 5 | * This program is free software; you can redistribute it and/or modify * |
| 6 | * it under the terms of the GNU General Public License as published by * |
| 7 | * the Free Software Foundation; either version 3 of the License, or * |
| 8 | * (at your option) any later version. * |
| 9 | * * |
| 10 | * This program is distributed in the hope that it will be useful, * |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 13 | * GNU General Public License for more details. * |
| 14 | * * |
| 15 | * You should have received a copy of the GNU General Public License * |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. * |
| 17 | **************************************************************************/ |
| 18 | |
| 19 | #pragma once |
| 20 | |
| 21 | #include <QLabel> |
| 22 | #include <QtConcurrent/QtConcurrent> |
| 23 | |
Andreas Traczyk | 6ace34f | 2018-12-14 14:31:23 -0500 | [diff] [blame] | 24 | #include "lrcinstance.h" |
| 25 | #include "navwidget.h" |
| 26 | |
| 27 | namespace Ui { |
| 28 | class NewWizardWidget; |
| 29 | } |
| 30 | |
| 31 | using namespace lrc::api::account; |
| 32 | |
| 33 | class NewWizardWidget : public NavWidget |
| 34 | { |
| 35 | Q_OBJECT |
| 36 | |
| 37 | public: |
| 38 | |
| 39 | using AccountInfo = Info; |
| 40 | |
Andreas Traczyk | 3199a1f | 2018-12-26 18:20:09 -0500 | [diff] [blame] | 41 | enum WizardMode { WIZARD, IMPORT, MIGRATION }; |
Andreas Traczyk | 6ace34f | 2018-12-14 14:31:23 -0500 | [diff] [blame] | 42 | |
| 43 | private: |
| 44 | enum NameRegistrationUIState { BLANK, INVALID, TAKEN, FREE, SEARCHING }; |
| 45 | |
| 46 | public: |
Andreas Traczyk | 3199a1f | 2018-12-26 18:20:09 -0500 | [diff] [blame] | 47 | explicit NewWizardWidget(QWidget* parent = 0); |
Andreas Traczyk | 6ace34f | 2018-12-14 14:31:23 -0500 | [diff] [blame] | 48 | ~NewWizardWidget(); |
| 49 | |
Andreas Traczyk | 3199a1f | 2018-12-26 18:20:09 -0500 | [diff] [blame] | 50 | void setToMigrate(AccountInfo* toBeMigrated); |
| 51 | |
Andreas Traczyk | 6ace34f | 2018-12-14 14:31:23 -0500 | [diff] [blame] | 52 | // NavWidget |
| 53 | virtual void navigated(bool to); |
| 54 | virtual void updateCustomUI(); |
| 55 | |
| 56 | //UI Slots |
| 57 | private slots: |
| 58 | void on_existingPushButton_clicked(); |
| 59 | void on_newAccountButton_clicked(); |
| 60 | void on_nextButton_clicked(); |
| 61 | void on_previousButton_clicked(); |
| 62 | void on_passwordEdit_textChanged(const QString& arg1); |
| 63 | |
| 64 | private slots: |
| 65 | void on_usernameEdit_textChanged(const QString& arg1); |
| 66 | void slotRegisteredNameFound(const std::string& accountId, |
| 67 | LookupStatus status, |
| 68 | const std::string& address, |
| 69 | const std::string& name); |
| 70 | void handle_nameRegistrationEnded(NameDirectory::RegisterNameStatus status, const QString& name); |
| 71 | void timeoutNameLookupTimer(); |
Andreas Traczyk | 6ace34f | 2018-12-14 14:31:23 -0500 | [diff] [blame] | 72 | void on_signUpCheckbox_toggled(bool checked); |
| 73 | |
| 74 | private: |
| 75 | Ui::NewWizardWidget* ui; |
| 76 | |
| 77 | WizardMode wizardMode_; |
| 78 | QPixmap statusSuccessPixmap_; |
| 79 | QPixmap statusInvalidPixmap_; |
| 80 | QPixmap statusErrorPixmap_; |
| 81 | |
| 82 | AccountInfo* account_; |
| 83 | QMovie* creationSpinnerMovie_; |
| 84 | |
| 85 | QMovie* lookupSpinnerMovie_; |
| 86 | QTimer lookupTimer_; |
| 87 | QLabel* lookupStatusLabel_; |
| 88 | QString registeredName_; |
| 89 | bool registrationStateOk_; |
| 90 | QMetaObject::Connection registeredNameFoundConnection_; |
Andreas Traczyk | 3199a1f | 2018-12-26 18:20:09 -0500 | [diff] [blame] | 91 | QString fileToImport_; |
Andreas Traczyk | 6ace34f | 2018-12-14 14:31:23 -0500 | [diff] [blame] | 92 | QLabel* passwordStatusLabel_; |
Andreas Traczyk | 3199a1f | 2018-12-26 18:20:09 -0500 | [diff] [blame] | 93 | |
Andreas Traczyk | 6ace34f | 2018-12-14 14:31:23 -0500 | [diff] [blame] | 94 | void updateNameRegistrationUi(NameRegistrationUIState state); |
| 95 | void changePage(QWidget* toPage); |
| 96 | void setNavBarVisibility(bool visible, bool back=false); |
Andreas Traczyk | 6ace34f | 2018-12-14 14:31:23 -0500 | [diff] [blame] | 97 | void validateWizardProgression(); |
| 98 | void createRingAccount(const QString &displayName = QString(), |
| 99 | const QString &password = QString(), |
| 100 | const QString &pin = QString(), |
| 101 | const QString &archivePath = QString()); |
| 102 | void processWizardInformations(); |
| 103 | }; |