From 7a127fb4b605da6a6f9cc781fe67de7aa00048aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 13 Feb 2019 14:29:32 +0100 Subject: Document that dialog parent relationship does not imply stacking order MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On macOS, and most probably some X11 window managers, the parent/child relationship of the dialog is not possible to propagate to the platform, and the only determining factor of whether or not the windows stack on top of each other is the modal state of the window. Task-number: QTBUG-34767 Change-Id: I8b4b4910e3f905c44e577544fc347dbded373848 Reviewed-by: Volker Hilsheimer Reviewed-by: Topi Reiniƶ --- src/widgets/dialogs/qdialog.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index c9093095a7..1c10e3e786 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -246,6 +246,13 @@ void QDialogPrivate::deletePlatformHelper() window-system properties for the widget (in particular it will reset the Qt::Dialog flag). + \note The parent relationship of the dialog does \e{not} imply + that the dialog will always be stacked on top of the parent + window. To ensure that the dialog is always on top, make the + dialog modal. This also applies for child windows of the dialog + itself. To ensure that child windows of the dialog stay on top + of the dialog, make the child windows modal as well. + \section1 Modal Dialogs A \b{modal} dialog is a dialog that blocks input to other -- cgit v1.2.3 From 8b3463fdeb3d03fd0c87873089a6f84321eecc49 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 17 Feb 2019 21:02:11 +0100 Subject: QAbstractItemView: make v-aligned items texts more user-friendly Commit 25133a1b77c059e32760f3d288c985183d86da4a fixed the item view text layouting correctly in a technical way. For a vertically aligned text which does not fit into the given rect it is not user-friendly to show some parts of the text. It is better to display the start of it and show an elide marker in the last visible line. Fixes: QTBUG-73721 Change-Id: Ia7453133ea0a229b24196467168c8371585c4d8f Reviewed-by: Eirik Aavitsland Reviewed-by: Richard Moe Gustavsen --- src/widgets/styles/qcommonstyle.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 79e338a6e7..c739ddc6e2 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -843,11 +843,14 @@ static void drawArrow(const QStyle *style, const QStyleOptionToolButton *toolbut } #endif // QT_CONFIG(toolbutton) -static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth) +static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth, int maxHeight = -1, int *lastVisibleLine = nullptr) { + if (lastVisibleLine) + *lastVisibleLine = -1; qreal height = 0; qreal widthUsed = 0; textLayout.beginLayout(); + int i = 0; while (true) { QTextLine line = textLayout.createLine(); if (!line.isValid()) @@ -856,6 +859,13 @@ static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth) line.setPosition(QPointF(0, height)); height += line.height(); widthUsed = qMax(widthUsed, line.naturalTextWidth()); + // we assume that the height of the next line is the same as the current one + if (maxHeight > 0 && lastVisibleLine && height + line.height() > maxHeight) { + const QTextLine nextLine = textLayout.createLine(); + *lastVisibleLine = nextLine.isValid() ? i : -1; + break; + } + ++i; } textLayout.endLayout(); return QSizeF(widthUsed, height); @@ -869,7 +879,13 @@ QString QCommonStylePrivate::calculateElidedText(const QString &text, const QTex QTextLayout textLayout(text, font); textLayout.setTextOption(textOption); - viewItemTextLayout(textLayout, textRect.width()); + // In AlignVCenter mode when more than one line is displayed and the height only allows + // some of the lines it makes no sense to display those. From a users perspective it makes + // more sense to see the start of the text instead something inbetween. + const bool vAlignmentOptimization = paintStartPosition && valign.testFlag(Qt::AlignVCenter); + + int lastVisibleLine = -1; + viewItemTextLayout(textLayout, textRect.width(), vAlignmentOptimization ? textRect.height() : -1, &lastVisibleLine); const QRectF boundingRect = textLayout.boundingRect(); // don't care about LTR/RTL here, only need the height @@ -896,7 +912,7 @@ QString QCommonStylePrivate::calculateElidedText(const QString &text, const QTex const int start = line.textStart(); const int length = line.textLength(); const bool drawElided = line.naturalTextWidth() > textRect.width(); - bool elideLastVisibleLine = false; + bool elideLastVisibleLine = lastVisibleLine == i; if (!drawElided && i + 1 < lineCount && lastVisibleLineShouldBeElided) { const QTextLine nextLine = textLayout.lineAt(i + 1); const int nextHeight = height + nextLine.height() / 2; @@ -927,7 +943,8 @@ QString QCommonStylePrivate::calculateElidedText(const QString &text, const QTex } // below visible text, can stop - if (height + layoutRect.top() >= textRect.bottom()) + if ((height + layoutRect.top() >= textRect.bottom()) || + (lastVisibleLine >= 0 && lastVisibleLine == i)) break; } return ret; -- cgit v1.2.3 From fed9fa171496fd24b264ef66e3e517d988fa3105 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Mon, 11 Mar 2019 22:00:27 +0100 Subject: Doc: replace 0 with \nullptr in documentation Replace some more 0 with \nullptr. Change-Id: I2af91bf3712eef5161b11da0c44614bc039ade03 Reviewed-by: Paul Wicking --- src/widgets/graphicsview/qgraphicsscene.cpp | 4 ++-- src/widgets/kernel/qtooltip.cpp | 4 ++-- src/widgets/kernel/qwidget.cpp | 8 ++++---- src/widgets/widgets/qabstractspinbox.cpp | 2 +- src/widgets/widgets/qcombobox.cpp | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index c517198a23..8bdce4af8b 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -5552,8 +5552,8 @@ bool QGraphicsScene::focusNextPrevChild(bool next) is a pointer to the item that gained input focus, or \nullptr if focus was lost. \a reason is the reason for the focus change (e.g., if the scene was deactivated while an input field had focus, \a oldFocusItem would point - to the input field item, \a newFocusItem would be 0, and \a reason would be - Qt::ActiveWindowFocusReason. + to the input field item, \a newFocusItem would be \nullptr, and \a reason + would be Qt::ActiveWindowFocusReason. */ /*! diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp index cf0f3f153b..f81cb471fa 100644 --- a/src/widgets/kernel/qtooltip.cpp +++ b/src/widgets/kernel/qtooltip.cpp @@ -482,8 +482,8 @@ bool QTipLabel::tipChanged(const QPoint &pos, const QString &text, QObject *o) The \a rect is in the coordinates of the widget you specify with \a w. If the \a rect is not empty you must specify a widget. - Otherwise this argument can be 0 but it is used to determine the - appropriate screen on multi-head systems. + Otherwise this argument can be \nullptr but it is used to + determine the appropriate screen on multi-head systems. If \a text is empty the tool tip is hidden. If the text is the same as the currently shown tooltip, the tip will \e not move. diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 6a5f80f1ff..b71a0ed052 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1009,8 +1009,8 @@ struct QWidgetExceptionCleaner deleted. The widget flags argument, \a f, is normally 0, but it can be set - to customize the frame of a window (i.e. \a - parent must be 0). To customize the frame, use a value composed + to customize the frame of a window (i.e. \a parent must be + \nullptr). To customize the frame, use a value composed from the bitwise OR of any of the \l{Qt::WindowFlags}{window flags}. If you add a child widget to an already visible widget you must @@ -4232,7 +4232,7 @@ void QWidget::setFixedHeight(int h) /*! Translates the widget coordinate \a pos to the coordinate system - of \a parent. The \a parent must not be 0 and must be a parent + of \a parent. The \a parent must not be \nullptr and must be a parent of the calling widget. \sa mapFrom(), mapToParent(), mapToGlobal(), underMouse() @@ -4257,7 +4257,7 @@ QPoint QWidget::mapTo(const QWidget * parent, const QPoint & pos) const /*! Translates the widget coordinate \a pos from the coordinate system of \a parent to this widget's coordinate system. The \a parent - must not be 0 and must be a parent of the calling widget. + must not be \nullptr and must be a parent of the calling widget. \sa mapTo(), mapFromParent(), mapFromGlobal(), underMouse() */ diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index 6a35dbe274..6edefaa311 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -688,7 +688,7 @@ QLineEdit *QAbstractSpinBox::lineEdit() const \fn void QAbstractSpinBox::setLineEdit(QLineEdit *lineEdit) Sets the line edit of the spinbox to be \a lineEdit instead of the - current line edit widget. \a lineEdit cannot be 0. + current line edit widget. \a lineEdit cannot be \nullptr. QAbstractSpinBox takes ownership of the new lineEdit diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index a24c9d350f..e38e1d7750 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -2034,7 +2034,7 @@ QAbstractItemModel *QComboBox::model() const } /*! - Sets the model to be \a model. \a model must not be 0. + Sets the model to be \a model. \a model must not be \nullptr. If you want to clear the contents of a model, call clear(). \sa clear() -- cgit v1.2.3