blob: b281d0cc175b85a8eccf473dbaf6159a6cb7c773 [file] [log] [blame]
Edric Milaret67007d12015-05-07 09:40:09 -04001/***************************************************************************
2 * Copyright (C) 2015 by Savoir-Faire Linux *
3 * Author: Edric Ladent Milaret <edric.ladent-milaret@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
Edric Milaret559bda52015-04-29 17:02:31 -040019#include "wizarddialog.h"
20#include "ui_wizarddialog.h"
21
Edric Milaret74e4b8b2015-05-15 10:25:00 -040022#include <QMovie>
23
Edric Milaret559bda52015-04-29 17:02:31 -040024#include "accountmodel.h"
Edric Milaret74e4b8b2015-05-15 10:25:00 -040025#include "account.h"
Edric Milaret559bda52015-04-29 17:02:31 -040026
27#include "utils.h"
28
29WizardDialog::WizardDialog(QWidget *parent) :
30 QDialog(parent),
31 ui(new Ui::WizardDialog)
32{
33 ui->setupUi(this);
34
35 this->setWindowFlags(Qt::CustomizeWindowHint);
36 this->setWindowFlags(Qt::FramelessWindowHint);
37 this->setFixedSize(this->width(),this->height());
38 ui->buttonBox->setEnabled(false);
Edric Milaret74e4b8b2015-05-15 10:25:00 -040039
40 ui->spinnerLabel->hide();
41 QMovie* movie = new QMovie(":images/spinner.gif");
42 if (movie->isValid())
43 {
44 ui->spinnerLabel->setMovie(movie);
45 movie->start();
46 }
Edric Milaret559bda52015-04-29 17:02:31 -040047}
48
49WizardDialog::~WizardDialog()
50{
51 delete ui;
52}
53
54void
Edric Milaret67007d12015-05-07 09:40:09 -040055WizardDialog::accept()
56{
Edric Milaret74e4b8b2015-05-15 10:25:00 -040057 //ui->spinnerLabel->show();
58 ui->label->setText("Please wait while we create your account.");
Edric Milaret67007d12015-05-07 09:40:09 -040059 ui->buttonBox->setEnabled(false);
60 ui->usernameEdit->setEnabled(false);
61
Edric Milaret74e4b8b2015-05-15 10:25:00 -040062 repaint();
Edric Milaret67007d12015-05-07 09:40:09 -040063
Edric Milaret74e4b8b2015-05-15 10:25:00 -040064 Utils::CreateStartupLink();
Edric Milaret67007d12015-05-07 09:40:09 -040065
Edric Milaret031c3052015-04-29 18:14:18 -040066 auto account = AccountModel::instance()->add(ui->usernameEdit->text(), Account::Protocol::RING);
Edric Milaret67007d12015-05-07 09:40:09 -040067 AccountModel::instance()->ip2ip()->setRingtonePath(Utils::GetRingtonePath());
Edric Milaret031c3052015-04-29 18:14:18 -040068 account->setRingtonePath(Utils::GetRingtonePath());
Edric Milaret74e4b8b2015-05-15 10:25:00 -040069 account->setUpnpEnabled(true);
70
71 connect(account, SIGNAL(changed(Account*)), this, SLOT(endSetup(Account*)));
72
73 account->performAction(Account::EditAction::SAVE);
74}
75
76void
77WizardDialog::endSetup(Account* a)
78{
79 Q_UNUSED(a)
80 QDialog::accept();
Edric Milaret559bda52015-04-29 17:02:31 -040081}
82
83void
84WizardDialog::on_usernameEdit_textChanged(const QString &arg1)
85{
Edric Milaret74e4b8b2015-05-15 10:25:00 -040086 ui->buttonBox->setEnabled(!arg1.isEmpty());
Edric Milaret559bda52015-04-29 17:02:31 -040087}