Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controller mapping table: show readable/translated strings for script bindings #11139

Merged
merged 3 commits into from
Jan 4, 2023
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: 4 additions & 3 deletions src/controllers/controllerinputmappingtablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#include "controllers/midi/midiutils.h"
#include "moc_controllerinputmappingtablemodel.cpp"

ControllerInputMappingTableModel::ControllerInputMappingTableModel(QObject* pParent)
: ControllerMappingTableModel(pParent) {
ControllerInputMappingTableModel::ControllerInputMappingTableModel(QObject* pParent,
ControlPickerMenu* pControlPickerMenu)
: ControllerMappingTableModel(pParent, pControlPickerMenu) {
}

ControllerInputMappingTableModel::~ControllerInputMappingTableModel() {
Expand Down Expand Up @@ -143,7 +144,7 @@ QAbstractItemDelegate* ControllerInputMappingTableModel::delegateForColumn(
case MIDI_COLUMN_OPTIONS:
return new MidiOptionsDelegate(pParent);
case MIDI_COLUMN_ACTION:
pControlDelegate = new ControlDelegate(this);
pControlDelegate = new ControlDelegate(this, m_pControlPickerMenu);
pControlDelegate->setMidiOptionsColumn(MIDI_COLUMN_OPTIONS);
return pControlDelegate;
}
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/controllerinputmappingtablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class ControllerInputMappingTableModel : public ControllerMappingTableModel {
Q_OBJECT
public:
ControllerInputMappingTableModel(QObject* pParent);
ControllerInputMappingTableModel(QObject* pParent, ControlPickerMenu* pControlPickerMenu);
~ControllerInputMappingTableModel() override;

// Apply the changes to the loaded preset.
Expand Down
4 changes: 3 additions & 1 deletion src/controllers/controllermappingtablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

#include "moc_controllermappingtablemodel.cpp"

ControllerMappingTableModel::ControllerMappingTableModel(QObject* pParent)
ControllerMappingTableModel::ControllerMappingTableModel(QObject* pParent,
ControlPickerMenu* pControlPickerMenu)
: QAbstractTableModel(pParent),
m_pControlPickerMenu(pControlPickerMenu),
m_pMidiPreset(nullptr),
m_pHidPreset(nullptr) {
}
Expand Down
4 changes: 3 additions & 1 deletion src/controllers/controllermappingtablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@

#include "controllers/controllerpreset.h"
#include "controllers/controllerpresetvisitor.h"
#include "controllers/controlpickermenu.h"
#include "controllers/midi/midicontrollerpreset.h"
#include "controllers/hid/hidcontrollerpreset.h"

class ControllerMappingTableModel : public QAbstractTableModel,
public ControllerPresetVisitor {
Q_OBJECT
public:
ControllerMappingTableModel(QObject* pParent);
ControllerMappingTableModel(QObject* pParent, ControlPickerMenu* pControlPickerMenu);
~ControllerMappingTableModel() override;

void setPreset(ControllerPresetPointer pPreset);
Expand All @@ -42,6 +43,7 @@ class ControllerMappingTableModel : public QAbstractTableModel,
virtual void onPresetLoaded() = 0;

QVector<QHash<int, QVariant> > m_headerInfo;
ControlPickerMenu* m_pControlPickerMenu;
ControllerPresetPointer m_pPreset;
MidiControllerPreset* m_pMidiPreset;
HidControllerPreset* m_pHidPreset;
Expand Down
7 changes: 4 additions & 3 deletions src/controllers/controlleroutputmappingtablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
#include "controllers/midi/midiutils.h"
#include "moc_controlleroutputmappingtablemodel.cpp"

ControllerOutputMappingTableModel::ControllerOutputMappingTableModel(QObject* pParent)
: ControllerMappingTableModel(pParent) {
ControllerOutputMappingTableModel::ControllerOutputMappingTableModel(QObject* pParent,
ControlPickerMenu* pControlPickerMenu)
: ControllerMappingTableModel(pParent, pControlPickerMenu) {
}

ControllerOutputMappingTableModel::~ControllerOutputMappingTableModel() {
Expand Down Expand Up @@ -112,7 +113,7 @@ QAbstractItemDelegate* ControllerOutputMappingTableModel::delegateForColumn(
case MIDI_COLUMN_OFF:
return new MidiByteDelegate(pParent);
case MIDI_COLUMN_ACTION:
return new ControlDelegate(this);
return new ControlDelegate(this, m_pControlPickerMenu);
}
}
return nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/controlleroutputmappingtablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class ControllerOutputMappingTableModel : public ControllerMappingTableModel {
Q_OBJECT
public:
ControllerOutputMappingTableModel(QObject* pParent);
ControllerOutputMappingTableModel(QObject* pParent, ControlPickerMenu* pControlPickerMenu);
~ControllerOutputMappingTableModel() override;

// Apply the changes to the loaded preset.
Expand Down
122 changes: 53 additions & 69 deletions src/controllers/controlpickermenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ ControlPickerMenu::ControlPickerMenu(QWidget* pParent)
m_parameterStr = tr("Parameter %1");
m_libraryStr = tr("Library");

m_numGroupsTrMap.insert("Channel", m_deckStr);
m_numGroupsTrMap.insert("Sampler", m_samplerStr);
m_numGroupsTrMap.insert("PreviewDeck", m_previewdeckStr);
m_numGroupsTrMap.insert("Microphone", m_microphoneStr);
m_numGroupsTrMap.insert("Auxiliary", m_auxStr);
m_numGroupsTrMap.insert("EffectRack", m_effectRackStr);

m_otherGroupsTrMap.insert("Skin", tr("Skin"));
m_otherGroupsTrMap.insert("Library", m_libraryStr);
m_otherGroupsTrMap.insert("Controller", tr("Controller"));
// TODO(ronso0) "translate" legacy 'Master' to 'Main' in main branch?
m_otherGroupsTrMap.insert("Master", "Master");

// Mixer Controls
QMenu* mixerMenu = addSubmenu(tr("Mixer"));
// Crossfader / Orientation
Expand Down Expand Up @@ -582,102 +595,66 @@ ControlPickerMenu::ControlPickerMenu(QWidget* pParent)
addSeparator();

// Library Controls
QMenu* libraryMenu = addSubmenu(tr("Library"));
QMenu* libraryMenu = addSubmenu(m_libraryStr);
QMenu* navigationMenu = addSubmenu(tr("Navigation"), libraryMenu);
addControl("[Library]",
"MoveUp",
addLibraryControl("MoveUp",
tr("Move up"),
tr("Equivalent to pressing the UP key on the keyboard"),
navigationMenu,
false,
m_libraryStr);
addControl("[Library]",
"MoveDown",
navigationMenu);
addLibraryControl("MoveDown",
tr("Move down"),
tr("Equivalent to pressing the DOWN key on the keyboard"),
navigationMenu,
false,
m_libraryStr);
addControl("[Library]",
"MoveVertical",
navigationMenu);
addLibraryControl("MoveVertical",
tr("Move up/down"),
tr("Move vertically in either direction using a knob, as if "
"pressing UP/DOWN keys"),
navigationMenu,
false,
m_libraryStr);
addControl("[Library]",
"ScrollUp",
navigationMenu);
addLibraryControl("ScrollUp",
tr("Scroll Up"),
tr("Equivalent to pressing the PAGE UP key on the keyboard"),
navigationMenu,
false,
m_libraryStr);
addControl("[Library]",
"ScrollDown",
navigationMenu);
addLibraryControl("ScrollDown",
tr("Scroll Down"),
tr("Equivalent to pressing the PAGE DOWN key on the keyboard"),
navigationMenu,
false,
m_libraryStr);
addControl("[Library]",
"ScrollVertical",
navigationMenu);
addLibraryControl("ScrollVertical",
tr("Scroll up/down"),
tr("Scroll vertically in either direction using a knob, as if "
"pressing PGUP/PGDOWN keys"),
navigationMenu,
false,
m_libraryStr);
addControl("[Library]",
"MoveLeft",
navigationMenu);
addLibraryControl("MoveLeft",
tr("Move left"),
tr("Equivalent to pressing the LEFT key on the keyboard"),
navigationMenu,
false,
m_libraryStr);
addControl("[Library]",
"MoveRight",
navigationMenu);
addLibraryControl("MoveRight",
tr("Move right"),
tr("Equivalent to pressing the RIGHT key on the keyboard"),
navigationMenu,
false,
m_libraryStr);
addControl("[Library]",
"MoveHorizontal",
navigationMenu);
addLibraryControl("MoveHorizontal",
tr("Move left/right"),
tr("Move horizontally in either direction using a knob, as if "
"pressing LEFT/RIGHT keys"),
navigationMenu,
false,
m_libraryStr);
navigationMenu);
navigationMenu->addSeparator();
addControl("[Library]",
"MoveFocusForward",
addLibraryControl("MoveFocusForward",
tr("Move focus to right pane"),
tr("Equivalent to pressing the TAB key on the keyboard"),
navigationMenu,
false,
m_libraryStr);
addControl("[Library]",
"MoveFocusBackward",
navigationMenu);
addLibraryControl("MoveFocusBackward",
tr("Move focus to left pane"),
tr("Equivalent to pressing the SHIFT+TAB key on the keyboard"),
navigationMenu,
false,
m_libraryStr);
addControl("[Library]",
"MoveFocus",
navigationMenu);
addLibraryControl("MoveFocus",
tr("Move focus to right/left pane"),
tr("Move focus one pane to right or left using a knob, as if "
"pressing TAB/SHIFT+TAB keys"),
navigationMenu,
false,
m_libraryStr);
navigationMenu);
libraryMenu->addSeparator();
addControl("[Library]", "GoToItem",
addLibraryControl("GoToItem",
tr("Go to the currently selected item"),
tr("Choose the currently selected item and advance forward one pane if appropriate"),
libraryMenu, false, m_libraryStr);
libraryMenu);
// Load track (these can be loaded into any channel)
addDeckAndSamplerControl("LoadSelectedTrack",
tr("Load Track"),
Expand All @@ -689,18 +666,18 @@ ControlPickerMenu::ControlPickerMenu(QWidget* pParent)
libraryMenu);
libraryMenu->addSeparator();
// Auto DJ
addControl("[Library]", "AutoDjAddBottom",
addLibraryControl("AutoDjAddBottom",
tr("Add to Auto DJ Queue (bottom)"),
tr("Append the selected track to the Auto DJ Queue"),
libraryMenu, false, m_libraryStr);
addControl("[Library]", "AutoDjAddTop",
libraryMenu);
addLibraryControl("AutoDjAddTop",
tr("Add to Auto DJ Queue (top)"),
tr("Prepend selected track to the Auto DJ Queue"),
libraryMenu, false, m_libraryStr);
addControl("[Library]", "AutoDjAddReplace",
libraryMenu);
addLibraryControl("AutoDjAddReplace",
tr("Add to Auto DJ Queue (replace)"),
tr("Replace Auto DJ Queue with selected tracks"),
libraryMenu, false, m_libraryStr);
libraryMenu);
libraryMenu->addSeparator();
addControl("[Recording]", "toggle_recording",
tr("Record Mix"),
Expand Down Expand Up @@ -1418,6 +1395,13 @@ void ControlPickerMenu::addPreviewDeckControl(const QString& control,
addPlayerControl(control, title, controlDescription, pMenu, false, false, true, addReset);
}

void ControlPickerMenu::addLibraryControl(const QString& control,
const QString& title,
const QString& description,
QMenu* pMenu) {
addSingleControl("[Library]", control, title, description, pMenu, m_libraryStr);
}

QMenu* ControlPickerMenu::addSubmenu(QString title, QMenu* pParent) {
if (pParent == nullptr) {
pParent = this;
Expand Down
15 changes: 15 additions & 0 deletions src/controllers/controlpickermenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ class ControlPickerMenu : public QMenu {
QString descriptionForConfigKey(const ConfigKey& key) const;
QString controlTitleForConfigKey(const ConfigKey& key) const;

// share translated group strings
QMap<QString, QString> getNumGroupsTrMap() const {
return m_numGroupsTrMap;
}
QMap<QString, QString> getOtherGroupsTrMap() const {
return m_otherGroupsTrMap;
}

signals:
// Emitted when the user selects a control from the menu.
void controlPicked(const ConfigKey& control);
Expand Down Expand Up @@ -88,6 +96,10 @@ class ControlPickerMenu : public QMenu {
bool microphoneControls,
bool auxControls,
bool addReset = false);
void addLibraryControl(const QString& control,
const QString& title,
const QString& helpText,
QMenu* pMenu);

int addAvailableControl(const ConfigKey& key, const QString& title, const QString& description);

Expand All @@ -108,4 +120,7 @@ class ControlPickerMenu : public QMenu {
QList<ConfigKey> m_controlsAvailable;
QHash<ConfigKey, QString> m_descriptionsByKey;
QHash<ConfigKey, QString> m_titlesByKey;

QMap<QString, QString> m_numGroupsTrMap;
QMap<QString, QString> m_otherGroupsTrMap;
};
Loading