summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/accessible/accessible.pri6
-rw-r--r--src/gui/gui.pro2
-rw-r--r--src/gui/image/qicon.cpp50
-rw-r--r--src/gui/image/qicon.h3
-rw-r--r--src/gui/image/qiconengine.cpp17
-rw-r--r--src/gui/image/qiconengine.h3
-rw-r--r--src/gui/image/qiconloader.cpp168
-rw-r--r--src/gui/image/qiconloader_p.h5
-rw-r--r--src/gui/image/qimage.h4
-rw-r--r--src/gui/image/qpixmapcache.cpp10
-rw-r--r--src/gui/image/qpixmapcache.h1
-rw-r--r--src/gui/kernel/qdrag.cpp19
-rw-r--r--src/gui/kernel/qdrag.h2
-rw-r--r--src/gui/kernel/qevent.cpp3
-rw-r--r--src/gui/kernel/qevent.h9
-rw-r--r--src/gui/kernel/qgenericplugin.cpp4
-rw-r--r--src/gui/kernel/qgenericplugin.h5
-rw-r--r--src/gui/kernel/qguiapplication.cpp32
-rw-r--r--src/gui/kernel/qguiapplication.h4
-rw-r--r--src/gui/kernel/qguiapplication_p.h1
-rw-r--r--src/gui/kernel/qinputdevicemanager_p.h3
-rw-r--r--src/gui/kernel/qplatformdrag.cpp14
-rw-r--r--src/gui/kernel/qplatformdrag.h1
-rw-r--r--src/gui/kernel/qplatformintegrationfactory.cpp14
-rw-r--r--src/gui/kernel/qsimpledrag.cpp8
-rw-r--r--src/gui/kernel/qsimpledrag_p.h1
-rw-r--r--src/gui/opengl/qtriangulator_p.h11
-rw-r--r--src/gui/text/qrawfont.cpp1
-rw-r--r--src/gui/text/qtexthtmlparser.cpp3
-rw-r--r--src/gui/text/qtextimagehandler.cpp1
30 files changed, 351 insertions, 54 deletions
diff --git a/src/gui/accessible/accessible.pri b/src/gui/accessible/accessible.pri
index 86ed4c3a71..b7f341d5b7 100644
--- a/src/gui/accessible/accessible.pri
+++ b/src/gui/accessible/accessible.pri
@@ -17,5 +17,9 @@ contains(QT_CONFIG, accessibility) {
HEADERS += accessible/qaccessiblebridge.h
SOURCES += accessible/qaccessiblebridge.cpp
- OBJECTIVE_SOURCES += accessible/qaccessiblecache_mac.mm
+ mac {
+ OBJECTIVE_SOURCES += accessible/qaccessiblecache_mac.mm
+
+ LIBS_PRIVATE += -framework Foundation
+ }
}
diff --git a/src/gui/gui.pro b/src/gui/gui.pro
index aa05d72a3d..55837bcf3b 100644
--- a/src/gui/gui.pro
+++ b/src/gui/gui.pro
@@ -33,7 +33,7 @@ testcocoon {
load(testcocoon)
}
-mac:!ios: LIBS_PRIVATE += -framework Cocoa
+osx: LIBS_PRIVATE += -framework AppKit
CONFIG += simd optimize_full
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index af3af516db..cebe5ce5f9 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -919,7 +919,7 @@ void QIcon::paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment,
*/
bool QIcon::isNull() const
{
- return !d;
+ return !d || d->engine->isNull();
}
/*!\internal
@@ -934,7 +934,12 @@ bool QIcon::isDetached() const
void QIcon::detach()
{
if (d) {
- if (d->ref.load() != 1) {
+ if (d->engine->isNull()) {
+ if (!d->ref.deref())
+ delete d;
+ d = 0;
+ return;
+ } else if (d->ref.load() != 1) {
QIconPrivate *x = new QIconPrivate;
x->engine = d->engine->clone();
if (!d->ref.deref())
@@ -958,11 +963,10 @@ void QIcon::addPixmap(const QPixmap &pixmap, Mode mode, State state)
{
if (pixmap.isNull())
return;
+ detach();
if (!d) {
d = new QIconPrivate;
d->engine = new QPixmapIconEngine;
- } else {
- detach();
}
d->engine->addPixmap(pixmap, mode, state);
}
@@ -1002,6 +1006,7 @@ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State
{
if (fileName.isEmpty())
return;
+ detach();
if (!d) {
#ifndef QT_NO_LIBRARY
QFileInfo info(fileName);
@@ -1024,8 +1029,6 @@ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State
d = new QIconPrivate;
d->engine = new QPixmapIconEngine;
}
- } else {
- detach();
}
d->engine->addFile(fileName, size, mode, state);
@@ -1135,8 +1138,7 @@ QString QIcon::themeName()
\since 4.6
Returns the QIcon corresponding to \a name in the current
- icon theme. If no such icon is found in the current theme
- \a fallback is returned instead.
+ icon theme.
The latest version of the freedesktop icon specification and naming
specification can be obtained here:
@@ -1150,19 +1152,18 @@ QString QIcon::themeName()
\snippet code/src_gui_image_qicon.cpp 3
- Or if you want to provide a guaranteed fallback for platforms that
- do not support theme icons, you can use the second argument:
-
- \snippet code/src_gui_image_qicon.cpp 4
-
\note By default, only X11 will support themed icons. In order to
use themed icons on Mac and Windows, you will have to bundle a
compliant theme in one of your themeSearchPaths() and set the
appropriate themeName().
+ \note Qt will make use of GTK's icon-theme.cache if present to speed up
+ the lookup. These caches can be generated using gtk-update-icon-cache:
+ \l{https://developer.gnome.org/gtk3/stable/gtk-update-icon-cache.html}.
+
\sa themeName(), setThemeName(), themeSearchPaths()
*/
-QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback)
+QIcon QIcon::fromTheme(const QString &name)
{
QIcon icon;
@@ -1178,7 +1179,26 @@ QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback)
qtIconCache()->insert(name, cachedIcon);
}
- if (qApp && icon.availableSizes().isEmpty())
+ return icon;
+}
+
+/*!
+ \overload
+
+ Returns the QIcon corresponding to \a name in the current
+ icon theme. If no such icon is found in the current theme
+ \a fallback is returned instead.
+
+ If you want to provide a guaranteed fallback for platforms that
+ do not support theme icons, you can use the second argument:
+
+ \snippet code/src_gui_image_qicon.cpp 4
+*/
+QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback)
+{
+ QIcon icon = fromTheme(name);
+
+ if (icon.isNull() || icon.availableSizes().isEmpty())
return fallback;
return icon;
diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h
index 8c72f54629..6808bc2828 100644
--- a/src/gui/image/qicon.h
+++ b/src/gui/image/qicon.h
@@ -105,7 +105,8 @@ public:
void setIsMask(bool isMask);
bool isMask() const;
- static QIcon fromTheme(const QString &name, const QIcon &fallback = QIcon());
+ static QIcon fromTheme(const QString &name);
+ static QIcon fromTheme(const QString &name, const QIcon &fallback);
static bool hasThemeIcon(const QString &name);
static QStringList themeSearchPaths();
diff --git a/src/gui/image/qiconengine.cpp b/src/gui/image/qiconengine.cpp
index c09933d45f..7411dbb054 100644
--- a/src/gui/image/qiconengine.cpp
+++ b/src/gui/image/qiconengine.cpp
@@ -150,6 +150,11 @@ void QIconEngine::addFile(const QString &/*fileName*/, const QSize &/*size*/, QI
icon, for example when instantiating an icon using
QIcon::fromTheme().
+ \value IsNullHook Allow to query if this engine represents a null
+ icon. The \a data argument of the virtual_hook() is a pointer to a
+ bool that can be set to true if the icon is null. This enum value
+ was added in Qt 5.7.
+
\sa virtual_hook()
*/
@@ -283,4 +288,16 @@ QString QIconEngine::iconName() const
return name;
}
+/*!
+ \since 5.7
+
+ Returns true if this icon engine represent a null QIcon.
+ */
+bool QIconEngine::isNull() const
+{
+ bool isNull = false;
+ const_cast<QIconEngine *>(this)->virtual_hook(QIconEngine::IsNullHook, &isNull);
+ return isNull;
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/image/qiconengine.h b/src/gui/image/qiconengine.h
index 9977113054..6c45cd216f 100644
--- a/src/gui/image/qiconengine.h
+++ b/src/gui/image/qiconengine.h
@@ -58,7 +58,7 @@ public:
virtual bool read(QDataStream &in);
virtual bool write(QDataStream &out) const;
- enum IconEngineHook { AvailableSizesHook = 1, IconNameHook };
+ enum IconEngineHook { AvailableSizesHook = 1, IconNameHook, IsNullHook };
struct AvailableSizesArgument
{
@@ -71,6 +71,7 @@ public:
QIcon::State state = QIcon::Off) const;
virtual QString iconName() const;
+ bool isNull() const; // ### Qt6 make virtual
virtual void virtual_hook(int id, void *data);
};
diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp
index 3ead72dfbb..ecce7f9967 100644
--- a/src/gui/image/qiconloader.cpp
+++ b/src/gui/image/qiconloader.cpp
@@ -155,6 +155,141 @@ QStringList QIconLoader::themeSearchPaths() const
return m_iconDirs;
}
+/*!
+ \class QIconCacheGtkReader
+ \internal
+ Helper class that reads and looks up into the icon-theme.cache generated with
+ gtk-update-icon-cache. If at any point we detect a corruption in the file
+ (because the offsets point at wrong locations for example), the reader
+ is marked as invalid.
+*/
+class QIconCacheGtkReader
+{
+public:
+ explicit QIconCacheGtkReader(const QString &themeDir);
+ QVector<const char *> lookup(const QString &);
+ bool isValid() const { return m_isValid; }
+private:
+ QFile m_file;
+ const unsigned char *m_data;
+ quint64 m_size;
+ bool m_isValid;
+
+ quint16 read16(uint offset)
+ {
+ if (offset > m_size - 2 || (offset & 0x1)) {
+ m_isValid = false;
+ return 0;
+ }
+ return m_data[offset+1] | m_data[offset] << 8;
+ }
+ quint32 read32(uint offset)
+ {
+ if (offset > m_size - 4 || (offset & 0x3)) {
+ m_isValid = false;
+ return 0;
+ }
+ return m_data[offset+3] | m_data[offset+2] << 8
+ | m_data[offset+1] << 16 | m_data[offset] << 24;
+ }
+};
+
+
+QIconCacheGtkReader::QIconCacheGtkReader(const QString &dirName)
+ : m_isValid(false)
+{
+ QFileInfo info(dirName + QLatin1Literal("/icon-theme.cache"));
+ if (!info.exists() || info.lastModified() < QFileInfo(dirName).lastModified())
+ return;
+ m_file.setFileName(info.absoluteFilePath());
+ if (!m_file.open(QFile::ReadOnly))
+ return;
+ m_size = m_file.size();
+ m_data = m_file.map(0, m_size);
+ if (!m_data)
+ return;
+ if (read16(0) != 1) // VERSION_MAJOR
+ return;
+
+ m_isValid = true;
+
+ // Check that all the directories are older than the cache
+ auto lastModified = info.lastModified();
+ quint32 dirListOffset = read32(8);
+ quint32 dirListLen = read32(dirListOffset);
+ for (uint i = 0; i < dirListLen; ++i) {
+ quint32 offset = read32(dirListOffset + 4 + 4 * i);
+ if (!m_isValid || offset >= m_size || lastModified < QFileInfo(dirName + QLatin1Char('/')
+ + QString::fromUtf8(reinterpret_cast<const char*>(m_data + offset))).lastModified()) {
+ m_isValid = false;
+ return;
+ }
+ }
+}
+
+static quint32 icon_name_hash(const char *p)
+{
+ quint32 h = static_cast<signed char>(*p);
+ for (p += 1; *p != '\0'; p++)
+ h = (h << 5) - h + *p;
+ return h;
+}
+
+/*! \internal
+ lookup the icon name and return the list of subdirectories in which an icon
+ with this name is present. The char* are pointers to the mapped data.
+ For example, this would return { "32x32/apps", "24x24/apps" , ... }
+ */
+QVector<const char *> QIconCacheGtkReader::lookup(const QString &name)
+{
+ QVector<const char *> ret;
+ if (!isValid())
+ return ret;
+
+ QByteArray nameUtf8 = name.toUtf8();
+ quint32 hash = icon_name_hash(nameUtf8);
+
+ quint32 hashOffset = read32(4);
+ quint32 hashBucketCount = read32(hashOffset);
+
+ if (!isValid() || hashBucketCount == 0) {
+ m_isValid = false;
+ return ret;
+ }
+
+ quint32 bucketIndex = hash % hashBucketCount;
+ quint32 bucketOffset = read32(hashOffset + 4 + bucketIndex * 4);
+ while (bucketOffset > 0 && bucketOffset <= m_size - 12) {
+ quint32 nameOff = read32(bucketOffset + 4);
+ if (nameOff < m_size && strcmp(reinterpret_cast<const char*>(m_data + nameOff), nameUtf8) == 0) {
+ quint32 dirListOffset = read32(8);
+ quint32 dirListLen = read32(dirListOffset);
+
+ quint32 listOffset = read32(bucketOffset+8);
+ quint32 listLen = read32(listOffset);
+
+ if (!m_isValid || listOffset + 4 + 8 * listLen > m_size) {
+ m_isValid = false;
+ return ret;
+ }
+
+ ret.reserve(listLen);
+ for (uint j = 0; j < listLen && m_isValid; ++j) {
+ quint32 dirIndex = read16(listOffset + 4 + 8 * j);
+ quint32 o = read32(dirListOffset + 4 + dirIndex*4);
+ if (!m_isValid || dirIndex >= dirListLen || o >= m_size) {
+ m_isValid = false;
+ return ret;
+ }
+ ret.append(reinterpret_cast<const char*>(m_data) + o);
+ }
+ return ret;
+ }
+ bucketOffset = read32(bucketOffset);
+ }
+ return ret;
+}
+
QIconTheme::QIconTheme(const QString &themeName)
: m_valid(false)
{
@@ -166,8 +301,10 @@ QIconTheme::QIconTheme(const QString &themeName)
QString themeDir = iconDir.path() + QLatin1Char('/') + themeName;
QFileInfo themeDirInfo(themeDir);
- if (themeDirInfo.isDir())
+ if (themeDirInfo.isDir()) {
m_contentDirs << themeDir;
+ m_gtkCaches << QSharedPointer<QIconCacheGtkReader>::create(themeDir);
+ }
if (!m_valid) {
themeIndex.setFileName(themeDir + QLatin1String("/index.theme"));
@@ -257,7 +394,6 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
}
const QStringList contentDirs = theme.contentDirs();
- const QVector<QIconDirInfo> subDirs = theme.keyList();
QString iconNameFallback = iconName;
@@ -268,6 +404,29 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
// Add all relevant files
for (int i = 0; i < contentDirs.size(); ++i) {
+ QVector<QIconDirInfo> subDirs = theme.keyList();
+
+ // Try to reduce the amount of subDirs by looking in the GTK+ cache in order to save
+ // a massive amount of file stat (especially if the icon is not there)
+ auto cache = theme.m_gtkCaches.at(i);
+ if (cache->isValid()) {
+ auto result = cache->lookup(iconNameFallback);
+ if (cache->isValid()) {
+ const QVector<QIconDirInfo> subDirsCopy = subDirs;
+ subDirs.clear();
+ subDirs.reserve(result.count());
+ foreach (const char *s, result) {
+ QString path = QString::fromUtf8(s);
+ auto it = std::find_if(subDirsCopy.cbegin(), subDirsCopy.cend(),
+ [&](const QIconDirInfo &info) {
+ return info.path == path; } );
+ if (it != subDirsCopy.cend()) {
+ subDirs.append(*it);
+ }
+ }
+ }
+ }
+
QString contentDir = contentDirs.at(i) + QLatin1Char('/');
for (int j = 0; j < subDirs.size() ; ++j) {
const QIconDirInfo &dirInfo = subDirs.at(j);
@@ -587,6 +746,11 @@ void QIconLoaderEngine::virtual_hook(int id, void *data)
name = m_info.iconName;
}
break;
+ case QIconEngine::IsNullHook:
+ {
+ *reinterpret_cast<bool*>(data) = m_info.entries.isEmpty();
+ }
+ break;
default:
QIconEngine::virtual_hook(id, data);
}
diff --git a/src/gui/image/qiconloader_p.h b/src/gui/image/qiconloader_p.h
index ccf0a9d438..193154e44e 100644
--- a/src/gui/image/qiconloader_p.h
+++ b/src/gui/image/qiconloader_p.h
@@ -139,6 +139,8 @@ private:
friend class QIconLoader;
};
+class QIconCacheGtkReader;
+
class QIconTheme
{
public:
@@ -148,12 +150,13 @@ public:
QVector<QIconDirInfo> keyList() { return m_keyList; }
QStringList contentDirs() { return m_contentDirs; }
bool isValid() { return m_valid; }
-
private:
QStringList m_contentDirs;
QVector<QIconDirInfo> m_keyList;
QStringList m_parents;
bool m_valid;
+public:
+ QVector<QSharedPointer<QIconCacheGtkReader>> m_gtkCaches;
};
class Q_GUI_EXPORT QIconLoader
diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h
index 888c7beb32..9d8e3efcc4 100644
--- a/src/gui/image/qimage.h
+++ b/src/gui/image/qimage.h
@@ -168,9 +168,9 @@ public:
Format format() const;
#if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QIMAGE_COMPAT_CPP)
- QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) const & Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) const & Q_REQUIRED_RESULT
{ return convertToFormat_helper(f, flags); }
- QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) && Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) && Q_REQUIRED_RESULT
{
if (convertToFormat_inplace(f, flags))
return std::move(*this);
diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp
index d29ddcf978..6265a0c16d 100644
--- a/src/gui/image/qpixmapcache.cpp
+++ b/src/gui/image/qpixmapcache.cpp
@@ -156,6 +156,16 @@ bool QPixmapCache::Key::operator ==(const Key &key) const
*/
/*!
+ Returns \c true if there is a cached pixmap associated with this key.
+ Otherwise, if pixmap was flushed, the key is no longer valid.
+ \since 5.7
+*/
+bool QPixmapCache::Key::isValid() const Q_DECL_NOTHROW
+{
+ return d && d->isValid;
+}
+
+/*!
\internal
*/
QPixmapCache::Key &QPixmapCache::Key::operator =(const Key &other)
diff --git a/src/gui/image/qpixmapcache.h b/src/gui/image/qpixmapcache.h
index 37a0588e06..ca18f299a7 100644
--- a/src/gui/image/qpixmapcache.h
+++ b/src/gui/image/qpixmapcache.h
@@ -59,6 +59,7 @@ public:
Key &operator =(const Key &other);
void swap(Key &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
+ bool isValid() const Q_DECL_NOTHROW;
private:
KeyData *d;
diff --git a/src/gui/kernel/qdrag.cpp b/src/gui/kernel/qdrag.cpp
index 2736fac8e0..36527966b7 100644
--- a/src/gui/kernel/qdrag.cpp
+++ b/src/gui/kernel/qdrag.cpp
@@ -33,6 +33,8 @@
#include <qdrag.h>
#include "private/qguiapplication_p.h"
+#include "qpa/qplatformintegration.h"
+#include "qpa/qplatformdrag.h"
#include <qpixmap.h>
#include <qpoint.h>
#include "qdnd_p.h"
@@ -223,6 +225,8 @@ QObject *QDrag::target() const
loop. Other events are still delivered to the application while
the operation is performed. On Windows, the Qt event loop is
blocked during the operation.
+
+ \sa cancel()
*/
Qt::DropAction QDrag::exec(Qt::DropActions supportedActions)
@@ -377,6 +381,21 @@ Qt::DropAction QDrag::defaultAction() const
Q_D(const QDrag);
return d->default_action;
}
+
+/*!
+ Cancels a drag operation initiated by Qt.
+
+ \note This is currently implemented on Windows and X11.
+
+ \since 5.6
+ \sa exec()
+*/
+void QDrag::cancel()
+{
+ if (QPlatformDrag *platformDrag = QGuiApplicationPrivate::platformIntegration()->drag())
+ platformDrag->cancelDrag();
+}
+
/*!
\fn void QDrag::actionChanged(Qt::DropAction action)
diff --git a/src/gui/kernel/qdrag.h b/src/gui/kernel/qdrag.h
index 0672cb00f9..961d7c89d9 100644
--- a/src/gui/kernel/qdrag.h
+++ b/src/gui/kernel/qdrag.h
@@ -77,6 +77,8 @@ public:
Qt::DropActions supportedActions() const;
Qt::DropAction defaultAction() const;
+ static void cancel();
+
Q_SIGNALS:
void actionChanged(Qt::DropAction action);
void targetChanged(QObject *newTarget);
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 0bb21752bc..233b9ef3f7 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -37,6 +37,7 @@
#include "qpa/qplatformintegration.h"
#include "qpa/qplatformdrag.h"
#include "private/qevent_p.h"
+#include "qfile.h"
#include "qmetaobject.h"
#include "qmimedata.h"
#include "private/qdnd_p.h"
@@ -3948,9 +3949,11 @@ QDebug operator<<(QDebug dbg, const QEvent *e)
QtDebugUtils::formatQEnum(dbg, static_cast<const QApplicationStateChangeEvent *>(e)->applicationState());
dbg << ')';
break;
+# ifndef QT_NO_CONTEXTMENU
case QEvent::ContextMenu:
dbg << "QContextMenuEvent(" << static_cast<const QContextMenuEvent *>(e)->pos() << ')';
break;
+# endif // !QT_NO_CONTEXTMENU
# ifndef QT_NO_TABLETEVENT
case QEvent::TabletEnterProximity:
case QEvent::TabletLeaveProximity:
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index b90fce97e0..66e650c42d 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -35,20 +35,19 @@
#define QEVENT_H
#include <QtGui/qwindowdefs.h>
-#include <QtCore/qobject.h>
#include <QtGui/qregion.h>
#include <QtCore/qnamespace.h>
#include <QtCore/qstring.h>
#include <QtGui/qkeysequence.h>
#include <QtCore/qcoreevent.h>
#include <QtCore/qvariant.h>
-#include <QtCore/qmap.h>
+#include <QtCore/qmap.h> // ### Qt 6: Remove
#include <QtCore/qvector.h>
-#include <QtCore/qset.h>
+#include <QtCore/qset.h> // ### Qt 6: Remove
#include <QtCore/qurl.h>
-#include <QtCore/qfile.h>
+#include <QtCore/qfile.h> // ### Qt 6: Replace by <qiodevice.h> and forward declare QFile
#include <QtGui/qvector2d.h>
-#include <QtGui/qtouchdevice.h>
+#include <QtGui/qtouchdevice.h> // ### Qt 6: Replace by forward declaration
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qgenericplugin.cpp b/src/gui/kernel/qgenericplugin.cpp
index 47f3ea5811..ae423b93e3 100644
--- a/src/gui/kernel/qgenericplugin.cpp
+++ b/src/gui/kernel/qgenericplugin.cpp
@@ -33,8 +33,6 @@
#include "qgenericplugin.h"
-#ifndef QT_NO_LIBRARY
-
QT_BEGIN_NAMESPACE
/*!
@@ -90,5 +88,3 @@ QGenericPlugin::~QGenericPlugin()
*/
QT_END_NAMESPACE
-
-#endif // QT_NO_LIBRARY
diff --git a/src/gui/kernel/qgenericplugin.h b/src/gui/kernel/qgenericplugin.h
index 03c1df7fba..21ae97f045 100644
--- a/src/gui/kernel/qgenericplugin.h
+++ b/src/gui/kernel/qgenericplugin.h
@@ -39,9 +39,6 @@
QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_LIBRARY
-
#define QGenericPluginFactoryInterface_iid "org.qt-project.Qt.QGenericPluginFactoryInterface"
class Q_GUI_EXPORT QGenericPlugin : public QObject
@@ -54,8 +51,6 @@ public:
virtual QObject* create(const QString& name, const QString &spec) = 0;
};
-#endif // QT_NO_LIBRARY
-
QT_END_NAMESPACE
#endif // QGENERICPLUGIN_H
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 2e0595152b..35e880fc5b 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -37,6 +37,7 @@
#include <qpa/qplatformintegrationfactory_p.h>
#include "private/qevent_p.h"
#include "qfont.h"
+#include "qtouchdevice.h"
#include <qpa/qplatformfontdatabase.h>
#include <qpa/qplatformwindow.h>
#include <qpa/qplatformnativeinterface.h>
@@ -146,6 +147,7 @@ QIcon *QGuiApplicationPrivate::app_icon = 0;
QString *QGuiApplicationPrivate::platform_name = 0;
QString *QGuiApplicationPrivate::displayName = 0;
+QString *QGuiApplicationPrivate::desktopFileName = 0;
QPalette *QGuiApplicationPrivate::app_pal = 0; // default application palette
@@ -606,6 +608,8 @@ QGuiApplication::~QGuiApplication()
QGuiApplicationPrivate::platform_name = 0;
delete QGuiApplicationPrivate::displayName;
QGuiApplicationPrivate::displayName = 0;
+ delete QGuiApplicationPrivate::desktopFileName;
+ QGuiApplicationPrivate::desktopFileName = 0;
}
QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags)
@@ -647,6 +651,34 @@ QString QGuiApplication::applicationDisplayName()
}
/*!
+ \property QGuiApplication::desktopFileName
+ \brief the base name of the desktop entry for this application
+ \since 5.7
+
+ This is the file name, without the full path, of the desktop entry
+ that represents this application according to the freedesktop desktop
+ entry specification.
+
+ This property gives a precise indication of what desktop entry represents
+ the application and it is needed by the windowing system to retrieve
+ such information without resorting to imprecise heuristics.
+
+ The latest version of the freedesktop desktop entry specification can be obtained
+ \l{http://standards.freedesktop.org/desktop-entry-spec/latest/}{here}.
+*/
+void QGuiApplication::setDesktopFileName(const QString &name)
+{
+ if (!QGuiApplicationPrivate::desktopFileName)
+ QGuiApplicationPrivate::desktopFileName = new QString;
+ *QGuiApplicationPrivate::desktopFileName = name;
+}
+
+QString QGuiApplication::desktopFileName()
+{
+ return QGuiApplicationPrivate::desktopFileName ? *QGuiApplicationPrivate::desktopFileName : QString();
+}
+
+/*!
Returns the most recently shown modal window. If no modal windows are
visible, this function returns zero.
diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h
index d995387d66..a773122d3e 100644
--- a/src/gui/kernel/qguiapplication.h
+++ b/src/gui/kernel/qguiapplication.h
@@ -67,6 +67,7 @@ class Q_GUI_EXPORT QGuiApplication : public QCoreApplication
Q_OBJECT
Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon)
Q_PROPERTY(QString applicationDisplayName READ applicationDisplayName WRITE setApplicationDisplayName)
+ Q_PROPERTY(QString desktopFileName READ desktopFileName WRITE setDesktopFileName)
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged)
Q_PROPERTY(QString platformName READ platformName STORED false)
Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed WRITE setQuitOnLastWindowClosed)
@@ -83,6 +84,9 @@ public:
static void setApplicationDisplayName(const QString &name);
static QString applicationDisplayName();
+ static void setDesktopFileName(const QString &name);
+ static QString desktopFileName();
+
static QWindowList allWindows();
static QWindowList topLevelWindows();
static QWindow *topLevelAt(const QPoint &pos);
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index 0559442049..6dc8735f86 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -183,6 +183,7 @@ public:
static QIcon *app_icon;
static QString *platform_name;
static QString *displayName;
+ static QString *desktopFileName;
QWindowList modalWindowList;
static void showModalWindow(QWindow *window);
diff --git a/src/gui/kernel/qinputdevicemanager_p.h b/src/gui/kernel/qinputdevicemanager_p.h
index d64793c23c..4c24b1bc93 100644
--- a/src/gui/kernel/qinputdevicemanager_p.h
+++ b/src/gui/kernel/qinputdevicemanager_p.h
@@ -61,7 +61,8 @@ public:
DeviceTypeUnknown,
DeviceTypePointer,
DeviceTypeKeyboard,
- DeviceTypeTouch
+ DeviceTypeTouch,
+ DeviceTypeTablet
};
QInputDeviceManager(QObject *parent = 0);
diff --git a/src/gui/kernel/qplatformdrag.cpp b/src/gui/kernel/qplatformdrag.cpp
index d789c75d1d..11230194fc 100644
--- a/src/gui/kernel/qplatformdrag.cpp
+++ b/src/gui/kernel/qplatformdrag.cpp
@@ -155,6 +155,20 @@ Qt::DropAction QPlatformDrag::defaultAction(Qt::DropActions possibleActions,
}
/*!
+ \brief Cancels the currently active drag (only for drags of
+ the current application initiated by QPlatformDrag::drag()).
+
+ The default implementation does nothing.
+
+ \since 5.6
+ */
+
+void QPlatformDrag::cancelDrag()
+{
+ Q_UNIMPLEMENTED();
+}
+
+/*!
\brief Called to notify QDrag about changes of the current action.
*/
diff --git a/src/gui/kernel/qplatformdrag.h b/src/gui/kernel/qplatformdrag.h
index 10ee88477f..72e28d2745 100644
--- a/src/gui/kernel/qplatformdrag.h
+++ b/src/gui/kernel/qplatformdrag.h
@@ -92,6 +92,7 @@ public:
virtual QMimeData *platformDropData() = 0;
virtual Qt::DropAction drag(QDrag *m_drag) = 0;
+ virtual void cancelDrag();
void updateAction(Qt::DropAction action);
virtual Qt::DropAction defaultAction(Qt::DropActions possibleActions, Qt::KeyboardModifiers modifiers) const;
diff --git a/src/gui/kernel/qplatformintegrationfactory.cpp b/src/gui/kernel/qplatformintegrationfactory.cpp
index 5a1fb3ca83..d109ceb2f0 100644
--- a/src/gui/kernel/qplatformintegrationfactory.cpp
+++ b/src/gui/kernel/qplatformintegrationfactory.cpp
@@ -42,11 +42,13 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QPlatformIntegrationFactoryInterface_iid, QLatin1String("/platforms"), Qt::CaseInsensitive))
+
+#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
(QPlatformIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
+#endif // !QT_NO_LIBRARY
static inline QPlatformIntegration *loadIntegration(QFactoryLoader *loader, const QString &key, const QStringList &parameters, int &argc, char ** argv)
{
@@ -59,8 +61,6 @@ static inline QPlatformIntegration *loadIntegration(QFactoryLoader *loader, cons
return 0;
}
-#endif // !QT_NO_LIBRARY
-
QPlatformIntegration *QPlatformIntegrationFactory::create(const QString &platform, const QStringList &paramList, int &argc, char **argv, const QString &platformPluginPath)
{
#ifndef QT_NO_LIBRARY
@@ -70,16 +70,10 @@ QPlatformIntegration *QPlatformIntegrationFactory::create(const QString &platfor
if (QPlatformIntegration *ret = loadIntegration(directLoader(), platform, paramList, argc, argv))
return ret;
}
- if (QPlatformIntegration *ret = loadIntegration(loader(), platform, paramList, argc, argv))
- return ret;
#else
- Q_UNUSED(platform);
- Q_UNUSED(paramList);
- Q_UNUSED(argc);
- Q_UNUSED(argv);
Q_UNUSED(platformPluginPath);
#endif
- return 0;
+ return loadIntegration(loader(), platform, paramList, argc, argv);
}
/*!
diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp
index 9f38c9b78a..706786385b 100644
--- a/src/gui/kernel/qsimpledrag.cpp
+++ b/src/gui/kernel/qsimpledrag.cpp
@@ -191,6 +191,14 @@ Qt::DropAction QBasicDrag::drag(QDrag *o)
return m_executed_drop_action;
}
+void QBasicDrag::cancelDrag()
+{
+ if (m_eventLoop) {
+ cancel();
+ m_eventLoop->quit();
+ }
+}
+
void QBasicDrag::restoreCursor()
{
if (m_restoreCursor) {
diff --git a/src/gui/kernel/qsimpledrag_p.h b/src/gui/kernel/qsimpledrag_p.h
index 055136c436..d5dacd8fd2 100644
--- a/src/gui/kernel/qsimpledrag_p.h
+++ b/src/gui/kernel/qsimpledrag_p.h
@@ -66,6 +66,7 @@ public:
virtual ~QBasicDrag();
virtual Qt::DropAction drag(QDrag *drag) Q_DECL_OVERRIDE;
+ void cancelDrag() Q_DECL_OVERRIDE;
virtual bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE;
diff --git a/src/gui/opengl/qtriangulator_p.h b/src/gui/opengl/qtriangulator_p.h
index 0ab3f7496c..4e13e5bdd0 100644
--- a/src/gui/opengl/qtriangulator_p.h
+++ b/src/gui/opengl/qtriangulator_p.h
@@ -88,12 +88,13 @@ public:
inline QVertexIndexVector &operator = (const QVertexIndexVector &other)
{
- if (t == UnsignedInt)
- indices32 = other.indices32;
- else
- indices16 = other.indices16;
+ if (t == UnsignedInt)
+ indices32 = other.indices32;
+ else
+ indices16 = other.indices16;
- return *this;
+ t = other.t;
+ return *this;
}
private:
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index 0fd5f510c7..0e8771b0ac 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -44,6 +44,7 @@
#include <qpa/qplatformfontdatabase.h>
#include <QtCore/qendian.h>
+#include <QtCore/qfile.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index f8f41bb53d..a09ed2c040 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -1140,6 +1140,7 @@ void QTextHtmlParserNode::setListStyle(const QVector<QCss::Value> &cssValues)
for (int i = 0; i < cssValues.count(); ++i) {
if (cssValues.at(i).type == QCss::Value::KnownIdentifier) {
switch (static_cast<QCss::KnownValue>(cssValues.at(i).variant.toInt())) {
+ case QCss::Value_None: hasOwnListStyle = true; listStyle = QTextListFormat::ListStyleUndefined; break;
case QCss::Value_Disc: hasOwnListStyle = true; listStyle = QTextListFormat::ListDisc; break;
case QCss::Value_Square: hasOwnListStyle = true; listStyle = QTextListFormat::ListSquare; break;
case QCss::Value_Circle: hasOwnListStyle = true; listStyle = QTextListFormat::ListCircle; break;
@@ -1495,6 +1496,8 @@ void QTextHtmlParser::applyAttributes(const QStringList &attributes)
node->listStyle = QTextListFormat::ListDisc;
else if (value == QLatin1String("circle"))
node->listStyle = QTextListFormat::ListCircle;
+ else if (value == QLatin1String("none"))
+ node->listStyle = QTextListFormat::ListStyleUndefined;
}
}
break;
diff --git a/src/gui/text/qtextimagehandler.cpp b/src/gui/text/qtextimagehandler.cpp
index 747ed90281..686a00e42a 100644
--- a/src/gui/text/qtextimagehandler.cpp
+++ b/src/gui/text/qtextimagehandler.cpp
@@ -38,6 +38,7 @@
#include <qtextformat.h>
#include <qpainter.h>
#include <qdebug.h>
+#include <qfile.h>
#include <private/qtextengine_p.h>
#include <qpalette.h>
#include <qthread.h>