summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-10-27 13:00:36 +0100
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2014-10-27 13:00:36 +0100
commit2eb26c170920d28213b71e549d5dac4663febb14 (patch)
tree8df5223ac114d758c2112a8fc787992175556418
parent49ddae28e0dcd1c59dd5d742cffedd5290d1224a (diff)
parent81998b4e8e440076bd22a9164f0a93481c0e597a (diff)
Merge remote-tracking branch 'origin/5.4' into dev
Conflicts: src/gui/text/qfontdatabase.cpp Change-Id: I6ac1f55faa22b8e7b591386fb67f0333d0ea443d
-rw-r--r--dist/changes-5.4.012
-rw-r--r--examples/network/securesocketclient/sslclient.cpp12
-rw-r--r--examples/network/securesocketclient/sslclient.h3
-rw-r--r--examples/opengl/threadedqopenglwidget/main.cpp33
-rw-r--r--qmake/generators/win32/msbuild_objectmodel.cpp12
-rw-r--r--qmake/generators/win32/msvc_objectmodel.cpp4
-rw-r--r--qmake/generators/win32/msvc_objectmodel.h1
-rw-r--r--qmake/generators/win32/msvc_vcproj.cpp27
-rw-r--r--qmake/generators/win32/msvc_vcproj.h1
-rw-r--r--src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java17
-rw-r--r--src/corelib/codecs/qicucodec.cpp2
-rw-r--r--src/corelib/codecs/qtextcodec.cpp7
-rw-r--r--src/corelib/global/qnamespace.qdoc14
-rw-r--r--src/corelib/io/qfile.cpp12
-rw-r--r--src/corelib/io/qfiledevice.cpp5
-rw-r--r--src/corelib/io/qloggingcategory.cpp23
-rw-r--r--src/corelib/kernel/qmetatype.h15
-rw-r--r--src/corelib/kernel/qtranslator.cpp5
-rw-r--r--src/corelib/kernel/qvariant.cpp20
-rw-r--r--src/corelib/kernel/qvariant.h6
-rw-r--r--src/gui/accessible/qaccessible.cpp1
-rw-r--r--src/gui/accessible/qaccessible.h2
-rw-r--r--src/gui/image/qiconloader.cpp1
-rw-r--r--src/gui/image/qimagereader.cpp23
-rw-r--r--src/gui/image/qimagewriter.cpp17
-rw-r--r--src/gui/kernel/qguiapplication.cpp5
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp10
-rw-r--r--src/gui/kernel/qwindowsysteminterface.h4
-rw-r--r--src/gui/kernel/qwindowsysteminterface_p.h4
-rw-r--r--src/gui/opengl/qopenglpixeltransferoptions.cpp93
-rw-r--r--src/gui/opengl/qopengltextureglyphcache.cpp5
-rw-r--r--src/gui/painting/qpdf.cpp6
-rw-r--r--src/gui/text/qfont.cpp12
-rw-r--r--src/gui/text/qfontdatabase.cpp9
-rw-r--r--src/gui/text/qfontengine_ft.cpp1
-rw-r--r--src/gui/text/qfontengine_p.h4
-rw-r--r--src/gui/util/qgridlayoutengine.cpp2
-rw-r--r--src/gui/util/qgridlayoutengine_p.h1
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp6
-rw-r--r--src/network/access/qnetworkreplyhttpimpl_p.h3
-rw-r--r--src/network/access/qnetworkreplynsurlconnectionimpl.mm3
-rw-r--r--src/network/doc/src/bearermanagement.qdoc2
-rw-r--r--src/network/socket/qnativesocketengine_win.cpp2
-rw-r--r--src/network/ssl/qssl.cpp10
-rw-r--r--src/network/ssl/qsslcontext_openssl.cpp7
-rw-r--r--src/network/ssl/qsslsocket_openssl.cpp4
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformcursor.cpp2
-rw-r--r--src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp14
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm6
-rw-r--r--src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm7
-rw-r--r--src/plugins/bearer/android/src/qandroidbearerengine.cpp41
-rw-r--r--src/plugins/bearer/corewlan/qcorewlanengine.h2
-rw-r--r--src/plugins/bearer/corewlan/qcorewlanengine.mm42
-rw-r--r--src/plugins/bearer/corewlan/qcorewlanengine_10_6.mm922
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp428
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerengine.h21
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp218
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerservice.h86
-rw-r--r--src/plugins/bearer/networkmanager/qnmdbushelper.cpp56
-rw-r--r--src/plugins/bearer/networkmanager/qnmdbushelper.h12
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibility.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibility.mm17
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm3
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoadrag.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaprintdevice.mm3
-rwxr-xr-xsrc/plugins/platforms/cocoa/qcocoasystemtrayicon.mm96
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm11
-rw-r--r--src/plugins/platforms/cocoa/qmacclipboard.h17
-rw-r--r--src/plugins/platforms/cocoa/qmacclipboard.mm56
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm59
-rw-r--r--src/plugins/platforms/cocoa/qprintengine_mac.mm47
-rw-r--r--src/plugins/platforms/ios/qioseventdispatcher.mm10
-rw-r--r--src/plugins/platforms/ios/quiaccessibilityelement.mm3
-rw-r--r--src/plugins/platforms/windows/qwindowscursor.cpp12
-rw-r--r--src/plugins/platforms/windows/qwindowscursor.h2
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp9
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp12
-rw-r--r--src/plugins/printsupport/cups/qcupsprintengine.cpp6
-rw-r--r--src/plugins/printsupport/cups/qppdprintdevice.cpp3
-rw-r--r--src/plugins/printsupport/windows/qwindowsprintdevice.cpp9
-rw-r--r--src/printsupport/kernel/qprintengine_win.cpp59
-rw-r--r--src/printsupport/kernel/qprinter.cpp12
-rw-r--r--src/printsupport/kernel/qprinterinfo.cpp27
-rw-r--r--src/printsupport/kernel/qprinterinfo.h3
-rw-r--r--src/sql/kernel/qsqldatabase.cpp15
-rw-r--r--src/sql/kernel/qsqlerror.cpp8
-rw-r--r--src/sql/kernel/qsqlfield.cpp23
-rw-r--r--src/sql/kernel/qsqlrecord.cpp13
-rw-r--r--src/testlib/qtestcase.cpp1
-rw-r--r--src/tools/rcc/rcc.cpp12
-rw-r--r--src/widgets/dialogs/qfontdialog.cpp1
-rw-r--r--src/widgets/dialogs/qwizard_win.cpp5
-rw-r--r--src/widgets/doc/snippets/customstyle/customstyle.cpp2
-rw-r--r--src/widgets/doc/snippets/customstyle/customstyle.h2
-rw-r--r--src/widgets/doc/snippets/customstyle/customstyle.pro1
-rw-r--r--src/widgets/doc/snippets/customstyle/main.cpp2
-rw-r--r--src/widgets/doc/snippets/customviewstyle.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp20
-rw-r--r--src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h4
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicsview.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicswidget.cpp4
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp1
-rw-r--r--src/widgets/kernel/qlayout.cpp9
-rw-r--r--src/widgets/kernel/qstandardgestures.cpp4
-rw-r--r--src/widgets/kernel/qwidget.cpp38
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm2
-rw-r--r--src/widgets/styles/qstyle.cpp12
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp14
-rw-r--r--src/widgets/styles/qwindowsvistastyle.cpp22
-rw-r--r--src/widgets/styles/qwindowsxpstyle.cpp33
-rw-r--r--src/widgets/styles/qwindowsxpstyle_p_p.h1
-rw-r--r--src/widgets/widgets/qcalendarwidget.cpp3
-rw-r--r--src/widgets/widgets/qcombobox.cpp29
-rw-r--r--src/widgets/widgets/qcombobox_p.h6
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp6
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp7
-rw-r--r--tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp10
-rw-r--r--tests/auto/corelib/io/largefile/tst_largefile.cpp2
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp45
-rw-r--r--tests/auto/gui/text/qglyphrun/qglyphrun.pro9
-rw-r--r--tests/auto/gui/text/qglyphrun/testdata.qrc2
-rw-r--r--tests/auto/gui/text/qrawfont/qrawfont.pro8
-rw-r--r--tests/auto/gui/text/qrawfont/testdata.qrc2
-rw-r--r--tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp39
-rw-r--r--tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp12
-rw-r--r--tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp18
-rw-r--r--tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp46
-rw-r--r--tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp8
-rw-r--r--tests/auto/shared/platforminputcontext.h2
-rw-r--r--tests/auto/shared/resources/test.ttf (renamed from tests/auto/gui/text/qglyphrun/test.ttf)bin2008 -> 2008 bytes
-rw-r--r--tests/auto/shared/resources/testfont.ttf (renamed from tests/auto/gui/text/qrawfont/testfont.ttf)bin63212 -> 63212 bytes
-rw-r--r--tests/auto/tools/rcc/data/images/images.expected2
-rw-r--r--tests/auto/widgets/dialogs/qfontdialog/qfontdialog.pro2
-rw-r--r--tests/auto/widgets/dialogs/qfontdialog/testfonts.qrc6
-rw-r--r--tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp30
-rw-r--r--tests/auto/widgets/gestures/gestures.pro6
-rw-r--r--tests/auto/widgets/gestures/qgesturerecognizer/qgesturerecognizer.pro4
-rw-r--r--tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp336
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp89
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp25
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp36
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp28
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp37
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp43
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp17
-rw-r--r--tests/auto/widgets/widgets.pro1
-rw-r--r--tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp10
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp54
-rw-r--r--tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp45
-rw-r--r--tests/manual/cocoa/qsystemtrayicon/icons.qrc11
-rw-r--r--tests/manual/cocoa/qsystemtrayicon/macsystray16x16.pngbin0 -> 101 bytes
-rw-r--r--tests/manual/cocoa/qsystemtrayicon/macsystray18x18.pngbin0 -> 108 bytes
-rw-r--r--tests/manual/cocoa/qsystemtrayicon/macsystray25x15.pngbin0 -> 109 bytes
-rw-r--r--tests/manual/cocoa/qsystemtrayicon/macsystray32x32.pngbin0 -> 117 bytes
-rw-r--r--tests/manual/cocoa/qsystemtrayicon/macsystray36x36.pngbin0 -> 151 bytes
-rw-r--r--tests/manual/cocoa/qsystemtrayicon/macsystray50x30.pngbin0 -> 167 bytes
-rw-r--r--tests/manual/cocoa/qsystemtrayicon/macsystray64x64.pngbin0 -> 204 bytes
-rw-r--r--tests/manual/cocoa/qsystemtrayicon/main.cpp88
-rw-r--r--tests/manual/cocoa/qsystemtrayicon/qsystemtrayicon.pro7
-rw-r--r--tools/configure/configureapp.cpp3
163 files changed, 2571 insertions, 1626 deletions
diff --git a/dist/changes-5.4.0 b/dist/changes-5.4.0
index f36145cd90..927ca0f9f1 100644
--- a/dist/changes-5.4.0
+++ b/dist/changes-5.4.0
@@ -31,3 +31,15 @@ QtSql
- qsql ibase: fix memory corruption due to LONG being 4 bytes in firebird.
- QSqlDriver::dbmsType(): New method reports DBMS type. Especially useful when using ODBC.
+
+****************************************************************************
+* Platform Specific Changes *
+****************************************************************************
+
+OS X
+----
+
+ - OS X 10.6 is no longer supported.
+ - OS X 10.10 is now supported.
+ - QMacStyle has been updated with better OS 10.10 support.
+ - The Qt binary packages are now configured with C++11 enabled.
diff --git a/examples/network/securesocketclient/sslclient.cpp b/examples/network/securesocketclient/sslclient.cpp
index 3ca0a6dc59..23ca7e41e7 100644
--- a/examples/network/securesocketclient/sslclient.cpp
+++ b/examples/network/securesocketclient/sslclient.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the examples of the Qt Toolkit.
@@ -46,6 +46,7 @@
#include <QtWidgets/QScrollBar>
#include <QtWidgets/QStyle>
#include <QtWidgets/QToolButton>
+#include <QtWidgets/QMessageBox>
#include <QtNetwork/QSslCipher>
SslClient::SslClient(QWidget *parent)
@@ -96,6 +97,8 @@ void SslClient::secureConnect()
this, SLOT(socketStateChanged(QAbstractSocket::SocketState)));
connect(socket, SIGNAL(encrypted()),
this, SLOT(socketEncrypted()));
+ connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
+ this, SLOT(socketError(QAbstractSocket::SocketError)));
connect(socket, SIGNAL(sslErrors(QList<QSslError>)),
this, SLOT(sslErrors(QList<QSslError>)));
connect(socket, SIGNAL(readyRead()),
@@ -118,8 +121,6 @@ void SslClient::socketStateChanged(QAbstractSocket::SocketState state)
form->cipherLabel->setText(tr("<none>"));
if (padLock)
padLock->hide();
- socket->deleteLater();
- socket = 0;
}
}
@@ -180,6 +181,11 @@ void SslClient::sendData()
form->sessionInput->clear();
}
+void SslClient::socketError(QAbstractSocket::SocketError error)
+{
+ QMessageBox::critical(this, tr("Connection error"), socket->errorString());
+}
+
void SslClient::sslErrors(const QList<QSslError> &errors)
{
QDialog errorDialog(this);
diff --git a/examples/network/securesocketclient/sslclient.h b/examples/network/securesocketclient/sslclient.h
index 8ebf2cc536..efc3569743 100644
--- a/examples/network/securesocketclient/sslclient.h
+++ b/examples/network/securesocketclient/sslclient.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the examples of the Qt Toolkit.
@@ -65,6 +65,7 @@ private slots:
void socketEncrypted();
void socketReadyRead();
void sendData();
+ void socketError(QAbstractSocket::SocketError error);
void sslErrors(const QList<QSslError> &errors);
void displayCertificateInfo();
diff --git a/examples/opengl/threadedqopenglwidget/main.cpp b/examples/opengl/threadedqopenglwidget/main.cpp
index 2c94469b7c..66ee4c2f7f 100644
--- a/examples/opengl/threadedqopenglwidget/main.cpp
+++ b/examples/opengl/threadedqopenglwidget/main.cpp
@@ -75,26 +75,31 @@ int main( int argc, char ** argv )
+ QLatin1Char('/') + getGlString(topLevelGlWidget.context()->functions(), GL_RENDERER);
const bool supportsThreading = !glInfo.contains(QLatin1String("nouveau"), Qt::CaseInsensitive)
- && !glInfo.contains(QLatin1String("ANGLE"), Qt::CaseInsensitive);
+ && !glInfo.contains(QLatin1String("ANGLE"), Qt::CaseInsensitive)
+ && !glInfo.contains(QLatin1String("llvmpipe"), Qt::CaseInsensitive);
const QString toolTip = supportsThreading ? glInfo : glInfo + QStringLiteral("\ndoes not support threaded OpenGL.");
topLevelGlWidget.setToolTip(toolTip);
QScopedPointer<MainWindow> mw1;
QScopedPointer<MainWindow> mw2;
- if (supportsThreading && !QApplication::arguments().contains(QStringLiteral("--single"))) {
- pos += QPoint(100, 100);
- mw1.reset(new MainWindow);
- mw1->setToolTip(toolTip);
- mw1->move(pos);
- mw1->setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example #1"));
- mw1->show();
- pos += QPoint(100, 100);
- mw2.reset(new MainWindow);
- mw2->setToolTip(toolTip);
- mw2->move(pos);
- mw2->setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example #2"));
- mw2->show();
+ if (!QApplication::arguments().contains(QStringLiteral("--single"))) {
+ if (supportsThreading) {
+ pos += QPoint(100, 100);
+ mw1.reset(new MainWindow);
+ mw1->setToolTip(toolTip);
+ mw1->move(pos);
+ mw1->setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example #1"));
+ mw1->show();
+ pos += QPoint(100, 100);
+ mw2.reset(new MainWindow);
+ mw2->setToolTip(toolTip);
+ mw2->move(pos);
+ mw2->setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example #2"));
+ mw2->show();
+ } else {
+ qWarning() << toolTip;
+ }
}
return a.exec();
diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp
index 5acd60edea..f2d55d481d 100644
--- a/qmake/generators/win32/msbuild_objectmodel.cpp
+++ b/qmake/generators/win32/msbuild_objectmodel.cpp
@@ -474,7 +474,11 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool)
<< attrTag("Condition", condition)
<< valueTag(tool.Configuration.PrimaryOutput);
}
-
+ if (!tool.Configuration.PrimaryOutputExtension.isEmpty()) {
+ xml<< tag("TargetExt")
+ << attrTag("Condition", condition)
+ << valueTag(tool.Configuration.PrimaryOutputExtension);
+ }
if ( tool.Configuration.linker.IgnoreImportLibrary != unset) {
xml<< tag("IgnoreImportLibrary")
<< attrTag("Condition", condition)
@@ -696,7 +700,11 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProject &tool)
<< attrTag("Condition", condition)
<< valueTag(config.PrimaryOutput);
}
-
+ if (!config.PrimaryOutputExtension.isEmpty()) {
+ xml << tag("TargetExt")
+ << attrTag("Condition", condition)
+ << valueTag(config.PrimaryOutputExtension);
+ }
if (config.linker.IgnoreImportLibrary != unset) {
xml << tag("IgnoreImportLibrary")
<< attrTag("Condition", condition)
diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp
index aa2d40ad77..596170b343 100644
--- a/qmake/generators/win32/msvc_objectmodel.cpp
+++ b/qmake/generators/win32/msvc_objectmodel.cpp
@@ -2398,7 +2398,11 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info)
if (!CustomBuildTool.Description.isEmpty())
CustomBuildTool.Description += ", ";
CustomBuildTool.Description += cmd_name;
+ // Execute custom build steps in an environment variable scope to prevent unwanted
+ // side effects for downstream build steps
+ CustomBuildTool.CommandLine += QLatin1String("setlocal");
CustomBuildTool.CommandLine += VCToolBase::fixCommandLine(cmd.trimmed());
+ CustomBuildTool.CommandLine += QLatin1String("endlocal");
int space = cmd.indexOf(' ');
QFileInfo finf(cmd.left(space));
if (CustomBuildTool.ToolPath.isEmpty())
diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h
index 850f5f0f57..4b70ca3d71 100644
--- a/qmake/generators/win32/msvc_objectmodel.h
+++ b/qmake/generators/win32/msvc_objectmodel.h
@@ -887,6 +887,7 @@ public:
QString ConfigurationName;
QString OutputDirectory;
QString PrimaryOutput;
+ QString PrimaryOutputExtension;
QString ProgramDatabase;
QString PlatformToolSet;
triState RegisterOutput;
diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp
index 24421c6c28..9385a50e02 100644
--- a/qmake/generators/win32/msvc_vcproj.cpp
+++ b/qmake/generators/win32/msvc_vcproj.cpp
@@ -405,6 +405,21 @@ QString VcprojGenerator::retrievePlatformToolSet() const
}
}
+bool VcprojGenerator::isStandardSuffix(const QString &suffix) const
+{
+ if (!project->values("QMAKE_APP_FLAG").isEmpty()) {
+ if (suffix.compare("exe", Qt::CaseInsensitive) == 0)
+ return true;
+ } else if (project->isActiveConfig("shared")) {
+ if (suffix.compare("dll", Qt::CaseInsensitive) == 0)
+ return true;
+ } else {
+ if (suffix.compare("lib", Qt::CaseInsensitive) == 0)
+ return true;
+ }
+ return false;
+}
+
ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHash<QString, QString> &projLookup,
QHash<QString, QString> &projGuids,
QHash<VcsolutionDepend *, QStringList> &extraSubdirs,
@@ -993,12 +1008,12 @@ void VcprojGenerator::initConfiguration()
if (conf.CompilerVersion >= NET2010) {
conf.PlatformToolSet = retrievePlatformToolSet();
- // The target name could have been changed.
- conf.PrimaryOutput = project->first("TARGET").toQString();
- if (!conf.PrimaryOutput.isEmpty() && project->first("TEMPLATE") == "vclib"
- && project->isActiveConfig("shared")) {
- conf.PrimaryOutput.append(project->first("TARGET_VERSION_EXT").toQString());
- }
+ const QFileInfo targetInfo = fileInfo(project->first("MSVCPROJ_TARGET").toQString());
+ conf.PrimaryOutput = targetInfo.completeBaseName();
+
+ const QString targetSuffix = targetInfo.suffix();
+ if (!isStandardSuffix(targetSuffix))
+ conf.PrimaryOutputExtension = '.' + targetSuffix;
}
if (conf.CompilerVersion >= NET2012) {
diff --git a/qmake/generators/win32/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h
index d15539d25c..f436b6da20 100644
--- a/qmake/generators/win32/msvc_vcproj.h
+++ b/qmake/generators/win32/msvc_vcproj.h
@@ -137,6 +137,7 @@ private:
const ProStringList &allDependencies = ProStringList());
QUuid increaseUUID(const QUuid &id);
QString retrievePlatformToolSet() const;
+ bool isStandardSuffix(const QString &suffix) const;
friend class VCFilter;
};
diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
index ed5be81d80..7642bc38b5 100644
--- a/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
+++ b/src/android/jar/src/org/qtproject/qt5/android/QtActivityDelegate.java
@@ -55,6 +55,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.ResultReceiver;
import android.text.method.MetaKeyKeyListener;
+import android.util.Base64;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
@@ -660,6 +661,22 @@ public class QtActivityDelegate
m_applicationParameters += "\t-qmljsdebugger=" + qmljsdebugger;
}
+ if (extras.containsKey("extraenvvars")) {
+ try {
+ m_environmentVariables += "\t" + new String(Base64.decode(extras.getString("extraenvvars"), Base64.DEFAULT), "UTF-8");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ if (extras.containsKey("extraappparams")) {
+ try {
+ m_applicationParameters += "\t" + new String(Base64.decode(extras.getString("extraappparams"), Base64.DEFAULT), "UTF-8");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
if (null == m_surfaces)
onCreate(null);
String nativeLibraryDir = QtNativeLibrariesDir.nativeLibrariesDir(m_activity);
diff --git a/src/corelib/codecs/qicucodec.cpp b/src/corelib/codecs/qicucodec.cpp
index 103bf0573f..a549430649 100644
--- a/src/corelib/codecs/qicucodec.cpp
+++ b/src/corelib/codecs/qicucodec.cpp
@@ -445,6 +445,8 @@ QTextCodec *QIcuCodec::codecForNameUnlocked(const char *name)
// backwards compatibility with Qt 4.x
if (!qstrcmp(name, "CP949"))
name = "windows-949";
+ else if (!qstrcmp(name, "Apple Roman"))
+ name = "macintosh";
// these are broken data in ICU 4.4, and can't be resolved even though they are aliases to tis-620
if (!qstrcmp(name, "windows-874-2000")
|| !qstrcmp(name, "windows-874")
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 519570c499..9d13e1b892 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -346,13 +346,13 @@ QTextCodec::ConverterState::~ConverterState()
The supported encodings are:
\list
- \li Apple Roman
\li \l{Big5 Text Codec}{Big5}
\li \l{Big5-HKSCS Text Codec}{Big5-HKSCS}
\li CP949
\li \l{EUC-JP Text Codec}{EUC-JP}
\li \l{EUC-KR Text Codec}{EUC-KR}
- \li \l{GBK Text Codec}{GB18030-0}
+ \li \l{GBK Text Codec}{GB18030}
+ \li HP-ROMAN8
\li IBM 850
\li IBM 866
\li IBM 874
@@ -360,10 +360,9 @@ QTextCodec::ConverterState::~ConverterState()
\li ISO 8859-1 to 10
\li ISO 8859-13 to 16
\li Iscii-Bng, Dev, Gjr, Knd, Mlm, Ori, Pnj, Tlg, and Tml
- \li JIS X 0201
- \li JIS X 0208
\li KOI8-R
\li KOI8-U
+ \li Macintosh
\li \l{Shift-JIS Text Codec}{Shift-JIS}
\li TIS-620
\li \l{TSCII Text Codec}{TSCII}
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 044ba66a4c..4e074bcdb5 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -159,11 +159,10 @@
\value AA_UseHighDpiPixmaps Make QIcon::pixmap() generate high-dpi pixmaps
that can be larger than the requested size. Such pixmaps will have
- devicePixelRatio set to a value higher than 1.
-
- After setting this attribute application code that uses pixmap
- sizes in layout geometry calculations should typically divide by
- QPixmap::devicePixelRatio() to get device-independent layout geometry.
+ devicePixelRatio set to a value higher than 1. After setting this
+ attribute application code that uses pixmap sizes in layout geometry
+ calculations should typically divide by QPixmap::devicePixelRatio()
+ to get device-independent layout geometry.
\value AA_ForceRasterWidgets Make top-level widgets use pure raster surfaces,
and do not support non-native GL-based child widgets.
@@ -183,7 +182,7 @@
\l{http://www.mesa3d.org/llvmpipe.html}{Mesa llvmpipe}, providing
OpenGL 2.1. The value may have no effect if no such OpenGL
implementation is available. The default name of this library is
- QtSoftwareOpenGL.dll and can be overridden by setting the environment
+ opengl32sw.dll and can be overridden by setting the environment
variable \e QT_OPENGL_DLL. See the platform-specific pages, for
instance \l{Qt for Windows}, for more information. This value has
been added in Qt 5.4.
@@ -191,7 +190,8 @@
\value AA_ShareOpenGLContexts Enables resource sharing between the OpenGL
contexts used by classes like QOpenGLWidget and QQuickWidget. This
allows sharing OpenGL resources, like textures, between QOpenGLWidget
- instances that belong to different top-level windows.
+ instances that belong to different top-level windows. This value has
+ been added in Qt 5.4.
The following values are obsolete:
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index 6fe4c2455b..d3411abf10 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -206,6 +206,13 @@ QAbstractFileEngine *QFilePrivate::engine() const
directory usually is not writable, but it is still possible to
create files in it.
+ Qt's understanding of file permissions is limited, which affects especially
+ the \l QFile::setPermissions() function. On Windows, Qt will set only the
+ legacy read-only flag, and that only when none of the Write* flags are
+ passed. Qt does not manipulate access control lists (ACLs), which makes this
+ function mostly useless for NTFS volumes. It may still be of use for USB
+ sticks that use VFAT file systems. POSIX ACLs are not manipulated, either.
+
\sa QTextStream, QDataStream, QFileInfo, QDir, {The Qt Resource System}
*/
@@ -1063,9 +1070,12 @@ QFile::permissions(const QString &fileName)
/*!
Sets the permissions for the file to the \a permissions specified.
- Returns \c true if successful, or false if the permissions cannot be
+ Returns \c true if successful, or \c false if the permissions cannot be
modified.
+ \warning This function does not manipulate ACLs, which may limit its
+ effectiveness.
+
\sa permissions(), setFileName()
*/
diff --git a/src/corelib/io/qfiledevice.cpp b/src/corelib/io/qfiledevice.cpp
index 8d1c59e159..598347a56f 100644
--- a/src/corelib/io/qfiledevice.cpp
+++ b/src/corelib/io/qfiledevice.cpp
@@ -648,9 +648,12 @@ QFile::Permissions QFileDevice::permissions() const
/*!
Sets the permissions for the file to the \a permissions specified.
- Returns \c true if successful, or false if the permissions cannot be
+ Returns \c true if successful, or \c false if the permissions cannot be
modified.
+ \warning This function does not manipulate ACLs, which may limit its
+ effectiveness.
+
\sa permissions()
*/
bool QFileDevice::setPermissions(Permissions permissions)
diff --git a/src/corelib/io/qloggingcategory.cpp b/src/corelib/io/qloggingcategory.cpp
index 37503e032c..fef48a9040 100644
--- a/src/corelib/io/qloggingcategory.cpp
+++ b/src/corelib/io/qloggingcategory.cpp
@@ -61,13 +61,15 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift)
\brief The QLoggingCategory class represents a category, or 'area' in the
logging infrastructure.
- QLoggingCategory represents a certain logging category - identified
- by a string - at runtime. Whether a category should be actually logged or
- not can be checked with the \l isEnabled() methods.
+ QLoggingCategory represents a certain logging category - identified by a
+ string - at runtime. A category can be configured to enable or disable
+ logging of messages per message type. Whether a message type is enabled or
+ not can be checked with the \l isDebugEnabled(), \l isWarningEnabled(), and
+ \l isCriticalEnabled() methods.
All objects are meant to be configured by a common registry (see also
\l{Configuring Categories}). Different objects can also represent the same
- category. It's therefore not recommended to export objects across module
+ category. It is therefore not recommended to export objects across module
boundaries, nor to manipulate the objects directly, nor to inherit from
QLoggingCategory.
@@ -110,8 +112,9 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift)
\section2 Logging Rules
- Logging rules allow to enable or disable logging for categories in a flexible
- way. Rules are specified in text, where every line must have the format
+ Logging rules allow logging for categories to be enabled or disabled in a
+ flexible way. Rules are specified in text, where every line must have the
+ format
\code
<category>[.<type>] = true|false
@@ -120,12 +123,12 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift)
\c <category> is the name of the category, potentially with \c{*} as a
wildcard symbol as the first or last character (or at both positions).
The optional \c <type> must be either \c debug, \c warning, or \c critical.
- Lines that do not fit to his scheme are ignored.
+ Lines that do not fit this scheme are ignored.
Rules are evaluated in text order, from first to last. That is, if two rules
apply to a category/type, the rule that comes later is applied.
- Rules can be set via \l setFilterRules(). Since Qt 5.3 logging rules can also
+ Rules can be set via \l setFilterRules(). Since Qt 5.3, logging rules can also
be set in the \c QT_LOGGING_RULES environment variable, and
are automatically loaded from the \c [Rules] section of a logging
configuration file. Such configuration files are looked up in the QtProject
@@ -168,13 +171,13 @@ static void setBoolLane(QBasicAtomicInt *atomic, bool enable, int shift)
\section2 Installing a Custom Filter
- As a lower-level alternative to the text rules you can also implement a
+ As a lower-level alternative to the text rules, you can also implement a
custom filter via \l installFilter(). All filter rules are ignored in this
case.
\section1 Printing the Category
- Use the \c %{category} place holder to print the category in the default
+ Use the \c %{category} placeholder to print the category in the default
message handler:
\snippet qloggingcategory/main.cpp 3
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 53bfa769ac..08b2fb083a 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -2112,6 +2112,21 @@ namespace QtPrivate {
};
}
+namespace QtMetaTypePrivate {
+inline Q_DECL_CONSTEXPR bool isBuiltinSequentialType(int typeId)
+{
+ return typeId == qMetaTypeId<QStringList>()
+ || typeId == qMetaTypeId<QByteArrayList>()
+ || typeId == qMetaTypeId<QVariantList>();
+}
+
+inline Q_DECL_CONSTEXPR bool isBuiltinAssociativeType(int typeId)
+{
+ return typeId == qMetaTypeId<QVariantHash>()
+ || typeId == qMetaTypeId<QVariantMap>();
+}
+} // QtMetaTypePrivate
+
QT_END_NAMESPACE
#endif // QMETATYPE_H
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index d0fa0613b3..33827926c6 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -1086,6 +1086,11 @@ void QTranslatorPrivate::clear()
\a disambiguation). If none is found, also tries (\a context, \a
sourceText, ""). If that still fails, returns a null string.
+ \note Incomplete translations may result in unexpected behavior:
+ If no translation for (\a context, \a sourceText, "")
+ is provided, the method might in this case actually return a
+ translation for a different \a disambiguation.
+
If \a n is not -1, it is used to choose an appropriate form for
the translation (e.g. "%n file found" vs. "%n files found").
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index cea893ba0c..2ac1bb11fb 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -3632,11 +3632,13 @@ QSequentialIterable::const_iterator::const_iterator(const const_iterator &other)
QSequentialIterable::const_iterator&
QSequentialIterable::const_iterator::operator=(const const_iterator &other)
{
- if (!m_impl.equal(other.m_impl)) {
- m_impl = other.m_impl;
- ref = other.ref;
+ other.ref->ref();
+ if (!ref->deref()) {
+ m_impl.destroyIter();
+ delete ref;
}
- ref->ref();
+ m_impl = other.m_impl;
+ ref = other.ref;
return *this;
}
@@ -3941,11 +3943,13 @@ QAssociativeIterable::const_iterator::const_iterator(const const_iterator &other
QAssociativeIterable::const_iterator&
QAssociativeIterable::const_iterator::operator=(const const_iterator &other)
{
- if (!m_impl.equal(other.m_impl)) {
- m_impl = other.m_impl;
- ref = other.ref;
+ other.ref->ref();
+ if (!ref->deref()) {
+ m_impl.destroyIter();
+ delete ref;
}
- ref->ref();
+ m_impl = other.m_impl;
+ ref = other.ref;
return *this;
}
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index bdbd0dd8ef..57e0523f7c 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -736,7 +736,7 @@ namespace QtPrivate {
{
static QVariantList invoke(const QVariant &v)
{
- if (v.userType() == qMetaTypeId<QStringList>() || v.userType() == qMetaTypeId<QByteArrayList>() || QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QSequentialIterableImpl>())) {
+ if (QtMetaTypePrivate::isBuiltinSequentialType(v.userType()) || QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QSequentialIterableImpl>())) {
QSequentialIterable iter = QVariantValueHelperInterface<QSequentialIterable>::invoke(v);
QVariantList l;
l.reserve(iter.size());
@@ -752,7 +752,7 @@ namespace QtPrivate {
{
static QVariantHash invoke(const QVariant &v)
{
- if (QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>())) {
+ if (QtMetaTypePrivate::isBuiltinAssociativeType(v.userType()) || QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>())) {
QAssociativeIterable iter = QVariantValueHelperInterface<QAssociativeIterable>::invoke(v);
QVariantHash l;
l.reserve(iter.size());
@@ -768,7 +768,7 @@ namespace QtPrivate {
{
static QVariantMap invoke(const QVariant &v)
{
- if (QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>())) {
+ if (QtMetaTypePrivate::isBuiltinAssociativeType(v.userType()) || QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>())) {
QAssociativeIterable iter = QVariantValueHelperInterface<QAssociativeIterable>::invoke(v);
QVariantMap l;
for (QAssociativeIterable::const_iterator it = iter.begin(), end = iter.end(); it != end; ++it)
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp
index 858c2e1b9c..01827c807a 100644
--- a/src/gui/accessible/qaccessible.cpp
+++ b/src/gui/accessible/qaccessible.cpp
@@ -166,6 +166,7 @@ QT_BEGIN_NAMESPACE
\value playsSound The object produces sound when interacted with.
\value pressed The object is pressed.
\value readOnly The object can usually be edited, but is explicitly set to read-only.
+ \value searchEdit The object is a line edit that is the input for search queries.
\value selectable The object is selectable.
\value selectableText The object has text which can be selected. This is different from selectable which refers to the object's children.
\value selected The object is selected, this is independent of text selection.
diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h
index 0583a8c691..7b5d7a1bfd 100644
--- a/src/gui/accessible/qaccessible.h
+++ b/src/gui/accessible/qaccessible.h
@@ -185,6 +185,8 @@ public:
quint64 selectableText : 1;
quint64 supportsAutoCompletion : 1;
+ quint64 searchEdit : 1;
+
// quint64 horizontal : 1;
// quint64 vertical : 1;
// quint64 invalidEntry : 1;
diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp
index 750e253dee..06491f1155 100644
--- a/src/gui/image/qiconloader.cpp
+++ b/src/gui/image/qiconloader.cpp
@@ -223,6 +223,7 @@ QIconTheme::QIconTheme(const QString &themeName)
// Parent themes provide fallbacks for missing icons
m_parents = indexReader.value(
QLatin1String("Icon Theme/Inherits")).toStringList();
+ m_parents.removeAll(QString());
// Ensure a default platform fallback for all themes
if (m_parents.isEmpty()) {
diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp
index e847a45a85..ad84b0a091 100644
--- a/src/gui/image/qimagereader.cpp
+++ b/src/gui/image/qimagereader.cpp
@@ -877,15 +877,22 @@ QString QImageReader::fileName() const
/*!
\since 4.2
- This is an image format specific function that sets the quality
- level of the image to \a quality. For image formats that do not
- support setting the quality, this value is ignored.
+ Sets the quality setting of the image format to \a quality.
- The value range of \a quality depends on the image format. For
- example, the "jpeg" format supports a quality range from 0 (low
- quality, high compression) to 100 (high quality, low compression).
+ Some image formats, in particular lossy ones, entail a tradeoff between a)
+ visual quality of the resulting image, and b) decoding execution time.
+ This function sets the level of that tradeoff for image formats that
+ support it.
- \sa quality()
+ In case of scaled image reading, the quality setting may also influence the
+ tradeoff level between visual quality and execution speed of the scaling
+ algorithm.
+
+ The value range of \a quality depends on the image format. For example,
+ the "jpeg" format supports a quality range from 0 (low visual quality) to
+ 100 (high visual quality).
+
+ \sa quality() setScaledSize()
*/
void QImageReader::setQuality(int quality)
{
@@ -895,7 +902,7 @@ void QImageReader::setQuality(int quality)
/*!
\since 4.2
- Returns the quality level of the image.
+ Returns the quality setting of the image format.
\sa setQuality()
*/
diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp
index d172d4008f..fa261df1a5 100644
--- a/src/gui/image/qimagewriter.cpp
+++ b/src/gui/image/qimagewriter.cpp
@@ -434,13 +434,16 @@ QString QImageWriter::fileName() const
}
/*!
- This is an image format specific function that sets the quality
- level of the image to \a quality. For image formats that do not
- support setting the quality, this value is ignored.
+ Sets the quality setting of the image format to \a quality.
- The value range of \a quality depends on the image format. For
- example, the "jpeg" format supports a quality range from 0 (low
- quality, high compression) to 100 (high quality, low compression).
+ Some image formats, in particular lossy ones, entail a tradeoff between a)
+ visual quality of the resulting image, and b) encoding execution time and
+ compression level. This function sets the level of that tradeoff for image
+ formats that support it. For other formats, this value is ignored.
+
+ The value range of \a quality depends on the image format. For example,
+ the "jpeg" format supports a quality range from 0 (low visual quality, high
+ compression) to 100 (high visual quality, low compression).
\sa quality()
*/
@@ -450,7 +453,7 @@ void QImageWriter::setQuality(int quality)
}
/*!
- Returns the quality level of the image.
+ Returns the quality setting of the image format.
\sa setQuality()
*/
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index e7fdbde432..8c71fb23de 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1630,8 +1630,9 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv
QWindowSystemInterfacePrivate::ApplicationStateChangedEvent * changeEvent = static_cast<QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *>(e);
QGuiApplicationPrivate::setApplicationState(changeEvent->newState, changeEvent->forcePropagate); }
break;
- case QWindowSystemInterfacePrivate::FlushEvents:
- QWindowSystemInterface::deferredFlushWindowSystemEvents();
+ case QWindowSystemInterfacePrivate::FlushEvents: {
+ QWindowSystemInterfacePrivate::FlushEventsEvent *flushEventsEvent = static_cast<QWindowSystemInterfacePrivate::FlushEventsEvent *>(e);
+ QWindowSystemInterface::deferredFlushWindowSystemEvents(flushEventsEvent->flags); }
break;
case QWindowSystemInterfacePrivate::Close:
QGuiApplicationPrivate::processCloseEvent(
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index bd95a8614f..722a695481 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -526,16 +526,16 @@ void QWindowSystemInterface::handleExposeEvent(QWindow *tlw, const QRegion &regi
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
}
-void QWindowSystemInterface::deferredFlushWindowSystemEvents()
+void QWindowSystemInterface::deferredFlushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)
{
Q_ASSERT(QThread::currentThread() == QGuiApplication::instance()->thread());
QMutexLocker locker(&QWindowSystemInterfacePrivate::flushEventMutex);
- flushWindowSystemEvents();
+ flushWindowSystemEvents(flags);
QWindowSystemInterfacePrivate::eventsFlushed.wakeOne();
}
-void QWindowSystemInterface::flushWindowSystemEvents()
+void QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)
{
const int count = QWindowSystemInterfacePrivate::windowSystemEventQueue.count();
if (!count)
@@ -549,11 +549,11 @@ void QWindowSystemInterface::flushWindowSystemEvents()
}
if (QThread::currentThread() != QGuiApplication::instance()->thread()) {
QMutexLocker locker(&QWindowSystemInterfacePrivate::flushEventMutex);
- QWindowSystemInterfacePrivate::FlushEventsEvent *e = new QWindowSystemInterfacePrivate::FlushEventsEvent();
+ QWindowSystemInterfacePrivate::FlushEventsEvent *e = new QWindowSystemInterfacePrivate::FlushEventsEvent(flags);
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
QWindowSystemInterfacePrivate::eventsFlushed.wait(&QWindowSystemInterfacePrivate::flushEventMutex);
} else {
- sendWindowSystemEvents(QEventLoop::AllEvents);
+ sendWindowSystemEvents(flags);
}
}
diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h
index 9784757d3a..30c236b51f 100644
--- a/src/gui/kernel/qwindowsysteminterface.h
+++ b/src/gui/kernel/qwindowsysteminterface.h
@@ -208,8 +208,8 @@ public:
// For event dispatcher implementations
static bool sendWindowSystemEvents(QEventLoop::ProcessEventsFlags flags);
static void setSynchronousWindowsSystemEvents(bool enable);
- static void flushWindowSystemEvents();
- static void deferredFlushWindowSystemEvents();
+ static void flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents);
+ static void deferredFlushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags);
static int windowSystemEventsQueued();
};
diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h
index 32a5aaa318..57411d8101 100644
--- a/src/gui/kernel/qwindowsysteminterface_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_p.h
@@ -187,9 +187,11 @@ public:
class FlushEventsEvent : public WindowSystemEvent {
public:
- FlushEventsEvent()
+ FlushEventsEvent(QEventLoop::ProcessEventsFlags f = QEventLoop::AllEvents)
: WindowSystemEvent(FlushEvents)
+ , flags(f)
{ }
+ QEventLoop::ProcessEventsFlags flags;
};
class UserEvent : public WindowSystemEvent {
diff --git a/src/gui/opengl/qopenglpixeltransferoptions.cpp b/src/gui/opengl/qopenglpixeltransferoptions.cpp
index 4f72b43f37..9ea2e0ecc1 100644
--- a/src/gui/opengl/qopenglpixeltransferoptions.cpp
+++ b/src/gui/opengl/qopenglpixeltransferoptions.cpp
@@ -36,6 +36,23 @@
QT_BEGIN_NAMESPACE
+/*!
+ * \class QOpenGLPixelTransferOptions
+ *
+ * \brief The QOpenGLPixelTransferOptions class describes the pixel storage
+ * modes that affect the unpacking of pixels during texture upload.
+ */
+
+/*!
+ * \fn QOpenGLPixelTransferOptions & QOpenGLPixelTransferOptions::operator=(QOpenGLPixelTransferOptions &&other)
+ * \internal
+ */
+
+/*!
+ * \fn void QOpenGLPixelTransferOptions::swap(QOpenGLPixelTransferOptions &other)
+ * \internal
+ */
+
class QOpenGLPixelTransferOptionsData : public QSharedData
{
public:
@@ -60,16 +77,25 @@ public:
bool swapBytes;
};
+/*!
+ * Constructs a new QOpenGLPixelTransferOptions instance with the default settings.
+ */
QOpenGLPixelTransferOptions::QOpenGLPixelTransferOptions()
: data(new QOpenGLPixelTransferOptionsData)
{
}
+/*!
+ * \internal
+ */
QOpenGLPixelTransferOptions::QOpenGLPixelTransferOptions(const QOpenGLPixelTransferOptions &rhs)
: data(rhs.data)
{
}
+/*!
+ * \internal
+ */
QOpenGLPixelTransferOptions &QOpenGLPixelTransferOptions::operator=(const QOpenGLPixelTransferOptions &rhs)
{
if (this != &rhs)
@@ -77,85 +103,152 @@ QOpenGLPixelTransferOptions &QOpenGLPixelTransferOptions::operator=(const QOpenG
return *this;
}
+/*!
+ * Destructor.
+ */
QOpenGLPixelTransferOptions::~QOpenGLPixelTransferOptions()
{
}
+/*!
+ * Sets the \a alignment requirements for each pixel row. Corresponds to \c GL_UNPACK_ALIGNMENT.
+ * The default value is 4, as specified by OpenGL.
+ */
void QOpenGLPixelTransferOptions::setAlignment(int alignment)
{
data->alignment = alignment;
}
+/*!
+ * \return the current alignment requirement for each pixel row.
+ */
int QOpenGLPixelTransferOptions::alignment() const
{
return data->alignment;
}
+/*!
+ * Sets the number of images that are skipped to \a skipImages.
+ * Corresponds to \c GL_UNPACK_SKIP_IMAGES. Equivalent to incrementing the pointer
+ * passed to QOpenGLTexture::setData(). The default value is 0.
+ */
void QOpenGLPixelTransferOptions::setSkipImages(int skipImages)
{
data->skipImages = skipImages;
}
+/*!
+ * \return the number of images that are skipped.
+ */
int QOpenGLPixelTransferOptions::skipImages() const
{
return data->skipImages;
}
+/*!
+ * Sets the number of rows that are skipped to \a skipRows.
+ * Corresponds to \c GL_UNPACK_SKIP_ROWS. Equivalent to incrementing the pointer
+ * passed to QOpenGLTexture::setData(). The default value is 0.
+ */
void QOpenGLPixelTransferOptions::setSkipRows(int skipRows)
{
data->skipRows = skipRows;
}
+/*!
+ * \return the number of rows that are skipped.
+ */
int QOpenGLPixelTransferOptions::skipRows() const
{
return data->skipRows;
}
+/*!
+ * Sets the number of pixels that are skipped to \a skipPixels.
+ * Corresponds to \c GL_UNPACK_SKIP_PIXELS. Equivalent to incrementing the pointer
+ * passed to QOpenGLTexture::setData(). The default value is 0.
+ */
void QOpenGLPixelTransferOptions::setSkipPixels(int skipPixels)
{
data->skipPixels = skipPixels;
}
+/*!
+ * \return the number of pixels that are skipped.
+ */
int QOpenGLPixelTransferOptions::skipPixels() const
{
return data->skipPixels;
}
+/*!
+ * Sets the image height for 3D textures to \a imageHeight.
+ * Corresponds to \c GL_UNPACK_IMAGE_HEIGHT.
+ * The default value is 0.
+ */
void QOpenGLPixelTransferOptions::setImageHeight(int imageHeight)
{
data->imageHeight = imageHeight;
}
+/*!
+ * \return the currently set image height.
+ */
int QOpenGLPixelTransferOptions::imageHeight() const
{
return data->imageHeight;
}
+/*!
+ * Sets the number of pixels in a row to \a rowLength.
+ * Corresponds to \c GL_UNPACK_ROW_LENGTH.
+ * The default value is 0.
+ */
void QOpenGLPixelTransferOptions::setRowLength(int rowLength)
{
data->rowLength = rowLength;
}
+/*!
+ * \return the currently set row length.
+ */
int QOpenGLPixelTransferOptions::rowLength() const
{
return data->rowLength;
}
+/*!
+ * \a lsbFirst specifies if bits within a byte are ordered from least to most significat.
+ * The default value is \c false, meaning that the first bit in each byte is the
+ * most significant one. This is significant for bitmap data only.
+ * Corresponds to \c GL_UNPACK_LSB_FIRST.
+ */
void QOpenGLPixelTransferOptions::setLeastSignificantByteFirst(bool lsbFirst)
{
data->lsbFirst = lsbFirst;
}
+/*!
+ * \return \c true if bits within a byte are ordered from least to most significant.
+ */
bool QOpenGLPixelTransferOptions::isLeastSignificantBitFirst() const
{
return data->lsbFirst;
}
+/*!
+ * \a swapBytes specifies if the byte ordering for multibyte components is reversed.
+ * The default value is \c false.
+ * Corresponds to \c GL_UNPACK_SWAP_BYTES.
+ */
void QOpenGLPixelTransferOptions::setSwapBytesEnabled(bool swapBytes)
{
data->swapBytes = swapBytes;
}
+/*!
+ * \return \c true if the byte ordering for multibyte components is reversed.
+ */
bool QOpenGLPixelTransferOptions::isSwapBytesEnabled() const
{
return data->swapBytes;
diff --git a/src/gui/opengl/qopengltextureglyphcache.cpp b/src/gui/opengl/qopengltextureglyphcache.cpp
index 6e16b2df75..0f70a01014 100644
--- a/src/gui/opengl/qopengltextureglyphcache.cpp
+++ b/src/gui/opengl/qopengltextureglyphcache.cpp
@@ -240,7 +240,7 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height)
QOpenGLShaderProgram *blitProgram = 0;
if (pex == 0) {
if (m_blitProgram == 0) {
- m_blitProgram = new QOpenGLShaderProgram(ctx);
+ m_blitProgram = new QOpenGLShaderProgram;
const bool isCoreProfile = ctx->format().profile() == QSurfaceFormat::CoreProfile;
{
@@ -444,6 +444,9 @@ void QOpenGLTextureGlyphCache::clear()
m_textureResource->free();
m_textureResource = 0;
+ delete m_blitProgram;
+ m_blitProgram = 0;
+
m_w = 0;
m_h = 0;
m_cx = 0;
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp
index 23412c4633..30421ea2fa 100644
--- a/src/gui/painting/qpdf.cpp
+++ b/src/gui/painting/qpdf.cpp
@@ -1347,6 +1347,8 @@ void QPdfEngine::setPen()
int pdfJoinStyle = 0;
switch(d->pen.joinStyle()) {
case Qt::MiterJoin:
+ case Qt::SvgMiterJoin:
+ *d->currentPage << d->pen.miterLimit() << "M ";
pdfJoinStyle = 0;
break;
case Qt::BevelJoin:
@@ -2081,8 +2083,10 @@ int QPdfEnginePrivate::writeImage(const QByteArray &data, int width, int height,
}
if (maskObject > 0)
xprintf("/Mask %d 0 R\n", maskObject);
- if (softMaskObject > 0)
+ if (softMaskObject > 0) {
xprintf("/SMask %d 0 R\n", softMaskObject);
+ xprintf("/Decode [1 0 1 0 1 0]\n");
+ }
int lenobj = requestObject();
xprintf("/Length %d 0 R\n", lenobj);
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 54fcbac308..a0cbd052e4 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -1014,8 +1014,8 @@ void QFont::setStyle(Style style)
}
/*!
- Returns the weight of the font which is one of the enumerated
- values from \l{QFont::Weight}.
+ Returns the weight of the font, using the same scale as the
+ \l{QFont::Weight} enumeration.
\sa setWeight(), Weight, QFontInfo
*/
@@ -1028,8 +1028,8 @@ int QFont::weight() const
\enum QFont::Weight
Qt uses a weighting scale from 0 to 99 similar to, but not the
- same as, the scales used in Windows or CSS. A weight of 0 is
- ultralight, whilst 99 will be extremely black.
+ same as, the scales used in Windows or CSS. A weight of 0 will be
+ thin, whilst 99 will be extremely black.
This enum contains the predefined font weights:
@@ -1041,8 +1041,8 @@ int QFont::weight() const
*/
/*!
- Sets the weight the font to \a weight, which should be a value
- from the \l QFont::Weight enumeration.
+ Sets the weight of the font to \a weight, using the scale defined by
+ \l QFont::Weight enumeration.
\sa weight(), QFontInfo
*/
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index dcd0521362..decf2fe121 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -91,9 +91,10 @@ static int getFontWeight(const QString &weightString)
// order of "expense".
//
// A simple string test is the cheapest, so let's do that first.
- if (s == QLatin1String("medium") ||
- s == QLatin1String("normal"))
+ if (s == QLatin1String("normal"))
return QFont::Normal;
+ if (s == QLatin1String("medium"))
+ return qt_mediumFontWeight;
if (s == QLatin1String("bold"))
return QFont::Bold;
if (s == QLatin1String("demibold") || s == QLatin1String("demi bold"))
@@ -102,6 +103,10 @@ static int getFontWeight(const QString &weightString)
return QFont::Black;
if (s == QLatin1String("light"))
return QFont::Light;
+ if (s == QLatin1String("thin"))
+ return qt_thinFontWeight;
+ if (s == QLatin1String("extralight"))
+ return qt_extralightFontWeight;
// Next up, let's see if contains() matches: slightly more expensive, but
// still fast enough.
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 062d2e5301..b44eb43be5 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -1062,6 +1062,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
(format == Format_A8 ? (info.width + 3) & ~3 : info.width * 4));
glyph_buffer_size = pitch * info.height;
glyph_buffer = new uchar[glyph_buffer_size];
+ memset(glyph_buffer, 0, glyph_buffer_size);
if (slot->format == FT_GLYPH_FORMAT_OUTLINE) {
FT_Bitmap bitmap;
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index 8c40189ed2..50b1bb9e9d 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -78,6 +78,10 @@ enum HB_Compat_Error {
typedef void (*qt_destroy_func_t) (void *user_data);
typedef bool (*qt_get_font_table_func_t) (void *user_data, uint tag, uchar *buffer, uint *length);
+const QFont::Weight qt_mediumFontWeight = static_cast<QFont::Weight>(57);
+const QFont::Weight qt_extralightFontWeight = static_cast<QFont::Weight>(12);
+const QFont::Weight qt_thinFontWeight = static_cast<QFont::Weight>(0);
+
class Q_GUI_EXPORT QFontEngine
{
public:
diff --git a/src/gui/util/qgridlayoutengine.cpp b/src/gui/util/qgridlayoutengine.cpp
index ed15e460f3..65f2297fce 100644
--- a/src/gui/util/qgridlayoutengine.cpp
+++ b/src/gui/util/qgridlayoutengine.cpp
@@ -1289,7 +1289,7 @@ void QGridLayoutEngine::fillRowData(QGridLayoutRowData *rowData,
if (rowIsIdenticalToPrevious && item != itemAt(row - 1, column, orientation))
rowIsIdenticalToPrevious = false;
- if (item)
+ if (item && !item->isIgnored())
rowIsEmpty = false;
}
diff --git a/src/gui/util/qgridlayoutengine_p.h b/src/gui/util/qgridlayoutengine_p.h
index bf34e816b5..b75312bfe8 100644
--- a/src/gui/util/qgridlayoutengine_p.h
+++ b/src/gui/util/qgridlayoutengine_p.h
@@ -295,6 +295,7 @@ public:
virtual QLayoutPolicy::Policy sizePolicy(Qt::Orientation orientation) const = 0;
virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const = 0;
+ virtual bool isIgnored() const { return false; }
virtual void setGeometry(const QRectF &rect) = 0;
/*
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index d3f6958d73..968342c7bd 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -1169,7 +1169,7 @@ void QNetworkReplyHttpImplPrivate::replyDownloadMetaData
setCachingEnabled(true);
}
- metaDataChanged();
+ _q_metaDataChanged();
}
void QNetworkReplyHttpImplPrivate::replyDownloadProgressSlot(qint64 bytesReceived, qint64 bytesTotal)
@@ -1362,7 +1362,7 @@ bool QNetworkReplyHttpImplPrivate::sendCacheContents(const QNetworkCacheMetaData
// This needs to be emitted in the event loop because it can be reached at
// the direct code path of qnam.get(...) before the user has a chance
// to connect any signals.
- QMetaObject::invokeMethod(q, "metaDataChanged", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(q, "_q_metaDataChanged", Qt::QueuedConnection);
QMetaObject::invokeMethod(q, "_q_cacheLoadReadyRead", Qt::QueuedConnection);
@@ -1991,7 +1991,7 @@ void QNetworkReplyHttpImplPrivate::error(QNetworkReplyImpl::NetworkError code, c
emit q->error(code);
}
-void QNetworkReplyHttpImplPrivate::metaDataChanged()
+void QNetworkReplyHttpImplPrivate::_q_metaDataChanged()
{
// FIXME merge this with replyDownloadMetaData(); ?
diff --git a/src/network/access/qnetworkreplyhttpimpl_p.h b/src/network/access/qnetworkreplyhttpimpl_p.h
index baff7a943c..77d9c5a368 100644
--- a/src/network/access/qnetworkreplyhttpimpl_p.h
+++ b/src/network/access/qnetworkreplyhttpimpl_p.h
@@ -124,6 +124,7 @@ public:
Q_PRIVATE_SLOT(d_func(), void uploadByteDeviceReadyReadSlot())
Q_PRIVATE_SLOT(d_func(), void emitReplyUploadProgress(qint64, qint64))
Q_PRIVATE_SLOT(d_func(), void _q_cacheSaveDeviceAboutToClose())
+ Q_PRIVATE_SLOT(d_func(), void _q_metaDataChanged())
#ifndef QT_NO_SSL
@@ -175,7 +176,7 @@ public:
void finished();
void error(QNetworkReply::NetworkError code, const QString &errorString);
void _q_error(QNetworkReply::NetworkError code, const QString &errorString);
- void metaDataChanged();
+ void _q_metaDataChanged();
void checkForRedirect(const int statusCode);
diff --git a/src/network/access/qnetworkreplynsurlconnectionimpl.mm b/src/network/access/qnetworkreplynsurlconnectionimpl.mm
index f93f18357a..327dbd4ea7 100644
--- a/src/network/access/qnetworkreplynsurlconnectionimpl.mm
+++ b/src/network/access/qnetworkreplynsurlconnectionimpl.mm
@@ -245,7 +245,7 @@ void QNetworkReplyNSURLConnectionImpl::readyReadOutgoingData()
Q_UNUSED(connection)
QNetworkReply::NetworkError qtError = QNetworkReply::UnknownNetworkError;
- if ([error domain] == NSURLErrorDomain) {
+ if ([[error domain] isEqualToString:NSURLErrorDomain]) {
switch ([error code]) {
case NSURLErrorTimedOut: qtError = QNetworkReply::TimeoutError; break;
case NSURLErrorUnsupportedURL: qtError = QNetworkReply::ProtocolUnknownError; break;
@@ -260,6 +260,7 @@ void QNetworkReplyNSURLConnectionImpl::readyReadOutgoingData()
}
replyprivate->setError(qtError, QString::fromNSString([error localizedDescription]));
+ replyprivate->setFinished();
}
- (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)aResponse
diff --git a/src/network/doc/src/bearermanagement.qdoc b/src/network/doc/src/bearermanagement.qdoc
index 63022b6a6f..cec08491d6 100644
--- a/src/network/doc/src/bearermanagement.qdoc
+++ b/src/network/doc/src/bearermanagement.qdoc
@@ -248,7 +248,7 @@ determining the feature support:
\li Linux uses the \l {http://projects.gnome.org/NetworkManager}{NetworkManager}
and \l {http://connman.net/}{ConnMan} / \l {http://ofono.org/}{oFono} APIs
which support interface notifications and starting and stopping of network
- interfaces.
+ interfaces. Network Manager version 0.9 and above is supported.
\row
\li Windows\unicode{0xAE} XP
\li This platform supports interface notifications without active polling.
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp
index 85ec2012b8..f5943d657f 100644
--- a/src/network/socket/qnativesocketengine_win.cpp
+++ b/src/network/socket/qnativesocketengine_win.cpp
@@ -1140,7 +1140,7 @@ bool QNativeSocketEnginePrivate::nativeHasPendingDatagrams() const
int err = WSAGetLastError();
if (ret == SOCKET_ERROR && err != WSAEMSGSIZE) {
WS_ERROR_DEBUG(err);
- if (err == WSAECONNRESET) {
+ if (err == WSAECONNRESET || err == WSAENETRESET) {
// Discard error message to prevent QAbstractSocket from
// getting this message repeatedly after reenabling the
// notifiers.
diff --git a/src/network/ssl/qssl.cpp b/src/network/ssl/qssl.cpp
index 63c826a3d7..740131797c 100644
--- a/src/network/ssl/qssl.cpp
+++ b/src/network/ssl/qssl.cpp
@@ -119,12 +119,12 @@ QT_BEGIN_NAMESPACE
a TLS 1.0 Client Hello, enabling TLSv1_0 and SSLv3 connections.
On the server side, this will enable both SSLv3 and TLSv1_0 connections.
\value SecureProtocols The default option, using protocols known to be secure;
- currently behaves like TlsV1SslV3.
+ currently behaves similar to TlsV1Ssl3 except denying SSLv3 connections that does
+ not upgrade to TLS.
- \note most servers using SSL understand both versions (2 and 3),
- but it is recommended to use the latest version only for security
- reasons. However, SSL and TLS are not compatible with each other:
- if you get unexpected handshake failures, verify that you chose
+ \note most servers understand both SSL and TLS, but it is recommended to use
+ TLS only for security reasons. However, SSL and TLS are not compatible with
+ each other: if you get unexpected handshake failures, verify that you chose
the correct setting for your protocol.
*/
diff --git a/src/network/ssl/qsslcontext_openssl.cpp b/src/network/ssl/qsslcontext_openssl.cpp
index f4c6b21598..a2758398f4 100644
--- a/src/network/ssl/qsslcontext_openssl.cpp
+++ b/src/network/ssl/qsslcontext_openssl.cpp
@@ -139,8 +139,11 @@ init_context:
case QSsl::SslV3:
sslContext->ctx = q_SSL_CTX_new(client ? q_SSLv3_client_method() : q_SSLv3_server_method());
break;
- case QSsl::SecureProtocols: // SslV2 will be disabled below
- case QSsl::TlsV1SslV3: // SslV2 will be disabled below
+ case QSsl::SecureProtocols:
+ // SSLv2 and SSLv3 will be disabled by SSL options
+ // But we need q_SSLv23_server_method() otherwise AnyProtocol will be unable to connect on Win32.
+ case QSsl::TlsV1SslV3:
+ // SSLv2 will will be disabled by SSL options
case QSsl::AnyProtocol:
default:
sslContext->ctx = q_SSL_CTX_new(client ? q_SSLv23_client_method() : q_SSLv23_server_method());
diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp
index 1d675edbbb..84b0d9c75e 100644
--- a/src/network/ssl/qsslsocket_openssl.cpp
+++ b/src/network/ssl/qsslsocket_openssl.cpp
@@ -280,8 +280,10 @@ int q_X509Callback(int ok, X509_STORE_CTX *ctx)
long QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SslProtocol protocol, QSsl::SslOptions sslOptions)
{
long options;
- if (protocol == QSsl::TlsV1SslV3 || protocol == QSsl::SecureProtocols)
+ if (protocol == QSsl::TlsV1SslV3)
options = SSL_OP_ALL|SSL_OP_NO_SSLv2;
+ else if (protocol == QSsl::SecureProtocols)
+ options = SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3;
else
options = SSL_OP_ALL;
diff --git a/src/platformsupport/eglconvenience/qeglplatformcursor.cpp b/src/platformsupport/eglconvenience/qeglplatformcursor.cpp
index df6e6cd50c..cf41bd2f1b 100644
--- a/src/platformsupport/eglconvenience/qeglplatformcursor.cpp
+++ b/src/platformsupport/eglconvenience/qeglplatformcursor.cpp
@@ -267,7 +267,7 @@ void QEGLPlatformCursorUpdater::update(const QPoint &pos, const QRegion &rgn)
{
m_active = false;
QWindowSystemInterface::handleExposeEvent(m_screen->topLevelAt(pos), rgn);
- QWindowSystemInterface::flushWindowSystemEvents();
+ QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
}
void QEGLPlatformCursorUpdater::scheduleUpdate(const QPoint &pos, const QRegion &rgn)
diff --git a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp
index fb9ec0f2e4..43903acfe1 100644
--- a/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp
+++ b/src/platformsupport/fontdatabases/basic/qbasicfontdatabase.cpp
@@ -277,10 +277,16 @@ QStringList QBasicFontDatabase::addTTFile(const QByteArray &fontData, const QByt
if (os2->usWeightClass == 0)
;
+ else if (os2->usWeightClass < 150)
+ weight = qt_thinFontWeight;
+ else if (os2->usWeightClass < 250)
+ weight = qt_extralightFontWeight;
else if (os2->usWeightClass < 350)
weight = QFont::Light;
else if (os2->usWeightClass < 450)
weight = QFont::Normal;
+ else if (os2->usWeightClass < 550)
+ weight = qt_mediumFontWeight;
else if (os2->usWeightClass < 650)
weight = QFont::DemiBold;
else if (os2->usWeightClass < 750)
@@ -290,10 +296,16 @@ QStringList QBasicFontDatabase::addTTFile(const QByteArray &fontData, const QByt
if (os2->panose[2] >= 2) {
int w = os2->panose[2];
- if (w <= 3)
+ if (w <= 1)
+ weight = qt_thinFontWeight;
+ else if (w <= 2)
+ weight = qt_extralightFontWeight;
+ else if (w <= 3)
weight = QFont::Light;
else if (w <= 5)
weight = QFont::Normal;
+ else if (w <= 6)
+ weight = qt_mediumFontWeight;
else if (w <= 7)
weight = QFont::DemiBold;
else if (w <= 8)
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
index fc289579ea..9f2ff10a21 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
@@ -294,10 +294,16 @@ static void getFontDescription(CTFontDescriptorRef font, FontDescription *fd)
fd->weight = QFont::Bold;
else if (normalizedWeight >= 0.3)
fd->weight = QFont::DemiBold;
+ else if (normalizedWeight >= 0.2)
+ fd->weight = qt_mediumFontWeight;
else if (normalizedWeight == 0.0)
fd->weight = QFont::Normal;
else if (normalizedWeight <= -0.4)
fd->weight = QFont::Light;
+ else if (normalizedWeight <= -0.6)
+ fd->weight = qt_extralightFontWeight;
+ else if (normalizedWeight <= -0.8)
+ fd->weight = qt_thinFontWeight;
}
}
if (CFNumberRef italic = (CFNumberRef) CFDictionaryGetValue(styles, kCTFontSlantTrait)) {
diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
index 5685bc9ea6..207b525664 100644
--- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
+++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
@@ -577,9 +577,10 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition
cgflags);
Q_ASSERT(ctx);
CGContextSetFontSize(ctx, fontDef.pixelSize);
- CGContextSetShouldAntialias(ctx, (aa || fontDef.pointSize > antialiasingThreshold)
- && !(fontDef.styleStrategy & QFont::NoAntialias));
- CGContextSetShouldSmoothFonts(ctx, aa);
+ const bool antialias = (aa || fontDef.pointSize > antialiasingThreshold) && !(fontDef.styleStrategy & QFont::NoAntialias);
+ CGContextSetShouldAntialias(ctx, antialias);
+ const bool smoothing = antialias && !(fontDef.styleStrategy & QFont::NoSubpixelAntialias);
+ CGContextSetShouldSmoothFonts(ctx, smoothing);
CGAffineTransform cgMatrix = CGAffineTransformIdentity;
diff --git a/src/plugins/bearer/android/src/qandroidbearerengine.cpp b/src/plugins/bearer/android/src/qandroidbearerengine.cpp
index 2d047ba612..64c1a20ecc 100644
--- a/src/plugins/bearer/android/src/qandroidbearerengine.cpp
+++ b/src/plugins/bearer/android/src/qandroidbearerengine.cpp
@@ -166,10 +166,7 @@ QNetworkSession::State QAndroidBearerEngine::sessionStateForId(const QString &id
const QMutexLocker configLocker(&ptr->mutex);
// Don't re-order...
if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
- return (m_connectivityManager->isActiveNetworkMetered()
- || m_connectivityManager->getActiveNetworkInfo().isRoaming())
- ? QNetworkSession::Roaming
- : QNetworkSession::Connected;
+ return QNetworkSession::Connected;
} else if ((ptr->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) {
return QNetworkSession::Disconnected;
} else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) {
@@ -267,6 +264,10 @@ void QAndroidBearerEngine::updateConfigurations()
QMutexLocker locker(&mutex);
QStringList oldKeys = accessPointConfigurations.keys();
+ QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces();
+ if (interfaces.isEmpty())
+ interfaces = QNetworkInterface::allInterfaces();
+
// Create a configuration for each of the main types (WiFi, Mobile, Bluetooth, WiMax, Ethernet)
foreach (const AndroidNetworkInfo &netInfo, m_connectivityManager->getAllNetworkInfo()) {
@@ -279,14 +280,13 @@ void QAndroidBearerEngine::updateConfigurations()
QNetworkConfiguration::BearerType bearerType = getBearerType(netInfo);
- QNetworkConfiguration::StateFlag state;
QString interfaceName;
+ QNetworkConfiguration::StateFlag state = QNetworkConfiguration::Defined;
if (netInfo.isAvailable()) {
if (netInfo.isConnected()) {
- state = QNetworkConfiguration::Active;
// Attempt to map an interface to this configuration
- const QList<QNetworkInterface> &interfaces = QNetworkInterface::allInterfaces();
- foreach (const QNetworkInterface &interface, interfaces) {
+ while (!interfaces.isEmpty()) {
+ QNetworkInterface interface = interfaces.takeFirst();
// ignore loopback interface
if (!interface.isValid())
continue;
@@ -297,22 +297,17 @@ void QAndroidBearerEngine::updateConfigurations()
// look for an active interface...
if (interface.flags() & QNetworkInterface::IsRunning
&& !interface.addressEntries().isEmpty()) {
- interfaceName = interface.humanReadableName();
- if (interfaceName.isEmpty())
- interfaceName = interface.name();
+ state = QNetworkConfiguration::Active;
+ interfaceName = interface.name();
+ break;
}
}
- } else if (netInfo.isConnectedOrConnecting()) {
- state = QNetworkConfiguration::Undefined;
- } else {
- state = QNetworkConfiguration::Discovered;
}
- } else {
- state = QNetworkConfiguration::Defined;
}
- const uint identifier = qHash(QLatin1String("android:") + name);
- const QString id = QString::number(identifier);
+ const QString key = QString(QLatin1String("android:%1:%2")).arg(name).arg(interfaceName);
+ const QString id = QString::number(qHash(key));
+ m_configurationInterface[id] = interfaceName;
oldKeys.removeAll(id);
if (accessPointConfigurations.contains(id)) {
@@ -347,12 +342,6 @@ void QAndroidBearerEngine::updateConfigurations()
ptr->state = state;
changed = true;
}
-
- QString &oldIfName = m_configurationInterface[id];
- if (oldIfName != interfaceName) {
- oldIfName = interfaceName;
- changed = true;
- }
} // Unlock configuration
if (changed) {
@@ -369,8 +358,6 @@ void QAndroidBearerEngine::updateConfigurations()
ptr->type = QNetworkConfiguration::InternetAccessPoint;
ptr->bearerType = bearerType;
accessPointConfigurations.insert(id, ptr);
- m_configurationInterface.insert(id, interfaceName);
-
locker.unlock();
Q_EMIT configurationAdded(ptr);
locker.relock();
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.h b/src/plugins/bearer/corewlan/qcorewlanengine.h
index 930bde40b3..50bdab0ea6 100644
--- a/src/plugins/bearer/corewlan/qcorewlanengine.h
+++ b/src/plugins/bearer/corewlan/qcorewlanengine.h
@@ -83,6 +83,7 @@ public:
private Q_SLOTS:
void doRequestUpdate();
void networksChanged();
+ void checkDisconnect();
private:
bool isWifiReady(const QString &dev);
@@ -95,6 +96,7 @@ private:
QScanThread *scanThread;
quint64 getBytes(const QString &interfaceName,bool b);
+ QString disconnectedInterfaceString;
protected:
void startNetworkChangeLoop();
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm
index 65e70876f2..6f9ea91799 100644
--- a/src/plugins/bearer/corewlan/qcorewlanengine.mm
+++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the plugins of the Qt Toolkit.
@@ -62,8 +62,6 @@ extern "C" { // Otherwise it won't find CWKeychain* symbols at link time
#include <net/if.h>
#include <ifaddrs.h>
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_7, __IPHONE_NA)
-
@interface QT_MANGLE_NAMESPACE(QNSListener) : NSObject
{
NSNotificationCenter *notificationCenter;
@@ -544,20 +542,44 @@ void QCoreWlanEngine::disconnectFromId(const QString &id)
QMutexLocker locker(&mutex);
QString interfaceString = getInterfaceFromId(id);
+ if (interfaceString.isEmpty()) {
+ locker.unlock();
+ emit connectionError(id, DisconnectionError);
+ return;
+ }
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
CWInterface *wifiInterface =
[CWInterface interfaceWithName: QCFString::toNSString(interfaceString)];
+ disconnectedInterfaceString = interfaceString;
[wifiInterface disassociate];
- if (wifiInterface.serviceActive) {
- locker.unlock();
- emit connectionError(id, DisconnectionError);
- locker.relock();
- }
+
+ QTimer::singleShot(1000, this,SLOT(checkDisconnect()));
[autoreleasepool release];
}
+void QCoreWlanEngine::checkDisconnect()
+{
+ QMutexLocker locker(&mutex);
+ if (!disconnectedInterfaceString.isEmpty()) {
+ NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
+
+ CWInterface *wifiInterface =
+ [CWInterface interfaceWithName: QCFString::toNSString(disconnectedInterfaceString)];
+
+ const QString networkSsid = QCFString::toQString([wifiInterface ssid]);
+ if (!networkSsid.isEmpty()) {
+ const QString id = QString::number(qHash(QLatin1String("corewlan:") + networkSsid));
+ locker.unlock();
+ emit connectionError(id, DisconnectionError);
+ locker.relock();
+ }
+ [autoreleasepool release];
+ disconnectedInterfaceString.clear();
+ }
+}
+
void QCoreWlanEngine::requestUpdate()
{
scanThread->getUserConfigurations();
@@ -862,7 +884,3 @@ quint64 QCoreWlanEngine::getBytes(const QString &interfaceName, bool b)
}
QT_END_NAMESPACE
-
-#else // QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE
-#include "qcorewlanengine_10_6.mm"
-#endif
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine_10_6.mm b/src/plugins/bearer/corewlan/qcorewlanengine_10_6.mm
deleted file mode 100644
index 6cf614cb30..0000000000
--- a/src/plugins/bearer/corewlan/qcorewlanengine_10_6.mm
+++ /dev/null
@@ -1,922 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/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 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <SystemConfiguration/SCNetworkConfiguration.h>
-
-@interface QT_MANGLE_NAMESPACE(QNSListener) : NSObject
-{
- NSNotificationCenter *notificationCenter;
- CWInterface *currentInterface;
- QCoreWlanEngine *engine;
- NSLock *locker;
-}
-- (void)notificationHandler:(NSNotification *)notification;
-- (void)remove;
-- (void)setEngine:(QCoreWlanEngine *)coreEngine;
-- (QCoreWlanEngine *)engine;
-- (void)dealloc;
-
-@property (assign) QCoreWlanEngine* engine;
-
-@end
-
-@implementation QT_MANGLE_NAMESPACE(QNSListener)
-
-- (id) init
-{
- [locker lock];
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
- notificationCenter = [NSNotificationCenter defaultCenter];
- currentInterface = [CWInterface interfaceWithName:nil];
- [notificationCenter addObserver:self selector:@selector(notificationHandler:) name:kCWPowerDidChangeNotification object:nil];
- [locker unlock];
- [autoreleasepool release];
- return self;
-}
-
--(void)dealloc
-{
- [super dealloc];
-}
-
--(void)setEngine:(QCoreWlanEngine *)coreEngine
-{
- [locker lock];
- if(!engine)
- engine = coreEngine;
- [locker unlock];
-}
-
--(QCoreWlanEngine *)engine
-{
- return engine;
-}
-
--(void)remove
-{
- [locker lock];
- [notificationCenter removeObserver:self];
- [locker unlock];
-}
-
-- (void)notificationHandler:(NSNotification *)notification
-{
- Q_UNUSED(notification);
- engine->requestUpdate();
-}
-@end
-
-static QT_MANGLE_NAMESPACE(QNSListener) *listener = 0;
-
-QT_BEGIN_NAMESPACE
-
-void networkChangeCallback(SCDynamicStoreRef/* store*/, CFArrayRef changedKeys, void *info)
-{
- for ( long i = 0; i < CFArrayGetCount(changedKeys); i++) {
-
- QString changed = QCFString::toQString((CFStringRef)CFArrayGetValueAtIndex(changedKeys, i));
- if( changed.contains("/Network/Global/IPv4")) {
- QCoreWlanEngine* wlanEngine = static_cast<QCoreWlanEngine*>(info);
- wlanEngine->requestUpdate();
- }
- }
- return;
-}
-
-
-QScanThread::QScanThread(QObject *parent)
- :QThread(parent)
-{
-}
-
-QScanThread::~QScanThread()
-{
-}
-
-void QScanThread::quit()
-{
- wait();
-}
-
-void QScanThread::run()
-{
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
- QStringList found;
- mutex.lock();
- CWInterface *currentInterface = [CWInterface interfaceWithName: QCFString::toNSString(interfaceName)];
- mutex.unlock();
-
- if([currentInterface power]) {
- NSError *err = nil;
- NSDictionary *parametersDict = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithBool:YES], kCWScanKeyMerge,
- [NSNumber numberWithInt:kCWScanTypeFast], kCWScanKeyScanType,
- [NSNumber numberWithInteger:100], kCWScanKeyRestTime, nil];
-
- NSArray* apArray = [currentInterface scanForNetworksWithParameters:parametersDict error:&err];
- CWNetwork *apNetwork;
-
- if (!err) {
-
- for(uint row=0; row < [apArray count]; row++ ) {
- apNetwork = [apArray objectAtIndex:row];
-
- const QString networkSsid = QCFString::toQString([apNetwork ssid]);
- const QString id = QString::number(qHash(QLatin1String("corewlan:") + networkSsid));
- found.append(id);
-
- QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined;
- bool known = isKnownSsid(networkSsid);
- if( [currentInterface.interfaceState intValue] == kCWInterfaceStateRunning) {
- if( networkSsid == QCFString::toQString( [currentInterface ssid])) {
- state = QNetworkConfiguration::Active;
- }
- }
- if(state == QNetworkConfiguration::Undefined) {
- if(known) {
- state = QNetworkConfiguration::Discovered;
- } else {
- state = QNetworkConfiguration::Undefined;
- }
- }
- QNetworkConfiguration::Purpose purpose = QNetworkConfiguration::UnknownPurpose;
- if([[apNetwork securityMode] intValue] == kCWSecurityModeOpen) {
- purpose = QNetworkConfiguration::PublicPurpose;
- } else {
- purpose = QNetworkConfiguration::PrivatePurpose;
- }
-
- found.append(foundNetwork(id, networkSsid, state, interfaceName, purpose));
-
- }
- }
- }
- // add known configurations that are not around.
- QMapIterator<QString, QMap<QString,QString> > i(userProfiles);
- while (i.hasNext()) {
- i.next();
-
- QString networkName = i.key();
- const QString id = QString::number(qHash(QLatin1String("corewlan:") + networkName));
-
- if(!found.contains(id)) {
- QString networkSsid = getSsidFromNetworkName(networkName);
- const QString ssidId = QString::number(qHash(QLatin1String("corewlan:") + networkSsid));
- QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined;
- QString interfaceName;
- QMapIterator<QString, QString> ij(i.value());
- while (ij.hasNext()) {
- ij.next();
- interfaceName = ij.value();
- }
-
- if( [currentInterface.interfaceState intValue] == kCWInterfaceStateRunning) {
- if( networkSsid == QCFString::toQString([currentInterface ssid])) {
- state = QNetworkConfiguration::Active;
- }
- }
- if(state == QNetworkConfiguration::Undefined) {
- if( userProfiles.contains(networkName)
- && found.contains(ssidId)) {
- state = QNetworkConfiguration::Discovered;
- }
- }
-
- if(state == QNetworkConfiguration::Undefined) {
- state = QNetworkConfiguration::Defined;
- }
-
- found.append(foundNetwork(id, networkName, state, interfaceName, QNetworkConfiguration::UnknownPurpose));
- }
- }
- emit networksChanged();
- [autoreleasepool release];
-}
-
-QStringList QScanThread::foundNetwork(const QString &id, const QString &name, const QNetworkConfiguration::StateFlags state, const QString &interfaceName, const QNetworkConfiguration::Purpose purpose)
-{
- QStringList found;
- QMutexLocker locker(&mutex);
- QNetworkConfigurationPrivate *ptr = new QNetworkConfigurationPrivate;
-
- ptr->name = name;
- ptr->isValid = true;
- ptr->id = id;
- ptr->state = state;
- ptr->type = QNetworkConfiguration::InternetAccessPoint;
- ptr->bearerType = QNetworkConfiguration::BearerWLAN;
- ptr->purpose = purpose;
-
- fetchedConfigurations.append( ptr);
- configurationInterface.insert(ptr->id, interfaceName);
-
- locker.unlock();
- locker.relock();
- found.append(id);
- return found;
-}
-
-QList<QNetworkConfigurationPrivate *> QScanThread::getConfigurations()
-{
- QMutexLocker locker(&mutex);
-
- QList<QNetworkConfigurationPrivate *> foundConfigurations = fetchedConfigurations;
- fetchedConfigurations.clear();
-
- return foundConfigurations;
-}
-
-void QScanThread::getUserConfigurations()
-{
- QMutexLocker locker(&mutex);
-
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
- userProfiles.clear();
-
- NSArray *wifiInterfaces = [CWInterface supportedInterfaces];
- for(uint row=0; row < [wifiInterfaces count]; row++ ) {
-
- CWInterface *wifiInterface = [CWInterface interfaceWithName: [wifiInterfaces objectAtIndex:row]];
- if ( ![wifiInterface power] )
- continue;
-
- NSString *nsInterfaceName = [wifiInterface name];
-// add user configured system networks
- SCDynamicStoreRef dynRef = SCDynamicStoreCreate(kCFAllocatorSystemDefault, (CFStringRef)@"Qt corewlan", nil, nil);
- NSDictionary * airportPlist = (NSDictionary *)SCDynamicStoreCopyValue(dynRef, (CFStringRef)[NSString stringWithFormat:@"Setup:/Network/Interface/%@/AirPort", nsInterfaceName]);
- CFRelease(dynRef);
- if(airportPlist != nil) {
- NSDictionary *prefNetDict = [airportPlist objectForKey:@"PreferredNetworks"];
-
- NSArray *thisSsidarray = [prefNetDict valueForKey:@"SSID_STR"];
- for(NSString *ssidkey in thisSsidarray) {
- QString thisSsid = QCFString::toQString(ssidkey);
- if(!userProfiles.contains(thisSsid)) {
- QMap <QString,QString> map;
- map.insert(thisSsid, QCFString::toQString(nsInterfaceName));
- userProfiles.insert(thisSsid, map);
- }
- }
- CFRelease(airportPlist);
- }
-
- // 802.1X user profiles
- QString userProfilePath = QDir::homePath() + "/Library/Preferences/com.apple.eap.profiles.plist";
- NSDictionary* eapDict = [[[NSDictionary alloc] initWithContentsOfFile: QCFString::toNSString(userProfilePath)] autorelease];
- if(eapDict != nil) {
- NSString *profileStr= @"Profiles";
- NSString *nameStr = @"UserDefinedName";
- NSString *networkSsidStr = @"Wireless Network";
- for (id profileKey in eapDict) {
- if ([profileStr isEqualToString:profileKey]) {
- NSDictionary *itemDict = [eapDict objectForKey:profileKey];
- for (id itemKey in itemDict) {
-
- NSInteger dictSize = [itemKey count];
- id objects[dictSize];
- id keys[dictSize];
-
- [itemKey getObjects:objects andKeys:keys];
- QString networkName;
- QString ssid;
- for(int i = 0; i < dictSize; i++) {
- if([nameStr isEqualToString:keys[i]]) {
- networkName = QCFString::toQString(objects[i]);
- }
- if([networkSsidStr isEqualToString:keys[i]]) {
- ssid = QCFString::toQString(objects[i]);
- }
- if(!userProfiles.contains(networkName)
- && !ssid.isEmpty()) {
- QMap<QString,QString> map;
- map.insert(ssid, QCFString::toQString(nsInterfaceName));
- userProfiles.insert(networkName, map);
- }
- }
- }
- }
- }
- }
- }
- [autoreleasepool release];
-}
-
-QString QScanThread::getSsidFromNetworkName(const QString &name)
-{
- QMutexLocker locker(&mutex);
-
- QMapIterator<QString, QMap<QString,QString> > i(userProfiles);
- while (i.hasNext()) {
- i.next();
- QMap<QString,QString> map = i.value();
- QMapIterator<QString, QString> ij(i.value());
- while (ij.hasNext()) {
- ij.next();
- const QString networkNameHash = QString::number(qHash(QLatin1String("corewlan:") +i.key()));
- if(name == i.key() || name == networkNameHash) {
- return ij.key();
- }
- }
- }
- return QString();
-}
-
-QString QScanThread::getNetworkNameFromSsid(const QString &ssid)
-{
- QMutexLocker locker(&mutex);
-
- QMapIterator<QString, QMap<QString,QString> > i(userProfiles);
- while (i.hasNext()) {
- i.next();
- QMap<QString,QString> map = i.value();
- QMapIterator<QString, QString> ij(i.value());
- while (ij.hasNext()) {
- ij.next();
- if(ij.key() == ssid) {
- return i.key();
- }
- }
- }
- return QString();
-}
-
-bool QScanThread::isKnownSsid(const QString &ssid)
-{
- QMutexLocker locker(&mutex);
-
- QMapIterator<QString, QMap<QString,QString> > i(userProfiles);
- while (i.hasNext()) {
- i.next();
- QMap<QString,QString> map = i.value();
- if(map.keys().contains(ssid)) {
- return true;
- }
- }
- return false;
-}
-
-
-QCoreWlanEngine::QCoreWlanEngine(QObject *parent)
-: QBearerEngineImpl(parent), scanThread(0)
-{
- scanThread = new QScanThread(this);
- connect(scanThread, SIGNAL(networksChanged()),
- this, SLOT(networksChanged()));
-}
-
-QCoreWlanEngine::~QCoreWlanEngine()
-{
- scanThread->terminate();
- scanThread->wait();
-
- while (!foundConfigurations.isEmpty())
- delete foundConfigurations.takeFirst();
- [listener remove];
- [listener release];
-}
-
-void QCoreWlanEngine::initialize()
-{
- QMutexLocker locker(&mutex);
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
-
- if([[CWInterface supportedInterfaces] count] > 0 && !listener) {
- listener = [[QT_MANGLE_NAMESPACE(QNSListener) alloc] init];
- listener.engine = this;
- hasWifi = true;
- } else {
- hasWifi = false;
- }
- storeSession = NULL;
-
- startNetworkChangeLoop();
- [autoreleasepool release];
-}
-
-
-QString QCoreWlanEngine::getInterfaceFromId(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- return scanThread->configurationInterface.value(id);
-}
-
-bool QCoreWlanEngine::hasIdentifier(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- return scanThread->configurationInterface.contains(id);
-}
-
-void QCoreWlanEngine::connectToId(const QString &id)
-{
- QMutexLocker locker(&mutex);
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
- QString interfaceString = getInterfaceFromId(id);
-
- CWInterface *wifiInterface =
- [CWInterface interfaceWithName: QCFString::toNSString(interfaceString)];
-
- if ([wifiInterface power]) {
- NSError *err = nil;
- NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:0];
-
- QString wantedSsid;
-
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
-
- const QString idHash = QString::number(qHash(QLatin1String("corewlan:") + ptr->name));
- const QString idHash2 = QString::number(qHash(QLatin1String("corewlan:") + scanThread->getNetworkNameFromSsid(ptr->name)));
-
- bool using8021X = false;
- if (idHash2 != id) {
- NSArray *array = [CW8021XProfile allUser8021XProfiles];
-
- for (NSUInteger i = 0; i < [array count]; ++i) {
- const QString networkNameHashCheck = QString::number(qHash(QLatin1String("corewlan:") + QCFString::toQString([[array objectAtIndex:i] userDefinedName])));
-
- const QString ssidHash = QString::number(qHash(QLatin1String("corewlan:") + QCFString::toQString([[array objectAtIndex:i] ssid])));
-
- if (id == networkNameHashCheck || id == ssidHash) {
- const QString thisName = scanThread->getSsidFromNetworkName(id);
- if (thisName.isEmpty())
- wantedSsid = id;
- else
- wantedSsid = thisName;
-
- [params setValue: [array objectAtIndex:i] forKey:kCWAssocKey8021XProfile];
- using8021X = true;
- break;
- }
- }
- }
-
- if (!using8021X) {
- QString wantedNetwork;
- QMapIterator<QString, QMap<QString,QString> > i(scanThread->userProfiles);
- while (i.hasNext()) {
- i.next();
- wantedNetwork = i.key();
- const QString networkNameHash = QString::number(qHash(QLatin1String("corewlan:") + wantedNetwork));
- if (id == networkNameHash) {
- wantedSsid = scanThread->getSsidFromNetworkName(wantedNetwork);
- break;
- }
- }
- }
- NSDictionary *scanParameters = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithBool:YES], kCWScanKeyMerge,
- [NSNumber numberWithInt:kCWScanTypeFast], kCWScanKeyScanType,
- [NSNumber numberWithInteger:100], kCWScanKeyRestTime,
- QCFString::toNSString(wantedSsid), kCWScanKeySSID,
- nil];
-
- NSArray *scanArray = [wifiInterface scanForNetworksWithParameters:scanParameters error:&err];
-
- if(!err) {
- for(uint row=0; row < [scanArray count]; row++ ) {
- CWNetwork *apNetwork = [scanArray objectAtIndex:row];
-
- if(wantedSsid == QCFString::toQString([apNetwork ssid])) {
-
- if(!using8021X) {
- SecKeychainAttribute attributes[3];
-
- NSString *account = [apNetwork ssid];
- NSString *keyKind = @"AirPort network password";
- NSString *keyName = account;
-
- attributes[0].tag = kSecAccountItemAttr;
- attributes[0].data = (void *)[account UTF8String];
- attributes[0].length = [account length];
-
- attributes[1].tag = kSecDescriptionItemAttr;
- attributes[1].data = (void *)[keyKind UTF8String];
- attributes[1].length = [keyKind length];
-
- attributes[2].tag = kSecLabelItemAttr;
- attributes[2].data = (void *)[keyName UTF8String];
- attributes[2].length = [keyName length];
-
- SecKeychainAttributeList attributeList = {3,attributes};
-
- SecKeychainSearchRef searchRef;
- SecKeychainSearchCreateFromAttributes(NULL, kSecGenericPasswordItemClass, &attributeList, &searchRef);
-
- NSString *password = @"";
- SecKeychainItemRef searchItem;
-
- if (SecKeychainSearchCopyNext(searchRef, &searchItem) == noErr) {
- UInt32 realPasswordLength;
- SecKeychainAttribute attributesW[8];
- attributesW[0].tag = kSecAccountItemAttr;
- SecKeychainAttributeList listW = {1,attributesW};
- char *realPassword;
- OSStatus status = SecKeychainItemCopyContent(searchItem, NULL, &listW, &realPasswordLength,(void **)&realPassword);
-
- if (status == noErr) {
- if (realPassword != NULL) {
-
- QByteArray pBuf;
- pBuf.resize(realPasswordLength);
- pBuf.prepend(realPassword);
- pBuf.insert(realPasswordLength,'\0');
-
- password = [NSString stringWithUTF8String:pBuf];
- }
- SecKeychainItemFreeContent(&listW, realPassword);
- }
-
- CFRelease(searchItem);
- } else {
- qDebug() << "SecKeychainSearchCopyNext error";
- }
- [params setValue: password forKey: kCWAssocKeyPassphrase];
- } // end using8021X
-
-
- bool result = [wifiInterface associateToNetwork: apNetwork parameters:[NSDictionary dictionaryWithDictionary:params] error:&err];
-
- if(!err) {
- if(!result) {
- emit connectionError(id, ConnectError);
- } else {
- return;
- }
- } else {
- qDebug() <<"associate ERROR"<< QCFString::toQString([err localizedDescription ]);
- }
- }
- } //end scan network
- } else {
- qDebug() <<"scan ERROR"<< QCFString::toQString([err localizedDescription ]);
- }
- emit connectionError(id, InterfaceLookupError);
- }
-
- locker.unlock();
- emit connectionError(id, InterfaceLookupError);
- [autoreleasepool release];
-}
-
-void QCoreWlanEngine::disconnectFromId(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- QString interfaceString = getInterfaceFromId(id);
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
-
- CWInterface *wifiInterface =
- [CWInterface interfaceWithName: QCFString::toNSString(interfaceString)];
-
- [wifiInterface disassociate];
- if ([[wifiInterface interfaceState]intValue] != kCWInterfaceStateInactive) {
- locker.unlock();
- emit connectionError(id, DisconnectionError);
- locker.relock();
- }
- [autoreleasepool release];
-}
-
-void QCoreWlanEngine::requestUpdate()
-{
- scanThread->getUserConfigurations();
- doRequestUpdate();
-}
-
-void QCoreWlanEngine::doRequestUpdate()
-{
- QMutexLocker locker(&mutex);
-
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
-
- NSArray *wifiInterfaces = [CWInterface supportedInterfaces];
- for (uint row = 0; row < [wifiInterfaces count]; ++row) {
- scanThread->interfaceName = QCFString::toQString([wifiInterfaces objectAtIndex:row]);
- scanThread->start();
- }
- locker.unlock();
- if ([wifiInterfaces count] == 0)
- networksChanged();
- [autoreleasepool release];
-}
-
-bool QCoreWlanEngine::isWifiReady(const QString &wifiDeviceName)
-{
- QMutexLocker locker(&mutex);
- bool haswifi = false;
- if(hasWifi) {
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
- CWInterface *defaultInterface = [CWInterface interfaceWithName: QCFString::toNSString(wifiDeviceName)];
- if([defaultInterface power]) {
- haswifi = true;
- }
- [autoreleasepool release];
- }
- return haswifi;
-}
-
-
-QNetworkSession::State QCoreWlanEngine::sessionStateForId(const QString &id)
-{
- QMutexLocker locker(&mutex);
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
-
- if (!ptr)
- return QNetworkSession::Invalid;
-
- if (!ptr->isValid) {
- return QNetworkSession::Invalid;
- } else if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
- return QNetworkSession::Connected;
- } else if ((ptr->state & QNetworkConfiguration::Discovered) ==
- QNetworkConfiguration::Discovered) {
- return QNetworkSession::Disconnected;
- } else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) {
- return QNetworkSession::NotAvailable;
- } else if ((ptr->state & QNetworkConfiguration::Undefined) ==
- QNetworkConfiguration::Undefined) {
- return QNetworkSession::NotAvailable;
- }
-
- return QNetworkSession::Invalid;
-}
-
-QNetworkConfigurationManager::Capabilities QCoreWlanEngine::capabilities() const
-{
- return QNetworkConfigurationManager::ForcedRoaming;
-}
-
-void QCoreWlanEngine::startNetworkChangeLoop()
-{
-
- SCDynamicStoreContext dynStoreContext = { 0, this/*(void *)storeSession*/, NULL, NULL, NULL };
- storeSession = SCDynamicStoreCreate(NULL,
- CFSTR("networkChangeCallback"),
- networkChangeCallback,
- &dynStoreContext);
- if (!storeSession ) {
- qWarning() << "could not open dynamic store: error:" << SCErrorString(SCError());
- return;
- }
-
- CFMutableArrayRef notificationKeys;
- notificationKeys = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
- CFMutableArrayRef patternsArray;
- patternsArray = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
-
- CFStringRef storeKey;
- storeKey = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL,
- kSCDynamicStoreDomainState,
- kSCEntNetIPv4);
- CFArrayAppendValue(notificationKeys, storeKey);
- CFRelease(storeKey);
-
- storeKey = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL,
- kSCDynamicStoreDomainState,
- kSCCompAnyRegex,
- kSCEntNetIPv4);
- CFArrayAppendValue(patternsArray, storeKey);
- CFRelease(storeKey);
-
- if (!SCDynamicStoreSetNotificationKeys(storeSession , notificationKeys, patternsArray)) {
- qWarning() << "register notification error:"<< SCErrorString(SCError());
- CFRelease(storeSession );
- CFRelease(notificationKeys);
- CFRelease(patternsArray);
- return;
- }
- CFRelease(notificationKeys);
- CFRelease(patternsArray);
-
- runloopSource = SCDynamicStoreCreateRunLoopSource(NULL, storeSession , 0);
- if (!runloopSource) {
- qWarning() << "runloop source error:"<< SCErrorString(SCError());
- CFRelease(storeSession );
- return;
- }
-
- CFRunLoopAddSource(CFRunLoopGetCurrent(), runloopSource, kCFRunLoopDefaultMode);
- return;
-}
-
-QNetworkSessionPrivate *QCoreWlanEngine::createSessionBackend()
-{
- return new QNetworkSessionPrivateImpl;
-}
-
-QNetworkConfigurationPrivatePointer QCoreWlanEngine::defaultConfiguration()
-{
- return QNetworkConfigurationPrivatePointer();
-}
-
-bool QCoreWlanEngine::requiresPolling() const
-{
- return true;
-}
-
-void QCoreWlanEngine::networksChanged()
-{
- QMutexLocker locker(&mutex);
-
- QStringList previous = accessPointConfigurations.keys();
-
- QList<QNetworkConfigurationPrivate *> foundConfigurations = scanThread->getConfigurations();
- while (!foundConfigurations.isEmpty()) {
- QNetworkConfigurationPrivate *cpPriv = foundConfigurations.takeFirst();
-
- previous.removeAll(cpPriv->id);
-
- if (accessPointConfigurations.contains(cpPriv->id)) {
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(cpPriv->id);
-
- bool changed = false;
-
- ptr->mutex.lock();
-
- if (ptr->isValid != cpPriv->isValid) {
- ptr->isValid = cpPriv->isValid;
- changed = true;
- }
-
- if (ptr->name != cpPriv->name) {
- ptr->name = cpPriv->name;
- changed = true;
- }
-
- if (ptr->bearerType != cpPriv->bearerType) {
- ptr->bearerType = cpPriv->bearerType;
- changed = true;
- }
-
- if (ptr->state != cpPriv->state) {
- ptr->state = cpPriv->state;
- changed = true;
- }
-
- ptr->mutex.unlock();
-
- if (changed) {
- locker.unlock();
- emit configurationChanged(ptr);
- locker.relock();
- }
-
- delete cpPriv;
- } else {
- QNetworkConfigurationPrivatePointer ptr(cpPriv);
-
- accessPointConfigurations.insert(ptr->id, ptr);
-
- locker.unlock();
- emit configurationAdded(ptr);
- locker.relock();
- }
- }
-
- while (!previous.isEmpty()) {
- QNetworkConfigurationPrivatePointer ptr =
- accessPointConfigurations.take(previous.takeFirst());
-
- locker.unlock();
- emit configurationRemoved(ptr);
- locker.relock();
- }
-
- locker.unlock();
- emit updateCompleted();
-
-}
-
-quint64 QCoreWlanEngine::bytesWritten(const QString &id)
-{
- QMutexLocker locker(&mutex);
- const QString interfaceStr = getInterfaceFromId(id);
- return getBytes(interfaceStr,false);
-}
-
-quint64 QCoreWlanEngine::bytesReceived(const QString &id)
-{
- QMutexLocker locker(&mutex);
- const QString interfaceStr = getInterfaceFromId(id);
- return getBytes(interfaceStr,true);
-}
-
-quint64 QCoreWlanEngine::startTime(const QString &identifier)
-{
- QMutexLocker locker(&mutex);
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
- quint64 timestamp = 0;
-
- NSString *filePath = @"/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist";
- NSDictionary* plistDict = [[[NSDictionary alloc] initWithContentsOfFile:filePath] autorelease];
- if(plistDict == nil)
- return timestamp;
- NSString *input = @"KnownNetworks";
- NSString *timeStampStr = @"_timeStamp";
-
- NSString *ssidStr = @"SSID_STR";
-
- for (id key in plistDict) {
- if ([input isEqualToString:key]) {
-
- NSDictionary *knownNetworksDict = [plistDict objectForKey:key];
- if(knownNetworksDict == nil)
- return timestamp;
- for (id networkKey in knownNetworksDict) {
- bool isFound = false;
- NSDictionary *itemDict = [knownNetworksDict objectForKey:networkKey];
- if(itemDict == nil)
- return timestamp;
- NSInteger dictSize = [itemDict count];
- id objects[dictSize];
- id keys[dictSize];
-
- [itemDict getObjects:objects andKeys:keys];
- bool ok = false;
- for(int i = 0; i < dictSize; i++) {
- if([ssidStr isEqualToString:keys[i]]) {
- const QString ident = QString::number(qHash(QLatin1String("corewlan:") + QCFString::toQString(objects[i])));
- if(ident == identifier) {
- ok = true;
- }
- }
- if(ok && [timeStampStr isEqualToString:keys[i]]) {
- timestamp = (quint64)[objects[i] timeIntervalSince1970];
- isFound = true;
- break;
- }
- }
- if(isFound)
- break;
- }
- }
- }
- [autoreleasepool release];
- return timestamp;
-}
-
-quint64 QCoreWlanEngine::getBytes(const QString &interfaceName, bool b)
-{
- struct ifaddrs *ifAddressList, *ifAddress;
- struct if_data *if_data;
-
- quint64 bytes = 0;
- ifAddressList = nil;
- if(getifaddrs(&ifAddressList) == 0) {
- for(ifAddress = ifAddressList; ifAddress; ifAddress = ifAddress->ifa_next) {
- if(interfaceName == ifAddress->ifa_name) {
- if_data = (struct if_data*)ifAddress->ifa_data;
- if(b) {
- bytes = if_data->ifi_ibytes;
- break;
- } else {
- bytes = if_data->ifi_obytes;
- break;
- }
- }
- }
- freeifaddrs(ifAddressList);
- }
- return bytes;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
index 08a0bb4c63..5f49ea0b6d 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
@@ -55,25 +55,21 @@ QT_BEGIN_NAMESPACE
QNetworkManagerEngine::QNetworkManagerEngine(QObject *parent)
: QBearerEngineImpl(parent),
- interface(new QNetworkManagerInterface(this)),
- systemSettings(new QNetworkManagerSettings(NM_DBUS_SERVICE_SYSTEM_SETTINGS, this)),
- userSettings(new QNetworkManagerSettings(NM_DBUS_SERVICE_USER_SETTINGS, this))
+ managerInterface(new QNetworkManagerInterface(this)),
+ systemSettings(new QNetworkManagerSettings(NM_DBUS_SERVICE, this)),
+ userSettings(new QNetworkManagerSettings(NM_DBUS_SERVICE, this))
{
- if (!interface->isValid())
+ if (!managerInterface->isValid())
return;
- interface->setConnections();
- connect(interface, SIGNAL(deviceAdded(QDBusObjectPath)),
+ managerInterface->setConnections();
+ connect(managerInterface, SIGNAL(deviceAdded(QDBusObjectPath)),
this, SLOT(deviceAdded(QDBusObjectPath)));
- connect(interface, SIGNAL(deviceRemoved(QDBusObjectPath)),
+ connect(managerInterface, SIGNAL(deviceRemoved(QDBusObjectPath)),
this, SLOT(deviceRemoved(QDBusObjectPath)));
-#if 0
- connect(interface, SIGNAL(stateChanged(QString,quint32)),
- this, SIGNAL(configurationsChanged()));
-#endif
- connect(interface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)),
+ connect(managerInterface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)),
this, SLOT(activationFinished(QDBusPendingCallWatcher*)));
- connect(interface, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)),
+ connect(managerInterface, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)),
this, SLOT(interfacePropertiesChanged(QString,QMap<QString,QVariant>)));
qDBusRegisterMetaType<QNmSettingsMap>();
@@ -100,52 +96,56 @@ void QNetworkManagerEngine::initialize()
QMutexLocker locker(&mutex);
// Get current list of access points.
- foreach (const QDBusObjectPath &devicePath, interface->getDevices()) {
+ foreach (const QDBusObjectPath &devicePath, managerInterface->getDevices()) {
locker.unlock();
- deviceAdded(devicePath);
+ deviceAdded(devicePath); //add all accesspoints
locker.relock();
}
// Get connections.
+
foreach (const QDBusObjectPath &settingsPath, systemSettings->listConnections()) {
locker.unlock();
- newConnection(settingsPath, systemSettings);
+ if (!hasIdentifier(settingsPath.path()))
+ newConnection(settingsPath, systemSettings); //add system connection configs
locker.relock();
}
+
foreach (const QDBusObjectPath &settingsPath, userSettings->listConnections()) {
locker.unlock();
- newConnection(settingsPath, userSettings);
+ if (!hasIdentifier(settingsPath.path()))
+ newConnection(settingsPath, userSettings);
locker.relock();
}
// Get active connections.
- foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
+ foreach (const QDBusObjectPath &acPath, managerInterface->activeConnections()) {
QNetworkManagerConnectionActive *activeConnection =
- new QNetworkManagerConnectionActive(acPath.path());
+ new QNetworkManagerConnectionActive(acPath.path(),this);
activeConnections.insert(acPath.path(), activeConnection);
activeConnection->setConnections();
connect(activeConnection, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)),
this, SLOT(activeConnectionPropertiesChanged(QString,QMap<QString,QVariant>)));
}
+ Q_EMIT updateCompleted();
}
bool QNetworkManagerEngine::networkManagerAvailable() const
{
QMutexLocker locker(&mutex);
- return interface->isValid();
+ return managerInterface->isValid();
}
QString QNetworkManagerEngine::getInterfaceFromId(const QString &id)
{
QMutexLocker locker(&mutex);
- foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
+ foreach (const QDBusObjectPath &acPath, managerInterface->activeConnections()) {
QNetworkManagerConnectionActive activeConnection(acPath.path());
- const QString identifier = QString::number(qHash(activeConnection.serviceName() + ' ' +
- activeConnection.connection().path()));
+ const QString identifier = activeConnection.connection().path();
if (id == identifier) {
QList<QDBusObjectPath> devices = activeConnection.devices();
@@ -161,24 +161,11 @@ QString QNetworkManagerEngine::getInterfaceFromId(const QString &id)
return QString();
}
+
bool QNetworkManagerEngine::hasIdentifier(const QString &id)
{
QMutexLocker locker(&mutex);
-
- if (connectionFromId(id))
- return true;
-
- for (int i = 0; i < accessPoints.count(); ++i) {
- QNetworkManagerInterfaceAccessPoint *accessPoint = accessPoints.at(i);
-
- const QString identifier =
- QString::number(qHash(accessPoint->connectionInterface()->path()));
-
- if (id == identifier)
- return true;
- }
-
- return false;
+ return accessPointConfigurations.contains(id);
}
void QNetworkManagerEngine::connectToId(const QString &id)
@@ -194,18 +181,17 @@ void QNetworkManagerEngine::connectToId(const QString &id)
const QString connectionType = map.value("connection").value("type").toString();
QString dbusDevicePath;
- foreach (const QDBusObjectPath &devicePath, interface->getDevices()) {
+ foreach (const QDBusObjectPath &devicePath, managerInterface->getDevices()) {
QNetworkManagerInterfaceDevice device(devicePath.path());
- if (device.deviceType() == DEVICE_TYPE_802_3_ETHERNET &&
+ if (device.deviceType() == DEVICE_TYPE_ETHERNET &&
connectionType == QLatin1String("802-3-ethernet")) {
dbusDevicePath = devicePath.path();
break;
- } else if (device.deviceType() == DEVICE_TYPE_802_11_WIRELESS &&
+ } else if (device.deviceType() == DEVICE_TYPE_WIFI &&
connectionType == QLatin1String("802-11-wireless")) {
dbusDevicePath = devicePath.path();
break;
- }
- else if (device.deviceType() == DEVICE_TYPE_GSM &&
+ } else if (device.deviceType() == DEVICE_TYPE_MODEM &&
connectionType == QLatin1String("gsm")) {
dbusDevicePath = devicePath.path();
break;
@@ -214,23 +200,34 @@ void QNetworkManagerEngine::connectToId(const QString &id)
const QString service = connection->connectionInterface()->service();
const QString settingsPath = connection->connectionInterface()->path();
+ QString specificPath = configuredAccessPoints.key(settingsPath);
+
+ if (specificPath.isEmpty())
+ specificPath = "/";
- interface->activateConnection(service, QDBusObjectPath(settingsPath),
- QDBusObjectPath(dbusDevicePath), QDBusObjectPath("/"));
+ managerInterface->activateConnection(service, QDBusObjectPath(settingsPath),
+ QDBusObjectPath(dbusDevicePath), QDBusObjectPath(specificPath));
}
void QNetworkManagerEngine::disconnectFromId(const QString &id)
{
QMutexLocker locker(&mutex);
- foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
+ QNetworkManagerSettingsConnection *connection = connectionFromId(id);
+ QNmSettingsMap map = connection->getSettings();
+ bool connectionAutoconnect = map.value("connection").value("autoconnect",true).toBool(); //if not present is true !!
+ if (connectionAutoconnect) { //autoconnect connections will simply be reconnected by nm
+ emit connectionError(id, QBearerEngineImpl::OperationNotSupported);
+ return;
+ }
+
+ foreach (const QDBusObjectPath &acPath, managerInterface->activeConnections()) {
QNetworkManagerConnectionActive activeConnection(acPath.path());
- const QString identifier = QString::number(qHash(activeConnection.serviceName() + ' ' +
- activeConnection.connection().path()));
+ const QString identifier = activeConnection.connection().path();
if (id == identifier && accessPointConfigurations.contains(id)) {
- interface->deactivateConnection(acPath);
+ managerInterface->deactivateConnection(acPath);
break;
}
}
@@ -238,15 +235,26 @@ void QNetworkManagerEngine::disconnectFromId(const QString &id)
void QNetworkManagerEngine::requestUpdate()
{
+ if (managerInterface->wirelessEnabled()) {
+ QHashIterator<QString, QNetworkManagerInterfaceDeviceWireless *> i(wirelessDevices);
+ while (i.hasNext()) {
+ i.next();
+ i.value()->requestScan();
+ }
+ }
+ QMetaObject::invokeMethod(this, "updateCompleted", Qt::QueuedConnection);
+}
+
+void QNetworkManagerEngine::scanFinished()
+{
QMetaObject::invokeMethod(this, "updateCompleted", Qt::QueuedConnection);
}
void QNetworkManagerEngine::interfacePropertiesChanged(const QString &path,
const QMap<QString, QVariant> &properties)
{
- QMutexLocker locker(&mutex);
-
Q_UNUSED(path)
+ QMutexLocker locker(&mutex);
QMapIterator<QString, QVariant> i(properties);
while (i.hasNext()) {
@@ -269,7 +277,7 @@ void QNetworkManagerEngine::interfacePropertiesChanged(const QString &path,
QNetworkManagerConnectionActive *activeConnection =
this->activeConnections.value(acPath.path());
if (!activeConnection) {
- activeConnection = new QNetworkManagerConnectionActive(acPath.path());
+ activeConnection = new QNetworkManagerConnectionActive(acPath.path(),this);
this->activeConnections.insert(acPath.path(), activeConnection);
activeConnection->setConnections();
@@ -277,15 +285,14 @@ void QNetworkManagerEngine::interfacePropertiesChanged(const QString &path,
this, SLOT(activeConnectionPropertiesChanged(QString,QMap<QString,QVariant>)));
}
- const QString id = QString::number(qHash(activeConnection->serviceName() + ' ' +
- activeConnection->connection().path()));
+ const QString id = activeConnection->connection().path();
identifiers.removeOne(id);
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
if (ptr) {
ptr->mutex.lock();
- if (activeConnection->state() == 2 &&
+ if (activeConnection->state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED &&
ptr->state != QNetworkConfiguration::Active) {
ptr->state = QNetworkConfiguration::Active;
ptr->mutex.unlock();
@@ -303,13 +310,13 @@ void QNetworkManagerEngine::interfacePropertiesChanged(const QString &path,
delete this->activeConnections.take(priorActiveConnections.takeFirst());
while (!identifiers.isEmpty()) {
- // These configurations are not active
QNetworkConfigurationPrivatePointer ptr =
accessPointConfigurations.value(identifiers.takeFirst());
ptr->mutex.lock();
if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
- ptr->state = QNetworkConfiguration::Discovered;
+ QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined;
+ ptr->state = (flag | QNetworkConfiguration::Discovered);
ptr->mutex.unlock();
locker.unlock();
@@ -335,15 +342,14 @@ void QNetworkManagerEngine::activeConnectionPropertiesChanged(const QString &pat
if (!activeConnection)
return;
- const QString id = QString::number(qHash(activeConnection->serviceName() + ' ' +
- activeConnection->connection().path()));
+ const QString id = activeConnection->connection().path();
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
if (ptr) {
ptr->mutex.lock();
- if (activeConnection->state() == 2 &&
+ if (activeConnection->state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED &&
ptr->state != QNetworkConfiguration::Active) {
- ptr->state = QNetworkConfiguration::Active;
+ ptr->state |= QNetworkConfiguration::Active;
ptr->mutex.unlock();
locker.unlock();
@@ -355,34 +361,63 @@ void QNetworkManagerEngine::activeConnectionPropertiesChanged(const QString &pat
}
}
-void QNetworkManagerEngine::devicePropertiesChanged(const QString &path,
- const QMap<QString, QVariant> &properties)
+void QNetworkManagerEngine::devicePropertiesChanged(const QString &/*path*/,quint32 /*state*/)
+{
+// Q_UNUSED(path);
+// Q_UNUSED(state)
+}
+
+void QNetworkManagerEngine::deviceConnectionsChanged(const QStringList &activeConnectionsList)
{
- Q_UNUSED(path);
- Q_UNUSED(properties);
+ QMutexLocker locker(&mutex);
+ for (int i = 0; i < connections.count(); ++i) {
+ if (activeConnectionsList.contains(connections.at(i)->connectionInterface()->path()))
+ continue;
+
+ const QString settingsPath = connections.at(i)->connectionInterface()->path();
+
+ QNetworkConfigurationPrivatePointer ptr =
+ accessPointConfigurations.value(settingsPath);
+ ptr->mutex.lock();
+ QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined;
+ ptr->state = (flag | QNetworkConfiguration::Discovered);
+ ptr->mutex.unlock();
+
+ locker.unlock();
+ emit configurationChanged(ptr);
+ locker.relock();
+ Q_EMIT updateCompleted();
+ }
}
void QNetworkManagerEngine::deviceAdded(const QDBusObjectPath &path)
{
- QNetworkManagerInterfaceDevice device(path.path());
- if (device.deviceType() == DEVICE_TYPE_802_11_WIRELESS) {
+ QMutexLocker locker(&mutex);
+ QNetworkManagerInterfaceDevice *iDevice;
+ iDevice = new QNetworkManagerInterfaceDevice(path.path(),this);
+ connect(iDevice,SIGNAL(connectionsChanged(QStringList)),
+ this,SLOT(deviceConnectionsChanged(QStringList)));
+
+ connect(iDevice,SIGNAL(stateChanged(QString,quint32)),
+ this,SLOT(devicePropertiesChanged(QString,quint32)));
+ iDevice->setConnections();
+ interfaceDevices.insert(path.path(),iDevice);
+
+ if (iDevice->deviceType() == DEVICE_TYPE_WIFI) {
QNetworkManagerInterfaceDeviceWireless *wirelessDevice =
- new QNetworkManagerInterfaceDeviceWireless(device.connectionInterface()->path());
+ new QNetworkManagerInterfaceDeviceWireless(iDevice->connectionInterface()->path(),this);
wirelessDevice->setConnections();
- connect(wirelessDevice, SIGNAL(accessPointAdded(QString,QDBusObjectPath)),
- this, SLOT(newAccessPoint(QString,QDBusObjectPath)));
- connect(wirelessDevice, SIGNAL(accessPointRemoved(QString,QDBusObjectPath)),
- this, SLOT(removeAccessPoint(QString,QDBusObjectPath)));
- connect(wirelessDevice, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)),
- this, SLOT(devicePropertiesChanged(QString,QMap<QString,QVariant>)));
+ connect(wirelessDevice, SIGNAL(accessPointAdded(QString)),
+ this, SLOT(newAccessPoint(QString)));
+ connect(wirelessDevice, SIGNAL(accessPointRemoved(QString)),
+ this, SLOT(removeAccessPoint(QString)));
+ connect(wirelessDevice,SIGNAL(scanDone()),this,SLOT(scanFinished()));
foreach (const QDBusObjectPath &apPath, wirelessDevice->getAccessPoints())
- newAccessPoint(QString(), apPath);
+ newAccessPoint(apPath.path());
- mutex.lock();
wirelessDevices.insert(path.path(), wirelessDevice);
- mutex.unlock();
}
}
@@ -390,47 +425,73 @@ void QNetworkManagerEngine::deviceRemoved(const QDBusObjectPath &path)
{
QMutexLocker locker(&mutex);
- delete wirelessDevices.take(path.path());
+ if (interfaceDevices.contains(path.path())) {
+ locker.unlock();
+ delete interfaceDevices.take(path.path());
+ locker.relock();
+ }
+ if (wirelessDevices.contains(path.path())) {
+ locker.unlock();
+ delete wirelessDevices.take(path.path());
+ locker.relock();
+ }
}
void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path,
QNetworkManagerSettings *settings)
{
QMutexLocker locker(&mutex);
-
if (!settings)
settings = qobject_cast<QNetworkManagerSettings *>(sender());
if (!settings)
return;
+ settings->deleteLater();
QNetworkManagerSettingsConnection *connection =
new QNetworkManagerSettingsConnection(settings->connectionInterface()->service(),
- path.path());
+ path.path(),this);
+ QString apPath;
+ for (int i = 0; i < accessPoints.count(); ++i) {
+ if (connection->getSsid() == accessPoints.at(i)->ssid()) {
+ // remove the corresponding accesspoint from configurations
+ apPath = accessPoints.at(i)->connectionInterface()->path();
+
+ QNetworkConfigurationPrivatePointer ptr
+ = accessPointConfigurations.take(apPath);
+ if (ptr) {
+ locker.unlock();
+ emit configurationRemoved(ptr);
+ locker.relock();
+ }
+ }
+ }
connections.append(connection);
- connect(connection, SIGNAL(removed(QString)), this, SLOT(removeConnection(QString)));
- connect(connection, SIGNAL(updated(QNmSettingsMap)),
- this, SLOT(updateConnection(QNmSettingsMap)));
+ connect(connection,SIGNAL(removed(QString)),this,SLOT(removeConnection(QString)));
+ connect(connection,SIGNAL(updated()),this,SLOT(updateConnection()));
+ connection->setConnections();
- const QString service = connection->connectionInterface()->service();
const QString settingsPath = connection->connectionInterface()->path();
+ if (connection->getType() == DEVICE_TYPE_WIFI
+ && !configuredAccessPoints.contains(settingsPath))
+ configuredAccessPoints.insert(apPath,settingsPath);
+
QNetworkConfigurationPrivate *cpPriv =
- parseConnection(service, settingsPath, connection->getSettings());
+ parseConnection(settingsPath, connection->getSettings());
// Check if connection is active.
- foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
+ foreach (const QDBusObjectPath &acPath, managerInterface->activeConnections()) {
QNetworkManagerConnectionActive activeConnection(acPath.path());
- if (activeConnection.serviceName() == service &&
+ if (activeConnection.defaultRoute() &&
activeConnection.connection().path() == settingsPath &&
- activeConnection.state() == 2) {
+ activeConnection.state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
cpPriv->state |= QNetworkConfiguration::Active;
break;
}
}
-
QNetworkConfigurationPrivatePointer ptr(cpPriv);
accessPointConfigurations.insert(ptr->id, ptr);
@@ -442,27 +503,34 @@ void QNetworkManagerEngine::removeConnection(const QString &path)
{
QMutexLocker locker(&mutex);
- Q_UNUSED(path)
-
QNetworkManagerSettingsConnection *connection =
qobject_cast<QNetworkManagerSettingsConnection *>(sender());
if (!connection)
return;
+ connection->deleteLater();
connections.removeAll(connection);
- const QString id = QString::number(qHash(connection->connectionInterface()->service() + ' ' +
- connection->connectionInterface()->path()));
+ const QString id = path;
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(id);
- connection->deleteLater();
-
- locker.unlock();
- emit configurationRemoved(ptr);
+ if (ptr) {
+ locker.unlock();
+ emit configurationRemoved(ptr);
+ locker.relock();
+ }
+ // add base AP back into configurations
+ QMapIterator<QString, QString> i(configuredAccessPoints);
+ while (i.hasNext()) {
+ i.next();
+ if (i.value() == path) {
+ newAccessPoint(i.key());
+ }
+ }
}
-void QNetworkManagerEngine::updateConnection(const QNmSettingsMap &settings)
+void QNetworkManagerEngine::updateConnection()
{
QMutexLocker locker(&mutex);
@@ -471,17 +539,16 @@ void QNetworkManagerEngine::updateConnection(const QNmSettingsMap &settings)
if (!connection)
return;
- const QString service = connection->connectionInterface()->service();
+ connection->deleteLater();
const QString settingsPath = connection->connectionInterface()->path();
- QNetworkConfigurationPrivate *cpPriv = parseConnection(service, settingsPath, settings);
+ QNetworkConfigurationPrivate *cpPriv = parseConnection(settingsPath, connection->getSettings());
// Check if connection is active.
- foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
+ foreach (const QDBusObjectPath &acPath, managerInterface->activeConnections()) {
QNetworkManagerConnectionActive activeConnection(acPath.path());
- if (activeConnection.serviceName() == service &&
- activeConnection.connection().path() == settingsPath &&
+ if (activeConnection.connection().path() == settingsPath &&
activeConnection.state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
cpPriv->state |= QNetworkConfiguration::Active;
break;
@@ -501,6 +568,7 @@ void QNetworkManagerEngine::updateConnection(const QNmSettingsMap &settings)
locker.unlock();
emit configurationChanged(ptr);
+ locker.relock();
delete cpPriv;
}
@@ -508,21 +576,22 @@ void QNetworkManagerEngine::activationFinished(QDBusPendingCallWatcher *watcher)
{
QMutexLocker locker(&mutex);
+ watcher->deleteLater();
+
QDBusPendingReply<QDBusObjectPath> reply(*watcher);
if (!reply.isError()) {
QDBusObjectPath result = reply.value();
QNetworkManagerConnectionActive activeConnection(result.path());
- const QString id = QString::number(qHash(activeConnection.serviceName() + ' ' +
- activeConnection.connection().path()));
+ const QString id = activeConnection.connection().path();
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
if (ptr) {
ptr->mutex.lock();
- if (activeConnection.state() == 2 &&
+ if (activeConnection.state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED &&
ptr->state != QNetworkConfiguration::Active) {
- ptr->state = QNetworkConfiguration::Active;
+ ptr->state |= QNetworkConfiguration::Active;
ptr->mutex.unlock();
locker.unlock();
@@ -535,42 +604,41 @@ void QNetworkManagerEngine::activationFinished(QDBusPendingCallWatcher *watcher)
}
}
-void QNetworkManagerEngine::newAccessPoint(const QString &path, const QDBusObjectPath &objectPath)
+void QNetworkManagerEngine::newAccessPoint(const QString &path)
{
QMutexLocker locker(&mutex);
- Q_UNUSED(path)
-
QNetworkManagerInterfaceAccessPoint *accessPoint =
- new QNetworkManagerInterfaceAccessPoint(objectPath.path());
- accessPoints.append(accessPoint);
-
- accessPoint->setConnections();
- connect(accessPoint, SIGNAL(propertiesChanged(QMap<QString,QVariant>)),
- this, SLOT(updateAccessPoint(QMap<QString,QVariant>)));
+ new QNetworkManagerInterfaceAccessPoint(path,this);
- // Check if configuration for this SSID already exists.
+ bool okToAdd = true;
for (int i = 0; i < accessPoints.count(); ++i) {
- if (accessPoint != accessPoints.at(i) &&
- accessPoint->ssid() == accessPoints.at(i)->ssid()) {
- return;
+ if (accessPoints.at(i)->connectionInterface()->path() == path) {
+ okToAdd = false;
}
}
+ if (okToAdd) {
+ accessPoints.append(accessPoint);
+ accessPoint->setConnections();
+ connect(accessPoint, SIGNAL(propertiesChanged(QMap<QString,QVariant>)),
+ this, SLOT(updateAccessPoint(QMap<QString,QVariant>)));
+ }
// Check if configuration exists for connection.
if (!accessPoint->ssid().isEmpty()) {
for (int i = 0; i < connections.count(); ++i) {
QNetworkManagerSettingsConnection *connection = connections.at(i);
-
+ const QString settingsPath = connection->connectionInterface()->path();
if (accessPoint->ssid() == connection->getSsid()) {
- const QString service = connection->connectionInterface()->service();
- const QString settingsPath = connection->connectionInterface()->path();
- const QString connectionId = QString::number(qHash(service + ' ' + settingsPath));
+ if (!configuredAccessPoints.contains(path)) {
+ configuredAccessPoints.insert(path,settingsPath);
+ }
QNetworkConfigurationPrivatePointer ptr =
- accessPointConfigurations.value(connectionId);
+ accessPointConfigurations.value(settingsPath);
ptr->mutex.lock();
- ptr->state = QNetworkConfiguration::Discovered;
+ QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined;
+ ptr->state = (flag | QNetworkConfiguration::Discovered);
ptr->mutex.unlock();
locker.unlock();
@@ -585,9 +653,9 @@ void QNetworkManagerEngine::newAccessPoint(const QString &path, const QDBusObjec
ptr->name = accessPoint->ssid();
ptr->isValid = true;
- ptr->id = QString::number(qHash(objectPath.path()));
+ ptr->id = path;
ptr->type = QNetworkConfiguration::InternetAccessPoint;
- if(accessPoint->flags() == NM_802_11_AP_FLAGS_PRIVACY) {
+ if (accessPoint->flags() == NM_802_11_AP_FLAGS_PRIVACY) {
ptr->purpose = QNetworkConfiguration::PrivatePurpose;
} else {
ptr->purpose = QNetworkConfiguration::PublicPurpose;
@@ -601,30 +669,24 @@ void QNetworkManagerEngine::newAccessPoint(const QString &path, const QDBusObjec
emit configurationAdded(ptr);
}
-void QNetworkManagerEngine::removeAccessPoint(const QString &path,
- const QDBusObjectPath &objectPath)
+void QNetworkManagerEngine::removeAccessPoint(const QString &path)
{
QMutexLocker locker(&mutex);
-
- Q_UNUSED(path)
-
for (int i = 0; i < accessPoints.count(); ++i) {
QNetworkManagerInterfaceAccessPoint *accessPoint = accessPoints.at(i);
- if (accessPoint->connectionInterface()->path() == objectPath.path()) {
+ if (accessPoint->connectionInterface()->path() == path) {
accessPoints.removeOne(accessPoint);
- if (configuredAccessPoints.contains(accessPoint)) {
+ if (configuredAccessPoints.contains(accessPoint->connectionInterface()->path())) {
// find connection and change state to Defined
- configuredAccessPoints.removeOne(accessPoint);
+ configuredAccessPoints.remove(accessPoint->connectionInterface()->path());
for (int i = 0; i < connections.count(); ++i) {
QNetworkManagerSettingsConnection *connection = connections.at(i);
- if (accessPoint->ssid() == connection->getSsid()) {
- const QString service = connection->connectionInterface()->service();
+ if (accessPoint->ssid() == connection->getSsid()) {//might not have bssid yet
const QString settingsPath = connection->connectionInterface()->path();
- const QString connectionId =
- QString::number(qHash(service + ' ' + settingsPath));
+ const QString connectionId = settingsPath;
QNetworkConfigurationPrivatePointer ptr =
accessPointConfigurations.value(connectionId);
@@ -640,17 +702,17 @@ void QNetworkManagerEngine::removeAccessPoint(const QString &path,
}
} else {
QNetworkConfigurationPrivatePointer ptr =
- accessPointConfigurations.take(QString::number(qHash(objectPath.path())));
+ accessPointConfigurations.take(path);
if (ptr) {
locker.unlock();
+
+ locker.unlock();
emit configurationRemoved(ptr);
locker.relock();
}
}
-
delete accessPoint;
-
break;
}
}
@@ -666,19 +728,19 @@ void QNetworkManagerEngine::updateAccessPoint(const QMap<QString, QVariant> &map
qobject_cast<QNetworkManagerInterfaceAccessPoint *>(sender());
if (!accessPoint)
return;
-
+ accessPoint->deleteLater();
for (int i = 0; i < connections.count(); ++i) {
QNetworkManagerSettingsConnection *connection = connections.at(i);
if (accessPoint->ssid() == connection->getSsid()) {
- const QString service = connection->connectionInterface()->service();
const QString settingsPath = connection->connectionInterface()->path();
- const QString connectionId = QString::number(qHash(service + ' ' + settingsPath));
+ const QString connectionId = settingsPath;
QNetworkConfigurationPrivatePointer ptr =
accessPointConfigurations.value(connectionId);
ptr->mutex.lock();
- ptr->state = QNetworkConfiguration::Discovered;
+ QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined;
+ ptr->state = (flag | QNetworkConfiguration::Discovered);
ptr->mutex.unlock();
locker.unlock();
@@ -688,14 +750,16 @@ void QNetworkManagerEngine::updateAccessPoint(const QMap<QString, QVariant> &map
}
}
-QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QString &service,
- const QString &settingsPath,
+QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QString &settingsPath,
const QNmSettingsMap &map)
{
+ // Q_UNUSED(service);
+ QMutexLocker locker(&mutex);
QNetworkConfigurationPrivate *cpPriv = new QNetworkConfigurationPrivate;
cpPriv->name = map.value("connection").value("id").toString();
+
cpPriv->isValid = true;
- cpPriv->id = QString::number(qHash(service + ' ' + settingsPath));
+ cpPriv->id = settingsPath;
cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
@@ -708,15 +772,14 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri
cpPriv->bearerType = QNetworkConfiguration::BearerEthernet;
cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
- foreach (const QDBusObjectPath &devicePath, interface->getDevices()) {
+ foreach (const QDBusObjectPath &devicePath, managerInterface->getDevices()) {
QNetworkManagerInterfaceDevice device(devicePath.path());
- if (device.deviceType() == DEVICE_TYPE_802_3_ETHERNET) {
+ if (device.deviceType() == DEVICE_TYPE_ETHERNET) {
QNetworkManagerInterfaceDeviceWired wiredDevice(device.connectionInterface()->path());
if (wiredDevice.carrier()) {
cpPriv->state |= QNetworkConfiguration::Discovered;
break;
}
-
}
}
} else if (connectionType == QLatin1String("802-11-wireless")) {
@@ -724,35 +787,57 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri
const QString connectionSsid = map.value("802-11-wireless").value("ssid").toString();
const QString connectionSecurity = map.value("802-11-wireless").value("security").toString();
- if(!connectionSecurity.isEmpty()) {
+ if (!connectionSecurity.isEmpty()) {
cpPriv->purpose = QNetworkConfiguration::PrivatePurpose;
} else {
cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
}
for (int i = 0; i < accessPoints.count(); ++i) {
- if (connectionSsid == accessPoints.at(i)->ssid()) {
+ if (connectionSsid == accessPoints.at(i)->ssid()
+ && map.value("802-11-wireless").value("seen-bssids").toStringList().contains(accessPoints.at(i)->hwAddress())) {
cpPriv->state |= QNetworkConfiguration::Discovered;
- if (!configuredAccessPoints.contains(accessPoints.at(i))) {
- configuredAccessPoints.append(accessPoints.at(i));
+ if (!configuredAccessPoints.contains(accessPoints.at(i)->connectionInterface()->path())) {
+ configuredAccessPoints.insert(accessPoints.at(i)->connectionInterface()->path(),settingsPath);
- const QString accessPointId =
- QString::number(qHash(accessPoints.at(i)->connectionInterface()->path()));
+ const QString accessPointId = accessPoints.at(i)->connectionInterface()->path();
QNetworkConfigurationPrivatePointer ptr =
accessPointConfigurations.take(accessPointId);
if (ptr) {
- mutex.unlock();
+ locker.unlock();
emit configurationRemoved(ptr);
- mutex.lock();
+ locker.relock();
}
}
break;
}
}
- } else if (connectionType == "gsm") {
- cpPriv->bearerType = QNetworkConfiguration::Bearer2G;
- } else if (connectionType == "cdma") {
- cpPriv->bearerType = QNetworkConfiguration::BearerCDMA2000;
+ } else if (connectionType == QLatin1String("gsm")) {
+
+ foreach (const QDBusObjectPath &devicePath, managerInterface->getDevices()) {
+ QNetworkManagerInterfaceDevice device(devicePath.path());
+
+ if (device.deviceType() == DEVICE_TYPE_MODEM) {
+ QNetworkManagerInterfaceDeviceModem deviceModem(device.connectionInterface()->path(),this);
+ switch (deviceModem.currentCapabilities()) {
+ case 2:
+ cpPriv->bearerType = QNetworkConfiguration::Bearer2G;
+ break;
+ case 4:
+ cpPriv->bearerType = QNetworkConfiguration::Bearer3G;
+ break;
+ case 8:
+ cpPriv->bearerType = QNetworkConfiguration::Bearer4G;
+ break;
+ default:
+ cpPriv->bearerType = QNetworkConfiguration::BearerUnknown;
+ break;
+ };
+ }
+ }
+
+ cpPriv->purpose = QNetworkConfiguration::PrivatePurpose;
+ cpPriv->state |= QNetworkConfiguration::Discovered;
}
return cpPriv;
@@ -762,12 +847,7 @@ QNetworkManagerSettingsConnection *QNetworkManagerEngine::connectionFromId(const
{
for (int i = 0; i < connections.count(); ++i) {
QNetworkManagerSettingsConnection *connection = connections.at(i);
- const QString service = connection->connectionInterface()->service();
- const QString settingsPath = connection->connectionInterface()->path();
-
- const QString identifier = QString::number(qHash(service + ' ' + settingsPath));
-
- if (id == identifier)
+ if (id == connection->connectionInterface()->path())
return connection;
}
@@ -789,8 +869,7 @@ QNetworkSession::State QNetworkManagerEngine::sessionStateForId(const QString &i
foreach (const QString &acPath, activeConnections.keys()) {
QNetworkManagerConnectionActive *activeConnection = activeConnections.value(acPath);
- const QString identifier = QString::number(qHash(activeConnection->serviceName() + ' ' +
- activeConnection->connection().path()));
+ const QString identifier = activeConnection->connection().path();
if (id == identifier) {
switch (activeConnection->state()) {
@@ -884,7 +963,8 @@ quint64 QNetworkManagerEngine::startTime(const QString &id)
QNetworkConfigurationManager::Capabilities QNetworkManagerEngine::capabilities() const
{
return QNetworkConfigurationManager::ForcedRoaming |
- QNetworkConfigurationManager::CanStartAndStopInterfaces;
+ QNetworkConfigurationManager::DataStatistics |
+ QNetworkConfigurationManager::CanStartAndStopInterfaces;
}
QNetworkSessionPrivate *QNetworkManagerEngine::createSessionBackend()
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
index 19a569d01e..ab1cfea71e 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
@@ -93,36 +93,37 @@ private Q_SLOTS:
const QMap<QString, QVariant> &properties);
void activeConnectionPropertiesChanged(const QString &path,
const QMap<QString, QVariant> &properties);
- void devicePropertiesChanged(const QString &path,
- const QMap<QString, QVariant> &properties);
+ void devicePropertiesChanged(const QString &path, quint32);
void deviceAdded(const QDBusObjectPath &path);
void deviceRemoved(const QDBusObjectPath &path);
void newConnection(const QDBusObjectPath &path, QNetworkManagerSettings *settings = 0);
void removeConnection(const QString &path);
- void updateConnection(const QNmSettingsMap &settings);
+ void updateConnection();
void activationFinished(QDBusPendingCallWatcher *watcher);
+ void deviceConnectionsChanged(const QStringList &activeConnectionsList);
- void newAccessPoint(const QString &path, const QDBusObjectPath &objectPath);
- void removeAccessPoint(const QString &path, const QDBusObjectPath &objectPath);
+ void newAccessPoint(const QString &path);
+ void removeAccessPoint(const QString &path);
void updateAccessPoint(const QMap<QString, QVariant> &map);
+ void scanFinished();
private:
- QNetworkConfigurationPrivate *parseConnection(const QString &service,
- const QString &settingsPath,
+ QNetworkConfigurationPrivate *parseConnection(const QString &settingsPath,
const QNmSettingsMap &map);
QNetworkManagerSettingsConnection *connectionFromId(const QString &id) const;
-private:
- QNetworkManagerInterface *interface;
+ QNetworkManagerInterface *managerInterface;
QNetworkManagerSettings *systemSettings;
QNetworkManagerSettings *userSettings;
QHash<QString, QNetworkManagerInterfaceDeviceWireless *> wirelessDevices;
QHash<QString, QNetworkManagerConnectionActive *> activeConnections;
QList<QNetworkManagerSettingsConnection *> connections;
QList<QNetworkManagerInterfaceAccessPoint *> accessPoints;
- QList<QNetworkManagerInterfaceAccessPoint *> configuredAccessPoints;
+ QHash<QString, QNetworkManagerInterfaceDevice *> interfaceDevices;
+
+ QMap<QString,QString> configuredAccessPoints; //ap, settings path
};
QT_END_NAMESPACE
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
index d249d85c4d..f249ac6100 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
@@ -97,21 +97,21 @@ bool QNetworkManagerInterface::setConnections()
QDBusConnection dbusConnection = QDBusConnection::systemBus();
bool allOk = false;
- if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
+ if (dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
QLatin1String(NM_DBUS_PATH),
QLatin1String(NM_DBUS_INTERFACE),
QLatin1String("PropertiesChanged"),
nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>)))) {
allOk = true;
}
- if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
+ if (dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
QLatin1String(NM_DBUS_PATH),
QLatin1String(NM_DBUS_INTERFACE),
QLatin1String("DeviceAdded"),
this,SIGNAL(deviceAdded(QDBusObjectPath)))) {
allOk = true;
}
- if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
+ if (dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
QLatin1String(NM_DBUS_PATH),
QLatin1String(NM_DBUS_INTERFACE),
QLatin1String("DeviceRemoved"),
@@ -133,18 +133,17 @@ QList <QDBusObjectPath> QNetworkManagerInterface::getDevices() const
return reply.value();
}
-void QNetworkManagerInterface::activateConnection( const QString &serviceName,
+void QNetworkManagerInterface::activateConnection( const QString &,
QDBusObjectPath connectionPath,
QDBusObjectPath devicePath,
QDBusObjectPath specificObject)
{
QDBusPendingCall pendingCall = d->connectionInterface->asyncCall(QLatin1String("ActivateConnection"),
- QVariant(serviceName),
QVariant::fromValue(connectionPath),
QVariant::fromValue(devicePath),
QVariant::fromValue(specificObject));
- QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(pendingCall, this);
+ QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(pendingCall);
connect(callWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
this, SIGNAL(activationFinished(QDBusPendingCallWatcher*)));
}
@@ -323,18 +322,31 @@ bool QNetworkManagerInterfaceDevice::setConnections()
if(!isValid() )
return false;
- bool allOk = false;
+ bool allOk = true;
delete nmDBusHelper;
nmDBusHelper = new QNmDBusHelper(this);
connect(nmDBusHelper,SIGNAL(pathForStateChanged(QString,quint32)),
this, SIGNAL(stateChanged(QString,quint32)));
+
if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
d->path,
QLatin1String(NM_DBUS_INTERFACE_DEVICE),
QLatin1String("StateChanged"),
nmDBusHelper,SLOT(deviceStateChanged(quint32)))) {
- allOk = true;
+ allOk = false;
}
+
+ connect(nmDBusHelper, SIGNAL(pathForConnectionsChanged(QStringList)),
+ this,SIGNAL(connectionsChanged(QStringList)));
+
+ if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
+ d->path,
+ QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT),
+ QLatin1String("PropertiesChanged"),
+ nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>))) ) {
+ allOk = false;
+ }
+
return allOk;
}
@@ -415,18 +427,18 @@ bool QNetworkManagerInterfaceDeviceWired::setConnections()
if(!isValid() )
return false;
- bool allOk = false;
+ bool allOk = true;
delete nmDBusHelper;
nmDBusHelper = new QNmDBusHelper(this);
connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)),
this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)));
- if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
+ if (!QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
d->path,
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED),
QLatin1String("PropertiesChanged"),
nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>))) ) {
- allOk = true;
+ allOk = false;
}
return allOk;
}
@@ -492,44 +504,50 @@ bool QNetworkManagerInterfaceDeviceWireless::setConnections()
return false;
QDBusConnection dbusConnection = QDBusConnection::systemBus();
- bool allOk = false;
+ bool allOk = true;
delete nmDBusHelper;
nmDBusHelper = new QNmDBusHelper(this);
connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)),
this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)));
- connect(nmDBusHelper, SIGNAL(pathForAccessPointAdded(QString,QDBusObjectPath)),
- this,SIGNAL(accessPointAdded(QString,QDBusObjectPath)));
+ connect(nmDBusHelper, SIGNAL(pathForAccessPointAdded(QString)),
+ this,SIGNAL(accessPointAdded(QString)));
- connect(nmDBusHelper, SIGNAL(pathForAccessPointRemoved(QString,QDBusObjectPath)),
- this,SIGNAL(accessPointRemoved(QString,QDBusObjectPath)));
+ connect(nmDBusHelper, SIGNAL(pathForAccessPointRemoved(QString)),
+ this,SIGNAL(accessPointRemoved(QString)));
- if(!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
+ if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
d->path,
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
QLatin1String("AccessPointAdded"),
nmDBusHelper, SLOT(slotAccessPointAdded(QDBusObjectPath)))) {
- allOk = true;
+ allOk = false;
}
- if(!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
+ if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
d->path,
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
QLatin1String("AccessPointRemoved"),
nmDBusHelper, SLOT(slotAccessPointRemoved(QDBusObjectPath)))) {
- allOk = true;
+ allOk = false;
}
- if(!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
+ if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
d->path,
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
QLatin1String("PropertiesChanged"),
nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>)))) {
- allOk = true;
+ allOk = false;
+ }
+ if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
+ d->path,
+ QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
+ QLatin1String("ScanDone"),
+ this, SLOT(scanIsDone()))) {
+ allOk = false;
}
-
return allOk;
}
@@ -569,6 +587,89 @@ quint32 QNetworkManagerInterfaceDeviceWireless::wirelessCapabilities() const
return d->connectionInterface->property("WirelelessCapabilities").toUInt();
}
+void QNetworkManagerInterfaceDeviceWireless::scanIsDone()
+{
+ Q_EMIT scanDone();
+}
+
+void QNetworkManagerInterfaceDeviceWireless::requestScan()
+{
+ d->connectionInterface->asyncCall(QLatin1String("RequestScan"));
+}
+
+
+class QNetworkManagerInterfaceDeviceModemPrivate
+{
+public:
+ QDBusInterface *connectionInterface;
+ QString path;
+ bool valid;
+};
+
+QNetworkManagerInterfaceDeviceModem::QNetworkManagerInterfaceDeviceModem(const QString &ifaceDevicePath, QObject *parent)
+ : QObject(parent), nmDBusHelper(0)
+{
+ d = new QNetworkManagerInterfaceDeviceModemPrivate();
+ d->path = ifaceDevicePath;
+ d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
+ d->path,
+ QLatin1String(NM_DBUS_INTERFACE_DEVICE_MODEM),
+ QDBusConnection::systemBus(), parent);
+ if (!d->connectionInterface->isValid()) {
+ d->valid = false;
+ return;
+ }
+ d->valid = true;
+}
+
+QNetworkManagerInterfaceDeviceModem::~QNetworkManagerInterfaceDeviceModem()
+{
+ delete d->connectionInterface;
+ delete d;
+}
+
+bool QNetworkManagerInterfaceDeviceModem::isValid()
+{
+
+ return d->valid;
+}
+
+bool QNetworkManagerInterfaceDeviceModem::setConnections()
+{
+ if (!isValid() )
+ return false;
+
+ bool allOk = true;
+
+ delete nmDBusHelper;
+ nmDBusHelper = new QNmDBusHelper(this);
+ connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)),
+ this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)));
+ if (!QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
+ d->path,
+ QLatin1String(NM_DBUS_INTERFACE_DEVICE_MODEM),
+ QLatin1String("PropertiesChanged"),
+ nmDBusHelper,SLOT(slotDevicePropertiesChanged(QMap<QString,QVariant>))) ) {
+ allOk = false;
+ }
+ return allOk;
+}
+
+QDBusInterface *QNetworkManagerInterfaceDeviceModem::connectionInterface() const
+{
+ return d->connectionInterface;
+}
+
+quint32 QNetworkManagerInterfaceDeviceModem::modemCapabilities() const
+{
+ return d->connectionInterface->property("ModemCapabilities").toUInt();
+}
+
+quint32 QNetworkManagerInterfaceDeviceModem::currentCapabilities() const
+{
+ return d->connectionInterface->property("CurrentCapabilities").toUInt();
+}
+
class QNetworkManagerSettingsPrivate
{
public:
@@ -606,12 +707,14 @@ bool QNetworkManagerSettings::isValid()
bool QNetworkManagerSettings::setConnections()
{
- bool allOk = false;
+ bool allOk = true;
- if (!QDBusConnection::systemBus().connect(d->path, QLatin1String(NM_DBUS_PATH_SETTINGS),
- QLatin1String(NM_DBUS_IFACE_SETTINGS), QLatin1String("NewConnection"),
- this, SIGNAL(newConnection(QDBusObjectPath)))) {
- allOk = true;
+ if (!QDBusConnection::systemBus().connect(d->path,
+ QLatin1String(NM_DBUS_PATH_SETTINGS),
+ QLatin1String(NM_DBUS_IFACE_SETTINGS),
+ QLatin1String("NewConnection"),
+ this, SIGNAL(newConnection(QDBusObjectPath)))) {
+ allOk = false;
}
return allOk;
@@ -623,6 +726,14 @@ QList <QDBusObjectPath> QNetworkManagerSettings::listConnections()
return reply.value();
}
+QString QNetworkManagerSettings::getConnectionByUuid(const QString &uuid)
+{
+ QList<QVariant> argumentList;
+ argumentList << QVariant::fromValue(uuid);
+ QDBusReply<QDBusObjectPath > reply = d->connectionInterface->callWithArgumentList(QDBus::Block,QLatin1String("GetConnectionByUuid"), argumentList);
+ return reply.value().path();
+}
+
QDBusInterface *QNetworkManagerSettings::connectionInterface() const
{
return d->connectionInterface;
@@ -676,13 +787,13 @@ bool QNetworkManagerSettingsConnection::setConnections()
return false;
QDBusConnection dbusConnection = QDBusConnection::systemBus();
- bool allOk = false;
- if(!dbusConnection.connect(d->service, d->path,
- QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), QLatin1String("Updated"),
- this, SIGNAL(updated(QNmSettingsMap)))) {
- allOk = true;
- } else {
- QDBusError error = dbusConnection.lastError();
+ bool allOk = true;
+ if (!dbusConnection.connect(d->service,
+ d->path,
+ QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION),
+ QLatin1String("Updated"),
+ this, SIGNAL(updated()))) {
+ allOk = false;
}
delete nmDBusHelper;
@@ -690,12 +801,13 @@ bool QNetworkManagerSettingsConnection::setConnections()
connect(nmDBusHelper, SIGNAL(pathForSettingsRemoved(QString)),
this,SIGNAL(removed(QString)));
- if (!dbusConnection.connect(d->service, d->path,
- QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), QLatin1String("Removed"),
- nmDBusHelper, SIGNAL(slotSettingsRemoved()))) {
- allOk = true;
+ if (!dbusConnection.connect(d->service,
+ d->path,
+ QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION),
+ QLatin1String("Removed"),
+ nmDBusHelper, SIGNAL(slotSettingsRemoved()))) {
+ allOk = false;
}
-
return allOk;
}
@@ -717,9 +829,9 @@ NMDeviceType QNetworkManagerSettingsConnection::getType()
d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("type")).toString();
if (devType == QLatin1String("802-3-ethernet"))
- return DEVICE_TYPE_802_3_ETHERNET;
+ return DEVICE_TYPE_ETHERNET;
else if (devType == QLatin1String("802-11-wireless"))
- return DEVICE_TYPE_802_11_WIRELESS;
+ return DEVICE_TYPE_WIFI;
else
return DEVICE_TYPE_UNKNOWN;
}
@@ -766,10 +878,10 @@ QString QNetworkManagerSettingsConnection::getMacAddress()
{
NMDeviceType type = getType();
- if (type == DEVICE_TYPE_802_3_ETHERNET) {
+ if (type == DEVICE_TYPE_ETHERNET) {
return d->settingsMap.value(QLatin1String("802-3-ethernet"))
.value(QLatin1String("mac-address")).toString();
- } else if (type == DEVICE_TYPE_802_11_WIRELESS) {
+ } else if (type == DEVICE_TYPE_WIFI) {
return d->settingsMap.value(QLatin1String("802-11-wireless"))
.value(QLatin1String("mac-address")).toString();
} else {
@@ -779,7 +891,7 @@ QString QNetworkManagerSettingsConnection::getMacAddress()
QStringList QNetworkManagerSettingsConnection::getSeenBssids()
{
- if (getType() == DEVICE_TYPE_802_11_WIRELESS) {
+ if (getType() == DEVICE_TYPE_WIFI) {
return d->settingsMap.value(QLatin1String("802-11-wireless"))
.value(QLatin1String("seen-bssids")).toStringList();
} else {
@@ -795,7 +907,7 @@ public:
bool valid;
};
-QNetworkManagerConnectionActive::QNetworkManagerConnectionActive( const QString &activeConnectionObjectPath, QObject *parent)
+QNetworkManagerConnectionActive::QNetworkManagerConnectionActive(const QString &activeConnectionObjectPath, QObject *parent)
: QObject(parent), nmDBusHelper(0)
{
d = new QNetworkManagerConnectionActivePrivate();
@@ -827,17 +939,18 @@ bool QNetworkManagerConnectionActive::setConnections()
if(!isValid() )
return false;
- bool allOk = false;
+ bool allOk = true;
delete nmDBusHelper;
nmDBusHelper = new QNmDBusHelper(this);
connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)),
this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)));
- if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
+
+ if (!QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
d->path,
QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION),
QLatin1String("PropertiesChanged"),
- nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>))) ) {
- allOk = true;
+ nmDBusHelper,SLOT(activeConnectionPropertiesChanged(QMap<QString,QVariant>))) ) {
+ allOk = false;
}
return allOk;
@@ -848,11 +961,6 @@ QDBusInterface *QNetworkManagerConnectionActive::connectionInterface() const
return d->connectionInterface;
}
-QString QNetworkManagerConnectionActive::serviceName() const
-{
- return d->connectionInterface->property("ServiceName").toString();
-}
-
QDBusObjectPath QNetworkManagerConnectionActive::connection() const
{
QVariant prop = d->connectionInterface->property("Connection");
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
index 6b15642386..11ddaf7088 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
@@ -64,31 +64,32 @@
typedef enum NMDeviceType
{
DEVICE_TYPE_UNKNOWN = 0,
- DEVICE_TYPE_802_3_ETHERNET,
- DEVICE_TYPE_802_11_WIRELESS,
- DEVICE_TYPE_GSM,
- DEVICE_TYPE_CDMA
+ DEVICE_TYPE_ETHERNET,
+ DEVICE_TYPE_WIFI,
+ DEVICE_TYPE_MODEM = 8
} NMDeviceType;
typedef enum
{
NM_DEVICE_STATE_UNKNOWN = 0,
- NM_DEVICE_STATE_UNMANAGED,
- NM_DEVICE_STATE_UNAVAILABLE,
- NM_DEVICE_STATE_DISCONNECTED,
- NM_DEVICE_STATE_PREPARE,
- NM_DEVICE_STATE_CONFIG,
- NM_DEVICE_STATE_NEED_AUTH,
- NM_DEVICE_STATE_IP_CONFIG,
- NM_DEVICE_STATE_ACTIVATED,
- NM_DEVICE_STATE_FAILED
+ NM_DEVICE_STATE_UNMANAGED = 10,
+ NM_DEVICE_STATE_UNAVAILABLE = 20,
+ NM_DEVICE_STATE_DISCONNECTED = 30,
+ NM_DEVICE_STATE_PREPARE = 40,
+ NM_DEVICE_STATE_CONFIG = 50,
+ NM_DEVICE_STATE_NEED_AUTH = 60,
+ NM_DEVICE_STATE_IP_CONFIG = 70,
+ NM_DEVICE_STATE_ACTIVATED = 100,
+ NM_DEVICE_STATE_DEACTIVATING = 110,
+ NM_DEVICE_STATE_FAILED = 120
} NMDeviceState;
typedef enum
{
NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0,
NM_ACTIVE_CONNECTION_STATE_ACTIVATING,
- NM_ACTIVE_CONNECTION_STATE_ACTIVATED
+ NM_ACTIVE_CONNECTION_STATE_ACTIVATED,
+ NM_ACTIVE_CONNECTION_STATE_DEACTIVATED
} NMActiveConnectionState;
#define NM_DBUS_SERVICE "org.freedesktop.NetworkManager"
@@ -98,13 +99,14 @@ typedef enum
#define NM_DBUS_INTERFACE_DEVICE NM_DBUS_INTERFACE ".Device"
#define NM_DBUS_INTERFACE_DEVICE_WIRED NM_DBUS_INTERFACE_DEVICE ".Wired"
#define NM_DBUS_INTERFACE_DEVICE_WIRELESS NM_DBUS_INTERFACE_DEVICE ".Wireless"
+#define NM_DBUS_INTERFACE_DEVICE_MODEM NM_DBUS_INTERFACE_DEVICE ".Modem"
#define NM_DBUS_PATH_ACCESS_POINT NM_DBUS_PATH "/AccessPoint"
#define NM_DBUS_INTERFACE_ACCESS_POINT NM_DBUS_INTERFACE ".AccessPoint"
-#define NM_DBUS_PATH_SETTINGS "/org/freedesktop/NetworkManagerSettings"
+#define NM_DBUS_PATH_SETTINGS "/org/freedesktop/NetworkManager/Settings"
-#define NM_DBUS_IFACE_SETTINGS_CONNECTION "org.freedesktop.NetworkManagerSettings.Connection"
-#define NM_DBUS_IFACE_SETTINGS "org.freedesktop.NetworkManagerSettings"
+#define NM_DBUS_IFACE_SETTINGS_CONNECTION "org.freedesktop.NetworkManager.Settings.Connection"
+#define NM_DBUS_IFACE_SETTINGS "org.freedesktop.NetworkManager.Settings"
#define NM_DBUS_INTERFACE_ACTIVE_CONNECTION NM_DBUS_INTERFACE ".Connection.Active"
#define NM_DBUS_INTERFACE_IP4_CONFIG NM_DBUS_INTERFACE ".IP4Config"
@@ -256,7 +258,8 @@ public:
Q_SIGNALS:
void stateChanged(const QString &, quint32);
-
+ void propertiesChanged(const QString &, QMap<QString,QVariant>);
+ void connectionsChanged(QStringList);
private:
QNetworkManagerInterfaceDevicePrivate *d;
QNmDBusHelper *nmDBusHelper;
@@ -320,15 +323,55 @@ public:
bool setConnections();
bool isValid();
+ void requestScan();
Q_SIGNALS:
void propertiesChanged( const QString &, QMap<QString,QVariant>);
- void accessPointAdded(const QString &,QDBusObjectPath);
- void accessPointRemoved(const QString &,QDBusObjectPath);
+ void accessPointAdded(const QString &);
+ void accessPointRemoved(const QString &);
+ void scanDone();
+private Q_SLOTS:
+ void scanIsDone();
private:
QNetworkManagerInterfaceDeviceWirelessPrivate *d;
QNmDBusHelper *nmDBusHelper;
};
+class QNetworkManagerInterfaceDeviceModemPrivate;
+class QNetworkManagerInterfaceDeviceModem : public QObject
+{
+ Q_OBJECT
+
+public:
+
+ enum ModemCapability {
+ None = 0x0,
+ Pots = 0x1,
+ Cmda_Edvo = 0x2,
+ Gsm_Umts = 0x4,
+ Lte = 0x08
+ };
+
+ explicit QNetworkManagerInterfaceDeviceModem(const QString &ifaceDevicePath,
+ QObject *parent = 0);
+ ~QNetworkManagerInterfaceDeviceModem();
+
+ QDBusObjectPath path() const;
+ QDBusInterface *connectionInterface() const;
+
+ bool setConnections();
+ bool isValid();
+
+ quint32 modemCapabilities() const;
+ quint32 currentCapabilities() const;
+
+Q_SIGNALS:
+ void propertiesChanged( const QString &, QMap<QString,QVariant>);
+private:
+ QNetworkManagerInterfaceDeviceModemPrivate *d;
+ QNmDBusHelper *nmDBusHelper;
+};
+
+
class QNetworkManagerSettingsPrivate;
class QNetworkManagerSettings : public QObject
{
@@ -341,6 +384,7 @@ public:
QDBusInterface *connectionInterface() const;
QList <QDBusObjectPath> listConnections();
+ QString getConnectionByUuid(const QString &uuid);
bool setConnections();
bool isValid();
@@ -375,7 +419,7 @@ public:
Q_SIGNALS:
- void updated(const QNmSettingsMap &settings);
+ void updated();
void removed(const QString &path);
private:
diff --git a/src/plugins/bearer/networkmanager/qnmdbushelper.cpp b/src/plugins/bearer/networkmanager/qnmdbushelper.cpp
index a2e055d784..0decfd78b9 100644
--- a/src/plugins/bearer/networkmanager/qnmdbushelper.cpp
+++ b/src/plugins/bearer/networkmanager/qnmdbushelper.cpp
@@ -60,7 +60,7 @@ QNmDBusHelper::~QNmDBusHelper()
void QNmDBusHelper::deviceStateChanged(quint32 state)
{
QDBusMessage msg = this->message();
- if(state == NM_DEVICE_STATE_ACTIVATED
+ if (state == NM_DEVICE_STATE_ACTIVATED
|| state == NM_DEVICE_STATE_DISCONNECTED
|| state == NM_DEVICE_STATE_UNAVAILABLE
|| state == NM_DEVICE_STATE_FAILED) {
@@ -70,18 +70,14 @@ void QNmDBusHelper::deviceStateChanged(quint32 state)
void QNmDBusHelper::slotAccessPointAdded(QDBusObjectPath path)
{
- if(path.path().length() > 2) {
- QDBusMessage msg = this->message();
- emit pathForAccessPointAdded(msg.path(), path);
- }
+ if (path.path().length() > 2)
+ emit pathForAccessPointAdded(path.path());
}
void QNmDBusHelper::slotAccessPointRemoved(QDBusObjectPath path)
{
- if(path.path().length() > 2) {
- QDBusMessage msg = this->message();
- emit pathForAccessPointRemoved(msg.path(), path);
- }
+ if (path.path().length() > 2)
+ emit pathForAccessPointRemoved(path.path());
}
void QNmDBusHelper::slotPropertiesChanged(QMap<QString,QVariant> map)
@@ -90,23 +86,29 @@ void QNmDBusHelper::slotPropertiesChanged(QMap<QString,QVariant> map)
QMapIterator<QString, QVariant> i(map);
while (i.hasNext()) {
i.next();
- if( i.key() == "State") { //state only applies to device interfaces
+ if (i.key() == QStringLiteral("State")) {
quint32 state = i.value().toUInt();
- if( state == NM_DEVICE_STATE_ACTIVATED
+ if (state == NM_DEVICE_STATE_ACTIVATED
|| state == NM_DEVICE_STATE_DISCONNECTED
|| state == NM_DEVICE_STATE_UNAVAILABLE
|| state == NM_DEVICE_STATE_FAILED) {
- emit pathForPropertiesChanged( msg.path(), map);
+ emit pathForPropertiesChanged(msg.path(), map);
}
- } else if( i.key() == "ActiveAccessPoint") {
+ } else if (i.key() == QStringLiteral("ActiveAccessPoint")) {
emit pathForPropertiesChanged(msg.path(), map);
- // qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value().value<QDBusObjectPath>().path();
- // } else if( i.key() == "Strength")
- // qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value().toUInt();
- // else
- // qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value();
- } else if (i.key() == "ActiveConnections") {
+ } else if (i.key() == QStringLiteral("ActiveConnections")) {
emit pathForPropertiesChanged(msg.path(), map);
+ } else if (i.key() == QStringLiteral("AvailableConnections")) {
+ const QDBusArgument &dbusArgs = i.value().value<QDBusArgument>();
+ QDBusObjectPath path;
+ QStringList paths;
+ dbusArgs.beginArray();
+ while (!dbusArgs.atEnd()) {
+ dbusArgs >> path;
+ paths << path.path();
+ }
+ dbusArgs.endArray();
+ emit pathForConnectionsChanged(paths);
}
}
}
@@ -117,6 +119,22 @@ void QNmDBusHelper::slotSettingsRemoved()
emit pathForSettingsRemoved(msg.path());
}
+void QNmDBusHelper::activeConnectionPropertiesChanged(QMap<QString,QVariant> map)
+{
+ QDBusMessage msg = this->message();
+ QMapIterator<QString, QVariant> i(map);
+ while (i.hasNext()) {
+ i.next();
+ if (i.key() == QStringLiteral("State")) {
+ quint32 state = i.value().toUInt();
+ if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED
+ || state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) {
+ emit pathForPropertiesChanged(msg.path(), map);
+ }
+ }
+ }
+}
+
QT_END_NAMESPACE
#endif // QT_NO_DBUS
diff --git a/src/plugins/bearer/networkmanager/qnmdbushelper.h b/src/plugins/bearer/networkmanager/qnmdbushelper.h
index cd5e8a3494..e224af87f1 100644
--- a/src/plugins/bearer/networkmanager/qnmdbushelper.h
+++ b/src/plugins/bearer/networkmanager/qnmdbushelper.h
@@ -51,17 +51,19 @@ class QNmDBusHelper: public QObject, protected QDBusContext
public slots:
void deviceStateChanged(quint32);
- void slotAccessPointAdded( QDBusObjectPath );
- void slotAccessPointRemoved( QDBusObjectPath );
- void slotPropertiesChanged( QMap<QString,QVariant>);
+ void slotAccessPointAdded(QDBusObjectPath);
+ void slotAccessPointRemoved(QDBusObjectPath);
+ void slotPropertiesChanged(QMap<QString,QVariant>);
void slotSettingsRemoved();
+ void activeConnectionPropertiesChanged(QMap<QString,QVariant>);
Q_SIGNALS:
void pathForStateChanged(const QString &, quint32);
- void pathForAccessPointAdded(const QString &, QDBusObjectPath );
- void pathForAccessPointRemoved(const QString &, QDBusObjectPath );
+ void pathForAccessPointAdded(const QString &);
+ void pathForAccessPointRemoved(const QString &);
void pathForPropertiesChanged(const QString &, QMap<QString,QVariant>);
void pathForSettingsRemoved(const QString &);
+ void pathForConnectionsChanged(const QStringList &pathsList);
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.h b/src/plugins/platforms/cocoa/qcocoaaccessibility.h
index 96dbd23695..3d1c95a0b4 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibility.h
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.h
@@ -70,6 +70,7 @@ namespace QCocoaAccessible {
*/
NSString *macRole(QAccessibleInterface *interface);
+NSString *macSubrole(QAccessibleInterface *interface);
bool shouldBeIgnored(QAccessibleInterface *interface);
NSArray *unignoredChildren(QAccessibleInterface *interface);
NSString *getTranslatedAction(const QString &qtAction);
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
index 1ade985b79..00baeddb39 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
@@ -162,7 +162,7 @@ static void populateRoleMap()
}
/*
- Returns a Mac accessibility role for the given interface, or
+ Returns a Cocoa accessibility role for the given interface, or
NSAccessibilityUnknownRole if no role mapping is found.
*/
NSString *macRole(QAccessibleInterface *interface)
@@ -190,13 +190,24 @@ NSString *macRole(QAccessibleInterface *interface)
}
/*
- Mac accessibility supports ignoring elements, which means that
+ Returns a Cocoa sub role for the given interface.
+*/
+NSString *macSubrole(QAccessibleInterface *interface)
+{
+ QAccessible::State s = interface->state();
+ if (s.searchEdit)
+ return NSAccessibilitySearchFieldSubrole;
+ return nil;
+}
+
+/*
+ Cocoa accessibility supports ignoring elements, which means that
the elements are still present in the accessibility tree but is
not used by the screen reader.
*/
bool shouldBeIgnored(QAccessibleInterface *interface)
{
- // Mac accessibility does not have an attribute that corresponds to the Invisible/Offscreen
+ // Cocoa accessibility does not have an attribute that corresponds to the Invisible/Offscreen
// state. Ignore interfaces with those flags set.
const QAccessible::State state = interface->state();
if (state.invisible ||
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
index 9f803e411d..dd76852b62 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
@@ -135,6 +135,7 @@
defaultAttributes = [[NSArray alloc] initWithObjects:
NSAccessibilityRoleAttribute,
NSAccessibilityRoleDescriptionAttribute,
+ NSAccessibilitySubroleAttribute,
NSAccessibilityChildrenAttribute,
NSAccessibilityFocusedAttribute,
NSAccessibilityParentAttribute,
@@ -221,6 +222,8 @@
if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) {
return role;
+ } else if ([attribute isEqualToString:NSAccessibilitySubroleAttribute]) {
+ return QCocoaAccessible::macSubrole(iface);
} else if ([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute]) {
return NSAccessibilityRoleDescription(role, nil);
} else if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) {
diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
index 326628a261..9f7609f24c 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
+++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
@@ -396,7 +396,7 @@ static void cleanupCocoaApplicationDelegate()
*/
QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationActive, true /*forcePropagate*/);
- return NO;
+ return YES;
}
- (void)setReflectionDelegate:(NSObject <NSApplicationDelegate> *)oldDelegate
diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm
index 2c8d391d2b..47b52c9fdd 100644
--- a/src/plugins/platforms/cocoa/qcocoadrag.mm
+++ b/src/plugins/platforms/cocoa/qcocoadrag.mm
@@ -132,7 +132,7 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
QMacPasteboard dragBoard((CFStringRef) NSDragPboard, QMacInternalPasteboardMime::MIME_DND);
m_drag->mimeData()->setData(QLatin1String("application/x-qt-mime-type-name"), QByteArray("dummy"));
- dragBoard.setMimeData(m_drag->mimeData());
+ dragBoard.setMimeData(m_drag->mimeData(), QMacPasteboard::LazyRequest);
NSPoint event_location = [m_lastEvent locationInWindow];
NSPoint local_point = [m_lastView convertPoint:event_location fromView:nil];
diff --git a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm
index 7322025df6..2101b68769 100644
--- a/src/plugins/platforms/cocoa/qcocoaprintdevice.mm
+++ b/src/plugins/platforms/cocoa/qcocoaprintdevice.mm
@@ -391,6 +391,9 @@ void QCocoaPrintDevice::loadDuplexModes() const
// If still no result, or not added in PPD, then add None
if (m_duplexModes.size() == 0 || !m_duplexModes.contains(QPrint::DuplexNone))
m_duplexModes.append(QPrint::DuplexNone);
+ // If have both modes, then can support DuplexAuto
+ if (m_duplexModes.contains(QPrint::DuplexLongSide) && m_duplexModes.contains(QPrint::DuplexShortSide))
+ m_duplexModes.append(QPrint::DuplexAuto);
m_haveDuplexModes = true;
}
diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
index 83c960d931..e449fd37d6 100755
--- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
+++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
@@ -187,6 +187,14 @@ void QCocoaSystemTrayIcon::cleanup()
m_sys = 0;
}
+static bool heightCompareFunction (QSize a, QSize b) { return (a.height() < b.height()); }
+static QList<QSize> sortByHeight(const QList<QSize> sizes)
+{
+ QList<QSize> sorted = sizes;
+ std::sort(sorted.begin(), sorted.end(), heightCompareFunction);
+ return sorted;
+}
+
void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon)
{
if (!m_sys)
@@ -196,16 +204,62 @@ void QCocoaSystemTrayIcon::updateIcon(const QIcon &icon)
const bool menuVisible = m_sys->item->menu && m_sys->item->menuVisible;
- CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
- const short scale = hgt - 4;
+ // The reccomended maximum title bar icon height is 18 points
+ // (device independent pixels). The menu height on past and
+ // current OS X versions is 22 points. Provide some future-proofing
+ // by deriving the icon height from the menu height.
+ const int padding = 4;
+ const int menuHeight = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
+ const int maxImageHeight = menuHeight - padding;
+
+ // Select pixmap based on the device pixel height. Ideally we would use
+ // the devicePixelRatio of the target screen, but that value is not
+ // known until draw time. Use qApp->devicePixelRatio, which returns the
+ // devicePixelRatio for the "best" screen on the system.
+ qreal devicePixelRatio = qApp->devicePixelRatio();
+ const int maxPixmapHeight = maxImageHeight * devicePixelRatio;
+ const QIcon::Mode mode = menuVisible ? QIcon::Selected : QIcon::Normal;
+ QSize selectedSize;
+ Q_FOREACH (const QSize& size, sortByHeight(icon.availableSizes(mode))) {
+ // Select a pixmap based on the height. We want the largest pixmap
+ // with a height smaller or equal to maxPixmapHeight. The pixmap
+ // may rectangular; assume it has a reasonable size. If there is
+ // not suitable pixmap use the smallest one the icon can provide.
+ if (size.height() <= maxPixmapHeight) {
+ selectedSize = size;
+ } else {
+ if (!selectedSize.isValid())
+ selectedSize = size;
+ break;
+ }
+ }
- QPixmap pm = m_sys->item->icon.pixmap(QSize(scale, scale),
- menuVisible ? QIcon::Selected : QIcon::Normal);
- if (pm.isNull()) {
- pm = QPixmap(scale, scale);
- pm.fill(Qt::transparent);
+ QPixmap pixmap = icon.pixmap(selectedSize, mode);
+
+ // Draw a low-resolution icon if there is not enough pixels for a retina
+ // icon. This prevents showing a small icon on retina displays.
+ if (devicePixelRatio > 1.0 && selectedSize.height() < maxPixmapHeight / 2)
+ devicePixelRatio = 1.0;
+
+ // Scale large pixmaps to fit the available menu bar area.
+ if (pixmap.height() > maxPixmapHeight)
+ pixmap = pixmap.scaledToHeight(maxPixmapHeight, Qt::SmoothTransformation);
+
+ // The icon will be stretched over the full height of the menu bar
+ // therefore we create a second pixmap which has the full height
+ QSize fullHeightSize(!pixmap.isNull() ? pixmap.width():
+ menuHeight * devicePixelRatio,
+ menuHeight * devicePixelRatio);
+ QPixmap fullHeightPixmap(fullHeightSize);
+ fullHeightPixmap.fill(Qt::transparent);
+ if (!pixmap.isNull()) {
+ QPainter p(&fullHeightPixmap);
+ QRect r = pixmap.rect();
+ r.moveCenter(fullHeightPixmap.rect().center());
+ p.drawPixmap(r, pixmap);
}
- NSImage *nsimage = static_cast<NSImage *>(qt_mac_create_nsimage(pm));
+
+ NSImage *nsimage = static_cast<NSImage *>(qt_mac_create_nsimage(fullHeightPixmap));
[(NSImageView*)[[m_sys->item item] view] setImage: nsimage];
[nsimage release];
}
@@ -327,18 +381,7 @@ QT_END_NAMESPACE
Q_UNUSED(notification);
down = NO;
- CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
- const short scale = hgt - 4;
-
- QPixmap pm = parent->icon.pixmap(QSize(scale, scale), QIcon::Normal);
- if (pm.isNull()) {
- pm = QPixmap(scale, scale);
- pm.fill(Qt::transparent);
- }
- NSImage *nsaltimage = static_cast<NSImage *>(qt_mac_create_nsimage(pm));
- [self setImage: nsaltimage];
- [nsaltimage release];
-
+ parent->systray->updateIcon(parent->icon);
parent->menuVisible = false;
[self setNeedsDisplay:YES];
@@ -350,18 +393,7 @@ QT_END_NAMESPACE
int clickCount = [mouseEvent clickCount];
[self setNeedsDisplay:YES];
- CGFloat hgt = [[[NSApplication sharedApplication] mainMenu] menuBarHeight];
- const short scale = hgt - 4;
-
- QPixmap pm = parent->icon.pixmap(QSize(scale, scale),
- parent->menuVisible ? QIcon::Selected : QIcon::Normal);
- if (pm.isNull()) {
- pm = QPixmap(scale, scale);
- pm.fill(Qt::transparent);
- }
- NSImage *nsaltimage = static_cast<NSImage *>(qt_mac_create_nsimage(pm));
- [self setImage: nsaltimage];
- [nsaltimage release];
+ parent->systray->updateIcon(parent->icon);
if (clickCount == 2) {
[self menuTrackingDone:nil];
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 9259c2c772..3366e5bc3c 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -699,7 +699,7 @@ void QCocoaWindow::setVisible(bool visible)
exposeWindow();
if (m_nsWindow) {
- QWindowSystemInterface::flushWindowSystemEvents();
+ QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
// setWindowState might have been called while the window was hidden and
// will not change the NSWindow state in that case. Sync up here:
@@ -1009,9 +1009,12 @@ void QCocoaWindow::raise()
[parentNSWindow addChildWindow:m_nsWindow ordered:NSWindowAbove];
} else {
[m_nsWindow orderFront: m_nsWindow];
- ProcessSerialNumber psn;
- GetCurrentProcess(&psn);
- SetFrontProcessWithOptions(&psn, kSetFrontProcessFrontWindowOnly);
+ static bool raiseProcess = qt_mac_resolveOption(true, "QT_MAC_SET_RAISE_PROCESS");
+ if (raiseProcess) {
+ ProcessSerialNumber psn;
+ GetCurrentProcess(&psn);
+ SetFrontProcessWithOptions(&psn, kSetFrontProcessFrontWindowOnly);
+ }
}
}
}
diff --git a/src/plugins/platforms/cocoa/qmacclipboard.h b/src/plugins/platforms/cocoa/qmacclipboard.h
index ba7a2e1aac..c5b6224545 100644
--- a/src/plugins/platforms/cocoa/qmacclipboard.h
+++ b/src/plugins/platforms/cocoa/qmacclipboard.h
@@ -43,15 +43,25 @@
QT_BEGIN_NAMESPACE
+class QMacMimeData;
class QMacPasteboard
{
+public:
+ enum DataRequestType { EagerRequest, LazyRequest };
+private:
struct Promise {
Promise() : itemId(0), convertor(0) { }
- Promise(int itemId, QMacInternalPasteboardMime *c, QString m, QVariant d, int o=0) : itemId(itemId), offset(o), convertor(c), mime(m), data(d) { }
+
+ static Promise eagerPromise(int itemId, QMacInternalPasteboardMime *c, QString m, QMacMimeData *d, int o = 0);
+ static Promise lazyPromise(int itemId, QMacInternalPasteboardMime *c, QString m, QMacMimeData *d, int o = 0);
+ Promise(int itemId, QMacInternalPasteboardMime *c, QString m, QMacMimeData *md, int o, DataRequestType drt);
+
int itemId, offset;
QMacInternalPasteboardMime *convertor;
QString mime;
- QVariant data;
+ QPointer<QMacMimeData> mimeData;
+ QVariant variantData;
+ DataRequestType dataRequestType;
};
QList<Promise> promises;
@@ -72,7 +82,8 @@ public:
PasteboardRef pasteBoard() const;
QMimeData *mimeData() const;
- void setMimeData(QMimeData *mime);
+
+ void setMimeData(QMimeData *mime, DataRequestType dataRequestType = EagerRequest);
QStringList formats() const;
bool hasFormat(const QString &format) const;
diff --git a/src/plugins/platforms/cocoa/qmacclipboard.mm b/src/plugins/platforms/cocoa/qmacclipboard.mm
index 65665ef790..b235625921 100644
--- a/src/plugins/platforms/cocoa/qmacclipboard.mm
+++ b/src/plugins/platforms/cocoa/qmacclipboard.mm
@@ -64,6 +64,26 @@ QT_BEGIN_NAMESPACE
QMacPasteboard code
*****************************************************************************/
+class QMacMimeData : public QMimeData
+{
+public:
+ QVariant variantData(const QString &mime) { return retrieveData(mime, QVariant::Invalid); }
+private:
+ QMacMimeData();
+};
+
+QMacPasteboard::Promise::Promise(int itemId, QMacInternalPasteboardMime *c, QString m, QMacMimeData *md, int o, DataRequestType drt)
+ : itemId(itemId), offset(o), convertor(c), mime(m), dataRequestType(drt)
+{
+ // Request the data from the application immediately for eager requests.
+ if (dataRequestType == QMacPasteboard::EagerRequest) {
+ variantData = md->variantData(m);
+ mimeData = 0;
+ } else {
+ mimeData = md;
+ }
+}
+
QMacPasteboard::QMacPasteboard(PasteboardRef p, uchar mt)
{
mac_mime_source = false;
@@ -103,6 +123,11 @@ QMacPasteboard::~QMacPasteboard()
// commit all promises for paste after exit close
for (int i = 0; i < promises.count(); ++i) {
const Promise &promise = promises.at(i);
+ // At this point app teardown has started and control is somewhere in the Q[Core]Application
+ // destructor. Skip "lazy" promises where the application has not provided data;
+ // the application will generally not be in a state to provide it.
+ if (promise.dataRequestType == LazyRequest)
+ continue;
QCFString flavor = QCFString(promise.convertor->flavorFor(promise.mime));
NSInteger pbItemId = promise.itemId;
promiseKeeper(paste, reinterpret_cast<PasteboardItemID>(pbItemId), flavor, this);
@@ -155,7 +180,17 @@ OSStatus QMacPasteboard::promiseKeeper(PasteboardRef paste, PasteboardItemID id,
qPrintable(flavorAsQString), qPrintable(promise.convertor->convertorName()), promise.offset);
#endif
- QList<QByteArray> md = promise.convertor->convertFromMime(promise.mime, promise.data, flavorAsQString);
+ // Get the promise data. If this is a "lazy" promise call variantData()
+ // to request the data from the application.
+ QVariant promiseData;
+ if (promise.dataRequestType == LazyRequest) {
+ if (!promise.mimeData.isNull())
+ promiseData = promise.mimeData->variantData(promise.mime);
+ } else {
+ promiseData = promise.variantData;
+ }
+
+ QList<QByteArray> md = promise.convertor->convertFromMime(promise.mime, promiseData, flavorAsQString);
if (md.size() <= promise.offset)
return cantGetFlavorErr;
const QByteArray &ba = md[promise.offset];
@@ -266,16 +301,8 @@ QMimeData
return mime;
}
-class QMacMimeData : public QMimeData
-{
-public:
- QVariant variantData(const QString &mime) { return retrieveData(mime, QVariant::Invalid); }
-private:
- QMacMimeData();
-};
-
void
-QMacPasteboard::setMimeData(QMimeData *mime_src)
+QMacPasteboard::setMimeData(QMimeData *mime_src, DataRequestType dataRequestType)
{
if (!paste)
return;
@@ -312,12 +339,17 @@ QMacPasteboard::setMimeData(QMimeData *mime_src)
continue;
QString flavor(c->flavorFor(mimeType));
if (!flavor.isEmpty()) {
- QVariant mimeData = static_cast<QMacMimeData*>(mime_src)->variantData(mimeType);
+ QMacMimeData *mimeData = static_cast<QMacMimeData*>(mime_src);
int numItems = c->count(mime_src);
for (int item = 0; item < numItems; ++item) {
const NSInteger itemID = item+1; //id starts at 1
- promises.append(QMacPasteboard::Promise(itemID, c, mimeType, mimeData, item));
+ //QMacPasteboard::Promise promise = (dataRequestType == QMacPasteboard::EagerRequest) ?
+ // QMacPasteboard::Promise::eagerPromise(itemID, c, mimeType, mimeData, item) :
+ // QMacPasteboard::Promise::lazyPromise(itemID, c, mimeType, mimeData, item);
+
+ QMacPasteboard::Promise promise(itemID, c, mimeType, mimeData, item, dataRequestType);
+ promises.append(promise);
PasteboardPutItemFlavor(paste, reinterpret_cast<PasteboardItemID>(itemID), QCFString(flavor), 0, kPasteboardFlavorNoFlags);
#ifdef DEBUG_PASTEBOARD
qDebug(" - adding %d %s [%s] <%s> [%d]",
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 06680228bc..ca98f6cec3 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -361,8 +361,12 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
// Send a geometry change event to Qt, if it's ready to handle events
if (!m_platformWindow->m_inConstructor) {
QWindowSystemInterface::handleGeometryChange(m_window, geometry);
- m_platformWindow->updateExposedGeometry();
- QWindowSystemInterface::flushWindowSystemEvents();
+ // Do not send incorrect exposes in case the window is not even visible yet.
+ // We might get here as a result of a resize() from QWidget's show(), for instance.
+ if (m_platformWindow->window()->isVisible()) {
+ m_platformWindow->updateExposedGeometry();
+ QWindowSystemInterface::flushWindowSystemEvents();
+ }
}
}
@@ -420,10 +424,12 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
#pragma clang diagnostic ignored "-Wobjc-method-access"
enum { NSWindowOcclusionStateVisible = 1UL << 1 };
#endif
+ // Older versions managed in -[QNSView viewDidMoveToWindow].
+ // Support QWidgetAction in NSMenu. Mavericks only sends this notification.
+ // Ideally we should support this in Qt as well, in order to disable animations
+ // when the window is occluded.
if ((NSUInteger)[self.window occlusionState] & NSWindowOcclusionStateVisible)
m_platformWindow->exposeWindow();
- else
- m_platformWindow->obscureWindow();
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9
#pragma clang diagnostic pop
#endif
@@ -686,7 +692,23 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
m_platformWindow->m_forwardWindow = 0;
}
- [targetView convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&qtWindowPoint andScreenPoint:&qtScreenPoint];
+ NSPoint globalPos = [NSEvent mouseLocation];
+
+ if ([self.window parentWindow]
+ && (theEvent.type == NSLeftMouseDragged || theEvent.type == NSLeftMouseUp)) {
+ // QToolBar can be implemented as a child window on top of its main window
+ // (with a borderless NSWindow). If an option "unified toolbar" set on the main window,
+ // it's possible to drag such a window using this toolbar.
+ // While handling mouse drag events, QToolBar moves the window (QWidget::move).
+ // In such a combination [NSEvent mouseLocation] is very different from the
+ // real event location and as a result a window will move chaotically.
+ NSPoint winPoint = [theEvent locationInWindow];
+ NSRect tmpRect = NSMakeRect(winPoint.x, winPoint.y, 1., 1.);
+ tmpRect = [[theEvent window] convertRectToScreen:tmpRect];
+ globalPos = tmpRect.origin;
+ }
+
+ [targetView convertFromScreen:globalPos toWindowPoint:&qtWindowPoint andScreenPoint:&qtScreenPoint];
ulong timestamp = [theEvent timestamp] * 1000;
QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag();
@@ -699,6 +721,10 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
- (void)handleFrameStrutMouseEvent:(NSEvent *)theEvent
{
// get m_buttons in sync
+ // Don't send frme strut events if we are in the middle of a mouse drag.
+ if (m_buttons != Qt::NoButton)
+ return;
+
NSEventType ty = [theEvent type];
switch (ty) {
case NSLeftMouseDown:
@@ -710,6 +736,12 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
case NSRightMouseDown:
m_frameStrutButtons |= Qt::RightButton;
break;
+ case NSLeftMouseDragged:
+ m_frameStrutButtons |= Qt::LeftButton;
+ break;
+ case NSRightMouseDragged:
+ m_frameStrutButtons |= Qt::RightButton;
+ break;
case NSRightMouseUp:
m_frameStrutButtons &= ~Qt::RightButton;
break;
@@ -1337,10 +1369,6 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
}
QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_screenPoint, pixelDelta, angleDelta, currentWheelModifiers, ph);
-
- if (momentumPhase == NSEventPhaseEnded || momentumPhase == NSEventPhaseCancelled || momentumPhase == NSEventPhaseNone) {
- currentWheelModifiers = Qt::NoModifier;
- }
} else
#endif
{
@@ -1806,6 +1834,19 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin
return NO;
}
+- (BOOL)wantsPeriodicDraggingUpdates
+{
+ // From the documentation:
+ //
+ // "If the destination returns NO, these messages are sent only when the mouse moves
+ // or a modifier flag changes. Otherwise the destination gets the default behavior,
+ // where it receives periodic dragging-updated messages even if nothing changes."
+ //
+ // We do not want these constant drag update events while mouse is stationary,
+ // since we do all animations (autoscroll) with timers.
+ return NO;
+}
+
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
return [self handleDrag : sender];
diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm
index fb968f31e9..f684fef233 100644
--- a/src/plugins/platforms/cocoa/qprintengine_mac.mm
+++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm
@@ -457,9 +457,6 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
break;
case PPK_CustomBase:
break;
- case PPK_Duplex:
- // TODO Add support using PMSetDuplex / PMGetDuplex
- break;
case PPK_FontEmbedding:
break;
case PPK_PageOrder:
@@ -503,6 +500,29 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
case PPK_DocumentName:
PMPrintSettingsSetJobName(d->settings(), QCFString(value.toString()));
break;
+ case PPK_Duplex: {
+ QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+ if (mode == property(PPK_Duplex).toInt() || !d->m_printDevice->supportedDuplexModes().contains(mode))
+ break;
+ switch (mode) {
+ case QPrinter::DuplexNone:
+ PMSetDuplex(d->settings(), kPMDuplexNone);
+ break;
+ case QPrinter::DuplexAuto:
+ PMSetDuplex(d->settings(), d->m_pageLayout.orientation() == QPageLayout::Landscape ? kPMDuplexTumble : kPMDuplexNoTumble);
+ break;
+ case QPrinter::DuplexLongSide:
+ PMSetDuplex(d->settings(), kPMDuplexNoTumble);
+ break;
+ case QPrinter::DuplexShortSide:
+ PMSetDuplex(d->settings(), kPMDuplexTumble);
+ break;
+ default:
+ // Don't change
+ break;
+ }
+ break;
+ }
case PPK_FullPage:
if (value.toBool())
d->m_pageLayout.setMode(QPageLayout::FullPageMode);
@@ -602,10 +622,6 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const
case PPK_CustomBase:
// Special case, leave null
break;
- case PPK_Duplex:
- // TODO Add support using PMSetDuplex / PMGetDuplex
- ret = QPrinter::DuplexNone;
- break;
case PPK_FontEmbedding:
ret = false;
break;
@@ -647,6 +663,23 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const
ret = QCFString::toQString(name);
break;
}
+ case PPK_Duplex: {
+ PMDuplexMode mode = kPMDuplexNone;
+ PMGetDuplex(d->settings(), &mode);
+ switch (mode) {
+ case kPMDuplexNoTumble:
+ ret = QPrinter::DuplexLongSide;
+ break;
+ case kPMDuplexTumble:
+ ret = QPrinter::DuplexShortSide;
+ break;
+ case kPMDuplexNone:
+ default:
+ ret = QPrinter::DuplexNone;
+ break;
+ }
+ break;
+ }
case PPK_FullPage:
ret = d->m_pageLayout.mode() == QPageLayout::FullPageMode;
break;
diff --git a/src/plugins/platforms/ios/qioseventdispatcher.mm b/src/plugins/platforms/ios/qioseventdispatcher.mm
index 821599d113..ce7dfe2606 100644
--- a/src/plugins/platforms/ios/qioseventdispatcher.mm
+++ b/src/plugins/platforms/ios/qioseventdispatcher.mm
@@ -259,10 +259,16 @@ static void __attribute__((noinline, noreturn)) user_main_trampoline()
NSArray *arguments = [[NSProcessInfo processInfo] arguments];
int argc = arguments.count;
char **argv = new char*[argc];
+
for (int i = 0; i < argc; ++i) {
NSString *arg = [arguments objectAtIndex:i];
- argv[i] = reinterpret_cast<char *>(malloc([arg lengthOfBytesUsingEncoding:[NSString defaultCStringEncoding]]));
- strcpy(argv[i], [arg cStringUsingEncoding:[NSString defaultCStringEncoding]]);
+
+ NSStringEncoding cStringEncoding = [NSString defaultCStringEncoding];
+ unsigned int bufferSize = [arg lengthOfBytesUsingEncoding:cStringEncoding] + 1;
+ argv[i] = reinterpret_cast<char *>(malloc(bufferSize));
+
+ if (![arg getCString:argv[i] maxLength:bufferSize encoding:cStringEncoding])
+ qFatal("Could not convert argv[%d] to C string", i);
}
int exitCode = qtmn(argc, argv);
diff --git a/src/plugins/platforms/ios/quiaccessibilityelement.mm b/src/plugins/platforms/ios/quiaccessibilityelement.mm
index 331c38460c..63b6827ad3 100644
--- a/src/plugins/platforms/ios/quiaccessibilityelement.mm
+++ b/src/plugins/platforms/ios/quiaccessibilityelement.mm
@@ -152,6 +152,9 @@
if (state.disabled)
traits |= UIAccessibilityTraitNotEnabled;
+ if (state.searchEdit)
+ traits |= UIAccessibilityTraitSearchField;
+
if (iface->role() == QAccessible::Button)
traits |= UIAccessibilityTraitButton;
diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp
index d2460e0640..f5d6c140bf 100644
--- a/src/plugins/platforms/windows/qwindowscursor.cpp
+++ b/src/plugins/platforms/windows/qwindowscursor.cpp
@@ -48,6 +48,13 @@
#include <QtCore/QDebug>
#include <QtCore/QScopedArrayPointer>
+static void initResources()
+{
+#if !defined (Q_OS_WINCE) && !defined (QT_NO_IMAGEFORMAT_PNG)
+ Q_INIT_RESOURCE(cursors);
+#endif
+}
+
QT_BEGIN_NAMESPACE
Q_GUI_EXPORT HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat = 0);
@@ -568,6 +575,11 @@ QWindowsWindowCursor QWindowsCursor::pixmapWindowCursor(const QCursor &c)
return it.value();
}
+QWindowsCursor::QWindowsCursor()
+{
+ initResources();
+}
+
/*!
\brief Set a cursor on a window.
diff --git a/src/plugins/platforms/windows/qwindowscursor.h b/src/plugins/platforms/windows/qwindowscursor.h
index c8e1df3f4d..a024646553 100644
--- a/src/plugins/platforms/windows/qwindowscursor.h
+++ b/src/plugins/platforms/windows/qwindowscursor.h
@@ -91,7 +91,7 @@ public:
CursorSuppressed // Cursor suppressed by touch interaction (Windows 8).
};
- QWindowsCursor() {}
+ QWindowsCursor();
void changeCursor(QCursor * widgetCursor, QWindow * widget) Q_DECL_OVERRIDE;
QPoint pos() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index dd9b9de0b6..8a80729354 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -1149,6 +1149,13 @@ void QWindowsWindow::updateTransientParent() const
#endif // !Q_OS_WINCE
}
+static inline bool testShowWithoutActivating(const QWindow *window)
+{
+ // QWidget-attribute Qt::WA_ShowWithoutActivating .
+ const QVariant showWithoutActivating = window->property("_q_showWithoutActivating");
+ return showWithoutActivating.isValid() && showWithoutActivating.toBool();
+}
+
// partially from QWidgetPrivate::show_sys()
void QWindowsWindow::show_sys() const
{
@@ -1180,7 +1187,7 @@ void QWindowsWindow::show_sys() const
} // Qt::WindowMaximized
} // !Qt::WindowMinimized
}
- if (type == Qt::Popup || type == Qt::ToolTip || type == Qt::Tool)
+ if (type == Qt::Popup || type == Qt::ToolTip || type == Qt::Tool || testShowWithoutActivating(w))
sm = SW_SHOWNOACTIVATE;
if (w->windowState() & Qt::WindowMaximized)
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
index fc3443aba5..dae3a79628 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
@@ -910,6 +910,18 @@ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
if (qtKey == baseQtKey || qtKey == 0)
continue;
+ // catch only more specific shortcuts, i.e. Ctrl+Shift+= also generates Ctrl++ and +,
+ // but Ctrl++ is more specific than +, so we should skip the last one
+ bool ambiguous = false;
+ foreach (int shortcut, result) {
+ if (int(shortcut & ~Qt::KeyboardModifierMask) == qtKey && (shortcut & mods) == mods) {
+ ambiguous = true;
+ break;
+ }
+ }
+ if (ambiguous)
+ continue;
+
result += (qtKey + mods);
}
}
diff --git a/src/plugins/printsupport/cups/qcupsprintengine.cpp b/src/plugins/printsupport/cups/qcupsprintengine.cpp
index 724ff5b98b..d7cd18f1d1 100644
--- a/src/plugins/printsupport/cups/qcupsprintengine.cpp
+++ b/src/plugins/printsupport/cups/qcupsprintengine.cpp
@@ -85,6 +85,12 @@ void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &v
// Get the named page size from the printer if supported
d->setPageSize(d->m_printDevice.supportedPageSize(value.toString()));
break;
+ case PPK_Duplex: {
+ QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+ if (mode != d->duplex && d->m_printDevice.supportedDuplexModes().contains(mode))
+ d->duplex = mode;
+ break;
+ }
case PPK_PrinterName:
d->changePrinter(value.toString());
break;
diff --git a/src/plugins/printsupport/cups/qppdprintdevice.cpp b/src/plugins/printsupport/cups/qppdprintdevice.cpp
index 75e8a8bf26..7a6acf8b78 100644
--- a/src/plugins/printsupport/cups/qppdprintdevice.cpp
+++ b/src/plugins/printsupport/cups/qppdprintdevice.cpp
@@ -387,6 +387,9 @@ void QPpdPrintDevice::loadDuplexModes() const
// If still no result, or not added in PPD, then add None
if (m_duplexModes.size() == 0 || !m_duplexModes.contains(QPrint::DuplexNone))
m_duplexModes.append(QPrint::DuplexNone);
+ // If have both modes, then can support DuplexAuto
+ if (m_duplexModes.contains(QPrint::DuplexLongSide) && m_duplexModes.contains(QPrint::DuplexShortSide))
+ m_duplexModes.append(QPrint::DuplexAuto);
m_haveDuplexModes = true;
}
diff --git a/src/plugins/printsupport/windows/qwindowsprintdevice.cpp b/src/plugins/printsupport/windows/qwindowsprintdevice.cpp
index 1a6f40722d..a0a549da6f 100644
--- a/src/plugins/printsupport/windows/qwindowsprintdevice.cpp
+++ b/src/plugins/printsupport/windows/qwindowsprintdevice.cpp
@@ -271,7 +271,7 @@ QMarginsF QWindowsPrintDevice::printableMargins(const QPageSize &pageSize,
const qreal rightMargin = physicalWidth - leftMargin - printableWidth;
const qreal bottomMargin = physicalHeight - topMargin - printableHeight;
margins = QMarginsF(leftMargin, topMargin, rightMargin, bottomMargin);
- ReleaseDC(NULL, pDC);
+ DeleteDC(pDC);
}
return margins;
}
@@ -280,11 +280,11 @@ void QWindowsPrintDevice::loadResolutions() const
{
DWORD resCount = DeviceCapabilities((LPWSTR)m_id.utf16(), NULL, DC_ENUMRESOLUTIONS, NULL, NULL);
if (int(resCount) > 0) {
- QScopedArrayPointer<LONG> resolutions(new LONG[resCount*sizeof(LONG)]);
+ QScopedArrayPointer<LONG> resolutions(new LONG[resCount*2]);
// Get the details and match the default paper size
if (DeviceCapabilities((LPWSTR)m_id.utf16(), NULL, DC_ENUMRESOLUTIONS, (LPWSTR)resolutions.data(), NULL) == resCount) {
- for (int i = 0; i < int(resCount); ++i)
- m_resolutions.append(resolutions[i]);
+ for (int i = 0; i < int(resCount * 2); i += 2)
+ m_resolutions.append(resolutions[i+1]);
}
}
m_haveResolutions = true;
@@ -378,6 +378,7 @@ void QWindowsPrintDevice::loadDuplexModes() const
DWORD duplex = DeviceCapabilities((LPWSTR)m_id.utf16(), NULL, DC_DUPLEX, NULL, NULL);
if (int(duplex) == 1) {
// TODO Assume if duplex flag supports both modes
+ m_duplexModes.append(QPrint::DuplexAuto);
m_duplexModes.append(QPrint::DuplexLongSide);
m_duplexModes.append(QPrint::DuplexShortSide);
}
diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp
index 14ffcaca96..90b204eb0c 100644
--- a/src/printsupport/kernel/qprintengine_win.cpp
+++ b/src/printsupport/kernel/qprintengine_win.cpp
@@ -734,10 +734,7 @@ void QWin32PrintEnginePrivate::strokePath_dev(const QPainterPath &path, const QC
else if (pen.joinStyle() == Qt::RoundJoin)
joinStyle = PS_JOIN_ROUND;
- bool cosmetic = qt_pen_is_cosmetic(pen, q->state->renderHints());
-
- HPEN pen = ExtCreatePen((cosmetic ? PS_COSMETIC : PS_GEOMETRIC)
- | PS_SOLID | capStyle | joinStyle,
+ HPEN pen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID | capStyle | joinStyle,
(penWidth == 0) ? 1 : penWidth, &brush, 0, 0);
HGDIOBJ old_pen = SelectObject(hdc, pen);
@@ -1006,9 +1003,6 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
// The following keys are settings that are unsupported by the Windows PrintEngine
case PPK_CustomBase:
break;
- case PPK_Duplex:
- // TODO Add support using DEVMODE.dmDuplex
- break;
case PPK_FontEmbedding:
break;
case PPK_PageOrder:
@@ -1049,6 +1043,33 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &
d->docName = value.toString();
break;
+ case PPK_Duplex: {
+ if (!d->devMode)
+ break;
+ QPrint::DuplexMode mode = QPrint::DuplexMode(value.toInt());
+ if (mode == property(PPK_Duplex).toInt() || !d->m_printDevice.supportedDuplexModes().contains(mode))
+ break;
+ switch (mode) {
+ case QPrinter::DuplexNone:
+ d->devMode->dmDuplex = DMDUP_SIMPLEX;
+ break;
+ case QPrinter::DuplexAuto:
+ d->devMode->dmDuplex = d->m_pageLayout.orientation() == QPageLayout::Landscape ? DMDUP_HORIZONTAL : DMDUP_VERTICAL;
+ break;
+ case QPrinter::DuplexLongSide:
+ d->devMode->dmDuplex = DMDUP_VERTICAL;
+ break;
+ case QPrinter::DuplexShortSide:
+ d->devMode->dmDuplex = DMDUP_HORIZONTAL;
+ break;
+ default:
+ // Don't change
+ break;
+ }
+ d->doReinit();
+ break;
+ }
+
case PPK_FullPage:
if (value.toBool())
d->m_pageLayout.setMode(QPageLayout::FullPageMode);
@@ -1263,10 +1284,6 @@ QVariant QWin32PrintEngine::property(PrintEnginePropertyKey key) const
// The following keys are settings that are unsupported by the Windows PrintEngine
// Return sensible default values to ensure consistent behavior across platforms
- case PPK_Duplex:
- // TODO Add support using DEVMODE.dmDuplex
- value = QPrinter::DuplexNone;
- break;
case PPK_FontEmbedding:
value = false;
break;
@@ -1303,6 +1320,26 @@ QVariant QWin32PrintEngine::property(PrintEnginePropertyKey key) const
value = d->docName;
break;
+ case PPK_Duplex: {
+ if (!d->devMode) {
+ value = QPrinter::DuplexNone;
+ } else {
+ switch (d->devMode->dmDuplex) {
+ case DMDUP_VERTICAL:
+ value = QPrinter::DuplexLongSide;
+ break;
+ case DMDUP_HORIZONTAL:
+ value = QPrinter::DuplexShortSide;
+ break;
+ case DMDUP_SIMPLEX:
+ default:
+ value = QPrinter::DuplexNone;
+ break;
+ }
+ }
+ break;
+ }
+
case PPK_FullPage:
value = d->m_pageLayout.mode() == QPageLayout::FullPageMode;
break;
diff --git a/src/printsupport/kernel/qprinter.cpp b/src/printsupport/kernel/qprinter.cpp
index 8d62580d67..c13b1574d0 100644
--- a/src/printsupport/kernel/qprinter.cpp
+++ b/src/printsupport/kernel/qprinter.cpp
@@ -1678,9 +1678,11 @@ bool QPrinter::fontEmbeddingEnabled() const
/*!
\since 4.2
+ \obsolete Use setDuplex() instead.
+
Enables double sided printing if \a doubleSided is true; otherwise disables it.
- Currently this option is only supported on X11.
+ \sa setDuplex()
*/
void QPrinter::setDoubleSidedPrinting(bool doubleSided)
{
@@ -1691,9 +1693,11 @@ void QPrinter::setDoubleSidedPrinting(bool doubleSided)
/*!
\since 4.2
+ \obsolete Use duplex() instead.
+
Returns \c true if double side printing is enabled.
- Currently this option is only supported on X11.
+ \sa duplex()
*/
bool QPrinter::doubleSidedPrinting() const
{
@@ -1705,7 +1709,7 @@ bool QPrinter::doubleSidedPrinting() const
Enables double sided printing based on the \a duplex mode.
- Currently this option is only supported on X11.
+ \sa duplex()
*/
void QPrinter::setDuplex(DuplexMode duplex)
{
@@ -1718,7 +1722,7 @@ void QPrinter::setDuplex(DuplexMode duplex)
Returns the current duplex mode.
- Currently this option is only supported on X11.
+ \sa setDuplex()
*/
QPrinter::DuplexMode QPrinter::duplex() const
{
diff --git a/src/printsupport/kernel/qprinterinfo.cpp b/src/printsupport/kernel/qprinterinfo.cpp
index b1321bf57a..a17da3fdaa 100644
--- a/src/printsupport/kernel/qprinterinfo.cpp
+++ b/src/printsupport/kernel/qprinterinfo.cpp
@@ -353,6 +353,33 @@ QList<int> QPrinterInfo::supportedResolutions() const
}
/*!
+ Returns the default duplex mode of this printer.
+
+ \since 5.4
+*/
+
+QPrinter::DuplexMode QPrinterInfo::defaultDuplexMode() const
+{
+ Q_D(const QPrinterInfo);
+ return QPrinter::DuplexMode(d->m_printDevice.defaultDuplexMode());
+}
+
+/*!
+ Returns a list of duplex modes supported by this printer.
+
+ \since 5.4
+*/
+
+QList<QPrinter::DuplexMode> QPrinterInfo::supportedDuplexModes() const
+{
+ Q_D(const QPrinterInfo);
+ QList<QPrinter::DuplexMode> list;
+ foreach (QPrint::DuplexMode mode, d->m_printDevice.supportedDuplexModes())
+ list << QPrinter::DuplexMode(mode);
+ return list;
+}
+
+/*!
Returns a list of all the available Printer Names on this system.
It is recommended to use this instead of availablePrinters() as
diff --git a/src/printsupport/kernel/qprinterinfo.h b/src/printsupport/kernel/qprinterinfo.h
index a4754c48dc..58d3873492 100644
--- a/src/printsupport/kernel/qprinterinfo.h
+++ b/src/printsupport/kernel/qprinterinfo.h
@@ -82,6 +82,9 @@ public:
QList<int> supportedResolutions() const;
+ QPrinter::DuplexMode defaultDuplexMode() const;
+ QList<QPrinter::DuplexMode> supportedDuplexModes() const;
+
static QStringList availablePrinterNames();
static QList<QPrinterInfo> availablePrinters();
diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp
index 31f0e2dc9e..dbc95dc5a8 100644
--- a/src/sql/kernel/qsqldatabase.cpp
+++ b/src/sql/kernel/qsqldatabase.cpp
@@ -1503,15 +1503,18 @@ QSql::NumericalPrecisionPolicy QSqlDatabase::numericalPrecisionPolicy() const
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QSqlDatabase &d)
{
+ QDebugStateSaver saver(dbg);
+ dbg.nospace();
+ dbg.noquote();
if (!d.isValid()) {
- dbg.nospace() << "QSqlDatabase(invalid)";
- return dbg.space();
+ dbg << "QSqlDatabase(invalid)";
+ return dbg;
}
- dbg.nospace() << "QSqlDatabase(driver=\"" << d.driverName() << "\", database=\""
- << d.databaseName() << "\", host=\"" << d.hostName() << "\", port=" << d.port()
- << ", user=\"" << d.userName() << "\", open=" << d.isOpen() << ")";
- return dbg.space();
+ dbg << "QSqlDatabase(driver=\"" << d.driverName() << "\", database=\""
+ << d.databaseName() << "\", host=\"" << d.hostName() << "\", port=" << d.port()
+ << ", user=\"" << d.userName() << "\", open=" << d.isOpen() << ')';
+ return dbg;
}
#endif
diff --git a/src/sql/kernel/qsqlerror.cpp b/src/sql/kernel/qsqlerror.cpp
index b80b471dfc..470bf57d44 100644
--- a/src/sql/kernel/qsqlerror.cpp
+++ b/src/sql/kernel/qsqlerror.cpp
@@ -39,9 +39,11 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QSqlError &s)
{
- dbg.nospace() << "QSqlError(" << s.nativeErrorCode() << ", " << s.driverText() <<
- ", " << s.databaseText() << ')';
- return dbg.space();
+ QDebugStateSaver saver(dbg);
+ dbg.nospace();
+ dbg << "QSqlError(" << s.nativeErrorCode() << ", " << s.driverText()
+ << ", " << s.databaseText() << ')';
+ return dbg;
}
#endif
diff --git a/src/sql/kernel/qsqlfield.cpp b/src/sql/kernel/qsqlfield.cpp
index dfd4712071..3fd2c68296 100644
--- a/src/sql/kernel/qsqlfield.cpp
+++ b/src/sql/kernel/qsqlfield.cpp
@@ -509,21 +509,24 @@ bool QSqlField::isValid() const
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QSqlField &f)
{
- dbg.nospace() << "QSqlField(" << f.name() << ", " << QMetaType::typeName(f.type());
+ QDebugStateSaver saver(dbg);
+ dbg.nospace();
+ dbg << "QSqlField(" << f.name() << ", " << QMetaType::typeName(f.type());
if (f.length() >= 0)
- dbg.nospace() << ", length: " << f.length();
+ dbg << ", length: " << f.length();
if (f.precision() >= 0)
- dbg.nospace() << ", precision: " << f.precision();
+ dbg << ", precision: " << f.precision();
if (f.requiredStatus() != QSqlField::Unknown)
- dbg.nospace() << ", required: "
- << (f.requiredStatus() == QSqlField::Required ? "yes" : "no");
- dbg.nospace() << ", generated: " << (f.isGenerated() ? "yes" : "no");
+ dbg << ", required: "
+ << (f.requiredStatus() == QSqlField::Required ? "yes" : "no");
+ dbg << ", generated: " << (f.isGenerated() ? "yes" : "no");
if (f.typeID() >= 0)
- dbg.nospace() << ", typeID: " << f.typeID();
+ dbg << ", typeID: " << f.typeID();
if (!f.defaultValue().isNull())
- dbg.nospace() << ", auto-value: \"" << f.defaultValue() << '\"';
- dbg.nospace() << ')';
- return dbg.space();
+ dbg << ", defaultValue: \"" << f.defaultValue() << '\"';
+ dbg << ", autoValue: " << f.isAutoValue()
+ << ", readOnly: " << f.isReadOnly() << ')';
+ return dbg;
}
#endif
diff --git a/src/sql/kernel/qsqlrecord.cpp b/src/sql/kernel/qsqlrecord.cpp
index 7fd64d1307..668392bb5b 100644
--- a/src/sql/kernel/qsqlrecord.cpp
+++ b/src/sql/kernel/qsqlrecord.cpp
@@ -509,9 +509,16 @@ void QSqlRecord::detach()
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QSqlRecord &r)
{
- dbg << "QSqlRecord(" << r.count() << ')';
- for (int i = 0; i < r.count(); ++i)
- dbg << '\n' << QString::fromLatin1("%1:").arg(i, 2) << r.field(i) << r.value(i).toString();
+ QDebugStateSaver saver(dbg);
+ dbg.nospace();
+ const int count = r.count();
+ dbg << "QSqlRecord(" << count << ')';
+ for (int i = 0; i < count; ++i) {
+ dbg.nospace();
+ dbg << '\n' << qSetFieldWidth(2) << right << i << left << qSetFieldWidth(0) << ':';
+ dbg.space();
+ dbg << r.field(i) << r.value(i).toString();
+ }
return dbg;
}
#endif
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index b3b206bfc9..2d92b3f6bd 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -2367,6 +2367,7 @@ static LONG WINAPI windowsFaultHandler(struct _EXCEPTION_POINTERS *exInfo)
static void initEnvironment()
{
qputenv("QT_LOGGING_TO_CONSOLE", "1");
+ qputenv("QT_QTESTLIB_RUNNING", "1");
}
/*!
diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp
index 11a99d136d..9d8a7b7051 100644
--- a/src/tools/rcc/rcc.cpp
+++ b/src/tools/rcc/rcc.cpp
@@ -1057,6 +1057,12 @@ bool RCCResourceLibrary::writeInitializer()
QByteArray initResources = "qInitResources";
initResources += initName;
+
+ // Work around -Wmissing-declarations warnings.
+ writeString("int ");
+ writeMangleNamespaceFunction(initResources);
+ writeString("();\n");
+
writeString("int ");
writeMangleNamespaceFunction(initResources);
writeString("()\n{\n");
@@ -1073,6 +1079,12 @@ bool RCCResourceLibrary::writeInitializer()
//cleanup
QByteArray cleanResources = "qCleanupResources";
cleanResources += initName;
+
+ // Work around -Wmissing-declarations warnings.
+ writeString("int ");
+ writeMangleNamespaceFunction(cleanResources);
+ writeString("();\n");
+
writeString("int ");
writeMangleNamespaceFunction(cleanResources);
writeString("()\n{\n");
diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp
index 109b726880..d12b109d9f 100644
--- a/src/widgets/dialogs/qfontdialog.cpp
+++ b/src/widgets/dialogs/qfontdialog.cpp
@@ -322,6 +322,7 @@ void QFontDialogPrivate::init()
familyList->setFocus();
retranslateStrings();
+ sampleEdit->setObjectName(QLatin1String("qt_fontDialog_sampleEdit"));
}
/*!
diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp
index 6a09f9c273..69761473fc 100644
--- a/src/widgets/dialogs/qwizard_win.cpp
+++ b/src/widgets/dialogs/qwizard_win.cpp
@@ -653,10 +653,7 @@ HFONT QVistaHelper::getCaptionFont(HANDLE hTheme)
{
LOGFONT lf = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0 } };
- if (!hTheme)
- pGetThemeSysFont(hTheme, WIZ_TMT_CAPTIONFONT, &lf);
- else
- {
+ if (!hTheme || FAILED(pGetThemeSysFont(hTheme, WIZ_TMT_CAPTIONFONT, &lf))) {
NONCLIENTMETRICS ncm;
ncm.cbSize = sizeof(NONCLIENTMETRICS);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, false);
diff --git a/src/widgets/doc/snippets/customstyle/customstyle.cpp b/src/widgets/doc/snippets/customstyle/customstyle.cpp
index b5d44ebecd..16715929a8 100644
--- a/src/widgets/doc/snippets/customstyle/customstyle.cpp
+++ b/src/widgets/doc/snippets/customstyle/customstyle.cpp
@@ -45,7 +45,7 @@
CustomStyle::CustomStyle()
{
//! [0]
- QSpinBox *spinBox = qobject_cast<QSpinBox *>(widget);
+ const QSpinBox *spinBox = qobject_cast<const QSpinBox *>(widget);
if (spinBox) {
//! [0] //! [1]
}
diff --git a/src/widgets/doc/snippets/customstyle/customstyle.h b/src/widgets/doc/snippets/customstyle/customstyle.h
index 0f23efc922..0782bdc09c 100644
--- a/src/widgets/doc/snippets/customstyle/customstyle.h
+++ b/src/widgets/doc/snippets/customstyle/customstyle.h
@@ -49,7 +49,7 @@ class CustomStyle : public QProxyStyle
Q_OBJECT
public:
- CustomStyle()
+ CustomStyle();
~CustomStyle() {}
void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
diff --git a/src/widgets/doc/snippets/customstyle/customstyle.pro b/src/widgets/doc/snippets/customstyle/customstyle.pro
index af0ee4e141..02b9b2791d 100644
--- a/src/widgets/doc/snippets/customstyle/customstyle.pro
+++ b/src/widgets/doc/snippets/customstyle/customstyle.pro
@@ -1,2 +1,3 @@
+QT += widgets
HEADERS += customstyle.h
SOURCES += customstyle.cpp main.cpp
diff --git a/src/widgets/doc/snippets/customstyle/main.cpp b/src/widgets/doc/snippets/customstyle/main.cpp
index 19fb6b2be9..8164a1e877 100644
--- a/src/widgets/doc/snippets/customstyle/main.cpp
+++ b/src/widgets/doc/snippets/customstyle/main.cpp
@@ -39,7 +39,7 @@
****************************************************************************/
//! [using a custom style]
-#include <QtGui>
+#include <QtWidgets>
#include "customstyle.h"
diff --git a/src/widgets/doc/snippets/customviewstyle.cpp b/src/widgets/doc/snippets/customviewstyle.cpp
index cdb4ed1d77..0e641653aa 100644
--- a/src/widgets/doc/snippets/customviewstyle.cpp
+++ b/src/widgets/doc/snippets/customviewstyle.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "customviewstyle.h"
diff --git a/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp b/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp
index 3d9c5d6de5..c9b2ecd62c 100644
--- a/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp
+++ b/src/widgets/graphicsview/qgraphicsgridlayoutengine.cpp
@@ -38,9 +38,29 @@
#include "qgraphicslayoutitem_p.h"
#include "qgraphicslayout_p.h"
#include "qgraphicswidget.h"
+#include <private/qgraphicswidget_p.h>
QT_BEGIN_NAMESPACE
+bool QGraphicsGridLayoutEngineItem::isHidden() const
+{
+ if (QGraphicsItem *item = q_layoutItem->graphicsItem())
+ return QGraphicsItemPrivate::get(item)->explicitlyHidden;
+ return false;
+}
+
+/*!
+ \internal
+
+ If this returns true, the layout will arrange just as if the item was never added to the layout.
+ (Note that this shouldn't lead to a "double spacing" where the item was hidden)
+ ### Qt6: Move to QGraphicsLayoutItem and make virtual
+*/
+bool QGraphicsGridLayoutEngineItem::isIgnored() const
+{
+ return isHidden() && !q_layoutItem->sizePolicy().retainSizeWhenHidden();
+}
+
/*
returns \c true if the size policy returns \c true for either hasHeightForWidth()
or hasWidthForHeight()
diff --git a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h
index 4d6bdfce0a..07486514f8 100644
--- a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h
+++ b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h
@@ -82,6 +82,10 @@ public:
return q_layoutItem->effectiveSizeHint(which, constraint);
}
+ bool isHidden() const;
+
+ virtual bool isIgnored() const Q_DECL_OVERRIDE;
+
virtual void setGeometry(const QRectF &rect) Q_DECL_OVERRIDE
{
q_layoutItem->setGeometry(rect);
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index 114c45dc0f..67d135271c 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -797,7 +797,7 @@ static QPainterPath qt_graphicsItem_shapeFromPath(const QPainterPath &path, cons
// if we pass a value of 0.0 to QPainterPathStroker::setWidth()
const qreal penWidthZero = qreal(0.00000001);
- if (path == QPainterPath())
+ if (path == QPainterPath() || pen == Qt::NoPen)
return path;
QPainterPathStroker ps;
ps.setCapStyle(pen.capStyle());
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index fdcb66f69b..8765b8114d 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -392,7 +392,7 @@ void QGraphicsScenePrivate::_q_emitUpdated()
*/
void QGraphicsScenePrivate::registerTopLevelItem(QGraphicsItem *item)
{
- item->d_ptr->ensureSequentialSiblingIndex();
+ ensureSequentialTopLevelSiblingIndexes();
needSortTopLevelItems = true; // ### maybe false
item->d_ptr->siblingIndex = topLevelItems.size();
topLevelItems.append(item);
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp
index 88d5e52204..5484ecb96e 100644
--- a/src/widgets/graphicsview/qgraphicsview.cpp
+++ b/src/widgets/graphicsview/qgraphicsview.cpp
@@ -765,7 +765,7 @@ void QGraphicsViewPrivate::updateRubberBand(const QMouseEvent *event)
}
// Set the new selection area
QPainterPath selectionArea;
- selectionArea.addPolygon(mapToScene(rubberBandRect));
+ selectionArea.addPolygon(q->mapToScene(rubberBandRect));
selectionArea.closeSubpath();
if (scene)
scene->setSelectionArea(selectionArea, rubberBandSelectionMode, q->viewportTransform());
diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp
index 4a9c3b098e..5bd563e535 100644
--- a/src/widgets/graphicsview/qgraphicswidget.cpp
+++ b/src/widgets/graphicsview/qgraphicswidget.cpp
@@ -1137,6 +1137,10 @@ QVariant QGraphicsWidget::itemChange(GraphicsItemChange change, const QVariant &
setAttribute(Qt::WA_Resized, false);
}
}
+
+ // layout size hint only changes if an item changes from/to explicitly hidden state
+ if (value.toBool() || d->explicitlyHidden)
+ updateGeometry();
break;
case ItemVisibleHasChanged:
if (!value.toBool()) {
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index 3fbb17ff3f..a6361bd750 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -837,6 +837,7 @@ void QAbstractItemView::setItemDelegate(QAbstractItemDelegate *delegate)
}
d->itemDelegate = delegate;
viewport()->update();
+ d->doDelayedItemsLayout();
}
/*!
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index 3900444df4..46cab90ab4 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -1106,15 +1106,6 @@ bool QLayout::activate()
ms.setWidth(mw->minimumSize().width());
if (heightSet)
ms.setHeight(mw->minimumSize().height());
- if ((!heightSet || !widthSet) && hasHeightForWidth()) {
- int h = minimumHeightForWidth(ms.width());
- if (h > ms.height()) {
- if (!heightSet)
- ms.setHeight(0);
- if (!widthSet)
- ms.setWidth(0);
- }
- }
mw->setMinimumSize(ms);
} else if (!widthSet || !heightSet) {
QSize ms = mw->minimumSize();
diff --git a/src/widgets/kernel/qstandardgestures.cpp b/src/widgets/kernel/qstandardgestures.cpp
index 78a2c65060..0822c04033 100644
--- a/src/widgets/kernel/qstandardgestures.cpp
+++ b/src/widgets/kernel/qstandardgestures.cpp
@@ -341,10 +341,10 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state,
if (d->horizontalDirection == QSwipeGesture::NoDirection)
d->horizontalDirection = horizontal;
if (d->verticalDirection != vertical || d->horizontalDirection != horizontal) {
- // the user has changed the direction!
result = QGestureRecognizer::CancelGesture;
+ } else {
+ result = QGestureRecognizer::TriggerGesture;
}
- result = QGestureRecognizer::TriggerGesture;
} else {
if (q->state() != Qt::NoGesture)
result = QGestureRecognizer::TriggerGesture;
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index af1745d845..63497ce745 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -1360,11 +1360,11 @@ void q_createNativeChildrenAndSetParent(const QWidget *parentWidget)
if (!childWidget->internalWinId())
childWidget->winId();
if (childWidget->windowHandle()) {
- QWindow *parentWindow = childWidget->nativeParentWidget()->windowHandle();
- if (childWidget->isWindow())
- childWidget->windowHandle()->setTransientParent(parentWindow);
- else
- childWidget->windowHandle()->setParent(parentWindow);
+ if (childWidget->isWindow()) {
+ childWidget->windowHandle()->setTransientParent(parentWidget->window()->windowHandle());
+ } else {
+ childWidget->windowHandle()->setParent(childWidget->nativeParentWidget()->windowHandle());
+ }
}
} else {
q_createNativeChildrenAndSetParent(childWidget);
@@ -1401,10 +1401,8 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
win->setProperty(propertyName, q->property(propertyName));
}
-#ifdef Q_OS_OSX
if (q->testAttribute(Qt::WA_ShowWithoutActivating))
win->setProperty("_q_showWithoutActivating", QVariant(true));
-#endif
win->setFlags(data.window_flags);
fixPosIncludesFrame();
if (q->testAttribute(Qt::WA_Moved)
@@ -9663,6 +9661,10 @@ QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const
is set, the input method may change its visual components to reflect
that only numbers can be entered.
+ \warning Some widgets require certain flags in order to work as
+ intended. To set a flag, do \c{w->setInputMethodHints(w->inputMethodHints()|f)}
+ instead of \c{w->setInputMethodHints(f)}.
+
\note The flags are only hints, so the particular input method
implementation is free to ignore them. If you want to be
sure that a certain type of characters are entered,
@@ -12250,6 +12252,17 @@ QPaintEngine *QWidget::paintEngine() const
*/
QPoint QWidget::mapToGlobal(const QPoint &pos) const
{
+#ifndef QT_NO_GRAPHICSVIEW
+ Q_D(const QWidget);
+ if (d->extra && d->extra->proxyWidget) {
+ const QList <QGraphicsView *> views = d->extra->proxyWidget->scene()->views();
+ if (!views.isEmpty()) {
+ const QPointF scenePos = d->extra->proxyWidget->mapToScene(pos);
+ const QPoint viewPortPos = views.first()->mapFromScene(scenePos);
+ return views.first()->viewport()->mapToGlobal(viewPortPos);
+ }
+ }
+#endif // !QT_NO_GRAPHICSVIEW
int x = pos.x(), y = pos.y();
const QWidget *w = this;
while (w) {
@@ -12274,6 +12287,17 @@ QPoint QWidget::mapToGlobal(const QPoint &pos) const
*/
QPoint QWidget::mapFromGlobal(const QPoint &pos) const
{
+#ifndef QT_NO_GRAPHICSVIEW
+ Q_D(const QWidget);
+ if (d->extra && d->extra->proxyWidget) {
+ const QList <QGraphicsView *> views = d->extra->proxyWidget->scene()->views();
+ if (!views.isEmpty()) {
+ const QPoint viewPortPos = views.first()->viewport()->mapFromGlobal(pos);
+ const QPointF scenePos = views.first()->mapToScene(viewPortPos);
+ return d->extra->proxyWidget->mapFromScene(scenePos).toPoint();
+ }
+ }
+#endif // !QT_NO_GRAPHICSVIEW
int x = pos.x(), y = pos.y();
const QWidget *w = this;
while (w) {
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index ff0f51ee13..fb0bafa66d 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -6025,8 +6025,10 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
p->fillPath(path, brush);
} else if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
static QPixmap pm(QLatin1String(":/qt-project.org/mac/style/images/leopard-unified-toolbar-on.png"));
+ p->save();
p->setRenderHint(QPainter::SmoothPixmapTransform);
QStyleHelper::drawBorderPixmap(pm, p, tb->rect, 2, 2, 2, 2);
+ p->restore();
} else {
QPen oldPen = p->pen();
p->setPen(QColor(0, 0, 0, 0x3a));
diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp
index 3affd84124..7c4d239894 100644
--- a/src/widgets/styles/qstyle.cpp
+++ b/src/widgets/styles/qstyle.cpp
@@ -1463,6 +1463,12 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
\value PM_TabCloseIndicatorWidth The default width of a close button on a tab in a tab bar.
\value PM_TabCloseIndicatorHeight The default height of a close button on a tab in a tab bar.
+ \value PM_ScrollView_ScrollBarSpacing Distance between frame and scrollbar
+ with SH_ScrollView_FrameOnlyAroundContents set.
+ \value PM_ScrollView_ScrollBarOverlap Overlap between scroll bars and scroll content
+
+ \value PM_SubMenuOverlap The horizontal overlap between a submenu and its parent.
+
\value PM_TreeViewIndentation The indentation of items in a tree view.
This enum value has been introduced in Qt 5.4.
@@ -1483,12 +1489,6 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
and PM_LayoutVerticalSpacing
instead.
- \value PM_ScrollView_ScrollBarSpacing Distance between frame and scrollbar
- with SH_ScrollView_FrameOnlyAroundContents set.
- \value PM_ScrollView_ScrollBarOverlap Overlap between scroll bars and scroll content
-
- \value PM_SubMenuOverlap The horizontal overlap between a submenu and its parent.
-
\sa pixelMetric()
*/
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index a6c7f5dde2..e9f20de842 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -4047,26 +4047,28 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
}
if (!dwOpt->title.isEmpty()) {
- QRect r = opt->rect;
+ QRect r = subElementRect(SE_DockWidgetTitleBarText, opt, w);
if (dwOpt->verticalTitleBar) {
QSize s = r.size();
s.transpose();
r.setSize(s);
-
p->save();
p->translate(r.left(), r.top() + r.width());
p->rotate(-90);
p->translate(-r.left(), -r.top());
}
+ r = subRule.contentsRect(r);
Qt::Alignment alignment = 0;
if (subRule.hasPosition())
alignment = subRule.position()->textAlignment;
if (alignment == 0)
alignment = Qt::AlignLeft;
- drawItemText(p, subRule.contentsRect(opt->rect),
+
+ QString titleText = p->fontMetrics().elidedText(dwOpt->title, Qt::ElideRight, r.width());
+ drawItemText(p, r,
alignment | Qt::TextShowMnemonic, dwOpt->palette,
- dwOpt->state & State_Enabled, dwOpt->title,
+ dwOpt->state & State_Enabled, titleText,
QPalette::WindowText);
if (dwOpt->verticalTitleBar)
@@ -5826,6 +5828,10 @@ bool QStyleSheetStyle::event(QEvent *e)
void QStyleSheetStyle::updateStyleSheetFont(QWidget* w) const
{
+ // Qt's fontDialog relies on the font of the sample edit for its selection,
+ // we should never override it.
+ if (w->objectName() == QLatin1String("qt_fontDialog_sampleEdit"))
+ return;
QWidget *container = containerWidget(w);
QRenderRule rule = renderRule(container, PseudoElement_None,
PseudoClass_Active | PseudoClass_Enabled | extendedPseudoClass(container));
diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp
index a6eb2c0bc6..007952192a 100644
--- a/src/widgets/styles/qwindowsvistastyle.cpp
+++ b/src/widgets/styles/qwindowsvistastyle.cpp
@@ -1756,26 +1756,8 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle
theme.stateId = stateId;
d->drawBackground(theme);
- // Calculate rect of gripper
- const int swidth = theme.rect.width();
- const int sheight = theme.rect.height();
-
- const QMargins contentsMargin = theme.margins(theme.rect, TMT_SIZINGMARGINS)
- / QWindowsXPStylePrivate::devicePixelRatio(widget);
-
- theme.partId = flags & State_Horizontal ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT;
- const QSize size = theme.size() / QWindowsXPStylePrivate::devicePixelRatio(widget);
-
if (QSysInfo::WindowsVersion < QSysInfo::WV_WINDOWS8) {
- QPoint gripperBoundsPos(0, 0);
- if ((flags & State_Horizontal
- && swidth - contentsMargin.left() - contentsMargin.right() > size.width())
- || sheight - contentsMargin.top() - contentsMargin.bottom() > size.height()) {
- gripperBoundsPos = QPoint(theme.rect.left() + (swidth - size.width()) / 2,
- theme.rect.top() + (sheight - size.height()) / 2);
- }
- const QRect gripperBounds(gripperBoundsPos, size);
-
+ const QRect gripperBounds = QWindowsXPStylePrivate::scrollBarGripperBounds(flags, widget, &theme);
// Draw gripper if there is enough space
if (!gripperBounds.isEmpty() && flags & State_Enabled) {
painter->save();
@@ -2285,7 +2267,7 @@ int QWindowsVistaStyle::pixelMetric(PixelMetric metric, const QStyleOption *opti
if (!QWindowsVistaStylePrivate::useVista())
return QWindowsStyle::pixelMetric(metric, option, widget);
- int ret = QWindowsStylePrivate::fixedPixelMetric(metric);
+ int ret = QWindowsVistaStylePrivate::fixedPixelMetric(metric);
if (ret != QWindowsStylePrivate::InvalidMetric)
return int(QStyleHelper::dpiScaled(ret));
diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp
index 624023f627..c18bbb3431 100644
--- a/src/widgets/styles/qwindowsxpstyle.cpp
+++ b/src/widgets/styles/qwindowsxpstyle.cpp
@@ -2529,6 +2529,20 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op
d->drawBackground(theme);
}
+QRect QWindowsXPStylePrivate::scrollBarGripperBounds(QStyle::State flags, const QWidget *widget, XPThemeData *theme)
+{
+ const bool horizontal = flags & QStyle::State_Horizontal;
+ const QMargins contentsMargin = theme->margins(theme->rect, TMT_SIZINGMARGINS)
+ / QWindowsStylePrivate::devicePixelRatio(widget);
+ theme->partId = horizontal ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT;
+ const QSize size = theme->size() / QWindowsStylePrivate::devicePixelRatio(widget);
+
+ const int hSpace = theme->rect.width() - size.width();
+ const int vSpace = theme->rect.height() - size.height();
+ const bool sufficientSpace = horizontal && hSpace > (contentsMargin.left() + contentsMargin.right())
+ || vSpace > contentsMargin.top() + contentsMargin.bottom();
+ return sufficientSpace ? QRect(theme->rect.topLeft() + QPoint(hSpace, vSpace) / 2, size) : QRect();
+}
/*!
\reimp
@@ -2754,24 +2768,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
theme.stateId = stateId;
d->drawBackground(theme);
- // Calculate rect of gripper
- const int swidth = theme.rect.width();
- const int sheight = theme.rect.height();
-
- const QMargins contentsMargin = theme.margins(theme.rect, TMT_SIZINGMARGINS)
- / QWindowsStylePrivate::devicePixelRatio(widget);
-
- theme.partId = flags & State_Horizontal ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT;
- const QSize size = theme.size() / QWindowsStylePrivate::devicePixelRatio(widget);
- QPoint gripperBoundsPos(0, 0);
- if ((flags & State_Horizontal
- && swidth - contentsMargin.left() - contentsMargin.right() > size.width())
- || sheight - contentsMargin.top() - contentsMargin.bottom() > size.height()) {
- gripperBoundsPos = QPoint(theme.rect.left() + (swidth - size.width()) / 2,
- theme.rect.top() + (sheight - size.height()) /2);
- }
- const QRect gripperBounds(gripperBoundsPos, size);
-
+ const QRect gripperBounds = QWindowsXPStylePrivate::scrollBarGripperBounds(flags, widget, &theme);
// Draw gripper if there is enough space
if (!gripperBounds.isEmpty()) {
p->save();
diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h
index 4f42b60681..5027588c93 100644
--- a/src/widgets/styles/qwindowsxpstyle_p_p.h
+++ b/src/widgets/styles/qwindowsxpstyle_p_p.h
@@ -392,6 +392,7 @@ public:
static bool resolveSymbols();
static bool useXP(bool update = false);
+ static QRect scrollBarGripperBounds(QStyle::State flags, const QWidget *widget, XPThemeData *theme);
bool isTransparent(XPThemeData &themeData);
QRegion region(XPThemeData &themeData);
diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp
index d6704c20d2..fa3dbc1f32 100644
--- a/src/widgets/widgets/qcalendarwidget.cpp
+++ b/src/widgets/widgets/qcalendarwidget.cpp
@@ -2247,6 +2247,9 @@ QSize QCalendarWidget::minimumSizeHint() const
w *= cols;
w = qMax(headerSize.width(), w);
h = (h * rows) + headerSize.height();
+ QMargins cm = contentsMargins();
+ w += cm.left() + cm.right();
+ h += cm.top() + cm.bottom();
d->cachedSizeHint = QSize(w, h);
return d->cachedSizeHint;
}
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index 44e22555db..fda37c49de 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -479,9 +479,9 @@ void QComboBoxPrivateContainer::updateScrollers()
view->verticalScrollBar()->minimum() < view->verticalScrollBar()->maximum()) {
bool needTop = view->verticalScrollBar()->value()
- > (view->verticalScrollBar()->minimum() + spacing());
+ > (view->verticalScrollBar()->minimum() + topMargin());
bool needBottom = view->verticalScrollBar()->value()
- < (view->verticalScrollBar()->maximum() - spacing()*2);
+ < (view->verticalScrollBar()->maximum() - bottomMargin() - topMargin());
if (needTop)
top->show();
else
@@ -572,13 +572,27 @@ void QComboBoxPrivateContainer::setItemView(QAbstractItemView *itemView)
}
/*!
+ Returns the top/bottom vertical margin of the view.
+*/
+int QComboBoxPrivateContainer::topMargin() const
+{
+ if (const QListView *lview = qobject_cast<const QListView*>(view))
+ return lview->spacing();
+#ifndef QT_NO_TABLEVIEW
+ if (const QTableView *tview = qobject_cast<const QTableView*>(view))
+ return tview->showGrid() ? 1 : 0;
+#endif
+ return 0;
+}
+
+/*!
Returns the spacing between the items in the view.
*/
int QComboBoxPrivateContainer::spacing() const
{
QListView *lview = qobject_cast<QListView*>(view);
if (lview)
- return lview->spacing();
+ return 2 * lview->spacing(); // QListView::spacing is the padding around the item.
#ifndef QT_NO_TABLEVIEW
QTableView *tview = qobject_cast<QTableView*>(view);
if (tview)
@@ -1690,8 +1704,6 @@ void QComboBox::setEditable(bool editable)
if (isEditable() == editable)
return;
- d->updateDelegate();
-
QStyleOptionComboBox opt;
initStyleOption(&opt);
if (editable) {
@@ -1712,6 +1724,7 @@ void QComboBox::setEditable(bool editable)
d->lineEdit = 0;
}
+ d->updateDelegate();
d->updateFocusPolicy();
d->viewContainer()->updateTopBottomMargin();
@@ -2528,7 +2541,7 @@ void QComboBox::showPopup()
QModelIndex idx = d->model->index(i, d->modelColumn, parent);
if (!idx.isValid())
continue;
- listHeight += view()->visualRect(idx).height() + container->spacing();
+ listHeight += view()->visualRect(idx).height();
#ifndef QT_NO_TREEVIEW
if (d->model->hasChildren(idx) && treeView && treeView->isExpanded(idx))
toCheck.push(idx);
@@ -2540,12 +2553,14 @@ void QComboBox::showPopup()
}
}
}
+ if (count > 1)
+ listHeight += (count - 1) * container->spacing();
listRect.setHeight(listHeight);
}
{
// add the spacing for the grid on the top and the bottom;
- int heightMargin = 2*container->spacing();
+ int heightMargin = container->topMargin() + container->bottomMargin();
// add the frame of the container
int marginTop, marginBottom;
diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h
index becdde55ae..4e1b4125ab 100644
--- a/src/widgets/widgets/qcombobox_p.h
+++ b/src/widgets/widgets/qcombobox_p.h
@@ -214,6 +214,8 @@ public:
QAbstractItemView *itemView() const;
void setItemView(QAbstractItemView *itemView);
int spacing() const;
+ int topMargin() const;
+ int bottomMargin() const { return topMargin(); }
void updateTopBottomMargin();
QTimer blockMouseReleaseTimer;
@@ -252,7 +254,7 @@ private:
friend class QComboBox;
};
-class QComboMenuDelegate : public QAbstractItemDelegate
+class Q_AUTOTEST_EXPORT QComboMenuDelegate : public QAbstractItemDelegate
{ Q_OBJECT
public:
QComboMenuDelegate(QObject *parent, QComboBox *cmb) : QAbstractItemDelegate(parent), mCombo(cmb) {}
@@ -281,7 +283,7 @@ private:
// Note that this class is intentionally not using QStyledItemDelegate
// Vista does not use the new theme for combo boxes and there might
// be other side effects from using the new class
-class QComboBoxDelegate : public QItemDelegate
+class Q_AUTOTEST_EXPORT QComboBoxDelegate : public QItemDelegate
{ Q_OBJECT
public:
QComboBoxDelegate(QObject *parent, QComboBox *cmb) : QItemDelegate(parent), mCombo(cmb) {}
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index 7ac2791112..702cd8bac9 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -2575,12 +2575,14 @@ void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list,
{
QSize center_hint(0, 0);
QSize center_min(0, 0);
+ QSize center_max(0, 0);
const bool have_central = centralWidgetItem != 0 && !centralWidgetItem->isEmpty();
if (have_central) {
center_hint = centralWidgetRect.size();
if (!center_hint.isValid())
center_hint = centralWidgetItem->sizeHint();
center_min = centralWidgetItem->minimumSize();
+ center_max = centralWidgetItem->maximumSize();
}
QRect center_rect = rect;
@@ -2656,7 +2658,7 @@ void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list,
left = (tl_significant && bl_significant) ? left_min.height() : 0;
right = (tr_significant && br_significant) ? right_min.height() : 0;
ver_struct_list[1].minimumSize = qMax(left, center_min.height(), right);
- ver_struct_list[1].maximumSize = have_central ? QWIDGETSIZE_MAX : 0;
+ ver_struct_list[1].maximumSize = center_max.height();
ver_struct_list[1].expansive = have_central;
ver_struct_list[1].empty = docks[QInternal::LeftDock].isEmpty()
&& !have_central
@@ -2717,7 +2719,7 @@ void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list,
bottom = (bl_significant && br_significant) ? bottom_min.width() : 0;
hor_struct_list[1].minimumSize = qMax(top, center_min.width(), bottom);
- hor_struct_list[1].maximumSize = have_central ? QWIDGETSIZE_MAX : 0;
+ hor_struct_list[1].maximumSize = center_max.width();
hor_struct_list[1].expansive = have_central;
hor_struct_list[1].empty = !have_central;
hor_struct_list[1].pos = center_rect.left();
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index 90fbfc1639..a82dd99591 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -1607,6 +1607,13 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return) {
if (hasAcceptableInput() || fixup()) {
+
+ QInputMethod *inputMethod = QApplication::inputMethod();
+ inputMethod->commit();
+ QWidget *lineEdit = qobject_cast<QWidget *>(parent());
+ if (!(lineEdit && lineEdit->inputMethodHints() & Qt::ImhMultiLine))
+ inputMethod->hide();
+
emit accepted();
emit editingFinished();
}
diff --git a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp
index 7c154575d0..4e3d5c64bc 100644
--- a/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp
+++ b/tests/auto/corelib/codecs/qtextcodec/tst_qtextcodec.cpp
@@ -196,10 +196,9 @@ void tst_QTextCodec::fromUnicode_data()
QTest::newRow("windows-1257") << "windows-1257" << true;
QTest::newRow("windows-1258") << "windows-1258" << true;
- QTest::newRow("macintosh") << "macintosh" << true;
+ QTest::newRow("Apple Roman") << "Apple Roman" << true;
//QTest::newRow("WINSAMI2") << "WINSAMI2" << true;
QTest::newRow("TIS-620") << "TIS-620" << true;
-// QTest::newRow("hp-roman8") << "hp-roman8" << true;
QTest::newRow("SJIS") << "SJIS" << false;
// all codecs from documentation
@@ -209,20 +208,17 @@ void tst_QTextCodec::fromUnicode_data()
QTest::newRow("windows-949") << "windows-949" << false;
QTest::newRow("EUC-JP") << "EUC-JP" << false;
QTest::newRow("EUC-KR") << "EUC-KR" << false;
- //QTest::newRow("GB18030-0") << "GB18030-0" << false; // only GB18030 works
QTest::newRow("GB18030") << "GB18030" << false;
+ QTest::newRow("HP-ROMAN8") << "HP-ROMAN8" << false;
QTest::newRow("IBM 850") << "IBM 850" << false;
QTest::newRow("IBM 866") << "IBM 866" << false;
QTest::newRow("IBM 874") << "IBM 874" << false;
QTest::newRow("ISO 2022-JP") << "ISO 2022-JP" << false;
//ISO 8859-1 to 10 and ISO 8859-13 to 16 tested previously
// Iscii-Bng, Dev, Gjr, Knd, Mlm, Ori, Pnj, Tlg, and Tml tested in Iscii test
- //QTest::newRow("JIS X 0201") << "JIS X 0201" << false; // actually not there
- //QTest::newRow("JIS X 0208") << "JIS X 0208" << false; // actually not there
QTest::newRow("KOI8-R") << "KOI8-R" << false;
QTest::newRow("KOI8-U") << "KOI8-U" << false;
- //QTest::newRow("MuleLao-1") << "MuleLao-1" << false; //only on x11
- QTest::newRow("ROMAN8") << "ROMAN8" << false;
+ QTest::newRow("Macintosh") << "Macintosh" << true;
QTest::newRow("Shift-JIS") << "Shift-JIS" << false;
QTest::newRow("TIS-620") << "TIS-620" << false;
QTest::newRow("TSCII") << "TSCII" << false;
diff --git a/tests/auto/corelib/io/largefile/tst_largefile.cpp b/tests/auto/corelib/io/largefile/tst_largefile.cpp
index bedbeb6181..62410f7c80 100644
--- a/tests/auto/corelib/io/largefile/tst_largefile.cpp
+++ b/tests/auto/corelib/io/largefile/tst_largefile.cpp
@@ -75,7 +75,7 @@ public:
#elif defined(Q_OS_MAC)
// HFS+ does not support sparse files, so we limit file size for the test
// on Mac OS.
- maxSizeBits = 32; // 4 GiB
+ maxSizeBits = 24; // 16 MiB
#else
maxSizeBits = 24; // 16 MiB
#endif
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index b3e683a29b..4264c96745 100644
--- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
+++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
@@ -35,6 +35,7 @@
#include <qvariant.h>
#include <qbitarray.h>
+#include <qbytearraylist.h>
#include <qdatetime.h>
#include <qmap.h>
#include <qiodevice.h>
@@ -208,6 +209,7 @@ private slots:
void convertBoolToByteArray_data() const;
void convertByteArrayToBool() const;
void convertByteArrayToBool_data() const;
+ void convertIterables() const;
void toIntFromQString() const;
void toIntFromDouble() const;
void setValue();
@@ -2838,6 +2840,49 @@ void tst_QVariant::convertByteArrayToBool_data() const
<< QByteArray("true");
}
+void tst_QVariant::convertIterables() const
+{
+ {
+ QStringList list;
+ list.append("Hello");
+ QCOMPARE(QVariant::fromValue(list).value<QVariantList>().count(), list.count());
+ }
+ {
+ QByteArrayList list;
+ list.append("Hello");
+ QCOMPARE(QVariant::fromValue(list).value<QVariantList>().count(), list.count());
+ }
+ {
+ QVariantList list;
+ list.append("World");
+ QCOMPARE(QVariant::fromValue(list).value<QVariantList>().count(), list.count());
+ }
+ {
+ QMap<QString, int> map;
+ map.insert("3", 4);
+ QCOMPARE(QVariant::fromValue(map).value<QVariantHash>().count(), map.count());
+ QCOMPARE(QVariant::fromValue(map).value<QVariantMap>().count(), map.count());
+ }
+ {
+ QVariantMap map;
+ map.insert("3", 4);
+ QCOMPARE(QVariant::fromValue(map).value<QVariantHash>().count(), map.count());
+ QCOMPARE(QVariant::fromValue(map).value<QVariantMap>().count(), map.count());
+ }
+ {
+ QHash<QString, int> hash;
+ hash.insert("3", 4);
+ QCOMPARE(QVariant::fromValue(hash).value<QVariantHash>().count(), hash.count());
+ QCOMPARE(QVariant::fromValue(hash).value<QVariantMap>().count(), hash.count());
+ }
+ {
+ QVariantHash hash;
+ hash.insert("3", 4);
+ QCOMPARE(QVariant::fromValue(hash).value<QVariantHash>().count(), hash.count());
+ QCOMPARE(QVariant::fromValue(hash).value<QVariantMap>().count(), hash.count());
+ }
+}
+
/*!
We verify that:
1. Converting the string "9.9" to int fails. This is the behavior of
diff --git a/tests/auto/gui/text/qglyphrun/qglyphrun.pro b/tests/auto/gui/text/qglyphrun/qglyphrun.pro
index 0993a5c49c..b7d9f164c9 100644
--- a/tests/auto/gui/text/qglyphrun/qglyphrun.pro
+++ b/tests/auto/gui/text/qglyphrun/qglyphrun.pro
@@ -8,14 +8,13 @@ linux: CONFIG += insignificant_test
SOURCES += \
tst_qglyphrun.cpp
-android {
- RESOURCES += \
- testdata.qrc
-}
wince* {
additionalFiles.files = test.ttf
- additionalFiles.path = .
+ additionalFiles.path = ../../../shared/resources/
DEPLOYMENT += additionalFiles
+} else {
+ RESOURCES += \
+ testdata.qrc
}
diff --git a/tests/auto/gui/text/qglyphrun/testdata.qrc b/tests/auto/gui/text/qglyphrun/testdata.qrc
index c4e237ad2f..25cadc477e 100644
--- a/tests/auto/gui/text/qglyphrun/testdata.qrc
+++ b/tests/auto/gui/text/qglyphrun/testdata.qrc
@@ -1,5 +1,5 @@
<RCC>
<qresource prefix="/">
- <file>test.ttf</file>
+ <file alias="test.ttf">../../../shared/resources/test.ttf</file>
</qresource>
</RCC>
diff --git a/tests/auto/gui/text/qrawfont/qrawfont.pro b/tests/auto/gui/text/qrawfont/qrawfont.pro
index 1891e7a9bf..20da2e9a22 100644
--- a/tests/auto/gui/text/qrawfont/qrawfont.pro
+++ b/tests/auto/gui/text/qrawfont/qrawfont.pro
@@ -7,9 +7,5 @@ QT = core core-private gui gui-private testlib
SOURCES += \
tst_qrawfont.cpp
-TESTDATA += testfont_bold_italic.ttf testfont.ttf
-
-android {
- RESOURCES += \
- testdata.qrc
-}
+RESOURCES += \
+ testdata.qrc
diff --git a/tests/auto/gui/text/qrawfont/testdata.qrc b/tests/auto/gui/text/qrawfont/testdata.qrc
index 7bea0d5a39..8f8e32ed24 100644
--- a/tests/auto/gui/text/qrawfont/testdata.qrc
+++ b/tests/auto/gui/text/qrawfont/testdata.qrc
@@ -1,6 +1,6 @@
<RCC>
<qresource prefix="/">
<file>testfont_bold_italic.ttf</file>
- <file>testfont.ttf</file>
+ <file alias="testfont.ttf">../../../shared/resources/testfont.ttf</file>
</qresource>
</RCC>
diff --git a/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp b/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
index a6d75390c3..a2f1668ef5 100644
--- a/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
+++ b/tests/auto/network/access/qnetworkdiskcache/tst_qnetworkdiskcache.cpp
@@ -55,6 +55,7 @@ public slots:
void init();
void cleanup();
void accessAfterRemoveReadyReadSlot();
+ void setCookieHeaderMetaDataChangedSlot();
private slots:
void qnetworkdiskcache_data();
@@ -68,6 +69,7 @@ private slots:
void metaData();
void remove();
void accessAfterRemove(); // QTBUG-17400
+ void setCookieHeader(); // QTBUG-41514
void setCacheDirectory_data();
void setCacheDirectory();
void updateMetaData();
@@ -86,8 +88,9 @@ private slots:
private:
QTemporaryDir tempDir;
- QUrl url; // used by accessAfterRemove()
+ QUrl url; // used by accessAfterRemove(), setCookieHeader()
QNetworkDiskCache *diskCache; // used by accessAfterRemove()
+ QNetworkAccessManager *manager; // used by setCookieHeader()
};
// FIXME same as in tst_qnetworkreply.cpp .. could be unified
@@ -403,6 +406,40 @@ void tst_QNetworkDiskCache::accessAfterRemoveReadyReadSlot()
diskCache->remove(url); // this used to cause a crash later on
}
+void tst_QNetworkDiskCache::setCookieHeader() // QTBUG-41514
+{
+ SubQNetworkDiskCache *cache = new SubQNetworkDiskCache();
+ url = QUrl("http://www.foo.com/cookieTest.html");
+ QNetworkCacheMetaData metaData;
+ metaData.setUrl(url);
+
+ QNetworkCacheMetaData::RawHeaderList headers;
+ headers.append(QNetworkCacheMetaData::RawHeader("Set-Cookie", "aaa=bbb"));
+ metaData.setRawHeaders(headers);
+ metaData.setSaveToDisk(true);
+ cache->setupWithOne(tempDir.path(), url, metaData);
+
+ manager = new QNetworkAccessManager();
+ manager->setCache(cache);
+
+ QNetworkRequest request(url);
+ QNetworkReply *reply = manager->get(request);
+ connect(reply, SIGNAL(metaDataChanged()), this, SLOT(setCookieHeaderMetaDataChangedSlot()));
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
+
+ QTestEventLoop::instance().enterLoop(5);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ reply->deleteLater();
+ manager->deleteLater();
+}
+
+void tst_QNetworkDiskCache::setCookieHeaderMetaDataChangedSlot()
+{
+ QList<QNetworkCookie> actualCookieJar = manager->cookieJar()->cookiesForUrl(url);
+ QVERIFY(!actualCookieJar.empty());
+}
+
void tst_QNetworkDiskCache::setCacheDirectory_data()
{
QTest::addColumn<QString>("cacheDir");
diff --git a/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp
index d3ff95a26d..1e0d9555dd 100644
--- a/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp
+++ b/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp
@@ -271,7 +271,11 @@ void tst_QNetworkSession::sessionProperties()
<< QLatin1String("WCDMA")
<< QLatin1String("HSPA")
<< QLatin1String("Bluetooth")
- << QLatin1String("WiMAX");
+ << QLatin1String("WiMAX")
+ << QLatin1String("BearerEVDO")
+ << QLatin1String("BearerLTE")
+ << QLatin1String("Bearer3G")
+ << QLatin1String("Bearer4G");
if (!configuration.isValid()) {
QVERIFY(configuration.bearerTypeName().isEmpty());
@@ -1022,7 +1026,11 @@ QNetworkConfiguration suitableConfiguration(QString bearerType, QNetworkConfigur
if (config.bearerTypeName() != "2G" &&
config.bearerTypeName() != "CDMA2000" &&
config.bearerTypeName() != "WCDMA" &&
- config.bearerTypeName() != "HSPA") {
+ config.bearerTypeName() != "HSPA" &&
+ config.bearerTypeName() != "EVDO" &&
+ config.bearerTypeName() != "LTE" &&
+ config.bearerTypeName() != "3G" &&
+ config.bearerTypeName() != "4G") {
// qDebug() << "Dumping config because bearer mismatches (cellular): " << config.name();
discoveredConfigs.removeOne(config);
}
diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
index 6e915f89fb..aa954429de 100644
--- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
@@ -1088,7 +1088,7 @@ void tst_QSslSocket::protocolServerSide_data()
#endif
QTest::newRow("ssl3-tls1.0") << QSsl::SslV3 << QSsl::TlsV1_0 << false;
QTest::newRow("ssl3-tls1ssl3") << QSsl::SslV3 << QSsl::TlsV1SslV3 << true;
- QTest::newRow("ssl3-secure") << QSsl::SslV3 << QSsl::SecureProtocols << true;
+ QTest::newRow("ssl3-secure") << QSsl::SslV3 << QSsl::SecureProtocols << false;
#ifndef OPENSSL_NO_SSL2
QTest::newRow("ssl3-any") << QSsl::SslV3 << QSsl::AnyProtocol << false; // we won't set a SNI header here because we connect to a
// numerical IP, so OpenSSL will send a SSL 2 handshake
@@ -1120,7 +1120,7 @@ void tst_QSslSocket::protocolServerSide_data()
#ifndef OPENSSL_NO_SSL2
QTest::newRow("secure-ssl2") << QSsl::SecureProtocols << QSsl::SslV2 << false;
#endif
- QTest::newRow("secure-ssl3") << QSsl::SecureProtocols << QSsl::SslV3 << true;
+ QTest::newRow("secure-ssl3") << QSsl::SecureProtocols << QSsl::SslV3 << false;
QTest::newRow("secure-tls1.0") << QSsl::SecureProtocols << QSsl::TlsV1_0 << true;
QTest::newRow("secure-tls1ssl3") << QSsl::SecureProtocols << QSsl::TlsV1SslV3 << true;
QTest::newRow("secure-any") << QSsl::SecureProtocols << QSsl::AnyProtocol << true;
@@ -2300,28 +2300,28 @@ void tst_QSslSocket::sslOptions()
#ifdef SSL_OP_NO_COMPRESSION
QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols,
QSslConfigurationPrivate::defaultSslOptions),
- long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_COMPRESSION));
+ long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_COMPRESSION));
#else
QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols,
QSslConfigurationPrivate::defaultSslOptions),
- long(SSL_OP_ALL|SSL_OP_NO_SSLv2));
+ long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3));
#endif
QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols,
QSsl::SslOptionDisableEmptyFragments
|QSsl::SslOptionDisableLegacyRenegotiation),
- long(SSL_OP_ALL|SSL_OP_NO_SSLv2));
+ long(SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3));
#ifdef SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION
QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols,
QSsl::SslOptionDisableEmptyFragments),
- long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)));
+ long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)));
#endif
#ifdef SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS
QCOMPARE(QSslSocketBackendPrivate::setupOpenSslOptions(QSsl::SecureProtocols,
QSsl::SslOptionDisableLegacyRenegotiation),
- long((SSL_OP_ALL|SSL_OP_NO_SSLv2) & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS));
+ long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3) & ~SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS));
#endif
#ifdef SSL_OP_NO_TICKET
@@ -2329,7 +2329,7 @@ void tst_QSslSocket::sslOptions()
QSsl::SslOptionDisableEmptyFragments
|QSsl::SslOptionDisableLegacyRenegotiation
|QSsl::SslOptionDisableSessionTickets),
- long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_TICKET)));
+ long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET)));
#endif
#ifdef SSL_OP_NO_TICKET
@@ -2339,7 +2339,7 @@ void tst_QSslSocket::sslOptions()
|QSsl::SslOptionDisableLegacyRenegotiation
|QSsl::SslOptionDisableSessionTickets
|QSsl::SslOptionDisableCompression),
- long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_TICKET|SSL_OP_NO_COMPRESSION)));
+ long((SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3|SSL_OP_NO_TICKET|SSL_OP_NO_COMPRESSION)));
#endif
#endif
}
diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
index c42450607d..1be570e4b8 100644
--- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
+++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
@@ -1022,9 +1022,9 @@ void tst_QPrinter::duplex()
{
// duplex()) / setDuplex() / PPK_Duplex
// PdfFormat: Supported, default QPrinter::DuplexNone
- // NativeFormat, Cups: Supported, default QPrinter::DuplexNone
- // NativeFormat, Win: Unsupported, always QPrinter::DuplexNone
- // NativeFormat, Mac: Unsupported, always QPrinter::DuplexNone
+ // NativeFormat, Cups: Supported, default to printer default
+ // NativeFormat, Win: Supported, default to printer default
+ // NativeFormat, Mac: Supported, default to printer default
QPrinter pdf;
pdf.setOutputFormat(QPrinter::PdfFormat);
@@ -1035,15 +1035,17 @@ void tst_QPrinter::duplex()
QPrinter native;
if (native.outputFormat() == QPrinter::NativeFormat) {
// Test default
- // TODO Printer specific, need QPrinterInfo::duplex()
- //QCOMPARE(native.duplex(), QPrinter::DuplexNone);
-
- // Test set/get
- QPrinter::DuplexMode expected = QPrinter::DuplexAuto;
+ QPrinterInfo printerInfo = QPrinterInfo::defaultPrinter();
+ QPrinter::DuplexMode expected = printerInfo.defaultDuplexMode();
+ QCOMPARE(native.duplex(), expected);
+ // Test set/get (skipping Auto as that will return something different)
+ foreach (QPrinter::DuplexMode mode, printerInfo.supportedDuplexModes()) {
+ if (mode != expected && mode != QPrinter::DuplexAuto) {
+ expected = mode;
+ break;
+ }
+ }
native.setDuplex(expected);
-#if defined Q_OS_MAC || defined Q_OS_WIN
- expected = QPrinter::DuplexNone;
-#endif // Q_OS_MAC || Q_OS_WIN
QCOMPARE(native.duplex(), expected);
// Test value preservation
@@ -1051,6 +1053,12 @@ void tst_QPrinter::duplex()
QCOMPARE(native.duplex(), expected);
native.setOutputFormat(QPrinter::NativeFormat);
QCOMPARE(native.duplex(), expected);
+
+ // Test setting invalid option
+ if (!printerInfo.supportedDuplexModes().contains(QPrinter::DuplexLongSide)) {
+ native.setDuplex(QPrinter::DuplexLongSide);
+ QCOMPARE(native.duplex(), expected);
+ }
} else {
QSKIP("No printers installed, cannot test NativeFormat, please install printers to test");
}
@@ -1059,9 +1067,9 @@ void tst_QPrinter::duplex()
void tst_QPrinter::doubleSidedPrinting()
{
// PdfFormat: Supported, default false
- // NativeFormat, Cups: Supported, default false
- // NativeFormat, Win: Unsupported, always false
- // NativeFormat, Mac: Unsupported, always false
+ // NativeFormat, Cups: Supported, default to printer default
+ // NativeFormat, Win: Supported, default to printer default
+ // NativeFormat, Mac: Supported, default to printer default
QPrinter pdf;
pdf.setOutputFormat(QPrinter::PdfFormat);
@@ -1072,15 +1080,13 @@ void tst_QPrinter::doubleSidedPrinting()
QPrinter native;
if (native.outputFormat() == QPrinter::NativeFormat) {
// Test default
- // TODO Printer specific, need QPrinterInfo::duplex()
- //QCOMPARE(native.doubleSidedPrinting(), false);
+ QPrinterInfo printerInfo;
+ bool expected = (printerInfo.defaultDuplexMode() != QPrinter::DuplexNone);
+ QCOMPARE(native.doubleSidedPrinting(), false);
// Test set/get
- bool expected = true;
+ expected = (printerInfo.supportedDuplexModes().count() > 1);
native.setDoubleSidedPrinting(expected);
-#if defined Q_OS_MAC || defined Q_OS_WIN
- expected = false;
-#endif // Q_OS_MAC || Q_OS_WIN
QCOMPARE(native.doubleSidedPrinting(), expected);
// Test value preservation
diff --git a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp
index 88a526ba17..f3e8b9209d 100644
--- a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp
+++ b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp
@@ -298,6 +298,8 @@ void tst_QPrinterInfo::testConstructors()
QCOMPARE(copy1.supportedPaperSizes(), printers.at(i).supportedPaperSizes());
QCOMPARE(copy1.supportedSizesWithNames(), printers.at(i).supportedSizesWithNames());
QCOMPARE(copy1.supportedResolutions(), printers.at(i).supportedResolutions());
+ QCOMPARE(copy1.defaultDuplexMode(), printers.at(i).defaultDuplexMode());
+ QCOMPARE(copy1.supportedDuplexModes(), printers.at(i).supportedDuplexModes());
QPrinter printer(printers.at(i));
QPrinterInfo copy2(printer);
@@ -317,6 +319,8 @@ void tst_QPrinterInfo::testConstructors()
QCOMPARE(copy2.supportedPaperSizes(), printers.at(i).supportedPaperSizes());
QCOMPARE(copy2.supportedSizesWithNames(), printers.at(i).supportedSizesWithNames());
QCOMPARE(copy2.supportedResolutions(), printers.at(i).supportedResolutions());
+ QCOMPARE(copy2.defaultDuplexMode(), printers.at(i).defaultDuplexMode());
+ QCOMPARE(copy2.supportedDuplexModes(), printers.at(i).supportedDuplexModes());
}
}
@@ -347,6 +351,8 @@ void tst_QPrinterInfo::testAssignment()
QCOMPARE(copy.minimumPhysicalPageSize(), printers.at(i).minimumPhysicalPageSize());
QCOMPARE(copy.maximumPhysicalPageSize(), printers.at(i).maximumPhysicalPageSize());
QCOMPARE(copy.supportedResolutions(), printers.at(i).supportedResolutions());
+ QCOMPARE(copy.defaultDuplexMode(), printers.at(i).defaultDuplexMode());
+ QCOMPARE(copy.supportedDuplexModes(), printers.at(i).supportedDuplexModes());
}
}
@@ -371,6 +377,8 @@ void tst_QPrinterInfo::namedPrinter()
QCOMPARE(pi2.minimumPhysicalPageSize(), pi.minimumPhysicalPageSize());
QCOMPARE(pi2.maximumPhysicalPageSize(), pi.maximumPhysicalPageSize());
QCOMPARE(pi2.supportedResolutions(), pi.supportedResolutions());
+ QCOMPARE(pi2.defaultDuplexMode(), pi.defaultDuplexMode());
+ QCOMPARE(pi2.supportedDuplexModes(), pi.supportedDuplexModes());
}
}
#endif // QT_NO_PRINTER
diff --git a/tests/auto/shared/platforminputcontext.h b/tests/auto/shared/platforminputcontext.h
index fc415d833b..22b7ad6610 100644
--- a/tests/auto/shared/platforminputcontext.h
+++ b/tests/auto/shared/platforminputcontext.h
@@ -56,6 +56,8 @@ public:
virtual void reset() { m_resetCallCount++; }
virtual void commit() {
m_commitCallCount++;
+ if (m_commitString.isEmpty())
+ return;
QInputMethodEvent commitEvent;
commitEvent.setCommitString(m_commitString);
if (qGuiApp->focusObject())
diff --git a/tests/auto/gui/text/qglyphrun/test.ttf b/tests/auto/shared/resources/test.ttf
index 382b2547b0..382b2547b0 100644
--- a/tests/auto/gui/text/qglyphrun/test.ttf
+++ b/tests/auto/shared/resources/test.ttf
Binary files differ
diff --git a/tests/auto/gui/text/qrawfont/testfont.ttf b/tests/auto/shared/resources/testfont.ttf
index d6042d2e58..d6042d2e58 100644
--- a/tests/auto/gui/text/qrawfont/testfont.ttf
+++ b/tests/auto/shared/resources/testfont.ttf
Binary files differ
diff --git a/tests/auto/tools/rcc/data/images/images.expected b/tests/auto/tools/rcc/data/images/images.expected
index ae470db336..1f0157d51c 100644
--- a/tests/auto/tools/rcc/data/images/images.expected
+++ b/tests/auto/tools/rcc/data/images/images.expected
@@ -116,6 +116,7 @@ bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *,
}
#endif
+int QT_RCC_MANGLE_NAMESPACE(qInitResources)();
int QT_RCC_MANGLE_NAMESPACE(qInitResources)()
{
QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData)
@@ -123,6 +124,7 @@ int QT_RCC_MANGLE_NAMESPACE(qInitResources)()
return 1;
}
+int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)();
int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)()
{
QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData)
diff --git a/tests/auto/widgets/dialogs/qfontdialog/qfontdialog.pro b/tests/auto/widgets/dialogs/qfontdialog/qfontdialog.pro
index 8116fe379a..dc1702971e 100644
--- a/tests/auto/widgets/dialogs/qfontdialog/qfontdialog.pro
+++ b/tests/auto/widgets/dialogs/qfontdialog/qfontdialog.pro
@@ -7,6 +7,8 @@ QT += core-private gui-private
SOURCES += tst_qfontdialog.cpp
+RESOURCES += testfonts.qrc
+
mac {
# ### fixme
# OBJECTIVE_SOURCES += tst_qfontdialog_mac_helpers.mm
diff --git a/tests/auto/widgets/dialogs/qfontdialog/testfonts.qrc b/tests/auto/widgets/dialogs/qfontdialog/testfonts.qrc
new file mode 100644
index 0000000000..cdfa287b39
--- /dev/null
+++ b/tests/auto/widgets/dialogs/qfontdialog/testfonts.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file alias="test.ttf">../../../shared/resources/test.ttf</file>
+ <file alias="testfont.ttf">../../../shared/resources/testfont.ttf</file>
+ </qresource>
+</RCC>
diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
index 22c84c2244..92ea7e5e57 100644
--- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
+++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
@@ -36,6 +36,7 @@
#include <qapplication.h>
+#include <qfontdatabase.h>
#include <qfontinfo.h>
#include <qtimer.h>
#include <qmainwindow.h>
@@ -70,6 +71,10 @@ private slots:
void setFont();
void task256466_wrongStyle();
void setNonStandardFontSize();
+#ifndef QT_NO_STYLE_STYLESHEET
+ void qtbug_41513_stylesheetStyle();
+#endif
+
private:
void runSlotWithFailsafeTimer(const char *member);
@@ -201,6 +206,31 @@ void tst_QFontDialog::setNonStandardFontSize()
{
runSlotWithFailsafeTimer(SLOT(testNonStandardFontSize()));
}
+#ifndef QT_NO_STYLE_STYLESHEET
+static const QString offendingStyleSheet = QStringLiteral("* { font-family: \"QtBidiTestFont\"; }");
+
+void tst_QFontDialog::qtbug_41513_stylesheetStyle()
+{
+ if (QFontDatabase::addApplicationFont(QFINDTESTDATA("test.ttf")) < 0)
+ QSKIP("Test fonts not found.");
+ if (QFontDatabase::addApplicationFont(QFINDTESTDATA("testfont.ttf")) < 0)
+ QSKIP("Test fonts not found.");
+ QFont testFont = QFont(QStringLiteral("QtsSpecialTestFont"));
+ qApp->setStyleSheet(offendingStyleSheet);
+ bool accepted = false;
+ QTimer::singleShot(2000, this, SLOT(postKeyReturn()));
+ QFont resultFont = QFontDialog::getFont(&accepted, testFont,
+ QApplication::activeWindow(),
+ QLatin1String("QFontDialog - Stylesheet Test"),
+ QFontDialog::DontUseNativeDialog);
+ QVERIFY(accepted);
+
+ QCOMPARE(resultFont, testFont);
+
+ // reset stylesheet
+ qApp->setStyleSheet(QString());
+}
+#endif // QT_NO_STYLE_STYLESHEET
void tst_QFontDialog::testNonStandardFontSize()
{
diff --git a/tests/auto/widgets/gestures/gestures.pro b/tests/auto/widgets/gestures/gestures.pro
new file mode 100644
index 0000000000..5a87a01ee2
--- /dev/null
+++ b/tests/auto/widgets/gestures/gestures.pro
@@ -0,0 +1,6 @@
+TEMPLATE=subdirs
+SUBDIRS=\
+ qgesturerecognizer \
+
+mac: SUBDIRS -= \ # Uses native recognizers
+ qgesturerecognizer \
diff --git a/tests/auto/widgets/gestures/qgesturerecognizer/qgesturerecognizer.pro b/tests/auto/widgets/gestures/qgesturerecognizer/qgesturerecognizer.pro
new file mode 100644
index 0000000000..7c9ddcfb03
--- /dev/null
+++ b/tests/auto/widgets/gestures/qgesturerecognizer/qgesturerecognizer.pro
@@ -0,0 +1,4 @@
+CONFIG += testcase
+TARGET = tst_qgesturerecognizer
+QT += widgets testlib gui-private core-private
+SOURCES += tst_qgesturerecognizer.cpp
diff --git a/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp b/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp
new file mode 100644
index 0000000000..833494f25e
--- /dev/null
+++ b/tests/auto/widgets/gestures/qgesturerecognizer/tst_qgesturerecognizer.cpp
@@ -0,0 +1,336 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QTest>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QWidget>
+#include <QtWidgets/QGestureEvent>
+#include <QtGui/QScreen>
+#include <QtGui/QTouchDevice>
+#include <QtCore/QVector>
+#include <QtCore/QString>
+#include <QtCore/QHash>
+#include <QtCore/QDebug>
+
+#include <qpa/qwindowsysteminterface.h>
+
+class tst_QGestureRecognizer : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QGestureRecognizer();
+
+private Q_SLOTS:
+ void initTestCase();
+#ifndef QT_NO_GESTURES
+ void panGesture_data();
+ void panGesture();
+ void pinchGesture_data();
+ void pinchGesture();
+ void swipeGesture_data();
+ void swipeGesture();
+#endif // !QT_NO_GESTURES
+
+private:
+ const int m_fingerDistance;
+ QTouchDevice *m_touchDevice;
+};
+
+tst_QGestureRecognizer::tst_QGestureRecognizer()
+ : m_fingerDistance(qRound(QGuiApplication::primaryScreen()->physicalDotsPerInch() / 2.0))
+ , m_touchDevice(new QTouchDevice)
+{
+}
+
+void tst_QGestureRecognizer::initTestCase()
+{
+ m_touchDevice->setType(QTouchDevice::TouchScreen);
+ QWindowSystemInterface::registerTouchDevice(m_touchDevice);
+}
+
+#ifndef QT_NO_GESTURES
+
+typedef QVector<Qt::GestureType> GestureTypeVector;
+
+class TestWidget : public QWidget
+{
+public:
+ explicit TestWidget(const GestureTypeVector &gestureTypes);
+
+ bool gestureReceived(Qt::GestureType gestureType) const
+ { return m_receivedGestures.value(gestureType); }
+
+protected:
+ bool event(QEvent * event) Q_DECL_OVERRIDE;
+
+private:
+ typedef QHash<Qt::GestureType, bool> GestureTypeHash;
+ GestureTypeHash m_receivedGestures;
+};
+
+TestWidget::TestWidget(const GestureTypeVector &gestureTypes)
+{
+ setAttribute(Qt::WA_AcceptTouchEvents);
+
+ foreach (Qt::GestureType gestureType, gestureTypes) {
+ grabGesture(gestureType);
+ m_receivedGestures.insert(gestureType, false);
+ }
+
+ const QRect geometry = QGuiApplication::primaryScreen()->availableGeometry();
+ const QSize size = geometry.size() / 2;
+ resize(size);
+ move(geometry.center() - QPoint(size.width() / 2, size.height() / 2));
+}
+
+bool TestWidget::event(QEvent * event)
+{
+ switch (event->type()) {
+ case QEvent::Gesture: {
+ const QGestureEvent *gestureEvent = static_cast<QGestureEvent *>(event);
+ const GestureTypeHash::iterator hend = m_receivedGestures.end();
+ for (GestureTypeHash::iterator it = m_receivedGestures.begin(); it != hend; ++it) {
+ if (const QGesture *gesture = gestureEvent->gesture(it.key())) {
+ if (gesture->state() == Qt::GestureFinished)
+ it.value() = true;
+ }
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ return QWidget::event(event);
+}
+
+static void pressSequence(QTest::QTouchEventSequence &sequence,
+ QVector<QPoint> &points,
+ QWidget *widget)
+{
+ const int pointCount = points.size();
+ for (int p = 0; p < pointCount; ++p)
+ sequence.press(p, points.at(p), widget);
+ sequence.commit();
+}
+
+static void linearSequence(int n, const QPoint &delta,
+ QTest::QTouchEventSequence &sequence,
+ QVector<QPoint> &points,
+ QWidget *widget)
+{
+ const int pointCount = points.size();
+ for (int s = 0; s < n; ++s) {
+ for (int p = 0; p < pointCount; ++p) {
+ points[p] += delta;
+ sequence.move(p, points[p], widget);
+ }
+ sequence.commit();
+ }
+}
+
+static void releaseSequence(QTest::QTouchEventSequence &sequence,
+ QVector<QPoint> &points,
+ QWidget *widget)
+{
+ const int pointCount = points.size();
+ for (int p = 0; p < pointCount; ++p)
+ sequence.release(p, points[p], widget);
+ sequence.commit();
+}
+
+// --- Pan
+
+enum PanSubTest {
+ TwoFingerPanSubTest
+};
+
+void tst_QGestureRecognizer::panGesture_data()
+{
+ QTest::addColumn<int>("panSubTest");
+ QTest::addColumn<bool>("gestureExpected");
+ QTest::newRow("Two finger") << int(TwoFingerPanSubTest) << true;
+}
+
+void tst_QGestureRecognizer::panGesture()
+{
+ QFETCH(int, panSubTest);
+ QFETCH(bool, gestureExpected);
+
+ Q_UNUSED(panSubTest) // Single finger pan will be added later.
+
+ const int panPoints = 2;
+ const Qt::GestureType gestureType = Qt::PanGesture;
+ TestWidget widget(GestureTypeVector(1, gestureType));
+ widget.setWindowTitle(QTest::currentTestFunction());
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+
+ QVector<QPoint> points;
+ for (int i = 0; i < panPoints; ++i)
+ points.append(QPoint(10 + i *20, 10 + i *20));
+
+ QTest::QTouchEventSequence panSequence = QTest::touchEvent(&widget, m_touchDevice);
+ pressSequence(panSequence, points, &widget);
+ linearSequence(5, QPoint(20, 20), panSequence, points, &widget);
+ releaseSequence(panSequence, points, &widget);
+
+ if (gestureExpected) {
+ QTRY_VERIFY(widget.gestureReceived(gestureType));
+ } else {
+ QCoreApplication::processEvents();
+ QVERIFY(!widget.gestureReceived(gestureType));
+ }
+}
+
+// --- Pinch
+
+enum PinchSubTest {
+ StandardPinchSubTest
+};
+
+void tst_QGestureRecognizer::pinchGesture_data()
+{
+ QTest::addColumn<int>("pinchSubTest");
+ QTest::addColumn<bool>("gestureExpected");
+ QTest::newRow("Standard") << int(StandardPinchSubTest) << true;
+}
+
+void tst_QGestureRecognizer::pinchGesture()
+{
+ QFETCH(int, pinchSubTest);
+ QFETCH(bool, gestureExpected);
+
+ Q_UNUSED(pinchSubTest)
+
+ const Qt::GestureType gestureType = Qt::PinchGesture;
+ TestWidget widget(GestureTypeVector(1, gestureType));
+ widget.setWindowTitle(QTest::currentTestFunction());
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+
+ QVector<QPoint> points;
+ points.append(widget.rect().center());
+ points.append(points.front() + QPoint(0, 20));
+
+ QTest::QTouchEventSequence pinchSequence = QTest::touchEvent(&widget, m_touchDevice);
+ pressSequence(pinchSequence, points, &widget);
+
+ for (int s = 0; s < 5; ++s) {
+ points[0] += QPoint(5, 30);
+ pinchSequence.move(0, points[0], &widget);
+ points[1] += QPoint(5, -30);
+ pinchSequence.move(1, points[1], &widget);
+ pinchSequence.commit();
+ }
+
+ releaseSequence(pinchSequence, points, &widget);
+
+ if (gestureExpected) {
+ QTRY_VERIFY(widget.gestureReceived(gestureType));
+ } else {
+ QCoreApplication::processEvents();
+ QVERIFY(!widget.gestureReceived(gestureType));
+ }
+}
+
+// --- Swipe
+
+enum SwipeSubTest {
+ SwipeLineSubTest,
+ SwipeChangeDirectionSubTest,
+};
+
+void tst_QGestureRecognizer::swipeGesture_data()
+{
+ QTest::addColumn<int>("swipeSubTest");
+ QTest::addColumn<bool>("gestureExpected");
+ QTest::newRow("Line") << int(SwipeLineSubTest) << true;
+ QTest::newRow("ChangeDirection") << int(SwipeChangeDirectionSubTest) << false;
+}
+
+void tst_QGestureRecognizer::swipeGesture()
+{
+ enum { swipePoints = 3 };
+
+ QFETCH(int, swipeSubTest);
+ QFETCH(bool, gestureExpected);
+
+ const Qt::GestureType gestureType = Qt::SwipeGesture;
+ TestWidget widget(GestureTypeVector(1, gestureType));
+ widget.setWindowTitle(QTest::currentTestFunction());
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+
+ // Start a swipe sequence with 2 points (QTBUG-15768)
+ const QPoint fingerDistance(m_fingerDistance, m_fingerDistance);
+ QVector<QPoint> points;
+ for (int i = 0; i < swipePoints - 1; ++i)
+ points.append(fingerDistance + i * fingerDistance);
+
+ QTest::QTouchEventSequence swipeSequence = QTest::touchEvent(&widget, m_touchDevice);
+ pressSequence(swipeSequence, points, &widget);
+
+ // Press point #3
+ points.append(points.last() + fingerDistance);
+ swipeSequence.press(points.size() - 1, points.last(), &widget);
+ swipeSequence.commit();
+ Q_ASSERT(points.size() == swipePoints);
+
+ // Move.
+ const QPoint moveDelta(60, 20);
+ switch (swipeSubTest) {
+ case SwipeLineSubTest:
+ linearSequence(5, moveDelta, swipeSequence, points, &widget);
+ break;
+ case SwipeChangeDirectionSubTest:
+ linearSequence(5, moveDelta, swipeSequence, points, &widget);
+ linearSequence(3, QPoint(-moveDelta.x(), moveDelta.y()), swipeSequence, points, &widget);
+ break;
+ }
+
+ releaseSequence(swipeSequence, points, &widget);
+
+ if (gestureExpected) {
+ QTRY_VERIFY(widget.gestureReceived(gestureType));
+ } else {
+ QCoreApplication::processEvents();
+ QVERIFY(!widget.gestureReceived(gestureType));
+ }
+}
+
+#endif // !QT_NO_GESTURES
+
+QTEST_MAIN(tst_QGestureRecognizer)
+
+#include "tst_qgesturerecognizer.moc"
diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
index c90c431d8b..3b55fcd5fc 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
@@ -124,6 +124,7 @@ private slots:
void heightForWidthWithSpanning();
void stretchAndHeightForWidth();
void testDefaultAlignment();
+ void hiddenItems();
};
class RectWidget : public QGraphicsWidget
@@ -3485,6 +3486,94 @@ void tst_QGraphicsGridLayout::testDefaultAlignment()
QCOMPARE(w->geometry(), QRectF(0,0,50,50));
QCOMPARE(w2->geometry(), QRectF(0,50,100,100));
}
+
+static RectWidget *addWidget(QGraphicsGridLayout *grid, int row, int column)
+{
+ RectWidget *w = new RectWidget;
+ w->setPreferredSize(20, 20);
+ grid->addItem(w, row, column);
+ return w;
+}
+
+static void setVisible(bool visible, QGraphicsWidget **widgets)
+{
+ for (int i = 0; i < 3; ++i)
+ if (widgets[i]) widgets[i]->setVisible(visible);
+}
+
+static void setRetainSizeWhenHidden(bool retainSize, QGraphicsWidget **widgets)
+{
+ QSizePolicy sp = widgets[0]->sizePolicy();
+ sp.setRetainSizeWhenHidden(retainSize);
+ for (int i = 0; i < 3; ++i)
+ if (widgets[i]) widgets[i]->setSizePolicy(sp);
+}
+
+void tst_QGraphicsGridLayout::hiddenItems()
+{
+ QGraphicsWidget *widget = new QGraphicsWidget;
+ QGraphicsGridLayout *layout = new QGraphicsGridLayout(widget);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->setSpacing(2);
+
+ // Create a 3x3 layout
+ addWidget(layout, 0, 0);
+ RectWidget *w01 = addWidget(layout, 0, 1);
+ addWidget(layout, 0, 2);
+ RectWidget *w10 = addWidget(layout, 1, 0);
+ RectWidget *w11 = addWidget(layout, 1, 1);
+ RectWidget *w12 = addWidget(layout, 1, 2);
+ addWidget(layout, 2, 0);
+ RectWidget *w21 = addWidget(layout, 2, 1);
+ addWidget(layout, 2, 2);
+
+ QGraphicsWidget *middleColumn[] = {w01, w11, w21 };
+ QGraphicsWidget *topTwoOfMiddleColumn[] = {w01, w11, 0 };
+
+ // hide and show middle column
+ QCOMPARE(layout->preferredWidth(), qreal(64));
+ setVisible(false, middleColumn); // hide middle column
+ QCOMPARE(layout->preferredWidth(), qreal(42));
+ setVisible(true, middleColumn); // show middle column
+ QCOMPARE(layout->preferredWidth(), qreal(64));
+ setRetainSizeWhenHidden(true, middleColumn);
+ QCOMPARE(layout->preferredWidth(), qreal(64));
+ setVisible(false, middleColumn); // hide middle column
+ QCOMPARE(layout->preferredWidth(), qreal(64));
+ setRetainSizeWhenHidden(false, middleColumn);
+ QCOMPARE(layout->preferredWidth(), qreal(42));
+ setVisible(true, middleColumn);
+ QCOMPARE(layout->preferredWidth(), qreal(64));
+
+ // Hide only two items, => column should not collapse
+ setVisible(false, topTwoOfMiddleColumn);
+ QCOMPARE(layout->preferredWidth(), qreal(64));
+
+
+ QGraphicsWidget *middleRow[] = {w10, w11, w12 };
+ QGraphicsWidget *leftMostTwoOfMiddleRow[] = {w10, w11, 0 };
+
+ // hide and show middle row
+ QCOMPARE(layout->preferredHeight(), qreal(64));
+ setVisible(false, middleRow);
+ QCOMPARE(layout->preferredHeight(), qreal(42));
+ setVisible(true, middleRow);
+ QCOMPARE(layout->preferredHeight(), qreal(64));
+ setRetainSizeWhenHidden(true, middleColumn);
+ QCOMPARE(layout->preferredHeight(), qreal(64));
+ setVisible(false, middleRow);
+ QCOMPARE(layout->preferredHeight(), qreal(64));
+ setRetainSizeWhenHidden(false, middleRow);
+ QCOMPARE(layout->preferredHeight(), qreal(42));
+ setVisible(true, middleRow);
+ QCOMPARE(layout->preferredHeight(), qreal(64));
+
+ // Hide only two items => row should not collapse
+ setVisible(false, leftMostTwoOfMiddleRow);
+ QCOMPARE(layout->preferredHeight(), qreal(64));
+
+}
+
QTEST_MAIN(tst_QGraphicsGridLayout)
#include "tst_qgraphicsgridlayout.moc"
diff --git a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
index d35667f215..107e3eb48a 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
@@ -50,6 +50,7 @@ private slots:
void compressLayoutRequest();
void automaticReparenting();
void verifyActivate();
+ void sizeHintOfHiddenLayout();
void invalidate();
void constructors();
void alternativeLayoutItems();
@@ -279,6 +280,30 @@ void tst_QGraphicsLayout::verifyActivate()
}
+
+void tst_QGraphicsLayout::sizeHintOfHiddenLayout()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+
+ QGraphicsWidget *window = new QGraphicsWidget(0, Qt::Window);
+ scene.addItem(window);
+ TestLayout *lout = new TestLayout(window);
+ lout->setContentsMargins(1,2,2,1);
+ QGraphicsWidget *w = new QGraphicsWidget;
+ w->setPreferredSize(20, 20);
+ w->setMaximumSize(50, 50);
+ lout->addItem(w);
+ window->setLayout(lout);
+
+ for (int pass = 0; pass < 3; ++pass) {
+ QCOMPARE(lout->sizeHint(Qt::MinimumSize), QSizeF(3,3));
+ QCOMPARE(lout->sizeHint(Qt::PreferredSize), QSizeF(23,23));
+ QCOMPARE(lout->sizeHint(Qt::MaximumSize), QSizeF(53,53));
+ window->setVisible(pass % 2);
+ }
+}
+
static void clearAllCounters(TestGraphicsWidget *widget)
{
if (!widget)
diff --git a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
index 7147bb8cce..1513abf0b1 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
@@ -103,6 +103,7 @@ private slots:
void testOffByOneInLargerLayout();
void testDefaultAlignment();
void combineSizePolicies();
+ void hiddenItems();
// Task specific tests
void task218400_insertStretchCrash();
@@ -1721,6 +1722,41 @@ void tst_QGraphicsLinearLayout::combineSizePolicies()
QCOMPARE(layout->maximumHeight(), qreal(200));
}
+void tst_QGraphicsLinearLayout::hiddenItems()
+{
+ QGraphicsWidget *widget = new QGraphicsWidget;
+ QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal, widget);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->setSpacing(2);
+
+ RectWidget *w1 = new RectWidget;
+ w1->setPreferredSize(QSizeF(20, 20));
+ layout->addItem(w1);
+
+ RectWidget *w2 = new RectWidget;
+ w2->setPreferredSize(QSizeF(20, 20));
+ layout->addItem(w2);
+
+ RectWidget *w3 = new RectWidget;
+ w3->setPreferredSize(QSizeF(20, 20));
+ layout->addItem(w3);
+
+ QCOMPARE(layout->preferredWidth(), qreal(64));
+ w2->hide();
+ QCOMPARE(layout->preferredWidth(), qreal(42));
+ w2->show();
+ QCOMPARE(layout->preferredWidth(), qreal(64));
+ QSizePolicy sp = w2->sizePolicy();
+ sp.setRetainSizeWhenHidden(true);
+ w2->setSizePolicy(sp);
+ QCOMPARE(layout->preferredWidth(), qreal(64));
+ w2->hide();
+ QCOMPARE(layout->preferredWidth(), qreal(64));
+ sp.setRetainSizeWhenHidden(false);
+ w2->setSizePolicy(sp);
+ QCOMPARE(layout->preferredWidth(), qreal(42));
+}
+
QTEST_MAIN(tst_QGraphicsLinearLayout)
#include "tst_qgraphicslinearlayout.moc"
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index ab84c9e482..66d0f64ceb 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -174,6 +174,7 @@ private slots:
void clickFocus();
void windowFrameMargins();
void QTBUG_6986_sendMouseEventToAlienWidget();
+ void mapToGlobal();
};
// Subclass that exposes the protected functions.
@@ -3659,5 +3660,32 @@ void tst_QGraphicsProxyWidget::QTBUG_6986_sendMouseEventToAlienWidget()
QTRY_COMPARE(scene.hoverButton->hoverLeaveReceived, true);
}
+void tst_QGraphicsProxyWidget::mapToGlobal() // QTBUG-41135
+{
+ const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry();
+ const QSize size = availableGeometry.size() / 5;
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ view.setWindowTitle(QTest::currentTestFunction());
+ view.resize(size);
+ view.move(availableGeometry.bottomRight() - QPoint(size.width(), size.height()) - QPoint(100, 100));
+ QWidget *embeddedWidget = new QWidget;
+ embeddedWidget->setFixedSize(size / 2);
+ scene.addWidget(embeddedWidget);
+ QApplication::setActiveWindow(&view);
+ view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ const QPoint embeddedCenter = embeddedWidget->geometry().center();
+ const QPoint embeddedCenterGlobal = embeddedWidget->mapToGlobal(embeddedCenter);
+ QCOMPARE(embeddedWidget->mapFromGlobal(embeddedCenterGlobal), embeddedCenter);
+ // This should be equivalent to the view center give or take rounding
+ // errors due to odd window margins
+ const QPoint viewCenter = view.geometry().center();
+ QVERIFY2((viewCenter - embeddedCenterGlobal).manhattanLength() <= 2,
+ qPrintable(QStringLiteral("%1, %2 != %3, %4")
+ .arg(viewCenter.x()).arg(viewCenter.y())
+ .arg(embeddedCenterGlobal.x()).arg(embeddedCenterGlobal.y())));
+}
+
QTEST_MAIN(tst_QGraphicsProxyWidget)
#include "tst_qgraphicsproxywidget.moc"
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
index 70448f9813..bd1c6a0dc5 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -242,6 +242,7 @@ private slots:
void style();
void sorting_data();
void sorting();
+ void insertionOrder();
void changedSignal_data();
void changedSignal();
void stickyFocus_data();
@@ -3633,6 +3634,42 @@ void tst_QGraphicsScene::sorting()
<< t_1);
}
+void tst_QGraphicsScene::insertionOrder()
+{
+ QGraphicsScene scene;
+ const int numItems = 5;
+ QList<QGraphicsItem*> items;
+
+ for (int i = 0; i < numItems; ++i) {
+ QGraphicsRectItem* item = new QGraphicsRectItem(i * 20, i * 20, 200, 200);
+ item->setData(0, i);
+ items.append(item);
+ scene.addItem(item);
+ }
+
+ {
+ QList<QGraphicsItem*> itemList = scene.items();
+ QCOMPARE(itemList.count(), numItems);
+ for (int i = 0; i < itemList.count(); ++i) {
+ QCOMPARE(numItems-1-i, itemList.at(i)->data(0).toInt());
+ }
+ }
+
+ for (int i = 0; i < items.size(); ++i)
+ {
+ scene.removeItem(items.at(i));
+ scene.addItem(items.at(i));
+ }
+
+ {
+ QList<QGraphicsItem*> itemList = scene.items();
+ QCOMPARE(itemList.count(), numItems);
+ for (int i = 0; i < itemList.count(); ++i) {
+ QCOMPARE(numItems-1-i, itemList.at(i)->data(0).toInt());
+ }
+ }
+}
+
class ChangedListener : public QObject
{
Q_OBJECT
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index d38bb86487..afd8be71e8 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
@@ -160,6 +160,7 @@ private slots:
void dragMode_scrollHand();
void dragMode_rubberBand();
void rubberBandSelectionMode();
+ void rotated_rubberBand();
void backgroundBrush();
void foregroundBrush();
void matrix();
@@ -935,6 +936,48 @@ void tst_QGraphicsView::rubberBandSelectionMode()
QCOMPARE(scene.selectedItems(), QList<QGraphicsItem *>() << rect);
}
+void tst_QGraphicsView::rotated_rubberBand()
+{
+ QWidget toplevel;
+ setFrameless(&toplevel);
+
+ QGraphicsScene scene;
+ const int dim = 3;
+ for (int i = 0; i < dim; i++) {
+ for (int j = 0; j < dim; j ++) {
+ QGraphicsRectItem *rect = new QGraphicsRectItem(i * 20, j * 20, 10, 10);
+ rect->setFlag(QGraphicsItem::ItemIsSelectable);
+ rect->setData(0, (i == j));
+ scene.addItem(rect);
+ }
+ }
+
+ QGraphicsView view(&scene, &toplevel);
+ QCOMPARE(view.rubberBandSelectionMode(), Qt::IntersectsItemShape);
+ view.setDragMode(QGraphicsView::RubberBandDrag);
+ view.resize(120, 120);
+ view.rotate(45);
+ toplevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&toplevel));
+
+ // Disable mouse tracking to prevent the window system from sending mouse
+ // move events to the viewport while we are synthesizing events. If
+ // QGraphicsView gets a mouse move event with no buttons down, it'll
+ // terminate the rubber band.
+ view.viewport()->setMouseTracking(false);
+
+ QCOMPARE(scene.selectedItems(), QList<QGraphicsItem *>());
+ int midWidth = view.viewport()->width() / 2;
+ sendMousePress(view.viewport(), QPoint(midWidth - 2, 0), Qt::LeftButton);
+ sendMouseMove(view.viewport(), QPoint(midWidth + 2, view.viewport()->height()),
+ Qt::LeftButton, Qt::LeftButton);
+ QCOMPARE(scene.selectedItems().count(), dim);
+ foreach (const QGraphicsItem *item, scene.items()) {
+ QCOMPARE(item->isSelected(), item->data(0).toBool());
+ }
+ sendMouseRelease(view.viewport(), QPoint(), Qt::LeftButton);
+}
+
void tst_QGraphicsView::backgroundBrush()
{
QGraphicsScene scene;
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index ec3e8ece6a..44d7671ca3 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -55,6 +55,7 @@
#include <qmainwindow.h>
#include <qdockwidget.h>
#include <qtoolbar.h>
+#include <qtoolbutton.h>
#include <QtGui/qpaintengine.h>
#include <QtGui/qbackingstore.h>
#include <QtGui/qguiapplication.h>
@@ -268,6 +269,7 @@ private slots:
void winIdChangeEvent();
void persistentWinId();
void showNativeChild();
+ void transientParent();
void qobject_castInDestroyedSlot();
void showHideEvent_data();
@@ -3992,6 +3994,21 @@ void tst_QWidget::persistentWinId()
QCOMPARE(w3->winId(), winId3);
}
+void tst_QWidget::transientParent()
+{
+ QWidget topLevel;
+ topLevel.setGeometry(QRect(m_availableTopLeft + QPoint(100, 100), m_testWidgetSize));
+ topLevel.setWindowTitle(__FUNCTION__);
+ QWidget *child = new QWidget(&topLevel);
+ QMenu *menu = new QMenu(child); // QTBUG-41898: Use top level as transient parent for native widgets as well.
+ QToolButton *toolButton = new QToolButton(child);
+ toolButton->setMenu(menu);
+ toolButton->winId();
+ topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+ QCOMPARE(menu->windowHandle()->transientParent(), topLevel.windowHandle());
+}
+
void tst_QWidget::showNativeChild()
{
QWidget topLevel;
diff --git a/tests/auto/widgets/widgets.pro b/tests/auto/widgets/widgets.pro
index 8b6c4722be..efcc47171d 100644
--- a/tests/auto/widgets/widgets.pro
+++ b/tests/auto/widgets/widgets.pro
@@ -8,3 +8,4 @@ SUBDIRS=\
styles \
util \
widgets \
+ gestures \
diff --git a/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp
index e3e7b13cbe..d0a787d32a 100644
--- a/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp
+++ b/tests/auto/widgets/widgets/qcalendarwidget/tst_qcalendarwidget.cpp
@@ -67,6 +67,8 @@ private slots:
void showPrevNext();
void firstDayOfWeek();
+
+ void contentsMargins();
};
// Testing get/set functions
@@ -391,5 +393,13 @@ void tst_QCalendarWidget::firstDayOfWeek()
QCOMPARE(calendar.firstDayOfWeek(), germanLocale.firstDayOfWeek());
}
+void tst_QCalendarWidget::contentsMargins()
+{
+ QCalendarWidget calendar1;
+ QCalendarWidget calendar2;
+ calendar2.setContentsMargins(10, 5, 20, 30);
+ QCOMPARE(calendar1.minimumSizeHint() + QSize(30, 35), calendar2.minimumSizeHint());
+}
+
QTEST_MAIN(tst_QCalendarWidget)
#include "tst_qcalendarwidget.moc"
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index 54cf1af5d3..ac32ee4968 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -152,6 +152,7 @@ private slots:
void resetModel();
void keyBoardNavigationWithMouse();
void task_QTBUG_1071_changingFocusEmitsActivated();
+ void maxVisibleItems_data();
void maxVisibleItems();
void task_QTBUG_10491_currentIndexAndModelColumn();
void highlightedSignal();
@@ -159,6 +160,7 @@ private slots:
void task_QTBUG_31146_popupCompletion();
void keyboardSelection();
void setCustomModelAndView();
+ void updateDelegateOnEditableChange();
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
@@ -2749,8 +2751,18 @@ void tst_QComboBox::task_QTBUG_1071_changingFocusEmitsActivated()
QTRY_COMPARE(spy.count(), 1);
}
+void tst_QComboBox::maxVisibleItems_data()
+{
+ QTest::addColumn<int>("spacing");
+ QTest::newRow("Default") << -1;
+ QTest::newRow("No spacing") << 0;
+ QTest::newRow("20") << -1;
+}
+
void tst_QComboBox::maxVisibleItems()
{
+ QFETCH(int, spacing);
+
QComboBox comboBox;
QCOMPARE(comboBox.maxVisibleItems(), 10); //default value.
@@ -2771,15 +2783,18 @@ void tst_QComboBox::maxVisibleItems()
QTRY_VERIFY(comboBox.view());
QTRY_VERIFY(comboBox.view()->isVisible());
- QAbstractItemView *v = comboBox.view();
- int itemHeight = v->visualRect(v->model()->index(0,0)).height();
- QListView *lv = qobject_cast<QListView*>(v);
- if (lv)
- itemHeight += lv->spacing();
+ QListView *listView = qobject_cast<QListView*>(comboBox.view());
+ QVERIFY(listView);
+ if (spacing >= 0)
+ listView->setSpacing(spacing);
+
+ const int itemHeight = listView->visualRect(listView->model()->index(0,0)).height()
+ + 2 * listView->spacing();
+
QStyleOptionComboBox opt;
opt.initFrom(&comboBox);
if (!comboBox.style()->styleHint(QStyle::SH_ComboBox_Popup, &opt))
- QCOMPARE(v->viewport()->height(), itemHeight * comboBox.maxVisibleItems());
+ QCOMPARE(listView->viewport()->height(), itemHeight * comboBox.maxVisibleItems());
}
void tst_QComboBox::task_QTBUG_10491_currentIndexAndModelColumn()
@@ -3035,5 +3050,32 @@ void tst_QComboBox::keyboardSelection()
QCOMPARE(comboBox.currentText(), list.at(1));
}
+void tst_QComboBox::updateDelegateOnEditableChange()
+{
+
+ QComboBox box;
+ box.addItem(QStringLiteral("Foo"));
+ box.addItem(QStringLiteral("Bar"));
+ box.setEditable(false);
+
+ QComboBoxPrivate *d = static_cast<QComboBoxPrivate *>(QComboBoxPrivate::get(&box));
+
+ {
+ bool menuDelegateBefore = qobject_cast<QComboMenuDelegate *>(box.itemDelegate()) != 0;
+ d->updateDelegate();
+ bool menuDelegateAfter = qobject_cast<QComboMenuDelegate *>(box.itemDelegate()) != 0;
+ QCOMPARE(menuDelegateAfter, menuDelegateBefore);
+ }
+
+ box.setEditable(true);
+
+ {
+ bool menuDelegateBefore = qobject_cast<QComboMenuDelegate *>(box.itemDelegate()) != 0;
+ d->updateDelegate();
+ bool menuDelegateAfter = qobject_cast<QComboMenuDelegate *>(box.itemDelegate()) != 0;
+ QCOMPARE(menuDelegateAfter, menuDelegateBefore);
+ }
+}
+
QTEST_MAIN(tst_QComboBox)
#include "tst_qcombobox.moc"
diff --git a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
index ebda07ee0c..27c803b43d 100644
--- a/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
+++ b/tests/auto/widgets/widgets/qmainwindow/tst_qmainwindow.cpp
@@ -137,6 +137,7 @@ private slots:
#endif
void addToolbarAfterShow();
void centralWidgetSize();
+ void fixedSizeCentralWidget();
void dockWidgetSize();
void QTBUG2774_stylechange();
void QTBUG15080_restoreState();
@@ -1737,6 +1738,50 @@ void tst_QMainWindow::centralWidgetSize()
QTRY_COMPARE(widget.size(), widget.sizeHint());
}
+void tst_QMainWindow::fixedSizeCentralWidget()
+{
+ // QTBUG-40410: dock widgets does not get all the available space when
+ // central widget is fixed size
+ QMainWindow mainWindow;
+ mainWindow.setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
+
+ MyWidget widget;
+ widget.setFixedSize(100,100);
+ mainWindow.setCentralWidget(&widget);
+
+ QDockWidget dock("D1");
+ QWidget *child = new MyWidget;
+ dock.setWidget(child);
+ mainWindow.addDockWidget(Qt::TopDockWidgetArea, &dock);
+
+ QDockWidget dock2("D2");
+ dock2.setWidget(new MyWidget);
+ mainWindow.addDockWidget(Qt::LeftDockWidgetArea, &dock2);
+
+ QSize sizeH = mainWindow.sizeHint();
+ QSize mwSize = QSize(sizeH.width(), sizeH.height() * 2);
+ mainWindow.resize(mwSize);
+ mainWindow.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&mainWindow));
+ if (mainWindow.height() < mwSize.height())
+ QSKIP("The screen is too small for this test");
+
+ // first, check that we get more than the size hint when we have more space
+ QTRY_VERIFY(child->height() > child->sizeHint().height());
+ int childHeight = child->height();
+
+ if (qGuiApp->styleHints()->showIsFullScreen())
+ QSKIP("The platform is auto maximizing, so we cannot resize the window");
+
+ // then, check that we get nothing when there is no space
+ mainWindow.resize(100,100);
+ QTRY_COMPARE(child->height(), 0);
+
+ // finally verify that we get the space back when we resize to the old size
+ mainWindow.resize(mwSize);
+ QTRY_COMPARE(child->height(), childHeight);
+}
+
void tst_QMainWindow::dockWidgetSize()
{
QMainWindow mainWindow;
diff --git a/tests/manual/cocoa/qsystemtrayicon/icons.qrc b/tests/manual/cocoa/qsystemtrayicon/icons.qrc
new file mode 100644
index 0000000000..2486dcab34
--- /dev/null
+++ b/tests/manual/cocoa/qsystemtrayicon/icons.qrc
@@ -0,0 +1,11 @@
+<RCC>
+ <qresource prefix="/">
+ <file>macsystray18x18.png</file>
+ <file>macsystray36x36.png</file>
+ <file>macsystray25x15.png</file>
+ <file>macsystray50x30.png</file>
+ <file>macsystray16x16.png</file>
+ <file>macsystray32x32.png</file>
+ <file>macsystray64x64.png</file>
+ </qresource>
+</RCC>
diff --git a/tests/manual/cocoa/qsystemtrayicon/macsystray16x16.png b/tests/manual/cocoa/qsystemtrayicon/macsystray16x16.png
new file mode 100644
index 0000000000..e6930f16c6
--- /dev/null
+++ b/tests/manual/cocoa/qsystemtrayicon/macsystray16x16.png
Binary files differ
diff --git a/tests/manual/cocoa/qsystemtrayicon/macsystray18x18.png b/tests/manual/cocoa/qsystemtrayicon/macsystray18x18.png
new file mode 100644
index 0000000000..4316516d85
--- /dev/null
+++ b/tests/manual/cocoa/qsystemtrayicon/macsystray18x18.png
Binary files differ
diff --git a/tests/manual/cocoa/qsystemtrayicon/macsystray25x15.png b/tests/manual/cocoa/qsystemtrayicon/macsystray25x15.png
new file mode 100644
index 0000000000..c1a98b898c
--- /dev/null
+++ b/tests/manual/cocoa/qsystemtrayicon/macsystray25x15.png
Binary files differ
diff --git a/tests/manual/cocoa/qsystemtrayicon/macsystray32x32.png b/tests/manual/cocoa/qsystemtrayicon/macsystray32x32.png
new file mode 100644
index 0000000000..35f0f28ae7
--- /dev/null
+++ b/tests/manual/cocoa/qsystemtrayicon/macsystray32x32.png
Binary files differ
diff --git a/tests/manual/cocoa/qsystemtrayicon/macsystray36x36.png b/tests/manual/cocoa/qsystemtrayicon/macsystray36x36.png
new file mode 100644
index 0000000000..d2c6df066c
--- /dev/null
+++ b/tests/manual/cocoa/qsystemtrayicon/macsystray36x36.png
Binary files differ
diff --git a/tests/manual/cocoa/qsystemtrayicon/macsystray50x30.png b/tests/manual/cocoa/qsystemtrayicon/macsystray50x30.png
new file mode 100644
index 0000000000..afea90b7fe
--- /dev/null
+++ b/tests/manual/cocoa/qsystemtrayicon/macsystray50x30.png
Binary files differ
diff --git a/tests/manual/cocoa/qsystemtrayicon/macsystray64x64.png b/tests/manual/cocoa/qsystemtrayicon/macsystray64x64.png
new file mode 100644
index 0000000000..b2a126d78f
--- /dev/null
+++ b/tests/manual/cocoa/qsystemtrayicon/macsystray64x64.png
Binary files differ
diff --git a/tests/manual/cocoa/qsystemtrayicon/main.cpp b/tests/manual/cocoa/qsystemtrayicon/main.cpp
new file mode 100644
index 0000000000..9b3fc2bd13
--- /dev/null
+++ b/tests/manual/cocoa/qsystemtrayicon/main.cpp
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/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 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <QtWidgets>
+
+int main(int argc, char**argv)
+{
+ QApplication app(argc, argv);
+
+ QWidget window;
+ window.show();
+
+ QSystemTrayIcon systrayIcon(&window);
+
+
+ enum Iconset { Square, // square icons, reccomended size (18 device-independent pixels or less)
+ Rectangular, // rectangular icons, good size
+ PowerOfTwo, // standard pow-2 icons, not optimized for the OS X menu bar
+ Small, // Not enough pixels
+ UnreasonablyLarge // please do something reasonable with my unreasonably large pixmap
+ };
+
+ // Select icon set and load images
+ Iconset iconset = Square;
+ QIcon icon;
+ switch (iconset) {
+ case Square:
+ icon.addFile(":/macsystray36x36.png");
+ icon.addFile(":/macsystray18x18.png");
+ break;
+ case Rectangular:
+ icon.addFile(":/macsystray50x30.png");
+ icon.addFile(":/macsystray25x15.png");
+ break;
+ case PowerOfTwo:
+ icon.addFile(":/macsystray16x16.png");
+ icon.addFile(":/macsystray32x32.png");
+ icon.addFile(":/macsystray64x64.png");
+ break;
+ case Small:
+ icon.addFile(":/macsystray16x16.png");
+ case UnreasonablyLarge:
+ icon.addFile(":/macsystray64x64.png");
+ break;
+ }
+
+ systrayIcon.setIcon(icon);
+ systrayIcon.show();
+
+ return app.exec();
+}
diff --git a/tests/manual/cocoa/qsystemtrayicon/qsystemtrayicon.pro b/tests/manual/cocoa/qsystemtrayicon/qsystemtrayicon.pro
new file mode 100644
index 0000000000..459ebafa38
--- /dev/null
+++ b/tests/manual/cocoa/qsystemtrayicon/qsystemtrayicon.pro
@@ -0,0 +1,7 @@
+TEMPLATE = app
+TARGET = qsystemtrayicon
+INCLUDEPATH += .
+QT += widgets
+
+SOURCES += main.cpp
+RESOURCES += icons.qrc
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index 99ecc7b2de..92422c2829 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -2022,7 +2022,8 @@ QString Configure::locateFile(const QString &fileName) const
if (file.endsWith(".h")) {
static const QStringList headerPaths =
Environment::headerPaths(Environment::compilerFromQMakeSpec(dictionary[QStringLiteral("QMAKESPEC")]));
- pathList = headerPaths;
+ pathList = qmakeIncludes;
+ pathList += headerPaths;
} else if (file.endsWith(".lib") || file.endsWith(".a")) {
static const QStringList libPaths =
Environment::libraryPaths(Environment::compilerFromQMakeSpec(dictionary[QStringLiteral("QMAKESPEC")]));