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 2224ac8d authored by Laurent Montel's avatar Laurent Montel 😁

Use debug categories

parent 4fbba7f0
org.kde.palapeli.libpala palapeli (libpala) IDENTIFIER [PALAPELI_LIBPALA_LOG]
org.kde.palapeli palapeli IDENTIFIER [PALAPELI_LOG]
......@@ -44,6 +44,9 @@ set(palapeli_SRCS
window/puzzletablewidget.cpp
window/pieceholder.cpp
)
ecm_qt_declare_logging_category(palapeli_SRCS HEADER palapeli_debug.h IDENTIFIER PALAPELI_LOG CATEGORY_NAME org.kde.palapeli)
kconfig_add_kcfg_files(palapeli_SRCS settings.kcfgc)
ki18n_wrap_ui(palapeli_SRCS settings.ui)
file(GLOB ICONS_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/../pics/*-apps-palapeli.png")
......
......@@ -21,7 +21,7 @@
#include <QCursor>
#include <QPropertyAnimation>
#include <QDebug> // IDW test.
#include "palapeli_debug.h" // IDW test.
Palapeli::ConstraintVisualizer::ConstraintVisualizer(Palapeli::Scene* scene)
: m_scene(scene)
......
This diff is collapsed.
......@@ -21,7 +21,7 @@
#include "scene.h"
#include "view.h"
#include <QDebug> // IDW test.
#include "palapeli_debug.h" // IDW test.
#include <QApplication>
#include <QStyle>
......@@ -186,12 +186,12 @@ Palapeli::TeleportPieceInteractor::TeleportPieceInteractor(QGraphicsView* view)
: Palapeli::Interactor(25, Palapeli::MouseInteractor, view)
{
setMetadata(PieceInteraction, i18nc("Works instantly, without dragging", "Teleport pieces to or from a holder"), QIcon());
qDebug() << "CONSTRUCTED TeleportPieceInteractor";
qCDebug(PALAPELI_LOG) << "CONSTRUCTED TeleportPieceInteractor";
}
bool Palapeli::TeleportPieceInteractor::startInteraction(const Palapeli::MouseEvent& event)
{
qDebug() << "ENTERED TeleportPieceInteractor::startInteraction";
qCDebug(PALAPELI_LOG) << "ENTERED TeleportPieceInteractor::startInteraction";
Palapeli::View* view = qobject_cast<Palapeli::View*>(this->view());
if (!view)
return false;
......@@ -237,12 +237,12 @@ Palapeli::ToggleCloseUpInteractor::ToggleCloseUpInteractor(QGraphicsView* view)
//
// IDW TODO - What about Palapeli::MouseEvent flags?
setMetadata(ViewportInteraction, i18nc("As in a movie scene", "Switch to close-up or distant view"), QIcon::fromTheme(QStringLiteral("zoom-in")));
qDebug() << "CONSTRUCTED ToggleCloseUpInteractor";
qCDebug(PALAPELI_LOG) << "CONSTRUCTED ToggleCloseUpInteractor";
}
bool Palapeli::ToggleCloseUpInteractor::startInteraction(const Palapeli::MouseEvent& event)
{
qDebug() << "ENTERED ToggleCloseUpInteractor::startInteraction";
qCDebug(PALAPELI_LOG) << "ENTERED ToggleCloseUpInteractor::startInteraction";
Palapeli::View* view = qobject_cast<Palapeli::View*>(this->view());
if (view)
view->toggleCloseUp();
......
......@@ -21,7 +21,7 @@
#include "mathtricks.h"
#include <cmath>
#include <QDebug>
#include "palapeli_debug.h"
#include <QImage>
#include <QPainter>
#include <QtMath>
......@@ -267,7 +267,7 @@ QImage Palapeli::applyBevelMap(const QImage &source, const Palapeli::BevelMap& b
// first, prevent mem corruption
if (source.width() * source.height() != bevelmap.size())
{
qWarning() << "ApplyBevelMap: returning unbeveled source since bevelmap has wrong size";
qCWarning(PALAPELI_LOG) << "ApplyBevelMap: returning unbeveled source since bevelmap has wrong size";
return source;
}
......
......@@ -23,7 +23,7 @@
#include "settings.h"
#include <QGraphicsView>
#include <QDebug>
#include "palapeli_debug.h"
Palapeli::Scene::Scene(QObject* parent)
: QGraphicsScene(parent)
......@@ -63,11 +63,11 @@ void Palapeli::Scene::dispatchPieces(const QList<Palapeli::Piece*> pieces)
void Palapeli::Scene::clearPieces()
{
qDebug() << "Palapeli::Scene Delete" << m_pieces.count() << "pieces in m_pieces list.";
qCDebug(PALAPELI_LOG) << "Palapeli::Scene Delete" << m_pieces.count() << "pieces in m_pieces list.";
qDeleteAll(m_pieces);
qDebug() << "Palapeli::Scene Clear m_pieces list.";
qCDebug(PALAPELI_LOG) << "Palapeli::Scene Clear m_pieces list.";
m_pieces.clear();
qDebug() << "Palapeli::Scene Stop m_constraintVisualizer.";
qCDebug(PALAPELI_LOG) << "Palapeli::Scene Stop m_constraintVisualizer.";
m_constraintVisualizer->stop();
}
......@@ -80,7 +80,7 @@ void Palapeli::Scene::addMargin(const qreal handleWidth, const qreal spacer) {
m_constraintVisualizer->stop();
m_constraintVisualizer->start(r, handleWidth);
views()[0]->fitInView(r, Qt::KeepAspectRatio);
qDebug() << "SCENE RECT" << r << "VIEW SIZE" << views()[0]->size();
qCDebug(PALAPELI_LOG) << "SCENE RECT" << r << "VIEW SIZE" << views()[0]->size();
}
QRectF Palapeli::Scene::extPiecesBoundingRect() const
......@@ -189,7 +189,7 @@ void Palapeli::Scene::searchConnections(const QList<Palapeli::Piece*>& pieces,
void Palapeli::Scene::pieceInstanceTransaction(const QList<Palapeli::Piece*>& deletedPieces, const QList<Palapeli::Piece*>& createdPieces)
{
// qDebug() << "Scene::pieceInstanceTransaction(delete" << deletedPieces.count() << "add" << createdPieces.count();
// qCDebug(PALAPELI_LOG) << "Scene::pieceInstanceTransaction(delete" << deletedPieces.count() << "add" << createdPieces.count();
const int oldPieceCount = m_pieces.count();
foreach (Palapeli::Piece* oldPiece, deletedPieces)
m_pieces.removeAll(oldPiece); //these pieces have been deleted by the caller
......@@ -199,7 +199,7 @@ void Palapeli::Scene::pieceInstanceTransaction(const QList<Palapeli::Piece*>& de
connect(newPiece, SIGNAL(moved(bool)),
this, SLOT(pieceMoved(bool)));
}
// qDebug() << "emit saveMove(" << oldPieceCount - m_pieces.count();
// qCDebug(PALAPELI_LOG) << "emit saveMove(" << oldPieceCount - m_pieces.count();
emit saveMove(oldPieceCount - m_pieces.count());
}
......@@ -227,13 +227,13 @@ void Palapeli::Scene::initializeGrid(const QPointF& gridTopLeft)
m_gridRank = 1;
m_gridX = 0;
m_gridY = 0;
// qDebug() << "GRID INITIALIZED" << m_gridTopLeft
// qCDebug(PALAPELI_LOG) << "GRID INITIALIZED" << m_gridTopLeft
// << "spacing" << m_gridSpacing << "scene size" << sceneRect();
}
void Palapeli::Scene::addToGrid(Palapeli::Piece* piece)
{
// qDebug() << "ADD TO GRID AT" << m_gridTopLeft
// qCDebug(PALAPELI_LOG) << "ADD TO GRID AT" << m_gridTopLeft
// << QPoint(m_gridX, m_gridY)
// << "spacing" << m_gridSpacing << "random" << false;
piece->setPlace(m_gridTopLeft, m_gridX, m_gridY, m_gridSpacing, false);
......
......@@ -33,7 +33,7 @@
#include <QDesktopWidget>
#include <QTimer>
#include <QDebug> // IDW test.
#include "palapeli_debug.h" // IDW test.
const int Palapeli::View::MinimumZoomLevel = 0;
const int Palapeli::View::MaximumZoomLevel = 200;
......@@ -56,13 +56,13 @@ Palapeli::View::View()
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
setScene(new Palapeli::Scene(this));
connect(m_scene, &Palapeli::Scene::sceneRectChanged, this, &View::logSceneChange);
qDebug() << "Initial size of Palapeli::View" << size();
qCDebug(PALAPELI_LOG) << "Initial size of Palapeli::View" << size();
}
// IDW test.
void Palapeli::View::logSceneChange(QRectF r)
{
// qDebug() << "View::logSceneChange" << r << "View size" << this->size();
// qCDebug(PALAPELI_LOG) << "View::logSceneChange" << r << "View size" << this->size();
}
Palapeli::InteractorManager* Palapeli::View::interactorManager() const
......@@ -150,7 +150,7 @@ void Palapeli::View::moveViewportBy(const QPointF& sceneDelta)
void Palapeli::View::teleportPieces(Piece* pieceUnder, const QPointF& scenePos)
{
qDebug() << "TELEPORT: pieceUnder" << (pieceUnder != 0)
qCDebug(PALAPELI_LOG) << "TELEPORT: pieceUnder" << (pieceUnder != 0)
<< "scenePos" << scenePos;
emit teleport(pieceUnder, scenePos, this);
}
......@@ -163,7 +163,7 @@ void Palapeli::View::zoomBy(int delta)
// IDW TODO - Accept deltas of <10, either by accumulating deltas or by
// implementing fractional zoom levels.
qDebug() << "View::zoomBy: delta" << delta;
qCDebug(PALAPELI_LOG) << "View::zoomBy: delta" << delta;
m_adjustPointer = true;
zoomTo(m_zoomLevel + delta / 10);
}
......@@ -185,7 +185,7 @@ void Palapeli::View::zoomTo(int level)
m_scenePos = mapToScene(m_mousePos);
// Create a new transform.
const qreal scalingFactor = m_minScale * pow(2, level/m_dZoom);
qDebug() << "View::zoomTo: level" << level
qCDebug(PALAPELI_LOG) << "View::zoomTo: level" << level
<< "scalingFactor" << scalingFactor
<< m_mousePos << m_scenePos;
// Translation, shear, etc. are the same: only the scale is replaced.
......@@ -209,7 +209,7 @@ void Palapeli::View::adjustPointer()
// If the view moved, keep the mouse at the same position in the scene.
const QPoint mousePos = mapFromScene(m_scenePos);
if (mousePos != m_mousePos) {
qDebug() << "POINTER MOVED from" << m_mousePos
qCDebug(PALAPELI_LOG) << "POINTER MOVED from" << m_mousePos
<< "to" << mousePos << "scenePos" << m_scenePos;
QCursor::setPos(mapToGlobal(mousePos));
}
......@@ -302,14 +302,14 @@ int Palapeli::View::calculateZoomRange(qreal distantScale, bool distantView)
if (closeUpScale < distantScale) {
closeUpScale = distantScale; // View is already large enough.
}
qDebug() << "View::calculateZoomRange: distantScale" << distantScale
qCDebug(PALAPELI_LOG) << "View::calculateZoomRange: distantScale" << distantScale
<< "distantView" << distantView
<< "closeUpScale" << closeUpScale;
const qreal minScale = distantScale*0.75;
const qreal maxScale = closeUpScale*2.0;
const qreal range = log(maxScale/minScale)/log(2.0);
const qreal dZoom = (MaximumZoomLevel - MinimumZoomLevel)/range;
qDebug() << "minScale" << minScale << "maxScale" << maxScale
qCDebug(PALAPELI_LOG) << "minScale" << minScale << "maxScale" << maxScale
<< "range" << range << "dZoom" << dZoom;
m_dZoom = dZoom;
m_minScale = minScale;
......@@ -321,21 +321,21 @@ int Palapeli::View::calculateZoomRange(qreal distantScale, bool distantView)
m_closeUpLevel : m_distantLevel + MinDiff;
m_isCloseUp = (! distantView); // Start with the view zoomed in or out.
const int level = (distantView ? m_distantLevel : m_closeUpLevel);
qDebug() << "INITIAL LEVEL" << level
qCDebug(PALAPELI_LOG) << "INITIAL LEVEL" << level
<< "toggles" << m_distantLevel << m_closeUpLevel;
return level;
}
void Palapeli::View::puzzleStarted()
{
qDebug() << "ENTERED View::puzzleStarted()";
qCDebug(PALAPELI_LOG) << "ENTERED View::puzzleStarted()";
// At this point the puzzle pieces have been shuffled or loaded from a
// .save file and the puzzle table has been scaled to fit the view. Now
// adjust zooming and slider to a range of distant and close-up views.
// Choose the lesser of the horizontal and vertical scaling factors.
const qreal distantScale = qMin(transform().m11(), transform().m22());
qDebug() << "distantScale" << distantScale;
qCDebug(PALAPELI_LOG) << "distantScale" << distantScale;
// Calculate the zooming range and return the distant scale's level.
int level = calculateZoomRange(distantScale, true);
......@@ -347,7 +347,7 @@ void Palapeli::View::puzzleStarted()
// Explain autosaving.
KMessageBox::information(window(), i18n("Your progress is saved automatically while you play."), i18nc("used as caption for a dialog that explains the autosave feature", "Automatic saving"), QStringLiteral("autosave-introduction"));
qDebug() << "EXITING View::puzzleStarted()";
qCDebug(PALAPELI_LOG) << "EXITING View::puzzleStarted()";
}
void Palapeli::View::startVictoryAnimation()
......
......@@ -24,7 +24,7 @@
#include <QFutureWatcher>
#include <QTimer>
#include <QApplication>
#include <QDebug>
#include "palapeli_debug.h"
#include <KLocalizedString>
#include <KNotification>
......@@ -38,7 +38,7 @@ void Palapeli::ImportHelper::doWork()
{
if (m_path.isEmpty())
{
qCritical() << i18nc("command line message", "Error: No puzzle file given.");
qCCritical(PALAPELI_LOG) << i18nc("command line message", "Error: No puzzle file given.");
qApp->quit();
}
//import puzzle
......
......@@ -19,6 +19,7 @@
#include "mainwindow.h"
#include "../engine/gameplay.h"
#include "palapeli_debug.h"
#include "puzzletablewidget.h"
#include "../file-io/collection-view.h"
......@@ -164,7 +165,7 @@ void Palapeli::MainWindow::enableMessages()
int result = KMessageBox::questionYesNo(this,
i18n("Enable all messages"));
if (result == KMessageBox::Yes) {
qDebug() << "ENABLE ALL MESSAGES";
qCDebug(PALAPELI_LOG) << "ENABLE ALL MESSAGES";
KMessageBox::enableAllMessages();
KSharedConfig::openConfig()->sync(); // Save the changes to disk.
}
......
......@@ -22,7 +22,7 @@
#include "settings.h"
#include <QCloseEvent>
#include <QDebug>
#include "palapeli_debug.h"
const qreal minGrid = 2.0; // 2x2 pieces in close-up of minimum holder.
const qreal maxGrid = 6.0; // 6x6 pieces in distant view of min holder.
......@@ -31,7 +31,7 @@ Palapeli::PieceHolder::PieceHolder(QWidget* parent, const QSizeF& pieceArea,
const QString& title)
: m_scene(scene())
{
qDebug() << "CONSTRUCTING Palapeli::PieceHolder" << title;
qCDebug(PALAPELI_LOG) << "CONSTRUCTING Palapeli::PieceHolder" << title;
setParent(parent);
setWindowFlags(Qt::Window | Qt::Tool | Qt::WindowTitleHint);
// Allow space for (2 * 2) pieces in minimum view initially.
......@@ -47,7 +47,7 @@ Palapeli::PieceHolder::PieceHolder(QWidget* parent, const QSizeF& pieceArea,
QRectF r = m_scene->sceneRect();
setMinimumSize(s*r.width()+1.0, s*r.height()+1.0);
resize(minimumSize());
qDebug() << "Close-up scale" << s << "pieceArea" << pieceArea
qCDebug(PALAPELI_LOG) << "Close-up scale" << s << "pieceArea" << pieceArea
<< "size" << size();
QTransform t;
t.scale(s, s);
......@@ -64,7 +64,7 @@ void Palapeli::PieceHolder::initializeZooming()
// of pieces can be teleported in, but the holder window will have to be
// resized or scrolled for the user to see them, even in distant view.
qDebug() << "ENTERED PieceHolder::initializeZooming() for" << name();
qCDebug(PALAPELI_LOG) << "ENTERED PieceHolder::initializeZooming() for" << name();
qreal scale = qMin(transform().m11(), transform().m22());
scale = scale * (minGrid / maxGrid);
// Calculate the zooming range and return the close-up scale's level.
......@@ -77,14 +77,14 @@ void Palapeli::PieceHolder::focusInEvent(QFocusEvent* e)
{
// The user selected this piece holder.
Q_UNUSED(e)
qDebug() << "PieceHolder::focusInEvent()" << windowTitle();
qCDebug(PALAPELI_LOG) << "PieceHolder::focusInEvent()" << windowTitle();
setSelected(true);
emit selected(this); // De-select the previously selected holder.
}
void Palapeli::PieceHolder::setSelected(bool onOff)
{
qDebug() << "PieceHolder::setSelected()" << windowTitle() << onOff;
qCDebug(PALAPELI_LOG) << "PieceHolder::setSelected()" << windowTitle() << onOff;
setStyleSheet(QString("QFrame { border: 3px solid %1; }").arg
(onOff ? "blue" : "lightGray"));
}
......
......@@ -22,6 +22,7 @@
#include "../engine/view.h"
#include "../engine/zoomwidget.h"
#include "settings.h"
#include "palapeli_debug.h"
#include <QToolBar>
#include <QGridLayout>
......@@ -110,7 +111,7 @@ void Palapeli::PuzzleTableWidget::showStatusBar(bool visible)
void Palapeli::PuzzleTableWidget::reportProgress(int pieceCount, int partCount)
{
qDebug() << "PuzzleTableWidget::reportProgress(" << pieceCount << partCount;
qCDebug(PALAPELI_LOG) << "PuzzleTableWidget::reportProgress(" << pieceCount << partCount;
m_zoomWidget->setEnabled(pieceCount > 0); //zoom does not work reliably when no puzzle is loaded
if (m_progressBar->minimum() != 0)
m_progressBar->setMinimum(0);
......
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