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

Save/restore RPCConsole geometry only for window #194

Merged
merged 1 commit into from
May 10, 2021

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Jan 21, 2021

After using the GUI with -disablewallet the "Node window" inherits the geometry of the main window, that could be unexpected for users.

This PR provides independent geometry settings for RPCConsole in both modes:

  • window sizes and QSplitter sizes when -disablewallet=0
  • only QSplitter sizes when -disablewallet=1

@maflcko
Copy link
Contributor

maflcko commented Jan 21, 2021

qt/rpcconsole.cpp:(.text+0x77ed): undefined reference to `WalletModel::isWalletEnabled()'

@hebasto
Copy link
Member Author

hebasto commented Jan 21, 2021

Fixed.

Copy link
Member

@luke-jr luke-jr left a comment

Choose a reason for hiding this comment

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

Concept ACK, though the code seems uglier than I would like (ignore this nit if we can't think of a better way)

Perhaps add a version number or comment to the splitter settings while you're at it, since adding/changing columns likely shouldn't use old sizes... Or at least a comment reminding us to do so later when/if we change the columns again.

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 b5523f1.

I think this #ifdef madness could go away by moving WalletModel::isWalletEnabled() to another place where it always compiled in.

@luke-jr
Copy link
Member

luke-jr commented Jan 27, 2021

I think this #ifdef madness could go away by moving WalletModel::isWalletEnabled() to another place where it always compiled in.

But then the code here will always be compiled in... the whole point of not building wallet support is to omit the code for it :p

@promag
Copy link
Contributor

promag commented Jan 27, 2021

@luke-jr I understand that but my proposal doesn't mean wallet support is compiled in, only downside is a runtime check:

bool IsWalletEnabled()
{
#ifdef ENABLE_WALLET
    return !gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET);
#else
    return false;
#endif
}

@luke-jr
Copy link
Member

luke-jr commented Jan 27, 2021

But with this, everything conditional on IsWalletEnabled() (in this case, the settings code) is being compiled in to a non-wallet build.

(Unless perhaps IsWalletEnabled is carefully made always-inlined so the compiler knows to remove the branch?)

@hebasto
Copy link
Member Author

hebasto commented Jan 27, 2021

Rebased b5523f1 -> 01d9586 (pr194.02 -> pr194.03) due to the conflict with #180.

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.

Can you show a screenshot of the behavior this PR is supposed to exhibit and what it is supposed to fix? Comparing with master, I don't see what this is supposed to do.

Testing on macOS 11.1 with Qt 5.15.2

Master

Wallet Enabled
Run bitcoin-qt with wallet enabled. The main window is resized to be wider.

Main Window Node Window
Screen Shot 2021-02-19 at 3 51 23 PM Screen Shot 2021-02-19 at 3 51 52 PM

Wallet Disabled
run bitcoin-qt with disablewallet=1. The Node Window has inherited the geometry of the Main Window when bitcoin-qt was run with wallet enabled.

Node Window
Screen Shot 2021-02-19 at 3 52 20 PM

Now, I'll resize the Node Window to be smaller.

Node Window
Screen Shot 2021-02-19 at 3 53 22 PM

Restart With Wallet Re-Enabled
The Main Window inherits the geometry of the Node Window when I resized the Node Window while bitcoin-qt was run with the -disablewallet=1.

Main Window
Screen Shot 2021-02-19 at 3 54 26 PM

PR

Wallet Enabled
Run bitcoin-qt with wallet enabled. The main window is resized to be wider.

Main Window Node Window
Screen Shot 2021-02-19 at 4 01 08 PM Screen Shot 2021-02-19 at 4 01 22 PM

Wallet Disabled
run bitcoin-qt with disablewallet=1. The Node Window has inherited the geometry of the Main Window when bitcoin-qt was run with wallet enabled. This is the same behavior as master.

Node Window
Screen Shot 2021-02-19 at 4 02 04 PM

Now, I'll resize the Node Window to be smaller.

Node Window
Screen Shot 2021-02-19 at 4 02 18 PM

Restart With Wallet Re-Enabled
The Main Window inherits the geometry of the Node Window when I resized the Node Window while bitcoin-qt was run with the -disablewallet=1. This is the same behavior as master.

Main Window
Screen Shot 2021-02-19 at 4 02 39 PM

@hebasto
Copy link
Member Author

hebasto commented Feb 21, 2021

@jarolrod

Comparing with master, I don't see what this is supposed to do.

Initially, I tested this pr in the Cinnamon DE only.
Here are the steps to reproduce the issue on macOS BigSur 11.2.1 (20D74) on the master branch:

  1. run bitcoin-qt -disablewallet=0, go to the menu -> Window -> Information, note the size/location of the "Node window", quit
  2. run bitcoin-qt -disablewallet=1, resize/move the window and note its size/location, quit
  3. run bitcoin-qt -disablewallet=0, go to the menu -> Window -> Information, note the size/location of the "Node window" is inherited from the the step 2

@Talkless
Copy link

Talkless commented Mar 7, 2021

I think this #ifdef madness could go away by moving WalletModel::isWalletEnabled() to another place where it always compiled in.

isWalletEnabled could be constexpr function (that implies inline) that returns false if ENABLE_WALLET=0, and out-of-line function checking program arguments at runtime otherwise.

Copy link

@Talkless Talkless left a comment

Choose a reason for hiding this comment

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

tACK 01d9586, tested on Debian Sid with Qt 5.15.2. I've managed to reproduce issue using #194 (comment) instructions, and I see that this PR does detach main window and information window sizes. Built with --enable-wallet and --disable-wallet.

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.

ACK 01d9586, tested on macOS 11.2 Qt 5.15.2

Reproduced the steps thanks to @hebasto's instructions. Confirming the behavior described on master and this PR fixes that

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 01d9586.

This is a straightforward solution to handle both cases (with and without wallet support).

A different path would be to move load/save window state out of RPCConsole and also use QSettings::beginGroup to distinguish each case.

@hebasto
Copy link
Member Author

hebasto commented May 10, 2021

@promag

Thank you for your review!

A different path would be to move load/save window state out of RPCConsole and also use QSettings::beginGroup to distinguish each case.

While working on this PR I did consider both variants you mentioned. The current implementation was chosen due to a smaller diff.

@hebasto hebasto merged commit a2bdbdb into bitcoin-core:master May 10, 2021
@hebasto hebasto deleted the 210121-window branch May 10, 2021 20:57
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request May 11, 2021
… window

01d9586 qt: Save/restore RPCConsole geometry only for window (Hennadii Stepanov)

Pull request description:

  After using the GUI with `-disablewallet` the "Node window" inherits the geometry of the main window, that could be unexpected for users.

  This PR provides independent geometry settings for `RPCConsole` in both modes:
  - window sizes and `QSplitter` sizes when `-disablewallet=0`
  - only `QSplitter` sizes when `-disablewallet=1`

ACKs for top commit:
  Talkless:
    tACK 01d9586, tested on Debian Sid with Qt 5.15.2. I've managed to reproduce issue using bitcoin-core/gui#194 (comment) instructions, and I see that this PR does detach main window and information window sizes. Built with `--enable-wallet` and `--disable-wallet`.
  jarolrod:
    ACK 01d9586, tested on macOS 11.2 Qt 5.15.2
  promag:
    Code review ACK 01d9586.

Tree-SHA512: 9934cf04d4d5070dfc4671ea950e225cda9988858227e5481dad1baafa14af477bdbf4f91307ca687fde0cad6e4e605a3a99377e70d67eb115a19955ce2516f5
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants