Merge "Merge remote-tracking branch 'origin/5.15' into dev"
commit
16e21c0a67
|
|
@ -419,14 +419,6 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
|
|||
!!ENDIF
|
||||
!!ENDIF
|
||||
|
||||
# Add a versionless target, for compatibility with Qt6.
|
||||
if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND NOT TARGET Qt::$${CMAKE_MODULE_NAME})
|
||||
add_library(Qt::$${CMAKE_MODULE_NAME} INTERFACE IMPORTED)
|
||||
set_target_properties(Qt::$${CMAKE_MODULE_NAME} PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES \"Qt5::$${CMAKE_MODULE_NAME}\"
|
||||
)
|
||||
endif()
|
||||
|
||||
!!IF !equals(TEMPLATE, aux)
|
||||
!!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
|
||||
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY FRAMEWORK 1)
|
||||
|
|
@ -648,3 +640,11 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
|
|||
|
||||
_qt5_$${CMAKE_MODULE_NAME}_check_file_exists(\"${CMAKE_CURRENT_LIST_DIR}/Qt5$${CMAKE_MODULE_NAME}ConfigVersion.cmake\")
|
||||
endif()
|
||||
|
||||
# Add a versionless target, for compatibility with Qt6.
|
||||
if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND TARGET Qt5::$${CMAKE_MODULE_NAME} AND NOT TARGET Qt::$${CMAKE_MODULE_NAME})
|
||||
add_library(Qt::$${CMAKE_MODULE_NAME} INTERFACE IMPORTED)
|
||||
set_target_properties(Qt::$${CMAKE_MODULE_NAME} PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES \"Qt5::$${CMAKE_MODULE_NAME}\"
|
||||
)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -159,6 +159,11 @@ public class QtNative
|
|||
}
|
||||
}
|
||||
|
||||
public static String[] getStringArray(String joinedString)
|
||||
{
|
||||
return joinedString.split(",");
|
||||
}
|
||||
|
||||
private static Uri getUriWithValidPermission(Context context, String uri, String openMode)
|
||||
{
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -42,6 +42,10 @@
|
|||
#include <androidjnimain.h>
|
||||
#include <jni.h>
|
||||
|
||||
#include <QMimeType>
|
||||
#include <QMimeDatabase>
|
||||
#include <QRegularExpression>
|
||||
|
||||
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()
|
||||
{
|
||||
m_intent.callObjectMethod("setType", "(Ljava/lang/String;)Landroid/content/Intent;",
|
||||
QJNIObjectPrivate::fromString("*/*").object());
|
||||
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(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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
27
src/src.pro
27
src/src.pro
|
|
@ -162,7 +162,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
|
||||
}
|
||||
|
|
@ -172,12 +172,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
|
||||
|
|
@ -185,7 +191,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
|
||||
|
|
@ -248,6 +263,12 @@ qtConfig(gui) {
|
|||
qtConfig(opengl) {
|
||||
SUBDIRS += src_openglwidgets
|
||||
}
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
requires(qtHaveModule(sql))
|
||||
requires(qtHaveModule(widgets))
|
||||
|
||||
TEMPLATE = app
|
||||
TARGET = testlib_cppsnippet
|
||||
QT = core testlib sql widgets
|
||||
|
|
|
|||
|
|
@ -161,3 +161,4 @@ if (NOT CMAKE_VERSION VERSION_LESS 3.8)
|
|||
endif()
|
||||
|
||||
expect_pass(test_import_plugins BINARY ${CMAKE_CTEST_COMMAND})
|
||||
expect_pass(test_versionless_targets)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(versionless_targets)
|
||||
|
||||
set(QT_NO_CREATE_VERSIONLESS_TARGETS ON)
|
||||
|
||||
find_package(Qt5Core REQUIRED)
|
||||
|
||||
if (NOT TARGET Qt5::Core)
|
||||
message(SEND_ERROR "Qt5::Core target not defined!")
|
||||
endif()
|
||||
|
||||
if (TARGET Qt::Core)
|
||||
message(SEND_ERROR "Qt::Core target defined despite QT_NO_CREATE_VERSIONLESS_TARGETS!")
|
||||
endif()
|
||||
|
||||
set(QT_NO_CREATE_VERSIONLESS_TARGETS OFF)
|
||||
|
||||
find_package(Qt5Core REQUIRED)
|
||||
|
||||
if (NOT TARGET Qt::Core)
|
||||
message(SEND_ERROR "Qt::Core target not defined!")
|
||||
endif()
|
||||
Loading…
Reference in New Issue