Added hot key shortcuts for Qt TAS editor window.

This commit is contained in:
mjbudd77 2021-12-06 20:48:36 -05:00
parent 8cfab72523
commit f351150ad9
3 changed files with 76 additions and 8 deletions

View File

@ -3590,7 +3590,13 @@ void consoleWin_t::toggleMovieFrameDisplay(void)
void consoleWin_t::toggleMovieReadWrite(void)
{
fceuWrapperLock();
FCEUI_SetMovieToggleReadOnly (!FCEUI_GetMovieToggleReadOnly ());
//FCEUI_SetMovieToggleReadOnly (!FCEUI_GetMovieToggleReadOnly ());
FCEUI_MovieToggleReadOnly();
if ( tasWin != NULL )
{
tasWin->updateRecordStatus();
}
fceuWrapperUnLock();
}

View File

@ -203,6 +203,11 @@ TasEditorWindow::TasEditorWindow(QWidget *parent)
mainLayout->setMenuBar( menuBar );
pianoRoll->setFocus();
for (int i=0; i<HK_MAX; i++)
{
hotkeyShortcut[i] = nullptr;
}
initHotKeys();
initModules();
updateCheckedItems();
@ -1174,8 +1179,8 @@ void TasEditorWindow::buildSideControlPanel(void)
connect( similarBtn, SIGNAL(clicked(void)), this, SLOT(findSimilarNote(void)) );
connect( moreBtn , SIGNAL(clicked(void)), this, SLOT(findNextSimilarNote(void)) );
shortcut = new QShortcut( QKeySequence("Pause"), this);
connect( shortcut, SIGNAL(activated(void)), this, SLOT(playbackPauseCB(void)) );
//shortcut = new QShortcut( QKeySequence("Pause"), this);
//connect( shortcut, SIGNAL(activated(void)), this, SLOT(playbackPauseCB(void)) );
shortcut = new QShortcut( QKeySequence("Shift+Up"), this);
connect( shortcut, SIGNAL(activated(void)), this, SLOT(playbackFrameRewind(void)) );
@ -1201,6 +1206,53 @@ void TasEditorWindow::buildSideControlPanel(void)
connect( bkmkBrnchStack, SIGNAL(currentChanged(int)), this, SLOT(tabViewChanged(int) ) );
}
//----------------------------------------------------------------------------
void TasEditorWindow::initHotKeys(void)
{
for (int i=0; i<HK_MAX; i++)
{
QKeySequence ks = Hotkeys[i].getKeySeq();
QShortcut *shortcut = Hotkeys[i].getShortcut();
//printf("HotKey: %i %s\n", i, ks.toString().toStdString().c_str() );
if ( hotkeyShortcut[i] == nullptr )
{
hotkeyShortcut[i] = new QShortcut( ks, this );
if ( shortcut != nullptr )
{
connect( hotkeyShortcut[i], &QShortcut::activated, [ this, i, shortcut ] { activateHotkey( i, shortcut ); } );
}
}
else
{
hotkeyShortcut[i]->setKey( ks );
}
}
// Frame Advance uses key state directly, disable shortcut events
hotkeyShortcut[HK_FRAME_ADVANCE]->setEnabled(false);
hotkeyShortcut[HK_TURBO ]->setEnabled(false);
// Disable shortcuts that are not allowed with TAS Editor
hotkeyShortcut[HK_OPEN_ROM ]->setEnabled(false);
hotkeyShortcut[HK_CLOSE_ROM ]->setEnabled(false);
hotkeyShortcut[HK_QUIT ]->setEnabled(false);
hotkeyShortcut[HK_FULLSCREEN ]->setEnabled(false);
hotkeyShortcut[HK_MAIN_MENU_HIDE]->setEnabled(false);
hotkeyShortcut[HK_LOAD_LUA ]->setEnabled(false);
}
//----------------------------------------------------------------------------
void TasEditorWindow::activateHotkey( int hkIdx, QShortcut *shortcut )
{
shortcut->activated();
}
//----------------------------------------------------------------------------
void TasEditorWindow::updateRecordStatus(void)
{
recRecordingCbox->setChecked( !movie_readonly );
}
//----------------------------------------------------------------------------
void TasEditorWindow::updateCheckedItems(void)
{
@ -1387,7 +1439,7 @@ void TasEditorWindow::frameUpdate(void)
mustCallManualLuaFunction = false;
}
#endif
pianoRoll->update();
if ( recentProjectMenuReset )
@ -2241,11 +2293,15 @@ void TasEditorWindow::setCurrentPattern(int idx)
taseditorConfig.currentPattern = idx;
}
//----------------------------------------------------------------------------
void TasEditorWindow::recordingChanged(int state)
void TasEditorWindow::recordingChanged(int newState)
{
fceuCriticalSection emuLock;
int oldState = !movie_readonly ? Qt::Checked : Qt::Unchecked;
FCEUI_MovieToggleReadOnly();
if ( newState != oldState )
{
FCEUI_MovieToggleReadOnly();
}
}
//----------------------------------------------------------------------------
void TasEditorWindow::editUndoCB(void)
@ -3927,10 +3983,10 @@ void QPianoRoll::contextMenuEvent(QContextMenuEvent *event)
mkr = markersManager->getMarkerAtFrame( rowUnderMouse );
act = new QAction(tr("Set Markers"), &menu);
act = new QAction(tr("Set Markers\tDbl-Clk"), &menu);
menu.addAction(act);
act->setEnabled( mkr == 0 );
act->setShortcut(QKeySequence(tr("Double Click")));
//act->setShortcut(QKeySequence(tr("Double Click")));
connect(act, SIGNAL(triggered(void)), tasWin, SLOT(setMarkers(void)));
act = new QAction(tr("Remove Markers"), &menu);

View File

@ -37,6 +37,7 @@
#include <QStackedWidget>
#include <QClipboard>
#include "Qt/config.h"
#include "Qt/ConsoleUtilities.h"
#include "Qt/TasEditor/taseditor_config.h"
#include "Qt/TasEditor/taseditor_project.h"
@ -327,6 +328,7 @@ class TasEditorWindow : public QDialog
QMenuBar *buildMenuBar(void);
void buildPianoRollDisplay(void);
void buildSideControlPanel(void);
void initHotKeys(void);
void initPatterns(void);
QMenu *recentProjectMenu;
@ -404,6 +406,8 @@ class TasEditorWindow : public QDialog
QClipboard *clipboard;
QShortcut *hotkeyShortcut[HK_MAX];
std::vector<std::string> patternsNames;
std::vector<std::vector<uint8_t>> patterns;
std::list <std::string*> projList;
@ -428,6 +432,7 @@ class TasEditorWindow : public QDialog
void frameUpdate(void);
void updateCheckedItems(void);
void updateHistoryItems(void);
void updateRecordStatus(void);
private slots:
void openProject(void);
void saveProjectCb(void);
@ -507,6 +512,7 @@ class TasEditorWindow : public QDialog
void setMarkers(void);
void removeMarkers(void);
void ungreenzoneSelectedFrames(void);
void activateHotkey( int hkIdx, QShortcut *shortcut );
friend class RECORDER;
friend class SPLICER;