summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Redondo <[email protected]>2025-02-05 12:18:53 +0100
committerDavid Redondo <[email protected]>2025-02-25 19:31:00 +0100
commit3c8bc2721cce78cfb24a4483459c0d56cbc570b9 (patch)
tree008aaa60075d86d7aed879cc0bd9edea6cdc484e
parent0770171dcda24a567d6f57b87fdd284011e56e16 (diff)
Add logging category for platform services
Rather than being hidden behind a compile time flag or uncategorized Change-Id: I3bc1781351220441134fb9815644e905273a1e40 Reviewed-by: Tor Arne Vestbø <[email protected]>
-rw-r--r--src/gui/kernel/qplatformservices.cpp2
-rw-r--r--src/gui/kernel/qplatformservices.h3
-rw-r--r--src/gui/platform/unix/qdesktopunixservices.cpp14
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm1
-rw-r--r--src/plugins/platforms/ios/qiosservices.mm2
-rw-r--r--src/plugins/platforms/windows/qwindowsservices.cpp19
7 files changed, 18 insertions, 24 deletions
diff --git a/src/gui/kernel/qplatformservices.cpp b/src/gui/kernel/qplatformservices.cpp
index 7ff2a6c2f8e..07ab7f69e04 100644
--- a/src/gui/kernel/qplatformservices.cpp
+++ b/src/gui/kernel/qplatformservices.cpp
@@ -9,6 +9,8 @@
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcQpaServices, "qt.qpa.services", QtWarningMsg)
+
/*!
\class QPlatformServices
\since 5.0
diff --git a/src/gui/kernel/qplatformservices.h b/src/gui/kernel/qplatformservices.h
index 063247af084..aa6a5c4c80b 100644
--- a/src/gui/kernel/qplatformservices.h
+++ b/src/gui/kernel/qplatformservices.h
@@ -15,9 +15,12 @@
#include <QtGui/qtguiglobal.h>
#include <QtCore/qobject.h>
+#include <QtCore/qloggingcategory.h>
QT_BEGIN_NAMESPACE
+QT_DECLARE_EXPORTED_QT_LOGGING_CATEGORY(lcQpaServices, Q_GUI_EXPORT)
+
class QUrl;
class QWindow;
diff --git a/src/gui/platform/unix/qdesktopunixservices.cpp b/src/gui/platform/unix/qdesktopunixservices.cpp
index be472414ee5..226bd338a2c 100644
--- a/src/gui/platform/unix/qdesktopunixservices.cpp
+++ b/src/gui/platform/unix/qdesktopunixservices.cpp
@@ -46,8 +46,6 @@ using namespace Qt::StringLiterals;
#if QT_CONFIG(multiprocess)
-enum { debug = 0 };
-
static inline QByteArray detectDesktopEnvironment()
{
const QByteArray xdgCurrentDesktop = qgetenv("XDG_CURRENT_DESKTOP");
@@ -136,8 +134,7 @@ static inline bool launch(const QString &launcher, const QUrl &url,
{
const QString command = launcher + u' ' + QLatin1StringView(url.toEncoded());
- if (debug)
- qDebug("Launching %s", qPrintable(command));
+ qCDebug(lcQpaServices, "Launching %s", qPrintable(command));
#if !QT_CONFIG(process)
if (!xdgActivationToken.isEmpty())
qputenv("XDG_ACTIVATION_TOKEN", xdgActivationToken.toUtf8());
@@ -162,8 +159,7 @@ static inline bool launch(const QString &launcher, const QUrl &url,
}
# endif
if (!ok)
- qWarning("Launch failed (%s)", qPrintable(command));
-
+ qCWarning(lcQpaServices, "Launch failed (%s)", qPrintable(command));
return ok;
}
@@ -501,7 +497,7 @@ bool QDesktopUnixServices::openUrl(const QUrl &url)
if (m_webBrowser.isEmpty()
&& !detectWebBrowser(desktopEnvironment(), true, &m_webBrowser)) {
- qWarning("Unable to detect a web browser to launch '%s'", qPrintable(url.toString()));
+ qCWarning(lcQpaServices, "Unable to detect a web browser to launch '%s'", qPrintable(url.toString()));
return false;
}
return launch(m_webBrowser, url, xdgActivationToken);
@@ -535,7 +531,7 @@ bool QDesktopUnixServices::openDocument(const QUrl &url)
if (m_documentLauncher.isEmpty()
&& !detectWebBrowser(desktopEnvironment(), false, &m_documentLauncher)) {
- qWarning("Unable to detect a launcher for '%s'", qPrintable(url.toString()));
+ qCWarning(lcQpaServices, "Unable to detect a launcher for '%s'", qPrintable(url.toString()));
return false;
}
return launch(m_documentLauncher, url, xdgActivationToken);
@@ -616,7 +612,7 @@ void QDesktopUnixServices::setApplicationBadge(qint64 number)
{
#if QT_CONFIG(dbus)
if (qGuiApp->desktopFileName().isEmpty()) {
- qWarning("QGuiApplication::desktopFileName() is empty");
+ qCWarning(lcQpaServices, "Cannot set badge number - QGuiApplication::desktopFileName() is empty");
return;
}
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h
index 36cf7766987..1d5ecf9b691 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.h
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.h
@@ -42,7 +42,6 @@ Q_DECLARE_LOGGING_CATEGORY(lcQpaApplication)
Q_DECLARE_LOGGING_CATEGORY(lcQpaClipboard)
Q_DECLARE_LOGGING_CATEGORY(lcQpaDialogs)
Q_DECLARE_LOGGING_CATEGORY(lcQpaMenus)
-Q_DECLARE_LOGGING_CATEGORY(lcQpaServices)
class QPixmap;
class QString;
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm
index 38ff31dafe6..7ef958e5d9b 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.mm
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm
@@ -29,7 +29,6 @@ Q_LOGGING_CATEGORY(lcQpaApplication, "qt.qpa.application");
Q_LOGGING_CATEGORY(lcQpaClipboard, "qt.qpa.clipboard")
Q_LOGGING_CATEGORY(lcQpaDialogs, "qt.qpa.dialogs")
Q_LOGGING_CATEGORY(lcQpaMenus, "qt.qpa.menus")
-Q_LOGGING_CATEGORY(lcQpaServices, "qt.qpa.services")
//
// Conversion Functions
diff --git a/src/plugins/platforms/ios/qiosservices.mm b/src/plugins/platforms/ios/qiosservices.mm
index 3e898cfffa0..c93eca666a2 100644
--- a/src/plugins/platforms/ios/qiosservices.mm
+++ b/src/plugins/platforms/ios/qiosservices.mm
@@ -17,7 +17,7 @@ QT_BEGIN_NAMESPACE
bool QIOSServices::openUrl(const QUrl &url)
{
if (qt_apple_isApplicationExtension()) {
- qWarning() << "openUrl not implement for application extensions yet";
+ qCWarning(lcQpaServices) << "openUrl not implement for application extensions yet";
return false;
}
diff --git a/src/plugins/platforms/windows/qwindowsservices.cpp b/src/plugins/platforms/windows/qwindowsservices.cpp
index 89f93fd1614..a6c6e2ba466 100644
--- a/src/plugins/platforms/windows/qwindowsservices.cpp
+++ b/src/plugins/platforms/windows/qwindowsservices.cpp
@@ -21,8 +21,6 @@ QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
-enum { debug = 0 };
-
class QWindowsShellExecuteThread : public QThread
{
public:
@@ -83,11 +81,10 @@ static bool openWebBrowser(const QUrl &url)
thread.wait();
const auto result = reinterpret_cast<quintptr>(thread.result());
- if (debug)
- qDebug() << __FUNCTION__ << urlS << QString::fromWCharArray(browserExecutable) << result;
+ qCDebug(lcQpaServices) << urlS << QString::fromWCharArray(browserExecutable) << result;
// ShellExecute returns a value greater than 32 if successful
if (result <= 32) {
- qWarning("%s", qPrintable(msgShellExecuteFailed(url, result)));
+ qCWarning(lcQpaServices, "%s", qPrintable(msgShellExecuteFailed(url, result)));
return false;
}
return true;
@@ -112,7 +109,7 @@ static inline bool shellExecute(const QUrl &url)
// ShellExecute returns a value greater than 32 if successful
if (result <= 32) {
- qWarning("%s", qPrintable(msgShellExecuteFailed(url, result)));
+ qCWarning(lcQpaServices, "%s", qPrintable(msgShellExecuteFailed(url, result)));
return false;
}
return true;
@@ -132,8 +129,7 @@ static inline QString mailCommand()
.stringValue( L"Progid");
const auto mailto = keyName.isEmpty() ? "mailto"_L1 : QLatin1StringView();
keyName += mailto + "\\Shell\\Open\\Command"_L1;
- if (debug)
- qDebug() << __FUNCTION__ << "keyName=" << keyName;
+ qCDebug(lcQpaServices) << "keyName=" << keyName;
const QString command = QWinRegistryKey(HKEY_CLASSES_ROOT, keyName).stringValue(L"");
// QTBUG-57816: As of Windows 10, if there is no mail client installed, an entry like
// "rundll32.exe .. url.dll,MailToProtocolHandler %l" is returned. Launching it
@@ -151,12 +147,12 @@ static inline bool launchMail(const QUrl &url)
{
QString command = mailCommand();
if (command.isEmpty()) {
- qWarning("Cannot launch '%ls': There is no mail program installed.", qUtf16Printable(url.toString()));
+ qCWarning(lcQpaServices, "Cannot launch '%ls': There is no mail program installed.", qUtf16Printable(url.toString()));
return false;
}
// Fix mail launch if no param is expected in this command.
if (command.indexOf("%1"_L1) < 0) {
- qWarning() << "The mail command lacks the '%1' parameter.";
+ qWarning(lcQpaServices) << "The mail command lacks the '%1' parameter.";
return false;
}
//Make sure the path for the process is in quotes
@@ -171,8 +167,7 @@ static inline bool launchMail(const QUrl &url)
// Pass the url as the parameter. Should use QProcess::startDetached(),
// but that cannot handle a Windows command line [yet].
command.replace("%1"_L1, url.toString(QUrl::FullyEncoded));
- if (debug)
- qDebug() << __FUNCTION__ << "Launching" << command;
+ qCDebug(lcQpaServices) << "Launching" << command;
//start the process
PROCESS_INFORMATION pi;
ZeroMemory(&pi, sizeof(pi));