From 08d4caadd734e640b3c5521306ff2ea0cfe600d0 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 15 Jan 2020 11:02:22 +0100 Subject: Prepare callers for QChar-to-QString change in some QLocale returns The assorted characters making up numbers can potentially need surrogate pairs for their encoding, so Qt6 shall make the methods returning them return QString instead of QChar. Prepare callers of these methods to cope when that happens. This follows up on commit f91af791cc3be1dfb9645ed4ebba10a7d9f74134, which announced the intent to change the return type. Task-number: QTBUG-81053 Change-Id: I99896c1d4fc2e24758c6486eaca32fd915b9a673 Reviewed-by: Thiago Macieira --- src/widgets/widgets/qspinbox.cpp | 48 ++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 19 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp index 61ea81c892..ae4394dc97 100644 --- a/src/widgets/widgets/qspinbox.cpp +++ b/src/widgets/widgets/qspinbox.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -1168,11 +1168,11 @@ QVariant QSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, } else { num = locale.toInt(copy, &ok); if (!ok && (max >= 1000 || min <= -1000)) { - const QChar sep = locale.groupSeparator(); - const QChar doubleSep[2] = {sep, sep}; - if (copy.contains(sep) && !copy.contains(QString(doubleSep, 2))) { + const QString sep(locale.groupSeparator()); + const QString doubleSep = sep + sep; + if (copy.contains(sep) && !copy.contains(doubleSep)) { QString copy2 = copy; - copy2.remove(locale.groupSeparator()); + copy2.remove(sep); num = locale.toInt(copy2, &ok); } } @@ -1314,6 +1314,10 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, const bool plus = max >= 0; const bool minus = min <= 0; + const QString group(locale.groupSeparator()); + const uint groupUcs = (group.size() > 1 && group.at(0).isHighSurrogate() + ? QChar::surrogateToUcs4(group.at(0), group.at(1)) + : group.at(0).unicode()); switch (len) { case 0: state = max != min ? QValidator::Intermediate : QValidator::Invalid; @@ -1360,14 +1364,15 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, } } } else { - const QChar last = copy.at(len - 1); - const QChar secondLast = copy.at(len - 2); - if ((last == locale.groupSeparator() || last.isSpace()) - && (secondLast == locale.groupSeparator() || secondLast.isSpace())) { + const QChar last = copy.back(); + const bool groupEnd = copy.endsWith(group); + const QStringView head(copy.constData(), groupEnd ? len - group.size() : len - 1); + const QChar secondLast = head.back(); + if ((groupEnd || last.isSpace()) && (head.endsWith(group) || secondLast.isSpace())) { state = QValidator::Invalid; QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; goto end; - } else if (last.isSpace() && (!locale.groupSeparator().isSpace() || secondLast.isSpace())) { + } else if (last.isSpace() && (!QChar::isSpace(groupUcs) || secondLast.isSpace())) { state = QValidator::Invalid; QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; goto end; @@ -1381,26 +1386,31 @@ QVariant QDoubleSpinBoxPrivate::validateAndInterpret(QString &input, int &pos, QSBDEBUG() << __FILE__ << __LINE__ << locale << copy << num << ok; if (!ok) { - if (locale.groupSeparator().isPrint()) { - if (max < 1000 && min > -1000 && copy.contains(locale.groupSeparator())) { + if (QChar::isPrint(groupUcs)) { + if (max < 1000 && min > -1000 && copy.contains(group)) { state = QValidator::Invalid; QSBDEBUG() << __FILE__ << __LINE__<< "state is set to Invalid"; goto end; } const int len = copy.size(); - for (int i=0; i Date: Mon, 6 Jan 2020 10:26:49 +0100 Subject: Make sure the focus is passed on correctly when back-tabbing When the tested widget has a focus proxy, then we should check if the current focus widget is not the same as that focus proxy before setting it to be the widget that gets focus. This ensures that when back-tabbing from a widget like QDoubleSpinBox that it will not get stuck inside that widget and will back-tab to the next correct one. Fixes: QTBUG-81097 Change-Id: I3f689c7715da7f3ce8c3d2f616041528f5778a2f Reviewed-by: Friedemann Kleint --- src/widgets/kernel/qapplication.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/widgets') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index ef76265f8b..ce32fd39a8 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -2139,7 +2139,8 @@ QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool && !(!next && focusProxy && test->isAncestorOf(focusProxy)) && test->isVisibleTo(toplevel) && test->isEnabled() && !(w->windowType() == Qt::SubWindow && !w->isAncestorOf(test)) - && (toplevel->windowType() != Qt::SubWindow || toplevel->isAncestorOf(test))) { + && (toplevel->windowType() != Qt::SubWindow || toplevel->isAncestorOf(test)) + && f != focusProxy) { w = test; if (seenWindow) focusWidgetAfterWindow = true; -- cgit v1.2.3 From ba1e880fbb2aacb550980bc2de35246bdcc38481 Mon Sep 17 00:00:00 2001 From: Indiana Kernick Date: Sat, 14 Dec 2019 05:31:48 +0000 Subject: QScrollArea: fix off-by-one error in ensureWidgetVisible If focusRect was 5 pixels past the right side of the viewport, then the scroll area would need to be scrolled by 5 pixels. The error arises because of this: focusRect.right() - d->viewport->width() == 4 focusRect.right() is still inside the rectangle but width is not. So one has to be added. Likewise for focusRect.bottom() and height. Change-Id: Ice47a7758d136b2e4bdcbe25a33a015b37f500c1 Fixes: QTBUG-80093 Reviewed-by: Richard Moe Gustavsen --- src/widgets/widgets/qscrollarea.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qscrollarea.cpp b/src/widgets/widgets/qscrollarea.cpp index 68aa545082..c36ec98f9a 100644 --- a/src/widgets/widgets/qscrollarea.cpp +++ b/src/widgets/widgets/qscrollarea.cpp @@ -490,14 +490,14 @@ void QScrollArea::ensureWidgetVisible(QWidget *childWidget, int xmargin, int yma if (focusRect.width() > visibleRect.width()) d->hbar->setValue(focusRect.center().x() - d->viewport->width() / 2); else if (focusRect.right() > visibleRect.right()) - d->hbar->setValue(focusRect.right() - d->viewport->width()); + d->hbar->setValue(focusRect.right() - d->viewport->width() + 1); else if (focusRect.left() < visibleRect.left()) d->hbar->setValue(focusRect.left()); if (focusRect.height() > visibleRect.height()) d->vbar->setValue(focusRect.center().y() - d->viewport->height() / 2); else if (focusRect.bottom() > visibleRect.bottom()) - d->vbar->setValue(focusRect.bottom() - d->viewport->height()); + d->vbar->setValue(focusRect.bottom() - d->viewport->height() + 1); else if (focusRect.top() < visibleRect.top()) d->vbar->setValue(focusRect.top()); } -- cgit v1.2.3 From 1ed802e3b8a7f236bd277719090f461a87eae78e Mon Sep 17 00:00:00 2001 From: Venugopal Shivashankar Date: Wed, 22 Jan 2020 16:07:05 +0100 Subject: Doc: Update the stylesheet reference for widgets and richtext MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the Qt-specific properites to the list. Fixes: QTBUG-37938 Change-Id: I178de6cd5e17cd282a20ccee9ce8355f540c38a1 Reviewed-by: Tor Arne Vestbø Reviewed-by: Paul Wicking Reviewed-by: Richard Moe Gustavsen Reviewed-by: Simon Hausmann --- src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc index c8f374a1b1..efe30308f0 100644 --- a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc +++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc @@ -2526,6 +2526,18 @@ See also \l{#height-prop}{height}. + \row + \li \b -qt-background-role + \li \l{#paletterole}{PaletteRole} + \li The \c{background-color} for the subcontrol or widget based on the + chosen role. + + \row + \li \b -qt-style-features + \li \c list + \li The list of CSS properties that you want to apply Qt-specific styles on. + + \note The \c list can only include properties that are not pixmap-based. \endtable \target list of icons -- cgit v1.2.3