blob: b4ca1863dd9d4f5c1d793a29bb3afaf3f6817e2f [file] [log] [blame]
Olivier SOLDANO47aa97f2017-04-04 10:40:00 -04001/**************************************************************************
Anthony Léonard2fde81d2017-04-17 10:06:55 -04002* Copyright (C) 2015-2017 by Savoir-faire Linux *
Olivier SOLDANO47aa97f2017-04-04 10:40:00 -04003* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
4* Author: Anthony Léonard <anthony.leonard@savoirfairelinux.com> *
5* Author: Olivier Soldano <olivier.soldano@savoirfairelinux.com> *
6* *
7* This program is free software; you can redistribute it and/or modify *
8* it under the terms of the GNU General Public License as published by *
9* the Free Software Foundation; either version 3 of the License, or *
10* (at your option) any later version. *
11* *
12* This program is distributed in the hope that it will be useful, *
13* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15* GNU General Public License for more details. *
16* *
17* You should have received a copy of the GNU General Public License *
18* along with this program. If not, see <http://www.gnu.org/licenses/>. *
19**************************************************************************/
Edric Milaret67007d12015-05-07 09:40:09 -040020
Edric Milaret5f316da2015-09-28 11:57:42 -040021#pragma once
Edric Milaret559bda52015-04-29 17:02:31 -040022
23#include <QDialog>
Edric Milaret67007d12015-05-07 09:40:09 -040024#include <QtConcurrent/QtConcurrent>
Edric Milaret559bda52015-04-29 17:02:31 -040025
Edric Milaret74e4b8b2015-05-15 10:25:00 -040026#include "account.h"
Edric Milaret25236d92016-03-28 09:40:58 -040027#include "person.h"
Edric Milaret74e4b8b2015-05-15 10:25:00 -040028
Andreas Traczykb8b13ba2018-08-21 16:30:16 -040029#include "lrcinstance.h"
30
Edric Milaret559bda52015-04-29 17:02:31 -040031namespace Ui {
32class WizardDialog;
33}
34
35class WizardDialog : public QDialog
36{
37 Q_OBJECT
38
39public:
Andreas Traczykb8b13ba2018-08-21 16:30:16 -040040 using AccountInfo = lrc::api::account::Info;
41
Edric Milaret57467842016-08-30 13:06:11 -040042 enum WizardMode {
43 WIZARD,
44 NEW_ACCOUNT,
Olivier SOLDANO1cd96172017-09-22 16:57:22 -040045 IMPORT,
Edric Milaret57467842016-08-30 13:06:11 -040046 MIGRATION
47 };
48
49public:
Andreas Traczykb8b13ba2018-08-21 16:30:16 -040050 explicit WizardDialog(WizardMode wizardMode = WIZARD, AccountInfo* toBeMigrated = nullptr, QWidget* parent = 0);
Edric Milaret559bda52015-04-29 17:02:31 -040051 ~WizardDialog();
52
Edric Milaret25236d92016-03-28 09:40:58 -040053//UI Slots
54private slots:
Edric Milaret57467842016-08-30 13:06:11 -040055 void on_existingPushButton_clicked();
56 void on_newAccountButton_clicked();
Anthony Léonard955b9572016-11-10 13:28:39 -050057 void on_nextButton_clicked();
Edric Milaret57467842016-08-30 13:06:11 -040058 void on_previousButton_clicked();
59 void on_passwordEdit_textChanged(const QString& arg1);
Edric Milaret74e4b8b2015-05-15 10:25:00 -040060
61private slots:
Anthony Léonardaa90e1a2016-10-12 11:24:17 -040062 void on_usernameEdit_textChanged(const QString& arg1);
Olivier SOLDANOb58f9c22017-07-20 13:44:05 -040063 void handle_registeredNameFound(Account *account, NameDirectory::LookupStatus status, const QString& address, const QString& name);
Anthony Léonardaa90e1a2016-10-12 11:24:17 -040064 void handle_nameRegistrationEnded(NameDirectory::RegisterNameStatus status, const QString& name);
65 void timeoutNameLookupTimer();
Olivier SOLDANO3dad1752017-07-13 14:08:53 -040066 void on_photoTaken(QString fileName);
Olivier SOLDANOaa47f602017-08-17 16:38:11 -040067 void on_signUpCheckbox_toggled(bool checked);
Olivier SOLDANOc1ca2df2017-09-06 16:01:46 -040068 void closeEvent(QCloseEvent* event);
Olivier SOLDANO1cd96172017-09-22 16:57:22 -040069 void on_archivePathSelector_clicked();
70 void on_dhtImportBtn_clicked();
71 void on_fileImportBtn_clicked();
Andreas Traczyk55f92cb2018-10-23 12:26:25 -040072 void slotAccountAdded(const std::string & accountId);
Edric Milaret25236d92016-03-28 09:40:58 -040073
74private:
75 Ui::WizardDialog* ui;
Andreas Traczykb8b13ba2018-08-21 16:30:16 -040076 AccountInfo* account_;
Edric Milaret57467842016-08-30 13:06:11 -040077 WizardMode wizardMode_;
78 QMovie* movie_;
Anthony Léonardaa90e1a2016-10-12 11:24:17 -040079 QTimer nameLookupTimer_;
Edric Milaret25236d92016-03-28 09:40:58 -040080
81 void setup();
Edric Milaret57467842016-08-30 13:06:11 -040082 void changePage(bool existingAccount);
Olivier SOLDANO1cd96172017-09-22 16:57:22 -040083 void validateFileImport();
84 void createRingAccount(const QString &displayName = QString(),
85 const QString &password = QString(),
86 const QString &pin = QString(),
87 const QString &archivePath = QString());
88 void processWizardInformations();
Edric Milaret559bda52015-04-29 17:02:31 -040089};