Skip to content

Commit

Permalink
More code review changes
Browse files Browse the repository at this point in the history
Fix spaces between types and references/pointers, e.g. use `const QBrush& c` instead of `const QBrush & c`.
Remove underscores from parameter names.
Remove spaces near parentheses.
Replace tabs with spaces.
Introduce intermediate variable to resolve "hanging" + operator.
Replace the connection for the periodic fader updates with one that uses function pointers instead of `SIGNAL` and `SLOT`.
  • Loading branch information
michaelgregorius committed Dec 30, 2023
1 parent 1d3ee18 commit 92878ce
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 51 deletions.
8 changes: 4 additions & 4 deletions include/MixerChannelView.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ namespace lmms::gui
void setSendReceiveState(const SendReceiveState& state);

QBrush backgroundActive() const;
void setBackgroundActive(const QBrush & c);
void setBackgroundActive(const QBrush& c);

QColor strokeOuterActive() const;
void setStrokeOuterActive(const QColor & c);
void setStrokeOuterActive(const QColor& c);

QColor strokeOuterInactive() const;
void setStrokeOuterInactive(const QColor & c );
void setStrokeOuterInactive(const QColor& c);

QColor strokeInnerActive() const;
void setStrokeInnerActive(const QColor & c );
void setStrokeInnerActive(const QColor& c);

QColor strokeInnerInactive() const;
void setStrokeInnerInactive(const QColor& c);
Expand Down
22 changes: 11 additions & 11 deletions include/MixerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ class LMMS_EXPORT MixerView : public QWidget, public ModelView,
Q_OBJECT
public:
MixerView();
void keyPressEvent(QKeyEvent * e) override;
void keyPressEvent(QKeyEvent* e) override;

void saveSettings( QDomDocument & _doc, QDomElement & _this ) override;
void loadSettings( const QDomElement & _this ) override;
void saveSettings(QDomDocument& doc, QDomElement& domElement) override;
void loadSettings(const QDomElement& domElement) override;

inline MixerChannelView* currentMixerChannel()
{
return m_currentMixerChannel;
}

inline MixerChannelView * channelView(int index)
inline MixerChannelView* channelView(int index)
{
return m_mixerChannelViews[index];
}
Expand Down Expand Up @@ -93,22 +93,22 @@ public slots:
int addNewChannel();

protected:
void closeEvent( QCloseEvent * _ce ) override;
void closeEvent(QCloseEvent* ce) override;

private slots:
void updateFaders();
void toggledSolo();

private:
QVector<MixerChannelView *> m_mixerChannelViews;
QVector<MixerChannelView*> m_mixerChannelViews;

MixerChannelView* m_currentMixerChannel;

QScrollArea * channelArea;
QHBoxLayout * chLayout;
QWidget * m_channelAreaWidget;
QStackedLayout * m_racksLayout;
QWidget * m_racksWidget;
QScrollArea* channelArea;
QHBoxLayout* chLayout;
QWidget* m_channelAreaWidget;
QStackedLayout* m_racksLayout;
QWidget* m_racksWidget;

void updateMaxChannelSelector();

Expand Down
10 changes: 5 additions & 5 deletions include/SendButtonIndicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ class MixerView;
class SendButtonIndicator : public QLabel
{
public:
SendButtonIndicator(QWidget * parent, MixerChannelView * owner, MixerView * mv);
SendButtonIndicator(QWidget* parent, MixerChannelView* owner, MixerView* mv);

void mousePressEvent(QMouseEvent * e) override;
void mousePressEvent(QMouseEvent* e) override;
void updateLightStatus();

private:

MixerChannelView * m_parent;
MixerView * m_mv;
MixerChannelView* m_parent;
MixerView* m_mv;
QPixmap m_qpmOff = embed::getIconPixmap("mixer_send_off", 29, 20);
QPixmap m_qpmOn = embed::getIconPixmap("mixer_send_on", 29, 20);

FloatModel * getSendModel();
FloatModel* getSendModel();
};


