summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-01-24 10:33:37 +0100
committerOswald Buddenhagen <oswald.buddenhagen@qt.io>2017-01-25 20:06:06 +0100
commit318b58562ae89453fb98e8145cd0440e14ba60b0 (patch)
tree622bc032cf076b4569621032f3a3315d95c3ae88 /src/widgets
parentc28fde3fdac19fd5a5f614bb7983080031c924b3 (diff)
parent79352528a1726b4551ea4d9285dd2394dd0d43da (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts: .qmake.conf mkspecs/common/msvc-desktop.conf mkspecs/common/msvc-version.conf mkspecs/common/winrt_winphone/qmake.conf mkspecs/features/mac/default_post.prf mkspecs/features/mac/sdk.prf mkspecs/features/qt.prf mkspecs/features/uikit/default_post.prf mkspecs/features/winrt/default_pre.prf mkspecs/winphone-arm-msvc2013/qmake.conf mkspecs/winphone-x86-msvc2013/qmake.conf mkspecs/winrt-arm-msvc2013/qmake.conf mkspecs/winrt-x64-msvc2013/qmake.conf mkspecs/winrt-x86-msvc2013/qmake.conf qmake/generators/win32/msvc_vcproj.cpp src/gui/kernel/qwindowsysteminterface.cpp src/network/kernel/qhostaddress.cpp src/plugins/platforms/mirclient/qmirclientplugin.cpp src/plugins/platforms/mirclient/qmirclientplugin.h src/widgets/util/qsystemtrayicon.cpp tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp tools/configure/Makefile.mingw tools/configure/Makefile.win32 Done-with: Jake Petroules <jake.petroules@qt.io> Done-with: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Change-Id: I4be3262d3994e11929d3b1ded2c3379783797dbe
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/configure.json1
-rw-r--r--src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp2
-rw-r--r--src/widgets/doc/src/model-view-programming.qdoc19
-rw-r--r--src/widgets/doc/src/modelview.qdoc2
-rw-r--r--src/widgets/itemviews/qheaderview.cpp14
-rw-r--r--src/widgets/itemviews/qlistview.cpp2
-rw-r--r--src/widgets/kernel/qapplication.cpp12
-rw-r--r--src/widgets/kernel/qshortcut.cpp8
-rw-r--r--src/widgets/kernel/qwidget.cpp8
-rw-r--r--src/widgets/styles/qandroidstyle.cpp9
-rw-r--r--src/widgets/styles/qfusionstyle.cpp14
-rw-r--r--src/widgets/styles/qpixmapstyle.cpp11
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp4
-rw-r--r--src/widgets/styles/qwindowsvistastyle.cpp3
-rw-r--r--src/widgets/util/qsystemtrayicon.cpp5
-rw-r--r--src/widgets/util/qundostack.cpp2
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp10
-rw-r--r--src/widgets/widgets/qdockarealayout_p.h1
-rw-r--r--src/widgets/widgets/qkeysequenceedit.cpp3
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp11
-rw-r--r--src/widgets/widgets/qmenu.cpp2
-rw-r--r--src/widgets/widgets/qmenubar.cpp13
-rw-r--r--src/widgets/widgets/qprogressbar.cpp18
23 files changed, 121 insertions, 53 deletions
diff --git a/src/widgets/configure.json b/src/widgets/configure.json
index 1e72b61886..8acbffef6a 100644
--- a/src/widgets/configure.json
+++ b/src/widgets/configure.json
@@ -86,6 +86,7 @@
"label": "QFileSystemModel",
"purpose": "Provides a data model for the local filesystem.",
"section": "File I/O",
+ "condition": "features.itemmodel",
"output": [ "publicFeature", "feature" ]
},
"itemviews": {
diff --git a/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp b/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp
index 284a4ce404..7d003e4886 100644
--- a/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp
+++ b/src/widgets/doc/snippets/code/src_gui_util_qcompleter.cpp
@@ -62,7 +62,7 @@ lineEdit->setCompleter(completer);
//! [1]
QCompleter *completer = new QCompleter(this);
-completer->setModel(new QDirModel(completer));
+completer->setModel(new QFileSystemModel(completer));
lineEdit->setCompleter(completer);
//! [1]
diff --git a/src/widgets/doc/src/model-view-programming.qdoc b/src/widgets/doc/src/model-view-programming.qdoc
index e727d7fe56..84819e8c1a 100644
--- a/src/widgets/doc/src/model-view-programming.qdoc
+++ b/src/widgets/doc/src/model-view-programming.qdoc
@@ -2070,9 +2070,22 @@
Normally, the begin and end functions are capable of informing other components
about changes to the model's underlying structure. For more complex changes to the
- model's structure, perhaps involving internal reorganization or sorting of data,
- it is necessary to emit the \l{QAbstractItemModel::layoutChanged()}{layoutChanged()}
- signal to cause any attached views to be updated.
+ model's structure, perhaps involving internal reorganization, sorting of data or
+ any other structural change, it is necessary to perform the following sequence:
+
+ \li Emit the \l{QAbstractItemModel::layoutAboutToBeChanged()}{layoutAboutToBeChanged()} signal
+ \li Update internal data which represents the structure of the model.
+ \li Update persistent indexes using \l{QAbstractItemModel::changePersistentIndexList()}{changePersistentIndexList()}
+ \li Emit the \l{QAbstractItemModel::layoutChanged()}{layoutChanged()} signal.
+
+ This sequence can be used for any structural update in lieu of the more
+ high-level and convenient protected methods. For example, if a model of
+ two million rows needs to have all odd numbered rows removed, that
+ is 1 million discountiguous ranges of 1 element each. It would be
+ possible to use beginRemoveRows and endRemoveRows 1 million times, but
+ that would obviously be inefficient. Instead, this can be signalled as a
+ single layout change which updates all necessary persistent indexes at
+ once.
\section3 Lazy population of model data
diff --git a/src/widgets/doc/src/modelview.qdoc b/src/widgets/doc/src/modelview.qdoc
index 4a53ea5cbd..1c0bb5195a 100644
--- a/src/widgets/doc/src/modelview.qdoc
+++ b/src/widgets/doc/src/modelview.qdoc
@@ -83,7 +83,7 @@
Model/View is a technology used to separate data from views in widgets that
handle data sets. Standard widgets are not designed for separating data
- from views and this is why Qt 4 has two different types of widgets. Both
+ from views and this is why Qt has two different types of widgets. Both
types of widgets look the same, but they interact with data differently.
\table
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index 837383f016..1310a060ea 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -3857,6 +3857,20 @@ bool QHeaderViewPrivate::read(QDataStream &in)
if (sectionItemsLengthTotal != lengthIn)
return false;
+ const int currentCount = (orient == Qt::Horizontal ? model->columnCount(root) : model->rowCount(root));
+ if (newSectionItems.count() < currentCount) {
+ // we have sections not in the saved state, give them default settings
+ for (int i = newSectionItems.count(); i < currentCount; ++i) {
+ visualIndicesIn.append(i);
+ logicalIndicesIn.append(i);
+ }
+ const int insertCount = currentCount - newSectionItems.count();
+ const int insertLength = defaultSectionSizeIn * insertCount;
+ lengthIn += insertLength;
+ SectionItem section(defaultSectionSizeIn, globalResizeMode);
+ newSectionItems.insert(newSectionItems.count(), insertCount, section); // append
+ }
+
orientation = static_cast<Qt::Orientation>(orient);
sortIndicatorOrder = static_cast<Qt::SortOrder>(order);
sortIndicatorSection = sortIndicatorSectionIn;
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index 2f1f699bca..45c547d313 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -2370,7 +2370,7 @@ QListViewItem QListModeViewBase::indexToListViewItem(const QModelIndex &index) c
{
if (flowPositions.isEmpty()
|| segmentPositions.isEmpty()
- || index.row() >= flowPositions.count())
+ || index.row() >= flowPositions.count() - 1)
return QListViewItem();
const int segment = qBinarySearch<int>(segmentStartRows, index.row(),
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 6258605a65..c6d59907a0 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -3290,7 +3290,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
QWheelEvent we(relpos, wheel->globalPos(), wheel->pixelDelta(), wheel->angleDelta(), wheel->delta(), wheel->orientation(), wheel->buttons(),
wheel->modifiers(), phase, wheel->source(), wheel->inverted());
bool eventAccepted;
- while (w) {
+ do {
we.spont = spontaneous && w == receiver;
we.ignore();
res = d->notify_helper(w, &we);
@@ -3308,7 +3308,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
we.p += w->pos();
w = w->parentWidget();
- }
+ } while (w);
wheel->setAccepted(eventAccepted);
} else if (!spontaneous) {
// wheel_widget may forward the wheel event to a delegate widget,
@@ -4482,9 +4482,13 @@ void QApplicationPrivate::notifyThemeChanged()
#ifndef QT_NO_DRAGANDDROP
void QApplicationPrivate::notifyDragStarted(const QDrag *drag)
{
- // Prevent pickMouseReceiver() from using the widget where the drag was started after a drag operation.
QGuiApplicationPrivate::notifyDragStarted(drag);
- qt_button_down = 0;
+ // QTBUG-26145
+ // Prevent pickMouseReceiver() from using the widget where the drag was started after a drag operation...
+ // QTBUG-56713
+ // ...only if qt_button_down is not a QQuickWidget
+ if (qt_button_down && !qt_button_down->inherits("QQuickWidget"))
+ qt_button_down = nullptr;
}
#endif // QT_NO_DRAGANDDROP
diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp
index 6eec5ff7e8..be5788274e 100644
--- a/src/widgets/kernel/qshortcut.cpp
+++ b/src/widgets/kernel/qshortcut.cpp
@@ -141,9 +141,11 @@ bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context)
static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidget *active_window)
{
bool visible = w->isVisible();
-#if defined(Q_OS_DARWIN) && !defined(QT_NO_MENUBAR)
- if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast<QMenuBar *>(w))
- visible = true;
+#ifndef QT_NO_MENUBAR
+ if (QMenuBar *menuBar = qobject_cast<QMenuBar *>(w)) {
+ if (menuBar->isNativeMenuBar())
+ visible = true;
+ }
#endif
if (!visible || !w->isEnabled())
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 61956b3fa4..759821a057 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -2526,10 +2526,6 @@ QWidget *QWidget::find(WId id)
If a widget is non-native (alien) and winId() is invoked on it, that widget
will be provided a native handle.
- On \macos, the type returned depends on which framework Qt was linked
- against. If Qt is using Carbon, the {WId} is actually an HIViewRef. If Qt
- is using Cocoa, {WId} is a pointer to an NSView.
-
This value may change at run-time. An event with type QEvent::WinIdChange
will be sent to the widget following a change in window system identifier.
@@ -9988,8 +9984,8 @@ bool QWidget::nativeEvent(const QByteArray &eventType, void *message, long *resu
}
/*!
- Ensures that the widget has been polished by QStyle (i.e., has a
- proper font and palette).
+ Ensures that the widget and its children have been polished by
+ QStyle (i.e., have a proper font and palette).
QWidget calls this function after it has been fully constructed
but before it is shown the very first time. You can call this
diff --git a/src/widgets/styles/qandroidstyle.cpp b/src/widgets/styles/qandroidstyle.cpp
index b37dffbe80..110153d0f6 100644
--- a/src/widgets/styles/qandroidstyle.cpp
+++ b/src/widgets/styles/qandroidstyle.cpp
@@ -1606,15 +1606,14 @@ void QAndroidStyle::AndroidProgressBarControl::drawControl(const QStyleOption *o
if (!m_progressDrawable)
return;
- if (const QStyleOptionProgressBar *progressBarOption =
- qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
+ if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
if (m_progressDrawable->type() == QAndroidStyle::Layer) {
- const double fraction = progressBarOption->progress / double(progressBarOption->maximum - progressBarOption->minimum);
+ const double fraction = double(qint64(pb->progress) - pb->minimum) / (qint64(pb->maximum) - pb->minimum);
QAndroidStyle::AndroidDrawable *clipDrawable = static_cast<QAndroidStyle::AndroidLayerDrawable *>(m_progressDrawable)->layer(m_progressId);
if (clipDrawable->type() == QAndroidStyle::Clip)
- static_cast<AndroidClipDrawable *>(clipDrawable)->setFactor(fraction, progressBarOption->orientation);
+ static_cast<AndroidClipDrawable *>(clipDrawable)->setFactor(fraction, pb->orientation);
else
- static_cast<AndroidLayerDrawable *>(m_progressDrawable)->setFactor(m_progressId, fraction, progressBarOption->orientation);
+ static_cast<AndroidLayerDrawable *>(m_progressDrawable)->setFactor(m_progressId, fraction, pb->orientation);
}
m_progressDrawable->draw(p, option);
}
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index 70af751fd3..54cc82bea9 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -1352,10 +1352,11 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
}
int maxWidth = rect.width();
- int minWidth = 0;
- qreal progress = qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar
- int progressBarWidth = (progress - bar->minimum) * qreal(maxWidth) / qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum);
- int width = indeterminate ? maxWidth : qMax(minWidth, progressBarWidth);
+ const auto progress = qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar
+ const auto totalSteps = qMax(Q_INT64_C(1), qint64(bar->maximum) - bar->minimum);
+ const auto progressSteps = qint64(progress) - bar->minimum;
+ const auto progressBarWidth = progressSteps * maxWidth / totalSteps;
+ int width = indeterminate ? maxWidth : progressBarWidth;
bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical;
if (inverted)
@@ -1450,8 +1451,9 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
inverted = bar->invertedAppearance;
if (vertical)
rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
- const int progressIndicatorPos = (bar->progress - qreal(bar->minimum)) * rect.width() /
- qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum);
+ const auto totalSteps = qMax(Q_INT64_C(1), qint64(bar->maximum) - bar->minimum);
+ const auto progressSteps = qint64(bar->progress) - bar->minimum;
+ const auto progressIndicatorPos = progressSteps * rect.width() / totalSteps;
if (progressIndicatorPos >= 0 && progressIndicatorPos <= rect.width())
leftRect = QRect(rect.left(), rect.top(), progressIndicatorPos, rect.height());
if (vertical)
diff --git a/src/widgets/styles/qpixmapstyle.cpp b/src/widgets/styles/qpixmapstyle.cpp
index e973a96a91..ce37065fb6 100644
--- a/src/widgets/styles/qpixmapstyle.cpp
+++ b/src/widgets/styles/qpixmapstyle.cpp
@@ -819,11 +819,14 @@ void QPixmapStyle::drawProgressBarFill(const QStyleOption *option,
drawCachedPixmap(vertical ? PB_VComplete : PB_HComplete, option->rect, painter);
} else {
- if (pbar->progress == 0)
+ if (pbar->progress == pbar->minimum)
return;
- const int maximum = pbar->maximum;
- const qreal ratio = qreal(vertical?option->rect.height():option->rect.width())/maximum;
- const int progress = pbar->progress*ratio;
+ const auto totalSteps = qint64(pbar->maximum) - pbar->minimum;
+ const auto progressSteps = qint64(pbar->progress) - pbar->minimum;
+ const auto availablePixels = vertical ? option->rect.height() : option->rect.width();
+ const auto pixelsPerStep = double(availablePixels) / totalSteps;
+
+ const auto progress = static_cast<int>(progressSteps * pixelsPerStep); // width in pixels
QRect optRect = option->rect;
if (vertical) {
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index d63c96bf0e..68ee8c22d3 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -3903,8 +3903,8 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
if (inverted)
reverse = !reverse;
const bool indeterminate = pb->minimum == pb->maximum;
- qreal fillRatio = indeterminate ? 0.50 : qreal(progress - minimum)/(maximum - minimum);
- int fillWidth = int(rect.width() * fillRatio);
+ const auto fillRatio = indeterminate ? 0.50 : double(progress - minimum) / (maximum - minimum);
+ const auto fillWidth = static_cast<int>(rect.width() * fillRatio);
int chunkWidth = fillWidth;
if (subRule.hasContentsSize()) {
QSize sz = subRule.size();
diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp
index d6a4016e4c..972deef150 100644
--- a/src/widgets/styles/qwindowsvistastyle.cpp
+++ b/src/widgets/styles/qwindowsvistastyle.cpp
@@ -1872,8 +1872,7 @@ QSize QWindowsVistaStyle::sizeFromContents(ContentsType type, const QStyleOption
case CT_MenuBarItem:
if (!sz.isEmpty())
sz += QSize(windowsItemHMargin * 5 + 1, 5);
- return sz;
- break;
+ return sz;
#endif
case CT_ItemViewItem:
sz = QWindowsXPStyle::sizeFromContents(type, option, size, widget);
diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp
index 64daad87ae..225c47052b 100644
--- a/src/widgets/util/qsystemtrayicon.cpp
+++ b/src/widgets/util/qsystemtrayicon.cpp
@@ -473,7 +473,10 @@ bool QBalloonTip::isBalloonVisible()
QBalloonTip::QBalloonTip(const QIcon &icon, const QString &title,
const QString &message, QSystemTrayIcon *ti)
- : QWidget(0, Qt::ToolTip), trayIcon(ti), timerId(-1)
+ : QWidget(0, Qt::ToolTip),
+ trayIcon(ti),
+ timerId(-1),
+ showArrow(true)
{
setAttribute(Qt::WA_DeleteOnClose);
QObject::connect(ti, SIGNAL(destroyed()), this, SLOT(close()));
diff --git a/src/widgets/util/qundostack.cpp b/src/widgets/util/qundostack.cpp
index cfca5787cb..3d21320655 100644
--- a/src/widgets/util/qundostack.cpp
+++ b/src/widgets/util/qundostack.cpp
@@ -724,10 +724,12 @@ void QUndoStack::setClean()
This method resets the clean index to -1.
This is typically called in the following cases, when a document has been:
+ \list
\li created basing on some template and has not been saved,
so no filename has been associated with the document yet.
\li restored from a backup file.
\li changed outside of the editor and the user did not reload it.
+ \endlist
\sa isClean(), setClean(), cleanIndex()
*/
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index 63f8172bf6..ad19e5d5f9 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())
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..3252ce5941 100644
--- a/src/widgets/widgets/qkeysequenceedit.cpp
+++ b/src/widgets/widgets/qkeysequenceedit.cpp
@@ -257,7 +257,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;
}
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index aef8b9cbd5..14d7f3d835 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -1030,12 +1030,19 @@ 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
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/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index ce43740524..2a76f1e8a0 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -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..64f19047b6 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;
}