Edric Milaret | 67007d1 | 2015-05-07 09:40:09 -0400 | [diff] [blame] | 1 | /*************************************************************************** |
| 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 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 | |
| 35 | this->setWindowFlags(Qt::CustomizeWindowHint); |
| 36 | this->setWindowFlags(Qt::FramelessWindowHint); |
| 37 | this->setFixedSize(this->width(),this->height()); |
| 38 | ui->buttonBox->setEnabled(false); |
Edric Milaret | 74e4b8b | 2015-05-15 10:25:00 -0400 | [diff] [blame] | 39 | |
| 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 Milaret | 559bda5 | 2015-04-29 17:02:31 -0400 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | WizardDialog::~WizardDialog() |
| 50 | { |
| 51 | delete ui; |
| 52 | } |
| 53 | |
| 54 | void |
Edric Milaret | 67007d1 | 2015-05-07 09:40:09 -0400 | [diff] [blame] | 55 | WizardDialog::accept() |
| 56 | { |
Edric Milaret | 74e4b8b | 2015-05-15 10:25:00 -0400 | [diff] [blame] | 57 | //ui->spinnerLabel->show(); |
| 58 | ui->label->setText("Please wait while we create your account."); |
Edric Milaret | 67007d1 | 2015-05-07 09:40:09 -0400 | [diff] [blame] | 59 | ui->buttonBox->setEnabled(false); |
| 60 | ui->usernameEdit->setEnabled(false); |
| 61 | |
Edric Milaret | 74e4b8b | 2015-05-15 10:25:00 -0400 | [diff] [blame] | 62 | repaint(); |
Edric Milaret | 67007d1 | 2015-05-07 09:40:09 -0400 | [diff] [blame] | 63 | |
Edric Milaret | 74e4b8b | 2015-05-15 10:25:00 -0400 | [diff] [blame] | 64 | Utils::CreateStartupLink(); |
Edric Milaret | 67007d1 | 2015-05-07 09:40:09 -0400 | [diff] [blame] | 65 | |
Edric Milaret | 031c305 | 2015-04-29 18:14:18 -0400 | [diff] [blame] | 66 | auto account = AccountModel::instance()->add(ui->usernameEdit->text(), Account::Protocol::RING); |
Edric Milaret | 67007d1 | 2015-05-07 09:40:09 -0400 | [diff] [blame] | 67 | AccountModel::instance()->ip2ip()->setRingtonePath(Utils::GetRingtonePath()); |
Edric Milaret | 031c305 | 2015-04-29 18:14:18 -0400 | [diff] [blame] | 68 | account->setRingtonePath(Utils::GetRingtonePath()); |
Edric Milaret | 74e4b8b | 2015-05-15 10:25:00 -0400 | [diff] [blame] | 69 | account->setUpnpEnabled(true); |
| 70 | |
| 71 | connect(account, SIGNAL(changed(Account*)), this, SLOT(endSetup(Account*))); |
| 72 | |
| 73 | account->performAction(Account::EditAction::SAVE); |
| 74 | } |
| 75 | |
| 76 | void |
| 77 | WizardDialog::endSetup(Account* a) |
| 78 | { |
| 79 | Q_UNUSED(a) |
| 80 | QDialog::accept(); |
Edric Milaret | 559bda5 | 2015-04-29 17:02:31 -0400 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | void |
| 84 | WizardDialog::on_usernameEdit_textChanged(const QString &arg1) |
| 85 | { |
Edric Milaret | 74e4b8b | 2015-05-15 10:25:00 -0400 | [diff] [blame] | 86 | ui->buttonBox->setEnabled(!arg1.isEmpty()); |
Edric Milaret | 559bda5 | 2015-04-29 17:02:31 -0400 | [diff] [blame] | 87 | } |