diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/Qt5CoreMacros.cmake | 2 | ||||
-rw-r--r-- | src/gui/kernel/qevent.cpp | 1 | ||||
-rw-r--r-- | src/gui/text/qfontdatabase.cpp | 35 | ||||
-rw-r--r-- | src/gui/text/qfontengine.cpp | 37 | ||||
-rw-r--r-- | src/network/access/qftp.cpp | 12 | ||||
-rw-r--r-- | src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm | 3 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 14 | ||||
-rw-r--r-- | src/widgets/dialogs/qfilesystemmodel.cpp | 9 | ||||
-rw-r--r-- | src/widgets/dialogs/qfilesystemmodel_p.h | 19 | ||||
-rw-r--r-- | src/widgets/itemviews/qlistwidget.cpp | 3 | ||||
-rw-r--r-- | src/widgets/itemviews/qtablewidget.cpp | 3 | ||||
-rw-r--r-- | src/widgets/itemviews/qtreewidget.cpp | 3 |
12 files changed, 123 insertions, 18 deletions
diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index 8b65db95cb..8d3dbe3ecf 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -257,7 +257,7 @@ function(QT5_ADD_BINARY_RESOURCES target ) add_custom_command(OUTPUT ${rcc_destination} COMMAND ${Qt5Core_RCC_EXECUTABLE} ARGS ${rcc_options} --binary --name ${target} --output ${rcc_destination} ${infiles} - DEPENDS ${rc_depends} ${out_depends} VERBATIM) + DEPENDS ${rc_depends} ${out_depends} ${infiles} VERBATIM) add_custom_target(${target} ALL DEPENDS ${rcc_destination}) endfunction() diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 916b13df44..139b36ef71 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -972,6 +972,7 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, \li scrolling is about to begin, but the distance did not yet change (Qt::ScrollBegin), \li or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd). \endlist + \note On X11 this value is driver specific and unreliable, use angleDelta() instead */ /*! diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 2cc071d67b..33dc27983a 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -2837,6 +2837,41 @@ QString QFontDatabase::resolveFontFamilyAlias(const QString &family) return QGuiApplicationPrivate::platformIntegration()->fontDatabase()->resolveFontFamilyAlias(family); } +Q_GUI_EXPORT QStringList qt_sort_families_by_writing_system(QChar::Script script, const QStringList &families) +{ + size_t writingSystem = std::find(scriptForWritingSystem, + scriptForWritingSystem + QFontDatabase::WritingSystemsCount, + script) - scriptForWritingSystem; + if (writingSystem == QFontDatabase::Any + || writingSystem >= QFontDatabase::WritingSystemsCount) { + return families; + } + + QFontDatabasePrivate *db = privateDb(); + QMultiMap<uint, QString> supported; + for (int i = 0; i < families.size(); ++i) { + const QString &family = families.at(i); + + QtFontFamily *testFamily = nullptr; + for (int x = 0; x < db->count; ++x) { + if (Q_UNLIKELY(matchFamilyName(family, db->families[x]))) { + testFamily = db->families[x]; + testFamily->ensurePopulated(); + break; + } + } + + uint order = i; + if (testFamily == nullptr + || (testFamily->writingSystems[writingSystem] & QtFontFamily::Supported) == 0) { + order |= 1 << 31; + } + + supported.insert(order, family); + } + + return supported.values(); +} QT_END_NAMESPACE diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index e4f9b8b9d4..33df020a6c 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2018 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -1845,7 +1845,12 @@ QFontEngine *QFontEngineMulti::loadEngine(int at) request.styleStrategy |= QFont::NoFontMerging; request.family = fallbackFamilyAt(at - 1); - if (QFontEngine *engine = QFontDatabase::findFont(request, m_script)) { + // At this point, the main script of the text has already been considered + // when fetching the list of fallback families from the database, and the + // info about the actual script of the characters may have been discarded, + // so we do not check for writing system support, but instead just load + // the family indiscriminately. + if (QFontEngine *engine = QFontDatabase::findFont(request, QFontDatabase::Any)) { engine->fontDef.weight = request.weight; if (request.style > QFont::StyleNormal) engine->fontDef.style = request.style; @@ -1898,8 +1903,33 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len, int glyph_pos = 0; QStringIterator it(str, str + len); + + int lastFallback = -1; while (it.hasNext()) { const uint ucs4 = it.peekNext(); + + // If we applied a fallback font to previous glyph, and the current is either + // ZWJ or ZWNJ, we should also try applying the same fallback font to that, in order + // to get the correct shaping rules applied. + if (lastFallback >= 0 && (ucs4 == QChar(0x200d) || ucs4 == QChar(0x200c))) { + QFontEngine *engine = m_engines.at(lastFallback); + glyph_t glyph = engine->glyphIndex(ucs4); + if (glyph != 0) { + glyphs->glyphs[glyph_pos] = glyph; + if (!(flags & GlyphIndicesOnly)) { + QGlyphLayout g = glyphs->mid(glyph_pos, 1); + engine->recalcAdvances(&g, flags); + } + + // set the high byte to indicate which engine the glyph came from + glyphs->glyphs[glyph_pos] |= (lastFallback << 24); + } else { + lastFallback = -1; + } + } else { + lastFallback = -1; + } + if (glyphs->glyphs[glyph_pos] == 0 && ucs4 != QChar::LineSeparator && ucs4 != QChar::LineFeed @@ -1928,6 +1958,9 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLayout g = glyphs->mid(glyph_pos, 1); engine->recalcAdvances(&g, flags); } + + lastFallback = x; + // set the high byte to indicate which engine the glyph came from glyphs->glyphs[glyph_pos] |= (x << 24); break; diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp index 762ef00225..719e3536b4 100644 --- a/src/network/access/qftp.cpp +++ b/src/network/access/qftp.cpp @@ -1702,8 +1702,16 @@ int QFtp::connectToHost(const QString &host, quint16 port) int QFtp::login(const QString &user, const QString &password) { QStringList cmds; - cmds << (QLatin1String("USER ") + (user.isNull() ? QLatin1String("anonymous") : user) + QLatin1String("\r\n")); - cmds << (QLatin1String("PASS ") + (password.isNull() ? QLatin1String("anonymous@") : password) + QLatin1String("\r\n")); + + if (user.isNull() || user.compare(QLatin1String("anonymous"), Qt::CaseInsensitive) == 0) { + cmds << (QLatin1String("USER ") + (user.isNull() ? QLatin1String("anonymous") : user) + QLatin1String("\r\n")); + cmds << (QLatin1String("PASS ") + (password.isNull() ? QLatin1String("anonymous@") : password) + QLatin1String("\r\n")); + } else { + cmds << (QLatin1String("USER ") + user + QLatin1String("\r\n")); + if (!password.isNull()) + cmds << (QLatin1String("PASS ") + password + QLatin1String("\r\n")); + } + return d_func()->addCommand(new QFtpCommand(Login, cmds)); } diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm index 237e8a89a5..7397312820 100644 --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm @@ -544,6 +544,9 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo fallbackList.append(QStringLiteral("Arial Unicode MS")); #endif + extern QStringList qt_sort_families_by_writing_system(QChar::Script, const QStringList &); + fallbackList = qt_sort_families_by_writing_system(script, fallbackList); + return fallbackList; } } diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index b2dcf7c3e7..335ec344d5 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -1019,10 +1019,12 @@ void QXcbConnection::xi2HandleScrollEvent(void *event, ScrollingDevice &scrollin double delta = scrollingDevice.lastScrollPosition.y() - value; scrollingDevice.lastScrollPosition.setY(value); angleDelta.setY((delta / scrollingDevice.verticalIncrement) * 120); - // We do not set "pixel" delta if it is only measured in ticks. - if (scrollingDevice.verticalIncrement > 1) + // With most drivers the increment is 1 for wheels. + // For libinput it is hardcoded to a useless 15. + // For a proper touchpad driver it should be in the same order of magnitude as 120 + if (scrollingDevice.verticalIncrement > 15) rawDelta.setY(delta); - else if (scrollingDevice.verticalIncrement < -1) + else if (scrollingDevice.verticalIncrement < -15) rawDelta.setY(-delta); } } @@ -1031,10 +1033,10 @@ void QXcbConnection::xi2HandleScrollEvent(void *event, ScrollingDevice &scrollin double delta = scrollingDevice.lastScrollPosition.x() - value; scrollingDevice.lastScrollPosition.setX(value); angleDelta.setX((delta / scrollingDevice.horizontalIncrement) * 120); - // We do not set "pixel" delta if it is only measured in ticks. - if (scrollingDevice.horizontalIncrement > 1) + // See comment under vertical + if (scrollingDevice.horizontalIncrement > 15) rawDelta.setX(delta); - else if (scrollingDevice.horizontalIncrement < -1) + else if (scrollingDevice.horizontalIncrement < -15) rawDelta.setX(-delta); } } diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 2b79831a74..14ac6ad31b 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -1086,8 +1086,8 @@ void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent return; QVector<QFileSystemModelPrivate::QFileSystemNode*> values; - QHash<QString, QFileSystemNode *>::const_iterator iterator; - for(iterator = indexNode->children.constBegin() ; iterator != indexNode->children.constEnd() ; ++iterator) { + + for (auto iterator = indexNode->children.constBegin(), cend = indexNode->children.constEnd(); iterator != cend; ++iterator) { if (filtersAcceptsNode(iterator.value())) { values.append(iterator.value()); } else { @@ -1647,13 +1647,10 @@ void QFileSystemModelPrivate::_q_directoryChanged(const QString &directory, cons QStringList toRemove; QStringList newFiles = files; std::sort(newFiles.begin(), newFiles.end()); - QHash<QString, QFileSystemNode*>::const_iterator i = parentNode->children.constBegin(); - while (i != parentNode->children.constEnd()) { + for (auto i = parentNode->children.constBegin(), cend = parentNode->children.constEnd(); i != cend; ++i) { QStringList::iterator iterator = std::lower_bound(newFiles.begin(), newFiles.end(), i.value()->fileName); if ((iterator == newFiles.end()) || (i.value()->fileName < *iterator)) toRemove.append(i.value()->fileName); - - ++i; } for (int i = 0 ; i < toRemove.count() ; ++i ) removeNode(parentNode, toRemove[i]); diff --git a/src/widgets/dialogs/qfilesystemmodel_p.h b/src/widgets/dialogs/qfilesystemmodel_p.h index 640225529b..e8bae4f659 100644 --- a/src/widgets/dialogs/qfilesystemmodel_p.h +++ b/src/widgets/dialogs/qfilesystemmodel_p.h @@ -72,6 +72,23 @@ class ExtendedInformation; class QFileSystemModelPrivate; class QFileIconProvider; +#if defined(Q_OS_WIN) +class QFileSystemModelNodePathKey : public QString +{ +public: + QFileSystemModelNodePathKey() {} + QFileSystemModelNodePathKey(const QString &other) : QString(other) {} + QFileSystemModelNodePathKey(const QFileSystemModelNodePathKey &other) : QString(other) {} + bool operator==(const QFileSystemModelNodePathKey &other) const { return !compare(other, Qt::CaseInsensitive); } +}; + +Q_DECLARE_TYPEINFO(QFileSystemModelNodePathKey, Q_MOVABLE_TYPE); + +inline uint qHash(const QFileSystemModelNodePathKey &key) { return qHash(key.toCaseFolded()); } +#else // Q_OS_WIN +typedef QString QFileSystemModelNodePathKey; +#endif + class Q_AUTOTEST_EXPORT QFileSystemModelPrivate : public QAbstractItemModelPrivate { Q_DECLARE_PUBLIC(QFileSystemModel) @@ -189,7 +206,7 @@ public: bool populatedChildren; bool isVisible; - QHash<QString,QFileSystemNode *> children; + QHash<QFileSystemModelNodePathKey, QFileSystemNode *> children; QList<QString> visibleChildren; int dirtyChildrenIndex; QFileSystemNode *parent; diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp index 95ad3f82d0..61b2c5e78f 100644 --- a/src/widgets/itemviews/qlistwidget.cpp +++ b/src/widgets/itemviews/qlistwidget.cpp @@ -690,6 +690,9 @@ QListWidgetItem *QListWidgetItem::clone() const Sets the data for a given \a role to the given \a value. Reimplement this function if you need extra roles or special behavior for certain roles. + \note The default implementation treats Qt::EditRole and Qt::DisplayRole as + referring to the same data. + \sa Qt::ItemDataRole, data() */ void QListWidgetItem::setData(int role, const QVariant &value) diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp index bb1970e3ac..892a8d3a22 100644 --- a/src/widgets/itemviews/qtablewidget.cpp +++ b/src/widgets/itemviews/qtablewidget.cpp @@ -1365,6 +1365,9 @@ QTableWidgetItem *QTableWidgetItem::clone() const /*! Sets the item's data for the given \a role to the specified \a value. + \note The default implementation treats Qt::EditRole and Qt::DisplayRole as + referring to the same data. + \sa Qt::ItemDataRole, data() */ void QTableWidgetItem::setData(int role, const QVariant &value) diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index d7b46a0835..b253abac73 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -1699,6 +1699,9 @@ Qt::ItemFlags QTreeWidgetItem::flags() const The \a role describes the type of data specified by \a value, and is defined by the Qt::ItemDataRole enum. + + \note The default implementation treats Qt::EditRole and Qt::DisplayRole as + referring to the same data. */ void QTreeWidgetItem::setData(int column, int role, const QVariant &value) { |