diff options
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 102 |
1 files changed, 94 insertions, 8 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 49d64c5cd8..76c4cbcb97 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -245,6 +245,9 @@ QWidgetPrivate::QWidgetPrivate(int version) #if !defined(QT_NO_IM) , imHints(Qt::ImhNone) #endif +#ifndef QT_NO_TOOLTIP + , toolTipDuration(-1) +#endif , inheritedFontResolveMask(0) , inheritedPaletteResolveMask(0) , leftmargin(0) @@ -261,10 +264,12 @@ QWidgetPrivate::QWidgetPrivate(int version) , bg_role(QPalette::NoRole) , dirtyOpaqueChildren(1) , isOpaque(0) + , retainSizeWhenHiddenChanged(0) , inDirtyList(0) , isScrolled(0) , isMoved(0) , usesDoubleBufferedGLContext(0) + , mustHaveWindowHandle(0) #ifndef QT_NO_IM , inheritsInputMethodHints(0) #endif @@ -1144,9 +1149,10 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) data.in_destructor = false; // Widgets with Qt::MSWindowsOwnDC (typically QGLWidget) must have a window handle. - if (f & Qt::MSWindowsOwnDC) + if (f & Qt::MSWindowsOwnDC) { + mustHaveWindowHandle = 1; q->setAttribute(Qt::WA_NativeWindow); - + } //#ifdef Q_WS_MAC // q->setAttribute(Qt::WA_NativeWindow); //#endif @@ -5597,6 +5603,15 @@ void QWidgetPrivate::setWindowIconText_helper(const QString &title) setWindowIconText_sys(qt_setWindowTitle_helperHelper(title, q)); } +/*! + \fn void QWidget::windowIconTextChanged(const QString &iconText) + + This signal is emitted when the window's icon text has changed, with the + new \a iconText as an argument. + + \since 5.2 +*/ + void QWidget::setWindowIconText(const QString &iconText) { if (QWidget::windowIconText() == iconText) @@ -5608,8 +5623,19 @@ void QWidget::setWindowIconText(const QString &iconText) QEvent e(QEvent::IconTextChange); QApplication::sendEvent(this, &e); + + emit windowIconTextChanged(iconText); } +/*! + \fn void QWidget::windowTitleChanged(const QString &title) + + This signal is emitted when the window's title has changed, with the + new \a title as an argument. + + \since 5.2 +*/ + void QWidget::setWindowTitle(const QString &title) { if (QWidget::windowTitle() == title && !title.isEmpty() && !title.isNull()) @@ -5621,6 +5647,8 @@ void QWidget::setWindowTitle(const QString &title) QEvent e(QEvent::WindowTitleChange); QApplication::sendEvent(this, &e); + + emit windowTitleChanged(title); } @@ -5657,6 +5685,15 @@ void QWidgetPrivate::setWindowIcon_helper() } } +/*! + \fn void QWidget::windowIconChanged(const QIcon &icon) + + This signal is emitted when the window's icon has changed, with the + new \a icon as an argument. + + \since 5.2 +*/ + void QWidget::setWindowIcon(const QIcon &icon) { Q_D(QWidget); @@ -5670,6 +5707,8 @@ void QWidget::setWindowIcon(const QIcon &icon) d->setWindowIcon_sys(); d->setWindowIcon_helper(); + + emit windowIconChanged(icon); } @@ -7264,10 +7303,19 @@ void QWidget::setVisible(bool visible) create(); } -#if defined(Q_WS_X11) - if (windowType() == Qt::Window) - QApplicationPrivate::applyX11SpecificCommandLineArguments(this); -#endif + // Handling of the -qwindowgeometry, -geometry command line arguments + if (windowType() == Qt::Window && windowHandle()) { + static bool done = false; + if (!done) { + done = true; + const QRect oldGeometry = frameGeometry(); + const QRect geometry = QGuiApplicationPrivate::applyWindowGeometrySpecification(oldGeometry, windowHandle()); + if (oldGeometry.size() != geometry.size()) + resize(geometry.size()); + if (geometry.topLeft() != oldGeometry.topLeft()) + move(geometry.topLeft()); + } // done + } bool wasResized = testAttribute(Qt::WA_Resized); Qt::WindowStates initialWindowState = windowState(); @@ -8207,7 +8255,7 @@ bool QWidget::event(QEvent *event) #ifndef QT_NO_TOOLTIP case QEvent::ToolTip: if (!d->toolTip.isEmpty()) - QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), d->toolTip, this); + QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), d->toolTip, this, QRect(), d->toolTipDuration); else event->ignore(); break; @@ -9251,6 +9299,10 @@ void QWidget::setSizePolicy(QSizePolicy policy) setAttribute(Qt::WA_WState_OwnSizePolicy); if (policy == d->size_policy) return; + + if (d->size_policy.retainSizeWhenHidden() != policy.retainSizeWhenHidden()) + d->retainSizeWhenHiddenChanged = 1; + d->size_policy = policy; #ifndef QT_NO_GRAPHICSVIEW @@ -9261,6 +9313,7 @@ void QWidget::setSizePolicy(QSizePolicy policy) #endif updateGeometry(); + d->retainSizeWhenHiddenChanged = 0; if (isWindow() && d->maybeTopData()) d->topData()->sizeAdjusted = false; @@ -9389,7 +9442,9 @@ void QWidgetPrivate::updateGeometry_helper(bool forceUpdate) widgetItem->invalidateSizeCache(); QWidget *parent; if (forceUpdate || !extra || extra->minw != extra->maxw || extra->minh != extra->maxh) { - if (!q->isWindow() && !q->isHidden() && (parent = q->parentWidget())) { + const int isHidden = q->isHidden() && !size_policy.retainSizeWhenHidden() && !retainSizeWhenHiddenChanged; + + if (!q->isWindow() && !isHidden && (parent = q->parentWidget())) { if (parent->d_func()->layout) parent->d_func()->layout->invalidate(); else if (parent->isVisible()) @@ -10019,6 +10074,13 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) } #endif + // Don't set WA_NativeWindow on platforms that don't support it -- except for QGLWidget, which depends on it + if (attribute == Qt::WA_NativeWindow && !d->mustHaveWindowHandle) { + QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration(); + if (!platformIntegration->hasCapability(QPlatformIntegration::NativeWidgets)) + return; + } + setAttribute_internal(attribute, on, data, d); switch (attribute) { @@ -10426,6 +10488,30 @@ QString QWidget::toolTip() const Q_D(const QWidget); return d->toolTip; } + +/*! + \property QWidget::toolTipDuration + \brief the widget's tooltip duration + \since 5.2 + + Specifies how long time the tooltip will be displayed, in milliseconds. + If the value is -1 (default) the duration is calculated depending on the length of the tooltip. + + \sa toolTip +*/ + +void QWidget::setToolTipDuration(int msec) +{ + Q_D(QWidget); + d->toolTipDuration = msec; +} + +int QWidget::toolTipDuration() const +{ + Q_D(const QWidget); + return d->toolTipDuration; +} + #endif // QT_NO_TOOLTIP |