summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qabstractscrollarea.cpp3
-rw-r--r--src/widgets/widgets/qabstractslider.cpp4
-rw-r--r--src/widgets/widgets/qabstractspinbox.cpp6
-rw-r--r--src/widgets/widgets/qabstractspinbox.h2
-rw-r--r--src/widgets/widgets/qcalendarwidget.cpp2
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp18
-rw-r--r--src/widgets/widgets/qdockarealayout_p.h1
-rw-r--r--src/widgets/widgets/qkeysequenceedit.cpp35
-rw-r--r--src/widgets/widgets/qlineedit.cpp2
-rw-r--r--src/widgets/widgets/qlineedit_p.cpp9
-rw-r--r--src/widgets/widgets/qlineedit_p.h3
-rw-r--r--src/widgets/widgets/qmaccocoaviewcontainer_mac.mm39
-rw-r--r--src/widgets/widgets/qmacnativewidget_mac.mm8
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp78
-rw-r--r--src/widgets/widgets/qmainwindowlayout_p.h2
-rw-r--r--src/widgets/widgets/qmdiarea.cpp5
-rw-r--r--src/widgets/widgets/qmenu.cpp2
-rw-r--r--src/widgets/widgets/qmenu.h8
-rw-r--r--src/widgets/widgets/qmenubar.cpp15
-rw-r--r--src/widgets/widgets/qprogressbar.cpp22
-rw-r--r--src/widgets/widgets/qsplitter.cpp4
-rw-r--r--src/widgets/widgets/qtoolbar.h8
22 files changed, 177 insertions, 99 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/qabstractslider.cpp b/src/widgets/widgets/qabstractslider.cpp
index cc6a407bf8..0ea9250695 100644
--- a/src/widgets/widgets/qabstractslider.cpp
+++ b/src/widgets/widgets/qabstractslider.cpp
@@ -303,9 +303,7 @@ void QAbstractSlider::setOrientation(Qt::Orientation orientation)
d->orientation = orientation;
if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) {
- QSizePolicy sp = sizePolicy();
- sp.transpose();
- setSizePolicy(sp);
+ setSizePolicy(sizePolicy().transposed());
setAttribute(Qt::WA_WState_OwnSizePolicy, false);
}
update();
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/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp
index b0ded70c4a..da4850a816 100644
--- a/src/widgets/widgets/qcalendarwidget.cpp
+++ b/src/widgets/widgets/qcalendarwidget.cpp
@@ -765,7 +765,7 @@ bool QCalendarTextNavigator::eventFilter(QObject *o, QEvent *e)
if (m_widget) {
if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) {
QKeyEvent* ke = (QKeyEvent*)e;
- if ((ke->text().length() > 0 && ke->text()[0].isPrint()) || m_dateFrame) {
+ if ((ke->text().length() > 0 && ke->text().at(0).isPrint()) || m_dateFrame) {
if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Select) {
applyDate();
emit editingFinished();
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index 63f8172bf6..b33f2dc798 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -266,6 +266,16 @@ bool QDockAreaLayoutInfo::isEmpty() const
return next(-1) == -1;
}
+bool QDockAreaLayoutInfo::onlyHasPlaceholders() const
+{
+ for (const QDockAreaLayoutItem &item : item_list) {
+ if (!item.placeHolderItem)
+ return false;
+ }
+
+ return true;
+}
+
QSize QDockAreaLayoutInfo::minimumSize() const
{
if (isEmpty())
@@ -2082,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);
@@ -2598,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)
@@ -3165,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;
@@ -3177,6 +3190,7 @@ void QDockAreaLayout::resizeDocks(const QList<QDockWidget *> &docks,
}
size = totalSize;
}
+#endif // QT_CONFIG(tabbar)
path.removeLast();
}
diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h
index f22a3d2de2..21787283f4 100644
--- a/src/widgets/widgets/qdockarealayout_p.h
+++ b/src/widgets/widgets/qdockarealayout_p.h
@@ -167,6 +167,7 @@ public:
void clear();
bool isEmpty() const;
+ bool onlyHasPlaceholders() const;
bool hasFixedSize() const;
QList<int> findSeparator(const QPoint &pos) const;
int next(int idx) const;
diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp
index 2fbc42330d..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)
@@ -257,7 +251,8 @@ void QKeySequenceEdit::keyPressEvent(QKeyEvent *e)
if (nextKey == Qt::Key_Control
|| nextKey == Qt::Key_Shift
|| nextKey == Qt::Key_Meta
- || nextKey == Qt::Key_Alt) {
+ || nextKey == Qt::Key_Alt
+ || nextKey == Qt::Key_unknown) {
return;
}
@@ -271,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 aef8b9cbd5..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);
@@ -1030,15 +1039,22 @@ bool QMainWindowLayoutState::restoreState(QDataStream &_stream,
Qt::Horizontal, QTabBar::RoundedSouth, mainWindow);
QRect geometry;
stream >> geometry;
- if (!floatingTab->layoutInfo()->restoreState(stream, dockWidgets, false))
+ QDockAreaLayoutInfo *info = floatingTab->layoutInfo();
+ if (!info->restoreState(stream, dockWidgets, false))
return false;
geometry = QDockAreaLayout::constrainedRect(geometry, floatingTab);
floatingTab->move(geometry.topLeft());
floatingTab->resize(geometry.size());
- floatingTab->show();
+
+ // Don't show an empty QDockWidgetGroupWindow if no dock widget is available yet.
+ // reparentWidgets() would be triggered by show(), so do it explicitly here.
+ if (info->onlyHasPlaceholders())
+ info->reparentWidgets(floatingTab);
+ else
+ floatingTab->show();
}
break;
-#endif // QT_NO_TABBAR
+#endif // QT_CONFIG(tabwidget)
#endif // QT_NO_DOCKWIDGET
#ifndef QT_NO_TOOLBAR
@@ -1795,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);
@@ -2005,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();
@@ -2023,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
@@ -2035,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
@@ -2113,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 {
@@ -2122,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();
@@ -2136,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();
}
@@ -2165,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);
@@ -2353,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) {
@@ -2374,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);
}
@@ -2401,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.
@@ -2410,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) {
@@ -2533,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)) {
@@ -2571,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
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 36a8a96b79..2917083415 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -1507,7 +1507,7 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action)
When inserting action items you usually specify a receiver and a
slot. The receiver will be notifed whenever the item is
\l{QAction::triggered()}{triggered()}. In addition, QMenu provides
- two signals, activated() and highlighted(), which signal the
+ two signals, triggered() and hovered(), which signal the
QAction that was triggered from the menu.
You clear a menu with clear() and remove individual action items
diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h
index 5d218ac1ba..e9a5db1112 100644
--- a/src/widgets/widgets/qmenu.h
+++ b/src/widgets/widgets/qmenu.h
@@ -98,8 +98,8 @@ public:
#else
// addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
template<class Obj, typename Func1>
- inline typename QtPrivate::QEnableIf<!std::is_same<const char*, Func1>::value
- && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type
+ inline typename std::enable_if<!std::is_same<const char*, Func1>::value
+ && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type
addAction(const QString &text, const Obj *object, Func1 slot, const QKeySequence &shortcut = 0)
{
QAction *result = addAction(text);
@@ -126,8 +126,8 @@ public:
}
// addAction(QIcon, QString): Connect to a QObject slot / functor or function pointer (with context)
template<class Obj, typename Func1>
- inline typename QtPrivate::QEnableIf<!std::is_same<const char*, Func1>::value
- && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type
+ inline typename std::enable_if<!std::is_same<const char*, Func1>::value
+ && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type
addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot, const QKeySequence &shortcut = 0)
{
QAction *result = addAction(actionIcon, text);
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index ce43740524..77ed7a4f78 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -1119,7 +1119,7 @@ void QMenuBar::keyPressEvent(QKeyEvent *e)
int clashCount = 0;
QAction *first = 0, *currentSelected = 0, *firstAfterCurrent = 0;
{
- QChar c = e->text()[0].toUpper();
+ const QChar c = e->text().at(0).toUpper();
for(int i = 0; i < d->actions.size(); ++i) {
if (d->actionRects.at(i).isNull())
continue;
@@ -1267,10 +1267,12 @@ void QMenuBar::actionEvent(QActionEvent *e)
} else if(e->type() == QEvent::ActionRemoved) {
e->action()->disconnect(this);
}
- if (isVisible()) {
+ // updateGeometries() is also needed for native menu bars because
+ // it updates shortcutIndexMap
+ if (isVisible() || isNativeMenuBar())
d->updateGeometries();
+ if (isVisible())
update();
- }
}
/*!
@@ -1683,6 +1685,13 @@ void QMenuBarPrivate::_q_internalShortcutActivated(int id)
{
Q_Q(QMenuBar);
QAction *act = actions.at(id);
+ if (act && act->menu()) {
+ if (QPlatformMenu *platformMenu = act->menu()->platformMenu()) {
+ platformMenu->showPopup(q->windowHandle(), actionRects.at(id), Q_NULLPTR);
+ return;
+ }
+ }
+
setCurrentAction(act, true, true);
if (act && !act->menu()) {
activateAction(act, QAction::Trigger);
diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp
index 10f005e6d3..2b228cdb2c 100644
--- a/src/widgets/widgets/qprogressbar.cpp
+++ b/src/widgets/widgets/qprogressbar.cpp
@@ -144,16 +144,17 @@ bool QProgressBarPrivate::repaintRequired() const
if (value == lastPaintedValue)
return false;
- int valueDifference = qAbs(value - lastPaintedValue);
-
+ const auto valueDifference = qAbs(qint64(value) - lastPaintedValue);
// Check if the text needs to be repainted
if (value == minimum || value == maximum)
return true;
+
+ const auto totalSteps = qint64(maximum) - minimum;
if (textVisible) {
if ((format.contains(QLatin1String("%v"))))
return true;
if ((format.contains(QLatin1String("%p"))
- && valueDifference >= qAbs((maximum - minimum) / 100)))
+ && valueDifference >= qAbs(totalSteps / 100)))
return true;
}
@@ -166,7 +167,7 @@ bool QProgressBarPrivate::repaintRequired() const
// (valueDifference / (maximum - minimum) > cw / groove.width())
// transformed to avoid integer division.
int grooveBlock = (q->orientation() == Qt::Horizontal) ? groove.width() : groove.height();
- return (valueDifference * grooveBlock > cw * (maximum - minimum));
+ return valueDifference * grooveBlock > cw * totalSteps;
}
/*!
@@ -260,9 +261,10 @@ QProgressBar::~QProgressBar()
void QProgressBar::reset()
{
Q_D(QProgressBar);
- d->value = d->minimum - 1;
if (d->minimum == INT_MIN)
d->value = INT_MIN;
+ else
+ d->value = d->minimum - 1;
repaint();
}
@@ -358,7 +360,7 @@ void QProgressBar::setRange(int minimum, int maximum)
d->minimum = minimum;
d->maximum = qMax(minimum, maximum);
- if (d->value < (d->minimum - 1) || d->value > d->maximum)
+ if (d->value < qint64(d->minimum) - 1 || d->value > d->maximum)
reset();
else
update();
@@ -479,11 +481,11 @@ QString QProgressBar::text() const
// progress bar has one step and that we are on that step. Return
// 100% here in order to avoid division by zero further down.
if (totalSteps == 0) {
- result.replace(QLatin1String("%p"), locale.toString(int(100)));
+ result.replace(QLatin1String("%p"), locale.toString(100));
return result;
}
- int progress = (qreal(d->value) - d->minimum) * 100.0 / totalSteps;
+ const auto progress = static_cast<int>((qint64(d->value) - d->minimum) * 100.0 / totalSteps);
result.replace(QLatin1String("%p"), locale.toString(progress));
return result;
}
@@ -506,9 +508,7 @@ void QProgressBar::setOrientation(Qt::Orientation orientation)
return;
d->orientation = orientation;
if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) {
- QSizePolicy sp = sizePolicy();
- sp.transpose();
- setSizePolicy(sp);
+ setSizePolicy(sizePolicy().transposed());
setAttribute(Qt::WA_WState_OwnSizePolicy, false);
}
d->resetLayoutItemMargins();
diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp
index e58fedba20..e6332293e4 100644
--- a/src/widgets/widgets/qsplitter.cpp
+++ b/src/widgets/widgets/qsplitter.cpp
@@ -1008,9 +1008,7 @@ void QSplitter::setOrientation(Qt::Orientation orientation)
return;
if (!testAttribute(Qt::WA_WState_OwnSizePolicy)) {
- QSizePolicy sp = sizePolicy();
- sp.transpose();
- setSizePolicy(sp);
+ setSizePolicy(sizePolicy().transposed());
setAttribute(Qt::WA_WState_OwnSizePolicy, false);
}
diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h
index 0ea4d4afeb..e0f2d9b073 100644
--- a/src/widgets/widgets/qtoolbar.h
+++ b/src/widgets/widgets/qtoolbar.h
@@ -116,8 +116,8 @@ public:
#else
// addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
template<class Obj, typename Func1>
- inline typename QtPrivate::QEnableIf<!std::is_same<const char*, Func1>::value
- && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type
+ inline typename std::enable_if<!std::is_same<const char*, Func1>::value
+ && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type
addAction(const QString &text, const Obj *object, Func1 slot)
{
QAction *result = addAction(text);
@@ -134,8 +134,8 @@ public:
}
// addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
template<class Obj, typename Func1>
- inline typename QtPrivate::QEnableIf<!std::is_same<const char*, Func1>::value
- && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::Type
+ inline typename std::enable_if<!std::is_same<const char*, Func1>::value
+ && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type
addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot)
{
QAction *result = addAction(actionIcon, text);