mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-19 21:03:30 -07:00
Convert to use private pointer for ui object
This commit is contained in:
parent
bb041c0eca
commit
e5dca50025
8 changed files with 88 additions and 57 deletions
|
@ -33,42 +33,46 @@
|
|||
#include <QPushButton>
|
||||
|
||||
#include "base/preferences.h"
|
||||
#include "base/utils/misc.h"
|
||||
#include "base/utils/string.h"
|
||||
#include "guiiconprovider.h"
|
||||
#include "ui_deletionconfirmationdialog.h"
|
||||
#include "utils.h"
|
||||
|
||||
class DeletionConfirmationDialog : public QDialog, private Ui::DeletionConfirmationDialog
|
||||
class DeletionConfirmationDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DeletionConfirmationDialog(QWidget *parent, const int &size, const QString &name, bool defaultDeleteFiles)
|
||||
: QDialog(parent)
|
||||
, m_ui(new Ui::DeletionConfirmationDialog)
|
||||
{
|
||||
setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
if (size == 1)
|
||||
label->setText(tr("Are you sure you want to delete '%1' from the transfer list?", "Are you sure you want to delete 'ubuntu-linux-iso' from the transfer list?").arg(name.toHtmlEscaped()));
|
||||
m_ui->label->setText(tr("Are you sure you want to delete '%1' from the transfer list?", "Are you sure you want to delete 'ubuntu-linux-iso' from the transfer list?").arg(name.toHtmlEscaped()));
|
||||
else
|
||||
label->setText(tr("Are you sure you want to delete these %1 torrents from the transfer list?", "Are you sure you want to delete these 5 torrents from the transfer list?").arg(QString::number(size)));
|
||||
m_ui->label->setText(tr("Are you sure you want to delete these %1 torrents from the transfer list?", "Are you sure you want to delete these 5 torrents from the transfer list?").arg(QString::number(size)));
|
||||
// Icons
|
||||
const QSize iconSize = Utils::Gui::largeIconSize();
|
||||
labelWarning->setPixmap(GuiIconProvider::instance()->getIcon("dialog-warning").pixmap(iconSize));
|
||||
labelWarning->setFixedWidth(iconSize.width());
|
||||
rememberBtn->setIcon(GuiIconProvider::instance()->getIcon("object-locked"));
|
||||
rememberBtn->setIconSize(Utils::Gui::mediumIconSize());
|
||||
m_ui->labelWarning->setPixmap(GuiIconProvider::instance()->getIcon("dialog-warning").pixmap(iconSize));
|
||||
m_ui->labelWarning->setFixedWidth(iconSize.width());
|
||||
m_ui->rememberBtn->setIcon(GuiIconProvider::instance()->getIcon("object-locked"));
|
||||
m_ui->rememberBtn->setIconSize(Utils::Gui::mediumIconSize());
|
||||
|
||||
checkPermDelete->setChecked(defaultDeleteFiles || Preferences::instance()->deleteTorrentFilesAsDefault());
|
||||
connect(checkPermDelete, &QCheckBox::clicked, this, &DeletionConfirmationDialog::updateRememberButtonState);
|
||||
buttonBox->button(QDialogButtonBox::Cancel)->setFocus();
|
||||
m_ui->checkPermDelete->setChecked(defaultDeleteFiles || Preferences::instance()->deleteTorrentFilesAsDefault());
|
||||
connect(m_ui->checkPermDelete, &QCheckBox::clicked, this, &DeletionConfirmationDialog::updateRememberButtonState);
|
||||
m_ui->buttonBox->button(QDialogButtonBox::Cancel)->setFocus();
|
||||
|
||||
Utils::Gui::resize(this);
|
||||
}
|
||||
|
||||
~DeletionConfirmationDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool shouldDeleteLocalFiles() const
|
||||
{
|
||||
return checkPermDelete->isChecked();
|
||||
return m_ui->checkPermDelete->isChecked();
|
||||
}
|
||||
|
||||
static bool askForDeletionConfirmation(QWidget *parent, bool &deleteLocalFiles, const int &size, const QString &name)
|
||||
|
@ -84,14 +88,17 @@ public:
|
|||
private slots:
|
||||
void updateRememberButtonState()
|
||||
{
|
||||
rememberBtn->setEnabled(checkPermDelete->isChecked() != Preferences::instance()->deleteTorrentFilesAsDefault());
|
||||
m_ui->rememberBtn->setEnabled(m_ui->checkPermDelete->isChecked() != Preferences::instance()->deleteTorrentFilesAsDefault());
|
||||
}
|
||||
|
||||
void on_rememberBtn_clicked()
|
||||
{
|
||||
Preferences::instance()->setDeleteTorrentFilesAsDefault(checkPermDelete->isChecked());
|
||||
rememberBtn->setEnabled(false);
|
||||
Preferences::instance()->setDeleteTorrentFilesAsDefault(m_ui->checkPermDelete->isChecked());
|
||||
m_ui->rememberBtn->setEnabled(false);
|
||||
}
|
||||
|
||||
private:
|
||||
Ui::DeletionConfirmationDialog *m_ui;
|
||||
};
|
||||
|
||||
#endif // DELETIONCONFIRMATIONDIALOG_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue