Olivier SOLDANO | 9b7e80d | 2017-05-04 16:06:01 -0400 | [diff] [blame] | 1 | /*************************************************************************** |
Isa Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 2 | * Copyright (C) 2015-2018 by Savoir-faire Linux * |
Olivier SOLDANO | 9b7e80d | 2017-05-04 16:06:01 -0400 | [diff] [blame] | 3 | * Author: Olivier Soldano <olivier.soldano@savoirfairelinux.com> * |
Isa Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 4 | * Author: Isa Nanic <isa.nanic@savoirfairelinux.com> * |
Olivier SOLDANO | 9b7e80d | 2017-05-04 16:06:01 -0400 | [diff] [blame] | 5 | * * |
| 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 Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 23 | #include "lrcinstance.h" |
| 24 | #include "utils.h" |
Olivier SOLDANO | 9b7e80d | 2017-05-04 16:06:01 -0400 | [diff] [blame] | 25 | |
Isa Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 26 | DeleteAccountDialog::DeleteAccountDialog(QWidget *parent) : |
Olivier SOLDANO | 9b7e80d | 2017-05-04 16:06:01 -0400 | [diff] [blame] | 27 | QDialog(parent), |
Isa Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 28 | ui(new Ui::DeleteAccountDialog) |
Olivier SOLDANO | 9b7e80d | 2017-05-04 16:06:01 -0400 | [diff] [blame] | 29 | { |
Olivier SOLDANO | 9b7e80d | 2017-05-04 16:06:01 -0400 | [diff] [blame] | 30 | ui->setupUi(this); |
Isa Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 31 | 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 SOLDANO | 9b7e80d | 2017-05-04 16:06:01 -0400 | [diff] [blame] | 34 | } else { |
Isa Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 35 | ui->labelWarning->hide(); |
Olivier SOLDANO | 9b7e80d | 2017-05-04 16:06:01 -0400 | [diff] [blame] | 36 | } |
Isa Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 37 | connect(ui->btnDeleteAccept, &QPushButton::clicked, this, &DeleteAccountDialog::on_deleteAcceptBtn_clicked); |
| 38 | connect(ui->btnDeleteCancel, &QPushButton::clicked, this, &DeleteAccountDialog::on_deleteCancelBtn_clicked); |
Olivier SOLDANO | 9b7e80d | 2017-05-04 16:06:01 -0400 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | DeleteAccountDialog::~DeleteAccountDialog() |
| 42 | { |
| 43 | delete ui; |
| 44 | } |
| 45 | |
Isa Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 46 | void |
| 47 | DeleteAccountDialog::on_deleteCancelBtn_clicked() |
Olivier SOLDANO | 9b7e80d | 2017-05-04 16:06:01 -0400 | [diff] [blame] | 48 | { |
Isa Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 49 | done(0); |
Olivier SOLDANO | 9b7e80d | 2017-05-04 16:06:01 -0400 | [diff] [blame] | 50 | } |
| 51 | |
Isa Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 52 | void |
| 53 | DeleteAccountDialog::on_deleteAcceptBtn_clicked() |
Olivier SOLDANO | 9b7e80d | 2017-05-04 16:06:01 -0400 | [diff] [blame] | 54 | { |
Isa Nanic | 6e4a39a | 2018-12-04 14:26:02 -0500 | [diff] [blame] | 55 | LRCInstance::editableAccountModel()->removeAccount(LRCInstance::getCurrAccId()); |
| 56 | done(0); |
| 57 | } |