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)
setValue("Network/Cookies", rawCookies); 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 int Preferences::getSpeedWidgetPeriod() const
{ {
return value("SpeedWidget/period", 1).toInt(); return value("SpeedWidget/period", 1).toInt();

2
src/base/preferences.h

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

5
src/gui/advancedsettings.cpp

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

2
src/gui/advancedsettings.h

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

34
src/gui/properties/propertieswidget.cpp

@ -140,9 +140,6 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran
// Peers list // Peers list
m_peerList = new PeerListWidget(this); m_peerList = new PeerListWidget(this);
m_ui->vBoxLayoutPeerPage->addWidget(m_peerList); m_ui->vBoxLayoutPeerPage->addWidget(m_peerList);
// Speed widget
m_speedWidget = new SpeedWidget(this);
m_ui->speedLayout->addWidget(m_speedWidget);
// Tab bar // Tab bar
m_tabBar = new PropTabBar(); m_tabBar = new PropTabBar();
m_tabBar->setContentsMargins(0, 5, 0, 0); m_tabBar->setContentsMargins(0, 5, 0, 0);
@ -164,6 +161,9 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran
connect(m_deleteHotkeyWeb, &QShortcut::activated, this, &PropertiesWidget::deleteSelectedUrlSeeds); connect(m_deleteHotkeyWeb, &QShortcut::activated, this, &PropertiesWidget::deleteSelectedUrlSeeds);
m_openHotkeyFile = new QShortcut(Qt::Key_Return, m_ui->filesList, nullptr, nullptr, Qt::WidgetShortcut); m_openHotkeyFile = new QShortcut(Qt::Key_Return, m_ui->filesList, nullptr, nullptr, Qt::WidgetShortcut);
connect(m_openHotkeyFile, &QShortcut::activated, this, &PropertiesWidget::openSelectedFile); connect(m_openHotkeyFile, &QShortcut::activated, this, &PropertiesWidget::openSelectedFile);
configure();
connect(Preferences::instance(), &Preferences::changed, this, &PropertiesWidget::configure);
} }
PropertiesWidget::~PropertiesWidget() PropertiesWidget::~PropertiesWidget()
@ -288,11 +288,6 @@ QTreeView *PropertiesWidget::getFilesList() const
return m_ui->filesList; return m_ui->filesList;
} }
SpeedWidget *PropertiesWidget::getSpeedWidget() const
{
return m_speedWidget;
}
void PropertiesWidget::updateSavePath(BitTorrent::TorrentHandle *const torrent) void PropertiesWidget::updateSavePath(BitTorrent::TorrentHandle *const torrent)
{ {
if (torrent == m_torrent) if (torrent == m_torrent)
@ -800,6 +795,29 @@ void PropertiesWidget::openSelectedFile()
openDoubleClickedFile(selectedIndexes.first()); 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() void PropertiesWidget::askWebSeed()
{ {
bool ok; bool ok;

4
src/gui/properties/propertieswidget.h

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

Loading…
Cancel
Save