Skip to content

Commit

Permalink
Convert features.menubar to QT_[REQUIRE_]CONFIG
Browse files Browse the repository at this point in the history
Change-Id: Idbd4978852fa280dd18a5684469d499da3892126
Reviewed-by: Oswald Buddenhagen <[email protected]>
  • Loading branch information
sbinner committed Sep 4, 2017
1 parent b649717 commit 314a591
Show file tree
Hide file tree
Showing 26 changed files with 114 additions and 88 deletions.
12 changes: 7 additions & 5 deletions src/widgets/accessible/qaccessiblemenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/accessible/qaccessiblemenu_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class QAccessibleMenu : public QAccessibleWidget
QMenu *menu() const;
};

#ifndef QT_NO_MENUBAR
#if QT_CONFIG(menubar)
class QAccessibleMenuBar : public QAccessibleWidget
{
public:
Expand All @@ -96,7 +96,7 @@ class QAccessibleMenuBar : public QAccessibleWidget
protected:
QMenuBar *menuBar() const;
};
#endif // QT_NO_MENUBAR
#endif // QT_CONFIG(menubar)


class QAccessibleMenuItem : public QAccessibleInterface, public QAccessibleActionInterface
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/accessible/qaccessiblewidgetfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 9 additions & 7 deletions src/widgets/kernel/qlayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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

Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/kernel/qlayoutitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 4 additions & 2 deletions src/widgets/kernel/qshortcut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/styles/qcommonstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/widgets/styles/qmacstyle_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/styles/qmacstyle_mac_p_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
6 changes: 4 additions & 2 deletions src/widgets/styles/qstylesheetstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 8 additions & 6 deletions src/widgets/styles/qwindowsstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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)) {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/styles/qwindowsvistastyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/styles/qwindowsxpstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 6 additions & 3 deletions src/widgets/widgets/qmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
/*!
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/widgets/qmainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class Q_WIDGETS_EXPORT QMainWindow : public QWidget

bool isSeparator(const QPoint &pos) const;

#ifndef QT_NO_MENUBAR
#if QT_CONFIG(menubar)
QMenuBar *menuBar() const;
void setMenuBar(QMenuBar *menubar);

Expand Down
Loading

0 comments on commit 314a591

Please sign in to comment.