summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qabstractbutton.h4
-rw-r--r--src/widgets/widgets/qlineedit.cpp2
-rw-r--r--src/widgets/widgets/qmenu.cpp26
-rw-r--r--src/widgets/widgets/qmenu.h54
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp2
5 files changed, 57 insertions, 31 deletions
diff --git a/src/widgets/widgets/qabstractbutton.h b/src/widgets/widgets/qabstractbutton.h
index e8dee142f2..c6f6e4c546 100644
--- a/src/widgets/widgets/qabstractbutton.h
+++ b/src/widgets/widgets/qabstractbutton.h
@@ -42,7 +42,9 @@
#include <QtWidgets/qtwidgetsglobal.h>
#include <QtGui/qicon.h>
-#include <QtGui/qkeysequence.h>
+#if QT_CONFIG(shortcut)
+# include <QtGui/qkeysequence.h>
+#endif
#include <QtWidgets/qwidget.h>
QT_REQUIRE_CONFIG(abstractbutton);
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index fb67936768..a5499c8ce8 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -78,7 +78,7 @@
#endif
#include "private/qstylesheetstyle_p.h"
-#ifndef QT_NO_SHORTCUT
+#if QT_CONFIG(shortcut)
#include "private/qapplication_p.h"
#include "private/qshortcutmap_p.h"
#include "qkeysequence.h"
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 51b458f03a..8f03889db6 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -403,7 +403,9 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
//calculate size
QFontMetrics qfm = q->fontMetrics();
bool previousWasSeparator = true; // this is true to allow removing the leading separators
+#if QT_CONFIG(shortcut)
const bool contextMenu = isContextMenu();
+#endif
for(int i = 0; i <= lastVisibleAction; i++) {
QAction *action = actions.at(i);
const bool isSection = action->isSeparator() && (!action->text().isEmpty() || !action->icon().isNull());
@@ -434,12 +436,12 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
if (t != -1) {
tabWidth = qMax(int(tabWidth), qfm.horizontalAdvance(s.mid(t+1)));
s = s.left(t);
- #ifndef QT_NO_SHORTCUT
+#if QT_CONFIG(shortcut)
} else if (action->isShortcutVisibleInContextMenu() || !contextMenu) {
QKeySequence seq = action->shortcut();
if (!seq.isEmpty())
tabWidth = qMax(int(tabWidth), qfm.horizontalAdvance(seq.toString(QKeySequence::NativeText)));
- #endif
+#endif
}
sz.setWidth(fm.boundingRect(QRect(), Qt::TextSingleLine | Qt::TextShowMnemonic, s).width());
sz.setHeight(qMax(fm.height(), qfm.height()));
@@ -1767,12 +1769,14 @@ QAction *QMenu::addAction(const QIcon &icon, const QString &text)
\sa QWidget::addAction()
*/
-QAction *QMenu::addAction(const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut)
+QAction *QMenu::addAction(const QString &text, const QObject *receiver, const char* member
+#if QT_CONFIG(shortcut)
+ , const QKeySequence &shortcut
+#endif
+ )
{
QAction *action = new QAction(text, this);
-#ifdef QT_NO_SHORTCUT
- Q_UNUSED(shortcut);
-#else
+#if QT_CONFIG(shortcut)
action->setShortcut(shortcut);
#endif
QObject::connect(action, SIGNAL(triggered(bool)), receiver, member);
@@ -1860,12 +1864,14 @@ QAction *QMenu::addAction(const QString &text, const QObject *receiver, const ch
\sa QWidget::addAction()
*/
QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver,
- const char* member, const QKeySequence &shortcut)
+ const char* member
+#if QT_CONFIG(shortcut)
+ , const QKeySequence &shortcut
+#endif
+ )
{
QAction *action = new QAction(icon, text, this);
-#ifdef QT_NO_SHORTCUT
- Q_UNUSED(shortcut);
-#else
+#if QT_CONFIG(shortcut)
action->setShortcut(shortcut);
#endif
QObject::connect(action, SIGNAL(triggered(bool)), receiver, member);
diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h
index 84ab9e027a..35d5a865ff 100644
--- a/src/widgets/widgets/qmenu.h
+++ b/src/widgets/widgets/qmenu.h
@@ -78,8 +78,17 @@ public:
using QWidget::addAction;
QAction *addAction(const QString &text);
QAction *addAction(const QIcon &icon, const QString &text);
- QAction *addAction(const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0);
- QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0);
+
+ QAction *addAction(const QString &text, const QObject *receiver, const char* member
+#if QT_CONFIG(shortcut)
+ , const QKeySequence &shortcut = {}
+#endif
+ );
+ QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char* member
+#if QT_CONFIG(shortcut)
+ , const QKeySequence &shortcut = {}
+#endif
+ );
#ifdef Q_CLANG_QDOC
template<typename Functor>
@@ -95,12 +104,14 @@ public:
template<class Obj, typename Func1>
inline typename std::enable_if<!std::is_same<const char*, Func1>::value
&& QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type
- addAction(const QString &text, const Obj *object, Func1 slot, const QKeySequence &shortcut = 0)
+ addAction(const QString &text, const Obj *object, Func1 slot
+#if QT_CONFIG(shortcut)
+ , const QKeySequence &shortcut = {}
+#endif
+ )
{
QAction *result = addAction(text);
-#ifdef QT_NO_SHORTCUT
- Q_UNUSED(shortcut)
-#else
+#if QT_CONFIG(shortcut)
result->setShortcut(shortcut);
#endif
connect(result, &QAction::triggered, object, std::move(slot));
@@ -108,12 +119,14 @@ public:
}
// addAction(QString): Connect to a functor or function pointer (without context)
template <typename Func1>
- inline QAction *addAction(const QString &text, Func1 slot, const QKeySequence &shortcut = 0)
+ inline QAction *addAction(const QString &text, Func1 slot
+#if QT_CONFIG(shortcut)
+ , const QKeySequence &shortcut = {}
+#endif
+ )
{
QAction *result = addAction(text);
-#ifdef QT_NO_SHORTCUT
- Q_UNUSED(shortcut)
-#else
+#if QT_CONFIG(shortcut)
result->setShortcut(shortcut);
#endif
connect(result, &QAction::triggered, std::move(slot));
@@ -123,12 +136,15 @@ public:
template<class Obj, typename Func1>
inline typename std::enable_if<!std::is_same<const char*, Func1>::value
&& QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type
- addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot, const QKeySequence &shortcut = 0)
+ addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot
+#if QT_CONFIG(shortcut)
+ , const QKeySequence &shortcut = {}
+#endif
+ )
+
{
QAction *result = addAction(actionIcon, text);
-#ifdef QT_NO_SHORTCUT
- Q_UNUSED(shortcut)
-#else
+#if QT_CONFIG(shortcut)
result->setShortcut(shortcut);
#endif
connect(result, &QAction::triggered, object, std::move(slot));
@@ -136,12 +152,14 @@ public:
}
// addAction(QIcon, QString): Connect to a functor or function pointer (without context)
template <typename Func1>
- inline QAction *addAction(const QIcon &actionIcon, const QString &text, Func1 slot, const QKeySequence &shortcut = 0)
+ inline QAction *addAction(const QIcon &actionIcon, const QString &text, Func1 slot
+#if QT_CONFIG(shortcut)
+ , const QKeySequence &shortcut = {}
+#endif
+ )
{
QAction *result = addAction(actionIcon, text);
-#ifdef QT_NO_SHORTCUT
- Q_UNUSED(shortcut)
-#else
+#if QT_CONFIG(shortcut)
result->setShortcut(shortcut);
#endif
connect(result, &QAction::triggered, std::move(slot));
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index dce18f9100..be4abf1ae2 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -92,7 +92,7 @@
#include <QtGui/qaccessible.h>
#include <QtCore/qmetaobject.h>
-#ifndef QT_NO_SHORTCUT
+#if QT_CONFIG(shortcut)
#include "private/qapplication_p.h"
#include "private/qshortcutmap_p.h"
#include <qkeysequence.h>