summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStephan Binner <stephan.binner@basyskom.com>2017-08-27 19:06:42 +0200
committerStephan Binner <stephan.binner@basyskom.com>2017-09-04 06:40:14 +0000
commit314a591461c58addd2805e0b4dc2cdb4308d5d31 (patch)
treedb353751ef969c00d9649c7c424c14d06ca83472 /src
parentb649717784368f04e61f5bc240c052c5c4744a2c (diff)
Convert features.menubar to QT_[REQUIRE_]CONFIG
Change-Id: Idbd4978852fa280dd18a5684469d499da3892126 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/accessible/qaccessiblemenu.cpp12
-rw-r--r--src/widgets/accessible/qaccessiblemenu_p.h4
-rw-r--r--src/widgets/accessible/qaccessiblewidgetfactory.cpp2
-rw-r--r--src/widgets/kernel/qlayout.cpp16
-rw-r--r--src/widgets/kernel/qlayoutitem.cpp2
-rw-r--r--src/widgets/kernel/qshortcut.cpp6
-rw-r--r--src/widgets/styles/qcommonstyle.cpp4
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm4
-rw-r--r--src/widgets/styles/qmacstyle_mac_p_p.h2
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp6
-rw-r--r--src/widgets/styles/qwindowsstyle.cpp14
-rw-r--r--src/widgets/styles/qwindowsvistastyle.cpp2
-rw-r--r--src/widgets/styles/qwindowsxpstyle.cpp2
-rw-r--r--src/widgets/widgets/qmainwindow.cpp9
-rw-r--r--src/widgets/widgets/qmainwindow.h2
-rw-r--r--src/widgets/widgets/qmdiarea.cpp1
-rw-r--r--src/widgets/widgets/qmdisubwindow.cpp39
-rw-r--r--src/widgets/widgets/qmdisubwindow_p.h8
-rw-r--r--src/widgets/widgets/qmenu.cpp28
-rw-r--r--src/widgets/widgets/qmenu_mac.mm6
-rw-r--r--src/widgets/widgets/qmenu_p.h2
-rw-r--r--src/widgets/widgets/qmenubar.cpp6
-rw-r--r--src/widgets/widgets/qmenubar.h7
-rw-r--r--src/widgets/widgets/qmenubar_p.h5
-rw-r--r--src/widgets/widgets/qtoolbar.cpp2
-rw-r--r--src/widgets/widgets/widgets.pri11
26 files changed, 114 insertions, 88 deletions
diff --git a/src/widgets/accessible/qaccessiblemenu.cpp b/src/widgets/accessible/qaccessiblemenu.cpp
index ae50bbaef0..715bf1c53f 100644
--- a/src/widgets/accessible/qaccessiblemenu.cpp
+++ b/src/widgets/accessible/qaccessiblemenu.cpp
@@ -40,7 +40,9 @@
#include "qaccessiblemenu_p.h"
#include <qmenu.h>
+#if QT_CONFIG(menubar)
#include <qmenubar.h>
+#endif
#include <QtWidgets/QAction>
#include <qstyle.h>
@@ -139,7 +141,7 @@ int QAccessibleMenu::indexOfChild( const QAccessibleInterface *child) const
return -1;
}
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
QAccessibleMenuBar::QAccessibleMenuBar(QWidget *w)
: QAccessibleWidget(w, QAccessible::MenuBar)
{
@@ -173,7 +175,7 @@ int QAccessibleMenuBar::indexOfChild(const QAccessibleInterface *child) const
return -1;
}
-#endif // QT_NO_MENUBAR
+#endif // QT_CONFIG(menubar)
QAccessibleMenuItem::QAccessibleMenuItem(QWidget *owner, QAction *action)
: m_action(action), m_owner(owner)
@@ -253,13 +255,13 @@ QRect QAccessibleMenuItem::rect() const
{
QRect rect;
QWidget *own = owner();
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (QMenuBar *menuBar = qobject_cast<QMenuBar*>(own)) {
rect = menuBar->actionGeometry(m_action);
QPoint globalPos = menuBar->mapToGlobal(QPoint(0,0));
rect = rect.translated(globalPos);
} else
-#endif // QT_NO_MENUBAR
+#endif // QT_CONFIG(menubar)
if (QMenu *menu = qobject_cast<QMenu*>(own)) {
rect = menu->actionGeometry(m_action);
QPoint globalPos = menu->mapToGlobal(QPoint(0,0));
@@ -289,7 +291,7 @@ QAccessible::State QAccessibleMenuItem::state() const
if (QMenu *menu = qobject_cast<QMenu*>(own)) {
if (menu->activeAction() == m_action)
s.focused = true;
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
} else if (QMenuBar *menuBar = qobject_cast<QMenuBar*>(own)) {
if (menuBar->activeAction() == m_action)
s.focused = true;
diff --git a/src/widgets/accessible/qaccessiblemenu_p.h b/src/widgets/accessible/qaccessiblemenu_p.h
index 52afeb5a04..35dcd9bad1 100644
--- a/src/widgets/accessible/qaccessiblemenu_p.h
+++ b/src/widgets/accessible/qaccessiblemenu_p.h
@@ -82,7 +82,7 @@ protected:
QMenu *menu() const;
};
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
class QAccessibleMenuBar : public QAccessibleWidget
{
public:
@@ -96,7 +96,7 @@ public:
protected:
QMenuBar *menuBar() const;
};
-#endif // QT_NO_MENUBAR
+#endif // QT_CONFIG(menubar)
class QAccessibleMenuItem : public QAccessibleInterface, public QAccessibleActionInterface
diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp
index 30ba1ddedf..97eaea728c 100644
--- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp
+++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp
@@ -138,7 +138,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje
#endif
} else if (classname == QLatin1String("QToolBar")) {
iface = new QAccessibleWidget(widget, QAccessible::ToolBar, widget->windowTitle());
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
} else if (classname == QLatin1String("QMenuBar")) {
iface = new QAccessibleMenuBar(widget);
#endif
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index 129c12885a..56edd019bb 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -41,7 +41,9 @@
#include "qapplication.h"
#include "qlayoutengine_p.h"
+#if QT_CONFIG(menubar)
#include "qmenubar.h"
+#endif
#include "qtoolbar.h"
#include "qsizegrip.h"
#include "qevent.h"
@@ -583,7 +585,7 @@ void QLayoutPrivate::doResize(const QSize &r)
const int mbTop = rect.top();
rect.setTop(mbTop + mbh);
q->setGeometry(rect);
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (menubar)
menubar->setGeometry(rect.left(), mbTop, r.width(), mbh);
#endif
@@ -615,7 +617,7 @@ void QLayout::widgetEvent(QEvent *e)
{
QChildEvent *c = (QChildEvent *)e;
if (c->child()->isWidgetType()) {
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (c->child() == d->menubar)
d->menubar = 0;
#endif
@@ -664,7 +666,7 @@ int QLayout::totalHeightForWidth(int w) const
top += wd->topmargin + wd->bottommargin;
}
int h = heightForWidth(w - side) + top;
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
h += menuBarHeightForWidth(d->menubar, w);
#endif
return h;
@@ -687,7 +689,7 @@ QSize QLayout::totalMinimumSize() const
}
QSize s = minimumSize();
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
top += menuBarHeightForWidth(d->menubar, s.width() + side);
#endif
return s + QSize(side, top);
@@ -712,7 +714,7 @@ QSize QLayout::totalSizeHint() const
QSize s = sizeHint();
if (hasHeightForWidth())
s.setHeight(heightForWidth(s.width() + side));
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
top += menuBarHeightForWidth(d->menubar, s.width());
#endif
return s + QSize(side, top);
@@ -735,7 +737,7 @@ QSize QLayout::totalMaximumSize() const
}
QSize s = maximumSize();
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
top += menuBarHeightForWidth(d->menubar, s.width());
#endif
@@ -813,7 +815,7 @@ void QLayoutPrivate::reparentChildWidgets(QWidget *mw)
Q_Q(QLayout);
int n = q->count();
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (menubar && menubar->parentWidget() != mw) {
menubar->setParent(mw);
}
diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp
index 51793bf060..0bdac43c56 100644
--- a/src/widgets/kernel/qlayoutitem.cpp
+++ b/src/widgets/kernel/qlayoutitem.cpp
@@ -41,7 +41,9 @@
#include "qapplication.h"
#include "qlayoutengine_p.h"
+#if QT_CONFIG(menubar)
#include "qmenubar.h"
+#endif
#include "qtoolbar.h"
#include "qevent.h"
#include "qstyle.h"
diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp
index 891cf563d6..18376bb183 100644
--- a/src/widgets/kernel/qshortcut.cpp
+++ b/src/widgets/kernel/qshortcut.cpp
@@ -46,7 +46,9 @@
#include <qwhatsthis.h>
#endif
#include <qmenu.h>
+#if QT_CONFIG(menubar)
#include <qmenubar.h>
+#endif
#include <qapplication.h>
#include <private/qapplication_p.h>
#include <private/qshortcutmap_p.h>
@@ -143,7 +145,7 @@ bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context)
static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidget *active_window)
{
bool visible = w->isVisible();
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (QMenuBar *menuBar = qobject_cast<QMenuBar *>(w)) {
if (menuBar->isNativeMenuBar())
visible = true;
@@ -208,7 +210,7 @@ static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidge
static bool correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsWidget *w, QWidget *active_window)
{
bool visible = w->isVisible();
-#if defined(Q_OS_DARWIN) && !defined(QT_NO_MENUBAR)
+#if defined(Q_OS_DARWIN) && QT_CONFIG(menubar)
if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast<QMenuBar *>(w))
visible = true;
#endif
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index a8f8c97776..9a11e98032 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -1392,7 +1392,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
opt->rect.x() + opt->rect.width() - 4, opt->rect.y() + opt->rect.height() / 2);
break;
#endif // QT_NO_MENU
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
case CE_MenuBarItem:
if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip
@@ -1412,7 +1412,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
if (widget && !widget->testAttribute(Qt::WA_NoSystemBackground))
p->eraseRect(opt->rect);
break;
-#endif // QT_NO_MENUBAR
+#endif // QT_CONFIG(menubar)
#if QT_CONFIG(progressbar)
case CE_ProgressBar:
if (const QStyleOptionProgressBar *pb
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index d9eeb2c83b..fcda61ef8c 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -76,7 +76,9 @@
#include <qlineedit.h>
#include <qmainwindow.h>
#include <qmdisubwindow.h>
+#if QT_CONFIG(menubar)
#include <qmenubar.h>
+#endif
#include <qpaintdevice.h>
#include <qpainter.h>
#include <qpixmapcache.h>
@@ -677,7 +679,7 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
#endif
else if (qobject_cast<const QHeaderView *>(widg))
ct = QStyle::CT_HeaderSection;
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
else if (qobject_cast<const QMenuBar *>(widg))
ct = QStyle::CT_MenuBar;
#endif
diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h
index b9ba1d828e..142966de40 100644
--- a/src/widgets/styles/qmacstyle_mac_p_p.h
+++ b/src/widgets/styles/qmacstyle_mac_p_p.h
@@ -80,7 +80,9 @@
#endif
#include <qmainwindow.h>
#include <qmap.h>
+#if QT_CONFIG(menubar)
#include <qmenubar.h>
+#endif
#include <qpaintdevice.h>
#include <qpainter.h>
#include <qpixmapcache.h>
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index f704745c8f..e781cb2f14 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -46,7 +46,9 @@
#include <qdebug.h>
#include <qapplication.h>
#include <qmenu.h>
+#if QT_CONFIG(menubar)
#include <qmenubar.h>
+#endif
#include <qpainter.h>
#include <qstyleoption.h>
#include <qlineedit.h>
@@ -1660,7 +1662,7 @@ int QStyleSheetStyle::nativeFrameWidth(const QWidget *w)
return base->pixelMetric(QStyle::PM_MenuPanelWidth, 0, w);
#endif
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (qobject_cast<const QMenuBar *>(w))
return base->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, w);
#endif
@@ -2829,7 +2831,7 @@ void QStyleSheetStyle::polish(QWidget *w)
#ifndef QT_NO_MDIAREA
|| qobject_cast<QMdiSubWindow *>(w)
#endif
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
|| qobject_cast<QMenuBar *>(w)
#endif
#if QT_CONFIG(dialog)
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp
index 818c3ea07e..2cdfebae0a 100644
--- a/src/widgets/styles/qwindowsstyle.cpp
+++ b/src/widgets/styles/qwindowsstyle.cpp
@@ -47,8 +47,10 @@
#include "qdrawutil.h" // for now
#include "qevent.h"
#include "qmenu.h"
+#if QT_CONFIG(menubar)
#include "qmenubar.h"
#include <private/qmenubar_p.h>
+#endif
#include "qpaintengine.h"
#include "qpainter.h"
#if QT_CONFIG(rubberband)
@@ -166,7 +168,7 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e)
// Update state and repaint the menu bars.
d->alt_down = false;
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
QList<QMenuBar *> l = widget->findChildren<QMenuBar *>();
for (int i = 0; i < l.size(); ++i)
l.at(i)->update();
@@ -574,7 +576,7 @@ int QWindowsStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWid
// Do nothing if we always paint underlines
Q_D(const QWindowsStyle);
if (!ret && widget && d) {
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
const QMenuBar *menuBar = qobject_cast<const QMenuBar *>(widget);
if (!menuBar && qobject_cast<const QMenu *>(widget)) {
QWidget *w = QApplication::activeWindow();
@@ -587,7 +589,7 @@ int QWindowsStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWid
ret = 1;
// Otherwise draw underlines if the toplevel widget has seen an alt-press
} else
-#endif // QT_NO_MENUBAR
+#endif // QT_CONFIG(menubar)
if (d->hasSeenAlt(widget)) {
ret = 1;
}
@@ -1260,7 +1262,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
}
break;
#endif // QT_NO_MENU
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
case CE_MenuBarItem:
if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
bool active = mbi->state & State_Selected;
@@ -1284,7 +1286,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
QCommonStyle::drawControl(ce, &newMbi, p, widget);
}
break;
-#endif // QT_NO_MENUBAR
+#endif // QT_CONFIG(menubar)
#if QT_CONFIG(tabbar)
case CE_TabBarTabShape:
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
@@ -2392,7 +2394,7 @@ QSize QWindowsStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
}
break;
#endif // QT_NO_MENU
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
case CT_MenuBarItem:
if (!sz.isEmpty())
sz += QSize(QWindowsStylePrivate::windowsItemHMargin * 4, QWindowsStylePrivate::windowsItemVMargin * 2);
diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp
index 8ab4a61f5f..91fc36959b 100644
--- a/src/widgets/styles/qwindowsvistastyle.cpp
+++ b/src/widgets/styles/qwindowsvistastyle.cpp
@@ -1871,7 +1871,7 @@ QSize QWindowsVistaStyle::sizeFromContents(ContentsType type, const QStyleOption
sz.setHeight(minimumHeight);
}
return sz;
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
case CT_MenuBarItem:
if (!sz.isEmpty())
sz += QSize(windowsItemHMargin * 5 + 1, 5);
diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp
index fc9b12767d..8b363b830a 100644
--- a/src/widgets/styles/qwindowsxpstyle.cpp
+++ b/src/widgets/styles/qwindowsxpstyle.cpp
@@ -3661,7 +3661,7 @@ QSize QWindowsXPStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt
case CT_Menu:
sz += QSize(1, 0);
break;
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
case CT_MenuBarItem:
if (!sz.isEmpty())
sz += QSize(windowsItemHMargin * 5 + 1, 6);
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index c76d3cb445..9337595ead 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -50,7 +50,10 @@
#include "qtoolbar.h"
#include <qapplication.h>
+#include <qmenu.h>
+#if QT_CONFIG(menubar)
#include <qmenubar.h>
+#endif
#if QT_CONFIG(statusbar)
#include <qstatusbar.h>
#endif
@@ -520,7 +523,7 @@ void QMainWindow::setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle)
emit toolButtonStyleChanged(d->toolButtonStyle);
}
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
/*!
Returns the menu bar for the main window. This function creates
and returns an empty menu bar if the menu bar does not exist.
@@ -607,7 +610,7 @@ void QMainWindow::setMenuWidget(QWidget *menuBar)
}
d->layout->setMenuBar(menuBar);
}
-#endif // QT_NO_MENUBAR
+#endif // QT_CONFIG(menubar)
#if QT_CONFIG(statusbar)
/*!
@@ -1663,7 +1666,7 @@ void QMainWindow::contextMenuEvent(QContextMenuEvent *event)
// children and for the menu bar as well
QWidget *child = childAt(event->pos());
while (child && child != this) {
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (QMenuBar *mb = qobject_cast<QMenuBar *>(child)) {
if (mb->parentWidget() != this)
return;
diff --git a/src/widgets/widgets/qmainwindow.h b/src/widgets/widgets/qmainwindow.h
index e0592d2c3f..ff489efa2d 100644
--- a/src/widgets/widgets/qmainwindow.h
+++ b/src/widgets/widgets/qmainwindow.h
@@ -123,7 +123,7 @@ public:
bool isSeparator(const QPoint &pos) const;
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
QMenuBar *menuBar() const;
void setMenuBar(QMenuBar *menubar);
diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp
index 513011f0ad..36b3828576 100644
--- a/src/widgets/widgets/qmdiarea.cpp
+++ b/src/widgets/widgets/qmdiarea.cpp
@@ -173,6 +173,7 @@
#include <QDesktopWidget>
#include <QDebug>
#include <qmath.h>
+#include <qmenu.h>
#include <private/qlayoutengine_p.h>
#include <algorithm>
diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp
index 663572802c..0abc4967e1 100644
--- a/src/widgets/widgets/qmdisubwindow.cpp
+++ b/src/widgets/widgets/qmdisubwindow.cpp
@@ -165,6 +165,7 @@
#endif
#include <QMdiArea>
#include <QScopedValueRollback>
+#include <QMenu>
QT_BEGIN_NAMESPACE
@@ -703,7 +704,7 @@ ControlContainer::ControlContainer(QMdiSubWindow *mdiChild)
: QObject(mdiChild),
previousLeft(0),
previousRight(0),
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
m_menuBar(0),
#endif
mdiChild(mdiChild)
@@ -725,7 +726,7 @@ ControlContainer::ControlContainer(QMdiSubWindow *mdiChild)
ControlContainer::~ControlContainer()
{
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
removeButtonsFromMenuBar();
#endif
delete m_menuLabel;
@@ -734,7 +735,7 @@ ControlContainer::~ControlContainer()
m_controllerWidget = 0;
}
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
/*
\internal
*/
@@ -846,7 +847,7 @@ void ControlContainer::removeButtonsFromMenuBar(QMenuBar *menuBar)
mdiChild->window()->setWindowTitle(mdiChild->d_func()->originalWindowTitle());
}
-#endif // QT_NO_MENUBAR
+#endif // QT_CONFIG(menubar)
void ControlContainer::updateWindowIcon(const QIcon &windowIcon)
{
@@ -1268,7 +1269,7 @@ void QMdiSubWindowPrivate::setNormalMode()
isMaximizeMode = false;
ensureWindowState(Qt::WindowNoState);
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
removeButtonsFromMenuBar();
#endif
@@ -1375,7 +1376,7 @@ void QMdiSubWindowPrivate::setMaximizeMode()
updateGeometryConstraints();
if (wasVisible) {
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (QMenuBar *mBar = menuBar())
showButtonsInMenuBar(mBar);
else
@@ -1438,7 +1439,7 @@ void QMdiSubWindowPrivate::setActive(bool activate, bool changeFocus)
Qt::WindowStates oldWindowState = q->windowState();
ensureWindowState(Qt::WindowActive);
emit q->aboutToActivate();
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (QMenuBar *mBar = menuBar())
showButtonsInMenuBar(mBar);
#endif
@@ -1783,7 +1784,7 @@ bool QMdiSubWindowPrivate::drawTitleBarWhenMaximized() const
#else
if (q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, q))
return true;
-#if defined(QT_NO_MENUBAR) || defined(QT_NO_MAINWINDOW)
+#if !QT_CONFIG(menubar) || defined(QT_NO_MAINWINDOW)
Q_UNUSED(isChildOfQMdiSubWindow);
return true;
#else
@@ -1797,7 +1798,7 @@ bool QMdiSubWindowPrivate::drawTitleBarWhenMaximized() const
#endif
}
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
/*!
\internal
@@ -1868,7 +1869,7 @@ void QMdiSubWindowPrivate::removeButtonsFromMenuBar()
originalTitle.clear();
}
-#endif // QT_NO_MENUBAR
+#endif // QT_CONFIG(menubar)
void QMdiSubWindowPrivate::updateWindowTitle(bool isRequestFromChild)
{
@@ -2295,7 +2296,7 @@ QMdiSubWindow::QMdiSubWindow(QWidget *parent, Qt::WindowFlags flags)
QMdiSubWindow::~QMdiSubWindow()
{
Q_D(QMdiSubWindow);
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
d->removeButtonsFromMenuBar();
#endif
d->setActive(false);
@@ -2628,7 +2629,7 @@ void QMdiSubWindow::showShaded()
d->ensureWindowState(Qt::WindowMinimized);
}
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
d->removeButtonsFromMenuBar();
#endif
@@ -2768,7 +2769,7 @@ bool QMdiSubWindow::eventFilter(QObject *object, QEvent *event)
if (object == d->baseWidget) {
d->updateWindowTitle(true);
d->lastChildWindowTitle = d->baseWidget->windowTitle();
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
} else if (maximizedButtonsWidget() && d->controlContainer->menuBar() && d->controlContainer->menuBar()
->cornerWidget(Qt::TopRightCorner) == maximizedButtonsWidget()) {
d->originalTitle.clear();
@@ -2831,7 +2832,7 @@ bool QMdiSubWindow::event(QEvent *event)
break;
case QEvent::ParentChange: {
bool wasResized = testAttribute(Qt::WA_Resized);
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
d->removeButtonsFromMenuBar();
#endif
d->currentOperation = QMdiSubWindowPrivate::None;
@@ -2888,12 +2889,12 @@ bool QMdiSubWindow::event(QEvent *event)
case QEvent::ModifiedChange:
if (!windowTitle().contains(QLatin1String("[*]")))
break;
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (maximizedButtonsWidget() && d->controlContainer->menuBar() && d->controlContainer->menuBar()
->cornerWidget(Qt::TopRightCorner) == maximizedButtonsWidget()) {
window()->setWindowModified(isWindowModified());
}
-#endif // QT_NO_MENUBAR
+#endif // QT_CONFIG(menubar)
d->updateInternalWindowTitle();
break;
case QEvent::LayoutDirectionChange:
@@ -2956,7 +2957,7 @@ void QMdiSubWindow::showEvent(QShowEvent *showEvent)
d->updateDirtyRegions();
// Show buttons in the menu bar if they're already not there.
// We want to do this when QMdiSubWindow becomes visible after being hidden.
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (d->controlContainer) {
if (QMenuBar *menuBar = d->menuBar()) {
if (menuBar->cornerWidget(Qt::TopRightCorner) != maximizedButtonsWidget())
@@ -2972,7 +2973,7 @@ void QMdiSubWindow::showEvent(QShowEvent *showEvent)
*/
void QMdiSubWindow::hideEvent(QHideEvent * /*hideEvent*/)
{
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
d_func()->removeButtonsFromMenuBar();
#endif
}
@@ -3046,7 +3047,7 @@ void QMdiSubWindow::closeEvent(QCloseEvent *closeEvent)
closeEvent->ignore();
return;
}
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
d->removeButtonsFromMenuBar();
#endif
d->setActive(false);
diff --git a/src/widgets/widgets/qmdisubwindow_p.h b/src/widgets/widgets/qmdisubwindow_p.h
index 71fcc38378..51652a78ff 100644
--- a/src/widgets/widgets/qmdisubwindow_p.h
+++ b/src/widgets/widgets/qmdisubwindow_p.h
@@ -58,7 +58,9 @@
#include <QStyle>
#include <QStyleOptionTitleBar>
+#if QT_CONFIG(menubar)
#include <QMenuBar>
+#endif
#include <QSizeGrip>
#include <QPointer>
#include <QDebug>
@@ -96,7 +98,7 @@ public:
ControlContainer(QMdiSubWindow *mdiChild);
~ControlContainer();
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
void showButtonsInMenuBar(QMenuBar *menuBar);
void removeButtonsFromMenuBar(QMenuBar *menuBar = 0);
QMenuBar *menuBar() const { return m_menuBar; }
@@ -108,7 +110,7 @@ public:
private:
QPointer<QWidget> previousLeft;
QPointer<QWidget> previousRight;
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
QPointer<QMenuBar> m_menuBar;
#endif
QPointer<QWidget> m_controllerWidget;
@@ -252,7 +254,7 @@ public:
int titleBarHeight(const QStyleOptionTitleBar &options) const;
void sizeParameters(int *margin, int *minWidth) const;
bool drawTitleBarWhenMaximized() const;
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
QMenuBar *menuBar() const;
void showButtonsInMenuBar(QMenuBar *menuBar);
void removeButtonsFromMenuBar();
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 9b2856a728..93ceca1095 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -64,7 +64,9 @@
#endif
#include "qmenu_p.h"
+#if QT_CONFIG(menubar)
#include "qmenubar_p.h"
+#endif
#include "qwidgetaction.h"
#if QT_CONFIG(toolbutton)
#include "qtoolbutton.h"
@@ -491,7 +493,7 @@ void QMenuPrivate::hideUpToMenuBar()
QWidget *caused = causedPopup.widget;
hideMenu(q); //hide after getting causedPopup
while(caused) {
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) {
mb->d_func()->setCurrentAction(0);
mb->d_func()->setKeyboardMode(false);
@@ -1273,7 +1275,7 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e)
bool passOnEvent = false;
QWidget *next_widget = 0;
QPoint cpos = caused->mapFromGlobal(e->globalPos());
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) {
passOnEvent = mb->rect().contains(cpos);
} else
@@ -1315,7 +1317,7 @@ void QMenuPrivate::activateCausedStack(const QVector<QPointer<QWidget> > &caused
} else if (action_e == QAction::Hover) {
emit qmenu->hovered(action);
}
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
} else if (QMenuBar *qmenubar = qobject_cast<QMenuBar*>(widget)) {
if (action_e == QAction::Trigger) {
emit qmenubar->triggered(action);
@@ -1410,7 +1412,7 @@ void QMenuPrivate::_q_actionTriggered()
QVector< QPointer<QWidget> > list;
for(QWidget *widget = q->parentWidget(); widget; ) {
if (qobject_cast<QMenu*>(widget)
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
|| qobject_cast<QMenuBar*>(widget)
#endif
) {
@@ -2310,7 +2312,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
d->doChildEffects = true;
d->updateLayoutDirection();
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
// if this menu is part of a chain attached to a QMenuBar, set the
// _NET_WM_WINDOW_TYPE_DROPDOWN_MENU X11 window type
setAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu, qobject_cast<QMenuBar *>(d->topCausedWidget()) != 0);
@@ -2406,11 +2408,11 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
if (snapToMouse) // position flowing left from the mouse
pos.setX(mouse.x() - size.width());
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
// if the menu is in a menubar or is a submenu, it should be right-aligned
if (qobject_cast<QMenuBar*>(d->causedPopup.widget) || qobject_cast<QMenu*>(d->causedPopup.widget))
pos.rx() -= size.width();
-#endif //QT_NO_MENUBAR
+#endif // QT_CONFIG(menubar)
if (pos.x() < screen.left() + desktopFrame)
pos.setX(qMax(p.x(), screen.left() + desktopFrame));
@@ -2486,7 +2488,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
hGuess = QEffects::LeftScroll;
}
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if ((snapToMouse && (pos.y() + size.height() / 2 < mouse.y())) ||
(qobject_cast<QMenuBar*>(d->causedPopup.widget) &&
pos.y() + size.width() / 2 < d->causedPopup.widget->mapToGlobal(d->causedPopup.widget->pos()).y()))
@@ -2494,7 +2496,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
#endif
if (QApplication::isEffectEnabled(Qt::UI_AnimateMenu)) {
bool doChildEffects = true;
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget)) {
doChildEffects = mb->d_func()->doChildEffects;
mb->d_func()->doChildEffects = false;
@@ -2656,7 +2658,7 @@ void QMenu::hideEvent(QHideEvent *)
QAccessibleEvent event(this, QAccessible::PopupMenuEnd);
QAccessible::updateAccessibility(&event);
#endif
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget))
mb->d_func()->setCurrentAction(0);
#endif
@@ -3204,7 +3206,7 @@ void QMenu::keyPressEvent(QKeyEvent *e)
if (style()->styleHint(QStyle::SH_MenuBar_AltKeyNavigation, 0, this))
{
d->hideMenu(this);
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (QMenuBar *mb = qobject_cast<QMenuBar*>(QApplication::focusWidget())) {
mb->d_func()->setKeyboardMode(false);
}
@@ -3266,7 +3268,7 @@ void QMenu::keyPressEvent(QKeyEvent *e)
{
QPointer<QWidget> caused = d->causedPopup.widget;
d->hideMenu(this); // hide after getting causedPopup
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (QMenuBar *mb = qobject_cast<QMenuBar*>(caused)) {
mb->d_func()->setCurrentAction(d->menuAction);
mb->d_func()->setKeyboardMode(true);
@@ -3343,7 +3345,7 @@ void QMenu::keyPressEvent(QKeyEvent *e)
}
}
if (!key_consumed) {
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->topCausedWidget())) {
QAction *oldAct = mb->d_func()->currentAction;
QApplication::sendEvent(mb, e);
diff --git a/src/widgets/widgets/qmenu_mac.mm b/src/widgets/widgets/qmenu_mac.mm
index f9f3ad08dc..65b7030e20 100644
--- a/src/widgets/widgets/qmenu_mac.mm
+++ b/src/widgets/widgets/qmenu_mac.mm
@@ -41,8 +41,10 @@
#import <AppKit/AppKit.h>
#include "qmenu.h"
+#if QT_CONFIG(menubar)
#include "qmenubar.h"
#include "qmenubar_p.h"
+#endif
#include "qmacnativewidget_mac.h"
#include <QtCore/QDebug>
@@ -139,7 +141,7 @@ void QMenuPrivate::moveWidgetToPlatformItem(QWidget *widget, QPlatformMenuItem*
#endif //QT_NO_MENU
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
/*!
\since 5.2
@@ -159,7 +161,7 @@ NSMenu *QMenuBar::toNSMenu()
}
return nil;
}
-#endif //QT_NO_MENUBAR
+#endif // QT_CONFIG(menubar)
QT_END_NAMESPACE
diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h
index 40cbb3b891..65975da984 100644
--- a/src/widgets/widgets/qmenu_p.h
+++ b/src/widgets/widgets/qmenu_p.h
@@ -52,7 +52,9 @@
//
#include <QtWidgets/private/qtwidgetsglobal_p.h>
+#if QT_CONFIG(menubar)
#include "QtWidgets/qmenubar.h"
+#endif
#include "QtWidgets/qstyleoption.h"
#include "QtCore/qdatetime.h"
#include "QtCore/qmap.h"
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index fd48058ec3..a78195d2aa 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -61,9 +61,6 @@
#include "private/qguiapplication_p.h"
#include "qpa/qplatformintegration.h"
-#ifndef QT_NO_MENUBAR
-
-
#include "qmenu_p.h"
#include "qmenubar_p.h"
#include "qdebug.h"
@@ -1874,9 +1871,6 @@ QPlatformMenuBar *QMenuBar::platformMenuBar()
// for private slots
-
QT_END_NAMESPACE
#include <moc_qmenubar.cpp>
-
-#endif // QT_NO_MENUBAR
diff --git a/src/widgets/widgets/qmenubar.h b/src/widgets/widgets/qmenubar.h
index 7ad205b77a..be70f4ea48 100644
--- a/src/widgets/widgets/qmenubar.h
+++ b/src/widgets/widgets/qmenubar.h
@@ -43,10 +43,9 @@
#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qmenu.h>
-QT_BEGIN_NAMESPACE
-
+QT_REQUIRE_CONFIG(menubar);
-#ifndef QT_NO_MENUBAR
+QT_BEGIN_NAMESPACE
class QMenuBarPrivate;
class QStyleOptionMenuItem;
@@ -140,8 +139,6 @@ private:
friend class QWindowsStyle;
};
-#endif // QT_NO_MENUBAR
-
QT_END_NAMESPACE
#endif // QMENUBAR_H
diff --git a/src/widgets/widgets/qmenubar_p.h b/src/widgets/widgets/qmenubar_p.h
index f5409b9762..01d8793a3a 100644
--- a/src/widgets/widgets/qmenubar_p.h
+++ b/src/widgets/widgets/qmenubar_p.h
@@ -56,9 +56,10 @@
#include <private/qmenu_p.h> // Mac needs what in this file!
#include <qpa/qplatformmenu.h>
+QT_REQUIRE_CONFIG(menubar);
+
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_MENUBAR
class QMenuBarExtension;
class QMenuBarPrivate : public QWidgetPrivate
{
@@ -136,8 +137,6 @@ public:
inline int indexOf(QAction *act) const { return q_func()->actions().indexOf(act); }
};
-#endif // QT_NO_MENUBAR
-
QT_END_NAMESPACE
#endif // QMENUBAR_P_H
diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp
index b5c2179bcc..663e8214c0 100644
--- a/src/widgets/widgets/qtoolbar.cpp
+++ b/src/widgets/widgets/qtoolbar.cpp
@@ -49,7 +49,9 @@
#include <qlayout.h>
#include <qmainwindow.h>
#include <qmenu.h>
+#if QT_CONFIG(menubar)
#include <qmenubar.h>
+#endif
#if QT_CONFIG(rubberband)
#include <qrubberband.h>
#endif
diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri
index a3f7061c4f..48d3dd96d5 100644
--- a/src/widgets/widgets/widgets.pri
+++ b/src/widgets/widgets/widgets.pri
@@ -19,8 +19,6 @@ HEADERS += \
widgets/qmdisubwindow_p.h \
widgets/qmenu.h \
widgets/qmenu_p.h \
- widgets/qmenubar.h \
- widgets/qmenubar_p.h \
widgets/qscrollarea_p.h \
widgets/qsizegrip.h \
widgets/qslider.h \
@@ -55,7 +53,6 @@ SOURCES += \
widgets/qmdiarea.cpp \
widgets/qmdisubwindow.cpp \
widgets/qmenu.cpp \
- widgets/qmenubar.cpp \
widgets/qsizegrip.cpp \
widgets/qslider.cpp \
widgets/qspinbox.cpp \
@@ -171,6 +168,14 @@ qtConfig(lcdnumber) {
widgets/qlcdnumber.cpp
}
+qtConfig(menubar) {
+ HEADERS += \
+ widgets/qmenubar.h \
+ widgets/qmenubar_p.h
+
+ SOURCES += widgets/qmenubar.cpp
+}
+
qtConfig(progressbar) {
HEADERS += widgets/qprogressbar.h
SOURCES += widgets/qprogressbar.cpp