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()
|
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);
|
QAction *actionOpen = new QAction("Open", this);
|
||||||
QIcon icon1;
|
QIcon iconOpen;
|
||||||
icon1.addFile(QStringLiteral(":/icons/resources/open.png"));
|
iconOpen.addFile(QStringLiteral(":/icons/resources/open.png"));
|
||||||
actionOpen->setIcon(icon1);
|
actionOpen->setIcon(iconOpen);
|
||||||
actionOpen->setShortcuts(QKeySequence::Open);
|
actionOpen->setShortcuts(QKeySequence::Open);
|
||||||
actionOpen->setStatusTip("Open an existing JSON file");
|
actionOpen->setStatusTip("Open an existing project file");
|
||||||
connect(actionOpen, SIGNAL(triggered()), this, SLOT(open()));
|
connect(actionOpen, SIGNAL(triggered()), this, SLOT(open_proj()));
|
||||||
|
|
||||||
QAction *actionSave = new QAction("Save", this);
|
QAction *actionSave = new QAction("Save", this);
|
||||||
QIcon icon2;
|
QIcon iconSave;
|
||||||
icon2.addFile(QStringLiteral(":/icons/resources/save.png"));
|
iconSave.addFile(QStringLiteral(":/icons/resources/save.png"));
|
||||||
actionSave->setIcon(icon2);
|
actionSave->setIcon(iconSave);
|
||||||
actionSave->setShortcuts(QKeySequence::Save);
|
actionSave->setShortcuts(QKeySequence::Save);
|
||||||
actionSave->setStatusTip("Save the ASC to disk");
|
actionSave->setStatusTip("Save existing project to disk");
|
||||||
connect(actionSave, SIGNAL(triggered()), this, SLOT(save()));
|
connect(actionSave, SIGNAL(triggered()), this, SLOT(save_proj()));
|
||||||
actionSave->setEnabled(false);
|
actionSave->setEnabled(false);
|
||||||
|
|
||||||
QAction *actionExit = new QAction("Exit", this);
|
QAction *actionExit = new QAction("Exit", this);
|
||||||
QIcon icon3;
|
QIcon iconExit;
|
||||||
icon3.addFile(QStringLiteral(":/icons/resources/exit.png"));
|
iconExit.addFile(QStringLiteral(":/icons/resources/exit.png"));
|
||||||
actionExit->setIcon(icon3);
|
actionExit->setIcon(iconExit);
|
||||||
actionExit->setShortcuts(QKeySequence::Quit);
|
actionExit->setShortcuts(QKeySequence::Quit);
|
||||||
actionExit->setStatusTip("Exit the application");
|
actionExit->setStatusTip("Exit the application");
|
||||||
connect(actionExit, SIGNAL(triggered()), this, SLOT(close()));
|
connect(actionExit, SIGNAL(triggered()), this, SLOT(close()));
|
||||||
@ -131,12 +139,14 @@ void BaseMainWindow::createMenusAndBars()
|
|||||||
statusBar = new QStatusBar();
|
statusBar = new QStatusBar();
|
||||||
setStatusBar(statusBar);
|
setStatusBar(statusBar);
|
||||||
|
|
||||||
|
menu_File->addAction(actionNew);
|
||||||
menu_File->addAction(actionOpen);
|
menu_File->addAction(actionOpen);
|
||||||
menu_File->addAction(actionSave);
|
menu_File->addAction(actionSave);
|
||||||
menu_File->addSeparator();
|
menu_File->addSeparator();
|
||||||
menu_File->addAction(actionExit);
|
menu_File->addAction(actionExit);
|
||||||
menu_Help->addAction(actionAbout);
|
menu_Help->addAction(actionAbout);
|
||||||
|
|
||||||
|
mainToolBar->addAction(actionNew);
|
||||||
mainToolBar->addAction(actionOpen);
|
mainToolBar->addAction(actionOpen);
|
||||||
mainToolBar->addAction(actionSave);
|
mainToolBar->addAction(actionSave);
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,9 @@ class BaseMainWindow : public QMainWindow
|
|||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
void writeInfo(std::string text);
|
void writeInfo(std::string text);
|
||||||
|
|
||||||
virtual void open() = 0;
|
virtual void new_proj() = 0;
|
||||||
virtual bool save() = 0;
|
virtual void open_proj() = 0;
|
||||||
|
virtual bool save_proj() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Context *ctx;
|
Context *ctx;
|
||||||
|
@ -41,8 +41,10 @@ void MainWindow::createMenu()
|
|||||||
menuBar->addAction(menu_Custom->menuAction());
|
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
|
NEXTPNR_NAMESPACE_END
|
||||||
|
@ -36,8 +36,9 @@ class MainWindow : public BaseMainWindow
|
|||||||
void createMenu();
|
void createMenu();
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
virtual void open();
|
virtual void new_proj();
|
||||||
virtual bool save();
|
virtual void open_proj();
|
||||||
|
virtual bool save_proj();
|
||||||
};
|
};
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
@ -68,6 +68,14 @@ void MainWindow::createMenu()
|
|||||||
QMenu *menu_Design = new QMenu("&Design", menuBar);
|
QMenu *menu_Design = new QMenu("&Design", menuBar);
|
||||||
menuBar->addAction(menu_Design->menuAction());
|
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);
|
actionLoadPCF = new QAction("Open PCF", this);
|
||||||
QIcon iconLoadPCF;
|
QIcon iconLoadPCF;
|
||||||
iconLoadPCF.addFile(QStringLiteral(":/icons/resources/open_pcf.png"));
|
iconLoadPCF.addFile(QStringLiteral(":/icons/resources/open_pcf.png"));
|
||||||
@ -119,6 +127,7 @@ void MainWindow::createMenu()
|
|||||||
QToolBar *taskFPGABar = new QToolBar();
|
QToolBar *taskFPGABar = new QToolBar();
|
||||||
addToolBar(Qt::TopToolBarArea, taskFPGABar);
|
addToolBar(Qt::TopToolBarArea, taskFPGABar);
|
||||||
|
|
||||||
|
taskFPGABar->addAction(actionLoadJSON);
|
||||||
taskFPGABar->addAction(actionLoadPCF);
|
taskFPGABar->addAction(actionLoadPCF);
|
||||||
taskFPGABar->addAction(actionPack);
|
taskFPGABar->addAction(actionPack);
|
||||||
taskFPGABar->addAction(actionAssignBudget);
|
taskFPGABar->addAction(actionAssignBudget);
|
||||||
@ -126,6 +135,7 @@ void MainWindow::createMenu()
|
|||||||
taskFPGABar->addAction(actionRoute);
|
taskFPGABar->addAction(actionRoute);
|
||||||
taskFPGABar->addAction(actionSaveAsc);
|
taskFPGABar->addAction(actionSaveAsc);
|
||||||
|
|
||||||
|
menu_Design->addAction(actionLoadJSON);
|
||||||
menu_Design->addAction(actionLoadPCF);
|
menu_Design->addAction(actionLoadPCF);
|
||||||
menu_Design->addAction(actionPack);
|
menu_Design->addAction(actionPack);
|
||||||
menu_Design->addAction(actionAssignBudget);
|
menu_Design->addAction(actionAssignBudget);
|
||||||
@ -165,9 +175,26 @@ void MainWindow::createMenu()
|
|||||||
taskToolBar->addAction(actionStop);
|
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()) {
|
if (!fileName.isEmpty()) {
|
||||||
tabWidget->setCurrentWidget(info);
|
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()
|
void MainWindow::save_asc()
|
||||||
{
|
{
|
||||||
@ -204,6 +231,7 @@ void MainWindow::save_asc()
|
|||||||
|
|
||||||
void MainWindow::disableActions()
|
void MainWindow::disableActions()
|
||||||
{
|
{
|
||||||
|
actionLoadJSON->setEnabled(false);
|
||||||
actionLoadPCF->setEnabled(false);
|
actionLoadPCF->setEnabled(false);
|
||||||
actionPack->setEnabled(false);
|
actionPack->setEnabled(false);
|
||||||
actionAssignBudget->setEnabled(false);
|
actionAssignBudget->setEnabled(false);
|
||||||
|
@ -37,9 +37,11 @@ class MainWindow : public BaseMainWindow
|
|||||||
void createMenu();
|
void createMenu();
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
virtual void open();
|
virtual void new_proj();
|
||||||
virtual bool save();
|
virtual void open_proj();
|
||||||
|
virtual bool save_proj();
|
||||||
|
|
||||||
|
void open_json();
|
||||||
void open_pcf();
|
void open_pcf();
|
||||||
void budget();
|
void budget();
|
||||||
void place();
|
void place();
|
||||||
@ -61,6 +63,7 @@ class MainWindow : public BaseMainWindow
|
|||||||
void disableActions();
|
void disableActions();
|
||||||
|
|
||||||
TaskManager *task;
|
TaskManager *task;
|
||||||
|
QAction *actionLoadJSON;
|
||||||
QAction *actionLoadPCF;
|
QAction *actionLoadPCF;
|
||||||
QAction *actionPack;
|
QAction *actionPack;
|
||||||
QAction *actionAssignBudget;
|
QAction *actionAssignBudget;
|
||||||
|
@ -9,5 +9,6 @@
|
|||||||
<file>resources/time_add.png</file>
|
<file>resources/time_add.png</file>
|
||||||
<file>resources/open_pcf.png</file>
|
<file>resources/open_pcf.png</file>
|
||||||
<file>resources/save_asc.png</file>
|
<file>resources/save_asc.png</file>
|
||||||
|
<file>resources/open_json.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</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