Fix build without feature.tabbar
Change-Id: I0891f8f6054382407f5ce2fdb3ead0203d255945 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
parent
b727d2f0e1
commit
377ffbd21d
@ -278,6 +278,7 @@ static const qreal titleBarButtonSpacing = 8;
|
||||
// hovered: tab is hovered
|
||||
bool isDarkMode() { return qt_mac_applicationIsInDarkMode(); }
|
||||
|
||||
#if QT_CONFIG(tabbar)
|
||||
static const QColor lightTabBarTabBackgroundActive(190, 190, 190);
|
||||
static const QColor darkTabBarTabBackgroundActive(38, 38, 38);
|
||||
static const QColor tabBarTabBackgroundActive() { return isDarkMode() ? darkTabBarTabBackgroundActive : lightTabBarTabBackgroundActive; }
|
||||
@ -323,6 +324,7 @@ static const QColor tabBarCloseButtonCrossSelected(115, 115, 115);
|
||||
|
||||
static const int closeButtonSize = 14;
|
||||
static const qreal closeButtonCornerRadius = 2.0;
|
||||
#endif // QT_CONFIG(tabbar)
|
||||
|
||||
static const int headerSectionArrowHeight = 6;
|
||||
static const int headerSectionSeparatorInset = 2;
|
||||
@ -467,6 +469,7 @@ static bool isInMacUnifiedToolbarArea(QWindow *window, int windowY)
|
||||
}
|
||||
|
||||
|
||||
#if QT_CONFIG(tabbar)
|
||||
static void drawTabCloseButton(QPainter *p, bool hover, bool selected, bool pressed, bool documentMode)
|
||||
{
|
||||
p->setRenderHints(QPainter::Antialiasing);
|
||||
@ -504,7 +507,6 @@ static void drawTabCloseButton(QPainter *p, bool hover, bool selected, bool pres
|
||||
p->drawLine(margin, height - margin, width - margin, margin);
|
||||
}
|
||||
|
||||
#if QT_CONFIG(tabbar)
|
||||
QRect rotateTabPainter(QPainter *p, QTabBar::Shape shape, QRect tabRect)
|
||||
{
|
||||
const auto tabDirection = QMacStylePrivate::tabDirection(shape);
|
||||
@ -2131,10 +2133,12 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
|
||||
int ret = 0;
|
||||
|
||||
switch (metric) {
|
||||
#if QT_CONFIG(tabbar)
|
||||
case PM_TabCloseIndicatorWidth:
|
||||
case PM_TabCloseIndicatorHeight:
|
||||
ret = closeButtonSize;
|
||||
break;
|
||||
#endif
|
||||
case PM_ToolBarIconSize:
|
||||
ret = proxy()->pixelMetric(PM_LargeIconSize);
|
||||
break;
|
||||
@ -2291,10 +2295,12 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
|
||||
ret = 16;
|
||||
break;
|
||||
case QStyleHelper::SizeDefault:
|
||||
#if QT_CONFIG(tabbar)
|
||||
const QStyleOptionTab *tb = qstyleoption_cast<const QStyleOptionTab *>(opt);
|
||||
if (tb && tb->documentMode)
|
||||
ret = 30;
|
||||
else
|
||||
#endif
|
||||
ret = QCommonStyle::pixelMetric(metric, opt, widget);
|
||||
break;
|
||||
}
|
||||
@ -3319,6 +3325,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
|
||||
} break;
|
||||
case PE_FrameStatusBarItem:
|
||||
break;
|
||||
#if QT_CONFIG(tabbar)
|
||||
case PE_IndicatorTabClose: {
|
||||
// Make close button visible only on the hovered tab.
|
||||
QTabBar *tabBar = qobject_cast<QTabBar*>(w->parentWidget());
|
||||
@ -3343,6 +3350,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
|
||||
}
|
||||
}
|
||||
} break;
|
||||
#endif // QT_CONFIG(tabbar)
|
||||
case PE_PanelStatusBar: {
|
||||
// Fill the status bar with the titlebar gradient.
|
||||
QLinearGradient linearGrad;
|
||||
|
@ -1678,12 +1678,9 @@ int QDockAreaLayoutInfo::prev(int index) const
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if QT_CONFIG(tabbar)
|
||||
void QDockAreaLayoutInfo::tab(int index, QLayoutItem *dockWidgetItem)
|
||||
{
|
||||
#if !QT_CONFIG(tabbar)
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(dockWidgetItem);
|
||||
#else
|
||||
if (tabbed) {
|
||||
item_list.append(QDockAreaLayoutItem(dockWidgetItem));
|
||||
updateTabBar();
|
||||
@ -1699,8 +1696,8 @@ void QDockAreaLayoutInfo::tab(int index, QLayoutItem *dockWidgetItem)
|
||||
new_info->updateTabBar();
|
||||
new_info->setCurrentTab(dockWidgetItem->widget());
|
||||
}
|
||||
#endif // QT_CONFIG(tabbar)
|
||||
}
|
||||
#endif // QT_CONFIG(tabbar)
|
||||
|
||||
void QDockAreaLayoutInfo::split(int index, Qt::Orientation orientation,
|
||||
QLayoutItem *dockWidgetItem)
|
||||
@ -3137,6 +3134,7 @@ void QDockAreaLayout::addDockWidget(QInternal::DockPosition pos, QDockWidget *do
|
||||
removePlaceHolder(dockWidget->objectName());
|
||||
}
|
||||
|
||||
#if QT_CONFIG(tabbar)
|
||||
void QDockAreaLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second)
|
||||
{
|
||||
const QList<int> path = indexOf(first);
|
||||
@ -3149,6 +3147,7 @@ void QDockAreaLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second)
|
||||
|
||||
removePlaceHolder(second->objectName());
|
||||
}
|
||||
#endif // QT_CONFIG(tabbar)
|
||||
|
||||
void QDockAreaLayout::resizeDocks(const QList<QDockWidget *> &docks,
|
||||
const QList<int> &sizes, Qt::Orientation o)
|
||||
|
@ -144,7 +144,9 @@ public:
|
||||
void remove(const QList<int> &path);
|
||||
void unnest(int index);
|
||||
void split(int index, Qt::Orientation orientation, QLayoutItem *dockWidgetItem);
|
||||
#if QT_CONFIG(tabbar)
|
||||
void tab(int index, QLayoutItem *dockWidgetItem);
|
||||
#endif
|
||||
QDockAreaLayoutItem &item(const QList<int> &path);
|
||||
QDockAreaLayoutInfo *info(const QList<int> &path);
|
||||
QDockAreaLayoutInfo *info(QWidget *widget);
|
||||
@ -275,7 +277,9 @@ public:
|
||||
bool restoreDockWidget(QDockWidget *dockWidget);
|
||||
void splitDockWidget(QDockWidget *after, QDockWidget *dockWidget,
|
||||
Qt::Orientation orientation);
|
||||
#if QT_CONFIG(tabbar)
|
||||
void tabifyDockWidget(QDockWidget *first, QDockWidget *second);
|
||||
#endif
|
||||
void resizeDocks(const QList<QDockWidget *> &docks, const QList<int> &sizes, Qt::Orientation o);
|
||||
|
||||
void apply(bool animate);
|
||||
|
@ -267,9 +267,11 @@ QDockWidgetLayout::~QDockWidgetLayout()
|
||||
bool QDockWidgetLayout::nativeWindowDeco() const
|
||||
{
|
||||
bool floating = parentWidget()->isWindow();
|
||||
#if QT_CONFIG(tabbar)
|
||||
if (auto groupWindow =
|
||||
qobject_cast<const QDockWidgetGroupWindow *>(parentWidget()->parentWidget()))
|
||||
floating = floating || groupWindow->tabLayoutInfo();
|
||||
#endif
|
||||
return nativeWindowDeco(floating);
|
||||
}
|
||||
|
||||
@ -1556,8 +1558,10 @@ bool QDockWidget::event(QEvent *event)
|
||||
const QObjectList &siblings = win->children();
|
||||
onTop = siblings.count() > 0 && siblings.last() == (QObject*)this;
|
||||
}
|
||||
#if QT_CONFIG(tabbar)
|
||||
if (!isFloating() && layout != 0 && onTop)
|
||||
layout->raise(this);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case QEvent::WindowActivate:
|
||||
|
@ -1138,6 +1138,7 @@ void QMainWindow::splitDockWidget(QDockWidget *after, QDockWidget *dockwidget,
|
||||
d_func()->layout->splitDockWidget(after, dockwidget, orientation);
|
||||
}
|
||||
|
||||
#if QT_CONFIG(tabbar)
|
||||
/*!
|
||||
\fn void QMainWindow::tabifyDockWidget(QDockWidget *first, QDockWidget *second)
|
||||
|
||||
@ -1164,9 +1165,6 @@ void QMainWindow::tabifyDockWidget(QDockWidget *first, QDockWidget *second)
|
||||
QList<QDockWidget*> QMainWindow::tabifiedDockWidgets(QDockWidget *dockwidget) const
|
||||
{
|
||||
QList<QDockWidget*> ret;
|
||||
#if !QT_CONFIG(tabbar)
|
||||
Q_UNUSED(dockwidget);
|
||||
#else
|
||||
const QDockAreaLayoutInfo *info = d_func()->layout->layoutState.dockAreaLayout.info(dockwidget);
|
||||
if (info && info->tabbed && info->tabBar) {
|
||||
for(int i = 0; i < info->item_list.count(); ++i) {
|
||||
@ -1180,9 +1178,9 @@ QList<QDockWidget*> QMainWindow::tabifiedDockWidgets(QDockWidget *dockwidget) co
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
#endif // QT_CONFIG(tabbar)
|
||||
|
||||
|
||||
/*!
|
||||
|
@ -171,8 +171,10 @@ public:
|
||||
Qt::Orientation orientation);
|
||||
void splitDockWidget(QDockWidget *after, QDockWidget *dockwidget,
|
||||
Qt::Orientation orientation);
|
||||
#if QT_CONFIG(tabbar)
|
||||
void tabifyDockWidget(QDockWidget *first, QDockWidget *second);
|
||||
QList<QDockWidget*> tabifiedDockWidgets(QDockWidget *dockwidget) const;
|
||||
#endif
|
||||
void removeDockWidget(QDockWidget *dockwidget);
|
||||
bool restoreDockWidget(QDockWidget *dockwidget);
|
||||
|
||||
|
@ -292,25 +292,31 @@ bool QDockWidgetGroupWindow::event(QEvent *e)
|
||||
|
||||
switch (e->type()) {
|
||||
case QEvent::Close:
|
||||
#if QT_CONFIG(tabbar)
|
||||
// Forward the close to the QDockWidget just as if its close button was pressed
|
||||
if (QDockWidget *dw = activeTabbedDockWidget()) {
|
||||
e->ignore();
|
||||
dw->close();
|
||||
adjustFlags();
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
case QEvent::Move:
|
||||
#if QT_CONFIG(tabbar)
|
||||
// Let QDockWidgetPrivate::moseEvent handle the dragging
|
||||
if (QDockWidget *dw = activeTabbedDockWidget())
|
||||
static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(dw))->moveEvent(static_cast<QMoveEvent*>(e));
|
||||
#endif
|
||||
return true;
|
||||
case QEvent::NonClientAreaMouseMove:
|
||||
case QEvent::NonClientAreaMouseButtonPress:
|
||||
case QEvent::NonClientAreaMouseButtonRelease:
|
||||
case QEvent::NonClientAreaMouseButtonDblClick:
|
||||
#if QT_CONFIG(tabbar)
|
||||
// Let the QDockWidgetPrivate of the currently visible dock widget handle the drag and drop
|
||||
if (QDockWidget *dw = activeTabbedDockWidget())
|
||||
static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(dw))->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(e));
|
||||
#endif
|
||||
return true;
|
||||
case QEvent::ChildAdded:
|
||||
if (qobject_cast<QDockWidget *>(static_cast<QChildEvent*>(e)->child()))
|
||||
@ -347,6 +353,7 @@ QDockAreaLayoutInfo *QDockWidgetGroupWindow::layoutInfo() const
|
||||
return static_cast<QDockWidgetGroupLayout *>(layout())->dockAreaLayoutInfo();
|
||||
}
|
||||
|
||||
#if QT_CONFIG(tabbar)
|
||||
/*! \internal
|
||||
If this is a floating tab bar returns the currently the QDockWidgetGroupWindow that contains
|
||||
tab, otherwise, return nullptr;
|
||||
@ -383,7 +390,6 @@ const QDockAreaLayoutInfo *QDockWidgetGroupWindow::tabLayoutInfo() const
|
||||
QDockWidget *QDockWidgetGroupWindow::activeTabbedDockWidget() const
|
||||
{
|
||||
QDockWidget *dw = nullptr;
|
||||
#if QT_CONFIG(tabbar)
|
||||
const QDockAreaLayoutInfo *info = tabLayoutInfo();
|
||||
if (!info)
|
||||
return nullptr;
|
||||
@ -405,9 +411,9 @@ QDockWidget *QDockWidgetGroupWindow::activeTabbedDockWidget() const
|
||||
dw = qobject_cast<QDockWidget *>(item.widgetItem->widget());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return dw;
|
||||
}
|
||||
#endif // QT_CONFIG(tabbar)
|
||||
|
||||
/*! \internal
|
||||
Destroy or hide this window if there is no more QDockWidget in it.
|
||||
@ -461,7 +467,11 @@ void QDockWidgetGroupWindow::adjustFlags()
|
||||
Qt::WindowFlags oldFlags = windowFlags();
|
||||
Qt::WindowFlags flags = oldFlags;
|
||||
|
||||
#if QT_CONFIG(tabbar)
|
||||
QDockWidget *top = activeTabbedDockWidget();
|
||||
#else
|
||||
QDockWidget *top = nullptr;
|
||||
#endif
|
||||
if (!top) { // nested tabs, show window decoration
|
||||
flags =
|
||||
((oldFlags & ~Qt::FramelessWindowHint) | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
|
||||
@ -507,6 +517,7 @@ void QDockWidgetGroupWindow::adjustFlags()
|
||||
|
||||
bool QDockWidgetGroupWindow::hasNativeDecos() const
|
||||
{
|
||||
#if QT_CONFIG(tabbar)
|
||||
QDockWidget *dw = activeTabbedDockWidget();
|
||||
if (!dw) // We have a group of nested QDockWidgets (not just floating tabs)
|
||||
return true;
|
||||
@ -515,6 +526,9 @@ bool QDockWidgetGroupWindow::hasNativeDecos() const
|
||||
return false;
|
||||
|
||||
return dw->titleBarWidget() == nullptr;
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@ -531,16 +545,18 @@ bool QDockWidgetGroupWindow::hover(QLayoutItem *widgetItem, const QPoint &mouseP
|
||||
savedState = *layoutInfo();
|
||||
|
||||
QMainWindow::DockOptions opts = static_cast<QMainWindow *>(parentWidget())->dockOptions();
|
||||
QDockAreaLayoutInfo newState = savedState;
|
||||
bool nestingEnabled =
|
||||
(opts & QMainWindow::AllowNestedDocks) && !(opts & QMainWindow::ForceTabbedDocks);
|
||||
QDockAreaLayoutInfo::TabMode tabMode =
|
||||
#if !QT_CONFIG(tabbar)
|
||||
QDockAreaLayoutInfo::NoTabs;
|
||||
#else
|
||||
nestingEnabled ? QDockAreaLayoutInfo::AllowTabs : QDockAreaLayoutInfo::ForceTabs;
|
||||
if (auto group = qobject_cast<QDockWidgetGroupWindow *>(widgetItem->widget())) {
|
||||
if (!group->tabLayoutInfo())
|
||||
tabMode = QDockAreaLayoutInfo::NoTabs;
|
||||
}
|
||||
|
||||
QDockAreaLayoutInfo newState = savedState;
|
||||
if (newState.tabbed) {
|
||||
// insertion into a top-level tab
|
||||
newState.item_list = { QDockAreaLayoutItem(new QDockAreaLayoutInfo(newState)) };
|
||||
@ -548,6 +564,7 @@ bool QDockWidgetGroupWindow::hover(QLayoutItem *widgetItem, const QPoint &mouseP
|
||||
newState.tabbed = false;
|
||||
newState.tabBar = nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
auto newGapPos = newState.gapIndex(mousePos, nestingEnabled, tabMode);
|
||||
Q_ASSERT(!newGapPos.isEmpty());
|
||||
@ -1498,14 +1515,6 @@ void QMainWindowLayout::addDockWidget(Qt::DockWidgetArea area,
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void QMainWindowLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second)
|
||||
{
|
||||
addChildWidget(second);
|
||||
layoutState.dockAreaLayout.tabifyDockWidget(first, second);
|
||||
emit second->dockLocationChanged(dockWidgetArea(first));
|
||||
invalidate();
|
||||
}
|
||||
|
||||
bool QMainWindowLayout::restoreDockWidget(QDockWidget *dockwidget)
|
||||
{
|
||||
addChildWidget(dockwidget);
|
||||
@ -1517,6 +1526,14 @@ bool QMainWindowLayout::restoreDockWidget(QDockWidget *dockwidget)
|
||||
}
|
||||
|
||||
#if QT_CONFIG(tabbar)
|
||||
void QMainWindowLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second)
|
||||
{
|
||||
addChildWidget(second);
|
||||
layoutState.dockAreaLayout.tabifyDockWidget(first, second);
|
||||
emit second->dockLocationChanged(dockWidgetArea(first));
|
||||
invalidate();
|
||||
}
|
||||
|
||||
bool QMainWindowLayout::documentMode() const
|
||||
{
|
||||
return _documentMode;
|
||||
@ -1535,20 +1552,15 @@ void QMainWindowLayout::setDocumentMode(bool enabled)
|
||||
for (QTabBar *bar : qAsConst(unusedTabBars))
|
||||
bar->setDocumentMode(_documentMode);
|
||||
}
|
||||
#endif // QT_CONFIG(tabbar)
|
||||
|
||||
void QMainWindowLayout::setVerticalTabsEnabled(bool enabled)
|
||||
{
|
||||
#if !QT_CONFIG(tabbar)
|
||||
Q_UNUSED(enabled);
|
||||
#else
|
||||
if (verticalTabsEnabled == enabled)
|
||||
return;
|
||||
|
||||
verticalTabsEnabled = enabled;
|
||||
|
||||
updateTabBarShapes();
|
||||
#endif // QT_CONFIG(tabbar)
|
||||
}
|
||||
|
||||
#if QT_CONFIG(tabwidget)
|
||||
@ -1609,7 +1621,6 @@ static inline QTabBar::Shape tabBarShapeFrom(QTabWidget::TabShape shape, QTabWid
|
||||
}
|
||||
#endif // QT_CONFIG(tabwidget)
|
||||
|
||||
#if QT_CONFIG(tabbar)
|
||||
void QMainWindowLayout::updateTabBarShapes()
|
||||
{
|
||||
#if QT_CONFIG(tabwidget)
|
||||
@ -1851,19 +1862,17 @@ void QMainWindowLayout::tabMoved(int from, int to)
|
||||
|
||||
info->moveTab(from, to);
|
||||
}
|
||||
#endif // QT_CONFIG(tabbar)
|
||||
|
||||
void QMainWindowLayout::raise(QDockWidget *widget)
|
||||
{
|
||||
#if QT_CONFIG(tabbar)
|
||||
QDockAreaLayoutInfo *info = dockInfo(widget);
|
||||
if (info == 0)
|
||||
return;
|
||||
if (!info->tabbed)
|
||||
return;
|
||||
info->setCurrentTab(widget);
|
||||
#endif
|
||||
}
|
||||
#endif // QT_CONFIG(tabbar)
|
||||
|
||||
#endif // QT_CONFIG(dockwidget)
|
||||
|
||||
@ -2329,7 +2338,7 @@ void QMainWindowLayout::setDockOptions(QMainWindow::DockOptions opts)
|
||||
|
||||
dockOptions = opts;
|
||||
|
||||
#if QT_CONFIG(dockwidget)
|
||||
#if QT_CONFIG(dockwidget) && QT_CONFIG(tabbar)
|
||||
setVerticalTabsEnabled(opts & QMainWindow::VerticalTabs);
|
||||
#endif
|
||||
|
||||
|
@ -337,8 +337,10 @@ public:
|
||||
explicit QDockWidgetGroupWindow(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr)
|
||||
: QWidget(parent, f) {}
|
||||
QDockAreaLayoutInfo *layoutInfo() const;
|
||||
#if QT_CONFIG(tabbar)
|
||||
const QDockAreaLayoutInfo *tabLayoutInfo() const;
|
||||
QDockWidget *activeTabbedDockWidget() const;
|
||||
#endif
|
||||
void destroyOrHideIfEmpty();
|
||||
void adjustFlags();
|
||||
bool hasNativeDecos() const;
|
||||
@ -494,13 +496,13 @@ public:
|
||||
void splitDockWidget(QDockWidget *after,
|
||||
QDockWidget *dockwidget,
|
||||
Qt::Orientation orientation);
|
||||
void tabifyDockWidget(QDockWidget *first, QDockWidget *second);
|
||||
Qt::DockWidgetArea dockWidgetArea(QWidget* widget) const;
|
||||
bool restoreDockWidget(QDockWidget *dockwidget);
|
||||
#if QT_CONFIG(tabbar)
|
||||
void tabifyDockWidget(QDockWidget *first, QDockWidget *second);
|
||||
void raise(QDockWidget *widget);
|
||||
void setVerticalTabsEnabled(bool enabled);
|
||||
bool restoreDockWidget(QDockWidget *dockwidget);
|
||||
|
||||
#if QT_CONFIG(tabbar)
|
||||
QDockAreaLayoutInfo *dockInfo(QWidget *w);
|
||||
bool _documentMode;
|
||||
bool documentMode() const;
|
||||
|
Loading…
Reference in New Issue
Block a user