summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-05-27 09:16:56 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-05-27 09:17:14 +0200
commit761b71bd20524bc1e495508a52c38a0bc6679a06 (patch)
treedf2748fb11234c9b0dfb82828ce8d76459d185db /src/widgets
parent800941df899a4418d4ac6cebbcc31a40120167bc (diff)
parent14aa1f7d6ffea29647557f98e654355782f55e66 (diff)
Merge remote-tracking branch 'origin/5.12' into 5.13
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp3
-rw-r--r--src/widgets/doc/snippets/cmake-macros/examples.cmake5
-rw-r--r--src/widgets/doc/src/cmake-macros.qdoc60
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp4
-rw-r--r--src/widgets/kernel/qwidget.cpp9
-rw-r--r--src/widgets/kernel/qwidget_p.h2
-rw-r--r--src/widgets/util/qcompleter.cpp40
-rw-r--r--src/widgets/widgets/qmenu.cpp11
-rw-r--r--src/widgets/widgets/qwidgetresizehandler.cpp2
9 files changed, 120 insertions, 16 deletions
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
index c0bacd553d..8a1bd1431e 100644
--- a/src/widgets/dialogs/qcolordialog.cpp
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -1859,6 +1859,9 @@ void QColorDialogPrivate::_q_addCustom()
void QColorDialogPrivate::retranslateStrings()
{
+ if (nativeDialogInUse)
+ return;
+
if (!smallDisplay) {
lblBasicColors->setText(QColorDialog::tr("&Basic colors"));
lblCustomColors->setText(QColorDialog::tr("&Custom colors"));
diff --git a/src/widgets/doc/snippets/cmake-macros/examples.cmake b/src/widgets/doc/snippets/cmake-macros/examples.cmake
new file mode 100644
index 0000000000..61ec7aed54
--- /dev/null
+++ b/src/widgets/doc/snippets/cmake-macros/examples.cmake
@@ -0,0 +1,5 @@
+#! [qt5_wrap_ui]
+set(SOURCES mainwindow.cpp main.cpp)
+qt5_wrap_ui(SOURCES mainwindow.ui)
+add_executable(myapp ${SOURCES})
+#! [qt5_wrap_ui]
diff --git a/src/widgets/doc/src/cmake-macros.qdoc b/src/widgets/doc/src/cmake-macros.qdoc
new file mode 100644
index 0000000000..36579576a9
--- /dev/null
+++ b/src/widgets/doc/src/cmake-macros.qdoc
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Free Documentation License Usage
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file. Please review the following information to ensure
+** the GNU Free Documentation License version 1.3 requirements
+** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\page qtwidgets-cmake-qt5-wrap-ui.html
+\ingroup cmake-macros-qtwidgets
+
+\title qt5_wrap_ui
+
+\brief Creates sources for \c{.ui} files.
+
+\section1 Synopsis
+
+\badcode
+qt5_wrap_ui(<VAR> ui_file1 [ui_file2 ...]
+ [OPTIONS ...])
+\endcode
+
+\section1 Description
+
+Creates rules for calling \l{uic}{User Interface Compiler (uic)} on the given
+\c{.ui} files. For each input file, an header file is generated in the build
+directory. The paths of the generated header files are added to\c{<VAR>}.
+
+\note This is a low-level macro. See the \l{CMake AUTOUIC Documentation} for a
+more convenient way to process \c{.ui} files with \c{uic}.
+
+\section1 Options
+
+You can set additional \c{OPTIONS} that should be added to the \c{uic} calls.
+You can find possible options in the \l{uic}{uic documentation}.
+
+\section1 Examples
+
+\snippet cmake-macros/examples.cmake qt5_wrap_ui
+*/
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index 713f022bdd..65708fa1ca 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -9795,9 +9795,9 @@ QRectF QGraphicsPixmapItem::boundingRect() const
return QRectF();
if (d->flags & ItemIsSelectable) {
qreal pw = 1.0;
- return QRectF(d->offset, d->pixmap.size() / d->pixmap.devicePixelRatio()).adjusted(-pw/2, -pw/2, pw/2, pw/2);
+ return QRectF(d->offset, QSizeF(d->pixmap.size()) / d->pixmap.devicePixelRatio()).adjusted(-pw/2, -pw/2, pw/2, pw/2);
} else {
- return QRectF(d->offset, d->pixmap.size() / d->pixmap.devicePixelRatio());
+ return QRectF(d->offset, QSizeF(d->pixmap.size()) / d->pixmap.devicePixelRatio());
}
}
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index d863ef625b..0682717f54 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -2583,14 +2583,15 @@ void QWidgetPrivate::createWinId()
/*!
\internal
Ensures that the widget is set on the screen point is on. This is handy getting a correct
-size hint before a resize in e.g QMenu and QToolTip
+size hint before a resize in e.g QMenu and QToolTip.
+Returns if the screen was changed.
*/
-void QWidgetPrivate::setScreenForPoint(const QPoint &pos)
+bool QWidgetPrivate::setScreenForPoint(const QPoint &pos)
{
Q_Q(QWidget);
if (!q->isWindow())
- return;
+ return false;
// Find the screen for pos and make the widget undertand it is on that screen.
const QScreen *currentScreen = windowHandle() ? windowHandle()->screen() : nullptr;
QScreen *actualScreen = QGuiApplication::screenAt(pos);
@@ -2599,7 +2600,9 @@ void QWidgetPrivate::setScreenForPoint(const QPoint &pos)
createWinId();
if (windowHandle())
windowHandle()->setScreen(actualScreen);
+ return true;
}
+ return false;
}
/*!
diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h
index 797963b931..af4ad31501 100644
--- a/src/widgets/kernel/qwidget_p.h
+++ b/src/widgets/kernel/qwidget_p.h
@@ -355,7 +355,7 @@ public:
void createRecursively();
void createWinId();
- void setScreenForPoint(const QPoint &pos);
+ bool setScreenForPoint(const QPoint &pos);
void createTLExtra();
void createExtra();
diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp
index 0daa4a4b41..e41f7e7573 100644
--- a/src/widgets/util/qcompleter.cpp
+++ b/src/widgets/util/qcompleter.cpp
@@ -976,18 +976,48 @@ void QCompleterPrivate::showPopup(const QRect& rect)
popup->show();
}
+#if QT_CONFIG(filesystemmodel)
+static bool isRoot(const QFileSystemModel *model, const QString &path)
+{
+ const auto index = model->index(path);
+ return index.isValid() && model->fileInfo(index).isRoot();
+}
+
+static bool completeOnLoaded(const QFileSystemModel *model,
+ const QString &nativePrefix,
+ const QString &path,
+ Qt::CaseSensitivity caseSensitivity)
+{
+ const auto pathSize = path.size();
+ const auto prefixSize = nativePrefix.size();
+ if (prefixSize < pathSize)
+ return false;
+ const QString prefix = QDir::fromNativeSeparators(nativePrefix);
+ if (prefixSize == pathSize)
+ return path.compare(prefix, caseSensitivity) == 0 && isRoot(model, path);
+ // The user is typing something within that directory and is not in a subdirectory yet.
+ const auto separator = QLatin1Char('/');
+ return prefix.startsWith(path, caseSensitivity) && prefix.at(pathSize) == separator
+ && !prefix.rightRef(prefixSize - pathSize - 1).contains(separator);
+}
+
void QCompleterPrivate::_q_fileSystemModelDirectoryLoaded(const QString &path)
{
Q_Q(QCompleter);
// Slot called when QFileSystemModel has finished loading.
// If we hide the popup because there was no match because the model was not loaded yet,
- // we re-start the completion when we get the results
- if (hiddenBecauseNoMatch
- && prefix.startsWith(path) && prefix != (path + QLatin1Char('/'))
- && widget) {
- q->complete();
+ // we re-start the completion when we get the results (unless triggered by
+ // something else, see QTBUG-14292).
+ if (hiddenBecauseNoMatch && widget) {
+ if (auto model = qobject_cast<const QFileSystemModel *>(proxy->sourceModel())) {
+ if (completeOnLoaded(model, prefix, path, cs))
+ q->complete();
+ }
}
}
+#else // QT_CONFIG(filesystemmodel)
+void QCompleterPrivate::_q_fileSystemModelDirectoryLoaded(const QString &) {}
+#endif
/*!
Constructs a completer object with the given \a parent.
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 14964a696d..287be3e272 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -73,6 +73,7 @@
#endif
#include "qpushbutton.h"
#include "qtooltip.h"
+#include <qwindow.h>
#include <private/qpushbutton_p.h>
#include <private/qaction_p.h>
#include <private/qguiapplication_p.h>
@@ -1485,6 +1486,8 @@ void QMenuPrivate::_q_platformMenuAboutToShow()
{
Q_Q(QMenu);
+ emit q->aboutToShow();
+
#ifdef Q_OS_OSX
if (platformMenu) {
const auto actions = q->actions();
@@ -1498,8 +1501,6 @@ void QMenuPrivate::_q_platformMenuAboutToShow()
}
}
#endif
-
- emit q->aboutToShow();
}
bool QMenuPrivate::hasMouseMoved(const QPoint &globalPos)
@@ -2328,8 +2329,10 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
d->motions = 0;
d->doChildEffects = true;
d->updateLayoutDirection();
- // Ensure that we get correct sizeHints by placing this window on the right screen.
- d->setScreenForPoint(p);
+
+ // Ensure that we get correct sizeHints by placing this window on the correct screen.
+ if (d->setScreenForPoint(p))
+ d->itemsDirty = true;
const bool contextMenu = d->isContextMenu();
if (d->lastContextMenu != contextMenu) {
diff --git a/src/widgets/widgets/qwidgetresizehandler.cpp b/src/widgets/widgets/qwidgetresizehandler.cpp
index 7ed6f6d78d..e8d435429f 100644
--- a/src/widgets/widgets/qwidgetresizehandler.cpp
+++ b/src/widgets/widgets/qwidgetresizehandler.cpp
@@ -121,7 +121,7 @@ bool QWidgetResizeHandler::eventFilter(QObject *o, QEvent *ee)
break;
const QRect widgetRect = widget->rect().marginsAdded(QMargins(range, range, range, range));
const QPoint cursorPoint = widget->mapFromGlobal(e->globalPos());
- if (!widgetRect.contains(cursorPoint) || mode == Nowhere)
+ if (!widgetRect.contains(cursorPoint))
return false;
if (e->button() == Qt::LeftButton) {
#if 0 // Used to be included in Qt4 for Q_WS_X11