Merge remote-tracking branch 'origin/5.7' into 5.8

Conflicts:
	config.tests/win/msvc_version.cpp
	configure.pri
	mkspecs/macx-ios-clang/features/default_post.prf
	mkspecs/macx-ios-clang/features/resolve_config.prf
	mkspecs/features/uikit/default_post.prf
	mkspecs/features/uikit/resolve_config.prf
	src/corelib/io/qsettings_mac.cpp
	src/corelib/json/qjsondocument.cpp
	src/plugins/platforms/cocoa/qcocoawindow.h
	src/plugins/platforms/cocoa/qcocoawindow.mm
	src/plugins/platforms/cocoa/qnswindowdelegate.h
	src/plugins/platforms/cocoa/qnswindowdelegate.mm
	src/plugins/platforms/ios/ios.pro
	src/plugins/platforms/ios/kernel.pro
	src/plugins/platforms/ios/qiosintegration.h
	src/plugins/platforms/minimalegl/qminimaleglintegration.cpp
	tests/auto/gui/painting/qpainter/tst_qpainter.cpp
	tools/configure/environment.cpp

Change-Id: I654845e54e40f5951fb78aab349ca667e9f27843
This commit is contained in:
Liang Qi 2016-10-31 20:09:14 +01:00
commit a732576a66
150 changed files with 14094 additions and 11839 deletions

View File

@ -1,6 +1 @@
mingw {
TMPPATH = $$(INCLUDE)
QMAKE_INCDIR_POST += $$split(TMPPATH, $$QMAKE_DIRLIST_SEP)
TMPPATH = $$(LIB)
QMAKE_LIBDIR_POST += $$split(TMPPATH, $$QMAKE_DIRLIST_SEP)
}
# This file exists only to detach the tests from the surroundings.

View File

@ -0,0 +1 @@
_MSC_FULL_VER

View File

@ -247,11 +247,12 @@ defineTest(qtConfTest_checkCompiler) {
$${1}.compilerId = "icc"
$${1}.compilerVersion = $$replace(version, "icpc version ([0-9.]+).*", "\\1")
} else: msvc {
qtRunLoggedCommand("$$QMAKE_CXX /? 2>&1", version)|return(false)
command = $$QMAKE_CXX /EP /nologo $$source $$system_quote($$QMAKE_CONFIG_TESTS_DIR/win/msvc_version.cpp)
qtRunLoggedCommand("$$command", version)|return(false)
version = "$$version"
$${1}.compilerDescription = "MSVC"
$${1}.compilerId = "cl"
$${1}.compilerVersion = $$replace(version, "^.*Compiler Version ([0-9.]+) for.*$", "\\1")
$${1}.compilerVersion = $$replace(version, "^.*([0-9]{2})([0-9]{2})([0-9]{5}).*$", "\\1.\\2.\\3")
} else {
return(false)
}

View File

