diff options
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 94 |
1 files changed, 86 insertions, 8 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index b2ea83c991..b49fd9b3b6 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -37,7 +37,6 @@ #include "qcursor.h" #include "qdesktopwidget_p.h" #include "qevent.h" -#include "qhash.h" #include "qlayout.h" #include "qmenu.h" #include "qmetaobject.h" @@ -100,6 +99,7 @@ #include "qwindowcontainer_p.h" +#include <QtPlatformHeaders/qxcbwindowfunctions.h> // widget/widget data creation count //#define QWIDGET_EXTRA_DEBUG @@ -704,7 +704,7 @@ void QWidget::setAutoFillBackground(bool enabled) close(). \row \li Top-level windows \li - \l windowModified, \l windowTitle, \l windowIcon, \l windowIconText, + \l windowModified, \l windowTitle, \l windowIcon, \l isActiveWindow, activateWindow(), \l minimized, showMinimized(), \l maximized, showMaximized(), \l fullScreen, showFullScreen(), showNormal(). @@ -5939,7 +5939,7 @@ void QWidget::unsetLocale() window title, if set. This is done by the QPA plugin, so it is shown to the user, but isn't part of the windowTitle string. - \sa windowIcon, windowIconText, windowModified, windowFilePath + \sa windowIcon, windowModified, windowFilePath */ QString QWidget::windowTitle() const { @@ -6034,7 +6034,11 @@ void QWidgetPrivate::setWindowIconText_helper(const QString &title) void QWidgetPrivate::setWindowIconText_sys(const QString &iconText) { - Q_UNUSED(iconText); + Q_Q(QWidget); + // ### The QWidget property is deprecated, but the XCB window function is not. + // It should remain available for the rare application that needs it. + if (QWindow *window = q->windowHandle()) + QXcbWindowFunctions::setWmWindowIconText(window, iconText); } /*! @@ -6044,6 +6048,9 @@ void QWidgetPrivate::setWindowIconText_sys(const QString &iconText) new \a iconText as an argument. \since 5.2 + \obsolete + + This signal is deprecated. */ void QWidget::setWindowIconText(const QString &iconText) @@ -6094,7 +6101,7 @@ void QWidget::setWindowTitle(const QString &title) has been set, windowIcon() returns the application icon (QApplication::windowIcon()). - \sa windowIconText, windowTitle + \sa windowTitle */ QIcon QWidget::windowIcon() const { @@ -6110,8 +6117,15 @@ QIcon QWidget::windowIcon() const void QWidgetPrivate::setWindowIcon_helper() { + Q_Q(QWidget); QEvent e(QEvent::WindowIconChange); - QApplication::sendEvent(q_func(), &e); + + // Do not send the event if the widget is a top level. + // In that case, setWindowIcon_sys does it, and event propagation from + // QWidgetWindow to the top level QWidget ensures that the event reaches + // the top level anyhow + if (!q->windowHandle()) + QApplication::sendEvent(q, &e); for (int i = 0; i < children.size(); ++i) { QWidget *w = qobject_cast<QWidget *>(children.at(i)); if (w && !w->isWindow()) @@ -6154,10 +6168,15 @@ void QWidgetPrivate::setWindowIcon_sys() /*! \property QWidget::windowIconText - \brief the widget's icon text + \brief the text to be displayed on the icon of a minimized window This property only makes sense for windows. If no icon - text has been set, this functions returns an empty string. + text has been set, this accessor returns an empty string. + It is only implemented on the X11 platform, and only certain + window managers use this window property. + + \obsolete + This property is deprecated. \sa windowIcon, windowTitle */ @@ -12796,6 +12815,65 @@ void QWidgetPrivate::setWidgetParentHelper(QObject *widgetAsObject, QObject *new widget->setParent(static_cast<QWidget*>(newParent)); } +#ifndef QT_NO_DEBUG_STREAM + +static inline void formatWidgetAttributes(QDebug debug, const QWidget *widget) +{ + const QMetaObject *qtMo = qt_getEnumMetaObject(Qt::WA_AttributeCount); + const QMetaEnum me = qtMo->enumerator(qtMo->indexOfEnumerator("WidgetAttribute")); + debug << ", attributes=["; + int count = 0; + for (int a = 0; a < Qt::WA_AttributeCount; ++a) { + if (widget->testAttribute(static_cast<Qt::WidgetAttribute>(a))) { + if (count++) + debug << ','; + debug << me.valueToKey(a); + } + } + debug << ']'; +} + +QDebug operator<<(QDebug debug, const QWidget *widget) +{ + const QDebugStateSaver saver(debug); + debug.nospace(); + if (widget) { + debug << widget->metaObject()->className() << '(' << (void *)widget; + if (!widget->objectName().isEmpty()) + debug << ", name=" << widget->objectName(); + if (debug.verbosity() > 2) { + const QRect geometry = widget->geometry(); + const QRect frameGeometry = widget->frameGeometry(); + if (widget->isVisible()) + debug << ", visible"; + if (!widget->isEnabled()) + debug << ", disabled"; + debug << ", states=" << widget->windowState() + << ", type=" << widget->windowType() << ", flags=" << widget->windowFlags(); + formatWidgetAttributes(debug, widget); + if (widget->isWindow()) + debug << ", window"; + debug << ", " << geometry.width() << 'x' << geometry.height() + << forcesign << geometry.x() << geometry.y() << noforcesign; + if (frameGeometry != geometry) { + const QMargins margins(geometry.x() - frameGeometry.x(), + geometry.y() - frameGeometry.y(), + frameGeometry.right() - geometry.right(), + frameGeometry.bottom() - geometry.bottom()); + debug << ", margins=" << margins; + } + debug << ", devicePixelRatio=" << widget->devicePixelRatio(); + if (const WId wid = widget->internalWinId()) + debug << ", winId=0x" << hex << wid << dec; + } + debug << ')'; + } else { + debug << "QWidget(0x0)"; + } + return debug; +} +#endif // !QT_NO_DEBUG_STREAM + QT_END_NAMESPACE #include "moc_qwidget.cpp" |