diff --git a/include/DetachableWidget.h b/include/DetachableWidget.h index 12228e49728..532dec3303f 100644 --- a/include/DetachableWidget.h +++ b/include/DetachableWidget.h @@ -36,7 +36,7 @@ class LMMS_EXPORT DetachableWidget : public QWidget { Q_OBJECT public: - explicit DetachableWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags{}); + using QWidget::QWidget; void closeEvent(QCloseEvent* ce) override; diff --git a/include/DetachableWindow.h b/include/DetachableWindow.h index bf3aa7b1aca..1636b4fad25 100644 --- a/include/DetachableWindow.h +++ b/include/DetachableWindow.h @@ -36,7 +36,7 @@ class LMMS_EXPORT DetachableWindow : public QMainWindow { Q_OBJECT public: - explicit DetachableWindow(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags{}); + using QMainWindow::QMainWindow; void closeEvent(QCloseEvent* ce) override; diff --git a/src/gui/DetachableWidget.cpp b/src/gui/DetachableWidget.cpp index 85f9c5b2359..be952e33e95 100644 --- a/src/gui/DetachableWidget.cpp +++ b/src/gui/DetachableWidget.cpp @@ -25,7 +25,6 @@ #include "DetachableWidget.h" -#include #include #include "GuiApplication.h" @@ -33,11 +32,6 @@ namespace lmms::gui { -DetachableWidget::DetachableWidget(QWidget* parent, Qt::WindowFlags f) - : QWidget{parent, f} -{ -} - void DetachableWidget::closeEvent(QCloseEvent* ce) { if (windowFlags().testFlag(Qt::Window)) diff --git a/src/gui/DetachableWindow.cpp b/src/gui/DetachableWindow.cpp index 33e0970c520..d86ac9447dd 100644 --- a/src/gui/DetachableWindow.cpp +++ b/src/gui/DetachableWindow.cpp @@ -25,7 +25,6 @@ #include "DetachableWindow.h" -#include #include #include "GuiApplication.h" @@ -33,11 +32,6 @@ namespace lmms::gui { -DetachableWindow::DetachableWindow(QWidget* parent, Qt::WindowFlags f) - : QMainWindow{parent, f} -{ -} - void DetachableWindow::closeEvent(QCloseEvent* ce) { if (windowFlags().testFlag(Qt::Window)) diff --git a/src/gui/MixerView.cpp b/src/gui/MixerView.cpp index 5e0e82d1e8f..9cf9fa53fdf 100644 --- a/src/gui/MixerView.cpp +++ b/src/gui/MixerView.cpp @@ -163,6 +163,15 @@ MixerView::MixerView() this, SLOT(updateFaders())); + // adjust window size + layout()->invalidate(); + resize(sizeHint()); + if (parentWidget()) + { + parentWidget()->resize(parentWidget()->sizeHint()); + } + setFixedHeight(height()); + // add ourself to workspace QMdiSubWindow * subWin = getGUI()->mainWindow()->addWindowedWidget( this ); Qt::WindowFlags flags = subWin->windowFlags(); @@ -170,6 +179,7 @@ MixerView::MixerView() subWin->setWindowFlags( flags ); layout()->setSizeConstraint( QLayout::SetMinimumSize ); subWin->layout()->setSizeConstraint( QLayout::SetMinAndMaxSize ); + subWin->setFixedHeight(subWin->height()); parentWidget()->setAttribute( Qt::WA_DeleteOnClose, false ); parentWidget()->move( 5, 310 ); diff --git a/src/gui/SampleTrackWindow.cpp b/src/gui/SampleTrackWindow.cpp index e2beda7e21f..f76cb8a211d 100644 --- a/src/gui/SampleTrackWindow.cpp +++ b/src/gui/SampleTrackWindow.cpp @@ -160,6 +160,15 @@ SampleTrackWindow::SampleTrackWindow(SampleTrackView* stv) flags &= ~Qt::WindowMaximizeButtonHint; subWin->setWindowFlags(flags); + // adjust window size + layout()->invalidate(); + resize(sizeHint()); + if (parentWidget()) + { + parentWidget()->resize(parentWidget()->sizeHint()); + } + setFixedSize(size()); + // Hide the Size and Maximize options from the system menu // since the dialog size is fixed. QMenu * systemMenu = subWin->systemMenu(); diff --git a/src/gui/SubWindow.cpp b/src/gui/SubWindow.cpp index bcd7fe59cfd..d22a337bf7b 100644 --- a/src/gui/SubWindow.cpp +++ b/src/gui/SubWindow.cpp @@ -252,10 +252,24 @@ void SubWindow::setBorderColor( const QColor &c ) void SubWindow::detach() { +#if QT_VERSION < 0x50C00 + // Workaround for a bug in Qt versions below 5.12, + // where argument-dependent-lookup fails for QFlags operators + // declared inside a namepsace. + // This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h + // See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348 + + using ::operator|; +#endif + if (isDetached()) { return; } - auto pos = mapToGlobal(widget()->pos()); - widget()->setWindowFlags(Qt::Window); + const auto pos = mapToGlobal(widget()->pos()); + + auto flags = windowFlags(); + flags |= Qt::Window; + flags &= ~Qt::Widget; + widget()->setWindowFlags(flags); widget()->show(); hide(); @@ -264,10 +278,24 @@ void SubWindow::detach() void SubWindow::attach() { +#if QT_VERSION < 0x50C00 + // Workaround for a bug in Qt versions below 5.12, + // where argument-dependent-lookup fails for QFlags operators + // declared inside a namepsace. + // This affects the Q_DECLARE_OPERATORS_FOR_FLAGS macro in Instrument.h + // See also: https://codereview.qt-project.org/c/qt/qtbase/+/225348 + + using ::operator|; +#endif + if (!isDetached()) { return; } auto frame = widget()->windowHandle()->frameGeometry(); - widget()->setWindowFlags(Qt::Widget); + + auto flags = windowFlags(); + flags &= ~Qt::Window; + flags |= Qt::Widget; + widget()->setWindowFlags(flags); widget()->show(); show();