From 018cb899d482967eb7d8ebdc48cadf1743abe680 Mon Sep 17 00:00:00 2001 From: Jan-Arve Saether Date: Tue, 22 May 2012 09:15:38 +0200 Subject: Replace (un)checkAction with toggleAction (3/3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove all references to (un)checkAction. This commit finalizes the intended change. Change-Id: I79d3b30b5c3d9fbe276c2c94fed5971bb21d6c02 Reviewed-by: Morten Johan Sørvig --- src/gui/accessible/qaccessible2.cpp | 30 ++-------------------- src/gui/accessible/qaccessible2.h | 2 -- src/plugins/accessible/widgets/simplewidgets.cpp | 21 +++++---------- .../other/qaccessibility/tst_qaccessibility.cpp | 24 ++++++++--------- 4 files changed, 20 insertions(+), 57 deletions(-) diff --git a/src/gui/accessible/qaccessible2.cpp b/src/gui/accessible/qaccessible2.cpp index 5ada74ca63..581568b32d 100644 --- a/src/gui/accessible/qaccessible2.cpp +++ b/src/gui/accessible/qaccessible2.cpp @@ -372,13 +372,12 @@ QT_BEGIN_NAMESPACE In general you should use one of the predefined action names, unless describing an action that does not fit these: \table \header \li Action name \li Description - \row \li \l checkAction() \li checks the item (checkbox, radio button, ...) + \row \li \l toggleAction() \li toggles the item (checkbox, radio button, switch, ...) \row \li \l decreaseAction() \li decrease the value of the accessible (e.g. spinbox) \row \li \l increaseAction() \li increase the value of the accessible (e.g. spinbox) \row \li \l pressAction() \li press or click or activate the accessible (should correspont to clicking the object with the mouse) \row \li \l setFocusAction() \li set the focus to this accessible \row \li \l showMenuAction() \li show a context menu, corresponds to right-clicks - \row \li \l uncheckAction() \li uncheck the item (checkbox, radio button, ...) \endtable In order to invoke the action, \l doAction() is called with an action name. @@ -461,9 +460,7 @@ struct QAccessibleActionStrings decreaseAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Decrease"))), showMenuAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "ShowMenu"))), setFocusAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "SetFocus"))), - toggleAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Toggle"))), - checkAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Check"))), - uncheckAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Uncheck"))) {} + toggleAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Toggle"))) {} const QString pressAction; const QString increaseAction; @@ -471,8 +468,6 @@ struct QAccessibleActionStrings const QString showMenuAction; const QString setFocusAction; const QString toggleAction; - const QString checkAction; - const QString uncheckAction; }; Q_GLOBAL_STATIC(QAccessibleActionStrings, accessibleActionStrings) @@ -497,10 +492,6 @@ QString QAccessibleActionInterface::localizedActionDescription(const QString &ac return tr("Sets the focus"); else if (actionName == strings->toggleAction) return tr("Toggles the state"); - else if (actionName == strings->checkAction) - return tr("Checks the checkbox"); - else if (actionName == strings->uncheckAction) - return tr("Unchecks the checkbox"); return QString(); } @@ -559,23 +550,6 @@ const QString &QAccessibleActionInterface::toggleAction() return accessibleActionStrings()->toggleAction; } -/*! - Returns the name of the check default action. - \sa actionNames(), localizedActionName() - */ -const QString &QAccessibleActionInterface::checkAction() -{ - return accessibleActionStrings()->checkAction; -} - -/*! - Returns the name of the uncheck default action. - \sa actionNames(), localizedActionName() - */ -const QString &QAccessibleActionInterface::uncheckAction() -{ - return accessibleActionStrings()->uncheckAction; -} /*! \internal diff --git a/src/gui/accessible/qaccessible2.h b/src/gui/accessible/qaccessible2.h index 94e5319147..922fb73b7d 100644 --- a/src/gui/accessible/qaccessible2.h +++ b/src/gui/accessible/qaccessible2.h @@ -233,8 +233,6 @@ public: static const QString &showMenuAction(); static const QString &setFocusAction(); static const QString &toggleAction(); - static const QString &checkAction(); - static const QString &uncheckAction(); }; class Q_GUI_EXPORT QAccessibleImageInterface diff --git a/src/plugins/accessible/widgets/simplewidgets.cpp b/src/plugins/accessible/widgets/simplewidgets.cpp index af0c211cca..0fa6dc9990 100644 --- a/src/plugins/accessible/widgets/simplewidgets.cpp +++ b/src/plugins/accessible/widgets/simplewidgets.cpp @@ -168,18 +168,11 @@ QStringList QAccessibleButton::actionNames() const names << showMenuAction(); break; case QAccessible::RadioButton: - names << checkAction(); + names << toggleAction(); break; default: if (button()->isCheckable()) { - if (state().checked) { - names << uncheckAction(); - } else { - // FIXME - // QCheckBox *cb = qobject_cast(object()); - // if (!cb || !cb->isTristate() || cb->checkState() == Qt::PartiallyChecked) - names << checkAction(); - } + names << toggleAction(); } else { names << pressAction(); } @@ -203,10 +196,8 @@ void QAccessibleButton::doAction(const QString &actionName) else #endif button()->animateClick(); - } else if (actionName == checkAction()) { - button()->setChecked(true); - } else if (actionName == uncheckAction()) { - button()->setChecked(false); + } else if (actionName == toggleAction()) { + button()->toggle(); } else { QAccessibleWidget::doAction(actionName); } @@ -552,14 +543,14 @@ QStringList QAccessibleGroupBox::actionNames() const QStringList actions = QAccessibleWidget::actionNames(); if (groupBox()->isCheckable()) { - actions.prepend(QAccessibleActionInterface::checkAction()); + actions.prepend(QAccessibleActionInterface::toggleAction()); } return actions; } void QAccessibleGroupBox::doAction(const QString &actionName) { - if (actionName == QAccessibleActionInterface::checkAction()) + if (actionName == QAccessibleActionInterface::toggleAction()) groupBox()->setChecked(!groupBox()->isChecked()); } diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 68ad38deda..4607be4a7a 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -949,14 +949,14 @@ void tst_QAccessibility::buttonTest() interface = QAccessible::queryAccessibleInterface(&toggleButton); actionInterface = interface->actionInterface(); QCOMPARE(interface->role(), QAccessible::CheckBox); - QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::checkAction() << QAccessibleActionInterface::setFocusAction()); - QCOMPARE(actionInterface->localizedActionDescription(QAccessibleActionInterface::checkAction()), QString("Checks the checkbox")); + QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::toggleAction() << QAccessibleActionInterface::setFocusAction()); + QCOMPARE(actionInterface->localizedActionDescription(QAccessibleActionInterface::toggleAction()), QString("Toggles the state")); QVERIFY(!toggleButton.isChecked()); QVERIFY(!interface->state().checked); - actionInterface->doAction(QAccessibleActionInterface::checkAction()); + actionInterface->doAction(QAccessibleActionInterface::toggleAction()); QTest::qWait(500); QVERIFY(toggleButton.isChecked()); - QCOMPARE(actionInterface->actionNames().at(0), QAccessibleActionInterface::uncheckAction()); + QCOMPARE(actionInterface->actionNames().at(0), QAccessibleActionInterface::toggleAction()); QVERIFY(interface->state().checked); delete interface; @@ -987,12 +987,12 @@ void tst_QAccessibility::buttonTest() interface = QAccessible::queryAccessibleInterface(&checkBox); actionInterface = interface->actionInterface(); QCOMPARE(interface->role(), QAccessible::CheckBox); - QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::checkAction() << QAccessibleActionInterface::setFocusAction()); + QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::toggleAction() << QAccessibleActionInterface::setFocusAction()); QVERIFY(!interface->state().checked); - actionInterface->doAction(QAccessibleActionInterface::checkAction()); + actionInterface->doAction(QAccessibleActionInterface::toggleAction()); QTest::qWait(500); - QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::uncheckAction() << QAccessibleActionInterface::setFocusAction()); + QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::toggleAction() << QAccessibleActionInterface::setFocusAction()); QVERIFY(interface->state().checked); QVERIFY(checkBox.isChecked()); QAccessible::State st; @@ -1009,11 +1009,11 @@ void tst_QAccessibility::buttonTest() interface = QAccessible::queryAccessibleInterface(&radio); actionInterface = interface->actionInterface(); QCOMPARE(interface->role(), QAccessible::RadioButton); - QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::checkAction() << QAccessibleActionInterface::setFocusAction()); + QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::toggleAction() << QAccessibleActionInterface::setFocusAction()); QVERIFY(!interface->state().checked); - actionInterface->doAction(QAccessibleActionInterface::checkAction()); + actionInterface->doAction(QAccessibleActionInterface::toggleAction()); QTest::qWait(500); - QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::checkAction() << QAccessibleActionInterface::setFocusAction()); + QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::toggleAction() << QAccessibleActionInterface::setFocusAction()); QVERIFY(interface->state().checked); QVERIFY(radio.isChecked()); QAccessible::State st; @@ -2045,8 +2045,8 @@ void tst_QAccessibility::groupBoxTest() QAccessible::State state = iface->state(); QVERIFY(state.checkable); QVERIFY(!state.checked); - QVERIFY(actionIface->actionNames().contains(QAccessibleActionInterface::checkAction())); - actionIface->doAction(QAccessibleActionInterface::checkAction()); + QVERIFY(actionIface->actionNames().contains(QAccessibleActionInterface::toggleAction())); + actionIface->doAction(QAccessibleActionInterface::toggleAction()); QVERIFY(groupBox->isChecked()); state = iface->state(); QVERIFY(state.checked); -- cgit v1.2.3