-
Notifications
You must be signed in to change notification settings - Fork 294
Enhanced Traffic Graph Widget with Multi-timeframe Support and Data Persistence #866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rebroad
wants to merge
4
commits into
bitcoin-core:master
Choose a base branch
from
rebroad:trafficgraphwidget-rebased
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b47170f
qt: Add formatBytesps function for bytes per second display
rebroad 1aff5ee
net: Add setTotalBytes functionality for traffic data persistence
rebroad 72bf0e9
util: Add FormatISO8601Time function for time-only ISO format
rebroad ab7bbd0
qt: Enhance TrafficGraphWidget with multi-timeframe support and data …
rebroad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,6 @@ | |
using util::Join; | ||
|
||
const int CONSOLE_HISTORY = 50; | ||
const int INITIAL_TRAFFIC_GRAPH_MINS = 30; | ||
const QSize FONT_RANGE(4, 40); | ||
const char fontSizeSettingsKey[] = "consoleFontSize"; | ||
|
||
|
@@ -566,7 +565,6 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty | |
connect(ui->clearButton, &QAbstractButton::clicked, [this] { clear(); }); | ||
connect(ui->fontBiggerButton, &QAbstractButton::clicked, this, &RPCConsole::fontBigger); | ||
connect(ui->fontSmallerButton, &QAbstractButton::clicked, this, &RPCConsole::fontSmaller); | ||
connect(ui->btnClearTrafficGraph, &QPushButton::clicked, ui->trafficGraph, &TrafficGraphWidget::clear); | ||
|
||
// disable the wallet selector by default | ||
ui->WalletSelector->setVisible(false); | ||
|
@@ -578,7 +576,7 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty | |
// based timer interface | ||
m_node.rpcSetTimerInterfaceIfUnset(rpcTimerInterface); | ||
|
||
setTrafficGraphRange(INITIAL_TRAFFIC_GRAPH_MINS); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we losing this default constant? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because it isn't needed - on startup it "defaults" to the first non-full range |
||
setTrafficGraphRange(1); // 1 is the lowest setting (0 bumps up) | ||
updateDetailWidget(); | ||
|
||
consoleFontSize = settings.value(fontSizeSettingsKey, QFont().pointSize()).toInt(); | ||
|
@@ -1164,21 +1162,60 @@ void RPCConsole::scrollToEnd() | |
scrollbar->setValue(scrollbar->maximum()); | ||
} | ||
|
||
void RPCConsole::on_sldGraphRange_valueChanged(int value) | ||
void RPCConsole::on_sldGraphRange_valueChanged(int slider_value) | ||
{ | ||
const int multiplier = 5; // each position on the slider represents 5 min | ||
int mins = value * multiplier; | ||
setTrafficGraphRange(mins); | ||
static int64_t last_click_time = 0; | ||
static bool last_click_was_up = false; | ||
unsigned int value = (slider_value + 100) / 200 + 1; // minimum of 1, 0 reserve for scale bump | ||
if (!slider_in_use) { | ||
// Avoid accidental boucing of direction | ||
int64_t now = GetTime<std::chrono::milliseconds>().count(); | ||
bool this_click_is_up = false; | ||
bool bouncing = false; | ||
if (slider_value > set_slider_value) this_click_is_up = true; | ||
if (now - last_click_time < 250 && this_click_is_up != last_click_was_up) { | ||
bouncing = true; | ||
ui->sldGraphRange->blockSignals(true); | ||
ui->sldGraphRange->setValue(set_slider_value); | ||
ui->sldGraphRange->blockSignals(false); | ||
} | ||
last_click_time = now; | ||
last_click_was_up = this_click_is_up; | ||
set_slider_value = slider_value; | ||
if (bouncing) return; | ||
} | ||
set_slider_value = slider_value; | ||
setTrafficGraphRange(value); | ||
} | ||
|
||
void RPCConsole::setTrafficGraphRange(int mins) | ||
void RPCConsole::setTrafficGraphRange(int value) | ||
{ | ||
ui->trafficGraph->setGraphRange(std::chrono::minutes{mins}); | ||
ui->lblGraphRange->setText(GUIUtil::formatDurationStr(std::chrono::minutes{mins})); | ||
std::chrono::minutes mins = ui->trafficGraph->setGraphRange(value); | ||
if (value) | ||
set_slider_value = (value - 1) * 200; | ||
else { | ||
// When bumping, calculate the proper slider position based on the traffic graph's new value | ||
unsigned int new_graph_value = ui->trafficGraph->getCurrentRangeIndex() + 1; // +1 because the index is 0-based | ||
set_slider_value = (new_graph_value - 1) * 200; | ||
ui->sldGraphRange->blockSignals(true); | ||
ui->sldGraphRange->setValue(set_slider_value); | ||
ui->sldGraphRange->blockSignals(false); | ||
} | ||
ui->lblGraphRange->setText(GUIUtil::formatDurationStr(mins)); | ||
} | ||
|
||
void RPCConsole::on_sldGraphRange_sliderReleased() | ||
{ | ||
ui->sldGraphRange->setValue(set_slider_value); | ||
slider_in_use = false; | ||
} | ||
|
||
void RPCConsole::on_sldGraphRange_sliderPressed() { slider_in_use = true; } | ||
|
||
void RPCConsole::updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut) | ||
{ | ||
if (!slider_in_use && ui->trafficGraph->GraphRangeBump()) | ||
setTrafficGraphRange(0); // bump it up | ||
ui->lblBytesIn->setText(GUIUtil::formatBytes(totalBytesIn)); | ||
ui->lblBytesOut->setText(GUIUtil::formatBytes(totalBytesOut)); | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're deleting this, maybe there should be a way for the user to insert a reference line?
For now, I'd move removal of anything to a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The user can effectively remove the data by deleting the .dat file - is there any basis for being able to do this while the client is running?