Moved to new signal slot syntax

This commit is contained in:
Miodrag Milanovic 2018-08-03 10:53:38 +02:00
parent 23a7d96f4c
commit 8abf38f37f
5 changed files with 47 additions and 50 deletions

View File

@ -86,38 +86,36 @@ BaseMainWindow::BaseMainWindow(std::unique_ptr<Context> context, QWidget *parent
splitter_v->addWidget(tabWidget); splitter_v->addWidget(tabWidget);
// Connect Worker // Connect Worker
connect(task, SIGNAL(log(std::string)), this, SLOT(writeInfo(std::string))); connect(task, &TaskManager::log, this, &BaseMainWindow::writeInfo);
connect(task, SIGNAL(pack_finished(bool)), this, SLOT(pack_finished(bool))); connect(task, &TaskManager::pack_finished, this, &BaseMainWindow::pack_finished);
connect(task, SIGNAL(budget_finish(bool)), this, SLOT(budget_finish(bool))); connect(task, &TaskManager::budget_finish, this, &BaseMainWindow::budget_finish);
connect(task, SIGNAL(place_finished(bool)), this, SLOT(place_finished(bool))); connect(task, &TaskManager::place_finished, this, &BaseMainWindow::place_finished);
connect(task, SIGNAL(route_finished(bool)), this, SLOT(route_finished(bool))); connect(task, &TaskManager::route_finished, this, &BaseMainWindow::route_finished);
connect(task, SIGNAL(taskCanceled()), this, SLOT(taskCanceled())); connect(task, &TaskManager::taskCanceled, this, &BaseMainWindow::taskCanceled);
connect(task, SIGNAL(taskStarted()), this, SLOT(taskStarted())); connect(task, &TaskManager::taskStarted, this, &BaseMainWindow::taskStarted);
connect(task, SIGNAL(taskPaused()), this, SLOT(taskPaused())); connect(task, &TaskManager::taskPaused, this, &BaseMainWindow::taskPaused);
// Events for context change // Events for context change
connect(this, SIGNAL(contextChanged(Context *)), task, SIGNAL(contextChanged(Context *))); connect(this, &BaseMainWindow::contextChanged, task, &TaskManager::contextChanged);
connect(this, SIGNAL(contextChanged(Context *)), console, SLOT(newContext(Context *))); connect(this, &BaseMainWindow::contextChanged, console, &PythonTab::newContext);
connect(this, SIGNAL(contextChanged(Context *)), fpgaView, SLOT(newContext(Context *))); connect(this, &BaseMainWindow::contextChanged, fpgaView, &FPGAViewWidget::newContext);
connect(this, SIGNAL(contextChanged(Context *)), designview, SLOT(newContext(Context *))); connect(this, &BaseMainWindow::contextChanged, designview, &DesignWidget::newContext);
// Catch close tab events // Catch close tab events
connect(centralTabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); connect(centralTabWidget, &QTabWidget::tabCloseRequested, this, &BaseMainWindow::closeTab);
// Propagate events from design view to device view // Propagate events from design view to device view
connect(designview, SIGNAL(selected(std::vector<DecalXY>, bool)), fpgaView, connect(designview, &DesignWidget::selected, fpgaView, &FPGAViewWidget::onSelectedArchItem);
SLOT(onSelectedArchItem(std::vector<DecalXY>, bool))); connect(designview, &DesignWidget::zoomSelected, fpgaView, &FPGAViewWidget::zoomSelected);
connect(designview, SIGNAL(zoomSelected()), fpgaView, SLOT(zoomSelected())); connect(designview, &DesignWidget::highlight, fpgaView, &FPGAViewWidget::onHighlightGroupChanged);
connect(designview, SIGNAL(highlight(std::vector<DecalXY>, int)), fpgaView,
SLOT(onHighlightGroupChanged(std::vector<DecalXY>, int)));
// Click event on device view // Click event on device view
connect(fpgaView, SIGNAL(clickedBel(BelId, bool)), designview, SLOT(onClickedBel(BelId, bool))); connect(fpgaView, &FPGAViewWidget::clickedBel, designview, &DesignWidget::onClickedBel);
connect(fpgaView, SIGNAL(clickedWire(WireId, bool)), designview, SLOT(onClickedWire(WireId, bool))); connect(fpgaView, &FPGAViewWidget::clickedWire, designview, &DesignWidget::onClickedWire);
connect(fpgaView, SIGNAL(clickedPip(PipId, bool)), designview, SLOT(onClickedPip(PipId, bool))); connect(fpgaView, &FPGAViewWidget::clickedPip, designview, &DesignWidget::onClickedPip);
// Update tree event // Update tree event
connect(this, SIGNAL(updateTreeView()), designview, SLOT(updateTree())); connect(this, &BaseMainWindow::updateTreeView, designview, &DesignWidget::updateTree);
createMenusAndBars(); createMenusAndBars();
} }
@ -135,26 +133,26 @@ void BaseMainWindow::createMenusAndBars()
actionNew->setIcon(QIcon(":/icons/resources/new.png")); actionNew->setIcon(QIcon(":/icons/resources/new.png"));
actionNew->setShortcuts(QKeySequence::New); actionNew->setShortcuts(QKeySequence::New);
actionNew->setStatusTip("New project file"); actionNew->setStatusTip("New project file");
connect(actionNew, SIGNAL(triggered()), this, SLOT(new_proj())); connect(actionNew, &QAction::triggered, this, &BaseMainWindow::new_proj);
actionOpen = new QAction("Open", this); actionOpen = new QAction("Open", this);
actionOpen->setIcon(QIcon(":/icons/resources/open.png")); actionOpen->setIcon(QIcon(":/icons/resources/open.png"));
actionOpen->setShortcuts(QKeySequence::Open); actionOpen->setShortcuts(QKeySequence::Open);
actionOpen->setStatusTip("Open an existing project file"); actionOpen->setStatusTip("Open an existing project file");
connect(actionOpen, SIGNAL(triggered()), this, SLOT(open_proj())); connect(actionOpen, &QAction::triggered, this, &BaseMainWindow::open_proj);
actionSave = new QAction("Save", this); actionSave = new QAction("Save", this);
actionSave->setIcon(QIcon(":/icons/resources/save.png")); actionSave->setIcon(QIcon(":/icons/resources/save.png"));
actionSave->setShortcuts(QKeySequence::Save); actionSave->setShortcuts(QKeySequence::Save);
actionSave->setStatusTip("Save existing project to disk"); actionSave->setStatusTip("Save existing project to disk");
actionSave->setEnabled(false); actionSave->setEnabled(false);
connect(actionSave, SIGNAL(triggered()), this, SLOT(save_proj())); connect(actionSave, &QAction::triggered, this, &BaseMainWindow::save_proj);
QAction *actionExit = new QAction("Exit", this); QAction *actionExit = new QAction("Exit", this);
actionExit->setIcon(QIcon(":/icons/resources/exit.png")); actionExit->setIcon(QIcon(":/icons/resources/exit.png"));
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, &QAction::triggered, this, &BaseMainWindow::close);
// Help menu actions // Help menu actions
QAction *actionAbout = new QAction("About", this); QAction *actionAbout = new QAction("About", this);
@ -164,67 +162,67 @@ void BaseMainWindow::createMenusAndBars()
actionLoadJSON->setIcon(QIcon(":/icons/resources/open_json.png")); actionLoadJSON->setIcon(QIcon(":/icons/resources/open_json.png"));
actionLoadJSON->setStatusTip("Open an existing JSON file"); actionLoadJSON->setStatusTip("Open an existing JSON file");
actionLoadJSON->setEnabled(true); actionLoadJSON->setEnabled(true);
connect(actionLoadJSON, SIGNAL(triggered()), this, SLOT(open_json())); connect(actionLoadJSON, &QAction::triggered, this, &BaseMainWindow::open_json);
actionPack = new QAction("Pack", this); actionPack = new QAction("Pack", this);
actionPack->setIcon(QIcon(":/icons/resources/pack.png")); actionPack->setIcon(QIcon(":/icons/resources/pack.png"));
actionPack->setStatusTip("Pack current design"); actionPack->setStatusTip("Pack current design");
actionPack->setEnabled(false); actionPack->setEnabled(false);
connect(actionPack, SIGNAL(triggered()), task, SIGNAL(pack())); connect(actionPack, &QAction::triggered, task, &TaskManager::pack);
actionAssignBudget = new QAction("Assign Budget", this); actionAssignBudget = new QAction("Assign Budget", this);
actionAssignBudget->setIcon(QIcon(":/icons/resources/time_add.png")); actionAssignBudget->setIcon(QIcon(":/icons/resources/time_add.png"));
actionAssignBudget->setStatusTip("Assign time budget for current design"); actionAssignBudget->setStatusTip("Assign time budget for current design");
actionAssignBudget->setEnabled(false); actionAssignBudget->setEnabled(false);
connect(actionAssignBudget, SIGNAL(triggered()), this, SLOT(budget())); connect(actionAssignBudget, &QAction::triggered, this, &BaseMainWindow::budget);
actionPlace = new QAction("Place", this); actionPlace = new QAction("Place", this);
actionPlace->setIcon(QIcon(":/icons/resources/place.png")); actionPlace->setIcon(QIcon(":/icons/resources/place.png"));
actionPlace->setStatusTip("Place current design"); actionPlace->setStatusTip("Place current design");
actionPlace->setEnabled(false); actionPlace->setEnabled(false);
connect(actionPlace, SIGNAL(triggered()), this, SLOT(place())); connect(actionPlace, &QAction::triggered, this, &BaseMainWindow::place);
actionRoute = new QAction("Route", this); actionRoute = new QAction("Route", this);
actionRoute->setIcon(QIcon(":/icons/resources/route.png")); actionRoute->setIcon(QIcon(":/icons/resources/route.png"));
actionRoute->setStatusTip("Route current design"); actionRoute->setStatusTip("Route current design");
actionRoute->setEnabled(false); actionRoute->setEnabled(false);
connect(actionRoute, SIGNAL(triggered()), task, SIGNAL(route())); connect(actionRoute, &QAction::triggered, task, &TaskManager::route);
// Worker control toolbar actions // Worker control toolbar actions
actionPlay = new QAction("Play", this); actionPlay = new QAction("Play", this);
actionPlay->setIcon(QIcon(":/icons/resources/control_play.png")); actionPlay->setIcon(QIcon(":/icons/resources/control_play.png"));
actionPlay->setStatusTip("Continue running task"); actionPlay->setStatusTip("Continue running task");
actionPlay->setEnabled(false); actionPlay->setEnabled(false);
connect(actionPlay, SIGNAL(triggered()), task, SLOT(continue_thread())); connect(actionPlay, &QAction::triggered, task, &TaskManager::continue_thread);
actionPause = new QAction("Pause", this); actionPause = new QAction("Pause", this);
actionPause->setIcon(QIcon(":/icons/resources/control_pause.png")); actionPause->setIcon(QIcon(":/icons/resources/control_pause.png"));
actionPause->setStatusTip("Pause running task"); actionPause->setStatusTip("Pause running task");
actionPause->setEnabled(false); actionPause->setEnabled(false);
connect(actionPause, SIGNAL(triggered()), task, SLOT(pause_thread())); connect(actionPause, &QAction::triggered, task, &TaskManager::pause_thread);
actionStop = new QAction("Stop", this); actionStop = new QAction("Stop", this);
actionStop->setIcon(QIcon(":/icons/resources/control_stop.png")); actionStop->setIcon(QIcon(":/icons/resources/control_stop.png"));
actionStop->setStatusTip("Stop running task"); actionStop->setStatusTip("Stop running task");
actionStop->setEnabled(false); actionStop->setEnabled(false);
connect(actionStop, SIGNAL(triggered()), task, SLOT(terminate_thread())); connect(actionStop, &QAction::triggered, task, &TaskManager::terminate_thread);
// Device view control toolbar actions // Device view control toolbar actions
QAction *actionZoomIn = new QAction("Zoom In", this); QAction *actionZoomIn = new QAction("Zoom In", this);
actionZoomIn->setIcon(QIcon(":/icons/resources/zoom_in.png")); actionZoomIn->setIcon(QIcon(":/icons/resources/zoom_in.png"));
connect(actionZoomIn, SIGNAL(triggered()), fpgaView, SLOT(zoomIn())); connect(actionZoomIn, &QAction::triggered, fpgaView, &FPGAViewWidget::zoomIn);
QAction *actionZoomOut = new QAction("Zoom Out", this); QAction *actionZoomOut = new QAction("Zoom Out", this);
actionZoomOut->setIcon(QIcon(":/icons/resources/zoom_out.png")); actionZoomOut->setIcon(QIcon(":/icons/resources/zoom_out.png"));
connect(actionZoomOut, SIGNAL(triggered()), fpgaView, SLOT(zoomOut())); connect(actionZoomOut, &QAction::triggered, fpgaView, &FPGAViewWidget::zoomOut);
QAction *actionZoomSelected = new QAction("Zoom Selected", this); QAction *actionZoomSelected = new QAction("Zoom Selected", this);
actionZoomSelected->setIcon(QIcon(":/icons/resources/shape_handles.png")); actionZoomSelected->setIcon(QIcon(":/icons/resources/shape_handles.png"));
connect(actionZoomSelected, SIGNAL(triggered()), fpgaView, SLOT(zoomSelected())); connect(actionZoomSelected, &QAction::triggered, fpgaView, &FPGAViewWidget::zoomSelected);
QAction *actionZoomOutbound = new QAction("Zoom Outbound", this); QAction *actionZoomOutbound = new QAction("Zoom Outbound", this);
actionZoomOutbound->setIcon(QIcon(":/icons/resources/shape_square.png")); actionZoomOutbound->setIcon(QIcon(":/icons/resources/shape_square.png"));
connect(actionZoomOutbound, SIGNAL(triggered()), fpgaView, SLOT(zoomOutbound())); connect(actionZoomOutbound, &QAction::triggered, fpgaView, &FPGAViewWidget::zoomOutbound);
// Add main menu // Add main menu
menuBar = new QMenuBar(); menuBar = new QMenuBar();

