diff --git a/src/ui/BuildButtonGrid.cpp b/src/ui/BuildButtonGrid.cpp index 038fd98..80626f2 100644 --- a/src/ui/BuildButtonGrid.cpp +++ b/src/ui/BuildButtonGrid.cpp @@ -72,7 +72,7 @@ BuildButtonGrid::BuildButtonGrid(const GameConfig* config, QWidget* parent) const int idx = static_cast(m_buttons.size()); m_buttons.push_back(btn); mapper->setMapping(btn, idx); - connect(btn, SIGNAL(clicked()), mapper, SLOT(map())); + connect(btn, &QPushButton::clicked, mapper, qOverload<>(&QSignalMapper::map)); ++col; if (col >= kCols) @@ -81,7 +81,7 @@ BuildButtonGrid::BuildButtonGrid(const GameConfig* config, QWidget* parent) ++row; } } - connect(mapper, SIGNAL(mapped(int)), this, SLOT(onBuildButton(int))); + connect(mapper, qOverload(&QSignalMapper::mapped), this, &BuildButtonGrid::onBuildButton); m_demolishButton = new QPushButton("Demolish", this); m_demolishButton->setCheckable(true); diff --git a/src/ui/GameWorldView.cpp b/src/ui/GameWorldView.cpp index 92ebd30..353eee0 100644 --- a/src/ui/GameWorldView.cpp +++ b/src/ui/GameWorldView.cpp @@ -126,7 +126,7 @@ GameWorldView::GameWorldView(Simulation* sim, const GameConfig* config, m_renderTimer = new QTimer(this); m_renderTimer->setInterval(16); - connect(m_renderTimer, SIGNAL(timeout()), this, SLOT(onFrame())); + connect(m_renderTimer, &QTimer::timeout, this, &GameWorldView::onFrame); m_renderTimer->start(); m_frameTimer.start(); } diff --git a/src/ui/HeaderBar.cpp b/src/ui/HeaderBar.cpp index 3abdd25..9ad7fd0 100644 --- a/src/ui/HeaderBar.cpp +++ b/src/ui/HeaderBar.cpp @@ -36,10 +36,10 @@ HeaderBar::HeaderBar(QWidget* parent) layout->addWidget(btn); m_speedButtons.push_back(btn); mapper->setMapping(btn, i); - connect(btn, SIGNAL(clicked()), mapper, SLOT(map())); + connect(btn, &QPushButton::clicked, mapper, qOverload<>(&QSignalMapper::map)); } - connect(mapper, SIGNAL(mapped(int)), this, SLOT(onSpeedButton(int))); - + connect(mapper, qOverload(&QSignalMapper::mapped), this, &HeaderBar::onSpeedButton); + setFixedHeight(sizeHint().height()); } @@ -70,3 +70,4 @@ void HeaderBar::onSpeedButton(int index) emit speedChanged(kSpeeds[index]); } } + diff --git a/src/ui/MainWindow.cpp b/src/ui/MainWindow.cpp index 2af7d88..c953787 100644 --- a/src/ui/MainWindow.cpp +++ b/src/ui/MainWindow.cpp @@ -41,43 +41,43 @@ MainWindow::MainWindow(Simulation* sim, const std::string& configDir, QWidget* p bottomLayout->addWidget(m_buildButtonGrid, 1); // Signals: game world → other panels - connect(m_gameWorldView, SIGNAL(selectionChanged(std::vector)), - m_selectedBuildingPanel, SLOT(onSelectionChanged(std::vector))); + connect(m_gameWorldView, &GameWorldView::selectionChanged, + m_selectedBuildingPanel, &SelectedBuildingPanel::onSelectionChanged); - connect(m_gameWorldView, SIGNAL(stateUpdated(Tick, int, double)), - m_headerBar, SLOT(onStateUpdated(Tick, int, double))); + connect(m_gameWorldView, &GameWorldView::stateUpdated, + m_headerBar, &HeaderBar::onStateUpdated); - connect(m_gameWorldView, SIGNAL(stateUpdated(Tick, int, double)), - this, SLOT(onStateUpdated(Tick, int, double))); // for affordability + connect(m_gameWorldView, &GameWorldView::stateUpdated, + this, &MainWindow::onStateUpdated); // for affordability - connect(m_gameWorldView, SIGNAL(stateUpdated(Tick, int, double)), - m_selectedBuildingPanel, SLOT(onStateUpdated(Tick, int, double))); + connect(m_gameWorldView, &GameWorldView::stateUpdated, + m_selectedBuildingPanel, &SelectedBuildingPanel::onStateUpdated); - connect(m_gameWorldView, SIGNAL(gameOver()), - this, SLOT(onGameOver())); + connect(m_gameWorldView, &GameWorldView::gameOver, + this, &MainWindow::onGameOver); - connect(m_gameWorldView, SIGNAL(escapeMenuRequested()), - this, SLOT(onEscapeMenuRequested())); + connect(m_gameWorldView, &GameWorldView::escapeMenuRequested, + this, &MainWindow::onEscapeMenuRequested); // Signals: build grid → game world - connect(m_buildButtonGrid, SIGNAL(buildingTypeSelected(BuildingType)), - m_gameWorldView, SLOT(enterBuilderMode(BuildingType))); + connect(m_buildButtonGrid, &BuildButtonGrid::buildingTypeSelected, + m_gameWorldView, &GameWorldView::enterBuilderMode); - connect(m_buildButtonGrid, SIGNAL(builderModeExited()), - m_gameWorldView, SLOT(exitBuilderMode())); + connect(m_buildButtonGrid, &BuildButtonGrid::builderModeExited, + m_gameWorldView, &GameWorldView::exitBuilderMode); - connect(m_gameWorldView, SIGNAL(builderModeExited()), - m_buildButtonGrid, SLOT(clearActiveButton())); + connect(m_gameWorldView, &GameWorldView::builderModeExited, + m_buildButtonGrid, &BuildButtonGrid::clearActiveButton); - connect(m_buildButtonGrid, SIGNAL(demolishModeToggleRequested()), - m_gameWorldView, SLOT(toggleDemolishMode())); + connect(m_buildButtonGrid, &BuildButtonGrid::demolishModeToggleRequested, + m_gameWorldView, &GameWorldView::toggleDemolishMode); - connect(m_gameWorldView, SIGNAL(demolishModeChanged(bool)), - m_buildButtonGrid, SLOT(setDemolishModeActive(bool))); + connect(m_gameWorldView, &GameWorldView::demolishModeChanged, + m_buildButtonGrid, &BuildButtonGrid::setDemolishModeActive); // Signals: header bar → game world - connect(m_headerBar, SIGNAL(speedChanged(double)), - m_gameWorldView, SLOT(setGameSpeed(double))); + connect(m_headerBar, &HeaderBar::speedChanged, + m_gameWorldView, &GameWorldView::setGameSpeed); m_gameWorldView->setFocus(); diff --git a/src/ui/SelectedBuildingPanel.cpp b/src/ui/SelectedBuildingPanel.cpp index f39e210..dc92ed9 100644 --- a/src/ui/SelectedBuildingPanel.cpp +++ b/src/ui/SelectedBuildingPanel.cpp @@ -84,10 +84,10 @@ SelectedBuildingPanel::SelectedBuildingPanel(Simulation* sim, m_layout->addWidget(m_clearBeltBtn); m_layout->addWidget(m_buffersLabel); - connect(m_recipeCombo, SIGNAL(currentIndexChanged(int)), - this, SLOT(onRecipeChanged(int))); - connect(m_clearBeltBtn, SIGNAL(clicked()), - this, SLOT(onClearBelt())); + connect(m_recipeCombo, qOverload(&QComboBox::currentIndexChanged), + this, &SelectedBuildingPanel::onRecipeChanged); + connect(m_clearBeltBtn, &QPushButton::clicked, + this, &SelectedBuildingPanel::onClearBelt); buildEmpty(); }