blob: 48a930e1c184823f35af0f94c2d306ab41082936 [file] [log] [blame]
Edric Milaret67007d12015-05-07 09:40:09 -04001/***************************************************************************
Edric Milaret5f316da2015-09-28 11:57:42 -04002 * Copyright (C) 2015 by Savoir-faire Linux *
Edric Milaret67007d12015-05-07 09:40:09 -04003 * 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
Edric Milareted0b2802015-10-01 15:10:02 -040035 setFixedSize(this->width(),this->height());
Edric Milaret74e4b8b2015-05-15 10:25:00 -040036
Edric Milareted0b2802015-10-01 15:10:02 -040037 ui->joinButton->setEnabled(false);
38
39 QPixmap logo(":/images/logo-ring-standard-coul.png");
40 ui->ringLogo->setPixmap(logo.scaledToHeight(100, Qt::SmoothTransformation));
41 ui->ringLogo->setAlignment(Qt::AlignHCenter);
Edric Milaret559bda52015-04-29 17:02:31 -040042}
43
44WizardDialog::~WizardDialog()
45{
46 delete ui;
47}
48
49void
Edric Milaret67007d12015-05-07 09:40:09 -040050WizardDialog::accept()
51{
Edric Milaret53ac6e52015-09-14 13:37:06 -040052 ui->label->setText(tr("Please wait while we create your account."));
Edric Milareted0b2802015-10-01 15:10:02 -040053 ui->joinButton->setEnabled(false);
Edric Milaret67007d12015-05-07 09:40:09 -040054 ui->usernameEdit->setEnabled(false);
55
Edric Milaret74e4b8b2015-05-15 10:25:00 -040056 repaint();
Edric Milaret67007d12015-05-07 09:40:09 -040057
Edric Milaret74e4b8b2015-05-15 10:25:00 -040058 Utils::CreateStartupLink();
Edric Milaret67007d12015-05-07 09:40:09 -040059
Edric Milareta3e47282015-10-23 15:20:30 -040060 auto account = AccountModel::instance().add(ui->usernameEdit->text(), Account::Protocol::RING);
Edric Milaret68779c42015-07-09 16:53:03 -040061 account->setDisplayName(ui->usernameEdit->text());
Edric Milareta3e47282015-10-23 15:20:30 -040062 AccountModel::instance().ip2ip()->setRingtonePath(Utils::GetRingtonePath());
Edric Milaret031c3052015-04-29 18:14:18 -040063 account->setRingtonePath(Utils::GetRingtonePath());
Edric Milaret74e4b8b2015-05-15 10:25:00 -040064 account->setUpnpEnabled(true);
65
66 connect(account, SIGNAL(changed(Account*)), this, SLOT(endSetup(Account*)));
67
68 account->performAction(Account::EditAction::SAVE);
69}
70
71void
72WizardDialog::endSetup(Account* a)
73{
74 Q_UNUSED(a)
75 QDialog::accept();
Edric Milaret559bda52015-04-29 17:02:31 -040076}
77
78void
79WizardDialog::on_usernameEdit_textChanged(const QString &arg1)
80{
Edric Milareted0b2802015-10-01 15:10:02 -040081 ui->joinButton->setEnabled(!arg1.isEmpty());
82}
83
84void
85WizardDialog::closeEvent(QCloseEvent *event)
86{
87 Q_UNUSED(event)
88
89 exit(0);
Edric Milaret559bda52015-04-29 17:02:31 -040090}