Skip to content
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

Fix resize issues #7524

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/InstrumentView.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class LMMS_EXPORT InstrumentView : public PluginView
InstrumentView( Instrument * _instrument, QWidget * _parent );
~InstrumentView() override;

virtual bool isResizable() const { return false; }

Instrument * model()
{
return( castModel<Instrument>() );
Expand Down
17 changes: 15 additions & 2 deletions src/gui/instrument/InstrumentTrackWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) :
vlayout->addWidget( generalSettingsWidget );
// Use QWidgetItem explicitly to make the size hint change on instrument changes
// QLayout::addWidget() uses QWidgetItemV2 with size hint caching
vlayout->insertItem(1, new QWidgetItem(m_tabWidget));

vlayout->addWidget( m_tabWidget, 1 );
m_tabWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
vlayout->addWidget( m_pianoView );
setModel( _itv->model() );

Expand All @@ -288,9 +290,19 @@ InstrumentTrackWindow::InstrumentTrackWindow( InstrumentTrackView * _itv ) :
if (!m_instrumentView->isResizable()) {
flags |= Qt::MSWindowsFixedSizeDialogHint;
// any better way than this?
subWin->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
if (subWin->layout())
{
subWin->layout()->setSizeConstraint(QLayout::SetFixedSize);
}
} else {
subWin->setMaximumSize(m_instrumentView->maximumHeight() + 12, m_instrumentView->maximumWidth() + 208);
subWin->setMinimumSize( m_instrumentView->minimumWidth() + 12, m_instrumentView->minimumHeight() + 208);
subWin->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
if (subWin->layout())
{
subWin->layout()->setSizeConstraint(QLayout::SetNoConstraint);
}
}
flags &= ~Qt::WindowMaximizeButtonHint;
subWin->setWindowFlags( flags );
Expand All @@ -311,7 +323,7 @@ void InstrumentTrackWindow::resizeEvent(QResizeEvent * event) {
adjustTabSize(m_instrumentView);
adjustTabSize(m_instrumentFunctionsView);
adjustTabSize(m_ssView);
adjustTabSize(m_effectView);
// EffectRackView has sizeHint to be QSize(EffectRackView::DEFAULT_WIDTH, INSTRUMENT_HEIGHT - 4 - 1)
adjustTabSize(m_midiView);
adjustTabSize(m_tuningView);
}
Expand Down Expand Up @@ -482,6 +494,7 @@ void InstrumentTrackWindow::updateInstrumentView()
m_track->dataChanged(); // Get the text on the trackButton to change

adjustTabSize(m_instrumentView);
m_instrumentView->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
m_pianoView->setVisible(m_track->m_instrument->hasNoteInput());
// adjust window size
layout()->invalidate();
Expand Down
2 changes: 1 addition & 1 deletion src/gui/instrument/InstrumentTuningView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ InstrumentTuningView::InstrumentTuningView(InstrumentTrack *it, QWidget *parent)
masterPitchLayout->addWidget(tlabel);

// Microtuner settings
m_microtunerNotSupportedLabel = new QLabel(tr("Microtuner is not available for MIDI-based instruments."));
m_microtunerNotSupportedLabel = new QLabel(tr("Microtuner is not available\nfor MIDI-based instruments."));
m_microtunerNotSupportedLabel->setWordWrap(true);
m_microtunerNotSupportedLabel->hide();
layout->addWidget(m_microtunerNotSupportedLabel);
Expand Down
27 changes: 25 additions & 2 deletions src/gui/widgets/TabWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ void TabWidget::addTab(QWidget* w, const QString& name, const char* pixmap, int
{
w->setFixedSize(width() - 4, height() - m_tabbarHeight);
}
else
{
w->setSizePolicy(sizePolicy());
}
if(w->minimumHeight() > minimumHeight() || w->minimumSizeHint().height() > minimumHeight()) { setMinimumHeight(w->minimumHeight()); }
if(w->minimumWidth() > minimumWidth() || w->minimumSizeHint().width() > minimumWidth()) { setMinimumWidth(w->minimumWidth()); }
w->move(2, m_tabbarHeight - 1);
w->hide();

Expand Down Expand Up @@ -197,9 +203,26 @@ void TabWidget::mousePressEvent(QMouseEvent* me)



void TabWidget::resizeEvent(QResizeEvent*)
void TabWidget::resizeEvent(QResizeEvent* ev)
{
if (!m_resizable)
if (m_resizable)
{
for (const auto& widget : m_widgets)
{
if(widget.w->minimumSize().height() > ev->size().height() - 4 ||
widget.w->minimumSize().width() > ev->size().width() - m_tabbarHeight)
{
ev->ignore();
return;
}
}
for (const auto& widget : m_widgets)
{
widget.w->resize(width() - 4, height() - m_tabbarHeight);
}
QWidget::resizeEvent(ev);
}
else
{
for (const auto& widget : m_widgets)
{
Expand Down
Loading