diff options
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r-- | src/widgets/kernel/qlayout.cpp | 3 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 93 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.h | 9 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetwindow.cpp | 4 |
4 files changed, 97 insertions, 12 deletions
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index 822690942e..dcacea4777 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -1175,13 +1175,12 @@ QLayoutItem *QLayout::replaceWidget(QWidget *from, QWidget *to, Qt::FindChildOpt if (index == -1) return 0; + addChildWidget(to); QLayoutItem *newitem = new QWidgetItem(to); newitem->setAlignment(item->alignment()); QLayoutItem *r = d->replaceAt(index, newitem); if (!r) delete newitem; - else - addChildWidget(to); return r; } diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index e1053b4add..a48bfdf3c6 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -100,6 +100,7 @@ #include "qwindowcontainer_p.h" +#include <QtPlatformHeaders/qxcbwindowfunctions.h> // widget/widget data creation count //#define QWIDGET_EXTRA_DEBUG @@ -704,7 +705,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(). @@ -5937,7 +5938,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 { @@ -6032,7 +6033,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); } /*! @@ -6042,6 +6047,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) @@ -6092,7 +6100,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 { @@ -6108,8 +6116,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()) @@ -6152,10 +6167,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 */ @@ -12809,6 +12829,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" diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index c3913e9d45..782c892a32 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -89,6 +89,9 @@ class QGraphicsEffect; class QRasterWindowSurface; class QUnifiedToolbarSurface; class QPixmap; +#ifndef QT_NO_DEBUG_STREAM +class QDebug; +#endif class QWidgetData { @@ -165,7 +168,7 @@ class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice Q_PROPERTY(bool acceptDrops READ acceptDrops WRITE setAcceptDrops) Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle NOTIFY windowTitleChanged DESIGNABLE isWindow) Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon NOTIFY windowIconChanged DESIGNABLE isWindow) - Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText NOTIFY windowIconTextChanged DESIGNABLE isWindow) + Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText NOTIFY windowIconTextChanged DESIGNABLE isWindow) // deprecated Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity DESIGNABLE isWindow) Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified DESIGNABLE isWindow) #ifndef QT_NO_TOOLTIP @@ -858,6 +861,10 @@ inline bool QWidget::testAttribute(Qt::WidgetAttribute attribute) const #define QWIDGETSIZE_MAX ((1<<24)-1) +#ifndef QT_NO_DEBUG_STREAM +Q_WIDGETS_EXPORT QDebug operator<<(QDebug, const QWidget *); +#endif + QT_END_NAMESPACE #endif // QWIDGET_H diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index ba8c16e838..efe7d9415b 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -161,7 +161,7 @@ bool QWidgetWindow::event(QEvent *event) if (m_widget->testAttribute(Qt::WA_DontShowOnScreen)) { // \a event is uninteresting for QWidgetWindow, the event was probably // generated before WA_DontShowOnScreen was set - return m_widget->event(event); + return QCoreApplication::sendEvent(m_widget, event); } switch (event->type()) { @@ -303,7 +303,7 @@ bool QWidgetWindow::event(QEvent *event) break; } - if (m_widget->event(event) && event->type() != QEvent::Timer) + if (QCoreApplication::sendEvent(m_widget, event) && event->type() != QEvent::Timer) return true; return QWindow::event(event); |