-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Replace save|restoreWindowGeometry with Qt functions #11335
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
Conversation
|
Nice find! So we've spend versions after version trying to iterate and get something working that was already in Qt. It isn't even remotely new either:
Concept ACK. As there might be OS-specific magic involved, delegating this to Qt is the right thing to do. And from here on we can just blame upstream if it bugs out again... |
|
utACK e70a784. Indeed Qt does more: http://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/kernel/qwidget.cpp#n7423. |
|
re-utACK after squash. |
|
Squashed |
|
utACK 011e31b. |
|
Nevermind that. That was an unclean working directory during my testing. The window will open in the bottom righthand corner of the screen if those setting values do not exist. I don't really think that is what we want, we want it to be centered if there is no position saved from previous runs. |
promag
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@achow101 is right, maybe we should keep GUIUtil::restoreWindowGeometry to center the window when necessary.
src/qt/rpcconsole.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this->.
src/qt/rpcconsole.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to this->.
src/qt/bitcoingui.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, and the one on line 266 as well which you missed ;)
|
ah cool, that bug is really annoying! Cool it gets fixe! |
|
@meshcollider I'm using Ubuntu 17.04 it just opens the window in some random corner (it's apparently inconsistent) if the geometry settings don't exist. |
|
@meshcollider e1166d5dad2a146cea57d0f74a886178fe33f7dd centers it for me. |
|
utACK after squash |
|
utACK d6e8c6687227f96f846210a3c0a8dc6118141528 after squash |
|
Squashed |
|
I'll review in a hour or so. |
src/qt/bitcoingui.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly I think it's better to keep restoreWindowGeometry and move this there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as below, I think its a lot cleaner inline, will change if others agree though 👍
src/qt/bitcoingui.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is wrong (don't have 2nd screen to test) since rect() is relative to widget as in QRect(0, 0, width(), height()).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be something like?
move(QApplication::desktop()->availableGeometry().center() - geometry().center());There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks :-)
src/qt/rpcconsole.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Funny fact, in Qt documentation this is done by overriding QWidget::closeEvent. Is the geometry available in the destructor in all platforms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same as above, I would keep GUIUtil::saveWindowGeometry, maybe add some logging there too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree, it's pretty excessive to leave one line of code in its own function, and this is pretty inconsequential behavior so I don't think its worth logging, unless others think it is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, IMO, no need to have utility functions for something that is a one-liner. That just makes code harder to follow.
|
utACK 13baf72 |
|
Tested ACK 13baf72 (macOS / Window 8.1).
|
|
Centering the window by default seems like a bad idea, but maybe that discussion belongs elsewhere. (If there's no saved position, the window manager should position it.) |
|
@luke-jr it seems most WMs center by default (tested on windows and Mac) but achow101 said his Ubuntu system was randomly placing it on screen, hence forced centering (which is the current behaviour) makes sense imo. And I think losing saved position is a non-issue when upgrading to a new version of the software, it would be an unnecessary mess in the code to check for legacy position/size values, migrate and then remove them. |
|
@meshcollider If the OS/WM decides to place randomly, that's what it should be... |
|
@luke-jr I mentioned that above (#11335 (comment) and #11335 (comment)), but it seemed the consensus to center it |
13baf72 Replace save|restoreWindowGeometry with Qt functions (MeshCollider) Pull request description: Alternative to #11208, closes #11207 According to the [Qt documentation](https://doc.qt.io/qt-4.8/qwidget.html#restoreGeometry), restoreGeometry does all the checks we need, so it would be better to rely on them instead of doing it ourselves. ~Haven't tested this properly yet, hence the WIP.~ Gives expected behavior exactly as the other system apps do based on my tests. Only potential issue is the case when the GUI is almost entirely offscreen with only a single strip of pixels, its not really possible to see the GUI, but if you know it's there you can bring it back onscreen with just the mouse. And that's exactly how notepad behaves on Windows so I don't think its a real issue. This also gives much better behavior when closing a maximized window, currently (0.15.0 release) a maximized window will save the window size on close, and then reopen as a not-maximized but still that size, which is really annoying. This reopens as maximized. Gitian build here: https://bitcoin.jonasschnelli.ch/build/305 Tree-SHA512: a8bde14793b4316192df1fa2eaaeb32b44d5ebc5219c35252379840056cd737a9fd162625fd715987f275fec8375334ec1ec328dbc671563f084c611a938985c
Github-Pull: bitcoin#11335 Rebased-From: 13baf72
…ions 13baf72 Replace save|restoreWindowGeometry with Qt functions (MeshCollider) Pull request description: Alternative to bitcoin#11208, closes bitcoin#11207 According to the [Qt documentation](https://doc.qt.io/qt-4.8/qwidget.html#restoreGeometry), restoreGeometry does all the checks we need, so it would be better to rely on them instead of doing it ourselves. ~Haven't tested this properly yet, hence the WIP.~ Gives expected behavior exactly as the other system apps do based on my tests. Only potential issue is the case when the GUI is almost entirely offscreen with only a single strip of pixels, its not really possible to see the GUI, but if you know it's there you can bring it back onscreen with just the mouse. And that's exactly how notepad behaves on Windows so I don't think its a real issue. This also gives much better behavior when closing a maximized window, currently (0.15.0 release) a maximized window will save the window size on close, and then reopen as a not-maximized but still that size, which is really annoying. This reopens as maximized. Gitian build here: https://bitcoin.jonasschnelli.ch/build/305 Tree-SHA512: a8bde14793b4316192df1fa2eaaeb32b44d5ebc5219c35252379840056cd737a9fd162625fd715987f275fec8375334ec1ec328dbc671563f084c611a938985c
…ions 13baf72 Replace save|restoreWindowGeometry with Qt functions (MeshCollider) Pull request description: Alternative to bitcoin#11208, closes bitcoin#11207 According to the [Qt documentation](https://doc.qt.io/qt-4.8/qwidget.html#restoreGeometry), restoreGeometry does all the checks we need, so it would be better to rely on them instead of doing it ourselves. ~Haven't tested this properly yet, hence the WIP.~ Gives expected behavior exactly as the other system apps do based on my tests. Only potential issue is the case when the GUI is almost entirely offscreen with only a single strip of pixels, its not really possible to see the GUI, but if you know it's there you can bring it back onscreen with just the mouse. And that's exactly how notepad behaves on Windows so I don't think its a real issue. This also gives much better behavior when closing a maximized window, currently (0.15.0 release) a maximized window will save the window size on close, and then reopen as a not-maximized but still that size, which is really annoying. This reopens as maximized. Gitian build here: https://bitcoin.jonasschnelli.ch/build/305 Tree-SHA512: a8bde14793b4316192df1fa2eaaeb32b44d5ebc5219c35252379840056cd737a9fd162625fd715987f275fec8375334ec1ec328dbc671563f084c611a938985c
Alternative to #11208, closes #11207
According to the Qt documentation, restoreGeometry does all the checks we need, so it would be better to rely on them instead of doing it ourselves.
Haven't tested this properly yet, hence the WIP.Gives expected behavior exactly as the other system apps do based on my tests. Only potential issue is the case when the GUI is almost entirely offscreen with only a single strip of pixels, its not really possible to see the GUI, but if you know it's there you can bring it back onscreen with just the mouse. And that's exactly how notepad behaves on Windows so I don't think its a real issue.
This also gives much better behavior when closing a maximized window, currently (0.15.0 release) a maximized window will save the window size on close, and then reopen as a not-maximized but still that size, which is really annoying. This reopens as maximized.
Gitian build here: https://bitcoin.jonasschnelli.ch/build/305