mirror of https://github.com/mgba-emu/mgba.git
Add load most recent script menu option (#3266)
This commit is contained in:
parent
eaee4228ba
commit
ecfdff2338
Binary file not shown.
|
@ -39,6 +39,7 @@ ScriptingView::ScriptingView(ScriptingController* controller, ConfigController*
|
||||||
|
|
||||||
connect(m_ui.buffers->selectionModel(), &QItemSelectionModel::currentChanged, this, &ScriptingView::selectBuffer);
|
connect(m_ui.buffers->selectionModel(), &QItemSelectionModel::currentChanged, this, &ScriptingView::selectBuffer);
|
||||||
connect(m_ui.load, &QAction::triggered, this, &ScriptingView::load);
|
connect(m_ui.load, &QAction::triggered, this, &ScriptingView::load);
|
||||||
|
connect(m_ui.loadMostRecent, &QAction::triggered, this, &ScriptingView::loadMostRecent);
|
||||||
connect(m_ui.reset, &QAction::triggered, controller, &ScriptingController::reset);
|
connect(m_ui.reset, &QAction::triggered, controller, &ScriptingController::reset);
|
||||||
|
|
||||||
m_mruFiles = m_config->getMRU(ConfigController::MRU::Script);
|
m_mruFiles = m_config->getMRU(ConfigController::MRU::Script);
|
||||||
|
@ -66,6 +67,10 @@ void ScriptingView::load() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptingView::loadMostRecent() {
|
||||||
|
m_controller->loadFile(m_mruFiles.at(0));
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptingView::controllerReset() {
|
void ScriptingView::controllerReset() {
|
||||||
selectBuffer(QModelIndex());
|
selectBuffer(QModelIndex());
|
||||||
}
|
}
|
||||||
|
@ -105,7 +110,15 @@ void ScriptingView::updateMRU() {
|
||||||
m_ui.mru->clear();
|
m_ui.mru->clear();
|
||||||
for (const auto& fname : m_mruFiles) {
|
for (const auto& fname : m_mruFiles) {
|
||||||
m_ui.mru->addAction(fname, [this, fname]() {
|
m_ui.mru->addAction(fname, [this, fname]() {
|
||||||
m_controller->loadFile(fname);
|
if (m_controller->loadFile(fname)) {
|
||||||
|
appendMRU(fname);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
checkEmptyMRU();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ScriptingView::checkEmptyMRU() {
|
||||||
|
m_ui.loadMostRecent->setEnabled(!m_mruFiles.isEmpty());
|
||||||
|
}
|
|
@ -22,6 +22,7 @@ public:
|
||||||
private slots:
|
private slots:
|
||||||
void submitRepl();
|
void submitRepl();
|
||||||
void load();
|
void load();
|
||||||
|
void loadMostRecent();
|
||||||
|
|
||||||
void controllerReset();
|
void controllerReset();
|
||||||
void selectBuffer(const QModelIndex& current, const QModelIndex& = QModelIndex());
|
void selectBuffer(const QModelIndex& current, const QModelIndex& = QModelIndex());
|
||||||
|
@ -31,6 +32,7 @@ private:
|
||||||
|
|
||||||
void appendMRU(const QString&);
|
void appendMRU(const QString&);
|
||||||
void updateMRU();
|
void updateMRU();
|
||||||
|
void checkEmptyMRU();
|
||||||
|
|
||||||
Ui::ScriptingView m_ui;
|
Ui::ScriptingView m_ui;
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="load"/>
|
<addaction name="load"/>
|
||||||
<addaction name="mru"/>
|
<addaction name="mru"/>
|
||||||
|
<addaction name="loadMostRecent"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="reset"/>
|
<addaction name="reset"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -108,6 +109,11 @@
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Load script...</string>
|
<string>Load script...</string>
|
||||||
</property>
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="loadMostRecent">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Load most recent</string>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="reset">
|
<action name="reset">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
Loading…
Reference in New Issue