move load/save proj to base
This commit is contained in:
parent
4a44b1c961
commit
ecc21caa77
@ -31,6 +31,7 @@
|
||||
#include "jsonparse.h"
|
||||
#include "log.h"
|
||||
#include "mainwindow.h"
|
||||
#include "project.h"
|
||||
#include "pythontab.h"
|
||||
|
||||
static void initBasenameResource() { Q_INIT_RESOURCE(base); }
|
||||
@ -431,4 +432,36 @@ void BaseMainWindow::updateJsonLoaded()
|
||||
onJsonLoaded();
|
||||
}
|
||||
|
||||
void BaseMainWindow::open_proj()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, QString("Open Project"), QString(), QString("*.proj"));
|
||||
if (!fileName.isEmpty()) {
|
||||
try {
|
||||
ProjectHandler proj;
|
||||
disableActions();
|
||||
ctx = proj.load(fileName.toStdString());
|
||||
Q_EMIT contextChanged(ctx.get());
|
||||
log_info("Loaded project %s...\n", fileName.toStdString().c_str());
|
||||
updateJsonLoaded();
|
||||
onProjectLoaded();
|
||||
} catch (log_execution_error_exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BaseMainWindow::save_proj()
|
||||
{
|
||||
if (currentProj.empty()) {
|
||||
QString fileName = QFileDialog::getSaveFileName(this, QString("Save Project"), QString(), QString("*.proj"));
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
currentProj = fileName.toStdString();
|
||||
}
|
||||
if (!currentProj.empty()) {
|
||||
ProjectHandler proj;
|
||||
proj.save(ctx.get(), currentProj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NEXTPNR_NAMESPACE_END
|
||||
|
@ -56,6 +56,7 @@ class BaseMainWindow : public QMainWindow
|
||||
|
||||
virtual void onDisableActions(){};
|
||||
virtual void onJsonLoaded(){};
|
||||
virtual void onProjectLoaded(){};
|
||||
virtual void onPackFinished(){};
|
||||
virtual void onBudgetFinished(){};
|
||||
virtual void onPlaceFinished(){};
|
||||
@ -66,8 +67,9 @@ class BaseMainWindow : public QMainWindow
|
||||
void closeTab(int index);
|
||||
|
||||
virtual void new_proj() = 0;
|
||||
virtual void open_proj() = 0;
|
||||
virtual bool save_proj() = 0;
|
||||
|
||||
void open_proj();
|
||||
void save_proj();
|
||||
|
||||
void open_json();
|
||||
void budget();
|
||||
@ -93,6 +95,7 @@ class BaseMainWindow : public QMainWindow
|
||||
TaskManager *task;
|
||||
bool timing_driven;
|
||||
std::string currentJson;
|
||||
std::string currentProj;
|
||||
|
||||
// main widgets
|
||||
QTabWidget *tabWidget;
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "jsonparse.h"
|
||||
#include "log.h"
|
||||
#include "pcf.h"
|
||||
#include "project.h"
|
||||
#include <fstream>
|
||||
|
||||
static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
|
||||
@ -166,23 +165,6 @@ void MainWindow::newContext(Context *ctx)
|
||||
setWindowTitle(title.c_str());
|
||||
}
|
||||
|
||||
void MainWindow::open_proj()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, QString("Open Project"), QString(), QString("*.proj"));
|
||||
if (!fileName.isEmpty()) {
|
||||
try {
|
||||
ProjectHandler proj;
|
||||
disableActions();
|
||||
ctx = proj.load(fileName.toStdString());
|
||||
Q_EMIT contextChanged(ctx.get());
|
||||
log_info("Loaded project %s...\n", fileName.toStdString().c_str());
|
||||
updateJsonLoaded();
|
||||
actionLoadPCF->setEnabled(false);
|
||||
} catch (log_execution_error_exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::open_pcf()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, QString("Open PCF"), QString(), QString("*.pcf"));
|
||||
@ -191,22 +173,6 @@ void MainWindow::open_pcf()
|
||||
}
|
||||
}
|
||||
|
||||
bool MainWindow::save_proj()
|
||||
{
|
||||
if (currentProj.empty()) {
|
||||
QString fileName = QFileDialog::getSaveFileName(this, QString("Save Project"), QString(), QString("*.proj"));
|
||||
if (fileName.isEmpty())
|
||||
return false;
|
||||
currentProj = fileName.toStdString();
|
||||
}
|
||||
if (!currentProj.empty()) {
|
||||
ProjectHandler proj;
|
||||
proj.save(ctx.get(), currentProj);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MainWindow::save_asc()
|
||||
{
|
||||
QString fileName = QFileDialog::getSaveFileName(this, QString("Save ASC"), QString(), QString("*.asc"));
|
||||
@ -227,5 +193,6 @@ void MainWindow::onDisableActions()
|
||||
|
||||
void MainWindow::onJsonLoaded() { actionLoadPCF->setEnabled(true); }
|
||||
void MainWindow::onRouteFinished() { actionSaveAsc->setEnabled(true); }
|
||||
void MainWindow::onProjectLoaded() { actionLoadPCF->setEnabled(false); }
|
||||
|
||||
NEXTPNR_NAMESPACE_END
|
||||
|
@ -41,11 +41,10 @@ class MainWindow : public BaseMainWindow
|
||||
void onDisableActions() override;
|
||||
void onJsonLoaded() override;
|
||||
void onRouteFinished() override;
|
||||
void onProjectLoaded() override;
|
||||
|
||||
protected Q_SLOTS:
|
||||
virtual void new_proj();
|
||||
virtual void open_proj();
|
||||
virtual bool save_proj();
|
||||
|
||||
void open_pcf();
|
||||
void save_asc();
|
||||
@ -56,7 +55,6 @@ class MainWindow : public BaseMainWindow
|
||||
QAction *actionLoadPCF;
|
||||
QAction *actionSaveAsc;
|
||||
|
||||
std::string currentProj;
|
||||
std::string currentPCF;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user