From eba3b567d639ab40c939e27900029f93e351d77a Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 6 May 2019 13:02:57 +0200 Subject: Accessibility: Improve handling of read-only state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have been rather sloppy in how read-only versus editable is handled. According to the definition, editable signifies that in principle a widget allows the user to change its text. Read-only means that this ability is (currently) disabled. Task-number: QTBUG-75002 Change-Id: I5d71843abcdaac52f4a60a1abcac2604341f6c96 Reviewed-by: Jan Arve Sæther --- src/widgets/accessible/simplewidgets.cpp | 10 ++++++++-- src/widgets/accessible/simplewidgets_p.h | 1 + src/widgets/widgets/qlineedit.cpp | 6 ++++++ 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp index efcf4cdc8b..716c833fc9 100644 --- a/src/widgets/accessible/simplewidgets.cpp +++ b/src/widgets/accessible/simplewidgets.cpp @@ -454,6 +454,13 @@ QAccessible::Role QAccessibleDisplay::role() const return QAccessibleWidget::role(); } +QAccessible::State QAccessibleDisplay::state() const +{ + QAccessible::State s = QAccessibleWidget::state(); + s.readOnly = true; + return s; +} + QString QAccessibleDisplay::text(QAccessible::Text t) const { QString str; @@ -732,10 +739,9 @@ QAccessible::State QAccessibleLineEdit::state() const QAccessible::State state = QAccessibleWidget::state(); QLineEdit *l = lineEdit(); + state.editable = true; if (l->isReadOnly()) state.readOnly = true; - else - state.editable = true; if (l->echoMode() != QLineEdit::Normal) state.passwordEdit = true; diff --git a/src/widgets/accessible/simplewidgets_p.h b/src/widgets/accessible/simplewidgets_p.h index fcd0e7df47..73572e3059 100644 --- a/src/widgets/accessible/simplewidgets_p.h +++ b/src/widgets/accessible/simplewidgets_p.h @@ -116,6 +116,7 @@ public: QString text(QAccessible::Text t) const override; QAccessible::Role role() const override; + QAccessible::State state() const override; QVector >relations(QAccessible::Relation match = QAccessible::AllRelations) const override; void *interface_cast(QAccessible::InterfaceType t) override; diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 4301a3a2e7..86c7d35dbc 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -1369,6 +1369,12 @@ void QLineEdit::setReadOnly(bool enable) QEvent event(QEvent::ReadOnlyChange); QCoreApplication::sendEvent(this, &event); update(); +#ifndef QT_NO_ACCESSIBILITY + QAccessible::State changedState; + changedState.readOnly = true; + QAccessibleStateChangeEvent ev(this, changedState); + QAccessible::updateAccessibility(&ev); +#endif } } -- cgit v1.2.3 From fc9baeeb9f6360051cb02d1da6c094aa8154f58e Mon Sep 17 00:00:00 2001 From: Vova Mshanetskiy Date: Thu, 25 Apr 2019 17:02:44 +0300 Subject: QWidgetTextControl: Emit cursorPositionChanged() when handling IM event QWidgetTextControl and consequently QTextEdit did not emit cursorPositionChanged() signal when cursor position was changed by a QInputMethodEvent with a QInputMethodEvent::Selection attribute. This is especially important on Android because QAndroidInputContext uses such events extensively to move the cursor and also relies on cursorPositionChanged() signal being emitted by the focus object. If the signal is not emitted, QAndroidInputContext does not notify the virtual keyboard about cursor position change which results in various glitches. Change-Id: I7edd141258c483e6f103adcd6e40049b49c13387 Reviewed-by: Richard Moe Gustavsen --- src/widgets/widgets/qwidgettextcontrol.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/widgets') diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index e179ea3b40..6b8ce63380 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -1974,6 +1974,8 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e) || e->preeditString() != cursor.block().layout()->preeditAreaText() || e->replacementLength() > 0; + int oldCursorPos = cursor.position(); + cursor.beginEditBlock(); if (isGettingInput) { cursor.removeSelectedText(); @@ -2078,6 +2080,8 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e) if (cursor.d) cursor.d->setX(); + if (oldCursorPos != cursor.position()) + emit q->cursorPositionChanged(); if (oldPreeditCursor != preeditCursor) emit q->microFocusChanged(); } -- cgit v1.2.3 From 69f6cab0af78285472deb8d91c862c600685e618 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sun, 28 Apr 2019 12:52:19 +0200 Subject: Doc: replace even more null/0/nullptr with \nullptr macro Try to replace all wordings like '.. to 0' with '.. to \nullptr'. Also checked for 'null pointer' and similar. Change-Id: I73341f59ba51e0798e816a8b1a532c7c7374b74a Reviewed-by: Edward Welbourne --- src/widgets/dialogs/qfilesystemmodel.cpp | 4 ++-- src/widgets/itemviews/qlistwidget.cpp | 4 ++-- src/widgets/itemviews/qtablewidget.cpp | 4 ++-- src/widgets/itemviews/qtreewidget.cpp | 4 ++-- src/widgets/itemviews/qtreewidgetitemiterator.cpp | 8 ++++---- src/widgets/kernel/qapplication.cpp | 4 ++-- src/widgets/kernel/qlayout.cpp | 8 ++++---- src/widgets/util/qundoview.cpp | 2 +- src/widgets/widgets/qmainwindow.cpp | 6 +++--- src/widgets/widgets/qmdiarea.cpp | 6 +++--- src/widgets/widgets/qmenubar.cpp | 4 ++-- 11 files changed, 27 insertions(+), 27 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index d29f74e93d..e486037e08 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -1197,8 +1197,8 @@ QStringList QFileSystemModel::mimeTypes() const \a indexes. The format used to describe the items corresponding to the indexes is obtained from the mimeTypes() function. - If the list of indexes is empty, 0 is returned rather than a serialized - empty list. + If the list of indexes is empty, \nullptr is returned rather than a + serialized empty list. */ QMimeData *QFileSystemModel::mimeData(const QModelIndexList &indexes) const { diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp index e46d25bef1..37bb370e73 100644 --- a/src/widgets/itemviews/qlistwidget.cpp +++ b/src/widgets/itemviews/qlistwidget.cpp @@ -1902,8 +1902,8 @@ QStringList QListWidget::mimeTypes() const \a items. The format used to describe the items is obtained from the mimeTypes() function. - If the list of items is empty, 0 is returned instead of a serialized empty - list. + If the list of items is empty, \nullptr is returned instead of a + serialized empty list. */ #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) QMimeData *QListWidget::mimeData(const QList &items) const diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp index ec4897a7ae..0fb9e28385 100644 --- a/src/widgets/itemviews/qtablewidget.cpp +++ b/src/widgets/itemviews/qtablewidget.cpp @@ -2633,8 +2633,8 @@ QStringList QTableWidget::mimeTypes() const \a items. The format used to describe the items is obtained from the mimeTypes() function. - If the list of items is empty, 0 is returned rather than a serialized - empty list. + If the list of items is empty, \nullptr is returned rather than a + serialized empty list. */ #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) QMimeData *QTableWidget::mimeData(const QList &items) const diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index 29cc199526..d2dc91b18c 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -3395,8 +3395,8 @@ QStringList QTreeWidget::mimeTypes() const \a items. The format used to describe the items is obtained from the mimeTypes() function. - If the list of items is empty, 0 is returned rather than a serialized - empty list. + If the list of items is empty, \nullptr is returned rather than a + serialized empty list. */ #if QT_VERSION >= QT_VERSION_CHECK(6,0,0) QMimeData *QTreeWidget::mimeData(const QList &items) const diff --git a/src/widgets/itemviews/qtreewidgetitemiterator.cpp b/src/widgets/itemviews/qtreewidgetitemiterator.cpp index 1c1f60bc37..14c19fcb9c 100644 --- a/src/widgets/itemviews/qtreewidgetitemiterator.cpp +++ b/src/widgets/itemviews/qtreewidgetitemiterator.cpp @@ -170,7 +170,7 @@ QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator=(const QTreeWidgetIte /*! The prefix ++ operator (++it) advances the iterator to the next matching item and returns a reference to the resulting iterator. - Sets the current pointer to 0 if the current item is the last matching item. + Sets the current pointer to \nullptr if the current item is the last matching item. */ QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator++() @@ -185,7 +185,7 @@ QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator++() /*! The prefix -- operator (--it) advances the iterator to the previous matching item and returns a reference to the resulting iterator. - Sets the current pointer to 0 if the current item is the first matching item. + Sets the current pointer to \nullptr if the current item is the first matching item. */ QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator--() @@ -395,7 +395,7 @@ void QTreeWidgetItemIteratorPrivate::ensureValidIterator(const QTreeWidgetItem * iterator goes backward.) If the current item is beyond the last item, the current item pointer is - set to 0. Returns the resulting iterator. + set to \nullptr. Returns the resulting iterator. */ /*! @@ -411,7 +411,7 @@ void QTreeWidgetItemIteratorPrivate::ensureValidIterator(const QTreeWidgetItem * iterator goes forward.) If the current item is ahead of the last item, the current item pointer is - set to 0. Returns the resulting iterator. + set to \nullptr. Returns the resulting iterator. */ /*! diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index b4a091765b..8f339a23f6 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1904,8 +1904,8 @@ void QApplication::aboutQt() This signal is emitted when the widget that has keyboard focus changed from \a old to \a now, i.e., because the user pressed the tab-key, clicked into - a widget or changed the active window. Both \a old and \a now can be the - null-pointer. + a widget or changed the active window. Both \a old and \a now can be \nullptr. + The signal is emitted after both widget have been notified about the change through QFocusEvent. diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index e3f6a56875..53c4de49c6 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -109,7 +109,7 @@ static int menuBarHeightForWidth(QWidget *menubar, int w) /*! Constructs a new top-level QLayout, with parent \a parent. - \a parent may not be a \nullptr. + \a parent may not be \nullptr. The layout is set directly as the top-level layout for \a parent. There can be only one top-level layout for a @@ -419,9 +419,9 @@ void QLayout::setContentsMargins(const QMargins &margins) /*! \since 4.3 - Extracts the left, top, right, and bottom margins used around the - layout, and assigns them to *\a left, *\a top, *\a right, and *\a - bottom (unless they are null pointers). + For each of \a left, \a top, \a right and \a bottom that is not + \nullptr, stores the size of the margin named in the location the + pointer refers to. By default, QLayout uses the values provided by the style. On most platforms, the margin is 11 pixels in all directions. diff --git a/src/widgets/util/qundoview.cpp b/src/widgets/util/qundoview.cpp index c862cbcea5..f59d87fb9d 100644 --- a/src/widgets/util/qundoview.cpp +++ b/src/widgets/util/qundoview.cpp @@ -361,7 +361,7 @@ QUndoStack *QUndoView::stack() const Sets the stack displayed by this view to \a stack. If \a stack is 0, the view will be empty. - If the view was previously looking at a QUndoGroup, the group is set to 0. + If the view was previously looking at a QUndoGroup, the group is set to \nullptr. \sa stack(), setGroup() */ diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index fae3aebba4..9c4c46f2d6 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -596,7 +596,7 @@ QStatusBar *QMainWindow::statusBar() const /*! Sets the status bar for the main window to \a statusbar. - Setting the status bar to 0 will remove it from the main window. + Setting the status bar to \nullptr will remove it from the main window. Note that QMainWindow takes ownership of the \a statusbar pointer and deletes it at the appropriate time. @@ -1464,8 +1464,8 @@ void QMainWindow::contextMenuEvent(QContextMenuEvent *event) #if QT_CONFIG(menu) /*! Returns a popup menu containing checkable entries for the toolbars and - dock widgets present in the main window. If there are no toolbars and - dock widgets present, this function returns a null pointer. + dock widgets present in the main window. If there are no toolbars and + dock widgets present, this function returns \nullptr. By default, this function is called by the main window when the user activates a context menu, typically by right-clicking on a toolbar or a dock diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index feea7cd050..8b201dcf9d 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -1998,9 +1998,9 @@ QMdiSubWindow *QMdiArea::addSubWindow(QWidget *widget, Qt::WindowFlags windowFla Removes \a widget from the MDI area. The \a widget must be either a QMdiSubWindow or a widget that is the internal widget of a subwindow. Note \a widget is never actually deleted by QMdiArea. - If a QMdiSubWindow is passed in its parent is set to 0 and it is - removed, but if an internal widget is passed in the child widget - is set to 0 but the QMdiSubWindow is not removed. + If a QMdiSubWindow is passed in, its parent is set to \nullptr and it is + removed; but if an internal widget is passed in, the child widget + is set to \nullptr and the QMdiSubWindow is \e not removed. \sa addSubWindow() */ diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index e7984078de..a53d7841f4 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -897,8 +897,8 @@ QAction *QMenuBar::insertMenu(QAction *before, QMenu *menu) } /*! - Returns the QAction that is currently highlighted. A null pointer - will be returned if no action is currently selected. + Returns the QAction that is currently highlighted, if any, + else \nullptr. */ QAction *QMenuBar::activeAction() const { -- cgit v1.2.3 From 3d8ed3ba969ba958401dbf5e6760cf0788f1888e Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Fri, 12 Apr 2019 15:59:03 +0200 Subject: Fix: style sheet styling of background of triangular QTabWidget tabs The triangular tab shape is not reproducible with setting style border options, so it should be painted with the usual code path, also when a custom background has been set. Fixes: QTBUG-72096 Change-Id: I7bc1c0579386b8ea7266ce6456534c2519d9addf Reviewed-by: Christian Ehrlicher --- src/widgets/styles/qstylesheetstyle.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index fc4efa18fb..2118bad9d6 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -4165,12 +4165,12 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q if (const QStyleOptionTab *tab = qstyleoption_cast(opt)) { QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab); QRect r = positionRect(w, subRule, PseudoElement_TabBarTab, opt->rect, opt->direction); - if (ce == CE_TabBarTabShape && subRule.hasDrawable()) { + if (ce == CE_TabBarTabShape && subRule.hasDrawable() && tab->shape < QTabBar::TriangularNorth) { subRule.drawRule(p, r); return; } QStyleOptionTab tabCopy(*tab); - subRule.configurePalette(&tabCopy.palette, QPalette::WindowText, QPalette::Window); + subRule.configurePalette(&tabCopy.palette, QPalette::WindowText, QPalette::Base); QFont oldFont = p->font(); if (subRule.hasFont) p->setFont(subRule.font); -- cgit v1.2.3