Commit 9a09eb76 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Use Q_SIGNALS/Q_SLOTS/Q_EMIT instead of signals/slots/emit

GIT_SILENT
parent e1b5ad68
......@@ -36,6 +36,7 @@ add_definitions(
-DQT_USE_FAST_OPERATOR_PLUS
-DQT_NO_URL_CAST_FROM_STRING
-DQT_NO_FOREACH
-DQT_NO_KEYWORDS
-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x054400
-DKF_DEPRECATED_WARNINGS_SINCE=0x060000
)
......
......@@ -40,7 +40,7 @@ public:
void run() override {
int index = m_ai->computeMove();
emit done (index);
Q_EMIT done (index);
}
/* IDW test. TODO - This is not actually used. Is it needed?
* I think AI_Main::stop() sets m_stopped atomically and even
......@@ -59,7 +59,7 @@ public:
qCDebug(KJUMPINGCUBE_LOG) << "STOP THREAD DONE";
}
*/
signals:
Q_SIGNALS:
void done (int index);
private:
......
......@@ -111,7 +111,7 @@ public:
void setSkill (int skill1, bool kepler1, bool newton1,
int skill2, bool kepler2, bool newton2);
signals:
Q_SIGNALS:
/**
* Signal the best move found after the AI search finishes or is stopped.
*
......
......@@ -123,7 +123,7 @@ void Game::gameActions (const int action)
void Game::showWinner()
{
emit buttonChange (false, false, i18n("Game over"));
Q_EMIT buttonChange (false, false, i18n("Game over"));
QString s = i18n("The winner is Player %1!", m_currentPlayer);
KMessageBox::information (m_view, s, i18n("Winner"));
}
......@@ -177,7 +177,7 @@ void Game::loadImmediateSettings()
m_fullSpeed = Prefs::animationNone();
m_pauseForStep = Prefs::pauseForStep();
if (reColorCubes) {
emit playerChanged (m_currentPlayer); // Re-display status bar icon.
Q_EMIT playerChanged (m_currentPlayer); // Re-display status bar icon.
}
// Choices of computer AIs and skills will take effect next time there is a
......@@ -249,14 +249,14 @@ void Game::setUpNextTurn()
m_waitingToMove = true;
if (computerPlOne && computerPlTwo) {
if (m_moveNo == 0) {
emit buttonChange (true, false, i18n("Start game"));
Q_EMIT buttonChange (true, false, i18n("Start game"));
}
else {
emit buttonChange (true, false, i18n("Continue game"));
Q_EMIT buttonChange (true, false, i18n("Continue game"));
}
}
else {
emit buttonChange (true, false, i18n("Start computer move"));
Q_EMIT buttonChange (true, false, i18n("Start computer move"));
}
// Wait for a button-click to show that the user is ready.
qCDebug(KJUMPINGCUBE_LOG) << "COMPUTER MUST WAIT";
......@@ -277,10 +277,10 @@ void Game::setUpNextTurn()
m_waitingState = Nil;
m_waitingToMove = true;
if (computerPlOne || computerPlTwo) {
emit buttonChange (false, false, i18n("Your turn"));
Q_EMIT buttonChange (false, false, i18n("Your turn"));
}
else {
emit buttonChange (false, false, i18n("Player %1", m_currentPlayer));
Q_EMIT buttonChange (false, false, i18n("Player %1", m_currentPlayer));
}
// Wait for a click on the cube to be moved.
}
......@@ -294,9 +294,9 @@ void Game::computeMove()
m_view->setWaitCursor();
m_activity = Computing;
setStopAction();
emit setAction (HINT, false);
Q_EMIT setAction (HINT, false);
if (isComputer (m_currentPlayer)) {
emit statusMessage (i18n("Computer player %1 is moving", m_currentPlayer), false);
Q_EMIT statusMessage (i18n("Computer player %1 is moving", m_currentPlayer), false);
}
m_ai->getMove (m_currentPlayer, m_box);
}
......@@ -360,8 +360,8 @@ void Game::doMove (int index)
m_ai->postMove (m_currentPlayer, index, m_side);
}
#endif
emit setAction (UNDO, true); // Update Undo and Redo actions.
emit setAction (REDO, false);
Q_EMIT setAction (UNDO, true); // Update Undo and Redo actions.
Q_EMIT setAction (REDO, false);
m_steps->clear();
bool won = m_box->doMove (m_currentPlayer, index, nullptr, m_steps);
#if AILog > 1
......@@ -416,7 +416,7 @@ void Game::doStep()
// Pause: return the step to the list and wait for a buttonClick.
m_steps->prepend (-index - 1);
m_waitingState = WaitingToStep;
emit buttonChange (true, false, i18n("Show next step"));
Q_EMIT buttonChange (true, false, i18n("Show next step"));
return;
}
// Now set the button up and start the animation.
......@@ -447,7 +447,7 @@ void Game::moveDone()
{
// Called after non-animated move, animated move, end of game or hint action.
m_view->setNormalCursor();
emit statusMessage (QLatin1String(""), false); // Clear the status bar.
Q_EMIT statusMessage (QLatin1String(""), false); // Clear the status bar.
m_activity = Idle;
setAction (HINT, true);
m_fullSpeed = Prefs::animationNone();
......@@ -461,7 +461,7 @@ void Game::moveDone()
Player Game::changePlayer()
{
m_currentPlayer = (m_currentPlayer == One) ? Two : One;
emit playerChanged (m_currentPlayer);
Q_EMIT playerChanged (m_currentPlayer);
setUpNextTurn();
return m_currentPlayer;
}
......@@ -513,19 +513,19 @@ void Game::setStopAction()
if ((! m_pauseForComputer) && (! m_interrupting) &&
(computerPlOne && computerPlTwo)) {
if (m_activity == Computing) { // Starting AI v. AI move.
emit buttonChange (true, true, i18n("Interrupt game"));
Q_EMIT buttonChange (true, true, i18n("Interrupt game"));
}
return; // Continuing AI v. AI move.
}
// Red button settings for AI v. human, two human players or pausing game.
if (m_activity == Computing) { // Calculating hint or AI move.
emit buttonChange (true, true, i18n("Stop computing"));
Q_EMIT buttonChange (true, true, i18n("Stop computing"));
}
else if (m_activity == ShowingMove) { // Showing hint or AI move.
emit buttonChange (true, true, i18n("Stop showing move"));
Q_EMIT buttonChange (true, true, i18n("Stop showing move"));
}
else if (m_activity == AnimatingMove) { // Animating AI or human move.
emit buttonChange (true, true, i18n("Stop animation"));
Q_EMIT buttonChange (true, true, i18n("Stop animation"));
}
}
......@@ -552,9 +552,9 @@ void Game::newGame()
setDim (Prefs::cubeDim());
qCDebug(KJUMPINGCUBE_LOG) << "Entering reset();";
reset(); // Clear cubebox, initialise states.
emit setAction (UNDO, false);
emit setAction (REDO, false);
emit statusMessage (i18n("New Game"), false);
Q_EMIT setAction (UNDO, false);
Q_EMIT setAction (REDO, false);
Q_EMIT statusMessage (i18n("New Game"), false);
m_moveNo = 0;
m_endMoveNo = LARGE_NUMBER;
setUpNextTurn();
......@@ -612,7 +612,7 @@ void Game::saveGame (bool saveAs)
KJobWidgets::setWindow(job, m_view);
job->exec();
if (! job->error() ) {
emit statusMessage (i18n("Game saved as %1", m_gameURL.url()), false);
Q_EMIT statusMessage (i18n("Game saved as %1", m_gameURL.url()), false);
}
else {
KMessageBox::sorry (m_view, i18n("There was an error in saving file\n%1",
......@@ -661,7 +661,7 @@ void Game::loadGame()
KConfigGroup game (&config, "Game");
readProperties (game);
emit setAction (UNDO, false);
Q_EMIT setAction (UNDO, false);
}
else
KMessageBox::sorry (m_view, i18n("There was an error loading file\n%1",
......@@ -671,15 +671,15 @@ void Game::loadGame()
void Game::undo()
{
bool moreToUndo = undoRedo (-1);
emit setAction (UNDO, moreToUndo);
emit setAction (REDO, true);
Q_EMIT setAction (UNDO, moreToUndo);
Q_EMIT setAction (REDO, true);
}
void Game::redo()
{
bool moreToRedo = undoRedo (+1);
emit setAction (REDO, moreToRedo);
emit setAction (UNDO, true);
Q_EMIT setAction (REDO, moreToRedo);
Q_EMIT setAction (UNDO, true);
}
bool Game::newGameOK()
......@@ -760,7 +760,7 @@ bool Game::undoRedo (int change)
m_moveNo = m_moveNo + change;
if (m_moveNo < m_endMoveNo) {
if (oldPlayer != m_currentPlayer) {
emit playerChanged (m_currentPlayer);
Q_EMIT playerChanged (m_currentPlayer);
}
m_waitingState = isComputer (m_currentPlayer) ? ComputerToMove
: m_waitingState;
......@@ -898,7 +898,7 @@ void Game::readProperties (const KConfigGroup& config)
onTurn = 1;
}
m_currentPlayer = (Player) onTurn;
emit playerChanged (m_currentPlayer);
Q_EMIT playerChanged (m_currentPlayer);
// Restore the game and player settings.
loadSavedSettings (config);
......
......@@ -53,7 +53,7 @@ public:
* */
void shutdown();
public slots:
public Q_SLOTS:
/**
* Perform one of the game-actions listed in enum type Action.
......@@ -70,7 +70,7 @@ private:
*/
void showWinner();
private slots:
private Q_SLOTS:
/**
* Pop up the settings/preferences/configuration dialog window.
*/
......@@ -104,7 +104,7 @@ private:
*/
void computeMove();
private slots:
private Q_SLOTS:
/**
* Deliver a computer-move or hint calculated by the AI thread and start an
* animation to show which cube is to move.
......@@ -178,7 +178,7 @@ private:
*/
void loadPlayerSettings();
private slots:
private Q_SLOTS:
/**
* Indicate that showing a move or animating a move-step has finished.
*
......@@ -187,7 +187,7 @@ private slots:
*/
void animationDone (int index);
signals:
Q_SIGNALS:
/**
* Request that the current player be shown in the KJumpingCube main window.
*
......@@ -269,7 +269,7 @@ private:
QUrl m_gameURL; // Location of load/save file.
private slots:
private Q_SLOTS:
void newGame(); // Slot needed for queued invocation.
private:
......
......@@ -167,7 +167,7 @@ bool KCubeBoxWidget::checkClick (int x, int y)
// one that KCubeWidget has?
*/
qCDebug(KJUMPINGCUBE_LOG) << "Emit mouseClick (" << x << y << ")";
emit mouseClick (x, y);
Q_EMIT mouseClick (x, y);
return false;
}
......@@ -420,7 +420,7 @@ void KCubeBoxWidget::nextAnimationStep()
animationTimer->stop(); // Finish normally.
cubes.at (m_index)->setNeutral();
currentAnimation = None;
emit animationDone (m_index);
Q_EMIT animationDone (m_index);
return;
}
switch (currentAnimation) {
......
......@@ -74,7 +74,7 @@ public:
bool loadSettings();
signals:
Q_SIGNALS:
void animationDone (int index);
void mouseClick (int x, int y);
......@@ -138,7 +138,7 @@ private:
void setPopup();
void scatterDots (int step);
private slots:
private Q_SLOTS:
void nextAnimationStep();
void highlightDone(); // Timeout of the highlighted cube.
......
......@@ -154,7 +154,7 @@ void KCubeWidget::mouseReleaseEvent(QMouseEvent *e)
if(e->button() == Qt::LeftButton && _clicksAllowed) {
e->accept();
emit clicked (m_row, m_col);
Q_EMIT clicked (m_row, m_col);
}
}
......
......@@ -68,13 +68,13 @@ public:
void expand (qreal scale);
void migrateDot (int rowDiff, int colDiff, int step, Player player);
public slots:
public Q_SLOTS:
/** resets the Cube to default values */
virtual void reset();
/** shows changed colors*/
virtual void updateColors();
signals:
Q_SIGNALS:
void clicked (int row, int column);
protected:
......
......@@ -46,7 +46,7 @@ public:
/** Default Constructor */
KJumpingCube();
public slots:
public Q_SLOTS:
void setAction (const Action a, const bool onOff);
protected:
......@@ -64,7 +64,7 @@ private:
QPushButton * actionButton;
QString buttonLook;
private slots:
private Q_SLOTS:
void changePlayerColor (int newPlayer);
void changeButton (bool enabled, bool stop = false,
const QString & caption = QString());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment