Added logic to Qt GUI to produce an error message dialog in the event that an ambiguous activation of conflicting hot key sequences occurs.
This commit is contained in:
parent
5f40358a06
commit
c790f1481c
|
@ -566,6 +566,14 @@ void consoleWin_t::initHotKeys(void)
|
|||
Hotkeys[i].init( this );
|
||||
}
|
||||
|
||||
for (int i = 0; i < HK_MAX; i++)
|
||||
{
|
||||
QShortcut *shortcut = Hotkeys[i].getShortcut();
|
||||
|
||||
// Use Lambda Function to set callback
|
||||
connect( shortcut, &QShortcut::activatedAmbiguously, [ this, shortcut ] { warnAmbiguousShortcut( shortcut ); } );
|
||||
}
|
||||
|
||||
// Frame Advance uses key state directly, disable shortcut events
|
||||
Hotkeys[HK_FRAME_ADVANCE].getShortcut()->setEnabled(false);
|
||||
Hotkeys[HK_TURBO ].getShortcut()->setEnabled(false);
|
||||
|
@ -2435,6 +2443,41 @@ void consoleWin_t::toggleFamKeyBrdEnable(void)
|
|||
toggleFamilyKeyboardFunc();
|
||||
}
|
||||
|
||||
void consoleWin_t::warnAmbiguousShortcut( QShortcut *shortcut)
|
||||
{
|
||||
char stmp[256];
|
||||
std::string msg;
|
||||
int c = 0;
|
||||
|
||||
sprintf( stmp, "Error: Ambiguous Shortcut Activation for Key Sequence: '%s'\n", shortcut->key().toString().toStdString().c_str() );
|
||||
|
||||
msg.assign( stmp );
|
||||
|
||||
for (int i = 0; i < HK_MAX; i++)
|
||||
{
|
||||
QShortcut *sc = Hotkeys[i].getShortcut();
|
||||
|
||||
if ( sc == NULL )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( (sc == shortcut) || (shortcut->key().matches( sc->key() ) == QKeySequence::ExactMatch) )
|
||||
{
|
||||
if ( c == 0 )
|
||||
{
|
||||
msg.append("Hot Key Conflict: "); c++;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.append(" and "); c++;
|
||||
}
|
||||
msg.append( Hotkeys[i].getConfigName() );
|
||||
}
|
||||
}
|
||||
QueueErrorMsgWindow( msg.c_str() );
|
||||
}
|
||||
|
||||
void consoleWin_t::powerConsoleCB(void)
|
||||
{
|
||||
fceuWrapperLock();
|
||||
|
|
|
@ -343,6 +343,7 @@ class consoleWin_t : public QMainWindow
|
|||
void loadState9(void);
|
||||
void mainMenuOpen(void);
|
||||
void mainMenuClose(void);
|
||||
void warnAmbiguousShortcut( QShortcut*);
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue