Commit 5c38e113 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port to qdebug categories

parent a43e8c52
......@@ -27,6 +27,7 @@ include(ECMInstallIcons)
include(KDEInstallDirs)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(KDECMakeSettings)
include(ECMQtDeclareLoggingCategory)
add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
#add_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII)
......@@ -38,5 +39,5 @@ add_subdirectory(src)
add_subdirectory(data)
add_subdirectory(doc)
add_subdirectory(kconf_update)
install(FILES knavalbattle.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR})
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
org.kde.kdegames.knavalbattle knavalbattle (kdegames) IDENTIFIER [KNAVALBATTLE_LOG]
......@@ -39,7 +39,7 @@ set(knavalbattle_SRCS
welcomescreen.cpp
)
ecm_qt_declare_logging_category(knavalbattle_SRCS HEADER knavalbattle_debug.h IDENTIFIER KNAVALBATTLE_LOG CATEGORY_NAME org.kde.kdegames.knavalbattle)
kconfig_add_kcfg_files(knavalbattle_SRCS settingsbase.kcfgc)
file(GLOB ICONS_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/../data/pictures/*-apps-knavalbattle.png")
ecm_add_app_icon(knavalbattle_SRCS ICONS ${ICONS_SRCS})
......
......@@ -129,7 +129,7 @@ public:
else {
if (!next_try()) {
// give up
qDebug() << "giving up (m_direction =" << m_direction << ")";
qCDebug(KNAVALBATTLE_LOG) << "giving up (m_direction =" << m_direction << ")";
return m_state.defaultStrategy(m_player, m_sea);
}
}
......@@ -227,7 +227,7 @@ class DiagonalStrategy : public Strategy
auto *generator = QRandomGenerator::global();
do {
m_offset = generator->bounded(m_gap);
qDebug() << "offset =" << m_offset << " / " << m_gap;
qCDebug(KNAVALBATTLE_LOG) << "offset =" << m_offset << " / " << m_gap;
} while (!movesAvailable());
m_range = 0;
......@@ -258,7 +258,7 @@ public:
{
if (!movesAvailable()) {
qDebug() << "no moves available";
qCDebug(KNAVALBATTLE_LOG) << "no moves available";
setup();
}
for (int i = 0; i < 50; i++) {
......
......@@ -7,7 +7,7 @@
(at your option) any later version.
*/
#include "animation.h"
#include <QDebug>
#include "knavalbattle_debug.h"
Animation::~Animation()
{
......
......@@ -13,7 +13,7 @@
#include <QPainter>
#include <QPen>
#include <QImage>
#include <QDebug>
#include "knavalbattle_debug.h"
#include <math.h> // fabs
......@@ -193,7 +193,7 @@ void Button::onMouseLeave()
bool Button::onClicked()
{
if (true) {
qDebug() << "clicked";
qCDebug(KNAVALBATTLE_LOG) << "clicked";
emit clicked();
return true;
}
......@@ -243,7 +243,7 @@ bool ButtonAnimation::step(int t)
int sign = (m_button->brightness() > m_brightness) ? -1 : 1;
double delta = (t - m_last) * m_speed;
// qDebug() << "button step t =" << t << "sign =" << sign << "delta =" << delta;
// qCDebug(KNAVALBATTLE_LOG) << "button step t =" << t << "sign =" << sign << "delta =" << delta;
m_last = t;
if (fabs(m_button->brightness() - m_brightness) <= delta) {
m_button->setBrightness(m_brightness);
......
......@@ -35,7 +35,7 @@ PlayerEntity* Controller::createPlayer(Sea::Player player, SeaView* view,
ChatWidget* chat, const QString& nick)
{
if (m_ui) {
qDebug() << "Cannot create more than one human player";
qCDebug(KNAVALBATTLE_LOG) << "Cannot create more than one human player";
return 0;
}
PlayerEntity* entity = new PlayerEntity(player, m_sea, view, chat);
......@@ -47,7 +47,7 @@ PlayerEntity* Controller::createPlayer(Sea::Player player, SeaView* view,
AIEntity* Controller::createAI(Sea::Player player, SeaView* view)
{
qDebug() << "created ai entity";
qCDebug(KNAVALBATTLE_LOG) << "created ai entity";
m_has_ai = true;
AIEntity* e = new AIEntity(player, m_sea, view);
e->setNick(i18n("Computer"));
......@@ -116,11 +116,11 @@ bool Controller::allPlayers() const
unsigned char bitmap = 0;
foreach (Entity* entity, m_entities) {
int player = entity->player();
qDebug() << "found player" << player;
qCDebug(KNAVALBATTLE_LOG) << "found player" << player;
bitmap |= (1 << player);
}
qDebug() << "bitmap =" << (unsigned) bitmap;
qCDebug(KNAVALBATTLE_LOG) << "bitmap =" << (unsigned) bitmap;
return bitmap == 3;
}
......@@ -178,12 +178,12 @@ void Controller::shoot(int player, const Coord& c)
{
Entity* entity = findEntity(Sea::opponent(Sea::Player(player)));
if (!entity) {
qDebug() << "no entity!";
qCDebug(KNAVALBATTLE_LOG) << "no entity!";
return;
}
if (m_shot) {
qDebug() << "shot in progress";
qCDebug(KNAVALBATTLE_LOG) << "shot in progress";
// shot in progress
return;
}
......@@ -215,7 +215,7 @@ void Controller::finalizeShot(Sea::Player player, const Coord& c, const HitInfo&
}
}
else {
qDebug() << "illegal move" << c << "for player" << player;
qCDebug(KNAVALBATTLE_LOG) << "illegal move" << c << "for player" << player;
}
delete m_shot;
......@@ -305,7 +305,7 @@ void Controller::receivedChat(const QString& text)
if (chat_sender) {
foreach (Entity* entity, m_entities) {
if (entity != chat_sender) {
qDebug() << "forwarding to" << entity->nick();
qCDebug(KNAVALBATTLE_LOG) << "forwarding to" << entity->nick();
entity->notifyChat(chat_sender, text);
}
}
......@@ -314,7 +314,7 @@ void Controller::receivedChat(const QString& text)
void Controller::nick(int player, const QString& nick)
{
qDebug() << "controller: nick";
qCDebug(KNAVALBATTLE_LOG) << "controller: nick";
foreach (Entity* entity, m_entities) {
if (entity->player() != Sea::Player(player)) {
entity->notifyNick(Sea::Player(player), nick);
......
......@@ -11,7 +11,7 @@
#define COORD_H
#include <QMetaType>
#include <QDebug>
#include "knavalbattle_debug.h"
class Coord
{
......
......@@ -10,7 +10,7 @@
#ifndef GRID_H
#define GRID_H
#include <QDebug>
#include "knavalbattle_debug.h"
#include "coord.h"
......
......@@ -193,7 +193,7 @@ void PlayerEntity::registerMiss(Sea::Player player, const Coord&)
void PlayerEntity::notifyChat(const Entity* entity, const QString& text)
{
if (entity != this) {
qDebug() << "received chat from" << entity->nick() << ":" << text;
qCDebug(KNAVALBATTLE_LOG) << "received chat from" << entity->nick() << ":" << text;
m_chat->display(entity->nick(), text);
}
}
......
......@@ -13,7 +13,7 @@
#include <QStatusBar>
#include <QVBoxLayout>
#include <QDebug>
#include "knavalbattle_debug.h"
#include <QInputDialog>
#include <QPointer>
......@@ -178,7 +178,7 @@ void PlayField::gameOver(Sea::Player winner)
info[KScoreDialog::Custom3] = QString::number(stats->misses());
int temp = highscoredialog->addScore(info, KScoreDialog::AskName);
qDebug() << "temp =" << temp;
qCDebug(KNAVALBATTLE_LOG) << "temp =" << temp;
//if (highscoredialog->addScore(info, KScoreDialog::AskName)) {
if (temp != 0) {
highscoredialog->exec();
......@@ -327,7 +327,7 @@ SimpleMenu* PlayField::createAuxMenu()
void PlayField::auxMenuDone()
{
qDebug() << "aux menu done";
qCDebug(KNAVALBATTLE_LOG) << "aux menu done";
SimpleMenu* menu = qobject_cast<SimpleMenu*>(sender());
if (menu) {
delete m_menu;
......
......@@ -163,7 +163,7 @@ void Protocol::readMore()
#define DEF_COORD(var, varx, vary) DEF_ELEMENT(varx); DEF_ELEMENT(vary); Coord var(varx.toInt(), vary.toInt());
MessagePtr Protocol::parseMessage(const QString& xmlMessage)
{
qDebug() << "received:" << xmlMessage;
qCDebug(KNAVALBATTLE_LOG) << "received:" << xmlMessage;
QDomDocument doc;
doc.setContent(xmlMessage);
......@@ -320,7 +320,7 @@ void Protocol::sendNext()
stream << sender.document().toString() << QLatin1Char('\n');
stream.flush();
qDebug() << "sending:" << sender.document().toString();
qCDebug(KNAVALBATTLE_LOG) << "sending:" << sender.document().toString();
}
}
......
......@@ -9,7 +9,7 @@
#include "ship.h"
#include <QDebug>
#include "knavalbattle_debug.h"
Ship::Ship(unsigned int size, Direction direction, Coord position)
: m_size(size)
......
......@@ -9,7 +9,7 @@
#include "welcomescreen.h"
#include <QDebug>
#include "knavalbattle_debug.h"
#include <QIcon>
#include "button.h"
......@@ -96,7 +96,7 @@ Button* WelcomeScreen::addButton(int x, int y, const QIcon& icon, const QString&
refresh();
connect(button, &Button::needsUpdate, this, &WelcomeScreen::refresh);
//qDebug() << "added button" << button;
//qCDebug(KNAVALBATTLE_LOG) << "added button" << button;
return button;
}
......@@ -149,7 +149,7 @@ void WelcomeScreen::onMouseMove(Button *button)
void WelcomeScreen::onMousePress(Button *button)
{
qDebug() << "on mouse press";
qCDebug(KNAVALBATTLE_LOG) << "on mouse press";
button->onMousePress();
m_clicked = button;
......
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