Skip to content

Commit

Permalink
Merge pull request #13124 from HemantAntony/13098-mapping_active_look…
Browse files Browse the repository at this point in the history
…s_disabled

Fix #13098: Fixed midi mapping "Active" looking disabled
  • Loading branch information
RomanPudashkin committed Sep 1, 2022
2 parents 2cb6415 + 941332e commit bdce152
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
17 changes: 17 additions & 0 deletions src/framework/shortcuts/shortcutstypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@
#include <list>
#include <QKeySequence>

#include "utils.h"
#include "stringutils.h"
#include "midi/midievent.h"

#include "translation.h"

namespace mu::shortcuts {
struct Shortcut
{
Expand Down Expand Up @@ -93,6 +96,20 @@ struct RemoteEvent {
return type != RemoteEventType::Undefined && value != -1;
}

String name() const
{
if (this->type == RemoteEventType::Note) {
//: A MIDI remote event, namely a note event
return mtrc("shortcuts", "Note %1").arg(String::fromStdString(pitchToString(this->value)));
} else if (this->type == RemoteEventType::Controller) {
//: A MIDI remote event, namely a MIDI controller event
return mtrc("shortcuts", "Controller %1").arg(String::number(this->value));
}

//: No MIDI remote event
return mtrc("shortcuts", "None");
}

bool operator ==(const RemoteEvent& other) const
{
return type == other.type && value == other.value;
Expand Down
18 changes: 1 addition & 17 deletions src/framework/shortcuts/view/editmidimappingmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ QString EditMidiMappingModel::mappingTitle() const
return qtrc("shortcuts", "Waiting…");
}

return deviceName(currentMidiInDeviceId) + " > " + eventName(m_event);
return deviceName(currentMidiInDeviceId) + " > " + m_event.name().toQString();
}

QVariant EditMidiMappingModel::inputtedEvent() const
Expand All @@ -86,19 +86,3 @@ QString EditMidiMappingModel::deviceName(const MidiDeviceID& deviceId) const

return QString();
}

QString EditMidiMappingModel::eventName(const RemoteEvent& event) const
{
QString title;

if (event.type == RemoteEventType::Note) {
//: A MIDI remote event, namely a note event
return qtrc("shortcuts", "Note %1").arg(QString::fromStdString(pitchToString(event.value)));
} else if (event.type == RemoteEventType::Controller) {
//: A MIDI remote event, namely a MIDI controller event
return qtrc("shortcuts", "Controller %1").arg(QString::number(event.value));
}

//: No MIDI remote event
return qtrc("shortcuts", "None");
}
1 change: 0 additions & 1 deletion src/framework/shortcuts/view/editmidimappingmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class EditMidiMappingModel : public QObject, public async::Asyncable

private:
QString deviceName(const midi::MidiDeviceID& deviceId) const;
QString eventName(const RemoteEvent& event) const;

RemoteEvent m_event;
};
Expand Down
3 changes: 2 additions & 1 deletion src/framework/shortcuts/view/mididevicemappingmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ QVariantMap MidiDeviceMappingModel::midiMappingToObject(const MidiControlsMappin

obj[TITLE_KEY] = !action.description.isEmpty() ? action.description.qTranslated() : action.title.qTranslated();
obj[ICON_KEY] = static_cast<int>(action.iconCode);
obj[STATUS_KEY] = midiMapping.isValid() ? qtrc("shortcuts", "Active") : qtrc("shortcuts", "Inactive");
obj[ENABLED_KEY] = midiMapping.isValid();
obj[STATUS_KEY] = midiMapping.isValid() ? midiMapping.event.name().toQString() : qtrc("shortcuts", "Inactive");
obj[MAPPED_TYPE_KEY] = static_cast<int>(midiMapping.event.type);
obj[MAPPED_VALUE_KEY] = midiMapping.event.value;

Expand Down

0 comments on commit bdce152

Please sign in to comment.