0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-03 09:56:38 -05:00

Merge bitcoin-core/gui#194: Save/restore RPCConsole geometry only for window

01d9586ae8 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 01d9586ae8, tested on Debian Sid with Qt 5.15.2. I've managed to reproduce issue using https://github.com/bitcoin-core/gui/pull/194#issuecomment-782822663 instructions, and I see that this PR does detach main window and information window sizes. Built with `--enable-wallet` and `--disable-wallet`.
  jarolrod:
    ACK 01d9586ae8, tested on macOS 11.2 Qt 5.15.2
  promag:
    Code review ACK 01d9586ae8.

Tree-SHA512: 9934cf04d4d5070dfc4671ea950e225cda9988858227e5481dad1baafa14af477bdbf4f91307ca687fde0cad6e4e605a3a99377e70d67eb115a19955ce2516f5
This commit is contained in:
Hennadii Stepanov 2021-05-10 23:53:12 +03:00
commit a2bdbdb358
No known key found for this signature in database
GPG key ID: 410108112E7EA81F

View file

@ -454,13 +454,21 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty
{
ui->setupUi(this);
QSettings settings;
if (!restoreGeometry(settings.value("RPCConsoleWindowGeometry").toByteArray())) {
// Restore failed (perhaps missing setting), center the window
move(QGuiApplication::primaryScreen()->availableGeometry().center() - frameGeometry().center());
#ifdef ENABLE_WALLET
if (WalletModel::isWalletEnabled()) {
// RPCConsole widget is a window.
if (!restoreGeometry(settings.value("RPCConsoleWindowGeometry").toByteArray())) {
// Restore failed (perhaps missing setting), center the window
move(QGuiApplication::primaryScreen()->availableGeometry().center() - frameGeometry().center());
}
ui->splitter->restoreState(settings.value("RPCConsoleWindowPeersTabSplitterSizes").toByteArray());
} else
#endif // ENABLE_WALLET
{
// RPCConsole is a child widget.
ui->splitter->restoreState(settings.value("RPCConsoleWidgetPeersTabSplitterSizes").toByteArray());
}
ui->splitter->restoreState(settings.value("PeersTabSplitterSizes").toByteArray());
constexpr QChar nonbreaking_hyphen(8209);
const std::vector<QString> CONNECTION_TYPE_DOC{
tr("Inbound: initiated by peer"),
@ -522,8 +530,18 @@ RPCConsole::RPCConsole(interfaces::Node& node, const PlatformStyle *_platformSty
RPCConsole::~RPCConsole()
{
QSettings settings;
settings.setValue("RPCConsoleWindowGeometry", saveGeometry());
settings.setValue("PeersTabSplitterSizes", ui->splitter->saveState());
#ifdef ENABLE_WALLET
if (WalletModel::isWalletEnabled()) {
// RPCConsole widget is a window.
settings.setValue("RPCConsoleWindowGeometry", saveGeometry());
settings.setValue("RPCConsoleWindowPeersTabSplitterSizes", ui->splitter->saveState());
} else
#endif // ENABLE_WALLET
{
// RPCConsole is a child widget.
settings.setValue("RPCConsoleWidgetPeersTabSplitterSizes", ui->splitter->saveState());
}
m_node.rpcUnsetTimerInterface(rpcTimerInterface);
delete rpcTimerInterface;
delete ui;