View File

@ -55,7 +55,7 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), sel
searchEdit->setClearButtonEnabled(true); searchEdit->setClearButtonEnabled(true);
searchEdit->addAction(QIcon(":/icons/resources/zoom.png"), QLineEdit::LeadingPosition); searchEdit->addAction(QIcon(":/icons/resources/zoom.png"), QLineEdit::LeadingPosition);
searchEdit->setPlaceholderText("Search..."); searchEdit->setPlaceholderText("Search...");
connect(searchEdit, SIGNAL(returnPressed()), this, SLOT(onSearchInserted())); connect(searchEdit, &QLineEdit::returnPressed, this, &DesignWidget::onSearchInserted);
actionFirst = new QAction("", this); actionFirst = new QAction("", this);
actionFirst->setIcon(QIcon(":/icons/resources/resultset_first.png")); actionFirst->setIcon(QIcon(":/icons/resources/resultset_first.png"));
@ -162,8 +162,7 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), sel
connect(treeView, &QTreeView::customContextMenuRequested, this, &DesignWidget::prepareMenuTree); connect(treeView, &QTreeView::customContextMenuRequested, this, &DesignWidget::prepareMenuTree);
connect(treeView, &QTreeView::doubleClicked, this, &DesignWidget::onDoubleClicked); connect(treeView, &QTreeView::doubleClicked, this, &DesignWidget::onDoubleClicked);
selectionModel = treeView->selectionModel(); selectionModel = treeView->selectionModel();
connect(selectionModel, SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), connect(selectionModel, &QItemSelectionModel::selectionChanged, this, &DesignWidget::onSelectionChanged);
SLOT(onSelectionChanged(const QItemSelection &, const QItemSelection &)));
history_index = -1; history_index = -1;
history_ignore = false; history_ignore = false;

