[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kollision] /: Compile with strict compile flags. Add nullptr/ initialize some
From: Laurent Montel <null () kde ! org>
Date: 2018-08-01 6:14:52
Message-ID: E1fkkPM-0000x4-H1 () code ! kde ! org
[Download RAW message or body]
Git commit 58124d3900d18c636f49fa83f4b092c82657eb61 by Laurent Montel.
Committed on 01/08/2018 at 06:14.
Pushed by mlaurent into branch 'master'.
Compile with strict compile flags. Add nullptr/ initialize some
variables
M +6 -1 CMakeLists.txt
M +3 -2 animator.h
M +2 -1 ball.h
M +5 -5 main.cpp
M +17 -17 mainarea.cpp
M +1 -0 mainarea.h
M +5 -5 mainwindow.cpp
M +9 -7 mainwindow.h
M +2 -1 message.cpp
M +2 -1 message.h
https://commits.kde.org/kollision/58124d3900d18c636f49fa83f4b092c82657eb61
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1269fe4..8631f2a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,7 +28,12 @@ include(KDEInstallDirs)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(KDECMakeSettings)
-add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
+add_definitions(-DQT_USE_FAST_OPERATOR_PLUS)
+add_definitions(-DTRANSLATION_DOMAIN="kdebugsettings")
+add_definitions("-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII")
+add_definitions( -DQT_DISABLE_DEPRECATED_BEFORE=0x060000 )
+add_definitions(-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT)
+add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
add_subdirectory(pictures)
add_subdirectory(sounds)
diff --git a/animator.h b/animator.h
index f0ff90a..3fc944e 100644
--- a/animator.h
+++ b/animator.h
@@ -17,8 +17,6 @@
class Animator : public AnimationGroup
{
Q_OBJECT
- QTimer m_timer;
- QTime m_time;
public:
Animator();
@@ -27,6 +25,9 @@ public:
void add(Animation* a);
public slots:
void tick();
+private:
+ QTimer m_timer;
+ QTime m_time;
};
#endif // ANIMATOR_H
diff --git a/ball.h b/ball.h
index bcd20b3..3458a09 100644
--- a/ball.h
+++ b/ball.h
@@ -19,7 +19,6 @@ class KGameRenderer;
class Ball : public KGameRenderedItem, public Sprite
{
- QPointF m_velocity;
public:
Ball(KGameRenderer* renderer, const QString& id, int size);
@@ -33,6 +32,8 @@ public:
QPointF position() const Q_DECL_OVERRIDE;
qreal radius() const;
+private:
+ QPointF m_velocity;
};
#endif // BALL_H
diff --git a/main.cpp b/main.cpp
index 14ab710..1ed7476 100644
--- a/main.cpp
+++ b/main.cpp
@@ -30,14 +30,14 @@ int main(int argc, char *argv[])
migrate.setUiFiles(QStringList() << QStringLiteral("kollisionui.rc"));
migrate.migrate();
- KAboutData aboutData("kollision", i18n("Kollision"),
- "0.3", i18n("KDE collision game"), KAboutLicense::GPL,
+ KAboutData aboutData(QStringLiteral("kollision"), i18n("Kollision"),
+ QStringLiteral("0.3"), i18n("KDE collision game"), \
KAboutLicense::GPL, i18n("(c) 2007 Paolo Capriotti"));
- aboutData.addAuthor(i18n("Paolo Capriotti"), QString(), \
"p.capriotti@gmail.com");
- aboutData.addAuthor(i18n("Dmitry Suzdalev"), QString(), "dimsuz@gmail.com");
+ aboutData.addAuthor(i18n("Paolo Capriotti"), QString(), \
QStringLiteral("p.capriotti@gmail.com")); + aboutData.addAuthor(i18n("Dmitry \
Suzdalev"), QString(), QStringLiteral("dimsuz@gmail.com")); \
aboutData.addCredit(i18n("Matteo Guarnieri"), i18n("Original idea"));
aboutData.addCredit(i18n("Brian Croom"), i18n("Port to use KGameRenderer"));
- aboutData.setHomepage("http://games.kde.org/kollision");
+ aboutData.setHomepage(QStringLiteral("http://games.kde.org/kollision"));
app.setWindowIcon(QIcon::fromTheme(QLatin1String("kollision")));
diff --git a/mainarea.cpp b/mainarea.cpp
index 1aa2b52..e8c595b 100644
--- a/mainarea.cpp
+++ b/mainarea.cpp
@@ -38,13 +38,13 @@ struct Theme : public KgTheme
{
Theme() : KgTheme("pictures/theme.desktop")
{
- setGraphicsPath(QStandardPaths::locate(QStandardPaths::AppDataLocation, \
"pictures/theme.svgz")); + \
setGraphicsPath(QStandardPaths::locate(QStandardPaths::AppDataLocation, \
QStringLiteral("pictures/theme.svgz"))); }
};
MainArea::MainArea()
: m_renderer(new Theme)
-, m_man(0)
+, m_man(nullptr)
, m_manBallDiameter(28)
, m_ballDiameter(28)
, m_death(false)
@@ -52,11 +52,11 @@ MainArea::MainArea()
, m_paused(false)
, m_pauseTime(0)
, m_penalty(0)
-, m_soundHitWall(QStandardPaths::locate(QStandardPaths::AppDataLocation, \
"sounds/hit_wall.ogg"))
-, m_soundYouLose(QStandardPaths::locate(QStandardPaths::AppDataLocation, \
"sounds/you_lose.ogg"))
-, m_soundBallLeaving(QStandardPaths::locate(QStandardPaths::AppDataLocation, \
"sounds/ball_leaving.ogg"))
-, m_soundStart(QStandardPaths::locate(QStandardPaths::AppDataLocation, \
"sounds/start.ogg"))
-, m_pauseAction(0)
+, m_soundHitWall(QStandardPaths::locate(QStandardPaths::AppDataLocation, \
QStringLiteral("sounds/hit_wall.ogg"))) +, \
m_soundYouLose(QStandardPaths::locate(QStandardPaths::AppDataLocation, \
QStringLiteral("sounds/you_lose.ogg"))) +, \
m_soundBallLeaving(QStandardPaths::locate(QStandardPaths::AppDataLocation, \
QStringLiteral("sounds/ball_leaving.ogg"))) +, \
m_soundStart(QStandardPaths::locate(QStandardPaths::AppDataLocation, \
QStringLiteral("sounds/start.ogg"))) +, m_pauseAction(nullptr)
{
// Initialize the sound state
@@ -132,7 +132,7 @@ Animation* MainArea::writeMessage(const QString& text)
Animation* MainArea::writeText(const QString& text, bool fade)
{
m_welcomeMsg.clear();
- foreach (const QString &line, text.split('\n')) {
+ foreach (const QString &line, text.split(QLatin1Char('\n'))) {
m_welcomeMsg.append(
QExplicitlySharedDataPointer<Message>(new Message(line, m_msgFont, \
m_size))); }
@@ -150,7 +150,7 @@ Animation* MainArea::writeText(const QString& text, bool fade)
return anim;
}
else {
- return 0;
+ return nullptr;
}
}
@@ -204,7 +204,7 @@ void MainArea::togglePause()
m_timer.stop();
QString shortcut = m_pauseAction ?
m_pauseAction->shortcut().toString() :
- "P";
+ QStringLiteral("P");
writeText(i18n("Game paused\nClick or press %1 to resume", shortcut), \
false);
if(m_lastGameTime >= 5) {
@@ -254,10 +254,10 @@ void MainArea::start()
m_welcomeMsg.clear();
- addBall("red_ball");
- addBall("red_ball");
- addBall("red_ball");
- addBall("red_ball");
+ addBall(QStringLiteral("red_ball"));
+ addBall(QStringLiteral("red_ball"));
+ addBall(QStringLiteral("red_ball"));
+ addBall(QStringLiteral("red_ball"));
m_pauseTime = 0;
m_penalty = 0;
@@ -359,7 +359,7 @@ void MainArea::abort()
m_man->setVelocity(QPointF(0, 0));
m_balls.push_back(m_man);
- m_man = 0;
+ m_man = nullptr;
emit changeState(false);
foreach (Ball* fball, m_fading) {
@@ -528,7 +528,7 @@ void MainArea::tick()
}
}
- addBall("red_ball");
+ addBall(QStringLiteral("red_ball"));
writeMessage(i18np("%1 ball", "%1 balls", m_balls.size() + 1));
}
@@ -571,7 +571,7 @@ void MainArea::mousePressEvent(QGraphicsSceneMouseEvent* e)
setManPosition(e->scenePos());
}
else if (!m_man) {
- m_man = new Ball(&m_renderer, "blue_ball", \
static_cast<int>(radius()*2)); + m_man = new Ball(&m_renderer, \
QStringLiteral("blue_ball"), static_cast<int>(radius()*2)); m_man->setZValue(1.0);
setManPosition(e->scenePos());
addItem(m_man);
diff --git a/mainarea.h b/mainarea.h
index a8fee8c..782ad21 100644
--- a/mainarea.h
+++ b/mainarea.h
@@ -31,6 +31,7 @@ struct Collision;
class MainArea : public QGraphicsScene
{
Q_OBJECT
+private:
QTimer m_timer;
int m_lastTime;
int m_lastGameTime;
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 9760ba3..82f47d3 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -55,10 +55,10 @@ MainWindow::MainWindow()
// setup status bar
QStatusBar* bar = statusBar();
Q_ASSERT(bar);
- m_time_label = new QLabel("");
+ m_time_label = new QLabel;
bar->addPermanentWidget(m_time_label);
- m_balls_label = new QLabel("");
+ m_balls_label = new QLabel;
bar->addWidget(m_balls_label);
// bar->setItemAlignment(STATUSBAR_BALLS, Qt::AlignLeft);
@@ -67,7 +67,7 @@ MainWindow::MainWindow()
connect(m_main, &MainArea::changeState, this, &MainWindow::changeState);
connect(m_main, &MainArea::pause, this, &MainWindow::pause);
- stateChanged("playing", KXMLGUIClient::StateReverse);
+ stateChanged(QStringLiteral("playing"), KXMLGUIClient::StateReverse);
connect(m_main, &MainArea::starting, this, &MainWindow::newGame);
connect(m_main, &MainArea::gameOver, this, &MainWindow::gameOver);
}
@@ -105,13 +105,13 @@ void MainWindow::setupActions()
void MainWindow::newGame()
{
- stateChanged("playing");
+ stateChanged(QStringLiteral("playing"));
m_lastUsedDifficulty = Kg::difficulty()->currentLevel();
}
void MainWindow::gameOver(int time)
{
- stateChanged("playing", KXMLGUIClient::StateReverse);
+ stateChanged(QStringLiteral("playing"), KXMLGUIClient::StateReverse);
QPointer<KScoreDialog> ksdialog = new KScoreDialog(KScoreDialog::Name, this);
ksdialog->initFromDifficulty(Kg::difficulty(), /*setConfigGroup=*/ false);
diff --git a/mainwindow.h b/mainwindow.h
index 1bb82ed..240c1f3 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -20,13 +20,6 @@ class MainArea;
class MainWindow : public KXmlGuiWindow
{
Q_OBJECT
- QLabel* m_balls_label;
- QLabel* m_time_label;
- Ui_Preferences m_pref_ui;
- MainArea* m_main;
- const KgDifficultyLevel* m_lastUsedDifficulty;
-
- void showCursor(bool show);
public:
MainWindow();
~MainWindow();
@@ -41,6 +34,15 @@ protected slots:
void highscores();
void changeState(bool);
void pause(bool);
+private:
+ QLabel* m_balls_label = nullptr;
+ QLabel* m_time_label = nullptr;
+ Ui_Preferences m_pref_ui;
+ MainArea* m_main = nullptr;
+ const KgDifficultyLevel* m_lastUsedDifficulty = nullptr;
+
+ void showCursor(bool show);
+
};
diff --git a/message.cpp b/message.cpp
index d9751f1..fffcdd0 100644
--- a/message.cpp
+++ b/message.cpp
@@ -59,6 +59,7 @@ QPointF Message::position() const
return QGraphicsTextItem::pos();
}
-int Message::height() const {
+int Message::height() const
+{
return document()->size().height();
}
diff --git a/message.h b/message.h
index 269bab7..8ed8255 100644
--- a/message.h
+++ b/message.h
@@ -16,7 +16,6 @@
class Message : public QGraphicsTextItem, public Sprite
{
- QPointF m_velocity;
public:
Message(const QString& text, const QFont& font, int maxwidth);
@@ -30,6 +29,8 @@ public:
QPointF position() const Q_DECL_OVERRIDE;
int height() const;
+private:
+ QPointF m_velocity;
};
typedef QExplicitlySharedDataPointer<Message> MessagePtr;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic