From 8adad2fe09b173ff876895c27884f49804a20bcc Mon Sep 17 00:00:00 2001
From: Nick Shaforostoff <shaforostoff@gmail.com>
Date: Wed, 13 Apr 2016 00:47:50 +0300
Subject: [PATCH] fix build with various QT_NO_* defines

Done-with: Andriy Gerasika <andriy.gerasika@gmail.com>
Change-Id: I90883a491dbddb005c3d756c339e42285d50e437
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
---
 src/corelib/global/qfeatures.txt                   |   6 +-
 src/corelib/itemmodels/qitemselectionmodel.h       |  11 +-
 src/corelib/statemachine/qabstractstate_p.h        |   8 +-
 src/corelib/statemachine/qhistorystate_p.h         |   6 +-
 src/gui/kernel/qevent.cpp                          |   2 +
 src/gui/kernel/qplatformmenu.h                     |   2 +
 src/gui/kernel/qplatformtheme.cpp                  |   6 +
 src/gui/kernel/qplatformtheme.h                    |   2 +
 src/gui/kernel/qplatformtheme_p.h                  |   2 +
 src/gui/kernel/qwindowsysteminterface.cpp          |   2 +-
 src/platformsupport/dbusmenu/qdbusmenutypes.cpp    |   4 +
 src/platformsupport/dbusmenu/qdbusmenutypes_p.h    |   2 +
 src/platformsupport/dbusmenu/qdbusplatformmenu.cpp |   2 +
 src/platformsupport/dbusmenu/qdbusplatformmenu_p.h |   2 +
 src/platformsupport/dbustray/qdbustrayicon.cpp     |   4 +-
 src/platformsupport/dbustray/qdbustrayicon_p.h     |   4 +-
 .../dbustray/qstatusnotifieritemadaptor.cpp        |   3 +-
 .../dbustray/qstatusnotifieritemadaptor_p.h        |   2 +
 .../ibus/qibusplatforminputcontext.cpp             |   6 +
 .../ibus/qibusplatforminputcontext.h               |   2 +
 src/plugins/platforms/cocoa/qcocoaclipboard.h      |   7 +-
 src/plugins/platforms/cocoa/qcocoaclipboard.mm     |   4 +
 src/plugins/platforms/cocoa/qcocoaintegration.h    |   4 +
 src/plugins/platforms/cocoa/qcocoaintegration.mm   |   6 +
 src/plugins/platforms/cocoa/qcocoamenuitem.h       |   4 +
 src/plugins/platforms/cocoa/qcocoamenuitem.mm      |  13 ++-
 .../platforms/cocoa/qcocoasystemtrayicon.mm        |   5 +
 src/plugins/platforms/cocoa/qcocoatheme.mm         |   2 +
 src/plugins/platforms/ios/qiosclipboard.h          |   7 +-
 src/plugins/platforms/ios/qiosclipboard.mm         |   4 +
 src/plugins/platforms/ios/qiosintegration.h        |   4 +
 src/plugins/platforms/ios/qiosintegration.mm       |   8 +-
 src/plugins/platforms/ios/qiosmenu.h               |   2 +
 src/plugins/platforms/ios/qiosmenu.mm              |   4 +
 .../platforms/ios/qiosplatformaccessibility.h      |   4 +
 .../platforms/ios/qiosplatformaccessibility.mm     |   4 +
 .../platforms/ios/quiaccessibilityelement.h        |   3 +
 .../platforms/ios/quiaccessibilityelement.mm       |   4 +
 src/plugins/platforms/ios/quiview.mm               |   2 +
 .../platforms/windows/qwindowsfontdatabase_ft.cpp  |   4 +
 src/plugins/platforms/xcb/qxcbconnection.cpp       |   2 +
 src/plugins/platforms/xcb/qxcbdrag.cpp             |  32 ++++-
 src/plugins/platforms/xcb/qxcbsessionmanager.cpp   |   4 +
 src/plugins/platforms/xcb/qxcbsessionmanager.h     |   4 +
 src/plugins/platforms/xcb/qxcbwindow.cpp           |   2 +
 src/printsupport/widgets/qcupsjobwidget_p.h        |  10 +-
 src/tools/uic/cpp/cppextractimages.cpp             |   4 +
 src/tools/uic/main.cpp                             |   2 +
 src/widgets/accessible/itemviews.cpp               |  24 +++-
 src/widgets/accessible/itemviews_p.h               |   6 +
 src/widgets/accessible/qaccessiblewidget.cpp       |   2 +
 .../accessible/qaccessiblewidgetfactory.cpp        |   4 +-
 src/widgets/accessible/simplewidgets.cpp           |   6 +
 src/widgets/dialogs/qdialog.cpp                    |   2 +
 .../graphicsview/qgraphicsscenelinearindex_p.h     |   4 +-
 src/widgets/itemviews/qabstractitemdelegate.cpp    |   4 +
 src/widgets/itemviews/qabstractitemview.cpp        |   2 +
 src/widgets/kernel/qaction.cpp                     |   2 +
 src/widgets/kernel/qshortcut.cpp                   |   6 +-
 src/widgets/kernel/qwidget.cpp                     |   5 +-
 src/widgets/kernel/qwindowcontainer.cpp            |   9 +-
 src/widgets/styles/qmacstyle_mac.mm                | 130 +++++++++++++++++++--
 src/widgets/styles/qstylehelper.cpp                |   2 +
 src/widgets/widgets/qabstractbutton.cpp            |   2 +
 src/widgets/widgets/qeffects.cpp                   |   5 +-
 src/widgets/widgets/qmenu.cpp                      |  13 ++-
 src/widgets/widgets/qmenubar.cpp                   |   6 +-
 67 files changed, 411 insertions(+), 56 deletions(-)

--- a/src/corelib/global/qfeatures.txt
+++ b/src/corelib/global/qfeatures.txt
@@ -107,7 +107,7 @@ Name: QSharedMemory
 Feature: SYSTEMSEMAPHORE
 Description: Provides a general counting system semaphore.
 Section: Kernel
-Requires:
+Requires: SHAREDMEMORY
 Name: QSystemSemaphore
 
 Feature: XMLSTREAM
@@ -500,7 +500,7 @@ Name: QColorDialog
 Feature: FILEDIALOG
 Description: Supports a dialog widget for selecting files or directories.
 Section: Dialogs
-Requires: DIRMODEL TREEVIEW COMBOBOX TOOLBUTTON BUTTONGROUP TOOLTIP SPLITTER STACKEDWIDGET PROXYMODEL
+Requires: FILESYSTEMMODEL TREEVIEW COMBOBOX TOOLBUTTON BUTTONGROUP TOOLTIP SPLITTER STACKEDWIDGET PROXYMODEL
 Name: QFileDialog
 
 Feature: FONTDIALOG
@@ -512,7 +512,7 @@ Name: QFontDialog
 Feature: PRINTDIALOG
 Description: Supports a dialog widget for specifying printer configuration.
 Section: Dialogs
-Requires: PRINTER COMBOBOX BUTTONGROUP SPINBOX TREEVIEW TABWIDGET
+Requires: PRINTER COMBOBOX BUTTONGROUP SPINBOX TABWIDGET
 Name: QPrintDialog
 
 Feature: PRINTPREVIEWDIALOG
--- a/src/corelib/itemmodels/qitemselectionmodel.h
+++ b/src/corelib/itemmodels/qitemselectionmodel.h
@@ -34,6 +34,10 @@
 #ifndef QITEMSELECTIONMODEL_H
 #define QITEMSELECTIONMODEL_H
 
+#include <QtCore/qglobal.h>
+
+#ifndef QT_NO_ITEMVIEWS
+
 #include <QtCore/qset.h>
 #include <QtCore/qvector.h>
 #include <QtCore/qlist.h>
@@ -41,9 +45,6 @@
 
 QT_BEGIN_NAMESPACE
 
