deleteaccountdialog.cpp 2.63 KB
Newer Older
1
/***************************************************************************
2
 * Copyright (C) 2015-2019 by Savoir-faire Linux                           *
3
 * Author: Olivier Soldano <olivier.soldano@savoirfairelinux.com>          *
4
 * Author: Isa Nanic <isa.nanic@savoirfairelinux.com>                      *
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
 *                                                                         *
 * 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/>.   *
 **************************************************************************/

#include "deleteaccountdialog.h"
#include "ui_deleteaccountdialog.h"

23 24
#include "lrcinstance.h"
#include "utils.h"
25

26
DeleteAccountDialog::DeleteAccountDialog(QWidget *parent) :
27
    QDialog(parent),
28
    ui(new Ui::DeleteAccountDialog)
29 30
{
    ui->setupUi(this);
31 32 33
    if (LRCInstance::getCurrentAccountInfo().profileInfo.type == lrc::api::profile::Type::RING){
        ui->labelBestId->setText(QString::fromStdString(Utils::bestNameForAccount(LRCInstance::getCurrentAccountInfo())));
        ui->labelAccountHash->setText(QString::fromStdString(LRCInstance::getCurrentAccountInfo().profileInfo.uri));
34
    } else {
35
        ui->labelWarning->hide();
36
    }
37 38
    connect(ui->btnDeleteAccept, &QPushButton::clicked, this, &DeleteAccountDialog::on_deleteAcceptBtn_clicked);
    connect(ui->btnDeleteCancel, &QPushButton::clicked, this, &DeleteAccountDialog::on_deleteCancelBtn_clicked);
39 40

    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
Andreas Traczyk's avatar
Andreas Traczyk committed
41
    setFixedSize(size());
42 43 44 45 46 47 48
}

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

49 50
void
DeleteAccountDialog::on_deleteCancelBtn_clicked()
51
{
52
    done(DialogCode::Rejected);
53 54
}

55 56
void
DeleteAccountDialog::on_deleteAcceptBtn_clicked()
57
{
58
    LRCInstance::editableAccountModel()->removeAccount(LRCInstance::getCurrAccId());
59
    done(DialogCode::Accepted);
60
}