From 9a1eaac8ec1c81e60f639b2d1f9f9da3708495b7 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Fri, 20 Sep 2024 22:17:40 +0200 Subject: [PATCH 01/12] Maximize button for resizable instruments Show the maximize button for resizable instruments. Most other changes have the character of refactorings and code reorganizations. Remove the negation in the if condition for resizable instruments to make the code better readable. Only manipulate the system menu if the instrument is not resizable. Add a TODO to the special code that sets a size. --- src/gui/instrument/InstrumentTrackWindow.cpp | 34 ++++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/gui/instrument/InstrumentTrackWindow.cpp b/src/gui/instrument/InstrumentTrackWindow.cpp index 1fb8596625e..60fc5937375 100644 --- a/src/gui/instrument/InstrumentTrackWindow.cpp +++ b/src/gui/instrument/InstrumentTrackWindow.cpp @@ -285,24 +285,30 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) : QMdiSubWindow* subWin = getGUI()->mainWindow()->addWindowedWidget( this ); Qt::WindowFlags flags = subWin->windowFlags(); - if (!m_instrumentView->isResizable()) { - flags |= Qt::MSWindowsFixedSizeDialogHint; - // any better way than this? - } else { - subWin->setMaximumSize(m_instrumentView->maximumHeight() + 12, m_instrumentView->maximumWidth() + 208); - subWin->setMinimumSize( m_instrumentView->minimumWidth() + 12, m_instrumentView->minimumHeight() + 208); + + if (m_instrumentView->isResizable()) + { + // TODO As of writing SlicerT is the only resizable instrument. Is this code specific to SlicerT? + const auto extraSpace = QSize(12, 208); + subWin->setMaximumSize(m_instrumentView->maximumSize() + extraSpace); + subWin->setMinimumSize(m_instrumentView->minimumSize() + extraSpace); + + flags |= Qt::WindowMaximizeButtonHint; } - flags &= ~Qt::WindowMaximizeButtonHint; - subWin->setWindowFlags( flags ); + else + { + flags |= Qt::MSWindowsFixedSizeDialogHint; + flags &= ~Qt::WindowMaximizeButtonHint; + // Hide the Size and Maximize options from the system menu since the dialog size is fixed. + QMenu * systemMenu = subWin->systemMenu(); + systemMenu->actions().at(2)->setVisible(false); // Size + systemMenu->actions().at(4)->setVisible(false); // Maximize + } - // Hide the Size and Maximize options from the system menu - // since the dialog size is fixed. - QMenu * systemMenu = subWin->systemMenu(); - systemMenu->actions().at( 2 )->setVisible( false ); // Size - systemMenu->actions().at( 4 )->setVisible( false ); // Maximize + subWin->setWindowFlags(flags); - subWin->setWindowIcon( embed::getIconPixmap( "instrument_track" ) ); + subWin->setWindowIcon(embed::getIconPixmap("instrument_track")); subWin->hide(); } From eec9df18732fafe3a3341d3396b4ac7baf17791b Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Sun, 22 Sep 2024 13:26:36 +0200 Subject: [PATCH 02/12] Fix rendering of maximized sub windows In `SubWindow::paintEvent` don't paint anything if the sub window is maximized . Otherwise some gradients are visible behind the maximized child content. In `SubWindow::adjustTitleBar` hide the title label and the buttons if the sub window is maximized. Always show the title and close button if not maximized. This is needed to reset the state correctly after maximization. --- src/gui/SubWindow.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/gui/SubWindow.cpp b/src/gui/SubWindow.cpp index dc6e49297d1..ba9a9fe6413 100644 --- a/src/gui/SubWindow.cpp +++ b/src/gui/SubWindow.cpp @@ -111,6 +111,13 @@ SubWindow::SubWindow(QWidget *parent, Qt::WindowFlags windowFlags) : */ void SubWindow::paintEvent( QPaintEvent * ) { + // Don't paint any of the other stuff if the sub window is maximized + // so that only it child content is painted. + if (isMaximized()) + { + return; + } + QPainter p( this ); QRect rect( 0, 0, width(), m_titleBarHeight ); @@ -295,9 +302,25 @@ void SubWindow::moveEvent( QMoveEvent * event ) */ void SubWindow::adjustTitleBar() { + // Don't show the title or any button if the sub window is maximized. Otherwise they + // might show up behind the actual maximized content of the child widget. + if (isMaximized()) + { + m_closeBtn->hide(); + m_maximizeBtn->hide(); + m_restoreBtn->hide(); + m_windowTitle->hide(); + + return; + } + + // Title adjustments + m_windowTitle->show(); + // button adjustments m_maximizeBtn->hide(); m_restoreBtn->hide(); + m_closeBtn->show(); const int rightSpace = 3; const int buttonGap = 1; From f5d25447cc01b5d453e0716e21ab7b072f99ada0 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Sun, 22 Sep 2024 13:29:54 +0200 Subject: [PATCH 03/12] Add SubWindow::addTitleButton Add the helper method `SubWindow::addTitleButton` to reduce code repetition in the constructor. --- include/SubWindow.h | 2 ++ src/gui/SubWindow.cpp | 33 +++++++++++++++------------------ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/include/SubWindow.h b/include/SubWindow.h index d1cc6a7af08..864b17b508f 100644 --- a/include/SubWindow.h +++ b/include/SubWindow.h @@ -78,6 +78,8 @@ class LMMS_EXPORT SubWindow : public QMdiSubWindow void paintEvent( QPaintEvent * pe ) override; void changeEvent( QEvent * event ) override; + QPushButton* addTitleButton(const std::string & iconName, const QString & toolTip); + signals: void focusLost(); diff --git a/src/gui/SubWindow.cpp b/src/gui/SubWindow.cpp index ba9a9fe6413..b8398cfcf1d 100644 --- a/src/gui/SubWindow.cpp +++ b/src/gui/SubWindow.cpp @@ -58,28 +58,13 @@ SubWindow::SubWindow(QWidget *parent, Qt::WindowFlags windowFlags) : m_borderColor = Qt::black; // close, maximize and restore (after maximizing) buttons - m_closeBtn = new QPushButton( embed::getIconPixmap( "close" ), QString(), this ); - m_closeBtn->resize( m_buttonSize ); - m_closeBtn->setFocusPolicy( Qt::NoFocus ); - m_closeBtn->setCursor( Qt::ArrowCursor ); - m_closeBtn->setAttribute( Qt::WA_NoMousePropagation ); - m_closeBtn->setToolTip( tr( "Close" ) ); + m_closeBtn = addTitleButton("close", tr("Close")); connect( m_closeBtn, SIGNAL(clicked(bool)), this, SLOT(close())); - m_maximizeBtn = new QPushButton( embed::getIconPixmap( "maximize" ), QString(), this ); - m_maximizeBtn->resize( m_buttonSize ); - m_maximizeBtn->setFocusPolicy( Qt::NoFocus ); - m_maximizeBtn->setCursor( Qt::ArrowCursor ); - m_maximizeBtn->setAttribute( Qt::WA_NoMousePropagation ); - m_maximizeBtn->setToolTip( tr( "Maximize" ) ); + m_maximizeBtn = addTitleButton("maximize", tr("Maximize")); connect( m_maximizeBtn, SIGNAL(clicked(bool)), this, SLOT(showMaximized())); - m_restoreBtn = new QPushButton( embed::getIconPixmap( "restore" ), QString(), this ); - m_restoreBtn->resize( m_buttonSize ); - m_restoreBtn->setFocusPolicy( Qt::NoFocus ); - m_restoreBtn->setCursor( Qt::ArrowCursor ); - m_restoreBtn->setAttribute( Qt::WA_NoMousePropagation ); - m_restoreBtn->setToolTip( tr( "Restore" ) ); + m_restoreBtn = addTitleButton("restore", tr("Restore")); connect( m_restoreBtn, SIGNAL(clicked(bool)), this, SLOT(showNormal())); // QLabel for the window title and the shadow effect @@ -426,5 +411,17 @@ void SubWindow::resizeEvent( QResizeEvent * event ) } } +QPushButton* SubWindow::addTitleButton(const std::string & iconName, const QString & toolTip) +{ + auto button = new QPushButton(embed::getIconPixmap(iconName), QString(), this); + button->resize(m_buttonSize); + button->setFocusPolicy(Qt::NoFocus); + button->setCursor(Qt::ArrowCursor); + button->setAttribute(Qt::WA_NoMousePropagation); + button->setToolTip(toolTip); + + return button; +} + } // namespace lmms::gui \ No newline at end of file From cdef4b5207b4c220f11fe5aa3f68b358c5f95e58 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Sun, 22 Sep 2024 13:32:04 +0200 Subject: [PATCH 04/12] Only disable the minimize button Disable the minimize button by taking the current flags and removing the minimize button hint from them instead of giving a list which might become incomplete in the future. So only do what we want to do. --- src/gui/SubWindow.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gui/SubWindow.cpp b/src/gui/SubWindow.cpp index b8398cfcf1d..c266812a5ca 100644 --- a/src/gui/SubWindow.cpp +++ b/src/gui/SubWindow.cpp @@ -79,9 +79,8 @@ SubWindow::SubWindow(QWidget *parent, Qt::WindowFlags windowFlags) : m_windowTitle->setGraphicsEffect( m_shadow ); // disable the minimize button - setWindowFlags( Qt::SubWindow | Qt::WindowMaximizeButtonHint | - Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint | - Qt::CustomizeWindowHint ); + setWindowFlags(this->windowFlags() & ~Qt::WindowMinimizeButtonHint); + connect( mdiArea(), SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(focusChanged(QMdiSubWindow*))); } From 0921c97f9876d567eb10fdacc5f680f3bd23f3e1 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Sun, 22 Sep 2024 13:33:23 +0200 Subject: [PATCH 05/12] Remove dependency on MdiArea Remove a dependency on the `MdiArea` when checking if the sub window is the active one. Query its own window state to find out if it is active. --- src/gui/SubWindow.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/gui/SubWindow.cpp b/src/gui/SubWindow.cpp index c266812a5ca..ae3497bd212 100644 --- a/src/gui/SubWindow.cpp +++ b/src/gui/SubWindow.cpp @@ -105,9 +105,7 @@ void SubWindow::paintEvent( QPaintEvent * ) QPainter p( this ); QRect rect( 0, 0, width(), m_titleBarHeight ); - bool isActive = mdiArea() - ? mdiArea()->activeSubWindow() == this - : false; + const bool isActive = windowState() & Qt::WindowActive; p.fillRect( rect, isActive ? activeColor() : p.pen().brush() ); From 4b0beb4af64695d08c5bbce8c112818c79d7c886 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Sun, 22 Sep 2024 13:40:04 +0200 Subject: [PATCH 06/12] Typo and newline at end of file Fix a typo and add a newline to the end of the file. --- src/gui/SubWindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/SubWindow.cpp b/src/gui/SubWindow.cpp index ae3497bd212..61d816e83fe 100644 --- a/src/gui/SubWindow.cpp +++ b/src/gui/SubWindow.cpp @@ -96,7 +96,7 @@ SubWindow::SubWindow(QWidget *parent, Qt::WindowFlags windowFlags) : void SubWindow::paintEvent( QPaintEvent * ) { // Don't paint any of the other stuff if the sub window is maximized - // so that only it child content is painted. + // so that only its child content is painted. if (isMaximized()) { return; @@ -421,4 +421,4 @@ QPushButton* SubWindow::addTitleButton(const std::string & iconName, const QStri } -} // namespace lmms::gui \ No newline at end of file +} // namespace lmms::gui From e85699f787278578d54ab2353f93c63ed8c37384 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Wed, 9 Oct 2024 13:57:32 +0200 Subject: [PATCH 07/12] Clear Qt::MSWindowsFixedSizeDialogHint Clear the `Qt::MSWindowsFixedSizeDialogHint` flag for resizable instruments (symmetric to the `else` case). --- src/gui/instrument/InstrumentTrackWindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/instrument/InstrumentTrackWindow.cpp b/src/gui/instrument/InstrumentTrackWindow.cpp index 60fc5937375..a9504732a09 100644 --- a/src/gui/instrument/InstrumentTrackWindow.cpp +++ b/src/gui/instrument/InstrumentTrackWindow.cpp @@ -293,6 +293,7 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) : subWin->setMaximumSize(m_instrumentView->maximumSize() + extraSpace); subWin->setMinimumSize(m_instrumentView->minimumSize() + extraSpace); + flags &= ~Qt::MSWindowsFixedSizeDialogHint; flags |= Qt::WindowMaximizeButtonHint; } else From e3560df90b78e33cae9a8c3f0b8daf1fbed44784 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Wed, 9 Oct 2024 18:26:17 +0200 Subject: [PATCH 08/12] Update the sub window title bar of exchanged instruments Update the title bar of an instrument's sub window if the model changes, e.g. if an instrument is exchanged via drag & drop. The main fix is to call the new method `updateSubWindowState` in `InstrumentTrackWindow::modelChanged`. It contains mostly the code that was previously executed in the constructor of `InstrumentTrackWindow`. The constructor now simply calls this method after it has put the constructed instance into a sub window. With the current implementation the sub window needs to be explicitly triggered to update its title bar once the flags have been adjusted in `updateSubWindowState`. This is done with the new public method `SubWindow::updateTitleBar`. Please note that such an explicit update is not needed if the instrument windows are managed by a `QMdiSubWindow` instead of a `SubWindow`. This means that the implementation of `SubWindow` is still missing something that `QMdiSubWindow` does. However, debugging also showed that setting the window flags of the sub window does not seem to lead to an event that could be caught in `SubWindow::changeEvent`. This was found out by simply dumping the event types of all events that arrive in that method and exchanging an instrument. The method `updateSubWindowState` uses the added method `findSubWindowInParents` to find the sub window it is contained in. The latter method should be considered to be moved into a templated helper class because it might be useful in other contexts as well. ## Technical details If you want to experiment with using QMdiSubWindows then simply add the following method to `MainWindow` (right next to `addWindowedWidget`): ``` QMdiSubWindow* MainWindow::addQMdiSubWindow(QWidget *w, Qt::WindowFlags windowFlags) { // wrap the widget in our own *custom* window that patches some errors in QMdiSubWindow auto win = new QMdiSubWindow(m_workspace->viewport(), windowFlags); win->setAttribute(Qt::WA_DeleteOnClose); win->setWidget(w); m_workspace->addSubWindow(win); return win; } ``` Then call that method instead of `addWindowedWidget` in the constructor of `InstrumentTrackWindow`: ``` QMdiSubWindow* subWin = getGUI()->mainWindow()->addQMdiSubWindow( this ); ``` You can then comment out the cast and the call of `updateTitleBar` in `updateSubWindowState` and everything will still work. --- include/InstrumentTrackWindow.h | 4 + include/SubWindow.h | 4 + src/gui/SubWindow.cpp | 4 + src/gui/instrument/InstrumentTrackWindow.cpp | 90 ++++++++++++++------ 4 files changed, 78 insertions(+), 24 deletions(-) diff --git a/include/InstrumentTrackWindow.h b/include/InstrumentTrackWindow.h index f44430d0e39..d40f0369335 100644 --- a/include/InstrumentTrackWindow.h +++ b/include/InstrumentTrackWindow.h @@ -34,6 +34,7 @@ class QLabel; class QLineEdit; class QWidget; +class QMdiSubWindow; namespace lmms { @@ -134,6 +135,9 @@ protected slots: //! required to keep the old look when using a variable sized tab widget void adjustTabSize(QWidget *w); + QMdiSubWindow* findSubWindowInParents(); + void updateSubWindowState(); + InstrumentTrack * m_track; InstrumentTrackView * m_itv; diff --git a/include/SubWindow.h b/include/SubWindow.h index 864b17b508f..2a375d02e85 100644 --- a/include/SubWindow.h +++ b/include/SubWindow.h @@ -71,6 +71,10 @@ class LMMS_EXPORT SubWindow : public QMdiSubWindow int titleBarHeight() const; int frameWidth() const; + // TODO Needed to update the title bar when replacing instruments. + // Update works automatically if QMdiSubWindows are used. + void updateTitleBar(); + protected: // hook the QWidget move/resize events to update the tracked geometry void moveEvent( QMoveEvent * event ) override; diff --git a/src/gui/SubWindow.cpp b/src/gui/SubWindow.cpp index 61d816e83fe..bead3594a36 100644 --- a/src/gui/SubWindow.cpp +++ b/src/gui/SubWindow.cpp @@ -249,6 +249,10 @@ int SubWindow::frameWidth() const } +void SubWindow::updateTitleBar() +{ + adjustTitleBar(); +} /** diff --git a/src/gui/instrument/InstrumentTrackWindow.cpp b/src/gui/instrument/InstrumentTrackWindow.cpp index a9504732a09..f85cfb93af1 100644 --- a/src/gui/instrument/InstrumentTrackWindow.cpp +++ b/src/gui/instrument/InstrumentTrackWindow.cpp @@ -59,7 +59,6 @@ #include "MainWindow.h" #include "PianoView.h" #include "PluginFactory.h" -#include "PluginView.h" #include "Song.h" #include "StringPairDrag.h" #include "SubWindow.h" @@ -284,30 +283,10 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) : updateInstrumentView(); QMdiSubWindow* subWin = getGUI()->mainWindow()->addWindowedWidget( this ); - Qt::WindowFlags flags = subWin->windowFlags(); - if (m_instrumentView->isResizable()) - { - // TODO As of writing SlicerT is the only resizable instrument. Is this code specific to SlicerT? - const auto extraSpace = QSize(12, 208); - subWin->setMaximumSize(m_instrumentView->maximumSize() + extraSpace); - subWin->setMinimumSize(m_instrumentView->minimumSize() + extraSpace); - - flags &= ~Qt::MSWindowsFixedSizeDialogHint; - flags |= Qt::WindowMaximizeButtonHint; - } - else - { - flags |= Qt::MSWindowsFixedSizeDialogHint; - flags &= ~Qt::WindowMaximizeButtonHint; - - // Hide the Size and Maximize options from the system menu since the dialog size is fixed. - QMenu * systemMenu = subWin->systemMenu(); - systemMenu->actions().at(2)->setVisible(false); // Size - systemMenu->actions().at(4)->setVisible(false); // Maximize - } - - subWin->setWindowFlags(flags); + // The previous call should have given us a sub window parent. Therefore + // we can reuse this method. + updateSubWindowState(); subWin->setWindowIcon(embed::getIconPixmap("instrument_track")); subWin->hide(); @@ -413,6 +392,8 @@ void InstrumentTrackWindow::modelChanged() m_tuningView->keymapCombo()->setModel(m_track->m_microtuner.keymapModel()); m_tuningView->rangeImportCheckbox()->setModel(m_track->m_microtuner.keyRangeImportModel()); updateName(); + + updateSubWindowState(); } @@ -717,5 +698,66 @@ void InstrumentTrackWindow::adjustTabSize(QWidget *w) w->update(); } +QMdiSubWindow* InstrumentTrackWindow::findSubWindowInParents() +{ + // TODO Move to helper? Does not seem to be provided by Qt. + auto p = parentWidget(); + + while (p != nullptr) + { + auto mdiSubWindow = dynamic_cast(p); + if (mdiSubWindow) + { + return mdiSubWindow; + } + else + { + p = p->parentWidget(); + } + } + + return nullptr; +} + +void InstrumentTrackWindow::updateSubWindowState() +{ + auto subWindow = findSubWindowInParents(); + if (subWindow && m_instrumentView) + { + Qt::WindowFlags flags = subWindow->windowFlags(); + + if (m_instrumentView->isResizable()) + { + // TODO As of writing SlicerT is the only resizable instrument. Is this code specific to SlicerT? + const auto extraSpace = QSize(12, 208); + subWindow->setMaximumSize(m_instrumentView->maximumSize() + extraSpace); + subWindow->setMinimumSize(m_instrumentView->minimumSize() + extraSpace); + + flags &= ~Qt::MSWindowsFixedSizeDialogHint; + flags |= Qt::WindowMaximizeButtonHint; + } + else + { + flags |= Qt::MSWindowsFixedSizeDialogHint; + flags &= ~Qt::WindowMaximizeButtonHint; + + // Hide the Size and Maximize options from the system menu since the dialog size is fixed. + QMenu * systemMenu = subWindow->systemMenu(); + systemMenu->actions().at(2)->setVisible(false); // Size + systemMenu->actions().at(4)->setVisible(false); // Maximize + } + + subWindow->setWindowFlags(flags); + + // TODO This is only needed if the sub window is implemented with LMMS' own SubWindow class. + // If an QMdiSubWindow is used everything works automatically. It seems that SubWindow is + // missing some implementation details that QMdiSubWindow has. + auto subWin = dynamic_cast(subWindow); + if (subWin) + { + subWin->updateTitleBar(); + } + } +} } // namespace lmms::gui From e69204fdcc7504026e071ef8331aa1f5b51f85c1 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Wed, 9 Oct 2024 18:31:26 +0200 Subject: [PATCH 09/12] Update the system menu Show or hide the "Size" and "Maximize" entries in the system menu depending on whether the instrument view is resizable or not. --- src/gui/instrument/InstrumentTrackWindow.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/gui/instrument/InstrumentTrackWindow.cpp b/src/gui/instrument/InstrumentTrackWindow.cpp index f85cfb93af1..6d846599fdc 100644 --- a/src/gui/instrument/InstrumentTrackWindow.cpp +++ b/src/gui/instrument/InstrumentTrackWindow.cpp @@ -726,7 +726,9 @@ void InstrumentTrackWindow::updateSubWindowState() { Qt::WindowFlags flags = subWindow->windowFlags(); - if (m_instrumentView->isResizable()) + const auto instrumentViewResizable = m_instrumentView->isResizable(); + + if (instrumentViewResizable) { // TODO As of writing SlicerT is the only resizable instrument. Is this code specific to SlicerT? const auto extraSpace = QSize(12, 208); @@ -740,14 +742,14 @@ void InstrumentTrackWindow::updateSubWindowState() { flags |= Qt::MSWindowsFixedSizeDialogHint; flags &= ~Qt::WindowMaximizeButtonHint; - - // Hide the Size and Maximize options from the system menu since the dialog size is fixed. - QMenu * systemMenu = subWindow->systemMenu(); - systemMenu->actions().at(2)->setVisible(false); // Size - systemMenu->actions().at(4)->setVisible(false); // Maximize } subWindow->setWindowFlags(flags); + + // Show or gide the Size and Maximize options from the system menu depending on whether the view is resizable or not + QMenu * systemMenu = subWindow->systemMenu(); + systemMenu->actions().at(2)->setVisible(instrumentViewResizable); // Size + systemMenu->actions().at(4)->setVisible(instrumentViewResizable); // Maximize // TODO This is only needed if the sub window is implemented with LMMS' own SubWindow class. // If an QMdiSubWindow is used everything works automatically. It seems that SubWindow is From 9aab76b3d47393fc2d6aebcf8d3ceaee78b75efe Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Wed, 9 Oct 2024 18:37:08 +0200 Subject: [PATCH 10/12] Show non-resizable instruments as normal Show the sub windows of non-resizable instruments as normal if the sub window is maximized because it was previously used with a resizable instrument. --- src/gui/instrument/InstrumentTrackWindow.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/instrument/InstrumentTrackWindow.cpp b/src/gui/instrument/InstrumentTrackWindow.cpp index 6d846599fdc..7287d399b5a 100644 --- a/src/gui/instrument/InstrumentTrackWindow.cpp +++ b/src/gui/instrument/InstrumentTrackWindow.cpp @@ -742,6 +742,13 @@ void InstrumentTrackWindow::updateSubWindowState() { flags |= Qt::MSWindowsFixedSizeDialogHint; flags &= ~Qt::WindowMaximizeButtonHint; + + // The sub window might be reused from an instrument that was maximized. Show the sub window + // as normal, i.e. not maximized, if the instrument view is not resizable. + if (subWindow->isMaximized()) + { + subWindow->showNormal(); + } } subWindow->setWindowFlags(flags); From 8b4976eaaf15612668cd1d3ea48b14601ae57a5f Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Fri, 11 Oct 2024 09:39:54 +0200 Subject: [PATCH 11/12] Fix typo --- src/gui/instrument/InstrumentTrackWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/instrument/InstrumentTrackWindow.cpp b/src/gui/instrument/InstrumentTrackWindow.cpp index 32612438002..9aa696e3906 100644 --- a/src/gui/instrument/InstrumentTrackWindow.cpp +++ b/src/gui/instrument/InstrumentTrackWindow.cpp @@ -753,7 +753,7 @@ void InstrumentTrackWindow::updateSubWindowState() subWindow->setWindowFlags(flags); - // Show or gide the Size and Maximize options from the system menu depending on whether the view is resizable or not + // Show or hide the Size and Maximize options from the system menu depending on whether the view is resizable or not QMenu * systemMenu = subWindow->systemMenu(); systemMenu->actions().at(2)->setVisible(instrumentViewResizable); // Size systemMenu->actions().at(4)->setVisible(instrumentViewResizable); // Maximize From a594002d982af0997d05ff9f6aa07219589cbe57 Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Fri, 11 Oct 2024 09:43:29 +0200 Subject: [PATCH 12/12] Rename updateSubWindowState Rename `updateSubWindowState` to `updateSubWindow`. --- include/InstrumentTrackWindow.h | 2 +- src/gui/instrument/InstrumentTrackWindow.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/InstrumentTrackWindow.h b/include/InstrumentTrackWindow.h index d40f0369335..d4b285ccdaa 100644 --- a/include/InstrumentTrackWindow.h +++ b/include/InstrumentTrackWindow.h @@ -136,7 +136,7 @@ protected slots: void adjustTabSize(QWidget *w); QMdiSubWindow* findSubWindowInParents(); - void updateSubWindowState(); + void updateSubWindow(); InstrumentTrack * m_track; InstrumentTrackView * m_itv; diff --git a/src/gui/instrument/InstrumentTrackWindow.cpp b/src/gui/instrument/InstrumentTrackWindow.cpp index 9aa696e3906..f6f30d020af 100644 --- a/src/gui/instrument/InstrumentTrackWindow.cpp +++ b/src/gui/instrument/InstrumentTrackWindow.cpp @@ -286,7 +286,7 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) : // The previous call should have given us a sub window parent. Therefore // we can reuse this method. - updateSubWindowState(); + updateSubWindow(); subWin->setWindowIcon(embed::getIconPixmap("instrument_track")); subWin->hide(); @@ -393,7 +393,7 @@ void InstrumentTrackWindow::modelChanged() m_tuningView->rangeImportCheckbox()->setModel(m_track->m_microtuner.keyRangeImportModel()); updateName(); - updateSubWindowState(); + updateSubWindow(); } @@ -719,7 +719,7 @@ QMdiSubWindow* InstrumentTrackWindow::findSubWindowInParents() return nullptr; } -void InstrumentTrackWindow::updateSubWindowState() +void InstrumentTrackWindow::updateSubWindow() { auto subWindow = findSubWindowInParents(); if (subWindow && m_instrumentView)