Further hot key config rework.
This commit is contained in:
parent
da401d9833
commit
cbdd6e43d9
|
@ -898,6 +898,9 @@ void consoleWin_t::createMainMenu(void)
|
|||
|
||||
emuMenu->addAction(powerAct);
|
||||
|
||||
Hotkeys[ HK_POWER ].setAction( powerAct );
|
||||
connect( Hotkeys[ HK_POWER ].getShortcut(), SIGNAL(activated()), this, SLOT(powerConsoleCB(void)) );
|
||||
|
||||
// Emulation -> Reset
|
||||
resetAct = new QAction(tr("&Reset"), this);
|
||||
//resetAct->setShortcut( QKeySequence(tr("Ctrl+R")));
|
||||
|
@ -907,6 +910,9 @@ void consoleWin_t::createMainMenu(void)
|
|||
|
||||
emuMenu->addAction(resetAct);
|
||||
|
||||
Hotkeys[ HK_RESET ].setAction( resetAct );
|
||||
connect( Hotkeys[ HK_RESET ].getShortcut(), SIGNAL(activated()), this, SLOT(consoleHardReset(void)) );
|
||||
|
||||
// Emulation -> Soft Reset
|
||||
sresetAct = new QAction(tr("&Soft Reset"), this);
|
||||
//sresetAct->setShortcut( QKeySequence(tr("Ctrl+R")));
|
||||
|
@ -918,13 +924,16 @@ void consoleWin_t::createMainMenu(void)
|
|||
|
||||
// Emulation -> Pause
|
||||
pauseAct = new QAction(tr("&Pause"), this);
|
||||
pauseAct->setShortcut( QKeySequence(tr("Pause")));
|
||||
//pauseAct->setShortcut( QKeySequence(tr("Pause")));
|
||||
pauseAct->setStatusTip(tr("Pause Console"));
|
||||
pauseAct->setIcon( style()->standardIcon( QStyle::SP_MediaPause ) );
|
||||
connect(pauseAct, SIGNAL(triggered()), this, SLOT(consolePause(void)) );
|
||||
|
||||
emuMenu->addAction(pauseAct);
|
||||
|
||||
Hotkeys[ HK_PAUSE ].setAction( pauseAct );
|
||||
connect( Hotkeys[ HK_PAUSE ].getShortcut(), SIGNAL(activated()), this, SLOT(consolePause(void)) );
|
||||
|
||||
emuMenu->addSeparator();
|
||||
|
||||
// Emulation -> Region
|
||||
|
@ -1036,6 +1045,9 @@ void consoleWin_t::createMainMenu(void)
|
|||
|
||||
emuMenu->addAction(insCoinAct);
|
||||
|
||||
Hotkeys[ HK_VS_INSERT_COIN ].setAction( insCoinAct );
|
||||
connect( Hotkeys[ HK_VS_INSERT_COIN ].getShortcut(), SIGNAL(activated()), this, SLOT(insertCoin(void)) );
|
||||
|
||||
emuMenu->addSeparator();
|
||||
|
||||
// Emulation -> FDS
|
||||
|
|
|
@ -52,7 +52,7 @@ HotKeyConfDialog_t::HotKeyConfDialog_t(QWidget *parent)
|
|||
|
||||
mainLayout = new QVBoxLayout();
|
||||
|
||||
tree = new QTreeWidget();
|
||||
tree = new HotKeyConfTree_t(this);
|
||||
|
||||
tree->setColumnCount(2);
|
||||
|
||||
|
@ -76,6 +76,8 @@ HotKeyConfDialog_t::HotKeyConfDialog_t(QWidget *parent)
|
|||
|
||||
item = new QTreeWidgetItem();
|
||||
|
||||
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemNeverHasChildren );
|
||||
|
||||
item->setText(0, QString::fromStdString(optionName));
|
||||
item->setText(1, QString::fromStdString(keyName));
|
||||
|
||||
|
@ -131,7 +133,7 @@ void HotKeyConfDialog_t::assignHotkey(QKeyEvent *event)
|
|||
(k == SDLK_LGUI) || (k == SDLK_RGUI) ||
|
||||
(k == SDLK_CAPSLOCK);
|
||||
|
||||
printf("Assign: '%s' %i 0x%08x\n", ks.toString().toStdString().c_str(), event->key(), event->key() );
|
||||
//printf("Assign: '%s' %i 0x%08x\n", ks.toString().toStdString().c_str(), event->key(), event->key() );
|
||||
|
||||
if ((k != SDLK_UNKNOWN) && !keyIsModifier)
|
||||
{
|
||||
|
@ -207,11 +209,42 @@ void HotKeyConfDialog_t::keyPressEvent(QKeyEvent *event)
|
|||
{
|
||||
//printf("Hotkey Window Key Press: 0x%x \n", event->key() );
|
||||
assignHotkey(event);
|
||||
event->accept();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void HotKeyConfDialog_t::keyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
//printf("Hotkey Window Key Release: 0x%x \n", event->key() );
|
||||
assignHotkey(event);
|
||||
event->accept();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
HotKeyConfTree_t::HotKeyConfTree_t(QWidget *parent)
|
||||
: QTreeWidget(parent)
|
||||
{
|
||||
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
HotKeyConfTree_t::~HotKeyConfTree_t(void)
|
||||
{
|
||||
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void HotKeyConfTree_t::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if ( parent() )
|
||||
{
|
||||
static_cast<HotKeyConfDialog_t*>(parent())->assignHotkey(event);
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void HotKeyConfTree_t::keyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
if ( parent() )
|
||||
{
|
||||
static_cast<HotKeyConfDialog_t*>(parent())->assignHotkey(event);
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
@ -18,6 +18,19 @@
|
|||
|
||||
#include "Qt/main.h"
|
||||
|
||||
class HotKeyConfTree_t : public QTreeWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HotKeyConfTree_t(QWidget *parent = 0);
|
||||
~HotKeyConfTree_t(void);
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void keyReleaseEvent(QKeyEvent *event);
|
||||
};
|
||||
|
||||
class HotKeyConfDialog_t : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -26,13 +39,13 @@ public:
|
|||
HotKeyConfDialog_t(QWidget *parent = 0);
|
||||
~HotKeyConfDialog_t(void);
|
||||
|
||||
void assignHotkey(QKeyEvent *event);
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void keyReleaseEvent(QKeyEvent *event);
|
||||
void assignHotkey(QKeyEvent *event);
|
||||
|
||||
QTreeWidget *tree;
|
||||
HotKeyConfTree_t *tree;
|
||||
|
||||
private:
|
||||
public slots:
|
||||
|
|
|
@ -758,7 +758,7 @@ InitConfig()
|
|||
|
||||
getHotKeyConfig( i, &hotKeyName, &hotKeySeq );
|
||||
|
||||
printf("Hot Key: '%s' = '%s' \n", hotKeyName, hotKeySeq );
|
||||
//printf("Hot Key: '%s' = '%s' \n", hotKeyName, hotKeySeq );
|
||||
|
||||
//keyText.assign(" mod=");
|
||||
|
||||
|
|
|
@ -217,11 +217,11 @@ int hotkey_t::init( QWidget *parent )
|
|||
|
||||
g_config->getOption (prefix + configName, &keyText);
|
||||
|
||||
printf("Initializing: '%s' = '%s'\n", configName, keyText.c_str() );
|
||||
//printf("Initializing: '%s' = '%s'\n", configName, keyText.c_str() );
|
||||
|
||||
shortcut = new QShortcut( QKeySequence( QString::fromStdString(keyText) ), parent );
|
||||
|
||||
printf("ShortCut: '%s' = '%s'\n", configName, shortcut->key().toString().toStdString().c_str() );
|
||||
//printf("ShortCut: '%s' = '%s'\n", configName, shortcut->key().toString().toStdString().c_str() );
|
||||
|
||||
conv2SDL();
|
||||
return 0;
|
||||
|
@ -234,13 +234,18 @@ int hotkey_t::readConfig(void)
|
|||
|
||||
g_config->getOption (prefix + configName, &keyText);
|
||||
|
||||
printf("Config: '%s' = '%s'\n", configName, keyText.c_str() );
|
||||
//printf("Config: '%s' = '%s'\n", configName, keyText.c_str() );
|
||||
|
||||
if ( shortcut )
|
||||
{
|
||||
shortcut->setKey( QString::fromStdString( keyText ) );
|
||||
|
||||
printf("ShortCut: '%s' = '%s'\n", configName, shortcut->key().toString().toStdString().c_str() );
|
||||
//printf("ShortCut: '%s' = '%s'\n", configName, shortcut->key().toString().toStdString().c_str() );
|
||||
|
||||
if ( act )
|
||||
{
|
||||
act->setText( actText + "\t" + shortcut->key().toString() );
|
||||
}
|
||||
}
|
||||
|
||||
conv2SDL();
|
||||
|
@ -254,12 +259,12 @@ void hotkey_t::conv2SDL(void)
|
|||
SDL_Keycode k = convQtKey2SDLKeyCode((Qt::Key)(shortcut->key()[0] & 0x01FFFFFF) );
|
||||
SDL_Keymod m = convQtKey2SDLModifier( (Qt::KeyboardModifier)(shortcut->key()[0] & 0xFE000000) );
|
||||
|
||||
printf("Key: '%s' 0x%08x\n", shortcut->key().toString().toStdString().c_str(), shortcut->key()[0] );
|
||||
//printf("Key: '%s' 0x%08x\n", shortcut->key().toString().toStdString().c_str(), shortcut->key()[0] );
|
||||
|
||||
sdl.value = k;
|
||||
sdl.modifier = m;
|
||||
|
||||
printf("Key: SDL: '%s' \n", SDL_GetKeyName(sdl.value) );
|
||||
//printf("Key: SDL: '%s' \n", SDL_GetKeyName(sdl.value) );
|
||||
}
|
||||
|
||||
void hotkey_t::setConfigName(const char *cName)
|
||||
|
|
Loading…
Reference in New Issue