Browse Source

Convert to use private pointer for ui object

adaptive-webui-19844
Chocobo1 6 years ago
parent
commit
e5dca50025
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 17
      src/app/stacktracedialog.h
  2. 35
      src/gui/aboutdialog.h
  3. 41
      src/gui/deletionconfirmationdialog.h
  4. 37
      src/gui/previewselectdialog.cpp
  5. 8
      src/gui/previewselectdialog.h
  6. 4
      src/gui/previewselectdialog.ui
  7. 1
      src/gui/transferlistwidget.cpp
  8. 2
      src/gui/transferlistwidget.h

17
src/app/stacktracedialog.h

@ -30,21 +30,27 @@ @@ -30,21 +30,27 @@
#ifndef STACKTRACEDIALOG_H
#define STACKTRACEDIALOG_H
#include <QString>
#include <QDialog>
#include <QString>
#include "base/utils/misc.h"
#include "ui_stacktracedialog.h"
class StacktraceDialog : public QDialog, private Ui::StacktraceDialog
class StacktraceDialog : public QDialog
{
Q_OBJECT
public:
StacktraceDialog(QWidget *parent = nullptr)
: QDialog(parent)
, m_ui(new Ui::StacktraceDialog)
{
m_ui->setupUi(this);
}
~StacktraceDialog()
{
setupUi(this);
delete m_ui;
}
void setStacktraceString(const QString &sigName, const QString &trace)
@ -79,8 +85,11 @@ public: @@ -79,8 +85,11 @@ public:
, sigName
, trace);
errorText->setHtml(htmlStr);
m_ui->errorText->setHtml(htmlStr);
}
private:
Ui::StacktraceDialog *m_ui;
};
#endif // STACKTRACEDIALOG_H

35
src/gui/aboutdialog.h

@ -36,21 +36,22 @@ @@ -36,21 +36,22 @@
#include "ui_aboutdialog.h"
#include "utils.h"
class AboutDialog : public QDialog, private Ui::AboutDialog
class AboutDialog : public QDialog
{
Q_OBJECT
public:
AboutDialog(QWidget *parent)
: QDialog(parent)
, m_ui(new Ui::AboutDialog)
{
setupUi(this);
m_ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
// Title
labelName->setText(QString("<b><h2>qBittorrent " QBT_VERSION " (%1-bit)</h2></b>").arg(QT_POINTER_SIZE * 8));
m_ui->labelName->setText(QString("<b><h2>qBittorrent " QBT_VERSION " (%1-bit)</h2></b>").arg(QT_POINTER_SIZE * 8));
logo->setPixmap(Utils::Gui::scaledPixmapSvg(":/icons/skin/qbittorrent-tray.svg", this, 32));
m_ui->logo->setPixmap(Utils::Gui::scaledPixmapSvg(":/icons/skin/qbittorrent-tray.svg", this, 32));
// About
QString aboutText = QString(
@ -68,40 +69,48 @@ public: @@ -68,40 +69,48 @@ public:
, tr("Home Page:")
, tr("Forum:")
, tr("Bug Tracker:"));
labelAbout->setText(aboutText);
m_ui->labelAbout->setText(aboutText);
labelMascot->setPixmap(Utils::Gui::scaledPixmap(":/icons/skin/mascot.png", this));
m_ui->labelMascot->setPixmap(Utils::Gui::scaledPixmap(":/icons/skin/mascot.png", this));
// Thanks
QFile thanksfile(":/thanks.html");
if (thanksfile.open(QIODevice::ReadOnly | QIODevice::Text)) {
textBrowserThanks->setHtml(QString::fromUtf8(thanksfile.readAll().constData()));
m_ui->textBrowserThanks->setHtml(QString::fromUtf8(thanksfile.readAll().constData()));
thanksfile.close();
}
// Translation
QFile translatorsfile(":/translators.html");
if (translatorsfile.open(QIODevice::ReadOnly | QIODevice::Text)) {
textBrowserTranslation->setHtml(QString::fromUtf8(translatorsfile.readAll().constData()));
m_ui->textBrowserTranslation->setHtml(QString::fromUtf8(translatorsfile.readAll().constData()));
translatorsfile.close();
}
// License
QFile licensefile(":/gpl.html");
if (licensefile.open(QIODevice::ReadOnly | QIODevice::Text)) {
textBrowserLicense->setHtml(QString::fromUtf8(licensefile.readAll().constData()));
m_ui->textBrowserLicense->setHtml(QString::fromUtf8(licensefile.readAll().constData()));
licensefile.close();
}
// Libraries
labelQtVer->setText(QT_VERSION_STR);
labelLibtVer->setText(Utils::Misc::libtorrentVersionString());
labelBoostVer->setText(Utils::Misc::boostVersionString());
labelOpensslVer->setText(Utils::Misc::opensslVersionString());
m_ui->labelQtVer->setText(QT_VERSION_STR);
m_ui->labelLibtVer->setText(Utils::Misc::libtorrentVersionString());
m_ui->labelBoostVer->setText(Utils::Misc::boostVersionString());
m_ui->labelOpensslVer->setText(Utils::Misc::opensslVersionString());
Utils::Gui::resize(this);
show();
}
~AboutDialog()
{
delete m_ui;
}
private:
Ui::AboutDialog *m_ui;
};
#endif // ABOUTDIALOG_H

41
src/gui/deletionconfirmationdialog.h

@ -33,42 +33,46 @@ @@ -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: @@ -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

37
src/gui/previewselectdialog.cpp

@ -40,22 +40,24 @@ @@ -40,22 +40,24 @@
#include "base/utils/fs.h"
#include "base/utils/misc.h"
#include "previewlistdelegate.h"
#include "ui_previewselectdialog.h"
#include "utils.h"
#define SETTINGS_KEY(name) "PreviewSelectDialog/" name
PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, BitTorrent::TorrentHandle *const torrent)
: QDialog(parent)
, m_ui(new Ui::PreviewSelectDialog)
, m_torrent(torrent)
, m_storeDialogSize(SETTINGS_KEY("Dimension"))
, m_storeTreeHeaderState(SETTINGS_KEY("HeaderState"))
{
setupUi(this);
m_ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Preview"));
connect(buttonBox, &QDialogButtonBox::accepted, this, &PreviewSelectDialog::previewButtonClicked);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Preview"));
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &PreviewSelectDialog::previewButtonClicked);
connect(m_ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
Preferences *const pref = Preferences::instance();
// Preview list
@ -67,15 +69,15 @@ PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, BitTorrent::TorrentHan @@ -67,15 +69,15 @@ PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, BitTorrent::TorrentHan
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
QTableView unused;
unused.setVerticalHeader(previewList->header());
previewList->header()->setParent(previewList);
unused.setVerticalHeader(m_ui->previewList->header());
m_ui->previewList->header()->setParent(m_ui->previewList);
unused.setVerticalHeader(new QHeaderView(Qt::Horizontal));
previewList->setModel(m_previewListModel);
previewList->hideColumn(FILE_INDEX);
m_ui->previewList->setModel(m_previewListModel);
m_ui->previewList->hideColumn(FILE_INDEX);
m_listDelegate = new PreviewListDelegate(this);
previewList->setItemDelegate(m_listDelegate);
previewList->setAlternatingRowColors(pref->useAlternatingRowColors());
m_ui->previewList->setItemDelegate(m_listDelegate);
m_ui->previewList->setAlternatingRowColors(pref->useAlternatingRowColors());
// Fill list in
QVector<qreal> fp = torrent->filesProgress();
int nbFiles = torrent->filesCount();
@ -96,8 +98,8 @@ PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, BitTorrent::TorrentHan @@ -96,8 +98,8 @@ PreviewSelectDialog::PreviewSelectDialog(QWidget *parent, BitTorrent::TorrentHan
connect(this, SIGNAL(readyToPreviewFile(QString)), parent, SLOT(previewFile(QString)));
m_previewListModel->sort(NAME);
previewList->header()->setSortIndicator(0, Qt::AscendingOrder);
previewList->selectionModel()->select(m_previewListModel->index(0, NAME), QItemSelectionModel::Select | QItemSelectionModel::Rows);
m_ui->previewList->header()->setSortIndicator(0, Qt::AscendingOrder);
m_ui->previewList->selectionModel()->select(m_previewListModel->index(0, NAME), QItemSelectionModel::Select | QItemSelectionModel::Rows);
// Restore dialog state
loadWindowState();
@ -119,11 +121,12 @@ PreviewSelectDialog::~PreviewSelectDialog() @@ -119,11 +121,12 @@ PreviewSelectDialog::~PreviewSelectDialog()
delete m_previewListModel;
delete m_listDelegate;
delete m_ui;
}
void PreviewSelectDialog::previewButtonClicked()
{
QModelIndexList selectedIndexes = previewList->selectionModel()->selectedRows(FILE_INDEX);
QModelIndexList selectedIndexes = m_ui->previewList->selectionModel()->selectedRows(FILE_INDEX);
if (selectedIndexes.isEmpty()) return;
// Flush data
@ -146,7 +149,7 @@ void PreviewSelectDialog::saveWindowState() @@ -146,7 +149,7 @@ void PreviewSelectDialog::saveWindowState()
// Persist dialog size
m_storeDialogSize = size();
// Persist TreeView Header state
m_storeTreeHeaderState = previewList->header()->saveState();
m_storeTreeHeaderState = m_ui->previewList->header()->saveState();
}
void PreviewSelectDialog::loadWindowState()
@ -156,7 +159,7 @@ void PreviewSelectDialog::loadWindowState() @@ -156,7 +159,7 @@ void PreviewSelectDialog::loadWindowState()
// Restore TreeView Header state
if (!m_storeTreeHeaderState.value().isEmpty()) {
m_headerStateInitialized = previewList->header()->restoreState(m_storeTreeHeaderState);
m_headerStateInitialized = m_ui->previewList->header()->restoreState(m_storeTreeHeaderState);
}
}
@ -167,8 +170,8 @@ void PreviewSelectDialog::showEvent(QShowEvent *event) @@ -167,8 +170,8 @@ void PreviewSelectDialog::showEvent(QShowEvent *event)
// Default size, have to be called after show(), because width is needed
// Set Name column width to 60% of TreeView
if (!m_headerStateInitialized) {
int nameSize = (previewList->size().width() * 0.6);
previewList->header()->resizeSection(0, nameSize);
int nameSize = (m_ui->previewList->size().width() * 0.6);
m_ui->previewList->header()->resizeSection(0, nameSize);
m_headerStateInitialized = true;
}
}

