blob: ae21ae3ae5b67a2e9bc7b58f11b36e2acca72696 [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
22#include "accountmodel.h"
23
24#include "utils.h"
25
26WizardDialog::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
38WizardDialog::~WizardDialog()
39{
40 delete ui;
41}
42
43void
Edric Milaret67007d12015-05-07 09:40:09 -040044WizardDialog::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
53void
54WizardDialog::endSetup()
55{
56 QDialog::accept();
57}
58
59void
60WizardDialog::setup()
Edric Milaret559bda52015-04-29 17:02:31 -040061{
Edric Milaret031c3052015-04-29 18:14:18 -040062 auto account = AccountModel::instance()->add(ui->usernameEdit->text(), Account::Protocol::RING);
Edric Milaret67007d12015-05-07 09:40:09 -040063 AccountModel::instance()->ip2ip()->setRingtonePath(Utils::GetRingtonePath());
Edric Milaret031c3052015-04-29 18:14:18 -040064 account->setRingtonePath(Utils::GetRingtonePath());
Edric Milaret559bda52015-04-29 17:02:31 -040065 AccountModel::instance()->save();
66 Utils::CreateStartupLink();
Edric Milaret67007d12015-05-07 09:40:09 -040067 endSetup();
Edric Milaret559bda52015-04-29 17:02:31 -040068}
69
70void
71WizardDialog::on_usernameEdit_textChanged(const QString &arg1)
72{
73 ui->buttonBox->setEnabled(!arg1.isEmpty());
74}