Browse Source

Merge pull request #9590 from dzmat/disable_graphs_collection

Implement option for disabling speed graphs
adaptive-webui-19844
Vladimir Golovnev 6 years ago committed by GitHub
parent
commit
72e148e0f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      src/base/preferences.cpp
  2. 2
      src/base/preferences.h
  3. 5
      src/gui/advancedsettings.cpp
  4. 2
      src/gui/advancedsettings.h
  5. 34
      src/gui/properties/propertieswidget.cpp
  6. 4
      src/gui/properties/propertieswidget.h

10
src/base/preferences.cpp

@ -1431,6 +1431,16 @@ void Preferences::setNetworkCookies(const QList<QNetworkCookie> &cookies) @@ -1431,6 +1431,16 @@ void Preferences::setNetworkCookies(const QList<QNetworkCookie> &cookies)
setValue("Network/Cookies", rawCookies);
}
bool Preferences::isSpeedWidgetEnabled() const
{
return value("SpeedWidget/Enabled", true).toBool();
}
void Preferences::setSpeedWidgetEnabled(bool enabled)
{
setValue("SpeedWidget/Enabled", enabled);
}
int Preferences::getSpeedWidgetPeriod() const
{
return value("SpeedWidget/period", 1).toInt();

2
src/base/preferences.h

@ -371,6 +371,8 @@ public: @@ -371,6 +371,8 @@ public:
void setNetworkCookies(const QList<QNetworkCookie> &cookies);
// SpeedWidget
bool isSpeedWidgetEnabled() const;
void setSpeedWidgetEnabled(bool enabled);
int getSpeedWidgetPeriod() const;
void setSpeedWidgetPeriod(const int period);
bool getSpeedWidgetGraphEnable(int id) const;

5
src/gui/advancedsettings.cpp

@ -73,6 +73,7 @@ enum AdvSettingsRows @@ -73,6 +73,7 @@ enum AdvSettingsRows
CONFIRM_REMOVE_ALL_TAGS,
DOWNLOAD_TRACKER_FAVICON,
SAVE_PATH_HISTORY_LENGTH,
ENABLE_SPEED_WIDGET,
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
USE_ICON_THEME,
#endif
@ -218,6 +219,7 @@ void AdvancedSettings::saveAdvancedSettings() @@ -218,6 +219,7 @@ void AdvancedSettings::saveAdvancedSettings()
// Misc GUI properties
mainWindow->setDownloadTrackerFavicon(checkBoxTrackerFavicon.isChecked());
AddNewTorrentDialog::setSavePathHistoryLength(spinBoxSavePathHistoryLength.value());
pref->setSpeedWidgetEnabled(checkBoxSpeedWidgetEnabled.isChecked());
// Tracker
session->setTrackerEnabled(checkBoxTrackerStatus.isChecked());
@ -467,6 +469,9 @@ void AdvancedSettings::loadAdvancedSettings() @@ -467,6 +469,9 @@ void AdvancedSettings::loadAdvancedSettings()
spinBoxSavePathHistoryLength.setRange(AddNewTorrentDialog::minPathHistoryLength, AddNewTorrentDialog::maxPathHistoryLength);
spinBoxSavePathHistoryLength.setValue(AddNewTorrentDialog::savePathHistoryLength());
addRow(SAVE_PATH_HISTORY_LENGTH, tr("Save path history length"), &spinBoxSavePathHistoryLength);
// Enable speed graphs
checkBoxSpeedWidgetEnabled.setChecked(pref->isSpeedWidgetEnabled());
addRow(ENABLE_SPEED_WIDGET, tr("Enable speed graphs"), &checkBoxSpeedWidgetEnabled);
// Tracker State
checkBoxTrackerStatus.setChecked(session->isTrackerEnabled());
addRow(TRACKER_STATUS, tr("Enable embedded tracker"), &checkBoxTrackerStatus);

2
src/gui/advancedsettings.h

@ -65,7 +65,7 @@ private: @@ -65,7 +65,7 @@ private:
QCheckBox checkBoxOsCache, checkBoxRecheckCompleted, checkBoxResolveCountries, checkBoxResolveHosts, checkBoxSuperSeeding,
checkBoxProgramNotifications, checkBoxTorrentAddedNotifications, checkBoxTrackerFavicon, checkBoxTrackerStatus,
checkBoxConfirmTorrentRecheck, checkBoxConfirmRemoveAllTags, checkBoxListenIPv6, checkBoxAnnounceAllTrackers, checkBoxAnnounceAllTiers,
checkBoxGuidedReadCache, checkBoxMultiConnectionsPerIp, checkBoxSuggestMode, checkBoxCoalesceRW;
checkBoxGuidedReadCache, checkBoxMultiConnectionsPerIp, checkBoxSuggestMode, checkBoxCoalesceRW, checkBoxSpeedWidgetEnabled;
QComboBox comboBoxInterface, comboBoxInterfaceAddress, comboBoxUtpMixedMode, comboBoxChokingAlgorithm, comboBoxSeedChokingAlgorithm;
QLineEdit lineEditAnnounceIP;

34
src/gui/properties/propertieswidget.cpp

@ -140,9 +140,6 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran @@ -140,9 +140,6 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran
// Peers list
m_peerList = new PeerListWidget(this);
m_ui->vBoxLayoutPeerPage->addWidget(m_peerList);
// Speed widget
m_speedWidget = new SpeedWidget(this);
m_ui->speedLayout->addWidget(m_speedWidget);
// Tab bar
m_tabBar = new PropTabBar();
m_tabBar->setContentsMargins(0, 5, 0, 0);
@ -164,6 +161,9 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran @@ -164,6 +161,9 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran
connect(m_deleteHotkeyWeb, &QShortcut::activated, this, &PropertiesWidget::deleteSelectedUrlSeeds);
m_openHotkeyFile = new QShortcut(Qt::Key_Return, m_ui->filesList, nullptr, nullptr, Qt::WidgetShortcut);
connect(m_openHotkeyFile, &QShortcut::activated, this, &PropertiesWidget::openSelectedFile);
configure();
connect(Preferences::instance(), &Preferences::changed, this, &PropertiesWidget::configure);
}
PropertiesWidget::~PropertiesWidget()
@ -288,11 +288,6 @@ QTreeView *PropertiesWidget::getFilesList() const @@ -288,11 +288,6 @@ QTreeView *PropertiesWidget::getFilesList() const
return m_ui->filesList;
}
SpeedWidget *PropertiesWidget::getSpeedWidget() const
{
return m_speedWidget;
}
void PropertiesWidget::updateSavePath(BitTorrent::TorrentHandle *const torrent)
{
if (torrent == m_torrent)
@ -800,6 +795,29 @@ void PropertiesWidget::openSelectedFile() @@ -800,6 +795,29 @@ void PropertiesWidget::openSelectedFile()
openDoubleClickedFile(selectedIndexes.first());
}
void PropertiesWidget::configure()
{
// Speed widget
if (Preferences::instance()->isSpeedWidgetEnabled()) {
if (!m_speedWidget || !qobject_cast<SpeedWidget *>(m_speedWidget)) {
m_ui->speedLayout->removeWidget(m_speedWidget);
delete m_speedWidget;
m_speedWidget = new SpeedWidget {this};
m_ui->speedLayout->addWidget(m_speedWidget);
}
}
else {
if (!m_speedWidget || !qobject_cast<QLabel *>(m_speedWidget)) {
m_ui->speedLayout->removeWidget(m_speedWidget);
delete m_speedWidget;
auto *label = new QLabel(tr("<center><b>Speed graphs are disabled</b><p>You may change this setting in Advanced Options </center>"), this);
label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
m_speedWidget = label;
m_ui->speedLayout->addWidget(m_speedWidget);
}
}
}
void PropertiesWidget::askWebSeed()
{
bool ok;

4
src/gui/properties/propertieswidget.h

@ -75,7 +75,6 @@ public: @@ -75,7 +75,6 @@ public:
TrackerListWidget *getTrackerList() const;
PeerListWidget *getPeerList() const;
QTreeView *getFilesList() const;
SpeedWidget *getSpeedWidget() const;
public slots:
void setVisibility(bool visible);
@ -108,6 +107,7 @@ protected slots: @@ -108,6 +107,7 @@ protected slots:
void openSelectedFile();
private slots:
void configure();
void filterText(const QString &filter);
void updateSavePath(BitTorrent::TorrentHandle *const torrent);
@ -125,7 +125,7 @@ private: @@ -125,7 +125,7 @@ private:
PropListDelegate *m_propListDelegate;
PeerListWidget *m_peerList;
TrackerListWidget *m_trackerList;
SpeedWidget *m_speedWidget;
QWidget *m_speedWidget = nullptr;
QList<int> m_slideSizes;
DownloadedPiecesBar *m_downloadedPieces;
PieceAvailabilityBar *m_piecesAvailability;

Loading…
Cancel
Save