@ -1,4 +1,4 @@
pre {
pre, .LegaleseLeft {
background-color: #f0f0f0;
font-family: Courier, monospace;
font-weight: 600;

View File

@ -18,8 +18,12 @@ img {
height: auto;
}
.content {
.content .border img {
box-shadow:3px 3px 8px 3px rgba(200,200,200,0.5)
}
.content .border .player {
box-shadow:3px 3px 8px 3px rgba(200,200,200,0.5)
}
.content .indexboxcont li {
@ -424,7 +428,7 @@ table styles
/* table with border alternative colours*/
table, pre {
table, pre, .LegaleseLeft {
-moz-border-radius: 7px 7px 7px 7px;
-webkit-border-radius: 7px 7px 7px 7px;
border-radius: 7px 7px 7px 7px;
@ -481,6 +485,10 @@ table, pre {
margin: 0px
}
.LegaleseLeft {
font-family: monospace;
white-space: pre-wrap;
}
/* table bodless & white*/
.borderless {
@ -543,7 +551,7 @@ ol.a > li{
text-align: left
}
.cpp {
.cpp, .LegaleseLeft {
display: block;
margin: 10px;
overflow: auto;

View File

@ -1280,6 +1280,12 @@ li a.active {
margin-top:0.75em;
max-width:100%
}
.context .border img {
box-shadow:3px 3px 8px 3px rgba(200,200,200,0.5)
}
.context .border .player {
box-shadow:3px 3px 8px 3px rgba(200,200,200,0.5)
}
.context table {
vertical-align:initial
}
@ -1364,7 +1370,7 @@ div.qt_commercial {
border-top:5px solid #5caa15;
margin-bottom:50px
}
pre {
pre, .LegaleseLeft {
background-color:#404244;
color:#fff;
display:block;
@ -1375,6 +1381,10 @@ pre {
padding:25px;
margin-top:0.75em
}
.mainContent .LegaleseLeft p {
color:#fff;
white-space: pre-wrap
}
.copy_text {
background-color:#46a2da;
color:#fff;

View File

@ -261,7 +261,7 @@
\snippet widgets/calculator/calculator.cpp 20
Like in \c additiveOperatorClicked(), we start by handing any
Like in \c additiveOperatorClicked(), we start by handling any
pending multiplicative and additive operators. Then we display \c
sumSoFar and reset the variable to zero. Resetting the variable
to zero is necessary to avoid counting the value twice.

View File

@ -55,7 +55,7 @@ while (<STDIN>) {
my $comment = " /* $1 */";
while (my $line = <HDR>) {
# Match a struct or class declaration, but not a forward declaration
$line =~ /^(?:struct|class) (?:Q_.*_EXPORT)? (\w+)(?!;)/ or next;
$line =~ /^(?:struct|class|namespace) (?:Q_.*_EXPORT)? (\w+)(?!;)/ or next;
print $comment if $comment;
printf " *%d%s*;\n", length $1, $1;
$comment = 0;

View File

@ -1,12 +1,9 @@
defineTest(addExclusiveBuilds) {
lessThan(ARGC, 2): \
error("addExclusiveBuilds() requires at least two arguments")
!$$join(ARGS, _and_):!fix_output_dirs: \
defineTest(addExclusiveBuildsProper) {
!$$1:!fix_output_dirs: \
return(true)
for(build, ARGS) {
for(build, 2) {
isEmpty($${build}.name) {
$${build}.name = $$title($$build)
export($${build}.name)
@ -20,7 +17,7 @@ defineTest(addExclusiveBuilds) {
export($${build}.dir_affix)
}
$${build}.exclusive = $$ARGS
$${build}.exclusive = $$2
export($${build}.exclusive)
QMAKE_EXCLUSIVE_BUILDS += $$build
@ -33,6 +30,13 @@ defineTest(addExclusiveBuilds) {
return(true)
}
defineTest(addExclusiveBuilds) {
lessThan(ARGC, 2): \
error("addExclusiveBuilds() requires at least two arguments")
addExclusiveBuildsProper($$join(ARGS, _and_), $$ARGS)
}
# Default directories to process
QMAKE_DIR_REPLACE = OBJECTS_DIR MOC_DIR RCC_DIR PRECOMPILED_DIR QGLTF_DIR DESTDIR
QMAKE_DIR_REPLACE_SANE += QGLTF_DIR

View File

@ -1,6 +1,7 @@
# Objective-C/C++ sources go in SOURCES, like all other sources
SOURCES += $$OBJECTIVE_SOURCES
unset(OBJECTIVE_SOURCES)
# Strip C/C++ flags from QMAKE_OBJECTIVE_CFLAGS just in case
QMAKE_OBJECTIVE_CFLAGS -= $$QMAKE_CFLAGS $$QMAKE_CXXFLAGS
@ -8,3 +9,4 @@ QMAKE_OBJECTIVE_CFLAGS -= $$QMAKE_CFLAGS $$QMAKE_CXXFLAGS
# Add Objective-C/C++ flags to C/C++ flags, the compiler can handle it
QMAKE_CFLAGS += $$QMAKE_OBJECTIVE_CFLAGS
QMAKE_CXXFLAGS += $$QMAKE_OBJECTIVE_CFLAGS
unset(QMAKE_OBJECTIVE_CFLAGS)

View File

@ -79,7 +79,7 @@ moc_source.CONFIG = no_link moc_verify
moc_source.dependency_type = TYPE_C
moc_source.commands = ${QMAKE_FUNC_mocCmdBase} ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
moc_source.output = $$MOC_DIR/$${QMAKE_CPP_MOD_MOC}${QMAKE_FILE_BASE}$${QMAKE_EXT_CPP_MOC}
moc_source.input = SOURCES OBJECTIVE_SOURCES
moc_source.input = SOURCES
moc_source.name = MOC ${QMAKE_FILE_IN}
moc_source.depends += $$WIN_INCLUDETEMP $$moc_predefs.output
silent:moc_source.commands = @echo moc ${QMAKE_FILE_IN} && $$moc_source.commands

View File

@ -292,7 +292,8 @@ contains(TEMPLATE, .*app) {
autoplugs =
for (qtmod, qt_module_deps) {
for (ptype, QT.$${qtmod}.plugin_types) {
isEmpty(QTPLUGIN.$$ptype) {
nptype = $$replace(ptype, [-/], _)
isEmpty(QTPLUGIN.$$nptype) {
for (plug, QT_PLUGINS) {
equals(QT_PLUGIN.$${plug}.TYPE, $$ptype) {
for (dep, QT_PLUGIN.$${plug}.EXTENDS) {
@ -305,7 +306,7 @@ contains(TEMPLATE, .*app) {
}
}
} else {
plug = $$eval(QTPLUGIN.$$ptype)
plug = $$eval(QTPLUGIN.$$nptype)
!equals(plug, -): \
autoplugs += $$plug
}

View File

@ -101,7 +101,7 @@ defineReplace(qtExportLibsForModule) {
else: \
module_config =
!isEmpty(MODULE_PLUGIN_TYPES): \
module_plugtypes = "QT.$${MODULE_ID}.plugin_types = $$replace(MODULE_PLUGIN_TYPES, /.*$, )"
module_plugtypes = "QT.$${MODULE_ID}.plugin_types = $$replace(MODULE_PLUGIN_TYPES, /[^.]+\\.[^.]+$, )"
else: \
module_plugtypes =
!isEmpty(MODULE_MASTER_HEADER): \

View File

@ -90,3 +90,11 @@ macx-xcode {
QMAKE_PCH_ARCHS = $$VALID_ARCHS
}
!xcodebuild:equals(TEMPLATE, app):!isEmpty(QMAKE_INFO_PLIST) {
# Only link in photo library support if Info.plist contains
# NSPhotoLibraryUsageDescription. Otherwise it will be rejected from AppStore.
plist_path = $$absolute_path($$QMAKE_INFO_PLIST, $$_PRO_FILE_PWD_)
system("/usr/libexec/PlistBuddy -c 'Print NSPhotoLibraryUsageDescription' $$system_quote($$plist_path) &>/dev/null"): \
QTPLUGIN += qiosnsphotolibrarysupport
}

View File

@ -11,7 +11,7 @@ load(resolve_config)
!macx-xcode:xcodebuild {
# Switch the order to make sure that the first Makefile target is the right one
!qtConfig(simulator_and_device):contains(QMAKE_MAC_SDK, ^$${simulator.sdk}.*): \
addExclusiveBuilds(simulator, device)
addExclusiveBuildsProper(simulator_and_device, simulator device)
else: \
addExclusiveBuilds(device, simulator)
addExclusiveBuildsProper(simulator_and_device, device simulator)
}

View File

@ -1813,6 +1813,12 @@
which qmake will replace with the actual executable name. Other variables
include @ICON@, @TYPEINFO@, @LIBRARY@, and @SHORT_VERSION@.
If building for iOS, and the \c{.plist} file contains the key
\c NSPhotoLibraryUsageDescription, qmake will include an additional plugin
to the build that adds photo access support (to, e.g.,
\l{QFileDialog::setDirectory()}{QFile/QFileDialog}). See Info.plist
documentation from Apple for more information regarding this key.
\note Most of the time, the default \c{Info.plist} is good enough.
\section1 QMAKE_LFLAGS

View File

@ -46,6 +46,7 @@
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <limits.h>
#if defined(_MSC_VER) && _MSC_VER >= 1400
#include <share.h>
#endif
@ -986,9 +987,11 @@ bool QMakeSourceFileInfo::findMocs(SourceFile *file)
continue;
int matchlen = 0, extralines = 0;
size_t needle_len = strlen(interesting[interest]);
Q_ASSERT(needle_len <= INT_MAX);
if (matchWhileUnsplitting(buffer, buffer_len, y,
interesting[interest],
strlen(interesting[interest]),
static_cast<int>(needle_len),
&matchlen, &extralines)
&& y + matchlen < buffer_len
&& !isCWordChar(buffer[y + matchlen])) {

View File

@ -374,14 +374,21 @@ void NmakeMakefileGenerator::init()
project->values("QMAKE_DISTCLEAN").append(tgt + ".lib");
}
if (project->isActiveConfig("debug_info")) {
// Add the compiler's PDB file.
QString pdbfile = var("OBJECTS_DIR") + project->first("TARGET") + ".vc.pdb";
QString pdbfile;
QString distPdbFile = tgt + ".pdb";
if (project->isActiveConfig("staticlib")) {
// For static libraries, the compiler's pdb file and the dist pdb file are the same.
pdbfile = distPdbFile;
} else {
// Use $${TARGET}.vc.pdb in the OBJECTS_DIR for the compiler and
// $${TARGET}.pdb (the default) for the linker.
pdbfile = var("OBJECTS_DIR") + project->first("TARGET") + ".vc.pdb";
}
QString escapedPdbFile = escapeFilePath(pdbfile);
project->values("QMAKE_CFLAGS").append("/Fd" + escapedPdbFile);
project->values("QMAKE_CXXFLAGS").append("/Fd" + escapedPdbFile);
project->values("QMAKE_CLEAN").append(pdbfile);
// Add the linker's PDB file to the distclean target.
project->values("QMAKE_DISTCLEAN").append(tgt + ".pdb");
project->values("QMAKE_DISTCLEAN").append(distPdbFile);
}
if (project->isActiveConfig("debug")) {
project->values("QMAKE_CLEAN").append(tgt + ".ilk");

View File

@ -156,12 +156,14 @@ static inline void positionCluster(HB_ShaperItem *item, int gfrom, int glast)
// ### wrong in rtl context!
case HB_Combining_BelowLeft:
p.y += offset;
// fall through
case HB_Combining_BelowLeftAttached:
p.x += attachmentRect.x - markMetrics.x;
p.y += (attachmentRect.y + attachmentRect.height) - markMetrics.y;
break;
case HB_Combining_Below:
p.y += offset;
// fall through
case HB_Combining_BelowAttached:
p.x += attachmentRect.x - markMetrics.x;
p.y += (attachmentRect.y + attachmentRect.height) - markMetrics.y;
@ -170,28 +172,33 @@ static inline void positionCluster(HB_ShaperItem *item, int gfrom, int glast)
break;
case HB_Combining_BelowRight:
p.y += offset;
// fall through
case HB_Combining_BelowRightAttached:
p.x += attachmentRect.x + attachmentRect.width - markMetrics.width - markMetrics.x;
p.y += attachmentRect.y + attachmentRect.height - markMetrics.y;
break;
case HB_Combining_Left:
p.x -= offset;
// fall through
case HB_Combining_LeftAttached:
break;
case HB_Combining_Right:
p.x += offset;
// fall through
case HB_Combining_RightAttached:
break;
case HB_Combining_DoubleAbove:
// ### wrong in RTL context!
case HB_Combining_AboveLeft:
p.y -= offset;
// fall through
case HB_Combining_AboveLeftAttached:
p.x += attachmentRect.x - markMetrics.x;
p.y += attachmentRect.y - markMetrics.y - markMetrics.height;
break;
case HB_Combining_Above:
p.y -= offset;
// fall through
case HB_Combining_AboveAttached:
p.x += attachmentRect.x - markMetrics.x;
p.y += attachmentRect.y - markMetrics.y - markMetrics.height;
@ -200,6 +207,7 @@ static inline void positionCluster(HB_ShaperItem *item, int gfrom, int glast)
break;
case HB_Combining_AboveRight:
p.y -= offset;
// fall through
case HB_Combining_AboveRightAttached:
p.x += attachmentRect.x + attachmentRect.width - markMetrics.x - markMetrics.width;
p.y += attachmentRect.y - markMetrics.y - markMetrics.height;

View File

@ -66,7 +66,7 @@ public class QtActivityLoader extends QtLoader {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
try {
Uri uri = Uri.parse("market://search?q=pname:org.kde.necessitas.ministro");
Uri uri = Uri.parse("market://details?id=org.kde.necessitas.ministro");
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
m_activity.startActivityForResult(intent, MINISTRO_INSTALL_REQUEST_CODE);
} catch (Exception e) {

View File

@ -73,7 +73,7 @@ public abstract class QtLoader {
public final static int MINISTRO_INSTALL_REQUEST_CODE = 0xf3ee; // request code used to know when Ministro instalation is finished
public static final int MINISTRO_API_LEVEL = 5; // Ministro api level (check IMinistro.aidl file)
public static final int NECESSITAS_API_LEVEL = 2; // Necessitas api level used by platform plugin
public static final int QT_VERSION = 0x050100; // This app requires at least Qt version 5.1.0
public static final int QT_VERSION = 0x050700; // This app requires at least Qt version 5.7.0
public static final String ERROR_CODE_KEY = "error.code";
public static final String ERROR_MESSAGE_KEY = "error.message";

View File

@ -113,9 +113,9 @@ QSet<QString> dictionary = QtConcurrent::blockingFilteredReduced(strings, allLow
//! [7]
// keep only images with an alpha channel
QList<QImage> images = ...;
QFuture<void> alphaImages = QtConcurrent::filter(strings, &QImage::hasAlphaChannel);
QFuture<void> alphaImages = QtConcurrent::filter(images, &QImage::hasAlphaChannel);
// keep only gray scale images
// retrieve gray scale images
QList<QImage> images = ...;
QFuture<QImage> grayscaleImages = QtConcurrent::filtered(images, &QImage::isGrayscale);

View File

@ -158,11 +158,8 @@
\endtable
Containers can be nested. For example, it is perfectly possible
to use a QMap<QString, QList<int> >, where the key type is
QString and the value type QList<int>. The only pitfall is that
you must insert a space between the closing angle brackets (>);
otherwise the C++ compiler will misinterpret the two >'s as a
right-shift operator (>>) and report a syntax error.
to use a QMap<QString, QList<int>>, where the key type is
QString and the value type QList<int>.
The containers are defined in individual header files with the
same name as the container (e.g., \c <QLinkedList>). For

View File

@ -80,7 +80,7 @@
\section1 Event Types
Most events types have special classes, notably QResizeEvent,
Most event types have special classes, notably QResizeEvent,
QPaintEvent, QMouseEvent, QKeyEvent, and QCloseEvent. Each class
subclasses QEvent and adds event-specific functions. For example,
QResizeEvent adds \l{QResizeEvent::}{size()} and

View File

@ -4251,8 +4251,10 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
Compares the floating point value \a p1 and \a p2 and
returns \c true if they are considered equal, otherwise \c false.
Note that comparing values where either \a p1 or \a p2 is 0.0 will not work.
The solution to this is to compare against values greater than or equal to 1.0.
Note that comparing values where either \a p1 or \a p2 is 0.0 will not work,
nor does comparing values where one of the values is NaN or infinity.
If one of the values is always 0.0, use qFuzzyIsNull instead. If one of the
values is likely to be 0.0, one solution is to add 1.0 to both values.
\snippet code/src_corelib_global_qglobal.cpp 46

View File

@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE
* There will only be one copy of the section in the output library or application.
*/
#if defined(QT_BUILD_CORE_LIB) || defined(QT_BOOTSTRAPPED) || defined(QT_NO_VERSION_TAGGING)
#if defined(QT_BUILD_CORE_LIB) || defined(QT_BOOTSTRAPPED) || defined(QT_NO_VERSION_TAGGING) || defined(QT_STATIC)
// don't make tags in QtCore, bootstrapped systems or if the user asked not to
#elif defined(Q_CC_GNU) && !defined(Q_OS_ANDROID)
# if defined(Q_PROCESSOR_X86) && (defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD_KERNEL))

View File

@ -293,8 +293,7 @@ QDateTime &QFileInfoPrivate::getFileTime(QAbstractFileEngine::FileTime request)
\note To speed up performance, QFileInfo caches information about
the file.
To speed up performance, QFileInfo caches information about the
file. Because files can be changed by other users or programs, or
Because files can be changed by other users or programs, or
even by other parts of the same program, there is a function that
refreshes the file information: refresh(). If you want to switch
off a QFileInfo's caching and force it to access the file system

View File

@ -283,7 +283,7 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry,
if (ret) {
data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute;
data.entryFlags |= QFileSystemMetaData::ExistsAttribute;
QString canonicalPath = QDir::cleanPath(QString::fromLocal8Bit(ret));
QString canonicalPath = QDir::cleanPath(QFile::decodeName(ret));
free(ret);
return QFileSystemEntry(canonicalPath);
} else if (errno == ENOENT) { // file doesn't exist

View File

@ -343,7 +343,7 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths,
QStringList p = paths;
QMutableListIterator<QString> it(p);
while (it.hasNext()) {
QString origPath = it.next();
QString origPath = it.next().normalized(QString::NormalizationForm_C);
QString realPath = origPath;
if (realPath.endsWith(QDir::separator()))
realPath = realPath.mid(0, realPath.size() - 1);

View File

@ -382,11 +382,11 @@ qint64 QFSFileEnginePrivate::nativeWrite(const char *data, qint64 len)
// Writing on Windows fails with ERROR_NO_SYSTEM_RESOURCES when
// the chunks are too large, so we limit the block size to 32MB.
const DWORD blockSize = DWORD(qMin(bytesToWrite, qint64(32 * 1024 * 1024)));
qint64 totalWritten = 0;
do {
const DWORD currentBlockSize = DWORD(qMin(bytesToWrite, qint64(32 * 1024 * 1024)));
DWORD bytesWritten;
if (!WriteFile(fileHandle, data + totalWritten, blockSize, &bytesWritten, NULL)) {
if (!WriteFile(fileHandle, data + totalWritten, currentBlockSize, &bytesWritten, NULL)) {
if (totalWritten == 0) {
// Note: Only return error if the first WriteFile failed.
q->setError(QFile::WriteError, qt_error_string());

View File

@ -274,7 +274,6 @@ static QVariant qtValue(CFPropertyListRef cfvalue)
const QString str = QString::fromUtf8(byteArray.constData(), byteArray.size());
return QSettingsPrivate::stringToVariant(str);
} else if (typeId == CFDictionaryGetTypeID()) {
CFDictionaryRef cfdict = static_cast<CFDictionaryRef>(cfvalue);
CFTypeID arrayTypeId = CFArrayGetTypeID();

View File

@ -155,7 +155,7 @@
dealing with URLs and strings:
\list
\li When creating an QString to contain a URL from a QByteArray or a
\li When creating a QString to contain a URL from a QByteArray or a
char*, always use QString::fromUtf8().
\endlist
*/

File diff suppressed because it is too large Load Diff

View File

@ -9,8 +9,8 @@ Those arrays in qurltlds_p.h are derived from the Public
Suffix List ([2]), which was originally provided by
Jo Hermans <jo.hermans@gmail.com>.
The file qurltlds_p.h was last generated Wednesday,
February 11th 14:36 2015.
The file qurltlds_p.h was last generated Thursday,
October 20th 8:40 2016.
----
[1] list: http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1

View File

@ -260,8 +260,7 @@ QJsonDocument QJsonDocument::fromBinaryData(const QByteArray &data, DataValidati
Creates a QJsonDocument from the QVariant \a variant.
If the \a variant contains any other type than a QVariantMap,
QVariantHash, QVariantList or QStringList, the returned document
document is invalid.
QVariantHash, QVariantList or QStringList, the returned document is invalid.
\sa toVariant()
*/

View File

@ -1004,7 +1004,7 @@ bool QCoreApplication::notifyInternal2(QObject *receiver, QEvent *event)
approaches are listed below:
\list 1
\li Reimplementing \l {QWidget::}{paintEvent()}, \l {QWidget::}{mousePressEvent()} and so
on. This is the commonest, easiest, and least powerful way.
on. This is the most common, easiest, and least powerful way.
\li Reimplementing this function. This is very powerful, providing
complete control; but only one subclass can be active at a time.

View File

@ -712,6 +712,10 @@ QMimeXMLProvider::QMimeXMLProvider(QMimeDatabasePrivate *db)
initResources();
}
QMimeXMLProvider::~QMimeXMLProvider()
{
}
bool QMimeXMLProvider::isValid()
{
return true;

View File

@ -138,6 +138,7 @@ class QMimeXMLProvider : public QMimeProviderBase
{
public:
QMimeXMLProvider(QMimeDatabasePrivate *db);
~QMimeXMLProvider();
virtual bool isValid() Q_DECL_OVERRIDE;
virtual QMimeType mimeTypeForName(const QString &name) Q_DECL_OVERRIDE;

View File

@ -89,8 +89,8 @@ public:
void unlock()
{
if (locked) {
if (mtx1) mtx1->unlock();
if (mtx2) mtx2->unlock();
if (mtx1) mtx1->unlock();
locked = false;
}
}
@ -100,7 +100,7 @@ public:
// mtx1 is already locked, mtx2 not... do we need to unlock and relock?
if (mtx1 == mtx2)
return false;
if (mtx1 < mtx2) {
if (std::less<QMutex *>()(mtx1, mtx2)) {
mtx2->lock();
return true;
}

View File

@ -1646,9 +1646,11 @@ QString QTime::toString(Qt::DateFormat format) const
\row \li z \li the milliseconds without leading zeroes (0 to 999)
\row \li zzz \li the milliseconds with leading zeroes (000 to 999)
\row \li AP or A
\li use AM/PM display. \e A/AP will be replaced by either "AM" or "PM".
\li use AM/PM display. \e A/AP will be replaced by either
QLocale::amText() or QLocale::pmText().
\row \li ap or a
\li use am/pm display. \e a/ap will be replaced by either "am" or "pm".
\li use am/pm display. \e a/ap will be replaced by a lower-case version of
QLocale::amText() or QLocale::pmText().
\row \li t \li the timezone (for example "CEST")
\endtable
@ -1657,7 +1659,8 @@ QString QTime::toString(Qt::DateFormat format) const
expression. Two consecutive single quotes ("''") are replaced by a singlequote
in the output. Formats without separators (e.g. "HHmm") are currently not supported.
Example format strings (assuming that the QTime is 14:13:09.042)
Example format strings (assuming that the QTime is 14:13:09.042 and the system
locale is \c{en_US})
\table
\header \li Format \li Result

View File

@ -548,7 +548,7 @@ QT_BEGIN_NAMESPACE
\inmodule QtCore
\reentrant
\brief The QRegularExpressionMatch class provides the results of a matching
\brief The QRegularExpressionMatch class provides the results of matching
a QRegularExpression against a string.
\since 5.0

View File

@ -494,48 +494,46 @@ static int ucstrncmp(const QChar *a, const QChar *b, int l)
if (!l)
return 0;
union {
const QChar *w;
const quint32 *d;
quintptr value;
} sa, sb;
sa.w = a;
sb.w = b;
// check alignment
if ((sa.value & 2) == (sb.value & 2)) {
if ((reinterpret_cast<quintptr>(a) & 2) == (reinterpret_cast<quintptr>(b) & 2)) {
// both addresses have the same alignment
if (sa.value & 2) {
if (reinterpret_cast<quintptr>(a) & 2) {
// both addresses are not aligned to 4-bytes boundaries
// compare the first character
if (*sa.w != *sb.w)
return sa.w->unicode() - sb.w->unicode();
if (*a != *b)
return a->unicode() - b->unicode();
--l;
++sa.w;
++sb.w;
++a;
++b;
// now both addresses are 4-bytes aligned
}
// both addresses are 4-bytes aligned
// do a fast 32-bit comparison
const quint32 *e = sa.d + (l >> 1);
for ( ; sa.d != e; ++sa.d, ++sb.d) {
if (*sa.d != *sb.d) {
if (*sa.w != *sb.w)
return sa.w->unicode() - sb.w->unicode();
return sa.w[1].unicode() - sb.w[1].unicode();
const quint32 *da = reinterpret_cast<const quint32 *>(a);
const quint32 *db = reinterpret_cast<const quint32 *>(b);
const quint32 *e = da + (l >> 1);
for ( ; da != e; ++da, ++db) {
if (*da != *db) {
a = reinterpret_cast<const QChar *>(da);
b = reinterpret_cast<const QChar *>(db);
if (*a != *b)
return a->unicode() - b->unicode();
return a[1].unicode() - b[1].unicode();
}
}
// do we have a tail?
return (l & 1) ? sa.w->unicode() - sb.w->unicode() : 0;
a = reinterpret_cast<const QChar *>(da);
b = reinterpret_cast<const QChar *>(db);
return (l & 1) ? a->unicode() - b->unicode() : 0;
} else {
// one of the addresses isn't 4-byte aligned but the other is
const QChar *e = sa.w + l;
for ( ; sa.w != e; ++sa.w, ++sb.w) {
if (*sa.w != *sb.w)
return sa.w->unicode() - sb.w->unicode();
const QChar *e = a + l;
for ( ; a != e; ++a, ++b) {
if (*a != *b)
return a->unicode() - b->unicode();
}
}
return 0;

View File

@ -761,18 +761,25 @@ QDBusMessage QDBusAbstractInterface::call(QDBus::CallMode mode, const QString &m
switch (count) {
case 8:
argList.prepend(arg8);
// fall through
case 7:
argList.prepend(arg7);
// fall through
case 6:
argList.prepend(arg6);
// fall through
case 5:
argList.prepend(arg5);
// fall through
case 4:
argList.prepend(arg4);
// fall through
case 3:
argList.prepend(arg3);
// fall through
case 2:
argList.prepend(arg2);
// fall through
case 1:
argList.prepend(arg1);
}
@ -819,18 +826,25 @@ QDBusPendingCall QDBusAbstractInterface::asyncCall(const QString &method, const
switch (count) {
case 8:
argList.prepend(arg8);
// fall through
case 7:
argList.prepend(arg7);
// fall through
case 6:
argList.prepend(arg6);
// fall through
case 5:
argList.prepend(arg5);
// fall through
case 4:
argList.prepend(arg4);
// fall through
case 3:
argList.prepend(arg3);
// fall through
case 2:
argList.prepend(arg2);
// fall through
case 1:
argList.prepend(arg1);
}

View File

@ -110,7 +110,7 @@ QDBusServer::~QDBusServer()
QDBusConnectionManager::instance()->removeConnection(name);
d->serverConnectionNames.clear();
}
d->serverObject = nullptr;
d->serverObject = Q_NULLPTR;
d->ref.store(0);
d->deleteLater();
}

View File

@ -9,6 +9,7 @@ QMAKE_DOCS = $$PWD/doc/qtgui.qdocconf
MODULE_PLUGIN_TYPES = \
platforms \
platforms/darwin \
xcbglintegrations \
platformthemes \
platforminputcontexts \

View File

@ -95,7 +95,6 @@ public:
QIcon::State state) = 0;
QString filename;
QIconDirInfo dir;
static int count;
};
struct ScalableEntry : public QIconLoaderEngineEntry
@ -124,18 +123,18 @@ public:
QIconLoaderEngine(const QString& iconName = QString());
~QIconLoaderEngine();
void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state);
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state);
QIconEngine *clone() const;
bool read(QDataStream &in);
bool write(QDataStream &out) const;
void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) Q_DECL_OVERRIDE;
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) Q_DECL_OVERRIDE;
QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) Q_DECL_OVERRIDE;
QIconEngine *clone() const Q_DECL_OVERRIDE;
bool read(QDataStream &in) Q_DECL_OVERRIDE;
bool write(QDataStream &out) const Q_DECL_OVERRIDE;
private:
QString key() const;
QString key() const Q_DECL_OVERRIDE;
bool hasIcon() const;
void ensureLoaded();
void virtual_hook(int id, void *data);
void virtual_hook(int id, void *data) Q_DECL_OVERRIDE;
QIconLoaderEngineEntry *entryForSize(const QSize &size);
QIconLoaderEngine(const QIconLoaderEngine &other);
QThemeIconInfo m_info;

View File

@ -5062,7 +5062,7 @@ static Q_CONSTEXPR QPixelFormat pixelformats[] = {
/*ALPHA USAGE*/ QPixelFormat::IgnoresAlpha,
/*ALPHA POSITION*/ QPixelFormat::AtBeginning,
/*PREMULTIPLIED*/ QPixelFormat::NotPremultiplied,
/*INTERPRETATION*/ QPixelFormat::UnsignedInteger,
/*INTERPRETATION*/ QPixelFormat::UnsignedByte,
/*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian),
//QImage::Format_RGB444:
QPixelFormat(QPixelFormat::RGB,

View File

@ -930,12 +930,12 @@ static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConvers
const int dest_pad = (dst_bytes_per_line >> 1) - width;
quint16 colorTableRGB16[256];
if (data->colortable.isEmpty()) {
const int tableSize = data->colortable.size();
if (tableSize == 0) {
for (int i = 0; i < 256; ++i)
colorTableRGB16[i] = qConvertRgb32To16(qRgb(i, i, i));
} else {
// 1) convert the existing colors to RGB16
const int tableSize = data->colortable.size();
for (int i = 0; i < tableSize; ++i)
colorTableRGB16[i] = qConvertRgb32To16(data->colortable.at(i));
data->colortable = QVector<QRgb>();

View File

@ -425,8 +425,9 @@ void QClipboard::setPixmap(const QPixmap &pixmap, Mode mode)
/*!
\fn QMimeData *QClipboard::mimeData(Mode mode) const
Returns a reference to a QMimeData representation of the current
clipboard data.
Returns a pointer to a QMimeData representation of the current
clipboard data (can be NULL if the given \a mode is not
supported by the platform).
The \a mode argument is used to control which part of the system
clipboard is used. If \a mode is QClipboard::Clipboard, the

View File

@ -350,6 +350,16 @@ void QWindowGeometrySpecification::applyTo(QWindow *window) const
static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOMETRY_SPECIFICATION_INITIALIZER;
/*!
\macro qGuiApp
\relates QGuiApplication
A global pointer referring to the unique application object.
Only valid for use when that object is a QGuiApplication.
\sa QCoreApplication::instance(), qApp
*/
/*!
\class QGuiApplication
\brief The QGuiApplication class manages the GUI application's control

View File

@ -342,6 +342,10 @@ void QPlatformScreen::resizeMaximizedWindows()
for (int i = 0; i < windows.size(); ++i) {
QWindow *w = windows.at(i);
// Skip non-platform windows, e.g., offscreen windows.
if (!w->handle())
continue;
if (platformScreenForWindow(w) != this)
continue;

View File

@ -41,6 +41,8 @@
#include <QtCore/qatomic.h>
#include <QtCore/QDebug>
#include <QOpenGLContext>
#include <QtGui/qguiapplication.h>
#ifdef major
#undef major
@ -761,6 +763,16 @@ Q_GLOBAL_STATIC(QSurfaceFormat, qt_default_surface_format)
*/
void QSurfaceFormat::setDefaultFormat(const QSurfaceFormat &format)
{
#ifndef QT_NO_OPENGL
if (qApp) {
QOpenGLContext *globalContext = QOpenGLContext::globalShareContext();
if (globalContext && globalContext->isValid()) {
qWarning("Warning: Setting a new default format with a different version or profile "
"after the global shared context is created may cause issues with context "
"sharing.");
}
}
#endif
*qt_default_surface_format() = format;
}

View File

@ -1492,6 +1492,7 @@ bool QOpenGLFramebufferObject::bindDefault()
if (ctx) {
ctx->functions()->glBindFramebuffer(GL_FRAMEBUFFER, ctx->defaultFramebufferObject());
QOpenGLContextPrivate::get(ctx)->qgl_current_fbo_invalid = true;
QOpenGLContextPrivate::get(ctx)->qgl_current_fbo = Q_NULLPTR;
}
#ifdef QT_DEBUG
else

View File

@ -335,6 +335,8 @@ struct QSpanData
QGradientData gradient;
QTextureData texture;
};
QExplicitlySharedDataPointer<const QSharedData> cachedGradient;
void init(QRasterBuffer *rb, const QRasterPaintEngine *pe);
void setup(const QBrush &brush, int alpha, QPainter::CompositionMode compositionMode);

View File

@ -2283,6 +2283,8 @@ void QRasterPaintEngine::drawImage(const QRectF &r, const QImage &img, const QRe
= QRectF(sr.x() + clippedTargetRect.x() - r.x(), sr.y() + clippedTargetRect.y() - r.y(),
clippedTargetRect.width(), clippedTargetRect.height()).toRect();
clippedSourceRect = clippedSourceRect.intersected(img.rect());
uint dbpl = d->rasterBuffer->bytesPerLine();
uint sbpl = img.bytesPerLine();
@ -4147,7 +4149,8 @@ void QRasterBuffer::flushToARGBImage(QImage *target) const
class QGradientCache
{
struct CacheInfo
public:
struct CacheInfo : public QSharedData
{
inline CacheInfo(QGradientStops s, int op, QGradient::InterpolationMode mode) :
stops(qMove(s)), opacity(op), interpolationMode(mode) {}
@ -4158,12 +4161,9 @@ class QGradientCache
QGradient::InterpolationMode interpolationMode;
};
typedef QMultiHash<quint64, CacheInfo> QGradientColorTableHash;
typedef QMultiHash<quint64, QExplicitlySharedDataPointer<const CacheInfo> > QGradientColorTableHash;
public:
typedef QPair<const QRgb *, const QRgba64 *> ColorBufferPair;
inline ColorBufferPair getBuffer(const QGradient &gradient, int opacity) {
inline QExplicitlySharedDataPointer<const CacheInfo> getBuffer(const QGradient &gradient, int opacity) {
quint64 hash_val = 0;
const QGradientStops stops = gradient.stops();
@ -4177,10 +4177,9 @@ public:
return addCacheElement(hash_val, gradient, opacity);
else {
do {
const CacheInfo &cache_info = it.value();
if (cache_info.stops == stops && cache_info.opacity == opacity && cache_info.interpolationMode == gradient.interpolationMode())
return qMakePair(reinterpret_cast<const QRgb *>(cache_info.buffer32),
reinterpret_cast<const QRgba64 *>(cache_info.buffer64));
const QExplicitlySharedDataPointer<const CacheInfo> &cache_info = it.value();
if (cache_info->stops == stops && cache_info->opacity == opacity && cache_info->interpolationMode == gradient.interpolationMode())
return cache_info;
++it;
} while (it != cache.constEnd() && it.key() == hash_val);
// an exact match for these stops and opacity was not found, create new cache
@ -4194,18 +4193,16 @@ protected:
inline void generateGradientColorTable(const QGradient& g,
QRgba64 *colorTable,
int size, int opacity) const;
ColorBufferPair addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) {
QExplicitlySharedDataPointer<const CacheInfo> addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) {
if (cache.size() == maxCacheSize()) {
// may remove more than 1, but OK
cache.erase(cache.begin() + (qrand() % maxCacheSize()));
}
CacheInfo cache_entry(gradient.stops(), opacity, gradient.interpolationMode());
generateGradientColorTable(gradient, cache_entry.buffer64, paletteSize(), opacity);
QExplicitlySharedDataPointer<CacheInfo> cache_entry(new CacheInfo (gradient.stops(), opacity, gradient.interpolationMode()));
generateGradientColorTable(gradient, cache_entry->buffer64, paletteSize(), opacity);
for (int i = 0; i < GRADIENT_STOPTABLE_SIZE; ++i)
cache_entry.buffer32[i] = cache_entry.buffer64[i].toArgb32();
CacheInfo &cache_value = cache.insert(hash_val, cache_entry).value();
return qMakePair(reinterpret_cast<const QRgb *>(cache_value.buffer32),
reinterpret_cast<const QRgba64 *>(cache_value.buffer64));
cache_entry->buffer32[i] = cache_entry->buffer64[i].toArgb32();
return cache.insert(hash_val, cache_entry).value();
}
QGradientColorTableHash cache;
@ -4424,6 +4421,7 @@ Q_GUI_EXPORT extern QImage qt_imageForBrush(int brushStyle, bool invert);
void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode compositionMode)
{
Qt::BrushStyle brushStyle = qbrush_style(brush);
cachedGradient.reset();
switch (brushStyle) {
case Qt::SolidPattern: {
type = Solid;
@ -4440,9 +4438,10 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode
const QLinearGradient *g = static_cast<const QLinearGradient *>(brush.gradient());
gradient.alphaColor = !brush.isOpaque() || alpha != 256;
QGradientCache::ColorBufferPair colorBuffers = qt_gradient_cache()->getBuffer(*g, alpha);
gradient.colorTable64 = colorBuffers.second;
gradient.colorTable32 = colorBuffers.first;
QExplicitlySharedDataPointer<const QGradientCache::CacheInfo> cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha);
cachedGradient = cacheInfo;
gradient.colorTable32 = cacheInfo->buffer32;
gradient.colorTable64 = cacheInfo->buffer64;
gradient.spread = g->spread();
@ -4461,9 +4460,10 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode
const QRadialGradient *g = static_cast<const QRadialGradient *>(brush.gradient());
gradient.alphaColor = !brush.isOpaque() || alpha != 256;
QGradientCache::ColorBufferPair colorBuffers = qt_gradient_cache()->getBuffer(*g, alpha);
gradient.colorTable64 = colorBuffers.second;
gradient.colorTable32 = colorBuffers.first;
QExplicitlySharedDataPointer<const QGradientCache::CacheInfo> cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha);
cachedGradient = cacheInfo;
gradient.colorTable32 = cacheInfo->buffer32;
gradient.colorTable64 = cacheInfo->buffer64;
gradient.spread = g->spread();
@ -4486,9 +4486,10 @@ void QSpanData::setup(const QBrush &brush, int alpha, QPainter::CompositionMode
const QConicalGradient *g = static_cast<const QConicalGradient *>(brush.gradient());
gradient.alphaColor = !brush.isOpaque() || alpha != 256;
QGradientCache::ColorBufferPair colorBuffers = qt_gradient_cache()->getBuffer(*g, alpha);
gradient.colorTable64 = colorBuffers.second;
gradient.colorTable32 = colorBuffers.first;
QExplicitlySharedDataPointer<const QGradientCache::CacheInfo> cacheInfo = qt_gradient_cache()->getBuffer(*g, alpha);
cachedGradient = cacheInfo;
gradient.colorTable32 = cacheInfo->buffer32;
gradient.colorTable64 = cacheInfo->buffer64;
gradient.spread = QGradient::RepeatSpread;

View File

@ -1924,7 +1924,7 @@ int QPdfEnginePrivate::writeCompressed(const char *src, int len)
}
int QPdfEnginePrivate::writeImage(const QByteArray &data, int width, int height, int depth,
int maskObject, int softMaskObject, bool dct)
int maskObject, int softMaskObject, bool dct, bool isMono)
{
int image = addXrefEntry(-1);
xprintf("<<\n"
@ -1934,8 +1934,13 @@ int QPdfEnginePrivate::writeImage(const QByteArray &data, int width, int height,
"/Height %d\n", width, height);
if (depth == 1) {
xprintf("/ImageMask true\n"
"/Decode [1 0]\n");
if (!isMono) {
xprintf("/ImageMask true\n"
"/Decode [1 0]\n");
} else {
xprintf("/BitsPerComponent 1\n"
"/ColorSpace /DeviceGray\n");
}
} else {
xprintf("/BitsPerComponent 8\n"
"/ColorSpace %s\n", (depth == 32) ? "/DeviceRGB" : "/DeviceGray");
@ -2453,7 +2458,7 @@ int QPdfEnginePrivate::addImage(const QImage &img, bool *bitmap, qint64 serial_n
memcpy(rawdata, image.constScanLine(y), bytesPerLine);
rawdata += bytesPerLine;
}
object = writeImage(data, w, h, d, 0, 0);
object = writeImage(data, w, h, d, 0, 0, false, is_monochrome(img.colorTable()));
} else {
QByteArray softMaskData;
bool dct = false;

View File

@ -295,7 +295,7 @@ private:
int streampos;
int writeImage(const QByteArray &data, int width, int height, int depth,
int maskObject, int softMaskObject, bool dct = false);
int maskObject, int softMaskObject, bool dct = false, bool isMono = false);
void writePage();
int addXrefEntry(int object, bool printostr = true);

View File

@ -746,8 +746,9 @@ static ColorData parseColorValue(QCss::Value v)
QVector<QCss::Value> colorDigits;
if (!p.parseExpr(&colorDigits))
return ColorData();
const int tokenCount = colorDigits.count();
for (int i = 0; i < qMin(colorDigits.count(), 7); i += 2) {
for (int i = 0; i < qMin(tokenCount, 7); i += 2) {
if (colorDigits.at(i).type == Value::Percentage) {
colorDigits[i].variant = colorDigits.at(i).variant.toReal() * (255. / 100.);
colorDigits[i].type = Value::Number;
@ -756,11 +757,15 @@ static ColorData parseColorValue(QCss::Value v)
}
}
if (tokenCount < 5)
return ColorData();
int v1 = colorDigits.at(0).variant.toInt();
int v2 = colorDigits.at(2).variant.toInt();
int v3 = colorDigits.at(4).variant.toInt();
int alpha = 255;
if (colorDigits.count() >= 7) {
if (tokenCount >= 7) {
int alphaValue = colorDigits.at(6).variant.toInt();
if (rgba && alphaValue <= 1)
alpha = colorDigits.at(6).variant.toReal() * 255.;

View File

@ -804,7 +804,8 @@ QStringList QPlatformFontDatabase::fallbacksForFamily(const QString &family, QFo
Q_UNUSED(family);
Q_UNUSED(styleHint);
QStringList retList;
QStringList preferredFallbacks;
QStringList otherFallbacks;
size_t writingSystem = std::find(scriptForWritingSystem,
scriptForWritingSystem + QFontDatabase::WritingSystemsCount,
@ -825,18 +826,18 @@ QStringList QPlatformFontDatabase::fallbacksForFamily(const QString &family, QFo
QtFontFoundry *foundry = f->foundries[j];
for (int k = 0; k < foundry->count; ++k) {
if (style == foundry->styles[k]->key.style) {
if (foundry->name.isEmpty())
retList.append(f->name);
else
retList.append(f->name + QLatin1String(" [") + foundry->name + QLatin1Char(']'));
break;
}
QString name = foundry->name.isEmpty()
? f->name
: f->name + QLatin1String(" [") + foundry->name + QLatin1Char(']');
if (style == foundry->styles[k]->key.style)
preferredFallbacks.append(name);
else
otherFallbacks.append(name);
}
}
}
return retList;
return preferredFallbacks + otherFallbacks;
}
static void initializeDb();
@ -1659,9 +1660,6 @@ bool QFontDatabase::isFixedPitch(const QString &family,
bool QFontDatabase::isBitmapScalable(const QString &family,
const QString &style) const
{
if (QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fontsAlwaysScalable())
return true;
bool bitmapScalable = false;
QString familyName, foundryName;
parseFontName(family, foundryName, familyName);
@ -1702,9 +1700,6 @@ bool QFontDatabase::isBitmapScalable(const QString &family,
*/
bool QFontDatabase::isSmoothlyScalable(const QString &family, const QString &style) const
{
if (QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fontsAlwaysScalable())
return true;
bool smoothScalable = false;
QString familyName, foundryName;
parseFontName(family, foundryName, familyName);

View File

@ -1910,7 +1910,7 @@ void QFontEngineFT::unlockAlphaMapForGlyph()
static inline bool is2dRotation(const QTransform &t)
{
return qFuzzyCompare(t.m11(), t.m22()) && qFuzzyCompare(t.m12(), -t.m21())
&& qFuzzyCompare(t.m11()*t.m22() - t.m12()*t.m21(), 1.0);
&& qFuzzyCompare(t.m11()*t.m22() - t.m12()*t.m21(), qreal(1.0));
}
QFontEngineFT::Glyph *QFontEngineFT::loadGlyphFor(glyph_t g,

View File

@ -244,7 +244,8 @@ QNetworkReplyHttpImpl::QNetworkReplyHttpImpl(QNetworkAccessManager* const manage
QNetworkReplyHttpImpl::~QNetworkReplyHttpImpl()
{
// Most work is done in private destructor
// This will do nothing if the request was already finished or aborted
emit abortHttpRequest();
}
void QNetworkReplyHttpImpl::close()
@ -442,9 +443,6 @@ QNetworkReplyHttpImplPrivate::QNetworkReplyHttpImplPrivate()
QNetworkReplyHttpImplPrivate::~QNetworkReplyHttpImplPrivate()
{
Q_Q(QNetworkReplyHttpImpl);
// This will do nothing if the request was already finished or aborted
emit q->abortHttpRequest();
}
/*

View File

@ -48,6 +48,11 @@
#include "qnetworkconfigmanager_p.h"
// for QNetworkSession::interface
#ifdef interface
# undef interface
#endif
#ifndef QT_NO_BEARERMANAGEMENT
QT_BEGIN_NAMESPACE

View File

@ -850,7 +850,7 @@ bool QAbstractSocketPrivate::writeToSocket()
const char *ptr = writeBuffer.readPointer();
// Attempt to write it all in one chunk.
qint64 written = socketEngine->write(ptr, nextSize);
qint64 written = nextSize ? socketEngine->write(ptr, nextSize) : Q_INT64_C(0);
if (written < 0) {
#if defined (QABSTRACTSOCKET_DEBUG)
qDebug() << "QAbstractSocketPrivate::writeToSocket() write error, aborting."
@ -2504,7 +2504,7 @@ qint64 QAbstractSocket::writeData(const char *data, qint64 size)
if (!d->isBuffered && d->socketType == TcpSocket
&& d->socketEngine && d->writeBuffer.isEmpty()) {
// This code is for the new Unbuffered QTcpSocket use case
qint64 written = d->socketEngine->write(data, size);
qint64 written = size ? d->socketEngine->write(data, size) : Q_INT64_C(0);
if (written < 0) {
d->setError(d->socketEngine->error(), d->socketEngine->errorString());
} else if (written < size) {

View File

@ -873,6 +873,10 @@ qint64 QNativeSocketEngine::writeDatagram(const char *data, qint64 size, const Q
/*!
Writes a block of \a size bytes from \a data to the socket.
Returns the number of bytes written, or -1 if an error occurred.
Passing zero as the \a size parameter on a connected UDP socket
will send an empty datagram. For other socket types results are
unspecified.
*/
qint64 QNativeSocketEngine::write(const char *data, qint64 size)
{

View File

@ -561,10 +561,12 @@ void QNativeSocketEngine::close()
ComPtr<IAsyncAction> action;
hr = socket3->CancelIOAsync(&action);
Q_ASSERT_SUCCEEDED(hr);
hr = QWinRTFunctions::await(action);
hr = QWinRTFunctions::await(action, QWinRTFunctions::YieldThread, 5000);
// If there is no pending IO (no read established before) the function will fail with
// "function was called at an unexpected time" which is fine.
if (hr != E_ILLEGAL_METHOD_CALL)
// Timeout is fine as well. The result will be the socket being hard reset instead of
// being closed gracefully
if (hr != E_ILLEGAL_METHOD_CALL && hr != ERROR_TIMEOUT)
Q_ASSERT_SUCCEEDED(hr);
return S_OK;
});

View File

@ -1293,14 +1293,19 @@ QGLFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(co
switch (versionString[2].toLatin1()) {
case '5':
versionFlags |= QGLFormat::OpenGL_Version_1_5;
// fall through
case '4':
versionFlags |= QGLFormat::OpenGL_Version_1_4;
// fall through
case '3':
versionFlags |= QGLFormat::OpenGL_Version_1_3;
// fall through
case '2':
versionFlags |= QGLFormat::OpenGL_Version_1_2;
// fall through
case '1':
versionFlags |= QGLFormat::OpenGL_Version_1_1;
// fall through
default:
break;
}
@ -1325,10 +1330,13 @@ QGLFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(co
switch (versionString[2].toLatin1()) {
case '3':
versionFlags |= QGLFormat::OpenGL_Version_3_3;
// fall through
case '2':
versionFlags |= QGLFormat::OpenGL_Version_3_2;
// fall through
case '1':
versionFlags |= QGLFormat::OpenGL_Version_3_1;
// fall through
case '0':
break;
default:
@ -1353,10 +1361,13 @@ QGLFormat::OpenGLVersionFlags Q_AUTOTEST_EXPORT qOpenGLVersionFlagsFromString(co
switch (versionString[2].toLatin1()) {
case '3':
versionFlags |= QGLFormat::OpenGL_Version_4_3;
// fall through
case '2':
versionFlags |= QGLFormat::OpenGL_Version_4_2;
// fall through
case '1':
versionFlags |= QGLFormat::OpenGL_Version_4_1;
// fall through
case '0':
break;
default:

View File

@ -414,8 +414,7 @@ QVariant QMacPasteboardMimeUnicodeText::convertToMime(const QString &mimetype, Q
if (flavor == QLatin1String("public.utf8-plain-text")) {
ret = QString::fromUtf8(firstData);
} else if (flavor == QLatin1String("public.utf16-plain-text")) {
ret = QString(reinterpret_cast<const QChar *>(firstData.constData()),
firstData.size() / sizeof(QChar));
ret = QTextCodec::codecForName("UTF-16")->toUnicode(firstData);
} else {
qWarning("QMime::convertToMime: unhandled mimetype: %s", qPrintable(mimetype));
}
@ -429,7 +428,7 @@ QList<QByteArray> QMacPasteboardMimeUnicodeText::convertFromMime(const QString &
if (flavor == QLatin1String("public.utf8-plain-text"))
ret.append(string.toUtf8());
else if (flavor == QLatin1String("public.utf16-plain-text"))
ret.append(QByteArray((char*)string.utf16(), string.length()*2));
ret.append(QTextCodec::codecForName("UTF-16")->fromUnicode(string));
return ret;
}

View File

@ -386,5 +386,10 @@ bool qglx_reduceFormat(QSurfaceFormat *format)
return true;
}
if (format->stereo()) {
format->setStereo(false);
return true;
}
return false;
}

View File

@ -635,6 +635,11 @@ static void updateWindow(JNIEnv */*env*/, jobject /*thiz*/)
if (QGuiApplication::instance() != nullptr) {
const auto tlw = QGuiApplication::topLevelWindows();
for (QWindow *w : tlw) {
// Skip non-platform windows, e.g., offscreen windows.
if (!w->handle())
continue;
QRect availableGeometry = w->screen()->availableGeometry();
if (w->geometry().width() > 0 && w->geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0)
QWindowSystemInterface::handleExposeEvent(w, QRegion(QRect(QPoint(), w->geometry().size())));

View File

@ -461,9 +461,9 @@ QVariant QAndroidPlatformTheme::themeHint(ThemeHint hint) const
case StyleNames:
if (qEnvironmentVariableIntValue("QT_USE_ANDROID_NATIVE_STYLE")
&& m_androidStyleData) {
return QStringList("android");
return QStringList(QLatin1String("android"));
}
return QStringList("fusion");
return QStringList(QLatin1String("fusion"));
case MouseDoubleClickDistance:
{

View File

@ -122,7 +122,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
- (void)dealloc
{
[self restoreOriginalContentView];
[mStolenContentView release];
[mColorPanel setDelegate:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self];

View File

@ -150,7 +150,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
- (void)dealloc
{
[self restoreOriginalContentView];
[mStolenContentView release];
[mFontPanel setDelegate:nil];
[[NSFontManager sharedFontManager] setDelegate:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self];

View File

@ -76,6 +76,7 @@ private:
static QCocoaWindow *findWindowForMenubar();
static QCocoaMenuBar *findGlobalMenubar();
bool needsImmediateUpdate();
bool shouldDisable(QCocoaWindow *active) const;
NSMenuItem *nativeItemForMenu(QCocoaMenu *menu) const;

View File

@ -90,6 +90,32 @@ QCocoaMenuBar::~QCocoaMenuBar()
}
}
bool QCocoaMenuBar::needsImmediateUpdate()
{
if (m_window && m_window->window()->isActive()) {
return true;
} else if (!m_window) {
// Only update if the focus/active window has no
// menubar, which means it'll be using this menubar.
// This is to avoid a modification in a parentless
// menubar to affect a window-assigned menubar.
QWindow *fw = QGuiApplication::focusWindow();
if (!fw) {
// Same if there's no focus window, BTW.
return true;
} else {
QCocoaWindow *cw = static_cast<QCocoaWindow *>(fw->handle());
if (cw && !cw->menubar())
return true;
}
}
// Either the menubar is attached to a non-active window,
// or the application's focus window has its own menubar
// (which is different from this one)
return false;
}
void QCocoaMenuBar::insertMenu(QPlatformMenu *platformMenu, QPlatformMenu *before)
{
QCocoaMenu *menu = static_cast<QCocoaMenu *>(platformMenu);
@ -130,7 +156,7 @@ void QCocoaMenuBar::insertMenu(QPlatformMenu *platformMenu, QPlatformMenu *befor
syncMenu(menu);
if (m_window && m_window->window()->isActive())
if (needsImmediateUpdate())
updateMenuBarImmediately();
}

View File

@ -322,6 +322,8 @@ public: // for QNSView
};
QHash<quintptr, BorderRange> m_contentBorderAreas; // identifer -> uppper/lower
QHash<quintptr, bool> m_enabledContentBorderAreas; // identifer -> enabled state (true/false)
bool m_hasWindowFilePath;
};
QT_END_NAMESPACE

View File

@ -380,6 +380,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
, m_topContentBorderThickness(0)
, m_bottomContentBorderThickness(0)
, m_normalGeometry(QRect(0,0,-1,-1))
, m_hasWindowFilePath(false)
{
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::QCocoaWindow" << window();
@ -935,6 +936,7 @@ void QCocoaWindow::setWindowFilePath(const QString &filePath)
QFileInfo fi(filePath);
[m_nsWindow setRepresentedFilename:fi.exists() ? filePath.toNSString() : @""];
m_hasWindowFilePath = fi.exists();
}
void QCocoaWindow::setWindowIcon(const QIcon &icon)

View File

@ -874,11 +874,6 @@ static bool _q_dontOverrideCtrlLMB = false;
if (!(m_acceptedMouseDowns & button) == button)
return false;
if (!(m_buttons & (m_sendUpAsRightButton ? Qt::RightButton : Qt::LeftButton))) {
qCWarning(lcQpaCocoaWindow) << "QNSView mouseDragged: Internal mouse button tracking"
<< "invalid (missing Qt::LeftButton)";
}
[self handleMouseEvent:theEvent];
return true;
}

View File

@ -59,6 +59,8 @@
- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame;
- (void)windowWillClose:(NSNotification *)notification;
- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu;
- (BOOL)window:(NSWindow *)window shouldDragDocumentWithEvent:(NSEvent *)event from:(NSPoint)dragImageLocation withPasteboard:(NSPasteboard *)pasteboard;
@end
QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSWindowDelegate);

View File

@ -123,4 +123,19 @@
m_cocoaWindow->windowWillClose();
}
- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu
{
Q_UNUSED(window);
Q_UNUSED(menu);
return m_cocoaWindow && m_cocoaWindow->m_hasWindowFilePath;
}
- (BOOL)window:(NSWindow *)window shouldDragDocumentWithEvent:(NSEvent *)event from:(NSPoint)dragImageLocation withPasteboard:(NSPasteboard *)pasteboard
{
Q_UNUSED(window);
Q_UNUSED(event);
Q_UNUSED(dragImageLocation);
Q_UNUSED(pasteboard);
return m_cocoaWindow && m_cocoaWindow->m_hasWindowFilePath;
}
@end

View File

@ -66,7 +66,8 @@ private:
Q_GLOBAL_STATIC(DeviceIntegration, deviceIntegration)
DeviceIntegration::DeviceIntegration() : m_integration(0)
DeviceIntegration::DeviceIntegration()
: m_integration(nullptr)
{
QStringList pluginKeys = QEglFSDeviceIntegrationFactory::keys();
if (!pluginKeys.isEmpty()) {

View File

@ -79,7 +79,7 @@ void QEglFSKmsEglDevice::close()
EGLNativeDisplayType QEglFSKmsEglDevice::nativeDisplay() const
{
return static_cast<QEglFSKmsEglDeviceIntegration *>(m_integration)->eglDevice();
return reinterpret_cast<EGLNativeDisplayType>(static_cast<QEglFSKmsEglDeviceIntegration *>(m_integration)->eglDevice());
}
QEglFSKmsScreen *QEglFSKmsEglDevice::createScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device,

View File

@ -1,74 +1,2 @@
TARGET = qios
QT += \
core-private gui-private \
clipboard_support-private fontdatabase_support-private graphics_support-private
LIBS += -framework Foundation -framework UIKit -framework QuartzCore -framework AudioToolbox
OBJECTIVE_SOURCES = \
plugin.mm \
qiosintegration.mm \
qioseventdispatcher.mm \
qioswindow.mm \
qiosscreen.mm \
qiosbackingstore.mm \
qiosapplicationdelegate.mm \
qiosapplicationstate.mm \
qiosviewcontroller.mm \
qioscontext.mm \
qiosinputcontext.mm \
qiostheme.mm \
qiosglobal.mm \
qiosservices.mm \
quiview.mm \
quiaccessibilityelement.mm \
qiosplatformaccessibility.mm \
qiostextresponder.mm
HEADERS = \
qiosintegration.h \
qioseventdispatcher.h \
qioswindow.h \
qiosscreen.h \
qiosbackingstore.h \
qiosapplicationdelegate.h \
qiosapplicationstate.h \
qiosviewcontroller.h \
qioscontext.h \
qiosinputcontext.h \
qiostheme.h \
qiosglobal.h \
qiosservices.h \
quiview.h \
quiaccessibilityelement.h \
qiosplatformaccessibility.h \
qiostextresponder.h \
qiosfileenginefactory.h
!tvos {
LIBS += -framework AssetsLibrary
OBJECTIVE_SOURCES += \
qiosclipboard.mm \
qiosmenu.mm \
qiosfileengineassetslibrary.mm \
qiosfiledialog.mm \
qiosmessagedialog.mm \
qiostextinputoverlay.mm
HEADERS += \
qiosclipboard.h \
qiosmenu.h \
qiosfileengineassetslibrary.h \
qiosfiledialog.h \
qiosmessagedialog.h \
qiostextinputoverlay.h
}
OTHER_FILES = \
quiview_textinput.mm \
quiview_accessibility.mm
PLUGIN_TYPE = platforms
PLUGIN_CLASS_NAME = QIOSIntegrationPlugin
!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -
load(qt_plugin)
TEMPLATE = subdirs
SUBDIRS = kernel.pro optional

View File

@ -0,0 +1,72 @@
TARGET = qios
QT += \
core-private gui-private \
clipboard_support-private fontdatabase_support-private graphics_support-private
LIBS += -framework Foundation -framework UIKit -framework QuartzCore -framework AudioToolbox
OBJECTIVE_SOURCES = \
plugin.mm \
qiosintegration.mm \
qioseventdispatcher.mm \
qioswindow.mm \
qiosscreen.mm \
qiosbackingstore.mm \
qiosapplicationdelegate.mm \
qiosapplicationstate.mm \
qiosviewcontroller.mm \
qioscontext.mm \
qiosinputcontext.mm \
qiostheme.mm \
qiosglobal.mm \
qiosservices.mm \
quiview.mm \
quiaccessibilityelement.mm \
qiosplatformaccessibility.mm \
qiostextresponder.mm
HEADERS = \
qiosintegration.h \
qioseventdispatcher.h \
qioswindow.h \
qiosscreen.h \
qiosbackingstore.h \
qiosapplicationdelegate.h \
qiosapplicationstate.h \
qiosviewcontroller.h \
qioscontext.h \
qiosinputcontext.h \
qiostheme.h \
qiosglobal.h \
qiosservices.h \
quiview.h \
quiaccessibilityelement.h \
qiosplatformaccessibility.h \
qiostextresponder.h \
qiosfileenginefactory.h
!tvos {
LIBS += -framework AssetsLibrary
OBJECTIVE_SOURCES += \
qiosclipboard.mm \
qiosmenu.mm \
qiosfiledialog.mm \
qiosmessagedialog.mm \
qiostextinputoverlay.mm
HEADERS += \
qiosclipboard.h \
qiosmenu.h \
qiosfiledialog.h \
qiosmessagedialog.h \
qiostextinputoverlay.h
}
OTHER_FILES = \
quiview_textinput.mm \
quiview_accessibility.mm
PLUGIN_TYPE = platforms
PLUGIN_CLASS_NAME = QIOSIntegrationPlugin
!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -
load(qt_plugin)

View File

@ -0,0 +1,22 @@
TARGET = qiosnsphotolibrarysupport
QT += core gui gui-private
LIBS += -framework UIKit -framework AssetsLibrary
HEADERS = \
qiosfileengineassetslibrary.h \
qiosfileenginefactory.h \
qiosimagepickercontroller.h
OBJECTIVE_SOURCES = \
plugin.mm \
qiosfileengineassetslibrary.mm \
qiosimagepickercontroller.mm \
OTHER_FILES = \
plugin.json
PLUGIN_CLASS_NAME = QIosOptionalPlugin_NSPhotoLibrary
PLUGIN_EXTENDS = -
PLUGIN_TYPE = platforms/darwin
load(qt_plugin)

View File

@ -0,0 +1,3 @@
{
"Keys": [ "NSPhotoLibrarySupport" ]
}

View File

@ -0,0 +1,64 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** 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 http://www.qt.io/terms-conditions. For further
** information use the contact form at http://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 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "../../qiosoptionalplugininterface.h"
#include "../../qiosfiledialog.h"
#include "qiosimagepickercontroller.h"
#include "qiosfileenginefactory.h"
QT_BEGIN_NAMESPACE
class QIosOptionalPlugin_NSPhotoLibrary : public QObject, QIosOptionalPluginInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QIosOptionalPluginInterface_iid FILE "plugin.json")
Q_INTERFACES(QIosOptionalPluginInterface)
public:
explicit QIosOptionalPlugin_NSPhotoLibrary(QObject* = 0) {};
~QIosOptionalPlugin_NSPhotoLibrary() {}
UIViewController* createImagePickerController(QIOSFileDialog *fileDialog) const override
{
return [[[QIOSImagePickerController alloc] initWithQIOSFileDialog:fileDialog] autorelease];
}
private:
QIOSFileEngineFactory m_fileEngineFactory;
};
QT_END_NAMESPACE
#include "plugin.moc"

View File

@ -43,6 +43,9 @@
#include <QtCore/private/qabstractfileengine_p.h>
Q_FORWARD_DECLARE_OBJC_CLASS(ALAsset);
QT_BEGIN_NAMESPACE
class QIOSAssetData;
class QIOSFileEngineAssetsLibrary : public QAbstractFileEngine
@ -51,20 +54,20 @@ public:
QIOSFileEngineAssetsLibrary(const QString &fileName);
~QIOSFileEngineAssetsLibrary();
bool open(QIODevice::OpenMode openMode) Q_DECL_OVERRIDE;
bool close() Q_DECL_OVERRIDE;
FileFlags fileFlags(FileFlags type) const Q_DECL_OVERRIDE;
qint64 size() const Q_DECL_OVERRIDE;
qint64 read(char *data, qint64 maxlen) Q_DECL_OVERRIDE;
qint64 pos() const Q_DECL_OVERRIDE;
bool seek(qint64 pos) Q_DECL_OVERRIDE;
QString fileName(FileName file) const Q_DECL_OVERRIDE;
void setFileName(const QString &file) Q_DECL_OVERRIDE;
QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const Q_DECL_OVERRIDE;
bool open(QIODevice::OpenMode openMode) override;
bool close() override;
FileFlags fileFlags(FileFlags type) const override;
qint64 size() const override;
qint64 read(char *data, qint64 maxlen) override;
qint64 pos() const override;
bool seek(qint64 pos) override;
QString fileName(FileName file) const override;
void setFileName(const QString &file) override;
QStringList entryList(QDir::Filters filters, const QStringList &filterNames) const override;
#ifndef QT_NO_FILESYSTEMITERATOR
Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames) Q_DECL_OVERRIDE;
Iterator *endEntryList() Q_DECL_OVERRIDE;
Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames) override;
Iterator *endEntryList() override;
#endif
void setError(QFile::FileError error, const QString &str) { QAbstractFileEngine::setError(error, str); }
@ -78,5 +81,7 @@ private:
ALAsset *loadAsset() const;
};
QT_END_NAMESPACE
#endif // QIOSFILEENGINEASSETSLIBRARY_H

View File

@ -48,6 +48,8 @@
#include <QtCore/qset.h>
#include <QtCore/qthreadstorage.h>
QT_BEGIN_NAMESPACE
static QThreadStorage<QString> g_iteratorCurrentUrl;
static QThreadStorage<QPointer<QIOSAssetData> > g_assetDataCache;
@ -472,4 +474,6 @@ QAbstractFileEngine::Iterator *QIOSFileEngineAssetsLibrary::endEntryList()
return 0;
}
QT_END_NAMESPACE
#endif

View File

@ -44,6 +44,8 @@
#include <QtCore/private/qabstractfileengine_p.h>
#include "qiosfileengineassetslibrary.h"
QT_BEGIN_NAMESPACE
class QIOSFileEngineFactory : public QAbstractFileEngineHandler
{
public:
@ -62,4 +64,6 @@ public:
}
};
QT_END_NAMESPACE
#endif // QIOSFILEENGINEFACTORY_H

View File

@ -0,0 +1,42 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** 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 http://www.qt.io/terms-conditions. For further
** information use the contact form at http://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 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#import <UIKit/UIKit.h>
#include "../../qiosfiledialog.h"
@interface QIOSImagePickerController : UIImagePickerController <UIImagePickerControllerDelegate, UINavigationControllerDelegate> {
QIOSFileDialog *m_fileDialog;
}
- (id)initWithQIOSFileDialog:(QIOSFileDialog *)fileDialog;
@end

View File

@ -0,0 +1,66 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** 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 http://www.qt.io/terms-conditions. For further
** information use the contact form at http://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 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#import <UIKit/UIKit.h>
#include "qiosimagepickercontroller.h"
@implementation QIOSImagePickerController
- (id)initWithQIOSFileDialog:(QIOSFileDialog *)fileDialog
{
self = [super init];
if (self) {
m_fileDialog = fileDialog;
[self setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self setDelegate:self];
}
return self;
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
Q_UNUSED(picker);
NSURL *url = [info objectForKey:UIImagePickerControllerReferenceURL];
QUrl fileUrl = QUrl::fromLocalFile(QString::fromNSString([url description]));
m_fileDialog->selectedFilesChanged(QList<QUrl>() << fileUrl);
emit m_fileDialog->accept();
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
Q_UNUSED(picker)
emit m_fileDialog->reject();
}
@end

View File

@ -0,0 +1,2 @@
TEMPLATE = subdirs
SUBDIRS = nsphotolibrarysupport

View File

@ -72,6 +72,8 @@ private:
QList<QUrl> m_selection;
QEventLoop m_eventLoop;
UIViewController *m_viewController;
bool showImagePickerDialog(QWindow *parent);
};
QT_END_NAMESPACE

View File

@ -37,52 +37,18 @@
**
****************************************************************************/
#include "qiosfiledialog.h"
#import <UIKit/UIKit.h>
#include <QtCore/qstandardpaths.h>
#include <QtGui/qwindow.h>
#include <QDebug>
@interface QIOSImagePickerController : UIImagePickerController <UIImagePickerControllerDelegate, UINavigationControllerDelegate> {
QIOSFileDialog *m_fileDialog;
}
@end
@implementation QIOSImagePickerController
- (id)initWithQIOSFileDialog:(QIOSFileDialog *)fileDialog
{
self = [super init];
if (self) {
m_fileDialog = fileDialog;
[self setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self setDelegate:self];
}
return self;
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
Q_UNUSED(picker);
NSURL *url = [info objectForKey:UIImagePickerControllerReferenceURL];
QUrl fileUrl = QUrl::fromLocalFile(QString::fromNSString([url description]));
m_fileDialog->selectedFilesChanged(QList<QUrl>() << fileUrl);
emit m_fileDialog->accept();
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
Q_UNUSED(picker)
emit m_fileDialog->reject();
}
@end
// --------------------------------------------------------------------------
#include "qiosfiledialog.h"
#include "qiosintegration.h"
#include "qiosoptionalplugininterface.h"
QIOSFileDialog::QIOSFileDialog()
: m_viewController(0)
: m_viewController(Q_NULLPTR)
{
}
@ -104,17 +70,36 @@ bool QIOSFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality window
bool acceptOpen = options()->acceptMode() == QFileDialogOptions::AcceptOpen;
QString directory = options()->initialDirectory().toLocalFile();
if (acceptOpen && directory.startsWith(QLatin1String("assets-library:"))) {
m_viewController = [[QIOSImagePickerController alloc] initWithQIOSFileDialog:this];
UIWindow *window = parent ? reinterpret_cast<UIView *>(parent->winId()).window
: [UIApplication sharedApplication].keyWindow;
[window.rootViewController presentViewController:m_viewController animated:YES completion:nil];
return true;
}
if (acceptOpen && directory.startsWith(QLatin1String("assets-library:")))
return showImagePickerDialog(parent);
return false;
}
bool QIOSFileDialog::showImagePickerDialog(QWindow *parent)
{
if (!m_viewController) {
QFactoryLoader *plugins = QIOSIntegration::instance()->optionalPlugins();
for (int i = 0; i < plugins->metaData().size(); ++i) {
QIosOptionalPluginInterface *plugin = qobject_cast<QIosOptionalPluginInterface *>(plugins->instance(i));
m_viewController = [plugin->createImagePickerController(this) retain];
if (m_viewController)
break;
}
}
if (!m_viewController) {
qWarning() << "QIOSFileDialog: Could not resolve Qt plugin that gives access to photos on iOS";
return false;
}
UIWindow *window = parent ? reinterpret_cast<UIView *>(parent->winId()).window
: [UIApplication sharedApplication].keyWindow;
[window.rootViewController presentViewController:m_viewController animated:YES completion:nil];
return true;
}
void QIOSFileDialog::hide()
{
// QFileDialog will remember the last directory set, and open subsequent dialogs in the same
@ -126,6 +111,8 @@ void QIOSFileDialog::hide()
emit directoryEntered(QUrl::fromLocalFile(QDir::currentPath()));
[m_viewController dismissViewControllerAnimated:YES completion:nil];
[m_viewController release];
m_viewController = Q_NULLPTR;
m_eventLoop.exit();
}

View File

@ -44,8 +44,9 @@
#include <qpa/qplatformnativeinterface.h>
#include <qpa/qwindowsysteminterface.h>
#include <QtCore/private/qfactoryloader_p.h>
#include "qiosapplicationstate.h"
#include "qiosfileenginefactory.h"
#ifndef Q_OS_TVOS
#include "qiostextinputoverlay.h"
#endif
@ -106,6 +107,8 @@ public:
void setDebugWindowManagement(bool);
bool debugWindowManagement() const;
QFactoryLoader *optionalPlugins() { return m_optionalPlugins; }
private:
QPlatformFontDatabase *m_fontDatabase;
#ifndef Q_OS_TVOS
@ -116,7 +119,7 @@ private:
QIOSApplicationState m_applicationState;
QIOSServices *m_platformServices;
mutable QPlatformAccessibility *m_accessibility;
QIOSFileEngineFactory m_fileEngineFactory;
QFactoryLoader *m_optionalPlugins;
#ifndef Q_OS_TVOS
QIOSTextInputOverlay m_textInputOverlay;
#endif

View File

@ -51,6 +51,7 @@
#include "qiosinputcontext.h"
#include "qiostheme.h"
#include "qiosservices.h"
#include "qiosoptionalplugininterface.h"
#include <QtGui/private/qguiapplication_p.h>
@ -80,6 +81,7 @@ QIOSIntegration::QIOSIntegration()
, m_inputContext(0)
, m_platformServices(new QIOSServices)
, m_accessibility(0)
, m_optionalPlugins(new QFactoryLoader(QIosOptionalPluginInterface_iid, QLatin1String("/platforms/darwin")))
, m_debugWindowManagement(false)
{
if (Q_UNLIKELY(![UIApplication sharedApplication])) {
@ -124,6 +126,9 @@ QIOSIntegration::QIOSIntegration()
m_touchDevice->setCapabilities(touchCapabilities);
QWindowSystemInterface::registerTouchDevice(m_touchDevice);
QMacInternalPasteboardMime::initializeMimeTypes();
for (int i = 0; i < m_optionalPlugins->metaData().size(); ++i)
qobject_cast<QIosOptionalPluginInterface *>(m_optionalPlugins->instance(i))->initPlugin();
}
QIOSIntegration::~QIOSIntegration()
@ -148,6 +153,9 @@ QIOSIntegration::~QIOSIntegration()
delete m_accessibility;
m_accessibility = 0;
delete m_optionalPlugins;
m_optionalPlugins = 0;
}
bool QIOSIntegration::hasCapability(Capability cap) const

View File

@ -0,0 +1,59 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** 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 http://www.qt.io/terms-conditions. For further
** information use the contact form at http://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 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** As a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QIOPLUGININTERFACE_H
#define QIOPLUGININTERFACE_H
#include <QtCore/QtPlugin>
#include "qiosfiledialog.h"
QT_BEGIN_NAMESPACE
Q_FORWARD_DECLARE_OBJC_CLASS(UIViewController);
#define QIosOptionalPluginInterface_iid "org.qt-project.Qt.QPA.ios.optional"
class QIosOptionalPluginInterface
{
public:
virtual ~QIosOptionalPluginInterface() {}
virtual void initPlugin() const {};
virtual UIViewController* createImagePickerController(QIOSFileDialog *) const { return Q_NULLPTR; };
};
Q_DECLARE_INTERFACE(QIosOptionalPluginInterface, QIosOptionalPluginInterface_iid)
QT_END_NAMESPACE
#endif // QIOPLUGININTERFACE_H

View File

@ -214,8 +214,8 @@ QIOSScreen::QIOSScreen(UIScreen *screen)
else
m_depth = 24;
if (deviceIdentifier.contains(QRegularExpression("^iPhone(7,1|8,2)$"))) {
// iPhone 6 Plus or iPhone 6S Plus
if (deviceIdentifier.contains(QRegularExpression("^iPhone(7,1|8,2|9,2|9,4)$"))) {
// iPhone Plus models
m_physicalDpi = 401;
} else if (deviceIdentifier.contains(QRegularExpression("^iPad(1,1|2,[1-4]|3,[1-6]|4,[1-3]|5,[3-4]|6,[7-8])$"))) {
// All iPads except the iPad Mini series

View File

@ -994,7 +994,8 @@ QIOSTextInputOverlay::QIOSTextInputOverlay()
QIOSTextInputOverlay::~QIOSTextInputOverlay()
{
disconnect(qApp, 0, this, 0);
if (qApp)
disconnect(qApp, 0, this, 0);
}
void QIOSTextInputOverlay::updateFocusObject()

View File

@ -58,7 +58,8 @@
#include <QtGui/QOpenGLContext>
#include <QtGui/QScreen>
#include <QtEglSupport/private/qt_egl_p.h>
// this is where EGL headers are pulled in, make sure it is last
#include "qminimaleglscreen.h"
QT_BEGIN_NAMESPACE

Some files were not shown because too many files have changed in this diff Show More