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 | |
| 22 | #include "accountmodel.h" |
| 23 | |
| 24 | #include "utils.h" |
| 25 | |
| 26 | WizardDialog::WizardDialog(QWidget *parent) : |
| 27 | QDialog(parent), |
| 28 | ui(new Ui::WizardDialog) |
| 29 | { |
| 30 | ui->setupUi(this); |
| 31 | |
| 32 | this->setWindowFlags(Qt::CustomizeWindowHint); |
| 33 | this->setWindowFlags(Qt::FramelessWindowHint); |
| 34 | this->setFixedSize(this->width(),this->height()); |
| 35 | ui->buttonBox->setEnabled(false); |
| 36 | } |
| 37 | |
| 38 | WizardDialog::~WizardDialog() |
| 39 | { |
| 40 | delete ui; |
| 41 | } |
| 42 | |
| 43 | void |
Edric Milaret | 67007d1 | 2015-05-07 09:40:09 -0400 | [diff] [blame] | 44 | WizardDialog::accept() |
| 45 | { |
| 46 | ui->label->setText("Working..."); |
| 47 | ui->buttonBox->setEnabled(false); |
| 48 | ui->usernameEdit->setEnabled(false); |
| 49 | |
| 50 | QtConcurrent::run(this, &WizardDialog::setup).waitForFinished(); |
| 51 | } |
| 52 | |
| 53 | void |
| 54 | WizardDialog::endSetup() |
| 55 | { |
| 56 | QDialog::accept(); |
| 57 | } |
| 58 | |
| 59 | void |
| 60 | WizardDialog::setup() |
Edric Milaret | 559bda5 | 2015-04-29 17:02:31 -0400 | [diff] [blame] | 61 | { |
Edric Milaret | 031c305 | 2015-04-29 18:14:18 -0400 | [diff] [blame] | 62 | auto account = AccountModel::instance()->add(ui->usernameEdit->text(), Account::Protocol::RING); |
Edric Milaret | 67007d1 | 2015-05-07 09:40:09 -0400 | [diff] [blame] | 63 | AccountModel::instance()->ip2ip()->setRingtonePath(Utils::GetRingtonePath()); |
Edric Milaret | 031c305 | 2015-04-29 18:14:18 -0400 | [diff] [blame] | 64 | account->setRingtonePath(Utils::GetRingtonePath()); |
Edric Milaret | 559bda5 | 2015-04-29 17:02:31 -0400 | [diff] [blame] | 65 | AccountModel::instance()->save(); |
| 66 | Utils::CreateStartupLink(); |
Edric Milaret | 67007d1 | 2015-05-07 09:40:09 -0400 | [diff] [blame] | 67 | endSetup(); |
Edric Milaret | 559bda5 | 2015-04-29 17:02:31 -0400 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | void |
| 71 | WizardDialog::on_usernameEdit_textChanged(const QString &arg1) |
| 72 | { |
| 73 | ui->buttonBox->setEnabled(!arg1.isEmpty()); |
| 74 | } |