View File

@ -44,7 +44,7 @@ MainWindow::MainWindow(std::unique_ptr<Context> context, ArchArgs args, QWidget
std::string title = "nextpnr-ice40 - [EMPTY]"; std::string title = "nextpnr-ice40 - [EMPTY]";
setWindowTitle(title.c_str()); setWindowTitle(title.c_str());
connect(this, SIGNAL(contextChanged(Context *)), this, SLOT(newContext(Context *))); connect(this, &BaseMainWindow::contextChanged, this, &MainWindow::newContext);
createMenu(); createMenu();
@ -60,13 +60,13 @@ void MainWindow::createMenu()
actionLoadPCF->setIcon(QIcon(":/icons/resources/open_pcf.png")); actionLoadPCF->setIcon(QIcon(":/icons/resources/open_pcf.png"));
actionLoadPCF->setStatusTip("Open PCF file"); actionLoadPCF->setStatusTip("Open PCF file");
actionLoadPCF->setEnabled(false); actionLoadPCF->setEnabled(false);
connect(actionLoadPCF, SIGNAL(triggered()), this, SLOT(open_pcf())); connect(actionLoadPCF, &QAction::triggered, this, &MainWindow::open_pcf);
actionSaveAsc = new QAction("Save ASC", this); actionSaveAsc = new QAction("Save ASC", this);
actionSaveAsc->setIcon(QIcon(":/icons/resources/save_asc.png")); actionSaveAsc->setIcon(QIcon(":/icons/resources/save_asc.png"));
actionSaveAsc->setStatusTip("Save ASC file"); actionSaveAsc->setStatusTip("Save ASC file");
actionSaveAsc->setEnabled(false); actionSaveAsc->setEnabled(false);
connect(actionSaveAsc, SIGNAL(triggered()), this, SLOT(save_asc())); connect(actionSaveAsc, &QAction::triggered, this, &MainWindow::save_asc);
// Add actions in menus // Add actions in menus
mainActionBar->addSeparator(); mainActionBar->addSeparator();

View File

@ -32,13 +32,13 @@ LineEditor::LineEditor(ParseHelper *helper, QWidget *parent) : QLineEdit(parent)
setContextMenuPolicy(Qt::CustomContextMenu); setContextMenuPolicy(Qt::CustomContextMenu);
QAction *clearAction = new QAction("Clear &history", this); QAction *clearAction = new QAction("Clear &history", this);
clearAction->setStatusTip("Clears line edit history"); clearAction->setStatusTip("Clears line edit history");
connect(clearAction, SIGNAL(triggered()), this, SLOT(clearHistory())); connect(clearAction, &QAction::triggered, this, &LineEditor::clearHistory);
contextMenu = createStandardContextMenu(); contextMenu = createStandardContextMenu();
contextMenu->addSeparator(); contextMenu->addSeparator();
contextMenu->addAction(clearAction); contextMenu->addAction(clearAction);
connect(this, SIGNAL(returnPressed()), SLOT(textInserted())); connect(this, &LineEditor::returnPressed, this, &LineEditor::textInserted);
connect(this, SIGNAL(customContextMenuRequested(const QPoint)), this, SLOT(showContextMenu(const QPoint))); connect(this, &LineEditor::customContextMenuRequested, this, &LineEditor::showContextMenu);
} }
void LineEditor::keyPressEvent(QKeyEvent *ev) void LineEditor::keyPressEvent(QKeyEvent *ev)

