Edric Milaret | 67007d1 | 2015-05-07 09:40:09 -0400 | [diff] [blame] | 1 | /*************************************************************************** |
Edric Milaret | 5f316da | 2015-09-28 11:57:42 -0400 | [diff] [blame] | 2 | * Copyright (C) 2015 by Savoir-faire Linux * |
Edric Milaret | 67007d1 | 2015-05-07 09:40:09 -0400 | [diff] [blame] | 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 Milaret | 559bda5 | 2015-04-29 17:02:31 -0400 | [diff] [blame] | 19 | #include "wizarddialog.h" |
| 20 | #include "ui_wizarddialog.h" |
| 21 | |
Edric Milaret | 74e4b8b | 2015-05-15 10:25:00 -0400 | [diff] [blame] | 22 | #include <QMovie> |
| 23 | |
Edric Milaret | 559bda5 | 2015-04-29 17:02:31 -0400 | [diff] [blame] | 24 | #include "accountmodel.h" |
Edric Milaret | 74e4b8b | 2015-05-15 10:25:00 -0400 | [diff] [blame] | 25 | #include "account.h" |
Edric Milaret | 559bda5 | 2015-04-29 17:02:31 -0400 | [diff] [blame] | 26 | |
| 27 | #include "utils.h" |
| 28 | |
| 29 | WizardDialog::WizardDialog(QWidget *parent) : |
| 30 | QDialog(parent), |
| 31 | ui(new Ui::WizardDialog) |
| 32 | { |
| 33 | ui->setupUi(this); |
| 34 | |
Edric Milaret | ed0b280 | 2015-10-01 15:10:02 -0400 | [diff] [blame] | 35 | setFixedSize(this->width(),this->height()); |
Edric Milaret | 74e4b8b | 2015-05-15 10:25:00 -0400 | [diff] [blame] | 36 | |
Edric Milaret | ed0b280 | 2015-10-01 15:10:02 -0400 | [diff] [blame] | 37 | 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 Milaret | 559bda5 | 2015-04-29 17:02:31 -0400 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | WizardDialog::~WizardDialog() |
| 45 | { |
| 46 | delete ui; |
| 47 | } |
| 48 | |
| 49 | void |
Edric Milaret | 67007d1 | 2015-05-07 09:40:09 -0400 | [diff] [blame] | 50 | WizardDialog::accept() |
| 51 | { |
Edric Milaret | 53ac6e5 | 2015-09-14 13:37:06 -0400 | [diff] [blame] | 52 | ui->label->setText(tr("Please wait while we create your account.")); |
Edric Milaret | ed0b280 | 2015-10-01 15:10:02 -0400 | [diff] [blame] | 53 | ui->joinButton->setEnabled(false); |
Edric Milaret | 67007d1 | 2015-05-07 09:40:09 -0400 | [diff] [blame] | 54 | ui->usernameEdit->setEnabled(false); |
| 55 | |
Edric Milaret | 74e4b8b | 2015-05-15 10:25:00 -0400 | [diff] [blame] | 56 | repaint(); |
Edric Milaret | 67007d1 | 2015-05-07 09:40:09 -0400 | [diff] [blame] | 57 | |
Edric Milaret | 74e4b8b | 2015-05-15 10:25:00 -0400 | [diff] [blame] | 58 | Utils::CreateStartupLink(); |
Edric Milaret | 67007d1 | 2015-05-07 09:40:09 -0400 | [diff] [blame] | 59 | |
Edric Milaret | a3e4728 | 2015-10-23 15:20:30 -0400 | [diff] [blame^] | 60 | auto account = AccountModel::instance().add(ui->usernameEdit->text(), Account::Protocol::RING); |
Edric Milaret | 68779c4 | 2015-07-09 16:53:03 -0400 | [diff] [blame] | 61 | account->setDisplayName(ui->usernameEdit->text()); |
Edric Milaret | a3e4728 | 2015-10-23 15:20:30 -0400 | [diff] [blame^] | 62 | AccountModel::instance().ip2ip()->setRingtonePath(Utils::GetRingtonePath()); |
Edric Milaret | 031c305 | 2015-04-29 18:14:18 -0400 | [diff] [blame] | 63 | account->setRingtonePath(Utils::GetRingtonePath()); |
Edric Milaret | 74e4b8b | 2015-05-15 10:25:00 -0400 | [diff] [blame] | 64 | account->setUpnpEnabled(true); |
| 65 | |
| 66 | connect(account, SIGNAL(changed(Account*)), this, SLOT(endSetup(Account*))); |
| 67 | |
| 68 | account->performAction(Account::EditAction::SAVE); |
| 69 | } |
| 70 | |
| 71 | void |
| 72 | WizardDialog::endSetup(Account* a) |
| 73 | { |
| 74 | Q_UNUSED(a) |
| 75 | QDialog::accept(); |
Edric Milaret | 559bda5 | 2015-04-29 17:02:31 -0400 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | void |
| 79 | WizardDialog::on_usernameEdit_textChanged(const QString &arg1) |
| 80 | { |
Edric Milaret | ed0b280 | 2015-10-01 15:10:02 -0400 | [diff] [blame] | 81 | ui->joinButton->setEnabled(!arg1.isEmpty()); |
| 82 | } |
| 83 | |
| 84 | void |
| 85 | WizardDialog::closeEvent(QCloseEvent *event) |
| 86 | { |
| 87 | Q_UNUSED(event) |
| 88 | |
| 89 | exit(0); |
Edric Milaret | 559bda5 | 2015-04-29 17:02:31 -0400 | [diff] [blame] | 90 | } |