diff options
author | Liang Qi <liang.qi@qt.io> | 2017-01-30 12:39:22 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-01-30 12:46:20 +0100 |
commit | 246799d8a7bf42c1f22fca7ef6d77e8d58054bad (patch) | |
tree | a0b92a804d7d2a30cd68fa327df5777d8bcc36ba /src/widgets/widgets | |
parent | 5ad191850becd7dc1d61d0975f141a5db64e6373 (diff) | |
parent | 02cc57f4edbae450ecfa8368052afa44f8aeee19 (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
examples/network/network-chat/peermanager.cpp
src/widgets/util/qsystemtrayicon.cpp
src/widgets/util/qsystemtrayicon_qpa.cpp
src/widgets/util/qsystemtrayicon_win.cpp
src/widgets/util/qsystemtrayicon_x11.cpp
Change-Id: I1c026df83818c0ccaf956980370e7522960627db
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r-- | src/widgets/widgets/qabstractscrollarea.cpp | 3 | ||||
-rw-r--r-- | src/widgets/widgets/qabstractspinbox.cpp | 6 | ||||
-rw-r--r-- | src/widgets/widgets/qabstractspinbox.h | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qdockarealayout.cpp | 8 | ||||
-rw-r--r-- | src/widgets/widgets/qkeysequenceedit.cpp | 32 | ||||
-rw-r--r-- | src/widgets/widgets/qlineedit.cpp | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qlineedit_p.cpp | 9 | ||||
-rw-r--r-- | src/widgets/widgets/qlineedit_p.h | 3 | ||||
-rw-r--r-- | src/widgets/widgets/qmaccocoaviewcontainer_mac.mm | 39 | ||||
-rw-r--r-- | src/widgets/widgets/qmacnativewidget_mac.mm | 8 | ||||
-rw-r--r-- | src/widgets/widgets/qmainwindowlayout.cpp | 67 | ||||
-rw-r--r-- | src/widgets/widgets/qmainwindowlayout_p.h | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qmdiarea.cpp | 5 |
13 files changed, 120 insertions, 66 deletions
diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp index aaf7e165cd..d091d1e970 100644 --- a/src/widgets/widgets/qabstractscrollarea.cpp +++ b/src/widgets/widgets/qabstractscrollarea.cpp @@ -473,6 +473,7 @@ void QAbstractScrollAreaPrivate::layoutChildren() // move the scrollbars away from top/left headers int vHeaderRight = 0; int hHeaderBottom = 0; +#if QT_CONFIG(itemviews) if ((vscrollOverlap > 0 && needv) || (hscrollOverlap > 0 && needh)) { const QList<QHeaderView *> headers = q->findChildren<QHeaderView*>(); if (headers.count() <= 2) { @@ -485,7 +486,7 @@ void QAbstractScrollAreaPrivate::layoutChildren() } } } - +#endif // QT_CONFIG(itemviews) if (needh) { QRect horizontalScrollBarRect(QPoint(controlsRect.left() + vHeaderRight, cornerPoint.y()), QPoint(cornerPoint.x() - 1, controlsRect.bottom())); #if 0 // Used to be included in Qt4 for Q_WS_MAC diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index c61bf4729a..6bcdc372ef 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -1246,11 +1246,9 @@ void QAbstractSpinBox::timerEvent(QTimerEvent *event) \reimp */ +#if QT_CONFIG(contextmenu) void QAbstractSpinBox::contextMenuEvent(QContextMenuEvent *event) { -#ifdef QT_NO_CONTEXTMENU - Q_UNUSED(event); -#else Q_D(QAbstractSpinBox); QPointer<QMenu> menu = d->edit->createStandardContextMenu(); @@ -1286,8 +1284,8 @@ void QAbstractSpinBox::contextMenuEvent(QContextMenuEvent *event) } } event->accept(); -#endif // QT_NO_CONTEXTMENU } +#endif // QT_CONFIG(contextmenu) /*! \reimp diff --git a/src/widgets/widgets/qabstractspinbox.h b/src/widgets/widgets/qabstractspinbox.h index ac46894a27..b60178b94c 100644 --- a/src/widgets/widgets/qabstractspinbox.h +++ b/src/widgets/widgets/qabstractspinbox.h @@ -142,7 +142,9 @@ protected: #endif void focusInEvent(QFocusEvent *event) override; void focusOutEvent(QFocusEvent *event) override; +#if QT_CONFIG(contextmenu) void contextMenuEvent(QContextMenuEvent *event) override; +#endif void changeEvent(QEvent *event) override; void closeEvent(QCloseEvent *event) override; void hideEvent(QHideEvent *event) override; diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index ad19e5d5f9..b33f2dc798 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -2092,7 +2092,7 @@ void QDockAreaLayoutInfo::reparentWidgets(QWidget *parent) const QDockAreaLayoutItem &item = item_list.at(i); if (item.flags & QDockAreaLayoutItem::GapItem) continue; - if (item.skip()) + if (!item.widgetItem && item.skip()) continue; if (item.subinfo) item.subinfo->reparentWidgets(parent); @@ -2608,7 +2608,9 @@ QLayoutItem *QDockAreaLayout::plug(const QList<int> &path) Q_ASSERT(!path.isEmpty()); const int index = path.first(); Q_ASSERT(index >= 0 && index < QInternal::DockCount); - return docks[index].plug(path.mid(1)); + QLayoutItem *item = docks[index].plug(path.mid(1)); + docks[index].reparentWidgets(mainWindow); + return item; } QLayoutItem *QDockAreaLayout::unplug(const QList<int> &path) @@ -3175,6 +3177,7 @@ void QDockAreaLayout::resizeDocks(const QList<QDockWidget *> &docks, while (path.size() > 1) { QDockAreaLayoutInfo *info = this->info(path); +#if QT_CONFIG(tabbar) if (!info->tabbed && info->o == o) { info->item_list[path.constLast()].size = size; int totalSize = 0; @@ -3187,6 +3190,7 @@ void QDockAreaLayout::resizeDocks(const QList<QDockWidget *> &docks, } size = totalSize; } +#endif // QT_CONFIG(tabbar) path.removeLast(); } diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp index 3252ce5941..4d86c7cfc7 100644 --- a/src/widgets/widgets/qkeysequenceedit.cpp +++ b/src/widgets/widgets/qkeysequenceedit.cpp @@ -43,6 +43,7 @@ #include "qboxlayout.h" #include "qlineedit.h" +#include <private/qkeymapper_p.h> QT_BEGIN_NAMESPACE @@ -80,15 +81,8 @@ void QKeySequenceEditPrivate::init() int QKeySequenceEditPrivate::translateModifiers(Qt::KeyboardModifiers state, const QString &text) { + Q_UNUSED(text); int result = 0; - // The shift modifier only counts when it is not used to type a symbol - // that is only reachable using the shift key anyway - if ((state & Qt::ShiftModifier) && (text.isEmpty() || - !text.at(0).isPrint() || - text.at(0).isLetterOrNumber() || - text.at(0).isSpace())) - result |= Qt::SHIFT; - if (state & Qt::ControlModifier) result |= Qt::CTRL; if (state & Qt::MetaModifier) @@ -272,7 +266,27 @@ void QKeySequenceEdit::keyPressEvent(QKeyEvent *e) if (d->keyNum >= QKeySequencePrivate::MaxKeyCount) return; - nextKey |= d->translateModifiers(e->modifiers(), e->text()); + if (e->modifiers() & Qt::ShiftModifier) { + QList<int> possibleKeys = QKeyMapper::possibleKeys(e); + int pkTotal = possibleKeys.count(); + if (!pkTotal) + return; + bool found = false; + for (int i = 0; i < possibleKeys.size(); ++i) { + if (possibleKeys.at(i) - nextKey == int(e->modifiers()) + || (possibleKeys.at(i) == nextKey && e->modifiers() == Qt::ShiftModifier)) { + nextKey = possibleKeys.at(i); + found = true; + break; + } + } + // Use as fallback + if (!found) + nextKey = possibleKeys.first(); + } else { + nextKey |= d->translateModifiers(e->modifiers(), e->text()); + } + d->key[d->keyNum] = nextKey; d->keyNum++; diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 6d49b29fb9..fb0ffd6083 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -2195,10 +2195,12 @@ void QLineEdit::changeEvent(QEvent *ev) update(); break; case QEvent::LayoutDirectionChange: +#if QT_CONFIG(toolbutton) for (const auto &e : d->trailingSideWidgets) { // Refresh icon to show arrow in right direction. if (e.flags & QLineEditPrivate::SideWidgetClearButton) static_cast<QLineEditIconButton *>(e.widget)->setIcon(d->clearButtonIcon()); } +#endif d->positionSideWidgets(); break; default: diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 7da1d911ee..9947d63279 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -313,6 +313,8 @@ void QLineEditPrivate::drag() #endif // QT_NO_DRAGANDDROP + +#if QT_CONFIG(toolbutton) QLineEditIconButton::QLineEditIconButton(QWidget *parent) : QToolButton(parent) , m_opacity(0) @@ -390,6 +392,7 @@ void QLineEditIconButton::updateCursor() setCursor(qFuzzyCompare(m_opacity, qreal(1.0)) || !parentWidget() ? QCursor(Qt::ArrowCursor) : parentWidget()->cursor()); #endif } +#endif // QT_CONFIG(toolbutton) void QLineEditPrivate::_q_textChanged(const QString &text) { @@ -397,7 +400,7 @@ void QLineEditPrivate::_q_textChanged(const QString &text) const int newTextSize = text.size(); if (!newTextSize || !lastTextSize) { lastTextSize = newTextSize; -#ifndef QT_NO_ANIMATION +#if QT_CONFIG(animation) && QT_CONFIG(toolbutton) const bool fadeIn = newTextSize > 0; for (const SideWidgetEntry &e : leadingSideWidgets) { if (e.flags & SideWidgetFadeInWithText) @@ -507,6 +510,7 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE flags |= SideWidgetCreatedByWidgetAction; } if (!w) { +#if QT_CONFIG(toolbutton) QLineEditIconButton *toolButton = new QLineEditIconButton(q); toolButton->setIcon(newAction->icon()); toolButton->setOpacity(lastTextSize > 0 || !(flags & SideWidgetFadeInWithText) ? 1 : 0); @@ -514,6 +518,9 @@ QWidget *QLineEditPrivate::addAction(QAction *newAction, QAction *before, QLineE QObject::connect(toolButton, SIGNAL(clicked()), q, SLOT(_q_clearButtonClicked())); toolButton->setDefaultAction(newAction); w = toolButton; +#else + return nullptr; +#endif } // If there is a 'before' action, it takes preference PositionIndexPair positionIndex = before ? findSideWidget(before) : PositionIndexPair(position, -1); diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h index 0a08aefab3..a903c003e6 100644 --- a/src/widgets/widgets/qlineedit_p.h +++ b/src/widgets/widgets/qlineedit_p.h @@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE class QLineEditPrivate; // QLineEditIconButton: This is a simple helper class that represents clickable icons that fade in with text - +#if QT_CONFIG(toolbutton) class Q_AUTOTEST_EXPORT QLineEditIconButton : public QToolButton { Q_OBJECT @@ -103,6 +103,7 @@ private: qreal m_opacity; }; +#endif // QT_CONFIG(toolbutton) class Q_AUTOTEST_EXPORT QLineEditPrivate : public QWidgetPrivate { diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm index b4f2b8959e..8e565ecfe0 100644 --- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm +++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm @@ -56,27 +56,21 @@ \inmodule QtWidgets While Qt offers a lot of classes for writing your application, Apple's - Cocoa framework offers lots of functionality that is not currently in Qt or - may never end up in Qt. Using QMacCocoaViewContainer, it is possible to put an - arbitrary NSView-derived class from Cocoa and put it in a Qt hierarchy. - Depending on how comfortable you are with using objective-C, you can use - QMacCocoaViewContainer directly, or subclass it to wrap further functionality - of the underlying NSView. - - QMacCocoaViewContainer works regardless if Qt is built against Carbon or - Cocoa. However, QCocoaContainerView requires \macos 10.5 or better to be - used with Carbon. - - It should be also noted that at the low level on \macos, there is a - difference between windows (top-levels) and view (widgets that are inside a - window). For this reason, make sure that the NSView that you are wrapping - doesn't end up as a top-level. The best way to ensure this is to make sure - you always have a parent and not set the parent to 0. - - If you are using QMacCocoaViewContainer as a sub-class and are mixing and - matching objective-C with C++ (a.k.a. objective-C++). It is probably - simpler to have your file end with \tt{.mm} than \tt{.cpp}. Most Apple tools will - correctly identify the source as objective-C++. + Cocoa frameworks offer functionality that is not currently available (or + may never end up) in Qt. Using QMacCocoaViewContainer, it is possible to take an + arbitrary NSView-derived class from Cocoa and put it in a Qt widgets hierarchy. + Depending on the level of integration you need, you can use QMacCocoaViewContainer + directly or subclass it to wrap more functionality of the underlying NSView. + + It should be also noted that, at the Cocoa level, there is a difference + between top-level windows and views (widgets that are inside a window). + For this reason, make sure that the NSView that you are wrapping doesn't + end up as a top-level window. The best way to ensure this is to make sure + QMacCocoaViewContainer's parent widget is not null. + + If you are using QMacCocoaViewContainer as a subclass and are accessing Cocoa API, + it is probably simpler to have your file end with \tt{.mm} instead of \tt{.cpp}. + Most Apple tools will correctly identify the source as Objective-C++. QMacCocoaViewContainer requires knowledge of how Cocoa works, especially in regard to its reference counting (retain/release) nature. It is noted in @@ -85,7 +79,8 @@ pool. If this is done outside of a running event loop, it is up to the developer to provide the autorelease pool. - The following is a snippet of subclassing QMacCocoaViewContainer to wrap a NSSearchField. + The following is a snippet showing how to subclass QMacCocoaViewContainer + to wrap an NSSearchField. \snippet macmainwindow.mm 0 */ diff --git a/src/widgets/widgets/qmacnativewidget_mac.mm b/src/widgets/widgets/qmacnativewidget_mac.mm index 936bd35187..9ad8aa1305 100644 --- a/src/widgets/widgets/qmacnativewidget_mac.mm +++ b/src/widgets/widgets/qmacnativewidget_mac.mm @@ -65,15 +65,11 @@ but it cannot be shown on its own. It needs to be put into a window when it is created or later through a native call. - QMacNativeWidget works for either Carbon or Cocoa depending on how Qt was configured. If Qt is - using Carbon, QMacNativeWidget will embed into Carbon hierarchies. If Qt is - using Cocoa, QMacNativeWidget embeds into Cocoa hierarchies. - - Here is an example of putting a QPushButton into a NSWindow: + Here is an example showing how to put a QPushButton into a NSWindow: \snippet qmacnativewidget/main.mm 0 - Note that QMacNativeWidget requires knowledge of Carbon or Cocoa. All it + Note that QMacNativeWidget requires knowledge of Cocoa. All it does is get the Qt hierarchy into a window not owned by Qt. It is then up to the programmer to ensure it is placed correctly in the window and responds correctly to events. diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 14d7f3d835..72e06e4efa 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -125,8 +125,11 @@ static void dumpLayout(QTextStream &qout, const QDockAreaLayoutInfo &layout, QSt << layout.rect.height() << " min size: " << minSize.width() << ',' << minSize.height() << " orient:" << layout.o +#if QT_CONFIG(tabbar) << " tabbed:" << layout.tabbed - << " tbshape:" << layout.tabBarShape << '\n'; + << " tbshape:" << layout.tabBarShape +#endif + << '\n'; indent += QLatin1String(" "); @@ -226,7 +229,9 @@ public: if (li->isEmpty()) return; int fw = frameWidth(); +#if QT_CONFIG(tabbar) li->reparentWidgets(parentWidget()); +#endif li->rect = r.adjusted(fw, fw, -fw, -fw); li->fitItems(); li->apply(false); @@ -317,6 +322,7 @@ QDockWidget *QDockWidgetGroupWindow::topDockWidget() const { QDockAreaLayoutInfo *info = layoutInfo(); QDockWidget *dw = 0; +#if QT_CONFIG(tabbar) if (info->tabBar && info->tabBar->currentIndex() >= 0) { int i = info->tabIndexToListIndex(info->tabBar->currentIndex()); if (i >= 0) { @@ -325,6 +331,7 @@ QDockWidget *QDockWidgetGroupWindow::topDockWidget() const dw = qobject_cast<QDockWidget *>(item.widgetItem->widget()); } } +#endif if (!dw) { for (int i = 0; !dw && i < info->item_list.count(); ++i) { const QDockAreaLayoutItem &item = info->item_list.at(i); @@ -373,8 +380,10 @@ void QDockWidgetGroupWindow::destroyOrHideIfEmpty() if (!wasHidden) dw->show(); } +#if QT_CONFIG(tabbar) foreach (QTabBar *tb, findChildren<QTabBar *>(QString(), Qt::FindDirectChildrenOnly)) tb->setParent(parentWidget()); +#endif deleteLater(); } @@ -1021,7 +1030,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream, } } break; -#ifndef QT_NO_TABBAR +#if QT_CONFIG(tabwidget) case QDockAreaLayout::FloatingDockWidgetTabMarker: { auto dockWidgets = allMyDockWidgets(mainWindow); @@ -1045,7 +1054,7 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream, floatingTab->show(); } break; -#endif // QT_NO_TABBAR +#endif // QT_CONFIG(tabwidget) #endif // QT_NO_DOCKWIDGET #ifndef QT_NO_TOOLBAR @@ -1802,10 +1811,10 @@ bool QMainWindowLayout::endSeparatorMove(const QPoint&) void QMainWindowLayout::raise(QDockWidget *widget) { +#ifndef QT_NO_TABBAR QDockAreaLayoutInfo *info = dockInfo(widget); if (info == 0) return; -#ifndef QT_NO_TABBAR if (!info->tabbed) return; info->setCurrentTab(widget); @@ -2012,7 +2021,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem) dwgw->layoutInfo()->remove(path); } currentGapRect = QRect(); - +#if QT_CONFIG(tabwidget) if (QDockWidget *dropTo = qobject_cast<QDockWidget*>(currentHoveredFloat)) { //dropping to a normal widget, we mutate it in a QDockWidgetGroupWindow with two tabs QDockWidgetGroupWindow *floatingTabs = createTabbedDockWindow(); @@ -2030,7 +2039,8 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem) dropTo->d_func()->plug(QRect()); currentHoveredFloat = floatingTabs; } - +#endif // QT_CONFIG(tabwidget) +#if QT_CONFIG(tabbar) QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(currentHoveredFloat); Q_ASSERT(dwgw); Q_ASSERT(dwgw->layoutInfo()->tabbed); // because floating group should always be tabbed @@ -2042,6 +2052,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem) globalRect.moveTopLeft(dwgw->mapToGlobal(globalRect.topLeft())); pluggingWidget = widget; widgetAnimator.animate(widget, globalRect, dockOptions & QMainWindow::AnimatedDocks); +#endif // QT_CONFIG(tabbar) return true; } #endif @@ -2120,7 +2131,9 @@ void QMainWindowLayout::animationFinished(QWidget *widget) if (QDockWidgetGroupWindow *dropTo = qobject_cast<QDockWidgetGroupWindow *>(currentHoveredFloat)) { parentInfo = dropTo->layoutInfo(); +#if QT_CONFIG(tabbar) Q_ASSERT(parentInfo->tabbed); +#endif path = parentInfo->indexOf(widget); Q_ASSERT(path.size() == 1); } else { @@ -2129,7 +2142,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget) parentInfo = layoutState.dockAreaLayout.info(path); Q_ASSERT(parentInfo); } - +#if QT_CONFIG(tabbar) if (parentInfo->tabbed) { // merge the two tab widgets int idx = path.constLast(); @@ -2143,15 +2156,19 @@ void QMainWindowLayout::animationFinished(QWidget *widget) parentInfo->reparentWidgets(currentHoveredFloat ? currentHoveredFloat.data() : parentWidget()); parentInfo->updateTabBar(); parentInfo->setCurrentTabId(currentId); - } else { + } else +#endif // QT_CONFIG(tabbar) + { QDockAreaLayoutItem &item = layoutState.dockAreaLayout.item(path); Q_ASSERT(item.widgetItem->widget() == dwgw); delete item.widgetItem; item.widgetItem = 0; item.subinfo = new QDockAreaLayoutInfo(qMove(*info)); *info = QDockAreaLayoutInfo(); +#if QT_CONFIG(tabbar) item.subinfo->reparentWidgets(parentWidget()); item.subinfo->setTabBarShape(parentInfo->tabBarShape); +#endif } dwgw->destroyOrHideIfEmpty(); } @@ -2172,7 +2189,9 @@ void QMainWindowLayout::animationFinished(QWidget *widget) savedState.clear(); currentGapPos.clear(); pluggingWidget = 0; - currentHoveredFloat = Q_NULLPTR; +#if QT_CONFIG(dockwidget) + currentHoveredFloat = nullptr; +#endif //applying the state will make sure that the currentGap is updated correctly //and all the geometries (especially the one from the central widget) is correct layoutState.apply(false); @@ -2360,7 +2379,7 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group) if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget)) { Q_ASSERT(path.constFirst() == 1); bool actualGroup = false; -#ifndef QT_NO_TABBAR +#if QT_CONFIG(tabwidget) if (group && (dockOptions & QMainWindow::GroupedDragging) && path.size() > 3) { QDockAreaLayoutItem &parentItem = layoutState.dockAreaLayout.item(path.mid(1, path.size() - 2)); if (parentItem.subinfo && parentItem.subinfo->tabbed) { @@ -2381,7 +2400,7 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group) savedState = layoutState; } } -#endif // QT_NO_TABBAR +#endif // QT_CONFIG(tabwidget) if (!actualGroup) { dw->d_func()->unplug(r); } @@ -2408,8 +2427,16 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group) void QMainWindowLayout::updateGapIndicator() { #ifndef QT_NO_RUBBERBAND - if ((!widgetAnimator.animating() && !currentGapPos.isEmpty()) || currentHoveredFloat) { - QWidget *expectedParent = currentHoveredFloat ? currentHoveredFloat.data() : parentWidget(); + if ((!widgetAnimator.animating() && !currentGapPos.isEmpty()) +#if QT_CONFIG(dockwidget) + || currentHoveredFloat +#endif + ) { + QWidget *expectedParent = +#if QT_CONFIG(dockwidget) + currentHoveredFloat ? currentHoveredFloat.data() : +#endif + parentWidget(); if (!gapIndicator) { gapIndicator = new QRubberBand(QRubberBand::Rectangle, expectedParent); // For accessibility to identify this special widget. @@ -2417,7 +2444,11 @@ void QMainWindowLayout::updateGapIndicator() } else if (gapIndicator->parent() != expectedParent) { gapIndicator->setParent(expectedParent); } - gapIndicator->setGeometry(currentHoveredFloat ? currentHoveredFloat->rect() : currentGapRect); + gapIndicator->setGeometry( +#if QT_CONFIG(dockwidget) + currentHoveredFloat ? currentHoveredFloat->rect() : +#endif + currentGapRect); gapIndicator->show(); gapIndicator->raise(); } else if (gapIndicator) { @@ -2540,17 +2571,18 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) updateGapIndicator(); } +#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) QDockWidgetGroupWindow *QMainWindowLayout::createTabbedDockWindow() { QDockWidgetGroupWindow* f = new QDockWidgetGroupWindow(parentWidget(), Qt::Tool); new QDockWidgetGroupLayout(f); return f; } +#endif void QMainWindowLayout::applyState(QMainWindowLayoutState &newState, bool animate) { -#ifndef QT_NO_DOCKWIDGET -#ifndef QT_NO_TABBAR +#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) QSet<QTabBar*> used = newState.dockAreaLayout.usedTabBars(); foreach (QDockWidgetGroupWindow *dwgw, parent()->findChildren<QDockWidgetGroupWindow*>(QString(), Qt::FindDirectChildrenOnly)) { @@ -2578,8 +2610,7 @@ void QMainWindowLayout::applyState(QMainWindowLayoutState &newState, bool animat for (int i = 0; i < QInternal::DockCount; ++i) newState.dockAreaLayout.docks[i].reparentWidgets(parentWidget()); -#endif // QT_NO_TABBAR -#endif // QT_NO_DOCKWIDGET +#endif // QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) newState.apply(dockOptions & QMainWindow::AnimatedDocks && animate); } diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index 40336caeba..857a05eb8e 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -231,9 +231,9 @@ public: void raise(QDockWidget *widget); void setVerticalTabsEnabled(bool enabled); bool restoreDockWidget(QDockWidget *dockwidget); - QDockAreaLayoutInfo *dockInfo(QWidget *w); #ifndef QT_NO_TABBAR + QDockAreaLayoutInfo *dockInfo(QWidget *w); bool _documentMode; bool documentMode() const; void setDocumentMode(bool enabled); diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp index 9b39743281..18cb823702 100644 --- a/src/widgets/widgets/qmdiarea.cpp +++ b/src/widgets/widgets/qmdiarea.cpp @@ -1533,20 +1533,23 @@ void QMdiAreaPrivate::highlightNextSubWindow(int increaseFactor) Q_ASSERT(indexToHighlighted >= 0); } +#if QT_CONFIG(rubberband) void QMdiAreaPrivate::showRubberBandFor(QMdiSubWindow *subWindow) { if (!subWindow || !rubberBand) return; +#if QT_CONFIG(tabbar) if (viewMode == QMdiArea::TabbedView) rubberBand->setGeometry(tabBar->tabRect(childWindows.indexOf(subWindow))); else +#endif rubberBand->setGeometry(subWindow->geometry()); rubberBand->raise(); rubberBand->show(); } - +#endif // QT_CONFIG(rubberBand) /*! \internal \since 4.4 |