From ed6a76ea48a45b05d6852a3d13d347d7b9d4ffbd Mon Sep 17 00:00:00 2001 From: Sergey Chupligin Date: Wed, 10 Jul 2024 15:49:13 +0300 Subject: [PATCH] Dont use QDebug --- src/controls/CMakeLists.txt | 6 +-- src/controls/filteringmousearea.cpp | 3 +- src/controls/logging.cpp | 34 ++++++++++++++++ src/controls/logging.h | 39 +++++++++++++++++++ src/controls/nemopage.cpp | 4 +- src/core/CMakeLists.txt | 4 +- src/core/logging.cpp | 34 ++++++++++++++++ src/core/logging.h | 39 +++++++++++++++++++ src/core/plugin.cpp | 1 - src/core/sizing.cpp | 4 +- src/core/theme.cpp | 8 ++-- .../themedaemon/mlocalthemedaemonclient.cpp | 14 +++---- 12 files changed, 169 insertions(+), 21 deletions(-) create mode 100644 src/controls/logging.cpp create mode 100644 src/controls/logging.h create mode 100644 src/core/logging.cpp create mode 100644 src/core/logging.h diff --git a/src/controls/CMakeLists.txt b/src/controls/CMakeLists.txt index d536aa1..20a3b7b 100644 --- a/src/controls/CMakeLists.txt +++ b/src/controls/CMakeLists.txt @@ -8,7 +8,7 @@ set(SRC nemofocussingleton.cpp nemowindow.cpp inversemousearea.cpp - ) + logging.cpp) set(HEADERS editfilter.h @@ -18,7 +18,8 @@ set(HEADERS nemofocussingleton.h nemowindow.h nemopage.h - inversemousearea.h ) + inversemousearea.h + logging.h) set(QML qml/ActionButton.qml @@ -80,7 +81,6 @@ target_link_libraries(nemocontrolsplugin PUBLIC Qt6::Quick PkgConfig::MLITE) - install(TARGETS nemocontrolsplugin RUNTIME DESTINATION "${QT_INSTALL_QML}/Nemo/Controls" BUNDLE DESTINATION "${QT_INSTALL_QML}/Nemo/Controls" diff --git a/src/controls/filteringmousearea.cpp b/src/controls/filteringmousearea.cpp index 8c874d3..3fb5be3 100644 --- a/src/controls/filteringmousearea.cpp +++ b/src/controls/filteringmousearea.cpp @@ -1,4 +1,5 @@ #include "filteringmousearea.h" +#include "logging.h" #include FilteringMouseArea::FilteringMouseArea(QQuickItem* parent) @@ -180,7 +181,7 @@ void FilteringMouseArea::mouseUngrabEvent() void FilteringMouseArea::grabMouseEvents() { - qDebug() << "Glacier Header: Grabbing mouse!"; + qCDebug(lcNemoControlsControlsLog) << "Glacier Header: Grabbing mouse!"; grabMouse(); } diff --git a/src/controls/logging.cpp b/src/controls/logging.cpp new file mode 100644 index 0000000..95c630f --- /dev/null +++ b/src/controls/logging.cpp @@ -0,0 +1,34 @@ +/**************************************************************************************** +** +** Copyright (C) 2024 Chupligin Sergey +** All rights reserved. +** +** You may use this file under the terms of BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the author nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR +** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +****************************************************************************************/ + +#include "logging.h" + +Q_LOGGING_CATEGORY(lcNemoControlsControlsLog, "org.nemocontrols.controls", QtWarningMsg) diff --git a/src/controls/logging.h b/src/controls/logging.h new file mode 100644 index 0000000..5c72090 --- /dev/null +++ b/src/controls/logging.h @@ -0,0 +1,39 @@ +/**************************************************************************************** +** +** Copyright (C) 2024 Chupligin Sergey +** All rights reserved. +** +** You may use this file under the terms of BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the author nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR +** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +****************************************************************************************/ + +#ifndef LOGGING_H +#define LOGGING_H + +#include + +Q_DECLARE_LOGGING_CATEGORY(lcNemoControlsControlsLog) + +#endif // LOGGING_H diff --git a/src/controls/nemopage.cpp b/src/controls/nemopage.cpp index c6f6d0d..a85a3f9 100644 --- a/src/controls/nemopage.cpp +++ b/src/controls/nemopage.cpp @@ -19,7 +19,7 @@ */ #include "nemopage.h" -#include +#include "logging.h" NemoPage::NemoPage(QQuickItem* parent) : QQuickItem(parent) @@ -43,7 +43,7 @@ void NemoPage::setAllowedOrientations(Qt::ScreenOrientations allowed) m_allowedOrientations = allowed; emit allowedOrientationsChanged(); } else { - qDebug() << "NemoPage: invalid allowedOrientation!"; + qCDebug(lcNemoControlsControlsLog) << "NemoPage: invalid allowedOrientation!"; } } } diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index a693f94..e3565f1 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -4,13 +4,15 @@ set(SRC plugin.cpp themedaemon/mlocalthemedaemonclient.cpp themedaemon/mabstractthemedaemonclient.cpp - theme.cpp) + theme.cpp + logging.cpp) set(HEADERS nemoimageprovider.h plugin.h sizing.h theme.h + logging.h themedaemon/mlocalthemedaemonclient.h themedaemon/mabstractthemedaemonclient.h) diff --git a/src/core/logging.cpp b/src/core/logging.cpp new file mode 100644 index 0000000..aad942e --- /dev/null +++ b/src/core/logging.cpp @@ -0,0 +1,34 @@ +/**************************************************************************************** +** +** Copyright (C) 2024 Chupligin Sergey +** All rights reserved. +** +** You may use this file under the terms of BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the author nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR +** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +****************************************************************************************/ + +#include "logging.h" + +Q_LOGGING_CATEGORY(lcNemoControlsCoreLog, "org.nemocontrols.core", QtWarningMsg) diff --git a/src/core/logging.h b/src/core/logging.h new file mode 100644 index 0000000..c73e982 --- /dev/null +++ b/src/core/logging.h @@ -0,0 +1,39 @@ +/**************************************************************************************** +** +** Copyright (C) 2024 Chupligin Sergey +** All rights reserved. +** +** You may use this file under the terms of BSD license as follows: +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the author nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR +** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +****************************************************************************************/ + +#ifndef LOGGING_H +#define LOGGING_H + +#include + +Q_DECLARE_LOGGING_CATEGORY(lcNemoControlsCoreLog) + +#endif // LOGGING_H diff --git a/src/core/plugin.cpp b/src/core/plugin.cpp index 24541a2..2fe1d2f 100644 --- a/src/core/plugin.cpp +++ b/src/core/plugin.cpp @@ -1,6 +1,5 @@ #include "plugin.h" #include "nemoimageprovider.h" -#include "sizing.h" #include "theme.h" #include diff --git a/src/core/sizing.cpp b/src/core/sizing.cpp index 5ca1b3c..11127d0 100644 --- a/src/core/sizing.cpp +++ b/src/core/sizing.cpp @@ -18,9 +18,9 @@ */ #include "sizing.h" +#include "logging.h" #include -#include #include #include #include @@ -80,7 +80,7 @@ void Sizing::recalcConstants() return; } - qDebug() << "Screen DPI is: " << dpi; + qCDebug(lcNemoControlsCoreLog) << "Screen DPI is: " << dpi; float dpScaleFactor; diff --git a/src/core/theme.cpp b/src/core/theme.cpp index 3dea716..df6e780 100644 --- a/src/core/theme.cpp +++ b/src/core/theme.cpp @@ -18,7 +18,7 @@ */ #include "theme.h" -#include +#include "logging.h" #include #include #include @@ -47,12 +47,12 @@ bool Theme::loadTheme(QString fileName) QFile themeFile(fileName); if (!themeFile.exists()) { - qDebug() << "Theme file " << fileName << " not found"; + qCDebug(lcNemoControlsCoreLog) << "Theme file " << fileName << " not found"; return false; } if (themeFile.size() == 0) { - qDebug() << "Theme file " << fileName << " is empty"; + qCDebug(lcNemoControlsCoreLog) << "Theme file " << fileName << " is empty"; return false; } @@ -208,7 +208,7 @@ void Theme::setThemeValues() QFile fontFile; fontFile.setFileName(theme.value("fontPath").toString()); if (!themeFile.exists()) { - qDebug() << "Font file " << fontFile.fileName() << " not found"; + qCDebug(lcNemoControlsCoreLog) << "Font file " << fontFile.fileName() << " not found"; } else { m_fontPath = theme.value("fontPath").toString(); emit fontPathChanged(); diff --git a/src/core/themedaemon/mlocalthemedaemonclient.cpp b/src/core/themedaemon/mlocalthemedaemonclient.cpp index bdf6526..5aec91b 100644 --- a/src/core/themedaemon/mlocalthemedaemonclient.cpp +++ b/src/core/themedaemon/mlocalthemedaemonclient.cpp @@ -40,8 +40,8 @@ #include "mlocalthemedaemonclient.h" +#include "../logging.h" #include -#include #include #include #include @@ -82,7 +82,7 @@ MLocalThemeDaemonClient::MLocalThemeDaemonClient(const QString& testPath, QObjec #define THEME_NAME "glacier" #endif #ifdef HAVE_MLITE - qDebug() << Q_FUNC_INFO << "Theme: " << themeItem.value(THEME_NAME).toString(); + qCDebug(lcNemoControlsCoreLog) << "Theme: " << themeItem.value(THEME_NAME).toString(); themeName = themeItem.value(THEME_NAME).toString(); #else themeName = QLatin1String(THEME_NAME); @@ -95,12 +95,12 @@ MLocalThemeDaemonClient::MLocalThemeDaemonClient(const QString& testPath, QObjec const QSettings themeIndexFile(themeIndexFileName, QSettings::IniFormat); if (themeIndexFile.status() != QSettings::NoError) { - qWarning() << Q_FUNC_INFO << "Theme" << themeName << "does not exist! Falling back to " << THEME_NAME; + qCWarning(lcNemoControlsCoreLog) << "Theme" << themeName << "does not exist! Falling back to " << THEME_NAME; } // we need to have X-MeeGoTouch-Metatheme group in index.theme if (!themeIndexFile.childGroups().contains(QString("X-MeeGoTouch-Metatheme"))) { - qWarning() << Q_FUNC_INFO << "Theme" << themeName << " is invalid"; + qCWarning(lcNemoControlsCoreLog) << "Theme" << themeName << " is invalid"; } // the paths should be stored in reverse order than in the inheritance chain @@ -108,7 +108,7 @@ MLocalThemeDaemonClient::MLocalThemeDaemonClient(const QString& testPath, QObjec themeRoots.prepend(themeRoot + QDir::separator() + themeName + QDir::separator() + QLatin1String("fontawesome")); } else { - qDebug() << Q_FUNC_INFO << "Theme: test mode: " << themeRoot; + qCDebug(lcNemoControlsCoreLog) << "Theme: test mode: " << themeRoot; themeRoots += themeRoot; } @@ -190,10 +190,10 @@ QImage MLocalThemeDaemonClient::readImage(const QString& id) const } } } - qDebug() << "Unknown theme image:" << id; + qCDebug(lcNemoControlsCoreLog) << "Unknown theme image:" << id; QDir hicolorIconsDir("/usr/share/icons/hicolor/scalable/"); if (hicolorIconsDir.exists()) { - qDebug() << "trying load into hicolor scalable dir"; + qCDebug(lcNemoControlsCoreLog) << "trying load into hicolor scalable dir"; QDirIterator it("/usr/share/icons/hicolor/scalable/", QStringList() << "*.svg", QDir::Files, QDirIterator::Subdirectories); while (it.hasNext()) {