mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-12 05:44:14 +03:00
Improve Properties widget
Drop redundant dependencies. Refresh after BitTorrent session refreshing (instead of using timer).
This commit is contained in:
parent
5b82b681cb
commit
c631dbdaa1
3 changed files with 15 additions and 27 deletions
|
@ -240,8 +240,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
// Transfer List tab
|
||||
m_transferListWidget = new TransferListWidget(hSplitter, this);
|
||||
// transferList->setStyleSheet("QTreeView {border: none;}"); // borderless
|
||||
m_propertiesWidget = new PropertiesWidget(hSplitter, this, m_transferListWidget);
|
||||
// m_transferListWidget->setStyleSheet("QTreeView {border: none;}"); // borderless
|
||||
m_propertiesWidget = new PropertiesWidget(hSplitter);
|
||||
connect(m_transferListWidget, &TransferListWidget::currentTorrentChanged, m_propertiesWidget, &PropertiesWidget::loadTorrentInfos);
|
||||
m_transferListFiltersWidget = new TransferListFiltersWidget(m_splitter, m_transferListWidget);
|
||||
m_transferListFiltersWidget->setDownloadTrackerFavicon(isDownloadTrackerFavicon());
|
||||
hSplitter->addWidget(m_transferListWidget);
|
||||
|
@ -1526,6 +1527,9 @@ void MainWindow::loadPreferences(bool configureSession)
|
|||
// Check connection status and display right icon
|
||||
void MainWindow::updateGUI()
|
||||
{
|
||||
if (currentTabWidget() == m_transferListWidget)
|
||||
m_propertiesWidget->loadDynamicData();
|
||||
|
||||
const BitTorrent::SessionStatus &status = BitTorrent::Session::instance()->status();
|
||||
|
||||
// update global information
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include <QSplitter>
|
||||
#include <QStackedWidget>
|
||||
#include <QThread>
|
||||
#include <QTimer>
|
||||
|
||||
#include "base/bittorrent/filepriority.h"
|
||||
#include "base/bittorrent/session.h"
|
||||
|
@ -49,7 +48,6 @@
|
|||
#include "downloadedpiecesbar.h"
|
||||
#include "guiiconprovider.h"
|
||||
#include "lineedit.h"
|
||||
#include "mainwindow.h"
|
||||
#include "peerlistwidget.h"
|
||||
#include "pieceavailabilitybar.h"
|
||||
#include "proplistdelegate.h"
|
||||
|
@ -59,7 +57,6 @@
|
|||
#include "torrentcontentfiltermodel.h"
|
||||
#include "torrentcontentmodel.h"
|
||||
#include "trackerlistwidget.h"
|
||||
#include "transferlistwidget.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include "ui_propertieswidget.h"
|
||||
|
@ -68,11 +65,9 @@
|
|||
#include "macutilities.h"
|
||||
#endif
|
||||
|
||||
PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, TransferListWidget *transferList)
|
||||
PropertiesWidget::PropertiesWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::PropertiesWidget())
|
||||
, m_transferList(transferList)
|
||||
, m_mainWindow(mainWindow)
|
||||
, m_torrent(nullptr)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
@ -103,7 +98,6 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran
|
|||
connect(m_ui->filesList, &QAbstractItemView::doubleClicked, this, &PropertiesWidget::openDoubleClickedFile);
|
||||
connect(m_propListModel, &TorrentContentFilterModel::filteredFilesChanged, this, &PropertiesWidget::filteredFilesChanged);
|
||||
connect(m_ui->listWebSeeds, &QWidget::customContextMenuRequested, this, &PropertiesWidget::displayWebSeedListMenu);
|
||||
connect(transferList, &TransferListWidget::currentTorrentChanged, this, &PropertiesWidget::loadTorrentInfos);
|
||||
connect(m_propListDelegate, &PropListDelegate::filteredFilesChanged, this, &PropertiesWidget::filteredFilesChanged);
|
||||
connect(m_ui->stackedProperties, &QStackedWidget::currentChanged, this, &PropertiesWidget::loadDynamicData);
|
||||
connect(BitTorrent::Session::instance(), &BitTorrent::Session::torrentSavePathChanged, this, &PropertiesWidget::updateSavePath);
|
||||
|
@ -149,10 +143,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran
|
|||
connect(m_tabBar, &PropTabBar::tabChanged, this, &PropertiesWidget::saveSettings);
|
||||
connect(m_tabBar, &PropTabBar::visibilityToggled, this, &PropertiesWidget::setVisibility);
|
||||
connect(m_tabBar, &PropTabBar::visibilityToggled, this, &PropertiesWidget::saveSettings);
|
||||
// Dynamic data refresher
|
||||
m_refreshTimer = new QTimer(this);
|
||||
connect(m_refreshTimer, &QTimer::timeout, this, &PropertiesWidget::loadDynamicData);
|
||||
m_refreshTimer->start(3000); // 3sec
|
||||
|
||||
m_editHotkeyFile = new QShortcut(Qt::Key_F2, m_ui->filesList, nullptr, nullptr, Qt::WidgetShortcut);
|
||||
connect(m_editHotkeyFile, &QShortcut::activated, this, &PropertiesWidget::renameSelectedFile);
|
||||
m_editHotkeyWeb = new QShortcut(Qt::Key_F2, m_ui->listWebSeeds, nullptr, nullptr, Qt::WidgetShortcut);
|
||||
|
@ -170,7 +161,6 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran
|
|||
PropertiesWidget::~PropertiesWidget()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "ENTER";
|
||||
delete m_refreshTimer;
|
||||
delete m_trackerList;
|
||||
delete m_peerList;
|
||||
delete m_speedWidget;
|
||||
|
@ -394,7 +384,7 @@ void PropertiesWidget::reloadPreferences()
|
|||
void PropertiesWidget::loadDynamicData()
|
||||
{
|
||||
// Refresh only if the torrent handle is valid and visible
|
||||
if (!m_torrent || (m_mainWindow->currentTabWidget() != m_transferList) || (m_state != VISIBLE)) return;
|
||||
if (!m_torrent || (m_state != VISIBLE)) return;
|
||||
|
||||
// Transfer infos
|
||||
switch (m_ui->stackedProperties->currentIndex()) {
|
||||
|
|
|
@ -41,7 +41,6 @@ class QTreeView;
|
|||
|
||||
class DownloadedPiecesBar;
|
||||
class LineEdit;
|
||||
class MainWindow;
|
||||
class PeerListWidget;
|
||||
class PieceAvailabilityBar;
|
||||
class PropListDelegate;
|
||||
|
@ -50,7 +49,6 @@ class SpeedWidget;
|
|||
class torrent_file;
|
||||
class TorrentContentFilterModel;
|
||||
class TrackerListWidget;
|
||||
class TransferListWidget;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
|
@ -69,8 +67,9 @@ public:
|
|||
VISIBLE
|
||||
};
|
||||
|
||||
PropertiesWidget(QWidget *parent, MainWindow *mainWindow, TransferListWidget *transferList);
|
||||
~PropertiesWidget();
|
||||
explicit PropertiesWidget(QWidget *parent);
|
||||
~PropertiesWidget() override;
|
||||
|
||||
BitTorrent::TorrentHandle *getCurrentTorrent() const;
|
||||
TrackerListWidget *getTrackerList() const;
|
||||
PeerListWidget *getPeerList() const;
|
||||
|
@ -78,6 +77,7 @@ public:
|
|||
|
||||
public slots:
|
||||
void setVisibility(bool visible);
|
||||
void loadTorrentInfos(BitTorrent::TorrentHandle *const torrent);
|
||||
void loadDynamicData();
|
||||
void clear();
|
||||
void readSettings();
|
||||
|
@ -86,12 +86,7 @@ public slots:
|
|||
void openDoubleClickedFile(const QModelIndex &);
|
||||
void loadTrackers(BitTorrent::TorrentHandle *const torrent);
|
||||
|
||||
protected:
|
||||
QPushButton *getButtonFromIndex(int index);
|
||||
void applyPriorities();
|
||||
|
||||
protected slots:
|
||||
void loadTorrentInfos(BitTorrent::TorrentHandle *const torrent);
|
||||
void updateTorrentInfos(BitTorrent::TorrentHandle *const torrent);
|
||||
void loadUrlSeeds();
|
||||
void askWebSeed();
|
||||
|
@ -112,14 +107,13 @@ private slots:
|
|||
void updateSavePath(BitTorrent::TorrentHandle *const torrent);
|
||||
|
||||
private:
|
||||
QPushButton *getButtonFromIndex(int index);
|
||||
void applyPriorities();
|
||||
void openFile(const QModelIndex &index);
|
||||
void openFolder(const QModelIndex &index, bool containingFolder);
|
||||
|
||||
Ui::PropertiesWidget *m_ui;
|
||||
TransferListWidget *m_transferList;
|
||||
MainWindow *m_mainWindow;
|
||||
BitTorrent::TorrentHandle *m_torrent;
|
||||
QTimer *m_refreshTimer;
|
||||
SlideState m_state;
|
||||
TorrentContentFilterModel *m_propListModel;
|
||||
PropListDelegate *m_propListDelegate;
|
||||
|
|
Loading…
Reference in a new issue