Expand Down
16 changes: 8 additions & 8 deletions src/gui/MixerChannelView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ namespace lmms::gui

const auto mixerChannel = Engine::mixer()->mixerChannel(channelIndex);
const auto mixerName = mixerChannel->m_name;
setToolTip(mixerName);
setToolTip(mixerName);

m_renameLineEdit = new QLineEdit{mixerName, nullptr};
m_renameLineEdit->setFixedWidth(65);
m_renameLineEdit->setFont(pointSizeF(font(), 7.5f));
m_renameLineEdit->setReadOnly(true);
m_renameLineEdit->installEventFilter(this);
m_renameLineEdit->installEventFilter(this);

auto renameLineEditScene = new QGraphicsScene{};
m_renameLineEditView = new QGraphicsView{};
Expand Down Expand Up @@ -113,7 +113,7 @@ namespace lmms::gui
m_soloButton->setToolTip(tr("Solo this channel"));
connect(&mixerChannel->m_soloModel, &BoolModel::dataChanged, mixerView, &MixerView::toggledSolo, Qt::DirectConnection);

QVBoxLayout * soloMuteLayout = new QVBoxLayout();
QVBoxLayout* soloMuteLayout = new QVBoxLayout();
soloMuteLayout->setContentsMargins(0, 0, 0, 0);
soloMuteLayout->setSpacing(0);
soloMuteLayout->addWidget(m_soloButton, 0, Qt::AlignHCenter);
Expand Down Expand Up @@ -298,7 +298,7 @@ namespace lmms::gui
return m_backgroundActive;
}

void MixerChannelView::setBackgroundActive(const QBrush & c)
void MixerChannelView::setBackgroundActive(const QBrush& c)
{
m_backgroundActive = c;
}
Expand All @@ -308,7 +308,7 @@ namespace lmms::gui
return m_strokeOuterActive;
}

void MixerChannelView::setStrokeOuterActive(const QColor & c)
void MixerChannelView::setStrokeOuterActive(const QColor& c)
{
m_strokeOuterActive = c;
}
Expand Down Expand Up @@ -394,11 +394,11 @@ namespace lmms::gui

const auto initialColor = channel->color().value_or(backgroundActive().color());
const auto * colorChooser = ColorChooser{this}.withPalette(ColorChooser::Palette::Mixer);
const auto newColor = colorChooser->getColor(initialColor);
const auto newColor = colorChooser->getColor(initialColor);

if (!newColor.isValid()) { return; }
if (!newColor.isValid()) { return; }

channel->setColor(newColor);
channel->setColor(newColor);

Engine::getSong()->setModified();
update();
Expand Down
32 changes: 17 additions & 15 deletions src/gui/MixerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,25 @@ MixerView::MixerView() :
class ChannelArea : public QScrollArea
{
public:
ChannelArea(QWidget * parent, MixerView * mv) :
ChannelArea(QWidget* parent, MixerView* mv) :
QScrollArea(parent), m_mv(mv) {}
~ChannelArea() override = default;
void keyPressEvent(QKeyEvent * e) override
void keyPressEvent(QKeyEvent* e) override
{
m_mv->keyPressEvent(e);
}
private:
MixerView * m_mv;
MixerView* m_mv;
};
channelArea = new ChannelArea(this, this);
channelArea->setWidget(m_channelAreaWidget);
channelArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
channelArea->setFrameStyle(QFrame::NoFrame);
channelArea->setMinimumWidth(mixerChannelSize.width() * 6);
channelArea->setFixedHeight(mixerChannelSize.height() +
style()->pixelMetric(QStyle::PM_ScrollBarExtent));

int const scrollBarExtent = style()->pixelMetric(QStyle::PM_ScrollBarExtent);
channelArea->setFixedHeight(mixerChannelSize.height() + scrollBarExtent);

