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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,13 +453,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 Full/Block Relay: initiated by peer"),
Expand Down Expand Up @@ -516,8 +524,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;
Expand Down