Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit acdf7898 authored by Laurent Montel's avatar Laurent Montel 😁

Fix clazy warning

parent d0245ef7
......@@ -19,7 +19,7 @@
CharacterItem::CharacterItem(Character *p_model) : ElementItem(p_model)
{
connect(p_model, SIGNAL(eaten()), this, SLOT(startBlinking()));
connect(p_model, &Character::eaten, this, &CharacterItem::startBlinking);
}
CharacterItem::~CharacterItem()
......
......@@ -35,13 +35,13 @@ Game::Game() :
m_points(0),
m_level(1),
m_nbEatenGhosts(0),
m_soundGameOver(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("sounds/kapman/gameover.ogg"))),
m_soundGhost(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("sounds/kapman/ghost.ogg"))),
m_soundGainLife(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("sounds/kapman/life.ogg"))),
m_soundEnergizer(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("sounds/kapman/energizer.ogg"))),
m_soundBonus(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("sounds/kapman/bonus.ogg"))),
m_soundPill(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("sounds/kapman/pill.ogg"))),
m_soundLevelUp(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("sounds/kapman/levelup.ogg")))
m_soundGameOver(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("sounds/kapman/gameover.ogg"))),
m_soundGhost(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("sounds/kapman/ghost.ogg"))),
m_soundGainLife(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("sounds/kapman/life.ogg"))),
m_soundEnergizer(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("sounds/kapman/energizer.ogg"))),
m_soundBonus(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("sounds/kapman/bonus.ogg"))),
m_soundPill(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("sounds/kapman/pill.ogg"))),
m_soundLevelUp(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("sounds/kapman/levelup.ogg")))
{
// Initialize the sound state
setSoundsEnabled(Settings::sounds());
......@@ -63,7 +63,7 @@ Game::Game() :
// This also creates all the characters
KapmanParser kapmanParser(this);
// Set the XML file as input source for the parser
QFile mazeXmlFile(QStandardPaths::locate(QStandardPaths::AppDataLocation, QLatin1Literal("defaultmaze.xml")));
QFile mazeXmlFile(QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("defaultmaze.xml")));
QXmlInputSource source(&mazeXmlFile);
// Create the XML file reader
QXmlSimpleReader reader;
......@@ -91,8 +91,8 @@ Game::Game() :
}
for (int i = 0; i < m_ghosts.size(); ++i) {
connect(m_ghosts[i], SIGNAL(lifeLost()), this, SLOT(kapmanDeath()));
connect(m_ghosts[i], SIGNAL(ghostEaten(Ghost*)), this, SLOT(ghostDeath(Ghost*)));
connect(m_ghosts[i], &Ghost::lifeLost, this, &Game::kapmanDeath);
connect(m_ghosts[i], &Ghost::ghostEaten, this, &Game::ghostDeath);
// Initialize the ghosts speed and the ghost speed increase considering the characters speed
m_ghosts[i]->initSpeedInc();
}
......@@ -399,7 +399,7 @@ void Game::kapmanDeath()
m_kapman->die();
// Make a 2 seconds pause while the kapman is blinking
pause(true);
QTimer::singleShot(2500, this, SLOT(resumeAfterKapmanDeath()));
QTimer::singleShot(2500, this, &Game::resumeAfterKapmanDeath);
}
void Game::resumeAfterKapmanDeath()
......
......@@ -25,15 +25,15 @@
GameScene::GameScene(Game *p_game) : m_game(p_game), m_kapmanItem(0), m_mazeItem(0)
{
connect(p_game, SIGNAL(levelStarted(bool)), SLOT(intro(bool)));
connect(p_game, SIGNAL(gameStarted()), this, SLOT(start()));
connect(p_game, SIGNAL(pauseChanged(bool,bool)), this, SLOT(setPaused(bool,bool)));
connect(p_game, SIGNAL(elementEaten(qreal,qreal)), this, SLOT(hideElement(qreal,qreal)));
connect(p_game, SIGNAL(bonusOn()), this, SLOT(displayBonus()));
connect(p_game, SIGNAL(bonusOff()), this, SLOT(hideBonus()));
connect(p_game, &Game::levelStarted, this, &GameScene::intro);
connect(p_game, &Game::gameStarted, this, &GameScene::start);
connect(p_game, &Game::pauseChanged, this, &GameScene::setPaused);
connect(p_game, &Game::elementEaten, this, &GameScene::hideElement);
connect(p_game, &Game::bonusOn, this, &GameScene::displayBonus);
connect(p_game, &Game::bonusOff, this, &GameScene::hideBonus);
// Connection between Game and GameScene for the display of won points when a bonus or a ghost is eaten
connect(p_game, SIGNAL(pointsToDisplay(long,qreal,qreal)), this, SLOT(displayPoints(long,qreal,qreal)));
connect(p_game, &Game::pointsToDisplay, this, &GameScene::displayPoints);
// Create the theme instance
m_theme = new KGameTheme();
......@@ -47,13 +47,13 @@ GameScene::GameScene(Game *p_game) : m_game(p_game), m_kapmanItem(0), m_mazeItem
// Give the maze the shared renderer to avoid loading the whole SVG file again
m_mazeItem->setSharedRenderer(m_renderer);
// Set the element Id to the right value
m_mazeItem->setElementId(QLatin1Literal("maze"));
m_mazeItem->setElementId(QStringLiteral("maze"));
m_mazeItem->setZValue(-2);
// Create the KapmanItem
m_kapmanItem = new KapmanItem(p_game->getKapman());
m_kapmanItem->setSharedRenderer(m_renderer);
m_kapmanItem->setElementId(QLatin1Literal("kapman_0"));
m_kapmanItem->setElementId(QStringLiteral("kapman_0"));
// Corrects the position of the KapmanItem
m_kapmanItem->update(p_game->getKapman()->getX(), p_game->getKapman()->getY());
m_kapmanItem->setZValue(2);
......@@ -90,7 +90,7 @@ GameScene::GameScene(Game *p_game) : m_game(p_game), m_kapmanItem(0), m_mazeItem
// Create the Bonus item
m_bonusItem = new ElementItem(m_game->getBonus());
m_bonusItem->setSharedRenderer(m_renderer);
m_bonusItem->setElementId(QLatin1Literal("bonus1"));
m_bonusItem->setElementId(QStringLiteral("bonus1"));
// All elements are created, update theme properties
updateSvgIds();
......@@ -98,21 +98,21 @@ GameScene::GameScene(Game *p_game) : m_game(p_game), m_kapmanItem(0), m_mazeItem
// Create the introduction labels
m_introLabel = new QGraphicsTextItem(i18n("GET READY!!!"));
m_introLabel->setFont(QFont(QLatin1Literal("Helvetica"), 25, QFont::Bold, false));
m_introLabel->setFont(QFont(QStringLiteral("Helvetica"), 25, QFont::Bold, false));
m_introLabel->setDefaultTextColor(QColor(QLatin1Literal("#FFFF00")));
m_introLabel->setZValue(4);
m_introLabel2 = new QGraphicsTextItem(i18n("Press any arrow key to start"));
m_introLabel2->setFont(QFont(QLatin1Literal("Helvetica"), 15, QFont::Bold, false));
m_introLabel2->setFont(QFont(QStringLiteral("Helvetica"), 15, QFont::Bold, false));
m_introLabel2->setDefaultTextColor(QColor(QLatin1Literal("#FFFF00")));
m_introLabel2->setZValue(4);
// Create the new level label
m_newLevelLabel = new QGraphicsTextItem();
m_newLevelLabel->setFont(QFont(QLatin1Literal("Helvetica"), 35, QFont::Bold, false));
m_newLevelLabel->setFont(QFont(QStringLiteral("Helvetica"), 35, QFont::Bold, false));
m_newLevelLabel->setDefaultTextColor(QColor(QLatin1Literal("#FFFF00")));
m_newLevelLabel->setZValue(4);
// Create the pause label
m_pauseLabel = new QGraphicsTextItem(i18n("PAUSED"));
m_pauseLabel->setFont(QFont(QLatin1Literal("Helvetica"), 35, QFont::Bold, false));
m_pauseLabel->setFont(QFont(QStringLiteral("Helvetica"), 35, QFont::Bold, false));
m_pauseLabel->setDefaultTextColor(QColor(QLatin1Literal("#FFFF00")));
m_pauseLabel->setZValue(4);
......@@ -186,10 +186,10 @@ void GameScene::updateSvgIds()
}
// Set the element Id to the right value
m_mazeItem->setElementId(QLatin1Literal("maze"));
m_mazeItem->setElementId(QStringLiteral("maze"));
// Create the KapmanItem
m_kapmanItem->setElementId(QLatin1Literal("kapman_0"));
m_kapmanItem->setElementId(QStringLiteral("kapman_0"));
// Corrects the position of the KapmanItem
m_kapmanItem->update(m_game->getKapman()->getX(), m_game->getKapman()->getY());
......@@ -217,7 +217,7 @@ void GameScene::updateThemeProperties()
}
// Set the Rotation flag for KapmanItem
if (m_theme->themeProperty(QLatin1Literal("RotateKapman")) == QLatin1String("0")) {
if (m_theme->themeProperty(QStringLiteral("RotateKapman")) == QLatin1String("0")) {
m_kapmanItem->setRotationFlag(false);
} else {
m_kapmanItem->setRotationFlag(true);
......@@ -325,25 +325,25 @@ void GameScene::displayBonus()
if (!items().contains(m_bonusItem)) {
switch (m_game->getLevel()) {
case 1:
m_bonusItem->setElementId(QLatin1Literal("bonus1"));
m_bonusItem->setElementId(QStringLiteral("bonus1"));
break;
case 2:
m_bonusItem->setElementId(QLatin1Literal("bonus2"));
m_bonusItem->setElementId(QStringLiteral("bonus2"));
break;
case 3:
m_bonusItem->setElementId(QLatin1Literal("bonus3"));
m_bonusItem->setElementId(QStringLiteral("bonus3"));
break;
case 4:
m_bonusItem->setElementId(QLatin1Literal("bonus4"));
m_bonusItem->setElementId(QStringLiteral("bonus4"));
break;
case 5:
m_bonusItem->setElementId(QLatin1Literal("bonus5"));
m_bonusItem->setElementId(QStringLiteral("bonus5"));
break;
case 6:
m_bonusItem->setElementId(QLatin1Literal("bonus6"));
m_bonusItem->setElementId(QStringLiteral("bonus6"));
break;
default:
m_bonusItem->setElementId(QLatin1Literal("bonus7"));
m_bonusItem->setElementId(QStringLiteral("bonus7"));
break;
}
m_bonusItem->update(m_game->getBonus()->getX(), m_game->getBonus()->getY());
......@@ -361,7 +361,7 @@ void GameScene::hideBonus()
void GameScene::displayPoints(long p_wonPoints, qreal p_xPos, qreal p_yPos)
{
// Launch a singleShot timer
QTimer::singleShot(1000, this, SLOT(hidePoints()));
QTimer::singleShot(1000, this, &GameScene::hidePoints);
// Add a label in the list of won points Labels
m_wonPointsLabels.prepend(new QGraphicsTextItem(QString::number(p_wonPoints)));
......@@ -372,7 +372,7 @@ void GameScene::displayPoints(long p_wonPoints, qreal p_xPos, qreal p_yPos)
// Positioning and customization of the point label
tempRef->setDefaultTextColor(QColor(QLatin1Literal("#FFFF00")));
tempRef->setFont(QFont(QLatin1Literal("Helvetica"), 15, QFont::Normal, false));
tempRef->setFont(QFont(QStringLiteral("Helvetica"), 15, QFont::Normal, false));
tempRef->setPos(p_xPos - (tempRef->boundingRect().width() / 2), p_yPos - (tempRef->boundingRect().height() / 2));
tempRef->setZValue(-1);
}
......
......@@ -23,7 +23,7 @@ GameView::GameView(Game *p_game) : QGraphicsView(new GameScene(p_game))
setFrameStyle(QFrame::NoFrame);
setFocusPolicy(Qt::StrongFocus);
// Forward the key press events to the Game instance
connect(this, SIGNAL(keyPressed(QKeyEvent*)), p_game, SLOT(keyPressEvent(QKeyEvent*)));
connect(this, &GameView::keyPressed, p_game, &Game::keyPressEvent);
}
GameView::~GameView()
......
......@@ -21,7 +21,7 @@
GhostItem::GhostItem(Ghost *p_model) : CharacterItem(p_model)
{
connect(p_model, SIGNAL(stateChanged()), this, SLOT(updateState()));
connect(p_model, &Ghost::stateChanged, this, &GhostItem::updateState);
// Calculations for the duration of blinking stuff
int blinkTimerDuration = (int)(500 * Game::s_durationRatio);
......@@ -74,7 +74,7 @@ void GhostItem::updateState()
switch (((Ghost *)getModel())->getState()) {
case Ghost::PREY:
updateBlinkTimersDuration();
setElementId(QLatin1Literal("scaredghost"));
setElementId(QStringLiteral("scaredghost"));
m_startBlinkingTimer->start();
// The ghosts are now weaker than the kapman, so they are under him
setZValue(1);
......@@ -85,7 +85,7 @@ void GhostItem::updateState()
setZValue(3);
break;
case Ghost::EATEN:
setElementId(QLatin1Literal("ghosteye"));
setElementId(QStringLiteral("ghosteye"));
// The ghosts are now weaker than the kapman, so they are under him
setZValue(1);
break;
......@@ -96,9 +96,9 @@ void GhostItem::blink()
{
CharacterItem::blink();
if (m_nbBlinks % 2 == 0) {
setElementId(QLatin1Literal("scaredghost"));
setElementId(QStringLiteral("scaredghost"));
} else {
setElementId(QLatin1Literal("whitescaredghost"));
setElementId(QStringLiteral("whitescaredghost"));
}
}
......@@ -31,9 +31,9 @@ const int KapmanItem::ANIM_HIGH_SPEED = 300;
KapmanItem::KapmanItem(Kapman *p_model) : CharacterItem(p_model)
{
connect(p_model, SIGNAL(directionChanged()), this, SLOT(updateDirection()));
connect(p_model, SIGNAL(gameUpdated()), this, SLOT(manageCollision()));
connect(p_model, SIGNAL(stopped()), this, SLOT(stopAnim()));
connect(p_model, &Kapman::directionChanged, this, &KapmanItem::updateDirection);
connect(p_model, &Kapman::gameUpdated, this, &KapmanItem::manageCollision);
connect(p_model, &Kapman::stopped, this, &KapmanItem::stopAnim);
// A timeLine for the Kapman animation
m_animationTimer = new QTimeLine();
......@@ -146,7 +146,7 @@ void KapmanItem::resumeAnim()
void KapmanItem::stopAnim()
{
setElementId(QLatin1Literal("kapman_0"));
setElementId(QStringLiteral("kapman_0"));
if (m_animationTimer->state() == QTimeLine::Running) {
m_animationTimer->stop();
}
......@@ -154,13 +154,13 @@ void KapmanItem::stopAnim()
void KapmanItem::setFrame(const int p_frame)
{
setElementId(QString::fromLatin1("kapman_%1").arg(p_frame));
setElementId(QStringLiteral("kapman_%1").arg(p_frame));
}
void KapmanItem::startBlinking()
{
stopAnim();
setElementId(QLatin1Literal("kapman_0"));
setElementId(QStringLiteral("kapman_0"));
CharacterItem::startBlinking();
}
......@@ -168,9 +168,9 @@ void KapmanItem::blink()
{
CharacterItem::blink();
if (m_nbBlinks % 2 == 0) {
setElementId(QLatin1Literal("kapman_0"));
setElementId(QStringLiteral("kapman_0"));
} else {
setElementId(QLatin1Literal("kapman_blink"));
setElementId(QStringLiteral("kapman_blink"));
}
// Make the kapman blink 2 times (4 ticks)
if (m_nbBlinks == 4) {
......
......@@ -49,10 +49,10 @@ KapmanMainWindow::KapmanMainWindow()
KStandardGameAction::quit(this, SLOT(close()), actionCollection());
KToggleAction *soundAction = new KToggleAction(i18n("&Play sounds"), this);
soundAction->setChecked(Settings::sounds());
actionCollection()->addAction(QLatin1String("sounds"), soundAction);
actionCollection()->addAction(QStringLiteral("sounds"), soundAction);
connect(soundAction, &KToggleAction::triggered, this, &KapmanMainWindow::setSoundsEnabled);
QAction *levelAction = new QAction(i18n("&Change level"), this);
actionCollection()->addAction(QLatin1String("level"), levelAction);
actionCollection()->addAction(QStringLiteral("level"), levelAction);
connect(levelAction, &QAction::triggered, this, &KapmanMainWindow::changeLevel);
// Add a statusbar to show level,score,lives information
m_statusBar = statusBar();
......@@ -69,7 +69,7 @@ KapmanMainWindow::KapmanMainWindow()
KgDifficultyLevel::Medium //default
);
KgDifficultyGUI::init(this);
connect(Kg::difficulty(), SIGNAL(currentLevelChanged(const KgDifficultyLevel*)), SLOT(initGame()));
connect(Kg::difficulty(), &KgDifficulty::currentLevelChanged, this, &KapmanMainWindow::initGame);
// Setup the window
setupGUI();
......@@ -88,7 +88,7 @@ void KapmanMainWindow::initGame()
// Create a new Game instance
delete m_game;
m_game = new Game();
connect(m_game, SIGNAL(gameOver(bool)), this, SLOT(newGame(bool))); // TODO Remove the useless bool parameter from gameOver()
connect(m_game, &Game::gameOver, this, &KapmanMainWindow::newGame); // TODO Remove the useless bool parameter from gameOver()
connect(m_game, &Game::levelChanged, this, &KapmanMainWindow::displayLevel);
connect(m_game, &Game::scoreChanged, this, &KapmanMainWindow::displayScore);
connect(m_game, &Game::livesChanged, this, &KapmanMainWindow::displayLives);
......@@ -175,11 +175,11 @@ void KapmanMainWindow::setSoundsEnabled(bool p_enabled)
void KapmanMainWindow::showSettings()
{
if (KConfigDialog::showDialog(QLatin1Literal("settings"))) {
if (KConfigDialog::showDialog(QStringLiteral("settings"))) {
return;
}
KConfigDialog *settingsDialog = new KConfigDialog(this, QLatin1Literal("settings"), Settings::self());
settingsDialog->addPage(new KGameThemeSelector(settingsDialog, Settings::self(), KGameThemeSelector::NewStuffDisableDownload), i18n("Theme"), QLatin1Literal("kapman"));
KConfigDialog *settingsDialog = new KConfigDialog(this, QStringLiteral("settings"), Settings::self());
settingsDialog->addPage(new KGameThemeSelector(settingsDialog, Settings::self(), KGameThemeSelector::NewStuffDisableDownload), i18n("Theme"), QStringLiteral("kapman"));
settingsDialog->setFaceType(KConfigDialog::Plain); //only one page -> no page selection necessary
connect(settingsDialog, &KConfigDialog::settingsChanged, this, &KapmanMainWindow::loadSettings);
settingsDialog->show();
......
......@@ -140,11 +140,11 @@ bool KapmanParser::endElement(const QString &, const QString &, const QString &p
break;
case '.': m_game->getMaze()->setCellType(m_counterRows, i, Cell::CORRIDOR);
m_game->getMaze()->setCellElement(m_counterRows, i,
new Pill(m_counterRows, i, m_game->getMaze(), QLatin1String("pill")));
new Pill(m_counterRows, i, m_game->getMaze(), QStringLiteral("pill")));
break;
case 'o': m_game->getMaze()->setCellType(m_counterRows, i, Cell::CORRIDOR);
m_game->getMaze()->setCellElement(m_counterRows, i,
new Energizer(m_counterRows, i, m_game->getMaze(), QLatin1String("energizer")));
new Energizer(m_counterRows, i, m_game->getMaze(), QStringLiteral("energizer")));
break;
case 'x': m_game->getMaze()->setCellType(m_counterRows, i, Cell::GHOSTCAMP);
break;
......
......@@ -35,7 +35,7 @@ int main(int argc, char **argv)
migrate.migrate();
KLocalizedString::setApplicationDomain("kapman");
// About Kapman
KAboutData about(QStringLiteral("kapman"), i18n("Kapman"), QLatin1String("1.1.0"),
KAboutData about(QStringLiteral("kapman"), i18n("Kapman"), QStringLiteral("1.1.0"),
i18n("Kapman: Go through the levels escaping ghosts!"),
KAboutLicense::GPL, i18n("Copyright (c) 2007-2008 The KapTeam"));
// Alphabetical order of Developers of Kapman
......
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