From 17c122e5ad5a46103e4e919390a5c392b3e7eacc Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Sun, 1 Sep 2013 16:03:01 +0300 Subject: [PATCH] Don't show the progress bar in AddNewTorrent dialog when not necessary. --- src/addnewtorrentdialog.cpp | 16 +++------------- src/addnewtorrentdialog.h | 4 +--- src/addnewtorrentdialog.ui | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/addnewtorrentdialog.cpp b/src/addnewtorrentdialog.cpp index 198d817f4..976d6dca7 100644 --- a/src/addnewtorrentdialog.cpp +++ b/src/addnewtorrentdialog.cpp @@ -63,11 +63,8 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent) : m_hasRenamedFile(false) { ui->setupUi(this); - m_progress = new QProgressBar(this); - m_progress->setMinimum(0); - m_progress->setMaximum(0); ui->lblMetaLoading->setVisible(false); - ui->buttonsHLayout->insertWidget(ui->buttonsHLayout->indexOf(ui->lblMetaLoading), m_progress); + ui->progMetaLoading->setVisible(false); QIniSettings settings; Preferences pref; @@ -96,7 +93,6 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent) : AddNewTorrentDialog::~AddNewTorrentDialog() { saveState(); - delete m_progress; delete ui; if (m_contentModel) delete m_contentModel; @@ -763,15 +759,9 @@ void AddNewTorrentDialog::updateMetadata(const QTorrentHandle &h) { } } -void AddNewTorrentDialog::setMetadataProgressIndicator(bool enabled, const QString &labelText) { +void AddNewTorrentDialog::setMetadataProgressIndicator(bool visibleIndicator, const QString &labelText) { // Always show info label when waiting for metadata ui->lblMetaLoading->setVisible(true); ui->lblMetaLoading->setText(labelText); - if (enabled) - m_progress->setEnabled(enabled); - else { - m_progress->setMaximum(1); - m_progress->setValue(1); - m_progress->setTextVisible(false); // Don't display %% completed - } + ui->progMetaLoading->setVisible(visibleIndicator); } diff --git a/src/addnewtorrentdialog.h b/src/addnewtorrentdialog.h index 7bd335d89..9ce3d9791 100644 --- a/src/addnewtorrentdialog.h +++ b/src/addnewtorrentdialog.h @@ -36,7 +36,6 @@ #include #include #include "qtorrenthandle.h" -#include QT_BEGIN_NAMESPACE namespace Ui { @@ -81,7 +80,7 @@ private: void updateFileNameInSavePaths(const QString& new_filename); void loadState(); void saveState(); - void setMetadataProgressIndicator(bool enabled, const QString &labelText = QString()); + void setMetadataProgressIndicator(bool visibleIndicator, const QString &labelText = QString()); private: Ui::AddNewTorrentDialog *ui; @@ -97,7 +96,6 @@ private: QStringList m_filesPath; bool m_hasRenamedFile; QShortcut *editHotkey; - QProgressBar *m_progress; }; #endif // ADDNEWTORRENTDIALOG_H diff --git a/src/addnewtorrentdialog.ui b/src/addnewtorrentdialog.ui index 475382ac9..e348b6233 100644 --- a/src/addnewtorrentdialog.ui +++ b/src/addnewtorrentdialog.ui @@ -186,6 +186,28 @@ + + + + + 0 + 0 + + + + 0 + + + -1 + + + false + + + %p% + + +