mirror of
https://github.com/LMMS/lmms.git
synced 2026-03-31 20:34:25 -04:00
SubWindow: Increase to respect child's sizeHint (#6956)
Before this commit, on creation, `SubWindow` gets resized to exactly the children's `sizeHint`. This makes the child too small, since the `SubWindow` already contains a title bar and borders. With this commit, the `SubWindow` is calculated such that after rendering, the child window gets exactly the `size` that its `sizeHint` has previously suggested. Most of LMMS widgets are not resizable, but the Lv2 help window is a good example to test this out. The help windows now in most cases contain enough space to fit the help text. In some cases, it still does not fit, though debug prints show that the `size` matches the `sizeHint`.
This commit is contained in:
@@ -562,13 +562,21 @@ void MainWindow::addSpacingToToolBar( int _size )
|
||||
7, _size );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
SubWindow* MainWindow::addWindowedWidget(QWidget *w, Qt::WindowFlags windowFlags)
|
||||
{
|
||||
// wrap the widget in our own *custom* window that patches some errors in QMdiSubWindow
|
||||
auto win = new SubWindow(m_workspace->viewport(), windowFlags);
|
||||
win->setAttribute(Qt::WA_DeleteOnClose);
|
||||
win->setWidget(w);
|
||||
if (w && w->sizeHint().isValid()) {win->resize(w->sizeHint());}
|
||||
if (w && w->sizeHint().isValid()) {
|
||||
auto titleBarHeight = win->titleBarHeight();
|
||||
auto frameWidth = win->frameWidth();
|
||||
QSize delta(2* frameWidth, titleBarHeight + frameWidth);
|
||||
win->resize(delta + w->sizeHint());
|
||||
}
|
||||
m_workspace->addSubWindow(win);
|
||||
return win;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user