blob: ef8c5751c2c9d4d81490d85e41c68d5611f60c7a [file] [log] [blame]
Olivier SOLDANO9b7e80d2017-05-04 16:06:01 -04001/***************************************************************************
Isa Nanic6e4a39a2018-12-04 14:26:02 -05002 * Copyright (C) 2015-2018 by Savoir-faire Linux *
Olivier SOLDANO9b7e80d2017-05-04 16:06:01 -04003 * Author: Olivier Soldano <olivier.soldano@savoirfairelinux.com> *
Isa Nanic6e4a39a2018-12-04 14:26:02 -05004 * Author: Isa Nanic <isa.nanic@savoirfairelinux.com> *
Olivier SOLDANO9b7e80d2017-05-04 16:06:01 -04005 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 **************************************************************************/
19
20#include "deleteaccountdialog.h"
21#include "ui_deleteaccountdialog.h"
22
Isa Nanic6e4a39a2018-12-04 14:26:02 -050023#include "lrcinstance.h"
24#include "utils.h"
Olivier SOLDANO9b7e80d2017-05-04 16:06:01 -040025
Isa Nanic6e4a39a2018-12-04 14:26:02 -050026DeleteAccountDialog::DeleteAccountDialog(QWidget *parent) :
Olivier SOLDANO9b7e80d2017-05-04 16:06:01 -040027 QDialog(parent),
Isa Nanic6e4a39a2018-12-04 14:26:02 -050028 ui(new Ui::DeleteAccountDialog)
Olivier SOLDANO9b7e80d2017-05-04 16:06:01 -040029{
Olivier SOLDANO9b7e80d2017-05-04 16:06:01 -040030 ui->setupUi(this);
Isa Nanic6e4a39a2018-12-04 14:26:02 -050031 if (LRCInstance::getCurrentAccountInfo().profileInfo.type == lrc::api::profile::Type::RING){
32 ui->labelBestId->setText(QString::fromStdString(Utils::bestNameForAccount(LRCInstance::getCurrentAccountInfo())));
33 ui->labelAccountHash->setText(QString::fromStdString(LRCInstance::getCurrentAccountInfo().profileInfo.uri));
Olivier SOLDANO9b7e80d2017-05-04 16:06:01 -040034 } else {
Isa Nanic6e4a39a2018-12-04 14:26:02 -050035 ui->labelWarning->hide();
Olivier SOLDANO9b7e80d2017-05-04 16:06:01 -040036 }
Isa Nanic6e4a39a2018-12-04 14:26:02 -050037 connect(ui->btnDeleteAccept, &QPushButton::clicked, this, &DeleteAccountDialog::on_deleteAcceptBtn_clicked);
38 connect(ui->btnDeleteCancel, &QPushButton::clicked, this, &DeleteAccountDialog::on_deleteCancelBtn_clicked);
Olivier SOLDANO9b7e80d2017-05-04 16:06:01 -040039}
40
41DeleteAccountDialog::~DeleteAccountDialog()
42{
43 delete ui;
44}
45
Isa Nanic6e4a39a2018-12-04 14:26:02 -050046void
47DeleteAccountDialog::on_deleteCancelBtn_clicked()
Olivier SOLDANO9b7e80d2017-05-04 16:06:01 -040048{
Isa Nanic6e4a39a2018-12-04 14:26:02 -050049 done(0);
Olivier SOLDANO9b7e80d2017-05-04 16:06:01 -040050}
51
Isa Nanic6e4a39a2018-12-04 14:26:02 -050052void
53DeleteAccountDialog::on_deleteAcceptBtn_clicked()
Olivier SOLDANO9b7e80d2017-05-04 16:06:01 -040054{
Isa Nanic6e4a39a2018-12-04 14:26:02 -050055 LRCInstance::editableAccountModel()->removeAccount(LRCInstance::getCurrAccId());
56 done(0);
57}