mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-10 23:07:59 +00:00
speedwidget class: excess QtConcurent usage removal
This commit is contained in:
parent
7a652c0a8c
commit
9d0ab0ae5f
@ -13,7 +13,7 @@ find_package(LibtorrentRasterbar REQUIRED)
|
|||||||
# Qt
|
# Qt
|
||||||
list(APPEND QBT_QT_COMPONENTS Core Network Xml)
|
list(APPEND QBT_QT_COMPONENTS Core Network Xml)
|
||||||
if (GUI)
|
if (GUI)
|
||||||
list (APPEND QBT_QT_COMPONENTS Concurrent Gui Svg Widgets)
|
list (APPEND QBT_QT_COMPONENTS Gui Svg Widgets)
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
list (APPEND QBT_QT_COMPONENTS WinExtras)
|
list (APPEND QBT_QT_COMPONENTS WinExtras)
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
@ -44,4 +44,4 @@ speedplotview.cpp
|
|||||||
|
|
||||||
add_library(qbt_properties STATIC ${QBT_PROPERTIES_HEADERS} ${QBT_PROPERTIES_SOURCES} ${QBT_PROPERTIES_FORMS})
|
add_library(qbt_properties STATIC ${QBT_PROPERTIES_HEADERS} ${QBT_PROPERTIES_SOURCES} ${QBT_PROPERTIES_FORMS})
|
||||||
target_link_libraries(qbt_properties qbt_base)
|
target_link_libraries(qbt_properties qbt_base)
|
||||||
target_link_libraries(qbt_properties Qt5::Widgets Qt5::Concurrent)
|
target_link_libraries(qbt_properties Qt5::Widgets)
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QSignalMapper>
|
#include <QSignalMapper>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include <libtorrent/session_status.hpp>
|
#include <libtorrent/session_status.hpp>
|
||||||
|
|
||||||
@ -116,8 +117,9 @@ SpeedWidget::SpeedWidget(PropertiesWidget *parent)
|
|||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
|
||||||
m_isUpdating = true;
|
QTimer *localUpdateTimer = new QTimer(this);
|
||||||
m_updateFuture = QtConcurrent::run(this, &SpeedWidget::update);
|
connect(localUpdateTimer, &QTimer::timeout, this, &SpeedWidget::update);
|
||||||
|
localUpdateTimer->start(1000);
|
||||||
|
|
||||||
m_plot->show();
|
m_plot->show();
|
||||||
}
|
}
|
||||||
@ -125,43 +127,28 @@ SpeedWidget::SpeedWidget(PropertiesWidget *parent)
|
|||||||
SpeedWidget::~SpeedWidget()
|
SpeedWidget::~SpeedWidget()
|
||||||
{
|
{
|
||||||
qDebug("SpeedWidget::~SpeedWidget() ENTER");
|
qDebug("SpeedWidget::~SpeedWidget() ENTER");
|
||||||
|
|
||||||
m_isUpdating = false;
|
|
||||||
m_updateFuture.waitForFinished();
|
|
||||||
|
|
||||||
saveSettings();
|
saveSettings();
|
||||||
|
|
||||||
qDebug("SpeedWidget::~SpeedWidget() EXIT");
|
qDebug("SpeedWidget::~SpeedWidget() EXIT");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpeedWidget::update()
|
void SpeedWidget::update()
|
||||||
{
|
{
|
||||||
while (m_isUpdating) {
|
const BitTorrent::SessionStatus &btStatus = BitTorrent::Session::instance()->status();
|
||||||
|
|
||||||
const BitTorrent::SessionStatus &btStatus = BitTorrent::Session::instance()->status();
|
SpeedPlotView::PointData point;
|
||||||
|
point.x = QDateTime::currentDateTime().toTime_t();
|
||||||
|
point.y[SpeedPlotView::UP] = btStatus.uploadRate;
|
||||||
|
point.y[SpeedPlotView::DOWN] = btStatus.downloadRate;
|
||||||
|
point.y[SpeedPlotView::PAYLOAD_UP] = btStatus.payloadUploadRate;
|
||||||
|
point.y[SpeedPlotView::PAYLOAD_DOWN] = btStatus.payloadDownloadRate;
|
||||||
|
point.y[SpeedPlotView::OVERHEAD_UP] = btStatus.ipOverheadUploadRate;
|
||||||
|
point.y[SpeedPlotView::OVERHEAD_DOWN] = btStatus.ipOverheadDownloadRate;
|
||||||
|
point.y[SpeedPlotView::DHT_UP] = btStatus.dhtUploadRate;
|
||||||
|
point.y[SpeedPlotView::DHT_DOWN] = btStatus.dhtDownloadRate;
|
||||||
|
point.y[SpeedPlotView::TRACKER_UP] = btStatus.trackerUploadRate;
|
||||||
|
point.y[SpeedPlotView::TRACKER_DOWN] = btStatus.trackerDownloadRate;
|
||||||
|
|
||||||
SpeedPlotView::PointData point;
|
m_plot->pushPoint(point);
|
||||||
point.x = QDateTime::currentDateTime().toTime_t();
|
|
||||||
point.y[SpeedPlotView::UP] = btStatus.uploadRate;
|
|
||||||
point.y[SpeedPlotView::DOWN] = btStatus.downloadRate;
|
|
||||||
point.y[SpeedPlotView::PAYLOAD_UP] = btStatus.payloadUploadRate;
|
|
||||||
point.y[SpeedPlotView::PAYLOAD_DOWN] = btStatus.payloadDownloadRate;
|
|
||||||
point.y[SpeedPlotView::OVERHEAD_UP] = btStatus.ipOverheadUploadRate;
|
|
||||||
point.y[SpeedPlotView::OVERHEAD_DOWN] = btStatus.ipOverheadDownloadRate;
|
|
||||||
point.y[SpeedPlotView::DHT_UP] = btStatus.dhtUploadRate;
|
|
||||||
point.y[SpeedPlotView::DHT_DOWN] = btStatus.dhtDownloadRate;
|
|
||||||
point.y[SpeedPlotView::TRACKER_UP] = btStatus.trackerUploadRate;
|
|
||||||
point.y[SpeedPlotView::TRACKER_DOWN] = btStatus.trackerDownloadRate;
|
|
||||||
|
|
||||||
m_plot->pushPoint(point);
|
|
||||||
|
|
||||||
QMetaObject::invokeMethod(this, "graphUpdate", Qt::QueuedConnection);
|
|
||||||
QThread::msleep(1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpeedWidget::graphUpdate()
|
|
||||||
{
|
|
||||||
m_plot->replot();
|
m_plot->replot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QtConcurrentRun>
|
|
||||||
|
|
||||||
#include "speedplotview.h"
|
#include "speedplotview.h"
|
||||||
|
|
||||||
@ -64,12 +63,11 @@ public:
|
|||||||
private slots:
|
private slots:
|
||||||
void onPeriodChange(int period);
|
void onPeriodChange(int period);
|
||||||
void onGraphChange(int id);
|
void onGraphChange(int id);
|
||||||
|
void update();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void update();
|
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
void saveSettings() const;
|
void saveSettings() const;
|
||||||
Q_INVOKABLE void graphUpdate();
|
|
||||||
|
|
||||||
QVBoxLayout *m_layout;
|
QVBoxLayout *m_layout;
|
||||||
QHBoxLayout *m_hlayout;
|
QHBoxLayout *m_hlayout;
|
||||||
@ -81,9 +79,6 @@ private:
|
|||||||
QMenu *m_graphsMenu;
|
QMenu *m_graphsMenu;
|
||||||
QList<QAction *> m_graphsMenuActions;
|
QList<QAction *> m_graphsMenuActions;
|
||||||
QSignalMapper *m_graphsSignalMapper;
|
QSignalMapper *m_graphsSignalMapper;
|
||||||
|
|
||||||
QFuture<void> m_updateFuture;
|
|
||||||
bool m_isUpdating;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SPEEDWIDGET_H
|
#endif // SPEEDWIDGET_H
|
||||||
|
@ -19,7 +19,7 @@ nogui {
|
|||||||
DEFINES += DISABLE_GUI
|
DEFINES += DISABLE_GUI
|
||||||
} else {
|
} else {
|
||||||
TARGET = qbittorrent
|
TARGET = qbittorrent
|
||||||
QT += xml concurrent svg widgets
|
QT += xml svg widgets
|
||||||
|
|
||||||
CONFIG(static) {
|
CONFIG(static) {
|
||||||
DEFINES += QBT_STATIC_QT
|
DEFINES += QBT_STATIC_QT
|
||||||
|
Loading…
Reference in New Issue
Block a user