wizarddialog.cpp 2.84 KB
Newer Older
1
/***************************************************************************
2
 * Copyright (C) 2015-2016 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

#include "utils.h"

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

35 36 37 38 39 40 41
    setFixedSize(this->width(),this->height());

    ui->joinButton->setEnabled(false);

    QPixmap logo(":/images/logo-ring-standard-coul.png");
    ui->ringLogo->setPixmap(logo.scaledToHeight(100, Qt::SmoothTransformation));
    ui->ringLogo->setAlignment(Qt::AlignHCenter);
42 43 44 45 46 47 48 49
}

WizardDialog::~WizardDialog()
{
    delete ui;
}

void
50 51
WizardDialog::accept()
{
52
    ui->label->setText(tr("Please wait while we create your account."));
53
    ui->joinButton->setEnabled(false);
54 55
    ui->usernameEdit->setEnabled(false);

56
    repaint();
57

58
    Utils::CreateStartupLink();
59

Edric Milaret's avatar
Edric Milaret committed
60
    auto account = AccountModel::instance().add(ui->usernameEdit->text(), Account::Protocol::RING);
61
    account->setDisplayName(ui->usernameEdit->text());
Edric Milaret's avatar
Edric Milaret committed
62
    AccountModel::instance().ip2ip()->setRingtonePath(Utils::GetRingtonePath());
63
    account->setRingtonePath(Utils::GetRingtonePath());
64 65 66 67 68 69 70 71 72 73 74 75
    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();
76 77 78 79 80
}

void
WizardDialog::on_usernameEdit_textChanged(const QString &arg1)
{
81 82 83 84 85 86 87 88 89
    ui->joinButton->setEnabled(!arg1.isEmpty());
}

void
WizardDialog::closeEvent(QCloseEvent *event)
{
    Q_UNUSED(event)

    exit(0);
90
}