Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
KReversi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Games
KReversi
Commits
d2549f90
Commit
d2549f90
authored
Sep 14, 2020
by
Friedrich W. H. Kossebau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Q_SIGNALS/Q_SLOTS/Q_EMIT instead of signals/slots/emit
GIT_SILENT
parent
ede919a4
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
45 additions
and
44 deletions
+45
-44
CMakeLists.txt
CMakeLists.txt
+1
-0
colorscheme.h
colorscheme.h
+1
-1
kexthighscore_gui.h
kexthighscore_gui.h
+7
-7
kexthighscore_tab.cpp
kexthighscore_tab.cpp
+3
-3
kexthighscore_tab.h
kexthighscore_tab.h
+3
-3
kreversicomputerplayer.cpp
kreversicomputerplayer.cpp
+2
-2
kreversicomputerplayer.h
kreversicomputerplayer.h
+2
-2
kreversigame.cpp
kreversigame.cpp
+10
-10
kreversigame.h
kreversigame.h
+2
-2
kreversihumanplayer.cpp
kreversihumanplayer.cpp
+2
-2
kreversihumanplayer.h
kreversihumanplayer.h
+2
-2
kreversiplayer.h
kreversiplayer.h
+2
-2
kreversiview.cpp
kreversiview.cpp
+1
-1
kreversiview.h
kreversiview.h
+3
-3
mainwindow.h
mainwindow.h
+1
-1
startgamedialog.cpp
startgamedialog.cpp
+1
-1
startgamedialog.h
startgamedialog.h
+2
-2
No files found.
CMakeLists.txt
View file @
d2549f90
...
@@ -41,6 +41,7 @@ add_definitions(
...
@@ -41,6 +41,7 @@ add_definitions(
# -DQT_NO_CAST_FROM_BYTEARRAY
# -DQT_NO_CAST_FROM_BYTEARRAY
-DQT_NO_URL_CAST_FROM_STRING
-DQT_NO_URL_CAST_FROM_STRING
-DQT_USE_QSTRINGBUILDER
-DQT_USE_QSTRINGBUILDER
-DQT_NO_KEYWORDS
)
)
if
(
${
KF5Config_VERSION
}
STRGREATER
"5.56.0"
)
if
(
${
KF5Config_VERSION
}
STRGREATER
"5.56.0"
)
add_definitions
(
-DQT_NO_FOREACH
)
add_definitions
(
-DQT_NO_FOREACH
)
...
...
colorscheme.h
View file @
d2549f90
...
@@ -41,7 +41,7 @@ public:
...
@@ -41,7 +41,7 @@ public:
QColor
foreground
()
const
;
QColor
foreground
()
const
;
QColor
border
()
const
;
QColor
border
()
const
;
signals
:
Q_SIGNALS
:
void
placeHolder
();
void
placeHolder
();
};
};
...
...
kexthighscore_gui.h
View file @
d2549f90
...
@@ -90,15 +90,15 @@ class HighscoresWidget : public QWidget
...
@@ -90,15 +90,15 @@ class HighscoresWidget : public QWidget
void
load
(
int
rank
);
void
load
(
int
rank
);
signals
:
Q_SIGNALS
:
void
tabChanged
(
int
i
);
void
tabChanged
(
int
i
);
public
slots
:
public
Q_SLOTS
:
void
changeTab
(
int
i
);
void
changeTab
(
int
i
);
private
slots
:
private
Q_SLOTS
:
void
showURL
(
const
QString
&
);
void
showURL
(
const
QString
&
);
void
tabChanged
()
{
emit
tabChanged
(
_tw
->
currentIndex
());
}
void
tabChanged
()
{
Q_EMIT
tabChanged
(
_tw
->
currentIndex
());
}
private:
private:
QTabWidget
*
_tw
=
nullptr
;
QTabWidget
*
_tw
=
nullptr
;
...
@@ -116,7 +116,7 @@ class HighscoresDialog : public KPageDialog
...
@@ -116,7 +116,7 @@ class HighscoresDialog : public KPageDialog
public:
public:
HighscoresDialog
(
int
rank
,
QWidget
*
parent
);
HighscoresDialog
(
int
rank
,
QWidget
*
parent
);
private
slots
:
private
Q_SLOTS
:
void
slotUser1
();
void
slotUser1
();
void
slotUser2
();
void
slotUser2
();
void
tabChanged
(
int
i
)
{
_tab
=
i
;
}
void
tabChanged
(
int
i
)
{
_tab
=
i
;
}
...
@@ -166,7 +166,7 @@ class ConfigDialog : public QDialog
...
@@ -166,7 +166,7 @@ class ConfigDialog : public QDialog
bool
hasBeenSaved
()
const
{
return
_saved
;
}
bool
hasBeenSaved
()
const
{
return
_saved
;
}
private
slots
:
private
Q_SLOTS
:
void
modifiedSlot
();
void
modifiedSlot
();
void
removeSlot
();
void
removeSlot
();
void
accept
()
override
;
void
accept
()
override
;
...
@@ -197,7 +197,7 @@ class AskNameDialog : public QDialog
...
@@ -197,7 +197,7 @@ class AskNameDialog : public QDialog
QString
name
()
const
{
return
_edit
->
text
();
}
QString
name
()
const
{
return
_edit
->
text
();
}
bool
dontAskAgain
()
const
{
return
_checkbox
->
isChecked
();
}
bool
dontAskAgain
()
const
{
return
_checkbox
->
isChecked
();
}
private
slots
:
private
Q_SLOTS
:
void
nameChanged
(
QDialogButtonBox
*
box
);
void
nameChanged
(
QDialogButtonBox
*
box
);
private:
private:
...
...
kexthighscore_tab.cpp
View file @
d2549f90
...
@@ -51,9 +51,9 @@ PlayersCombo::PlayersCombo(QWidget *parent)
...
@@ -51,9 +51,9 @@ PlayersCombo::PlayersCombo(QWidget *parent)
void
PlayersCombo
::
activatedSlot
(
int
i
)
void
PlayersCombo
::
activatedSlot
(
int
i
)
{
{
const
PlayerInfos
&
p
=
internal
->
playerInfos
();
const
PlayerInfos
&
p
=
internal
->
playerInfos
();
if
(
i
==
(
int
)
p
.
nbEntries
()
)
emit
allSelected
();
if
(
i
==
(
int
)
p
.
nbEntries
()
)
Q_EMIT
allSelected
();
else
if
(
i
==
(
int
)
p
.
nbEntries
()
+
1
)
emit
noneSelected
();
else
if
(
i
==
(
int
)
p
.
nbEntries
()
+
1
)
Q_EMIT
noneSelected
();
else
emit
playerSelected
(
i
);
else
Q_EMIT
playerSelected
(
i
);
}
}
void
PlayersCombo
::
load
()
void
PlayersCombo
::
load
()
...
...
kexthighscore_tab.h
View file @
d2549f90
...
@@ -39,12 +39,12 @@ class PlayersCombo : public QComboBox
...
@@ -39,12 +39,12 @@ class PlayersCombo : public QComboBox
void
load
();
void
load
();
signals
:
Q_SIGNALS
:
void
playerSelected
(
uint
i
);
void
playerSelected
(
uint
i
);
void
allSelected
();
void
allSelected
();
void
noneSelected
();
void
noneSelected
();
private
slots
:
private
Q_SLOTS
:
void
activatedSlot
(
int
i
);
void
activatedSlot
(
int
i
);
};
};
...
@@ -57,7 +57,7 @@ class AdditionalTab : public QWidget
...
@@ -57,7 +57,7 @@ class AdditionalTab : public QWidget
virtual
void
load
();
virtual
void
load
();
private
slots
:
private
Q_SLOTS
:
void
playerSelected
(
uint
i
)
{
display
(
i
)
;
}
void
playerSelected
(
uint
i
)
{
display
(
i
)
;
}
void
allSelected
();
void
allSelected
();
...
...
kreversicomputerplayer.cpp
View file @
d2549f90
...
@@ -39,7 +39,7 @@ void KReversiComputerPlayer::prepare(KReversiGame *game)
...
@@ -39,7 +39,7 @@ void KReversiComputerPlayer::prepare(KReversiGame *game)
m_game
=
game
;
m_game
=
game
;
m_state
=
WAITING
;
m_state
=
WAITING
;
emit
ready
();
Q_EMIT
ready
();
}
}
void
KReversiComputerPlayer
::
takeTurn
()
void
KReversiComputerPlayer
::
takeTurn
()
...
@@ -48,7 +48,7 @@ void KReversiComputerPlayer::takeTurn()
...
@@ -48,7 +48,7 @@ void KReversiComputerPlayer::takeTurn()
KReversiMove
move
=
m_engine
->
computeMove
(
*
m_game
,
true
);
KReversiMove
move
=
m_engine
->
computeMove
(
*
m_game
,
true
);
move
.
color
=
m_color
;
move
.
color
=
m_color
;
m_state
=
WAITING
;
m_state
=
WAITING
;
emit
makeMove
(
move
);
Q_EMIT
makeMove
(
move
);
}
}
void
KReversiComputerPlayer
::
skipTurn
()
void
KReversiComputerPlayer
::
skipTurn
()
...
...
kreversicomputerplayer.h
View file @
d2549f90
...
@@ -60,9 +60,9 @@ public:
...
@@ -60,9 +60,9 @@ public:
*/
*/
int
lowestSkill
();
int
lowestSkill
();
signals
:
Q_SIGNALS
:
public
slots
:
public
Q_SLOTS
:
private:
private:
int
m_lowestSkill
;
int
m_lowestSkill
;
...
...
kreversigame.cpp
View file @
d2549f90
...
@@ -96,32 +96,32 @@ void KReversiGame::makeMove(KReversiMove move)
...
@@ -96,32 +96,32 @@ void KReversiGame::makeMove(KReversiMove move)
turnChips
(
move
);
turnChips
(
move
);
m_delayTimer
.
singleShot
(
m_delay
*
(
qMax
(
1
,
m_changedChips
.
count
()
-
1
)),
this
,
&
KReversiGame
::
onDelayTimer
);
m_delayTimer
.
singleShot
(
m_delay
*
(
qMax
(
1
,
m_changedChips
.
count
()
-
1
)),
this
,
&
KReversiGame
::
onDelayTimer
);
emit
boardChanged
();
Q_EMIT
boardChanged
();
}
}
void
KReversiGame
::
startNextTurn
()
void
KReversiGame
::
startNextTurn
()
{
{
m_curPlayer
=
Utils
::
opponentColorFor
(
m_lastPlayer
);
m_curPlayer
=
Utils
::
opponentColorFor
(
m_lastPlayer
);
emit
moveFinished
();
// previous move has just finished
Q_EMIT
moveFinished
();
// previous move has just finished
if
(
!
isGameOver
())
{
if
(
!
isGameOver
())
{
if
(
isAnyPlayerMovePossible
(
m_curPlayer
))
{
if
(
isAnyPlayerMovePossible
(
m_curPlayer
))
{
if
(
m_curPlayer
==
White
)
if
(
m_curPlayer
==
White
)
emit
whitePlayerTurn
();
Q_EMIT
whitePlayerTurn
();
else
else
emit
blackPlayerTurn
();
Q_EMIT
blackPlayerTurn
();
}
else
{
}
else
{
if
(
m_curPlayer
==
White
)
if
(
m_curPlayer
==
White
)
emit
whitePlayerCantMove
();
Q_EMIT
whitePlayerCantMove
();
else
else
emit
blackPlayerCantMove
();
Q_EMIT
blackPlayerCantMove
();
m_lastPlayer
=
m_curPlayer
;
m_lastPlayer
=
m_curPlayer
;
startNextTurn
();
startNextTurn
();
}
}
}
else
{
//Game is over
}
else
{
//Game is over
emit
gameOver
();
Q_EMIT
gameOver
();
}
}
}
}
...
@@ -168,7 +168,7 @@ int KReversiGame::undo()
...
@@ -168,7 +168,7 @@ int KReversiGame::undo()
else
else
m_changedChips
.
clear
();
m_changedChips
.
clear
();
emit
boardChanged
();
Q_EMIT
boardChanged
();
kickCurrentPlayer
();
kickCurrentPlayer
();
return
movesUndone
;
return
movesUndone
;
...
@@ -389,8 +389,8 @@ ChipColor KReversiGame::chipColorAt(KReversiPos pos) const
...
@@ -389,8 +389,8 @@ ChipColor KReversiGame::chipColorAt(KReversiPos pos) const
void
KReversiGame
::
kickCurrentPlayer
()
void
KReversiGame
::
kickCurrentPlayer
()
{
{
if
(
m_curPlayer
==
White
)
if
(
m_curPlayer
==
White
)
emit
whitePlayerTurn
();
Q_EMIT
whitePlayerTurn
();
else
else
emit
blackPlayerTurn
();
Q_EMIT
blackPlayerTurn
();
}
}
kreversigame.h
View file @
d2549f90
...
@@ -128,7 +128,7 @@ public:
...
@@ -128,7 +128,7 @@ public:
* @return Is hint allowed for current player
* @return Is hint allowed for current player
*/
*/
bool
isHintAllowed
()
const
;
bool
isHintAllowed
()
const
;
private
slots
:
private
Q_SLOTS
:
/**
/**
* Starts next player's turn.
* Starts next player's turn.
*/
*/
...
@@ -156,7 +156,7 @@ private slots:
...
@@ -156,7 +156,7 @@ private slots:
*/
*/
void
whiteReady
();
void
whiteReady
();
signals
:
Q_SIGNALS
:
void
gameOver
();
void
gameOver
();
void
boardChanged
();
void
boardChanged
();
void
moveFinished
();
void
moveFinished
();
...
...
kreversihumanplayer.cpp
View file @
d2549f90
...
@@ -34,7 +34,7 @@ void KReversiHumanPlayer::prepare(KReversiGame* game)
...
@@ -34,7 +34,7 @@ void KReversiHumanPlayer::prepare(KReversiGame* game)
m_game
=
game
;
m_game
=
game
;
m_state
=
WAITING
;
m_state
=
WAITING
;
emit
ready
();
Q_EMIT
ready
();
}
}
void
KReversiHumanPlayer
::
takeTurn
()
void
KReversiHumanPlayer
::
takeTurn
()
...
@@ -60,5 +60,5 @@ void KReversiHumanPlayer::onUICellClick(KReversiPos pos)
...
@@ -60,5 +60,5 @@ void KReversiHumanPlayer::onUICellClick(KReversiPos pos)
}
}
m_state
=
WAITING
;
m_state
=
WAITING
;
emit
makeMove
(
KReversiMove
(
m_color
,
pos
));
Q_EMIT
makeMove
(
KReversiMove
(
m_color
,
pos
));
}
}
kreversihumanplayer.h
View file @
d2549f90
...
@@ -48,9 +48,9 @@ public:
...
@@ -48,9 +48,9 @@ public:
void
skipTurn
()
override
;
void
skipTurn
()
override
;
void
gameOver
()
override
;
void
gameOver
()
override
;
signals
:
Q_SIGNALS
:
public
slots
:
public
Q_SLOTS
:
/**
/**
* Using it to get information from UI.
* Using it to get information from UI.
* @param move Move that player has made.
* @param move Move that player has made.
...
...
kreversiplayer.h
View file @
d2549f90
...
@@ -97,7 +97,7 @@ public:
...
@@ -97,7 +97,7 @@ public:
*/
*/
int
getUndoCount
();
int
getUndoCount
();
public
slots
:
public
Q_SLOTS
:
/**
/**
* Triggered by KReversiGame before game starts
* Triggered by KReversiGame before game starts
* Implementation should assign @p game to m_game
* Implementation should assign @p game to m_game
...
@@ -121,7 +121,7 @@ public slots:
...
@@ -121,7 +121,7 @@ public slots:
*/
*/
virtual
void
gameOver
()
=
0
;
virtual
void
gameOver
()
=
0
;
signals
:
Q_SIGNALS
:
/**
/**
* Player emit it when want to notify about his move
* Player emit it when want to notify about his move
*/
*/
...
...
kreversiview.cpp
View file @
d2549f90
...
@@ -229,7 +229,7 @@ void KReversiView::onPlayerMove(int row, int col)
...
@@ -229,7 +229,7 @@ void KReversiView::onPlayerMove(int row, int col)
if
(
!
m_game
)
if
(
!
m_game
)
return
;
return
;
emit
userMove
(
KReversiPos
(
row
,
col
));
Q_EMIT
userMove
(
KReversiPos
(
row
,
col
));
}
}
...
...
kreversiview.h
View file @
d2549f90
...
@@ -73,7 +73,7 @@ public:
...
@@ -73,7 +73,7 @@ public:
*/
*/
void
setAnimationSpeed
(
int
speed
);
void
setAnimationSpeed
(
int
speed
);
public
slots
:
public
Q_SLOTS
:
/**
/**
* This will make view visually mark the last made move
* This will make view visually mark the last made move
*
*
...
@@ -95,7 +95,7 @@ public slots:
...
@@ -95,7 +95,7 @@ public slots:
*/
*/
void
slotHint
();
void
slotHint
();
private
slots
:
private
Q_SLOTS
:
/**
/**
* Triggered on user click on board, connected to QML signal
* Triggered on user click on board, connected to QML signal
*
*
...
@@ -111,7 +111,7 @@ private slots:
...
@@ -111,7 +111,7 @@ private slots:
void
gameOver
();
void
gameOver
();
void
whitePlayerCantMove
();
void
whitePlayerCantMove
();
void
blackPlayerCantMove
();
void
blackPlayerCantMove
();
signals
:
Q_SIGNALS
:
void
userMove
(
KReversiPos
);
void
userMove
(
KReversiPos
);
private:
private:
...
...
mainwindow.h
View file @
d2549f90
...
@@ -50,7 +50,7 @@ class KReversiMainWindow : public KXmlGuiWindow
...
@@ -50,7 +50,7 @@ class KReversiMainWindow : public KXmlGuiWindow
public:
public:
explicit
KReversiMainWindow
(
QWidget
*
parent
=
nullptr
,
bool
startDemo
=
false
);
explicit
KReversiMainWindow
(
QWidget
*
parent
=
nullptr
,
bool
startDemo
=
false
);
~
KReversiMainWindow
();
~
KReversiMainWindow
();
public
slots
:
public
Q_SLOTS
:
void
slotNewGame
();
void
slotNewGame
();
void
levelChanged
();
void
levelChanged
();
void
slotAnimSpeedChanged
(
int
);
void
slotAnimSpeedChanged
(
int
);
...
...
startgamedialog.cpp
View file @
d2549f90
...
@@ -136,7 +136,7 @@ void StartGameDialog::loadChipImages()
...
@@ -136,7 +136,7 @@ void StartGameDialog::loadChipImages()
void
StartGameDialog
::
slotAccepted
()
void
StartGameDialog
::
slotAccepted
()
{
{
emit
startGame
();
Q_EMIT
startGame
();
accept
();
accept
();
}
}
...
...
startgamedialog.h
View file @
d2549f90
...
@@ -57,13 +57,13 @@ public:
...
@@ -57,13 +57,13 @@ public:
*/
*/
void
setChipsPrefix
(
ChipsPrefix
prefix
);
void
setChipsPrefix
(
ChipsPrefix
prefix
);
signals
:
Q_SIGNALS
:
/**
/**
* Emitted when user has finished entering information
* Emitted when user has finished entering information
*/
*/
void
startGame
();
void
startGame
();
private
slots
:
private
Q_SLOTS
:
/**
/**
* Handles "User changed player type for black player" event
* Handles "User changed player type for black player" event
*/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment