From: Friedemann Kleint Date: Thu, 10 May 2012 14:57:41 +0000 (+0200) Subject: Keep object name of QWidgetWindow in sync with the widget. X-Git-Tag: 071012110112~1074 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=78b9de746c9328cb56339d36598a67977360be2b;p=profile%2Fivi%2Fqtbase.git Keep object name of QWidgetWindow in sync with the widget. Use new objectNameChanged() signal. Change-Id: I247566bd51d23ec65ff74ba9ac7be0d18e8ff160 Reviewed-by: Girish Ramakrishnan Reviewed-by: Samuel Rødal --- diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 7461255..1b5b9cc 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -9074,16 +9074,6 @@ void QWidget::ensurePolished() const QChildEvent e(QEvent::ChildPolished, const_cast(this)); QCoreApplication::sendEvent(d->parent, &e); } - if (d->extra && d->extra->topextra && d->extra->topextra->window - && d->extra->topextra->window->objectName().isEmpty()) { - QString on = objectName(); - if (on.isEmpty()) { - on = QString::fromUtf8(metaObject()->className()); - on += QStringLiteral("Class"); - } - on += QStringLiteral("Window"); - d->extra->topextra->window->setObjectName(on); - } } /*! diff --git a/src/widgets/kernel/qwidgetwindow_qpa.cpp b/src/widgets/kernel/qwidgetwindow_qpa.cpp index 5639bac..ddda4c3 100644 --- a/src/widgets/kernel/qwidgetwindow_qpa.cpp +++ b/src/widgets/kernel/qwidgetwindow_qpa.cpp @@ -60,6 +60,8 @@ extern bool qt_try_modal(QWidget *widget, QEvent::Type type); QWidgetWindow::QWidgetWindow(QWidget *widget) : m_widget(widget) { + updateObjectName(); + connect(m_widget, &QObject::objectNameChanged, this, &QWidgetWindow::updateObjectName); } #ifndef QT_NO_ACCESSIBILITY @@ -507,4 +509,13 @@ bool QWidgetWindow::nativeEvent(const QByteArray &eventType, void *message, long return m_widget->nativeEvent(eventType, message, result); } +void QWidgetWindow::updateObjectName() +{ + QString name = m_widget->objectName(); + if (name.isEmpty()) + name = QString::fromUtf8(m_widget->metaObject()->className()) + QStringLiteral("Class"); + name += QStringLiteral("Window"); + setObjectName(name); +} + QT_END_NAMESPACE diff --git a/src/widgets/kernel/qwidgetwindow_qpa_p.h b/src/widgets/kernel/qwidgetwindow_qpa_p.h index e5c07a2..80af5e6 100644 --- a/src/widgets/kernel/qwidgetwindow_qpa_p.h +++ b/src/widgets/kernel/qwidgetwindow_qpa_p.h @@ -83,6 +83,9 @@ protected: void handleWindowStateChangedEvent(QWindowStateChangeEvent *event); bool nativeEvent(const QByteArray &eventType, void *message, long *result); +private slots: + void updateObjectName(); + private: void updateGeometry();