4#include "private/qabstractbutton_p.h"
6#if QT_CONFIG(itemviews)
9#if QT_CONFIG(buttongroup)
11#include "private/qbuttongroup_p.h"
13#include "private/qapplication_p.h"
19#if QT_CONFIG(accessibility)
22#include <qpa/qplatformtheme.h>
24#include <QtCore/qpointer.h>
30#define AUTO_REPEAT_DELAY 300
31#define AUTO_REPEAT_INTERVAL 100
140#ifndef QT_NO_SHORTCUT
155#if QT_CONFIG(buttongroup)
157 return group->d_func()->buttonList;
164 auto isNoMemberOfMyAutoExclusiveGroup = [](
QAbstractButton *candidate) {
166#if QT_CONFIG(buttongroup)
167 || candidate->group()
171 candidates.removeIf(isNoMemberOfMyAutoExclusiveGroup);
178#if QT_CONFIG(buttongroup)
180 return group->d_func()->checkedButton;
188 for (
int i = 0;
i < buttonList.size(); ++
i) {
190 if (
b->d_func()->checked &&
b !=
q)
198#if QT_CONFIG(buttongroup)
202 group->d_func()->checkedButton =
q;
203 if (
group->d_func()->exclusive && previous && previous !=
q)
209 b->setChecked(
false);
216#if QT_CONFIG(buttongroup)
223 if (!fb || !buttonList.contains(fb))
232 for (
int i = 0;
i < buttonList.size(); ++
i) {
246 score = (
qAbs(
p.y() - goal.
y()) << 16) +
qAbs(
p.x() - goal.
x());
250 score = (
qAbs(
p.x() - goal.
x()) << 16) +
qAbs(
p.y() - goal.
y());
252 score = (1 << 30) + (
p.y() - goal.
y()) * (
p.y() - goal.
y()) + (
p.x() - goal.
x()) * (
p.x() - goal.
x());
255 if (score > bestScore && candidate)
260 if (
p.y() < goal.
y()) {
266 if (
p.y() > goal.
y()) {
272 if (
p.x() < goal.
x()) {
278 if (
p.x() > goal.
x()) {
288#ifdef QT_KEYPAD_NAVIGATION
289 && !QApplicationPrivate::keypadNavigationEnabled()
307#if QT_CONFIG(buttongroup)
315 for (
int i = 0;
i < buttonList.size(); ++
i) {
317 if (!
b->isCheckable())
321 : (
b->focusPolicy() &
~Qt::TabFocus)));
351 bool changeState =
true;
354#if QT_CONFIG(buttongroup)
362 QPointer<QAbstractButton> guard(
q);
380 QPointer<QAbstractButton> guard(
q);
382#if QT_CONFIG(buttongroup)
383 if (guard &&
group) {
394 QPointer<QAbstractButton> guard(
q);
396#if QT_CONFIG(buttongroup)
397 if (guard &&
group) {
408 QPointer<QAbstractButton> guard(
q);
410#if QT_CONFIG(buttongroup)
411 if (guard &&
group) {
422 QPointer<QAbstractButton> guard(
q);
424#if QT_CONFIG(buttongroup)
425 if (guard &&
group) {
448#if QT_CONFIG(buttongroup)
451 d->group->removeButton(
this);
488#ifndef QT_NO_SHORTCUT
495#if QT_CONFIG(accessibility)
496 QAccessibleEvent
event(
this, QAccessible::NameChanged);
497 QAccessible::updateAccessibility(&
event);
530#ifndef QT_NO_SHORTCUT
539 if (
d->shortcutId != 0)
587 if (!
d->checkable ||
d->checked ==
checked) {
588 if (!
d->blockRefresh)
593 if (!
checked &&
d->queryCheckedButton() ==
this) {
595#if QT_CONFIG(buttongroup)
596 if (
d->group ?
d->group->d_func()->exclusive :
d->autoExclusive)
599 d->group->d_func()->detectCheckedButton();
601 if (
d->autoExclusive)
606 QPointer<QAbstractButton> guard(
this);
609 if (!
d->blockRefresh)
618#if QT_CONFIG(accessibility)
622 QAccessibleStateChangeEvent
event(
this,
s);
623 QAccessible::updateAccessibility(&
event);
650 if (
d->autoRepeat &&
d->down)
651 d->repeatTimer.start(
d->autoRepeatDelay,
this);
653 d->repeatTimer.stop();
682 if (
d->autoRepeat &&
d->down)
683 d->repeatTimer.start(
d->autoRepeatDelay,
this);
685 d->repeatTimer.stop();
691 return d->autoRepeat;
714 return d->autoRepeatDelay;
737 return d->autoRepeatInterval;
768 return d->autoExclusive;
771#if QT_CONFIG(buttongroup)
809 if (!
d->animateTimer.isActive())
811 d->animateTimer.start(100,
this);
830 QPointer<QAbstractButton> guard(
this);
916#ifndef QT_NO_SHORTCUT
920 if (
d->shortcutId != se->shortcutId())
922 if (!se->isAmbiguous()) {
923 if (!
d->animateTimer.isActive())
975 d->repeatTimer.stop();
1012 const auto key = e->
key();
1015 .value<QList<Qt::Key>>();
1030#ifdef QT_KEYPAD_NAVIGATION
1031 if ((QApplicationPrivate::keypadNavigationEnabled()
1040 if (
d->autoExclusive
1045 || (pw && qobject_cast<QAbstractItemView *>(pw->parentWidget()))
1052 d->moveFocus(e->
key());
1068#ifndef QT_NO_SHORTCUT
1086 d->repeatTimer.stop();
1090 .value<QList<Qt::Key>>();
1104 if (e->
timerId() ==
d->repeatTimer.timerId()) {
1105 d->repeatTimer.start(
d->autoRepeatInterval,
this);
1107 QPointer<QAbstractButton> guard(
this);
1116 }
else if (e->
timerId() ==
d->animateTimer.timerId()) {
1117 d->animateTimer.stop();
1126#ifdef QT_KEYPAD_NAVIGATION
1127 if (!QApplicationPrivate::keypadNavigationEnabled())
1129 d->fixFocusPolicy();
1148 switch (e->
type()) {
1237 if (
d->iconSize.isValid())
1246 if (
d->iconSize ==
size)
1261#include "moc_qabstractbutton.cpp"
static QWidget * focusWidget()
Returns the application widget that has the keyboard input focus, or \nullptr if no widget in this ap...
Type type() const
Returns the event type.
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
The QFocusEvent class contains event parameters for widget focus events.
Qt::FocusReason reason() const
Returns the reason for this focus event.
static QPlatformTheme * platformTheme()
The QIcon class provides scalable icons in different modes and states.
The QKeyEvent class describes a key event.
bool isAutoRepeat() const
Returns true if this event comes from an auto-repeating key; returns false if it comes from an initia...
int key() const
Returns the code of the key that was pressed or released.
The QKeySequence class encapsulates a key sequence as used by shortcuts.
static QKeySequence mnemonic(const QString &text)
Returns the shortcut key sequence for the mnemonic in text, or an empty key sequence if no mnemonics ...
QList< T > findChildren(QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
Returns all children of this object with the given name that can be cast to type T,...
constexpr QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
\inmodule QtCore\reentrant
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr QRect translated(int dx, int dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr QPoint center() const noexcept
Returns the center point of the rectangle.
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
The QShortcutEvent class provides an event which is generated when the user presses a key combination...
QPointF position() const
Returns the position of the point in this event, relative to the widget or item that received the eve...
Qt::MouseButton button() const
Returns the button that caused the event.
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
\macro QT_RESTRICTED_CAST_FROM_ASCII
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
Combined button and popup list for selecting options.
@ NavigationModeKeypadDirectional
@ WA_WState_OwnSizePolicy
constexpr T qAbs(const T &t)
GLboolean GLboolean GLboolean b
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble GLdouble GLdouble GLdouble q
#define QT_CONFIG(feature)
if(qFloatDistance(a, b)<(1<< 7))
[0]