diff options
28 files changed, 409 insertions, 156 deletions
diff --git a/src/corelib/doc/snippets/qdebug/qdebugsnippet.cpp b/src/corelib/doc/snippets/qdebug/qdebugsnippet.cpp index f71d61ed47..a9ab83f5bf 100644 --- a/src/corelib/doc/snippets/qdebug/qdebugsnippet.cpp +++ b/src/corelib/doc/snippets/qdebug/qdebugsnippet.cpp @@ -51,11 +51,12 @@ public: }; //! [0] -QDebug operator<<(QDebug dbg, const Coordinate &c) +QDebug operator<<(QDebug debug, const Coordinate &c) { - dbg.nospace() << "(" << c.x() << ", " << c.y() << ")"; + QDebugStateSaver saver(debug); + debug.nospace() << '(' << c.x() << ", " << c.y() << ')'; - return dbg.space(); + return debug; } //! [0] diff --git a/src/corelib/doc/snippets/qloggingcategory/main.cpp b/src/corelib/doc/snippets/qloggingcategory/main.cpp index 6b66424875..8d76c5736e 100644 --- a/src/corelib/doc/snippets/qloggingcategory/main.cpp +++ b/src/corelib/doc/snippets/qloggingcategory/main.cpp @@ -59,10 +59,11 @@ struct UsbEntry { int classtype; }; -QDebug operator<<(QDebug &dbg, const UsbEntry &entry) +QDebug operator<<(QDebug &debug, const UsbEntry &entry) { - dbg.nospace() << "" << entry.id << " (" << entry.classtype << ")"; - return dbg.space(); + QDebugStateSaver saver(debug); + debug.nospace() << "" << entry.id << " (" << entry.classtype << ')'; + return debug; } QList<UsbEntry> usbEntries() { diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 78349fbc49..4c189bfe57 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -7,6 +7,7 @@ HEADERS += \ io/qdatastream_p.h \ io/qdataurl_p.h \ io/qdebug.h \ + io/qdebug_p.h \ io/qdir.h \ io/qdir_p.h \ io/qdiriterator.h \ diff --git a/src/corelib/io/qdebug_p.h b/src/corelib/io/qdebug_p.h new file mode 100644 index 0000000000..0525929169 --- /dev/null +++ b/src/corelib/io/qdebug_p.h @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDEBUG_P_H +#define QDEBUG_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "QtCore/qdebug.h" +#include "QtCore/qmetaobject.h" +#include "QtCore/qflags.h" + +QT_BEGIN_NAMESPACE + +namespace QtDebugUtils { + +// inline helpers for formatting basic classes. + +template <class Point> +static inline void formatQPoint(QDebug &debug, const Point &point) +{ + debug << point.x() << ',' << point.y(); +} + +template <class Size> +static inline void formatQSize(QDebug &debug, const Size &size) +{ + debug << size.width() << ", " << size.height(); +} + +template <class Rect> +static inline void formatQRect(QDebug &debug, const Rect &rect) +{ + debug << rect.x() << ',' << rect.y() << ' ' << rect.width() << 'x' << rect.height(); +} + +template <class Margins> +static inline void formatQMargins(QDebug &debug, const Margins &margins) +{ + debug << margins.left() << ", " << margins.top() << ", " << margins.right() + << ", " << margins.bottom(); +} + +#ifndef QT_NO_QOBJECT +template <class QEnum> +static inline void formatQEnum(QDebug &debug, QEnum value) +{ + const QMetaObject *metaObject = qt_getEnumMetaObject(value); + const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(value))); + if (const char *key = me.valueToKey(value)) + debug << key; + else + debug << int(value); +} + +template <class QEnum> +static inline void formatNonNullQEnum(QDebug &debug, const char *prefix, QEnum value) +{ + if (value) { + debug << prefix; + formatQEnum(debug, value); + } +} + +template <class Enum> +static inline void formatQFlags(QDebug &debug, const QFlags<Enum> &value) +{ + const QMetaObject *metaObject = qt_getEnumMetaObject(Enum()); + const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(Enum()))); + const QDebugStateSaver saver(debug); + debug.noquote(); + debug << me.valueToKeys(value); +} + +template <class Enum> +static inline void formatNonNullQFlags(QDebug &debug, const char *prefix, const QFlags<Enum> &value) +{ + if (value) { + debug << prefix; + formatQFlags(debug, value); + } +} + +#endif // !QT_NO_QOBJECT + +} // namespace QtDebugUtils + +QT_END_NAMESPACE + +#endif // QDEBUG_P_H diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index af69a91e4a..d5574a4dd1 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -36,6 +36,7 @@ #ifndef QOBJECTDEFS_H #error Do not include qobjectdefs_impl.h directly +#include <QtCore/qnamespace.h> #endif #if 0 diff --git a/src/corelib/tools/qmargins.cpp b/src/corelib/tools/qmargins.cpp index a9413d6b5c..92c977a73b 100644 --- a/src/corelib/tools/qmargins.cpp +++ b/src/corelib/tools/qmargins.cpp @@ -33,7 +33,8 @@ #include "qmargins.h" #include "qdatastream.h" -#include "qdebug.h" + +#include <private/qdebug_p.h> QT_BEGIN_NAMESPACE @@ -431,10 +432,13 @@ QDataStream &operator>>(QDataStream &s, QMargins &m) #endif // QT_NO_DATASTREAM #ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QMargins &m) { +QDebug operator<<(QDebug dbg, const QMargins &m) +{ QDebugStateSaver saver(dbg); - dbg.nospace() << "QMargins(" << m.left() << ", " - << m.top() << ", " << m.right() << ", " << m.bottom() << ')'; + dbg.nospace(); + dbg << "QMargins" << '('; + QtDebugUtils::formatQMargins(dbg, m); + dbg << ')'; return dbg; } #endif @@ -764,10 +768,13 @@ QDataStream &operator>>(QDataStream &s, QMarginsF &m) #endif // QT_NO_DATASTREAM #ifndef QT_NO_DEBUG_STREAM -QDebug operator<<(QDebug dbg, const QMarginsF &m) { +QDebug operator<<(QDebug dbg, const QMarginsF &m) +{ QDebugStateSaver saver(dbg); - dbg.nospace() << "QMarginsF(" << m.left() << ", " - << m.top() << ", " << m.right() << ", " << m.bottom() << ')'; + dbg.nospace(); + dbg << "QMarginsF" << '('; + QtDebugUtils::formatQMargins(dbg, m); + dbg << ')'; return dbg; } #endif diff --git a/src/corelib/tools/qpoint.cpp b/src/corelib/tools/qpoint.cpp index ebce6c9422..dc2a2d9739 100644 --- a/src/corelib/tools/qpoint.cpp +++ b/src/corelib/tools/qpoint.cpp @@ -33,7 +33,8 @@ #include "qpoint.h" #include "qdatastream.h" -#include "qdebug.h" + +#include <private/qdebug_p.h> QT_BEGIN_NAMESPACE @@ -447,14 +448,20 @@ QDataStream &operator>>(QDataStream &s, QPoint &p) QDebug operator<<(QDebug dbg, const QPoint &p) { QDebugStateSaver saver(dbg); - dbg.nospace() << "QPoint(" << p.x() << ',' << p.y() << ')'; + dbg.nospace(); + dbg << "QPoint" << '('; + QtDebugUtils::formatQPoint(dbg, p); + dbg << ')'; return dbg; } QDebug operator<<(QDebug dbg, const QPointF &p) { QDebugStateSaver saver(dbg); - dbg.nospace() << "QPointF(" << p.x() << ',' << p.y() << ')'; + dbg.nospace(); + dbg << "QPointF" << '('; + QtDebugUtils::formatQPoint(dbg, p); + dbg << ')'; return dbg; } #endif diff --git a/src/corelib/tools/qrect.cpp b/src/corelib/tools/qrect.cpp index 35cf2d5e5b..b2174745e4 100644 --- a/src/corelib/tools/qrect.cpp +++ b/src/corelib/tools/qrect.cpp @@ -33,9 +33,10 @@ #include "qrect.h" #include "qdatastream.h" -#include "qdebug.h" #include "qmath.h" +#include <private/qdebug_p.h> + QT_BEGIN_NAMESPACE /*! @@ -1279,8 +1280,10 @@ QDataStream &operator>>(QDataStream &s, QRect &r) QDebug operator<<(QDebug dbg, const QRect &r) { QDebugStateSaver saver(dbg); - dbg.nospace() << "QRect(" << r.x() << ',' << r.y() << ' ' - << r.width() << 'x' << r.height() << ')'; + dbg.nospace(); + dbg << "QRect" << '('; + QtDebugUtils::formatQRect(dbg, r); + dbg << ')'; return dbg; } #endif @@ -2488,8 +2491,10 @@ QDataStream &operator>>(QDataStream &s, QRectF &r) QDebug operator<<(QDebug dbg, const QRectF &r) { QDebugStateSaver saver(dbg); - dbg.nospace() << "QRectF(" << r.x() << ',' << r.y() << ' ' - << r.width() << 'x' << r.height() << ')'; + dbg.nospace(); + dbg << "QRectF" << '('; + QtDebugUtils::formatQRect(dbg, r); + dbg << ')'; return dbg; } #endif diff --git a/src/corelib/tools/qsize.cpp b/src/corelib/tools/qsize.cpp index d91dd0d130..19227432f2 100644 --- a/src/corelib/tools/qsize.cpp +++ b/src/corelib/tools/qsize.cpp @@ -33,7 +33,8 @@ #include "qsize.h" #include "qdatastream.h" -#include "qdebug.h" + +#include <private/qdebug_p.h> QT_BEGIN_NAMESPACE @@ -440,7 +441,10 @@ QDataStream &operator>>(QDataStream &s, QSize &sz) QDebug operator<<(QDebug dbg, const QSize &s) { QDebugStateSaver saver(dbg); - dbg.nospace() << "QSize(" << s.width() << ", " << s.height() << ')'; + dbg.nospace(); + dbg << "QSize("; + QtDebugUtils::formatQSize(dbg, s); + dbg << ')'; return dbg; } #endif @@ -867,7 +871,10 @@ QDataStream &operator>>(QDataStream &s, QSizeF &sz) QDebug operator<<(QDebug dbg, const QSizeF &s) { QDebugStateSaver saver(dbg); - dbg.nospace() << "QSizeF(" << s.width() << ", " << s.height() << ')'; + dbg.nospace(); + dbg << "QSizeF("; + QtDebugUtils::formatQSize(dbg, s); + dbg << ')'; return dbg; } #endif diff --git a/src/dbus/qdbusabstractinterface.cpp b/src/dbus/qdbusabstractinterface.cpp index 29d5c3d88c..03640cdd21 100644 --- a/src/dbus/qdbusabstractinterface.cpp +++ b/src/dbus/qdbusabstractinterface.cpp @@ -88,7 +88,7 @@ QDBusAbstractInterfacePrivate::QDBusAbstractInterfacePrivate(const QString &serv if (!connection.isConnected()) { lastError = QDBusError(QDBusError::Disconnected, - QLatin1String("Not connected to D-Bus server")); + QDBusUtil::disconnectedErrorMessage()); } else if (!service.isEmpty()) { currentOwner = connectionPrivate()->getNameOwner(service); // verify the name owner if (currentOwner.isEmpty()) { @@ -131,8 +131,8 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu // try to read this property QDBusMessage msg = QDBusMessage::createMethodCall(service, path, - QLatin1String(DBUS_INTERFACE_PROPERTIES), - QLatin1String("Get")); + QDBusUtil::dbusInterfaceProperties(), + QStringLiteral("Get")); QDBusMessagePrivate::setParametersValidated(msg, true); msg << interface << QString::fromUtf8(mp.name()); QDBusMessage reply = connection.call(msg, QDBus::Block, timeout); @@ -144,7 +144,7 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu if (reply.signature() != QLatin1String("v")) { QString errmsg = QLatin1String("Invalid signature `%1' in return from call to " DBUS_INTERFACE_PROPERTIES); - lastError = QDBusError(QDBusError::InvalidSignature, errmsg.arg(reply.signature())); + lastError = QDBusError(QDBusError::InvalidSignature, qMove(errmsg).arg(reply.signature())); return false; } @@ -198,8 +198,8 @@ bool QDBusAbstractInterfacePrivate::setProperty(const QMetaProperty &mp, const Q // send the value QDBusMessage msg = QDBusMessage::createMethodCall(service, path, - QLatin1String(DBUS_INTERFACE_PROPERTIES), - QLatin1String("Set")); + QDBusUtil::dbusInterfaceProperties(), + QStringLiteral("Set")); QDBusMessagePrivate::setParametersValidated(msg, true); msg << interface << QString::fromUtf8(mp.name()) << QVariant::fromValue(QDBusVariant(value)); QDBusMessage reply = connection.call(msg, QDBus::Block, timeout); @@ -290,10 +290,10 @@ QDBusAbstractInterface::QDBusAbstractInterface(QDBusAbstractInterfacePrivate &d, && !d.service.isEmpty() && !d.service.startsWith(QLatin1Char(':')) && d.connectionPrivate()->mode != QDBusConnectionPrivate::PeerMode) - d_func()->connection.connect(QLatin1String(DBUS_SERVICE_DBUS), // service + d_func()->connection.connect(QDBusUtil::dbusService(), // service QString(), // path - QLatin1String(DBUS_INTERFACE_DBUS), // interface - QLatin1String("NameOwnerChanged"), + QDBusUtil::dbusInterface(), // interface + QDBusUtil::nameOwnerChanged(), QStringList() << d.service, QString(), // signature this, SLOT(_q_serviceOwnerChanged(QString,QString,QString))); @@ -316,10 +316,10 @@ QDBusAbstractInterface::QDBusAbstractInterface(const QString &service, const QSt && !service.isEmpty() && !service.startsWith(QLatin1Char(':')) && d_func()->connectionPrivate()->mode != QDBusConnectionPrivate::PeerMode) - d_func()->connection.connect(QLatin1String(DBUS_SERVICE_DBUS), // service + d_func()->connection.connect(QDBusUtil::dbusService(), // service QString(), // path - QLatin1String(DBUS_INTERFACE_DBUS), // interface - QLatin1String("NameOwnerChanged"), + QDBusUtil::dbusInterface(), // interface + QDBusUtil::nameOwnerChanged(), QStringList() << service, QString(), //signature this, SLOT(_q_serviceOwnerChanged(QString,QString,QString))); diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index 5dc18fe908..0adb3dd748 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -462,7 +462,7 @@ bool QDBusConnection::send(const QDBusMessage &message) const { if (!d || !d->connection) { QDBusError err = QDBusError(QDBusError::Disconnected, - QLatin1String("Not connected to D-BUS server")); + QDBusUtil::disconnectedErrorMessage()); if (d) d->lastError = err; return false; @@ -495,7 +495,7 @@ bool QDBusConnection::callWithCallback(const QDBusMessage &message, QObject *rec { if (!d || !d->connection) { QDBusError err = QDBusError(QDBusError::Disconnected, - QLatin1String("Not connected to D-BUS server")); + QDBusUtil::disconnectedErrorMessage()); if (d) d->lastError = err; return false; @@ -553,7 +553,7 @@ QDBusMessage QDBusConnection::call(const QDBusMessage &message, QDBus::CallMode { if (!d || !d->connection) { QDBusError err = QDBusError(QDBusError::Disconnected, - QLatin1String("Not connected to D-Bus server")); + QDBusUtil::disconnectedErrorMessage()); if (d) d->lastError = err; @@ -968,7 +968,7 @@ bool QDBusConnection::isConnected() const */ QDBusError QDBusConnection::lastError() const { - return d ? d->lastError : QDBusError(QDBusError::Disconnected, QStringLiteral("Not connected.")); + return d ? d->lastError : QDBusError(QDBusError::Disconnected, QDBusUtil::disconnectedErrorMessage()); } /*! diff --git a/src/dbus/qdbusconnectioninterface.cpp b/src/dbus/qdbusconnectioninterface.cpp index f3ca04b86c..ff923ba282 100644 --- a/src/dbus/qdbusconnectioninterface.cpp +++ b/src/dbus/qdbusconnectioninterface.cpp @@ -42,7 +42,7 @@ #include <QtCore/QVariant> #include <QtCore/QDebug> -#include "qdbus_symbols_p.h" // for the DBUS_* constants +#include "qdbusutil_p.h" // for the DBUS_* constants #ifndef QT_NO_DBUS @@ -154,8 +154,8 @@ const char *QDBusConnectionInterface::staticInterfaceName() */ QDBusConnectionInterface::QDBusConnectionInterface(const QDBusConnection &connection, QObject *parent) - : QDBusAbstractInterface(QLatin1String(DBUS_SERVICE_DBUS), - QLatin1String(DBUS_PATH_DBUS), + : QDBusAbstractInterface(QDBusUtil::dbusService(), + QDBusUtil::dbusPath(), DBUS_INTERFACE_DBUS, connection, parent) { connect(this, SIGNAL(NameAcquired(QString)), this, SIGNAL(serviceRegistered(QString))); diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 6edf08ebbe..9eac1ed933 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -72,23 +72,6 @@ static dbus_int32_t server_slot = -1; static QBasicAtomicInt isDebugging = Q_BASIC_ATOMIC_INITIALIZER(-1); #define qDBusDebug if (::isDebugging == 0); else qDebug -static inline QString orgFreedesktopDBusString() -{ - return QStringLiteral(DBUS_SERVICE_DBUS); -} - -static inline QString dbusServiceString() -{ - return orgFreedesktopDBusString(); -} - -static inline QString dbusInterfaceString() -{ - // it's the same string, but just be sure - Q_ASSERT(orgFreedesktopDBusString() == QLatin1String(DBUS_INTERFACE_DBUS)); - return orgFreedesktopDBusString(); -} - static inline QDebug operator<<(QDebug dbg, const QThread *th) { QDebugStateSaver saver(dbg); @@ -1041,7 +1024,7 @@ QDBusConnectionPrivate::QDBusConnectionPrivate(QObject *p) // prepopulate watchedServices: // we know that the owner of org.freedesktop.DBus is itself - watchedServices.insert(dbusServiceString(), WatchedServiceData(dbusServiceString(), 1)); + watchedServices.insert(QDBusUtil::dbusService(), WatchedServiceData(QDBusUtil::dbusService(), 1)); // prepopulate matchRefCounts: // we know that org.freedesktop.DBus will never change owners @@ -1377,7 +1360,7 @@ bool QDBusConnectionPrivate::activateInternalFilters(const ObjectTreeNode &node, // object may be null const QString interface = msg.interface(); - if (interface.isEmpty() || interface == QLatin1String(DBUS_INTERFACE_INTROSPECTABLE)) { + if (interface.isEmpty() || interface == QDBusUtil::dbusInterfaceIntrospectable()) { if (msg.member() == QLatin1String("Introspect") && msg.signature().isEmpty()) { //qDebug() << "QDBusConnectionPrivate::activateInternalFilters introspect" << msg.d_ptr->msg; QDBusMessage reply = msg.createReply(qDBusIntrospectObject(node, msg.path())); @@ -1392,7 +1375,7 @@ bool QDBusConnectionPrivate::activateInternalFilters(const ObjectTreeNode &node, } if (node.obj && (interface.isEmpty() || - interface == QLatin1String(DBUS_INTERFACE_PROPERTIES))) { + interface == QDBusUtil::dbusInterfaceProperties())) { //qDebug() << "QDBusConnectionPrivate::activateInternalFilters properties" << msg.d_ptr->msg; if (msg.member() == QLatin1String("Get") && msg.signature() == QLatin1String("ss")) { QDBusMessage reply = qDBusPropertyGet(node, msg); @@ -1779,7 +1762,7 @@ void QDBusConnectionPrivate::setConnection(DBusConnection *dbc, const QDBusError // we don't use connectSignal here because we don't need the rules to be sent to the bus // the bus will always send us these two signals SignalHook hook; - hook.service = dbusServiceString(); + hook.service = QDBusUtil::dbusService(); hook.path.clear(); // no matching hook.obj = this; hook.params << QMetaType::Void << QVariant::String; // both functions take a QString as parameter and return void @@ -2205,10 +2188,10 @@ QDBusPendingCallPrivate *QDBusConnectionPrivate::sendWithReplyAsync(const QDBusM return pcall; } else { // we're probably disconnected at this point - lastError = error = QDBusError(QDBusError::Disconnected, QLatin1String("Not connected to server")); + lastError = error = QDBusError(QDBusError::Disconnected, QDBusUtil::disconnectedErrorMessage()); } } else { - lastError = error = QDBusError(QDBusError::NoMemory, QLatin1String("Out of memory")); + lastError = error = QDBusError(QDBusError::NoMemory, QStringLiteral("Out of memory")); } q_dbus_message_unref(msg); @@ -2279,8 +2262,8 @@ void QDBusConnectionPrivate::connectSignal(const QString &key, const SignalHook WatchedServicesHash::mapped_type &data = watchedServices[hook.service]; if (++data.refcount == 1) { // we need to watch for this service changing - connectSignal(dbusServiceString(), QString(), dbusInterfaceString(), - QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(), + connectSignal(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(), + QStringLiteral("NameOwnerChanged"), QStringList() << hook.service, QString(), this, SLOT(serviceOwnerChangedNoLock(QString,QString,QString))); data.owner = getNameOwnerNoCache(hook.service); qDBusDebug() << this << "Watching service" << hook.service << "for owner changes (current owner:" @@ -2359,8 +2342,8 @@ QDBusConnectionPrivate::disconnectSignal(SignalHookHash::Iterator &it) if (sit != watchedServices.end()) { if (--sit.value().refcount == 0) { watchedServices.erase(sit); - disconnectSignal(dbusServiceString(), QString(), dbusInterfaceString(), - QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(), + disconnectSignal(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(), + QStringLiteral("NameOwnerChanged"), QStringList() << hook.service, QString(), this, SLOT(serviceOwnerChangedNoLock(QString,QString,QString))); } } @@ -2501,9 +2484,9 @@ QString QDBusConnectionPrivate::getNameOwner(const QString& serviceName) QString QDBusConnectionPrivate::getNameOwnerNoCache(const QString &serviceName) { - QDBusMessage msg = QDBusMessage::createMethodCall(dbusServiceString(), - QLatin1String(DBUS_PATH_DBUS), dbusInterfaceString(), - QLatin1String("GetNameOwner")); + QDBusMessage msg = QDBusMessage::createMethodCall(QDBusUtil::dbusService(), + QDBusUtil::dbusPath(), QDBusUtil::dbusInterface(), + QStringLiteral("GetNameOwner")); QDBusMessagePrivate::setParametersValidated(msg, true); msg << serviceName; QDBusMessage reply = sendWithReply(msg, QDBus::Block); @@ -2526,8 +2509,8 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa // introspect the target object QDBusMessage msg = QDBusMessage::createMethodCall(service, path, - QLatin1String(DBUS_INTERFACE_INTROSPECTABLE), - QLatin1String("Introspect")); + QDBusUtil::dbusInterfaceIntrospectable(), + QStringLiteral("Introspect")); QDBusMessagePrivate::setParametersValidated(msg, true); QDBusMessage reply = sendWithReply(msg, QDBus::Block); @@ -2586,7 +2569,7 @@ bool QDBusConnectionPrivate::isServiceRegisteredByThread(const QString &serviceN { if (!serviceName.isEmpty() && serviceName == baseService) return true; - if (serviceName == dbusServiceString()) + if (serviceName == QDBusUtil::dbusService()) return false; QDBusReadLocker locker(UnregisterServiceAction, this); diff --git a/src/dbus/qdbuspendingcall.cpp b/src/dbus/qdbuspendingcall.cpp index 321dcb4ef4..09eff81107 100644 --- a/src/dbus/qdbuspendingcall.cpp +++ b/src/dbus/qdbuspendingcall.cpp @@ -36,6 +36,7 @@ #include "qdbusconnection_p.h" #include "qdbusmetatype_p.h" +#include "qdbusutil_p.h" #include "qcoreapplication.h" #include "qcoreevent.h" #include <private/qobject_p.h> @@ -383,7 +384,7 @@ QDBusError QDBusPendingCall::error() const // not connected, return an error QDBusError err = QDBusError(QDBusError::Disconnected, - QLatin1String("Not connected to D-Bus server")); + QDBusUtil::disconnectedErrorMessage()); return err; } diff --git a/src/dbus/qdbusserver.cpp b/src/dbus/qdbusserver.cpp index 3b7b797cff..2fc7c75d83 100644 --- a/src/dbus/qdbusserver.cpp +++ b/src/dbus/qdbusserver.cpp @@ -34,6 +34,7 @@ #include "qdbusserver.h" #include "qdbusconnection_p.h" #include "qdbusconnectionmanager_p.h" +#include "qdbusutil_p.h" #ifndef QT_NO_DBUS @@ -130,7 +131,7 @@ bool QDBusServer::isConnected() const */ QDBusError QDBusServer::lastError() const { - return d ? d->lastError : QDBusError(QDBusError::Disconnected, QStringLiteral("Not connected.")); + return d ? d->lastError : QDBusError(QDBusError::Disconnected, QDBusUtil::disconnectedErrorMessage()); } /*! diff --git a/src/dbus/qdbusservicewatcher.cpp b/src/dbus/qdbusservicewatcher.cpp index a7832eb3ff..4adf049d17 100644 --- a/src/dbus/qdbusservicewatcher.cpp +++ b/src/dbus/qdbusservicewatcher.cpp @@ -33,7 +33,7 @@ #include "qdbusservicewatcher.h" #include "qdbusconnection.h" -#include "qdbus_symbols_p.h" +#include "qdbusutil_p.h" #include <QStringList> @@ -43,10 +43,6 @@ QT_BEGIN_NAMESPACE -Q_GLOBAL_STATIC_WITH_ARGS(QString, busService, (QLatin1String(DBUS_SERVICE_DBUS))) -Q_GLOBAL_STATIC_WITH_ARGS(QString, busInterface, (QLatin1String(DBUS_INTERFACE_DBUS))) -Q_GLOBAL_STATIC_WITH_ARGS(QString, signalName, (QLatin1String("NameOwnerChanged"))) - class QDBusServiceWatcherPrivate: public QObjectPrivate { Q_DECLARE_PUBLIC(QDBusServiceWatcher) @@ -120,7 +116,7 @@ QStringList QDBusServiceWatcherPrivate::matchArgsForService(const QString &servi void QDBusServiceWatcherPrivate::addService(const QString &service) { QStringList matchArgs = matchArgsForService(service); - connection.connect(*busService(), QString(), *busInterface(), *signalName(), + connection.connect(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(), QDBusUtil::nameOwnerChanged(), matchArgs, QString(), q_func(), SLOT(_q_serviceOwnerChanged(QString,QString,QString))); } @@ -128,7 +124,7 @@ void QDBusServiceWatcherPrivate::addService(const QString &service) void QDBusServiceWatcherPrivate::removeService(const QString &service) { QStringList matchArgs = matchArgsForService(service); - connection.disconnect(*busService(), QString(), *busInterface(), *signalName(), + connection.disconnect(QDBusUtil::dbusService(), QString(), QDBusUtil::dbusInterface(), QDBusUtil::nameOwnerChanged(), matchArgs, QString(), q_func(), SLOT(_q_serviceOwnerChanged(QString,QString,QString))); } diff --git a/src/dbus/qdbusutil_p.h b/src/dbus/qdbusutil_p.h index b5f92f2e47..8f5ae922db 100644 --- a/src/dbus/qdbusutil_p.h +++ b/src/dbus/qdbusutil_p.h @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2015 Intel Corporation. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtDBus module of the Qt Toolkit. @@ -51,6 +52,8 @@ #include <QtDBus/qdbusmacros.h> #include <QtDBus/qdbuserror.h> +#include "qdbus_symbols_p.h" + #ifndef QT_NO_DBUS QT_BEGIN_NAMESPACE @@ -147,6 +150,25 @@ namespace QDBusUtil *error = QDBusError(QDBusError::InvalidInterface, QString::fromLatin1("Invalid error name: %1").arg(name)); return false; } + + inline QString dbusService() + { return QStringLiteral(DBUS_SERVICE_DBUS); } + inline QString dbusPath() + { return QStringLiteral(DBUS_PATH_DBUS); } + inline QString dbusInterface() + { + // it's the same string, but just be sure + Q_ASSERT(dbusService() == QLatin1String(DBUS_INTERFACE_DBUS)); + return dbusService(); + } + inline QString dbusInterfaceProperties() + { return QStringLiteral(DBUS_INTERFACE_PROPERTIES); } + inline QString dbusInterfaceIntrospectable() + { return QStringLiteral(DBUS_INTERFACE_INTROSPECTABLE); } + inline QString nameOwnerChanged() + { return QStringLiteral("NameOwnerChanged"); } + inline QString disconnectedErrorMessage() + { return QStringLiteral("Not connected to D-Bus server"); } } QT_END_NAMESPACE diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index ccd7c37486..11f7f13552 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -37,13 +37,13 @@ #include "qpa/qplatformintegration.h" #include "qpa/qplatformdrag.h" #include "private/qevent_p.h" -#include "qdebug.h" #include "qmetaobject.h" #include "qmimedata.h" #include "private/qdnd_p.h" #include "qevent_p.h" #include "qmath.h" +#include <private/qdebug_p.h> QT_BEGIN_NAMESPACE @@ -3463,7 +3463,10 @@ QShortcutEvent::~QShortcutEvent() static inline void formatTouchEvent(QDebug d, const QTouchEvent &t) { - d << "QTouchEvent(" << t.type() << " states: " << t.touchPointStates(); + d << "QTouchEvent("; + QtDebugUtils::formatQEnum(d, t.type()); + d << " states: "; + QtDebugUtils::formatQFlags(d, t.touchPointStates()); d << ", " << t.touchPoints().size() << " points: " << t.touchPoints() << ')'; } @@ -3644,15 +3647,20 @@ static const char *eventClassName(QEvent::Type t) static void formatDropEvent(QDebug d, const QDropEvent *e) { const QEvent::Type type = e->type(); - d << eventClassName(type) << "(dropAction=" << e->dropAction() << ", proposedAction=" - << e->proposedAction() << ", possibleActions=" << e->possibleActions() - << ", posF=" << e->posF(); + d << eventClassName(type) << "(dropAction="; + QtDebugUtils::formatQEnum(d, e->dropAction()); + d << ", proposedAction="; + QtDebugUtils::formatQEnum(d, e->proposedAction()); + d << ", possibleActions="; + QtDebugUtils::formatQFlags(d, e->possibleActions()); + d << ", posF="; + QtDebugUtils::formatQPoint(d, e->posF()); if (type == QEvent::DragMove || type == QEvent::DragEnter) d << ", answerRect=" << static_cast<const QDragMoveEvent *>(e)->answerRect(); d << ", formats=" << e->mimeData()->formats(); - if (const Qt::KeyboardModifiers mods = e->keyboardModifiers()) - d << ", keyboardModifiers=" << mods; - d << ", " << e->mouseButtons(); + QtDebugUtils::formatNonNullQFlags(d, ", keyboardModifiers=", e->keyboardModifiers()); + d << ", "; + QtDebugUtils::formatQFlags(d, e->mouseButtons()); } # endif // !QT_NO_DRAGANDDROP @@ -3663,15 +3671,19 @@ static void formatTabletEvent(QDebug d, const QTabletEvent *e) { const QEvent::Type type = e->type(); - d << eventClassName(type) << '(' << type - << ", device=" << e->device() - << ", pointerType=" << e->pointerType() - << ", uniqueId=" << e->uniqueId() + d << eventClassName(type) << '('; + QtDebugUtils::formatQEnum(d, type); + d << ", device="; + QtDebugUtils::formatQEnum(d, e->device()); + d << ", pointerType="; + QtDebugUtils::formatQEnum(d, e->pointerType()); + d << ", uniqueId=" << e->uniqueId() << ", pos=" << e->posF() << ", z=" << e->z() << ", xTilt=" << e->xTilt() << ", yTilt=" << e->yTilt() - << ", " << e->buttons(); + << ", "; + QtDebugUtils::formatQFlags(d, e->buttons()); if (type == QEvent::TabletPress || type == QEvent::TabletMove) d << ", pressure=" << e->pressure(); if (e->device() == QTabletEvent::RotationStylus || e->device() == QTabletEvent::FourDMouse) @@ -3685,8 +3697,19 @@ static void formatTabletEvent(QDebug d, const QTabletEvent *e) QDebug operator<<(QDebug dbg, const QTouchEvent::TouchPoint &tp) { QDebugStateSaver saver(dbg); - dbg.nospace() << "TouchPoint(" << tp.id() << ' ' << tp.rect() << ' ' << tp.state() << " press " << tp.pressure() - << " vel " << tp.velocity() << " start " << tp.startPos() << " last " << tp.lastPos() << " delta " << tp.pos() - tp.lastPos() << ')'; + dbg.nospace(); + dbg << "TouchPoint(" << tp.id() << " ("; + QtDebugUtils::formatQRect(dbg, tp.rect()); + dbg << ") "; + QtDebugUtils::formatQEnum(dbg, tp.state()); + dbg << " press " << tp.pressure() << " vel " << tp.velocity() + << " start ("; + QtDebugUtils::formatQPoint(dbg, tp.startPos()); + dbg << ") last ("; + QtDebugUtils::formatQPoint(dbg, tp.lastPos()); + dbg << ") delta ("; + QtDebugUtils::formatQPoint(dbg, tp.pos() - tp.lastPos()); + dbg << ')'; return dbg; } @@ -3716,18 +3739,23 @@ QDebug operator<<(QDebug dbg, const QEvent *e) const QMouseEvent *me = static_cast<const QMouseEvent*>(e); const Qt::MouseButton button = me->button(); const Qt::MouseButtons buttons = me->buttons(); - dbg << "QMouseEvent(" << type; - if (type != QEvent::MouseMove && type != QEvent::NonClientAreaMouseMove) - dbg << ", " << button; - if (buttons && button != buttons) - dbg << ", buttons=" << buttons; - if (me->modifiers()) - dbg << ", " << me->modifiers(); - dbg << ", localPos=" << me->localPos() << ", screenPos=" << me->screenPos(); - if (me->source()) - dbg << ", " << me->source(); - if (const Qt::MouseEventFlags flags = me->flags()) - dbg << ", flags = " << hex << int(flags) << dec; + dbg << "QMouseEvent("; + QtDebugUtils::formatQEnum(dbg, type); + if (type != QEvent::MouseMove && type != QEvent::NonClientAreaMouseMove) { + dbg << ", "; + QtDebugUtils::formatQEnum(dbg, button); + } + if (buttons && button != buttons) { + dbg << ", buttons="; + QtDebugUtils::formatQFlags(dbg, buttons); + } + QtDebugUtils::formatNonNullQFlags(dbg, ", ", me->modifiers()); + dbg << ", localPos="; + QtDebugUtils::formatQPoint(dbg, me->localPos()); + dbg << ", screenPos="; + QtDebugUtils::formatQPoint(dbg, me->screenPos()); + QtDebugUtils::formatNonNullQEnum(dbg, ", ", me->source()); + QtDebugUtils::formatNonNullQFlags(dbg, ", flags=", me->flags()); dbg << ')'; } break; @@ -3743,10 +3771,11 @@ QDebug operator<<(QDebug dbg, const QEvent *e) case QEvent::ShortcutOverride: { const QKeyEvent *ke = static_cast<const QKeyEvent *>(e); - dbg << "QKeyEvent(" << type - << ", " << static_cast<Qt::Key>(ke->key()); - if (ke->modifiers()) - dbg << ", " << ke->modifiers(); + dbg << "QKeyEvent("; + QtDebugUtils::formatQEnum(dbg, type); + dbg << ", "; + QtDebugUtils::formatQEnum(dbg, static_cast<Qt::Key>(ke->key())); + QtDebugUtils::formatNonNullQFlags(dbg, ", ", ke->modifiers()); if (!ke->text().isEmpty()) dbg << ", text=" << ke->text(); if (ke->isAutoRepeat()) @@ -3765,11 +3794,16 @@ QDebug operator<<(QDebug dbg, const QEvent *e) case QEvent::FocusAboutToChange: case QEvent::FocusIn: case QEvent::FocusOut: - dbg << "QFocusEvent(" << type << ", " << static_cast<const QFocusEvent *>(e)->reason() << ')'; + dbg << "QFocusEvent("; + QtDebugUtils::formatQEnum(dbg, type); + dbg << ", "; + QtDebugUtils::formatQEnum(dbg, static_cast<const QFocusEvent *>(e)->reason()); + dbg << ')'; break; case QEvent::Move: { const QMoveEvent *me = static_cast<const QMoveEvent *>(e); - dbg << "QMoveEvent(" << me->pos(); + dbg << "QMoveEvent("; + QtDebugUtils::formatQPoint(dbg, me->pos()); if (!me->spontaneous()) dbg << ", non-spontaneous"; dbg << ')'; @@ -3777,7 +3811,8 @@ QDebug operator<<(QDebug dbg, const QEvent *e) break; case QEvent::Resize: { const QResizeEvent *re = static_cast<const QResizeEvent *>(e); - dbg << "QResizeEvent(" << re->size(); + dbg << "QResizeEvent("; + QtDebugUtils::formatQSize(dbg, re->size()); if (!re->spontaneous()) dbg << ", non-spontaneous"; dbg << ')'; @@ -3804,19 +3839,25 @@ QDebug operator<<(QDebug dbg, const QEvent *e) case QEvent::ChildAdded: case QEvent::ChildPolished: case QEvent::ChildRemoved: - dbg << "QChildEvent(" << type << ", " << (static_cast<const QChildEvent*>(e))->child() << ')'; + dbg << "QChildEvent("; + QtDebugUtils::formatQEnum(dbg, type); + dbg << ", " << (static_cast<const QChildEvent*>(e))->child() << ')'; break; # ifndef QT_NO_GESTURES case QEvent::NativeGesture: { const QNativeGestureEvent *ne = static_cast<const QNativeGestureEvent *>(e); - dbg << "QNativeGestureEvent(" << ne->gestureType() - << "localPos=" << ne->localPos() << ", value=" << ne->value() << ')'; + dbg << "QNativeGestureEvent("; + QtDebugUtils::formatQEnum(dbg, ne->gestureType()); + dbg << "localPos="; + QtDebugUtils::formatQPoint(dbg, ne->localPos()); + dbg << ", value=" << ne->value() << ')'; } break; # endif // !QT_NO_GESTURES case QEvent::ApplicationStateChange: - dbg << "QApplicationStateChangeEvent(" - << static_cast<const QApplicationStateChangeEvent *>(e)->applicationState() << ')'; + dbg << "QApplicationStateChangeEvent("; + QtDebugUtils::formatQEnum(dbg, static_cast<const QApplicationStateChangeEvent *>(e)->applicationState()); + dbg << ')'; break; case QEvent::ContextMenu: dbg << "QContextMenuEvent(" << static_cast<const QContextMenuEvent *>(e)->pos() << ')'; @@ -3849,8 +3890,9 @@ QDebug operator<<(QDebug dbg, const QEvent *e) dbg << ')'; break; default: - dbg << eventClassName(type) << '(' << type << ", " - << (const void *)e << ", type = " << e->type() << ')'; + dbg << eventClassName(type) << '('; + QtDebugUtils::formatQEnum(dbg, type); + dbg << ", " << (const void *)e << ')'; break; } return dbg; diff --git a/src/platformsupport/dbustray/qdbustrayicon.cpp b/src/platformsupport/dbustray/qdbustrayicon.cpp index fe58bafedc..fed8d219d9 100644 --- a/src/platformsupport/dbustray/qdbustrayicon.cpp +++ b/src/platformsupport/dbustray/qdbustrayicon.cpp @@ -115,12 +115,6 @@ void QDBusTrayIcon::cleanup() m_registered = false; } -void QDBusTrayIcon::activate(int x, int y) -{ - qCDebug(qLcTray) << x << y; - setStatus(QStringLiteral("Active")); -} - void QDBusTrayIcon::attentionTimerExpired() { m_messageTitle = QString(); @@ -213,11 +207,6 @@ void QDBusTrayIcon::updateMenu(QPlatformMenu * menu) m_menu->emitUpdated(); } -void QDBusTrayIcon::contextMenu(int x, int y) -{ - qCDebug(qLcTray) << x << y; -} - void QDBusTrayIcon::showMessage(const QString &title, const QString &msg, const QIcon &icon, QPlatformSystemTrayIcon::MessageIcon iconType, int msecs) { diff --git a/src/platformsupport/dbustray/qdbustrayicon_p.h b/src/platformsupport/dbustray/qdbustrayicon_p.h index 78dfae7c02..34a89c9018 100644 --- a/src/platformsupport/dbustray/qdbustrayicon_p.h +++ b/src/platformsupport/dbustray/qdbustrayicon_p.h @@ -113,10 +113,6 @@ public: QDBusPlatformMenu *menu() { return m_menu; } -public Q_SLOTS: - void activate(int x, int y); - void contextMenu(int x, int y); - signals: void categoryChanged(); void statusChanged(QString arg); diff --git a/src/platformsupport/dbustray/qstatusnotifieritemadaptor.cpp b/src/platformsupport/dbustray/qstatusnotifieritemadaptor.cpp index 540e2f011d..36212e9b61 100644 --- a/src/platformsupport/dbustray/qstatusnotifieritemadaptor.cpp +++ b/src/platformsupport/dbustray/qstatusnotifieritemadaptor.cpp @@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(qLcMenu) +Q_DECLARE_LOGGING_CATEGORY(qLcTray) QStatusNotifierItemAdaptor::QStatusNotifierItemAdaptor(QDBusTrayIcon *parent) : QDBusAbstractAdaptor(parent), m_trayIcon(parent) @@ -151,22 +152,26 @@ QXdgDBusToolTipStruct QStatusNotifierItemAdaptor::toolTip() const void QStatusNotifierItemAdaptor::Activate(int x, int y) { - m_trayIcon->activate(x, y); + qCDebug(qLcTray) << x << y; + emit m_trayIcon->activated(QPlatformSystemTrayIcon::Trigger); } void QStatusNotifierItemAdaptor::ContextMenu(int x, int y) { - m_trayIcon->contextMenu(x, y); + qCDebug(qLcTray) << x << y; + emit m_trayIcon->activated(QPlatformSystemTrayIcon::Context); } -void QStatusNotifierItemAdaptor::Scroll(int, const QString &) +void QStatusNotifierItemAdaptor::Scroll(int w, const QString &s) { + qCDebug(qLcTray) << w << s; // unsupported } -void QStatusNotifierItemAdaptor::SecondaryActivate(int, int) +void QStatusNotifierItemAdaptor::SecondaryActivate(int x, int y) { - // unsupported + qCDebug(qLcTray) << x << y; + emit m_trayIcon->activated(QPlatformSystemTrayIcon::MiddleClick); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp index 67548a0836..f5065a22b8 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.cpp +++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp @@ -208,15 +208,22 @@ static inline QString resolveBugListFile(const QString &fileName) return QStandardPaths::locate(QStandardPaths::ConfigLocation, fileName); } +# ifndef QT_NO_OPENGL typedef QHash<QOpenGLConfig::Gpu, QWindowsOpenGLTester::Renderers> SupportedRenderersCache; Q_GLOBAL_STATIC(SupportedRenderersCache, supportedRenderersCache) +# endif #endif // !Q_OS_WINCE QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::detectSupportedRenderers(const GpuDescription &gpu, bool glesOnly) { Q_UNUSED(gpu) -#ifndef Q_OS_WINCE + Q_UNUSED(glesOnly) +#if defined(QT_NO_OPENGL) + return 0; +#elif defined(Q_OS_WINCE) + return QWindowsOpenGLTester::Gles; +#else QOpenGLConfig::Gpu qgpu; qgpu.deviceId = gpu.deviceId; qgpu.vendorId = gpu.vendorId; @@ -265,9 +272,7 @@ QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::detectSupportedRenderers(c srCache->insert(qgpu, result); return result; -#else // !Q_OS_WINCE - return QWindowsOpenGLTester::Gles; -#endif +#endif // !Q_OS_WINCE && !QT_NO_OPENGL } QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::supportedGlesRenderers() @@ -288,7 +293,7 @@ QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::supportedRenderers() bool QWindowsOpenGLTester::testDesktopGL() { -#ifndef Q_OS_WINCE +#if !defined(QT_NO_OPENGL) && !defined(Q_OS_WINCE) HMODULE lib = 0; HWND wnd = 0; HDC dc = 0; @@ -414,9 +419,9 @@ cleanup: // No FreeLibrary. Some implementations, Mesa in particular, deadlock when trying to unload. return result; -#else // !Q_OS_WINCE +#else return false; -#endif +#endif // !QT_NO_OPENGL && !Q_OS_WINCE } QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index a43bf53fa3..6afa4e6591 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -2265,6 +2265,7 @@ void QWindowsWindow::setCustomMargins(const QMargins &newCustomMargins) void *QWindowsWindow::surface(void *nativeConfig, int *err) { #ifdef QT_NO_OPENGL + Q_UNUSED(nativeConfig) return 0; #else if (!m_surface) { @@ -2278,11 +2279,13 @@ void *QWindowsWindow::surface(void *nativeConfig, int *err) void QWindowsWindow::invalidateSurface() { +#ifndef QT_NO_OPENGL if (m_surface) { if (QWindowsStaticOpenGLContext *staticOpenGLContext = QWindowsIntegration::staticOpenGLContext()) staticOpenGLContext->destroyWindowSurface(m_surface); m_surface = 0; } +#endif // QT_NO_OPENGL } void QWindowsWindow::setTouchWindowTouchTypeStatic(QWindow *window, QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 2084d7ea5d..f4c633e2d7 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -1480,6 +1480,7 @@ static const char * xcb_atomnames = { "WM_STATE\0" "WM_CHANGE_STATE\0" "WM_CLASS\0" + "WM_NAME\0" // Session management "WM_CLIENT_LEADER\0" diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index de454b5eae..f479c1bc80 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -107,6 +107,7 @@ namespace QXcbAtom { WM_STATE, WM_CHANGE_STATE, WM_CLASS, + WM_NAME, // Session management WM_CLIENT_LEADER, diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index eed8b19013..b06b41a77b 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -86,6 +86,7 @@ #include <qpa/qplatformbackingstore.h> #include <qpa/qwindowsysteminterface.h> +#include <QTextCodec> #include <stdio.h> #ifdef XCB_USE_XLIB @@ -243,6 +244,48 @@ static inline bool positionIncludesFrame(QWindow *w) return qt_window_private(w)->positionPolicy == QWindowPrivate::WindowFrameInclusive; } +#ifdef XCB_USE_XLIB +static inline XTextProperty* qstringToXTP(Display *dpy, const QString& s) +{ + #include <X11/Xatom.h> + + static XTextProperty tp = { 0, 0, 0, 0 }; + static bool free_prop = true; // we can't free tp.value in case it references + // the data of the static QByteArray below. + if (tp.value) { + if (free_prop) + XFree(tp.value); + tp.value = 0; + free_prop = true; + } + + static const QTextCodec* mapper = QTextCodec::codecForLocale(); + int errCode = 0; + if (mapper) { + QByteArray mapped = mapper->fromUnicode(s); + char* tl[2]; + tl[0] = mapped.data(); + tl[1] = 0; + errCode = XmbTextListToTextProperty(dpy, tl, 1, XStdICCTextStyle, &tp); + if (errCode < 0) + qDebug("XmbTextListToTextProperty result code %d", errCode); + } + if (!mapper || errCode < 0) { + mapper = QTextCodec::codecForName("latin1"); + if (!mapper || !mapper->canEncode(s)) + return Q_NULLPTR; + static QByteArray qcs; + qcs = s.toLatin1(); + tp.value = (uchar*)qcs.data(); + tp.encoding = XA_STRING; + tp.format = 8; + tp.nitems = qcs.length(); + free_prop = false; + } + return &tp; +} +#endif // XCB_USE_XLIB + static const char *wm_window_type_property_id = "_q_xcb_wm_window_type"; QXcbWindow::QXcbWindow(QWindow *window) @@ -1421,6 +1464,12 @@ void QXcbWindow::setWindowTitle(const QString &title) 8, ba.length(), ba.constData())); + +#ifdef XCB_USE_XLIB + XTextProperty *text = qstringToXTP(DISPLAY_FROM_XCB(this), title); + if (text) + XSetWMName(DISPLAY_FROM_XCB(this), m_window, text); +#endif xcb_flush(xcb_connection()); } diff --git a/src/widgets/styles/qproxystyle.cpp b/src/widgets/styles/qproxystyle.cpp index 4b1c58dc50..61f836b23c 100644 --- a/src/widgets/styles/qproxystyle.cpp +++ b/src/widgets/styles/qproxystyle.cpp @@ -101,8 +101,8 @@ void QProxyStylePrivate::ensureBaseStyle() const /*! Constructs a QProxyStyle object for overriding behavior in the - specified base \a style, or in the current \l{QApplication::style()} - {application style} if base \a style is not specified. + specified \a style, or in the default native \l{QApplication::style()} + {style} if \a style is not specified. Ownership of \a style is transferred to QProxyStyle. */ diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 01952aac3c..a46b8af4ff 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -32,7 +32,7 @@ cross_compile: SUBDIRS -= tools # Disable the QtDBus tests if we can't connect to the session bus qtHaveModule(dbus) { - !system("dbus-send --type=signal / local.AutotestCheck.Hello"): { + !system("dbus-send --session --type=signal / local.AutotestCheck.Hello"): { warning("QtDBus is enabled but session bus is not available. Please check the installation.") SUBDIRS -= dbus } |