Browse Source

Don't show the progress bar in AddNewTorrent dialog when not necessary.

adaptive-webui-19844
sledgehammer999 11 years ago
parent
commit
17c122e5ad
  1. 16
      src/addnewtorrentdialog.cpp
  2. 4
      src/addnewtorrentdialog.h
  3. 22
      src/addnewtorrentdialog.ui

16
src/addnewtorrentdialog.cpp

@ -63,11 +63,8 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent) :
m_hasRenamedFile(false) m_hasRenamedFile(false)
{ {
ui->setupUi(this); ui->setupUi(this);
m_progress = new QProgressBar(this);
m_progress->setMinimum(0);
m_progress->setMaximum(0);
ui->lblMetaLoading->setVisible(false); ui->lblMetaLoading->setVisible(false);
ui->buttonsHLayout->insertWidget(ui->buttonsHLayout->indexOf(ui->lblMetaLoading), m_progress); ui->progMetaLoading->setVisible(false);
QIniSettings settings; QIniSettings settings;
Preferences pref; Preferences pref;
@ -96,7 +93,6 @@ AddNewTorrentDialog::AddNewTorrentDialog(QWidget *parent) :
AddNewTorrentDialog::~AddNewTorrentDialog() AddNewTorrentDialog::~AddNewTorrentDialog()
{ {
saveState(); saveState();
delete m_progress;
delete ui; delete ui;
if (m_contentModel) if (m_contentModel)
delete 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 // Always show info label when waiting for metadata
ui->lblMetaLoading->setVisible(true); ui->lblMetaLoading->setVisible(true);
ui->lblMetaLoading->setText(labelText); ui->lblMetaLoading->setText(labelText);
if (enabled) ui->progMetaLoading->setVisible(visibleIndicator);
m_progress->setEnabled(enabled);
else {
m_progress->setMaximum(1);
m_progress->setValue(1);
m_progress->setTextVisible(false); // Don't display %% completed
}
} }

4
src/addnewtorrentdialog.h

@ -36,7 +36,6 @@
#include <QUrl> #include <QUrl>
#include <libtorrent/torrent_info.hpp> #include <libtorrent/torrent_info.hpp>
#include "qtorrenthandle.h" #include "qtorrenthandle.h"
#include <QProgressBar>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
namespace Ui { namespace Ui {
@ -81,7 +80,7 @@ private:
void updateFileNameInSavePaths(const QString& new_filename); void updateFileNameInSavePaths(const QString& new_filename);
void loadState(); void loadState();
void saveState(); void saveState();
void setMetadataProgressIndicator(bool enabled, const QString &labelText = QString()); void setMetadataProgressIndicator(bool visibleIndicator, const QString &labelText = QString());
private: private:
Ui::AddNewTorrentDialog *ui; Ui::AddNewTorrentDialog *ui;
@ -97,7 +96,6 @@ private:
QStringList m_filesPath; QStringList m_filesPath;
bool m_hasRenamedFile; bool m_hasRenamedFile;
QShortcut *editHotkey; QShortcut *editHotkey;
QProgressBar *m_progress;
}; };
#endif // ADDNEWTORRENTDIALOG_H #endif // ADDNEWTORRENTDIALOG_H

22
src/addnewtorrentdialog.ui

@ -186,6 +186,28 @@
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="buttonsHLayout"> <layout class="QHBoxLayout" name="buttonsHLayout">
<item>
<widget class="QProgressBar" name="progMetaLoading">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>0</number>
</property>
<property name="value">
<number>-1</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
<property name="format">
<string notr="true">%p%</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QLabel" name="lblMetaLoading"> <widget class="QLabel" name="lblMetaLoading">
<property name="enabled"> <property name="enabled">

Loading…
Cancel
Save