Enable customizing the save statistics time interval
[qBittorrent.git] / src / gui / deletionconfirmationdialog.cpp
blob9f5fe5452521b775fe449991cae83cc38a1e1b98
1 /*
2 * Bittorrent Client using Qt and libtorrent.
3 * Copyright (C) 2024 Vladimir Golovnev <glassez@yandex.ru>
4 * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * In addition, as a special exception, the copyright holders give permission to
21 * link this program with the OpenSSL project's "OpenSSL" library (or with
22 * modified versions of it that use the same license as the "OpenSSL" library),
23 * and distribute the linked executables. You must obey the GNU General Public
24 * License in all respects for all of the code used other than "OpenSSL". If you
25 * modify file(s), you may extend this exception to your version of the file(s),
26 * but you are not obligated to do so. If you do not wish to do so, delete this
27 * exception statement from your version.
30 #include "deletionconfirmationdialog.h"
32 #include <QPushButton>
34 #include "base/bittorrent/session.h"
35 #include "base/global.h"
36 #include "base/preferences.h"
37 #include "uithememanager.h"
38 #include "utils.h"
40 DeletionConfirmationDialog::DeletionConfirmationDialog(QWidget *parent, const int size, const QString &name, const bool defaultDeleteFiles)
41 : QDialog(parent)
42 , m_ui(new Ui::DeletionConfirmationDialog)
44 m_ui->setupUi(this);
46 if (size == 1)
47 m_ui->label->setText(tr("Are you sure you want to remove '%1' from the transfer list?", "Are you sure you want to remove 'ubuntu-linux-iso' from the transfer list?").arg(name.toHtmlEscaped()));
48 else
49 m_ui->label->setText(tr("Are you sure you want to remove these %1 torrents from the transfer list?", "Are you sure you want to remove these 5 torrents from the transfer list?").arg(QString::number(size)));
51 // Icons
52 const QSize iconSize = Utils::Gui::largeIconSize();
53 m_ui->labelWarning->setPixmap(UIThemeManager::instance()->getIcon(u"dialog-warning"_s).pixmap(iconSize));
54 m_ui->labelWarning->setFixedWidth(iconSize.width());
55 m_ui->rememberBtn->setIcon(UIThemeManager::instance()->getIcon(u"object-locked"_s));
56 m_ui->rememberBtn->setIconSize(Utils::Gui::mediumIconSize());
58 m_ui->checkRemoveContent->setChecked(defaultDeleteFiles || Preferences::instance()->removeTorrentContent());
59 connect(m_ui->checkRemoveContent, &QCheckBox::clicked, this, &DeletionConfirmationDialog::updateRememberButtonState);
60 m_ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Remove"));
61 m_ui->buttonBox->button(QDialogButtonBox::Cancel)->setFocus();
63 connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
64 connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
67 DeletionConfirmationDialog::~DeletionConfirmationDialog()
69 delete m_ui;
72 bool DeletionConfirmationDialog::isRemoveContentSelected() const
74 return m_ui->checkRemoveContent->isChecked();
77 void DeletionConfirmationDialog::updateRememberButtonState()
79 m_ui->rememberBtn->setEnabled(m_ui->checkRemoveContent->isChecked() != Preferences::instance()->removeTorrentContent());
82 void DeletionConfirmationDialog::on_rememberBtn_clicked()
84 Preferences::instance()->setRemoveTorrentContent(m_ui->checkRemoveContent->isChecked());
85 m_ui->rememberBtn->setEnabled(false);