From 8f7e21bc509d6743c6a0ed6c86373890d4e17530 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 2 May 2020 11:21:50 -0700 Subject: Don't compile pcre2 if we will use the system library Change-Id: I99ab0f318b1c43b89888fffd160b4923a06c4585 Reviewed-by: Giuseppe D'Angelo Reviewed-by: Joerg Bornemann --- src/src.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/src.pro b/src/src.pro index 6658cbc9e0..043577173b 100644 --- a/src/src.pro +++ b/src/src.pro @@ -158,7 +158,7 @@ src_android.subdir = $$PWD/android } } SUBDIRS += src_tools_bootstrap src_tools_moc src_tools_rcc src_tools_tracegen -qtConfig(regularexpression):pcre2 { +qtConfig(regularexpression):!qtConfig(system-pcre2):pcre2 { SUBDIRS += src_3rdparty_pcre2 src_corelib.depends += src_3rdparty_pcre2 } -- cgit v1.2.3 From ec2ac17c10416d4f5a265f9899b8012d3bebea01 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 14 Apr 2020 09:59:14 +0200 Subject: Improve QTranslator documentation code snippet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use :/i18n/, because this is the place where translations are stored by default if using qmake's CONFIG += lrelease embed_translations. Also revert change of app.exec() done in 16da0b2cf8b6b. First of all, both QGuiApplication and QApplication feature overloads of exec(), so using QCoreApplication::exec() might miss functionality. Anyhow, while it's true that all of them are static member functions, the vast majority of our examples and templates call them with class member access syntax, so let's try to be consistent. Finally, the example since a while uses QCoreApplication::translate, not tr(), so let's not mention it in the description. Change-Id: Ic6e5d91cf04d3f0d1a4296c5c09e790773e6fc62 Reviewed-by: Miłosz Kosobucki Reviewed-by: Paul Wicking --- src/corelib/doc/snippets/hellotrmain.cpp | 6 +++--- src/corelib/kernel/qtranslator.cpp | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/corelib/doc/snippets/hellotrmain.cpp b/src/corelib/doc/snippets/hellotrmain.cpp index 721a83240b..526da44701 100644 --- a/src/corelib/doc/snippets/hellotrmain.cpp +++ b/src/corelib/doc/snippets/hellotrmain.cpp @@ -54,15 +54,15 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); QTranslator translator; - // look up e.g. :/translations/myapp_de.qm - if (translator.load(QLocale(), QLatin1String("myapp"), QLatin1String("_"), QLatin1String(":/translations"))) + // look up e.g. :/i18n/myapp_de.qm + if (translator.load(QLocale(), QLatin1String("myapp"), QLatin1String("_"), QLatin1String(":/i18n"))) QCoreApplication::installTranslator(&translator); QPushButton hello(QCoreApplication::translate("main", "Hello world!")); hello.resize(100, 30); hello.show(); - return QCoreApplication::exec(); + return app.exec(); } //! [0] diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp index 2205366696..d7d670b5bc 100644 --- a/src/corelib/kernel/qtranslator.cpp +++ b/src/corelib/kernel/qtranslator.cpp @@ -341,8 +341,9 @@ public: Translation files are created using \l{Qt Linguist}. The most common use of QTranslator is to: load a translation - file, install it using QCoreApplication::installTranslator(), and use - it via QObject::tr(). Here's an example \c main() function using the + file, and install it using QCoreApplication::installTranslator(). + + Here's an example \c main() function using the QTranslator: \snippet hellotrmain.cpp 0 -- cgit v1.2.3 From 540b6f6d64448bc4ba8381310f01585bd4be65ac Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 29 Apr 2020 08:18:21 +0200 Subject: Doc: Fix compilation of testlib snippets if sql, widgets are missing Change-Id: Ibcc872408ba829085809737004d9d3186bd20bab Reviewed-by: Paul Wicking --- src/testlib/doc/snippets/snippets.pro | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/testlib/doc/snippets/snippets.pro b/src/testlib/doc/snippets/snippets.pro index 28b6682b72..d1ca7ca3ec 100644 --- a/src/testlib/doc/snippets/snippets.pro +++ b/src/testlib/doc/snippets/snippets.pro @@ -1,3 +1,6 @@ +requires(qtHaveModule(sql)) +requires(qtHaveModule(widgets)) + TEMPLATE = app TARGET = testlib_cppsnippet QT = core testlib sql widgets -- cgit v1.2.3 From dbaf62033af3fdd7998c108246d0d96416595605 Mon Sep 17 00:00:00 2001 From: Assam Boudjelthia Date: Tue, 21 Apr 2020 16:42:44 +0300 Subject: Android: fix mimeTypes handling for file dialog Since Android native file manager supports mimeTypes, I use QMimeDatabase to get the correct mime type for the nameFilter used with the file dialog. [ChangeLog][Android] Support setting mimetypes and and namefilters for Android native file dialog. Task-number: QTBUG-83089 Change-Id: I46545576dc9b51aa872bb37dbf4fe12b2533bdd9 Reviewed-by: Ville Voutilainen --- .../src/org/qtproject/qt5/android/QtNative.java | 5 +++ .../android/qandroidplatformfiledialoghelper.cpp | 46 +++++++++++++++++++--- 2 files changed, 45 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java index 76ecbe043b..f408d65895 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtNative.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtNative.java @@ -157,6 +157,11 @@ public class QtNative } } + public static String[] getStringArray(String joinedString) + { + return joinedString.split(","); + } + private static Uri getUriWithValidPermission(Context context, String uri, String openMode) { try { diff --git a/src/plugins/platforms/android/qandroidplatformfiledialoghelper.cpp b/src/plugins/platforms/android/qandroidplatformfiledialoghelper.cpp index 7b5f2f16f8..2e29a22cf7 100644 --- a/src/plugins/platforms/android/qandroidplatformfiledialoghelper.cpp +++ b/src/plugins/platforms/android/qandroidplatformfiledialoghelper.cpp @@ -42,6 +42,10 @@ #include #include +#include +#include +#include + QT_BEGIN_NAMESPACE namespace QtAndroidFileDialogHelper { @@ -147,17 +151,47 @@ void QAndroidPlatformFileDialogHelper::setAllowMultipleSelections(bool allowMult allowMultipleSelections.object(), allowMultiple); } +QStringList nameFilterExtensions(const QString nameFilters) +{ + QStringList ret; +#if QT_CONFIG(regularexpression) + QRegularExpression re("(\\*\\.?\\w*)"); + QRegularExpressionMatchIterator i = re.globalMatch(nameFilters); + while (i.hasNext()) + ret << i.next().captured(1); +#endif // QT_CONFIG(regularexpression) + ret.removeAll("*"); + return ret; +} + void QAndroidPlatformFileDialogHelper::setMimeTypes() { + QStringList mimeTypes = options()->mimeTypeFilters(); + const QString nameFilter = options()->initiallySelectedNameFilter(); + + if (mimeTypes.isEmpty() && !nameFilter.isEmpty()) { + QMimeDatabase db; + for (const QString &filter : nameFilterExtensions(nameFilter)) + mimeTypes.append(db.mimeTypeForFile(filter).name()); + } + + QString type = !mimeTypes.isEmpty() ? mimeTypes.at(0) : QLatin1String("*/*"); m_intent.callObjectMethod("setType", "(Ljava/lang/String;)Landroid/content/Intent;", - QJNIObjectPrivate::fromString("*/*").object()); + QJNIObjectPrivate::fromString(type).object()); + + if (!mimeTypes.isEmpty()) { + const QJNIObjectPrivate extraMimeType = QJNIObjectPrivate::getStaticObjectField( + JniIntentClass, "EXTRA_MIME_TYPES", "Ljava/lang/String;"); + + QJNIObjectPrivate mimeTypesArray = QJNIObjectPrivate::callStaticObjectMethod( + "org/qtproject/qt5/android/QtNative", + "getStringArray", + "(Ljava/lang/String;)[Ljava/lang/String;", + QJNIObjectPrivate::fromString(mimeTypes.join(",")).object()); - const QJNIObjectPrivate extraMimeType = QJNIObjectPrivate::getStaticObjectField( - JniIntentClass, "EXTRA_MIME_TYPES", "Ljava/lang/String;"); - for (const QString &type : options()->mimeTypeFilters()) { m_intent.callObjectMethod( - "putExtra", "(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;", - extraMimeType.object(), QJNIObjectPrivate::fromString(type).object()); + "putExtra", "(Ljava/lang/String;[Ljava/lang/String;)Landroid/content/Intent;", + extraMimeType.object(), mimeTypesArray.object()); } } -- cgit v1.2.3 From e7efa77bb3e730c123411f3ed679036df812f57f Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sun, 5 Apr 2020 14:54:04 +0200 Subject: Compile fixes for clang10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix some warnings that are flagged as errors on clang10. Change-Id: I906634c8b2bd94db42d74a7f3d10efb086e373cc Reviewed-by: Mårten Nordheim (cherry picked from commit bc726ed5d96161b70a22b9a11e0943acca219cfc) --- .../itemmodels/qconcatenatetablesproxymodel.cpp | 2 +- src/corelib/itemmodels/qidentityproxymodel.cpp | 2 +- src/corelib/itemmodels/qtransposeproxymodel.cpp | 2 +- src/corelib/text/qlocale.cpp | 2 +- src/gui/painting/qdrawhelper.cpp | 18 +++++++++--------- src/gui/painting/qregion.cpp | 2 +- src/gui/text/qfontengine.cpp | 8 ++++---- src/gui/util/qvalidator.cpp | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp b/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp index a2597faa93..0e29714677 100644 --- a/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp +++ b/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp @@ -642,7 +642,7 @@ void QConcatenateTablesProxyModelPrivate::_q_slotSourceLayoutAboutToBeChanged(co layoutChangePersistentIndexes.reserve(persistentIndexList.size()); layoutChangeProxyIndexes.reserve(persistentIndexList.size()); - for (const QPersistentModelIndex &proxyPersistentIndex : persistentIndexList) { + for (const QModelIndex &proxyPersistentIndex : persistentIndexList) { layoutChangeProxyIndexes.append(proxyPersistentIndex); Q_ASSERT(proxyPersistentIndex.isValid()); const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex); diff --git a/src/corelib/itemmodels/qidentityproxymodel.cpp b/src/corelib/itemmodels/qidentityproxymodel.cpp index f5684c6eda..8210e27f8a 100644 --- a/src/corelib/itemmodels/qidentityproxymodel.cpp +++ b/src/corelib/itemmodels/qidentityproxymodel.cpp @@ -532,7 +532,7 @@ void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QListlayoutAboutToBeChanged(parents, hint); const auto proxyPersistentIndexes = q->persistentIndexList(); - for (const QPersistentModelIndex &proxyPersistentIndex : proxyPersistentIndexes) { + for (const QModelIndex &proxyPersistentIndex : proxyPersistentIndexes) { proxyIndexes << proxyPersistentIndex; Q_ASSERT(proxyPersistentIndex.isValid()); const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex); diff --git a/src/corelib/itemmodels/qtransposeproxymodel.cpp b/src/corelib/itemmodels/qtransposeproxymodel.cpp index 4853f90632..207faa6151 100644 --- a/src/corelib/itemmodels/qtransposeproxymodel.cpp +++ b/src/corelib/itemmodels/qtransposeproxymodel.cpp @@ -92,7 +92,7 @@ void QTransposeProxyModelPrivate::onLayoutAboutToBeChanged(const QListmapToSource(proxyPersistentIndex); diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index e74b825774..fac62c94a4 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -4509,7 +4509,7 @@ QStringList QLocale::uiLanguages() const if (!res.isNull()) { uiLanguages = res.toStringList(); // ... but we need to include likely-adjusted forms of each of those, too: - for (const auto entry : qAsConst(uiLanguages)) + for (const auto &entry : qAsConst(uiLanguages)) locales.append(QLocale(entry)); } if (locales.isEmpty()) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index f153557077..169b6b8869 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -2842,15 +2842,15 @@ static void QT_FASTCALL fetchTransformedBilinearARGB32PM_fast_rotate_helper(uint fy += fdy; ++b; } - uint *boundedEnd = end; \ - if (fdx > 0) \ - boundedEnd = qMin(boundedEnd, b + (max_fx - fx) / fdx); \ - else if (fdx < 0) \ - boundedEnd = qMin(boundedEnd, b + (min_fx - fx) / fdx); \ - if (fdy > 0) \ - boundedEnd = qMin(boundedEnd, b + (max_fy - fy) / fdy); \ - else if (fdy < 0) \ - boundedEnd = qMin(boundedEnd, b + (min_fy - fy) / fdy); \ + uint *boundedEnd = end; + if (fdx > 0) + boundedEnd = qMin(boundedEnd, b + (max_fx - fx) / fdx); + else if (fdx < 0) + boundedEnd = qMin(boundedEnd, b + (min_fx - fx) / fdx); + if (fdy > 0) + boundedEnd = qMin(boundedEnd, b + (max_fy - fy) / fdy); + else if (fdy < 0) + boundedEnd = qMin(boundedEnd, b + (min_fy - fy) / fdy); // until boundedEnd we can now have a fast middle part without boundary checks #if defined(__SSE2__) diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp index bac042c784..739a4d04e6 100644 --- a/src/gui/painting/qregion.cpp +++ b/src/gui/painting/qregion.cpp @@ -2845,7 +2845,7 @@ static bool RectInRegion(QRegionPrivate *region, int rx, int ry, uint rwidth, ui break; } } - return partIn ? ((ry <= prect->bottom()) ? RectanglePart : RectangleIn) : RectangleOut; + return partIn; } // END OF Region.c extract // START OF poly.h extract diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index b6046b0fc5..5005f120dd 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -757,10 +757,10 @@ Q_GUI_EXPORT void qt_addBitmapToPath(qreal x0, qreal y0, const uchar *image_data // set up edges for (int y = 0; y <= h; ++y) { for (int x = 0; x <= w; ++x) { - bool topLeft = (x == 0)|(y == 0) ? false : SET(x - 1, y - 1); - bool topRight = (x == w)|(y == 0) ? false : SET(x, y - 1); - bool bottomLeft = (x == 0)|(y == h) ? false : SET(x - 1, y); - bool bottomRight = (x == w)|(y == h) ? false : SET(x, y); + bool topLeft = (x == 0 || y == 0) ? false : SET(x - 1, y - 1); + bool topRight = (x == w || y == 0) ? false : SET(x, y - 1); + bool bottomLeft = (x == 0 || y == h) ? false : SET(x - 1, y); + bool bottomRight = (x == w || y == h) ? false : SET(x, y); GRID(x, y) = 0; if ((!topRight) & bottomRight) diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp index 6e87faf534..a2faa21172 100644 --- a/src/gui/util/qvalidator.cpp +++ b/src/gui/util/qvalidator.cpp @@ -704,7 +704,7 @@ QValidator::State QDoubleValidatorPrivate::validateWithLocale(QString &input, QL if (notation == QDoubleValidator::StandardNotation) { double max = qMax(qAbs(q->b), qAbs(q->t)); - if (max < LLONG_MAX) { + if (max < double(LLONG_MAX)) { qlonglong n = pow10(numDigits(qlonglong(max))); // In order to get the highest possible number in the intermediate // range we need to get 10 to the power of the number of digits -- cgit v1.2.3 From 538223d10d133d23133db1ec7a50cb2775aca657 Mon Sep 17 00:00:00 2001 From: Paul Wicking Date: Wed, 29 Apr 2020 08:57:03 +0200 Subject: Doc: Enable snippet compilation Enable compilation of snippets in network, widgets, and testlib. Task-number: QTBUG-74787 Task-number: QTBUG-81497 Done-with: Nico Vertriest Done-with: Kai Koehne Change-Id: Ifdc7c06698bdee5fd423a145320f6cc0db63622b Reviewed-by: Nico Vertriest --- src/src.pro | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/src.pro b/src/src.pro index 043577173b..c73d58819e 100644 --- a/src/src.pro +++ b/src/src.pro @@ -168,12 +168,18 @@ win32:SUBDIRS += src_winmain qtConfig(network) { SUBDIRS += src_network src_plugins.depends += src_network + qtHaveModule(gui):qtConfig(private_tests) { + src_network_doc_snippets.subdir = network/doc/snippets + src_network_doc_snippets.target = sub-network-doc-snippets + src_network_doc_snippets.depends = src_network + SUBDIRS += src_network_doc_snippets + } } qtConfig(sql) { SUBDIRS += src_sql src_plugins.depends += src_sql - contains(QT_CONFIG, private_tests) { + qtConfig(private_tests) { src_sql_doc_snippets.subdir = sql/doc/snippets src_sql_doc_snippets.target = sub-sql-doc-snippets src_sql_doc_snippets.depends = src_sql @@ -181,7 +187,16 @@ qtConfig(sql) { } } qtConfig(xml): SUBDIRS += src_xml -qtConfig(testlib): SUBDIRS += src_testlib +qtConfig(testlib) { + SUBDIRS += src_testlib + qtConfig(private_tests) { + src_testlib_doc_snippets.subdir = testlib/doc/snippets + src_testlib_doc_snippets.target = sub-testlib-doc-snippets + src_testlib_doc_snippets.depends = src_testlib + SUBDIRS += src_testlib_doc_snippets + } +} + qtConfig(dbus) { force_dbus_bootstrap|qtConfig(private_tests): \ SUBDIRS += src_tools_bootstrap_dbus @@ -240,6 +255,12 @@ qtConfig(gui) { SUBDIRS += src_opengl src_plugins.depends += src_opengl } + qtConfig(private_tests) { + src_widgets_doc_snippets.subdir = widgets/doc/snippets + src_widgets_doc_snippets.target = sub-widgets-doc-snippets + src_widgets_doc_snippets.depends = src_widgets + SUBDIRS += src_widgets_doc_snippets + } } } SUBDIRS += src_plugins -- cgit v1.2.3