Preps for more UI functionality
This commit is contained in:
parent
e770f16a22
commit
8344a21282
@ -90,27 +90,35 @@ void BaseMainWindow::writeInfo(std::string text) { info->info(text); }
|
||||
|
||||
void BaseMainWindow::createMenusAndBars()
|
||||
{
|
||||
QAction *actionNew = new QAction("New", this);
|
||||
QIcon iconNew;
|
||||
iconNew.addFile(QStringLiteral(":/icons/resources/new.png"));
|
||||
actionNew->setIcon(iconNew);
|
||||
actionNew->setShortcuts(QKeySequence::New);
|
||||
actionNew->setStatusTip("New project file");
|
||||
connect(actionNew, SIGNAL(triggered()), this, SLOT(new_proj()));
|
||||
|
||||
QAction *actionOpen = new QAction("Open", this);
|
||||
QIcon icon1;
|
||||
icon1.addFile(QStringLiteral(":/icons/resources/open.png"));
|
||||
actionOpen->setIcon(icon1);
|
||||
QIcon iconOpen;
|
||||
iconOpen.addFile(QStringLiteral(":/icons/resources/open.png"));
|
||||
actionOpen->setIcon(iconOpen);
|
||||
actionOpen->setShortcuts(QKeySequence::Open);
|
||||
actionOpen->setStatusTip("Open an existing JSON file");
|
||||
connect(actionOpen, SIGNAL(triggered()), this, SLOT(open()));
|
||||
actionOpen->setStatusTip("Open an existing project file");
|
||||
connect(actionOpen, SIGNAL(triggered()), this, SLOT(open_proj()));
|
||||
|
||||
QAction *actionSave = new QAction("Save", this);
|
||||
QIcon icon2;
|
||||
icon2.addFile(QStringLiteral(":/icons/resources/save.png"));
|
||||
actionSave->setIcon(icon2);
|
||||
QIcon iconSave;
|
||||
iconSave.addFile(QStringLiteral(":/icons/resources/save.png"));
|
||||
actionSave->setIcon(iconSave);
|
||||
actionSave->setShortcuts(QKeySequence::Save);
|
||||
actionSave->setStatusTip("Save the ASC to disk");
|
||||
connect(actionSave, SIGNAL(triggered()), this, SLOT(save()));
|
||||
actionSave->setStatusTip("Save existing project to disk");
|
||||
connect(actionSave, SIGNAL(triggered()), this, SLOT(save_proj()));
|
||||
actionSave->setEnabled(false);
|
||||
|
||||
QAction *actionExit = new QAction("Exit", this);
|
||||
QIcon icon3;
|
||||
icon3.addFile(QStringLiteral(":/icons/resources/exit.png"));
|
||||
actionExit->setIcon(icon3);
|
||||
QIcon iconExit;
|
||||
iconExit.addFile(QStringLiteral(":/icons/resources/exit.png"));
|
||||
actionExit->setIcon(iconExit);
|
||||
actionExit->setShortcuts(QKeySequence::Quit);
|
||||
actionExit->setStatusTip("Exit the application");
|
||||
connect(actionExit, SIGNAL(triggered()), this, SLOT(close()));
|
||||
@ -131,12 +139,14 @@ void BaseMainWindow::createMenusAndBars()
|
||||
statusBar = new QStatusBar();
|
||||
setStatusBar(statusBar);
|
||||
|
||||
menu_File->addAction(actionNew);
|
||||
menu_File->addAction(actionOpen);
|
||||
menu_File->addAction(actionSave);
|
||||
menu_File->addSeparator();
|
||||
menu_File->addAction(actionExit);
|
||||
menu_Help->addAction(actionAbout);
|
||||
|
||||
mainToolBar->addAction(actionNew);
|
||||
mainToolBar->addAction(actionOpen);
|
||||
mainToolBar->addAction(actionSave);
|
||||
}
|
||||
|
@ -49,8 +49,9 @@ class BaseMainWindow : public QMainWindow
|
||||
protected Q_SLOTS:
|
||||
void writeInfo(std::string text);
|
||||
|
||||
virtual void open() = 0;
|
||||
virtual bool save() = 0;
|
||||
virtual void new_proj() = 0;
|
||||
virtual void open_proj() = 0;
|
||||
virtual bool save_proj() = 0;
|
||||
|
||||
protected:
|
||||
Context *ctx;
|
||||
|
@ -41,8 +41,10 @@ void MainWindow::createMenu()
|
||||
menuBar->addAction(menu_Custom->menuAction());
|
||||
}
|
||||
|
||||
void MainWindow::open() {}
|
||||
void MainWindow::new_proj() {}
|
||||
|
||||
bool MainWindow::save() { return false; }
|
||||
void MainWindow::open_proj() {}
|
||||
|
||||
bool MainWindow::save_proj() { return false; }
|
||||
|
||||
NEXTPNR_NAMESPACE_END
|
||||
|
@ -36,8 +36,9 @@ class MainWindow : public BaseMainWindow
|
||||
void createMenu();
|
||||
|
||||
protected Q_SLOTS:
|
||||
virtual void open();
|
||||
virtual bool save();
|
||||
virtual void new_proj();
|
||||
virtual void open_proj();
|
||||
virtual bool save_proj();
|
||||
};
|
||||
|
||||
NEXTPNR_NAMESPACE_END
|
||||
|
@ -68,6 +68,14 @@ void MainWindow::createMenu()
|
||||
QMenu *menu_Design = new QMenu("&Design", menuBar);
|
||||
menuBar->addAction(menu_Design->menuAction());
|
||||
|
||||
actionLoadJSON = new QAction("Open JSON", this);
|
||||
QIcon iconLoadJSON;
|
||||
iconLoadJSON.addFile(QStringLiteral(":/icons/resources/open_json.png"));
|
||||
actionLoadJSON->setIcon(iconLoadJSON);
|
||||
actionLoadJSON->setStatusTip("Open an existing JSON file");
|
||||
connect(actionLoadJSON, SIGNAL(triggered()), this, SLOT(open_json()));
|
||||
actionLoadJSON->setEnabled(false);
|
||||
|
||||
actionLoadPCF = new QAction("Open PCF", this);
|
||||
QIcon iconLoadPCF;
|
||||
iconLoadPCF.addFile(QStringLiteral(":/icons/resources/open_pcf.png"));
|
||||
@ -119,6 +127,7 @@ void MainWindow::createMenu()
|
||||
QToolBar *taskFPGABar = new QToolBar();
|
||||
addToolBar(Qt::TopToolBarArea, taskFPGABar);
|
||||
|
||||
taskFPGABar->addAction(actionLoadJSON);
|
||||
taskFPGABar->addAction(actionLoadPCF);
|
||||
taskFPGABar->addAction(actionPack);
|
||||
taskFPGABar->addAction(actionAssignBudget);
|
||||
@ -126,6 +135,7 @@ void MainWindow::createMenu()
|
||||
taskFPGABar->addAction(actionRoute);
|
||||
taskFPGABar->addAction(actionSaveAsc);
|
||||
|
||||
menu_Design->addAction(actionLoadJSON);
|
||||
menu_Design->addAction(actionLoadPCF);
|
||||
menu_Design->addAction(actionPack);
|
||||
menu_Design->addAction(actionAssignBudget);
|
||||
@ -165,9 +175,26 @@ void MainWindow::createMenu()
|
||||
taskToolBar->addAction(actionStop);
|
||||
}
|
||||
|
||||
void MainWindow::open()
|
||||
void MainWindow::new_proj()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(), QString("*.json"));
|
||||
disableActions();
|
||||
actionLoadJSON->setEnabled(true);
|
||||
}
|
||||
|
||||
void MainWindow::open_proj()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, QString("Open Project"), QString(), QString("*.npnr"));
|
||||
if (!fileName.isEmpty()) {
|
||||
tabWidget->setCurrentWidget(info);
|
||||
|
||||
std::string fn = fileName.toStdString();
|
||||
disableActions();
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::open_json()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, QString("Open JSON"), QString(), QString("*.json"));
|
||||
if (!fileName.isEmpty()) {
|
||||
tabWidget->setCurrentWidget(info);
|
||||
|
||||
@ -190,7 +217,7 @@ void MainWindow::open_pcf()
|
||||
}
|
||||
}
|
||||
|
||||
bool MainWindow::save() { return false; }
|
||||
bool MainWindow::save_proj() { return false; }
|
||||
|
||||
void MainWindow::save_asc()
|
||||
{
|
||||
@ -204,6 +231,7 @@ void MainWindow::save_asc()
|
||||
|
||||
void MainWindow::disableActions()
|
||||
{
|
||||
actionLoadJSON->setEnabled(false);
|
||||
actionLoadPCF->setEnabled(false);
|
||||
actionPack->setEnabled(false);
|
||||
actionAssignBudget->setEnabled(false);
|
||||
|
@ -37,9 +37,11 @@ class MainWindow : public BaseMainWindow
|
||||
void createMenu();
|
||||
|
||||
protected Q_SLOTS:
|
||||
virtual void open();
|
||||
virtual bool save();
|
||||
virtual void new_proj();
|
||||
virtual void open_proj();
|
||||
virtual bool save_proj();
|
||||
|
||||
void open_json();
|
||||
void open_pcf();
|
||||
void budget();
|
||||
void place();
|
||||
@ -61,6 +63,7 @@ class MainWindow : public BaseMainWindow
|
||||
void disableActions();
|
||||
|
||||
TaskManager *task;
|
||||
QAction *actionLoadJSON;
|
||||
QAction *actionLoadPCF;
|
||||
QAction *actionPack;
|
||||
QAction *actionAssignBudget;
|
||||
|
@ -9,5 +9,6 @@
|
||||
<file>resources/time_add.png</file>
|
||||
<file>resources/open_pcf.png</file>
|
||||
<file>resources/save_asc.png</file>
|
||||
<file>resources/open_json.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
BIN
gui/ice40/resources/open_json.png
Normal file
BIN
gui/ice40/resources/open_json.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
Loading…
Reference in New Issue
Block a user