Skip to content

Commit

Permalink
MixerChannelLcdSpinBox_adding_inputdialog
Browse files Browse the repository at this point in the history
  • Loading branch information
szeli1 committed Jul 27, 2024
1 parent 99c30ea commit aae393b
Show file tree
Hide file tree
Showing 2 changed files with 32 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
30 changes: 30 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,25 @@ void MixerChannelLcdSpinBox::contextMenuEvent(QContextMenuEvent* event)
contextMenu->exec(QCursor::pos());
}

void MixerChannelLcdSpinBox::enterValue()
{
bool ok;
int new_val;

new_val = QInputDialog::getInt(
this, tr("Set value"),
tr("Please enter a new value between %1 and %2:").
arg(model()->minValue()).
arg(model()->maxValue()),
model()->value(),
model()->minValue(),
model()->maxValue(),
model()->step<int>(), &ok);

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

} // namespace lmms::gui

0 comments on commit aae393b

Please sign in to comment.