View File

@ -42,18 +42,18 @@ PythonTab::PythonTab(QWidget *parent) : QWidget(parent), initialized(false)
console->setContextMenuPolicy(Qt::CustomContextMenu); console->setContextMenuPolicy(Qt::CustomContextMenu);
QAction *clearAction = new QAction("Clear &buffer", this); QAction *clearAction = new QAction("Clear &buffer", this);
clearAction->setStatusTip("Clears display buffer"); clearAction->setStatusTip("Clears display buffer");
connect(clearAction, SIGNAL(triggered()), this, SLOT(clearBuffer())); connect(clearAction, &QAction::triggered, this, &PythonTab::clearBuffer);
contextMenu = console->createStandardContextMenu(); contextMenu = console->createStandardContextMenu();
contextMenu->addSeparator(); contextMenu->addSeparator();
contextMenu->addAction(clearAction); contextMenu->addAction(clearAction);
connect(console, SIGNAL(customContextMenuRequested(const QPoint)), this, SLOT(showContextMenu(const QPoint))); connect(console, &PythonConsole::customContextMenuRequested, this, &PythonTab::showContextMenu);
lineEdit = new LineEditor(&parseHelper); lineEdit = new LineEditor(&parseHelper);
lineEdit->setMinimumHeight(30); lineEdit->setMinimumHeight(30);
lineEdit->setMaximumHeight(30); lineEdit->setMaximumHeight(30);
lineEdit->setFont(f); lineEdit->setFont(f);
lineEdit->setPlaceholderText(PythonTab::PROMPT); lineEdit->setPlaceholderText(PythonTab::PROMPT);
connect(lineEdit, SIGNAL(textLineInserted(QString)), this, SLOT(editLineReturnPressed(QString))); connect(lineEdit, &LineEditor::textLineInserted, this, &PythonTab::editLineReturnPressed);
QGridLayout *mainLayout = new QGridLayout(); QGridLayout *mainLayout = new QGridLayout();
mainLayout->addWidget(console, 0, 0); mainLayout->addWidget(console, 0, 0);