8
src/gui/previewselectdialog.h

@ -32,7 +32,6 @@ @@ -32,7 +32,6 @@
#include <QDialog>
#include "base/settingvalue.h"
#include "ui_previewselectdialog.h"
class QStandardItemModel;
@ -40,9 +39,13 @@ namespace BitTorrent @@ -40,9 +39,13 @@ namespace BitTorrent
{
class TorrentHandle;
}
namespace Ui
{
class PreviewSelectDialog;
}
class PreviewListDelegate;
class PreviewSelectDialog : public QDialog, private Ui::preview
class PreviewSelectDialog : public QDialog
{
Q_OBJECT
@ -73,6 +76,7 @@ private: @@ -73,6 +76,7 @@ private:
void loadWindowState();
void saveWindowState();
Ui::PreviewSelectDialog *m_ui;
QStandardItemModel *m_previewListModel;
PreviewListDelegate *m_listDelegate;
BitTorrent::TorrentHandle *const m_torrent;

4
src/gui/previewselectdialog.ui

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>preview</class>
<widget class="QDialog" name="preview">
<class>PreviewSelectDialog</class>
<widget class="QDialog" name="PreviewSelectDialog">
<property name="geometry">
<rect>
<x>0</x>

1
src/gui/transferlistwidget.cpp

@ -31,6 +31,7 @@ @@ -31,6 +31,7 @@
#include <QClipboard>
#include <QDebug>
#include <QFileDialog>
#include <QHeaderView>
#include <QMenu>
#include <QMessageBox>
#include <QRegExp>

2
src/gui/transferlistwidget.h

@ -38,8 +38,6 @@ namespace BitTorrent @@ -38,8 +38,6 @@ namespace BitTorrent
}
class QShortcut;
class QSortFilterProxyModel;
class QStandardItemModel;
class MainWindow;
class TransferListDelegate;

Loading…
Cancel
Save