Skip to content
Merged
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
7 changes: 7 additions & 0 deletions include/MixerChannelView.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
#include <QPixmap>
#include <QWidget>

namespace lmms
{
class MixerChannel;
}

namespace lmms::gui
{
constexpr int MIXER_CHANNEL_INNER_BORDER_SIZE = 3;
Expand Down Expand Up @@ -100,6 +105,8 @@ namespace lmms::gui

private:
QString elideName(const QString& name);
MixerChannel* mixerChannel() const;
auto isMasterChannel() const -> bool { return m_channelIndex == 0; }

private:
SendButtonIndicator* m_sendButton;
Expand Down
29 changes: 17 additions & 12 deletions src/gui/MixerChannelView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ namespace lmms::gui

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

if (m_channelIndex != 0) // no move-options in master
if (!isMasterChannel()) // no move-options in master
{
contextMenu->addAction(tr("Move &left"), this, &MixerChannelView::moveChannelLeft);
contextMenu->addAction(tr("Move &right"), this, &MixerChannelView::moveChannelRight);
Expand All @@ -155,7 +155,7 @@ namespace lmms::gui
contextMenu->addAction(tr("Rename &channel"), this, &MixerChannelView::renameChannel);
contextMenu->addSeparator();

if (m_channelIndex != 0) // no remove-option in master
if (!isMasterChannel()) // no remove-option in master
{
contextMenu->addAction(embed::getIconPixmap("cancel"), tr("R&emove channel"), this, &MixerChannelView::removeChannel);
contextMenu->addSeparator();
Expand All @@ -178,7 +178,7 @@ namespace lmms::gui
void MixerChannelView::paintEvent(QPaintEvent* event)
{
auto * mixer = Engine::mixer();
const auto channel = mixer->mixerChannel(m_channelIndex);
const auto channel = mixerChannel();
const bool muted = channel->m_muteModel.value();
const auto name = channel->m_name;
const auto elidedName = elideName(name);
Expand Down Expand Up @@ -351,7 +351,7 @@ namespace lmms::gui

m_channelNumberLcd->hide();
m_renameLineEdit->setFixedWidth(m_renameLineEdit->width());
m_renameLineEdit->setText(Engine::mixer()->mixerChannel(m_channelIndex)->m_name);
m_renameLineEdit->setText(mixerChannel()->m_name);

m_renameLineEditView->setFocus();
m_renameLineEdit->selectAll();
Expand All @@ -370,27 +370,27 @@ namespace lmms::gui
auto newName = m_renameLineEdit->text();
setFocus();

const auto mixerChannel = Engine::mixer()->mixerChannel(m_channelIndex);
if (!newName.isEmpty() && mixerChannel->m_name != newName)
const auto mc = mixerChannel();
if (!newName.isEmpty() && mc->m_name != newName)
{
mixerChannel->m_name = newName;
mc->m_name = newName;
m_renameLineEdit->setText(elideName(newName));
Engine::getSong()->setModified();
}

setToolTip(mixerChannel->m_name);
setToolTip(mc->m_name);
}

void MixerChannelView::resetColor()
{
Engine::mixer()->mixerChannel(m_channelIndex)->setColor(std::nullopt);
mixerChannel()->setColor(std::nullopt);
Engine::getSong()->setModified();
update();
}

void MixerChannelView::selectColor()
{
const auto channel = Engine::mixer()->mixerChannel(m_channelIndex);
const auto channel = mixerChannel();

const auto initialColor = channel->color().value_or(backgroundActive().color());
const auto * colorChooser = ColorChooser{this}.withPalette(ColorChooser::Palette::Mixer);
Expand All @@ -406,7 +406,7 @@ namespace lmms::gui

void MixerChannelView::randomizeColor()
{
auto channel = Engine::mixer()->mixerChannel(m_channelIndex);
auto channel = mixerChannel();
channel->setColor(ColorChooser::getPalette(ColorChooser::Palette::Mixer)[rand() % 48]);
Engine::getSong()->setModified();
update();
Expand Down Expand Up @@ -444,4 +444,9 @@ namespace lmms::gui
return elidedName;
}

MixerChannel* MixerChannelView::mixerChannel() const
{
return Engine::mixer()->mixerChannel(m_channelIndex);
}

} // namespace lmms::gui