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ø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
0770171dcd
commit
3c8bc2721c
@ -9,6 +9,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
Q_LOGGING_CATEGORY(lcQpaServices, "qt.qpa.services", QtWarningMsg)
|
||||
|
||||
/*!
|
||||
\class QPlatformServices
|
||||
\since 5.0
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user