ml->addWidget(channelArea, 1, Qt::AlignTop);

// show the add new mixer channel button
Expand All @@ -158,13 +160,13 @@ MixerView::MixerView() :

updateGeometry();

// timer for updating faders
connect(getGUI()->mainWindow(), SIGNAL(periodicUpdate()),
this, SLOT(updateFaders()));
auto* mainWindow = getGUI()->mainWindow();

// timer for updating faders
connect(mainWindow, &MainWindow::periodicUpdate, this, &MixerView::updateFaders);

// add ourself to workspace
QMdiSubWindow * subWin = getGUI()->mainWindow()->addWindowedWidget(this);
QMdiSubWindow* subWin = mainWindow->addWindowedWidget(this);
Qt::WindowFlags flags = subWin->windowFlags();
flags &= ~Qt::WindowMaximizeButtonHint;
subWin->setWindowFlags(flags);
Expand Down Expand Up @@ -258,17 +260,17 @@ void MixerView::updateMaxChannelSelector()
}


void MixerView::saveSettings(QDomDocument & _doc, QDomElement & _this)
void MixerView::saveSettings(QDomDocument& doc, QDomElement& domElement)
{
MainWindow::saveWidgetState(this, _this);
MainWindow::saveWidgetState(this, domElement);
}




void MixerView::loadSettings(const QDomElement & _this)
void MixerView::loadSettings(const QDomElement& domElement)
{
MainWindow::restoreWidgetState(this, _this);
MainWindow::restoreWidgetState(this, domElement);
}


Expand Down Expand Up @@ -512,7 +514,7 @@ void MixerView::keyPressEvent(QKeyEvent * e)



void MixerView::closeEvent(QCloseEvent * _ce)
void MixerView::closeEvent(QCloseEvent * ce)
{
if (parentWidget())
{
Expand All @@ -522,7 +524,7 @@ void MixerView::closeEvent(QCloseEvent * _ce)
{
hide();
}
_ce->ignore();
ce->ignore();
}


Expand Down
16 changes: 8 additions & 8 deletions src/gui/SendButtonIndicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace lmms::gui
{

SendButtonIndicator:: SendButtonIndicator(QWidget * parent, MixerChannelView * owner, MixerView * mv) :
SendButtonIndicator:: SendButtonIndicator(QWidget* parent, MixerChannelView* owner, MixerView* mv) :
QLabel(parent),
m_parent(owner),
m_mv(mv)
Expand All @@ -19,30 +19,30 @@ SendButtonIndicator:: SendButtonIndicator(QWidget * parent, MixerChannelView * o
setPixmap(m_qpmOff);
}

void SendButtonIndicator::mousePressEvent(QMouseEvent * e)
void SendButtonIndicator::mousePressEvent(QMouseEvent* e)
{
Mixer * mix = Engine::mixer();
Mixer* mix = Engine::mixer();
int from = m_mv->currentMixerChannel()->channelIndex();
int to = m_parent->channelIndex();
FloatModel * sendModel = mix->channelSendModel(from, to);
FloatModel* sendModel = mix->channelSendModel(from, to);
if (sendModel == nullptr)
{
// not sending. create a mixer send.
mix->createChannelSend( from, to );
mix->createChannelSend(from, to);
}
else
{
// sending. delete the mixer send.
mix->deleteChannelSend( from, to );
mix->deleteChannelSend(from, to);
}

m_mv->updateMixerChannel(m_parent->channelIndex());
updateLightStatus();
}

FloatModel * SendButtonIndicator::getSendModel()
FloatModel* SendButtonIndicator::getSendModel()
{
Mixer * mix = Engine::mixer();
Mixer* mix = Engine::mixer();
return mix->channelSendModel(m_mv->currentMixerChannel()->channelIndex(), m_parent->channelIndex());
}

Expand Down

0 comments on commit 92878ce

Please sign in to comment.