summaryrefslogtreecommitdiffstats
path: root/src/platformsupport
diff options
context:
space:
mode:
Diffstat (limited to 'src/platformsupport')
-rw-r--r--src/platformsupport/accessibility/accessibility.pri2
-rw-r--r--src/platformsupport/cglconvenience/cglconvenience.mm23
-rw-r--r--src/platformsupport/clipboard/qmacmime.mm7
-rw-r--r--src/platformsupport/dbusmenu/qdbusmenuadaptor.cpp4
-rw-r--r--src/platformsupport/dbusmenu/qdbusmenutypes.cpp13
-rw-r--r--src/platformsupport/dbusmenu/qdbusmenutypes_p.h2
-rw-r--r--src/platformsupport/dbusmenu/qdbusplatformmenu.cpp4
-rw-r--r--src/platformsupport/dbusmenu/qdbusplatformmenu_p.h2
-rw-r--r--src/platformsupport/dbustray/qdbustrayicon.cpp4
-rw-r--r--src/platformsupport/dbustray/qdbustrayicon_p.h4
-rw-r--r--src/platformsupport/dbustray/qstatusnotifieritemadaptor.cpp3
-rw-r--r--src/platformsupport/dbustray/qstatusnotifieritemadaptor_p.h2
-rw-r--r--src/platformsupport/devicediscovery/devicediscovery.pri7
-rw-r--r--src/platformsupport/devicediscovery/qdevicediscovery_static.cpp8
-rw-r--r--src/platformsupport/eglconvenience/eglconvenience.pri6
-rw-r--r--src/platformsupport/eventdispatchers/eventdispatchers.pri5
-rw-r--r--src/platformsupport/eventdispatchers/qeventdispatcher_glib_p.h6
-rw-r--r--src/platformsupport/eventdispatchers/qwindowsguieventdispatcher.cpp4
-rw-r--r--src/platformsupport/eventdispatchers/qwindowsguieventdispatcher_p.h6
-rw-r--r--src/platformsupport/fbconvenience/qfbbackingstore.cpp7
-rw-r--r--src/platformsupport/fbconvenience/qfbbackingstore_p.h1
-rw-r--r--src/platformsupport/fbconvenience/qfbscreen.cpp15
-rw-r--r--src/platformsupport/fbconvenience/qfbvthandler.cpp5
-rw-r--r--src/platformsupport/fbconvenience/qfbvthandler_p.h1
-rw-r--r--src/platformsupport/fontdatabases/basic/basic.pri4
-rw-r--r--src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp3
-rw-r--r--src/platformsupport/fontdatabases/fontconfig/fontconfig.pri2
-rw-r--r--src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp8
-rw-r--r--src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h1
-rw-r--r--src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp2
-rw-r--r--src/platformsupport/fontdatabases/fontdatabases.pri25
-rw-r--r--src/platformsupport/fontdatabases/mac/coretext.pri7
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm263
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h9
-rw-r--r--src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm61
-rw-r--r--src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h8
-rw-r--r--src/platformsupport/glxconvenience/glxconvenience.pri6
-rw-r--r--src/platformsupport/graphics/qrasterbackingstore.cpp17
-rw-r--r--src/platformsupport/graphics/qrasterbackingstore_p.h9
-rw-r--r--src/platformsupport/input/evdevkeyboard/evdevkeyboard.pri5
-rw-r--r--src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp5
-rw-r--r--src/platformsupport/input/evdevmouse/evdevmouse.pri5
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp5
-rw-r--r--src/platformsupport/input/evdevtablet/evdevtablet.pri5
-rw-r--r--src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp4
-rw-r--r--src/platformsupport/input/evdevtouch/evdevtouch.pri10
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp54
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h5
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp4
-rw-r--r--src/platformsupport/input/input.pri10
-rw-r--r--src/platformsupport/input/libinput/libinput.pri15
-rw-r--r--src/platformsupport/input/libinput/qlibinputpointer.cpp2
-rw-r--r--src/platformsupport/input/libinput/qlibinputtouch.cpp13
-rw-r--r--src/platformsupport/input/shared/qtouchoutputmapping.cpp91
-rw-r--r--src/platformsupport/input/shared/qtouchoutputmapping_p.h71
-rw-r--r--src/platformsupport/input/shared/shared.pri5
-rw-r--r--src/platformsupport/input/tslib/tslib.pri2
-rw-r--r--src/platformsupport/linuxaccessibility/atspiadaptor.cpp22
-rw-r--r--src/platformsupport/linuxaccessibility/linuxaccessibility.pri2
-rw-r--r--src/platformsupport/platformcompositor/platformcompositor.pri2
-rw-r--r--src/platformsupport/platformcompositor/qopenglcompositor.cpp41
-rw-r--r--src/platformsupport/platformcompositor/qopenglcompositor_p.h9
-rw-r--r--src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp8
-rw-r--r--src/platformsupport/platformsupport.pro6
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes.cpp47
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes_p.h5
-rw-r--r--src/platformsupport/themes/qabstractfileiconengine.cpp129
-rw-r--r--src/platformsupport/themes/qabstractfileiconengine_p.h96
-rw-r--r--src/platformsupport/themes/themes.pri6
69 files changed, 844 insertions, 406 deletions
diff --git a/src/platformsupport/accessibility/accessibility.pri b/src/platformsupport/accessibility/accessibility.pri
index fb56edbf1a..924f6a512f 100644
--- a/src/platformsupport/accessibility/accessibility.pri
+++ b/src/platformsupport/accessibility/accessibility.pri
@@ -1,4 +1,4 @@
-contains(QT_CONFIG, accessibility) {
+qtConfig(accessibility) {
INCLUDEPATH += $$PWD
HEADERS += \
diff --git a/src/platformsupport/cglconvenience/cglconvenience.mm b/src/platformsupport/cglconvenience/cglconvenience.mm
index a4c5c7f61e..85add35879 100644
--- a/src/platformsupport/cglconvenience/cglconvenience.mm
+++ b/src/platformsupport/cglconvenience/cglconvenience.mm
@@ -81,22 +81,15 @@ void *qcgl_createNSOpenGLPixelFormat(const QSurfaceFormat &format)
else if (format.swapBehavior() == QSurfaceFormat::TripleBuffer)
attrs.append(NSOpenGLPFATripleBuffer);
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
- if (format.profile() == QSurfaceFormat::CoreProfile
- && ((format.majorVersion() == 3 && format.minorVersion() >= 2)
- || format.majorVersion() > 3)) {
- attrs << NSOpenGLPFAOpenGLProfile;
- attrs << NSOpenGLProfileVersion3_2Core;
- } else {
- attrs << NSOpenGLPFAOpenGLProfile;
- attrs << NSOpenGLProfileVersionLegacy;
- }
+ if (format.profile() == QSurfaceFormat::CoreProfile
+ && ((format.majorVersion() == 3 && format.minorVersion() >= 2)
+ || format.majorVersion() > 3)) {
+ attrs << NSOpenGLPFAOpenGLProfile;
+ attrs << NSOpenGLProfileVersion3_2Core;
+ } else {
+ attrs << NSOpenGLPFAOpenGLProfile;
+ attrs << NSOpenGLProfileVersionLegacy;
}
-#else
- if (format.profile() == QSurfaceFormat::CoreProfile)
- qWarning("Mac OSX >= 10.7 is needed for OpenGL Core Profile support");
-#endif
if (format.depthBufferSize() > 0)
attrs << NSOpenGLPFADepthSize << format.depthBufferSize();
diff --git a/src/platformsupport/clipboard/qmacmime.mm b/src/platformsupport/clipboard/qmacmime.mm
index f2b9afa2b5..d48da8da15 100644
--- a/src/platformsupport/clipboard/qmacmime.mm
+++ b/src/platformsupport/clipboard/qmacmime.mm
@@ -43,7 +43,7 @@
#import <AppKit/AppKit.h>
#endif
-#if defined(Q_OS_IOS)
+#if defined(QT_PLATFORM_UIKIT)
#import <UIKit/UIKit.h>
#endif
@@ -520,11 +520,6 @@ QString QMacPasteboardMimeRtfText::mimeFor(QString flav)
bool QMacPasteboardMimeRtfText::canConvert(const QString &mime, QString flav)
{
-#if defined(Q_OS_IOS)
- if (QSysInfo::MacintoshVersion < QSysInfo::MV_IOS_7_0)
- return false;
-#endif
-
return mime == mimeFor(flav);
}
diff --git a/src/platformsupport/dbusmenu/qdbusmenuadaptor.cpp b/src/platformsupport/dbusmenu/qdbusmenuadaptor.cpp
index f6a5144e2b..354b9c3a2e 100644
--- a/src/platformsupport/dbusmenu/qdbusmenuadaptor.cpp
+++ b/src/platformsupport/dbusmenu/qdbusmenuadaptor.cpp
@@ -105,7 +105,7 @@ QList<int> QDBusMenuAdaptor::AboutToShowGroup(const QList<int> &ids, QList<int>
qCDebug(qLcMenu) << ids;
Q_UNUSED(idErrors)
idErrors.clear();
- Q_FOREACH (int id, ids)
+ for (int id : ids)
AboutToShow(id);
return QList<int>(); // updatesNeeded
}
@@ -134,7 +134,7 @@ void QDBusMenuAdaptor::Event(int id, const QString &eventId, const QDBusVariant
QList<int> QDBusMenuAdaptor::EventGroup(const QDBusMenuEventList &events)
{
- Q_FOREACH (const QDBusMenuEvent &ev, events)
+ for (const QDBusMenuEvent &ev : events)
Event(ev.m_id, ev.m_eventId, ev.m_data, ev.m_timestamp);
return QList<int>(); // idErrors
}
diff --git a/src/platformsupport/dbusmenu/qdbusmenutypes.cpp b/src/platformsupport/dbusmenu/qdbusmenutypes.cpp
index 546483fcec..82a13d2fa0 100644
--- a/src/platformsupport/dbusmenu/qdbusmenutypes.cpp
+++ b/src/platformsupport/dbusmenu/qdbusmenutypes.cpp
@@ -113,7 +113,8 @@ uint QDBusMenuLayoutItem::populate(int id, int depth, const QStringList &propert
void QDBusMenuLayoutItem::populate(const QDBusPlatformMenu *menu, int depth, const QStringList &propertyNames)
{
- Q_FOREACH (QDBusPlatformMenuItem *item, menu->items()) {
+ const auto items = menu->items();
+ for (QDBusPlatformMenuItem *item : items) {
QDBusMenuLayoutItem child;
child.populate(item, depth - 1, propertyNames);
m_children << child;
@@ -136,7 +137,7 @@ const QDBusArgument &operator<<(QDBusArgument &arg, const QDBusMenuLayoutItem &i
arg.beginStructure();
arg << item.m_id << item.m_properties;
arg.beginArray(qMetaTypeId<QDBusVariant>());
- foreach (const QDBusMenuLayoutItem& child, item.m_children)
+ for (const QDBusMenuLayoutItem &child : item.m_children)
arg << QDBusVariant(QVariant::fromValue<QDBusMenuLayoutItem>(child));
arg.endArray();
arg.endStructure();
@@ -190,11 +191,13 @@ QDBusMenuItem::QDBusMenuItem(const QDBusPlatformMenuItem *item)
m_properties.insert(QLatin1String("toggle-type"), toggleType);
m_properties.insert(QLatin1String("toggle-state"), item->isChecked() ? 1 : 0);
}
+#ifndef QT_NO_SHORTCUT
const QKeySequence &scut = item->shortcut();
if (!scut.isEmpty()) {
QDBusMenuShortcut shortcut = convertKeySequence(scut);
m_properties.insert(QLatin1String("shortcut"), QVariant::fromValue(shortcut));
}
+#endif
const QIcon &icon = item->icon();
if (!icon.name().isEmpty()) {
m_properties.insert(QLatin1String("icon-name"), icon.name());
@@ -211,9 +214,9 @@ QDBusMenuItemList QDBusMenuItem::items(const QList<int> &ids, const QStringList
{
Q_UNUSED(propertyNames)
QDBusMenuItemList ret;
- QList<const QDBusPlatformMenuItem *> items = QDBusPlatformMenuItem::byIds(ids);
+ const QList<const QDBusPlatformMenuItem *> items = QDBusPlatformMenuItem::byIds(ids);
ret.reserve(items.size());
- Q_FOREACH (const QDBusPlatformMenuItem *item, items)
+ for (const QDBusPlatformMenuItem *item : items)
ret << QDBusMenuItem(item);
return ret;
}
@@ -230,6 +233,7 @@ QString QDBusMenuItem::convertMnemonic(const QString &label)
return ret;
}
+#ifndef QT_NO_SHORTCUT
QDBusMenuShortcut QDBusMenuItem::convertKeySequence(const QKeySequence &sequence)
{
QDBusMenuShortcut shortcut;
@@ -258,6 +262,7 @@ QDBusMenuShortcut QDBusMenuItem::convertKeySequence(const QKeySequence &sequence
}
return shortcut;
}
+#endif
const QDBusArgument &operator<<(QDBusArgument &arg, const QDBusMenuEvent &ev)
{
diff --git a/src/platformsupport/dbusmenu/qdbusmenutypes_p.h b/src/platformsupport/dbusmenu/qdbusmenutypes_p.h
index 1de71b69e4..fd6727d3be 100644
--- a/src/platformsupport/dbusmenu/qdbusmenutypes_p.h
+++ b/src/platformsupport/dbusmenu/qdbusmenutypes_p.h
@@ -74,7 +74,9 @@ public:
static QDBusMenuItemList items(const QList<int> &ids, const QStringList &propertyNames);
static QString convertMnemonic(const QString &label);
+#ifndef QT_NO_SHORTCUT
static QDBusMenuShortcut convertKeySequence(const QKeySequence &sequence);
+#endif
static void registerDBusTypes();
int m_id;
diff --git a/src/platformsupport/dbusmenu/qdbusplatformmenu.cpp b/src/platformsupport/dbusmenu/qdbusplatformmenu.cpp
index 446c3dfa83..15440a03cd 100644
--- a/src/platformsupport/dbusmenu/qdbusplatformmenu.cpp
+++ b/src/platformsupport/dbusmenu/qdbusplatformmenu.cpp
@@ -134,10 +134,12 @@ void QDBusPlatformMenuItem::setHasExclusiveGroup(bool hasExclusiveGroup)
m_hasExclusiveGroup = hasExclusiveGroup;
}
+#ifndef QT_NO_SHORTCUT
void QDBusPlatformMenuItem::setShortcut(const QKeySequence &shortcut)
{
m_shortcut = shortcut;
}
+#endif
void QDBusPlatformMenuItem::trigger()
{
@@ -156,7 +158,7 @@ QDBusPlatformMenuItem *QDBusPlatformMenuItem::byId(int id)
QList<const QDBusPlatformMenuItem *> QDBusPlatformMenuItem::byIds(const QList<int> &ids)
{
QList<const QDBusPlatformMenuItem *> ret;
- Q_FOREACH (int id, ids) {
+ for (int id : ids) {
if (menuItemsByID.contains(id))
ret << menuItemsByID[id];
}
diff --git a/src/platformsupport/dbusmenu/qdbusplatformmenu_p.h b/src/platformsupport/dbusmenu/qdbusplatformmenu_p.h
index f641ff5d8e..38c27e8051 100644
--- a/src/platformsupport/dbusmenu/qdbusplatformmenu_p.h
+++ b/src/platformsupport/dbusmenu/qdbusplatformmenu_p.h
@@ -99,8 +99,10 @@ public:
void setChecked(bool isChecked) Q_DECL_OVERRIDE;
bool hasExclusiveGroup() const { return m_hasExclusiveGroup; }
void setHasExclusiveGroup(bool hasExclusiveGroup) Q_DECL_OVERRIDE;
+#ifndef QT_NO_SHORTCUT
QKeySequence shortcut() const { return m_shortcut; }
void setShortcut(const QKeySequence& shortcut) Q_DECL_OVERRIDE;
+#endif
void setIconSize(int size) Q_DECL_OVERRIDE { Q_UNUSED(size); }
void setNativeContents(WId item) Q_DECL_OVERRIDE { Q_UNUSED(item); }
diff --git a/src/platformsupport/dbustray/qdbustrayicon.cpp b/src/platformsupport/dbustray/qdbustrayicon.cpp
index 1d8e430f3e..0369eaf144 100644
--- a/src/platformsupport/dbustray/qdbustrayicon.cpp
+++ b/src/platformsupport/dbustray/qdbustrayicon.cpp
@@ -37,9 +37,10 @@
**
****************************************************************************/
+#include "qdbustrayicon_p.h"
+
#ifndef QT_NO_SYSTEMTRAYICON
-#include "qdbustrayicon_p.h"
#include "qdbusmenuconnection_p.h"
#include "qstatusnotifieritemadaptor_p.h"
#include "qdbusmenuadaptor_p.h"
@@ -302,4 +303,3 @@ bool QDBusTrayIcon::isSystemTrayAvailable() const
QT_END_NAMESPACE
#endif //QT_NO_SYSTEMTRAYICON
-
diff --git a/src/platformsupport/dbustray/qdbustrayicon_p.h b/src/platformsupport/dbustray/qdbustrayicon_p.h
index fa2299866a..a383ef86fc 100644
--- a/src/platformsupport/dbustray/qdbustrayicon_p.h
+++ b/src/platformsupport/dbustray/qdbustrayicon_p.h
@@ -52,6 +52,8 @@
// We mean it.
//
+#include <QtCore/qglobal.h>
+
#ifndef QT_NO_SYSTEMTRAYICON
#include <QIcon>
@@ -162,6 +164,6 @@ private:
};
QT_END_NAMESPACE
-#endif // QT_NO_SYSTEMTRAYICON
+#endif // QT_NO_SYSTEMTRAYICON
#endif // QDBUSTRAYICON_H
diff --git a/src/platformsupport/dbustray/qstatusnotifieritemadaptor.cpp b/src/platformsupport/dbustray/qstatusnotifieritemadaptor.cpp
index 402cdab92c..d3c5454f01 100644
--- a/src/platformsupport/dbustray/qstatusnotifieritemadaptor.cpp
+++ b/src/platformsupport/dbustray/qstatusnotifieritemadaptor.cpp
@@ -48,9 +48,10 @@
QMetaObject::invokeMethod().
*/
+#include "qstatusnotifieritemadaptor_p.h"
+
#ifndef QT_NO_SYSTEMTRAYICON
-#include "qstatusnotifieritemadaptor_p.h"
#include "qdbustrayicon_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/platformsupport/dbustray/qstatusnotifieritemadaptor_p.h b/src/platformsupport/dbustray/qstatusnotifieritemadaptor_p.h
index deab9e74b5..776e1b23ef 100644
--- a/src/platformsupport/dbustray/qstatusnotifieritemadaptor_p.h
+++ b/src/platformsupport/dbustray/qstatusnotifieritemadaptor_p.h
@@ -62,6 +62,8 @@
// We mean it.
//
+#include <QtCore/qglobal.h>
+
#ifndef QT_NO_SYSTEMTRAYICON
#include <QtCore/QObject>
diff --git a/src/platformsupport/devicediscovery/devicediscovery.pri b/src/platformsupport/devicediscovery/devicediscovery.pri
index 9829ae88ba..f4e9103130 100644
--- a/src/platformsupport/devicediscovery/devicediscovery.pri
+++ b/src/platformsupport/devicediscovery/devicediscovery.pri
@@ -1,11 +1,10 @@
HEADERS += $$PWD/qdevicediscovery_p.h
-contains(QT_CONFIG, libudev) {
+qtConfig(libudev) {
SOURCES += $$PWD/qdevicediscovery_udev.cpp
HEADERS += $$PWD/qdevicediscovery_udev_p.h
- INCLUDEPATH += $$QMAKE_INCDIR_LIBUDEV
- LIBS_PRIVATE += $$QMAKE_LIBS_LIBUDEV
-} else: contains(QT_CONFIG, evdev) {
+ QMAKE_USE_PRIVATE += libudev
+} else: qtConfig(evdev) {
SOURCES += $$PWD/qdevicediscovery_static.cpp
HEADERS += $$PWD/qdevicediscovery_static_p.h
} else {
diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp b/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp
index 135ffa2494..5c72dbe7e2 100644
--- a/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp
+++ b/src/platformsupport/devicediscovery/qdevicediscovery_static.cpp
@@ -101,7 +101,8 @@ QStringList QDeviceDiscoveryStatic::scanConnectedDevices()
// check for input devices
if (m_types & Device_InputMask) {
dir.setPath(QString::fromLatin1(QT_EVDEV_DEVICE_PATH));
- foreach (const QString &deviceFile, dir.entryList()) {
+ const auto deviceFiles = dir.entryList();
+ for (const QString &deviceFile : deviceFiles) {
QString absoluteFilePath = dir.absolutePath() + QLatin1Char('/') + deviceFile;
if (checkDeviceType(absoluteFilePath))
devices << absoluteFilePath;
@@ -111,7 +112,8 @@ QStringList QDeviceDiscoveryStatic::scanConnectedDevices()
// check for drm devices
if (m_types & Device_VideoMask) {
dir.setPath(QString::fromLatin1(QT_DRM_DEVICE_PATH));
- foreach (const QString &deviceFile, dir.entryList()) {
+ const auto deviceFiles = dir.entryList();
+ for (const QString &deviceFile : deviceFiles) {
QString absoluteFilePath = dir.absolutePath() + QLatin1Char('/') + deviceFile;
if (checkDeviceType(absoluteFilePath))
devices << absoluteFilePath;
@@ -133,7 +135,7 @@ bool QDeviceDiscoveryStatic::checkDeviceType(const QString &device)
qCDebug(lcDD) << "doing static device discovery for " << device;
- if ((m_types & Device_DRM) && device.contains(QString::fromLatin1(QT_DRM_DEVICE_PREFIX))) {
+ if ((m_types & Device_DRM) && device.contains(QLatin1String(QT_DRM_DEVICE_PREFIX))) {
QT_CLOSE(fd);
return true;
}
diff --git a/src/platformsupport/eglconvenience/eglconvenience.pri b/src/platformsupport/eglconvenience/eglconvenience.pri
index 1cacaf4a4c..4a93d997fb 100644
--- a/src/platformsupport/eglconvenience/eglconvenience.pri
+++ b/src/platformsupport/eglconvenience/eglconvenience.pri
@@ -1,4 +1,4 @@
-contains(QT_CONFIG,egl) {
+qtConfig(egl) {
HEADERS += \
$$PWD/qeglconvenience_p.h \
$$PWD/qeglstreamconvenience_p.h \
@@ -8,7 +8,7 @@ contains(QT_CONFIG,egl) {
$$PWD/qeglconvenience.cpp \
$$PWD/qeglstreamconvenience.cpp
- contains(QT_CONFIG,opengl) {
+ qtConfig(opengl) {
HEADERS += $$PWD/qeglplatformcontext_p.h \
$$PWD/qeglpbuffer_p.h
@@ -19,7 +19,7 @@ contains(QT_CONFIG,egl) {
# Avoid X11 header collision, use generic EGL native types
DEFINES += QT_EGL_NO_X11
- contains(QT_CONFIG,xlib) {
+ qtConfig(xlib) {
HEADERS += \
$$PWD/qxlibeglintegration_p.h
SOURCES += \
diff --git a/src/platformsupport/eventdispatchers/eventdispatchers.pri b/src/platformsupport/eventdispatchers/eventdispatchers.pri
index a0b37cae1a..fb0f3b3827 100644
--- a/src/platformsupport/eventdispatchers/eventdispatchers.pri
+++ b/src/platformsupport/eventdispatchers/eventdispatchers.pri
@@ -14,9 +14,8 @@ HEADERS +=\
$$PWD/qwindowsguieventdispatcher_p.h
}
-contains(QT_CONFIG, glib) {
+qtConfig(glib) {
SOURCES +=$$PWD/qeventdispatcher_glib.cpp
HEADERS +=$$PWD/qeventdispatcher_glib_p.h
- QMAKE_CXXFLAGS += $$QT_CFLAGS_GLIB
- LIBS_PRIVATE += $$QT_LIBS_GLIB
+ QMAKE_USE_PRIVATE += glib
}
diff --git a/src/platformsupport/eventdispatchers/qeventdispatcher_glib_p.h b/src/platformsupport/eventdispatchers/qeventdispatcher_glib_p.h
index 7d57b97276..6d148753bf 100644
--- a/src/platformsupport/eventdispatchers/qeventdispatcher_glib_p.h
+++ b/src/platformsupport/eventdispatchers/qeventdispatcher_glib_p.h
@@ -44,9 +44,9 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from
-// version to version without notice, or even be removed.
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
//
// We mean it.
//
diff --git a/src/platformsupport/eventdispatchers/qwindowsguieventdispatcher.cpp b/src/platformsupport/eventdispatchers/qwindowsguieventdispatcher.cpp
index 7d49c35d84..de369e0b00 100644
--- a/src/platformsupport/eventdispatchers/qwindowsguieventdispatcher.cpp
+++ b/src/platformsupport/eventdispatchers/qwindowsguieventdispatcher.cpp
@@ -151,11 +151,10 @@ messageDebugEntries[] = {
{WM_IME_ENDCOMPOSITION, "WM_IME_ENDCOMPOSITION", true},
{WM_IME_NOTIFY, "WM_IME_NOTIFY", true},
{WM_IME_REQUEST, "WM_IME_REQUEST", true},
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
{WM_QUERYENDSESSION, "WM_QUERYENDSESSION", true},
{WM_ENDSESSION, "WM_ENDSESSION", true},
#endif
-#ifndef Q_OS_WINCE
{WM_MOUSEACTIVATE,"WM_MOUSEACTIVATE", true},
{WM_CHILDACTIVATE, "WM_CHILDACTIVATE", true},
{WM_PARENTNOTIFY, "WM_PARENTNOTIFY", true},
@@ -181,7 +180,6 @@ messageDebugEntries[] = {
{WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN", true},
{WM_DISPLAYCHANGE, "WM_DISPLAYCHANGE", true},
{WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD", true},
-#endif // !Q_OS_WINCE
{WM_THEMECHANGED, "WM_THEMECHANGED", true}
};
diff --git a/src/platformsupport/eventdispatchers/qwindowsguieventdispatcher_p.h b/src/platformsupport/eventdispatchers/qwindowsguieventdispatcher_p.h
index 5682fc72ef..9a23b5c0bd 100644
--- a/src/platformsupport/eventdispatchers/qwindowsguieventdispatcher_p.h
+++ b/src/platformsupport/eventdispatchers/qwindowsguieventdispatcher_p.h
@@ -44,9 +44,9 @@
// W A R N I N G
// -------------
//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from
-// version to version without notice, or even be removed.
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
//
// We mean it.
//
diff --git a/src/platformsupport/fbconvenience/qfbbackingstore.cpp b/src/platformsupport/fbconvenience/qfbbackingstore.cpp
index fa1b8d0acd..2cad3441e4 100644
--- a/src/platformsupport/fbconvenience/qfbbackingstore.cpp
+++ b/src/platformsupport/fbconvenience/qfbbackingstore.cpp
@@ -81,6 +81,12 @@ const QImage QFbBackingStore::image()
return mImage;
}
+
+QImage QFbBackingStore::toImage() const
+{
+ return mImage;
+}
+
void QFbBackingStore::lock()
{
mImageMutex.lock();
@@ -110,4 +116,3 @@ void QFbBackingStore::endPaint()
}
QT_END_NAMESPACE
-
diff --git a/src/platformsupport/fbconvenience/qfbbackingstore_p.h b/src/platformsupport/fbconvenience/qfbbackingstore_p.h
index fc06b95475..c8dfe3489c 100644
--- a/src/platformsupport/fbconvenience/qfbbackingstore_p.h
+++ b/src/platformsupport/fbconvenience/qfbbackingstore_p.h
@@ -72,6 +72,7 @@ public:
void resize(const QSize &size, const QRegion &region) Q_DECL_OVERRIDE;
const QImage image();
+ QImage toImage() const override;
void lock();
void unlock();
diff --git a/src/platformsupport/fbconvenience/qfbscreen.cpp b/src/platformsupport/fbconvenience/qfbscreen.cpp
index 4066743cc2..216f2722a4 100644
--- a/src/platformsupport/fbconvenience/qfbscreen.cpp
+++ b/src/platformsupport/fbconvenience/qfbscreen.cpp
@@ -138,15 +138,16 @@ void QFbScreen::lower(QFbWindow *window)
QWindow *QFbScreen::topWindow() const
{
- foreach (QFbWindow *fbw, mWindowStack)
+ for (QFbWindow *fbw : mWindowStack) {
if (fbw->window()->type() == Qt::Window || fbw->window()->type() == Qt::Dialog)
return fbw->window();
+ }
return 0;
}
QWindow *QFbScreen::topLevelAt(const QPoint & p) const
{
- foreach (QFbWindow *fbw, mWindowStack) {
+ for (QFbWindow *fbw : mWindowStack) {
if (fbw->geometry().contains(p, false) && fbw->window()->isVisible())
return fbw->window();
}
@@ -206,15 +207,13 @@ void QFbScreen::generateRects()
remainingScreen -= localGeometry;
QRegion windowRegion(localGeometry);
windowRegion -= remainingScreen;
- foreach (const QRect &rect, windowRegion.rects()) {
+ for (const QRect &rect : windowRegion)
mCachedRects += QPair<QRect, int>(rect, i);
- }
}
#endif
}
- const QVector<QRect> remainingScreenRects = remainingScreen.rects();
- mCachedRects.reserve(mCachedRects.count() + remainingScreenRects.count());
- foreach (const QRect &rect, remainingScreenRects)
+ mCachedRects.reserve(mCachedRects.count() + remainingScreen.rectCount());
+ for (const QRect &rect : remainingScreen)
mCachedRects += QPair<QRect, int>(rect, -1);
mIsUpToDate = true;
}
@@ -254,7 +253,7 @@ QRegion QFbScreen::doRedraw()
rectRegion -= intersect;
// we only expect one rectangle, but defensive coding...
- foreach (const QRect &rect, intersect.rects()) {
+ for (const QRect &rect : intersect) {
bool firstLayer = true;
if (layer == -1) {
mCompositePainter->setCompositionMode(QPainter::CompositionMode_Source);
diff --git a/src/platformsupport/fbconvenience/qfbvthandler.cpp b/src/platformsupport/fbconvenience/qfbvthandler.cpp
index 4c4a01a82e..102bc91647 100644
--- a/src/platformsupport/fbconvenience/qfbvthandler.cpp
+++ b/src/platformsupport/fbconvenience/qfbvthandler.cpp
@@ -39,8 +39,9 @@
#include "qfbvthandler_p.h"
#include <QtCore/QSocketNotifier>
+#include <QtCore/private/qglobal_p.h>
-#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) && (!defined(QT_NO_EVDEV) || !defined(QT_NO_LIBINPUT))
+#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) && (QT_CONFIG(evdev) || QT_CONFIG(libinput))
#define VTH_ENABLED
@@ -171,7 +172,7 @@ void QFbVtHandler::handleSignal()
char sigNo;
if (QT_READ(m_sigFd[1], &sigNo, sizeof(sigNo)) == sizeof(sigNo)) {
switch (sigNo) {
- case SIGINT: // fallthrough
+ case SIGINT:
case SIGTERM:
handleInt();
break;
diff --git a/src/platformsupport/fbconvenience/qfbvthandler_p.h b/src/platformsupport/fbconvenience/qfbvthandler_p.h
index e05a9d3ffc..17d07317b2 100644
--- a/src/platformsupport/fbconvenience/qfbvthandler_p.h
+++ b/src/platformsupport/fbconvenience/qfbvthandler_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QObject>
QT_BEGIN_NAMESPACE
diff --git a/src/platformsupport/fontdatabases/basic/basic.pri b/src/platformsupport/fontdatabases/basic/basic.pri
index d70b3b6a1a..575c93fe20 100644
--- a/src/platformsupport/fontdatabases/basic/basic.pri
+++ b/src/platformsupport/fontdatabases/basic/basic.pri
@@ -1,5 +1,3 @@
-DEFINES += QT_NO_FONTCONFIG
-
HEADERS += \
$$PWD/qbasicfontdatabase_p.h \
$$QT_SOURCE_TREE/src/gui/text/qfontengine_ft_p.h
@@ -8,6 +6,4 @@ SOURCES += \
$$PWD/qbasicfontdatabase.cpp \
$$QT_SOURCE_TREE/src/gui/text/qfontengine_ft.cpp
-CONFIG += opentype
-
include($$QT_SOURCE_TREE/src/3rdparty/freetype_dependency.pri)
diff --git a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp
index 4b9d4690f3..60ddc9fa23 100644
--- a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp
+++ b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp
@@ -77,7 +77,8 @@ void QBasicFontDatabase::populateFontDatabase()
<< QLatin1String("*.pfb")
<< QLatin1String("*.otf");
- foreach (const QFileInfo &fi, dir.entryInfoList(nameFilters, QDir::Files)) {
+ const auto fis = dir.entryInfoList(nameFilters, QDir::Files);
+ for (const QFileInfo &fi : fis) {
const QByteArray file = QFile::encodeName(fi.absoluteFilePath());
QBasicFontDatabase::addTTFile(QByteArray(), file);
}
diff --git a/src/platformsupport/fontdatabases/fontconfig/fontconfig.pri b/src/platformsupport/fontdatabases/fontconfig/fontconfig.pri
index bd7294b818..63097c33c1 100644
--- a/src/platformsupport/fontdatabases/fontconfig/fontconfig.pri
+++ b/src/platformsupport/fontdatabases/fontconfig/fontconfig.pri
@@ -2,5 +2,5 @@ HEADERS += $$PWD/qfontconfigdatabase_p.h \
$$PWD/qfontenginemultifontconfig_p.h
SOURCES += $$PWD/qfontconfigdatabase.cpp \
$$PWD/qfontenginemultifontconfig.cpp
-DEFINES -= QT_NO_FONTCONFIG
+
QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_FONTCONFIG
diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
index 02b7e1bd63..5847c601a8 100644
--- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
@@ -504,7 +504,7 @@ static void populateFromPattern(FcPattern *pattern)
void QFontconfigDatabase::populateFontDatabase()
{
- FcInitReinitialize();
+ FcInit();
FcFontSet *fonts;
{
@@ -568,6 +568,12 @@ void QFontconfigDatabase::populateFontDatabase()
// QApplication::setFont(font);
}
+void QFontconfigDatabase::invalidate()
+{
+ // Clear app fonts.
+ FcConfigAppFontClear(0);
+}
+
QFontEngineMulti *QFontconfigDatabase::fontEngineMulti(QFontEngine *fontEngine, QChar::Script script)
{
return new QFontEngineMultiFontConfig(fontEngine, script);
diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h
index 197a442d5b..244558b910 100644
--- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h
+++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase_p.h
@@ -62,6 +62,7 @@ class QFontconfigDatabase : public QBasicFontDatabase
{
public:
void populateFontDatabase() Q_DECL_OVERRIDE;
+ void invalidate() Q_DECL_OVERRIDE;
QFontEngineMulti *fontEngineMulti(QFontEngine *fontEngine, QChar::Script script) Q_DECL_OVERRIDE;
QFontEngine *fontEngine(const QFontDef &fontDef, void *handle) Q_DECL_OVERRIDE;
QFontEngine *fontEngine(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference) Q_DECL_OVERRIDE;
diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp
index ad5908dcc7..7574f9f9e6 100644
--- a/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp
+++ b/src/platformsupport/fontdatabases/fontconfig/qfontenginemultifontconfig.cpp
@@ -50,7 +50,7 @@ QFontEngineMultiFontConfig::QFontEngineMultiFontConfig(QFontEngine *fe, int scri
QFontEngineMultiFontConfig::~QFontEngineMultiFontConfig()
{
- Q_FOREACH (FcPattern *pattern, cachedMatchPatterns) {
+ for (FcPattern *pattern : qAsConst(cachedMatchPatterns)) {
if (pattern)
FcPatternDestroy(pattern);
}
diff --git a/src/platformsupport/fontdatabases/fontdatabases.pri b/src/platformsupport/fontdatabases/fontdatabases.pri
index 12b06d64cc..f8e51f2a6d 100644
--- a/src/platformsupport/fontdatabases/fontdatabases.pri
+++ b/src/platformsupport/fontdatabases/fontdatabases.pri
@@ -1,16 +1,15 @@
-!win32|contains(QT_CONFIG, freetype):!mac {
- include($$PWD/basic/basic.pri)
-}
-
-unix:!mac {
- CONFIG += qpa/genericunixfontdatabase
- include($$PWD/genericunix/genericunix.pri)
- contains(QT_CONFIG,fontconfig) {
- include($$PWD/fontconfig/fontconfig.pri)
+darwin:!if(watchos:CONFIG(simulator, simulator|device)) {
+ include($$PWD/mac/coretext.pri)
+} else {
+ !win32|qtConfig(freetype) {
+ include($$PWD/basic/basic.pri)
}
-}
-mac {
- include($$PWD/mac/coretext.pri)
+ unix {
+ CONFIG += qpa/genericunixfontdatabase
+ include($$PWD/genericunix/genericunix.pri)
+ contains(QT_CONFIG,fontconfig) {
+ include($$PWD/fontconfig/fontconfig.pri)
+ }
+ }
}
-
diff --git a/src/platformsupport/fontdatabases/mac/coretext.pri b/src/platformsupport/fontdatabases/mac/coretext.pri
index ebb64d15b4..4d19a59226 100644
--- a/src/platformsupport/fontdatabases/mac/coretext.pri
+++ b/src/platformsupport/fontdatabases/mac/coretext.pri
@@ -1,15 +1,14 @@
HEADERS += $$PWD/qcoretextfontdatabase_p.h $$PWD/qfontengine_coretext_p.h
OBJECTIVE_SOURCES += $$PWD/qfontengine_coretext.mm $$PWD/qcoretextfontdatabase.mm
-contains(QT_CONFIG, freetype) {
+qtConfig(freetype) {
include($$QT_SOURCE_TREE/src/3rdparty/freetype_dependency.pri)
HEADERS += $$QT_SOURCE_TREE/src/gui/text/qfontengine_ft_p.h
SOURCES += $$QT_SOURCE_TREE/src/gui/text/qfontengine_ft.cpp
- CONFIG += opentype
}
-ios: \
- # On iOS CoreText and CoreGraphics are stand-alone frameworks
+uikit: \
+ # On iOS/tvOS/watchOS CoreText and CoreGraphics are stand-alone frameworks
LIBS_PRIVATE += -framework CoreText -framework CoreGraphics
else: \
# On Mac OS they are part of the ApplicationServices umbrella framework,
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
index 5be7e3aadc..16d65caf86 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
@@ -44,7 +44,7 @@
#if defined(Q_OS_OSX)
#import <AppKit/AppKit.h>
#import <IOKit/graphics/IOGraphicsLib.h>
-#elif defined(Q_OS_IOS)
+#elif defined(QT_PLATFORM_UIKIT)
#import <UIKit/UIFont.h>
#endif
@@ -183,7 +183,7 @@ QCoreTextFontDatabase::QCoreTextFontDatabase(bool useFreeType)
QCoreTextFontDatabase::~QCoreTextFontDatabase()
{
- foreach (CTFontDescriptorRef ref, m_systemFontDescriptors)
+ for (CTFontDescriptorRef ref : qAsConst(m_systemFontDescriptors))
CFRelease(ref);
}
@@ -191,7 +191,7 @@ static CFArrayRef availableFamilyNames()
{
#if defined(Q_OS_OSX)
return CTFontManagerCopyAvailableFontFamilyNames();
-#elif defined(Q_OS_IOS)
+#elif defined(QT_PLATFORM_UIKIT)
return (CFArrayRef) [[UIFont familyNames] retain];
#endif
}
@@ -523,46 +523,37 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo
static QHash<QString, QStringList> fallbackLists;
if (!family.isEmpty()) {
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_8, __IPHONE_6_0)
- // CTFontCopyDefaultCascadeListForLanguages is available in the SDK
- #if QT_MAC_DEPLOYMENT_TARGET_BELOW(__MAC_10_8, __IPHONE_6_0)
- // But we have to feature check at runtime
- if (&CTFontCopyDefaultCascadeListForLanguages)
- #endif
- {
- QCFType<CFMutableDictionaryRef> attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- CFDictionaryAddValue(attributes, kCTFontFamilyNameAttribute, QCFString(family));
- if (QCFType<CTFontDescriptorRef> fontDescriptor = CTFontDescriptorCreateWithAttributes(attributes)) {
- if (QCFType<CTFontRef> font = CTFontCreateWithFontDescriptor(fontDescriptor, 12.0, 0)) {
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- NSArray *languages = [defaults stringArrayForKey: @"AppleLanguages"];
-
- QCFType<CFArrayRef> cascadeList = (CFArrayRef) CTFontCopyDefaultCascadeListForLanguages(font, (CFArrayRef) languages);
- if (cascadeList) {
- QStringList fallbackList;
- const int numCascades = CFArrayGetCount(cascadeList);
- for (int i = 0; i < numCascades; ++i) {
- CTFontDescriptorRef fontFallback = (CTFontDescriptorRef) CFArrayGetValueAtIndex(cascadeList, i);
- QCFString fallbackFamilyName = (CFStringRef) CTFontDescriptorCopyAttribute(fontFallback, kCTFontFamilyNameAttribute);
- fallbackList.append(QCFString::toQString(fallbackFamilyName));
- }
+ QCFType<CFMutableDictionaryRef> attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ CFDictionaryAddValue(attributes, kCTFontFamilyNameAttribute, QCFString(family));
+ if (QCFType<CTFontDescriptorRef> fontDescriptor = CTFontDescriptorCreateWithAttributes(attributes)) {
+ if (QCFType<CTFontRef> font = CTFontCreateWithFontDescriptor(fontDescriptor, 12.0, 0)) {
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+ NSArray *languages = [defaults stringArrayForKey: @"AppleLanguages"];
+
+ QCFType<CFArrayRef> cascadeList = (CFArrayRef) CTFontCopyDefaultCascadeListForLanguages(font, (CFArrayRef) languages);
+ if (cascadeList) {
+ QStringList fallbackList;
+ const int numCascades = CFArrayGetCount(cascadeList);
+ for (int i = 0; i < numCascades; ++i) {
+ CTFontDescriptorRef fontFallback = (CTFontDescriptorRef) CFArrayGetValueAtIndex(cascadeList, i);
+ QCFString fallbackFamilyName = (CFStringRef) CTFontDescriptorCopyAttribute(fontFallback, kCTFontFamilyNameAttribute);
+ fallbackList.append(QCFString::toQString(fallbackFamilyName));
+ }
#if defined(Q_OS_OSX)
- // Since we are only returning a list of default fonts for the current language, we do not
- // cover all unicode completely. This was especially an issue for some of the common script
- // symbols such as mathematical symbols, currency or geometric shapes. To minimize the risk
- // of missing glyphs, we add Arial Unicode MS as a final fail safe, since this covers most
- // of Unicode 2.1.
- if (!fallbackList.contains(QStringLiteral("Arial Unicode MS")))
- fallbackList.append(QStringLiteral("Arial Unicode MS"));
+ // Since we are only returning a list of default fonts for the current language, we do not
+ // cover all unicode completely. This was especially an issue for some of the common script
+ // symbols such as mathematical symbols, currency or geometric shapes. To minimize the risk
+ // of missing glyphs, we add Arial Unicode MS as a final fail safe, since this covers most
+ // of Unicode 2.1.
+ if (!fallbackList.contains(QStringLiteral("Arial Unicode MS")))
+ fallbackList.append(QStringLiteral("Arial Unicode MS"));
#endif
- return fallbackList;
- }
+ return fallbackList;
}
}
}
-#endif
}
// We were not able to find a fallback for the specific family,
@@ -625,7 +616,6 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo
return fallbackLists[styleLookupKey.arg(styleHint)];
}
-#if HAVE_CORETEXT
static CFArrayRef createDescriptorArrayForFont(CTFontRef font, const QString &fileName = QString())
{
CFMutableArrayRef array = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
@@ -643,7 +633,7 @@ static CFArrayRef createDescriptorArrayForFont(CTFontRef font, const QString &fi
// QUrl::fromLocalFile() doesn't accept qrc pseudo-paths like ":/fonts/myfont.ttf".
// Therefore construct from QString with the qrc:// scheme -> "qrc:///fonts/myfont.ttf".
fontURL = QUrl(QStringLiteral("qrc://") + fileName.mid(1)).toCFURL();
- } else if (!fileName.isEmpty()) {
+ } else {
// At this point we hope that filename is in a format that QUrl can handle.
fontURL = QUrl::fromLocalFile(fileName).toCFURL();
}
@@ -658,104 +648,41 @@ static CFArrayRef createDescriptorArrayForFont(CTFontRef font, const QString &fi
CFArrayAppendValue(array, descriptor);
return array;
}
-#endif
QStringList QCoreTextFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName)
{
QCFType<CFArrayRef> fonts;
QStringList families;
-#if HAVE_CORETEXT
- if (&CTFontManagerRegisterGraphicsFont) {
- CFErrorRef error = 0;
- if (!fontData.isEmpty()) {
- QByteArray* fontDataCopy = new QByteArray(fontData);
- QCFType<CGDataProviderRef> dataProvider = CGDataProviderCreateWithData(fontDataCopy,
- fontDataCopy->constData(), fontDataCopy->size(), releaseFontData);
- QCFType<CGFontRef> cgFont = CGFontCreateWithDataProvider(dataProvider);
- if (cgFont) {
- if (CTFontManagerRegisterGraphicsFont(cgFont, &error)) {
- QCFType<CTFontRef> font = CTFontCreateWithGraphicsFont(cgFont, 0.0, NULL, NULL);
- fonts = createDescriptorArrayForFont(font
+ CFErrorRef error = 0;
+ if (!fontData.isEmpty()) {
+ QByteArray* fontDataCopy = new QByteArray(fontData);
+ QCFType<CGDataProviderRef> dataProvider = CGDataProviderCreateWithData(fontDataCopy,
+ fontDataCopy->constData(), fontDataCopy->size(), releaseFontData);
+ QCFType<CGFontRef> cgFont = CGFontCreateWithDataProvider(dataProvider);
+ if (cgFont) {
+ if (CTFontManagerRegisterGraphicsFont(cgFont, &error)) {
+ QCFType<CTFontRef> font = CTFontCreateWithGraphicsFont(cgFont, 0.0, NULL, NULL);
+ fonts = createDescriptorArrayForFont(font
#ifndef QT_NO_FREETYPE
- , m_useFreeType ? fileName : QString()
-#endif
- );
- m_applicationFonts.append(QVariant::fromValue(QCFType<CGFontRef>::constructFromGet(cgFont)));
- }
- }
- } else {
- QCFType<CFURLRef> fontURL = CFURLCreateWithFileSystemPath(NULL, QCFString(fileName), kCFURLPOSIXPathStyle, false);
- if (CTFontManagerRegisterFontsForURL(fontURL, kCTFontManagerScopeProcess, &error)) {
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_6, __IPHONE_7_0)
- if (&CTFontManagerCreateFontDescriptorsFromURL)
- fonts = CTFontManagerCreateFontDescriptorsFromURL(fontURL);
- else
+ , m_useFreeType ? fileName : QString()
#endif
- {
- // We're limited to a single font per file, unless we dive into the font tables
- QCFType<CFMutableDictionaryRef> attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 1,
- &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- CFDictionaryAddValue(attributes, kCTFontURLAttribute, fontURL);
- QCFType<CTFontDescriptorRef> descriptor = CTFontDescriptorCreateWithAttributes(attributes);
- QCFType<CTFontRef> font = CTFontCreateWithFontDescriptor(descriptor, 0.0, NULL);
- fonts = createDescriptorArrayForFont(font);
- }
-
- m_applicationFonts.append(QVariant::fromValue(QCFType<CFURLRef>::constructFromGet(fontURL)));
+ );
+ m_applicationFonts.append(QVariant::fromValue(QCFType<CGFontRef>::constructFromGet(cgFont)));
}
}
-
- if (error) {
- NSLog(@"Unable to register font: %@", error);
- CFRelease(error);
+ } else {
+ QCFType<CFURLRef> fontURL = CFURLCreateWithFileSystemPath(NULL, QCFString(fileName), kCFURLPOSIXPathStyle, false);
+ if (CTFontManagerRegisterFontsForURL(fontURL, kCTFontManagerScopeProcess, &error)) {
+ fonts = CTFontManagerCreateFontDescriptorsFromURL(fontURL);
+ m_applicationFonts.append(QVariant::fromValue(QCFType<CFURLRef>::constructFromGet(fontURL)));
}
}
-#endif
-#if HAVE_CORETEXT && HAVE_ATS
- else
-#endif
-#if HAVE_ATS
- {
- ATSFontContainerRef fontContainer;
- OSStatus e;
-
- if (!fontData.isEmpty()) {
- e = ATSFontActivateFromMemory((void *) fontData.constData(), fontData.size(),
- kATSFontContextLocal, kATSFontFormatUnspecified, NULL,
- kATSOptionFlagsDefault, &fontContainer);
- } else {
- FSRef ref;
- if (FSPathMakeRef(reinterpret_cast<const UInt8 *>(fileName.toUtf8().constData()),
- &ref, 0) != noErr)
- return QStringList();
- e = ATSFontActivateFromFileReference(&ref, kATSFontContextLocal, kATSFontFormatUnspecified, 0,
- kATSOptionFlagsDefault, &fontContainer);
- }
-
- if (e == noErr) {
- ItemCount fontCount = 0;
- e = ATSFontFindFromContainer(fontContainer, kATSOptionFlagsDefault, 0, 0, &fontCount);
- if (e != noErr)
- return QStringList();
-
- QVarLengthArray<ATSFontRef> containedFonts(fontCount);
- e = ATSFontFindFromContainer(fontContainer, kATSOptionFlagsDefault, fontCount, containedFonts.data(), &fontCount);
- if (e != noErr)
- return QStringList();
-
- CFMutableArrayRef fontsArray = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
- for (int i = 0; i < containedFonts.size(); ++i) {
- QCFType<CTFontRef> font = CTFontCreateWithPlatformFont(containedFonts[i], 12.0, NULL, NULL);
- CFArrayAppendValue(fontsArray, QCFType<CTFontDescriptorRef>(CTFontCopyFontDescriptor(font)));
- }
- fonts = fontsArray;
-
- m_applicationFonts.append(QVariant::fromValue(fontContainer));
- }
+ if (error) {
+ NSLog(@"Unable to register font: %@", error);
+ CFRelease(error);
}
-#endif
if (fonts) {
const int numFonts = CFArrayGetCount(fonts);
@@ -852,41 +779,39 @@ static CTFontUIFontType fontTypeFromTheme(QPlatformTheme::Font f)
static CTFontDescriptorRef fontDescriptorFromTheme(QPlatformTheme::Font f)
{
-#ifdef Q_OS_IOS
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_7_0) {
- // Use Dynamic Type to resolve theme fonts if possible, to get
- // correct font sizes and style based on user configuration.
- NSString *textStyle = 0;
- switch (f) {
- case QPlatformTheme::TitleBarFont:
- case QPlatformTheme::HeaderViewFont:
- textStyle = UIFontTextStyleHeadline;
- break;
- case QPlatformTheme::MdiSubWindowTitleFont:
- textStyle = UIFontTextStyleSubheadline;
- break;
- case QPlatformTheme::TipLabelFont:
- case QPlatformTheme::SmallFont:
- textStyle = UIFontTextStyleFootnote;
- break;
- case QPlatformTheme::MiniFont:
- textStyle = UIFontTextStyleCaption2;
- break;
- case QPlatformTheme::FixedFont:
- // Fall back to regular code path, as iOS doesn't provide
- // an appropriate text style for this theme font.
- break;
- default:
- textStyle = UIFontTextStyleBody;
- break;
- }
+#if defined(QT_PLATFORM_UIKIT)
+ // Use Dynamic Type to resolve theme fonts if possible, to get
+ // correct font sizes and style based on user configuration.
+ NSString *textStyle = 0;
+ switch (f) {
+ case QPlatformTheme::TitleBarFont:
+ case QPlatformTheme::HeaderViewFont:
+ textStyle = UIFontTextStyleHeadline;
+ break;
+ case QPlatformTheme::MdiSubWindowTitleFont:
+ textStyle = UIFontTextStyleSubheadline;
+ break;
+ case QPlatformTheme::TipLabelFont:
+ case QPlatformTheme::SmallFont:
+ textStyle = UIFontTextStyleFootnote;
+ break;
+ case QPlatformTheme::MiniFont:
+ textStyle = UIFontTextStyleCaption2;
+ break;
+ case QPlatformTheme::FixedFont:
+ // Fall back to regular code path, as iOS doesn't provide
+ // an appropriate text style for this theme font.
+ break;
+ default:
+ textStyle = UIFontTextStyleBody;
+ break;
+ }
- if (textStyle) {
- UIFontDescriptor *desc = [UIFontDescriptor preferredFontDescriptorWithTextStyle:textStyle];
- return static_cast<CTFontDescriptorRef>(CFBridgingRetain(desc));
- }
+ if (textStyle) {
+ UIFontDescriptor *desc = [UIFontDescriptor preferredFontDescriptorWithTextStyle:textStyle];
+ return static_cast<CTFontDescriptorRef>(CFBridgingRetain(desc));
}
-#endif // Q_OS_IOS
+#endif // Q_OS_IOS, Q_OS_TVOS, Q_OS_WATCHOS
// OSX default case and iOS fallback case
CTFontUIFontType fontType = fontTypeFromTheme(f);
@@ -952,32 +877,16 @@ void QCoreTextFontDatabase::removeApplicationFonts()
if (m_applicationFonts.isEmpty())
return;
- foreach (const QVariant &font, m_applicationFonts) {
-#if HAVE_CORETEXT
- if (&CTFontManagerUnregisterGraphicsFont && &CTFontManagerUnregisterFontsForURL) {
- CFErrorRef error;
- if (font.canConvert(qMetaTypeId<QCFType<CGFontRef> >())) {
- CTFontManagerUnregisterGraphicsFont(font.value<QCFType<CGFontRef> >(), &error);
- } else if (font.canConvert(qMetaTypeId<QCFType<CFURLRef> >())) {
- CTFontManagerUnregisterFontsForURL(font.value<QCFType<CFURLRef> >(), kCTFontManagerScopeProcess, &error);
- }
+ for (const QVariant &font : qAsConst(m_applicationFonts)) {
+ CFErrorRef error;
+ if (font.canConvert(qMetaTypeId<QCFType<CGFontRef> >())) {
+ CTFontManagerUnregisterGraphicsFont(font.value<QCFType<CGFontRef> >(), &error);
+ } else if (font.canConvert(qMetaTypeId<QCFType<CFURLRef> >())) {
+ CTFontManagerUnregisterFontsForURL(font.value<QCFType<CFURLRef> >(), kCTFontManagerScopeProcess, &error);
}
-#endif
-#if HAVE_CORETEXT && HAVE_ATS
- else
-#endif
-#if HAVE_ATS
- if (font.canConvert(qMetaTypeId<ATSFontContainerRef>())) {
- ATSFontDeactivate(font.value<ATSFontContainerRef>(), 0, kATSOptionFlagsDoNotNotify);
- }
-#endif
}
m_applicationFonts.clear();
-
-#if HAVE_ATS
- ATSFontNotify(kATSFontNotifyActionFontsChanged, 0);
-#endif
}
#ifndef QT_NO_FREETYPE
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
index 2cc6b09a15..1bc3522bda 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
@@ -52,27 +52,20 @@
//
#include <qglobal.h>
-#define HAVE_CORETEXT QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_8, __IPHONE_4_1)
-#define HAVE_ATS QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_5, __IPHONE_NA)
#include <qpa/qplatformfontdatabase.h>
#include <qpa/qplatformtheme.h>
#include <private/qcore_mac_p.h>
-#ifndef Q_OS_IOS
+#ifdef Q_OS_OSX
#include <ApplicationServices/ApplicationServices.h>
#else
#include <CoreText/CoreText.h>
#include <CoreGraphics/CoreGraphics.h>
#endif
-#if HAVE_CORETEXT
Q_DECLARE_METATYPE(QCFType<CGFontRef>);
Q_DECLARE_METATYPE(QCFType<CFURLRef>);
-#endif
-#if HAVE_ATS
-Q_DECLARE_METATYPE(ATSFontContainerRef);
-#endif
QT_BEGIN_NAMESPACE
diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
index d11676ced7..0bc0416eec 100644
--- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
+++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
@@ -51,7 +51,7 @@
#import <AppKit/AppKit.h>
#endif
-#if defined(Q_OS_IOS) && !QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_8_2)
+#if defined(QT_PLATFORM_UIKIT) && !QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_8_2)
#import <UIKit/UIKit.h>
#endif
@@ -78,7 +78,7 @@
#define kCTFontWeightBold NSFontWeightBold
#define kCTFontWeightHeavy NSFontWeightHeavy
#define kCTFontWeightBlack NSFontWeightBlack
-#elif defined(Q_OS_IOS)
+#elif defined(QT_PLATFORM_UIKIT)
#define kCTFontWeightUltraLight UIFontWeightUltraLight
#define kCTFontWeightThin UIFontWeightThin
#define kCTFontWeightLight UIFontWeightLight
@@ -172,7 +172,7 @@ QFontEngine::GlyphFormat QCoreTextFontEngine::defaultGlyphFormat = QFontEngine::
CGAffineTransform qt_transform_from_fontdef(const QFontDef &fontDef)
{
CGAffineTransform transform = CGAffineTransformIdentity;
- if (fontDef.stretch != 100)
+ if (fontDef.stretch && fontDef.stretch != 100)
transform = CGAffineTransformMakeScale(float(fontDef.stretch) / float(100), 1);
return transform;
}
@@ -256,6 +256,9 @@ void QCoreTextFontEngine::init()
} else
avgCharWidth = QFontEngine::averageCharWidth();
+ underlineThickness = QFixed::fromReal(CTFontGetUnderlineThickness(ctfont));
+ underlinePos = -QFixed::fromReal(CTFontGetUnderlinePosition(ctfont));
+
cache_cost = (CTFontGetAscent(ctfont) + CTFontGetDescent(ctfont)) * avgCharWidth.toInt() * 2000;
// HACK hb_coretext requires both CTFont and CGFont but user_data is only void*
@@ -375,6 +378,19 @@ QFixed QCoreTextFontEngine::ascent() const
? QFixed::fromReal(CTFontGetAscent(ctfont)).round()
: QFixed::fromReal(CTFontGetAscent(ctfont));
}
+
+QFixed QCoreTextFontEngine::capHeight() const
+{
+ QFixed c = QFixed::fromReal(CTFontGetCapHeight(ctfont));
+ if (c <= 0)
+ return calculatedCapHeight();
+
+ if (fontDef.styleStrategy & QFont::ForceIntegerMetrics)
+ c = c.round();
+
+ return c;
+}
+
QFixed QCoreTextFontEngine::descent() const
{
QFixed d = QFixed::fromReal(CTFontGetDescent(ctfont));
@@ -437,31 +453,25 @@ void QCoreTextFontEngine::draw(CGContextRef ctx, qreal x, qreal y, const QTextIt
CGContextSetTextDrawingMode(ctx, kCGTextFill);
-
- QVarLengthArray<CGSize> advances(glyphs.size());
+ QVarLengthArray<CGPoint> cgPositions(glyphs.size());
QVarLengthArray<CGGlyph> cgGlyphs(glyphs.size());
-
- for (int i = 0; i < glyphs.size() - 1; ++i) {
- advances[i].width = (positions[i + 1].x - positions[i].x).toReal();
- advances[i].height = (positions[i + 1].y - positions[i].y).toReal();
+ const qreal firstX = positions[0].x.toReal();
+ const qreal firstY = positions[0].y.toReal();
+ for (int i = 0; i < glyphs.size(); ++i) {
+ cgPositions[i].x = positions[i].x.toReal() - firstX;
+ cgPositions[i].y = positions[i].y.toReal() - firstY;
cgGlyphs[i] = glyphs[i];
}
- advances[glyphs.size() - 1].width = 0;
- advances[glyphs.size() - 1].height = 0;
- cgGlyphs[glyphs.size() - 1] = glyphs[glyphs.size() - 1];
- CGContextSetFont(ctx, cgFont);
//NSLog(@"Font inDraw %@ ctfont %@", CGFontCopyFullName(cgFont), CTFontCopyFamilyName(ctfont));
CGContextSetTextPosition(ctx, positions[0].x.toReal(), positions[0].y.toReal());
-
- CGContextShowGlyphsWithAdvances(ctx, cgGlyphs.data(), advances.data(), glyphs.size());
+ CTFontDrawGlyphs(ctfont, cgGlyphs.data(), cgPositions.data(), glyphs.size(), ctx);
if (synthesisFlags & QFontEngine::SynthesizedBold) {
CGContextSetTextPosition(ctx, positions[0].x.toReal() + 0.5 * lineThickness().toReal(),
positions[0].y.toReal());
-
- CGContextShowGlyphsWithAdvances(ctx, cgGlyphs.data(), advances.data(), glyphs.size());
+ CTFontDrawGlyphs(ctfont, cgGlyphs.data(), cgPositions.data(), glyphs.size(), ctx);
}
CGContextSetTextMatrix(ctx, oldTextMatrix);
@@ -606,7 +616,7 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition
if (!im.width() || !im.height())
return im;
-#ifndef Q_OS_IOS
+#ifdef Q_OS_OSX
CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
#else
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
@@ -645,14 +655,13 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition
CGContextSetTextMatrix(ctx, cgMatrix);
CGContextSetRGBFillColor(ctx, 1, 1, 1, 1);
CGContextSetTextDrawingMode(ctx, kCGTextFill);
- CGContextSetFont(ctx, cgFont);
CGContextSetTextPosition(ctx, pos_x, pos_y);
- CGContextShowGlyphsWithAdvances(ctx, &cgGlyph, &CGSizeZero, 1);
+ CTFontDrawGlyphs(ctfont, &cgGlyph, &CGPointZero, 1, ctx);
if (synthesisFlags & QFontEngine::SynthesizedBold) {
CGContextSetTextPosition(ctx, pos_x + 0.5 * lineThickness().toReal(), pos_y);
- CGContextShowGlyphsWithAdvances(ctx, &cgGlyph, &CGSizeZero, 1);
+ CTFontDrawGlyphs(ctfont, &cgGlyph, &CGPointZero, 1, ctx);
}
} else {
// CGContextSetTextMatrix does not work with color glyphs, so we use
@@ -800,6 +809,16 @@ bool QCoreTextFontEngine::supportsTransformation(const QTransform &transform) co
return false;
}
+QFixed QCoreTextFontEngine::lineThickness() const
+{
+ return underlineThickness;
+}
+
+QFixed QCoreTextFontEngine::underlinePosition() const
+{
+ return underlinePos;
+}
+
QFontEngine::Properties QCoreTextFontEngine::properties() const
{
Properties result;
diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
index 22008162f7..d9ffbb5697 100644
--- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
+++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
@@ -54,7 +54,7 @@
#include <private/qfontengine_p.h>
#include <private/qcore_mac_p.h>
-#ifndef Q_OS_IOS
+#ifdef Q_OS_OSX
#include <ApplicationServices/ApplicationServices.h>
#else
#include <CoreText/CoreText.h>
@@ -78,6 +78,7 @@ public:
glyph_metrics_t boundingBox(glyph_t glyph) Q_DECL_OVERRIDE;
QFixed ascent() const Q_DECL_OVERRIDE;
+ QFixed capHeight() const Q_DECL_OVERRIDE;
QFixed descent() const Q_DECL_OVERRIDE;
QFixed leading() const Q_DECL_OVERRIDE;
QFixed xHeight() const Q_DECL_OVERRIDE;
@@ -92,6 +93,9 @@ public:
int synthesized() const Q_DECL_OVERRIDE { return synthesisFlags; }
bool supportsSubPixelPositions() const Q_DECL_OVERRIDE { return true; }
+ QFixed lineThickness() const Q_DECL_OVERRIDE;
+ QFixed underlinePosition() const Q_DECL_OVERRIDE;
+
void draw(CGContextRef ctx, qreal x, qreal y, const QTextItemInt &ti, int paintDeviceHeight);
FaceId faceId() const Q_DECL_OVERRIDE;
@@ -126,6 +130,8 @@ private:
int synthesisFlags;
CGAffineTransform transform;
QFixed avgCharWidth;
+ QFixed underlineThickness;
+ QFixed underlinePos;
QFontEngine::FaceId face_id;
mutable bool kerningPairsLoaded;
};
diff --git a/src/platformsupport/glxconvenience/glxconvenience.pri b/src/platformsupport/glxconvenience/glxconvenience.pri
index cc5b198f6c..80e79ee663 100644
--- a/src/platformsupport/glxconvenience/glxconvenience.pri
+++ b/src/platformsupport/glxconvenience/glxconvenience.pri
@@ -1,6 +1,6 @@
-contains(QT_CONFIG, xlib) {
- contains(QT_CONFIG,opengl):!contains(QT_CONFIG,opengles2) {
- contains(QT_CONFIG, xrender): LIBS_PRIVATE += -lXrender
+qtConfig(xlib) {
+ qtConfig(opengl):!qtConfig(opengles2) {
+ qtConfig(xrender): QMAKE_USE_PRIVATE += xrender
LIBS_PRIVATE += $$QMAKE_LIBS_X11
HEADERS += $$PWD/qglxconvenience_p.h
SOURCES += $$PWD/qglxconvenience.cpp
diff --git a/src/platformsupport/graphics/qrasterbackingstore.cpp b/src/platformsupport/graphics/qrasterbackingstore.cpp
index 3b1a87b8cd..325c98b93d 100644
--- a/src/platformsupport/graphics/qrasterbackingstore.cpp
+++ b/src/platformsupport/graphics/qrasterbackingstore.cpp
@@ -62,13 +62,20 @@ void QRasterBackingStore::resize(const QSize &size, const QRegion &staticContent
if (m_image.size() == effectiveBufferSize)
return;
- QImage::Format format = window()->format().hasAlpha() ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
- m_image = QImage(effectiveBufferSize, format);
+ m_image = QImage(effectiveBufferSize, format());
m_image.setDevicePixelRatio(windowDevicePixelRatio);
- if (format == QImage::Format_ARGB32_Premultiplied)
+ if (m_image.format() == QImage::Format_ARGB32_Premultiplied)
m_image.fill(Qt::transparent);
}
+QImage::Format QRasterBackingStore::format() const
+{
+ if (window()->format().hasAlpha())
+ return QImage::Format_ARGB32_Premultiplied;
+ else
+ return QImage::Format_RGB32;
+}
+
QPaintDevice *QRasterBackingStore::paintDevice()
{
return &m_image;
@@ -89,7 +96,7 @@ bool QRasterBackingStore::scroll(const QRegion &region, int dx, int dy)
const qreal devicePixelRatio = m_image.devicePixelRatio();
const QPoint delta(dx * devicePixelRatio, dy * devicePixelRatio);
- foreach (const QRect &rect, region.rects())
+ for (const QRect &rect : region)
qt_scrollRectInImage(m_image, QRect(rect.topLeft() * devicePixelRatio, rect.size() * devicePixelRatio), delta);
return true;
@@ -103,7 +110,7 @@ void QRasterBackingStore::beginPaint(const QRegion &region)
QPainter painter(&m_image);
painter.setCompositionMode(QPainter::CompositionMode_Source);
const QColor blank = Qt::transparent;
- foreach (const QRect &rect, region.rects())
+ for (const QRect &rect : region)
painter.fillRect(rect, blank);
}
diff --git a/src/platformsupport/graphics/qrasterbackingstore_p.h b/src/platformsupport/graphics/qrasterbackingstore_p.h
index de96c99b5a..55976d2ceb 100644
--- a/src/platformsupport/graphics/qrasterbackingstore_p.h
+++ b/src/platformsupport/graphics/qrasterbackingstore_p.h
@@ -62,13 +62,16 @@ public:
QRasterBackingStore(QWindow *window);
~QRasterBackingStore();
- QPaintDevice *paintDevice() Q_DECL_OVERRIDE;
- QImage toImage() const Q_DECL_OVERRIDE;
- void resize (const QSize &size, const QRegion &) Q_DECL_OVERRIDE;
+ void resize(const QSize &size, const QRegion &staticContents) Q_DECL_OVERRIDE;
bool scroll(const QRegion &area, int dx, int dy) Q_DECL_OVERRIDE;
void beginPaint(const QRegion &region) Q_DECL_OVERRIDE;
+ QPaintDevice *paintDevice() Q_DECL_OVERRIDE;
+ QImage toImage() const Q_DECL_OVERRIDE;
+
protected:
+ virtual QImage::Format format() const;
+
QImage m_image;
};
diff --git a/src/platformsupport/input/evdevkeyboard/evdevkeyboard.pri b/src/platformsupport/input/evdevkeyboard/evdevkeyboard.pri
index c058498ba0..445f230fa5 100644
--- a/src/platformsupport/input/evdevkeyboard/evdevkeyboard.pri
+++ b/src/platformsupport/input/evdevkeyboard/evdevkeyboard.pri
@@ -7,6 +7,5 @@ SOURCES += \
$$PWD/qevdevkeyboardhandler.cpp \
$$PWD/qevdevkeyboardmanager.cpp
-contains(QT_CONFIG, libudev) {
- LIBS_PRIVATE += $$QMAKE_LIBS_LIBUDEV
-}
+qtConfig(libudev): \
+ QMAKE_USE_PRIVATE += libudev
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp
index ffe9f82325..94ebae8f42 100644
--- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp
+++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp
@@ -84,10 +84,9 @@ QEvdevKeyboardManager::QEvdevKeyboardManager(const QString &key, const QString &
m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Keyboard, this);
if (m_deviceDiscovery) {
// scan and add already connected keyboards
- QStringList devices = m_deviceDiscovery->scanConnectedDevices();
- foreach (const QString &device, devices) {
+ const QStringList devices = m_deviceDiscovery->scanConnectedDevices();
+ for (const QString &device : devices)
addKeyboard(device);
- }
connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addKeyboard(QString)));
connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeKeyboard(QString)));
diff --git a/src/platformsupport/input/evdevmouse/evdevmouse.pri b/src/platformsupport/input/evdevmouse/evdevmouse.pri
index 7e7a9e1629..a8c9c663f3 100644
--- a/src/platformsupport/input/evdevmouse/evdevmouse.pri
+++ b/src/platformsupport/input/evdevmouse/evdevmouse.pri
@@ -6,7 +6,6 @@ SOURCES += \
$$PWD/qevdevmousehandler.cpp \
$$PWD/qevdevmousemanager.cpp
-contains(QT_CONFIG, libudev) {
- LIBS_PRIVATE += $$QMAKE_LIBS_LIBUDEV
-}
+qtConfig(libudev): \
+ QMAKE_USE_PRIVATE += libudev
diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp
index 129654c99b..2d96691b09 100644
--- a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp
+++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp
@@ -90,10 +90,9 @@ QEvdevMouseManager::QEvdevMouseManager(const QString &key, const QString &specif
m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Mouse | QDeviceDiscovery::Device_Touchpad, this);
if (m_deviceDiscovery) {
// scan and add already connected keyboards
- QStringList devices = m_deviceDiscovery->scanConnectedDevices();
- foreach (const QString &device, devices) {
+ const QStringList devices = m_deviceDiscovery->scanConnectedDevices();
+ for (const QString &device : devices)
addMouse(device);
- }
connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addMouse(QString)));
connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeMouse(QString)));
diff --git a/src/platformsupport/input/evdevtablet/evdevtablet.pri b/src/platformsupport/input/evdevtablet/evdevtablet.pri
index fb9489353c..ea1712ad2f 100644
--- a/src/platformsupport/input/evdevtablet/evdevtablet.pri
+++ b/src/platformsupport/input/evdevtablet/evdevtablet.pri
@@ -6,6 +6,5 @@ SOURCES += \
$$PWD/qevdevtablethandler.cpp \
$$PWD/qevdevtabletmanager.cpp
-contains(QT_CONFIG, libudev) {
- LIBS_PRIVATE += $$QMAKE_LIBS_LIBUDEV
-}
+qtConfig(libudev): \
+ QMAKE_USE_PRIVATE += libudev
diff --git a/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp b/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp
index 00a8c7a65d..89a60df98d 100644
--- a/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp
+++ b/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp
@@ -85,8 +85,8 @@ QEvdevTabletManager::QEvdevTabletManager(const QString &key, const QString &spec
qCDebug(qLcEvdevTablet) << "evdevtablet: Using device discovery";
m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Tablet, this);
if (m_deviceDiscovery) {
- QStringList devices = m_deviceDiscovery->scanConnectedDevices();
- foreach (const QString &device, devices)
+ const QStringList devices = m_deviceDiscovery->scanConnectedDevices();
+ for (const QString &device : devices)
addDevice(device);
connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addDevice(QString)));
connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeDevice(QString)));
diff --git a/src/platformsupport/input/evdevtouch/evdevtouch.pri b/src/platformsupport/input/evdevtouch/evdevtouch.pri
index c2edc13143..58fafcd8f9 100644
--- a/src/platformsupport/input/evdevtouch/evdevtouch.pri
+++ b/src/platformsupport/input/evdevtouch/evdevtouch.pri
@@ -6,12 +6,12 @@ SOURCES += \
$$PWD/qevdevtouchhandler.cpp \
$$PWD/qevdevtouchmanager.cpp
-contains(QT_CONFIG, libudev) {
- LIBS_PRIVATE += $$QMAKE_LIBS_LIBUDEV
-}
+INCLUDEPATH += $$PWD/../shared
+
+qtConfig(libudev): \
+ QMAKE_USE_PRIVATE += libudev
-contains(QT_CONFIG, mtdev) {
+qtConfig(mtdev) {
CONFIG += link_pkgconfig
PKGCONFIG_PRIVATE += mtdev
}
-
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
index 435f411f96..32ec9d5452 100644
--- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
+++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
@@ -38,6 +38,7 @@
****************************************************************************/
#include "qevdevtouchhandler_p.h"
+#include "qtouchoutputmapping_p.h"
#include <QStringList>
#include <QHash>
#include <QSocketNotifier>
@@ -49,7 +50,7 @@
#include <QtGui/private/qguiapplication_p.h>
#include <linux/input.h>
-#if !defined(QT_NO_MTDEV)
+#if QT_CONFIG(mtdev)
extern "C" {
#include <mtdev.h>
}
@@ -116,6 +117,7 @@ public:
int findClosestContact(const QHash<int, Contact> &contacts, int x, int y, int *dist);
void addTouchPoint(const Contact &contact, Qt::TouchPointStates *combinedStates);
void reportPoints();
+ void loadMultiScreenMappings();
int hw_range_x_min;
int hw_range_x_max;
@@ -124,10 +126,12 @@ public:
int hw_pressure_min;
int hw_pressure_max;
QString hw_name;
+ QString deviceNode;
bool m_forceToActiveWindow;
bool m_typeB;
QTransform m_rotate;
bool m_singleTouch;
+ int m_screenIndex;
};
QEvdevTouchScreenData::QEvdevTouchScreenData(QEvdevTouchScreenHandler *q_ptr, const QStringList &args)
@@ -137,7 +141,8 @@ QEvdevTouchScreenData::QEvdevTouchScreenData(QEvdevTouchScreenHandler *q_ptr, co
hw_range_x_min(0), hw_range_x_max(0),
hw_range_y_min(0), hw_range_y_max(0),
hw_pressure_min(0), hw_pressure_max(0),
- m_typeB(false), m_singleTouch(false)
+ m_typeB(false), m_singleTouch(false),
+ m_screenIndex(-1)
{
m_forceToActiveWindow = args.contains(QLatin1String("force_window"));
}
@@ -145,7 +150,7 @@ QEvdevTouchScreenData::QEvdevTouchScreenData(QEvdevTouchScreenHandler *q_ptr, co
#define LONG_BITS (sizeof(long) << 3)
#define NUM_LONGS(bits) (((bits) + LONG_BITS - 1) / LONG_BITS)
-#if defined(QT_NO_MTDEV)
+#if !QT_CONFIG(mtdev)
static inline bool testBit(long bit, const long *array)
{
return (array[bit / LONG_BITS] >> bit % LONG_BITS) & 1;
@@ -154,7 +159,7 @@ static inline bool testBit(long bit, const long *array)
QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const QString &spec, QObject *parent)
: QObject(parent), m_notify(Q_NULLPTR), m_fd(-1), d(Q_NULLPTR), m_device(Q_NULLPTR)
-#if !defined(QT_NO_MTDEV)
+#if QT_CONFIG(mtdev)
, m_mtdev(Q_NULLPTR)
#endif
{
@@ -198,7 +203,7 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const
return;
}
-#if !defined(QT_NO_MTDEV)
+#if QT_CONFIG(mtdev)
m_mtdev = static_cast<mtdev *>(calloc(1, sizeof(mtdev)));
int mtdeverr = mtdev_open(m_mtdev, m_fd);
if (mtdeverr) {
@@ -210,7 +215,7 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const
d = new QEvdevTouchScreenData(this, args);
-#if !defined(QT_NO_MTDEV)
+#if QT_CONFIG(mtdev)
const char *mtdevStr = "(mtdev)";
d->m_typeB = true;
#else
@@ -222,7 +227,9 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const
}
#endif
- qCDebug(qLcEvdevTouch, "evdevtouch: %s: Protocol type %c %s (%s)", qPrintable(device),
+ d->deviceNode = device;
+
+ qCDebug(qLcEvdevTouch, "evdevtouch: %s: Protocol type %c %s (%s)", qPrintable(d->deviceNode),
d->m_typeB ? 'B' : 'A', mtdevStr, d->m_singleTouch ? "single" : "multi");
input_absinfo absInfo;
@@ -292,12 +299,20 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const
if (inverty)
d->m_rotate *= QTransform::fromTranslate(0.5, 0.5).scale(1.0, -1.0).translate(-0.5, -0.5);
+ QTouchOutputMapping mapping;
+ if (mapping.load()) {
+ d->m_screenIndex = mapping.screenIndexForDeviceNode(d->deviceNode);
+ if (d->m_screenIndex >= 0)
+ qCDebug(qLcEvdevTouch, "evdevtouch: Mapping device %s to screen index %d",
+ qPrintable(d->deviceNode), d->m_screenIndex);
+ }
+
registerTouchDevice();
}
QEvdevTouchScreenHandler::~QEvdevTouchScreenHandler()
{
-#if !defined(QT_NO_MTDEV)
+#if QT_CONFIG(mtdev)
if (m_mtdev) {
mtdev_close(m_mtdev);
free(m_mtdev);
@@ -322,7 +337,7 @@ void QEvdevTouchScreenHandler::readData()
::input_event buffer[32];
int events = 0;
-#if !defined(QT_NO_MTDEV)
+#if QT_CONFIG(mtdev)
forever {
do {
events = mtdev_get(m_mtdev, m_fd, buffer, sizeof(buffer) / sizeof(::input_event));
@@ -647,8 +662,23 @@ void QEvdevTouchScreenData::reportPoints()
return;
winRect = QHighDpi::toNativePixels(win->geometry(), win);
} else {
- QScreen *primary = QGuiApplication::primaryScreen();
- winRect = QHighDpi::toNativePixels(primary->geometry(), primary);
+ // Now it becomes tricky. Traditionally we picked the primaryScreen()
+ // and were done with it. But then, enter multiple screens, and
+ // suddenly it was all broken.
+ //
+ // For now we only support the display configuration of the KMS/DRM
+ // backends of eglfs. See QTouchOutputMapping.
+ //
+ // The good news it that once winRect refers to the correct screen
+ // geometry in the full virtual desktop space, there is nothing else
+ // left to do since qguiapp will handle the rest.
+ QScreen *screen = QGuiApplication::primaryScreen();
+ if (m_screenIndex >= 0) {
+ const QList<QScreen *> screens = QGuiApplication::screens();
+ if (m_screenIndex < screens.count())
+ screen = screens.at(m_screenIndex);
+ }
+ winRect = QHighDpi::toNativePixels(screen->geometry(), screen);
}
const int hw_w = hw_range_x_max - hw_range_x_min;
@@ -679,10 +709,12 @@ void QEvdevTouchScreenData::reportPoints()
tp.pressure = (tp.pressure - hw_pressure_min) / qreal(hw_pressure_max - hw_pressure_min);
}
+ // Let qguiapp pick the target window.
QWindowSystemInterface::handleTouchEvent(Q_NULLPTR, q->touchDevice(), m_touchPoints);
}
+
QEvdevTouchScreenHandlerThread::QEvdevTouchScreenHandlerThread(const QString &device, const QString &spec, QObject *parent)
: QDaemonThread(parent), m_device(device), m_spec(spec), m_handler(Q_NULLPTR), m_touchDeviceRegistered(false)
{
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h b/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h
index a423bbd2ef..6554d4998c 100644
--- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h
+++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QObject>
#include <QString>
#include <QList>
@@ -58,7 +59,7 @@
#include <QtCore/private/qthread_p.h>
#include <qpa/qwindowsysteminterface.h>
-#if !defined(QT_NO_MTDEV)
+#if QT_CONFIG(mtdev)
struct mtdev;
#endif
@@ -88,7 +89,7 @@ private:
int m_fd;
QEvdevTouchScreenData *d;
QTouchDevice *m_device;
-#if !defined(QT_NO_MTDEV)
+#if QT_CONFIG(mtdev)
mtdev *m_mtdev;
#endif
};
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp
index 2de0816ef5..d0c6c10224 100644
--- a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp
+++ b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp
@@ -85,8 +85,8 @@ QEvdevTouchManager::QEvdevTouchManager(const QString &key, const QString &specif
qCDebug(qLcEvdevTouch) << "evdevtouch: Using device discovery";
m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Touchpad | QDeviceDiscovery::Device_Touchscreen, this);
if (m_deviceDiscovery) {
- QStringList devices = m_deviceDiscovery->scanConnectedDevices();
- foreach (const QString &device, devices)
+ const QStringList devices = m_deviceDiscovery->scanConnectedDevices();
+ for (const QString &device : devices)
addDevice(device);
connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addDevice(QString)));
connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeDevice(QString)));
diff --git a/src/platformsupport/input/input.pri b/src/platformsupport/input/input.pri
index 3b9593eb31..eb4d8a983d 100644
--- a/src/platformsupport/input/input.pri
+++ b/src/platformsupport/input/input.pri
@@ -1,14 +1,18 @@
-contains(QT_CONFIG, evdev) {
+qtConfig(evdev) {
include($$PWD/evdevmouse/evdevmouse.pri)
include($$PWD/evdevkeyboard/evdevkeyboard.pri)
include($$PWD/evdevtouch/evdevtouch.pri)
include($$PWD/evdevtablet/evdevtablet.pri)
}
-contains(QT_CONFIG, tslib) {
+qtConfig(tslib) {
include($$PWD/tslib/tslib.pri)
}
-contains(QT_CONFIG, libinput) {
+qtConfig(libinput) {
include($$PWD/libinput/libinput.pri)
}
+
+qtConfig(evdev)|qtConfig(libinput) {
+ include($$PWD/shared/shared.pri)
+}
diff --git a/src/platformsupport/input/libinput/libinput.pri b/src/platformsupport/input/libinput/libinput.pri
index 35d962ff3c..f922769a37 100644
--- a/src/platformsupport/input/libinput/libinput.pri
+++ b/src/platformsupport/input/libinput/libinput.pri
@@ -10,14 +10,11 @@ SOURCES += \
$$PWD/qlibinputkeyboard.cpp \
$$PWD/qlibinputtouch.cpp
-INCLUDEPATH += $$QMAKE_INCDIR_LIBUDEV $$QMAKE_INCDIR_LIBINPUT
-LIBS_PRIVATE += $$QMAKE_LIBS_LIBUDEV $$QMAKE_LIBS_LIBINPUT
+QMAKE_USE_PRIVATE += libudev libinput
-contains(QT_CONFIG, xkbcommon-evdev) {
- INCLUDEPATH += $$QMAKE_INCDIR_XKBCOMMON_EVDEV
- LIBS_PRIVATE += $$QMAKE_LIBS_XKBCOMMON_EVDEV
-} else {
- DEFINES += QT_NO_XKBCOMMON_EVDEV
-}
+INCLUDEPATH += $$PWD/../shared
-DEFINES += QT_LIBINPUT_VERSION_MAJOR=$$QMAKE_LIBINPUT_VERSION_MAJOR QT_LIBINPUT_VERSION_MINOR=$$QMAKE_LIBINPUT_VERSION_MINOR
+qtConfig(xkbcommon-evdev): \
+ QMAKE_USE_PRIVATE += xkbcommon_evdev
+else: \
+ DEFINES += QT_NO_XKBCOMMON_EVDEV
diff --git a/src/platformsupport/input/libinput/qlibinputpointer.cpp b/src/platformsupport/input/libinput/qlibinputpointer.cpp
index d5a3a8b437..3b583ec99d 100644
--- a/src/platformsupport/input/libinput/qlibinputpointer.cpp
+++ b/src/platformsupport/input/libinput/qlibinputpointer.cpp
@@ -96,7 +96,7 @@ void QLibInputPointer::processMotion(libinput_event_pointer *e)
void QLibInputPointer::processAxis(libinput_event_pointer *e)
{
-#if QT_LIBINPUT_VERSION_MAJOR == 0 && QT_LIBINPUT_VERSION_MINOR <= 7
+#if QT_LIBRARY_VERSION(libinput) < QT_VERSION_CHECK(0, 8, 0)
const double v = libinput_event_pointer_get_axis_value(e) * 120;
const Qt::Orientation ori = libinput_event_pointer_get_axis(e) == LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL
? Qt::Vertical : Qt::Horizontal;
diff --git a/src/platformsupport/input/libinput/qlibinputtouch.cpp b/src/platformsupport/input/libinput/qlibinputtouch.cpp
index 0a0e9daccb..42925a18e1 100644
--- a/src/platformsupport/input/libinput/qlibinputtouch.cpp
+++ b/src/platformsupport/input/libinput/qlibinputtouch.cpp
@@ -41,6 +41,7 @@
#include <libinput.h>
#include <QtGui/QGuiApplication>
#include <QtGui/QScreen>
+#include <QtGui/private/qhighdpiscaling_p.h>
QT_BEGIN_NAMESPACE
@@ -63,10 +64,14 @@ QLibInputTouch::DeviceState *QLibInputTouch::deviceState(libinput_event_touch *e
static inline QPointF getPos(libinput_event_touch *e)
{
- const QSize screenSize = QGuiApplication::primaryScreen()->geometry().size();
- const double x = libinput_event_touch_get_x_transformed(e, screenSize.width());
- const double y = libinput_event_touch_get_y_transformed(e, screenSize.height());
- return QPointF(x, y);
+ // TODO Map to correct screen using QTouchOutputMapping.
+ // Perhaps investigate libinput_device_get_output_name as well.
+ // For now just use the primary screen.
+ QScreen *screen = QGuiApplication::primaryScreen();
+ const QRect geom = QHighDpi::toNativePixels(screen->geometry(), screen);
+ const double x = libinput_event_touch_get_x_transformed(e, geom.width());
+ const double y = libinput_event_touch_get_y_transformed(e, geom.height());
+ return geom.topLeft() + QPointF(x, y);
}
void QLibInputTouch::registerDevice(libinput_device *dev)
diff --git a/src/platformsupport/input/shared/qtouchoutputmapping.cpp b/src/platformsupport/input/shared/qtouchoutputmapping.cpp
new file mode 100644
index 0000000000..55c1dc34f4
--- /dev/null
+++ b/src/platformsupport/input/shared/qtouchoutputmapping.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtouchoutputmapping_p.h"
+#include <QFile>
+#include <QVariantMap>
+#include <QJsonDocument>
+#include <QJsonObject>
+#include <QJsonArray>
+
+QT_BEGIN_NAMESPACE
+
+bool QTouchOutputMapping::load()
+{
+ static QByteArray configFile = qgetenv("QT_QPA_EGLFS_KMS_CONFIG");
+ if (configFile.isEmpty())
+ return false;
+
+ QFile file(QString::fromUtf8(configFile));
+ if (!file.open(QFile::ReadOnly)) {
+ qWarning("touch input support: Failed to open %s", configFile.constData());
+ return false;
+ }
+
+ const QJsonDocument doc = QJsonDocument::fromJson(file.readAll());
+ if (!doc.isObject()) {
+ qWarning("touch input support: Failed to parse %s", configFile.constData());
+ return false;
+ }
+
+ // What we are interested is the virtualIndex and touchDevice properties for
+ // each element in the outputs array.
+ const QJsonArray outputs = doc.object().value(QLatin1String("outputs")).toArray();
+ for (int i = 0; i < outputs.size(); ++i) {
+ const QVariantMap output = outputs.at(i).toObject().toVariantMap();
+ if (!output.contains(QStringLiteral("touchDevice")))
+ continue;
+ if (!output.contains(QStringLiteral("virtualIndex"))) {
+ qWarning("evdevtouch: Output %d specifies touchDevice but not virtualIndex, this is wrong", i);
+ continue;
+ }
+ const QString &deviceNode = output.value(QStringLiteral("touchDevice")).toString();
+ const int screenIndex = output.value(QStringLiteral("virtualIndex")).toInt();
+ m_screenIndexTable.insert(deviceNode, screenIndex);
+ }
+
+ return true;
+}
+
+int QTouchOutputMapping::screenIndexForDeviceNode(const QString &deviceNode)
+{
+ return m_screenIndexTable.value(deviceNode, -1);
+}
+
+QT_END_NAMESPACE
diff --git a/src/platformsupport/input/shared/qtouchoutputmapping_p.h b/src/platformsupport/input/shared/qtouchoutputmapping_p.h
new file mode 100644
index 0000000000..74999d93ce
--- /dev/null
+++ b/src/platformsupport/input/shared/qtouchoutputmapping_p.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTOUCHOUTPUTMAPPING_P_H
+#define QTOUCHOUTPUTMAPPING_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QString>
+#include <QHash>
+
+QT_BEGIN_NAMESPACE
+
+class QTouchOutputMapping
+{
+public:
+ bool load();
+ int screenIndexForDeviceNode(const QString &deviceNode);
+
+private:
+ QHash<QString, int> m_screenIndexTable;
+};
+
+QT_END_NAMESPACE
+
+#endif // QTOUCHOUTPUTMAPPING_P_H
diff --git a/src/platformsupport/input/shared/shared.pri b/src/platformsupport/input/shared/shared.pri
new file mode 100644
index 0000000000..1443235244
--- /dev/null
+++ b/src/platformsupport/input/shared/shared.pri
@@ -0,0 +1,5 @@
+HEADERS += \
+ $$PWD/qtouchoutputmapping_p.h
+
+SOURCES += \
+ $$PWD/qtouchoutputmapping.cpp
diff --git a/src/platformsupport/input/tslib/tslib.pri b/src/platformsupport/input/tslib/tslib.pri
index c9fef1ca8f..9efd126e13 100644
--- a/src/platformsupport/input/tslib/tslib.pri
+++ b/src/platformsupport/input/tslib/tslib.pri
@@ -4,4 +4,4 @@ HEADERS += \
SOURCES += \
$$PWD/qtslib.cpp
-LIBS += -lts
+QMAKE_USE += tslib
diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
index 8366c56a09..f6c126a771 100644
--- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
@@ -778,9 +778,8 @@ void AtSpiAdaptor::updateEventListeners()
QDBusReply<QSpiEventListenerArray> listenersReply = m_dbus->connection().call(m);
if (listenersReply.isValid()) {
const QSpiEventListenerArray evList = listenersReply.value();
- Q_FOREACH (const QSpiEventListener &ev, evList) {
+ for (const QSpiEventListener &ev : evList)
setBitFlag(ev.eventName);
- }
m_applicationAdaptor->sendEvents(!evList.isEmpty());
} else {
qAtspiDebug("Could not query active accessibility event listeners.");
@@ -1508,11 +1507,10 @@ QStringList AtSpiAdaptor::accessibleInterfaces(QAccessibleInterface *interface)
QSpiRelationArray AtSpiAdaptor::relationSet(QAccessibleInterface *interface, const QDBusConnection &connection) const
{
typedef QPair<QAccessibleInterface*, QAccessible::Relation> RelationPair;
- QVector<RelationPair> relationInterfaces;
- relationInterfaces = interface->relations();
+ const QVector<RelationPair> relationInterfaces = interface->relations();
QSpiRelationArray relations;
- Q_FOREACH (const RelationPair &pair, relationInterfaces) {
+ for (const RelationPair &pair : relationInterfaces) {
// FIXME: this loop seems a bit strange... "related" always have one item when we check.
//And why is it a list, when it always have one item? And it seems to assume that the QAccessible::Relation enum maps directly to AtSpi
QSpiObjectReferenceArray related;
@@ -1757,24 +1755,20 @@ QSpiActionArray AtSpiAdaptor::getActions(QAccessibleInterface *interface) const
QSpiActionArray actions;
const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(interface);
actions.reserve(actionNames.size());
- Q_FOREACH (const QString &actionName, actionNames) {
+ for (const QString &actionName : actionNames) {
QSpiAction action;
- QStringList keyBindings;
action.name = actionName;
if (actionInterface) {
action.description = actionInterface->localizedActionDescription(actionName);
- keyBindings = actionInterface->keyBindingsForAction(actionName);
+ const QStringList keyBindings = actionInterface->keyBindingsForAction(actionName);
+ if (!keyBindings.isEmpty())
+ action.keyBinding = keyBindings.front();
} else {
action.description = qAccessibleLocalizedActionDescription(actionName);
}
- if (keyBindings.length() > 0)
- action.keyBinding = keyBindings[0];
- else
- action.keyBinding = QString();
-
- actions << action;
+ actions.append(std::move(action));
}
return actions;
}
diff --git a/src/platformsupport/linuxaccessibility/linuxaccessibility.pri b/src/platformsupport/linuxaccessibility/linuxaccessibility.pri
index 1b65fb1cad..1f36b815cf 100644
--- a/src/platformsupport/linuxaccessibility/linuxaccessibility.pri
+++ b/src/platformsupport/linuxaccessibility/linuxaccessibility.pri
@@ -1,4 +1,4 @@
-contains(QT_CONFIG, accessibility-atspi-bridge) {
+qtConfig(accessibility-atspi-bridge) {
QT_FOR_PRIVATE += dbus
include(../../3rdparty/atspi2/atspi2.pri)
diff --git a/src/platformsupport/platformcompositor/platformcompositor.pri b/src/platformsupport/platformcompositor/platformcompositor.pri
index 923d7225da..1e908c9998 100644
--- a/src/platformsupport/platformcompositor/platformcompositor.pri
+++ b/src/platformsupport/platformcompositor/platformcompositor.pri
@@ -1,4 +1,4 @@
-contains(QT_CONFIG, opengl) {
+qtConfig(opengl) {
SOURCES += $$PWD/qopenglcompositor.cpp \
$$PWD/qopenglcompositorbackingstore.cpp
diff --git a/src/platformsupport/platformcompositor/qopenglcompositor.cpp b/src/platformsupport/platformcompositor/qopenglcompositor.cpp
index 610619a4e4..0f4946f81a 100644
--- a/src/platformsupport/platformcompositor/qopenglcompositor.cpp
+++ b/src/platformsupport/platformcompositor/qopenglcompositor.cpp
@@ -40,7 +40,6 @@
#include <QtGui/QOpenGLContext>
#include <QtGui/QOpenGLFramebufferObject>
#include <QtGui/QWindow>
-#include <QtGui/QMatrix4x4>
#include <qpa/qplatformbackingstore.h>
#include "qopenglcompositor_p.h"
@@ -78,7 +77,8 @@ static QOpenGLCompositor *compositor = 0;
QOpenGLCompositor::QOpenGLCompositor()
: m_context(0),
- m_targetWindow(0)
+ m_targetWindow(0),
+ m_rotation(0)
{
Q_ASSERT(!compositor);
m_updateTimer.setSingleShot(true);
@@ -93,10 +93,19 @@ QOpenGLCompositor::~QOpenGLCompositor()
compositor = 0;
}
-void QOpenGLCompositor::setTarget(QOpenGLContext *context, QWindow *targetWindow)
+void QOpenGLCompositor::setTarget(QOpenGLContext *context, QWindow *targetWindow,
+ const QRect &nativeTargetGeometry)
{
m_context = context;
m_targetWindow = targetWindow;
+ m_nativeTargetGeometry = nativeTargetGeometry;
+}
+
+void QOpenGLCompositor::setRotation(int degrees)
+{
+ m_rotation = degrees;
+ m_rotationMatrix.setToIdentity();
+ m_rotationMatrix.rotate(degrees, 0, 0, 1);
}
void QOpenGLCompositor::update()
@@ -109,7 +118,7 @@ QImage QOpenGLCompositor::grab()
{
Q_ASSERT(m_context && m_targetWindow);
m_context->makeCurrent(m_targetWindow);
- QScopedPointer<QOpenGLFramebufferObject> fbo(new QOpenGLFramebufferObject(m_targetWindow->geometry().size()));
+ QScopedPointer<QOpenGLFramebufferObject> fbo(new QOpenGLFramebufferObject(m_nativeTargetGeometry.size()));
renderAll(fbo.data());
return fbo->toImage();
}
@@ -127,9 +136,7 @@ void QOpenGLCompositor::renderAll(QOpenGLFramebufferObject *fbo)
fbo->bind();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
-
- const QRect targetWindowRect(QPoint(0, 0), m_targetWindow->geometry().size());
- glViewport(0, 0, targetWindowRect.width(), targetWindowRect.height());
+ glViewport(0, 0, m_nativeTargetGeometry.width(), m_nativeTargetGeometry.height());
if (!m_blitter.isCreated())
m_blitter.create();
@@ -181,7 +188,8 @@ static inline QRect toBottomLeftRect(const QRect &topLeftRect, int windowHeight)
topLeftRect.width(), topLeftRect.height());
}
-static void clippedBlit(const QPlatformTextureList *textures, int idx, const QRect &targetWindowRect, QOpenGLTextureBlitter *blitter)
+static void clippedBlit(const QPlatformTextureList *textures, int idx, const QRect &targetWindowRect,
+ QOpenGLTextureBlitter *blitter, QMatrix4x4 *rotationMatrix)
{
const QRect clipRect = textures->clipRect(idx);
if (clipRect.isEmpty())
@@ -191,7 +199,10 @@ static void clippedBlit(const QPlatformTextureList *textures, int idx, const QRe
const QRect clippedRectInWindow = rectInWindow & clipRect.translated(rectInWindow.topLeft());
const QRect srcRect = toBottomLeftRect(clipRect, rectInWindow.height());
- const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(clippedRectInWindow, targetWindowRect);
+ QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(clippedRectInWindow, targetWindowRect);
+ if (rotationMatrix)
+ target = *rotationMatrix * target;
+
const QMatrix3x3 source = QOpenGLTextureBlitter::sourceTransform(srcRect, rectInWindow.size(),
QOpenGLTextureBlitter::OriginBottomLeft);
@@ -219,25 +230,29 @@ void QOpenGLCompositor::render(QOpenGLCompositorWindow *window)
if (textures->count() > 1 && i == textures->count() - 1) {
// Backingstore for a widget with QOpenGLWidget subwidgets
blend.set(true);
- const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect);
+ QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect);
+ if (m_rotation)
+ target = m_rotationMatrix * target;
m_blitter.blit(textureId, target, QOpenGLTextureBlitter::OriginTopLeft);
} else if (textures->count() == 1) {
// A regular QWidget window
const bool translucent = window->sourceWindow()->requestedFormat().alphaBufferSize() > 0;
blend.set(translucent);
- const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect);
+ QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect);
+ if (m_rotation)
+ target = m_rotationMatrix * target;
m_blitter.blit(textureId, target, QOpenGLTextureBlitter::OriginTopLeft);
} else if (!textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop)) {
// Texture from an FBO belonging to a QOpenGLWidget
blend.set(false);
- clippedBlit(textures, i, targetWindowRect, &m_blitter);
+ clippedBlit(textures, i, targetWindowRect, &m_blitter, m_rotation ? &m_rotationMatrix : nullptr);
}
}
for (int i = 0; i < textures->count(); ++i) {
if (textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop)) {
blend.set(true);
- clippedBlit(textures, i, targetWindowRect, &m_blitter);
+ clippedBlit(textures, i, targetWindowRect, &m_blitter, m_rotation ? &m_rotationMatrix : nullptr);
}
}
diff --git a/src/platformsupport/platformcompositor/qopenglcompositor_p.h b/src/platformsupport/platformcompositor/qopenglcompositor_p.h
index 2c34fba409..dece41f676 100644
--- a/src/platformsupport/platformcompositor/qopenglcompositor_p.h
+++ b/src/platformsupport/platformcompositor/qopenglcompositor_p.h
@@ -52,7 +52,8 @@
//
#include <QtCore/QTimer>
-#include <QtGui/private/qopengltextureblitter_p.h>
+#include <QtGui/QOpenGLTextureBlitter>
+#include <QtGui/QMatrix4x4>
QT_BEGIN_NAMESPACE
@@ -78,7 +79,8 @@ public:
static QOpenGLCompositor *instance();
static void destroy();
- void setTarget(QOpenGLContext *context, QWindow *window);
+ void setTarget(QOpenGLContext *context, QWindow *window, const QRect &nativeTargetGeometry);
+ void setRotation(int degrees);
QOpenGLContext *context() const { return m_context; }
QWindow *targetWindow() const { return m_targetWindow; }
@@ -106,6 +108,9 @@ private:
QOpenGLContext *m_context;
QWindow *m_targetWindow;
+ QRect m_nativeTargetGeometry;
+ int m_rotation;
+ QMatrix4x4 m_rotationMatrix;
QTimer m_updateTimer;
QOpenGLTextureBlitter m_blitter;
QList<QOpenGLCompositorWindow *> m_windows;
diff --git a/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp b/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
index 7c29be7804..dbaaf524e8 100644
--- a/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
+++ b/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
@@ -140,7 +140,7 @@ void QOpenGLCompositorBackingStore::updateTexture()
QOpenGLContext *ctx = QOpenGLContext::currentContext();
if (!ctx->isOpenGLES() || ctx->format().majorVersion() >= 3) {
- foreach (const QRect &rect, m_dirty.rects()) {
+ for (const QRect &rect : m_dirty) {
QRect r = imageRect & rect;
glPixelStorei(GL_UNPACK_ROW_LENGTH, m_image.width());
glTexSubImage2D(GL_TEXTURE_2D, 0, r.x(), r.y(), r.width(), r.height(), GL_RGBA, GL_UNSIGNED_BYTE,
@@ -148,7 +148,7 @@ void QOpenGLCompositorBackingStore::updateTexture()
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
}
} else {
- foreach (const QRect &rect, m_dirty.rects()) {
+ for (const QRect &rect : m_dirty) {
// intersect with image rect to be sure
QRect r = imageRect & rect;
@@ -161,7 +161,7 @@ void QOpenGLCompositorBackingStore::updateTexture()
fixed |= r;
}
- foreach (const QRect &rect, fixed.rects()) {
+ for (const QRect &rect : fixed) {
// if the sub-rect is full-width we can pass the image data directly to
// OpenGL instead of copying, since there's no gap between scanlines
if (rect.width() == imageRect.width()) {
@@ -258,7 +258,7 @@ void QOpenGLCompositorBackingStore::beginPaint(const QRegion &region)
if (m_image.hasAlphaChannel()) {
QPainter p(&m_image);
p.setCompositionMode(QPainter::CompositionMode_Source);
- foreach (const QRect &r, region.rects())
+ for (const QRect &r : region)
p.fillRect(r, Qt::transparent);
}
}
diff --git a/src/platformsupport/platformsupport.pro b/src/platformsupport/platformsupport.pro
index 60be964b74..19efa60f48 100644
--- a/src/platformsupport/platformsupport.pro
+++ b/src/platformsupport/platformsupport.pro
@@ -22,13 +22,13 @@ include(linuxaccessibility/linuxaccessibility.pri)
include(clipboard/clipboard.pri)
include(platformcompositor/platformcompositor.pri)
-# dbus convenience, but not for darwin: the platform
+# dbus convenience for unix except darwin: the platform
# plugins for these platforms do not use dbus and we
# don't want to create a false dependency.
-!darwin: contains(QT_CONFIG, dbus) {
+unix:!darwin:qtConfig(dbus) {
include(dbusmenu/dbusmenu.pri)
include(dbustray/dbustray.pri)
}
-ios: include(graphics/graphics.pri)
+darwin: include(graphics/graphics.pri)
load(qt_module)
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
index 9abcd04063..296c282a47 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
@@ -50,6 +50,7 @@
#include <QtCore/QFile>
#include <QtCore/QDebug>
#include <QtCore/QHash>
+#include <QtCore/QMimeDatabase>
#include <QtCore/QLoggingCategory>
#include <QtCore/QSettings>
#include <QtCore/QVariant>
@@ -231,6 +232,28 @@ QVariant QGenericUnixTheme::themeHint(ThemeHint hint) const
return QPlatformTheme::themeHint(hint);
}
+// Helper functions for implementing QPlatformTheme::fileIcon() for XDG icon themes.
+static QList<QSize> availableXdgFileIconSizes()
+{
+ return QIcon::fromTheme(QStringLiteral("inode-directory")).availableSizes();
+}
+
+static QIcon xdgFileIcon(const QFileInfo &fileInfo)
+{
+ QMimeDatabase mimeDatabase;
+ QMimeType mimeType = mimeDatabase.mimeTypeForFile(fileInfo);
+ if (!mimeType.isValid())
+ return QIcon();
+ const QString &iconName = mimeType.iconName();
+ if (!iconName.isEmpty()) {
+ const QIcon icon = QIcon::fromTheme(iconName);
+ if (!icon.isNull())
+ return icon;
+ }
+ const QString &genericIconName = mimeType.genericIconName();
+ return genericIconName.isEmpty() ? QIcon() : QIcon::fromTheme(genericIconName);
+}
+
#ifndef QT_NO_SETTINGS
class QKdeThemePrivate : public QPlatformThemePrivate
{
@@ -345,7 +368,7 @@ void QKdeThemePrivate::refresh()
QVariant QKdeThemePrivate::readKdeSetting(const QString &key, const QStringList &kdeDirs, int kdeVersion, QHash<QString, QSettings*> &kdeSettings)
{
- foreach (const QString &kdeDir, kdeDirs) {
+ for (const QString &kdeDir : kdeDirs) {
QSettings *settings = kdeSettings.value(kdeDir);
if (!settings) {
const QString kdeGlobalsPath = kdeGlobals(kdeDir, kdeVersion);
@@ -478,7 +501,7 @@ QStringList QKdeThemePrivate::kdeIconThemeSearchPaths(const QStringList &kdeDirs
{
QStringList paths = QGenericUnixTheme::xdgIconThemePaths();
const QString iconPath = QStringLiteral("/share/icons");
- foreach (const QString &candidate, kdeDirs) {
+ for (const QString &candidate : kdeDirs) {
const QFileInfo fi(candidate + iconPath);
if (fi.isDir())
paths.append(fi.absoluteFilePath());
@@ -506,6 +529,8 @@ QVariant QKdeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
return QVariant(d->iconFallbackThemeName);
case QPlatformTheme::IconThemeSearchPaths:
return QVariant(d->kdeIconThemeSearchPaths(d->kdeDirs));
+ case QPlatformTheme::IconPixmapSizes:
+ return QVariant::fromValue(availableXdgFileIconSizes());
case QPlatformTheme::StyleNames:
return QVariant(d->styleNames);
case QPlatformTheme::KeyboardScheme:
@@ -520,6 +545,11 @@ QVariant QKdeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
return QPlatformTheme::themeHint(hint);
}
+QIcon QKdeTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions) const
+{
+ return xdgFileIcon(fileInfo);
+}
+
const QPalette *QKdeTheme::palette(Palette type) const
{
Q_D(const QKdeTheme);
@@ -657,6 +687,8 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
return QVariant(QStringLiteral("gnome"));
case QPlatformTheme::IconThemeSearchPaths:
return QVariant(QGenericUnixTheme::xdgIconThemePaths());
+ case QPlatformTheme::IconPixmapSizes:
+ return QVariant::fromValue(availableXdgFileIconSizes());
case QPlatformTheme::StyleNames: {
QStringList styleNames;
styleNames << QStringLiteral("fusion") << QStringLiteral("windows");
@@ -666,12 +698,19 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
return QVariant(int(GnomeKeyboardScheme));
case QPlatformTheme::PasswordMaskCharacter:
return QVariant(QChar(0x2022));
+ case QPlatformTheme::UiEffects:
+ return QVariant(int(HoverEffect));
default:
break;
}
return QPlatformTheme::themeHint(hint);
}
+QIcon QGnomeTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions) const
+{
+ return xdgFileIcon(fileInfo);
+}
+
const QFont *QGnomeTheme::font(Font type) const
{
Q_D(const QGnomeTheme);
@@ -759,8 +798,8 @@ QStringList QGenericUnixTheme::themeNames()
<< "MATE"
<< "XFCE"
<< "LXDE";
- QList<QByteArray> desktopNames = desktopEnvironment.split(':');
- Q_FOREACH (const QByteArray &desktopName, desktopNames) {
+ const QList<QByteArray> desktopNames = desktopEnvironment.split(':');
+ for (const QByteArray &desktopName : desktopNames) {
if (desktopEnvironment == "KDE") {
#ifndef QT_NO_SETTINGS
result.push_back(QLatin1String(QKdeTheme::name));
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h
index 952658e130..da13390662 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h
@@ -107,6 +107,9 @@ public:
static QPlatformTheme *createKdeTheme();
QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE;
+ QIcon fileIcon(const QFileInfo &fileInfo,
+ QPlatformTheme::IconOptions iconOptions = 0) const override;
+
const QPalette *palette(Palette type = SystemPalette) const Q_DECL_OVERRIDE;
const QFont *font(Font type) const Q_DECL_OVERRIDE;
@@ -129,6 +132,8 @@ class QGnomeTheme : public QPlatformTheme
public:
QGnomeTheme();
QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE;
+ QIcon fileIcon(const QFileInfo &fileInfo,
+ QPlatformTheme::IconOptions = 0) const override;
const QFont *font(Font type) const Q_DECL_OVERRIDE;
QString standardButtonText(int button) const Q_DECL_OVERRIDE;
diff --git a/src/platformsupport/themes/qabstractfileiconengine.cpp b/src/platformsupport/themes/qabstractfileiconengine.cpp
new file mode 100644
index 0000000000..192ed00510
--- /dev/null
+++ b/src/platformsupport/themes/qabstractfileiconengine.cpp
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qabstractfileiconengine_p.h"
+
+#include <qpixmapcache.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QAbstractFileIconEngine
+ \brief Helper base class for retrieving icons for files for usage by QFileIconProvider and related.
+
+ Reimplement availableSizes() and new virtual filePixmap() and return icons created
+ with this engine from QPlatformTheme::fileIcon().
+
+ Note: The class internally caches pixmaps for files by suffix (with the exception
+ of some files on Windows), but not for directories (since directory icons may have
+ overlay icons on Windows). You might want to cache pixmaps for directories
+ in your implementation.
+
+ \since 5.8
+ \internal
+ \sa QFileIconProvider::DontUseCustomDirectoryIcons, QPlatformTheme
+ \ingroup qpa
+*/
+QPixmap QAbstractFileIconEngine::pixmap(const QSize &size, QIcon::Mode mode,
+ QIcon::State state)
+{
+ Q_UNUSED(mode);
+ Q_UNUSED(state);
+
+ if (!size.isValid())
+ return QPixmap();
+
+ QString key = cacheKey();
+ if (key.isEmpty())
+ return filePixmap(size, mode, state);
+
+ key += QLatin1Char('_') + QString::number(size.width());
+
+ QPixmap result;
+ if (!QPixmapCache::find(key, result)) {
+ result = filePixmap(size, mode, state);
+ if (!result.isNull())
+ QPixmapCache::insert(key, result);
+ }
+
+ return result;
+}
+
+QSize QAbstractFileIconEngine::actualSize(const QSize &size, QIcon::Mode mode,
+ QIcon::State state)
+{
+ const QList<QSize> &sizes = availableSizes(mode, state);
+ const int numberSizes = sizes.length();
+ if (numberSizes == 0)
+ return QSize();
+
+ // Find the smallest available size whose area is still larger than the input
+ // size. Otherwise, use the largest area available size. (We don't assume the
+ // platform theme sizes are sorted, hence the extra logic.)
+ const int sizeArea = size.width() * size.height();
+ QSize actualSize = sizes.first();
+ int actualArea = actualSize.width() * actualSize.height();
+ for (int i = 1; i < numberSizes; ++i) {
+ const QSize &s = sizes.at(i);
+ const int a = s.width() * s.height();
+ if ((sizeArea <= a && a < actualArea) || (actualArea < sizeArea && actualArea < a)) {
+ actualSize = s;
+ actualArea = a;
+ }
+ }
+
+ if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height()))
+ actualSize.scale(size, Qt::KeepAspectRatio);
+
+ return actualSize;
+}
+
+/* Reimplement to return a cache key for the entry. An empty result indicates
+ * the icon should not be cached (for example, directory icons having custom icons). */
+QString QAbstractFileIconEngine::cacheKey() const
+{
+ if (!m_fileInfo.isFile() || m_fileInfo.isSymLink() || m_fileInfo.isExecutable())
+ return QString();
+
+ const QString &suffix = m_fileInfo.suffix();
+ return QLatin1String("qt_.")
+ + (suffix.isEmpty() ? m_fileInfo.fileName() : suffix); // handle "Makefile" ;)
+}
+
+QT_END_NAMESPACE
diff --git a/src/platformsupport/themes/qabstractfileiconengine_p.h b/src/platformsupport/themes/qabstractfileiconengine_p.h
new file mode 100644
index 0000000000..ce38cf262e
--- /dev/null
+++ b/src/platformsupport/themes/qabstractfileiconengine_p.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QABSTRACTFILEICONENGINE_P_H
+#define QABSTRACTFILEICONENGINE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qfileinfo.h>
+#include <private/qicon_p.h>
+#include <qpa/qplatformtheme.h>
+
+QT_BEGIN_NAMESPACE
+
+class QAbstractFileIconEngine : public QPixmapIconEngine
+{
+public:
+ explicit QAbstractFileIconEngine(const QFileInfo &info, QPlatformTheme::IconOptions opts)
+ : QPixmapIconEngine(), m_fileInfo(info), m_options(opts) {}
+
+ QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State) override;
+ QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) override;
+
+ QFileInfo fileInfo() const { return m_fileInfo; }
+ QPlatformTheme::IconOptions options() const { return m_options; }
+
+ // Helper to convert a sequence of ints to a list of QSize
+ template <class It> static QList<QSize> toSizeList(It i1, It i2);
+
+protected:
+ virtual QPixmap filePixmap(const QSize &size, QIcon::Mode mode, QIcon::State) = 0;
+ virtual QString cacheKey() const;
+
+private:
+ const QFileInfo m_fileInfo;
+ const QPlatformTheme::IconOptions m_options;
+};
+
+template <class It>
+inline QList<QSize> QAbstractFileIconEngine::toSizeList(It i1, It i2)
+{
+ QList<QSize> result;
+ result.reserve(int(i2 - i1));
+ for ( ; i1 != i2; ++i1)
+ result.append(QSize(*i1, *i1));
+ return result;
+}
+
+QT_END_NAMESPACE
+
+#endif // QABSTRACTFILEICONENGINE_P_H
diff --git a/src/platformsupport/themes/themes.pri b/src/platformsupport/themes/themes.pri
index adee852626..552973431f 100644
--- a/src/platformsupport/themes/themes.pri
+++ b/src/platformsupport/themes/themes.pri
@@ -1,3 +1,9 @@
unix:!mac {
include($$PWD/genericunix/genericunix.pri)
}
+
+HEADERS += \
+ $$PWD/qabstractfileiconengine_p.h
+
+SOURCES += \
+ $$PWD/qabstractfileiconengine.cpp