Skip to content

Commit

Permalink
Dont't use QDebug
Browse files Browse the repository at this point in the history
  • Loading branch information
neochapay committed Mar 14, 2024
1 parent b21957c commit be3e4e4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
4 changes: 2 additions & 2 deletions config.h.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <QCoreApplication>
#include <QDir>
#include <QDebug>
#include <glacierapp.h>

inline bool isRunningInstalled()
{
Expand All @@ -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;
}
10 changes: 5 additions & 5 deletions src/dbusadaptor.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Chupligin Sergey <[email protected]>
* Copyright (C) 2023-2024 Chupligin Sergey <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
Expand All @@ -17,6 +17,7 @@
* Boston, MA 02110-1301, USA.
*/

#include "glacierapp.h"
#include "dbusadaptor.h"
#include "qcoreapplication.h"

Expand All @@ -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();
}
17 changes: 9 additions & 8 deletions src/glacierapp.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2023 Chupligin Sergey <[email protected]>
* Copyright (C) 2017-2024 Chupligin Sergey <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
Expand All @@ -23,7 +23,6 @@

#include <QDBusConnection>
#include <QDBusConnectionInterface>
#include <QDebug>
#include <QFileInfo>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
Expand All @@ -43,6 +42,8 @@
#include <QSettings>
#endif

Q_LOGGING_CATEGORY(lcGlacierAppCoreLog, "org.glacier.app", QtWarningMsg)

QGuiApplication* GlacierApp::app(int& argc, char** argv)
{
setenv("QT_QUICK_CONTROLS_STYLE", "Nemo", 1);
Expand All @@ -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);

Expand All @@ -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",
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion src/glacierapp.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2023 Chupligin Sergey <[email protected]>
* Copyright (C) 2017-2024 Chupligin Sergey <[email protected]>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
Expand All @@ -22,6 +22,9 @@

#include <QLocale>
#include <QObject>
#include <QLoggingCategory>

Q_DECLARE_LOGGING_CATEGORY(lcGlacierAppCoreLog)

class QGuiApplication;
class QQmlApplicationEngine;
Expand Down

0 comments on commit be3e4e4

Please sign in to comment.