Hide the LED button for "Custom Base Velocity" (#7067)

Hide the LED button for "Custom Base Velocity" as it did not have any other effect besides disabling the spinbox in the GUI. It did not affect any model which could be evaluated elsewhere.

## Technical details
Add functionality to show/hide the LED button to `GroupBox`. There's also a corresponding getter called `ledButtonShown`. The latter is evaluated in the following situations:
* Mouse clicks: if the LED button is hidden then the model is not toggled.
* Paining: The X position of the caption changes depending on whether the LED button is shown or not.

At a certain point the class `GroupBox` should be replaced by something that's implemented with layouts and which is used wherever it's possible.
This commit is contained in:
Michael Gregorius
2024-02-10 14:27:50 +01:00
committed by GitHub
parent c2052151ab
commit dd53bec311
3 changed files with 31 additions and 7 deletions

View File

@@ -145,6 +145,7 @@ InstrumentMidiIOView::InstrumentMidiIOView( QWidget* parent ) :
}
auto baseVelocityGroupBox = new GroupBox(tr("CUSTOM BASE VELOCITY"));
baseVelocityGroupBox->setLedButtonShown(false);
layout->addWidget( baseVelocityGroupBox );
auto baseVelocityLayout = new QVBoxLayout(baseVelocityGroupBox);
@@ -160,12 +161,8 @@ InstrumentMidiIOView::InstrumentMidiIOView( QWidget* parent ) :
m_baseVelocitySpinBox = new LcdSpinBox( 3, baseVelocityGroupBox );
m_baseVelocitySpinBox->setLabel( tr( "BASE VELOCITY" ) );
m_baseVelocitySpinBox->setEnabled( false );
baseVelocityLayout->addWidget( m_baseVelocitySpinBox );
connect( baseVelocityGroupBox->ledButton(), SIGNAL(toggled(bool)),
m_baseVelocitySpinBox, SLOT(setEnabled(bool)));
layout->addStretch();
}

View File

@@ -72,13 +72,23 @@ void GroupBox::modelChanged()
}
bool GroupBox::ledButtonShown() const
{
return m_led->isVisible();
}
void GroupBox::setLedButtonShown(bool value)
{
m_led->setVisible(value);
}
void GroupBox::mousePressEvent( QMouseEvent * _me )
{
if( _me->y() > 1 && _me->y() < 13 && _me->button() == Qt::LeftButton )
if (ledButtonShown() && _me->y() > 1 && _me->y() < 13 && _me->button() == Qt::LeftButton)
{
model()->setValue( !model()->value() );
model()->setValue(!model()->value());
}
}
@@ -102,7 +112,9 @@ void GroupBox::paintEvent( QPaintEvent * pe )
// draw text
p.setPen( palette().color( QPalette::Active, QPalette::Text ) );
p.setFont( pointSize<8>( font() ) );
p.drawText( 22, m_titleBarHeight, m_caption );
int const captionX = ledButtonShown() ? 22 : 6;
p.drawText(captionX, m_titleBarHeight, m_caption);
}