From aae393b457b4f4777ef2d203e30984600821accc Mon Sep 17 00:00:00 2001 From: szeli1 <143485814+szeli1@users.noreply.github.com> Date: Sat, 27 Jul 2024 17:05:55 +0200 Subject: [PATCH] MixerChannelLcdSpinBox_adding_inputdialog --- include/MixerChannelLcdSpinBox.h | 2 ++ src/gui/widgets/MixerChannelLcdSpinBox.cpp | 30 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/MixerChannelLcdSpinBox.h b/include/MixerChannelLcdSpinBox.h index 0abd9f100f1..251cf7da259 100644 --- a/include/MixerChannelLcdSpinBox.h +++ b/include/MixerChannelLcdSpinBox.h @@ -50,6 +50,8 @@ class MixerChannelLcdSpinBox : public LcdSpinBox void contextMenuEvent(QContextMenuEvent* event) override; private: + void enterValue(); + TrackView * m_tv; }; diff --git a/src/gui/widgets/MixerChannelLcdSpinBox.cpp b/src/gui/widgets/MixerChannelLcdSpinBox.cpp index 8a67394de91..3ac8a1d5797 100644 --- a/src/gui/widgets/MixerChannelLcdSpinBox.cpp +++ b/src/gui/widgets/MixerChannelLcdSpinBox.cpp @@ -24,6 +24,9 @@ #include "MixerChannelLcdSpinBox.h" +#include +#include + #include "CaptionMenu.h" #include "MixerView.h" #include "GuiApplication.h" @@ -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(); @@ -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(), &ok); + + if(ok) + { + model()->setValue(new_val); + } +} } // namespace lmms::gui