mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix modifier key names in shortcut editor (fixes #2817)
This commit is contained in:
parent
1acaa45ea5
commit
1722fe4530
1
CHANGES
1
CHANGES
|
@ -19,6 +19,7 @@ Other fixes:
|
||||||
- Qt: Fix savestate preview sizes with different scales (fixes mgba.io/i/2560)
|
- Qt: Fix savestate preview sizes with different scales (fixes mgba.io/i/2560)
|
||||||
- Qt: Properly cap number of attached players by platform (fixes mgba.io/i/2807)
|
- Qt: Properly cap number of attached players by platform (fixes mgba.io/i/2807)
|
||||||
- Qt: Disable attempted linking betwen incompatible platforms (fixes mgba.io/i/2702)
|
- Qt: Disable attempted linking betwen incompatible platforms (fixes mgba.io/i/2702)
|
||||||
|
- Qt: Fix modifier key names in shortcut editor (fixes mgba.io/i/2817)
|
||||||
Misc:
|
Misc:
|
||||||
- GB Serialize: Add missing savestate support for MBC6 and NT (newer)
|
- GB Serialize: Add missing savestate support for MBC6 and NT (newer)
|
||||||
- GBA: Improve detection of valid ELF ROMs
|
- GBA: Improve detection of valid ELF ROMs
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "input/GamepadAxisEvent.h"
|
#include "input/GamepadAxisEvent.h"
|
||||||
#include "input/GamepadButtonEvent.h"
|
#include "input/GamepadButtonEvent.h"
|
||||||
#include "ShortcutController.h"
|
#include "ShortcutController.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
|
@ -33,35 +34,7 @@ void KeyEditor::setValue(int key) {
|
||||||
if (key < 0) {
|
if (key < 0) {
|
||||||
setText(tr("---"));
|
setText(tr("---"));
|
||||||
} else {
|
} else {
|
||||||
QKeySequence seq(key);
|
setText(keyName(key));
|
||||||
switch (key) {
|
|
||||||
#ifndef Q_OS_MAC
|
|
||||||
case Qt::Key_Shift:
|
|
||||||
setText(QCoreApplication::translate("QShortcut", "Shift"));
|
|
||||||
break;
|
|
||||||
case Qt::Key_Control:
|
|
||||||
setText(QCoreApplication::translate("QShortcut", "Control"));
|
|
||||||
break;
|
|
||||||
case Qt::Key_Alt:
|
|
||||||
setText(QCoreApplication::translate("QShortcut", "Alt"));
|
|
||||||
break;
|
|
||||||
case Qt::Key_Meta:
|
|
||||||
setText(QCoreApplication::translate("QShortcut", "Meta"));
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case Qt::Key_Super_L:
|
|
||||||
setText(tr("Super (L)"));
|
|
||||||
break;
|
|
||||||
case Qt::Key_Super_R:
|
|
||||||
setText(tr("Super (R)"));
|
|
||||||
break;
|
|
||||||
case Qt::Key_Menu:
|
|
||||||
setText(tr("Menu"));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
setText(QKeySequence(key).toString(QKeySequence::NativeText));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit valueChanged(key);
|
emit valueChanged(key);
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "ShortcutModel.h"
|
#include "ShortcutModel.h"
|
||||||
|
|
||||||
#include "ShortcutController.h"
|
#include "ShortcutController.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
using namespace QGBA;
|
using namespace QGBA;
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ QVariant ShortcutModel::data(const QModelIndex& index, int role) const {
|
||||||
case 0:
|
case 0:
|
||||||
return m_controller->visibleName(item->name);
|
return m_controller->visibleName(item->name);
|
||||||
case 1:
|
case 1:
|
||||||
return shortcut ? QKeySequence(shortcut->shortcut()).toString(QKeySequence::NativeText) : QVariant();
|
return shortcut ? keyName(shortcut->shortcut()) : QVariant();
|
||||||
case 2:
|
case 2:
|
||||||
if (!shortcut) {
|
if (!shortcut) {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QKeySequence>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "VFileDevice.h"
|
#include "VFileDevice.h"
|
||||||
|
@ -129,4 +130,27 @@ bool extractMatchingFile(VDir* dir, std::function<QString (VDirEntry*)> filter)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString keyName(int key) {
|
||||||
|
switch (key) {
|
||||||
|
#ifndef Q_OS_MAC
|
||||||
|
case Qt::Key_Shift:
|
||||||
|
return QCoreApplication::translate("QShortcut", "Shift");
|
||||||
|
case Qt::Key_Control:
|
||||||
|
return QCoreApplication::translate("QShortcut", "Control");
|
||||||
|
case Qt::Key_Alt:
|
||||||
|
return QCoreApplication::translate("QShortcut", "Alt");
|
||||||
|
case Qt::Key_Meta:
|
||||||
|
return QCoreApplication::translate("QShortcut", "Meta");
|
||||||
|
#endif
|
||||||
|
case Qt::Key_Super_L:
|
||||||
|
return QObject::tr("Super (L)");
|
||||||
|
case Qt::Key_Super_R:
|
||||||
|
return QObject::tr("Super (R)");
|
||||||
|
case Qt::Key_Menu:
|
||||||
|
return QObject::tr("Menu");
|
||||||
|
default:
|
||||||
|
return QKeySequence(key).toString(QKeySequence::NativeText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,4 +75,6 @@ constexpr const T& clamp(const T& v, const T& lo, const T& hi) {
|
||||||
QString romFilters(bool includeMvl = false);
|
QString romFilters(bool includeMvl = false);
|
||||||
bool extractMatchingFile(VDir* dir, std::function<QString (VDirEntry*)> filter);
|
bool extractMatchingFile(VDir* dir, std::function<QString (VDirEntry*)> filter);
|
||||||
|
|
||||||
|
QString keyName(int key);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue