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

Port to qdebug categories

parent e6d4ef8e
......@@ -30,7 +30,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
......@@ -48,4 +48,5 @@ endif()
add_subdirectory(src)
add_subdirectory(data)
add_subdirectory(doc)
install( FILES kigo.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR} )
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
org.kde.kdegames.kigo kigo (kdegames) IDENTIFIER [KIGO_LOG]
......@@ -22,6 +22,8 @@ ki18n_wrap_ui(kigo_SRCS
gui/widgets/gamewidget.ui
gui/widgets/setupwidget.ui
)
ecm_qt_declare_logging_category(kigo_SRCS HEADER kigo_debug.h IDENTIFIER KIGO_LOG CATEGORY_NAME org.kde.kdegames.kigo)
kconfig_add_kcfg_files(kigo_SRCS preferences.kcfgc)
file(GLOB ICONS_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/../data/icons/*-apps-kigo.png")
ecm_add_app_icon(kigo_SRCS ICONS ${ICONS_SRCS})
......
......@@ -24,7 +24,7 @@
#include <KLocalizedString>
#include <QApplication>
#include <QDebug>
#include "kigo_debug.h"
#include <QFile>
namespace Kigo {
......@@ -72,11 +72,11 @@ bool Game::start(const QString &command)
m_process.start(command); // Start new process with provided command
if (!m_process.waitForStarted()) { // Blocking wait for process start
m_response = QLatin1String("Unable to execute command: ") + command;
//qDebug() << m_response;
//qCDebug(KIGO_LOG) << m_response;
return false;
}
m_engineCommand = command;
////qDebug() << "Game" << command << "started...";
////qCDebug(KIGO_LOG) << "Game" << command << "started...";
// Test if we started a GTP-compatible Go game
m_process.write("name\n");
......@@ -84,13 +84,13 @@ bool Game::start(const QString &command)
const QString response = m_process.readAllStandardOutput();
if (response.isEmpty() || !response.startsWith(QLatin1Char('='))) {
m_response = QStringLiteral("Game did not respond to GTP command \"name\"");
//qDebug() << m_response;
//qCDebug(KIGO_LOG) << m_response;
stop();
return false;
} else {
m_engineName = m_response;
}
//qDebug() << "Game is a GTP-compatible Go game";
//qCDebug(KIGO_LOG) << "Game is a GTP-compatible Go game";
m_process.write("version\n");
if (waitResponse()) {
......@@ -113,7 +113,7 @@ bool Game::init()
return false;
}
//qDebug() << "Init game!";
//qCDebug(KIGO_LOG) << "Init game!";
m_process.write("clear_board\n");
if (waitResponse()) {
......@@ -160,7 +160,7 @@ bool Game::init(const QString &fileName, int moveNumber)
if (waitResponse()) {
m_fixedHandicap = m_response.toInt();
}
//qDebug() << "Loaded komi is" << m_komi << "and handicap is" << m_fixedHandicap;
//qCDebug(KIGO_LOG) << "Loaded komi is" << m_komi << "and handicap is" << m_fixedHandicap;
m_consecutivePassMoveNumber = 0;
m_currentMove = moveNumber;
......@@ -247,7 +247,7 @@ bool Game::setFixedHandicap(int handicap)
return false;
}
} else {
//qWarning() << "Handicap" << handicap << " not set, it is too high!";
//qCWarning(KIGO_LOG) << "Handicap" << handicap << " not set, it is too high!";
return false;
}
}
......@@ -285,7 +285,7 @@ bool Game::playMove(const Player &player, const Stone &stone, bool undoable)
const Player *tmp = &player;
if (!tmp->isValid()) {
//qDebug() << "Invalid player argument, using current player!";
//qCDebug(KIGO_LOG) << "Invalid player argument, using current player!";
tmp = m_currentPlayer;
}
......@@ -339,7 +339,7 @@ bool Game::playMove(const Player &player, const Stone &stone, bool undoable)
undoStr = i18n("Black passed");
}
}
//qDebug() << "Push new undo command" << undoStr;
//qCDebug(KIGO_LOG) << "Push new undo command" << undoStr;
m_undoStack.push(new UndoCommand(playerTemp, moveType, undoStr));
}
......@@ -363,7 +363,7 @@ bool Game::generateMove(const Player &player, bool undoable)
}
const Player *tmp = &player;
if (!tmp->isValid()) {
//qDebug() << "Invalid player argument, using current player!";
//qCDebug(KIGO_LOG) << "Invalid player argument, using current player!";
tmp = m_currentPlayer;
}
......@@ -424,7 +424,7 @@ bool Game::generateMove(const Player &player, bool undoable)
}
if (undoable) {
//qDebug() << "Push new undo command" << undoStr;
//qCDebug(KIGO_LOG) << "Push new undo command" << undoStr;
m_undoStack.push(new UndoCommand(playerTemp, moveType, undoStr));
}
if (tmp->isWhite()) {
......@@ -489,17 +489,17 @@ bool Game::redoMove()
const Player *player = undoCmd->player();
if (undoCmd->moveType() == UndoCommand::MoveType::Passed) {
//qDebug() << "Redo a pass move for" << player << undoCmd->text();
//qCDebug(KIGO_LOG) << "Redo a pass move for" << player << undoCmd->text();
playMove(*player, Stone(), false); // E.g. pass move
} else if (undoCmd->moveType() == UndoCommand::MoveType::Resigned) {
// Note: Although it is possible to undo after a resign and redo it,
// it is a bit questionable whether this makes sense logically.
//qDebug() << "Redo a resign for" << player << undoCmd->text();
//qCDebug(KIGO_LOG) << "Redo a resign for" << player << undoCmd->text();
emit resigned(*player);
m_gameFinished = true;
//emit resigned(*m_currentPlayer);
} else {
//qDebug() << "Redo a normal move for" << player << undoCmd->text();
//qCDebug(KIGO_LOG) << "Redo a normal move for" << player << undoCmd->text();
playMove(*player, Stone(undoCmd->text()), false);
}
m_undoStack.redo();
......@@ -722,7 +722,7 @@ bool Game::waitResponse(bool nonBlocking)
case QProcess::ReadError: m_response = m_process.readAllStandardError(); break;
case QProcess::UnknownError: m_response = QStringLiteral("Unknown error!"); break;
}
qWarning() << "Command failed:" << m_response;
qCWarning(KIGO_LOG) << "Command failed:" << m_response;
return false;
}
......
......@@ -20,7 +20,7 @@
#include "move.h"
#include <QDebug>
#include "kigo_debug.h"
namespace Kigo {
......
......@@ -20,7 +20,7 @@
#include "player.h"
#include <QDebug>
#include "kigo_debug.h"
namespace Kigo {
......
......@@ -20,7 +20,7 @@
#include "stone.h"
#include <QDebug>
#include "kigo_debug.h"
namespace Kigo {
......
......@@ -249,7 +249,7 @@ void GameScene::updateTerritoryItems()
if (m_showTerritory) {
QPixmap stonePixmap;
const int halfCellSize = m_cellSize / 2;
//qDebug() << "Fetching territory from engine ...";
//qCDebug(KIGO_LOG) << "Fetching territory from engine ...";
stonePixmap = ThemeRenderer::self()->renderElement(ThemeRenderer::Element::WhiteTerritory, QSize(m_cellSize, m_cellSize));
foreach (const Stone &stone, m_game->finalStates(Game::FinalState::FinalWhiteTerritory)) {
......
......@@ -38,7 +38,7 @@ ThemeRenderer::ThemeRenderer()
{
QPixmapCache::setCacheLimit(3 * 1024);
if (!loadTheme(Preferences::theme())) {
//qDebug() << "Failed to load any game theme!";
//qCDebug(KIGO_LOG) << "Failed to load any game theme!";
}
}
......@@ -52,7 +52,7 @@ bool ThemeRenderer::loadTheme(const QString &themeName)
bool discardCache = !m_currentTheme.isEmpty();
if (!m_currentTheme.isEmpty() && m_currentTheme == themeName) {
//qDebug() << "Notice: Loading the same theme";
//qCDebug(KIGO_LOG) << "Notice: Loading the same theme";
return true; // We don't have to do anything
}
......@@ -60,8 +60,8 @@ bool ThemeRenderer::loadTheme(const QString &themeName)
KGameTheme theme;
if (themeName.isEmpty() || !theme.load(themeName)) {
//qDebug() << "Failed to load theme" << Preferences::theme();
//qDebug() << "Trying to load default";
//qCDebug(KIGO_LOG) << "Failed to load theme" << Preferences::theme();
//qCDebug(KIGO_LOG) << "Trying to load default";
if (!theme.loadDefault()) {
return true;
}
......@@ -70,13 +70,13 @@ bool ThemeRenderer::loadTheme(const QString &themeName)
m_currentTheme = QStringLiteral("default");
}
//qDebug() << "Loading" << theme.graphics();
//qCDebug(KIGO_LOG) << "Loading" << theme.graphics();
if (!m_renderer->load(theme.graphics())) {
return false;
}
if (discardCache) {
//qDebug() << "Discarding cache";
//qCDebug(KIGO_LOG) << "Discarding cache";
QPixmapCache::clear();
}
emit themeChanged(m_currentTheme);
......
......@@ -268,7 +268,7 @@ void MainWindow::finishGame()
m_undoView->setEnabled(false);
//qDebug() << "Fetching final score from engine ...";
//qCDebug(KIGO_LOG) << "Fetching final score from engine ...";
Score score = m_game->estimatedScore();
QString name;
if (score.color() == QLatin1Char('W')) {
......@@ -333,7 +333,7 @@ void MainWindow::showPreferences()
void MainWindow::applyPreferences()
{
//qDebug() << "Update settings based on changed configuration...";
//qCDebug(KIGO_LOG) << "Update settings based on changed configuration...";
m_gameScene->showLabels(Preferences::showBoardLabels());
ThemeRenderer::self()->loadTheme(Preferences::theme());
......
......@@ -45,7 +45,7 @@ GameWidget::GameWidget(Game *game, QWidget *parent)
void GameWidget::init()
{
if (!m_game->isRunning()) {
//qDebug() << "Game is not running, no information update";
//qCDebug(KIGO_LOG) << "Game is not running, no information update";
return;
}
......
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