Skip to content

Commit

Permalink
Add input dialog to the mixer channel LCD spin box (LMMS#7399)
Browse files Browse the repository at this point in the history
Co-authored-by: saker <[email protected]>
  • Loading branch information
szeli1 and sakertooth authored Aug 11, 2024
1 parent d8e4d8c commit bda1a9c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/MixerChannelLcdSpinBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class MixerChannelLcdSpinBox : public LcdSpinBox
void contextMenuEvent(QContextMenuEvent* event) override;

private:
void enterValue();

TrackView * m_tv;
};

Expand Down
23 changes: 23 additions & 0 deletions src/gui/widgets/MixerChannelLcdSpinBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

#include "MixerChannelLcdSpinBox.h"

#include <QInputDialog>
#include <QMouseEvent>

#include "CaptionMenu.h"
#include "MixerView.h"
#include "GuiApplication.h"
Expand All @@ -40,6 +43,13 @@ void MixerChannelLcdSpinBox::setTrackView(TrackView * tv)

void MixerChannelLcdSpinBox::mouseDoubleClickEvent(QMouseEvent* event)
{
if (!(event->modifiers() & Qt::ShiftModifier) &&
!(event->modifiers() & Qt::ControlModifier))
{
enterValue();
return;
}

getGUI()->mixerView()->setCurrentMixerChannel(model()->value());

getGUI()->mixerView()->parentWidget()->show();
Expand Down Expand Up @@ -69,5 +79,18 @@ void MixerChannelLcdSpinBox::contextMenuEvent(QContextMenuEvent* event)
contextMenu->exec(QCursor::pos());
}

void MixerChannelLcdSpinBox::enterValue()
{
const auto val = model()->value();
const auto min = model()->minValue();
const auto max = model()->maxValue();
const auto step = model()->step<int>();
const auto label = tr("Please enter a new value between %1 and %2:").arg(min).arg(max);

auto ok = false;
const auto newVal = QInputDialog::getInt(this, tr("Set value"), label, val, min, max, step, &ok);

if (ok) { model()->setValue(newVal); }
}

} // namespace lmms::gui

0 comments on commit bda1a9c

Please sign in to comment.