Disable menu options on json load

This commit is contained in:
Miodrag Milanovic 2018-08-05 18:02:33 +02:00
parent 7794bbfb3f
commit 9510c444c9
4 changed files with 14 additions and 6 deletions

View File

@ -170,6 +170,7 @@ int CommandHandler::executeMain(std::unique_ptr<Context> ctx)
log_error("Loading design failed.\n");
customAfterLoad(w.getContext());
w.updateJsonLoaded();
}
} catch (log_execution_error_exception) {
// show error is handled by gui itself

View File

@ -302,8 +302,7 @@ void BaseMainWindow::load_json(std::string filename)
if (parse_json_file(f, filename, ctx.get())) {
log("Loading design successful.\n");
Q_EMIT updateTreeView();
actionPack->setEnabled(true);
onJsonLoaded();
updateJsonLoaded();
} else {
actionLoadJSON->setEnabled(true);
log("Loading design failed.\n");
@ -425,4 +424,11 @@ void BaseMainWindow::disableActions()
onDisableActions();
}
void BaseMainWindow::updateJsonLoaded()
{
disableActions();
actionPack->setEnabled(true);
onJsonLoaded();
}
NEXTPNR_NAMESPACE_END

View File

@ -48,12 +48,12 @@ class BaseMainWindow : public QMainWindow
explicit BaseMainWindow(std::unique_ptr<Context> context, ArchArgs args, QWidget *parent = 0);
virtual ~BaseMainWindow();
Context *getContext() { return ctx.get(); }
void load_json(std::string filename);
void updateJsonLoaded();
protected:
void createMenusAndBars();
void disableActions();
void load_json(std::string filename);
virtual void onDisableActions(){};
virtual void onJsonLoaded(){};
virtual void onPackFinished(){};

View File

@ -34,9 +34,10 @@ class MainWindow : public BaseMainWindow
public:
void createMenu();
void load_pcf(std::string filename);
protected:
void load_pcf(std::string filename);
void onDisableActions() override;
void onJsonLoaded() override;
void onRouteFinished() override;