blob: 67193c15b1ae67812ae28f95a2b202022bd67063 [file] [log] [blame]
Olivier SOLDANO47aa97f2017-04-04 10:40:00 -04001/**************************************************************************
2* Copyright (C) 2015-2016 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* *
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
Edric Milaret559bda52015-04-29 17:02:31 -040029namespace Ui {
30class WizardDialog;
31}
32
33class WizardDialog : public QDialog
34{
35 Q_OBJECT
36
37public:
Edric Milaret57467842016-08-30 13:06:11 -040038 enum WizardMode {
39 WIZARD,
40 NEW_ACCOUNT,
41 MIGRATION
42 };
43
44public:
45 explicit WizardDialog(WizardMode wizardMode = WIZARD, Account* toBeMigrated = nullptr, QWidget* parent = 0);
Edric Milaret559bda52015-04-29 17:02:31 -040046 ~WizardDialog();
47
Edric Milaret25236d92016-03-28 09:40:58 -040048// Overrided function
Edric Milareted0b2802015-10-01 15:10:02 -040049protected slots:
Edric Milaret67007d12015-05-07 09:40:09 -040050 void accept();
Edric Milaret25236d92016-03-28 09:40:58 -040051 void closeEvent(QCloseEvent* event);
Edric Milaret67007d12015-05-07 09:40:09 -040052
Edric Milaret25236d92016-03-28 09:40:58 -040053//UI Slots
54private slots:
55 void on_avatarButton_clicked();
Edric Milaret57467842016-08-30 13:06:11 -040056 void on_existingPushButton_clicked();
57 void on_newAccountButton_clicked();
Anthony Léonard955b9572016-11-10 13:28:39 -050058 void on_nextButton_clicked();
Edric Milaret57467842016-08-30 13:06:11 -040059 void on_previousButton_clicked();
60 void on_passwordEdit_textChanged(const QString& arg1);
Edric Milaret74e4b8b2015-05-15 10:25:00 -040061
62private slots:
Edric Milaret57467842016-08-30 13:06:11 -040063 void endSetup(Account::RegistrationState state);
Anthony Léonardaa90e1a2016-10-12 11:24:17 -040064 void on_usernameEdit_textChanged(const QString& arg1);
65 void handle_registeredNameFound(const Account *account, NameDirectory::LookupStatus status, const QString& address, const QString& name);
66 void handle_nameRegistrationEnded(NameDirectory::RegisterNameStatus status, const QString& name);
67 void timeoutNameLookupTimer();
Edric Milaret25236d92016-03-28 09:40:58 -040068
69private:
70 Ui::WizardDialog* ui;
Edric Milaret57467842016-08-30 13:06:11 -040071 Account* account_;
72 WizardMode wizardMode_;
73 QMovie* movie_;
Anthony Léonardaa90e1a2016-10-12 11:24:17 -040074 QTimer nameLookupTimer_;
Edric Milaret25236d92016-03-28 09:40:58 -040075
76 void setup();
Edric Milaret57467842016-08-30 13:06:11 -040077 void changePage(bool existingAccount);
Anthony Léonardaa90e1a2016-10-12 11:24:17 -040078 void usernameFailedRegistration();
Edric Milaret559bda52015-04-29 17:02:31 -040079};