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

Fixed MIDI Autodetect always On (#1813) #7564

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Rhodexa
Copy link

@Rhodexa Rhodexa commented Oct 25, 2024

The Autodetect checkbox for MIDI Controller Connections is now only enabled if there’s no existing connection between a controller and a parameter. Additionally, the Autodetect feature will disengage automatically when a MIDI CC signal is recognized. This prevents accidental reassignment of connections and ensures clear visibility of active controls

Copy link
Contributor

@szeli1 szeli1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed your PR, please make the following changes

(DID NOT TEST)

@@ -125,8 +125,7 @@ public slots:
namespace gui
{

ControllerConnectionDialog::ControllerConnectionDialog( QWidget * _parent,
const AutomatableModel * _target_model ) :
ControllerConnectionDialog::ControllerConnectionDialog( QWidget * _parent, const AutomatableModel * _target_model ) :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ControllerConnectionDialog::ControllerConnectionDialog( QWidget * _parent, const AutomatableModel * _target_model ) :
ControllerConnectionDialog::ControllerConnectionDialog(QWidget* _parent, const AutomatableModel* _target_model) :

Make sure you follow the style guidelines!

m_midiGroupBox = new GroupBox( tr( "MIDI CONTROLLER" ), this );
m_midiGroupBox->setGeometry( 8, 10, 240, 80 );
connect( m_midiGroupBox->model(), SIGNAL(dataChanged()),
this, SLOT(midiToggled()));

m_midiChannelSpinBox = new LcdSpinBox( 2, m_midiGroupBox,
tr( "Input channel" ) );
m_midiChannelSpinBox = new LcdSpinBox( 2, m_midiGroupBox, tr( "Input channel" ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
m_midiChannelSpinBox = new LcdSpinBox( 2, m_midiGroupBox, tr( "Input channel" ) );
m_midiChannelSpinBox = new LcdSpinBox(2, m_midiGroupBox, tr("Input channel"));

m_midiChannelSpinBox->addTextForValue( 0, "--" );
m_midiChannelSpinBox->setLabel( tr( "CHANNEL" ) );
m_midiChannelSpinBox->move( 8, 24 );

m_midiControllerSpinBox = new LcdSpinBox( 3, m_midiGroupBox,
tr( "Input controller" ) );
m_midiControllerSpinBox = new LcdSpinBox( 3, m_midiGroupBox, tr( "Input controller" ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
m_midiControllerSpinBox = new LcdSpinBox( 3, m_midiGroupBox, tr( "Input controller" ) );
m_midiControllerSpinBox = new LcdSpinBox(3, m_midiGroupBox, tr("Input controller"));

m_midiAutoDetectCheckBox =
new LedCheckBox( tr("Auto Detect"),
m_midiGroupBox, tr("Auto Detect") );
m_midiAutoDetectCheckBox = new LedCheckBox( tr("Auto Detect"), m_midiGroupBox, tr("Auto Detect") );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
m_midiAutoDetectCheckBox = new LedCheckBox( tr("Auto Detect"), m_midiGroupBox, tr("Auto Detect") );
m_midiAutoDetectCheckBox = new LedCheckBox(tr("Auto Detect"), m_midiGroupBox, tr("Auto Detect"));

rp_btn->setGeometry( 160, 24, 32, 32 );
rp_btn->setMenu( m_readablePorts );
rp_btn->setPopupMode( QToolButton::InstantPopup );
rp_btn->setText( tr( "MIDI-devices to receive MIDI-events from" ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove unnecessary white spaces here.

@@ -200,7 +199,7 @@ ControllerConnectionDialog::ControllerConnectionDialog( QWidget * _parent,
this, SLOT(userSelected()));


// Mapping functions
// MAPPING FUNCTION Section
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// MAPPING FUNCTION Section
// Mapping function section

// TODO: This should be reworked into some sort of "shadow" state rather than turning it off...
// since it makes for switching between the USER mode and CONTROLLER mode a bit awkward
// If you toggle the autodetect then move from MIDI to USER then back to MIDI it resets, which is not ideal.
m_midiAutoDetect.setValue( enabled && (!m_targetModel->controllerConnection()) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
m_midiAutoDetect.setValue( enabled && (!m_targetModel->controllerConnection()) );
m_midiAutoDetect.setValue(enabled && (!m_targetModel->controllerConnection()));

Usual white space issue

@@ -420,6 +424,7 @@ void ControllerConnectionDialog::midiValueChanged()
if( m_midiAutoDetect.value() )
{
m_midiController->useDetected();
m_midiAutoDetect.setValue( false );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
m_midiAutoDetect.setValue( false );
m_midiAutoDetect.setValue(false);

@@ -382,7 +385,7 @@ void ControllerConnectionDialog::midiToggled()




// USER CONTROLLER Section logic (Doubles as a Radio-button kinda logic together with MIDI CONTROLLER Section, apparently)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put this inside the header please



// Comments from someone trying to get their head around Qt!
// MIDI CONTROLLER Section logic (Doubles as a Radio-button kinda logic together with USER CONTROLLER Section, apaprently)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add these comments inside the header like this:

//! MIDI controller section logic (Doubles as a Radio-button kinda logic together with user controller section, apparently?)

@Rhodexa
Copy link
Author

Rhodexa commented Oct 28, 2024

Hey, thanks for the feedback, @szeli1, I have revised the entire file to correct code style issues in general. Additionally, I have a also fixed similar issues that were present in the header file. I hope it now adheres better to the ideal structure!

Please let me know if there’s anything else you’d like me to adjust!

@szeli1
Copy link
Contributor

szeli1 commented Oct 28, 2024

Usually the only lines that are formatted are the lines that were changed. I'm sorry I didn't mention this before and I'm not sure what should you do with this knowledge. If I were you I would undo these formatting changes for all lines that were not changed.

(edit: you can mark my review as closed once you implemented the changes I requested)

Copy link
Contributor

@szeli1 szeli1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a style review.

It is difficult to see what was changed because lots of lines are only formatted so it is hard to spot the differences.

{
cc = m_targetModel->controllerConnection();

if( cc && cc->getController()->type() != Controller::ControllerType::Dummy && Engine::getSong() )
if(cc && cc->getController()->type() != Controller::ControllerType::Dummy && Engine::getSong())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(cc && cc->getController()->type() != Controller::ControllerType::Dummy && Engine::getSong())
if (cc && cc->getController()->type() != Controller::ControllerType::Dummy && Engine::getSong())

"if" or "for" and "(" should have a space between.

{
m_midiGroupBox->model()->setValue( true );
}
if(!cc) { m_midiGroupBox->model()->setValue(true); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(!cc) { m_midiGroupBox->model()->setValue(true); }
if (!cc) { m_midiGroupBox->model()->setValue(true); }

{
m_midiController->useDetected();
if( m_readablePorts )
m_midiAutoDetect.setValue(false);
if(m_readablePorts)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(m_readablePorts)
if (m_readablePorts)

void ControllerConnectionDialog::midiValueChanged()
{
if( m_midiAutoDetect.value() )
if(m_midiAutoDetect.value())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(m_midiAutoDetect.value())
if (m_midiAutoDetect.value())

@JohannesLorenz JohannesLorenz added the rework required Pull requests which must be reworked to make it able to merge or review label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rework required Pull requests which must be reworked to make it able to merge or review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants