From be3e4e4b40e32686bcb4bd6f933d92b826e2cab5 Mon Sep 17 00:00:00 2001 From: Chupligin Sergey Date: Thu, 14 Mar 2024 09:14:44 +0000 Subject: [PATCH] Dont't use QDebug --- config.h.in | 4 ++-- src/dbusadaptor.cpp | 10 +++++----- src/glacierapp.cpp | 17 +++++++++-------- src/glacierapp.h | 5 ++++- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/config.h.in b/config.h.in index 4ec6117..0a05425 100644 --- a/config.h.in +++ b/config.h.in @@ -1,6 +1,6 @@ #include #include -#include +#include inline bool isRunningInstalled() { @@ -14,6 +14,6 @@ inline QString appDirectory() if (installed) { path = QString("@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/%1/qml/").arg(qApp->applicationName()); } - qDebug() << "isRunningInstalled" << installed << path; + qCDebug(lcGlacierAppCoreLog) << "isRunningInstalled" << installed << path; return path; } diff --git a/src/dbusadaptor.cpp b/src/dbusadaptor.cpp index 236c597..13710a5 100644 --- a/src/dbusadaptor.cpp +++ b/src/dbusadaptor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 Chupligin Sergey + * Copyright (C) 2023-2024 Chupligin Sergey * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -17,6 +17,7 @@ * Boston, MA 02110-1301, USA. */ +#include "glacierapp.h" #include "dbusadaptor.h" #include "qcoreapplication.h" @@ -26,25 +27,24 @@ DBusAdaptor::DBusAdaptor(QQuickWindow* window) : QDBusAbstractAdaptor(window) , m_window(window) { - QDBusConnection sessionbus = QDBusConnection::sessionBus(); QString serviceName = QString("org.glacier.%1").arg(qApp->applicationName().replace("-", "_")); QDBusConnection::sessionBus().registerService(serviceName); if (!QDBusConnection::sessionBus().registerObject("/", m_window)) { - qWarning() << Q_FUNC_INFO << "Cannot register DBus object!"; + qCWarning(lcGlacierAppCoreLog) << Q_FUNC_INFO << "Cannot register DBus object!"; }; } void DBusAdaptor::show(QStringList args) { Q_UNUSED(args); - qDebug() << "show window from dbus call"; + qCDebug(lcGlacierAppCoreLog) << "show window from dbus call"; m_window->show(); } void DBusAdaptor::quit(QStringList args) { Q_UNUSED(args); - qDebug() << "quit over dbus"; + qCDebug(lcGlacierAppCoreLog) << "quit over dbus"; qApp->quit(); } diff --git a/src/glacierapp.cpp b/src/glacierapp.cpp index 54650e3..370f248 100644 --- a/src/glacierapp.cpp +++ b/src/glacierapp.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2023 Chupligin Sergey + * Copyright (C) 2017-2024 Chupligin Sergey * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -23,7 +23,6 @@ #include #include -#include #include #include #include @@ -43,6 +42,8 @@ #include #endif +Q_LOGGING_CATEGORY(lcGlacierAppCoreLog, "org.glacier.app", QtWarningMsg) + QGuiApplication* GlacierApp::app(int& argc, char** argv) { setenv("QT_QUICK_CONTROLS_STYLE", "Nemo", 1); @@ -67,14 +68,14 @@ QGuiApplication* GlacierApp::app(int& argc, char** argv) QTranslator* myappTranslator = new QTranslator(app); if (myappTranslator->load(locale, app->applicationName(), QLatin1String("_"), QLatin1String("/usr/share/%1/translations/").arg(app->applicationName()))) { - qDebug() << "translation.load() success" << locale; + qCDebug(lcGlacierAppCoreLog) << "translation.load() success" << locale; if (app->installTranslator(myappTranslator)) { - qDebug() << "installTranslator() success" << locale; + qCDebug(lcGlacierAppCoreLog) << "installTranslator() success" << locale; } else { - qDebug() << "installTranslator() failed" << locale; + qCDebug(lcGlacierAppCoreLog) << "installTranslator() failed" << locale; } } else { - qDebug() << "translation.load() failed" << locale; + qCDebug(lcGlacierAppCoreLog) << "translation.load() failed" << locale; } connect(app, &QGuiApplication::aboutToQuit, saveWindowSize); @@ -85,7 +86,7 @@ QGuiApplication* GlacierApp::app(int& argc, char** argv) QString serviceName = QString("org.glacier.%1").arg(qApp->applicationName().replace("-", "_")); QDBusConnection sessionBus = QDBusConnection::sessionBus(); if (sessionBus.interface()->isServiceRegistered(serviceName)) { - qWarning() << "Current application run shadow mode. Call and exit."; + qCWarning(lcGlacierAppCoreLog) << "Current application run shadow mode. Call and exit."; QDBusMessage message = QDBusMessage::createMethodCall(serviceName, "/", "glacier.app", @@ -147,7 +148,7 @@ QQuickWindow* GlacierApp::showWindow() #endif if (QCoreApplication::arguments().contains("--prestart") || QCoreApplication::arguments().contains("-p")) { - qDebug() << "Application run in shadow mode"; + qCDebug(lcGlacierAppCoreLog) << "Application run in shadow mode"; new DBusAdaptor(window); } else { window->show(); diff --git a/src/glacierapp.h b/src/glacierapp.h index 8994459..d153cfa 100644 --- a/src/glacierapp.h +++ b/src/glacierapp.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017-2023 Chupligin Sergey + * Copyright (C) 2017-2024 Chupligin Sergey * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -22,6 +22,9 @@ #include #include +#include + +Q_DECLARE_LOGGING_CATEGORY(lcGlacierAppCoreLog) class QGuiApplication; class QQmlApplicationEngine;