diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-01-10 17:17:12 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-22 12:12:17 +0100 |
commit | db51ffc0d1fbce85fd542403812fab8783c53e3c (patch) | |
tree | 2e7a051dbf6701b477e4c19de014a44dbaf84c37 /src/plugins/platforms/windows/qwindowscontext.cpp | |
parent | a5c288ea5675a382edf0b3ecae42f461a22a7303 (diff) |
Port Windows QPA plugin to new logger API.
Introduce logging categories and change most debug statements
to qCDebug().
Retrieve the filter rules from the environment variable
QT_QPA_VERBOSE (should be removed once the logging framework
offers a more convenient way of configuring).
Replace the old per-category variables controlling verboseness
of the output by a single variable which can be set on the command
line.
Change-Id: Iae55ecdb0e150efd165b7d3e90b371f72853f194
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowscontext.cpp')
-rw-r--r-- | src/plugins/platforms/windows/qwindowscontext.cpp | 59 |
1 files changed, 26 insertions, 33 deletions
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 43ea317f83..e700c88982 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -79,16 +79,18 @@ QT_BEGIN_NAMESPACE -// Verbosity of components -int QWindowsContext::verboseWindows = 0; -int QWindowsContext::verboseEvents = 0; -int QWindowsContext::verboseBackingStore = 0; -int QWindowsContext::verboseFonts = 0; -int QWindowsContext::verboseGL = 0; -int QWindowsContext::verboseOLE = 0; -int QWindowsContext::verboseInputMethods = 0; -int QWindowsContext::verboseDialogs = 0; -int QWindowsContext::verboseTablet = 0; +Q_LOGGING_CATEGORY(lcQpaWindows, "qt.qpa.windows") +Q_LOGGING_CATEGORY(lcQpaBackingStore, "qt.qpa.backingstore") +Q_LOGGING_CATEGORY(lcQpaEvents, "qt.qpa.events") +Q_LOGGING_CATEGORY(lcQpaFonts, "qt.qpa.fonts") +Q_LOGGING_CATEGORY(lcQpaGl, "qt.qpa.gl") +Q_LOGGING_CATEGORY(lcQpaMime, "qt.qpa.mime") +Q_LOGGING_CATEGORY(lcQpaInputMethods, "qt.qpa.inputmethods") +Q_LOGGING_CATEGORY(lcQpaDialogs, "qt.qpa.dialogs") +Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.tabletsupport") +Q_LOGGING_CATEGORY(lcQpaAccessibility, "qt.qpa.accessibility") + +int QWindowsContext::verbose = 0; // Get verbosity of components from "foo:2,bar:3" static inline int componentVerbose(const char *v, const char *keyWord) @@ -316,23 +318,13 @@ QWindowsContext::QWindowsContext() : # pragma warning( disable : 4996 ) #endif m_instance = this; + // ### FIXME: Remove this once the logging system has other options of configurations. const QByteArray bv = qgetenv("QT_QPA_VERBOSE"); - if (!bv.isEmpty()) { - const char *v = bv.data(); - QWindowsContext::verboseWindows = componentVerbose(v, "windows"); - QWindowsContext::verboseEvents = componentVerbose(v, "events"); - QWindowsContext::verboseBackingStore = componentVerbose(v, "backingstore"); - QWindowsContext::verboseFonts = componentVerbose(v, "fonts"); - QWindowsContext::verboseGL = componentVerbose(v, "gl"); - QWindowsContext::verboseOLE = componentVerbose(v, "ole"); - QWindowsContext::verboseInputMethods = componentVerbose(v, "im"); - QWindowsContext::verboseDialogs = componentVerbose(v, "dialogs"); - QWindowsContext::verboseTablet = componentVerbose(v, "tablet"); - } + if (!bv.isEmpty()) + QLoggingCategory::setFilterRules(QString::fromLocal8Bit(bv)); #if !defined(QT_NO_TABLETEVENT) && !defined(Q_OS_WINCE) d->m_tabletSupport.reset(QWindowsTabletSupport::create()); - if (QWindowsContext::verboseTablet) - qDebug() << "Tablet support: " << (d->m_tabletSupport.isNull() ? QStringLiteral("None") : d->m_tabletSupport->description()); + qCDebug(lcQpaTablet) << "Tablet support: " << (d->m_tabletSupport.isNull() ? QStringLiteral("None") : d->m_tabletSupport->description()); #endif } @@ -515,8 +507,7 @@ QString QWindowsContext::registerWindowClass(QString cname, qPrintable(cname)); d->m_registeredWindowClassNames.insert(cname); - if (QWindowsContext::verboseWindows) - qDebug().nospace() << __FUNCTION__ << ' ' << cname + qCDebug(lcQpaWindows).nospace() << __FUNCTION__ << ' ' << cname << " style=0x" << QString::number(style, 16) << " brush=" << brush << " icon=" << icon << " atom=" << atom; return cname; @@ -827,8 +818,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, // Suppress events sent during DestroyWindow() for native children. if (platformWindow->testFlag(QWindowsWindow::WithinDestroy)) return false; - if (QWindowsContext::verboseEvents > 1) - qDebug().nospace() << "Event window: " << platformWindow->window(); + if (QWindowsContext::verbose > 1) + qCDebug(lcQpaEvents) << "Event window: " << platformWindow->window(); } else { qWarning("%s: No Qt Window found for event 0x%x (%s), hwnd=0x%p.", __FUNCTION__, message, @@ -1074,11 +1065,13 @@ extern "C" LRESULT QT_WIN_CALLBACK qWindowsWndProc(HWND hwnd, UINT message, WPAR LRESULT result; const QtWindows::WindowsEventType et = windowsEventType(message, wParam); const bool handled = QWindowsContext::instance()->windowsProc(hwnd, message, et, wParam, lParam, &result); - if (QWindowsContext::verboseEvents > 1) - if (const char *eventName = QWindowsGuiEventDispatcher::windowsMessageName(message)) - qDebug("EVENT: hwd=%p %s msg=0x%x et=0x%x wp=%d at %d,%d handled=%d", - hwnd, eventName, message, et, int(wParam), - GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), handled); + if (QWindowsContext::verbose > 1 && lcQpaEvents().isDebugEnabled()) { + if (const char *eventName = QWindowsGuiEventDispatcher::windowsMessageName(message)) { + qCDebug(lcQpaEvents) << "EVENT: hwd=" << hwnd << eventName << hex << "msg=0x" << message + << "et=0x" << et << dec << "wp=" << int(wParam) << "at" + << GET_X_LPARAM(lParam) << GET_Y_LPARAM(lParam) << "handled=" << handled; + } + } if (!handled) result = DefWindowProc(hwnd, message, wParam, lParam); return result; |