summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
-rw-r--r--src/widgets/kernel/qwidget.cpp63
1 files changed, 57 insertions, 6 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 49d64c5cd8..5532b04b22 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,6 +264,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
, bg_role(QPalette::NoRole)
, dirtyOpaqueChildren(1)
, isOpaque(0)
+ , retainSizeWhenHiddenChanged(0)
, inDirtyList(0)
, isScrolled(0)
, isMoved(0)
@@ -7264,10 +7268,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 +8220,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 +9264,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 +9278,7 @@ void QWidget::setSizePolicy(QSizePolicy policy)
#endif
updateGeometry();
+ d->retainSizeWhenHiddenChanged = 0;
if (isWindow() && d->maybeTopData())
d->topData()->sizeAdjusted = false;
@@ -9389,7 +9407,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 +10039,13 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
}
#endif
+ // Don't set WA_NativeWindow on platforms that don't support it
+ if (attribute == Qt::WA_NativeWindow) {
+ QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration();
+ if (!platformIntegration->hasCapability(QPlatformIntegration::NativeWidgets))
+ return;
+ }
+
setAttribute_internal(attribute, on, data, d);
switch (attribute) {
@@ -10426,6 +10453,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