Fix subwindow size limits (MainWindow::restoreWidgetState)#8204
Fix subwindow size limits (MainWindow::restoreWidgetState)#8204yohannd1 wants to merge 8 commits intoLMMS:masterfrom
Conversation
|
This was previously simply a fix for negative positions, but I've recently realized the minimum size hint code was also wrong. For example, upon loading the project the "Project Notes" window would have its width set to 800 if it was saved as less, even though its actual minimal amount when resizing is around 200 or 300. Today I pushed a commit that updates the code style and uses One potential concern was re-introducing a bug (discussed in comments on the function in question) where in corrupt project files the size would be null, and I manually tried editing a |
It seems that was because I was using the content widget for size hint, not the subwindow itself - I believe I've fixed it now. |
messmerd
left a comment
There was a problem hiding this comment.
Haven't tested it, but the changes are pretty simple and straightforward
Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
|
any particular reason to use |
|
On further looking, the max as a whole at least in current state seems redundant, If others think that it's better to leave this to be explicit, the |
The general rule of thumb is to prefer the STL when possible. It also helps in our effort to move away from Qt (more importantly in the core, i.e., the |
|
I believe And, as for the explicit check, in previous tests I had the minimum size being loaded incorrectly, but Nonetheless, the current |
Then wouldn't it be better to just remove the check? i.e. long pile of useless difftldr: remove if and deindent block lol - if (normalGeometry.isValid())
- {
- // first restore the window, as attempting to resize a maximized window causes graphics glitching
- win->setWindowState(win->windowState() & ~(Qt::WindowMaximized | Qt::WindowMinimized));
-
- win->setGeometry(normalGeometry);
-
- // set the window to its correct minimized/maximized/restored state
- Qt::WindowStates winState = win->windowState();
- auto winState = win->windowState();
- winState = de.attribute("maximized").toInt()
- ? (winState | Qt::WindowMaximized)
- : (winState & ~Qt::WindowMaximized);
- }
+ // first restore the window, as attempting to resize a maximized window causes graphics glitching
+ win->setWindowState(win->windowState() & ~(Qt::WindowMaximized | Qt::WindowMinimized));
+
+ win->setGeometry(normalGeometry);
+
+ // set the window to its correct minimized/maximized/restored state
+ Qt::WindowStates winState = win->windowState();
+ auto winState = win->windowState();
+ winState = de.attribute("maximized").toInt()
+ ? (winState | Qt::WindowMaximized)
+ : (winState & ~Qt::WindowMaximized);And then again, without the check there's currently nothing that would behave differently compared to the version without explicit minimum heights, so unless you want to keep them for clarity they can be removed as well. sorry if i'm repeating myself, i just want to be sure that i'm clear |
|
That does make sense! I've now removed it. Just in case, I've added a comment (not sure if it is of much help either way...):
Also, since // Set the window to its correct "maximized?" state.
auto winState = win->windowState();
winState.setFlag(Qt::WindowMaximized, de.attribute("maximized").toInt());
win->setWindowState(winState); |
Previously fixed #8202, but that one got fixed first by #3532.
This PR now just corrects the subwindow size on load.