Skip to content

Commit

Permalink
Code review changes
Browse files Browse the repository at this point in the history
Mostly whitespace and formatting changes: remove tabs, remove spaces in parameter lists, remove underscores from parameter names.

Some lines have been shortened by introducing intermediate variables, e.g. in `MixerChannelView`.

`MixerView` has many changes but only related to whitespace. Spaces have been introduced for if and for statements. Whitespace at round braces has been removed everywhere in the implementation file even if a line was not touched by the intial changes.

Remove duplicate forward declaration of `MixerChannelView`.
  • Loading branch information
michaelgregorius committed Dec 29, 2023
1 parent 29e4cfe commit f32d9ce
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 97 deletions.
2 changes: 1 addition & 1 deletion include/MixerChannelView.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace lmms::gui
void paintEvent(QPaintEvent* event) override;
void contextMenuEvent(QContextMenuEvent*) override;
void mousePressEvent(QMouseEvent*) override;
void mouseDoubleClickEvent(QMouseEvent*) override;
void mouseDoubleClickEvent(QMouseEvent*) override;
bool eventFilter(QObject* dist, QEvent* event) override;

int channelIndex() const;
Expand Down
5 changes: 2 additions & 3 deletions include/SendButtonIndicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@ namespace gui

class MixerChannelView;
class MixerView;
class MixerChannelView;

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:
Expand Down
30 changes: 18 additions & 12 deletions src/gui/MixerChannelView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ namespace lmms::gui

void MixerChannelView::contextMenuEvent(QContextMenuEvent*)
{
auto contextMenu = new CaptionMenu( Engine::mixer()->mixerChannel( m_channelIndex )->m_name, this );
auto contextMenu = new CaptionMenu(Engine::mixer()->mixerChannel(m_channelIndex)->m_name, this);

if (m_channelIndex != 0) // no move-options in master
{
Expand Down Expand Up @@ -178,11 +178,13 @@ namespace lmms::gui

void MixerChannelView::paintEvent(QPaintEvent* event)
{
const auto channel = Engine::mixer()->mixerChannel(m_channelIndex);
auto * mixer = Engine::mixer();
const auto channel = mixer->mixerChannel(m_channelIndex);
const bool muted = channel->m_muteModel.value();
const auto name = channel->m_name;
const auto elidedName = elideName(name);
const auto isActive = m_mixerView->currentMixerChannel() == this;
const auto * mixerChannelView = m_mixerView->currentMixerChannel();
const auto isActive = mixerChannelView == this;

if (!m_inRename && m_renameLineEdit->text() != elidedName)
{
Expand Down Expand Up @@ -210,8 +212,9 @@ namespace lmms::gui
painter.setPen(isActive ? strokeOuterActive() : strokeOuterInactive());
painter.drawRect(0, 0, width - MIXER_CHANNEL_OUTER_BORDER_SIZE, height - MIXER_CHANNEL_OUTER_BORDER_SIZE);

const auto sendToThis = Engine::mixer()->channelSendModel(m_mixerView->currentMixerChannel()->m_channelIndex, m_channelIndex) != nullptr;
const auto receiveFromThis = Engine::mixer()->channelSendModel(m_channelIndex, m_mixerView->currentMixerChannel()->m_channelIndex) != nullptr;
const auto & currentMixerChannelIndex = mixerChannelView->m_channelIndex;
const auto sendToThis = mixer->channelSendModel(currentMixerChannelIndex, m_channelIndex) != nullptr;
const auto receiveFromThis = mixer->channelSendModel(m_channelIndex, currentMixerChannelIndex) != nullptr;
const auto sendReceiveStateNone = !sendToThis && !receiveFromThis;

// Only one or none of them can be on
Expand Down Expand Up @@ -389,10 +392,13 @@ namespace lmms::gui
void MixerChannelView::selectColor()
{
const auto channel = Engine::mixer()->mixerChannel(m_channelIndex);
const auto newColor = ColorChooser{this}
.withPalette(ColorChooser::Palette::Mixer)
->getColor(channel->color().value_or(backgroundActive().color()));

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

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

channel->setColor(newColor);

Engine::getSong()->setModified();
Expand All @@ -410,25 +416,25 @@ namespace lmms::gui
void MixerChannelView::removeChannel()
{
auto mix = getGUI()->mixerView();
mix->deleteChannel(m_channelIndex);
mix->deleteChannel(m_channelIndex);
}

void MixerChannelView::removeUnusedChannels()
{
auto mix = getGUI()->mixerView();
mix->deleteUnusedChannels();
mix->deleteUnusedChannels();
}

void MixerChannelView::moveChannelLeft()
{
auto mix = getGUI()->mixerView();
mix->moveChannelLeft(m_channelIndex);
mix->moveChannelLeft(m_channelIndex);
}

void MixerChannelView::moveChannelRight()
{
auto mix = getGUI()->mixerView();
mix->moveChannelRight(m_channelIndex);
mix->moveChannelRight(m_channelIndex);
}

QString MixerChannelView::elideName(const QString& name)
Expand Down
Loading

0 comments on commit f32d9ce

Please sign in to comment.