wizarddialog.cpp 2.96 KB
Newer Older
1
/***************************************************************************
Edric Milaret's avatar
Edric Milaret committed
2
 * Copyright (C) 2015 by Savoir-faire Linux                                *
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
 *                                                                         *
 * This program is free software; you can redistribute it and/or modify    *
 * it under the terms of the GNU General Public License as published by    *
 * the Free Software Foundation; either version 3 of the License, or       *
 * (at your option) any later version.                                     *
 *                                                                         *
 * This program is distributed in the hope that it will be useful,         *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
 * GNU General Public License for more details.                            *
 *                                                                         *
 * You should have received a copy of the GNU General Public License       *
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.   *
 **************************************************************************/

19 20 21
#include "wizarddialog.h"
#include "ui_wizarddialog.h"

22 23
#include <QMovie>

24
#include "accountmodel.h"
25
#include "account.h"
26 27 28 29 30 31 32 33 34 35 36 37 38

#include "utils.h"

WizardDialog::WizardDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::WizardDialog)
{
    ui->setupUi(this);

    this->setWindowFlags(Qt::CustomizeWindowHint);
    this->setWindowFlags(Qt::FramelessWindowHint);
    this->setFixedSize(this->width(),this->height());
    ui->buttonBox->setEnabled(false);
39 40 41 42 43 44 45 46

    ui->spinnerLabel->hide();
    QMovie* movie = new QMovie(":images/spinner.gif");
    if (movie->isValid())
    {
        ui->spinnerLabel->setMovie(movie);
        movie->start();
    }
47 48 49 50
}

WizardDialog::~WizardDialog()
{
Edric Milaret's avatar
Edric Milaret committed
51 52 53
    if (ui->spinnerLabel->movie()) {
        delete ui->spinnerLabel->movie();
    }
54 55 56 57
    delete ui;
}

void
58 59
WizardDialog::accept()
{
60
    //ui->spinnerLabel->show();
61
    ui->label->setText(tr("Please wait while we create your account."));
62 63 64
    ui->buttonBox->setEnabled(false);
    ui->usernameEdit->setEnabled(false);

65
    repaint();
66

67
    Utils::CreateStartupLink();
68

69
    auto account = AccountModel::instance()->add(ui->usernameEdit->text(), Account::Protocol::RING);
70
    account->setDisplayName(ui->usernameEdit->text());
71
    AccountModel::instance()->ip2ip()->setRingtonePath(Utils::GetRingtonePath());
72
    account->setRingtonePath(Utils::GetRingtonePath());
73 74 75 76 77 78 79 80 81 82 83 84
    account->setUpnpEnabled(true);

    connect(account, SIGNAL(changed(Account*)), this, SLOT(endSetup(Account*)));

    account->performAction(Account::EditAction::SAVE);
}

void
WizardDialog::endSetup(Account* a)
{
    Q_UNUSED(a)
    QDialog::accept();
85 86 87 88 89
}

void
WizardDialog::on_usernameEdit_textChanged(const QString &arg1)
{
90
    ui->buttonBox->setEnabled(!arg1.isEmpty());
91
}