mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-10 23:07:59 +00:00
- Refresh torrent properties and transfer list only when they are visible in order to save CPU :)
This commit is contained in:
parent
d6e1dc9020
commit
70c62f6294
22
src/GUI.cpp
22
src/GUI.cpp
@ -60,7 +60,6 @@
|
|||||||
#include "statusbar.h"
|
#include "statusbar.h"
|
||||||
|
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
enum TabIndex{TAB_TRANSFER, TAB_SEARCH, TAB_RSS};
|
|
||||||
|
|
||||||
/*****************************************************
|
/*****************************************************
|
||||||
* *
|
* *
|
||||||
@ -110,14 +109,15 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis
|
|||||||
|
|
||||||
qDebug("create tabWidget");
|
qDebug("create tabWidget");
|
||||||
tabs = new QTabWidget();
|
tabs = new QTabWidget();
|
||||||
|
connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(tab_changed(int)));
|
||||||
vSplitter = new QSplitter(Qt::Horizontal);
|
vSplitter = new QSplitter(Qt::Horizontal);
|
||||||
vSplitter->setChildrenCollapsible(false);
|
vSplitter->setChildrenCollapsible(false);
|
||||||
hSplitter = new QSplitter(Qt::Vertical);
|
hSplitter = new QSplitter(Qt::Vertical);
|
||||||
hSplitter->setChildrenCollapsible(false);
|
hSplitter->setChildrenCollapsible(false);
|
||||||
|
|
||||||
// Transfer List tab
|
// Transfer List tab
|
||||||
transferList = new TransferListWidget(hSplitter, BTSession);
|
transferList = new TransferListWidget(hSplitter, this, BTSession);
|
||||||
properties = new PropertiesWidget(hSplitter, transferList, BTSession);
|
properties = new PropertiesWidget(hSplitter, this, transferList, BTSession);
|
||||||
transferListFilters = new TransferListFiltersWidget(vSplitter, transferList);
|
transferListFilters = new TransferListFiltersWidget(vSplitter, transferList);
|
||||||
hSplitter->addWidget(transferList);
|
hSplitter->addWidget(transferList);
|
||||||
hSplitter->addWidget(properties);
|
hSplitter->addWidget(properties);
|
||||||
@ -246,6 +246,14 @@ void GUI::on_actionBugReport_triggered() const {
|
|||||||
QDesktopServices::openUrl(QUrl(QString::fromUtf8("http://bugs.qbittorrent.org")));
|
QDesktopServices::openUrl(QUrl(QString::fromUtf8("http://bugs.qbittorrent.org")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUI::tab_changed(int new_tab) {
|
||||||
|
if(new_tab == TAB_TRANSFER) {
|
||||||
|
qDebug("Changed tab to transfer list, refreshing the list");
|
||||||
|
transferList->refreshList();
|
||||||
|
properties->loadDynamicData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GUI::writeSettings() {
|
void GUI::writeSettings() {
|
||||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||||
settings.beginGroup(QString::fromUtf8("MainWindow"));
|
settings.beginGroup(QString::fromUtf8("MainWindow"));
|
||||||
@ -410,7 +418,7 @@ void GUI::previewFile(QString filePath) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int GUI::getCurrentTabIndex() const{
|
int GUI::getCurrentTabIndex() const{
|
||||||
if(isMinimized() || isHidden())
|
if(isMinimized() || !isVisible())
|
||||||
return -1;
|
return -1;
|
||||||
return tabs->currentIndex();
|
return tabs->currentIndex();
|
||||||
}
|
}
|
||||||
@ -463,7 +471,11 @@ void GUI::on_actionAbout_triggered() {
|
|||||||
|
|
||||||
void GUI::showEvent(QShowEvent *e) {
|
void GUI::showEvent(QShowEvent *e) {
|
||||||
qDebug("** Show Event **");
|
qDebug("** Show Event **");
|
||||||
//updateLists(true);
|
if(getCurrentTabIndex() == TAB_TRANSFER) {
|
||||||
|
qDebug("-> Refreshing transfer list");
|
||||||
|
transferList->refreshList();
|
||||||
|
properties->loadDynamicData();
|
||||||
|
}
|
||||||
e->accept();
|
e->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +37,8 @@
|
|||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include "qtorrenthandle.h"
|
#include "qtorrenthandle.h"
|
||||||
|
|
||||||
|
enum TabIndex{TAB_TRANSFER, TAB_SEARCH, TAB_RSS};
|
||||||
|
|
||||||
class Bittorrent;
|
class Bittorrent;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
class downloadFromURL;
|
class downloadFromURL;
|
||||||
@ -112,6 +114,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
|
|||||||
void fullDiskError(QTorrentHandle& h, QString msg) const;
|
void fullDiskError(QTorrentHandle& h, QString msg) const;
|
||||||
void handleDownloadFromUrlFailure(QString, QString) const;
|
void handleDownloadFromUrlFailure(QString, QString) const;
|
||||||
void createSystrayDelayed();
|
void createSystrayDelayed();
|
||||||
|
void tab_changed(int);
|
||||||
// Keyboard shortcuts
|
// Keyboard shortcuts
|
||||||
void createKeyboardShortcuts();
|
void createKeyboardShortcuts();
|
||||||
void displayTransferTab() const;
|
void displayTransferTab() const;
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
#include "torrentfilesmodel.h"
|
#include "torrentfilesmodel.h"
|
||||||
#include "peerlistwidget.h"
|
#include "peerlistwidget.h"
|
||||||
#include "trackerlist.h"
|
#include "trackerlist.h"
|
||||||
|
#include "GUI.h"
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
#define DEFAULT_BUTTON_CSS ""
|
#define DEFAULT_BUTTON_CSS ""
|
||||||
@ -57,7 +58,8 @@
|
|||||||
#define SELECTED_BUTTON_CSS "QPushButton {border: 1px solid rgb(85, 81, 91);border-radius: 3px;padding: 2px;background-color: rgb(255, 208, 105); margin-left: 3px; margin-right: 3px;}"
|
#define SELECTED_BUTTON_CSS "QPushButton {border: 1px solid rgb(85, 81, 91);border-radius: 3px;padding: 2px;background-color: rgb(255, 208, 105); margin-left: 3px; margin-right: 3px;}"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transferList, Bittorrent* BTSession): QWidget(parent), transferList(transferList), BTSession(BTSession) {
|
PropertiesWidget::PropertiesWidget(QWidget *parent, GUI* main_window, TransferListWidget *transferList, Bittorrent* BTSession):
|
||||||
|
QWidget(parent), transferList(transferList), main_window(main_window), BTSession(BTSession) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
state = VISIBLE;
|
state = VISIBLE;
|
||||||
|
|
||||||
@ -283,8 +285,9 @@ void PropertiesWidget::reloadPreferences() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesWidget::loadDynamicData() {
|
void PropertiesWidget::loadDynamicData() {
|
||||||
if(!h.is_valid()) return;
|
// Refresh only if the torrent handle is valid and if visible
|
||||||
if(state != VISIBLE) return;
|
if(!h.is_valid() || main_window->getCurrentTabIndex() != TAB_TRANSFER || state != VISIBLE) return;
|
||||||
|
qDebug("Refreshing torrent properties");
|
||||||
try {
|
try {
|
||||||
// Transfer infos
|
// Transfer infos
|
||||||
if(stackedProperties->currentIndex() == MAIN_TAB) {
|
if(stackedProperties->currentIndex() == MAIN_TAB) {
|
||||||
|
@ -47,6 +47,7 @@ class QAction;
|
|||||||
class torrent_file;
|
class torrent_file;
|
||||||
class PeerListWidget;
|
class PeerListWidget;
|
||||||
class TrackerList;
|
class TrackerList;
|
||||||
|
class GUI;
|
||||||
|
|
||||||
enum Tab {MAIN_TAB, TRACKERS_TAB, PEERS_TAB, URLSEEDS_TAB, FILES_TAB};
|
enum Tab {MAIN_TAB, TRACKERS_TAB, PEERS_TAB, URLSEEDS_TAB, FILES_TAB};
|
||||||
enum SlideState {REDUCED, VISIBLE};
|
enum SlideState {REDUCED, VISIBLE};
|
||||||
@ -56,6 +57,7 @@ class PropertiesWidget : public QWidget, private Ui::PropertiesWidget {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
TransferListWidget *transferList;
|
TransferListWidget *transferList;
|
||||||
|
GUI *main_window;
|
||||||
QTorrentHandle h;
|
QTorrentHandle h;
|
||||||
QTimer *refreshTimer;
|
QTimer *refreshTimer;
|
||||||
RealProgressBar *progressBar;
|
RealProgressBar *progressBar;
|
||||||
@ -78,7 +80,6 @@ protected:
|
|||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void loadTorrentInfos(QTorrentHandle &h);
|
void loadTorrentInfos(QTorrentHandle &h);
|
||||||
void loadDynamicData();
|
|
||||||
void loadUrlSeeds();
|
void loadUrlSeeds();
|
||||||
void on_main_infos_button_clicked();
|
void on_main_infos_button_clicked();
|
||||||
void on_trackers_button_clicked();
|
void on_trackers_button_clicked();
|
||||||
@ -96,6 +97,7 @@ protected slots:
|
|||||||
void filteredFilesChanged();
|
void filteredFilesChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void loadDynamicData();
|
||||||
void reduce();
|
void reduce();
|
||||||
void slide();
|
void slide();
|
||||||
void clear();
|
void clear();
|
||||||
@ -104,7 +106,7 @@ public slots:
|
|||||||
void reloadPreferences();
|
void reloadPreferences();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PropertiesWidget(QWidget *parent, TransferListWidget *transferList, Bittorrent* BTSession);
|
PropertiesWidget(QWidget *parent, GUI* main_window, TransferListWidget *transferList, Bittorrent* BTSession);
|
||||||
~PropertiesWidget();
|
~PropertiesWidget();
|
||||||
const QTorrentHandle& getCurrentTorrent() const;
|
const QTorrentHandle& getCurrentTorrent() const;
|
||||||
Bittorrent* getBTSession() const;
|
Bittorrent* getBTSession() const;
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "previewselect.h"
|
#include "previewselect.h"
|
||||||
#include "speedlimitdlg.h"
|
#include "speedlimitdlg.h"
|
||||||
#include "options_imp.h"
|
#include "options_imp.h"
|
||||||
|
#include "GUI.h"
|
||||||
#include "deletionconfirmationdlg.h"
|
#include "deletionconfirmationdlg.h"
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
@ -48,10 +49,10 @@
|
|||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
TransferListWidget::TransferListWidget(QWidget *parent, Bittorrent *_BTSession): QTreeView(parent) {
|
TransferListWidget::TransferListWidget(QWidget *parent, GUI *main_window, Bittorrent *_BTSession):
|
||||||
QSettings settings("qBittorrent", "qBittorrent");
|
QTreeView(parent), BTSession(_BTSession), main_window(main_window) {
|
||||||
BTSession = _BTSession;
|
|
||||||
|
|
||||||
|
QSettings settings("qBittorrent", "qBittorrent");
|
||||||
// Create and apply delegate
|
// Create and apply delegate
|
||||||
listDelegate = new TransferListDelegate(this);
|
listDelegate = new TransferListDelegate(this);
|
||||||
setItemDelegate(listDelegate);
|
setItemDelegate(listDelegate);
|
||||||
@ -386,6 +387,9 @@ void TransferListWidget::setRefreshInterval(int t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::refreshList() {
|
void TransferListWidget::refreshList() {
|
||||||
|
// Refresh only if displayed
|
||||||
|
if(main_window->getCurrentTabIndex() != TAB_TRANSFER) return;
|
||||||
|
qDebug("Refreshing transfer list");
|
||||||
unsigned int nb_downloading = 0, nb_seeding=0, nb_active=0, nb_inactive = 0;
|
unsigned int nb_downloading = 0, nb_seeding=0, nb_active=0, nb_inactive = 0;
|
||||||
for(int i=0; i<listModel->rowCount(); ++i) {
|
for(int i=0; i<listModel->rowCount(); ++i) {
|
||||||
int s = updateTorrent(i);
|
int s = updateTorrent(i);
|
||||||
|
@ -39,6 +39,7 @@ class QSortFilterProxyModel;
|
|||||||
class Bittorrent;
|
class Bittorrent;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
class TransferListDelegate;
|
class TransferListDelegate;
|
||||||
|
class GUI;
|
||||||
|
|
||||||
enum TorrentFilter {FILTER_ALL, FILTER_DOWNLOADING, FILTER_COMPLETED, FILTER_ACTIVE, FILTER_INACTIVE};
|
enum TorrentFilter {FILTER_ALL, FILTER_DOWNLOADING, FILTER_COMPLETED, FILTER_ACTIVE, FILTER_INACTIVE};
|
||||||
|
|
||||||
@ -51,9 +52,10 @@ private:
|
|||||||
QSortFilterProxyModel *proxyModel;
|
QSortFilterProxyModel *proxyModel;
|
||||||
Bittorrent* BTSession;
|
Bittorrent* BTSession;
|
||||||
QTimer *refreshTimer;
|
QTimer *refreshTimer;
|
||||||
|
GUI *main_window;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TransferListWidget(QWidget *parent, Bittorrent* BTSession);
|
TransferListWidget(QWidget *parent, GUI *main_window, Bittorrent* BTSession);
|
||||||
~TransferListWidget();
|
~TransferListWidget();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Loading…
Reference in New Issue
Block a user