Browse Source

Merge pull request #10231 from glassez/properties

Improve Properties widget
adaptive-webui-19844
Vladimir Golovnev 6 years ago committed by GitHub
parent
commit
5c00d89d57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/gui/mainwindow.cpp
  2. 16
      src/gui/properties/propertieswidget.cpp
  3. 18
      src/gui/properties/propertieswidget.h

8
src/gui/mainwindow.cpp

@ -240,8 +240,9 @@ MainWindow::MainWindow(QWidget *parent)
// Transfer List tab // Transfer List tab
m_transferListWidget = new TransferListWidget(hSplitter, this); m_transferListWidget = new TransferListWidget(hSplitter, this);
// transferList->setStyleSheet("QTreeView {border: none;}"); // borderless // m_transferListWidget->setStyleSheet("QTreeView {border: none;}"); // borderless
m_propertiesWidget = new PropertiesWidget(hSplitter, this, m_transferListWidget); m_propertiesWidget = new PropertiesWidget(hSplitter);
connect(m_transferListWidget, &TransferListWidget::currentTorrentChanged, m_propertiesWidget, &PropertiesWidget::loadTorrentInfos);
m_transferListFiltersWidget = new TransferListFiltersWidget(m_splitter, m_transferListWidget); m_transferListFiltersWidget = new TransferListFiltersWidget(m_splitter, m_transferListWidget);
m_transferListFiltersWidget->setDownloadTrackerFavicon(isDownloadTrackerFavicon()); m_transferListFiltersWidget->setDownloadTrackerFavicon(isDownloadTrackerFavicon());
hSplitter->addWidget(m_transferListWidget); hSplitter->addWidget(m_transferListWidget);
@ -1526,6 +1527,9 @@ void MainWindow::loadPreferences(bool configureSession)
// Check connection status and display right icon // Check connection status and display right icon
void MainWindow::updateGUI() void MainWindow::updateGUI()
{ {
if (currentTabWidget() == m_transferListWidget)
m_propertiesWidget->loadDynamicData();
const BitTorrent::SessionStatus &status = BitTorrent::Session::instance()->status(); const BitTorrent::SessionStatus &status = BitTorrent::Session::instance()->status();
// update global information // update global information

16
src/gui/properties/propertieswidget.cpp

@ -36,7 +36,6 @@
#include <QSplitter> #include <QSplitter>
#include <QStackedWidget> #include <QStackedWidget>
#include <QThread> #include <QThread>
#include <QTimer>
#include "base/bittorrent/filepriority.h" #include "base/bittorrent/filepriority.h"
#include "base/bittorrent/session.h" #include "base/bittorrent/session.h"
@ -49,7 +48,6 @@
#include "downloadedpiecesbar.h" #include "downloadedpiecesbar.h"
#include "guiiconprovider.h" #include "guiiconprovider.h"
#include "lineedit.h" #include "lineedit.h"
#include "mainwindow.h"
#include "peerlistwidget.h" #include "peerlistwidget.h"
#include "pieceavailabilitybar.h" #include "pieceavailabilitybar.h"
#include "proplistdelegate.h" #include "proplistdelegate.h"
@ -59,7 +57,6 @@
#include "torrentcontentfiltermodel.h" #include "torrentcontentfiltermodel.h"
#include "torrentcontentmodel.h" #include "torrentcontentmodel.h"
#include "trackerlistwidget.h" #include "trackerlistwidget.h"
#include "transferlistwidget.h"
#include "utils.h" #include "utils.h"
#include "ui_propertieswidget.h" #include "ui_propertieswidget.h"
@ -68,11 +65,9 @@
#include "macutilities.h" #include "macutilities.h"
#endif #endif
PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, TransferListWidget *transferList) PropertiesWidget::PropertiesWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent)
, m_ui(new Ui::PropertiesWidget()) , m_ui(new Ui::PropertiesWidget())
, m_transferList(transferList)
, m_mainWindow(mainWindow)
, m_torrent(nullptr) , m_torrent(nullptr)
{ {
m_ui->setupUi(this); 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_ui->filesList, &QAbstractItemView::doubleClicked, this, &PropertiesWidget::openDoubleClickedFile);
connect(m_propListModel, &TorrentContentFilterModel::filteredFilesChanged, this, &PropertiesWidget::filteredFilesChanged); connect(m_propListModel, &TorrentContentFilterModel::filteredFilesChanged, this, &PropertiesWidget::filteredFilesChanged);
connect(m_ui->listWebSeeds, &QWidget::customContextMenuRequested, this, &PropertiesWidget::displayWebSeedListMenu); 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_propListDelegate, &PropListDelegate::filteredFilesChanged, this, &PropertiesWidget::filteredFilesChanged);
connect(m_ui->stackedProperties, &QStackedWidget::currentChanged, this, &PropertiesWidget::loadDynamicData); connect(m_ui->stackedProperties, &QStackedWidget::currentChanged, this, &PropertiesWidget::loadDynamicData);
connect(BitTorrent::Session::instance(), &BitTorrent::Session::torrentSavePathChanged, this, &PropertiesWidget::updateSavePath); 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::tabChanged, this, &PropertiesWidget::saveSettings);
connect(m_tabBar, &PropTabBar::visibilityToggled, this, &PropertiesWidget::setVisibility); connect(m_tabBar, &PropTabBar::visibilityToggled, this, &PropertiesWidget::setVisibility);
connect(m_tabBar, &PropTabBar::visibilityToggled, this, &PropertiesWidget::saveSettings); 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); m_editHotkeyFile = new QShortcut(Qt::Key_F2, m_ui->filesList, nullptr, nullptr, Qt::WidgetShortcut);
connect(m_editHotkeyFile, &QShortcut::activated, this, &PropertiesWidget::renameSelectedFile); connect(m_editHotkeyFile, &QShortcut::activated, this, &PropertiesWidget::renameSelectedFile);
m_editHotkeyWeb = new QShortcut(Qt::Key_F2, m_ui->listWebSeeds, nullptr, nullptr, Qt::WidgetShortcut); 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() PropertiesWidget::~PropertiesWidget()
{ {
qDebug() << Q_FUNC_INFO << "ENTER"; qDebug() << Q_FUNC_INFO << "ENTER";
delete m_refreshTimer;
delete m_trackerList; delete m_trackerList;
delete m_peerList; delete m_peerList;
delete m_speedWidget; delete m_speedWidget;
@ -394,7 +384,7 @@ void PropertiesWidget::reloadPreferences()
void PropertiesWidget::loadDynamicData() void PropertiesWidget::loadDynamicData()
{ {
// Refresh only if the torrent handle is valid and visible // 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 // Transfer infos
switch (m_ui->stackedProperties->currentIndex()) { switch (m_ui->stackedProperties->currentIndex()) {

18
src/gui/properties/propertieswidget.h

@ -41,7 +41,6 @@ class QTreeView;
class DownloadedPiecesBar; class DownloadedPiecesBar;
class LineEdit; class LineEdit;
class MainWindow;
class PeerListWidget; class PeerListWidget;
class PieceAvailabilityBar; class PieceAvailabilityBar;
class PropListDelegate; class PropListDelegate;
@ -50,7 +49,6 @@ class SpeedWidget;
class torrent_file; class torrent_file;
class TorrentContentFilterModel; class TorrentContentFilterModel;
class TrackerListWidget; class TrackerListWidget;
class TransferListWidget;
namespace Ui namespace Ui
{ {
@ -69,8 +67,9 @@ public:
VISIBLE VISIBLE
}; };
PropertiesWidget(QWidget *parent, MainWindow *mainWindow, TransferListWidget *transferList); explicit PropertiesWidget(QWidget *parent);
~PropertiesWidget(); ~PropertiesWidget() override;
BitTorrent::TorrentHandle *getCurrentTorrent() const; BitTorrent::TorrentHandle *getCurrentTorrent() const;
TrackerListWidget *getTrackerList() const; TrackerListWidget *getTrackerList() const;
PeerListWidget *getPeerList() const; PeerListWidget *getPeerList() const;
@ -78,6 +77,7 @@ public:
public slots: public slots:
void setVisibility(bool visible); void setVisibility(bool visible);
void loadTorrentInfos(BitTorrent::TorrentHandle *const torrent);
void loadDynamicData(); void loadDynamicData();
void clear(); void clear();
void readSettings(); void readSettings();
@ -86,12 +86,7 @@ public slots:
void openDoubleClickedFile(const QModelIndex &); void openDoubleClickedFile(const QModelIndex &);
void loadTrackers(BitTorrent::TorrentHandle *const torrent); void loadTrackers(BitTorrent::TorrentHandle *const torrent);
protected:
QPushButton *getButtonFromIndex(int index);
void applyPriorities();
protected slots: protected slots:
void loadTorrentInfos(BitTorrent::TorrentHandle *const torrent);
void updateTorrentInfos(BitTorrent::TorrentHandle *const torrent); void updateTorrentInfos(BitTorrent::TorrentHandle *const torrent);
void loadUrlSeeds(); void loadUrlSeeds();
void askWebSeed(); void askWebSeed();
@ -112,14 +107,13 @@ private slots:
void updateSavePath(BitTorrent::TorrentHandle *const torrent); void updateSavePath(BitTorrent::TorrentHandle *const torrent);
private: private:
QPushButton *getButtonFromIndex(int index);
void applyPriorities();
void openFile(const QModelIndex &index); void openFile(const QModelIndex &index);
void openFolder(const QModelIndex &index, bool containingFolder); void openFolder(const QModelIndex &index, bool containingFolder);
Ui::PropertiesWidget *m_ui; Ui::PropertiesWidget *m_ui;
TransferListWidget *m_transferList;
MainWindow *m_mainWindow;
BitTorrent::TorrentHandle *m_torrent; BitTorrent::TorrentHandle *m_torrent;
QTimer *m_refreshTimer;
SlideState m_state; SlideState m_state;
TorrentContentFilterModel *m_propListModel; TorrentContentFilterModel *m_propListModel;
PropListDelegate *m_propListDelegate; PropListDelegate *m_propListDelegate;

Loading…
Cancel
Save