diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-06-20 12:52:15 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-06-28 00:24:28 +0200 |
commit | 168b18de2d1429dc4f8c8db538c0a2cf3141c694 (patch) | |
tree | c8682182d57880334b1d7aa7ab98daab87e68222 /src/widgets/kernel/qaction.cpp | |
parent | 6007120aa4391fa53acd774a451530c6561a1658 (diff) |
QtWidgets: Preparatory change for moving out QAction (or parts of it)
- Fix some spelling
- Use QT_CONFIG for shortcuts
- Quick C++ brush up, use member initialization
Preemptively fix sanity bot warnings about missing space after flow
control keyword, introducing range-based for on this occasion
- Remove unused member variable
Task-number: QTBUG-69478
Change-Id: I6af21886d5a0b48f4b2d11082991a877bd8d817d
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/widgets/kernel/qaction.cpp')
-rw-r--r-- | src/widgets/kernel/qaction.cpp | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp index 47e91bf8f9..19ad65692b 100644 --- a/src/widgets/kernel/qaction.cpp +++ b/src/widgets/kernel/qaction.cpp @@ -75,24 +75,18 @@ static QString qt_strippedText(QString s) } -QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0), - visible(1), forceInvisible(0), checkable(0), checked(0), separator(0), fontSet(false), - iconVisibleInMenu(-1), - shortcutVisibleInContextMenu(-1), - menuRole(QAction::TextHeuristicRole), - priority(QAction::NormalPriority) -{ -#ifndef QT_NO_SHORTCUT - shortcutId = 0; - shortcutContext = Qt::WindowShortcut; - autorepeat = true; +QActionPrivate::QActionPrivate() : +#if QT_CONFIG(shortcut) + autorepeat(1), #endif -} - -QActionPrivate::~QActionPrivate() + enabled(1), forceDisabled(0), visible(1), forceInvisible(0), checkable(0), + checked(0), separator(0), fontSet(false), + iconVisibleInMenu(-1), shortcutVisibleInContextMenu(-1) { } +QActionPrivate::~QActionPrivate() = default; + bool QActionPrivate::showStatusText(QWidget *widget, const QString &str) { #if !QT_CONFIG(statustip) @@ -127,7 +121,7 @@ void QActionPrivate::sendDataChanged() emit q->changed(); } -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) void QActionPrivate::redoGrab(QShortcutMap &map) { Q_Q(QAction); @@ -345,7 +339,7 @@ QWidget *QAction::parentWidget() const QObject *ret = parent(); while (ret && !ret->isWidgetType()) ret = ret->parent(); - return (QWidget*)ret; + return static_cast<QWidget*>(ret); } /*! @@ -374,7 +368,7 @@ QList<QGraphicsWidget *> QAction::associatedGraphicsWidgets() const } #endif -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) /*! \property QAction::shortcut \brief the action's primary shortcut key @@ -573,7 +567,7 @@ QAction::~QAction() #endif if (d->group) d->group->removeAction(this); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) if (d->shortcutId && qApp) { QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(d->shortcutId, this); for(int i = 0; i < d->alternateShortcutIds.count(); ++i) { @@ -1027,7 +1021,7 @@ void QAction::setEnabled(bool b) return; QAPP_CHECK("setEnabled"); d->enabled = b; -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) d->setShortcutEnabled(b, QGuiApplicationPrivate::instance()->shortcutMap); #endif d->sendDataChanged(); @@ -1080,7 +1074,7 @@ bool QAction::isVisible() const bool QAction::event(QEvent *e) { -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) if (e->type() == QEvent::Shortcut) { QShortcutEvent *se = static_cast<QShortcutEvent *>(e); Q_ASSERT_X(se->key() == d_func()->shortcut || d_func()->alternateShortcuts.contains(se->key()), @@ -1351,7 +1345,7 @@ Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QAction *action) d << " toolTip=" << action->toolTip(); if (action->isCheckable()) d << " checked=" << action->isChecked(); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) if (!action->shortcut().isEmpty()) d << " shortcut=" << action->shortcut(); #endif |