-
-#ifndef QT_NO_ITEMVIEWS
-
 class Q_CORE_EXPORT QItemSelectionRange
 {
 
@@ -266,11 +267,11 @@ Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(Q
 Q_CORE_EXPORT QDebug operator<<(QDebug, const QItemSelectionRange &);
 #endif
 
-#endif // QT_NO_ITEMVIEWS
-
 QT_END_NAMESPACE
 
 Q_DECLARE_METATYPE(QItemSelectionRange)
 Q_DECLARE_METATYPE(QItemSelection)
 
+#endif // QT_NO_ITEMVIEWS
+
 #endif // QITEMSELECTIONMODEL_H
--- a/src/corelib/statemachine/qabstractstate_p.h
+++ b/src/corelib/statemachine/qabstractstate_p.h
@@ -45,6 +45,10 @@
 // We mean it.
 //
 
+#include <QtCore/qglobal.h>
+
+#ifndef QT_NO_STATEMACHINE
+
 #include <private/qobject_p.h>
 #include <QtCore/qabstractstate.h>
 
@@ -88,4 +92,6 @@ public:
 
 QT_END_NAMESPACE
 
-#endif
+#endif // QT_NO_STATEMACHINE
+
+#endif // QABSTRACTSTATE_P_H
--- a/src/corelib/statemachine/qhistorystate_p.h
+++ b/src/corelib/statemachine/qhistorystate_p.h
@@ -47,6 +47,8 @@
 
 #include "private/qabstractstate_p.h"
 
+#ifndef QT_NO_STATEMACHINE
+
 #include <QtCore/qabstracttransition.h>
 #include <QtCore/qhistorystate.h>
 #include <QtCore/qlist.h>
@@ -87,4 +89,6 @@ protected:
 
 QT_END_NAMESPACE
 
-#endif
+#endif // QT_NO_STATEMACHINE
+
+#endif // QHISTORYSTATE_P_H
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -3901,6 +3901,7 @@ QDebug operator<<(QDebug dbg, const QEve
         dbg << ')';
     }
         break;
+#ifndef QT_NO_SHORTCUT
     case QEvent::Shortcut: {
         const QShortcutEvent *se = static_cast<const QShortcutEvent *>(e);
         dbg << "QShortcutEvent(" << se->key().toString() << ", id=" << se->shortcutId();
@@ -3909,6 +3910,7 @@ QDebug operator<<(QDebug dbg, const QEve
         dbg << ')';
     }
         break;
+#endif
     case QEvent::FocusAboutToChange:
     case QEvent::FocusIn:
     case QEvent::FocusOut:
--- a/src/gui/kernel/qplatformmenu.h
+++ b/src/gui/kernel/qplatformmenu.h
@@ -77,7 +77,9 @@ public:
     virtual void setRole(MenuRole role) = 0;
     virtual void setCheckable(bool checkable) = 0;
     virtual void setChecked(bool isChecked) = 0;
+#ifndef QT_NO_SHORTCUT
     virtual void setShortcut(const QKeySequence& shortcut) = 0;
+#endif
     virtual void setEnabled(bool enabled) = 0;
     virtual void setIconSize(int size) = 0;
     virtual void setNativeContents(WId item) { Q_UNUSED(item); }
--- a/src/gui/kernel/qplatformtheme.cpp
+++ b/src/gui/kernel/qplatformtheme.cpp
@@ -146,6 +146,7 @@ QT_BEGIN_NAMESPACE
 */
 
 
+#ifndef QT_NO_SHORTCUT
 // Table of key bindings. It must be sorted on key sequence:
 // The integer value of VK_KEY | Modifier Keys (e.g., VK_META, and etc.)
 // A priority of 1 indicates that this is the primary key binding when multiple are defined.
@@ -329,6 +330,7 @@ const QKeyBinding QPlatformThemePrivate:
 };
 
 const uint QPlatformThemePrivate::numberOfKeyBindings = sizeof(QPlatformThemePrivate::keyBindings)/(sizeof(QKeyBinding));
+#endif
 
 QPlatformThemePrivate::QPlatformThemePrivate()
         : systemPalette(0)
@@ -574,6 +576,7 @@ static inline int maybeSwapShortcut(int
 }
 #endif
 
+#ifndef QT_NO_SHORTCUT
 // mixed-mode predicate: all of these overloads are actually needed (but not all for every compiler)
 struct ByStandardKey {
     typedef bool result_type;
@@ -624,6 +627,7 @@ QList<QKeySequence> QPlatformTheme::keyB
 
     return list;
 }
+#endif
 
 /*!
    Returns the text of a standard \a button.
@@ -686,10 +690,12 @@ unsigned QPlatformThemePrivate::currentK
 {
     const uint keyboardScheme = QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::KeyboardScheme).toInt();
     unsigned result = 1u << keyboardScheme;
+#ifndef QT_NO_SHORTCUT
     if (keyboardScheme == QPlatformTheme::KdeKeyboardScheme
         || keyboardScheme == QPlatformTheme::GnomeKeyboardScheme
         || keyboardScheme == QPlatformTheme::CdeKeyboardScheme)
         result |= KB_X11;
+#endif
     return result;
 }
 
--- a/src/gui/kernel/qplatformtheme.h
+++ b/src/gui/kernel/qplatformtheme.h
@@ -297,7 +297,9 @@ public:
 
     virtual QIconEngine *createIconEngine(const QString &iconName) const;
 
+#ifndef QT_NO_SHORTCUT
     virtual QList<QKeySequence> keyBindings(QKeySequence::StandardKey key) const;
+#endif
 
     virtual QString standardButtonText(int button) const;
 
--- a/src/gui/kernel/qplatformtheme_p.h
+++ b/src/gui/kernel/qplatformtheme_p.h
@@ -61,8 +61,10 @@ public:
 
     void initializeSystemPalette();
 
+#ifndef QT_NO_SHORTCUT
     static const QKeyBinding keyBindings[];
     static const uint numberOfKeyBindings;
+#endif
 
     static unsigned currentKeyPlatforms();
 
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -229,7 +229,7 @@ bool QWindowSystemInterface::handleShort
 #else
     Q_UNUSED(window)
     Q_UNUSED(timestamp)
-    Q_UNUSED(key)
+    Q_UNUSED(keyCode)
     Q_UNUSED(modifiers)
     Q_UNUSED(nativeScanCode)
     Q_UNUSED(nativeVirtualKey)
--- a/src/platformsupport/dbusmenu/qdbusmenutypes.cpp
+++ b/src/platformsupport/dbusmenu/qdbusmenutypes.cpp
@@ -185,11 +185,13 @@ QDBusMenuItem::QDBusMenuItem(const QDBus
             m_properties.insert(QLatin1String("toggle-type"), QLatin1String("checkmark"));
             m_properties.insert(QLatin1String("toggle-state"), item->isChecked() ? 1 : 0);
         }
+#ifndef QT_NO_SHORTCUT
         const QKeySequence &scut = item->shortcut();
         if (!scut.isEmpty()) {
             QDBusMenuShortcut shortcut = convertKeySequence(scut);
             m_properties.insert(QLatin1String("shortcut"), QVariant::fromValue(shortcut));
         }
+#endif
         const QIcon &icon = item->icon();
         if (!icon.name().isEmpty()) {
             m_properties.insert(QLatin1String("icon-name"), icon.name());
@@ -225,6 +227,7 @@ QString QDBusMenuItem::convertMnemonic(c
     return ret;
 }
 
+#ifndef QT_NO_SHORTCUT
 QDBusMenuShortcut QDBusMenuItem::convertKeySequence(const QKeySequence &sequence)
 {
     QDBusMenuShortcut shortcut;
@@ -253,6 +256,7 @@ QDBusMenuShortcut QDBusMenuItem::convert
     }
     return shortcut;
 }
+#endif
 
 const QDBusArgument &operator<<(QDBusArgument &arg, const QDBusMenuEvent &ev)
 {
--- a/src/platformsupport/dbusmenu/qdbusmenutypes_p.h
+++ b/src/platformsupport/dbusmenu/qdbusmenutypes_p.h
@@ -68,7 +68,9 @@ public:
 
     static QDBusMenuItemList items(const QList<int> &ids, const QStringList &propertyNames);
     static QString convertMnemonic(const QString &label);
+#ifndef QT_NO_SHORTCUT
     static QDBusMenuShortcut convertKeySequence(const QKeySequence &sequence);
+#endif
     static void registerDBusTypes();
 
     int m_id;
--- a/src/platformsupport/dbusmenu/qdbusplatformmenu.cpp
+++ b/src/platformsupport/dbusmenu/qdbusplatformmenu.cpp
@@ -120,10 +120,12 @@ void QDBusPlatformMenuItem::setChecked(b
     m_isChecked = isChecked;
 }
 
+#ifndef QT_NO_SHORTCUT
 void QDBusPlatformMenuItem::setShortcut(const QKeySequence &shortcut)
 {
     m_shortcut = shortcut;
 }
+#endif
 
 void QDBusPlatformMenuItem::trigger()
 {
--- a/src/platformsupport/dbustray/qdbustrayicon.cpp
+++ b/src/platformsupport/dbustray/qdbustrayicon.cpp
@@ -31,9 +31,10 @@
 **
 ****************************************************************************/
 
+#include "qdbustrayicon_p.h"
+
 #ifndef QT_NO_SYSTEMTRAYICON
 
-#include "qdbustrayicon_p.h"
 #include "qdbusmenuconnection_p.h"
 #include "qstatusnotifieritemadaptor_p.h"
 #include "qdbusmenuadaptor_p.h"
@@ -293,4 +294,3 @@ bool QDBusTrayIcon::isSystemTrayAvailabl
 
 QT_END_NAMESPACE
 #endif //QT_NO_SYSTEMTRAYICON
-
--- a/src/platformsupport/dbustray/qdbustrayicon_p.h
+++ b/src/platformsupport/dbustray/qdbustrayicon_p.h
@@ -46,6 +46,8 @@
 // We mean it.
 //
 
+#include <QtCore/qglobal.h>
+
 #ifndef QT_NO_SYSTEMTRAYICON
 
 #include <QIcon>
@@ -156,6 +158,6 @@ private:
 };
 
 QT_END_NAMESPACE
-#endif // QT_NO_SYSTEMTRAYICON
 
+#endif // QT_NO_SYSTEMTRAYICON
 #endif // QDBUSTRAYICON_H
--- a/src/platformsupport/dbustray/qstatusnotifieritemadaptor.cpp
+++ b/src/platformsupport/dbustray/qstatusnotifieritemadaptor.cpp
@@ -42,9 +42,10 @@
     QMetaObject::invokeMethod().
 */
 
+#include "qstatusnotifieritemadaptor_p.h"
+
 #ifndef QT_NO_SYSTEMTRAYICON
 
-#include "qstatusnotifieritemadaptor_p.h"
 #include "qdbustrayicon_p.h"
 
 QT_BEGIN_NAMESPACE
--- a/src/platformsupport/dbustray/qstatusnotifieritemadaptor_p.h
+++ b/src/platformsupport/dbustray/qstatusnotifieritemadaptor_p.h
@@ -56,6 +56,8 @@
 // We mean it.
 //
 
+#include <QtCore/qglobal.h>
+
 #ifndef QT_NO_SYSTEMTRAYICON
 
 #include <QtCore/QObject>
--- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
+++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
@@ -95,11 +95,13 @@ QIBusPlatformInputContext::QIBusPlatform
     QString socketPath = QIBusPlatformInputContextPrivate::getSocketPath();
     QFile file(socketPath);
     if (file.open(QFile::ReadOnly)) {
+#ifndef QT_NO_FILESYSTEMWATCHER
         // If KDE session save is used or restart ibus-daemon,
         // the applications could run before ibus-daemon runs.
         // We watch the getSocketPath() to get the launching ibus-daemon.
         m_socketWatcher.addPath(socketPath);
         connect(&m_socketWatcher, SIGNAL(fileChanged(QString)), this, SLOT(socketChanged(QString)));
+#endif
     }
 
     m_timer.setSingleShot(true);
@@ -401,8 +403,10 @@ void QIBusPlatformInputContext::filterEv
             && window != NULL) {
             const QPoint globalPos = window->screen()->handle()->cursor()->pos();
             const QPoint pos = window->mapFromGlobal(globalPos);
+#ifndef QT_NO_CONTEXTMENU
             QWindowSystemInterface::handleContextMenuEvent(window, false, pos,
                                                            globalPos, modifiers);
+#endif
         }
         QWindowSystemInterface::handleExtendedKeyEvent(window, time, type, qtcode, modifiers,
                                                        code, sym, state, string, isAutoRepeat);
@@ -441,8 +445,10 @@ void QIBusPlatformInputContext::connectT
     d->initBus();
     connectToContextSignals();
 
+#ifndef QT_NO_FILESYSTEMWATCHER
     if (m_socketWatcher.files().size() == 0)
         m_socketWatcher.addPath(QIBusPlatformInputContextPrivate::getSocketPath());
+#endif
 }
 
 void QIBusPlatformInputContext::globalEngineChanged(const QString &engine_name)
--- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h
+++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h
@@ -104,7 +104,9 @@ public Q_SLOTS:
 private:
     QIBusPlatformInputContextPrivate *d;
     bool m_eventFilterUseSynchronousMode;
+#ifndef QT_NO_FILESYSTEMWATCHER
     QFileSystemWatcher m_socketWatcher;
+#endif
     QTimer m_timer;
 
     void connectToContextSignals();
--- a/src/plugins/platforms/cocoa/qcocoaclipboard.h
+++ b/src/plugins/platforms/cocoa/qcocoaclipboard.h
@@ -35,6 +35,9 @@
 #define QCOCOACLIPBOARD_H
 
 #include <qpa/qplatformclipboard.h>
+
+#ifndef QT_NO_CLIPBOARD
+
 #include "qmacclipboard.h"
 #include <QtCore/QScopedPointer>
 
@@ -65,4 +68,6 @@ private:
 
 QT_END_NAMESPACE
 
-#endif
+#endif // QT_NO_CLIPBOARD
+
+#endif // QCOCOACLIPBOARD_H
--- a/src/plugins/platforms/cocoa/qcocoaclipboard.mm
+++ b/src/plugins/platforms/cocoa/qcocoaclipboard.mm
@@ -33,6 +33,8 @@
 
 #include "qcocoaclipboard.h"
 
+#ifndef QT_NO_CLIPBOARD
+
 QT_BEGIN_NAMESPACE
 
 QCocoaClipboard::QCocoaClipboard()
@@ -99,3 +101,5 @@ void QCocoaClipboard::handleApplicationS
 #include "moc_qcocoaclipboard.cpp"
 
 QT_END_NAMESPACE
+
+#endif // QT_NO_CLIPBOARD
--- a/src/plugins/platforms/cocoa/qcocoaintegration.h
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.h
@@ -124,7 +124,9 @@ public:
 #ifndef QT_NO_ACCESSIBILITY
     QCocoaAccessibility *accessibility() const Q_DECL_OVERRIDE;
 #endif
+#ifndef QT_NO_CLIPBOARD
     QCocoaClipboard *clipboard() const Q_DECL_OVERRIDE;
+#endif
     QCocoaDrag *drag() const Q_DECL_OVERRIDE;
 
     QStringList themeNames() const Q_DECL_OVERRIDE;
@@ -160,7 +162,9 @@ private:
 #endif
     QScopedPointer<QPlatformTheme> mPlatformTheme;
     QList<QCocoaScreen *> mScreens;
