blob: c77edb8d2220c3b08a4fc7360c7c2ca6544ffe8d [file] [log] [blame]
Andreas Traczyk55f92cb2018-10-23 12:26:25 -04001/**************************************************************************
2* Copyright (C) 2015-2018 by Savoir-faire Linux *
3* 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* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> *
7* *
8* This program is free software; you can redistribute it and/or modify *
9* it under the terms of the GNU General Public License as published by *
10* the Free Software Foundation; either version 3 of the License, or *
11* (at your option) any later version. *
12* *
13* This program is distributed in the hope that it will be useful, *
14* but WITHOUT ANY WARRANTY; without even the implied warranty of *
15* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16* GNU General Public License for more details. *
17* *
18* You should have received a copy of the GNU General Public License *
19* along with this program. If not, see <http://www.gnu.org/licenses/>. *
20**************************************************************************/
21
22#pragma once
23
24#include <QDialog>
25#include <QtConcurrent/QtConcurrent>
26
27#include "account.h"
28#include "person.h"
29
30#include "lrcinstance.h"
31#include "navwidget.h"
32
33namespace Ui {
34class WizardWidget;
35}
36
37class WizardWidget : public NavWidget
38{
39 Q_OBJECT
40
41public:
42 using AccountInfo = lrc::api::account::Info;
43
44 enum WizardMode {
45 WIZARD,
46 NEW_ACCOUNT,
47 IMPORT,
48 MIGRATION
49 };
50
51public:
52 explicit WizardWidget(WizardMode wizardMode = WIZARD, AccountInfo* toBeMigrated = nullptr, QWidget* parent = 0);
53 ~WizardWidget();
54
Andreas Traczykfc33a492018-12-14 13:53:13 -050055 // NavWidget
56 virtual void navigated(bool to);
57
Andreas Traczyk55f92cb2018-10-23 12:26:25 -040058//UI Slots
59private slots:
60 void on_existingPushButton_clicked();
61 void on_newAccountButton_clicked();
62 void on_nextButton_clicked();
63 void on_previousButton_clicked();
64 void on_passwordEdit_textChanged(const QString& arg1);
65
66private slots:
67 void on_usernameEdit_textChanged(const QString& arg1);
68 void handle_registeredNameFound(Account *account, NameDirectory::LookupStatus status, const QString& address, const QString& name);
69 void handle_nameRegistrationEnded(NameDirectory::RegisterNameStatus status, const QString& name);
70 void timeoutNameLookupTimer();
71 void on_photoTaken(QString fileName);
72 void on_signUpCheckbox_toggled(bool checked);
73 void on_archivePathSelector_clicked();
74 void on_dhtImportBtn_clicked();
75 void on_fileImportBtn_clicked();
76
77private:
78 Ui::WizardWidget* ui;
79 AccountInfo* account_;
80 WizardMode wizardMode_;
81 QMovie* movie_;
82 QTimer nameLookupTimer_;
83
84 QMetaObject::Connection accountAddedConnection_;
85
86 void setup();
87 void changePage(bool existingAccount);
88 void validateFileImport();
89 void createRingAccount(const QString &displayName = QString(),
90 const QString &password = QString(),
91 const QString &pin = QString(),
92 const QString &archivePath = QString());
93 void processWizardInformations();
94};