Added custom QApplication implementation
This commit is contained in:
parent
cf78f1b0e4
commit
e5bd4764b2
@ -115,7 +115,7 @@ foreach (family ${FAMILIES})
|
|||||||
include(${family}/family.cmake)
|
include(${family}/family.cmake)
|
||||||
foreach (target ${family_targets})
|
foreach (target ${family_targets})
|
||||||
# Include family-specific source files to all family targets and set defines appropriately
|
# Include family-specific source files to all family targets and set defines appropriately
|
||||||
target_include_directories(${target} PRIVATE ${family}/ generated/ gui/${family}/)
|
target_include_directories(${target} PRIVATE ${family}/ generated/ gui/${family}/ gui/)
|
||||||
target_compile_definitions(${target} PRIVATE NEXTPNR_NAMESPACE=nextpnr_${family} ARCH_${ufamily} ARCHNAME=${family} QT_NO_KEYWORDS)
|
target_compile_definitions(${target} PRIVATE NEXTPNR_NAMESPACE=nextpnr_${family} ARCH_${ufamily} ARCHNAME=${family} QT_NO_KEYWORDS)
|
||||||
target_link_libraries(${target} LINK_PUBLIC gui_${family} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} ${GUI_LIBRARY_FILES_${ufamily}})
|
target_link_libraries(${target} LINK_PUBLIC gui_${family} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} ${GUI_LIBRARY_FILES_${ufamily}})
|
||||||
endforeach (target)
|
endforeach (target)
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <boost/filesystem/convenience.hpp>
|
#include <boost/filesystem/convenience.hpp>
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
|
#include "application.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "nextpnr.h"
|
#include "nextpnr.h"
|
||||||
@ -107,7 +108,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (vm.count("gui")) {
|
if (vm.count("gui")) {
|
||||||
QApplication a(argc, argv);
|
Application a(argc, argv);
|
||||||
MainWindow w(&ctx);
|
MainWindow w(&ctx);
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
|
47
gui/application.cc
Normal file
47
gui/application.cc
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* nextpnr -- Next Generation Place and Route
|
||||||
|
*
|
||||||
|
* Copyright (C) 2018 Miodrag Milanovic <miodrag@symbioticeda.com>
|
||||||
|
* Copyright (C) 2018 Serge Bazanski <q3k@symbioticeda.com>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "application.h"
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QSurfaceFormat>
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
||||||
|
{
|
||||||
|
QSurfaceFormat fmt;
|
||||||
|
fmt.setSamples(10);
|
||||||
|
QSurfaceFormat::setDefaultFormat(fmt);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Application::notify(QObject *receiver, QEvent *event)
|
||||||
|
{
|
||||||
|
bool retVal = true;
|
||||||
|
try {
|
||||||
|
retVal = QApplication::notify(receiver, event);
|
||||||
|
} catch (...) {
|
||||||
|
QMessageBox::critical(0, "Error", "Fatal error !!!");
|
||||||
|
}
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
NEXTPNR_NAMESPACE_END
|
38
gui/application.h
Normal file
38
gui/application.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* nextpnr -- Next Generation Place and Route
|
||||||
|
*
|
||||||
|
* Copyright (C) 2018 Miodrag Milanovic <miodrag@symbioticeda.com>
|
||||||
|
* Copyright (C) 2018 Serge Bazanski <q3k@symbioticeda.com>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and/or distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef APPLICATION_H
|
||||||
|
#define APPLICATION_H
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
#include "nextpnr.h"
|
||||||
|
|
||||||
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
class Application : public QApplication
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Application(int &argc, char **argv);
|
||||||
|
bool notify(QObject *receiver, QEvent *event);
|
||||||
|
};
|
||||||
|
|
||||||
|
NEXTPNR_NAMESPACE_END
|
||||||
|
|
||||||
|
#endif // APPLICATION_H
|
@ -45,10 +45,13 @@ MainWindow::MainWindow(Context *_ctx, QWidget *parent)
|
|||||||
task = new TaskManager(_ctx);
|
task = new TaskManager(_ctx);
|
||||||
connect(task, SIGNAL(log(std::string)), this, SLOT(writeInfo(std::string)));
|
connect(task, SIGNAL(log(std::string)), this, SLOT(writeInfo(std::string)));
|
||||||
|
|
||||||
connect(task, SIGNAL(loadfile_finished(bool)), this, SLOT(loadfile_finished(bool)));
|
connect(task, SIGNAL(loadfile_finished(bool)), this,
|
||||||
|
SLOT(loadfile_finished(bool)));
|
||||||
connect(task, SIGNAL(pack_finished(bool)), this, SLOT(pack_finished(bool)));
|
connect(task, SIGNAL(pack_finished(bool)), this, SLOT(pack_finished(bool)));
|
||||||
connect(task, SIGNAL(place_finished(bool)), this, SLOT(place_finished(bool)));
|
connect(task, SIGNAL(place_finished(bool)), this,
|
||||||
connect(task, SIGNAL(route_finished(bool)), this, SLOT(route_finished(bool)));
|
SLOT(place_finished(bool)));
|
||||||
|
connect(task, SIGNAL(route_finished(bool)), this,
|
||||||
|
SLOT(route_finished(bool)));
|
||||||
|
|
||||||
connect(task, SIGNAL(taskCanceled()), this, SLOT(taskCanceled()));
|
connect(task, SIGNAL(taskCanceled()), this, SLOT(taskCanceled()));
|
||||||
connect(task, SIGNAL(taskStarted()), this, SLOT(taskStarted()));
|
connect(task, SIGNAL(taskStarted()), this, SLOT(taskStarted()));
|
||||||
@ -146,7 +149,7 @@ void MainWindow::open()
|
|||||||
|
|
||||||
bool MainWindow::save() { return false; }
|
bool MainWindow::save() { return false; }
|
||||||
|
|
||||||
void MainWindow::disableActions()
|
void MainWindow::disableActions()
|
||||||
{
|
{
|
||||||
actionPack->setEnabled(false);
|
actionPack->setEnabled(false);
|
||||||
actionPlace->setEnabled(false);
|
actionPlace->setEnabled(false);
|
||||||
@ -163,8 +166,7 @@ void MainWindow::loadfile_finished(bool status)
|
|||||||
if (status) {
|
if (status) {
|
||||||
log("Loading design successful.\n");
|
log("Loading design successful.\n");
|
||||||
actionPack->setEnabled(true);
|
actionPack->setEnabled(true);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
log("Loading design failed.\n");
|
log("Loading design failed.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,8 +176,7 @@ void MainWindow::pack_finished(bool status)
|
|||||||
if (status) {
|
if (status) {
|
||||||
log("Packing design successful.\n");
|
log("Packing design successful.\n");
|
||||||
actionPlace->setEnabled(true);
|
actionPlace->setEnabled(true);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
log("Packing design failed.\n");
|
log("Packing design failed.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,8 +186,7 @@ void MainWindow::place_finished(bool status)
|
|||||||
if (status) {
|
if (status) {
|
||||||
log("Placing design successful.\n");
|
log("Placing design successful.\n");
|
||||||
actionRoute->setEnabled(true);
|
actionRoute->setEnabled(true);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
log("Placing design failed.\n");
|
log("Placing design failed.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,7 @@ Worker::Worker(Context *_ctx, TaskManager *parent) : ctx(_ctx)
|
|||||||
parent->clearTerminate();
|
parent->clearTerminate();
|
||||||
throw WorkerInterruptionRequested();
|
throw WorkerInterruptionRequested();
|
||||||
}
|
}
|
||||||
if (parent->isPaused())
|
if (parent->isPaused()) {
|
||||||
{
|
|
||||||
Q_EMIT taskPaused();
|
Q_EMIT taskPaused();
|
||||||
}
|
}
|
||||||
while (parent->isPaused()) {
|
while (parent->isPaused()) {
|
||||||
@ -102,7 +101,6 @@ void Worker::route()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TaskManager::TaskManager(Context *ctx) : toTerminate(false), toPause(false)
|
TaskManager::TaskManager(Context *ctx) : toTerminate(false), toPause(false)
|
||||||
{
|
{
|
||||||
Worker *worker = new Worker(ctx, this);
|
Worker *worker = new Worker(ctx, this);
|
||||||
@ -116,10 +114,13 @@ TaskManager::TaskManager(Context *ctx) : toTerminate(false), toPause(false)
|
|||||||
connect(this, &TaskManager::route, worker, &Worker::route);
|
connect(this, &TaskManager::route, worker, &Worker::route);
|
||||||
|
|
||||||
connect(worker, &Worker::log, this, &TaskManager::info);
|
connect(worker, &Worker::log, this, &TaskManager::info);
|
||||||
connect(worker, &Worker::loadfile_finished, this, &TaskManager::loadfile_finished);
|
connect(worker, &Worker::loadfile_finished, this,
|
||||||
|
&TaskManager::loadfile_finished);
|
||||||
connect(worker, &Worker::pack_finished, this, &TaskManager::pack_finished);
|
connect(worker, &Worker::pack_finished, this, &TaskManager::pack_finished);
|
||||||
connect(worker, &Worker::place_finished, this, &TaskManager::place_finished);
|
connect(worker, &Worker::place_finished, this,
|
||||||
connect(worker, &Worker::route_finished, this, &TaskManager::route_finished);
|
&TaskManager::place_finished);
|
||||||
|
connect(worker, &Worker::route_finished, this,
|
||||||
|
&TaskManager::route_finished);
|
||||||
|
|
||||||
connect(worker, &Worker::taskCanceled, this, &TaskManager::taskCanceled);
|
connect(worker, &Worker::taskCanceled, this, &TaskManager::taskCanceled);
|
||||||
connect(worker, &Worker::taskStarted, this, &TaskManager::taskStarted);
|
connect(worker, &Worker::taskStarted, this, &TaskManager::taskStarted);
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include "application.h"
|
||||||
#include "bitstream.h"
|
#include "bitstream.h"
|
||||||
#include "design_utils.h"
|
#include "design_utils.h"
|
||||||
#include "jsonparse.h"
|
#include "jsonparse.h"
|
||||||
@ -329,7 +330,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (vm.count("gui")) {
|
if (vm.count("gui")) {
|
||||||
QApplication a(argc, argv);
|
Application a(argc, argv);
|
||||||
MainWindow w(&ctx);
|
MainWindow w(&ctx);
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user