+#ifndef QT_NO_CLIPBOARD
     QCocoaClipboard  *mCocoaClipboard;
+#endif
     QScopedPointer<QCocoaDrag> mCocoaDrag;
     QScopedPointer<QCocoaNativeInterface> mNativeInterface;
     QScopedPointer<QCocoaServices> mServices;
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -277,7 +277,9 @@ QCocoaIntegration::QCocoaIntegration(con
 #ifndef QT_NO_ACCESSIBILITY
     , mAccessibility(new QCocoaAccessibility)
 #endif
+#ifndef QT_NO_CLIPBOARD
     , mCocoaClipboard(new QCocoaClipboard)
+#endif
     , mCocoaDrag(new QCocoaDrag)
     , mNativeInterface(new QCocoaNativeInterface)
     , mServices(new QCocoaServices)
@@ -361,11 +363,13 @@ QCocoaIntegration::~QCocoaIntegration()
         [[NSApplication sharedApplication] setDelegate: 0];
     }
 
+#ifndef QT_NO_CLIPBOARD
     // Delete the clipboard integration and destroy mime type converters.
     // Deleting the clipboard integration flushes promised pastes using
     // the mime converters - the ordering here is important.
     delete mCocoaClipboard;
     QMacInternalPasteboardMime::destroyMimeTypes();
+#endif
 
     // Delete screens in reverse order to avoid crash in case of multiple screens
     while (!mScreens.isEmpty()) {
@@ -526,10 +530,12 @@ QCocoaAccessibility *QCocoaIntegration::
 }
 #endif
 
+#ifndef QT_NO_CLIPBOARD
 QCocoaClipboard *QCocoaIntegration::clipboard() const
 {
     return mCocoaClipboard;
 }
