Added recent projects menu to Qt TAS editor menu.
This commit is contained in:
parent
556ac79038
commit
989f6d38d4
|
@ -364,9 +364,10 @@ QMenuBar *TasEditorWindow::buildMenuBar(void)
|
|||
fileMenu->addAction(act);
|
||||
|
||||
// File -> Recent
|
||||
recentMenu = fileMenu->addMenu( tr("Recent") );
|
||||
recentProjectMenu = fileMenu->addMenu( tr("&Recent") );
|
||||
|
||||
recentMenu->setEnabled(false); // TODO: setup recent projects menu
|
||||
buildRecentProjectMenu();
|
||||
recentProjectMenuReset = false;
|
||||
|
||||
fileMenu->addSeparator();
|
||||
|
||||
|
@ -1389,6 +1390,12 @@ void TasEditorWindow::frameUpdate(void)
|
|||
|
||||
pianoRoll->update();
|
||||
|
||||
if ( recentProjectMenuReset )
|
||||
{
|
||||
buildRecentProjectMenu();
|
||||
recentProjectMenuReset = false;
|
||||
}
|
||||
|
||||
fceuWrapperUnLock();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -1404,6 +1411,7 @@ bool TasEditorWindow::loadProject(const char* fullname)
|
|||
// loaded successfully
|
||||
applyMovieInputConfig();
|
||||
// add new file to Recent menu
|
||||
addRecentProject( fullname );
|
||||
//taseditorWindow.updateRecentProjectsArray(fullname);
|
||||
//taseditorWindow.updateCaption();
|
||||
update();
|
||||
|
@ -1539,6 +1547,7 @@ bool TasEditorWindow::saveProjectAs(bool save_compact)
|
|||
{
|
||||
project.save( filename.toStdString().c_str(), taseditorConfig.projectSavingOptions_SaveInBinary, taseditorConfig.projectSavingOptions_SaveMarkers, taseditorConfig.projectSavingOptions_SaveBookmarks, taseditorConfig.projectSavingOptions_GreenzoneSavingMode, taseditorConfig.projectSavingOptions_SaveHistory, taseditorConfig.projectSavingOptions_SavePianoRoll, taseditorConfig.projectSavingOptions_SaveSelection);
|
||||
}
|
||||
addRecentProject( filename.toStdString().c_str() );
|
||||
//taseditorWindow.updateRecentProjectsArray(nameo);
|
||||
// saved successfully - remove * mark from caption
|
||||
//taseditorWindow.updateCaption();
|
||||
|
@ -2055,6 +2064,121 @@ void TasEditorWindow::exportMovieFile(void)
|
|||
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void TasEditorWindow::clearProjectList(void)
|
||||
{
|
||||
std::list <std::string*>::iterator it;
|
||||
|
||||
for (it=projList.begin(); it != projList.end(); it++)
|
||||
{
|
||||
delete *it;
|
||||
}
|
||||
projList.clear();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void TasEditorWindow::buildRecentProjectMenu(void)
|
||||
{
|
||||
QAction *act;
|
||||
std::string s;
|
||||
std::string *sptr;
|
||||
char buf[128];
|
||||
|
||||
clearProjectList();
|
||||
recentProjectMenu->clear();
|
||||
|
||||
for (int i=0; i<10; i++)
|
||||
{
|
||||
sprintf(buf, "SDL.RecentTasProject%02i", i);
|
||||
|
||||
g_config->getOption( buf, &s);
|
||||
|
||||
//printf("Recent Rom:%i '%s'\n", i, s.c_str() );
|
||||
|
||||
if ( s.size() > 0 )
|
||||
{
|
||||
act = new TasRecentProjectAction( tr(s.c_str()), recentProjectMenu);
|
||||
|
||||
recentProjectMenu->addAction( act );
|
||||
|
||||
connect(act, SIGNAL(triggered()), act, SLOT(activateCB(void)) );
|
||||
|
||||
sptr = new std::string();
|
||||
|
||||
sptr->assign( s.c_str() );
|
||||
|
||||
projList.push_front( sptr );
|
||||
}
|
||||
}
|
||||
recentProjectMenu->setEnabled( !recentProjectMenu->isEmpty() );
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void TasEditorWindow::saveRecentProjectMenu(void)
|
||||
{
|
||||
int i;
|
||||
std::string *s;
|
||||
std::list <std::string*>::iterator it;
|
||||
char buf[128];
|
||||
|
||||
i = projList.size() - 1;
|
||||
|
||||
for (it=projList.begin(); it != projList.end(); it++)
|
||||
{
|
||||
s = *it;
|
||||
sprintf(buf, "SDL.RecentTasProject%02i", i);
|
||||
|
||||
g_config->setOption( buf, s->c_str() );
|
||||
|
||||
//printf("Recent Rom:%u '%s'\n", i, s->c_str() );
|
||||
i--;
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void TasEditorWindow::addRecentProject( const char *proj )
|
||||
{
|
||||
std::string *s;
|
||||
std::list <std::string*>::iterator match_it;
|
||||
|
||||
for (match_it=projList.begin(); match_it != projList.end(); match_it++)
|
||||
{
|
||||
s = *match_it;
|
||||
|
||||
if ( s->compare( proj ) == 0 )
|
||||
{
|
||||
//printf("Found Match: %s\n", proj );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( match_it != projList.end() )
|
||||
{
|
||||
s = *match_it;
|
||||
|
||||
projList.erase(match_it);
|
||||
|
||||
projList.push_back(s);
|
||||
}
|
||||
else
|
||||
{
|
||||
s = new std::string();
|
||||
|
||||
s->assign( proj );
|
||||
|
||||
projList.push_back(s);
|
||||
|
||||
if ( projList.size() > 10 )
|
||||
{
|
||||
s = projList.front();
|
||||
|
||||
projList.pop_front();
|
||||
|
||||
delete s;
|
||||
}
|
||||
}
|
||||
|
||||
saveRecentProjectMenu();
|
||||
|
||||
recentProjectMenuReset = true;
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void TasEditorWindow::saveProjectCb(void)
|
||||
{
|
||||
saveProject();
|
||||
|
@ -5553,3 +5677,26 @@ void TasFindNoteWindow::findNextClicked(void)
|
|||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
//---- TAS Recent Project Menu Action
|
||||
//----------------------------------------------------------------------------
|
||||
TasRecentProjectAction::TasRecentProjectAction(QString desc, QWidget *parent)
|
||||
: QAction( desc, parent )
|
||||
{
|
||||
path = desc.toStdString();
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
TasRecentProjectAction::~TasRecentProjectAction(void)
|
||||
{
|
||||
//printf("Recent TAS Project Menu Action Deleted\n");
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
void TasRecentProjectAction::activateCB(void)
|
||||
{
|
||||
//printf("Activate Recent TAS Project: %s \n", path.c_str() );
|
||||
|
||||
if ( tasWin )
|
||||
{
|
||||
tasWin->loadProject( path.c_str() );
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
@ -241,6 +241,21 @@ class QPianoRoll : public QWidget
|
|||
void vbarActionTriggered(int act);
|
||||
};
|
||||
|
||||
class TasRecentProjectAction : public QAction
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TasRecentProjectAction( QString title, QWidget *parent = 0);
|
||||
~TasRecentProjectAction(void);
|
||||
|
||||
std::string path;
|
||||
|
||||
public slots:
|
||||
void activateCB(void);
|
||||
|
||||
};
|
||||
|
||||
class TasFindNoteWindow : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -295,6 +310,7 @@ class TasEditorWindow : public QDialog
|
|||
HISTORY history;
|
||||
BRANCHES branches;
|
||||
|
||||
bool loadProject(const char* fullname);
|
||||
void loadClipboard(const char *txt);
|
||||
void toggleInput(int start, int end, int joy, int button, int consecutivenessTag);
|
||||
void setInputUsingPattern(int start, int end, int joy, int button, int consecutivenessTag);
|
||||
|
@ -313,7 +329,7 @@ class TasEditorWindow : public QDialog
|
|||
void buildSideControlPanel(void);
|
||||
void initPatterns(void);
|
||||
|
||||
QMenu *recentMenu;
|
||||
QMenu *recentProjectMenu;
|
||||
QAction *followUndoAct;
|
||||
QAction *followMkrAct;
|
||||
QAction *enaHotChgAct;
|
||||
|
@ -390,17 +406,23 @@ class TasEditorWindow : public QDialog
|
|||
|
||||
std::vector<std::string> patternsNames;
|
||||
std::vector<std::vector<uint8_t>> patterns;
|
||||
std::list <std::string*> projList;
|
||||
|
||||
bool mustCallManualLuaFunction;
|
||||
bool recentProjectMenuReset;
|
||||
private:
|
||||
|
||||
int initModules(void);
|
||||
bool loadProject(const char* fullname);
|
||||
bool saveProject(bool save_compact = false);
|
||||
bool saveProjectAs(bool save_compact = false);
|
||||
bool askToSaveProject(void);
|
||||
void updateToolTips(void);
|
||||
|
||||
void clearProjectList(void);
|
||||
void buildRecentProjectMenu(void);
|
||||
void saveRecentProjectMenu(void);
|
||||
void addRecentProject(const char *prog);
|
||||
|
||||
public slots:
|
||||
void closeWindow(void);
|
||||
void frameUpdate(void);
|
||||
|
|
|
@ -747,6 +747,14 @@ InitConfig()
|
|||
config->addOption( buf, "");
|
||||
}
|
||||
|
||||
for (unsigned int i=0; i<10; i++)
|
||||
{
|
||||
char buf[128];
|
||||
sprintf(buf, "SDL.RecentTasProject%02u", i);
|
||||
|
||||
config->addOption( buf, "");
|
||||
}
|
||||
|
||||
config->addOption("_useNativeFileDialog", "SDL.UseNativeFileDialog", false);
|
||||
config->addOption("_useNativeMenuBar" , "SDL.UseNativeMenuBar", false);
|
||||
config->addOption("SDL.PauseOnMainMenuAccess", false);
|
||||
|
|
Loading…
Reference in New Issue