-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Maximize button for resizable instruments #7514
Merged
michaelgregorius
merged 14 commits into
LMMS:master
from
michaelgregorius:7512-MaximizeButtonForResizableInstruments
Jan 1, 2025
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
9a1eaac
Maximize button for resizable instruments
michaelgregorius eec9df1
Fix rendering of maximized sub windows
michaelgregorius f5d2544
Add SubWindow::addTitleButton
michaelgregorius cdef4b5
Only disable the minimize button
michaelgregorius 0921c97
Remove dependency on MdiArea
michaelgregorius 4b0beb4
Typo and newline at end of file
michaelgregorius e85699f
Clear Qt::MSWindowsFixedSizeDialogHint
michaelgregorius e3560df
Update the sub window title bar of exchanged instruments
michaelgregorius e69204f
Update the system menu
michaelgregorius 9aab76b
Show non-resizable instruments as normal
michaelgregorius f677b8c
Merge remote-tracking branch 'upstream/master' into 7512-MaximizeButt…
michaelgregorius 8b4976e
Fix typo
michaelgregorius a594002
Rename updateSubWindowState
michaelgregorius 567a599
Merge remote-tracking branch 'upstream/master' into 7512-MaximizeButt…
michaelgregorius File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -249,6 +249,10 @@ int SubWindow::frameWidth() const | |
} | ||
|
||
|
||
void SubWindow::updateTitleBar() | ||
{ | ||
adjustTitleBar(); | ||
} | ||
|
||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<QMdiSubWindow*>(p); | ||
if (mdiSubWindow) | ||
{ | ||
return mdiSubWindow; | ||
} | ||
else | ||
{ | ||
p = p->parentWidget(); | ||
} | ||
} | ||
|
||
return nullptr; | ||
} | ||
|
||
void InstrumentTrackWindow::updateSubWindowState() | ||
JohannesLorenz marked this conversation as resolved.
Show resolved
Hide resolved
michaelgregorius marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
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? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note, this is still not fixed - see my previous comment. |
||
const auto extraSpace = QSize(12, 208); | ||
subWindow->setMaximumSize(m_instrumentView->maximumSize() + extraSpace); | ||
subWindow->setMinimumSize(m_instrumentView->minimumSize() + extraSpace); | ||
|
||
flags &= ~Qt::MSWindowsFixedSizeDialogHint; | ||
michaelgregorius marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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*>(subWindow); | ||
if (subWin) | ||
{ | ||
subWin->updateTitleBar(); | ||
} | ||
} | ||
} | ||
|
||
} // namespace lmms::gui |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
These 2 are other good candidates for "inlining".
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.
As this is only a style issue which is a matter of taste I'd rather keep it as is. I find it more readable and due to the braces it is also not very prone to "Heartbleed-like" issues if code is added.