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

Fix main window geometry save/restore #107

Closed
wants to merge 1 commit into from
Closed
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
14 changes: 9 additions & 5 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
m_network_style(networkStyle)
{
QSettings settings;
if (!restoreGeometry(settings.value("MainWindowGeometry").toByteArray())) {
// Restore failed (perhaps missing setting), center the window
move(QGuiApplication::primaryScreen()->availableGeometry().center() - frameGeometry().center());
}
settings.beginGroup("MainWindow");
resize(settings.value("size", QSize(800, 540)).toSize());
Copy link
Member

Choose a reason for hiding this comment

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

Not sure hard-coding a size in pixels is a good idea. It should auto-size based on what Qt determines is needed when a wallet is loaded (ie, all widgets visible)

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a default size that is used only at first run or after -resetguisettings.

Copy link
Member

Choose a reason for hiding this comment

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

I'm aware. But the ideal default size isn't measured in pixels.

Copy link
Member Author

Choose a reason for hiding this comment

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

But the ideal default size isn't measured in pixels.

Correct. The ideal size is set by users and it will be saved in settings. I don't think the default size could be ideal for more than one person :)

Copy link
Member

Choose a reason for hiding this comment

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

Until we removed the default wallet, the default window size was automatically sane for any platform. We just need to go back to that.

Copy link
Member Author

Choose a reason for hiding this comment

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

@luke-jr Do you suggest to revert bitcoin/bitcoin#15454 back or to calculate the default window size as if a wallet is loaded?

Copy link
Member

Choose a reason for hiding this comment

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

The latter of course

Copy link
Member Author

Choose a reason for hiding this comment

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

Reworked in #116.

move(settings.value("pos", QGuiApplication::primaryScreen()->availableGeometry().center() - frameGeometry().center()).toPoint());
settings.endGroup();

#ifdef ENABLE_WALLET
enableWallet = WalletModel::isWalletEnabled();
Expand Down Expand Up @@ -224,7 +224,11 @@ BitcoinGUI::~BitcoinGUI()
unsubscribeFromCoreSignals();

QSettings settings;
settings.setValue("MainWindowGeometry", saveGeometry());
settings.beginGroup("MainWindow");
settings.setValue("size", size());
settings.setValue("pos", pos());
settings.endGroup();

if(trayIcon) // Hide tray icon, as deleting will let it linger until quit (on Ubuntu)
trayIcon->hide();
#ifdef Q_OS_MAC
Expand Down