+#endif
 
 QCocoaDrag *QCocoaIntegration::drag() const
 {
--- a/src/plugins/platforms/cocoa/qcocoamenuitem.h
+++ b/src/plugins/platforms/cocoa/qcocoamenuitem.h
@@ -84,7 +84,9 @@ public:
     void setIsSeparator(bool isSeparator) Q_DECL_OVERRIDE;
     void setFont(const QFont &font) Q_DECL_OVERRIDE;
     void setRole(MenuRole role) Q_DECL_OVERRIDE;
+#ifndef QT_NO_SHORTCUT
     void setShortcut(const QKeySequence& shortcut) Q_DECL_OVERRIDE;
+#endif
     void setCheckable(bool checkable) Q_DECL_OVERRIDE { Q_UNUSED(checkable) }
     void setChecked(bool isChecked) Q_DECL_OVERRIDE;
     void setEnabled(bool isEnabled) Q_DECL_OVERRIDE;
@@ -118,7 +120,9 @@ private:
     QFont m_font;
     MenuRole m_role;
     MenuRole m_detectedRole;
+#ifndef QT_NO_SHORTCUT
     QKeySequence m_shortcut;
+#endif
     quintptr m_tag;
     int m_iconSize;
     bool m_textSynced:1;
--- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
@@ -66,6 +66,7 @@ static quint32 constructModifierMask(qui
     return ret;
 }
 
+#ifndef QT_NO_SHORTCUT
 // return an autoreleased string given a QKeySequence (currently only looks at the first one).
 NSString *keySequenceToKeyEqivalent(const QKeySequence &accel)
 {
@@ -84,6 +85,7 @@ NSUInteger keySequenceModifierMask(const
 {
     return constructModifierMask(accel[0]);
 }
+#endif
 
 QCocoaMenuItem::QCocoaMenuItem() :
     m_native(NULL),
@@ -181,10 +183,12 @@ void QCocoaMenuItem::setRole(MenuRole ro
     m_role = role;
 }
 
+#ifndef QT_NO_SHORTCUT
 void QCocoaMenuItem::setShortcut(const QKeySequence& shortcut)
 {
     m_shortcut = shortcut;
 }
+#endif
 
 void QCocoaMenuItem::setChecked(bool isChecked)
 {
@@ -312,11 +316,13 @@ NSMenuItem *QCocoaMenuItem::sync()
     [m_native setView:m_itemView];
 
     QString text = mergeText();
+#ifndef QT_NO_SHORTCUT
     QKeySequence accel = mergeAccel();
 
     // Show multiple key sequences as part of the menu text.
     if (accel.count() > 1)
         text += QLatin1String(" (") + accel.toString(QKeySequence::NativeText) + QLatin1String(")");
+#endif
 
     QString finalString = qt_mac_removeMnemonics(text);
     bool useAttributedTitle = false;
@@ -338,10 +344,13 @@ NSMenuItem *QCocoaMenuItem::sync()
        [m_native setTitle: QCFString::toNSString(finalString)];
     }
 
+#ifndef QT_NO_SHORTCUT
     if (accel.count() == 1) {
         [m_native setKeyEquivalent:keySequenceToKeyEqivalent(accel)];
         [m_native setKeyEquivalentModifierMask:keySequenceModifierMask(accel)];
-    } else {
+    } else
+#endif
+    {
         [m_native setKeyEquivalent:@""];
         [m_native setKeyEquivalentModifierMask:NSCommandKeyMask];
     }
@@ -382,6 +391,7 @@ QString QCocoaMenuItem::mergeText()
     return m_text;
 }
 
+#ifndef QT_NO_SHORTCUT
 QKeySequence QCocoaMenuItem::mergeAccel()
 {
     QCocoaMenuLoader *loader = getMenuLoader();
@@ -394,6 +404,7 @@ QKeySequence QCocoaMenuItem::mergeAccel(
 
     return m_shortcut;
 }
+#endif
 
 void QCocoaMenuItem::syncMerged()
 {
--- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
+++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
@@ -69,6 +69,9 @@
 #define QT_MAC_SYSTEMTRAY_USE_GROWL
 
 #include "qcocoasystemtrayicon.h"
+
+#ifndef QT_NO_SYSTEMTRAYICON
+
 #include <qtemporaryfile.h>
 #include <qimagewriter.h>
 #include <qdebug.h>
@@ -530,3 +533,5 @@ private:
     return qmenu;
 }
 @end
+
+#endif // QT_NO_SYSTEMTRAYICON
--- a/src/plugins/platforms/cocoa/qcocoatheme.mm
+++ b/src/plugins/platforms/cocoa/qcocoatheme.mm
@@ -90,8 +90,10 @@ bool QCocoaTheme::usePlatformNativeDialo
 QPlatformDialogHelper * QCocoaTheme::createPlatformDialogHelper(DialogType dialogType) const
 {
     switch (dialogType) {
+#ifndef QT_NO_FILEDIALOG
     case QPlatformTheme::FileDialog:
         return new QCocoaFileDialogHelper();
+#endif
 #ifndef QT_NO_COLORDIALOG
     case QPlatformTheme::ColorDialog:
         return new QCocoaColorDialogHelper();
--- a/src/plugins/platforms/ios/qiosclipboard.h
+++ b/src/plugins/platforms/ios/qiosclipboard.h
@@ -34,10 +34,13 @@
 #ifndef QIOSCLIPBOARD_H
 #define QIOSCLIPBOARD_H
 
+#include <qpa/qplatformclipboard.h>
+
+#ifndef QT_NO_CLIPBOARD
+
 #import <UIKit/UIKit.h>
 
 #include <QMimeData>
-#include <qpa/qplatformclipboard.h>
 
 @class QUIClipboard;
 
@@ -61,4 +64,6 @@ private:
 
 QT_END_NAMESPACE
 
+#endif // QT_NO_CLIPBOARD
+
 #endif // QIOSCLIPBOARD_H
--- a/src/plugins/platforms/ios/qiosclipboard.mm
+++ b/src/plugins/platforms/ios/qiosclipboard.mm
@@ -33,6 +33,8 @@
 
 #include "qiosclipboard.h"
 
+#ifndef QT_NO_CLIPBOARD
+
 #include <QtPlatformSupport/private/qmacmime_p.h>
 #include <QtCore/QMimeData>
 #include <QtGui/QGuiApplication>
@@ -241,3 +243,5 @@ bool QIOSClipboard::ownsMode(QClipboard:
 }
 
 QT_END_NAMESPACE
+
+#endif // QT_NO_CLIPBOARD
--- a/src/plugins/platforms/ios/qiosintegration.h
+++ b/src/plugins/platforms/ios/qiosintegration.h
@@ -63,7 +63,9 @@ public:
     QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const Q_DECL_OVERRIDE;
 
     QPlatformFontDatabase *fontDatabase() const Q_DECL_OVERRIDE;
+#ifndef QT_NO_CLIPBOARD
     QPlatformClipboard *clipboard() const Q_DECL_OVERRIDE;
+#endif
     QPlatformInputContext *inputContext() const Q_DECL_OVERRIDE;
     QPlatformServices *services() const Q_DECL_OVERRIDE;
 
@@ -76,7 +78,9 @@ public:
     QPlatformNativeInterface *nativeInterface() const Q_DECL_OVERRIDE;
 
     QTouchDevice *touchDevice();
+#ifndef QT_NO_ACCESSIBILITY
     QPlatformAccessibility *accessibility() const Q_DECL_OVERRIDE;
+#endif
 
     // Called from Objective-C class QIOSScreenTracker, which can't be friended
     void addScreen(QPlatformScreen *screen) { screenAdded(screen); }
--- a/src/plugins/platforms/ios/qiosintegration.mm
+++ b/src/plugins/platforms/ios/qiosintegration.mm
@@ -64,7 +64,9 @@ QIOSIntegration *QIOSIntegration::instan
 
 QIOSIntegration::QIOSIntegration()
     : m_fontDatabase(new QCoreTextFontDatabase)
+#if !defined(Q_OS_TVOS) && !defined(QT_NO_CLIPBOARD)
     , m_clipboard(new QIOSClipboard)
+#endif
     , m_inputContext(0)
     , m_platformServices(new QIOSServices)
     , m_accessibility(0)
@@ -119,8 +121,10 @@ QIOSIntegration::~QIOSIntegration()
     delete m_fontDatabase;
     m_fontDatabase = 0;
 
+#if !defined(Q_OS_TVOS) && !defined(QT_NO_CLIPBOARD)
     delete m_clipboard;
     m_clipboard = 0;
+#endif
     QMacInternalPasteboardMime::destroyMimeTypes();
 
     delete m_inputContext;
@@ -207,6 +211,7 @@ QPlatformFontDatabase * QIOSIntegration:
     return m_fontDatabase;
 }
 
+#ifndef QT_NO_CLIPBOARD
 QPlatformClipboard *QIOSIntegration::clipboard() const
 {
     return m_clipboard;
@@ -216,6 +221,7 @@ QPlatformInputContext *QIOSIntegration::
 {
     return m_inputContext;
 }
+#endif
 
 QPlatformServices *QIOSIntegration::services() const
 {
@@ -256,12 +262,14 @@ QTouchDevice *QIOSIntegration::touchDevi
     return m_touchDevice;
 }
 
+#ifndef QT_NO_ACCESSIBILITY
 QPlatformAccessibility *QIOSIntegration::accessibility() const
 {
     if (!m_accessibility)
         m_accessibility = new QIOSPlatformAccessibility;
     return m_accessibility;
 }
+#endif
 
 QPlatformNativeInterface *QIOSIntegration::nativeInterface() const
 {
--- a/src/plugins/platforms/ios/qiosmenu.h
+++ b/src/plugins/platforms/ios/qiosmenu.h
@@ -62,7 +62,9 @@ public:
     void setRole(MenuRole role) Q_DECL_OVERRIDE;
     void setCheckable(bool) Q_DECL_OVERRIDE {}
     void setChecked(bool) Q_DECL_OVERRIDE {}
+#ifndef QT_NO_SHORTCUT
     void setShortcut(const QKeySequence&) Q_DECL_OVERRIDE;
+#endif
     void setEnabled(bool enabled) Q_DECL_OVERRIDE;
     void setIconSize(int) Q_DECL_OVERRIDE {}
 
--- a/src/plugins/platforms/ios/qiosmenu.mm
+++ b/src/plugins/platforms/ios/qiosmenu.mm
@@ -294,10 +294,12 @@ void QIOSMenuItem::setRole(QPlatformMenu
     m_role = role;
 }
 
+#ifndef QT_NO_SHORTCUT
 void QIOSMenuItem::setShortcut(const QKeySequence &sequence)
 {
     m_shortcut = sequence;
 }
+#endif
 
 void QIOSMenuItem::setEnabled(bool enabled)
 {
@@ -576,6 +578,7 @@ QIOSMenuItemList QIOSMenu::filterFirstRe
 
     for (int i = 0; i < menuItems.count(); ++i) {
         QIOSMenuItem *menuItem = menuItems.at(i);
+#ifndef QT_NO_SHORTCUT
         QKeySequence shortcut = menuItem->m_shortcut;
         if ((shortcut == QKeySequence::Cut && [responder canPerformAction:@selector(cut:) withSender:nil])
                 || (shortcut == QKeySequence::Copy && [responder canPerformAction:@selector(copy:) withSender:nil])
@@ -589,6 +592,7 @@ QIOSMenuItemList QIOSMenu::filterFirstRe
                 || (shortcut == QKeySequence::Underline && [responder canPerformAction:@selector(toggleUnderline:) withSender:nil])) {
             continue;
         }
+#endif
         filteredMenuItems.append(menuItem);
     }
     return filteredMenuItems;
--- a/src/plugins/platforms/ios/qiosplatformaccessibility.h
+++ b/src/plugins/platforms/ios/qiosplatformaccessibility.h
@@ -36,6 +36,8 @@
 
 #include <qpa/qplatformaccessibility.h>
 
+#ifndef QT_NO_ACCESSIBILITY
+
 QT_BEGIN_NAMESPACE
 
 class QIOSPlatformAccessibility: public QPlatformAccessibility
@@ -50,3 +52,5 @@ public:
 QT_END_NAMESPACE
 
 #endif
+
+#endif
--- a/src/plugins/platforms/ios/qiosplatformaccessibility.mm
+++ b/src/plugins/platforms/ios/qiosplatformaccessibility.mm
@@ -33,6 +33,8 @@
 
 #include "qiosplatformaccessibility.h"
 
+#ifndef QT_NO_ACCESSIBILITY
+
 #include <QtGui/QtGui>
 #include "qioswindow.h"
 
@@ -79,3 +81,5 @@ void QIOSPlatformAccessibility::notifyAc
         break;
     }
 }
+
+#endif
--- a/src/plugins/platforms/ios/quiaccessibilityelement.h
+++ b/src/plugins/platforms/ios/quiaccessibilityelement.h
@@ -37,6 +37,8 @@
 #import <UIKit/UIKit.h>
 #import <QtGui/QtGui>
 
+#ifndef QT_NO_ACCESSIBILITY
+
 @interface QMacAccessibilityElement : UIAccessibilityElement
 {}
 
@@ -48,3 +50,4 @@
 @end
 
 #endif
+#endif
--- a/src/plugins/platforms/ios/quiaccessibilityelement.mm
+++ b/src/plugins/platforms/ios/quiaccessibilityelement.mm
@@ -33,6 +33,8 @@
 
 #include "quiaccessibilityelement.h"
 
+#ifndef QT_NO_ACCESSIBILITY
+
 #include "private/qaccessiblecache_p.h"
 
 @implementation QMacAccessibilityElement
@@ -215,3 +217,5 @@
 }
 
 @end
+
+#endif
--- a/src/plugins/platforms/ios/quiview.mm
+++ b/src/plugins/platforms/ios/quiview.mm
@@ -477,5 +477,7 @@
 
 @end
 
+#ifndef QT_NO_ACCESSIBILITY
 // Include category as an alternative to using -ObjC (Apple QA1490)
 #include "quiview_accessibility.mm"
+#endif
--- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp
@@ -122,7 +122,11 @@ static FontKeys &fontKeys()
                                      QSettings::NativeFormat);
         const QStringList allKeys = fontRegistry.allKeys();
         const QString trueType = QStringLiteral("(TrueType)");
+#ifndef QT_NO_REGULAREXPRESSION
         const QRegularExpression sizeListMatch(QStringLiteral("\\s(\\d+,)+\\d+"));
+#else
+        const QRegExp sizeListMatch(QLatin1String("\\s(\\d+,)+\\d+"));
+#endif
         Q_ASSERT(sizeListMatch.isValid());
         const int size = allKeys.size();
         result.reserve(size);
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -1710,11 +1710,13 @@ void QXcbConnection::processXcbEvents()
         if (compressEvent(event, i, eventqueue))
             continue;
 
+#ifndef QT_NO_CLIPBOARD
         bool accepted = false;
         if (clipboard()->processIncr())
             clipboard()->incrTransactionPeeker(event, accepted);
         if (accepted)
             continue;
+#endif
 
         QVector<PeekFunc>::iterator it = m_peekFuncs.begin();
         while (it != m_peekFuncs.end()) {
--- a/src/plugins/platforms/xcb/qxcbdrag.cpp
+++ b/src/plugins/platforms/xcb/qxcbdrag.cpp
@@ -188,8 +188,10 @@ void QXcbDrag::startDrag()
 
     init();
 
+#ifndef QT_NO_CLIPBOARD
     xcb_set_selection_owner(xcb_connection(), connection()->clipboard()->owner(),
                             atom(QXcbAtom::XdndSelection), connection()->time());
+#endif
 
     QStringList fmts = QXcbMime::formatsHelper(drag()->mimeData());
     for (int i = 0; i < fmts.size(); ++i) {
@@ -199,10 +201,12 @@ void QXcbDrag::startDrag()
                 drag_types.append(atoms.at(j));
         }
     }
+#ifndef QT_NO_CLIPBOARD
     if (drag_types.size() > 3)
         xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, connection()->clipboard()->owner(),
                             atom(QXcbAtom::XdndTypelist),
                             XCB_ATOM_ATOM, 32, drag_types.size(), (const void *)drag_types.constData());
+#endif
 
     setUseCompositing(current_virtual_desktop->compositingActive());
     setScreen(current_virtual_desktop->screens().constFirst()->screen());
@@ -441,7 +445,11 @@ void QXcbDrag::move(const QPoint &global
             enter.window = target;
             enter.format = 32;
             enter.type = atom(QXcbAtom::XdndEnter);
+#ifndef QT_NO_CLIPBOARD
             enter.data.data32[0] = connection()->clipboard()->owner();
+#else
+            enter.data.data32[0] = 0;
+#endif
             enter.data.data32[1] = flags;
             enter.data.data32[2] = drag_types.size()>0 ? drag_types.at(0) : 0;
             enter.data.data32[3] = drag_types.size()>1 ? drag_types.at(1) : 0;
@@ -470,7 +478,11 @@ void QXcbDrag::move(const QPoint &global
         move.window = target;
         move.format = 32;
         move.type = atom(QXcbAtom::XdndPosition);
+#ifndef QT_NO_CLIPBOARD
         move.data.data32[0] = connection()->clipboard()->owner();
+#else
+        move.data.data32[0] = 0;
+#endif
         move.data.data32[1] = 0; // flags
         move.data.data32[2] = (globalPos.x() << 16) + globalPos.y();
         move.data.data32[3] = connection()->time();
@@ -499,7 +511,11 @@ void QXcbDrag::drop(const QPoint &global
     drop.window = current_target;
     drop.format = 32;
     drop.type = atom(QXcbAtom::XdndDrop);
+#ifndef QT_NO_CLIPBOARD
     drop.data.data32[0] = connection()->clipboard()->owner();
+#else
+    drop.data.data32[0] = 0;
+#endif
     drop.data.data32[1] = 0; // flags
     drop.data.data32[2] = connection()->time();
 
@@ -785,9 +801,11 @@ void QXcbDrag::handle_xdnd_position(QPla
     // reset
     target_time = XCB_CURRENT_TIME;
 
+#ifndef QT_NO_CLIPBOARD
     if (xdnd_dragsource == connection()->clipboard()->owner())
         handle_xdnd_status(&response);
     else
+#endif
         Q_XCB_CALL(xcb_send_event(xcb_connection(), false, current_proxy_target,
                                   XCB_EVENT_MASK_NO_EVENT, (const char *)&response));
 }
@@ -853,7 +871,11 @@ void QXcbDrag::handle_xdnd_status(const
 
 void QXcbDrag::handleStatus(const xcb_client_message_event_t *event)
 {
-    if (event->window != connection()->clipboard()->owner() || !drag())
+    if (
+#ifndef QT_NO_CLIPBOARD
+            event->window != connection()->clipboard()->owner() ||
+#endif
+            !drag())
         return;
 
     xcb_client_message_event_t *lastEvent = const_cast<xcb_client_message_event_t *>(event);
@@ -908,7 +930,11 @@ void QXcbDrag::send_leave()
     leave.window = current_target;
     leave.format = 32;
     leave.type = atom(QXcbAtom::XdndLeave);
+#ifndef QT_NO_CLIPBOARD
     leave.data.data32[0] = connection()->clipboard()->owner();
+#else
+    leave.data.data32[0] = 0;
+#endif
     leave.data.data32[1] = 0; // flags
     leave.data.data32[2] = 0; // x, y
     leave.data.data32[3] = 0; // w, h
@@ -1000,8 +1026,10 @@ void QXcbDrag::handleDrop(QPlatformWindo
 void QXcbDrag::handleFinished(const xcb_client_message_event_t *event)
 {
     DEBUG("xdndHandleFinished");
+#ifndef QT_NO_CLIPBOARD
     if (event->window != connection()->clipboard()->owner())
         return;
+#endif
 
     const unsigned long *l = (const unsigned long *)event->data.data32;
 
@@ -1281,11 +1309,13 @@ QVariant QXcbDropData::xdndObtainData(co
     if (a == XCB_NONE)
         return result;
 
+#ifndef QT_NO_CLIPBOARD
     if (c->clipboard()->getSelectionOwner(drag->atom(QXcbAtom::XdndSelection)) == XCB_NONE)
         return result; // should never happen?
 
     xcb_atom_t xdnd_selection = c->atom(QXcbAtom::XdndSelection);
     result = c->clipboard()->getSelection(xdnd_selection, a, xdnd_selection, drag->targetTime());
+#endif
 
     return mimeConvertToFormat(c, a, result, QLatin1String(format), requestedType, encoding);
 }
--- a/src/plugins/platforms/xcb/qxcbsessionmanager.cpp
+++ b/src/plugins/platforms/xcb/qxcbsessionmanager.cpp
@@ -34,6 +34,8 @@
 
 #include "qxcbsessionmanager.h"
 
+#ifndef QT_NO_SESSIONMANAGER
+
 #include <qguiapplication.h>
 #include <qdatetime.h>
 #include <qfileinfo.h>
@@ -485,3 +487,5 @@ void QXcbSessionManager::exitEventLoop()
 }
 
 #include "qxcbsessionmanager.moc"
+
+#endif
--- a/src/plugins/platforms/xcb/qxcbsessionmanager.h
+++ b/src/plugins/platforms/xcb/qxcbsessionmanager.h
@@ -46,6 +46,8 @@
 
 #include <qpa/qplatformsessionmanager.h>
 
+#ifndef QT_NO_SESSIONMANAGER
+
 QT_BEGIN_NAMESPACE
 
 class QEventLoop;
@@ -83,4 +85,6 @@ private:
 
 QT_END_NAMESPACE
 
+#endif //QT_NO_SESSIONMANAGER
+
 #endif //QXCBSESSIONMANAGER_H
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -236,6 +236,7 @@ static inline XTextProperty* qstringToXT
         free_prop = true;
     }
 
+#ifndef QT_NO_TEXTCODEC
     static const QTextCodec* mapper = QTextCodec::codecForLocale();
     int errCode = 0;
     if (mapper) {
@@ -259,6 +260,7 @@ static inline XTextProperty* qstringToXT
         tp.nitems = qcs.length();
         free_prop = false;
     }
+#endif
     return &tp;
 }
 #endif // XCB_USE_XLIB
--- a/src/printsupport/widgets/qcupsjobwidget_p.h
+++ b/src/printsupport/widgets/qcupsjobwidget_p.h
@@ -47,13 +47,14 @@
 //
 //
 
-#include <ui_qcupsjobwidget.h>
 #include <private/qcups_p.h>
 
-QT_BEGIN_NAMESPACE
-
 #if !defined(QT_NO_PRINTER) && !defined(QT_NO_CUPS)
 
+#include <ui_qcupsjobwidget.h>
+
+QT_BEGIN_NAMESPACE
+
 class QString;
 class QTime;
 class QPrinter;
@@ -100,8 +101,8 @@ private:
     Q_DISABLE_COPY(QCupsJobWidget)
 };
 
-#endif // QT_NO_PRINTER / QT_NO_CUPS
-
 QT_END_NAMESPACE
 
+#endif // QT_NO_PRINTER / QT_NO_CUPS
+
 #endif  // QCUPSJOBWIDGET_P_H
--- a/src/tools/uic/cpp/cppextractimages.cpp
+++ b/src/tools/uic/cpp/cppextractimages.cpp
@@ -82,7 +82,9 @@ void ExtractImages::acceptUI(DomUI *node
         m_imagesDir = dir;
 
         m_output = new QTextStream(&f);
+#ifndef QT_NO_TEXTCODEC
         m_output->setCodec(QTextCodec::codecForName("UTF-8"));
+#endif
 
         QTextStream &out = *m_output;
 
@@ -126,7 +128,9 @@ void ExtractImages::acceptImage(DomImage
 
     if (isXPM_GZ) {
         QTextStream *imageOut = new QTextStream(&f);
+#ifndef QT_NO_TEXTCODEC
         imageOut->setCodec(QTextCodec::codecForName("UTF-8"));
+#endif
 
         CPP::WriteIconData::writeImage(*imageOut, QString(), m_option.limitXPM_LineLength, image);
         delete imageOut;
--- a/src/tools/uic/main.cpp
+++ b/src/tools/uic/main.cpp
@@ -132,7 +132,9 @@ int runUic(int argc, char *argv[])
             return 1;
         }
         out = new QTextStream(&f);
+#ifndef QT_NO_TEXTCODEC
         out->setCodec(QTextCodec::codecForName("UTF-8"));
+#endif
     }
 
     bool rtn = driver.uic(inputFile, out);
--- a/src/widgets/accessible/itemviews.cpp
+++ b/src/widgets/accessible/itemviews.cpp
@@ -75,13 +75,22 @@ QAccessibleTable::QAccessibleTable(QWidg
 {
     Q_ASSERT(view());
 
+#ifndef QT_NO_TABLEVIEW
     if (qobject_cast<const QTableView*>(view())) {
         m_role = QAccessible::Table;
-    } else if (qobject_cast<const QTreeView*>(view())) {
+    } else
+#endif
+#ifndef QT_NO_TREEVIEW
+    if (qobject_cast<const QTreeView*>(view())) {
         m_role = QAccessible::Tree;
-    } else if (qobject_cast<const QListView*>(view())) {
+    } else
+#endif
+#ifndef QT_NO_LISTVIEW
+    if (qobject_cast<const QListView*>(view())) {
         m_role = QAccessible::List;
-    } else {
+    } else
+#endif
+    {
         // is this our best guess?
         m_role = QAccessible::Table;
     }
@@ -658,6 +667,8 @@ void QAccessibleTable::modelChange(QAcce
     }
 }
 
+#ifndef QT_NO_TREEVIEW
+
 // TREE VIEW
 
 QModelIndex QAccessibleTree::indexFromLogical(int row, int column) const
@@ -708,7 +719,6 @@ int QAccessibleTree::childCount() const
     return (treeView->d_func()->viewItems.count() + hHeader)* view()->model()->columnCount();
 }
 
-
 QAccessibleInterface *QAccessibleTree::child(int logicalIndex) const
 {
     if (logicalIndex < 0 || !view()->model() || !view()->model()->columnCount())
@@ -830,6 +840,8 @@ bool QAccessibleTree::selectRow(int row)
     return true;
 }
 
+#endif // QT_NO_TREEVIEW
+
 // TABLE CELL
 
 QAccessibleTableCell::QAccessibleTableCell(QAbstractItemView *view_, const QModelIndex &index_, QAccessible::Role role_)
@@ -906,12 +918,14 @@ int QAccessibleTableCell::columnIndex()
 
 int QAccessibleTableCell::rowIndex() const
 {
+#ifndef QT_NO_TREEVIEW
     if (role() == QAccessible::TreeItem) {
        const QTreeView *treeView = qobject_cast<const QTreeView*>(view);
        Q_ASSERT(treeView);
        int row = treeView->d_func()->viewIndex(m_index);
        return row;
     }
+#endif
     return m_index.row();
 }
 
@@ -1040,6 +1054,7 @@ QAccessible::State QAccessibleTableCell:
         if (view->selectionMode() == QAbstractItemView::ExtendedSelection)
             st.extSelectable = true;
     }
+#ifndef QT_NO_TREEVIEW
     if (m_role == QAccessible::TreeItem) {
         const QTreeView *treeView = qobject_cast<const QTreeView*>(view);
         if (treeView->model()->hasChildren(m_index))
@@ -1047,6 +1062,7 @@ QAccessible::State QAccessibleTableCell:
         if (treeView->isExpanded(m_index))
             st.expanded = true;
     }
+#endif
     return st;
 }
 
--- a/src/widgets/accessible/itemviews_p.h
+++ b/src/widgets/accessible/itemviews_p.h
@@ -138,6 +138,7 @@ private:
     QAccessible::Role m_role;
 };
 
+#ifndef QT_NO_TREEVIEW
 class QAccessibleTree :public QAccessibleTable
 {
 public:
@@ -165,6 +166,7 @@ private:
 
     inline int logicalIndex(const QModelIndex &index) const;
 };
+#endif
 
 class QAccessibleTableCell: public QAccessibleInterface, public QAccessibleTableCellInterface, public QAccessibleActionInterface
 {
@@ -214,7 +216,9 @@ private:
     void unselectCell();
 
 friend class QAccessibleTable;
+#ifndef QT_NO_TREEVIEW
 friend class QAccessibleTree;
+#endif
 };
 
 
@@ -248,7 +252,9 @@ private:
     Qt::Orientation orientation;
 
 friend class QAccessibleTable;
+#ifndef QT_NO_TREEVIEW
 friend class QAccessibleTree;
+#endif
 };
 
 // This is the corner button on the top left of a table.
--- a/src/widgets/accessible/qaccessiblewidget.cpp
+++ b/src/widgets/accessible/qaccessiblewidget.cpp
@@ -138,9 +138,11 @@ QString qt_accStripAmp(const QString &te
 
 QString qt_accHotKey(const QString &text)
 {
+#ifndef QT_NO_SHORTCUT
     int ampIndex = qt_accAmpIndex(text);
     if (ampIndex != -1)
         return QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + text.at(ampIndex + 1);
+#endif
 
     return QString();
 }
--- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp
+++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp
@@ -133,9 +133,11 @@ QAccessibleInterface *qAccessibleFactory
     } else if (classname == QLatin1String("QMenu")) {
         iface = new QAccessibleMenu(widget);
 #endif
-#ifndef QT_NO_ITEMVIEWS
+#ifndef QT_NO_TREEVIEW
     } else if (classname == QLatin1String("QTreeView")) {
         iface = new QAccessibleTree(widget);
+#endif // QT_NO_TREEVIEW
+#ifndef QT_NO_ITEMVIEWS
     } else if (classname == QLatin1String("QTableView") || classname == QLatin1String("QListView")) {
         iface = new QAccessibleTable(widget);
     // ### This should be cleaned up. We return the parent for the scrollarea to hide it.
--- a/src/widgets/accessible/simplewidgets.cpp
+++ b/src/widgets/accessible/simplewidgets.cpp
@@ -398,8 +398,10 @@ QAccessible::Role QAccessibleDisplay::ro
     } else if (qobject_cast<QProgressBar*>(object())) {
         return QAccessible::ProgressBar;
 #endif
+#ifndef QT_NO_STATUSBAR
     } else if (qobject_cast<QStatusBar*>(object())) {
         return QAccessible::StatusBar;
+#endif
     }
     return QAccessibleWidget::role();
 }
@@ -422,8 +424,10 @@ QString QAccessibleDisplay::text(QAccess
                     str = doc.toPlainText();
                 }
 #endif
+#ifndef QT_NO_SHORTCUT
                 if (label->buddy())
                     str = qt_accStripAmp(str);
+#endif
 #ifndef QT_NO_LCDNUMBER
             } else if (qobject_cast<QLCDNumber*>(object())) {
                 QLCDNumber *l = qobject_cast<QLCDNumber*>(object());
@@ -432,8 +436,10 @@ QString QAccessibleDisplay::text(QAccess
                 else
                     str = QString::number(l->intValue());
 #endif
+#ifndef QT_NO_STATUSBAR
             } else if (qobject_cast<QStatusBar*>(object())) {
                 return qobject_cast<QStatusBar*>(object())->currentMessage();
+#endif
             }
         }
         break;
