Skip to content
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

Add access to the Peers tab from the network icon #309

Merged
merged 1 commit into from
May 31, 2021

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented May 1, 2021

This PR add a small context menu to the network activity icon that provides an access to the Peers tab:

gui-network-icon

Closes #93.

@hebasto hebasto added UX All about "how to get things done" Feature labels May 1, 2021
@hebasto hebasto force-pushed the 210501-network branch 2 times, most recently from 418dd58 to 1f208f4 Compare May 1, 2021 21:09
src/qt/bitcoingui.cpp Outdated Show resolved Hide resolved
@hebasto
Copy link
Member Author

hebasto commented May 2, 2021

Updated 1f208f4 -> a7f5ea5 (pr309.02 -> pr309.03, diff):

Copy link
Contributor

@kristapsk kristapsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK a7f5ea5

Copy link
Member

@jarolrod jarolrod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK a7f5ea5

Tested on macOS 11.3 Qt 5.15.2, Also tested with -disablewallet=1.

This is ok to merge as-is. But, wanted to document how I think this should be changed around as part of a follow-up.

The 'Peers Tab' is for seeing your connected Peers and interacting with them, such as banning or disconnecting a peer.

The idea of "Disabling Network Activity" should be tied to the 'Network Traffic Tab' not the 'Peers Tab'. This means we could add a "Disable Network Activity" button to the Network Traffic tab and a 'Network Traffic' widget next to the 'Connection Count' widget. Pressing this 'Network Traffic' widget would open the 'Network Traffic' tab where the user has the option of disabling network activity.

@hebasto
Copy link
Member Author

hebasto commented May 4, 2021

@Sjors Do you mind looking into this PR?

@hebasto hebasto requested a review from Sjors May 4, 2021 17:50
Copy link
Member

@Sjors Sjors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK a7f5ea5

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ACK a7f5ea5.

updateNetworkState();
setNetworkActive(m_node.getNetworkActive());
connect(connectionsControl, &GUIUtil::ClickableLabel::clicked, [this] {
m_network_context_menu->exec(QCursor::pos());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QMenu::exec is blocking. If you want to keep this approach then you could declare a local QMenu instance instead - this way you can ditch the class member and the call to .clear().

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@promag

Thanks!

QMenu::exec is blocking.

My bad! Fixed.

If you want to keep this approach then you could declare a local QMenu instance instead - this way you can ditch the class member and the call to .clear().

How the lifetime of local QMenu instances could be managed in a proper way?

@hebasto
Copy link
Member Author

hebasto commented May 8, 2021

Updated a7f5ea5 -> d29ea72 (pr309.03 -> pr309.04, diff):

QMenu::exec is blocking.

@RandyMcMillan
Copy link
Contributor

RandyMcMillan commented May 8, 2021

It would be great if a key combo was added to this functionality...
Maybe:

COMMAND + OPTION <W> or <N> would work.

@hebasto
Copy link
Member Author

hebasto commented May 8, 2021

It would be great if a key combo was added to this functionality...
Maybe:

COMMAND + OPTION <W> or <N> would work.

For switching to the Peers tab we already have the Ctrl+P shortcut.
Adding a shortcut for enabling/disabling the network activity is out of this PR scope.

@kristapsk
Copy link
Contributor

Adding a shortcut for enabling/disabling the network activity

I'm not even sure such shortcut is a good idea at all. Could accidentally hit that, the same that has happened to more with that icon without this PR.

Copy link
Contributor

@kristapsk kristapsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK d29ea72

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK d29ea72.

Not fond of the approach though. It seems it would be enough to update the menu item text on BitcoinGUI::updateNetworkState() instead of QMenu::clear() + QMenu::addAction() and the slot would just query the current network state.

It also seems more elegant to just call BitcoinGUI::updateNetworkState() in BitcoinGUI::setClientModel which already calls m_node.getNetworkActive().

Worth noting that when the toggle action is triggered it calls m_node.setNetworkActive() which results in destroying that same action due to QMenu::clear().

Don't mind my feedback, it's just another way of implementing the feature, thanks for adding the feature and addressing my previous comment.

@hebasto hebasto changed the title gui: Add access to the Peers tab from the network icon Add access to the Peers tab from the network icon May 10, 2021
@Sjors
Copy link
Member

Sjors commented May 10, 2021

re-ACK d29ea72

@hebasto
Copy link
Member Author

hebasto commented May 11, 2021

@promag

Many thanks for your valuable review and feedback!

Not fond of the approach though. It seems it would be enough to update the menu item text on BitcoinGUI::updateNetworkState() instead of QMenu::clear() + QMenu::addAction() and the slot would just query the current network state.

It also seems more elegant to just call BitcoinGUI::updateNetworkState() in BitcoinGUI::setClientModel which already calls m_node.getNetworkActive().

Worth noting that when the toggle action is triggered it calls m_node.setNetworkActive() which results in destroying that same action due to QMenu::clear().

Do you mind having a look at https://github.com/hebasto/gui/commits/210511-pr309-alt?

@hebasto hebasto merged commit 1122590 into bitcoin-core:master May 31, 2021
@hebasto hebasto deleted the 210501-network branch May 31, 2021 16:40
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Jun 1, 2021
gwillen pushed a commit to ElementsProject/elements that referenced this pull request Jun 1, 2022
@bitcoin-core bitcoin-core locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Feature UX All about "how to get things done"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Network tray icon should open peers window, add button to disable network there
6 participants