--- a/src/widgets/dialogs/qdialog.cpp
+++ b/src/widgets/dialogs/qdialog.cpp
@@ -648,12 +648,14 @@ void QDialog::contextMenuEvent(QContextM
 /*! \reimp */
 void QDialog::keyPressEvent(QKeyEvent *e)
 {
+#ifndef QT_NO_SHORTCUT
     //   Calls reject() if Escape is pressed. Simulates a button
     //   click for the default button if Enter is pressed. Move focus
     //   for the arrow keys. Ignore the rest.
     if (e->matches(QKeySequence::Cancel)) {
         reject();
     } else
+#endif
     if (!e->modifiers() || (e->modifiers() & Qt::KeypadModifier && e->key() == Qt::Key_Enter)) {
         switch (e->key()) {
         case Qt::Key_Enter:
--- a/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h
+++ b/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h
@@ -108,8 +108,8 @@ private:
     int m_numSortedElements;
 };
 
-#endif // QT_NO_GRAPHICSVIEW
-
 QT_END_NAMESPACE
 
+#endif // QT_NO_GRAPHICSVIEW
+
 #endif // QGRAPHICSSCENELINEARINDEX_H
--- a/src/widgets/itemviews/qabstractitemdelegate.cpp
+++ b/src/widgets/itemviews/qabstractitemdelegate.cpp
@@ -458,11 +458,13 @@ bool QAbstractItemDelegatePrivate::edito
         if (editorHandlesKeyEvent(editor, keyEvent))
             return false;
 
+#ifndef QT_NO_SHORTCUT
         if (keyEvent->matches(QKeySequence::Cancel)) {
             // don't commit data
             emit q->closeEditor(editor, QAbstractItemDelegate::RevertModelCache);
             return true;
         }
+#endif
 
         switch (keyEvent->key()) {
         case Qt::Key_Tab:
@@ -513,11 +515,13 @@ bool QAbstractItemDelegatePrivate::edito
 
             emit q->closeEditor(editor, QAbstractItemDelegate::NoHint);
         }
+#ifndef QT_NO_SHORTCUT
     } else if (event->type() == QEvent::ShortcutOverride) {
         if (static_cast<QKeyEvent*>(event)->matches(QKeySequence::Cancel)) {
             event->accept();
             return true;
         }
+#endif
     }
     return false;
 }
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -2422,10 +2422,12 @@ void QAbstractItemView::keyPressEvent(QK
         break;
 #endif
     default: {
+#ifndef QT_NO_SHORTCUT
        if (event == QKeySequence::SelectAll && selectionMode() != NoSelection) {
             selectAll();
             break;
         }
+#endif
 #ifdef Q_OS_OSX
         if (event->key() == Qt::Key_O && event->modifiers() & Qt::ControlModifier && currentIndex().isValid()) {
             emit activated(currentIndex());
--- a/src/widgets/kernel/qaction.cpp
+++ b/src/widgets/kernel/qaction.cpp
@@ -1308,8 +1308,10 @@ Q_WIDGETS_EXPORT QDebug operator<<(QDebu
             d << " toolTip=" << action->toolTip();
         if (action->isCheckable())
             d << " checked=" << action->isChecked();
+#ifndef QT_NO_SHORTCUT
         if (!action->shortcut().isEmpty())
             d << " shortcut=" << action->shortcut();
+#endif
         d << " menuRole=";
         QtDebugUtils::formatQEnum(d, action->menuRole());
         d << " visible=" << action->isVisible();
--- a/src/widgets/kernel/qshortcut.cpp
+++ b/src/widgets/kernel/qshortcut.cpp
@@ -135,7 +135,7 @@ bool qWidgetShortcutContextMatcher(QObje
 static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidget *active_window)
 {
     bool visible = w->isVisible();
-#ifdef Q_OS_MAC
+#if defined(Q_OS_DARWIN) && !defined(QT_NO_MENUBAR)
     if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast<QMenuBar *>(w))
         visible = true;
 #endif
@@ -198,7 +198,7 @@ static bool correctWidgetContext(Qt::Sho
 static bool correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsWidget *w, QWidget *active_window)
 {
     bool visible = w->isVisible();
-#ifdef Q_OS_MAC
+#if defined(Q_OS_DARWIN) && !defined(QT_NO_MENUBAR)
     if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast<QMenuBar *>(w))
         visible = true;
 #endif
@@ -266,7 +266,7 @@ static bool correctActionContext(Qt::Sho
         QWidget *w = widgets.at(i);
 #ifndef QT_NO_MENU
         if (QMenu *menu = qobject_cast<QMenu *>(w)) {
-#ifdef Q_OS_MAC
+#ifdef Q_OS_DARWIN
             // On Mac, menu item shortcuts are processed before reaching any window.
             // That means that if a menu action shortcut has not been already processed
             // (and reaches this point), then the menu item itself has been disabled.
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -9422,10 +9422,13 @@ void QWidget::tabletEvent(QTabletEvent *
 
 void QWidget::keyPressEvent(QKeyEvent *event)
 {
+#ifndef QT_NO_SHORTCUT
     if ((windowType() == Qt::Popup) && event->matches(QKeySequence::Cancel)) {
         event->accept();
         close();
-    } else {
+    } else
+#endif
+    {
         event->ignore();
     }
 }
--- a/src/widgets/kernel/qwindowcontainer.cpp
+++ b/src/widgets/kernel/qwindowcontainer.cpp
@@ -91,11 +91,14 @@ public:
         }
         QWidget *p = q->parentWidget();
         while (p) {
-            if (
+            if (false
 #ifndef QT_NO_MDIAREA
-                qobject_cast<QMdiSubWindow *>(p) != 0 ||
+                || qobject_cast<QMdiSubWindow *>(p) != 0
 #endif
-                qobject_cast<QAbstractScrollArea *>(p) != 0) {
+#ifndef QT_NO_SCROLLAREA
+                || qobject_cast<QAbstractScrollArea *>(p) != 0
+#endif
+                    ) {
                 q->winId();
                 usesNativeWidgets = true;
                 break;
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -185,12 +185,14 @@ typedef HIRect * (*PtrHIShapeGetBounds)(
 static PtrHIShapeGetBounds ptrHIShapeGetBounds = 0;
 
 static int closeButtonSize = 12;
+#ifndef QT_NO_TABBAR
 static bool isVerticalTabs(const QTabBar::Shape shape) {
     return (shape == QTabBar::RoundedEast
                 || shape == QTabBar::TriangularEast
                 || shape == QTabBar::RoundedWest
                 || shape == QTabBar::TriangularWest);
 }
+#endif
 
 static bool isInMacUnifiedToolbarArea(QWindow *window, int windowY)
 {
@@ -242,6 +244,7 @@ void drawTabCloseButton(QPainter *p, boo
     p->drawLine(min, max, max, min);
 }
 
+#ifndef QT_NO_TABBAR
 QRect rotateTabPainter(QPainter *p, QTabBar::Shape shape, QRect tabRect)
 {
     if (isVerticalTabs(shape)) {
@@ -425,6 +428,7 @@ void drawTabBase(QPainter *p, const QSty
     p->setPen(borderBottom);
     p->drawLine(tabRect.x(), height - 1, width, height - 1);
 }
+#endif
 
 static int getControlSize(const QStyleOption *option, const QWidget *widget)
 {
@@ -440,13 +444,16 @@ static int getControlSize(const QStyleOp
 }
 
 
+#ifndef QT_NO_TREEVIEW
 static inline bool isTreeView(const QWidget *widget)
 {
     return (widget && widget->parentWidget() &&
             (qobject_cast<const QTreeView *>(widget->parentWidget())
              ));
 }
+#endif
 
+#ifndef QT_NO_TABBAR
 static inline ThemeTabDirection getTabDirection(QTabBar::Shape shape)
 {
     ThemeTabDirection ttd;
@@ -471,6 +478,7 @@ static inline ThemeTabDirection getTabDi
     }
     return ttd;
 }
+#endif
 
 static QString qt_mac_removeMnemonics(const QString &original)
 {
@@ -737,8 +745,10 @@ inline bool qt_mac_is_metal(const QWidge
         if (w->isWindow() && w->testAttribute(Qt::WA_WState_Created)) {  // If not created will fall through to the opaque check and be fine anyway.
             return qt_macWindowIsTextured(w);
         }
+#ifndef QT_NO_ACCESSIBILITY
         if (w->d_func()->isOpaque)
             break;
+#endif
     }
     return false;
 }
@@ -773,22 +783,34 @@ static QSize qt_aqua_get_known_size(QSty
             ct = QStyle::CT_RadioButton;
         else if (qobject_cast<const QCheckBox *>(widg))
             ct = QStyle::CT_CheckBox;
+#ifndef QT_NO_COMBOBOX
         else if (qobject_cast<const QComboBox *>(widg))
             ct = QStyle::CT_ComboBox;
+#endif
+#ifndef QT_NO_TOOLBUTTON
         else if (qobject_cast<const QToolButton *>(widg))
             ct = QStyle::CT_ToolButton;
+#endif
         else if (qobject_cast<const QSlider *>(widg))
             ct = QStyle::CT_Slider;
+#ifndef QT_NO_PROGRESSBAR
         else if (qobject_cast<const QProgressBar *>(widg))
             ct = QStyle::CT_ProgressBar;
+#endif
+#ifndef QT_NO_LINEEDIT
         else if (qobject_cast<const QLineEdit *>(widg))
             ct = QStyle::CT_LineEdit;
+#endif
         else if (qobject_cast<const QHeaderView *>(widg))
             ct = QStyle::CT_HeaderSection;
+#ifndef QT_NO_MENUBAR
         else if (qobject_cast<const QMenuBar *>(widg))
             ct = QStyle::CT_MenuBar;
+#endif
+#ifndef QT_NO_SIZEGRIP
         else if (qobject_cast<const QSizeGrip *>(widg))
             ct = QStyle::CT_SizeGrip;
+#endif
         else
             return ret;
     }
@@ -898,6 +920,7 @@ static QSize qt_aqua_get_known_size(QSty
         if (sz == QAquaSizeSmall) {
             int width = 0, height = 0;
             if (szHint == QSize(-1, -1)) { //just 'guess'..
+#ifndef QT_NO_TOOLBUTTON
                 const QToolButton *bt = qobject_cast<const QToolButton *>(widg);
                 // If this conversion fails then the widget was not what it claimed to be.
                 if(bt) {
@@ -918,7 +941,9 @@ static QSize qt_aqua_get_known_size(QSty
                             width = qMax(height, text_height);
                         }
                     }
-                } else {
+                } else
+#endif
+                {
                     // Let's return the size hint...
                     width = szHint.width();
                     height = szHint.height();
@@ -982,6 +1007,7 @@ static QSize qt_aqua_get_known_size(QSty
             ret.setWidth(w);
         break;
     }
+#ifndef QT_NO_PROGRESSBAR
     case QStyle::CT_ProgressBar: {
         int finalValue = -1;
         Qt::Orientation orient = Qt::Horizontal;
@@ -1000,6 +1026,8 @@ static QSize qt_aqua_get_known_size(QSty
             ret.setWidth(finalValue);
         break;
     }
+#endif
+#ifndef QT_NO_COMBOBOX
     case QStyle::CT_LineEdit:
         if (!widg || !qobject_cast<QComboBox *>(widg->parentWidget())) {
             //should I take into account the font dimentions of the lineedit? -Sam
@@ -1009,9 +1037,12 @@ static QSize qt_aqua_get_known_size(QSty
                 ret = QSize(-1, 19);
         }
         break;
+#endif
     case QStyle::CT_HeaderSection:
+#ifndef QT_NO_TREEVIEW
         if (isTreeView(widg))
            ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricListHeaderHeight));
+#endif
         break;
     case QStyle::CT_MenuBar:
         if (sz == QAquaSizeLarge) {
@@ -1408,6 +1439,7 @@ void QMacStylePrivate::initComboboxBdi(c
         // an extra check here before using the mini and small buttons.
         int h = combo->rect.size().height();
         if (combo->editable){
+#ifndef QT_NO_DATETIMEEDIT
             if (qobject_cast<const QDateTimeEdit *>(widget)) {
                 // Except when, you know, we get a QDateTimeEdit with calendarPopup
                 // enabled. And then things get weird, basically because it's a
@@ -1424,7 +1456,9 @@ void QMacStylePrivate::initComboboxBdi(c
                     bdi->kind = kThemeComboBoxSmall;
                 else
                     bdi->kind = kThemeComboBox;
-            } else {
+            } else
+#endif
+            {
                 if (h < 21)
                     bdi->kind = kThemeComboBoxMini;
                 else if (h < 26)
@@ -2294,7 +2328,12 @@ void QMacStyle::polish(QWidget* w)
         w->setAttribute(Qt::WA_SetPalette, false);
     }
 
-    if (qobject_cast<QMenu*>(w) || qobject_cast<QComboBoxPrivateContainer *>(w)) {
+#ifndef QT_NO_MENU
+    if (qobject_cast<QMenu*>(w)
+#ifndef QT_NO_COMBOBOX
+            || qobject_cast<QComboBoxPrivateContainer *>(w)
+#endif
+            ) {
         w->setWindowOpacity(0.985);
         if (!w->testAttribute(Qt::WA_SetPalette)) {
             QPixmap px(64, 64);
@@ -2314,7 +2353,9 @@ void QMacStyle::polish(QWidget* w)
             w->setAttribute(Qt::WA_SetPalette, false);
         }
     }
+#endif
 
+#ifndef QT_NO_TABBAR
     if (QTabBar *tb = qobject_cast<QTabBar*>(w)) {
         if (tb->documentMode()) {
             w->setAttribute(Qt::WA_Hover);
@@ -2324,6 +2365,7 @@ void QMacStyle::polish(QWidget* w)
             w->setPalette(p);
         }
     }
+#endif
 
     QCommonStyle::polish(w);
 
@@ -2342,19 +2384,26 @@ void QMacStyle::polish(QWidget* w)
 
 void QMacStyle::unpolish(QWidget* w)
 {
-    if ((qobject_cast<QMenu*>(w) || qt_mac_is_metal(w)) && !w->testAttribute(Qt::WA_SetPalette)) {
+    if ((
+#ifndef QT_NO_MENU
+            qobject_cast<QMenu*>(w) ||
+#endif
+            qt_mac_is_metal(w)
+        ) && !w->testAttribute(Qt::WA_SetPalette)) {
         QPalette pal = qApp->palette(w);
         w->setPalette(pal);
         w->setAttribute(Qt::WA_SetPalette, false);
         w->setWindowOpacity(1.0);
     }
 
+#ifndef QT_NO_COMBOBOX
     if (QComboBox *combo = qobject_cast<QComboBox *>(w)) {
         if (!combo->isEditable()) {
             if (QWidget *widget = combo->findChild<QComboBoxPrivateContainer *>())
                 widget->setWindowOpacity(1.0);
         }
     }
+#endif
 
     if (QRubberBand *rubber = qobject_cast<QRubberBand*>(w)) {
         rubber->setWindowOpacity(1.0);
@@ -2906,9 +2955,12 @@ int QMacStyle::styleHint(StyleHint sh, c
         ret = QEvent::MouseButtonRelease;
         break;
     case SH_TabBar_SelectMouseType:
+#ifndef QT_NO_TABBAR
         if (const QStyleOptionTabBarBase *opt2 = qstyleoption_cast<const QStyleOptionTabBarBase *>(opt)) {
             ret = opt2->documentMode ? QEvent::MouseButtonPress : QEvent::MouseButtonRelease;
-        } else {
+        } else
+#endif
+        {
             ret = QEvent::MouseButtonRelease;
         }
         break;
@@ -2928,18 +2980,22 @@ int QMacStyle::styleHint(StyleHint sh, c
         ret = Qt::AlignRight;
         break;
     case SH_TabBar_Alignment: {
+#ifndef QT_NO_TABWIDGET
         if (const QTabWidget *tab = qobject_cast<const QTabWidget*>(w)) {
             if (tab->documentMode()) {
                 ret = Qt::AlignLeft;
                 break;
             }
         }
+#endif
+#ifndef QT_NO_TABBAR
         if (const QTabBar *tab = qobject_cast<const QTabBar*>(w)) {
             if (tab->documentMode()) {
                 ret = Qt::AlignLeft;
                 break;
             }
         }
+#endif
         ret = Qt::AlignCenter;
         } break;
     case SH_UnderlineShortcut:
@@ -3069,9 +3125,11 @@ int QMacStyle::styleHint(StyleHint sh, c
     case SH_FocusFrame_AboveWidget:
         ret = true;
         break;
+#ifndef QT_NO_WIZARD
     case SH_WizardStyle:
         ret = QWizard::MacStyle;
         break;
+#endif
     case SH_ItemView_ArrowKeysNavigateIntoChildren:
         ret = false;
         break;
@@ -3089,9 +3147,11 @@ int QMacStyle::styleHint(StyleHint sh, c
                                              opt->rect.width(), opt->rect.height() - 8);
                 HIThemeMenuDrawInfo mdi;
                 mdi.version = 0;
+#ifndef QT_NO_MENU
                 if (w && qobject_cast<QMenu *>(w->parentWidget()))
                     mdi.menuType = kThemeMenuTypeHierarchical;
                 else
+#endif
                     mdi.menuType = kThemeMenuTypePopUp;
                 QCFType<HIShapeRef> shape;
                 HIThemeGetMenuBackgroundShape(&menuRect, &mdi, &shape);
@@ -3103,9 +3163,11 @@ int QMacStyle::styleHint(StyleHint sh, c
     case SH_ItemView_PaintAlternatingRowColorsForEmptyArea:
         ret = true;
         break;
+#ifndef QT_NO_TABBAR
     case SH_TabBar_CloseButtonPosition:
         ret = QTabBar::LeftSide;
         break;
+#endif
     case SH_DockWidget_ButtonsHaveFrame:
         ret = false;
         break;
@@ -3271,6 +3333,7 @@ void QMacStyle::drawPrimitive(PrimitiveE
         p->drawPath(path);
         p->restore();
         break; }
+#ifndef QT_NO_TABBAR
     case PE_FrameTabBarBase:
         if (const QStyleOptionTabBarBase *tbb
                 = qstyleoption_cast<const QStyleOptionTabBarBase *>(opt)) {
@@ -3306,6 +3369,7 @@ void QMacStyle::drawPrimitive(PrimitiveE
             p->restore();
         }
         break;
+#endif
     case PE_PanelTipLabel:
         p->fillRect(opt->rect, opt->palette.brush(QPalette::ToolTipBase));
         break;
@@ -3317,9 +3381,11 @@ void QMacStyle::drawPrimitive(PrimitiveE
                 HIThemeGroupBoxDrawInfo gdi;
                 gdi.version = qt_mac_hitheme_version;
                 gdi.state = tds;
+#ifndef QT_NO_GROUPBOX
                 if (w && qobject_cast<QGroupBox *>(w->parentWidget()))
                     gdi.kind = kHIThemeGroupBoxKindSecondary;
                 else
+#endif
                     gdi.kind = kHIThemeGroupBoxKindPrimary;
                 HIRect hirect = qt_hirectForQRect(opt->rect);
                 HIThemeDrawGroupBox(&hirect, &gdi, cg, kHIThemeOrientationNormal);
@@ -3553,6 +3619,7 @@ void QMacStyle::drawPrimitive(PrimitiveE
         // Draw the focus frame for widgets other than QLineEdit (e.g. for line edits in Webkit).
         // Focus frame is drawn outside the rectangle passed in the option-rect.
         if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
+#ifndef QT_NO_LINEEDIT
             if ((opt->state & State_HasFocus) && !qobject_cast<const QLineEdit*>(w)) {
                 int vmargin = pixelMetric(QStyle::PM_FocusFrameVMargin);
                 int hmargin = pixelMetric(QStyle::PM_FocusFrameHMargin);
@@ -3560,9 +3627,11 @@ void QMacStyle::drawPrimitive(PrimitiveE
                 focusFrame.rect = panel->rect.adjusted(-hmargin, -vmargin, hmargin, vmargin);
                 drawControl(CE_FocusFrame, &focusFrame, p, w);
             }
+#endif
         }
 
         break;
+#ifndef QT_NO_TABWIDGET
     case PE_FrameTabWidget:
         if (const QStyleOptionTabWidgetFrame *twf
                 = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
@@ -3577,6 +3646,7 @@ void QMacStyle::drawPrimitive(PrimitiveE
             HIThemeDrawTabPane(&hirect, &tpdi, cg, kHIThemeOrientationNormal);
         }
         break;
+#endif
     case PE_PanelScrollAreaCorner: {
         const QBrush brush(opt->palette.brush(QPalette::Base));
         p->fillRect(opt->rect, brush);
@@ -3720,9 +3790,11 @@ void QMacStyle::drawControl(ControlEleme
             HIRect bounds = qt_hirectForQRect(ir);
 
             bool noVerticalHeader = true;
+#ifndef QT_NO_TABLEVIEW
             if (w)
                 if (const QTableView *table = qobject_cast<const QTableView *>(w->parentWidget()))
                     noVerticalHeader = !table->verticalHeader()->isVisible();
+#endif
 
             bool drawTopBorder = header->orientation == Qt::Horizontal;
             bool drawLeftBorder = header->orientation == Qt::Vertical
@@ -4157,6 +4229,7 @@ void QMacStyle::drawControl(ControlEleme
             QCommonStyle::drawControl(CE_ComboBoxLabel, &comboCopy, p, w);
         }
         break;
+#ifndef QT_NO_TABBAR
     case CE_TabBarTabShape:
         if (const QStyleOptionTab *tabOpt = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
 
@@ -4363,6 +4436,8 @@ void QMacStyle::drawControl(ControlEleme
             }
         }
         break;
+#endif
+#ifndef QT_NO_DOCKWIDGET
     case CE_DockWidgetTitle:
         if (const QDockWidget *dockWidget = qobject_cast<const QDockWidget *>(w)) {
             bool floating = dockWidget->isFloating();
@@ -4439,6 +4514,7 @@ void QMacStyle::drawControl(ControlEleme
             }
         }
         break;
+#endif
     case CE_FocusFrame: {
         const int hMargin = proxy()->pixelMetric(QStyle::PM_FocusFrameHMargin, opt, w);
         const int vMargin = proxy()->pixelMetric(QStyle::PM_FocusFrameVMargin, opt, w);
@@ -4563,9 +4639,11 @@ void QMacStyle::drawControl(ControlEleme
                 // Always be normal or disabled to follow the Mac style.
                 int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize);
                 QSize iconSize(smallIconSize, smallIconSize);
+#ifndef QT_NO_COMBOBOX
                 if (const QComboBox *comboBox = qobject_cast<const QComboBox *>(w)) {
                     iconSize = comboBox->iconSize();
                 }
+#endif
                 QPixmap pixmap = mi->icon.pixmap(window, iconSize, mode);
                 int pixw = pixmap.width() / pixmap.devicePixelRatio();
                 int pixh = pixmap.height() / pixmap.devicePixelRatio();
@@ -4849,6 +4927,7 @@ void QMacStyle::drawControl(ControlEleme
             }
         }
         break;
+#ifndef QT_NO_TOOLBAR
     case CE_ToolBar: {
         const QStyleOptionToolBar *toolBar = qstyleoption_cast<const QStyleOptionToolBar *>(opt);
 
@@ -4857,6 +4936,7 @@ void QMacStyle::drawControl(ControlEleme
         // the title bar. The following code fills the toolBar area with transparent pixels
         // to make that gradient visible.
         if (w)  {
+#ifndef QT_NO_MAINWINDOW
             if (QMainWindow * mainWindow = qobject_cast<QMainWindow *>(w->window())) {
                 if (toolBar && toolBar->toolBarArea == Qt::TopToolBarArea && mainWindow->unifiedTitleAndToolBarOnMac()) {
 
@@ -4885,6 +4965,7 @@ void QMacStyle::drawControl(ControlEleme
                     break;
                 }
             }
+#endif
         }
 
         // draw background gradient
@@ -4915,6 +4996,7 @@ void QMacStyle::drawControl(ControlEleme
 
 
         } break;
+#endif
     default:
         QCommonStyle::drawControl(ce, opt, p, w);
         break;
@@ -5006,6 +5088,7 @@ QRect QMacStyle::subElementRect(SubEleme
                   int(outRect.size.height));
         break;
     }
+#ifndef QT_NO_TABWIDGET
     case SE_TabWidgetLeftCorner:
         if (const QStyleOptionTabWidgetFrame *twf
                 = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
@@ -5067,11 +5150,14 @@ QRect QMacStyle::subElementRect(SubEleme
             }
         }
         break;
+#endif
     case SE_LineEditContents:
         rect = QCommonStyle::subElementRect(sr, opt, widget);
+#ifndef QT_NO_COMBOBOX
         if (widget && qobject_cast<const QComboBox*>(widget->parentWidget()))
             rect.adjust(-1, -2, 0, 0);
         else
+#endif
             rect.adjust(-1, -1, 0, +1);
         break;
     case SE_CheckBoxLayoutItem:
@@ -5085,12 +5171,15 @@ QRect QMacStyle::subElementRect(SubEleme
         }
         break;
     case SE_ComboBoxLayoutItem:
+#ifndef QT_NO_TOOLBAR
         if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) {
             // Do nothing, because QToolbar needs the entire widget rect.
             // Otherwise it will be clipped. Equivalent to
             // widget->setAttribute(Qt::WA_LayoutUsesWidgetRect), but without
             // all the hassle.
-        } else {
+        } else
+#endif
+        {
             rect = opt->rect;
             if (controlSize == QAquaSizeLarge) {
                 rect.adjust(+3, +2, -3, -4);
@@ -5208,6 +5297,7 @@ QRect QMacStyle::subElementRect(SubEleme
         }
         rect.setBottom(rect.bottom() - 1);
         break;
+#ifndef QT_NO_TABWIDGET
     case SE_TabWidgetLayoutItem:
         if (const QStyleOptionTabWidgetFrame *tabWidgetOpt =
                 qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
@@ -5221,6 +5311,7 @@ QRect QMacStyle::subElementRect(SubEleme
                 rect.setTop(rect.top() + SIZE(6 /* AHIG */, 3 /* guess */, 2 /* AHIG */));
         }
         break;
+#endif
 #ifndef QT_NO_DOCKWIDGET
         case SE_DockWidgetCloseButton:
         case SE_DockWidgetFloatButton:
@@ -5727,6 +5818,7 @@ void QMacStyle::drawComplexControl(Compl
             }
         }
         break;
+#ifndef QT_NO_SPINBOX
     case CC_SpinBox:
         if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
             QStyleOptionSpinBox newSB = *sb;
@@ -5797,6 +5889,7 @@ void QMacStyle::drawComplexControl(Compl
             }
         }
         break;
+#endif
     case CC_ComboBox:
         if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(opt)){
             HIThemeButtonDrawInfo bdi;
@@ -6102,10 +6195,12 @@ void QMacStyle::drawComplexControl(Compl
 #endif
         }
         break;
+#ifndef QT_NO_DIAL
     case CC_Dial:
         if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(opt))
             QStyleHelper::drawDial(dial, p);
         break;
+#endif
     default:
         QCommonStyle::drawComplexControl(cc, opt, p, widget);
         break;
@@ -6483,6 +6578,7 @@ QRect QMacStyle::subControlRect(ComplexC
             }
         }
         break;
+#ifndef QT_NO_SPINBOX
     case CC_SpinBox:
         if (const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
             QAquaWidgetSize aquaSize = d->aquaSizeConstrain(spin, widget);
@@ -6576,6 +6672,7 @@ QRect QMacStyle::subControlRect(ComplexC
             }
         }
         break;
+#endif
     case CC_ToolButton:
         ret = QCommonStyle::subControlRect(cc, opt, sc, widget);
         if (sc == SC_ToolButtonMenu
@@ -6601,7 +6698,7 @@ QSize QMacStyle::sizeFromContents(Conten
     bool useAquaGuideline = true;
 
     switch (ct) {
-
+#ifndef QT_NO_SPINBOX
     case CT_SpinBox:
         if (const QStyleOptionSpinBox *vopt = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
             // Add button + frame widths
@@ -6610,6 +6707,7 @@ QSize QMacStyle::sizeFromContents(Conten
             sz += QSize(buttonWidth + 2*fw, 2*fw - 3);
         }
         break;
+#endif
     case QStyle::CT_TabWidget:
         // the size between the pane and the "contentsRect" (+4,+4)
         // (the "contentsRect" is on the inside of the pane)
@@ -6645,7 +6743,7 @@ QSize QMacStyle::sizeFromContents(Conten
              * overlap is how much the pane should overlap the tab bar
         */
         // then add the size between the stackwidget and the "contentsRect"
-
+#ifndef QT_NO_TABWIDGET
         if (const QStyleOptionTabWidgetFrame *twf
                 = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
             QSize extra(0,0);
@@ -6659,8 +6757,9 @@ QSize QMacStyle::sizeFromContents(Conten
             }
             sz+= extra;
         }
-
+#endif
         break;
+#ifndef QT_NO_TABBAR
     case QStyle::CT_TabBarTab:
         if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
             const QAquaWidgetSize AquaSize = d->aquaSizeConstrain(opt, widget);
@@ -6728,6 +6827,7 @@ QSize QMacStyle::sizeFromContents(Conten
             }
         }
         break;
+#endif
     case QStyle::CT_PushButton:
         // By default, we fit the contents inside a normal rounded push button.
         // Do this by add enough space around the contents so that rounded
@@ -6741,7 +6841,9 @@ QSize QMacStyle::sizeFromContents(Conten
     case QStyle::CT_MenuItem:
         if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
             int maxpmw = mi->maxIconWidth;
+#ifndef QT_NO_COMBOBOX
             const QComboBox *comboBox = qobject_cast<const QComboBox *>(widget);
+#endif
             int w = sz.width(),
                 h = sz.height();
             if (mi->menuItemType == QStyleOptionMenuItem::Separator) {
@@ -6752,11 +6854,14 @@ QSize QMacStyle::sizeFromContents(Conten
             } else {
                 h = mi->fontMetrics.height() + 2;
                 if (!mi->icon.isNull()) {
+#ifndef QT_NO_COMBOBOX
                     if (comboBox) {
                         const QSize &iconSize = comboBox->iconSize();
                         h = qMax(h, iconSize.height() + 4);
                         maxpmw = qMax(maxpmw, iconSize.width());
-                    } else {
+                    } else
+#endif
+                    {
                         int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
                         h = qMax(h, mi->icon.actualSize(QSize(iconExtent, iconExtent)).height() + 4);
                     }
@@ -6770,6 +6875,7 @@ QSize QMacStyle::sizeFromContents(Conten
                 w += maxpmw + 6;
             // add space for a check. All items have place for a check too.
             w += 20;
+#ifndef QT_NO_COMBOBOX
             if (comboBox && comboBox->isVisible()) {
                 QStyleOptionComboBox cmb;
                 cmb.initFrom(comboBox);
@@ -6779,7 +6885,9 @@ QSize QMacStyle::sizeFromContents(Conten
                 w = qMax(w, subControlRect(QStyle::CC_ComboBox, &cmb,
                                                    QStyle::SC_ComboBoxEditField,
                                                    comboBox).width());
-            } else {
+            } else
+#endif
+            {
                 w += 12;
             }
             sz = QSize(w, h);
--- a/src/widgets/styles/qstylehelper.cpp
+++ b/src/widgets/styles/qstylehelper.cpp
@@ -385,9 +385,11 @@ void drawBorderPixmap(const QPixmap &pix
 
 QColor backgroundColor(const QPalette &pal, const QWidget* widget)
 {
+#ifndef QT_NO_SCROLLBAR
     if (qobject_cast<const QScrollBar *>(widget) && widget->parent() &&
             qobject_cast<const QAbstractScrollArea *>(widget->parent()->parent()))
         return widget->parentWidget()->parentWidget()->palette().color(QPalette::Base);
+#endif
     return pal.color(QPalette::Base);
 }
 
--- a/src/widgets/widgets/qabstractbutton.cpp
+++ b/src/widgets/widgets/qabstractbutton.cpp
@@ -1093,6 +1093,7 @@ void QAbstractButton::keyPressEvent(QKey
         break;
     }
     default:
+#ifndef QT_NO_SHORTCUT
         if (e->matches(QKeySequence::Cancel) && d->down) {
             setDown(false);
             repaint(); //flush paint event before invoking potentially expensive operation
@@ -1100,6 +1101,7 @@ void QAbstractButton::keyPressEvent(QKey
             d->emitReleased();
             return;
         }
+#endif
         e->ignore();
     }
 }
--- a/src/widgets/widgets/qeffects.cpp
+++ b/src/widgets/widgets/qeffects.cpp
@@ -196,10 +196,13 @@ bool QAlphaWidget::eventFilter(QObject *
         render();
         break;
     case QEvent::KeyPress: {
+#ifndef QT_NO_SHORTCUT
        QKeyEvent *ke = (QKeyEvent*)e;
        if (ke->matches(QKeySequence::Cancel)) {
            showWidget = false;
-       } else {
+       } else
+#endif
+       {
            duration = 0;
        }
        render();
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -2684,7 +2684,10 @@ QMenu::event(QEvent *e)
             if (kev->key() == Qt::Key_Up || kev->key() == Qt::Key_Down
                 || kev->key() == Qt::Key_Left || kev->key() == Qt::Key_Right
                 || kev->key() == Qt::Key_Enter || kev->key() == Qt::Key_Return
-                || kev->matches(QKeySequence::Cancel)) {
+#ifndef QT_NO_SHORTCUT
+                || kev->matches(QKeySequence::Cancel)
+#endif
+                    ) {
                 e->accept();
                 return true;
             }
@@ -3011,7 +3014,11 @@ void QMenu::keyPressEvent(QKeyEvent *e)
         key_consumed = false;
     }
 
-    if (!key_consumed && (e->matches(QKeySequence::Cancel)
+    if (!key_consumed && (
+        false
+#ifndef QT_NO_SHORTCUT
+        || e->matches(QKeySequence::Cancel)
+#endif
 #ifdef QT_KEYPAD_NAVIGATION
         || e->key() == Qt::Key_Back
 #endif
@@ -3227,7 +3234,9 @@ static void copyActionToPlatformItem(con
         item->setIcon(QIcon());
     }
     item->setVisible(action->isVisible());
+#ifndef QT_NO_SHORTCUT
     item->setShortcut(action->shortcut());
+#endif
     item->setCheckable(action->isCheckable());
     item->setChecked(action->isChecked());
     item->setFont(action->font());
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -1124,11 +1124,13 @@ void QMenuBar::keyPressEvent(QKeyEvent *
         key_consumed = false;
     }
 
+#ifndef QT_NO_SHORTCUT
     if (!key_consumed && e->matches(QKeySequence::Cancel)) {
         d->setCurrentAction(0);
         d->setKeyboardMode(false);
         key_consumed = true;
     }
+#endif
 
     if(!key_consumed &&
        (!e->modifiers() ||
@@ -1445,6 +1447,7 @@ bool QMenuBar::event(QEvent *e)
     case QEvent::Show:
         d->_q_updateLayout();
     break;
+#ifndef QT_NO_SHORTCUT
     case QEvent::ShortcutOverride: {
         QKeyEvent *kev = static_cast<QKeyEvent*>(e);
         //we only filter out escape if there is a current action
@@ -1454,8 +1457,7 @@ bool QMenuBar::event(QEvent *e)
         }
     }
     break;
-
-
+#endif
 #ifndef QT_NO_WHATSTHIS
     case QEvent::QueryWhatsThis:
         e->setAccepted(d->whatsThis.size());
--- a/src/platformsupport/dbusmenu/qdbusplatformmenu_p.h
+++ b/src/platformsupport/dbusmenu/qdbusplatformmenu_p.h
@@ -91,8 +91,10 @@ public:
     void setCheckable(bool checkable) Q_DECL_OVERRIDE;
     bool isChecked() const { return m_isChecked; }
     void setChecked(bool isChecked) Q_DECL_OVERRIDE;
+#ifndef QT_NO_SHORTCUT
     QKeySequence shortcut() const { return m_shortcut; }
     void setShortcut(const QKeySequence& shortcut) Q_DECL_OVERRIDE;
+#endif
     void setIconSize(int size) Q_DECL_OVERRIDE { Q_UNUSED(size); }
     void setNativeContents(WId item) Q_DECL_OVERRIDE { Q_UNUSED(item); }
 
