summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/android/LICENSE11
-rw-r--r--src/3rdparty/android/qt_attribution.json11
-rw-r--r--src/3rdparty/angle/SYSTEMINFO_LICENSE22
-rw-r--r--src/3rdparty/angle/TRACEEVENT_LICENSE27
-rw-r--r--src/3rdparty/angle/qt_attribution.json61
-rw-r--r--src/3rdparty/atspi2/LICENSE482
-rw-r--r--src/3rdparty/atspi2/qt_attribution.json11
-rw-r--r--src/3rdparty/double-conversion/include/double-conversion/utils.h2
-rw-r--r--src/3rdparty/double-conversion/qt_attribution.json14
-rw-r--r--src/3rdparty/easing/LICENSE (renamed from src/3rdparty/easing/legal.qdoc)10
-rw-r--r--src/3rdparty/easing/qt_attribution.json11
-rw-r--r--src/3rdparty/forkfd/LICENSE19
-rw-r--r--src/3rdparty/forkfd/qt_attribution.json12
-rw-r--r--src/3rdparty/freebsd/LICENSE31
-rw-r--r--src/3rdparty/freebsd/qt_attribution.json17
-rw-r--r--src/3rdparty/freetype/qt_attribution.json13
-rw-r--r--src/3rdparty/freetype_dependency.pri8
-rw-r--r--src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro4
-rw-r--r--src/3rdparty/harfbuzz-ng/qt_attribution.json25
-rw-r--r--src/3rdparty/harfbuzz/qt_attribution.json17
-rw-r--r--src/3rdparty/harfbuzz_dependency.pri6
-rw-r--r--src/3rdparty/iaccessible2/LICENSE38
-rw-r--r--src/3rdparty/iaccessible2/qt_attribution.json17
-rw-r--r--src/3rdparty/libjpeg/LICENSE50
-rw-r--r--src/3rdparty/libjpeg/qt_attribution.json13
-rw-r--r--src/3rdparty/libpng/qt_attribution.json15
-rw-r--r--src/3rdparty/md4/qt_attribution.json10
-rw-r--r--src/3rdparty/md5/qt_attribution.json11
-rw-r--r--src/3rdparty/pcre/pcre.pro2
-rw-r--r--src/3rdparty/pcre/qt_attribution.json15
-rw-r--r--src/3rdparty/pixman/LICENSE20
-rw-r--r--src/3rdparty/pixman/qt_attribution.json13
-rw-r--r--src/3rdparty/rfc6234/LICENSE34
-rw-r--r--src/3rdparty/rfc6234/qt_attribution.json12
-rw-r--r--src/3rdparty/sha1/qt_attribution.json12
-rw-r--r--src/3rdparty/sha3/BRG_ENDIAN_LICENSE21
-rw-r--r--src/3rdparty/sha3/CC0_LICENSE99
-rw-r--r--src/3rdparty/sha3/qt_attribution.json29
-rw-r--r--src/3rdparty/sqlite/qt_attribution.json12
-rw-r--r--src/3rdparty/wintab/qt_attribution.json12
-rw-r--r--src/3rdparty/xcb/LICENSE23
-rw-r--r--src/3rdparty/xcb/qt_attribution.json24
-rw-r--r--src/3rdparty/xkbcommon/qt_attribution.json26
-rw-r--r--src/3rdparty/zlib/LICENSE28
-rw-r--r--src/3rdparty/zlib/qt_attribution.json15
-rw-r--r--src/angle/src/config.pri2
-rw-r--r--src/corelib/Qt5CoreMacros.cmake3
-rw-r--r--src/corelib/arch/arch.pri2
-rw-r--r--src/corelib/arch/qatomic_msvc.h42
-rw-r--r--src/corelib/codecs/codecs.pri23
-rw-r--r--src/corelib/codecs/cp949codetbl_p.h2
-rw-r--r--src/corelib/codecs/qbig5codec_p.h1
-rw-r--r--src/corelib/codecs/qeuckrcodec_p.h1
-rw-r--r--src/corelib/codecs/qgb18030codec_p.h1
-rw-r--r--src/corelib/codecs/qiconvcodec_p.h1
-rw-r--r--src/corelib/codecs/qicucodec.cpp10
-rw-r--r--src/corelib/codecs/qicucodec_p.h2
-rw-r--r--src/corelib/codecs/qisciicodec_p.h1
-rw-r--r--src/corelib/codecs/qjpunicode_p.h2
-rw-r--r--src/corelib/codecs/qlatincodec_p.h1
-rw-r--r--src/corelib/codecs/qsimplecodec_p.h1
-rw-r--r--src/corelib/codecs/qtextcodec.cpp6
-rw-r--r--src/corelib/codecs/qtextcodec_p.h1
-rw-r--r--src/corelib/codecs/qtsciicodec_p.h1
-rw-r--r--src/corelib/codecs/qutfcodec.cpp87
-rw-r--r--src/corelib/codecs/qwindowscodec.cpp2
-rw-r--r--src/corelib/codecs/qwindowscodec_p.h1
-rw-r--r--src/corelib/corelib.pro16
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp36
-rw-r--r--src/corelib/doc/src/animation.qdoc2
-rw-r--r--src/corelib/doc/src/qtcore-index.qdoc14
-rw-r--r--src/corelib/global/qcompilerdetection.h8
-rw-r--r--src/corelib/global/qconfig-large.h140
-rw-r--r--src/corelib/global/qconfig-medium.h241
-rw-r--r--src/corelib/global/qconfig-minimal.h463
-rw-r--r--src/corelib/global/qconfig-nacl.h233
-rw-r--r--src/corelib/global/qconfig-small.h281
-rw-r--r--src/corelib/global/qflags.h9
-rw-r--r--src/corelib/global/qglobal.cpp402
-rw-r--r--src/corelib/global/qglobal.h101
-rw-r--r--src/corelib/global/qglobal_p.h52
-rw-r--r--src/corelib/global/qhooks.cpp2
-rw-r--r--src/corelib/global/qhooks_p.h2
-rw-r--r--src/corelib/global/qlibraryinfo.cpp35
-rw-r--r--src/corelib/global/qlibraryinfo.h11
-rw-r--r--src/corelib/global/qlogging.cpp12
-rw-r--r--src/corelib/global/qnamespace.h8
-rw-r--r--src/corelib/global/qnamespace.qdoc35
-rw-r--r--src/corelib/global/qnumeric_p.h4
-rw-r--r--src/corelib/global/qprocessordetection.h2
-rw-r--r--src/corelib/global/qsysinfo.h20
-rw-r--r--src/corelib/global/qsystemdetection.h28
-rw-r--r--src/corelib/global/qt_windows.h17
-rw-r--r--src/corelib/io/io.pri37
-rw-r--r--src/corelib/io/qabstractfileengine_p.h1
-rw-r--r--src/corelib/io/qdatastream.cpp1
-rw-r--r--src/corelib/io/qdatastream.h5
-rw-r--r--src/corelib/io/qdatastream_p.h1
-rw-r--r--src/corelib/io/qdataurl_p.h1
-rw-r--r--src/corelib/io/qdebug.h4
-rw-r--r--src/corelib/io/qdebug_p.h1
-rw-r--r--src/corelib/io/qdir.cpp10
-rw-r--r--src/corelib/io/qfileselector.cpp13
-rw-r--r--src/corelib/io/qfileselector_p.h2
-rw-r--r--src/corelib/io/qfilesystemengine.cpp29
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp7
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp260
-rw-r--r--src/corelib/io/qfilesystementry_p.h1
-rw-r--r--src/corelib/io/qfilesystemiterator_win.cpp5
-rw-r--r--src/corelib/io/qfilesystemmetadata_p.h16
-rw-r--r--src/corelib/io/qfilesystemwatcher.cpp4
-rw-r--r--src/corelib/io/qfilesystemwatcher_fsevents.mm8
-rw-r--r--src/corelib/io/qfilesystemwatcher_win.cpp10
-rw-r--r--src/corelib/io/qfsfileengine.cpp8
-rw-r--r--src/corelib/io/qfsfileengine_p.h9
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp141
-rw-r--r--src/corelib/io/qiodevice.cpp45
-rw-r--r--src/corelib/io/qiodevice_p.h4
-rw-r--r--src/corelib/io/qipaddress_p.h1
-rw-r--r--src/corelib/io/qlockfile_p.h1
-rw-r--r--src/corelib/io/qlockfile_unix.cpp4
-rw-r--r--src/corelib/io/qlockfile_win.cpp4
-rw-r--r--src/corelib/io/qloggingregistry_p.h1
-rw-r--r--src/corelib/io/qprocess.cpp14
-rw-r--r--src/corelib/io/qprocess_unix.cpp2
-rw-r--r--src/corelib/io/qprocess_win.cpp4
-rw-r--r--src/corelib/io/qprocess_wince.cpp308
-rw-r--r--src/corelib/io/qresource.cpp4
-rw-r--r--src/corelib/io/qsettings.cpp12
-rw-r--r--src/corelib/io/qsettings_mac.cpp30
-rw-r--r--src/corelib/io/qsettings_win.cpp8
-rw-r--r--src/corelib/io/qstandardpaths.h7
-rw-r--r--src/corelib/io/qstandardpaths_mac.mm4
-rw-r--r--src/corelib/io/qstandardpaths_unix.cpp2
-rw-r--r--src/corelib/io/qstandardpaths_win.cpp42
-rw-r--r--src/corelib/io/qstorageinfo_p.h3
-rw-r--r--src/corelib/io/qtemporaryfile.cpp27
-rw-r--r--src/corelib/io/qtemporaryfile_p.h5
-rw-r--r--src/corelib/io/qtextstream.cpp2
-rw-r--r--src/corelib/io/qtextstream_p.h1
-rw-r--r--src/corelib/io/qtldurl_p.h1
-rw-r--r--src/corelib/io/qurl.cpp40
-rw-r--r--src/corelib/io/qurl.h16
-rw-r--r--src/corelib/io/qurl_p.h1
-rw-r--r--src/corelib/io/qurltlds_p.h2
-rw-r--r--src/corelib/io/qwindowspipereader.cpp17
-rw-r--r--src/corelib/io/qwindowspipewriter.cpp5
-rw-r--r--src/corelib/io/qwindowspipewriter_p.h1
-rw-r--r--src/corelib/io/qwinoverlappedionotifier_p.h1
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp38
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel_p.h2
-rw-r--r--src/corelib/itemmodels/qsortfilterproxymodel.cpp35
-rw-r--r--src/corelib/json/qjson_p.h20
-rw-r--r--src/corelib/json/qjsondocument.cpp4
-rw-r--r--src/corelib/json/qjsonparser_p.h1
-rw-r--r--src/corelib/json/qjsonvalue.cpp3
-rw-r--r--src/corelib/json/qjsonwriter_p.h2
-rw-r--r--src/corelib/kernel/kernel.pri27
-rw-r--r--src/corelib/kernel/qcfsocketnotifier_p.h1
-rw-r--r--src/corelib/kernel/qcore_foundation.mm537
-rw-r--r--src/corelib/kernel/qcore_mac_objc.mm4
-rw-r--r--src/corelib/kernel/qcore_mac_p.h2
-rw-r--r--src/corelib/kernel/qcore_unix_p.h5
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp41
-rw-r--r--src/corelib/kernel/qcoreapplication_win.cpp34
-rw-r--r--src/corelib/kernel/qcorecmdlineargs_p.h89
-rw-r--r--src/corelib/kernel/qcoreglobaldata_p.h1
-rw-r--r--src/corelib/kernel/qcrashhandler_p.h2
-rw-r--r--src/corelib/kernel/qdeadlinetimer.cpp827
-rw-r--r--src/corelib/kernel/qdeadlinetimer.h190
-rw-r--r--src/corelib/kernel/qdeadlinetimer_p.h (renamed from src/corelib/global/qconfig-dist.h)25
-rw-r--r--src/corelib/kernel/qelapsedtimer.cpp (renamed from src/corelib/tools/qelapsedtimer.cpp)7
-rw-r--r--src/corelib/kernel/qelapsedtimer.h (renamed from src/corelib/tools/qelapsedtimer.h)0
-rw-r--r--src/corelib/kernel/qelapsedtimer_generic.cpp (renamed from src/corelib/tools/qelapsedtimer_generic.cpp)9
-rw-r--r--src/corelib/kernel/qelapsedtimer_mac.cpp (renamed from src/corelib/tools/qelapsedtimer_mac.cpp)29
-rw-r--r--src/corelib/kernel/qelapsedtimer_unix.cpp (renamed from src/corelib/tools/qelapsedtimer_unix.cpp)14
-rw-r--r--src/corelib/kernel/qelapsedtimer_win.cpp (renamed from src/corelib/tools/qelapsedtimer_win.cpp)71
-rw-r--r--src/corelib/kernel/qeventdispatcher_cf.mm12
-rw-r--r--src/corelib/kernel/qeventdispatcher_cf_p.h2
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp266
-rw-r--r--src/corelib/kernel/qeventdispatcher_win_p.h2
-rw-r--r--src/corelib/kernel/qeventdispatcher_winrt.cpp113
-rw-r--r--src/corelib/kernel/qeventdispatcher_winrt_p.h1
-rw-r--r--src/corelib/kernel/qeventloop_p.h1
-rw-r--r--src/corelib/kernel/qfunctions_p.h6
-rw-r--r--src/corelib/kernel/qfunctions_wince.cpp407
-rw-r--r--src/corelib/kernel/qfunctions_wince.h473
-rw-r--r--src/corelib/kernel/qjni_p.h2
-rw-r--r--src/corelib/kernel/qjnihelpers.cpp10
-rw-r--r--src/corelib/kernel/qjnihelpers_p.h3
-rw-r--r--src/corelib/kernel/qmath.h22
-rw-r--r--src/corelib/kernel/qmetaobject.cpp23
-rw-r--r--src/corelib/kernel/qmetaobject.h11
-rw-r--r--src/corelib/kernel/qmetaobject_moc_p.h2
-rw-r--r--src/corelib/kernel/qmetaobject_p.h15
-rw-r--r--src/corelib/kernel/qmetaobjectbuilder_p.h1
-rw-r--r--src/corelib/kernel/qmetatype.cpp10
-rw-r--r--src/corelib/kernel/qmetatype.h16
-rw-r--r--src/corelib/kernel/qmetatype_p.h1
-rw-r--r--src/corelib/kernel/qobject.cpp18
-rw-r--r--src/corelib/kernel/qobject.h4
-rw-r--r--src/corelib/kernel/qobject_impl.h16
-rw-r--r--src/corelib/kernel/qobject_p.h1
-rw-r--r--src/corelib/kernel/qobjectdefs_impl.h46
-rw-r--r--src/corelib/kernel/qppsattribute_p.h1
-rw-r--r--src/corelib/kernel/qppsobject.cpp24
-rw-r--r--src/corelib/kernel/qsharedmemory_win.cpp8
-rw-r--r--src/corelib/kernel/qsystemerror.cpp22
-rw-r--r--src/corelib/kernel/qsystemerror_p.h1
-rw-r--r--src/corelib/kernel/qsystemsemaphore_p.h4
-rw-r--r--src/corelib/kernel/qsystemsemaphore_posix.cpp4
-rw-r--r--src/corelib/kernel/qsystemsemaphore_systemv.cpp3
-rw-r--r--src/corelib/kernel/qsystemsemaphore_win.cpp4
-rw-r--r--src/corelib/kernel/qtimer.cpp72
-rw-r--r--src/corelib/kernel/qtimer.h99
-rw-r--r--src/corelib/kernel/qtimerinfo_unix_p.h2
-rw-r--r--src/corelib/kernel/qtranslator.cpp2
-rw-r--r--src/corelib/kernel/qtranslator_p.h2
-rw-r--r--src/corelib/mimetypes/qmimeglobpattern.cpp2
-rw-r--r--src/corelib/mimetypes/qmimeglobpattern_p.h2
-rw-r--r--src/corelib/mimetypes/qmimemagicrule_p.h2
-rw-r--r--src/corelib/mimetypes/qmimeprovider.cpp5
-rw-r--r--src/corelib/mimetypes/qmimetype.cpp9
-rw-r--r--src/corelib/mimetypes/qmimetype_p.h1
-rw-r--r--src/corelib/mimetypes/qmimetypeparser.cpp2
-rw-r--r--src/corelib/plugin/plugin.pri4
-rw-r--r--src/corelib/plugin/qelfparser_p.h2
-rw-r--r--src/corelib/plugin/qfactoryloader.cpp12
-rw-r--r--src/corelib/plugin/qlibrary.cpp8
-rw-r--r--src/corelib/plugin/qlibrary_p.h1
-rw-r--r--src/corelib/plugin/qlibrary_unix.cpp16
-rw-r--r--src/corelib/plugin/qlibrary_win.cpp21
-rw-r--r--src/corelib/plugin/qmachparser.cpp3
-rw-r--r--src/corelib/plugin/qmachparser_p.h2
-rw-r--r--src/corelib/plugin/qpluginloader.cpp5
-rw-r--r--src/corelib/plugin/qsystemlibrary.cpp16
-rw-r--r--src/corelib/plugin/qsystemlibrary_p.h6
-rw-r--r--src/corelib/plugin/quuid.cpp37
-rw-r--r--src/corelib/plugin/quuid.h6
-rw-r--r--src/corelib/statemachine/qsignaleventgenerator_p.h1
-rw-r--r--src/corelib/statemachine/qsignaltransition.h1
-rw-r--r--src/corelib/statemachine/qstate.h1
-rw-r--r--src/corelib/thread/qfuture.h25
-rw-r--r--src/corelib/thread/qfutureinterface.h10
-rw-r--r--src/corelib/thread/qfutureinterface_p.h1
-rw-r--r--src/corelib/thread/qmutex.cpp55
-rw-r--r--src/corelib/thread/qmutex.h57
-rw-r--r--src/corelib/thread/qmutex_p.h2
-rw-r--r--src/corelib/thread/qmutex_win.cpp4
-rw-r--r--src/corelib/thread/qmutexpool_p.h1
-rw-r--r--src/corelib/thread/qorderedmutexlocker_p.h1
-rw-r--r--src/corelib/thread/qreadwritelock_p.h2
-rw-r--r--src/corelib/thread/qthread.cpp4
-rw-r--r--src/corelib/thread/qthread_win.cpp44
-rw-r--r--src/corelib/thread/qwaitcondition.h3
-rw-r--r--src/corelib/thread/qwaitcondition.qdoc15
-rw-r--r--src/corelib/thread/qwaitcondition_win.cpp5
-rw-r--r--src/corelib/tools/qalgorithms.h209
-rw-r--r--src/corelib/tools/qbytearray.cpp85
-rw-r--r--src/corelib/tools/qbytearray.h8
-rw-r--r--src/corelib/tools/qbytearraylist.h2
-rw-r--r--src/corelib/tools/qbytedata_p.h1
-rw-r--r--src/corelib/tools/qchar.h12
-rw-r--r--src/corelib/tools/qcollator_p.h1
-rw-r--r--src/corelib/tools/qcommandlineoption.cpp58
-rw-r--r--src/corelib/tools/qcommandlineoption.h16
-rw-r--r--src/corelib/tools/qcommandlineparser.cpp28
-rw-r--r--src/corelib/tools/qcryptographichash.h3
-rw-r--r--src/corelib/tools/qdatetime.cpp1051
-rw-r--r--src/corelib/tools/qdatetime.h89
-rw-r--r--src/corelib/tools/qdatetime_mac.mm74
-rw-r--r--src/corelib/tools/qdatetime_p.h71
-rw-r--r--src/corelib/tools/qdatetimeparser_p.h1
-rw-r--r--src/corelib/tools/qfreelist_p.h1
-rw-r--r--src/corelib/tools/qharfbuzz_p.h2
-rw-r--r--src/corelib/tools/qhash.cpp20
-rw-r--r--src/corelib/tools/qhash.h21
-rw-r--r--src/corelib/tools/qline.cpp23
-rw-r--r--src/corelib/tools/qline.h14
-rw-r--r--src/corelib/tools/qlist.h5
-rw-r--r--src/corelib/tools/qlocale.cpp1
-rw-r--r--src/corelib/tools/qlocale_data_p.h2
-rw-r--r--src/corelib/tools/qlocale_mac.mm3
-rw-r--r--src/corelib/tools/qlocale_p.h1
-rw-r--r--src/corelib/tools/qlocale_win.cpp78
-rw-r--r--src/corelib/tools/qpodlist_p.h1
-rw-r--r--src/corelib/tools/qpoint.h13
-rw-r--r--src/corelib/tools/qrect.h13
-rw-r--r--src/corelib/tools/qringbuffer.cpp46
-rw-r--r--src/corelib/tools/qringbuffer_p.h9
-rw-r--r--src/corelib/tools/qscopedpointer.cpp42
-rw-r--r--src/corelib/tools/qscopedpointer.h45
-rw-r--r--src/corelib/tools/qscopedpointer_p.h2
-rw-r--r--src/corelib/tools/qsharedpointer.cpp112
-rw-r--r--src/corelib/tools/qsharedpointer.h14
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h116
-rw-r--r--src/corelib/tools/qsimd.cpp29
-rw-r--r--src/corelib/tools/qsimd_p.h63
-rw-r--r--src/corelib/tools/qsize.h13
-rw-r--r--src/corelib/tools/qstring.cpp248
-rw-r--r--src/corelib/tools/qstring.h212
-rw-r--r--src/corelib/tools/qstringiterator_p.h1
-rw-r--r--src/corelib/tools/qstringlist.h2
-rw-r--r--src/corelib/tools/qtimezoneprivate_data_p.h2
-rw-r--r--src/corelib/tools/qtimezoneprivate_win.cpp6
-rw-r--r--src/corelib/tools/qtools_p.h2
-rw-r--r--src/corelib/tools/qunicodetables_p.h2
-rw-r--r--src/corelib/tools/qunicodetools_p.h1
-rw-r--r--src/corelib/tools/tools.pri32
-rw-r--r--src/corelib/xml/qxmlstream_p.h2
-rw-r--r--src/corelib/xml/qxmlutils_p.h1
-rw-r--r--src/dbus/dbus.pro15
-rw-r--r--src/dbus/qdbus_symbols_p.h2
-rw-r--r--src/dbus/qdbusabstractadaptor.h2
-rw-r--r--src/dbus/qdbusabstractadaptor_p.h1
-rw-r--r--src/dbus/qdbusabstractinterface.h1
-rw-r--r--src/dbus/qdbusabstractinterface_p.h1
-rw-r--r--src/dbus/qdbusargument.h2
-rw-r--r--src/dbus/qdbusargument_p.h1
-rw-r--r--src/dbus/qdbusconnection.cpp35
-rw-r--r--src/dbus/qdbusconnection.h2
-rw-r--r--src/dbus/qdbusconnection_p.h5
-rw-r--r--src/dbus/qdbusconnectioninterface.h1
-rw-r--r--src/dbus/qdbusconnectionmanager_p.h1
-rw-r--r--src/dbus/qdbuscontext.h1
-rw-r--r--src/dbus/qdbuscontext_p.h2
-rw-r--r--src/dbus/qdbuserror.h2
-rw-r--r--src/dbus/qdbusextratypes.h2
-rw-r--r--src/dbus/qdbusintegrator.cpp13
-rw-r--r--src/dbus/qdbusintegrator_p.h1
-rw-r--r--src/dbus/qdbusinterface.h1
-rw-r--r--src/dbus/qdbusinterface_p.h1
-rw-r--r--src/dbus/qdbusintrospection_p.h2
-rw-r--r--src/dbus/qdbusmessage.h2
-rw-r--r--src/dbus/qdbusmessage_p.h1
-rw-r--r--src/dbus/qdbusmetaobject_p.h8
-rw-r--r--src/dbus/qdbusmetatype.h1
-rw-r--r--src/dbus/qdbusmetatype_p.h1
-rw-r--r--src/dbus/qdbuspendingcall.h6
-rw-r--r--src/dbus/qdbuspendingcall_p.h1
-rw-r--r--src/dbus/qdbuspendingreply.h3
-rw-r--r--src/dbus/qdbusreply.h3
-rw-r--r--src/dbus/qdbusserver.h2
-rw-r--r--src/dbus/qdbusservicewatcher.h4
-rw-r--r--src/dbus/qdbusthreaddebug_p.h2
-rw-r--r--src/dbus/qdbusunixfiledescriptor.h2
-rw-r--r--src/dbus/qdbusutil_p.h5
-rw-r--r--src/dbus/qdbusvirtualobject.h4
-rw-r--r--src/dbus/qdbusxmlparser_p.h2
-rw-r--r--src/dbus/qtdbusglobal.h (renamed from src/dbus/qdbusmacros.h)4
-rw-r--r--src/dbus/qtdbusglobal_p.h57
-rw-r--r--src/gui/accessible/qaccessible.h2
-rw-r--r--src/gui/accessible/qaccessiblebridge.h1
-rw-r--r--src/gui/accessible/qaccessiblecache_p.h2
-rw-r--r--src/gui/accessible/qaccessibleobject.h1
-rw-r--r--src/gui/accessible/qaccessibleplugin.h1
-rw-r--r--src/gui/accessible/qplatformaccessibility.h4
-rw-r--r--src/gui/animation/qguivariantanimation.cpp5
-rw-r--r--src/gui/doc/src/qtgui.qdoc13
-rw-r--r--src/gui/gui.pro2
-rw-r--r--src/gui/image/image.pri14
-rw-r--r--src/gui/image/qbitmap.h1
-rw-r--r--src/gui/image/qbmphandler_p.h1
-rw-r--r--src/gui/image/qgifhandler.pri3
-rw-r--r--src/gui/image/qicon.h2
-rw-r--r--src/gui/image/qicon_p.h2
-rw-r--r--src/gui/image/qiconengine.h2
-rw-r--r--src/gui/image/qiconengineplugin.h1
-rw-r--r--src/gui/image/qiconloader.cpp28
-rw-r--r--src/gui/image/qiconloader_p.h2
-rw-r--r--src/gui/image/qimage.cpp38
-rw-r--r--src/gui/image/qimage.h10
-rw-r--r--src/gui/image/qimage_conversions.cpp31
-rw-r--r--src/gui/image/qimage_darwin.mm141
-rw-r--r--src/gui/image/qimage_p.h5
-rw-r--r--src/gui/image/qimage_sse4.cpp2
-rw-r--r--src/gui/image/qimageiohandler.h1
-rw-r--r--src/gui/image/qimagepixmapcleanuphooks_p.h1
-rw-r--r--src/gui/image/qimagereader.cpp67
-rw-r--r--src/gui/image/qimagereader.h1
-rw-r--r--src/gui/image/qimagewriter.cpp25
-rw-r--r--src/gui/image/qimagewriter.h1
-rw-r--r--src/gui/image/qjpeghandler.pri11
-rw-r--r--src/gui/image/qmovie.h3
-rw-r--r--src/gui/image/qpaintengine_pic_p.h3
-rw-r--r--src/gui/image/qpicture.h1
-rw-r--r--src/gui/image/qpicture_p.h1
-rw-r--r--src/gui/image/qpictureformatplugin.h1
-rw-r--r--src/gui/image/qpixmap.cpp14
-rw-r--r--src/gui/image/qpixmap.h1
-rw-r--r--src/gui/image/qpixmap_blitter.cpp8
-rw-r--r--src/gui/image/qpixmap_blitter_p.h1
-rw-r--r--src/gui/image/qpixmap_raster.cpp21
-rw-r--r--src/gui/image/qpixmap_raster_p.h2
-rw-r--r--src/gui/image/qpixmap_win.cpp170
-rw-r--r--src/gui/image/qpixmapcache.h1
-rw-r--r--src/gui/image/qpixmapcache_p.h1
-rw-r--r--src/gui/image/qplatformpixmap.h1
-rw-r--r--src/gui/image/qpnghandler.cpp49
-rw-r--r--src/gui/image/qpnghandler.pri4
-rw-r--r--src/gui/image/qpnghandler_p.h1
-rw-r--r--src/gui/image/qppmhandler_p.h1
-rw-r--r--src/gui/image/qxbmhandler_p.h1
-rw-r--r--src/gui/image/qxpmhandler.cpp2
-rw-r--r--src/gui/image/qxpmhandler_p.h1
-rw-r--r--src/gui/itemmodels/qstandarditemmodel.cpp48
-rw-r--r--src/gui/itemmodels/qstandarditemmodel.h1
-rw-r--r--src/gui/itemmodels/qstandarditemmodel_p.h1
-rw-r--r--src/gui/kernel/kernel.pri2
-rw-r--r--src/gui/kernel/qclipboard.cpp4
-rw-r--r--src/gui/kernel/qclipboard.h1
-rw-r--r--src/gui/kernel/qcursor.h1
-rw-r--r--src/gui/kernel/qcursor_p.h2
-rw-r--r--src/gui/kernel/qdnd_p.h1
-rw-r--r--src/gui/kernel/qdrag.h1
-rw-r--r--src/gui/kernel/qevent.cpp137
-rw-r--r--src/gui/kernel/qevent.h29
-rw-r--r--src/gui/kernel/qevent_p.h7
-rw-r--r--src/gui/kernel/qgenericplugin.h1
-rw-r--r--src/gui/kernel/qgenericpluginfactory.h1
-rw-r--r--src/gui/kernel/qguiapplication.cpp52
-rw-r--r--src/gui/kernel/qguiapplication.h4
-rw-r--r--src/gui/kernel/qguiapplication_p.h1
-rw-r--r--src/gui/kernel/qhighdpiscaling.cpp9
-rw-r--r--src/gui/kernel/qhighdpiscaling_p.h10
-rw-r--r--src/gui/kernel/qinputdevicemanager_p.h1
-rw-r--r--src/gui/kernel/qinputdevicemanager_p_p.h1
-rw-r--r--src/gui/kernel/qinputmethod.h1
-rw-r--r--src/gui/kernel/qinputmethod_p.h1
-rw-r--r--src/gui/kernel/qkeymapper_p.h1
-rw-r--r--src/gui/kernel/qkeysequence.h2
-rw-r--r--src/gui/kernel/qkeysequence_p.h1
-rw-r--r--src/gui/kernel/qoffscreensurface.h1
-rw-r--r--src/gui/kernel/qopenglcontext.cpp15
-rw-r--r--src/gui/kernel/qopenglcontext.h2
-rw-r--r--src/gui/kernel/qopenglcontext_p.h2
-rw-r--r--src/gui/kernel/qopenglwindow.cpp2
-rw-r--r--src/gui/kernel/qopenglwindow.h2
-rw-r--r--src/gui/kernel/qpaintdevicewindow.h1
-rw-r--r--src/gui/kernel/qpaintdevicewindow_p.h1
-rw-r--r--src/gui/kernel/qpalette.h1
-rw-r--r--src/gui/kernel/qpixelformat.h2
-rw-r--r--src/gui/kernel/qplatformclipboard.h2
-rw-r--r--src/gui/kernel/qplatformcursor.h1
-rw-r--r--src/gui/kernel/qplatformdialoghelper.cpp95
-rw-r--r--src/gui/kernel/qplatformdialoghelper.h70
-rw-r--r--src/gui/kernel/qplatformdrag.h2
-rw-r--r--src/gui/kernel/qplatformgraphicsbuffer.h1
-rw-r--r--src/gui/kernel/qplatformgraphicsbufferhelper.h1
-rw-r--r--src/gui/kernel/qplatforminputcontext.h1
-rw-r--r--src/gui/kernel/qplatforminputcontext_p.h1
-rw-r--r--src/gui/kernel/qplatforminputcontextfactory_p.h1
-rw-r--r--src/gui/kernel/qplatforminputcontextplugin_p.h1
-rw-r--r--src/gui/kernel/qplatformintegration.cpp2
-rw-r--r--src/gui/kernel/qplatformintegration.h4
-rw-r--r--src/gui/kernel/qplatformintegrationfactory_p.h1
-rw-r--r--src/gui/kernel/qplatformintegrationplugin.h1
-rw-r--r--src/gui/kernel/qplatformmenu.h2
-rw-r--r--src/gui/kernel/qplatformnativeinterface.h1
-rw-r--r--src/gui/kernel/qplatformoffscreensurface.h1
-rw-r--r--src/gui/kernel/qplatformopenglcontext.h1
-rw-r--r--src/gui/kernel/qplatformscreen.h1
-rw-r--r--src/gui/kernel/qplatformscreen_p.h2
-rw-r--r--src/gui/kernel/qplatformservices.h2
-rw-r--r--src/gui/kernel/qplatformsessionmanager.h1
-rw-r--r--src/gui/kernel/qplatformsharedgraphicscache.h1
-rw-r--r--src/gui/kernel/qplatformsurface.h1
-rw-r--r--src/gui/kernel/qplatformsystemtrayicon.h1
-rw-r--r--src/gui/kernel/qplatformtheme.cpp19
-rw-r--r--src/gui/kernel/qplatformtheme.h11
-rw-r--r--src/gui/kernel/qplatformtheme_p.h2
-rw-r--r--src/gui/kernel/qplatformthemefactory_p.h1
-rw-r--r--src/gui/kernel/qplatformthemeplugin.h1
-rw-r--r--src/gui/kernel/qplatformwindow.h1
-rw-r--r--src/gui/kernel/qplatformwindow_p.h1
-rw-r--r--src/gui/kernel/qrasterwindow.h1
-rw-r--r--src/gui/kernel/qscreen.h1
-rw-r--r--src/gui/kernel/qscreen_p.h1
-rw-r--r--src/gui/kernel/qsessionmanager.h1
-rw-r--r--src/gui/kernel/qsessionmanager_p.h1
-rw-r--r--src/gui/kernel/qshapedpixmapdndwindow_p.h1
-rw-r--r--src/gui/kernel/qshortcutmap_p.h1
-rw-r--r--src/gui/kernel/qsimpledrag_p.h1
-rw-r--r--src/gui/kernel/qstylehints.cpp32
-rw-r--r--src/gui/kernel/qstylehints.h5
-rw-r--r--src/gui/kernel/qsurface.h1
-rw-r--r--src/gui/kernel/qsurfaceformat.h2
-rw-r--r--src/gui/kernel/qt_gui_pch.h2
-rw-r--r--src/gui/kernel/qtguiglobal.h (renamed from src/plugins/platforms/eglfs/qeglfshooks.h)25
-rw-r--r--src/gui/kernel/qtguiglobal_p.h57
-rw-r--r--src/gui/kernel/qtouchdevice.h1
-rw-r--r--src/gui/kernel/qtouchdevice_p.h1
-rw-r--r--src/gui/kernel/qwindow.h1
-rw-r--r--src/gui/kernel/qwindow_p.h1
-rw-r--r--src/gui/kernel/qwindowdefs.h2
-rw-r--r--src/gui/kernel/qwindowdefs_win.h11
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp14
-rw-r--r--src/gui/kernel/qwindowsysteminterface.h6
-rw-r--r--src/gui/kernel/qwindowsysteminterface_p.h1
-rw-r--r--src/gui/math3d/qgenericmatrix.h1
-rw-r--r--src/gui/math3d/qmatrix4x4.h1
-rw-r--r--src/gui/math3d/qquaternion.h1
-rw-r--r--src/gui/math3d/qvector2d.h1
-rw-r--r--src/gui/math3d/qvector3d.h1
-rw-r--r--src/gui/math3d/qvector4d.h1
-rw-r--r--src/gui/opengl/opengl.pri2
-rw-r--r--src/gui/opengl/qopengl.h21
-rw-r--r--src/gui/opengl/qopengl2pexvertexarray_p.h1
-rw-r--r--src/gui/opengl/qopengl_p.h1
-rw-r--r--src/gui/opengl/qopenglbuffer.h2
-rw-r--r--src/gui/opengl/qopenglcustomshaderstage_p.h2
-rw-r--r--src/gui/opengl/qopengldebug.h2
-rw-r--r--src/gui/opengl/qopenglengineshadermanager.cpp4
-rw-r--r--src/gui/opengl/qopenglengineshadermanager_p.h1
-rw-r--r--src/gui/opengl/qopenglengineshadersource_p.h1
-rw-r--r--src/gui/opengl/qopenglextensions_p.h1
-rw-r--r--src/gui/opengl/qopenglextrafunctions.h2
-rw-r--r--src/gui/opengl/qopenglframebufferobject.cpp9
-rw-r--r--src/gui/opengl/qopenglframebufferobject.h2
-rw-r--r--src/gui/opengl/qopenglframebufferobject_p.h1
-rw-r--r--src/gui/opengl/qopenglfunctions.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_1_0.cpp10
-rw-r--r--src/gui/opengl/qopenglfunctions_1_0.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_1_1.cpp20
-rw-r--r--src/gui/opengl/qopenglfunctions_1_1.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_1_2.cpp30
-rw-r--r--src/gui/opengl/qopenglfunctions_1_2.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_1_3.cpp40
-rw-r--r--src/gui/opengl/qopenglfunctions_1_3.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_1_4.cpp50
-rw-r--r--src/gui/opengl/qopenglfunctions_1_4.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_1_5.cpp55
-rw-r--r--src/gui/opengl/qopenglfunctions_1_5.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_2_0.cpp60
-rw-r--r--src/gui/opengl/qopenglfunctions_2_0.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_2_1.cpp65
-rw-r--r--src/gui/opengl/qopenglfunctions_2_1.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_3_0.cpp70
-rw-r--r--src/gui/opengl/qopenglfunctions_3_0.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_3_1.cpp50
-rw-r--r--src/gui/opengl/qopenglfunctions_3_1.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_3_2_compatibility.cpp80
-rw-r--r--src/gui/opengl/qopenglfunctions_3_2_compatibility.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_3_2_core.cpp55
-rw-r--r--src/gui/opengl/qopenglfunctions_3_2_core.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_3_3_compatibility.cpp90
-rw-r--r--src/gui/opengl/qopenglfunctions_3_3_compatibility.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_3_3_core.cpp60
-rw-r--r--src/gui/opengl/qopenglfunctions_3_3_core.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_4_0_compatibility.cpp95
-rw-r--r--src/gui/opengl/qopenglfunctions_4_0_compatibility.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_4_0_core.cpp65
-rw-r--r--src/gui/opengl/qopenglfunctions_4_0_core.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_4_1_compatibility.cpp100
-rw-r--r--src/gui/opengl/qopenglfunctions_4_1_compatibility.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_4_1_core.cpp70
-rw-r--r--src/gui/opengl/qopenglfunctions_4_1_core.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_4_2_compatibility.cpp105
-rw-r--r--src/gui/opengl/qopenglfunctions_4_2_compatibility.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_4_2_core.cpp75
-rw-r--r--src/gui/opengl/qopenglfunctions_4_2_core.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_4_3_compatibility.cpp110
-rw-r--r--src/gui/opengl/qopenglfunctions_4_3_compatibility.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_4_3_core.cpp80
-rw-r--r--src/gui/opengl/qopenglfunctions_4_3_core.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_4_4_compatibility.cpp115
-rw-r--r--src/gui/opengl/qopenglfunctions_4_4_compatibility.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_4_4_core.cpp85
-rw-r--r--src/gui/opengl/qopenglfunctions_4_4_core.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_4_5_compatibility.cpp125
-rw-r--r--src/gui/opengl/qopenglfunctions_4_5_compatibility.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_4_5_core.cpp90
-rw-r--r--src/gui/opengl/qopenglfunctions_4_5_core.h2
-rw-r--r--src/gui/opengl/qopenglfunctions_es2.h2
-rw-r--r--src/gui/opengl/qopenglgradientcache_p.h1
-rw-r--r--src/gui/opengl/qopenglpaintdevice.cpp2
-rw-r--r--src/gui/opengl/qopenglpaintdevice.h2
-rw-r--r--src/gui/opengl/qopenglpaintdevice_p.h1
-rw-r--r--src/gui/opengl/qopenglpaintengine.cpp6
-rw-r--r--src/gui/opengl/qopenglpaintengine_p.h1
-rw-r--r--src/gui/opengl/qopenglpixeltransferoptions.h2
-rw-r--r--src/gui/opengl/qopenglqueryhelper_p.h2
-rw-r--r--src/gui/opengl/qopenglshadercache_p.h2
-rw-r--r--src/gui/opengl/qopenglshaderprogram.cpp17
-rw-r--r--src/gui/opengl/qopenglshaderprogram.h2
-rw-r--r--src/gui/opengl/qopengltexture.cpp2
-rw-r--r--src/gui/opengl/qopengltexture.h2
-rw-r--r--src/gui/opengl/qopengltexture_p.h1
-rw-r--r--src/gui/opengl/qopengltextureblitter.cpp193
-rw-r--r--src/gui/opengl/qopengltextureblitter.h (renamed from src/gui/opengl/qopengltextureblitter_p.h)27
-rw-r--r--src/gui/opengl/qopengltexturecache_p.h1
-rw-r--r--src/gui/opengl/qopengltextureglyphcache_p.h1
-rw-r--r--src/gui/opengl/qopengltexturehelper_p.h2
-rw-r--r--src/gui/opengl/qopengltimerquery.h2
-rw-r--r--src/gui/opengl/qopenglversionfunctions.h2
-rw-r--r--src/gui/opengl/qopenglversionfunctionsfactory_p.h3
-rw-r--r--src/gui/opengl/qopenglvertexarrayobject.h2
-rw-r--r--src/gui/opengl/qrbtree_p.h2
-rw-r--r--src/gui/opengl/qtriangulatingstroker_p.h1
-rw-r--r--src/gui/opengl/qtriangulator_p.h1
-rw-r--r--src/gui/painting/painting.pri4
-rw-r--r--src/gui/painting/qbackingstore.h1
-rw-r--r--src/gui/painting/qbezier_p.h1
-rw-r--r--src/gui/painting/qblendfunctions_p.h1
-rw-r--r--src/gui/painting/qblittable_p.h1
-rw-r--r--src/gui/painting/qbrush.cpp59
-rw-r--r--src/gui/painting/qbrush.h1
-rw-r--r--src/gui/painting/qcolor.cpp2
-rw-r--r--src/gui/painting/qcolor.h2
-rw-r--r--src/gui/painting/qcolor_p.h2
-rw-r--r--src/gui/painting/qcompositionfunctions.cpp104
-rw-r--r--src/gui/painting/qcosmeticstroker_p.h1
-rw-r--r--src/gui/painting/qdatabuffer_p.h1
-rw-r--r--src/gui/painting/qdrawhelper.cpp393
-rw-r--r--src/gui/painting/qdrawhelper_avx2.cpp4
-rw-r--r--src/gui/painting/qdrawhelper_p.h12
-rw-r--r--src/gui/painting/qdrawhelper_sse4.cpp16
-rw-r--r--src/gui/painting/qdrawhelper_x86_p.h1
-rw-r--r--src/gui/painting/qdrawingprimitive_sse2_p.h1
-rw-r--r--src/gui/painting/qemulationpaintengine_p.h1
-rw-r--r--src/gui/painting/qfixed_p.h1
-rw-r--r--src/gui/painting/qmatrix.h1
-rw-r--r--src/gui/painting/qmemrotate_p.h1
-rw-r--r--src/gui/painting/qoutlinemapper_p.h1
-rw-r--r--src/gui/painting/qpagedpaintdevice.h1
-rw-r--r--src/gui/painting/qpagedpaintdevice_p.h1
-rw-r--r--src/gui/painting/qpagelayout.h1
-rw-r--r--src/gui/painting/qpagesize.h1
-rw-r--r--src/gui/painting/qpaintdevice.h1
-rw-r--r--src/gui/painting/qpaintengine.h1
-rw-r--r--src/gui/painting/qpaintengine_blitter.cpp18
-rw-r--r--src/gui/painting/qpaintengine_blitter_p.h1
-rw-r--r--src/gui/painting/qpaintengine_p.h1
-rw-r--r--src/gui/painting/qpaintengine_raster_p.h1
-rw-r--r--src/gui/painting/qpaintengineex_p.h1
-rw-r--r--src/gui/painting/qpainter.cpp10
-rw-r--r--src/gui/painting/qpainter.h1
-rw-r--r--src/gui/painting/qpainter_p.h1
-rw-r--r--src/gui/painting/qpainterpath.cpp7
-rw-r--r--src/gui/painting/qpainterpath.h1
-rw-r--r--src/gui/painting/qpainterpath_p.h1
-rw-r--r--src/gui/painting/qpathclipper_p.h1
-rw-r--r--src/gui/painting/qpathsimplifier_p.h1
-rw-r--r--src/gui/painting/qpdf.cpp5
-rw-r--r--src/gui/painting/qpdf_p.h2
-rw-r--r--src/gui/painting/qpdfwriter.h2
-rw-r--r--src/gui/painting/qpen.h1
-rw-r--r--src/gui/painting/qplatformbackingstore.cpp15
-rw-r--r--src/gui/painting/qplatformbackingstore.h3
-rw-r--r--src/gui/painting/qpolygon.cpp15
-rw-r--r--src/gui/painting/qpolygon.h1
-rw-r--r--src/gui/painting/qpolygonclipper_p.h1
-rw-r--r--src/gui/painting/qrasterizer_p.h2
-rw-r--r--src/gui/painting/qregion.cpp160
-rw-r--r--src/gui/painting/qregion.h18
-rw-r--r--src/gui/painting/qrgb.h2
-rw-r--r--src/gui/painting/qrgba64.h2
-rw-r--r--src/gui/painting/qrgba64_p.h101
-rw-r--r--src/gui/painting/qstroker_p.h1
-rw-r--r--src/gui/painting/qtextureglyphcache.cpp3
-rw-r--r--src/gui/painting/qtextureglyphcache_p.h3
-rw-r--r--src/gui/painting/qtransform.h1
-rw-r--r--src/gui/painting/qvectorpath_p.h1
-rw-r--r--src/gui/text/qabstracttextdocumentlayout.cpp28
-rw-r--r--src/gui/text/qabstracttextdocumentlayout.h4
-rw-r--r--src/gui/text/qabstracttextdocumentlayout_p.h1
-rw-r--r--src/gui/text/qcssparser.cpp71
-rw-r--r--src/gui/text/qcssparser_p.h17
-rw-r--r--src/gui/text/qcssscanner.cpp863
-rw-r--r--src/gui/text/qdistancefield.cpp70
-rw-r--r--src/gui/text/qdistancefield_p.h24
-rw-r--r--src/gui/text/qfont.cpp13
-rw-r--r--src/gui/text/qfont.h1
-rw-r--r--src/gui/text/qfont_p.h1
-rw-r--r--src/gui/text/qfontdatabase.cpp12
-rw-r--r--src/gui/text/qfontdatabase.h1
-rw-r--r--src/gui/text/qfontengine.cpp12
-rw-r--r--src/gui/text/qfontengine_p.h2
-rw-r--r--src/gui/text/qfontengineglyphcache_p.h2
-rw-r--r--src/gui/text/qfontinfo.h1
-rw-r--r--src/gui/text/qfontmetrics.h1
-rw-r--r--src/gui/text/qfontsubset_p.h1
-rw-r--r--src/gui/text/qfragmentmap_p.h2
-rw-r--r--src/gui/text/qglyphrun.h1
-rw-r--r--src/gui/text/qglyphrun_p.h1
-rw-r--r--src/gui/text/qharfbuzzng_p.h1
-rw-r--r--src/gui/text/qplatformfontdatabase.h2
-rw-r--r--src/gui/text/qrawfont.h1
-rw-r--r--src/gui/text/qrawfont_p.h1
-rw-r--r--src/gui/text/qstatictext.h1
-rw-r--r--src/gui/text/qstatictext_p.h1
-rw-r--r--src/gui/text/qsyntaxhighlighter.h2
-rw-r--r--src/gui/text/qtextcursor.h1
-rw-r--r--src/gui/text/qtextcursor_p.h1
-rw-r--r--src/gui/text/qtextdocument.cpp8
-rw-r--r--src/gui/text/qtextdocument.h1
-rw-r--r--src/gui/text/qtextdocument_p.cpp5
-rw-r--r--src/gui/text/qtextdocument_p.h6
-rw-r--r--src/gui/text/qtextdocumentfragment.h1
-rw-r--r--src/gui/text/qtextdocumentfragment_p.h1
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp13
-rw-r--r--src/gui/text/qtextdocumentlayout_p.h1
-rw-r--r--src/gui/text/qtextdocumentwriter.cpp5
-rw-r--r--src/gui/text/qtextdocumentwriter.h1
-rw-r--r--src/gui/text/qtextengine.cpp10
-rw-r--r--src/gui/text/qtextengine_p.h2
-rw-r--r--src/gui/text/qtextformat.h1
-rw-r--r--src/gui/text/qtextformat_p.h1
-rw-r--r--src/gui/text/qtexthtmlparser_p.h1
-rw-r--r--src/gui/text/qtextimagehandler_p.h1
-rw-r--r--src/gui/text/qtextlayout.cpp6
-rw-r--r--src/gui/text/qtextlayout.h1
-rw-r--r--src/gui/text/qtextlist.h1
-rw-r--r--src/gui/text/qtextobject.h1
-rw-r--r--src/gui/text/qtextobject_p.h1
-rw-r--r--src/gui/text/qtextodfwriter.cpp4
-rw-r--r--src/gui/text/qtextodfwriter_p.h2
-rw-r--r--src/gui/text/qtextoption.h1
-rw-r--r--src/gui/text/qtexttable.h2
-rw-r--r--src/gui/text/qtexttable_p.h1
-rw-r--r--src/gui/text/qzipreader_p.h1
-rw-r--r--src/gui/text/qzipwriter_p.h2
-rw-r--r--src/gui/util/qabstractlayoutstyleinfo_p.h1
-rw-r--r--src/gui/util/qdesktopservices.h1
-rw-r--r--src/gui/util/qgridlayoutengine_p.h1
-rw-r--r--src/gui/util/qhexstring_p.h2
-rw-r--r--src/gui/util/qlayoutpolicy_p.h1
-rw-r--r--src/gui/util/qvalidator.cpp15
-rw-r--r--src/gui/util/qvalidator.h1
-rw-r--r--src/network/access/access.pri9
-rw-r--r--src/network/access/http2/bitstreams.cpp336
-rw-r--r--src/network/access/http2/bitstreams_p.h185
-rw-r--r--src/network/access/http2/hpack.cpp551
-rw-r--r--src/network/access/http2/hpack_p.h155
-rw-r--r--src/network/access/http2/hpacktable.cpp533
-rw-r--r--src/network/access/http2/hpacktable_p.h237
-rw-r--r--src/network/access/http2/http2.pri17
-rw-r--r--src/network/access/http2/http2frames.cpp556
-rw-r--r--src/network/access/http2/http2frames_p.h191
-rw-r--r--src/network/access/http2/http2protocol.cpp156
-rw-r--r--src/network/access/http2/http2protocol_p.h175
-rw-r--r--src/network/access/http2/http2streams.cpp (renamed from src/corelib/plugin/quuid_darwin.mm)65
-rw-r--r--src/network/access/http2/http2streams_p.h103
-rw-r--r--src/network/access/http2/huffman.cpp573
-rw-r--r--src/network/access/http2/huffman_p.h182
-rw-r--r--src/network/access/qabstractnetworkcache.h1
-rw-r--r--src/network/access/qabstractnetworkcache_p.h1
-rw-r--r--src/network/access/qabstractprotocolhandler_p.h4
-rw-r--r--src/network/access/qftp_p.h7
-rw-r--r--src/network/access/qhttp2protocolhandler.cpp1213
-rw-r--r--src/network/access/qhttp2protocolhandler_p.h207
-rw-r--r--src/network/access/qhttpmultipart.h1
-rw-r--r--src/network/access/qhttpmultipart_p.h1
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp14
-rw-r--r--src/network/access/qhttpnetworkconnection_p.h21
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp75
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel_p.h9
-rw-r--r--src/network/access/qhttpnetworkheader_p.h3
-rw-r--r--src/network/access/qhttpnetworkreply.cpp5
-rw-r--r--src/network/access/qhttpnetworkreply_p.h7
-rw-r--r--src/network/access/qhttpnetworkrequest.cpp14
-rw-r--r--src/network/access/qhttpnetworkrequest_p.h7
-rw-r--r--src/network/access/qhttpprotocolhandler_p.h1
-rw-r--r--src/network/access/qhttpthreaddelegate.cpp11
-rw-r--r--src/network/access/qhttpthreaddelegate_p.h1
-rw-r--r--src/network/access/qnetworkaccessauthenticationmanager_p.h1
-rw-r--r--src/network/access/qnetworkaccessbackend_p.h1
-rw-r--r--src/network/access/qnetworkaccesscache_p.h1
-rw-r--r--src/network/access/qnetworkaccesscachebackend_p.h1
-rw-r--r--src/network/access/qnetworkaccessdebugpipebackend_p.h1
-rw-r--r--src/network/access/qnetworkaccessfilebackend_p.h1
-rw-r--r--src/network/access/qnetworkaccessftpbackend_p.h1
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp81
-rw-r--r--src/network/access/qnetworkaccessmanager.h4
-rw-r--r--src/network/access/qnetworkaccessmanager_p.h8
-rw-r--r--src/network/access/qnetworkcookie.cpp2
-rw-r--r--src/network/access/qnetworkcookie.h1
-rw-r--r--src/network/access/qnetworkcookie_p.h1
-rw-r--r--src/network/access/qnetworkcookiejar.h1
-rw-r--r--src/network/access/qnetworkcookiejar_p.h1
-rw-r--r--src/network/access/qnetworkdiskcache.cpp2
-rw-r--r--src/network/access/qnetworkdiskcache.h1
-rw-r--r--src/network/access/qnetworkdiskcache_p.h1
-rw-r--r--src/network/access/qnetworkfile.cpp (renamed from src/corelib/tools/qstring_mac.mm)65
-rw-r--r--src/network/access/qnetworkfile_p.h80
-rw-r--r--src/network/access/qnetworkreply.h1
-rw-r--r--src/network/access/qnetworkreply_p.h1
-rw-r--r--src/network/access/qnetworkreplydataimpl_p.h1
-rw-r--r--src/network/access/qnetworkreplyfileimpl.cpp150
-rw-r--r--src/network/access/qnetworkreplyfileimpl_p.h13
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp48
-rw-r--r--src/network/access/qnetworkreplyhttpimpl_p.h1
-rw-r--r--src/network/access/qnetworkreplyimpl_p.h1
-rw-r--r--src/network/access/qnetworkrequest.cpp8
-rw-r--r--src/network/access/qnetworkrequest.h3
-rw-r--r--src/network/access/qnetworkrequest_p.h1
-rw-r--r--src/network/access/qspdyprotocolhandler.cpp8
-rw-r--r--src/network/access/qspdyprotocolhandler_p.h1
-rw-r--r--src/network/bearer/qbearerengine_p.h1
-rw-r--r--src/network/bearer/qbearerplugin_p.h1
-rw-r--r--src/network/bearer/qnetworkconfigmanager.h1
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.h1
-rw-r--r--src/network/bearer/qnetworkconfiguration.h2
-rw-r--r--src/network/bearer/qnetworkconfiguration_p.h1
-rw-r--r--src/network/bearer/qnetworksession.h1
-rw-r--r--src/network/bearer/qnetworksession_p.h1
-rw-r--r--src/network/bearer/qsharednetworksession_p.h1
-rw-r--r--src/network/doc/snippets/code/src_network_socket_qsctpsocket.cpp53
-rw-r--r--src/network/doc/snippets/code/src_network_socket_qudpsocket.cpp9
-rw-r--r--src/network/kernel/kernel.pri14
-rw-r--r--src/network/kernel/qauthenticator.cpp14
-rw-r--r--src/network/kernel/qauthenticator.h1
-rw-r--r--src/network/kernel/qauthenticator_p.h1
-rw-r--r--src/network/kernel/qdnslookup.h1
-rw-r--r--src/network/kernel/qdnslookup_p.h1
-rw-r--r--src/network/kernel/qhostaddress.cpp120
-rw-r--r--src/network/kernel/qhostaddress.h13
-rw-r--r--src/network/kernel/qhostaddress_p.h1
-rw-r--r--src/network/kernel/qhostinfo.h1
-rw-r--r--src/network/kernel/qhostinfo_p.h1
-rw-r--r--src/network/kernel/qhostinfo_win.cpp11
-rw-r--r--src/network/kernel/qnetworkdatagram.cpp535
-rw-r--r--src/network/kernel/qnetworkdatagram.h123
-rw-r--r--src/network/kernel/qnetworkdatagram_p.h23
-rw-r--r--src/network/kernel/qnetworkfunctions_wince.h96
-rw-r--r--src/network/kernel/qnetworkinterface.cpp4
-rw-r--r--src/network/kernel/qnetworkinterface.h1
-rw-r--r--src/network/kernel/qnetworkinterface_p.h1
-rw-r--r--src/network/kernel/qnetworkinterface_win.cpp8
-rw-r--r--src/network/kernel/qnetworkproxy.cpp37
-rw-r--r--src/network/kernel/qnetworkproxy.h9
-rw-r--r--src/network/kernel/qnetworkproxy_mac.cpp97
-rw-r--r--src/network/kernel/qnetworkproxy_p.h2
-rw-r--r--src/network/kernel/qnetworkproxy_win.cpp30
-rw-r--r--src/network/kernel/qtnetworkglobal.h60
-rw-r--r--src/network/kernel/qtnetworkglobal_p.h57
-rw-r--r--src/network/kernel/qurlinfo_p.h1
-rw-r--r--src/network/network.pro1
-rw-r--r--src/network/socket/qabstractsocket.cpp154
-rw-r--r--src/network/socket/qabstractsocket.h2
-rw-r--r--src/network/socket/qabstractsocket_p.h12
-rw-r--r--src/network/socket/qabstractsocketengine_p.h12
-rw-r--r--src/network/socket/qhttpsocketengine.cpp22
-rw-r--r--src/network/socket/qhttpsocketengine_p.h7
-rw-r--r--src/network/socket/qlocalserver.h1
-rw-r--r--src/network/socket/qlocalserver_p.h2
-rw-r--r--src/network/socket/qlocalsocket.h1
-rw-r--r--src/network/socket/qlocalsocket_p.h2
-rw-r--r--src/network/socket/qnativesocketengine.cpp126
-rw-r--r--src/network/socket/qnativesocketengine_p.h22
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp182
-rw-r--r--src/network/socket/qnativesocketengine_win.cpp57
-rw-r--r--src/network/socket/qnativesocketengine_winrt.cpp16
-rw-r--r--src/network/socket/qnativesocketengine_winrt_p.h2
-rw-r--r--src/network/socket/qnet_unix_p.h1
-rw-r--r--src/network/socket/qsctpserver.cpp250
-rw-r--r--src/network/socket/qsctpserver.h (renamed from src/corelib/io/qurl_mac.mm)57
-rw-r--r--src/network/socket/qsctpserver_p.h76
-rw-r--r--src/network/socket/qsctpsocket.cpp547
-rw-r--r--src/network/socket/qsctpsocket.h82
-rw-r--r--src/network/socket/qsctpsocket_p.h90
-rw-r--r--src/network/socket/qsocks5socketengine.cpp62
-rw-r--r--src/network/socket/qsocks5socketengine_p.h7
-rw-r--r--src/network/socket/qtcpserver.cpp39
-rw-r--r--src/network/socket/qtcpserver.h4
-rw-r--r--src/network/socket/qtcpserver_p.h3
-rw-r--r--src/network/socket/qtcpsocket.h1
-rw-r--r--src/network/socket/qtcpsocket_p.h1
-rw-r--r--src/network/socket/qudpsocket.cpp126
-rw-r--r--src/network/socket/qudpsocket.h5
-rw-r--r--src/network/socket/socket.pri27
-rw-r--r--src/network/ssl/qasn1element_p.h1
-rw-r--r--src/network/ssl/qssl.h2
-rw-r--r--src/network/ssl/qssl_p.h1
-rw-r--r--src/network/ssl/qsslcertificate.h1
-rw-r--r--src/network/ssl/qsslcertificate_p.h1
-rw-r--r--src/network/ssl/qsslcertificateextension.h1
-rw-r--r--src/network/ssl/qsslcertificateextension_p.h1
-rw-r--r--src/network/ssl/qsslcipher.h1
-rw-r--r--src/network/ssl/qsslcipher_p.h1
-rw-r--r--src/network/ssl/qsslconfiguration.cpp78
-rw-r--r--src/network/ssl/qsslconfiguration.h9
-rw-r--r--src/network/ssl/qsslconfiguration_p.h8
-rw-r--r--src/network/ssl/qsslcontext_openssl.cpp61
-rw-r--r--src/network/ssl/qsslcontext_openssl_p.h1
-rw-r--r--src/network/ssl/qssldiffiehellmanparameters.cpp324
-rw-r--r--src/network/ssl/qssldiffiehellmanparameters.h118
-rw-r--r--src/network/ssl/qssldiffiehellmanparameters_dummy.cpp57
-rw-r--r--src/network/ssl/qssldiffiehellmanparameters_openssl.cpp164
-rw-r--r--src/network/ssl/qssldiffiehellmanparameters_p.h78
-rw-r--r--src/network/ssl/qsslellipticcurve.h2
-rw-r--r--src/network/ssl/qsslerror.h1
-rw-r--r--src/network/ssl/qsslkey.h1
-rw-r--r--src/network/ssl/qsslkey_p.cpp16
-rw-r--r--src/network/ssl/qsslkey_p.h4
-rw-r--r--src/network/ssl/qsslpresharedkeyauthenticator.h2
-rw-r--r--src/network/ssl/qsslpresharedkeyauthenticator_p.h1
-rw-r--r--src/network/ssl/qsslsocket.cpp28
-rw-r--r--src/network/ssl/qsslsocket.h3
-rw-r--r--src/network/ssl/qsslsocket_mac.cpp187
-rw-r--r--src/network/ssl/qsslsocket_mac_p.h1
-rw-r--r--src/network/ssl/qsslsocket_openssl.cpp73
-rw-r--r--src/network/ssl/qsslsocket_openssl_android.cpp1
-rw-r--r--src/network/ssl/qsslsocket_openssl_p.h2
-rw-r--r--src/network/ssl/qsslsocket_openssl_symbols.cpp39
-rw-r--r--src/network/ssl/qsslsocket_openssl_symbols_p.h48
-rw-r--r--src/network/ssl/qsslsocket_p.h6
-rw-r--r--src/network/ssl/qsslsocket_winrt.cpp4
-rw-r--r--src/network/ssl/qsslsocket_winrt_p.h1
-rw-r--r--src/network/ssl/ssl.pri62
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp6
-rw-r--r--src/opengl/qgl.cpp3
-rw-r--r--src/platformsupport/cglconvenience/cglconvenience.mm23
-rw-r--r--src/platformsupport/clipboard/qmacmime.mm7
-rw-r--r--src/platformsupport/eventdispatchers/eventdispatchers.pri4
-rw-r--r--src/platformsupport/eventdispatchers/qwindowsguieventdispatcher.cpp4
-rw-r--r--src/platformsupport/fbconvenience/qfbbackingstore.cpp7
-rw-r--r--src/platformsupport/fbconvenience/qfbbackingstore_p.h1
-rw-r--r--src/platformsupport/fbconvenience/qfbscreen.cpp10
-rw-r--r--src/platformsupport/fontdatabases/basic/basic.pri2
-rw-r--r--src/platformsupport/fontdatabases/mac/coretext.pri5
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm259
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h9
-rw-r--r--src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm46
-rw-r--r--src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h7
-rw-r--r--src/platformsupport/graphics/qrasterbackingstore.cpp4
-rw-r--r--src/platformsupport/input/evdevtouch/evdevtouch.pri3
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp40
-rw-r--r--src/platformsupport/input/input.pri4
-rw-r--r--src/platformsupport/input/libinput/libinput.pri2
-rw-r--r--src/platformsupport/input/libinput/qlibinputtouch.cpp13
-rw-r--r--src/platformsupport/input/shared/qtouchoutputmapping.cpp (renamed from src/corelib/tools/qbytearray_mac.mm)86
-rw-r--r--src/platformsupport/input/shared/qtouchoutputmapping_p.h (renamed from src/gui/image/qnativeimage_p.h)33
-rw-r--r--src/platformsupport/input/shared/shared.pri5
-rw-r--r--src/platformsupport/linuxaccessibility/atspiadaptor.cpp22
-rw-r--r--src/platformsupport/platformcompositor/qopenglcompositor.cpp41
-rw-r--r--src/platformsupport/platformcompositor/qopenglcompositor_p.h9
-rw-r--r--src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp8
-rw-r--r--src/platformsupport/platformsupport.pro2
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes.cpp39
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes_p.h5
-rw-r--r--src/platformsupport/themes/qabstractfileiconengine.cpp130
-rw-r--r--src/platformsupport/themes/qabstractfileiconengine_p.h96
-rw-r--r--src/platformsupport/themes/themes.pri6
-rw-r--r--src/plugins/bearer/bearer.pro2
-rw-r--r--src/plugins/bearer/corewlan/qcorewlanengine.mm20
-rw-r--r--src/plugins/bearer/generic/qgenericengine.cpp38
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp44
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerengine.h30
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp30
-rw-r--r--src/plugins/bearer/nla/nla.pro6
-rw-r--r--src/plugins/bearer/qnetworksession_impl.cpp2
-rw-r--r--src/plugins/generic/bsdkeyboard/bsdkeyboard.json3
-rw-r--r--src/plugins/generic/bsdkeyboard/bsdkeyboard.pro16
-rw-r--r--src/plugins/generic/bsdkeyboard/main.cpp59
-rw-r--r--src/plugins/generic/bsdkeyboard/qbsdkeyboard.cpp408
-rw-r--r--src/plugins/generic/bsdkeyboard/qbsdkeyboard.h139
-rw-r--r--src/plugins/generic/bsdkeyboard/qbsdkeyboard_defaultmap.h622
-rw-r--r--src/plugins/generic/bsdmouse/bsdmouse.json3
-rw-r--r--src/plugins/generic/bsdmouse/bsdmouse.pro16
-rw-r--r--src/plugins/generic/bsdmouse/main.cpp58
-rw-r--r--src/plugins/generic/bsdmouse/qbsdmouse.cpp165
-rw-r--r--src/plugins/generic/bsdmouse/qbsdmouse.h70
-rw-r--r--src/plugins/generic/generic.pro4
-rw-r--r--src/plugins/generic/tuiotouch/qtuiohandler.cpp256
-rw-r--r--src/plugins/generic/tuiotouch/qtuiohandler_p.h8
-rw-r--r--src/plugins/generic/tuiotouch/qtuiotoken_p.h144
-rw-r--r--src/plugins/generic/tuiotouch/tuiotouch.pro3
-rw-r--r--src/plugins/imageformats/gif/gif.pro7
-rw-r--r--src/plugins/imageformats/gif/qgifhandler.cpp (renamed from src/gui/image/qgifhandler.cpp)0
-rw-r--r--src/plugins/imageformats/gif/qgifhandler_p.h (renamed from src/gui/image/qgifhandler_p.h)0
-rw-r--r--src/plugins/imageformats/ico/ico.pro7
-rw-r--r--src/plugins/imageformats/imageformats.pro4
-rw-r--r--src/plugins/imageformats/jpeg/jpeg.pro18
-rw-r--r--src/plugins/imageformats/jpeg/qjpeghandler.cpp (renamed from src/gui/image/qjpeghandler.cpp)25
-rw-r--r--src/plugins/imageformats/jpeg/qjpeghandler_p.h (renamed from src/gui/image/qjpeghandler_p.h)0
-rw-r--r--src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp2
-rw-r--r--src/plugins/platforminputcontexts/ibus/qibustypes.cpp5
-rw-r--r--src/plugins/platforms/android/qandroidinputcontext.cpp14
-rw-r--r--src/plugins/platforms/android/qandroidplatformintegration.cpp18
-rw-r--r--src/plugins/platforms/android/qandroidplatformintegration.h2
-rw-r--r--src/plugins/platforms/android/qandroidplatformscreen.cpp3
-rw-r--r--src/plugins/platforms/bsdfb/bsdfb.json3
-rw-r--r--src/plugins/platforms/bsdfb/bsdfb.pro15
-rw-r--r--src/plugins/platforms/bsdfb/main.cpp60
-rw-r--r--src/plugins/platforms/bsdfb/qbsdfbintegration.cpp142
-rw-r--r--src/plugins/platforms/bsdfb/qbsdfbintegration.h81
-rw-r--r--src/plugins/platforms/bsdfb/qbsdfbscreen.cpp276
-rw-r--r--src/plugins/platforms/bsdfb/qbsdfbscreen.h74
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplication.h1
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplication.mm13
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h3
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm21
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.h5
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.mm10
-rw-r--r--src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm10
-rw-r--r--src/plugins/platforms/cocoa/qcocoadrag.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm7
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.h8
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.mm181
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoakeymapper.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenu.mm7
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenubar.mm7
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuitem.mm12
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuloader.h8
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuloader.mm195
-rw-r--r--src/plugins/platforms/cocoa/qcocoaresources.qrc5
-rw-r--r--src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm90
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.h4
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.mm55
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm48
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h1
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm65
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.h1
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.mm7
-rw-r--r--src/plugins/platforms/cocoa/qpaintengine_mac.mm5
-rw-r--r--src/plugins/platforms/cocoa/qt_mac_p.h16
-rw-r--r--src/plugins/platforms/cocoa/qt_menu.nib/classes.nib59
-rw-r--r--src/plugins/platforms/cocoa/qt_menu.nib/info.nib18
-rw-r--r--src/plugins/platforms/cocoa/qt_menu.nib/keyedobjects.nibbin5560 -> 0 bytes
-rw-r--r--src/plugins/platforms/direct2d/direct2d.pro2
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.cpp10
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.h2
-rw-r--r--src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp2
-rw-r--r--src/plugins/platforms/directfb/qdirectfbbackingstore.cpp16
-rw-r--r--src/plugins/platforms/directfb/qdirectfbbackingstore.h2
-rw-r--r--src/plugins/platforms/eglfs/api/api.pri15
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfscursor.cpp (renamed from src/plugins/platforms/eglfs/qeglfscursor.cpp)172
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfscursor_p.h (renamed from src/plugins/platforms/eglfs/qeglfscursor.h)28
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp (renamed from src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp)108
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsdeviceintegration_p.h (renamed from src/plugins/platforms/eglfs/qeglfsdeviceintegration.h)18
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsglobal.h (renamed from src/plugins/platforms/eglfs/qeglfsglobal.h)9
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfshooks.cpp (renamed from src/plugins/platforms/eglfs/qeglfshooks.cpp)16
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfshooks_p.h67
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsscreen.cpp (renamed from src/plugins/platforms/eglfs/qeglfsscreen.cpp)31
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfsscreen_p.h (renamed from src/plugins/platforms/eglfs/qeglfsscreen.h)14
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfswindow.cpp (renamed from src/plugins/platforms/eglfs/qeglfswindow.cpp)15
-rw-r--r--src/plugins/platforms/eglfs/api/qeglfswindow_p.h (renamed from src/plugins/platforms/eglfs/qeglfswindow.h)13
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/eglfs_brcm.pro2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmintegration.h4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmmain.cpp8
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h3
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmmain.cpp8
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp11
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h5
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp33
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h15
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp19
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h3
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicemain.cpp6
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp26
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h10
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp98
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h5
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp29
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.h11
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp15
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h10
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/eglfs_mali.pro2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.cpp2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.h4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmalimain.cpp8
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/eglfs_viv.pro3
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.h4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivmain.cpp8
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro3
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.cpp2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.h4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlmain.cpp8
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro2
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h4
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11main.cpp8
-rw-r--r--src/plugins/platforms/eglfs/eglfs-plugin.pro2
-rw-r--r--src/plugins/platforms/eglfs/eglfs.pro2
-rw-r--r--src/plugins/platforms/eglfs/eglfsdeviceintegration.pro (renamed from src/plugins/platforms/eglfs/eglfs_device_lib.pro)17
-rw-r--r--src/plugins/platforms/eglfs/qeglfscontext.cpp6
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.cpp26
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.h2
-rw-r--r--src/plugins/platforms/eglfs/qeglfsoffscreenwindow.cpp2
-rw-r--r--src/plugins/platforms/ios/ios.pro36
-rw-r--r--src/plugins/platforms/ios/plugin.mm4
-rw-r--r--src/plugins/platforms/ios/qioseventdispatcher.mm2
-rw-r--r--src/plugins/platforms/ios/qiosfileenginefactory.h4
-rw-r--r--src/plugins/platforms/ios/qiosglobal.h7
-rw-r--r--src/plugins/platforms/ios/qiosglobal.mm22
-rw-r--r--src/plugins/platforms/ios/qiosinputcontext.mm14
-rw-r--r--src/plugins/platforms/ios/qiosintegration.h7
-rw-r--r--src/plugins/platforms/ios/qiosintegration.mm10
-rw-r--r--src/plugins/platforms/ios/qiosmenu.mm2
-rw-r--r--src/plugins/platforms/ios/qiosscreen.mm22
-rw-r--r--src/plugins/platforms/ios/qiostextinputoverlay.mm22
-rw-r--r--src/plugins/platforms/ios/qiostextresponder.mm12
-rw-r--r--src/plugins/platforms/ios/qiostheme.mm12
-rw-r--r--src/plugins/platforms/ios/qiosviewcontroller.h4
-rw-r--r--src/plugins/platforms/ios/qiosviewcontroller.mm66
-rw-r--r--src/plugins/platforms/ios/qioswindow.mm2
-rw-r--r--src/plugins/platforms/ios/quiview.mm76
-rw-r--r--src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp6
-rw-r--r--src/plugins/platforms/mirclient/qmirclientbackingstore.cpp8
-rw-r--r--src/plugins/platforms/offscreen/qoffscreencommon.cpp5
-rw-r--r--src/plugins/platforms/platforms.pro12
-rw-r--r--src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp4
-rw-r--r--src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp12
-rw-r--r--src/plugins/platforms/qnx/qqnxintegration.cpp4
-rw-r--r--src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp4
-rw-r--r--src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp3
-rw-r--r--src/plugins/platforms/qnx/qqnxnavigatorpps.cpp2
-rw-r--r--src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp2
-rw-r--r--src/plugins/platforms/qnx/qqnxrasterwindow.cpp5
-rw-r--r--src/plugins/platforms/qnx/qqnxscreen.cpp19
-rw-r--r--src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp2
-rw-r--r--src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp4
-rw-r--r--src/plugins/platforms/vnc/main.cpp (renamed from src/gui/image/qnativeimage.cpp)37
-rw-r--r--src/plugins/platforms/vnc/qvnc.cpp680
-rw-r--r--src/plugins/platforms/vnc/qvnc_p.h417
-rw-r--r--src/plugins/platforms/vnc/qvncclient.cpp662
-rw-r--r--src/plugins/platforms/vnc/qvncclient.h149
-rw-r--r--src/plugins/platforms/vnc/qvncintegration.cpp148
-rw-r--r--src/plugins/platforms/vnc/qvncintegration.h85
-rw-r--r--src/plugins/platforms/vnc/qvncscreen.cpp187
-rw-r--r--src/plugins/platforms/vnc/qvncscreen.h93
-rw-r--r--src/plugins/platforms/vnc/vnc.json3
-rw-r--r--src/plugins/platforms/vnc/vnc.pro25
-rw-r--r--src/plugins/platforms/windows/accessible/accessible.pri14
-rw-r--r--src/plugins/platforms/windows/accessible/comutils.cpp24
-rw-r--r--src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp36
-rw-r--r--src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp2
-rw-r--r--src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h2
-rw-r--r--src/plugins/platforms/windows/qplatformfunctions_wince.h371
-rw-r--r--src/plugins/platforms/windows/qtwindows_additional.h179
-rw-r--r--src/plugins/platforms/windows/qtwindowsglobal.h23
-rw-r--r--src/plugins/platforms/windows/qwindowsbackingstore.cpp39
-rw-r--r--src/plugins/platforms/windows/qwindowsbackingstore.h4
-rw-r--r--src/plugins/platforms/windows/qwindowsclipboard.cpp3
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp208
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.h46
-rw-r--r--src/plugins/platforms/windows/qwindowscursor.cpp70
-rw-r--r--src/plugins/platforms/windows/qwindowscursor.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsdialoghelpers.cpp340
-rw-r--r--src/plugins/platforms/windows/qwindowsdialoghelpers.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsdrag.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowseglcontext.cpp12
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase.cpp239
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp333
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase_ft.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsfontengine.cpp124
-rw-r--r--src/plugins/platforms/windows/qwindowsfontengine.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsglcontext.cpp10
-rw-r--r--src/plugins/platforms/windows/qwindowsglcontext.h4
-rw-r--r--src/plugins/platforms/windows/qwindowsinputcontext.cpp4
-rw-r--r--src/plugins/platforms/windows/qwindowsinputcontext.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp49
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsinternalmimedata.cpp1
-rw-r--r--src/plugins/platforms/windows/qwindowsinternalmimedata.h2
-rw-r--r--src/plugins/platforms/windows/qwindowskeymapper.cpp34
-rw-r--r--src/plugins/platforms/windows/qwindowskeymapper.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsmime.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsmime.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.cpp128
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.h6
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeimage.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsnativeimage.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsole.h2
-rw-r--r--src/plugins/platforms/windows/qwindowsopengltester.cpp36
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.cpp25
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.h3
-rw-r--r--src/plugins/platforms/windows/qwindowsservices.cpp15
-rw-r--r--src/plugins/platforms/windows/qwindowstabletsupport.h4
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp162
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.h11
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp185
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.h22
-rw-r--r--src/plugins/platforms/windows/windows.pri40
-rw-r--r--src/plugins/platforms/windows/windows.pro2
-rw-r--r--src/plugins/platforms/xcb/qxcbbackingstore.cpp19
-rw-r--r--src/plugins/platforms/xcb/qxcbbackingstore.h2
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp18
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h1
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp5
-rw-r--r--src/plugins/platforms/xcb/xcb_qpa_lib.pro10
-rw-r--r--src/plugins/platformthemes/gtk3/gtk3.pro6
-rw-r--r--src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp12
-rw-r--r--src/plugins/platformthemes/gtk3/qgtk3menu.cpp489
-rw-r--r--src/plugins/platformthemes/gtk3/qgtk3menu.h162
-rw-r--r--src/plugins/platformthemes/gtk3/qgtk3theme.cpp11
-rw-r--r--src/plugins/platformthemes/gtk3/qgtk3theme.h3
-rw-r--r--src/plugins/sqldrivers/db2/db2.pro11
-rw-r--r--src/plugins/sqldrivers/db2/main.cpp2
-rw-r--r--src/plugins/sqldrivers/db2/qsql_db2.cpp (renamed from src/sql/drivers/db2/qsql_db2.cpp)0
-rw-r--r--src/plugins/sqldrivers/db2/qsql_db2_p.h (renamed from src/sql/drivers/db2/qsql_db2_p.h)0
-rw-r--r--src/plugins/sqldrivers/ibase/ibase.pro13
-rw-r--r--src/plugins/sqldrivers/ibase/main.cpp2
-rw-r--r--src/plugins/sqldrivers/ibase/qsql_ibase.cpp (renamed from src/sql/drivers/ibase/qsql_ibase.cpp)0
-rw-r--r--src/plugins/sqldrivers/ibase/qsql_ibase_p.h (renamed from src/sql/drivers/ibase/qsql_ibase_p.h)0
-rw-r--r--src/plugins/sqldrivers/mysql/main.cpp2
-rw-r--r--src/plugins/sqldrivers/mysql/mysql.pro19
-rw-r--r--src/plugins/sqldrivers/mysql/qsql_mysql.cpp (renamed from src/sql/drivers/mysql/qsql_mysql.cpp)9
-rw-r--r--src/plugins/sqldrivers/mysql/qsql_mysql_p.h (renamed from src/sql/drivers/mysql/qsql_mysql_p.h)0
-rw-r--r--src/plugins/sqldrivers/oci/main.cpp2
-rw-r--r--src/plugins/sqldrivers/oci/oci.pro12
-rw-r--r--src/plugins/sqldrivers/oci/qsql_oci.cpp (renamed from src/sql/drivers/oci/qsql_oci.cpp)0
-rw-r--r--src/plugins/sqldrivers/oci/qsql_oci_p.h (renamed from src/sql/drivers/oci/qsql_oci_p.h)0
-rw-r--r--src/plugins/sqldrivers/odbc/main.cpp2
-rw-r--r--src/plugins/sqldrivers/odbc/odbc.pro15
-rw-r--r--src/plugins/sqldrivers/odbc/qsql_odbc.cpp (renamed from src/sql/drivers/odbc/qsql_odbc.cpp)0
-rw-r--r--src/plugins/sqldrivers/odbc/qsql_odbc_p.h (renamed from src/sql/drivers/odbc/qsql_odbc_p.h)0
-rw-r--r--src/plugins/sqldrivers/psql/main.cpp2
-rw-r--r--src/plugins/sqldrivers/psql/psql.pro13
-rw-r--r--src/plugins/sqldrivers/psql/qsql_psql.cpp (renamed from src/sql/drivers/psql/qsql_psql.cpp)0
-rw-r--r--src/plugins/sqldrivers/psql/qsql_psql_p.h (renamed from src/sql/drivers/psql/qsql_psql_p.h)0
-rw-r--r--src/plugins/sqldrivers/sqldrivers.pro18
-rw-r--r--src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp (renamed from src/sql/drivers/sqlite/qsql_sqlite.cpp)81
-rw-r--r--src/plugins/sqldrivers/sqlite/qsql_sqlite_p.h (renamed from src/sql/drivers/sqlite/qsql_sqlite_p.h)6
-rw-r--r--src/plugins/sqldrivers/sqlite/smain.cpp2
-rw-r--r--src/plugins/sqldrivers/sqlite/sqlite.pro12
-rw-r--r--src/plugins/sqldrivers/sqlite2/qsql_sqlite2.cpp (renamed from src/sql/drivers/sqlite2/qsql_sqlite2.cpp)0
-rw-r--r--src/plugins/sqldrivers/sqlite2/qsql_sqlite2_p.h (renamed from src/sql/drivers/sqlite2/qsql_sqlite2_p.h)0
-rw-r--r--src/plugins/sqldrivers/sqlite2/smain.cpp2
-rw-r--r--src/plugins/sqldrivers/sqlite2/sqlite2.pro7
-rw-r--r--src/plugins/sqldrivers/tds/main.cpp2
-rw-r--r--src/plugins/sqldrivers/tds/qsql_tds.cpp (renamed from src/sql/drivers/tds/qsql_tds.cpp)2
-rw-r--r--src/plugins/sqldrivers/tds/qsql_tds_p.h (renamed from src/sql/drivers/tds/qsql_tds_p.h)0
-rw-r--r--src/plugins/sqldrivers/tds/tds.pro13
-rw-r--r--src/printsupport/dialogs/qabstractprintdialog.h2
-rw-r--r--src/printsupport/dialogs/qabstractprintdialog_p.h1
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog.h2
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog_p.h1
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog_unix_p.h2
-rw-r--r--src/printsupport/dialogs/qprintdialog.h1
-rw-r--r--src/printsupport/dialogs/qprintpreviewdialog.h2
-rw-r--r--src/printsupport/kernel/kernel.pri1
-rw-r--r--src/printsupport/kernel/qcups_p.h2
-rw-r--r--src/printsupport/kernel/qpaintengine_alpha_p.h2
-rw-r--r--src/printsupport/kernel/qpaintengine_preview_p.h1
-rw-r--r--src/printsupport/kernel/qplatformprintdevice.h1
-rw-r--r--src/printsupport/kernel/qplatformprintersupport.h1
-rw-r--r--src/printsupport/kernel/qplatformprintplugin.h2
-rw-r--r--src/printsupport/kernel/qprint_p.h5
-rw-r--r--src/printsupport/kernel/qprintdevice_p.h1
-rw-r--r--src/printsupport/kernel/qprintengine.h1
-rw-r--r--src/printsupport/kernel/qprintengine_win.cpp4
-rw-r--r--src/printsupport/kernel/qprintengine_win_p.h2
-rw-r--r--src/printsupport/kernel/qprinter.h2
-rw-r--r--src/printsupport/kernel/qprinter_p.h2
-rw-r--r--src/printsupport/kernel/qprinterinfo.h1
-rw-r--r--src/printsupport/kernel/qprinterinfo_p.h2
-rw-r--r--src/printsupport/kernel/qtprintsupportglobal.h2
-rw-r--r--src/printsupport/kernel/qtprintsupportglobal_p.h57
-rw-r--r--src/printsupport/widgets/qcupsjobwidget_p.h1
-rw-r--r--src/printsupport/widgets/qprintpreviewwidget.h1
-rw-r--r--src/sql/doc/src/qtsql.qdoc13
-rw-r--r--src/sql/drivers/db2/qsql_db2.pri8
-rw-r--r--src/sql/drivers/drivers.pri11
-rw-r--r--src/sql/drivers/ibase/qsql_ibase.pri10
-rw-r--r--src/sql/drivers/mysql/qsql_mysql.pri16
-rw-r--r--src/sql/drivers/oci/qsql_oci.pri9
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.pri12
-rw-r--r--src/sql/drivers/psql/qsql_psql.pri10
-rw-r--r--src/sql/drivers/sqlite/qsql_sqlite.pri9
-rw-r--r--src/sql/drivers/sqlite2/qsql_sqlite2.pri4
-rw-r--r--src/sql/drivers/tds/qsql_tds.pri10
-rw-r--r--src/sql/kernel/kernel.pri3
-rw-r--r--src/sql/kernel/qsqlcachedresult_p.h1
-rw-r--r--src/sql/kernel/qsqldatabase.cpp117
-rw-r--r--src/sql/kernel/qsqldatabase.h2
-rw-r--r--src/sql/kernel/qsqldriver.h2
-rw-r--r--src/sql/kernel/qsqldriver_p.h1
-rw-r--r--src/sql/kernel/qsqldriverplugin.h2
-rw-r--r--src/sql/kernel/qsqlerror.h2
-rw-r--r--src/sql/kernel/qsqlfield.h2
-rw-r--r--src/sql/kernel/qsqlindex.h1
-rw-r--r--src/sql/kernel/qsqlnulldriver_p.h1
-rw-r--r--src/sql/kernel/qsqlquery.h2
-rw-r--r--src/sql/kernel/qsqlrecord.h2
-rw-r--r--src/sql/kernel/qsqlresult.h2
-rw-r--r--src/sql/kernel/qsqlresult_p.h1
-rw-r--r--src/sql/kernel/qtsqlglobal.h (renamed from src/sql/kernel/qsql.h)4
-rw-r--r--src/sql/kernel/qtsqlglobal_p.h57
-rw-r--r--src/sql/models/qsqlquerymodel.h1
-rw-r--r--src/sql/models/qsqlquerymodel_p.h1
-rw-r--r--src/sql/models/qsqlrelationaldelegate.h2
-rw-r--r--src/sql/models/qsqlrelationaltablemodel.h1
-rw-r--r--src/sql/models/qsqltablemodel.h1
-rw-r--r--src/sql/models/qsqltablemodel_p.h1
-rw-r--r--src/sql/sql.pro1
-rw-r--r--src/src.pro10
-rw-r--r--src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp9
-rw-r--r--src/testlib/qabstracttestlogger.cpp2
-rw-r--r--src/testlib/qbenchmarkmetric.cpp5
-rw-r--r--src/testlib/qbenchmarkmetric.h3
-rw-r--r--src/testlib/qbenchmarkperfevents.cpp9
-rw-r--r--src/testlib/qplaintestlogger.cpp15
-rw-r--r--src/testlib/qtest.h5
-rw-r--r--src/testlib/qtestblacklist.cpp6
-rw-r--r--src/testlib/qtestcase.cpp87
-rw-r--r--src/testlib/qtestcase.h31
-rw-r--r--src/testlib/qtestcase.qdoc22
-rw-r--r--src/testlib/qtesttouch.h1
-rw-r--r--src/testlib/qxctestlogger.mm2
-rw-r--r--src/testlib/qxunittestlogger.cpp2
-rw-r--r--src/testlib/testlib.pro7
-rw-r--r--src/tools/bootstrap/bootstrap.pro6
-rw-r--r--src/tools/moc/generator.cpp7
-rw-r--r--src/tools/moc/main.cpp70
-rw-r--r--src/tools/moc/preprocessor.cpp65
-rw-r--r--src/tools/moc/preprocessor.h1
-rw-r--r--src/tools/uic/cpp/cppwritedeclaration.cpp21
-rw-r--r--src/tools/uic/cpp/cppwriteinitialization.cpp48
-rw-r--r--src/widgets/accessible/complexwidgets.cpp24
-rw-r--r--src/widgets/accessible/complexwidgets_p.h1
-rw-r--r--src/widgets/accessible/itemviews.cpp4
-rw-r--r--src/widgets/accessible/itemviews_p.h1
-rw-r--r--src/widgets/accessible/qaccessiblemenu_p.h1
-rw-r--r--src/widgets/accessible/qaccessiblewidget.h1
-rw-r--r--src/widgets/accessible/qaccessiblewidgetfactory_p.h1
-rw-r--r--src/widgets/accessible/qaccessiblewidgets_p.h1
-rw-r--r--src/widgets/accessible/rangecontrols_p.h1
-rw-r--r--src/widgets/accessible/simplewidgets_p.h1
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp16
-rw-r--r--src/widgets/dialogs/qcolordialog.h1
-rw-r--r--src/widgets/dialogs/qdialog.cpp25
-rw-r--r--src/widgets/dialogs/qdialog.h8
-rw-r--r--src/widgets/dialogs/qdialog_p.h5
-rw-r--r--src/widgets/dialogs/qerrormessage.cpp28
-rw-r--r--src/widgets/dialogs/qerrormessage.h1
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp14
-rw-r--r--src/widgets/dialogs/qfiledialog.h1
-rw-r--r--src/widgets/dialogs/qfiledialog_p.h6
-rw-r--r--src/widgets/dialogs/qfileinfogatherer.cpp2
-rw-r--r--src/widgets/dialogs/qfileinfogatherer_p.h2
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp13
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.h1
-rw-r--r--src/widgets/dialogs/qfilesystemmodel_p.h3
-rw-r--r--src/widgets/dialogs/qfontdialog.cpp10
-rw-r--r--src/widgets/dialogs/qfontdialog.h1
-rw-r--r--src/widgets/dialogs/qfontdialog_p.h1
-rw-r--r--src/widgets/dialogs/qfscompleter_p.h6
-rw-r--r--src/widgets/dialogs/qinputdialog.h1
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp74
-rw-r--r--src/widgets/dialogs/qmessagebox.h5
-rw-r--r--src/widgets/dialogs/qprogressdialog.cpp19
-rw-r--r--src/widgets/dialogs/qprogressdialog.h1
-rw-r--r--src/widgets/dialogs/qsidebar_p.h1
-rw-r--r--src/widgets/dialogs/qwizard.cpp8
-rw-r--r--src/widgets/dialogs/qwizard.h1
-rw-r--r--src/widgets/dialogs/qwizard_win.cpp252
-rw-r--r--src/widgets/dialogs/qwizard_win_p.h4
-rw-r--r--src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp1
-rw-r--r--src/widgets/effects/qgraphicseffect.h1
-rw-r--r--src/widgets/effects/qgraphicseffect_p.h1
-rw-r--r--src/widgets/effects/qpixmapfilter_p.h1
-rw-r--r--src/widgets/graphicsview/qgraph_p.h1
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout.h1
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout_p.h1
-rw-r--r--src/widgets/graphicsview/qgraphicsgridlayout.h1
-rw-r--r--src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h1
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp13
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.h2
-rw-r--r--src/widgets/graphicsview/qgraphicsitem_p.h1
-rw-r--r--src/widgets/graphicsview/qgraphicsitemanimation.h1
-rw-r--r--src/widgets/graphicsview/qgraphicslayout.h1
-rw-r--r--src/widgets/graphicsview/qgraphicslayout_p.h2
-rw-r--r--src/widgets/graphicsview/qgraphicslayoutitem.h1
-rw-r--r--src/widgets/graphicsview/qgraphicslayoutitem_p.h1
-rw-r--r--src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h1
-rw-r--r--src/widgets/graphicsview/qgraphicslinearlayout.h1
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget.h1
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget_p.h1
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp7
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.h1
-rw-r--r--src/widgets/graphicsview/qgraphicsscene_bsp_p.h1
-rw-r--r--src/widgets/graphicsview/qgraphicsscene_p.h1
-rw-r--r--src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h2
-rw-r--r--src/widgets/graphicsview/qgraphicssceneevent.h1
-rw-r--r--src/widgets/graphicsview/qgraphicssceneindex_p.h1
-rw-r--r--src/widgets/graphicsview/qgraphicsscenelinearindex_p.h2
-rw-r--r--src/widgets/graphicsview/qgraphicstransform.h1
-rw-r--r--src/widgets/graphicsview/qgraphicstransform_p.h4
-rw-r--r--src/widgets/graphicsview/qgraphicsview.cpp15
-rw-r--r--src/widgets/graphicsview/qgraphicsview.h1
-rw-r--r--src/widgets/graphicsview/qgraphicsview_p.h1
-rw-r--r--src/widgets/graphicsview/qgraphicswidget.h1
-rw-r--r--src/widgets/graphicsview/qgraphicswidget_p.h1
-rw-r--r--src/widgets/graphicsview/qsimplex_p.h1
-rw-r--r--src/widgets/itemviews/qabstractitemdelegate.h1
-rw-r--r--src/widgets/itemviews/qabstractitemdelegate_p.h1
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp4
-rw-r--r--src/widgets/itemviews/qabstractitemview.h1
-rw-r--r--src/widgets/itemviews/qabstractitemview_p.h1
-rw-r--r--src/widgets/itemviews/qbsptree_p.h1
-rw-r--r--src/widgets/itemviews/qcolumnview.h1
-rw-r--r--src/widgets/itemviews/qcolumnview_p.h1
-rw-r--r--src/widgets/itemviews/qcolumnviewgrip_p.h1
-rw-r--r--src/widgets/itemviews/qdatawidgetmapper.h1
-rw-r--r--src/widgets/itemviews/qdirmodel.cpp20
-rw-r--r--src/widgets/itemviews/qdirmodel.h1
-rw-r--r--src/widgets/itemviews/qfileiconprovider.cpp131
-rw-r--r--src/widgets/itemviews/qfileiconprovider.h1
-rw-r--r--src/widgets/itemviews/qfileiconprovider_p.h1
-rw-r--r--src/widgets/itemviews/qheaderview.h1
-rw-r--r--src/widgets/itemviews/qheaderview_p.h1
-rw-r--r--src/widgets/itemviews/qitemdelegate.h1
-rw-r--r--src/widgets/itemviews/qitemeditorfactory.h1
-rw-r--r--src/widgets/itemviews/qitemeditorfactory_p.h2
-rw-r--r--src/widgets/itemviews/qlistview.h1
-rw-r--r--src/widgets/itemviews/qlistview_p.h1
-rw-r--r--src/widgets/itemviews/qlistwidget.h1
-rw-r--r--src/widgets/itemviews/qlistwidget_p.h1
-rw-r--r--src/widgets/itemviews/qstyleditemdelegate.h1
-rw-r--r--src/widgets/itemviews/qtableview.cpp3
-rw-r--r--src/widgets/itemviews/qtableview.h1
-rw-r--r--src/widgets/itemviews/qtableview_p.h1
-rw-r--r--src/widgets/itemviews/qtablewidget.h1
-rw-r--r--src/widgets/itemviews/qtablewidget_p.h1
-rw-r--r--src/widgets/itemviews/qtreeview.cpp9
-rw-r--r--src/widgets/itemviews/qtreeview.h1
-rw-r--r--src/widgets/itemviews/qtreeview_p.h1
-rw-r--r--src/widgets/itemviews/qtreewidget.h1
-rw-r--r--src/widgets/itemviews/qtreewidget_p.h1
-rw-r--r--src/widgets/itemviews/qtreewidgetitemiterator.h2
-rw-r--r--src/widgets/itemviews/qwidgetitemdata_p.h1
-rw-r--r--src/widgets/kernel/kernel.pri6
-rw-r--r--src/widgets/kernel/qaction.cpp17
-rw-r--r--src/widgets/kernel/qaction.h1
-rw-r--r--src/widgets/kernel/qaction_p.h1
-rw-r--r--src/widgets/kernel/qactiongroup.h1
-rw-r--r--src/widgets/kernel/qapplication.cpp86
-rw-r--r--src/widgets/kernel/qapplication.h14
-rw-r--r--src/widgets/kernel/qapplication_p.h10
-rw-r--r--src/widgets/kernel/qboxlayout.h1
-rw-r--r--src/widgets/kernel/qdesktopwidget.h1
-rw-r--r--src/widgets/kernel/qdesktopwidget_p.h1
-rw-r--r--src/widgets/kernel/qformlayout.cpp330
-rw-r--r--src/widgets/kernel/qformlayout.h16
-rw-r--r--src/widgets/kernel/qgesture.h1
-rw-r--r--src/widgets/kernel/qgesture_p.h1
-rw-r--r--src/widgets/kernel/qgesturemanager.cpp2
-rw-r--r--src/widgets/kernel/qgesturemanager_p.h1
-rw-r--r--src/widgets/kernel/qgesturerecognizer.h2
-rw-r--r--src/widgets/kernel/qgridlayout.cpp10
-rw-r--r--src/widgets/kernel/qgridlayout.h1
-rw-r--r--src/widgets/kernel/qlayout.cpp7
-rw-r--r--src/widgets/kernel/qlayout.h1
-rw-r--r--src/widgets/kernel/qlayout_p.h1
-rw-r--r--src/widgets/kernel/qlayoutengine_p.h1
-rw-r--r--src/widgets/kernel/qlayoutitem.h1
-rw-r--r--src/widgets/kernel/qmacgesturerecognizer_p.h1
-rw-r--r--src/widgets/kernel/qopenglwidget.h2
-rw-r--r--src/widgets/kernel/qshortcut.cpp3
-rw-r--r--src/widgets/kernel/qshortcut.h1
-rw-r--r--src/widgets/kernel/qsizepolicy.h1
-rw-r--r--src/widgets/kernel/qstackedlayout.h1
-rw-r--r--src/widgets/kernel/qstandardgestures_p.h1
-rw-r--r--src/widgets/kernel/qt_widgets_pch.h2
-rw-r--r--src/widgets/kernel/qtooltip.h1
-rw-r--r--src/widgets/kernel/qtwidgetsglobal.h (renamed from src/widgets/kernel/qwidgetsfunctions_wince.h)29
-rw-r--r--src/widgets/kernel/qtwidgetsglobal_p.h57
-rw-r--r--src/widgets/kernel/qwhatsthis.h1
-rw-r--r--src/widgets/kernel/qwidget.cpp27
-rw-r--r--src/widgets/kernel/qwidget.h1
-rw-r--r--src/widgets/kernel/qwidget_p.h1
-rw-r--r--src/widgets/kernel/qwidgetaction.h1
-rw-r--r--src/widgets/kernel/qwidgetaction_p.h1
-rw-r--r--src/widgets/kernel/qwidgetbackingstore.cpp31
-rw-r--r--src/widgets/kernel/qwidgetbackingstore_p.h4
-rw-r--r--src/widgets/kernel/qwidgetsfunctions_wince.cpp120
-rw-r--r--src/widgets/kernel/qwidgetwindow_p.h1
-rw-r--r--src/widgets/kernel/qwindowcontainer_p.h1
-rw-r--r--src/widgets/kernel/win.pri6
-rw-r--r--src/widgets/statemachine/qbasickeyeventtransition_p.h1
-rw-r--r--src/widgets/statemachine/qbasicmouseeventtransition_p.h1
-rw-r--r--src/widgets/statemachine/qkeyeventtransition.h1
-rw-r--r--src/widgets/statemachine/qmouseeventtransition.h1
-rw-r--r--src/widgets/styles/qandroidstyle_p.h1
-rw-r--r--src/widgets/styles/qcommonstyle.cpp37
-rw-r--r--src/widgets/styles/qcommonstyle.h1
-rw-r--r--src/widgets/styles/qcommonstyle_p.h1
-rw-r--r--src/widgets/styles/qcommonstylepixmaps_p.h2
-rw-r--r--src/widgets/styles/qdrawutil.h1
-rw-r--r--src/widgets/styles/qfusionstyle.cpp18
-rw-r--r--src/widgets/styles/qfusionstyle_p.h1
-rw-r--r--src/widgets/styles/qfusionstyle_p_p.h1
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm27
-rw-r--r--src/widgets/styles/qmacstyle_mac_p.h1
-rw-r--r--src/widgets/styles/qmacstyle_mac_p_p.h1
-rw-r--r--src/widgets/styles/qpixmapstyle_p.h1
-rw-r--r--src/widgets/styles/qpixmapstyle_p_p.h1
-rw-r--r--src/widgets/styles/qproxystyle.cpp11
-rw-r--r--src/widgets/styles/qproxystyle.h1
-rw-r--r--src/widgets/styles/qproxystyle_p.h1
-rw-r--r--src/widgets/styles/qstyle.cpp5
-rw-r--r--src/widgets/styles/qstyle.h4
-rw-r--r--src/widgets/styles/qstyle_wince.qrc97
-rw-r--r--src/widgets/styles/qstyleanimation_p.h1
-rw-r--r--src/widgets/styles/qstylefactory.cpp24
-rw-r--r--src/widgets/styles/qstylefactory.h1
-rw-r--r--src/widgets/styles/qstylehelper_p.h2
-rw-r--r--src/widgets/styles/qstyleoption.h1
-rw-r--r--src/widgets/styles/qstylepainter.h1
-rw-r--r--src/widgets/styles/qstyleplugin.h1
-rw-r--r--src/widgets/styles/qstylesheetstyle_p.h1
-rw-r--r--src/widgets/styles/qwindowscestyle.cpp2429
-rw-r--r--src/widgets/styles/qwindowscestyle_p.h108
-rw-r--r--src/widgets/styles/qwindowscestyle_p_p.h116
-rw-r--r--src/widgets/styles/qwindowsmobilestyle.cpp7272
-rw-r--r--src/widgets/styles/qwindowsmobilestyle_p.h121
-rw-r--r--src/widgets/styles/qwindowsmobilestyle_p_p.h133
-rw-r--r--src/widgets/styles/qwindowsstyle.cpp50
-rw-r--r--src/widgets/styles/qwindowsstyle_p.h1
-rw-r--r--src/widgets/styles/qwindowsstyle_p_p.h1
-rw-r--r--src/widgets/styles/qwindowsvistastyle.cpp62
-rw-r--r--src/widgets/styles/qwindowsvistastyle_p.h1
-rw-r--r--src/widgets/styles/qwindowsvistastyle_p_p.h1
-rw-r--r--src/widgets/styles/qwindowsxpstyle.cpp305
-rw-r--r--src/widgets/styles/qwindowsxpstyle_p.h1
-rw-r--r--src/widgets/styles/qwindowsxpstyle_p_p.h164
-rw-r--r--src/widgets/styles/styles.pri22
-rw-r--r--src/widgets/util/qcolormap.h1
-rw-r--r--src/widgets/util/qcompleter.cpp12
-rw-r--r--src/widgets/util/qcompleter.h1
-rw-r--r--src/widgets/util/qcompleter_p.h1
-rw-r--r--src/widgets/util/qflickgesture_p.h1
-rw-r--r--src/widgets/util/qscroller.h1
-rw-r--r--src/widgets/util/qscroller_p.h1
-rw-r--r--src/widgets/util/qscrollerproperties.h1
-rw-r--r--src/widgets/util/qscrollerproperties_p.h1
-rw-r--r--src/widgets/util/qsystemtrayicon.cpp29
-rw-r--r--src/widgets/util/qsystemtrayicon.h1
-rw-r--r--src/widgets/util/qsystemtrayicon_p.h1
-rw-r--r--src/widgets/util/qsystemtrayicon_win.cpp10
-rw-r--r--src/widgets/util/qsystemtrayicon_wince.cpp301
-rw-r--r--src/widgets/util/qundogroup.h1
-rw-r--r--src/widgets/util/qundostack.cpp4
-rw-r--r--src/widgets/util/qundostack.h1
-rw-r--r--src/widgets/util/qundostack_p.h1
-rw-r--r--src/widgets/util/qundoview.h1
-rw-r--r--src/widgets/util/util.pri2
-rw-r--r--src/widgets/widgets.pro1
-rw-r--r--src/widgets/widgets/qabstractbutton.h1
-rw-r--r--src/widgets/widgets/qabstractbutton_p.h1
-rw-r--r--src/widgets/widgets/qabstractscrollarea.cpp8
-rw-r--r--src/widgets/widgets/qabstractscrollarea.h1
-rw-r--r--src/widgets/widgets/qabstractscrollarea_p.h1
-rw-r--r--src/widgets/widgets/qabstractslider.h1
-rw-r--r--src/widgets/widgets/qabstractslider_p.h1
-rw-r--r--src/widgets/widgets/qabstractspinbox.h1
-rw-r--r--src/widgets/widgets/qabstractspinbox_p.h1
-rw-r--r--src/widgets/widgets/qbuttongroup.h1
-rw-r--r--src/widgets/widgets/qbuttongroup_p.h1
-rw-r--r--src/widgets/widgets/qcalendarwidget.h1
-rw-r--r--src/widgets/widgets/qcheckbox.cpp4
-rw-r--r--src/widgets/widgets/qcheckbox.h1
-rw-r--r--src/widgets/widgets/qcombobox.h1
-rw-r--r--src/widgets/widgets/qcombobox_p.h1
-rw-r--r--src/widgets/widgets/qcommandlinkbutton.cpp9
-rw-r--r--src/widgets/widgets/qcommandlinkbutton.h1
-rw-r--r--src/widgets/widgets/qdatetimeedit.h1
-rw-r--r--src/widgets/widgets/qdatetimeedit_p.h1
-rw-r--r--src/widgets/widgets/qdial.h1
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.cpp10
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.h1
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp11
-rw-r--r--src/widgets/widgets/qdockarealayout_p.h3
-rw-r--r--src/widgets/widgets/qdockwidget.cpp6
-rw-r--r--src/widgets/widgets/qdockwidget.h1
-rw-r--r--src/widgets/widgets/qdockwidget_p.h1
-rw-r--r--src/widgets/widgets/qeffects.cpp12
-rw-r--r--src/widgets/widgets/qfocusframe.h1
-rw-r--r--src/widgets/widgets/qfontcombobox.h1
-rw-r--r--src/widgets/widgets/qframe.h1
-rw-r--r--src/widgets/widgets/qframe_p.h1
-rw-r--r--src/widgets/widgets/qgroupbox.cpp4
-rw-r--r--src/widgets/widgets/qgroupbox.h1
-rw-r--r--src/widgets/widgets/qkeysequenceedit.cpp12
-rw-r--r--src/widgets/widgets/qkeysequenceedit.h1
-rw-r--r--src/widgets/widgets/qkeysequenceedit_p.h1
-rw-r--r--src/widgets/widgets/qlabel.cpp4
-rw-r--r--src/widgets/widgets/qlabel.h1
-rw-r--r--src/widgets/widgets/qlabel_p.h1
-rw-r--r--src/widgets/widgets/qlcdnumber.cpp5
-rw-r--r--src/widgets/widgets/qlcdnumber.h1
-rw-r--r--src/widgets/widgets/qlineedit.cpp14
-rw-r--r--src/widgets/widgets/qlineedit.h1
-rw-r--r--src/widgets/widgets/qlineedit_p.h2
-rw-r--r--src/widgets/widgets/qmaccocoaviewcontainer_mac.h1
-rw-r--r--src/widgets/widgets/qmaccocoaviewcontainer_mac.mm5
-rw-r--r--src/widgets/widgets/qmacnativewidget_mac.h1
-rw-r--r--src/widgets/widgets/qmacnativewidget_mac.mm5
-rw-r--r--src/widgets/widgets/qmainwindow.cpp12
-rw-r--r--src/widgets/widgets/qmainwindow.h4
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp6
-rw-r--r--src/widgets/widgets/qmainwindowlayout_p.h1
-rw-r--r--src/widgets/widgets/qmdiarea.cpp5
-rw-r--r--src/widgets/widgets/qmdiarea.h1
-rw-r--r--src/widgets/widgets/qmdiarea_p.h1
-rw-r--r--src/widgets/widgets/qmdisubwindow.cpp12
-rw-r--r--src/widgets/widgets/qmdisubwindow.h1
-rw-r--r--src/widgets/widgets/qmdisubwindow_p.h1
-rw-r--r--src/widgets/widgets/qmenu.cpp14
-rw-r--r--src/widgets/widgets/qmenu.h17
-rw-r--r--src/widgets/widgets/qmenu_mac.mm5
-rw-r--r--src/widgets/widgets/qmenu_p.h43
-rw-r--r--src/widgets/widgets/qmenu_wince.cpp666
-rw-r--r--src/widgets/widgets/qmenu_wince.rc231
-rw-r--r--src/widgets/widgets/qmenu_wince_resource_p.h89
-rw-r--r--src/widgets/widgets/qmenubar.cpp85
-rw-r--r--src/widgets/widgets/qmenubar.h12
-rw-r--r--src/widgets/widgets/qmenubar_p.h54
-rw-r--r--src/widgets/widgets/qplaintextedit.h1
-rw-r--r--src/widgets/widgets/qplaintextedit_p.h1
-rw-r--r--src/widgets/widgets/qprogressbar.h1
-rw-r--r--src/widgets/widgets/qpushbutton.cpp8
-rw-r--r--src/widgets/widgets/qpushbutton.h1
-rw-r--r--src/widgets/widgets/qpushbutton_p.h1
-rw-r--r--src/widgets/widgets/qradiobutton.cpp4
-rw-r--r--src/widgets/widgets/qradiobutton.h1
-rw-r--r--src/widgets/widgets/qrubberband.h1
-rw-r--r--src/widgets/widgets/qscrollarea.h1
-rw-r--r--src/widgets/widgets/qscrollarea_p.h2
-rw-r--r--src/widgets/widgets/qscrollbar.cpp10
-rw-r--r--src/widgets/widgets/qscrollbar.h1
-rw-r--r--src/widgets/widgets/qscrollbar_p.h1
-rw-r--r--src/widgets/widgets/qsizegrip.h1
-rw-r--r--src/widgets/widgets/qslider.cpp4
-rw-r--r--src/widgets/widgets/qslider.h1
-rw-r--r--src/widgets/widgets/qspinbox.h1
-rw-r--r--src/widgets/widgets/qsplashscreen.h1
-rw-r--r--src/widgets/widgets/qsplitter.cpp5
-rw-r--r--src/widgets/widgets/qsplitter.h1
-rw-r--r--src/widgets/widgets/qsplitter_p.h1
-rw-r--r--src/widgets/widgets/qstackedwidget.h1
-rw-r--r--src/widgets/widgets/qstatusbar.cpp3
-rw-r--r--src/widgets/widgets/qstatusbar.h1
-rw-r--r--src/widgets/widgets/qtabbar.cpp28
-rw-r--r--src/widgets/widgets/qtabbar.h6
-rw-r--r--src/widgets/widgets/qtabbar_p.h4
-rw-r--r--src/widgets/widgets/qtabwidget.h1
-rw-r--r--src/widgets/widgets/qtextbrowser.h1
-rw-r--r--src/widgets/widgets/qtextedit.h1
-rw-r--r--src/widgets/widgets/qtextedit_p.h1
-rw-r--r--src/widgets/widgets/qtoolbar.cpp15
-rw-r--r--src/widgets/widgets/qtoolbar.h7
-rw-r--r--src/widgets/widgets/qtoolbar_p.h1
-rw-r--r--src/widgets/widgets/qtoolbararealayout_p.h1
-rw-r--r--src/widgets/widgets/qtoolbarextension_p.h1
-rw-r--r--src/widgets/widgets/qtoolbarlayout_p.h1
-rw-r--r--src/widgets/widgets/qtoolbarseparator_p.h1
-rw-r--r--src/widgets/widgets/qtoolbox.h1
-rw-r--r--src/widgets/widgets/qtoolbutton.h1
-rw-r--r--src/widgets/widgets/qwidgetanimator_p.h1
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp2
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol_p.h2
-rw-r--r--src/widgets/widgets/qwidgetresizehandler_p.h1
-rw-r--r--src/widgets/widgets/qwidgettextcontrol_p.h1
-rw-r--r--src/widgets/widgets/qwidgettextcontrol_p_p.h1
-rw-r--r--src/widgets/widgets/widgets.pri16
-rw-r--r--src/winmain/qtmain_win.cpp59
-rw-r--r--src/winmain/winmain.pro4
1668 files changed, 29893 insertions, 27040 deletions
diff --git a/src/3rdparty/android/LICENSE b/src/3rdparty/android/LICENSE
new file mode 100644
index 0000000000..c026b6b79a
--- /dev/null
+++ b/src/3rdparty/android/LICENSE
@@ -0,0 +1,11 @@
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
diff --git a/src/3rdparty/android/qt_attribution.json b/src/3rdparty/android/qt_attribution.json
new file mode 100644
index 0000000000..c1f89fd8bd
--- /dev/null
+++ b/src/3rdparty/android/qt_attribution.json
@@ -0,0 +1,11 @@
+{
+ "Id": "android-native-style",
+ "Name": "Native Style for Android",
+ "QDocModule": "qtgui",
+ "QtUsage": "Used in Android platform plugin.",
+
+ "License": "Apache License 2.0",
+ "LicenseId": "Apache-2.0",
+ "LicenseFile": "LICENSE",
+ "Copyright": "Copyright (C) 2005 The Android Open Source Project"
+}
diff --git a/src/3rdparty/angle/SYSTEMINFO_LICENSE b/src/3rdparty/angle/SYSTEMINFO_LICENSE
new file mode 100644
index 0000000000..c12444e3bc
--- /dev/null
+++ b/src/3rdparty/angle/SYSTEMINFO_LICENSE
@@ -0,0 +1,22 @@
+Copyright (C) 2009 Apple Inc. All Rights Reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/src/3rdparty/angle/TRACEEVENT_LICENSE b/src/3rdparty/angle/TRACEEVENT_LICENSE
new file mode 100644
index 0000000000..34d6cd9268
--- /dev/null
+++ b/src/3rdparty/angle/TRACEEVENT_LICENSE
@@ -0,0 +1,27 @@
+Copyright 2013 The Chromium Authors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+ * Neither the name of Google Inc. nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/src/3rdparty/angle/qt_attribution.json b/src/3rdparty/angle/qt_attribution.json
new file mode 100644
index 0000000000..230f30940b
--- /dev/null
+++ b/src/3rdparty/angle/qt_attribution.json
@@ -0,0 +1,61 @@
+[
+ {
+ "Id": "angle",
+ "Name": "ANGLE Library",
+ "QDocModule": "qtgui",
+ "QtUsage": "Used on Windows to implement OpenGL ES on top of DirectX. Configure with -no-opengl, or -opengl desktop to exclude.",
+
+ "License": "BSD 3-clause \"New\" or \"Revised\" License",
+ "LicenseId": "BSD-3-Clause",
+ "LicenseFile": "LICENSE",
+ "Copyright": "Copyright (C) 2002-2013 The ANGLE Project Authors"
+ },
+ {
+ "Id": "angle-arrayboundsclamper",
+ "Name": "ANGLE Array Bounds Clamper for WebKit",
+ "QDocModule": "qtgui",
+ "QtUsage": "Used on Windows to implement OpenGL ES on top of DirectX. Configure with -no-opengl, or -opengl desktop to exclude.",
+
+ "Path": "src/third_party/compiler",
+ "Description": "Implements clamping of array indexing expressions during shader translation.",
+ "License": "BSD 2-clause \"Simplified\" License",
+ "LicenseId": "BSD-2-Clause",
+ "LicenseFile": "src/third_party/compiler/LICENSE",
+ "Copyright": "Copyright (C) 2012 Apple Inc."
+ },
+ {
+ "Id": "angle-murmurhash",
+ "Name": "Murmurhash (as part of ANGLE)",
+ "QDocModule": "qtgui",
+ "QtUsage": "Used on Windows to implement OpenGL ES on top of DirectX. Configure with -no-opengl, or -opengl desktop to exclude.",
+
+ "Path": "src/third_party/murmurhash",
+ "License": "Public Domain",
+ "LicenseId": "NONE",
+ "Copyright": "MurmurHash3 was written by Austin Appleby, and is placed in the public domain. The author hereby disclaims copyright to this source code."
+ },
+ {
+ "Id": "angle-systeminfo",
+ "Name": "Systeminfo (as part of ANGLE)",
+ "QDocModule": "qtgui",
+ "QtUsage": "Used on Windows to implement OpenGL ES on top of DirectX. Configure with -no-opengl, or -opengl desktop to exclude.",
+
+ "Path": "src/third_party/systeminfo",
+ "License": "BSD 2-clause \"Simplified\" License",
+ "LicenseId": "BSD-2-Clause",
+ "LicenseFile": "SYSTEMINFO_LICENSE",
+ "Copyright": "Copyright (C) 2009 Apple Inc. All Rights Reserved."
+ },
+ {
+ "Id": "angle-trace_event",
+ "Name": "trace_event (as part of ANGLE)",
+ "QDocModule": "qtgui",
+ "QtUsage": "Used on Windows to implement OpenGL ES on top of DirectX. Configure with -no-opengl, or -opengl desktop to exclude.",
+
+ "Path": "src/third_party/trace_event",
+ "License": "BSD 3-clause \"New\" or \"Revised\" License",
+ "LicenseId": "BSD-3-Clause",
+ "LicenseFile": "TRACEEVENT_LICENSE",
+ "Copyright": "Copyright (c) 2013 The Chromium Authors."
+ }
+]
diff --git a/src/3rdparty/atspi2/LICENSE b/src/3rdparty/atspi2/LICENSE
new file mode 100644
index 0000000000..dc5f1b170d
--- /dev/null
+++ b/src/3rdparty/atspi2/LICENSE
@@ -0,0 +1,482 @@
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the library GPL. It is
+ numbered 2 because it goes with version 2 of the ordinary GPL.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Library General Public License, applies to some
+specially designated Free Software Foundation software, and to any
+other libraries whose authors decide to use it. You can use it for
+your libraries, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if
+you distribute copies of the library, or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link a program with the library, you must provide
+complete object files to the recipients so that they can relink them
+with the library, after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ Our method of protecting your rights has two steps: (1) copyright
+the library, and (2) offer you this license which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ Also, for each distributor's protection, we want to make certain
+that everyone understands that there is no warranty for this free
+library. If the library is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original
+version, so that any problems introduced by others will not reflect on
+the original authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that companies distributing free
+software will individually obtain patent licenses, thus in effect
+transforming the program into proprietary software. To prevent this,
+we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+ Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License, which was designed for utility programs. This
+license, the GNU Library General Public License, applies to certain
+designated libraries. This license is quite different from the ordinary
+one; be sure to read it in full, and don't assume that anything in it is
+the same as in the ordinary license.
+
+ The reason we have a separate public license for some libraries is that
+they blur the distinction we usually make between modifying or adding to a
+program and simply using it. Linking a program with a library, without
+changing the library, is in some sense simply using the library, and is
+analogous to running a utility program or application program. However, in
+a textual and legal sense, the linked executable is a combined work, a
+derivative of the original library, and the ordinary General Public License
+treats it as such.
+
+ Because of this blurred distinction, using the ordinary General
+Public License for libraries did not effectively promote software
+sharing, because most developers did not use the libraries. We
+concluded that weaker conditions might promote sharing better.
+
+ However, unrestricted linking of non-free programs would deprive the
+users of those programs of all benefit from the free status of the
+libraries themselves. This Library General Public License is intended to
+permit developers of non-free programs to use free libraries, while
+preserving your freedom as a user of such programs to change the free
+libraries that are incorporated in them. (We have not seen how to achieve
+this as regards changes in header files, but we have achieved it as regards
+changes in the actual functions of the Library.) The hope is that this
+will lead to faster development of free libraries.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, while the latter only
+works together with the library.
+
+ Note that it is possible for a library to be covered by the ordinary
+General Public License rather than by this special one.
+
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library which
+contains a notice placed by the copyright holder or other authorized
+party saying it may be distributed under the terms of this Library
+General Public License (also called "this License"). Each licensee is
+addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also compile or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ c) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ d) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the source code distributed need not include anything that is normally
+distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Library General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
diff --git a/src/3rdparty/atspi2/qt_attribution.json b/src/3rdparty/atspi2/qt_attribution.json
new file mode 100644
index 0000000000..ed2ef85158
--- /dev/null
+++ b/src/3rdparty/atspi2/qt_attribution.json
@@ -0,0 +1,11 @@
+{
+ "Id": "atspi2",
+ "Name": "at-spi2 (Assistive Technology Service Provider Interface)",
+ "QDocModule": "qtgui",
+ "QtUsage": "Optionally ysed on Linux for accessibility. Configure without dbus (QT_CONFIG-=accessibility-atspi-bridge) to avoid.",
+
+ "License": "GNU Library General Public License v2 or later",
+ "LicenseId": "LGPL-2.0+",
+ "LicenseFile": "LICENSE",
+ "Copyright": "Copyright 2010, 2011 Novell, Inc., Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany."
+}
diff --git a/src/3rdparty/double-conversion/include/double-conversion/utils.h b/src/3rdparty/double-conversion/include/double-conversion/utils.h
index a89b284eda..20bfd36c84 100644
--- a/src/3rdparty/double-conversion/include/double-conversion/utils.h
+++ b/src/3rdparty/double-conversion/include/double-conversion/utils.h
@@ -74,8 +74,6 @@
#else
#undef DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS
#endif // _WIN32
-#elif defined(WINCE) || defined(_WIN32_WCE)
-#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
#elif defined(__ghs)
// Green Hills toolchain uses a 64bit wide floating point stack
#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
diff --git a/src/3rdparty/double-conversion/qt_attribution.json b/src/3rdparty/double-conversion/qt_attribution.json
new file mode 100644
index 0000000000..92118ac779
--- /dev/null
+++ b/src/3rdparty/double-conversion/qt_attribution.json
@@ -0,0 +1,14 @@
+{
+ "Id": "doubleconversion",
+ "Name": "Efficient Binary-Decimal and Decimal-Binary Conversion Routines for IEEE Doubles",
+ "QDocModule": "qtcore",
+ "QtUsage": "Used in Qt Core. Configure with -system-doubleconversion or -no-doubleconversion to avoid.",
+
+ "Homepage": "https://github.com/google/double-conversion",
+ "Version": "2.0.1",
+ "DownloadLocation": "https://github.com/google/double-conversion/commit/2fb03de56faa32bbba5e02222528e7b760f71d77",
+ "License": "BSD 3-clause \"New\" or \"Revised\" License",
+ "LicenseId": "BSD-3-Clause",
+ "LicenseFile": "LICENSE",
+ "Copyright": "Copyright 2006-2012, the V8 project authors"
+}
diff --git a/src/3rdparty/easing/legal.qdoc b/src/3rdparty/easing/LICENSE
index 466ff1561b..5dc85c4712 100644
--- a/src/3rdparty/easing/legal.qdoc
+++ b/src/3rdparty/easing/LICENSE
@@ -1,10 +1,3 @@
-/*!
-\page legal-easing.html
-\title Easing Equations by Robert Penner
-\ingroup licensing
-
-\legalese
-\code
Copyright (c) 2001 Robert Penner
All rights reserved.
@@ -30,6 +23,3 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-\endcode
-\endlegalese
-*/
diff --git a/src/3rdparty/easing/qt_attribution.json b/src/3rdparty/easing/qt_attribution.json
new file mode 100644
index 0000000000..b6240c61c8
--- /dev/null
+++ b/src/3rdparty/easing/qt_attribution.json
@@ -0,0 +1,11 @@
+{
+ "Id": "easing",
+ "Name": "Easing Equations by Robert Penner",
+ "QDocModule": "qtcore",
+ "QtUsage": "Used in Qt Core (QEasingCurve).",
+
+ "License": "BSD 3-clause \"New\" or \"Revised\" License",
+ "LicenseId": "BSD-3-Clause",
+ "LicenseFile": "LICENSE",
+ "Copyright": "Copyright (c) 2001 Robert Penner"
+}
diff --git a/src/3rdparty/forkfd/LICENSE b/src/3rdparty/forkfd/LICENSE
new file mode 100644
index 0000000000..351ebf705d
--- /dev/null
+++ b/src/3rdparty/forkfd/LICENSE
@@ -0,0 +1,19 @@
+Copyright (C) 2016 Intel Corporation.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/src/3rdparty/forkfd/qt_attribution.json b/src/3rdparty/forkfd/qt_attribution.json
new file mode 100644
index 0000000000..89f25f4870
--- /dev/null
+++ b/src/3rdparty/forkfd/qt_attribution.json
@@ -0,0 +1,12 @@
+{
+ "Id": "forkfd",
+ "Name": "forkfd",
+ "QDocModule": "qtcore",
+ "QtUsage": "Used on most Unix platforms in Qt Core.",
+
+ "License": "MIT License",
+ "LicenseId": "MIT",
+ "LicenseFile": "LICENSE",
+ "Copyright": "Copyright (C) 2013-2016 Intel Corporation
+Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com"
+}
diff --git a/src/3rdparty/freebsd/LICENSE b/src/3rdparty/freebsd/LICENSE
new file mode 100644
index 0000000000..5bb30318eb
--- /dev/null
+++ b/src/3rdparty/freebsd/LICENSE
@@ -0,0 +1,31 @@
+Copyright (c) 1992, 1993
+ The Regents of the University of California. All rights reserved.
+
+Copyright (c) 2011 The FreeBSD Foundation
+All rights reserved.
+Portions of this software were developed by David Chisnall
+under sponsorship from the FreeBSD Foundation.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. Neither the name of the University nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
diff --git a/src/3rdparty/freebsd/qt_attribution.json b/src/3rdparty/freebsd/qt_attribution.json
new file mode 100644
index 0000000000..40c337cc67
--- /dev/null
+++ b/src/3rdparty/freebsd/qt_attribution.json
@@ -0,0 +1,17 @@
+{
+ "Id": "freebsd",
+ "Name": "FreeBSD strtoll and strtoull",
+ "QDocModule": "qtcore",
+ "QtUsage": "Used in Qt Core.",
+
+ "License": "BSD 3-clause \"New\" or \"Revised\" License",
+ "LicenseId": "BSD-3-Clause",
+ "LicenseFile": "LICENSE",
+ "Copyright": "Copyright (c) 1992, 1993
+ The Regents of the University of California. All rights reserved.
+
+Copyright (c) 2011 The FreeBSD Foundation
+All rights reserved.
+Portions of this software were developed by David Chisnall
+under sponsorship from the FreeBSD Foundation."
+}
diff --git a/src/3rdparty/freetype/qt_attribution.json b/src/3rdparty/freetype/qt_attribution.json
new file mode 100644
index 0000000000..6c11f1b617
--- /dev/null
+++ b/src/3rdparty/freetype/qt_attribution.json
@@ -0,0 +1,13 @@
+{
+ "Id": "freetype",
+ "Name": "Freetype 2",
+ "QDocModule": "qtgui",
+ "QtUsage": "Optionally used in Qt GUI and platform plugins. Configure with -no-freetype, or -system-freetype to avoid.",
+
+ "Description": "FreeType is a freely available software library to render fonts.",
+ "Homepage": "http://www.freetype.org",
+ "License": "Freetype Project License or GNU General Public License v2.0 only",
+ "LicenseId": "FTL or GPL-2.0",
+ "LicenseFile": "docs/LICENSE.TXT",
+ "Copyright": "Copyright 2006-2015 by David Turner, Robert Wilhelm, and Werner Lemberg."
+}
diff --git a/src/3rdparty/freetype_dependency.pri b/src/3rdparty/freetype_dependency.pri
index 39280deb2f..7513e40bfd 100644
--- a/src/3rdparty/freetype_dependency.pri
+++ b/src/3rdparty/freetype_dependency.pri
@@ -1,7 +1,7 @@
-contains(QT_CONFIG, freetype) {
- INCLUDEPATH += $$PWD/freetype/include
- LIBS_PRIVATE += -L$$QT_BUILD_TREE/lib -lqtfreetype$$qtPlatformTargetSuffix()
-} else:contains(QT_CONFIG, system-freetype) {
+contains(QT_CONFIG, system-freetype) {
# pull in the proper freetype2 include directory
include($$QT_SOURCE_TREE/config.tests/unix/freetype/freetype.pri)
+} else: contains(QT_CONFIG, freetype) {
+ INCLUDEPATH += $$PWD/freetype/include
+ LIBS_PRIVATE += -L$$QT_BUILD_TREE/lib -lqtfreetype$$qtPlatformTargetSuffix()
}
diff --git a/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro b/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro
index 4325fd153b..4fd0823332 100644
--- a/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro
+++ b/src/3rdparty/harfbuzz-ng/harfbuzz-ng.pro
@@ -146,8 +146,8 @@ contains(SHAPERS, coretext) {
HEADERS += \
$$PWD/src/hb-coretext.h
- ios: \
- # On iOS CoreText and CoreGraphics are stand-alone frameworks
+ uikit: \
+ # On iOS/tvOS CoreText and CoreGraphics are stand-alone frameworks
LIBS_PRIVATE += -framework CoreText -framework CoreGraphics
else: \
# On Mac OS they are part of the ApplicationServices umbrella framework,
diff --git a/src/3rdparty/harfbuzz-ng/qt_attribution.json b/src/3rdparty/harfbuzz-ng/qt_attribution.json
new file mode 100644
index 0000000000..4d3eb79150
--- /dev/null
+++ b/src/3rdparty/harfbuzz-ng/qt_attribution.json
@@ -0,0 +1,25 @@
+{
+ "Id": "harfbuzz-ng",
+ "Name": "HarfBuzz-NG",
+ "QDocModule": "qtgui",
+ "QtUsage": "Optionally used in Qt GUI. Configure with -system-harfbuzz or -qt-harfbuzz to avoid.",
+
+ "Description": "HarfBuzz is an OpenType text shaping engine.",
+ "Homepage": "http://harfbuzz.org",
+
+ "License": "MIT License",
+ "LicenseId": "MIT",
+ "LicenseFile": "COPYING",
+ "Copyright": "Copyright © 2010,2011,2012 Google, Inc.
+Copyright © 2012 Mozilla Foundation
+Copyright © 2011 Codethink Limited
+Copyright © 2008,2010 Nokia Corporation and/or its subsidiary(-ies)
+Copyright © 2009 Keith Stribley
+Copyright © 2009 Martin Hosken and SIL International
+Copyright © 2007 Chris Wilson
+Copyright © 2006 Behdad Esfahbod
+Copyright © 2005 David Turner
+Copyright © 2004,2007,2008,2009,2010 Red Hat, Inc.
+Copyright © 1998-2004 David Turner and Werner Lemberg
+"
+}
diff --git a/src/3rdparty/harfbuzz/qt_attribution.json b/src/3rdparty/harfbuzz/qt_attribution.json
new file mode 100644
index 0000000000..2c2b31e4a9
--- /dev/null
+++ b/src/3rdparty/harfbuzz/qt_attribution.json
@@ -0,0 +1,17 @@
+{
+ "Id": "harfbuzz",
+ "Name": "HarfBuzz",
+ "QDocModule": "qtgui",
+ "QtUsage": "Optionally used in Qt GUI. Configure with -system-harfbuzz or -qt-harfbuzz to avoid.",
+
+ "License": "MIT License",
+ "LicenseId": "MIT",
+ "LicenseFile": "COPYING",
+ "Copyright": "Copyright (c) 1992, 1993
+ The Regents of the University of California. All rights reserved.
+
+Copyright (c) 2011 The FreeBSD Foundation
+All rights reserved.
+Portions of this software were developed by David Chisnall
+under sponsorship from the FreeBSD Foundation."
+}
diff --git a/src/3rdparty/harfbuzz_dependency.pri b/src/3rdparty/harfbuzz_dependency.pri
index 74433688f6..36abbfbe35 100644
--- a/src/3rdparty/harfbuzz_dependency.pri
+++ b/src/3rdparty/harfbuzz_dependency.pri
@@ -1,6 +1,6 @@
-contains(QT_CONFIG, harfbuzz) {
+contains(QT_CONFIG, system-harfbuzz) {
+ LIBS_PRIVATE += -lharfbuzz
+} else: contains(QT_CONFIG, harfbuzz) {
INCLUDEPATH += $$PWD/harfbuzz-ng/include
LIBS_PRIVATE += -L$$QT_BUILD_TREE/lib -lqtharfbuzzng$$qtPlatformTargetSuffix()
-} else:contains(QT_CONFIG, system-harfbuzz) {
- LIBS_PRIVATE += -lharfbuzz
}
diff --git a/src/3rdparty/iaccessible2/LICENSE b/src/3rdparty/iaccessible2/LICENSE
new file mode 100644
index 0000000000..688d9d3197
--- /dev/null
+++ b/src/3rdparty/iaccessible2/LICENSE
@@ -0,0 +1,38 @@
+Copyright (c) 2013 Linux Foundation
+All rights reserved.
+
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials
+ provided with the distribution.
+
+ 3. Neither the name of the Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products
+ derived from this software without specific prior written
+ permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+This BSD License conforms to the Open Source Initiative "Simplified
+BSD License" as published at:
+http://www.opensource.org/licenses/bsd-license.php
diff --git a/src/3rdparty/iaccessible2/qt_attribution.json b/src/3rdparty/iaccessible2/qt_attribution.json
new file mode 100644
index 0000000000..545ffe4d63
--- /dev/null
+++ b/src/3rdparty/iaccessible2/qt_attribution.json
@@ -0,0 +1,17 @@
+{
+ "Id": "iaccessible2",
+ "Name": "IAccessible2 IDL Specification",
+ "QDocModule": "qtgui",
+ "QtUsage": "Optionally used in the Windows platform plugin. Configure with -no-accessibility to avoid.",
+
+ "Description": "IAccessible2 is a new accessibility API which complements Microsoft's earlier work on MSAA",
+ "Homepage": "http://www.linuxfoundation.org/collaborate/workgroups/accessibility/iaccessible2",
+ "License": "BSD 3-clause \"New\" or \"Revised\" License",
+ "LicenseId": "BSD-3-Clause",
+ "LicenseFile": "LICENSE",
+ "Copyright": "Copyright (c) 2000, 2006 Sun Microsystems, Inc.
+Copyright (c) 2006 IBM Corporation
+Copyright (c) 2007, 2010, 2012, 2013 Linux Foundation
+
+IAccessible2 is a trademark of the Linux Foundation. The IAccessible2 mark may be used in accordance with the Linux Foundation Trademark Policy to indicate compliance with the IAccessible2 specification."
+}
diff --git a/src/3rdparty/libjpeg/LICENSE b/src/3rdparty/libjpeg/LICENSE
new file mode 100644
index 0000000000..797a6d5668
--- /dev/null
+++ b/src/3rdparty/libjpeg/LICENSE
@@ -0,0 +1,50 @@
+from qtbase/src/3rdparty/libjpeg/README:
+
+LEGAL ISSUES
+============
+
+In plain English:
+
+1. We don't promise that this software works. (But if you find any bugs,
+ please let us know!)
+2. You can use this software for whatever you want. You don't have to pay us.
+3. You may not pretend that you wrote this software. If you use it in a
+ program, you must acknowledge somewhere in your documentation that
+ you've used the IJG code.
+
+In legalese:
+
+The authors make NO WARRANTY or representation, either express or implied,
+with respect to this software, its quality, accuracy, merchantability, or
+fitness for a particular purpose. This software is provided "AS IS", and you,
+its user, assume the entire risk as to its quality and accuracy.
+
+This software is copyright (C) 1991-1998, Thomas G. Lane.
+All Rights Reserved except as specified below.
+
+Permission is hereby granted to use, copy, modify, and distribute this
+software (or portions thereof) for any purpose, without fee, subject to these
+conditions:
+(1) If any part of the source code for this software is distributed, then this
+README file must be included, with this copyright and no-warranty notice
+unaltered; and any additions, deletions, or changes to the original files
+must be clearly indicated in accompanying documentation.
+(2) If only executable code is distributed, then the accompanying
+documentation must state that "this software is based in part on the work of
+the Independent JPEG Group".
+(3) Permission for use of this software is granted only if the user accepts
+full responsibility for any undesirable consequences; the authors accept
+NO LIABILITY for damages of any kind.
+
+These conditions apply to any software derived from or based on the IJG code,
+not just to the unmodified library. If you use our work, you ought to
+acknowledge us.
+
+Permission is NOT granted for the use of any IJG author's name or company name
+in advertising or publicity relating to this software or products derived from
+it. This software may be referred to only as "the Independent JPEG Group's
+software".
+
+We specifically permit and encourage the use of this software as the basis of
+commercial products, provided that all warranty or liability claims are
+assumed by the product vendor.
diff --git a/src/3rdparty/libjpeg/qt_attribution.json b/src/3rdparty/libjpeg/qt_attribution.json
new file mode 100644
index 0000000000..ee5c094a0f
--- /dev/null
+++ b/src/3rdparty/libjpeg/qt_attribution.json
@@ -0,0 +1,13 @@
+{
+ "Id": "libjpeg",
+ "Name": "LibJPEG",
+ "QDocModule": "qtgui",
+ "QtUsage": "Used in the QJPEG image plugin. Configure with -no-jpeg to avoid.",
+
+ "Description": "The Independent JPEG Group's JPEG software",
+ "Homepage": "http://www.ijg.org/",
+ "License": "Independent JPEG Group License",
+ "LicenseId": "IJG",
+ "LicenseFile": "LICENSE",
+ "Copyright": "Copyright (C) 1991-2011, Thomas G. Lane, Guido Vollbeding."
+}
diff --git a/src/3rdparty/libpng/qt_attribution.json b/src/3rdparty/libpng/qt_attribution.json
new file mode 100644
index 0000000000..93e73243af
--- /dev/null
+++ b/src/3rdparty/libpng/qt_attribution.json
@@ -0,0 +1,15 @@
+{
+ "Id": "libpng",
+ "Name": "LibPNG",
+ "QDocModule": "qtgui",
+ "QtUsage": "Used in the qpng image plugin. Configure with -system-png or -no-png to avoid.",
+
+ "Description": "libpng is the official PNG reference library.",
+ "Homepage": "http://www.libpng.org/pub/png/libpng.html",
+ "License": "libpng License",
+ "LicenseId": "Libpng",
+ "LicenseFile": "LICENSE",
+ "Copyright": "Copyright (c) 1998-2015 Glenn Randers-Pehrson
+Copyright (c) 1996-1997 Andreas Dilger
+Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."
+}
diff --git a/src/3rdparty/md4/qt_attribution.json b/src/3rdparty/md4/qt_attribution.json
new file mode 100644
index 0000000000..f1bca24660
--- /dev/null
+++ b/src/3rdparty/md4/qt_attribution.json
@@ -0,0 +1,10 @@
+{
+ "Id": "md4",
+ "Name": "MD4",
+ "QDocModule": "qtcore",
+ "QtUsage": "Used in Qt Core (QCryptographicHash). Configure with -DQT_CRYPTOGRAPHICHASH_ONLY_SHA1 to avoid.",
+
+ "Description": "An OpenSSL-compatible implementation of the RSA Data Security, Inc. MD4 Message-Digest Algorithm.",
+ "License": "Public Domain",
+ "Copyright": "Written by Alexander Peslyak - better known as Solar Designer <solar@openwall.com> - in 2001, and placed in the public domain. There's absolutely no warranty."
+}
diff --git a/src/3rdparty/md5/qt_attribution.json b/src/3rdparty/md5/qt_attribution.json
new file mode 100644
index 0000000000..52b613cf6c
--- /dev/null
+++ b/src/3rdparty/md5/qt_attribution.json
@@ -0,0 +1,11 @@
+{
+ "Id": "md5",
+ "Name": "MD5",
+ "QDocModule": "qtcore",
+ "QtUsage": "Used in Qt Core (QCryptographicHash). Configure with -DQT_CRYPTOGRAPHICHASH_ONLY_SHA1 to avoid.",
+
+ "Description": "MD5 message-digest algorithm.",
+ "License": "Public Domain",
+ "Copyright": "Written by Colin Plumb in 1993, no copyright is claimed.
+Ian Jackson <ian@chiark.greenend.org.uk>."
+}
diff --git a/src/3rdparty/pcre/pcre.pro b/src/3rdparty/pcre/pcre.pro
index 53405e0e46..fad82b80b1 100644
--- a/src/3rdparty/pcre/pcre.pro
+++ b/src/3rdparty/pcre/pcre.pro
@@ -11,7 +11,7 @@ DEFINES += HAVE_CONFIG_H
# platform/compiler specific definitions
win32: DEFINES += PCRE_STATIC
-ios|qnx|winrt: DEFINES += PCRE_DISABLE_JIT
+uikit|qnx|winrt: DEFINES += PCRE_DISABLE_JIT
SOURCES += \
$$PWD/pcre16_byte_order.c \
diff --git a/src/3rdparty/pcre/qt_attribution.json b/src/3rdparty/pcre/qt_attribution.json
new file mode 100644
index 0000000000..ec8832486b
--- /dev/null
+++ b/src/3rdparty/pcre/qt_attribution.json
@@ -0,0 +1,15 @@
+{
+ "Id": "pcre",
+ "Name": "PCRE",
+ "QDocModule": "qtcore",
+ "QtUsage": "Optionally used in Qt Core (QRegularExpression). Configure with -system-pcre or -no-pcre to avoid.",
+
+ "Description": "The PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5.",
+ "Homepage": "http://www.pcre.org/",
+ "License": "BSD 3-clause \"New\" or \"Revised\" License",
+ "LicenseId": "BSD-3-Clause",
+ "LicenseFile": "LICENCE",
+ "Copyright": "Copyright (c) 1997-2015 University of Cambridge
+Copyright (c) 2010-2015 Zoltan Herczeg
+Copyright (c) 2007-2012, Google Inc."
+}
diff --git a/src/3rdparty/pixman/LICENSE b/src/3rdparty/pixman/LICENSE
new file mode 100644
index 0000000000..3cb51484f1
--- /dev/null
+++ b/src/3rdparty/pixman/LICENSE
@@ -0,0 +1,20 @@
+Copyright © 2009 Nokia Corporation
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/src/3rdparty/pixman/qt_attribution.json b/src/3rdparty/pixman/qt_attribution.json
new file mode 100644
index 0000000000..607bda754d
--- /dev/null
+++ b/src/3rdparty/pixman/qt_attribution.json
@@ -0,0 +1,13 @@
+{
+ "Id": "pixman",
+ "Name": "Pixman",
+ "QDocModule": "qtgui",
+ "QtUsage": "Used in Qt GUI on ARM NEON.",
+
+ "Description": "pixman is a library that provides low-level pixel manipulation features such as image compositing and trapezoid rasterization.",
+ "Homepage": "http://www.pixman.org/",
+ "License": "MIT License",
+ "LicenseFile": "LICENSE",
+ "LicenseId": "MIT",
+ "Copyright": "Copyright © 2009 Nokia Corporation"
+}
diff --git a/src/3rdparty/rfc6234/LICENSE b/src/3rdparty/rfc6234/LICENSE
new file mode 100644
index 0000000000..7075960ee2
--- /dev/null
+++ b/src/3rdparty/rfc6234/LICENSE
@@ -0,0 +1,34 @@
+Copyright (c) 2011 IETF Trust and the persons identified as
+authors of the code. All rights reserved.
+
+Redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the following
+conditions are met:
+
+- Redistributions of source code must retain the above
+ copyright notice, this list of conditions and
+ the following disclaimer.
+
+- Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+- Neither the name of Internet Society, IETF or IETF Trust, nor
+ the names of specific contributors, may be used to endorse or
+ promote products derived from this software without specific
+ prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/src/3rdparty/rfc6234/qt_attribution.json b/src/3rdparty/rfc6234/qt_attribution.json
new file mode 100644
index 0000000000..9fc427b4a6
--- /dev/null
+++ b/src/3rdparty/rfc6234/qt_attribution.json
@@ -0,0 +1,12 @@
+{
+ "Id": "rfc6234",
+ "Name": "Secure Hash Algorithms SHA-384 and SHA-512",
+ "QDocModule": "qtcore",
+ "QtUsage": "Used in Qt Core (QCryptographicHash and QMessageAuthenticationCode)",
+
+ "Description": "Implements the Secure Hash Algorithms SHA 384 and SHA-521",
+ "License": "BSD 3-clause \"New\" or \"Revised\" License",
+ "LicenseFile": "LICENSE",
+ "LicenseId": "BSD-3-Clause",
+ "Copyright": "Copyright (c) 2011 IETF Trust and the persons identified as authors of the code."
+}
diff --git a/src/3rdparty/sha1/qt_attribution.json b/src/3rdparty/sha1/qt_attribution.json
new file mode 100644
index 0000000000..707c239f8d
--- /dev/null
+++ b/src/3rdparty/sha1/qt_attribution.json
@@ -0,0 +1,12 @@
+{
+ "Id": "sha1",
+ "Name": "Secure Hash Algorithm SHA-1",
+ "QDocModule": "qtcore",
+ "QtUsage": "Used in Qt Core (QCryptographicHash).",
+
+ "Description": "Implements the Secure Hash Algorithms SHA 1",
+ "Homepage": "http://www.dominik-reichl.de/projects/csha1/",
+ "License": "Public Domain",
+ "Copyright": "Copyright (C) Dominik Reichl <dominik.reichl@t-online.de>
+Copyright (C) 2016 The Qt Company Ltd"
+}
diff --git a/src/3rdparty/sha3/BRG_ENDIAN_LICENSE b/src/3rdparty/sha3/BRG_ENDIAN_LICENSE
new file mode 100644
index 0000000000..0a4fdcbc3b
--- /dev/null
+++ b/src/3rdparty/sha3/BRG_ENDIAN_LICENSE
@@ -0,0 +1,21 @@
+Copyright (c) 1998-2008, Brian Gladman, Worcester, UK. All rights reserved.
+
+LICENSE TERMS
+
+The redistribution and use of this software (with or without changes)
+is allowed without the payment of fees or royalties provided that:
+
+ 1. source code distributions include the above copyright notice, this
+ list of conditions and the following disclaimer;
+
+ 2. binary distributions include the above copyright notice, this list
+ of conditions and the following disclaimer in their documentation;
+
+ 3. the name of the copyright holder is not used to endorse products
+ built using this software without specific written permission.
+
+DISCLAIMER
+
+This software is provided 'as is' with no explicit or implied warranties
+in respect of its properties, including, but not limited to, correctness
+and/or fitness for purpose.
diff --git a/src/3rdparty/sha3/CC0_LICENSE b/src/3rdparty/sha3/CC0_LICENSE
new file mode 100644
index 0000000000..cff12c3d88
--- /dev/null
+++ b/src/3rdparty/sha3/CC0_LICENSE
@@ -0,0 +1,99 @@
+CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF
+THIS DOCUMENT DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
+INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE USE OF THIS
+DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES
+RESULTING FROM THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED HEREUNDER.
+
+Statement of Purpose
+
+The laws of most jurisdictions throughout the world automatically confer exclusive Copyright and
+Related Rights (defined below) upon the creator and subsequent owner(s) (each and all, an "owner")
+of an original work of authorship and/or a database (each, a "Work").
+
+Certain owners wish to permanently relinquish those rights to a Work for the purpose of contributing
+to a commons of creative, cultural and scientific works ("Commons") that the public can reliably and
+without fear of later claims of infringement build upon, modify, incorporate in other works, reuse
+and redistribute as freely as possible in any form whatsoever and for any purposes, including
+without limitation commercial purposes. These owners may contribute to the Commons to promote the
+ideal of a free culture and the further production of creative, cultural and scientific works, or to
+gain reputation or greater distribution for their Work in part through the use and efforts of
+others.
+
+For these and/or other purposes and motivations, and without any expectation of additional
+consideration or compensation, the person associating CC0 with a Work (the "Affirmer"), to the
+extent that he or she is an owner of Copyright and Related Rights in the Work, voluntarily elects to
+apply CC0 to the Work and publicly distribute the Work under its terms, with knowledge of his or her
+Copyright and Related Rights in the Work and the meaning and intended legal effect of CC0 on those
+rights.
+
+1. Copyright and Related Rights. A Work made available under CC0 may be protected by copyright and
+ related or neighboring rights ("Copyright and Related Rights"). Copyright and Related Rights
+ include, but are not limited to, the following:
+
+ i. the right to reproduce, adapt, distribute, perform, display, communicate, and translate a Work;
+
+ ii. moral rights retained by the original author(s) and/or performer(s);
+
+ iii. publicity and privacy rights pertaining to a person's image or likeness depicted in a Work;
+
+ iv. rights protecting against unfair competition in regards to a Work, subject to the limitations
+ in paragraph 4(a), below;
+
+ v. rights protecting the extraction, dissemination, use and reuse of data in a Work;
+
+ vi. database rights (such as those arising under Directive 96/9/EC of the European Parliament and
+ of the Council of 11 March 1996 on the legal protection of databases, and under any national
+ implementation thereof, including any amended or successor version of such directive); and
+
+ vii. other similar, equivalent or corresponding rights throughout the world based on applicable
+ law or treaty, and any national implementations thereof.
+
+2. Waiver. To the greatest extent permitted by, but not in contravention of, applicable law,
+ Affirmer hereby overtly, fully, permanently, irrevocably and unconditionally waives, abandons,
+ and surrenders all of Affirmer's Copyright and Related Rights and associated claims and causes of
+ action, whether now known or unknown (including existing as well as future claims and causes of
+ action), in the Work (i) in all territories worldwide, (ii) for the maximum duration provided by
+ applicable law or treaty (including future time extensions), (iii) in any current or future
+ medium and for any number of copies, and (iv) for any purpose whatsoever, including without
+ limitation commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes the
+ Waiver for the benefit of each member of the public at large and to the detriment of Affirmer's
+ heirs and successors, fully intending that such Waiver shall not be subject to revocation,
+ rescission, cancellation, termination, or any other legal or equitable action to disrupt the
+ quiet enjoyment of the Work by the public as contemplated by Affirmer's express Statement of
+ Purpose.
+
+3. Public License Fallback. Should any part of the Waiver for any reason be judged legally invalid
+ or ineffective under applicable law, then the Waiver shall be preserved to the maximum extent
+ permitted taking into account Affirmer's express Statement of Purpose. In addition, to the extent
+ the Waiver is so judged Affirmer hereby grants to each affected person a royalty-free, non
+ transferable, non sublicensable, non exclusive, irrevocable and unconditional license to exercise
+ Affirmer's Copyright and Related Rights in the Work (i) in all territories worldwide, (ii) for
+ the maximum duration provided by applicable law or treaty (including future time extensions),
+ (iii) in any current or future medium and for any number of copies, and (iv) for any purpose
+ whatsoever, including without limitation commercial, advertising or promotional purposes (the
+ "License"). The License shall be deemed effective as of the date CC0 was applied by Affirmer to
+ the Work. Should any part of the License for any reason be judged legally invalid or ineffective
+ under applicable law, such partial invalidity or ineffectiveness shall not invalidate the
+ remainder of the License, and in such case Affirmer hereby affirms that he or she will not (i)
+ exercise any of his or her remaining Copyright and Related Rights in the Work or (ii) assert any
+ associated claims and causes of action with respect to the Work, in either case contrary to
+ Affirmer's express Statement of Purpose.
+
+4. Limitations and Disclaimers.
+
+a. No trademark or patent rights held by Affirmer are waived, abandoned, surrendered, licensed or
+ otherwise affected by this document.
+
+b. Affirmer offers the Work as-is and makes no representations or warranties of any kind concerning
+ the Work, express, implied, statutory or otherwise, including without limitation warranties of
+ title, merchantability, fitness for a particular purpose, non infringement, or the absence of
+ latent or other defects, accuracy, or the present or absence of errors, whether or not
+ discoverable, all to the greatest extent permissible under applicable law.
+
+c. Affirmer disclaims responsibility for clearing rights of other persons that may apply to the Work
+ or any use thereof, including without limitation any person's Copyright and Related Rights in the
+ Work. Further, Affirmer disclaims responsibility for obtaining any necessary consents,
+ permissions or other rights required for any use of the Work.
+
+d. Affirmer understands and acknowledges that Creative Commons is not a party to this document and
+ has no duty or obligation with respect to this CC0 or use of the Work.
diff --git a/src/3rdparty/sha3/qt_attribution.json b/src/3rdparty/sha3/qt_attribution.json
new file mode 100644
index 0000000000..13e6e971d9
--- /dev/null
+++ b/src/3rdparty/sha3/qt_attribution.json
@@ -0,0 +1,29 @@
+[
+ {
+ "Id": "sha3_endian",
+ "Name": "Secure Hash Algorithm SHA-3 - brg_endian",
+ "QDocModule": "qtcore",
+ "QtUsage": "Used in Qt Core (QCryptographicHash).",
+
+ "Description": "SHA-3, originally known as Keccak, is a cryptographic hash function.",
+ "License": "BSD 3-clause \"New\" or \"Revised\" License",
+ "LicenseFile": "BRG_ENDIAN_LICENSE",
+ "LicenseId": "BSD-3-Clause",
+ "Copyright": "Copyright (c) 1998-2008, Brian Gladman, Worcester, UK. All rights reserved."
+ },
+ {
+ "Id": "sha3_keccak",
+ "Name": "Secure Hash Algorithm SHA-3 - Keccak",
+ "QDocModule": "qtcore",
+ "QtUsage": "Used in Qt Core (QCryptographicHash).",
+
+ "Description": "SHA-3, originally known as Keccak, is a cryptographic hash function.",
+ "License": "Creative Commons Zero v1.0 Universal",
+ "LicenseId": "CC0-1.0",
+ "LicenseFile": "CC0_LICENSE",
+ "Copyright": "Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche.
+
+To the extent possible under law, the implementers have waived all copyright
+and related or neighboring rights to the source code in this file."
+ }
+]
diff --git a/src/3rdparty/sqlite/qt_attribution.json b/src/3rdparty/sqlite/qt_attribution.json
new file mode 100644
index 0000000000..a4ea0cdbd2
--- /dev/null
+++ b/src/3rdparty/sqlite/qt_attribution.json
@@ -0,0 +1,12 @@
+{
+ "Id": "sqlite",
+ "Name": "SQLite",
+ "QDocModule": "qtsql",
+ "QtUsage": "Used in Qt SQL Lite plugin. Configure Qt with -system-sqlite or -no-sqlite to avoid.",
+
+ "Description": "SQLite is a small C library that implements a self-contained, embeddable, zero-configuration SQL database engine.",
+ "Homepage": "http://www.sqlite.org/",
+ "Version": "3.11.1.0",
+ "License": "Public Domain",
+ "Copyright": "The authors disclaim copyright to the source code. However, a license can be obtained if needed."
+}
diff --git a/src/3rdparty/wintab/qt_attribution.json b/src/3rdparty/wintab/qt_attribution.json
new file mode 100644
index 0000000000..742278fb26
--- /dev/null
+++ b/src/3rdparty/wintab/qt_attribution.json
@@ -0,0 +1,12 @@
+{
+ "Id": "wintab",
+ "Name": "Wintab API",
+ "QDocModule": "qtgui",
+ "QtUsage": "Used in the Qt platform plugin for Windows. Configure with -DQT_NO_TABLETEVENT to avoid.",
+
+ "Description": "Wintab is a de facto API for pointing devices on Windows.",
+ "Homepage": "http://www.pointing.com/Wintab.html",
+ "License": "Public Domain",
+ "LicenseId": "NONE",
+ "Copyright": "Copyright 1991-1998 by LCS/Telegraphics."
+}
diff --git a/src/3rdparty/xcb/LICENSE b/src/3rdparty/xcb/LICENSE
new file mode 100644
index 0000000000..8f4e5c3a72
--- /dev/null
+++ b/src/3rdparty/xcb/LICENSE
@@ -0,0 +1,23 @@
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use, copy,
+modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the names of the authors or
+their institutions shall not be used in advertising or otherwise to
+promote the sale, use or other dealings in this Software without
+prior written authorization from the authors.
diff --git a/src/3rdparty/xcb/qt_attribution.json b/src/3rdparty/xcb/qt_attribution.json
new file mode 100644
index 0000000000..30b9af3818
--- /dev/null
+++ b/src/3rdparty/xcb/qt_attribution.json
@@ -0,0 +1,24 @@
+{
+ "Id": "xcb",
+ "Name": "XCB",
+ "QDocModule": "qtgui",
+ "QtUsage": "Optionally used in xcb platform plugin if configured with -qt-xcb.",
+
+ "Description": "Selected xcb libraries.",
+ "Homepage": "https://xcb.freedesktop.org/",
+ "License": "MIT License",
+ "LicenseId": "MIT",
+ "LicenseFile": "LICENSE",
+ "Copyright": "Copyright © 2000 Keith Packard
+Copyright © 2006 Jamey Sharp
+Copyright © 2007-2008 Vincent Torri <vtorri@univ-evry.fr>
+Copyright © 2007 Bart Massey
+Copyright © 2008-2009 Julien Danjou <julien@danjou.info>
+Copyright © 2008 Arnaud Fontaine <arnau@debian.org>
+Copyright © 2008 Bart Massey <bart@cs.pdx.edu>
+Copyright © 2008 Ian Osgood <iano@quirkster.com>
+Copyright © 2008 Jamey Sharp <jamey@minilop.net>
+Copyright © 2008 Josh Triplett <josh@freedesktop.org>
+Copyright © 2008 Ulrich Eckhardt <doomster@knuut.de>
+"
+}
diff --git a/src/3rdparty/xkbcommon/qt_attribution.json b/src/3rdparty/xkbcommon/qt_attribution.json
new file mode 100644
index 0000000000..8ee0df1b22
--- /dev/null
+++ b/src/3rdparty/xkbcommon/qt_attribution.json
@@ -0,0 +1,26 @@
+{
+ "Id": "xkbcommon",
+ "Name": "xkbcommon",
+ "QDocModule": "qtgui",
+ "QtUsage": "Used in xcb platform plugin. Configure with -system-xkbcommon-x11 to avoid.",
+
+ "Description": "xkbcommon is a keymap compiler and support library which processes a reduced subset of keymaps as defined by the XKB specification.",
+ "Homepage": "http://xkbcommon.org/",
+ "License": "MIT Licenses (with no-advertisement clause)",
+ "LicenseId": "MIT",
+ "LicenseFile": "COPYING",
+ "Copyright": "Copyright 1985, 1987, 1988, 1990, 1998 The Open Group
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+Copyright 1993, 1994, 1995, 1996 by Silicon Graphics Computer Systems, Inc.
+Copyright 1996 by Joseph Moss
+Copyright 2002-2007 Free Software Foundation, Inc.
+Copyright 2003-2004 Dmitry Golubev <lastguru@mail.ru>
+Copyright 2004, Gregory Mokhin <mokhin@bog.msu.ru>
+Copyright 2006 Erdal Ronahî
+Copyright 2008, 2009 Dan Nicholson
+Copyright 2009-2012 Daniel Stone
+Copyright 2010, 2012 Intel Corporation
+Copyright 2010 Francisco Jerez <currojerez@riseup.net>
+Copyright 2011 Joseph Adams <joeyadams3.14159@gmail.com>
+Copyright 2012 Ran Benita <ran234@gmail.com>"
+}
diff --git a/src/3rdparty/zlib/LICENSE b/src/3rdparty/zlib/LICENSE
new file mode 100644
index 0000000000..9c57e18006
--- /dev/null
+++ b/src/3rdparty/zlib/LICENSE
@@ -0,0 +1,28 @@
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+ Jean-loup Gailly Mark Adler
+ jloup@gzip.org madler@alumni.caltech.edu
+
+If you use the zlib library in a product, we would appreciate *not* receiving
+lengthy legal documents to sign. The sources are provided for free but without
+warranty of any kind. The library has been entirely written by Jean-loup
+Gailly and Mark Adler; it does not include third-party code.
+
+If you redistribute modified sources, we would appreciate that you include in
+the file ChangeLog history information documenting your changes. Please read
+the FAQ for more information on the distribution of modified source versions.
+
diff --git a/src/3rdparty/zlib/qt_attribution.json b/src/3rdparty/zlib/qt_attribution.json
new file mode 100644
index 0000000000..a10fd1921f
--- /dev/null
+++ b/src/3rdparty/zlib/qt_attribution.json
@@ -0,0 +1,15 @@
+{
+ "Id": "zlib",
+ "Name": "Data Compression Library (zlib)",
+ "QDocModule": "qtcore",
+ "QtUsage": "Optionally used in Qt Core and and development tools. Configure with -system-zlib to avoid.",
+
+ "Description": "zlib is a general purpose data compression library.",
+ "Homepage": "http://zlib.net/",
+ "Version": "1.2.5",
+
+ "License": "ZLib license",
+ "LicenseId": "Zlib",
+ "LicenseFile": "LICENSE",
+ "Copyright": "(C) 1995-2010 Jean-loup Gailly and Mark Adler"
+}
diff --git a/src/angle/src/config.pri b/src/angle/src/config.pri
index 2c5b5ec615..4beb095217 100644
--- a/src/angle/src/config.pri
+++ b/src/angle/src/config.pri
@@ -40,8 +40,6 @@ DEFINES += _WINDOWS \
CONFIG += angle_d3d11 # Remove to disable D3D11 renderer
-equals(QMAKE_TARGET_OS, xp): CONFIG -= angle_d3d11
-
angle_d3d11 {
DEFINES += ANGLE_ENABLE_D3D11 ANGLE_DEFAULT_D3D11=1
!build_pass: message("Enabling D3D11 mode for ANGLE")
diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake
index 9235641544..23909c9f3f 100644
--- a/src/corelib/Qt5CoreMacros.cmake
+++ b/src/corelib/Qt5CoreMacros.cmake
@@ -90,6 +90,9 @@ macro(QT5_GET_MOC_FLAGS _moc_flags)
if(WIN32)
set(${_moc_flags} ${${_moc_flags}} -DWIN32)
endif()
+ if (MSVC)
+ set(${_moc_flags} --compiler-flavor=msvc)
+ endif()
endmacro()
diff --git a/src/corelib/arch/arch.pri b/src/corelib/arch/arch.pri
index ec617386a4..0f7c2b887b 100644
--- a/src/corelib/arch/arch.pri
+++ b/src/corelib/arch/arch.pri
@@ -1,4 +1,4 @@
-win32|wince:HEADERS += arch/qatomic_msvc.h
+win32:HEADERS += arch/qatomic_msvc.h
HEADERS += \
arch/qatomic_bootstrap.h \
diff --git a/src/corelib/arch/qatomic_msvc.h b/src/corelib/arch/qatomic_msvc.h
index 62d54ded55..5eae2bdc48 100644
--- a/src/corelib/arch/qatomic_msvc.h
+++ b/src/corelib/arch/qatomic_msvc.h
@@ -45,8 +45,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
-#ifndef Q_OS_WINCE
-
// use compiler intrinsics for all atomic functions
# define QT_INTERLOCKED_PREFIX _
# define QT_INTERLOCKED_PROTOTYPE
@@ -58,36 +56,6 @@
# define Q_ATOMIC_INT64_IS_SUPPORTED
# endif
-#else // Q_OS_WINCE
-
-# if _WIN32_WCE < 0x600 && defined(_X86_)
-// For X86 Windows CE, include winbase.h to catch inline functions which
-// override the regular definitions inside of coredll.dll.
-// Though one could use the original version of Increment/Decrement, others are
-// not exported at all.
-# include <winbase.h>
-
-// It's safer to remove the volatile and let the compiler add it as needed.
-# define QT_INTERLOCKED_VOLATILE
-
-# else // _WIN32_WCE >= 0x600 || !_X86_
-
-# define QT_INTERLOCKED_PROTOTYPE __cdecl
-# define QT_INTERLOCKED_DECLARE_PROTOTYPES
-
-# if _WIN32_WCE >= 0x600
-# if defined(_X86_)
-# define QT_INTERLOCKED_PREFIX _
-# define QT_INTERLOCKED_INTRINSIC
-# endif
-# else
-# define QT_INTERLOCKED_VOLATILE
-# endif
-
-# endif // _WIN32_WCE >= 0x600 || !_X86_
-
-#endif // Q_OS_WINCE
-
////////////////////////////////////////////////////////////////////////////////////////////////////
// Prototype declaration
@@ -128,7 +96,7 @@ extern "C" {
long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Exchange )(long QT_INTERLOCKED_VOLATILE *, long);
long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( ExchangeAdd )(long QT_INTERLOCKED_VOLATILE *, long);
-# if !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86)
+# if !defined(__i386__) && !defined(_M_IX86)
void * QT_INTERLOCKED_FUNCTION( CompareExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *, void *);
void * QT_INTERLOCKED_FUNCTION( ExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *);
__int64 QT_INTERLOCKED_FUNCTION( ExchangeAdd64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64);
@@ -165,7 +133,7 @@ extern "C" {
# pragma intrinsic (_InterlockedCompareExchange)
# pragma intrinsic (_InterlockedExchangeAdd)
-# if !defined(Q_OS_WINCE) && !defined(_M_IX86)
+# if !defined(_M_IX86)
# pragma intrinsic (_InterlockedCompareExchangePointer)
# pragma intrinsic (_InterlockedExchangePointer)
# pragma intrinsic (_InterlockedExchangeAdd64)
@@ -176,7 +144,7 @@ extern "C" {
////////////////////////////////////////////////////////////////////////////////////////////////////
// Interlocked* replacement macros
-#if defined(Q_OS_WINCE) || defined(__i386__) || defined(_M_IX86)
+#if defined(__i386__) || defined(_M_IX86)
# define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \
reinterpret_cast<void *>( \
@@ -195,7 +163,7 @@ extern "C" {
reinterpret_cast<long QT_INTERLOCKED_VOLATILE *>(value), \
(valueToAdd))
-#else // !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86)
+#else // !defined(__i386__) && !defined(_M_IX86)
# define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \
QT_INTERLOCKED_FUNCTION(CompareExchangePointer)( \
@@ -213,7 +181,7 @@ extern "C" {
reinterpret_cast<qint64 QT_INTERLOCKED_VOLATILE *>(value), \
(valueToAdd))
-#endif // !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86)
+#endif // !defined(__i386__) && !defined(_M_IX86)
////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri
index bfb677e6fb..fdaec33c5a 100644
--- a/src/corelib/codecs/codecs.pri
+++ b/src/corelib/codecs/codecs.pri
@@ -40,20 +40,17 @@ contains(QT_CONFIG,icu) {
codecs/qeuckrcodec.cpp \
codecs/qbig5codec.cpp
- unix:!qnx:!mac:!ios:!linux-android-* {
- contains(QT_CONFIG,iconv) {
- HEADERS += codecs/qiconvcodec_p.h
- SOURCES += codecs/qiconvcodec.cpp
- } else:contains(QT_CONFIG,gnu-libiconv) {
- HEADERS += codecs/qiconvcodec_p.h
- SOURCES += codecs/qiconvcodec.cpp
- DEFINES += GNU_LIBICONV
- LIBS_PRIVATE *= -liconv
- } else:contains(QT_CONFIG,sun-libiconv) {
- HEADERS += codecs/qiconvcodec_p.h
- SOURCES += codecs/qiconvcodec.cpp
- DEFINES += GNU_LIBICONV
+ unix:!qnx:!darwin:!linux-android-* {
+ contains(QT_CONFIG, iconv) {
+ HEADERS += codecs/qiconvcodec_p.h
+ SOURCES += codecs/qiconvcodec.cpp
+ contains(QT_CONFIG, gnu-libiconv) {
+ DEFINES += GNU_LIBICONV
+ LIBS_PRIVATE *= -liconv
+ } else: contains(QT_CONFIG, sun-libiconv) {
+ DEFINES += GNU_LIBICONV
}
+ }
} else:!win32-msvc* {
DEFINES += QT_NO_ICONV
}
diff --git a/src/corelib/codecs/cp949codetbl_p.h b/src/corelib/codecs/cp949codetbl_p.h
index 3d55bcfac9..3b615d4e17 100644
--- a/src/corelib/codecs/cp949codetbl_p.h
+++ b/src/corelib/codecs/cp949codetbl_p.h
@@ -51,6 +51,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
static const unsigned short cp949_icode_to_unicode[] = {
0xac02, 0xac03, 0xac05, 0xac06, 0xac0b, 0xac0c, 0xac0d, 0xac0e, 0xac0f, 0xac18, 0xac1e, 0xac1f, 0xac21, 0xac22, 0xac23,
0xac25, 0xac26, 0xac27, 0xac28, 0xac29, 0xac2a, 0xac2b, 0xac2e, 0xac32, 0xac33, 0xac34, 0xac35, 0xac36, 0xac37, 0xac3a,
diff --git a/src/corelib/codecs/qbig5codec_p.h b/src/corelib/codecs/qbig5codec_p.h
index 24a520a119..9dbcf41a6d 100644
--- a/src/corelib/codecs/qbig5codec_p.h
+++ b/src/corelib/codecs/qbig5codec_p.h
@@ -55,6 +55,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qtextcodec.h>
#include <QtCore/qlist.h>
diff --git a/src/corelib/codecs/qeuckrcodec_p.h b/src/corelib/codecs/qeuckrcodec_p.h
index 0311fb689c..2cf950a350 100644
--- a/src/corelib/codecs/qeuckrcodec_p.h
+++ b/src/corelib/codecs/qeuckrcodec_p.h
@@ -76,6 +76,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qtextcodec.h>
#include <QtCore/qlist.h>
diff --git a/src/corelib/codecs/qgb18030codec_p.h b/src/corelib/codecs/qgb18030codec_p.h
index 3884eea6fd..dd136aeddb 100644
--- a/src/corelib/codecs/qgb18030codec_p.h
+++ b/src/corelib/codecs/qgb18030codec_p.h
@@ -53,6 +53,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qtextcodec.h>
#include <QtCore/qlist.h>
diff --git a/src/corelib/codecs/qiconvcodec_p.h b/src/corelib/codecs/qiconvcodec_p.h
index 4c7f7084e6..dd078fdda4 100644
--- a/src/corelib/codecs/qiconvcodec_p.h
+++ b/src/corelib/codecs/qiconvcodec_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qtextcodec.h"
#if defined(Q_OS_UNIX) && !defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED)
diff --git a/src/corelib/codecs/qicucodec.cpp b/src/corelib/codecs/qicucodec.cpp
index aa2095d9da..ee9f1d0048 100644
--- a/src/corelib/codecs/qicucodec.cpp
+++ b/src/corelib/codecs/qicucodec.cpp
@@ -527,7 +527,7 @@ QTextCodec *QIcuCodec::codecForNameUnlocked(const char *name)
// check whether there is really a converter for the name available.
UConverter *conv = ucnv_open(standardName, &error);
if (!conv) {
- qDebug() << "codecForName: ucnv_open failed" << standardName << u_errorName(error);
+ qDebug("codecForName: ucnv_open failed %s %s", standardName, u_errorName(error));
return 0;
}
//qDebug() << "QIcuCodec: Standard name for " << name << "is" << standardName;
@@ -577,7 +577,7 @@ UConverter *QIcuCodec::getConverter(QTextCodec::ConverterState *state) const
ucnv_setSubstChars(static_cast<UConverter *>(state->d),
state->flags & QTextCodec::ConvertInvalidToNull ? "\0" : "?", 1, &error);
if (U_FAILURE(error))
- qDebug() << "getConverter(state) ucnv_open failed" << m_name << u_errorName(error);
+ qDebug("getConverter(state) ucnv_open failed %s %s", m_name, u_errorName(error));
}
conv = static_cast<UConverter *>(state->d);
}
@@ -587,7 +587,7 @@ UConverter *QIcuCodec::getConverter(QTextCodec::ConverterState *state) const
conv = ucnv_open(m_name, &error);
ucnv_setSubstChars(conv, "?", 1, &error);
if (U_FAILURE(error))
- qDebug() << "getConverter(no state) ucnv_open failed" << m_name << u_errorName(error);
+ qDebug("getConverter(no state) ucnv_open failed %s %s", m_name, u_errorName(error));
}
return conv;
}
@@ -610,7 +610,7 @@ QString QIcuCodec::convertToUnicode(const char *chars, int length, QTextCodec::C
&chars, end,
0, false, &error);
if (!U_SUCCESS(error) && error != U_BUFFER_OVERFLOW_ERROR) {
- qDebug() << "convertToUnicode failed:" << u_errorName(error);
+ qDebug("convertToUnicode failed: %s", u_errorName(error));
break;
}
@@ -647,7 +647,7 @@ QByteArray QIcuCodec::convertFromUnicode(const QChar *unicode, int length, QText
&uc, end,
0, false, &error);
if (!U_SUCCESS(error))
- qDebug() << "convertFromUnicode failed:" << u_errorName(error);
+ qDebug("convertFromUnicode failed: %s", u_errorName(error));
convertedChars = ch - string.data();
if (uc >= end)
break;
diff --git a/src/corelib/codecs/qicucodec_p.h b/src/corelib/codecs/qicucodec_p.h
index a277529dc4..3a373ce5b3 100644
--- a/src/corelib/codecs/qicucodec_p.h
+++ b/src/corelib/codecs/qicucodec_p.h
@@ -53,6 +53,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
extern "C" {
typedef struct UConverter UConverter;
}
diff --git a/src/corelib/codecs/qisciicodec_p.h b/src/corelib/codecs/qisciicodec_p.h
index 94a3171d7d..f92c0091ce 100644
--- a/src/corelib/codecs/qisciicodec_p.h
+++ b/src/corelib/codecs/qisciicodec_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qtextcodec.h"
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/codecs/qjpunicode_p.h b/src/corelib/codecs/qjpunicode_p.h
index 104f540b66..4fa2b9f757 100644
--- a/src/corelib/codecs/qjpunicode_p.h
+++ b/src/corelib/codecs/qjpunicode_p.h
@@ -80,7 +80,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/codecs/qlatincodec_p.h b/src/corelib/codecs/qlatincodec_p.h
index b3556a411a..1042c3b80d 100644
--- a/src/corelib/codecs/qlatincodec_p.h
+++ b/src/corelib/codecs/qlatincodec_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qtextcodec.h"
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/codecs/qsimplecodec_p.h b/src/corelib/codecs/qsimplecodec_p.h
index d45cf2377f..d268a9f5b8 100644
--- a/src/corelib/codecs/qsimplecodec_p.h
+++ b/src/corelib/codecs/qsimplecodec_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qtextcodec.h"
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index edb03af447..5098ac4242 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -132,7 +132,7 @@ bool qTextCodecNameMatch(const char *n, const char *h)
}
-#if !defined(Q_OS_WIN32) && !defined(Q_OS_WINCE) && !defined(QT_LOCALE_IS_UTF8)
+#if !defined(Q_OS_WIN32) && !defined(QT_LOCALE_IS_UTF8)
static QTextCodec *checkForCodec(const QByteArray &name) {
QTextCodec *c = QTextCodec::codecForName(name);
if (!c) {
@@ -169,7 +169,7 @@ static QTextCodec *setupLocaleMapper()
#if defined(QT_LOCALE_IS_UTF8)
locale = QTextCodec::codecForName("UTF-8");
-#elif defined(Q_OS_WIN) || defined(Q_OS_WINCE)
+#elif defined(Q_OS_WIN)
locale = QTextCodec::codecForName("System");
#else
@@ -289,7 +289,7 @@ static void setup()
#if !defined(QT_NO_ICONV)
(void) new QIconvCodec;
#endif
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN32)
(void) new QWindowsLocalCodec;
#endif // Q_OS_WIN32
#endif // !QT_NO_CODECS && !QT_BOOTSTRAPPED
diff --git a/src/corelib/codecs/qtextcodec_p.h b/src/corelib/codecs/qtextcodec_p.h
index ad05d01b90..f3c2d090c9 100644
--- a/src/corelib/codecs/qtextcodec_p.h
+++ b/src/corelib/codecs/qtextcodec_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qtextcodec.h"
#include <string.h>
diff --git a/src/corelib/codecs/qtsciicodec_p.h b/src/corelib/codecs/qtsciicodec_p.h
index 6beb22cf6a..68ab01f7b5 100644
--- a/src/corelib/codecs/qtsciicodec_p.h
+++ b/src/corelib/codecs/qtsciicodec_p.h
@@ -80,6 +80,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qtextcodec.h"
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/codecs/qutfcodec.cpp b/src/corelib/codecs/qutfcodec.cpp
index f1054ceb98..74a716db4a 100644
--- a/src/corelib/codecs/qutfcodec.cpp
+++ b/src/corelib/codecs/qutfcodec.cpp
@@ -52,6 +52,19 @@ enum { Endian = 0, Data = 1 };
static const uchar utf8bom[] = { 0xef, 0xbb, 0xbf };
+#if (defined(__SSE2__) && defined(QT_COMPILER_SUPPORTS_SSE2)) \
+ || (defined(__ARM_NEON__) && defined(Q_PROCESSOR_ARM_64))
+static Q_ALWAYS_INLINE uint qBitScanReverse(unsigned v) Q_DECL_NOTHROW
+{
+ uint result = qCountLeadingZeroBits(v);
+ // Now Invert the result: clz will count *down* from the msb to the lsb, so the msb index is 31
+ // and the lsb index is 0. The result for _bit_scan_reverse is expected to be the index when
+ // counting up: msb index is 0 (because it starts there), and the lsb index is 31.
+ result ^= sizeof(unsigned) * 8 - 1;
+ return result;
+}
+#endif
+
#if defined(__SSE2__) && defined(QT_COMPILER_SUPPORTS_SSE2)
static inline bool simdEncodeAscii(uchar *&dst, const ushort *&nextAscii, const ushort *&src, const ushort *end)
{
@@ -81,9 +94,9 @@ static inline bool simdEncodeAscii(uchar *&dst, const ushort *&nextAscii, const
// find the next probable ASCII character
// we don't want to load 32 bytes again in this loop if we know there are non-ASCII
// characters still coming
- nextAscii = src + _bit_scan_reverse(n) + 1;
+ nextAscii = src + qBitScanReverse(n) + 1;
- n = _bit_scan_forward(n);
+ n = qCountTrailingZeroBits(n);
dst += n;
src += n;
return false;
@@ -132,13 +145,81 @@ static inline bool simdDecodeAscii(ushort *&dst, const uchar *&nextAscii, const
// find the next probable ASCII character
// we don't want to load 16 bytes again in this loop if we know there are non-ASCII
// characters still coming
- n = _bit_scan_reverse(n);
+ n = qBitScanReverse(n);
nextAscii = src + (n / BitSpacing) + 1;
return false;
}
return src == end;
}
+#elif defined(__ARM_NEON__) && defined(Q_PROCESSOR_ARM_64) // vaddv is only available on Aarch64
+static inline bool simdEncodeAscii(uchar *&dst, const ushort *&nextAscii, const ushort *&src, const ushort *end)
+{
+ uint16x8_t maxAscii = vdupq_n_u16(0x7f);
+ uint16x8_t mask1 = { 1, 1 << 2, 1 << 4, 1 << 6, 1 << 8, 1 << 10, 1 << 12, 1 << 14 };
+ uint16x8_t mask2 = vshlq_n_u16(mask1, 1);
+
+ // do sixteen characters at a time
+ for ( ; end - src >= 16; src += 16, dst += 16) {
+ // load 2 lanes (or: "load interleaved")
+ uint16x8x2_t in = vld2q_u16(src);
+
+ // check if any of the elements > 0x7f, select 1 bit per element (element 0 -> bit 0, element 1 -> bit 1, etc),
+ // add those together into a scalar, and merge the scalars.
+ uint16_t nonAscii = vaddvq_u16(vandq_u16(vcgtq_u16(in.val[0], maxAscii), mask1))
+ | vaddvq_u16(vandq_u16(vcgtq_u16(in.val[1], maxAscii), mask2));
+
+ // merge the two lanes by shifting the values of the second by 8 and inserting them
+ uint16x8_t out = vsliq_n_u16(in.val[0], in.val[1], 8);
+
+ // store, even if there are non-ASCII characters here
+ vst1q_u8(dst, vreinterpretq_u8_u16(out));
+
+ if (nonAscii) {
+ // find the next probable ASCII character
+ // we don't want to load 32 bytes again in this loop if we know there are non-ASCII
+ // characters still coming
+ nextAscii = src + qBitScanReverse(nonAscii) + 1;
+
+ nonAscii = qCountTrailingZeroBits(nonAscii);
+ dst += nonAscii;
+ src += nonAscii;
+ return false;
+ }
+ }
+ return src == end;
+}
+
+static inline bool simdDecodeAscii(ushort *&dst, const uchar *&nextAscii, const uchar *&src, const uchar *end)
+{
+ // do eight characters at a time
+ uint8x8_t msb_mask = vdup_n_u8(0x80);
+ uint8x8_t add_mask = { 1, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7 };
+ for ( ; end - src >= 8; src += 8, dst += 8) {
+ uint8x8_t c = vld1_u8(src);
+ uint8_t n = vaddv_u8(vand_u8(vcge_u8(c, msb_mask), add_mask));
+ if (!n) {
+ // store
+ vst1q_u16(dst, vmovl_u8(c));
+ continue;
+ }
+
+ // copy the front part that is still ASCII
+ while (!(n & 1)) {
+ *dst++ = *src++;
+ n >>= 1;
+ }
+
+ // find the next probable ASCII character
+ // we don't want to load 16 bytes again in this loop if we know there are non-ASCII
+ // characters still coming
+ n = qBitScanReverse(n);
+ nextAscii = src + n + 1;
+ return false;
+
+ }
+ return src == end;
+}
#else
static inline bool simdEncodeAscii(uchar *, const ushort *, const ushort *, const ushort *)
{
diff --git a/src/corelib/codecs/qwindowscodec.cpp b/src/corelib/codecs/qwindowscodec.cpp
index b802ab7249..813d3c8153 100644
--- a/src/corelib/codecs/qwindowscodec.cpp
+++ b/src/corelib/codecs/qwindowscodec.cpp
@@ -157,7 +157,7 @@ QString QWindowsLocalCodec::convertToUnicodeCharByChar(const char *chars, int le
state->remainingChars = 0;
}
const char *mb = mbcs;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
const char *next = 0;
QString s;
while ((next = CharNextExA(CP_ACP, mb, 0)) != mb) {
diff --git a/src/corelib/codecs/qwindowscodec_p.h b/src/corelib/codecs/qwindowscodec_p.h
index 529c621b2e..2fd3c35378 100644
--- a/src/corelib/codecs/qwindowscodec_p.h
+++ b/src/corelib/codecs/qwindowscodec_p.h
@@ -50,6 +50,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qtextcodec.h"
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro
index 2faa97eb17..1db814180b 100644
--- a/src/corelib/corelib.pro
+++ b/src/corelib/corelib.pro
@@ -48,11 +48,19 @@ include(statemachine/statemachine.pri)
include(mimetypes/mimetypes.pri)
include(xml/xml.pri)
-# otherwise mingw headers do not declare common functions like putenv
-mingw: CONFIG -= strict_c++
+win32 {
+ mingw {
+ # otherwise mingw headers do not declare common functions like putenv
+ CONFIG -= strict_c++
+ # Override MinGW's definition in _mingw.h
+ DEFINES += WINVER=0x600 _WIN32_WINNT=0x0600
+ }
+
+ !winrt: LIBS_PRIVATE += -lwinmm
+}
-mac|darwin {
- !ios {
+darwin {
+ osx {
LIBS_PRIVATE += -framework ApplicationServices
LIBS_PRIVATE += -framework CoreServices
}
diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
index 54b5c95a34..1169ad5536 100644
--- a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp
@@ -131,26 +131,46 @@ absoluteValue = qAbs(myValue);
//! [10]
-//! [11]
-qreal valueA = 2.3;
-qreal valueB = 2.7;
+//! [11A]
+double valueA = 2.3;
+double valueB = 2.7;
int roundedValueA = qRound(valueA);
// roundedValueA = 2
int roundedValueB = qRound(valueB);
// roundedValueB = 3
-//! [11]
+//! [11A]
+//! [11B]
+float valueA = 2.3;
+float valueB = 2.7;
-//! [12]
-qreal valueA = 42949672960.3;
-qreal valueB = 42949672960.7;
+int roundedValueA = qRound(valueA);
+// roundedValueA = 2
+int roundedValueB = qRound(valueB);
+// roundedValueB = 3
+//! [11B]
+
+
+//! [12A]
+double valueA = 42949672960.3;
+double valueB = 42949672960.7;
+
+qint64 roundedValueA = qRound64(valueA);
+// roundedValueA = 42949672960
+qint64 roundedValueB = qRound64(valueB);
+// roundedValueB = 42949672961
+//! [12A]
+
+//! [12B]
+float valueA = 42949672960.3;
+float valueB = 42949672960.7;
qint64 roundedValueA = qRound64(valueA);
// roundedValueA = 42949672960
qint64 roundedValueB = qRound64(valueB);
// roundedValueB = 42949672961
-//! [12]
+//! [12B]
//! [13]
diff --git a/src/corelib/doc/src/animation.qdoc b/src/corelib/doc/src/animation.qdoc
index 4e71ed4268..0c1b2aed17 100644
--- a/src/corelib/doc/src/animation.qdoc
+++ b/src/corelib/doc/src/animation.qdoc
@@ -121,7 +121,7 @@
As mentioned in the previous section, the QPropertyAnimation class can
interpolate over Qt properties. It is often this class that should be used
for animation of values; in fact, its superclass, QVariantAnimation, has an
- empty implementation of \l{QAbstractAnimation::}{updateCurrentValue()}, and
+ empty implementation of \l{QVariantAnimation::}{updateCurrentValue()}, and
does not change any value unless we change it ourselves on the
\l{QVariantAnimation::valueChanged()}{valueChanged signal}.
diff --git a/src/corelib/doc/src/qtcore-index.qdoc b/src/corelib/doc/src/qtcore-index.qdoc
index e2fce5797d..fe9b43507c 100644
--- a/src/corelib/doc/src/qtcore-index.qdoc
+++ b/src/corelib/doc/src/qtcore-index.qdoc
@@ -101,7 +101,19 @@
\li \l{The Event System}
\endlist
- \section1 Related Information
+ \section1 Licenses and Attributions
+
+ Qt Core is available under commercial licenses from \l{The Qt Company}.
+ In addition, it is available under the
+ \l{GNU Lesser General Public License, version 3}, or
+ the \l{GNU General Public License, version 2}.
+ See \l{Qt Licensing} for further details.
+
+ Furthermore Qt Core potentially contains third party
+ modules under following permissive licenses:
+
+ \generatelist{groupsbymodule attributions-qtcore}
+
\section1 Reference
These are links to the API reference materials.
\list
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 285931e794..70c9e97c13 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -656,14 +656,6 @@
/* General C++ features */
# define Q_COMPILER_RESTRICTED_VLA
# define Q_COMPILER_THREADSAFE_STATICS
-# if !__has_feature(cxx_exceptions)
-# ifndef QT_NO_EXCEPTIONS
-# define QT_NO_EXCEPTIONS
-# endif
-# endif
-# if !__has_feature(cxx_rtti)
-# define QT_NO_RTTI
-# endif
# if __has_feature(attribute_deprecated_with_message)
# define Q_DECL_DEPRECATED_X(text) __attribute__ ((__deprecated__(text)))
# endif
diff --git a/src/corelib/global/qconfig-large.h b/src/corelib/global/qconfig-large.h
deleted file mode 100644
index 270858e65b..0000000000
--- a/src/corelib/global/qconfig-large.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/* Dialogs */
-#ifndef QT_NO_FILEDIALOG
-# define QT_NO_FILEDIALOG
-#endif
-#ifndef QT_NO_FONTDIALOG
-# define QT_NO_FONTDIALOG
-#endif
-#ifndef QT_NO_INPUTDIALOG
-# define QT_NO_INPUTDIALOG
-#endif
-#ifndef QT_NO_PRINTDIALOG
-# define QT_NO_PRINTDIALOG
-#endif
-#ifndef QT_NO_PROGRESSDIALOG
-# define QT_NO_PROGRESSDIALOG
-#endif
-
-/* Images */
-#ifndef QT_NO_IMAGEFORMAT_BMP
-# define QT_NO_IMAGEFORMAT_BMP
-#endif
-#ifndef QT_NO_IMAGEFORMAT_PPM
-# define QT_NO_IMAGEFORMAT_PPM
-#endif
-
-/* Internationalization */
-#ifndef QT_NO_CODECS
-# define QT_NO_CODECS
-#endif
-#ifndef QT_NO_TRANSLATION
-# define QT_NO_TRANSLATION
-#endif
-
-/* ItemViews */
-#ifndef QT_NO_TABLEVIEW
-# define QT_NO_TABLEVIEW
-#endif
-#ifndef QT_NO_TREEVIEW
-# define QT_NO_TREEVIEW
-#endif
-
-/* Kernel */
-#ifndef QT_NO_CLIPBOARD
-# define QT_NO_CLIPBOARD
-#endif
-#ifndef QT_NO_DRAGANDDROP
-# define QT_NO_DRAGANDDROP
-#endif
-#ifndef QT_NO_EFFECTS
-# define QT_NO_EFFECTS
-#endif
-#ifndef QT_NO_PROPERTIES
-# define QT_NO_PROPERTIES
-#endif
-
-/* Networking */
-#ifndef QT_NO_HTTP
-# define QT_NO_HTTP
-#endif
-#ifndef QT_NO_UDPSOCKET
-# define QT_NO_UDPSOCKET
-#endif
-#ifndef QT_NO_FTP
-# define QT_NO_FTP
-#endif
-
-/* Painting */
-#ifndef QT_NO_COLORNAMES
-# define QT_NO_COLORNAMES
-#endif
-#ifndef QT_NO_PICTURE
-# define QT_NO_PICTURE
-#endif
-#ifndef QT_NO_PRINTER
-# define QT_NO_PRINTER
-#endif
-#ifndef QT_NO_CUPS
-# define QT_NO_CUPS
-#endif
-
-/* Styles */
-#ifndef QT_NO_STYLE_STYLESHEET
-# define QT_NO_STYLE_STYLESHEET
-#endif
-
-/* Widgets */
-#ifndef QT_NO_CALENDARWIDGET
-# define QT_NO_CALENDARWIDGET
-#endif
-#ifndef QT_NO_DATETIMEEDIT
-# define QT_NO_DATETIMEEDIT
-#endif
-#ifndef QT_NO_DIAL
-# define QT_NO_DIAL
-#endif
-#ifndef QT_NO_TABLEWIDGET
-# define QT_NO_TABLEWIDGET
-#endif
-#ifndef QT_NO_TREEWIDGET
-# define QT_NO_TREEWIDGET
-#endif
diff --git a/src/corelib/global/qconfig-medium.h b/src/corelib/global/qconfig-medium.h
deleted file mode 100644
index 830e936924..0000000000
--- a/src/corelib/global/qconfig-medium.h
+++ /dev/null
@@ -1,241 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/* Dialogs */
-#ifndef QT_NO_COLORDIALOG
-# define QT_NO_COLORDIALOG
-#endif
-#ifndef QT_NO_FILEDIALOG
-# define QT_NO_FILEDIALOG
-#endif
-#ifndef QT_NO_FONTDIALOG
-# define QT_NO_FONTDIALOG
-#endif
-#ifndef QT_NO_INPUTDIALOG
-# define QT_NO_INPUTDIALOG
-#endif
-#ifndef QT_NO_PRINTDIALOG
-# define QT_NO_PRINTDIALOG
-#endif
-#ifndef QT_NO_PROGRESSDIALOG
-# define QT_NO_PROGRESSDIALOG
-#endif
-
-/* Images */
-#ifndef QT_NO_IMAGEFORMAT_BMP
-# define QT_NO_IMAGEFORMAT_BMP
-#endif
-#ifndef QT_NO_IMAGEFORMAT_PPM
-# define QT_NO_IMAGEFORMAT_PPM
-#endif
-#ifndef QT_NO_MOVIE
-# define QT_NO_MOVIE
-#endif
-
-/* Internationalization */
-#ifndef QT_NO_BIG_CODECS
-# define QT_NO_BIG_CODECS
-#endif
-#ifndef QT_NO_TEXTCODEC
-# define QT_NO_TEXTCODEC
-#endif
-#ifndef QT_NO_CODECS
-# define QT_NO_CODECS
-#endif
-#ifndef QT_NO_TRANSLATION
-# define QT_NO_TRANSLATION
-#endif
-
-/* ItemViews */
-#ifndef QT_NO_TABLEVIEW
-# define QT_NO_TABLEVIEW
-#endif
-#ifndef QT_NO_TREEVIEW
-# define QT_NO_TREEVIEW
-#endif
-
-/* Kernel */
-#ifndef QT_NO_ACTION
-# define QT_NO_ACTION
-#endif
-#ifndef QT_NO_CLIPBOARD
-# define QT_NO_CLIPBOARD
-#endif
-#ifndef QT_NO_DRAGANDDROP
-# define QT_NO_DRAGANDDROP
-#endif
-#ifndef QT_NO_EFFECTS
-# define QT_NO_EFFECTS
-#endif
-#ifndef QT_NO_PROPERTIES
-# define QT_NO_PROPERTIES
-#endif
-#ifndef QT_NO_SESSIONMANAGER
-# define QT_NO_SESSIONMANAGER
-#endif
-#ifndef QT_NO_SHORTCUT
-# define QT_NO_SHORTCUT
-#endif
-#ifndef QT_NO_WHEELEVENT
-# define QT_NO_WHEELEVENT
-#endif
-
-/* Networking */
-#ifndef QT_NO_HTTP
-# define QT_NO_HTTP
-#endif
-#ifndef QT_NO_NETWORKPROXY
-# define QT_NO_NETWORKPROXY
-#endif
-#ifndef QT_NO_SOCKS5
-# define QT_NO_SOCKS5
-#endif
-#ifndef QT_NO_UDPSOCKET
-# define QT_NO_UDPSOCKET
-#endif
-#ifndef QT_NO_FTP
-# define QT_NO_FTP
-#endif
-
-/* Painting */
-#ifndef QT_NO_COLORNAMES
-# define QT_NO_COLORNAMES
-#endif
-#ifndef QT_NO_PICTURE
-# define QT_NO_PICTURE
-#endif
-#ifndef QT_NO_PRINTER
-# define QT_NO_PRINTER
-#endif
-#ifndef QT_NO_CUPS
-# define QT_NO_CUPS
-#endif
-
-/* Styles */
-#ifndef QT_NO_STYLE_STYLESHEET
-# define QT_NO_STYLE_STYLESHEET
-#endif
-
-/* Utilities */
-#ifndef QT_NO_UNDOCOMMAND
-# define QT_NO_UNDOCOMMAND
-#endif
-#ifndef QT_NO_UNDOGROUP
-# define QT_NO_UNDOGROUP
-#endif
-#ifndef QT_NO_UNDOSTACK
-# define QT_NO_UNDOSTACK
-#endif
-#ifndef QT_NO_UNDOVIEW
-# define QT_NO_UNDOVIEW
-#endif
-#ifndef QT_NO_GESTURES
-# define QT_NO_GESTURES
-#endif
-
-/* Widgets */
-#ifndef QT_NO_LCDNUMBER
-# define QT_NO_LCDNUMBER
-#endif
-#ifndef QT_NO_CALENDARWIDGET
-# define QT_NO_CALENDARWIDGET
-#endif
-#ifndef QT_NO_DATETIMEEDIT
-# define QT_NO_DATETIMEEDIT
-#endif
-#ifndef QT_NO_MENU
-# define QT_NO_MENU
-#endif
-#ifndef QT_NO_CONTEXTMENU
-# define QT_NO_CONTEXTMENU
-#endif
-#ifndef QT_NO_MAINWINDOW
-# define QT_NO_MAINWINDOW
-#endif
-#ifndef QT_NO_DOCKWIDGET
-# define QT_NO_DOCKWIDGET
-#endif
-#ifndef QT_NO_TOOLBAR
-# define QT_NO_TOOLBAR
-#endif
-#ifndef QT_NO_MENUBAR
-# define QT_NO_MENUBAR
-#endif
-#ifndef QT_NO_PROGRESSBAR
-# define QT_NO_PROGRESSBAR
-#endif
-#ifndef QT_NO_SIZEGRIP
-# define QT_NO_SIZEGRIP
-#endif
-#ifndef QT_NO_DIAL
-# define QT_NO_DIAL
-#endif
-#ifndef QT_NO_STACKEDWIDGET
-# define QT_NO_STACKEDWIDGET
-#endif
-#ifndef QT_NO_TABWIDGET
-# define QT_NO_TABWIDGET
-#endif
-#ifndef QT_NO_STATUSBAR
-# define QT_NO_STATUSBAR
-#endif
-#ifndef QT_NO_STATUSTIP
-# define QT_NO_STATUSTIP
-#endif
-#ifndef QT_NO_TABLEWIDGET
-# define QT_NO_TABLEWIDGET
-#endif
-#ifndef QT_NO_TOOLBUTTON
-# define QT_NO_TOOLBUTTON
-#endif
-#ifndef QT_NO_TABBAR
-# define QT_NO_TABBAR
-#endif
-#ifndef QT_NO_TOOLBOX
-# define QT_NO_TOOLBOX
-#endif
-#ifndef QT_NO_WHATSTHIS
-# define QT_NO_WHATSTHIS
-#endif
-#ifndef QT_NO_TOOLTIP
-# define QT_NO_TOOLTIP
-#endif
-#ifndef QT_NO_TREEWIDGET
-# define QT_NO_TREEWIDGET
-#endif
diff --git a/src/corelib/global/qconfig-minimal.h b/src/corelib/global/qconfig-minimal.h
deleted file mode 100644
index 305655b1c9..0000000000
--- a/src/corelib/global/qconfig-minimal.h
+++ /dev/null
@@ -1,463 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/* Data structures */
-#ifndef QT_NO_TEXTDATE
-# define QT_NO_TEXTDATE
-#endif
-#ifndef QT_NO_DATESTRING
-# define QT_NO_DATESTRING
-#endif
-
-/* Dialogs */
-#ifndef QT_NO_COLORDIALOG
-# define QT_NO_COLORDIALOG
-#endif
-#ifndef QT_NO_ERRORMESSAGE
-# define QT_NO_ERRORMESSAGE
-#endif
-#ifndef QT_NO_FILEDIALOG
-# define QT_NO_FILEDIALOG
-#endif
-#ifndef QT_NO_FONTDIALOG
-# define QT_NO_FONTDIALOG
-#endif
-#ifndef QT_NO_INPUTDIALOG
-# define QT_NO_INPUTDIALOG
-#endif
-#ifndef QT_NO_MESSAGEBOX
-# define QT_NO_MESSAGEBOX
-#endif
-#ifndef QT_NO_PRINTDIALOG
-# define QT_NO_PRINTDIALOG
-#endif
-#ifndef QT_NO_PRINTPREVIEWDIALOG
-# define QT_NO_PRINTPREVIEWDIALOG
-#endif
-#ifndef QT_NO_PROGRESSDIALOG
-# define QT_NO_PROGRESSDIALOG
-#endif
-#ifndef QT_NO_WIZARD
-# define QT_NO_WIZARD
-#endif
-
-/* File I/O */
-#ifndef QT_NO_DOM
-# define QT_NO_DOM
-#endif
-#ifndef QT_NO_FILESYSTEMWATCHER
-# define QT_NO_FILESYSTEMWATCHER
-#endif
-#ifndef QT_NO_FILESYSTEMMODEL
-# define QT_NO_FILESYSTEMMODEL
-#endif
-#ifndef QT_NO_PROCESS
-# define QT_NO_PROCESS
-#endif
-#ifndef QT_NO_TEMPORARYFILE
-# define QT_NO_TEMPORARYFILE
-#endif
-#ifndef QT_NO_SETTINGS
-# define QT_NO_SETTINGS
-#endif
-#ifndef QT_NO_LIBRARY
-# define QT_NO_LIBRARY
-#endif
-
-/* Fonts */
-#ifndef QT_NO_FREETYPE
-# define QT_NO_FREETYPE
-#endif
-
-/* Images */
-#ifndef QT_NO_IMAGEFORMATPLUGIN
-# define QT_NO_IMAGEFORMATPLUGIN
-#endif
-#ifndef QT_NO_IMAGEFORMAT_BMP
-# define QT_NO_IMAGEFORMAT_BMP
-#endif
-#ifndef QT_NO_IMAGEFORMAT_JPEG
-# define QT_NO_IMAGEFORMAT_JPEG
-#endif
-#ifndef QT_NO_IMAGEFORMAT_PNG
-# define QT_NO_IMAGEFORMAT_PNG
-#endif
-#ifndef QT_NO_IMAGEFORMAT_PPM
-# define QT_NO_IMAGEFORMAT_PPM
-#endif
-#ifndef QT_NO_IMAGEFORMAT_XBM
-# define QT_NO_IMAGEFORMAT_XBM
-#endif
-#ifndef QT_NO_IMAGEFORMAT_XPM
-# define QT_NO_IMAGEFORMAT_XPM
-#endif
-#ifndef QT_NO_IMAGE_HEURISTIC_MASK
-# define QT_NO_IMAGE_HEURISTIC_MASK
-#endif
-#ifndef QT_NO_MOVIE
-# define QT_NO_MOVIE
-#endif
-
-/* Internationalization */
-#ifndef QT_NO_BIG_CODECS
-# define QT_NO_BIG_CODECS
-#endif
-#ifndef QT_NO_TEXTCODEC
-# define QT_NO_TEXTCODEC
-#endif
-#ifndef QT_NO_CODECS
-# define QT_NO_CODECS
-#endif
-#ifndef QT_NO_TRANSLATION
-# define QT_NO_TRANSLATION
-#endif
-
-/* ItemViews */
-#ifndef QT_NO_ITEMVIEWS
-# define QT_NO_ITEMVIEWS
-#endif
-#ifndef QT_NO_DATAWIDGETMAPPER
-# define QT_NO_DATAWIDGETMAPPER
-#endif
-#ifndef QT_NO_DIRMODEL
-# define QT_NO_DIRMODEL
-#endif
-#ifndef QT_NO_LISTVIEW
-# define QT_NO_LISTVIEW
-#endif
-#ifndef QT_NO_COLUMNVIEW
-# define QT_NO_COLUMNVIEW
-#endif
-#ifndef QT_NO_PROXYMODEL
-# define QT_NO_PROXYMODEL
-#endif
-#ifndef QT_NO_SORTFILTERPROXYMODEL
-# define QT_NO_SORTFILTERPROXYMODEL
-#endif
-#ifndef QT_NO_STANDARDITEMMODEL
-# define QT_NO_STANDARDITEMMODEL
-#endif
-#ifndef QT_NO_STRINGLISTMODEL
-# define QT_NO_STRINGLISTMODEL
-#endif
-#ifndef QT_NO_TABLEVIEW
-# define QT_NO_TABLEVIEW
-#endif
-#ifndef QT_NO_TREEVIEW
-# define QT_NO_TREEVIEW
-#endif
-
-/* Kernel */
-#ifndef QT_NO_ACTION
-# define QT_NO_ACTION
-#endif
-#ifndef QT_NO_CLIPBOARD
-# define QT_NO_CLIPBOARD
-#endif
-#ifndef QT_NO_CSSPARSER
-# define QT_NO_CSSPARSER
-#endif
-#ifndef QT_NO_CURSOR
-# define QT_NO_CURSOR
-#endif
-#ifndef QT_NO_DRAGANDDROP
-# define QT_NO_DRAGANDDROP
-#endif
-#ifndef QT_NO_EFFECTS
-# define QT_NO_EFFECTS
-#endif
-#ifndef QT_NO_PROPERTIES
-# define QT_NO_PROPERTIES
-#endif
-#ifndef QT_NO_SESSIONMANAGER
-# define QT_NO_SESSIONMANAGER
-#endif
-#ifndef QT_NO_SHAREDMEMORY
-# define QT_NO_SHAREDMEMORY
-#endif
-#ifndef QT_NO_SHORTCUT
-# define QT_NO_SHORTCUT
-#endif
-#ifndef QT_NO_SYSTEMSEMAPHORE
-# define QT_NO_SYSTEMSEMAPHORE
-#endif
-#ifndef QT_NO_TABLETEVENT
-# define QT_NO_TABLETEVENT
-#endif
-#ifndef QT_NO_TEXTHTMLPARSER
-# define QT_NO_TEXTHTMLPARSER
-#endif
-#ifndef QT_NO_CONCURRENT
-# define QT_NO_CONCURRENT
-#endif
-#ifndef QT_NO_WHEELEVENT
-# define QT_NO_WHEELEVENT
-#endif
-#ifndef QT_NO_XMLSTREAM
-# define QT_NO_XMLSTREAM
-#endif
-#ifndef QT_NO_XMLSTREAMREADER
-# define QT_NO_XMLSTREAMREADER
-#endif
-#ifndef QT_NO_XMLSTREAMWRITER
-# define QT_NO_XMLSTREAMWRITER
-#endif
-
-/* Networking */
-#ifndef QT_NO_HTTP
-# define QT_NO_HTTP
-#endif
-#ifndef QT_NO_NETWORKPROXY
-# define QT_NO_NETWORKPROXY
-#endif
-#ifndef QT_NO_SOCKS5
-# define QT_NO_SOCKS5
-#endif
-#ifndef QT_NO_UDPSOCKET
-# define QT_NO_UDPSOCKET
-#endif
-#ifndef QT_NO_FTP
-# define QT_NO_FTP
-#endif
-
-/* Painting */
-#ifndef QT_NO_COLORNAMES
-# define QT_NO_COLORNAMES
-#endif
-#ifndef QT_NO_PAINT_DEBUG
-# define QT_NO_PAINT_DEBUG
-#endif
-#ifndef QT_NO_PICTURE
-# define QT_NO_PICTURE
-#endif
-#ifndef QT_NO_PRINTER
-# define QT_NO_PRINTER
-#endif
-#ifndef QT_NO_CUPS
-# define QT_NO_CUPS
-#endif
-
-/* Styles */
-#ifndef QT_NO_STYLE_FUSION
-# define QT_NO_STYLE_FUSION
-#endif
-#ifndef QT_NO_STYLE_STYLESHEET
-# define QT_NO_STYLE_STYLESHEET
-#endif
-#ifndef QT_NO_STYLE_WINDOWSCE
-# define QT_NO_STYLE_WINDOWSCE
-#endif
-#ifndef QT_NO_STYLE_WINDOWSMOBILE
-# define QT_NO_STYLE_WINDOWSMOBILE
-#endif
-#ifndef QT_NO_STYLE_WINDOWSVISTA
-# define QT_NO_STYLE_WINDOWSVISTA
-#endif
-#ifndef QT_NO_STYLE_WINDOWSXP
-# define QT_NO_STYLE_WINDOWSXP
-#endif
-
-/* Utilities */
-#ifndef QT_NO_ACCESSIBILITY
-# define QT_NO_ACCESSIBILITY
-#endif
-#ifndef QT_NO_COMPLETER
-# define QT_NO_COMPLETER
-#endif
-#ifndef QT_NO_DESKTOPSERVICES
-# define QT_NO_DESKTOPSERVICES
-#endif
-#ifndef QT_NO_MIMETYPE
-# define QT_NO_MIMETYPE
-#endif
-#ifndef QT_NO_SYSTEMTRAYICON
-# define QT_NO_SYSTEMTRAYICON
-#endif
-#ifndef QT_NO_UNDOCOMMAND
-# define QT_NO_UNDOCOMMAND
-#endif
-#ifndef QT_NO_UNDOGROUP
-# define QT_NO_UNDOGROUP
-#endif
-#ifndef QT_NO_UNDOSTACK
-# define QT_NO_UNDOSTACK
-#endif
-#ifndef QT_NO_UNDOVIEW
-# define QT_NO_UNDOVIEW
-#endif
-#ifndef QT_NO_GESTURES
-# define QT_NO_GESTURES
-#endif
-
-/* Widgets */
-#ifndef QT_NO_GROUPBOX
-# define QT_NO_GROUPBOX
-#endif
-#ifndef QT_NO_BUTTONGROUP
-# define QT_NO_BUTTONGROUP
-#endif
-#ifndef QT_NO_LCDNUMBER
-# define QT_NO_LCDNUMBER
-#endif
-#ifndef QT_NO_LINEEDIT
-# define QT_NO_LINEEDIT
-#endif
-#ifndef QT_NO_COMBOBOX
-# define QT_NO_COMBOBOX
-#endif
-#ifndef QT_NO_FONTCOMBOBOX
-# define QT_NO_FONTCOMBOBOX
-#endif
-#ifndef QT_NO_SPINBOX
-# define QT_NO_SPINBOX
-#endif
-#ifndef QT_NO_CALENDARWIDGET
-# define QT_NO_CALENDARWIDGET
-#endif
-#ifndef QT_NO_DATETIMEEDIT
-# define QT_NO_DATETIMEEDIT
-#endif
-#ifndef QT_NO_LISTWIDGET
-# define QT_NO_LISTWIDGET
-#endif
-#ifndef QT_NO_MENU
-# define QT_NO_MENU
-#endif
-#ifndef QT_NO_CONTEXTMENU
-# define QT_NO_CONTEXTMENU
-#endif
-#ifndef QT_NO_MAINWINDOW
-# define QT_NO_MAINWINDOW
-#endif
-#ifndef QT_NO_DOCKWIDGET
-# define QT_NO_DOCKWIDGET
-#endif
-#ifndef QT_NO_TOOLBAR
-# define QT_NO_TOOLBAR
-#endif
-#ifndef QT_NO_MENUBAR
-# define QT_NO_MENUBAR
-#endif
-#ifndef QT_NO_PROGRESSBAR
-# define QT_NO_PROGRESSBAR
-#endif
-#ifndef QT_NO_RESIZEHANDLER
-# define QT_NO_RESIZEHANDLER
-#endif
-#ifndef QT_NO_RUBBERBAND
-# define QT_NO_RUBBERBAND
-#endif
-#ifndef QT_NO_SPLITTER
-# define QT_NO_SPLITTER
-#endif
-#ifndef QT_NO_SIZEGRIP
-# define QT_NO_SIZEGRIP
-#endif
-#ifndef QT_NO_SLIDER
-# define QT_NO_SLIDER
-#endif
-#ifndef QT_NO_DIAL
-# define QT_NO_DIAL
-#endif
-#ifndef QT_NO_SCROLLBAR
-# define QT_NO_SCROLLBAR
-#endif
-#ifndef QT_NO_SCROLLAREA
-# define QT_NO_SCROLLAREA
-#endif
-#ifndef QT_NO_GRAPHICSVIEW
-# define QT_NO_GRAPHICSVIEW
-#endif
-#ifndef QT_NO_PRINTPREVIEWWIDGET
-# define QT_NO_PRINTPREVIEWWIDGET
-#endif
-#ifndef QT_NO_MDIAREA
-# define QT_NO_MDIAREA
-#endif
-#ifndef QT_NO_TEXTEDIT
-# define QT_NO_TEXTEDIT
-#endif
-#ifndef QT_NO_SYNTAXHIGHLIGHTER
-# define QT_NO_SYNTAXHIGHLIGHTER
-#endif
-#ifndef QT_NO_TEXTBROWSER
-# define QT_NO_TEXTBROWSER
-#endif
-#ifndef QT_NO_SPINWIDGET
-# define QT_NO_SPINWIDGET
-#endif
-#ifndef QT_NO_SPLASHSCREEN
-# define QT_NO_SPLASHSCREEN
-#endif
-#ifndef QT_NO_STACKEDWIDGET
-# define QT_NO_STACKEDWIDGET
-#endif
-#ifndef QT_NO_TABWIDGET
-# define QT_NO_TABWIDGET
-#endif
-#ifndef QT_NO_STATUSBAR
-# define QT_NO_STATUSBAR
-#endif
-#ifndef QT_NO_STATUSTIP
-# define QT_NO_STATUSTIP
-#endif
-#ifndef QT_NO_TABLEWIDGET
-# define QT_NO_TABLEWIDGET
-#endif
-#ifndef QT_NO_TOOLBUTTON
-# define QT_NO_TOOLBUTTON
-#endif
-#ifndef QT_NO_TABBAR
-# define QT_NO_TABBAR
-#endif
-#ifndef QT_NO_TOOLBOX
-# define QT_NO_TOOLBOX
-#endif
-#ifndef QT_NO_WHATSTHIS
-# define QT_NO_WHATSTHIS
-#endif
-#ifndef QT_NO_TOOLTIP
-# define QT_NO_TOOLTIP
-#endif
-#ifndef QT_NO_TREEWIDGET
-# define QT_NO_TREEWIDGET
-#endif
-#ifndef QT_NO_VALIDATOR
-# define QT_NO_VALIDATOR
-#endif
diff --git a/src/corelib/global/qconfig-nacl.h b/src/corelib/global/qconfig-nacl.h
deleted file mode 100644
index 10292c05c3..0000000000
--- a/src/corelib/global/qconfig-nacl.h
+++ /dev/null
@@ -1,233 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#if 0
-#pragma qt_sync_stop_processing
-#endif
-
-#define QT_FONTS_ARE_RESOURCES
-
-/* Data structures */
-#ifndef QT_NO_TEXTDATE
-# define QT_NO_TEXTDATE
-#endif
-#ifndef QT_NO_DATESTRING
-# define QT_NO_DATESTRING
-#endif
-
-/* Dialogs */
-#ifndef QT_NO_FILEDIALOG
-# define QT_NO_FILEDIALOG
-#endif
-#ifndef QT_NO_PRINTDIALOG
-# define QT_NO_PRINTDIALOG
-#endif
-#ifndef QT_NO_PRINTPREVIEWDIALOG
-# define QT_NO_PRINTPREVIEWDIALOG
-#endif
-
-
-/* File I/O */
-#ifndef QT_NO_DOM
-# define QT_NO_DOM
-#endif
-#ifndef QT_NO_FILESYSTEMWATCHER
-# define QT_NO_FILESYSTEMWATCHER
-#endif
-#ifndef QT_NO_FILESYSTEMMODEL
-# define QT_NO_FILESYSTEMMODEL
-#endif
-#ifndef QT_NO_FILESYSTEMMODEL
-# define QT_NO_FILESYSTEMMODEL
-#endif
-#ifndef QT_NO_PROCESS
-# define QT_NO_PROCESS
-#endif
-#ifndef QT_NO_TEMPORARYFILE
-# define QT_NO_TEMPORARYFILE
-#endif
-#ifndef QT_NO_SETTINGS
-# define QT_NO_SETTINGS
-#endif
-#ifndef QT_NO_LIBRARY
-# define QT_NO_LIBRARY
-#endif
-
-/* Images */
-#ifndef QT_NO_IMAGEFORMATPLUGIN
-# define QT_NO_IMAGEFORMATPLUGIN
-#endif
-#ifndef QT_NO_IMAGE_HEURISTIC_MASK
-# define QT_NO_IMAGE_HEURISTIC_MASK
-#endif
-#ifndef QT_NO_MOVIE
-# define QT_NO_MOVIE
-#endif
-
-/* Internationalization */
-#ifndef QT_NO_BIG_CODECS
-# define QT_NO_BIG_CODECS
-#endif
-#ifndef QT_NO_TEXTCODEC
-# define QT_NO_TEXTCODEC
-#endif
-#ifndef QT_NO_CODECS
-# define QT_NO_CODECS
-#endif
-#ifndef QT_NO_TRANSLATION
-# define QT_NO_TRANSLATION
-#endif
-
-/* ItemViews */
-
-#ifndef QT_NO_DIRMODEL
-# define QT_NO_DIRMODEL
-#endif
-
-/* Kernel */
-#ifndef QT_NO_CLIPBOARD
-# define QT_NO_CLIPBOARD
-#endif
-#ifndef QT_NO_CSSPARSER
-# define QT_NO_CSSPARSER
-#endif
-#ifndef QT_NO_CURSOR
-# define QT_NO_CURSOR
-#endif
-#ifndef QT_NO_DRAGANDDROP
-# define QT_NO_DRAGANDDROP
-#endif
-#ifndef QT_NO_EFFECTS
-# define QT_NO_EFFECTS
-#endif
-#ifndef QT_NO_SESSIONMANAGER
-# define QT_NO_SESSIONMANAGER
-#endif
-#ifndef QT_NO_SHAREDMEMORY
-# define QT_NO_SHAREDMEMORY
-#endif
-#ifndef QT_NO_SYSTEMLOCALE
-# define QT_NO_SYSTEMSEMAPHORE
-#endif
-#ifndef QT_NO_SYSTEMSEMAPHORE
-# define QT_NO_SYSTEMSEMAPHORE
-#endif
-#ifndef QT_NO_TABLETEVENT
-# define QT_NO_TABLETEVENT
-#endif
-#ifndef QT_NO_CRASHHANDLER
-# define QT_NO_CRASHHANDLER
-#endif
-#ifndef QT_NO_CONCURRENT
-# define QT_NO_CONCURRENT
-#endif
-#ifndef QT_NO_XMLSTREAM
-# define QT_NO_XMLSTREAM
-#endif
-#ifndef QT_NO_XMLSTREAMREADER
-# define QT_NO_XMLSTREAMREADER
-#endif
-#ifndef QT_NO_XMLSTREAMWRITER
-# define QT_NO_XMLSTREAMWRITER
-#endif
-
-/* Networking */
-#ifndef QT_NO_HTTP
-# define QT_NO_HTTP
-#endif
-#ifndef QT_NO_NETWORKPROXY
-# define QT_NO_NETWORKPROXY
-#endif
-#ifndef QT_NO_SOCKS5
-# define QT_NO_SOCKS5
-#endif
-#ifndef QT_NO_UDPSOCKET
-# define QT_NO_UDPSOCKET
-#endif
-#ifndef QT_NO_FTP
-# define QT_NO_FTP
-#endif
-
-/* Painting */
-#ifndef QT_NO_COLORNAMES
-# define QT_NO_COLORNAMES
-#endif
-#ifndef QT_NO_PAINT_DEBUG
-# define QT_NO_PAINT_DEBUG
-#endif
-#ifndef QT_NO_PICTURE
-# define QT_NO_PICTURE
-#endif
-#ifndef QT_NO_PRINTER
-# define QT_NO_PRINTER
-#endif
-#ifndef QT_NO_CUPS
-# define QT_NO_CUPS
-#endif
-
-/* Styles */
-#ifndef QT_NO_STYLE_STYLESHEET
-# define QT_NO_STYLE_STYLESHEET
-#endif
-#ifndef QT_NO_STYLE_WINDOWSCE
-# define QT_NO_STYLE_WINDOWSCE
-#endif
-#ifndef QT_NO_STYLE_WINDOWSMOBILE
-# define QT_NO_STYLE_WINDOWSMOBILE
-#endif
-#ifndef QT_NO_STYLE_WINDOWSVISTA
-# define QT_NO_STYLE_WINDOWSVISTA
-#endif
-#ifndef QT_NO_STYLE_WINDOWSXP
-# define QT_NO_STYLE_WINDOWSXP
-#endif
-
-/* Utilities */
-#ifndef QT_NO_ACCESSIBILITY
-# define QT_NO_ACCESSIBILITY
-#endif
-#ifndef QT_NO_COMPLETER
-# define QT_NO_COMPLETER
-#endif
-#ifndef QT_NO_DESKTOPSERVICES
-# define QT_NO_DESKTOPSERVICES
-#endif
-#ifndef QT_NO_SYSTEMTRAYICON
-# define QT_NO_SYSTEMTRAYICON
-#endif
diff --git a/src/corelib/global/qconfig-small.h b/src/corelib/global/qconfig-small.h
deleted file mode 100644
index 1f1bff91a3..0000000000
--- a/src/corelib/global/qconfig-small.h
+++ /dev/null
@@ -1,281 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/* Dialogs */
-#ifndef QT_NO_COLORDIALOG
-# define QT_NO_COLORDIALOG
-#endif
-#ifndef QT_NO_ERRORMESSAGE
-# define QT_NO_ERRORMESSAGE
-#endif
-#ifndef QT_NO_FILEDIALOG
-# define QT_NO_FILEDIALOG
-#endif
-#ifndef QT_NO_FONTDIALOG
-# define QT_NO_FONTDIALOG
-#endif
-#ifndef QT_NO_INPUTDIALOG
-# define QT_NO_INPUTDIALOG
-#endif
-#ifndef QT_NO_MESSAGEBOX
-# define QT_NO_MESSAGEBOX
-#endif
-#ifndef QT_NO_PRINTDIALOG
-# define QT_NO_PRINTDIALOG
-#endif
-#ifndef QT_NO_PROGRESSDIALOG
-# define QT_NO_PROGRESSDIALOG
-#endif
-
-/* File I/O */
-#ifndef QT_NO_SETTINGS
-# define QT_NO_SETTINGS
-#endif
-#ifndef QT_NO_LIBRARY
-# define QT_NO_LIBRARY
-#endif
-
-/* Fonts */
-#ifndef QT_NO_FREETYPE
-# define QT_NO_FREETYPE
-#endif
-
-/* Images */
-#ifndef QT_NO_IMAGEFORMATPLUGIN
-# define QT_NO_IMAGEFORMATPLUGIN
-#endif
-#ifndef QT_NO_IMAGEFORMAT_BMP
-# define QT_NO_IMAGEFORMAT_BMP
-#endif
-#ifndef QT_NO_IMAGEFORMAT_JPEG
-# define QT_NO_IMAGEFORMAT_JPEG
-#endif
-#ifndef QT_NO_IMAGEFORMAT_PPM
-# define QT_NO_IMAGEFORMAT_PPM
-#endif
-#ifndef QT_NO_IMAGEFORMAT_XBM
-# define QT_NO_IMAGEFORMAT_XBM
-#endif
-#ifndef QT_NO_IMAGEFORMAT_XPM
-# define QT_NO_IMAGEFORMAT_XPM
-#endif
-#ifndef QT_NO_MOVIE
-# define QT_NO_MOVIE
-#endif
-
-/* Internationalization */
-#ifndef QT_NO_TEXTCODEC
-# define QT_NO_TEXTCODEC
-#endif
-#ifndef QT_NO_CODECS
-# define QT_NO_CODECS
-#endif
-#ifndef QT_NO_TRANSLATION
-# define QT_NO_TRANSLATION
-#endif
-
-/* ItemViews */
-#ifndef QT_NO_DIRMODEL
-# define QT_NO_DIRMODEL
-#endif
-#ifndef QT_NO_PROXYMODEL
-# define QT_NO_PROXYMODEL
-#endif
-#ifndef QT_NO_SORTFILTERPROXYMODEL
-# define QT_NO_SORTFILTERPROXYMODEL
-#endif
-#ifndef QT_NO_STRINGLISTMODEL
-# define QT_NO_STRINGLISTMODEL
-#endif
-#ifndef QT_NO_TABLEVIEW
-# define QT_NO_TABLEVIEW
-#endif
-#ifndef QT_NO_TREEVIEW
-# define QT_NO_TREEVIEW
-#endif
-
-/* Kernel */
-#ifndef QT_NO_ACTION
-# define QT_NO_ACTION
-#endif
-#ifndef QT_NO_CLIPBOARD
-# define QT_NO_CLIPBOARD
-#endif
-#ifndef QT_NO_DRAGANDDROP
-# define QT_NO_DRAGANDDROP
-#endif
-#ifndef QT_NO_EFFECTS
-# define QT_NO_EFFECTS
-#endif
-#ifndef QT_NO_PROPERTIES
-# define QT_NO_PROPERTIES
-#endif
-#ifndef QT_NO_SESSIONMANAGER
-# define QT_NO_SESSIONMANAGER
-#endif
-#ifndef QT_NO_SHORTCUT
-# define QT_NO_SHORTCUT
-#endif
-#ifndef QT_NO_WHEELEVENT
-# define QT_NO_WHEELEVENT
-#endif
-
-/* Networking */
-#ifndef QT_NO_HTTP
-# define QT_NO_HTTP
-#endif
-
-/* Painting */
-#ifndef QT_NO_COLORNAMES
-# define QT_NO_COLORNAMES
-#endif
-#ifndef QT_NO_PICTURE
-# define QT_NO_PICTURE
-#endif
-#ifndef QT_NO_PRINTER
-# define QT_NO_PRINTER
-#endif
-#ifndef QT_NO_CUPS
-# define QT_NO_CUPS
-#endif
-
-/* Styles */
-#ifndef QT_NO_STYLE_FUSION
-# define QT_NO_STYLE_FUSION
-#endif
-#ifndef QT_NO_STYLE_STYLESHEET
-# define QT_NO_STYLE_STYLESHEET
-#endif
-#ifndef QT_NO_STYLE_WINDOWSVISTA
-# define QT_NO_STYLE_WINDOWSVISTA
-#endif
-
-/* Utilities */
-#ifndef QT_NO_COMPLETER
-# define QT_NO_COMPLETER
-#endif
-#ifndef QT_NO_DESKTOPSERVICES
-# define QT_NO_DESKTOPSERVICES
-#endif
-#ifndef QT_NO_MIMETYPE
-# define QT_NO_MIMETYPE
-#endif
-#ifndef QT_NO_SYSTEMTRAYICON
-# define QT_NO_SYSTEMTRAYICON
-#endif
-#ifndef QT_NO_GESTURES
-# define QT_NO_GESTURES
-#endif
-
-/* Widgets */
-#ifndef QT_NO_LCDNUMBER
-# define QT_NO_LCDNUMBER
-#endif
-#ifndef QT_NO_FONTCOMBOBOX
-# define QT_NO_FONTCOMBOBOX
-#endif
-#ifndef QT_NO_SPINBOX
-# define QT_NO_SPINBOX
-#endif
-#ifndef QT_NO_CALENDARWIDGET
-# define QT_NO_CALENDARWIDGET
-#endif
-#ifndef QT_NO_DATETIMEEDIT
-# define QT_NO_DATETIMEEDIT
-#endif
-#ifndef QT_NO_MENU
-# define QT_NO_MENU
-#endif
-#ifndef QT_NO_CONTEXTMENU
-# define QT_NO_CONTEXTMENU
-#endif
-#ifndef QT_NO_MAINWINDOW
-# define QT_NO_MAINWINDOW
-#endif
-#ifndef QT_NO_DOCKWIDGET
-# define QT_NO_DOCKWIDGET
-#endif
-#ifndef QT_NO_TOOLBAR
-# define QT_NO_TOOLBAR
-#endif
-#ifndef QT_NO_MENUBAR
-# define QT_NO_MENUBAR
-#endif
-#ifndef QT_NO_PROGRESSBAR
-# define QT_NO_PROGRESSBAR
-#endif
-#ifndef QT_NO_SPLITTER
-# define QT_NO_SPLITTER
-#endif
-#ifndef QT_NO_SIZEGRIP
-# define QT_NO_SIZEGRIP
-#endif
-#ifndef QT_NO_STACKEDWIDGET
-# define QT_NO_STACKEDWIDGET
-#endif
-#ifndef QT_NO_TABWIDGET
-# define QT_NO_TABWIDGET
-#endif
-#ifndef QT_NO_STATUSBAR
-# define QT_NO_STATUSBAR
-#endif
-#ifndef QT_NO_TABLEWIDGET
-# define QT_NO_TABLEWIDGET
-#endif
-#ifndef QT_NO_TOOLBUTTON
-# define QT_NO_TOOLBUTTON
-#endif
-#ifndef QT_NO_TABBAR
-# define QT_NO_TABBAR
-#endif
-#ifndef QT_NO_TOOLBOX
-# define QT_NO_TOOLBOX
-#endif
-#ifndef QT_NO_WHATSTHIS
-# define QT_NO_WHATSTHIS
-#endif
-#ifndef QT_NO_TOOLTIP
-# define QT_NO_TOOLTIP
-#endif
-#ifndef QT_NO_TREEWIDGET
-# define QT_NO_TREEWIDGET
-#endif
-#ifndef QT_NO_VALIDATOR
-# define QT_NO_VALIDATOR
-#endif
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h
index b907caa9b6..a6bd37c33f 100644
--- a/src/corelib/global/qflags.h
+++ b/src/corelib/global/qflags.h
@@ -111,8 +111,8 @@ public:
typedef Enum enum_type;
// compiler-generated copy/move ctor/assignment operators are fine!
#ifdef Q_QDOC
- inline QFlags(const QFlags &other);
- inline QFlags &operator=(const QFlags &other);
+ Q_DECL_CONSTEXPR inline QFlags(const QFlags &other);
+ Q_DECL_CONSTEXPR inline QFlags &operator=(const QFlags &other);
#endif
Q_DECL_CONSTEXPR inline QFlags(Enum f) Q_DECL_NOTHROW : i(Int(f)) {}
Q_DECL_CONSTEXPR inline QFlags(Zero = Q_NULLPTR) Q_DECL_NOTHROW : i(0) {}
@@ -163,8 +163,10 @@ private:
Int i;
};
+#ifndef Q_MOC_RUN
#define Q_DECLARE_FLAGS(Flags, Enum)\
typedef QFlags<Enum> Flags;
+#endif
#define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) \
Q_DECL_CONSTEXPR inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) Q_DECL_NOTHROW \
@@ -179,8 +181,11 @@ Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1,
#else /* Q_NO_TYPESAFE_FLAGS */
+#ifndef Q_MOC_RUN
#define Q_DECLARE_FLAGS(Flags, Enum)\
typedef uint Flags;
+#endif
+
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
#endif /* Q_NO_TYPESAFE_FLAGS */
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 79ced22c0f..e05b7874e5 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -47,7 +47,6 @@
#include "qdatetime.h"
#include <private/qlocale_tools_p.h>
-#include <private/qsystemlibrary_p.h>
#include <qmutex.h>
#ifndef QT_NO_QOBJECT
@@ -64,11 +63,9 @@
# include <exception>
#endif
-#if !defined(Q_OS_WINCE)
-# include <errno.h>
-# if defined(Q_CC_MSVC)
-# include <crtdbg.h>
-# endif
+#include <errno.h>
+#if defined(Q_CC_MSVC)
+# include <crtdbg.h>
#endif
#ifdef Q_OS_WINRT
@@ -573,11 +570,11 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in
\snippet code/src_corelib_global_qglobal.cpp 4
The remaining functions are qRound() and qRound64(), which both
- accept a \l qreal value as their argument returning the value
- rounded up to the nearest integer and 64-bit integer respectively,
- the qInstallMessageHandler() function which installs the given
- QtMessageHandler, and the qVersion() function which returns the
- version number of Qt at run-time as a string.
+ accept a \c double or \c float value as their argument returning
+ the value rounded up to the nearest integer and 64-bit integer
+ respectively, the qInstallMessageHandler() function which installs
+ the given QtMessageHandler, and the qVersion() function which
+ returns the version number of Qt at run-time as a string.
\section1 Macros
@@ -864,24 +861,44 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in
\snippet code/src_corelib_global_qglobal.cpp 10
*/
-/*! \fn int qRound(qreal value)
+/*! \fn int qRound(double value)
+ \relates <QtGlobal>
+
+ Rounds \a value to the nearest integer.
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp 11A
+*/
+
+/*! \fn int qRound(float value)
\relates <QtGlobal>
Rounds \a value to the nearest integer.
Example:
- \snippet code/src_corelib_global_qglobal.cpp 11
+ \snippet code/src_corelib_global_qglobal.cpp 11B
+*/
+
+/*! \fn qint64 qRound64(double value)
+ \relates <QtGlobal>
+
+ Rounds \a value to the nearest 64-bit integer.
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp 12A
*/
-/*! \fn qint64 qRound64(qreal value)
+/*! \fn qint64 qRound64(float value)
\relates <QtGlobal>
Rounds \a value to the nearest 64-bit integer.
Example:
- \snippet code/src_corelib_global_qglobal.cpp 12
+ \snippet code/src_corelib_global_qglobal.cpp 12B
*/
/*! \fn const T &qMin(const T &value1, const T &value2)
@@ -1016,7 +1033,7 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in
example, "4.1.2"). This may be a different version than the
version the application was compiled against.
- \sa QT_VERSION_STR
+ \sa QT_VERSION_STR, QLibraryInfo::version()
*/
const char *qVersion() Q_DECL_NOTHROW
@@ -1147,19 +1164,11 @@ bool qSharedBuild() Q_DECL_NOTHROW
\value WV_6_3 Operating system version 6.3, corresponds to Windows 8.1, introduced in Qt 5.2
\value WV_10_0 Operating system version 10.0, corresponds to Windows 10, introduced in Qt 5.5
- CE-based versions:
-
- \value WV_CE Windows CE
- \value WV_CENET Windows CE .NET
- \value WV_CE_5 Windows CE 5.x
- \value WV_CE_6 Windows CE 6.x
-
The following masks can be used for testing whether a Windows
version is MS-DOS-based, NT-based, or CE-based:
\value WV_DOS_based MS-DOS-based version of Windows
\value WV_NT_based NT-based version of Windows
- \value WV_CE_based CE-based version of Windows
\value WV_None Operating system other than Windows.
@@ -1223,6 +1232,12 @@ bool qSharedBuild() Q_DECL_NOTHROW
\value MV_IOS_9_3 iOS 9.3
\value MV_IOS_10_0 iOS 10.0
+ \value MV_TVOS tvOS (any)
+ \value MV_TVOS_9_0 tvOS 9.0
+ \value MV_TVOS_9_1 tvOS 9.1
+ \value MV_TVOS_9_2 tvOS 9.2
+ \value MV_TVOS_10_0 tvOS 10.0
+
\value MV_None Not a Darwin operating system
\sa WinVersion
@@ -1232,7 +1247,7 @@ bool qSharedBuild() Q_DECL_NOTHROW
\macro Q_OS_DARWIN
\relates <QtGlobal>
- Defined on Darwin-based operating systems such as \macos, iOS, watchOS, and tvOS.
+ Defined on Darwin-based operating systems such as \macOS, iOS, watchOS, and tvOS.
*/
/*!
@@ -1282,7 +1297,7 @@ bool qSharedBuild() Q_DECL_NOTHROW
\relates <QtGlobal>
Defined on all supported versions of Windows. That is, if
- \l Q_OS_WIN32, \l Q_OS_WIN64, \l Q_OS_WINCE or \l Q_OS_WINRT is defined.
+ \l Q_OS_WIN32, \l Q_OS_WIN64 or \l Q_OS_WINRT is defined.
*/
/*!
@@ -1300,13 +1315,6 @@ bool qSharedBuild() Q_DECL_NOTHROW
*/
/*!
- \macro Q_OS_WINCE
- \relates <QtGlobal>
-
- Defined on Windows CE.
-*/
-
-/*!
\macro Q_OS_WINRT
\relates <QtGlobal>
@@ -1936,13 +1944,35 @@ QSysInfo::MacVersion QSysInfo::macVersion()
return QSysInfo::MacVersion(Q_MV_OSX(version.major, version.minor));
#elif defined(Q_OS_IOS)
return QSysInfo::MacVersion(Q_MV_IOS(version.major, version.minor));
+#elif defined(Q_OS_TVOS)
+ return QSysInfo::MacVersion(Q_MV_TVOS(version.major, version.minor));
#else
return QSysInfo::MV_Unknown;
#endif
}
const QSysInfo::MacVersion QSysInfo::MacintoshVersion = QSysInfo::macVersion();
-#elif defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) || defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
+#ifdef Q_OS_OSX
+static const char *osxVer_helper(QAppleOperatingSystemVersion version = qt_apple_os_version())
+{
+ if (version.major == 10) {
+ switch (version.minor) {
+ case 9:
+ return "Mavericks";
+ case 10:
+ return "Yosemite";
+ case 11:
+ return "El Capitan";
+ case 12:
+ return "Sierra";
+ }
+ }
+ // unknown, future version
+ return 0;
+}
+#endif
+
+#elif defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) || defined(Q_OS_WINRT)
QT_BEGIN_INCLUDE_NAMESPACE
#include "qt_windows.h"
@@ -1995,9 +2025,7 @@ static inline OSVERSIONINFOEX determineWinOsVersion()
{
OSVERSIONINFOEX result = { sizeof(OSVERSIONINFOEX), 0, 0, 0, 0, {'\0'}, 0, 0, 0, 0, 0};
-#ifndef Q_OS_WINCE
#define GetProcAddressA GetProcAddress
-#endif
// GetModuleHandle is not supported in WinRT and linking to it at load time
// will not pass the Windows App Certification Kit... but it exists and is functional,
@@ -2046,113 +2074,66 @@ static inline OSVERSIONINFOEX determineWinOsVersion()
static OSVERSIONINFOEX winOsVersion()
{
- static OSVERSIONINFOEX result = determineWinOsVersion();
- return result;
-}
-
-QSysInfo::WinVersion QSysInfo::windowsVersion()
-{
-#ifndef VER_PLATFORM_WIN32s
-#define VER_PLATFORM_WIN32s 0
-#endif
-#ifndef VER_PLATFORM_WIN32_WINDOWS
-#define VER_PLATFORM_WIN32_WINDOWS 1
-#endif
-#ifndef VER_PLATFORM_WIN32_NT
-#define VER_PLATFORM_WIN32_NT 2
-#endif
-#ifndef VER_PLATFORM_WIN32_CE
-#define VER_PLATFORM_WIN32_CE 3
-#endif
-
- static QSysInfo::WinVersion winver;
- if (winver)
- return winver;
- winver = QSysInfo::WV_NT;
- const OSVERSIONINFOEX osver = winOsVersion();
- if (osver.dwMajorVersion == 0)
- return QSysInfo::WV_None;
-#ifdef Q_OS_WINCE
- DWORD qt_cever = 0;
- qt_cever = osver.dwMajorVersion * 100;
- qt_cever += osver.dwMinorVersion * 10;
-#endif
- switch (osver.dwPlatformId) {
- case VER_PLATFORM_WIN32s:
- winver = QSysInfo::WV_32s;
- break;
- case VER_PLATFORM_WIN32_WINDOWS:
- // We treat Windows Me (minor 90) the same as Windows 98
- if (osver.dwMinorVersion == 90)
- winver = QSysInfo::WV_Me;
- else if (osver.dwMinorVersion == 10)
- winver = QSysInfo::WV_98;
- else
- winver = QSysInfo::WV_95;
- break;
-#ifdef Q_OS_WINCE
- case VER_PLATFORM_WIN32_CE:
- if (qt_cever >= 600)
- winver = QSysInfo::WV_CE_6;
- if (qt_cever >= 500)
- winver = QSysInfo::WV_CE_5;
- else if (qt_cever >= 400)
- winver = QSysInfo::WV_CENET;
- else
- winver = QSysInfo::WV_CE;
- break;
-#endif
- default: // VER_PLATFORM_WIN32_NT
- if (osver.dwMajorVersion < 5) {
- winver = QSysInfo::WV_NT;
- } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 0) {
- winver = QSysInfo::WV_2000;
- } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 1) {
- winver = QSysInfo::WV_XP;
- } else if (osver.dwMajorVersion == 5 && osver.dwMinorVersion == 2) {
- winver = QSysInfo::WV_2003;
- } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 0) {
- winver = QSysInfo::WV_VISTA;
- } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 1) {
- winver = QSysInfo::WV_WINDOWS7;
- } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 2) {
- winver = QSysInfo::WV_WINDOWS8;
- } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 3) {
- winver = QSysInfo::WV_WINDOWS8_1;
- } else if (osver.dwMajorVersion == 10 && osver.dwMinorVersion == 0) {
- winver = QSysInfo::WV_WINDOWS10;
- } else {
- winver = QSysInfo::WV_NT_based;
- }
- }
-
+ OSVERSIONINFOEX realResult = determineWinOsVersion();
#ifdef QT_DEBUG
{
if (Q_UNLIKELY(qEnvironmentVariableIsSet("QT_WINVER_OVERRIDE"))) {
+ OSVERSIONINFOEX result = realResult;
+ result.dwMajorVersion = 0;
+ result.dwMinorVersion = 0;
+
+ // Erase any build number and service pack information
+ result.dwBuildNumber = 0;
+ result.szCSDVersion[0] = L'\0';
+ result.wServicePackMajor = 0;
+ result.wServicePackMinor = 0;
+
const QByteArray winVerOverride = qgetenv("QT_WINVER_OVERRIDE");
- if (winVerOverride == "NT")
- winver = QSysInfo::WV_NT;
- else if (winVerOverride == "2000")
- winver = QSysInfo::WV_2000;
- else if (winVerOverride == "2003")
- winver = QSysInfo::WV_2003;
- else if (winVerOverride == "XP")
- winver = QSysInfo::WV_XP;
- else if (winVerOverride == "VISTA")
- winver = QSysInfo::WV_VISTA;
- else if (winVerOverride == "WINDOWS7")
- winver = QSysInfo::WV_WINDOWS7;
- else if (winVerOverride == "WINDOWS8")
- winver = QSysInfo::WV_WINDOWS8;
- else if (winVerOverride == "WINDOWS8_1")
- winver = QSysInfo::WV_WINDOWS8_1;
- else if (winVerOverride == "WINDOWS10")
- winver = QSysInfo::WV_WINDOWS10;
+ if (winVerOverride == "WINDOWS7" || winVerOverride == "2008_R2") {
+ result.dwMajorVersion = 6;
+ result.dwMinorVersion = 1;
+ } else if (winVerOverride == "WINDOWS8" || winVerOverride == "2012") {
+ result.dwMajorVersion = 6;
+ result.dwMinorVersion = 2;
+ } else if (winVerOverride == "WINDOWS8_1" || winVerOverride == "2012_R2") {
+ result.dwMajorVersion = 6;
+ result.dwMinorVersion = 3;
+ } else if (winVerOverride == "WINDOWS10" || winVerOverride == "2016") {
+ result.dwMajorVersion = 10;
+ } else {
+ return realResult;
+ }
+
+ if (winVerOverride == "2008_R2"
+ || winVerOverride == "2012"
+ || winVerOverride == "2012_R2"
+ || winVerOverride == "2016") {
+ // If the current host OS is a domain controller and the override OS
+ // is also a server type OS, preserve that information
+ if (result.wProductType == VER_NT_WORKSTATION)
+ result.wProductType = VER_NT_SERVER;
+ } else {
+ // Any other OS must be a workstation OS type
+ result.wProductType = VER_NT_WORKSTATION;
+ }
}
}
#endif
+ return realResult;
+}
- return winver;
+QSysInfo::WinVersion QSysInfo::windowsVersion()
+{
+ const OSVERSIONINFOEX osver = winOsVersion();
+ if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 1)
+ return QSysInfo::WV_WINDOWS7;
+ if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 2)
+ return QSysInfo::WV_WINDOWS8;
+ if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 3)
+ return QSysInfo::WV_WINDOWS8_1;
+ if (osver.dwMajorVersion == 10 && osver.dwMinorVersion == 0)
+ return QSysInfo::WV_WINDOWS10;
+ return QSysInfo::WV_NT_based;
}
static QString winSp_helper()
@@ -2171,37 +2152,21 @@ static QString winSp_helper()
static const char *winVer_helper()
{
- const bool workstation = winOsVersion().wProductType == VER_NT_WORKSTATION;
-
- switch (int(QSysInfo::WindowsVersion)) {
- case QSysInfo::WV_NT:
- return "NT";
- case QSysInfo::WV_2000:
- return "2000";
- case QSysInfo::WV_XP:
- return "XP";
- case QSysInfo::WV_2003:
- return "2003";
- case QSysInfo::WV_VISTA:
- return workstation ? "Vista" : "Server 2008";
- case QSysInfo::WV_WINDOWS7:
+ const OSVERSIONINFOEX osver = winOsVersion();
+ const bool workstation = osver.wProductType == VER_NT_WORKSTATION;
+
+#define Q_WINVER(major, minor) (major << 8 | minor)
+ switch (Q_WINVER(osver.dwMajorVersion, osver.dwMinorVersion)) {
+ case Q_WINVER(6, 1):
return workstation ? "7" : "Server 2008 R2";
- case QSysInfo::WV_WINDOWS8:
+ case Q_WINVER(6, 2):
return workstation ? "8" : "Server 2012";
- case QSysInfo::WV_WINDOWS8_1:
+ case Q_WINVER(6, 3):
return workstation ? "8.1" : "Server 2012 R2";
- case QSysInfo::WV_WINDOWS10:
+ case Q_WINVER(10, 0):
return workstation ? "10" : "Server 2016";
-
- case QSysInfo::WV_CE:
- return "CE";
- case QSysInfo::WV_CENET:
- return "CENET";
- case QSysInfo::WV_CE_5:
- return "CE5";
- case QSysInfo::WV_CE_6:
- return "CE6";
}
+#undef Q_WINVER
// unknown, future version
return 0;
}
@@ -2458,7 +2423,7 @@ QString QSysInfo::buildCpuArchitecture()
*/
QString QSysInfo::currentCpuArchitecture()
{
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
// We don't need to catch all the CPU architectures in this function;
// only those where the host CPU might be different than the build target
// (usually, 64-bit platforms).
@@ -2610,9 +2575,7 @@ static QString unknownText()
*/
QString QSysInfo::kernelType()
{
-#if defined(Q_OS_WINCE)
- return QStringLiteral("wince");
-#elif defined(Q_OS_WIN)
+#if defined(Q_OS_WIN)
return QStringLiteral("winnt");
#elif defined(Q_OS_UNIX)
struct utsname u;
@@ -2626,7 +2589,7 @@ QString QSysInfo::kernelType()
\since 5.4
Returns the release version of the operating system kernel. On Windows, it
- returns the version of the NT or CE kernel. On Unix systems, including
+ returns the version of the NT kernel. On Unix systems, including
Android and \macos, it returns the same as the \c{uname -r}
command would return.
@@ -2668,9 +2631,9 @@ QString QSysInfo::kernelVersion()
to determine the distribution name and returns that. If determining the
distribution name failed, it returns "unknown".
- \b{Darwin, \macos and iOS note}: this function returns "macos" for macOS
- systems, "ios" for iOS systems and "darwin" in case the system could not be
- determined.
+ \b{Darwin, \macOS, iOS and tvOS note}: this function returns "macos" for macOS
+ systems, "ios" for iOS systems, "tvos" for tvOS systems and "darwin" in case
+ the system could not be determined.
\b{OS X note}: this function returns "osx" for versions of \macos prior to 10.12.
@@ -2678,8 +2641,7 @@ QString QSysInfo::kernelVersion()
"unknown" otherwise.
\b{Windows note}: this function returns "winphone" for builds for Windows
- Phone, "winrt" for WinRT builds, "wince" for Windows CE and Embedded
- Compact builds, and "windows" for normal desktop builds.
+ Phone, "winrt" for WinRT builds and "windows" for normal desktop builds.
For other Unix-type systems, this function usually returns "unknown".
@@ -2692,8 +2654,6 @@ QString QSysInfo::productType()
return QStringLiteral("winphone");
#elif defined(Q_OS_WINRT)
return QStringLiteral("winrt");
-#elif defined(Q_OS_WINCE)
- return QStringLiteral("wince");
#elif defined(Q_OS_WIN)
return QStringLiteral("windows");
@@ -2705,6 +2665,8 @@ QString QSysInfo::productType()
#elif defined(Q_OS_IOS)
return QStringLiteral("ios");
+#elif defined(Q_OS_TVOS)
+ return QStringLiteral("tvos");
#elif defined(Q_OS_MACOS)
const QAppleOperatingSystemVersion version = qt_apple_os_version();
if (version.major == 10 && version.minor < 12)
@@ -2738,9 +2700,8 @@ QString QSysInfo::productType()
In all other Unix-type systems, this function always returns "unknown".
- \note The version string returned from this function is only guaranteed to
- be orderable on Android, \macos and iOS. On Windows, some Windows
- versions are text ("XP" and "Vista", for example). On Linux, the version of
+ \note The version string returned from this function is not guaranteed to
+ be orderable. On Linux, the version of
the distribution may jump unexpectedly, please refer to the distribution's
documentation for versioning practices.
@@ -2791,53 +2752,38 @@ QString QSysInfo::prettyProductName()
{
#if defined(Q_OS_IOS)
return QLatin1String("iOS ") + productVersion();
+#elif defined(Q_OS_TVOS)
+ return QLatin1String("tvOS ") + productVersion();
#elif defined(Q_OS_MACOS)
- // get the known codenames
- const char *basename = 0;
- switch (int(MacintoshVersion)) {
- case MV_CHEETAH:
- case MV_PUMA:
- case MV_JAGUAR:
- case MV_PANTHER:
- case MV_TIGER:
- // This version of Qt does not run on those versions of OS X
- // so this case label will never be reached
- Q_UNREACHABLE();
- break;
- case MV_LEOPARD:
- basename = "Mac OS X Leopard (";
- break;
- case MV_SNOWLEOPARD:
- basename = "Mac OS X Snow Leopard (";
- break;
- case MV_LION:
- basename = "OS X Lion (";
- break;
- case MV_MOUNTAINLION:
- basename = "OS X Mountain Lion (";
- break;
- case MV_MAVERICKS:
- basename = "OS X Mavericks (";
- break;
- case MV_YOSEMITE:
- basename = "OS X Yosemite (";
- break;
- case MV_ELCAPITAN:
- basename = "OS X El Capitan (";
- break;
- case MV_SIERRA:
- basename = "macOS Sierra (";
- break;
+ const QAppleOperatingSystemVersion version = qt_apple_os_version();
+ const char *name = osxVer_helper(version);
+ if (name) {
+ return (version.major == 10 && version.minor < 12
+ ? QLatin1String("OS X ")
+ : QLatin1String("macOS "))
+ + QLatin1String(name)
+ + QLatin1String(" (") + QString::number(version.major)
+ + QLatin1Char('.') + QString::number(version.minor)
+ + QLatin1Char(')');
+ } else {
+ return QLatin1String("macOS ")
+ + QString::number(version.major) + QLatin1Char('.')
+ + QString::number(version.minor);
}
- if (basename)
- return QLatin1String(basename) + productVersion() + QLatin1Char(')');
-
- // a future version of macOS
- return QLatin1String("macOS ") + productVersion();
#elif defined(Q_OS_WINPHONE)
return QLatin1String("Windows Phone ") + QLatin1String(winVer_helper());
#elif defined(Q_OS_WIN)
- return QLatin1String("Windows ") + QLatin1String(winVer_helper()) + winSp_helper();
+ const char *name = winVer_helper();
+ const OSVERSIONINFOEX osver = winOsVersion();
+ if (name)
+ return QLatin1String("Windows ") + QLatin1String(name) + winSp_helper()
+ + QLatin1String(" (") + QString::number(osver.dwMajorVersion)
+ + QLatin1Char('.') + QString::number(osver.dwMinorVersion)
+ + QLatin1Char(')');
+ else
+ return QLatin1String("Windows ")
+ + QString::number(osver.dwMajorVersion) + QLatin1Char('.')
+ + QString::number(osver.dwMinorVersion);
#elif defined(Q_OS_ANDROID)
return QLatin1String("Android ") + productVersion();
#elif defined(Q_OS_HAIKU)
@@ -4301,6 +4247,24 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
*/
/*!
+ \fn bool qFuzzyIsNull(double d)
+ \relates <QtGlobal>
+ \since 4.4
+ \threadsafe
+
+ Returns true if the absolute value of \a d is within 0.000000000001 of 0.0.
+*/
+
+/*!
+ \fn bool qFuzzyIsNull(float f)
+ \relates <QtGlobal>
+ \since 4.4
+ \threadsafe
+
+ Returns true if the absolute value of \a f is within 0.00001f of 0.0.
+*/
+
+/*!
\macro QT_REQUIRE_VERSION(int argc, char **argv, const char *version)
\relates <QtGlobal>
@@ -4515,7 +4479,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
On QNX the message is sent to slogger2
If you are using the \b{default message handler} this function will
- abort on Unix systems to create a core dump. On Windows, for debug builds,
+ abort to create a core dump. On Windows, for debug builds,
this function will report a _CRT_ERROR enabling you to connect a debugger
to the application.
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 118203f720..3d8baf7188 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -296,26 +296,8 @@ typedef double qreal;
# else
# define Q_CORE_EXPORT Q_DECL_IMPORT
# endif
-# if defined(QT_BUILD_GUI_LIB)
-# define Q_GUI_EXPORT Q_DECL_EXPORT
-# else
-# define Q_GUI_EXPORT Q_DECL_IMPORT
-# endif
-# if defined(QT_BUILD_WIDGETS_LIB)
-# define Q_WIDGETS_EXPORT Q_DECL_EXPORT
-# else
-# define Q_WIDGETS_EXPORT Q_DECL_IMPORT
-# endif
-# if defined(QT_BUILD_NETWORK_LIB)
-# define Q_NETWORK_EXPORT Q_DECL_EXPORT
-# else
-# define Q_NETWORK_EXPORT Q_DECL_IMPORT
-# endif
#else
# define Q_CORE_EXPORT
-# define Q_GUI_EXPORT
-# define Q_WIDGETS_EXPORT
-# define Q_NETWORK_EXPORT
#endif
/*
@@ -469,7 +451,7 @@ typedef qptrdiff qintptr;
# define QT_ASCII_CAST_WARN
#endif
-#if defined(__i386__) || defined(_WIN32) || defined(_WIN32_WCE)
+#if defined(__i386__) || defined(_WIN32)
# if defined(Q_CC_GNU)
# define QT_FASTCALL __attribute__((regparm(3)))
# elif defined(Q_CC_MSVC)
@@ -529,23 +511,11 @@ Q_DECL_CONSTEXPR inline int qRound(double d)
{ return d >= 0.0 ? int(d + 0.5) : int(d - double(int(d-1)) + 0.5) + int(d-1); }
Q_DECL_CONSTEXPR inline int qRound(float d)
{ return d >= 0.0f ? int(d + 0.5f) : int(d - float(int(d-1)) + 0.5f) + int(d-1); }
-#ifdef Q_QDOC
-/*
- Just for documentation generation
-*/
-int qRound(qreal d);
-#endif
Q_DECL_CONSTEXPR inline qint64 qRound64(double d)
{ return d >= 0.0 ? qint64(d + 0.5) : qint64(d - double(qint64(d-1)) + 0.5) + qint64(d-1); }
Q_DECL_CONSTEXPR inline qint64 qRound64(float d)
{ return d >= 0.0f ? qint64(d + 0.5f) : qint64(d - float(qint64(d-1)) + 0.5f) + qint64(d-1); }
-#ifdef Q_QDOC
-/*
- Just for documentation generation
-*/
-qint64 qRound64(qreal d);
-#endif
template <typename T>
Q_DECL_CONSTEXPR inline const T &qMin(const T &a, const T &b) { return (a < b) ? a : b; }
@@ -568,25 +538,53 @@ Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max
#ifndef Q_FORWARD_DECLARE_MUTABLE_CF_TYPE
# define Q_FORWARD_DECLARE_MUTABLE_CF_TYPE(type) typedef struct __ ## type * type ## Ref
#endif
+#ifndef Q_FORWARD_DECLARE_CG_TYPE
+#define Q_FORWARD_DECLARE_CG_TYPE(type) typedef const struct type *type ## Ref;
+#endif
+#ifndef Q_FORWARD_DECLARE_MUTABLE_CG_TYPE
+#define Q_FORWARD_DECLARE_MUTABLE_CG_TYPE(type) typedef struct type *type ## Ref;
+#endif
-#ifdef Q_OS_MAC
-# define QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(osx, ios) \
- ((defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && osx != __MAC_NA && __MAC_OS_X_VERSION_MAX_ALLOWED >= osx) || \
- (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MAX_ALLOWED >= ios))
+#ifdef Q_OS_DARWIN
+# define QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios, tvos, watchos) \
+ ((defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && macos != __MAC_NA && __MAC_OS_X_VERSION_MAX_ALLOWED >= macos) || \
+ (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MAX_ALLOWED >= ios) || \
+ (defined(__TV_OS_VERSION_MAX_ALLOWED) && tvos != __TVOS_NA && __TV_OS_VERSION_MAX_ALLOWED >= tvos) || \
+ (defined(__WATCH_OS_VERSION_MAX_ALLOWED) && watchos != __WATCHOS_NA && __WATCH_OS_VERSION_MAX_ALLOWED >= watchos))
-# define QT_MAC_DEPLOYMENT_TARGET_BELOW(osx, ios) \
- ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && osx != __MAC_NA && __MAC_OS_X_VERSION_MIN_REQUIRED < osx) || \
- (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MIN_REQUIRED < ios))
+# define QT_DARWIN_DEPLOYMENT_TARGET_BELOW(macos, ios, tvos, watchos) \
+ ((defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && macos != __MAC_NA && __MAC_OS_X_VERSION_MIN_REQUIRED < macos) || \
+ (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && ios != __IPHONE_NA && __IPHONE_OS_VERSION_MIN_REQUIRED < ios) || \
+ (defined(__TV_OS_VERSION_MIN_REQUIRED) && tvos != __TVOS_NA && __TV_OS_VERSION_MIN_REQUIRED < tvos) || \
+ (defined(__WATCH_OS_VERSION_MIN_REQUIRED) && watchos != __WATCHOS_NA && __WATCH_OS_VERSION_MIN_REQUIRED < watchos))
+# define QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios) \
+ QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, ios, __TVOS_NA, __WATCHOS_NA)
+# define QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(macos) \
+ QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(macos, __IPHONE_NA, __TVOS_NA, __WATCHOS_NA)
# define QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(ios) \
- QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, ios)
-# define QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(osx) \
- QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(osx, __IPHONE_NA)
-
+ QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, ios, __TVOS_NA, __WATCHOS_NA)
+# define QT_TVOS_PLATFORM_SDK_EQUAL_OR_ABOVE(tvos) \
+ QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, __IPHONE_NA, tvos, __WATCHOS_NA)
+# define QT_WATCHOS_PLATFORM_SDK_EQUAL_OR_ABOVE(watchos) \
+ QT_DARWIN_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_NA, __IPHONE_NA, __TVOS_NA, watchos)
+
+# define QT_MACOS_IOS_DEPLOYMENT_TARGET_BELOW(macos, ios) \
+ QT_DARWIN_DEPLOYMENT_TARGET_BELOW(macos, ios, __TVOS_NA, __WATCHOS_NA)
+# define QT_MACOS_DEPLOYMENT_TARGET_BELOW(macos) \
+ QT_DARWIN_DEPLOYMENT_TARGET_BELOW(macos, __IPHONE_NA, __TVOS_NA, __WATCHOS_NA)
# define QT_IOS_DEPLOYMENT_TARGET_BELOW(ios) \
- QT_MAC_DEPLOYMENT_TARGET_BELOW(__MAC_NA, ios)
-# define QT_OSX_DEPLOYMENT_TARGET_BELOW(osx) \
- QT_MAC_DEPLOYMENT_TARGET_BELOW(osx, __IPHONE_NA)
+ QT_DARWIN_DEPLOYMENT_TARGET_BELOW(__MAC_NA, ios, __TVOS_NA, __WATCHOS_NA)
+# define QT_TVOS_DEPLOYMENT_TARGET_BELOW(tvos) \
+ QT_DARWIN_DEPLOYMENT_TARGET_BELOW(__MAC_NA, __IPHONE_NA, tvos, __WATCHOS_NA)
+# define QT_WATCHOS_DEPLOYMENT_TARGET_BELOW(watchos) \
+ QT_DARWIN_DEPLOYMENT_TARGET_BELOW(__MAC_NA, __IPHONE_NA, __TVOS_NA, watchos)
+
+# define QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(osx, ios) QT_MACOS_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(osx, ios)
+# define QT_MAC_DEPLOYMENT_TARGET_BELOW(osx, ios) QT_MACOS_IOS_DEPLOYMENT_TARGET_BELOW(osx, ios)
+
+# define QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(osx) QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(osx)
+# define QT_OSX_DEPLOYMENT_TARGET_BELOW(osx) QT_MACOS_DEPLOYMENT_TARGET_BELOW(osx)
// Implemented in qcore_mac_objc.mm
class Q_CORE_EXPORT QMacAutoReleasePool
@@ -599,7 +597,7 @@ private:
void *pool;
};
-#endif // Q_OS_MAC
+#endif // Q_OS_DARWIN
/*
Data stream functions are provided by many classes (defined in qdatastream.h)
@@ -622,7 +620,7 @@ class QDataStream;
# define QT_NO_SOCKS5
#endif
-#if defined(Q_OS_IOS)
+#if defined(QT_PLATFORM_UIKIT)
# define QT_NO_PROCESS
#endif
@@ -795,18 +793,12 @@ Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2)
return (qAbs(p1 - p2) * 100000.f <= qMin(qAbs(p1), qAbs(p2)));
}
-/*!
- \internal
-*/
Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d) Q_REQUIRED_RESULT Q_DECL_UNUSED;
Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d)
{
return qAbs(d) <= 0.000000000001;
}
-/*!
- \internal
-*/
Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f) Q_REQUIRED_RESULT Q_DECL_UNUSED;
Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f)
{
@@ -1032,8 +1024,11 @@ Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1);
#ifdef Q_QDOC
// Just for documentation generation
+template<typename T>
auto qOverload(T functionPointer);
+template<typename T>
auto qConstOverload(T memberFunctionPointer);
+template<typename T>
auto qNonConstOverload(T memberFunctionPointer);
#elif defined(Q_COMPILER_VARIADIC_TEMPLATES)
diff --git a/src/corelib/global/qglobal_p.h b/src/corelib/global/qglobal_p.h
new file mode 100644
index 0000000000..e8d822b6c6
--- /dev/null
+++ b/src/corelib/global/qglobal_p.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Intel Corporation.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGLOBAL_P_H
+#define QGLOBAL_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qglobal.h"
+#include "qglobal_p.h" // include self to avoid syncqt warning - no-op
+
+#endif // QGLOBAL_P_H
+
diff --git a/src/corelib/global/qhooks.cpp b/src/corelib/global/qhooks.cpp
index b91ec64786..7b9a3db30d 100644
--- a/src/corelib/global/qhooks.cpp
+++ b/src/corelib/global/qhooks.cpp
@@ -67,7 +67,7 @@ quintptr Q_CORE_EXPORT qtHookData[] = {
// The required sizes and offsets are tested in tests/auto/other/toolsupport.
// When this fails and the change was intentional, adjust the test and
// adjust this value here.
- 5
+ 15
};
Q_STATIC_ASSERT(QHooks::LastHookIndex == sizeof(qtHookData) / sizeof(qtHookData[0]));
diff --git a/src/corelib/global/qhooks_p.h b/src/corelib/global/qhooks_p.h
index 47270d8ad2..a51a2ec86b 100644
--- a/src/corelib/global/qhooks_p.h
+++ b/src/corelib/global/qhooks_p.h
@@ -52,7 +52,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index 458200180e..4303f74709 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -229,30 +229,30 @@ QLibraryInfo::QLibraryInfo()
{ }
/*!
- Returns the person to whom this build of Qt is licensed.
-
- \sa licensedProducts()
+ \deprecated
+ This function used to return the person to whom this build of Qt is licensed, now returns an empty string.
*/
+#if QT_DEPRECATED_SINCE(5, 8)
QString
QLibraryInfo::licensee()
{
- const char * volatile str = QT_CONFIGURE_LICENSEE;
- return QString::fromLocal8Bit(str);
+ return QString();
}
+#endif
/*!
- Returns the products that the license for this build of Qt has access to.
-
- \sa licensee()
+ \deprecated
+ This function used to return the products that the license for this build of Qt has access to, now returns an empty string.
*/
+#if QT_DEPRECATED_SINCE(5, 8)
QString
QLibraryInfo::licensedProducts()
{
- const char * volatile str = QT_CONFIGURE_LICENSED_PRODUCTS;
- return QString::fromLatin1(str);
+ return QString();
}
+#endif
/*!
\since 4.6
@@ -366,6 +366,19 @@ QLibraryInfo::isDebugBuild()
#endif
}
+#ifndef QT_BOOTSTRAPPED
+/*!
+ \since 5.8
+ Returns the version of the Qt library.
+
+ \sa qVersion()
+*/
+QVersionNumber QLibraryInfo::version() Q_DECL_NOTHROW
+{
+ return QVersionNumber(QT_VERSION_MAJOR, QT_VERSION_MINOR, QT_VERSION_PATCH);
+}
+#endif // QT_BOOTSTRAPPED
+
#endif // QT_BUILD_QMAKE
/*
@@ -519,7 +532,7 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
reg_var.setMinimal(true);
while((rep = reg_var.indexIn(ret)) != -1) {
ret.replace(rep, reg_var.matchedLength(),
- QString::fromLocal8Bit(qgetenv(ret.mid(rep + 2,
+ QString::fromLocal8Bit(qgetenv(ret.midRef(rep + 2,
reg_var.matchedLength() - 3).toLatin1().constData()).constData()));
}
diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h
index 362d47dea3..55be706382 100644
--- a/src/corelib/global/qlibraryinfo.h
+++ b/src/corelib/global/qlibraryinfo.h
@@ -42,6 +42,7 @@
#include <QtCore/qstring.h>
#include <QtCore/qdatetime.h>
+#include <QtCore/qversionnumber.h>
QT_BEGIN_NAMESPACE
@@ -50,8 +51,10 @@ class QStringList;
class Q_CORE_EXPORT QLibraryInfo
{
public:
- static QString licensee();
- static QString licensedProducts();
+#if QT_DEPRECATED_SINCE(5, 8)
+ static QT_DEPRECATED QString licensee();
+ static QT_DEPRECATED QString licensedProducts();
+#endif
#ifndef QT_NO_DATESTRING
#if QT_DEPRECATED_SINCE(5, 5)
@@ -63,6 +66,10 @@ public:
static bool isDebugBuild();
+#ifndef QT_BOOTSTRAPPED
+ static QVersionNumber version() Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
+#endif
+
enum LibraryLocation
{
PrefixPath = 0,
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 49a8aa0df1..a6da9567c6 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -140,6 +140,8 @@ static QT_PREPEND_NAMESPACE(qint64) qt_gettid()
#endif
#endif // !QT_BOOTSTRAPPED
+#include <cstdlib>
+
#include <stdio.h>
QT_BEGIN_NAMESPACE
@@ -170,7 +172,7 @@ static bool isFatal(QtMsgType msgType)
static bool willLogToConsole()
{
-#if defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
+#if defined(Q_OS_WINRT)
// these systems have no stderr, so always log to the system log
return false;
#elif defined(QT_BOOTSTRAPPED)
@@ -1176,7 +1178,7 @@ void QMessagePattern::setPattern(const QString &pattern)
else if (inIf)
error += QLatin1String("QT_MESSAGE_PATTERN: missing %{endif}\n");
if (!error.isEmpty()) {
-#if defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
+#if defined(Q_OS_WINRT)
OutputDebugString(reinterpret_cast<const wchar_t*>(error.utf16()));
if (0)
#elif defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB)
@@ -1676,11 +1678,7 @@ static void qt_message_fatal(QtMsgType, const QMessageLogContext &context, const
Q_UNUSED(message);
#endif
-#if (defined(Q_OS_UNIX) || defined(Q_CC_MINGW))
- abort(); // trap; generates core dump
-#else
- exit(1); // goodbye cruel world
-#endif
+ std::abort();
}
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 2a0b8461cd..edb568a2d6 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -301,12 +301,7 @@ public:
MacWindowToolBarButtonHint = 0x10000000,
BypassGraphicsProxyWidget = 0x20000000,
NoDropShadowWindowHint = 0x40000000,
- WindowFullscreenButtonHint = 0x80000000,
-
- // The following enums have overlapping values with other enums.
- // This was not intentional, but it's too late to change now.
- WindowOkButtonHint = 0x00080000, // WindowTransparentForInput
- WindowCancelButtonHint = 0x00100000 // WindowOverridesSystemGestures
+ WindowFullscreenButtonHint = 0x80000000
};
Q_DECLARE_FLAGS(WindowFlags, WindowType)
@@ -509,6 +504,7 @@ public:
AA_DontUseNativeDialogs = 23,
AA_SynthesizeMouseForUnhandledTabletEvents = 24,
AA_CompressHighFrequencyEvents = 25,
+ AA_DontCheckOpenGLContextThreadAffinity = 26,
// Add new attributes before this line
AA_AttributeCount
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index bc74acfcde..bf55693e8a 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -250,6 +250,13 @@
If your application needs to handle all events with no compression,
you can unset this attribute. This value has been added in Qt 5.7.
+ \value AA_DontCheckOpenGLContextThreadAffinity When making a context
+ current using QOpenGLContext, do not check that the
+ \l{QObject#Thread Affinity}{QObject thread affinity}
+ of the QOpenGLContext object is the same thread calling
+ \l{QOpenGLContext::makeCurrent}{makeCurrent()}. This value has been
+ added in Qt 5.8.
+
The following values are obsolete:
\value AA_ImmediateWidgetCreation This attribute is no longer fully
@@ -753,27 +760,25 @@
\value MonoOnly The pixmap becomes monochrome. If necessary,
it is dithered using the chosen dithering algorithm.
- Dithering mode preference for RGB channels:
+ Dithering mode preference:
- \value DiffuseDither (default) - A high-quality dither.
- \value OrderedDither A faster, more ordered dither.
+ \value DiffuseDither (default) - A high-quality dither using error diffusion.
+ \value OrderedDither A faster, ordered dither.
\value ThresholdDither No dithering; closest color is used.
- Dithering mode preference for alpha channel:
+ Dithering mode preference for 1-bit alpha masks:
\value ThresholdAlphaDither (default) - No dithering.
- \value OrderedAlphaDither A faster, more ordered dither.
- \value DiffuseAlphaDither A high-quality dither.
+ \value OrderedAlphaDither A faster, ordered dither.
+ \value DiffuseAlphaDither A high-quality dither using error diffusion.
\omitvalue NoAlpha
Color matching versus dithering preference:
- \value PreferDither (default when converting to a pixmap) - Always dither
- 32-bit images when the image is converted to 8 bits.
- \value AvoidDither (default when converting for the purpose of saving to
- file) - Dither 32-bit images only if the image has more than 256
- colors and it is being converted to 8 bits.
- \omitvalue AutoDither
+ \value PreferDither Always dither images when converting to smaller color-spaces.
+ \value AvoidDither Only dither to indexed formats if the source image uses more
+ different colors than the size of the color table of the destination format.
+ \value AutoDither (default) - Only dither when down-converting to 1 or 8-bit indexed formats.
\omitvalue ColorMode_Mask
\omitvalue Dither_Mask
@@ -2221,12 +2226,6 @@
the bottom. This window hint is currently not implemented
for \macos.
- \value WindowOkButtonHint Adds an OK button to the window decoration of a dialog.
- Only supported for Windows CE.
-
- \value WindowCancelButtonHint Adds a Cancel button to the window decoration of a dialog.
- Only supported for Windows CE.
-
\value WindowTransparentForInput Informs the window system that this window
is used only for output (displaying something) and does not take input.
Therefore input events should pass through as if it wasn't there.
diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h
index 3451b2158d..ef40a45dc4 100644
--- a/src/corelib/global/qnumeric_p.h
+++ b/src/corelib/global/qnumeric_p.h
@@ -52,11 +52,11 @@
// We mean it.
//
-#include "QtCore/qglobal.h"
+#include "QtCore/private/qglobal_p.h"
#include <cmath>
#include <limits>
-#if defined(Q_CC_MSVC) && !defined(Q_OS_WINCE)
+#if defined(Q_CC_MSVC)
# include <intrin.h>
#elif defined(Q_CC_INTEL)
# include <immintrin.h> // for _addcarry_u<nn>
diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h
index 6ecd41bc30..566d76d3d2 100644
--- a/src/corelib/global/qprocessordetection.h
+++ b/src/corelib/global/qprocessordetection.h
@@ -334,7 +334,7 @@
# elif defined(__BIG_ENDIAN__) || defined(_big_endian__) || defined(_BIG_ENDIAN)
# define Q_BYTE_ORDER Q_BIG_ENDIAN
# elif defined(__LITTLE_ENDIAN__) || defined(_little_endian__) || defined(_LITTLE_ENDIAN) \
- || defined(_WIN32_WCE) || defined(WINAPI_FAMILY) // Windows CE is always little-endian according to MSDN.
+ || defined(WINAPI_FAMILY) // WinRT is always little-endian according to MSDN.
# define Q_BYTE_ORDER Q_LITTLE_ENDIAN
# else
# error "Unable to determine byte order!"
diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h
index d1a4102f29..31d78bca50 100644
--- a/src/corelib/global/qsysinfo.h
+++ b/src/corelib/global/qsysinfo.h
@@ -69,7 +69,7 @@ public:
LittleEndian
# ifdef Q_QDOC
- , ByteOrder = <platform-dependent>
+ , ByteOrder = BigEndian or LittleEndian
# elif Q_BYTE_ORDER == Q_BIG_ENDIAN
, ByteOrder = BigEndian
# elif Q_BYTE_ORDER == Q_LITTLE_ENDIAN
@@ -109,13 +109,7 @@ public:
WV_6_1 = WV_WINDOWS7,
WV_6_2 = WV_WINDOWS8,
WV_6_3 = WV_WINDOWS8_1,
- WV_10_0 = WV_WINDOWS10,
-
- WV_CE = 0x0100,
- WV_CENET = 0x0200,
- WV_CE_5 = 0x0300,
- WV_CE_6 = 0x0400,
- WV_CE_based = 0x0f00
+ WV_10_0 = WV_WINDOWS10
};
#if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
static const WinVersion WindowsVersion;
@@ -127,6 +121,7 @@ public:
#define Q_MV_OSX(major, minor) (major == 10 ? minor + 2 : (major == 9 ? 1 : 0))
#define Q_MV_IOS(major, minor) (QSysInfo::MV_IOS | major << 4 | minor)
+#define Q_MV_TVOS(major, minor) (QSysInfo::MV_TVOS | major << 4 | minor)
enum MacVersion {
MV_None = 0xffff,
MV_Unknown = 0x0000,
@@ -180,7 +175,14 @@ public:
MV_IOS_9_1 = Q_MV_IOS(9, 1),
MV_IOS_9_2 = Q_MV_IOS(9, 2),
MV_IOS_9_3 = Q_MV_IOS(9, 3),
- MV_IOS_10_0 = Q_MV_IOS(10, 0)
+ MV_IOS_10_0 = Q_MV_IOS(10, 0),
+
+ /* tvOS */
+ MV_TVOS = 1 << 9,
+ MV_TVOS_9_0 = Q_MV_TVOS(9, 0),
+ MV_TVOS_9_1 = Q_MV_TVOS(9, 1),
+ MV_TVOS_9_2 = Q_MV_TVOS(9, 2),
+ MV_TVOS_10_0 = Q_MV_TVOS(10, 0)
};
#if defined(Q_OS_MAC)
static const MacVersion MacintoshVersion;
diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h
index 1e852ae538..90954b1eca 100644
--- a/src/corelib/global/qsystemdetection.h
+++ b/src/corelib/global/qsystemdetection.h
@@ -47,7 +47,7 @@
/*
The operating system, must be one of: (Q_OS_x)
- DARWIN - Any Darwin system (OS X, iOS, watchOS, tvOS)
+ DARWIN - Any Darwin system (macOS, iOS, watchOS, tvOS)
MACOS - macOS
IOS - iOS
WATCHOS - watchOS
@@ -56,7 +56,6 @@
OS2 - OS/2
OS2EMX - XFree86 on OS/2 (not PM)
WIN32 - Win32 (Windows 2000/XP/Vista/7 and Windows Server 2003/2008)
- WINCE - WinCE (Windows CE 5.0)
WINRT - WinRT (Windows 8 Runtime)
CYGWIN - Cygwin
SOLARIS - Sun Solaris
@@ -103,18 +102,21 @@
# define Q_OS_DARWIN32
# endif
# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
-# if defined(TARGET_OS_TV) && TARGET_OS_TV
-# define Q_OS_TVOS
-# elif defined(TARGET_OS_WATCH) && TARGET_OS_WATCH
+# if defined(TARGET_OS_WATCH) && TARGET_OS_WATCH
# define Q_OS_WATCHOS
# else
-# // TARGET_OS_IOS is only available in newer SDKs,
-# // so assume any other iOS-based platform is iOS for now
-# define Q_OS_IOS
+# define QT_PLATFORM_UIKIT
+# if defined(TARGET_OS_TV) && TARGET_OS_TV
+# define Q_OS_TVOS
+# else
+# // TARGET_OS_IOS is only available in newer SDKs,
+# // so assume any other iOS-based platform is iOS for now
+# define Q_OS_IOS
+# endif
# endif
# else
-# // there is no "real" OS X define (rdar://22640089),
-# // assume any non iOS-based platform is OS X for now
+# // TARGET_OS_OSX is only available in newer SDKs,
+# // so assume any non iOS-based platform is macOS for now
# define Q_OS_MACOS
# endif
# else
@@ -129,9 +131,7 @@
# define Q_OS_WIN32
# define Q_OS_WIN64
#elif !defined(SAG_COM) && (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__))
-# if defined(WINCE) || defined(_WIN32_WCE)
-# define Q_OS_WINCE
-# elif defined(WINAPI_FAMILY)
+# if defined(WINAPI_FAMILY)
# ifndef WINAPI_FAMILY_PC_APP
# define WINAPI_FAMILY_PC_APP WINAPI_FAMILY_APP
# endif
@@ -209,7 +209,7 @@
# error "Qt has not been ported to this OS - see http://www.qt-project.org/"
#endif
-#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) || defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) || defined(Q_OS_WINRT)
# define Q_OS_WIN
#endif
diff --git a/src/corelib/global/qt_windows.h b/src/corelib/global/qt_windows.h
index 8ac3c2135d..7b95501c08 100644
--- a/src/corelib/global/qt_windows.h
+++ b/src/corelib/global/qt_windows.h
@@ -48,10 +48,10 @@
#if defined(Q_CC_MINGW)
// mingw's windows.h does not set _WIN32_WINNT, resulting breaking compilation
# ifndef WINVER
-# define WINVER 0x501
+# define WINVER 0x600
# endif
# ifndef _WIN32_WINNT
-# define _WIN32_WINNT 0x0501
+# define _WIN32_WINNT 0x600
# endif
#endif
@@ -67,10 +67,6 @@
# define _WIN32_IE 0x0501
#endif
-#ifdef _WIN32_WCE
-#include <ceconfig.h>
-#endif
-
// already defined when compiled with WINVER >= 0x0500
#ifndef SPI_SETMENUANIMATION
#define SPI_SETMENUANIMATION 0x1003
@@ -144,13 +140,4 @@
#define CLEARTYPE_QUALITY 5
#endif
-#ifdef Q_OS_WINCE
-#ifndef LR_DEFAULTSIZE
-#define LR_DEFAULTSIZE 0
-#endif
-#ifndef LR_SHARED
-#define LR_SHARED 0
-#endif
-#endif // Q_OS_WINCE
-
#endif // QT_WINDOWS_H
diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri
index 1cb2909c2a..ab345e9aae 100644
--- a/src/corelib/io/io.pri
+++ b/src/corelib/io/io.pri
@@ -106,25 +106,21 @@ win32 {
SOURCES += io/qfilesystemiterator_win.cpp
!winrt {
- SOURCES += io/qsettings_win.cpp
- SOURCES += io/qstandardpaths_win.cpp
+ HEADERS += \
+ io/qwindowspipereader_p.h \
+ io/qwindowspipewriter_p.h \
+ io/qwinoverlappedionotifier_p.h
- wince* {
- SOURCES += io/qprocess_wince.cpp \
- io/qstorageinfo_stub.cpp
- } else {
- HEADERS += \
- io/qwinoverlappedionotifier_p.h \
- io/qwindowspipereader_p.h \
- io/qwindowspipewriter_p.h
- SOURCES += \
- io/qprocess_win.cpp \
- io/qwinoverlappedionotifier.cpp \
- io/qwindowspipereader.cpp \
- io/qwindowspipewriter.cpp \
- io/qstorageinfo_win.cpp
- LIBS += -lmpr
- }
+ SOURCES += \
+ io/qprocess_win.cpp \
+ io/qsettings_win.cpp \
+ io/qstandardpaths_win.cpp \
+ io/qstorageinfo_win.cpp \
+ io/qwindowspipereader.cpp \
+ io/qwindowspipewriter.cpp \
+ io/qwinoverlappedionotifier.cpp
+
+ LIBS += -lmpr
} else {
SOURCES += \
io/qstandardpaths_winrt.cpp \
@@ -139,7 +135,7 @@ win32 {
io/qprocess_unix.cpp \
io/qfilesystemiterator_unix.cpp
- !integrity {
+ !integrity:!tvos {
SOURCES += io/forkfd_qt.cpp
HEADERS += \
../3rdparty/forkfd/forkfd.h
@@ -147,7 +143,6 @@ win32 {
}
!nacl:mac: {
SOURCES += io/qsettings_mac.cpp
- OBJECTIVE_SOURCES += io/qurl_mac.mm
}
mac {
SOURCES += io/qstorageinfo_mac.cpp
@@ -156,7 +151,7 @@ win32 {
OBJECTIVE_SOURCES += io/qfilesystemwatcher_fsevents.mm
HEADERS += io/qfilesystemwatcher_fsevents_p.h
LIBS += -framework DiskArbitration -framework IOKit
- } else:ios {
+ } else {
LIBS += -framework MobileCoreServices
}
} else:android {
diff --git a/src/corelib/io/qabstractfileengine_p.h b/src/corelib/io/qabstractfileengine_p.h
index 0293184645..48b3dec324 100644
--- a/src/corelib/io/qabstractfileengine_p.h
+++ b/src/corelib/io/qabstractfileengine_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qfile.h"
#include "QtCore/qdir.h"
diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp
index de1fc18cd0..b4eb98e062 100644
--- a/src/corelib/io/qdatastream.cpp
+++ b/src/corelib/io/qdatastream.cpp
@@ -556,6 +556,7 @@ void QDataStream::setByteOrder(ByteOrder bo)
\value Qt_5_5 Same as Qt_5_4
\value Qt_5_6 Version 17 (Qt 5.6)
\value Qt_5_7 Same as Qt_5_6
+ \value Qt_5_8 Same as Qt_5_6
\omitvalue Qt_DefaultCompiledVersion
\sa setVersion(), version()
diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h
index e8634fddef..ac58677b77 100644
--- a/src/corelib/io/qdatastream.h
+++ b/src/corelib/io/qdatastream.h
@@ -94,10 +94,11 @@ public:
Qt_5_5 = Qt_5_4,
Qt_5_6 = 17,
Qt_5_7 = Qt_5_6,
-#if QT_VERSION >= 0x050800
+ Qt_5_8 = Qt_5_7,
+#if QT_VERSION >= 0x050900
#error Add the datastream version for this Qt version and update Qt_DefaultCompiledVersion
#endif
- Qt_DefaultCompiledVersion = Qt_5_7
+ Qt_DefaultCompiledVersion = Qt_5_8
};
enum ByteOrder {
diff --git a/src/corelib/io/qdatastream_p.h b/src/corelib/io/qdatastream_p.h
index 73f57e2d6c..3ca0ae840e 100644
--- a/src/corelib/io/qdatastream_p.h
+++ b/src/corelib/io/qdatastream_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <qdatastream.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/io/qdataurl_p.h b/src/corelib/io/qdataurl_p.h
index d2fa247b95..fd5c7df50b 100644
--- a/src/corelib/io/qdataurl_p.h
+++ b/src/corelib/io/qdataurl_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qurl.h"
#include "QtCore/qbytearray.h"
#include "QtCore/qstring.h"
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h
index 8021f29e16..abc2abeaec 100644
--- a/src/corelib/io/qdebug.h
+++ b/src/corelib/io/qdebug.h
@@ -438,8 +438,8 @@ inline QDebug operator<<(QDebug debug, const QFlags<T> &flags)
#define QT_FORWARD_DECLARE_CF_TYPE(type) Q_FORWARD_DECLARE_CF_TYPE(type);
#define QT_FORWARD_DECLARE_MUTABLE_CF_TYPE(type) Q_FORWARD_DECLARE_MUTABLE_CF_TYPE(type);
-#define QT_FORWARD_DECLARE_CG_TYPE(type) typedef const struct type *type ## Ref;
-#define QT_FORWARD_DECLARE_MUTABLE_CG_TYPE(type) typedef struct type *type ## Ref;
+#define QT_FORWARD_DECLARE_CG_TYPE(type) Q_FORWARD_DECLARE_CG_TYPE(type);
+#define QT_FORWARD_DECLARE_MUTABLE_CG_TYPE(type) Q_FORWARD_DECLARE_MUTABLE_CG_TYPE(type);
QT_END_NAMESPACE
Q_FORWARD_DECLARE_CF_TYPE(CFString);
diff --git a/src/corelib/io/qdebug_p.h b/src/corelib/io/qdebug_p.h
index ead86bbb6d..a1887655d2 100644
--- a/src/corelib/io/qdebug_p.h
+++ b/src/corelib/io/qdebug_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qdebug.h"
#include "QtCore/qmetaobject.h"
#include "QtCore/qflags.h"
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index f8fae711f2..91953ebf26 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -146,9 +146,11 @@ inline QStringList QDirPrivate::splitFilters(const QString &nameFilter, QChar se
{
if (sep.isNull())
sep = getFilterSepChar(nameFilter);
- QStringList ret = nameFilter.split(sep);
- for (int i = 0; i < ret.count(); ++i)
- ret[i] = ret[i].trimmed();
+ const QVector<QStringRef> split = nameFilter.splitRef(sep);
+ QStringList ret;
+ ret.reserve(split.size());
+ for (const auto &e : split)
+ ret.append(e.trimmed().toString());
return ret;
}
@@ -2187,7 +2189,7 @@ QString QDir::cleanPath(const QString &path)
name.replace(dir_separator, QLatin1Char('/'));
bool allowUncPaths = false;
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) //allow unc paths
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) //allow unc paths
allowUncPaths = true;
#endif
diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp
index b2f4b6931f..920281cef7 100644
--- a/src/corelib/io/qfileselector.cpp
+++ b/src/corelib/io/qfileselector.cpp
@@ -55,8 +55,6 @@ QT_BEGIN_NAMESPACE
//Environment variable to allow tooling full control of file selectors
static const char env_override[] = "QT_NO_BUILTIN_SELECTORS";
-static const ushort selectorIndicator = '+';
-
Q_GLOBAL_STATIC(QFileSelectorSharedData, sharedData);
static QBasicMutex sharedDataMutex;
@@ -267,7 +265,7 @@ QUrl QFileSelector::select(const QUrl &filePath) const
return ret;
}
-static QString selectionHelper(const QString &path, const QString &fileName, const QStringList &selectors)
+QString QFileSelectorPrivate::selectionHelper(const QString &path, const QString &fileName, const QStringList &selectors, const QChar &indicator)
{
/* selectionHelper does a depth-first search of possible selected files. Because there is strict
selector ordering in the API, we can stop checking as soon as we find the file in a directory
@@ -276,12 +274,15 @@ static QString selectionHelper(const QString &path, const QString &fileName, con
Q_ASSERT(path.isEmpty() || path.endsWith(QLatin1Char('/')));
for (const QString &s : selectors) {
- QString prospectiveBase = path + QLatin1Char(selectorIndicator) + s + QLatin1Char('/');
+ QString prospectiveBase = path;
+ if (!indicator.isNull())
+ prospectiveBase += indicator;
+ prospectiveBase += s + QLatin1Char('/');
QStringList remainingSelectors = selectors;
remainingSelectors.removeAll(s);
if (!QDir(prospectiveBase).exists())
continue;
- QString prospectiveFile = selectionHelper(prospectiveBase, fileName, remainingSelectors);
+ QString prospectiveFile = selectionHelper(prospectiveBase, fileName, remainingSelectors, indicator);
if (!prospectiveFile.isEmpty())
return prospectiveFile;
}
@@ -369,7 +370,7 @@ QStringList QFileSelectorPrivate::platformSelectors()
#if defined(Q_OS_WIN)
// can't fall back to QSysInfo because we need both "winphone" and "winrt" for the Windows Phone case
ret << QStringLiteral("windows");
- ret << QSysInfo::kernelType(); // "wince" and "winnt"
+ ret << QSysInfo::kernelType(); // "winnt"
# if defined(Q_OS_WINRT)
ret << QStringLiteral("winrt");
# if defined(Q_OS_WINPHONE)
diff --git a/src/corelib/io/qfileselector_p.h b/src/corelib/io/qfileselector_p.h
index f93eb0ccb3..024d0b190d 100644
--- a/src/corelib/io/qfileselector_p.h
+++ b/src/corelib/io/qfileselector_p.h
@@ -70,6 +70,8 @@ public:
static void updateSelectors();
static QStringList platformSelectors();
static void addStatics(const QStringList &); //For loading GUI statics from other Qt modules
+ static QString selectionHelper(const QString &path, const QString &fileName,
+ const QStringList &selectors, const QChar &indicator = QLatin1Char('+'));
QFileSelectorPrivate();
QString select(const QString &filePath) const;
diff --git a/src/corelib/io/qfilesystemengine.cpp b/src/corelib/io/qfilesystemengine.cpp
index fd8f251ccb..6424012a9a 100644
--- a/src/corelib/io/qfilesystemengine.cpp
+++ b/src/corelib/io/qfilesystemengine.cpp
@@ -91,7 +91,7 @@ QString QFileSystemEngine::slowCanonicalized(const QString &path)
if (separatorPos != -1) {
if (fi.isDir() && !target.endsWith(slash))
target.append(slash);
- target.append(tmpPath.mid(separatorPos));
+ target.append(tmpPath.midRef(separatorPos));
}
tmpPath = QDir::cleanPath(target);
separatorPos = 0;
@@ -227,14 +227,27 @@ static void fillStat64fromStat32(struct stat64 *statBuf64, const struct stat &st
{
statBuf64->st_mode = statBuf32.st_mode;
statBuf64->st_size = statBuf32.st_size;
+#if _POSIX_VERSION >= 200809L
+ statBuf64->st_ctim = statBuf32.st_ctim;
+ statBuf64->st_mtim = statBuf32.st_mtim;
+ statBuf64->st_atim = statBuf32.st_atim;
+#else
statBuf64->st_ctime = statBuf32.st_ctime;
statBuf64->st_mtime = statBuf32.st_mtime;
statBuf64->st_atime = statBuf32.st_atime;
+#endif
statBuf64->st_uid = statBuf32.st_uid;
statBuf64->st_gid = statBuf32.st_gid;
}
#endif
+#if _POSIX_VERSION >= 200809L
+static qint64 timespecToMSecs(const timespec &spec)
+{
+ return (qint64(spec.tv_sec) * 1000) + (spec.tv_nsec / 1000000);
+}
+#endif
+
void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer)
{
// Permissions
@@ -278,9 +291,17 @@ void QFileSystemMetaData::fillFromStatBuf(const QT_STATBUF &statBuffer)
#endif
// Times
- creationTime_ = statBuffer.st_ctime ? statBuffer.st_ctime : statBuffer.st_mtime;
- modificationTime_ = statBuffer.st_mtime;
- accessTime_ = statBuffer.st_atime;
+#if _POSIX_VERSION >= 200809L
+ modificationTime_ = timespecToMSecs(statBuffer.st_mtim);
+ creationTime_ = timespecToMSecs(statBuffer.st_ctim);
+ if (!creationTime_)
+ creationTime_ = modificationTime_;
+ accessTime_ = timespecToMSecs(statBuffer.st_atim);
+#else
+ creationTime_ = qint64(statBuffer.st_ctime ? statBuffer.st_ctime : statBuffer.st_mtime) * 1000;
+ modificationTime_ = qint64(statBuffer.st_mtime) * 1000;
+ accessTime_ = qint64(statBuffer.st_atime) * 1000;
+#endif
userId_ = statBuffer.st_uid;
groupId_ = statBuffer.st_gid;
}
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index 75797e58da..6aaaa4c05a 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -61,7 +61,7 @@
#include <CoreServices/CoreServices.h>
#endif
-#ifdef Q_OS_IOS
+#if defined(QT_PLATFORM_UIKIT)
#include <MobileCoreServices/MobileCoreServices.h>
#endif
@@ -182,8 +182,9 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link,
#endif
if (!ret.startsWith(QLatin1Char('/'))) {
- if (link.filePath().startsWith(QLatin1Char('/'))) {
- ret.prepend(link.filePath().left(link.filePath().lastIndexOf(QLatin1Char('/')))
+ const QString linkFilePath = link.filePath();
+ if (linkFilePath.startsWith(QLatin1Char('/'))) {
+ ret.prepend(linkFilePath.leftRef(linkFilePath.lastIndexOf(QLatin1Char('/')))
+ QLatin1Char('/'));
} else {
ret.prepend(QDir::currentPath() + QLatin1Char('/'));
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 85c795fadd..abf346a717 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -52,14 +52,11 @@
#include "qvarlengtharray.h"
#include "qdatetime.h"
#include "qt_windows.h"
+#include "qvector.h"
-#if !defined(Q_OS_WINCE)
-# include <sys/types.h>
-# include <direct.h>
-# include <winioctl.h>
-#else
-# include <types.h>
-#endif
+#include <sys/types.h>
+#include <direct.h>
+#include <winioctl.h>
#include <objbase.h>
#ifndef Q_OS_WINRT
# include <shlobj.h>
@@ -116,8 +113,7 @@ typedef INT_PTR intptr_t;
# define INVALID_FILE_ATTRIBUTES (DWORD (-1))
#endif
-#if !defined(Q_OS_WINCE)
-# if !defined(REPARSE_DATA_BUFFER_HEADER_SIZE)
+#if !defined(REPARSE_DATA_BUFFER_HEADER_SIZE)
typedef struct _REPARSE_DATA_BUFFER {
ULONG ReparseTag;
USHORT ReparseDataLength;
@@ -143,32 +139,31 @@ typedef struct _REPARSE_DATA_BUFFER {
} GenericReparseBuffer;
};
} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
-# define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer)
-# endif // !defined(REPARSE_DATA_BUFFER_HEADER_SIZE)
+# define REPARSE_DATA_BUFFER_HEADER_SIZE FIELD_OFFSET(REPARSE_DATA_BUFFER, GenericReparseBuffer)
+#endif // !defined(REPARSE_DATA_BUFFER_HEADER_SIZE)
-# ifndef MAXIMUM_REPARSE_DATA_BUFFER_SIZE
-# define MAXIMUM_REPARSE_DATA_BUFFER_SIZE 16384
-# endif
-# ifndef IO_REPARSE_TAG_SYMLINK
-# define IO_REPARSE_TAG_SYMLINK (0xA000000CL)
-# endif
-# ifndef FSCTL_GET_REPARSE_POINT
-# define FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
-# endif
-#endif // !defined(Q_OS_WINCE)
+#ifndef MAXIMUM_REPARSE_DATA_BUFFER_SIZE
+# define MAXIMUM_REPARSE_DATA_BUFFER_SIZE 16384
+#endif
+#ifndef IO_REPARSE_TAG_SYMLINK
+# define IO_REPARSE_TAG_SYMLINK (0xA000000CL)
+#endif
+#ifndef FSCTL_GET_REPARSE_POINT
+# define FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
+#endif
QT_BEGIN_NAMESPACE
Q_CORE_EXPORT int qt_ntfs_permission_lookup = 0;
-#if defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
+#if defined(Q_OS_WINRT)
static QString qfsPrivateCurrentDir = QLatin1String("");
-// As none of the functions we try to resolve do exist on Windows CE
+// As none of the functions we try to resolve do exist on WinRT
// we use QT_NO_LIBRARY to shorten everything up a little bit.
-#ifndef QT_NO_LIBRARY
-#define QT_NO_LIBRARY 1
-#endif
-#endif
+# ifndef QT_NO_LIBRARY
+# define QT_NO_LIBRARY 1
+# endif
+#endif // Q_OS_WINRT
#if !defined(QT_NO_LIBRARY)
QT_BEGIN_INCLUDE_NAMESPACE
@@ -182,8 +177,6 @@ typedef DWORD (WINAPI *PtrGetEffectiveRightsFromAclW)(PACL, PTRUSTEE_W, OUT PACC
static PtrGetEffectiveRightsFromAclW ptrGetEffectiveRightsFromAclW = 0;
typedef BOOL (WINAPI *PtrGetUserProfileDirectoryW)(HANDLE, LPWSTR, LPDWORD);
static PtrGetUserProfileDirectoryW ptrGetUserProfileDirectoryW = 0;
-typedef BOOL (WINAPI *PtrGetVolumePathNamesForVolumeNameW)(LPCWSTR,LPWSTR,DWORD,PDWORD);
-static PtrGetVolumePathNamesForVolumeNameW ptrGetVolumePathNamesForVolumeNameW = 0;
QT_END_INCLUDE_NAMESPACE
static TRUSTEE_W currentUserTrusteeW;
@@ -233,7 +226,6 @@ static void resolveLibs()
#endif
triedResolve = true;
-#if !defined(Q_OS_WINCE)
HINSTANCE advapiHnd = QSystemLibrary::load(L"advapi32");
if (advapiHnd) {
ptrGetNamedSecurityInfoW = (PtrGetNamedSecurityInfoW)GetProcAddress(advapiHnd, "GetNamedSecurityInfoW");
@@ -279,10 +271,6 @@ static void resolveLibs()
HINSTANCE userenvHnd = QSystemLibrary::load(L"userenv");
if (userenvHnd)
ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)GetProcAddress(userenvHnd, "GetUserProfileDirectoryW");
- HINSTANCE kernel32 = LoadLibrary(L"kernel32");
- if(kernel32)
- ptrGetVolumePathNamesForVolumeNameW = (PtrGetVolumePathNamesForVolumeNameW)GetProcAddress(kernel32, "GetVolumePathNamesForVolumeNameW");
-#endif
}
}
#endif // QT_NO_LIBRARY
@@ -309,14 +297,14 @@ static bool resolveUNCLibs()
}
#endif
triedResolve = true;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
HINSTANCE hLib = QSystemLibrary::load(L"Netapi32");
if (hLib) {
ptrNetShareEnum = (PtrNetShareEnum)GetProcAddress(hLib, "NetShareEnum");
if (ptrNetShareEnum)
ptrNetApiBufferFree = (PtrNetApiBufferFree)GetProcAddress(hLib, "NetApiBufferFree");
}
-#endif // !Q_OS_WINCE && !Q_OS_WINRT
+#endif // !Q_OS_WINRT
}
return ptrNetShareEnum && ptrNetApiBufferFree;
}
@@ -324,7 +312,7 @@ static bool resolveUNCLibs()
static QString readSymLink(const QFileSystemEntry &link)
{
QString result;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
HANDLE handle = CreateFile((wchar_t*)link.nativeFilePath().utf16(),
FILE_READ_EA,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
@@ -357,27 +345,24 @@ static QString readSymLink(const QFileSystemEntry &link)
#if !defined(QT_NO_LIBRARY)
resolveLibs();
- if (ptrGetVolumePathNamesForVolumeNameW) {
- QRegExp matchVolName(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), Qt::CaseInsensitive);
- if(matchVolName.indexIn(result) == 0) {
- DWORD len;
- wchar_t buffer[MAX_PATH];
- QString volumeName = result.mid(0, matchVolName.matchedLength()).prepend(QLatin1String("\\\\?\\"));
- if(ptrGetVolumePathNamesForVolumeNameW((wchar_t*)volumeName.utf16(), buffer, MAX_PATH, &len) != 0)
- result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer));
- }
+ QRegExp matchVolName(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), Qt::CaseInsensitive);
+ if (matchVolName.indexIn(result) == 0) {
+ DWORD len;
+ wchar_t buffer[MAX_PATH];
+ QString volumeName = result.mid(0, matchVolName.matchedLength()).prepend(QLatin1String("\\\\?\\"));
+ if (GetVolumePathNamesForVolumeName(reinterpret_cast<LPCWSTR>(volumeName.utf16()), buffer, MAX_PATH, &len) != 0)
+ result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer));
}
-#endif // !Q_OS_WINCE && !Q_OS_WINRT
+#endif // !Q_OS_WINRT
}
#else
Q_UNUSED(link);
-#endif // Q_OS_WINCE || Q_OS_WINRT
+#endif // Q_OS_WINRT
return result;
}
static QString readLink(const QFileSystemEntry &link)
{
-#if !defined(Q_OS_WINCE)
#if !defined(QT_NO_LIBRARY)
QString ret;
@@ -418,31 +403,16 @@ static QString readLink(const QFileSystemEntry &link)
Q_UNUSED(link);
return QString();
#endif // QT_NO_LIBRARY
-#elif !defined(QT_NO_WINCE_SHELLSDK)
- wchar_t target[MAX_PATH];
- QString result;
- if (SHGetShortcutTarget((wchar_t*)QFileInfo(link.filePath()).absoluteFilePath().replace(QLatin1Char('/'),QLatin1Char('\\')).utf16(), target, MAX_PATH)) {
- result = QString::fromWCharArray(target);
- if (result.startsWith(QLatin1Char('"')))
- result.remove(0,1);
- if (result.endsWith(QLatin1Char('"')))
- result.remove(result.size()-1,1);
- }
- return result;
-#else // QT_NO_WINCE_SHELLSDK
- Q_UNUSED(link);
- return QString();
-#endif // Q_OS_WINCE
}
static bool uncShareExists(const QString &server)
{
// This code assumes the UNC path is always like \\?\UNC\server...
- QStringList parts = server.split(QLatin1Char('\\'), QString::SkipEmptyParts);
+ const QVector<QStringRef> parts = server.splitRef(QLatin1Char('\\'), QString::SkipEmptyParts);
if (parts.count() >= 3) {
QStringList shares;
if (QFileSystemEngine::uncListSharesOnServer(QLatin1String("\\\\") + parts.at(2), &shares))
- return parts.count() >= 4 ? shares.contains(parts.at(3), Qt::CaseInsensitive) : true;
+ return parts.count() < 4 || shares.contains(parts.at(3).toString(), Qt::CaseInsensitive);
}
return false;
}
@@ -533,7 +503,7 @@ QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path)
{
// can be //server or //server/share
QString absPath;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT_WIN81)
+#if !defined(Q_OS_WINRT_WIN81)
QVarLengthArray<wchar_t, MAX_PATH> buf(qMax(MAX_PATH, path.size() + 1));
wchar_t *fileName = 0;
DWORD retLen = GetFullPathName((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName);
@@ -553,17 +523,12 @@ QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path)
if (absPath.size() < rootPath.size() && rootPath.startsWith(absPath))
absPath = rootPath;
# endif // Q_OS_WINRT
-#elif !defined(Q_OS_WINCE)
+#else // !Q_OS_WINRT_WIN81
if (QDir::isRelativePath(path))
absPath = QDir::toNativeSeparators(QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + path));
else
absPath = QDir::toNativeSeparators(QDir::cleanPath(path));
-#else // Q_OS_WINRT
- if (path.startsWith(QLatin1Char('/')) || path.startsWith(QLatin1Char('\\')))
- absPath = QDir::toNativeSeparators(path);
- else
- absPath = QDir::toNativeSeparators(QDir::cleanPath(qfsPrivateCurrentDir + QLatin1Char('/') + path));
-#endif // Q_OS_WINCE
+#endif // Q_OS_WINRT_WIN81
// This is really ugly, but GetFullPathName strips off whitespace at the end.
// If you for instance write ". " in the lineedit of QFileDialog,
// (which is an invalid filename) this function will strip the space off and viola,
@@ -580,15 +545,10 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
QString ret;
if (!entry.isRelative()) {
-#if !defined(Q_OS_WINCE)
- if (entry.isAbsolute() && entry.isClean()) {
+ if (entry.isAbsolute() && entry.isClean())
ret = entry.filePath();
- } else {
+ else
ret = QDir::fromNativeSeparators(nativeAbsoluteFilePath(entry.filePath()));
- }
-#else
- ret = entry.filePath();
-#endif
} else {
#ifndef Q_OS_WINRT_WIN81
ret = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + entry.filePath());
@@ -617,25 +577,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
}
-#ifndef Q_OS_WINCE
-
-// FILE_INFO_BY_HANDLE_CLASS has been extended by FileIdInfo = 18 as of VS2012.
-typedef enum { Q_FileIdInfo = 18 } Q_FILE_INFO_BY_HANDLE_CLASS;
-
-# if defined(Q_CC_MINGW) || (defined(Q_CC_MSVC) && (_MSC_VER < 1700 || WINVER <= 0x0601))
-
-// MinGW-64 defines FILE_ID_128 as of gcc-4.8.1 along with FILE_SUPPORTS_INTEGRITY_STREAMS
-# if !(defined(Q_CC_MINGW) && defined(FILE_SUPPORTS_INTEGRITY_STREAMS))
-typedef struct _FILE_ID_128 {
- BYTE Identifier[16];
-} FILE_ID_128, *PFILE_ID_128;
-# endif // !(Q_CC_MINGW && FILE_SUPPORTS_INTEGRITY_STREAMS)
+#if defined(Q_CC_MINGW) && WINVER < 0x0602 // Windows 8 onwards
typedef struct _FILE_ID_INFO {
ULONGLONG VolumeSerialNumber;
FILE_ID_128 FileId;
} FILE_ID_INFO, *PFILE_ID_INFO;
-# endif // if defined (Q_CC_MINGW) || (defined(Q_CC_MSVC) && (_MSC_VER < 1700 || WINVER <= 0x0601))
+
+#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
// File ID for Windows up to version 7.
static inline QByteArray fileId(HANDLE handle)
@@ -658,44 +607,26 @@ static inline QByteArray fileId(HANDLE handle)
// File ID for Windows starting from version 8.
QByteArray fileIdWin8(HANDLE handle)
{
-#ifndef Q_OS_WINRT
- typedef BOOL (WINAPI* GetFileInformationByHandleExType)(HANDLE, Q_FILE_INFO_BY_HANDLE_CLASS, void *, DWORD);
-
- // Dynamically resolve GetFileInformationByHandleEx (Vista onwards).
- static GetFileInformationByHandleExType getFileInformationByHandleEx = 0;
- if (!getFileInformationByHandleEx) {
- QSystemLibrary library(QLatin1String("kernel32"));
- getFileInformationByHandleEx = (GetFileInformationByHandleExType)library.resolve("GetFileInformationByHandleEx");
- }
- QByteArray result;
- if (getFileInformationByHandleEx) {
- FILE_ID_INFO infoEx;
- if (getFileInformationByHandleEx(handle, Q_FileIdInfo,
- &infoEx, sizeof(FILE_ID_INFO))) {
- result = QByteArray::number(infoEx.VolumeSerialNumber, 16);
- result += ':';
- // Note: MinGW-64's definition of FILE_ID_128 differs from the MSVC one.
- result += QByteArray((char *)&infoEx.FileId, sizeof(infoEx.FileId)).toHex();
- }
- }
-#else // !Q_OS_WINRT
+#if !defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE)
QByteArray result;
FILE_ID_INFO infoEx;
- if (GetFileInformationByHandleEx(handle, FileIdInfo,
+ if (GetFileInformationByHandleEx(handle,
+ static_cast<FILE_INFO_BY_HANDLE_CLASS>(18), // FileIdInfo in Windows 8
&infoEx, sizeof(FILE_ID_INFO))) {
result = QByteArray::number(infoEx.VolumeSerialNumber, 16);
result += ':';
- result += QByteArray((char *)infoEx.FileId.Identifier, sizeof(infoEx.FileId.Identifier)).toHex();
+ // Note: MinGW-64's definition of FILE_ID_128 differs from the MSVC one.
+ result += QByteArray(reinterpret_cast<const char *>(&infoEx.FileId), int(sizeof(infoEx.FileId))).toHex();
}
-#endif // Q_OS_WINRT
return result;
+#else // !QT_BOOTSTRAPPED && !QT_BUILD_QMAKE
+ return fileId(handle);
+#endif
}
-#endif // !Q_OS_WINCE
//static
QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry)
{
-#ifndef Q_OS_WINCE
QByteArray result;
const HANDLE handle =
#ifndef Q_OS_WINRT
@@ -711,9 +642,6 @@ QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry)
CloseHandle(handle);
}
return result;
-#else // !Q_OS_WINCE
- return entry.nativeFilePath().toLower().toLatin1();
-#endif
}
//static
@@ -882,7 +810,7 @@ static bool tryDriveUNCFallback(const QFileSystemEntry &fname, QFileSystemMetaDa
{
bool entryExists = false;
DWORD fileAttrib = 0;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
if (fname.isDriveRoot()) {
// a valid drive ??
const UINT oldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
@@ -925,7 +853,7 @@ static bool tryDriveUNCFallback(const QFileSystemEntry &fname, QFileSystemMetaDa
fileAttrib = FILE_ATTRIBUTE_DIRECTORY;
entryExists = true;
}
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
}
#endif
if (entryExists)
@@ -949,7 +877,6 @@ static bool tryFindFallback(const QFileSystemEntry &fname, QFileSystemMetaData &
return filledData;
}
-#if !defined(Q_OS_WINCE)
//static
bool QFileSystemEngine::fillMetaData(int fd, QFileSystemMetaData &data,
QFileSystemMetaData::MetaDataFlags what)
@@ -960,7 +887,6 @@ bool QFileSystemEngine::fillMetaData(int fd, QFileSystemMetaData &data,
}
return false;
}
-#endif
//static
bool QFileSystemEngine::fillMetaData(HANDLE fHandle, QFileSystemMetaData &data,
@@ -1069,25 +995,6 @@ static inline bool mkDir(const QString &path, DWORD *lastError = 0)
{
if (lastError)
*lastError = 0;
-#if defined(Q_OS_WINCE)
- // Unfortunately CreateDirectory returns true for paths longer than
- // 256, but does not create a directory. It starts to fail, when
- // path length > MAX_PATH, which is 260 usually on CE.
- // This only happens on a Windows Mobile device. Windows CE seems
- // not to be affected by this.
- static int platformId = 0;
- if (platformId == 0) {
- wchar_t platformString[64];
- if (SystemParametersInfo(SPI_GETPLATFORMTYPE, sizeof(platformString)/sizeof(*platformString),platformString,0)) {
- if (0 == wcscmp(platformString, L"PocketPC") || 0 == wcscmp(platformString, L"Smartphone"))
- platformId = 1;
- else
- platformId = 2;
- }
- }
- if (platformId == 1 && QFSFileEnginePrivate::longFileName(path).size() > 256)
- return false;
-#endif
const QString longPath = QFSFileEnginePrivate::longFileName(path);
const bool result = ::CreateDirectory((wchar_t*)longPath.utf16(), 0);
if (lastError) // Capture lastError before any QString is freed since custom allocators might change it.
@@ -1200,9 +1107,10 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo
if (removeEmptyParents) {
dirName = QDir::toNativeSeparators(QDir::cleanPath(dirName));
for (int oldslash = 0, slash=dirName.length(); slash > 0; oldslash = slash) {
- QString chunk = dirName.left(slash);
- if (chunk.length() == 2 && chunk.at(0).isLetter() && chunk.at(1) == QLatin1Char(':'))
+ const QStringRef chunkRef = dirName.leftRef(slash);
+ if (chunkRef.length() == 2 && chunkRef.at(0).isLetter() && chunkRef.at(1) == QLatin1Char(':'))
break;
+ const QString chunk = chunkRef.toString();
if (!isDirPath(chunk, 0))
return false;
if (!rmDir(chunk))
@@ -1217,9 +1125,7 @@ bool QFileSystemEngine::removeDirectory(const QFileSystemEntry &entry, bool remo
//static
QString QFileSystemEngine::rootPath()
{
-#if defined(Q_OS_WINCE)
- QString ret = QLatin1String("/");
-#elif defined(Q_OS_WINRT)
+#if defined(Q_OS_WINRT)
// We specify the package root as root directory
QString ret = QLatin1String("/");
// Get package location
@@ -1285,13 +1191,8 @@ QString QFileSystemEngine::homePath()
+ QString::fromLocal8Bit(qgetenv("HOMEPATH"));
if (ret.isEmpty() || !QFile::exists(ret)) {
ret = QString::fromLocal8Bit(qgetenv("HOME"));
- if (ret.isEmpty() || !QFile::exists(ret)) {
-#if defined(Q_OS_WINCE)
- ret = QLatin1String("\\My Documents");
- if (!QFile::exists(ret))
-#endif
- ret = rootPath();
- }
+ if (ret.isEmpty() || !QFile::exists(ret))
+ ret = rootPath();
}
}
}
@@ -1304,10 +1205,6 @@ QString QFileSystemEngine::tempPath()
#ifndef Q_OS_WINRT
wchar_t tempPath[MAX_PATH];
const DWORD len = GetTempPath(MAX_PATH, tempPath);
-#ifdef Q_OS_WINCE
- if (len)
- ret = QString::fromWCharArray(tempPath, len);
-#else // Q_OS_WINCE
if (len) { // GetTempPath() can return short names, expand.
wchar_t longTempPath[MAX_PATH];
const DWORD longLen = GetLongPathName(tempPath, longTempPath, MAX_PATH);
@@ -1315,7 +1212,6 @@ QString QFileSystemEngine::tempPath()
QString::fromWCharArray(longTempPath, longLen) :
QString::fromWCharArray(tempPath, len);
}
-#endif // !Q_OS_WINCE
if (!ret.isEmpty()) {
while (ret.endsWith(QLatin1Char('\\')))
ret.chop(1);
@@ -1343,11 +1239,7 @@ QString QFileSystemEngine::tempPath()
ret = QDir::fromNativeSeparators(QString::fromWCharArray(path.GetRawBuffer(nullptr)));
#endif // Q_OS_WINRT
if (ret.isEmpty()) {
-#if !defined(Q_OS_WINCE)
ret = QLatin1String("C:/tmp");
-#else
- ret = QLatin1String("/Temp");
-#endif
} else if (ret.length() >= 2 && ret[1] == QLatin1Char(':'))
ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters.
return ret;
@@ -1360,7 +1252,7 @@ bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry)
if(!(meta.exists() && meta.isDirectory()))
return false;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT_WIN81)
+#if !defined(Q_OS_WINRT_WIN81)
//TODO: this should really be using nativeFilePath(), but that returns a path in long format \\?\c:\foo
//which causes many problems later on when it's returned through currentPath()
return ::SetCurrentDirectory(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(entry.filePath()).utf16())) != 0;
@@ -1373,7 +1265,7 @@ bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry)
QFileSystemEntry QFileSystemEngine::currentPath()
{
QString ret;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT_WIN81)
+#if !defined(Q_OS_WINRT_WIN81)
DWORD size = 0;
wchar_t currentName[PATH_MAX];
size = ::GetCurrentDirectory(PATH_MAX, currentName);
@@ -1389,17 +1281,13 @@ QFileSystemEntry QFileSystemEngine::currentPath()
}
if (ret.length() >= 2 && ret[1] == QLatin1Char(':'))
ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters.
-#else // !Q_OS_WINCE && !Q_OS_WINRT_WIN81
+#else // !Q_OS_WINRT_WIN81
//TODO - a race condition exists when using currentPath / setCurrentPath from multiple threads
if (qfsPrivateCurrentDir.isEmpty())
-#ifndef Q_OS_WINRT_WIN81
- qfsPrivateCurrentDir = QCoreApplication::applicationDirPath();
-#else
qfsPrivateCurrentDir = QDir::rootPath();
-#endif
ret = qfsPrivateCurrentDir;
-#endif // Q_OS_WINCE || Q_OS_WINRT_WIN81
+#endif // Q_OS_WINRT_WIN81
return QFileSystemEntry(ret, QFileSystemEntry::FromNativePath());
}
@@ -1482,31 +1370,11 @@ static inline QDateTime fileTimeToQDateTime(const FILETIME *time)
{
QDateTime ret;
-#if defined(Q_OS_WINCE)
- SYSTEMTIME systime;
- FILETIME ftime;
- systime.wYear = 1970;
- systime.wMonth = 1;
- systime.wDay = 1;
- systime.wHour = 0;
- systime.wMinute = 0;
- systime.wSecond = 0;
- systime.wMilliseconds = 0;
- systime.wDayOfWeek = 4;
- SystemTimeToFileTime(&systime, &ftime);
- unsigned __int64 acttime = (unsigned __int64)time->dwHighDateTime << 32 | time->dwLowDateTime;
- FileTimeToSystemTime(time, &systime);
- unsigned __int64 time1970 = (unsigned __int64)ftime.dwHighDateTime << 32 | ftime.dwLowDateTime;
- unsigned __int64 difftime = acttime - time1970;
- difftime /= 10000000;
- ret.setTime_t((unsigned int)difftime);
-#else
SYSTEMTIME sTime, lTime;
FileTimeToSystemTime(time, &sTime);
SystemTimeToTzSpecificLocalTime(0, &sTime, &lTime);
ret.setDate(QDate(lTime.wYear, lTime.wMonth, lTime.wDay));
ret.setTime(QTime(lTime.wHour, lTime.wMinute, lTime.wSecond, lTime.wMilliseconds));
-#endif
return ret;
}
diff --git a/src/corelib/io/qfilesystementry_p.h b/src/corelib/io/qfilesystementry_p.h
index 6bb8fc2400..300a375377 100644
--- a/src/corelib/io/qfilesystementry_p.h
+++ b/src/corelib/io/qfilesystementry_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qstring.h>
#include <QtCore/qbytearray.h>
diff --git a/src/corelib/io/qfilesystemiterator_win.cpp b/src/corelib/io/qfilesystemiterator_win.cpp
index ba195b2330..2ce7bd7a4b 100644
--- a/src/corelib/io/qfilesystemiterator_win.cpp
+++ b/src/corelib/io/qfilesystemiterator_win.cpp
@@ -40,6 +40,7 @@
#include "qfilesystemiterator_p.h"
#include "qfilesystemengine_p.h"
#include "qplatformdefs.h"
+#include "qvector.h"
#include <QtCore/qt_windows.h>
@@ -92,12 +93,10 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa
haveData = true;
int infoLevel = 0 ; // FindExInfoStandard;
DWORD dwAdditionalFlags = 0;
-#ifndef Q_OS_WINCE
if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7) {
dwAdditionalFlags = 2; // FIND_FIRST_EX_LARGE_FETCH
infoLevel = 1 ; // FindExInfoBasic;
}
-#endif
int searchOps = 0; // FindExSearchNameMatch
if (onlyDirs)
searchOps = 1 ; // FindExSearchLimitToDirectories
@@ -105,7 +104,7 @@ bool QFileSystemIterator::advance(QFileSystemEntry &fileEntry, QFileSystemMetaDa
FINDEX_SEARCH_OPS(searchOps), 0, dwAdditionalFlags);
if (findFileHandle == INVALID_HANDLE_VALUE) {
if (nativePath.startsWith(QLatin1String("\\\\?\\UNC\\"))) {
- QStringList parts = nativePath.split(QLatin1Char('\\'), QString::SkipEmptyParts);
+ const QVector<QStringRef> parts = nativePath.splitRef(QLatin1Char('\\'), QString::SkipEmptyParts);
if (parts.count() == 4 && QFileSystemEngine::uncListSharesOnServer(
QLatin1String("\\\\") + parts.at(2), &uncShares)) {
if (uncShares.isEmpty())
diff --git a/src/corelib/io/qfilesystemmetadata_p.h b/src/corelib/io/qfilesystemmetadata_p.h
index 7135c9b19b..091552f86e 100644
--- a/src/corelib/io/qfilesystemmetadata_p.h
+++ b/src/corelib/io/qfilesystemmetadata_p.h
@@ -237,9 +237,10 @@ private:
FILETIME lastAccessTime_;
FILETIME lastWriteTime_;
#else
- time_t creationTime_;
- time_t modificationTime_;
- time_t accessTime_;
+ // msec precision
+ qint64 creationTime_;
+ qint64 modificationTime_;
+ qint64 accessTime_;
uint userId_;
uint groupId_;
@@ -276,9 +277,9 @@ inline QDateTime QFileSystemMetaData::fileTime(QAbstractFileEngine::FileTime tim
#endif
#if defined(Q_OS_UNIX)
-inline QDateTime QFileSystemMetaData::creationTime() const { return QDateTime::fromTime_t(creationTime_); }
-inline QDateTime QFileSystemMetaData::modificationTime() const { return QDateTime::fromTime_t(modificationTime_); }
-inline QDateTime QFileSystemMetaData::accessTime() const { return QDateTime::fromTime_t(accessTime_); }
+inline QDateTime QFileSystemMetaData::creationTime() const { return QDateTime::fromMSecsSinceEpoch(creationTime_); }
+inline QDateTime QFileSystemMetaData::modificationTime() const { return QDateTime::fromMSecsSinceEpoch(modificationTime_); }
+inline QDateTime QFileSystemMetaData::accessTime() const { return QDateTime::fromMSecsSinceEpoch(accessTime_); }
inline uint QFileSystemMetaData::userId() const { return userId_; }
inline uint QFileSystemMetaData::groupId() const { return groupId_; }
@@ -331,13 +332,10 @@ inline void QFileSystemMetaData::fillFromFindData(WIN32_FIND_DATA &findData, boo
if (setLinkType) {
knownFlagsMask |= LinkType;
entryFlags &= ~LinkType;
-#if !defined(Q_OS_WINCE)
if ((fileAttribute_ & FILE_ATTRIBUTE_REPARSE_POINT)
&& (findData.dwReserved0 == IO_REPARSE_TAG_SYMLINK)) {
entryFlags |= LinkType;
}
-#endif
-
}
}
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp
index a186b34f85..d3aef27296 100644
--- a/src/corelib/io/qfilesystemwatcher.cpp
+++ b/src/corelib/io/qfilesystemwatcher.cpp
@@ -58,7 +58,7 @@
# include "qfilesystemwatcher_win_p.h"
#elif defined(USE_INOTIFY)
# include "qfilesystemwatcher_inotify_p.h"
-#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_OPENBSD) || defined(Q_OS_IOS)
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_OPENBSD) || defined(QT_PLATFORM_UIKIT)
# include "qfilesystemwatcher_kqueue_p.h"
#elif defined(Q_OS_OSX)
# include "qfilesystemwatcher_fsevents_p.h"
@@ -74,7 +74,7 @@ QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject
// there is a chance that inotify may fail on Linux pre-2.6.13 (August
// 2005), so we can't just new inotify directly.
return QInotifyFileSystemWatcherEngine::create(parent);
-#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_OPENBSD) || defined(Q_OS_IOS)
+#elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) || defined(Q_OS_OPENBSD) || defined(QT_PLATFORM_UIKIT)
return QKqueueFileSystemWatcherEngine::create(parent);
#elif defined(Q_OS_OSX)
return QFseventsFileSystemWatcherEngine::create(parent);
diff --git a/src/corelib/io/qfilesystemwatcher_fsevents.mm b/src/corelib/io/qfilesystemwatcher_fsevents.mm
index be9eef889a..beb8acb05f 100644
--- a/src/corelib/io/qfilesystemwatcher_fsevents.mm
+++ b/src/corelib/io/qfilesystemwatcher_fsevents.mm
@@ -198,7 +198,7 @@ void QFseventsFileSystemWatcherEngine::processEvent(ConstFSEventStreamRef stream
const FSEventStreamEventFlags eventFlags[],
const FSEventStreamEventId eventIds[])
{
-#if defined(Q_OS_OSX) && MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_6
+#if defined(Q_OS_OSX)
Q_UNUSED(streamRef);
bool needsRestart = false;
@@ -256,12 +256,6 @@ void QFseventsFileSystemWatcherEngine::processEvent(ConstFSEventStreamRef stream
if (needsRestart)
emit scheduleStreamRestart();
#else
- // This is a work-around for moc: when we put the version check at the top of the header file,
- // moc will still see the Q_OBJECT macro and generate a meta-object when compiling for 10.6,
- // which obviously won't link.
- //
- // So the trick is to still compile this class on 10.6, but never instantiate it.
-
Q_UNUSED(streamRef);
Q_UNUSED(numEvents);
Q_UNUSED(eventPaths);
diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp
index e8b49db9f3..be56d8dd1d 100644
--- a/src/corelib/io/qfilesystemwatcher_win.cpp
+++ b/src/corelib/io/qfilesystemwatcher_win.cpp
@@ -86,13 +86,9 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths,
QString path = it.next();
QString normalPath = path;
if ((normalPath.endsWith(QLatin1Char('/')) && !normalPath.endsWith(QLatin1String(":/")))
- || (normalPath.endsWith(QLatin1Char('\\')) && !normalPath.endsWith(QLatin1String(":\\")))
-#ifdef Q_OS_WINCE
- && normalPath.size() > 1)
-#else
- )
-#endif
- normalPath.chop(1);
+ || (normalPath.endsWith(QLatin1Char('\\')) && !normalPath.endsWith(QLatin1String(":\\")))) {
+ normalPath.chop(1);
+ }
QFileInfo fileInfo(normalPath);
if (!fileInfo.exists())
continue;
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp
index 2cda4d6bda..098bc49468 100644
--- a/src/corelib/io/qfsfileengine.cpp
+++ b/src/corelib/io/qfsfileengine.cpp
@@ -48,9 +48,7 @@
#ifndef QT_NO_FSFILEENGINE
-#if !defined(Q_OS_WINCE)
#include <errno.h>
-#endif
#if defined(Q_OS_UNIX)
#include "private/qcore_unix_p.h"
#endif
@@ -125,10 +123,8 @@ void QFSFileEnginePrivate::init()
{
is_sequential = 0;
tried_stat = 0;
-#if !defined(Q_OS_WINCE)
need_lstat = 1;
is_link = 0;
-#endif
openMode = QIODevice::NotOpen;
fd = -1;
fh = 0;
@@ -139,10 +135,8 @@ void QFSFileEnginePrivate::init()
fileAttrib = INVALID_FILE_ATTRIBUTES;
fileHandle = INVALID_HANDLE_VALUE;
mapHandle = NULL;
-#ifndef Q_OS_WINCE
cachedFd = -1;
#endif
-#endif
}
/*!
@@ -551,7 +545,7 @@ bool QFSFileEnginePrivate::seekFdFh(qint64 pos)
} else {
// Unbuffered stdio mode.
if (QT_LSEEK(fd, QT_OFF_T(pos), SEEK_SET) == -1) {
- qWarning() << "QFile::at: Cannot set file position" << pos;
+ qWarning("QFile::at: Cannot set file position %lld", pos);
q->setError(QFile::PositionError, qt_error_string(errno));
return false;
}
diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h
index dd498a5bc5..593ecc2687 100644
--- a/src/corelib/io/qfsfileengine_p.h
+++ b/src/corelib/io/qfsfileengine_p.h
@@ -61,10 +61,6 @@
QT_BEGIN_NAMESPACE
-#if defined(Q_OS_WINCE_STD) && _WIN32_WCE < 0x600
-#define Q_USE_DEPRECATED_MAP_API 1
-#endif
-
class QFSFileEnginePrivate;
class Q_CORE_EXPORT QFSFileEngine : public QAbstractFileEngine
@@ -184,10 +180,7 @@ public:
HANDLE mapHandle;
QHash<uchar *, DWORD /* offset % AllocationGranularity */> maps;
-#ifndef Q_OS_WINCE
mutable int cachedFd;
-#endif
-
mutable DWORD fileAttrib;
#else
QHash<uchar *, QPair<int /*offset % PageSize*/, size_t /*length + offset % PageSize*/> > maps;
@@ -206,10 +199,8 @@ public:
mutable uint is_sequential : 2;
mutable uint tried_stat : 1;
-#if !defined(Q_OS_WINCE)
mutable uint need_lstat : 1;
mutable uint is_link : 1;
-#endif
#if defined(Q_OS_WIN)
bool doStat(QFileSystemMetaData::MetaDataFlags flags) const;
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index af026b8976..5c79a745fa 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -50,13 +50,9 @@
#include "qdatetime.h"
#include "qt_windows.h"
-#if !defined(Q_OS_WINCE)
-# include <sys/types.h>
-# include <direct.h>
-# include <winioctl.h>
-#else
-# include <types.h>
-#endif
+#include <sys/types.h>
+#include <direct.h>
+#include <winioctl.h>
#include <objbase.h>
#ifndef Q_OS_WINRT
# include <shlobj.h>
@@ -77,14 +73,12 @@
QT_BEGIN_NAMESPACE
-#if !defined(Q_OS_WINCE)
static inline bool isUncPath(const QString &path)
{
// Starts with \\, but not \\.
return (path.startsWith(QLatin1String("\\\\"))
&& path.size() > 2 && path.at(2) != QLatin1Char('.'));
}
-#endif
/*!
\internal
@@ -95,7 +89,7 @@ QString QFSFileEnginePrivate::longFileName(const QString &path)
return path;
QString absPath = QFileSystemEngine::nativeAbsoluteFilePath(path);
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
QString prefix = QLatin1String("\\\\?\\");
if (isUncPath(absPath)) {
prefix.append(QLatin1String("UNC\\")); // "\\\\?\\UNC\\"
@@ -171,7 +165,6 @@ bool QFSFileEnginePrivate::nativeClose()
// Windows native mode.
bool ok = true;
-#ifndef Q_OS_WINCE
if (cachedFd != -1) {
if (::_close(cachedFd) && !::CloseHandle(fileHandle)) {
q->setError(QFile::UnspecifiedError, qt_error_string());
@@ -184,7 +177,6 @@ bool QFSFileEnginePrivate::nativeClose()
return ok;
}
-#endif
if ((fileHandle == INVALID_HANDLE_VALUE || !::CloseHandle(fileHandle))) {
q->setError(QFile::UnspecifiedError, qt_error_string());
@@ -238,24 +230,6 @@ qint64 QFSFileEnginePrivate::nativeSize() const
// Always retrive the current information
metaData.clearFlags(QFileSystemMetaData::SizeAttribute);
-#if defined(Q_OS_WINCE)
- // Buffered stdlib mode.
- if (fh) {
- QT_OFF_T oldPos = QT_FTELL(fh);
- QT_FSEEK(fh, 0, SEEK_END);
- qint64 fileSize = (qint64)QT_FTELL(fh);
- QT_FSEEK(fh, oldPos, SEEK_SET);
- if (fileSize == -1) {
- fileSize = 0;
- thatQ->setError(QFile::UnspecifiedError, qt_error_string(errno));
- }
- return fileSize;
- }
- if (fd != -1) {
- thatQ->setError(QFile::UnspecifiedError, QLatin1String("Not implemented!"));
- return 0;
- }
-#endif
bool filled = false;
if (fileHandle != INVALID_HANDLE_VALUE && openMode != QIODevice::NotOpen )
filled = QFileSystemEngine::fillMetaData(fileHandle, metaData,
@@ -287,7 +261,6 @@ qint64 QFSFileEnginePrivate::nativePos() const
if (fileHandle == INVALID_HANDLE_VALUE)
return 0;
-#if !defined(Q_OS_WINCE)
LARGE_INTEGER currentFilePos;
LARGE_INTEGER offset;
offset.QuadPart = 0;
@@ -297,18 +270,6 @@ qint64 QFSFileEnginePrivate::nativePos() const
}
return qint64(currentFilePos.QuadPart);
-#else
- LARGE_INTEGER filepos;
- filepos.HighPart = 0;
- DWORD newFilePointer = SetFilePointer(fileHandle, 0, &filepos.HighPart, FILE_CURRENT);
- if (newFilePointer == 0xFFFFFFFF && GetLastError() != NO_ERROR) {
- thatQ->setError(QFile::UnspecifiedError, qt_error_string());
- return 0;
- }
-
- filepos.LowPart = newFilePointer;
- return filepos.QuadPart;
-#endif
}
/*
@@ -323,7 +284,6 @@ bool QFSFileEnginePrivate::nativeSeek(qint64 pos)
return seekFdFh(pos);
}
-#if !defined(Q_OS_WINCE)
LARGE_INTEGER currentFilePos;
LARGE_INTEGER offset;
offset.QuadPart = pos;
@@ -333,17 +293,6 @@ bool QFSFileEnginePrivate::nativeSeek(qint64 pos)
}
return true;
-#else
- DWORD newFilePointer;
- LARGE_INTEGER *li = reinterpret_cast<LARGE_INTEGER*>(&pos);
- newFilePointer = SetFilePointer(fileHandle, li->LowPart, &li->HighPart, FILE_BEGIN);
- if (newFilePointer == 0xFFFFFFFF && GetLastError() != NO_ERROR) {
- q->setError(QFile::PositionError, qt_error_string());
- return false;
- }
-
- return true;
-#endif
}
/*
@@ -460,7 +409,6 @@ int QFSFileEnginePrivate::nativeHandle() const
{
if (fh || fd != -1)
return fh ? QT_FILENO(fh) : fd;
-#ifndef Q_OS_WINCE
if (cachedFd != -1)
return cachedFd;
@@ -471,9 +419,6 @@ int QFSFileEnginePrivate::nativeHandle() const
flags |= _O_RDONLY;
cachedFd = _open_osfhandle((intptr_t) fileHandle, flags);
return cachedFd;
-#else
- return -1;
-#endif
}
/*
@@ -481,7 +426,7 @@ int QFSFileEnginePrivate::nativeHandle() const
*/
bool QFSFileEnginePrivate::nativeIsSequential() const
{
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
HANDLE handle = fileHandle;
if (fh || fd != -1)
handle = (HANDLE)_get_osfhandle(fh ? QT_FILENO(fh) : fd);
@@ -529,35 +474,9 @@ bool QFSFileEngine::rename(const QString &newName)
bool QFSFileEngine::renameOverwrite(const QString &newName)
{
Q_D(QFSFileEngine);
-#if defined(Q_OS_WINCE)
- // Windows Embedded Compact 7 does not have MoveFileEx, simulate it with the following sequence:
- // 1. DeleteAndRenameFile (Should work on RAM FS when both files exist)
- // 2. DeleteFile/MoveFile (Should work on all file systems)
- //
- // DeleteFile/MoveFile fallback implementation violates atomicity, but it is more acceptable than
- // alternative CopyFile/DeleteFile sequence for the following reasons:
- //
- // 1. DeleteFile/MoveFile is way faster than CopyFile/DeleteFile and thus more atomic.
- // 2. Given the intended use case of this function in QSaveFile, DeleteFile/MoveFile sequence will
- // delete the old content, but leave a file "filename.ext.XXXXXX" in the same directory if MoveFile fails.
- // With CopyFile/DeleteFile sequence, it can happen that new data is partially copied to target file
- // (because CopyFile is not atomic either), thus leaving *some* content to target file.
- // This makes the need for application level recovery harder to detect than in DeleteFile/MoveFile
- // sequence where target file simply does not exist.
- //
- bool ret = ::DeleteAndRenameFile((wchar_t*)QFileSystemEntry(newName).nativeFilePath().utf16(),
- (wchar_t*)d->fileEntry.nativeFilePath().utf16()) != 0;
- if (!ret) {
- ret = ::DeleteFile((wchar_t*)QFileSystemEntry(newName).nativeFilePath().utf16()) != 0;
- if (ret || ::GetLastError() == ERROR_FILE_NOT_FOUND)
- ret = ::MoveFile((wchar_t*)d->fileEntry.nativeFilePath().utf16(),
- (wchar_t*)QFileSystemEntry(newName).nativeFilePath().utf16()) != 0;
- }
-#else
bool ret = ::MoveFileEx((wchar_t*)d->fileEntry.nativeFilePath().utf16(),
(wchar_t*)QFileSystemEntry(newName).nativeFilePath().utf16(),
MOVEFILE_REPLACE_EXISTING) != 0;
-#endif
if (!ret)
setError(QFile::RenameError, QSystemError(::GetLastError(), QSystemError::NativeError).toString());
return ret;
@@ -585,7 +504,7 @@ bool QFSFileEngine::setCurrentPath(const QString &path)
QString QFSFileEngine::currentPath(const QString &fileName)
{
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
QString ret;
//if filename is a drive: then get the pwd of that drive
if (fileName.length() >= 2 &&
@@ -604,10 +523,10 @@ QString QFSFileEngine::currentPath(const QString &fileName)
if (ret.length() >= 2 && ret[1] == QLatin1Char(':'))
ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters.
return ret;
-#else // !Q_OS_WINCE && !Q_OS_WINRT
+#else // !Q_OS_WINRT
Q_UNUSED(fileName);
return QFileSystemEngine::currentPath().filePath();
-#endif // Q_OS_WINCE || Q_OS_WINRT
+#endif // Q_OS_WINRT
}
QString QFSFileEngine::homePath()
@@ -628,12 +547,12 @@ QString QFSFileEngine::tempPath()
QFileInfoList QFSFileEngine::drives()
{
QFileInfoList ret;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
-#if defined(Q_OS_WIN32)
+#if !defined(Q_OS_WINRT)
+# if defined(Q_OS_WIN32)
const UINT oldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
quint32 driveBits = (quint32) GetLogicalDrives() & 0x3ffffff;
::SetErrorMode(oldErrorMode);
-#endif
+# endif
char driveName[] = "A:/";
while (driveBits) {
@@ -643,10 +562,10 @@ QFileInfoList QFSFileEngine::drives()
driveBits = driveBits >> 1;
}
return ret;
-#else // !Q_OS_WINCE && !Q_OS_WINRT
+#else // !Q_OS_WINRT
ret.append(QFileInfo(QLatin1String("/")));
return ret;
-#endif // Q_OS_WINCE || Q_OS_WINRT
+#endif // Q_OS_WINRT
}
bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) const
@@ -654,13 +573,11 @@ bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) cons
if (!tried_stat || !metaData.hasFlags(flags)) {
tried_stat = true;
-#if !defined(Q_OS_WINCE)
int localFd = fd;
if (fh && fileEntry.isEmpty())
localFd = QT_FILENO(fh);
if (localFd != -1)
QFileSystemEngine::fillMetaData(localFd, metaData, flags);
-#endif
if (metaData.missingFlags(flags) && !fileEntry.isEmpty())
QFileSystemEngine::fillMetaData(fileEntry, metaData, metaData.missingFlags(flags));
}
@@ -671,8 +588,8 @@ bool QFSFileEnginePrivate::doStat(QFileSystemMetaData::MetaDataFlags flags) cons
bool QFSFileEngine::link(const QString &newName)
{
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
-#if !defined(QT_NO_LIBRARY)
+#if !defined(Q_OS_WINRT)
+# if !defined(QT_NO_LIBRARY)
bool ret = false;
QString linkName = newName;
@@ -713,24 +630,11 @@ bool QFSFileEngine::link(const QString &newName)
CoUninitialize();
return ret;
-#else
+# else // QT_NO_LIBRARY
Q_UNUSED(newName);
return false;
-#endif // QT_NO_LIBRARY
-#elif defined(Q_OS_WINCE) && !defined(QT_NO_WINCE_SHELLSDK)
- QString linkName = newName;
- linkName.replace(QLatin1Char('/'), QLatin1Char('\\'));
- if (!linkName.endsWith(QLatin1String(".lnk")))
- linkName += QLatin1String(".lnk");
- QString orgName = fileName(AbsoluteName).replace(QLatin1Char('/'), QLatin1Char('\\'));
- // Need to append on our own
- orgName.prepend(QLatin1Char('"'));
- orgName.append(QLatin1Char('"'));
- bool ret = SUCCEEDED(SHCreateShortcut((wchar_t*)linkName.utf16(), (wchar_t*)orgName.utf16()));
- if (!ret)
- setError(QFile::RenameError, qt_error_string());
- return ret;
-#else // Q_OS_WINCE && !QT_NO_WINCE_SHELLSDK
+# endif // QT_NO_LIBRARY
+#else // !Q_OS_WINRT
Q_UNUSED(newName);
Q_UNIMPLEMENTED();
return false;
@@ -811,7 +715,6 @@ QString QFSFileEngine::fileName(FileName file) const
QString ret;
if (!isRelativePath()) {
-#if !defined(Q_OS_WINCE)
if (d->fileEntry.filePath().startsWith(QLatin1Char('/')) || // It's a absolute path to the current drive, so \a.txt -> Z:\a.txt
d->fileEntry.filePath().size() == 2 || // It's a drive letter that needs to get a working dir appended
(d->fileEntry.filePath().size() > 2 && d->fileEntry.filePath().at(2) != QLatin1Char('/')) || // It's a drive-relative path, so Z:a.txt -> Z:\currentpath\a.txt
@@ -819,9 +722,7 @@ QString QFSFileEngine::fileName(FileName file) const
d->fileEntry.filePath().endsWith(QLatin1String("/..")) || d->fileEntry.filePath().endsWith(QLatin1String("/.")))
{
ret = QDir::fromNativeSeparators(QFileSystemEngine::nativeAbsoluteFilePath(d->fileEntry.filePath()));
- } else
-#endif
- {
+ } else {
ret = d->fileEntry.filePath();
}
} else {
@@ -903,14 +804,12 @@ bool QFSFileEngine::setSize(qint64 size)
if (d->fileHandle != INVALID_HANDLE_VALUE || d->fd != -1 || d->fh) {
// resize open file
HANDLE fh = d->fileHandle;
-#if !defined(Q_OS_WINCE)
if (fh == INVALID_HANDLE_VALUE) {
if (d->fh)
fh = (HANDLE)_get_osfhandle(QT_FILENO(d->fh));
else
fh = (HANDLE)_get_osfhandle(d->fd);
}
-#endif
if (fh == INVALID_HANDLE_VALUE)
return false;
qint64 currentPos = pos();
@@ -982,10 +881,8 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size,
// get handle to the file
HANDLE handle = fileHandle;
-#ifndef Q_OS_WINCE
if (handle == INVALID_HANDLE_VALUE && fh)
handle = (HANDLE)::_get_osfhandle(QT_FILENO(fh));
-#endif
#ifdef Q_USE_DEPRECATED_MAP_API
nativeClose();
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index f5b17318be..c560bc7a03 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -739,6 +739,18 @@ void QIODevicePrivate::setWriteChannelCount(int count)
}
/*!
+ \internal
+*/
+bool QIODevicePrivate::allWriteBuffersEmpty() const
+{
+ for (const QRingBuffer &ringBuffer : writeBuffers) {
+ if (!ringBuffer.isEmpty())
+ return false;
+ }
+ return true;
+}
+
+/*!
Opens the device and sets its OpenMode to \a mode. Returns \c true if successful;
otherwise returns \c false. This function should be called from any
reimplementations of open() or other functions that open the device.
@@ -1148,34 +1160,31 @@ QByteArray QIODevice::read(qint64 maxSize)
Q_D(QIODevice);
QByteArray result;
- CHECK_MAXLEN(read, result);
-
#if defined QIODEVICE_DEBUG
printf("%p QIODevice::read(%lld), d->pos = %lld, d->buffer.size() = %lld\n",
this, maxSize, d->pos, d->buffer.size());
#endif
+ // Try to prevent the data from being copied, if we have a chunk
+ // with the same size in the read buffer.
+ if (maxSize == d->buffer.nextDataBlockSize() && !d->transactionStarted
+ && (d->openMode & (QIODevice::ReadOnly | QIODevice::Text)) == QIODevice::ReadOnly) {
+ result = d->buffer.read();
+ if (!d->isSequential())
+ d->pos += maxSize;
+ if (d->buffer.isEmpty())
+ readData(nullptr, 0);
+ return result;
+ }
+
+ CHECK_MAXLEN(read, result);
if (maxSize >= MaxByteArraySize) {
checkWarnMessage(this, "read", "maxSize argument exceeds QByteArray size limit");
maxSize = MaxByteArraySize - 1;
}
- qint64 readBytes = 0;
- if (maxSize) {
- result.resize(int(maxSize));
- if (!result.size()) {
- // If resize fails, read incrementally.
- qint64 readResult;
- do {
- result.resize(int(qMin(maxSize, qint64(result.size() + d->readBufferChunkSize))));
- readResult = read(result.data() + readBytes, result.size() - readBytes);
- if (readResult > 0 || readBytes == 0)
- readBytes += readResult;
- } while (readResult == d->readBufferChunkSize);
- } else {
- readBytes = read(result.data(), result.size());
- }
- }
+ result.resize(int(maxSize));
+ qint64 readBytes = read(result.data(), result.size());
if (readBytes <= 0)
result.clear();
diff --git a/src/corelib/io/qiodevice_p.h b/src/corelib/io/qiodevice_p.h
index d264bfd31d..76bec89ef2 100644
--- a/src/corelib/io/qiodevice_p.h
+++ b/src/corelib/io/qiodevice_p.h
@@ -92,6 +92,8 @@ public:
friend class QIODevicePrivate;
public:
// wrap functions from QRingBuffer
+ inline void setChunkSize(int size) { Q_ASSERT(m_buf); m_buf->setChunkSize(size); }
+ inline int chunkSize() const { Q_ASSERT(m_buf); return m_buf->chunkSize(); }
inline qint64 nextDataBlockSize() const { return (m_buf ? m_buf->nextDataBlockSize() : Q_INT64_C(0)); }
inline const char *readPointer() const { return (m_buf ? m_buf->readPointer() : Q_NULLPTR); }
inline const char *readPointerAtPosition(qint64 pos, qint64 &length) const { Q_ASSERT(m_buf); return m_buf->readPointerAtPosition(pos, length); }
@@ -152,6 +154,8 @@ public:
return buffer.isEmpty() || (transactionStarted && isSequential()
&& transactionPos == buffer.size());
}
+ bool allWriteBuffersEmpty() const;
+
void seekBuffer(qint64 newPos);
inline void setCurrentReadChannel(int channel)
diff --git a/src/corelib/io/qipaddress_p.h b/src/corelib/io/qipaddress_p.h
index 52fa9c05ad..5a478ae27b 100644
--- a/src/corelib/io/qipaddress_p.h
+++ b/src/corelib/io/qipaddress_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qstring.h"
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/io/qlockfile_p.h b/src/corelib/io/qlockfile_p.h
index d7f2a1d52d..86a606ec00 100644
--- a/src/corelib/io/qlockfile_p.h
+++ b/src/corelib/io/qlockfile_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qlockfile.h>
#include <QtCore/qfile.h>
diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp
index fda012dad3..82beb15912 100644
--- a/src/corelib/io/qlockfile_unix.cpp
+++ b/src/corelib/io/qlockfile_unix.cpp
@@ -70,7 +70,7 @@
# include <cstdio>
#elif defined(Q_OS_HAIKU)
# include <kernel/OS.h>
-#elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS)
+#elif defined(Q_OS_BSD4) && !defined(QT_PLATFORM_UIKIT)
# include <sys/cdefs.h>
# include <sys/param.h>
# include <sys/sysctl.h>
@@ -283,7 +283,7 @@ QString QLockFilePrivate::processNameByPid(qint64 pid)
if (get_thread_info(pid, &info) != B_OK)
return QString();
return QFile::decodeName(info.name);
-#elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS)
+#elif defined(Q_OS_BSD4) && !defined(QT_PLATFORM_UIKIT)
# if defined(Q_OS_NETBSD)
struct kinfo_proc2 kp;
int mib[6] = { CTL_KERN, KERN_PROC2, KERN_PROC_PID, (int)pid, sizeof(struct kinfo_proc2), 1 };
diff --git a/src/corelib/io/qlockfile_win.cpp b/src/corelib/io/qlockfile_win.cpp
index 4afab3d135..baaff8da17 100644
--- a/src/corelib/io/qlockfile_win.cpp
+++ b/src/corelib/io/qlockfile_win.cpp
@@ -100,7 +100,7 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys()
? QLockFile::LockFailedError
: QLockFile::PermissionError;
default:
- qWarning() << "Got unexpected locking error" << lastError;
+ qWarning("Got unexpected locking error %llu", quint64(lastError));
return QLockFile::UnknownError;
}
}
@@ -165,7 +165,7 @@ bool QLockFilePrivate::isApparentlyStale() const
QString QLockFilePrivate::processNameByPid(qint64 pid)
{
-#if !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE)
+#if !defined(Q_OS_WINRT)
typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD);
HMODULE hPsapi = LoadLibraryA("psapi");
diff --git a/src/corelib/io/qloggingregistry_p.h b/src/corelib/io/qloggingregistry_p.h
index b8b62e034f..5197da1ba4 100644
--- a/src/corelib/io/qloggingregistry_p.h
+++ b/src/corelib/io/qloggingregistry_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qloggingcategory.h>
#include <QtCore/qmap.h>
#include <QtCore/qmutex.h>
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 3a475c0267..f9b3b9fb00 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -48,9 +48,6 @@
#if defined QPROCESS_DEBUG
#include <qstring.h>
#include <ctype.h>
-#if !defined(Q_OS_WINCE)
-#include <errno.h>
-#endif
QT_BEGIN_NAMESPACE
/*
@@ -1988,13 +1985,6 @@ qint64 QProcess::writeData(const char *data, qint64 len)
{
Q_D(QProcess);
-#if defined(Q_OS_WINCE)
- Q_UNUSED(data);
- Q_UNUSED(len);
- d->setErrorAndEmit(QProcess::WriteError);
- return -1;
-#endif
-
if (d->stdinChannel.closed) {
#if defined QPROCESS_DEBUG
qDebug("QProcess::writeData(%p \"%s\", %lld) == 0 (write channel closing)",
@@ -2171,7 +2161,6 @@ void QProcessPrivate::start(QIODevice::OpenMode mode)
mode &= ~QIODevice::ReadOnly; // not open for reading
if (mode == 0)
mode = QIODevice::Unbuffered;
-#ifndef Q_OS_WINCE
if ((mode & QIODevice::ReadOnly) == 0) {
if (stdoutChannel.type == QProcessPrivate::Channel::Normal)
q->setStandardOutputFile(q->nullDevice());
@@ -2179,7 +2168,6 @@ void QProcessPrivate::start(QIODevice::OpenMode mode)
&& processChannelMode != QProcess::MergedChannels)
q->setStandardErrorFile(q->nullDevice());
}
-#endif
q->QIODevice::open(mode);
@@ -2537,7 +2525,7 @@ QT_BEGIN_INCLUDE_NAMESPACE
#if defined(Q_OS_MACX)
# include <crt_externs.h>
# define environ (*_NSGetEnviron())
-#elif defined(Q_OS_WINCE) || defined(Q_OS_IOS)
+#elif defined(QT_PLATFORM_UIKIT)
static char *qt_empty_environ[] = { 0 };
#define environ qt_empty_environ
#elif !defined(Q_OS_WIN)
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 8c5589538d..1d425653a3 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -322,7 +322,7 @@ QT_END_INCLUDE_NAMESPACE
QProcessEnvironment QProcessEnvironment::systemEnvironment()
{
QProcessEnvironment env;
-#if !defined(Q_OS_IOS)
+#if !defined(QT_PLATFORM_UIKIT)
const char *entry;
for (int count = 0; (entry = environ[count]); ++count) {
const char *equal = strchr(entry, '=');
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index 96b39efe3a..8579db1694 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -867,13 +867,15 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a
bool success = false;
PROCESS_INFORMATION pinfo;
+ DWORD dwCreationFlags = (GetConsoleWindow() ? 0 : CREATE_NO_WINDOW);
+ dwCreationFlags |= CREATE_UNICODE_ENVIRONMENT;
STARTUPINFOW startupInfo = { sizeof( STARTUPINFO ), 0, 0, 0,
(ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT,
(ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
success = CreateProcess(0, (wchar_t*)args.utf16(),
- 0, 0, FALSE, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE, 0,
+ 0, 0, FALSE, dwCreationFlags, 0,
workingDir.isEmpty() ? 0 : (wchar_t*)workingDir.utf16(),
&startupInfo, &pinfo);
diff --git a/src/corelib/io/qprocess_wince.cpp b/src/corelib/io/qprocess_wince.cpp
deleted file mode 100644
index 824a6158dc..0000000000
--- a/src/corelib/io/qprocess_wince.cpp
+++ /dev/null
@@ -1,308 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qprocess.h"
-#include "qprocess_p.h"
-
-#include <qdir.h>
-#include <qfileinfo.h>
-#include <qregexp.h>
-#include <qtimer.h>
-#include <qwineventnotifier.h>
-#include <qdebug.h>
-#include <private/qthread_p.h>
-
-#ifndef QT_NO_PROCESS
-
-QT_BEGIN_NAMESPACE
-
-//#define QPROCESS_DEBUG
-
-void QProcessPrivate::destroyPipe(Q_PIPE pipe[2])
-{
- Q_UNUSED(pipe);
-}
-
-void QProcessPrivate::closeChannel(Channel *channel)
-{
- Q_UNUSED(channel);
-}
-
-static QString qt_create_commandline(const QString &program, const QStringList &arguments)
-{
- QString args;
- if (!program.isEmpty()) {
- QString programName = program;
- if (!programName.startsWith(QLatin1Char('\"')) && !programName.endsWith(QLatin1Char('\"')) && programName.contains(QLatin1Char(' ')))
- programName = QLatin1Char('\"') + programName + QLatin1Char('\"');
- programName.replace(QLatin1Char('/'), QLatin1Char('\\'));
-
- // add the prgram as the first arg ... it works better
- args = programName + QLatin1Char(' ');
- }
-
- for (int i=0; i<arguments.size(); ++i) {
- QString tmp = arguments.at(i);
- // Quotes are escaped and their preceding backslashes are doubled.
- tmp.replace(QRegExp(QLatin1String("(\\\\*)\"")), QLatin1String("\\1\\1\\\""));
- if (tmp.isEmpty() || tmp.contains(QLatin1Char(' ')) || tmp.contains(QLatin1Char('\t'))) {
- // The argument must not end with a \ since this would be interpreted
- // as escaping the quote -- rather put the \ behind the quote: e.g.
- // rather use "foo"\ than "foo\"
- int i = tmp.length();
- while (i > 0 && tmp.at(i - 1) == QLatin1Char('\\'))
- --i;
- tmp.insert(i, QLatin1Char('"'));
- tmp.prepend(QLatin1Char('"'));
- }
- args += QLatin1Char(' ') + tmp;
- }
- return args;
-}
-
-QProcessEnvironment QProcessEnvironment::systemEnvironment()
-{
- QProcessEnvironment env;
- return env;
-}
-
-void QProcessPrivate::startProcess()
-{
- Q_Q(QProcess);
-
- bool success = false;
-
- if (pid) {
- CloseHandle(pid->hThread);
- CloseHandle(pid->hProcess);
- delete pid;
- pid = 0;
- }
- pid = new PROCESS_INFORMATION;
- memset(pid, 0, sizeof(PROCESS_INFORMATION));
-
- q->setProcessState(QProcess::Starting);
-
- QString args = qt_create_commandline(QString(), arguments);
- if (!nativeArguments.isEmpty()) {
- if (!args.isEmpty())
- args += QLatin1Char(' ');
- args += nativeArguments;
- }
-
-#if defined QPROCESS_DEBUG
- qDebug("Creating process");
- qDebug(" program : [%s]", program.toLatin1().constData());
- qDebug(" args : %s", args.toLatin1().constData());
- qDebug(" pass environment : %s", environment.isEmpty() ? "no" : "yes");
-#endif
-
- QString fullPathProgram = program;
- if (!QDir::isAbsolutePath(fullPathProgram))
- fullPathProgram = QFileInfo(fullPathProgram).absoluteFilePath();
- fullPathProgram.replace(QLatin1Char('/'), QLatin1Char('\\'));
- success = CreateProcess((wchar_t*)fullPathProgram.utf16(),
- (wchar_t*)args.utf16(),
- 0, 0, false, 0, 0, 0, 0, pid);
-
- if (!success) {
- cleanup();
- setErrorAndEmit(QProcess::FailedToStart);
- q->setProcessState(QProcess::NotRunning);
- return;
- }
-
- q->setProcessState(QProcess::Running);
- // User can call kill()/terminate() from the stateChanged() slot
- // so check before proceeding
- if (!pid)
- return;
-
- if (threadData->hasEventDispatcher()) {
- processFinishedNotifier = new QWinEventNotifier(pid->hProcess, q);
- QObject::connect(processFinishedNotifier, SIGNAL(activated(HANDLE)), q, SLOT(_q_processDied()));
- processFinishedNotifier->setEnabled(true);
- }
-
- // give the process a chance to start ...
- Sleep(20);
- _q_startupNotification();
-}
-
-bool QProcessPrivate::processStarted(QString * /*errorMessage*/)
-{
- return processState == QProcess::Running;
-}
-
-qint64 QProcessPrivate::bytesAvailableInChannel(const Channel *) const
-{
- return 0;
-}
-
-qint64 QProcessPrivate::readFromChannel(const Channel *, char *data, qint64 maxlen)
-{
- return -1;
-}
-
-static BOOL QT_WIN_CALLBACK qt_terminateApp(HWND hwnd, LPARAM procId)
-{
- DWORD currentProcId = 0;
- GetWindowThreadProcessId(hwnd, &currentProcId);
- if (currentProcId == (DWORD)procId)
- PostMessage(hwnd, WM_CLOSE, 0, 0);
-
- return TRUE;
-}
-
-void QProcessPrivate::terminateProcess()
-{
- if (pid) {
- EnumWindows(qt_terminateApp, (LPARAM)pid->dwProcessId);
- PostThreadMessage(pid->dwThreadId, WM_CLOSE, 0, 0);
- }
-}
-
-void QProcessPrivate::killProcess()
-{
- if (pid)
- TerminateProcess(pid->hProcess, 0xf291);
-}
-
-bool QProcessPrivate::waitForStarted(int)
-{
- Q_Q(QProcess);
-
- if (processStarted())
- return true;
-
- if (processError == QProcess::FailedToStart)
- return false;
-
- setError(QProcess::Timedout);
- return false;
-}
-
-bool QProcessPrivate::drainOutputPipes()
-{
- return true;
-}
-
-bool QProcessPrivate::waitForReadyRead(int msecs)
-{
- return false;
-}
-
-bool QProcessPrivate::waitForBytesWritten(int msecs)
-{
- return false;
-}
-
-bool QProcessPrivate::waitForFinished(int msecs)
-{
- Q_Q(QProcess);
-#if defined QPROCESS_DEBUG
- qDebug("QProcessPrivate::waitForFinished(%d)", msecs);
-#endif
-
- if (!pid)
- return true;
-
- if (WaitForSingleObject(pid->hProcess, msecs == -1 ? INFINITE : msecs) == WAIT_OBJECT_0) {
- _q_processDied();
- return true;
- }
-
- setError(QProcess::Timedout);
- return false;
-}
-
-void QProcessPrivate::findExitCode()
-{
- DWORD theExitCode;
- if (GetExitCodeProcess(pid->hProcess, &theExitCode)) {
- exitCode = theExitCode;
- //### for now we assume a crash if exit code is less than -1 or the magic number
- crashed = (exitCode == 0xf291 || (int)exitCode < 0);
- }
-}
-
-void QProcessPrivate::flushPipeWriter()
-{
-}
-
-qint64 QProcessPrivate::pipeWriterBytesToWrite() const
-{
- return 0;
-}
-
-bool QProcessPrivate::writeToStdin()
-{
- return false;
-}
-
-bool QProcessPrivate::startDetached(const QString &program, const QStringList &arguments, const QString &workingDir, qint64 *pid)
-{
- Q_UNUSED(workingDir);
- QString args = qt_create_commandline(QString(), arguments);
-
- bool success = false;
-
- PROCESS_INFORMATION pinfo;
-
- QString fullPathProgram = program;
- if (!QDir::isAbsolutePath(fullPathProgram))
- fullPathProgram.prepend(QDir::currentPath().append(QLatin1Char('/')));
- fullPathProgram.replace(QLatin1Char('/'), QLatin1Char('\\'));
- success = CreateProcess((wchar_t*)fullPathProgram.utf16(),
- (wchar_t*)args.utf16(),
- 0, 0, false, CREATE_NEW_CONSOLE, 0, 0, 0, &pinfo);
-
- if (success) {
- CloseHandle(pinfo.hThread);
- CloseHandle(pinfo.hProcess);
- if (pid)
- *pid = pinfo.dwProcessId;
- }
-
- return success;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_PROCESS
diff --git a/src/corelib/io/qresource.cpp b/src/corelib/io/qresource.cpp
index 96957ac11d..7fe3753da4 100644
--- a/src/corelib/io/qresource.cpp
+++ b/src/corelib/io/qresource.cpp
@@ -303,12 +303,12 @@ QResourcePrivate::ensureInitialized() const
if(!that->absoluteFilePath.startsWith(QLatin1Char(':')))
that->absoluteFilePath.prepend(QLatin1Char(':'));
- QString path = fileName;
+ QStringRef path(&fileName);
if(path.startsWith(QLatin1Char(':')))
path = path.mid(1);
if(path.startsWith(QLatin1Char('/'))) {
- that->load(path);
+ that->load(path.toString());
} else {
QMutexLocker lock(resourceMutex());
QStringList searchPaths = *resourceSearchPaths();
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index eb6cadceec..a7aa13fa45 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -81,7 +81,6 @@
#include <stdlib.h>
#ifdef Q_OS_WIN // for homedirpath reading from registry
-# include <private/qsystemlibrary_p.h>
# include <qt_windows.h>
# ifndef Q_OS_WINRT
# include <shlobj.h>
@@ -110,7 +109,7 @@ using namespace ABI::Windows::Storage;
#define Q_XDG_PLATFORM
#endif
-#if !defined(QT_NO_STANDARDPATHS) && (defined(Q_XDG_PLATFORM) || defined(Q_OS_IOS))
+#if !defined(QT_NO_STANDARDPATHS) && (defined(Q_XDG_PLATFORM) || defined(QT_PLATFORM_UIKIT))
#define QSETTINGS_USE_QSTANDARDPATHS
#endif
@@ -966,21 +965,12 @@ static QString windowsConfigPath(int type)
if (result.isEmpty()) {
switch (type) {
-#ifndef Q_OS_WINCE
case CSIDL_COMMON_APPDATA:
result = QLatin1String("C:\\temp\\qt-common");
break;
case CSIDL_APPDATA:
result = QLatin1String("C:\\temp\\qt-user");
break;
-#else
- case CSIDL_COMMON_APPDATA:
- result = QLatin1String("\\Temp\\qt-common");
- break;
- case CSIDL_APPDATA:
- result = QLatin1String("\\Temp\\qt-user");
- break;
-#endif
default:
;
}
diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp
index d73cc4d298..7f857a77a4 100644
--- a/src/corelib/io/qsettings_mac.cpp
+++ b/src/corelib/io/qsettings_mac.cpp
@@ -181,7 +181,7 @@ static QCFType<CFPropertyListRef> macValue(const QVariant &value)
QDateTime dt = value.toDateTime();
if (dt.timeSpec() == Qt::LocalTime) {
QDateTime reference;
- reference.setTime_t((uint)kCFAbsoluteTimeIntervalSince1970);
+ reference.setSecsSinceEpoch(qint64(kCFAbsoluteTimeIntervalSince1970));
result = CFDateCreate(kCFAllocatorDefault, CFAbsoluteTime(reference.secsTo(dt)));
} else {
goto string_case;
@@ -293,7 +293,7 @@ static QVariant qtValue(CFPropertyListRef cfvalue)
return map;
} else if (typeId == CFDateGetTypeID()) {
QDateTime dt;
- dt.setTime_t((uint)kCFAbsoluteTimeIntervalSince1970);
+ dt.setSecsSinceEpoch(qint64(kCFAbsoluteTimeIntervalSince1970));
return dt.addSecs((int)CFDateGetAbsoluteTime(static_cast<CFDateRef>(cfvalue)));
}
return QVariant();
@@ -541,31 +541,7 @@ void QMacSettingsPrivate::sync()
domains[i].userName, hostNames[j]);
// only report failures for the primary file (the one we write to)
if (!ok && i == 0 && hostNames[j] == hostName && status == QSettings::NoError) {
-#if 1
- if (QSysInfo::macVersion() < QSysInfo::MV_10_7) {
- // work around what seems to be a bug in CFPreferences:
- // don't report an error if there are no preferences for the application
- QCFType<CFArrayRef> appIds = CFPreferencesCopyApplicationList(domains[i].userName,
- hostNames[j]);
-
- // iterate through all the applications and see if we're there
- CFIndex size = CFArrayGetCount(appIds);
- for (CFIndex k = 0; k < size; ++k) {
- const void *cfvalue = CFArrayGetValueAtIndex(appIds, k);
- if (CFGetTypeID(cfvalue) == CFStringGetTypeID()) {
- if (CFStringCompare(static_cast<CFStringRef>(cfvalue),
- domains[i].applicationOrSuiteId,
- kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
- setStatus(QSettings::AccessError);
- break;
- }
- }
- }
- } else
-#endif
- {
- setStatus(QSettings::AccessError);
- }
+ setStatus(QSettings::AccessError);
}
}
}
diff --git a/src/corelib/io/qsettings_win.cpp b/src/corelib/io/qsettings_win.cpp
index 05ed51e999..7c6b782acd 100644
--- a/src/corelib/io/qsettings_win.cpp
+++ b/src/corelib/io/qsettings_win.cpp
@@ -609,16 +609,12 @@ HKEY QWinSettingsPrivate::writeHandle() const
QWinSettingsPrivate::~QWinSettingsPrivate()
{
if (deleteWriteHandleOnExit && writeHandle() != 0) {
-#if defined(Q_OS_WINCE)
- remove(regList.at(0).key());
-#else
QString emptyKey;
DWORD res = RegDeleteKey(writeHandle(), reinterpret_cast<const wchar_t *>(emptyKey.utf16()));
if (res != ERROR_SUCCESS) {
qWarning("QSettings: Failed to delete key \"%s\": %s",
regList.at(0).key().toLatin1().data(), errorCodeToString(res).toLatin1().data());
}
-#endif
}
for (int i = 0; i < regList.size(); ++i)
@@ -660,10 +656,6 @@ void QWinSettingsPrivate::remove(const QString &uKey)
}
}
} else {
-#if defined(Q_OS_WINCE)
- // For WinCE always Close the handle first.
- RegCloseKey(handle);
-#endif
res = RegDeleteKey(writeHandle(), reinterpret_cast<const wchar_t *>(rKey.utf16()));
if (res != ERROR_SUCCESS) {
diff --git a/src/corelib/io/qstandardpaths.h b/src/corelib/io/qstandardpaths.h
index fff1a29bf3..df76d73eae 100644
--- a/src/corelib/io/qstandardpaths.h
+++ b/src/corelib/io/qstandardpaths.h
@@ -41,6 +41,7 @@
#define QSTANDARDPATHS_H
#include <QtCore/qstringlist.h>
+#include <QtCore/qobjectdefs.h>
QT_BEGIN_NAMESPACE
@@ -49,6 +50,8 @@ QT_BEGIN_NAMESPACE
class Q_CORE_EXPORT QStandardPaths
{
+ Q_GADGET
+
public:
// Do not re-order, must match QDesktopServices
enum StandardLocation {
@@ -73,6 +76,7 @@ public:
AppConfigLocation,
AppLocalDataLocation = DataLocation
};
+ Q_ENUM(StandardLocation)
static QString writableLocation(StandardLocation type);
static QStringList standardLocations(StandardLocation type);
@@ -82,6 +86,7 @@ public:
LocateDirectory = 0x1
};
Q_DECLARE_FLAGS(LocateOptions, LocateOption)
+ Q_FLAG(LocateOptions)
static QString locate(StandardLocation type, const QString &fileName, LocateOptions options = LocateFile);
static QStringList locateAll(StandardLocation type, const QString &fileName, LocateOptions options = LocateFile);
@@ -103,6 +108,8 @@ private:
~QStandardPaths();
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QStandardPaths::LocateOptions)
+
#endif // QT_NO_STANDARDPATHS
QT_END_NAMESPACE
diff --git a/src/corelib/io/qstandardpaths_mac.mm b/src/corelib/io/qstandardpaths_mac.mm
index f08a6dac53..dc3d7737b6 100644
--- a/src/corelib/io/qstandardpaths_mac.mm
+++ b/src/corelib/io/qstandardpaths_mac.mm
@@ -117,7 +117,7 @@ static QString baseWritableLocation(QStandardPaths::StandardLocation type,
case QStandardPaths::TempLocation:
path = QDir::tempPath();
break;
-#ifdef Q_OS_IOS
+#if defined(QT_PLATFORM_UIKIT)
// These locations point to non-existing write-protected paths. Use sensible fallbacks.
case QStandardPaths::MusicLocation:
path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Music");
@@ -204,7 +204,7 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
{
QStringList dirs;
-#ifdef Q_OS_IOS
+#if defined(QT_PLATFORM_UIKIT)
if (type == PicturesLocation)
dirs << writableLocation(PicturesLocation) << QLatin1String("assets-library://");
#endif
diff --git a/src/corelib/io/qstandardpaths_unix.cpp b/src/corelib/io/qstandardpaths_unix.cpp
index bcbc9664ef..0561e5833f 100644
--- a/src/corelib/io/qstandardpaths_unix.cpp
+++ b/src/corelib/io/qstandardpaths_unix.cpp
@@ -223,7 +223,7 @@ QString QStandardPaths::writableLocation(StandardLocation type)
if (!value.isEmpty()) {
// value can start with $HOME
if (value.startsWith(QLatin1String("$HOME")))
- value = QDir::homePath() + value.mid(5);
+ value = QDir::homePath() + value.midRef(5);
if (value.length() > 1 && value.endsWith(QLatin1Char('/')))
value.chop(1);
return value;
diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp
index 9bd5a9e3b6..38c63553ea 100644
--- a/src/corelib/io/qstandardpaths_win.cpp
+++ b/src/corelib/io/qstandardpaths_win.cpp
@@ -51,13 +51,7 @@ const GUID qCLSID_FOLDERID_Downloads = { 0x374de290, 0x123f, 0x4565, { 0x91, 0x6
#include <qt_windows.h>
#include <shlobj.h>
-#if !defined(Q_OS_WINCE)
-# include <intshcut.h>
-#else
-# if !defined(STANDARDSHELL_UI_MODEL)
-# include <winx.h>
-# endif
-#endif
+#include <intshcut.h>
#ifndef CSIDL_MYMUSIC
#define CSIDL_MYMUSIC 13
@@ -117,7 +111,6 @@ static inline void appendTestMode(QString &path)
// Map QStandardPaths::StandardLocation to CLSID of SHGetSpecialFolderPath()
static int writableSpecialFolderClsid(QStandardPaths::StandardLocation type)
{
-#ifndef Q_OS_WINCE
static const int clsids[] = {
CSIDL_DESKTOPDIRECTORY, // DesktopLocation
CSIDL_PERSONAL, // DocumentsLocation
@@ -137,27 +130,6 @@ static int writableSpecialFolderClsid(QStandardPaths::StandardLocation type)
CSIDL_APPDATA, // AppDataLocation ("Roaming" path)
CSIDL_LOCAL_APPDATA, // AppConfigLocation ("Local" path)
};
-#else // !Q_OS_WINCE
- static const int clsids[] = {
- CSIDL_DESKTOPDIRECTORY, // DesktopLocation
- CSIDL_PERSONAL, // DocumentsLocation
- CSIDL_FONTS, // FontsLocation
- CSIDL_PROGRAMS, // ApplicationsLocation
- CSIDL_MYMUSIC, // MusicLocation
- CSIDL_MYVIDEO, // MoviesLocation
- CSIDL_MYPICTURES, // PicturesLocation
- -1, -1, // TempLocation/HomeLocation
- CSIDL_APPDATA, // AppLocalDataLocation, AppLocalDataLocation = DataLocation
- -1, // CacheLocation
- CSIDL_APPDATA, // GenericDataLocation
- -1, // RuntimeLocation
- CSIDL_APPDATA, // ConfigLocation
- -1, -1, // DownloadLocation/GenericCacheLocation
- CSIDL_APPDATA, // GenericConfigLocation
- CSIDL_APPDATA, // AppDataLocation
- CSIDL_APPDATA, // AppConfigLocation
- };
-#endif // Q_OS_WINCE
Q_STATIC_ASSERT(sizeof(clsids) / sizeof(clsids[0]) == size_t(QStandardPaths::AppConfigLocation + 1));
return size_t(type) < sizeof(clsids) / sizeof(clsids[0]) ? clsids[type] : -1;
@@ -183,7 +155,6 @@ static QString sHGetSpecialFolderPath(int clsid, QStandardPaths::StandardLocatio
static QString sHGetKnownFolderPath(const GUID &clsid, QStandardPaths::StandardLocation type, bool warn = false)
{
QString result;
-#ifndef Q_OS_WINCE
typedef HRESULT (WINAPI *GetKnownFolderPath)(const GUID&, DWORD, HANDLE, LPWSTR*);
static const GetKnownFolderPath sHGetKnownFolderPath = // Vista onwards.
@@ -199,11 +170,6 @@ static QString sHGetKnownFolderPath(const GUID &clsid, QStandardPaths::StandardL
qPrintable(displayName(type)));
}
}
-#else // !Q_OS_WINCE
- Q_UNUSED(clsid)
- Q_UNUSED(type)
- Q_UNUSED(warn)
-#endif
return result;
}
@@ -266,7 +232,6 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
dirs.append(localDir);
// type-specific handling goes here
-#ifndef Q_OS_WINCE
if (isConfigLocation(type)) {
QString programData = sHGetSpecialFolderPath(CSIDL_COMMON_APPDATA, type);
if (!programData.isEmpty()) {
@@ -274,12 +239,11 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
appendOrganizationAndApp(programData);
dirs.append(programData);
}
-# ifndef QT_BOOTSTRAPPED
+#ifndef QT_BOOTSTRAPPED
dirs.append(QCoreApplication::applicationDirPath());
dirs.append(QCoreApplication::applicationDirPath() + QLatin1String("/data"));
-# endif // !QT_BOOTSTRAPPED
+#endif // !QT_BOOTSTRAPPED
} // isConfigLocation()
-#endif // !Q_OS_WINCE
return dirs;
}
diff --git a/src/corelib/io/qstorageinfo_p.h b/src/corelib/io/qstorageinfo_p.h
index 744653ea42..a14fa8480a 100644
--- a/src/corelib/io/qstorageinfo_p.h
+++ b/src/corelib/io/qstorageinfo_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qstorageinfo.h"
QT_BEGIN_NAMESPACE
@@ -70,7 +71,7 @@ public:
static QStorageInfo root();
protected:
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
void retrieveVolumeInfo();
void retrieveDiskFreeSpace();
#elif defined(Q_OS_MAC)
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp
index 0b0446a37e..c430c7714a 100644
--- a/src/corelib/io/qtemporaryfile.cpp
+++ b/src/corelib/io/qtemporaryfile.cpp
@@ -404,7 +404,12 @@ bool QTemporaryFileEngine::close()
//************* QTemporaryFilePrivate
-QTemporaryFilePrivate::QTemporaryFilePrivate() : autoRemove(true)
+QTemporaryFilePrivate::QTemporaryFilePrivate()
+{
+}
+
+QTemporaryFilePrivate::QTemporaryFilePrivate(const QString &templateNameIn)
+ : templateName(templateNameIn)
{
}
@@ -498,15 +503,11 @@ QString QTemporaryFilePrivate::defaultTemplateName()
QTemporaryFile::QTemporaryFile()
: QFile(*new QTemporaryFilePrivate)
{
- Q_D(QTemporaryFile);
- d->templateName = QTemporaryFilePrivate::defaultTemplateName();
}
QTemporaryFile::QTemporaryFile(const QString &templateName)
- : QFile(*new QTemporaryFilePrivate)
+ : QFile(*new QTemporaryFilePrivate(templateName))
{
- Q_D(QTemporaryFile);
- d->templateName = templateName;
}
#else
@@ -519,10 +520,8 @@ QTemporaryFile::QTemporaryFile(const QString &templateName)
\sa setFileTemplate(), QDir::tempPath()
*/
QTemporaryFile::QTemporaryFile()
- : QFile(*new QTemporaryFilePrivate, 0)
+ : QTemporaryFile(nullptr)
{
- Q_D(QTemporaryFile);
- d->templateName = QTemporaryFilePrivate::defaultTemplateName();
}
/*!
@@ -540,10 +539,8 @@ QTemporaryFile::QTemporaryFile()
\sa open(), fileTemplate()
*/
QTemporaryFile::QTemporaryFile(const QString &templateName)
- : QFile(*new QTemporaryFilePrivate, 0)
+ : QTemporaryFile(templateName, nullptr)
{
- Q_D(QTemporaryFile);
- d->templateName = templateName;
}
/*!
@@ -557,8 +554,6 @@ QTemporaryFile::QTemporaryFile(const QString &templateName)
QTemporaryFile::QTemporaryFile(QObject *parent)
: QFile(*new QTemporaryFilePrivate, parent)
{
- Q_D(QTemporaryFile);
- d->templateName = QTemporaryFilePrivate::defaultTemplateName();
}
/*!
@@ -577,10 +572,8 @@ QTemporaryFile::QTemporaryFile(QObject *parent)
\sa open(), fileTemplate()
*/
QTemporaryFile::QTemporaryFile(const QString &templateName, QObject *parent)
- : QFile(*new QTemporaryFilePrivate, parent)
+ : QFile(*new QTemporaryFilePrivate(templateName), parent)
{
- Q_D(QTemporaryFile);
- d->templateName = templateName;
}
#endif
diff --git a/src/corelib/io/qtemporaryfile_p.h b/src/corelib/io/qtemporaryfile_p.h
index 58cc318ffd..d057603034 100644
--- a/src/corelib/io/qtemporaryfile_p.h
+++ b/src/corelib/io/qtemporaryfile_p.h
@@ -67,13 +67,14 @@ class QTemporaryFilePrivate : public QFilePrivate
protected:
QTemporaryFilePrivate();
+ explicit QTemporaryFilePrivate(const QString &templateNameIn);
~QTemporaryFilePrivate();
QAbstractFileEngine *engine() const;
void resetFileEngine() const;
- bool autoRemove;
- QString templateName;
+ bool autoRemove = true;
+ QString templateName = defaultTemplateName();
static QString defaultTemplateName();
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index 27b7570226..b8db23329a 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -231,9 +231,7 @@ static const int QTEXTSTREAM_BUFFERSIZE = 16384;
#include "qnumeric.h"
#include "qvarlengtharray.h"
-#ifndef Q_OS_WINCE
#include <locale.h>
-#endif
#include "private/qlocale_p.h"
#include <stdlib.h>
diff --git a/src/corelib/io/qtextstream_p.h b/src/corelib/io/qtextstream_p.h
index 684cff6aa1..a642beddc4 100644
--- a/src/corelib/io/qtextstream_p.h
+++ b/src/corelib/io/qtextstream_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qtextstream.h"
#ifndef QT_NO_TEXTCODEC
#include "qtextcodec.h"
diff --git a/src/corelib/io/qtldurl_p.h b/src/corelib/io/qtldurl_p.h
index b1fde0c700..b9fbdebbc5 100644
--- a/src/corelib/io/qtldurl_p.h
+++ b/src/corelib/io/qtldurl_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qurl.h"
#include "QtCore/qstring.h"
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index b79ec78aa9..9cf1be58d8 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -413,9 +413,6 @@
#include "qtldurl_p.h"
#include "private/qipaddress_p.h"
#include "qurlquery.h"
-#if defined(Q_OS_WINCE_WM)
-#pragma optimize("g", off)
-#endif
QT_BEGIN_NAMESPACE
extern QString qt_normalizePathSegments(const QString &name, bool allowUncPaths); // qdir.cpp
@@ -3456,33 +3453,6 @@ QByteArray QUrl::toPercentEncoding(const QString &input, const QByteArray &exclu
return input.toUtf8().toPercentEncoding(exclude, include);
}
-/*! \fn QUrl QUrl::fromCFURL(CFURLRef url)
- \since 5.2
-
- Constructs a QUrl containing a copy of the CFURL \a url.
-*/
-
-/*! \fn CFURLRef QUrl::toCFURL() const
- \since 5.2
-
- Creates a CFURL from a QUrl. The caller owns the CFURL and is
- responsible for releasing it.
-*/
-
-/*!
- \fn QUrl QUrl::fromNSURL(const NSURL *url)
- \since 5.2
-
- Constructs a QUrl containing a copy of the NSURL \a url.
-*/
-
-/*!
- \fn NSURL* QUrl::toNSURL() const
- \since 5.2
-
- Creates a NSURL from a QUrl. The NSURL is autoreleased.
-*/
-
/*!
\internal
\since 5.0
@@ -3816,13 +3786,13 @@ QUrl QUrl::fromLocalFile(const QString &localFile)
} else if (deslashified.startsWith(QLatin1String("//"))) {
// magic for shared drive on windows
int indexOfPath = deslashified.indexOf(QLatin1Char('/'), 2);
- QString hostSpec = deslashified.mid(2, indexOfPath - 2);
+ QStringRef hostSpec = deslashified.midRef(2, indexOfPath - 2);
// Check for Windows-specific WebDAV specification: "//host@SSL/path".
if (hostSpec.endsWith(webDavSslTag(), Qt::CaseInsensitive)) {
- hostSpec.chop(4);
+ hostSpec.truncate(hostSpec.size() - 4);
scheme = webDavScheme();
}
- url.setHost(hostSpec);
+ url.setHost(hostSpec.toString());
if (indexOfPath > 2)
deslashified = deslashified.right(deslashified.length() - indexOfPath);
@@ -4287,8 +4257,8 @@ QUrl QUrl::fromUserInput(const QString &userInput)
if (urlPrepended.isValid() && (!urlPrepended.host().isEmpty() || !urlPrepended.path().isEmpty()))
{
int dotIndex = trimmedString.indexOf(QLatin1Char('.'));
- const QString hostscheme = trimmedString.left(dotIndex).toLower();
- if (hostscheme == ftpScheme())
+ const QStringRef hostscheme = trimmedString.leftRef(dotIndex);
+ if (hostscheme.compare(ftpScheme(), Qt::CaseInsensitive) == 0)
urlPrepended.setScheme(ftpScheme());
return adjustFtpPath(urlPrepended);
}
diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h
index 947b3bbb55..bce271fcb1 100644
--- a/src/corelib/io/qurl.h
+++ b/src/corelib/io/qurl.h
@@ -48,11 +48,9 @@
#include <QtCore/qpair.h>
#include <QtCore/qglobal.h>
-#ifdef Q_OS_MAC
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_FORWARD_DECLARE_CF_TYPE(CFURL);
-# ifdef __OBJC__
Q_FORWARD_DECLARE_OBJC_CLASS(NSURL);
-# endif
#endif
QT_BEGIN_NAMESPACE
@@ -164,6 +162,12 @@ public:
};
Q_DECLARE_FLAGS(ComponentFormattingOptions, ComponentFormattingOption)
#ifdef Q_QDOC
+private:
+ // We need to let qdoc think that FormattingOptions is a normal QFlags, but
+ // it needs to be a QUrlTwoFlags for compiling default arguments of somme functions.
+ template<typename T> struct QFlags : QUrlTwoFlags<T, ComponentFormattingOption>
+ { using QUrlTwoFlags<T, ComponentFormattingOption>::QUrlTwoFlags; };
+public:
Q_DECLARE_FLAGS(FormattingOptions, UrlFormattingOption)
#else
typedef QUrlTwoFlags<UrlFormattingOption, ComponentFormattingOption> FormattingOptions;
@@ -271,13 +275,11 @@ public:
static QByteArray toPercentEncoding(const QString &,
const QByteArray &exclude = QByteArray(),
const QByteArray &include = QByteArray());
-#if defined(Q_OS_MAC) || defined(Q_QDOC)
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
static QUrl fromCFURL(CFURLRef url);
CFURLRef toCFURL() const Q_DECL_CF_RETURNS_RETAINED;
-# if defined(__OBJC__) || defined(Q_QDOC)
static QUrl fromNSURL(const NSURL *url);
NSURL *toNSURL() const Q_DECL_NS_RETURNS_AUTORELEASED;
-# endif
#endif
#if QT_DEPRECATED_SINCE(5,0)
@@ -372,6 +374,7 @@ Q_DECLARE_SHARED(QUrl)
Q_DECLARE_OPERATORS_FOR_FLAGS(QUrl::ComponentFormattingOptions)
//Q_DECLARE_OPERATORS_FOR_FLAGS(QUrl::FormattingOptions)
+#ifndef Q_QDOC
Q_DECL_CONSTEXPR inline QUrl::FormattingOptions operator|(QUrl::UrlFormattingOption f1, QUrl::UrlFormattingOption f2)
{ return QUrl::FormattingOptions(f1) | f2; }
Q_DECL_CONSTEXPR inline QUrl::FormattingOptions operator|(QUrl::UrlFormattingOption f1, QUrl::FormattingOptions f2)
@@ -399,6 +402,7 @@ Q_DECL_CONSTEXPR inline QUrl::FormattingOptions operator|(QUrl::ComponentFormatt
//inline QUrl::UrlFormattingOption &operator=(const QUrl::UrlFormattingOption &i, QUrl::ComponentFormattingOptions f)
//{ i = int(f); f; }
+#endif // Q_QDOC
#ifndef QT_NO_DATASTREAM
Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QUrl &);
diff --git a/src/corelib/io/qurl_p.h b/src/corelib/io/qurl_p.h
index 49dcdeb144..cb88cac35e 100644
--- a/src/corelib/io/qurl_p.h
+++ b/src/corelib/io/qurl_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qurl.h"
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/io/qurltlds_p.h b/src/corelib/io/qurltlds_p.h
index 69d0701faa..2bd5c68c7b 100644
--- a/src/corelib/io/qurltlds_p.h
+++ b/src/corelib/io/qurltlds_p.h
@@ -52,6 +52,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
QT_BEGIN_NAMESPACE
// note to maintainer:
diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp
index 15fb276be9..b8df8e8084 100644
--- a/src/corelib/io/qwindowspipereader.cpp
+++ b/src/corelib/io/qwindowspipereader.cpp
@@ -71,21 +71,6 @@ QWindowsPipeReader::QWindowsPipeReader(QObject *parent)
this, &QWindowsPipeReader::emitPendingReadyRead, Qt::QueuedConnection);
}
-bool qt_cancelIo(HANDLE handle, OVERLAPPED *overlapped)
-{
- typedef BOOL (WINAPI *PtrCancelIoEx)(HANDLE, LPOVERLAPPED);
- static PtrCancelIoEx ptrCancelIoEx = 0;
- if (!ptrCancelIoEx) {
- HMODULE kernel32 = GetModuleHandleA("kernel32");
- if (kernel32)
- ptrCancelIoEx = PtrCancelIoEx(GetProcAddress(kernel32, "CancelIoEx"));
- }
- if (ptrCancelIoEx)
- return ptrCancelIoEx(handle, overlapped);
- else
- return CancelIo(handle);
-}
-
QWindowsPipeReader::~QWindowsPipeReader()
{
stop();
@@ -110,7 +95,7 @@ void QWindowsPipeReader::stop()
{
stopped = true;
if (readSequenceStarted) {
- if (!qt_cancelIo(handle, &overlapped)) {
+ if (!CancelIoEx(handle, &overlapped)) {
const DWORD dwError = GetLastError();
if (dwError != ERROR_NOT_FOUND) {
qErrnoWarning(dwError, "QWindowsPipeReader: qt_cancelIo on handle %x failed.",
diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp
index b0ca0d979b..3ab2c70c75 100644
--- a/src/corelib/io/qwindowspipewriter.cpp
+++ b/src/corelib/io/qwindowspipewriter.cpp
@@ -42,9 +42,6 @@
QT_BEGIN_NAMESPACE
-extern bool qt_cancelIo(HANDLE handle, OVERLAPPED *overlapped); // from qwindowspipereader.cpp
-
-
QWindowsPipeWriter::Overlapped::Overlapped(QWindowsPipeWriter *pipeWriter)
: pipeWriter(pipeWriter)
{
@@ -211,7 +208,7 @@ void QWindowsPipeWriter::stop()
bytesWrittenPending = false;
pendingBytesWrittenValue = 0;
if (writeSequenceStarted) {
- if (!qt_cancelIo(handle, &overlapped)) {
+ if (!CancelIoEx(handle, &overlapped)) {
const DWORD dwError = GetLastError();
if (dwError != ERROR_NOT_FOUND) {
qErrnoWarning(dwError, "QWindowsPipeWriter: qt_cancelIo on handle %x failed.",
diff --git a/src/corelib/io/qwindowspipewriter_p.h b/src/corelib/io/qwindowspipewriter_p.h
index 3c641670b6..5a0d04855f 100644
--- a/src/corelib/io/qwindowspipewriter_p.h
+++ b/src/corelib/io/qwindowspipewriter_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <qelapsedtimer.h>
#include <qobject.h>
#include <qbytearray.h>
diff --git a/src/corelib/io/qwinoverlappedionotifier_p.h b/src/corelib/io/qwinoverlappedionotifier_p.h
index febdfe310f..276a1d861e 100644
--- a/src/corelib/io/qwinoverlappedionotifier_p.h
+++ b/src/corelib/io/qwinoverlappedionotifier_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <qobject.h>
typedef struct _OVERLAPPED OVERLAPPED;
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp
index d645205155..54ea45782d 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.cpp
+++ b/src/corelib/itemmodels/qabstractitemmodel.cpp
@@ -47,6 +47,7 @@
#include <qvector.h>
#include <qstack.h>
#include <qbitarray.h>
+#include <qdatetime.h>
#include <limits.h>
@@ -547,6 +548,43 @@ const QHash<int,QByteArray> &QAbstractItemModelPrivate::defaultRoleNames()
return *qDefaultRoleNames();
}
+bool QAbstractItemModelPrivate::isVariantLessThan(const QVariant &left, const QVariant &right,
+ Qt::CaseSensitivity cs, bool isLocaleAware)
+{
+ if (left.userType() == QVariant::Invalid)
+ return false;
+ if (right.userType() == QVariant::Invalid)
+ return true;
+ switch (left.userType()) {
+ case QVariant::Int:
+ return left.toInt() < right.toInt();
+ case QVariant::UInt:
+ return left.toUInt() < right.toUInt();
+ case QVariant::LongLong:
+ return left.toLongLong() < right.toLongLong();
+ case QVariant::ULongLong:
+ return left.toULongLong() < right.toULongLong();
+ case QMetaType::Float:
+ return left.toFloat() < right.toFloat();
+ case QVariant::Double:
+ return left.toDouble() < right.toDouble();
+ case QVariant::Char:
+ return left.toChar() < right.toChar();
+ case QVariant::Date:
+ return left.toDate() < right.toDate();
+ case QVariant::Time:
+ return left.toTime() < right.toTime();
+ case QVariant::DateTime:
+ return left.toDateTime() < right.toDateTime();
+ case QVariant::String:
+ default:
+ if (isLocaleAware)
+ return left.toString().localeAwareCompare(right.toString()) < 0;
+ else
+ return left.toString().compare(right.toString(), cs) < 0;
+ }
+}
+
static uint typeOfVariant(const QVariant &value)
{
diff --git a/src/corelib/itemmodels/qabstractitemmodel_p.h b/src/corelib/itemmodels/qabstractitemmodel_p.h
index 9ff40cd60e..7086ae730a 100644
--- a/src/corelib/itemmodels/qabstractitemmodel_p.h
+++ b/src/corelib/itemmodels/qabstractitemmodel_p.h
@@ -150,6 +150,8 @@ public:
QHash<int,QByteArray> roleNames;
static const QHash<int,QByteArray> &defaultRoleNames();
+ static bool isVariantLessThan(const QVariant &left, const QVariant &right,
+ Qt::CaseSensitivity cs = Qt::CaseSensitive, bool isLocaleAware = false);
};
Q_DECLARE_TYPEINFO(QAbstractItemModelPrivate::Change, Q_MOVABLE_TYPE);
diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
index 0f45862035..b0ddfa879d 100644
--- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp
+++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp
@@ -2654,40 +2654,7 @@ bool QSortFilterProxyModel::lessThan(const QModelIndex &source_left, const QMode
Q_D(const QSortFilterProxyModel);
QVariant l = (source_left.model() ? source_left.model()->data(source_left, d->sort_role) : QVariant());
QVariant r = (source_right.model() ? source_right.model()->data(source_right, d->sort_role) : QVariant());
- // Duplicated in QStandardItem::operator<()
- if (l.userType() == QVariant::Invalid)
- return false;
- if (r.userType() == QVariant::Invalid)
- return true;
- switch (l.userType()) {
- case QVariant::Int:
- return l.toInt() < r.toInt();
- case QVariant::UInt:
- return l.toUInt() < r.toUInt();
- case QVariant::LongLong:
- return l.toLongLong() < r.toLongLong();
- case QVariant::ULongLong:
- return l.toULongLong() < r.toULongLong();
- case QMetaType::Float:
- return l.toFloat() < r.toFloat();
- case QVariant::Double:
- return l.toDouble() < r.toDouble();
- case QVariant::Char:
- return l.toChar() < r.toChar();
- case QVariant::Date:
- return l.toDate() < r.toDate();
- case QVariant::Time:
- return l.toTime() < r.toTime();
- case QVariant::DateTime:
- return l.toDateTime() < r.toDateTime();
- case QVariant::String:
- default:
- if (d->sort_localeaware)
- return l.toString().localeAwareCompare(r.toString()) < 0;
- else
- return l.toString().compare(r.toString(), d->sort_casesensitivity) < 0;
- }
- return false;
+ return QAbstractItemModelPrivate::isVariantLessThan(l, r, d->sort_casesensitivity, d->sort_localeaware);
}
/*!
diff --git a/src/corelib/json/qjson_p.h b/src/corelib/json/qjson_p.h
index b0a634cb4a..1cffdbc250 100644
--- a/src/corelib/json/qjson_p.h
+++ b/src/corelib/json/qjson_p.h
@@ -151,6 +151,14 @@ public:
val = qToLittleEndian(qFromLittleEndian(val) + i);
return *this;
}
+ q_littleendian &operator |=(T i) {
+ val = qToLittleEndian(qFromLittleEndian(val) | i);
+ return *this;
+ }
+ q_littleendian &operator &=(T i) {
+ val = qToLittleEndian(qFromLittleEndian(val) & i);
+ return *this;
+ }
};
} // namespace QJsonPrivate
@@ -205,6 +213,14 @@ public:
*this = (uint(*this) - i);
return *this;
}
+ qle_bitfield &operator |=(uint i) {
+ *this = (uint(*this) | i);
+ return *this;
+ }
+ qle_bitfield &operator &=(uint i) {
+ *this = (uint(*this) & i);
+ return *this;
+ }
};
template<int pos, int width>
@@ -396,7 +412,7 @@ public:
const ushort *uc = (const ushort *)str.unicode();
int i = 0;
#ifdef __SSE2__
- for ( ; i + 16 < len; i += 16) {
+ for ( ; i + 16 <= len; i += 16) {
__m128i chunk1 = _mm_loadu_si128((__m128i*)&uc[i]); // load
__m128i chunk2 = _mm_loadu_si128((__m128i*)&uc[i + 8]); // load
// pack the two vector to 16 x 8bits elements
@@ -405,7 +421,7 @@ public:
}
# ifdef Q_PROCESSOR_X86_64
// we can do one more round, of 8 characters
- if (i + 8 < len) {
+ if (i + 8 <= len) {
__m128i chunk = _mm_loadu_si128((__m128i*)&uc[i]); // load
// pack with itself, we'll discard the high part anyway
chunk = _mm_packus_epi16(chunk, chunk);
diff --git a/src/corelib/json/qjsondocument.cpp b/src/corelib/json/qjsondocument.cpp
index 6eca54bdf0..86fd63ead4 100644
--- a/src/corelib/json/qjsondocument.cpp
+++ b/src/corelib/json/qjsondocument.cpp
@@ -260,7 +260,7 @@ QJsonDocument QJsonDocument::fromBinaryData(const QByteArray &data, DataValidati
Creates a QJsonDocument from the QVariant \a variant.
If the \a variant contains any other type than a QVariantMap,
- QVariantList or QStringList, the returned document
+ QVariantHash, QVariantList or QStringList, the returned document
document is invalid.
\sa toVariant()
@@ -270,6 +270,8 @@ QJsonDocument QJsonDocument::fromVariant(const QVariant &variant)
QJsonDocument doc;
if (variant.type() == QVariant::Map) {
doc.setObject(QJsonObject::fromVariantMap(variant.toMap()));
+ } else if (variant.type() == QVariant::Hash) {
+ doc.setObject(QJsonObject::fromVariantHash(variant.toHash()));
} else if (variant.type() == QVariant::List) {
doc.setArray(QJsonArray::fromVariantList(variant.toList()));
} else if (variant.type() == QVariant::StringList) {
diff --git a/src/corelib/json/qjsonparser_p.h b/src/corelib/json/qjsonparser_p.h
index ceb366b0f8..e3b95109c6 100644
--- a/src/corelib/json/qjsonparser_p.h
+++ b/src/corelib/json/qjsonparser_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <qjsondocument.h>
#include <qvarlengtharray.h>
diff --git a/src/corelib/json/qjsonvalue.cpp b/src/corelib/json/qjsonvalue.cpp
index 718dfa43b3..5a906dda7b 100644
--- a/src/corelib/json/qjsonvalue.cpp
+++ b/src/corelib/json/qjsonvalue.cpp
@@ -438,7 +438,7 @@ QJsonValue QJsonValue::fromVariant(const QVariant &variant)
The QJsonValue types will be converted as follows:
- \value Null \l {QVariant::}{QVariant()}
+ \value Null QMetaType::Nullptr
\value Bool QMetaType::Bool
\value Double QMetaType::Double
\value String QString
@@ -466,6 +466,7 @@ QVariant QJsonValue::toVariant() const
QJsonObject(d, static_cast<QJsonPrivate::Object *>(base)).toVariantMap() :
QVariantMap();
case Null:
+ return QVariant::fromValue(nullptr);
case Undefined:
break;
}
diff --git a/src/corelib/json/qjsonwriter_p.h b/src/corelib/json/qjsonwriter_p.h
index b9cdbb6976..76a8460449 100644
--- a/src/corelib/json/qjsonwriter_p.h
+++ b/src/corelib/json/qjsonwriter_p.h
@@ -50,6 +50,8 @@
//
// We mean it.
//
+
+#include <QtCore/private/qglobal_p.h>
#include <qjsonvalue.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/kernel/kernel.pri b/src/corelib/kernel/kernel.pri
index 8c16e10c27..f21a1d5d3e 100644
--- a/src/corelib/kernel/kernel.pri
+++ b/src/corelib/kernel/kernel.pri
@@ -4,6 +4,9 @@ HEADERS += \
kernel/qabstracteventdispatcher.h \
kernel/qabstractnativeeventfilter.h \
kernel/qbasictimer.h \
+ kernel/qdeadlinetimer.h \
+ kernel/qdeadlinetimer_p.h \
+ kernel/qelapsedtimer.h \
kernel/qeventloop.h\
kernel/qpointer.h \
kernel/qcorecmdlineargs_p.h \
@@ -45,6 +48,8 @@ SOURCES += \
kernel/qabstracteventdispatcher.cpp \
kernel/qabstractnativeeventfilter.cpp \
kernel/qbasictimer.cpp \
+ kernel/qdeadlinetimer.cpp \
+ kernel/qelapsedtimer.cpp \
kernel/qeventloop.cpp \
kernel/qcoreapplication.cpp \
kernel/qcoreevent.cpp \
@@ -69,6 +74,7 @@ SOURCES += \
win32 {
SOURCES += \
kernel/qcoreapplication_win.cpp \
+ kernel/qelapsedtimer_win.cpp \
kernel/qwineventnotifier.cpp \
kernel/qsharedmemory_win.cpp \
kernel/qsystemsemaphore_win.cpp
@@ -84,14 +90,6 @@ win32 {
}
}
-wince {
- SOURCES += \
- kernel/qfunctions_wince.cpp
- HEADERS += \
- kernel/qfunctions_fake_env_p.h \
- kernel/qfunctions_wince.h
-}
-
winrt {
SOURCES += \
kernel/qfunctions_winrt.cpp
@@ -109,7 +107,9 @@ mac {
SOURCES += \
kernel/qcfsocketnotifier.cpp \
kernel/qcoreapplication_mac.cpp \
- kernel/qcore_mac.cpp
+ kernel/qcore_mac.cpp \
+ kernel/qcore_foundation.mm
+ !nacl: SOURCES += kernel/qelapsedtimer_mac.cpp
OBJECTIVE_SOURCES += \
kernel/qcore_mac_objc.mm \
@@ -119,7 +119,7 @@ mac {
osx: LIBS_PRIVATE += -framework CoreServices -framework AppKit
- ios {
+ uikit {
# We need UIKit for UIDevice
LIBS_PRIVATE += -framework UIKit
}
@@ -138,6 +138,7 @@ unix|integrity {
kernel/qcrashhandler.cpp \
kernel/qeventdispatcher_unix.cpp \
kernel/qtimerinfo_unix.cpp
+ !darwin|nacl: SOURCES += kernel/qelapsedtimer_unix.cpp
HEADERS += \
kernel/qcore_unix_p.h \
@@ -156,8 +157,8 @@ unix|integrity {
kernel/qeventdispatcher_glib.cpp
HEADERS += \
kernel/qeventdispatcher_glib_p.h
- QMAKE_CXXFLAGS += $$QT_CFLAGS_GLIB
- LIBS_PRIVATE +=$$QT_LIBS_GLIB
+ QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_GLIB
+ LIBS_PRIVATE +=$$QMAKE_LIBS_GLIB
}
contains(QT_CONFIG, clock-gettime):include($$QT_SOURCE_TREE/config.tests/unix/clock-gettime/clock-gettime.pri)
@@ -203,3 +204,5 @@ android {
kernel/qjnihelpers_p.h \
kernel/qjni_p.h
}
+
+!darwin:!unix:!win32: SOURCES += kernel/qelapsedtimer_generic.cpp
diff --git a/src/corelib/kernel/qcfsocketnotifier_p.h b/src/corelib/kernel/qcfsocketnotifier_p.h
index c11c345361..12c5bf6334 100644
--- a/src/corelib/kernel/qcfsocketnotifier_p.h
+++ b/src/corelib/kernel/qcfsocketnotifier_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qabstracteventdispatcher.h>
#include <QtCore/qhash.h>
diff --git a/src/corelib/kernel/qcore_foundation.mm b/src/corelib/kernel/qcore_foundation.mm
new file mode 100644
index 0000000000..2291017a5d
--- /dev/null
+++ b/src/corelib/kernel/qcore_foundation.mm
@@ -0,0 +1,537 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2014 Samuel Gaist <samuel.gaist@edeltech.ch>
+** Copyright (C) 2014 Petroules Corporation.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/qstring.h>
+#include <QtCore/qurl.h>
+#include <QtCore/qdatetime.h>
+#include <QtCore/quuid.h>
+#include <QtCore/qbytearray.h>
+#include <QtCore/qrect.h>
+
+#import <Foundation/Foundation.h>
+
+#if defined(QT_PLATFORM_UIKIT)
+#import <CoreGraphics/CoreGraphics.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \since 5.3
+
+ Constructs a new QByteArray containing a copy of the CFData \a data.
+
+ \sa fromRawCFData(), fromRawData(), toRawCFData(), toCFData()
+*/
+QByteArray QByteArray::fromCFData(CFDataRef data)
+{
+ if (!data)
+ return QByteArray();
+
+ return QByteArray(reinterpret_cast<const char *>(CFDataGetBytePtr(data)), CFDataGetLength(data));
+}
+
+/*!
+ \since 5.3
+
+ Constructs a QByteArray that uses the bytes of the CFData \a data.
+
+ The \a data's bytes are not copied.
+
+ The caller guarantees that the CFData will not be deleted
+ or modified as long as this QByteArray object exists.
+
+ \sa fromCFData(), fromRawData(), toRawCFData(), toCFData()
+*/
+QByteArray QByteArray::fromRawCFData(CFDataRef data)
+{
+ if (!data)
+ return QByteArray();
+
+ return QByteArray::fromRawData(reinterpret_cast<const char *>(CFDataGetBytePtr(data)), CFDataGetLength(data));
+}
+
+/*!
+ \since 5.3
+
+ Creates a CFData from a QByteArray. The caller owns the CFData object
+ and is responsible for releasing it.
+
+ \sa toRawCFData(), fromCFData(), fromRawCFData(), fromRawData()
+*/
+CFDataRef QByteArray::toCFData() const
+{
+ return CFDataCreate(kCFAllocatorDefault, reinterpret_cast<const UInt8 *>(data()), length());
+}
+
+/*!
+ \since 5.3
+
+ Constructs a CFData that uses the bytes of the QByteArray.
+
+ The QByteArray's bytes are not copied.
+
+ The caller guarantees that the QByteArray will not be deleted
+ or modified as long as this CFData object exists.
+
+ \sa toCFData(), fromRawCFData(), fromCFData(), fromRawData()
+*/
+CFDataRef QByteArray::toRawCFData() const
+{
+ return CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const UInt8 *>(data()),
+ length(), kCFAllocatorNull);
+}
+
+/*!
+ \since 5.3
+
+ Constructs a new QByteArray containing a copy of the NSData \a data.
+
+ \sa fromRawNSData(), fromRawData(), toNSData(), toRawNSData()
+*/
+QByteArray QByteArray::fromNSData(const NSData *data)
+{
+ if (!data)
+ return QByteArray();
+ return QByteArray(reinterpret_cast<const char *>([data bytes]), [data length]);
+}
+
+/*!
+ \since 5.3
+
+ Constructs a QByteArray that uses the bytes of the NSData \a data.
+
+ The \a data's bytes are not copied.
+
+ The caller guarantees that the NSData will not be deleted
+ or modified as long as this QByteArray object exists.
+
+ \sa fromNSData(), fromRawData(), toRawNSData(), toNSData()
+*/
+QByteArray QByteArray::fromRawNSData(const NSData *data)
+{
+ if (!data)
+ return QByteArray();
+ return QByteArray::fromRawData(reinterpret_cast<const char *>([data bytes]), [data length]);
+}
+
+/*!
+ \since 5.3
+
+ Creates a NSData from a QByteArray. The NSData object is autoreleased.
+
+ \sa fromNSData(), fromRawNSData(), fromRawData(), toRawNSData()
+*/
+NSData *QByteArray::toNSData() const
+{
+ return [NSData dataWithBytes:constData() length:size()];
+}
+
+/*!
+ \since 5.3
+
+ Constructs a NSData that uses the bytes of the QByteArray.
+
+ The QByteArray's bytes are not copied.
+
+ The caller guarantees that the QByteArray will not be deleted
+ or modified as long as this NSData object exists.
+
+ \sa fromRawNSData(), fromNSData(), fromRawData(), toNSData()
+*/
+NSData *QByteArray::toRawNSData() const
+{
+ // const_cast is fine here because NSData is immutable thus will never modify bytes we're giving it
+ return [NSData dataWithBytesNoCopy:const_cast<char *>(constData()) length:size() freeWhenDone:NO];
+}
+
+// ----------------------------------------------------------------------------
+
+/*!
+ \since 5.2
+
+ Constructs a new QString containing a copy of the \a string CFString.
+
+ \note this function is only available on OS X and iOS.
+*/
+QString QString::fromCFString(CFStringRef string)
+{
+ if (!string)
+ return QString();
+ CFIndex length = CFStringGetLength(string);
+
+ // Fast path: CFStringGetCharactersPtr does not copy but may
+ // return null for any and no reason.
+ const UniChar *chars = CFStringGetCharactersPtr(string);
+ if (chars)
+ return QString(reinterpret_cast<const QChar *>(chars), length);
+
+ QString ret(length, Qt::Uninitialized);
+ CFStringGetCharacters(string, CFRangeMake(0, length), reinterpret_cast<UniChar *>(ret.data()));
+ return ret;
+}
+
+/*!
+ \since 5.2
+
+ Creates a CFString from a QString. The caller owns the CFString and is
+ responsible for releasing it.
+
+ \note this function is only available on OS X and iOS.
+*/
+CFStringRef QString::toCFString() const
+{
+ return CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar *>(unicode()), length());
+}
+
+/*!
+ \since 5.2
+
+ Constructs a new QString containing a copy of the \a string NSString.
+
+ \note this function is only available on OS X and iOS.
+*/
+QString QString::fromNSString(const NSString *string)
+{
+ if (!string)
+ return QString();
+ QString qstring;
+ qstring.resize([string length]);
+ [string getCharacters: reinterpret_cast<unichar*>(qstring.data()) range: NSMakeRange(0, [string length])];
+ return qstring;
+}
+
+/*!
+ \since 5.2
+
+ Creates a NSString from a QString. The NSString is autoreleased.
+
+ \note this function is only available on OS X and iOS.
+*/
+NSString *QString::toNSString() const
+{
+ return [NSString stringWithCharacters: reinterpret_cast<const UniChar*>(unicode()) length: length()];
+}
+
+// ----------------------------------------------------------------------------
+
+/*!
+ \since 5.7
+
+ Constructs a new QUuid containing a copy of the \a uuid CFUUID.
+
+ \note this function is only available on Apple platforms.
+*/
+QUuid QUuid::fromCFUUID(CFUUIDRef uuid)
+{
+ if (!uuid)
+ return QUuid();
+ const CFUUIDBytes bytes = CFUUIDGetUUIDBytes(uuid);
+ return QUuid::fromRfc4122(QByteArray::fromRawData(reinterpret_cast<const char *>(&bytes), sizeof(bytes)));
+}
+
+/*!
+ \since 5.7
+
+ Creates a CFUUID from a QUuid. The caller owns the CFUUID and is
+ responsible for releasing it.
+
+ \note this function is only available on Apple platforms.
+*/
+CFUUIDRef QUuid::toCFUUID() const
+{
+ const QByteArray bytes = toRfc4122();
+ return CFUUIDCreateFromUUIDBytes(0, *reinterpret_cast<const CFUUIDBytes *>(bytes.constData()));
+}
+
+/*!
+ \since 5.7
+
+ Constructs a new QUuid containing a copy of the \a uuid NSUUID.
+
+ \note this function is only available on Apple platforms.
+*/
+QUuid QUuid::fromNSUUID(const NSUUID *uuid)
+{
+ if (!uuid)
+ return QUuid();
+ uuid_t bytes;
+ [uuid getUUIDBytes:bytes];
+ return QUuid::fromRfc4122(QByteArray::fromRawData(reinterpret_cast<const char *>(bytes), sizeof(bytes)));
+}
+
+/*!
+ \since 5.7
+
+ Creates a NSUUID from a QUuid. The NSUUID is autoreleased.
+
+ \note this function is only available on Apple platforms.
+*/
+NSUUID *QUuid::toNSUUID() const
+{
+ const QByteArray bytes = toRfc4122();
+ return [[[NSUUID alloc] initWithUUIDBytes:*reinterpret_cast<const uuid_t *>(bytes.constData())] autorelease];
+}
+
+// ----------------------------------------------------------------------------
+
+
+/*!
+ \since 5.2
+
+ Constructs a QUrl containing a copy of the CFURL \a url.
+*/
+QUrl QUrl::fromCFURL(CFURLRef url)
+{
+ return QUrl(QString::fromCFString(CFURLGetString(url)));
+}
+
+/*!
+ \since 5.2
+
+ Creates a CFURL from a QUrl. The caller owns the CFURL and is
+ responsible for releasing it.
+*/
+CFURLRef QUrl::toCFURL() const
+{
+ CFURLRef url = 0;
+ CFStringRef str = toString(FullyEncoded).toCFString();
+ if (str) {
+ url = CFURLCreateWithString(0, str, 0);
+ CFRelease(str);
+ }
+ return url;
+}
+
+/*!
+ \since 5.2
+
+ Constructs a QUrl containing a copy of the NSURL \a url.
+*/
+QUrl QUrl::fromNSURL(const NSURL *url)
+{
+ return QUrl(QString::fromNSString([url absoluteString]));
+}
+
+/*!
+ \since 5.2
+
+ Creates a NSURL from a QUrl. The NSURL is autoreleased.
+*/
+NSURL *QUrl::toNSURL() const
+{
+ return [NSURL URLWithString:toString(FullyEncoded).toNSString()];
+}
+
+// ----------------------------------------------------------------------------
+
+
+/*!
+ \since 5.5
+
+ Constructs a new QDateTime containing a copy of the CFDate \a date.
+
+ \sa toCFDate()
+*/
+QDateTime QDateTime::fromCFDate(CFDateRef date)
+{
+ if (!date)
+ return QDateTime();
+ return QDateTime::fromMSecsSinceEpoch(static_cast<qint64>((CFDateGetAbsoluteTime(date)
+ + kCFAbsoluteTimeIntervalSince1970) * 1000));
+}
+
+/*!
+ \since 5.5
+
+ Creates a CFDate from a QDateTime. The caller owns the CFDate object
+ and is responsible for releasing it.
+
+ \sa fromCFDate()
+*/
+CFDateRef QDateTime::toCFDate() const
+{
+ return CFDateCreate(kCFAllocatorDefault, (static_cast<CFAbsoluteTime>(toMSecsSinceEpoch())
+ / 1000) - kCFAbsoluteTimeIntervalSince1970);
+}
+
+/*!
+ \since 5.5
+
+ Constructs a new QDateTime containing a copy of the NSDate \a date.
+
+ \sa toNSDate()
+*/
+QDateTime QDateTime::fromNSDate(const NSDate *date)
+{
+ if (!date)
+ return QDateTime();
+ return QDateTime::fromMSecsSinceEpoch(static_cast<qint64>([date timeIntervalSince1970] * 1000));
+}
+
+/*!
+ \since 5.5
+
+ Creates an NSDate from a QDateTime. The NSDate object is autoreleased.
+
+ \sa fromNSDate()
+*/
+NSDate *QDateTime::toNSDate() const
+{
+ return [NSDate
+ dateWithTimeIntervalSince1970:static_cast<NSTimeInterval>(toMSecsSinceEpoch()) / 1000];
+}
+
+// ----------------------------------------------------------------------------
+
+/*!
+ \since 5.8
+
+ Creates a CGRect from a QRect.
+
+ \sa fromCGRect()
+*/
+CGRect QRect::toCGRect() const Q_DECL_NOTHROW
+{
+ return CGRectMake(x(), y(), width(), height());
+}
+
+/*!
+ \since 5.8
+
+ Creates a CGRect from a QRectF.
+
+ \sa fromCGRect()
+*/
+CGRect QRectF::toCGRect() const Q_DECL_NOTHROW
+{
+ return CGRectMake(x(), y(), width(), height());
+}
+
+/*!
+ \since 5.8
+
+ Creates a QRectF from a CGRect.
+
+ \sa toCGRect()
+*/
+QRectF QRectF::fromCGRect(CGRect rect) Q_DECL_NOTHROW
+{
+ return QRectF(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
+}
+
+// ----------------------------------------------------------------------------
+
+/*!
+ \since 5.8
+
+ Creates a CGPoint from a QPoint.
+
+ \sa fromCGPoint()
+*/
+CGPoint QPoint::toCGPoint() const Q_DECL_NOTHROW
+{
+ return CGPointMake(x(), y());
+}
+
+/*!
+ \since 5.8
+
+ Creates a CGPoint from a QPointF.
+
+ \sa fromCGPoint()
+*/
+CGPoint QPointF::toCGPoint() const Q_DECL_NOTHROW
+{
+ return CGPointMake(x(), y());
+}
+
+/*!
+ \since 5.8
+
+ Creates a QRectF from a CGPoint.
+
+ \sa toCGPoint()
+*/
+QPointF QPointF::fromCGPoint(CGPoint point) Q_DECL_NOTHROW
+{
+ return QPointF(point.x, point.y);
+}
+
+// ----------------------------------------------------------------------------
+
+/*!
+ \since 5.8
+
+ Creates a CGSize from a QSize.
+
+ \sa fromCGSize()
+*/
+CGSize QSize::toCGSize() const Q_DECL_NOTHROW
+{
+ return CGSizeMake(width(), height());
+}
+
+/*!
+ \since 5.8
+
+ Creates a CGSize from a QSizeF.
+
+ \sa fromCGSize()
+*/
+CGSize QSizeF::toCGSize() const Q_DECL_NOTHROW
+{
+ return CGSizeMake(width(), height());
+}
+
+/*!
+ \since 5.8
+
+ Creates a QRectF from a CGSize.
+
+ \sa toCGSize()
+*/
+QSizeF QSizeF::fromCGSize(CGSize size) Q_DECL_NOTHROW
+{
+ return QSizeF(size.width, size.height);
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm
index de491dd43d..068b6b0440 100644
--- a/src/corelib/kernel/qcore_mac_objc.mm
+++ b/src/corelib/kernel/qcore_mac_objc.mm
@@ -47,7 +47,7 @@
#include <qdebug.h>
-#ifdef Q_OS_IOS
+#if defined(Q_OS_IOS)
#import <UIKit/UIKit.h>
#endif
@@ -101,7 +101,7 @@ QT_FOR_EACH_MUTABLE_CORE_GRAPHICS_TYPE(QT_DECLARE_WEAK_QDEBUG_OPERATOR_FOR_CF_TY
QAppleOperatingSystemVersion qt_apple_os_version()
{
QAppleOperatingSystemVersion v = {0, 0, 0};
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_10, __IPHONE_8_0)
+#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_10, __IPHONE_8_0) || defined(Q_OS_TVOS)
if ([NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)]) {
NSOperatingSystemVersion osv = NSProcessInfo.processInfo.operatingSystemVersion;
v.major = osv.majorVersion;
diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h
index b94aac1093..63e1cb48dc 100644
--- a/src/corelib/kernel/qcore_mac_p.h
+++ b/src/corelib/kernel/qcore_mac_p.h
@@ -61,7 +61,7 @@
#include <CoreFoundation/CoreFoundation.h>
#endif
-#include "qglobal.h"
+#include "private/qglobal_p.h"
#ifdef __OBJC__
#include <Foundation/Foundation.h>
diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h
index 125ced6fc9..c393609188 100644
--- a/src/corelib/kernel/qcore_unix_p.h
+++ b/src/corelib/kernel/qcore_unix_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qplatformdefs.h"
#include "qatomic.h"
#include "qhash.h"
@@ -298,8 +299,8 @@ static inline int qt_safe_close(int fd)
#undef QT_CLOSE
#define QT_CLOSE qt_safe_close
-// - VxWorks doesn't have processes
-#if !defined(Q_OS_VXWORKS)
+// - VxWorks & iOS/tvOS don't have processes
+#if !defined(Q_OS_VXWORKS) && !defined(QT_NO_PROCESS)
static inline int qt_safe_execve(const char *filename, char *const argv[],
char *const envp[])
{
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 2179a0d323..c1f2dfded4 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -1299,19 +1299,6 @@ void QCoreApplication::exit(int returnCode)
QEventLoop *eventLoop = data->eventLoops.at(i);
eventLoop->exit(returnCode);
}
-#ifdef Q_OS_WINRT
- qWarning("QCoreApplication::exit: It is not recommended to explicitly exit an application on Windows Store Apps");
- ComPtr<ICoreApplication> app;
- HRESULT hr = RoGetActivationFactory(Wrappers::HString::MakeReference(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication).Get(),
- IID_PPV_ARGS(&app));
- RETURN_VOID_IF_FAILED("Could not acquire ICoreApplication object");
- ComPtr<ICoreApplicationExit> appExit;
-
- hr = app.As(&appExit);
- RETURN_VOID_IF_FAILED("Could not acquire ICoreApplicationExit object");
- hr = appExit->Exit();
- RETURN_VOID_IF_FAILED("Could not exit application");
-#endif // Q_OS_WINRT
}
/*****************************************************************************
@@ -2259,14 +2246,6 @@ QStringList QCoreApplication::arguments()
// classes by index.
QString cmdline = QString::fromWCharArray(GetCommandLine());
-#if defined(Q_OS_WINCE)
- wchar_t tempFilename[MAX_PATH+1];
- if (GetModuleFileName(0, tempFilename, MAX_PATH)) {
- tempFilename[MAX_PATH] = 0;
- cmdline.prepend(QLatin1Char('\"') + QString::fromWCharArray(tempFilename) + QLatin1String("\" "));
- }
-#endif // Q_OS_WINCE
-
const QCoreApplicationPrivate *d = self->d_func();
if (d->origArgv) {
const QStringList allArguments = qWinCmdArgs(cmdline);
@@ -2497,6 +2476,26 @@ QStringList QCoreApplication::libraryPaths()
}
}
+#ifdef Q_OS_DARWIN
+ // Check the main bundle's PlugIns directory as this is a standard location for Apple OSes.
+ // Note that the QLibraryInfo::PluginsPath below will coincidentally be the same as this value
+ // but with a different casing, so it can't be relied upon when the underlying filesystem
+ // is case sensitive (and this is always the case on newer OSes like iOS).
+ if (CFBundleRef bundleRef = CFBundleGetMainBundle()) {
+ if (QCFType<CFURLRef> urlRef = CFBundleCopyBuiltInPlugInsURL(bundleRef)) {
+ if (QCFType<CFURLRef> absoluteUrlRef = CFURLCopyAbsoluteURL(urlRef)) {
+ if (QCFString path = CFURLCopyFileSystemPath(absoluteUrlRef, kCFURLPOSIXPathStyle)) {
+ if (QFile::exists(path)) {
+ path = QDir(path).canonicalPath();
+ if (!app_libpaths->contains(path))
+ app_libpaths->append(path);
+ }
+ }
+ }
+ }
+ }
+#endif // Q_OS_DARWIN
+
QString installPathPlugins = QLibraryInfo::location(QLibraryInfo::PluginsPath);
if (QFile::exists(installPathPlugins)) {
// Make sure we convert from backslashes to slashes.
diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp
index 0e2d4e2324..67e509eeef 100644
--- a/src/corelib/kernel/qcoreapplication_win.cpp
+++ b/src/corelib/kernel/qcoreapplication_win.cpp
@@ -122,6 +122,7 @@ QString QCoreApplicationPrivate::appName() const
#ifndef Q_OS_WINRT
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Q_CORE_EXPORT HINSTANCE qWinAppInst() // get Windows app handle
{
return GetModuleHandle(0);
@@ -145,12 +146,13 @@ Q_CORE_EXPORT int qWinAppCmdShow() // get main window sho
: SW_SHOWDEFAULT;
#endif
}
+#endif
/*****************************************************************************
qWinMain() - Initializes Windows. Called from WinMain() in qtmain_win.cpp
*****************************************************************************/
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
// ### Qt6: FIXME: Consider removing this function. It is here for Active Qt
// servers and for binary for compatibility to applications built with Qt 5.3
@@ -171,30 +173,7 @@ void qWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam,
argv.append(_strdup(wArg.toLocal8Bit().constData()));
}
-#elif defined(Q_OS_WINCE)
-
-Q_CORE_EXPORT void __cdecl qWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam,
- int cmdShow, int &argc, QVector<char *> &argv)
-{
- static bool already_called = false;
-
- if (already_called) {
- qWarning("Qt: Internal error: qWinMain should be called only once");
- return;
- }
- already_called = true;
-
- // Create command line
- argv = qWinCmdLine<char>(cmdParam, int(strlen(cmdParam)), argc);
-
- appCmdShow = cmdShow;
-
- // Ignore Windows parameters
- Q_UNUSED(instance);
- Q_UNUSED(prevInstance);
-}
-
-#endif // Q_OS_WINCE
+#endif // !Q_OS_WINRT
#ifndef QT_NO_QOBJECT
@@ -212,11 +191,6 @@ QT_END_INCLUDE_NAMESPACE
# define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
# define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
#endif
-#ifdef _WIN32_WCE
-# ifndef WM_NCACTIVATE
-# define WM_NCACTIVATE 0x86
-# endif
-#endif
// The values below should never change. Note that none of the usual
// WM_...FIRST & WM_...LAST values are in the list, as they normally have other
diff --git a/src/corelib/kernel/qcorecmdlineargs_p.h b/src/corelib/kernel/qcorecmdlineargs_p.h
index 2d8de08f2d..33445a1625 100644
--- a/src/corelib/kernel/qcorecmdlineargs_p.h
+++ b/src/corelib/kernel/qcorecmdlineargs_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qstring.h"
#include "QtCore/qstringlist.h"
@@ -81,93 +82,7 @@ static inline QStringList qWinCmdArgs(const QString &cmdLine)
return result;
}
-#elif defined(Q_OS_WINCE) // Q_OS_WIN32
-
-// template implementation of the parsing algorithm
-// this is used from qcoreapplication_win.cpp and the tools (rcc, uic...)
-
-template<typename Char>
-static QVector<Char*> qWinCmdLine(Char *cmdParam, int length, int &argc)
-{
- QVector<Char*> argv(8);
- Char *p = cmdParam;
- Char *p_end = p + length;
-
- argc = 0;
-
- while (*p && p < p_end) { // parse cmd line arguments
- while (QChar((short)(*p)).isSpace()) // skip white space
- p++;
- if (*p && p < p_end) { // arg starts
- int quote;
- Char *start, *r;
- if (*p == Char('\"')) {
- quote = *p;
- start = ++p;
- } else {
- quote = 0;
- start = p;
- }
- r = start;
- while (*p && p < p_end) {
- if (quote) {
- if (*p == quote) {
- p++;
- if (QChar((short)(*p)).isSpace())
- break;
- quote = 0;
- }
- }
- if (*p == '\\') { // escape char?
- // testing by looking at argc, argv shows that it only escapes quotes
- if (p < p_end && (*(p+1) == Char('\"')))
- p++;
- } else {
- if (!quote && (*p == Char('\"'))) {
- quote = *p++;
- continue;
- } else if (QChar((short)(*p)).isSpace() && !quote)
- break;
- }
- if (*p)
- *r++ = *p++;
- }
- if (*p && p < p_end)
- p++;
- *r = Char('\0');
-
- if (argc >= (int)argv.size()-1) // expand array
- argv.resize(argv.size()*2);
- argv[argc++] = start;
- }
- }
- argv[argc] = 0;
-
- return argv;
-}
-
-static inline QStringList qWinCmdArgs(QString cmdLine) // not const-ref: this might be modified
-{
- QStringList args;
-
- int argc = 0;
- QVector<wchar_t*> argv = qWinCmdLine<wchar_t>((wchar_t *)cmdLine.utf16(), cmdLine.length(), argc);
- for (int a = 0; a < argc; ++a) {
- args << QString::fromWCharArray(argv[a]);
- }
-
- return args;
-}
-
-static inline QStringList qCmdLineArgs(int argc, char *argv[])
-{
- Q_UNUSED(argc)
- Q_UNUSED(argv)
- QString cmdLine = QString::fromWCharArray(GetCommandLine());
- return qWinCmdArgs(cmdLine);
-}
-
-#elif defined(Q_OS_WINRT) // Q_OS_WINCE
+#elif defined(Q_OS_WINRT) // Q_OS_WIN32
static inline QStringList qCmdLineArgs(int argc, char *argv[])
{
diff --git a/src/corelib/kernel/qcoreglobaldata_p.h b/src/corelib/kernel/qcoreglobaldata_p.h
index 4f97449c75..32b5becf4f 100644
--- a/src/corelib/kernel/qcoreglobaldata_p.h
+++ b/src/corelib/kernel/qcoreglobaldata_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qmap.h"
#include "QtCore/qstringlist.h"
#include "QtCore/qreadwritelock.h"
diff --git a/src/corelib/kernel/qcrashhandler_p.h b/src/corelib/kernel/qcrashhandler_p.h
index 1fd0ff3af8..64c15ce66c 100644
--- a/src/corelib/kernel/qcrashhandler_p.h
+++ b/src/corelib/kernel/qcrashhandler_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
#ifndef QT_NO_CRASHHANDLER
diff --git a/src/corelib/kernel/qdeadlinetimer.cpp b/src/corelib/kernel/qdeadlinetimer.cpp
new file mode 100644
index 0000000000..7906b29ece
--- /dev/null
+++ b/src/corelib/kernel/qdeadlinetimer.cpp
@@ -0,0 +1,827 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Intel Corporation.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdeadlinetimer.h"
+#include "qdeadlinetimer_p.h"
+#include <qpair.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_DECL_CONST_FUNCTION static inline QPair<qint64, qint64> toSecsAndNSecs(qint64 nsecs)
+{
+ qint64 secs = nsecs / (1000*1000*1000);
+ if (nsecs < 0)
+ --secs;
+ nsecs -= secs * 1000*1000*1000;
+ return qMakePair(secs, nsecs);
+}
+
+/*!
+ \class QDeadlineTimer
+ \inmodule QtCore
+ \brief The QDeadlineTimer class marks a deadline in the future.
+ \since 5.8
+
+ \reentrant
+ \ingroup tools
+
+ The QDeadlineTimer class is usually used to calculate future deadlines and
+ verify whether the deadline has expired. QDeadlineTimer can also be used
+ for deadlines without expiration ("forever"). It forms a counterpart to
+ QElapsedTimer, which calculates how much time has elapsed since
+ QElapsedTimer::start() was called.
+
+ QDeadlineTimer provides a more convenient API compared to
+ QElapsedTimer::hasExpired().
+
+ The typical use-case for the class is to create a QDeadlineTimer before the
+ operation in question is started, and then use remainingTime() or
+ hasExpired() to determine whether to continue trying the operation.
+ QDeadlineTimer objects can be passed to functions being called to execute
+ this operation so they know how long to still operate.
+
+ \code
+ void executeOperation(int msecs)
+ {
+ QDeadlineTimer deadline(msecs);
+ do {
+ if (readFromDevice(deadline.remainingTime())
+ break;
+ waitForReadyRead(deadline);
+ } while (!deadline.hasExpired());
+ }
+ \endcode
+
+ Many QDeadlineTimer functions deal with time out values, which all are
+ measured in milliseconds. There are two special values, the same as many
+ other Qt functions named \c{waitFor} or similar:
+
+ \list
+ \o 0: no time left, expired
+ \o -1: infinite time left, timer never expires
+ \endlist
+
+ \section1 Reference Clocks
+
+ QDeadlineTimer will use the same clock as QElapsedTimer (see
+ QElapsedTimer::clockType() and QElapsedTimer::isMonotonic()).
+
+ \section1 Timer types
+
+ Like QTimer, QDeadlineTimer can select among different levels of coarseness
+ on the timers. You can select precise timing by passing Qt::PreciseTimer to
+ the functions that set of change the timer, or you can select coarse timing
+ by passing Qt::CoarseTimer. Qt::VeryCoarseTimer is currently interpreted
+ the same way as Qt::CoarseTimer.
+
+ This feature is dependent on support from the operating system: if the OS
+ does not support a coarse timer functionality, then QDeadlineTimer will
+ behave like Qt::PreciseTimer was passed.
+
+ QDeadlineTimer defaults to Qt::CoarseTimer because on operating systems
+ that do support coarse timing, making timing calls to that clock source is
+ often much more efficient. The level of coarseness depends on the
+ operating system, but should be in the order of a couple of milliseconds.
+
+ \section1 \c{std::chrono} Compatibility
+
+ QDeadlineTimer is compatible with the \c{std::chrono} API from C++11 and
+ can be constructed from or compared to both \c{std::chrono::duration} and
+ \c{std::chrono::time_point} objects. In addition, it is fully compatible
+ with the time literals from C++14, which allow one to write code as:
+
+ \code
+ using namespace std::chrono;
+
+ QDeadlineTimer deadline(30s);
+ device->waitForReadyRead(deadline);
+ if (deadline.remainingTime<nanoseconds>() > 300ms)
+ cleanup();
+ \endcode
+
+ As can be seen in the example above, QDeadlineTimer offers a templated
+ version of remainingTime() and deadline() that can be used to return
+ \c{std::chrono} objects.
+
+ Note that comparing to \c{time_point} is not as efficient as comparing to
+ \c{duration}, since QDeadlineTimer may need to convert from its own
+ internal clock source to the clock source used by the \c{time_point} object.
+ Also note that, due to this conversion, the deadlines will not be precise,
+ so the following code is not expected to compare equally:
+
+ \code
+ using namespace std::chrono;
+ auto now = steady_clock::now();
+ QDeadlineTimer deadline(now + 1s);
+ Q_ASSERT(deadline == now + 1s);
+ \endcode
+
+ \sa QTime, QTimer, QDeadlineTimer, Qt::TimerType
+*/
+
+/*!
+ \enum QDeadlineTimer::ForeverConstant
+
+ \value Forever Used when creating a QDeadlineTimer to indicate the
+ deadline should not expire
+*/
+
+/*!
+ \fn QDeadlineTimer::QDeadlineTimer(Qt::TimerType timerType)
+
+ Constructs an expired QDeadlineTimer object. For this object,
+ remainingTime() will return 0.
+
+ The timer type \a timerType may be ignored, since the timer is already
+ expired. Similarly, for optimization purposes, this function will not
+ attempt to obtain the current time and will use a value known to be in the
+ past. Therefore, deadline() may return an unexpected value and this object
+ cannot be used in calculation of how long it is overdue. If that
+ functionality is required, use QDeadlineTimer::current().
+
+ \sa hasExpired(), remainingTime(), timerType(), current()
+*/
+
+/*!
+ \fn QDeadlineTimer::QDeadlineTimer(ForeverConstant, Qt::TimerType timerType)
+
+ Constructs a QDeadlineTimer object that never expires. For this object,
+ remainingTime() will return -1, deadline() will return the maximum value,
+ and isForever() will return true.
+
+ The timer type \a timerType may be ignored, since the timer is already
+ expired.
+
+ \sa hasExpired(), isForever(), remainingTime(), timerType()
+*/
+
+/*!
+ Constructs a QDeadlineTimer object with an expiry time of \a msecs msecs
+ from the moment of the creation of this object, if msecs is positive. If \a
+ msecs is zero, this QDeadlineTimer will be marked as expired, causing
+ remainingTime() to return zero and deadline() to return an indeterminate
+ time point in the past. If \a msecs is -1, the timer will be set it to
+ never expire, causing remainingTime() to return -1 and deadline() to return
+ the maximum value.
+
+ The QDeadlineTimer object will be constructed with a timer type of \a
+ timerType.
+
+ For optimization purposes, if \a msecs is zero, this function may skip
+ obtaining the current time and may instead use a value known to be in the
+ past. If that happens, deadline() may return an unexpected value and this
+ object cannot be used in calculation of how long it is overdue. If that
+ functionality is required, use QDeadlineTimer::current() and add time to
+ it.
+
+ \sa hasExpired(), isForever(), remainingTime(), setRemainingTime()
+*/
+QDeadlineTimer::QDeadlineTimer(qint64 msecs, Qt::TimerType type) Q_DECL_NOTHROW
+ : t2(0)
+{
+ setRemainingTime(msecs, type);
+}
+
+/*!
+ \fn QDeadlineTimer::QDeadlineTimer(std::chrono::time_point<Clock, Duration> deadline, Qt::TimerType type)
+
+ Constructs a QDeadlineTimer object with a deadline at \a deadline time
+ point, converting from the clock source \c{Clock} to Qt's internal clock
+ source (see QElapsedTimer::clcokType()).
+
+ If \a deadline is in the past, this QDeadlineTimer object is set to
+ expired, whereas if \a deadline is equal to \c{Duration::max()}, then this
+ object is set to never expire.
+
+ The QDeadlineTimer object will be constructed with a timer type of \a
+ timerType.
+
+ \sa hasExpired(), isForever(), remainingTime<Duration>(), setDeadline()
+*/
+
+/*!
+ \fn QDeadlineTimer::QDeadlineTimer(std::chrono::duration<Rep, Period> remaining, Qt::TimerType type)
+
+ Constructs a QDeadlineTimer object with a remaining time of \a remaining.
+ If \a remaining is zero or negative, this QDeadlineTimer object will be
+ mark as expired, whereas if \a remaining is equal to \c{duration::max()},
+ the object will be set to never expire.
+
+ The QDeadlineTimer object will be constructed with a timer type of \a
+ timerType.
+
+ This constructor can be used with C++14's user-defined literals for time, such as in:
+
+ \code
+ using namespace std::chrono;
+ QDeadlineTimer deadline(250ms);
+ \endcode
+
+ For optimization purposes, if \a remaining is zero or negative, this
+ function may skip obtaining the current time and may instead use a value
+ known to be in the past. If that happens, deadline() may return an
+ unexpected value and this object cannot be used in calculation of how long
+ it is overdue. If that functionality is required, use
+ QDeadlineTimer::current() and add time to it.
+
+ \sa hasExpired(), isForever(), remainingTime<Duration>(), setRemainingTime()
+*/
+
+/*!
+ \fn void QDeadlineTimer::setDeadline(std::chrono::time_point<Clock, Duration> deadline, Qt::TimerType type)
+
+ Sets this QDeadlineTimer to the deadline marked by \a deadline time
+ point, converting from the clock source \c{Clock} to Qt's internal clock
+ source (see QElapsedTimer::clcokType()).
+
+ If \a deadline is in the past, this QDeadlineTimer object is set to
+ expired, whereas if \a deadline is equal to \c{Duration::max()}, then this
+ object is set to never expire.
+
+ The timer type for this QDeadlineTimer object will be set to \a timerType type.
+
+ \sa hasExpired(), isForever(), remainingTime<Duration>(),
+*/
+
+/*!
+ Sets the remaining time for this QDeadlineTimer object to \a msecs
+ milliseconds from now, if \a msecs has a positive value. If \a msecs is
+ zero, this QDeadlineTimer object will be marked as expired, whereas a value
+ of -1 will set it to never expire.
+
+ The timer type for this QDeadlineTimer object will be set to \a timerType type.
+
+ \sa setPreciseRemainingTime(), hasExpired(), isForever(), remainingTime()
+*/
+void QDeadlineTimer::setRemainingTime(qint64 msecs, Qt::TimerType timerType) Q_DECL_NOTHROW
+{
+ if (msecs == -1)
+ *this = QDeadlineTimer(Forever, timerType);
+ else
+ setPreciseRemainingTime(0, msecs * 1000 * 1000, timerType);
+}
+
+/*!
+ Sets the remaining time for this QDeadlineTimer object to \a secs seconds
+ plus \a nsecs nanoseconds from now, if \a secs has a positive value. If \a
+ secs is -1, this QDeadlineTimer will be set it to never expire. If both
+ parameters are zero, this QDeadlineTimer will be marked as expired.
+
+ The timer type for this QDeadlineTimer object will be set to \a timerType type.
+
+ \sa setRemainingTime(), hasExpired(), isForever(), remainingTime()
+*/
+void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, qint64 nsecs, Qt::TimerType timerType) Q_DECL_NOTHROW
+{
+ if (secs == -1) {
+ *this = QDeadlineTimer(Forever, timerType);
+ return;
+ }
+
+ *this = current(timerType);
+ if (QDeadlineTimerNanosecondsInT2) {
+ t1 += secs + toSecsAndNSecs(nsecs).first;
+ t2 += toSecsAndNSecs(nsecs).second;
+ if (t2 > 1000*1000*1000) {
+ t2 -= 1000*1000*1000;
+ ++t1;
+ }
+ } else {
+ t1 += secs * 1000 * 1000 * 1000 + nsecs;
+ }
+}
+
+/*!
+ \overload
+ \fn void QDeadlineTimer::setRemainingTime(std::chrono::duration<Rep, Period> remaining, Qt::TimerType type)
+
+ Sets the remaining time for this QDeadlineTimer object to \a remaining. If
+ \a remaining is zero or negative, this QDeadlineTimer object will be mark
+ as expired, whereas if \a remaining is equal to \c{duration::max()}, the
+ object will be set to never expire.
+
+ The timer type for this QDeadlineTimer object will be set to \a timerType type.
+
+ This function can be used with C++14's user-defined literals for time, such as in:
+
+ \code
+ using namespace std::chrono;
+ deadline.setRemainingTime(250ms);
+ \endcode
+
+ \sa setDeadline(), remainingTime<Duration>(), hasExpired(), isForever()
+*/
+
+/*!
+ \fn void QDeadlineTimer::setPreciseRemainingTime(qint64 secs, unsigned nsecs, Qt::TimerType type)
+
+ Sets the remaining time for this QDeadlineTimer object to \a secs seconds
+ and \a nsecs nanoseconds from now, if \a secs is a positive value. If both
+ values are zero, this QDeadlineTimer object will be marked as expired,
+ whereas if \a secs is -1, it will set it to never expire.
+
+ If value of \a nsecs is more than 1 billion nanoseconds (1 second), this
+ function will adjust \a secs accordingly.
+
+ The timer type for this QDeadlineTimer object will be set to \a timerType type.
+
+ \sa setRemainingTime(), hasExpired(), isForever(), remainingTime()
+*/
+
+/*!
+ \overload
+ \fn Duration QDeadlineTimer::remainingTime() const
+
+ Returns a \c{std::chrono::duration} object of type \c{Duration} containing
+ the remaining time in this QDeadlineTimer, if it still has time left. If
+ the deadline has passed, this returns \c{Duration::zero()}, whereas if the
+ object is set to never expire, it returns \c{Duration::max()} (instead of
+ -1).
+
+ It is not possible to obtain the overdue time for expired timers with this
+ function. To do that, see deadline().
+
+ \note The overload of this function without template parameter always
+ returns milliseconds.
+
+ \sa setRemainingTime(), deadline<Clock, Duration>()
+*/
+
+/*!
+ \overload
+ \fn std::chrono::time_point<Clock, Duration> QDeadlineTimer::deadline() const
+
+ Returns the absolute time point for the deadline stored in QDeadlineTimer
+ object as a \c{std::chrono::time_point} object. The template parameter
+ \c{Clock} is mandatory and indicates which of the C++ timekeeping clocks to
+ use as a reference. The value will be in the past if this QDeadlineTimer
+ has expired.
+
+ If this QDeadlineTimer never expires, this function returns
+ \c{std::chrono::time_point<Clock, Duration>::max()}.
+
+ This function can be used to calculate the amount of time a timer is
+ overdue, by subtracting the current time point of the reference clock, as
+ in the following example:
+
+ \code
+ auto realTimeLeft = std::chrono::nanoseconds::max();
+ auto tp = deadline.deadline<std::chrono::steady_clock>();
+ if (tp != std::chrono::steady_clock::max())
+ realTimeLeft = tp - std::chrono::steady_clock::now();
+ \endcode
+
+ \note Timers that were created as expired have an indetermine time point in
+ the past as their deadline, so the above calculation may not work.
+
+ \sa remainingTime(), deadlineNSecs(), setDeadline()
+*/
+
+/*!
+ Returns true if this QDeadlineTimer object never expires, false otherwise.
+ For timers that never expire, remainingTime() always returns -1 and
+ deadline() returns the maximum value.
+
+ \sa ForeverConstant, hasExpired(), remainingTime()
+*/
+bool QDeadlineTimer::isForever() const Q_DECL_NOTHROW
+{
+ return t1 == (std::numeric_limits<qint64>::max)();
+}
+
+/*!
+ Returns true if this QDeadlineTimer object has expired, false if there
+ remains time left. For objects that have expired, remainingTime() will
+ return zero and deadline() will return a time point in the past.
+
+ QDeadlineTimer objects created with the \ref{ForeverConstant} never expire
+ and this function always returns false for them.
+
+ \sa isForever(), remainingTime()
+*/
+bool QDeadlineTimer::hasExpired() const Q_DECL_NOTHROW
+{
+ if (isForever())
+ return false;
+ return *this <= current(timerType());
+}
+
+/*!
+ \fn Qt::TimerType QDeadlineTimer::timerType() const Q_DECL_NOTHROW
+
+ Returns the timer type is active for this object.
+
+ \sa setTimerType()
+*/
+
+/*!
+ Changes the timer type for this object to \a timerType.
+
+ The behavior for each possible value of \a timerType is operating-system
+ dependent. Qt::PreciseTimer will use the most precise timer that Qt can
+ find, with resolution of 1 millisecond or better, whereas QDeadlineTimer
+ will try to use a more coarse timer for Qt::CoarseTimer and
+ Qt::VeryCoarseTimer.
+
+ \sa timerType()
+ */
+void QDeadlineTimer::setTimerType(Qt::TimerType timerType)
+{
+ type = timerType;
+}
+
+/*!
+ Returns the remaining time in this QDeadlineTimer object in milliseconds.
+ If the timer has already expired, this function will return zero and it is
+ not possible to obtain the amount of time overdue with this function (to do
+ that, see deadline()). If the timer was set to never expire, this function
+ returns -1.
+
+ This function is suitable for use in Qt APIs that take a millisecond
+ timeout, such as the many \ref QIODevice \c waitFor functions or the timed
+ lock functions in \ref QMutex, \ref QWaitCondition, \ref QSemaphore, or
+ \ref QReadWriteLock. For example:
+
+ \code
+ mutex.tryLock(deadline.remainingTime());
+ \code
+
+ \sa remainingTimeNSecs(), isForever(), hasExpired()
+*/
+qint64 QDeadlineTimer::remainingTime() const Q_DECL_NOTHROW
+{
+ qint64 ns = remainingTimeNSecs();
+ return ns <= 0 ? ns : ns / (1000 * 1000);
+}
+
+/*!
+ Returns the remaining time in this QDeadlineTimer object in nanoseconds. If
+ the timer has already expired, this function will return zero and it is not
+ possible to obtain the amount of time overdue with this function. If the
+ timer was set to never expire, this function returns -1.
+
+ \sa remainingTime(), isForever(), hasExpired()
+*/
+qint64 QDeadlineTimer::remainingTimeNSecs() const Q_DECL_NOTHROW
+{
+ if (isForever())
+ return -1;
+ qint64 raw = rawRemainingTimeNSecs();
+ return raw < 0 ? 0 : raw;
+}
+
+/*!
+ \internal
+ Same as remainingTimeNSecs, but may return negative remaining times. Does
+ not deal with Forever.
+*/
+qint64 QDeadlineTimer::rawRemainingTimeNSecs() const Q_DECL_NOTHROW
+{
+ QDeadlineTimer now = current(timerType());
+ if (QDeadlineTimerNanosecondsInT2)
+ return (t1 - now.t1) * (1000*1000*1000) + t2 - now.t2;
+ return t1 - now.t1;
+}
+
+/*!
+ Returns the absolute time point for the deadline stored in QDeadlineTimer
+ object, calculated in milliseconds relative to the reference clock, the
+ same as QElapsedTimer::msecsSinceReference(). The value will be in the past
+ if this QDeadlineTimer has expired.
+
+ If this QDeadlineTimer never expires, this function returns
+ \c{std::numeric_limits<qint64>::max()}.
+
+ This function can be used to calculate the amount of time a timer is
+ overdue, by subtracting QDeadlineTimer::current() or
+ QElapsedTimer::msecsSinceReference(), as in the following example:
+
+ \code
+ qint64 realTimeLeft = deadline.deadline();
+ if (realTimeLeft != (std::numeric_limits<qint64>::max)()) {
+ realTimeLeft -= QDeadlineTimer::current().deadline();
+ // or:
+ //QElapsedTimer timer;
+ //timer.start();
+ //realTimeLeft -= timer.msecsSinceReference();
+ }
+ \endcode
+
+ \note Timers that were created as expired have an indetermine time point in
+ the past as their deadline, so the above calculation may not work.
+
+ \sa remainingTime(), deadlineNSecs(), setDeadline()
+*/
+qint64 QDeadlineTimer::deadline() const Q_DECL_NOTHROW
+{
+ if (isForever())
+ return t1;
+ return deadlineNSecs() / (1000 * 1000);
+}
+
+/*!
+ Returns the absolute time point for the deadline stored in QDeadlineTimer
+ object, calculated in nanoseconds relative to the reference clock, the
+ same as QElapsedTimer::msecsSinceReference(). The value will be in the past
+ if this QDeadlineTimer has expired.
+
+ If this QDeadlineTimer never expires, this function returns
+ \c{std::numeric_limits<qint64>::max()}.
+
+ This function can be used to calculate the amount of time a timer is
+ overdue, by subtracting QDeadlineTimer::current(), as in the following
+ example:
+
+ \code
+ qint64 realTimeLeft = deadline.deadlineNSecs();
+ if (realTimeLeft != std::numeric_limits<qint64>::max())
+ realTimeLeft -= QDeadlineTimer::current().deadlineNSecs();
+ \endcode
+
+ \note Timers that were created as expired have an indetermine time point in
+ the past as their deadline, so the above calculation may not work.
+
+ \sa remainingTime(), deadlineNSecs()
+*/
+qint64 QDeadlineTimer::deadlineNSecs() const Q_DECL_NOTHROW
+{
+ if (isForever())
+ return t1;
+ if (QDeadlineTimerNanosecondsInT2)
+ return t1 * 1000 * 1000 * 1000 + t2;
+ return t1;
+}
+
+/*!
+ Sets the deadline for this QDeadlineTimer object to be the \a msecs
+ absolute time point, counted in milliseconds since the reference clock (the
+ same as QElapsedTimer::msecsSinceReference()), and the timer type to \a
+ timerType. If the value is in the past, this QDeadlineTimer will be marked
+ as expired.
+
+ If \a msecs is \c{std::numeric_limits<qint64>::max()}, this QDeadlineTimer
+ will be set to never expire.
+
+ \sa setPreciseDeadline(), deadline(), deadlineNSecs(), setRemainingTime()
+*/
+void QDeadlineTimer::setDeadline(qint64 msecs, Qt::TimerType timerType) Q_DECL_NOTHROW
+{
+ if (msecs == (std::numeric_limits<qint64>::max)()) {
+ setPreciseDeadline(msecs, 0, timerType); // msecs == MAX implies Forever
+ } else {
+ setPreciseDeadline(msecs / 1000, msecs % 1000 * 1000 * 1000, timerType);
+ }
+}
+
+/*!
+ Sets the deadline for this QDeadlineTimer object to be \a secs seconds and
+ \a nsecs nanoseconds since the reference clock epoch (the same as
+ QElapsedTimer::msecsSinceReference()), and the timer type to \a timerType.
+ If the value is in the past, this QDeadlineTimer will be marked as expired.
+
+ If \a secs or \a nsecs is \c{std::numeric_limits<qint64>::max()}, this
+ QDeadlineTimer will be set to never expire. If \a nsecs is more than 1
+ billion nanoseconds (1 second), then \a secs will be adjusted accordingly.
+
+ \sa setDeadline(), deadline(), deadlineNSecs(), setRemainingTime()
+*/
+void QDeadlineTimer::setPreciseDeadline(qint64 secs, qint64 nsecs, Qt::TimerType timerType) Q_DECL_NOTHROW
+{
+ type = timerType;
+ if (secs == (std::numeric_limits<qint64>::max)() || nsecs == (std::numeric_limits<qint64>::max)()) {
+ *this = QDeadlineTimer(Forever, timerType);
+ } else if (QDeadlineTimerNanosecondsInT2) {
+ t1 = secs + toSecsAndNSecs(nsecs).first;
+ t2 = toSecsAndNSecs(nsecs).second;
+ } else {
+ t1 = secs * (1000*1000*1000) + nsecs;
+ }
+}
+
+/*!
+ Returns a QDeadlineTimer object whose deadline is extended from \a dt's
+ deadline by \a nsecs nanoseconds. If \a dt was set to never expire, this
+ function returns a QDeadlineTimer that will not expire either.
+
+ \note if \a dt was created as expired, its deadline is indeterminate and
+ adding an amount of time may or may not cause it to become unexpired.
+*/
+QDeadlineTimer QDeadlineTimer::addNSecs(QDeadlineTimer dt, qint64 nsecs) Q_DECL_NOTHROW
+{
+ if (dt.isForever() || nsecs == (std::numeric_limits<qint64>::max)()) {
+ dt = QDeadlineTimer(Forever, dt.timerType());
+ } else if (QDeadlineTimerNanosecondsInT2) {
+ dt.t1 += toSecsAndNSecs(nsecs).first;
+ dt.t2 += toSecsAndNSecs(nsecs).second;
+ if (dt.t2 > 1000*1000*1000) {
+ dt.t2 -= 1000*1000*1000;
+ ++dt.t1;
+ }
+ } else {
+ dt.t1 += nsecs;
+ }
+ return dt;
+}
+
+/*!
+ \fn QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType)
+
+ Returns a QDeadlineTimer that is expired but is guaranteed to contain the
+ current time. Objects created by this function can participate in the
+ calculation of how long a timer is overdue, using the deadline() function.
+
+ The QDeadlineTimer object will be constructed with a timer type of \a
+ timerType.
+*/
+
+/*!
+ \fn qint64 QDeadlineTimer::resolution(Qt::TimerType timerType)
+
+ Returns the resolution in nanoseconds of the system clock that backs timers
+ of type \a timerType, or 0 if the resolution could not be determined.
+
+ The resolution is not a guarantee that applications will get time values
+ with an accuracy down to that level. It is only the minimum change value
+ that can be expected.
+*/
+
+/*!
+ \fn bool operator==(QDeadlineTimer d1, QDeadlineTimer d2)
+ \related QDeadlineTimer
+
+ Returns true if the deadline on \a d1 and the deadline in \a d2 are the
+ same, false otherwise. The timer type used to create the two deadlines is
+ ignored. This function is equivalent to:
+
+ \code
+ return d1.deadlineNSecs() == d2.deadlineNSecs();
+ \endcode
+
+ \note comparing QDeadlineTimer objects with different timer types is
+ not supported and may result in unpredictable behavior.
+*/
+
+/*!
+ \fn bool operator!=(QDeadlineTimer d1, QDeadlineTimer d2)
+ \related QDeadlineTimer
+
+ Returns true if the deadline on \a d1 and the deadline in \a d2 are
+ diferent, false otherwise. The timer type used to create the two deadlines
+ is ignored. This function is equivalent to:
+
+ \code
+ return d1.deadlineNSecs() != d2.deadlineNSecs();
+ \endcode
+
+ \note comparing QDeadlineTimer objects with different timer types is
+ not supported and may result in unpredictable behavior.
+*/
+
+/*!
+ \fn bool operator<(QDeadlineTimer d1, QDeadlineTimer d2)
+ \related QDeadlineTimer
+
+ Returns true if the deadline on \a d1 is earlier than the deadline in \a
+ d2, false otherwise. The timer type used to create the two deadlines is
+ ignored. This function is equivalent to:
+
+ \code
+ return d1.deadlineNSecs() < d2.deadlineNSecs();
+ \endcode
+
+ \note comparing QDeadlineTimer objects with different timer types is
+ not supported and may result in unpredictable behavior.
+*/
+
+/*!
+ \fn bool operator<=(QDeadlineTimer d1, QDeadlineTimer d2)
+ \related QDeadlineTimer
+
+ Returns true if the deadline on \a d1 is earlier than or the same as the
+ deadline in \a d2, false otherwise. The timer type used to create the two
+ deadlines is ignored. This function is equivalent to:
+
+ \code
+ return d1.deadlineNSecs() <= d2.deadlineNSecs();
+ \endcode
+
+ \note comparing QDeadlineTimer objects with different timer types is
+ not supported and may result in unpredictable behavior.
+*/
+
+/*!
+ \fn bool operator>(QDeadlineTimer d1, QDeadlineTimer d2)
+ \related QDeadlineTimer
+
+ Returns true if the deadline on \a d1 is later than the deadline in \a
+ d2, false otherwise. The timer type used to create the two deadlines is
+ ignored. This function is equivalent to:
+
+ \code
+ return d1.deadlineNSecs() > d2.deadlineNSecs();
+ \endcode
+
+ \note comparing QDeadlineTimer objects with different timer types is
+ not supported and may result in unpredictable behavior.
+*/
+
+/*!
+ \fn bool operator>=(QDeadlineTimer d1, QDeadlineTimer d2)
+ \related QDeadlineTimer
+
+ Returns true if the deadline on \a d1 is later than or the same as the
+ deadline in \a d2, false otherwise. The timer type used to create the two
+ deadlines is ignored. This function is equivalent to:
+
+ \code
+ return d1.deadlineNSecs() >= d2.deadlineNSecs();
+ \endcode
+
+ \note comparing QDeadlineTimer objects with different timer types is
+ not supported and may result in unpredictable behavior.
+*/
+
+/*!
+ \fn QDeadlineTimer operator+(QDeadlineTimer dt, qint64 msecs)
+ \related QDeadlineTimer
+
+ Returns a QDeadlineTimer object whose deadline is \a msecs later than the
+ deadline stored in \a dt. If \a dt is set to never expire, this function
+ returns a QDeadlineTimer that does not expire either.
+
+ To add times of precision greater than 1 millisecond, use addNSecs().
+*/
+
+/*!
+ \fn QDeadlineTimer operator+(qint64 msecs, QDeadlineTimer dt)
+ \related QDeadlineTimer
+
+ Returns a QDeadlineTimer object whose deadline is \a msecs later than the
+ deadline stored in \a dt. If \a dt is set to never expire, this function
+ returns a QDeadlineTimer that does not expire either.
+
+ To add times of precision greater than 1 millisecond, use addNSecs().
+*/
+
+/*!
+ \fn QDeadlineTimer operator-(QDeadlineTimer dt, qint64 msecs)
+ \related QDeadlineTimer
+
+ Returns a QDeadlineTimer object whose deadline is \a msecs before the
+ deadline stored in \a dt. If \a dt is set to never expire, this function
+ returns a QDeadlineTimer that does not expire either.
+
+ To subtract times of precision greater than 1 millisecond, use addNSecs().
+*/
+
+/*!
+ \fn QDeadlineTimer &QDeadlineTimer::operator+=(qint64 msecs)
+
+ Extends this QDeadlineTimer object by \a msecs milliseconds and returns
+ itself. If this object is set to never expire, this function does nothing.
+
+ To add times of precision greater than 1 millisecond, use addNSecs().
+*/
+
+/*!
+ \fn QDeadlineTimer &QDeadlineTimer::operator-=(qint64 msecs)
+
+ Shortens this QDeadlineTimer object by \a msecs milliseconds and returns
+ itself. If this object is set to never expire, this function does nothing.
+
+ To subtract times of precision greater than 1 millisecond, use addNSecs().
+*/
+
+// the rest of the functions are in qelapsedtimer_xxx.cpp
+
+QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qdeadlinetimer.h b/src/corelib/kernel/qdeadlinetimer.h
new file mode 100644
index 0000000000..ac8a09ba97
--- /dev/null
+++ b/src/corelib/kernel/qdeadlinetimer.h
@@ -0,0 +1,190 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Intel Corporation.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDEADLINETIMER_H
+#define QDEADLINETIMER_H
+
+#include <QtCore/qelapsedtimer.h>
+#include <QtCore/qmetatype.h>
+#include <QtCore/qnamespace.h>
+
+#ifdef max
+// un-pollute the namespace. We need std::numeric_limits::max() and std::chrono::duration::max()
+# undef max
+#endif
+
+#include <limits>
+
+#if QT_HAS_INCLUDE(<chrono>)
+# include <chrono>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class Q_CORE_EXPORT QDeadlineTimer
+{
+public:
+ enum ForeverConstant { Forever };
+
+ Q_DECL_CONSTEXPR QDeadlineTimer(Qt::TimerType type_ = Qt::CoarseTimer) Q_DECL_NOTHROW
+ : t1(0), t2(0), type(type_) {}
+ Q_DECL_CONSTEXPR QDeadlineTimer(ForeverConstant, Qt::TimerType type_ = Qt::CoarseTimer) Q_DECL_NOTHROW
+ : t1(std::numeric_limits<qint64>::max()), t2(0), type(type_) {}
+ explicit QDeadlineTimer(qint64 msecs, Qt::TimerType type = Qt::CoarseTimer) Q_DECL_NOTHROW;
+
+ void swap(QDeadlineTimer &other)
+ { qSwap(t1, other.t1); qSwap(t2, other.t2); qSwap(type, other.type); }
+
+ bool isForever() const Q_DECL_NOTHROW;
+ bool hasExpired() const Q_DECL_NOTHROW;
+
+ Qt::TimerType timerType() const Q_DECL_NOTHROW
+ { return Qt::TimerType(type & 0xff); }
+ void setTimerType(Qt::TimerType type);
+
+ qint64 remainingTime() const Q_DECL_NOTHROW;
+ qint64 remainingTimeNSecs() const Q_DECL_NOTHROW;
+ void setRemainingTime(qint64 msecs, Qt::TimerType type = Qt::CoarseTimer) Q_DECL_NOTHROW;
+ void setPreciseRemainingTime(qint64 secs, qint64 nsecs = 0,
+ Qt::TimerType type = Qt::CoarseTimer) Q_DECL_NOTHROW;
+
+ qint64 deadline() const Q_DECL_NOTHROW Q_DECL_PURE_FUNCTION;
+ qint64 deadlineNSecs() const Q_DECL_NOTHROW Q_DECL_PURE_FUNCTION;
+ void setDeadline(qint64 msecs, Qt::TimerType timerType = Qt::CoarseTimer) Q_DECL_NOTHROW;
+ void setPreciseDeadline(qint64 secs, qint64 nsecs = 0,
+ Qt::TimerType type = Qt::CoarseTimer) Q_DECL_NOTHROW;
+
+ static QDeadlineTimer addNSecs(QDeadlineTimer dt, qint64 nsecs) Q_DECL_NOTHROW Q_DECL_PURE_FUNCTION;
+ static QDeadlineTimer current(Qt::TimerType timerType = Qt::CoarseTimer) Q_DECL_NOTHROW;
+
+ friend bool operator==(QDeadlineTimer d1, QDeadlineTimer d2)
+ { return d1.t1 == d2.t1 && d1.t2 == d2.t2; }
+ friend bool operator!=(QDeadlineTimer d1, QDeadlineTimer d2)
+ { return !(d1 == d2); }
+ friend bool operator<(QDeadlineTimer d1, QDeadlineTimer d2)
+ { return d1.t1 < d2.t1 || (d1.t1 == d2.t1 && d1.t2 < d2.t2); }
+ friend bool operator<=(QDeadlineTimer d1, QDeadlineTimer d2)
+ { return d1 == d2 || d1 < d2; }
+ friend bool operator>(QDeadlineTimer d1, QDeadlineTimer d2)
+ { return d2 < d1; }
+ friend bool operator>=(QDeadlineTimer d1, QDeadlineTimer d2)
+ { return !(d1 < d2); }
+
+ friend QDeadlineTimer operator+(QDeadlineTimer dt, qint64 msecs)
+ { return QDeadlineTimer::addNSecs(dt, msecs * 1000 * 1000); }
+ friend QDeadlineTimer operator+(qint64 msecs, QDeadlineTimer dt)
+ { return dt + msecs; }
+ friend QDeadlineTimer operator-(QDeadlineTimer dt, qint64 msecs)
+ { return dt + (-msecs); }
+ friend qint64 operator-(QDeadlineTimer dt1, QDeadlineTimer dt2)
+ { return (dt1.deadlineNSecs() - dt2.deadlineNSecs()) / (1000 * 1000); }
+ QDeadlineTimer &operator+=(qint64 msecs)
+ { *this = *this + msecs; return *this; }
+ QDeadlineTimer &operator-=(qint64 msecs)
+ { *this = *this + (-msecs); return *this; }
+
+#if QT_HAS_INCLUDE(<chrono>) || defined(Q_QDOC)
+ template <class Clock, class Duration>
+ QDeadlineTimer(std::chrono::time_point<Clock, Duration> deadline_,
+ Qt::TimerType type_ = Qt::CoarseTimer) : t2(0)
+ { setDeadline(deadline_, type_); }
+ template <class Clock, class Duration>
+ QDeadlineTimer &operator=(std::chrono::time_point<Clock, Duration> deadline_)
+ { setDeadline(deadline_); return *this; }
+
+ template <class Clock, class Duration>
+ void setDeadline(std::chrono::time_point<Clock, Duration> deadline_,
+ Qt::TimerType type_ = Qt::CoarseTimer)
+ { setRemainingTime(deadline_ == deadline_.max() ? Duration::max() : deadline_ - Clock::now(), type_); }
+
+ template <class Clock, class Duration = typename Clock::duration>
+ std::chrono::time_point<Clock, Duration> deadline() const
+ {
+ auto val = std::chrono::nanoseconds(rawRemainingTimeNSecs()) + Clock::now();
+ return std::chrono::time_point_cast<Duration>(val);
+ }
+
+ template <class Rep, class Period>
+ QDeadlineTimer(std::chrono::duration<Rep, Period> remaining, Qt::TimerType type_ = Qt::CoarseTimer)
+ : t2(0)
+ { setRemainingTime(remaining, type_); }
+
+ template <class Rep, class Period>
+ QDeadlineTimer &operator=(std::chrono::duration<Rep, Period> remaining)
+ { setRemainingTime(remaining); return *this; }
+
+ template <class Rep, class Period>
+ void setRemainingTime(std::chrono::duration<Rep, Period> remaining, Qt::TimerType type_ = Qt::CoarseTimer)
+ {
+ if (remaining == remaining.max())
+ *this = QDeadlineTimer(Forever, type_);
+ else
+ setPreciseRemainingTime(0, std::chrono::nanoseconds(remaining).count(), type_);
+ }
+
+ std::chrono::nanoseconds remainingTimeAsDuration() const Q_DECL_NOTHROW
+ {
+ if (isForever())
+ return std::chrono::nanoseconds::max();
+ qint64 nsecs = rawRemainingTimeNSecs();
+ if (nsecs <= 0)
+ return std::chrono::nanoseconds::zero();
+ return std::chrono::nanoseconds(nsecs);
+ }
+
+ template <class Rep, class Period>
+ friend QDeadlineTimer operator+(QDeadlineTimer dt, std::chrono::duration<Rep, Period> value)
+ { return QDeadlineTimer::addNSecs(dt, std::chrono::duration_cast<std::chrono::nanoseconds>(value).count()); }
+ template <class Rep, class Period>
+ friend QDeadlineTimer operator+(std::chrono::duration<Rep, Period> value, QDeadlineTimer dt)
+ { return dt + value; }
+ template <class Rep, class Period>
+ friend QDeadlineTimer operator+=(QDeadlineTimer &dt, std::chrono::duration<Rep, Period> value)
+ { return dt = dt + value; }
+#endif
+
+private:
+ qint64 t1;
+ unsigned t2;
+ unsigned type;
+
+ qint64 rawRemainingTimeNSecs() const Q_DECL_NOTHROW;
+};
+
+Q_DECLARE_SHARED(QDeadlineTimer)
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QDeadlineTimer)
+
+#endif // QDEADLINETIMER_H
diff --git a/src/corelib/global/qconfig-dist.h b/src/corelib/kernel/qdeadlinetimer_p.h
index c9739db990..94ded921e1 100644
--- a/src/corelib/global/qconfig-dist.h
+++ b/src/corelib/kernel/qdeadlinetimer_p.h
@@ -37,12 +37,23 @@
**
****************************************************************************/
+#ifndef QDEADLINETIMER_P_H
+#define QDEADLINETIMER_P_H
-/*
- Empty leaves all features enabled. See doc/html/emb-features.html for choices.
+#include <QtCore/qglobal.h>
- Note that disabling some features will produce a libqt that is not
- compatible with other libqt builds. Such modifications are only
- supported on Qt for Embedded Linux where reducing the library size is
- important and where the application suite is often a fixed set.
-*/
+QT_BEGIN_NAMESPACE
+
+enum {
+#if defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN)
+ // t1 contains seconds and t2 contains nanoseconds
+ QDeadlineTimerNanosecondsInT2 = 1
+#else
+ // t1 contains nanoseconds, t2 is always zero
+ QDeadlineTimerNanosecondsInT2 = 0
+#endif
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/corelib/tools/qelapsedtimer.cpp b/src/corelib/kernel/qelapsedtimer.cpp
index addecc0236..5e9d1317ac 100644
--- a/src/corelib/tools/qelapsedtimer.cpp
+++ b/src/corelib/kernel/qelapsedtimer.cpp
@@ -83,6 +83,9 @@ QT_BEGIN_NAMESPACE
\snippet qelapsedtimer/main.cpp 2
+ It is often more convenient to use \ref{QDeadlineTimer} in this case, which
+ counts towards a timeout in the future instead of tracking elapsed time.
+
\section1 Reference Clocks
QElapsedTimer will use the platform's monotonic reference clock in all
@@ -120,7 +123,7 @@ QT_BEGIN_NAMESPACE
The information on which clocks types may overflow and how to remedy that
issue is documented along with the clock types.
- \sa QTime, QTimer
+ \sa QTime, QTimer, QDeadlineTimer
*/
/*!
@@ -255,7 +258,7 @@ bool QElapsedTimer::isValid() const Q_DECL_NOTHROW
The value of \a timeout can be -1 to indicate that this timer does not
expire, in which case this function will always return false.
- \sa elapsed()
+ \sa elapsed(), QDeadlineTimer
*/
bool QElapsedTimer::hasExpired(qint64 timeout) const Q_DECL_NOTHROW
{
diff --git a/src/corelib/tools/qelapsedtimer.h b/src/corelib/kernel/qelapsedtimer.h
index 7954b41bf4..7954b41bf4 100644
--- a/src/corelib/tools/qelapsedtimer.h
+++ b/src/corelib/kernel/qelapsedtimer.h
diff --git a/src/corelib/tools/qelapsedtimer_generic.cpp b/src/corelib/kernel/qelapsedtimer_generic.cpp
index 29ba1517ed..fdeb385188 100644
--- a/src/corelib/tools/qelapsedtimer_generic.cpp
+++ b/src/corelib/kernel/qelapsedtimer_generic.cpp
@@ -38,6 +38,7 @@
****************************************************************************/
#include "qelapsedtimer.h"
+#include "qdeadlinetimer.h"
#include "qdatetime.h"
QT_BEGIN_NAMESPACE
@@ -201,4 +202,12 @@ bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) Q_DECL_NOTHROW
return v1.t1 < v2.t1;
}
+QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) Q_DECL_NOTHROW
+{
+ QDeadlineTimer result;
+ result.t1 = QDateTime::currentMSecsSinceEpoch() * 1000 * 1000;
+ result.type = timerType;
+ return result;
+}
+
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qelapsedtimer_mac.cpp b/src/corelib/kernel/qelapsedtimer_mac.cpp
index 886e0f41b2..7490693991 100644
--- a/src/corelib/tools/qelapsedtimer_mac.cpp
+++ b/src/corelib/kernel/qelapsedtimer_mac.cpp
@@ -41,6 +41,8 @@
#define _POSIX_C_SOURCE 200809L
#include "qelapsedtimer.h"
+#include "qdeadlinetimer.h"
+#include "qdeadlinetimer_p.h"
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
@@ -50,6 +52,12 @@
QT_BEGIN_NAMESPACE
+#ifdef __LP64__
+typedef __int128_t LargeInt;
+#else
+typedef qint64 LargeInt;
+#endif
+
QElapsedTimer::ClockType QElapsedTimer::clockType() Q_DECL_NOTHROW
{
return MachAbsoluteTime;
@@ -65,13 +73,13 @@ static qint64 absoluteToNSecs(qint64 cpuTime)
{
if (info.denom == 0)
mach_timebase_info(&info);
-#ifdef __LP64__
- __uint128_t nsecs = static_cast<__uint128_t>(cpuTime) * info.numer / info.denom;
- return static_cast<qint64>(nsecs);
-#else
- qint64 nsecs = cpuTime * info.numer / info.denom;
+
+ // don't do multiplication & division if those are equal
+ // (mathematically it would be the same, but it's computationally expensive)
+ if (info.numer == info.denom)
+ return cpuTime;
+ qint64 nsecs = LargeInt(cpuTime) * info.numer / info.denom;
return nsecs;
-#endif
}
static qint64 absoluteToMSecs(qint64 cpuTime)
@@ -146,4 +154,13 @@ bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) Q_DECL_NOTHROW
return v1.t1 < v2.t1;
}
+QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) Q_DECL_NOTHROW
+{
+ Q_STATIC_ASSERT(!QDeadlineTimerNanosecondsInT2);
+ QDeadlineTimer result;
+ result.type = timerType;
+ result.t1 = absoluteToNSecs(mach_absolute_time());
+ return result;
+}
+
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qelapsedtimer_unix.cpp b/src/corelib/kernel/qelapsedtimer_unix.cpp
index e2c3ae6280..e166d4e3d2 100644
--- a/src/corelib/tools/qelapsedtimer_unix.cpp
+++ b/src/corelib/kernel/qelapsedtimer_unix.cpp
@@ -39,6 +39,8 @@
****************************************************************************/
#include "qelapsedtimer.h"
+#include "qdeadlinetimer.h"
+#include "qdeadlinetimer_p.h"
#if defined(Q_OS_VXWORKS)
#include "qfunctions_vxworks.h"
#else
@@ -248,4 +250,16 @@ bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) Q_DECL_NOTHROW
return v1.t1 < v2.t1 || (v1.t1 == v2.t1 && v1.t2 < v2.t2);
}
+QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) Q_DECL_NOTHROW
+{
+ Q_STATIC_ASSERT(QDeadlineTimerNanosecondsInT2);
+ QDeadlineTimer result;
+ qint64 cursec, curnsec;
+ do_gettime(&cursec, &curnsec);
+ result.t1 = cursec;
+ result.t2 = curnsec;
+ result.type = timerType;
+ return result;
+}
+
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qelapsedtimer_win.cpp b/src/corelib/kernel/qelapsedtimer_win.cpp
index 734aaf80f2..0c380b2f6a 100644
--- a/src/corelib/tools/qelapsedtimer_win.cpp
+++ b/src/corelib/kernel/qelapsedtimer_win.cpp
@@ -38,37 +38,25 @@
****************************************************************************/
#include "qelapsedtimer.h"
+#include "qdeadlinetimer.h"
+#include "qdeadlinetimer_p.h"
#include <qt_windows.h>
-typedef ULONGLONG (WINAPI *PtrGetTickCount64)(void);
-#if defined(Q_OS_WINRT)
- static const PtrGetTickCount64 ptrGetTickCount64 = &GetTickCount64;
-#else
- static PtrGetTickCount64 ptrGetTickCount64 = 0;
-#endif
-
QT_BEGIN_NAMESPACE
// Result of QueryPerformanceFrequency, 0 indicates that the high resolution timer is unavailable
static quint64 counterFrequency = 0;
-static void resolveLibs()
+static void resolveCounterFrequency()
{
static bool done = false;
if (done)
return;
-#if !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE)
- // try to get GetTickCount64 from the system
- HMODULE kernel32 = GetModuleHandleW(L"kernel32");
- if (!kernel32)
- return;
- ptrGetTickCount64 = (PtrGetTickCount64)GetProcAddress(kernel32, "GetTickCount64");
-#endif // !Q_OS_WINRT && !Q_OS_WINCE
-
// Retrieve the number of high-resolution performance counter ticks per second
LARGE_INTEGER frequency;
if (!QueryPerformanceFrequency(&frequency)) {
+ qFatal("QueryPerformanceFrequency failed, even though Microsoft documentation promises it wouldn't.");
counterFrequency = 0;
} else {
counterFrequency = frequency.QuadPart;
@@ -90,37 +78,33 @@ static inline qint64 ticksToNanoseconds(qint64 ticks)
}
}
+static inline qint64 nanosecondsToTicks(qint64 nsec)
+{
+ if (counterFrequency > 0) {
+ // QueryPerformanceCounter uses an arbitrary frequency
+ return double(nsec) * counterFrequency / 1000000000.;
+ } else {
+ // GetTickCount(64) uses milliseconds
+ return nsec / 1000000;
+ }
+}
+
static quint64 getTickCount()
{
- resolveLibs();
+ resolveCounterFrequency();
// This avoids a division by zero and disables the high performance counter if it's not available
if (counterFrequency > 0) {
LARGE_INTEGER counter;
- if (QueryPerformanceCounter(&counter)) {
- return counter.QuadPart;
- } else {
- qWarning("QueryPerformanceCounter failed, although QueryPerformanceFrequency succeeded.");
- return 0;
- }
+ bool ok = QueryPerformanceCounter(&counter);
+ Q_ASSERT_X(ok, "QElapsedTimer::start()",
+ "QueryPerformanceCounter failed, although QueryPerformanceFrequency succeeded.");
+ Q_UNUSED(ok);
+ return counter.QuadPart;
}
-#ifndef Q_OS_WINRT
- if (ptrGetTickCount64)
- return ptrGetTickCount64();
-
- static quint32 highdword = 0;
- static quint32 lastval = 0;
- quint32 val = GetTickCount();
- if (val < lastval)
- ++highdword;
- lastval = val;
- return val | (quint64(highdword) << 32);
-#else // !Q_OS_WINRT
- // ptrGetTickCount64 is always set on WinRT but GetTickCount is not available
- return ptrGetTickCount64();
-#endif // Q_OS_WINRT
+ return GetTickCount64();
}
quint64 qt_msectime()
@@ -130,7 +114,7 @@ quint64 qt_msectime()
QElapsedTimer::ClockType QElapsedTimer::clockType() Q_DECL_NOTHROW
{
- resolveLibs();
+ resolveCounterFrequency();
if (counterFrequency > 0)
return PerformanceCounter;
@@ -190,4 +174,13 @@ bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) Q_DECL_NOTHROW
return (v1.t1 - v2.t1) < 0;
}
+QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) Q_DECL_NOTHROW
+{
+ Q_STATIC_ASSERT(!QDeadlineTimerNanosecondsInT2);
+ QDeadlineTimer result;
+ result.t1 = ticksToNanoseconds(getTickCount());
+ result.type = timerType;
+ return result;
+}
+
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qeventdispatcher_cf.mm b/src/corelib/kernel/qeventdispatcher_cf.mm
index 55f27a5b60..437e4062ad 100644
--- a/src/corelib/kernel/qeventdispatcher_cf.mm
+++ b/src/corelib/kernel/qeventdispatcher_cf.mm
@@ -210,6 +210,13 @@ QEventDispatcherCoreFoundation::~QEventDispatcherCoreFoundation()
m_cfSocketNotifier.removeSocketNotifiers();
}
+QEventLoop *QEventDispatcherCoreFoundation::currentEventLoop() const
+{
+ QEventLoop *eventLoop = QThreadData::current()->eventLoops.top();
+ Q_ASSERT(eventLoop);
+ return eventLoop;
+}
+
/*!
Processes all pending events that match \a flags until there are no
more events to process. Returns \c true if pending events were handled;
@@ -302,10 +309,7 @@ bool QEventDispatcherCoreFoundation::processEvents(QEventLoop::ProcessEventsFlag
// to exit, and then unwind back to the previous event loop which will break
// immediately, since it has already been exited.
- QEventLoop *currentEventLoop = QThreadData::current()->eventLoops.top();
- Q_ASSERT(currentEventLoop);
-
- if (!currentEventLoop->isRunning()) {
+ if (!currentEventLoop()->isRunning()) {
qEventDispatcherDebug() << "Top level event loop was exited";
break;
} else {
diff --git a/src/corelib/kernel/qeventdispatcher_cf_p.h b/src/corelib/kernel/qeventdispatcher_cf_p.h
index c2592cacc8..e6581e2bac 100644
--- a/src/corelib/kernel/qeventdispatcher_cf_p.h
+++ b/src/corelib/kernel/qeventdispatcher_cf_p.h
@@ -228,6 +228,8 @@ public:
void flush();
protected:
+ QEventLoop *currentEventLoop() const;
+
virtual bool processPostedEvents();
struct ProcessEventsState
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index 166e509635..1a0efae2dc 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -55,7 +55,6 @@
QT_BEGIN_NAMESPACE
-HINSTANCE qWinAppInst();
extern uint qGlobalPostedEventsCount();
#ifndef TIME_KILL_SYNCHRONOUS
@@ -63,11 +62,7 @@ extern uint qGlobalPostedEventsCount();
#endif
#ifndef QS_RAWINPUT
-# ifdef Q_OS_WINCE
-# define QS_RAWINPUT 0x0000
-# else
# define QS_RAWINPUT 0x0400
-# endif
#endif
#ifndef WM_TOUCH
@@ -89,230 +84,14 @@ enum {
SendPostedEventsWindowsTimerId = ~1u
};
-#if defined(Q_OS_WINCE)
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <winsock.h>
-QT_END_INCLUDE_NAMESPACE
-// Asynchronous Winsocks ------------------------------------------
-#ifndef QT_NO_THREAD
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <qthread.h>
-#include <qmap.h>
-#include <qmutex.h>
-QT_END_INCLUDE_NAMESPACE
-
-//#define QCE_ASYNC_DEBUG
-
-namespace {
- class SocketAsyncHandler;
-
- class SocketAsyncHandler : public QThread
- {
- public:
- SocketAsyncHandler();
- ~SocketAsyncHandler();
- void run();
- void select(SOCKET sock, HWND handle, unsigned int msg, long ev);
- void removeSelect(SOCKET sock);
- void safeRemove(SOCKET sock);
- private:
- struct SockInfo {
- HWND handle;
- unsigned int msg;
- long ev;
- };
- QMap<SOCKET, SockInfo> sockets;
- QMutex mutex;
- QWaitCondition cond;
- bool supposedToDie;
- };
-
- SocketAsyncHandler::SocketAsyncHandler()
- : supposedToDie(false)
- {
- }
-
- SocketAsyncHandler::~SocketAsyncHandler()
- {
- mutex.lock();
- supposedToDie = true;
- mutex.unlock();
- cond.wakeOne();
- wait();
- while (sockets.size() > 0)
- removeSelect(sockets.begin().key());
- }
-
- void SocketAsyncHandler::removeSelect(SOCKET sock)
- {
- if (!sockets.contains(sock))
- return;
- sockets.remove(sock);
- return;
- }
-
- void SocketAsyncHandler::safeRemove(SOCKET sock)
- {
- QMutexLocker locker(&mutex);
- removeSelect(sock);
- }
-
- void SocketAsyncHandler::select(SOCKET sock, HWND handle, unsigned int msg, long ev)
- {
- QMutexLocker locker(&mutex);
-
- if (sockets.contains(sock))
- sockets.remove(sock);
-
- SockInfo info;
- info.handle = handle;
- info.msg = msg;
- info.ev = ev;
- sockets.insert(sock, info);
- cond.wakeOne();
- }
-
- void SocketAsyncHandler::run()
- {
- do {
- mutex.lock();
-
- while (!supposedToDie && sockets.isEmpty()) {
- cond.wait(&mutex);
- }
-
- if (supposedToDie) {
- mutex.unlock();
- break;
- }
-
- // Copy current items to reduce lock time
- // and to be able to use SendMessage
- QMap<SOCKET, SockInfo> currentSockets = sockets;
- mutex.unlock();
-
- fd_set readS, writeS, exS;
- FD_ZERO(&readS);
- FD_ZERO(&writeS);
- FD_ZERO(&exS);
-
- int maxFd = 0;
-
- for (QMap<SOCKET, SockInfo>::iterator it = currentSockets.begin(); it != currentSockets.end(); ++it) {
- const SockInfo &info = it.value();
- int socket = it.key();
- maxFd = qMax(maxFd, socket);
-
- if ((info.ev & FD_READ) || (info.ev & FD_CLOSE) || (info.ev & FD_ACCEPT))
- FD_SET(socket, &readS);
- if ((info.ev & FD_WRITE)|| (info.ev & FD_CONNECT))
- FD_SET(socket, &writeS);
- if (info.ev & FD_OOB)
- FD_SET(socket, &exS);
- }
-
- timeval timeout;
- timeout.tv_sec = 0;
- timeout.tv_usec = 50000;
- int result = ::select(maxFd + 1, &readS, &writeS, &exS, &timeout);
- if (result > 0) {
- HWND handle;
- unsigned int tmpMsg;
- SOCKET sock;
- HRESULT ret;
- for (QMap<SOCKET, SockInfo>::const_iterator it = currentSockets.constBegin();
- it != currentSockets.constEnd(); ++it) {
- handle = (*it).handle;
- tmpMsg = (*it).msg;
- sock = it.key();
- if (FD_ISSET(sock, &readS))
- ret = SendMessage(handle, tmpMsg, sock, FD_READ);
-
- if (FD_ISSET(sock, &writeS))
- ret = SendMessage(handle, tmpMsg, sock, FD_WRITE);
-
- if (FD_ISSET(sock, &exS))
- ret = SendMessage(handle, tmpMsg, sock, FD_OOB);
- }
- }
-
-#ifdef QCE_ASYNC_DEBUG
- else if (result == 0) { //timeout
- qDebug(" WSAAsync select timeout");
- } else if (result < 0) { // SocketError
- // This might happen because of two reasons
- // 1. We already closed a socket in between the copy and the select
- // and thus select() returns an error
- // 2. Something is really wrong, then
- // ### Loop on all descriptors, try to select and remove the
- // ### broken one.
- qWarning("WSAAsync select error %d", WSAGetLastError());
- }
-#endif
- } while(true);
- }
-} // namespace
-
-Q_GLOBAL_STATIC(SocketAsyncHandler, qt_async_handler)
-
-int WSAAsyncSelect(SOCKET sock, HWND handle, unsigned int msg, long ev)
-{
- if (sock == 0 || handle == 0 || handle == INVALID_HANDLE_VALUE) {
- WSASetLastError(WSAEINVAL);
- return SOCKET_ERROR;
- }
-
- if (msg == 0 && ev == 0)
- qt_async_handler()->safeRemove(sock);
- else
- qt_async_handler()->select(sock, handle, msg, ev);
-
- qt_async_handler()->start(QThread::LowPriority);
- WSASetLastError(0);
- return 0;
-}
-#else // QT_NO_THREAD
-int WSAAsyncSelect(SOCKET, HWND, unsigned int, long)
-{
- return SOCKET_ERROR;
-}
-#endif
-#endif // Q_OS_WINCE
-
class QEventDispatcherWin32Private;
#if !defined(DWORD_PTR) && !defined(Q_OS_WIN64)
#define DWORD_PTR DWORD
#endif
-typedef MMRESULT(WINAPI *ptimeSetEvent)(UINT, UINT, LPTIMECALLBACK, DWORD_PTR, UINT);
-typedef MMRESULT(WINAPI *ptimeKillEvent)(UINT);
-
-static ptimeSetEvent qtimeSetEvent = 0;
-static ptimeKillEvent qtimeKillEvent = 0;
-
LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp);
-static void resolveTimerAPI()
-{
- static bool triedResolve = false;
- if (!triedResolve) {
-#ifndef QT_NO_THREAD
- QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve));
- if (triedResolve)
- return;
-#endif
- triedResolve = true;
-#if !defined(Q_OS_WINCE)
- qtimeSetEvent = (ptimeSetEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeSetEvent");
- qtimeKillEvent = (ptimeKillEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeKillEvent");
-#else
- qtimeSetEvent = (ptimeSetEvent)QSystemLibrary::resolve(QLatin1String("Mmtimer"), "timeSetEvent");
- qtimeKillEvent = (ptimeKillEvent)QSystemLibrary::resolve(QLatin1String("Mmtimer"), "timeKillEvent");
-#endif
- }
-}
-
QEventDispatcherWin32Private::QEventDispatcherWin32Private()
: threadId(GetCurrentThreadId()), interrupt(false), closingDown(false), internalHwnd(0),
getMessageHook(0), serialNumber(0), lastSerialNumber(0), sendPostedEventsWindowsTimerId(0),
@@ -321,7 +100,6 @@ QEventDispatcherWin32Private::QEventDispatcherWin32Private()
, activateNotifiersPosted(false)
#endif
{
- resolveTimerAPI();
}
QEventDispatcherWin32Private::~QEventDispatcherWin32Private()
@@ -502,11 +280,7 @@ LRESULT QT_WIN_CALLBACK qt_GetMessageHook(int code, WPARAM wp, LPARAM lp)
}
}
}
-#ifdef Q_OS_WINCE
- return 0;
-#else
return q->d_func()->getMessageHook ? CallNextHookEx(0, code, wp, lp) : 0;
-#endif
}
// Provide class name and atom for the message window used by
@@ -535,7 +309,7 @@ QWindowsMessageWindowClassContext::QWindowsMessageWindowClassContext()
wc.lpfnWndProc = qt_internal_proc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
- wc.hInstance = qWinAppInst();
+ wc.hInstance = GetModuleHandle(0);
wc.hIcon = 0;
wc.hCursor = 0;
wc.hbrBackground = 0;
@@ -552,7 +326,7 @@ QWindowsMessageWindowClassContext::QWindowsMessageWindowClassContext()
QWindowsMessageWindowClassContext::~QWindowsMessageWindowClassContext()
{
if (className) {
- UnregisterClass(className, qWinAppInst());
+ UnregisterClass(className, GetModuleHandle(0));
delete [] className;
}
}
@@ -564,18 +338,13 @@ static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatch
QWindowsMessageWindowClassContext *ctx = qWindowsMessageWindowClassContext();
if (!ctx->atom)
return 0;
-#ifdef Q_OS_WINCE
- HWND parent = 0;
-#else
- HWND parent = HWND_MESSAGE;
-#endif
HWND wnd = CreateWindow(ctx->className, // classname
ctx->className, // window name
0, // style
0, 0, 0, 0, // geometry
- parent, // parent
+ HWND_MESSAGE, // parent
0, // menu handle
- qWinAppInst(), // application
+ GetModuleHandle(0), // application
0); // windows creation data.
if (!wnd) {
@@ -609,24 +378,27 @@ void QEventDispatcherWin32Private::registerTimer(WinTimerInfo *t)
Q_Q(QEventDispatcherWin32);
- int ok = 0;
+ bool ok = false;
calculateNextTimeout(t, qt_msectime());
uint interval = t->interval;
if (interval == 0u) {
// optimization for single-shot-zero-timer
QCoreApplication::postEvent(q, new QZeroTimerEvent(t->timerId));
- ok = 1;
- } else if ((interval < 20u || t->timerType == Qt::PreciseTimer) && qtimeSetEvent) {
- ok = t->fastTimerId = qtimeSetEvent(interval, 1, qt_fast_timer_proc, (DWORD_PTR)t,
- TIME_CALLBACK_FUNCTION | TIME_PERIODIC | TIME_KILL_SYNCHRONOUS);
+ ok = true;
+ } else if (interval < 20u || t->timerType == Qt::PreciseTimer) {
+ // 3/2016: Although MSDN states timeSetEvent() is deprecated, the function
+ // is still deemed to be the most reliable precision timer.
+ t->fastTimerId = timeSetEvent(interval, 1, qt_fast_timer_proc, DWORD_PTR(t),
+ TIME_CALLBACK_FUNCTION | TIME_PERIODIC | TIME_KILL_SYNCHRONOUS);
+ ok = t->fastTimerId;
}
- if (ok == 0) {
+ if (!ok) {
// user normal timers for (Very)CoarseTimers, or if no more multimedia timers available
ok = SetTimer(internalHwnd, t->timerId, interval, 0);
}
- if (ok == 0)
+ if (!ok)
qErrnoWarning("QEventDispatcherWin32::registerTimer: Failed to create a timer");
}
@@ -635,7 +407,7 @@ void QEventDispatcherWin32Private::unregisterTimer(WinTimerInfo *t)
if (t->interval == 0) {
QCoreApplicationPrivate::removePostedTimerEvent(t->dispatcher, t->timerId);
} else if (t->fastTimerId != 0) {
- qtimeKillEvent(t->fastTimerId);
+ timeKillEvent(t->fastTimerId);
QCoreApplicationPrivate::removePostedTimerEvent(t->dispatcher, t->timerId);
} else if (internalHwnd) {
KillTimer(internalHwnd, t->timerId);
@@ -702,7 +474,6 @@ void QEventDispatcherWin32::installMessageHook()
if (d->getMessageHook)
return;
-#ifndef Q_OS_WINCE
// setup GetMessage hook needed to drive our posted events
d->getMessageHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC) qt_GetMessageHook, NULL, GetCurrentThreadId());
if (Q_UNLIKELY(!d->getMessageHook)) {
@@ -710,17 +481,14 @@ void QEventDispatcherWin32::installMessageHook()
qFatal("Qt: INTERNAL ERROR: failed to install GetMessage hook: %d, %s",
errorCode, qPrintable(qt_error_string(errorCode)));
}
-#endif
}
void QEventDispatcherWin32::uninstallMessageHook()
{
Q_D(QEventDispatcherWin32);
-#ifndef Q_OS_WINCE
if (d->getMessageHook)
UnhookWindowsHookEx(d->getMessageHook);
-#endif
d->getMessageHook = 0;
}
@@ -1166,11 +934,7 @@ void QEventDispatcherWin32::activateEventNotifiers()
Q_D(QEventDispatcherWin32);
//### this could break if events are removed/added in the activation
for (int i=0; i<d->winEventNotifierList.count(); i++) {
-#if !defined(Q_OS_WINCE)
if (WaitForSingleObjectEx(d->winEventNotifierList.at(i)->handle(), 0, TRUE) == WAIT_OBJECT_0)
-#else
- if (WaitForSingleObject(d->winEventNotifierList.at(i)->handle(), 0) == WAIT_OBJECT_0)
-#endif
d->activateEventNotifier(d->winEventNotifierList.at(i));
}
}
diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h
index a87b56cd38..773315c04f 100644
--- a/src/corelib/kernel/qeventdispatcher_win_p.h
+++ b/src/corelib/kernel/qeventdispatcher_win_p.h
@@ -138,7 +138,7 @@ struct WinTimerInfo { // internal timer info
quint64 timeout; // - when to actually fire
QObject *obj; // - object to receive events
bool inTimerEvent;
- int fastTimerId;
+ UINT fastTimerId;
};
class QZeroTimerEvent : public QTimerEvent
diff --git a/src/corelib/kernel/qeventdispatcher_winrt.cpp b/src/corelib/kernel/qeventdispatcher_winrt.cpp
index 2ffcf03eb2..3b2321aa49 100644
--- a/src/corelib/kernel/qeventdispatcher_winrt.cpp
+++ b/src/corelib/kernel/qeventdispatcher_winrt.cpp
@@ -95,6 +95,51 @@ private:
std::function<HRESULT()> delegate;
};
+class QWorkHandler : public IWorkItemHandler
+{
+public:
+ QWorkHandler(const std::function<HRESULT()> &delegate)
+ : m_delegate(delegate)
+ {
+ }
+
+ STDMETHODIMP Invoke(ABI::Windows::Foundation::IAsyncAction *operation)
+ {
+ HRESULT res = m_delegate();
+ Q_UNUSED(operation);
+ return res;
+ }
+
+ STDMETHODIMP QueryInterface(REFIID riid, void FAR* FAR* ppvObj)
+ {
+ if (riid == IID_IUnknown || riid == IID_IWorkItemHandler) {
+ *ppvObj = this;
+ AddRef();
+ return NOERROR;
+ }
+ *ppvObj = NULL;
+ return ResultFromScode(E_NOINTERFACE);
+ }
+
+ STDMETHODIMP_(ULONG) AddRef(void)
+ {
+ return ++m_refs;
+ }
+
+ STDMETHODIMP_(ULONG) Release(void)
+ {
+ if (--m_refs == 0) {
+ delete this;
+ return 0;
+ }
+ return m_refs;
+ }
+
+private:
+ std::function<HRESULT()> m_delegate;
+ ULONG m_refs{0};
+};
+
class QEventDispatcherWinRTPrivate : public QAbstractEventDispatcherPrivate
{
Q_DECLARE_PUBLIC(QEventDispatcherWinRT)
@@ -175,48 +220,62 @@ QEventDispatcherWinRT::~QEventDispatcherWinRT()
HRESULT QEventDispatcherWinRT::runOnXamlThread(const std::function<HRESULT ()> &delegate, bool waitForRun)
{
static __declspec(thread) ICoreDispatcher *dispatcher = nullptr;
+ HRESULT hr;
if (!dispatcher) {
- HRESULT hr;
ComPtr<ICoreImmersiveApplication> application;
hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication).Get(),
IID_PPV_ARGS(&application));
ComPtr<ICoreApplicationView> view;
hr = application->get_MainView(&view);
- Q_ASSERT_SUCCEEDED(hr);
- ComPtr<ICoreWindow> window;
- hr = view->get_CoreWindow(&window);
- Q_ASSERT_SUCCEEDED(hr);
- if (!window) {
- // In case the application is launched via activation
- // there might not be a main view (eg ShareTarget).
- // Hence iterate through the available views and try to find
- // a dispatcher in there
- ComPtr<IVectorView<CoreApplicationView*>> appViews;
- hr = application->get_Views(&appViews);
+ if (SUCCEEDED(hr) && view) {
+ ComPtr<ICoreWindow> window;
+ hr = view->get_CoreWindow(&window);
Q_ASSERT_SUCCEEDED(hr);
- quint32 count;
- hr = appViews->get_Size(&count);
- Q_ASSERT_SUCCEEDED(hr);
- for (quint32 i = 0; i < count; ++i) {
- hr = appViews->GetAt(i, &view);
+ if (!window) {
+ // In case the application is launched via activation
+ // there might not be a main view (eg ShareTarget).
+ // Hence iterate through the available views and try to find
+ // a dispatcher in there
+ ComPtr<IVectorView<CoreApplicationView*>> appViews;
+ hr = application->get_Views(&appViews);
Q_ASSERT_SUCCEEDED(hr);
- hr = view->get_CoreWindow(&window);
+ quint32 count;
+ hr = appViews->get_Size(&count);
Q_ASSERT_SUCCEEDED(hr);
- if (window) {
- hr = window->get_Dispatcher(&dispatcher);
+ for (quint32 i = 0; i < count; ++i) {
+ hr = appViews->GetAt(i, &view);
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = view->get_CoreWindow(&window);
Q_ASSERT_SUCCEEDED(hr);
- if (dispatcher)
- break;
+ if (window) {
+ hr = window->get_Dispatcher(&dispatcher);
+ Q_ASSERT_SUCCEEDED(hr);
+ if (dispatcher)
+ break;
+ }
}
+ } else {
+ hr = window->get_Dispatcher(&dispatcher);
+ Q_ASSERT_SUCCEEDED(hr);
}
- Q_ASSERT(dispatcher);
- } else {
- hr = window->get_Dispatcher(&dispatcher);
- Q_ASSERT_SUCCEEDED(hr);
}
}
- HRESULT hr;
+ if (Q_UNLIKELY(!dispatcher)) {
+ // In case the application is launched in a way that has no UI and
+ // also does not allow to create one, e.g. as a background task.
+ // Features like network operations do still work, others might cause
+ // errors in that case.
+ ComPtr<IThreadPoolStatics> tpStatics;
+ hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_System_Threading_ThreadPool).Get(),
+ IID_PPV_ARGS(&tpStatics));
+ ComPtr<IAsyncAction> op;
+ hr = tpStatics.Get()->RunAsync(new QWorkHandler(delegate), &op);
+ if (FAILED(hr) || !waitForRun)
+ return hr;
+ return QWinRTFunctions::await(op);
+ }
+
boolean onXamlThread;
hr = dispatcher->get_HasThreadAccess(&onXamlThread);
Q_ASSERT_SUCCEEDED(hr);
diff --git a/src/corelib/kernel/qeventdispatcher_winrt_p.h b/src/corelib/kernel/qeventdispatcher_winrt_p.h
index abcb3bf99c..f69bb9cf3f 100644
--- a/src/corelib/kernel/qeventdispatcher_winrt_p.h
+++ b/src/corelib/kernel/qeventdispatcher_winrt_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qabstracteventdispatcher.h"
#include <qt_windows.h>
diff --git a/src/corelib/kernel/qeventloop_p.h b/src/corelib/kernel/qeventloop_p.h
index 3ce707a6a9..dcbb5c63c6 100644
--- a/src/corelib/kernel/qeventloop_p.h
+++ b/src/corelib/kernel/qeventloop_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include "qcoreapplication.h"
#include "qobject_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/kernel/qfunctions_p.h b/src/corelib/kernel/qfunctions_p.h
index 06f5ea09da..715c553dc5 100644
--- a/src/corelib/kernel/qfunctions_p.h
+++ b/src/corelib/kernel/qfunctions_p.h
@@ -51,11 +51,9 @@
#ifndef QFUNCTIONS_P_H
#define QFUNCTIONS_P_H
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
-#if defined(Q_OS_WINCE)
-# include "QtCore/qfunctions_wince.h"
-#elif defined(Q_OS_VXWORKS)
+#if defined(Q_OS_VXWORKS)
# include "QtCore/qfunctions_vxworks.h"
#elif defined(Q_OS_NACL)
# include "QtCore/qfunctions_nacl.h"
diff --git a/src/corelib/kernel/qfunctions_wince.cpp b/src/corelib/kernel/qfunctions_wince.cpp
deleted file mode 100644
index 104c6fb27c..0000000000
--- a/src/corelib/kernel/qfunctions_wince.cpp
+++ /dev/null
@@ -1,407 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifdef _WIN32_WCE //Q_OS_WINCE
-
-#include <windows.h>
-#include <winbase.h>
-#include <kfuncs.h>
-#include <stdio.h>
-#if _WIN32_WCE < 0x800
-# include <altcecrt.h>
-#else
-# include <fcntl.h>
-#endif
-
-#include "qplatformdefs.h"
-#include "qfunctions_wince.h"
-#include "qfunctions_fake_env_p.h"
-#include "qstring.h"
-
-QT_USE_NAMESPACE
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-wchar_t* CEPrivConvCharToWide(const char* string)
-{
- size_t length = strlen(string);
- wchar_t* wString = new wchar_t[length +1];
- for (unsigned int i = 0; i < (length +1); i++)
- wString[i] = string[i];
- return wString;
-}
-
-// Time -------------------------------------------------------------
-time_t qt_wince_ftToTime_t( const FILETIME ft )
-{
- ULARGE_INTEGER li;
- li.LowPart = ft.dwLowDateTime;
- li.HighPart = ft.dwHighDateTime;
-
- // 100-nanosec to seconds
- li.QuadPart /= 10000000;
-
- // FILETIME is from 1601-01-01 T 00:00:00
- // time_t is from 1970-01-01 T 00:00:00
- // 1970 - 1601 = 369 year (89 leap years)
- //
- // ((369y*365d) + 89d) *24h *60min *60sec
- // = 11644473600 seconds
- li.QuadPart -= 11644473600;
- return li.LowPart;
-}
-
-FILETIME qt_wince_time_tToFt( time_t tt )
-{
- ULARGE_INTEGER li;
- li.QuadPart = tt;
- li.QuadPart += 11644473600;
- li.QuadPart *= 10000000;
-
- FILETIME ft;
- ft.dwLowDateTime = li.LowPart;
- ft.dwHighDateTime = li.HighPart;
- return ft;
-}
-
-// File I/O ---------------------------------------------------------
-#if _WIN32_WCE < 0x800
-int errno = 0;
-#endif
-
-int qt_wince__getdrive( void )
-{
- return 1;
-}
-
-int qt_wince__waccess( const wchar_t *path, int pmode )
-{
- DWORD res = GetFileAttributes( path );
- if ( 0xFFFFFFFF == res )
- return -1;
-
- if ( (pmode & W_OK) && (res & FILE_ATTRIBUTE_READONLY) )
- return -1;
-
- if ( (pmode & X_OK) && !(res & FILE_ATTRIBUTE_DIRECTORY) ) {
- QString file = QString::fromWCharArray(path);
- if ( !(file.endsWith(QString::fromLatin1(".exe")) ||
- file.endsWith(QString::fromLatin1(".com"))) )
- return -1;
- }
-
- return 0;
-}
-
-int qt_wince_open( const char *filename, int oflag, int pmode )
-{
- QString fn( QString::fromLatin1(filename) );
- return _wopen( (wchar_t*)fn.utf16(), oflag, pmode );
-}
-
-int qt_wince__wopen( const wchar_t *filename, int oflag, int /*pmode*/ )
-{
- wchar_t *flag;
-
- if ( oflag & _O_APPEND ) {
- if ( oflag & _O_WRONLY ) {
- flag = L"a";
- } else if ( oflag & _O_RDWR ) {
- flag = L"a+";
- }
- } else if (oflag & _O_BINARY) {
- if ( oflag & _O_WRONLY ) {
- flag = L"wb";
- } else if ( oflag & _O_RDWR ) {
- flag = L"w+b"; // slightly different from "r+" where the file must exist
- } else if ( oflag & _O_RDONLY ) {
- flag = L"rb";
- } else {
- flag = L"b";
- }
- } else {
- if ( oflag & _O_WRONLY ) {
- flag = L"wt";
- } else if ( oflag & _O_RDWR ) {
- flag = L"w+t"; // slightly different from "r+" where the file must exist
- } else if ( oflag & _O_RDONLY ) {
- flag = L"rt";
- } else {
- flag = L"t";
- }
- }
-
- int retval = (int)_wfopen( filename, flag );
- return (retval == NULL) ? -1 : retval;
-}
-
-long qt_wince__lseek( int handle, long offset, int origin )
-{
- return fseek( (FILE*)handle, offset, origin );
-}
-
-int qt_wince__read( int handle, void *buffer, unsigned int count )
-{
- return fread( buffer, 1, count, (FILE*)handle );
-}
-
-int qt_wince__write( int handle, const void *buffer, unsigned int count )
-{
- return fwrite( buffer, 1, count, (FILE*)handle );
-}
-
-int qt_wince__close( int handle )
-{
- if (!handle)
- return 0;
- return fclose( (FILE*)handle );
-}
-
-FILE *qt_wince__fdopen(int handle, const char* /*mode*/)
-{
- return (FILE*)handle;
-}
-
-FILE *qt_wince_fdopen( int handle, const char* /*mode*/ )
-{
- return (FILE*)handle;
-}
-
-void qt_wince_rewind( FILE *stream )
-{
- fseek( stream, 0L, SEEK_SET );
-}
-
-int qt_wince___fileno(FILE *f)
-{
- return (int) _fileno(f);
-}
-
-FILE *qt_wince_tmpfile( void )
-{
- static long i = 0;
- char name[16];
- sprintf( name, "tmp%i", i++ );
- return fopen( name, "r+" );
-}
-
-int qt_wince__mkdir(const char *dirname)
-{
- return CreateDirectory(reinterpret_cast<const wchar_t *> (QString(QString::fromLatin1(dirname)).utf16()), 0) ? 0 : -1;
-}
-
-int qt_wince__rmdir(const char *dirname)
-{
- return RemoveDirectory(reinterpret_cast<const wchar_t *> (QString::fromLatin1(dirname).utf16())) ? 0 : -1;
-}
-
-int qt_wince__access( const char *path, int pmode )
-{
- return _waccess(reinterpret_cast<const wchar_t *> (QString::fromLatin1(path).utf16()),pmode);
-}
-
-int qt_wince__rename( const char *oldname, const char *newname )
-{
- return !MoveFile(reinterpret_cast<const wchar_t *> (QString::fromLatin1(oldname).utf16()), reinterpret_cast<const wchar_t *> (QString::fromLatin1(newname).utf16()));
-}
-
-int qt_wince__remove( const char *name )
-{
- return !DeleteFile(reinterpret_cast<const wchar_t *> (QString::fromLatin1(name).utf16()));
-}
-
-int qt_wince_stat( const char *path, struct stat *buffer )
-{
- WIN32_FIND_DATA finfo;
- HANDLE ff = FindFirstFile( reinterpret_cast<const wchar_t *> (QString::fromLatin1(path).utf16()), &finfo );
-
- if ( ff == INVALID_HANDLE_VALUE )
- return -1;
-
- buffer->st_ctime = qt_wince_ftToTime_t( finfo.ftCreationTime );
- buffer->st_atime = qt_wince_ftToTime_t( finfo.ftLastAccessTime );
- buffer->st_mtime = qt_wince_ftToTime_t( finfo.ftLastWriteTime );
- buffer->st_nlink = 0;
- buffer->st_size = finfo.nFileSizeLow; // ### missing high!
- buffer->st_mode = (finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _S_IFDIR : _S_IFREG;
- buffer->st_mode |= (finfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? _O_RDONLY : _O_RDWR;
- return (FindClose(ff) == 0);
-}
-
-int qt_wince__fstat( int handle, struct stat *buffer)
-{
- BY_HANDLE_FILE_INFORMATION fInfo;
- BOOL res = GetFileInformationByHandle((HANDLE)handle, &fInfo);
-
- buffer->st_ctime = qt_wince_ftToTime_t( fInfo.ftCreationTime );
- buffer->st_atime = qt_wince_ftToTime_t( fInfo.ftLastAccessTime );
- buffer->st_mtime = qt_wince_ftToTime_t( fInfo.ftLastWriteTime );
- buffer->st_nlink = 0;
- buffer->st_size = fInfo.nFileSizeLow; // ### missing high!
- buffer->st_mode = (fInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _S_IFDIR : _S_IFREG;
- buffer->st_mode |= (fInfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? _O_RDONLY : _O_RDWR;
- return (res == 0);
-}
-
-int qt_wince_SetErrorMode(int newValue)
-{
- static int oldValue;
- int result = oldValue;
- oldValue = newValue;
- return result;
-}
-
-bool qt_wince__chmod(const char *file, int mode)
-{
- return _wchmod( reinterpret_cast<const wchar_t *> (QString::fromLatin1(file).utf16()), mode);
-}
-
-bool qt_wince__wchmod(const wchar_t *file, int mode)
-{
- BOOL success = FALSE;
- // ### Does not work properly, what about just adding one property?
- if(mode&_S_IWRITE) {
- success = SetFileAttributes(file, FILE_ATTRIBUTE_NORMAL);
- } else if((mode&_S_IREAD) && !(mode&_S_IWRITE)) {
- success = SetFileAttributes(file, FILE_ATTRIBUTE_READONLY);
- }
- return success ? 0 : -1;
-}
-
-HANDLE qt_wince_CreateFileA(LPCSTR filename, DWORD access, DWORD share, LPSECURITY_ATTRIBUTES attr, DWORD dispo, DWORD flags, HANDLE tempFile)
-{
- return CreateFileW( reinterpret_cast<const wchar_t *>(QString::fromLatin1(filename).utf16()), access, share, attr, dispo, flags, tempFile);
-}
-
-// Graphics ---------------------------------------------------------
-BOOL qt_wince_SetWindowOrgEx( HDC /*hdc*/, int /*X*/, int /*Y*/, LPPOINT /*lpPoint*/) {
- return TRUE;
-}
-
-// Threading --------------------------------------------------------
-HANDLE qt_wince__beginthread(void( *start_address )( void * ), unsigned stack_size, void *arglist)
-{
- unsigned initflag = 0;
- if (stack_size > 0)
- initflag |= STACK_SIZE_PARAM_IS_A_RESERVATION;
- return CreateThread(NULL, stack_size, (LPTHREAD_START_ROUTINE)start_address, arglist, initflag, NULL);
-}
-
-unsigned long qt_wince__beginthreadex( void *security,
- unsigned stack_size,
- unsigned (__stdcall *start_address)(void *),
- void *arglist,
- unsigned initflag,
- unsigned *thrdaddr)
-{
- if (stack_size > 0)
- initflag |= STACK_SIZE_PARAM_IS_A_RESERVATION;
- return (unsigned long)
- CreateThread( (LPSECURITY_ATTRIBUTES)security,
- (DWORD)stack_size,
- (LPTHREAD_START_ROUTINE)start_address,
- (LPVOID)arglist,
- (DWORD)initflag | CREATE_SUSPENDED,
- (LPDWORD)thrdaddr);
-}
-
-void qt_wince__endthreadex(unsigned nExitCode) {
- ExitThread((DWORD)nExitCode);
-}
-
-void *qt_wince_bsearch(const void *key,
- const void *base,
- size_t num,
- size_t size,
- int (__cdecl *compare)(const void *, const void *))
-{
- size_t low = 0;
- size_t high = num - 1;
- while (low <= high) {
- size_t mid = (low + high) >> 1;
- int c = compare(key, (char*)base + mid * size);
- if (c < 0) {
- if (!mid)
- break;
- high = mid - 1;
- } else if (c > 0)
- low = mid + 1;
- else
- return (char*) base + mid * size;
- }
- return 0;
-}
-
-void *lfind(const void* key, const void* base, size_t* elements, size_t size,
- int (__cdecl *compare)(const void*, const void*))
-{
- const char* current = (char*) base;
- const char* const end = (char*) (current + (*elements) * size);
- while (current != end) {
- if (compare(current, key) == 0)
- return (void*)current;
- current += size;
- }
- return 0;
-}
-
-DWORD qt_wince_GetThreadLocale(void)
-{
- return GetUserDefaultLCID();
-}
-
-void *qt_wince_calloc( size_t num, size_t size )
-{
- void *ptr = malloc( num * size );
- if( ptr )
- memset( ptr, 0, num * size );
- return ptr;
-}
-
-// _getpid is currently only used for creating a temporary filename
-int qt_wince__getpid()
-{
- return qAbs((int)GetCurrentProcessId());
-}
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-#endif // Q_OS_WINCE
diff --git a/src/corelib/kernel/qfunctions_wince.h b/src/corelib/kernel/qfunctions_wince.h
deleted file mode 100644
index 030950e1bd..0000000000
--- a/src/corelib/kernel/qfunctions_wince.h
+++ /dev/null
@@ -1,473 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFUNCTIONS_WINCE_H
-#define QFUNCTIONS_WINCE_H
-
-#include <QtCore/qglobal.h>
-
-#ifdef Q_OS_WINCE
-# ifndef NOMINMAX
-# define NOMINMAX
-# endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <windows.h>
-#include <winuser.h>
-#include <winbase.h>
-#include <objbase.h>
-#include <kfuncs.h>
-#include <ctype.h>
-#include <time.h>
-#include <crtdefs.h>
-#if _WIN32_WCE < 0x800
-# include <altcecrt.h>
-#else
-# include <fcntl.h>
-# include <stat.h>
-#endif
-#include <winsock.h>
-#include <ceconfig.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifdef QT_BUILD_CORE_LIB
-#endif
-
-QT_END_NAMESPACE
-
-// The standard SDK misses this define...
-#define _control87 _controlfp
-
-#if !defined __cplusplus
-#define bool int
-#define true 1
-#define false 0
-#endif
-
-// Environment ------------------------------------------------------
-errno_t qt_fake_getenv_s(size_t*, char*, size_t, const char*);
-errno_t qt_fake__putenv_s(const char*, const char*);
-
-#ifdef __cplusplus // have this as tiff plugin is written in C
-extern "C" {
-#endif
-
-#if !defined(NO_ERRNO_H)
-#define NO_ERRNO_H
-#endif
-
-// Environment ------------------------------------------------------
-int qt_wince__getpid(void);
-
-
-// Time -------------------------------------------------------------
-#ifndef _TM_DEFINED
-#define _TM_DEFINED
-struct tm {
- int tm_sec; /* seconds after the minute - [0,59] */
- int tm_min; /* minutes after the hour - [0,59] */
- int tm_hour; /* hours since midnight - [0,23] */
- int tm_mday; /* day of the month - [1,31] */
- int tm_mon; /* months since January - [0,11] */
- int tm_year; /* years since 1900 */
- int tm_wday; /* days since Sunday - [0,6] */
- int tm_yday; /* days since January 1 - [0,365] */
- int tm_isdst; /* daylight-saving time flag */
-};
-#endif // _TM_DEFINED
-
-FILETIME qt_wince_time_tToFt( time_t tt );
-time_t qt_wince_ftToTime_t( const FILETIME ft );
-
-#if _WIN32_WCE < 0x800
-
-// File I/O ---------------------------------------------------------
-#define _O_RDONLY 0x0001
-#define _O_RDWR 0x0002
-#define _O_WRONLY 0x0004
-#define _O_CREAT 0x0008
-#define _O_TRUNC 0x0010
-#define _O_APPEND 0x0020
-#define _O_EXCL 0x0040
-
-#define O_RDONLY _O_RDONLY
-#define O_RDWR _O_RDWR
-#define O_WRONLY _O_WRONLY
-#define O_CREAT _O_CREAT
-#define O_TRUNC _O_TRUNC
-#define O_APPEND _O_APPEND
-#define O_EXCL _O_EXCL
-
-#define _S_IFMT 0x0600
-#define _S_IFDIR 0x0200
-#define _S_IFCHR 0x0100
-#define _S_IFREG 0x0400
-#define _S_IREAD 0x0010
-#define _S_IWRITE 0x0008
-
-#define S_IFMT _S_IFMT
-#define S_IFDIR _S_IFDIR
-#define S_IFCHR _S_IFCHR
-#define S_IFREG _S_IFREG
-#define S_IREAD _S_IREAD
-#define S_IWRITE _S_IWRITE
-
-#ifndef _IOFBF
-#define _IOFBF 0x0000
-#endif
-
-#ifndef _IOLBF
-#define _IOLBF 0x0040
-#endif
-
-#ifndef _IONBF
-#define _IONBF 0x0004
-#endif
-
-// Regular Berkeley error constants
-#ifndef _STAT_DEFINED
-#define _STAT_DEFINED
-struct stat
-{
- int st_mode;
- int st_size;
- int st_nlink;
- time_t st_mtime;
- time_t st_atime;
- time_t st_ctime;
-};
-#endif
-
-typedef int mode_t;
-extern int errno;
-#endif // _WIN32_WCE < 0x800
-
-int qt_wince__getdrive( void );
-int qt_wince__waccess( const wchar_t *path, int pmode );
-int qt_wince__wopen( const wchar_t *filename, int oflag, int pmode );
-long qt_wince__lseek( int handle, long offset, int origin );
-int qt_wince__read( int handle, void *buffer, unsigned int count );
-int qt_wince__write( int handle, const void *buffer, unsigned int count );
-int qt_wince__close( int handle );
-FILE *qt_wince__fdopen(int handle, const char *mode);
-FILE *qt_wince_fdopen(int handle, const char *mode);
-void qt_wince_rewind( FILE *stream );
-int qt_wince___fileno(FILE *);
-FILE *qt_wince_tmpfile( void );
-
-//For zlib we need these helper functions, but they break the build when
-//set globally, so just set them for zlib use
-#ifdef ZLIB_H
-#define open qt_wince_open
-#define close qt_wince__close
-#define lseek qt_wince__lseek
-#define read qt_wince__read
-#define write qt_wince__write
-#endif
-
-int qt_wince__mkdir(const char *dirname);
-int qt_wince__rmdir(const char *dirname);
-int qt_wince__access( const char *path, int pmode );
-int qt_wince__rename( const char *oldname, const char *newname );
-int qt_wince__remove( const char *name );
-#ifdef __cplusplus
-int qt_wince_open( const char *filename, int oflag, int pmode = 0 );
-#else
-int qt_wince_open( const char *filename, int oflag, int pmode );
-#endif
-int qt_wince_stat( const char *path, struct stat *buffer );
-int qt_wince__fstat( int handle, struct stat *buffer);
-
-#define SEM_FAILCRITICALERRORS 0x0001
-#define SEM_NOOPENFILEERRORBOX 0x0002
-int qt_wince_SetErrorMode(int);
-#ifndef CoInitialize
-#define CoInitialize(x) CoInitializeEx(x, COINIT_MULTITHREADED)
-#endif
-
-bool qt_wince__chmod(const char *file, int mode);
-bool qt_wince__wchmod(const wchar_t *file, int mode);
-
-QT_WARNING_DISABLE_MSVC(4273)
-HANDLE qt_wince_CreateFileA(LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
-
-// Printer ----------------------------------------------------------
-#define ETO_GLYPH_INDEX 0x0010
-
-// Graphics ---------------------------------------------------------
-#ifndef SM_CXCURSOR
-# define SM_CXCURSOR 13
-#endif
-#ifndef SM_CYCURSOR
-# define SM_CYCURSOR 14
-#endif
-BOOL qt_wince_SetWindowOrgEx( HDC hdc, int X, int Y, LPPOINT lpPoint );
-
-// Other stuff ------------------------------------------------------
-#define MWMO_ALERTABLE 0x0002
-// ### not the real values
-#define CREATE_NO_WINDOW 2
-#define CF_HDROP 15
-
-void *qt_wince_calloc(size_t num, size_t size);
-#if !defined(TLS_OUT_OF_INDEXES)
-# define TLS_OUT_OF_INDEXES 0xffffffff
-#endif
-DWORD qt_wince_GetThreadLocale(void);
-
-HANDLE qt_wince__beginthread(void( *start_address )( void * ), unsigned stack_size, void *arglist);
-
-unsigned long qt_wince__beginthreadex( void *security,
- unsigned stack_size,
- unsigned (__stdcall *start_address)(void *),
- void *arglist,
- unsigned initflag,
- unsigned *thrdaddr );
-void qt_wince__endthreadex(unsigned nExitCode);
-
-
-// bsearch is needed for building the tiff plugin
-// otherwise it could go into qguifunctions_wce
-void *qt_wince_bsearch(const void *key,
- const void *base,
- size_t num,
- size_t size,
- int (__cdecl *compare)(const void *, const void *));
-
-// Missing typedefs
-#ifndef _TIME_T_DEFINED
-typedef unsigned long time_t;
-#define _TIME_T_DEFINED
-#endif
-typedef HANDLE HDROP;
-
-#ifndef WS_THICKFRAME
-#define WS_THICKFRAME WS_DLGFRAME
-#endif
-
-typedef UINT UWORD;
-
-// Missing definitions: not necessary equal to their Win32 values
-// (the goal is to just have a clean compilation of MFC)
-#define WS_MAXIMIZE 0
-#define WS_MINIMIZE 0
-#ifndef WS_EX_TOOLWINDOW
-#define WS_EX_TOOLWINDOW 0
-#endif
-#define WS_EX_NOPARENTNOTIFY 0
-#define WM_ENTERIDLE 0x0121
-#define WM_PRINT WM_PAINT
-#define WM_NCCREATE (0x0081)
-#define WM_PARENTNOTIFY 0
-#define WM_NCDESTROY (WM_APP-1)
-#ifndef SW_RESTORE
-#define SW_RESTORE (SW_SHOWNORMAL)
-#endif
-#define SW_NORMAL (SW_SHOWNORMAL)
-#define WAIT_OBJECT_0 0x00000000L
-#define DEFAULT_GUI_FONT SYSTEM_FONT
-#ifndef SWP_NOREDRAW
-#define SWP_NOREDRAW 0
-#endif
-#define WSAGETSELECTEVENT(lParam) LOWORD(lParam)
-#define HWND_TOPMOST ((HWND)-1)
-#define HWND_NOTOPMOST ((HWND)-2)
-#define PS_DOT 2
-#define PD_ALLPAGES 0
-#define PD_USEDEVMODECOPIES 0
-#define PD_NOSELECTION 0
-#define PD_HIDEPRINTTOFILE 0
-#define PD_NOPAGENUMS 0
-#define CF_METAFILEPICT 3
-#define MM_ANISOTROPIC 8
-#define KF_ALTDOWN 0x2000
-#define SPI_GETWORKAREA 48
-
-#ifndef WM_SETCURSOR
- #define WM_SETCURSOR 0x0020
- #define IDC_ARROW MAKEINTRESOURCE(32512)
- #define IDC_IBEAM MAKEINTRESOURCE(32513)
- #define IDC_WAIT MAKEINTRESOURCE(32514)
- #define IDC_CROSS MAKEINTRESOURCE(32515)
- #define IDC_UPARROW MAKEINTRESOURCE(32516)
- #define IDC_SIZE MAKEINTRESOURCE(32646)
- #define IDC_ICON MAKEINTRESOURCE(32512)
- #define IDC_SIZENWSE MAKEINTRESOURCE(32642)
- #define IDC_SIZENESW MAKEINTRESOURCE(32643)
- #define IDC_SIZEWE MAKEINTRESOURCE(32644)
- #define IDC_SIZENS MAKEINTRESOURCE(32645)
- #define IDC_SIZEALL MAKEINTRESOURCE(32646)
- #define IDC_NO MAKEINTRESOURCE(32648)
- #define IDC_APPSTARTING MAKEINTRESOURCE(32650)
- #define IDC_HELP MAKEINTRESOURCE(32651)
- #define IDC_HAND MAKEINTRESOURCE(32649)
-#endif
-
-#define GMEM_MOVEABLE LMEM_MOVEABLE
-#define GPTR LPTR
-
-// WinCE: CESYSGEN prunes the following FRP defines,
-// and INTERNET_TRANSFER_TYPE_ASCII breaks in wininet.h
-#undef FTP_TRANSFER_TYPE_ASCII
-#define FTP_TRANSFER_TYPE_ASCII 0x00000001
-#undef FTP_TRANSFER_TYPE_BINARY
-#define FTP_TRANSFER_TYPE_BINARY 0x00000002
-
-typedef DWORD OLE_COLOR;
-
-// Define the Windows Styles which are not defined by MS
-#ifndef WS_POPUPWINDOW
-#define WS_POPUPWINDOW WS_POPUP|WS_BORDER|WS_SYSMENU|WS_CAPTION
-#endif
-
-#ifndef WS_OVERLAPPEDWINDOW
-#define WS_OVERLAPPEDWINDOW WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_THICKFRAME|WS_MINIMIZEBOX|WS_MAXIMIZEBOX
-#endif
-
-#ifndef WS_TILED
-#define WS_TILED WS_OVERLAPPED
-#endif
-
-#ifndef WS_TILEDWINDOW
-#define WS_TILEDWINDOW WS_OVERLAPPEDWINDOW
-#endif
-
-#ifndef WS_EX_CAPTIONOKBTN
-#define WS_EX_CAPTIONOKBTN 0x80000000L
-#endif
-
-#ifndef WS_EX_NODRAG
-#define WS_EX_NODRAG 0x40000000L
-#endif
-
-#ifdef __cplusplus
-} // Extern C.
-#endif
-
-#ifdef __cplusplus
-
-
-// As Windows CE lacks some standard functions used in Qt, these got
-// reimplemented. Other projects do this as well. Inline functions are used
-// that there is a central place to disable functions for newer versions if
-// they get available. There are no defines used anymore, because this
-// will break member functions of classes which are called like these
-// functions. Also inline functions are only supported by C++, so just define
-// them for C++, as only 3rd party dependencies are C, this is no issue.
-// The other declarations available in this file are being used per
-// define inside qplatformdefs.h of the corresponding WinCE mkspec.
-
-#define generate_inline_return_func0(funcname, returntype) \
- inline returntype funcname() \
- { \
- return qt_wince_##funcname(); \
- }
-#define generate_inline_return_func1(funcname, returntype, param1) \
- inline returntype funcname(param1 p1) \
- { \
- return qt_wince_##funcname(p1); \
- }
-#define generate_inline_return_func2(funcname, returntype, prependnamespace, param1, param2) \
- inline returntype funcname(param1 p1, param2 p2) \
- { \
- return prependnamespace##funcname(p1, p2); \
- }
-#define generate_inline_return_func3(funcname, returntype, param1, param2, param3) \
- inline returntype funcname(param1 p1, param2 p2, param3 p3) \
- { \
- return qt_wince_##funcname(p1, p2, p3); \
- }
-#define generate_inline_return_func4(funcname, returntype, prependnamespace, param1, param2, param3, param4) \
- inline returntype funcname(param1 p1, param2 p2, param3 p3, param4 p4) \
- { \
- return prependnamespace##funcname(p1, p2, p3, p4); \
- }
-#define generate_inline_return_func5(funcname, returntype, param1, param2, param3, param4, param5) \
- inline returntype funcname(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5) \
- { \
- return qt_wince_##funcname(p1, p2, p3, p4, p5); \
- }
-#define generate_inline_return_func6(funcname, returntype, param1, param2, param3, param4, param5, param6) \
- inline returntype funcname(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6) \
- { \
- return qt_wince_##funcname(p1, p2, p3, p4, p5, p6); \
- }
-#define generate_inline_return_func7(funcname, returntype, param1, param2, param3, param4, param5, param6, param7) \
- inline returntype funcname(param1 p1, param2 p2, param3 p3, param4 p4, param5 p5, param6 p6, param7 p7) \
- { \
- return qt_wince_##funcname(p1, p2, p3, p4, p5, p6, p7); \
- }
-
-typedef unsigned (__stdcall *StartAdressExFunc)(void *);
-typedef void(*StartAdressFunc)(void *);
-typedef int ( __cdecl *CompareFunc ) (const void *, const void *) ;
-
-generate_inline_return_func4(getenv_s, errno_t, qt_fake_, size_t *, char *, size_t, const char *)
-generate_inline_return_func2(_putenv_s, errno_t, qt_fake_, const char *, const char *)
-generate_inline_return_func0(_getpid, int)
-generate_inline_return_func1(time_tToFt, FILETIME, time_t)
-generate_inline_return_func1(ftToTime_t, time_t, FILETIME)
-generate_inline_return_func0(_getdrive, int)
-generate_inline_return_func2(_waccess, int, qt_wince_, const wchar_t *, int)
-generate_inline_return_func3(_wopen, int, const wchar_t *, int, int)
-generate_inline_return_func2(_fdopen, FILE *, qt_wince_, int, const char *)
-generate_inline_return_func2(fdopen, FILE *, qt_wince_, int, const char *)
-generate_inline_return_func1(rewind, void, FILE *)
-generate_inline_return_func0(tmpfile, FILE *)
-generate_inline_return_func2(_rename, int, qt_wince_, const char *, const char *)
-generate_inline_return_func1(_remove, int, const char *)
-generate_inline_return_func1(SetErrorMode, int, int)
-#if _WIN32_WCE < 0x800
-generate_inline_return_func2(_chmod, bool, qt_wince_, const char *, int)
-generate_inline_return_func2(_wchmod, bool, qt_wince_, const wchar_t *, int)
-#endif
-generate_inline_return_func7(CreateFileA, HANDLE, LPCSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE)
-generate_inline_return_func4(SetWindowOrgEx, BOOL, qt_wince_, HDC, int, int, LPPOINT)
-generate_inline_return_func2(calloc, void *, qt_wince_, size_t, size_t)
-generate_inline_return_func0(GetThreadLocale, DWORD)
-generate_inline_return_func3(_beginthread, HANDLE, StartAdressFunc, unsigned, void *)
-generate_inline_return_func6(_beginthreadex, unsigned long, void *, unsigned, StartAdressExFunc, void *, unsigned, unsigned *)
-generate_inline_return_func1(_endthreadex, void, unsigned)
-generate_inline_return_func5(bsearch, void *, const void *, const void *, size_t, size_t, CompareFunc)
-
-#endif //__cplusplus
-
-#endif // Q_OS_WINCE
-#endif // QFUNCTIONS_WINCE_H
diff --git a/src/corelib/kernel/qjni_p.h b/src/corelib/kernel/qjni_p.h
index 79cbe1de72..52abd51dc1 100644
--- a/src/corelib/kernel/qjni_p.h
+++ b/src/corelib/kernel/qjni_p.h
@@ -52,7 +52,7 @@
#define QJNI_P_H
#include <jni.h>
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qsharedpointer.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/kernel/qjnihelpers.cpp b/src/corelib/kernel/qjnihelpers.cpp
index 76f530ab9c..102b835089 100644
--- a/src/corelib/kernel/qjnihelpers.cpp
+++ b/src/corelib/kernel/qjnihelpers.cpp
@@ -357,6 +357,16 @@ jobject QtAndroidPrivate::service()
return g_jService;
}
+jobject QtAndroidPrivate::context()
+{
+ if (g_jActivity)
+ return g_jActivity;
+ if (g_jService)
+ return g_jService;
+
+ return 0;
+}
+
JavaVM *QtAndroidPrivate::javaVM()
{
return g_javaVM;
diff --git a/src/corelib/kernel/qjnihelpers_p.h b/src/corelib/kernel/qjnihelpers_p.h
index 78ad08a09e..43e2f3af20 100644
--- a/src/corelib/kernel/qjnihelpers_p.h
+++ b/src/corelib/kernel/qjnihelpers_p.h
@@ -52,7 +52,7 @@
//
#include <jni.h>
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
#include <functional>
QT_BEGIN_NAMESPACE
@@ -101,6 +101,7 @@ namespace QtAndroidPrivate
Q_CORE_EXPORT jobject activity();
Q_CORE_EXPORT jobject service();
+ Q_CORE_EXPORT jobject context();
Q_CORE_EXPORT JavaVM *javaVM();
Q_CORE_EXPORT jint initJNI(JavaVM *vm, JNIEnv *env);
jobject classLoader();
diff --git a/src/corelib/kernel/qmath.h b/src/corelib/kernel/qmath.h
index c24fc3a0ce..773884047a 100644
--- a/src/corelib/kernel/qmath.h
+++ b/src/corelib/kernel/qmath.h
@@ -45,6 +45,7 @@
#endif
#include <QtCore/qglobal.h>
+#include <QtCore/qalgorithms.h>
#ifndef _USE_MATH_DEFINES
# define _USE_MATH_DEFINES
@@ -241,20 +242,12 @@ Q_DECL_CONSTEXPR inline double qRadiansToDegrees(double radians)
}
-#if defined(Q_CC_GNU)
-// clz instructions exist in at least MIPS, ARM, PowerPC and X86, so we can assume this builtin always maps to an efficient instruction.
+#if defined(QT_HAS_BUILTIN_CLZ)
inline quint32 qNextPowerOfTwo(quint32 v)
{
if (v == 0)
return 1;
- return 2U << (31 ^ __builtin_clz(v));
-}
-
-inline quint64 qNextPowerOfTwo(quint64 v)
-{
- if (v == 0)
- return 1;
- return Q_UINT64_C(2) << (63 ^ __builtin_clzll(v));
+ return 2U << (31 ^ QAlgorithmsPrivate::qt_builtin_clz(v));
}
#else
inline quint32 qNextPowerOfTwo(quint32 v)
@@ -267,7 +260,16 @@ inline quint32 qNextPowerOfTwo(quint32 v)
++v;
return v;
}
+#endif
+#if defined(QT_HAS_BUILTIN_CLZLL)
+inline quint64 qNextPowerOfTwo(quint64 v)
+{
+ if (v == 0)
+ return 1;
+ return Q_UINT64_C(2) << (63 ^ QAlgorithmsPrivate::qt_builtin_clzll(v));
+}
+#else
inline quint64 qNextPowerOfTwo(quint64 v)
{
v |= v >> 1;
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index f4f75e39e6..2e0dd8e5d2 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -2557,9 +2557,19 @@ int QMetaEnum::value(int index) const
*/
bool QMetaEnum::isFlag() const
{
- return mobj && mobj->d.data[handle + 1];
+ return mobj && mobj->d.data[handle + 1] & EnumIsFlag;
}
+/*!
+ \since 5.8
+
+ Returns \c true if this enumerator is declared as a C++11 enum class;
+ otherwise returns false.
+*/
+bool QMetaEnum::isScoped() const
+{
+ return mobj && mobj->d.data[handle + 1] & EnumIsScoped;
+}
/*!
Returns the scope this enumerator was declared in.
@@ -2652,15 +2662,16 @@ int QMetaEnum::keysToValue(const char *keys, bool *ok) const
return -1;
if (ok != 0)
*ok = true;
- QStringList l = QString::fromLatin1(keys).split(QLatin1Char('|'));
- if (l.isEmpty())
+ const QString keysString = QString::fromLatin1(keys);
+ const QVector<QStringRef> splitKeys = keysString.splitRef(QLatin1Char('|'));
+ if (splitKeys.isEmpty())
return 0;
- //#### TODO write proper code, do not use QStringList
+ // ### TODO write proper code: do not allocate memory, so we can go nothrow
int value = 0;
int count = mobj->d.data[handle + 2];
int data = mobj->d.data[handle + 3];
- for (int li = 0; li < l.size(); ++li) {
- QString trimmed = l.at(li).trimmed();
+ for (const QStringRef &untrimmed : splitKeys) {
+ const QStringRef trimmed = untrimmed.trimmed();
QByteArray qualified_key = trimmed.toLatin1();
const char *key = qualified_key.constData();
uint scope = 0;
diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h
index 85ac7e77e4..40b2aa6402 100644
--- a/src/corelib/kernel/qmetaobject.h
+++ b/src/corelib/kernel/qmetaobject.h
@@ -168,19 +168,15 @@ public:
inline bool isValid() const { return mobj != Q_NULLPTR; }
-#ifdef Q_QDOC
- static QMetaMethod fromSignal(PointerToMemberFunction signal);
-#else
- template <typename Func>
- static inline QMetaMethod fromSignal(Func signal)
+ template <typename PointerToMemberFunction>
+ static inline QMetaMethod fromSignal(PointerToMemberFunction signal)
{
- typedef QtPrivate::FunctionPointer<Func> SignalType;
+ typedef QtPrivate::FunctionPointer<PointerToMemberFunction> SignalType;
Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
"No Q_OBJECT in the class with the signal");
return fromSignalImpl(&SignalType::Object::staticMetaObject,
reinterpret_cast<void **>(&signal));
}
-#endif
private:
#if QT_DEPRECATED_SINCE(5,0)
@@ -214,6 +210,7 @@ public:
const char *name() const;
bool isFlag() const;
+ bool isScoped() const;
int keyCount() const;
const char *key(int index) const;
diff --git a/src/corelib/kernel/qmetaobject_moc_p.h b/src/corelib/kernel/qmetaobject_moc_p.h
index 1b24837ec0..ad258acfcd 100644
--- a/src/corelib/kernel/qmetaobject_moc_p.h
+++ b/src/corelib/kernel/qmetaobject_moc_p.h
@@ -52,6 +52,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
QT_BEGIN_NAMESPACE
// This function is shared with moc.cpp. This file should be included where needed.
diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h
index 0790af2bb5..1c540f64c7 100644
--- a/src/corelib/kernel/qmetaobject_p.h
+++ b/src/corelib/kernel/qmetaobject_p.h
@@ -114,6 +114,11 @@ enum MetaDataFlags {
TypeNameIndexMask = 0x7FFFFFFF
};
+enum EnumFlags {
+ EnumIsFlag = 0x1,
+ EnumIsScoped = 0x2
+};
+
extern int qMetaTypeTypeInternal(const char *);
class QArgumentType
@@ -168,6 +173,7 @@ class QMutex;
struct QMetaObjectPrivate
{
+ // revision 7 is Qt 5.0 everything lower is not supported
enum { OutputRevision = 7 }; // Used by moc, qmetaobjectbuilder and qdbus
int revision;
@@ -176,12 +182,9 @@ struct QMetaObjectPrivate
int methodCount, methodData;
int propertyCount, propertyData;
int enumeratorCount, enumeratorData;
- int constructorCount, constructorData; //since revision 2
- int flags; //since revision 3
- int signalCount; //since revision 4
- // revision 5 introduces changes in normalized signatures, no new members
- // revision 6 added qt_static_metacall as a member of each Q_OBJECT and inside QMetaObject itself
- // revision 7 is Qt 5
+ int constructorCount, constructorData;
+ int flags;
+ int signalCount;
static inline const QMetaObjectPrivate *get(const QMetaObject *metaobject)
{ return reinterpret_cast<const QMetaObjectPrivate*>(metaobject->d.data); }
diff --git a/src/corelib/kernel/qmetaobjectbuilder_p.h b/src/corelib/kernel/qmetaobjectbuilder_p.h
index 0934873ad0..144595330d 100644
--- a/src/corelib/kernel/qmetaobjectbuilder_p.h
+++ b/src/corelib/kernel/qmetaobjectbuilder_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qobject.h>
#include <QtCore/qmetaobject.h>
#include <QtCore/qdatastream.h>
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 3ac1f28638..f27fde6b8d 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -870,8 +870,7 @@ const char *QMetaType::typeName(int typeId)
return result;
}
-/*!
- \internal
+/*
Similar to QMetaType::type(), but only looks in the static set of types.
*/
static inline int qMetaTypeStaticType(const char *typeName, int length)
@@ -884,8 +883,7 @@ static inline int qMetaTypeStaticType(const char *typeName, int length)
return types[i].type;
}
-/*!
- \internal
+/*
Similar to QMetaType::type(), but only looks in the custom set of
types, and doesn't lock the mutex.
The extra \a firstInvalidIndex parameter is an easy way to avoid
@@ -1270,6 +1268,7 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
case QMetaType::UnknownType:
case QMetaType::Void:
case QMetaType::VoidStar:
+ case QMetaType::Nullptr:
case QMetaType::QObjectStar:
case QMetaType::QModelIndex:
case QMetaType::QPersistentModelIndex:
@@ -1491,6 +1490,7 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
case QMetaType::UnknownType:
case QMetaType::Void:
case QMetaType::VoidStar:
+ case QMetaType::Nullptr:
case QMetaType::QObjectStar:
case QMetaType::QModelIndex:
case QMetaType::QPersistentModelIndex:
@@ -1840,6 +1840,8 @@ public:
template<typename T>
void delegate(const T *where) { DestructorImpl<T>::Destruct(m_type, const_cast<T*>(where)); }
+ // MSVC2013 and earlier can not const_cast a std::nullptr_t pointer.
+ void delegate(const std::nullptr_t *) {}
void delegate(const void *) {}
void delegate(const QMetaTypeSwitcher::UnknownType*) {}
void delegate(const QMetaTypeSwitcher::NotBuiltinType *where)
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index b68dbacbd3..9abeefa8d8 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -86,6 +86,7 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId();
F(UChar, 37, uchar) \
F(Float, 38, float) \
F(SChar, 40, signed char) \
+ F(Nullptr, 51, std::nullptr_t) \
#define QT_FOR_EACH_STATIC_PRIMITIVE_POINTER(F)\
F(VoidStar, 31, void*) \
@@ -414,7 +415,7 @@ public:
QT_FOR_EACH_STATIC_TYPE(QT_DEFINE_METATYPE_ID)
FirstCoreType = Bool,
- LastCoreType = QPersistentModelIndex,
+ LastCoreType = Nullptr,
FirstGuiType = QFont,
LastGuiType = QPolygonF,
FirstWidgetsType = QSizePolicy,
@@ -506,11 +507,8 @@ public:
static int registerTypedef(const char *typeName, int aliasId);
static int registerNormalizedTypedef(const QT_PREPEND_NAMESPACE(QByteArray) &normalizedTypeName, int aliasId);
static int type(const char *typeName);
-#ifndef Q_QDOC
+
static int type(const QT_PREPEND_NAMESPACE(QByteArray) &typeName);
-#else
- static int type(const QByteArray &typeName);
-#endif
static const char *typeName(int type);
static int sizeOf(int type);
static TypeFlags typeFlags(int type);
@@ -600,8 +598,11 @@ public:
}
#ifdef Q_QDOC
+ template<typename MemberFunction, int>
static bool registerConverter(MemberFunction function);
+ template<typename MemberFunctionOk, char>
static bool registerConverter(MemberFunctionOk function);
+ template<typename UnaryFunction>
static bool registerConverter(UnaryFunction function);
#else
// member function as in "QString QFont::toString() const"
@@ -1857,6 +1858,7 @@ inline int qRegisterMetaTypeStreamOperators()
} QT_END_NAMESPACE \
/**/
+#ifndef Q_MOC_RUN
#define Q_DECLARE_METATYPE(TYPE) Q_DECLARE_METATYPE_IMPL(TYPE)
#define Q_DECLARE_METATYPE_IMPL(TYPE) \
QT_BEGIN_NAMESPACE \
@@ -1876,7 +1878,7 @@ inline int qRegisterMetaTypeStreamOperators()
} \
}; \
QT_END_NAMESPACE
-
+#endif // Q_MOC_RUN
#define Q_DECLARE_BUILTIN_METATYPE(TYPE, METATYPEID, NAME) \
QT_BEGIN_NAMESPACE \
@@ -1899,7 +1901,9 @@ QT_FOR_EACH_STATIC_WIDGETS_CLASS(QT_FORWARD_DECLARE_STATIC_TYPES_ITER)
typedef QList<QVariant> QVariantList;
typedef QMap<QString, QVariant> QVariantMap;
typedef QHash<QString, QVariant> QVariantHash;
+#ifndef Q_QDOC
typedef QList<QByteArray> QByteArrayList;
+#endif
#define Q_DECLARE_METATYPE_TEMPLATE_1ARG(SINGLE_ARG_TEMPLATE) \
QT_BEGIN_NAMESPACE \
diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h
index 445e912cf7..dd0bce2645 100644
--- a/src/corelib/kernel/qmetatype_p.h
+++ b/src/corelib/kernel/qmetatype_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qmetatype.h"
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index c235260f1b..26c3ce2443 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -4471,6 +4471,19 @@ QDebug operator<<(QDebug dbg, const QObject *o)
*/
/*!
+ \macro QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
+ \relates QObject
+ \since 5.8
+
+ Defining this macro will disable narrowing and floating-point-to-integral
+ conversions between the arguments carried by a signal and the arguments
+ accepted by a slot, when the signal and the slot are connected using the
+ PMF-based syntax.
+
+ \sa QObject::connect
+*/
+
+/*!
\typedef QObjectList
\relates QObject
@@ -4776,11 +4789,12 @@ bool QObject::disconnect(const QMetaObject::Connection &connection)
c->isSlotObject = false;
}
+ c->sender->disconnectNotify(QMetaObjectPrivate::signal(c->sender->metaObject(),
+ c->signal_index));
+
const_cast<QMetaObject::Connection &>(connection).d_ptr = 0;
c->deref(); // has been removed from the QMetaObject::Connection object
- // disconnectNotify() not called (the signal index is unknown).
-
return true;
}
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index c06f702b30..3cec9802dc 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -210,8 +210,11 @@ public:
const char *member, Qt::ConnectionType type = Qt::AutoConnection) const;
#ifdef Q_QDOC
+ template<typename PointerToMemberFunction>
static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type = Qt::AutoConnection);
+ template<typename PointerToMemberFunction, typename Functor>
static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor);
+ template<typename PointerToMemberFunction, typename Functor>
static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type = Qt::AutoConnection);
#else
//Connect a signal to a pointer to qobject member function
@@ -337,6 +340,7 @@ public:
static bool disconnect(const QMetaObject::Connection &);
#ifdef Q_QDOC
+ template<typename PointerToMemberFunction>
static bool disconnect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method);
#else
template <typename Func1, typename Func2>
diff --git a/src/corelib/kernel/qobject_impl.h b/src/corelib/kernel/qobject_impl.h
index aa68c9c1ad..d7ae63a98c 100644
--- a/src/corelib/kernel/qobject_impl.h
+++ b/src/corelib/kernel/qobject_impl.h
@@ -97,7 +97,7 @@ namespace QtPrivate {
inline void destroyIfLastRef() Q_DECL_NOTHROW
{ if (!m_ref.deref()) m_impl(Destroy, this, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR); }
- inline bool compare(void **a) { bool ret; m_impl(Compare, this, Q_NULLPTR, a, &ret); return ret; }
+ inline bool compare(void **a) { bool ret = false; m_impl(Compare, this, Q_NULLPTR, a, &ret); return ret; }
inline void call(QObject *r, void **a) { m_impl(Call, this, r, a, Q_NULLPTR); }
protected:
~QSlotObjectBase() {}
@@ -143,10 +143,9 @@ namespace QtPrivate {
case Call:
FuncType::template call<Args, R>(static_cast<QStaticSlotObject*>(this_)->function, r, a);
break;
- case Compare:
- *ret = false; // not implemented
- break;
- case NumOperations: ;
+ case Compare: // not implemented
+ case NumOperations:
+ Q_UNUSED(ret);
}
}
public:
@@ -168,10 +167,9 @@ namespace QtPrivate {
case Call:
FuncType::template call<Args, R>(static_cast<QFunctorSlotObject*>(this_)->function, r, a);
break;
- case Compare:
- *ret = false; // not implemented
- break;
- case NumOperations: ;
+ case Compare: // not implemented
+ case NumOperations:
+ Q_UNUSED(ret);
}
}
public:
diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h
index 4383ece245..a7d7ef0889 100644
--- a/src/corelib/kernel/qobject_p.h
+++ b/src/corelib/kernel/qobject_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qobject.h"
#include "QtCore/qpointer.h"
#include "QtCore/qsharedpointer.h"
diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h
index 5eae70ecc5..e94e713e1f 100644
--- a/src/corelib/kernel/qobjectdefs_impl.h
+++ b/src/corelib/kernel/qobjectdefs_impl.h
@@ -50,6 +50,8 @@
#pragma qt_sync_stop_processing
#endif
+#include <type_traits>
+
QT_BEGIN_NAMESPACE
@@ -194,6 +196,46 @@ namespace QtPrivate {
};
/*
+ Logic that checks if the underlying type of an enum is signed or not.
+ Needs an external, explicit check that E is indeed an enum. Works
+ around the fact that it's undefined behavior to instantiate
+ std::underlying_type on non-enums (cf. §20.13.7.6 [meta.trans.other]).
+ */
+ template<typename E, typename Enable = void>
+ struct IsEnumUnderlyingTypeSigned : std::false_type
+ {
+ };
+
+ template<typename E>
+ struct IsEnumUnderlyingTypeSigned<E, typename std::enable_if<std::is_enum<E>::value>::type>
+ : std::integral_constant<bool, std::is_signed<typename std::underlying_type<E>::type>::value>
+ {
+ };
+
+ /*
+ Logic that checks if the argument of the slot does not narrow the
+ argument of the signal when used in list initialization. Cf. §8.5.4.7
+ [dcl.init.list] for the definition of narrowing.
+ For incomplete From/To types, there's no narrowing.
+ */
+ template<typename From, typename To, typename Enable = void>
+ struct AreArgumentsNarrowedBase : std::false_type
+ {
+ };
+
+ template<typename From, typename To>
+ struct AreArgumentsNarrowedBase<From, To, typename std::enable_if<sizeof(From) && sizeof(To)>::type>
+ : std::integral_constant<bool,
+ (std::is_floating_point<From>::value && std::is_integral<To>::value) ||
+ (std::is_floating_point<From>::value && std::is_floating_point<To>::value && sizeof(From) > sizeof(To)) ||
+ ((std::is_integral<From>::value || std::is_enum<From>::value) && std::is_floating_point<To>::value) ||
+ (std::is_integral<From>::value && std::is_integral<To>::value && (sizeof(From) > sizeof(To) || std::is_signed<From>::value != std::is_signed<To>::value)) ||
+ (std::is_enum<From>::value && std::is_integral<To>::value && (sizeof(From) > sizeof(To) || IsEnumUnderlyingTypeSigned<From>::value != std::is_signed<To>::value))
+ >
+ {
+ };
+
+ /*
Logic that check if the arguments of the slot matches the argument of the signal.
To be used like this:
Q_STATIC_ASSERT(CheckCompatibleArguments<FunctionPointer<Signal>::Arguments, FunctionPointer<Slot>::Arguments>::value)
@@ -203,6 +245,10 @@ namespace QtPrivate {
static char test(...);
static const typename RemoveRef<A1>::Type &dummy();
enum { value = sizeof(test(dummy())) == sizeof(int) };
+#ifdef QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
+ struct AreArgumentsNarrowed : AreArgumentsNarrowedBase<typename RemoveRef<A1>::Type, typename RemoveRef<A2>::Type> {};
+ Q_STATIC_ASSERT_X(!AreArgumentsNarrowed::value, "Signal and slot arguments are not compatible (narrowing)");
+#endif
};
template<typename A1, typename A2> struct AreArgumentsCompatible<A1, A2&> { enum { value = false }; };
template<typename A> struct AreArgumentsCompatible<A&, A&> { enum { value = true }; };
diff --git a/src/corelib/kernel/qppsattribute_p.h b/src/corelib/kernel/qppsattribute_p.h
index 1d9cc4484c..035756e002 100644
--- a/src/corelib/kernel/qppsattribute_p.h
+++ b/src/corelib/kernel/qppsattribute_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QList>
#include <QMap>
#include <QSharedDataPointer>
diff --git a/src/corelib/kernel/qppsobject.cpp b/src/corelib/kernel/qppsobject.cpp
index 30498a380d..dd01d48cc0 100644
--- a/src/corelib/kernel/qppsobject.cpp
+++ b/src/corelib/kernel/qppsobject.cpp
@@ -397,12 +397,12 @@ QByteArray QPpsObjectPrivate::encode(const QVariantMap &ppsData, bool *ok)
void QPpsObjectPrivate::encodeData(pps_encoder_t *encoder, const char *name, const QVariant &data,
bool *ok)
{
- QString errorFunction;
+ const char *errorFunction;
pps_encoder_error_t error = PPS_ENCODER_OK;
switch (data.type()) {
case QVariant::Bool:
error = pps_encoder_add_bool(encoder, name, data.toBool());
- errorFunction = QStringLiteral("pps_encoder_add_bool");
+ errorFunction = "pps_encoder_add_bool";
break;
// We want to support encoding uint even though libpps doesn't support it directly.
// We can't encode uint as an int since that will lose precision (e.g. 2^31+1 can't be
@@ -411,41 +411,41 @@ void QPpsObjectPrivate::encodeData(pps_encoder_t *encoder, const char *name, con
case QVariant::UInt:
case QVariant::Double:
error = pps_encoder_add_double(encoder, name, data.toDouble());
- errorFunction = QStringLiteral("pps_encoder_add_double");
+ errorFunction = "pps_encoder_add_double";
break;
case QVariant::Int:
error = pps_encoder_add_int(encoder, name, data.toInt());
- errorFunction = QStringLiteral("pps_encoder_add_int");
+ errorFunction = "pps_encoder_add_int";
break;
case QVariant::LongLong:
error = pps_encoder_add_int64(encoder, name, data.toLongLong());
- errorFunction = QStringLiteral("pps_encoder_add_int64");
+ errorFunction = "pps_encoder_add_int64";
break;
case QVariant::String:
error = pps_encoder_add_string(encoder, name, data.toString().toUtf8().constData());
- errorFunction = QStringLiteral("pps_encoder_add_string");
+ errorFunction = "pps_encoder_add_string";
break;
case QVariant::List:
error = pps_encoder_start_array(encoder, name);
- errorFunction = QStringLiteral("pps_encoder_start_array");
+ errorFunction = "pps_encoder_start_array";
if (error == PPS_ENCODER_OK) {
encodeArray(encoder, data.toList(), ok);
error = pps_encoder_end_array(encoder);
- errorFunction = QStringLiteral("pps_encoder_end_array");
+ errorFunction = "pps_encoder_end_array";
}
break;
case QVariant::Map:
error = pps_encoder_start_object(encoder, name);
- errorFunction = QStringLiteral("pps_encoder_start_object");
+ errorFunction = "pps_encoder_start_object";
if (error == PPS_ENCODER_OK) {
encodeObject(encoder, data.toMap(), ok);
error = pps_encoder_end_object(encoder);
- errorFunction = QStringLiteral("pps_encoder_end_object");
+ errorFunction = "pps_encoder_end_object";
}
break;
case QVariant::Invalid:
error = pps_encoder_add_null(encoder, name);
- errorFunction = QStringLiteral("pps_encoder_add_null");
+ errorFunction = "pps_encoder_add_null";
break;
default:
qWarning("QPpsObjectPrivate::encodeData: the type of the parameter data is invalid");
@@ -454,7 +454,7 @@ void QPpsObjectPrivate::encodeData(pps_encoder_t *encoder, const char *name, con
}
if (error != PPS_ENCODER_OK) {
- qWarning() << "QPpsObjectPrivate::encodeData: " << errorFunction << " failed";
+ qWarning("QPpsObjectPrivate::encodeData: %s failed", errorFunction);
*ok = false;
} else {
*ok = true;
diff --git a/src/corelib/kernel/qsharedmemory_win.cpp b/src/corelib/kernel/qsharedmemory_win.cpp
index e998b938c7..07d4930332 100644
--- a/src/corelib/kernel/qsharedmemory_win.cpp
+++ b/src/corelib/kernel/qsharedmemory_win.cpp
@@ -64,8 +64,8 @@ void QSharedMemoryPrivate::setErrorString(QLatin1String function)
errorString = QSharedMemory::tr("%1: already exists").arg(function);
break;
case ERROR_FILE_NOT_FOUND:
-#if defined(Q_OS_WINCE) || (defined(Q_OS_WINRT) && _MSC_VER < 1900)
- // This happens on CE only if no file is present as CreateFileMappingW
+#if defined(Q_OS_WINRT) && _MSC_VER < 1900
+ // This happens on WinRT only if no file is present as CreateFileMappingW
// bails out with this error code
case ERROR_INVALID_PARAMETER:
#endif
@@ -112,10 +112,6 @@ HANDLE QSharedMemoryPrivate::handle()
#else
hand = CreateFileMappingFromApp(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, (PCWSTR)nativeKey.utf16());
#endif
-#elif defined(Q_OS_WINCE)
- // This works for opening a mapping too, but always opens it with read/write access in
- // attach as it seems.
- hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, 0, (wchar_t*)nativeKey.utf16());
#else
hand = OpenFileMapping(FILE_MAP_ALL_ACCESS, false, (wchar_t*)nativeKey.utf16());
#endif
diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp
index 12fd5404da..f38daec4f8 100644
--- a/src/corelib/kernel/qsystemerror.cpp
+++ b/src/corelib/kernel/qsystemerror.cpp
@@ -39,15 +39,9 @@
#include <qglobal.h>
#include "qsystemerror_p.h"
-#if !defined(Q_OS_WINCE)
-# include <errno.h>
-# if defined(Q_CC_MSVC)
-# include <crtdbg.h>
-# endif
-#else
-# if (_WIN32_WCE >= 0x700)
-# include <errno.h>
-# endif
+#include <errno.h>
+#if defined(Q_CC_MSVC)
+# include <crtdbg.h>
#endif
#ifdef Q_OS_WIN
# include <qt_windows.h>
@@ -131,16 +125,12 @@ static QString standardLibraryErrorString(int errorCode)
s = QT_TRANSLATE_NOOP("QIODevice", "No space left on device");
break;
default: {
- #ifdef Q_OS_WINCE
- ret = windowsErrorString(errorCode);
- #else
- #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX)
+ #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX)
QByteArray buf(1024, '\0');
ret = fromstrerror_helper(strerror_r(errorCode, buf.data(), buf.size()), buf);
- #else
+ #else
ret = QString::fromLocal8Bit(strerror(errorCode));
- #endif
- #endif
+ #endif
break; }
}
if (s) {
diff --git a/src/corelib/kernel/qsystemerror_p.h b/src/corelib/kernel/qsystemerror_p.h
index c3d8118711..440b763149 100644
--- a/src/corelib/kernel/qsystemerror_p.h
+++ b/src/corelib/kernel/qsystemerror_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <qstring.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/kernel/qsystemsemaphore_p.h b/src/corelib/kernel/qsystemsemaphore_p.h
index 26647db2e1..3b55d80276 100644
--- a/src/corelib/kernel/qsystemsemaphore_p.h
+++ b/src/corelib/kernel/qsystemsemaphore_p.h
@@ -56,9 +56,7 @@
#ifndef QT_NO_SYSTEMSEMAPHORE
#include "qsharedmemory_p.h"
-#ifndef Q_OS_WINCE
-# include <sys/types.h>
-#endif
+#include <sys/types.h>
#ifdef QT_POSIX_IPC
# include <semaphore.h>
#endif
diff --git a/src/corelib/kernel/qsystemsemaphore_posix.cpp b/src/corelib/kernel/qsystemsemaphore_posix.cpp
index 6137239467..9fbf5779b8 100644
--- a/src/corelib/kernel/qsystemsemaphore_posix.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_posix.cpp
@@ -147,7 +147,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
if (::sem_post(semaphore) == -1) {
setErrorString(QLatin1String("QSystemSemaphore::modifySemaphore (sem_post)"));
#if defined QSYSTEMSEMAPHORE_DEBUG
- qDebug() << QLatin1String("QSystemSemaphore::modify sem_post failed") << count << errno;
+ qDebug("QSystemSemaphore::modify sem_post failed %d %d", count, errno);
#endif
// rollback changes to preserve the SysV semaphore behavior
for ( ; cnt < count; ++cnt) {
@@ -169,7 +169,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
}
setErrorString(QLatin1String("QSystemSemaphore::modifySemaphore (sem_wait)"));
#if defined QSYSTEMSEMAPHORE_DEBUG
- qDebug() << QLatin1String("QSystemSemaphore::modify sem_wait failed") << count << errno;
+ qDebug("QSystemSemaphore::modify sem_wait failed %d %d", count, errno);
#endif
return false;
}
diff --git a/src/corelib/kernel/qsystemsemaphore_systemv.cpp b/src/corelib/kernel/qsystemsemaphore_systemv.cpp
index f4fdfa5f58..1967899a58 100644
--- a/src/corelib/kernel/qsystemsemaphore_systemv.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_systemv.cpp
@@ -187,7 +187,8 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
}
setErrorString(QLatin1String("QSystemSemaphore::modifySemaphore"));
#if defined QSYSTEMSEMAPHORE_DEBUG
- qDebug() << QLatin1String("QSystemSemaphore::modify failed") << count << semctl(semaphore, 0, GETVAL) << errno << EIDRM << EINVAL;
+ qDebug("QSystemSemaphore::modify failed %d %d %d %d %d",
+ count, int(semctl(semaphore, 0, GETVAL)), int(errno), int(EIDRM), int(EINVAL);
#endif
return false;
}
diff --git a/src/corelib/kernel/qsystemsemaphore_win.cpp b/src/corelib/kernel/qsystemsemaphore_win.cpp
index 236e346afe..3395f5641e 100644
--- a/src/corelib/kernel/qsystemsemaphore_win.cpp
+++ b/src/corelib/kernel/qsystemsemaphore_win.cpp
@@ -121,11 +121,7 @@ bool QSystemSemaphorePrivate::modifySemaphore(int count)
return false;
}
} else {
-#if !defined(Q_OS_WINCE)
if (WAIT_OBJECT_0 != WaitForSingleObjectEx(semaphore, INFINITE, FALSE)) {
-#else
- if (WAIT_OBJECT_0 != WaitForSingleObject(semaphore, INFINITE)) {
-#endif
setErrorString(QLatin1String("QSystemSemaphore::modifySemaphore"));
#if defined QSYSTEMSEMAPHORE_DEBUG
qDebug("QSystemSemaphore::modifySemaphore WaitForSingleObject failed");
diff --git a/src/corelib/kernel/qtimer.cpp b/src/corelib/kernel/qtimer.cpp
index 80accc0cb8..8ba494ec3d 100644
--- a/src/corelib/kernel/qtimer.cpp
+++ b/src/corelib/kernel/qtimer.cpp
@@ -533,6 +533,78 @@ void QTimer::singleShot(int msec, Qt::TimerType timerType, const QObject *receiv
*/
/*!
+ \fn void QTimer::singleShot(std::chrono::duration<Rep, Period> value, const QObject *receiver, const char *member)
+ \since 5.8
+ \overload
+ \reentrant
+
+ This static function calls a slot after a given time interval.
+
+ It is very convenient to use this function because you do not need
+ to bother with a \l{QObject::timerEvent()}{timerEvent} or
+ create a local QTimer object.
+
+ The \a receiver is the receiving object and the \a member is the slot. The
+ time interval is given in the duration object \a value.
+
+ \sa start()
+*/
+
+/*!
+ \fn void QTimer::singleShot(std::chrono::duration<Rep, Period> value, Qt::TimerType timerType, const QObject *receiver, const char *member)
+ \since 5.8
+ \overload
+ \reentrant
+
+ This static function calls a slot after a given time interval.
+
+ It is very convenient to use this function because you do not need
+ to bother with a \l{QObject::timerEvent()}{timerEvent} or
+ create a local QTimer object.
+
+ The \a receiver is the receiving object and the \a member is the slot. The
+ time interval is given in the duration object \a value. The \a timerType affects the
+ accuracy of the timer.
+
+ \sa start()
+*/
+
+/*!
+ \fn void QTimer::start(std::chrono::duration<Rep, Period> value)
+ \since 5.8
+ \overload
+
+ Starts or restarts the timer with a timeout of duration \a value.
+
+ If the timer is already running, it will be
+ \l{QTimer::stop()}{stopped} and restarted.
+
+ If \l singleShot is true, the timer will be activated only once.
+*/
+
+/*!
+ \fn std::chrono::milliseconds QTimer::intervalAsDuration() const
+ \since 5.8
+
+ Returns the interval of this timer as a \c std::chrono::milliseconds object.
+
+ \sa interval
+*/
+
+/*!
+ \fn std::chrono::milliseconds QTimer::remainingTimeAsDuration() const
+ \since 5.8
+
+ Returns the time remaining in this timer object as a \c
+ std::chrono::milliseconds object. If this timer is due or overdue, the
+ returned value is \c std::chrono::milliseconds::zero(). If the remaining
+ time could not be found or the timer is not active, this function returns a
+ negative duration.
+
+ \sa remainingTime()
+*/
+
+/*!
\property QTimer::singleShot
\brief whether the timer is a single-shot timer
diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h
index dd52d52a1c..1567fe760c 100644
--- a/src/corelib/kernel/qtimer.h
+++ b/src/corelib/kernel/qtimer.h
@@ -47,6 +47,10 @@
#include <QtCore/qbasictimer.h> // conceptual inheritance
#include <QtCore/qobject.h>
+#if QT_HAS_INCLUDE(<chrono>)
+# include <chrono>
+#endif
+
QT_BEGIN_NAMESPACE
@@ -80,21 +84,27 @@ public:
static void singleShot(int msec, Qt::TimerType timerType, const QObject *receiver, const char *member);
#ifdef Q_QDOC
+ template<typename PointerToMemberFunction>
static void singleShot(int msec, const QObject *receiver, PointerToMemberFunction method);
+ template<typename PointerToMemberFunction>
static void singleShot(int msec, Qt::TimerType timerType, const QObject *receiver, PointerToMemberFunction method);
+ template<typename Functor>
static void singleShot(int msec, Functor functor);
+ template<typename Functor>
static void singleShot(int msec, Qt::TimerType timerType, Functor functor);
+ template<typename Functor, int>
static void singleShot(int msec, const QObject *context, Functor functor);
+ template<typename Functor, int>
static void singleShot(int msec, Qt::TimerType timerType, const QObject *context, Functor functor);
#else
// singleShot to a QObject slot
- template <typename Func1>
- static inline void singleShot(int msec, const typename QtPrivate::FunctionPointer<Func1>::Object *receiver, Func1 slot)
+ template <typename Duration, typename Func1>
+ static inline void singleShot(Duration interval, const typename QtPrivate::FunctionPointer<Func1>::Object *receiver, Func1 slot)
{
- singleShot(msec, msec >= 2000 ? Qt::CoarseTimer : Qt::PreciseTimer, receiver, slot);
+ singleShot(interval, defaultTypeFor(interval), receiver, slot);
}
- template <typename Func1>
- static inline void singleShot(int msec, Qt::TimerType timerType, const typename QtPrivate::FunctionPointer<Func1>::Object *receiver,
+ template <typename Duration, typename Func1>
+ static inline void singleShot(Duration interval, Qt::TimerType timerType, const typename QtPrivate::FunctionPointer<Func1>::Object *receiver,
Func1 slot)
{
typedef QtPrivate::FunctionPointer<Func1> SlotType;
@@ -103,42 +113,42 @@ public:
Q_STATIC_ASSERT_X(int(SlotType::ArgumentCount) == 0,
"The slot must not have any arguments.");
- singleShotImpl(msec, timerType, receiver,
+ singleShotImpl(interval, timerType, receiver,
new QtPrivate::QSlotObject<Func1, typename SlotType::Arguments, void>(slot));
}
// singleShot to a functor or function pointer (without context)
- template <typename Func1>
+ template <typename Duration, typename Func1>
static inline typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
!QtPrivate::is_same<const char*, Func1>::value, void>::Type
- singleShot(int msec, Func1 slot)
+ singleShot(Duration interval, Func1 slot)
{
- singleShot(msec, msec >= 2000 ? Qt::CoarseTimer : Qt::PreciseTimer, Q_NULLPTR, slot);
+ singleShot(interval, defaultTypeFor(interval), nullptr, slot);
}
- template <typename Func1>
+ template <typename Duration, typename Func1>
static inline typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
!QtPrivate::is_same<const char*, Func1>::value, void>::Type
- singleShot(int msec, Qt::TimerType timerType, Func1 slot)
+ singleShot(Duration interval, Qt::TimerType timerType, Func1 slot)
{
- singleShot(msec, timerType, Q_NULLPTR, slot);
+ singleShot(interval, timerType, nullptr, slot);
}
// singleShot to a functor or function pointer (with context)
- template <typename Func1>
+ template <typename Duration, typename Func1>
static inline typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
!QtPrivate::is_same<const char*, Func1>::value, void>::Type
- singleShot(int msec, QObject *context, Func1 slot)
+ singleShot(Duration interval, QObject *context, Func1 slot)
{
- singleShot(msec, msec >= 2000 ? Qt::CoarseTimer : Qt::PreciseTimer, context, slot);
+ singleShot(interval, defaultTypeFor(interval), context, slot);
}
- template <typename Func1>
+ template <typename Duration, typename Func1>
static inline typename QtPrivate::QEnableIf<!QtPrivate::FunctionPointer<Func1>::IsPointerToMemberFunction &&
!QtPrivate::is_same<const char*, Func1>::value, void>::Type
- singleShot(int msec, Qt::TimerType timerType, QObject *context, Func1 slot)
+ singleShot(Duration interval, Qt::TimerType timerType, QObject *context, Func1 slot)
{
//compilation error if the slot has arguments.
typedef QtPrivate::FunctionPointer<Func1> SlotType;
Q_STATIC_ASSERT_X(int(SlotType::ArgumentCount) <= 0, "The slot must not have any arguments.");
- singleShotImpl(msec, timerType, context,
+ singleShotImpl(interval, timerType, context,
new QtPrivate::QFunctorSlotObject<Func1, 0,
typename QtPrivate::List_Left<void, 0>::Value, void>(slot));
}
@@ -153,6 +163,43 @@ public Q_SLOTS:
Q_SIGNALS:
void timeout(QPrivateSignal);
+public:
+#if QT_HAS_INCLUDE(<chrono>) || defined(Q_QDOC)
+ template <class Rep, class Period>
+ void setInterval(std::chrono::duration<Rep, Period> value)
+ {
+ setInterval(std::chrono::duration_cast<std::chrono::milliseconds>(value).count());
+ }
+
+ std::chrono::milliseconds intervalAsDuration() const
+ {
+ return std::chrono::milliseconds(interval());
+ }
+
+ std::chrono::milliseconds remainingTimeAsDuration() const
+ {
+ return std::chrono::milliseconds(remainingTime());
+ }
+
+ template <class Rep, class Period>
+ static void singleShot(std::chrono::duration<Rep, Period> value, const QObject *receiver, const char *member)
+ {
+ singleShot(int(std::chrono::duration_cast<std::chrono::milliseconds>(value).count()), receiver, member);
+ }
+
+ template <class Rep, class Period>
+ static void singleShot(std::chrono::duration<Rep, Period> value, Qt::TimerType timerType, const QObject *receiver, const char *member)
+ {
+ singleShot(int(std::chrono::duration_cast<std::chrono::milliseconds>(value).count()), timerType, receiver, member);
+ }
+
+ template <class Rep, class Period>
+ void start(std::chrono::duration<Rep, Period> value)
+ {
+ start(int(std::chrono::duration_cast<std::chrono::milliseconds>(value).count()));
+ }
+#endif
+
protected:
void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE;
@@ -162,9 +209,25 @@ private:
inline int startTimer(int){ return -1;}
inline void killTimer(int){}
+ static Q_DECL_CONSTEXPR Qt::TimerType defaultTypeFor(int msecs) Q_DECL_NOTHROW
+ { return msecs >= 2000 ? Qt::CoarseTimer : Qt::PreciseTimer; }
static void singleShotImpl(int msec, Qt::TimerType timerType,
const QObject *receiver, QtPrivate::QSlotObjectBase *slotObj);
+#if QT_HAS_INCLUDE(<chrono>)
+ template <class Rep, class Period>
+ static Qt::TimerType defaultTypeFor(std::chrono::duration<Rep, Period> interval)
+ { return defaultTypeFor(int(std::chrono::duration_cast<std::chrono::milliseconds>(interval).count())); }
+
+ template <class Rep, class Period>
+ static void singleShotImpl(std::chrono::duration<Rep, Period> interval, Qt::TimerType timerType,
+ const QObject *receiver, QtPrivate::QSlotObjectBase *slotObj)
+ {
+ singleShotImpl(int(std::chrono::duration_cast<std::chrono::milliseconds>(interval).count()),
+ timerType, receiver, slotObj);
+ }
+#endif
+
int id, inter, del;
uint single : 1;
uint nulltimer : 1;
diff --git a/src/corelib/kernel/qtimerinfo_unix_p.h b/src/corelib/kernel/qtimerinfo_unix_p.h
index 2de8a4681f..7bd6f16ea1 100644
--- a/src/corelib/kernel/qtimerinfo_unix_p.h
+++ b/src/corelib/kernel/qtimerinfo_unix_p.h
@@ -51,6 +51,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
// #define QTIMERINFO_DEBUG
#include "qabstracteventdispatcher.h"
diff --git a/src/corelib/kernel/qtranslator.cpp b/src/corelib/kernel/qtranslator.cpp
index 2c813b5156..e016773bde 100644
--- a/src/corelib/kernel/qtranslator.cpp
+++ b/src/corelib/kernel/qtranslator.cpp
@@ -487,7 +487,7 @@ bool QTranslator::load(const QString & filename, const QString & directory,
}
const QString suffixOrDotQM = suffix.isNull() ? dotQmLiteral() : suffix;
- QString fname = filename;
+ QStringRef fname(&filename);
QString realname;
QString delims;
delims = search_delimiters.isNull() ? QStringLiteral("_.") : search_delimiters;
diff --git a/src/corelib/kernel/qtranslator_p.h b/src/corelib/kernel/qtranslator_p.h
index 21de8e2a8c..e148637ac6 100644
--- a/src/corelib/kernel/qtranslator_p.h
+++ b/src/corelib/kernel/qtranslator_p.h
@@ -51,6 +51,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
enum {
Q_EQ = 0x01,
Q_LT = 0x02,
diff --git a/src/corelib/mimetypes/qmimeglobpattern.cpp b/src/corelib/mimetypes/qmimeglobpattern.cpp
index 94be5385f3..568f9bf4de 100644
--- a/src/corelib/mimetypes/qmimeglobpattern.cpp
+++ b/src/corelib/mimetypes/qmimeglobpattern.cpp
@@ -124,7 +124,7 @@ bool QMimeGlobPattern::matchFileName(const QString &inputFilename) const
if (starCount == 1 && m_pattern.at(pattern_len - 1) == QLatin1Char('*')) {
if (len + 1 < pattern_len) return false;
if (m_pattern.at(0) == QLatin1Char('*'))
- return filename.indexOf(m_pattern.mid(1, pattern_len - 2)) != -1;
+ return filename.indexOf(m_pattern.midRef(1, pattern_len - 2)) != -1;
const QChar *c1 = m_pattern.unicode();
const QChar *c2 = filename.unicode();
diff --git a/src/corelib/mimetypes/qmimeglobpattern_p.h b/src/corelib/mimetypes/qmimeglobpattern_p.h
index e4c74ff7fa..3e4fdb50f6 100644
--- a/src/corelib/mimetypes/qmimeglobpattern_p.h
+++ b/src/corelib/mimetypes/qmimeglobpattern_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
#ifndef QT_NO_MIMETYPE
diff --git a/src/corelib/mimetypes/qmimemagicrule_p.h b/src/corelib/mimetypes/qmimemagicrule_p.h
index 26f93d96cc..0c6c1dbcd7 100644
--- a/src/corelib/mimetypes/qmimemagicrule_p.h
+++ b/src/corelib/mimetypes/qmimemagicrule_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
#ifndef QT_NO_MIMETYPE
diff --git a/src/corelib/mimetypes/qmimeprovider.cpp b/src/corelib/mimetypes/qmimeprovider.cpp
index dc6eb05d9a..e72f9a30d0 100644
--- a/src/corelib/mimetypes/qmimeprovider.cpp
+++ b/src/corelib/mimetypes/qmimeprovider.cpp
@@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE
static QString fallbackParent(const QString &mimeTypeName)
{
- const QString myGroup = mimeTypeName.left(mimeTypeName.indexOf(QLatin1Char('/')));
+ const QStringRef myGroup = mimeTypeName.leftRef(mimeTypeName.indexOf(QLatin1Char('/')));
// All text/* types are subclasses of text/plain.
if (myGroup == QLatin1String("text") && mimeTypeName != QLatin1String("text/plain"))
return QLatin1String("text/plain");
@@ -363,7 +363,8 @@ bool QMimeBinaryProvider::matchSuffixTree(QMimeGlobMatchResult &result, QMimeBin
const int weight = flagsAndWeight & 0xff;
const bool caseSensitive = flagsAndWeight & 0x100;
if (caseSensitiveCheck || !caseSensitive) {
- result.addMatch(QLatin1String(mimeType), weight, QLatin1Char('*') + fileName.mid(charPos+1));
+ result.addMatch(QLatin1String(mimeType), weight,
+ QLatin1Char('*') + fileName.midRef(charPos + 1));
success = true;
}
}
diff --git a/src/corelib/mimetypes/qmimetype.cpp b/src/corelib/mimetypes/qmimetype.cpp
index 80b6a76ecc..5d18b67e8d 100644
--- a/src/corelib/mimetypes/qmimetype.cpp
+++ b/src/corelib/mimetypes/qmimetype.cpp
@@ -286,11 +286,12 @@ QString QMimeType::genericIconName() const
// then the mimetype is used to generate the generic icon by using the top-level
// media type (e.g. "video" in "video/ogg") and appending "-x-generic"
// (i.e. "video-x-generic" in the previous example).
- QString group = name();
- const int slashindex = group.indexOf(QLatin1Char('/'));
+ const QString group = name();
+ QStringRef groupRef(&group);
+ const int slashindex = groupRef.indexOf(QLatin1Char('/'));
if (slashindex != -1)
- group = group.left(slashindex);
- return group + QLatin1String("-x-generic");
+ groupRef = groupRef.left(slashindex);
+ return groupRef + QLatin1String("-x-generic");
}
return d->genericIconName;
}
diff --git a/src/corelib/mimetypes/qmimetype_p.h b/src/corelib/mimetypes/qmimetype_p.h
index c89ffbefa3..b0bfad2f65 100644
--- a/src/corelib/mimetypes/qmimetype_p.h
+++ b/src/corelib/mimetypes/qmimetype_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qmimetype.h"
#ifndef QT_NO_MIMETYPE
diff --git a/src/corelib/mimetypes/qmimetypeparser.cpp b/src/corelib/mimetypes/qmimetypeparser.cpp
index 535fa51c92..7693055cc1 100644
--- a/src/corelib/mimetypes/qmimetypeparser.cpp
+++ b/src/corelib/mimetypes/qmimetypeparser.cpp
@@ -85,7 +85,7 @@ static const char matchMaskAttributeC[] = "mask";
\class QMimeTypeParser
\inmodule QtCore
\internal
- \brief The QMimeTypeParser class parses MIME types, and builds a MIME database hierarchy by adding to QMimeDatabasePrivate.
+ \brief The QMimeTypeParser class parses MIME types, and builds a MIME database hierarchy by adding to QMimeDatabase.
Populates QMimeDataBase
diff --git a/src/corelib/plugin/plugin.pri b/src/corelib/plugin/plugin.pri
index 544dd41742..473480eb55 100644
--- a/src/corelib/plugin/plugin.pri
+++ b/src/corelib/plugin/plugin.pri
@@ -35,8 +35,4 @@ integrity {
SOURCES += plugin/qlibrary_unix.cpp
}
-darwin {
- OBJECTIVE_SOURCES += plugin/quuid_darwin.mm
-}
-
!no-libdl: LIBS_PRIVATE += $$QMAKE_LIBS_DYNLOAD
diff --git a/src/corelib/plugin/qelfparser_p.h b/src/corelib/plugin/qelfparser_p.h
index 145f00df43..bcda19e8b5 100644
--- a/src/corelib/plugin/qelfparser_p.h
+++ b/src/corelib/plugin/qelfparser_p.h
@@ -52,7 +52,7 @@
//
#include <qendian.h>
-#include <qglobal.h>
+#include <private/qglobal_p.h>
#ifndef QT_NO_LIBRARY
#if defined (Q_OF_ELF) && defined(Q_CC_GNU)
diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp
index 6cd02e3a3f..c09dc6c22b 100644
--- a/src/corelib/plugin/qfactoryloader.cpp
+++ b/src/corelib/plugin/qfactoryloader.cpp
@@ -108,7 +108,11 @@ void QFactoryLoader::update()
if (!QDir(path).exists(QLatin1String(".")))
continue;
- QStringList plugins = QDir(path).entryList(QDir::Files);
+ QStringList plugins = QDir(path).entryList(
+#ifdef Q_OS_WIN
+ QStringList(QStringLiteral("*.dll")),
+#endif
+ QDir::Files);
QLibraryPrivate *library = 0;
#ifdef Q_OS_MAC
@@ -187,10 +191,12 @@ void QFactoryLoader::update()
++keyUsageCount;
}
}
- if (keyUsageCount || keys.isEmpty())
+ if (keyUsageCount || keys.isEmpty()) {
+ library->setLoadHints(QLibrary::PreventUnloadHint); // once loaded, don't unload
d->libraryList += library;
- else
+ } else {
library->release();
+ }
}
}
#else
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index 18ce085856..aff2991ed1 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -621,12 +621,12 @@ bool QLibrary::isLibrary(const QString &fileName)
QString completeSuffix = QFileInfo(fileName).completeSuffix();
if (completeSuffix.isEmpty())
return false;
- QStringList suffixes = completeSuffix.split(QLatin1Char('.'));
+ const QVector<QStringRef> suffixes = completeSuffix.splitRef(QLatin1Char('.'));
# if defined(Q_OS_DARWIN)
// On Mac, libs look like libmylib.1.0.0.dylib
- const QString lastSuffix = suffixes.at(suffixes.count() - 1);
- const QString firstSuffix = suffixes.at(0);
+ const QStringRef &lastSuffix = suffixes.at(suffixes.count() - 1);
+ const QStringRef &firstSuffix = suffixes.at(0);
bool valid = (lastSuffix == QLatin1String("dylib")
|| firstSuffix == QLatin1String("so")
@@ -662,7 +662,7 @@ bool QLibrary::isLibrary(const QString &fileName)
int suffix;
int suffixPos = -1;
for (suffix = 0; suffix < validSuffixList.count() && suffixPos == -1; ++suffix)
- suffixPos = suffixes.indexOf(validSuffixList.at(suffix));
+ suffixPos = suffixes.indexOf(QStringRef(&validSuffixList.at(suffix)));
bool valid = suffixPos != -1;
for (int i = suffixPos + 1; i < suffixes.count() && valid; ++i)
diff --git a/src/corelib/plugin/qlibrary_p.h b/src/corelib/plugin/qlibrary_p.h
index c3bdc5a832..f883e74843 100644
--- a/src/corelib/plugin/qlibrary_p.h
+++ b/src/corelib/plugin/qlibrary_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qlibrary.h"
#include "QtCore/qpointer.h"
#include "QtCore/qstringlist.h"
diff --git a/src/corelib/plugin/qlibrary_unix.cpp b/src/corelib/plugin/qlibrary_unix.cpp
index f6a947b61a..9db0b7ff39 100644
--- a/src/corelib/plugin/qlibrary_unix.cpp
+++ b/src/corelib/plugin/qlibrary_unix.cpp
@@ -50,10 +50,6 @@
# include <private/qcore_mac_p.h>
#endif
-#if defined(QT_AOUT_UNDERSCORE)
-#include <string.h>
-#endif
-
#if (defined(Q_OS_VXWORKS) && !defined(VXWORKS_RTP)) || defined (Q_OS_NACL)
#define QT_NO_DYNAMIC_LIBRARY
#endif
@@ -171,9 +167,6 @@ bool QLibraryPrivate::load_sys()
}
#if !defined(Q_OS_CYGWIN)
else {
-#if defined(Q_OS_MAC)
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4)
-#endif
dlFlags |= RTLD_LOCAL;
}
#endif
@@ -308,14 +301,7 @@ Q_CORE_EXPORT QFunctionPointer qt_mac_resolve_sys(void *handle, const char *symb
QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol)
{
-#if defined(QT_AOUT_UNDERSCORE)
- // older a.out systems add an underscore in front of symbols
- char* undrscr_symbol = new char[strlen(symbol)+2];
- undrscr_symbol[0] = '_';
- strcpy(undrscr_symbol+1, symbol);
- QFunctionPointer address = QFunctionPointer(dlsym(pHnd, undrscr_symbol));
- delete [] undrscr_symbol;
-#elif defined(QT_HPUX_LD)
+#if defined(QT_HPUX_LD)
QFunctionPointer address = 0;
if (shl_findsym((shl_t*)&pHnd, symbol, TYPE_UNDEFINED, &address) < 0)
address = 0;
diff --git a/src/corelib/plugin/qlibrary_win.cpp b/src/corelib/plugin/qlibrary_win.cpp
index 46fbba151c..48aa0cdbb6 100644
--- a/src/corelib/plugin/qlibrary_win.cpp
+++ b/src/corelib/plugin/qlibrary_win.cpp
@@ -71,15 +71,6 @@ bool QLibraryPrivate::load_sys()
#endif
// We make the following attempts at locating the library:
//
- // WinCE
- // if (absolute)
- // fileName
- // fileName + ".dll"
- // else
- // fileName + ".dll"
- // fileName
- // QFileInfo(fileName).absoluteFilePath()
- //
// Windows
// if (absolute)
// fileName
@@ -97,14 +88,10 @@ bool QLibraryPrivate::load_sys()
// If the fileName is an absolute path we try that first, otherwise we
// use the system-specific suffix first
QFileSystemEntry fsEntry(fileName);
- if (fsEntry.isAbsolute()) {
+ if (fsEntry.isAbsolute())
attempts.prepend(fileName);
- } else {
+ else
attempts.append(fileName);
-#if defined(Q_OS_WINCE)
- attempts.append(QFileInfo(fileName).absoluteFilePath());
-#endif
- }
#ifdef Q_OS_WINRT
if (fileName.startsWith(QLatin1Char('/')))
attempts.prepend(QDir::rootPath() + fileName);
@@ -176,11 +163,7 @@ bool QLibraryPrivate::unload_sys()
QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol)
{
-#ifdef Q_OS_WINCE
- FARPROC address = GetProcAddress(pHnd, (const wchar_t*)QString::fromLatin1(symbol).utf16());
-#else
FARPROC address = GetProcAddress(pHnd, symbol);
-#endif
if (!address) {
errorString = QLibrary::tr("Cannot resolve symbol \"%1\" in %2: %3").arg(
QString::fromLatin1(symbol)).arg(
diff --git a/src/corelib/plugin/qmachparser.cpp b/src/corelib/plugin/qmachparser.cpp
index c136ef3797..a599fbcb23 100644
--- a/src/corelib/plugin/qmachparser.cpp
+++ b/src/corelib/plugin/qmachparser.cpp
@@ -59,6 +59,9 @@ static const cpu_type_t my_cputype = CPU_TYPE_X86;
static const cpu_type_t my_cputype = CPU_TYPE_POWERPC64;
#elif defined(Q_PROCESSOR_POWER_32)
static const cpu_type_t my_cputype = CPU_TYPE_POWERPC;
+#elif defined(Q_PROCESSOR_ARM_64)
+# define MACHO64
+static const cpu_type_t my_cputype = CPU_TYPE_ARM64;
#elif defined(Q_PROCESSOR_ARM)
static const cpu_type_t my_cputype = CPU_TYPE_ARM;
#else
diff --git a/src/corelib/plugin/qmachparser_p.h b/src/corelib/plugin/qmachparser_p.h
index 0df7a98f96..ff7eaadb70 100644
--- a/src/corelib/plugin/qmachparser_p.h
+++ b/src/corelib/plugin/qmachparser_p.h
@@ -52,7 +52,7 @@
//
#include <qendian.h>
-#include <qglobal.h>
+#include <private/qglobal_p.h>
#ifndef QT_NO_LIBRARY
#if defined(Q_OF_MACH_O)
diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp
index 094280e3b4..4ec4e43952 100644
--- a/src/corelib/plugin/qpluginloader.cpp
+++ b/src/corelib/plugin/qpluginloader.cpp
@@ -154,6 +154,7 @@ QPluginLoader::QPluginLoader(const QString &fileName, QObject *parent)
: QObject(parent), d(0), did_load(false)
{
setFileName(fileName);
+ setLoadHints(QLibrary::PreventUnloadHint);
}
/*!
@@ -348,7 +349,7 @@ static QString locatePlugin(const QString& fileName)
void QPluginLoader::setFileName(const QString &fileName)
{
#if defined(QT_SHARED)
- QLibrary::LoadHints lh;
+ QLibrary::LoadHints lh = QLibrary::PreventUnloadHint;
if (d) {
lh = d->loadHints();
d->release();
@@ -394,7 +395,7 @@ QString QPluginLoader::errorString() const
\brief Give the load() function some hints on how it should behave.
You can give hints on how the symbols in the plugin are
- resolved. By default, none of the hints are set.
+ resolved. By default since Qt 5.7, QLibrary::PreventUnloadHint is set.
See the documentation of QLibrary::loadHints for a complete
description of how this property works.
diff --git a/src/corelib/plugin/qsystemlibrary.cpp b/src/corelib/plugin/qsystemlibrary.cpp
index 178a33f987..7c80fbbd42 100644
--- a/src/corelib/plugin/qsystemlibrary.cpp
+++ b/src/corelib/plugin/qsystemlibrary.cpp
@@ -68,23 +68,11 @@
DLL Safe search mode is documented in the "Dynamic-Link Library Search
Order" document on MSDN.
-
- Since library loading code is sometimes shared between Windows and WinCE,
- this class can also be used on WinCE. However, its implementation just
- calls the LoadLibrary() function. This is ok since it is documented as not
- loading from the current directory on WinCE. This behaviour is documented
- in the documentation for LoadLibrary for Windows CE at MSDN.
- (http://msdn.microsoft.com/en-us/library/ms886736.aspx)
*/
QT_BEGIN_NAMESPACE
-#if defined(Q_OS_WINCE)
-HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirectory /* = true */)
-{
- return ::LoadLibrary(libraryName);
-}
-#elif defined(Q_OS_WINRT)
+#if defined(Q_OS_WINRT)
HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirectory /* = true */)
{
Q_UNUSED(onlySystemDirectory);
@@ -141,6 +129,6 @@ HINSTANCE QSystemLibrary::load(const wchar_t *libraryName, bool onlySystemDirect
}
-#endif //Q_OS_WINCE
+#endif // Q_OS_WINRT
QT_END_NAMESPACE
diff --git a/src/corelib/plugin/qsystemlibrary_p.h b/src/corelib/plugin/qsystemlibrary_p.h
index 469376d81b..4e093c0b7c 100644
--- a/src/corelib/plugin/qsystemlibrary_p.h
+++ b/src/corelib/plugin/qsystemlibrary_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
#ifdef Q_OS_WIN
# include <QtCore/qstring.h>
# include <qt_windows.h>
@@ -93,11 +93,7 @@ public:
load();
if (!m_handle)
return 0;
-#ifdef Q_OS_WINCE
- return QFunctionPointer(GetProcAddress(m_handle, (const wchar_t*)QString::fromLatin1(symbol).utf16()));
-#else
return QFunctionPointer(GetProcAddress(m_handle, symbol));
-#endif
}
static QFunctionPointer resolve(const QString &libraryName, const char *symbol)
diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp
index 5876bb84c3..f11ac6548b 100644
--- a/src/corelib/plugin/quuid.cpp
+++ b/src/corelib/plugin/quuid.cpp
@@ -809,39 +809,6 @@ QUuid::Version QUuid::version() const Q_DECL_NOTHROW
return ver;
}
-/*! \fn QUuid QUuid::fromCFUUID(CFUUIDRef uuid)
- \since 5.7
-
- Constructs a new QUuid containing a copy of the \a uuid CFUUID.
-
- \note this function is only available on Apple platforms.
-*/
-
-/*! \fn CFUUIDRef QUuid::toCFUUID() const
- \since 5.7
-
- Creates a CFUUID from a QUuid. The caller owns the CFUUID and is
- responsible for releasing it.
-
- \note this function is only available on Apple platforms.
-*/
-
-/*! \fn QUuid QUuid::fromNSUUID(const NSUUID *uuid)
- \since 5.7
-
- Constructs a new QUuid containing a copy of the \a uuid NSUUID.
-
- \note this function is only available on Apple platforms.
-*/
-
-/*! \fn NSUUID QUuid::toNSUUID() const
- \since 5.7
-
- Creates a NSUUID from a QUuid. The NSUUID is autoreleased.
-
- \note this function is only available on Apple platforms.
-*/
-
/*!
\fn bool QUuid::operator<(const QUuid &other) const
@@ -1002,7 +969,7 @@ QUuid QUuid::createUuid()
{
int *pseed = new int;
static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(2);
- qsrand(*pseed = QDateTime::currentDateTimeUtc().toTime_t()
+ qsrand(*pseed = QDateTime::currentSecsSinceEpoch()
+ quintptr(&pseed)
+ serial.fetchAndAddRelaxed(1));
uuidseed.setLocalData(pseed);
@@ -1010,7 +977,7 @@ QUuid QUuid::createUuid()
#else
static bool seeded = false;
if (!seeded)
- qsrand(QDateTime::currentDateTimeUtc().toTime_t()
+ qsrand(QDateTime::currentSecsSinceEpoch()
+ quintptr(&seeded));
#endif
diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h
index a1d16b449e..264f572993 100644
--- a/src/corelib/plugin/quuid.h
+++ b/src/corelib/plugin/quuid.h
@@ -55,11 +55,9 @@ typedef struct _GUID
#endif
#endif
-#ifdef Q_OS_DARWIN
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_FORWARD_DECLARE_CF_TYPE(CFUUID);
-# ifdef __OBJC__
Q_FORWARD_DECLARE_OBJC_CLASS(NSUUID);
-# endif
#endif
QT_BEGIN_NAMESPACE
@@ -210,10 +208,8 @@ public:
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
static QUuid fromCFUUID(CFUUIDRef uuid);
CFUUIDRef toCFUUID() const Q_DECL_CF_RETURNS_RETAINED;
-# if defined(__OBJC__) || defined(Q_QDOC)
static QUuid fromNSUUID(const NSUUID *uuid);
NSUUID *toNSUUID() const Q_DECL_NS_RETURNS_AUTORELEASED;
-# endif
#endif
uint data1;
diff --git a/src/corelib/statemachine/qsignaleventgenerator_p.h b/src/corelib/statemachine/qsignaleventgenerator_p.h
index c0bb52c480..92b1ee3b70 100644
--- a/src/corelib/statemachine/qsignaleventgenerator_p.h
+++ b/src/corelib/statemachine/qsignaleventgenerator_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qobject.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/statemachine/qsignaltransition.h b/src/corelib/statemachine/qsignaltransition.h
index e8d413cd8a..d7cf8584da 100644
--- a/src/corelib/statemachine/qsignaltransition.h
+++ b/src/corelib/statemachine/qsignaltransition.h
@@ -60,6 +60,7 @@ public:
QSignalTransition(const QObject *sender, const char *signal,
QState *sourceState = Q_NULLPTR);
#ifdef Q_QDOC
+ template<typename PointerToMemberFunction>
QSignalTransition(const QObject *object, PointerToMemberFunction signal,
QState *sourceState = Q_NULLPTR);
#elif defined(Q_COMPILER_DELEGATING_CONSTRUCTORS)
diff --git a/src/corelib/statemachine/qstate.h b/src/corelib/statemachine/qstate.h
index ee1ff3fea3..7a9dc9c132 100644
--- a/src/corelib/statemachine/qstate.h
+++ b/src/corelib/statemachine/qstate.h
@@ -82,6 +82,7 @@ public:
void addTransition(QAbstractTransition *transition);
QSignalTransition *addTransition(const QObject *sender, const char *signal, QAbstractState *target);
#ifdef Q_QDOC
+ template<typename PointerToMemberFunction>
QSignalTransition *addTransition(const QObject *sender, PointerToMemberFunction signal,
QAbstractState *target);
#else
diff --git a/src/corelib/thread/qfuture.h b/src/corelib/thread/qfuture.h
index 7ae5c68bb9..1f0c747f40 100644
--- a/src/corelib/thread/qfuture.h
+++ b/src/corelib/thread/qfuture.h
@@ -65,13 +65,7 @@ public:
explicit QFuture(QFutureInterface<T> *p) // internal
: d(*p)
{ }
- QFuture(const QFuture &other)
- : d(other.d)
- { }
- ~QFuture()
- { }
- inline QFuture &operator=(const QFuture &other);
bool operator==(const QFuture &other) const { return (d == other.d); }
bool operator!=(const QFuture &other) const { return (d != other.d); }
@@ -157,13 +151,6 @@ public: // Warning: the d pointer is not documented and is considered private.
};
template <typename T>
-inline QFuture<T> &QFuture<T>::operator=(const QFuture<T> &other)
-{
- d = other.d;
- return *this;
-}
-
-template <typename T>
inline T QFuture<T>::result() const
{
d.waitForResult(0);
@@ -195,13 +182,7 @@ public:
explicit QFuture(QFutureInterfaceBase *p) // internal
: d(*p)
{ }
- QFuture(const QFuture &other)
- : d(other.d)
- { }
- ~QFuture()
- { }
- QFuture &operator=(const QFuture &other);
bool operator==(const QFuture &other) const { return (d == other.d); }
bool operator!=(const QFuture &other) const { return (d != other.d); }
@@ -248,12 +229,6 @@ public:
mutable QFutureInterfaceBase d;
};
-inline QFuture<void> &QFuture<void>::operator=(const QFuture<void> &other)
-{
- d = other.d;
- return *this;
-}
-
inline QFuture<void> QFutureInterface<void>::future()
{
return QFuture<void>(this);
diff --git a/src/corelib/thread/qfutureinterface.h b/src/corelib/thread/qfutureinterface.h
index 1787ff3b93..559d26e231 100644
--- a/src/corelib/thread/qfutureinterface.h
+++ b/src/corelib/thread/qfutureinterface.h
@@ -285,21 +285,13 @@ template <>
class QFutureInterface<void> : public QFutureInterfaceBase
{
public:
- QFutureInterface<void>(State initialState = NoState)
+ explicit QFutureInterface<void>(State initialState = NoState)
: QFutureInterfaceBase(initialState)
{ }
- QFutureInterface<void>(const QFutureInterface<void> &other)
- : QFutureInterfaceBase(other)
- { }
static QFutureInterface<void> canceledResult()
{ return QFutureInterface(State(Started | Finished | Canceled)); }
- QFutureInterface<void> &operator=(const QFutureInterface<void> &other)
- {
- QFutureInterfaceBase::operator=(other);
- return *this;
- }
inline QFuture<void> future(); // implemented in qfuture.h
diff --git a/src/corelib/thread/qfutureinterface_p.h b/src/corelib/thread/qfutureinterface_p.h
index f5f0e7047f..ee8dfe1354 100644
--- a/src/corelib/thread/qfutureinterface_p.h
+++ b/src/corelib/thread/qfutureinterface_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qelapsedtimer.h>
#include <QtCore/qcoreevent.h>
#include <QtCore/qlist.h>
diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp
index 0b14ec31c2..6dfe1ddc89 100644
--- a/src/corelib/thread/qmutex.cpp
+++ b/src/corelib/thread/qmutex.cpp
@@ -264,6 +264,61 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT
return lockInternal(timeout);
}
+/*! \fn bool QMutex::try_lock()
+ \since 5.8
+
+ This function is provided for compatibility with the Standard Library
+ concept \c Lockable. It is equivalent to tryLock().
+*/
+
+/*! \fn bool QMutex::try_lock_for(std::chrono::duration<Rep, Period> duration)
+ \since 5.8
+
+ Attempts to lock the mutex. This function returns \c true if the lock
+ was obtained; otherwise it returns \c false. If another thread has
+ locked the mutex, this function will wait for at most \a duration
+ for the mutex to become available.
+
+ Note: Passing a negative duration as the \a duration is equivalent to
+ calling try_lock(). This behavior is different from tryLock.
+
+ If the lock was obtained, the mutex must be unlocked with unlock()
+ before another thread can successfully lock it.
+
+ Calling this function multiple times on the same mutex from the
+ same thread is allowed if this mutex is a
+ \l{QMutex::Recursive}{recursive mutex}. If this mutex is a
+ \l{QMutex::NonRecursive}{non-recursive mutex}, this function will
+ \e always return false when attempting to lock the mutex
+ recursively.
+
+ \sa lock(), unlock()
+*/
+
+/*! \fn bool QMutex::try_lock_until(std::chrono::time_point<Clock, Duration> timePoint)
+ \since 5.8
+
+ Attempts to lock the mutex. This function returns \c true if the lock
+ was obtained; otherwise it returns \c false. If another thread has
+ locked the mutex, this function will wait at most until \a timePoint
+ for the mutex to become available.
+
+ Note: Passing a \a timePoint which has already passed is equivalent
+ to calling try_lock. This behavior is different from tryLock.
+
+ If the lock was obtained, the mutex must be unlocked with unlock()
+ before another thread can successfully lock it.
+
+ Calling this function multiple times on the same mutex from the
+ same thread is allowed if this mutex is a
+ \l{QMutex::Recursive}{recursive mutex}. If this mutex is a
+ \l{QMutex::NonRecursive}{non-recursive mutex}, this function will
+ \e always return false when attempting to lock the mutex
+ recursively.
+
+ \sa lock(), unlock()
+*/
+
/*! \fn void QMutex::unlock()
Unlocks the mutex. Attempting to unlock a mutex in a different
thread to the one that locked it results in an error. Unlocking a
diff --git a/src/corelib/thread/qmutex.h b/src/corelib/thread/qmutex.h
index a06bcd99ac..da8d1704b0 100644
--- a/src/corelib/thread/qmutex.h
+++ b/src/corelib/thread/qmutex.h
@@ -44,6 +44,10 @@
#include <QtCore/qatomic.h>
#include <new>
+#if QT_HAS_INCLUDE(<chrono>)
+# include <chrono>
+#endif
+
QT_BEGIN_NAMESPACE
@@ -60,11 +64,13 @@ class QMutexData;
class Q_CORE_EXPORT QBasicMutex
{
public:
+ // BasicLockable concept
inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
if (!fastTryLock())
lockInternal();
}
+ // BasicLockable concept
inline void unlock() Q_DECL_NOTHROW {
Q_ASSERT(d_ptr.load()); //mutex must be locked
if (!fastTryUnlock())
@@ -75,6 +81,9 @@ public:
return fastTryLock();
}
+ // Lockable concept
+ bool try_lock() Q_DECL_NOTHROW { return tryLock(); }
+
bool isRecursive() Q_DECL_NOTHROW; //### Qt6: remove me
bool isRecursive() const Q_DECL_NOTHROW;
@@ -112,10 +121,41 @@ public:
explicit QMutex(RecursionMode mode = NonRecursive);
~QMutex();
+ // BasicLockable concept
void lock() QT_MUTEX_LOCK_NOEXCEPT;
bool tryLock(int timeout = 0) QT_MUTEX_LOCK_NOEXCEPT;
+ // BasicLockable concept
void unlock() Q_DECL_NOTHROW;
+ // Lockable concept
+ bool try_lock() QT_MUTEX_LOCK_NOEXCEPT { return tryLock(); }
+
+#if QT_HAS_INCLUDE(<chrono>)
+ // TimedLockable concept
+ template <class Rep, class Period>
+ bool try_lock_for(std::chrono::duration<Rep, Period> duration)
+ {
+ // § 30.4.1.3.5 [thread.timedmutex.requirements] specifies that a
+ // duration less than or equal to duration.zero() shall result in a
+ // try_lock, unlike QMutex's tryLock with a negative duration which
+ // results in a lock.
+
+ if (duration <= duration.zero())
+ return tryLock(0);
+ return tryLock(std::chrono::duration_cast<std::chrono::milliseconds>(duration).count());
+ }
+
+ // TimedLockable concept
+ template<class Clock, class Duration>
+ bool try_lock_until(std::chrono::time_point<Clock, Duration> timePoint)
+ {
+ // Implemented in terms of try_lock_for to honor the similar
+ // requirement in § 30.4.1.3.12 [thread.timedmutex.requirements]
+
+ return try_lock_for(timePoint - Clock::now());
+ }
+#endif
+
bool isRecursive() const Q_DECL_NOTHROW
{ return QBasicMutex::isRecursive(); }
@@ -189,9 +229,26 @@ public:
inline void lock() Q_DECL_NOTHROW {}
inline bool tryLock(int timeout = 0) Q_DECL_NOTHROW { Q_UNUSED(timeout); return true; }
+ inline bool try_lock() Q_DECL_NOTHROW { return true; }
inline void unlock() Q_DECL_NOTHROW {}
inline bool isRecursive() const Q_DECL_NOTHROW { return true; }
+#if QT_HAS_INCLUDE(<chrono>) || defined(Q_QDOC)
+ template <class Rep, class Period>
+ inline bool try_lock_for(std::chrono::duration<Rep, Period> duration) Q_DECL_NOTHROW
+ {
+ Q_UNUSED(duration);
+ return true;
+ }
+
+ template<class Clock, class Duration>
+ inline bool try_lock_until(std::chrono::time_point<Clock, Duration> timePoint) Q_DECL_NOTHROW
+ {
+ Q_UNUSED(timePoint);
+ return true;
+ }
+#endif
+
private:
Q_DISABLE_COPY(QMutex)
};
diff --git a/src/corelib/thread/qmutex_p.h b/src/corelib/thread/qmutex_p.h
index 20cc5f1f5e..4e6f522a37 100644
--- a/src/corelib/thread/qmutex_p.h
+++ b/src/corelib/thread/qmutex_p.h
@@ -54,7 +54,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qnamespace.h>
#include <QtCore/qmutex.h>
#include <QtCore/qatomic.h>
diff --git a/src/corelib/thread/qmutex_win.cpp b/src/corelib/thread/qmutex_win.cpp
index acb0f9dc61..3c314a4c0c 100644
--- a/src/corelib/thread/qmutex_win.cpp
+++ b/src/corelib/thread/qmutex_win.cpp
@@ -61,11 +61,7 @@ QMutexPrivate::~QMutexPrivate()
bool QMutexPrivate::wait(int timeout)
{
-#ifndef Q_OS_WINCE
return (WaitForSingleObjectEx(event, timeout < 0 ? INFINITE : timeout, FALSE) == WAIT_OBJECT_0);
-#else
- return (WaitForSingleObject(event, timeout < 0 ? INFINITE : timeout) == WAIT_OBJECT_0);
-#endif
}
void QMutexPrivate::wakeUp() Q_DECL_NOTHROW
diff --git a/src/corelib/thread/qmutexpool_p.h b/src/corelib/thread/qmutexpool_p.h
index 796e65d960..b6c837e9f9 100644
--- a/src/corelib/thread/qmutexpool_p.h
+++ b/src/corelib/thread/qmutexpool_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qatomic.h"
#include "QtCore/qmutex.h"
#include "QtCore/qvarlengtharray.h"
diff --git a/src/corelib/thread/qorderedmutexlocker_p.h b/src/corelib/thread/qorderedmutexlocker_p.h
index f54f7c705d..81c7c5268c 100644
--- a/src/corelib/thread/qorderedmutexlocker_p.h
+++ b/src/corelib/thread/qorderedmutexlocker_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qmutex.h>
#include <functional>
diff --git a/src/corelib/thread/qreadwritelock_p.h b/src/corelib/thread/qreadwritelock_p.h
index 24d25eb2be..bb58dfab56 100644
--- a/src/corelib/thread/qreadwritelock_p.h
+++ b/src/corelib/thread/qreadwritelock_p.h
@@ -52,7 +52,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qhash.h>
#include <QtCore/QWaitCondition>
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index 4aac24f454..7118ad5c9b 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -403,7 +403,7 @@ QThread::QThread(QThreadPrivate &dd, QObject *parent)
Note that deleting a QThread object will not stop the execution
of the thread it manages. Deleting a running QThread (i.e.
- isFinished() returns \c false) will probably result in a program
+ isFinished() returns \c false) will result in a program
crash. Wait for the finished() signal before deleting the
QThread.
*/
@@ -418,7 +418,7 @@ QThread::~QThread()
locker.relock();
}
if (d->running && !d->finished && !d->data->isAdopted)
- qWarning("QThread: Destroyed while thread is still running");
+ qFatal("QThread: Destroyed while thread is still running");
d->data->thread = 0;
}
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index ef1799a021..a14c193bad 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -55,15 +55,10 @@
#include <qt_windows.h>
#ifndef Q_OS_WINRT
-#ifndef Q_OS_WINCE
-#ifndef _MT
-#define _MT
-#endif // _MT
-#include <process.h>
-#else // !Q_OS_WINCE
-#include "qfunctions_wince.h"
-#endif // Q_OS_WINCE
-#else // !Q_OS_WINRT
+# ifndef _MT
+# define _MT
+# endif // _MT
+# include <process.h>
#endif // Q_OS_WINRT
#ifndef QT_NO_THREAD
@@ -150,7 +145,6 @@ QThreadData *QThreadData::current(bool createIfNecessary)
// WinRT API?
} else {
HANDLE realHandle = INVALID_HANDLE_VALUE;
-#if !defined(Q_OS_WINCE) || (defined(_WIN32_WCE) && (_WIN32_WCE>=0x600))
DuplicateHandle(GetCurrentProcess(),
GetCurrentThread(),
GetCurrentProcess(),
@@ -158,9 +152,6 @@ QThreadData *QThreadData::current(bool createIfNecessary)
0,
FALSE,
DUPLICATE_SAME_ACCESS);
-#else
- realHandle = reinterpret_cast<HANDLE>(GetCurrentThreadId());
-#endif
qt_watch_adopted_thread(realHandle, threadData->thread);
}
}
@@ -190,9 +181,7 @@ void qt_watch_adopted_thread(const HANDLE adoptedThreadHandle, QThread *qthread)
QMutexLocker lock(&qt_adopted_thread_watcher_mutex);
if (GetCurrentThreadId() == qt_adopted_thread_watcher_id) {
-#if !defined(Q_OS_WINCE) || (defined(_WIN32_WCE) && (_WIN32_WCE>=0x600))
CloseHandle(adoptedThreadHandle);
-#endif
return;
}
@@ -291,9 +280,7 @@ DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID)
data->deref();
QMutexLocker lock(&qt_adopted_thread_watcher_mutex);
-#if !defined(Q_OS_WINCE) || (defined(_WIN32_WCE) && (_WIN32_WCE>=0x600))
CloseHandle(qt_adopted_thread_handles.at(handleIndex));
-#endif
qt_adopted_thread_handles.remove(handleIndex);
qt_adopted_qthreads.remove(qthreadIndex);
}
@@ -306,7 +293,7 @@ DWORD WINAPI qt_adopted_thread_watcher_function(LPVOID)
return 0;
}
-#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
#ifndef Q_OS_WIN64
# define ULONG_PTR DWORD
@@ -336,7 +323,7 @@ void qt_set_thread_name(HANDLE threadId, LPCSTR threadName)
{
}
}
-#endif // !QT_NO_DEBUG && Q_CC_MSVC && !Q_OS_WINCE && !Q_OS_WINRT
+#endif // !QT_NO_DEBUG && Q_CC_MSVC && !Q_OS_WINRT
/**************************************************************************
** QThreadPrivate
@@ -378,7 +365,7 @@ unsigned int __stdcall QT_ENSURE_STACK_ALIGNED_FOR_SSE QThreadPrivate::start(voi
else
createEventDispatcher(data);
-#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(QT_NO_DEBUG) && defined(Q_CC_MSVC) && !defined(Q_OS_WINRT)
// sets the name of the current thread.
QByteArray objectName = thr->objectName().toLocal8Bit();
qt_set_thread_name((HANDLE)-1,
@@ -453,7 +440,7 @@ int QThread::idealThreadCount() Q_DECL_NOTHROW
void QThread::yieldCurrentThread()
{
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
SwitchToThread();
#else
::Sleep(0);
@@ -495,7 +482,6 @@ void QThread::start(Priority priority)
d->returnCode = 0;
d->interruptionRequested = false;
-#ifndef Q_OS_WINRT
/*
NOTE: we create the thread in the suspended state, set the
priority and then resume the thread.
@@ -506,9 +492,21 @@ void QThread::start(Priority priority)
less than NormalPriority), but the newly created thread preempts
its 'parent' and runs at normal priority.
*/
+#if defined(Q_CC_MSVC) && !defined(_DLL) // && !defined(Q_OS_WINRT)
+# ifdef Q_OS_WINRT
+ // If you wish to accept the memory leaks, uncomment the part above.
+ // See:
+ // https://support.microsoft.com/en-us/kb/104641
+ // https://msdn.microsoft.com/en-us/library/kdzttdcb.aspx
+# error "Microsoft documentation says this combination leaks memory every time a thread is started. " \
+ "Please change your build back to -MD/-MDd or, if you understand this issue and want to continue, " \
+ "edit this source file."
+# endif
+ // MSVC -MT or -MTd build
d->handle = (Qt::HANDLE) _beginthreadex(NULL, d->stackSize, QThreadPrivate::start,
this, CREATE_SUSPENDED, &(d->id));
-#else // !Q_OS_WINRT
+#else
+ // MSVC -MD or -MDd or MinGW build
d->handle = (Qt::HANDLE) CreateThread(NULL, d->stackSize, (LPTHREAD_START_ROUTINE)QThreadPrivate::start,
this, CREATE_SUSPENDED, reinterpret_cast<LPDWORD>(&d->id));
#endif // Q_OS_WINRT
diff --git a/src/corelib/thread/qwaitcondition.h b/src/corelib/thread/qwaitcondition.h
index d2e018834a..a0c6766833 100644
--- a/src/corelib/thread/qwaitcondition.h
+++ b/src/corelib/thread/qwaitcondition.h
@@ -65,6 +65,9 @@ public:
void wakeOne();
void wakeAll();
+ void notify_one() { wakeOne(); }
+ void notify_all() { wakeAll(); }
+
private:
Q_DISABLE_COPY(QWaitCondition)
diff --git a/src/corelib/thread/qwaitcondition.qdoc b/src/corelib/thread/qwaitcondition.qdoc
index d7de323922..eebc28f059 100644
--- a/src/corelib/thread/qwaitcondition.qdoc
+++ b/src/corelib/thread/qwaitcondition.qdoc
@@ -172,3 +172,18 @@
\sa wakeOne(), wakeAll()
*/
+
+
+/*! \fn void QWaitCondition::notify_one()
+ \since 5.8
+
+ This function is provided for STL compatibility. It is equivalent
+ to wakeOne().
+*/
+
+/*! \fn void QWaitCondition::notify_all()
+ \since 5.8
+
+ This function is provided for STL compatibility. It is equivalent
+ to wakeAll().
+*/
diff --git a/src/corelib/thread/qwaitcondition_win.cpp b/src/corelib/thread/qwaitcondition_win.cpp
index a95ca0b8fd..e6610f18c8 100644
--- a/src/corelib/thread/qwaitcondition_win.cpp
+++ b/src/corelib/thread/qwaitcondition_win.cpp
@@ -115,12 +115,7 @@ bool QWaitConditionPrivate::wait(QWaitConditionEvent *wce, unsigned long time)
{
// wait for the event
bool ret = false;
-#ifndef Q_OS_WINCE
switch (WaitForSingleObjectEx(wce->event, time, FALSE)) {
-#else
- switch (WaitForSingleObject(wce->event, time)) {
-#endif
-
default: break;
case WAIT_OBJECT_0:
diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h
index 4f704d6764..6e472e8b22 100644
--- a/src/corelib/tools/qalgorithms.h
+++ b/src/corelib/tools/qalgorithms.h
@@ -142,15 +142,9 @@ QT_DEPRECATED_X("Use std::count") inline void qCount(const Container &container,
}
#ifdef Q_QDOC
-template <typename T>
-LessThan qLess()
-{
-}
-
-template <typename T>
-LessThan qGreater()
-{
-}
+typedef void* LessThan;
+template <typename T> LessThan qLess();
+template <typename T> LessThan qGreater();
#else
template <typename T>
class QT_DEPRECATED_X("Use std::less") qLess
@@ -522,20 +516,153 @@ QT_DEPRECATED_X("Use std::binary_search") Q_OUTOFLINE_TEMPLATE RandomAccessItera
#endif // QT_DEPRECATED_SINCE(5, 2)
-} //namespace QAlgorithmsPrivate
-
+#ifdef Q_CC_CLANG
+// Clang had a bug where __builtin_ctz/clz/popcount were not marked as constexpr.
+# if (defined __apple_build_version__ && __clang_major__ >= 7) || (Q_CC_CLANG >= 307)
+# define QT_HAS_CONSTEXPR_BUILTINS
+# endif
+#elif defined(Q_CC_MSVC) && !defined(Q_CC_INTEL) && !defined(Q_OS_WINCE) && !defined(Q_PROCESSOR_ARM)
+# define QT_HAS_CONSTEXPR_BUILTINS
+#elif defined(Q_CC_GNU)
+# define QT_HAS_CONSTEXPR_BUILTINS
+#endif
-// Use __builtin_popcount on gcc. Clang claims to be gcc
-// but has a bug where __builtin_popcount is not marked as
-// constexpr.
-#if defined(Q_CC_GNU) && !defined(Q_CC_CLANG)
+#if defined QT_HAS_CONSTEXPR_BUILTINS
+#if defined(Q_CC_GNU) || defined(Q_CC_CLANG)
+# define QT_HAS_BUILTIN_CTZS
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) Q_DECL_NOTHROW
+{
+# if QT_HAS_BUILTIN(__builtin_ctzs) || defined(__BMI__)
+ return __builtin_ctzs(v);
+# else
+ return __builtin_ctz(v);
+# endif
+}
+#define QT_HAS_BUILTIN_CLZS
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW
+{
+# if QT_HAS_BUILTIN(__builtin_clzs) || defined(__BMI__)
+ return __builtin_clzs(v);
+# else
+ return __builtin_clz(v) - 16U;
+# endif
+}
+#define QT_HAS_BUILTIN_CTZ
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctz(quint32 v) Q_DECL_NOTHROW
+{
+ return __builtin_ctz(v);
+}
+#define QT_HAS_BUILTIN_CLZ
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clz(quint32 v) Q_DECL_NOTHROW
+{
+ return __builtin_clz(v);
+}
+#define QT_HAS_BUILTIN_CTZLL
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzll(quint64 v) Q_DECL_NOTHROW
+{
+ return __builtin_ctzll(v);
+}
+#define QT_HAS_BUILTIN_CLZLL
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzll(quint64 v) Q_DECL_NOTHROW
+{
+ return __builtin_clzll(v);
+}
#define QALGORITHMS_USE_BUILTIN_POPCOUNT
-#endif
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) Q_DECL_NOTHROW
+{
+ return __builtin_popcount(v);
+}
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint8 v) Q_DECL_NOTHROW
+{
+ return __builtin_popcount(v);
+}
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint16 v) Q_DECL_NOTHROW
+{
+ return __builtin_popcount(v);
+}
+#define QALGORITHMS_USE_BUILTIN_POPCOUNTLL
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NOTHROW
+{
+ return __builtin_popcountll(v);
+}
+#elif defined(Q_CC_MSVC) && !defined(Q_OS_WINCE) && !defined(Q_PROCESSOR_ARM)
+#define QT_HAS_BUILTIN_CTZ
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE unsigned long qt_builtin_ctz(quint32 val)
+{
+ unsigned long result;
+ _BitScanForward(&result, val);
+ return result;
+}
+#define QT_HAS_BUILTIN_CLZ
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE unsigned long qt_builtin_clz(quint32 val)
+{
+ unsigned long result;
+ _BitScanReverse(&result, val);
+ // Now Invert the result: clz will count *down* from the msb to the lsb, so the msb index is 31
+ // and the lsb index is 0. The result for the index when counting up: msb index is 0 (because it
+ // starts there), and the lsb index is 31.
+ result ^= sizeof(quint32) * 8 - 1;
+ return result;
+}
+#if Q_PROCESSOR_WORDSIZE == 8
+// These are only defined for 64bit builds.
+#define QT_HAS_BUILTIN_CTZLL
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE unsigned long qt_builtin_ctzll(quint64 val)
+{
+ unsigned long result;
+ _BitScanForward64(&result, val);
+ return result;
+}
+// MSVC calls it _BitScanReverse and returns the carry flag, which we don't need
+#define QT_HAS_BUILTIN_CLZLL
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE unsigned long qt_builtin_clzll(quint64 val)
+{
+ unsigned long result;
+ _BitScanReverse64(&result, val);
+ // see qt_builtin_clz
+ result ^= sizeof(quint64) * 8 - 1;
+ return result;
+}
+#endif // MSVC 64bit
+# define QT_HAS_BUILTIN_CTZS
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_ctzs(quint16 v) Q_DECL_NOTHROW
+{
+ return qt_builtin_ctz(v);
+}
+#define QT_HAS_BUILTIN_CLZS
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW
+{
+ return qt_builtin_clz(v) - 16U;
+}
+#define QALGORITHMS_USE_BUILTIN_POPCOUNT
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) Q_DECL_NOTHROW
+{
+ return __popcnt(v);
+}
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint8 v) Q_DECL_NOTHROW
+{
+ return __popcnt16(v);
+}
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcount(quint16 v) Q_DECL_NOTHROW
+{
+ return __popcnt16(v);
+}
+#if Q_PROCESSOR_WORDSIZE == 8
+#define QALGORITHMS_USE_BUILTIN_POPCOUNTLL
+Q_DECL_CONSTEXPR Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NOTHROW
+{
+ return __popcnt64(v);
+}
+#endif // MSVC 64bit
+#endif // MSVC
+#endif // QT_HAS_CONSTEXPR_BUILTINS
+
+} //namespace QAlgorithmsPrivate
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint32 v) Q_DECL_NOTHROW
{
#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT
- return __builtin_popcount(v);
+ return QAlgorithmsPrivate::qt_builtin_popcount(v);
#else
// See http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
return
@@ -548,7 +675,7 @@ Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint32 v) Q
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint8 v) Q_DECL_NOTHROW
{
#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT
- return __builtin_popcount(v);
+ return QAlgorithmsPrivate::qt_builtin_popcount(v);
#else
return
(((v ) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f;
@@ -558,7 +685,7 @@ Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint8 v) Q_
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint16 v) Q_DECL_NOTHROW
{
#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT
- return __builtin_popcount(v);
+ return QAlgorithmsPrivate::qt_builtin_popcount(v);
#else
return
(((v ) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
@@ -568,8 +695,8 @@ Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint16 v) Q
Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(quint64 v) Q_DECL_NOTHROW
{
-#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT
- return __builtin_popcountll(v);
+#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNTLL
+ return QAlgorithmsPrivate::qt_builtin_popcountll(v);
#else
return
(((v ) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
@@ -592,8 +719,8 @@ Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline uint qPopulationCount(long unsigne
Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint32 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
- return v ? __builtin_ctz(v) : 32U;
+#if defined(QT_HAS_BUILTIN_CTZ)
+ return v ? QAlgorithmsPrivate::qt_builtin_ctz(v) : 32U;
#else
// see http://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightParallel
unsigned int c = 32; // c will be the number of zero bits on the right
@@ -610,8 +737,8 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint32 v) Q_DECL_NO
Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint8 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
- return v ? __builtin_ctz(v) : 8U;
+#if defined(QT_HAS_BUILTIN_CTZ)
+ return v ? QAlgorithmsPrivate::qt_builtin_ctz(v) : 8U;
#else
unsigned int c = 8; // c will be the number of zero bits on the right
v &= -signed(v);
@@ -625,12 +752,8 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint8 v) Q_DECL_NOT
Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint16 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
-# if QT_HAS_BUILTIN(__builtin_ctzs) || (defined(__LZCNT__) && defined(__BMI__))
- return v ? __builtin_ctzs(v) : 16U;
-# else
- return v ? __builtin_ctz(v) : 16U;
-# endif
+#if defined(QT_HAS_BUILTIN_CTZS)
+ return v ? QAlgorithmsPrivate::qt_builtin_ctzs(v) : 16U;
#else
unsigned int c = 16; // c will be the number of zero bits on the right
v &= -signed(v);
@@ -645,8 +768,8 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint16 v) Q_DECL_NO
Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(quint64 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
- return v ? __builtin_ctzll(v) : 64;
+#if defined(QT_HAS_BUILTIN_CTZLL)
+ return v ? QAlgorithmsPrivate::qt_builtin_ctzll(v) : 64;
#else
quint32 x = static_cast<quint32>(v);
return x ? qCountTrailingZeroBits(x)
@@ -661,8 +784,8 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountTrailingZeroBits(unsigned long v) Q_D
Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint32 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
- return v ? __builtin_clz(v) : 32U;
+#if defined(QT_HAS_BUILTIN_CLZ)
+ return v ? QAlgorithmsPrivate::qt_builtin_clz(v) : 32U;
#else
// Hacker's Delight, 2nd ed. Fig 5-16, p. 102
v = v | (v >> 1);
@@ -676,8 +799,8 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint32 v) Q_DECL_NOT
Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint8 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
- return v ? __builtin_clz(v)-24U : 8U;
+#if defined(QT_HAS_BUILTIN_CLZ)
+ return v ? QAlgorithmsPrivate::qt_builtin_clz(v)-24U : 8U;
#else
v = v | (v >> 1);
v = v | (v >> 2);
@@ -688,12 +811,8 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint8 v) Q_DECL_NOTH
Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint16 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
-# if QT_HAS_BUILTIN(__builtin_clzs) || (defined(__LZCNT__) && defined(__BMI__))
- return v ? __builtin_clzs(v) : 16U;
-# else
- return v ? __builtin_clz(v)-16U : 16U;
-# endif
+#if defined(QT_HAS_BUILTIN_CLZS)
+ return v ? QAlgorithmsPrivate::qt_builtin_clzs(v) : 16U;
#else
v = v | (v >> 1);
v = v | (v >> 2);
@@ -705,8 +824,8 @@ Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint16 v) Q_DECL_NOT
Q_DECL_RELAXED_CONSTEXPR inline uint qCountLeadingZeroBits(quint64 v) Q_DECL_NOTHROW
{
-#if defined(Q_CC_GNU)
- return v ? __builtin_clzll(v) : 64U;
+#if defined(QT_HAS_BUILTIN_CLZLL)
+ return v ? QAlgorithmsPrivate::qt_builtin_clzll(v) : 64U;
#else
v = v | (v >> 1);
v = v | (v >> 2);
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index c9d6f4e411..266c2e9b57 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -4467,91 +4467,6 @@ QByteArray QByteArray::fromPercentEncoding(const QByteArray &input, char percent
\sa fromStdString(), QString::toStdString()
*/
-/*! \fn QByteArray QByteArray::fromCFData(CFDataRef data)
- \since 5.3
-
- Constructs a new QByteArray containing a copy of the CFData \a data.
-
- \sa fromRawCFData(), fromRawData(), toRawCFData(), toCFData()
-*/
-
-/*! \fn QByteArray QByteArray::fromRawCFData(CFDataRef data)
- \since 5.3
-
- Constructs a QByteArray that uses the bytes of the CFData \a data.
-
- The \a data's bytes are not copied.
-
- The caller guarantees that the CFData will not be deleted
- or modified as long as this QByteArray object exists.
-
- \sa fromCFData(), fromRawData(), toRawCFData(), toCFData()
-*/
-
-/*! \fn CFDataRef QByteArray::toCFData() const
- \since 5.3
-
- Creates a CFData from a QByteArray. The caller owns the CFData object
- and is responsible for releasing it.
-
- \sa toRawCFData(), fromCFData(), fromRawCFData(), fromRawData()
-*/
-
-/*! \fn CFDataRef QByteArray::toRawCFData() const
- \since 5.3
-
- Constructs a CFData that uses the bytes of the QByteArray.
-
- The QByteArray's bytes are not copied.
-
- The caller guarantees that the QByteArray will not be deleted
- or modified as long as this CFData object exists.
-
- \sa toCFData(), fromRawCFData(), fromCFData(), fromRawData()
-*/
-
-/*! \fn QByteArray QByteArray::fromNSData(const NSData *data)
- \since 5.3
-
- Constructs a new QByteArray containing a copy of the NSData \a data.
-
- \sa fromRawNSData(), fromRawData(), toNSData(), toRawNSData()
-*/
-
-/*! \fn QByteArray QByteArray::fromRawNSData(const NSData *data)
- \since 5.3
-
- Constructs a QByteArray that uses the bytes of the NSData \a data.
-
- The \a data's bytes are not copied.
-
- The caller guarantees that the NSData will not be deleted
- or modified as long as this QByteArray object exists.
-
- \sa fromNSData(), fromRawData(), toRawNSData(), toNSData()
-*/
-
-/*! \fn NSData QByteArray::toNSData() const
- \since 5.3
-
- Creates a NSData from a QByteArray. The NSData object is autoreleased.
-
- \sa fromNSData(), fromRawNSData(), fromRawData(), toRawNSData()
-*/
-
-/*! \fn NSData QByteArray::toRawNSData() const
- \since 5.3
-
- Constructs a NSData that uses the bytes of the QByteArray.
-
- The QByteArray's bytes are not copied.
-
- The caller guarantees that the QByteArray will not be deleted
- or modified as long as this NSData object exists.
-
- \sa fromRawNSData(), fromNSData(), fromRawData(), toNSData()
-*/
-
static inline bool q_strchr(const char str[], char chr)
{
if (!str) return false;
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index d334bb43c5..477402d6de 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -56,11 +56,9 @@
#error qbytearray.h must be included before any header file that defines truncate
#endif
-#ifdef Q_OS_MAC
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_FORWARD_DECLARE_CF_TYPE(CFData);
-# ifdef __OBJC__
Q_FORWARD_DECLARE_OBJC_CLASS(NSData);
-# endif
#endif
QT_BEGIN_NAMESPACE
@@ -384,17 +382,15 @@ public:
static QByteArray fromHex(const QByteArray &hexEncoded) Q_REQUIRED_RESULT;
static QByteArray fromPercentEncoding(const QByteArray &pctEncoded, char percent = '%') Q_REQUIRED_RESULT;
-#if defined(Q_OS_MAC) || defined(Q_QDOC)
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
static QByteArray fromCFData(CFDataRef data);
static QByteArray fromRawCFData(CFDataRef data);
CFDataRef toCFData() const Q_DECL_CF_RETURNS_RETAINED;
CFDataRef toRawCFData() const Q_DECL_CF_RETURNS_RETAINED;
-# if defined(__OBJC__) || defined(Q_QDOC)
static QByteArray fromNSData(const NSData *data);
static QByteArray fromRawNSData(const NSData *data);
NSData *toNSData() const Q_DECL_NS_RETURNS_AUTORELEASED;
NSData *toRawNSData() const Q_DECL_NS_RETURNS_AUTORELEASED;
-# endif
#endif
typedef char *iterator;
diff --git a/src/corelib/tools/qbytearraylist.h b/src/corelib/tools/qbytearraylist.h
index bc8b08b380..501bb2e0d5 100644
--- a/src/corelib/tools/qbytearraylist.h
+++ b/src/corelib/tools/qbytearraylist.h
@@ -50,11 +50,13 @@ QT_BEGIN_NAMESPACE
typedef QListIterator<QByteArray> QByteArrayListIterator;
typedef QMutableListIterator<QByteArray> QMutableByteArrayListIterator;
+#ifndef Q_QDOC
typedef QList<QByteArray> QByteArrayList;
namespace QtPrivate {
QByteArray Q_CORE_EXPORT QByteArrayList_join(const QByteArrayList *that, const char *separator, int separatorLength);
}
+#endif
#ifdef Q_QDOC
class QByteArrayList : public QList<QByteArray>
diff --git a/src/corelib/tools/qbytedata_p.h b/src/corelib/tools/qbytedata_p.h
index b275158597..8331be112d 100644
--- a/src/corelib/tools/qbytedata_p.h
+++ b/src/corelib/tools/qbytedata_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <qbytearray.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h
index f01fbc109c..a83e5e6f98 100644
--- a/src/corelib/tools/qchar.h
+++ b/src/corelib/tools/qchar.h
@@ -578,6 +578,18 @@ Q_DECL_CONSTEXPR inline bool operator>=(QChar c1, QChar c2) Q_DECL_NOTHROW { ret
Q_DECL_CONSTEXPR inline bool operator> (QChar c1, QChar c2) Q_DECL_NOTHROW { return operator< (c2, c1); }
Q_DECL_CONSTEXPR inline bool operator<=(QChar c1, QChar c2) Q_DECL_NOTHROW { return !operator< (c2, c1); }
+// disambiguate QChar == int (but only that, so constrain template to exactly 'int'):
+template <typename T>
+Q_DECL_DEPRECATED_X("don't compare ints to QChars, compare them to QChar::unicode() instead")
+Q_DECL_CONSTEXPR inline
+typename std::enable_if<std::is_same<typename std::remove_cv<T>::type, int>::value, bool>::type
+operator==(QChar lhs, T rhs) Q_DECL_NOEXCEPT { return lhs == QChar(rhs); }
+template <typename T>
+Q_DECL_DEPRECATED_X("don't compare ints to QChars, compare them to QChar::unicode() instead")
+Q_DECL_CONSTEXPR inline
+typename std::enable_if<std::is_same<typename std::remove_cv<T>::type, int>::value, bool>::type
+operator!=(QChar lhs, T rhs) Q_DECL_NOEXCEPT { return lhs != QChar(rhs); }
+
#ifndef QT_NO_DATASTREAM
Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, QChar);
Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QChar &);
diff --git a/src/corelib/tools/qcollator_p.h b/src/corelib/tools/qcollator_p.h
index a056fcc4af..fbbce00676 100644
--- a/src/corelib/tools/qcollator_p.h
+++ b/src/corelib/tools/qcollator_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qcollator.h"
#include <QVector>
#ifdef QT_USE_ICU
diff --git a/src/corelib/tools/qcommandlineoption.cpp b/src/corelib/tools/qcommandlineoption.cpp
index 751e18c44e..c2b86014ba 100644
--- a/src/corelib/tools/qcommandlineoption.cpp
+++ b/src/corelib/tools/qcommandlineoption.cpp
@@ -49,14 +49,12 @@ class QCommandLineOptionPrivate : public QSharedData
public:
Q_NEVER_INLINE
explicit QCommandLineOptionPrivate(const QString &name)
- : names(removeInvalidNames(QStringList(name))),
- hidden(false)
+ : names(removeInvalidNames(QStringList(name)))
{ }
Q_NEVER_INLINE
explicit QCommandLineOptionPrivate(const QStringList &names)
- : names(removeInvalidNames(names)),
- hidden(false)
+ : names(removeInvalidNames(names))
{ }
static QStringList removeInvalidNames(QStringList nameList);
@@ -74,8 +72,7 @@ public:
//! The list of default values used for this option.
QStringList defaultValues;
- //! Show or hide in --help
- bool hidden;
+ QCommandLineOption::Flags flags;
};
/*!
@@ -394,6 +391,7 @@ QStringList QCommandLineOption::defaultValues() const
return d->defaultValues;
}
+#if QT_DEPRECATED_SINCE(5, 8)
/*!
Sets whether to hide this option in the user-visible help output.
@@ -401,11 +399,12 @@ QStringList QCommandLineOption::defaultValues() const
a particular option makes it internal, i.e. not listed in the help output.
\since 5.6
+ \obsolete Use setFlags(QCommandLineOption::HiddenFromHelp), QCommandLineOption::HiddenFromHelp
\sa isHidden
*/
void QCommandLineOption::setHidden(bool hide)
{
- d->hidden = hide;
+ d->flags.setFlag(HiddenFromHelp, hide);
}
/*!
@@ -413,11 +412,52 @@ void QCommandLineOption::setHidden(bool hide)
false if the option is listed.
\since 5.6
- \sa setHidden()
+ \obsolete Use flags() & QCommandLineOption::HiddenFromHelp
+ \sa setHidden(), QCommandLineOption::HiddenFromHelp
*/
bool QCommandLineOption::isHidden() const
{
- return d->hidden;
+ return d->flags & HiddenFromHelp;
}
+#endif
+
+/*!
+ Returns a set of flags that affect this command-line option.
+
+ \since 5.8
+ \sa setFlags(), QCommandLineOption::Flags
+ */
+QCommandLineOption::Flags QCommandLineOption::flags() const
+{
+ return d->flags;
+}
+
+/*!
+ Set the set of flags that affect this command-line option to \a flags.
+
+ \since 5.8
+ \sa flags(), QCommandLineOption::Flags
+ */
+void QCommandLineOption::setFlags(Flags flags)
+{
+ d->flags = flags;
+}
+
+/*!
+ \enum QCommandLineOption::Flag
+
+ \value HiddenFromHelp Hide this option in the user-visible help output. All
+ options are visible by default. Setting this flag for a particular
+ option makes it internal, i.e. not listed in the help output.
+
+ \value ShortOptionStyle The option will always be understood as a short
+ option, regardless of what was set by
+ QCommandLineParser::setSingleDashWordOptionMode.
+ This allows flags such as \c{-DDEFINE=VALUE} or \c{-I/include/path} to be
+ interpreted as short flags even when the parser is in
+ QCommandLineParser::ParseAsLongOptions mode.
+
+ \sa QCommandLineOption::setFlags(), QCommandLineOption::flags()
+*/
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qcommandlineoption.h b/src/corelib/tools/qcommandlineoption.h
index a7747f9fb2..6ebaab3d48 100644
--- a/src/corelib/tools/qcommandlineoption.h
+++ b/src/corelib/tools/qcommandlineoption.h
@@ -50,6 +50,12 @@ class QCommandLineOptionPrivate;
class Q_CORE_EXPORT QCommandLineOption
{
public:
+ enum Flag {
+ HiddenFromHelp = 0x1,
+ ShortOptionStyle = 0x2
+ };
+ Q_DECLARE_FLAGS(Flags, Flag)
+
explicit QCommandLineOption(const QString &name);
explicit QCommandLineOption(const QStringList &names);
/*implicit*/ QCommandLineOption(const QString &name, const QString &description,
@@ -82,14 +88,24 @@ public:
void setDefaultValues(const QStringList &defaultValues);
QStringList defaultValues() const;
+ Flags flags() const;
+ void setFlags(Flags aflags);
+
+#if QT_DEPRECATED_SINCE(5, 8)
+ QT_DEPRECATED_X("Use setFlags() with HiddenFromHelp)")
void setHidden(bool hidden);
+ QT_DEPRECATED_X("Use flags() and HiddenFromHelp")
bool isHidden() const;
+#endif
+
private:
QSharedDataPointer<QCommandLineOptionPrivate> d;
};
Q_DECLARE_SHARED(QCommandLineOption)
+Q_DECLARE_OPERATORS_FOR_FLAGS(QCommandLineOption::Flags)
+
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp
index 7db0920a29..4c55880915 100644
--- a/src/corelib/tools/qcommandlineparser.cpp
+++ b/src/corelib/tools/qcommandlineparser.cpp
@@ -44,7 +44,7 @@
#include <qhash.h>
#include <qvector.h>
#include <qdebug.h>
-#if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WINRT)
# include <qt_windows.h>
#endif
#include <stdio.h>
@@ -297,7 +297,9 @@ QCommandLineParser::~QCommandLineParser()
i.e. as the long option named \c{abc}. This is how Qt's own tools
(uic, rcc...) have always been parsing arguments. This mode should be
used for preserving compatibility in applications that were parsing
- arguments in such a way.
+ arguments in such a way. There is an exception if the \c{a} option has the
+ QCommandLineOption::ShortOptionStyle flag set, in which case it is still
+ interpreted as \c{-a bc}.
\sa setSingleDashWordOptionMode()
*/
@@ -532,7 +534,7 @@ QString QCommandLineParser::errorText() const
enum MessageType { UsageMessage, ErrorMessage };
-#if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WINRT)
// Return whether to use a message box. Use handles if a console can be obtained
// or we are run with redirected handles (for example, by QProcess).
static inline bool displayMessageBox()
@@ -554,7 +556,7 @@ static void showParserMessage(const QString &message, MessageType type)
else
qCritical(qPrintable(message));
return;
-#elif defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WINCE)
+#elif defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED)
if (displayMessageBox()) {
const UINT flags = MB_OK | MB_TOPMOST | MB_SETFOREGROUND
| (type == UsageMessage ? MB_ICONINFORMATION : MB_ICONERROR);
@@ -567,7 +569,7 @@ static void showParserMessage(const QString &message, MessageType type)
reinterpret_cast<const wchar_t *>(title.utf16()), flags);
return;
}
-#endif // Q_OS_WIN && !QT_BOOTSTRAPPED && !Q_OS_WINCE
+#endif // Q_OS_WIN && !QT_BOOTSTRAPPED
fputs(qPrintable(message), type == UsageMessage ? stdout : stderr);
}
@@ -765,6 +767,18 @@ bool QCommandLineParserPrivate::parse(const QStringList &args)
}
case QCommandLineParser::ParseAsLongOptions:
{
+ if (argument.size() > 2) {
+ const QString possibleShortOptionStyleName = argument.mid(1, 1);
+ const auto shortOptionIt = nameHash.constFind(possibleShortOptionStyleName);
+ if (shortOptionIt != nameHash.constEnd()) {
+ const auto &arg = commandLineOptionList.at(*shortOptionIt);
+ if (arg.flags() & QCommandLineOption::ShortOptionStyle) {
+ registerFoundOption(possibleShortOptionStyleName);
+ optionValuesHash[*shortOptionIt].append(argument.mid(2));
+ break;
+ }
+ }
+ }
const QString optionName = argument.mid(1).section(assignChar, 0, 0);
if (registerFoundOption(optionName)) {
if (!parseOptionValue(optionName, argument, &argumentIterator, args.end()))
@@ -1103,7 +1117,7 @@ QString QCommandLineParserPrivate::helpText() const
optionNameList.reserve(commandLineOptionList.size());
int longestOptionNameString = 0;
for (const QCommandLineOption &option : commandLineOptionList) {
- if (option.isHidden())
+ if (option.flags() & QCommandLineOption::HiddenFromHelp)
continue;
const QStringList optionNames = option.names();
QString optionNamesString;
@@ -1122,7 +1136,7 @@ QString QCommandLineParserPrivate::helpText() const
++longestOptionNameString;
auto optionNameIterator = optionNameList.cbegin();
for (const QCommandLineOption &option : commandLineOptionList) {
- if (option.isHidden())
+ if (option.flags() & QCommandLineOption::HiddenFromHelp)
continue;
text += wrapText(*optionNameIterator, longestOptionNameString, option.description());
++optionNameIterator;
diff --git a/src/corelib/tools/qcryptographichash.h b/src/corelib/tools/qcryptographichash.h
index a19c734768..0f17baa036 100644
--- a/src/corelib/tools/qcryptographichash.h
+++ b/src/corelib/tools/qcryptographichash.h
@@ -42,6 +42,7 @@
#define QCRYPTOGRAPHICHASH_H
#include <QtCore/qbytearray.h>
+#include <QtCore/qobjectdefs.h>
QT_BEGIN_NAMESPACE
@@ -51,6 +52,7 @@ class QIODevice;
class Q_CORE_EXPORT QCryptographicHash
{
+ Q_GADGET
public:
enum Algorithm {
#ifndef QT_CRYPTOGRAPHICHASH_ONLY_SHA1
@@ -69,6 +71,7 @@ public:
Sha3_512
#endif
};
+ Q_ENUM(Algorithm)
explicit QCryptographicHash(Algorithm method);
~QCryptographicHash();
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index a8010af74c..ee5ee5c362 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -57,9 +57,6 @@
#include <time.h>
#ifdef Q_OS_WIN
# include <qt_windows.h>
-# ifdef Q_OS_WINCE
-# include "qfunctions_wince.h"
-# endif
# ifdef Q_OS_WINRT
# include "qfunctions_winrt.h"
# endif
@@ -71,8 +68,6 @@
QT_BEGIN_NAMESPACE
-Q_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer<QDateTimePrivate>, defaultDateTimePrivate, (new QDateTimePrivate()))
-
/*****************************************************************************
Date/Time Constants
*****************************************************************************/
@@ -1685,9 +1680,6 @@ QString QTime::toString(const QString& format) const
bool QTime::setHMS(int h, int m, int s, int ms)
{
-#if defined(Q_OS_WINCE)
- startTick = NullTime;
-#endif
if (!isValid(h,m,s,ms)) {
mds = NullTime; // make this invalid
return false;
@@ -1767,10 +1759,6 @@ QTime QTime::addMSecs(int ms) const
t.mds = (ds() + ms) % MSECS_PER_DAY;
}
}
-#if defined(Q_OS_WINCE)
- if (startTick > NullTime)
- t.startTick = (startTick + ms) % MSECS_PER_DAY;
-#endif
return t;
}
@@ -1792,13 +1780,7 @@ int QTime::msecsTo(const QTime &t) const
{
if (!isValid() || !t.isValid())
return 0;
-#if defined(Q_OS_WINCE)
- // GetLocalTime() for Windows CE has no milliseconds resolution
- if (t.startTick > NullTime && startTick > NullTime)
- return t.startTick - startTick;
- else
-#endif
- return t.ds() - ds();
+ return t.ds() - ds();
}
@@ -2137,13 +2119,14 @@ int QTime::elapsed() const
QDateTime static helper functions
*****************************************************************************/
+// get the types from QDateTime (through QDateTimePrivate)
+typedef QDateTimePrivate::QDateTimeShortData ShortData;
+typedef QDateTimePrivate::QDateTimeData QDateTimeData;
+
// Calls the platform variant of tzset
static void qt_tzset()
{
-#if defined(Q_OS_WINCE)
- // WinCE doesn't use tzset
- return;
-#elif defined(Q_OS_WIN)
+#if defined(Q_OS_WIN)
_tzset();
#else
tzset();
@@ -2157,12 +2140,7 @@ static void qt_tzset()
// Relies on tzset, mktime, or localtime having been called to populate timezone
static int qt_timezone()
{
-#if defined(Q_OS_WINCE)
- TIME_ZONE_INFORMATION tzi;
- GetTimeZoneInformation(&tzi);
- // Expressed in minutes, convert to seconds
- return (tzi.Bias + tzi.StandardBias) * 60;
-#elif defined(_MSC_VER) && _MSC_VER >= 1400
+#if defined(_MSC_VER)
long offset;
_get_timezone(&offset);
return offset;
@@ -2191,16 +2169,6 @@ static int qt_timezone()
// Returns the tzname, assume tzset has been called already
static QString qt_tzname(QDateTimePrivate::DaylightStatus daylightStatus)
{
-#if defined(Q_OS_WINCE)
- TIME_ZONE_INFORMATION tzi;
- DWORD res = GetTimeZoneInformation(&tzi);
- if (res == TIME_ZONE_ID_UNKNOWN)
- return QString();
- else if (daylightStatus == QDateTimePrivate::DaylightTime)
- return QString::fromWCharArray(tzi.DaylightName);
- else
- return QString::fromWCharArray(tzi.StandardName);
-#else
int isDst = (daylightStatus == QDateTimePrivate::DaylightTime) ? 1 : 0;
#if defined(_MSC_VER) && _MSC_VER >= 1400
size_t s = 0;
@@ -2211,7 +2179,6 @@ static QString qt_tzname(QDateTimePrivate::DaylightStatus daylightStatus)
#else
return QString::fromLocal8Bit(tzname[isDst]);
#endif // Q_OS_WIN
-#endif // Q_OS_WINCE
}
// Calls the platform variant of mktime for the given date, time and daylightStatus,
@@ -2226,48 +2193,6 @@ static qint64 qt_mktime(QDate *date, QTime *time, QDateTimePrivate::DaylightStat
int yy, mm, dd;
date->getDate(&yy, &mm, &dd);
-#if defined(Q_OS_WINCE)
- // WinCE doesn't provide standard C library time functions
- SYSTEMTIME st;
- memset(&st, 0, sizeof(SYSTEMTIME));
- st.wSecond = time->second();
- st.wMinute = time->minute();
- st.wHour = time->hour();
- st.wDay = dd;
- st.wMonth = mm;
- st.wYear = yy;
- FILETIME lft;
- bool valid = SystemTimeToFileTime(&st, &lft);
- FILETIME ft;
- if (valid)
- valid = LocalFileTimeToFileTime(&lft, &ft);
- const time_t secsSinceEpoch = ftToTime_t(ft);
- const time_t localSecs = ftToTime_t(lft);
- TIME_ZONE_INFORMATION tzi;
- GetTimeZoneInformation(&tzi);
- bool isDaylight = false;
- // Check for overflow
- qint64 localDiff = qAbs(localSecs - secsSinceEpoch);
- int daylightOffset = qAbs(tzi.Bias + tzi.DaylightBias) * 60;
- if (localDiff > daylightOffset)
- valid = false;
- else
- isDaylight = (localDiff == daylightOffset);
- if (daylightStatus) {
- if (isDaylight)
- *daylightStatus = QDateTimePrivate::DaylightTime;
- else
- *daylightStatus = QDateTimePrivate::StandardTime;
- }
- if (abbreviation) {
- if (isDaylight)
- *abbreviation = QString::fromWCharArray(tzi.DaylightName);
- else
- *abbreviation = QString::fromWCharArray(tzi.StandardName);
- }
- if (ok)
- *ok = valid;
-#else
// All other platforms provide standard C library time functions
tm local;
memset(&local, 0, sizeof(local)); // tm_[wy]day plus any non-standard fields
@@ -2329,7 +2254,6 @@ static qint64 qt_mktime(QDate *date, QTime *time, QDateTimePrivate::DaylightStat
if (ok)
*ok = false;
}
-#endif // Q_OS_WINCE
return ((qint64)secsSinceEpoch * 1000) + msec;
}
@@ -2345,23 +2269,7 @@ static bool qt_localtime(qint64 msecsSinceEpoch, QDate *localDate, QTime *localT
tm local;
bool valid = false;
-#if defined(Q_OS_WINCE)
- FILETIME utcTime = time_tToFt(secsSinceEpoch);
- FILETIME resultTime;
- valid = FileTimeToLocalFileTime(&utcTime , &resultTime);
- SYSTEMTIME sysTime;
- if (valid)
- valid = FileTimeToSystemTime(&resultTime , &sysTime);
-
- if (valid) {
- local.tm_sec = sysTime.wSecond;
- local.tm_min = sysTime.wMinute;
- local.tm_hour = sysTime.wHour;
- local.tm_mday = sysTime.wDay;
- local.tm_mon = sysTime.wMonth - 1;
- local.tm_year = sysTime.wYear - 1900;
- }
-#elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
+#if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
// localtime() is required to work as if tzset() was called before it.
// localtime_r() does not have this requirement, so make an explicit call.
qt_tzset();
@@ -2574,240 +2482,423 @@ static qint64 localMSecsToEpochMSecs(qint64 localMsecs,
}
}
-/*****************************************************************************
- QDateTimePrivate member functions
- *****************************************************************************/
+static inline bool specCanBeSmall(Qt::TimeSpec spec)
+{
+ return spec == Qt::LocalTime || spec == Qt::UTC;
+}
-QDateTimePrivate::QDateTimePrivate(const QDate &toDate, const QTime &toTime, Qt::TimeSpec toSpec,
- int offsetSeconds)
- : m_msecs(0),
- m_spec(Qt::LocalTime),
- m_offsetFromUtc(0),
- m_status(0)
+static inline bool msecsCanBeSmall(qint64 msecs)
{
- setTimeSpec(toSpec, offsetSeconds);
- setDateTime(toDate, toTime);
+ if (!QDateTimeData::CanBeSmall)
+ return false;
+
+ ShortData sd;
+ sd.msecs = qintptr(msecs);
+ return sd.msecs == msecs;
}
-#ifndef QT_BOOTSTRAPPED
-QDateTimePrivate::QDateTimePrivate(const QDate &toDate, const QTime &toTime,
- const QTimeZone &toTimeZone)
- : m_spec(Qt::TimeZone),
- m_offsetFromUtc(0),
- m_timeZone(toTimeZone),
- m_status(0)
+static Q_DECL_CONSTEXPR inline
+QDateTimePrivate::StatusFlags mergeSpec(QDateTimePrivate::StatusFlags status, Qt::TimeSpec spec)
{
- setDateTime(toDate, toTime);
+ return QDateTimePrivate::StatusFlags((status & ~QDateTimePrivate::TimeSpecMask) |
+ (int(spec) << QDateTimePrivate::TimeSpecShift));
+}
+
+static Q_DECL_CONSTEXPR inline Qt::TimeSpec extractSpec(QDateTimePrivate::StatusFlags status)
+{
+ return Qt::TimeSpec((status & QDateTimePrivate::TimeSpecMask) >> QDateTimePrivate::TimeSpecShift);
+}
+
+// Set the Daylight Status if LocalTime set via msecs
+static Q_DECL_RELAXED_CONSTEXPR inline QDateTimePrivate::StatusFlags
+mergeDaylightStatus(QDateTimePrivate::StatusFlags sf, QDateTimePrivate::DaylightStatus status)
+{
+ sf &= ~QDateTimePrivate::DaylightMask;
+ if (status == QDateTimePrivate::DaylightTime) {
+ sf |= QDateTimePrivate::SetToDaylightTime;
+ } else if (status == QDateTimePrivate::StandardTime) {
+ sf |= QDateTimePrivate::SetToStandardTime;
+ }
+ return sf;
+}
+
+// Get the DST Status if LocalTime set via msecs
+static Q_DECL_RELAXED_CONSTEXPR inline
+QDateTimePrivate::DaylightStatus extractDaylightStatus(QDateTimePrivate::StatusFlags status)
+{
+ if (status & QDateTimePrivate::SetToDaylightTime)
+ return QDateTimePrivate::DaylightTime;
+ if (status & QDateTimePrivate::SetToStandardTime)
+ return QDateTimePrivate::StandardTime;
+ return QDateTimePrivate::UnknownDaylightTime;
}
-#endif // QT_BOOTSTRAPPED
-void QDateTimePrivate::setTimeSpec(Qt::TimeSpec spec, int offsetSeconds)
+static inline qint64 getMSecs(const QDateTimeData &d)
{
- clearValidDateTime();
- clearSetToDaylightStatus();
+ if (d.isShort()) {
+ // same as, but producing better code
+ //return d.data.msecs;
+ return qintptr(d.d) >> 8;
+ }
+ return d->m_msecs;
+}
+
+static inline QDateTimePrivate::StatusFlags getStatus(const QDateTimeData &d)
+{
+ if (d.isShort()) {
+ // same as, but producing better code
+ //return StatusFlag(d.data.status);
+ return QDateTimePrivate::StatusFlag(qintptr(d.d) & 0xFF);
+ }
+ return d->m_status;
+}
+
+static inline Qt::TimeSpec getSpec(const QDateTimeData &d)
+{
+ return extractSpec(getStatus(d));
+}
+
+// Refresh the LocalTime validity and offset
+static void refreshDateTime(QDateTimeData &d)
+{
+ auto status = getStatus(d);
+ const auto spec = extractSpec(status);
+ const qint64 msecs = getMSecs(d);
+ qint64 epochMSecs = 0;
+ int offsetFromUtc = 0;
+ QDate testDate;
+ QTime testTime;
+ Q_ASSERT(spec == Qt::TimeZone || spec == Qt::LocalTime);
#ifndef QT_BOOTSTRAPPED
- m_timeZone = QTimeZone();
+ // If not valid time zone then is invalid
+ if (spec == Qt::TimeZone) {
+ if (!d->m_timeZone.isValid())
+ status &= ~QDateTimePrivate::ValidDateTime;
+ else
+ epochMSecs = QDateTimePrivate::zoneMSecsToEpochMSecs(msecs, d->m_timeZone, &testDate, &testTime);
+ }
#endif // QT_BOOTSTRAPPED
- switch (spec) {
- case Qt::OffsetFromUTC:
- if (offsetSeconds == 0) {
- m_spec = Qt::UTC;
- m_offsetFromUtc = 0;
+ // If not valid date and time then is invalid
+ if (!(status & QDateTimePrivate::ValidDate) || !(status & QDateTimePrivate::ValidTime)) {
+ status &= ~QDateTimePrivate::ValidDateTime;
+ if (status & QDateTimePrivate::ShortData) {
+ d.data.status = status;
} else {
- m_spec = Qt::OffsetFromUTC;
- m_offsetFromUtc = offsetSeconds;
+ d->m_status = status;
+ d->m_offsetFromUtc = 0;
}
+ return;
+ }
+
+ // We have a valid date and time and a Qt::LocalTime or Qt::TimeZone that needs calculating
+ // LocalTime and TimeZone might fall into a "missing" DST transition hour
+ // Calling toEpochMSecs will adjust the returned date/time if it does
+ if (spec == Qt::LocalTime) {
+ auto dstStatus = extractDaylightStatus(status);
+ epochMSecs = localMSecsToEpochMSecs(msecs, &dstStatus, &testDate, &testTime);
+ }
+ if (timeToMSecs(testDate, testTime) == msecs) {
+ status |= QDateTimePrivate::ValidDateTime;
+ // Cache the offset to use in offsetFromUtc()
+ offsetFromUtc = (msecs - epochMSecs) / 1000;
+ } else {
+ status &= ~QDateTimePrivate::ValidDateTime;
+ }
+
+ if (status & QDateTimePrivate::ShortData) {
+ d.data.status = status;
+ } else {
+ d->m_status = status;
+ d->m_offsetFromUtc = offsetFromUtc;
+ }
+}
+
+// Check the UTC / offsetFromUTC validity
+static void checkValidDateTime(QDateTimeData &d)
+{
+ auto status = getStatus(d);
+ auto spec = extractSpec(status);
+ switch (spec) {
+ case Qt::OffsetFromUTC:
+ case Qt::UTC:
+ // for these, a valid date and a valid time imply a valid QDateTime
+ if ((status & QDateTimePrivate::ValidDate) && (status & QDateTimePrivate::ValidTime))
+ status |= QDateTimePrivate::ValidDateTime;
+ else
+ status &= ~QDateTimePrivate::ValidDateTime;
+ if (status & QDateTimePrivate::ShortData)
+ d.data.status = status;
+ else
+ d->m_status = status;
break;
case Qt::TimeZone:
- // Use system time zone instead
- m_spec = Qt::LocalTime;
- m_offsetFromUtc = 0;
+ case Qt::LocalTime:
+ // for these, we need to check whether the timezone is valid and whether
+ // the time is valid in that timezone. Expensive, but no other option.
+ refreshDateTime(d);
+ break;
+ }
+}
+
+static void setTimeSpec(QDateTimeData &d, Qt::TimeSpec spec, int offsetSeconds)
+{
+ auto status = getStatus(d);
+ status &= ~(QDateTimePrivate::ValidDateTime | QDateTimePrivate::DaylightMask |
+ QDateTimePrivate::TimeSpecMask);
+
+ switch (spec) {
+ case Qt::OffsetFromUTC:
+ if (offsetSeconds == 0)
+ spec = Qt::UTC;
break;
+ case Qt::TimeZone:
+ // Use system time zone instead
+ spec = Qt::LocalTime;
+ // fallthrough
case Qt::UTC:
case Qt::LocalTime:
- m_spec = spec;
- m_offsetFromUtc = 0;
+ offsetSeconds = 0;
break;
}
+
+ status = mergeSpec(status, spec);
+ if (d.isShort() && offsetSeconds == 0) {
+ d.data.status = status;
+ } else {
+ d.detach();
+ d->m_status = status & ~QDateTimePrivate::ShortData;
+ d->m_offsetFromUtc = offsetSeconds;
+#ifndef QT_BOOTSTRAPPED
+ d->m_timeZone = QTimeZone();
+#endif // QT_BOOTSTRAPPED
+ }
}
-void QDateTimePrivate::setDateTime(const QDate &date, const QTime &time)
+static void setDateTime(QDateTimeData &d, const QDate &date, const QTime &time)
{
// If the date is valid and the time is not we set time to 00:00:00
QTime useTime = time;
if (!useTime.isValid() && date.isValid())
useTime = QTime::fromMSecsSinceStartOfDay(0);
- StatusFlags newStatus;
+ QDateTimePrivate::StatusFlags newStatus = 0;
// Set date value and status
qint64 days = 0;
if (date.isValid()) {
days = date.toJulianDay() - JULIAN_DAY_FOR_EPOCH;
- newStatus = ValidDate;
- } else if (date.isNull()) {
- newStatus = NullDate;
+ newStatus = QDateTimePrivate::ValidDate;
}
// Set time value and status
int ds = 0;
if (useTime.isValid()) {
ds = useTime.msecsSinceStartOfDay();
- newStatus |= ValidTime;
- } else if (time.isNull()) {
- newStatus |= NullTime;
+ newStatus |= QDateTimePrivate::ValidTime;
}
// Set msecs serial value
- m_msecs = (days * MSECS_PER_DAY) + ds;
- m_status = newStatus;
+ qint64 msecs = (days * MSECS_PER_DAY) + ds;
+ if (d.isShort()) {
+ // let's see if we can keep this short
+ if (msecsCanBeSmall(msecs)) {
+ // yes, we can
+ d.data.msecs = qintptr(msecs);
+ d.data.status &= ~(QDateTimePrivate::ValidityMask | QDateTimePrivate::DaylightMask);
+ d.data.status |= newStatus;
+ } else {
+ // nope...
+ d.detach();
+ }
+ }
+ if (!d.isShort()) {
+ d.detach();
+ d->m_msecs = msecs;
+ d->m_status &= ~(QDateTimePrivate::ValidityMask | QDateTimePrivate::DaylightMask);
+ d->m_status |= newStatus;
+ }
// Set if date and time are valid
- checkValidDateTime();
+ checkValidDateTime(d);
}
-QPair<QDate, QTime> QDateTimePrivate::getDateTime() const
+static QPair<QDate, QTime> getDateTime(const QDateTimeData &d)
{
QPair<QDate, QTime> result;
- msecsToTime(m_msecs, &result.first, &result.second);
+ qint64 msecs = getMSecs(d);
+ auto status = getStatus(d);
+ msecsToTime(msecs, &result.first, &result.second);
- if (isNullDate())
+ if (!status.testFlag(QDateTimePrivate::ValidDate))
result.first = QDate();
- if (isNullTime())
+ if (!status.testFlag(QDateTimePrivate::ValidTime))
result.second = QTime();
return result;
}
-// Set the Daylight Status if LocalTime set via msecs
-void QDateTimePrivate::setDaylightStatus(QDateTimePrivate::DaylightStatus status)
-{
- if (status == DaylightTime) {
- m_status = m_status & ~SetToStandardTime;
- m_status = m_status | SetToDaylightTime;
- } else if (status == StandardTime) {
- m_status = m_status & ~SetToDaylightTime;
- m_status = m_status | SetToStandardTime;
+/*****************************************************************************
+ QDateTime::Data member functions
+ *****************************************************************************/
+
+inline QDateTime::Data::Data()
+{
+ // default-constructed data has a special exception:
+ // it can be small even if CanBeSmall == false
+ // (optimization so we don't allocate memory in the default constructor)
+ quintptr value = quintptr(mergeSpec(QDateTimePrivate::ShortData, Qt::LocalTime));
+ d = reinterpret_cast<QDateTimePrivate *>(value);
+}
+
+inline QDateTime::Data::Data(Qt::TimeSpec spec)
+{
+ if (CanBeSmall && Q_LIKELY(specCanBeSmall(spec))) {
+ d = reinterpret_cast<QDateTimePrivate *>(quintptr(mergeSpec(QDateTimePrivate::ShortData, spec)));
} else {
- clearSetToDaylightStatus();
+ // the structure is too small, we need to detach
+ d = new QDateTimePrivate;
+ d->ref.ref();
+ d->m_status = mergeSpec(0, spec);
}
}
-// Get the DST Status if LocalTime set via msecs
-QDateTimePrivate::DaylightStatus QDateTimePrivate::daylightStatus() const
+inline QDateTime::Data::Data(const Data &other)
+ : d(other.d)
{
- if ((m_status & SetToDaylightTime) == SetToDaylightTime)
- return DaylightTime;
- if ((m_status & SetToStandardTime) == SetToStandardTime)
- return StandardTime;
- return UnknownDaylightTime;
+ if (!isShort()) {
+ // check if we could shrink
+ if (specCanBeSmall(extractSpec(d->m_status)) && msecsCanBeSmall(d->m_msecs)) {
+ ShortData sd;
+ sd.msecs = qintptr(d->m_msecs);
+ sd.status = d->m_status | QDateTimePrivate::ShortData;
+ data = sd;
+ } else {
+ // no, have to keep it big
+ d->ref.ref();
+ }
+ }
}
-qint64 QDateTimePrivate::toMSecsSinceEpoch() const
+inline QDateTime::Data::Data(Data &&other)
+ : d(other.d)
{
- switch (m_spec) {
- case Qt::OffsetFromUTC:
- case Qt::UTC:
- return (m_msecs - (m_offsetFromUtc * 1000));
+ // reset the other to a short state
+ Data dummy;
+ Q_ASSERT(dummy.isShort());
+ other.d = dummy.d;
+}
- case Qt::LocalTime: {
- // recalculate the local timezone
- DaylightStatus status = daylightStatus();
- return localMSecsToEpochMSecs(m_msecs, &status);
- }
+inline QDateTime::Data &QDateTime::Data::operator=(const Data &other)
+{
+ if (d == other.d)
+ return *this;
- case Qt::TimeZone:
-#ifdef QT_BOOTSTRAPPED
- return 0;
-#else
- return zoneMSecsToEpochMSecs(m_msecs, m_timeZone);
-#endif
+ auto x = d;
+ d = other.d;
+ if (!other.isShort()) {
+ // check if we could shrink
+ if (specCanBeSmall(extractSpec(other.d->m_status)) && msecsCanBeSmall(other.d->m_msecs)) {
+ ShortData sd;
+ sd.msecs = qintptr(other.d->m_msecs);
+ sd.status = other.d->m_status | QDateTimePrivate::ShortData;
+ data = sd;
+ } else {
+ // no, have to keep it big
+ other.d->ref.ref();
+ }
}
- Q_UNREACHABLE();
- return 0;
+
+ if (!(quintptr(x) & QDateTimePrivate::ShortData) && !x->ref.deref())
+ delete x;
+ return *this;
}
-// Check the UTC / offsetFromUTC validity
-void QDateTimePrivate::checkValidDateTime()
+inline QDateTime::Data::~Data()
{
- switch (m_spec) {
- case Qt::OffsetFromUTC:
- case Qt::UTC:
- // for these, a valid date and a valid time imply a valid QDateTime
- if (isValidDate() && isValidTime())
- setValidDateTime();
- else
- clearValidDateTime();
- break;
- case Qt::TimeZone:
- case Qt::LocalTime:
- // for these, we need to check whether the timezone is valid and whether
- // the time is valid in that timezone. Expensive, but no other option.
- refreshDateTime();
- break;
- }
+ if (!isShort() && !d->ref.deref())
+ delete d;
}
-// Refresh the LocalTime validity and offset
-void QDateTimePrivate::refreshDateTime()
+inline bool QDateTime::Data::isShort() const
{
- switch (m_spec) {
- case Qt::OffsetFromUTC:
- case Qt::UTC:
- // Always set by setDateTime so just return
- return;
- case Qt::TimeZone:
- case Qt::LocalTime:
- break;
- }
-
- // If not valid date and time then is invalid
- if (!isValidDate() || !isValidTime()) {
- clearValidDateTime();
- m_offsetFromUtc = 0;
- return;
- }
+ bool b = quintptr(d) & QDateTimePrivate::ShortData;
-#ifndef QT_BOOTSTRAPPED
- // If not valid time zone then is invalid
- if (m_spec == Qt::TimeZone && !m_timeZone.isValid()) {
- clearValidDateTime();
- m_offsetFromUtc = 0;
- return;
- }
-#endif // QT_BOOTSTRAPPED
+ // even if CanBeSmall = false, we have short data for a default-constructed
+ // QDateTime object. But it's unlikely.
+ if (CanBeSmall)
+ return Q_LIKELY(b);
+ return Q_UNLIKELY(b);
+}
- // We have a valid date and time and a Qt::LocalTime or Qt::TimeZone that needs calculating
- // LocalTime and TimeZone might fall into a "missing" DST transition hour
- // Calling toEpochMSecs will adjust the returned date/time if it does
- QDate testDate;
- QTime testTime;
- qint64 epochMSecs = 0;
- if (m_spec == Qt::LocalTime) {
- DaylightStatus status = daylightStatus();
- epochMSecs = localMSecsToEpochMSecs(m_msecs, &status, &testDate, &testTime);
-#ifndef QT_BOOTSTRAPPED
- } else {
- epochMSecs = zoneMSecsToEpochMSecs(m_msecs, m_timeZone, &testDate, &testTime);
-#endif // QT_BOOTSTRAPPED
- }
- if (timeToMSecs(testDate, testTime) == m_msecs) {
- setValidDateTime();
- // Cache the offset to use in toMSecsSinceEpoch()
- m_offsetFromUtc = (m_msecs - epochMSecs) / 1000;
+inline void QDateTime::Data::detach()
+{
+ QDateTimePrivate *x;
+ bool wasShort = isShort();
+ if (wasShort) {
+ // force enlarging
+ x = new QDateTimePrivate;
+ x->m_status = QDateTimePrivate::StatusFlag(data.status & ~QDateTimePrivate::ShortData);
+ x->m_msecs = data.msecs;
} else {
- clearValidDateTime();
- m_offsetFromUtc = 0;
+ if (d->ref.load() == 1)
+ return;
+
+ x = new QDateTimePrivate(*d);
}
+
+ x->ref.store(1);
+ if (!wasShort && !d->ref.deref())
+ delete d;
+ d = x;
+}
+
+inline const QDateTimePrivate *QDateTime::Data::operator->() const
+{
+ Q_ASSERT(!isShort());
+ return d;
+}
+
+inline QDateTimePrivate *QDateTime::Data::operator->()
+{
+ // should we attempt to detach here?
+ Q_ASSERT(!isShort());
+ Q_ASSERT(d->ref.load() == 1);
+ return d;
+}
+
+/*****************************************************************************
+ QDateTimePrivate member functions
+ *****************************************************************************/
+
+Q_NEVER_INLINE
+QDateTime::Data QDateTimePrivate::create(const QDate &toDate, const QTime &toTime, Qt::TimeSpec toSpec,
+ int offsetSeconds)
+{
+ QDateTime::Data result(toSpec);
+ setTimeSpec(result, toSpec, offsetSeconds);
+ setDateTime(result, toDate, toTime);
+ return result;
}
#ifndef QT_BOOTSTRAPPED
+inline QDateTime::Data QDateTimePrivate::create(const QDate &toDate, const QTime &toTime,
+ const QTimeZone &toTimeZone)
+{
+ QDateTime::Data result(Qt::TimeZone);
+ Q_ASSERT(!result.isShort());
+
+ result.d->m_status = mergeSpec(result.d->m_status, Qt::TimeZone);
+ result.d->m_timeZone = toTimeZone;
+ setDateTime(result, toDate, toTime);
+ return result;
+}
+
// Convert a TimeZone time expressed in zone msecs encoding into a UTC epoch msecs
-qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QTimeZone &zone,
- QDate *localDate, QTime *localTime)
+inline qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QTimeZone &zone,
+ QDate *localDate, QTime *localTime)
{
// Get the effective data from QTimeZone
QTimeZonePrivate::Data data = zone.d->dataForLocalTime(zoneMSecs);
@@ -2958,8 +3049,7 @@ qint64 QDateTimePrivate::zoneMSecsToEpochMSecs(qint64 zoneMSecs, const QTimeZone
\sa isValid()
*/
-QDateTime::QDateTime()
- : d(*defaultDateTimePrivate())
+QDateTime::QDateTime() Q_DECL_NOEXCEPT_EXPR(Data::CanBeSmall)
{
}
@@ -2970,7 +3060,7 @@ QDateTime::QDateTime()
*/
QDateTime::QDateTime(const QDate &date)
- : d(new QDateTimePrivate(date, QTime(0, 0, 0), Qt::LocalTime, 0))
+ : d(QDateTimePrivate::create(date, QTime(0, 0, 0), Qt::LocalTime, 0))
{
}
@@ -2990,7 +3080,7 @@ QDateTime::QDateTime(const QDate &date)
*/
QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec)
- : d(new QDateTimePrivate(date, time, spec, 0))
+ : d(QDateTimePrivate::create(date, time, spec, 0))
{
}
@@ -3013,7 +3103,7 @@ QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec)
*/
QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec, int offsetSeconds)
- : d(new QDateTimePrivate(date, time, spec, offsetSeconds))
+ : d(QDateTimePrivate::create(date, time, spec, offsetSeconds))
{
}
@@ -3030,7 +3120,7 @@ QDateTime::QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec, in
*/
QDateTime::QDateTime(const QDate &date, const QTime &time, const QTimeZone &timeZone)
- : d(new QDateTimePrivate(date, time, timeZone))
+ : d(QDateTimePrivate::create(date, time, timeZone))
{
}
#endif // QT_BOOTSTRAPPED
@@ -3038,13 +3128,22 @@ QDateTime::QDateTime(const QDate &date, const QTime &time, const QTimeZone &time
/*!
Constructs a copy of the \a other datetime.
*/
-
-QDateTime::QDateTime(const QDateTime &other)
+QDateTime::QDateTime(const QDateTime &other) Q_DECL_NOTHROW
: d(other.d)
{
}
/*!
+ \since 5.8
+ Moves the content of the temporary \a other datetime to this object and
+ leaves \a other in an unspecified (but proper) state.
+*/
+QDateTime::QDateTime(QDateTime &&other) Q_DECL_NOTHROW
+ : d(std::move(other.d))
+{
+}
+
+/*!
Destroys the datetime.
*/
QDateTime::~QDateTime()
@@ -3056,7 +3155,7 @@ QDateTime::~QDateTime()
copy.
*/
-QDateTime &QDateTime::operator=(const QDateTime &other)
+QDateTime &QDateTime::operator=(const QDateTime &other) Q_DECL_NOTHROW
{
d = other.d;
return *this;
@@ -3078,7 +3177,9 @@ QDateTime &QDateTime::operator=(const QDateTime &other)
bool QDateTime::isNull() const
{
- return d->isNullDate() && d->isNullTime();
+ auto status = getStatus(d);
+ return !status.testFlag(QDateTimePrivate::ValidDate) &&
+ !status.testFlag(QDateTimePrivate::ValidTime);
}
/*!
@@ -3095,7 +3196,8 @@ bool QDateTime::isNull() const
bool QDateTime::isValid() const
{
- return (d->isValidDateTime());
+ auto status = getStatus(d);
+ return status & QDateTimePrivate::ValidDateTime;
}
/*!
@@ -3106,10 +3208,11 @@ bool QDateTime::isValid() const
QDate QDateTime::date() const
{
- if (d->isNullDate())
+ auto status = getStatus(d);
+ if (!status.testFlag(QDateTimePrivate::ValidDate))
return QDate();
QDate dt;
- msecsToTime(d->m_msecs, &dt, 0);
+ msecsToTime(getMSecs(d), &dt, 0);
return dt;
}
@@ -3121,10 +3224,11 @@ QDate QDateTime::date() const
QTime QDateTime::time() const
{
- if (d->isNullTime())
+ auto status = getStatus(d);
+ if (!status.testFlag(QDateTimePrivate::ValidTime))
return QTime();
QTime tm;
- msecsToTime(d->m_msecs, 0, &tm);
+ msecsToTime(getMSecs(d), 0, &tm);
return tm;
}
@@ -3136,7 +3240,7 @@ QTime QDateTime::time() const
Qt::TimeSpec QDateTime::timeSpec() const
{
- return d->m_spec;
+ return getSpec(d);
}
#ifndef QT_BOOTSTRAPPED
@@ -3154,7 +3258,7 @@ Qt::TimeSpec QDateTime::timeSpec() const
QTimeZone QDateTime::timeZone() const
{
- switch (d->m_spec) {
+ switch (getSpec(d)) {
case Qt::UTC:
return QTimeZone::utc();
case Qt::OffsetFromUTC:
@@ -3189,7 +3293,20 @@ QTimeZone QDateTime::timeZone() const
int QDateTime::offsetFromUtc() const
{
- return d->m_offsetFromUtc;
+ if (!d.isShort())
+ return d->m_offsetFromUtc;
+ if (!isValid())
+ return 0;
+
+ auto spec = getSpec(d);
+ if (spec == Qt::LocalTime) {
+ // we didn't cache the value, so we need to calculate it now...
+ qint64 msecs = getMSecs(d);
+ return (msecs - toMSecsSinceEpoch()) / 1000;
+ }
+
+ Q_ASSERT(spec == Qt::UTC);
+ return 0;
}
/*!
@@ -3215,7 +3332,7 @@ int QDateTime::offsetFromUtc() const
QString QDateTime::timeZoneAbbreviation() const
{
- switch (d->m_spec) {
+ switch (getSpec(d)) {
case Qt::UTC:
return QTimeZonePrivate::utcQString();
case Qt::OffsetFromUTC:
@@ -3224,12 +3341,12 @@ QString QDateTime::timeZoneAbbreviation() const
#ifdef QT_BOOTSTRAPPED
break;
#else
- return d->m_timeZone.d->abbreviation(d->toMSecsSinceEpoch());
+ return d->m_timeZone.d->abbreviation(toMSecsSinceEpoch());
#endif // QT_BOOTSTRAPPED
case Qt::LocalTime: {
QString abbrev;
- QDateTimePrivate::DaylightStatus status = d->daylightStatus();
- localMSecsToEpochMSecs(d->m_msecs, &status, 0, 0, &abbrev);
+ auto status = extractDaylightStatus(getStatus(d));
+ localMSecsToEpochMSecs(getMSecs(d), &status, 0, 0, &abbrev);
return abbrev;
}
}
@@ -3249,7 +3366,7 @@ QString QDateTime::timeZoneAbbreviation() const
bool QDateTime::isDaylightTime() const
{
- switch (d->m_spec) {
+ switch (getSpec(d)) {
case Qt::UTC:
case Qt::OffsetFromUTC:
return false;
@@ -3260,9 +3377,9 @@ bool QDateTime::isDaylightTime() const
return d->m_timeZone.d->isDaylightTime(toMSecsSinceEpoch());
#endif // QT_BOOTSTRAPPED
case Qt::LocalTime: {
- QDateTimePrivate::DaylightStatus status = d->daylightStatus();
+ auto status = extractDaylightStatus(getStatus(d));
if (status == QDateTimePrivate::UnknownDaylightTime)
- localMSecsToEpochMSecs(d->m_msecs, &status);
+ localMSecsToEpochMSecs(getMSecs(d), &status);
return (status == QDateTimePrivate::DaylightTime);
}
}
@@ -3278,7 +3395,7 @@ bool QDateTime::isDaylightTime() const
void QDateTime::setDate(const QDate &date)
{
- d->setDateTime(date, time());
+ setDateTime(d, date, time());
}
/*!
@@ -3296,7 +3413,7 @@ void QDateTime::setDate(const QDate &date)
void QDateTime::setTime(const QTime &time)
{
- d->setDateTime(date(), time);
+ setDateTime(d, date(), time);
}
/*!
@@ -3317,9 +3434,8 @@ void QDateTime::setTime(const QTime &time)
void QDateTime::setTimeSpec(Qt::TimeSpec spec)
{
- QDateTimePrivate *d = this->d.data(); // detaches (and shadows d)
- d->setTimeSpec(spec, 0);
- d->checkValidDateTime();
+ QT_PREPEND_NAMESPACE(setTimeSpec(d, spec, 0));
+ checkValidDateTime(d);
}
/*!
@@ -3339,9 +3455,8 @@ void QDateTime::setTimeSpec(Qt::TimeSpec spec)
void QDateTime::setOffsetFromUtc(int offsetSeconds)
{
- QDateTimePrivate *d = this->d.data(); // detaches (and shadows d)
- d->setTimeSpec(Qt::OffsetFromUTC, offsetSeconds);
- d->checkValidDateTime();
+ QT_PREPEND_NAMESPACE(setTimeSpec(d, Qt::OffsetFromUTC, offsetSeconds));
+ checkValidDateTime(d);
}
#ifndef QT_BOOTSTRAPPED
@@ -3358,11 +3473,11 @@ void QDateTime::setOffsetFromUtc(int offsetSeconds)
void QDateTime::setTimeZone(const QTimeZone &toZone)
{
- QDateTimePrivate *d = this->d.data(); // detaches (and shadows d)
- d->m_spec = Qt::TimeZone;
+ d.detach(); // always detach
+ d->m_status = mergeSpec(d->m_status, Qt::TimeZone);
d->m_offsetFromUtc = 0;
d->m_timeZone = toZone;
- d->refreshDateTime();
+ refreshDateTime(d);
}
#endif // QT_BOOTSTRAPPED
@@ -3379,44 +3494,85 @@ void QDateTime::setTimeZone(const QTimeZone &toZone)
this object is not valid. However, for all valid dates, this function
returns a unique value.
- \sa toTime_t(), setMSecsSinceEpoch()
+ \sa toSecsSinceEpoch(), setMSecsSinceEpoch()
*/
qint64 QDateTime::toMSecsSinceEpoch() const
{
- return d->toMSecsSinceEpoch();
+ switch (getSpec(d)) {
+ case Qt::UTC:
+ return getMSecs(d);
+
+ case Qt::OffsetFromUTC:
+ return d->m_msecs - (d->m_offsetFromUtc * 1000);
+
+ case Qt::LocalTime: {
+ // recalculate the local timezone
+ auto status = extractDaylightStatus(getStatus(d));
+ return localMSecsToEpochMSecs(getMSecs(d), &status);
+ }
+
+ case Qt::TimeZone:
+#ifdef QT_BOOTSTRAPPED
+ return 0;
+#else
+ return QDateTimePrivate::zoneMSecsToEpochMSecs(d->m_msecs, d->m_timeZone);
+#endif
+ }
+ Q_UNREACHABLE();
+ return 0;
+}
+
+/*!
+ \since 5.8
+
+ Returns the datetime as the number of seconds that have passed since
+ 1970-01-01T00:00:00.000, Coordinated Universal Time (Qt::UTC).
+
+ On systems that do not support time zones, this function will
+ behave as if local time were Qt::UTC.
+
+ The behavior for this function is undefined if the datetime stored in
+ this object is not valid. However, for all valid dates, this function
+ returns a unique value.
+
+ \sa toMSecsSinceEpoch(), setSecsSinceEpoch()
+*/
+qint64 QDateTime::toSecsSinceEpoch() const
+{
+ return toMSecsSinceEpoch() / 1000;
}
+#if QT_DEPRECATED_SINCE(5, 8)
/*!
+ \deprecated
+
Returns the datetime as the number of seconds that have passed
since 1970-01-01T00:00:00, Coordinated Universal Time (Qt::UTC).
On systems that do not support time zones, this function will
behave as if local time were Qt::UTC.
- \note This function returns a 32-bit unsigned integer, so it does not
- support dates before 1970, but it does support dates after
- 2038-01-19T03:14:06, which may not be valid time_t values. Be careful
- when passing those time_t values to system functions, which could
- interpret them as negative dates.
+ \note This function returns a 32-bit unsigned integer and is deprecated.
If the date is outside the range 1970-01-01T00:00:00 to
2106-02-07T06:28:14, this function returns -1 cast to an unsigned integer
(i.e., 0xFFFFFFFF).
- To get an extended range, use toMSecsSinceEpoch().
+ To get an extended range, use toMSecsSinceEpoch() or toSecsSinceEpoch().
- \sa toMSecsSinceEpoch(), setTime_t()
+ \sa toSecsSinceEpoch(), toMSecsSinceEpoch(), setTime_t()
*/
uint QDateTime::toTime_t() const
{
if (!isValid())
return uint(-1);
- qint64 retval = d->toMSecsSinceEpoch() / 1000;
+ qint64 retval = toMSecsSinceEpoch() / 1000;
if (quint64(retval) >= Q_UINT64_C(0xFFFFFFFF))
return uint(-1);
return uint(retval);
}
+#endif
/*!
\since 4.7
@@ -3430,65 +3586,98 @@ uint QDateTime::toTime_t() const
(\c{std::numeric_limits<qint64>::min()}) to \a msecs will result in
undefined behavior.
- \sa toMSecsSinceEpoch(), setTime_t()
+ \sa toMSecsSinceEpoch(), setSecsSinceEpoch()
*/
void QDateTime::setMSecsSinceEpoch(qint64 msecs)
{
- QDateTimePrivate *d = this->d.data(); // detaches (and shadows d)
+ const auto spec = getSpec(d);
+ auto status = getStatus(d);
- d->m_status = 0;
- switch (d->m_spec) {
+ status &= ~QDateTimePrivate::ValidityMask;
+ switch (spec) {
case Qt::UTC:
- d->m_msecs = msecs;
- d->m_status = d->m_status
+ status = status
| QDateTimePrivate::ValidDate
| QDateTimePrivate::ValidTime
| QDateTimePrivate::ValidDateTime;
break;
case Qt::OffsetFromUTC:
- d->m_msecs = msecs + (d->m_offsetFromUtc * 1000);
- d->m_status = d->m_status
+ msecs = msecs + (d->m_offsetFromUtc * 1000);
+ status = status
| QDateTimePrivate::ValidDate
| QDateTimePrivate::ValidTime
| QDateTimePrivate::ValidDateTime;
break;
case Qt::TimeZone:
+ Q_ASSERT(!d.isShort());
#ifndef QT_BOOTSTRAPPED
// Docs state any LocalTime before 1970-01-01 will *not* have any DST applied
// but all affected times afterwards will have DST applied.
+ d.detach();
if (msecs >= 0)
d->m_offsetFromUtc = d->m_timeZone.d->offsetFromUtc(msecs);
else
d->m_offsetFromUtc = d->m_timeZone.d->standardTimeOffset(msecs);
- d->m_msecs = msecs + (d->m_offsetFromUtc * 1000);
- d->m_status = d->m_status
+ msecs = msecs + (d->m_offsetFromUtc * 1000);
+ status = status
| QDateTimePrivate::ValidDate
| QDateTimePrivate::ValidTime
| QDateTimePrivate::ValidDateTime;
- d->refreshDateTime();
#endif // QT_BOOTSTRAPPED
break;
case Qt::LocalTime: {
QDate dt;
QTime tm;
- QDateTimePrivate::DaylightStatus status;
- epochMSecsToLocalTime(msecs, &dt, &tm, &status);
- d->setDateTime(dt, tm);
- d->setDaylightStatus(status);
- d->refreshDateTime();
+ QDateTimePrivate::DaylightStatus dstStatus;
+ epochMSecsToLocalTime(msecs, &dt, &tm, &dstStatus);
+ setDateTime(d, dt, tm);
+ msecs = getMSecs(d);
+ status = mergeDaylightStatus(getStatus(d), dstStatus);
break;
}
}
+
+ if (msecsCanBeSmall(msecs) && d.isShort()) {
+ // we can keep short
+ d.data.msecs = qintptr(msecs);
+ d.data.status = status;
+ } else {
+ d.detach();
+ d->m_status = status;
+ d->m_msecs = msecs;
+ }
+
+ if (spec == Qt::LocalTime || spec == Qt::TimeZone)
+ refreshDateTime(d);
}
/*!
+ \since 5.8
+
+ Sets the date and time given the number of seconds \a secs that have
+ passed since 1970-01-01T00:00:00.000, Coordinated Universal Time
+ (Qt::UTC). On systems that do not support time zones this function
+ will behave as if local time were Qt::UTC.
+
+ \sa toSecsSinceEpoch(), setMSecsSinceEpoch()
+*/
+void QDateTime::setSecsSinceEpoch(qint64 secs)
+{
+ setMSecsSinceEpoch(secs * 1000);
+}
+
+#if QT_DEPRECATED_SINCE(5, 8)
+/*!
\fn void QDateTime::setTime_t(uint seconds)
+ \deprecated
Sets the date and time given the number of \a seconds that have
passed since 1970-01-01T00:00:00, Coordinated Universal Time
(Qt::UTC). On systems that do not support time zones this function
will behave as if local time were Qt::UTC.
+ \note This function is deprecated. For new code, use setSecsSinceEpoch().
+
\sa toTime_t()
*/
@@ -3496,6 +3685,7 @@ void QDateTime::setTime_t(uint secsSince1Jan1970UTC)
{
setMSecsSinceEpoch((qint64)secsSince1Jan1970UTC * 1000);
}
+#endif
#ifndef QT_NO_DATESTRING
/*!
@@ -3565,13 +3755,13 @@ QString QDateTime::toString(Qt::DateFormat format) const
return QLocale().toString(*this, QLocale::LongFormat);
case Qt::RFC2822Date: {
buf = QLocale::c().toString(*this, QStringLiteral("dd MMM yyyy hh:mm:ss "));
- buf += toOffsetString(Qt::TextDate, d->m_offsetFromUtc);
+ buf += toOffsetString(Qt::TextDate, offsetFromUtc());
return buf;
}
default:
#ifndef QT_NO_TEXTDATE
case Qt::TextDate: {
- const QPair<QDate, QTime> p = d->getDateTime();
+ const QPair<QDate, QTime> p = getDateTime(d);
const QDate &dt = p.first;
const QTime &tm = p.second;
//We cant use date.toString(Qt::TextDate) as we need to insert the time before the year
@@ -3582,14 +3772,14 @@ QString QDateTime::toString(Qt::DateFormat format) const
.arg(dt.year());
if (timeSpec() != Qt::LocalTime) {
buf += QLatin1String(" GMT");
- if (d->m_spec == Qt::OffsetFromUTC)
- buf += toOffsetString(Qt::TextDate, d->m_offsetFromUtc);
+ if (getSpec(d) == Qt::OffsetFromUTC)
+ buf += toOffsetString(Qt::TextDate, offsetFromUtc());
}
return buf;
}
#endif
case Qt::ISODate: {
- const QPair<QDate, QTime> p = d->getDateTime();
+ const QPair<QDate, QTime> p = getDateTime(d);
const QDate &dt = p.first;
const QTime &tm = p.second;
buf = dt.toString(Qt::ISODate);
@@ -3597,12 +3787,12 @@ QString QDateTime::toString(Qt::DateFormat format) const
return QString(); // failed to convert
buf += QLatin1Char('T');
buf += tm.toString(Qt::ISODate);
- switch (d->m_spec) {
+ switch (getSpec(d)) {
case Qt::UTC:
buf += QLatin1Char('Z');
break;
case Qt::OffsetFromUTC:
- buf += toOffsetString(Qt::ISODate, d->m_offsetFromUtc);
+ buf += toOffsetString(Qt::ISODate, offsetFromUtc());
break;
default:
break;
@@ -3691,12 +3881,7 @@ QString QDateTime::toString(const QString& format) const
}
#endif //QT_NO_DATESTRING
-static void massageAdjustedDateTime(Qt::TimeSpec spec,
-#ifndef QT_BOOTSTRAPPED
- const QTimeZone &zone,
-#endif // QT_BOOTSTRAPPED
- QDate *date,
- QTime *time)
+static inline void massageAdjustedDateTime(const QDateTimeData &d, QDate *date, QTime *time)
{
/*
If we have just adjusted to a day with a DST transition, our given time
@@ -3706,24 +3891,20 @@ static void massageAdjustedDateTime(Qt::TimeSpec spec,
to its DST-ness); but for a time in spring's missing hour it'll adjust the
time while picking a DST-ness. (Handling of autumn is trickier, as either
DST-ness is valid, without adjusting the time. We might want to propagate
- d->daylightStatus() in that case, but it's hard to do so without breaking
+ the daylight status in that case, but it's hard to do so without breaking
(far more common) other cases; and it makes little difference, as the two
answers do then differ only in DST-ness.)
*/
+ auto spec = getSpec(d);
if (spec == Qt::LocalTime) {
QDateTimePrivate::DaylightStatus status = QDateTimePrivate::UnknownDaylightTime;
localMSecsToEpochMSecs(timeToMSecs(*date, *time), &status, date, time);
#ifndef QT_BOOTSTRAPPED
} else if (spec == Qt::TimeZone) {
- QDateTimePrivate::zoneMSecsToEpochMSecs(timeToMSecs(*date, *time), zone, date, time);
+ QDateTimePrivate::zoneMSecsToEpochMSecs(timeToMSecs(*date, *time), d->m_timeZone, date, time);
#endif // QT_BOOTSTRAPPED
}
}
-#ifdef QT_BOOTSTRAPPED // Avoid duplicate #if-ery in uses.
-#define MASSAGEADJUSTEDDATETIME(s, z, d, t) massageAdjustedDateTime(s, d, t)
-#else
-#define MASSAGEADJUSTEDDATETIME(s, z, d, t) massageAdjustedDateTime(s, z, d, t)
-#endif // QT_BOOTSTRAPPED
/*!
Returns a QDateTime object containing a datetime \a ndays days
@@ -3742,12 +3923,12 @@ static void massageAdjustedDateTime(Qt::TimeSpec spec,
QDateTime QDateTime::addDays(qint64 ndays) const
{
QDateTime dt(*this);
- QPair<QDate, QTime> p = d->getDateTime();
+ QPair<QDate, QTime> p = getDateTime(d);
QDate &date = p.first;
QTime &time = p.second;
date = date.addDays(ndays);
- MASSAGEADJUSTEDDATETIME(d->m_spec, d->m_timeZone, &date, &time);
- dt.d->setDateTime(date, time);
+ massageAdjustedDateTime(dt.d, &date, &time);
+ setDateTime(dt.d, date, time);
return dt;
}
@@ -3768,12 +3949,12 @@ QDateTime QDateTime::addDays(qint64 ndays) const
QDateTime QDateTime::addMonths(int nmonths) const
{
QDateTime dt(*this);
- QPair<QDate, QTime> p = d->getDateTime();
+ QPair<QDate, QTime> p = getDateTime(d);
QDate &date = p.first;
QTime &time = p.second;
date = date.addMonths(nmonths);
- MASSAGEADJUSTEDDATETIME(d->m_spec, d->m_timeZone, &date, &time);
- dt.d->setDateTime(date, time);
+ massageAdjustedDateTime(dt.d, &date, &time);
+ setDateTime(dt.d, date, time);
return dt;
}
@@ -3794,15 +3975,14 @@ QDateTime QDateTime::addMonths(int nmonths) const
QDateTime QDateTime::addYears(int nyears) const
{
QDateTime dt(*this);
- QPair<QDate, QTime> p = d->getDateTime();
+ QPair<QDate, QTime> p = getDateTime(d);
QDate &date = p.first;
QTime &time = p.second;
date = date.addYears(nyears);
- MASSAGEADJUSTEDDATETIME(d->m_spec, d->m_timeZone, &date, &time);
- dt.d->setDateTime(date, time);
+ massageAdjustedDateTime(dt.d, &date, &time);
+ setDateTime(dt.d, date, time);
return dt;
}
-#undef MASSAGEADJUSTEDDATETIME
/*!
Returns a QDateTime object containing a datetime \a s seconds
@@ -3834,12 +4014,26 @@ QDateTime QDateTime::addMSecs(qint64 msecs) const
return QDateTime();
QDateTime dt(*this);
- if (d->m_spec == Qt::LocalTime || d->m_spec == Qt::TimeZone)
+ auto spec = getSpec(d);
+ if (spec == Qt::LocalTime || spec == Qt::TimeZone) {
// Convert to real UTC first in case crosses DST transition
- dt.setMSecsSinceEpoch(d->toMSecsSinceEpoch() + msecs);
- else
+ dt.setMSecsSinceEpoch(toMSecsSinceEpoch() + msecs);
+ } else {
// No need to convert, just add on
- dt.d->m_msecs = dt.d->m_msecs + msecs;
+ if (d.isShort()) {
+ // need to check if we need to enlarge first
+ msecs += dt.d.data.msecs;
+ if (msecsCanBeSmall(msecs)) {
+ dt.d.data.msecs = qintptr(msecs);
+ } else {
+ dt.d.detach();
+ dt.d->m_msecs = msecs;
+ }
+ } else {
+ dt.d.detach();
+ dt.d->m_msecs += msecs;
+ }
+ }
return dt;
}
@@ -3905,7 +4099,7 @@ qint64 QDateTime::msecsTo(const QDateTime &other) const
if (!isValid() || !other.isValid())
return 0;
- return other.d->toMSecsSinceEpoch() - d->toMSecsSinceEpoch();
+ return other.toMSecsSinceEpoch() - toMSecsSinceEpoch();
}
/*!
@@ -3928,7 +4122,7 @@ qint64 QDateTime::msecsTo(const QDateTime &other) const
QDateTime QDateTime::toTimeSpec(Qt::TimeSpec spec) const
{
- if (d->m_spec == spec && (spec == Qt::UTC || spec == Qt::LocalTime))
+ if (getSpec(d) == spec && (spec == Qt::UTC || spec == Qt::LocalTime))
return *this;
if (!isValid()) {
@@ -3937,7 +4131,7 @@ QDateTime QDateTime::toTimeSpec(Qt::TimeSpec spec) const
return ret;
}
- return fromMSecsSinceEpoch(d->toMSecsSinceEpoch(), spec, 0);
+ return fromMSecsSinceEpoch(toMSecsSinceEpoch(), spec, 0);
}
/*!
@@ -3955,7 +4149,8 @@ QDateTime QDateTime::toTimeSpec(Qt::TimeSpec spec) const
QDateTime QDateTime::toOffsetFromUtc(int offsetSeconds) const
{
- if (d->m_spec == Qt::OffsetFromUTC && d->m_offsetFromUtc == offsetSeconds)
+ if (getSpec(d) == Qt::OffsetFromUTC
+ && d->m_offsetFromUtc == offsetSeconds)
return *this;
if (!isValid()) {
@@ -3964,7 +4159,7 @@ QDateTime QDateTime::toOffsetFromUtc(int offsetSeconds) const
return ret;
}
- return fromMSecsSinceEpoch(d->toMSecsSinceEpoch(), Qt::OffsetFromUTC, offsetSeconds);
+ return fromMSecsSinceEpoch(toMSecsSinceEpoch(), Qt::OffsetFromUTC, offsetSeconds);
}
#ifndef QT_BOOTSTRAPPED
@@ -3978,7 +4173,7 @@ QDateTime QDateTime::toOffsetFromUtc(int offsetSeconds) const
QDateTime QDateTime::toTimeZone(const QTimeZone &timeZone) const
{
- if (d->m_spec == Qt::TimeZone && d->m_timeZone == timeZone)
+ if (getSpec(d) == Qt::TimeZone && d->m_timeZone == timeZone)
return *this;
if (!isValid()) {
@@ -3987,7 +4182,7 @@ QDateTime QDateTime::toTimeZone(const QTimeZone &timeZone) const
return ret;
}
- return fromMSecsSinceEpoch(d->toMSecsSinceEpoch(), timeZone);
+ return fromMSecsSinceEpoch(toMSecsSinceEpoch(), timeZone);
}
#endif // QT_BOOTSTRAPPED
@@ -4000,10 +4195,9 @@ QDateTime QDateTime::toTimeZone(const QTimeZone &timeZone) const
bool QDateTime::operator==(const QDateTime &other) const
{
- if (d->m_spec == Qt::LocalTime
- && other.d->m_spec == Qt::LocalTime
- && d->m_status == other.d->m_status) {
- return (d->m_msecs == other.d->m_msecs);
+ if (getSpec(d) == Qt::LocalTime
+ && getStatus(d) == getStatus(other.d)) {
+ return getMSecs(d) == getMSecs(other.d);
}
// Convert to UTC and compare
return (toMSecsSinceEpoch() == other.toMSecsSinceEpoch());
@@ -4028,10 +4222,9 @@ bool QDateTime::operator==(const QDateTime &other) const
bool QDateTime::operator<(const QDateTime &other) const
{
- if (d->m_spec == Qt::LocalTime
- && other.d->m_spec == Qt::LocalTime
- && d->m_status == other.d->m_status) {
- return (d->m_msecs < other.d->m_msecs);
+ if (getSpec(d) == Qt::LocalTime
+ && getStatus(d) == getStatus(other.d)) {
+ return getMSecs(d) < getMSecs(other.d);
}
// Convert to UTC and compare
return (toMSecsSinceEpoch() < other.toMSecsSinceEpoch());
@@ -4086,6 +4279,16 @@ bool QDateTime::operator<(const QDateTime &other) const
\sa currentDateTime(), currentDateTimeUtc(), toTime_t(), toTimeSpec()
*/
+/*!
+ \fn qint64 QDateTime::currentSecsSinceEpoch()
+ \since 5.8
+
+ Returns the number of seconds since 1970-01-01T00:00:00 Universal
+ Coordinated Time.
+
+ \sa currentMSecsSinceEpoch()
+*/
+
#if defined(Q_OS_WIN)
static inline uint msecsFromDecomposed(int hour, int minute, int sec, int msec = 0)
{
@@ -4109,9 +4312,6 @@ QTime QTime::currentTime()
memset(&st, 0, sizeof(SYSTEMTIME));
GetLocalTime(&st);
ct.setHMS(st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
-#if defined(Q_OS_WINCE)
- ct.startTick = GetTickCount() % MSECS_PER_DAY;
-#endif
return ct;
}
@@ -4150,6 +4350,17 @@ qint64 QDateTime::currentMSecsSinceEpoch() Q_DECL_NOTHROW
- julianDayFromDate(1970, 1, 1)) * Q_INT64_C(86400000);
}
+qint64 QDateTime::currentSecsSinceEpoch() Q_DECL_NOTHROW
+{
+ SYSTEMTIME st;
+ memset(&st, 0, sizeof(SYSTEMTIME));
+ GetSystemTime(&st);
+
+ return st.wHour * SECS_PER_HOUR + st.wMinute * SECS_PER_MIN + st.wSecond +
+ qint64(julianDayFromDate(st.wYear, st.wMonth, st.wDay)
+ - julianDayFromDate(1970, 1, 1)) * Q_INT64_C(86400);
+}
+
#elif defined(Q_OS_UNIX)
QDate QDate::currentDate()
{
@@ -4180,51 +4391,29 @@ qint64 QDateTime::currentMSecsSinceEpoch() Q_DECL_NOTHROW
return qint64(tv.tv_sec) * Q_INT64_C(1000) + tv.tv_usec / 1000;
}
+qint64 QDateTime::currentSecsSinceEpoch() Q_DECL_NOTHROW
+{
+ struct timeval tv;
+ gettimeofday(&tv, 0);
+ return qint64(tv.tv_sec);
+}
#else
#error "What system is this?"
#endif
-/*! \fn QDateTime QDateTime::fromCFDate(CFDateRef date)
- \since 5.5
-
- Constructs a new QDateTime containing a copy of the CFDate \a date.
-
- \sa toCFDate()
-*/
-
-/*! \fn CFDateRef QDateTime::toCFDate() const
- \since 5.5
-
- Creates a CFDate from a QDateTime. The caller owns the CFDate object
- and is responsible for releasing it.
-
- \sa fromCFDate()
-*/
-
-/*! \fn QDateTime QDateTime::fromNSDate(const NSDate *date)
- \since 5.5
-
- Constructs a new QDateTime containing a copy of the NSDate \a date.
-
- \sa toNSDate()
-*/
-
-/*! \fn NSDate QDateTime::toNSDate() const
- \since 5.5
-
- Creates an NSDate from a QDateTime. The NSDate object is autoreleased.
-
- \sa fromNSDate()
-*/
-
+#if QT_DEPRECATED_SINCE(5, 8)
/*!
\since 4.2
+ \deprecated
Returns a datetime whose date and time are the number of \a seconds
that have passed since 1970-01-01T00:00:00, Coordinated Universal
Time (Qt::UTC) and converted to Qt::LocalTime. On systems that do not
support time zones, the time will be set as if local time were Qt::UTC.
+ \note This function is deprecated. Please use fromSecsSinceEpoch() in new
+ code.
+
\sa toTime_t(), setTime_t()
*/
QDateTime QDateTime::fromTime_t(uint seconds)
@@ -4234,6 +4423,7 @@ QDateTime QDateTime::fromTime_t(uint seconds)
/*!
\since 5.2
+ \deprecated
Returns a datetime whose date and time are the number of \a seconds
that have passed since 1970-01-01T00:00:00, Coordinated Universal
@@ -4243,6 +4433,9 @@ QDateTime QDateTime::fromTime_t(uint seconds)
ignored. If the \a spec is Qt::OffsetFromUTC and the \a offsetSeconds is 0
then the spec will be set to Qt::UTC, i.e. an offset of 0 seconds.
+ \note This function is deprecated. Please use fromSecsSinceEpoch() in new
+ code.
+
\sa toTime_t(), setTime_t()
*/
QDateTime QDateTime::fromTime_t(uint seconds, Qt::TimeSpec spec, int offsetSeconds)
@@ -4253,11 +4446,15 @@ QDateTime QDateTime::fromTime_t(uint seconds, Qt::TimeSpec spec, int offsetSecon
#ifndef QT_BOOTSTRAPPED
/*!
\since 5.2
+ \deprecated
Returns a datetime whose date and time are the number of \a seconds
that have passed since 1970-01-01T00:00:00, Coordinated Universal
Time (Qt::UTC) and with the given \a timeZone.
+ \note This function is deprecated. Please use fromSecsSinceEpoch() in new
+ code.
+
\sa toTime_t(), setTime_t()
*/
QDateTime QDateTime::fromTime_t(uint seconds, const QTimeZone &timeZone)
@@ -4265,6 +4462,7 @@ QDateTime QDateTime::fromTime_t(uint seconds, const QTimeZone &timeZone)
return fromMSecsSinceEpoch((qint64)seconds * 1000, timeZone);
}
#endif
+#endif // QT_DEPRECATED_SINCE(5, 8)
/*!
\since 4.7
@@ -4278,7 +4476,7 @@ QDateTime QDateTime::fromTime_t(uint seconds, const QTimeZone &timeZone)
range of QDateTime, both negative and positive. The behavior of this
function is undefined for those values.
- \sa toTime_t(), setTime_t()
+ \sa toMSecsSinceEpoch(), setMSecsSinceEpoch()
*/
QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs)
{
@@ -4303,16 +4501,41 @@ QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs)
If \a spec is Qt::TimeZone then the spec will be set to Qt::LocalTime,
i.e. the current system time zone.
- \sa fromTime_t()
+ \sa toMSecsSinceEpoch(), setMSecsSinceEpoch()
*/
QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs, Qt::TimeSpec spec, int offsetSeconds)
{
QDateTime dt;
- dt.d->setTimeSpec(spec, offsetSeconds);
+ QT_PREPEND_NAMESPACE(setTimeSpec(dt.d, spec, offsetSeconds));
dt.setMSecsSinceEpoch(msecs);
return dt;
}
+/*!
+ \since 5.8
+
+ Returns a datetime whose date and time are the number of seconds \a secs
+ that have passed since 1970-01-01T00:00:00.000, Coordinated Universal
+ Time (Qt::UTC) and converted to the given \a spec.
+
+ Note that there are possible values for \a secs that lie outside the valid
+ range of QDateTime, both negative and positive. The behavior of this
+ function is undefined for those values.
+
+ If the \a spec is not Qt::OffsetFromUTC then the \a offsetSeconds will be
+ ignored. If the \a spec is Qt::OffsetFromUTC and the \a offsetSeconds is 0
+ then the spec will be set to Qt::UTC, i.e. an offset of 0 seconds.
+
+ If \a spec is Qt::TimeZone then the spec will be set to Qt::LocalTime,
+ i.e. the current system time zone.
+
+ \sa toSecsSinceEpoch(), setSecsSinceEpoch()
+*/
+QDateTime QDateTime::fromSecsSinceEpoch(qint64 secs, Qt::TimeSpec spec, int offsetSeconds)
+{
+ return fromMSecsSinceEpoch(secs * 1000, spec, offsetSeconds);
+}
+
#ifndef QT_BOOTSTRAPPED
/*!
\since 5.2
@@ -4321,7 +4544,7 @@ QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs, Qt::TimeSpec spec, int of
that have passed since 1970-01-01T00:00:00.000, Coordinated Universal
Time (Qt::UTC) and with the given \a timeZone.
- \sa fromTime_t()
+ \sa fromSecsSinceEpoch()
*/
QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone)
{
@@ -4330,6 +4553,20 @@ QDateTime QDateTime::fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone
dt.setMSecsSinceEpoch(msecs);
return dt;
}
+
+/*!
+ \since 5.8
+
+ Returns a datetime whose date and time are the number of seconds \a secs
+ that have passed since 1970-01-01T00:00:00.000, Coordinated Universal
+ Time (Qt::UTC) and with the given \a timeZone.
+
+ \sa fromMSecsSinceEpoch()
+*/
+QDateTime QDateTime::fromSecsSinceEpoch(qint64 secs, const QTimeZone &timeZone)
+{
+ return fromMSecsSinceEpoch(secs * 1000, timeZone);
+}
#endif
#if QT_DEPRECATED_SINCE(5, 2)
@@ -4825,7 +5062,7 @@ QDataStream &operator<<(QDataStream &out, const QDateTime &dateTime)
if (out.version() >= QDataStream::Qt_5_2) {
// In 5.2 we switched to using Qt::TimeSpec and added offset support
- dateAndTime = dateTime.d->getDateTime();
+ dateAndTime = getDateTime(dateTime.d);
out << dateAndTime << qint8(dateTime.timeSpec());
if (dateTime.timeSpec() == Qt::OffsetFromUTC)
out << qint32(dateTime.offsetFromUtc());
@@ -4840,13 +5077,13 @@ QDataStream &operator<<(QDataStream &out, const QDateTime &dateTime)
// This approach is wrong and should not be used again; it breaks
// the guarantee that a deserialised local datetime is the same time
// of day, regardless of which timezone it was serialised in.
- dateAndTime = (dateTime.isValid() ? dateTime.toUTC() : dateTime).d->getDateTime();
+ dateAndTime = getDateTime((dateTime.isValid() ? dateTime.toUTC() : dateTime).d);
out << dateAndTime << qint8(dateTime.timeSpec());
} else if (out.version() >= QDataStream::Qt_4_0) {
// From 4.0 to 5.1 (except 5.0) we used QDateTimePrivate::Spec
- dateAndTime = dateTime.d->getDateTime();
+ dateAndTime = getDateTime(dateTime.d);
out << dateAndTime;
switch (dateTime.timeSpec()) {
case Qt::UTC:
@@ -4866,7 +5103,7 @@ QDataStream &operator<<(QDataStream &out, const QDateTime &dateTime)
} else { // version < QDataStream::Qt_4_0
// Before 4.0 there was no TimeSpec, only Qt::LocalTime was supported
- dateAndTime = dateTime.d->getDateTime();
+ dateAndTime = getDateTime(dateTime.d);
out << dateAndTime;
}
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h
index f292a97db1..ebf9b45570 100644
--- a/src/corelib/tools/qdatetime.h
+++ b/src/corelib/tools/qdatetime.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -46,11 +47,9 @@
#include <limits>
-#ifdef Q_OS_MAC
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_FORWARD_DECLARE_CF_TYPE(CFDate);
-# ifdef __OBJC__
Q_FORWARD_DECLARE_OBJC_CLASS(NSDate);
-# endif
#endif
QT_BEGIN_NAMESPACE
@@ -148,15 +147,9 @@ Q_DECLARE_TYPEINFO(QDate, Q_MOVABLE_TYPE);
class Q_CORE_EXPORT QTime
{
explicit Q_DECL_CONSTEXPR QTime(int ms) : mds(ms)
-#if defined(Q_OS_WINCE)
- , startTick(NullTime)
-#endif
{}
public:
Q_DECL_CONSTEXPR QTime(): mds(NullTime)
-#if defined(Q_OS_WINCE)
- , startTick(NullTime)
-#endif
{}
QTime(int h, int m, int s = 0, int ms = 0);
@@ -202,9 +195,6 @@ private:
enum TimeFlag { NullTime = -1 };
Q_DECL_CONSTEXPR inline int ds() const { return mds == -1 ? 0 : mds; }
int mds;
-#if defined(Q_OS_WINCE)
- int startTick;
-#endif
friend class QDateTime;
friend class QDateTimePrivate;
@@ -219,8 +209,46 @@ class QDateTimePrivate;
class Q_CORE_EXPORT QDateTime
{
+ // ### Qt 6: revisit the optimization
+ struct ShortData {
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
+ quintptr status : 8;
+#endif
+ // note: this is only 24 bits on 32-bit systems...
+ qintptr msecs : sizeof(void *) * 8 - 8;
+
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ quintptr status : 8;
+#endif
+ };
+
+ union Data {
+ enum {
+ // To be of any use, we need at least 60 years around 1970, which
+ // is 1,893,456,000,000 ms. That requires 41 bits to store, plus
+ // the sign bit. With the status byte, the minimum size is 50 bits.
+ CanBeSmall = sizeof(ShortData) * 8 > 50
+ };
+
+ Data();
+ Data(Qt::TimeSpec);
+ Data(const Data &other);
+ Data(Data &&other);
+ Data &operator=(const Data &other);
+ ~Data();
+
+ bool isShort() const;
+ void detach();
+
+ const QDateTimePrivate *operator->() const;
+ QDateTimePrivate *operator->();
+
+ QDateTimePrivate *d;
+ ShortData data;
+ };
+
public:
- QDateTime();
+ QDateTime() Q_DECL_NOEXCEPT_EXPR(Data::CanBeSmall);
explicit QDateTime(const QDate &);
QDateTime(const QDate &, const QTime &, Qt::TimeSpec spec = Qt::LocalTime);
// ### Qt 6: Merge with above with default offsetSeconds = 0
@@ -228,15 +256,16 @@ public:
#ifndef QT_BOOTSTRAPPED
QDateTime(const QDate &date, const QTime &time, const QTimeZone &timeZone);
#endif // QT_BOOTSTRAPPED
- QDateTime(const QDateTime &other);
+ QDateTime(const QDateTime &other) Q_DECL_NOTHROW;
+ QDateTime(QDateTime &&other) Q_DECL_NOTHROW;
~QDateTime();
#ifdef Q_COMPILER_RVALUE_REFS
QDateTime &operator=(QDateTime &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
- QDateTime &operator=(const QDateTime &other);
+ QDateTime &operator=(const QDateTime &other) Q_DECL_NOTHROW;
- void swap(QDateTime &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
+ void swap(QDateTime &other) Q_DECL_NOTHROW { qSwap(d.d, other.d.d); }
bool isNull() const;
bool isValid() const;
@@ -252,8 +281,7 @@ public:
bool isDaylightTime() const;
qint64 toMSecsSinceEpoch() const;
- // ### Qt 6: use quint64 instead of uint
- uint toTime_t() const;
+ qint64 toSecsSinceEpoch() const;
void setDate(const QDate &date);
void setTime(const QTime &time);
@@ -263,8 +291,7 @@ public:
void setTimeZone(const QTimeZone &toZone);
#endif // QT_BOOTSTRAPPED
void setMSecsSinceEpoch(qint64 msecs);
- // ### Qt 6: use quint64 instead of uint
- void setTime_t(uint secsSince1Jan1970UTC);
+ void setSecsSinceEpoch(qint64 secs);
#ifndef QT_NO_DATESTRING
QString toString(Qt::DateFormat f = Qt::TextDate) const;
@@ -306,38 +333,40 @@ public:
static QDateTime fromString(const QString &s, Qt::DateFormat f = Qt::TextDate);
static QDateTime fromString(const QString &s, const QString &format);
#endif
- // ### Qt 6: use quint64 instead of uint
+
+#if QT_DEPRECATED_SINCE(5, 8)
+ uint toTime_t() const;
+ void setTime_t(uint secsSince1Jan1970UTC);
static QDateTime fromTime_t(uint secsSince1Jan1970UTC);
- // ### Qt 6: Merge with above with default spec = Qt::LocalTime
static QDateTime fromTime_t(uint secsSince1Jan1970UTC, Qt::TimeSpec spec,
int offsetFromUtc = 0);
-#ifndef QT_BOOTSTRAPPED
static QDateTime fromTime_t(uint secsSince1Jan1970UTC, const QTimeZone &timeZone);
#endif
+
static QDateTime fromMSecsSinceEpoch(qint64 msecs);
// ### Qt 6: Merge with above with default spec = Qt::LocalTime
static QDateTime fromMSecsSinceEpoch(qint64 msecs, Qt::TimeSpec spec, int offsetFromUtc = 0);
+ static QDateTime fromSecsSinceEpoch(qint64 secs, Qt::TimeSpec spe = Qt::LocalTime, int offsetFromUtc = 0);
+
#ifndef QT_BOOTSTRAPPED
static QDateTime fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone);
+ static QDateTime fromSecsSinceEpoch(qint64 secs, const QTimeZone &timeZone);
#endif
+
static qint64 currentMSecsSinceEpoch() Q_DECL_NOTHROW;
+ static qint64 currentSecsSinceEpoch() Q_DECL_NOTHROW;
-#if defined(Q_OS_MAC) || defined(Q_QDOC)
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
static QDateTime fromCFDate(CFDateRef date);
CFDateRef toCFDate() const Q_DECL_CF_RETURNS_RETAINED;
-# if defined(__OBJC__) || defined(Q_QDOC)
static QDateTime fromNSDate(const NSDate *date);
NSDate *toNSDate() const Q_DECL_NS_RETURNS_AUTORELEASED;
-# endif
#endif
private:
friend class QDateTimePrivate;
- // ### Qt6: Using a private here has high impact on runtime
- // on users such as QFileInfo. In Qt 6, the data members
- // should be inlined.
- QSharedDataPointer<QDateTimePrivate> d;
+ Data d;
#ifndef QT_NO_DATASTREAM
friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QDateTime &);
diff --git a/src/corelib/tools/qdatetime_mac.mm b/src/corelib/tools/qdatetime_mac.mm
deleted file mode 100644
index d61ea28636..0000000000
--- a/src/corelib/tools/qdatetime_mac.mm
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2014 Petroules Corporation.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdatetime.h"
-
-#import <Foundation/Foundation.h>
-
-QT_BEGIN_NAMESPACE
-
-QDateTime QDateTime::fromCFDate(CFDateRef date)
-{
- if (!date)
- return QDateTime();
- return QDateTime::fromMSecsSinceEpoch(static_cast<qint64>((CFDateGetAbsoluteTime(date)
- + kCFAbsoluteTimeIntervalSince1970) * 1000));
-}
-
-CFDateRef QDateTime::toCFDate() const
-{
- return CFDateCreate(kCFAllocatorDefault, (static_cast<CFAbsoluteTime>(toMSecsSinceEpoch())
- / 1000) - kCFAbsoluteTimeIntervalSince1970);
-}
-
-QDateTime QDateTime::fromNSDate(const NSDate *date)
-{
- if (!date)
- return QDateTime();
- return QDateTime::fromMSecsSinceEpoch(static_cast<qint64>([date timeIntervalSince1970] * 1000));
-}
-
-NSDate *QDateTime::toNSDate() const
-{
- return [NSDate
- dateWithTimeIntervalSince1970:static_cast<NSTimeInterval>(toMSecsSinceEpoch()) / 1000];
-}
-
-QT_END_NAMESPACE
diff --git a/src/corelib/tools/qdatetime_p.h b/src/corelib/tools/qdatetime_p.h
index 104cbccbd4..38a084b257 100644
--- a/src/corelib/tools/qdatetime_p.h
+++ b/src/corelib/tools/qdatetime_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -51,6 +52,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qplatformdefs.h"
#include "QtCore/qatomic.h"
#include "QtCore/qdatetime.h"
@@ -60,9 +62,13 @@
QT_BEGIN_NAMESPACE
-class QDateTimePrivate : public QSharedData
+class QDateTimePrivate
{
public:
+ // forward the declarations from QDateTime (this makes them public)
+ typedef QDateTime::ShortData QDateTimeShortData;
+ typedef QDateTime::Data QDateTimeData;
+
// Never change or delete this enum, it is required for backwards compatible
// serialization of QDateTime before 5.2, so is essentially public API
enum Spec {
@@ -76,7 +82,6 @@ public:
// Daylight Time Status
enum DaylightStatus {
- NoDaylightTime = -2,
UnknownDaylightTime = -1,
StandardTime = 0,
DaylightTime = 1
@@ -84,62 +89,46 @@ public:
// Status of date/time
enum StatusFlag {
- NullDate = 0x01,
- NullTime = 0x02,
- ValidDate = 0x04, // just the date field
- ValidTime = 0x08, // just the time field
- ValidDateTime = 0x10, // the whole object (including timezone)
+ ShortData = 0x01,
+
+ ValidDate = 0x02,
+ ValidTime = 0x04,
+ ValidDateTime = 0x08,
+
+ TimeSpecMask = 0x30,
+
SetToStandardTime = 0x40,
SetToDaylightTime = 0x80
};
Q_DECLARE_FLAGS(StatusFlags, StatusFlag)
+ enum {
+ TimeSpecShift = 4,
+ ValidityMask = ValidDate | ValidTime | ValidDateTime,
+ DaylightMask = SetToStandardTime | SetToDaylightTime
+ };
+
QDateTimePrivate() : m_msecs(0),
- m_spec(Qt::LocalTime),
+ m_status(StatusFlag(Qt::LocalTime << TimeSpecShift)),
m_offsetFromUtc(0),
- m_status(NullDate | NullTime)
- {}
+ ref(0)
+ {
+ }
- QDateTimePrivate(const QDate &toDate, const QTime &toTime, Qt::TimeSpec toSpec,
- int offsetSeconds);
+ static QDateTime::Data create(const QDate &toDate, const QTime &toTime, Qt::TimeSpec toSpec,
+ int offsetSeconds);
#ifndef QT_BOOTSTRAPPED
- QDateTimePrivate(const QDate &toDate, const QTime &toTime, const QTimeZone & timeZone);
+ static QDateTime::Data create(const QDate &toDate, const QTime &toTime, const QTimeZone & timeZone);
#endif // QT_BOOTSTRAPPED
- // ### XXX: when the tooling situation improves, look at fixing the padding.
- // 4 bytes padding
-
qint64 m_msecs;
- Qt::TimeSpec m_spec;
+ StatusFlags m_status;
int m_offsetFromUtc;
+ mutable QAtomicInt ref;
#ifndef QT_BOOTSTRAPPED
QTimeZone m_timeZone;
#endif // QT_BOOTSTRAPPED
- StatusFlags m_status;
-
- void setTimeSpec(Qt::TimeSpec spec, int offsetSeconds);
- void setDateTime(const QDate &date, const QTime &time);
- QPair<QDate, QTime> getDateTime() const;
-
- void setDaylightStatus(DaylightStatus status);
- DaylightStatus daylightStatus() const;
-
- // Returns msecs since epoch, assumes offset value is current
- inline qint64 toMSecsSinceEpoch() const;
-
- void checkValidDateTime();
- void refreshDateTime();
-
- // Get/set date and time status
- inline bool isNullDate() const { return m_status & NullDate; }
- inline bool isNullTime() const { return m_status & NullTime; }
- inline bool isValidDate() const { return m_status & ValidDate; }
- inline bool isValidTime() const { return m_status & ValidTime; }
- inline bool isValidDateTime() const { return m_status & ValidDateTime; }
- inline void setValidDateTime() { m_status |= ValidDateTime; }
- inline void clearValidDateTime() { m_status &= ~ValidDateTime; }
- inline void clearSetToDaylightStatus() { m_status &= ~(SetToStandardTime | SetToDaylightTime); }
#ifndef QT_BOOTSTRAPPED
static qint64 zoneMSecsToEpochMSecs(qint64 msecs, const QTimeZone &zone,
diff --git a/src/corelib/tools/qdatetimeparser_p.h b/src/corelib/tools/qdatetimeparser_p.h
index 01a2f20802..6f381965a9 100644
--- a/src/corelib/tools/qdatetimeparser_p.h
+++ b/src/corelib/tools/qdatetimeparser_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "qplatformdefs.h"
#include "QtCore/qatomic.h"
#include "QtCore/qdatetime.h"
diff --git a/src/corelib/tools/qfreelist_p.h b/src/corelib/tools/qfreelist_p.h
index ebe34bc135..c3efc41d62 100644
--- a/src/corelib/tools/qfreelist_p.h
+++ b/src/corelib/tools/qfreelist_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qatomic.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/tools/qharfbuzz_p.h b/src/corelib/tools/qharfbuzz_p.h
index cc4d9bbd85..2a0307d35f 100644
--- a/src/corelib/tools/qharfbuzz_p.h
+++ b/src/corelib/tools/qharfbuzz_p.h
@@ -48,6 +48,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
#ifndef QHARFBUZZ_P_H
#define QHARFBUZZ_P_H
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index 593a87e65d..abec9ebb79 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -2644,4 +2644,24 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW
\sa QHash::constFind()
*/
+/*!
+ \fn uint qHash(const QHash<Key, T> &key, uint seed = 0)
+ \since 5.8
+ \relates QHash
+
+ Returns the hash value for the \a key, using \a seed to seed the calculation.
+
+ Type \c T must be supported by qHash().
+*/
+
+/*!
+ \fn uint qHash(const QMultiHash<Key, T> &key, uint seed = 0)
+ \since 5.8
+ \relates QMultiHash
+
+ Returns the hash value for the \a key, using \a seed to seed the calculation.
+
+ Type \c T must be supported by qHash().
+*/
+
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 7abbeabeae..6a2d7bdd11 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -1095,6 +1095,27 @@ Q_INLINE_TEMPLATE int QMultiHash<Key, T>::count(const Key &key, const T &value)
Q_DECLARE_ASSOCIATIVE_ITERATOR(Hash)
Q_DECLARE_MUTABLE_ASSOCIATIVE_ITERATOR(Hash)
+template <class Key, class T>
+uint qHash(const QHash<Key, T> &key, uint seed = 0)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(std::declval<Key&>())) && noexcept(qHash(std::declval<T&>())))
+{
+ QtPrivate::QHashCombineCommutative hash;
+ for (auto it = key.begin(), end = key.end(); it != end; ++it) {
+ const Key &k = it.key();
+ const T &v = it.value();
+ seed = hash(seed, std::pair<const Key&, const T&>(k, v));
+ }
+ return seed;
+}
+
+template <class Key, class T>
+inline uint qHash(const QMultiHash<Key, T> &key, uint seed = 0)
+ Q_DECL_NOEXCEPT_EXPR(noexcept(qHash(std::declval<Key&>())) && noexcept(qHash(std::declval<T&>())))
+{
+ const QHash<Key, T> &key2 = key;
+ return qHash(key2, seed);
+}
+
QT_END_NAMESPACE
#if defined(Q_CC_MSVC)
diff --git a/src/corelib/tools/qline.cpp b/src/corelib/tools/qline.cpp
index b004f74be9..8942292a3d 100644
--- a/src/corelib/tools/qline.cpp
+++ b/src/corelib/tools/qline.cpp
@@ -214,6 +214,14 @@ QT_BEGIN_NAMESPACE
Returns this line translated the distance specified by \a dx and \a dy.
*/
+/*!
+ \fn QPoint QLine::center() const
+
+ \since 5.8
+
+ Returns the center point of this line. This is equivalent to
+ (p1() + p2()) / 2, except it will never overflow.
+*/
/*!
\fn void QLine::setP1(const QPoint &p1)
@@ -351,6 +359,12 @@ QDataStream &operator>>(QDataStream &stream, QLine &line)
translate() function, and can be traversed using the pointAt()
function.
+ \section1 Constraints
+
+ QLine is limited to the minimum and maximum values for the
+ \c int type. Operations on a QLine that could potentially result
+ in values outside this range will result in undefined behavior.
+
\sa QLine, QPolygonF, QRectF
*/
@@ -711,6 +725,15 @@ QLineF::IntersectType QLineF::intersect(const QLineF &l, QPointF *intersectionPo
*/
/*!
+ \fn QPointF QLineF::center() const
+
+ \since 5.8
+
+ Returns the center point of this line. This is equivalent to
+ 0.5 * p1() + 0.5 * p2().
+*/
+
+/*!
\fn void QLineF::setP1(const QPointF &p1)
\since 4.4
diff --git a/src/corelib/tools/qline.h b/src/corelib/tools/qline.h
index 819dd3fd3b..5b5ca3b4c8 100644
--- a/src/corelib/tools/qline.h
+++ b/src/corelib/tools/qline.h
@@ -76,6 +76,8 @@ public:
Q_DECL_CONSTEXPR inline QLine translated(const QPoint &p) const Q_REQUIRED_RESULT;
Q_DECL_CONSTEXPR inline QLine translated(int dx, int dy) const Q_REQUIRED_RESULT;
+ Q_DECL_CONSTEXPR inline QPoint center() const Q_REQUIRED_RESULT;
+
inline void setP1(const QPoint &p1);
inline void setP2(const QPoint &p2);
inline void setPoints(const QPoint &p1, const QPoint &p2);
@@ -165,6 +167,11 @@ Q_DECL_CONSTEXPR inline QLine QLine::translated(int adx, int ady) const
return translated(QPoint(adx, ady));
}
+Q_DECL_CONSTEXPR inline QPoint QLine::center() const
+{
+ return QPoint(int((qint64(pt1.x()) + pt2.x()) / 2), int((qint64(pt1.y()) + pt2.y()) / 2));
+}
+
inline void QLine::setP1(const QPoint &aP1)
{
pt1 = aP1;
@@ -253,6 +260,8 @@ public:
Q_DECL_CONSTEXPR inline QLineF translated(const QPointF &p) const Q_REQUIRED_RESULT;
Q_DECL_CONSTEXPR inline QLineF translated(qreal dx, qreal dy) const Q_REQUIRED_RESULT;
+ Q_DECL_CONSTEXPR inline QPointF center() const Q_REQUIRED_RESULT;
+
inline void setP1(const QPointF &p1);
inline void setP2(const QPointF &p2);
inline void setPoints(const QPointF &p1, const QPointF &p2);
@@ -357,6 +366,11 @@ Q_DECL_CONSTEXPR inline QLineF QLineF::translated(qreal adx, qreal ady) const
return translated(QPointF(adx, ady));
}
+Q_DECL_CONSTEXPR inline QPointF QLineF::center() const
+{
+ return QPointF(0.5 * pt1.x() + 0.5 * pt2.x(), 0.5 * pt1.y() + 0.5 * pt2.y());
+}
+
inline void QLineF::setLength(qreal len)
{
if (isNull())
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 90ed5072e7..c7f27abdd6 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -118,7 +118,10 @@ struct Q_CORE_EXPORT QListData {
};
template <typename T>
-class QList : public QListSpecialMethods<T>
+class QList
+#ifndef Q_QDOC
+ : public QListSpecialMethods<T>
+#endif
{
public:
struct MemoryLayout
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index ea5d74d9bb..7809c513d6 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -61,7 +61,6 @@
#include "qvariant.h"
#include "qstringbuilder.h"
#include "private/qnumeric_p.h"
-#include "private/qsystemlibrary_p.h"
#ifdef Q_OS_WIN
# include <qt_windows.h>
# include <time.h>
diff --git a/src/corelib/tools/qlocale_data_p.h b/src/corelib/tools/qlocale_data_p.h
index 262cecb564..869153942e 100644
--- a/src/corelib/tools/qlocale_data_p.h
+++ b/src/corelib/tools/qlocale_data_p.h
@@ -51,6 +51,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
QT_BEGIN_NAMESPACE
/* This part of the file isn't generated, but written by hand since
diff --git a/src/corelib/tools/qlocale_mac.mm b/src/corelib/tools/qlocale_mac.mm
index 4b1d190705..4f6efc8832 100644
--- a/src/corelib/tools/qlocale_mac.mm
+++ b/src/corelib/tools/qlocale_mac.mm
@@ -390,9 +390,6 @@ static QString macFormatCurrency(const QSystemLocale::CurrencyToStringArgument &
static QVariant macQuoteString(QSystemLocale::QueryType type, const QStringRef &str)
{
- if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_6)
- return QVariant();
-
QString begin, end;
QCFType<CFLocaleRef> locale = CFLocaleCopyCurrent();
switch (type) {
diff --git a/src/corelib/tools/qlocale_p.h b/src/corelib/tools/qlocale_p.h
index f95edf4d14..c83c9d3333 100644
--- a/src/corelib/tools/qlocale_p.h
+++ b/src/corelib/tools/qlocale_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include "QtCore/qstring.h"
#include "QtCore/qvarlengtharray.h"
#include "QtCore/qvariant.h"
diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp
index 88bfada515..f8b9f86ac6 100644
--- a/src/corelib/tools/qlocale_win.cpp
+++ b/src/corelib/tools/qlocale_win.cpp
@@ -44,9 +44,6 @@
#include "qstringlist.h"
#include "qvariant.h"
#include "qdatetime.h"
-
-#include "private/qsystemlibrary_p.h"
-
#include "qdebug.h"
#ifdef Q_OS_WIN
@@ -67,7 +64,6 @@ QT_BEGIN_NAMESPACE
#ifndef Q_OS_WINRT
static QByteArray getWinLocaleName(LCID id = LOCALE_USER_DEFAULT);
-static const char *winLangCodeToIsoName(int code);
static QString winIso639LangName(LCID id = LOCALE_USER_DEFAULT);
static QString winIso3116CtryName(LCID id = LOCALE_USER_DEFAULT);
#else // !Q_OS_WINRT
@@ -600,50 +596,32 @@ QVariant QSystemLocalePrivate::toCurrencyString(const QSystemLocale::CurrencyToS
QVariant QSystemLocalePrivate::uiLanguages()
{
- if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) {
- typedef BOOL (WINAPI *GetUserPreferredUILanguagesFunc) (
- DWORD dwFlags,
- PULONG pulNumLanguages,
- PWSTR pwszLanguagesBuffer,
- PULONG pcchLanguagesBuffer);
- static GetUserPreferredUILanguagesFunc GetUserPreferredUILanguages_ptr = 0;
#ifndef Q_OS_WINRT
- if (!GetUserPreferredUILanguages_ptr) {
- QSystemLibrary lib(QLatin1String("kernel32"));
- if (lib.load())
- GetUserPreferredUILanguages_ptr = (GetUserPreferredUILanguagesFunc)lib.resolve("GetUserPreferredUILanguages");
- }
-#endif // !Q_OS_WINRT
- if (GetUserPreferredUILanguages_ptr) {
- unsigned long cnt = 0;
- QVarLengthArray<wchar_t, 64> buf(64);
- unsigned long size = buf.size();
- if (!GetUserPreferredUILanguages_ptr(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size)) {
- size = 0;
- if (GetLastError() == ERROR_INSUFFICIENT_BUFFER &&
- GetUserPreferredUILanguages_ptr(MUI_LANGUAGE_NAME, &cnt, NULL, &size)) {
- buf.resize(size);
- if (!GetUserPreferredUILanguages_ptr(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size))
- return QStringList();
- }
- }
- QStringList result;
- result.reserve(cnt);
- const wchar_t *str = buf.constData();
- for (; cnt > 0; --cnt) {
- QString s = QString::fromWCharArray(str);
- if (s.isEmpty())
- break; // something is wrong
- result.append(s);
- str += s.size()+1;
- }
- return result;
+ unsigned long cnt = 0;
+ QVarLengthArray<wchar_t, 64> buf(64);
+# if !defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE) // Not present in MinGW 4.9/bootstrap builds.
+ unsigned long size = buf.size();
+ if (!GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size)) {
+ size = 0;
+ if (GetLastError() == ERROR_INSUFFICIENT_BUFFER &&
+ GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &cnt, NULL, &size)) {
+ buf.resize(size);
+ if (!GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size))
+ return QStringList();
}
}
-
-#ifndef Q_OS_WINRT
- // old Windows before Vista
- return QStringList(QString::fromLatin1(winLangCodeToIsoName(GetUserDefaultUILanguage())));
+# endif // !QT_BOOTSTRAPPED && !QT_BUILD_QMAKE
+ QStringList result;
+ result.reserve(cnt);
+ const wchar_t *str = buf.constData();
+ for (; cnt > 0; --cnt) {
+ QString s = QString::fromWCharArray(str);
+ if (s.isEmpty())
+ break; // something is wrong
+ result.append(s);
+ str += s.size() + 1;
+ }
+ return result;
#else // !Q_OS_WINRT
QStringList result;
ComPtr<ABI::Windows::Globalization::IApplicationLanguagesStatics> appLanguagesStatics;
@@ -1161,19 +1139,16 @@ static QByteArray getWinLocaleName(LPWSTR id)
}
}
-#if defined(Q_OS_WINCE)
- result = winLangCodeToIsoName(id != LOCALE_USER_DEFAULT ? id : GetUserDefaultLCID());
-#else // !Q_OS_WINCE
-# ifndef Q_OS_WINRT
+#ifndef Q_OS_WINRT
if (id == LOCALE_USER_DEFAULT)
id = GetUserDefaultLCID();
-# else // !Q_OS_WINRT
+#else // !Q_OS_WINRT
WCHAR lcName[LOCALE_NAME_MAX_LENGTH];
if (QString::fromWCharArray(id) == QString::fromWCharArray(LOCALE_NAME_USER_DEFAULT)) {
GetUserDefaultLocaleName(lcName, LOCALE_NAME_MAX_LENGTH);
id = lcName;
}
-# endif // Q_OS_WINRT
+#endif // Q_OS_WINRT
QString resultuage = winIso639LangName(id);
QString country = winIso3116CtryName(id);
result = resultuage.toLatin1();
@@ -1181,7 +1156,6 @@ static QByteArray getWinLocaleName(LPWSTR id)
result += '_';
result += country.toLatin1();
}
-#endif // !Q_OS_WINCE
return result;
}
diff --git a/src/corelib/tools/qpodlist_p.h b/src/corelib/tools/qpodlist_p.h
index 810df02000..95990e0bb6 100644
--- a/src/corelib/tools/qpodlist_p.h
+++ b/src/corelib/tools/qpodlist_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qvarlengtharray.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/tools/qpoint.h b/src/corelib/tools/qpoint.h
index 4e2e6b91a6..7b1004897a 100644
--- a/src/corelib/tools/qpoint.h
+++ b/src/corelib/tools/qpoint.h
@@ -42,6 +42,10 @@
#include <QtCore/qnamespace.h>
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+struct CGPoint;
+#endif
+
QT_BEGIN_NAMESPACE
@@ -89,6 +93,10 @@ public:
friend Q_DECL_CONSTEXPR inline const QPoint operator-(const QPoint &);
friend Q_DECL_CONSTEXPR inline const QPoint operator/(const QPoint &, qreal);
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+ CGPoint toCGPoint() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+#endif
+
private:
friend class QTransform;
int xp;
@@ -247,6 +255,11 @@ public:
Q_DECL_CONSTEXPR QPoint toPoint() const;
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+ static QPointF fromCGPoint(CGPoint point) Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ CGPoint toCGPoint() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+#endif
+
private:
friend class QMatrix;
friend class QTransform;
diff --git a/src/corelib/tools/qrect.h b/src/corelib/tools/qrect.h
index b376b6b999..f973cf3494 100644
--- a/src/corelib/tools/qrect.h
+++ b/src/corelib/tools/qrect.h
@@ -48,6 +48,10 @@
#error qrect.h must be included before any header file that defines topLeft
#endif
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+struct CGRect;
+#endif
+
QT_BEGIN_NAMESPACE
class Q_CORE_EXPORT QRect
@@ -149,6 +153,10 @@ public:
friend Q_DECL_CONSTEXPR inline bool operator==(const QRect &, const QRect &) Q_DECL_NOTHROW;
friend Q_DECL_CONSTEXPR inline bool operator!=(const QRect &, const QRect &) Q_DECL_NOTHROW;
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+ CGRect toCGRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+#endif
+
private:
int x1;
int y1;
@@ -604,6 +612,11 @@ public:
Q_DECL_CONSTEXPR inline QRect toRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
QRect toAlignedRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+ static QRectF fromCGRect(CGRect rect) Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ CGRect toCGRect() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+#endif
+
private:
qreal xp;
qreal yp;
diff --git a/src/corelib/tools/qringbuffer.cpp b/src/corelib/tools/qringbuffer.cpp
index 4a2dfdec2b..cb11e72435 100644
--- a/src/corelib/tools/qringbuffer.cpp
+++ b/src/corelib/tools/qringbuffer.cpp
@@ -108,24 +108,25 @@ char *QRingBuffer::reserve(qint64 bytes)
if (bytes <= 0 || bytes >= MaxByteArraySize)
return 0;
- if (buffers.isEmpty()) {
- buffers.append(QByteArray());
- buffers.first().resize(qMax(basicBlockSize, int(bytes)));
+ if (bufferSize == 0) {
+ if (buffers.isEmpty())
+ buffers.append(QByteArray(qMax(basicBlockSize, int(bytes)), Qt::Uninitialized));
+ else
+ buffers.first().resize(qMax(basicBlockSize, int(bytes)));
} else {
const qint64 newSize = bytes + tail;
- // if need buffer reallocation
- if (newSize > buffers.constLast().size()) {
- if (newSize > buffers.constLast().capacity() && (tail >= basicBlockSize
- || newSize >= MaxByteArraySize)) {
- // shrink this buffer to its current size
- buffers.last().resize(tail);
-
- // create a new QByteArray
- buffers.append(QByteArray());
- ++tailBuffer;
- tail = 0;
- }
- buffers.last().resize(qMax(basicBlockSize, tail + int(bytes)));
+ // if need a new buffer
+ if (basicBlockSize == 0 || (newSize > buffers.constLast().capacity()
+ && (tail >= basicBlockSize || newSize >= MaxByteArraySize))) {
+ // shrink this buffer to its current size
+ buffers.last().resize(tail);
+
+ // create a new QByteArray
+ buffers.append(QByteArray(qMax(basicBlockSize, int(bytes)), Qt::Uninitialized));
+ ++tailBuffer;
+ tail = 0;
+ } else if (newSize > buffers.constLast().size()) {
+ buffers.last().resize(qMax(basicBlockSize, int(newSize)));
}
}
@@ -146,10 +147,8 @@ char *QRingBuffer::reserveFront(qint64 bytes)
if (bytes <= 0 || bytes >= MaxByteArraySize)
return 0;
- if (head < bytes) {
- if (buffers.isEmpty()) {
- buffers.append(QByteArray());
- } else {
+ if (head < bytes || basicBlockSize == 0) {
+ if (head > 0) {
buffers.first().remove(0, head);
if (tailBuffer == 0)
tail -= head;
@@ -157,12 +156,15 @@ char *QRingBuffer::reserveFront(qint64 bytes)
head = qMax(basicBlockSize, int(bytes));
if (bufferSize == 0) {
+ if (buffers.isEmpty())
+ buffers.prepend(QByteArray(head, Qt::Uninitialized));
+ else
+ buffers.first().resize(head);
tail = head;
} else {
- buffers.prepend(QByteArray());
+ buffers.prepend(QByteArray(head, Qt::Uninitialized));
++tailBuffer;
}
- buffers.first().resize(head);
}
head -= int(bytes);
diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h
index 9ff1ec49cf..325b71f267 100644
--- a/src/corelib/tools/qringbuffer_p.h
+++ b/src/corelib/tools/qringbuffer_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qlist.h>
@@ -66,6 +67,14 @@ public:
explicit inline QRingBuffer(int growth = QRINGBUFFER_CHUNKSIZE) :
head(0), tail(0), tailBuffer(0), basicBlockSize(growth), bufferSize(0) { }
+ inline void setChunkSize(int size) {
+ basicBlockSize = size;
+ }
+
+ inline int chunkSize() const {
+ return basicBlockSize;
+ }
+
inline qint64 nextDataBlockSize() const {
return (tailBuffer == 0 ? tail : buffers.first().size()) - head;
}
diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp
index 1a37e0bc9c..67d11660e1 100644
--- a/src/corelib/tools/qscopedpointer.cpp
+++ b/src/corelib/tools/qscopedpointer.cpp
@@ -193,6 +193,48 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \fn bool operator==(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t)
+ \relates QScopedPointer
+ \since 5.8
+
+ Returns \c true if the scoped pointer \a lhs is a null pointer.
+
+ \sa QScopedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator==(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs)
+ \relates QScopedPointer
+ \since 5.8
+
+ Returns \c true if the scoped pointer \a rhs is a null pointer.
+
+ \sa QScopedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t)
+ \relates QScopedPointer
+ \since 5.8
+
+ Returns \c true if the scoped pointer \a lhs is a valid (i.e. a non-null)
+ pointer.
+
+ \sa QScopedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs)
+ \relates QScopedPointer
+ \since 5.8
+
+ Returns \c true if the scoped pointer \a rhs is a valid (i.e. a non-null)
+ pointer.
+
+ \sa QScopedPointer::isNull()
+*/
+
+/*!
\fn bool QScopedPointer::isNull() const
Returns \c true if this object is holding a pointer that is \c null.
diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h
index 3e6af97a33..92d7df6e5d 100644
--- a/src/corelib/tools/qscopedpointer.h
+++ b/src/corelib/tools/qscopedpointer.h
@@ -97,7 +97,7 @@ class QScopedPointer
{
typedef T *QScopedPointer:: *RestrictedBool;
public:
- explicit inline QScopedPointer(T *p = Q_NULLPTR) : d(p)
+ explicit QScopedPointer(T *p = Q_NULLPTR) Q_DECL_NOTHROW : d(p)
{
}
@@ -113,13 +113,12 @@ public:
return *d;
}
- inline T *operator->() const
+ T *operator->() const Q_DECL_NOTHROW
{
- Q_ASSERT(d);
return d;
}
- inline bool operator!() const
+ bool operator!() const Q_DECL_NOTHROW
{
return !d;
}
@@ -130,23 +129,23 @@ public:
return isNull() ? Q_NULLPTR : &QScopedPointer::d;
}
#else
- inline operator RestrictedBool() const
+ operator RestrictedBool() const Q_DECL_NOTHROW
{
return isNull() ? Q_NULLPTR : &QScopedPointer::d;
}
#endif
- inline T *data() const
+ T *data() const Q_DECL_NOTHROW
{
return d;
}
- inline bool isNull() const
+ bool isNull() const Q_DECL_NOTHROW
{
return !d;
}
- inline void reset(T *other = Q_NULLPTR)
+ void reset(T *other = Q_NULLPTR) Q_DECL_NOEXCEPT_EXPR(noexcept(Cleanup::cleanup(std::declval<T *>())))
{
if (d == other)
return;
@@ -155,7 +154,7 @@ public:
Cleanup::cleanup(oldD);
}
- inline T *take()
+ T *take() Q_DECL_NOTHROW
{
T *oldD = d;
d = Q_NULLPTR;
@@ -177,18 +176,42 @@ private:
};
template <class T, class Cleanup>
-inline bool operator==(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
+inline bool operator==(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs) Q_DECL_NOTHROW
{
return lhs.data() == rhs.data();
}
template <class T, class Cleanup>
-inline bool operator!=(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
+inline bool operator!=(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs) Q_DECL_NOTHROW
{
return lhs.data() != rhs.data();
}
template <class T, class Cleanup>
+inline bool operator==(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return lhs.isNull();
+}
+
+template <class T, class Cleanup>
+inline bool operator==(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs) Q_DECL_NOTHROW
+{
+ return rhs.isNull();
+}
+
+template <class T, class Cleanup>
+inline bool operator!=(const QScopedPointer<T, Cleanup> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return !lhs.isNull();
+}
+
+template <class T, class Cleanup>
+inline bool operator!=(std::nullptr_t, const QScopedPointer<T, Cleanup> &rhs) Q_DECL_NOTHROW
+{
+ return !rhs.isNull();
+}
+
+template <class T, class Cleanup>
inline void swap(QScopedPointer<T, Cleanup> &p1, QScopedPointer<T, Cleanup> &p2) Q_DECL_NOTHROW
{ p1.swap(p2); }
diff --git a/src/corelib/tools/qscopedpointer_p.h b/src/corelib/tools/qscopedpointer_p.h
index f74a3a7945..c1c44e7695 100644
--- a/src/corelib/tools/qscopedpointer_p.h
+++ b/src/corelib/tools/qscopedpointer_p.h
@@ -48,6 +48,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
#ifndef QSCOPEDPOINTER_P_H
#define QSCOPEDPOINTER_P_H
diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp
index 84afb0c5db..af09ef6f40 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -442,15 +442,20 @@
*/
/*!
- \fn QSharedPointer::QSharedPointer(T *ptr)
+ \fn QSharedPointer::QSharedPointer(X *ptr)
Creates a QSharedPointer that points to \a ptr. The pointer \a ptr
becomes managed by this QSharedPointer and must not be passed to
another QSharedPointer object or deleted outside this object.
+
+ Since Qt 5.8, when the last reference to this QSharedPointer gets
+ destroyed, \a ptr will be deleted by calling \c X's destructor (even if \c
+ X is not the same as QSharedPointer's template parameter \c T). Previously,
+ the destructor for \c T was called.
*/
/*!
- \fn QSharedPointer::QSharedPointer(T *ptr, Deleter deleter)
+ \fn QSharedPointer::QSharedPointer(X *ptr, Deleter deleter)
Creates a QSharedPointer that points to \a ptr. The pointer \a ptr
becomes managed by this QSharedPointer and must not be passed to
@@ -477,6 +482,9 @@
}
\endcode
+ Note that the custom deleter function will be called with a pointer to type
+ \c X, even if the QSharedPointer template parameter \c T is not the same.
+
It is also possible to specify a member function directly, as in:
\code
QSharedPointer<MyObject> obj =
@@ -487,6 +495,22 @@
*/
/*!
+ \fn QSharedPointer::QSharedPointer(std::nullptr_t)
+ \since 5.8
+
+ Creates a QSharedPointer that is null. This is equivalent to the
+ QSharedPointer default constructor.
+*/
+
+/*!
+ \fn QSharedPointer::QSharedPointer(std::nullptr_t, Deleter)
+ \since 5.8
+
+ Creates a QSharedPointer that is null. This is equivalent to the
+ QSharedPointer default constructor.
+*/
+
+/*!
\fn QSharedPointer::QSharedPointer(const QSharedPointer<T> &other)
Creates a QSharedPointer object that shares \a other's pointer.
@@ -1124,6 +1148,90 @@
*/
/*!
+ \fn bool operator==(const QSharedPointer<T> &lhs, std::nullptr_t)
+ \relates QSharedPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a lhs is a null pointer.
+
+ \sa QSharedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator==(std::nullptr_t, const QSharedPointer<T> &rhs)
+ \relates QSharedPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a rhs is a null pointer.
+
+ \sa QSharedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(const QSharedPointer<T> &lhs, std::nullptr_t)
+ \relates QSharedPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a lhs is a valid (i.e.
+ non-null) pointer.
+
+ \sa QSharedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(std::nullptr_t, const QSharedPointer<T> &rhs)
+ \relates QSharedPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a rhs is a valid (i.e.
+ non-null) pointer.
+
+ \sa QSharedPointer::isNull()
+*/
+
+/*!
+ \fn bool operator==(const QWeakPointer<T> &lhs, std::nullptr_t)
+ \relates QWeakPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a lhs is a null pointer.
+
+ \sa QWeakPointer::isNull()
+*/
+
+/*!
+ \fn bool operator==(std::nullptr_t, const QWeakPointer<T> &rhs)
+ \relates QWeakPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a rhs is a null pointer.
+
+ \sa QWeakPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(const QWeakPointer<T> &lhs, std::nullptr_t)
+ \relates QWeakPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a lhs is a valid (i.e.
+ non-null) pointer.
+
+ \sa QWeakPointer::isNull()
+*/
+
+/*!
+ \fn bool operator!=(std::nullptr_t, const QWeakPointer<T> &rhs)
+ \relates QWeakPointer
+ \since 5.8
+
+ Returns \c true if the pointer referenced by \a rhs is a valid (i.e.
+ non-null) pointer.
+
+ \sa QWeakPointer::isNull()
+*/
+
+/*!
\fn bool operator!=(const QWeakPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
\relates QWeakPointer
diff --git a/src/corelib/tools/qsharedpointer.h b/src/corelib/tools/qsharedpointer.h
index 72976637d5..3b86eb238b 100644
--- a/src/corelib/tools/qsharedpointer.h
+++ b/src/corelib/tools/qsharedpointer.h
@@ -67,8 +67,10 @@ public:
// constructors
QSharedPointer();
- explicit QSharedPointer(T *ptr);
- QSharedPointer(T *ptr, Deleter d);
+ template <typename X> explicit QSharedPointer(X *ptr);
+ template <typename X, typename Deleter> QSharedPointer(X *ptr, Deleter d);
+ QSharedPointer(std::nullptr_t);
+ template <typename Deleter> QSharedPointer(std::nullptr_t, Deleter d);
QSharedPointer(const QSharedPointer<T> &other);
QSharedPointer(const QWeakPointer<T> &other);
@@ -147,6 +149,14 @@ template<class T, class X> bool operator==(const QWeakPointer<T> &ptr1, const QS
template<class T, class X> bool operator!=(const QWeakPointer<T> &ptr1, const QSharedPointer<X> &ptr2);
template<class T, class X> bool operator==(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2);
template<class T, class X> bool operator!=(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2);
+template<class T> bool operator==(const QSharedPointer<T> &lhs, std::nullptr_t);
+template<class T> bool operator!=(const QSharedPointer<T> &lhs, std::nullptr_t);
+template<class T> bool operator==(std::nullptr_t, const QSharedPointer<T> &rhs);
+template<class T> bool operator!=(std::nullptr_t, const QSharedPointer<T> &rhs);
+template<class T> bool operator==(const QWeakPointer<T> &lhs, std::nullptr_t);
+template<class T> bool operator!=(const QWeakPointer<T> &lhs, std::nullptr_t);
+template<class T> bool operator==(std::nullptr_t, const QWeakPointer<T> &rhs);
+template<class T> bool operator!=(std::nullptr_t, const QWeakPointer<T> &rhs);
template <class X, class T> QSharedPointer<X> qSharedPointerCast(const QSharedPointer<T> &other);
template <class X, class T> QSharedPointer<X> qSharedPointerCast(const QWeakPointer<T> &other);
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index fc23c29148..7ce12bc244 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -305,23 +305,29 @@ public:
typedef const value_type &const_reference;
typedef qptrdiff difference_type;
- inline T *data() const { return value; }
- inline bool isNull() const { return !data(); }
- inline operator RestrictedBool() const { return isNull() ? Q_NULLPTR : &QSharedPointer::value; }
- inline bool operator !() const { return isNull(); }
- inline T &operator*() const { return *data(); }
- inline T *operator->() const { return data(); }
-
- QSharedPointer() Q_DECL_NOTHROW : value(Q_NULLPTR), d(Q_NULLPTR) {}
+ T *data() const Q_DECL_NOTHROW { return value; }
+ bool isNull() const Q_DECL_NOTHROW { return !data(); }
+ operator RestrictedBool() const Q_DECL_NOTHROW { return isNull() ? Q_NULLPTR : &QSharedPointer::value; }
+ bool operator !() const Q_DECL_NOTHROW { return isNull(); }
+ T &operator*() const { return *data(); }
+ T *operator->() const Q_DECL_NOTHROW { return data(); }
+
+ Q_DECL_CONSTEXPR QSharedPointer() Q_DECL_NOTHROW : value(nullptr), d(nullptr) { }
~QSharedPointer() { deref(); }
- inline explicit QSharedPointer(T *ptr) : value(ptr) // noexcept
+ Q_DECL_CONSTEXPR QSharedPointer(std::nullptr_t) Q_DECL_NOTHROW : value(nullptr), d(nullptr) { }
+
+ template <class X>
+ inline explicit QSharedPointer(X *ptr) : value(ptr) // noexcept
{ internalConstruct(ptr, QtSharedPointer::NormalDeleter()); }
- template <typename Deleter>
- inline QSharedPointer(T *ptr, Deleter deleter) : value(ptr) // throws
+ template <class X, typename Deleter>
+ inline QSharedPointer(X *ptr, Deleter deleter) : value(ptr) // throws
{ internalConstruct(ptr, deleter); }
+ template <typename Deleter>
+ QSharedPointer(std::nullptr_t, Deleter) : value(nullptr), d(nullptr) { }
+
QSharedPointer(const QSharedPointer &other) Q_DECL_NOTHROW : value(other.value), d(other.d)
{ if (d) ref(); }
QSharedPointer &operator=(const QSharedPointer &other) Q_DECL_NOTHROW
@@ -363,7 +369,7 @@ public:
#endif
template <class X>
- inline QSharedPointer(const QSharedPointer<X> &other) : value(other.value), d(other.d)
+ QSharedPointer(const QSharedPointer<X> &other) Q_DECL_NOTHROW : value(other.value), d(other.d)
{ if (d) ref(); }
template <class X>
@@ -511,15 +517,15 @@ private:
inline void enableSharedFromThis(...) {}
- template <typename Deleter>
- inline void internalConstruct(T *ptr, Deleter deleter)
+ template <typename X, typename Deleter>
+ inline void internalConstruct(X *ptr, Deleter deleter)
{
if (!ptr) {
d = Q_NULLPTR;
return;
}
- typedef QtSharedPointer::ExternalRefCountWithCustomDeleter<T, Deleter> Private;
+ typedef QtSharedPointer::ExternalRefCountWithCustomDeleter<X, Deleter> Private;
# ifdef QT_SHAREDPOINTER_TRACK_POINTERS
typename Private::DestroyerFn actualDeleter = &Private::safetyCheckDeleter;
# else
@@ -598,10 +604,10 @@ public:
typedef const value_type &const_reference;
typedef qptrdiff difference_type;
- inline bool isNull() const { return d == Q_NULLPTR || d->strongref.load() == 0 || value == Q_NULLPTR; }
- inline operator RestrictedBool() const { return isNull() ? Q_NULLPTR : &QWeakPointer::value; }
- inline bool operator !() const { return isNull(); }
- inline T *data() const { return d == Q_NULLPTR || d->strongref.load() == 0 ? Q_NULLPTR : value; }
+ bool isNull() const Q_DECL_NOTHROW { return d == Q_NULLPTR || d->strongref.load() == 0 || value == Q_NULLPTR; }
+ operator RestrictedBool() const Q_DECL_NOTHROW { return isNull() ? Q_NULLPTR : &QWeakPointer::value; }
+ bool operator !() const Q_DECL_NOTHROW { return isNull(); }
+ T *data() const Q_DECL_NOTHROW { return d == Q_NULLPTR || d->strongref.load() == 0 ? Q_NULLPTR : value; }
inline QWeakPointer() Q_DECL_NOTHROW : d(Q_NULLPTR), value(Q_NULLPTR) { }
inline ~QWeakPointer() { if (d && !d->weakref.deref()) delete d; }
@@ -668,11 +674,11 @@ public:
}
template <class X>
- inline bool operator==(const QWeakPointer<X> &o) const
+ bool operator==(const QWeakPointer<X> &o) const Q_DECL_NOTHROW
{ return d == o.d && value == static_cast<const T *>(o.value); }
template <class X>
- inline bool operator!=(const QWeakPointer<X> &o) const
+ bool operator!=(const QWeakPointer<X> &o) const Q_DECL_NOTHROW
{ return !(*this == o); }
template <class X>
@@ -688,11 +694,11 @@ public:
}
template <class X>
- inline bool operator==(const QSharedPointer<X> &o) const
+ bool operator==(const QSharedPointer<X> &o) const Q_DECL_NOTHROW
{ return d == o.d; }
template <class X>
- inline bool operator!=(const QSharedPointer<X> &o) const
+ bool operator!=(const QSharedPointer<X> &o) const Q_DECL_NOTHROW
{ return !(*this == o); }
inline void clear() { *this = QWeakPointer(); }
@@ -774,48 +780,96 @@ public:
// operator== and operator!=
//
template <class T, class X>
-bool operator==(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
+bool operator==(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2) Q_DECL_NOTHROW
{
return ptr1.data() == ptr2.data();
}
template <class T, class X>
-bool operator!=(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
+bool operator!=(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2) Q_DECL_NOTHROW
{
return ptr1.data() != ptr2.data();
}
template <class T, class X>
-bool operator==(const QSharedPointer<T> &ptr1, const X *ptr2)
+bool operator==(const QSharedPointer<T> &ptr1, const X *ptr2) Q_DECL_NOTHROW
{
return ptr1.data() == ptr2;
}
template <class T, class X>
-bool operator==(const T *ptr1, const QSharedPointer<X> &ptr2)
+bool operator==(const T *ptr1, const QSharedPointer<X> &ptr2) Q_DECL_NOTHROW
{
return ptr1 == ptr2.data();
}
template <class T, class X>
-bool operator!=(const QSharedPointer<T> &ptr1, const X *ptr2)
+bool operator!=(const QSharedPointer<T> &ptr1, const X *ptr2) Q_DECL_NOTHROW
{
return !(ptr1 == ptr2);
}
template <class T, class X>
-bool operator!=(const T *ptr1, const QSharedPointer<X> &ptr2)
+bool operator!=(const T *ptr1, const QSharedPointer<X> &ptr2) Q_DECL_NOTHROW
{
return !(ptr2 == ptr1);
}
template <class T, class X>
-bool operator==(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2)
+bool operator==(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2) Q_DECL_NOTHROW
{
return ptr2 == ptr1;
}
template <class T, class X>
-bool operator!=(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2)
+bool operator!=(const QSharedPointer<T> &ptr1, const QWeakPointer<X> &ptr2) Q_DECL_NOTHROW
{
return ptr2 != ptr1;
}
+template<class T>
+inline bool operator==(const QSharedPointer<T> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return lhs.isNull();
+}
+
+template<class T>
+inline bool operator!=(const QSharedPointer<T> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return !lhs.isNull();
+}
+
+template<class T>
+inline bool operator==(std::nullptr_t, const QSharedPointer<T> &rhs) Q_DECL_NOTHROW
+{
+ return rhs.isNull();
+}
+
+template<class T>
+inline bool operator!=(std::nullptr_t, const QSharedPointer<T> &rhs) Q_DECL_NOTHROW
+{
+ return !rhs.isNull();
+}
+
+template<class T>
+inline bool operator==(const QWeakPointer<T> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return lhs.isNull();
+}
+
+template<class T>
+inline bool operator!=(const QWeakPointer<T> &lhs, std::nullptr_t) Q_DECL_NOTHROW
+{
+ return !lhs.isNull();
+}
+
+template<class T>
+inline bool operator==(std::nullptr_t, const QWeakPointer<T> &rhs) Q_DECL_NOTHROW
+{
+ return rhs.isNull();
+}
+
+template<class T>
+inline bool operator!=(std::nullptr_t, const QWeakPointer<T> &rhs) Q_DECL_NOTHROW
+{
+ return !rhs.isNull();
+}
+
//
// operator-
//
diff --git a/src/corelib/tools/qsimd.cpp b/src/corelib/tools/qsimd.cpp
index c869c4e089..d4edf459de 100644
--- a/src/corelib/tools/qsimd.cpp
+++ b/src/corelib/tools/qsimd.cpp
@@ -48,16 +48,8 @@
#endif
#if defined(Q_OS_WIN)
-# if defined(Q_OS_WINCE)
-# include <qt_windows.h>
-# if _WIN32_WCE < 0x800
-# include <cmnintrin.h>
-# endif
-# endif
# if !defined(Q_CC_GNU)
-# ifndef Q_OS_WINCE
-# include <intrin.h>
-# endif
+# include <intrin.h>
# endif
#elif defined(Q_OS_LINUX) && (defined(Q_PROCESSOR_ARM) || defined(Q_PROCESSOR_MIPS_32))
#include "private/qcore_unix_p.h"
@@ -93,25 +85,6 @@ static inline uint detectProcessorFeatures()
{
return 0;
}
-#elif defined (Q_OS_WINCE)
-static inline quint64 detectProcessorFeatures()
-{
- quint64 features = 0;
-
-#if defined (ARM)
-# ifdef PF_ARM_NEON
- if (IsProcessorFeaturePresent(PF_ARM_NEON))
- features |= Q_UINT64_C(1) << CpuFeatureNEON;
-# endif
-#elif defined(_X86_)
- if (IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE))
- features |= Q_UINT64_C(1) << CpuFeatureSSE2;
- if (IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE))
- features |= Q_UINT64_C(1) << CpuFeatureSSE3;
-#endif
- return features;
-}
-
#elif defined(Q_PROCESSOR_ARM)
static inline quint64 detectProcessorFeatures()
{
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index 7002d34654..9d8695c0f6 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -52,7 +52,7 @@
// We mean it.
//
-#include <qglobal.h>
+#include <QtCore/private/qglobal_p.h>
#include <qatomic.h>
/*
@@ -139,7 +139,7 @@
* }
*/
-#if defined(__MINGW64_VERSION_MAJOR) || (defined(Q_CC_MSVC) && !defined(Q_OS_WINCE))
+#if defined(__MINGW64_VERSION_MAJOR) || defined(Q_CC_MSVC)
#include <intrin.h>
#endif
@@ -465,65 +465,6 @@ static inline quint64 qCpuFeatures()
#define qCpuHasFeature(feature) ((qCompilerCpuFeatures & (Q_UINT64_C(1) << CpuFeature ## feature)) \
|| (qCpuFeatures() & (Q_UINT64_C(1) << CpuFeature ## feature)))
-#if QT_HAS_BUILTIN(__builtin_clz) && QT_HAS_BUILTIN(__builtin_ctz) && defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
-static Q_ALWAYS_INLINE unsigned _bit_scan_reverse(unsigned val)
-{
- Q_ASSERT(val != 0); // if val==0, the result is undefined.
- unsigned result = static_cast<unsigned>(__builtin_clz(val)); // Count Leading Zeros
- // Now Invert the result: clz will count *down* from the msb to the lsb, so the msb index is 31
- // and the lsb inde is 0. The result for _bit_scan_reverse is expected to be the index when
- // counting up: msb index is 0 (because it starts there), and the lsb index is 31.
- result ^= sizeof(unsigned) * 8 - 1;
- return result;
-}
-static Q_ALWAYS_INLINE unsigned _bit_scan_forward(unsigned val)
-{
- Q_ASSERT(val != 0); // if val==0, the result is undefined.
- return static_cast<unsigned>(__builtin_ctz(val)); // Count Trailing Zeros
-}
-#elif defined(Q_PROCESSOR_X86)
-// Bit scan functions for x86
-# if defined(Q_CC_MSVC)
-# if defined _WIN32_WCE && _WIN32_WCE < 0x800
-extern "C" unsigned char _BitScanForward(unsigned long* Index, unsigned long Mask);
-extern "C" unsigned char _BitScanReverse(unsigned long* Index, unsigned long Mask);
-# pragma intrinsic(_BitScanForward)
-# pragma intrinsic(_BitScanReverse)
-# endif
-// MSVC calls it _BitScanReverse and returns the carry flag, which we don't need
-static __forceinline unsigned long _bit_scan_reverse(uint val)
-{
- unsigned long result;
- _BitScanReverse(&result, val);
- return result;
-}
-static __forceinline unsigned long _bit_scan_forward(uint val)
-{
- unsigned long result;
- _BitScanForward(&result, val);
- return result;
-}
-# elif (defined(Q_CC_CLANG) || (defined(Q_CC_GNU) && Q_CC_GNU < 405)) \
- && !defined(Q_CC_INTEL)
-// Clang is missing the intrinsic for _bit_scan_reverse
-// GCC only added it in version 4.5
-static inline __attribute__((always_inline))
-unsigned _bit_scan_reverse(unsigned val)
-{
- unsigned result;
- asm("bsr %1, %0" : "=r" (result) : "r" (val));
- return result;
-}
-static inline __attribute__((always_inline))
-unsigned _bit_scan_forward(unsigned val)
-{
- unsigned result;
- asm("bsf %1, %0" : "=r" (result) : "r" (val));
- return result;
-}
-# endif
-#endif // Q_PROCESSOR_X86
-
#define ALIGNMENT_PROLOGUE_16BYTES(ptr, i, length) \
for (; i < static_cast<int>(qMin(static_cast<quintptr>(length), ((4 - ((reinterpret_cast<quintptr>(ptr) >> 2) & 0x3)) & 0x3))); ++i)
diff --git a/src/corelib/tools/qsize.h b/src/corelib/tools/qsize.h
index 5d40c4079a..cd5f8adbf5 100644
--- a/src/corelib/tools/qsize.h
+++ b/src/corelib/tools/qsize.h
@@ -42,6 +42,10 @@
#include <QtCore/qnamespace.h>
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+struct CGSize;
+#endif
+
QT_BEGIN_NAMESPACE
@@ -86,6 +90,10 @@ public:
friend inline Q_DECL_CONSTEXPR const QSize operator*(qreal, const QSize &) Q_DECL_NOTHROW;
friend inline const QSize operator/(const QSize &, qreal);
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+ CGSize toCGSize() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+#endif
+
private:
int wd;
int ht;
@@ -248,6 +256,11 @@ public:
Q_DECL_CONSTEXPR inline QSize toSize() const Q_DECL_NOTHROW;
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+ static QSizeF fromCGSize(CGSize size) Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+ CGSize toCGSize() const Q_DECL_NOTHROW Q_REQUIRED_RESULT;
+#endif
+
private:
qreal wd;
qreal ht;
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 69fd4f1e52..bf1bc3e650 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -81,9 +81,6 @@
#ifdef Q_OS_WIN
# include <qt_windows.h>
-# ifdef Q_OS_WINCE
-# include <winnls.h>
-# endif
#endif
#ifdef truncate
@@ -471,7 +468,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, int l)
uint mask = ~_mm_movemask_epi8(result);
if (ushort(mask)) {
// found a different byte
- uint idx = uint(_bit_scan_forward(mask));
+ uint idx = qCountTrailingZeroBits(mask);
return reinterpret_cast<const QChar *>(ptr + idx)->unicode()
- reinterpret_cast<const QChar *>(ptr + distance + idx)->unicode();
}
@@ -574,7 +571,7 @@ static int ucstrncmp(const QChar *a, const uchar *c, int l)
# endif
if (mask) {
// found a different character
- uint idx = uint(_bit_scan_forward(mask));
+ uint idx = qCountTrailingZeroBits(mask);
return uc[offset + idx / 2] - c[offset + idx / 2];
}
}
@@ -592,7 +589,7 @@ static int ucstrncmp(const QChar *a, const uchar *c, int l)
uint mask = ~_mm_movemask_epi8(result);
if (ushort(mask)) {
// found a different character
- uint idx = uint(_bit_scan_forward(mask));
+ uint idx = qCountTrailingZeroBits(mask);
return uc[offset + idx / 2] - c[offset + idx / 2];
}
@@ -687,7 +684,7 @@ static int findChar(const QChar *str, int len, QChar ch, int from,
// found a match
// same as: return n - s + _bit_scan_forward(mask) / 2
return (reinterpret_cast<const char *>(n) - reinterpret_cast<const char *>(s)
- + _bit_scan_forward(mask)) >> 1;
+ + qCountTrailingZeroBits(mask)) >> 1;
}
}
@@ -1152,7 +1149,7 @@ const QString::Null QString::null = { };
has a ref count of 1, whereas QString::append() needs an extra
test).
- There are three ways you can access this improved method of string
+ There are two ways you can access this improved method of string
construction. The straightforward way is to include
\c{QStringBuilder} wherever you want to use it, and use the
\c{'%'} operator instead of \c{'+'} when concatenating strings:
@@ -3266,22 +3263,7 @@ static int lastIndexOfHelper(const ushort *haystack, int from, const ushort *nee
*/
int QString::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) const
{
- const int sl = str.d->size;
- if (sl == 1)
- return lastIndexOf(QChar(str.d->data()[0]), from, cs);
-
- const int l = d->size;
- if (from < 0)
- from += l;
- int delta = l-sl;
- if (from == l && sl == 0)
- return from;
- if (uint(from) >= uint(l) || delta < 0)
- return -1;
- if (from > delta)
- from = delta;
-
- return lastIndexOfHelper(d->data(), from, str.d->data(), str.d->size, cs);
+ return QStringRef(this).lastIndexOf(QStringRef(&str), from, cs);
}
/*!
@@ -3305,25 +3287,7 @@ int QString::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) c
*/
int QString::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs) const
{
- const int sl = str.size();
- if (sl == 1)
- return lastIndexOf(QLatin1Char(str.latin1()[0]), from, cs);
-
- const int l = d->size;
- if (from < 0)
- from += l;
- int delta = l-sl;
- if (from == l && sl == 0)
- return from;
- if (uint(from) >= uint(l) || delta < 0)
- return -1;
- if (from > delta)
- from = delta;
-
- QVarLengthArray<ushort> s(sl);
- qt_from_latin1(s.data(), str.latin1(), sl);
-
- return lastIndexOfHelper(d->data(), from, s.data(), sl, cs);
+ return QStringRef(this).lastIndexOf(str, from, cs);
}
/*!
@@ -3354,23 +3318,7 @@ int QString::lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
*/
int QString::lastIndexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs) const
{
- const int sl = str.size();
- if (sl == 1)
- return lastIndexOf(str.at(0), from, cs);
-
- const int l = d->size;
- if (from < 0)
- from += l;
- int delta = l - sl;
- if (from == l && sl == 0)
- return from;
- if (uint(from) >= uint(l) || delta < 0)
- return -1;
- if (from > delta)
- from = delta;
-
- return lastIndexOfHelper(d->data(), from, reinterpret_cast<const ushort*>(str.unicode()),
- str.size(), cs);
+ return QStringRef(this).lastIndexOf(str, from, cs);
}
@@ -5045,7 +4993,7 @@ void QString::truncate(int pos)
If you want to remove characters from the \e beginning of the
string, use remove() instead.
- \sa truncate(), resize(), remove()
+ \sa truncate(), resize(), remove(), QStringRef::chop()
*/
void QString::chop(int n)
{
@@ -5453,9 +5401,15 @@ int QString::compare(QLatin1String other, Qt::CaseSensitivity cs) const Q_DECL_N
int QString::compare_helper(const QChar *data1, int length1, const char *data2, int length2,
Qt::CaseSensitivity cs)
{
- // ### optimize me
- const QString s2 = QString::fromUtf8(data2, length2 == -1 ? (data2 ? int(strlen(data2)) : -1) : length2);
- return compare_helper(data1, length1, s2.constData(), s2.size(), cs);
+ if (!data2)
+ return length1;
+ if (Q_UNLIKELY(length2 < 0))
+ length2 = int(strlen(data2));
+ // ### make me nothrow in all cases
+ QVarLengthArray<ushort> s2(length2);
+ const auto beg = reinterpret_cast<QChar *>(s2.data());
+ const auto end = QUtf8::convertToUnicode(beg, data2, length2);
+ return compare_helper(data1, length1, beg, end - beg, cs);
}
/*!
@@ -5556,7 +5510,7 @@ int QString::localeAwareCompare(const QString &other) const
return localeAwareCompare_helper(constData(), length(), other.constData(), other.length());
}
-#if defined(QT_USE_ICU) && !defined(Q_OS_WIN32) && !defined(Q_OS_WINCE) && !defined (Q_OS_MAC)
+#if defined(QT_USE_ICU) && !defined(Q_OS_WIN32) && !defined(Q_OS_DARWIN)
Q_GLOBAL_STATIC(QThreadStorage<QCollator>, defaultCollator)
#endif
@@ -5571,12 +5525,12 @@ int QString::localeAwareCompare_helper(const QChar *data1, int length1,
if (length1 == 0 || length2 == 0)
return ucstrcmp(data1, length1, data2, length2);
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
-#ifndef Q_OS_WINRT
+#if defined(Q_OS_WIN)
+# ifndef Q_OS_WINRT
int res = CompareString(GetUserDefaultLCID(), 0, (wchar_t*)data1, length1, (wchar_t*)data2, length2);
-#else
+# else
int res = CompareStringEx(LOCALE_NAME_USER_DEFAULT, 0, (LPCWSTR)data1, length1, (LPCWSTR)data2, length2, NULL, NULL, 0);
-#endif
+# endif
switch (res) {
case CSTR_LESS_THAN:
@@ -7983,40 +7937,6 @@ QString QString::multiArg(int numArgs, const QString **args) const
return result;
}
-
-/*! \fn QString QString::fromCFString(CFStringRef string)
- \since 5.2
-
- Constructs a new QString containing a copy of the \a string CFString.
-
- \note this function is only available on \macos and iOS.
-*/
-
-/*! \fn CFStringRef QString::toCFString() const
- \since 5.2
-
- Creates a CFString from a QString. The caller owns the CFString and is
- responsible for releasing it.
-
- \note this function is only available on \macos and iOS.
-*/
-
-/*! \fn QString QString::fromNSString(const NSString *string)
- \since 5.2
-
- Constructs a new QString containing a copy of the \a string NSString.
-
- \note this function is only available on \macos and iOS.
-*/
-
-/*! \fn NSString QString::toNSString() const
- \since 5.2
-
- Creates a NSString from a QString. The NSString is autoreleased.
-
- \note this function is only available on \macos and iOS.
-*/
-
/*! \fn bool QString::isSimpleText() const
\internal
@@ -8366,6 +8286,78 @@ QString &QString::setRawData(const QChar *unicode, int size)
Returns the size of the Latin-1 string stored in this object.
*/
+/*! \fn QLatin1Char QLatin1String::at(int pos) const
+ \since 5.8
+
+ Returns the character at position \a pos in this object.
+
+ \note This function performs no error checking.
+ The behavior is undefined when \a pos < 0 or \a pos ≥ size().
+
+ \sa operator[]()
+*/
+
+/*! \fn QLatin1Char QLatin1String::operator[](int pos) const
+ \since 5.8
+
+ Returns the character at position \a pos in this object.
+
+ \note This function performs no error checking.
+ The behavior is undefined when \a pos < 0 or \a pos ≥ size().
+
+ \sa at()
+*/
+
+/*! \fn QLatin1String QLatin1String::mid(int start) const
+ \since 5.8
+
+ Returns the substring starting at position \a start in this object,
+ and extending to the end of the string.
+
+ \note This function performs no error checking.
+ The behavior is undefined when \a start < 0 or \a start > size().
+
+ \sa left(), right()
+*/
+
+/*! \fn QLatin1String QLatin1String::mid(int start, int length) const
+ \since 5.8
+ \overload
+
+ Returns the substring of length \a length starting at position
+ \a start in this object.
+
+ \note This function performs no error checking.
+ The behavior is undefined when \a start < 0, \a length < 0,
+ or \a start + \a length > size().
+
+ \sa left(), right()
+*/
+
+/*! \fn QLatin1String QLatin1String::left(int length) const
+ \since 5.8
+
+ Returns the substring of length \a length starting at position
+ 0 in this object.
+
+ \note This function performs no error checking.
+ The behavior is undefined when \a length < 0 or \a length > size().
+
+ \sa mid(), right()
+*/
+
+/*! \fn QLatin1String QLatin1String::right(int length) const
+ \since 5.8
+
+ Returns the substring of length \a length starting at position
+ size() - \a length in this object.
+
+ \note This function performs no error checking.
+ The behavior is undefined when \a length < 0 or \a length > size().
+
+ \sa mid(), left()
+*/
+
/*! \fn bool QLatin1String::operator==(const QString &other) const
Returns \c true if this string is equal to string \a other;
@@ -9398,6 +9390,24 @@ QStringRef QStringRef::appendTo(QString *string) const
*/
/*!
+ \overload
+ \fn int QStringRef::compare(const QByteArray &other, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ \since 5.8
+
+ Compares this string with \a other and returns an
+ integer less than, equal to, or greater than zero if this string
+ is less than, equal to, or greater than the \a other byte array,
+ interpreted as a UTF-8 sequence.
+
+ If \a cs is Qt::CaseSensitive, the comparison is case sensitive;
+ otherwise the comparison is case insensitive.
+
+ Equivalent to \c {compare(*this, other, cs)}.
+
+ \sa QString::compare()
+*/
+
+/*!
\fn int QStringRef::localeAwareCompare(const QStringRef &s1, const QString & s2)
\since 4.5
@@ -9640,6 +9650,18 @@ QStringRef QString::midRef(int position, int n) const
*/
/*!
+ \fn void QStringRef::chop(int n)
+ \since 5.8
+
+ Removes \a n characters from the end of the string.
+
+ If \a n is greater than or equal to size(), the result is an
+ empty string; if \a n is negative, it is equivalent to passing zero.
+
+ \sa QString::chop(), truncate()
+*/
+
+/*!
\since 4.8
Returns the index position of the first occurrence of the string \a
@@ -9729,23 +9751,7 @@ int QStringRef::indexOf(const QStringRef &str, int from, Qt::CaseSensitivity cs)
*/
int QStringRef::lastIndexOf(const QString &str, int from, Qt::CaseSensitivity cs) const
{
- const int sl = str.size();
- if (sl == 1)
- return lastIndexOf(str.at(0), from, cs);
-
- const int l = size();;
- if (from < 0)
- from += l;
- int delta = l - sl;
- if (from == l && sl == 0)
- return from;
- if (uint(from) >= uint(l) || delta < 0)
- return -1;
- if (from > delta)
- from = delta;
-
- return lastIndexOfHelper(reinterpret_cast<const ushort*>(unicode()), from,
- reinterpret_cast<const ushort*>(str.unicode()), str.size(), cs);
+ return lastIndexOf(QStringRef(&str), from, cs);
}
/*!
@@ -9781,7 +9787,7 @@ int QStringRef::lastIndexOf(QLatin1String str, int from, Qt::CaseSensitivity cs)
{
const int sl = str.size();
if (sl == 1)
- return lastIndexOf(QLatin1Char(str.latin1()[0]), from, cs);
+ return lastIndexOf(str.at(0), from, cs);
const int l = size();
if (from < 0)
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 3dda382dd5..a110c129de 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -68,11 +68,9 @@ namespace std
#error qstring.h must be included before any header file that defines truncate
#endif
-#ifdef Q_OS_MAC
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_FORWARD_DECLARE_CF_TYPE(CFString);
-# ifdef __OBJC__
Q_FORWARD_DECLARE_OBJC_CLASS(NSString);
-# endif
#endif
QT_BEGIN_NAMESPACE
@@ -99,6 +97,18 @@ public:
Q_DECL_CONSTEXPR int size() const Q_DECL_NOTHROW { return m_size; }
Q_DECL_CONSTEXPR const char *data() const Q_DECL_NOTHROW { return m_data; }
+ Q_DECL_CONSTEXPR QLatin1Char at(int i) const { return QLatin1Char(m_data[i]); }
+ Q_DECL_CONSTEXPR QLatin1Char operator[](int i) const { return at(i); }
+
+ Q_DECL_CONSTEXPR QLatin1String mid(int pos) const
+ { return QLatin1String(m_data + pos, m_size - pos); }
+ Q_DECL_CONSTEXPR QLatin1String mid(int pos, int n) const
+ { return QLatin1String(m_data + pos, n); }
+ Q_DECL_CONSTEXPR QLatin1String left(int n) const
+ { return QLatin1String(m_data, n); }
+ Q_DECL_CONSTEXPR QLatin1String right(int n) const
+ { return QLatin1String(m_data + m_size - n, n); }
+
inline bool operator==(const QString &s) const Q_DECL_NOTHROW;
inline bool operator!=(const QString &s) const Q_DECL_NOTHROW;
inline bool operator>(const QString &s) const Q_DECL_NOTHROW;
@@ -593,7 +603,7 @@ public:
Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW
{ return -s2.compare(s1, cs); }
- int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW;
+ inline int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW;
static int compare(const QString &s1, const QStringRef &s2,
Qt::CaseSensitivity = Qt::CaseSensitive) Q_DECL_NOTHROW;
@@ -768,13 +778,11 @@ public:
inline std::u32string toStdU32String() const;
#endif
-#if defined(Q_OS_MAC) || defined(Q_QDOC)
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
static QString fromCFString(CFStringRef string);
CFStringRef toCFString() const Q_DECL_CF_RETURNS_RETAINED;
-# if defined(__OBJC__) || defined(Q_QDOC)
static QString fromNSString(const NSString *string);
NSString *toNSString() const Q_DECL_NS_RETURNS_AUTORELEASED;
-# endif
#endif
// compatibility
struct Null { };
@@ -802,6 +810,16 @@ private:
Data *d;
+ friend inline bool operator==(QChar, const QString &) Q_DECL_NOTHROW;
+ friend inline bool operator< (QChar, const QString &) Q_DECL_NOTHROW;
+ friend inline bool operator> (QChar, const QString &) Q_DECL_NOTHROW;
+ friend inline bool operator==(QChar, const QStringRef &) Q_DECL_NOTHROW;
+ friend inline bool operator< (QChar, const QStringRef &) Q_DECL_NOTHROW;
+ friend inline bool operator> (QChar, const QStringRef &) Q_DECL_NOTHROW;
+ friend inline bool operator==(QChar, QLatin1String) Q_DECL_NOTHROW;
+ friend inline bool operator< (QChar, QLatin1String) Q_DECL_NOTHROW;
+ friend inline bool operator> (QChar, QLatin1String) Q_DECL_NOTHROW;
+
void reallocData(uint alloc, bool grow = false);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void expand(int i);
@@ -1422,6 +1440,12 @@ public:
QStringRef mid(int pos, int n = -1) const Q_REQUIRED_RESULT;
void truncate(int pos) Q_DECL_NOTHROW { m_size = qBound(0, pos, m_size); }
+ void chop(int n) Q_DECL_NOTHROW {
+ if (n >= m_size)
+ m_size = 0;
+ else if (n > 0)
+ m_size -= n;
+ }
bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
@@ -1485,6 +1509,10 @@ public:
int compare(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW;
int compare(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW;
int compare(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const Q_DECL_NOTHROW;
+#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
+ int compare(const QByteArray &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const
+ { return QString::compare_helper(unicode(), size(), s.data(), qstrnlen(s.data(), s.size()), cs); }
+#endif
static int compare(const QStringRef &s1, const QString &s2,
Qt::CaseSensitivity = Qt::CaseSensitive) Q_DECL_NOTHROW;
static int compare(const QStringRef &s1, const QStringRef &s2,
@@ -1520,24 +1548,10 @@ inline QStringRef::QStringRef(const QString *aString, int aPosition, int aSize)
inline QStringRef::QStringRef(const QString *aString)
:m_string(aString), m_position(0), m_size(aString?aString->size() : 0){}
+// QStringRef <> QStringRef
Q_CORE_EXPORT bool operator==(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW;
inline bool operator!=(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW
{ return !(s1 == s2); }
-Q_CORE_EXPORT bool operator==(const QString &s1, const QStringRef &s2) Q_DECL_NOTHROW;
-inline bool operator!=(const QString &s1, const QStringRef &s2) Q_DECL_NOTHROW
-{ return !(s1 == s2); }
-inline bool operator==(const QStringRef &s1, const QString &s2) Q_DECL_NOTHROW
-{ return s2 == s1; }
-inline bool operator!=(const QStringRef &s1, const QString &s2) Q_DECL_NOTHROW
-{ return s2 != s1; }
-Q_CORE_EXPORT bool operator==(QLatin1String s1, const QStringRef &s2) Q_DECL_NOTHROW;
-inline bool operator!=(QLatin1String s1, const QStringRef &s2) Q_DECL_NOTHROW
-{ return !(s1 == s2); }
-inline bool operator==(const QStringRef &s1, QLatin1String s2) Q_DECL_NOTHROW
-{ return s2 == s1; }
-inline bool operator!=(const QStringRef &s1, QLatin1String s2) Q_DECL_NOTHROW
-{ return s2 != s1; }
-
Q_CORE_EXPORT bool operator<(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW;
inline bool operator>(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW
{ return s2 < s1; }
@@ -1546,7 +1560,127 @@ inline bool operator<=(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHRO
inline bool operator>=(const QStringRef &s1, const QStringRef &s2) Q_DECL_NOTHROW
{ return !(s1 < s2); }
+// QString <> QStringRef
+Q_CORE_EXPORT bool operator==(const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW;
+inline bool operator!=(const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) != 0; }
+inline bool operator< (const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) < 0; }
+inline bool operator> (const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) > 0; }
+inline bool operator<=(const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) <= 0; }
+inline bool operator>=(const QString &lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return lhs.compare(rhs) >= 0; }
+
+inline bool operator==(const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs == lhs; }
+inline bool operator!=(const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs != lhs; }
+inline bool operator< (const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs > lhs; }
+inline bool operator> (const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs < lhs; }
+inline bool operator<=(const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs >= lhs; }
+inline bool operator>=(const QStringRef &lhs, const QString &rhs) Q_DECL_NOTHROW { return rhs <= lhs; }
+
+inline int QString::compare(const QStringRef &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
+{ return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); }
+inline int QString::compare(const QString &s1, const QStringRef &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
+{ return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); }
+inline int QStringRef::compare(const QString &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
+{ return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); }
+inline int QStringRef::compare(const QStringRef &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
+{ return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); }
+inline int QStringRef::compare(QLatin1String s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
+{ return QString::compare_helper(constData(), length(), s, cs); }
+inline int QStringRef::compare(const QStringRef &s1, const QString &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
+{ return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); }
+inline int QStringRef::compare(const QStringRef &s1, const QStringRef &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
+{ return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); }
+inline int QStringRef::compare(const QStringRef &s1, QLatin1String s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
+{ return QString::compare_helper(s1.constData(), s1.length(), s2, cs); }
+
+// QLatin1String <> QStringRef
+Q_CORE_EXPORT bool operator==(QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW;
+inline bool operator!=(QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) != 0; }
+inline bool operator< (QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) > 0; }
+inline bool operator> (QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) < 0; }
+inline bool operator<=(QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) >= 0; }
+inline bool operator>=(QLatin1String lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return rhs.compare(lhs) <= 0; }
+
+inline bool operator==(const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs == lhs; }
+inline bool operator!=(const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs != lhs; }
+inline bool operator< (const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs > lhs; }
+inline bool operator> (const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs < lhs; }
+inline bool operator<=(const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs >= lhs; }
+inline bool operator>=(const QStringRef &lhs, QLatin1String rhs) Q_DECL_NOTHROW { return rhs <= lhs; }
+
+// QChar <> QString
+inline bool operator==(QChar lhs, const QString &rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) == 0; }
+inline bool operator< (QChar lhs, const QString &rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) < 0; }
+inline bool operator> (QChar lhs, const QString &rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) > 0; }
+
+inline bool operator!=(QChar lhs, const QString &rhs) Q_DECL_NOTHROW { return !(lhs == rhs); }
+inline bool operator<=(QChar lhs, const QString &rhs) Q_DECL_NOTHROW { return !(lhs > rhs); }
+inline bool operator>=(QChar lhs, const QString &rhs) Q_DECL_NOTHROW { return !(lhs < rhs); }
+
+inline bool operator==(const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs == lhs; }
+inline bool operator!=(const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs == lhs); }
+inline bool operator< (const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs > lhs; }
+inline bool operator> (const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs < lhs; }
+inline bool operator<=(const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs < lhs); }
+inline bool operator>=(const QString &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs > lhs); }
+
+// QChar <> QStringRef
+inline bool operator==(QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) == 0; }
+inline bool operator< (QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) < 0; }
+inline bool operator> (QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs.data(), rhs.size()) > 0; }
+
+inline bool operator!=(QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return !(lhs == rhs); }
+inline bool operator<=(QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return !(lhs > rhs); }
+inline bool operator>=(QChar lhs, const QStringRef &rhs) Q_DECL_NOTHROW { return !(lhs < rhs); }
+
+inline bool operator==(const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs == lhs; }
+inline bool operator!=(const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs == lhs); }
+inline bool operator< (const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs > lhs; }
+inline bool operator> (const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return rhs < lhs; }
+inline bool operator<=(const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs < lhs); }
+inline bool operator>=(const QStringRef &lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs > lhs); }
+
+// QChar <> QLatin1String
+inline bool operator==(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs) == 0; }
+inline bool operator< (QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs) < 0; }
+inline bool operator> (QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW
+{ return QString::compare_helper(&lhs, 1, rhs) > 0; }
+
+inline bool operator!=(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW { return !(lhs == rhs); }
+inline bool operator<=(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW { return !(lhs > rhs); }
+inline bool operator>=(QChar lhs, QLatin1String rhs) Q_DECL_NOTHROW { return !(lhs < rhs); }
+
+inline bool operator==(QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return rhs == lhs; }
+inline bool operator!=(QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs == lhs); }
+inline bool operator< (QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return rhs > lhs; }
+inline bool operator> (QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return rhs < lhs; }
+inline bool operator<=(QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs < lhs); }
+inline bool operator>=(QLatin1String lhs, QChar rhs) Q_DECL_NOTHROW { return !(rhs > lhs); }
+
#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
+// QStringRef <> QByteArray
+inline QT_ASCII_CAST_WARN bool operator==(const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) == 0; }
+inline QT_ASCII_CAST_WARN bool operator!=(const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) != 0; }
+inline QT_ASCII_CAST_WARN bool operator< (const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) < 0; }
+inline QT_ASCII_CAST_WARN bool operator> (const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) > 0; }
+inline QT_ASCII_CAST_WARN bool operator<=(const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) <= 0; }
+inline QT_ASCII_CAST_WARN bool operator>=(const QStringRef &lhs, const QByteArray &rhs) { return lhs.compare(rhs) >= 0; }
+
+inline QT_ASCII_CAST_WARN bool operator==(const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) == 0; }
+inline QT_ASCII_CAST_WARN bool operator!=(const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) != 0; }
+inline QT_ASCII_CAST_WARN bool operator< (const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) > 0; }
+inline QT_ASCII_CAST_WARN bool operator> (const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) < 0; }
+inline QT_ASCII_CAST_WARN bool operator<=(const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) >= 0; }
+inline QT_ASCII_CAST_WARN bool operator>=(const QByteArray &lhs, const QStringRef &rhs) { return rhs.compare(lhs) <= 0; }
+
+// QStringRef <> const char *
inline QT_ASCII_CAST_WARN bool QStringRef::operator==(const char *s) const
{ return QString::compare_helper(constData(), size(), s, -1) == 0; }
inline QT_ASCII_CAST_WARN bool QStringRef::operator!=(const char *s) const
@@ -1574,23 +1708,6 @@ inline QT_ASCII_CAST_WARN bool operator>=(const char *s1, const QStringRef &s2)
{ return QString::compare_helper(s2.constData(), s2.size(), s1, -1) <= 0; }
#endif // !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
-inline int QString::compare(const QStringRef &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
-{ return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); }
-inline int QString::compare(const QString &s1, const QStringRef &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
-{ return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); }
-inline int QStringRef::compare(const QString &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
-{ return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); }
-inline int QStringRef::compare(const QStringRef &s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
-{ return QString::compare_helper(constData(), length(), s.constData(), s.length(), cs); }
-inline int QStringRef::compare(QLatin1String s, Qt::CaseSensitivity cs) const Q_DECL_NOTHROW
-{ return QString::compare_helper(constData(), length(), s, cs); }
-inline int QStringRef::compare(const QStringRef &s1, const QString &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
-{ return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); }
-inline int QStringRef::compare(const QStringRef &s1, const QStringRef &s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
-{ return QString::compare_helper(s1.constData(), s1.length(), s2.constData(), s2.length(), cs); }
-inline int QStringRef::compare(const QStringRef &s1, QLatin1String s2, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
-{ return QString::compare_helper(s1.constData(), s1.length(), s2, cs); }
-
inline int QString::localeAwareCompare(const QStringRef &s) const
{ return localeAwareCompare_helper(constData(), length(), s.constData(), s.length()); }
inline int QString::localeAwareCompare(const QString& s1, const QStringRef& s2)
@@ -1616,6 +1733,23 @@ inline bool QStringRef::contains(const QStringRef &s, Qt::CaseSensitivity cs) co
inline QString &QString::insert(int i, const QStringRef &s)
{ return insert(i, s.constData(), s.length()); }
+#if !defined(QT_USE_FAST_OPERATOR_PLUS) && !defined(QT_USE_QSTRINGBUILDER)
+inline QString operator+(const QString &s1, const QStringRef &s2)
+{ QString t; t.reserve(s1.size() + s2.size()); t += s1; t += s2; return t; }
+inline QString operator+(const QStringRef &s1, const QString &s2)
+{ QString t; t.reserve(s1.size() + s2.size()); t += s1; t += s2; return t; }
+inline QString operator+(const QStringRef &s1, QLatin1String s2)
+{ QString t; t.reserve(s1.size() + s2.size()); t += s1; t += s2; return t; }
+inline QString operator+(QLatin1String s1, const QStringRef &s2)
+{ QString t; t.reserve(s1.size() + s2.size()); t += s1; t += s2; return t; }
+inline QString operator+(const QStringRef &s1, const QStringRef &s2)
+{ QString t; t.reserve(s1.size() + s2.size()); t += s1; t += s2; return t; }
+inline QString operator+(const QStringRef &s1, QChar s2)
+{ QString t; t.reserve(s1.size() + 1); t += s1; t += s2; return t; }
+inline QString operator+(QChar s1, const QStringRef &s2)
+{ QString t; t.reserve(1 + s2.size()); t += s1; t += s2; return t; }
+#endif // !(QT_USE_FAST_OPERATOR_PLUS || QT_USE_QSTRINGBUILDER)
+
namespace Qt {
#if QT_DEPRECATED_SINCE(5, 0)
QT_DEPRECATED inline QString escape(const QString &plain) {
diff --git a/src/corelib/tools/qstringiterator_p.h b/src/corelib/tools/qstringiterator_p.h
index 2e24031ce4..7cf59ae42f 100644
--- a/src/corelib/tools/qstringiterator_p.h
+++ b/src/corelib/tools/qstringiterator_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qstring.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/tools/qstringlist.h b/src/corelib/tools/qstringlist.h
index e01f9e16e8..87f15528bf 100644
--- a/src/corelib/tools/qstringlist.h
+++ b/src/corelib/tools/qstringlist.h
@@ -149,6 +149,7 @@ public:
Q_DECLARE_TYPEINFO(QStringList, Q_MOVABLE_TYPE);
+#ifndef Q_QDOC
inline QStringList *QListSpecialMethods<QString>::self()
{ return static_cast<QStringList *>(this); }
inline const QStringList *QListSpecialMethods<QString>::self() const
@@ -284,6 +285,7 @@ inline int QStringList::lastIndexOf(const QRegularExpression &rx, int from) cons
}
#endif // QT_NO_REGULAREXPRESSION
#endif // QT_BOOTSTRAPPED
+#endif // Q_QDOC
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qtimezoneprivate_data_p.h b/src/corelib/tools/qtimezoneprivate_data_p.h
index b4e52af33a..6bbcb0e2cd 100644
--- a/src/corelib/tools/qtimezoneprivate_data_p.h
+++ b/src/corelib/tools/qtimezoneprivate_data_p.h
@@ -52,6 +52,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
QT_BEGIN_NAMESPACE
/*
diff --git a/src/corelib/tools/qtimezoneprivate_win.cpp b/src/corelib/tools/qtimezoneprivate_win.cpp
index 8e32db48de..4febeda537 100644
--- a/src/corelib/tools/qtimezoneprivate_win.cpp
+++ b/src/corelib/tools/qtimezoneprivate_win.cpp
@@ -383,17 +383,11 @@ static void calculateTransitionsForYear(const QWinTimeZonePrivate::QWinTransitio
static QLocale::Country userCountry()
{
-#if defined(Q_OS_WINCE)
- // Guess that the syslem locale country is the right one to use
- // TODO Find if WinCE has equivalent api
- return QLocale::system().country();
-#else
const GEOID id = GetUserGeoID(GEOCLASS_NATION);
wchar_t code[3];
const int size = GetGeoInfo(id, GEO_ISO2, code, 3, 0);
return (size == 3) ? QLocalePrivate::codeToCountry(reinterpret_cast<const QChar*>(code), size)
: QLocale::AnyCountry;
-#endif // Q_OS_WINCE
}
// Create the system default time zone
diff --git a/src/corelib/tools/qtools_p.h b/src/corelib/tools/qtools_p.h
index 09adee5586..17d2ab852a 100644
--- a/src/corelib/tools/qtools_p.h
+++ b/src/corelib/tools/qtools_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include "QtCore/qglobal.h"
+#include "QtCore/private/qglobal_p.h"
#include <limits.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/tools/qunicodetables_p.h b/src/corelib/tools/qunicodetables_p.h
index cec84a2490..5a422ea4eb 100644
--- a/src/corelib/tools/qunicodetables_p.h
+++ b/src/corelib/tools/qunicodetables_p.h
@@ -50,6 +50,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
#ifndef QUNICODETABLES_P_H
#define QUNICODETABLES_P_H
diff --git a/src/corelib/tools/qunicodetools_p.h b/src/corelib/tools/qunicodetools_p.h
index 5cde188656..5e2d56a226 100644
--- a/src/corelib/tools/qunicodetools_p.h
+++ b/src/corelib/tools/qunicodetools_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qchar.h>
QT_BEGIN_NAMESPACE
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index b64ec756ba..853827e032 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -71,7 +71,6 @@ HEADERS += \
tools/qtimezoneprivate_p.h \
tools/qtimezoneprivate_data_p.h \
tools/qtools_p.h \
- tools/qelapsedtimer.h \
tools/qunicodetables_p.h \
tools/qunicodetools_p.h \
tools/qvarlengtharray.h \
@@ -92,7 +91,6 @@ SOURCES += \
tools/qdatetime.cpp \
tools/qdatetimeparser.cpp \
tools/qeasingcurve.cpp \
- tools/qelapsedtimer.cpp \
tools/qfreelist.cpp \
tools/qhash.cpp \
tools/qline.cpp \
@@ -130,33 +128,29 @@ msvc: NO_PCH_SOURCES += tools/qvector_msvc.cpp
false: SOURCES += $$NO_PCH_SOURCES # Hack for QtCreator
!nacl:mac: {
- SOURCES += tools/qelapsedtimer_mac.cpp
OBJECTIVE_SOURCES += tools/qlocale_mac.mm \
tools/qtimezoneprivate_mac.mm \
- tools/qstring_mac.mm \
- tools/qbytearray_mac.mm \
- tools/qdatetime_mac.mm
}
else:android {
- SOURCES += tools/qelapsedtimer_unix.cpp tools/qlocale_unix.cpp tools/qtimezoneprivate_android.cpp
+ SOURCES += tools/qlocale_unix.cpp tools/qtimezoneprivate_android.cpp
}
else:unix {
- SOURCES += tools/qelapsedtimer_unix.cpp tools/qlocale_unix.cpp tools/qtimezoneprivate_tz.cpp
+ SOURCES += tools/qlocale_unix.cpp tools/qtimezoneprivate_tz.cpp
}
else:win32 {
- SOURCES += tools/qelapsedtimer_win.cpp \
- tools/qlocale_win.cpp \
+ SOURCES += tools/qlocale_win.cpp \
tools/qtimezoneprivate_win.cpp
winphone: LIBS_PRIVATE += -lWindowsPhoneGlobalizationUtil
winrt-*-msvc2013: LIBS += advapi32.lib
-} else:integrity:SOURCES += tools/qelapsedtimer_unix.cpp tools/qlocale_unix.cpp
-else:SOURCES += tools/qelapsedtimer_generic.cpp
+} else:integrity {
+ SOURCES += tools/qlocale_unix.cpp
+}
-contains(QT_CONFIG, zlib) {
- include($$PWD/../../3rdparty/zlib.pri)
+contains(QT_CONFIG, system-zlib) {
+ include($$PWD/../../3rdparty/zlib_dependency.pri)
} else {
CONFIG += no_core_dep
- include($$PWD/../../3rdparty/zlib_dependency.pri)
+ include($$PWD/../../3rdparty/zlib.pri)
}
contains(QT_CONFIG,icu) {
@@ -198,12 +192,10 @@ INCLUDEPATH += ../3rdparty/md5 \
../3rdparty/md4 \
../3rdparty/sha3
-contains(QT_CONFIG, doubleconversion) {
- include($$PWD/../../3rdparty/double-conversion/double-conversion.pri)
-} else:contains(QT_CONFIG, system-doubleconversion) {
+contains(QT_CONFIG, system-doubleconversion) {
LIBS_PRIVATE += -ldouble-conversion
-} else {
- DEFINES += QT_NO_DOUBLECONVERSION
+} else: contains(QT_CONFIG, doubleconversion) {
+ include($$PWD/../../3rdparty/double-conversion/double-conversion.pri)
}
# Note: libm should be present by default becaue this is C++
diff --git a/src/corelib/xml/qxmlstream_p.h b/src/corelib/xml/qxmlstream_p.h
index ab0bbba413..c68d6f0f53 100644
--- a/src/corelib/xml/qxmlstream_p.h
+++ b/src/corelib/xml/qxmlstream_p.h
@@ -48,6 +48,8 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
+
// This file was generated by qlalr - DO NOT EDIT!
#ifndef QXMLSTREAM_P_H
#define QXMLSTREAM_P_H
diff --git a/src/corelib/xml/qxmlutils_p.h b/src/corelib/xml/qxmlutils_p.h
index d45ecb50b3..d8d25e0efe 100644
--- a/src/corelib/xml/qxmlutils_p.h
+++ b/src/corelib/xml/qxmlutils_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtCore/private/qglobal_p.h>
#include <QtCore/qstring.h>
QT_BEGIN_NAMESPACE
diff --git a/src/dbus/dbus.pro b/src/dbus/dbus.pro
index fa67fc17ef..96a798ed66 100644
--- a/src/dbus/dbus.pro
+++ b/src/dbus/dbus.pro
@@ -3,15 +3,15 @@ QT = core-private
CONFIG += link_pkgconfig
MODULE_CONFIG = dbusadaptors dbusinterfaces
-!contains(QT_LIBS_DBUS, .*dbus-1.*) {
- win32:CONFIG(debug, debug|release):QT_LIBS_DBUS += -ldbus-1d
- else:QT_LIBS_DBUS += -ldbus-1
+!contains(QMAKE_LIBS_DBUS, .*dbus-1.*) {
+ win32:CONFIG(debug, debug|release):QMAKE_LIBS_DBUS += -ldbus-1d
+ else:QMAKE_LIBS_DBUS += -ldbus-1
}
DEFINES += DBUS_API_SUBJECT_TO_CHANGE
-QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS
+QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_DBUS
contains(QT_CONFIG, dbus-linked) {
- LIBS_PRIVATE += $$QT_LIBS_DBUS
+ LIBS_PRIVATE += $$QMAKE_LIBS_DBUS
DEFINES += QT_LINKED_LIBDBUS
}
@@ -27,9 +27,9 @@ DEFINES += QT_NO_FOREACH
QMAKE_DOCS = $$PWD/doc/qtdbus.qdocconf
-PUB_HEADERS = qdbusargument.h \
+PUB_HEADERS = qtdbusglobal.h \
+ qdbusargument.h \
qdbusconnectioninterface.h \
- qdbusmacros.h \
qdbuserror.h \
qdbusextratypes.h \
qdbusmessage.h \
@@ -47,6 +47,7 @@ PUB_HEADERS = qdbusargument.h \
qdbusservicewatcher.h \
qdbusunixfiledescriptor.h
HEADERS += $$PUB_HEADERS \
+ qtdbusglobal_p.h \
qdbusconnection_p.h \
qdbusconnectionmanager_p.h \
qdbusmessage_p.h \
diff --git a/src/dbus/qdbus_symbols_p.h b/src/dbus/qdbus_symbols_p.h
index fbeea61c95..cfc0e12046 100644
--- a/src/dbus/qdbus_symbols_p.h
+++ b/src/dbus/qdbus_symbols_p.h
@@ -53,7 +53,7 @@
#ifndef QDBUS_SYMBOLS_P_H
#define QDBUS_SYMBOLS_P_H
-#include <QtCore/qglobal.h>
+#include <QtDBus/private/qtdbusglobal_p.h>
#ifndef QT_NO_DBUS
diff --git a/src/dbus/qdbusabstractadaptor.h b/src/dbus/qdbusabstractadaptor.h
index e506458d33..f86d939fae 100644
--- a/src/dbus/qdbusabstractadaptor.h
+++ b/src/dbus/qdbusabstractadaptor.h
@@ -40,8 +40,8 @@
#ifndef QDBUSABSTRACTADAPTOR_H
#define QDBUSABSTRACTADAPTOR_H
+#include <QtDBus/qtdbusglobal.h>
#include <QtCore/qobject.h>
-#include <QtDBus/qdbusmacros.h>
#ifndef QT_NO_DBUS
diff --git a/src/dbus/qdbusabstractadaptor_p.h b/src/dbus/qdbusabstractadaptor_p.h
index e99e35766d..ed28777734 100644
--- a/src/dbus/qdbusabstractadaptor_p.h
+++ b/src/dbus/qdbusabstractadaptor_p.h
@@ -52,6 +52,7 @@
#ifndef QDBUSABSTRACTADAPTOR_P_H
#define QDBUSABSTRACTADAPTOR_P_H
+#include <QtDBus/private/qtdbusglobal_p.h>
#include <qdbusabstractadaptor.h>
#include <QtCore/qobject.h>
diff --git a/src/dbus/qdbusabstractinterface.h b/src/dbus/qdbusabstractinterface.h
index 32c33f19f2..f859c5ee7d 100644
--- a/src/dbus/qdbusabstractinterface.h
+++ b/src/dbus/qdbusabstractinterface.h
@@ -40,6 +40,7 @@
#ifndef QDBUSABSTRACTINTERFACE_H
#define QDBUSABSTRACTINTERFACE_H
+#include <QtDBus/qtdbusglobal.h>
#include <QtCore/qstring.h>
#include <QtCore/qvariant.h>
#include <QtCore/qlist.h>
diff --git a/src/dbus/qdbusabstractinterface_p.h b/src/dbus/qdbusabstractinterface_p.h
index ba555d5862..8e45bae88b 100644
--- a/src/dbus/qdbusabstractinterface_p.h
+++ b/src/dbus/qdbusabstractinterface_p.h
@@ -53,6 +53,7 @@
#ifndef QDBUSABSTRACTINTERFACE_P_H
#define QDBUSABSTRACTINTERFACE_P_H
+#include <QtDBus/private/qtdbusglobal_p.h>
#include <qdbusabstractinterface.h>
#include <qdbusconnection.h>
#include <qdbuserror.h>
diff --git a/src/dbus/qdbusargument.h b/src/dbus/qdbusargument.h
index 85469fbc3d..5342a79227 100644
--- a/src/dbus/qdbusargument.h
+++ b/src/dbus/qdbusargument.h
@@ -40,6 +40,7 @@
#ifndef QDBUSARGUMENT_H
#define QDBUSARGUMENT_H
+#include <QtDBus/qtdbusglobal.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qhash.h>
#include <QtCore/qglobal.h>
@@ -49,7 +50,6 @@
#include <QtCore/qstringlist.h>
#include <QtCore/qvariant.h>
#include <QtDBus/qdbusextratypes.h>
-#include <QtDBus/qdbusmacros.h>
#ifndef QT_NO_DBUS
diff --git a/src/dbus/qdbusargument_p.h b/src/dbus/qdbusargument_p.h
index ca0a2cde13..559f8b1186 100644
--- a/src/dbus/qdbusargument_p.h
+++ b/src/dbus/qdbusargument_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtDBus/private/qtdbusglobal_p.h>
#include <qdbusargument.h>
#include "qdbusunixfiledescriptor.h"
#include "qdbus_symbols_p.h"
diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp
index bd25d8a6bf..cddb7dfb95 100644
--- a/src/dbus/qdbusconnection.cpp
+++ b/src/dbus/qdbusconnection.cpp
@@ -69,10 +69,6 @@
QT_BEGIN_NAMESPACE
-#ifdef Q_OS_WIN
-static void preventDllUnload();
-#endif
-
Q_GLOBAL_STATIC(QDBusConnectionManager, _q_manager)
// can be replaced with a lambda in Qt 5.7
@@ -161,10 +157,6 @@ QDBusConnectionManager::QDBusConnectionManager()
this, &QDBusConnectionManager::createServer, Qt::BlockingQueuedConnection);
moveToThread(this); // ugly, don't do this in other projects
-#ifdef Q_OS_WIN
- // prevent the library from being unloaded on Windows. See comments in the function.
- preventDllUnload();
-#endif
defaultBuses[0] = defaultBuses[1] = Q_NULLPTR;
start();
}
@@ -1290,31 +1282,4 @@ QT_END_NAMESPACE
#include "qdbusconnection.moc"
-#ifdef Q_OS_WIN
-# include <qt_windows.h>
-
-QT_BEGIN_NAMESPACE
-static void preventDllUnload()
-{
- // Thread termination is really wacky on Windows. For some reason we don't
- // understand, exiting from the thread may try to unload the DLL. Since the
- // QDBusConnectionManager thread runs until the DLL is unloaded, we've got
- // a deadlock: the main thread is waiting for the manager thread to exit,
- // but the manager thread is attempting to acquire a lock to unload the DLL.
- //
- // We work around the issue by preventing the unload from happening in the
- // first place.
- //
- // For this trick, see
- // https://blogs.msdn.microsoft.com/oldnewthing/20131105-00/?p=2733
-
- static HMODULE self;
- GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
- GET_MODULE_HANDLE_EX_FLAG_PIN,
- reinterpret_cast<const wchar_t *>(&self), // any address in this DLL
- &self);
-}
-QT_END_NAMESPACE
-#endif
-
#endif // QT_NO_DBUS
diff --git a/src/dbus/qdbusconnection.h b/src/dbus/qdbusconnection.h
index d7ba55b3eb..d9a894b637 100644
--- a/src/dbus/qdbusconnection.h
+++ b/src/dbus/qdbusconnection.h
@@ -41,7 +41,7 @@
#ifndef QDBUSCONNECTION_H
#define QDBUSCONNECTION_H
-#include <QtDBus/qdbusmacros.h>
+#include <QtDBus/qtdbusglobal.h>
#include <QtCore/qobjectdefs.h>
#include <QtCore/qstring.h>
diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h
index b710bfd2aa..0b7c731810 100644
--- a/src/dbus/qdbusconnection_p.h
+++ b/src/dbus/qdbusconnection_p.h
@@ -53,6 +53,7 @@
#ifndef QDBUSCONNECTION_P_H
#define QDBUSCONNECTION_P_H
+#include <QtDBus/private/qtdbusglobal_p.h>
#include <qdbuserror.h>
#include <qdbusconnection.h>
@@ -279,7 +280,7 @@ public slots:
void socketWrite(int);
void objectDestroyed(QObject *o);
void relaySignal(QObject *obj, const QMetaObject *, int signalId, const QVariantList &args);
- void addSignalHook(const QString &key, const SignalHook &hook);
+ bool addSignalHook(const QString &key, const SignalHook &hook);
bool removeSignalHook(const QString &key, const SignalHook &hook);
private slots:
@@ -292,7 +293,7 @@ signals:
void dispatchStatusChanged();
void spyHooksFinished(const QDBusMessage &msg);
void messageNeedsSending(QDBusPendingCallPrivate *pcall, void *msg, int timeout = -1);
- void signalNeedsConnecting(const QString &key, const QDBusConnectionPrivate::SignalHook &hook);
+ bool signalNeedsConnecting(const QString &key, const QDBusConnectionPrivate::SignalHook &hook);
bool signalNeedsDisconnecting(const QString &key, const QDBusConnectionPrivate::SignalHook &hook);
void serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner);
void callWithCallbackFailed(const QDBusError &error, const QDBusMessage &message);
diff --git a/src/dbus/qdbusconnectioninterface.h b/src/dbus/qdbusconnectioninterface.h
index 862bbbc0cd..7b694a1f96 100644
--- a/src/dbus/qdbusconnectioninterface.h
+++ b/src/dbus/qdbusconnectioninterface.h
@@ -40,6 +40,7 @@
#ifndef QDBUSCONNECTIONINTERFACE_H
#define QDBUSCONNECTIONINTERFACE_H
+#include <QtDBus/qtdbusglobal.h>
#include <QtCore/qstringlist.h>
#include <QtDBus/qdbusabstractinterface.h>
diff --git a/src/dbus/qdbusconnectionmanager_p.h b/src/dbus/qdbusconnectionmanager_p.h
index 5e85f86f9f..1c7dea811d 100644
--- a/src/dbus/qdbusconnectionmanager_p.h
+++ b/src/dbus/qdbusconnectionmanager_p.h
@@ -53,6 +53,7 @@
#ifndef QDBUSCONNECTIONMANAGER_P_H
#define QDBUSCONNECTIONMANAGER_P_H
+#include <QtDBus/private/qtdbusglobal_p.h>
#include "qdbusconnection_p.h"
#include "private/qthread_p.h"
diff --git a/src/dbus/qdbuscontext.h b/src/dbus/qdbuscontext.h
index 9af6ff52ed..fedfcbd98e 100644
--- a/src/dbus/qdbuscontext.h
+++ b/src/dbus/qdbuscontext.h
@@ -40,6 +40,7 @@
#ifndef QDBUSCONTEXT_H
#define QDBUSCONTEXT_H
+#include <QtDBus/qtdbusglobal.h>
#include <QtCore/qstring.h>
#include <QtDBus/qdbuserror.h>
diff --git a/src/dbus/qdbuscontext_p.h b/src/dbus/qdbuscontext_p.h
index 00c749fbc8..087ded8b4f 100644
--- a/src/dbus/qdbuscontext_p.h
+++ b/src/dbus/qdbuscontext_p.h
@@ -52,7 +52,7 @@
#ifndef QDBUSCONTEXT_P_H
#define QDBUSCONTEXT_P_H
-#include <QtCore/qglobal.h>
+#include <QtDBus/private/qtdbusglobal_p.h>
#ifndef QT_NO_DBUS
diff --git a/src/dbus/qdbuserror.h b/src/dbus/qdbuserror.h
index bd7014bdf9..7c3abc9cc7 100644
--- a/src/dbus/qdbuserror.h
+++ b/src/dbus/qdbuserror.h
@@ -40,7 +40,7 @@
#ifndef QDBUSERROR_H
#define QDBUSERROR_H
-#include <QtDBus/qdbusmacros.h>
+#include <QtDBus/qtdbusglobal.h>
#include <QtCore/qstring.h>
#ifndef QT_NO_DBUS
diff --git a/src/dbus/qdbusextratypes.h b/src/dbus/qdbusextratypes.h
index b65bfc1e9b..12961e2702 100644
--- a/src/dbus/qdbusextratypes.h
+++ b/src/dbus/qdbusextratypes.h
@@ -42,9 +42,9 @@
// define some useful types for D-BUS
+#include <QtDBus/qtdbusglobal.h>
#include <QtCore/qvariant.h>
#include <QtCore/qstring.h>
-#include <QtDBus/qdbusmacros.h>
#if QT_DEPRECATED_SINCE(5, 6)
#include <QtCore/qhash.h>
#endif
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index 54418c213a..21bc3c8ac2 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -2187,20 +2187,16 @@ bool QDBusConnectionPrivate::connectSignal(const QString &service,
// check the slot
QDBusConnectionPrivate::SignalHook hook;
QString key;
- QString name2 = name;
- if (name2.isNull())
- name2.detach();
hook.signature = signature;
if (!prepareHook(hook, key, service, path, interface, name, argumentMatch, receiver, slot, 0, false))
return false; // don't connect
Q_ASSERT(thread() != QThread::currentThread());
- emit signalNeedsConnecting(key, hook);
- return true;
+ return emit signalNeedsConnecting(key, hook);
}
-void QDBusConnectionPrivate::addSignalHook(const QString &key, const SignalHook &hook)
+bool QDBusConnectionPrivate::addSignalHook(const QString &key, const SignalHook &hook)
{
QDBusWriteLocker locker(ConnectAction, this);
@@ -2216,7 +2212,7 @@ void QDBusConnectionPrivate::addSignalHook(const QString &key, const SignalHook
entry.midx == hook.midx &&
entry.argumentMatch == hook.argumentMatch) {
// no need to compare the parameters if it's the same slot
- return; // already there
+ return false; // already there
}
}
@@ -2228,7 +2224,7 @@ void QDBusConnectionPrivate::addSignalHook(const QString &key, const SignalHook
if (mit != matchRefCounts.end()) { // Match already present
mit.value() = mit.value() + 1;
- return;
+ return true;
}
matchRefCounts.insert(hook.matchRule, 1);
@@ -2255,6 +2251,7 @@ void QDBusConnectionPrivate::addSignalHook(const QString &key, const SignalHook
}
}
}
+ return true;
}
bool QDBusConnectionPrivate::disconnectSignal(const QString &service,
diff --git a/src/dbus/qdbusintegrator_p.h b/src/dbus/qdbusintegrator_p.h
index 470baeb692..85a067da1e 100644
--- a/src/dbus/qdbusintegrator_p.h
+++ b/src/dbus/qdbusintegrator_p.h
@@ -53,6 +53,7 @@
#ifndef QDBUSINTEGRATOR_P_H
#define QDBUSINTEGRATOR_P_H
+#include <QtDBus/private/qtdbusglobal_p.h>
#include "qdbus_symbols_p.h"
#include "qcoreevent.h"
diff --git a/src/dbus/qdbusinterface.h b/src/dbus/qdbusinterface.h
index 9db2cb9ce8..b6c2693400 100644
--- a/src/dbus/qdbusinterface.h
+++ b/src/dbus/qdbusinterface.h
@@ -40,6 +40,7 @@
#ifndef QDBUSINTERFACE_H
#define QDBUSINTERFACE_H
+#include <QtDBus/qtdbusglobal.h>
#include <QtDBus/qdbusabstractinterface.h>
#include <QtDBus/qdbusconnection.h>
diff --git a/src/dbus/qdbusinterface_p.h b/src/dbus/qdbusinterface_p.h
index f35916502b..b726925306 100644
--- a/src/dbus/qdbusinterface_p.h
+++ b/src/dbus/qdbusinterface_p.h
@@ -52,6 +52,7 @@
#ifndef QDBUSINTERFACE_P_H
#define QDBUSINTERFACE_P_H
+#include <QtDBus/private/qtdbusglobal_p.h>
#include "qdbusabstractinterface_p.h"
#include "qdbusmetaobject_p.h"
#include <qdbusinterface.h>
diff --git a/src/dbus/qdbusintrospection_p.h b/src/dbus/qdbusintrospection_p.h
index 2b02a71156..e60900b162 100644
--- a/src/dbus/qdbusintrospection_p.h
+++ b/src/dbus/qdbusintrospection_p.h
@@ -51,13 +51,13 @@
// We mean it.
//
+#include <QtDBus/private/qtdbusglobal_p.h>
#include <QtCore/qstring.h>
#include <QtCore/qvector.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qmap.h>
#include <QtCore/qpair.h>
#include <QtCore/qshareddata.h>
-#include "qdbusmacros.h"
#ifndef QT_NO_DBUS
diff --git a/src/dbus/qdbusmessage.h b/src/dbus/qdbusmessage.h
index 570dd0b736..9f4a98b855 100644
--- a/src/dbus/qdbusmessage.h
+++ b/src/dbus/qdbusmessage.h
@@ -40,7 +40,7 @@
#ifndef QDBUSMESSAGE_H
#define QDBUSMESSAGE_H
-#include <QtDBus/qdbusmacros.h>
+#include <QtDBus/qtdbusglobal.h>
#include <QtDBus/qdbuserror.h>
#include <QtCore/qlist.h>
#include <QtCore/qvariant.h>
diff --git a/src/dbus/qdbusmessage_p.h b/src/dbus/qdbusmessage_p.h
index 31a333f9fb..4b84b3f0cc 100644
--- a/src/dbus/qdbusmessage_p.h
+++ b/src/dbus/qdbusmessage_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtDBus/private/qtdbusglobal_p.h>
#include <qatomic.h>
#include <qstring.h>
#include <qdbusmessage.h>
diff --git a/src/dbus/qdbusmetaobject_p.h b/src/dbus/qdbusmetaobject_p.h
index c785849826..599358634b 100644
--- a/src/dbus/qdbusmetaobject_p.h
+++ b/src/dbus/qdbusmetaobject_p.h
@@ -37,6 +37,9 @@
**
****************************************************************************/
+#ifndef QDBUSMETAOBJECT_P_H
+#define QDBUSMETAOBJECT_P_H
+
//
// W A R N I N G
// -------------
@@ -49,11 +52,8 @@
//
//
-#ifndef QDBUSMETAOBJECT_P_H
-#define QDBUSMETAOBJECT_P_H
-
+#include <QtDBus/private/qtdbusglobal_p.h>
#include <QtCore/qmetaobject.h>
-#include <qdbusmacros.h>
#ifndef QT_NO_DBUS
diff --git a/src/dbus/qdbusmetatype.h b/src/dbus/qdbusmetatype.h
index 8b314da78c..9f3d9019d7 100644
--- a/src/dbus/qdbusmetatype.h
+++ b/src/dbus/qdbusmetatype.h
@@ -40,6 +40,7 @@
#ifndef QDBUSMETATYPE_H
#define QDBUSMETATYPE_H
+#include <QtDBus/qtdbusglobal.h>
#include "QtCore/qmetatype.h"
#include <QtDBus/qdbusargument.h>
diff --git a/src/dbus/qdbusmetatype_p.h b/src/dbus/qdbusmetatype_p.h
index 3bfe18729e..1aa11552df 100644
--- a/src/dbus/qdbusmetatype_p.h
+++ b/src/dbus/qdbusmetatype_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtDBus/private/qtdbusglobal_p.h>
#include <qdbusmetatype.h>
#include <qdbusmessage.h>
diff --git a/src/dbus/qdbuspendingcall.h b/src/dbus/qdbuspendingcall.h
index a89103f242..1e4c6ebfd2 100644
--- a/src/dbus/qdbuspendingcall.h
+++ b/src/dbus/qdbuspendingcall.h
@@ -40,13 +40,11 @@
#ifndef QDBUSPENDINGCALL_H
#define QDBUSPENDINGCALL_H
-#include <QtCore/qglobal.h>
+#include <QtDBus/qtdbusglobal.h>
+#include <QtDBus/qdbusmessage.h>
#include <QtCore/qobject.h>
#include <QtCore/qshareddata.h>
-#include <QtDBus/qdbusmacros.h>
-#include <QtDBus/qdbusmessage.h>
-
#ifndef QT_NO_DBUS
QT_BEGIN_NAMESPACE
diff --git a/src/dbus/qdbuspendingcall_p.h b/src/dbus/qdbuspendingcall_p.h
index d6c2ef2114..10f189ae43 100644
--- a/src/dbus/qdbuspendingcall_p.h
+++ b/src/dbus/qdbuspendingcall_p.h
@@ -53,6 +53,7 @@
#ifndef QDBUSPENDINGCALL_P_H
#define QDBUSPENDINGCALL_P_H
+#include <QtDBus/private/qtdbusglobal_p.h>
#include <qshareddata.h>
#include <qpointer.h>
#include <qvector.h>
diff --git a/src/dbus/qdbuspendingreply.h b/src/dbus/qdbuspendingreply.h
index 1ee658c0c8..786eab2120 100644
--- a/src/dbus/qdbuspendingreply.h
+++ b/src/dbus/qdbuspendingreply.h
@@ -40,8 +40,7 @@
#ifndef QDBUSPENDINGREPLY_H
#define QDBUSPENDINGREPLY_H
-#include <QtCore/qglobal.h>
-#include <QtDBus/qdbusmacros.h>
+#include <QtDBus/qtdbusglobal.h>
#include <QtDBus/qdbusargument.h>
#include <QtDBus/qdbuspendingcall.h>
diff --git a/src/dbus/qdbusreply.h b/src/dbus/qdbusreply.h
index 897e9452eb..b6a454d240 100644
--- a/src/dbus/qdbusreply.h
+++ b/src/dbus/qdbusreply.h
@@ -40,10 +40,9 @@
#ifndef QDBUSREPLY_H
#define QDBUSREPLY_H
-#include <QtCore/qglobal.h>
+#include <QtDBus/qtdbusglobal.h>
#include <QtCore/qvariant.h>
-#include <QtDBus/qdbusmacros.h>
#include <QtDBus/qdbusmessage.h>
#include <QtDBus/qdbuserror.h>
#include <QtDBus/qdbusextratypes.h>
diff --git a/src/dbus/qdbusserver.h b/src/dbus/qdbusserver.h
index 0844229256..ac4dfcb67f 100644
--- a/src/dbus/qdbusserver.h
+++ b/src/dbus/qdbusserver.h
@@ -40,9 +40,9 @@
#ifndef QDBUSSERVER_H
#define QDBUSSERVER_H
+#include <QtDBus/qtdbusglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qstring.h>
-#include <QtDBus/qdbusmacros.h>
#ifndef QT_NO_DBUS
diff --git a/src/dbus/qdbusservicewatcher.h b/src/dbus/qdbusservicewatcher.h
index a785c89761..77573beb5d 100644
--- a/src/dbus/qdbusservicewatcher.h
+++ b/src/dbus/qdbusservicewatcher.h
@@ -40,8 +40,7 @@
#ifndef QDBUSSERVICEWATCHER_H
#define QDBUSSERVICEWATCHER_H
-#include <QtCore/qobject.h>
-#include <QtDBus/qdbusmacros.h>
+#include <QtDBus/qtdbusglobal.h>
#if !defined(QT_NO_DBUS) && !defined(QT_NO_QOBJECT)
@@ -63,6 +62,7 @@ public:
WatchForOwnerChange = 0x03
};
Q_DECLARE_FLAGS(WatchMode, WatchModeFlag)
+ Q_FLAG(WatchMode)
explicit QDBusServiceWatcher(QObject *parent = Q_NULLPTR);
QDBusServiceWatcher(const QString &service, const QDBusConnection &connection,
diff --git a/src/dbus/qdbusthreaddebug_p.h b/src/dbus/qdbusthreaddebug_p.h
index a94621b8d6..866e777be6 100644
--- a/src/dbus/qdbusthreaddebug_p.h
+++ b/src/dbus/qdbusthreaddebug_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtDBus/private/qtdbusglobal_p.h>
#ifndef QT_NO_DBUS
diff --git a/src/dbus/qdbusunixfiledescriptor.h b/src/dbus/qdbusunixfiledescriptor.h
index 05a5617ddc..ed3209ceda 100644
--- a/src/dbus/qdbusunixfiledescriptor.h
+++ b/src/dbus/qdbusunixfiledescriptor.h
@@ -41,8 +41,8 @@
#ifndef QDBUSUNIXFILEDESCRIPTOR_H
#define QDBUSUNIXFILEDESCRIPTOR_H
+#include <QtDBus/qtdbusglobal.h>
#include <QtCore/qshareddata.h>
-#include <QtDBus/qdbusmacros.h>
#ifndef QT_NO_DBUS
diff --git a/src/dbus/qdbusutil_p.h b/src/dbus/qdbusutil_p.h
index e11fe573b5..9a95ab7ba3 100644
--- a/src/dbus/qdbusutil_p.h
+++ b/src/dbus/qdbusutil_p.h
@@ -52,12 +52,11 @@
#ifndef QDBUSUTIL_P_H
#define QDBUSUTIL_P_H
+#include <QtDBus/private/qtdbusglobal_p.h>
+#include <QtDBus/qdbuserror.h>
#include <QtCore/qstring.h>
#include <QtCore/qvariant.h>
-#include <QtDBus/qdbusmacros.h>
-#include <QtDBus/qdbuserror.h>
-
#include "qdbus_symbols_p.h"
#ifndef QT_NO_DBUS
diff --git a/src/dbus/qdbusvirtualobject.h b/src/dbus/qdbusvirtualobject.h
index 8eb4c73f57..1a96d900b4 100644
--- a/src/dbus/qdbusvirtualobject.h
+++ b/src/dbus/qdbusvirtualobject.h
@@ -40,7 +40,7 @@
#ifndef QDBUSVIRTUALOBJECT_H
#define QDBUSVIRTUALOBJECT_H
-#include <QtDBus/qdbusmacros.h>
+#include <QtDBus/qtdbusglobal.h>
#include <QtCore/qstring.h>
#include <QtCore/qobject.h>
@@ -52,7 +52,6 @@ QT_BEGIN_NAMESPACE
class QDBusMessage;
class QDBusConnection;
-class QDBusVirtualObjectPrivate;
class Q_DBUS_EXPORT QDBusVirtualObject : public QObject
{
Q_OBJECT
@@ -64,7 +63,6 @@ public:
virtual bool handleMessage(const QDBusMessage &message, const QDBusConnection &connection) = 0;
private:
- Q_DECLARE_PRIVATE(QDBusVirtualObject)
Q_DISABLE_COPY(QDBusVirtualObject)
};
diff --git a/src/dbus/qdbusxmlparser_p.h b/src/dbus/qdbusxmlparser_p.h
index 0ba04440c4..7db2d12df4 100644
--- a/src/dbus/qdbusxmlparser_p.h
+++ b/src/dbus/qdbusxmlparser_p.h
@@ -51,8 +51,8 @@
// We mean it.
//
+#include <QtDBus/private/qtdbusglobal_p.h>
#include <QtCore/qmap.h>
-#include <qdbusmacros.h>
#include "qdbusintrospection_p.h"
#ifndef QT_NO_DBUS
diff --git a/src/dbus/qdbusmacros.h b/src/dbus/qtdbusglobal.h
index 0b4fdb2cf0..633cc352bb 100644
--- a/src/dbus/qdbusmacros.h
+++ b/src/dbus/qtdbusglobal.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QDBUSMACROS_H
-#define QDBUSMACROS_H
+#ifndef QTDBUSGLOBAL_H
+#define QTDBUSGLOBAL_H
#include <QtCore/qglobal.h>
#include <QtCore/qmetatype.h>
diff --git a/src/dbus/qtdbusglobal_p.h b/src/dbus/qtdbusglobal_p.h
new file mode 100644
index 0000000000..c2788f5c23
--- /dev/null
+++ b/src/dbus/qtdbusglobal_p.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtDBus module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTDBUSGLOBAL_P_H
+#define QTDBUSGLOBAL_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtDBus/qtdbusglobal.h>
+#include <QtCore/private/qglobal_p.h>
+
+#endif // QTDBUSGLOBAL_P_H
diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h
index 7bc124f7d9..27756d764d 100644
--- a/src/gui/accessible/qaccessible.h
+++ b/src/gui/accessible/qaccessible.h
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#ifndef QT_NO_ACCESSIBILITY
#ifndef QACCESSIBLE_H
diff --git a/src/gui/accessible/qaccessiblebridge.h b/src/gui/accessible/qaccessiblebridge.h
index c161e01b0f..7429716e65 100644
--- a/src/gui/accessible/qaccessiblebridge.h
+++ b/src/gui/accessible/qaccessiblebridge.h
@@ -40,6 +40,7 @@
#ifndef QACCESSIBLEBRIDGE_H
#define QACCESSIBLEBRIDGE_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
diff --git a/src/gui/accessible/qaccessiblecache_p.h b/src/gui/accessible/qaccessiblecache_p.h
index a9208702e4..f054ee9678 100644
--- a/src/gui/accessible/qaccessiblecache_p.h
+++ b/src/gui/accessible/qaccessiblecache_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtCore/qobject.h>
#include <QtCore/qhash.h>
diff --git a/src/gui/accessible/qaccessibleobject.h b/src/gui/accessible/qaccessibleobject.h
index 5918e942bd..dd69dcb081 100644
--- a/src/gui/accessible/qaccessibleobject.h
+++ b/src/gui/accessible/qaccessibleobject.h
@@ -40,6 +40,7 @@
#ifndef QACCESSIBLEOBJECT_H
#define QACCESSIBLEOBJECT_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qaccessible.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/accessible/qaccessibleplugin.h b/src/gui/accessible/qaccessibleplugin.h
index b0c28e5bf8..09d4c542d3 100644
--- a/src/gui/accessible/qaccessibleplugin.h
+++ b/src/gui/accessible/qaccessibleplugin.h
@@ -40,6 +40,7 @@
#ifndef QACCESSIBLEPLUGIN_H
#define QACCESSIBLEPLUGIN_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qaccessible.h>
#include <QtCore/qfactoryinterface.h>
diff --git a/src/gui/accessible/qplatformaccessibility.h b/src/gui/accessible/qplatformaccessibility.h
index 5dc4781bb2..5d668c2bd6 100644
--- a/src/gui/accessible/qplatformaccessibility.h
+++ b/src/gui/accessible/qplatformaccessibility.h
@@ -48,9 +48,11 @@
// source and binary incompatible with future versions of Qt.
//
-#include <QtCore/qobject.h>
+#include <QtGui/qtguiglobal.h>
+
#ifndef QT_NO_ACCESSIBILITY
+#include <QtCore/qobject.h>
#include <QtGui/qaccessible.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/animation/qguivariantanimation.cpp b/src/gui/animation/qguivariantanimation.cpp
index e18340d302..b72764e048 100644
--- a/src/gui/animation/qguivariantanimation.cpp
+++ b/src/gui/animation/qguivariantanimation.cpp
@@ -36,11 +36,12 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include <QtCore/qvariantanimation.h>
-#include <private/qvariantanimation_p.h>
+#include <QtGui/qtguiglobal.h>
#ifndef QT_NO_ANIMATION
+#include <QtCore/qvariantanimation.h>
+#include <private/qvariantanimation_p.h>
#include <QtGui/qcolor.h>
#include <QtGui/qvector2d.h>
#include <QtGui/qvector3d.h>
diff --git a/src/gui/doc/src/qtgui.qdoc b/src/gui/doc/src/qtgui.qdoc
index 9781135960..a9fe520d5e 100644
--- a/src/gui/doc/src/qtgui.qdoc
+++ b/src/gui/doc/src/qtgui.qdoc
@@ -187,6 +187,19 @@
More info in \l{Drag and Drop}
+ \section1 Licenses and Attributions
+
+ Qt GUI is available under commercial licenses from \l{The Qt Company}.
+ In addition, it is available under the
+ \l{GNU Lesser General Public License, version 3}, or
+ the \l{GNU General Public License, version 2}.
+ See \l{Qt Licensing} for further details.
+
+ Furthermore Qt GUI potentially contains third party
+ modules under following permissive licenses:
+
+ \generatelist{groupsbymodule attributions-qtgui}
+
\section1 Reference
\list
\li \l{Qt GUI C++ Classes}
diff --git a/src/gui/gui.pro b/src/gui/gui.pro
index 462f133ff8..d1d0041616 100644
--- a/src/gui/gui.pro
+++ b/src/gui/gui.pro
@@ -18,7 +18,7 @@ MODULE_PLUGIN_TYPES = \
egldeviceintegrations
# This is here only because the platform plugin is no module, obviously.
-win32:contains(QT_CONFIG, angle)|contains(QT_CONFIG, dynamicgl) {
+contains(QT_CONFIG, angle) {
MODULE_AUX_INCLUDES = \
\$\$QT_MODULE_INCLUDE_BASE/QtANGLE
}
diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri
index 8db944e5e3..fe21ff4cc0 100644
--- a/src/gui/image/image.pri
+++ b/src/gui/image/image.pri
@@ -11,7 +11,6 @@ HEADERS += \
image/qimagereader.h \
image/qimagewriter.h \
image/qmovie.h \
- image/qnativeimage_p.h \
image/qpaintengine_pic_p.h \
image/qpicture.h \
image/qpicture_p.h \
@@ -45,7 +44,6 @@ SOURCES += \
image/qmovie.cpp \
image/qpixmap_raster.cpp \
image/qpixmap_blitter.cpp \
- image/qnativeimage.cpp \
image/qimagepixmapcleanuphooks.cpp \
image/qicon.cpp \
image/qiconloader.cpp \
@@ -55,6 +53,8 @@ SOURCES += \
win32:!winrt: SOURCES += image/qpixmap_win.cpp
+darwin: OBJECTIVE_SOURCES += image/qimage_darwin.mm
+
NO_PCH_SOURCES += image/qimage_compat.cpp
false: SOURCES += $$NO_PCH_SOURCES # Hack for QtCreator
@@ -71,11 +71,11 @@ SOURCES += \
image/qxbmhandler.cpp \
image/qxpmhandler.cpp
-!contains(QT_CONFIG, no-png):include($$PWD/qpnghandler.pri)
-else:DEFINES *= QT_NO_IMAGEFORMAT_PNG
-
-contains(QT_CONFIG, jpeg):include($$PWD/qjpeghandler.pri)
-contains(QT_CONFIG, gif):include($$PWD/qgifhandler.pri)
+contains(QT_CONFIG, png) {
+ HEADERS += image/qpnghandler_p.h
+ SOURCES += image/qpnghandler.cpp
+ include($$PWD/../../3rdparty/png_dependency.pri)
+}
# SIMD
SSE2_SOURCES += image/qimage_sse2.cpp
diff --git a/src/gui/image/qbitmap.h b/src/gui/image/qbitmap.h
index 68727e74b5..def59b3f89 100644
--- a/src/gui/image/qbitmap.h
+++ b/src/gui/image/qbitmap.h
@@ -40,6 +40,7 @@
#ifndef QBITMAP_H
#define QBITMAP_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qpixmap.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/image/qbmphandler_p.h b/src/gui/image/qbmphandler_p.h
index c4800e3f97..258ce0fce6 100644
--- a/src/gui/image/qbmphandler_p.h
+++ b/src/gui/image/qbmphandler_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtGui/qimageiohandler.h"
#ifndef QT_NO_IMAGEFORMAT_BMP
diff --git a/src/gui/image/qgifhandler.pri b/src/gui/image/qgifhandler.pri
deleted file mode 100644
index ec33101451..0000000000
--- a/src/gui/image/qgifhandler.pri
+++ /dev/null
@@ -1,3 +0,0 @@
-# common to plugin and built-in forms
-HEADERS += $$PWD/qgifhandler_p.h
-SOURCES += $$PWD/qgifhandler.cpp
diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h
index 1b0e73c21b..40d3e92af9 100644
--- a/src/gui/image/qicon.h
+++ b/src/gui/image/qicon.h
@@ -40,7 +40,7 @@
#ifndef QICON_H
#define QICON_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qsize.h>
#include <QtCore/qlist.h>
#include <QtGui/qpixmap.h>
diff --git a/src/gui/image/qicon_p.h b/src/gui/image/qicon_p.h
index cfae9b3e52..a978a72192 100644
--- a/src/gui/image/qicon_p.h
+++ b/src/gui/image/qicon_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtCore/qsize.h>
#include <QtCore/qlist.h>
#include <QtGui/qpixmap.h>
diff --git a/src/gui/image/qiconengine.h b/src/gui/image/qiconengine.h
index c702a1e8bb..b0c92ced73 100644
--- a/src/gui/image/qiconengine.h
+++ b/src/gui/image/qiconengine.h
@@ -40,7 +40,7 @@
#ifndef QICONENGINE_H
#define QICONENGINE_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qlist.h>
#include <QtGui/qicon.h>
diff --git a/src/gui/image/qiconengineplugin.h b/src/gui/image/qiconengineplugin.h
index aacb3a9ebb..7a01d3731c 100644
--- a/src/gui/image/qiconengineplugin.h
+++ b/src/gui/image/qiconengineplugin.h
@@ -40,6 +40,7 @@
#ifndef QICONENGINEPLUGIN_H
#define QICONENGINEPLUGIN_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp
index 0233ccbf87..0faf8820dd 100644
--- a/src/gui/image/qiconloader.cpp
+++ b/src/gui/image/qiconloader.cpp
@@ -316,10 +316,8 @@ QIconTheme::QIconTheme(const QString &themeName)
#ifndef QT_NO_SETTINGS
if (themeIndex.exists()) {
const QSettings indexReader(themeIndex.fileName(), QSettings::IniFormat);
- QStringListIterator keyIterator(indexReader.allKeys());
- while (keyIterator.hasNext()) {
-
- const QString key = keyIterator.next();
+ const QStringList keys = indexReader.allKeys();
+ for (const QString &key : keys) {
if (key.endsWith(QLatin1String("/Size"))) {
// Note the QSettings ini-format does not accept
// slashes in key names, hence we have to cheat
@@ -431,21 +429,23 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
QString contentDir = contentDirs.at(i) + QLatin1Char('/');
for (int j = 0; j < subDirs.size() ; ++j) {
const QIconDirInfo &dirInfo = subDirs.at(j);
- QString subdir = dirInfo.path;
- QDir currentDir(contentDir + subdir);
- if (currentDir.exists(pngIconName)) {
+ const QString subDir = contentDir + dirInfo.path + QLatin1Char('/');
+ const QString pngPath = subDir + pngIconName;
+ if (QFile::exists(pngPath)) {
PixmapEntry *iconEntry = new PixmapEntry;
iconEntry->dir = dirInfo;
- iconEntry->filename = currentDir.filePath(pngIconName);
+ iconEntry->filename = pngPath;
// Notice we ensure that pixmap entries always come before
// scalable to preserve search order afterwards
info.entries.prepend(iconEntry);
- } else if (m_supportsSvg &&
- currentDir.exists(svgIconName)) {
- ScalableEntry *iconEntry = new ScalableEntry;
- iconEntry->dir = dirInfo;
- iconEntry->filename = currentDir.filePath(svgIconName);
- info.entries.append(iconEntry);
+ } else if (m_supportsSvg) {
+ const QString svgPath = subDir + svgIconName;
+ if (QFile::exists(svgPath)) {
+ ScalableEntry *iconEntry = new ScalableEntry;
+ iconEntry->dir = dirInfo;
+ iconEntry->filename = svgPath;
+ info.entries.append(iconEntry);
+ }
}
}
}
diff --git a/src/gui/image/qiconloader_p.h b/src/gui/image/qiconloader_p.h
index 0945add2fb..583499be76 100644
--- a/src/gui/image/qiconloader_p.h
+++ b/src/gui/image/qiconloader_p.h
@@ -40,7 +40,7 @@
#ifndef QICONLOADER_P_H
#define QICONLOADER_P_H
-#include <QtCore/qglobal.h>
+#include <QtGui/private/qtguiglobal_p.h>
#ifndef QT_NO_ICON
//
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index de02e9a1dd..bd32ca7bee 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -780,9 +780,8 @@ QImage::QImage() Q_DECL_NOEXCEPT
drawing onto it with QPainter.
*/
QImage::QImage(int width, int height, Format format)
- : QPaintDevice()
+ : QImage(QSize(width, height), format)
{
- d = QImageData::create(QSize(width, height), format);
}
/*!
@@ -2286,7 +2285,7 @@ QRgb QImage::pixel(int x, int y) const
const QPixelLayout *layout = &qPixelLayouts[d->format];
uint result;
const uint *ptr = qFetchPixels[layout->bpp](&result, s, x, 1);
- return *layout->convertToARGB32PM(&result, ptr, 1, layout, 0);
+ return *layout->convertToARGB32PM(&result, ptr, 1, 0, 0);
}
/*!
@@ -2388,7 +2387,7 @@ void QImage::setPixel(int x, int y, uint index_or_rgb)
const QPixelLayout *layout = &qPixelLayouts[d->format];
uint result;
- const uint *ptr = layout->convertFromARGB32PM(&result, &index_or_rgb, 1, layout, 0);
+ const uint *ptr = layout->convertFromARGB32PM(&result, &index_or_rgb, 1, 0, 0);
qStorePixels[layout->bpp](s, ptr, x, 1);
}
@@ -2574,7 +2573,7 @@ bool QImage::allGray() const
while (x < d->width) {
int l = qMin(d->width - x, buffer_size);
const uint *ptr = fetch(buffer, b, x, l);
- ptr = layout->convertToARGB32PM(buffer, ptr, l, layout, 0);
+ ptr = layout->convertToARGB32PM(buffer, ptr, l, 0, 0);
for (int i = 0; i < l; ++i) {
if (!qIsGray(ptr[i]))
return false;
@@ -5217,4 +5216,33 @@ Q_GUI_EXPORT void qt_imageTransform(QImage &src, QImageIOHandler::Transformation
}
}
+QMap<QString, QString> qt_getImageText(const QImage &image, const QString &description)
+{
+ QMap<QString, QString> text = qt_getImageTextFromDescription(description);
+ const auto textKeys = image.textKeys();
+ for (const QString &key : textKeys) {
+ if (!key.isEmpty() && !text.contains(key))
+ text.insert(key, image.text(key));
+ }
+ return text;
+}
+
+QMap<QString, QString> qt_getImageTextFromDescription(const QString &description)
+{
+ QMap<QString, QString> text;
+ const auto pairs = description.splitRef(QLatin1String("\n\n"));
+ for (const QStringRef &pair : pairs) {
+ int index = pair.indexOf(QLatin1Char(':'));
+ if (index >= 0 && pair.indexOf(QLatin1Char(' ')) < index) {
+ if (!pair.trimmed().isEmpty())
+ text.insert(QLatin1String("Description"), pair.toString().simplified());
+ } else {
+ const QStringRef key = pair.left(index);
+ if (!key.trimmed().isEmpty())
+ text.insert(key.toString(), pair.mid(index + 2).toString().simplified());
+ }
+ }
+ return text;
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h
index 6f8e214b11..91aaf673d0 100644
--- a/src/gui/image/qimage.h
+++ b/src/gui/image/qimage.h
@@ -40,6 +40,7 @@
#ifndef QIMAGE_H
#define QIMAGE_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qcolor.h>
#include <QtGui/qrgb.h>
#include <QtGui/qpaintdevice.h>
@@ -53,6 +54,10 @@
#include <QtCore/qstringlist.h>
#endif
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+Q_FORWARD_DECLARE_MUTABLE_CG_TYPE(CGImage);
+#endif
+
QT_BEGIN_NAMESPACE
@@ -320,6 +325,11 @@ public:
static QPixelFormat toPixelFormat(QImage::Format format) Q_DECL_NOTHROW;
static QImage::Format toImageFormat(QPixelFormat format) Q_DECL_NOTHROW;
+ // Platform spesific conversion functions
+#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
+ CGImageRef toCGImage() const Q_DECL_CF_RETURNS_RETAINED;
+#endif
+
#if QT_DEPRECATED_SINCE(5, 0)
QT_DEPRECATED inline QString text(const char *key, const char *lang = Q_NULLPTR) const;
QT_DEPRECATED inline QList<QImageTextKeyLang> textList() const;
diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp
index bb0b76d55f..442492d198 100644
--- a/src/gui/image/qimage_conversions.cpp
+++ b/src/gui/image/qimage_conversions.cpp
@@ -108,7 +108,7 @@ void qGamma_correct_back_to_linear_cs(QImage *image)
// The drawhelper conversions from/to RGB32 are passthroughs which is not always correct for general image conversion.
static const uint *QT_FASTCALL convertRGB32FromARGB32PM(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = 0xff000000 | qUnpremultiply(src[i]);
@@ -116,7 +116,7 @@ static const uint *QT_FASTCALL convertRGB32FromARGB32PM(uint *buffer, const uint
}
static const uint *QT_FASTCALL convertRGB32ToARGB32PM(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = 0xff000000 |src[i];
@@ -124,10 +124,11 @@ static const uint *QT_FASTCALL convertRGB32ToARGB32PM(uint *buffer, const uint *
}
#ifdef QT_COMPILER_SUPPORTS_SSE4_1
-extern const uint *QT_FASTCALL convertRGB32FromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *);
+extern const uint *QT_FASTCALL convertRGB32FromARGB32PM_sse4(uint *buffer, const uint *src, int count,
+ const QVector<QRgb> *, QDitherInfo *);
#endif
-void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags)
+void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags flags)
{
// Cannot be used with indexed formats.
Q_ASSERT(dest->format > QImage::Format_Indexed8);
@@ -158,14 +159,20 @@ void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversio
convertFromARGB32PM = convertRGB32FromARGB32PM;
}
}
+ QDitherInfo dither;
+ QDitherInfo *ditherPtr = 0;
+ if ((flags & Qt::PreferDither) && (flags & Qt::Dither_Mask) != Qt::ThresholdDither)
+ ditherPtr = &dither;
for (int y = 0; y < src->height; ++y) {
+ dither.y = y;
int x = 0;
while (x < src->width) {
+ dither.x = x;
int l = qMin(src->width - x, buffer_size);
const uint *ptr = fetch(buffer, srcData, x, l);
- ptr = convertToARGB32PM(buffer, ptr, l, srcLayout, 0);
- ptr = convertFromARGB32PM(buffer, ptr, l, destLayout, 0);
+ ptr = convertToARGB32PM(buffer, ptr, l, 0, ditherPtr);
+ ptr = convertFromARGB32PM(buffer, ptr, l, 0, ditherPtr);
store(destData, ptr, x, l);
x += l;
}
@@ -174,7 +181,7 @@ void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversio
}
}
-bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::ImageConversionFlags)
+bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::ImageConversionFlags flags)
{
// Cannot be used with indexed formats or between formats with different pixel depths.
Q_ASSERT(dst_format > QImage::Format_Indexed8);
@@ -207,14 +214,20 @@ bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::Im
convertFromARGB32PM = convertRGB32FromARGB32PM;
}
}
+ QDitherInfo dither;
+ QDitherInfo *ditherPtr = 0;
+ if ((flags & Qt::PreferDither) && (flags & Qt::Dither_Mask) != Qt::ThresholdDither)
+ ditherPtr = &dither;
for (int y = 0; y < data->height; ++y) {
+ dither.y = y;
int x = 0;
while (x < data->width) {
+ dither.x = x;
int l = qMin(data->width - x, buffer_size);
const uint *ptr = fetch(buffer, srcData, x, l);
- ptr = convertToARGB32PM(buffer, ptr, l, srcLayout, 0);
- ptr = convertFromARGB32PM(buffer, ptr, l, destLayout, 0);
+ ptr = convertToARGB32PM(buffer, ptr, l, 0, ditherPtr);
+ ptr = convertFromARGB32PM(buffer, ptr, l, 0, ditherPtr);
// The conversions might be passthrough and not use the buffer, in that case we are already done.
if (srcData != (const uchar*)ptr)
store(srcData, ptr, x, l);
diff --git a/src/gui/image/qimage_darwin.mm b/src/gui/image/qimage_darwin.mm
new file mode 100644
index 0000000000..d72733abd3
--- /dev/null
+++ b/src/gui/image/qimage_darwin.mm
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qimage.h"
+
+#include <private/qcore_mac_p.h>
+
+#import <Foundation/Foundation.h>
+#import <CoreGraphics/CoreGraphics.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ Creates a \c CGImage equivalent to the QImage \a image. Returns a
+ \c CGImageRef handle.
+
+ The returned CGImageRef partakes in the QImage implicit sharing,
+ and holds a reference to the QImage data. CGImage is immutable
+ and will never detach the QImage. Writing to the QImage will detach
+ as usual.
+
+ This function is fast, and does not copy or convert image data.
+
+ The following image formats are supported, and will be mapped to
+ a corresponding native image type:
+
+ \table
+ \header
+ \li Qt
+ \li CoreGraphics
+ \row
+ \li Format_ARGB32
+ \li kCGImageAlphaFirst | kCGBitmapByteOrder32Host
+ \row
+ \li Format_RGB32
+ \li kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host
+ \row
+ \li Format_RGBA8888_Premultiplied
+ \li kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big
+ \row
+ \li Format_RGBA8888
+ \li kCGImageAlphaLast | kCGBitmapByteOrder32Big
+ \row
+ \li Format_RGBX8888
+ \li kCGImageAlphaNoneSkipLast | kCGBitmapByteOrder32Big
+ \row
+ \li Format_ARGB32_Premultiplied
+ \li kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host
+ \endtable
+
+ Other formats are not supported; this function returns a null
+ CGImageRef for those cases. Users of this function may then
+ convert the QImage to a supported formate first, for example
+ Format_ARGB32_Premultiplied.
+
+ The CGImageRef color space is set to the sRGB color space.
+
+ \sa toNSImage()
+*/
+CGImageRef QImage::toCGImage() const
+{
+ if (isNull())
+ return nil;
+
+ // Determine the target native format
+ uint cgflags = kCGImageAlphaNone;
+ switch (format()) {
+ case QImage::Format_ARGB32:
+ cgflags = kCGImageAlphaFirst | kCGBitmapByteOrder32Host;
+ break;
+ case QImage::Format_RGB32:
+ cgflags = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host;
+ break;
+ case QImage::Format_RGBA8888_Premultiplied:
+ cgflags = kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big;
+ break;
+ case QImage::Format_RGBA8888:
+ cgflags = kCGImageAlphaLast | kCGBitmapByteOrder32Big;
+ break;
+ case QImage::Format_RGBX8888:
+ cgflags = kCGImageAlphaNoneSkipLast | kCGBitmapByteOrder32Big;
+ break;
+ case QImage::Format_ARGB32_Premultiplied:
+ cgflags = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host;
+ break;
+ default: break;
+ }
+
+ // Format not supported: return nil CGImageRef
+ if (cgflags == kCGImageAlphaNone)
+ return nil;
+
+ // Create a data provider that owns a copy of the QImage and references the image data.
+ auto deleter = [](void *image, const void *, size_t)
+ { delete static_cast<QImage *>(image); };
+ QCFType<CGDataProviderRef> dataProvider =
+ CGDataProviderCreateWithData(new QImage(*this), bits(), byteCount(), deleter);
+
+ QCFType<CGColorSpaceRef> colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB);
+
+ const size_t bitsPerComponent = 8;
+ const size_t bitsPerPixel = 32;
+ const CGFloat *decode = nullptr;
+ const bool shouldInterpolate = false;
+
+ return CGImageCreate(width(), height(), bitsPerComponent, bitsPerPixel,
+ this->bytesPerLine(), colorSpace, cgflags, dataProvider,
+ decode, shouldInterpolate, kCGRenderingIntentDefault);
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h
index 3e76f39b94..775ab6d541 100644
--- a/src/gui/image/qimage_p.h
+++ b/src/gui/image/qimage_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtGui/private/qtguiglobal_p.h>
#include <QMap>
#include <QVector>
@@ -212,6 +212,9 @@ inline QImage::Format qt_alphaVersionForPainting(QImage::Format format)
return toFormat;
}
+Q_GUI_EXPORT QMap<QString, QString> qt_getImageText(const QImage &image, const QString &description);
+Q_GUI_EXPORT QMap<QString, QString> qt_getImageTextFromDescription(const QString &description);
+
QT_END_NAMESPACE
#endif // QIMAGE_P_H
diff --git a/src/gui/image/qimage_sse4.cpp b/src/gui/image/qimage_sse4.cpp
index 1f3f8f0d3f..0e2c2f492e 100644
--- a/src/gui/image/qimage_sse4.cpp
+++ b/src/gui/image/qimage_sse4.cpp
@@ -48,7 +48,7 @@
QT_BEGIN_NAMESPACE
const uint *QT_FASTCALL convertRGB32FromARGB32PM_sse4(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = 0xff000000 | qUnpremultiply_sse4(src[i]);
diff --git a/src/gui/image/qimageiohandler.h b/src/gui/image/qimageiohandler.h
index 8f196ee9e0..baf9853259 100644
--- a/src/gui/image/qimageiohandler.h
+++ b/src/gui/image/qimageiohandler.h
@@ -40,6 +40,7 @@
#ifndef QIMAGEIOHANDLER_H
#define QIMAGEIOHANDLER_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qiodevice.h>
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
diff --git a/src/gui/image/qimagepixmapcleanuphooks_p.h b/src/gui/image/qimagepixmapcleanuphooks_p.h
index f0ac17b0a9..29144c6656 100644
--- a/src/gui/image/qimagepixmapcleanuphooks_p.h
+++ b/src/gui/image/qimagepixmapcleanuphooks_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtGui/qpixmap.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp
index 4dada4ca82..45d57856aa 100644
--- a/src/gui/image/qimagereader.cpp
+++ b/src/gui/image/qimagereader.cpp
@@ -147,6 +147,9 @@
#include <private/qfactoryloader_p.h>
#include <QMutexLocker>
+// for qt_getImageText
+#include <private/qimage_p.h>
+
// image handlers
#include <private/qbmphandler_p.h>
#include <private/qppmhandler_p.h>
@@ -155,12 +158,6 @@
#ifndef QT_NO_IMAGEFORMAT_PNG
#include <private/qpnghandler_p.h>
#endif
-#ifndef QT_NO_IMAGEFORMAT_JPEG
-#include <private/qjpeghandler_p.h>
-#endif
-#ifdef QT_BUILTIN_GIF_READER
-#include <private/qgifhandler_p.h>
-#endif
#include <algorithm>
@@ -175,13 +172,6 @@ enum _qt_BuiltInFormatType {
#ifndef QT_NO_IMAGEFORMAT_PNG
_qt_PngFormat,
#endif
-#ifndef QT_NO_IMAGEFORMAT_JPEG
- _qt_JpgFormat,
- _qt_JpegFormat,
-#endif
-#ifdef QT_BUILTIN_GIF_READER
- _qt_GifFormat,
-#endif
#ifndef QT_NO_IMAGEFORMAT_BMP
_qt_BmpFormat,
#endif
@@ -210,13 +200,6 @@ static const _qt_BuiltInFormatStruct _qt_BuiltInFormats[] = {
#ifndef QT_NO_IMAGEFORMAT_PNG
{"png", "image/png"},
#endif
-#ifndef QT_NO_IMAGEFORMAT_JPEG
- {"jpg", "image/jpeg"},
- {"jpeg", "image/jpeg"},
-#endif
-#ifdef QT_BUILTIN_GIF_READER
- {"gif", "image/gif"},
-#endif
#ifndef QT_NO_IMAGEFORMAT_BMP
{"bmp", "image/bmp"},
#endif
@@ -357,14 +340,6 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
} else if (testFormat == "png") {
handler = new QPngHandler;
#endif
-#ifndef QT_NO_IMAGEFORMAT_JPEG
- } else if (testFormat == "jpg" || testFormat == "jpeg") {
- handler = new QJpegHandler;
-#endif
-#ifdef QT_BUILTIN_GIF_READER
- } else if (testFormat == "gif") {
- handler = new QGifHandler;
-#endif
#ifndef QT_NO_IMAGEFORMAT_BMP
} else if (testFormat == "bmp") {
handler = new QBmpHandler;
@@ -442,19 +417,6 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
handler = new QPngHandler;
break;
#endif
-#ifndef QT_NO_IMAGEFORMAT_JPEG
- case _qt_JpgFormat:
- case _qt_JpegFormat:
- if (QJpegHandler::canRead(device))
- handler = new QJpegHandler;
- break;
-#endif
-#ifdef QT_BUILTIN_GIF_READER
- case _qt_GifFormat:
- if (QGifHandler::canRead(device))
- handler = new QGifHandler;
- break;
-#endif
#ifndef QT_NO_IMAGEFORMAT_BMP
case _qt_BmpFormat:
if (QBmpHandler::canRead(device))
@@ -491,8 +453,8 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device,
if (handler) {
#ifdef QIMAGEREADER_DEBUG
- qDebug() << "QImageReader::createReadHandler: the" << _qt_BuiltInFormats[currentFormat].extension
- << "built-in handler can read this data";
+ qDebug("QImageReader::createReadHandler: the %s built-in handler can read this data",
+ _qt_BuiltInFormats[currentFormat].extension);
#endif
break;
}
@@ -633,18 +595,8 @@ bool QImageReaderPrivate::initHandler()
*/
void QImageReaderPrivate::getText()
{
- if (!text.isEmpty() || (!handler && !initHandler()) || !handler->supportsOption(QImageIOHandler::Description))
- return;
- foreach (const QString &pair, handler->option(QImageIOHandler::Description).toString().split(
- QLatin1String("\n\n"))) {
- int index = pair.indexOf(QLatin1Char(':'));
- if (index >= 0 && pair.indexOf(QLatin1Char(' ')) < index) {
- text.insert(QLatin1String("Description"), pair.simplified());
- } else {
- QString key = pair.left(index);
- text.insert(key, pair.mid(index + 2).simplified());
- }
- }
+ if (text.isEmpty() && (handler || initHandler()) && handler->supportsOption(QImageIOHandler::Description))
+ text = qt_getImageTextFromDescription(handler->option(QImageIOHandler::Description).toString());
}
/*!
@@ -674,12 +626,9 @@ QImageReader::QImageReader(QIODevice *device, const QByteArray &format)
\sa setFileName()
*/
QImageReader::QImageReader(const QString &fileName, const QByteArray &format)
- : d(new QImageReaderPrivate(this))
+ : QImageReader(new QFile(fileName), format)
{
- QFile *file = new QFile(fileName);
- d->device = file;
d->deleteDevice = true;
- d->format = format;
}
/*!
diff --git a/src/gui/image/qimagereader.h b/src/gui/image/qimagereader.h
index ad4f56c001..9d6c1e0b1e 100644
--- a/src/gui/image/qimagereader.h
+++ b/src/gui/image/qimagereader.h
@@ -40,6 +40,7 @@
#ifndef QIMAGEREADER_H
#define QIMAGEREADER_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qcoreapplication.h>
#include <QtGui/qimage.h>
diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp
index 35db038601..f3af2738af 100644
--- a/src/gui/image/qimagewriter.cpp
+++ b/src/gui/image/qimagewriter.cpp
@@ -115,12 +115,6 @@
#ifndef QT_NO_IMAGEFORMAT_PNG
#include <private/qpnghandler_p.h>
#endif
-#ifndef QT_NO_IMAGEFORMAT_JPEG
-#include <private/qjpeghandler_p.h>
-#endif
-#ifdef QT_BUILTIN_GIF_READER
-#include <private/qgifhandler_p.h>
-#endif
#include <algorithm>
@@ -184,14 +178,6 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device,
} else if (testFormat == "png") {
handler = new QPngHandler;
#endif
-#ifndef QT_NO_IMAGEFORMAT_JPEG
- } else if (testFormat == "jpg" || testFormat == "jpeg") {
- handler = new QJpegHandler;
-#endif
-#ifdef QT_BUILTIN_GIF_READER
- } else if (testFormat == "gif") {
- handler = new QGifHandler;
-#endif
#ifndef QT_NO_IMAGEFORMAT_BMP
} else if (testFormat == "bmp") {
handler = new QBmpHandler;
@@ -340,12 +326,9 @@ QImageWriter::QImageWriter(QIODevice *device, const QByteArray &format)
by inspecting the extension of \a fileName.
*/
QImageWriter::QImageWriter(const QString &fileName, const QByteArray &format)
- : d(new QImageWriterPrivate(this))
+ : QImageWriter(new QFile(fileName), format)
{
- QFile *file = new QFile(fileName);
- d->device = file;
d->deleteDevice = true;
- d->format = format;
}
/*!
@@ -910,9 +893,6 @@ QList<QByteArray> QImageWriter::supportedImageFormats()
#ifndef QT_NO_IMAGEFORMAT_PNG
formats << "png";
#endif
-#ifndef QT_NO_IMAGEFORMAT_JPEG
- formats << "jpg" << "jpeg";
-#endif
#ifndef QT_NO_IMAGEFORMATPLUGIN
supportedImageHandlerFormats(loader(), QImageIOPlugin::CanWrite, &formats);
@@ -951,9 +931,6 @@ QList<QByteArray> QImageWriter::supportedMimeTypes()
#ifndef QT_NO_IMAGEFORMAT_PNG
mimeTypes << "image/png";
#endif
-#ifndef QT_NO_IMAGEFORMAT_JPEG
- mimeTypes << "image/jpeg";
-#endif
#ifndef QT_NO_IMAGEFORMATPLUGIN
supportedImageHandlerMimeTypes(loader(), QImageIOPlugin::CanWrite, &mimeTypes);
diff --git a/src/gui/image/qimagewriter.h b/src/gui/image/qimagewriter.h
index a6208ae5dc..58f8c51472 100644
--- a/src/gui/image/qimagewriter.h
+++ b/src/gui/image/qimagewriter.h
@@ -40,6 +40,7 @@
#ifndef QIMAGEWRITER_H
#define QIMAGEWRITER_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qlist.h>
diff --git a/src/gui/image/qjpeghandler.pri b/src/gui/image/qjpeghandler.pri
deleted file mode 100644
index de40c6742e..0000000000
--- a/src/gui/image/qjpeghandler.pri
+++ /dev/null
@@ -1,11 +0,0 @@
-# common to plugin and built-in forms
-HEADERS += $$PWD/qjpeghandler_p.h
-SOURCES += $$PWD/qjpeghandler.cpp
-contains(QT_CONFIG, system-jpeg) {
- msvc: \
- LIBS += libjpeg.lib
- else: \
- LIBS += -ljpeg
-} else {
- include($$PWD/../../3rdparty/libjpeg.pri)
-}
diff --git a/src/gui/image/qmovie.h b/src/gui/image/qmovie.h
index cf644d3347..2b41e07dba 100644
--- a/src/gui/image/qmovie.h
+++ b/src/gui/image/qmovie.h
@@ -40,10 +40,11 @@
#ifndef QMOVIE_H
#define QMOVIE_H
-#include <QtCore/qobject.h>
+#include <QtGui/qtguiglobal.h>
#ifndef QT_NO_MOVIE
+#include <QtCore/qobject.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qlist.h>
#include <QtGui/qimagereader.h>
diff --git a/src/gui/image/qpaintengine_pic_p.h b/src/gui/image/qpaintengine_pic_p.h
index 6894593092..277004d055 100644
--- a/src/gui/image/qpaintengine_pic_p.h
+++ b/src/gui/image/qpaintengine_pic_p.h
@@ -52,7 +52,8 @@
//
//
-#include "QtGui/qpaintengine.h"
+#include <QtGui/private/qtguiglobal_p.h>
+#include <QtGui/qpaintengine.h>
#ifndef QT_NO_PICTURE
diff --git a/src/gui/image/qpicture.h b/src/gui/image/qpicture.h
index f375157317..8da11caee4 100644
--- a/src/gui/image/qpicture.h
+++ b/src/gui/image/qpicture.h
@@ -40,6 +40,7 @@
#ifndef QPICTURE_H
#define QPICTURE_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qiodevice.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qsharedpointer.h>
diff --git a/src/gui/image/qpicture_p.h b/src/gui/image/qpicture_p.h
index df1235469c..67db9aa354 100644
--- a/src/gui/image/qpicture_p.h
+++ b/src/gui/image/qpicture_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtCore/qatomic.h"
#include "QtCore/qbuffer.h"
#include "QtCore/qobjectdefs.h"
diff --git a/src/gui/image/qpictureformatplugin.h b/src/gui/image/qpictureformatplugin.h
index 003ccac116..32195687c7 100644
--- a/src/gui/image/qpictureformatplugin.h
+++ b/src/gui/image/qpictureformatplugin.h
@@ -40,6 +40,7 @@
#ifndef QPICTUREFORMATPLUGIN_H
#define QPICTUREFORMATPLUGIN_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 59d6dc12c6..a360debf5b 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -125,12 +125,8 @@ QPixmap::QPixmap()
*/
QPixmap::QPixmap(int w, int h)
- : QPaintDevice()
+ : QPixmap(QSize(w, h))
{
- if (!qt_pixmap_thread_test())
- doInit(0, 0, QPlatformPixmap::PixmapType);
- else
- doInit(w, h, QPlatformPixmap::PixmapType);
}
/*!
@@ -144,12 +140,8 @@ QPixmap::QPixmap(int w, int h)
*/
QPixmap::QPixmap(const QSize &size)
- : QPaintDevice()
+ : QPixmap(size, QPlatformPixmap::PixmapType)
{
- if (!qt_pixmap_thread_test())
- doInit(0, 0, QPlatformPixmap::PixmapType);
- else
- doInit(size.width(), size.height(), QPlatformPixmap::PixmapType);
}
/*!
@@ -778,7 +770,7 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers
QFileInfo info(fileName);
QString key = QLatin1String("qt_pixmap")
% info.absoluteFilePath()
- % HexString<uint>(info.lastModified().toTime_t())
+ % HexString<uint>(info.lastModified().toSecsSinceEpoch())
% HexString<quint64>(info.size())
% HexString<uint>(data ? data->pixelType() : QPlatformPixmap::PixmapType);
diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h
index 165ec4a6b8..d651b57fd5 100644
--- a/src/gui/image/qpixmap.h
+++ b/src/gui/image/qpixmap.h
@@ -40,6 +40,7 @@
#ifndef QPIXMAP_H
#define QPIXMAP_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qpaintdevice.h>
#include <QtGui/qcolor.h>
#include <QtCore/qnamespace.h>
diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp
index 0906b65d96..4032176efc 100644
--- a/src/gui/image/qpixmap_blitter.cpp
+++ b/src/gui/image/qpixmap_blitter.cpp
@@ -152,7 +152,7 @@ void QBlittablePlatformPixmap::fill(const QColor &color)
uint pixel = qPremultiply(color.rgba());
const QPixelLayout *layout = &qPixelLayouts[blittable()->lock()->format()];
Q_ASSERT(layout->convertFromARGB32PM);
- layout->convertFromARGB32PM(&pixel, &pixel, 1, layout, 0);
+ layout->convertFromARGB32PM(&pixel, &pixel, 1, 0, 0);
//so premultiplied formats are supported and ARGB32 and RGB32
blittable()->lock()->fill(pixel);
@@ -298,10 +298,8 @@ QRectF QBlittablePlatformPixmap::clipAndTransformRect(const QRectF &rect) const
if (clipData->hasRectClip) {
transformationRect &= clipData->clipRect;
} else if (clipData->hasRegionClip) {
- const QVector<QRect> rects = clipData->clipRegion.rects();
- for (int i = 0; i < rects.size(); i++) {
- transformationRect &= rects.at(i);
- }
+ for (const QRect &rect : clipData->clipRegion)
+ transformationRect &= rect;
}
}
}
diff --git a/src/gui/image/qpixmap_blitter_p.h b/src/gui/image/qpixmap_blitter_p.h
index bc97bbc1df..9889cfb8ec 100644
--- a/src/gui/image/qpixmap_blitter_p.h
+++ b/src/gui/image/qpixmap_blitter_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <qpa/qplatformpixmap.h>
#include <private/qpaintengine_blitter_p.h>
diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp
index 13104ce17f..741f7713da 100644
--- a/src/gui/image/qpixmap_raster.cpp
+++ b/src/gui/image/qpixmap_raster.cpp
@@ -42,7 +42,6 @@
#include <private/qfont_p.h>
#include "qpixmap_raster_p.h"
-#include "qnativeimage_p.h"
#include "qimage_p.h"
#include "qpaintengine.h"
@@ -50,9 +49,12 @@
#include "qimage.h"
#include <QBuffer>
#include <QImageReader>
+#include <QGuiApplication>
+#include <QScreen>
#include <private/qimage_p.h>
#include <private/qsimd_p.h>
#include <private/qdrawhelper_p.h>
+#include <qpa/qplatformscreen.h>
QT_BEGIN_NAMESPACE
@@ -88,6 +90,13 @@ QRasterPlatformPixmap::~QRasterPlatformPixmap()
{
}
+QImage::Format QRasterPlatformPixmap::systemOpaqueFormat()
+{
+ if (!QGuiApplication::primaryScreen())
+ return QImage::Format_RGB32;
+ return QGuiApplication::primaryScreen()->handle()->format();
+}
+
QPlatformPixmap *QRasterPlatformPixmap::createCompatiblePlatformPixmap() const
{
return new QRasterPlatformPixmap(pixelType());
@@ -99,7 +108,7 @@ void QRasterPlatformPixmap::resize(int width, int height)
if (pixelType() == BitmapType)
format = QImage::Format_MonoLSB;
else
- format = QNativeImage::systemFormat();
+ format = systemOpaqueFormat();
image = QImage(width, height, format);
w = width;
@@ -195,7 +204,7 @@ void QRasterPlatformPixmap::fill(const QColor &color)
}
pixel = qPremultiply(color.rgba());
const QPixelLayout *layout = &qPixelLayouts[image.format()];
- layout->convertFromARGB32PM(&pixel, &pixel, 1, layout, 0);
+ layout->convertFromARGB32PM(&pixel, &pixel, 1, 0, 0);
} else if (image.format() == QImage::Format_Alpha8) {
pixel = qAlpha(color.rgba());
} else if (image.format() == QImage::Format_Grayscale8) {
@@ -306,13 +315,13 @@ void QRasterPlatformPixmap::createPixmapForImage(QImage &sourceImage, Qt::ImageC
? QImage::Format_ARGB32_Premultiplied
: QImage::Format_RGB32;
} else {
- QImage::Format opaqueFormat = QNativeImage::systemFormat();
+ QImage::Format opaqueFormat = systemOpaqueFormat();
QImage::Format alphaFormat = qt_alphaVersionForPainting(opaqueFormat);
if (!sourceImage.hasAlphaChannel()) {
format = opaqueFormat;
} else if ((flags & Qt::NoOpaqueDetection) == 0
- && !const_cast<QImage &>(sourceImage).data_ptr()->checkForAlphaPixels())
+ && !sourceImage.data_ptr()->checkForAlphaPixels())
{
format = opaqueFormat;
} else {
@@ -335,7 +344,7 @@ void QRasterPlatformPixmap::createPixmapForImage(QImage &sourceImage, Qt::ImageC
} else if (inPlace && sourceImage.d->convertInPlace(format, flags)) {
image = sourceImage;
} else {
- image = sourceImage.convertToFormat(format);
+ image = sourceImage.convertToFormat(format, flags);
}
if (image.d) {
diff --git a/src/gui/image/qpixmap_raster_p.h b/src/gui/image/qpixmap_raster_p.h
index 1a42757669..95e018eb35 100644
--- a/src/gui/image/qpixmap_raster_p.h
+++ b/src/gui/image/qpixmap_raster_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <qpa/qplatformpixmap.h>
@@ -87,6 +88,7 @@ protected:
void createPixmapForImage(QImage &sourceImage, Qt::ImageConversionFlags flags, bool inPlace);
void setImage(const QImage &image);
QImage image;
+ static QImage::Format systemOpaqueFormat();
private:
friend class QPixmap;
diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp
index 7f20586156..92f6964783 100644
--- a/src/gui/image/qpixmap_win.cpp
+++ b/src/gui/image/qpixmap_win.cpp
@@ -48,84 +48,6 @@
QT_BEGIN_NAMESPACE
-#ifdef Q_OS_WINCE
-#define GetDIBits(a,b,c,d,e,f,g) qt_wince_GetDIBits(a,b,c,d,e,f,g)
-int qt_wince_GetDIBits(HDC /*hdc*/ , HBITMAP hSourceBitmap, uint, uint, LPVOID lpvBits, LPBITMAPINFO, uint)
-{
- if (!lpvBits) {
- qWarning("::GetDIBits(), lpvBits NULL");
- return 0;
- }
- BITMAP bm;
- GetObject(hSourceBitmap, sizeof(BITMAP), &bm);
- bm.bmHeight = qAbs(bm.bmHeight);
-
- HBITMAP hTargetBitmap;
- void *pixels;
-
- BITMAPINFO dibInfo;
- memset(&dibInfo, 0, sizeof(dibInfo));
- dibInfo.bmiHeader.biBitCount = 32;
- dibInfo.bmiHeader.biClrImportant = 0;
- dibInfo.bmiHeader.biClrUsed = 0;
- dibInfo.bmiHeader.biCompression = BI_RGB;;
- dibInfo.bmiHeader.biHeight = -bm.bmHeight;
- dibInfo.bmiHeader.biWidth = bm.bmWidth;
- dibInfo.bmiHeader.biPlanes = 1;
- dibInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- dibInfo.bmiHeader.biSizeImage = bm.bmWidth * bm.bmHeight * 4;
-
- HDC displayDC = GetDC(NULL);
- if (!displayDC) {
- qWarning("::GetDIBits(), failed to GetDC");
- return 0;
- }
-
- int ret = bm.bmHeight;
-
- hTargetBitmap = CreateDIBSection(displayDC, (const BITMAPINFO*) &dibInfo, DIB_RGB_COLORS,
- (void**)&pixels, NULL, 0);
- if (!hTargetBitmap) {
- qWarning("::GetDIBits(), failed to CreateDIBSection");
- return 0;
- }
-
- HDC hdcSrc = CreateCompatibleDC(displayDC);
- HDC hdcDst = CreateCompatibleDC(displayDC);
-
- if (!(hdcDst && hdcSrc)) {
- qWarning("::GetDIBits(), failed to CreateCompatibleDC");
- ret = 0;
- }
-
- HBITMAP hOldBitmap1 = (HBITMAP) SelectObject(hdcSrc, hSourceBitmap);
- HBITMAP hOldBitmap2 = (HBITMAP) SelectObject(hdcDst, hTargetBitmap);
-
- if (!(hOldBitmap1 && hOldBitmap2)) {
- qWarning("::GetDIBits(), failed to SelectObject for bitmaps");
- ret = 0;
- }
-
- if (!BitBlt(hdcDst, 0, 0, bm.bmWidth, bm.bmHeight, hdcSrc, 0, 0, SRCCOPY)) {
- qWarning("::GetDIBits(), BitBlt failed");
- ret = 0;
- }
-
- SelectObject(hdcSrc, hOldBitmap1);
- SelectObject(hdcDst, hOldBitmap2);
-
- DeleteDC(hdcSrc);
- DeleteDC(hdcDst);
-
- ReleaseDC(NULL, displayDC);
-
- memcpy(lpvBits, pixels, dibInfo.bmiHeader.biSizeImage);
-
- DeleteObject(hTargetBitmap);
- return ret;
-}
-#endif
-
static inline void initBitMapInfoHeader(int width, int height, bool topToBottom, BITMAPINFOHEADER *bih)
{
memset(bih, 0, sizeof(BITMAPINFOHEADER));
@@ -325,8 +247,6 @@ Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &p)
return hIcon;
}
-#ifndef Q_OS_WINCE
-
Q_GUI_EXPORT QImage qt_imageFromWinHBITMAP(HDC hdc, HBITMAP bitmap, int w, int h)
{
QImage image(w, h, QImage::Format_ARGB32_Premultiplied);
@@ -415,95 +335,5 @@ Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon)
DeleteDC(hdc);
return QPixmap::fromImage(image);
}
-#else //ifndef Q_OS_WINCE
-Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon)
-{
- HDC screenDevice = GetDC(0);
- HDC hdc = CreateCompatibleDC(screenDevice);
- ReleaseDC(0, screenDevice);
-
- ICONINFO iconinfo;
- bool result = GetIconInfo(icon, &iconinfo);
- if (!result)
- qWarning("QPixmap::fromWinHICON(), failed to GetIconInfo()");
-
- int w = 0;
- int h = 0;
- if (!iconinfo.xHotspot || !iconinfo.yHotspot) {
- // We could not retrieve the icon size via GetIconInfo,
- // so we try again using the icon bitmap.
- BITMAP bm;
- int result = GetObject(iconinfo.hbmColor, sizeof(BITMAP), &bm);
- if (!result) result = GetObject(iconinfo.hbmMask, sizeof(BITMAP), &bm);
- if (!result) {
- qWarning("QPixmap::fromWinHICON(), failed to retrieve icon size");
- return QPixmap();
- }
- w = bm.bmWidth;
- h = bm.bmHeight;
- } else {
- // x and y Hotspot describes the icon center
- w = iconinfo.xHotspot * 2;
- h = iconinfo.yHotspot * 2;
- }
- const DWORD dwImageSize = w * h * 4;
-
- BITMAPINFO bmi;
- memset(&bmi, 0, sizeof(bmi));
- bmi.bmiHeader.biSize = sizeof(BITMAPINFO);
- bmi.bmiHeader.biWidth = w;
- bmi.bmiHeader.biHeight = -h;
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = 32;
- bmi.bmiHeader.biCompression = BI_RGB;
- bmi.bmiHeader.biSizeImage = dwImageSize;
-
- uchar* bits;
-
- HBITMAP winBitmap = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, (void**) &bits, 0, 0);
- if (winBitmap )
- memset(bits, 0xff, dwImageSize);
- if (!winBitmap) {
- qWarning("QPixmap::fromWinHICON(), failed to CreateDIBSection()");
- return QPixmap();
- }
-
- HGDIOBJ oldhdc = (HBITMAP)SelectObject(hdc, winBitmap);
- if (!DrawIconEx( hdc, 0, 0, icon, w, h, 0, 0, DI_NORMAL))
- qWarning("QPixmap::fromWinHICON(), failed to DrawIcon()");
-
- uint mask = 0xff000000;
- // Create image and copy data into image.
- QImage image(w, h, QImage::Format_ARGB32);
-
- if (!image.isNull()) { // failed to alloc?
- int bytes_per_line = w * sizeof(QRgb);
- for (int y=0; y < h; ++y) {
- QRgb *dest = (QRgb *) image.scanLine(y);
- const QRgb *src = (const QRgb *) (bits + y * bytes_per_line);
- for (int x=0; x < w; ++x) {
- dest[x] = src[x];
- }
- }
- }
- if (!DrawIconEx( hdc, 0, 0, icon, w, h, 0, 0, DI_MASK))
- qWarning("QPixmap::fromWinHICON(), failed to DrawIcon()");
- if (!image.isNull()) { // failed to alloc?
- int bytes_per_line = w * sizeof(QRgb);
- for (int y=0; y < h; ++y) {
- QRgb *dest = (QRgb *) image.scanLine(y);
- const QRgb *src = (const QRgb *) (bits + y * bytes_per_line);
- for (int x=0; x < w; ++x) {
- if (!src[x])
- dest[x] = dest[x] | mask;
- }
- }
- }
- SelectObject(hdc, oldhdc); //restore state
- DeleteObject(winBitmap);
- DeleteDC(hdc);
- return QPixmap::fromImage(image);
-}
-#endif //ifndef Q_OS_WINCE
QT_END_NAMESPACE
diff --git a/src/gui/image/qpixmapcache.h b/src/gui/image/qpixmapcache.h
index cc35fd0fd2..856b82f559 100644
--- a/src/gui/image/qpixmapcache.h
+++ b/src/gui/image/qpixmapcache.h
@@ -40,6 +40,7 @@
#ifndef QPIXMAPCACHE_H
#define QPIXMAPCACHE_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qpixmap.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/image/qpixmapcache_p.h b/src/gui/image/qpixmapcache_p.h
index 951c4ea9b1..3c57367514 100644
--- a/src/gui/image/qpixmapcache_p.h
+++ b/src/gui/image/qpixmapcache_p.h
@@ -50,6 +50,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "qpixmapcache.h"
#include "qpaintengine.h"
#include <private/qimage_p.h>
diff --git a/src/gui/image/qplatformpixmap.h b/src/gui/image/qplatformpixmap.h
index c83278a4c3..8513755cca 100644
--- a/src/gui/image/qplatformpixmap.h
+++ b/src/gui/image/qplatformpixmap.h
@@ -49,6 +49,7 @@
// source and binary incompatible with future versions of Qt.
//
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qpixmap.h>
#include <QtCore/qatomic.h>
diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp
index d021e6f09f..fdf77e162c 100644
--- a/src/gui/image/qpnghandler.cpp
+++ b/src/gui/image/qpnghandler.cpp
@@ -49,6 +49,8 @@
#include <qvariant.h>
#include <qvector.h>
+#include <private/qimage_p.h> // for qt_getImageText
+
#include <png.h>
#include <pngconf.h>
@@ -75,20 +77,8 @@
# endif
#endif
-#ifdef Q_OS_WINCE
-#define CALLBACK_CALL_TYPE __cdecl
-#else
-#define CALLBACK_CALL_TYPE
-#endif
-
QT_BEGIN_NAMESPACE
-#if defined(Q_OS_WINCE) && defined(STANDARDSHELL_UI_MODEL)
-# define Q_INTERNAL_WIN_NO_THROW __declspec(nothrow)
-#else
-# define Q_INTERNAL_WIN_NO_THROW
-#endif
-
// avoid going through QImage::scanLine() which calls detach
#define FAST_SCAN_LINE(data, bpl, y) (data + (y) * bpl)
@@ -190,7 +180,7 @@ private:
extern "C" {
static
-void CALLBACK_CALL_TYPE iod_read_fn(png_structp png_ptr, png_bytep data, png_size_t length)
+void iod_read_fn(png_structp png_ptr, png_bytep data, png_size_t length)
{
QPngHandlerPrivate *d = (QPngHandlerPrivate *)png_get_io_ptr(png_ptr);
QIODevice *in = d->q->device();
@@ -215,7 +205,7 @@ void CALLBACK_CALL_TYPE iod_read_fn(png_structp png_ptr, png_bytep data, png_siz
static
-void CALLBACK_CALL_TYPE qpiw_write_fn(png_structp png_ptr, png_bytep data, png_size_t length)
+void qpiw_write_fn(png_structp png_ptr, png_bytep data, png_size_t length)
{
QPNGImageWriter* qpiw = (QPNGImageWriter*)png_get_io_ptr(png_ptr);
QIODevice* out = qpiw->device();
@@ -229,7 +219,7 @@ void CALLBACK_CALL_TYPE qpiw_write_fn(png_structp png_ptr, png_bytep data, png_s
static
-void CALLBACK_CALL_TYPE qpiw_flush_fn(png_structp /* png_ptr */)
+void qpiw_flush_fn(png_structp /* png_ptr */)
{
}
@@ -487,7 +477,7 @@ static void read_image_scaled(QImage *outImage, png_structp png_ptr, png_infop i
}
extern "C" {
-static void CALLBACK_CALL_TYPE qt_png_warning(png_structp /*png_ptr*/, png_const_charp message)
+static void qt_png_warning(png_structp /*png_ptr*/, png_const_charp message)
{
qWarning("libpng warning: %s", message);
}
@@ -495,7 +485,7 @@ static void CALLBACK_CALL_TYPE qt_png_warning(png_structp /*png_ptr*/, png_const
}
-void Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngTexts(png_info *info)
+void QPngHandlerPrivate::readPngTexts(png_info *info)
{
png_textp text_ptr;
int num_text=0;
@@ -522,7 +512,7 @@ void Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngTexts(png_info *info)
}
-bool Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngHeader()
+bool QPngHandlerPrivate::readPngHeader()
{
state = Error;
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0);
@@ -566,7 +556,7 @@ bool Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngHeader()
return true;
}
-bool Q_INTERNAL_WIN_NO_THROW QPngHandlerPrivate::readPngImage(QImage *outImage)
+bool QPngHandlerPrivate::readPngImage(QImage *outImage)
{
if (state == Error)
return false;
@@ -730,27 +720,10 @@ void QPNGImageWriter::setGamma(float g)
gamma = g;
}
-
static void set_text(const QImage &image, png_structp png_ptr, png_infop info_ptr,
const QString &description)
{
- QMap<QString, QString> text;
- foreach (const QString &key, image.textKeys()) {
- if (!key.isEmpty())
- text.insert(key, image.text(key));
- }
- foreach (const QString &pair, description.split(QLatin1String("\n\n"))) {
- int index = pair.indexOf(QLatin1Char(':'));
- if (index >= 0 && pair.indexOf(QLatin1Char(' ')) < index) {
- QString s = pair.simplified();
- if (!s.isEmpty())
- text.insert(QLatin1String("Description"), s);
- } else {
- QString key = pair.left(index);
- if (!key.simplified().isEmpty())
- text.insert(key, pair.mid(index + 2).simplified());
- }
- }
+ const QMap<QString, QString> text = qt_getImageText(image, description);
if (text.isEmpty())
return;
@@ -810,7 +783,7 @@ bool QPNGImageWriter::writeImage(const QImage& image, int off_x, int off_y)
return writeImage(image, -1, QString(), off_x, off_y);
}
-bool Q_INTERNAL_WIN_NO_THROW QPNGImageWriter::writeImage(const QImage& image, volatile int quality_in, const QString &description,
+bool QPNGImageWriter::writeImage(const QImage& image, volatile int quality_in, const QString &description,
int off_x_in, int off_y_in)
{
QPoint offset = image.offset();
diff --git a/src/gui/image/qpnghandler.pri b/src/gui/image/qpnghandler.pri
index 505d214130..e69de29bb2 100644
--- a/src/gui/image/qpnghandler.pri
+++ b/src/gui/image/qpnghandler.pri
@@ -1,4 +0,0 @@
-HEADERS += $$PWD/qpnghandler_p.h
-SOURCES += $$PWD/qpnghandler.cpp
-
-include($$PWD/../../3rdparty/png_dependency.pri)
diff --git a/src/gui/image/qpnghandler_p.h b/src/gui/image/qpnghandler_p.h
index fb5a830baa..0232df7c3f 100644
--- a/src/gui/image/qpnghandler_p.h
+++ b/src/gui/image/qpnghandler_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtGui/qimageiohandler.h"
#ifndef QT_NO_IMAGEFORMAT_PNG
diff --git a/src/gui/image/qppmhandler_p.h b/src/gui/image/qppmhandler_p.h
index 1e8ca2b81e..3106d74651 100644
--- a/src/gui/image/qppmhandler_p.h
+++ b/src/gui/image/qppmhandler_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtGui/qimageiohandler.h"
#ifndef QT_NO_IMAGEFORMAT_PPM
diff --git a/src/gui/image/qxbmhandler_p.h b/src/gui/image/qxbmhandler_p.h
index 5094a43ef6..c59872f4be 100644
--- a/src/gui/image/qxbmhandler_p.h
+++ b/src/gui/image/qxbmhandler_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtGui/qimageiohandler.h"
#ifndef QT_NO_IMAGEFORMAT_XBM
diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp
index c8dd589673..756e31318f 100644
--- a/src/gui/image/qxpmhandler.cpp
+++ b/src/gui/image/qxpmhandler.cpp
@@ -845,7 +845,7 @@ static bool read_xpm_header(
if (!read_xpm_string(buf, device, source, index, state))
return false;
-#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(Q_OS_WINCE)
+#ifdef Q_CC_MSVC
if (sscanf_s(buf, "%d %d %d %d", w, h, ncols, cpp) < 4)
#else
if (sscanf(buf, "%d %d %d %d", w, h, ncols, cpp) < 4)
diff --git a/src/gui/image/qxpmhandler_p.h b/src/gui/image/qxpmhandler_p.h
index 9a2041be94..51e5d6dc6c 100644
--- a/src/gui/image/qxpmhandler_p.h
+++ b/src/gui/image/qxpmhandler_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtGui/qimageiohandler.h"
#ifndef QT_NO_IMAGEFORMAT_XPM
diff --git a/src/gui/itemmodels/qstandarditemmodel.cpp b/src/gui/itemmodels/qstandarditemmodel.cpp
index 5c04510af1..e965045524 100644
--- a/src/gui/itemmodels/qstandarditemmodel.cpp
+++ b/src/gui/itemmodels/qstandarditemmodel.cpp
@@ -705,20 +705,16 @@ void QStandardItemModelPrivate::columnsRemoved(QStandardItem *parent,
Constructs an item.
*/
QStandardItem::QStandardItem()
- : d_ptr(new QStandardItemPrivate)
+ : QStandardItem(*new QStandardItemPrivate)
{
- Q_D(QStandardItem);
- d->q_ptr = this;
}
/*!
Constructs an item with the given \a text.
*/
QStandardItem::QStandardItem(const QString &text)
- : d_ptr(new QStandardItemPrivate)
+ : QStandardItem(*new QStandardItemPrivate)
{
- Q_D(QStandardItem);
- d->q_ptr = this;
setText(text);
}
@@ -726,22 +722,17 @@ QStandardItem::QStandardItem(const QString &text)
Constructs an item with the given \a icon and \a text.
*/
QStandardItem::QStandardItem(const QIcon &icon, const QString &text)
- : d_ptr(new QStandardItemPrivate)
+ : QStandardItem(text)
{
- Q_D(QStandardItem);
- d->q_ptr = this;
setIcon(icon);
- setText(text);
}
/*!
Constructs an item with \a rows rows and \a columns columns of child items.
*/
QStandardItem::QStandardItem(int rows, int columns)
- : d_ptr(new QStandardItemPrivate)
+ : QStandardItem(*new QStandardItemPrivate)
{
- Q_D(QStandardItem);
- d->q_ptr = this;
setRowCount(rows);
setColumnCount(columns);
}
@@ -1877,36 +1868,7 @@ bool QStandardItem::operator<(const QStandardItem &other) const
{
const int role = model() ? model()->sortRole() : Qt::DisplayRole;
const QVariant l = data(role), r = other.data(role);
- // this code is copied from QSortFilterProxyModel::lessThan()
- if (l.userType() == QVariant::Invalid)
- return false;
- if (r.userType() == QVariant::Invalid)
- return true;
- switch (l.userType()) {
- case QVariant::Int:
- return l.toInt() < r.toInt();
- case QVariant::UInt:
- return l.toUInt() < r.toUInt();
- case QVariant::LongLong:
- return l.toLongLong() < r.toLongLong();
- case QVariant::ULongLong:
- return l.toULongLong() < r.toULongLong();
- case QMetaType::Float:
- return l.toFloat() < r.toFloat();
- case QVariant::Double:
- return l.toDouble() < r.toDouble();
- case QVariant::Char:
- return l.toChar() < r.toChar();
- case QVariant::Date:
- return l.toDate() < r.toDate();
- case QVariant::Time:
- return l.toTime() < r.toTime();
- case QVariant::DateTime:
- return l.toDateTime() < r.toDateTime();
- case QVariant::String:
- default:
- return l.toString().compare(r.toString()) < 0;
- }
+ return QAbstractItemModelPrivate::isVariantLessThan(l, r);
}
/*!
diff --git a/src/gui/itemmodels/qstandarditemmodel.h b/src/gui/itemmodels/qstandarditemmodel.h
index 476b936a25..a9cde106c1 100644
--- a/src/gui/itemmodels/qstandarditemmodel.h
+++ b/src/gui/itemmodels/qstandarditemmodel.h
@@ -40,6 +40,7 @@
#ifndef QSTANDARDITEMMODEL_H
#define QSTANDARDITEMMODEL_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qabstractitemmodel.h>
#include <QtGui/qbrush.h>
#include <QtGui/qfont.h>
diff --git a/src/gui/itemmodels/qstandarditemmodel_p.h b/src/gui/itemmodels/qstandarditemmodel_p.h
index 1849e1a850..fbba93b93a 100644
--- a/src/gui/itemmodels/qstandarditemmodel_p.h
+++ b/src/gui/itemmodels/qstandarditemmodel_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "private/qabstractitemmodel_p.h"
#ifndef QT_NO_STANDARDITEMMODEL
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
index 73a5a7b6ab..0e224df1ff 100644
--- a/src/gui/kernel/kernel.pri
+++ b/src/gui/kernel/kernel.pri
@@ -6,6 +6,8 @@ PRECOMPILED_HEADER = kernel/qt_gui_pch.h
KERNEL_P= kernel
HEADERS += \
+ kernel/qtguiglobal.h \
+ kernel/qtguiglobal_p.h \
kernel/qgenericpluginfactory.h \
kernel/qgenericplugin.h \
kernel/qwindowsysteminterface.h \
diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp
index bb3895c2f5..ec6c0bcc36 100644
--- a/src/gui/kernel/qclipboard.cpp
+++ b/src/gui/kernel/qclipboard.cpp
@@ -553,7 +553,7 @@ bool QClipboard::ownsFindBuffer() const
bool QClipboard::supportsMode(Mode mode) const
{
QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard();
- return clipboard->supportsMode(mode);
+ return clipboard && clipboard->supportsMode(mode);
}
/*!
@@ -565,7 +565,7 @@ bool QClipboard::supportsMode(Mode mode) const
bool QClipboard::ownsMode(Mode mode) const
{
QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard();
- return clipboard->ownsMode(mode);
+ return clipboard && clipboard->ownsMode(mode);
}
/*!
diff --git a/src/gui/kernel/qclipboard.h b/src/gui/kernel/qclipboard.h
index 2588288880..e91444d3dc 100644
--- a/src/gui/kernel/qclipboard.h
+++ b/src/gui/kernel/qclipboard.h
@@ -40,6 +40,7 @@
#ifndef QCLIPBOARD_H
#define QCLIPBOARD_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qobject.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qcursor.h b/src/gui/kernel/qcursor.h
index 814e8ab7bd..c7e9188e5b 100644
--- a/src/gui/kernel/qcursor.h
+++ b/src/gui/kernel/qcursor.h
@@ -40,6 +40,7 @@
#ifndef QCURSOR_H
#define QCURSOR_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qpoint.h>
#include <QtGui/qwindowdefs.h>
diff --git a/src/gui/kernel/qcursor_p.h b/src/gui/kernel/qcursor_p.h
index 8dcea7fdcc..37245a793f 100644
--- a/src/gui/kernel/qcursor_p.h
+++ b/src/gui/kernel/qcursor_p.h
@@ -51,8 +51,8 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtCore/qatomic.h"
-#include "QtCore/qglobal.h"
#include "QtCore/qnamespace.h"
#include "QtGui/qpixmap.h"
diff --git a/src/gui/kernel/qdnd_p.h b/src/gui/kernel/qdnd_p.h
index af7aaf771a..6f2ec46252 100644
--- a/src/gui/kernel/qdnd_p.h
+++ b/src/gui/kernel/qdnd_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtCore/qobject.h"
#include "QtCore/qmap.h"
#include "QtCore/qmimedata.h"
diff --git a/src/gui/kernel/qdrag.h b/src/gui/kernel/qdrag.h
index 6332899c39..a8288e1b53 100644
--- a/src/gui/kernel/qdrag.h
+++ b/src/gui/kernel/qdrag.h
@@ -40,6 +40,7 @@
#ifndef QDRAG_H
#define QDRAG_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qobject.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 19220b5492..63876479bd 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -289,7 +289,7 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton but
QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &screenPos,
Qt::MouseButton button, Qt::MouseButtons buttons,
Qt::KeyboardModifiers modifiers)
- : QInputEvent(type, modifiers), l(localPos), w(localPos), s(screenPos), b(button), mouseState(buttons), caps(0)
+ : QMouseEvent(type, localPos, localPos, screenPos, button, buttons, modifiers)
{}
/*!
@@ -342,7 +342,7 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &wind
QMouseEvent::QMouseEvent(QEvent::Type type, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos,
Qt::MouseButton button, Qt::MouseButtons buttons,
Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source)
- : QInputEvent(type, modifiers), l(localPos), w(windowPos), s(screenPos), b(button), mouseState(buttons), caps(0)
+ : QMouseEvent(type, localPos, windowPos, screenPos, button, buttons, modifiers)
{
QGuiApplicationPrivate::setMouseEventSource(this, source);
}
@@ -405,6 +405,18 @@ Qt::MouseEventFlags QMouseEvent::flags() const
*/
/*!
+ \fn void QMouseEvent::setLocalPos(const QPointF &localPosition)
+
+ \since 5.8
+
+ \internal
+
+ Sets the local position in the mouse event to \a localPosition. This allows to re-use one event
+ when sending it to a series of receivers that expect the local pos in their
+ respective local coordinates.
+*/
+
+/*!
\fn QPointF QMouseEvent::windowPos() const
\since 5.0
@@ -829,9 +841,8 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta
QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
- : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta),
- angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), ph(Qt::NoScrollPhase),
- src(Qt::MouseEventNotSynthesized), invertedScrolling(false)
+ : QWheelEvent(pos, globalPos, pixelDelta, angleDelta, qt4Delta, qt4Orientation,
+ buttons, modifiers, Qt::NoScrollPhase)
{}
/*!
@@ -860,9 +871,8 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase)
- : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta),
- angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), ph(phase),
- src(Qt::MouseEventNotSynthesized), invertedScrolling(false)
+ : QWheelEvent(pos, globalPos, pixelDelta, angleDelta, qt4Delta, qt4Orientation,
+ buttons, modifiers, phase, Qt::MouseEventNotSynthesized)
{}
/*!
@@ -896,9 +906,8 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase, Qt::MouseEventSource source)
- : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta),
- angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons), ph(phase), src(source),
- invertedScrolling(false)
+ : QWheelEvent(pos, globalPos, pixelDelta, angleDelta, qt4Delta, qt4Orientation,
+ buttons, modifiers, phase, source, false)
{}
/*!
@@ -1767,7 +1776,7 @@ QIconDragEvent::~QIconDragEvent()
coordinates.
*/
QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos)
- : QInputEvent(ContextMenu), p(pos), gp(globalPos), reas(reason)
+ : QContextMenuEvent(reason, pos, globalPos, Qt::NoModifier)
{}
/*!
@@ -2065,6 +2074,16 @@ QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos)
*/
/*!
+ \fn QInputMethodEvent::Attribute::Attribute(AttributeType type, int start, int length)
+ \overload
+ \since 5.7
+
+ Constructs an input method attribute with no value. \a type
+ specifies the type of attribute, and \a start and \a length
+ the position of the attribute.
+*/
+
+/*!
Constructs an event of type QEvent::InputMethod. The
attributes(), preeditString(), commitString(), replacementStart(),
and replacementLength() are initialized to default values.
@@ -2440,19 +2459,8 @@ QTabletEvent::QTabletEvent(Type type, const QPointF &pos, const QPointF &globalP
int device, int pointerType,
qreal pressure, int xTilt, int yTilt, qreal tangentialPressure,
qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID)
- : QInputEvent(type, keyState),
- mPos(pos),
- mGPos(globalPos),
- mDev(device),
- mPointerType(pointerType),
- mXT(xTilt),
- mYT(yTilt),
- mZ(z),
- mPress(pressure),
- mTangential(tangentialPressure),
- mRot(rotation),
- mUnique(uniqueID),
- mExtra(new QTabletEventPrivate(Qt::NoButton, Qt::NoButton))
+ : QTabletEvent(type, pos, globalPos, device, pointerType, pressure, xTilt, yTilt,
+ tangentialPressure, rotation, z, keyState, uniqueID, Qt::NoButton, Qt::NoButton)
{
}
@@ -4414,6 +4422,7 @@ QTouchEvent::~QTouchEvent()
The values of this enum describe additional information about a touch point.
\value Pen Indicates that the contact has been made by a designated pointing device (e.g. a pen) instead of a finger.
+ \value Token Indicates that the contact has been made by a fiducial object (e.g. a knob or other token) instead of a finger.
*/
/*!
@@ -4460,6 +4469,22 @@ int QTouchEvent::TouchPoint::id() const
}
/*!
+ \since 5.8
+ Returns the unique ID of this touch point or token, if any.
+
+ It is normally invalid (with a \l {QPointerUniqueId::numeric()} {numeric()} value of -1),
+ because touchscreens cannot uniquely identify fingers. But when the
+ \l {TouchPoint::InfoFlag} {Token} flag is set, it is expected to uniquely
+ identify a specific token (fiducial object).
+
+ \sa flags
+*/
+QPointerUniqueId QTouchEvent::TouchPoint::uniqueId() const
+{
+ return d->uniqueId;
+}
+
+/*!
Returns the current state of this touch point.
*/
Qt::TouchPointState QTouchEvent::TouchPoint::state() const
@@ -4663,6 +4688,19 @@ qreal QTouchEvent::TouchPoint::pressure() const
}
/*!
+ \since 5.8
+ Returns the angular orientation of this touch point. The return value is in degrees,
+ where zero (the default) indicates the finger or token is pointing upwards,
+ a negative angle means it's rotated to the left, and a positive angle means
+ it's rotated to the right. Most touchscreens do not detect rotation, so
+ zero is the most common value.
+*/
+qreal QTouchEvent::TouchPoint::rotation() const
+{
+ return d->rotation;
+}
+
+/*!
Returns a velocity vector for this touch point.
The vector is in the screen's coordinate system, using pixels per seconds for the magnitude.
@@ -4713,6 +4751,14 @@ void QTouchEvent::TouchPoint::setId(int id)
}
/*! \internal */
+void QTouchEvent::TouchPoint::setUniqueId(qint64 uid)
+{
+ if (d->ref.load() != 1)
+ d = d->detach();
+ d->uniqueId = QPointerUniqueId(uid);
+}
+
+/*! \internal */
void QTouchEvent::TouchPoint::setState(Qt::TouchPointStates state)
{
if (d->ref.load() != 1)
@@ -4849,6 +4895,14 @@ void QTouchEvent::TouchPoint::setPressure(qreal pressure)
}
/*! \internal */
+void QTouchEvent::TouchPoint::setRotation(qreal angle)
+{
+ if (d->ref.load() != 1)
+ d = d->detach();
+ d->rotation = angle;
+}
+
+/*! \internal */
void QTouchEvent::TouchPoint::setVelocity(const QVector2D &v)
{
if (d->ref.load() != 1)
@@ -5119,4 +5173,37 @@ Qt::ApplicationState QApplicationStateChangeEvent::applicationState() const
return m_applicationState;
}
+/*!
+ \class QPointerUniqueId
+ \since 5.8
+ \ingroup events
+ \inmodule QtGui
+
+ \brief QPointerUniqueId identifies a unique object, such as a tagged token
+ or stylus, which is used with a pointing device.
+
+ \sa QTouchEvent::TouchPoint
+*/
+
+/*!
+ Constructs a unique pointer ID with a numeric \a id provided by the hardware.
+ The default is -1, which means an invalid pointer ID.
+*/
+QPointerUniqueId::QPointerUniqueId(qint64 id)
+ : m_numericId(id)
+{
+}
+
+/*!
+ \property QPointerUniqueId::numeric
+ \brief the numeric unique ID of the token represented by a touchpoint
+
+ This is the numeric unique ID if the device provides that type of ID;
+ otherwise it is -1.
+*/
+qint64 QPointerUniqueId::numeric() const
+{
+ return m_numericId;
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index 570212966f..93374b2299 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -40,6 +40,7 @@
#ifndef QEVENT_H
#define QEVENT_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qwindowdefs.h>
#include <QtGui/qregion.h>
#include <QtCore/qnamespace.h>
@@ -131,6 +132,8 @@ public:
inline Qt::MouseButton button() const { return b; }
inline Qt::MouseButtons buttons() const { return mouseState; }
+ inline void setLocalPos(const QPointF &localPosition) { l = localPosition; }
+
#if QT_DEPRECATED_SINCE(5, 0)
QT_DEPRECATED inline QPointF posF() const { return l; }
#endif
@@ -535,8 +538,9 @@ public:
class Attribute {
public:
Attribute(AttributeType typ, int s, int l, QVariant val) : type(typ), start(s), length(l), value(qMove(val)) {}
- AttributeType type;
+ Attribute(AttributeType typ, int s, int l) : type(typ), start(s), length(l), value() {}
+ AttributeType type;
int start;
int length;
QVariant value;
@@ -789,6 +793,22 @@ inline bool operator==(QKeyEvent *e, QKeySequence::StandardKey key){return (e ?
inline bool operator==(QKeySequence::StandardKey key, QKeyEvent *e){return (e ? e->matches(key) : false);}
#endif // QT_NO_SHORTCUT
+class QPointerUniqueIdPrivate;
+class Q_GUI_EXPORT QPointerUniqueId
+{
+ Q_GADGET
+ Q_PROPERTY(qint64 numeric READ numeric CONSTANT)
+public:
+ explicit QPointerUniqueId(qint64 id = -1);
+
+ qint64 numeric() const;
+
+private:
+ // TODO for TUIO 2, or any other type of complex token ID, a d-pointer can replace
+ // m_numericId without changing the size of this class.
+ qint64 m_numericId;
+};
+
class QTouchEventTouchPointPrivate;
class Q_GUI_EXPORT QTouchEvent : public QInputEvent
{
@@ -797,7 +817,8 @@ public:
{
public:
enum InfoFlag {
- Pen = 0x0001
+ Pen = 0x0001,
+ Token = 0x0002
};
#ifndef Q_MOC_RUN
// otherwise moc gives
@@ -823,6 +844,7 @@ public:
{ qSwap(d, other.d); }
int id() const;
+ QPointerUniqueId uniqueId() const;
Qt::TouchPointState state() const;
@@ -847,12 +869,14 @@ public:
QRectF screenRect() const;
qreal pressure() const;
+ qreal rotation() const;
QVector2D velocity() const;
InfoFlags flags() const;
QVector<QPointF> rawScreenPositions() const;
// internal
void setId(int id);
+ void setUniqueId(qint64 uid);
void setState(Qt::TouchPointStates state);
void setPos(const QPointF &pos);
void setScenePos(const QPointF &scenePos);
@@ -870,6 +894,7 @@ public:
void setSceneRect(const QRectF &sceneRect);
void setScreenRect(const QRectF &screenRect);
void setPressure(qreal pressure);
+ void setRotation(qreal angle);
void setVelocity(const QVector2D &v);
void setFlags(InfoFlags flags);
void setRawScreenPositions(const QVector<QPointF> &positions);
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
index 726aa05d36..7e82b9c654 100644
--- a/src/gui/kernel/qevent_p.h
+++ b/src/gui/kernel/qevent_p.h
@@ -40,7 +40,7 @@
#ifndef QEVENT_P_H
#define QEVENT_P_H
-#include <QtCore/qglobal.h>
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtCore/qurl.h>
#include <QtGui/qevent.h>
@@ -65,7 +65,8 @@ public:
: ref(1),
id(id),
state(Qt::TouchPointReleased),
- pressure(qreal(-1.))
+ pressure(qreal(-1.)),
+ rotation(qreal(0.))
{ }
inline QTouchEventTouchPointPrivate *detach()
@@ -79,12 +80,14 @@ public:
QAtomicInt ref;
int id;
+ QPointerUniqueId uniqueId;
Qt::TouchPointStates state;
QRectF rect, sceneRect, screenRect;
QPointF normalizedPos,
startPos, startScenePos, startScreenPos, startNormalizedPos,
lastPos, lastScenePos, lastScreenPos, lastNormalizedPos;
qreal pressure;
+ qreal rotation;
QVector2D velocity;
QTouchEvent::TouchPoint::InfoFlags flags;
QVector<QPointF> rawScreenPositions;
diff --git a/src/gui/kernel/qgenericplugin.h b/src/gui/kernel/qgenericplugin.h
index 7f1a493861..e8aa2e6f32 100644
--- a/src/gui/kernel/qgenericplugin.h
+++ b/src/gui/kernel/qgenericplugin.h
@@ -40,6 +40,7 @@
#ifndef QGENERICPLUGIN_H
#define QGENERICPLUGIN_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
diff --git a/src/gui/kernel/qgenericpluginfactory.h b/src/gui/kernel/qgenericpluginfactory.h
index 282f3fed6d..9cc77a0590 100644
--- a/src/gui/kernel/qgenericpluginfactory.h
+++ b/src/gui/kernel/qgenericpluginfactory.h
@@ -40,6 +40,7 @@
#ifndef QGENERICPLUGINFACTORY_H
#define QGENERICPLUGINFACTORY_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qstringlist.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index f60cfd8af3..2ed7eb2cfb 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -104,13 +104,13 @@
#if defined(Q_OS_MAC)
# include "private/qcore_mac_p.h"
-#elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#elif defined(Q_OS_WIN)
# include <QtCore/qt_windows.h>
# include <QtCore/QLibraryInfo>
# if defined(Q_OS_WINPHONE)
# include <Objbase.h>
# endif
-#endif // Q_OS_WIN && !Q_OS_WINCE
+#endif // Q_OS_WIN
#include <ctype.h>
@@ -656,9 +656,20 @@ QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags
*/
void QGuiApplication::setApplicationDisplayName(const QString &name)
{
- if (!QGuiApplicationPrivate::displayName)
- QGuiApplicationPrivate::displayName = new QString;
- *QGuiApplicationPrivate::displayName = name;
+ if (!QGuiApplicationPrivate::displayName) {
+ QGuiApplicationPrivate::displayName = new QString(name);
+ if (qGuiApp) {
+ disconnect(qGuiApp, &QGuiApplication::applicationNameChanged,
+ qGuiApp, &QGuiApplication::applicationDisplayNameChanged);
+
+ if (QGuiApplicationPrivate::displayName != applicationName())
+ emit qGuiApp->applicationDisplayNameChanged();
+ }
+ } else if (name != *QGuiApplicationPrivate::displayName) {
+ *QGuiApplicationPrivate::displayName = name;
+ if (qGuiApp)
+ emit qGuiApp->applicationDisplayNameChanged();
+ }
}
QString QGuiApplication::applicationDisplayName()
@@ -1054,7 +1065,7 @@ QWindow *QGuiApplication::topLevelAt(const QPoint &pos)
\li \c eglfs is a platform plugin for running Qt5 applications on top of
EGL and OpenGL ES 2.0 without an actual windowing system (like X11
or Wayland). For more information, see \l{EGLFS}.
- \li \c ios
+ \li \c ios (also used for tvOS)
\li \c kms is an experimental platform plugin using kernel modesetting
and \l{http://dri.freedesktop.org/wiki/DRM}{DRM} (Direct Rendering
Manager).
@@ -1102,12 +1113,12 @@ static void init_platform(const QString &pluginArgument, const QString &platform
keys.join(QStringLiteral(", ")));
}
fatalMessage += QStringLiteral("Reinstalling the application may fix this problem.");
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
// Windows: Display message box unless it is a console application
// or debug build showing an assert box.
if (!QLibraryInfo::isDebugBuild() && !GetConsoleWindow())
MessageBox(0, (LPCTSTR)fatalMessage.utf16(), (LPCTSTR)(QCoreApplication::applicationName().utf16()), MB_OK | MB_ICONERROR);
-#endif // Q_OS_WIN && !Q_OS_WINCE && !Q_OS_WINRT
+#endif // Q_OS_WIN && !Q_OS_WINRT
qFatal("%s", qPrintable(fatalMessage));
return;
}
@@ -1186,7 +1197,7 @@ static void init_plugins(const QList<QByteArray> &pluginList)
if (plugin)
QGuiApplicationPrivate::generic_plugin_list.append(plugin);
else
- qWarning() << "No such plugin for spec " << pluginSpec;
+ qWarning("No such plugin for spec \"%s\"", pluginSpec.constData());
}
}
@@ -1310,7 +1321,7 @@ void QGuiApplicationPrivate::init()
#ifndef QT_NO_SESSIONMANAGER
QString session_id;
QString session_key;
-# if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+# if defined(Q_OS_WIN)
wchar_t guidstr[40];
GUID guid;
CoCreateGuid(&guid);
@@ -1424,9 +1435,8 @@ void QGuiApplicationPrivate::init()
init_plugins(pluginList);
QWindowSystemInterface::flushWindowSystemEvents();
-#ifndef QT_NO_SESSIONMANAGER
Q_Q(QGuiApplication);
-
+#ifndef QT_NO_SESSIONMANAGER
// connect to the session manager
session_manager = new QSessionManager(q, session_id, session_key);
#endif
@@ -1455,6 +1465,10 @@ void QGuiApplicationPrivate::init()
if (layout_direction == Qt::LayoutDirectionAuto || force_reverse)
QGuiApplication::setLayoutDirection(qt_detectRTLLanguage() ? Qt::RightToLeft : Qt::LeftToRight);
+
+ if (!QGuiApplicationPrivate::displayName)
+ QObject::connect(q, &QGuiApplication::applicationNameChanged,
+ q, &QGuiApplication::applicationDisplayNameChanged);
}
extern void qt_cleanupFontDatabase();
@@ -2450,6 +2464,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
QWindow *window = e->window.data();
typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints;
QHash<QWindow *, StatesAndTouchPoints> windowsNeedingEvents;
+ bool velocityOnly = false;
for (int i = 0; i < e->points.count(); ++i) {
QTouchEvent::TouchPoint touchPoint = e->points.at(i);
@@ -2526,8 +2541,14 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
// Stationary points might not be delivered down to the receiving item
// and get their position transformed, keep the old values instead.
- if (touchPoint.state() != Qt::TouchPointStationary)
+ if (touchPoint.state() == Qt::TouchPointStationary) {
+ if (touchInfo.touchPoint.velocity() != touchPoint.velocity()) {
+ touchInfo.touchPoint.setVelocity(touchPoint.velocity());
+ velocityOnly = true;
+ }
+ } else {
touchInfo.touchPoint = touchPoint;
+ }
break;
}
@@ -2561,7 +2582,10 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
break;
case Qt::TouchPointStationary:
// don't send the event if nothing changed
- continue;
+ if (velocityOnly)
+ eventType = QEvent::TouchUpdate;
+ else
+ continue;
default:
eventType = QEvent::TouchUpdate;
break;
diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h
index 10057c5b7f..6721970222 100644
--- a/src/gui/kernel/qguiapplication.h
+++ b/src/gui/kernel/qguiapplication.h
@@ -40,6 +40,7 @@
#ifndef QGUIAPPLICATION_H
#define QGUIAPPLICATION_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qcoreapplication.h>
#include <QtGui/qwindowdefs.h>
#include <QtGui/qinputmethod.h>
@@ -72,7 +73,7 @@ class Q_GUI_EXPORT QGuiApplication : public QCoreApplication
{
Q_OBJECT
Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon)
- Q_PROPERTY(QString applicationDisplayName READ applicationDisplayName WRITE setApplicationDisplayName)
+ Q_PROPERTY(QString applicationDisplayName READ applicationDisplayName WRITE setApplicationDisplayName NOTIFY applicationDisplayNameChanged)
Q_PROPERTY(QString desktopFileName READ desktopFileName WRITE setDesktopFileName)
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged)
Q_PROPERTY(QString platformName READ platformName STORED false)
@@ -183,6 +184,7 @@ Q_SIGNALS:
void saveStateRequest(QSessionManager &sessionManager);
#endif
void paletteChanged(const QPalette &pal);
+ void applicationDisplayNameChanged();
protected:
bool event(QEvent *) Q_DECL_OVERRIDE;
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index a028441a2f..e1a35e048c 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtGui/qguiapplication.h>
#include <QtCore/QPointF>
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp
index d5bc51a7e3..76663cdc01 100644
--- a/src/gui/kernel/qhighdpiscaling.cpp
+++ b/src/gui/kernel/qhighdpiscaling.cpp
@@ -68,10 +68,11 @@ static inline qreal initialGlobalScaleFactor()
}
} else {
if (qEnvironmentVariableIsSet(legacyDevicePixelEnvVar)) {
- qWarning() << "Warning:" << legacyDevicePixelEnvVar << "is deprecated. Instead use:" << endl
- << " " << autoScreenEnvVar << "to enable platform plugin controlled per-screen factors." << endl
- << " " << screenFactorsEnvVar << "to set per-screen factors." << endl
- << " " << scaleFactorEnvVar << "to set the application global scale factor.";
+ qWarning("Warning: %s is deprecated. Instead use:\n"
+ " %s to enable platform plugin controlled per-screen factors.\n"
+ " %s to set per-screen factors.\n"
+ " %s to set the application global scale factor.",
+ legacyDevicePixelEnvVar, autoScreenEnvVar, screenFactorsEnvVar, scaleFactorEnvVar);
int dpr = qEnvironmentVariableIntValue(legacyDevicePixelEnvVar);
if (dpr > 0)
diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h
index eb3a9d5545..32c8f07dc0 100644
--- a/src/gui/kernel/qhighdpiscaling_p.h
+++ b/src/gui/kernel/qhighdpiscaling_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtCore/qmargins.h>
#include <QtCore/qmath.h>
#include <QtCore/qrect.h>
@@ -382,8 +382,7 @@ inline QRegion fromNativeLocalRegion(const QRegion &pixelRegion, const QWindow *
qreal scaleFactor = QHighDpiScaling::factor(window);
QRegion pointRegion;
- const auto rects = pixelRegion.rects();
- for (const QRect &rect : rects) {
+ for (const QRect &rect : pixelRegion) {
pointRegion += QRect(fromNative(rect.topLeft(), scaleFactor),
fromNative(rect.size(), scaleFactor));
}
@@ -399,7 +398,7 @@ inline QRegion fromNativeLocalExposedRegion(const QRegion &pixelRegion, const QW
const qreal scaleFactor = QHighDpiScaling::factor(window);
QRegion pointRegion;
- foreach (const QRect &rect, pixelRegion.rects()) {
+ for (const QRect &rect : pixelRegion) {
const QPointF topLeftP = QPointF(rect.topLeft()) / scaleFactor;
const QPointF bottomRightP = QPointF(rect.bottomRight()) / scaleFactor;
pointRegion += QRect(QPoint(qFloor(topLeftP.x()), qFloor(topLeftP.y())),
@@ -415,8 +414,7 @@ inline QRegion toNativeLocalRegion(const QRegion &pointRegion, const QWindow *wi
qreal scaleFactor = QHighDpiScaling::factor(window);
QRegion pixelRegon;
- const auto rects = pointRegion.rects();
- for (const QRect &rect : rects) {
+ for (const QRect &rect : pointRegion) {
pixelRegon += QRect(toNative(rect.topLeft(), scaleFactor),
toNative(rect.size(), scaleFactor));
}
diff --git a/src/gui/kernel/qinputdevicemanager_p.h b/src/gui/kernel/qinputdevicemanager_p.h
index 1cf0443834..11bbaae592 100644
--- a/src/gui/kernel/qinputdevicemanager_p.h
+++ b/src/gui/kernel/qinputdevicemanager_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtCore/qobject.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qinputdevicemanager_p_p.h b/src/gui/kernel/qinputdevicemanager_p_p.h
index 45d8b64172..ae91f3a2ab 100644
--- a/src/gui/kernel/qinputdevicemanager_p_p.h
+++ b/src/gui/kernel/qinputdevicemanager_p_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtCore/qmap.h>
#include <private/qobject_p.h>
#include "qinputdevicemanager_p.h"
diff --git a/src/gui/kernel/qinputmethod.h b/src/gui/kernel/qinputmethod.h
index 1a63d1314e..efdefb6e5a 100644
--- a/src/gui/kernel/qinputmethod.h
+++ b/src/gui/kernel/qinputmethod.h
@@ -40,6 +40,7 @@
#ifndef QINPUTMETHOD_H
#define QINPUTMETHOD_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qobject.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qinputmethod_p.h b/src/gui/kernel/qinputmethod_p.h
index 3f7cd195ea..81723bbe30 100644
--- a/src/gui/kernel/qinputmethod_p.h
+++ b/src/gui/kernel/qinputmethod_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <qinputmethod.h>
#include <private/qobject_p.h>
#include <QtCore/QWeakPointer>
diff --git a/src/gui/kernel/qkeymapper_p.h b/src/gui/kernel/qkeymapper_p.h
index 59977688e4..aeec7b7414 100644
--- a/src/gui/kernel/qkeymapper_p.h
+++ b/src/gui/kernel/qkeymapper_p.h
@@ -50,6 +50,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <qobject.h>
#include <private/qobject_p.h>
#include <qkeysequence.h>
diff --git a/src/gui/kernel/qkeysequence.h b/src/gui/kernel/qkeysequence.h
index 3a660b063e..6bdfd84ca3 100644
--- a/src/gui/kernel/qkeysequence.h
+++ b/src/gui/kernel/qkeysequence.h
@@ -40,7 +40,7 @@
#ifndef QKEYSEQUENCE_H
#define QKEYSEQUENCE_H
-#include <QtCore/qnamespace.h>
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qstring.h>
#include <QtCore/qobjectdefs.h>
diff --git a/src/gui/kernel/qkeysequence_p.h b/src/gui/kernel/qkeysequence_p.h
index 116e91c0cd..8ba86c31b8 100644
--- a/src/gui/kernel/qkeysequence_p.h
+++ b/src/gui/kernel/qkeysequence_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "qkeysequence.h"
#include <algorithm>
diff --git a/src/gui/kernel/qoffscreensurface.h b/src/gui/kernel/qoffscreensurface.h
index d639407e1a..bacc9c851a 100644
--- a/src/gui/kernel/qoffscreensurface.h
+++ b/src/gui/kernel/qoffscreensurface.h
@@ -40,6 +40,7 @@
#ifndef QOFFSCREENSURFACE_H
#define QOFFSCREENSURFACE_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/QObject>
#include <QtGui/qsurface.h>
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index 0f7bbfd2e1..7e5697e5d8 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -940,13 +940,20 @@ GLuint QOpenGLContext::defaultFramebufferObject() const
If \a surface is 0 this is equivalent to calling doneCurrent().
- Do not call this function from a different thread than the one the
+ Avoid calling this function from a different thread than the one the
QOpenGLContext instance lives in. If you wish to use QOpenGLContext from a
different thread you should first call make sure it's not current in the
current thread, by calling doneCurrent() if necessary. Then call
moveToThread(otherThread) before using it in the other thread.
- \sa functions(), doneCurrent()
+ By default Qt employs a check that enforces the above condition on the
+ thread affinity. It is still possible to disable this check by setting the
+ \c{Qt::AA_DontCheckOpenGLContextThreadAffinity} application attribute. Be
+ sure to understand the consequences of using QObjects from outside
+ the thread they live in, as explained in the
+ \l{QObject#Thread Affinity}{QObject thread affinity} documentation.
+
+ \sa functions(), doneCurrent(), Qt::AA_DontCheckOpenGLContextThreadAffinity
*/
bool QOpenGLContext::makeCurrent(QSurface *surface)
{
@@ -954,8 +961,10 @@ bool QOpenGLContext::makeCurrent(QSurface *surface)
if (!isValid())
return false;
- if (Q_UNLIKELY(thread() != QThread::currentThread()))
+ if (Q_UNLIKELY(!qApp->testAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity)
+ && thread() != QThread::currentThread())) {
qFatal("Cannot make QOpenGLContext current in a different thread");
+ }
if (!surface) {
doneCurrent();
diff --git a/src/gui/kernel/qopenglcontext.h b/src/gui/kernel/qopenglcontext.h
index 33e3f1c3f6..3ec9ce3188 100644
--- a/src/gui/kernel/qopenglcontext.h
+++ b/src/gui/kernel/qopenglcontext.h
@@ -40,7 +40,7 @@
#ifndef QOPENGLCONTEXT_H
#define QOPENGLCONTEXT_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#ifndef QT_NO_OPENGL
diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h
index 2fe8446c65..57f70356b8 100644
--- a/src/gui/kernel/qopenglcontext_p.h
+++ b/src/gui/kernel/qopenglcontext_p.h
@@ -51,6 +51,8 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
+
#ifndef QT_NO_OPENGL
#include "qopengl.h"
diff --git a/src/gui/kernel/qopenglwindow.cpp b/src/gui/kernel/qopenglwindow.cpp
index 8ab5c08442..e1bd3d11b2 100644
--- a/src/gui/kernel/qopenglwindow.cpp
+++ b/src/gui/kernel/qopenglwindow.cpp
@@ -42,7 +42,7 @@
#include <QtGui/QOpenGLFramebufferObject>
#include <QtGui/QOpenGLPaintDevice>
#include <QtGui/QOpenGLFunctions>
-#include <QtGui/private/qopengltextureblitter_p.h>
+#include <QtGui/QOpenGLTextureBlitter>
#include <QtGui/private/qopenglextensions_p.h>
#include <QtGui/private/qopenglcontext_p.h>
#include <QtGui/QMatrix4x4>
diff --git a/src/gui/kernel/qopenglwindow.h b/src/gui/kernel/qopenglwindow.h
index 6e2a8ab904..fe236f9538 100644
--- a/src/gui/kernel/qopenglwindow.h
+++ b/src/gui/kernel/qopenglwindow.h
@@ -40,7 +40,7 @@
#ifndef QOPENGLWINDOW_H
#define QOPENGLWINDOW_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#ifndef QT_NO_OPENGL
diff --git a/src/gui/kernel/qpaintdevicewindow.h b/src/gui/kernel/qpaintdevicewindow.h
index 1b66ed7c41..81b41dcdd5 100644
--- a/src/gui/kernel/qpaintdevicewindow.h
+++ b/src/gui/kernel/qpaintdevicewindow.h
@@ -40,6 +40,7 @@
#ifndef QPAINTDEVICEWINDOW_H
#define QPAINTDEVICEWINDOW_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/QWindow>
#include <QtGui/QPaintDevice>
diff --git a/src/gui/kernel/qpaintdevicewindow_p.h b/src/gui/kernel/qpaintdevicewindow_p.h
index 39cd1b3615..a16b83689e 100644
--- a/src/gui/kernel/qpaintdevicewindow_p.h
+++ b/src/gui/kernel/qpaintdevicewindow_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtGui/QPaintDeviceWindow>
#include <QtCore/QCoreApplication>
#include <QtGui/private/qwindow_p.h>
diff --git a/src/gui/kernel/qpalette.h b/src/gui/kernel/qpalette.h
index c130a1844b..d04fb1f0c5 100644
--- a/src/gui/kernel/qpalette.h
+++ b/src/gui/kernel/qpalette.h
@@ -40,6 +40,7 @@
#ifndef QPALETTE_H
#define QPALETTE_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qwindowdefs.h>
#include <QtGui/qcolor.h>
#include <QtGui/qbrush.h>
diff --git a/src/gui/kernel/qpixelformat.h b/src/gui/kernel/qpixelformat.h
index a78a3b5ad3..6b2d6a6ac7 100644
--- a/src/gui/kernel/qpixelformat.h
+++ b/src/gui/kernel/qpixelformat.h
@@ -40,7 +40,7 @@
#ifndef QPIXELFORMAT_H
#define QPIXELFORMAT_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qplatformclipboard.h b/src/gui/kernel/qplatformclipboard.h
index c30e085d00..60733b0a9f 100644
--- a/src/gui/kernel/qplatformclipboard.h
+++ b/src/gui/kernel/qplatformclipboard.h
@@ -49,7 +49,7 @@
// source and binary incompatible with future versions of Qt.
//
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#ifndef QT_NO_CLIPBOARD
diff --git a/src/gui/kernel/qplatformcursor.h b/src/gui/kernel/qplatformcursor.h
index 52c93c87e3..f9c1607663 100644
--- a/src/gui/kernel/qplatformcursor.h
+++ b/src/gui/kernel/qplatformcursor.h
@@ -48,6 +48,7 @@
// source and binary incompatible with future versions of Qt.
//
+#include <QtGui/qtguiglobal.h>
#include <QtCore/QList>
#include <QtGui/QImage>
#include <QtGui/QMouseEvent>
diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp
index fe4d167078..c36186b815 100644
--- a/src/gui/kernel/qplatformdialoghelper.cpp
+++ b/src/gui/kernel/qplatformdialoghelper.cpp
@@ -156,23 +156,33 @@ public:
QString windowTitle;
};
-QFontDialogOptions::QFontDialogOptions() : d(new QFontDialogOptionsPrivate)
+QFontDialogOptions::QFontDialogOptions(QFontDialogOptionsPrivate *dd)
+ : d(dd)
{
}
-QFontDialogOptions::QFontDialogOptions(const QFontDialogOptions &rhs) : d(rhs.d)
+QFontDialogOptions::~QFontDialogOptions()
{
}
-QFontDialogOptions &QFontDialogOptions::operator=(const QFontDialogOptions &rhs)
+namespace {
+ struct FontDialogCombined : QFontDialogOptionsPrivate, QFontDialogOptions
+ {
+ FontDialogCombined() : QFontDialogOptionsPrivate(), QFontDialogOptions(this) {}
+ FontDialogCombined(const FontDialogCombined &other)
+ : QFontDialogOptionsPrivate(other), QFontDialogOptions(this) {}
+ };
+}
+
+// static
+QSharedPointer<QFontDialogOptions> QFontDialogOptions::create()
{
- if (this != &rhs)
- d = rhs.d;
- return *this;
+ return QSharedPointer<FontDialogCombined>::create();
}
-QFontDialogOptions::~QFontDialogOptions()
+QSharedPointer<QFontDialogOptions> QFontDialogOptions::clone() const
{
+ return QSharedPointer<FontDialogCombined>::create(*static_cast<const FontDialogCombined*>(this));
}
QString QFontDialogOptions::windowTitle() const
@@ -289,23 +299,33 @@ public:
QString windowTitle;
};
-QColorDialogOptions::QColorDialogOptions() : d(new QColorDialogOptionsPrivate)
+QColorDialogOptions::QColorDialogOptions(QColorDialogOptionsPrivate *dd)
+ : d(dd)
{
}
-QColorDialogOptions::QColorDialogOptions(const QColorDialogOptions &rhs) : d(rhs.d)
+QColorDialogOptions::~QColorDialogOptions()
{
}
-QColorDialogOptions &QColorDialogOptions::operator=(const QColorDialogOptions &rhs)
+namespace {
+ struct ColorDialogCombined : QColorDialogOptionsPrivate, QColorDialogOptions
+ {
+ ColorDialogCombined() : QColorDialogOptionsPrivate(), QColorDialogOptions(this) {}
+ ColorDialogCombined(const ColorDialogCombined &other)
+ : QColorDialogOptionsPrivate(other), QColorDialogOptions(this) {}
+ };
+}
+
+// static
+QSharedPointer<QColorDialogOptions> QColorDialogOptions::create()
{
- if (this != &rhs)
- d = rhs.d;
- return *this;
+ return QSharedPointer<ColorDialogCombined>::create();
}
-QColorDialogOptions::~QColorDialogOptions()
+QSharedPointer<QColorDialogOptions> QColorDialogOptions::clone() const
{
+ return QSharedPointer<ColorDialogCombined>::create(*static_cast<const ColorDialogCombined*>(this));
}
QString QColorDialogOptions::windowTitle() const
@@ -436,23 +456,32 @@ public:
QStringList supportedSchemes;
};
-QFileDialogOptions::QFileDialogOptions() : d(new QFileDialogOptionsPrivate)
+QFileDialogOptions::QFileDialogOptions(QFileDialogOptionsPrivate *dd)
+ : d(dd)
{
}
-QFileDialogOptions::QFileDialogOptions(const QFileDialogOptions &rhs) : d(rhs.d)
+QFileDialogOptions::~QFileDialogOptions()
{
}
-QFileDialogOptions &QFileDialogOptions::operator=(const QFileDialogOptions &rhs)
+namespace {
+ struct FileDialogCombined : QFileDialogOptionsPrivate, QFileDialogOptions
+ {
+ FileDialogCombined() : QFileDialogOptionsPrivate(), QFileDialogOptions(this) {}
+ FileDialogCombined(const FileDialogCombined &other) : QFileDialogOptionsPrivate(other), QFileDialogOptions(this) {}
+ };
+}
+
+// static
+QSharedPointer<QFileDialogOptions> QFileDialogOptions::create()
{
- if (this != &rhs)
- d = rhs.d;
- return *this;
+ return QSharedPointer<FileDialogCombined>::create();
}
-QFileDialogOptions::~QFileDialogOptions()
+QSharedPointer<QFileDialogOptions> QFileDialogOptions::clone() const
{
+ return QSharedPointer<FileDialogCombined>::create(*static_cast<const FileDialogCombined*>(this));
}
QString QFileDialogOptions::windowTitle() const
@@ -728,23 +757,33 @@ public:
QPlatformDialogHelper::StandardButtons buttons;
};
-QMessageDialogOptions::QMessageDialogOptions() : d(new QMessageDialogOptionsPrivate)
+QMessageDialogOptions::QMessageDialogOptions(QMessageDialogOptionsPrivate *dd)
+ : d(dd)
{
}
-QMessageDialogOptions::QMessageDialogOptions(const QMessageDialogOptions &rhs) : d(rhs.d)
+QMessageDialogOptions::~QMessageDialogOptions()
{
}
-QMessageDialogOptions &QMessageDialogOptions::operator=(const QMessageDialogOptions &rhs)
+namespace {
+ struct MessageDialogCombined : QMessageDialogOptionsPrivate, QMessageDialogOptions
+ {
+ MessageDialogCombined() : QMessageDialogOptionsPrivate(), QMessageDialogOptions(this) {}
+ MessageDialogCombined(const MessageDialogCombined &other)
+ : QMessageDialogOptionsPrivate(other), QMessageDialogOptions(this) {}
+ };
+}
+
+// static
+QSharedPointer<QMessageDialogOptions> QMessageDialogOptions::create()
{
- if (this != &rhs)
- d = rhs.d;
- return *this;
+ return QSharedPointer<MessageDialogCombined>::create();
}
-QMessageDialogOptions::~QMessageDialogOptions()
+QSharedPointer<QMessageDialogOptions> QMessageDialogOptions::clone() const
{
+ return QSharedPointer<MessageDialogCombined>::create(*static_cast<const MessageDialogCombined*>(this));
}
QString QMessageDialogOptions::windowTitle() const
diff --git a/src/gui/kernel/qplatformdialoghelper.h b/src/gui/kernel/qplatformdialoghelper.h
index 825dcf293d..6caef070e2 100644
--- a/src/gui/kernel/qplatformdialoghelper.h
+++ b/src/gui/kernel/qplatformdialoghelper.h
@@ -49,6 +49,7 @@
// source and binary incompatible with future versions of Qt.
//
+#include <QtGui/qtguiglobal.h>
#include <QtCore/QtGlobal>
#include <QtCore/QObject>
#include <QtCore/QList>
@@ -72,6 +73,8 @@ class QFontDialogOptionsPrivate;
class QFileDialogOptionsPrivate;
class QMessageDialogOptionsPrivate;
+#define QPLATFORMDIALOGHELPERS_HAS_CREATE
+
class Q_GUI_EXPORT QPlatformDialogHelper : public QObject
{
Q_OBJECT
@@ -176,6 +179,10 @@ QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QColorDialogOptions
{
Q_GADGET
+ Q_DISABLE_COPY(QColorDialogOptions)
+protected:
+ explicit QColorDialogOptions(QColorDialogOptionsPrivate *dd);
+ ~QColorDialogOptions();
public:
enum ColorDialogOption {
ShowAlphaChannel = 0x00000001,
@@ -186,12 +193,8 @@ public:
Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)
Q_FLAG(ColorDialogOptions)
- QColorDialogOptions();
- QColorDialogOptions(const QColorDialogOptions &rhs);
- QColorDialogOptions &operator=(const QColorDialogOptions &rhs);
- ~QColorDialogOptions();
-
- void swap(QColorDialogOptions &other) { qSwap(d, other.d); }
+ static QSharedPointer<QColorDialogOptions> create();
+ QSharedPointer<QColorDialogOptions> clone() const;
QString windowTitle() const;
void setWindowTitle(const QString &);
@@ -211,11 +214,9 @@ public:
static void setStandardColor(int index, QRgb color);
private:
- QSharedDataPointer<QColorDialogOptionsPrivate> d;
+ QColorDialogOptionsPrivate *d;
};
-Q_DECLARE_SHARED(QColorDialogOptions)
-
class Q_GUI_EXPORT QPlatformColorDialogHelper : public QPlatformDialogHelper
{
Q_OBJECT
@@ -237,6 +238,11 @@ private:
class Q_GUI_EXPORT QFontDialogOptions
{
Q_GADGET
+ Q_DISABLE_COPY(QFontDialogOptions)
+protected:
+ explicit QFontDialogOptions(QFontDialogOptionsPrivate *dd);
+ ~QFontDialogOptions();
+
public:
enum FontDialogOption {
NoButtons = 0x00000001,
@@ -250,12 +256,8 @@ public:
Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)
Q_FLAG(FontDialogOptions)
- QFontDialogOptions();
- QFontDialogOptions(const QFontDialogOptions &rhs);
- QFontDialogOptions &operator=(const QFontDialogOptions &rhs);
- ~QFontDialogOptions();
-
- void swap(QFontDialogOptions &other) { qSwap(d, other.d); }
+ static QSharedPointer<QFontDialogOptions> create();
+ QSharedPointer<QFontDialogOptions> clone() const;
QString windowTitle() const;
void setWindowTitle(const QString &);
@@ -266,11 +268,9 @@ public:
FontDialogOptions options() const;
private:
- QSharedDataPointer<QFontDialogOptionsPrivate> d;
+ QFontDialogOptionsPrivate *d;
};
-Q_DECLARE_SHARED(QFontDialogOptions)
-
class Q_GUI_EXPORT QPlatformFontDialogHelper : public QPlatformDialogHelper
{
Q_OBJECT
@@ -292,6 +292,11 @@ private:
class Q_GUI_EXPORT QFileDialogOptions
{
Q_GADGET
+ Q_DISABLE_COPY(QFileDialogOptions)
+protected:
+ QFileDialogOptions(QFileDialogOptionsPrivate *dd);
+ ~QFileDialogOptions();
+
public:
enum ViewMode { Detail, List };
Q_ENUM(ViewMode)
@@ -319,12 +324,8 @@ public:
Q_DECLARE_FLAGS(FileDialogOptions, FileDialogOption)
Q_FLAG(FileDialogOptions)
- QFileDialogOptions();
- QFileDialogOptions(const QFileDialogOptions &rhs);
- QFileDialogOptions &operator=(const QFileDialogOptions &rhs);
- ~QFileDialogOptions();
-
- void swap(QFileDialogOptions &other) { qSwap(d, other.d); }
+ static QSharedPointer<QFileDialogOptions> create();
+ QSharedPointer<QFileDialogOptions> clone() const;
QString windowTitle() const;
void setWindowTitle(const QString &);
@@ -383,11 +384,9 @@ public:
static QString defaultNameFilterString();
private:
- QSharedDataPointer<QFileDialogOptionsPrivate> d;
+ QFileDialogOptionsPrivate *d;
};
-Q_DECLARE_SHARED(QFileDialogOptions)
-
class Q_GUI_EXPORT QPlatformFileDialogHelper : public QPlatformDialogHelper
{
Q_OBJECT
@@ -423,17 +422,18 @@ private:
class Q_GUI_EXPORT QMessageDialogOptions
{
Q_GADGET
+ Q_DISABLE_COPY(QMessageDialogOptions)
+protected:
+ QMessageDialogOptions(QMessageDialogOptionsPrivate *dd);
+ ~QMessageDialogOptions();
+
public:
// Keep in sync with QMessageBox::Icon
enum Icon { NoIcon, Information, Warning, Critical, Question };
Q_ENUM(Icon)
- QMessageDialogOptions();
- QMessageDialogOptions(const QMessageDialogOptions &rhs);
- QMessageDialogOptions &operator=(const QMessageDialogOptions &rhs);
- ~QMessageDialogOptions();
-
- void swap(QMessageDialogOptions &other) { qSwap(d, other.d); }
+ static QSharedPointer<QMessageDialogOptions> create();
+ QSharedPointer<QMessageDialogOptions> clone() const;
QString windowTitle() const;
void setWindowTitle(const QString &);
@@ -454,11 +454,9 @@ public:
QPlatformDialogHelper::StandardButtons standardButtons() const;
private:
- QSharedDataPointer<QMessageDialogOptionsPrivate> d;
+ QMessageDialogOptionsPrivate *d;
};
-Q_DECLARE_SHARED(QMessageDialogOptions)
-
class Q_GUI_EXPORT QPlatformMessageDialogHelper : public QPlatformDialogHelper
{
Q_OBJECT
diff --git a/src/gui/kernel/qplatformdrag.h b/src/gui/kernel/qplatformdrag.h
index a9744a17ac..560f984a5b 100644
--- a/src/gui/kernel/qplatformdrag.h
+++ b/src/gui/kernel/qplatformdrag.h
@@ -49,7 +49,7 @@
// source and binary incompatible with future versions of Qt.
//
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#include <QtGui/QPixmap>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qplatformgraphicsbuffer.h b/src/gui/kernel/qplatformgraphicsbuffer.h
index 53fc551ad2..0aeef946e6 100644
--- a/src/gui/kernel/qplatformgraphicsbuffer.h
+++ b/src/gui/kernel/qplatformgraphicsbuffer.h
@@ -50,6 +50,7 @@
//
+#include <QtGui/qtguiglobal.h>
#include <QtCore/QSize>
#include <QtCore/QRect>
#include <QtGui/QPixelFormat>
diff --git a/src/gui/kernel/qplatformgraphicsbufferhelper.h b/src/gui/kernel/qplatformgraphicsbufferhelper.h
index 59fcd12fd0..5b7daff65a 100644
--- a/src/gui/kernel/qplatformgraphicsbufferhelper.h
+++ b/src/gui/kernel/qplatformgraphicsbufferhelper.h
@@ -40,6 +40,7 @@
#ifndef QPLATFORMGRAPHICSBUFFERHELPER_H
#define QPLATFORMGRAPHICSBUFFERHELPER_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qpa/qplatformgraphicsbuffer.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qplatforminputcontext.h b/src/gui/kernel/qplatforminputcontext.h
index 7afa6b82f2..26d40cd2c6 100644
--- a/src/gui/kernel/qplatforminputcontext.h
+++ b/src/gui/kernel/qplatforminputcontext.h
@@ -49,6 +49,7 @@
// source and binary incompatible with future versions of Qt.
//
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qinputmethod.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qplatforminputcontext_p.h b/src/gui/kernel/qplatforminputcontext_p.h
index 14e9dda072..c4f4b97d03 100644
--- a/src/gui/kernel/qplatforminputcontext_p.h
+++ b/src/gui/kernel/qplatforminputcontext_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <private/qobject_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qplatforminputcontextfactory_p.h b/src/gui/kernel/qplatforminputcontextfactory_p.h
index 4106b2fedc..881421ce49 100644
--- a/src/gui/kernel/qplatforminputcontextfactory_p.h
+++ b/src/gui/kernel/qplatforminputcontextfactory_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtCore/qstringlist.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qplatforminputcontextplugin_p.h b/src/gui/kernel/qplatforminputcontextplugin_p.h
index 1bb0332ac7..3f45df922e 100644
--- a/src/gui/kernel/qplatforminputcontextplugin_p.h
+++ b/src/gui/kernel/qplatforminputcontextplugin_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp
index 3490e786a8..5bf0df67db 100644
--- a/src/gui/kernel/qplatformintegration.cpp
+++ b/src/gui/kernel/qplatformintegration.cpp
@@ -402,6 +402,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const
return true;
case ItemViewActivateItemOnSingleClick:
return QPlatformTheme::defaultThemeHint(QPlatformTheme::ItemViewActivateItemOnSingleClick);
+ case UiEffects:
+ return QPlatformTheme::defaultThemeHint(QPlatformTheme::UiEffects);
}
return 0;
diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h
index 6ac98c20ce..22a834f0e1 100644
--- a/src/gui/kernel/qplatformintegration.h
+++ b/src/gui/kernel/qplatformintegration.h
@@ -49,6 +49,7 @@
// source and binary incompatible with future versions of Qt.
//
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qwindowdefs.h>
#include <qpa/qplatformscreen.h>
#include <QtGui/qsurfaceformat.h>
@@ -155,7 +156,8 @@ public:
MousePressAndHoldInterval,
TabFocusBehavior,
ReplayMousePressOutsidePopup,
- ItemViewActivateItemOnSingleClick
+ ItemViewActivateItemOnSingleClick,
+ UiEffects
};
virtual QVariant styleHint(StyleHint hint) const;
diff --git a/src/gui/kernel/qplatformintegrationfactory_p.h b/src/gui/kernel/qplatformintegrationfactory_p.h
index ea8c846557..22c77ce8bd 100644
--- a/src/gui/kernel/qplatformintegrationfactory_p.h
+++ b/src/gui/kernel/qplatformintegrationfactory_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtCore/qstringlist.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qplatformintegrationplugin.h b/src/gui/kernel/qplatformintegrationplugin.h
index 7d2a9b2a5f..f1136965b7 100644
--- a/src/gui/kernel/qplatformintegrationplugin.h
+++ b/src/gui/kernel/qplatformintegrationplugin.h
@@ -49,6 +49,7 @@
// source and binary incompatible with future versions of Qt.
//
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
diff --git a/src/gui/kernel/qplatformmenu.h b/src/gui/kernel/qplatformmenu.h
index bd4f4d9beb..6eaabd3e08 100644
--- a/src/gui/kernel/qplatformmenu.h
+++ b/src/gui/kernel/qplatformmenu.h
@@ -49,7 +49,7 @@
// source and binary incompatible with future versions of Qt.
//
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qpointer.h>
#include <QtGui/QFont>
#include <QtGui/QKeySequence>
diff --git a/src/gui/kernel/qplatformnativeinterface.h b/src/gui/kernel/qplatformnativeinterface.h
index f830221c70..95d6a03dbb 100644
--- a/src/gui/kernel/qplatformnativeinterface.h
+++ b/src/gui/kernel/qplatformnativeinterface.h
@@ -49,6 +49,7 @@
// source and binary incompatible with future versions of Qt.
//
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qwindowdefs.h>
#include <QtCore/QObject>
#include <QtCore/QVariant>
diff --git a/src/gui/kernel/qplatformoffscreensurface.h b/src/gui/kernel/qplatformoffscreensurface.h
index 77a8f63316..7f2e0d475b 100644
--- a/src/gui/kernel/qplatformoffscreensurface.h
+++ b/src/gui/kernel/qplatformoffscreensurface.h
@@ -49,6 +49,7 @@
// source and binary incompatible with future versions of Qt.
//
+#include <QtGui/qtguiglobal.h>
#include "qplatformsurface.h"
#include <QtCore/qscopedpointer.h>
diff --git a/src/gui/kernel/qplatformopenglcontext.h b/src/gui/kernel/qplatformopenglcontext.h
index 1a38a5fed3..f307cc14f9 100644
--- a/src/gui/kernel/qplatformopenglcontext.h
+++ b/src/gui/kernel/qplatformopenglcontext.h
@@ -49,6 +49,7 @@
// source and binary incompatible with future versions of Qt.
//
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qnamespace.h>
#ifndef QT_NO_OPENGL
diff --git a/src/gui/kernel/qplatformscreen.h b/src/gui/kernel/qplatformscreen.h
index cd300c34c8..030edea880 100644
--- a/src/gui/kernel/qplatformscreen.h
+++ b/src/gui/kernel/qplatformscreen.h
@@ -49,6 +49,7 @@
// source and binary incompatible with future versions of Qt.
//
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qmetatype.h>
#include <QtCore/qnamespace.h>
#include <QtCore/qcoreevent.h>
diff --git a/src/gui/kernel/qplatformscreen_p.h b/src/gui/kernel/qplatformscreen_p.h
index aa31c4db25..d5dc7b471a 100644
--- a/src/gui/kernel/qplatformscreen_p.h
+++ b/src/gui/kernel/qplatformscreen_p.h
@@ -51,6 +51,8 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
+
QT_BEGIN_NAMESPACE
class QScreen;
diff --git a/src/gui/kernel/qplatformservices.h b/src/gui/kernel/qplatformservices.h
index 52b8ce7854..339bbfde3f 100644
--- a/src/gui/kernel/qplatformservices.h
+++ b/src/gui/kernel/qplatformservices.h
@@ -49,7 +49,7 @@
// source and binary incompatible with future versions of Qt.
//
-#include <QtCore/QtGlobal>
+#include <QtGui/qtguiglobal.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qplatformsessionmanager.h b/src/gui/kernel/qplatformsessionmanager.h
index 98c364f7fe..ca7cab389b 100644
--- a/src/gui/kernel/qplatformsessionmanager.h
+++ b/src/gui/kernel/qplatformsessionmanager.h
@@ -51,6 +51,7 @@
// source and binary incompatible with future versions of Qt.
//
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qmetatype.h>
#include <QtCore/qnamespace.h>
diff --git a/src/gui/kernel/qplatformsharedgraphicscache.h b/src/gui/kernel/qplatformsharedgraphicscache.h
index 6e0ba9151f..e11d2f41a9 100644
--- a/src/gui/kernel/qplatformsharedgraphicscache.h
+++ b/src/gui/kernel/qplatformsharedgraphicscache.h
@@ -49,6 +49,7 @@
// source and binary incompatible with future versions of Qt.
//
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qobject.h>
#include <QtGui/qimage.h>
diff --git a/src/gui/kernel/qplatformsurface.h b/src/gui/kernel/qplatformsurface.h
index 0bbe811803..5a1e4fe82d 100644
--- a/src/gui/kernel/qplatformsurface.h
+++ b/src/gui/kernel/qplatformsurface.h
@@ -49,6 +49,7 @@
// source and binary incompatible with future versions of Qt.
//
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qnamespace.h>
#include <QtGui/qsurface.h>
#include <QtGui/qsurfaceformat.h>
diff --git a/src/gui/kernel/qplatformsystemtrayicon.h b/src/gui/kernel/qplatformsystemtrayicon.h
index dcd7225180..c52dbfbd78 100644
--- a/src/gui/kernel/qplatformsystemtrayicon.h
+++ b/src/gui/kernel/qplatformsystemtrayicon.h
@@ -41,6 +41,7 @@
#ifndef QPLATFORMSYSTEMTRAYICON_H
#define QPLATFORMSYSTEMTRAYICON_H
+#include <QtGui/qtguiglobal.h>
#include "QtCore/qobject.h"
#ifndef QT_NO_SYSTEMTRAYICON
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp
index 7f74959a60..d80ab8b597 100644
--- a/src/gui/kernel/qplatformtheme.cpp
+++ b/src/gui/kernel/qplatformtheme.cpp
@@ -44,6 +44,7 @@
#include <QtCore/QVariant>
#include <QtCore/QStringList>
#include <QtCore/qfileinfo.h>
+#include <qicon.h>
#include <qpalette.h>
#include <qtextformat.h>
#include <private/qiconloader_p.h>
@@ -405,14 +406,22 @@ QPixmap QPlatformTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) co
return QPixmap();
}
-QPixmap QPlatformTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size,
- QPlatformTheme::IconOptions iconOptions) const
+/*!
+ \brief Return an icon for \a fileInfo, observing \a iconOptions.
+
+ This function is queried by QFileIconProvider and similar classes to obtain
+ an icon for a file. If it does not return a non-null icon, fileIconPixmap()
+ is queried for a specific size.
+
+ \since 5.8
+*/
+
+QIcon QPlatformTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions) const
{
Q_UNUSED(fileInfo);
- Q_UNUSED(size);
Q_UNUSED(iconOptions);
// TODO Should return QCommonStyle pixmaps?
- return QPixmap();
+ return QIcon();
}
QVariant QPlatformTheme::themeHint(ThemeHint hint) const
@@ -444,6 +453,8 @@ QVariant QPlatformTheme::themeHint(ThemeHint hint) const
return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::MousePressAndHoldInterval);
case QPlatformTheme::ItemViewActivateItemOnSingleClick:
return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ItemViewActivateItemOnSingleClick);
+ case QPlatformTheme::UiEffects:
+ return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::UiEffects);
default:
return QPlatformTheme::defaultThemeHint(hint);
}
diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h
index c4c7482995..a8baca1967 100644
--- a/src/gui/kernel/qplatformtheme.h
+++ b/src/gui/kernel/qplatformtheme.h
@@ -49,12 +49,13 @@
// source and binary incompatible with future versions of Qt.
//
-#include <QtCore/QtGlobal>
+#include <QtGui/qtguiglobal.h>
#include <QtCore/QScopedPointer>
#include <QtGui/QKeySequence>
QT_BEGIN_NAMESPACE
+class QIcon;
class QIconEngine;
class QMenu;
class QMenuBar;
@@ -270,7 +271,8 @@ public:
AnimateComboUiEffect = 0x8,
AnimateTooltipUiEffect = 0x10,
FadeTooltipUiEffect = 0x20,
- AnimateToolBoxUiEffect = 0x40
+ AnimateToolBoxUiEffect = 0x40,
+ HoverEffect = 0x80
};
enum IconOption {
@@ -300,9 +302,8 @@ public:
virtual QVariant themeHint(ThemeHint hint) const;
virtual QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const;
- virtual QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size,
- QPlatformTheme::IconOptions iconOptions = 0) const;
-
+ virtual QIcon fileIcon(const QFileInfo &fileInfo,
+ QPlatformTheme::IconOptions iconOptions = 0) const;
virtual QIconEngine *createIconEngine(const QString &iconName) const;
virtual QList<QKeySequence> keyBindings(QKeySequence::StandardKey key) const;
diff --git a/src/gui/kernel/qplatformtheme_p.h b/src/gui/kernel/qplatformtheme_p.h
index 11f9e261ef..f2777c57b3 100644
--- a/src/gui/kernel/qplatformtheme_p.h
+++ b/src/gui/kernel/qplatformtheme_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/QtGlobal>
+#include <QtGui/private/qtguiglobal_p.h>
#include "private/qkeysequence_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qplatformthemefactory_p.h b/src/gui/kernel/qplatformthemefactory_p.h
index abd78d544d..3f77f03485 100644
--- a/src/gui/kernel/qplatformthemefactory_p.h
+++ b/src/gui/kernel/qplatformthemefactory_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtCore/qstringlist.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qplatformthemeplugin.h b/src/gui/kernel/qplatformthemeplugin.h
index 52aa09d1d5..7b56879940 100644
--- a/src/gui/kernel/qplatformthemeplugin.h
+++ b/src/gui/kernel/qplatformthemeplugin.h
@@ -49,6 +49,7 @@
// source and binary incompatible with future versions of Qt.
//
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h
index b2a19dd3d9..dcee4d2d84 100644
--- a/src/gui/kernel/qplatformwindow.h
+++ b/src/gui/kernel/qplatformwindow.h
@@ -48,6 +48,7 @@
// source and binary incompatible with future versions of Qt.
//
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qscopedpointer.h>
#include <QtCore/qrect.h>
#include <QtCore/qmargins.h>
diff --git a/src/gui/kernel/qplatformwindow_p.h b/src/gui/kernel/qplatformwindow_p.h
index dc76adca86..62ecd61d9e 100644
--- a/src/gui/kernel/qplatformwindow_p.h
+++ b/src/gui/kernel/qplatformwindow_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtCore/qrect.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qrasterwindow.h b/src/gui/kernel/qrasterwindow.h
index 915aea598f..76312bcda2 100644
--- a/src/gui/kernel/qrasterwindow.h
+++ b/src/gui/kernel/qrasterwindow.h
@@ -40,6 +40,7 @@
#ifndef QRASTERWINDOW_H
#define QRASTERWINDOW_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/QPaintDeviceWindow>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qscreen.h b/src/gui/kernel/qscreen.h
index af4e8f4760..98e35aff43 100644
--- a/src/gui/kernel/qscreen.h
+++ b/src/gui/kernel/qscreen.h
@@ -40,6 +40,7 @@
#ifndef QSCREEN_H
#define QSCREEN_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/QList>
#include <QtCore/QObject>
#include <QtCore/QRect>
diff --git a/src/gui/kernel/qscreen_p.h b/src/gui/kernel/qscreen_p.h
index 544c29a18f..f31658355b 100644
--- a/src/gui/kernel/qscreen_p.h
+++ b/src/gui/kernel/qscreen_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtGui/qscreen.h>
#include <qpa/qplatformscreen.h>
#include "qhighdpiscaling_p.h"
diff --git a/src/gui/kernel/qsessionmanager.h b/src/gui/kernel/qsessionmanager.h
index 54c278afbf..21100b25d9 100644
--- a/src/gui/kernel/qsessionmanager.h
+++ b/src/gui/kernel/qsessionmanager.h
@@ -40,6 +40,7 @@
#ifndef QSESSIONMANAGER_H
#define QSESSIONMANAGER_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qobject.h>
#include <QtGui/qwindowdefs.h>
#include <QtCore/qstring.h>
diff --git a/src/gui/kernel/qsessionmanager_p.h b/src/gui/kernel/qsessionmanager_p.h
index 982fc801ff..954443430e 100644
--- a/src/gui/kernel/qsessionmanager_p.h
+++ b/src/gui/kernel/qsessionmanager_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <private/qobject_p.h>
#include <QtCore/qstring.h>
#include <QtCore/qstringlist.h>
diff --git a/src/gui/kernel/qshapedpixmapdndwindow_p.h b/src/gui/kernel/qshapedpixmapdndwindow_p.h
index 21cecba9e8..2c25ca7c76 100644
--- a/src/gui/kernel/qshapedpixmapdndwindow_p.h
+++ b/src/gui/kernel/qshapedpixmapdndwindow_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtGui/QRasterWindow>
#include <QtGui/QPixmap>
diff --git a/src/gui/kernel/qshortcutmap_p.h b/src/gui/kernel/qshortcutmap_p.h
index f513863e5b..8fc68229fb 100644
--- a/src/gui/kernel/qshortcutmap_p.h
+++ b/src/gui/kernel/qshortcutmap_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtGui/qkeysequence.h"
#include "QtCore/qvector.h"
#include "QtCore/qscopedpointer.h"
diff --git a/src/gui/kernel/qsimpledrag_p.h b/src/gui/kernel/qsimpledrag_p.h
index 8924b4d08f..0b8a0bc703 100644
--- a/src/gui/kernel/qsimpledrag_p.h
+++ b/src/gui/kernel/qsimpledrag_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <qpa/qplatformdrag.h>
#include <QtCore/QObject>
diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp
index ecc2886a04..7ccf1d86b0 100644
--- a/src/gui/kernel/qstylehints.cpp
+++ b/src/gui/kernel/qstylehints.cpp
@@ -77,6 +77,7 @@ public:
, m_keyboardInputInterval(-1)
, m_cursorFlashTime(-1)
, m_tabFocusBehavior(-1)
+ , m_uiEffects(-1)
{}
int m_mouseDoubleClickInterval;
@@ -86,6 +87,7 @@ public:
int m_keyboardInputInterval;
int m_cursorFlashTime;
int m_tabFocusBehavior;
+ int m_uiEffects;
};
/*!
@@ -451,4 +453,34 @@ bool QStyleHints::singleClickActivation() const
return themeableHint(QPlatformTheme::ItemViewActivateItemOnSingleClick, QPlatformIntegration::ItemViewActivateItemOnSingleClick).toBool();
}
+/*!
+ \property QStyleHints::useHoverEffects
+ \brief \c true if UI elements should use hover effects. This is the
+ standard behavior on desktop platforms with a mouse pointer, whereas
+ on touch platforms the overhead of hover event delivery can be avoided.
+
+ \since 5.8
+*/
+bool QStyleHints::useHoverEffects() const
+{
+ Q_D(const QStyleHints);
+ return (d->m_uiEffects >= 0 ?
+ d->m_uiEffects :
+ themeableHint(QPlatformTheme::UiEffects, QPlatformIntegration::UiEffects).toInt()) & QPlatformTheme::HoverEffect;
+}
+
+void QStyleHints::setUseHoverEffects(bool useHoverEffects)
+{
+ Q_D(QStyleHints);
+ if (d->m_uiEffects >= 0 && useHoverEffects == bool(d->m_uiEffects & QPlatformTheme::HoverEffect))
+ return;
+ if (d->m_uiEffects == -1)
+ d->m_uiEffects = 0;
+ if (useHoverEffects)
+ d->m_uiEffects |= QPlatformTheme::HoverEffect;
+ else
+ d->m_uiEffects &= ~QPlatformTheme::HoverEffect;
+ emit useHoverEffectsChanged(useHoverEffects);
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qstylehints.h b/src/gui/kernel/qstylehints.h
index 0b07e60579..fb55cc7ed6 100644
--- a/src/gui/kernel/qstylehints.h
+++ b/src/gui/kernel/qstylehints.h
@@ -40,6 +40,7 @@
#ifndef QSTYLEHINTS_H
#define QSTYLEHINTS_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qobject.h>
QT_BEGIN_NAMESPACE
@@ -69,6 +70,7 @@ class Q_GUI_EXPORT QStyleHints : public QObject
Q_PROPERTY(bool useRtlExtensions READ useRtlExtensions STORED false CONSTANT FINAL)
Q_PROPERTY(Qt::TabFocusBehavior tabFocusBehavior READ tabFocusBehavior NOTIFY tabFocusBehaviorChanged FINAL)
Q_PROPERTY(bool singleClickActivation READ singleClickActivation STORED false CONSTANT FINAL)
+ Q_PROPERTY(bool useHoverEffects READ useHoverEffects WRITE setUseHoverEffects NOTIFY useHoverEffectsChanged FINAL)
public:
void setMouseDoubleClickInterval(int mouseDoubleClickInterval);
@@ -95,6 +97,8 @@ public:
Qt::TabFocusBehavior tabFocusBehavior() const;
void setTabFocusBehavior(Qt::TabFocusBehavior tabFocusBehavior);
bool singleClickActivation() const;
+ bool useHoverEffects() const;
+ void setUseHoverEffects(bool useHoverEffects);
Q_SIGNALS:
void cursorFlashTimeChanged(int cursorFlashTime);
@@ -104,6 +108,7 @@ Q_SIGNALS:
void startDragDistanceChanged(int startDragDistance);
void startDragTimeChanged(int startDragTime);
void tabFocusBehaviorChanged(Qt::TabFocusBehavior tabFocusBehavior);
+ void useHoverEffectsChanged(bool useHoverEffects);
private:
friend class QGuiApplication;
diff --git a/src/gui/kernel/qsurface.h b/src/gui/kernel/qsurface.h
index 86b800a6db..d9ccdc096d 100644
--- a/src/gui/kernel/qsurface.h
+++ b/src/gui/kernel/qsurface.h
@@ -40,6 +40,7 @@
#ifndef QSURFACE_H
#define QSURFACE_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qnamespace.h>
#include <QtGui/qsurfaceformat.h>
#include <QtCore/qmetatype.h>
diff --git a/src/gui/kernel/qsurfaceformat.h b/src/gui/kernel/qsurfaceformat.h
index 9e8bcc91a7..b4e3f68b97 100644
--- a/src/gui/kernel/qsurfaceformat.h
+++ b/src/gui/kernel/qsurfaceformat.h
@@ -39,7 +39,7 @@
#ifndef QSURFACEFORMAT_H
#define QSURFACEFORMAT_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qpair.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qt_gui_pch.h b/src/gui/kernel/qt_gui_pch.h
index 8d1455f6c8..db12ba1078 100644
--- a/src/gui/kernel/qt_gui_pch.h
+++ b/src/gui/kernel/qt_gui_pch.h
@@ -47,7 +47,7 @@
// from corelib/global/qt_pch.h
#if defined __cplusplus
-#include <qglobal.h>
+#include <qtguiglobal.h>
#ifdef Q_OS_WIN
diff --git a/src/plugins/platforms/eglfs/qeglfshooks.h b/src/gui/kernel/qtguiglobal.h
index cc6c325b58..f0e64fbc53 100644
--- a/src/plugins/platforms/eglfs/qeglfshooks.h
+++ b/src/gui/kernel/qtguiglobal.h
@@ -3,7 +3,7 @@
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the plugins of the Qt Toolkit.
+** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -37,20 +37,23 @@
**
****************************************************************************/
-#ifndef QEGLFSHOOKS_H
-#define QEGLFSHOOKS_H
+#ifndef QTGUIGLOBAL_H
+#define QTGUIGLOBAL_H
-#include "qeglfsglobal.h"
-#include "qeglfsdeviceintegration.h"
+#include <QtCore/qglobal.h>
QT_BEGIN_NAMESPACE
-class QEglFSHooks : public QEGLDeviceIntegration
-{
-};
-
-Q_EGLFS_EXPORT QEGLDeviceIntegration *qt_egl_device_integration();
+#ifndef QT_STATIC
+# if defined(QT_BUILD_GUI_LIB)
+# define Q_GUI_EXPORT Q_DECL_EXPORT
+# else
+# define Q_GUI_EXPORT Q_DECL_IMPORT
+# endif
+#else
+# define Q_GUI_EXPORT
+#endif
QT_END_NAMESPACE
-#endif // QEGLFSHOOKS_H
+#endif // QTGUIGLOBAL_H
diff --git a/src/gui/kernel/qtguiglobal_p.h b/src/gui/kernel/qtguiglobal_p.h
new file mode 100644
index 0000000000..fd04b8ff95
--- /dev/null
+++ b/src/gui/kernel/qtguiglobal_p.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTGUIGLOBAL_P_H
+#define QTGUIGLOBAL_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtGui/qtguiglobal.h>
+#include <QtCore/private/qglobal_p.h>
+
+#endif // QTGUIGLOBAL_P_H
diff --git a/src/gui/kernel/qtouchdevice.h b/src/gui/kernel/qtouchdevice.h
index 243f53d4ca..0fb24e47bf 100644
--- a/src/gui/kernel/qtouchdevice.h
+++ b/src/gui/kernel/qtouchdevice.h
@@ -40,6 +40,7 @@
#ifndef QTOUCHDEVICE_H
#define QTOUCHDEVICE_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qobject.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qtouchdevice_p.h b/src/gui/kernel/qtouchdevice_p.h
index b42b0507d9..203d9fca74 100644
--- a/src/gui/kernel/qtouchdevice_p.h
+++ b/src/gui/kernel/qtouchdevice_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtGui/qtouchdevice.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h
index 06bd788262..bf25cf64c9 100644
--- a/src/gui/kernel/qwindow.h
+++ b/src/gui/kernel/qwindow.h
@@ -40,6 +40,7 @@
#ifndef QWINDOW_H
#define QWINDOW_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/QObject>
#include <QtCore/QEvent>
#include <QtCore/QMargins>
diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h
index ccd14f66ae..6d6d5a22ee 100644
--- a/src/gui/kernel/qwindow_p.h
+++ b/src/gui/kernel/qwindow_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtGui/qscreen.h>
#include <QtGui/qwindow.h>
#include <qpa/qplatformwindow.h>
diff --git a/src/gui/kernel/qwindowdefs.h b/src/gui/kernel/qwindowdefs.h
index fb6b1831af..b4f3ed4712 100644
--- a/src/gui/kernel/qwindowdefs.h
+++ b/src/gui/kernel/qwindowdefs.h
@@ -40,7 +40,7 @@
#ifndef QWINDOWDEFS_H
#define QWINDOWDEFS_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qobjectdefs.h>
#include <QtCore/qnamespace.h>
diff --git a/src/gui/kernel/qwindowdefs_win.h b/src/gui/kernel/qwindowdefs_win.h
index d1000856bb..b546fe305e 100644
--- a/src/gui/kernel/qwindowdefs_win.h
+++ b/src/gui/kernel/qwindowdefs_win.h
@@ -40,7 +40,7 @@
#ifndef QWINDOWDEFS_WIN_H
#define QWINDOWDEFS_WIN_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
QT_BEGIN_NAMESPACE
@@ -111,13 +111,4 @@ typedef long HRESULT;
typedef struct tagMSG MSG;
-QT_BEGIN_NAMESPACE
-
-Q_CORE_EXPORT HINSTANCE qWinAppInst();
-Q_CORE_EXPORT HINSTANCE qWinAppPrevInst();
-Q_CORE_EXPORT int qWinAppCmdShow();
-Q_WIDGETS_EXPORT HDC qt_win_display_dc();
-
-QT_END_NAMESPACE
-
#endif // QWINDOWDEFS_WIN_H
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index 1b7edb1278..73140b4f6f 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -474,7 +474,10 @@ QList<QTouchEvent::TouchPoint>
QList<QWindowSystemInterface::TouchPoint>::const_iterator end = points.constEnd();
while (point != end) {
p.setId(point->id);
+ if (point->uniqueId >= 0)
+ p.setUniqueId(point->uniqueId);
p.setPressure(point->pressure);
+ p.setRotation(point->rotation);
states |= point->state;
p.setState(point->state);
@@ -922,6 +925,17 @@ Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int
#endif
}
+namespace QTest
+{
+ Q_GUI_EXPORT QTouchDevice * createTouchDevice(QTouchDevice::DeviceType devType = QTouchDevice::TouchScreen)
+ {
+ QTouchDevice *ret = new QTouchDevice();
+ ret->setType(devType);
+ QWindowSystemInterface::registerTouchDevice(ret);
+ return ret;
+ }
+}
+
Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *w, QTouchDevice *device,
const QList<QTouchEvent::TouchPoint> &points,
Qt::KeyboardModifiers mods = Qt::NoModifier)
diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h
index 6bf87439b9..e7e47ac6d9 100644
--- a/src/gui/kernel/qwindowsysteminterface.h
+++ b/src/gui/kernel/qwindowsysteminterface.h
@@ -48,6 +48,7 @@
// source and binary incompatible with future versions of Qt.
//
+#include <QtGui/qtguiglobal.h>
#include <QtCore/QTime>
#include <QtGui/qwindowdefs.h>
#include <QtCore/QEvent>
@@ -117,11 +118,14 @@ public:
static void handleWheelEvent(QWindow *w, ulong timestamp, const QPointF & local, const QPointF & global, int d, Qt::Orientation o, Qt::KeyboardModifiers mods = Qt::NoModifier);
struct TouchPoint {
- TouchPoint() : id(0), pressure(0), state(Qt::TouchPointStationary) { }
+ TouchPoint() : id(0), uniqueId(-1), pressure(0), rotation(0), state(Qt::TouchPointStationary) { }
int id; // for application use
+ qint64 uniqueId; // for TUIO: object/token ID; otherwise empty
+ // TODO for TUIO 2.0: add registerPointerUniqueID(QPointerUniqueId)
QPointF normalPosition; // touch device coordinates, (0 to 1, 0 to 1)
QRectF area; // the touched area, centered at position in screen coordinates
qreal pressure; // 0 to 1
+ qreal rotation; // 0 means pointing straight up; 0 if unknown (like QTabletEvent::rotation)
Qt::TouchPointState state; //Qt::TouchPoint{Pressed|Moved|Stationary|Released}
QVector2D velocity; // in screen coordinate system, pixels / seconds
QTouchEvent::TouchPoint::InfoFlags flags;
diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h
index b218c1c68c..bdbf191cbd 100644
--- a/src/gui/kernel/qwindowsysteminterface_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_p.h
@@ -50,6 +50,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "qwindowsysteminterface.h"
#include <QElapsedTimer>
diff --git a/src/gui/math3d/qgenericmatrix.h b/src/gui/math3d/qgenericmatrix.h
index 5e22fa6730..9a1ab54124 100644
--- a/src/gui/math3d/qgenericmatrix.h
+++ b/src/gui/math3d/qgenericmatrix.h
@@ -40,6 +40,7 @@
#ifndef QGENERICMATRIX_H
#define QGENERICMATRIX_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qmetatype.h>
#include <QtCore/qdebug.h>
#include <QtCore/qdatastream.h>
diff --git a/src/gui/math3d/qmatrix4x4.h b/src/gui/math3d/qmatrix4x4.h
index bdcf4555d7..19540308a1 100644
--- a/src/gui/math3d/qmatrix4x4.h
+++ b/src/gui/math3d/qmatrix4x4.h
@@ -40,6 +40,7 @@
#ifndef QMATRIX4X4_H
#define QMATRIX4X4_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qvector3d.h>
#include <QtGui/qvector4d.h>
#include <QtGui/qquaternion.h>
diff --git a/src/gui/math3d/qquaternion.h b/src/gui/math3d/qquaternion.h
index d4c91c430a..21b051e08e 100644
--- a/src/gui/math3d/qquaternion.h
+++ b/src/gui/math3d/qquaternion.h
@@ -40,6 +40,7 @@
#ifndef QQUATERNION_H
#define QQUATERNION_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qgenericmatrix.h>
#include <QtGui/qvector3d.h>
#include <QtGui/qvector4d.h>
diff --git a/src/gui/math3d/qvector2d.h b/src/gui/math3d/qvector2d.h
index 697360bd5b..d2724c9498 100644
--- a/src/gui/math3d/qvector2d.h
+++ b/src/gui/math3d/qvector2d.h
@@ -40,6 +40,7 @@
#ifndef QVECTOR2D_H
#define QVECTOR2D_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qpoint.h>
#include <QtCore/qmetatype.h>
diff --git a/src/gui/math3d/qvector3d.h b/src/gui/math3d/qvector3d.h
index c3b335cf7c..c1d881a735 100644
--- a/src/gui/math3d/qvector3d.h
+++ b/src/gui/math3d/qvector3d.h
@@ -40,6 +40,7 @@
#ifndef QVECTOR3D_H
#define QVECTOR3D_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qpoint.h>
#include <QtCore/qmetatype.h>
diff --git a/src/gui/math3d/qvector4d.h b/src/gui/math3d/qvector4d.h
index 28a438f3ac..9387e8d187 100644
--- a/src/gui/math3d/qvector4d.h
+++ b/src/gui/math3d/qvector4d.h
@@ -40,6 +40,7 @@
#ifndef QVECTOR4D_H
#define QVECTOR4D_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qpoint.h>
#include <QtCore/qmetatype.h>
diff --git a/src/gui/opengl/opengl.pri b/src/gui/opengl/opengl.pri
index b13f258fda..dfaf3042bc 100644
--- a/src/gui/opengl/opengl.pri
+++ b/src/gui/opengl/opengl.pri
@@ -32,7 +32,7 @@ contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles2) {
opengl/qopenglversionfunctionsfactory_p.h \
opengl/qopenglvertexarrayobject.h \
opengl/qopengldebug.h \
- opengl/qopengltextureblitter_p.h \
+ opengl/qopengltextureblitter.h \
opengl/qopengltexture.h \
opengl/qopengltexture_p.h \
opengl/qopengltexturehelper_p.h \
diff --git a/src/gui/opengl/qopengl.h b/src/gui/opengl/qopengl.h
index 5f9d78b780..e2408d0047 100644
--- a/src/gui/opengl/qopengl.h
+++ b/src/gui/opengl/qopengl.h
@@ -40,7 +40,7 @@
#ifndef QOPENGL_H
#define QOPENGL_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#ifndef QT_NO_OPENGL
@@ -119,10 +119,8 @@ typedef char GLchar;
#else // non-ES2 platforms
# if defined(Q_OS_MAC)
# include <OpenGL/gl.h>
-# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
-# define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
-# include <OpenGL/gl3.h>
-# endif
+# define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
+# include <OpenGL/gl3.h>
# include <OpenGL/glext.h>
# else
# define GL_GLEXT_LEGACY // Prevents GL/gl.h from #including system glext.h
@@ -131,16 +129,11 @@ typedef char GLchar;
# endif // Q_OS_MAC
#endif // QT_OPENGL_ES_2
-// Desktops, apart from Mac OS X prior to 10.7 can support OpenGL 3.
-// Desktops, apart from Mac OS X prior to 10.9 can support OpenGL 4.
+// Desktops can support OpenGL 4.
#if !defined(QT_OPENGL_ES_2)
-# if !defined(Q_OS_MAC) || (defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
-# define QT_OPENGL_3
-# define QT_OPENGL_3_2
-# endif
-# if !defined(Q_OS_MAC) || (defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9)
-# define QT_OPENGL_4
-# endif
+#define QT_OPENGL_3
+#define QT_OPENGL_3_2
+#define QT_OPENGL_4
# if !defined(Q_OS_MAC)
# define QT_OPENGL_4_3
# endif
diff --git a/src/gui/opengl/qopengl2pexvertexarray_p.h b/src/gui/opengl/qopengl2pexvertexarray_p.h
index 22397391dd..5dc060ff3d 100644
--- a/src/gui/opengl/qopengl2pexvertexarray_p.h
+++ b/src/gui/opengl/qopengl2pexvertexarray_p.h
@@ -51,6 +51,7 @@
#ifndef QOPENGL2PEXVERTEXARRAY_P_H
#define QOPENGL2PEXVERTEXARRAY_P_H
+#include <QtGui/private/qtguiglobal_p.h>
#include <QRectF>
#include <private/qdatabuffer_p.h>
diff --git a/src/gui/opengl/qopengl_p.h b/src/gui/opengl/qopengl_p.h
index 042b903625..cda062eacf 100644
--- a/src/gui/opengl/qopengl_p.h
+++ b/src/gui/opengl/qopengl_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <qopengl.h>
#include <private/qopenglcontext_p.h>
#include <QtCore/qset.h>
diff --git a/src/gui/opengl/qopenglbuffer.h b/src/gui/opengl/qopenglbuffer.h
index bd947bc1d8..f2dfec3bb4 100644
--- a/src/gui/opengl/qopenglbuffer.h
+++ b/src/gui/opengl/qopenglbuffer.h
@@ -40,7 +40,7 @@
#ifndef QOPENGLBUFFER_H
#define QOPENGLBUFFER_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#ifndef QT_NO_OPENGL
diff --git a/src/gui/opengl/qopenglcustomshaderstage_p.h b/src/gui/opengl/qopenglcustomshaderstage_p.h
index 2342991e5e..f4a71af88e 100644
--- a/src/gui/opengl/qopenglcustomshaderstage_p.h
+++ b/src/gui/opengl/qopenglcustomshaderstage_p.h
@@ -51,8 +51,8 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QOpenGLShaderProgram>
-#include <QtGlobal>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/opengl/qopengldebug.h b/src/gui/opengl/qopengldebug.h
index 90e12fb8b1..74b2731f7e 100644
--- a/src/gui/opengl/qopengldebug.h
+++ b/src/gui/opengl/qopengldebug.h
@@ -40,7 +40,7 @@
#ifndef QOPENGLDEBUG_H
#define QOPENGLDEBUG_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#ifndef QT_NO_OPENGL
diff --git a/src/gui/opengl/qopenglengineshadermanager.cpp b/src/gui/opengl/qopenglengineshadermanager.cpp
index 4e3d14ba37..1d3e47f93b 100644
--- a/src/gui/opengl/qopenglengineshadermanager.cpp
+++ b/src/gui/opengl/qopenglengineshadermanager.cpp
@@ -390,7 +390,7 @@ QOpenGLEngineShaderProg *QOpenGLEngineSharedShaders::findProgramInCache(const QO
fragShader->setObjectName(QString::fromLatin1(description));
#endif
if (!fragShader->compileSourceCode(fragSource)) {
- qWarning() << "Warning:" << description << "failed to compile!";
+ qWarning("Warning: \"%s\" failed to compile!", description.constData());
break;
}
@@ -405,7 +405,7 @@ QOpenGLEngineShaderProg *QOpenGLEngineSharedShaders::findProgramInCache(const QO
vertexShader->setObjectName(QString::fromLatin1(description));
#endif
if (!vertexShader->compileSourceCode(vertexSource)) {
- qWarning() << "Warning:" << description << "failed to compile!";
+ qWarning("Warning: \"%s\" failed to compile!", description.constData());
break;
}
diff --git a/src/gui/opengl/qopenglengineshadermanager_p.h b/src/gui/opengl/qopenglengineshadermanager_p.h
index a5e190a48d..23b2ccf486 100644
--- a/src/gui/opengl/qopenglengineshadermanager_p.h
+++ b/src/gui/opengl/qopenglengineshadermanager_p.h
@@ -220,6 +220,7 @@
#ifndef QOPENGLENGINE_SHADER_MANAGER_H
#define QOPENGLENGINE_SHADER_MANAGER_H
+#include <QtGui/private/qtguiglobal_p.h>
#include <QOpenGLShader>
#include <QOpenGLShaderProgram>
#include <QPainter>
diff --git a/src/gui/opengl/qopenglengineshadersource_p.h b/src/gui/opengl/qopenglengineshadersource_p.h
index 876d2775d3..1e88ac63b5 100644
--- a/src/gui/opengl/qopenglengineshadersource_p.h
+++ b/src/gui/opengl/qopenglengineshadersource_p.h
@@ -52,6 +52,7 @@
#ifndef QOPENGL_ENGINE_SHADER_SOURCE_H
#define QOPENGL_ENGINE_SHADER_SOURCE_H
+#include <QtGui/private/qtguiglobal_p.h>
#include "qopenglengineshadermanager_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/gui/opengl/qopenglextensions_p.h b/src/gui/opengl/qopenglextensions_p.h
index 894b6f2dc6..a5f1a2cc88 100644
--- a/src/gui/opengl/qopenglextensions_p.h
+++ b/src/gui/opengl/qopenglextensions_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "qopenglextrafunctions.h"
QT_BEGIN_NAMESPACE
diff --git a/src/gui/opengl/qopenglextrafunctions.h b/src/gui/opengl/qopenglextrafunctions.h
index aa29d685bc..1b36068588 100644
--- a/src/gui/opengl/qopenglextrafunctions.h
+++ b/src/gui/opengl/qopenglextrafunctions.h
@@ -40,7 +40,7 @@
#ifndef QOPENGLEXTRAFUNCTIONS_H
#define QOPENGLEXTRAFUNCTIONS_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#ifndef QT_NO_OPENGL
diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp
index b6e8855d46..1ccd78d2ed 100644
--- a/src/gui/opengl/qopenglframebufferobject.cpp
+++ b/src/gui/opengl/qopenglframebufferobject.cpp
@@ -856,10 +856,8 @@ QOpenGLFramebufferObject::QOpenGLFramebufferObject(const QSize &size, GLenum tar
\sa size(), texture()
*/
QOpenGLFramebufferObject::QOpenGLFramebufferObject(int width, int height, GLenum target)
- : d_ptr(new QOpenGLFramebufferObjectPrivate)
+ : QOpenGLFramebufferObject(QSize(width, height), target)
{
- Q_D(QOpenGLFramebufferObject);
- d->init(this, QSize(width, height), NoAttachment, target, effectiveInternalFormat(0));
}
/*! \overload
@@ -883,11 +881,8 @@ QOpenGLFramebufferObject::QOpenGLFramebufferObject(const QSize &size, const QOpe
*/
QOpenGLFramebufferObject::QOpenGLFramebufferObject(int width, int height, const QOpenGLFramebufferObjectFormat &format)
- : d_ptr(new QOpenGLFramebufferObjectPrivate)
+ : QOpenGLFramebufferObject(QSize(width, height), format)
{
- Q_D(QOpenGLFramebufferObject);
- d->init(this, QSize(width, height), format.attachment(), format.textureTarget(),
- format.internalTextureFormat(), format.samples(), format.mipmap());
}
/*! \overload
diff --git a/src/gui/opengl/qopenglframebufferobject.h b/src/gui/opengl/qopenglframebufferobject.h
index b22726cafb..b9e61e9ee4 100644
--- a/src/gui/opengl/qopenglframebufferobject.h
+++ b/src/gui/opengl/qopenglframebufferobject.h
@@ -40,7 +40,7 @@
#ifndef QOPENGLFRAMEBUFFEROBJECT_H
#define QOPENGLFRAMEBUFFEROBJECT_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#ifndef QT_NO_OPENGL
diff --git a/src/gui/opengl/qopenglframebufferobject_p.h b/src/gui/opengl/qopenglframebufferobject_p.h
index c677b5e344..b6e332fef1 100644
--- a/src/gui/opengl/qopenglframebufferobject_p.h
+++ b/src/gui/opengl/qopenglframebufferobject_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <qopenglframebufferobject.h>
#include <private/qopenglcontext_p.h>
#include <private/qopenglextensions_p.h>
diff --git a/src/gui/opengl/qopenglfunctions.h b/src/gui/opengl/qopenglfunctions.h
index f6cd0e553e..aad48571b3 100644
--- a/src/gui/opengl/qopenglfunctions.h
+++ b/src/gui/opengl/qopenglfunctions.h
@@ -40,7 +40,7 @@
#ifndef QOPENGLFUNCTIONS_H
#define QOPENGLFUNCTIONS_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#ifndef QT_NO_OPENGL
diff --git a/src/gui/opengl/qopenglfunctions_1_0.cpp b/src/gui/opengl/qopenglfunctions_1_0.cpp
index 9d5a76380a..4235c9a339 100644
--- a/src/gui/opengl/qopenglfunctions_1_0.cpp
+++ b/src/gui/opengl/qopenglfunctions_1_0.cpp
@@ -74,12 +74,14 @@ QOpenGLFunctions_1_0::QOpenGLFunctions_1_0()
QOpenGLFunctions_1_0::~QOpenGLFunctions_1_0()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_0_Deprecated)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_0_Deprecated) {
d_1_0_Deprecated->refs.deref();
- Q_ASSERT(d_1_0_Deprecated->refs.load());
+ Q_ASSERT(d_1_0_Deprecated->refs.load());
+ }
}
bool QOpenGLFunctions_1_0::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_1_0.h b/src/gui/opengl/qopenglfunctions_1_0.h
index 825a6255a3..8284604086 100644
--- a/src/gui/opengl/qopenglfunctions_1_0.h
+++ b/src/gui/opengl/qopenglfunctions_1_0.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_1_0_H
#define QOPENGLVERSIONFUNCTIONS_1_0_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_1_1.cpp b/src/gui/opengl/qopenglfunctions_1_1.cpp
index 57385f1927..7d09bb40c1 100644
--- a/src/gui/opengl/qopenglfunctions_1_1.cpp
+++ b/src/gui/opengl/qopenglfunctions_1_1.cpp
@@ -76,18 +76,22 @@ QOpenGLFunctions_1_1::QOpenGLFunctions_1_1()
QOpenGLFunctions_1_1::~QOpenGLFunctions_1_1()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_0_Deprecated)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_0_Deprecated) {
d_1_0_Deprecated->refs.deref();
- Q_ASSERT(d_1_0_Deprecated->refs.load());
- if (d_1_1_Deprecated)
+ Q_ASSERT(d_1_0_Deprecated->refs.load());
+ }
+ if (d_1_1_Deprecated) {
d_1_1_Deprecated->refs.deref();
- Q_ASSERT(d_1_1_Deprecated->refs.load());
+ Q_ASSERT(d_1_1_Deprecated->refs.load());
+ }
}
bool QOpenGLFunctions_1_1::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_1_1.h b/src/gui/opengl/qopenglfunctions_1_1.h
index f312258f00..052d3e93bd 100644
--- a/src/gui/opengl/qopenglfunctions_1_1.h
+++ b/src/gui/opengl/qopenglfunctions_1_1.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_1_1_H
#define QOPENGLVERSIONFUNCTIONS_1_1_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_1_2.cpp b/src/gui/opengl/qopenglfunctions_1_2.cpp
index 9eaa13862d..94a9d64660 100644
--- a/src/gui/opengl/qopenglfunctions_1_2.cpp
+++ b/src/gui/opengl/qopenglfunctions_1_2.cpp
@@ -78,24 +78,30 @@ QOpenGLFunctions_1_2::QOpenGLFunctions_1_2()
QOpenGLFunctions_1_2::~QOpenGLFunctions_1_2()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_0_Deprecated)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_0_Deprecated) {
d_1_0_Deprecated->refs.deref();
- Q_ASSERT(d_1_0_Deprecated->refs.load());
- if (d_1_1_Deprecated)
+ Q_ASSERT(d_1_0_Deprecated->refs.load());
+ }
+ if (d_1_1_Deprecated) {
d_1_1_Deprecated->refs.deref();
- Q_ASSERT(d_1_1_Deprecated->refs.load());
- if (d_1_2_Deprecated)
+ Q_ASSERT(d_1_1_Deprecated->refs.load());
+ }
+ if (d_1_2_Deprecated) {
d_1_2_Deprecated->refs.deref();
- Q_ASSERT(d_1_2_Deprecated->refs.load());
+ Q_ASSERT(d_1_2_Deprecated->refs.load());
+ }
}
bool QOpenGLFunctions_1_2::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_1_2.h b/src/gui/opengl/qopenglfunctions_1_2.h
index fd4e7f74f9..6b36500a79 100644
--- a/src/gui/opengl/qopenglfunctions_1_2.h
+++ b/src/gui/opengl/qopenglfunctions_1_2.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_1_2_H
#define QOPENGLVERSIONFUNCTIONS_1_2_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_1_3.cpp b/src/gui/opengl/qopenglfunctions_1_3.cpp
index 6211997302..972ef9ff70 100644
--- a/src/gui/opengl/qopenglfunctions_1_3.cpp
+++ b/src/gui/opengl/qopenglfunctions_1_3.cpp
@@ -80,30 +80,38 @@ QOpenGLFunctions_1_3::QOpenGLFunctions_1_3()
QOpenGLFunctions_1_3::~QOpenGLFunctions_1_3()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_0_Deprecated)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_0_Deprecated) {
d_1_0_Deprecated->refs.deref();
- Q_ASSERT(d_1_0_Deprecated->refs.load());
- if (d_1_1_Deprecated)
+ Q_ASSERT(d_1_0_Deprecated->refs.load());
+ }
+ if (d_1_1_Deprecated) {
d_1_1_Deprecated->refs.deref();
- Q_ASSERT(d_1_1_Deprecated->refs.load());
- if (d_1_2_Deprecated)
+ Q_ASSERT(d_1_1_Deprecated->refs.load());
+ }
+ if (d_1_2_Deprecated) {
d_1_2_Deprecated->refs.deref();
- Q_ASSERT(d_1_2_Deprecated->refs.load());
- if (d_1_3_Deprecated)
+ Q_ASSERT(d_1_2_Deprecated->refs.load());
+ }
+ if (d_1_3_Deprecated) {
d_1_3_Deprecated->refs.deref();
- Q_ASSERT(d_1_3_Deprecated->refs.load());
+ Q_ASSERT(d_1_3_Deprecated->refs.load());
+ }
}
bool QOpenGLFunctions_1_3::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_1_3.h b/src/gui/opengl/qopenglfunctions_1_3.h
index a8509c46c5..3ed5851d5d 100644
--- a/src/gui/opengl/qopenglfunctions_1_3.h
+++ b/src/gui/opengl/qopenglfunctions_1_3.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_1_3_H
#define QOPENGLVERSIONFUNCTIONS_1_3_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_1_4.cpp b/src/gui/opengl/qopenglfunctions_1_4.cpp
index 5ff2c24014..4b78253301 100644
--- a/src/gui/opengl/qopenglfunctions_1_4.cpp
+++ b/src/gui/opengl/qopenglfunctions_1_4.cpp
@@ -82,36 +82,46 @@ QOpenGLFunctions_1_4::QOpenGLFunctions_1_4()
QOpenGLFunctions_1_4::~QOpenGLFunctions_1_4()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_0_Deprecated)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_0_Deprecated) {
d_1_0_Deprecated->refs.deref();
- Q_ASSERT(d_1_0_Deprecated->refs.load());
- if (d_1_1_Deprecated)
+ Q_ASSERT(d_1_0_Deprecated->refs.load());
+ }
+ if (d_1_1_Deprecated) {
d_1_1_Deprecated->refs.deref();
- Q_ASSERT(d_1_1_Deprecated->refs.load());
- if (d_1_2_Deprecated)
+ Q_ASSERT(d_1_1_Deprecated->refs.load());
+ }
+ if (d_1_2_Deprecated) {
d_1_2_Deprecated->refs.deref();
- Q_ASSERT(d_1_2_Deprecated->refs.load());
- if (d_1_3_Deprecated)
+ Q_ASSERT(d_1_2_Deprecated->refs.load());
+ }
+ if (d_1_3_Deprecated) {
d_1_3_Deprecated->refs.deref();
- Q_ASSERT(d_1_3_Deprecated->refs.load());
- if (d_1_4_Deprecated)
+ Q_ASSERT(d_1_3_Deprecated->refs.load());
+ }
+ if (d_1_4_Deprecated) {
d_1_4_Deprecated->refs.deref();
- Q_ASSERT(d_1_4_Deprecated->refs.load());
+ Q_ASSERT(d_1_4_Deprecated->refs.load());
+ }
}
bool QOpenGLFunctions_1_4::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_1_4.h b/src/gui/opengl/qopenglfunctions_1_4.h
index eeb99dbb1b..849fad6744 100644
--- a/src/gui/opengl/qopenglfunctions_1_4.h
+++ b/src/gui/opengl/qopenglfunctions_1_4.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_1_4_H
#define QOPENGLVERSIONFUNCTIONS_1_4_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_1_5.cpp b/src/gui/opengl/qopenglfunctions_1_5.cpp
index d07f1decec..2a0820d0cb 100644
--- a/src/gui/opengl/qopenglfunctions_1_5.cpp
+++ b/src/gui/opengl/qopenglfunctions_1_5.cpp
@@ -83,39 +83,50 @@ QOpenGLFunctions_1_5::QOpenGLFunctions_1_5()
QOpenGLFunctions_1_5::~QOpenGLFunctions_1_5()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_5_Core)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_5_Core) {
d_1_5_Core->refs.deref();
- Q_ASSERT(d_1_5_Core->refs.load());
- if (d_1_0_Deprecated)
+ Q_ASSERT(d_1_5_Core->refs.load());
+ }
+ if (d_1_0_Deprecated) {
d_1_0_Deprecated->refs.deref();
- Q_ASSERT(d_1_0_Deprecated->refs.load());
- if (d_1_1_Deprecated)
+ Q_ASSERT(d_1_0_Deprecated->refs.load());
+ }
+ if (d_1_1_Deprecated) {
d_1_1_Deprecated->refs.deref();
- Q_ASSERT(d_1_1_Deprecated->refs.load());
- if (d_1_2_Deprecated)
+ Q_ASSERT(d_1_1_Deprecated->refs.load());
+ }
+ if (d_1_2_Deprecated) {
d_1_2_Deprecated->refs.deref();
- Q_ASSERT(d_1_2_Deprecated->refs.load());
- if (d_1_3_Deprecated)
+ Q_ASSERT(d_1_2_Deprecated->refs.load());
+ }
+ if (d_1_3_Deprecated) {
d_1_3_Deprecated->refs.deref();
- Q_ASSERT(d_1_3_Deprecated->refs.load());
- if (d_1_4_Deprecated)
+ Q_ASSERT(d_1_3_Deprecated->refs.load());
+ }
+ if (d_1_4_Deprecated) {
d_1_4_Deprecated->refs.deref();
- Q_ASSERT(d_1_4_Deprecated->refs.load());
+ Q_ASSERT(d_1_4_Deprecated->refs.load());
+ }
}
bool QOpenGLFunctions_1_5::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_1_5.h b/src/gui/opengl/qopenglfunctions_1_5.h
index d5f23c146b..18914a8957 100644
--- a/src/gui/opengl/qopenglfunctions_1_5.h
+++ b/src/gui/opengl/qopenglfunctions_1_5.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_1_5_H
#define QOPENGLVERSIONFUNCTIONS_1_5_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_2_0.cpp b/src/gui/opengl/qopenglfunctions_2_0.cpp
index b7dc8ef458..c175b13c5b 100644
--- a/src/gui/opengl/qopenglfunctions_2_0.cpp
+++ b/src/gui/opengl/qopenglfunctions_2_0.cpp
@@ -85,42 +85,54 @@ QOpenGLFunctions_2_0::QOpenGLFunctions_2_0()
QOpenGLFunctions_2_0::~QOpenGLFunctions_2_0()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_5_Core)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_5_Core) {
d_1_5_Core->refs.deref();
- Q_ASSERT(d_1_5_Core->refs.load());
- if (d_2_0_Core)
+ Q_ASSERT(d_1_5_Core->refs.load());
+ }
+ if (d_2_0_Core) {
d_2_0_Core->refs.deref();
- Q_ASSERT(d_2_0_Core->refs.load());
- if (d_1_0_Deprecated)
+ Q_ASSERT(d_2_0_Core->refs.load());
+ }
+ if (d_1_0_Deprecated) {
d_1_0_Deprecated->refs.deref();
- Q_ASSERT(d_1_0_Deprecated->refs.load());
- if (d_1_1_Deprecated)
+ Q_ASSERT(d_1_0_Deprecated->refs.load());
+ }
+ if (d_1_1_Deprecated) {
d_1_1_Deprecated->refs.deref();
- Q_ASSERT(d_1_1_Deprecated->refs.load());
- if (d_1_2_Deprecated)
+ Q_ASSERT(d_1_1_Deprecated->refs.load());
+ }
+ if (d_1_2_Deprecated) {
d_1_2_Deprecated->refs.deref();
- Q_ASSERT(d_1_2_Deprecated->refs.load());
- if (d_1_3_Deprecated)
+ Q_ASSERT(d_1_2_Deprecated->refs.load());
+ }
+ if (d_1_3_Deprecated) {
d_1_3_Deprecated->refs.deref();
- Q_ASSERT(d_1_3_Deprecated->refs.load());
- if (d_1_4_Deprecated)
+ Q_ASSERT(d_1_3_Deprecated->refs.load());
+ }
+ if (d_1_4_Deprecated) {
d_1_4_Deprecated->refs.deref();
- Q_ASSERT(d_1_4_Deprecated->refs.load());
+ Q_ASSERT(d_1_4_Deprecated->refs.load());
+ }
}
bool QOpenGLFunctions_2_0::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_2_0.h b/src/gui/opengl/qopenglfunctions_2_0.h
index 81b7274a93..74a91e0ff0 100644
--- a/src/gui/opengl/qopenglfunctions_2_0.h
+++ b/src/gui/opengl/qopenglfunctions_2_0.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_2_0_H
#define QOPENGLVERSIONFUNCTIONS_2_0_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_2_1.cpp b/src/gui/opengl/qopenglfunctions_2_1.cpp
index e756685d10..4e77efd121 100644
--- a/src/gui/opengl/qopenglfunctions_2_1.cpp
+++ b/src/gui/opengl/qopenglfunctions_2_1.cpp
@@ -86,45 +86,58 @@ QOpenGLFunctions_2_1::QOpenGLFunctions_2_1()
QOpenGLFunctions_2_1::~QOpenGLFunctions_2_1()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_5_Core)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_5_Core) {
d_1_5_Core->refs.deref();
- Q_ASSERT(d_1_5_Core->refs.load());
- if (d_2_0_Core)
+ Q_ASSERT(d_1_5_Core->refs.load());
+ }
+ if (d_2_0_Core) {
d_2_0_Core->refs.deref();
- Q_ASSERT(d_2_0_Core->refs.load());
- if (d_2_1_Core)
+ Q_ASSERT(d_2_0_Core->refs.load());
+ }
+ if (d_2_1_Core) {
d_2_1_Core->refs.deref();
- Q_ASSERT(d_2_1_Core->refs.load());
- if (d_1_0_Deprecated)
+ Q_ASSERT(d_2_1_Core->refs.load());
+ }
+ if (d_1_0_Deprecated) {
d_1_0_Deprecated->refs.deref();
- Q_ASSERT(d_1_0_Deprecated->refs.load());
- if (d_1_1_Deprecated)
+ Q_ASSERT(d_1_0_Deprecated->refs.load());
+ }
+ if (d_1_1_Deprecated) {
d_1_1_Deprecated->refs.deref();
- Q_ASSERT(d_1_1_Deprecated->refs.load());
- if (d_1_2_Deprecated)
+ Q_ASSERT(d_1_1_Deprecated->refs.load());
+ }
+ if (d_1_2_Deprecated) {
d_1_2_Deprecated->refs.deref();
- Q_ASSERT(d_1_2_Deprecated->refs.load());
- if (d_1_3_Deprecated)
+ Q_ASSERT(d_1_2_Deprecated->refs.load());
+ }
+ if (d_1_3_Deprecated) {
d_1_3_Deprecated->refs.deref();
- Q_ASSERT(d_1_3_Deprecated->refs.load());
- if (d_1_4_Deprecated)
+ Q_ASSERT(d_1_3_Deprecated->refs.load());
+ }
+ if (d_1_4_Deprecated) {
d_1_4_Deprecated->refs.deref();
- Q_ASSERT(d_1_4_Deprecated->refs.load());
+ Q_ASSERT(d_1_4_Deprecated->refs.load());
+ }
}
bool QOpenGLFunctions_2_1::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_2_1.h b/src/gui/opengl/qopenglfunctions_2_1.h
index 7bac5af9da..e9212640f7 100644
--- a/src/gui/opengl/qopenglfunctions_2_1.h
+++ b/src/gui/opengl/qopenglfunctions_2_1.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_2_1_H
#define QOPENGLVERSIONFUNCTIONS_2_1_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_3_0.cpp b/src/gui/opengl/qopenglfunctions_3_0.cpp
index ee7f92855d..09e3ad09ef 100644
--- a/src/gui/opengl/qopenglfunctions_3_0.cpp
+++ b/src/gui/opengl/qopenglfunctions_3_0.cpp
@@ -88,48 +88,62 @@ QOpenGLFunctions_3_0::QOpenGLFunctions_3_0()
QOpenGLFunctions_3_0::~QOpenGLFunctions_3_0()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_5_Core)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_5_Core) {
d_1_5_Core->refs.deref();
- Q_ASSERT(d_1_5_Core->refs.load());
- if (d_2_0_Core)
+ Q_ASSERT(d_1_5_Core->refs.load());
+ }
+ if (d_2_0_Core) {
d_2_0_Core->refs.deref();
- Q_ASSERT(d_2_0_Core->refs.load());
- if (d_2_1_Core)
+ Q_ASSERT(d_2_0_Core->refs.load());
+ }
+ if (d_2_1_Core) {
d_2_1_Core->refs.deref();
- Q_ASSERT(d_2_1_Core->refs.load());
- if (d_3_0_Core)
+ Q_ASSERT(d_2_1_Core->refs.load());
+ }
+ if (d_3_0_Core) {
d_3_0_Core->refs.deref();
- Q_ASSERT(d_3_0_Core->refs.load());
- if (d_1_0_Deprecated)
+ Q_ASSERT(d_3_0_Core->refs.load());
+ }
+ if (d_1_0_Deprecated) {
d_1_0_Deprecated->refs.deref();
- Q_ASSERT(d_1_0_Deprecated->refs.load());
- if (d_1_1_Deprecated)
+ Q_ASSERT(d_1_0_Deprecated->refs.load());
+ }
+ if (d_1_1_Deprecated) {
d_1_1_Deprecated->refs.deref();
- Q_ASSERT(d_1_1_Deprecated->refs.load());
- if (d_1_2_Deprecated)
+ Q_ASSERT(d_1_1_Deprecated->refs.load());
+ }
+ if (d_1_2_Deprecated) {
d_1_2_Deprecated->refs.deref();
- Q_ASSERT(d_1_2_Deprecated->refs.load());
- if (d_1_3_Deprecated)
+ Q_ASSERT(d_1_2_Deprecated->refs.load());
+ }
+ if (d_1_3_Deprecated) {
d_1_3_Deprecated->refs.deref();
- Q_ASSERT(d_1_3_Deprecated->refs.load());
- if (d_1_4_Deprecated)
+ Q_ASSERT(d_1_3_Deprecated->refs.load());
+ }
+ if (d_1_4_Deprecated) {
d_1_4_Deprecated->refs.deref();
- Q_ASSERT(d_1_4_Deprecated->refs.load());
+ Q_ASSERT(d_1_4_Deprecated->refs.load());
+ }
}
bool QOpenGLFunctions_3_0::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_3_0.h b/src/gui/opengl/qopenglfunctions_3_0.h
index da8d5ec5ff..1082d869d1 100644
--- a/src/gui/opengl/qopenglfunctions_3_0.h
+++ b/src/gui/opengl/qopenglfunctions_3_0.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_3_0_H
#define QOPENGLVERSIONFUNCTIONS_3_0_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_3_1.cpp b/src/gui/opengl/qopenglfunctions_3_1.cpp
index a459ddf244..9328f5ca89 100644
--- a/src/gui/opengl/qopenglfunctions_3_1.cpp
+++ b/src/gui/opengl/qopenglfunctions_3_1.cpp
@@ -82,36 +82,46 @@ QOpenGLFunctions_3_1::QOpenGLFunctions_3_1()
QOpenGLFunctions_3_1::~QOpenGLFunctions_3_1()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_5_Core)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_5_Core) {
d_1_5_Core->refs.deref();
- Q_ASSERT(d_1_5_Core->refs.load());
- if (d_2_0_Core)
+ Q_ASSERT(d_1_5_Core->refs.load());
+ }
+ if (d_2_0_Core) {
d_2_0_Core->refs.deref();
- Q_ASSERT(d_2_0_Core->refs.load());
- if (d_2_1_Core)
+ Q_ASSERT(d_2_0_Core->refs.load());
+ }
+ if (d_2_1_Core) {
d_2_1_Core->refs.deref();
- Q_ASSERT(d_2_1_Core->refs.load());
- if (d_3_0_Core)
+ Q_ASSERT(d_2_1_Core->refs.load());
+ }
+ if (d_3_0_Core) {
d_3_0_Core->refs.deref();
- Q_ASSERT(d_3_0_Core->refs.load());
- if (d_3_1_Core)
+ Q_ASSERT(d_3_0_Core->refs.load());
+ }
+ if (d_3_1_Core) {
d_3_1_Core->refs.deref();
- Q_ASSERT(d_3_1_Core->refs.load());
+ Q_ASSERT(d_3_1_Core->refs.load());
+ }
}
bool QOpenGLFunctions_3_1::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_3_1.h b/src/gui/opengl/qopenglfunctions_3_1.h
index d5957381e9..2691dd29e7 100644
--- a/src/gui/opengl/qopenglfunctions_3_1.h
+++ b/src/gui/opengl/qopenglfunctions_3_1.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_3_1_H
#define QOPENGLVERSIONFUNCTIONS_3_1_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_3_2_compatibility.cpp b/src/gui/opengl/qopenglfunctions_3_2_compatibility.cpp
index 09402db09a..b90a123bfe 100644
--- a/src/gui/opengl/qopenglfunctions_3_2_compatibility.cpp
+++ b/src/gui/opengl/qopenglfunctions_3_2_compatibility.cpp
@@ -90,54 +90,70 @@ QOpenGLFunctions_3_2_Compatibility::QOpenGLFunctions_3_2_Compatibility()
QOpenGLFunctions_3_2_Compatibility::~QOpenGLFunctions_3_2_Compatibility()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_5_Core)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_5_Core) {
d_1_5_Core->refs.deref();
- Q_ASSERT(d_1_5_Core->refs.load());
- if (d_2_0_Core)
+ Q_ASSERT(d_1_5_Core->refs.load());
+ }
+ if (d_2_0_Core) {
d_2_0_Core->refs.deref();
- Q_ASSERT(d_2_0_Core->refs.load());
- if (d_2_1_Core)
+ Q_ASSERT(d_2_0_Core->refs.load());
+ }
+ if (d_2_1_Core) {
d_2_1_Core->refs.deref();
- Q_ASSERT(d_2_1_Core->refs.load());
- if (d_3_0_Core)
+ Q_ASSERT(d_2_1_Core->refs.load());
+ }
+ if (d_3_0_Core) {
d_3_0_Core->refs.deref();
- Q_ASSERT(d_3_0_Core->refs.load());
- if (d_3_1_Core)
+ Q_ASSERT(d_3_0_Core->refs.load());
+ }
+ if (d_3_1_Core) {
d_3_1_Core->refs.deref();
- Q_ASSERT(d_3_1_Core->refs.load());
- if (d_3_2_Core)
+ Q_ASSERT(d_3_1_Core->refs.load());
+ }
+ if (d_3_2_Core) {
d_3_2_Core->refs.deref();
- Q_ASSERT(d_3_2_Core->refs.load());
- if (d_1_0_Deprecated)
+ Q_ASSERT(d_3_2_Core->refs.load());
+ }
+ if (d_1_0_Deprecated) {
d_1_0_Deprecated->refs.deref();
- Q_ASSERT(d_1_0_Deprecated->refs.load());
- if (d_1_1_Deprecated)
+ Q_ASSERT(d_1_0_Deprecated->refs.load());
+ }
+ if (d_1_1_Deprecated) {
d_1_1_Deprecated->refs.deref();
- Q_ASSERT(d_1_1_Deprecated->refs.load());
- if (d_1_2_Deprecated)
+ Q_ASSERT(d_1_1_Deprecated->refs.load());
+ }
+ if (d_1_2_Deprecated) {
d_1_2_Deprecated->refs.deref();
- Q_ASSERT(d_1_2_Deprecated->refs.load());
- if (d_1_3_Deprecated)
+ Q_ASSERT(d_1_2_Deprecated->refs.load());
+ }
+ if (d_1_3_Deprecated) {
d_1_3_Deprecated->refs.deref();
- Q_ASSERT(d_1_3_Deprecated->refs.load());
- if (d_1_4_Deprecated)
+ Q_ASSERT(d_1_3_Deprecated->refs.load());
+ }
+ if (d_1_4_Deprecated) {
d_1_4_Deprecated->refs.deref();
- Q_ASSERT(d_1_4_Deprecated->refs.load());
+ Q_ASSERT(d_1_4_Deprecated->refs.load());
+ }
}
bool QOpenGLFunctions_3_2_Compatibility::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_3_2_compatibility.h b/src/gui/opengl/qopenglfunctions_3_2_compatibility.h
index 44fa6759e5..9f34190721 100644
--- a/src/gui/opengl/qopenglfunctions_3_2_compatibility.h
+++ b/src/gui/opengl/qopenglfunctions_3_2_compatibility.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_3_2_COMPATIBILITY_H
#define QOPENGLVERSIONFUNCTIONS_3_2_COMPATIBILITY_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_3_2_core.cpp b/src/gui/opengl/qopenglfunctions_3_2_core.cpp
index 177dc9e25d..02c0c78b01 100644
--- a/src/gui/opengl/qopenglfunctions_3_2_core.cpp
+++ b/src/gui/opengl/qopenglfunctions_3_2_core.cpp
@@ -83,39 +83,50 @@ QOpenGLFunctions_3_2_Core::QOpenGLFunctions_3_2_Core()
QOpenGLFunctions_3_2_Core::~QOpenGLFunctions_3_2_Core()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_5_Core)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_5_Core) {
d_1_5_Core->refs.deref();
- Q_ASSERT(d_1_5_Core->refs.load());
- if (d_2_0_Core)
+ Q_ASSERT(d_1_5_Core->refs.load());
+ }
+ if (d_2_0_Core) {
d_2_0_Core->refs.deref();
- Q_ASSERT(d_2_0_Core->refs.load());
- if (d_2_1_Core)
+ Q_ASSERT(d_2_0_Core->refs.load());
+ }
+ if (d_2_1_Core) {
d_2_1_Core->refs.deref();
- Q_ASSERT(d_2_1_Core->refs.load());
- if (d_3_0_Core)
+ Q_ASSERT(d_2_1_Core->refs.load());
+ }
+ if (d_3_0_Core) {
d_3_0_Core->refs.deref();
- Q_ASSERT(d_3_0_Core->refs.load());
- if (d_3_1_Core)
+ Q_ASSERT(d_3_0_Core->refs.load());
+ }
+ if (d_3_1_Core) {
d_3_1_Core->refs.deref();
- Q_ASSERT(d_3_1_Core->refs.load());
- if (d_3_2_Core)
+ Q_ASSERT(d_3_1_Core->refs.load());
+ }
+ if (d_3_2_Core) {
d_3_2_Core->refs.deref();
- Q_ASSERT(d_3_2_Core->refs.load());
+ Q_ASSERT(d_3_2_Core->refs.load());
+ }
}
bool QOpenGLFunctions_3_2_Core::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_3_2_core.h b/src/gui/opengl/qopenglfunctions_3_2_core.h
index 36f959c04b..2d5ee14bee 100644
--- a/src/gui/opengl/qopenglfunctions_3_2_core.h
+++ b/src/gui/opengl/qopenglfunctions_3_2_core.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_3_2_CORE_H
#define QOPENGLVERSIONFUNCTIONS_3_2_CORE_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_3_3_compatibility.cpp b/src/gui/opengl/qopenglfunctions_3_3_compatibility.cpp
index 110a49ea53..c585f0fc7c 100644
--- a/src/gui/opengl/qopenglfunctions_3_3_compatibility.cpp
+++ b/src/gui/opengl/qopenglfunctions_3_3_compatibility.cpp
@@ -91,60 +91,78 @@ QOpenGLFunctions_3_3_Compatibility::QOpenGLFunctions_3_3_Compatibility()
QOpenGLFunctions_3_3_Compatibility::~QOpenGLFunctions_3_3_Compatibility()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_5_Core)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_5_Core) {
d_1_5_Core->refs.deref();
- Q_ASSERT(d_1_5_Core->refs.load());
- if (d_2_0_Core)
+ Q_ASSERT(d_1_5_Core->refs.load());
+ }
+ if (d_2_0_Core) {
d_2_0_Core->refs.deref();
- Q_ASSERT(d_2_0_Core->refs.load());
- if (d_2_1_Core)
+ Q_ASSERT(d_2_0_Core->refs.load());
+ }
+ if (d_2_1_Core) {
d_2_1_Core->refs.deref();
- Q_ASSERT(d_2_1_Core->refs.load());
- if (d_3_0_Core)
+ Q_ASSERT(d_2_1_Core->refs.load());
+ }
+ if (d_3_0_Core) {
d_3_0_Core->refs.deref();
- Q_ASSERT(d_3_0_Core->refs.load());
- if (d_3_1_Core)
+ Q_ASSERT(d_3_0_Core->refs.load());
+ }
+ if (d_3_1_Core) {
d_3_1_Core->refs.deref();
- Q_ASSERT(d_3_1_Core->refs.load());
- if (d_3_2_Core)
+ Q_ASSERT(d_3_1_Core->refs.load());
+ }
+ if (d_3_2_Core) {
d_3_2_Core->refs.deref();
- Q_ASSERT(d_3_2_Core->refs.load());
- if (d_3_3_Core)
+ Q_ASSERT(d_3_2_Core->refs.load());
+ }
+ if (d_3_3_Core) {
d_3_3_Core->refs.deref();
- Q_ASSERT(d_3_3_Core->refs.load());
- if (d_1_0_Deprecated)
+ Q_ASSERT(d_3_3_Core->refs.load());
+ }
+ if (d_1_0_Deprecated) {
d_1_0_Deprecated->refs.deref();
- Q_ASSERT(d_1_0_Deprecated->refs.load());
- if (d_1_1_Deprecated)
+ Q_ASSERT(d_1_0_Deprecated->refs.load());
+ }
+ if (d_1_1_Deprecated) {
d_1_1_Deprecated->refs.deref();
- Q_ASSERT(d_1_1_Deprecated->refs.load());
- if (d_1_2_Deprecated)
+ Q_ASSERT(d_1_1_Deprecated->refs.load());
+ }
+ if (d_1_2_Deprecated) {
d_1_2_Deprecated->refs.deref();
- Q_ASSERT(d_1_2_Deprecated->refs.load());
- if (d_1_3_Deprecated)
+ Q_ASSERT(d_1_2_Deprecated->refs.load());
+ }
+ if (d_1_3_Deprecated) {
d_1_3_Deprecated->refs.deref();
- Q_ASSERT(d_1_3_Deprecated->refs.load());
- if (d_1_4_Deprecated)
+ Q_ASSERT(d_1_3_Deprecated->refs.load());
+ }
+ if (d_1_4_Deprecated) {
d_1_4_Deprecated->refs.deref();
- Q_ASSERT(d_1_4_Deprecated->refs.load());
- if (d_3_3_Deprecated)
+ Q_ASSERT(d_1_4_Deprecated->refs.load());
+ }
+ if (d_3_3_Deprecated) {
d_3_3_Deprecated->refs.deref();
- Q_ASSERT(d_3_3_Deprecated->refs.load());
+ Q_ASSERT(d_3_3_Deprecated->refs.load());
+ }
}
bool QOpenGLFunctions_3_3_Compatibility::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_3_3_compatibility.h b/src/gui/opengl/qopenglfunctions_3_3_compatibility.h
index 126cc16858..a5c0cab63c 100644
--- a/src/gui/opengl/qopenglfunctions_3_3_compatibility.h
+++ b/src/gui/opengl/qopenglfunctions_3_3_compatibility.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_3_3_COMPATIBILITY_H
#define QOPENGLVERSIONFUNCTIONS_3_3_COMPATIBILITY_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_3_3_core.cpp b/src/gui/opengl/qopenglfunctions_3_3_core.cpp
index 2e706724d9..7779d92b6a 100644
--- a/src/gui/opengl/qopenglfunctions_3_3_core.cpp
+++ b/src/gui/opengl/qopenglfunctions_3_3_core.cpp
@@ -84,42 +84,54 @@ QOpenGLFunctions_3_3_Core::QOpenGLFunctions_3_3_Core()
QOpenGLFunctions_3_3_Core::~QOpenGLFunctions_3_3_Core()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_5_Core)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_5_Core) {
d_1_5_Core->refs.deref();
- Q_ASSERT(d_1_5_Core->refs.load());
- if (d_2_0_Core)
+ Q_ASSERT(d_1_5_Core->refs.load());
+ }
+ if (d_2_0_Core) {
d_2_0_Core->refs.deref();
- Q_ASSERT(d_2_0_Core->refs.load());
- if (d_2_1_Core)
+ Q_ASSERT(d_2_0_Core->refs.load());
+ }
+ if (d_2_1_Core) {
d_2_1_Core->refs.deref();
- Q_ASSERT(d_2_1_Core->refs.load());
- if (d_3_0_Core)
+ Q_ASSERT(d_2_1_Core->refs.load());
+ }
+ if (d_3_0_Core) {
d_3_0_Core->refs.deref();
- Q_ASSERT(d_3_0_Core->refs.load());
- if (d_3_1_Core)
+ Q_ASSERT(d_3_0_Core->refs.load());
+ }
+ if (d_3_1_Core) {
d_3_1_Core->refs.deref();
- Q_ASSERT(d_3_1_Core->refs.load());
- if (d_3_2_Core)
+ Q_ASSERT(d_3_1_Core->refs.load());
+ }
+ if (d_3_2_Core) {
d_3_2_Core->refs.deref();
- Q_ASSERT(d_3_2_Core->refs.load());
- if (d_3_3_Core)
+ Q_ASSERT(d_3_2_Core->refs.load());
+ }
+ if (d_3_3_Core) {
d_3_3_Core->refs.deref();
- Q_ASSERT(d_3_3_Core->refs.load());
+ Q_ASSERT(d_3_3_Core->refs.load());
+ }
}
bool QOpenGLFunctions_3_3_Core::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_3_3_core.h b/src/gui/opengl/qopenglfunctions_3_3_core.h
index 15a62802ab..4f0132d959 100644
--- a/src/gui/opengl/qopenglfunctions_3_3_core.h
+++ b/src/gui/opengl/qopenglfunctions_3_3_core.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_3_3_CORE_H
#define QOPENGLVERSIONFUNCTIONS_3_3_CORE_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_4_0_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_0_compatibility.cpp
index 14fb168c94..b5c423ef0c 100644
--- a/src/gui/opengl/qopenglfunctions_4_0_compatibility.cpp
+++ b/src/gui/opengl/qopenglfunctions_4_0_compatibility.cpp
@@ -92,63 +92,82 @@ QOpenGLFunctions_4_0_Compatibility::QOpenGLFunctions_4_0_Compatibility()
QOpenGLFunctions_4_0_Compatibility::~QOpenGLFunctions_4_0_Compatibility()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_5_Core)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_5_Core) {
d_1_5_Core->refs.deref();
- Q_ASSERT(d_1_5_Core->refs.load());
- if (d_2_0_Core)
+ Q_ASSERT(d_1_5_Core->refs.load());
+ }
+ if (d_2_0_Core) {
d_2_0_Core->refs.deref();
- Q_ASSERT(d_2_0_Core->refs.load());
- if (d_2_1_Core)
+ Q_ASSERT(d_2_0_Core->refs.load());
+ }
+ if (d_2_1_Core) {
d_2_1_Core->refs.deref();
- Q_ASSERT(d_2_1_Core->refs.load());
- if (d_3_0_Core)
+ Q_ASSERT(d_2_1_Core->refs.load());
+ }
+ if (d_3_0_Core) {
d_3_0_Core->refs.deref();
- Q_ASSERT(d_3_0_Core->refs.load());
- if (d_3_1_Core)
+ Q_ASSERT(d_3_0_Core->refs.load());
+ }
+ if (d_3_1_Core) {
d_3_1_Core->refs.deref();
- Q_ASSERT(d_3_1_Core->refs.load());
- if (d_3_2_Core)
+ Q_ASSERT(d_3_1_Core->refs.load());
+ }
+ if (d_3_2_Core) {
d_3_2_Core->refs.deref();
- Q_ASSERT(d_3_2_Core->refs.load());
- if (d_3_3_Core)
+ Q_ASSERT(d_3_2_Core->refs.load());
+ }
+ if (d_3_3_Core) {
d_3_3_Core->refs.deref();
- Q_ASSERT(d_3_3_Core->refs.load());
- if (d_4_0_Core)
+ Q_ASSERT(d_3_3_Core->refs.load());
+ }
+ if (d_4_0_Core) {
d_4_0_Core->refs.deref();
- Q_ASSERT(d_4_0_Core->refs.load());
- if (d_1_0_Deprecated)
+ Q_ASSERT(d_4_0_Core->refs.load());
+ }
+ if (d_1_0_Deprecated) {
d_1_0_Deprecated->refs.deref();
- Q_ASSERT(d_1_0_Deprecated->refs.load());
- if (d_1_1_Deprecated)
+ Q_ASSERT(d_1_0_Deprecated->refs.load());
+ }
+ if (d_1_1_Deprecated) {
d_1_1_Deprecated->refs.deref();
- Q_ASSERT(d_1_1_Deprecated->refs.load());
- if (d_1_2_Deprecated)
+ Q_ASSERT(d_1_1_Deprecated->refs.load());
+ }
+ if (d_1_2_Deprecated) {
d_1_2_Deprecated->refs.deref();
- Q_ASSERT(d_1_2_Deprecated->refs.load());
- if (d_1_3_Deprecated)
+ Q_ASSERT(d_1_2_Deprecated->refs.load());
+ }
+ if (d_1_3_Deprecated) {
d_1_3_Deprecated->refs.deref();
- Q_ASSERT(d_1_3_Deprecated->refs.load());
- if (d_1_4_Deprecated)
+ Q_ASSERT(d_1_3_Deprecated->refs.load());
+ }
+ if (d_1_4_Deprecated) {
d_1_4_Deprecated->refs.deref();
- Q_ASSERT(d_1_4_Deprecated->refs.load());
- if (d_3_3_Deprecated)
+ Q_ASSERT(d_1_4_Deprecated->refs.load());
+ }
+ if (d_3_3_Deprecated) {
d_3_3_Deprecated->refs.deref();
- Q_ASSERT(d_3_3_Deprecated->refs.load());
+ Q_ASSERT(d_3_3_Deprecated->refs.load());
+ }
}
bool QOpenGLFunctions_4_0_Compatibility::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_4_0_compatibility.h b/src/gui/opengl/qopenglfunctions_4_0_compatibility.h
index 9ca6eb8a36..1fa5e8a361 100644
--- a/src/gui/opengl/qopenglfunctions_4_0_compatibility.h
+++ b/src/gui/opengl/qopenglfunctions_4_0_compatibility.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_4_0_COMPATIBILITY_H
#define QOPENGLVERSIONFUNCTIONS_4_0_COMPATIBILITY_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_4_0_core.cpp b/src/gui/opengl/qopenglfunctions_4_0_core.cpp
index 6dc94153c8..4e4e8cc547 100644
--- a/src/gui/opengl/qopenglfunctions_4_0_core.cpp
+++ b/src/gui/opengl/qopenglfunctions_4_0_core.cpp
@@ -85,45 +85,58 @@ QOpenGLFunctions_4_0_Core::QOpenGLFunctions_4_0_Core()
QOpenGLFunctions_4_0_Core::~QOpenGLFunctions_4_0_Core()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_5_Core)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_5_Core) {
d_1_5_Core->refs.deref();
- Q_ASSERT(d_1_5_Core->refs.load());
- if (d_2_0_Core)
+ Q_ASSERT(d_1_5_Core->refs.load());
+ }
+ if (d_2_0_Core) {
d_2_0_Core->refs.deref();
- Q_ASSERT(d_2_0_Core->refs.load());
- if (d_2_1_Core)
+ Q_ASSERT(d_2_0_Core->refs.load());
+ }
+ if (d_2_1_Core) {
d_2_1_Core->refs.deref();
- Q_ASSERT(d_2_1_Core->refs.load());
- if (d_3_0_Core)
+ Q_ASSERT(d_2_1_Core->refs.load());
+ }
+ if (d_3_0_Core) {
d_3_0_Core->refs.deref();
- Q_ASSERT(d_3_0_Core->refs.load());
- if (d_3_1_Core)
+ Q_ASSERT(d_3_0_Core->refs.load());
+ }
+ if (d_3_1_Core) {
d_3_1_Core->refs.deref();
- Q_ASSERT(d_3_1_Core->refs.load());
- if (d_3_2_Core)
+ Q_ASSERT(d_3_1_Core->refs.load());
+ }
+ if (d_3_2_Core) {
d_3_2_Core->refs.deref();
- Q_ASSERT(d_3_2_Core->refs.load());
- if (d_3_3_Core)
+ Q_ASSERT(d_3_2_Core->refs.load());
+ }
+ if (d_3_3_Core) {
d_3_3_Core->refs.deref();
- Q_ASSERT(d_3_3_Core->refs.load());
- if (d_4_0_Core)
+ Q_ASSERT(d_3_3_Core->refs.load());
+ }
+ if (d_4_0_Core) {
d_4_0_Core->refs.deref();
- Q_ASSERT(d_4_0_Core->refs.load());
+ Q_ASSERT(d_4_0_Core->refs.load());
+ }
}
bool QOpenGLFunctions_4_0_Core::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_4_0_core.h b/src/gui/opengl/qopenglfunctions_4_0_core.h
index c3e1e9ce5a..8fd2af2d04 100644
--- a/src/gui/opengl/qopenglfunctions_4_0_core.h
+++ b/src/gui/opengl/qopenglfunctions_4_0_core.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_4_0_CORE_H
#define QOPENGLVERSIONFUNCTIONS_4_0_CORE_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_4_1_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_1_compatibility.cpp
index 293409ddef..72c60c74b7 100644
--- a/src/gui/opengl/qopenglfunctions_4_1_compatibility.cpp
+++ b/src/gui/opengl/qopenglfunctions_4_1_compatibility.cpp
@@ -93,66 +93,86 @@ QOpenGLFunctions_4_1_Compatibility::QOpenGLFunctions_4_1_Compatibility()
QOpenGLFunctions_4_1_Compatibility::~QOpenGLFunctions_4_1_Compatibility()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_5_Core)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_5_Core) {
d_1_5_Core->refs.deref();
- Q_ASSERT(d_1_5_Core->refs.load());
- if (d_2_0_Core)
+ Q_ASSERT(d_1_5_Core->refs.load());
+ }
+ if (d_2_0_Core) {
d_2_0_Core->refs.deref();
- Q_ASSERT(d_2_0_Core->refs.load());
- if (d_2_1_Core)
+ Q_ASSERT(d_2_0_Core->refs.load());
+ }
+ if (d_2_1_Core) {
d_2_1_Core->refs.deref();
- Q_ASSERT(d_2_1_Core->refs.load());
- if (d_3_0_Core)
+ Q_ASSERT(d_2_1_Core->refs.load());
+ }
+ if (d_3_0_Core) {
d_3_0_Core->refs.deref();
- Q_ASSERT(d_3_0_Core->refs.load());
- if (d_3_1_Core)
+ Q_ASSERT(d_3_0_Core->refs.load());
+ }
+ if (d_3_1_Core) {
d_3_1_Core->refs.deref();
- Q_ASSERT(d_3_1_Core->refs.load());
- if (d_3_2_Core)
+ Q_ASSERT(d_3_1_Core->refs.load());
+ }
+ if (d_3_2_Core) {
d_3_2_Core->refs.deref();
- Q_ASSERT(d_3_2_Core->refs.load());
- if (d_3_3_Core)
+ Q_ASSERT(d_3_2_Core->refs.load());
+ }
+ if (d_3_3_Core) {
d_3_3_Core->refs.deref();
- Q_ASSERT(d_3_3_Core->refs.load());
- if (d_4_0_Core)
+ Q_ASSERT(d_3_3_Core->refs.load());
+ }
+ if (d_4_0_Core) {
d_4_0_Core->refs.deref();
- Q_ASSERT(d_4_0_Core->refs.load());
- if (d_4_1_Core)
+ Q_ASSERT(d_4_0_Core->refs.load());
+ }
+ if (d_4_1_Core) {
d_4_1_Core->refs.deref();
- Q_ASSERT(d_4_1_Core->refs.load());
- if (d_1_0_Deprecated)
+ Q_ASSERT(d_4_1_Core->refs.load());
+ }
+ if (d_1_0_Deprecated) {
d_1_0_Deprecated->refs.deref();
- Q_ASSERT(d_1_0_Deprecated->refs.load());
- if (d_1_1_Deprecated)
+ Q_ASSERT(d_1_0_Deprecated->refs.load());
+ }
+ if (d_1_1_Deprecated) {
d_1_1_Deprecated->refs.deref();
- Q_ASSERT(d_1_1_Deprecated->refs.load());
- if (d_1_2_Deprecated)
+ Q_ASSERT(d_1_1_Deprecated->refs.load());
+ }
+ if (d_1_2_Deprecated) {
d_1_2_Deprecated->refs.deref();
- Q_ASSERT(d_1_2_Deprecated->refs.load());
- if (d_1_3_Deprecated)
+ Q_ASSERT(d_1_2_Deprecated->refs.load());
+ }
+ if (d_1_3_Deprecated) {
d_1_3_Deprecated->refs.deref();
- Q_ASSERT(d_1_3_Deprecated->refs.load());
- if (d_1_4_Deprecated)
+ Q_ASSERT(d_1_3_Deprecated->refs.load());
+ }
+ if (d_1_4_Deprecated) {
d_1_4_Deprecated->refs.deref();
- Q_ASSERT(d_1_4_Deprecated->refs.load());
- if (d_3_3_Deprecated)
+ Q_ASSERT(d_1_4_Deprecated->refs.load());
+ }
+ if (d_3_3_Deprecated) {
d_3_3_Deprecated->refs.deref();
- Q_ASSERT(d_3_3_Deprecated->refs.load());
+ Q_ASSERT(d_3_3_Deprecated->refs.load());
+ }
}
bool QOpenGLFunctions_4_1_Compatibility::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_4_1_compatibility.h b/src/gui/opengl/qopenglfunctions_4_1_compatibility.h
index e06803f0aa..a284f8e6d3 100644
--- a/src/gui/opengl/qopenglfunctions_4_1_compatibility.h
+++ b/src/gui/opengl/qopenglfunctions_4_1_compatibility.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_4_1_COMPATIBILITY_H
#define QOPENGLVERSIONFUNCTIONS_4_1_COMPATIBILITY_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_4_1_core.cpp b/src/gui/opengl/qopenglfunctions_4_1_core.cpp
index ff3d191781..5a1e1eb42f 100644
--- a/src/gui/opengl/qopenglfunctions_4_1_core.cpp
+++ b/src/gui/opengl/qopenglfunctions_4_1_core.cpp
@@ -86,48 +86,62 @@ QOpenGLFunctions_4_1_Core::QOpenGLFunctions_4_1_Core()
QOpenGLFunctions_4_1_Core::~QOpenGLFunctions_4_1_Core()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_5_Core)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_5_Core) {
d_1_5_Core->refs.deref();
- Q_ASSERT(d_1_5_Core->refs.load());
- if (d_2_0_Core)
+ Q_ASSERT(d_1_5_Core->refs.load());
+ }
+ if (d_2_0_Core) {
d_2_0_Core->refs.deref();
- Q_ASSERT(d_2_0_Core->refs.load());
- if (d_2_1_Core)
+ Q_ASSERT(d_2_0_Core->refs.load());
+ }
+ if (d_2_1_Core) {
d_2_1_Core->refs.deref();
- Q_ASSERT(d_2_1_Core->refs.load());
- if (d_3_0_Core)
+ Q_ASSERT(d_2_1_Core->refs.load());
+ }
+ if (d_3_0_Core) {
d_3_0_Core->refs.deref();
- Q_ASSERT(d_3_0_Core->refs.load());
- if (d_3_1_Core)
+ Q_ASSERT(d_3_0_Core->refs.load());
+ }
+ if (d_3_1_Core) {
d_3_1_Core->refs.deref();
- Q_ASSERT(d_3_1_Core->refs.load());
- if (d_3_2_Core)
+ Q_ASSERT(d_3_1_Core->refs.load());
+ }
+ if (d_3_2_Core) {
d_3_2_Core->refs.deref();
- Q_ASSERT(d_3_2_Core->refs.load());
- if (d_3_3_Core)
+ Q_ASSERT(d_3_2_Core->refs.load());
+ }
+ if (d_3_3_Core) {
d_3_3_Core->refs.deref();
- Q_ASSERT(d_3_3_Core->refs.load());
- if (d_4_0_Core)
+ Q_ASSERT(d_3_3_Core->refs.load());
+ }
+ if (d_4_0_Core) {
d_4_0_Core->refs.deref();
- Q_ASSERT(d_4_0_Core->refs.load());
- if (d_4_1_Core)
+ Q_ASSERT(d_4_0_Core->refs.load());
+ }
+ if (d_4_1_Core) {
d_4_1_Core->refs.deref();
- Q_ASSERT(d_4_1_Core->refs.load());
+ Q_ASSERT(d_4_1_Core->refs.load());
+ }
}
bool QOpenGLFunctions_4_1_Core::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_4_1_core.h b/src/gui/opengl/qopenglfunctions_4_1_core.h
index 17d922e261..d35db3c839 100644
--- a/src/gui/opengl/qopenglfunctions_4_1_core.h
+++ b/src/gui/opengl/qopenglfunctions_4_1_core.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_4_1_CORE_H
#define QOPENGLVERSIONFUNCTIONS_4_1_CORE_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_4_2_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_2_compatibility.cpp
index 58527e92b5..8398ef0948 100644
--- a/src/gui/opengl/qopenglfunctions_4_2_compatibility.cpp
+++ b/src/gui/opengl/qopenglfunctions_4_2_compatibility.cpp
@@ -94,69 +94,90 @@ QOpenGLFunctions_4_2_Compatibility::QOpenGLFunctions_4_2_Compatibility()
QOpenGLFunctions_4_2_Compatibility::~QOpenGLFunctions_4_2_Compatibility()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_5_Core)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_5_Core) {
d_1_5_Core->refs.deref();
- Q_ASSERT(d_1_5_Core->refs.load());
- if (d_2_0_Core)
+ Q_ASSERT(d_1_5_Core->refs.load());
+ }
+ if (d_2_0_Core) {
d_2_0_Core->refs.deref();
- Q_ASSERT(d_2_0_Core->refs.load());
- if (d_2_1_Core)
+ Q_ASSERT(d_2_0_Core->refs.load());
+ }
+ if (d_2_1_Core) {
d_2_1_Core->refs.deref();
- Q_ASSERT(d_2_1_Core->refs.load());
- if (d_3_0_Core)
+ Q_ASSERT(d_2_1_Core->refs.load());
+ }
+ if (d_3_0_Core) {
d_3_0_Core->refs.deref();
- Q_ASSERT(d_3_0_Core->refs.load());
- if (d_3_1_Core)
+ Q_ASSERT(d_3_0_Core->refs.load());
+ }
+ if (d_3_1_Core) {
d_3_1_Core->refs.deref();
- Q_ASSERT(d_3_1_Core->refs.load());
- if (d_3_2_Core)
+ Q_ASSERT(d_3_1_Core->refs.load());
+ }
+ if (d_3_2_Core) {
d_3_2_Core->refs.deref();
- Q_ASSERT(d_3_2_Core->refs.load());
- if (d_3_3_Core)
+ Q_ASSERT(d_3_2_Core->refs.load());
+ }
+ if (d_3_3_Core) {
d_3_3_Core->refs.deref();
- Q_ASSERT(d_3_3_Core->refs.load());
- if (d_4_0_Core)
+ Q_ASSERT(d_3_3_Core->refs.load());
+ }
+ if (d_4_0_Core) {
d_4_0_Core->refs.deref();
- Q_ASSERT(d_4_0_Core->refs.load());
- if (d_4_1_Core)
+ Q_ASSERT(d_4_0_Core->refs.load());
+ }
+ if (d_4_1_Core) {
d_4_1_Core->refs.deref();
- Q_ASSERT(d_4_1_Core->refs.load());
- if (d_4_2_Core)
+ Q_ASSERT(d_4_1_Core->refs.load());
+ }
+ if (d_4_2_Core) {
d_4_2_Core->refs.deref();
- Q_ASSERT(d_4_2_Core->refs.load());
- if (d_1_0_Deprecated)
+ Q_ASSERT(d_4_2_Core->refs.load());
+ }
+ if (d_1_0_Deprecated) {
d_1_0_Deprecated->refs.deref();
- Q_ASSERT(d_1_0_Deprecated->refs.load());
- if (d_1_1_Deprecated)
+ Q_ASSERT(d_1_0_Deprecated->refs.load());
+ }
+ if (d_1_1_Deprecated) {
d_1_1_Deprecated->refs.deref();
- Q_ASSERT(d_1_1_Deprecated->refs.load());
- if (d_1_2_Deprecated)
+ Q_ASSERT(d_1_1_Deprecated->refs.load());
+ }
+ if (d_1_2_Deprecated) {
d_1_2_Deprecated->refs.deref();
- Q_ASSERT(d_1_2_Deprecated->refs.load());
- if (d_1_3_Deprecated)
+ Q_ASSERT(d_1_2_Deprecated->refs.load());
+ }
+ if (d_1_3_Deprecated) {
d_1_3_Deprecated->refs.deref();
- Q_ASSERT(d_1_3_Deprecated->refs.load());
- if (d_1_4_Deprecated)
+ Q_ASSERT(d_1_3_Deprecated->refs.load());
+ }
+ if (d_1_4_Deprecated) {
d_1_4_Deprecated->refs.deref();
- Q_ASSERT(d_1_4_Deprecated->refs.load());
- if (d_3_3_Deprecated)
+ Q_ASSERT(d_1_4_Deprecated->refs.load());
+ }
+ if (d_3_3_Deprecated) {
d_3_3_Deprecated->refs.deref();
- Q_ASSERT(d_3_3_Deprecated->refs.load());
+ Q_ASSERT(d_3_3_Deprecated->refs.load());
+ }
}
bool QOpenGLFunctions_4_2_Compatibility::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_4_2_compatibility.h b/src/gui/opengl/qopenglfunctions_4_2_compatibility.h
index cb95c39936..7b45859984 100644
--- a/src/gui/opengl/qopenglfunctions_4_2_compatibility.h
+++ b/src/gui/opengl/qopenglfunctions_4_2_compatibility.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_4_2_COMPATIBILITY_H
#define QOPENGLVERSIONFUNCTIONS_4_2_COMPATIBILITY_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_4_2_core.cpp b/src/gui/opengl/qopenglfunctions_4_2_core.cpp
index b929abcf6a..fdfb4db455 100644
--- a/src/gui/opengl/qopenglfunctions_4_2_core.cpp
+++ b/src/gui/opengl/qopenglfunctions_4_2_core.cpp
@@ -87,51 +87,66 @@ QOpenGLFunctions_4_2_Core::QOpenGLFunctions_4_2_Core()
QOpenGLFunctions_4_2_Core::~QOpenGLFunctions_4_2_Core()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_5_Core)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_5_Core) {
d_1_5_Core->refs.deref();
- Q_ASSERT(d_1_5_Core->refs.load());
- if (d_2_0_Core)
+ Q_ASSERT(d_1_5_Core->refs.load());
+ }
+ if (d_2_0_Core) {
d_2_0_Core->refs.deref();
- Q_ASSERT(d_2_0_Core->refs.load());
- if (d_2_1_Core)
+ Q_ASSERT(d_2_0_Core->refs.load());
+ }
+ if (d_2_1_Core) {
d_2_1_Core->refs.deref();
- Q_ASSERT(d_2_1_Core->refs.load());
- if (d_3_0_Core)
+ Q_ASSERT(d_2_1_Core->refs.load());
+ }
+ if (d_3_0_Core) {
d_3_0_Core->refs.deref();
- Q_ASSERT(d_3_0_Core->refs.load());
- if (d_3_1_Core)
+ Q_ASSERT(d_3_0_Core->refs.load());
+ }
+ if (d_3_1_Core) {
d_3_1_Core->refs.deref();
- Q_ASSERT(d_3_1_Core->refs.load());
- if (d_3_2_Core)
+ Q_ASSERT(d_3_1_Core->refs.load());
+ }
+ if (d_3_2_Core) {
d_3_2_Core->refs.deref();
- Q_ASSERT(d_3_2_Core->refs.load());
- if (d_3_3_Core)
+ Q_ASSERT(d_3_2_Core->refs.load());
+ }
+ if (d_3_3_Core) {
d_3_3_Core->refs.deref();
- Q_ASSERT(d_3_3_Core->refs.load());
- if (d_4_0_Core)
+ Q_ASSERT(d_3_3_Core->refs.load());
+ }
+ if (d_4_0_Core) {
d_4_0_Core->refs.deref();
- Q_ASSERT(d_4_0_Core->refs.load());
- if (d_4_1_Core)
+ Q_ASSERT(d_4_0_Core->refs.load());
+ }
+ if (d_4_1_Core) {
d_4_1_Core->refs.deref();
- Q_ASSERT(d_4_1_Core->refs.load());
- if (d_4_2_Core)
+ Q_ASSERT(d_4_1_Core->refs.load());
+ }
+ if (d_4_2_Core) {
d_4_2_Core->refs.deref();
- Q_ASSERT(d_4_2_Core->refs.load());
+ Q_ASSERT(d_4_2_Core->refs.load());
+ }
}
bool QOpenGLFunctions_4_2_Core::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_4_2_core.h b/src/gui/opengl/qopenglfunctions_4_2_core.h
index 14b748b3f5..80bb33e7d8 100644
--- a/src/gui/opengl/qopenglfunctions_4_2_core.h
+++ b/src/gui/opengl/qopenglfunctions_4_2_core.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_4_2_CORE_H
#define QOPENGLVERSIONFUNCTIONS_4_2_CORE_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_4_3_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_3_compatibility.cpp
index a9f15083ad..19e67c6331 100644
--- a/src/gui/opengl/qopenglfunctions_4_3_compatibility.cpp
+++ b/src/gui/opengl/qopenglfunctions_4_3_compatibility.cpp
@@ -95,72 +95,94 @@ QOpenGLFunctions_4_3_Compatibility::QOpenGLFunctions_4_3_Compatibility()
QOpenGLFunctions_4_3_Compatibility::~QOpenGLFunctions_4_3_Compatibility()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_5_Core)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_5_Core) {
d_1_5_Core->refs.deref();
- Q_ASSERT(d_1_5_Core->refs.load());
- if (d_2_0_Core)
+ Q_ASSERT(d_1_5_Core->refs.load());
+ }
+ if (d_2_0_Core) {
d_2_0_Core->refs.deref();
- Q_ASSERT(d_2_0_Core->refs.load());
- if (d_2_1_Core)
+ Q_ASSERT(d_2_0_Core->refs.load());
+ }
+ if (d_2_1_Core) {
d_2_1_Core->refs.deref();
- Q_ASSERT(d_2_1_Core->refs.load());
- if (d_3_0_Core)
+ Q_ASSERT(d_2_1_Core->refs.load());
+ }
+ if (d_3_0_Core) {
d_3_0_Core->refs.deref();
- Q_ASSERT(d_3_0_Core->refs.load());
- if (d_3_1_Core)
+ Q_ASSERT(d_3_0_Core->refs.load());
+ }
+ if (d_3_1_Core) {
d_3_1_Core->refs.deref();
- Q_ASSERT(d_3_1_Core->refs.load());
- if (d_3_2_Core)
+ Q_ASSERT(d_3_1_Core->refs.load());
+ }
+ if (d_3_2_Core) {
d_3_2_Core->refs.deref();
- Q_ASSERT(d_3_2_Core->refs.load());
- if (d_3_3_Core)
+ Q_ASSERT(d_3_2_Core->refs.load());
+ }
+ if (d_3_3_Core) {
d_3_3_Core->refs.deref();
- Q_ASSERT(d_3_3_Core->refs.load());
- if (d_4_0_Core)
+ Q_ASSERT(d_3_3_Core->refs.load());
+ }
+ if (d_4_0_Core) {
d_4_0_Core->refs.deref();
- Q_ASSERT(d_4_0_Core->refs.load());
- if (d_4_1_Core)
+ Q_ASSERT(d_4_0_Core->refs.load());
+ }
+ if (d_4_1_Core) {
d_4_1_Core->refs.deref();
- Q_ASSERT(d_4_1_Core->refs.load());
- if (d_4_2_Core)
+ Q_ASSERT(d_4_1_Core->refs.load());
+ }
+ if (d_4_2_Core) {
d_4_2_Core->refs.deref();
- Q_ASSERT(d_4_2_Core->refs.load());
- if (d_4_3_Core)
+ Q_ASSERT(d_4_2_Core->refs.load());
+ }
+ if (d_4_3_Core) {
d_4_3_Core->refs.deref();
- Q_ASSERT(d_4_3_Core->refs.load());
- if (d_1_0_Deprecated)
+ Q_ASSERT(d_4_3_Core->refs.load());
+ }
+ if (d_1_0_Deprecated) {
d_1_0_Deprecated->refs.deref();
- Q_ASSERT(d_1_0_Deprecated->refs.load());
- if (d_1_1_Deprecated)
+ Q_ASSERT(d_1_0_Deprecated->refs.load());
+ }
+ if (d_1_1_Deprecated) {
d_1_1_Deprecated->refs.deref();
- Q_ASSERT(d_1_1_Deprecated->refs.load());
- if (d_1_2_Deprecated)
+ Q_ASSERT(d_1_1_Deprecated->refs.load());
+ }
+ if (d_1_2_Deprecated) {
d_1_2_Deprecated->refs.deref();
- Q_ASSERT(d_1_2_Deprecated->refs.load());
- if (d_1_3_Deprecated)
+ Q_ASSERT(d_1_2_Deprecated->refs.load());
+ }
+ if (d_1_3_Deprecated) {
d_1_3_Deprecated->refs.deref();
- Q_ASSERT(d_1_3_Deprecated->refs.load());
- if (d_1_4_Deprecated)
+ Q_ASSERT(d_1_3_Deprecated->refs.load());
+ }
+ if (d_1_4_Deprecated) {
d_1_4_Deprecated->refs.deref();
- Q_ASSERT(d_1_4_Deprecated->refs.load());
- if (d_3_3_Deprecated)
+ Q_ASSERT(d_1_4_Deprecated->refs.load());
+ }
+ if (d_3_3_Deprecated) {
d_3_3_Deprecated->refs.deref();
- Q_ASSERT(d_3_3_Deprecated->refs.load());
+ Q_ASSERT(d_3_3_Deprecated->refs.load());
+ }
}
bool QOpenGLFunctions_4_3_Compatibility::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_4_3_compatibility.h b/src/gui/opengl/qopenglfunctions_4_3_compatibility.h
index 33d3065500..515467a38d 100644
--- a/src/gui/opengl/qopenglfunctions_4_3_compatibility.h
+++ b/src/gui/opengl/qopenglfunctions_4_3_compatibility.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_4_3_COMPATIBILITY_H
#define QOPENGLVERSIONFUNCTIONS_4_3_COMPATIBILITY_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_4_3_core.cpp b/src/gui/opengl/qopenglfunctions_4_3_core.cpp
index d3f988ba0d..95e2d7bc43 100644
--- a/src/gui/opengl/qopenglfunctions_4_3_core.cpp
+++ b/src/gui/opengl/qopenglfunctions_4_3_core.cpp
@@ -88,54 +88,70 @@ QOpenGLFunctions_4_3_Core::QOpenGLFunctions_4_3_Core()
QOpenGLFunctions_4_3_Core::~QOpenGLFunctions_4_3_Core()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_5_Core)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_5_Core) {
d_1_5_Core->refs.deref();
- Q_ASSERT(d_1_5_Core->refs.load());
- if (d_2_0_Core)
+ Q_ASSERT(d_1_5_Core->refs.load());
+ }
+ if (d_2_0_Core) {
d_2_0_Core->refs.deref();
- Q_ASSERT(d_2_0_Core->refs.load());
- if (d_2_1_Core)
+ Q_ASSERT(d_2_0_Core->refs.load());
+ }
+ if (d_2_1_Core) {
d_2_1_Core->refs.deref();
- Q_ASSERT(d_2_1_Core->refs.load());
- if (d_3_0_Core)
+ Q_ASSERT(d_2_1_Core->refs.load());
+ }
+ if (d_3_0_Core) {
d_3_0_Core->refs.deref();
- Q_ASSERT(d_3_0_Core->refs.load());
- if (d_3_1_Core)
+ Q_ASSERT(d_3_0_Core->refs.load());
+ }
+ if (d_3_1_Core) {
d_3_1_Core->refs.deref();
- Q_ASSERT(d_3_1_Core->refs.load());
- if (d_3_2_Core)
+ Q_ASSERT(d_3_1_Core->refs.load());
+ }
+ if (d_3_2_Core) {
d_3_2_Core->refs.deref();
- Q_ASSERT(d_3_2_Core->refs.load());
- if (d_3_3_Core)
+ Q_ASSERT(d_3_2_Core->refs.load());
+ }
+ if (d_3_3_Core) {
d_3_3_Core->refs.deref();
- Q_ASSERT(d_3_3_Core->refs.load());
- if (d_4_0_Core)
+ Q_ASSERT(d_3_3_Core->refs.load());
+ }
+ if (d_4_0_Core) {
d_4_0_Core->refs.deref();
- Q_ASSERT(d_4_0_Core->refs.load());
- if (d_4_1_Core)
+ Q_ASSERT(d_4_0_Core->refs.load());
+ }
+ if (d_4_1_Core) {
d_4_1_Core->refs.deref();
- Q_ASSERT(d_4_1_Core->refs.load());
- if (d_4_2_Core)
+ Q_ASSERT(d_4_1_Core->refs.load());
+ }
+ if (d_4_2_Core) {
d_4_2_Core->refs.deref();
- Q_ASSERT(d_4_2_Core->refs.load());
- if (d_4_3_Core)
+ Q_ASSERT(d_4_2_Core->refs.load());
+ }
+ if (d_4_3_Core) {
d_4_3_Core->refs.deref();
- Q_ASSERT(d_4_3_Core->refs.load());
+ Q_ASSERT(d_4_3_Core->refs.load());
+ }
}
bool QOpenGLFunctions_4_3_Core::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_4_3_core.h b/src/gui/opengl/qopenglfunctions_4_3_core.h
index 7e18292bb0..4a700c36d7 100644
--- a/src/gui/opengl/qopenglfunctions_4_3_core.h
+++ b/src/gui/opengl/qopenglfunctions_4_3_core.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_4_3_CORE_H
#define QOPENGLVERSIONFUNCTIONS_4_3_CORE_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_4_4_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_4_compatibility.cpp
index 8cbb94c1a1..a33efd0b95 100644
--- a/src/gui/opengl/qopenglfunctions_4_4_compatibility.cpp
+++ b/src/gui/opengl/qopenglfunctions_4_4_compatibility.cpp
@@ -95,75 +95,98 @@ QOpenGLFunctions_4_4_Compatibility::QOpenGLFunctions_4_4_Compatibility()
QOpenGLFunctions_4_4_Compatibility::~QOpenGLFunctions_4_4_Compatibility()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_5_Core)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_5_Core) {
d_1_5_Core->refs.deref();
- Q_ASSERT(d_1_5_Core->refs.load());
- if (d_2_0_Core)
+ Q_ASSERT(d_1_5_Core->refs.load());
+ }
+ if (d_2_0_Core) {
d_2_0_Core->refs.deref();
- Q_ASSERT(d_2_0_Core->refs.load());
- if (d_2_1_Core)
+ Q_ASSERT(d_2_0_Core->refs.load());
+ }
+ if (d_2_1_Core) {
d_2_1_Core->refs.deref();
- Q_ASSERT(d_2_1_Core->refs.load());
- if (d_3_0_Core)
+ Q_ASSERT(d_2_1_Core->refs.load());
+ }
+ if (d_3_0_Core) {
d_3_0_Core->refs.deref();
- Q_ASSERT(d_3_0_Core->refs.load());
- if (d_3_1_Core)
+ Q_ASSERT(d_3_0_Core->refs.load());
+ }
+ if (d_3_1_Core) {
d_3_1_Core->refs.deref();
- Q_ASSERT(d_3_1_Core->refs.load());
- if (d_3_2_Core)
+ Q_ASSERT(d_3_1_Core->refs.load());
+ }
+ if (d_3_2_Core) {
d_3_2_Core->refs.deref();
- Q_ASSERT(d_3_2_Core->refs.load());
- if (d_3_3_Core)
+ Q_ASSERT(d_3_2_Core->refs.load());
+ }
+ if (d_3_3_Core) {
d_3_3_Core->refs.deref();
- Q_ASSERT(d_3_3_Core->refs.load());
- if (d_4_0_Core)
+ Q_ASSERT(d_3_3_Core->refs.load());
+ }
+ if (d_4_0_Core) {
d_4_0_Core->refs.deref();
- Q_ASSERT(d_4_0_Core->refs.load());
- if (d_4_1_Core)
+ Q_ASSERT(d_4_0_Core->refs.load());
+ }
+ if (d_4_1_Core) {
d_4_1_Core->refs.deref();
- Q_ASSERT(d_4_1_Core->refs.load());
- if (d_4_2_Core)
+ Q_ASSERT(d_4_1_Core->refs.load());
+ }
+ if (d_4_2_Core) {
d_4_2_Core->refs.deref();
- Q_ASSERT(d_4_2_Core->refs.load());
- if (d_4_3_Core)
+ Q_ASSERT(d_4_2_Core->refs.load());
+ }
+ if (d_4_3_Core) {
d_4_3_Core->refs.deref();
- Q_ASSERT(d_4_3_Core->refs.load());
- if (d_4_4_Core)
+ Q_ASSERT(d_4_3_Core->refs.load());
+ }
+ if (d_4_4_Core) {
d_4_4_Core->refs.deref();
- Q_ASSERT(d_4_4_Core->refs.load());
- if (d_1_0_Deprecated)
+ Q_ASSERT(d_4_4_Core->refs.load());
+ }
+ if (d_1_0_Deprecated) {
d_1_0_Deprecated->refs.deref();
- Q_ASSERT(d_1_0_Deprecated->refs.load());
- if (d_1_1_Deprecated)
+ Q_ASSERT(d_1_0_Deprecated->refs.load());
+ }
+ if (d_1_1_Deprecated) {
d_1_1_Deprecated->refs.deref();
- Q_ASSERT(d_1_1_Deprecated->refs.load());
- if (d_1_2_Deprecated)
+ Q_ASSERT(d_1_1_Deprecated->refs.load());
+ }
+ if (d_1_2_Deprecated) {
d_1_2_Deprecated->refs.deref();
- Q_ASSERT(d_1_2_Deprecated->refs.load());
- if (d_1_3_Deprecated)
+ Q_ASSERT(d_1_2_Deprecated->refs.load());
+ }
+ if (d_1_3_Deprecated) {
d_1_3_Deprecated->refs.deref();
- Q_ASSERT(d_1_3_Deprecated->refs.load());
- if (d_1_4_Deprecated)
+ Q_ASSERT(d_1_3_Deprecated->refs.load());
+ }
+ if (d_1_4_Deprecated) {
d_1_4_Deprecated->refs.deref();
- Q_ASSERT(d_1_4_Deprecated->refs.load());
- if (d_3_3_Deprecated)
+ Q_ASSERT(d_1_4_Deprecated->refs.load());
+ }
+ if (d_3_3_Deprecated) {
d_3_3_Deprecated->refs.deref();
- Q_ASSERT(d_3_3_Deprecated->refs.load());
+ Q_ASSERT(d_3_3_Deprecated->refs.load());
+ }
}
bool QOpenGLFunctions_4_4_Compatibility::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_4_4_compatibility.h b/src/gui/opengl/qopenglfunctions_4_4_compatibility.h
index d369ff27ff..f2d640cdaf 100644
--- a/src/gui/opengl/qopenglfunctions_4_4_compatibility.h
+++ b/src/gui/opengl/qopenglfunctions_4_4_compatibility.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_4_4_COMPATIBILITY_H
#define QOPENGLVERSIONFUNCTIONS_4_4_COMPATIBILITY_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_4_4_core.cpp b/src/gui/opengl/qopenglfunctions_4_4_core.cpp
index 95bfc3a438..019a70087a 100644
--- a/src/gui/opengl/qopenglfunctions_4_4_core.cpp
+++ b/src/gui/opengl/qopenglfunctions_4_4_core.cpp
@@ -89,57 +89,74 @@ QOpenGLFunctions_4_4_Core::QOpenGLFunctions_4_4_Core()
QOpenGLFunctions_4_4_Core::~QOpenGLFunctions_4_4_Core()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_5_Core)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_5_Core) {
d_1_5_Core->refs.deref();
- Q_ASSERT(d_1_5_Core->refs.load());
- if (d_2_0_Core)
+ Q_ASSERT(d_1_5_Core->refs.load());
+ }
+ if (d_2_0_Core) {
d_2_0_Core->refs.deref();
- Q_ASSERT(d_2_0_Core->refs.load());
- if (d_2_1_Core)
+ Q_ASSERT(d_2_0_Core->refs.load());
+ }
+ if (d_2_1_Core) {
d_2_1_Core->refs.deref();
- Q_ASSERT(d_2_1_Core->refs.load());
- if (d_3_0_Core)
+ Q_ASSERT(d_2_1_Core->refs.load());
+ }
+ if (d_3_0_Core) {
d_3_0_Core->refs.deref();
- Q_ASSERT(d_3_0_Core->refs.load());
- if (d_3_1_Core)
+ Q_ASSERT(d_3_0_Core->refs.load());
+ }
+ if (d_3_1_Core) {
d_3_1_Core->refs.deref();
- Q_ASSERT(d_3_1_Core->refs.load());
- if (d_3_2_Core)
+ Q_ASSERT(d_3_1_Core->refs.load());
+ }
+ if (d_3_2_Core) {
d_3_2_Core->refs.deref();
- Q_ASSERT(d_3_2_Core->refs.load());
- if (d_3_3_Core)
+ Q_ASSERT(d_3_2_Core->refs.load());
+ }
+ if (d_3_3_Core) {
d_3_3_Core->refs.deref();
- Q_ASSERT(d_3_3_Core->refs.load());
- if (d_4_0_Core)
+ Q_ASSERT(d_3_3_Core->refs.load());
+ }
+ if (d_4_0_Core) {
d_4_0_Core->refs.deref();
- Q_ASSERT(d_4_0_Core->refs.load());
- if (d_4_1_Core)
+ Q_ASSERT(d_4_0_Core->refs.load());
+ }
+ if (d_4_1_Core) {
d_4_1_Core->refs.deref();
- Q_ASSERT(d_4_1_Core->refs.load());
- if (d_4_2_Core)
+ Q_ASSERT(d_4_1_Core->refs.load());
+ }
+ if (d_4_2_Core) {
d_4_2_Core->refs.deref();
- Q_ASSERT(d_4_2_Core->refs.load());
- if (d_4_3_Core)
+ Q_ASSERT(d_4_2_Core->refs.load());
+ }
+ if (d_4_3_Core) {
d_4_3_Core->refs.deref();
- Q_ASSERT(d_4_3_Core->refs.load());
- if (d_4_4_Core)
+ Q_ASSERT(d_4_3_Core->refs.load());
+ }
+ if (d_4_4_Core) {
d_4_4_Core->refs.deref();
- Q_ASSERT(d_4_4_Core->refs.load());
+ Q_ASSERT(d_4_4_Core->refs.load());
+ }
}
bool QOpenGLFunctions_4_4_Core::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_4_4_core.h b/src/gui/opengl/qopenglfunctions_4_4_core.h
index e508478c50..bcb7383a9e 100644
--- a/src/gui/opengl/qopenglfunctions_4_4_core.h
+++ b/src/gui/opengl/qopenglfunctions_4_4_core.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_4_4_CORE_H
#define QOPENGLVERSIONFUNCTIONS_4_4_CORE_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_4_5_compatibility.cpp b/src/gui/opengl/qopenglfunctions_4_5_compatibility.cpp
index 81ee8559a5..f9d2bb9ceb 100644
--- a/src/gui/opengl/qopenglfunctions_4_5_compatibility.cpp
+++ b/src/gui/opengl/qopenglfunctions_4_5_compatibility.cpp
@@ -97,81 +97,106 @@ QOpenGLFunctions_4_5_Compatibility::QOpenGLFunctions_4_5_Compatibility()
QOpenGLFunctions_4_5_Compatibility::~QOpenGLFunctions_4_5_Compatibility()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_5_Core)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_5_Core) {
d_1_5_Core->refs.deref();
- Q_ASSERT(d_1_5_Core->refs.load());
- if (d_2_0_Core)
+ Q_ASSERT(d_1_5_Core->refs.load());
+ }
+ if (d_2_0_Core) {
d_2_0_Core->refs.deref();
- Q_ASSERT(d_2_0_Core->refs.load());
- if (d_2_1_Core)
+ Q_ASSERT(d_2_0_Core->refs.load());
+ }
+ if (d_2_1_Core) {
d_2_1_Core->refs.deref();
- Q_ASSERT(d_2_1_Core->refs.load());
- if (d_3_0_Core)
+ Q_ASSERT(d_2_1_Core->refs.load());
+ }
+ if (d_3_0_Core) {
d_3_0_Core->refs.deref();
- Q_ASSERT(d_3_0_Core->refs.load());
- if (d_3_1_Core)
+ Q_ASSERT(d_3_0_Core->refs.load());
+ }
+ if (d_3_1_Core) {
d_3_1_Core->refs.deref();
- Q_ASSERT(d_3_1_Core->refs.load());
- if (d_3_2_Core)
+ Q_ASSERT(d_3_1_Core->refs.load());
+ }
+ if (d_3_2_Core) {
d_3_2_Core->refs.deref();
- Q_ASSERT(d_3_2_Core->refs.load());
- if (d_3_3_Core)
+ Q_ASSERT(d_3_2_Core->refs.load());
+ }
+ if (d_3_3_Core) {
d_3_3_Core->refs.deref();
- Q_ASSERT(d_3_3_Core->refs.load());
- if (d_4_0_Core)
+ Q_ASSERT(d_3_3_Core->refs.load());
+ }
+ if (d_4_0_Core) {
d_4_0_Core->refs.deref();
- Q_ASSERT(d_4_0_Core->refs.load());
- if (d_4_1_Core)
+ Q_ASSERT(d_4_0_Core->refs.load());
+ }
+ if (d_4_1_Core) {
d_4_1_Core->refs.deref();
- Q_ASSERT(d_4_1_Core->refs.load());
- if (d_4_2_Core)
+ Q_ASSERT(d_4_1_Core->refs.load());
+ }
+ if (d_4_2_Core) {
d_4_2_Core->refs.deref();
- Q_ASSERT(d_4_2_Core->refs.load());
- if (d_4_3_Core)
+ Q_ASSERT(d_4_2_Core->refs.load());
+ }
+ if (d_4_3_Core) {
d_4_3_Core->refs.deref();
- Q_ASSERT(d_4_3_Core->refs.load());
- if (d_4_4_Core)
+ Q_ASSERT(d_4_3_Core->refs.load());
+ }
+ if (d_4_4_Core) {
d_4_4_Core->refs.deref();
- Q_ASSERT(d_4_4_Core->refs.load());
- if (d_4_5_Core)
+ Q_ASSERT(d_4_4_Core->refs.load());
+ }
+ if (d_4_5_Core) {
d_4_5_Core->refs.deref();
- Q_ASSERT(d_4_5_Core->refs.load());
- if (d_1_0_Deprecated)
+ Q_ASSERT(d_4_5_Core->refs.load());
+ }
+ if (d_1_0_Deprecated) {
d_1_0_Deprecated->refs.deref();
- Q_ASSERT(d_1_0_Deprecated->refs.load());
- if (d_1_1_Deprecated)
+ Q_ASSERT(d_1_0_Deprecated->refs.load());
+ }
+ if (d_1_1_Deprecated) {
d_1_1_Deprecated->refs.deref();
- Q_ASSERT(d_1_1_Deprecated->refs.load());
- if (d_1_2_Deprecated)
+ Q_ASSERT(d_1_1_Deprecated->refs.load());
+ }
+ if (d_1_2_Deprecated) {
d_1_2_Deprecated->refs.deref();
- Q_ASSERT(d_1_2_Deprecated->refs.load());
- if (d_1_3_Deprecated)
+ Q_ASSERT(d_1_2_Deprecated->refs.load());
+ }
+ if (d_1_3_Deprecated) {
d_1_3_Deprecated->refs.deref();
- Q_ASSERT(d_1_3_Deprecated->refs.load());
- if (d_1_4_Deprecated)
+ Q_ASSERT(d_1_3_Deprecated->refs.load());
+ }
+ if (d_1_4_Deprecated) {
d_1_4_Deprecated->refs.deref();
- Q_ASSERT(d_1_4_Deprecated->refs.load());
- if (d_3_3_Deprecated)
+ Q_ASSERT(d_1_4_Deprecated->refs.load());
+ }
+ if (d_3_3_Deprecated) {
d_3_3_Deprecated->refs.deref();
- Q_ASSERT(d_3_3_Deprecated->refs.load());
- if (d_4_5_Deprecated)
+ Q_ASSERT(d_3_3_Deprecated->refs.load());
+ }
+ if (d_4_5_Deprecated) {
d_4_5_Deprecated->refs.deref();
- Q_ASSERT(d_4_5_Deprecated->refs.load());
+ Q_ASSERT(d_4_5_Deprecated->refs.load());
+ }
}
bool QOpenGLFunctions_4_5_Compatibility::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_4_5_compatibility.h b/src/gui/opengl/qopenglfunctions_4_5_compatibility.h
index 1c50dafd65..b164538686 100644
--- a/src/gui/opengl/qopenglfunctions_4_5_compatibility.h
+++ b/src/gui/opengl/qopenglfunctions_4_5_compatibility.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_4_5_COMPATIBILITY_H
#define QOPENGLVERSIONFUNCTIONS_4_5_COMPATIBILITY_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_4_5_core.cpp b/src/gui/opengl/qopenglfunctions_4_5_core.cpp
index 2fdb9ef855..27c0223cf9 100644
--- a/src/gui/opengl/qopenglfunctions_4_5_core.cpp
+++ b/src/gui/opengl/qopenglfunctions_4_5_core.cpp
@@ -90,60 +90,78 @@ QOpenGLFunctions_4_5_Core::QOpenGLFunctions_4_5_Core()
QOpenGLFunctions_4_5_Core::~QOpenGLFunctions_4_5_Core()
{
- if (d_1_0_Core)
+ if (d_1_0_Core) {
d_1_0_Core->refs.deref();
- Q_ASSERT(d_1_0_Core->refs.load());
- if (d_1_1_Core)
+ Q_ASSERT(d_1_0_Core->refs.load());
+ }
+ if (d_1_1_Core) {
d_1_1_Core->refs.deref();
- Q_ASSERT(d_1_1_Core->refs.load());
- if (d_1_2_Core)
+ Q_ASSERT(d_1_1_Core->refs.load());
+ }
+ if (d_1_2_Core) {
d_1_2_Core->refs.deref();
- Q_ASSERT(d_1_2_Core->refs.load());
- if (d_1_3_Core)
+ Q_ASSERT(d_1_2_Core->refs.load());
+ }
+ if (d_1_3_Core) {
d_1_3_Core->refs.deref();
- Q_ASSERT(d_1_3_Core->refs.load());
- if (d_1_4_Core)
+ Q_ASSERT(d_1_3_Core->refs.load());
+ }
+ if (d_1_4_Core) {
d_1_4_Core->refs.deref();
- Q_ASSERT(d_1_4_Core->refs.load());
- if (d_1_5_Core)
+ Q_ASSERT(d_1_4_Core->refs.load());
+ }
+ if (d_1_5_Core) {
d_1_5_Core->refs.deref();
- Q_ASSERT(d_1_5_Core->refs.load());
- if (d_2_0_Core)
+ Q_ASSERT(d_1_5_Core->refs.load());
+ }
+ if (d_2_0_Core) {
d_2_0_Core->refs.deref();
- Q_ASSERT(d_2_0_Core->refs.load());
- if (d_2_1_Core)
+ Q_ASSERT(d_2_0_Core->refs.load());
+ }
+ if (d_2_1_Core) {
d_2_1_Core->refs.deref();
- Q_ASSERT(d_2_1_Core->refs.load());
- if (d_3_0_Core)
+ Q_ASSERT(d_2_1_Core->refs.load());
+ }
+ if (d_3_0_Core) {
d_3_0_Core->refs.deref();
- Q_ASSERT(d_3_0_Core->refs.load());
- if (d_3_1_Core)
+ Q_ASSERT(d_3_0_Core->refs.load());
+ }
+ if (d_3_1_Core) {
d_3_1_Core->refs.deref();
- Q_ASSERT(d_3_1_Core->refs.load());
- if (d_3_2_Core)
+ Q_ASSERT(d_3_1_Core->refs.load());
+ }
+ if (d_3_2_Core) {
d_3_2_Core->refs.deref();
- Q_ASSERT(d_3_2_Core->refs.load());
- if (d_3_3_Core)
+ Q_ASSERT(d_3_2_Core->refs.load());
+ }
+ if (d_3_3_Core) {
d_3_3_Core->refs.deref();
- Q_ASSERT(d_3_3_Core->refs.load());
- if (d_4_0_Core)
+ Q_ASSERT(d_3_3_Core->refs.load());
+ }
+ if (d_4_0_Core) {
d_4_0_Core->refs.deref();
- Q_ASSERT(d_4_0_Core->refs.load());
- if (d_4_1_Core)
+ Q_ASSERT(d_4_0_Core->refs.load());
+ }
+ if (d_4_1_Core) {
d_4_1_Core->refs.deref();
- Q_ASSERT(d_4_1_Core->refs.load());
- if (d_4_2_Core)
+ Q_ASSERT(d_4_1_Core->refs.load());
+ }
+ if (d_4_2_Core) {
d_4_2_Core->refs.deref();
- Q_ASSERT(d_4_2_Core->refs.load());
- if (d_4_3_Core)
+ Q_ASSERT(d_4_2_Core->refs.load());
+ }
+ if (d_4_3_Core) {
d_4_3_Core->refs.deref();
- Q_ASSERT(d_4_3_Core->refs.load());
- if (d_4_4_Core)
+ Q_ASSERT(d_4_3_Core->refs.load());
+ }
+ if (d_4_4_Core) {
d_4_4_Core->refs.deref();
- Q_ASSERT(d_4_4_Core->refs.load());
- if (d_4_5_Core)
+ Q_ASSERT(d_4_4_Core->refs.load());
+ }
+ if (d_4_5_Core) {
d_4_5_Core->refs.deref();
- Q_ASSERT(d_4_5_Core->refs.load());
+ Q_ASSERT(d_4_5_Core->refs.load());
+ }
}
bool QOpenGLFunctions_4_5_Core::initializeOpenGLFunctions()
diff --git a/src/gui/opengl/qopenglfunctions_4_5_core.h b/src/gui/opengl/qopenglfunctions_4_5_core.h
index b086e63917..0940d8cf61 100644
--- a/src/gui/opengl/qopenglfunctions_4_5_core.h
+++ b/src/gui/opengl/qopenglfunctions_4_5_core.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_4_5_CORE_H
#define QOPENGLVERSIONFUNCTIONS_4_5_CORE_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglfunctions_es2.h b/src/gui/opengl/qopenglfunctions_es2.h
index 45cb329a87..3b7d2806ea 100644
--- a/src/gui/opengl/qopenglfunctions_es2.h
+++ b/src/gui/opengl/qopenglfunctions_es2.h
@@ -40,7 +40,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_ES2_H
#define QOPENGLVERSIONFUNCTIONS_ES2_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if defined(QT_OPENGL_ES_2) || defined(Q_QDOC)
diff --git a/src/gui/opengl/qopenglgradientcache_p.h b/src/gui/opengl/qopenglgradientcache_p.h
index 12423452f2..a2ed85c061 100644
--- a/src/gui/opengl/qopenglgradientcache_p.h
+++ b/src/gui/opengl/qopenglgradientcache_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QMultiHash>
#include <QObject>
#include <private/qopenglcontext_p.h>
diff --git a/src/gui/opengl/qopenglpaintdevice.cpp b/src/gui/opengl/qopenglpaintdevice.cpp
index 75f09d6031..e539ee0e31 100644
--- a/src/gui/opengl/qopenglpaintdevice.cpp
+++ b/src/gui/opengl/qopenglpaintdevice.cpp
@@ -137,7 +137,7 @@ QOpenGLPaintDevice::QOpenGLPaintDevice(const QSize &size)
\sa QOpenGLContext::currentContext()
*/
QOpenGLPaintDevice::QOpenGLPaintDevice(int width, int height)
- : d_ptr(new QOpenGLPaintDevicePrivate(QSize(width, height)))
+ : QOpenGLPaintDevice(QSize(width, height))
{
}
diff --git a/src/gui/opengl/qopenglpaintdevice.h b/src/gui/opengl/qopenglpaintdevice.h
index dffa68c29e..27b7fba84f 100644
--- a/src/gui/opengl/qopenglpaintdevice.h
+++ b/src/gui/opengl/qopenglpaintdevice.h
@@ -40,7 +40,7 @@
#ifndef QOPENGLPAINTDEVICE_H
#define QOPENGLPAINTDEVICE_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#ifndef QT_NO_OPENGL
diff --git a/src/gui/opengl/qopenglpaintdevice_p.h b/src/gui/opengl/qopenglpaintdevice_p.h
index 78e6b7a464..3683ebebac 100644
--- a/src/gui/opengl/qopenglpaintdevice_p.h
+++ b/src/gui/opengl/qopenglpaintdevice_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <qopenglpaintdevice.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp
index d93871c99b..5c05a05d80 100644
--- a/src/gui/opengl/qopenglpaintengine.cpp
+++ b/src/gui/opengl/qopenglpaintengine.cpp
@@ -1012,11 +1012,11 @@ void QOpenGL2PaintEngineExPrivate::fillStencilWithVertexArray(const float *data,
funcs.glStencilMask(0xff); // Enable stencil writes
if (dirtyStencilRegion.intersects(currentScissorBounds)) {
- QVector<QRect> clearRegion = dirtyStencilRegion.intersected(currentScissorBounds).rects();
+ const QRegion clearRegion = dirtyStencilRegion.intersected(currentScissorBounds);
funcs.glClearStencil(0); // Clear to zero
- for (int i = 0; i < clearRegion.size(); ++i) {
+ for (const QRect &rect : clearRegion) {
#ifndef QT_GL_NO_SCISSOR_TEST
- setScissor(clearRegion.at(i));
+ setScissor(rect);
#endif
funcs.glClear(GL_STENCIL_BUFFER_BIT);
}
diff --git a/src/gui/opengl/qopenglpaintengine_p.h b/src/gui/opengl/qopenglpaintengine_p.h
index c9f328203c..807efb1ec2 100644
--- a/src/gui/opengl/qopenglpaintengine_p.h
+++ b/src/gui/opengl/qopenglpaintengine_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QDebug>
#include <qopenglpaintdevice.h>
diff --git a/src/gui/opengl/qopenglpixeltransferoptions.h b/src/gui/opengl/qopenglpixeltransferoptions.h
index 81aa588ae4..2fc52b82d8 100644
--- a/src/gui/opengl/qopenglpixeltransferoptions.h
+++ b/src/gui/opengl/qopenglpixeltransferoptions.h
@@ -40,7 +40,7 @@
#ifndef QOPENGLPIXELUPLOADOPTIONS_H
#define QOPENGLPIXELUPLOADOPTIONS_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL)
diff --git a/src/gui/opengl/qopenglqueryhelper_p.h b/src/gui/opengl/qopenglqueryhelper_p.h
index be36c32217..60dbf9c743 100644
--- a/src/gui/opengl/qopenglqueryhelper_p.h
+++ b/src/gui/opengl/qopenglqueryhelper_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtGui/private/qtguiglobal_p.h>
#if !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglshadercache_p.h b/src/gui/opengl/qopenglshadercache_p.h
index 5070874d83..b4d1d64721 100644
--- a/src/gui/opengl/qopenglshadercache_p.h
+++ b/src/gui/opengl/qopenglshadercache_p.h
@@ -51,7 +51,7 @@
#ifndef QOPENGLSHADERCACHE_P_H
#define QOPENGLSHADERCACHE_P_H
-#include <QtCore/qglobal.h>
+#include <QtGui/private/qtguiglobal_p.h>
#if defined(QT_MEEGO_EXPERIMENTAL_SHADERCACHE) && defined(QT_OPENGL_ES_2)
# include "qopenglshadercache_meego_p.h"
diff --git a/src/gui/opengl/qopenglshaderprogram.cpp b/src/gui/opengl/qopenglshaderprogram.cpp
index 4134513210..f076e10e20 100644
--- a/src/gui/opengl/qopenglshaderprogram.cpp
+++ b/src/gui/opengl/qopenglshaderprogram.cpp
@@ -337,9 +337,10 @@ bool QOpenGLShaderPrivate::compile(QOpenGLShader *q)
// Dump the source code if we got it
if (sourceCodeBuffer) {
- qWarning("*** Problematic %s shader source code ***", type);
- qWarning() << qPrintable(QString::fromLatin1(sourceCodeBuffer));
- qWarning("***");
+ qWarning("*** Problematic %s shader source code ***\n"
+ "%ls\n"
+ "***",
+ type, qUtf16Printable(QString::fromLatin1(sourceCodeBuffer)));
}
// Cleanup
@@ -1215,8 +1216,7 @@ int QOpenGLShaderProgram::attributeLocation(const char *name) const
if (d->linked && d->programGuard && d->programGuard->id()) {
return d->glfuncs->glGetAttribLocation(d->programGuard->id(), name);
} else {
- qWarning() << "QOpenGLShaderProgram::attributeLocation(" << name
- << "): shader program is not linked";
+ qWarning("QOpenGLShaderProgram::attributeLocation(%s): shader program is not linked", name);
return -1;
}
}
@@ -1479,7 +1479,7 @@ void QOpenGLShaderProgram::setAttributeValue
Q_D(QOpenGLShaderProgram);
Q_UNUSED(d);
if (rows < 1 || rows > 4) {
- qWarning() << "QOpenGLShaderProgram::setAttributeValue: rows" << rows << "not supported";
+ qWarning("QOpenGLShaderProgram::setAttributeValue: rows %d not supported", rows);
return;
}
if (location != -1) {
@@ -1891,8 +1891,7 @@ int QOpenGLShaderProgram::uniformLocation(const char *name) const
if (d->linked && d->programGuard && d->programGuard->id()) {
return d->glfuncs->glGetUniformLocation(d->programGuard->id(), name);
} else {
- qWarning() << "QOpenGLShaderProgram::uniformLocation(" << name
- << "): shader program is not linked";
+ qWarning("QOpenGLShaderProgram::uniformLocation(%s): shader program is not linked", name);
return -1;
}
}
@@ -2819,7 +2818,7 @@ void QOpenGLShaderProgram::setUniformValueArray(int location, const GLfloat *val
else if (tupleSize == 4)
d->glfuncs->glUniform4fv(location, count, values);
else
- qWarning() << "QOpenGLShaderProgram::setUniformValue: size" << tupleSize << "not supported";
+ qWarning("QOpenGLShaderProgram::setUniformValue: size %d not supported", tupleSize);
}
}
diff --git a/src/gui/opengl/qopenglshaderprogram.h b/src/gui/opengl/qopenglshaderprogram.h
index da20228e51..2da359c535 100644
--- a/src/gui/opengl/qopenglshaderprogram.h
+++ b/src/gui/opengl/qopenglshaderprogram.h
@@ -40,7 +40,7 @@
#ifndef QOPENGLSHADERPROGRAM_H
#define QOPENGLSHADERPROGRAM_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#ifndef QT_NO_OPENGL
diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp
index 1db61b7ca1..0a46eea85d 100644
--- a/src/gui/opengl/qopengltexture.cpp
+++ b/src/gui/opengl/qopengltexture.cpp
@@ -2216,7 +2216,7 @@ QOpenGLTexture::QOpenGLTexture(Target target)
OpenGL context.
*/
QOpenGLTexture::QOpenGLTexture(const QImage& image, MipMapGeneration genMipMaps)
- : d_ptr(new QOpenGLTexturePrivate(QOpenGLTexture::Target2D, this))
+ : QOpenGLTexture(QOpenGLTexture::Target2D)
{
setData(image, genMipMaps);
}
diff --git a/src/gui/opengl/qopengltexture.h b/src/gui/opengl/qopengltexture.h
index 8c32fcef26..0a948488a6 100644
--- a/src/gui/opengl/qopengltexture.h
+++ b/src/gui/opengl/qopengltexture.h
@@ -40,7 +40,7 @@
#ifndef QOPENGLABSTRACTTEXTURE_H
#define QOPENGLABSTRACTTEXTURE_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#ifndef QT_NO_OPENGL
diff --git a/src/gui/opengl/qopengltexture_p.h b/src/gui/opengl/qopengltexture_p.h
index e9ada026ed..9914316bb4 100644
--- a/src/gui/opengl/qopengltexture_p.h
+++ b/src/gui/opengl/qopengltexture_p.h
@@ -53,6 +53,7 @@
#ifndef QT_NO_OPENGL
+#include <QtGui/private/qtguiglobal_p.h>
#include "private/qobject_p.h"
#include "qopengltexture.h"
#include "qopengl.h"
diff --git a/src/gui/opengl/qopengltextureblitter.cpp b/src/gui/opengl/qopengltextureblitter.cpp
index 18ff0c4acf..2e74afcbc2 100644
--- a/src/gui/opengl/qopengltextureblitter.cpp
+++ b/src/gui/opengl/qopengltextureblitter.cpp
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include "qopengltextureblitter_p.h"
+#include "qopengltextureblitter.h"
#include <QtGui/QOpenGLBuffer>
#include <QtGui/QOpenGLShaderProgram>
@@ -51,6 +51,49 @@
QT_BEGIN_NAMESPACE
+/*!
+ \class QOpenGLTextureBlitter
+ \brief The QOpenGLTextureBlitter class provides a convenient way to draw textured quads via OpenGL.
+ \since 5.8
+ \ingroup painting-3D
+ \inmodule QtGui
+
+ Drawing textured quads, in order to get the contents of a texture
+ onto the screen, is a common operation when developing 2D user
+ interfaces. QOpenGLTextureBlitter provides a convenience class to
+ avoid repeating vertex data, shader sources, buffer and program
+ management and matrix calculations.
+
+ For example, a QOpenGLWidget subclass can do the following to draw
+ the contents rendered into a framebuffer at the pixel position \c{(x, y)}:
+
+ \code
+ void OpenGLWidget::initializeGL()
+ {
+ m_blitter.create();
+ m_fbo = new QOpenGLFramebufferObject(size);
+ }
+
+ void OpenGLWidget::paintGL()
+ {
+ m_fbo->bind();
+ // update offscreen content
+ m_fbo->release();
+
+ m_blitter.bind();
+ const QRect targetRect(QPoint(x, y), m_fbo->size());
+ const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(targetRect, QRect(QPoint(0, 0), m_fbo->size()));
+ m_blitter.blit(m_fbo->texture(), target, QOpenGLTextureBlitter::OriginBottomLeft);
+ m_blitter.release();
+ }
+ \endcode
+
+ The blitter implements GLSL shaders both for GLSL 1.00 (suitable
+ for OpenGL (ES) 2.x and compatibility profiles of newer OpenGL
+ versions) and version 150 (suitable for core profile contexts with
+ OpenGL 3.2 and newer).
+ */
+
static const char vertex_shader150[] =
"#version 150 core\n"
"in vec3 vertexCoord;"
@@ -309,16 +352,44 @@ bool QOpenGLTextureBlitterPrivate::buildProgram(ProgramIndex idx, const char *vs
return true;
}
+/*!
+ Constructs a new QOpenGLTextureBlitter instance.
+
+ \note no graphics resources are initialized in the
+ constructor. This makes it safe to place plain
+ QOpenGLTextureBlitter members into classes because the actual
+ initialization that depends on the OpenGL context happens only in
+ create().
+ */
QOpenGLTextureBlitter::QOpenGLTextureBlitter()
: d_ptr(new QOpenGLTextureBlitterPrivate)
{
}
+/*!
+ Destructs the instance.
+
+ \note When the OpenGL context - or a context sharing resources
+ with it - that was current when calling create() is not current,
+ graphics resources will not be released. Therefore, it is
+ recommended to call destroy() manually instead of relying on the
+ destructor to perform OpenGL resource cleanup.
+ */
QOpenGLTextureBlitter::~QOpenGLTextureBlitter()
{
destroy();
}
+/*!
+ Initializes the graphics resources used by the blitter.
+
+ \return \c true if successful, \c false if there was a
+ failure. Failures can occur when there is no OpenGL context
+ current on the current thread, or when shader compilation fails
+ for some reason.
+
+ \sa isCreated(), destroy()
+ */
bool QOpenGLTextureBlitter::create()
{
QOpenGLContext *currentContext = QOpenGLContext::currentContext();
@@ -358,12 +429,26 @@ bool QOpenGLTextureBlitter::create()
return true;
}
+/*!
+ \return \c true if create() was called and succeeded. \c false otherwise.
+
+ \sa create(), destroy()
+ */
bool QOpenGLTextureBlitter::isCreated() const
{
Q_D(const QOpenGLTextureBlitter);
return d->programs[QOpenGLTextureBlitterPrivate::TEXTURE_2D].glProgram;
}
+/*!
+ Frees all graphics resources held by the blitter. Assumes that
+ the OpenGL context, or another context sharing resources with it,
+ that was current on the thread when invoking create() is current.
+
+ The function has no effect when the blitter is not in created state.
+
+ \sa create()
+ */
void QOpenGLTextureBlitter::destroy()
{
if (!isCreated())
@@ -376,12 +461,29 @@ void QOpenGLTextureBlitter::destroy()
d->vao.reset();
}
+/*!
+ \return \c true when bind() accepts \c GL_TEXTURE_EXTERNAL_OES as
+ its target argument.
+
+ \sa bind(), blit()
+ */
bool QOpenGLTextureBlitter::supportsExternalOESTarget() const
{
QOpenGLContext *ctx = QOpenGLContext::currentContext();
return ctx && ctx->isOpenGLES() && ctx->hasExtension("GL_OES_EGL_image_external");
}
+/*!
+ Binds the graphics resources used by the blitter. This must be
+ called before calling blit(). Code modifying the OpenGL state
+ should be avoided between the call to bind() and blit() because
+ otherwise conflicts may arise.
+
+ \a target is the texture target for the source texture and must be
+ either \c GL_TEXTURE_2D or \c GL_OES_EGL_image_external.
+
+ \sa release(), blit()
+ */
void QOpenGLTextureBlitter::bind(GLenum target)
{
Q_D(QOpenGLTextureBlitter);
@@ -404,6 +506,11 @@ void QOpenGLTextureBlitter::bind(GLenum target)
d->textureBuffer.release();
}
+/*!
+ Unbinds the graphics resources used by the blitter.
+
+ \sa bind()
+ */
void QOpenGLTextureBlitter::release()
{
Q_D(QOpenGLTextureBlitter);
@@ -412,18 +519,64 @@ void QOpenGLTextureBlitter::release()
d->vao->release();
}
-void QOpenGLTextureBlitter::setSwizzleRB(bool swizzle)
+/*!
+ Enables or disables swizzling for the red and blue color
+ channels. An BGRA to RGBA conversion (occurring in the shader on
+ the GPU, instead of a slow CPU-side transformation) can be useful
+ when the source texture contains data from a QImage with a format
+ like QImage::Format_ARGB32 which maps to BGRA on little endian
+ systems.
+
+ By default the red-blue swizzle is disabled since this is what a
+ texture attached to an framebuffer object or a texture based on a
+ byte ordered QImage format (like QImage::Format_RGBA8888) needs.
+ */
+void QOpenGLTextureBlitter::setRedBlueSwizzle(bool swizzle)
{
Q_D(QOpenGLTextureBlitter);
d->swizzle = swizzle;
}
+/*!
+ Changes the opacity. The default opacity is 1.0.
+
+ \note the blitter does not alter the blend state. It is up to the
+ caller of blit() to ensure the correct blend settings are active.
+ */
void QOpenGLTextureBlitter::setOpacity(float opacity)
{
Q_D(QOpenGLTextureBlitter);
d->opacity = opacity;
}
+/*!
+ \enum QOpenGLTextureBlitter::Origin
+
+ \value OriginBottomLeft Indicates that the data in the texture
+ follows the OpenGL convention of coordinate systems, meaning Y is
+ running from bottom to top.
+
+ \value OriginTopLeft Indicates that the data in the texture has Y
+ running from top to bottom, which is typical with regular,
+ unflipped image data.
+
+ \sa blit()
+ */
+
+/*!
+ Performs the blit with the source texture \a texture.
+
+ \a targetTransform specifies the transformation applied. This is
+ usually generated by the targetTransform() helper function.
+
+ \a sourceOrigin specifies if the image data needs flipping. When
+ \a texture corresponds to a texture attached to an FBO pass
+ OriginBottomLeft. On the other hand, when \a texture is based on
+ unflipped image data, pass OriginTopLeft. This is more efficient
+ than using QImage::mirrored().
+
+ \sa targetTransform(), Origin, bind()
+ */
void QOpenGLTextureBlitter::blit(GLuint texture,
const QMatrix4x4 &targetTransform,
Origin sourceOrigin)
@@ -432,6 +585,19 @@ void QOpenGLTextureBlitter::blit(GLuint texture,
d->blit(texture,targetTransform, sourceOrigin);
}
+/*!
+ Performs the blit with the source texture \a texture.
+
+ \a targetTransform specifies the transformation applied. This is
+ usually generated by the targetTransform() helper function.
+
+ \a sourceTransform specifies the transformation applied to the
+ source. This allows using only a sub-rect of the source
+ texture. This is usually generated by the sourceTransform() helper
+ function.
+
+ \sa sourceTransform(), targetTransform(), Origin, bind()
+ */
void QOpenGLTextureBlitter::blit(GLuint texture,
const QMatrix4x4 &targetTransform,
const QMatrix3x3 &sourceTransform)
@@ -440,6 +606,18 @@ void QOpenGLTextureBlitter::blit(GLuint texture,
d->blit(texture, targetTransform, sourceTransform);
}
+/*!
+ Calculates a target transform suitable for blit().
+
+ \a target is the target rectangle in pixels. \a viewport describes
+ the source dimensions and will in most cases be set to (0, 0,
+ image width, image height).
+
+ For unscaled output the size of \a target and \viewport should
+ match.
+
+ \sa blit()
+ */
QMatrix4x4 QOpenGLTextureBlitter::targetTransform(const QRectF &target,
const QRect &viewport)
{
@@ -460,6 +638,17 @@ QMatrix4x4 QOpenGLTextureBlitter::targetTransform(const QRectF &target,
return matrix;
}
+/*!
+ Calculates a 3x3 matrix suitable as the input to blit(). This is
+ used when only a part of the texture is to be used in the blit.
+
+ \a subTexture is the desired source rectangle in pixels, \a
+ textureSize is the full width and height of the texture data. \a
+ origin specifies the orientation of the image data when it comes
+ to the Y axis.
+
+ \sa blit(), Origin
+ */
QMatrix3x3 QOpenGLTextureBlitter::sourceTransform(const QRectF &subTexture,
const QSize &textureSize,
Origin origin)
diff --git a/src/gui/opengl/qopengltextureblitter_p.h b/src/gui/opengl/qopengltextureblitter.h
index 5d39a3e8fa..2f7c6b1a0a 100644
--- a/src/gui/opengl/qopengltextureblitter_p.h
+++ b/src/gui/opengl/qopengltextureblitter.h
@@ -37,28 +37,21 @@
**
****************************************************************************/
-#ifndef QOPENGLTEXTUREBLITTER_P_H
-#define QOPENGLTEXTUREBLITTER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
+#ifndef QOPENGLTEXTUREBLITTER_H
+#define QOPENGLTEXTUREBLITTER_H
+
+#include <QtGui/qtguiglobal.h>
+
+#ifndef QT_NO_OPENGL
#include <QtGui/qopengl.h>
#include <QtGui/QMatrix3x3>
+#include <QtGui/QMatrix4x4>
QT_BEGIN_NAMESPACE
class QOpenGLTextureBlitterPrivate;
-
class Q_GUI_EXPORT QOpenGLTextureBlitter
{
public:
@@ -79,7 +72,7 @@ public:
void bind(GLenum target = GL_TEXTURE_2D);
void release();
- void setSwizzleRB(bool swizzle);
+ void setRedBlueSwizzle(bool swizzle);
void setOpacity(float opacity);
void blit(GLuint texture, const QMatrix4x4 &targetTransform, Origin sourceOrigin);
@@ -96,4 +89,6 @@ private:
QT_END_NAMESPACE
-#endif //QOPENGLTEXTUREBLITTER_P_H
+#endif
+
+#endif //QOPENGLTEXTUREBLITTER_H
diff --git a/src/gui/opengl/qopengltexturecache_p.h b/src/gui/opengl/qopengltexturecache_p.h
index aedc8e7e47..c68b068739 100644
--- a/src/gui/opengl/qopengltexturecache_p.h
+++ b/src/gui/opengl/qopengltexturecache_p.h
@@ -51,6 +51,7 @@
#ifndef QOPENGLTEXTURECACHE_P_H
#define QOPENGLTEXTURECACHE_P_H
+#include <QtGui/private/qtguiglobal_p.h>
#include <QHash>
#include <QObject>
#include <QCache>
diff --git a/src/gui/opengl/qopengltextureglyphcache_p.h b/src/gui/opengl/qopengltextureglyphcache_p.h
index 6cd7667d78..da6ba36643 100644
--- a/src/gui/opengl/qopengltextureglyphcache_p.h
+++ b/src/gui/opengl/qopengltextureglyphcache_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <private/qtextureglyphcache_p.h>
#include <private/qopenglcontext_p.h>
#include <qopenglshaderprogram.h>
diff --git a/src/gui/opengl/qopengltexturehelper_p.h b/src/gui/opengl/qopengltexturehelper_p.h
index 6b26527269..00f6f9e5aa 100644
--- a/src/gui/opengl/qopengltexturehelper_p.h
+++ b/src/gui/opengl/qopengltexturehelper_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtGui/private/qtguiglobal_p.h>
#ifndef QT_NO_OPENGL
diff --git a/src/gui/opengl/qopengltimerquery.h b/src/gui/opengl/qopengltimerquery.h
index 80e52a4c99..7b9ab850e2 100644
--- a/src/gui/opengl/qopengltimerquery.h
+++ b/src/gui/opengl/qopengltimerquery.h
@@ -40,7 +40,7 @@
#ifndef QOPENGLTIMERQUERY_H
#define QOPENGLTIMERQUERY_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#if !defined(QT_NO_OPENGL) && !defined(QT_OPENGL_ES_2)
diff --git a/src/gui/opengl/qopenglversionfunctions.h b/src/gui/opengl/qopenglversionfunctions.h
index 7f991b1955..63209cf392 100644
--- a/src/gui/opengl/qopenglversionfunctions.h
+++ b/src/gui/opengl/qopenglversionfunctions.h
@@ -50,7 +50,7 @@
#ifndef QOPENGLVERSIONFUNCTIONS_H
#define QOPENGLVERSIONFUNCTIONS_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#ifndef QT_NO_OPENGL
diff --git a/src/gui/opengl/qopenglversionfunctionsfactory_p.h b/src/gui/opengl/qopenglversionfunctionsfactory_p.h
index 0af2e4d572..469a9cc624 100644
--- a/src/gui/opengl/qopenglversionfunctionsfactory_p.h
+++ b/src/gui/opengl/qopenglversionfunctionsfactory_p.h
@@ -60,9 +60,10 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
+
#ifndef QT_NO_OPENGL
-#include <QtCore/QtGlobal>
#include <QtGui/qopenglcontext.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/opengl/qopenglvertexarrayobject.h b/src/gui/opengl/qopenglvertexarrayobject.h
index 228c29fce7..a8153ea40b 100644
--- a/src/gui/opengl/qopenglvertexarrayobject.h
+++ b/src/gui/opengl/qopenglvertexarrayobject.h
@@ -40,7 +40,7 @@
#ifndef QOPENGLVERTEXARRAYOBJECT_H
#define QOPENGLVERTEXARRAYOBJECT_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#ifndef QT_NO_OPENGL
diff --git a/src/gui/opengl/qrbtree_p.h b/src/gui/opengl/qrbtree_p.h
index 4c9dfe1af4..d3ee23a91c 100644
--- a/src/gui/opengl/qrbtree_p.h
+++ b/src/gui/opengl/qrbtree_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtGui/private/qtguiglobal_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/opengl/qtriangulatingstroker_p.h b/src/gui/opengl/qtriangulatingstroker_p.h
index 5c037cb05d..2b0f08972b 100644
--- a/src/gui/opengl/qtriangulatingstroker_p.h
+++ b/src/gui/opengl/qtriangulatingstroker_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <private/qdatabuffer_p.h>
#include <qvarlengtharray.h>
#include <private/qvectorpath_p.h>
diff --git a/src/gui/opengl/qtriangulator_p.h b/src/gui/opengl/qtriangulator_p.h
index 2ef635ff84..4d1aba099c 100644
--- a/src/gui/opengl/qtriangulator_p.h
+++ b/src/gui/opengl/qtriangulator_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtCore/qvector.h>
#include <QtGui/private/qvectorpath_p.h>
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri
index 283b6643b9..2f927aeddb 100644
--- a/src/gui/painting/painting.pri
+++ b/src/gui/painting/painting.pri
@@ -104,8 +104,8 @@ AVX2_SOURCES += painting/qdrawhelper_avx2.cpp
NEON_SOURCES += painting/qdrawhelper_neon.cpp painting/qimagescale_neon.cpp
NEON_HEADERS += painting/qdrawhelper_neon_p.h
NEON_ASM += ../3rdparty/pixman/pixman-arm-neon-asm.S painting/qdrawhelper_neon_asm.S
-!ios:contains(QT_ARCH, "arm"): CONFIG+=no_clang_integrated_as
-!ios:!contains(QT_ARCH, "arm64"): DEFINES += ENABLE_PIXMAN_DRAWHELPERS
+!uikit:contains(QT_ARCH, "arm"): CONFIG += no_clang_integrated_as
+!uikit:!contains(QT_ARCH, "arm64"): DEFINES += ENABLE_PIXMAN_DRAWHELPERS
MIPS_DSP_SOURCES += painting/qdrawhelper_mips_dsp.cpp
MIPS_DSP_HEADERS += painting/qdrawhelper_mips_dsp_p.h painting/qt_mips_asm_dsp_p.h
diff --git a/src/gui/painting/qbackingstore.h b/src/gui/painting/qbackingstore.h
index 886cf29f0e..2ba6e1c906 100644
--- a/src/gui/painting/qbackingstore.h
+++ b/src/gui/painting/qbackingstore.h
@@ -40,6 +40,7 @@
#ifndef QBACKINGSTORE_H
#define QBACKINGSTORE_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qrect.h>
#include <QtGui/qwindow.h>
diff --git a/src/gui/painting/qbezier_p.h b/src/gui/painting/qbezier_p.h
index c4e14a18cb..f8a91e9ef3 100644
--- a/src/gui/painting/qbezier_p.h
+++ b/src/gui/painting/qbezier_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtCore/qpoint.h"
#include "QtCore/qline.h"
#include "QtCore/qrect.h"
diff --git a/src/gui/painting/qblendfunctions_p.h b/src/gui/painting/qblendfunctions_p.h
index d21765bcde..7ee04987fe 100644
--- a/src/gui/painting/qblendfunctions_p.h
+++ b/src/gui/painting/qblendfunctions_p.h
@@ -40,6 +40,7 @@
#ifndef QBLENDFUNCTIONS_P_H
#define QBLENDFUNCTIONS_P_H
+#include <QtGui/private/qtguiglobal_p.h>
#include <qmath.h>
#include "qdrawhelper_p.h"
diff --git a/src/gui/painting/qblittable_p.h b/src/gui/painting/qblittable_p.h
index 8df56f6d0c..24440c3c61 100644
--- a/src/gui/painting/qblittable_p.h
+++ b/src/gui/painting/qblittable_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtCore/qsize.h>
#include <QtGui/private/qpixmap_blitter_p.h>
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index 3a296ac40c..acea5682d1 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -458,13 +458,8 @@ QBrush::QBrush(const QImage &image)
*/
QBrush::QBrush(Qt::BrushStyle style)
+ : QBrush(QColor(Qt::black), style)
{
- if (qbrush_check_type(style))
- init(Qt::black, style);
- else {
- d.reset(nullBrushInstance());
- d->ref.ref();
- }
}
/*!
@@ -491,13 +486,8 @@ QBrush::QBrush(const QColor &color, Qt::BrushStyle style)
\sa setColor(), setStyle()
*/
QBrush::QBrush(Qt::GlobalColor color, Qt::BrushStyle style)
+ : QBrush(QColor(color), style)
{
- if (qbrush_check_type(style))
- init(color, style);
- else {
- d.reset(nullBrushInstance());
- d->ref.ref();
- }
}
/*!
@@ -579,11 +569,20 @@ void QBrush::cleanUp(QBrushData *x)
QBrushDataPointerDeleter::deleteData(x);
}
+static Q_DECL_CONSTEXPR inline bool use_same_brushdata(Qt::BrushStyle lhs, Qt::BrushStyle rhs)
+{
+ return lhs == rhs // includes Qt::TexturePattern
+ || (lhs >= Qt::NoBrush && lhs <= Qt::DiagCrossPattern && rhs >= Qt::NoBrush && rhs <= Qt::DiagCrossPattern)
+ || (lhs >= Qt::LinearGradientPattern && lhs <= Qt::ConicalGradientPattern && rhs >= Qt::LinearGradientPattern && rhs <= Qt::ConicalGradientPattern)
+ ;
+}
void QBrush::detach(Qt::BrushStyle newStyle)
{
- if (newStyle == d->style && d->ref.load() == 1)
+ if (use_same_brushdata(newStyle, d->style) && d->ref.load() == 1) {
+ d->style = newStyle;
return;
+ }
QScopedPointer<QBrushData> x;
switch(newStyle) {
@@ -1673,13 +1672,8 @@ QLinearGradient::QLinearGradient(const QPointF &start, const QPointF &finalStop)
\sa QGradient::setColorAt(), QGradient::setStops()
*/
QLinearGradient::QLinearGradient(qreal xStart, qreal yStart, qreal xFinalStop, qreal yFinalStop)
+ : QLinearGradient(QPointF(xStart, yStart), QPointF(xFinalStop, yFinalStop))
{
- m_type = LinearGradient;
- m_spread = PadSpread;
- m_data.linear.x1 = xStart;
- m_data.linear.y1 = yStart;
- m_data.linear.x2 = xFinalStop;
- m_data.linear.y2 = yFinalStop;
}
@@ -1882,19 +1876,8 @@ QRadialGradient::QRadialGradient(const QPointF &center, qreal radius)
*/
QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal radius, qreal fx, qreal fy)
+ : QRadialGradient(QPointF(cx, cy), radius, QPointF(fx, fy))
{
- m_type = RadialGradient;
- m_spread = PadSpread;
- m_data.radial.cx = cx;
- m_data.radial.cy = cy;
- m_data.radial.cradius = radius;
-
- QPointF adapted_focal = qt_radial_gradient_adapt_focal_point(QPointF(cx, cy),
- radius,
- QPointF(fx, fy));
-
- m_data.radial.fx = adapted_focal.x();
- m_data.radial.fy = adapted_focal.y();
}
/*!
@@ -1904,14 +1887,8 @@ QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal radius, qreal fx, qre
\sa QGradient::setColorAt(), QGradient::setStops()
*/
QRadialGradient::QRadialGradient(qreal cx, qreal cy, qreal radius)
+ : QRadialGradient(QPointF(cx, cy), radius)
{
- m_type = RadialGradient;
- m_spread = PadSpread;
- m_data.radial.cx = cx;
- m_data.radial.cy = cy;
- m_data.radial.cradius = radius;
- m_data.radial.fx = cx;
- m_data.radial.fy = cy;
}
@@ -2211,12 +2188,8 @@ QConicalGradient::QConicalGradient(const QPointF &center, qreal angle)
*/
QConicalGradient::QConicalGradient(qreal cx, qreal cy, qreal angle)
+ : QConicalGradient(QPointF(cx, cy), angle)
{
- m_type = ConicalGradient;
- m_spread = PadSpread;
- m_data.conical.cx = cx;
- m_data.conical.cy = cy;
- m_data.conical.angle = angle;
}
diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h
index 568c06ef84..e5cff9cc9b 100644
--- a/src/gui/painting/qbrush.h
+++ b/src/gui/painting/qbrush.h
@@ -40,6 +40,7 @@
#ifndef QBRUSH_H
#define QBRUSH_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qpair.h>
#include <QtCore/qpoint.h>
#include <QtCore/qvector.h>
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index 0d24fd94f5..56180af693 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -261,7 +261,7 @@ QT_BEGIN_NAMESPACE
alpha-channel to feature \l {QColor#Alpha-Blended
Drawing}{alpha-blended drawing}.
- \sa QPalette, QBrush, QApplication::setColorSpec()
+ \sa QPalette, QBrush
*/
#define QCOLOR_INT_RANGE_CHECK(fn, var) \
diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h
index 6338eedd22..6cf3a8e262 100644
--- a/src/gui/painting/qcolor.h
+++ b/src/gui/painting/qcolor.h
@@ -40,6 +40,7 @@
#ifndef QCOLOR_H
#define QCOLOR_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qrgb.h>
#include <QtCore/qnamespace.h>
#include <QtCore/qstringlist.h>
@@ -263,6 +264,7 @@ private:
friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QColor &);
#endif
};
+Q_DECLARE_TYPEINFO(QColor, QT_VERSION >= QT_VERSION_CHECK(6,0,0) ? Q_MOVABLE_TYPE : Q_RELOCATABLE_TYPE);
inline QColor::QColor() Q_DECL_NOTHROW
{ invalidate(); }
diff --git a/src/gui/painting/qcolor_p.h b/src/gui/painting/qcolor_p.h
index 75bc888952..a8d52672f0 100644
--- a/src/gui/painting/qcolor_p.h
+++ b/src/gui/painting/qcolor_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include "QtCore/qglobal.h"
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtGui/qrgb.h"
#include "QtCore/qstringlist.h"
diff --git a/src/gui/painting/qcompositionfunctions.cpp b/src/gui/painting/qcompositionfunctions.cpp
index 9312ee9540..6d2cb9aadb 100644
--- a/src/gui/painting/qcompositionfunctions.cpp
+++ b/src/gui/painting/qcompositionfunctions.cpp
@@ -87,6 +87,36 @@ QT_BEGIN_NAMESPACE
}\
}
+#if defined __SSE2__
+# define LOAD(ptr) _mm_loadl_epi64(reinterpret_cast<const __m128i *>(ptr))
+#ifdef Q_PROCESSOR_X86_64
+# define CONVERT(value) _mm_cvtsi64_si128(value)
+#else
+# define CONVERT(value) LOAD(&value)
+#endif
+# define STORE(ptr, value) _mm_storel_epi64(reinterpret_cast<__m128i *>(ptr), value)
+# define ADD(p, q) _mm_add_epi32(p, q)
+# define ALPHA(c) _mm_shufflelo_epi16(c, _MM_SHUFFLE(3, 3, 3, 3))
+# define CONST(n) _mm_shufflelo_epi16(_mm_cvtsi32_si128(n), _MM_SHUFFLE(0, 0, 0, 0))
+# define INVALPHA(c) _mm_sub_epi32(CONST(65535), ALPHA(c))
+#elif defined __ARM_NEON__
+# define LOAD(ptr) vreinterpret_u16_u64(vld1_u64(reinterpret_cast<const uint64_t *>(ptr)))
+# define CONVERT(value) vreinterpret_u16_u64(vmov_n_u64(value))
+# define STORE(ptr, value) vst1_u64(reinterpret_cast<uint64_t *>(ptr), vreinterpret_u64_u16(value))
+# define ADD(p, q) vadd_u16(p, q)
+# define ALPHA(c) vdup_lane_u16(c, 3)
+# define CONST(n) vdup_n_u16(n)
+# define INVALPHA(c) vmvn_u16(ALPHA(c))
+#else
+# define LOAD(ptr) *ptr
+# define CONVERT(value) value
+# define STORE(ptr, value) *ptr = value
+# define ADD(p, q) (p + q)
+# define ALPHA(c) (c).alpha()
+# define CONST(n) n
+# define INVALPHA(c) (65535 - ALPHA(c))
+#endif
+
void QT_FASTCALL comp_func_solid_Clear(uint *dest, int length, uint, uint const_alpha)
{
comp_func_Clear_impl(dest, length, const_alpha);
@@ -99,7 +129,7 @@ void QT_FASTCALL comp_func_solid_Clear_rgb64(QRgba64 *dest, int length, QRgba64,
else {
int ialpha = 255 - const_alpha;
for (int i = 0; i < length; ++i) {
- dest[i] = multiplyAlpha255(dest[i], ialpha);
+ STORE(&dest[i], multiplyAlpha255(LOAD(&dest[i]), ialpha));
}
}
}
@@ -116,7 +146,7 @@ void QT_FASTCALL comp_func_Clear_rgb64(QRgba64 *dest, const QRgba64 *, int lengt
else {
int ialpha = 255 - const_alpha;
for (int i = 0; i < length; ++i) {
- dest[i] = multiplyAlpha255(dest[i], ialpha);
+ STORE(&dest[i], multiplyAlpha255(LOAD(&dest[i]), ialpha));
}
}
}
@@ -146,9 +176,9 @@ void QT_FASTCALL comp_func_solid_Source_rgb64(QRgba64 *dest, int length, QRgba64
qt_memfill64((quint64*)dest, color, length);
else {
int ialpha = 255 - const_alpha;
- color = multiplyAlpha255(color, const_alpha);
+ auto c = multiplyAlpha255(CONVERT(color), const_alpha);
for (int i = 0; i < length; ++i) {
- dest[i] = color + multiplyAlpha255(dest[i], ialpha);
+ STORE(&dest[i], ADD(c, multiplyAlpha255(LOAD(&dest[i]), ialpha)));
}
}
}
@@ -174,7 +204,7 @@ void QT_FASTCALL comp_func_Source_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRg
else {
int ialpha = 255 - const_alpha;
for (int i = 0; i < length; ++i) {
- dest[i] = interpolate255(src[i], const_alpha, dest[i], ialpha);
+ STORE(&dest[i], interpolate255(LOAD(&src[i]), const_alpha, LOAD(&dest[i]), ialpha));
}
}
}
@@ -221,10 +251,12 @@ void QT_FASTCALL comp_func_solid_SourceOver_rgb64(QRgba64 *dest, int length, QRg
if (const_alpha == 255 && color.isOpaque()) {
qt_memfill64((quint64*)dest, color, length);
} else {
+ auto c = CONVERT(color);
if (const_alpha != 255)
- color = multiplyAlpha255(color, const_alpha);
+ c = multiplyAlpha255(c, const_alpha);
+ auto cAlpha = INVALPHA(c);
for (int i = 0; i < length; ++i) {
- dest[i] = color + multiplyAlpha65535(dest[i], 65535 - color.alpha());
+ STORE(&dest[i], ADD(c, multiplyAlpha65535(LOAD(&dest[i]), cAlpha)));
}
}
}
@@ -258,12 +290,12 @@ void QT_FASTCALL comp_func_SourceOver_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const
if (s.isOpaque())
dest[i] = s;
else if (!s.isTransparent())
- dest[i] = s + multiplyAlpha65535(dest[i], 65535 - s.alpha());
+ STORE(&dest[i], ADD(CONVERT(s), multiplyAlpha65535(LOAD(&dest[i]), 65535 - s.alpha())));
}
} else {
for (int i = 0; i < length; ++i) {
- QRgba64 s = multiplyAlpha255(src[i], const_alpha);
- dest[i] = s + multiplyAlpha65535(dest[i], 65535 - s.alpha());
+ auto s = multiplyAlpha255(LOAD(&src[i]), const_alpha);
+ STORE(&dest[i], ADD(s, multiplyAlpha65535(LOAD(&dest[i]), INVALPHA(s))));
}
}
}
@@ -287,11 +319,12 @@ void QT_FASTCALL comp_func_solid_DestinationOver(uint *dest, int length, uint co
void QT_FASTCALL comp_func_solid_DestinationOver_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha)
{
+ auto c = CONVERT(color);
if (const_alpha != 255)
- color = multiplyAlpha255(color, const_alpha);
+ c = multiplyAlpha255(c, const_alpha);
for (int i = 0; i < length; ++i) {
- QRgba64 d = dest[i];
- dest[i] = d + multiplyAlpha65535(color, 65535 - d.alpha());
+ auto d = LOAD(&dest[i]);
+ STORE(&dest[i], ADD(d, multiplyAlpha65535(c, INVALPHA(d))));
}
}
@@ -318,14 +351,14 @@ void QT_FASTCALL comp_func_DestinationOver_rgb64(QRgba64 *Q_DECL_RESTRICT dest,
{
if (const_alpha == 255) {
for (int i = 0; i < length; ++i) {
- QRgba64 d = dest[i];
- dest[i] = d + multiplyAlpha65535(src[i], 65535 - d.alpha());
+ auto d = LOAD(&dest[i]);
+ STORE(&dest[i], ADD(d, multiplyAlpha65535(LOAD(&src[i]), INVALPHA(d))));
}
} else {
for (int i = 0; i < length; ++i) {
- QRgba64 d = dest[i];
- QRgba64 s = multiplyAlpha255(src[i], const_alpha);
- dest[i] = d + multiplyAlpha65535(s, 65535 - d.alpha());
+ auto d = LOAD(&dest[i]);
+ auto s = multiplyAlpha255(LOAD(&src[i]), const_alpha);
+ STORE(&dest[i], ADD(d, multiplyAlpha65535(s, INVALPHA(d))));
}
}
}
@@ -393,15 +426,15 @@ void QT_FASTCALL comp_func_SourceIn_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const Q
{
if (const_alpha == 255) {
for (int i = 0; i < length; ++i) {
- dest[i] = multiplyAlpha65535(src[i], dest[i].alpha());
+ STORE(&dest[i], multiplyAlpha65535(LOAD(&src[i]), dest[i].alpha()));
}
} else {
uint ca = const_alpha * 257;
- uint cia = 65535 - ca;
+ auto cia = CONST(65535 - ca);
for (int i = 0; i < length; ++i) {
- QRgba64 d = dest[i];
- QRgba64 s = multiplyAlpha65535(src[i], ca);
- dest[i] = interpolate65535(s, d.alpha(), d, cia);
+ auto d = LOAD(&dest[i]);
+ auto s = multiplyAlpha65535(LOAD(&src[i]), ca);
+ STORE(&dest[i], interpolate65535(s, ALPHA(d), d, cia));
}
}
}
@@ -431,7 +464,7 @@ void QT_FASTCALL comp_func_solid_DestinationIn_rgb64(QRgba64 *dest, int length,
if (const_alpha != 255)
a = qt_div_65535(a * ca64k) + 65535 - ca64k;
for (int i = 0; i < length; ++i) {
- dest[i] = multiplyAlpha65535(dest[i], a);
+ STORE(&dest[i], multiplyAlpha65535(LOAD(&dest[i]), a));
}
}
@@ -885,14 +918,19 @@ void QT_FASTCALL comp_func_solid_Plus(uint *dest, int length, uint color, uint c
void QT_FASTCALL comp_func_solid_Plus_rgb64(QRgba64 *dest, int length, QRgba64 color, uint const_alpha)
{
+ auto b = CONVERT(color);
if (const_alpha == 255) {
for (int i = 0; i < length; ++i) {
- dest[i] = addWithSaturation(dest[i], color);
+ auto a = LOAD(&dest[i]);
+ a = addWithSaturation(a, b);
+ STORE(&dest[i], a);
}
} else {
for (int i = 0; i < length; ++i) {
- QRgba64 d = addWithSaturation(dest[i], color);
- dest[i] = interpolate255(d, const_alpha, dest[i], 255 - const_alpha);
+ auto a = LOAD(&dest[i]);
+ auto d = addWithSaturation(a, b);
+ a = interpolate255(d, const_alpha, a, 255 - const_alpha);
+ STORE(&dest[i], a);
}
}
}
@@ -924,12 +962,18 @@ void QT_FASTCALL comp_func_Plus_rgb64(QRgba64 *Q_DECL_RESTRICT dest, const QRgba
{
if (const_alpha == 255) {
for (int i = 0; i < length; ++i) {
- dest[i] = addWithSaturation(dest[i], src[i]);
+ auto a = LOAD(&dest[i]);
+ auto b = LOAD(&src[i]);
+ a = addWithSaturation(a, b);
+ STORE(&dest[i], a);
}
} else {
for (int i = 0; i < length; ++i) {
- QRgba64 d = addWithSaturation(dest[i], src[i]);
- dest[i] = interpolate255(d, const_alpha, dest[i], 255 - const_alpha);
+ auto a = LOAD(&dest[i]);
+ auto b = LOAD(&src[i]);
+ auto d = addWithSaturation(a, b);
+ a = interpolate255(d, const_alpha, a, 255 - const_alpha);
+ STORE(&dest[i], a);
}
}
}
diff --git a/src/gui/painting/qcosmeticstroker_p.h b/src/gui/painting/qcosmeticstroker_p.h
index b22e2c2cf5..68f4e00cdc 100644
--- a/src/gui/painting/qcosmeticstroker_p.h
+++ b/src/gui/painting/qcosmeticstroker_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <private/qdrawhelper_p.h>
#include <private/qvectorpath_p.h>
#include <private/qpaintengine_raster_p.h>
diff --git a/src/gui/painting/qdatabuffer_p.h b/src/gui/painting/qdatabuffer_p.h
index f5a3fa1432..77b5be0c4c 100644
--- a/src/gui/painting/qdatabuffer_p.h
+++ b/src/gui/painting/qdatabuffer_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtCore/qbytearray.h"
#include <stdlib.h>
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 8729640a80..affbc43afe 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -168,7 +168,7 @@ template<> Q_DECL_CONSTEXPR QPixelLayout::BPP bitsPerPixel<QImage::Format_ARGB66
template<QImage::Format Format>
static const uint *QT_FASTCALL convertToRGB32(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1);
Q_CONSTEXPR uint greenMask = ((1 << greenWidth<Format>()) - 1);
@@ -198,7 +198,7 @@ static const uint *QT_FASTCALL convertToRGB32(uint *buffer, const uint *src, int
template<QImage::Format Format>
static const QRgba64 *QT_FASTCALL convertToRGB64(QRgba64 *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1);
Q_CONSTEXPR uint greenMask = ((1 << greenWidth<Format>()) - 1);
@@ -228,7 +228,7 @@ static const QRgba64 *QT_FASTCALL convertToRGB64(QRgba64 *buffer, const uint *sr
template<QImage::Format Format>
static const uint *QT_FASTCALL convertARGBPMToARGB32PM(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
Q_CONSTEXPR uint alphaMask = ((1 << alphaWidth<Format>()) - 1);
Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1);
@@ -282,7 +282,7 @@ static const uint *QT_FASTCALL convertARGBPMToARGB32PM(uint *buffer, const uint
template<QImage::Format Format>
static const QRgba64 *QT_FASTCALL convertARGBPMToARGB64PM(QRgba64 *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
Q_CONSTEXPR uint alphaMask = ((1 << alphaWidth<Format>()) - 1);
Q_CONSTEXPR uint redMask = ((1 << redWidth<Format>()) - 1);
@@ -336,48 +336,110 @@ static const QRgba64 *QT_FASTCALL convertARGBPMToARGB64PM(QRgba64 *buffer, const
template<QImage::Format Format, bool fromRGB>
static const uint *QT_FASTCALL convertRGBFromARGB32PM(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *dither)
{
- Q_CONSTEXPR uint rMask = ((1 << redWidth<Format>()) - 1);
- Q_CONSTEXPR uint gMask = ((1 << greenWidth<Format>()) - 1);
- Q_CONSTEXPR uint bMask = ((1 << blueWidth<Format>()) - 1);
+ Q_CONSTEXPR uchar rWidth = redWidth<Format>();
+ Q_CONSTEXPR uchar gWidth = greenWidth<Format>();
+ Q_CONSTEXPR uchar bWidth = blueWidth<Format>();
- Q_CONSTEXPR uchar rRightShift = 24 - redWidth<Format>();
- Q_CONSTEXPR uchar gRightShift = 16 - greenWidth<Format>();
- Q_CONSTEXPR uchar bRightShift = 8 - blueWidth<Format>();
+ // RGB32 -> RGB888 is not a precision loss.
+ if (!dither || (rWidth == 8 && gWidth == 8 && bWidth == 8)) {
+ Q_CONSTEXPR uint rMask = (1 << rWidth) - 1;
+ Q_CONSTEXPR uint gMask = (1 << gWidth) - 1;
+ Q_CONSTEXPR uint bMask = (1 << bWidth) - 1;
- for (int i = 0; i < count; ++i) {
- const uint c = fromRGB ? src[i] : qUnpremultiply(src[i]);
- const uint r = ((c >> rRightShift) & rMask) << redShift<Format>();
- const uint g = ((c >> gRightShift) & gMask) << greenShift<Format>();
- const uint b = ((c >> bRightShift) & bMask) << blueShift<Format>();
- buffer[i] = r | g | b;
+ Q_CONSTEXPR uchar rRightShift = 24 - rWidth;
+ Q_CONSTEXPR uchar gRightShift = 16 - gWidth;
+ Q_CONSTEXPR uchar bRightShift = 8 - bWidth;
+
+ for (int i = 0; i < count; ++i) {
+ const uint c = fromRGB ? src[i] : qUnpremultiply(src[i]);
+ const uint r = ((c >> rRightShift) & rMask) << redShift<Format>();
+ const uint g = ((c >> gRightShift) & gMask) << greenShift<Format>();
+ const uint b = ((c >> bRightShift) & bMask) << blueShift<Format>();
+ buffer[i] = r | g | b;
+ }
+ } else {
+ // We do ordered dither by using a rounding conversion, but instead of
+ // adding half of input precision, we add the adjusted result from the
+ // bayer matrix before narrowing.
+ // Note: Rounding conversion in itself is different from the naive
+ // conversion we do above for non-dithering.
+ const uint *bayer_line = qt_bayer_matrix[dither->y & 15];
+ for (int i = 0; i < count; ++i) {
+ const uint c = fromRGB ? src[i] : qUnpremultiply(src[i]);
+ const int d = bayer_line[(dither->x + i) & 15];
+ const int dr = d - ((d + 1) >> rWidth);
+ const int dg = d - ((d + 1) >> gWidth);
+ const int db = d - ((d + 1) >> bWidth);
+ int r = qRed(c);
+ int g = qGreen(c);
+ int b = qBlue(c);
+ r = (r + ((dr - r) >> rWidth) + 1) >> (8 - rWidth);
+ g = (g + ((dg - g) >> gWidth) + 1) >> (8 - gWidth);
+ b = (b + ((db - b) >> bWidth) + 1) >> (8 - bWidth);
+ buffer[i] = (r << redShift<Format>())
+ | (g << greenShift<Format>())
+ | (b << blueShift<Format>());
+ }
}
return buffer;
}
template<QImage::Format Format, bool fromRGB>
static const uint *QT_FASTCALL convertARGBPMFromARGB32PM(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *dither)
{
- Q_CONSTEXPR uint aMask = ((1 << alphaWidth<Format>()) - 1);
- Q_CONSTEXPR uint rMask = ((1 << redWidth<Format>()) - 1);
- Q_CONSTEXPR uint gMask = ((1 << greenWidth<Format>()) - 1);
- Q_CONSTEXPR uint bMask = ((1 << blueWidth<Format>()) - 1);
+ Q_CONSTEXPR uchar aWidth = alphaWidth<Format>();
+ Q_CONSTEXPR uchar rWidth = redWidth<Format>();
+ Q_CONSTEXPR uchar gWidth = greenWidth<Format>();
+ Q_CONSTEXPR uchar bWidth = blueWidth<Format>();
- Q_CONSTEXPR uchar aRightShift = 32 - alphaWidth<Format>();
- Q_CONSTEXPR uchar rRightShift = 24 - redWidth<Format>();
- Q_CONSTEXPR uchar gRightShift = 16 - greenWidth<Format>();
- Q_CONSTEXPR uchar bRightShift = 8 - blueWidth<Format>();
+ if (!dither) {
+ Q_CONSTEXPR uint aMask = (1 << aWidth) - 1;
+ Q_CONSTEXPR uint rMask = (1 << rWidth) - 1;
+ Q_CONSTEXPR uint gMask = (1 << gWidth) - 1;
+ Q_CONSTEXPR uint bMask = (1 << bWidth) - 1;
- Q_CONSTEXPR uint aOpaque = (0xff & aMask) << alphaShift<Format>();
- for (int i = 0; i < count; ++i) {
- const uint c = src[i];
- const uint a = fromRGB ? aOpaque : (((c >> aRightShift) & aMask) << alphaShift<Format>());
- const uint r = ((c >> rRightShift) & rMask) << redShift<Format>();
- const uint g = ((c >> gRightShift) & gMask) << greenShift<Format>();
- const uint b = ((c >> bRightShift) & bMask) << blueShift<Format>();
- buffer[i] = a | r | g | b;
+ Q_CONSTEXPR uchar aRightShift = 32 - aWidth;
+ Q_CONSTEXPR uchar rRightShift = 24 - rWidth;
+ Q_CONSTEXPR uchar gRightShift = 16 - gWidth;
+ Q_CONSTEXPR uchar bRightShift = 8 - bWidth;
+
+ Q_CONSTEXPR uint aOpaque = aMask << alphaShift<Format>();
+ for (int i = 0; i < count; ++i) {
+ const uint c = src[i];
+ const uint a = fromRGB ? aOpaque : (((c >> aRightShift) & aMask) << alphaShift<Format>());
+ const uint r = ((c >> rRightShift) & rMask) << redShift<Format>();
+ const uint g = ((c >> gRightShift) & gMask) << greenShift<Format>();
+ const uint b = ((c >> bRightShift) & bMask) << blueShift<Format>();
+ buffer[i] = a | r | g | b;
+ }
+ } else {
+ const uint *bayer_line = qt_bayer_matrix[dither->y & 15];
+ for (int i = 0; i < count; ++i) {
+ const uint c = src[i];
+ const int d = bayer_line[(dither->x + i) & 15];
+ const int da = d - ((d + 1) >> aWidth);
+ const int dr = d - ((d + 1) >> rWidth);
+ const int dg = d - ((d + 1) >> gWidth);
+ const int db = d - ((d + 1) >> bWidth);
+ int a = qAlpha(c);
+ int r = qRed(c);
+ int g = qGreen(c);
+ int b = qBlue(c);
+ if (fromRGB)
+ a = (1 << aWidth) - 1;
+ else
+ a = (a + ((da - a) >> aWidth) + 1) >> (8 - aWidth);
+ r = (r + ((dr - r) >> rWidth) + 1) >> (8 - rWidth);
+ g = (g + ((dg - g) >> gWidth) + 1) >> (8 - gWidth);
+ b = (b + ((db - b) >> bWidth) + 1) >> (8 - bWidth);
+ buffer[i] = (a << alphaShift<Format>())
+ | (r << redShift<Format>())
+ | (g << greenShift<Format>())
+ | (b << blueShift<Format>());
+ }
}
return buffer;
}
@@ -418,35 +480,35 @@ template<QImage::Format Format> Q_DECL_CONSTEXPR static inline QPixelLayout pixe
// To convert in place, let 'dest' and 'src' be the same.
static const uint *QT_FASTCALL convertIndexedToARGB32PM(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *clut)
+ const QVector<QRgb> *clut, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
- buffer[i] = qPremultiply(clut[src[i]]);
+ buffer[i] = qPremultiply(clut->at(src[i]));
return buffer;
}
static const QRgba64 *QT_FASTCALL convertIndexedToARGB64PM(QRgba64 *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *clut)
+ const QVector<QRgb> *clut, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
- buffer[i] = QRgba64::fromArgb32(clut[src[i]]).premultiplied();
+ buffer[i] = QRgba64::fromArgb32(clut->at(src[i])).premultiplied();
return buffer;
}
static const uint *QT_FASTCALL convertPassThrough(uint *, const uint *src, int,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
return src;
}
static const uint *QT_FASTCALL convertARGB32ToARGB32PM(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
return qt_convertARGB32ToARGB32PM(buffer, src, count);
}
static const uint *QT_FASTCALL convertRGBA8888PMToARGB32PM(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = RGBA2ARGB(src[i]);
@@ -454,13 +516,13 @@ static const uint *QT_FASTCALL convertRGBA8888PMToARGB32PM(uint *buffer, const u
}
static const uint *QT_FASTCALL convertRGBA8888ToARGB32PM(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
return qt_convertRGBA8888ToARGB32PM(buffer, src, count);
}
static const uint *QT_FASTCALL convertAlpha8ToRGB32(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = qRgba(0, 0, 0, src[i]);
@@ -468,7 +530,7 @@ static const uint *QT_FASTCALL convertAlpha8ToRGB32(uint *buffer, const uint *sr
}
static const uint *QT_FASTCALL convertGrayscale8ToRGB32(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = qRgb(src[i], src[i], src[i]);
@@ -476,7 +538,7 @@ static const uint *QT_FASTCALL convertGrayscale8ToRGB32(uint *buffer, const uint
}
static const QRgba64 *QT_FASTCALL convertAlpha8ToRGB64(QRgba64 *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = QRgba64::fromRgba(0, 0, 0, src[i]);
@@ -484,7 +546,7 @@ static const QRgba64 *QT_FASTCALL convertAlpha8ToRGB64(QRgba64 *buffer, const ui
}
static const QRgba64 *QT_FASTCALL convertGrayscale8ToRGB64(QRgba64 *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = QRgba64::fromRgba(src[i], src[i], src[i], 255);
@@ -492,7 +554,7 @@ static const QRgba64 *QT_FASTCALL convertGrayscale8ToRGB64(QRgba64 *buffer, cons
}
static const uint *QT_FASTCALL convertARGB32FromARGB32PM(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = qUnpremultiply(src[i]);
@@ -500,7 +562,7 @@ static const uint *QT_FASTCALL convertARGB32FromARGB32PM(uint *buffer, const uin
}
static const uint *QT_FASTCALL convertRGBA8888PMFromARGB32PM(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = ARGB2RGBA(src[i]);
@@ -551,7 +613,7 @@ static inline void qConvertARGB32PMToARGB64PM_sse2(QRgba64 *buffer, const uint *
#endif
static const QRgba64 *QT_FASTCALL convertRGB32ToRGB64(QRgba64 *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
#ifdef __SSE2__
qConvertARGB32PMToARGB64PM_sse2<false, true>(buffer, src, count);
@@ -563,7 +625,7 @@ static const QRgba64 *QT_FASTCALL convertRGB32ToRGB64(QRgba64 *buffer, const uin
}
static const QRgba64 *QT_FASTCALL convertARGB32ToARGB64PM(QRgba64 *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
#ifdef __SSE2__
qConvertARGB32PMToARGB64PM_sse2<false, false>(buffer, src, count);
@@ -577,7 +639,7 @@ static const QRgba64 *QT_FASTCALL convertARGB32ToARGB64PM(QRgba64 *buffer, const
}
static const QRgba64 *QT_FASTCALL convertARGB32PMToARGB64PM(QRgba64 *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
#ifdef __SSE2__
qConvertARGB32PMToARGB64PM_sse2<false, false>(buffer, src, count);
@@ -589,7 +651,7 @@ static const QRgba64 *QT_FASTCALL convertARGB32PMToARGB64PM(QRgba64 *buffer, con
}
static const QRgba64 *QT_FASTCALL convertRGBA8888ToARGB64PM(QRgba64 *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
#ifdef __SSE2__
qConvertARGB32PMToARGB64PM_sse2<true, false>(buffer, src, count);
@@ -603,7 +665,7 @@ static const QRgba64 *QT_FASTCALL convertRGBA8888ToARGB64PM(QRgba64 *buffer, con
}
static const QRgba64 *QT_FASTCALL convertRGBA8888PMToARGB64PM(QRgba64 *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
#ifdef __SSE2__
qConvertARGB32PMToARGB64PM_sse2<true, false>(buffer, src, count);
@@ -615,7 +677,7 @@ static const QRgba64 *QT_FASTCALL convertRGBA8888PMToARGB64PM(QRgba64 *buffer, c
}
static const uint *QT_FASTCALL convertRGBA8888FromARGB32PM(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = ARGB2RGBA(qUnpremultiply(src[i]));
@@ -623,7 +685,7 @@ static const uint *QT_FASTCALL convertRGBA8888FromARGB32PM(uint *buffer, const u
}
static const uint *QT_FASTCALL convertRGBXFromRGB32(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = ARGB2RGBA(0xff000000 | src[i]);
@@ -631,7 +693,7 @@ static const uint *QT_FASTCALL convertRGBXFromRGB32(uint *buffer, const uint *sr
}
static const uint *QT_FASTCALL convertRGBXFromARGB32PM(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = ARGB2RGBA(0xff000000 | qUnpremultiply(src[i]));
@@ -640,10 +702,28 @@ static const uint *QT_FASTCALL convertRGBXFromARGB32PM(uint *buffer, const uint
template<QtPixelOrder PixelOrder>
static const uint *QT_FASTCALL convertA2RGB30PMToARGB32PM(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *dither)
{
- for (int i = 0; i < count; ++i)
- buffer[i] = qConvertA2rgb30ToArgb32<PixelOrder>(src[i]);
+ if (!dither) {
+ for (int i = 0; i < count; ++i)
+ buffer[i] = qConvertA2rgb30ToArgb32<PixelOrder>(src[i]);
+ } else {
+ for (int i = 0; i < count; ++i) {
+ const uint c = src[i];
+ short d10 = (qt_bayer_matrix[dither->y & 15][(dither->x + i) & 15] << 2);
+ short a10 = (c >> 30) * 0x155;
+ short r10 = ((c >> 20) & 0x3ff);
+ short g10 = ((c >> 10) & 0x3ff);
+ short b10 = (c & 0x3ff);
+ if (PixelOrder == PixelOrderBGR)
+ std::swap(r10, b10);
+ short a8 = (a10 + ((d10 - a10) >> 8)) >> 2;
+ short r8 = (r10 + ((d10 - r10) >> 8)) >> 2;
+ short g8 = (g10 + ((d10 - g10) >> 8)) >> 2;
+ short b8 = (b10 + ((d10 - b10) >> 8)) >> 2;
+ buffer[i] = qRgba(r8, g8, b8, a8);
+ }
+ }
return buffer;
}
@@ -693,7 +773,7 @@ static inline void qConvertA2RGB30PMToARGB64PM_sse2(QRgba64 *buffer, const uint
template<QtPixelOrder PixelOrder>
static const QRgba64 *QT_FASTCALL convertA2RGB30PMToARGB64PM(QRgba64 *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
#ifdef __SSE2__
qConvertA2RGB30PMToARGB64PM_sse2<PixelOrder>(buffer, src, count);
@@ -706,7 +786,7 @@ static const QRgba64 *QT_FASTCALL convertA2RGB30PMToARGB64PM(QRgba64 *buffer, co
template<QtPixelOrder PixelOrder>
static const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = qConvertArgb32ToA2rgb30<PixelOrder>(src[i]);
@@ -715,7 +795,7 @@ static const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM(uint *buffer, const
template<QtPixelOrder PixelOrder>
static const uint *QT_FASTCALL convertRGB30FromRGB32(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = qConvertRgb32ToRgb30<PixelOrder>(src[i]);
@@ -724,7 +804,7 @@ static const uint *QT_FASTCALL convertRGB30FromRGB32(uint *buffer, const uint *s
template<QtPixelOrder PixelOrder>
static const uint *QT_FASTCALL convertRGB30FromARGB32PM(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = qConvertRgb32ToRgb30<PixelOrder>(qUnpremultiply(src[i]));
@@ -732,7 +812,7 @@ static const uint *QT_FASTCALL convertRGB30FromARGB32PM(uint *buffer, const uint
}
static const uint *QT_FASTCALL convertAlpha8FromARGB32PM(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = qAlpha(src[i]);
@@ -740,7 +820,7 @@ static const uint *QT_FASTCALL convertAlpha8FromARGB32PM(uint *buffer, const uin
}
static const uint *QT_FASTCALL convertGrayscale8FromRGB32(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = qGray(src[i]);
@@ -748,7 +828,7 @@ static const uint *QT_FASTCALL convertGrayscale8FromRGB32(uint *buffer, const ui
}
static const uint *QT_FASTCALL convertGrayscale8FromARGB32PM(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = qGray(qUnpremultiply(src[i]));
@@ -1037,7 +1117,7 @@ static uint *QT_FASTCALL destFetch(uint *buffer, QRasterBuffer *rasterBuffer, in
{
const QPixelLayout *layout = &qPixelLayouts[rasterBuffer->format];
const uint *ptr = qFetchPixels[layout->bpp](buffer, rasterBuffer->scanLine(y), x, length);
- return const_cast<uint *>(layout->convertToARGB32PM(buffer, ptr, length, layout, 0));
+ return const_cast<uint *>(layout->convertToARGB32PM(buffer, ptr, length, 0, 0));
}
static QRgba64 *QT_FASTCALL destFetch64(QRgba64 *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length)
@@ -1045,14 +1125,14 @@ static QRgba64 *QT_FASTCALL destFetch64(QRgba64 *buffer, QRasterBuffer *rasterBu
const QPixelLayout *layout = &qPixelLayouts[rasterBuffer->format];
uint buffer32[buffer_size];
const uint *ptr = qFetchPixels[layout->bpp](buffer32, rasterBuffer->scanLine(y), x, length);
- return const_cast<QRgba64 *>(layout->convertToARGB64PM(buffer, ptr, length, layout, 0));
+ return const_cast<QRgba64 *>(layout->convertToARGB64PM(buffer, ptr, length, 0, 0));
}
static QRgba64 *QT_FASTCALL destFetch64uint32(QRgba64 *buffer, QRasterBuffer *rasterBuffer, int x, int y, int length)
{
const QPixelLayout *layout = &qPixelLayouts[rasterBuffer->format];
const uint *src = ((const uint *)rasterBuffer->scanLine(y)) + x;
- return const_cast<QRgba64 *>(layout->convertToARGB64PM(buffer, src, length, layout, 0));
+ return const_cast<QRgba64 *>(layout->convertToARGB64PM(buffer, src, length, 0, 0));
}
static DestFetchProc destFetchProc[QImage::NImageFormats] =
@@ -1219,9 +1299,9 @@ static void QT_FASTCALL destStore(QRasterBuffer *rasterBuffer, int x, int y, con
int l = qMin(length, buffer_size);
const uint *ptr = 0;
if (!layout->premultiplied && !layout->alphaWidth)
- ptr = layout->convertFromRGB32(buf, buffer, l, layout, 0);
+ ptr = layout->convertFromRGB32(buf, buffer, l, 0, 0);
else
- ptr = layout->convertFromARGB32PM(buf, buffer, l, layout, 0);
+ ptr = layout->convertFromARGB32PM(buf, buffer, l, 0, 0);
store(dest, ptr, x, l);
length -= l;
buffer += l;
@@ -1247,9 +1327,9 @@ static void QT_FASTCALL destStore64(QRasterBuffer *rasterBuffer, int x, int y, c
const uint *ptr = 0;
convertFromRgb64(buf, buffer, l);
if (!layout->premultiplied && !layout->alphaWidth)
- ptr = layout->convertFromRGB32(buf, buf, l, layout, 0);
+ ptr = layout->convertFromRGB32(buf, buf, l, 0, 0);
else
- ptr = layout->convertFromARGB32PM(buf, buf, l, layout, 0);
+ ptr = layout->convertFromARGB32PM(buf, buf, l, 0, 0);
store(dest, ptr, x, l);
length -= l;
buffer += l;
@@ -1436,8 +1516,7 @@ static const uint *QT_FASTCALL fetchUntransformed(uint *buffer, const Operator *
{
const QPixelLayout *layout = &qPixelLayouts[data->texture.format];
const uint *ptr = qFetchPixels[layout->bpp](buffer, data->texture.scanLine(y), x, length);
- const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0;
- return layout->convertToARGB32PM(buffer, ptr, length, layout, clut);
+ return layout->convertToARGB32PM(buffer, ptr, length, data->texture.colorTable, 0);
}
static const uint *QT_FASTCALL fetchUntransformedARGB32PM(uint *, const Operator *,
@@ -1465,14 +1544,13 @@ static const QRgba64 *QT_FASTCALL fetchUntransformed64(QRgba64 *buffer, const Op
const QSpanData *data, int y, int x, int length)
{
const QPixelLayout *layout = &qPixelLayouts[data->texture.format];
- const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0;
if (layout->bpp != QPixelLayout::BPP32) {
uint buffer32[buffer_size];
const uint *ptr = qFetchPixels[layout->bpp](buffer32, data->texture.scanLine(y), x, length);
- return layout->convertToARGB64PM(buffer, ptr, length, layout, clut);
+ return layout->convertToARGB64PM(buffer, ptr, length, data->texture.colorTable, 0);
} else {
const uint *src = (const uint *)data->texture.scanLine(y) + x;
- return layout->convertToARGB64PM(buffer, src, length, layout, clut);
+ return layout->convertToARGB64PM(buffer, src, length, data->texture.colorTable, 0);
}
}
@@ -1639,8 +1717,7 @@ static const uint *QT_FASTCALL fetchTransformed(uint *buffer, const Operator *,
++b;
}
}
- const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0;
- return layout->convertToARGB32PM(buffer, buffer, length, layout, clut);
+ return layout->convertToARGB32PM(buffer, buffer, length, data->texture.colorTable, 0);
}
template<TextureBlendType blendType> /* either BlendTransformed or BlendTransformedTiled */
@@ -1655,7 +1732,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformed64(QRgba64 *buffer, const Oper
const QPixelLayout *layout = &qPixelLayouts[data->texture.format];
FetchPixelFunc fetch = qFetchPixel[layout->bpp];
- const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0;
+ const QVector<QRgb> *clut = data->texture.colorTable;
uint buffer32[buffer_size];
QRgba64 *b = buffer;
@@ -1672,7 +1749,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformed64(QRgba64 *buffer, const Oper
int i = 0, j = 0;
while (i < length) {
if (j == buffer_size) {
- layout->convertToARGB64PM(b, buffer32, buffer_size, layout, clut);
+ layout->convertToARGB64PM(b, buffer32, buffer_size, clut, 0);
b += buffer_size;
j = 0;
}
@@ -1695,7 +1772,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformed64(QRgba64 *buffer, const Oper
++i; ++j;
}
if (j > 0) {
- layout->convertToARGB64PM(b, buffer32, j, layout, clut);
+ layout->convertToARGB64PM(b, buffer32, j, clut, 0);
b += j;
}
} else {
@@ -1710,7 +1787,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformed64(QRgba64 *buffer, const Oper
int i = 0, j = 0;
while (i < length) {
if (j == buffer_size) {
- layout->convertToARGB64PM(b, buffer32, buffer_size, layout, clut);
+ layout->convertToARGB64PM(b, buffer32, buffer_size, clut, 0);
b += buffer_size;
j = 0;
}
@@ -1741,7 +1818,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformed64(QRgba64 *buffer, const Oper
++i; ++j;
}
if (j > 0) {
- layout->convertToARGB64PM(b, buffer32, j, layout, clut);
+ layout->convertToARGB64PM(b, buffer32, j, clut, 0);
b += j;
}
}
@@ -1750,9 +1827,9 @@ static const QRgba64 *QT_FASTCALL fetchTransformed64(QRgba64 *buffer, const Oper
/** \internal
interpolate 4 argb pixels with the distx and disty factor.
- distx and disty bust be between 0 and 16
+ distx and disty must be between 0 and 16
*/
-static inline uint interpolate_4_pixels_16(uint tl, uint tr, uint bl, uint br, int distx, int disty)
+static inline uint interpolate_4_pixels_16(uint tl, uint tr, uint bl, uint br, uint distx, uint disty)
{
uint distxy = distx * disty;
//idistx * disty = (16-distx) * disty = 16*disty - distxy
@@ -2099,10 +2176,12 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c
fetchTransformedBilinear_pixelBounds<blendType>(image_height, image_y1, image_y2, y1, y2);
const uint *s1 = (const uint *)data->texture.scanLine(y1);
const uint *s2 = (const uint *)data->texture.scanLine(y2);
- int disty = (fy & 0x0000ffff) >> 12;
+ int disty = ((fy & 0x0000ffff) + 0x0800) >> 12;
if (blendType != BlendTransformedBilinearTiled) {
#define BILINEAR_DOWNSCALE_BOUNDS_PROLOG \
+ const qint64 min_fx = qint64(image_x1) * fixed_scale; \
+ const qint64 max_fx = qint64(image_x2) * fixed_scale; \
while (b < end) { \
int x1 = (fx >> 16); \
int x2; \
@@ -2113,16 +2192,16 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c
uint tr = s1[x2]; \
uint bl = s2[x1]; \
uint br = s2[x2]; \
- int distx = (fx & 0x0000ffff) >> 12; \
+ int distx = ((fx & 0x0000ffff) + 0x0800) >> 12; \
*b = interpolate_4_pixels_16(tl, tr, bl, br, distx, disty); \
fx += fdx; \
++b; \
} \
- uint *boundedEnd; \
+ uint *boundedEnd = end; \
if (fdx > 0) \
- boundedEnd = qMin(end, buffer + uint((image_x2 - (fx >> 16)) / data->m11)); \
- else \
- boundedEnd = qMin(end, buffer + uint((image_x1 - (fx >> 16)) / data->m11)); \
+ boundedEnd = qMin(boundedEnd, b + (max_fx - fx) / fdx); \
+ else if (fdx < 0) \
+ boundedEnd = qMin(boundedEnd, b + (min_fx - fx) / fdx); \
boundedEnd -= 3;
#if defined(__SSE2__)
@@ -2132,6 +2211,7 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c
const __m128i v_256 = _mm_set1_epi16(256);
const __m128i v_disty = _mm_set1_epi16(disty);
const __m128i v_fdx = _mm_set1_epi32(fdx*4);
+ const __m128i v_fx_r = _mm_set1_epi32(0x8);
__m128i v_fx = _mm_setr_epi32(fx, fx + fdx, fx + fdx + fdx, fx + fdx + fdx + fdx);
while (b < boundedEnd) {
@@ -2145,7 +2225,8 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c
const __m128i bl = _mm_setr_epi32(s2[offset0], s2[offset1], s2[offset2], s2[offset3]);
const __m128i br = _mm_setr_epi32(s2[offset0 + 1], s2[offset1 + 1], s2[offset2 + 1], s2[offset3 + 1]);
- __m128i v_distx = _mm_srli_epi16(v_fx, 12);
+ __m128i v_distx = _mm_srli_epi16(v_fx, 8);
+ v_distx = _mm_srli_epi16(_mm_add_epi32(v_distx, v_fx_r), 4);
v_distx = _mm_shufflehi_epi16(v_distx, _MM_SHUFFLE(2,2,0,0));
v_distx = _mm_shufflelo_epi16(v_distx, _MM_SHUFFLE(2,2,0,0));
@@ -2175,6 +2256,7 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c
}
const int32x4_t v_ffff_mask = vdupq_n_s32(0x0000ffff);
+ const int32x4_t v_fx_r = vdupq_n_s32(0x0800);
while (b < boundedEnd) {
@@ -2183,7 +2265,7 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c
Vect_buffer v_fx_shifted;
v_fx_shifted.vect = vshrq_n_s32(v_fx.vect, 16);
- int32x4_t v_distx = vshrq_n_s32(vandq_s32(v_fx.vect, v_ffff_mask), 12);
+ int32x4_t v_distx = vshrq_n_s32(vaddq_s32(vandq_s32(v_fx.vect, v_ffff_mask), v_fx_r), 12);
for (int i = 0; i < 4; i++) {
int x1 = v_fx_shifted.i[i];
@@ -2213,7 +2295,7 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c
uint tr = s1[x2];
uint bl = s2[x1];
uint br = s2[x2];
- int distx = (fx & 0x0000ffff) >> 12;
+ int distx = ((fx & 0x0000ffff) + 0x0800) >> 12;
*b = interpolate_4_pixels_16(tl, tr, bl, br, distx, disty);
fx += fdx;
++b;
@@ -2253,6 +2335,10 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c
if (blendType != BlendTransformedBilinearTiled) {
#define BILINEAR_ROTATE_BOUNDS_PROLOG \
+ const qint64 min_fx = qint64(image_x1) * fixed_scale; \
+ const qint64 max_fx = qint64(image_x2) * fixed_scale; \
+ const qint64 min_fy = qint64(image_y1) * fixed_scale; \
+ const qint64 max_fy = qint64(image_y2) * fixed_scale; \
while (b < end) { \
int x1 = (fx >> 16); \
int x2; \
@@ -2275,7 +2361,15 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c
fy += fdy; \
++b; \
} \
- uint *boundedEnd = end - 3; \
+ uint *boundedEnd = end; \
+ if (fdx > 0) \
+ boundedEnd = qMin(boundedEnd, b + (max_fx - fx) / fdx); \
+ else if (fdx < 0) \
+ boundedEnd = qMin(boundedEnd, b + (min_fx - fx) / fdx); \
+ if (fdy > 0) \
+ boundedEnd = qMin(boundedEnd, b + (max_fy - fy) / fdy); \
+ else if (fdy < 0) \
+ boundedEnd = qMin(boundedEnd, b + (min_fy - fy) / fdy); \
boundedEnd -= 3;
#if defined(__SSE2__)
@@ -2285,6 +2379,7 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c
const __m128i v_256 = _mm_set1_epi16(256);
const __m128i v_fdx = _mm_set1_epi32(fdx*4);
const __m128i v_fdy = _mm_set1_epi32(fdy*4);
+ const __m128i v_fxy_r = _mm_set1_epi32(0x8);
__m128i v_fx = _mm_setr_epi32(fx, fx + fdx, fx + fdx + fdx, fx + fdx + fdx + fdx);
__m128i v_fy = _mm_setr_epi32(fy, fy + fdy, fy + fdy + fdy, fy + fdy + fdy + fdy);
@@ -2293,15 +2388,6 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c
const __m128i vbpl = _mm_shufflelo_epi16(_mm_cvtsi32_si128(bytesPerLine/4), _MM_SHUFFLE(0, 0, 0, 0));
while (b < boundedEnd) {
- if (fdx > 0 && (short)_mm_extract_epi16(v_fx, 7) >= image_x2)
- break;
- if (fdx < 0 && (short)_mm_extract_epi16(v_fx, 7) < image_x1)
- break;
- if (fdy > 0 && (short)_mm_extract_epi16(v_fy, 7) >= image_y2)
- break;
- if (fdy < 0 && (short)_mm_extract_epi16(v_fy, 7) < image_y1)
- break;
-
const __m128i vy = _mm_packs_epi32(_mm_srli_epi32(v_fy, 16), _mm_setzero_si128());
// 4x16bit * 4x16bit -> 4x32bit
__m128i offset = _mm_unpacklo_epi16(_mm_mullo_epi16(vy, vbpl), _mm_mulhi_epi16(vy, vbpl));
@@ -2317,8 +2403,10 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c
const __m128i bl = _mm_setr_epi32(bottomData[offset0], bottomData[offset1], bottomData[offset2], bottomData[offset3]);
const __m128i br = _mm_setr_epi32(bottomData[offset0 + 1], bottomData[offset1 + 1], bottomData[offset2 + 1], bottomData[offset3 + 1]);
- __m128i v_distx = _mm_srli_epi16(v_fx, 12);
- __m128i v_disty = _mm_srli_epi16(v_fy, 12);
+ __m128i v_distx = _mm_srli_epi16(v_fx, 8);
+ __m128i v_disty = _mm_srli_epi16(v_fy, 8);
+ v_distx = _mm_srli_epi16(_mm_add_epi32(v_distx, v_fxy_r), 4);
+ v_disty = _mm_srli_epi16(_mm_add_epi32(v_disty, v_fxy_r), 4);
v_distx = _mm_shufflehi_epi16(v_distx, _MM_SHUFFLE(2,2,0,0));
v_distx = _mm_shufflelo_epi16(v_distx, _MM_SHUFFLE(2,2,0,0));
v_disty = _mm_shufflehi_epi16(v_disty, _MM_SHUFFLE(2,2,0,0));
@@ -2357,8 +2445,8 @@ static const uint * QT_FASTCALL fetchTransformedBilinearARGB32PM(uint *buffer, c
int disty = (fy & 0x0000ffff) >> 8;
*b = interpolate_4_pixels(tl, tr, bl, br, distx, disty);
#else
- int distx = (fx & 0x0000ffff) >> 12;
- int disty = (fy & 0x0000ffff) >> 12;
+ int distx = ((fx & 0x0000ffff) + 0x0800) >> 12;
+ int disty = ((fy & 0x0000ffff) + 0x0800) >> 12;
*b = interpolate_4_pixels_16(tl, tr, bl, br, distx, disty);
#endif
@@ -2423,7 +2511,7 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
const QSpanData *data, int y, int x, int length)
{
const QPixelLayout *layout = &qPixelLayouts[data->texture.format];
- const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0;
+ const QVector<QRgb> *clut = data->texture.colorTable;
int image_width = data->texture.width;
int image_height = data->texture.height;
@@ -2479,9 +2567,9 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
int len2 = qMin(x, count - len1);
ptr1 = fetch(buf1, s1, x, len1);
- ptr1 = layout->convertToARGB32PM(buf1, ptr1, len1, layout, clut);
+ ptr1 = layout->convertToARGB32PM(buf1, ptr1, len1, clut, 0);
ptr2 = fetch(buf2, s2, x, len1);
- ptr2 = layout->convertToARGB32PM(buf2, ptr2, len1, layout, clut);
+ ptr2 = layout->convertToARGB32PM(buf2, ptr2, len1, clut, 0);
for (int i = 0; i < len1; ++i) {
uint t = ptr1[i];
uint b = ptr2[i];
@@ -2491,9 +2579,9 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
if (len2) {
ptr1 = fetch(buf1 + len1, s1, 0, len2);
- ptr1 = layout->convertToARGB32PM(buf1 + len1, ptr1, len2, layout, clut);
+ ptr1 = layout->convertToARGB32PM(buf1 + len1, ptr1, len2, clut, 0);
ptr2 = fetch(buf2 + len1, s2, 0, len2);
- ptr2 = layout->convertToARGB32PM(buf2 + len1, ptr2, len2, layout, clut);
+ ptr2 = layout->convertToARGB32PM(buf2 + len1, ptr2, len2, clut, 0);
for (int i = 0; i < len2; ++i) {
uint t = ptr1[i];
uint b = ptr2[i];
@@ -2512,9 +2600,9 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
int leading = start - x;
ptr1 = fetch(buf1 + leading, s1, start, len);
- ptr1 = layout->convertToARGB32PM(buf1 + leading, ptr1, len, layout, clut);
+ ptr1 = layout->convertToARGB32PM(buf1 + leading, ptr1, len, clut, 0);
ptr2 = fetch(buf2 + leading, s2, start, len);
- ptr2 = layout->convertToARGB32PM(buf2 + leading, ptr2, len, layout, clut);
+ ptr2 = layout->convertToARGB32PM(buf2 + leading, ptr2, len, clut, 0);
for (int i = 0; i < len; ++i) {
uint t = ptr1[i];
@@ -2576,8 +2664,8 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
fx += fdx;
}
- layout->convertToARGB32PM(buf1, buf1, len * 2, layout, clut);
- layout->convertToARGB32PM(buf2, buf2, len * 2, layout, clut);
+ layout->convertToARGB32PM(buf1, buf1, len * 2, clut, 0);
+ layout->convertToARGB32PM(buf2, buf2, len * 2, clut, 0);
if ((fdx < 0 && fdx > -(fixed_scale / 8)) || std::abs(data->m22) < (1./8.)) { // scale up more than 8x
int disty = (fy & 0x0000ffff) >> 8;
@@ -2587,13 +2675,13 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
fracX += fdx;
}
} else { //scale down
- int disty = (fy & 0x0000ffff) >> 12;
+ int disty = ((fy & 0x0000ffff) + 0x0800) >> 12;
for (int i = 0; i < len; ++i) {
uint tl = buf1[i * 2 + 0];
uint tr = buf1[i * 2 + 1];
uint bl = buf2[i * 2 + 0];
uint br = buf2[i * 2 + 1];
- int distx = (fracX & 0x0000ffff) >> 12;
+ int distx = ((fracX & 0x0000ffff) + 0x0800) >> 12;
b[i] = interpolate_4_pixels_16(tl, tr, bl, br, distx, disty);
fracX += fdx;
}
@@ -2638,8 +2726,8 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
fx += fdx;
fy += fdy;
}
- layout->convertToARGB32PM(buf1, buf1, len * 2, layout, clut);
- layout->convertToARGB32PM(buf2, buf2, len * 2, layout, clut);
+ layout->convertToARGB32PM(buf1, buf1, len * 2, clut, 0);
+ layout->convertToARGB32PM(buf2, buf2, len * 2, clut, 0);
if (std::abs(data->m11) > 8 || std::abs(data->m22) > 8) {
//if we are zooming more than 8 times, we use 8bit precision for the position.
@@ -2659,8 +2747,8 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
uint bl = buf2[i * 2 + 0];
uint br = buf2[i * 2 + 1];
- int distx = (fracX & 0x0000ffff) >> 12;
- int disty = (fracY & 0x0000ffff) >> 12;
+ int distx = ((fracX & 0x0000ffff) + 0x0800) >> 12;
+ int disty = ((fracY & 0x0000ffff) + 0x0800) >> 12;
b[i] = interpolate_4_pixels_16(tl, tr, bl, br, distx, disty);
fracX += fdx;
@@ -2730,8 +2818,8 @@ static const uint *QT_FASTCALL fetchTransformedBilinear(uint *buffer, const Oper
fw += fdw;
}
- layout->convertToARGB32PM(buf1, buf1, len * 2, layout, clut);
- layout->convertToARGB32PM(buf2, buf2, len * 2, layout, clut);
+ layout->convertToARGB32PM(buf1, buf1, len * 2, clut, 0);
+ layout->convertToARGB32PM(buf2, buf2, len * 2, clut, 0);
for (int i = 0; i < len; ++i) {
int distx = distxs[i];
@@ -2752,7 +2840,7 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co
const QSpanData *data, int y, int x, int length)
{
const QPixelLayout *layout = &qPixelLayouts[data->texture.format];
- const QRgb *clut = data->texture.colorTable ? data->texture.colorTable->constData() : 0;
+ const QVector<QRgb> *clut = data->texture.colorTable;
int image_width = data->texture.width;
int image_height = data->texture.height;
@@ -2869,9 +2957,9 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co
fx += fdx;
}
- layout->convertToARGB64PM(buf1, sbuf1, len * 2, layout, clut);
+ layout->convertToARGB64PM(buf1, sbuf1, len * 2, clut, 0);
if (disty)
- layout->convertToARGB64PM(buf2, sbuf2, len * 2, layout, clut);
+ layout->convertToARGB64PM(buf2, sbuf2, len * 2, clut, 0);
for (int i = 0; i < len; ++i) {
int distx = (fracX & 0x0000ffff);
@@ -3007,8 +3095,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co
fx += fdx;
fy += fdy;
}
- layout->convertToARGB64PM(buf1, sbuf1, len * 2, layout, clut);
- layout->convertToARGB64PM(buf2, sbuf2, len * 2, layout, clut);
+ layout->convertToARGB64PM(buf1, sbuf1, len * 2, clut, 0);
+ layout->convertToARGB64PM(buf2, sbuf2, len * 2, clut, 0);
for (int i = 0; i < len; ++i) {
int distx = (fracX & 0x0000ffff);
@@ -3079,8 +3167,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co
fw += fdw;
}
- layout->convertToARGB64PM(buf1, sbuf1, len * 2, layout, clut);
- layout->convertToARGB64PM(buf2, sbuf2, len * 2, layout, clut);
+ layout->convertToARGB64PM(buf1, sbuf1, len * 2, clut, 0);
+ layout->convertToARGB64PM(buf2, sbuf2, len * 2, clut, 0);
for (int i = 0; i < len; ++i) {
int distx = distxs[i];
@@ -4038,7 +4126,7 @@ template<typename T>
struct QBlendBase
{
typedef T BlendType;
- QBlendBase(QSpanData *d, Operator o)
+ QBlendBase(QSpanData *d, const Operator &o)
: data(d)
, op(o)
, dest(0)
@@ -4057,7 +4145,7 @@ struct QBlendBase
class BlendSrcGeneric : public QBlendBase<uint>
{
public:
- BlendSrcGeneric(QSpanData *d, Operator o)
+ BlendSrcGeneric(QSpanData *d, const Operator &o)
: QBlendBase<uint>(d, o)
{
}
@@ -4083,7 +4171,7 @@ public:
class BlendSrcGenericRGB64 : public QBlendBase<QRgba64>
{
public:
- BlendSrcGenericRGB64(QSpanData *d, Operator o)
+ BlendSrcGenericRGB64(QSpanData *d, const Operator &o)
: QBlendBase<QRgba64>(d, o)
{
}
@@ -5764,7 +5852,7 @@ static inline void rgbBlendPixel(quint32 *dst, int coverage, int sr, int sg, int
*dst = qRgb(nr, ng, nb);
}
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
Q_GUI_EXPORT bool qt_needs_a8_gamma_correction = false;
static inline void grayBlendPixel(quint32 *dst, int coverage, int sr, int sg, int sb, const uint *gamma, const uchar *invgamma)
@@ -5801,7 +5889,7 @@ static void qt_alphamapblit_uint32(QRasterBuffer *rasterBuffer,
const quint32 c = color;
const int destStride = rasterBuffer->bytesPerLine() / sizeof(quint32);
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
const QDrawHelperGammaTables *tables = QGuiApplicationPrivate::instance()->gammaTables();
if (!tables)
return;
@@ -5828,7 +5916,7 @@ static void qt_alphamapblit_uint32(QRasterBuffer *rasterBuffer,
} else if (coverage == 255) {
dest[i] = c;
} else {
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && doGrayBlendPixel
&& qAlpha(dest[i]) == 255) {
grayBlendPixel(dest+i, coverage, sr, sg, sb, gamma, invgamma);
@@ -5869,7 +5957,7 @@ static void qt_alphamapblit_uint32(QRasterBuffer *rasterBuffer,
} else if (coverage == 255) {
dest[xp] = c;
} else {
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && doGrayBlendPixel
&& qAlpha(dest[xp]) == 255) {
grayBlendPixel(dest+xp, coverage, sr, sg, sb, gamma, invgamma);
@@ -6327,7 +6415,7 @@ void qt_memfill32(quint32 *dest, quint32 color, int count)
#endif
#ifdef QT_COMPILER_SUPPORTS_SSE4_1
-template<QtPixelOrder> const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *);
+template<QtPixelOrder> const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QVector<QRgb> *, QDitherInfo *);
#endif
extern void qInitBlendFunctions();
@@ -6403,14 +6491,19 @@ static void qInitDrawhelperFunctions()
#if defined(QT_COMPILER_SUPPORTS_SSE4_1)
if (qCpuHasFeature(SSE4_1)) {
#if !defined(__SSE4_1__)
- extern const uint *QT_FASTCALL convertARGB32ToARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *);
- extern const uint *QT_FASTCALL convertRGBA8888ToARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *);
+ extern const uint *QT_FASTCALL convertARGB32ToARGB32PM_sse4(uint *buffer, const uint *src, int count,
+ const QVector<QRgb> *, QDitherInfo *);
+ extern const uint *QT_FASTCALL convertRGBA8888ToARGB32PM_sse4(uint *buffer, const uint *src, int count,
+ const QVector<QRgb> *, QDitherInfo *);
qPixelLayouts[QImage::Format_ARGB32].convertToARGB32PM = convertARGB32ToARGB32PM_sse4;
qPixelLayouts[QImage::Format_RGBA8888].convertToARGB32PM = convertRGBA8888ToARGB32PM_sse4;
#endif
- extern const uint *QT_FASTCALL convertARGB32FromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *);
- extern const uint *QT_FASTCALL convertRGBA8888FromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *);
- extern const uint *QT_FASTCALL convertRGBXFromARGB32PM_sse4(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *);
+ extern const uint *QT_FASTCALL convertARGB32FromARGB32PM_sse4(uint *buffer, const uint *src, int count,
+ const QVector<QRgb> *, QDitherInfo *);
+ extern const uint *QT_FASTCALL convertRGBA8888FromARGB32PM_sse4(uint *buffer, const uint *src, int count,
+ const QVector<QRgb> *, QDitherInfo *);
+ extern const uint *QT_FASTCALL convertRGBXFromARGB32PM_sse4(uint *buffer, const uint *src, int count,
+ const QVector<QRgb> *, QDitherInfo *);
qPixelLayouts[QImage::Format_ARGB32].convertFromARGB32PM = convertARGB32FromARGB32PM_sse4;
qPixelLayouts[QImage::Format_RGBA8888].convertFromARGB32PM = convertRGBA8888FromARGB32PM_sse4;
qPixelLayouts[QImage::Format_RGBX8888].convertFromARGB32PM = convertRGBXFromARGB32PM_sse4;
@@ -6421,8 +6514,10 @@ static void qInitDrawhelperFunctions()
#if defined(QT_COMPILER_SUPPORTS_AVX2) && !defined(__AVX2__)
if (qCpuHasFeature(AVX2)) {
- extern const uint *QT_FASTCALL convertARGB32ToARGB32PM_avx2(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *);
- extern const uint *QT_FASTCALL convertRGBA8888ToARGB32PM_avx2(uint *buffer, const uint *src, int count, const QPixelLayout *, const QRgb *);
+ extern const uint *QT_FASTCALL convertARGB32ToARGB32PM_avx2(uint *buffer, const uint *src, int count,
+ const QVector<QRgb> *, QDitherInfo *);
+ extern const uint *QT_FASTCALL convertRGBA8888ToARGB32PM_avx2(uint *buffer, const uint *src, int count,
+ const QVector<QRgb> *, QDitherInfo *);
qPixelLayouts[QImage::Format_ARGB32].convertToARGB32PM = convertARGB32ToARGB32PM_avx2;
qPixelLayouts[QImage::Format_RGBA8888].convertToARGB32PM = convertRGBA8888ToARGB32PM_avx2;
}
diff --git a/src/gui/painting/qdrawhelper_avx2.cpp b/src/gui/painting/qdrawhelper_avx2.cpp
index e11536ebd0..35a975c972 100644
--- a/src/gui/painting/qdrawhelper_avx2.cpp
+++ b/src/gui/painting/qdrawhelper_avx2.cpp
@@ -44,13 +44,13 @@
QT_BEGIN_NAMESPACE
const uint *QT_FASTCALL convertARGB32ToARGB32PM_avx2(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
return qt_convertARGB32ToARGB32PM(buffer, src, count);
}
const uint *QT_FASTCALL convertRGBA8888ToARGB32PM_avx2(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
return qt_convertRGBA8888ToARGB32PM(buffer, src, count);
}
diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h
index 21af6039f8..922ff157e2 100644
--- a/src/gui/painting/qdrawhelper_p.h
+++ b/src/gui/painting/qdrawhelper_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include "QtCore/qglobal.h"
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtCore/qmath.h"
#include "QtGui/qcolor.h"
#include "QtGui/qpainter.h"
@@ -1171,11 +1171,15 @@ inline int comp_func_Plus_one_pixel(uint d, const uint s)
#undef MIX
#undef AMIX
-struct QPixelLayout;
+struct QDitherInfo {
+ int x;
+ int y;
+};
+
typedef const uint *(QT_FASTCALL *ConvertFunc)(uint *buffer, const uint *src, int count,
- const QPixelLayout *layout, const QRgb *clut);
+ const QVector<QRgb> *clut, QDitherInfo *dither);
typedef const QRgba64 *(QT_FASTCALL *ConvertFunc64)(QRgba64 *buffer, const uint *src, int count,
- const QPixelLayout *layout, const QRgb *clut);
+ const QVector<QRgb> *clut, QDitherInfo *dither);
struct QPixelLayout
{
diff --git a/src/gui/painting/qdrawhelper_sse4.cpp b/src/gui/painting/qdrawhelper_sse4.cpp
index a39cdb3127..257bad9eca 100644
--- a/src/gui/painting/qdrawhelper_sse4.cpp
+++ b/src/gui/painting/qdrawhelper_sse4.cpp
@@ -45,19 +45,19 @@
QT_BEGIN_NAMESPACE
const uint *QT_FASTCALL convertARGB32ToARGB32PM_sse4(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
return qt_convertARGB32ToARGB32PM(buffer, src, count);
}
const uint *QT_FASTCALL convertRGBA8888ToARGB32PM_sse4(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
return qt_convertRGBA8888ToARGB32PM(buffer, src, count);
}
const uint *QT_FASTCALL convertARGB32FromARGB32PM_sse4(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = qUnpremultiply_sse4(src[i]);
@@ -65,7 +65,7 @@ const uint *QT_FASTCALL convertARGB32FromARGB32PM_sse4(uint *buffer, const uint
}
const uint *QT_FASTCALL convertRGBA8888FromARGB32PM_sse4(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = ARGB2RGBA(qUnpremultiply_sse4(src[i]));
@@ -73,7 +73,7 @@ const uint *QT_FASTCALL convertRGBA8888FromARGB32PM_sse4(uint *buffer, const uin
}
const uint *QT_FASTCALL convertRGBXFromARGB32PM_sse4(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = ARGB2RGBA(0xff000000 | qUnpremultiply_sse4(src[i]));
@@ -82,7 +82,7 @@ const uint *QT_FASTCALL convertRGBXFromARGB32PM_sse4(uint *buffer, const uint *s
template<QtPixelOrder PixelOrder>
const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM_sse4(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *)
+ const QVector<QRgb> *, QDitherInfo *)
{
for (int i = 0; i < count; ++i)
buffer[i] = qConvertArgb32ToA2rgb30_sse4<PixelOrder>(src[i]);
@@ -91,10 +91,10 @@ const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM_sse4(uint *buffer, const ui
template
const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM_sse4<PixelOrderBGR>(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *);
+ const QVector<QRgb> *, QDitherInfo *);
template
const uint *QT_FASTCALL convertA2RGB30PMFromARGB32PM_sse4<PixelOrderRGB>(uint *buffer, const uint *src, int count,
- const QPixelLayout *, const QRgb *);
+ const QVector<QRgb> *, QDitherInfo *);
QT_END_NAMESPACE
diff --git a/src/gui/painting/qdrawhelper_x86_p.h b/src/gui/painting/qdrawhelper_x86_p.h
index 37be8b89a9..cefc213999 100644
--- a/src/gui/painting/qdrawhelper_x86_p.h
+++ b/src/gui/painting/qdrawhelper_x86_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <private/qdrawhelper_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/painting/qdrawingprimitive_sse2_p.h b/src/gui/painting/qdrawingprimitive_sse2_p.h
index e16529e2d0..8799dff92a 100644
--- a/src/gui/painting/qdrawingprimitive_sse2_p.h
+++ b/src/gui/painting/qdrawingprimitive_sse2_p.h
@@ -40,6 +40,7 @@
#ifndef QDRAWINGPRIMITIVE_SSE2_P_H
#define QDRAWINGPRIMITIVE_SSE2_P_H
+#include <QtGui/private/qtguiglobal_p.h>
#include <private/qsimd_p.h>
#include "qdrawhelper_p.h"
diff --git a/src/gui/painting/qemulationpaintengine_p.h b/src/gui/painting/qemulationpaintengine_p.h
index f3cf88af17..457cc06d63 100644
--- a/src/gui/painting/qemulationpaintengine_p.h
+++ b/src/gui/painting/qemulationpaintengine_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <private/qpaintengineex_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/painting/qfixed_p.h b/src/gui/painting/qfixed_p.h
index d2b6e51ab1..846592881c 100644
--- a/src/gui/painting/qfixed_p.h
+++ b/src/gui/painting/qfixed_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtCore/qdebug.h"
#include "QtCore/qpoint.h"
#include "QtCore/qsize.h"
diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h
index b28c8433cd..76bf61671c 100644
--- a/src/gui/painting/qmatrix.h
+++ b/src/gui/painting/qmatrix.h
@@ -40,6 +40,7 @@
#ifndef QMATRIX_H
#define QMATRIX_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qpolygon.h>
#include <QtGui/qregion.h>
#include <QtGui/qwindowdefs.h>
diff --git a/src/gui/painting/qmemrotate_p.h b/src/gui/painting/qmemrotate_p.h
index 64cfb22517..62613d301a 100644
--- a/src/gui/painting/qmemrotate_p.h
+++ b/src/gui/painting/qmemrotate_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "private/qdrawhelper_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/gui/painting/qoutlinemapper_p.h b/src/gui/painting/qoutlinemapper_p.h
index 47413d920c..71999fbdee 100644
--- a/src/gui/painting/qoutlinemapper_p.h
+++ b/src/gui/painting/qoutlinemapper_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtCore/qrect.h>
#include <QtGui/qtransform.h>
diff --git a/src/gui/painting/qpagedpaintdevice.h b/src/gui/painting/qpagedpaintdevice.h
index 3aebbb7551..c516f6a963 100644
--- a/src/gui/painting/qpagedpaintdevice.h
+++ b/src/gui/painting/qpagedpaintdevice.h
@@ -40,6 +40,7 @@
#ifndef QPAGEDPAINTDEVICE_H
#define QPAGEDPAINTDEVICE_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qpaintdevice.h>
#include <QtGui/qpagelayout.h>
diff --git a/src/gui/painting/qpagedpaintdevice_p.h b/src/gui/painting/qpagedpaintdevice_p.h
index 028ab3b5af..a993ea4cac 100644
--- a/src/gui/painting/qpagedpaintdevice_p.h
+++ b/src/gui/painting/qpagedpaintdevice_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <qpagedpaintdevice.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/painting/qpagelayout.h b/src/gui/painting/qpagelayout.h
index bd29165777..b41689d33b 100644
--- a/src/gui/painting/qpagelayout.h
+++ b/src/gui/painting/qpagelayout.h
@@ -40,6 +40,7 @@
#ifndef QPAGELAYOUT_H
#define QPAGELAYOUT_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qsharedpointer.h>
#include <QtCore/qstring.h>
#include <QtCore/qmargins.h>
diff --git a/src/gui/painting/qpagesize.h b/src/gui/painting/qpagesize.h
index 4916ddd4b5..82054824b4 100644
--- a/src/gui/painting/qpagesize.h
+++ b/src/gui/painting/qpagesize.h
@@ -40,6 +40,7 @@
#ifndef QPAGESIZE_H
#define QPAGESIZE_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qsharedpointer.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/painting/qpaintdevice.h b/src/gui/painting/qpaintdevice.h
index 5c9b966029..9458b4ba9a 100644
--- a/src/gui/painting/qpaintdevice.h
+++ b/src/gui/painting/qpaintdevice.h
@@ -40,6 +40,7 @@
#ifndef QPAINTDEVICE_H
#define QPAINTDEVICE_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qwindowdefs.h>
#include <QtCore/qrect.h>
diff --git a/src/gui/painting/qpaintengine.h b/src/gui/painting/qpaintengine.h
index a9da37b354..9fb67e253e 100644
--- a/src/gui/painting/qpaintengine.h
+++ b/src/gui/painting/qpaintengine.h
@@ -40,6 +40,7 @@
#ifndef QPAINTENGINE_H
#define QPAINTENGINE_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qnamespace.h>
#include <QtCore/qobjectdefs.h>
#include <QtCore/qscopedpointer.h>
diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp
index 81191d07b8..a50d1dfd73 100644
--- a/src/gui/painting/qpaintengine_blitter.cpp
+++ b/src/gui/painting/qpaintengine_blitter.cpp
@@ -312,7 +312,7 @@ void QBlitterPaintEnginePrivate::updateBrushState(QPainterState *s)
{
Qt::BrushStyle style = qbrush_style(s->brush);
- caps.updateState(STATE_BRUSH_PATTERN, style > Qt::SolidPattern);
+ caps.updateState(STATE_BRUSH_PATTERN, style != Qt::SolidPattern);
caps.updateState(STATE_BRUSH_ALPHA,
qbrush_color(s->brush).alpha() < 255);
}
@@ -374,9 +374,8 @@ void QBlitterPaintEnginePrivate::fillRect(const QRectF &rect, const QColor &colo
else
pmData->blittable()->fillRect(targetRect & clipData->clipRect, color);
} else if (clipData->hasRegionClip) {
- QVector<QRect> rects = clipData->clipRegion.rects();
- for (int i = 0; i < rects.size(); ++i) {
- QRect intersectRect = rects.at(i).intersected(targetRect.toRect());
+ for (const QRect &rect : clipData->clipRegion) {
+ QRect intersectRect = rect.intersected(targetRect.toRect());
if (!intersectRect.isEmpty()) {
unlock();
if (alpha)
@@ -609,10 +608,8 @@ void QBlitterPaintEngine::fillRect(const QRectF &rect, const QBrush &brush)
}
} else if (clipData->hasRegionClip) {
QRect unclippedTargetRect(x, y, blitWidth, blitHeight);
- const QVector<QRect> intersectedRects = clipData->clipRegion.intersected(unclippedTargetRect).rects();
- const int intersectedSize = intersectedRects.size();
- for (int i = 0; i < intersectedSize; ++i) {
- const QRect &targetRect = intersectedRects.at(i);
+ const QRegion targetRegion = clipData->clipRegion.intersected(unclippedTargetRect);
+ for (const QRect &targetRect : targetRegion) {
if (!targetRect.isValid() || targetRect.isEmpty())
continue;
int tmpSrcX = srcX + (targetRect.x() - x);
@@ -686,9 +683,8 @@ void QBlitterPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const Q
if (clipData->hasRectClip) {
d->clipAndDrawPixmap(clipData->clipRect, targetRect, pm, sr, canDrawOpacity);
} else if (clipData->hasRegionClip) {
- QVector<QRect>rects = clipData->clipRegion.rects();
- for (int i = 0; i<rects.size(); ++i)
- d->clipAndDrawPixmap(rects.at(i), targetRect, pm, sr, canDrawOpacity);
+ for (const QRect &rect : clipData->clipRegion)
+ d->clipAndDrawPixmap(rect, targetRect, pm, sr, canDrawOpacity);
}
} else {
QRectF deviceRect(0, 0, paintDevice()->width(), paintDevice()->height());
diff --git a/src/gui/painting/qpaintengine_blitter_p.h b/src/gui/painting/qpaintengine_blitter_p.h
index 3feabcf6fc..40f5347b26 100644
--- a/src/gui/painting/qpaintengine_blitter_p.h
+++ b/src/gui/painting/qpaintengine_blitter_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "private/qpaintengine_raster_p.h"
#ifndef QT_NO_BLITTABLE
diff --git a/src/gui/painting/qpaintengine_p.h b/src/gui/painting/qpaintengine_p.h
index c14f085721..1a1df547bb 100644
--- a/src/gui/painting/qpaintengine_p.h
+++ b/src/gui/painting/qpaintengine_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtGui/qpainter.h"
#include "QtGui/qpaintengine.h"
#include "QtGui/qregion.h"
diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h
index 1afb119535..8cde88fa82 100644
--- a/src/gui/painting/qpaintengine_raster_p.h
+++ b/src/gui/painting/qpaintengine_raster_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "private/qpaintengineex_p.h"
#include "QtGui/qpainterpath.h"
#include "private/qdatabuffer_p.h"
diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h
index 643c39c80f..7c2c98140f 100644
--- a/src/gui/painting/qpaintengineex_p.h
+++ b/src/gui/painting/qpaintengineex_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtGui/qpaintengine.h>
#include <private/qpaintengine_p.h>
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 2c5e0672b1..6472481e7a 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -2834,7 +2834,7 @@ void QPainter::setClipRegion(const QRegion &r, Qt::ClipOperation op)
QRect rect = r.boundingRect();
if (qt_show_painter_debug_output)
printf("QPainter::setClipRegion(), size=%d, [%d,%d,%d,%d]\n",
- r.rects().size(), rect.x(), rect.y(), rect.width(), rect.height());
+ r.rectCount(), rect.x(), rect.y(), rect.width(), rect.height());
#endif
if (!d->engine) {
qWarning("QPainter::setClipRegion: Painter not active");
@@ -6477,6 +6477,8 @@ void QPainterPrivate::drawTextItem(const QPointF &p, const QTextItem &_ti, QText
extended->drawTextItem(QPointF(x, y), ti2);
else
engine->drawTextItem(QPointF(x, y), ti2);
+ drawTextItemDecoration(q, p, ti2.fontEngine, textEngine, ti2.underlineStyle,
+ ti2.flags, ti2.width.toReal(), ti2.charFormat);
if (!rtl)
x += ti2.width.toReal();
@@ -6508,6 +6510,8 @@ void QPainterPrivate::drawTextItem(const QPointF &p, const QTextItem &_ti, QText
extended->drawTextItem(QPointF(x, y), ti2);
else
engine->drawTextItem(QPointF(x,y), ti2);
+ drawTextItemDecoration(q, p, ti2.fontEngine, textEngine, ti2.underlineStyle,
+ ti2.flags, ti2.width.toReal(), ti2.charFormat);
// reset the high byte for all glyphs
const int hi = which << 24;
@@ -6519,9 +6523,9 @@ void QPainterPrivate::drawTextItem(const QPointF &p, const QTextItem &_ti, QText
extended->drawTextItem(p, ti);
else
engine->drawTextItem(p, ti);
+ drawTextItemDecoration(q, p, ti.fontEngine, textEngine, ti.underlineStyle,
+ ti.flags, ti.width.toReal(), ti.charFormat);
}
- drawTextItemDecoration(q, p, ti.fontEngine, textEngine, ti.underlineStyle,
- ti.flags, ti.width.toReal(), ti.charFormat);
if (state->renderHints != oldRenderHints) {
state->renderHints = oldRenderHints;
diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h
index 5743d97405..46817b9c73 100644
--- a/src/gui/painting/qpainter.h
+++ b/src/gui/painting/qpainter.h
@@ -40,6 +40,7 @@
#ifndef QPAINTER_H
#define QPAINTER_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qnamespace.h>
#include <QtCore/qrect.h>
#include <QtCore/qpoint.h>
diff --git a/src/gui/painting/qpainter_p.h b/src/gui/painting/qpainter_p.h
index 23ab5db7b4..2d44577310 100644
--- a/src/gui/painting/qpainter_p.h
+++ b/src/gui/painting/qpainter_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtGui/qbrush.h"
#include "QtGui/qfont.h"
#include "QtGui/qpen.h"
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index 5b91266b64..7dbc83b338 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -1294,10 +1294,9 @@ void QPainterPath::addRegion(const QRegion &region)
ensureData();
detach();
- QVector<QRect> rects = region.rects();
- d_func()->elements.reserve(rects.size() * 5);
- for (int i=0; i<rects.size(); ++i)
- addRect(rects.at(i));
+ d_func()->elements.reserve(region.rectCount() * 5);
+ for (const QRect &rect : region)
+ addRect(rect);
}
diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h
index 882918fc87..131fcde8cc 100644
--- a/src/gui/painting/qpainterpath.h
+++ b/src/gui/painting/qpainterpath.h
@@ -40,6 +40,7 @@
#ifndef QPAINTERPATH_H
#define QPAINTERPATH_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qmatrix.h>
#include <QtCore/qglobal.h>
#include <QtCore/qrect.h>
diff --git a/src/gui/painting/qpainterpath_p.h b/src/gui/painting/qpainterpath_p.h
index e90cdb0f43..92d9a4ea66 100644
--- a/src/gui/painting/qpainterpath_p.h
+++ b/src/gui/painting/qpainterpath_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtGui/qpainterpath.h"
#include "QtGui/qregion.h"
#include "QtCore/qlist.h"
diff --git a/src/gui/painting/qpathclipper_p.h b/src/gui/painting/qpathclipper_p.h
index fe3ce84e4a..64e684e1ad 100644
--- a/src/gui/painting/qpathclipper_p.h
+++ b/src/gui/painting/qpathclipper_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtGui/qpainterpath.h>
#include <QtCore/qlist.h>
diff --git a/src/gui/painting/qpathsimplifier_p.h b/src/gui/painting/qpathsimplifier_p.h
index 47b1c3c623..6ef298f6bf 100644
--- a/src/gui/painting/qpathsimplifier_p.h
+++ b/src/gui/painting/qpathsimplifier_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtGui/qpainterpath.h>
#include <QtGui/private/qdatabuffer_p.h>
#include <QtGui/private/qvectorpath_p.h>
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp
index d568dca6b9..34f1c51f6d 100644
--- a/src/gui/painting/qpdf.cpp
+++ b/src/gui/painting/qpdf.cpp
@@ -1078,9 +1078,8 @@ void QPdfEngine::updateState(const QPaintEngineState &state)
} else if (flags & DirtyClipRegion) {
d->clipEnabled = true;
QPainterPath path;
- QVector<QRect> rects = state.clipRegion().rects();
- for (int i = 0; i < rects.size(); ++i)
- path.addRect(rects.at(i));
+ for (const QRect &rect : state.clipRegion())
+ path.addRect(rect);
updateClipPath(path, state.clipOperation());
flags |= DirtyClipPath;
} else if (flags & DirtyClipEnabled) {
diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h
index ef41f1efc1..cb1a91e09f 100644
--- a/src/gui/painting/qpdf_p.h
+++ b/src/gui/painting/qpdf_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtGui/private/qtguiglobal_p.h>
#ifndef QT_NO_PDF
diff --git a/src/gui/painting/qpdfwriter.h b/src/gui/painting/qpdfwriter.h
index cf1da95bf1..baad274818 100644
--- a/src/gui/painting/qpdfwriter.h
+++ b/src/gui/painting/qpdfwriter.h
@@ -40,7 +40,7 @@
#ifndef QPDFWRITER_H
#define QPDFWRITER_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#ifndef QT_NO_PDF
diff --git a/src/gui/painting/qpen.h b/src/gui/painting/qpen.h
index 7469931a48..d8d99ba800 100644
--- a/src/gui/painting/qpen.h
+++ b/src/gui/painting/qpen.h
@@ -40,6 +40,7 @@
#ifndef QPEN_H
#define QPEN_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qcolor.h>
#include <QtGui/qbrush.h>
diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp
index 35cf1dae86..e2c5a82ffc 100644
--- a/src/gui/painting/qplatformbackingstore.cpp
+++ b/src/gui/painting/qplatformbackingstore.cpp
@@ -49,7 +49,7 @@
#include <QtGui/QOpenGLContext>
#include <QtGui/QOpenGLFunctions>
#ifndef QT_NO_OPENGL
-#include <QtGui/private/qopengltextureblitter_p.h>
+#include <QtGui/qopengltextureblitter.h>
#endif
#include <qpa/qplatformgraphicsbuffer.h>
#include <qpa/qplatformgraphicsbufferhelper.h>
@@ -251,9 +251,8 @@ static QRegion deviceRegion(const QRegion &region, QWindow *window, const QPoint
return region;
QVector<QRect> rects;
- const QVector<QRect> regionRects = region.rects();
- rects.reserve(regionRects.count());
- for (const QRect &rect : regionRects)
+ rects.reserve(region.rectCount());
+ for (const QRect &rect : region)
rects.append(deviceRect(rect.translated(offset), window));
QRegion deviceRegion;
@@ -390,7 +389,7 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &regi
if (textureId) {
if (d_ptr->needsSwizzle)
- d_ptr->blitter->setSwizzleRB(true);
+ d_ptr->blitter->setRedBlueSwizzle(true);
// The backingstore is for the entire tlw.
// In case of native children offset tells the position relative to the tlw.
const QRect srcRect = toBottomLeftRect(deviceWindowRect.translated(offset), d_ptr->textureSize.height());
@@ -399,7 +398,7 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &regi
origin);
d_ptr->blitter->blit(textureId, QMatrix4x4(), source);
if (d_ptr->needsSwizzle)
- d_ptr->blitter->setSwizzleRB(false);
+ d_ptr->blitter->setRedBlueSwizzle(false);
}
// Textures for renderToTexture widgets that have WA_AlwaysStackOnTop set.
@@ -413,7 +412,7 @@ void QPlatformBackingStore::composeAndFlush(QWindow *window, const QRegion &regi
context->swapBuffers(window);
}
-
+#endif
/*!
Implemented in subclasses to return the content of the backingstore as a QImage.
@@ -426,7 +425,7 @@ QImage QPlatformBackingStore::toImage() const
{
return QImage();
}
-
+#ifndef QT_NO_OPENGL
/*!
May be reimplemented in subclasses to return the content of the
backingstore as an OpenGL texture. \a dirtyRegion is the part of the
diff --git a/src/gui/painting/qplatformbackingstore.h b/src/gui/painting/qplatformbackingstore.h
index 9b09620cce..8d0e29ad8d 100644
--- a/src/gui/painting/qplatformbackingstore.h
+++ b/src/gui/painting/qplatformbackingstore.h
@@ -49,6 +49,7 @@
// source and binary incompatible with future versions of Qt.
//
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qrect.h>
#include <QtCore/qobject.h>
@@ -121,7 +122,9 @@ public:
virtual void composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset,
QPlatformTextureList *textures, QOpenGLContext *context,
bool translucentBackground);
+#endif
virtual QImage toImage() const;
+#ifndef QT_NO_OPENGL
enum TextureFlag {
TextureSwizzle = 0x01,
TextureFlip = 0x02,
diff --git a/src/gui/painting/qpolygon.cpp b/src/gui/painting/qpolygon.cpp
index d2203595c8..126b752811 100644
--- a/src/gui/painting/qpolygon.cpp
+++ b/src/gui/painting/qpolygon.cpp
@@ -443,14 +443,15 @@ void QPolygon::putPoints(int index, int nPoints, const QPolygon & from, int from
QRect QPolygon::boundingRect() const
{
- if (isEmpty())
- return QRect(0, 0, 0, 0);
const QPoint *pd = constData();
+ const QPoint *pe = pd + size();
+ if (pd == pe)
+ return QRect(0, 0, 0, 0);
int minx, maxx, miny, maxy;
minx = maxx = pd->x();
miny = maxy = pd->y();
++pd;
- for (int i = 1; i < size(); ++i) {
+ for (; pd != pe; ++pd) {
if (pd->x() < minx)
minx = pd->x();
else if (pd->x() > maxx)
@@ -459,7 +460,6 @@ QRect QPolygon::boundingRect() const
miny = pd->y();
else if (pd->y() > maxy)
maxy = pd->y();
- ++pd;
}
return QRect(QPoint(minx,miny), QPoint(maxx,maxy));
}
@@ -657,14 +657,15 @@ QPolygonF QPolygonF::translated(const QPointF &offset) const
QRectF QPolygonF::boundingRect() const
{
- if (isEmpty())
- return QRectF(0, 0, 0, 0);
const QPointF *pd = constData();
+ const QPointF *pe = pd + size();
+ if (pd == pe)
+ return QRectF(0, 0, 0, 0);
qreal minx, maxx, miny, maxy;
minx = maxx = pd->x();
miny = maxy = pd->y();
++pd;
- for (int i = 1; i < size(); ++i) {
+ while (pd != pe) {
if (pd->x() < minx)
minx = pd->x();
else if (pd->x() > maxx)
diff --git a/src/gui/painting/qpolygon.h b/src/gui/painting/qpolygon.h
index 23bdd1933f..c57802e84e 100644
--- a/src/gui/painting/qpolygon.h
+++ b/src/gui/painting/qpolygon.h
@@ -40,6 +40,7 @@
#ifndef QPOLYGON_H
#define QPOLYGON_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qvector.h>
#include <QtCore/qpoint.h>
#include <QtCore/qrect.h>
diff --git a/src/gui/painting/qpolygonclipper_p.h b/src/gui/painting/qpolygonclipper_p.h
index c67a692b52..04a31111c9 100644
--- a/src/gui/painting/qpolygonclipper_p.h
+++ b/src/gui/painting/qpolygonclipper_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "private/qdatabuffer_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/gui/painting/qrasterizer_p.h b/src/gui/painting/qrasterizer_p.h
index a3e12c076d..955577f4a3 100644
--- a/src/gui/painting/qrasterizer_p.h
+++ b/src/gui/painting/qrasterizer_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include "QtCore/qglobal.h"
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtGui/qpainter.h"
#include <private/qdrawhelper_p.h>
diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp
index 611e40e9aa..1ba6345bf9 100644
--- a/src/gui/painting/qregion.cpp
+++ b/src/gui/painting/qregion.cpp
@@ -81,8 +81,8 @@ QT_BEGIN_NAMESPACE
contains() a QPoint or QRect. The bounding rectangle can be found
with boundingRect().
- The function rects() gives a decomposition of the region into
- rectangles.
+ Iteration over the region (with begin(), end()) gives a decomposition of
+ the region into rectangles. The same sequence of rectangles is returned by rects().
Example of using complex regions:
\snippet code/src_gui_painting_qregion.cpp 0
@@ -395,23 +395,24 @@ void QRegion::exec(const QByteArray &buffer, int ver, QDataStream::ByteOrder byt
QDataStream &operator<<(QDataStream &s, const QRegion &r)
{
- QVector<QRect> a = r.rects();
- if (a.isEmpty()) {
+ auto b = r.begin(), e = r.end();
+ if (b == e) {
s << (quint32)0;
} else {
+ const auto size = e - b;
if (s.version() == 1) {
- int i;
- for (i = a.size() - 1; i > 0; --i) {
+ for (auto i = size - 1; i > 0; --i) {
s << (quint32)(12 + i * 24);
s << (int)QRGN_OR;
}
- for (i = 0; i < a.size(); ++i) {
- s << (quint32)(4+8) << (int)QRGN_SETRECT << a[i];
- }
+ for (auto it = b; it != e; ++it)
+ s << (quint32)(4+8) << (int)QRGN_SETRECT << *it;
} else {
- s << (quint32)(4 + 4 + 16 * a.size()); // 16: storage size of QRect
+ s << quint32(4 + 4 + 16 * size); // 16: storage size of QRect
s << (qint32)QRGN_RECTS;
- s << a;
+ s << quint32(size);
+ for (auto it = b; it != e; ++it)
+ s << *it;
}
}
return s;
@@ -722,12 +723,9 @@ bool QRegion::intersects(const QRegion &region) const
if (rectCount() == 1 && region.rectCount() == 1)
return true;
- const QVector<QRect> myRects = rects();
- const QVector<QRect> otherRects = region.rects();
-
- for (QVector<QRect>::const_iterator i1 = myRects.constBegin(); i1 < myRects.constEnd(); ++i1)
- for (QVector<QRect>::const_iterator i2 = otherRects.constBegin(); i2 < otherRects.constEnd(); ++i2)
- if (rect_intersects(*i1, *i2))
+ for (const QRect &myRect : *this)
+ for (const QRect &otherRect : region)
+ if (rect_intersects(myRect, otherRect))
return true;
return false;
}
@@ -928,6 +926,100 @@ QRegion QRegion::intersect(const QRect &r) const
*/
/*!
+ \typedef QRegion::const_iterator
+ \since 5.8
+
+ An iterator over the QRects that make up the region.
+
+ QRegion does not offer mutable iterators.
+
+ \sa begin(), end()
+*/
+
+/*!
+ \typedef QRegion::const_reverse_iterator
+ \since 5.8
+
+ A reverse iterator over the QRects that make up the region.
+
+ QRegion does not offer mutable iterators.
+
+ \sa rbegin(), rend()
+*/
+
+/*!
+ \fn QRegion::begin() const
+ \since 5.8
+
+ Returns a const_iterator pointing to the beginning of the range of
+ rectangles that make up this range, in the order in which rects()
+ returns them.
+
+ \sa rbegin(), cbegin(), end()
+*/
+
+/*!
+ \fn QRegion::cbegin() const
+ \since 5.8
+
+ Same as begin().
+*/
+
+/*!
+ \fn QRegion::end() const
+ \since 5.8
+
+ Returns a const_iterator pointing to one past the end of the range of
+ rectangles that make up this range, in the order in which rects()
+ returns them.
+
+ \sa rend(), cend(), begin()
+*/
+
+/*!
+ \fn QRegion::cend() const
+ \since 5.8
+
+ Same as end().
+*/
+
+/*!
+ \fn QRegion::rbegin() const
+ \since 5.8
+
+ Returns a const_reverse_iterator pointing to the beginning of the range of
+ rectangles that make up this range, in the reverse order in which rects()
+ returns them.
+
+ \sa begin(), crbegin(), rend()
+*/
+
+/*!
+ \fn QRegion::crbegin() const
+ \since 5.8
+
+ Same as rbegin().
+*/
+
+/*!
+ \fn QRegion::rend() const
+ \since 5.8
+
+ Returns a const_reverse_iterator pointing to one past the end of the range of
+ rectangles that make up this range, in the reverse order in which rects()
+ returns them.
+
+ \sa end(), crend(), rbegin()
+*/
+
+/*!
+ \fn QRegion::crend() const
+ \since 5.8
+
+ Same as rend().
+*/
+
+/*!
\fn void QRegion::setRects(const QRect *rects, int number)
Sets the region using the array of rectangles specified by \a rects and
@@ -1065,13 +1157,11 @@ Q_GUI_EXPORT QPainterPath qt_regionToPath(const QRegion &region)
return result;
}
- const QVector<QRect> rects = region.rects();
+ auto rect = region.begin();
+ const auto end = region.end();
QVarLengthArray<Segment> segments;
- segments.resize(4 * rects.size());
-
- const QRect *rect = rects.constData();
- const QRect *end = rect + rects.size();
+ segments.resize(4 * (end - rect));
int lastRowSegmentCount = 0;
Segment *lastRowSegments = 0;
@@ -1179,6 +1269,12 @@ struct QRegionPrivate {
}
}
+ const QRect *begin() const Q_DECL_NOTHROW
+ { return numRects == 1 ? &extents : rects.data(); } // avoid vectorize()
+
+ const QRect *end() const Q_DECL_NOTHROW
+ { return begin() + numRects; }
+
inline void append(const QRect *r);
void append(const QRegionPrivate *r);
void prepend(const QRect *r);
@@ -4200,7 +4296,7 @@ QRegion QRegion::xored(const QRegion &r) const
}
}
-QRect QRegion::boundingRect() const
+QRect QRegion::boundingRect() const Q_DECL_NOTHROW
{
if (isEmpty())
return QRect();
@@ -4256,6 +4352,16 @@ QVector<QRect> QRegion::rects() const
}
}
+QRegion::const_iterator QRegion::begin() const Q_DECL_NOTHROW
+{
+ return d->qt_rgn ? d->qt_rgn->begin() : nullptr;
+}
+
+QRegion::const_iterator QRegion::end() const Q_DECL_NOTHROW
+{
+ return d->qt_rgn ? d->qt_rgn->end() : nullptr;
+}
+
void QRegion::setRects(const QRect *rects, int num)
{
*this = QRegion();
@@ -4288,7 +4394,7 @@ void QRegion::setRects(const QRect *rects, int num)
}
}
-int QRegion::rectCount() const
+int QRegion::rectCount() const Q_DECL_NOTHROW
{
return (d->qt_rgn ? d->qt_rgn->numRects : 0);
}
@@ -4318,10 +4424,10 @@ bool QRegion::intersects(const QRect &rect) const
if (d->qt_rgn->numRects == 1)
return true;
- const QVector<QRect> myRects = rects();
- for (QVector<QRect>::const_iterator it = myRects.constBegin(); it < myRects.constEnd(); ++it)
- if (rect_intersects(r, *it))
+ for (const QRect &rect : *this) {
+ if (rect_intersects(r, rect))
return true;
+ }
return false;
}
diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h
index d66f80fcde..4f0a071da8 100644
--- a/src/gui/painting/qregion.h
+++ b/src/gui/painting/qregion.h
@@ -40,6 +40,7 @@
#ifndef QREGION_H
#define QREGION_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qatomic.h>
#include <QtCore/qrect.h>
#include <QtGui/qwindowdefs.h>
@@ -81,6 +82,18 @@ public:
bool isEmpty() const;
bool isNull() const;
+ typedef const QRect *const_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
+ const_iterator begin() const Q_DECL_NOTHROW;
+ const_iterator cbegin() const Q_DECL_NOTHROW { return begin(); }
+ const_iterator end() const Q_DECL_NOTHROW;
+ const_iterator cend() const Q_DECL_NOTHROW { return end(); }
+ const_reverse_iterator rbegin() const Q_DECL_NOTHROW { return const_reverse_iterator(end()); }
+ const_reverse_iterator crbegin() const Q_DECL_NOTHROW { return rbegin(); }
+ const_reverse_iterator rend() const Q_DECL_NOTHROW { return const_reverse_iterator(begin()); }
+ const_reverse_iterator crend() const Q_DECL_NOTHROW { return rend(); }
+
bool contains(const QPoint &p) const;
bool contains(const QRect &r) const;
@@ -108,10 +121,10 @@ public:
bool intersects(const QRegion &r) const;
bool intersects(const QRect &r) const;
- QRect boundingRect() const;
+ QRect boundingRect() const Q_DECL_NOTHROW;
QVector<QRect> rects() const;
void setRects(const QRect *rect, int num);
- int rectCount() const;
+ int rectCount() const Q_DECL_NOTHROW;
#ifdef Q_COMPILER_MANGLES_RETURN_TYPE
// ### Qt 6: remove these, they're kept for MSVC compat
const QRegion operator|(const QRegion &r) const;
@@ -165,6 +178,7 @@ Q_GUI_EXPORT
static const struct QRegionData shared_empty;
static void cleanUp(QRegionData *x);
};
+Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QRegion)
/*****************************************************************************
QRegion stream functions
diff --git a/src/gui/painting/qrgb.h b/src/gui/painting/qrgb.h
index 6e666025ac..fe8306109b 100644
--- a/src/gui/painting/qrgb.h
+++ b/src/gui/painting/qrgb.h
@@ -40,7 +40,7 @@
#ifndef QRGB_H
#define QRGB_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qprocessordetection.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/painting/qrgba64.h b/src/gui/painting/qrgba64.h
index 27e1e6e06d..a3ae0c9b14 100644
--- a/src/gui/painting/qrgba64.h
+++ b/src/gui/painting/qrgba64.h
@@ -40,7 +40,7 @@
#ifndef QRGBA64_H
#define QRGBA64_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qprocessordetection.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/painting/qrgba64_p.h b/src/gui/painting/qrgba64_p.h
index cf3dad5f90..0dadc038fa 100644
--- a/src/gui/painting/qrgba64_p.h
+++ b/src/gui/painting/qrgba64_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtGui/qrgba64.h>
#include <QtGui/private/qdrawhelper_p.h>
#include <private/qsimd_p.h>
@@ -72,27 +73,49 @@ inline QRgba64 multiplyAlpha256(QRgba64 rgba64, uint alpha256)
inline QRgba64 multiplyAlpha65535(QRgba64 rgba64, uint alpha65535)
{
+ return QRgba64::fromRgba64(qt_div_65535(rgba64.red() * alpha65535),
+ qt_div_65535(rgba64.green() * alpha65535),
+ qt_div_65535(rgba64.blue() * alpha65535),
+ qt_div_65535(rgba64.alpha() * alpha65535));
+}
+
#ifdef __SSE2__
- const __m128i va = _mm_shufflelo_epi16(_mm_cvtsi32_si128(alpha65535), _MM_SHUFFLE(0, 0, 0, 0));
- __m128i vs = _mm_loadl_epi64((__m128i*)&rgba64);
+Q_ALWAYS_INLINE __m128i multiplyAlpha65535(__m128i rgba64, __m128i va)
+{
+ __m128i vs = rgba64;
vs = _mm_unpacklo_epi16(_mm_mullo_epi16(vs, va), _mm_mulhi_epu16(vs, va));
vs = _mm_add_epi32(vs, _mm_srli_epi32(vs, 16));
vs = _mm_add_epi32(vs, _mm_set1_epi32(0x8000));
vs = _mm_srai_epi32(vs, 16);
vs = _mm_packs_epi32(vs, _mm_setzero_si128());
- _mm_storel_epi64((__m128i*)&rgba64, vs);
- return rgba64;
-#else
- return QRgba64::fromRgba64(qt_div_65535(rgba64.red() * alpha65535),
- qt_div_65535(rgba64.green() * alpha65535),
- qt_div_65535(rgba64.blue() * alpha65535),
- qt_div_65535(rgba64.alpha() * alpha65535));
+ return vs;
+}
+Q_ALWAYS_INLINE __m128i multiplyAlpha65535(__m128i rgba64, uint alpha65535)
+{
+ const __m128i va = _mm_shufflelo_epi16(_mm_cvtsi32_si128(alpha65535), _MM_SHUFFLE(0, 0, 0, 0));
+ return multiplyAlpha65535(rgba64, va);
+}
#endif
+
+#if defined(__ARM_NEON__)
+Q_ALWAYS_INLINE uint16x4_t multiplyAlpha65535(uint16x4_t rgba64, uint16x4_t alpha65535)
+{
+ uint32x4_t vs32 = vmull_u16(rgba64, alpha65535); // vs = vs * alpha
+ vs32 = vsraq_n_u32(vs32, vs32, 16); // vs = vs + (vs >> 16)
+ return vrshrn_n_u32(vs32, 16); // vs = (vs + 0x8000) >> 16
}
+Q_ALWAYS_INLINE uint16x4_t multiplyAlpha65535(uint16x4_t rgba64, uint alpha65535)
+{
+ uint32x4_t vs32 = vmull_n_u16(rgba64, alpha65535); // vs = vs * alpha
+ vs32 = vsraq_n_u32(vs32, vs32, 16); // vs = vs + (vs >> 16)
+ return vrshrn_n_u32(vs32, 16); // vs = (vs + 0x8000) >> 16
+}
+#endif
-inline QRgba64 multiplyAlpha255(QRgba64 rgba64, uint alpha255)
+template<typename T>
+inline T multiplyAlpha255(T rgba64, uint alpha255)
{
-#ifdef __SSE2__
+#if defined(__SSE2__) || defined(__ARM_NEON__)
return multiplyAlpha65535(rgba64, alpha255 * 257);
#else
return QRgba64::fromRgba64(qt_div_255(rgba64.red() * alpha255),
@@ -112,25 +135,69 @@ inline QRgba64 interpolate255(QRgba64 x, uint alpha1, QRgba64 y, uint alpha2)
return QRgba64::fromRgba64(multiplyAlpha255(x, alpha1) + multiplyAlpha255(y, alpha2));
}
+#if defined __SSE2__
+Q_ALWAYS_INLINE __m128i interpolate255(__m128i x, uint alpha1, __m128i y, uint alpha2)
+{
+ return _mm_add_epi32(multiplyAlpha255(x, alpha1), multiplyAlpha255(y, alpha2));
+}
+#endif
+
+#if defined __ARM_NEON__
+Q_ALWAYS_INLINE uint16x4_t interpolate255(uint16x4_t x, uint alpha1, uint16x4_t y, uint alpha2)
+{
+ return vadd_u16(multiplyAlpha255(x, alpha1), multiplyAlpha255(y, alpha2));
+}
+#endif
+
inline QRgba64 interpolate65535(QRgba64 x, uint alpha1, QRgba64 y, uint alpha2)
{
return QRgba64::fromRgba64(multiplyAlpha65535(x, alpha1) + multiplyAlpha65535(y, alpha2));
}
+#if defined __SSE2__
+Q_ALWAYS_INLINE __m128i interpolate65535(__m128i x, uint alpha1, __m128i y, uint alpha2)
+{
+ return _mm_add_epi32(multiplyAlpha65535(x, alpha1), multiplyAlpha65535(y, alpha2));
+}
+// alpha2 below is const-ref because otherwise MSVC2013 complains that it can't 16-byte align the argument.
+Q_ALWAYS_INLINE __m128i interpolate65535(__m128i x, __m128i alpha1, __m128i y, const __m128i &alpha2)
+{
+ return _mm_add_epi32(multiplyAlpha65535(x, alpha1), multiplyAlpha65535(y, alpha2));
+}
+#endif
+
+#if defined __ARM_NEON__
+Q_ALWAYS_INLINE uint16x4_t interpolate65535(uint16x4_t x, uint alpha1, uint16x4_t y, uint alpha2)
+{
+ return vadd_u16(multiplyAlpha65535(x, alpha1), multiplyAlpha65535(y, alpha2));
+}
+Q_ALWAYS_INLINE uint16x4_t interpolate65535(uint16x4_t x, uint16x4_t alpha1, uint16x4_t y, uint16x4_t alpha2)
+{
+ return vadd_u16(multiplyAlpha65535(x, alpha1), multiplyAlpha65535(y, alpha2));
+}
+#endif
+
inline QRgba64 addWithSaturation(QRgba64 a, QRgba64 b)
{
-#if defined(__SSE2__) && defined(Q_PROCESSOR_X86_64)
- __m128i va = _mm_cvtsi64_si128((quint64)a);
- __m128i vb = _mm_cvtsi64_si128((quint64)b);
- va = _mm_adds_epu16(va, vb);
- return QRgba64::fromRgba64(_mm_cvtsi128_si64(va));
-#else
return QRgba64::fromRgba64(qMin(a.red() + b.red(), 65535),
qMin(a.green() + b.green(), 65535),
qMin(a.blue() + b.blue(), 65535),
qMin(a.alpha() + b.alpha(), 65535));
+}
+
+#if defined(__SSE2__)
+Q_ALWAYS_INLINE __m128i addWithSaturation(__m128i a, __m128i b)
+{
+ return _mm_adds_epu16(a, b);
+}
#endif
+
+#if defined(__ARM_NEON__)
+Q_ALWAYS_INLINE uint16x4_t addWithSaturation(uint16x4_t a, uint16x4_t b)
+{
+ return vqmovn_u32(vaddl_u16(a, b));
}
+#endif
QT_END_NAMESPACE
diff --git a/src/gui/painting/qstroker_p.h b/src/gui/painting/qstroker_p.h
index e17e68b237..ededb5d80b 100644
--- a/src/gui/painting/qstroker_p.h
+++ b/src/gui/painting/qstroker_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtGui/qpainterpath.h"
#include "private/qdatabuffer_p.h"
#include "private/qnumeric_p.h"
diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp
index d2c3eceeef..86a53c21a3 100644
--- a/src/gui/painting/qtextureglyphcache.cpp
+++ b/src/gui/painting/qtextureglyphcache.cpp
@@ -42,7 +42,6 @@
#include "qtextureglyphcache_p.h"
#include "private/qfontengine_p.h"
#include "private/qnumeric_p.h"
-#include "private/qnativeimage_p.h"
QT_BEGIN_NAMESPACE
@@ -247,6 +246,7 @@ void QTextureGlyphCache::fillInPendingGlyphs()
resizeCache(qNextPowerOfTwo(requiredWidth - 1), qNextPowerOfTwo(requiredHeight - 1));
}
+ beginFillTexture();
{
QHash<GlyphAndSubPixelPosition, Coord>::iterator iter = m_pendingGlyphs.begin();
while (iter != m_pendingGlyphs.end()) {
@@ -256,6 +256,7 @@ void QTextureGlyphCache::fillInPendingGlyphs()
++iter;
}
}
+ endFillTexture();
m_pendingGlyphs.clear();
}
diff --git a/src/gui/painting/qtextureglyphcache_p.h b/src/gui/painting/qtextureglyphcache_p.h
index 14271ccc65..25253b496a 100644
--- a/src/gui/painting/qtextureglyphcache_p.h
+++ b/src/gui/painting/qtextureglyphcache_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <qhash.h>
#include <qimage.h>
#include <qobject.h>
@@ -117,7 +118,9 @@ public:
virtual void resizeTextureData(int width, int height) = 0;
virtual int glyphPadding() const { return 0; }
+ virtual void beginFillTexture() { }
virtual void fillTexture(const Coord &coord, glyph_t glyph, QFixed subPixelPosition) = 0;
+ virtual void endFillTexture() { }
inline void createCache(int width, int height) {
m_w = width;
diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h
index 470a5565e1..2aea19eca0 100644
--- a/src/gui/painting/qtransform.h
+++ b/src/gui/painting/qtransform.h
@@ -39,6 +39,7 @@
#ifndef QTRANSFORM_H
#define QTRANSFORM_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qmatrix.h>
#include <QtGui/qpainterpath.h>
#include <QtGui/qpolygon.h>
diff --git a/src/gui/painting/qvectorpath_p.h b/src/gui/painting/qvectorpath_p.h
index 01f7418930..d1b08ed423 100644
--- a/src/gui/painting/qvectorpath_p.h
+++ b/src/gui/painting/qvectorpath_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtGui/qpaintengine.h>
#include <private/qpaintengine_p.h>
diff --git a/src/gui/text/qabstracttextdocumentlayout.cpp b/src/gui/text/qabstracttextdocumentlayout.cpp
index ff2497817e..2278378613 100644
--- a/src/gui/text/qabstracttextdocumentlayout.cpp
+++ b/src/gui/text/qabstracttextdocumentlayout.cpp
@@ -602,9 +602,32 @@ QTextDocument *QAbstractTextDocumentLayout::document() const
*/
QString QAbstractTextDocumentLayout::anchorAt(const QPointF& pos) const
{
+ QTextCharFormat fmt = formatAt(pos).toCharFormat();
+ return fmt.anchorHref();
+}
+
+/*!
+ \since 5.8
+
+ Returns the source of the image at the given position \a pos, or an empty
+ string if no image exists at that point.
+*/
+QString QAbstractTextDocumentLayout::imageAt(const QPointF &pos) const
+{
+ QTextImageFormat fmt = formatAt(pos).toImageFormat();
+ return fmt.name();
+}
+
+/*!
+ \since 5.8
+
+ Returns the text format at the given position \a pos.
+*/
+QTextFormat QAbstractTextDocumentLayout::formatAt(const QPointF &pos) const
+{
int cursorPos = hitTest(pos, Qt::ExactHit);
if (cursorPos == -1)
- return QString();
+ return QTextFormat();
// compensate for preedit in the hit text block
QTextBlock block = document()->firstBlock();
@@ -623,8 +646,7 @@ QString QAbstractTextDocumentLayout::anchorAt(const QPointF& pos) const
QTextDocumentPrivate *pieceTable = qobject_cast<const QTextDocument *>(parent())->docHandle();
QTextDocumentPrivate::FragmentIterator it = pieceTable->find(cursorPos);
- QTextCharFormat fmt = pieceTable->formatCollection()->charFormat(it->format);
- return fmt.anchorHref();
+ return pieceTable->formatCollection()->format(it->format);
}
/*!
diff --git a/src/gui/text/qabstracttextdocumentlayout.h b/src/gui/text/qabstracttextdocumentlayout.h
index 01704fe37b..438ad6e70b 100644
--- a/src/gui/text/qabstracttextdocumentlayout.h
+++ b/src/gui/text/qabstracttextdocumentlayout.h
@@ -40,6 +40,7 @@
#ifndef QABSTRACTTEXTDOCUMENTLAYOUT_H
#define QABSTRACTTEXTDOCUMENTLAYOUT_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qobject.h>
#include <QtGui/qtextlayout.h>
#include <QtGui/qtextdocument.h>
@@ -82,7 +83,10 @@ public:
virtual void draw(QPainter *painter, const PaintContext &context) = 0;
virtual int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const = 0;
+
QString anchorAt(const QPointF& pos) const;
+ QString imageAt(const QPointF &pos) const;
+ QTextFormat formatAt(const QPointF &pos) const;
virtual int pageCount() const = 0;
virtual QSizeF documentSize() const = 0;
diff --git a/src/gui/text/qabstracttextdocumentlayout_p.h b/src/gui/text/qabstracttextdocumentlayout_p.h
index fc39d8ec5c..191c463dc6 100644
--- a/src/gui/text/qabstracttextdocumentlayout_p.h
+++ b/src/gui/text/qabstracttextdocumentlayout_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "private/qobject_p.h"
#include "QtCore/qhash.h"
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index c237d80d34..72c5d5ff33 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -900,7 +900,7 @@ static QBrush brushFromData(const BrushData& c, const QPalette &pal)
}
}
-static BorderStyle parseStyleValue(QCss::Value v)
+static BorderStyle parseStyleValue(const QCss::Value &v)
{
if (v.type == Value::KnownIdentifier) {
switch (v.variant.toInt()) {
@@ -1867,12 +1867,15 @@ bool StyleSelector::selectorMatches(const Selector &selector, NodePtr node)
do {
match = basicSelectorMatches(sel, node);
if (!match) {
- if (sel.relationToNext == BasicSelector::MatchNextSelectorIfParent
- || i == selector.basicSelectors.count() - 1) // first element must always match!
+ if (i == selector.basicSelectors.count() - 1) // first element must always match!
+ break;
+ if (sel.relationToNext != BasicSelector::MatchNextSelectorIfAncestor &&
+ sel.relationToNext != BasicSelector::MatchNextSelectorIfIndirectAdjecent)
break;
}
- if (match || sel.relationToNext != BasicSelector::MatchNextSelectorIfAncestor)
+ if (match || (sel.relationToNext != BasicSelector::MatchNextSelectorIfAncestor &&
+ sel.relationToNext != BasicSelector::MatchNextSelectorIfIndirectAdjecent))
--i;
if (i < 0)
@@ -1885,16 +1888,18 @@ bool StyleSelector::selectorMatches(const Selector &selector, NodePtr node)
NodePtr nextParent = parentNode(node);
freeNode(node);
node = nextParent;
- } else if (sel.relationToNext == BasicSelector::MatchNextSelectorIfPreceeds) {
+ } else if (sel.relationToNext == BasicSelector::MatchNextSelectorIfDirectAdjecent
+ || sel.relationToNext == BasicSelector::MatchNextSelectorIfIndirectAdjecent) {
NodePtr previousSibling = previousSiblingNode(node);
freeNode(node);
node = previousSibling;
- }
+ }
if (isNullNode(node)) {
match = false;
break;
}
- } while (i >= 0 && (match || sel.relationToNext == BasicSelector::MatchNextSelectorIfAncestor));
+ } while (i >= 0 && (match || sel.relationToNext == BasicSelector::MatchNextSelectorIfAncestor
+ || sel.relationToNext == BasicSelector::MatchNextSelectorIfIndirectAdjecent));
freeNode(node);
@@ -1914,18 +1919,38 @@ bool StyleSelector::basicSelectorMatches(const BasicSelector &sel, NodePtr node)
if (attrValue.isNull())
return false;
- if (a.valueMatchCriterium == QCss::AttributeSelector::MatchContains) {
+ switch (a.valueMatchCriterium) {
+ case QCss::AttributeSelector::NoMatch:
+ break;
+ case QCss::AttributeSelector::MatchEqual:
+ if (attrValue != a.value)
+ return false;
+ break;
+ case QCss::AttributeSelector::MatchIncludes: {
const auto lst = attrValue.splitRef(QLatin1Char(' '));
if (!lst.contains(QStringRef(&a.value)))
return false;
- } else if (
- (a.valueMatchCriterium == QCss::AttributeSelector::MatchEqual
- && attrValue != a.value)
- ||
- (a.valueMatchCriterium == QCss::AttributeSelector::MatchBeginsWith
- && !attrValue.startsWith(a.value))
- )
- return false;
+ break;
+ }
+ case QCss::AttributeSelector::MatchDashMatch: {
+ const QString dashPrefix = a.value + QLatin1Char('-');
+ if (attrValue != a.value && !attrValue.startsWith(dashPrefix))
+ return false;
+ break;
+ }
+ case QCss::AttributeSelector::MatchBeginsWith:
+ if (!attrValue.startsWith(a.value))
+ return false;
+ break;
+ case QCss::AttributeSelector::MatchEndsWith:
+ if (!attrValue.endsWith(a.value))
+ return false;
+ break;
+ case QCss::AttributeSelector::MatchContains:
+ if (!attrValue.contains(a.value))
+ return false;
+ break;
+ }
}
}
@@ -2336,9 +2361,11 @@ bool Parser::parseCombinator(BasicSelector::Relation *relation)
prev();
}
if (test(PLUS)) {
- *relation = BasicSelector::MatchNextSelectorIfPreceeds;
+ *relation = BasicSelector::MatchNextSelectorIfDirectAdjecent;
} else if (test(GREATER)) {
*relation = BasicSelector::MatchNextSelectorIfParent;
+ } else if (test(TILDE)) {
+ *relation = BasicSelector::MatchNextSelectorIfIndirectAdjecent;
}
skipSpace();
return true;
@@ -2439,7 +2466,7 @@ bool Parser::parseSimpleSelector(BasicSelector *basicSel)
onceMore = true;
AttributeSelector a;
a.name = QLatin1String("class");
- a.valueMatchCriterium = AttributeSelector::MatchContains;
+ a.valueMatchCriterium = AttributeSelector::MatchIncludes;
if (!parseClass(&a.value)) return false;
basicSel->attributeSelectors.append(a);
} else if (testAttrib()) {
@@ -2485,9 +2512,15 @@ bool Parser::parseAttrib(AttributeSelector *attr)
if (test(EQUAL)) {
attr->valueMatchCriterium = AttributeSelector::MatchEqual;
} else if (test(INCLUDES)) {
- attr->valueMatchCriterium = AttributeSelector::MatchContains;
+ attr->valueMatchCriterium = AttributeSelector::MatchIncludes;
} else if (test(DASHMATCH)) {
+ attr->valueMatchCriterium = AttributeSelector::MatchDashMatch;
+ } else if (test(BEGINSWITH)) {
attr->valueMatchCriterium = AttributeSelector::MatchBeginsWith;
+ } else if (test(ENDSWITH)) {
+ attr->valueMatchCriterium = AttributeSelector::MatchEndsWith;
+ } else if (test(CONTAINS)) {
+ attr->valueMatchCriterium = AttributeSelector::MatchContains;
} else {
return next(RBRACKET);
}
diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h
index 4da7b62dba..f5cd5395b2 100644
--- a/src/gui/text/qcssparser_p.h
+++ b/src/gui/text/qcssparser_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtCore/QStringList>
#include <QtCore/QVector>
#include <QtCore/QVariant>
@@ -538,8 +539,11 @@ struct AttributeSelector
enum ValueMatchType {
NoMatch,
MatchEqual,
- MatchContains,
- MatchBeginsWith
+ MatchIncludes,
+ MatchDashMatch,
+ MatchBeginsWith,
+ MatchEndsWith,
+ MatchContains
};
inline AttributeSelector() : valueMatchCriterium(NoMatch) {}
@@ -557,7 +561,8 @@ struct BasicSelector
NoRelation,
MatchNextSelectorIfAncestor,
MatchNextSelectorIfParent,
- MatchNextSelectorIfPreceeds
+ MatchNextSelectorIfDirectAdjecent,
+ MatchNextSelectorIfIndirectAdjecent,
};
QString elementName;
@@ -678,11 +683,15 @@ enum TokenType {
CDC,
INCLUDES,
DASHMATCH,
+ BEGINSWITH,
+ ENDSWITH,
+ CONTAINS,
LBRACE,
PLUS,
GREATER,
COMMA,
+ TILDE,
STRING,
INVALID,
@@ -782,7 +791,7 @@ public:
inline bool testImport() { return testTokenAndEndsWith(ATKEYWORD_SYM, QLatin1String("import")); }
inline bool testMedia() { return testTokenAndEndsWith(ATKEYWORD_SYM, QLatin1String("media")); }
inline bool testPage() { return testTokenAndEndsWith(ATKEYWORD_SYM, QLatin1String("page")); }
- inline bool testCombinator() { return test(PLUS) || test(GREATER) || test(S); }
+ inline bool testCombinator() { return test(PLUS) || test(GREATER) || test(TILDE) || test(S); }
inline bool testProperty() { return test(IDENT); }
bool testTerm();
inline bool testExpr() { return testTerm(); }
diff --git a/src/gui/text/qcssscanner.cpp b/src/gui/text/qcssscanner.cpp
index f6b25d50ba..33dc01c8bc 100644
--- a/src/gui/text/qcssscanner.cpp
+++ b/src/gui/text/qcssscanner.cpp
@@ -88,8 +88,10 @@ int QCssScanner_Generated::lex()
goto state_3;
if (ch.unicode() == 35)
goto state_4;
- if (ch.unicode() == 39)
+ if (ch.unicode() == 36)
goto state_5;
+ if (ch.unicode() == 39)
+ goto state_6;
if (ch.unicode() == 40) {
token = QCss::LPAREN;
goto found;
@@ -98,22 +100,20 @@ int QCssScanner_Generated::lex()
token = QCss::RPAREN;
goto found;
}
- if (ch.unicode() == 42) {
- token = QCss::STAR;
- goto found;
- }
- if (ch.unicode() == 43)
+ if (ch.unicode() == 42)
goto state_9;
- if (ch.unicode() == 44)
+ if (ch.unicode() == 43)
goto state_10;
- if (ch.unicode() == 45)
+ if (ch.unicode() == 44)
goto state_11;
- if (ch.unicode() == 46)
+ if (ch.unicode() == 45)
goto state_12;
- if (ch.unicode() == 47)
+ if (ch.unicode() == 46)
goto state_13;
- if (ch.unicode() >= 48 && ch.unicode() <= 57)
+ if (ch.unicode() == 47)
goto state_14;
+ if (ch.unicode() >= 48 && ch.unicode() <= 57)
+ goto state_15;
if (ch.unicode() == 58) {
token = QCss::COLON;
goto found;
@@ -123,147 +123,167 @@ int QCssScanner_Generated::lex()
goto found;
}
if (ch.unicode() == 60)
- goto state_17;
+ goto state_18;
if (ch.unicode() == 61) {
token = QCss::EQUAL;
goto found;
}
if (ch.unicode() == 62)
- goto state_19;
- if (ch.unicode() == 64)
goto state_20;
+ if (ch.unicode() == 64)
+ goto state_21;
if (ch.unicode() == 91) {
token = QCss::LBRACKET;
goto found;
}
if (ch.unicode() == 92)
- goto state_22;
+ goto state_23;
if (ch.unicode() == 93) {
token = QCss::RBRACKET;
goto found;
}
+ if (ch.unicode() == 94)
+ goto state_25;
if (ch.unicode() == 95)
- goto state_24;
+ goto state_26;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_24;
+ goto state_26;
if (ch.unicode() == 123)
- goto state_25;
+ goto state_27;
if (ch.unicode() == 124)
- goto state_26;
+ goto state_28;
if (ch.unicode() == 125) {
token = QCss::RBRACE;
goto found;
}
if (ch.unicode() == 126)
- goto state_28;
+ goto state_30;
goto out;
state_1:
lastAcceptingPos = pos;
token = QCss::S;
ch = next();
if (ch.unicode() >= 9 && ch.unicode() <= 10)
- goto state_29;
+ goto state_31;
if (ch.unicode() >= 12 && ch.unicode() <= 13)
- goto state_29;
+ goto state_31;
if (ch.unicode() == 32)
- goto state_29;
+ goto state_31;
if (ch.unicode() == 43)
- goto state_9;
- if (ch.unicode() == 44)
goto state_10;
+ if (ch.unicode() == 44)
+ goto state_11;
if (ch.unicode() == 62)
- goto state_19;
+ goto state_20;
if (ch.unicode() == 123)
- goto state_25;
+ goto state_27;
+ if (ch.unicode() == 126)
+ goto state_32;
goto out;
state_3:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_30;
+ goto state_33;
if (ch.unicode() == 11)
- goto state_30;
+ goto state_33;
if (ch.unicode() >= 14 && ch.unicode() <= 33)
- goto state_30;
+ goto state_33;
if (ch.unicode() == 34)
- goto state_31;
+ goto state_34;
if (ch.unicode() >= 35 && ch.unicode() <= 91)
- goto state_30;
+ goto state_33;
if (ch.unicode() == 92)
- goto state_32;
+ goto state_35;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
- goto state_30;
+ goto state_33;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_30;
+ goto state_33;
if (ch.unicode() >= 123)
- goto state_30;
+ goto state_33;
goto out;
state_4:
ch = next();
if (ch.unicode() == 45)
- goto state_33;
+ goto state_36;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_33;
+ goto state_36;
if (ch.unicode() == 92)
- goto state_34;
+ goto state_37;
if (ch.unicode() == 95)
- goto state_33;
+ goto state_36;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_33;
+ goto state_36;
goto out;
state_5:
+ ch = next();
+ if (ch.unicode() == 61) {
+ token = QCss::ENDSWITH;
+ goto found;
+ }
+ goto out;
+ state_6:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_35;
+ goto state_39;
if (ch.unicode() == 11)
- goto state_35;
+ goto state_39;
if (ch.unicode() >= 14 && ch.unicode() <= 38)
- goto state_35;
+ goto state_39;
if (ch.unicode() == 39)
- goto state_36;
+ goto state_40;
if (ch.unicode() >= 40 && ch.unicode() <= 91)
- goto state_35;
+ goto state_39;
if (ch.unicode() == 92)
- goto state_37;
+ goto state_41;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
- goto state_35;
+ goto state_39;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_35;
+ goto state_39;
if (ch.unicode() >= 123)
- goto state_35;
+ goto state_39;
goto out;
state_9:
lastAcceptingPos = pos;
- token = QCss::PLUS;
+ token = QCss::STAR;
+ ch = next();
+ if (ch.unicode() == 61) {
+ token = QCss::CONTAINS;
+ goto found;
+ }
goto out;
state_10:
lastAcceptingPos = pos;
- token = QCss::COMMA;
+ token = QCss::PLUS;
goto out;
state_11:
lastAcceptingPos = pos;
+ token = QCss::COMMA;
+ goto out;
+ state_12:
+ lastAcceptingPos = pos;
token = QCss::MINUS;
ch = next();
if (ch.unicode() == 45)
- goto state_38;
+ goto state_43;
if (ch.unicode() == 92)
- goto state_22;
+ goto state_23;
if (ch.unicode() == 95)
- goto state_24;
+ goto state_26;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_24;
+ goto state_26;
goto out;
- state_12:
+ state_13:
lastAcceptingPos = pos;
token = QCss::DOT;
ch = next();
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_39;
+ goto state_44;
goto out;
- state_13:
+ state_14:
lastAcceptingPos = pos;
token = QCss::SLASH;
ch = next();
@@ -272,80 +292,87 @@ int QCssScanner_Generated::lex()
goto found;
}
goto out;
- state_14:
+ state_15:
lastAcceptingPos = pos;
token = QCss::NUMBER;
ch = next();
if (ch.unicode() == 37)
- goto state_41;
+ goto state_46;
if (ch.unicode() == 45)
- goto state_42;
+ goto state_47;
if (ch.unicode() == 46)
- goto state_43;
+ goto state_48;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_44;
+ goto state_49;
if (ch.unicode() == 92)
- goto state_45;
+ goto state_50;
if (ch.unicode() == 95)
- goto state_46;
+ goto state_51;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_46;
+ goto state_51;
goto out;
- state_17:
+ state_18:
ch = next();
if (ch.unicode() == 33)
- goto state_47;
+ goto state_52;
goto out;
- state_19:
+ state_20:
lastAcceptingPos = pos;
token = QCss::GREATER;
goto out;
- state_20:
+ state_21:
ch = next();
if (ch.unicode() == 45)
- goto state_48;
+ goto state_53;
if (ch.unicode() == 92)
- goto state_49;
+ goto state_54;
if (ch.unicode() == 95)
- goto state_50;
+ goto state_55;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_50;
+ goto state_55;
goto out;
- state_22:
+ state_23:
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_51;
+ goto state_56;
if (ch.unicode() == 11)
- goto state_51;
+ goto state_56;
if (ch.unicode() >= 14 && ch.unicode() <= 47)
- goto state_51;
+ goto state_56;
if (ch.unicode() >= 58 && ch.unicode() <= 96)
- goto state_51;
+ goto state_56;
if (ch.unicode() >= 103)
- goto state_51;
+ goto state_56;
+ goto out;
+ state_25:
+ ch = next();
+ if (ch.unicode() == 61) {
+ token = QCss::BEGINSWITH;
+ goto found;
+ }
goto out;
- state_24:
+ state_26:
lastAcceptingPos = pos;
token = QCss::IDENT;
ch = next();
if (ch.unicode() == 40)
- goto state_52;
+ goto state_58;
if (ch.unicode() == 45)
- goto state_53;
+ goto state_59;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_53;
+ goto state_59;
if (ch.unicode() == 92)
- goto state_54;
+ goto state_60;
if (ch.unicode() == 95)
- goto state_53;
+ goto state_59;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_53;
+ goto state_59;
goto out;
- state_25:
+ state_27:
lastAcceptingPos = pos;
token = QCss::LBRACE;
goto out;
- state_26:
+ state_28:
lastAcceptingPos = pos;
token = QCss::OR;
ch = next();
@@ -354,782 +381,790 @@ int QCssScanner_Generated::lex()
goto found;
}
goto out;
- state_28:
+ state_30:
+ lastAcceptingPos = pos;
+ token = QCss::TILDE;
ch = next();
if (ch.unicode() == 61) {
token = QCss::INCLUDES;
goto found;
}
goto out;
- state_29:
+ state_31:
lastAcceptingPos = pos;
token = QCss::S;
ch = next();
if (ch.unicode() >= 9 && ch.unicode() <= 10)
- goto state_29;
+ goto state_31;
if (ch.unicode() >= 12 && ch.unicode() <= 13)
- goto state_29;
+ goto state_31;
if (ch.unicode() == 32)
- goto state_29;
+ goto state_31;
if (ch.unicode() == 43)
- goto state_9;
- if (ch.unicode() == 44)
goto state_10;
+ if (ch.unicode() == 44)
+ goto state_11;
if (ch.unicode() == 62)
- goto state_19;
+ goto state_20;
if (ch.unicode() == 123)
- goto state_25;
+ goto state_27;
+ if (ch.unicode() == 126)
+ goto state_32;
goto out;
- state_30:
+ state_32:
+ lastAcceptingPos = pos;
+ token = QCss::TILDE;
+ goto out;
+ state_33:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_30;
+ goto state_33;
if (ch.unicode() == 11)
- goto state_30;
+ goto state_33;
if (ch.unicode() >= 14 && ch.unicode() <= 33)
- goto state_30;
+ goto state_33;
if (ch.unicode() == 34)
- goto state_31;
+ goto state_34;
if (ch.unicode() >= 35 && ch.unicode() <= 91)
- goto state_30;
+ goto state_33;
if (ch.unicode() == 92)
- goto state_32;
+ goto state_35;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
- goto state_30;
+ goto state_33;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_30;
+ goto state_33;
if (ch.unicode() >= 123)
- goto state_30;
+ goto state_33;
goto out;
- state_31:
+ state_34:
lastAcceptingPos = pos;
token = QCss::STRING;
goto out;
- state_32:
+ state_35:
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_57;
+ goto state_63;
if (ch.unicode() == 10)
- goto state_58;
+ goto state_64;
if (ch.unicode() == 11)
- goto state_57;
+ goto state_63;
if (ch.unicode() == 12)
- goto state_59;
+ goto state_65;
if (ch.unicode() == 13)
- goto state_60;
+ goto state_66;
if (ch.unicode() >= 14 && ch.unicode() <= 47)
- goto state_57;
+ goto state_63;
if (ch.unicode() >= 58 && ch.unicode() <= 96)
- goto state_57;
+ goto state_63;
if (ch.unicode() >= 103)
- goto state_57;
+ goto state_63;
goto out;
- state_33:
+ state_36:
lastAcceptingPos = pos;
token = QCss::HASH;
ch = next();
if (ch.unicode() == 45)
- goto state_61;
+ goto state_67;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_61;
+ goto state_67;
if (ch.unicode() == 92)
- goto state_62;
+ goto state_68;
if (ch.unicode() == 95)
- goto state_61;
+ goto state_67;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_61;
+ goto state_67;
goto out;
- state_34:
+ state_37:
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_63;
+ goto state_69;
if (ch.unicode() == 11)
- goto state_63;
+ goto state_69;
if (ch.unicode() >= 14 && ch.unicode() <= 47)
- goto state_63;
+ goto state_69;
if (ch.unicode() >= 58 && ch.unicode() <= 96)
- goto state_63;
+ goto state_69;
if (ch.unicode() >= 103)
- goto state_63;
+ goto state_69;
goto out;
- state_35:
+ state_39:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_35;
+ goto state_39;
if (ch.unicode() == 11)
- goto state_35;
+ goto state_39;
if (ch.unicode() >= 14 && ch.unicode() <= 38)
- goto state_35;
+ goto state_39;
if (ch.unicode() == 39)
- goto state_36;
+ goto state_40;
if (ch.unicode() >= 40 && ch.unicode() <= 91)
- goto state_35;
+ goto state_39;
if (ch.unicode() == 92)
- goto state_37;
+ goto state_41;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
- goto state_35;
+ goto state_39;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_35;
+ goto state_39;
if (ch.unicode() >= 123)
- goto state_35;
+ goto state_39;
goto out;
- state_36:
+ state_40:
lastAcceptingPos = pos;
token = QCss::STRING;
goto out;
- state_37:
+ state_41:
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_64;
+ goto state_70;
if (ch.unicode() == 10)
- goto state_65;
+ goto state_71;
if (ch.unicode() == 11)
- goto state_64;
+ goto state_70;
if (ch.unicode() == 12)
- goto state_66;
+ goto state_72;
if (ch.unicode() == 13)
- goto state_67;
+ goto state_73;
if (ch.unicode() >= 14 && ch.unicode() <= 47)
- goto state_64;
+ goto state_70;
if (ch.unicode() >= 58 && ch.unicode() <= 96)
- goto state_64;
+ goto state_70;
if (ch.unicode() >= 103)
- goto state_64;
+ goto state_70;
goto out;
- state_38:
+ state_43:
ch = next();
if (ch.unicode() == 62) {
token = QCss::CDC;
goto found;
}
goto out;
- state_39:
+ state_44:
lastAcceptingPos = pos;
token = QCss::NUMBER;
ch = next();
if (ch.unicode() == 37)
- goto state_41;
+ goto state_46;
if (ch.unicode() == 45)
- goto state_42;
+ goto state_47;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_69;
+ goto state_75;
if (ch.unicode() == 92)
- goto state_45;
+ goto state_50;
if (ch.unicode() == 95)
- goto state_46;
+ goto state_51;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_46;
+ goto state_51;
goto out;
- state_41:
+ state_46:
lastAcceptingPos = pos;
token = QCss::PERCENTAGE;
goto out;
- state_42:
+ state_47:
ch = next();
if (ch.unicode() == 92)
- goto state_45;
+ goto state_50;
if (ch.unicode() == 95)
- goto state_46;
+ goto state_51;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_46;
+ goto state_51;
goto out;
- state_43:
+ state_48:
ch = next();
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_39;
+ goto state_44;
goto out;
- state_44:
+ state_49:
lastAcceptingPos = pos;
token = QCss::NUMBER;
ch = next();
if (ch.unicode() == 37)
- goto state_41;
+ goto state_46;
if (ch.unicode() == 45)
- goto state_42;
+ goto state_47;
if (ch.unicode() == 46)
- goto state_43;
+ goto state_48;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_44;
+ goto state_49;
if (ch.unicode() == 92)
- goto state_45;
+ goto state_50;
if (ch.unicode() == 95)
- goto state_46;
+ goto state_51;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_46;
+ goto state_51;
goto out;
- state_45:
+ state_50:
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_70;
+ goto state_76;
if (ch.unicode() == 11)
- goto state_70;
+ goto state_76;
if (ch.unicode() >= 14 && ch.unicode() <= 47)
- goto state_70;
+ goto state_76;
if (ch.unicode() >= 58 && ch.unicode() <= 96)
- goto state_70;
+ goto state_76;
if (ch.unicode() >= 103)
- goto state_70;
+ goto state_76;
goto out;
- state_46:
+ state_51:
lastAcceptingPos = pos;
token = QCss::LENGTH;
ch = next();
if (ch.unicode() == 45)
- goto state_71;
+ goto state_77;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_71;
+ goto state_77;
if (ch.unicode() == 92)
- goto state_72;
+ goto state_78;
if (ch.unicode() == 95)
- goto state_71;
+ goto state_77;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_71;
+ goto state_77;
goto out;
- state_47:
+ state_52:
ch = next();
if (ch.unicode() == 45)
- goto state_73;
+ goto state_79;
goto out;
- state_48:
+ state_53:
ch = next();
if (ch.unicode() == 92)
- goto state_49;
+ goto state_54;
if (ch.unicode() == 95)
- goto state_50;
+ goto state_55;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_50;
+ goto state_55;
goto out;
- state_49:
+ state_54:
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_74;
+ goto state_80;
if (ch.unicode() == 11)
- goto state_74;
+ goto state_80;
if (ch.unicode() >= 14 && ch.unicode() <= 47)
- goto state_74;
+ goto state_80;
if (ch.unicode() >= 58 && ch.unicode() <= 96)
- goto state_74;
+ goto state_80;
if (ch.unicode() >= 103)
- goto state_74;
+ goto state_80;
goto out;
- state_50:
+ state_55:
lastAcceptingPos = pos;
token = QCss::ATKEYWORD_SYM;
ch = next();
if (ch.unicode() == 45)
- goto state_75;
+ goto state_81;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_75;
+ goto state_81;
if (ch.unicode() == 92)
- goto state_76;
+ goto state_82;
if (ch.unicode() == 95)
- goto state_75;
+ goto state_81;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_75;
+ goto state_81;
goto out;
- state_51:
+ state_56:
lastAcceptingPos = pos;
token = QCss::IDENT;
ch = next();
if (ch.unicode() == 40)
- goto state_52;
+ goto state_58;
if (ch.unicode() == 45)
- goto state_53;
+ goto state_59;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_53;
+ goto state_59;
if (ch.unicode() == 92)
- goto state_54;
+ goto state_60;
if (ch.unicode() == 95)
- goto state_53;
+ goto state_59;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_53;
+ goto state_59;
goto out;
- state_52:
+ state_58:
lastAcceptingPos = pos;
token = QCss::FUNCTION;
goto out;
- state_53:
+ state_59:
lastAcceptingPos = pos;
token = QCss::IDENT;
ch = next();
if (ch.unicode() == 40)
- goto state_52;
+ goto state_58;
if (ch.unicode() == 45)
- goto state_53;
+ goto state_59;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_53;
+ goto state_59;
if (ch.unicode() == 92)
- goto state_54;
+ goto state_60;
if (ch.unicode() == 95)
- goto state_53;
+ goto state_59;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_53;
+ goto state_59;
goto out;
- state_54:
+ state_60:
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_77;
+ goto state_83;
if (ch.unicode() == 11)
- goto state_77;
+ goto state_83;
if (ch.unicode() >= 14 && ch.unicode() <= 47)
- goto state_77;
+ goto state_83;
if (ch.unicode() >= 58 && ch.unicode() <= 96)
- goto state_77;
+ goto state_83;
if (ch.unicode() >= 103)
- goto state_77;
+ goto state_83;
goto out;
- state_57:
+ state_63:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_30;
+ goto state_33;
if (ch.unicode() == 11)
- goto state_30;
+ goto state_33;
if (ch.unicode() >= 14 && ch.unicode() <= 33)
- goto state_30;
+ goto state_33;
if (ch.unicode() == 34)
- goto state_31;
+ goto state_34;
if (ch.unicode() >= 35 && ch.unicode() <= 91)
- goto state_30;
+ goto state_33;
if (ch.unicode() == 92)
- goto state_32;
+ goto state_35;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
- goto state_30;
+ goto state_33;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_30;
+ goto state_33;
if (ch.unicode() >= 123)
- goto state_30;
+ goto state_33;
goto out;
- state_58:
+ state_64:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_30;
+ goto state_33;
if (ch.unicode() == 11)
- goto state_30;
+ goto state_33;
if (ch.unicode() >= 14 && ch.unicode() <= 33)
- goto state_30;
+ goto state_33;
if (ch.unicode() == 34)
- goto state_31;
+ goto state_34;
if (ch.unicode() >= 35 && ch.unicode() <= 91)
- goto state_30;
+ goto state_33;
if (ch.unicode() == 92)
- goto state_32;
+ goto state_35;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
- goto state_30;
+ goto state_33;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_30;
+ goto state_33;
if (ch.unicode() >= 123)
- goto state_30;
+ goto state_33;
goto out;
- state_59:
+ state_65:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_30;
+ goto state_33;
if (ch.unicode() == 11)
- goto state_30;
+ goto state_33;
if (ch.unicode() >= 14 && ch.unicode() <= 33)
- goto state_30;
+ goto state_33;
if (ch.unicode() == 34)
- goto state_31;
+ goto state_34;
if (ch.unicode() >= 35 && ch.unicode() <= 91)
- goto state_30;
+ goto state_33;
if (ch.unicode() == 92)
- goto state_32;
+ goto state_35;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
- goto state_30;
+ goto state_33;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_30;
+ goto state_33;
if (ch.unicode() >= 123)
- goto state_30;
+ goto state_33;
goto out;
- state_60:
+ state_66:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_30;
+ goto state_33;
if (ch.unicode() == 10)
- goto state_78;
+ goto state_84;
if (ch.unicode() == 11)
- goto state_30;
+ goto state_33;
if (ch.unicode() >= 14 && ch.unicode() <= 33)
- goto state_30;
+ goto state_33;
if (ch.unicode() == 34)
- goto state_31;
+ goto state_34;
if (ch.unicode() >= 35 && ch.unicode() <= 91)
- goto state_30;
+ goto state_33;
if (ch.unicode() == 92)
- goto state_32;
+ goto state_35;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
- goto state_30;
+ goto state_33;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_30;
+ goto state_33;
if (ch.unicode() >= 123)
- goto state_30;
+ goto state_33;
goto out;
- state_61:
+ state_67:
lastAcceptingPos = pos;
token = QCss::HASH;
ch = next();
if (ch.unicode() == 45)
- goto state_61;
+ goto state_67;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_61;
+ goto state_67;
if (ch.unicode() == 92)
- goto state_62;
+ goto state_68;
if (ch.unicode() == 95)
- goto state_61;
+ goto state_67;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_61;
+ goto state_67;
goto out;
- state_62:
+ state_68:
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_79;
+ goto state_85;
if (ch.unicode() == 11)
- goto state_79;
+ goto state_85;
if (ch.unicode() >= 14 && ch.unicode() <= 47)
- goto state_79;
+ goto state_85;
if (ch.unicode() >= 58 && ch.unicode() <= 96)
- goto state_79;
+ goto state_85;
if (ch.unicode() >= 103)
- goto state_79;
+ goto state_85;
goto out;
- state_63:
+ state_69:
lastAcceptingPos = pos;
token = QCss::HASH;
ch = next();
if (ch.unicode() == 45)
- goto state_61;
+ goto state_67;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_61;
+ goto state_67;
if (ch.unicode() == 92)
- goto state_62;
+ goto state_68;
if (ch.unicode() == 95)
- goto state_61;
+ goto state_67;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_61;
+ goto state_67;
goto out;
- state_64:
+ state_70:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_35;
+ goto state_39;
if (ch.unicode() == 11)
- goto state_35;
+ goto state_39;
if (ch.unicode() >= 14 && ch.unicode() <= 38)
- goto state_35;
+ goto state_39;
if (ch.unicode() == 39)
- goto state_36;
+ goto state_40;
if (ch.unicode() >= 40 && ch.unicode() <= 91)
- goto state_35;
+ goto state_39;
if (ch.unicode() == 92)
- goto state_37;
+ goto state_41;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
- goto state_35;
+ goto state_39;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_35;
+ goto state_39;
if (ch.unicode() >= 123)
- goto state_35;
+ goto state_39;
goto out;
- state_65:
+ state_71:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_35;
+ goto state_39;
if (ch.unicode() == 11)
- goto state_35;
+ goto state_39;
if (ch.unicode() >= 14 && ch.unicode() <= 38)
- goto state_35;
+ goto state_39;
if (ch.unicode() == 39)
- goto state_36;
+ goto state_40;
if (ch.unicode() >= 40 && ch.unicode() <= 91)
- goto state_35;
+ goto state_39;
if (ch.unicode() == 92)
- goto state_37;
+ goto state_41;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
- goto state_35;
+ goto state_39;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_35;
+ goto state_39;
if (ch.unicode() >= 123)
- goto state_35;
+ goto state_39;
goto out;
- state_66:
+ state_72:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_35;
+ goto state_39;
if (ch.unicode() == 11)
- goto state_35;
+ goto state_39;
if (ch.unicode() >= 14 && ch.unicode() <= 38)
- goto state_35;
+ goto state_39;
if (ch.unicode() == 39)
- goto state_36;
+ goto state_40;
if (ch.unicode() >= 40 && ch.unicode() <= 91)
- goto state_35;
+ goto state_39;
if (ch.unicode() == 92)
- goto state_37;
+ goto state_41;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
- goto state_35;
+ goto state_39;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_35;
+ goto state_39;
if (ch.unicode() >= 123)
- goto state_35;
+ goto state_39;
goto out;
- state_67:
+ state_73:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_35;
+ goto state_39;
if (ch.unicode() == 10)
- goto state_80;
+ goto state_86;
if (ch.unicode() == 11)
- goto state_35;
+ goto state_39;
if (ch.unicode() >= 14 && ch.unicode() <= 38)
- goto state_35;
+ goto state_39;
if (ch.unicode() == 39)
- goto state_36;
+ goto state_40;
if (ch.unicode() >= 40 && ch.unicode() <= 91)
- goto state_35;
+ goto state_39;
if (ch.unicode() == 92)
- goto state_37;
+ goto state_41;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
- goto state_35;
+ goto state_39;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_35;
+ goto state_39;
if (ch.unicode() >= 123)
- goto state_35;
+ goto state_39;
goto out;
- state_69:
+ state_75:
lastAcceptingPos = pos;
token = QCss::NUMBER;
ch = next();
if (ch.unicode() == 37)
- goto state_41;
+ goto state_46;
if (ch.unicode() == 45)
- goto state_42;
+ goto state_47;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_69;
+ goto state_75;
if (ch.unicode() == 92)
- goto state_45;
+ goto state_50;
if (ch.unicode() == 95)
- goto state_46;
+ goto state_51;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_46;
+ goto state_51;
goto out;
- state_70:
+ state_76:
lastAcceptingPos = pos;
token = QCss::LENGTH;
ch = next();
if (ch.unicode() == 45)
- goto state_71;
+ goto state_77;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_71;
+ goto state_77;
if (ch.unicode() == 92)
- goto state_72;
+ goto state_78;
if (ch.unicode() == 95)
- goto state_71;
+ goto state_77;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_71;
+ goto state_77;
goto out;
- state_71:
+ state_77:
lastAcceptingPos = pos;
token = QCss::LENGTH;
ch = next();
if (ch.unicode() == 45)
- goto state_71;
+ goto state_77;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_71;
+ goto state_77;
if (ch.unicode() == 92)
- goto state_72;
+ goto state_78;
if (ch.unicode() == 95)
- goto state_71;
+ goto state_77;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_71;
+ goto state_77;
goto out;
- state_72:
+ state_78:
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_81;
+ goto state_87;
if (ch.unicode() == 11)
- goto state_81;
+ goto state_87;
if (ch.unicode() >= 14 && ch.unicode() <= 47)
- goto state_81;
+ goto state_87;
if (ch.unicode() >= 58 && ch.unicode() <= 96)
- goto state_81;
+ goto state_87;
if (ch.unicode() >= 103)
- goto state_81;
+ goto state_87;
goto out;
- state_73:
+ state_79:
ch = next();
if (ch.unicode() == 45) {
token = QCss::CDO;
goto found;
}
goto out;
- state_74:
+ state_80:
lastAcceptingPos = pos;
token = QCss::ATKEYWORD_SYM;
ch = next();
if (ch.unicode() == 45)
- goto state_75;
+ goto state_81;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_75;
+ goto state_81;
if (ch.unicode() == 92)
- goto state_76;
+ goto state_82;
if (ch.unicode() == 95)
- goto state_75;
+ goto state_81;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_75;
+ goto state_81;
goto out;
- state_75:
+ state_81:
lastAcceptingPos = pos;
token = QCss::ATKEYWORD_SYM;
ch = next();
if (ch.unicode() == 45)
- goto state_75;
+ goto state_81;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_75;
+ goto state_81;
if (ch.unicode() == 92)
- goto state_76;
+ goto state_82;
if (ch.unicode() == 95)
- goto state_75;
+ goto state_81;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_75;
+ goto state_81;
goto out;
- state_76:
+ state_82:
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_83;
+ goto state_89;
if (ch.unicode() == 11)
- goto state_83;
+ goto state_89;
if (ch.unicode() >= 14 && ch.unicode() <= 47)
- goto state_83;
+ goto state_89;
if (ch.unicode() >= 58 && ch.unicode() <= 96)
- goto state_83;
+ goto state_89;
if (ch.unicode() >= 103)
- goto state_83;
+ goto state_89;
goto out;
- state_77:
+ state_83:
lastAcceptingPos = pos;
token = QCss::IDENT;
ch = next();
if (ch.unicode() == 40)
- goto state_52;
+ goto state_58;
if (ch.unicode() == 45)
- goto state_53;
+ goto state_59;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_53;
+ goto state_59;
if (ch.unicode() == 92)
- goto state_54;
+ goto state_60;
if (ch.unicode() == 95)
- goto state_53;
+ goto state_59;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_53;
+ goto state_59;
goto out;
- state_78:
+ state_84:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_30;
+ goto state_33;
if (ch.unicode() == 11)
- goto state_30;
+ goto state_33;
if (ch.unicode() >= 14 && ch.unicode() <= 33)
- goto state_30;
+ goto state_33;
if (ch.unicode() == 34)
- goto state_31;
+ goto state_34;
if (ch.unicode() >= 35 && ch.unicode() <= 91)
- goto state_30;
+ goto state_33;
if (ch.unicode() == 92)
- goto state_32;
+ goto state_35;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
- goto state_30;
+ goto state_33;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_30;
+ goto state_33;
if (ch.unicode() >= 123)
- goto state_30;
+ goto state_33;
goto out;
- state_79:
+ state_85:
lastAcceptingPos = pos;
token = QCss::HASH;
ch = next();
if (ch.unicode() == 45)
- goto state_61;
+ goto state_67;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_61;
+ goto state_67;
if (ch.unicode() == 92)
- goto state_62;
+ goto state_68;
if (ch.unicode() == 95)
- goto state_61;
+ goto state_67;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_61;
+ goto state_67;
goto out;
- state_80:
+ state_86:
lastAcceptingPos = pos;
token = QCss::INVALID;
ch = next();
if (ch.unicode() >= 1 && ch.unicode() <= 9)
- goto state_35;
+ goto state_39;
if (ch.unicode() == 11)
- goto state_35;
+ goto state_39;
if (ch.unicode() >= 14 && ch.unicode() <= 38)
- goto state_35;
+ goto state_39;
if (ch.unicode() == 39)
- goto state_36;
+ goto state_40;
if (ch.unicode() >= 40 && ch.unicode() <= 91)
- goto state_35;
+ goto state_39;
if (ch.unicode() == 92)
- goto state_37;
+ goto state_41;
if (ch.unicode() >= 93 && ch.unicode() <= 96)
- goto state_35;
+ goto state_39;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_35;
+ goto state_39;
if (ch.unicode() >= 123)
- goto state_35;
+ goto state_39;
goto out;
- state_81:
+ state_87:
lastAcceptingPos = pos;
token = QCss::LENGTH;
ch = next();
if (ch.unicode() == 45)
- goto state_71;
+ goto state_77;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_71;
+ goto state_77;
if (ch.unicode() == 92)
- goto state_72;
+ goto state_78;
if (ch.unicode() == 95)
- goto state_71;
+ goto state_77;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_71;
+ goto state_77;
goto out;
- state_83:
+ state_89:
lastAcceptingPos = pos;
token = QCss::ATKEYWORD_SYM;
ch = next();
if (ch.unicode() == 45)
- goto state_75;
+ goto state_81;
if (ch.unicode() >= 48 && ch.unicode() <= 57)
- goto state_75;
+ goto state_81;
if (ch.unicode() == 92)
- goto state_76;
+ goto state_82;
if (ch.unicode() == 95)
- goto state_75;
+ goto state_81;
if ((ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256)
- goto state_75;
+ goto state_81;
goto out;
found:
lastAcceptingPos = pos;
diff --git a/src/gui/text/qdistancefield.cpp b/src/gui/text/qdistancefield.cpp
index 5a696807b4..933dd1bf54 100644
--- a/src/gui/text/qdistancefield.cpp
+++ b/src/gui/text/qdistancefield.cpp
@@ -45,6 +45,8 @@
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcDistanceField, "qt.distanceField");
+
namespace
{
enum FillHDir
@@ -736,8 +738,40 @@ static bool imageHasNarrowOutlines(const QImage &im)
return minHThick == 1 || minVThick == 1;
}
+static int QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE = 54;
+static int QT_DISTANCEFIELD_DEFAULT_SCALE = 16;
+static int QT_DISTANCEFIELD_DEFAULT_RADIUS = 80;
+static int QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT = 2000;
+
+static void initialDistanceFieldFactor()
+{
+ static bool initialized = false;
+ if (initialized)
+ return;
+ initialized = true;
+
+ if (qEnvironmentVariableIsSet("QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE")) {
+ QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE = qEnvironmentVariableIntValue("QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE");
+ qCDebug(lcDistanceField) << "set the QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE:" << QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE;
+ }
+
+ if (qEnvironmentVariableIsSet("QT_DISTANCEFIELD_DEFAULT_SCALE")) {
+ QT_DISTANCEFIELD_DEFAULT_SCALE = qEnvironmentVariableIntValue("QT_DISTANCEFIELD_DEFAULT_SCALE");
+ qCDebug(lcDistanceField) << "set the QT_DISTANCEFIELD_DEFAULT_SCALE:" << QT_DISTANCEFIELD_DEFAULT_SCALE;
+ }
+ if (qEnvironmentVariableIsSet("QT_DISTANCEFIELD_DEFAULT_RADIUS")) {
+ QT_DISTANCEFIELD_DEFAULT_RADIUS = qEnvironmentVariableIntValue("QT_DISTANCEFIELD_DEFAULT_RADIUS");
+ qDebug(lcDistanceField) << "set the QT_DISTANCEFIELD_DEFAULT_RADIUS:" << QT_DISTANCEFIELD_DEFAULT_RADIUS;
+ }
+ if (qEnvironmentVariableIsSet("QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT")) {
+ QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT = qEnvironmentVariableIntValue("QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT");
+ qCDebug(lcDistanceField) << "set the QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT:" << QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT;
+ }
+}
+
bool qt_fontHasNarrowOutlines(QFontEngine *fontEngine)
{
+ initialDistanceFieldFactor();
QFontEngine *fe = fontEngine->cloneWithSize(QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE);
if (!fe)
return false;
@@ -757,6 +791,7 @@ bool qt_fontHasNarrowOutlines(QFontEngine *fontEngine)
bool qt_fontHasNarrowOutlines(const QRawFont &f)
{
QRawFont font = f;
+ initialDistanceFieldFactor();
font.setPixelSize(QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE);
if (!font.isValid())
return false;
@@ -769,6 +804,41 @@ bool qt_fontHasNarrowOutlines(const QRawFont &f)
QRawFont::PixelAntialiasing));
}
+int QT_DISTANCEFIELD_BASEFONTSIZE(bool narrowOutlineFont)
+{
+ initialDistanceFieldFactor();
+
+ if (Q_UNLIKELY(narrowOutlineFont))
+ return QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE * 2;
+ else
+ return QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE;
+}
+
+int QT_DISTANCEFIELD_SCALE(bool narrowOutlineFont)
+{
+ initialDistanceFieldFactor();
+
+ if (Q_UNLIKELY(narrowOutlineFont))
+ return QT_DISTANCEFIELD_DEFAULT_SCALE / 2;
+ else
+ return QT_DISTANCEFIELD_DEFAULT_SCALE;
+}
+
+int QT_DISTANCEFIELD_RADIUS(bool narrowOutlineFont)
+{
+ initialDistanceFieldFactor();
+
+ if (Q_UNLIKELY(narrowOutlineFont))
+ return QT_DISTANCEFIELD_DEFAULT_RADIUS / 2;
+ else
+ return QT_DISTANCEFIELD_DEFAULT_RADIUS;
+}
+
+int QT_DISTANCEFIELD_HIGHGLYPHCOUNT()
+{
+ initialDistanceFieldFactor();
+ return QT_DISTANCEFIELD_DEFAULT_HIGHGLYPHCOUNT;
+}
QDistanceFieldData::QDistanceFieldData(const QDistanceFieldData &other)
: QSharedData(other)
diff --git a/src/gui/text/qdistancefield_p.h b/src/gui/text/qdistancefield_p.h
index c6c5e6b650..27ab84332c 100644
--- a/src/gui/text/qdistancefield_p.h
+++ b/src/gui/text/qdistancefield_p.h
@@ -51,30 +51,24 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <qrawfont.h>
#include <private/qfontengine_p.h>
#include <QtCore/qshareddata.h>
+#include <QtCore/qglobal.h>
+#include <QLoggingCategory>
QT_BEGIN_NAMESPACE
-#define QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE 54
-#define QT_DISTANCEFIELD_DEFAULT_SCALE 16
-#define QT_DISTANCEFIELD_DEFAULT_RADIUS 80
-#define QT_DISTANCEFIELD_HIGHGLYPHCOUNT 2000
-
-#define QT_DISTANCEFIELD_BASEFONTSIZE(NarrowOutlineFont) \
- (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE * 2 : \
- QT_DISTANCEFIELD_DEFAULT_BASEFONTSIZE)
-#define QT_DISTANCEFIELD_SCALE(NarrowOutlineFont) \
- (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_SCALE / 2 : \
- QT_DISTANCEFIELD_DEFAULT_SCALE)
-#define QT_DISTANCEFIELD_RADIUS(NarrowOutlineFont) \
- (NarrowOutlineFont ? QT_DISTANCEFIELD_DEFAULT_RADIUS / 2 : \
- QT_DISTANCEFIELD_DEFAULT_RADIUS)
-
bool Q_GUI_EXPORT qt_fontHasNarrowOutlines(const QRawFont &f);
bool Q_GUI_EXPORT qt_fontHasNarrowOutlines(QFontEngine *fontEngine);
+int Q_GUI_EXPORT QT_DISTANCEFIELD_BASEFONTSIZE(bool narrowOutlineFont);
+int Q_GUI_EXPORT QT_DISTANCEFIELD_TILESIZE(bool narrowOutlineFont);
+int Q_GUI_EXPORT QT_DISTANCEFIELD_SCALE(bool narrowOutlineFont);
+int Q_GUI_EXPORT QT_DISTANCEFIELD_RADIUS(bool narrowOutlineFont);
+int Q_GUI_EXPORT QT_DISTANCEFIELD_HIGHGLYPHCOUNT();
+
class Q_GUI_EXPORT QDistanceFieldData : public QSharedData
{
public:
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 9e4f61ebee..5e72e6969c 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -2001,7 +2001,7 @@ QString QFont::key() const
QString QFont::toString() const
{
const QChar comma(QLatin1Char(','));
- return family() + comma +
+ QString fontDescription = family() + comma +
QString::number( pointSizeF()) + comma +
QString::number( pixelSize()) + comma +
QString::number((int) styleHint()) + comma +
@@ -2011,6 +2011,12 @@ QString QFont::toString() const
QString::number((int) strikeOut()) + comma +
QString::number((int)fixedPitch()) + comma +
QString::number((int) false);
+
+ QString fontStyle = styleName();
+ if (!fontStyle.isEmpty())
+ fontDescription += comma + fontStyle;
+
+ return fontDescription;
}
/*!
@@ -2054,7 +2060,7 @@ bool QFont::fromString(const QString &descrip)
setUnderline(l[5].toInt());
setStrikeOut(l[6].toInt());
setFixedPitch(l[7].toInt());
- } else if (count == 10) {
+ } else if (count >= 10) {
if (l[2].toInt() > 0)
setPixelSize(l[2].toInt());
setStyleHint((StyleHint) l[3].toInt());
@@ -2063,7 +2069,10 @@ bool QFont::fromString(const QString &descrip)
setUnderline(l[6].toInt());
setStrikeOut(l[7].toInt());
setFixedPitch(l[8].toInt());
+ if (count == 11)
+ d->request.styleName = l[10].toString();
}
+
if (count >= 9 && !d->request.fixedPitch) // assume 'false' fixedPitch equals default
d->request.ignorePitch = true;
diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h
index 85a237643c..b295e13f61 100644
--- a/src/gui/text/qfont.h
+++ b/src/gui/text/qfont.h
@@ -40,6 +40,7 @@
#ifndef QFONT_H
#define QFONT_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qwindowdefs.h>
#include <QtCore/qstring.h>
#include <QtCore/qsharedpointer.h>
diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h
index 3979bb27ac..21823dc12f 100644
--- a/src/gui/text/qfont_p.h
+++ b/src/gui/text/qfont_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtGui/qfont.h"
#include "QtCore/qmap.h"
#include "QtCore/qhash.h"
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index c4a130e04c..ef09a0cacd 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -2221,10 +2221,18 @@ QString QFontDatabase::writingSystemSample(WritingSystem writingSystem)
sample += QChar(0x05D3);
break;
case Arabic:
+ sample += QChar(0x0623);
sample += QChar(0x0628);
+ sample += QChar(0x062C);
+ sample += QChar(0x062F);
+ sample += QChar(0x064A);
+ sample += QChar(0x0629);
+ sample += QChar(0x0020);
+ sample += QChar(0x0639);
+ sample += QChar(0x0631);
+ sample += QChar(0x0628);
+ sample += QChar(0x064A);
sample += QChar(0x0629);
- sample += QChar(0x062A);
- sample += QChar(0x063A);
break;
case Syriac:
sample += QChar(0x0715);
diff --git a/src/gui/text/qfontdatabase.h b/src/gui/text/qfontdatabase.h
index 67cf671304..e6aef493bd 100644
--- a/src/gui/text/qfontdatabase.h
+++ b/src/gui/text/qfontdatabase.h
@@ -40,6 +40,7 @@
#ifndef QFONTDATABASE_H
#define QFONTDATABASE_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qwindowdefs.h>
#include <QtCore/qstring.h>
#include <QtGui/qfont.h>
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index fe5d544dba..adc8f634dc 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -1845,7 +1845,11 @@ QFontEngine *QFontEngineMulti::loadEngine(int at)
glyph_t QFontEngineMulti::glyphIndex(uint ucs4) const
{
glyph_t glyph = engine(0)->glyphIndex(ucs4);
- if (glyph == 0 && ucs4 != QChar::LineSeparator) {
+ if (glyph == 0
+ && ucs4 != QChar::LineSeparator
+ && ucs4 != QChar::LineFeed
+ && ucs4 != QChar::CarriageReturn
+ && ucs4 != QChar::ParagraphSeparator) {
if (!m_fallbackFamiliesQueried)
const_cast<QFontEngineMulti *>(this)->ensureFallbackFamiliesQueried();
for (int x = 1, n = qMin(m_engines.size(), 256); x < n; ++x) {
@@ -1883,7 +1887,11 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len,
QStringIterator it(str, str + len);
while (it.hasNext()) {
const uint ucs4 = it.peekNext();
- if (glyphs->glyphs[glyph_pos] == 0 && ucs4 != QChar::LineSeparator) {
+ if (glyphs->glyphs[glyph_pos] == 0
+ && ucs4 != QChar::LineSeparator
+ && ucs4 != QChar::LineFeed
+ && ucs4 != QChar::CarriageReturn
+ && ucs4 != QChar::ParagraphSeparator) {
if (!m_fallbackFamiliesQueried)
const_cast<QFontEngineMulti *>(this)->ensureFallbackFamiliesQueried();
for (int x = 1, n = qMin(m_engines.size(), 256); x < n; ++x) {
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index 1430444c7e..f3eeddab41 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include "QtCore/qglobal.h"
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtCore/qatomic.h"
#include <QtCore/qvarlengtharray.h>
#include <QtCore/QLinkedList>
diff --git a/src/gui/text/qfontengineglyphcache_p.h b/src/gui/text/qfontengineglyphcache_p.h
index 54b9af71df..fd5db1ecf5 100644
--- a/src/gui/text/qfontengineglyphcache_p.h
+++ b/src/gui/text/qfontengineglyphcache_p.h
@@ -52,7 +52,7 @@
//
-#include "QtCore/qglobal.h"
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtCore/qatomic.h"
#include <QtCore/qvarlengtharray.h>
#include "private/qfont_p.h"
diff --git a/src/gui/text/qfontinfo.h b/src/gui/text/qfontinfo.h
index ee368e26bd..f5e05775b4 100644
--- a/src/gui/text/qfontinfo.h
+++ b/src/gui/text/qfontinfo.h
@@ -40,6 +40,7 @@
#ifndef QFONTINFO_H
#define QFONTINFO_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qfont.h>
#include <QtCore/qsharedpointer.h>
diff --git a/src/gui/text/qfontmetrics.h b/src/gui/text/qfontmetrics.h
index 1d7241c9f2..22e51f29f7 100644
--- a/src/gui/text/qfontmetrics.h
+++ b/src/gui/text/qfontmetrics.h
@@ -40,6 +40,7 @@
#ifndef QFONTMETRICS_H
#define QFONTMETRICS_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qfont.h>
#include <QtCore/qsharedpointer.h>
#ifndef QT_INCLUDE_COMPAT
diff --git a/src/gui/text/qfontsubset_p.h b/src/gui/text/qfontsubset_p.h
index a7328df4ed..e7c6053beb 100644
--- a/src/gui/text/qfontsubset_p.h
+++ b/src/gui/text/qfontsubset_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "private/qfontengine_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/gui/text/qfragmentmap_p.h b/src/gui/text/qfragmentmap_p.h
index b54d7261d0..35f60ac961 100644
--- a/src/gui/text/qfragmentmap_p.h
+++ b/src/gui/text/qfragmentmap_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include "QtCore/qglobal.h"
+#include <QtGui/private/qtguiglobal_p.h>
#include <stdlib.h>
#include <private/qtools_p.h>
diff --git a/src/gui/text/qglyphrun.h b/src/gui/text/qglyphrun.h
index 6016925d27..6182c4f749 100644
--- a/src/gui/text/qglyphrun.h
+++ b/src/gui/text/qglyphrun.h
@@ -40,6 +40,7 @@
#ifndef QGLYPHRUN_H
#define QGLYPHRUN_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qsharedpointer.h>
#include <QtCore/qvector.h>
#include <QtCore/qpoint.h>
diff --git a/src/gui/text/qglyphrun_p.h b/src/gui/text/qglyphrun_p.h
index 52fa03f150..5b6bdad648 100644
--- a/src/gui/text/qglyphrun_p.h
+++ b/src/gui/text/qglyphrun_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "qglyphrun.h"
#include "qrawfont.h"
diff --git a/src/gui/text/qharfbuzzng_p.h b/src/gui/text/qharfbuzzng_p.h
index 28f20338dd..95a21eedb6 100644
--- a/src/gui/text/qharfbuzzng_p.h
+++ b/src/gui/text/qharfbuzzng_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtCore/qchar.h>
#include <harfbuzz/hb.h>
diff --git a/src/gui/text/qplatformfontdatabase.h b/src/gui/text/qplatformfontdatabase.h
index 61c892ad8b..13d8cbde60 100644
--- a/src/gui/text/qplatformfontdatabase.h
+++ b/src/gui/text/qplatformfontdatabase.h
@@ -49,7 +49,7 @@
// source and binary incompatible with future versions of Qt.
//
-#include <QtCore/qconfig.h>
+#include <QtGui/qtguiglobal.h>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QList>
diff --git a/src/gui/text/qrawfont.h b/src/gui/text/qrawfont.h
index aa98363229..5791c6af16 100644
--- a/src/gui/text/qrawfont.h
+++ b/src/gui/text/qrawfont.h
@@ -40,6 +40,7 @@
#ifndef QRAWFONT_H
#define QRAWFONT_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qstring.h>
#include <QtCore/qiodevice.h>
#include <QtCore/qglobal.h>
diff --git a/src/gui/text/qrawfont_p.h b/src/gui/text/qrawfont_p.h
index ee54578cf9..0fc8739bfb 100644
--- a/src/gui/text/qrawfont_p.h
+++ b/src/gui/text/qrawfont_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "qrawfont.h"
#include "qfontengine_p.h"
diff --git a/src/gui/text/qstatictext.h b/src/gui/text/qstatictext.h
index 2da74825a2..00dfccc144 100644
--- a/src/gui/text/qstatictext.h
+++ b/src/gui/text/qstatictext.h
@@ -40,6 +40,7 @@
#ifndef QSTATICTEXT_H
#define QSTATICTEXT_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qsize.h>
#include <QtCore/qstring.h>
#include <QtCore/qmetatype.h>
diff --git a/src/gui/text/qstatictext_p.h b/src/gui/text/qstatictext_p.h
index 7fdf46c101..dda566a22b 100644
--- a/src/gui/text/qstatictext_p.h
+++ b/src/gui/text/qstatictext_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "qstatictext.h"
#include <private/qtextureglyphcache_p.h>
diff --git a/src/gui/text/qsyntaxhighlighter.h b/src/gui/text/qsyntaxhighlighter.h
index 2ccb3a68b9..d87f89f0fd 100644
--- a/src/gui/text/qsyntaxhighlighter.h
+++ b/src/gui/text/qsyntaxhighlighter.h
@@ -40,7 +40,7 @@
#ifndef QSYNTAXHIGHLIGHTER_H
#define QSYNTAXHIGHLIGHTER_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#ifndef QT_NO_SYNTAXHIGHLIGHTER
diff --git a/src/gui/text/qtextcursor.h b/src/gui/text/qtextcursor.h
index 9610e61b39..1a00b753ad 100644
--- a/src/gui/text/qtextcursor.h
+++ b/src/gui/text/qtextcursor.h
@@ -40,6 +40,7 @@
#ifndef QTEXTCURSOR_H
#define QTEXTCURSOR_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qstring.h>
#include <QtCore/qshareddata.h>
#include <QtGui/qtextformat.h>
diff --git a/src/gui/text/qtextcursor_p.h b/src/gui/text/qtextcursor_p.h
index 84f912a3fa..3569317b6d 100644
--- a/src/gui/text/qtextcursor_p.h
+++ b/src/gui/text/qtextcursor_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "qtextcursor.h"
#include "qtextdocument.h"
#include "qtextdocument_p.h"
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 723918ae69..75899dec80 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -94,7 +94,7 @@ bool Qt::mightBeRichText(const QString& text)
++start;
// skip a leading <?xml ... ?> as for example with xhtml
- if (text.mid(start, 5) == QLatin1String("<?xml")) {
+ if (text.midRef(start, 5).compare(QLatin1String("<?xml")) == 0) {
while (start < text.length()) {
if (text.at(start) == QLatin1Char('?')
&& start + 2 < text.length()
@@ -109,12 +109,12 @@ bool Qt::mightBeRichText(const QString& text)
++start;
}
- if (text.mid(start, 5).toLower() == QLatin1String("<!doc"))
+ if (text.midRef(start, 5).compare(QLatin1String("<!doc"), Qt::CaseInsensitive) == 0)
return true;
int open = start;
while (open < text.length() && text.at(open) != QLatin1Char('<')
&& text.at(open) != QLatin1Char('\n')) {
- if (text.at(open) == QLatin1Char('&') && text.mid(open+1,3) == QLatin1String("lt;"))
+ if (text.at(open) == QLatin1Char('&') && text.midRef(open + 1, 3) == QLatin1String("lt;"))
return true; // support desperate attempt of user to see <...>
++open;
}
@@ -3135,7 +3135,7 @@ void QTextHtmlExporter::emitTable(const QTextTable *table)
html += QLatin1String("</table>");
}
-void QTextHtmlExporter::emitFrame(QTextFrame::Iterator frameIt)
+void QTextHtmlExporter::emitFrame(const QTextFrame::Iterator &frameIt)
{
if (!frameIt.atEnd()) {
QTextFrame::Iterator next = frameIt;
diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h
index 02cfa97bce..1888088f0d 100644
--- a/src/gui/text/qtextdocument.h
+++ b/src/gui/text/qtextdocument.h
@@ -40,6 +40,7 @@
#ifndef QTEXTDOCUMENT_H
#define QTEXTDOCUMENT_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qsize.h>
#include <QtCore/qrect.h>
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index ffc5d7418b..3537adba9e 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -1078,8 +1078,9 @@ void QTextDocumentPrivate::appendUndoItem(const QTextUndoCommand &c)
const QTextUndoCommand &last = undoStack.at(lastIdx);
if ( (last.block_part && c.block_part && !last.block_end) // part of the same block => can merge
- || (!c.block_part && !last.block_part)) { // two single undo items => can merge
-
+ || (!c.block_part && !last.block_part) // two single undo items => can merge
+ || (c.command == QTextUndoCommand::Inserted && last.command == c.command && (last.block_part && !c.block_part))) {
+ // two sequential inserts that are not part of the same block => can merge
if (undoStack[lastIdx].tryMerge(c))
return;
}
diff --git a/src/gui/text/qtextdocument_p.h b/src/gui/text/qtextdocument_p.h
index 34849df0bb..cad9131fbf 100644
--- a/src/gui/text/qtextdocument_p.h
+++ b/src/gui/text/qtextdocument_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include "QtCore/qglobal.h"
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtCore/qstring.h"
#include "QtCore/qvector.h"
#include "QtCore/qlist.h"
@@ -158,7 +158,7 @@ public:
};
Q_DECLARE_TYPEINFO(QTextUndoCommand, Q_PRIMITIVE_TYPE);
-class Q_AUTOTEST_EXPORT QTextDocumentPrivate : public QObjectPrivate
+class Q_GUI_EXPORT QTextDocumentPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QTextDocument)
public:
@@ -378,7 +378,7 @@ private:
enum StyleMode { EmitStyleTag, OmitStyleTag };
enum FrameType { TextFrame, TableFrame, RootFrame };
- void emitFrame(QTextFrame::Iterator frameIt);
+ void emitFrame(const QTextFrame::Iterator &frameIt);
void emitTextFrame(const QTextFrame *frame);
void emitBlock(const QTextBlock &block);
void emitTable(const QTextTable *table);
diff --git a/src/gui/text/qtextdocumentfragment.h b/src/gui/text/qtextdocumentfragment.h
index d1c1adfd0a..a56f6d06d6 100644
--- a/src/gui/text/qtextdocumentfragment.h
+++ b/src/gui/text/qtextdocumentfragment.h
@@ -40,6 +40,7 @@
#ifndef QTEXTDOCUMENTFRAGMENT_H
#define QTEXTDOCUMENTFRAGMENT_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qstring.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/text/qtextdocumentfragment_p.h b/src/gui/text/qtextdocumentfragment_p.h
index 56dff01149..e8699545f7 100644
--- a/src/gui/text/qtextdocumentfragment_p.h
+++ b/src/gui/text/qtextdocumentfragment_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtGui/qtextdocument.h"
#include "private/qtexthtmlparser_p.h"
#include "private/qtextdocument_p.h"
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index b6cbd9617f..8ad2d85e7c 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -295,7 +295,7 @@ static inline bool isEmptyBlockBeforeTable(const QTextBlock &block, const QTextB
;
}
-static inline bool isEmptyBlockBeforeTable(QTextFrame::Iterator it)
+static inline bool isEmptyBlockBeforeTable(const QTextFrame::Iterator &it)
{
QTextFrame::Iterator next = it; ++next;
if (it.currentFrame())
@@ -419,7 +419,7 @@ static bool operator<(int pos, const QCheckPoint &checkPoint)
#endif
-static void fillBackground(QPainter *p, const QRectF &rect, QBrush brush, const QPointF &origin, QRectF gradientRect = QRectF())
+static void fillBackground(QPainter *p, const QRectF &rect, QBrush brush, const QPointF &origin, const QRectF &gradientRect = QRectF())
{
p->save();
if (brush.style() >= Qt::LinearGradientPattern && brush.style() <= Qt::ConicalGradientPattern) {
@@ -1504,7 +1504,7 @@ void QTextDocumentLayoutPrivate::drawListItem(const QPointF &offset, QPainter *p
painter->restore();
}
-static QFixed flowPosition(const QTextFrame::iterator it)
+static QFixed flowPosition(const QTextFrame::iterator &it)
{
if (it.atEnd())
return 0;
@@ -2921,11 +2921,11 @@ void QTextDocumentLayout::documentChanged(int from, int oldLength, int length)
{
Q_D(QTextDocumentLayout);
- QTextBlock startIt = document()->findBlock(from);
+ QTextBlock blockIt = document()->findBlock(from);
QTextBlock endIt = document()->findBlock(qMax(0, from + length - 1));
if (endIt.isValid())
endIt = endIt.next();
- for (QTextBlock blockIt = startIt; blockIt.isValid() && blockIt != endIt; blockIt = blockIt.next())
+ for (; blockIt.isValid() && blockIt != endIt; blockIt = blockIt.next())
blockIt.clearLayout();
if (d->docPrivate->pageSize.isNull())
@@ -2967,9 +2967,6 @@ void QTextDocumentLayout::documentChanged(int from, int oldLength, int length)
d->insideDocumentChange = false;
- for (QTextBlock blockIt = startIt; blockIt.isValid() && blockIt != endIt; blockIt = blockIt.next())
- emit updateBlock(blockIt);
-
if (d->showLayoutProgress) {
const QSizeF newSize = dynamicDocumentSize();
if (newSize != d->lastReportedSize) {
diff --git a/src/gui/text/qtextdocumentlayout_p.h b/src/gui/text/qtextdocumentlayout_p.h
index a9cd6cf289..710c49628e 100644
--- a/src/gui/text/qtextdocumentlayout_p.h
+++ b/src/gui/text/qtextdocumentlayout_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtGui/qabstracttextdocumentlayout.h"
#include "QtGui/qtextoption.h"
#include "QtGui/qtextobject.h"
diff --git a/src/gui/text/qtextdocumentwriter.cpp b/src/gui/text/qtextdocumentwriter.cpp
index a7c58ac2a6..731aaf1fcf 100644
--- a/src/gui/text/qtextdocumentwriter.cpp
+++ b/src/gui/text/qtextdocumentwriter.cpp
@@ -139,12 +139,9 @@ QTextDocumentWriter::QTextDocumentWriter(QIODevice *device, const QByteArray &fo
format by inspecting the extension of \a fileName.
*/
QTextDocumentWriter::QTextDocumentWriter(const QString &fileName, const QByteArray &format)
- : d(new QTextDocumentWriterPrivate(this))
+ : QTextDocumentWriter(new QFile(fileName), format)
{
- QFile *file = new QFile(fileName);
- d->device = file;
d->deleteDevice = true;
- d->format = format;
}
/*!
diff --git a/src/gui/text/qtextdocumentwriter.h b/src/gui/text/qtextdocumentwriter.h
index b7917e55a4..0502bf1a96 100644
--- a/src/gui/text/qtextdocumentwriter.h
+++ b/src/gui/text/qtextdocumentwriter.h
@@ -39,6 +39,7 @@
#ifndef QTEXTDOCUMENTWRITER_H
#define QTEXTDOCUMENTWRITER_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qstring.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 7378b129a9..cad30b0c77 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -843,7 +843,7 @@ enum JustificationClass {
Adds an inter character justification opportunity after the number or letter
character and a space justification opportunity after the space character.
*/
-static inline void qt_getDefaultJustificationOpportunities(const ushort *string, int length, QGlyphLayout g, ushort *log_clusters, int spaceAs)
+static inline void qt_getDefaultJustificationOpportunities(const ushort *string, int length, const QGlyphLayout &g, ushort *log_clusters, int spaceAs)
{
int str_pos = 0;
while (str_pos < length) {
@@ -877,7 +877,7 @@ static inline void qt_getDefaultJustificationOpportunities(const ushort *string,
}
}
-static inline void qt_getJustificationOpportunities(const ushort *string, int length, const QScriptItem &si, QGlyphLayout g, ushort *log_clusters)
+static inline void qt_getJustificationOpportunities(const ushort *string, int length, const QScriptItem &si, const QGlyphLayout &g, ushort *log_clusters)
{
Q_ASSERT(length > 0 && g.numGlyphs > 0);
@@ -1292,9 +1292,7 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si,
#ifdef Q_OS_DARWIN
if (actualFontEngine->type() == QFontEngine::Mac) {
- // CTRunGetPosition has a bug which applies matrix on 10.6, so we disable
- // scaling the advances for this particular version
- if (QSysInfo::MacintoshVersion != QSysInfo::MV_10_6 && actualFontEngine->fontDef.stretch != 100) {
+ if (actualFontEngine->fontDef.stretch != 100) {
QFixed stretch = QFixed(int(actualFontEngine->fontDef.stretch)) / QFixed(100);
for (uint i = 0; i < num_glyphs; ++i)
g.advances[i] *= stretch;
@@ -3519,7 +3517,7 @@ QTextItemInt QTextItemInt::midItem(QFontEngine *fontEngine, int firstGlyphIndex,
}
-QTransform qt_true_matrix(qreal w, qreal h, QTransform x)
+QTransform qt_true_matrix(qreal w, qreal h, const QTransform &x)
{
QRectF rect = x.mapRect(QRectF(0, 0, w, h));
return x * QTransform::fromTranslate(-rect.x(), -rect.y());
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index 56c9825cc1..160e9ce490 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include "QtCore/qglobal.h"
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtCore/qstring.h"
#include "QtCore/qvarlengtharray.h"
#include "QtCore/qnamespace.h"
diff --git a/src/gui/text/qtextformat.h b/src/gui/text/qtextformat.h
index 805affd87c..28c3035537 100644
--- a/src/gui/text/qtextformat.h
+++ b/src/gui/text/qtextformat.h
@@ -40,6 +40,7 @@
#ifndef QTEXTFORMAT_H
#define QTEXTFORMAT_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qcolor.h>
#include <QtGui/qfont.h>
#include <QtCore/qshareddata.h>
diff --git a/src/gui/text/qtextformat_p.h b/src/gui/text/qtextformat_p.h
index 45a432d2f5..f05bfaff71 100644
--- a/src/gui/text/qtextformat_p.h
+++ b/src/gui/text/qtextformat_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtGui/qtextformat.h"
#include "QtCore/qvector.h"
diff --git a/src/gui/text/qtexthtmlparser_p.h b/src/gui/text/qtexthtmlparser_p.h
index 4c0dd967f9..4ea6e44138 100644
--- a/src/gui/text/qtexthtmlparser_p.h
+++ b/src/gui/text/qtexthtmlparser_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtCore/qvector.h"
#include "QtGui/qbrush.h"
#include "QtGui/qcolor.h"
diff --git a/src/gui/text/qtextimagehandler_p.h b/src/gui/text/qtextimagehandler_p.h
index 4bc19d49c3..a22c91ecbf 100644
--- a/src/gui/text/qtextimagehandler_p.h
+++ b/src/gui/text/qtextimagehandler_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtCore/qobject.h"
#include "QtGui/qabstracttextdocumentlayout.h"
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 3b1ee8ec03..f5827bb683 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -975,7 +975,7 @@ void QTextLayout::setFlags(int flags)
}
static void addSelectedRegionsToPath(QTextEngine *eng, int lineNumber, const QPointF &pos, QTextLayout::FormatRange *selection,
- QPainterPath *region, QRectF boundingRect)
+ QPainterPath *region, const QRectF &boundingRect)
{
const QScriptLine &line = eng->lines[lineNumber];
@@ -1326,7 +1326,11 @@ void QTextLayout::drawCursor(QPainter *p, const QPointF &pos, int cursorPosition
&& (p->transform().type() > QTransform::TxTranslate);
if (toggleAntialiasing)
p->setRenderHint(QPainter::Antialiasing);
+ QPainter::CompositionMode origCompositionMode = p->compositionMode();
+ if (p->paintEngine()->hasFeature(QPaintEngine::RasterOpModes))
+ p->setCompositionMode(QPainter::RasterOp_NotDestination);
p->fillRect(QRectF(x, y, qreal(width), (base + descent).toReal()), p->pen().brush());
+ p->setCompositionMode(origCompositionMode);
if (toggleAntialiasing)
p->setRenderHint(QPainter::Antialiasing, false);
if (d->layoutData->hasBidi) {
diff --git a/src/gui/text/qtextlayout.h b/src/gui/text/qtextlayout.h
index 1cbb5ac8d8..980a099b05 100644
--- a/src/gui/text/qtextlayout.h
+++ b/src/gui/text/qtextlayout.h
@@ -39,6 +39,7 @@
#ifndef QTEXTLAYOUT_H
#define QTEXTLAYOUT_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qstring.h>
#include <QtCore/qnamespace.h>
#include <QtCore/qrect.h>
diff --git a/src/gui/text/qtextlist.h b/src/gui/text/qtextlist.h
index 71da175a14..3967787f03 100644
--- a/src/gui/text/qtextlist.h
+++ b/src/gui/text/qtextlist.h
@@ -40,6 +40,7 @@
#ifndef QTEXTLIST_H
#define QTEXTLIST_H
+#include <QtGui/qtguiglobal.h>
#include <QtGui/qtextobject.h>
#include <QtCore/qobject.h>
diff --git a/src/gui/text/qtextobject.h b/src/gui/text/qtextobject.h
index d3f6b3d0ac..a5030de112 100644
--- a/src/gui/text/qtextobject.h
+++ b/src/gui/text/qtextobject.h
@@ -40,6 +40,7 @@
#ifndef QTEXTOBJECT_H
#define QTEXTOBJECT_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qobject.h>
#include <QtGui/qtextformat.h>
#include <QtGui/qtextlayout.h>
diff --git a/src/gui/text/qtextobject_p.h b/src/gui/text/qtextobject_p.h
index ffc331e99d..81ab023cc3 100644
--- a/src/gui/text/qtextobject_p.h
+++ b/src/gui/text/qtextobject_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "QtGui/qtextobject.h"
#include "private/qobject_p.h"
#include "QtGui/qtextdocument.h"
diff --git a/src/gui/text/qtextodfwriter.cpp b/src/gui/text/qtextodfwriter.cpp
index ad537b7126..73d2e545ba 100644
--- a/src/gui/text/qtextodfwriter.cpp
+++ b/src/gui/text/qtextodfwriter.cpp
@@ -295,7 +295,7 @@ void QTextOdfWriter::writeBlock(QXmlStreamWriter &writer, const QTextBlock &bloc
writer.writeStartElement(textNS, QString::fromLatin1("span"));
QString fragmentText = frag.fragment().text();
- if (fragmentText.length() == 1 && fragmentText[0] == 0xFFFC) { // its an inline character.
+ if (fragmentText.length() == 1 && fragmentText[0] == QChar(0xFFFC)) { // its an inline character.
writeInlineCharacter(writer, frag.fragment());
writer.writeEndElement(); // span
continue;
@@ -510,7 +510,7 @@ void QTextOdfWriter::writeBlockFormat(QXmlStreamWriter &writer, QTextBlockFormat
case QTextOption::CenterTab: type = QString::fromLatin1("center"); break;
}
writer.writeAttribute(styleNS, QString::fromLatin1("type"), type);
- if (iterator->delimiter != 0)
+ if (!iterator->delimiter.isNull())
writer.writeAttribute(styleNS, QString::fromLatin1("char"), iterator->delimiter);
++iterator;
}
diff --git a/src/gui/text/qtextodfwriter_p.h b/src/gui/text/qtextodfwriter_p.h
index d4cd91f8a3..c1a5652760 100644
--- a/src/gui/text/qtextodfwriter_p.h
+++ b/src/gui/text/qtextodfwriter_p.h
@@ -40,7 +40,7 @@
#ifndef QTEXTODFWRITER_H
#define QTEXTODFWRITER_H
-#include <QtCore/qglobal.h>
+#include <QtGui/private/qtguiglobal_p.h>
#ifndef QT_NO_TEXTODFWRITER
diff --git a/src/gui/text/qtextoption.h b/src/gui/text/qtextoption.h
index f9c24ffeaf..9ef9cee9bb 100644
--- a/src/gui/text/qtextoption.h
+++ b/src/gui/text/qtextoption.h
@@ -40,6 +40,7 @@
#ifndef QTEXTOPTION_H
#define QTEXTOPTION_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qnamespace.h>
#include <QtCore/qchar.h>
#include <QtCore/qmetatype.h>
diff --git a/src/gui/text/qtexttable.h b/src/gui/text/qtexttable.h
index 14525aae25..ee8e974396 100644
--- a/src/gui/text/qtexttable.h
+++ b/src/gui/text/qtexttable.h
@@ -40,7 +40,7 @@
#ifndef QTEXTTABLE_H
#define QTEXTTABLE_H
-#include <QtCore/qglobal.h>
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qobject.h>
#include <QtGui/qtextobject.h>
diff --git a/src/gui/text/qtexttable_p.h b/src/gui/text/qtexttable_p.h
index 72d9d8c639..848537272d 100644
--- a/src/gui/text/qtexttable_p.h
+++ b/src/gui/text/qtexttable_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "private/qtextobject_p.h"
#include "private/qtextdocument_p.h"
diff --git a/src/gui/text/qzipreader_p.h b/src/gui/text/qzipreader_p.h
index 5603f0f0d6..eed6ee6a62 100644
--- a/src/gui/text/qzipreader_p.h
+++ b/src/gui/text/qzipreader_p.h
@@ -40,6 +40,7 @@
#ifndef QZIPREADER_H
#define QZIPREADER_H
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtCore/qglobal.h>
#ifndef QT_NO_TEXTODFWRITER
diff --git a/src/gui/text/qzipwriter_p.h b/src/gui/text/qzipwriter_p.h
index 0a4763855e..433bbab31e 100644
--- a/src/gui/text/qzipwriter_p.h
+++ b/src/gui/text/qzipwriter_p.h
@@ -39,7 +39,7 @@
#ifndef QZIPWRITER_H
#define QZIPWRITER_H
-#include <QtCore/qglobal.h>
+#include <QtGui/private/qtguiglobal_p.h>
#ifndef QT_NO_TEXTODFWRITER
diff --git a/src/gui/util/qabstractlayoutstyleinfo_p.h b/src/gui/util/qabstractlayoutstyleinfo_p.h
index b8f3825ada..bf1e1fc852 100644
--- a/src/gui/util/qabstractlayoutstyleinfo_p.h
+++ b/src/gui/util/qabstractlayoutstyleinfo_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtCore/qnamespace.h>
#include "qlayoutpolicy_p.h"
diff --git a/src/gui/util/qdesktopservices.h b/src/gui/util/qdesktopservices.h
index 3d44ab4a1e..21705e2757 100644
--- a/src/gui/util/qdesktopservices.h
+++ b/src/gui/util/qdesktopservices.h
@@ -40,6 +40,7 @@
#ifndef QDESKTOPSERVICES_H
#define QDESKTOPSERVICES_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qstring.h>
#include <QtCore/qstandardpaths.h>
diff --git a/src/gui/util/qgridlayoutengine_p.h b/src/gui/util/qgridlayoutengine_p.h
index d79d4cc9c9..5f0cc5da73 100644
--- a/src/gui/util/qgridlayoutengine_p.h
+++ b/src/gui/util/qgridlayoutengine_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include "qalgorithms.h"
#include "qbitarray.h"
#include "qlist.h"
diff --git a/src/gui/util/qhexstring_p.h b/src/gui/util/qhexstring_p.h
index ac11c8ad14..511eec0f1b 100644
--- a/src/gui/util/qhexstring_p.h
+++ b/src/gui/util/qhexstring_p.h
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include <QtCore/qglobal.h>
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtCore/qpoint.h>
#include <QtCore/qstring.h>
#include <QtGui/qpolygon.h>
diff --git a/src/gui/util/qlayoutpolicy_p.h b/src/gui/util/qlayoutpolicy_p.h
index 979b808563..a729a57e8b 100644
--- a/src/gui/util/qlayoutpolicy_p.h
+++ b/src/gui/util/qlayoutpolicy_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtGui/private/qtguiglobal_p.h>
#include <QtCore/qobject.h>
#include <QtCore/qnamespace.h>
diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp
index 90c6e7a7b8..fb9dfc9f69 100644
--- a/src/gui/util/qvalidator.cpp
+++ b/src/gui/util/qvalidator.cpp
@@ -216,7 +216,7 @@ public:
*/
QValidator::QValidator(QObject * parent)
- : QObject(*new QValidatorPrivate, parent)
+ : QValidator(*new QValidatorPrivate, parent)
{
}
@@ -337,10 +337,8 @@ void QValidator::fixup(QString &) const
*/
QIntValidator::QIntValidator(QObject * parent)
- : QValidator(parent)
+ : QIntValidator(INT_MIN, INT_MAX, parent)
{
- b = INT_MIN;
- t = INT_MAX;
}
@@ -589,11 +587,8 @@ public:
*/
QDoubleValidator::QDoubleValidator(QObject * parent)
- : QValidator(*new QDoubleValidatorPrivate , parent)
+ : QDoubleValidator(-HUGE_VAL, HUGE_VAL, 1000, parent)
{
- b = -HUGE_VAL;
- t = HUGE_VAL;
- dec = 1000;
}
@@ -845,7 +840,7 @@ QDoubleValidator::Notation QDoubleValidator::notation() const
*/
QRegExpValidator::QRegExpValidator(QObject *parent)
- : QValidator(parent), r(QString::fromLatin1(".*"))
+ : QRegExpValidator(QRegExp(QString::fromLatin1(".*")), parent)
{
}
@@ -982,7 +977,7 @@ QRegularExpressionValidator::QRegularExpressionValidator(QObject *parent)
*/
QRegularExpressionValidator::QRegularExpressionValidator(const QRegularExpression &re, QObject *parent)
- : QValidator(*new QRegularExpressionValidatorPrivate, parent)
+ : QRegularExpressionValidator(parent)
{
Q_D(QRegularExpressionValidator);
d->setRegularExpression(re);
diff --git a/src/gui/util/qvalidator.h b/src/gui/util/qvalidator.h
index 85787a66c6..eba4b54672 100644
--- a/src/gui/util/qvalidator.h
+++ b/src/gui/util/qvalidator.h
@@ -41,6 +41,7 @@
#ifndef QVALIDATOR_H
#define QVALIDATOR_H
+#include <QtGui/qtguiglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qstring.h>
#include <QtCore/qregexp.h>
diff --git a/src/network/access/access.pri b/src/network/access/access.pri
index 38e9c25269..70ace3f55e 100644
--- a/src/network/access/access.pri
+++ b/src/network/access/access.pri
@@ -37,7 +37,9 @@ HEADERS += \
access/qnetworkdiskcache.h \
access/qhttpthreaddelegate_p.h \
access/qhttpmultipart.h \
- access/qhttpmultipart_p.h
+ access/qhttpmultipart_p.h \
+ access/qnetworkfile_p.h \
+ access/qhttp2protocolhandler_p.h
SOURCES += \
access/qftp.cpp \
@@ -68,8 +70,11 @@ SOURCES += \
access/qabstractnetworkcache.cpp \
access/qnetworkdiskcache.cpp \
access/qhttpthreaddelegate.cpp \
- access/qhttpmultipart.cpp
+ access/qhttpmultipart.cpp \
+ access/qnetworkfile.cpp \
+ access/qhttp2protocolhandler.cpp
mac: LIBS_PRIVATE += -framework Security
include($$PWD/../../3rdparty/zlib_dependency.pri)
+include($$PWD/http2/http2.pri)
diff --git a/src/network/access/http2/bitstreams.cpp b/src/network/access/http2/bitstreams.cpp
new file mode 100644
index 0000000000..d22c7cd4ec
--- /dev/null
+++ b/src/network/access/http2/bitstreams.cpp
@@ -0,0 +1,336 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "bitstreams_p.h"
+#include "huffman_p.h"
+
+#include <QtCore/qbytearray.h>
+
+#include <limits>
+
+QT_BEGIN_NAMESPACE
+
+static_assert(std::numeric_limits<uchar>::digits == 8, "octets expected");
+
+namespace HPack
+{
+
+BitOStream::BitOStream(std::vector<uchar> &b)
+ : buffer(b),
+ // All data 'packed' before:
+ bitsSet(8 * quint64(b.size()))
+{
+}
+
+void BitOStream::writeBits(uchar bits, quint8 bitLength)
+{
+ Q_ASSERT(bitLength <= 8);
+
+ quint8 count = bitsSet % 8; // bits used in buffer.back(), but 0 means 8
+ bits <<= 8 - bitLength; // at top of byte, lower bits clear
+ if (count) { // we have a part-used byte; fill it some more:
+ buffer.back() |= bits >> count;
+ count = 8 - count;
+ } // count bits have been consumed (and 0 now means 0)
+ if (bitLength > count)
+ buffer.push_back(bits << count);
+
+ bitsSet += bitLength;
+}
+
+void BitOStream::write(quint32 src)
+{
+ const quint8 prefixLen = 8 - bitsSet % 8;
+ const quint32 fullPrefix = (1 << prefixLen) - 1;
+
+ // https://http2.github.io/http2-spec/compression.html#low-level.representation,
+ // 5.1
+ if (src < fullPrefix) {
+ writeBits(uchar(src), prefixLen);
+ } else {
+ writeBits(uchar(fullPrefix), prefixLen);
+ // We're on the byte boundary now,
+ // so we can just 'push_back'.
+ Q_ASSERT(!(bitsSet % 8));
+ src -= fullPrefix;
+ while (src >= 128) {
+ buffer.push_back(uchar(src % 128 + 128));
+ src /= 128;
+ bitsSet += 8;
+ }
+ buffer.push_back(src);
+ bitsSet += 8;
+ }
+}
+
+void BitOStream::write(const QByteArray &src, bool compressed)
+{
+ quint32 byteLen = src.size();
+ if (compressed && byteLen) {
+ const auto bitLen = huffman_encoded_bit_length(src);
+ Q_ASSERT(bitLen && std::numeric_limits<quint32>::max() >= (bitLen + 7) / 8);
+ byteLen = (bitLen + 7) / 8;
+ writeBits(uchar(1), 1); // bit set - compressed
+ } else {
+ writeBits(uchar(0), 1); // no compression.
+ }
+
+ write(byteLen);
+
+ if (compressed) {
+ huffman_encode_string(src, *this);
+ } else {
+ bitsSet += quint64(src.size()) * 8;
+ buffer.insert(buffer.end(), src.begin(), src.end());
+ }
+}
+
+quint64 BitOStream::bitLength() const
+{
+ return bitsSet;
+}
+
+quint64 BitOStream::byteLength() const
+{
+ return buffer.size();
+}
+
+const uchar *BitOStream::begin() const
+{
+ return &buffer[0];
+}
+
+const uchar *BitOStream::end() const
+{
+ return &buffer[0] + buffer.size();
+}
+
+void BitOStream::clear()
+{
+ buffer.clear();
+ bitsSet = 0;
+}
+
+BitIStream::BitIStream()
+ : first(),
+ last(),
+ offset(),
+ streamError(Error::NoError)
+{
+}
+
+BitIStream::BitIStream(const uchar *begin, const uchar *end)
+ : first(begin),
+ last(end),
+ offset(),
+ streamError(Error::NoError)
+{
+}
+
+quint64 BitIStream::bitLength() const
+{
+ return quint64(last - first) * 8;
+}
+
+bool BitIStream::hasMoreBits() const
+{
+ return offset < bitLength();
+}
+
+bool BitIStream::skipBits(quint64 nBits)
+{
+ if (nBits > bitLength() || bitLength() - nBits < offset)
+ return false;
+
+ offset += nBits;
+ return true;
+}
+
+bool BitIStream::rewindOffset(quint64 nBits)
+{
+ if (nBits > offset)
+ return false;
+
+ offset -= nBits;
+ return true;
+}
+
+bool BitIStream::read(quint32 *dstPtr)
+{
+ Q_ASSERT(dstPtr);
+ quint32 &dst = *dstPtr;
+
+ // 5.1 Integer Representation
+ //
+ // Integers are used to represent name indexes, header field indexes, or string lengths.
+ // An integer representation can start anywhere within an octet.
+ // To allow for optimized processing, an integer representation always finishes at the end of an octet.
+ // An integer is represented in two parts: a prefix that fills the current octet and an optional
+ // list of octets that are used if the integer value does not fit within the prefix.
+ // The number of bits of the prefix (called N) is a parameter of the integer representation.
+ // If the integer value is small enough, i.e., strictly less than 2N-1, it is compressed within the N-bit prefix.
+ // ...
+ // The prefix size, N, is always between 1 and 8 bits. An integer
+ // starting at an octet boundary will have an 8-bit prefix.
+
+ // Technically, such integers can be of any size, but as we do not have arbitrary-long integers,
+ // everything that does not fit into 'dst' we consider as an error (after all, try to allocate a string
+ // of such size and ... hehehe - send it as a part of a header!
+
+ // This function updates the offset _only_ if the read was successful.
+ if (offset >= bitLength()) {
+ setError(Error::NotEnoughData);
+ return false;
+ }
+
+ setError(Error::NoError);
+
+ const quint32 prefixLen = 8 - offset % 8;
+ const quint32 fullPrefix = (1 << prefixLen) - 1;
+
+ const uchar prefix = uchar(first[offset / 8] & fullPrefix);
+ if (prefix < fullPrefix) {
+ // The number fitted into the prefix bits.
+ dst = prefix;
+ offset += prefixLen;
+ return true;
+ }
+
+ quint32 newOffset = offset + prefixLen;
+ // We have a list of bytes representing an integer ...
+ quint64 val = prefix;
+ quint32 octetPower = 0;
+
+ while (true) {
+ if (newOffset >= bitLength()) {
+ setError(Error::NotEnoughData);
+ return false;
+ }
+
+ const uchar octet = first[newOffset / 8];
+
+ if (octetPower == 28 && octet > 15) {
+ qCritical("integer is too big");
+ setError(Error::InvalidInteger);
+ return false;
+ }
+
+ val += quint32(octet & 0x7f) << octetPower;
+ newOffset += 8;
+
+ if (!(octet & 0x80)) {
+ // The most significant bit of each octet is used
+ // as a continuation flag: its value is set to 1
+ // except for the last octet in the list.
+ break;
+ }
+
+ octetPower += 7;
+ }
+
+ dst = val;
+ offset = newOffset;
+ Q_ASSERT(!(offset % 8));
+
+ return true;
+}
+
+bool BitIStream::read(QByteArray *dstPtr)
+{
+ Q_ASSERT(dstPtr);
+ QByteArray &dst = *dstPtr;
+ //5.2 String Literal Representation
+ //
+ // Header field names and header field values can be represented as string literals.
+ // A string literal is compressed as a sequence of octets, either by directly encoding
+ // the string literal's octets or by using a Huffman code.
+
+ // We update the offset _only_ if the read was successful.
+
+ const quint64 oldOffset = offset;
+ uchar compressed = 0;
+ if (peekBits(offset, 1, &compressed) != 1 || !skipBits(1)) {
+ setError(Error::NotEnoughData);
+ return false;
+ }
+
+ setError(Error::NoError);
+
+ quint32 len = 0;
+ if (read(&len)) {
+ Q_ASSERT(!(offset % 8));
+ if (len <= (bitLength() - offset) / 8) { // We have enough data to read a string ...
+ if (!compressed) {
+ // Now good news, integer always ends on a byte boundary.
+ // We can read 'len' bytes without any bit magic.
+ const char *src = reinterpret_cast<const char *>(first + offset / 8);
+ dst = QByteArray(src, len);
+ offset += quint64(len) * 8;
+ return true;
+ }
+
+ BitIStream slice(first + offset / 8, first + offset / 8 + len);
+ if (huffman_decode_string(slice, &dst)) {
+ offset += quint64(len) * 8;
+ return true;
+ }
+
+ setError(Error::CompressionError);
+ } else {
+ setError(Error::NotEnoughData);
+ }
+ } // else the exact reason was set by read(quint32).
+
+ offset = oldOffset;
+ return false;
+}
+
+BitIStream::Error BitIStream::error() const
+{
+ return streamError;
+}
+
+void BitIStream::setError(Error newState)
+{
+ streamError = newState;
+}
+
+} // namespace HPack
+
+QT_END_NAMESPACE
diff --git a/src/network/access/http2/bitstreams_p.h b/src/network/access/http2/bitstreams_p.h
new file mode 100644
index 0000000000..9eba319dc2
--- /dev/null
+++ b/src/network/access/http2/bitstreams_p.h
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BITSTREAMS_P_H
+#define BITSTREAMS_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qdebug.h>
+
+#include <type_traits>
+#include <algorithm>
+#include <vector>
+
+QT_BEGIN_NAMESPACE
+
+class QByteArray;
+
+namespace HPack
+{
+
+// BitOStream works with an external buffer,
+// for example, HEADERS frame.
+class Q_AUTOTEST_EXPORT BitOStream
+{
+public:
+ BitOStream(std::vector<uchar> &buffer);
+
+ // Write 'bitLength' bits from the least significant
+ // bits in 'bits' to bitstream:
+ void writeBits(uchar bits, quint8 bitLength);
+ // HPACK data format, we support:
+ // * 32-bit integers
+ // * strings
+ void write(quint32 src);
+ void write(const QByteArray &src, bool compressed);
+
+ quint64 bitLength() const;
+ quint64 byteLength() const;
+ const uchar *begin() const;
+ const uchar *end() const;
+
+ void clear();
+
+private:
+ Q_DISABLE_COPY(BitOStream);
+
+ std::vector<uchar> &buffer;
+ quint64 bitsSet;
+};
+
+class Q_AUTOTEST_EXPORT BitIStream
+{
+public:
+ // Error is set by 'read' functions.
+ // 'peek' does not set the error,
+ // since it just peeks some bits
+ // without the notion of wrong/right.
+ // 'read' functions only change 'streamOffset'
+ // on success.
+ enum class Error
+ {
+ NoError,
+ NotEnoughData,
+ CompressionError,
+ InvalidInteger
+ };
+
+ BitIStream();
+ BitIStream(const uchar *f, const uchar *l);
+
+ quint64 bitLength() const;
+ bool hasMoreBits() const;
+
+ // peekBits tries to read 'length' bits from the bitstream into
+ // 'dst' ('length' must be <= sizeof(dst) * 8), packing them
+ // starting from the most significant bit of the most significant
+ // byte. It's a template so that we can use it with different
+ // integer types. Returns the number of bits actually read.
+ // Does not change stream's offset.
+
+ template<class T>
+ quint64 peekBits(quint64 from, quint64 length, T *dstPtr) const
+ {
+ static_assert(std::is_unsigned<T>::value, "peekBits: unsigned integer type expected");
+
+ Q_ASSERT(dstPtr);
+ Q_ASSERT(length <= sizeof(T) * 8);
+
+ if (from >= bitLength() || !length)
+ return 0;
+
+ T &dst = *dstPtr;
+ dst = T();
+ length = std::min(length, bitLength() - from);
+
+ const uchar *srcByte = first + from / 8;
+ auto bitsToRead = length + from % 8;
+
+ while (bitsToRead > 8) {
+ dst = (dst << 8) | *srcByte;
+ bitsToRead -= 8;
+ ++srcByte;
+ }
+
+ dst <<= bitsToRead;
+ dst |= *srcByte >> (8 - bitsToRead);
+ dst <<= sizeof(T) * 8 - length;
+
+ return length;
+ }
+
+ quint64 streamOffset() const
+ {
+ return offset;
+ }
+
+ bool skipBits(quint64 nBits);
+ bool rewindOffset(quint64 nBits);
+
+ bool read(quint32 *dstPtr);
+ bool read(QByteArray *dstPtr);
+
+ Error error() const;
+
+private:
+ void setError(Error newState);
+
+ const uchar *first;
+ const uchar *last;
+ quint64 offset;
+ Error streamError;
+};
+
+} // namespace HPack
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/network/access/http2/hpack.cpp b/src/network/access/http2/hpack.cpp
new file mode 100644
index 0000000000..95e6f9051b
--- /dev/null
+++ b/src/network/access/http2/hpack.cpp
@@ -0,0 +1,551 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "bitstreams_p.h"
+#include "hpack_p.h"
+
+#include <QtCore/qbytearray.h>
+#include <QtCore/qdebug.h>
+
+#include <limits>
+
+QT_BEGIN_NAMESPACE
+
+namespace HPack
+{
+
+HeaderSize header_size(const HttpHeader &header)
+{
+ HeaderSize size(true, 0);
+ for (const HeaderField &field : header) {
+ HeaderSize delta = entry_size(field);
+ if (!delta.first)
+ return HeaderSize();
+ if (std::numeric_limits<quint32>::max() - size.second < delta.second)
+ return HeaderSize();
+ size.second += delta.second;
+ }
+
+ return size;
+}
+
+struct BitPattern
+{
+ BitPattern()
+ : value(),
+ bitLength()
+ {
+ }
+
+ BitPattern(uchar v, uchar len)
+ : value(v),
+ bitLength(len)
+ {
+ }
+
+ uchar value;
+ uchar bitLength;
+};
+
+bool operator == (const BitPattern &lhs, const BitPattern &rhs)
+{
+ return lhs.bitLength == rhs.bitLength && lhs.value == rhs.value;
+}
+
+namespace
+{
+
+using StreamError = BitIStream::Error;
+
+// There are several bit patterns to distinguish header fields:
+// 1 - indexed
+// 01 - literal with incremented indexing
+// 0000 - literal without indexing
+// 0001 - literal, never indexing
+// 001 - dynamic table size update.
+
+// It's always 1 or 0 actually, but the number of bits to extract
+// from the input stream - differs.
+const BitPattern Indexed(1, 1);
+const BitPattern LiteralIncrementalIndexing(1, 2);
+const BitPattern LiteralNoIndexing(0, 4);
+const BitPattern LiteralNeverIndexing(1, 4);
+const BitPattern SizeUpdate(1, 3);
+
+bool is_literal_field(const BitPattern &pattern)
+{
+ return pattern == LiteralIncrementalIndexing
+ || pattern == LiteralNoIndexing
+ || pattern == LiteralNeverIndexing;
+}
+
+void write_bit_pattern(const BitPattern &pattern, BitOStream &outputStream)
+{
+ outputStream.writeBits(pattern.value, pattern.bitLength);
+}
+
+bool read_bit_pattern(const BitPattern &pattern, BitIStream &inputStream)
+{
+ uchar chunk = 0;
+
+ const quint32 bitsRead = inputStream.peekBits(inputStream.streamOffset(),
+ pattern.bitLength, &chunk);
+ if (bitsRead != pattern.bitLength)
+ return false;
+
+ // Since peekBits packs in the most significant bits, shift it!
+ chunk >>= (8 - bitsRead);
+ if (chunk != pattern.value)
+ return false;
+
+ inputStream.skipBits(pattern.bitLength);
+
+ return true;
+}
+
+bool is_request_pseudo_header(const QByteArray &name)
+{
+ return name == ":method" || name == ":scheme" ||
+ name == ":authority" || name == ":path";
+}
+
+} // unnamed namespace
+
+Encoder::Encoder(quint32 size, bool compress)
+ : lookupTable(size, true /*encoder needs search index*/),
+ compressStrings(compress)
+{
+}
+
+quint32 Encoder::dynamicTableSize() const
+{
+ return lookupTable.dynamicDataSize();
+}
+
+bool Encoder::encodeRequest(BitOStream &outputStream, const HttpHeader &header)
+{
+ if (!header.size()) {
+ qDebug("empty header");
+ return false;
+ }
+
+ if (!encodeRequestPseudoHeaders(outputStream, header))
+ return false;
+
+ for (const auto &field : header) {
+ if (is_request_pseudo_header(field.name))
+ continue;
+
+ if (!encodeHeaderField(outputStream, field))
+ return false;
+ }
+
+ return true;
+}
+
+bool Encoder::encodeResponse(BitOStream &outputStream, const HttpHeader &header)
+{
+ if (!header.size()) {
+ qDebug("empty header");
+ return false;
+ }
+
+ if (!encodeResponsePseudoHeaders(outputStream, header))
+ return false;
+
+ for (const auto &field : header) {
+ if (field.name == ":status")
+ continue;
+
+ if (!encodeHeaderField(outputStream, field))
+ return false;
+ }
+
+ return true;
+}
+
+bool Encoder::encodeSizeUpdate(BitOStream &outputStream, quint32 newSize)
+{
+ if (!lookupTable.updateDynamicTableSize(newSize)) {
+ qDebug("failed to update own table size");
+ return false;
+ }
+
+ write_bit_pattern(SizeUpdate, outputStream);
+ outputStream.write(newSize);
+
+ return true;
+}
+
+void Encoder::setMaxDynamicTableSize(quint32 size)
+{
+ // Up to a caller (HTTP2 protocol handler)
+ // to validate this size first.
+ lookupTable.setMaxDynamicTableSize(size);
+}
+
+bool Encoder::encodeRequestPseudoHeaders(BitOStream &outputStream,
+ const HttpHeader &header)
+{
+ // The following pseudo-header fields are defined for HTTP/2 requests:
+ // - The :method pseudo-header field includes the HTTP method
+ // - The :scheme pseudo-header field includes the scheme portion of the target URI
+ // - The :authority pseudo-header field includes the authority portion of the target URI
+ // - The :path pseudo-header field includes the path and query parts of the target URI
+
+ // All HTTP/2 requests MUST include exactly one valid value for the :method,
+ // :scheme, and :path pseudo-header fields, unless it is a CONNECT request
+ // (Section 8.3). An HTTP request that omits mandatory pseudo-header fields
+ // is malformed (Section 8.1.2.6).
+
+ using size_type = decltype(header.size());
+
+ bool methodFound = false;
+ const char *headerName[] = {":authority", ":scheme", ":path"};
+ const size_type nHeaders = sizeof headerName / sizeof headerName[0];
+ bool headerFound[nHeaders] = {};
+
+ for (const auto &field : header) {
+ if (field.name == ":status") {
+ qCritical("invalid pseudo-header (:status) in a request");
+ return false;
+ }
+
+ if (field.name == ":method") {
+ if (methodFound) {
+ qCritical("only one :method pseudo-header is allowed");
+ return false;
+ }
+
+ if (!encodeMethod(outputStream, field))
+ return false;
+ methodFound = true;
+ } else if (field.name == "cookie") {
+ // "crumbs" ...
+ } else {
+ for (size_type j = 0; j < nHeaders; ++j) {
+ if (field.name == headerName[j]) {
+ if (headerFound[j]) {
+ qCritical() << "only one" << headerName[j] << "pseudo-header is allowed";
+ return false;
+ }
+ if (!encodeHeaderField(outputStream, field))
+ return false;
+ headerFound[j] = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if (!methodFound) {
+ qCritical("mandatory :method pseudo-header not found");
+ return false;
+ }
+
+ // 1: don't demand headerFound[0], as :authority isn't mandatory.
+ for (size_type i = 1; i < nHeaders; ++i) {
+ if (!headerFound[i]) {
+ qCritical() << "mandatory" << headerName[i]
+ << "pseudo-header not found";
+ return false;
+ }
+ }
+
+ return true;
+}
+
+bool Encoder::encodeHeaderField(BitOStream &outputStream, const HeaderField &field)
+{
+ // TODO: at the moment we never use LiteralNo/Never Indexing ...
+
+ // Here we try:
+ // 1. indexed
+ // 2. literal indexed with indexed name/literal value
+ // 3. literal indexed with literal name/literal value
+ if (const auto index = lookupTable.indexOf(field.name, field.value))
+ return encodeIndexedField(outputStream, index);
+
+ if (const auto index = lookupTable.indexOf(field.name)) {
+ return encodeLiteralField(outputStream, LiteralIncrementalIndexing,
+ index, field.value, compressStrings);
+ }
+
+ return encodeLiteralField(outputStream, LiteralIncrementalIndexing,
+ field.name, field.value, compressStrings);
+}
+
+bool Encoder::encodeMethod(BitOStream &outputStream, const HeaderField &field)
+{
+ Q_ASSERT(field.name == ":method");
+ quint32 index = lookupTable.indexOf(field.name, field.value);
+ if (index)
+ return encodeIndexedField(outputStream, index);
+
+ index = lookupTable.indexOf(field.name);
+ Q_ASSERT(index); // ":method" is always in the static table ...
+ return encodeLiteralField(outputStream, LiteralIncrementalIndexing,
+ index, field.value, compressStrings);
+}
+
+bool Encoder::encodeResponsePseudoHeaders(BitOStream &outputStream, const HttpHeader &header)
+{
+ bool statusFound = false;
+ for (const auto &field : header) {
+ if (is_request_pseudo_header(field.name)) {
+ qCritical() << "invalid pseudo-header" << field.name << "in http response";
+ return false;
+ }
+
+ if (field.name == ":status") {
+ if (statusFound) {
+ qDebug("only one :status pseudo-header is allowed");
+ return false;
+ }
+ if (!encodeHeaderField(outputStream, field))
+ return false;
+ statusFound = true;
+ } else if (field.name == "cookie") {
+ // "crumbs"..
+ }
+ }
+
+ if (!statusFound)
+ qCritical("mandatory :status pseudo-header not found");
+
+ return statusFound;
+}
+
+bool Encoder::encodeIndexedField(BitOStream &outputStream, quint32 index) const
+{
+ Q_ASSERT(lookupTable.indexIsValid(index));
+
+ write_bit_pattern(Indexed, outputStream);
+ outputStream.write(index);
+
+ return true;
+}
+
+bool Encoder::encodeLiteralField(BitOStream &outputStream, const BitPattern &fieldType,
+ const QByteArray &name, const QByteArray &value,
+ bool withCompression)
+{
+ Q_ASSERT(is_literal_field(fieldType));
+ // According to HPACK, the bit pattern is
+ // 01 | 000000 (integer 0 that fits into 6-bit prefix),
+ // since integers always end on byte boundary,
+ // this also implies that we always start at bit offset == 0.
+ if (outputStream.bitLength() % 8) {
+ qCritical("invalid bit offset");
+ return false;
+ }
+
+ if (fieldType == LiteralIncrementalIndexing) {
+ if (!lookupTable.prependField(name, value))
+ qDebug("failed to prepend a new field");
+ }
+
+ write_bit_pattern(fieldType, outputStream);
+
+ outputStream.write(0);
+ outputStream.write(name, withCompression);
+ outputStream.write(value, withCompression);
+
+ return true;
+}
+
+bool Encoder::encodeLiteralField(BitOStream &outputStream, const BitPattern &fieldType,
+ quint32 nameIndex, const QByteArray &value,
+ bool withCompression)
+{
+ Q_ASSERT(is_literal_field(fieldType));
+
+ QByteArray name;
+ const bool found = lookupTable.fieldName(nameIndex, &name);
+ Q_UNUSED(found) Q_ASSERT(found);
+
+ if (fieldType == LiteralIncrementalIndexing) {
+ if (!lookupTable.prependField(name, value))
+ qDebug("failed to prepend a new field");
+ }
+
+ write_bit_pattern(fieldType, outputStream);
+ outputStream.write(nameIndex);
+ outputStream.write(value, withCompression);
+
+ return true;
+}
+
+Decoder::Decoder(quint32 size)
+ : lookupTable{size, false /* we do not need search index ... */}
+{
+}
+
+bool Decoder::decodeHeaderFields(BitIStream &inputStream)
+{
+ header.clear();
+ while (true) {
+ if (read_bit_pattern(Indexed, inputStream)) {
+ if (!decodeIndexedField(inputStream))
+ return false;
+ } else if (read_bit_pattern(LiteralIncrementalIndexing, inputStream)) {
+ if (!decodeLiteralField(LiteralIncrementalIndexing, inputStream))
+ return false;
+ } else if (read_bit_pattern(LiteralNoIndexing, inputStream)) {
+ if (!decodeLiteralField(LiteralNoIndexing, inputStream))
+ return false;
+ } else if (read_bit_pattern(LiteralNeverIndexing, inputStream)) {
+ if (!decodeLiteralField(LiteralNeverIndexing, inputStream))
+ return false;
+ } else if (read_bit_pattern(SizeUpdate, inputStream)) {
+ if (!decodeSizeUpdate(inputStream))
+ return false;
+ } else {
+ return inputStream.bitLength() == inputStream.streamOffset();
+ }
+ }
+
+ return false;
+}
+
+quint32 Decoder::dynamicTableSize() const
+{
+ return lookupTable.dynamicDataSize();
+}
+
+void Decoder::setMaxDynamicTableSize(quint32 size)
+{
+ // Up to a caller (HTTP2 protocol handler)
+ // to validate this size first.
+ lookupTable.setMaxDynamicTableSize(size);
+}
+
+bool Decoder::decodeIndexedField(BitIStream &inputStream)
+{
+ quint32 index = 0;
+ if (inputStream.read(&index)) {
+ if (!index) {
+ // "The index value of 0 is not used.
+ // It MUST be treated as a decoding
+ // error if found in an indexed header
+ // field representation."
+ return false;
+ }
+
+ QByteArray name, value;
+ if (lookupTable.field(index, &name, &value))
+ return processDecodedField(Indexed, name, value);
+ } else {
+ handleStreamError(inputStream);
+ }
+
+ return false;
+}
+
+bool Decoder::decodeSizeUpdate(BitIStream &inputStream)
+{
+ // For now, just read and skip bits.
+ quint32 maxSize = 0;
+ if (inputStream.read(&maxSize)) {
+ if (!lookupTable.updateDynamicTableSize(maxSize))
+ return false;
+
+ return true;
+ }
+
+ handleStreamError(inputStream);
+ return false;
+}
+
+bool Decoder::decodeLiteralField(const BitPattern &fieldType, BitIStream &inputStream)
+{
+ // https://http2.github.io/http2-spec/compression.html
+ // 6.2.1, 6.2.2, 6.2.3
+ // Format for all 'literal' is similar,
+ // the difference - is how we update/not our lookup table.
+ quint32 index = 0;
+ if (inputStream.read(&index)) {
+ QByteArray name;
+ if (!index) {
+ // Read a string.
+ if (!inputStream.read(&name)) {
+ handleStreamError(inputStream);
+ return false;
+ }
+ } else {
+ if (!lookupTable.fieldName(index, &name))
+ return false;
+ }
+
+ QByteArray value;
+ if (inputStream.read(&value))
+ return processDecodedField(fieldType, name, value);
+ }
+
+ handleStreamError(inputStream);
+
+ return false;
+}
+
+bool Decoder::processDecodedField(const BitPattern &fieldType,
+ const QByteArray &name,
+ const QByteArray &value)
+{
+ if (fieldType == LiteralIncrementalIndexing) {
+ if (!lookupTable.prependField(name, value))
+ return false;
+ }
+
+ header.push_back(HeaderField(name, value));
+ return true;
+}
+
+void Decoder::handleStreamError(BitIStream &inputStream)
+{
+ const auto errorCode(inputStream.error());
+ if (errorCode == StreamError::NoError)
+ return;
+
+ // For now error handling not needed here,
+ // HTTP2 layer will end with session error/COMPRESSION_ERROR.
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/network/access/http2/hpack_p.h b/src/network/access/http2/hpack_p.h
new file mode 100644
index 0000000000..6a1d30d87b
--- /dev/null
+++ b/src/network/access/http2/hpack_p.h
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HPACK_P_H
+#define HPACK_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "hpacktable_p.h"
+
+#include <QtCore/qglobal.h>
+
+#include <vector>
+
+QT_BEGIN_NAMESPACE
+
+class QByteArray;
+
+namespace HPack
+{
+
+using HttpHeader = std::vector<HeaderField>;
+HeaderSize header_size(const HttpHeader &header);
+
+class Q_AUTOTEST_EXPORT Encoder
+{
+public:
+ Encoder(quint32 maxTableSize, bool compressStrings);
+
+ quint32 dynamicTableSize() const;
+
+ bool encodeRequest(class BitOStream &outputStream,
+ const HttpHeader &header);
+ bool encodeResponse(BitOStream &outputStream,
+ const HttpHeader &header);
+
+ bool encodeSizeUpdate(BitOStream &outputStream,
+ quint32 newSize);
+
+ void setMaxDynamicTableSize(quint32 size);
+
+private:
+ bool encodeRequestPseudoHeaders(BitOStream &outputStream,
+ const HttpHeader &header);
+ bool encodeHeaderField(BitOStream &outputStream,
+ const HeaderField &field);
+ bool encodeMethod(BitOStream &outputStream,
+ const HeaderField &field);
+
+ bool encodeResponsePseudoHeaders(BitOStream &outputStream,
+ const HttpHeader &header);
+
+ bool encodeIndexedField(BitOStream &outputStream, quint32 index) const;
+
+
+ bool encodeLiteralField(BitOStream &outputStream,
+ const struct BitPattern &fieldType,
+ quint32 nameIndex,
+ const QByteArray &value,
+ bool withCompression);
+
+ bool encodeLiteralField(BitOStream &outputStream,
+ const BitPattern &fieldType,
+ const QByteArray &name,
+ const QByteArray &value,
+ bool withCompression);
+
+ FieldLookupTable lookupTable;
+ bool compressStrings;
+};
+
+class Q_AUTOTEST_EXPORT Decoder
+{
+public:
+ Decoder(quint32 maxTableSize);
+
+ bool decodeHeaderFields(class BitIStream &inputStream);
+
+ const HttpHeader &decodedHeader() const
+ {
+ return header;
+ }
+
+ quint32 dynamicTableSize() const;
+
+ void setMaxDynamicTableSize(quint32 size);
+
+private:
+
+ bool decodeIndexedField(BitIStream &inputStream);
+ bool decodeSizeUpdate(BitIStream &inputStream);
+ bool decodeLiteralField(const BitPattern &fieldType,
+ BitIStream &inputStream);
+
+ bool processDecodedField(const BitPattern &fieldType,
+ const QByteArray &name,
+ const QByteArray &value);
+
+ void handleStreamError(BitIStream &inputStream);
+
+ HttpHeader header;
+ FieldLookupTable lookupTable;
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif
+
diff --git a/src/network/access/http2/hpacktable.cpp b/src/network/access/http2/hpacktable.cpp
new file mode 100644
index 0000000000..db9574e2bc
--- /dev/null
+++ b/src/network/access/http2/hpacktable.cpp
@@ -0,0 +1,533 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "hpacktable_p.h"
+
+#include <QtCore/qdebug.h>
+
+#include <algorithm>
+#include <cstring>
+#include <limits>
+
+
+QT_BEGIN_NAMESPACE
+
+namespace HPack
+{
+
+HeaderSize entry_size(const QByteArray &name, const QByteArray &value)
+{
+ // 32 comes from HPACK:
+ // "4.1 Calculating Table Size
+ // Note: The additional 32 octets account for an estimated overhead associated
+ // with an entry. For example, an entry structure using two 64-bit pointers
+ // to reference the name and the value of the entry and two 64-bit integers
+ // for counting the number of references to the name and value would have
+ // 32 octets of overhead."
+
+ const unsigned sum = unsigned(name.size()) + value.size();
+ if (std::numeric_limits<unsigned>::max() - 32 < sum)
+ return HeaderSize();
+ if (sum + 32 > std::numeric_limits<quint32>::max())
+ return HeaderSize();
+ return HeaderSize(true, quint32(sum + 32));
+}
+
+namespace
+{
+
+int compare(const QByteArray &lhs, const QByteArray &rhs)
+{
+ if (const int minLen = std::min(lhs.size(), rhs.size())) {
+ // We use memcmp, since strings in headers are allowed
+ // to contain '\0'.
+ const int cmp = std::memcmp(lhs.constData(), rhs.constData(), minLen);
+ if (cmp)
+ return cmp;
+ }
+
+ return lhs.size() - rhs.size();
+}
+
+} // unnamed namespace
+
+FieldLookupTable::SearchEntry::SearchEntry()
+ : field(),
+ chunk(),
+ offset(),
+ table()
+{
+}
+
+FieldLookupTable::SearchEntry::SearchEntry(const HeaderField *f,
+ const Chunk *c,
+ quint32 o,
+ const FieldLookupTable *t)
+ : field(f),
+ chunk(c),
+ offset(o),
+ table(t)
+{
+ Q_ASSERT(field);
+}
+
+bool FieldLookupTable::SearchEntry::operator < (const SearchEntry &rhs)const
+{
+ Q_ASSERT(field);
+ Q_ASSERT(rhs.field);
+
+ int cmp = compare(field->name, rhs.field->name);
+ if (cmp)
+ return cmp < 0;
+
+ cmp = compare(field->value, rhs.field->value);
+ if (cmp)
+ return cmp < 0;
+
+ if (!chunk) // 'this' is not in the searchIndex.
+ return rhs.chunk;
+
+ if (!rhs.chunk) // not in the searchIndex.
+ return false;
+
+ Q_ASSERT(table);
+ Q_ASSERT(rhs.table == table);
+
+ const quint32 leftChunkIndex = table->indexOfChunk(chunk);
+ const quint32 rightChunkIndex = rhs.table->indexOfChunk(rhs.chunk);
+
+ // Later added - smaller is chunk index (since we push_front).
+ if (leftChunkIndex != rightChunkIndex)
+ return leftChunkIndex > rightChunkIndex;
+
+ // Later added - smaller is offset.
+ return offset > rhs.offset;
+}
+
+// This data is from HPACK's specs and it's quite
+// conveniently sorted == works with binary search as it is.
+// Later this can probably change and instead of simple
+// vector we'll just reuse FieldLookupTable.
+// TODO: it makes sense to generate this table while ...
+// configuring/building Qt (some script downloading/parsing/generating
+// would be quite handy).
+const std::vector<HeaderField> &staticTable()
+{
+ static std::vector<HeaderField> table = {
+ {":authority", ""},
+ {":method", "GET"},
+ {":method", "POST"},
+ {":path", "/"},
+ {":path", "/index.html"},
+ {":scheme", "http"},
+ {":scheme", "https"},
+ {":status", "200"},
+ {":status", "204"},
+ {":status", "206"},
+ {":status", "304"},
+ {":status", "400"},
+ {":status", "404"},
+ {":status", "500"},
+ {"accept-charset", ""},
+ {"accept-encoding", "gzip, deflate"},
+ {"accept-language", ""},
+ {"accept-ranges", ""},
+ {"accept", ""},
+ {"access-control-allow-origin", ""},
+ {"age", ""},
+ {"allow", ""},
+ {"authorization", ""},
+ {"cache-control", ""},
+ {"content-disposition", ""},
+ {"content-encoding", ""},
+ {"content-language", ""},
+ {"content-length", ""},
+ {"content-location", ""},
+ {"content-range", ""},
+ {"content-type", ""},
+ {"cookie", ""},
+ {"date", ""},
+ {"etag", ""},
+ {"expect", ""},
+ {"expires", ""},
+ {"from", ""},
+ {"host", ""},
+ {"if-match", ""},
+ {"if-modified-since", ""},
+ {"if-none-match", ""},
+ {"if-range", ""},
+ {"if-unmodified-since", ""},
+ {"last-modified", ""},
+ {"link", ""},
+ {"location", ""},
+ {"max-forwards", ""},
+ {"proxy-authenticate", ""},
+ {"proxy-authorization", ""},
+ {"range", ""},
+ {"referer", ""},
+ {"refresh", ""},
+ {"retry-after", ""},
+ {"server", ""},
+ {"set-cookie", ""},
+ {"strict-transport-security", ""},
+ {"transfer-encoding", ""},
+ {"user-agent", ""},
+ {"vary", ""},
+ {"via", ""},
+ {"www-authenticate", ""}
+ };
+
+ return table;
+}
+
+FieldLookupTable::FieldLookupTable(quint32 maxSize, bool use)
+ : maxTableSize(maxSize),
+ tableCapacity(maxSize),
+ useIndex(use),
+ nDynamic(),
+ begin(),
+ end(),
+ dataSize()
+{
+}
+
+
+bool FieldLookupTable::prependField(const QByteArray &name, const QByteArray &value)
+{
+ const auto entrySize = entry_size(name, value);
+ if (!entrySize.first)
+ return false;
+
+ if (entrySize.second > tableCapacity) {
+ clearDynamicTable();
+ return true;
+ }
+
+ while (nDynamic && tableCapacity - dataSize < entrySize.second)
+ evictEntry();
+
+ if (!begin) {
+ // Either no more space or empty table ...
+ chunks.push_front(ChunkPtr(new Chunk(ChunkSize)));
+ end += ChunkSize;
+ begin = ChunkSize;
+ }
+
+ --begin;
+
+ dataSize += entrySize.second;
+ ++nDynamic;
+
+ auto &newField = front();
+ newField.name = name;
+ newField.value = value;
+
+ if (useIndex) {
+ const auto result = searchIndex.insert(frontKey());
+ Q_UNUSED(result) Q_ASSERT(result.second);
+ }
+
+ return true;
+}
+
+void FieldLookupTable::evictEntry()
+{
+ if (!nDynamic)
+ return;
+
+ Q_ASSERT(end != begin);
+
+ if (useIndex) {
+ const auto res = searchIndex.erase(backKey());
+ Q_UNUSED(res) Q_ASSERT(res == 1);
+ }
+
+ const HeaderField &field = back();
+ const auto entrySize = entry_size(field);
+ Q_ASSERT(entrySize.first);
+ Q_ASSERT(dataSize >= entrySize.second);
+ dataSize -= entrySize.second;
+
+ --nDynamic;
+ --end;
+
+ if (end == begin) {
+ Q_ASSERT(chunks.size() == 1);
+ end = ChunkSize;
+ begin = end;
+ } else if (!(end % ChunkSize)) {
+ chunks.pop_back();
+ }
+}
+
+quint32 FieldLookupTable::numberOfEntries() const
+{
+ return quint32(staticTable().size()) + nDynamic;
+}
+
+quint32 FieldLookupTable::numberOfStaticEntries() const
+{
+ return quint32(staticTable().size());
+}
+
+quint32 FieldLookupTable::numberOfDynamicEntries() const
+{
+ return nDynamic;
+}
+
+quint32 FieldLookupTable::dynamicDataSize() const
+{
+ return dataSize;
+}
+
+void FieldLookupTable::clearDynamicTable()
+{
+ searchIndex.clear();
+ chunks.clear();
+ begin = 0;
+ end = 0;
+ nDynamic = 0;
+ dataSize = 0;
+}
+
+bool FieldLookupTable::indexIsValid(quint32 index) const
+{
+ return index && index <= staticTable().size() + nDynamic;
+}
+
+quint32 FieldLookupTable::indexOf(const QByteArray &name, const QByteArray &value)const
+{
+ // Start from the static part first:
+ const auto &table = staticTable();
+ const HeaderField field(name, value);
+ const auto staticPos = std::lower_bound(table.begin(), table.end(), field,
+ [](const HeaderField &lhs, const HeaderField &rhs) {
+ int cmp = compare(lhs.name, rhs.name);
+ if (cmp)
+ return cmp < 0;
+ return compare(lhs.value, rhs.value) < 0;
+ });
+ if (staticPos != table.end()) {
+ if (staticPos->name == name && staticPos->value == value)
+ return staticPos - table.begin() + 1;
+ }
+
+ // Now we have to lookup in our dynamic part ...
+ if (!useIndex) {
+ qCritical("lookup in dynamic table requires search index enabled");
+ return 0;
+ }
+
+ const SearchEntry key(&field, nullptr, 0, this);
+ const auto pos = searchIndex.lower_bound(key);
+ if (pos != searchIndex.end()) {
+ const HeaderField &found = *pos->field;
+ if (found.name == name && found.value == value)
+ return keyToIndex(*pos);
+ }
+
+ return 0;
+}
+
+quint32 FieldLookupTable::indexOf(const QByteArray &name) const
+{
+ // Start from the static part first:
+ const auto &table = staticTable();
+ const HeaderField field(name, QByteArray());
+ const auto staticPos = std::lower_bound(table.begin(), table.end(), field,
+ [](const HeaderField &lhs, const HeaderField &rhs) {
+ return compare(lhs.name, rhs.name) < 0;
+ });
+ if (staticPos != table.end()) {
+ if (staticPos->name == name)
+ return staticPos - table.begin() + 1;
+ }
+
+ // Now we have to lookup in our dynamic part ...
+ if (!useIndex) {
+ qCritical("lookup in dynamic table requires search index enabled");
+ return 0;
+ }
+
+ const SearchEntry key(&field, nullptr, 0, this);
+ const auto pos = searchIndex.lower_bound(key);
+ if (pos != searchIndex.end()) {
+ const HeaderField &found = *pos->field;
+ if (found.name == name)
+ return keyToIndex(*pos);
+ }
+
+ return 0;
+}
+
+bool FieldLookupTable::field(quint32 index, QByteArray *name, QByteArray *value) const
+{
+ Q_ASSERT(name);
+ Q_ASSERT(value);
+
+ if (!indexIsValid(index))
+ return false;
+
+ const auto &table = staticTable();
+ if (index - 1 < table.size()) {
+ *name = table[index - 1].name;
+ *value = table[index - 1].value;
+ return true;
+ }
+
+ index = index - 1 - quint32(table.size()) + begin;
+ const auto chunkIndex = index / ChunkSize;
+ Q_ASSERT(chunkIndex < chunks.size());
+ const auto offset = index % ChunkSize;
+ const HeaderField &found = (*chunks[chunkIndex])[offset];
+ *name = found.name;
+ *value = found.value;
+
+ return true;
+}
+
+bool FieldLookupTable::fieldName(quint32 index, QByteArray *dst) const
+{
+ Q_ASSERT(dst);
+ return field(index, dst, &dummyDst);
+}
+
+bool FieldLookupTable::fieldValue(quint32 index, QByteArray *dst) const
+{
+ Q_ASSERT(dst);
+ return field(index, &dummyDst, dst);
+}
+
+const HeaderField &FieldLookupTable::front() const
+{
+ Q_ASSERT(nDynamic && begin != end && chunks.size());
+ return (*chunks[0])[begin];
+}
+
+HeaderField &FieldLookupTable::front()
+{
+ Q_ASSERT(nDynamic && begin != end && chunks.size());
+ return (*chunks[0])[begin];
+}
+
+const HeaderField &FieldLookupTable::back() const
+{
+ Q_ASSERT(nDynamic && end && end != begin);
+
+ const quint32 absIndex = end - 1;
+ const quint32 chunkIndex = absIndex / ChunkSize;
+ Q_ASSERT(chunkIndex < chunks.size());
+ const quint32 offset = absIndex % ChunkSize;
+ return (*chunks[chunkIndex])[offset];
+}
+
+quint32 FieldLookupTable::indexOfChunk(const Chunk *chunk) const
+{
+ Q_ASSERT(chunk);
+
+ for (size_type i = 0; i < chunks.size(); ++i) {
+ if (chunks[i].get() == chunk)
+ return quint32(i);
+ }
+
+ Q_UNREACHABLE();
+ return 0;
+}
+
+quint32 FieldLookupTable::keyToIndex(const SearchEntry &key) const
+{
+ Q_ASSERT(key.chunk);
+
+ const auto chunkIndex = indexOfChunk(key.chunk);
+ const auto offset = key.offset;
+ Q_ASSERT(offset < ChunkSize);
+ Q_ASSERT(chunkIndex || offset >= begin);
+
+ return quint32(offset + chunkIndex * ChunkSize - begin + 1 + staticTable().size());
+}
+
+FieldLookupTable::SearchEntry FieldLookupTable::frontKey() const
+{
+ Q_ASSERT(chunks.size() && end != begin);
+ return SearchEntry(&front(), chunks.front().get(), begin, this);
+}
+
+FieldLookupTable::SearchEntry FieldLookupTable::backKey() const
+{
+ Q_ASSERT(chunks.size() && end != begin);
+
+ const HeaderField &field = back();
+ const quint32 absIndex = end - 1;
+ const auto offset = absIndex % ChunkSize;
+ const auto chunk = chunks[absIndex / ChunkSize].get();
+
+ return SearchEntry(&field, chunk, offset, this);
+}
+
+bool FieldLookupTable::updateDynamicTableSize(quint32 size)
+{
+ if (!size) {
+ clearDynamicTable();
+ return true;
+ }
+
+ if (size > maxTableSize)
+ return false;
+
+ tableCapacity = size;
+ while (nDynamic && dataSize > tableCapacity)
+ evictEntry();
+
+ return true;
+}
+
+void FieldLookupTable::setMaxDynamicTableSize(quint32 size)
+{
+ // This is for an external user, for example, HTTP2 protocol
+ // layer that can receive SETTINGS frame from its peer.
+ // No validity checks here, up to this external user.
+ // We update max size and capacity (this can also result in
+ // items evicted or even dynamic table completely cleared).
+ maxTableSize = size;
+ updateDynamicTableSize(size);
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/network/access/http2/hpacktable_p.h b/src/network/access/http2/hpacktable_p.h
new file mode 100644
index 0000000000..aaea89b986
--- /dev/null
+++ b/src/network/access/http2/hpacktable_p.h
@@ -0,0 +1,237 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HPACKTABLE_P_H
+#define HPACKTABLE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qbytearray.h>
+#include <QtCore/qglobal.h>
+#include <QtCore/qpair.h>
+
+#include <vector>
+#include <memory>
+#include <deque>
+#include <set>
+
+QT_BEGIN_NAMESPACE
+
+namespace HPack
+{
+
+struct Q_AUTOTEST_EXPORT HeaderField
+{
+ HeaderField()
+ {
+ }
+
+ HeaderField(const QByteArray &n, const QByteArray &v)
+ : name(n),
+ value(v)
+ {
+ }
+
+ bool operator == (const HeaderField &rhs) const
+ {
+ return name == rhs.name && value == rhs.value;
+ }
+
+ QByteArray name;
+ QByteArray value;
+};
+
+using HeaderSize = QPair<bool, quint32>;
+
+HeaderSize entry_size(const QByteArray &name, const QByteArray &value);
+
+inline HeaderSize entry_size(const HeaderField &entry)
+{
+ return entry_size(entry.name, entry.value);
+}
+
+/*
+ Lookup table consists of two parts (HPACK, 2.3):
+ the immutable static table (pre-defined by HPACK's specs)
+ and dynamic table which is updated while
+ compressing/decompressing headers.
+
+ Table must provide/implement:
+ 1. Fast random access - we read fields' indices from
+ HPACK's bit stream.
+ 2. FIFO for dynamic part - to push new items to the front
+ and evict them from the back (HPACK, 2.3.2).
+ 3. Fast lookup - encoder receives pairs of strings
+ (name|value) and it has to find an index for a pair
+ as the whole or for a name at least (if it's already
+ in either static or dynamic table).
+
+ Static table is an immutable vector.
+
+ Dynamic part is implemented in a way similar to std::deque -
+ it's a vector of pointers to chunks. Each chunk is a vector of
+ (name|value) pairs. Once allocated with a fixed size, chunk
+ never re-allocates its data, so entries' addresses do not change.
+ We add new chunks prepending them to the front of a vector,
+ in each chunk we fill (name|value) pairs starting from the back
+ of the chunk (this simplifies item eviction/FIFO).
+ Given a 'linear' index we can find a chunk number and
+ offset in this chunk - random access.
+
+ Lookup in a static part is straightforward:
+ it's an (immutable) vector, data is sorted,
+ contains no duplicates, we use binary search comparing string values.
+
+ To provide a lookup in dynamic table faster than a linear search,
+ we have an std::set of 'SearchEntries', where each entry contains:
+ - a pointer to a (name|value) pair (to compare
+ name|value strings).
+ - a pointer to a chunk containing this pair and
+ - an offset within this chunk - to calculate a
+ 'linear' index.
+
+ Entries in a table can be duplicated (HPACK, 2.3.2),
+ if we evict an entry, we must update our index removing
+ the exactly right key, thus keys in this set are sorted
+ by name|value pairs first, and then by chunk index/offset
+ (so that NewSearchEntryKey < OldSearchEntry even if strings
+ are equal).
+*/
+
+class Q_AUTOTEST_EXPORT FieldLookupTable
+{
+public:
+ enum
+ {
+ ChunkSize = 16,
+ DefaultSize = 4096 // Recommended by HTTP2.
+ };
+
+ FieldLookupTable(quint32 maxTableSize, bool useIndex);
+
+ bool prependField(const QByteArray &name, const QByteArray &value);
+ void evictEntry();
+
+ quint32 numberOfEntries() const;
+ quint32 numberOfStaticEntries() const;
+ quint32 numberOfDynamicEntries() const;
+ quint32 dynamicDataSize() const;
+ void clearDynamicTable();
+
+ bool indexIsValid(quint32 index) const;
+ quint32 indexOf(const QByteArray &name, const QByteArray &value) const;
+ quint32 indexOf(const QByteArray &name) const;
+ bool field(quint32 index, QByteArray *name, QByteArray *value) const;
+ bool fieldName(quint32 index, QByteArray *dst) const;
+ bool fieldValue(quint32 index, QByteArray *dst) const;
+
+ bool updateDynamicTableSize(quint32 size);
+ void setMaxDynamicTableSize(quint32 size);
+
+private:
+ // Table's maximum size is controlled
+ // by SETTINGS_HEADER_TABLE_SIZE (HTTP/2, 6.5.2).
+ quint32 maxTableSize;
+ // The tableCapacity is how many bytes the table
+ // can currently hold. It cannot exceed maxTableSize.
+ // It can be modified by a special message in
+ // the HPACK bit stream (HPACK, 6.3).
+ quint32 tableCapacity;
+
+ using Chunk = std::vector<HeaderField>;
+ using ChunkPtr = std::unique_ptr<Chunk>;
+ std::deque<ChunkPtr> chunks;
+ using size_type = std::deque<ChunkPtr>::size_type;
+
+ struct SearchEntry;
+ friend struct SearchEntry;
+
+ struct SearchEntry
+ {
+ SearchEntry();
+ SearchEntry(const HeaderField *f, const Chunk *c,
+ quint32 o, const FieldLookupTable *t);
+
+ const HeaderField *field;
+ const Chunk *chunk;
+ const quint32 offset;
+ const FieldLookupTable *table;
+
+ bool operator < (const SearchEntry &rhs) const;
+ };
+
+ bool useIndex;
+ std::set<SearchEntry> searchIndex;
+
+ SearchEntry frontKey() const;
+ SearchEntry backKey() const;
+
+ bool fieldAt(quint32 index, HeaderField *field) const;
+
+ const HeaderField &front() const;
+ HeaderField &front();
+ const HeaderField &back() const;
+
+ quint32 nDynamic;
+ quint32 begin;
+ quint32 end;
+ quint32 dataSize;
+
+ quint32 indexOfChunk(const Chunk *chunk) const;
+ quint32 keyToIndex(const SearchEntry &key) const;
+
+ mutable QByteArray dummyDst;
+
+ Q_DISABLE_COPY(FieldLookupTable);
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/network/access/http2/http2.pri b/src/network/access/http2/http2.pri
new file mode 100644
index 0000000000..e9f30aeb4a
--- /dev/null
+++ b/src/network/access/http2/http2.pri
@@ -0,0 +1,17 @@
+HEADERS += \
+ access/http2/bitstreams_p.h \
+ access/http2/huffman_p.h \
+ access/http2/hpack_p.h \
+ access/http2/hpacktable_p.h \
+ access/http2/http2frames_p.h \
+ access/http2/http2streams_p.h \
+ access/http2/http2protocol_p.h
+
+SOURCES += \
+ access/http2/bitstreams.cpp \
+ access/http2/huffman.cpp \
+ access/http2/hpack.cpp \
+ access/http2/hpacktable.cpp \
+ access/http2/http2frames.cpp \
+ access/http2/http2streams.cpp \
+ access/http2/http2protocol.cpp
diff --git a/src/network/access/http2/http2frames.cpp b/src/network/access/http2/http2frames.cpp
new file mode 100644
index 0000000000..95f00dd286
--- /dev/null
+++ b/src/network/access/http2/http2frames.cpp
@@ -0,0 +1,556 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "http2frames_p.h"
+
+#include <QtNetwork/qabstractsocket.h>
+
+#include <algorithm>
+#include <utility>
+
+QT_BEGIN_NAMESPACE
+
+namespace Http2
+{
+
+// HTTP/2 frames are defined by RFC7540, clauses 4 and 6.
+
+FrameStatus validate_frame_header(FrameType type, FrameFlags flags, quint32 payloadSize)
+{
+ // 4.2 Frame Size
+ if (payloadSize > maxPayloadSize)
+ return FrameStatus::sizeError;
+
+ switch (type) {
+ case FrameType::SETTINGS:
+ // SETTINGS ACK can not have any payload.
+ // The payload of a SETTINGS frame consists of zero
+ // or more parameters, each consisting of an unsigned
+ // 16-bit setting identifier and an unsigned 32-bit value.
+ // Thus the payload size must be a multiple of 6.
+ if (flags.testFlag(FrameFlag::ACK) ? payloadSize : payloadSize % 6)
+ return FrameStatus::sizeError;
+ break;
+ case FrameType::PRIORITY:
+ // 6.3 PRIORITY
+ if (payloadSize != 5)
+ return FrameStatus::sizeError;
+ break;
+ case FrameType::PING:
+ // 6.7 PING
+ if (payloadSize != 8)
+ return FrameStatus::sizeError;
+ break;
+ case FrameType::GOAWAY:
+ // 6.8 GOAWAY
+ if (payloadSize < 8)
+ return FrameStatus::sizeError;
+ break;
+ case FrameType::RST_STREAM:
+ case FrameType::WINDOW_UPDATE:
+ // 6.4 RST_STREAM, 6.9 WINDOW_UPDATE
+ if (payloadSize != 4)
+ return FrameStatus::sizeError;
+ break;
+ case FrameType::PUSH_PROMISE:
+ // 6.6 PUSH_PROMISE
+ if (payloadSize < 4)
+ return FrameStatus::sizeError;
+ default:
+ // DATA/HEADERS/CONTINUATION will be verified
+ // when we have payload.
+ // Frames of unknown types are ignored (5.1)
+ break;
+ }
+
+ return FrameStatus::goodFrame;
+}
+
+FrameStatus validate_frame_payload(FrameType type, FrameFlags flags,
+ quint32 size, const uchar *src)
+{
+ Q_ASSERT(!size || src);
+
+ // Ignored, 5.1
+ if (type == FrameType::LAST_FRAME_TYPE)
+ return FrameStatus::goodFrame;
+
+ // 6.1 DATA, 6.2 HEADERS
+ if (type == FrameType::DATA || type == FrameType::HEADERS) {
+ if (flags.testFlag(FrameFlag::PADDED)) {
+ if (!size || size < src[0])
+ return FrameStatus::sizeError;
+ size -= src[0];
+ }
+ if (type == FrameType::HEADERS && flags.testFlag(FrameFlag::PRIORITY)) {
+ if (size < 5)
+ return FrameStatus::sizeError;
+ }
+ }
+
+ // 6.6 PUSH_PROMISE
+ if (type == FrameType::PUSH_PROMISE) {
+ if (flags.testFlag(FrameFlag::PADDED)) {
+ if (!size || size < src[0])
+ return FrameStatus::sizeError;
+ size -= src[0];
+ }
+
+ if (size < 4)
+ return FrameStatus::sizeError;
+ }
+
+ return FrameStatus::goodFrame;
+}
+
+FrameStatus validate_frame_payload(FrameType type, FrameFlags flags,
+ const std::vector<uchar> &payload)
+{
+ const uchar *src = payload.size() ? &payload[0] : nullptr;
+ return validate_frame_payload(type, flags, quint32(payload.size()), src);
+}
+
+
+FrameReader::FrameReader(FrameReader &&rhs)
+ : frameBuffer(std::move(rhs.frameBuffer))
+{
+ type = rhs.type;
+ rhs.type = FrameType::LAST_FRAME_TYPE;
+
+ flags = rhs.flags;
+ rhs.flags = FrameFlag::EMPTY;
+
+ streamID = rhs.streamID;
+ rhs.streamID = 0;
+
+ payloadSize = rhs.payloadSize;
+ rhs.payloadSize = 0;
+
+ state = rhs.state;
+ rhs.state = Idle;
+
+ offset = rhs.offset;
+ rhs.offset = 0;
+}
+
+FrameReader &FrameReader::operator = (FrameReader &&rhs)
+{
+ frameBuffer = std::move(rhs.frameBuffer);
+
+ type = rhs.type;
+ rhs.type = FrameType::LAST_FRAME_TYPE;
+
+ flags = rhs.flags;
+ rhs.flags = FrameFlag::EMPTY;
+
+ streamID = rhs.streamID;
+ rhs.streamID = 0;
+
+ payloadSize = rhs.payloadSize;
+ rhs.payloadSize = 0;
+
+ state = rhs.state;
+ rhs.state = Idle;
+
+ offset = rhs.offset;
+ rhs.offset = 0;
+
+ return *this;
+}
+
+FrameStatus FrameReader::read(QAbstractSocket &socket)
+{
+ if (state != ReadingPayload) {
+ // Either Idle or ReadingHeader:
+ if (!readHeader(socket))
+ return FrameStatus::incompleteFrame;
+
+ Q_ASSERT(state == Idle);
+
+ const auto status = validate_frame_header(type, flags, payloadSize);
+ if (status != FrameStatus::goodFrame) {
+ // No need to read any payload.
+ return status;
+ }
+
+ if (Http2PredefinedParameters::maxFrameSize < payloadSize)
+ return FrameStatus::sizeError;
+
+ frameBuffer.resize(payloadSize);
+ offset = 0;
+ }
+
+ if (frameBuffer.size()) {
+ if (!readPayload(socket))
+ return FrameStatus::incompleteFrame;
+ Q_ASSERT(state == Idle);
+ }
+
+ return validate_frame_payload(type, flags, frameBuffer);
+}
+
+bool FrameReader::padded(uchar *pad) const
+{
+ Q_ASSERT(pad);
+
+ if (!flags.testFlag(FrameFlag::PADDED))
+ return false;
+
+ if (type == FrameType::DATA
+ || type == FrameType::PUSH_PROMISE
+ || type == FrameType::HEADERS) {
+ Q_ASSERT(frameBuffer.size() >= 1);
+ *pad = frameBuffer[0];
+ return true;
+ }
+
+ return false;
+}
+
+bool FrameReader::priority(quint32 *streamID, uchar *weight) const
+{
+ Q_ASSERT(streamID);
+ Q_ASSERT(weight);
+
+ if (!frameBuffer.size())
+ return false;
+
+ const uchar *src = &frameBuffer[0];
+ if (type == FrameType::HEADERS && flags.testFlag(FrameFlag::PADDED))
+ ++src;
+
+ if ((type == FrameType::HEADERS && flags.testFlag(FrameFlag::PRIORITY))
+ || type == FrameType::PRIORITY) {
+ *streamID = qFromBigEndian<quint32>(src);
+ *weight = src[4];
+ return true;
+ }
+
+ return false;
+}
+
+quint32 FrameReader::dataSize() const
+{
+ quint32 size = quint32(frameBuffer.size());
+ uchar pad = 0;
+ if (padded(&pad)) {
+ // + 1 one for a byte with padding number itself:
+ size -= pad + 1;
+ }
+
+ quint32 dummyID = 0;
+ uchar dummyW = 0;
+ if (priority(&dummyID, &dummyW))
+ size -= 5;
+
+ return size;
+}
+
+const uchar *FrameReader::dataBegin() const
+{
+ if (!frameBuffer.size())
+ return nullptr;
+
+ const uchar *src = &frameBuffer[0];
+ uchar dummyPad = 0;
+ if (padded(&dummyPad))
+ ++src;
+
+ quint32 dummyID = 0;
+ uchar dummyW = 0;
+ if (priority(&dummyID, &dummyW))
+ src += 5;
+
+ return src;
+}
+
+bool FrameReader::readHeader(QAbstractSocket &socket)
+{
+ Q_ASSERT(state != ReadingPayload);
+
+ if (state == Idle) {
+ offset = 0;
+ frameBuffer.resize(frameHeaderSize);
+ state = ReadingHeader;
+ }
+
+ Q_ASSERT(offset < frameHeaderSize);
+
+ const auto chunkSize = socket.read(reinterpret_cast<char *>(&frameBuffer[offset]),
+ frameHeaderSize - offset);
+ if (chunkSize > 0)
+ offset += chunkSize;
+
+ if (offset < frameHeaderSize)
+ return false;
+
+ // We got a complete frame header:
+ state = Idle;
+
+ const uchar *src = &frameBuffer[0];
+
+ payloadSize = src[0] << 16 | src[1] << 8 | src[2];
+ type = FrameType(src[3]);
+ if (int(type) >= int(FrameType::LAST_FRAME_TYPE))
+ type = FrameType::LAST_FRAME_TYPE; // To be ignored, 5.1
+
+ flags = FrameFlags(src[4]);
+ streamID = qFromBigEndian<quint32>(src + 5);
+
+ return true;
+}
+
+bool FrameReader::readPayload(QAbstractSocket &socket)
+{
+ Q_ASSERT(offset < frameBuffer.size());
+ Q_ASSERT(state != ReadingHeader);
+
+ state = ReadingPayload;
+
+ // Casts and ugliness - to deal with MSVC. Values are guaranteed to fit into quint32.
+ const auto residue = qint64(frameBuffer.size() - offset);
+ const auto chunkSize = socket.read(reinterpret_cast<char *>(&frameBuffer[offset]), residue);
+ if (chunkSize > 0)
+ offset += quint32(chunkSize);
+
+ if (offset < frameBuffer.size())
+ return false;
+
+ // Complete payload read:
+ state = Idle;
+ return true;
+}
+
+
+FrameWriter::FrameWriter()
+{
+ frameBuffer.reserve(Http2PredefinedParameters::maxFrameSize +
+ Http2PredefinedParameters::frameHeaderSize);
+}
+
+FrameWriter::FrameWriter(FrameType type, FrameFlags flags, quint32 streamID)
+{
+ frameBuffer.reserve(Http2PredefinedParameters::maxFrameSize +
+ Http2PredefinedParameters::frameHeaderSize);
+ start(type, flags, streamID);
+}
+
+void FrameWriter::start(FrameType type, FrameFlags flags, quint32 streamID)
+{
+ frameBuffer.resize(frameHeaderSize);
+ // The first three bytes - payload size, which is 0 for now.
+ frameBuffer[0] = 0;
+ frameBuffer[1] = 0;
+ frameBuffer[2] = 0;
+
+ frameBuffer[3] = uchar(type);
+ frameBuffer[4] = uchar(flags);
+
+ qToBigEndian(streamID, &frameBuffer[5]);
+}
+
+void FrameWriter::setPayloadSize(quint32 size)
+{
+ Q_ASSERT(frameBuffer.size() >= frameHeaderSize);
+ Q_ASSERT(size < maxPayloadSize);
+
+ frameBuffer[0] = size >> 16;
+ frameBuffer[1] = size >> 8;
+ frameBuffer[2] = size;
+}
+
+quint32 FrameWriter::payloadSize() const
+{
+ Q_ASSERT(frameBuffer.size() >= frameHeaderSize);
+ return frameBuffer[0] << 16 | frameBuffer[1] << 8 | frameBuffer[2];
+}
+
+void FrameWriter::setType(FrameType type)
+{
+ Q_ASSERT(frameBuffer.size() >= frameHeaderSize);
+ frameBuffer[3] = uchar(type);
+}
+
+FrameType FrameWriter::type() const
+{
+ Q_ASSERT(frameBuffer.size() >= frameHeaderSize);
+ return FrameType(frameBuffer[3]);
+}
+
+void FrameWriter::setFlags(FrameFlags flags)
+{
+ Q_ASSERT(frameBuffer.size() >= frameHeaderSize);
+ frameBuffer[4] = uchar(flags);
+}
+
+void FrameWriter::addFlag(FrameFlag flag)
+{
+ setFlags(flags() | flag);
+}
+
+FrameFlags FrameWriter::flags() const
+{
+ Q_ASSERT(frameBuffer.size() >= frameHeaderSize);
+ return FrameFlags(frameBuffer[4]);
+}
+
+quint32 FrameWriter::streamID() const
+{
+ return qFromBigEndian<quint32>(&frameBuffer[5]);
+}
+
+void FrameWriter::append(uchar val)
+{
+ frameBuffer.push_back(val);
+ updatePayloadSize();
+}
+
+void FrameWriter::append(const uchar *begin, const uchar *end)
+{
+ Q_ASSERT(begin && end);
+ Q_ASSERT(begin < end);
+
+ frameBuffer.insert(frameBuffer.end(), begin, end);
+ updatePayloadSize();
+}
+
+void FrameWriter::updatePayloadSize()
+{
+ // First, compute size:
+ const quint32 payloadSize = quint32(frameBuffer.size() - frameHeaderSize);
+ Q_ASSERT(payloadSize <= maxPayloadSize);
+ setPayloadSize(payloadSize);
+}
+
+bool FrameWriter::write(QAbstractSocket &socket) const
+{
+ Q_ASSERT(frameBuffer.size() >= frameHeaderSize);
+ // Do some sanity check first:
+ Q_ASSERT(int(type()) < int(FrameType::LAST_FRAME_TYPE));
+ Q_ASSERT(validate_frame_header(type(), flags(), payloadSize()) == FrameStatus::goodFrame);
+
+ const auto nWritten = socket.write(reinterpret_cast<const char *>(&frameBuffer[0]),
+ frameBuffer.size());
+ return nWritten != -1 && size_type(nWritten) == frameBuffer.size();
+}
+
+bool FrameWriter::writeHEADERS(QAbstractSocket &socket, quint32 sizeLimit)
+{
+ Q_ASSERT(frameBuffer.size() >= frameHeaderSize);
+
+ if (sizeLimit > quint32(maxPayloadSize))
+ sizeLimit = quint32(maxPayloadSize);
+
+ if (quint32(frameBuffer.size() - frameHeaderSize) <= sizeLimit) {
+ updatePayloadSize();
+ return write(socket);
+ }
+
+ // Write a frame's header (not controlled by sizeLimit) and
+ // as many bytes of payload as we can within sizeLimit,
+ // then send CONTINUATION frames, as needed.
+ setPayloadSize(sizeLimit);
+ const quint32 firstChunkSize = frameHeaderSize + sizeLimit;
+ qint64 written = socket.write(reinterpret_cast<const char *>(&frameBuffer[0]),
+ firstChunkSize);
+
+ if (written != qint64(firstChunkSize))
+ return false;
+
+ FrameWriter continuationFrame(FrameType::CONTINUATION, FrameFlag::EMPTY, streamID());
+ quint32 offset = firstChunkSize;
+
+ while (offset != frameBuffer.size()) {
+ const auto chunkSize = std::min(sizeLimit, quint32(frameBuffer.size() - offset));
+ if (chunkSize + offset == frameBuffer.size())
+ continuationFrame.addFlag(FrameFlag::END_HEADERS);
+ continuationFrame.setPayloadSize(chunkSize);
+ if (!continuationFrame.write(socket))
+ return false;
+ written = socket.write(reinterpret_cast<const char *>(&frameBuffer[offset]),
+ chunkSize);
+ if (written != qint64(chunkSize))
+ return false;
+
+ offset += chunkSize;
+ }
+
+ return true;
+}
+
+bool FrameWriter::writeDATA(QAbstractSocket &socket, quint32 sizeLimit,
+ const uchar *src, quint32 size)
+{
+ // With DATA frame(s) we always have:
+ // 1) frame's header (9 bytes)
+ // 2) a separate payload (from QNonContiguousByteDevice).
+ // We either fit within a sizeLimit, or split into several
+ // DATA frames.
+
+ Q_ASSERT(src);
+
+ if (sizeLimit > quint32(maxPayloadSize))
+ sizeLimit = quint32(maxPayloadSize);
+ // We NEVER set END_STREAM, since QHttp2ProtocolHandler works with
+ // QNonContiguousByteDevice and this 'writeDATA' is probably
+ // not the last one for a given request.
+ // This has to be done externally (sending an empty DATA frame with END_STREAM).
+ for (quint32 offset = 0; offset != size;) {
+ const auto chunkSize = std::min(size - offset, sizeLimit);
+ setPayloadSize(chunkSize);
+ // Frame's header first:
+ if (!write(socket))
+ return false;
+ // Payload (if any):
+ if (chunkSize) {
+ const auto written = socket.write(reinterpret_cast<const char*>(src + offset),
+ chunkSize);
+ if (written != qint64(chunkSize))
+ return false;
+ }
+
+ offset += chunkSize;
+ }
+
+ return true;
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/network/access/http2/http2frames_p.h b/src/network/access/http2/http2frames_p.h
new file mode 100644
index 0000000000..c85be57a2e
--- /dev/null
+++ b/src/network/access/http2/http2frames_p.h
@@ -0,0 +1,191 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HTTP2FRAMES_P_H
+#define HTTP2FRAMES_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the Network Access API. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "http2protocol_p.h"
+#include "hpack_p.h"
+
+#include <QtCore/qendian.h>
+#include <QtCore/qglobal.h>
+
+#include <algorithm>
+#include <vector>
+
+QT_BEGIN_NAMESPACE
+
+class QHttp2ProtocolHandler;
+class QAbstractSocket;
+
+namespace Http2
+{
+
+class Q_AUTOTEST_EXPORT FrameReader
+{
+ friend class QT_PREPEND_NAMESPACE(QHttp2ProtocolHandler);
+
+public:
+ FrameReader() = default;
+
+ FrameReader(const FrameReader &) = default;
+ FrameReader(FrameReader &&rhs);
+
+ FrameReader &operator = (const FrameReader &) = default;
+ FrameReader &operator = (FrameReader &&rhs);
+
+ FrameStatus read(QAbstractSocket &socket);
+
+ bool padded(uchar *pad) const;
+ bool priority(quint32 *streamID, uchar *weight) const;
+
+ // N of bytes without padding and/or priority
+ quint32 dataSize() const;
+ // Beginning of payload without priority/padding
+ // bytes.
+ const uchar *dataBegin() const;
+
+ FrameType type = FrameType::LAST_FRAME_TYPE;
+ FrameFlags flags = FrameFlag::EMPTY;
+ quint32 streamID = 0;
+ quint32 payloadSize = 0;
+
+private:
+ bool readHeader(QAbstractSocket &socket);
+ bool readPayload(QAbstractSocket &socket);
+
+ enum ReaderState {
+ Idle,
+ ReadingHeader,
+ ReadingPayload
+ };
+
+ ReaderState state = Idle;
+
+ // As soon as we got a header, we
+ // know payload size, offset is
+ // needed if we do not have enough
+ // data and will read the next chunk.
+ quint32 offset = 0;
+ std::vector<uchar> frameBuffer;
+};
+
+class Q_AUTOTEST_EXPORT FrameWriter
+{
+ friend class QT_PREPEND_NAMESPACE(QHttp2ProtocolHandler);
+
+public:
+ using payload_type = std::vector<uchar>;
+ using size_type = payload_type::size_type;
+
+ FrameWriter();
+ FrameWriter(FrameType type, FrameFlags flags, quint32 streamID);
+
+ void start(FrameType type, FrameFlags flags, quint32 streamID);
+
+ void setPayloadSize(quint32 size);
+ quint32 payloadSize() const;
+
+ void setType(FrameType type);
+ FrameType type() const;
+
+ void setFlags(FrameFlags flags);
+ void addFlag(FrameFlag flag);
+ FrameFlags flags() const;
+
+ quint32 streamID() const;
+
+ // All append functions also update frame's payload
+ // length.
+ template<typename ValueType>
+ void append(ValueType val)
+ {
+ uchar wired[sizeof val] = {};
+ qToBigEndian(val, wired);
+ append(wired, wired + sizeof val);
+ }
+ void append(uchar val);
+ void append(Settings identifier)
+ {
+ append(quint16(identifier));
+ }
+ void append(const payload_type &payload)
+ {
+ append(&payload[0], &payload[0] + payload.size());
+ }
+
+ void append(const uchar *begin, const uchar *end);
+
+ // Write 'frameBuffer' as a single frame:
+ bool write(QAbstractSocket &socket) const;
+ // Write as a single frame if we can, or write headers and
+ // CONTINUATION(s) frame(s).
+ bool writeHEADERS(QAbstractSocket &socket, quint32 sizeLimit);
+ // Write either a single DATA frame or several DATA frames
+ // depending on 'sizeLimit'. Data itself is 'external' to
+ // FrameWriter, since it's a 'readPointer' from QNonContiguousData.
+ bool writeDATA(QAbstractSocket &socket, quint32 sizeLimit,
+ const uchar *src, quint32 size);
+
+ std::vector<uchar> &rawFrameBuffer()
+ {
+ return frameBuffer;
+ }
+
+private:
+ void updatePayloadSize();
+ std::vector<uchar> frameBuffer;
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/network/access/http2/http2protocol.cpp b/src/network/access/http2/http2protocol.cpp
new file mode 100644
index 0000000000..7f788a6f42
--- /dev/null
+++ b/src/network/access/http2/http2protocol.cpp
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/qstring.h>
+
+#include "http2protocol_p.h"
+
+QT_BEGIN_NAMESPACE
+
+Q_LOGGING_CATEGORY(QT_HTTP2, "qt.network.http2")
+
+namespace Http2
+{
+
+// 3.5 HTTP/2 Connection Preface:
+// "That is, the connection preface starts with the string
+// PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n)."
+const char Http2clientPreface[clientPrefaceLength] =
+ {0x50, 0x52, 0x49, 0x20, 0x2a, 0x20,
+ 0x48, 0x54, 0x54, 0x50, 0x2f, 0x32,
+ 0x2e, 0x30, 0x0d, 0x0a, 0x0d, 0x0a,
+ 0x53, 0x4d, 0x0d, 0x0a, 0x0d, 0x0a};
+
+
+void qt_error(quint32 errorCode, QNetworkReply::NetworkError &error,
+ QString &errorMessage)
+{
+ if (errorCode > quint32(HTTP_1_1_REQUIRED)) {
+ error = QNetworkReply::ProtocolFailure;
+ errorMessage = QLatin1String("RST_STREAM with unknown error code (%1)");
+ errorMessage = errorMessage.arg(errorCode);
+ return;
+ }
+
+ const Http2Error http2Error = Http2Error(errorCode);
+
+ switch (http2Error) {
+ case HTTP2_NO_ERROR:
+ error = QNetworkReply::NoError;
+ errorMessage.clear();
+ break;
+ case PROTOCOL_ERROR:
+ error = QNetworkReply::ProtocolFailure;
+ errorMessage = QLatin1String("HTTP/2 protocol error");
+ break;
+ case INTERNAL_ERROR:
+ error = QNetworkReply::InternalServerError;
+ errorMessage = QLatin1String("Internal server error");
+ break;
+ case FLOW_CONTROL_ERROR:
+ error = QNetworkReply::ProtocolFailure;
+ errorMessage = QLatin1String("Flow control error");
+ break;
+ case SETTINGS_TIMEOUT:
+ error = QNetworkReply::TimeoutError;
+ errorMessage = QLatin1String("SETTINGS ACK timeout error");
+ break;
+ case STREAM_CLOSED:
+ error = QNetworkReply::ProtocolFailure;
+ errorMessage = QLatin1String("Server received frame(s) on a half-closed stream");
+ break;
+ case FRAME_SIZE_ERROR:
+ error = QNetworkReply::ProtocolFailure;
+ errorMessage = QLatin1String("Server received a frame with an invalid size");
+ break;
+ case REFUSE_STREAM:
+ error = QNetworkReply::ProtocolFailure;
+ errorMessage = QLatin1String("Server refused a stream");
+ break;
+ case CANCEL:
+ error = QNetworkReply::ProtocolFailure;
+ errorMessage = QLatin1String("Stream is no longer needed");
+ break;
+ case COMPRESSION_ERROR:
+ error = QNetworkReply::ProtocolFailure;
+ errorMessage = QLatin1String("Server is unable to maintain the "
+ "header compression context for the connection");
+ break;
+ case CONNECT_ERROR:
+ // TODO: in Qt6 we'll have to add more error codes in QNetworkReply.
+ error = QNetworkReply::UnknownNetworkError;
+ errorMessage = QLatin1String("The connection established in response "
+ "to a CONNECT request was reset or abnormally closed");
+ break;
+ case ENHANCE_YOUR_CALM:
+ error = QNetworkReply::UnknownServerError;
+ errorMessage = QLatin1String("Server dislikes our behavior, excessive load detected.");
+ break;
+ case INADEQUATE_SECURITY:
+ error = QNetworkReply::ContentAccessDenied;
+ errorMessage = QLatin1String("The underlying transport has properties "
+ "that do not meet minimum security "
+ "requirements");
+ break;
+ case HTTP_1_1_REQUIRED:
+ error = QNetworkReply::ProtocolFailure;
+ errorMessage = QLatin1String("Server requires that HTTP/1.1 "
+ "be used instead of HTTP/2.");
+ }
+}
+
+QString qt_error_string(quint32 errorCode)
+{
+ QNetworkReply::NetworkError error = QNetworkReply::NoError;
+ QString message;
+ qt_error(errorCode, error, message);
+ return message;
+}
+
+QNetworkReply::NetworkError qt_error(quint32 errorCode)
+{
+ QNetworkReply::NetworkError error = QNetworkReply::NoError;
+ QString message;
+ qt_error(errorCode, error, message);
+ return error;
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/network/access/http2/http2protocol_p.h b/src/network/access/http2/http2protocol_p.h
new file mode 100644
index 0000000000..5c46949e23
--- /dev/null
+++ b/src/network/access/http2/http2protocol_p.h
@@ -0,0 +1,175 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HTTP2PROTOCOL_P_H
+#define HTTP2PROTOCOL_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the Network Access API. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtNetwork/qnetworkreply.h>
+#include <QtCore/qloggingcategory.h>
+#include <QtCore/qglobal.h>
+
+// Different HTTP/2 constants/values as defined by RFC 7540.
+
+QT_BEGIN_NAMESPACE
+
+class QString;
+
+namespace Http2
+{
+
+enum class Settings : quint16
+{
+ HEADER_TABLE_SIZE_ID = 0x1,
+ ENABLE_PUSH_ID = 0x2,
+ MAX_CONCURRENT_STREAMS_ID = 0x3,
+ INITIAL_WINDOW_SIZE_ID = 0x4,
+ MAX_FRAME_SIZE_ID = 0x5,
+ MAX_HEADER_LIST_SIZE_ID = 0x6
+};
+
+enum class FrameType : uchar
+{
+ DATA = 0x0,
+ HEADERS = 0x1,
+ PRIORITY = 0x2,
+ RST_STREAM = 0x3,
+ SETTINGS = 0x4,
+ PUSH_PROMISE = 0x5,
+ PING = 0x6,
+ GOAWAY = 0x7,
+ WINDOW_UPDATE = 0x8,
+ CONTINUATION = 0x9,
+ // ATTENTION: enumerators must be sorted.
+ // We use LAST_FRAME_TYPE to check if
+ // frame type is known, if not - this frame
+ // must be ignored, HTTP/2 5.1).
+ LAST_FRAME_TYPE
+};
+
+enum class FrameFlag : uchar
+{
+ EMPTY = 0x0, // Valid for any frame type.
+ ACK = 0x1, // Valid for PING, SETTINGS
+ END_STREAM = 0x1, // Valid for HEADERS, DATA
+ END_HEADERS = 0x4, // Valid for PUSH_PROMISE, HEADERS,
+ PADDED = 0x8, // Valid for PUSH_PROMISE, HEADERS, DATA
+ PRIORITY = 0x20 // Valid for HEADERS,
+};
+
+Q_DECLARE_FLAGS(FrameFlags, FrameFlag)
+Q_DECLARE_OPERATORS_FOR_FLAGS(FrameFlags)
+
+enum Http2PredefinedParameters
+{
+ // Old-style enum, so we
+ // can use as Http2::frameHeaderSize for example.
+ clientPrefaceLength = 24, // HTTP/2, 3.5
+ connectionStreamID = 0, // HTTP/2, 5.1.1
+ frameHeaderSize = 9, // HTTP/2, 4.1
+
+ // It's our max frame size we send in SETTINGS frame,
+ // it's also the default one and we also use it to later
+ // validate incoming frames:
+ maxFrameSize = 16384, // HTTP/2 6.5.2
+
+ defaultSessionWindowSize = 65535, // HTTP/2 6.5.2
+ maxPayloadSize = (1 << 24) - 1, // HTTP/2 6.5.2
+ // Using 1000 (rather arbitrarily), just to
+ // impose *some* upper limit:
+ maxPeerConcurrentStreams = 1000,
+ maxConcurrentStreams = 100 // HTTP/2, 6.5.2
+};
+
+extern const Q_AUTOTEST_EXPORT char Http2clientPreface[clientPrefaceLength];
+
+enum class FrameStatus
+{
+ protocolError,
+ sizeError,
+ incompleteFrame,
+ goodFrame
+};
+
+enum Http2Error
+{
+ // Old-style enum to avoid excessive name
+ // qualification ...
+ // NB:
+ // I use the last enumerator to check
+ // that errorCode (quint32) is valid,
+ // so it needs to be the highest-numbered!
+ // HTTP/2 7:
+ HTTP2_NO_ERROR = 0x0,
+ PROTOCOL_ERROR = 0x1,
+ INTERNAL_ERROR = 0x2,
+ FLOW_CONTROL_ERROR = 0x3,
+ SETTINGS_TIMEOUT = 0x4,
+ STREAM_CLOSED = 0x5,
+ FRAME_SIZE_ERROR = 0x6,
+ REFUSE_STREAM = 0x7,
+ CANCEL = 0x8,
+ COMPRESSION_ERROR = 0x9,
+ CONNECT_ERROR = 0xa,
+ ENHANCE_YOUR_CALM = 0xb,
+ INADEQUATE_SECURITY = 0xc,
+ HTTP_1_1_REQUIRED = 0xd
+};
+
+void qt_error(quint32 errorCode, QNetworkReply::NetworkError &error, QString &errorString);
+QString qt_error_string(quint32 errorCode);
+QNetworkReply::NetworkError qt_error(quint32 errorCode);
+
+}
+
+Q_DECLARE_LOGGING_CATEGORY(QT_HTTP2)
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/corelib/plugin/quuid_darwin.mm b/src/network/access/http2/http2streams.cpp
index c2a7240f3b..f57f8d8367 100644
--- a/src/corelib/plugin/quuid_darwin.mm
+++ b/src/network/access/http2/http2streams.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the QtCore module of the Qt Toolkit.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -37,39 +37,64 @@
**
****************************************************************************/
-#include "quuid.h"
+#include "http2streams_p.h"
-#import <Foundation/Foundation.h>
+#include "private/qhttp2protocolhandler_p.h"
+#include "private/qhttpnetworkreply_p.h"
+
+#include <QtCore/qdebug.h>
QT_BEGIN_NAMESPACE
-QUuid QUuid::fromCFUUID(CFUUIDRef uuid)
+namespace Http2
+{
+
+Stream::Stream(const HttpMessagePair &message, quint32 id, qint32 sendSize, qint32 recvSize)
+ : httpPair(message),
+ streamID(id),
+ sendWindow(sendSize),
+ recvWindow(recvSize)
+{
+}
+
+QHttpNetworkReply *Stream::reply() const
+{
+ return httpPair.second;
+}
+
+const QHttpNetworkRequest &Stream::request() const
{
- if (!uuid)
- return QUuid();
- const CFUUIDBytes bytes = CFUUIDGetUUIDBytes(uuid);
- return QUuid::fromRfc4122(QByteArray::fromRawData(reinterpret_cast<const char *>(&bytes), sizeof(bytes)));
+ return httpPair.first;
}
-CFUUIDRef QUuid::toCFUUID() const
+QHttpNetworkRequest &Stream::request()
{
- const QByteArray bytes = toRfc4122();
- return CFUUIDCreateFromUUIDBytes(0, *reinterpret_cast<const CFUUIDBytes *>(bytes.constData()));
+ return httpPair.first;
}
-QUuid QUuid::fromNSUUID(const NSUUID *uuid)
+QHttpNetworkRequest::Priority Stream::priority() const
{
- if (!uuid)
- return QUuid();
- uuid_t bytes;
- [uuid getUUIDBytes:bytes];
- return QUuid::fromRfc4122(QByteArray::fromRawData(reinterpret_cast<const char *>(bytes), sizeof(bytes)));
+ return httpPair.first.priority();
}
-NSUUID *QUuid::toNSUUID() const
+uchar Stream::weight() const
{
- const QByteArray bytes = toRfc4122();
- return [[[NSUUID alloc] initWithUUIDBytes:*reinterpret_cast<const uuid_t *>(bytes.constData())] autorelease];
+ switch (priority()) {
+ case QHttpNetworkRequest::LowPriority:
+ return 0;
+ case QHttpNetworkRequest::NormalPriority:
+ return 127;
+ case QHttpNetworkRequest::HighPriority:
+ default:
+ return 255;
+ }
+}
+
+QNonContiguousByteDevice *Stream::data() const
+{
+ return httpPair.first.uploadByteDevice();
+}
+
}
QT_END_NAMESPACE
diff --git a/src/network/access/http2/http2streams_p.h b/src/network/access/http2/http2streams_p.h
new file mode 100644
index 0000000000..5d9a6ab512
--- /dev/null
+++ b/src/network/access/http2/http2streams_p.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HTTP2STREAMS_P_H
+#define HTTP2STREAMS_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the Network Access API. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qhttpnetworkconnectionchannel_p.h>
+#include <private/qhttpnetworkrequest_p.h>
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+class QNonContiguousByteDevice;
+
+namespace Http2
+{
+
+struct Q_AUTOTEST_EXPORT Stream
+{
+ enum StreamState {
+ idle,
+ open,
+ halfClosedLocal,
+ halfClosedRemote,
+ closed
+ };
+
+ Stream() = default;
+ Stream(const HttpMessagePair &message, quint32 streamID, qint32 sendSize,
+ qint32 recvSize);
+
+ // TODO: check includes!!!
+ QHttpNetworkReply *reply() const;
+ const QHttpNetworkRequest &request() const;
+ QHttpNetworkRequest &request();
+ QHttpNetworkRequest::Priority priority() const;
+ uchar weight() const;
+
+ QNonContiguousByteDevice *data() const;
+
+ HttpMessagePair httpPair;
+ quint32 streamID = 0;
+ // Signed as window sizes can become negative:
+ qint32 sendWindow = 65535;
+ qint32 recvWindow = 65535;
+
+ StreamState state = idle;
+};
+
+}
+
+QT_END_NAMESPACE
+
+#endif
+
diff --git a/src/network/access/http2/huffman.cpp b/src/network/access/http2/huffman.cpp
new file mode 100644
index 0000000000..0c1aa54dd6
--- /dev/null
+++ b/src/network/access/http2/huffman.cpp
@@ -0,0 +1,573 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "bitstreams_p.h"
+#include "huffman_p.h"
+
+#include <QtCore/qbytearray.h>
+
+#include <algorithm>
+#include <limits>
+
+QT_BEGIN_NAMESPACE
+
+namespace HPack
+{
+
+/*
+ The static Huffman code used here was extracted from:
+ https://http2.github.io/http2-spec/compression.html#huffman.code
+
+ This code was generated from statistics obtained on a large
+ sample of HTTP headers. It is a canonical Huffman code
+ with some tweaking to ensure that no symbol has a unique
+ code length. All codes were left-aligned - for implementation
+ convenience.
+
+ Using binary trees to implement decoding would be prohibitively
+ expensive (both memory and time-wise). Instead we use a table-based
+ approach and any given code itself works as an index into such table(s).
+ We have 256 possible byte values and code lengths in
+ a range [5, 26]. This would require a huge table (and most of entries
+ would be 'wasted', since we only have to encode 256 elements).
+ Instead we use multi-level tables. The first level table
+ is using 9-bit length index; some entries in this table are 'terminal',
+ some reference the next level table(s).
+
+ For example, bytes with values 48 and 49 (ASCII codes for '0' and '1')
+ both have code length 5, Huffman codes are: 00000 and 00001. They
+ both are placed in the 'root' table,
+ the 'root' table has index length == 9:
+ [00000 | 4 remaining bits]
+ ...
+ [00001 | 4 remaining bits]
+
+ All entires with indices between these two will 'point' to value 48
+ with bitLength == 5 so that bit stream (for example) 000001010 will be
+ decoded as: 48 + "put 1010 back into bitstream".
+
+ A good description can be found here:
+ http://commandlinefanatic.com/cgi-bin/showarticle.cgi?article=art007
+ or just google "Efficient Huffman Decoding".
+ Also see comments below about 'filling holes'.
+*/
+
+namespace
+{
+
+const CodeEntry staticHuffmanCodeTable[]
+{
+ { 0, 0xffc00000ul, 13}, // 11111111|11000
+ { 1, 0xffffb000ul, 23}, // 11111111|11111111|1011000
+ { 2, 0xfffffe20ul, 28}, // 11111111|11111111|11111110|0010
+ { 3, 0xfffffe30ul, 28}, // 11111111|11111111|11111110|0011
+ { 4, 0xfffffe40ul, 28}, // 11111111|11111111|11111110|0100
+ { 5, 0xfffffe50ul, 28}, // 11111111|11111111|11111110|0101
+ { 6, 0xfffffe60ul, 28}, // 11111111|11111111|11111110|0110
+ { 7, 0xfffffe70ul, 28}, // 11111111|11111111|11111110|0111
+ { 8, 0xfffffe80ul, 28}, // 11111111|11111111|11111110|1000
+ { 9, 0xffffea00ul, 24}, // 11111111|11111111|11101010
+ { 10, 0xfffffff0ul, 30}, // 11111111|11111111|11111111|111100
+ { 11, 0xfffffe90ul, 28}, // 11111111|11111111|11111110|1001
+ { 12, 0xfffffea0ul, 28}, // 11111111|11111111|11111110|1010
+ { 13, 0xfffffff4ul, 30}, // 11111111|11111111|11111111|111101
+ { 14, 0xfffffeb0ul, 28}, // 11111111|11111111|11111110|1011
+ { 15, 0xfffffec0ul, 28}, // 11111111|11111111|11111110|1100
+ { 16, 0xfffffed0ul, 28}, // 11111111|11111111|11111110|1101
+ { 17, 0xfffffee0ul, 28}, // 11111111|11111111|11111110|1110
+ { 18, 0xfffffef0ul, 28}, // 11111111|11111111|11111110|1111
+ { 19, 0xffffff00ul, 28}, // 11111111|11111111|11111111|0000
+ { 20, 0xffffff10ul, 28}, // 11111111|11111111|11111111|0001
+ { 21, 0xffffff20ul, 28}, // 11111111|11111111|11111111|0010
+ { 22, 0xfffffff8ul, 30}, // 11111111|11111111|11111111|111110
+ { 23, 0xffffff30ul, 28}, // 11111111|11111111|11111111|0011
+ { 24, 0xffffff40ul, 28}, // 11111111|11111111|11111111|0100
+ { 25, 0xffffff50ul, 28}, // 11111111|11111111|11111111|0101
+ { 26, 0xffffff60ul, 28}, // 11111111|11111111|11111111|0110
+ { 27, 0xffffff70ul, 28}, // 11111111|11111111|11111111|0111
+ { 28, 0xffffff80ul, 28}, // 11111111|11111111|11111111|1000
+ { 29, 0xffffff90ul, 28}, // 11111111|11111111|11111111|1001
+ { 30, 0xffffffa0ul, 28}, // 11111111|11111111|11111111|1010
+ { 31, 0xffffffb0ul, 28}, // 11111111|11111111|11111111|1011
+ { 32, 0x50000000ul, 6}, // ' ' 010100
+ { 33, 0xfe000000ul, 10}, // '!' 11111110|00
+ { 34, 0xfe400000ul, 10}, // '"' 11111110|01
+ { 35, 0xffa00000ul, 12}, // '#' 11111111|1010
+ { 36, 0xffc80000ul, 13}, // '$' 11111111|11001
+ { 37, 0x54000000ul, 6}, // '%' 010101
+ { 38, 0xf8000000ul, 8}, // '&' 11111000
+ { 39, 0xff400000ul, 11}, // ''' 11111111|010
+ { 40, 0xfe800000ul, 10}, // '(' 11111110|10
+ { 41, 0xfec00000ul, 10}, // ')' 11111110|11
+ { 42, 0xf9000000ul, 8}, // '*' 11111001
+ { 43, 0xff600000ul, 11}, // '+' 11111111|011
+ { 44, 0xfa000000ul, 8}, // ',' 11111010
+ { 45, 0x58000000ul, 6}, // '-' 010110
+ { 46, 0x5c000000ul, 6}, // '.' 010111
+ { 47, 0x60000000ul, 6}, // '/' 011000
+ { 48, 0x00000000ul, 5}, // '0' 00000
+ { 49, 0x08000000ul, 5}, // '1' 00001
+ { 50, 0x10000000ul, 5}, // '2' 00010
+ { 51, 0x64000000ul, 6}, // '3' 011001
+ { 52, 0x68000000ul, 6}, // '4' 011010
+ { 53, 0x6c000000ul, 6}, // '5' 011011
+ { 54, 0x70000000ul, 6}, // '6' 011100
+ { 55, 0x74000000ul, 6}, // '7' 011101
+ { 56, 0x78000000ul, 6}, // '8' 011110
+ { 57, 0x7c000000ul, 6}, // '9' 011111
+ { 58, 0xb8000000ul, 7}, // ':' 1011100
+ { 59, 0xfb000000ul, 8}, // ';' 11111011
+ { 60, 0xfff80000ul, 15}, // '<' 11111111|1111100
+ { 61, 0x80000000ul, 6}, // '=' 100000
+ { 62, 0xffb00000ul, 12}, // '>' 11111111|1011
+ { 63, 0xff000000ul, 10}, // '?' 11111111|00
+ { 64, 0xffd00000ul, 13}, // '@' 11111111|11010
+ { 65, 0x84000000ul, 6}, // 'A' 100001
+ { 66, 0xba000000ul, 7}, // 'B' 1011101
+ { 67, 0xbc000000ul, 7}, // 'C' 1011110
+ { 68, 0xbe000000ul, 7}, // 'D' 1011111
+ { 69, 0xc0000000ul, 7}, // 'E' 1100000
+ { 70, 0xc2000000ul, 7}, // 'F' 1100001
+ { 71, 0xc4000000ul, 7}, // 'G' 1100010
+ { 72, 0xc6000000ul, 7}, // 'H' 1100011
+ { 73, 0xc8000000ul, 7}, // 'I' 1100100
+ { 74, 0xca000000ul, 7}, // 'J' 1100101
+ { 75, 0xcc000000ul, 7}, // 'K' 1100110
+ { 76, 0xce000000ul, 7}, // 'L' 1100111
+ { 77, 0xd0000000ul, 7}, // 'M' 1101000
+ { 78, 0xd2000000ul, 7}, // 'N' 1101001
+ { 79, 0xd4000000ul, 7}, // 'O' 1101010
+ { 80, 0xd6000000ul, 7}, // 'P' 1101011
+ { 81, 0xd8000000ul, 7}, // 'Q' 1101100
+ { 82, 0xda000000ul, 7}, // 'R' 1101101
+ { 83, 0xdc000000ul, 7}, // 'S' 1101110
+ { 84, 0xde000000ul, 7}, // 'T' 1101111
+ { 85, 0xe0000000ul, 7}, // 'U' 1110000
+ { 86, 0xe2000000ul, 7}, // 'V' 1110001
+ { 87, 0xe4000000ul, 7}, // 'W' 1110010
+ { 88, 0xfc000000ul, 8}, // 'X' 11111100
+ { 89, 0xe6000000ul, 7}, // 'Y' 1110011
+ { 90, 0xfd000000ul, 8}, // 'Z' 11111101
+ { 91, 0xffd80000ul, 13}, // '[' 11111111|11011
+ { 92, 0xfffe0000ul, 19}, // '\' 11111111|11111110|000
+ { 93, 0xffe00000ul, 13}, // ']' 11111111|11100
+ { 94, 0xfff00000ul, 14}, // '^' 11111111|111100
+ { 95, 0x88000000ul, 6}, // '_' 100010
+ { 96, 0xfffa0000ul, 15}, // '`' 11111111|1111101
+ { 97, 0x18000000ul, 5}, // 'a' 00011
+ { 98, 0x8c000000ul, 6}, // 'b' 100011
+ { 99, 0x20000000ul, 5}, // 'c' 00100
+ {100, 0x90000000ul, 6}, // 'd' 100100
+ {101, 0x28000000ul, 5}, // 'e' 00101
+ {102, 0x94000000ul, 6}, // 'f' 100101
+ {103, 0x98000000ul, 6}, // 'g' 100110
+ {104, 0x9c000000ul, 6}, // 'h' 100111
+ {105, 0x30000000ul, 5}, // 'i' 00110
+ {106, 0xe8000000ul, 7}, // 'j' 1110100
+ {107, 0xea000000ul, 7}, // 'k' 1110101
+ {108, 0xa0000000ul, 6}, // 'l' 101000
+ {109, 0xa4000000ul, 6}, // 'm' 101001
+ {110, 0xa8000000ul, 6}, // 'n' 101010
+ {111, 0x38000000ul, 5}, // 'o' 00111
+ {112, 0xac000000ul, 6}, // 'p' 101011
+ {113, 0xec000000ul, 7}, // 'q' 1110110
+ {114, 0xb0000000ul, 6}, // 'r' 101100
+ {115, 0x40000000ul, 5}, // 's' 01000
+ {116, 0x48000000ul, 5}, // 't' 01001
+ {117, 0xb4000000ul, 6}, // 'u' 101101
+ {118, 0xee000000ul, 7}, // 'v' 1110111
+ {119, 0xf0000000ul, 7}, // 'w' 1111000
+ {120, 0xf2000000ul, 7}, // 'x' 1111001
+ {121, 0xf4000000ul, 7}, // 'y' 1111010
+ {122, 0xf6000000ul, 7}, // 'z' 1111011
+ {123, 0xfffc0000ul, 15}, // '{' 11111111|1111110
+ {124, 0xff800000ul, 11}, // '|' 11111111|100
+ {125, 0xfff40000ul, 14}, // '}' 11111111|111101
+ {126, 0xffe80000ul, 13}, // '~' 11111111|11101
+ {127, 0xffffffc0ul, 28}, // 11111111|11111111|11111111|1100
+ {128, 0xfffe6000ul, 20}, // 11111111|11111110|0110
+ {129, 0xffff4800ul, 22}, // 11111111|11111111|010010
+ {130, 0xfffe7000ul, 20}, // 11111111|11111110|0111
+ {131, 0xfffe8000ul, 20}, // 11111111|11111110|1000
+ {132, 0xffff4c00ul, 22}, // 11111111|11111111|010011
+ {133, 0xffff5000ul, 22}, // 11111111|11111111|010100
+ {134, 0xffff5400ul, 22}, // 11111111|11111111|010101
+ {135, 0xffffb200ul, 23}, // 11111111|11111111|1011001
+ {136, 0xffff5800ul, 22}, // 11111111|11111111|010110
+ {137, 0xffffb400ul, 23}, // 11111111|11111111|1011010
+ {138, 0xffffb600ul, 23}, // 11111111|11111111|1011011
+ {139, 0xffffb800ul, 23}, // 11111111|11111111|1011100
+ {140, 0xffffba00ul, 23}, // 11111111|11111111|1011101
+ {141, 0xffffbc00ul, 23}, // 11111111|11111111|1011110
+ {142, 0xffffeb00ul, 24}, // 11111111|11111111|11101011
+ {143, 0xffffbe00ul, 23}, // 11111111|11111111|1011111
+ {144, 0xffffec00ul, 24}, // 11111111|11111111|11101100
+ {145, 0xffffed00ul, 24}, // 11111111|11111111|11101101
+ {146, 0xffff5c00ul, 22}, // 11111111|11111111|010111
+ {147, 0xffffc000ul, 23}, // 11111111|11111111|1100000
+ {148, 0xffffee00ul, 24}, // 11111111|11111111|11101110
+ {149, 0xffffc200ul, 23}, // 11111111|11111111|1100001
+ {150, 0xffffc400ul, 23}, // 11111111|11111111|1100010
+ {151, 0xffffc600ul, 23}, // 11111111|11111111|1100011
+ {152, 0xffffc800ul, 23}, // 11111111|11111111|1100100
+ {153, 0xfffee000ul, 21}, // 11111111|11111110|11100
+ {154, 0xffff6000ul, 22}, // 11111111|11111111|011000
+ {155, 0xffffca00ul, 23}, // 11111111|11111111|1100101
+ {156, 0xffff6400ul, 22}, // 11111111|11111111|011001
+ {157, 0xffffcc00ul, 23}, // 11111111|11111111|1100110
+ {158, 0xffffce00ul, 23}, // 11111111|11111111|1100111
+ {159, 0xffffef00ul, 24}, // 11111111|11111111|11101111
+ {160, 0xffff6800ul, 22}, // 11111111|11111111|011010
+ {161, 0xfffee800ul, 21}, // 11111111|11111110|11101
+ {162, 0xfffe9000ul, 20}, // 11111111|11111110|1001
+ {163, 0xffff6c00ul, 22}, // 11111111|11111111|011011
+ {164, 0xffff7000ul, 22}, // 11111111|11111111|011100
+ {165, 0xffffd000ul, 23}, // 11111111|11111111|1101000
+ {166, 0xffffd200ul, 23}, // 11111111|11111111|1101001
+ {167, 0xfffef000ul, 21}, // 11111111|11111110|11110
+ {168, 0xffffd400ul, 23}, // 11111111|11111111|1101010
+ {169, 0xffff7400ul, 22}, // 11111111|11111111|011101
+ {170, 0xffff7800ul, 22}, // 11111111|11111111|011110
+ {171, 0xfffff000ul, 24}, // 11111111|11111111|11110000
+ {172, 0xfffef800ul, 21}, // 11111111|11111110|11111
+ {173, 0xffff7c00ul, 22}, // 11111111|11111111|011111
+ {174, 0xffffd600ul, 23}, // 11111111|11111111|1101011
+ {175, 0xffffd800ul, 23}, // 11111111|11111111|1101100
+ {176, 0xffff0000ul, 21}, // 11111111|11111111|00000
+ {177, 0xffff0800ul, 21}, // 11111111|11111111|00001
+ {178, 0xffff8000ul, 22}, // 11111111|11111111|100000
+ {179, 0xffff1000ul, 21}, // 11111111|11111111|00010
+ {180, 0xffffda00ul, 23}, // 11111111|11111111|1101101
+ {181, 0xffff8400ul, 22}, // 11111111|11111111|100001
+ {182, 0xffffdc00ul, 23}, // 11111111|11111111|1101110
+ {183, 0xffffde00ul, 23}, // 11111111|11111111|1101111
+ {184, 0xfffea000ul, 20}, // 11111111|11111110|1010
+ {185, 0xffff8800ul, 22}, // 11111111|11111111|100010
+ {186, 0xffff8c00ul, 22}, // 11111111|11111111|100011
+ {187, 0xffff9000ul, 22}, // 11111111|11111111|100100
+ {188, 0xffffe000ul, 23}, // 11111111|11111111|1110000
+ {189, 0xffff9400ul, 22}, // 11111111|11111111|100101
+ {190, 0xffff9800ul, 22}, // 11111111|11111111|100110
+ {191, 0xffffe200ul, 23}, // 11111111|11111111|1110001
+ {192, 0xfffff800ul, 26}, // 11111111|11111111|11111000|00
+ {193, 0xfffff840ul, 26}, // 11111111|11111111|11111000|01
+ {194, 0xfffeb000ul, 20}, // 11111111|11111110|1011
+ {195, 0xfffe2000ul, 19}, // 11111111|11111110|001
+ {196, 0xffff9c00ul, 22}, // 11111111|11111111|100111
+ {197, 0xffffe400ul, 23}, // 11111111|11111111|1110010
+ {198, 0xffffa000ul, 22}, // 11111111|11111111|101000
+ {199, 0xfffff600ul, 25}, // 11111111|11111111|11110110|0
+ {200, 0xfffff880ul, 26}, // 11111111|11111111|11111000|10
+ {201, 0xfffff8c0ul, 26}, // 11111111|11111111|11111000|11
+ {202, 0xfffff900ul, 26}, // 11111111|11111111|11111001|00
+ {203, 0xfffffbc0ul, 27}, // 11111111|11111111|11111011|110
+ {204, 0xfffffbe0ul, 27}, // 11111111|11111111|11111011|111
+ {205, 0xfffff940ul, 26}, // 11111111|11111111|11111001|01
+ {206, 0xfffff100ul, 24}, // 11111111|11111111|11110001
+ {207, 0xfffff680ul, 25}, // 11111111|11111111|11110110|1
+ {208, 0xfffe4000ul, 19}, // 11111111|11111110|010
+ {209, 0xffff1800ul, 21}, // 11111111|11111111|00011
+ {210, 0xfffff980ul, 26}, // 11111111|11111111|11111001|10
+ {211, 0xfffffc00ul, 27}, // 11111111|11111111|11111100|000
+ {212, 0xfffffc20ul, 27}, // 11111111|11111111|11111100|001
+ {213, 0xfffff9c0ul, 26}, // 11111111|11111111|11111001|11
+ {214, 0xfffffc40ul, 27}, // 11111111|11111111|11111100|010
+ {215, 0xfffff200ul, 24}, // 11111111|11111111|11110010
+ {216, 0xffff2000ul, 21}, // 11111111|11111111|00100
+ {217, 0xffff2800ul, 21}, // 11111111|11111111|00101
+ {218, 0xfffffa00ul, 26}, // 11111111|11111111|11111010|00
+ {219, 0xfffffa40ul, 26}, // 11111111|11111111|11111010|01
+ {220, 0xffffffd0ul, 28}, // 11111111|11111111|11111111|1101
+ {221, 0xfffffc60ul, 27}, // 11111111|11111111|11111100|011
+ {222, 0xfffffc80ul, 27}, // 11111111|11111111|11111100|100
+ {223, 0xfffffca0ul, 27}, // 11111111|11111111|11111100|101
+ {224, 0xfffec000ul, 20}, // 11111111|11111110|1100
+ {225, 0xfffff300ul, 24}, // 11111111|11111111|11110011
+ {226, 0xfffed000ul, 20}, // 11111111|11111110|1101
+ {227, 0xffff3000ul, 21}, // 11111111|11111111|00110
+ {228, 0xffffa400ul, 22}, // 11111111|11111111|101001
+ {229, 0xffff3800ul, 21}, // 11111111|11111111|00111
+ {230, 0xffff4000ul, 21}, // 11111111|11111111|01000
+ {231, 0xffffe600ul, 23}, // 11111111|11111111|1110011
+ {232, 0xffffa800ul, 22}, // 11111111|11111111|101010
+ {233, 0xffffac00ul, 22}, // 11111111|11111111|101011
+ {234, 0xfffff700ul, 25}, // 11111111|11111111|11110111|0
+ {235, 0xfffff780ul, 25}, // 11111111|11111111|11110111|1
+ {236, 0xfffff400ul, 24}, // 11111111|11111111|11110100
+ {237, 0xfffff500ul, 24}, // 11111111|11111111|11110101
+ {238, 0xfffffa80ul, 26}, // 11111111|11111111|11111010|10
+ {239, 0xffffe800ul, 23}, // 11111111|11111111|1110100
+ {240, 0xfffffac0ul, 26}, // 11111111|11111111|11111010|11
+ {241, 0xfffffcc0ul, 27}, // 11111111|11111111|11111100|110
+ {242, 0xfffffb00ul, 26}, // 11111111|11111111|11111011|00
+ {243, 0xfffffb40ul, 26}, // 11111111|11111111|11111011|01
+ {244, 0xfffffce0ul, 27}, // 11111111|11111111|11111100|111
+ {245, 0xfffffd00ul, 27}, // 11111111|11111111|11111101|000
+ {246, 0xfffffd20ul, 27}, // 11111111|11111111|11111101|001
+ {247, 0xfffffd40ul, 27}, // 11111111|11111111|11111101|010
+ {248, 0xfffffd60ul, 27}, // 11111111|11111111|11111101|011
+ {249, 0xffffffe0ul, 28}, // 11111111|11111111|11111111|1110
+ {250, 0xfffffd80ul, 27}, // 11111111|11111111|11111101|100
+ {251, 0xfffffda0ul, 27}, // 11111111|11111111|11111101|101
+ {252, 0xfffffdc0ul, 27}, // 11111111|11111111|11111101|110
+ {253, 0xfffffde0ul, 27}, // 11111111|11111111|11111101|111
+ {254, 0xfffffe00ul, 27}, // 11111111|11111111|11111110|000
+ {255, 0xfffffb80ul, 26}, // 11111111|11111111|11111011|10
+ {256, 0xfffffffcul, 30} // EOS 11111111|11111111|11111111|111111
+};
+
+void write_huffman_code(BitOStream &outputStream, const CodeEntry &code)
+{
+ // Append octet by octet.
+ auto bitLength = code.bitLength;
+ const auto hc = code.huffmanCode >> (32 - bitLength);
+
+ if (bitLength > 24) {
+ outputStream.writeBits(uchar(hc >> 24), bitLength - 24);
+ bitLength = 24;
+ }
+
+ if (bitLength > 16) {
+ outputStream.writeBits(uchar(hc >> 16), bitLength - 16);
+ bitLength = 16;
+ }
+
+ if (bitLength > 8) {
+ outputStream.writeBits(uchar(hc >> 8), bitLength - 8);
+ bitLength = 8;
+ }
+
+ outputStream.writeBits(uchar(hc), bitLength);
+}
+
+}
+
+// That's from HPACK's specs - we deal with octets.
+static_assert(std::numeric_limits<uchar>::digits == 8, "octets expected");
+
+quint64 huffman_encoded_bit_length(const QByteArray &inputData)
+{
+ quint64 bitLength = 0;
+ for (int i = 0, e = inputData.size(); i < e; ++i)
+ bitLength += staticHuffmanCodeTable[int(inputData[i])].bitLength;
+
+ return bitLength;
+}
+
+void huffman_encode_string(const QByteArray &inputData, BitOStream &outputStream)
+{
+ for (int i = 0, e = inputData.size(); i < e; ++i)
+ write_huffman_code(outputStream, staticHuffmanCodeTable[int(inputData[i])]);
+
+ // Pad bits ...
+ if (outputStream.bitLength() % 8)
+ outputStream.writeBits(0xff, 8 - outputStream.bitLength() % 8);
+}
+
+bool padding_is_valid(quint32 chunk, quint32 nBits)
+{
+ Q_ASSERT(nBits);
+
+ // HPACK, 5.2: "A padding strictly longer than 7 bits MUST be
+ // treated as a decoding error."
+ if (nBits > 7)
+ return false;
+ // HPACK, 5.2:
+ // "A padding not corresponding to the most significant bits
+ // of the code for the EOS symbol MUST be treated as a decoding error."
+ return (chunk >> (32 - nBits)) == quint32((1 << nBits) - 1);
+}
+
+HuffmanDecoder::HuffmanDecoder()
+ : minCodeLength()
+{
+ const auto nCodes = sizeof staticHuffmanCodeTable / sizeof staticHuffmanCodeTable[0];
+
+ std::vector<CodeEntry> symbols(staticHuffmanCodeTable, staticHuffmanCodeTable + nCodes);
+ // Now we sort: by bit length first (in the descending order) and by the symbol
+ // value (descending). Descending order: to make sure we do not create prefix tables with
+ // short 'indexLength' first and having longer codes that do not fit into such tables later.
+ std::sort(symbols.begin(), symbols.end(), [](const CodeEntry &code1, const CodeEntry &code2) {
+ if (code1.bitLength == code2.bitLength)
+ return code1.byteValue > code2.byteValue;
+ return code1.bitLength > code2.bitLength;
+ });
+
+ minCodeLength = symbols.back().bitLength; // The shortest one, currently it's 5.
+
+ // TODO: add a verification - Huffman codes
+ // within a given bit length range also
+ // should be in descending order.
+
+ // Initialize 'prefixTables' and 'tableData'.
+ addTable(0, quint32(BitConstants::rootPrefix)); // 'root' table.
+
+ for (const auto &s : symbols) {
+ quint32 tableIndex = 0;
+ while (true) {
+ Q_ASSERT(tableIndex < prefixTables.size());
+ // Note, by value - since prefixTables will be updated in between.
+ const auto table = prefixTables[tableIndex];
+ // We skip prefixed bits (if any) and use indexed bits only:
+ const auto entryIndex = s.huffmanCode << table.prefixLength >> (32 - table.indexLength);
+ // Again, by value.
+ PrefixTableEntry entry = tableEntry(table, entryIndex);
+ // How many bits were coded by previous tables and this table:
+ const auto codedLength = table.prefixLength + table.indexLength;
+ if (codedLength < s.bitLength) {
+ // We have to add a new prefix table ... (if it's not done yet).
+ if (!entry.bitLength) {
+ entry.nextTable = addTable(codedLength, std::min<quint32>(quint32(BitConstants::childPrefix),
+ s.bitLength - codedLength));
+ entry.bitLength = s.bitLength;
+ entry.byteValue = s.byteValue;
+ setTableEntry(table, entryIndex, entry);
+ }
+ tableIndex = entry.nextTable;
+ } else {
+ // We found the slot for our code (terminal entry):
+ entry.byteValue = s.byteValue;
+ entry.bitLength = s.bitLength;
+ // Refer to our own table as 'nextTable':
+ entry.nextTable = tableIndex;
+ setTableEntry(table, entryIndex, entry);
+ break;
+ }
+ }
+ }
+
+ // Now, we have a table(s) and have to fill 'holes' to
+ // 'fix' terminal entries.
+ for (const auto &table : prefixTables) {
+ const quint32 codedLength = table.prefixLength + table.indexLength;
+ for (quint32 j = 0; j < table.size();) {
+ const PrefixTableEntry &entry = tableEntry(table, j);
+ if (entry.bitLength && entry.bitLength < codedLength) {
+ const quint32 range = 1 << (codedLength - entry.bitLength);
+ for (quint32 k = 1; k < range; ++k)
+ setTableEntry(table, j + k, entry);
+ j += range;
+ } else {
+ ++j;
+ }
+ }
+ }
+}
+
+bool HuffmanDecoder::decodeStream(BitIStream &inputStream, QByteArray &outputBuffer)
+{
+ while (true) {
+ quint32 chunk = 0;
+ const quint32 readBits = inputStream.peekBits(inputStream.streamOffset(), 32, &chunk);
+ if (!readBits)
+ return !inputStream.hasMoreBits();
+
+ if (readBits < minCodeLength) {
+ inputStream.skipBits(readBits);
+ return padding_is_valid(chunk, readBits);
+ }
+
+ quint32 tableIndex = 0;
+ const PrefixTable *table = &prefixTables[tableIndex];
+ quint32 entryIndex = chunk >> (32 - table->indexLength);
+ PrefixTableEntry entry = tableEntry(*table, entryIndex);
+
+ while (true) {
+ if (entry.nextTable == tableIndex)
+ break;
+
+ tableIndex = entry.nextTable;
+ table = &prefixTables[tableIndex];
+ entryIndex = chunk << table->prefixLength >> (32 - table->indexLength);
+ entry = tableEntry(*table, entryIndex);
+ }
+
+ if (entry.bitLength > readBits) {
+ inputStream.skipBits(readBits);
+ return padding_is_valid(chunk, readBits);
+ }
+
+ if (!entry.bitLength || entry.byteValue == 256) {
+ //EOS (256) == compression error (HPACK).
+ inputStream.skipBits(readBits);
+ return false;
+ }
+
+ outputBuffer.append(entry.byteValue);
+ inputStream.skipBits(entry.bitLength);
+ }
+
+ return false;
+}
+
+quint32 HuffmanDecoder::addTable(quint32 prefix, quint32 index)
+{
+ PrefixTable newTable{prefix, index};
+ newTable.offset = quint32(tableData.size());
+ prefixTables.push_back(newTable);
+ // Add entries for this table:
+ tableData.resize(tableData.size() + newTable.size());
+
+ return quint32(prefixTables.size() - 1);
+}
+
+PrefixTableEntry HuffmanDecoder::tableEntry(const PrefixTable &table, quint32 index)
+{
+ Q_ASSERT(index < table.size());
+ return tableData[table.offset + index];
+}
+
+void HuffmanDecoder::setTableEntry(const PrefixTable &table, quint32 index,
+ const PrefixTableEntry &entry)
+{
+ Q_ASSERT(index < table.size());
+ tableData[table.offset + index] = entry;
+}
+
+bool huffman_decode_string(BitIStream &inputStream, QByteArray *outputBuffer)
+{
+ Q_ASSERT(outputBuffer);
+
+ static HuffmanDecoder decoder;
+ return decoder.decodeStream(inputStream, *outputBuffer);
+}
+
+}
+
+QT_END_NAMESPACE
diff --git a/src/network/access/http2/huffman_p.h b/src/network/access/http2/huffman_p.h
new file mode 100644
index 0000000000..7195661664
--- /dev/null
+++ b/src/network/access/http2/huffman_p.h
@@ -0,0 +1,182 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HUFFMAN_P_H
+#define HUFFMAN_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+class QByteArray;
+
+namespace HPack
+{
+
+struct CodeEntry
+{
+ CodeEntry() : byteValue(),
+ huffmanCode(),
+ bitLength()
+ {
+ }
+
+ CodeEntry(quint32 val, quint32 code, quint32 len)
+ : byteValue(val),
+ huffmanCode(code),
+ bitLength(len)
+ {
+ }
+
+ quint32 byteValue;
+ quint32 huffmanCode;
+ quint32 bitLength;
+};
+
+class BitOStream;
+
+quint64 huffman_encoded_bit_length(const QByteArray &inputData);
+void huffman_encode_string(const QByteArray &inputData, BitOStream &outputStream);
+
+// PrefixTable:
+// Huffman codes with a small bit length
+// fit into a table (these are 'terminal' symbols),
+// codes with longer codes require additional
+// tables, so several symbols will have the same index
+// in a table - pointing into the next table.
+// Every table has an 'indexLength' - that's
+// how many bits can fit in table's indices +
+// 'prefixLength' - how many bits were addressed
+// by its 'parent' table(s).
+// All PrefixTables are kept in 'prefixTables' array.
+// PrefixTable itself does not have any entries,
+// it just holds table's prefix/index + 'offset' -
+// there table's data starts in an array of all
+// possible entries ('tableData').
+
+struct PrefixTable
+{
+ PrefixTable()
+ : prefixLength(),
+ indexLength(),
+ offset()
+ {
+ }
+
+ PrefixTable(quint32 prefix, quint32 index)
+ : prefixLength(prefix),
+ indexLength(index),
+ offset()
+ {
+ }
+
+ quint32 size()const
+ {
+ // Number of entries table contains:
+ return 1 << indexLength;
+ }
+
+ quint32 prefixLength;
+ quint32 indexLength;
+ quint32 offset;
+};
+
+// Table entry is either a terminal entry (thus probably the code found)
+// or points into another table ('nextTable' - index into
+// 'prefixTables' array). If it's a terminal, 'nextTable' index
+// refers to the same table.
+
+struct PrefixTableEntry
+{
+ PrefixTableEntry()
+ : bitLength(),
+ nextTable(),
+ byteValue()
+ {
+ }
+
+ quint32 bitLength;
+ quint32 nextTable;
+ quint32 byteValue;
+};
+
+class BitIStream;
+
+class HuffmanDecoder
+{
+public:
+ enum class BitConstants
+ {
+ rootPrefix = 9,
+ childPrefix = 6
+ };
+
+ HuffmanDecoder();
+
+ bool decodeStream(BitIStream &inputStream, QByteArray &outputBuffer);
+
+private:
+ quint32 addTable(quint32 prefixLength, quint32 indexLength);
+ PrefixTableEntry tableEntry(const PrefixTable &table, quint32 index);
+ void setTableEntry(const PrefixTable &table, quint32 index, const PrefixTableEntry &entry);
+
+ std::vector<PrefixTable> prefixTables;
+ std::vector<PrefixTableEntry> tableData;
+ quint32 minCodeLength;
+};
+
+bool huffman_decode_string(BitIStream &inputStream, QByteArray *outputBuffer);
+
+} // namespace HPack
+
+QT_END_NAMESPACE
+
+#endif
+
diff --git a/src/network/access/qabstractnetworkcache.h b/src/network/access/qabstractnetworkcache.h
index 6b80147757..33b0bc4ce3 100644
--- a/src/network/access/qabstractnetworkcache.h
+++ b/src/network/access/qabstractnetworkcache.h
@@ -40,6 +40,7 @@
#ifndef QABSTRACTNETWORKCACHE_H
#define QABSTRACTNETWORKCACHE_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qshareddata.h>
#include <QtCore/qpair.h>
diff --git a/src/network/access/qabstractnetworkcache_p.h b/src/network/access/qabstractnetworkcache_p.h
index 7be89f22b6..fee723e315 100644
--- a/src/network/access/qabstractnetworkcache_p.h
+++ b/src/network/access/qabstractnetworkcache_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "private/qobject_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/network/access/qabstractprotocolhandler_p.h b/src/network/access/qabstractprotocolhandler_p.h
index a05df3e429..30814d6737 100644
--- a/src/network/access/qabstractprotocolhandler_p.h
+++ b/src/network/access/qabstractprotocolhandler_p.h
@@ -51,9 +51,9 @@
// We mean it.
//
-#ifndef QT_NO_HTTP
+#include <QtNetwork/private/qtnetworkglobal_p.h>
-#include <QtCore/qglobal.h>
+#ifndef QT_NO_HTTP
QT_BEGIN_NAMESPACE
diff --git a/src/network/access/qftp_p.h b/src/network/access/qftp_p.h
index 37f8f2f8d2..6cf5116798 100644
--- a/src/network/access/qftp_p.h
+++ b/src/network/access/qftp_p.h
@@ -48,9 +48,10 @@
// We mean it.
//
-#ifndef QFTP_H
-#define QFTP_H
+#ifndef QFTP_P_H
+#define QFTP_P_H
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include <QtCore/qstring.h>
#include <private/qurlinfo_p.h>
#include <QtCore/qobject.h>
@@ -172,4 +173,4 @@ private:
QT_END_NAMESPACE
-#endif // QFTP_H
+#endif // QFTP_P_H
diff --git a/src/network/access/qhttp2protocolhandler.cpp b/src/network/access/qhttp2protocolhandler.cpp
new file mode 100644
index 0000000000..f50224f64a
--- /dev/null
+++ b/src/network/access/qhttp2protocolhandler.cpp
@@ -0,0 +1,1213 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qhttpnetworkconnection_p.h"
+#include "qhttp2protocolhandler_p.h"
+
+#if !defined(QT_NO_HTTP)
+
+#include "http2/bitstreams_p.h"
+
+#include <private/qnoncontiguousbytedevice_p.h>
+
+#include <QtNetwork/qabstractsocket.h>
+#include <QtCore/qloggingcategory.h>
+#include <QtCore/qendian.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qurl.h>
+
+#include <algorithm>
+#include <vector>
+
+QT_BEGIN_NAMESPACE
+
+namespace
+{
+
+HPack::HttpHeader build_headers(const QHttpNetworkRequest &request, quint32 maxHeaderListSize)
+{
+ using namespace HPack;
+
+ HttpHeader header;
+ header.reserve(300);
+
+ // 1. Before anything - mandatory fields, if they do not fit into maxHeaderList -
+ // then stop immediately with error.
+ const auto auth = request.url().authority(QUrl::FullyEncoded | QUrl::RemoveUserInfo).toLatin1();
+ header.push_back(HeaderField(":authority", auth));
+ header.push_back(HeaderField(":method", request.methodName()));
+ header.push_back(HeaderField(":path", request.uri(false)));
+ header.push_back(HeaderField(":scheme", request.url().scheme().toLatin1()));
+
+ HeaderSize size = header_size(header);
+ if (!size.first) // Ooops!
+ return HttpHeader();
+
+ if (size.second > maxHeaderListSize)
+ return HttpHeader(); // Bad, we cannot send this request ...
+
+ for (const auto &field : request.header()) {
+ const HeaderSize delta = entry_size(field.first, field.second);
+ if (!delta.first) // Overflow???
+ break;
+ if (std::numeric_limits<quint32>::max() - delta.second < size.second)
+ break;
+ size.second += delta.second;
+ if (size.second > maxHeaderListSize)
+ break;
+
+ QByteArray key(field.first.toLower());
+ if (key == "connection" || key == "host" || key == "keep-alive"
+ || key == "proxy-connection" || key == "transfer-encoding")
+ continue; // Those headers are not valid (section 3.2.1) - from QSpdyProtocolHandler
+ // TODO: verify with specs, which fields are valid to send ....
+ // toLower - 8.1.2 .... "header field names MUST be converted to lowercase prior
+ // to their encoding in HTTP/2.
+ // A request or response containing uppercase header field names
+ // MUST be treated as malformed (Section 8.1.2.6)".
+ header.push_back(HeaderField(key, field.second));
+ }
+
+ return header;
+}
+
+bool sum_will_overflow(qint32 windowSize, qint32 delta)
+{
+ if (windowSize > 0)
+ return std::numeric_limits<qint32>::max() - windowSize < delta;
+ return std::numeric_limits<qint32>::min() - windowSize > delta;
+}
+
+}// Unnamed namespace
+
+// Since we anyway end up having this in every function definition:
+using namespace Http2;
+
+const std::deque<quint32>::size_type QHttp2ProtocolHandler::maxRecycledStreams = 10000;
+const qint32 QHttp2ProtocolHandler::sessionMaxRecvWindowSize;
+const qint32 QHttp2ProtocolHandler::streamInitialRecvWindowSize;
+const quint32 QHttp2ProtocolHandler::maxAcceptableTableSize;
+
+QHttp2ProtocolHandler::QHttp2ProtocolHandler(QHttpNetworkConnectionChannel *channel)
+ : QAbstractProtocolHandler(channel),
+ decoder(HPack::FieldLookupTable::DefaultSize),
+ encoder(HPack::FieldLookupTable::DefaultSize, true)
+{
+ continuedFrames.reserve(20);
+}
+
+void QHttp2ProtocolHandler::_q_uploadDataReadyRead()
+{
+ auto data = qobject_cast<QNonContiguousByteDevice *>(sender());
+ Q_ASSERT(data);
+ const qint32 streamID = data->property("HTTP2StreamID").toInt();
+ Q_ASSERT(activeStreams.contains(streamID));
+ auto &stream = activeStreams[streamID];
+
+ if (!sendDATA(stream)) {
+ finishStreamWithError(stream, QNetworkReply::UnknownNetworkError,
+ QLatin1String("failed to send DATA"));
+ sendRST_STREAM(streamID, INTERNAL_ERROR);
+ markAsReset(streamID);
+ deleteActiveStream(streamID);
+ }
+}
+
+void QHttp2ProtocolHandler::_q_replyDestroyed(QObject *reply)
+{
+ const quint32 streamID = reply->property("HTTP2StreamID").toInt();
+ if (activeStreams.contains(streamID)) {
+ sendRST_STREAM(streamID, CANCEL);
+ markAsReset(streamID);
+ deleteActiveStream(streamID);
+ }
+}
+
+void QHttp2ProtocolHandler::_q_readyRead()
+{
+ _q_receiveReply();
+}
+
+void QHttp2ProtocolHandler::_q_receiveReply()
+{
+ Q_ASSERT(m_socket);
+ Q_ASSERT(m_channel);
+
+ do {
+ const auto result = inboundFrame.read(*m_socket);
+ switch (result) {
+ case FrameStatus::incompleteFrame:
+ return;
+ case FrameStatus::protocolError:
+ return connectionError(PROTOCOL_ERROR, "invalid frame");
+ case FrameStatus::sizeError:
+ return connectionError(FRAME_SIZE_ERROR, "invalid frame size");
+ default:
+ break;
+ }
+
+ Q_ASSERT(result == FrameStatus::goodFrame);
+
+ if (continuationExpected && inboundFrame.type != FrameType::CONTINUATION)
+ return connectionError(PROTOCOL_ERROR, "CONTINUATION expected");
+
+ switch (inboundFrame.type) {
+ case FrameType::DATA:
+ handleDATA();
+ break;
+ case FrameType::HEADERS:
+ handleHEADERS();
+ break;
+ case FrameType::PRIORITY:
+ handlePRIORITY();
+ break;
+ case FrameType::RST_STREAM:
+ handleRST_STREAM();
+ break;
+ case FrameType::SETTINGS:
+ handleSETTINGS();
+ break;
+ case FrameType::PUSH_PROMISE:
+ handlePUSH_PROMISE();
+ break;
+ case FrameType::PING:
+ handlePING();
+ break;
+ case FrameType::GOAWAY:
+ handleGOAWAY();
+ break;
+ case FrameType::WINDOW_UPDATE:
+ handleWINDOW_UPDATE();
+ break;
+ case FrameType::CONTINUATION:
+ handleCONTINUATION();
+ break;
+ case FrameType::LAST_FRAME_TYPE:
+ // 5.1 - ignore unknown frames.
+ break;
+ }
+ } while (!goingAway || activeStreams.size());
+}
+
+bool QHttp2ProtocolHandler::sendRequest()
+{
+ if (goingAway)
+ return false;
+
+ if (!prefaceSent && !sendClientPreface())
+ return false;
+
+ auto &requests = m_channel->spdyRequestsToSend;
+ if (!requests.size())
+ return true;
+
+ const auto streamsToUse = std::min<quint32>(maxConcurrentStreams - activeStreams.size(),
+ requests.size());
+ auto it = requests.begin();
+ m_channel->state = QHttpNetworkConnectionChannel::WritingState;
+ for (quint32 i = 0; i < streamsToUse; ++i) {
+ const qint32 newStreamID = createNewStream(*it);
+ if (!newStreamID) {
+ // TODO: actually we have to open a new connection.
+ qCCritical(QT_HTTP2, "sendRequest: out of stream IDs");
+ break;
+ }
+
+ it = requests.erase(it);
+
+ Stream &newStream = activeStreams[newStreamID];
+ if (!sendHEADERS(newStream)) {
+ finishStreamWithError(newStream, QNetworkReply::UnknownNetworkError,
+ QLatin1String("failed to send HEADERS frame(s)"));
+ deleteActiveStream(newStreamID);
+ continue;
+ }
+
+ if (newStream.data() && !sendDATA(newStream)) {
+ finishStreamWithError(newStream, QNetworkReply::UnknownNetworkError,
+ QLatin1String("failed to send DATA frame(s)"));
+ sendRST_STREAM(newStreamID, INTERNAL_ERROR);
+ markAsReset(newStreamID);
+ deleteActiveStream(newStreamID);
+ }
+ }
+
+ m_channel->state = QHttpNetworkConnectionChannel::IdleState;
+
+ return true;
+}
+
+
+bool QHttp2ProtocolHandler::sendClientPreface()
+{
+ // 3.5 HTTP/2 Connection Preface
+ Q_ASSERT(m_socket);
+
+ if (prefaceSent)
+ return true;
+
+ const qint64 written = m_socket->write(Http2clientPreface,
+ Http2::clientPrefaceLength);
+ if (written != Http2::clientPrefaceLength)
+ return false;
+
+ // 6.5 SETTINGS
+ outboundFrame.start(FrameType::SETTINGS, FrameFlag::EMPTY, Http2::connectionStreamID);
+ // MAX frame size (16 kb), disable PUSH
+ outboundFrame.append(Settings::MAX_FRAME_SIZE_ID);
+ outboundFrame.append(quint32(Http2::maxFrameSize));
+ outboundFrame.append(Settings::ENABLE_PUSH_ID);
+ outboundFrame.append(quint32(0));
+
+ if (!outboundFrame.write(*m_socket))
+ return false;
+
+ sessionRecvWindowSize = sessionMaxRecvWindowSize;
+ if (defaultSessionWindowSize < sessionMaxRecvWindowSize) {
+ const auto delta = sessionMaxRecvWindowSize - defaultSessionWindowSize;
+ if (!sendWINDOW_UPDATE(connectionStreamID, delta))
+ return false;
+ }
+
+ prefaceSent = true;
+ waitingForSettingsACK = true;
+
+ return true;
+}
+
+bool QHttp2ProtocolHandler::sendSETTINGS_ACK()
+{
+ Q_ASSERT(m_socket);
+
+ if (!prefaceSent && !sendClientPreface())
+ return false;
+
+ outboundFrame.start(FrameType::SETTINGS, FrameFlag::ACK, Http2::connectionStreamID);
+
+ return outboundFrame.write(*m_socket);
+}
+
+bool QHttp2ProtocolHandler::sendHEADERS(Stream &stream)
+{
+ using namespace HPack;
+
+ outboundFrame.start(FrameType::HEADERS, FrameFlag::PRIORITY | FrameFlag::END_HEADERS,
+ stream.streamID);
+
+ if (!stream.data()) {
+ outboundFrame.addFlag(FrameFlag::END_STREAM);
+ stream.state = Stream::halfClosedLocal;
+ } else {
+ stream.state = Stream::open;
+ }
+
+ outboundFrame.append(quint32()); // No stream dependency in Qt.
+ outboundFrame.append(stream.weight());
+
+ const auto headers = build_headers(stream.request(), maxHeaderListSize);
+ if (!headers.size()) // nothing fits into maxHeaderListSize
+ return false;
+
+ // Compress in-place:
+ BitOStream outputStream(outboundFrame.frameBuffer);
+ if (!encoder.encodeRequest(outputStream, headers))
+ return false;
+
+ return outboundFrame.writeHEADERS(*m_socket, maxFrameSize);
+}
+
+bool QHttp2ProtocolHandler::sendDATA(Stream &stream)
+{
+ Q_ASSERT(maxFrameSize > frameHeaderSize);
+ Q_ASSERT(m_socket);
+ Q_ASSERT(stream.data());
+
+ const auto &request = stream.request();
+ auto reply = stream.reply();
+ Q_ASSERT(reply);
+ const auto replyPrivate = reply->d_func();
+ Q_ASSERT(replyPrivate);
+
+ auto slot = std::min<qint32>(sessionSendWindowSize, stream.sendWindow);
+ while (!stream.data()->atEnd() && slot) {
+ qint64 chunkSize = 0;
+ const uchar *src =
+ reinterpret_cast<const uchar *>(stream.data()->readPointer(slot, chunkSize));
+
+ if (chunkSize == -1)
+ return false;
+
+ if (!src || !chunkSize) {
+ // Stream is not suspended by the flow control,
+ // we do not have data ready yet.
+ return true;
+ }
+
+ outboundFrame.start(FrameType::DATA, FrameFlag::EMPTY, stream.streamID);
+ const qint32 bytesWritten = std::min<qint32>(slot, chunkSize);
+
+ if (!outboundFrame.writeDATA(*m_socket, maxFrameSize, src, bytesWritten))
+ return false;
+
+ stream.data()->advanceReadPointer(bytesWritten);
+ stream.sendWindow -= bytesWritten;
+ sessionSendWindowSize -= bytesWritten;
+ replyPrivate->totallyUploadedData += bytesWritten;
+ emit reply->dataSendProgress(replyPrivate->totallyUploadedData,
+ request.contentLength());
+ slot = std::min(sessionSendWindowSize, stream.sendWindow);
+ }
+
+ if (replyPrivate->totallyUploadedData == request.contentLength()) {
+ outboundFrame.start(FrameType::DATA, FrameFlag::END_STREAM, stream.streamID);
+ outboundFrame.setPayloadSize(0);
+ outboundFrame.write(*m_socket);
+ stream.state = Stream::halfClosedLocal;
+ stream.data()->disconnect(this);
+ removeFromSuspended(stream.streamID);
+ } else if (!stream.data()->atEnd()) {
+ addToSuspended(stream);
+ }
+
+ return true;
+}
+
+bool QHttp2ProtocolHandler::sendWINDOW_UPDATE(quint32 streamID, quint32 delta)
+{
+ Q_ASSERT(m_socket);
+
+ outboundFrame.start(FrameType::WINDOW_UPDATE, FrameFlag::EMPTY, streamID);
+ outboundFrame.append(delta);
+ return outboundFrame.write(*m_socket);
+}
+
+bool QHttp2ProtocolHandler::sendRST_STREAM(quint32 streamID, quint32 errorCode)
+{
+ Q_ASSERT(m_socket);
+
+ outboundFrame.start(FrameType::RST_STREAM, FrameFlag::EMPTY, streamID);
+ outboundFrame.append(errorCode);
+ return outboundFrame.write(*m_socket);
+}
+
+bool QHttp2ProtocolHandler::sendGOAWAY(quint32 errorCode)
+{
+ Q_ASSERT(m_socket);
+
+ outboundFrame.start(FrameType::GOAWAY, FrameFlag::EMPTY, connectionStreamID);
+ outboundFrame.append(quint32(connectionStreamID));
+ outboundFrame.append(errorCode);
+ return outboundFrame.write(*m_socket);
+}
+
+void QHttp2ProtocolHandler::handleDATA()
+{
+ Q_ASSERT(inboundFrame.type == FrameType::DATA);
+
+ const auto streamID = inboundFrame.streamID;
+ if (streamID == connectionStreamID)
+ return connectionError(PROTOCOL_ERROR, "DATA on stream 0x0");
+
+ if (!activeStreams.contains(streamID) && !streamWasReset(streamID))
+ return connectionError(ENHANCE_YOUR_CALM, "DATA on invalid stream");
+
+ if (qint32(inboundFrame.payloadSize) > sessionRecvWindowSize)
+ return connectionError(FLOW_CONTROL_ERROR, "Flow control error");
+
+ sessionRecvWindowSize -= inboundFrame.payloadSize;
+
+ if (activeStreams.contains(streamID)) {
+ auto &stream = activeStreams[streamID];
+
+ if (qint32(inboundFrame.payloadSize) > stream.recvWindow) {
+ finishStreamWithError(stream, QNetworkReply::ProtocolInvalidOperationError,
+ QLatin1String("flow control error"));
+ sendRST_STREAM(streamID, FLOW_CONTROL_ERROR);
+ markAsReset(streamID);
+ deleteActiveStream(streamID);
+ } else {
+ stream.recvWindow -= inboundFrame.payloadSize;
+ // Uncompress data if needed and append it ...
+ updateStream(stream, inboundFrame);
+
+ if (inboundFrame.flags.testFlag(FrameFlag::END_STREAM)) {
+ finishStream(stream);
+ deleteActiveStream(stream.streamID);
+ } else if (stream.recvWindow < streamInitialRecvWindowSize / 2) {
+ QMetaObject::invokeMethod(this, "sendWINDOW_UPDATE", Qt::QueuedConnection,
+ Q_ARG(quint32, stream.streamID),
+ Q_ARG(quint32, streamInitialRecvWindowSize - stream.recvWindow));
+ stream.recvWindow = streamInitialRecvWindowSize;
+ }
+ }
+ }
+
+ if (sessionRecvWindowSize < sessionMaxRecvWindowSize / 2) {
+ QMetaObject::invokeMethod(this, "sendWINDOW_UPDATE", Qt::QueuedConnection,
+ Q_ARG(quint32, connectionStreamID),
+ Q_ARG(quint32, sessionMaxRecvWindowSize - sessionRecvWindowSize));
+ sessionRecvWindowSize = sessionMaxRecvWindowSize;
+ }
+}
+
+void QHttp2ProtocolHandler::handleHEADERS()
+{
+ Q_ASSERT(inboundFrame.type == FrameType::HEADERS);
+
+ const auto streamID = inboundFrame.streamID;
+ if (streamID == connectionStreamID)
+ return connectionError(PROTOCOL_ERROR, "HEADERS on 0x0 stream");
+
+ if (!activeStreams.contains(streamID) && !streamWasReset(streamID))
+ return connectionError(ENHANCE_YOUR_CALM, "HEADERS on invalid stream");
+
+ if (inboundFrame.flags.testFlag(FrameFlag::PRIORITY)) {
+ handlePRIORITY();
+ if (goingAway)
+ return;
+ }
+
+ const bool endHeaders = inboundFrame.flags.testFlag(FrameFlag::END_HEADERS);
+ continuedFrames.clear();
+ continuedFrames.push_back(std::move(inboundFrame));
+ if (!endHeaders) {
+ continuationExpected = true;
+ return;
+ }
+
+ handleContinuedHEADERS();
+}
+
+void QHttp2ProtocolHandler::handlePRIORITY()
+{
+ Q_ASSERT(inboundFrame.type == FrameType::PRIORITY ||
+ inboundFrame.type == FrameType::HEADERS);
+
+ const auto streamID = inboundFrame.streamID;
+ if (streamID == connectionStreamID)
+ return connectionError(PROTOCOL_ERROR, "PIRORITY on 0x0 stream");
+
+ if (!activeStreams.contains(streamID) && !streamWasReset(streamID))
+ return connectionError(ENHANCE_YOUR_CALM, "PRIORITY on invalid stream");
+
+ quint32 streamDependency = 0;
+ uchar weight = 0;
+ const bool noErr = inboundFrame.priority(&streamDependency, &weight);
+ Q_UNUSED(noErr) Q_ASSERT(noErr);
+
+
+ const bool exclusive = streamDependency & 0x80000000;
+ streamDependency &= ~0x80000000;
+
+ // Ignore this for now ...
+ // Can be used for streams (re)prioritization - 5.3
+ Q_UNUSED(exclusive);
+ Q_UNUSED(weight);
+}
+
+void QHttp2ProtocolHandler::handleRST_STREAM()
+{
+ Q_ASSERT(inboundFrame.type == FrameType::RST_STREAM);
+
+ // "RST_STREAM frames MUST be associated with a stream.
+ // If a RST_STREAM frame is received with a stream identifier of 0x0,
+ // the recipient MUST treat this as a connection error (Section 5.4.1)
+ // of type PROTOCOL_ERROR.
+ if (inboundFrame.streamID == connectionStreamID)
+ return connectionError(PROTOCOL_ERROR, "RST_STREAM on 0x0");
+
+ if (!(inboundFrame.streamID & 0x1)) {
+ // RST_STREAM on a promised stream:
+ // since we do not keep track of such streams,
+ // just ignore.
+ return;
+ }
+
+ if (inboundFrame.streamID >= nextID) {
+ // "RST_STREAM frames MUST NOT be sent for a stream
+ // in the "idle" state. .. the recipient MUST treat this
+ // as a connection error (Section 5.4.1) of type PROTOCOL_ERROR."
+ return connectionError(PROTOCOL_ERROR, "RST_STREAM on idle stream");
+ }
+
+ if (!activeStreams.contains(inboundFrame.streamID)) {
+ // 'closed' stream, ignore.
+ return;
+ }
+
+ Q_ASSERT(inboundFrame.dataSize() == 4);
+
+ Stream &stream = activeStreams[inboundFrame.streamID];
+ finishStreamWithError(stream, qFromBigEndian<quint32>(inboundFrame.dataBegin()));
+ markAsReset(stream.streamID);
+ deleteActiveStream(stream.streamID);
+}
+
+void QHttp2ProtocolHandler::handleSETTINGS()
+{
+ // 6.5 SETTINGS.
+ Q_ASSERT(inboundFrame.type == FrameType::SETTINGS);
+
+ if (inboundFrame.streamID != connectionStreamID)
+ return connectionError(PROTOCOL_ERROR, "SETTINGS on invalid stream");
+
+ if (inboundFrame.flags.testFlag(FrameFlag::ACK)) {
+ if (!waitingForSettingsACK)
+ return connectionError(PROTOCOL_ERROR, "unexpected SETTINGS ACK");
+ waitingForSettingsACK = false;
+ return;
+ }
+
+ if (inboundFrame.dataSize()) {
+ auto src = inboundFrame.dataBegin();
+ for (const uchar *end = src + inboundFrame.dataSize(); src != end; src += 6) {
+ const Settings identifier = Settings(qFromBigEndian<quint16>(src));
+ const quint32 intVal = qFromBigEndian<quint32>(src + 2);
+ if (!acceptSetting(identifier, intVal)) {
+ // If not accepted - we finish with connectionError.
+ return;
+ }
+ }
+ }
+
+ sendSETTINGS_ACK();
+}
+
+
+void QHttp2ProtocolHandler::handlePUSH_PROMISE()
+{
+ // 6.6 PUSH_PROMISE.
+ Q_ASSERT(inboundFrame.type == FrameType::PUSH_PROMISE);
+
+ if (prefaceSent && !waitingForSettingsACK) {
+ // This means, server ACKed our 'NO PUSH',
+ // but sent us PUSH_PROMISE anyway.
+ return connectionError(PROTOCOL_ERROR, "unexpected PUSH_PROMISE frame");
+ }
+
+ const auto streamID = inboundFrame.streamID;
+ if (streamID == connectionStreamID) {
+ return connectionError(PROTOCOL_ERROR,
+ "PUSH_PROMISE with invalid associated stream (0x0)");
+ }
+
+ if (!activeStreams.contains(streamID) && !streamWasReset(streamID)) {
+ return connectionError(ENHANCE_YOUR_CALM,
+ "PUSH_PROMISE with invalid associated stream");
+ }
+
+ const auto reservedID = qFromBigEndian<quint32>(inboundFrame.dataBegin());
+ if (!reservedID || (reservedID & 0x1)) {
+ return connectionError(PROTOCOL_ERROR,
+ "PUSH_PROMISE with invalid promised stream ID");
+ }
+
+ // "ignoring a PUSH_PROMISE frame causes the stream
+ // state to become indeterminate" - let's RST_STREAM it then ...
+ sendRST_STREAM(reservedID, REFUSE_STREAM);
+ markAsReset(reservedID);
+
+ const bool endHeaders = inboundFrame.flags.testFlag(FrameFlag::END_HEADERS);
+ continuedFrames.clear();
+ continuedFrames.push_back(std::move(inboundFrame));
+
+ if (!endHeaders) {
+ continuationExpected = true;
+ return;
+ }
+
+ handleContinuedHEADERS();
+}
+
+void QHttp2ProtocolHandler::handlePING()
+{
+ // Since we're implementing a client and not
+ // a server, we only reply to a PING, ACKing it.
+ Q_ASSERT(inboundFrame.type == FrameType::PING);
+ Q_ASSERT(m_socket);
+
+ if (inboundFrame.streamID != connectionStreamID)
+ return connectionError(PROTOCOL_ERROR, "PING on invalid stream");
+
+ if (inboundFrame.flags & FrameFlag::ACK)
+ return connectionError(PROTOCOL_ERROR, "unexpected PING ACK");
+
+ Q_ASSERT(inboundFrame.dataSize() == 8);
+
+ outboundFrame.start(FrameType::PING, FrameFlag::ACK, connectionStreamID);
+ outboundFrame.append(inboundFrame.dataBegin(), inboundFrame.dataBegin() + 8);
+ outboundFrame.write(*m_socket);
+}
+
+void QHttp2ProtocolHandler::handleGOAWAY()
+{
+ // 6.8 GOAWAY
+
+ Q_ASSERT(inboundFrame.type == FrameType::GOAWAY);
+ // "An endpoint MUST treat a GOAWAY frame with a stream identifier
+ // other than 0x0 as a connection error (Section 5.4.1) of type PROTOCOL_ERROR."
+ if (inboundFrame.streamID != connectionStreamID)
+ return connectionError(PROTOCOL_ERROR, "GOAWAY on invalid stream");
+
+ const auto src = inboundFrame.dataBegin();
+ quint32 lastStreamID = qFromBigEndian<quint32>(src);
+ const quint32 errorCode = qFromBigEndian<quint32>(src + 4);
+
+ if (!lastStreamID) {
+ // "The last stream identifier can be set to 0 if no
+ // streams were processed."
+ lastStreamID = 1;
+ }
+
+ if (!(lastStreamID & 0x1)) {
+ // 5.1.1 - we (client) use only odd numbers as stream identifiers.
+ return connectionError(PROTOCOL_ERROR, "GOAWAY with invalid last stream ID");
+ }
+
+ if (lastStreamID >= nextID) {
+ // "A server that is attempting to gracefully shut down a connection SHOULD
+ // send an initial GOAWAY frame with the last stream identifier set to 2^31-1
+ // and a NO_ERROR code."
+ if (lastStreamID != (quint32(1) << 31) - 1 || errorCode != HTTP2_NO_ERROR)
+ return connectionError(PROTOCOL_ERROR, "GOAWAY invalid stream/error code");
+ lastStreamID = 1;
+ } else {
+ lastStreamID += 2;
+ }
+
+ goingAway = true;
+
+ QNetworkReply::NetworkError error = QNetworkReply::NoError;
+ QString message;
+ qt_error(errorCode, error, message);
+
+ for (quint32 id = lastStreamID; id < nextID; id += 2) {
+ const auto it = activeStreams.find(id);
+ if (it != activeStreams.end()) {
+ Stream &stream = *it;
+ finishStreamWithError(stream, error, message);
+ markAsReset(id);
+ deleteActiveStream(id);
+ } else {
+ removeFromSuspended(id);
+ }
+ }
+
+ if (!activeStreams.size())
+ closeSession();
+}
+
+void QHttp2ProtocolHandler::handleWINDOW_UPDATE()
+{
+ Q_ASSERT(inboundFrame.type == FrameType::WINDOW_UPDATE);
+
+
+ const quint32 delta = qFromBigEndian<quint32>(inboundFrame.dataBegin());
+ const bool valid = delta && delta <= quint32(std::numeric_limits<qint32>::max());
+ const auto streamID = inboundFrame.streamID;
+
+ if (streamID == Http2::connectionStreamID) {
+ if (!valid || sum_will_overflow(sessionSendWindowSize, delta))
+ return connectionError(PROTOCOL_ERROR, "WINDOW_UPDATE invalid delta");
+ sessionSendWindowSize += delta;
+ } else {
+ if (!activeStreams.contains(streamID)) {
+ // WINDOW_UPDATE on closed streams can be ignored.
+ return;
+ }
+ auto &stream = activeStreams[streamID];
+ if (!valid || sum_will_overflow(stream.sendWindow, delta)) {
+ finishStreamWithError(stream, QNetworkReply::ProtocolInvalidOperationError,
+ QLatin1String("invalid WINDOW_UPDATE delta"));
+ sendRST_STREAM(streamID, PROTOCOL_ERROR);
+ markAsReset(streamID);
+ deleteActiveStream(streamID);
+ return;
+ }
+ stream.sendWindow += delta;
+ }
+
+ // Since we're in _q_receiveReply at the moment, let's first handle other
+ // frames and resume suspended streams (if any) == start sending our own frame
+ // after handling these frames, since one them can be e.g. GOAWAY.
+ QMetaObject::invokeMethod(this, "resumeSuspendedStreams", Qt::QueuedConnection);
+}
+
+void QHttp2ProtocolHandler::handleCONTINUATION()
+{
+ Q_ASSERT(inboundFrame.type == FrameType::CONTINUATION);
+ Q_ASSERT(continuedFrames.size()); // HEADERS frame must be already in.
+
+ if (inboundFrame.streamID != continuedFrames.front().streamID)
+ return connectionError(PROTOCOL_ERROR, "CONTINUATION on invalid stream");
+
+ const bool endHeaders = inboundFrame.flags.testFlag(FrameFlag::END_HEADERS);
+ continuedFrames.push_back(std::move(inboundFrame));
+
+ if (!endHeaders)
+ return;
+
+ continuationExpected = false;
+ handleContinuedHEADERS();
+}
+
+void QHttp2ProtocolHandler::handleContinuedHEADERS()
+{
+ Q_ASSERT(continuedFrames.size());
+
+ const auto streamID = continuedFrames[0].streamID;
+
+ if (continuedFrames[0].type == FrameType::HEADERS) {
+ if (activeStreams.contains(streamID)) {
+ Stream &stream = activeStreams[streamID];
+ if (stream.state != Stream::halfClosedLocal) {
+ // If we're receiving headers, they're a response to a request we sent;
+ // and we closed our end when we finished sending that.
+ finishStreamWithError(stream, QNetworkReply::ProtocolInvalidOperationError,
+ QLatin1String("HEADERS on invalid stream"));
+ sendRST_STREAM(streamID, CANCEL);
+ markAsReset(streamID);
+ deleteActiveStream(streamID);
+ return;
+ }
+ } else if (!streamWasReset(streamID)) {
+ return connectionError(PROTOCOL_ERROR, "HEADERS on invalid stream");
+ }
+ }
+
+ quint32 total = 0;
+ for (const auto &frame : continuedFrames)
+ total += frame.dataSize();
+
+ if (!total) {
+ // It could be a PRIORITY sent in HEADERS - handled by this point.
+ return;
+ }
+
+ std::vector<uchar> hpackBlock(total);
+ auto dst = hpackBlock.begin();
+ for (const auto &frame : continuedFrames) {
+ if (!frame.dataSize())
+ continue;
+ const uchar *src = frame.dataBegin();
+ std::copy(src, src + frame.dataSize(), dst);
+ dst += frame.dataSize();
+ }
+
+ HPack::BitIStream inputStream{&hpackBlock[0],
+ &hpackBlock[0] + hpackBlock.size()};
+
+ if (!decoder.decodeHeaderFields(inputStream))
+ return connectionError(COMPRESSION_ERROR, "HPACK decompression failed");
+
+ if (continuedFrames[0].type == FrameType::HEADERS) {
+ if (activeStreams.contains(streamID)) {
+ Stream &stream = activeStreams[streamID];
+ updateStream(stream, decoder.decodedHeader());
+ if (continuedFrames[0].flags & FrameFlag::END_STREAM) {
+ finishStream(stream);
+ deleteActiveStream(stream.streamID);
+ }
+ }
+ }
+}
+
+bool QHttp2ProtocolHandler::acceptSetting(Http2::Settings identifier, quint32 newValue)
+{
+ if (identifier == Settings::HEADER_TABLE_SIZE_ID) {
+ if (newValue > maxAcceptableTableSize) {
+ connectionError(PROTOCOL_ERROR, "SETTINGS invalid table size");
+ return false;
+ }
+ encoder.setMaxDynamicTableSize(newValue);
+ }
+
+ if (identifier == Settings::INITIAL_WINDOW_SIZE_ID) {
+ // For every active stream - adjust its window
+ // (and handle possible overflows as errors).
+ if (newValue > quint32(std::numeric_limits<qint32>::max())) {
+ connectionError(FLOW_CONTROL_ERROR, "SETTINGS invalid initial window size");
+ return false;
+ }
+
+ const qint32 delta = qint32(newValue) - streamInitialSendWindowSize;
+ streamInitialSendWindowSize = newValue;
+
+ std::vector<quint32> brokenStreams;
+ brokenStreams.reserve(activeStreams.size());
+ for (auto &stream : activeStreams) {
+ if (sum_will_overflow(stream.sendWindow, delta)) {
+ brokenStreams.push_back(stream.streamID);
+ continue;
+ }
+ stream.sendWindow += delta;
+ }
+
+ for (auto id : brokenStreams) {
+ auto &stream = activeStreams[id];
+ finishStreamWithError(stream, QNetworkReply::ProtocolInvalidOperationError,
+ QLatin1String("SETTINGS window overflow"));
+ sendRST_STREAM(id, PROTOCOL_ERROR);
+ markAsReset(id);
+ deleteActiveStream(id);
+ }
+
+ QMetaObject::invokeMethod(this, "resumeSuspendedStreams", Qt::QueuedConnection);
+ }
+
+ if (identifier == Settings::MAX_CONCURRENT_STREAMS_ID) {
+ if (maxConcurrentStreams > maxPeerConcurrentStreams) {
+ connectionError(PROTOCOL_ERROR, "SETTINGS invalid number of concurrent streams");
+ return false;
+ }
+ maxConcurrentStreams = newValue;
+ }
+
+ if (identifier == Settings::MAX_FRAME_SIZE_ID) {
+ if (newValue < Http2::maxFrameSize || newValue > Http2::maxPayloadSize) {
+ connectionError(PROTOCOL_ERROR, "SETTGINGS max frame size is out of range");
+ return false;
+ }
+ maxFrameSize = newValue;
+ }
+
+ if (identifier == Settings::MAX_HEADER_LIST_SIZE_ID) {
+ // We just remember this value, it can later
+ // prevent us from sending any request (and this
+ // will end up in request/reply error).
+ maxHeaderListSize = newValue;
+ }
+
+ return true;
+}
+
+void QHttp2ProtocolHandler::updateStream(Stream &stream, const HPack::HttpHeader &headers)
+{
+ const auto httpReply = stream.reply();
+ Q_ASSERT(httpReply);
+ const auto httpReplyPrivate = httpReply->d_func();
+ for (const auto &pair : headers) {
+ const auto &name = pair.name;
+ auto value = pair.value;
+
+ if (name == ":status") {
+ httpReply->setStatusCode(value.left(3).toInt());
+ httpReplyPrivate->reasonPhrase = QString::fromLatin1(value.mid(4));
+ } else if (name == ":version") {
+ httpReplyPrivate->majorVersion = value.at(5) - '0';
+ httpReplyPrivate->minorVersion = value.at(7) - '0';
+ } else if (name == "content-length") {
+ bool ok = false;
+ const qlonglong length = value.toLongLong(&ok);
+ if (ok)
+ httpReply->setContentLength(length);
+ } else {
+ QByteArray binder(", ");
+ if (name == "set-cookie")
+ binder = "\n";
+ httpReply->setHeaderField(name, value.replace('\0', binder));
+ }
+ }
+
+ emit httpReply->headerChanged();
+}
+
+void QHttp2ProtocolHandler::updateStream(Stream &stream, const Http2::FrameReader &frame)
+{
+ Q_ASSERT(frame.type == FrameType::DATA);
+
+ if (const auto length = frame.dataSize()) {
+ const char *data = reinterpret_cast<const char *>(frame.dataBegin());
+ auto &httpRequest = stream.request();
+ auto httpReply = stream.reply();
+ Q_ASSERT(httpReply);
+ auto replyPrivate = httpReply->d_func();
+
+ replyPrivate->compressedData.append(data, length);
+ replyPrivate->totalProgress += length;
+
+ const QByteArray wrapped(data, length);
+ if (httpRequest.d->autoDecompress && replyPrivate->isCompressed()) {
+ QByteDataBuffer inDataBuffer;
+ inDataBuffer.append(wrapped);
+ replyPrivate->uncompressBodyData(&inDataBuffer, &replyPrivate->responseData);
+ } else {
+ replyPrivate->responseData.append(wrapped);
+ }
+
+ if (replyPrivate->shouldEmitSignals()) {
+ emit httpReply->readyRead();
+ emit httpReply->dataReadProgress(replyPrivate->totalProgress, replyPrivate->bodyLength);
+ }
+ }
+}
+
+void QHttp2ProtocolHandler::finishStream(Stream &stream)
+{
+ stream.state = Stream::closed;
+ auto httpReply = stream.reply();
+ Q_ASSERT(httpReply);
+ httpReply->disconnect(this);
+ if (stream.data())
+ stream.data()->disconnect(this);
+
+ qCDebug(QT_HTTP2) << "stream" << stream.streamID << "closed";
+
+ emit httpReply->finished();
+}
+
+void QHttp2ProtocolHandler::finishStreamWithError(Stream &stream, quint32 errorCode)
+{
+ QNetworkReply::NetworkError error = QNetworkReply::NoError;
+ QString message;
+ qt_error(errorCode, error, message);
+ finishStreamWithError(stream, error, message);
+}
+
+void QHttp2ProtocolHandler::finishStreamWithError(Stream &stream, QNetworkReply::NetworkError error,
+ const QString &message)
+{
+ stream.state = Stream::closed;
+ auto httpReply = stream.reply();
+ Q_ASSERT(httpReply);
+ httpReply->disconnect(this);
+ if (stream.data())
+ stream.data()->disconnect(this);
+
+ qCWarning(QT_HTTP2) << "stream" << stream.streamID
+ << "finished with error:" << message;
+
+ // TODO: error message must be translated!!! (tr)
+ emit httpReply->finishedWithError(error, message);
+}
+
+quint32 QHttp2ProtocolHandler::createNewStream(const HttpMessagePair &message)
+{
+ const qint32 newStreamID = allocateStreamID();
+ if (!newStreamID)
+ return 0;
+
+ Q_ASSERT(!activeStreams.contains(newStreamID));
+
+ const auto reply = message.second;
+ const auto replyPrivate = reply->d_func();
+ replyPrivate->connection = m_connection;
+ replyPrivate->connectionChannel = m_channel;
+ reply->setSpdyWasUsed(true);
+ reply->setProperty("HTTP2StreamID", newStreamID);
+ connect(reply, SIGNAL(destroyed(QObject*)),
+ this, SLOT(_q_replyDestroyed(QObject*)));
+
+ const Stream newStream(message, newStreamID,
+ streamInitialSendWindowSize,
+ streamInitialRecvWindowSize);
+
+ if (auto src = newStream.data()) {
+ connect(src, SIGNAL(readyRead()), this,
+ SLOT(_q_uploadDataReadyRead()), Qt::QueuedConnection);
+ src->setProperty("HTTP2StreamID", newStreamID);
+ }
+
+ activeStreams.insert(newStreamID, newStream);
+
+ return newStreamID;
+}
+
+void QHttp2ProtocolHandler::addToSuspended(Stream &stream)
+{
+ qCDebug(QT_HTTP2) << "stream" << stream.streamID
+ << "suspended by flow control";
+ const auto priority = stream.priority();
+ Q_ASSERT(int(priority) >= 0 && int(priority) < 3);
+ suspendedStreams[priority].push_back(stream.streamID);
+}
+
+void QHttp2ProtocolHandler::markAsReset(quint32 streamID)
+{
+ // For now, we trace only client's streams (created by us,
+ // odd integer numbers).
+ if (streamID & 0x1) {
+ qCDebug(QT_HTTP2) << "stream" << streamID << "was reset";
+ // This part is quite tricky: I have to clear this set
+ // so that it does not become tOOO big.
+ if (recycledStreams.size() > maxRecycledStreams) {
+ // At least, I'm erasing the oldest first ...
+ recycledStreams.erase(recycledStreams.begin(),
+ recycledStreams.begin() +
+ recycledStreams.size() / 2);
+ }
+
+ const auto it = std::lower_bound(recycledStreams.begin(), recycledStreams.end(),
+ streamID);
+ if (it != recycledStreams.end() && *it == streamID)
+ return;
+
+ recycledStreams.insert(it, streamID);
+ }
+}
+
+quint32 QHttp2ProtocolHandler::popStreamToResume()
+{
+ quint32 streamID = connectionStreamID;
+ const int nQ = sizeof suspendedStreams / sizeof suspendedStreams[0];
+ using QNR = QHttpNetworkRequest;
+ const QNR::Priority ranks[nQ] = {QNR::HighPriority,
+ QNR::NormalPriority,
+ QNR::LowPriority};
+
+ for (int i = 0; i < nQ; ++i) {
+ auto &queue = suspendedStreams[ranks[i]];
+ auto it = queue.begin();
+ for (; it != queue.end(); ++it) {
+ if (!activeStreams.contains(*it))
+ continue;
+ if (activeStreams[*it].sendWindow > 0)
+ break;
+ }
+
+ if (it != queue.end()) {
+ streamID = *it;
+ queue.erase(it);
+ break;
+ }
+ }
+
+ return streamID;
+}
+
+void QHttp2ProtocolHandler::removeFromSuspended(quint32 streamID)
+{
+ const int nQ = sizeof suspendedStreams / sizeof suspendedStreams[0];
+ for (int i = 0; i < nQ; ++i) {
+ auto &q = suspendedStreams[i];
+ q.erase(std::remove(q.begin(), q.end(), streamID), q.end());
+ }
+}
+
+void QHttp2ProtocolHandler::deleteActiveStream(quint32 streamID)
+{
+ if (activeStreams.contains(streamID)) {
+ auto &stream = activeStreams[streamID];
+ if (stream.reply())
+ stream.reply()->disconnect(this);
+ if (stream.data())
+ stream.data()->disconnect(this);
+ activeStreams.remove(streamID);
+ }
+
+ removeFromSuspended(streamID);
+ if (m_channel->spdyRequestsToSend.size())
+ QMetaObject::invokeMethod(this, "sendRequest", Qt::QueuedConnection);
+}
+
+bool QHttp2ProtocolHandler::streamWasReset(quint32 streamID) const
+{
+ const auto it = std::lower_bound(recycledStreams.begin(),
+ recycledStreams.end(),
+ streamID);
+ return it != recycledStreams.end() && *it == streamID;
+}
+
+void QHttp2ProtocolHandler::resumeSuspendedStreams()
+{
+ while (sessionSendWindowSize > 0) {
+ const auto streamID = popStreamToResume();
+ if (!streamID)
+ return;
+
+ if (!activeStreams.contains(streamID))
+ continue;
+
+ Stream &stream = activeStreams[streamID];
+ if (!sendDATA(stream)) {
+ finishStreamWithError(stream, QNetworkReply::UnknownNetworkError,
+ QLatin1String("failed to send DATA"));
+ sendRST_STREAM(streamID, INTERNAL_ERROR);
+ markAsReset(streamID);
+ deleteActiveStream(streamID);
+ }
+ }
+}
+
+quint32 QHttp2ProtocolHandler::allocateStreamID()
+{
+ // With protocol upgrade streamID == 1 will become
+ // invalid. The logic must be updated.
+ if (nextID > quint32(std::numeric_limits<qint32>::max()))
+ return 0;
+
+ const quint32 streamID = nextID;
+ nextID += 2;
+
+ return streamID;
+}
+
+void QHttp2ProtocolHandler::connectionError(Http2::Http2Error errorCode,
+ const char *message)
+{
+ Q_ASSERT(message);
+ Q_ASSERT(!goingAway);
+
+ qCCritical(QT_HTTP2) << "connection error:" << message;
+
+ goingAway = true;
+ sendGOAWAY(errorCode);
+ const auto error = qt_error(errorCode);
+ m_channel->emitFinishedWithError(error, message);
+
+ for (auto &stream: activeStreams)
+ finishStreamWithError(stream, error, QLatin1String(message));
+
+ closeSession();
+}
+
+void QHttp2ProtocolHandler::closeSession()
+{
+ activeStreams.clear();
+ for (auto &q: suspendedStreams)
+ q.clear();
+ recycledStreams.clear();
+
+ m_channel->close();
+}
+
+QT_END_NAMESPACE
+
+#endif // !defined(QT_NO_HTTP)
diff --git a/src/network/access/qhttp2protocolhandler_p.h b/src/network/access/qhttp2protocolhandler_p.h
new file mode 100644
index 0000000000..6804c329b9
--- /dev/null
+++ b/src/network/access/qhttp2protocolhandler_p.h
@@ -0,0 +1,207 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QHTTP2PROTOCOLHANDLER_P_H
+#define QHTTP2PROTOCOLHANDLER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the Network Access API. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qhttpnetworkconnectionchannel_p.h>
+#include <private/qabstractprotocolhandler_p.h>
+#include <private/qhttpnetworkrequest_p.h>
+
+#if !defined(QT_NO_HTTP)
+
+#include "http2/http2protocol_p.h"
+#include "http2/http2streams_p.h"
+#include "http2/http2frames_p.h"
+#include "http2/hpacktable_p.h"
+#include "http2/hpack_p.h"
+
+#include <QtCore/qbytearray.h>
+#include <QtCore/qglobal.h>
+#include <QtCore/qobject.h>
+#include <QtCore/qflags.h>
+#include <QtCore/qhash.h>
+
+#include <vector>
+#include <limits>
+#include <deque>
+#include <set>
+
+QT_BEGIN_NAMESPACE
+
+class QHttp2ProtocolHandler : public QObject, public QAbstractProtocolHandler
+{
+ Q_OBJECT
+
+public:
+ QHttp2ProtocolHandler(QHttpNetworkConnectionChannel *channel);
+
+ QHttp2ProtocolHandler(const QHttp2ProtocolHandler &rhs) = delete;
+ QHttp2ProtocolHandler(QHttp2ProtocolHandler &&rhs) = delete;
+
+ QHttp2ProtocolHandler &operator = (const QHttp2ProtocolHandler &rhs) = delete;
+ QHttp2ProtocolHandler &operator = (QHttp2ProtocolHandler &&rhs) = delete;
+
+private slots:
+ void _q_uploadDataReadyRead();
+ void _q_replyDestroyed(QObject* reply);
+
+private:
+ using Stream = Http2::Stream;
+
+ void _q_readyRead() override;
+ void _q_receiveReply() override;
+ Q_INVOKABLE bool sendRequest() override;
+
+ bool sendClientPreface();
+ bool sendSETTINGS_ACK();
+ bool sendHEADERS(Stream &stream);
+ bool sendDATA(Stream &stream);
+ Q_INVOKABLE bool sendWINDOW_UPDATE(quint32 streamID, quint32 delta);
+ bool sendRST_STREAM(quint32 streamID, quint32 errorCoder);
+ bool sendGOAWAY(quint32 errorCode);
+
+ void handleDATA();
+ void handleHEADERS();
+ void handlePRIORITY();
+ void handleRST_STREAM();
+ void handleSETTINGS();
+ void handlePUSH_PROMISE();
+ void handlePING();
+ void handleGOAWAY();
+ void handleWINDOW_UPDATE();
+ void handleCONTINUATION();
+
+ void handleContinuedHEADERS();
+
+ bool acceptSetting(Http2::Settings identifier, quint32 newValue);
+
+ void updateStream(Stream &stream, const HPack::HttpHeader &headers);
+ void updateStream(Stream &stream, const Http2::FrameReader &dataFrame);
+ void finishStream(Stream &stream);
+ // Error code send by a peer (GOAWAY/RST_STREAM):
+ void finishStreamWithError(Stream &stream, quint32 errorCode);
+ // Locally encountered error:
+ void finishStreamWithError(Stream &stream, QNetworkReply::NetworkError error,
+ const QString &message);
+
+ // Stream's lifecycle management:
+ quint32 createNewStream(const HttpMessagePair &message);
+ void addToSuspended(Stream &stream);
+ void markAsReset(quint32 streamID);
+ quint32 popStreamToResume();
+ void removeFromSuspended(quint32 streamID);
+ void deleteActiveStream(quint32 streamID);
+ bool streamWasReset(quint32 streamID) const;
+
+ bool prefaceSent = false;
+ // In the current implementation we send
+ // SETTINGS only once, immediately after
+ // the client's preface 24-byte message.
+ bool waitingForSettingsACK = false;
+
+ static const quint32 maxAcceptableTableSize = 16 * HPack::FieldLookupTable::DefaultSize;
+ // HTTP/2 4.3: Header compression is stateful. One compression context and
+ // one decompression context are used for the entire connection.
+ HPack::Decoder decoder;
+ HPack::Encoder encoder;
+
+ QHash<quint32, Stream> activeStreams;
+ std::deque<quint32> suspendedStreams[3]; // 3 for priorities: High, Normal, Low.
+ static const std::deque<quint32>::size_type maxRecycledStreams;
+ std::deque<quint32> recycledStreams;
+
+ // Peer's max frame size.
+ quint32 maxFrameSize = Http2::maxFrameSize;
+
+ Http2::FrameReader inboundFrame;
+ Http2::FrameWriter outboundFrame;
+ // Temporary storage to assemble HEADERS' block
+ // from several CONTINUATION frames ...
+ bool continuationExpected = false;
+ std::vector<Http2::FrameReader> continuedFrames;
+
+ // Peer's max number of streams ...
+ quint32 maxConcurrentStreams = Http2::maxConcurrentStreams;
+
+ // Control flow:
+ static const qint32 sessionMaxRecvWindowSize = Http2::defaultSessionWindowSize * 10;
+ // Signed integer, it can become negative (it's still a valid window size):
+ qint32 sessionRecvWindowSize = sessionMaxRecvWindowSize;
+
+ // We do not negotiate this window size
+ // We have to send WINDOW_UPDATE frames to our peer also.
+ static const qint32 streamInitialRecvWindowSize = Http2::defaultSessionWindowSize;
+
+ // Updated by SETTINGS and WINDOW_UPDATE.
+ qint32 sessionSendWindowSize = Http2::defaultSessionWindowSize;
+ qint32 streamInitialSendWindowSize = Http2::defaultSessionWindowSize;
+
+ // It's unlimited by default, but can be changed via SETTINGS.
+ quint32 maxHeaderListSize = (std::numeric_limits<quint32>::max)();
+
+ Q_INVOKABLE void resumeSuspendedStreams();
+ // Our stream IDs (all odd), the first valid will be 1.
+ quint32 nextID = 1;
+ quint32 allocateStreamID();
+ bool validPeerStreamID() const;
+ bool goingAway = false;
+
+ // Errors:
+ void connectionError(Http2::Http2Error errorCode,
+ const char *message);
+ void closeSession();
+};
+
+QT_END_NAMESPACE
+
+#endif // !defined(QT_NO_HTTP)
+
+#endif
diff --git a/src/network/access/qhttpmultipart.h b/src/network/access/qhttpmultipart.h
index cbf28c083e..6d4531b099 100644
--- a/src/network/access/qhttpmultipart.h
+++ b/src/network/access/qhttpmultipart.h
@@ -40,6 +40,7 @@
#ifndef QHTTPMULTIPART_H
#define QHTTPMULTIPART_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/QSharedDataPointer>
#include <QtCore/QByteArray>
#include <QtCore/QIODevice>
diff --git a/src/network/access/qhttpmultipart_p.h b/src/network/access/qhttpmultipart_p.h
index 875f52f8e3..a03df9cb13 100644
--- a/src/network/access/qhttpmultipart_p.h
+++ b/src/network/access/qhttpmultipart_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "QtCore/qshareddata.h"
#include "qnetworkrequest_p.h" // for deriving QHttpPartPrivate from QNetworkHeadersPrivate
#include "private/qobject_p.h"
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index 79f418f675..74fc23957c 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -60,6 +60,7 @@
# include <QtNetwork/qsslkey.h>
# include <QtNetwork/qsslcipher.h>
# include <QtNetwork/qsslconfiguration.h>
+# include <QtNetwork/qsslerror.h>
#endif
@@ -82,9 +83,10 @@ QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(const QString &host
networkLayerState(Unknown),
hostName(hostName), port(port), encrypt(encrypt), delayIpv4(true)
#ifndef QT_NO_SSL
-, channelCount((type == QHttpNetworkConnection::ConnectionTypeSPDY) ? 1 : defaultHttpChannelCount)
+, channelCount((type == QHttpNetworkConnection::ConnectionTypeSPDY || type == QHttpNetworkConnection::ConnectionTypeHTTP2)
+ ? 1 : defaultHttpChannelCount)
#else
-, channelCount(defaultHttpChannelCount)
+, channelCount(type == QHttpNetworkConnection::ConnectionTypeHTTP2 ? 1 : defaultHttpChannelCount)
#endif // QT_NO_SSL
#ifndef QT_NO_NETWORKPROXY
, networkProxy(QNetworkProxy::NoProxy)
@@ -617,13 +619,11 @@ QHttpNetworkReply* QHttpNetworkConnectionPrivate::queueRequest(const QHttpNetwor
break;
}
}
-#ifndef QT_NO_SSL
- else { // SPDY
+ else { // SPDY, HTTP/2
if (!pair.second->d_func()->requestIsPrepared)
prepareRequest(pair);
channels[0].spdyRequestsToSend.insertMulti(request.priority(), pair);
}
-#endif // QT_NO_SSL
// For Happy Eyeballs the networkLayerState is set to Unknown
// untill we have started the first connection attempt. So no
@@ -1011,8 +1011,9 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest()
}
break;
}
+ case QHttpNetworkConnection::ConnectionTypeHTTP2:
case QHttpNetworkConnection::ConnectionTypeSPDY: {
-#ifndef QT_NO_SSL
+
if (channels[0].spdyRequestsToSend.isEmpty())
return;
@@ -1024,7 +1025,6 @@ void QHttpNetworkConnectionPrivate::_q_startNextRequest()
if (channels[0].socket && channels[0].socket->state() == QAbstractSocket::ConnectedState
&& !channels[0].pendingEncrypt)
channels[0].sendRequest();
-#endif // QT_NO_SSL
break;
}
}
diff --git a/src/network/access/qhttpnetworkconnection_p.h b/src/network/access/qhttpnetworkconnection_p.h
index e05bc1df74..cad0ab1ac4 100644
--- a/src/network/access/qhttpnetworkconnection_p.h
+++ b/src/network/access/qhttpnetworkconnection_p.h
@@ -50,6 +50,8 @@
//
// We mean it.
//
+
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include <QtNetwork/qnetworkrequest.h>
#include <QtNetwork/qnetworkreply.h>
#include <QtNetwork/qabstractsocket.h>
@@ -70,17 +72,6 @@
#ifndef QT_NO_HTTP
-#ifndef QT_NO_SSL
-#ifndef QT_NO_OPENSSL
-# include <private/qsslcontext_openssl_p.h>
-#endif
-# include <private/qsslsocket_p.h>
-# include <QtNetwork/qsslsocket.h>
-# include <QtNetwork/qsslerror.h>
-#else
-# include <QtNetwork/qtcpsocket.h>
-#endif
-
QT_BEGIN_NAMESPACE
class QHttpNetworkRequest;
@@ -88,6 +79,10 @@ class QHttpNetworkReply;
class QHttpThreadDelegate;
class QByteArray;
class QHostInfo;
+#ifndef QT_NO_SSL
+class QSslConfiguration;
+class QSslContext;
+#endif // !QT_NO_SSL
class QHttpNetworkConnectionPrivate;
class Q_AUTOTEST_EXPORT QHttpNetworkConnection : public QObject
@@ -97,7 +92,8 @@ public:
enum ConnectionType {
ConnectionTypeHTTP,
- ConnectionTypeSPDY
+ ConnectionTypeSPDY,
+ ConnectionTypeHTTP2
};
#ifndef QT_NO_BEARERMANAGEMENT
@@ -159,6 +155,7 @@ private:
friend class QHttpNetworkReply;
friend class QHttpNetworkReplyPrivate;
friend class QHttpNetworkConnectionChannel;
+ friend class QHttp2ProtocolHandler;
friend class QHttpProtocolHandler;
friend class QSpdyProtocolHandler;
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index 2f7be01078..ee155bdbed 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -47,10 +47,12 @@
#ifndef QT_NO_HTTP
+#include <private/qhttp2protocolhandler_p.h>
#include <private/qhttpprotocolhandler_p.h>
#include <private/qspdyprotocolhandler_p.h>
#ifndef QT_NO_SSL
+# include <private/qsslsocket_p.h>
# include <QtNetwork/qsslkey.h>
# include <QtNetwork/qsslcipher.h>
# include <QtNetwork/qsslconfiguration.h>
@@ -177,8 +179,11 @@ void QHttpNetworkConnectionChannel::init()
if (!sslConfiguration.isNull())
sslSocket->setSslConfiguration(sslConfiguration);
} else {
-#endif // QT_NO_SSL
- protocolHandler.reset(new QHttpProtocolHandler(this));
+#endif // !QT_NO_SSL
+ if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2)
+ protocolHandler.reset(new QHttp2ProtocolHandler(this));
+ else
+ protocolHandler.reset(new QHttpProtocolHandler(this));
#ifndef QT_NO_SSL
}
#endif
@@ -833,10 +838,17 @@ void QHttpNetworkConnectionChannel::_q_connected()
#endif
} else {
state = QHttpNetworkConnectionChannel::IdleState;
- if (!reply)
- connection->d_func()->dequeueRequest(socket);
- if (reply)
- sendRequest();
+ if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2) {
+ if (spdyRequestsToSend.count() > 0) {
+ // wait for data from the server first (e.g. initial window, max concurrent requests)
+ QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
+ }
+ } else {
+ if (!reply)
+ connection->d_func()->dequeueRequest(socket);
+ if (reply)
+ sendRequest();
+ }
}
}
@@ -970,8 +982,12 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket
}
} while (!connection->d_func()->highPriorityQueue.isEmpty()
|| !connection->d_func()->lowPriorityQueue.isEmpty());
+
+ if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2
#ifndef QT_NO_SSL
- if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeSPDY) {
+ || connection->connectionType() == QHttpNetworkConnection::ConnectionTypeSPDY
+#endif
+ ) {
QList<HttpMessagePair> spdyPairs = spdyRequestsToSend.values();
for (int a = 0; a < spdyPairs.count(); ++a) {
// emit error for all replies
@@ -980,7 +996,6 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket
emit currentReply->finishedWithError(errorCode, errorString);
}
}
-#endif // QT_NO_SSL
// send the next request
QMetaObject::invokeMethod(that, "_q_startNextRequest", Qt::QueuedConnection);
@@ -1002,19 +1017,19 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket
#ifndef QT_NO_NETWORKPROXY
void QHttpNetworkConnectionChannel::_q_proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator* auth)
{
+ if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2
#ifndef QT_NO_SSL
- if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeSPDY) {
+ || connection->connectionType() == QHttpNetworkConnection::ConnectionTypeSPDY
+#endif
+ ) {
connection->d_func()->emitProxyAuthenticationRequired(this, proxy, auth);
} else { // HTTP
-#endif // QT_NO_SSL
// Need to dequeue the request before we can emit the error.
if (!reply)
connection->d_func()->dequeueRequest(socket);
if (reply)
connection->d_func()->emitProxyAuthenticationRequired(this, proxy, auth);
-#ifndef QT_NO_SSL
}
-#endif // QT_NO_SSL
}
#endif
@@ -1024,6 +1039,19 @@ void QHttpNetworkConnectionChannel::_q_uploadDataReadyRead()
sendRequest();
}
+void QHttpNetworkConnectionChannel::emitFinishedWithError(QNetworkReply::NetworkError error,
+ const char *message)
+{
+ if (reply)
+ emit reply->finishedWithError(error, QHttpNetworkConnectionChannel::tr(message));
+ QList<HttpMessagePair> spdyPairs = spdyRequestsToSend.values();
+ for (int a = 0; a < spdyPairs.count(); ++a) {
+ QHttpNetworkReply *currentReply = spdyPairs.at(a).second;
+ Q_ASSERT(currentReply);
+ emit currentReply->finishedWithError(error, QHttpNetworkConnectionChannel::tr(message));
+ }
+}
+
#ifndef QT_NO_SSL
void QHttpNetworkConnectionChannel::_q_encrypted()
{
@@ -1043,6 +1071,10 @@ void QHttpNetworkConnectionChannel::_q_encrypted()
// no need to re-queue requests, if SPDY was enabled on the request it
// has gone to the SPDY queue already
break;
+ } else if (nextProtocol == QSslConfiguration::ALPNProtocolHTTP2) {
+ protocolHandler.reset(new QHttp2ProtocolHandler(this));
+ connection->setConnectionType(QHttpNetworkConnection::ConnectionTypeHTTP2);
+ break;
} else {
emitFinishedWithError(QNetworkReply::SslHandshakeFailedError,
"detected unknown Next Protocol Negotiation protocol");
@@ -1066,11 +1098,13 @@ void QHttpNetworkConnectionChannel::_q_encrypted()
state = QHttpNetworkConnectionChannel::IdleState;
pendingEncrypt = false;
- if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeSPDY) {
+ if (connection->connectionType() == QHttpNetworkConnection::ConnectionTypeSPDY ||
+ connection->connectionType() == QHttpNetworkConnection::ConnectionTypeHTTP2) {
// we call setSpdyWasUsed(true) on the replies in the SPDY handler when the request is sent
- if (spdyRequestsToSend.count() > 0)
+ if (spdyRequestsToSend.count() > 0) {
// wait for data from the server first (e.g. initial window, max concurrent requests)
QMetaObject::invokeMethod(connection, "_q_startNextRequest", Qt::QueuedConnection);
+ }
} else { // HTTP
if (!reply)
connection->d_func()->dequeueRequest(socket);
@@ -1092,19 +1126,6 @@ void QHttpNetworkConnectionChannel::requeueSpdyRequests()
spdyRequestsToSend.clear();
}
-void QHttpNetworkConnectionChannel::emitFinishedWithError(QNetworkReply::NetworkError error,
- const char *message)
-{
- if (reply)
- emit reply->finishedWithError(error, QHttpNetworkConnectionChannel::tr(message));
- QList<HttpMessagePair> spdyPairs = spdyRequestsToSend.values();
- for (int a = 0; a < spdyPairs.count(); ++a) {
- QHttpNetworkReply *currentReply = spdyPairs.at(a).second;
- Q_ASSERT(currentReply);
- emit currentReply->finishedWithError(error, QHttpNetworkConnectionChannel::tr(message));
- }
-}
-
void QHttpNetworkConnectionChannel::_q_sslErrors(const QList<QSslError> &errors)
{
if (!socket)
diff --git a/src/network/access/qhttpnetworkconnectionchannel_p.h b/src/network/access/qhttpnetworkconnectionchannel_p.h
index b3b52a7f42..61aea9d35d 100644
--- a/src/network/access/qhttpnetworkconnectionchannel_p.h
+++ b/src/network/access/qhttpnetworkconnectionchannel_p.h
@@ -50,6 +50,8 @@
//
// We mean it.
//
+
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include <QtNetwork/qnetworkrequest.h>
#include <QtNetwork/qnetworkreply.h>
#include <QtNetwork/qabstractsocket.h>
@@ -119,18 +121,21 @@ public:
bool authenticationCredentialsSent;
bool proxyCredentialsSent;
QScopedPointer<QAbstractProtocolHandler> protocolHandler;
+ // SPDY or HTTP/2 requests; SPDY is TLS-only, but
+ // HTTP/2 can be cleartext also, that's why it's
+ // outside of QT_NO_SSL section. Sorted by priority:
+ QMultiMap<int, HttpMessagePair> spdyRequestsToSend;
#ifndef QT_NO_SSL
bool ignoreAllSslErrors;
QList<QSslError> ignoreSslErrorsList;
QSslConfiguration sslConfiguration;
- QMultiMap<int, HttpMessagePair> spdyRequestsToSend; // sorted by priority
void ignoreSslErrors();
void ignoreSslErrors(const QList<QSslError> &errors);
void setSslConfiguration(const QSslConfiguration &config);
void requeueSpdyRequests(); // when we wanted SPDY but got HTTP
+#endif
// to emit the signal for all in-flight replies:
void emitFinishedWithError(QNetworkReply::NetworkError error, const char *message);
-#endif
#ifndef QT_NO_BEARERMANAGEMENT
QSharedPointer<QNetworkSession> networkSession;
#endif
diff --git a/src/network/access/qhttpnetworkheader_p.h b/src/network/access/qhttpnetworkheader_p.h
index 3eaab587a0..89169b9331 100644
--- a/src/network/access/qhttpnetworkheader_p.h
+++ b/src/network/access/qhttpnetworkheader_p.h
@@ -50,6 +50,9 @@
//
// We mean it.
//
+
+#include <QtNetwork/private/qtnetworkglobal_p.h>
+
#ifndef QT_NO_HTTP
#include <qshareddata.h>
diff --git a/src/network/access/qhttpnetworkreply.cpp b/src/network/access/qhttpnetworkreply.cpp
index 3601c36bc2..24ada3a81f 100644
--- a/src/network/access/qhttpnetworkreply.cpp
+++ b/src/network/access/qhttpnetworkreply.cpp
@@ -484,8 +484,7 @@ qint64 QHttpNetworkReplyPrivate::readStatus(QAbstractSocket *socket)
}
// is this a valid reply?
- if (fragment.length() >= 5 && !fragment.startsWith("HTTP/"))
- {
+ if (fragment.length() == 5 && !fragment.startsWith("HTTP/")) {
fragment.clear();
return -1;
}
@@ -739,6 +738,8 @@ qint64 QHttpNetworkReplyPrivate::readBody(QAbstractSocket *socket, QByteDataBuff
#ifndef QT_NO_COMPRESS
int QHttpNetworkReplyPrivate::initializeInflateStream()
{
+ Q_ASSERT(inflateStrm);
+
inflateStrm->zalloc = Z_NULL;
inflateStrm->zfree = Z_NULL;
inflateStrm->opaque = Z_NULL;
diff --git a/src/network/access/qhttpnetworkreply_p.h b/src/network/access/qhttpnetworkreply_p.h
index da39633dd1..f3b007f594 100644
--- a/src/network/access/qhttpnetworkreply_p.h
+++ b/src/network/access/qhttpnetworkreply_p.h
@@ -50,9 +50,13 @@
//
// We mean it.
//
-#include <qplatformdefs.h>
+
+#include <QtNetwork/private/qtnetworkglobal_p.h>
+
#ifndef QT_NO_HTTP
+#include <qplatformdefs.h>
+
#ifndef QT_NO_COMPRESS
struct z_stream_s;
#endif
@@ -176,6 +180,7 @@ private:
friend class QHttpNetworkConnection;
friend class QHttpNetworkConnectionPrivate;
friend class QHttpNetworkConnectionChannel;
+ friend class QHttp2ProtocolHandler;
friend class QHttpProtocolHandler;
friend class QSpdyProtocolHandler;
};
diff --git a/src/network/access/qhttpnetworkrequest.cpp b/src/network/access/qhttpnetworkrequest.cpp
index 5d51e7fb1a..802043d847 100644
--- a/src/network/access/qhttpnetworkrequest.cpp
+++ b/src/network/access/qhttpnetworkrequest.cpp
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(QHttpNetworkRequest::Operation op,
QHttpNetworkRequest::Priority pri, const QUrl &newUrl)
: QHttpNetworkHeaderPrivate(newUrl), operation(op), priority(pri), uploadByteDevice(0),
- autoDecompress(false), pipeliningAllowed(false), spdyAllowed(false),
+ autoDecompress(false), pipeliningAllowed(false), spdyAllowed(false), http2Allowed(false),
withCredentials(true), preConnect(false), followRedirect(false), redirectCount(0)
{
}
@@ -61,6 +61,7 @@ QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(const QHttpNetworkRequest
autoDecompress(other.autoDecompress),
pipeliningAllowed(other.pipeliningAllowed),
spdyAllowed(other.spdyAllowed),
+ http2Allowed(other.http2Allowed),
withCredentials(other.withCredentials),
ssl(other.ssl),
preConnect(other.preConnect),
@@ -82,6 +83,7 @@ bool QHttpNetworkRequestPrivate::operator==(const QHttpNetworkRequestPrivate &ot
&& (autoDecompress == other.autoDecompress)
&& (pipeliningAllowed == other.pipeliningAllowed)
&& (spdyAllowed == other.spdyAllowed)
+ && (http2Allowed == other.http2Allowed)
// we do not clear the customVerb in setOperation
&& (operation != QHttpNetworkRequest::Custom || (customVerb == other.customVerb))
&& (withCredentials == other.withCredentials)
@@ -331,6 +333,16 @@ void QHttpNetworkRequest::setSPDYAllowed(bool b)
d->spdyAllowed = b;
}
+bool QHttpNetworkRequest::isHTTP2Allowed() const
+{
+ return d->http2Allowed;
+}
+
+void QHttpNetworkRequest::setHTTP2Allowed(bool b)
+{
+ d->http2Allowed = b;
+}
+
bool QHttpNetworkRequest::withCredentials() const
{
return d->withCredentials;
diff --git a/src/network/access/qhttpnetworkrequest_p.h b/src/network/access/qhttpnetworkrequest_p.h
index d9540e6369..d1abb76e28 100644
--- a/src/network/access/qhttpnetworkrequest_p.h
+++ b/src/network/access/qhttpnetworkrequest_p.h
@@ -50,6 +50,8 @@
//
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
+
#ifndef QT_NO_HTTP
#include <private/qhttpnetworkheader_p.h>
@@ -115,6 +117,9 @@ public:
bool isSPDYAllowed() const;
void setSPDYAllowed(bool b);
+ bool isHTTP2Allowed() const;
+ void setHTTP2Allowed(bool b);
+
bool withCredentials() const;
void setWithCredentials(bool b);
@@ -142,6 +147,7 @@ private:
friend class QHttpNetworkConnectionPrivate;
friend class QHttpNetworkConnectionChannel;
friend class QHttpProtocolHandler;
+ friend class QHttp2ProtocolHandler;
friend class QSpdyProtocolHandler;
};
@@ -163,6 +169,7 @@ public:
bool autoDecompress;
bool pipeliningAllowed;
bool spdyAllowed;
+ bool http2Allowed;
bool withCredentials;
bool ssl;
bool preConnect;
diff --git a/src/network/access/qhttpprotocolhandler_p.h b/src/network/access/qhttpprotocolhandler_p.h
index b13993778c..863b988be3 100644
--- a/src/network/access/qhttpprotocolhandler_p.h
+++ b/src/network/access/qhttpprotocolhandler_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include <private/qabstractprotocolhandler_p.h>
#ifndef QT_NO_HTTP
diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp
index 3adf71ccfb..1dca7f02fb 100644
--- a/src/network/access/qhttpthreaddelegate.cpp
+++ b/src/network/access/qhttpthreaddelegate.cpp
@@ -285,9 +285,16 @@ void QHttpThreadDelegate::startRequest()
urlCopy.setPort(urlCopy.port(ssl ? 443 : 80));
QHttpNetworkConnection::ConnectionType connectionType
- = QHttpNetworkConnection::ConnectionTypeHTTP;
+ = httpRequest.isHTTP2Allowed() ? QHttpNetworkConnection::ConnectionTypeHTTP2
+ : QHttpNetworkConnection::ConnectionTypeHTTP;
+
#ifndef QT_NO_SSL
- if (httpRequest.isSPDYAllowed() && ssl) {
+ if (httpRequest.isHTTP2Allowed() && ssl) {
+ QList<QByteArray> protocols;
+ protocols << QSslConfiguration::ALPNProtocolHTTP2
+ << QSslConfiguration::NextProtocolHttp1_1;
+ incomingSslConfiguration.setAllowedNextProtocols(protocols);
+ } else if (httpRequest.isSPDYAllowed() && ssl) {
connectionType = QHttpNetworkConnection::ConnectionTypeSPDY;
urlCopy.setScheme(QStringLiteral("spdy")); // to differentiate SPDY requests from HTTPS requests
QList<QByteArray> nextProtocols;
diff --git a/src/network/access/qhttpthreaddelegate_p.h b/src/network/access/qhttpthreaddelegate_p.h
index cec125d7a5..64c58cf648 100644
--- a/src/network/access/qhttpthreaddelegate_p.h
+++ b/src/network/access/qhttpthreaddelegate_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include <QObject>
#include <QThreadStorage>
#include <QNetworkProxy>
diff --git a/src/network/access/qnetworkaccessauthenticationmanager_p.h b/src/network/access/qnetworkaccessauthenticationmanager_p.h
index 3d1cd6b4fb..548675728f 100644
--- a/src/network/access/qnetworkaccessauthenticationmanager_p.h
+++ b/src/network/access/qnetworkaccessauthenticationmanager_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qnetworkaccessmanager.h"
#include "qnetworkaccesscache_p.h"
#include "qnetworkaccessbackend_p.h"
diff --git a/src/network/access/qnetworkaccessbackend_p.h b/src/network/access/qnetworkaccessbackend_p.h
index 47f5872235..7f39c942a3 100644
--- a/src/network/access/qnetworkaccessbackend_p.h
+++ b/src/network/access/qnetworkaccessbackend_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qnetworkreplyimpl_p.h"
#include "QtCore/qobject.h"
diff --git a/src/network/access/qnetworkaccesscache_p.h b/src/network/access/qnetworkaccesscache_p.h
index 2337dd10af..3732b5cbb4 100644
--- a/src/network/access/qnetworkaccesscache_p.h
+++ b/src/network/access/qnetworkaccesscache_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "QtCore/qobject.h"
#include "QtCore/qbasictimer.h"
#include "QtCore/qbytearray.h"
diff --git a/src/network/access/qnetworkaccesscachebackend_p.h b/src/network/access/qnetworkaccesscachebackend_p.h
index c9b8c84579..8db1a6b1d5 100644
--- a/src/network/access/qnetworkaccesscachebackend_p.h
+++ b/src/network/access/qnetworkaccesscachebackend_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qnetworkaccessbackend_p.h"
#include "qnetworkrequest.h"
#include "qnetworkreply.h"
diff --git a/src/network/access/qnetworkaccessdebugpipebackend_p.h b/src/network/access/qnetworkaccessdebugpipebackend_p.h
index 6f8e248880..1d1af61dbd 100644
--- a/src/network/access/qnetworkaccessdebugpipebackend_p.h
+++ b/src/network/access/qnetworkaccessdebugpipebackend_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qnetworkaccessbackend_p.h"
#include "qnetworkrequest.h"
#include "qnetworkreply.h"
diff --git a/src/network/access/qnetworkaccessfilebackend_p.h b/src/network/access/qnetworkaccessfilebackend_p.h
index dec90062e4..081ff2b9e7 100644
--- a/src/network/access/qnetworkaccessfilebackend_p.h
+++ b/src/network/access/qnetworkaccessfilebackend_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qnetworkaccessbackend_p.h"
#include "qnetworkrequest.h"
#include "qnetworkreply.h"
diff --git a/src/network/access/qnetworkaccessftpbackend_p.h b/src/network/access/qnetworkaccessftpbackend_p.h
index c5beaf94e8..cdf6b7a07f 100644
--- a/src/network/access/qnetworkaccessftpbackend_p.h
+++ b/src/network/access/qnetworkaccessftpbackend_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qnetworkaccessbackend_p.h"
#include "qnetworkaccesscache_p.h"
#include "qnetworkrequest.h"
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 587ab27a0f..246b9a7bad 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -1105,6 +1105,47 @@ QNetworkReply *QNetworkAccessManager::sendCustomRequest(const QNetworkRequest &r
}
/*!
+ \since 5.8
+
+ \overload
+
+ Sends the contents of the \a data byte array to the destination
+ specified by \a request.
+*/
+QNetworkReply *QNetworkAccessManager::sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, const QByteArray &data)
+{
+ QBuffer *buffer = new QBuffer;
+ buffer->setData(data);
+ buffer->open(QIODevice::ReadOnly);
+
+ QNetworkReply *reply = sendCustomRequest(request, verb, buffer);
+ buffer->setParent(reply);
+ return reply;
+}
+
+/*!
+ \since 5.8
+
+ \overload
+
+ Sends a custom request to the server identified by the URL of \a request.
+
+ Sends the contents of the \a multiPart message to the destination
+ specified by \a request.
+
+ This can be used for sending MIME multipart messages for custom verbs.
+
+ \sa QHttpMultiPart, QHttpPart, put()
+*/
+QNetworkReply *QNetworkAccessManager::sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, QHttpMultiPart *multiPart)
+{
+ QNetworkRequest newRequest = d_func()->prepareMultipart(request, multiPart);
+ QIODevice *device = multiPart->d_func()->device;
+ QNetworkReply *reply = sendCustomRequest(newRequest, verb, device);
+ return reply;
+}
+
+/*!
Returns a new QNetworkReply object to handle the operation \a op
and request \a req. The device \a outgoingData is always 0 for Get and
Head requests, but is the value passed to post() and put() in
@@ -1516,27 +1557,35 @@ void QNetworkAccessManagerPrivate::clearCache(QNetworkAccessManager *manager)
manager->d_func()->objectCache.clear();
manager->d_func()->authenticationManager->clearCache();
- if (manager->d_func()->httpThread) {
- manager->d_func()->httpThread->quit();
- manager->d_func()->httpThread->wait(5000);
- if (manager->d_func()->httpThread->isFinished())
- delete manager->d_func()->httpThread;
- else
- QObject::connect(manager->d_func()->httpThread, SIGNAL(finished()), manager->d_func()->httpThread, SLOT(deleteLater()));
- manager->d_func()->httpThread = 0;
- }
+ manager->d_func()->destroyThread();
}
QNetworkAccessManagerPrivate::~QNetworkAccessManagerPrivate()
{
- if (httpThread) {
- httpThread->quit();
- httpThread->wait(5000);
- if (httpThread->isFinished())
- delete httpThread;
+ destroyThread();
+}
+
+QThread * QNetworkAccessManagerPrivate::createThread()
+{
+ if (!thread) {
+ thread = new QThread;
+ thread->setObjectName(QStringLiteral("QNetworkAccessManager thread"));
+ thread->start();
+ }
+ Q_ASSERT(thread);
+ return thread;
+}
+
+void QNetworkAccessManagerPrivate::destroyThread()
+{
+ if (thread) {
+ thread->quit();
+ thread->wait(5000);
+ if (thread->isFinished())
+ delete thread;
else
- QObject::connect(httpThread, SIGNAL(finished()), httpThread, SLOT(deleteLater()));
- httpThread = 0;
+ QObject::connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
+ thread = 0;
}
}
diff --git a/src/network/access/qnetworkaccessmanager.h b/src/network/access/qnetworkaccessmanager.h
index cba5cc09d6..4b8c4ddf0e 100644
--- a/src/network/access/qnetworkaccessmanager.h
+++ b/src/network/access/qnetworkaccessmanager.h
@@ -40,6 +40,7 @@
#ifndef QNETWORKACCESSMANAGER_H
#define QNETWORKACCESSMANAGER_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/QObject>
#ifndef QT_NO_SSL
#include <QtNetwork/QSslConfiguration>
@@ -128,6 +129,8 @@ public:
QNetworkReply *put(const QNetworkRequest &request, QHttpMultiPart *multiPart);
QNetworkReply *deleteResource(const QNetworkRequest &request);
QNetworkReply *sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, QIODevice *data = Q_NULLPTR);
+ QNetworkReply *sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, const QByteArray &data);
+ QNetworkReply *sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, QHttpMultiPart *multiPart);
#ifndef QT_NO_BEARERMANAGEMENT
void setConfiguration(const QNetworkConfiguration &config);
@@ -173,6 +176,7 @@ private:
friend class QNetworkReplyImplPrivate;
friend class QNetworkReplyHttpImpl;
friend class QNetworkReplyHttpImplPrivate;
+ friend class QNetworkReplyFileImpl;
Q_DECLARE_PRIVATE(QNetworkAccessManager)
Q_PRIVATE_SLOT(d_func(), void _q_replyFinished())
diff --git a/src/network/access/qnetworkaccessmanager_p.h b/src/network/access/qnetworkaccessmanager_p.h
index 44cf253368..bb4641ab8b 100644
--- a/src/network/access/qnetworkaccessmanager_p.h
+++ b/src/network/access/qnetworkaccessmanager_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qnetworkaccessmanager.h"
#include "qnetworkaccesscache_p.h"
#include "qnetworkaccessbackend_p.h"
@@ -74,7 +75,7 @@ class QNetworkAccessManagerPrivate: public QObjectPrivate
public:
QNetworkAccessManagerPrivate()
: networkCache(0), cookieJar(0),
- httpThread(0),
+ thread(0),
#ifndef QT_NO_NETWORKPROXY
proxyFactory(0),
#endif
@@ -107,6 +108,9 @@ public:
}
~QNetworkAccessManagerPrivate();
+ QThread * createThread();
+ void destroyThread();
+
void _q_replyFinished();
void _q_replyEncrypted();
void _q_replySslErrors(const QList<QSslError> &errors);
@@ -163,7 +167,7 @@ public:
QNetworkCookieJar *cookieJar;
- QThread *httpThread;
+ QThread *thread;
#ifndef QT_NO_NETWORKPROXY
diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp
index 21dc12829a..7a538cbf08 100644
--- a/src/network/access/qnetworkcookie.cpp
+++ b/src/network/access/qnetworkcookie.cpp
@@ -970,7 +970,7 @@ QList<QNetworkCookie> QNetworkCookiePrivate::parseSetCookieHeaderLine(const QByt
if (ok) {
if (secs <= 0) {
//earliest representable time (RFC6265 section 5.2.2)
- cookie.setExpirationDate(QDateTime::fromTime_t(0));
+ cookie.setExpirationDate(QDateTime::fromSecsSinceEpoch(0));
} else {
cookie.setExpirationDate(now.addSecs(secs));
}
diff --git a/src/network/access/qnetworkcookie.h b/src/network/access/qnetworkcookie.h
index 8f4b26465a..e462b98555 100644
--- a/src/network/access/qnetworkcookie.h
+++ b/src/network/access/qnetworkcookie.h
@@ -40,6 +40,7 @@
#ifndef QNETWORKCOOKIE_H
#define QNETWORKCOOKIE_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/QSharedDataPointer>
#include <QtCore/QList>
#include <QtCore/QMetaType>
diff --git a/src/network/access/qnetworkcookie_p.h b/src/network/access/qnetworkcookie_p.h
index 61f04e7177..13538ad243 100644
--- a/src/network/access/qnetworkcookie_p.h
+++ b/src/network/access/qnetworkcookie_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "QtCore/qdatetime.h"
QT_BEGIN_NAMESPACE
diff --git a/src/network/access/qnetworkcookiejar.h b/src/network/access/qnetworkcookiejar.h
index d6370cbc05..f9c1549e20 100644
--- a/src/network/access/qnetworkcookiejar.h
+++ b/src/network/access/qnetworkcookiejar.h
@@ -40,6 +40,7 @@
#ifndef QNETWORKCOOKIEJAR_H
#define QNETWORKCOOKIEJAR_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/QObject>
#include <QtCore/QUrl>
diff --git a/src/network/access/qnetworkcookiejar_p.h b/src/network/access/qnetworkcookiejar_p.h
index b6f4eb2bc0..43f189a40c 100644
--- a/src/network/access/qnetworkcookiejar_p.h
+++ b/src/network/access/qnetworkcookiejar_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "private/qobject_p.h"
#include "qnetworkcookie.h"
diff --git a/src/network/access/qnetworkdiskcache.cpp b/src/network/access/qnetworkdiskcache.cpp
index 077826ccf6..ce3b773c64 100644
--- a/src/network/access/qnetworkdiskcache.cpp
+++ b/src/network/access/qnetworkdiskcache.cpp
@@ -422,7 +422,7 @@ QIODevice *QNetworkDiskCache::data(const QUrl &url)
// ### verify that QFile uses the fd size and not the file name
qint64 size = file->size() - file->pos();
const uchar *p = 0;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_INTEGRITY)
+#if !defined(Q_OS_INTEGRITY)
p = file->map(file->pos(), size);
#endif
if (p) {
diff --git a/src/network/access/qnetworkdiskcache.h b/src/network/access/qnetworkdiskcache.h
index ad8b83a5f3..a3aa8d3a07 100644
--- a/src/network/access/qnetworkdiskcache.h
+++ b/src/network/access/qnetworkdiskcache.h
@@ -40,6 +40,7 @@
#ifndef QNETWORKDISKCACHE_H
#define QNETWORKDISKCACHE_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtNetwork/qabstractnetworkcache.h>
QT_BEGIN_NAMESPACE
diff --git a/src/network/access/qnetworkdiskcache_p.h b/src/network/access/qnetworkdiskcache_p.h
index 9e035863dd..e47b93b09d 100644
--- a/src/network/access/qnetworkdiskcache_p.h
+++ b/src/network/access/qnetworkdiskcache_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "private/qabstractnetworkcache_p.h"
#include <qbuffer.h>
diff --git a/src/corelib/tools/qstring_mac.mm b/src/network/access/qnetworkfile.cpp
index 7b3d6b53c0..374dd26e2e 100644
--- a/src/corelib/tools/qstring_mac.mm
+++ b/src/network/access/qnetworkfile.cpp
@@ -3,7 +3,7 @@
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the QtCore module of the Qt Toolkit.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -37,47 +37,56 @@
**
****************************************************************************/
-#include "qstring.h"
+#include "qnetworkfile_p.h"
-#import <Foundation/Foundation.h>
+#include <QtCore/QDebug>
+#include <QNetworkReply>
+#include <QtCore/QDateTime>
+#include <QtCore/QFileInfo>
+#include <QtCore/QMetaObject>
+#include <QtCore/QCoreApplication>
QT_BEGIN_NAMESPACE
-QString QString::fromCFString(CFStringRef string)
+QNetworkFile::QNetworkFile()
+ : QFile()
{
- if (!string)
- return QString();
- CFIndex length = CFStringGetLength(string);
-
- // Fast path: CFStringGetCharactersPtr does not copy but may
- // return null for any and no reason.
- const UniChar *chars = CFStringGetCharactersPtr(string);
- if (chars)
- return QString(reinterpret_cast<const QChar *>(chars), length);
-
- QString ret(length, Qt::Uninitialized);
- CFStringGetCharacters(string, CFRangeMake(0, length), reinterpret_cast<UniChar *>(ret.data()));
- return ret;
}
-CFStringRef QString::toCFString() const
+QNetworkFile::QNetworkFile(const QString &name)
+ : QFile(name)
{
- return CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar *>(unicode()), length());
}
-QString QString::fromNSString(const NSString *string)
+void QNetworkFile::open()
{
- if (!string)
- return QString();
- QString qstring;
- qstring.resize([string length]);
- [string getCharacters: reinterpret_cast<unichar*>(qstring.data()) range: NSMakeRange(0, [string length])];
- return qstring;
+ bool opened = false;
+ QFileInfo fi(fileName());
+ if (fi.isDir()) {
+ QString msg = QCoreApplication::translate("QNetworkAccessFileBackend",
+ "Cannot open %1: Path is a directory").arg(fileName());
+ error(QNetworkReply::ContentOperationNotPermittedError, msg);
+ } else {
+ headerRead(QNetworkRequest::LastModifiedHeader, QVariant::fromValue(fi.lastModified()));
+ headerRead(QNetworkRequest::ContentLengthHeader, QVariant::fromValue(fi.size()));
+ opened = QFile::open(QIODevice::ReadOnly | QIODevice::Unbuffered);
+ if (!opened) {
+ QString msg = QCoreApplication::translate("QNetworkAccessFileBackend",
+ "Error opening %1: %2").arg(fileName(), errorString());
+ if (exists())
+ error(QNetworkReply::ContentAccessDenied, msg);
+ else
+ error(QNetworkReply::ContentNotFoundError, msg);
+ }
+ }
+ finished(opened);
}
-NSString *QString::toNSString() const
+void QNetworkFile::close()
{
- return [NSString stringWithCharacters: reinterpret_cast<const UniChar*>(unicode()) length: length()];
+ // This override is needed because 'using' keyword cannot be used for slots. And the base
+ // function is not an invokable/slot function.
+ QFile::close();
}
QT_END_NAMESPACE
diff --git a/src/network/access/qnetworkfile_p.h b/src/network/access/qnetworkfile_p.h
new file mode 100644
index 0000000000..dd56b24bd8
--- /dev/null
+++ b/src/network/access/qnetworkfile_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QNETWORKFILE_H
+#define QNETWORKFILE_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the Network Access API. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtNetwork/private/qtnetworkglobal_p.h>
+#include <QFile>
+#include <qnetworkreply.h>
+
+QT_BEGIN_NAMESPACE
+
+class QNetworkFile : public QFile
+{
+ Q_OBJECT
+public:
+ QNetworkFile();
+ QNetworkFile(const QString &name);
+ using QFile::open;
+
+public Q_SLOTS:
+ void open();
+ void close() Q_DECL_OVERRIDE;
+
+Q_SIGNALS:
+ void finished(bool ok);
+ void headerRead(QNetworkRequest::KnownHeaders header, const QVariant &value);
+ void error(QNetworkReply::NetworkError error, const QString &message);
+};
+
+QT_END_NAMESPACE
+
+#endif // QNETWORKFILE_H
diff --git a/src/network/access/qnetworkreply.h b/src/network/access/qnetworkreply.h
index 9aaf06a803..1419db8597 100644
--- a/src/network/access/qnetworkreply.h
+++ b/src/network/access/qnetworkreply.h
@@ -40,6 +40,7 @@
#ifndef QNETWORKREPLY_H
#define QNETWORKREPLY_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/QIODevice>
#include <QtCore/QString>
#include <QtCore/QVariant>
diff --git a/src/network/access/qnetworkreply_p.h b/src/network/access/qnetworkreply_p.h
index 420b862b17..66d8c9d527 100644
--- a/src/network/access/qnetworkreply_p.h
+++ b/src/network/access/qnetworkreply_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qnetworkrequest.h"
#include "qnetworkrequest_p.h"
#include "qnetworkreply.h"
diff --git a/src/network/access/qnetworkreplydataimpl_p.h b/src/network/access/qnetworkreplydataimpl_p.h
index 60d3f583cc..c8b44d7539 100644
--- a/src/network/access/qnetworkreplydataimpl_p.h
+++ b/src/network/access/qnetworkreplydataimpl_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qnetworkreply.h"
#include "qnetworkreply_p.h"
#include "qnetworkaccessmanager.h"
diff --git a/src/network/access/qnetworkreplyfileimpl.cpp b/src/network/access/qnetworkreplyfileimpl.cpp
index 36bc4b41df..ef319ebf0d 100644
--- a/src/network/access/qnetworkreplyfileimpl.cpp
+++ b/src/network/access/qnetworkreplyfileimpl.cpp
@@ -40,31 +40,45 @@
#include "qnetworkreplyfileimpl_p.h"
#include "QtCore/qdatetime.h"
+#include "qnetworkaccessmanager_p.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QFileInfo>
+#include <QtCore/QThread>
+#include "qnetworkfile_p.h"
+#include "qnetworkrequest.h"
QT_BEGIN_NAMESPACE
QNetworkReplyFileImplPrivate::QNetworkReplyFileImplPrivate()
- : QNetworkReplyPrivate(), realFileSize(0)
+ : QNetworkReplyPrivate(), managerPrivate(0), realFile(0)
{
+ qRegisterMetaType<QNetworkRequest::KnownHeaders>();
+ qRegisterMetaType<QNetworkReply::NetworkError>();
}
QNetworkReplyFileImpl::~QNetworkReplyFileImpl()
{
+ QNetworkReplyFileImplPrivate *d = (QNetworkReplyFileImplPrivate*) d_func();
+ if (d->realFile) {
+ if (d->realFile->thread() == QThread::currentThread())
+ delete d->realFile;
+ else
+ QMetaObject::invokeMethod(d->realFile, "deleteLater", Qt::QueuedConnection);
+ }
}
-QNetworkReplyFileImpl::QNetworkReplyFileImpl(QObject *parent, const QNetworkRequest &req, const QNetworkAccessManager::Operation op)
- : QNetworkReply(*new QNetworkReplyFileImplPrivate(), parent)
+QNetworkReplyFileImpl::QNetworkReplyFileImpl(QNetworkAccessManager *manager, const QNetworkRequest &req, const QNetworkAccessManager::Operation op)
+ : QNetworkReply(*new QNetworkReplyFileImplPrivate(), manager)
{
setRequest(req);
setUrl(req.url());
setOperation(op);
- setFinished(true);
QNetworkReply::open(QIODevice::ReadOnly);
QNetworkReplyFileImplPrivate *d = (QNetworkReplyFileImplPrivate*) d_func();
+ d->managerPrivate = manager->d_func();
+
QUrl url = req.url();
if (url.host() == QLatin1String("localhost"))
url.setHost(QString());
@@ -77,7 +91,7 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QObject *parent, const QNetworkRequ
setError(QNetworkReply::ProtocolInvalidOperationError, msg);
QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ProtocolInvalidOperationError));
- QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
+ fileOpenFinished(false);
return;
}
#endif
@@ -85,7 +99,6 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QObject *parent, const QNetworkRequ
url.setPath(QLatin1String("/"));
setUrl(url);
-
QString fileName = url.toLocalFile();
if (fileName.isEmpty()) {
const QString scheme = url.scheme();
@@ -101,68 +114,85 @@ QNetworkReplyFileImpl::QNetworkReplyFileImpl(QObject *parent, const QNetworkRequ
}
}
- QFileInfo fi(fileName);
- if (fi.isDir()) {
- QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Cannot open %1: Path is a directory").arg(url.toString());
- setError(QNetworkReply::ContentOperationNotPermittedError, msg);
- QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
- Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ContentOperationNotPermittedError));
- QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
- return;
- }
-
- d->realFile.setFileName(fileName);
- bool opened = d->realFile.open(QIODevice::ReadOnly | QIODevice::Unbuffered);
-
- // could we open the file?
- if (!opened) {
- QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Error opening %1: %2")
- .arg(d->realFile.fileName(), d->realFile.errorString());
-
- if (d->realFile.exists()) {
- setError(QNetworkReply::ContentAccessDenied, msg);
- QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
- Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ContentAccessDenied));
- } else {
- setError(QNetworkReply::ContentNotFoundError, msg);
+ if (req.attribute(QNetworkRequest::BackgroundRequestAttribute).toBool()) { // Asynchronous open
+ auto realFile = new QNetworkFile(fileName);
+ connect(realFile, &QNetworkFile::headerRead, this, &QNetworkReplyFileImpl::setHeader,
+ Qt::QueuedConnection);
+ connect(realFile, &QNetworkFile::error, this, &QNetworkReplyFileImpl::setError,
+ Qt::QueuedConnection);
+ connect(realFile, SIGNAL(finished(bool)), SLOT(fileOpenFinished(bool)),
+ Qt::QueuedConnection);
+
+ realFile->moveToThread(d->managerPrivate->createThread());
+ QMetaObject::invokeMethod(realFile, "open", Qt::QueuedConnection);
+
+ d->realFile = realFile;
+ } else { // Synch open
+ setFinished(true);
+
+ QFileInfo fi(fileName);
+ if (fi.isDir()) {
+ QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Cannot open %1: Path is a directory").arg(url.toString());
+ setError(QNetworkReply::ContentOperationNotPermittedError, msg);
QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
- Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ContentNotFoundError));
+ Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ContentOperationNotPermittedError));
+ QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
+ return;
+ }
+ d->realFile = new QFile(fileName, this);
+ bool opened = d->realFile->open(QIODevice::ReadOnly | QIODevice::Unbuffered);
+
+ // could we open the file?
+ if (!opened) {
+ QString msg = QCoreApplication::translate("QNetworkAccessFileBackend", "Error opening %1: %2")
+ .arg(d->realFile->fileName(), d->realFile->errorString());
+
+ if (fi.exists()) {
+ setError(QNetworkReply::ContentAccessDenied, msg);
+ QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
+ Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ContentAccessDenied));
+ } else {
+ setError(QNetworkReply::ContentNotFoundError, msg);
+ QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
+ Q_ARG(QNetworkReply::NetworkError, QNetworkReply::ContentNotFoundError));
+ }
+ QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
+ return;
}
+ setHeader(QNetworkRequest::LastModifiedHeader, fi.lastModified());
+ setHeader(QNetworkRequest::ContentLengthHeader, fi.size());
+
+ QMetaObject::invokeMethod(this, "metaDataChanged", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(this, "downloadProgress", Qt::QueuedConnection,
+ Q_ARG(qint64, fi.size()), Q_ARG(qint64, fi.size()));
+ QMetaObject::invokeMethod(this, "readyRead", Qt::QueuedConnection);
QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
- return;
}
-
- setHeader(QNetworkRequest::LastModifiedHeader, fi.lastModified());
- d->realFileSize = fi.size();
- setHeader(QNetworkRequest::ContentLengthHeader, d->realFileSize);
-
- QMetaObject::invokeMethod(this, "metaDataChanged", Qt::QueuedConnection);
- QMetaObject::invokeMethod(this, "downloadProgress", Qt::QueuedConnection,
- Q_ARG(qint64, d->realFileSize), Q_ARG(qint64, d->realFileSize));
- QMetaObject::invokeMethod(this, "readyRead", Qt::QueuedConnection);
- QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
}
void QNetworkReplyFileImpl::close()
{
Q_D(QNetworkReplyFileImpl);
QNetworkReply::close();
- d->realFile.close();
+ if (d->realFile) {
+ if (d->realFile->thread() == thread())
+ d->realFile->close();
+ else
+ QMetaObject::invokeMethod(d->realFile, "close", Qt::QueuedConnection);
+ }
}
void QNetworkReplyFileImpl::abort()
{
- Q_D(QNetworkReplyFileImpl);
- QNetworkReply::close();
- d->realFile.close();
+ close();
}
qint64 QNetworkReplyFileImpl::bytesAvailable() const
{
Q_D(const QNetworkReplyFileImpl);
- if (!d->realFile.isOpen())
+ if (!d->isFinished || !d->realFile || !d->realFile->isOpen())
return QNetworkReply::bytesAvailable();
- return QNetworkReply::bytesAvailable() + d->realFile.bytesAvailable();
+ return QNetworkReply::bytesAvailable() + d->realFile->bytesAvailable();
}
bool QNetworkReplyFileImpl::isSequential () const
@@ -172,8 +202,9 @@ bool QNetworkReplyFileImpl::isSequential () const
qint64 QNetworkReplyFileImpl::size() const
{
- Q_D(const QNetworkReplyFileImpl);
- return d->realFileSize;
+ bool ok;
+ int size = header(QNetworkRequest::ContentLengthHeader).toInt(&ok);
+ return ok ? size : 0;
}
/*!
@@ -182,11 +213,11 @@ qint64 QNetworkReplyFileImpl::size() const
qint64 QNetworkReplyFileImpl::readData(char *data, qint64 maxlen)
{
Q_D(QNetworkReplyFileImpl);
- if (!d->realFile.isOpen())
+ if (!d->isFinished || !d->realFile || !d->realFile->isOpen())
return -1;
- qint64 ret = d->realFile.read(data, maxlen);
- if (bytesAvailable() == 0 && d->realFile.isOpen())
- d->realFile.close();
+ qint64 ret = d->realFile->read(data, maxlen);
+ if (bytesAvailable() == 0)
+ d->realFile->close();
if (ret == 0 && bytesAvailable() == 0)
return -1;
else {
@@ -196,6 +227,17 @@ qint64 QNetworkReplyFileImpl::readData(char *data, qint64 maxlen)
}
}
+void QNetworkReplyFileImpl::fileOpenFinished(bool isOpen)
+{
+ setFinished(true);
+ if (isOpen) {
+ const auto fileSize = size();
+ Q_EMIT metaDataChanged();
+ Q_EMIT downloadProgress(fileSize, fileSize);
+ Q_EMIT readyRead();
+ }
+ Q_EMIT finished();
+}
QT_END_NAMESPACE
diff --git a/src/network/access/qnetworkreplyfileimpl_p.h b/src/network/access/qnetworkreplyfileimpl_p.h
index bac00881a8..d6af66152e 100644
--- a/src/network/access/qnetworkreplyfileimpl_p.h
+++ b/src/network/access/qnetworkreplyfileimpl_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qnetworkreply.h"
#include "qnetworkreply_p.h"
#include "qnetworkaccessmanager.h"
@@ -59,13 +60,12 @@
QT_BEGIN_NAMESPACE
-
class QNetworkReplyFileImplPrivate;
class QNetworkReplyFileImpl: public QNetworkReply
{
Q_OBJECT
public:
- QNetworkReplyFileImpl(QObject *parent, const QNetworkRequest &req, const QNetworkAccessManager::Operation op);
+ QNetworkReplyFileImpl(QNetworkAccessManager *manager, const QNetworkRequest &req, const QNetworkAccessManager::Operation op);
~QNetworkReplyFileImpl();
virtual void abort() Q_DECL_OVERRIDE;
@@ -77,6 +77,9 @@ public:
virtual qint64 readData(char *data, qint64 maxlen) Q_DECL_OVERRIDE;
+private Q_SLOTS:
+ void fileOpenFinished(bool isOpen);
+
Q_DECLARE_PRIVATE(QNetworkReplyFileImpl)
};
@@ -85,12 +88,14 @@ class QNetworkReplyFileImplPrivate: public QNetworkReplyPrivate
public:
QNetworkReplyFileImplPrivate();
- QFile realFile;
- qint64 realFileSize;
+ QNetworkAccessManagerPrivate *managerPrivate;
+ QPointer<QFile> realFile;
Q_DECLARE_PUBLIC(QNetworkReplyFileImpl)
};
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QNetworkRequest::KnownHeaders)
+
#endif // QNETWORKREPLYFILEIMPL_H
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index 6bf3c56db2..b5e44fa29a 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -522,36 +522,36 @@ bool QNetworkReplyHttpImplPrivate::loadFromCacheIfAllowed(QHttpNetworkRequest &h
* now
* is the current (local) time
*/
- int age_value = 0;
+ qint64 age_value = 0;
it = cacheHeaders.findRawHeader("age");
if (it != cacheHeaders.rawHeaders.constEnd())
- age_value = it->second.toInt();
+ age_value = it->second.toLongLong();
QDateTime dateHeader;
- int date_value = 0;
+ qint64 date_value = 0;
it = cacheHeaders.findRawHeader("date");
if (it != cacheHeaders.rawHeaders.constEnd()) {
dateHeader = QNetworkHeadersPrivate::fromHttpDate(it->second);
- date_value = dateHeader.toTime_t();
+ date_value = dateHeader.toSecsSinceEpoch();
}
- int now = currentDateTime.toTime_t();
- int request_time = now;
- int response_time = now;
+ qint64 now = currentDateTime.toSecsSinceEpoch();
+ qint64 request_time = now;
+ qint64 response_time = now;
// Algorithm from RFC 2616 section 13.2.3
- int apparent_age = qMax(0, response_time - date_value);
- int corrected_received_age = qMax(apparent_age, age_value);
- int response_delay = response_time - request_time;
- int corrected_initial_age = corrected_received_age + response_delay;
- int resident_time = now - response_time;
- int current_age = corrected_initial_age + resident_time;
+ qint64 apparent_age = qMax<qint64>(0, response_time - date_value);
+ qint64 corrected_received_age = qMax(apparent_age, age_value);
+ qint64 response_delay = response_time - request_time;
+ qint64 corrected_initial_age = corrected_received_age + response_delay;
+ qint64 resident_time = now - response_time;
+ qint64 current_age = corrected_initial_age + resident_time;
- int freshness_lifetime = 0;
+ qint64 freshness_lifetime = 0;
// RFC 2616 13.2.4 Expiration Calculations
if (lastModified.isValid() && dateHeader.isValid()) {
- int diff = lastModified.secsTo(dateHeader);
+ qint64 diff = lastModified.secsTo(dateHeader);
freshness_lifetime = diff / 10;
if (httpRequest.headerField("Warning").isEmpty()) {
QDateTime dt = currentDateTime.addSecs(current_age);
@@ -601,17 +601,10 @@ void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpReq
thread->setObjectName(QStringLiteral("Qt HTTP synchronous thread"));
QObject::connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
thread->start();
- } else if (!managerPrivate->httpThread) {
+ } else {
// We use the manager-global thread.
// At some point we could switch to having multiple threads if it makes sense.
- managerPrivate->httpThread = new QThread();
- managerPrivate->httpThread->setObjectName(QStringLiteral("Qt HTTP thread"));
- managerPrivate->httpThread->start();
-
- thread = managerPrivate->httpThread;
- } else {
- // Asynchronous request, thread already exists
- thread = managerPrivate->httpThread;
+ thread = managerPrivate->createThread();
}
QUrl url = newHttpRequest.url();
@@ -745,6 +738,9 @@ void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpReq
if (request.attribute(QNetworkRequest::SpdyAllowedAttribute).toBool())
httpRequest.setSPDYAllowed(true);
+ if (request.attribute(QNetworkRequest::HTTP2AllowedAttribute).toBool())
+ httpRequest.setHTTP2Allowed(true);
+
if (static_cast<QNetworkRequest::LoadControl>
(newHttpRequest.attribute(QNetworkRequest::AuthenticationReuseAttribute,
QNetworkRequest::Automatic).toInt()) == QNetworkRequest::Manual)
@@ -1123,8 +1119,8 @@ void QNetworkReplyHttpImplPrivate::onRedirected(const QUrl &redirectUrl, int htt
cookedHeaders.clear();
- if (managerPrivate->httpThread)
- managerPrivate->httpThread->disconnect();
+ if (managerPrivate->thread)
+ managerPrivate->thread->disconnect();
// Recurse
QMetaObject::invokeMethod(q, "start", Qt::QueuedConnection,
diff --git a/src/network/access/qnetworkreplyhttpimpl_p.h b/src/network/access/qnetworkreplyhttpimpl_p.h
index 4aba915c7d..868fa617b6 100644
--- a/src/network/access/qnetworkreplyhttpimpl_p.h
+++ b/src/network/access/qnetworkreplyhttpimpl_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qnetworkrequest.h"
#include "qnetworkreply.h"
diff --git a/src/network/access/qnetworkreplyimpl_p.h b/src/network/access/qnetworkreplyimpl_p.h
index 054cbcc3a7..7cd99392d3 100644
--- a/src/network/access/qnetworkreplyimpl_p.h
+++ b/src/network/access/qnetworkreplyimpl_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qnetworkreply.h"
#include "qnetworkreply_p.h"
#include "qnetworkaccessmanager.h"
diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp
index 63332d4fd1..29362b81e2 100644
--- a/src/network/access/qnetworkrequest.cpp
+++ b/src/network/access/qnetworkrequest.cpp
@@ -260,6 +260,14 @@ QT_BEGIN_NAMESPACE
Indicates whether SPDY was used for receiving
this reply.
+ \value HTTP2AllowedAttribute
+ Requests only, type: QMetaType::Bool (default: false)
+ Indicates whether the QNetworkAccessManager code is
+ allowed to use HTTP/2 with this request. This applies
+ to SSL requests or 'cleartext' HTTP/2.
+
+ \omitvalue HTTP2WasUsedAttribute
+
\value EmitAllUploadProgressSignalsAttribute
Requests only, type: QMetaType::Bool (default: false)
Indicates whether all upload signals should be emitted.
diff --git a/src/network/access/qnetworkrequest.h b/src/network/access/qnetworkrequest.h
index 4a90a50e53..00375f285c 100644
--- a/src/network/access/qnetworkrequest.h
+++ b/src/network/access/qnetworkrequest.h
@@ -40,6 +40,7 @@
#ifndef QNETWORKREQUEST_H
#define QNETWORKREQUEST_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/QSharedDataPointer>
#include <QtCore/QString>
#include <QtCore/QUrl>
@@ -86,6 +87,8 @@ public:
BackgroundRequestAttribute,
SpdyAllowedAttribute,
SpdyWasUsedAttribute,
+ HTTP2AllowedAttribute,
+ HTTP2WasUsedAttribute,
EmitAllUploadProgressSignalsAttribute,
FollowRedirectsAttribute,
diff --git a/src/network/access/qnetworkrequest_p.h b/src/network/access/qnetworkrequest_p.h
index de6941c476..5e18da6d55 100644
--- a/src/network/access/qnetworkrequest_p.h
+++ b/src/network/access/qnetworkrequest_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qnetworkrequest.h"
#include "QtCore/qbytearray.h"
#include "QtCore/qlist.h"
diff --git a/src/network/access/qspdyprotocolhandler.cpp b/src/network/access/qspdyprotocolhandler.cpp
index 413b03cc22..445a2a1c29 100644
--- a/src/network/access/qspdyprotocolhandler.cpp
+++ b/src/network/access/qspdyprotocolhandler.cpp
@@ -458,7 +458,7 @@ bool QSpdyProtocolHandler::uncompressHeader(const QByteArray &input, QByteArray
break;
}
default: {
- qWarning() << "got unexpected zlib return value:" << zlibRet;
+ qWarning("got unexpected zlib return value: %d", zlibRet);
return false;
}
}
@@ -849,7 +849,7 @@ void QSpdyProtocolHandler::handleControlFrame(const QByteArray &frameHeaders) //
break;
}
default:
- qWarning() << "cannot handle frame of type" << type;
+ qWarning("cannot handle frame of type %d", int(type));
}
}
@@ -1073,7 +1073,7 @@ void QSpdyProtocolHandler::handleSETTINGS(char flags, quint32 /*length*/, const
break;
}
default:
- qWarning() << "found unknown settings value" << value;
+ qWarning("found unknown settings value %u", uint(value));
}
}
}
@@ -1112,7 +1112,7 @@ void QSpdyProtocolHandler::handleGOAWAY(char /*flags*/, quint32 /*length*/,
break;
}
default:
- qWarning() << "unexpected status code" << statusCode;
+ qWarning("unexpected status code %d", int(statusCode));
errorCode = QNetworkReply::ProtocolUnknownError;
}
diff --git a/src/network/access/qspdyprotocolhandler_p.h b/src/network/access/qspdyprotocolhandler_p.h
index aba081b9d1..0a18505b23 100644
--- a/src/network/access/qspdyprotocolhandler_p.h
+++ b/src/network/access/qspdyprotocolhandler_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include <private/qabstractprotocolhandler_p.h>
#include <QtNetwork/qnetworkreply.h>
#include <private/qbytedata_p.h>
diff --git a/src/network/bearer/qbearerengine_p.h b/src/network/bearer/qbearerengine_p.h
index b36fedb741..5fc2578a78 100644
--- a/src/network/bearer/qbearerengine_p.h
+++ b/src/network/bearer/qbearerengine_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qnetworkconfiguration_p.h"
#include "qnetworksession.h"
#include "qnetworkconfigmanager.h"
diff --git a/src/network/bearer/qbearerplugin_p.h b/src/network/bearer/qbearerplugin_p.h
index caaa71ca1f..0cdde3c06c 100644
--- a/src/network/bearer/qbearerplugin_p.h
+++ b/src/network/bearer/qbearerplugin_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qbearerengine_p.h"
#include <QtCore/qplugin.h>
diff --git a/src/network/bearer/qnetworkconfigmanager.h b/src/network/bearer/qnetworkconfigmanager.h
index 4d841d8e33..da248bc7d0 100644
--- a/src/network/bearer/qnetworkconfigmanager.h
+++ b/src/network/bearer/qnetworkconfigmanager.h
@@ -40,6 +40,7 @@
#ifndef QNETWORKCONFIGMANAGER_H
#define QNETWORKCONFIGMANAGER_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qobject.h>
#include <QtNetwork/qnetworkconfiguration.h>
diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h
index a322fb5cfe..a804e037a3 100644
--- a/src/network/bearer/qnetworkconfigmanager_p.h
+++ b/src/network/bearer/qnetworkconfigmanager_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qnetworkconfigmanager.h"
#include "qnetworkconfiguration_p.h"
diff --git a/src/network/bearer/qnetworkconfiguration.h b/src/network/bearer/qnetworkconfiguration.h
index 45f7402992..208f9f4692 100644
--- a/src/network/bearer/qnetworkconfiguration.h
+++ b/src/network/bearer/qnetworkconfiguration.h
@@ -40,7 +40,7 @@
#ifndef QNETWORKCONFIGURATION_H
#define QNETWORKCONFIGURATION_H
-# include <QtCore/qglobal.h>
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qshareddata.h>
#include <QtCore/qstring.h>
diff --git a/src/network/bearer/qnetworkconfiguration_p.h b/src/network/bearer/qnetworkconfiguration_p.h
index 316000c717..12d9676b59 100644
--- a/src/network/bearer/qnetworkconfiguration_p.h
+++ b/src/network/bearer/qnetworkconfiguration_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qnetworkconfiguration.h"
#include <QtCore/qshareddata.h>
diff --git a/src/network/bearer/qnetworksession.h b/src/network/bearer/qnetworksession.h
index 2ff1d89564..d96b8915eb 100644
--- a/src/network/bearer/qnetworksession.h
+++ b/src/network/bearer/qnetworksession.h
@@ -40,6 +40,7 @@
#ifndef QNETWORKSESSION_H
#define QNETWORKSESSION_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qstring.h>
#include <QtNetwork/qnetworkinterface.h>
diff --git a/src/network/bearer/qnetworksession_p.h b/src/network/bearer/qnetworksession_p.h
index 45596ea003..661587603c 100644
--- a/src/network/bearer/qnetworksession_p.h
+++ b/src/network/bearer/qnetworksession_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qnetworksession.h"
#include "qnetworkconfiguration_p.h"
#include "QtCore/qsharedpointer.h"
diff --git a/src/network/bearer/qsharednetworksession_p.h b/src/network/bearer/qsharednetworksession_p.h
index ba4bd500ac..001b8af02a 100644
--- a/src/network/bearer/qsharednetworksession_p.h
+++ b/src/network/bearer/qsharednetworksession_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qnetworksession.h"
#include "qnetworkconfiguration.h"
#include <QHash>
diff --git a/src/network/doc/snippets/code/src_network_socket_qsctpsocket.cpp b/src/network/doc/snippets/code/src_network_socket_qsctpsocket.cpp
new file mode 100644
index 0000000000..3783a6f939
--- /dev/null
+++ b/src/network/doc/snippets/code/src_network_socket_qsctpsocket.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QSctpSocket *socket = new QSctpSocket(this);
+
+socket->setMaxChannelCount(16);
+socket->connectToHost(QHostAddress::LocalHost, 1973);
+
+if (socket->waitForConnected(1000)) {
+ int inputChannels = socket->readChannelCount();
+ int outputChannels = socket->writeChannelCount();
+
+ ....
+}
+//! [0]
diff --git a/src/network/doc/snippets/code/src_network_socket_qudpsocket.cpp b/src/network/doc/snippets/code/src_network_socket_qudpsocket.cpp
index 9e491f802e..a98e31b10b 100644
--- a/src/network/doc/snippets/code/src_network_socket_qudpsocket.cpp
+++ b/src/network/doc/snippets/code/src_network_socket_qudpsocket.cpp
@@ -61,14 +61,7 @@ void Server::initSocket()
void Server::readPendingDatagrams()
{
while (udpSocket->hasPendingDatagrams()) {
- QByteArray datagram;
- datagram.resize(udpSocket->pendingDatagramSize());
- QHostAddress sender;
- quint16 senderPort;
-
- udpSocket->readDatagram(datagram.data(), datagram.size(),
- &sender, &senderPort);
-
+ QNetworkDatagram datagram = udpSocket->receiveDatagram();
processTheDatagram(datagram);
}
}
diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri
index 811d8b6f0d..34d2f164e8 100644
--- a/src/network/kernel/kernel.pri
+++ b/src/network/kernel/kernel.pri
@@ -3,7 +3,9 @@
PRECOMPILED_HEADER = ../corelib/global/qt_pch.h
INCLUDEPATH += $$PWD
-HEADERS += kernel/qauthenticator.h \
+HEADERS += kernel/qtnetworkglobal.h \
+ kernel/qtnetworkglobal_p.h \
+ kernel/qauthenticator.h \
kernel/qauthenticator_p.h \
kernel/qdnslookup.h \
kernel/qdnslookup_p.h \
@@ -11,6 +13,7 @@ HEADERS += kernel/qauthenticator.h \
kernel/qhostaddress_p.h \
kernel/qhostinfo.h \
kernel/qhostinfo_p.h \
+ kernel/qnetworkdatagram.h \
kernel/qnetworkdatagram_p.h \
kernel/qnetworkinterface.h \
kernel/qnetworkinterface_p.h \
@@ -22,9 +25,10 @@ SOURCES += kernel/qauthenticator.cpp \
kernel/qdnslookup.cpp \
kernel/qhostaddress.cpp \
kernel/qhostinfo.cpp \
- kernel/qurlinfo.cpp \
+ kernel/qnetworkdatagram.cpp \
+ kernel/qnetworkinterface.cpp \
kernel/qnetworkproxy.cpp \
- kernel/qnetworkinterface.cpp
+ kernel/qurlinfo.cpp
unix {
!integrity: SOURCES += kernel/qdnslookup_unix.cpp
@@ -53,10 +57,10 @@ win32: {
mac {
LIBS_PRIVATE += -framework SystemConfiguration -framework CoreFoundation
- !ios: LIBS_PRIVATE += -framework CoreServices
+ !uikit: LIBS_PRIVATE += -framework CoreServices
}
-mac:!ios:SOURCES += kernel/qnetworkproxy_mac.cpp
+osx:SOURCES += kernel/qnetworkproxy_mac.cpp
else:win32:SOURCES += kernel/qnetworkproxy_win.cpp
else:contains(QT_CONFIG, libproxy) {
SOURCES += kernel/qnetworkproxy_libproxy.cpp
diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp
index 6da231d019..107addae58 100644
--- a/src/network/kernel/qauthenticator.cpp
+++ b/src/network/kernel/qauthenticator.cpp
@@ -1271,14 +1271,10 @@ static QByteArray qEncodeNtlmv2Response(const QAuthenticatorPrivate *ctx,
if(timeArray.size()) {
ds.writeRawData(timeArray.constData(), timeArray.size());
} else {
- QDateTime currentTime(QDate::currentDate(),
- QTime::currentTime(), Qt::UTC);
-
- // number of seconds between 1601 and epoc(1970)
+ // number of seconds between 1601 and the epoch (1970)
// 369 years, 89 leap years
// ((369 * 365) + 89) * 24 * 3600 = 11644473600
-
- time = currentTime.toTime_t() + Q_UINT64_C(11644473600);
+ time = QDateTime::currentSecsSinceEpoch() + 11644473600;
// represented as 100 nano seconds
time = time * Q_UINT64_C(10000000);
@@ -1455,15 +1451,9 @@ static bool q_NTLM_SSPI_library_load()
if (pSecurityFunctionTable == NULL) {
securityDLLHandle = LoadLibrary(L"secur32.dll");
if (securityDLLHandle != NULL) {
-#if defined(Q_OS_WINCE)
- INIT_SECURITY_INTERFACE pInitSecurityInterface =
- (INIT_SECURITY_INTERFACE)GetProcAddress(securityDLLHandle,
- L"InitSecurityInterfaceW");
-#else
INIT_SECURITY_INTERFACE pInitSecurityInterface =
(INIT_SECURITY_INTERFACE)GetProcAddress(securityDLLHandle,
"InitSecurityInterfaceW");
-#endif
if (pInitSecurityInterface != NULL)
pSecurityFunctionTable = pInitSecurityInterface();
}
diff --git a/src/network/kernel/qauthenticator.h b/src/network/kernel/qauthenticator.h
index 7f8d912b49..1032c2f501 100644
--- a/src/network/kernel/qauthenticator.h
+++ b/src/network/kernel/qauthenticator.h
@@ -40,6 +40,7 @@
#ifndef QAUTHENTICATOR_H
#define QAUTHENTICATOR_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qstring.h>
#include <QtCore/qvariant.h>
diff --git a/src/network/kernel/qauthenticator_p.h b/src/network/kernel/qauthenticator_p.h
index 46388a0185..8a1ee0ebe6 100644
--- a/src/network/kernel/qauthenticator_p.h
+++ b/src/network/kernel/qauthenticator_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include <qhash.h>
#include <qbytearray.h>
#include <qstring.h>
diff --git a/src/network/kernel/qdnslookup.h b/src/network/kernel/qdnslookup.h
index bf8b6debbe..ead5e650f5 100644
--- a/src/network/kernel/qdnslookup.h
+++ b/src/network/kernel/qdnslookup.h
@@ -40,6 +40,7 @@
#ifndef QDNSLOOKUP_H
#define QDNSLOOKUP_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qlist.h>
#include <QtCore/qobject.h>
#include <QtCore/qshareddata.h>
diff --git a/src/network/kernel/qdnslookup_p.h b/src/network/kernel/qdnslookup_p.h
index 98d828b7b5..d070286383 100644
--- a/src/network/kernel/qdnslookup_p.h
+++ b/src/network/kernel/qdnslookup_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "QtCore/qmutex.h"
#include "QtCore/qrunnable.h"
#include "QtCore/qsharedpointer.h"
diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp
index 13ecfac3f5..95f90af49e 100644
--- a/src/network/kernel/qhostaddress.cpp
+++ b/src/network/kernel/qhostaddress.cpp
@@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE
// sockaddr_in6 size changed between old and new SDK
// Only the new version is the correct one, so always
// use this structure.
-#if defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
+#if defined(Q_OS_WINRT)
# if !defined(u_char)
# define u_char unsigned char
# endif
@@ -151,20 +151,37 @@ void QHostAddressPrivate::setAddress(quint32 a_)
/// parses v4-mapped addresses or the AnyIPv6 address and stores in \a a;
/// returns true if the address was one of those
-static bool convertToIpv4(quint32& a, const Q_IPV6ADDR &a6)
+static bool convertToIpv4(quint32& a, const Q_IPV6ADDR &a6, const QHostAddress::ConversionMode mode)
{
+ if (mode == QHostAddress::StrictConversion)
+ return false;
+
const uchar *ptr = a6.c;
if (qFromUnaligned<quint64>(ptr) != 0)
return false;
- if (qFromBigEndian<quint32>(ptr + 8) == 0) {
- // is it AnyIPv6?
- a = 0;
- return qFromBigEndian<quint32>(ptr + 12) == 0;
+
+ const quint32 mid = qFromBigEndian<quint32>(ptr + 8);
+ if ((mid == 0xffff) && (mode & QHostAddress::ConvertV4MappedToIPv4)) {
+ a = qFromBigEndian<quint32>(ptr + 12);
+ return true;
}
- if (qFromBigEndian<quint32>(ptr + 8) != 0xFFFF)
+ if (mid != 0)
return false;
- a = qFromBigEndian<quint32>(ptr + 12);
- return true;
+
+ const quint32 low = qFromBigEndian<quint32>(ptr + 12);
+ if ((low == 0) && (mode & QHostAddress::ConvertUnspecifiedAddress)) {
+ a = 0;
+ return true;
+ }
+ if ((low == 1) && (mode & QHostAddress::ConvertLocalHost)) {
+ a = INADDR_LOOPBACK;
+ return true;
+ }
+ if ((low != 1) && (mode & QHostAddress::ConvertV4CompatToIPv4)) {
+ a = low;
+ return true;
+ }
+ return false;
}
void QHostAddressPrivate::setAddress(const quint8 *a_)
@@ -173,7 +190,8 @@ void QHostAddressPrivate::setAddress(const quint8 *a_)
isParsed = true;
memcpy(a6.c, a_, sizeof(a6));
a = 0;
- convertToIpv4(a, a6);
+ convertToIpv4(a, a6, (QHostAddress::ConvertV4MappedToIPv4
+ | QHostAddress::ConvertUnspecifiedAddress));
}
void QHostAddressPrivate::setAddress(const Q_IPV6ADDR &a_)
@@ -385,6 +403,20 @@ void QNetmaskAddress::setPrefixLength(QAbstractSocket::NetworkLayerProtocol prot
\value Any The dual stack any-address. A socket bound with this address will listen on both IPv4 and IPv6 interfaces.
*/
+/*! \enum QHostAddress::ConversionModeFlag
+
+ \since 5.8
+
+ \value StrictConversion Don't convert IPv6 addresses to IPv4 when comparing two QHostAddress objects of different protocols, so they will always be considered different.
+ \value ConvertV4MappedToIPv4 Convert IPv4-mapped IPv6 addresses (RFC 4291 sect. 2.5.5.2) when comparing. Therefore QHostAddress("::ffff:192.168.1.1") will compare equal to QHostAddress("192.168.1.1").
+ \value ConvertV4CompatToIPv4 Convert IPv4-compatible IPv6 addresses (RFC 4291 sect. 2.5.5.1) when comparing. Therefore QHostAddress("::192.168.1.1") will compare equal to QHostAddress("192.168.1.1").
+ \value ConvertLocalHost Convert the IPv6 loopback addresses to its IPv4 equivalent when comparing. Therefore e.g. QHostAddress("::1") will compare equal to QHostAddress("127.0.0.1").
+ \value ConvertUnspecifiedAddress All unspecified addresses will compare equal, namely AnyIPv4, AnyIPv6 and Any.
+ \value TolerantConversion Sets all three preceding flags.
+
+ \sa isEqual()
+ */
+
/*! Constructs a null host address object, i.e. an address which is not valid for any host or interface.
\sa clear()
@@ -690,7 +722,9 @@ quint32 QHostAddress::toIPv4Address(bool *ok) const
quint32 dummy;
if (ok)
*ok = d->protocol == QAbstractSocket::IPv4Protocol || d->protocol == QAbstractSocket::AnyIPProtocol
- || (d->protocol == QAbstractSocket::IPv6Protocol && convertToIpv4(dummy, d->a6));
+ || (d->protocol == QAbstractSocket::IPv6Protocol
+ && convertToIpv4(dummy, d->a6, ConversionMode(QHostAddress::ConvertV4MappedToIPv4
+ | QHostAddress::ConvertUnspecifiedAddress)));
return d->a;
}
@@ -812,19 +846,73 @@ void QHostAddress::setScopeId(const QString &id)
/*!
Returns \c true if this host address is the same as the \a other address
- given; otherwise returns \c false.
+ given; otherwise returns \c false. This operator just calls isEqual(other, StrictConversion).
+
+ \sa isEqual()
*/
bool QHostAddress::operator==(const QHostAddress &other) const
{
+ return isEqual(other, StrictConversion);
+}
+
+/*!
+ \since 5.8
+
+ Returns \c true if this host address is the same as the \a other address
+ given; otherwise returns \c false.
+
+ The parameter \a mode controls which conversions are preformed between addresses
+ of differing protocols. If no \a mode is given, \c TolerantConversion is performed
+ by default.
+
+ \sa ConversionMode, operator==()
+ */
+bool QHostAddress::isEqual(const QHostAddress &other, ConversionMode mode) const
+{
QT_ENSURE_PARSED(this);
QT_ENSURE_PARSED(&other);
- if (d->protocol == QAbstractSocket::IPv4Protocol)
- return other.d->protocol == QAbstractSocket::IPv4Protocol && d->a == other.d->a;
+ if (d->protocol == QAbstractSocket::IPv4Protocol) {
+ switch (other.d->protocol) {
+ case QAbstractSocket::IPv4Protocol:
+ return d->a == other.d->a;
+ case QAbstractSocket::IPv6Protocol:
+ quint32 a4;
+ return convertToIpv4(a4, other.d->a6, mode) && (a4 == d->a);
+ case QAbstractSocket::AnyIPProtocol:
+ return (mode & QHostAddress::ConvertUnspecifiedAddress) && d->a == 0;
+ case QAbstractSocket::UnknownNetworkLayerProtocol:
+ return false;
+ }
+ }
+
if (d->protocol == QAbstractSocket::IPv6Protocol) {
- return other.d->protocol == QAbstractSocket::IPv6Protocol
- && memcmp(&d->a6, &other.d->a6, sizeof(Q_IPV6ADDR)) == 0;
+ switch (other.d->protocol) {
+ case QAbstractSocket::IPv4Protocol:
+ quint32 a4;
+ return convertToIpv4(a4, d->a6, mode) && (a4 == other.d->a);
+ case QAbstractSocket::IPv6Protocol:
+ return memcmp(&d->a6, &other.d->a6, sizeof(Q_IPV6ADDR)) == 0;
+ case QAbstractSocket::AnyIPProtocol:
+ return (mode & QHostAddress::ConvertUnspecifiedAddress)
+ && (other.d->a6_64.c[0] == 0) && (other.d->a6_64.c[1] == 0);
+ case QAbstractSocket::UnknownNetworkLayerProtocol:
+ return false;
+ }
+ }
+
+ if ((d->protocol == QAbstractSocket::AnyIPProtocol)
+ && (mode & QHostAddress::ConvertUnspecifiedAddress)) {
+ switch (other.d->protocol) {
+ case QAbstractSocket::IPv4Protocol:
+ return other.d->a == 0;
+ case QAbstractSocket::IPv6Protocol:
+ return (other.d->a6_64.c[0] == 0) && (other.d->a6_64.c[1] == 0);
+ default:
+ break;
+ }
}
+
return d->protocol == other.d->protocol;
}
diff --git a/src/network/kernel/qhostaddress.h b/src/network/kernel/qhostaddress.h
index 8236a71986..58af14ee33 100644
--- a/src/network/kernel/qhostaddress.h
+++ b/src/network/kernel/qhostaddress.h
@@ -41,6 +41,7 @@
#ifndef QHOSTADDRESS_H
#define QHOSTADDRESS_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qpair.h>
#include <QtCore/qstring.h>
#include <QtCore/qscopedpointer.h>
@@ -79,6 +80,16 @@ public:
AnyIPv6,
AnyIPv4
};
+ enum ConversionModeFlag {
+ ConvertV4MappedToIPv4 = 1,
+ ConvertV4CompatToIPv4 = 2,
+ ConvertUnspecifiedAddress = 4,
+ ConvertLocalHost = 8,
+ TolerantConversion = 0xff,
+
+ StrictConversion = 0
+ };
+ Q_DECLARE_FLAGS(ConversionMode, ConversionModeFlag)
QHostAddress();
explicit QHostAddress(quint32 ip4Addr);
@@ -118,6 +129,7 @@ public:
QString scopeId() const;
void setScopeId(const QString &id);
+ bool isEqual(const QHostAddress &address, ConversionMode mode = TolerantConversion) const;
bool operator ==(const QHostAddress &address) const;
bool operator ==(SpecialAddress address) const;
inline bool operator !=(const QHostAddress &address) const
@@ -139,6 +151,7 @@ public:
protected:
QScopedPointer<QHostAddressPrivate> d;
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QHostAddress::ConversionMode)
Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QHostAddress)
inline bool operator ==(QHostAddress::SpecialAddress address1, const QHostAddress &address2)
diff --git a/src/network/kernel/qhostaddress_p.h b/src/network/kernel/qhostaddress_p.h
index 7b43af01bb..55c3e5afde 100644
--- a/src/network/kernel/qhostaddress_p.h
+++ b/src/network/kernel/qhostaddress_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qhostaddress.h"
#include "qabstractsocket.h"
diff --git a/src/network/kernel/qhostinfo.h b/src/network/kernel/qhostinfo.h
index 42317c4c65..9b4a4853d9 100644
--- a/src/network/kernel/qhostinfo.h
+++ b/src/network/kernel/qhostinfo.h
@@ -40,6 +40,7 @@
#ifndef QHOSTINFO_H
#define QHOSTINFO_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qlist.h>
#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qhostaddress.h>
diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h
index 68d7dfae5b..ba342bf533 100644
--- a/src/network/kernel/qhostinfo_p.h
+++ b/src/network/kernel/qhostinfo_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "QtCore/qcoreapplication.h"
#include "private/qcoreapplication_p.h"
#include "QtNetwork/qhostinfo.h"
diff --git a/src/network/kernel/qhostinfo_win.cpp b/src/network/kernel/qhostinfo_win.cpp
index b98f36a612..9e5d556f2b 100644
--- a/src/network/kernel/qhostinfo_win.cpp
+++ b/src/network/kernel/qhostinfo_win.cpp
@@ -81,11 +81,7 @@ static bool resolveLibraryInternal()
{
// Attempt to resolve getaddrinfo(); without it we'll have to fall
// back to gethostbyname(), which has no IPv6 support.
-#if defined(Q_OS_WINCE)
- local_getaddrinfo = (getaddrinfoProto) QSystemLibrary::resolve(QLatin1String("ws2"), "getaddrinfo");
- local_freeaddrinfo = (freeaddrinfoProto) QSystemLibrary::resolve(QLatin1String("ws2"), "freeaddrinfo");
- local_getnameinfo = (getnameinfoProto) QSystemLibrary::resolve(QLatin1String("ws2"), "getnameinfo");
-#elif defined (Q_OS_WINRT)
+#if defined (Q_OS_WINRT)
local_getaddrinfo = (getaddrinfoProto) &getaddrinfo;
local_freeaddrinfo = (freeaddrinfoProto) &freeaddrinfo;
local_getnameinfo = (getnameinfoProto) getnameinfo;
@@ -116,11 +112,6 @@ static void translateWSAError(int error, QHostInfo *results)
QHostInfo QHostInfoAgent::fromName(const QString &hostName)
{
-#if defined(Q_OS_WINCE)
- static QBasicMutex qPrivCEMutex;
- QMutexLocker locker(&qPrivCEMutex);
-#endif
-
QSysInfo::machineHostName(); // this initializes ws2_32.dll
// Load res_init on demand.
diff --git a/src/network/kernel/qnetworkdatagram.cpp b/src/network/kernel/qnetworkdatagram.cpp
new file mode 100644
index 0000000000..ba8a063edf
--- /dev/null
+++ b/src/network/kernel/qnetworkdatagram.cpp
@@ -0,0 +1,535 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Intel Corporation.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qnetworkdatagram.h"
+#include "qnetworkdatagram_p.h"
+
+#ifndef QT_NO_UDPSOCKET
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QNetworkDatagram
+ \brief The QNetworkDatagram class provides the data and matadata of a UDP datagram.
+ \since 5.8
+ \ingroup network
+ \inmodule QtNetwork
+ \reentrant
+
+ QNetworkDatagram can be used with the \l QUdpSocket class to represent the full
+ information contained in a UDP (User Datagram Protocol) datagram.
+ QNetworkDatagram encapsulates the following information of a datagram:
+ \list
+ \li the payload data;
+ \li the sender address and port number;
+ \li the destination address and port number;
+ \li the remaining hop count limit (on IPv4, this field is usually called "time to live" - TTL);
+ \li the network interface index the datagram was received on or to be sent on.
+ \endlist
+
+ QUdpSocket will try to match a common behavior as much as possible on all
+ operating systems, but not all of the metadata above can be obtained in
+ some operating systems. Metadata that cannot be set on the datagram when
+ sending with QUdpSocket::writeDatagram() will be silently discarded.
+
+ Upon reception, the senderAddress() and senderPort() properties contain the
+ address and port of the peer that sent the datagram, while
+ destinationAddress() and destinationPort() contain the target that was
+ contained in the datagram. That is usually an address local to the current
+ machine, but it can also be an IPv4 broadcast address (such as
+ "255.255.255.255") or an IPv4 or IPv6 multicast address. Applications may
+ find it useful to determine if the datagram was sent specifically to this
+ machine via unicast addressing or whether it was sent to multiple destinations.
+
+ When sending, the senderAddress() and senderPort() should contain the local
+ address to be used when sending. The sender address must be an address that
+ is assigned to this machine, which can be obtained using
+ \l{QNetworkInterface}, and the port number must be the port number that the
+ socket is bound to. Either field can be left unset and will be filled in by
+ the operating system with default values. The destinationAddress() and
+ destinationPort() fields may be set to a target address different from the
+ one the UDP socket is currently associated with.
+
+ Usually, when sending a datagram in reply to a datagram previously
+ received, one will set the destinationAddress() to be the senderAddress()
+ of the incoming datagram and similarly for the port numbers. To facilitate
+ this common process, QNetworkDatagram provides the function makeReply().
+
+ The hopCount() function contains, for a received datagram, the remaining
+ hop count limit for the packet. When sending, it contains the hop count
+ limit to be set. Most protocols will leave this value set to the default
+ and let the operating system decide on the best value to be used.
+ Multicasting over IPv4 often uses this field to indicate the scope of the
+ multicast group (link-local, local to an organization or global).
+
+ The interfaceIndex() function contains the index of the operating system's
+ interface that received the packet. This value is the same one that can be
+ set on a QHostAddress::scopeId() property and matches the
+ QNetworkInterface::index() property. When sending packets to global
+ addresses, it is not necessary to set the interface index as the operating
+ system will choose the correct one using the system routing table. This
+ property is important when sending datagrams to link-local destinations,
+ whether unicast or multicast.
+
+ \section1 Feature support
+
+ Some features of QNetworkDatagram are not supported in all operating systems.
+ Only the address and ports of the remote host (sender in received packets
+ and destination for outgoing packets) are supported in all systems. On most
+ operating systems, the other features are supported only for IPv6. Software
+ should check at runtime whether the rest could be determined for IPv4
+ addresses.
+
+ The current feature support is as follows:
+
+ \table
+ \header \li Operating system \li Local address \li Hop count \li Interface index
+ \row \li FreeBSD \li Supported \li Supported \li Only for IPv6
+ \row \li Linux \li Supported \li Supported \li Supported
+ \row \li OS X \li Supported \li Supported \li Only for IPv6
+ \row \li Other Unix supporting RFC 3542 \li Only for IPv6 \li Only for IPv6 \li Only for IPv6
+ \row \li Windows XP and older \li Not supported \li Not supported \li Not supported
+ \row \li Windows Vista & up \li Supported \li Supported \li Supported
+ \row \li Windows CE \li Not supported \li Not supported \li Not supported
+ \row \li Windows RT \li Not supported \li Not supported \li Not supported
+ \endtable
+
+ \sa QUdpSocket, QNetworkInterface
+ */
+
+/*!
+ Creates a QNetworkDatagram object with no payload data and undefined destination address.
+
+ The payload can be modified by using setData() and the destination address
+ can be set with setDestination().
+
+ If the destination address is left undefined, QUdpSocket::writeDatagram()
+ will attempt to send the datagram to the address last associated with, by
+ using QUdpSocket::connectToHost().
+ */
+QNetworkDatagram::QNetworkDatagram()
+ : d(new QNetworkDatagramPrivate)
+{
+}
+
+/*!
+ Creates a QNetworkDatagram object and sets \a data as the payload data, along with
+ \a destinationAddress and \a port as the destination address of the datagram.
+ */
+QNetworkDatagram::QNetworkDatagram(const QByteArray &data, const QHostAddress &destinationAddress, quint16 port)
+ : d(new QNetworkDatagramPrivate(data, destinationAddress, port))
+{
+}
+
+/*!
+ Creates a copy of the \a other datagram, including the payload and metadata.
+
+ To create a datagram suitable for sending in a reply, use QNetworkDatagram::makeReply();
+ */
+QNetworkDatagram::QNetworkDatagram(const QNetworkDatagram &other)
+ : d(new QNetworkDatagramPrivate(*other.d))
+{
+}
+
+/*! \internal */
+QNetworkDatagram::QNetworkDatagram(QNetworkDatagramPrivate &dd)
+ : d(&dd)
+{
+}
+
+/*!
+ Copies the \a other datagram, including the payload and metadata.
+
+ To create a datagram suitable for sending in a reply, use QNetworkDatagram::makeReply();
+ */
+QNetworkDatagram &QNetworkDatagram::operator=(const QNetworkDatagram &other)
+{
+ *d = *other.d;
+ return *this;
+}
+
+/*!
+ Clears the payload data and metadata in this QNetworkDatagram object, resetting
+ them to their default values.
+ */
+void QNetworkDatagram::clear()
+{
+ d->data.clear();
+ d->header.senderAddress.clear();
+ d->header.destinationAddress.clear();
+ d->header.hopLimit = -1;
+ d->header.ifindex = 0;
+}
+
+/*!
+ \fn QNetworkDatagram::isNull() const
+ Returns true if this QNetworkDatagram object is null. This function is the
+ opposite of isValid().
+ */
+
+/*!
+ Returns true if this QNetworkDatagram object is valid. A valid QNetworkDatagram
+ object contains at least one sender or receiver address. Valid datagrams
+ can contain empty payloads.
+ */
+bool QNetworkDatagram::isValid() const
+{
+ return d->header.senderAddress.protocol() != QAbstractSocket::UnknownNetworkLayerProtocol ||
+ d->header.destinationAddress.protocol() != QAbstractSocket::UnknownNetworkLayerProtocol;
+}
+
+/*!
+ Returns the sender address associated with this datagram. For a datagram
+ received from the network, it is the address of the peer node that sent the
+ datagram. For an outgoing datagrams, it is the local address to be used
+ when sending.
+
+ If no sender address was set on this datagram, the returned object will
+ report true to QHostAddress::isNull().
+
+ \sa destinationAddress(), senderPort(), setSender()
+*/
+QHostAddress QNetworkDatagram::senderAddress() const
+{
+ return d->header.senderAddress;
+}
+
+/*!
+ Returns the destination address associated with this datagram. For a
+ datagram received from the network, it is the address the peer node sent
+ the datagram to, which can either be a local address of this machine or a
+ multicast or broadcast address. For an outgoing datagrams, it is the
+ address the datagram should be sent to.
+
+ If no destination address was set on this datagram, the returned object
+ will report true to QHostAddress::isNull().
+
+ \sa senderAddress(), destinationPort(), setDestination()
+*/
+QHostAddress QNetworkDatagram::destinationAddress() const
+{
+ return d->header.destinationAddress;
+}
+
+/*!
+ Returns the port number of the sender associated with this datagram. For a
+ datagram received from the network, it is the port number that the peer
+ node sent the datagram from. For an outgoing datagram, it is the local port
+ the datagram should be sent from.
+
+ If no sender address was associated with this datagram, this function
+ returns -1.
+
+ \sa senderAddress(), destinationPort(), setSender()
+*/
+int QNetworkDatagram::senderPort() const
+{
+ return d->header.senderAddress.protocol() == QAbstractSocket::UnknownNetworkLayerProtocol
+ ? -1 : d->header.senderPort;
+}
+
+/*!
+ Returns the port number of the destination associated with this datagram.
+ For a datagram received from the network, it is the local port number that
+ the peer node sent the datagram to. For an outgoing datagram, it is the
+ peer port the datagram should be sent to.
+
+ If no destination address was associated with this datagram, this function
+ returns -1.
+
+ \sa destinationAddress(), senderPort(), setDestination()
+*/
+int QNetworkDatagram::destinationPort() const
+{
+ return d->header.destinationAddress.protocol() == QAbstractSocket::UnknownNetworkLayerProtocol
+ ? -1 : d->header.destinationPort;
+}
+
+/*!
+ Sets the sender address associated with this datagram to be the address \a
+ address and port number \a port. The sender address and port numbers are
+ usually set by \l QUdpSocket upon reception, so there's no need to call
+ this function on a received datagram.
+
+ For outgoing datagrams, this function can be used to set the address the
+ datagram should carry. The address \a address must usually be one of the
+ local addresses assigned to this machine, which can be obtained using \l
+ QNetworkInterface. If left unset, the operating system will choose the most
+ appropriate address to use given the destination in question.
+
+ The port number \a port must be the port number associated with the socket,
+ if there is one. The value of 0 can be used to indicate that the operating
+ system should choose the port number.
+
+ \sa QUdpSocket::writeDatagram(), senderAddress(), senderPort(), setDestination()
+ */
+void QNetworkDatagram::setSender(const QHostAddress &address, quint16 port)
+{
+ d->header.senderAddress = address;
+ d->header.senderPort = port;
+}
+
+/*!
+ Sets the destination address associated with this datagram to be the
+ address \a address and port number \a port. The destination address and
+ port numbers are usually set by \l QUdpSocket upon reception, so there's no
+ need to call this function on a received datagram.
+
+ For outgoing datagrams, this function can be used to set the address the
+ datagram should be sent to. It can be the unicast address used to
+ communicate with the peer or a broadcast or multicast address to send to a
+ group of devices.
+
+ \sa QUdpSocket::writeDatagram(), destinationAddress(), destinationPort(), setSender()
+ */
+void QNetworkDatagram::setDestination(const QHostAddress &address, quint16 port)
+{
+ d->header.destinationAddress = address;
+ d->header.destinationPort = port;
+}
+
+/*!
+ Returns the hop count limit associated with this datagram. The hop count
+ limit is the number of nodes that are allowed to forward the IP packet
+ before it expires and an error is sent back to the sender of the datagram.
+ In IPv4, this value is usually known as "time to live" (TTL).
+
+ If this datagram was received from the network, this is the remaining hop
+ count of the datagram after reception and was decremented by 1 by each node
+ that forwarded the packet. A value of -1 indicates that the hop limit count
+ not be obtained.
+
+ If this is an outgoing datagram, this is the value to be set in the IP header
+ upon sending. A value of -1 indicates the operating system should choose
+ the value.
+
+ \sa setHopLimit()
+ */
+int QNetworkDatagram::hopLimit() const
+{
+ return d->header.hopLimit;
+}
+
+/*!
+ Sets the hop count limit associated with this datagram to \a count. The hop
+ count limit is the number of nodes that are allowed to forward the IP
+ packet before it expires and an error is sent back to the sender of the
+ datagram. In IPv4, this value is usually known as "time to live" (TTL).
+
+ It is usually not necessary to call this function on datagrams received
+ from the network.
+
+ If this is an outgoing packet, this is the value to be set in the IP header
+ upon sending. The valid range for the value is 1 to 255. This function also
+ accepts a value of -1 to indicate that the operating system should choose
+ the value.
+
+ \sa hopLimit()
+ */
+void QNetworkDatagram::setHopLimit(int count)
+{
+ d->header.hopLimit = count;
+}
+
+/*!
+ Returns the interface index this datagram is associated with. The interface
+ index is a positive number that uniquely identifies the network interface
+ in the operating system. This number matches the value returned by
+ QNetworkInterface::index() for the interface.
+
+ If this datagram was received from the network, this is the index of the
+ interface that the packet was received from. If this is an outgoing
+ datagram, this is the index of the interface that the datagram should be
+ sent on.
+
+ A value of 0 indicates that the interface index is unknown.
+
+ \sa setInterfaceIndex()
+ */
+uint QNetworkDatagram::interfaceIndex() const
+{
+ return d->header.ifindex;
+}
+
+/*!
+ Sets the interface index this datagram is associated with to \a index. The
+ interface index is a positive number that uniquely identifies the network
+ interface in the operating system. This number matches the value returned
+ by QNetworkInterface::index() for the interface.
+
+ It is usually not necessary to call this function on datagrams received
+ from the network.
+
+ If this is an outgoing packet, this is the index of the interface the
+ datagram should be sent on. A value of 0 indicates that the operating
+ system should choose the interface based on other factors.
+
+ Note that the interface index can also be set with
+ QHostAddress::setScopeId() for IPv6 destination addresses and then with
+ setDestination(). If the scope ID set in the destination address and \a
+ index are different and neither is zero, it is undefined which interface
+ the operating system will send the datagram on.
+
+ \sa setInterfaceIndex()
+ */
+void QNetworkDatagram::setInterfaceIndex(uint index)
+{
+ d->header.ifindex = index;
+}
+
+/*!
+ Returns the data payload of this datagram. For a datagram received from the
+ network, it contains the payload of the datagram. For an outgoing datagram,
+ it is the datagram to be sent.
+
+ Note that datagrams can be transmitted with no data, so the returned
+ QByteArray may be empty.
+
+ \sa setData()
+ */
+QByteArray QNetworkDatagram::data() const
+{
+ return d->data;
+}
+
+/*!
+ Sets the data payload of this datagram to \a data. It is usually not
+ necessary to call this function on received datagrams. For outgoing
+ datagrams, this function sets the data to be sent on the network.
+
+ Since datagrams can empty, an empty QByteArray is a valid value for \a
+ data.
+
+ \sa data()
+ */
+void QNetworkDatagram::setData(const QByteArray &data)
+{
+ d->data = data;
+}
+
+/*!
+ \fn QNetworkDatagram QNetworkDatagram::makeReply(const QByteArray &data) const
+
+ Creates a new QNetworkDatagram representing a reply to this incoming datagram
+ and sets the payload data to \a data. This function is a very convenient
+ way of responding to a datagram back to the original sender.
+
+ Example:
+ \code
+ void Server::readPendingDatagrams()
+ {
+ while (udpSocket->hasPendingDatagrams()) {
+ QNetworkDatagram datagram = udpSocket->receiveDatagram();
+ QByteArray replyData = processThePayload(datagram.data());
+ udpSocket->writeDatagram(datagram.makeReply(replyData));
+ }
+ }
+ \endcode
+
+ This function is especially convenient since it will automatically copy
+ parameters from this datagram to the new datagram as appropriate:
+
+ \list
+ \li this datagram's sender address and port are copied to the new
+ datagram's destination address and port;
+ \li this datagram's interface index, if any, is copied to the new
+ datagram's interface index;
+ \li this datagram's destination address and port are copied to the new
+ datagram's sender address and port only if the address is IPv6
+ global (non-multicast) address;
+ \li the hop count limit on the new datagram is reset to the default (-1);
+ \endlist
+
+ If QNetworkDatagram is modified in a future version of Qt to carry further
+ metadata, this function will copy that metadata as appropriate.
+
+ This datagram's destination address is not copied if it is an IPv4 address
+ because it is not possible to tell an IPv4 broadcast address apart from a
+ regular IPv4 address without an exhaustive search of all addresses assigned
+ to this machine. Attempting to send a datagram with the sender address
+ equal to the broadcast address is likely to fail. However, this should not
+ affect the communication as network interfaces with multiple IPv4 addresses
+ are uncommon, so the address the operating system will select will likely
+ be one the peer will understand.
+
+ \note This function comes with both rvalue- and lvalue-reference qualifier
+ overloads, so it is a good idea to make sure this object is rvalue, if
+ possible, before calling makeReply, so as to make better use of move
+ semantics. To achieve that, the example above would use:
+ \code
+ udpSocket->writeDatagram(std::move(datagram).makeReply(replyData));
+ \endcode
+ */
+
+static bool isNonMulticast(const QHostAddress &addr)
+{
+ // is it a multicast address?
+ return !addr.isMulticast();
+}
+
+QNetworkDatagram QNetworkDatagram::makeReply_helper(const QByteArray &data) const
+{
+ QNetworkDatagramPrivate *x = new QNetworkDatagramPrivate(data, d->header.senderAddress, d->header.senderPort);
+ x->header.ifindex = d->header.ifindex;
+ if (isNonMulticast(d->header.destinationAddress)) {
+ x->header.senderAddress = d->header.destinationAddress;
+ x->header.senderPort = d->header.destinationPort;
+ }
+ return QNetworkDatagram(*x);
+}
+
+void QNetworkDatagram::makeReply_helper_inplace(const QByteArray &data)
+{
+ d->data = data;
+ d->header.hopLimit = -1;
+ qSwap(d->header.destinationPort, d->header.senderPort);
+ qSwap(d->header.destinationAddress, d->header.senderAddress);
+ if (!isNonMulticast(d->header.senderAddress))
+ d->header.senderAddress.clear();
+}
+
+void QNetworkDatagram::destroy(QNetworkDatagramPrivate *d)
+{
+ Q_ASSUME(d);
+ delete d;
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_UDPSOCKET
diff --git a/src/network/kernel/qnetworkdatagram.h b/src/network/kernel/qnetworkdatagram.h
new file mode 100644
index 0000000000..a20d69185a
--- /dev/null
+++ b/src/network/kernel/qnetworkdatagram.h
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Intel Corporation.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QNETWORKDATAGRAM_H
+#define QNETWORKDATAGRAM_H
+
+#include <QtCore/qbytearray.h>
+#include <QtNetwork/qhostaddress.h>
+
+#ifndef QT_NO_UDPSOCKET
+
+QT_BEGIN_NAMESPACE
+
+class QNetworkDatagramPrivate;
+class QUdpSocketPrivate;
+
+class Q_NETWORK_EXPORT QNetworkDatagram
+{
+public:
+ QNetworkDatagram();
+ QNetworkDatagram(const QByteArray &data, const QHostAddress &destinationAddress = QHostAddress(),
+ quint16 port = 0); // implicit
+ QNetworkDatagram(const QNetworkDatagram &other);
+ QNetworkDatagram &operator=(const QNetworkDatagram &other);
+ ~QNetworkDatagram()
+ { if (d) destroy(d); }
+
+ QNetworkDatagram(QNetworkDatagram &&other) Q_DECL_NOTHROW
+ : d(other.d)
+ { other.d = Q_NULLPTR; }
+ QNetworkDatagram &operator=(QNetworkDatagram &&other) Q_DECL_NOTHROW
+ { swap(other); return *this; }
+
+ void swap(QNetworkDatagram &other) Q_DECL_NOTHROW
+ { qSwap(d, other.d); }
+
+ void clear();
+ bool isValid() const;
+ bool isNull() const
+ { return !isValid(); }
+
+ uint interfaceIndex() const;
+ void setInterfaceIndex(uint index);
+
+ QHostAddress senderAddress() const;
+ QHostAddress destinationAddress() const;
+ int senderPort() const;
+ int destinationPort() const;
+ void setSender(const QHostAddress &address, quint16 port = 0);
+ void setDestination(const QHostAddress &address, quint16 port);
+
+ int hopLimit() const;
+ void setHopLimit(int count);
+
+ QByteArray data() const;
+ void setData(const QByteArray &data);
+
+#ifdef Q_COMPILER_REF_QUALIFIERS
+ QNetworkDatagram makeReply(const QByteArray &payload) const &
+ { return makeReply_helper(payload); }
+ QNetworkDatagram makeReply(const QByteArray &payload) &&
+ { makeReply_helper_inplace(payload); return *this; }
+#else
+ QNetworkDatagram makeReply(const QByteArray &paylaod) const
+ { return makeReply_helper(paylaod); }
+#endif
+
+private:
+ QNetworkDatagramPrivate *d;
+ friend class QUdpSocket;
+ friend class QSctpSocket;
+
+ explicit QNetworkDatagram(QNetworkDatagramPrivate &dd);
+ QNetworkDatagram makeReply_helper(const QByteArray &data) const;
+ void makeReply_helper_inplace(const QByteArray &data);
+ static void destroy(QNetworkDatagramPrivate *d);
+};
+
+Q_DECLARE_SHARED(QNetworkDatagram)
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QNetworkDatagram)
+
+#endif // QT_NO_UDPSOCKET
+
+#endif // QNETWORKDATAGRAM_H
diff --git a/src/network/kernel/qnetworkdatagram_p.h b/src/network/kernel/qnetworkdatagram_p.h
index 4941d8c94b..e55651a78b 100644
--- a/src/network/kernel/qnetworkdatagram_p.h
+++ b/src/network/kernel/qnetworkdatagram_p.h
@@ -45,6 +45,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include <QtNetwork/qhostaddress.h>
QT_BEGIN_NAMESPACE
@@ -53,7 +54,8 @@ class QIpPacketHeader
{
public:
QIpPacketHeader(const QHostAddress &dstAddr = QHostAddress(), quint16 port = 0)
- : destinationAddress(dstAddr), ifindex(0), hopLimit(-1), destinationPort(port)
+ : destinationAddress(dstAddr), ifindex(0), hopLimit(-1), streamNumber(-1),
+ destinationPort(port), endOfRecord(false)
{}
void clear()
@@ -62,6 +64,8 @@ public:
destinationAddress.clear();
ifindex = 0;
hopLimit = -1;
+ streamNumber = -1;
+ endOfRecord = false;
}
QHostAddress senderAddress;
@@ -69,8 +73,25 @@ public:
uint ifindex;
int hopLimit;
+ int streamNumber;
quint16 senderPort;
quint16 destinationPort;
+ bool endOfRecord;
+};
+
+class QNetworkDatagramPrivate
+{
+public:
+ QNetworkDatagramPrivate(const QByteArray &data = QByteArray(),
+ const QHostAddress &dstAddr = QHostAddress(), quint16 port = 0)
+ : data(data), header(dstAddr, port)
+ {}
+ QNetworkDatagramPrivate(const QByteArray &data, const QIpPacketHeader &header)
+ : data(data), header(header)
+ {}
+
+ QByteArray data;
+ QIpPacketHeader header;
};
QT_END_NAMESPACE
diff --git a/src/network/kernel/qnetworkfunctions_wince.h b/src/network/kernel/qnetworkfunctions_wince.h
deleted file mode 100644
index 0e464a47f3..0000000000
--- a/src/network/kernel/qnetworkfunctions_wince.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QNETWORKFUNCTIONS_WINCE_H
-#define QNETWORKFUNCTIONS_WINCE_H
-
-#if 0
-#pragma qt_sync_stop_processing
-#endif
-
-#ifdef Q_OS_WINCE
-
-#include <qt_windows.h>
-
-QT_BEGIN_NAMESPACE
-
-DECLARE_HANDLE(SC_HANDLE);
-typedef enum _SC_ENUM_TYPE {
- SC_ENUM_PROCESS_INFO = 0
-} SC_ENUM_TYPE;
-#define SC_MANAGER_CONNECT 0x0001
-#define SC_MANAGER_CREATE_SERVICE 0x0002
-#define SC_MANAGER_ENUMERATE_SERVICE 0x0004
-#define SERVICE_ACTIVE 0x00000001
-#define SERVICE_INACTIVE 0x00000002
-#define SERVICE_STATE_ALL (SERVICE_ACTIVE | \
- SERVICE_INACTIVE)
-typedef struct _SERVICE_STATUS_PROCESS {
- DWORD dwServiceType;
- DWORD dwCurrentState;
- DWORD dwControlsAccepted;
- DWORD dwWin32ExitCode;
- DWORD dwServiceSpecificExitCode;
- DWORD dwCheckPoint;
- DWORD dwWaitHint;
- DWORD dwProcessId;
- DWORD dwServiceFlags;
-} SERVICE_STATUS_PROCESS, *LPSERVICE_STATUS_PROCESS;
-typedef struct _ENUM_SERVICE_STATUS_PROCESSA {
- LPSTR lpServiceName;
- LPSTR lpDisplayName;
- SERVICE_STATUS_PROCESS ServiceStatusProcess;
-} ENUM_SERVICE_STATUS_PROCESSA, *LPENUM_SERVICE_STATUS_PROCESSA;
-typedef struct _ENUM_SERVICE_STATUS_PROCESSW {
- LPWSTR lpServiceName;
- LPWSTR lpDisplayName;
- SERVICE_STATUS_PROCESS ServiceStatusProcess;
-} ENUM_SERVICE_STATUS_PROCESSW, *LPENUM_SERVICE_STATUS_PROCESSW;
-#ifdef UNICODE
-typedef ENUM_SERVICE_STATUS_PROCESSW ENUM_SERVICE_STATUS_PROCESS;
-typedef LPENUM_SERVICE_STATUS_PROCESSW LPENUM_SERVICE_STATUS_PROCESS;
-#else
-typedef ENUM_SERVICE_STATUS_PROCESSA ENUM_SERVICE_STATUS_PROCESS;
-typedef LPENUM_SERVICE_STATUS_PROCESSA LPENUM_SERVICE_STATUS_PROCESS;
-#endif // UNICODE
-
-QT_END_NAMESPACE
-
-#endif // Q_OS_WINCE
-#endif // QNETWORKFUNCTIONS_WINCE_H
diff --git a/src/network/kernel/qnetworkinterface.cpp b/src/network/kernel/qnetworkinterface.cpp
index 28893aa71c..c5d1adbef0 100644
--- a/src/network/kernel/qnetworkinterface.cpp
+++ b/src/network/kernel/qnetworkinterface.cpp
@@ -536,7 +536,7 @@ QList<QNetworkAddressEntry> QNetworkInterface::addressEntries() const
QNetworkInterface::interfaceFromName(name).index()
\endcode
- \sa interfaceFromName(), interfaceNameFromIndex()
+ \sa interfaceFromName(), interfaceNameFromIndex(), QNetworkDatagram::interfaceIndex()
*/
int QNetworkInterface::interfaceIndexFromName(const QString &name)
{
@@ -596,7 +596,7 @@ QNetworkInterface QNetworkInterface::interfaceFromIndex(int index)
QNetworkInterface::interfaceFromIndex(index).name()
\endcode
- \sa interfaceFromIndex(), interfaceIndexFromName()
+ \sa interfaceFromIndex(), interfaceIndexFromName(), QNetworkDatagram::interfaceIndex()
*/
QString QNetworkInterface::interfaceNameFromIndex(int index)
{
diff --git a/src/network/kernel/qnetworkinterface.h b/src/network/kernel/qnetworkinterface.h
index c519de8081..c31621c3cb 100644
--- a/src/network/kernel/qnetworkinterface.h
+++ b/src/network/kernel/qnetworkinterface.h
@@ -40,6 +40,7 @@
#ifndef QNETWORKINTERFACE_H
#define QNETWORKINTERFACE_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qshareddata.h>
#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qhostaddress.h>
diff --git a/src/network/kernel/qnetworkinterface_p.h b/src/network/kernel/qnetworkinterface_p.h
index aa21d7f92c..2dfc93cc18 100644
--- a/src/network/kernel/qnetworkinterface_p.h
+++ b/src/network/kernel/qnetworkinterface_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include <QtCore/qatomic.h>
#include <QtCore/qlist.h>
#include <QtCore/qreadwritelock.h>
diff --git a/src/network/kernel/qnetworkinterface_win.cpp b/src/network/kernel/qnetworkinterface_win.cpp
index 0a82eac417..3002b2497b 100644
--- a/src/network/kernel/qnetworkinterface_win.cpp
+++ b/src/network/kernel/qnetworkinterface_win.cpp
@@ -81,19 +81,11 @@ static void resolveLibs()
HINSTANCE iphlpapiHnd = GetModuleHandle(L"iphlpapi");
Q_ASSERT(iphlpapiHnd);
-#if defined(Q_OS_WINCE)
- // since Windows Embedded Compact 7
- ptrConvertInterfaceIndexToLuid = (PtrConvertInterfaceIndexToLuid)GetProcAddress(iphlpapiHnd, L"ConvertInterfaceIndexToLuid");
- ptrConvertInterfaceLuidToName = (PtrConvertInterfaceLuidToName)GetProcAddress(iphlpapiHnd, L"ConvertInterfaceLuidToNameW");
- ptrConvertInterfaceLuidToIndex = (PtrConvertInterfaceLuidToIndex)GetProcAddress(iphlpapiHnd, L"ConvertInterfaceLuidToIndex");
- ptrConvertInterfaceNameToLuid = (PtrConvertInterfaceNameToLuid)GetProcAddress(iphlpapiHnd, L"ConvertInterfaceNameToLuidW");
-#else
// since Windows Vista
ptrConvertInterfaceIndexToLuid = (PtrConvertInterfaceIndexToLuid)GetProcAddress(iphlpapiHnd, "ConvertInterfaceIndexToLuid");
ptrConvertInterfaceLuidToName = (PtrConvertInterfaceLuidToName)GetProcAddress(iphlpapiHnd, "ConvertInterfaceLuidToNameW");
ptrConvertInterfaceLuidToIndex = (PtrConvertInterfaceLuidToIndex)GetProcAddress(iphlpapiHnd, "ConvertInterfaceLuidToIndex");
ptrConvertInterfaceNameToLuid = (PtrConvertInterfaceNameToLuid)GetProcAddress(iphlpapiHnd, "ConvertInterfaceNameToLuidW");
-#endif
done = true;
}
}
diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp
index 645f74c616..bb1a7d0d8b 100644
--- a/src/network/kernel/qnetworkproxy.cpp
+++ b/src/network/kernel/qnetworkproxy.cpp
@@ -212,6 +212,12 @@
lookup on a remote host name and connect to it, as opposed to
requiring the application to perform the name lookup and request
connection to IP addresses only.
+
+ \value SctpTunnelingCapability Ability to open transparent, tunneled
+ SCTP connections to a remote host.
+
+ \value SctpListeningCapability Ability to create a listening socket
+ and wait for an incoming SCTP connection from a remote host.
*/
#include "qnetworkproxy.h"
@@ -369,7 +375,9 @@ static QNetworkProxy::Capabilities defaultCapabilitiesForType(QNetworkProxy::Pro
/* [QNetworkProxy::DefaultProxy] = */
(int(QNetworkProxy::ListeningCapability) |
int(QNetworkProxy::TunnelingCapability) |
- int(QNetworkProxy::UdpTunnelingCapability)),
+ int(QNetworkProxy::UdpTunnelingCapability) |
+ int(QNetworkProxy::SctpTunnelingCapability) |
+ int(QNetworkProxy::SctpListeningCapability)),
/* [QNetworkProxy::Socks5Proxy] = */
(int(QNetworkProxy::TunnelingCapability) |
int(QNetworkProxy::ListeningCapability) |
@@ -379,7 +387,9 @@ static QNetworkProxy::Capabilities defaultCapabilitiesForType(QNetworkProxy::Pro
/* [QNetworkProxy::NoProxy] = */
(int(QNetworkProxy::ListeningCapability) |
int(QNetworkProxy::TunnelingCapability) |
- int(QNetworkProxy::UdpTunnelingCapability)),
+ int(QNetworkProxy::UdpTunnelingCapability) |
+ int(QNetworkProxy::SctpTunnelingCapability) |
+ int(QNetworkProxy::SctpListeningCapability)),
/* [QNetworkProxy::HttpProxy] = */
(int(QNetworkProxy::TunnelingCapability) |
int(QNetworkProxy::CachingCapability) |
@@ -966,6 +976,14 @@ template<> void QSharedDataPointer<QNetworkProxyQueryPrivate>::detach()
characteristics of the socket. The URL component is not used.
\row
+ \li SctpSocket
+ \li Message-oriented sockets requesting a connection to a remote
+ server. The peer hostname and peer port match the values passed
+ to QSctpSocket::connectToHost(). The local port is usually -1,
+ indicating the socket has no preference in which port should be
+ used. The URL component is not used.
+
+ \row
\li TcpServer
\li Passive server sockets that listen on a port and await
incoming connections from the network. Normally, only the
@@ -981,6 +999,14 @@ template<> void QSharedDataPointer<QNetworkProxyQueryPrivate>::detach()
indicate that more detailed information is present in the URL
component. For ease of implementation, the URL's host and
port are set as the destination address.
+
+ \row
+ \li SctpServer
+ \li Passive server sockets that listen on an SCTP port and await
+ incoming connections from the network. Normally, only the
+ local port is used, but the remote address could be used in
+ specific circumstances, for example to indicate which remote
+ host a connection is expected from. The URL component is not used.
\endtable
It should be noted that any of the criteria may be missing or
@@ -1001,10 +1027,13 @@ template<> void QSharedDataPointer<QNetworkProxyQueryPrivate>::detach()
\value TcpSocket a normal, outgoing TCP socket
\value UdpSocket a datagram-based UDP socket, which could send
to multiple destinations
+ \value SctpSocket a message-oriented, outgoing SCTP socket
\value TcpServer a TCP server that listens for incoming
connections from the network
\value UrlRequest a more complex request which involves loading
of a URL
+ \value SctpServer an SCTP server that listens for incoming
+ connections from the network
\sa queryType(), setQueryType()
*/
@@ -1614,6 +1643,10 @@ QDebug operator<<(QDebug debug, const QNetworkProxy &proxy)
scaps << QStringLiteral("Caching");
if (caps & QNetworkProxy::HostNameLookupCapability)
scaps << QStringLiteral("NameLookup");
+ if (caps & QNetworkProxy::SctpTunnelingCapability)
+ scaps << QStringLiteral("SctpTunnel");
+ if (caps & QNetworkProxy::SctpListeningCapability)
+ scaps << QStringLiteral("SctpListen");
debug << '[' << scaps.join(QLatin1Char(' ')) << ']';
return debug;
}
diff --git a/src/network/kernel/qnetworkproxy.h b/src/network/kernel/qnetworkproxy.h
index e60a84fa34..fc919a24a6 100644
--- a/src/network/kernel/qnetworkproxy.h
+++ b/src/network/kernel/qnetworkproxy.h
@@ -40,6 +40,7 @@
#ifndef QNETWORKPROXY_H
#define QNETWORKPROXY_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtNetwork/qhostaddress.h>
#include <QtNetwork/qnetworkrequest.h>
#include <QtCore/qshareddata.h>
@@ -59,8 +60,10 @@ public:
enum QueryType {
TcpSocket,
UdpSocket,
+ SctpSocket,
TcpServer = 100,
- UrlRequest
+ UrlRequest,
+ SctpServer
};
QNetworkProxyQuery();
@@ -140,7 +143,9 @@ public:
ListeningCapability = 0x0002,
UdpTunnelingCapability = 0x0004,
CachingCapability = 0x0008,
- HostNameLookupCapability = 0x0010
+ HostNameLookupCapability = 0x0010,
+ SctpTunnelingCapability = 0x00020,
+ SctpListeningCapability = 0x00040
};
Q_DECLARE_FLAGS(Capabilities, Capability)
diff --git a/src/network/kernel/qnetworkproxy_mac.cpp b/src/network/kernel/qnetworkproxy_mac.cpp
index 06a6fbac45..37126298c6 100644
--- a/src/network/kernel/qnetworkproxy_mac.cpp
+++ b/src/network/kernel/qnetworkproxy_mac.cpp
@@ -234,60 +234,55 @@ QList<QNetworkProxy> macQueryInternal(const QNetworkProxyQuery &query)
QCFType<CFStringRef> cfPacLocation = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, pacLocationSetting, NULL, NULL,
kCFStringEncodingUTF8);
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
- QCFType<CFDataRef> pacData;
- QCFType<CFURLRef> pacUrl = CFURLCreateWithString(kCFAllocatorDefault, cfPacLocation, NULL);
- if (!pacUrl) {
- qWarning("Invalid PAC URL \"%s\"", qPrintable(QCFString::toQString(cfPacLocation)));
- return result;
- }
- SInt32 errorCode;
- if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, pacUrl, &pacData, NULL, NULL, &errorCode)) {
- QString pacLocation = QCFString::toQString(cfPacLocation);
- qWarning("Unable to get the PAC script at \"%s\" (%s)", qPrintable(pacLocation), cfurlErrorDescription(errorCode));
- return result;
- }
- if (!pacData) {
- qWarning("\"%s\" returned an empty PAC script", qPrintable(QCFString::toQString(cfPacLocation)));
- return result;
- }
- QCFType<CFStringRef> pacScript = CFStringCreateFromExternalRepresentation(kCFAllocatorDefault, pacData, kCFStringEncodingISOLatin1);
- if (!pacScript) {
- // This should never happen, but the documentation says it may return NULL if there was a problem creating the object.
- QString pacLocation = QCFString::toQString(cfPacLocation);
- qWarning("Unable to read the PAC script at \"%s\"", qPrintable(pacLocation));
- return result;
- }
-
- QByteArray encodedURL = query.url().toEncoded(); // converted to UTF-8
- if (encodedURL.isEmpty()) {
- return result; // Invalid URL, abort
- }
-
- QCFType<CFURLRef> targetURL = CFURLCreateWithBytes(kCFAllocatorDefault, (UInt8*)encodedURL.data(), encodedURL.size(), kCFStringEncodingUTF8, NULL);
- if (!targetURL) {
- return result; // URL creation problem, abort
- }
-
- QCFType<CFErrorRef> pacError;
- QCFType<CFArrayRef> proxies = CFNetworkCopyProxiesForAutoConfigurationScript(pacScript, targetURL, &pacError);
- if (!proxies) {
- QString pacLocation = QCFString::toQString(cfPacLocation);
- QCFType<CFStringRef> pacErrorDescription = CFErrorCopyDescription(pacError);
- qWarning("Execution of PAC script at \"%s\" failed: %s", qPrintable(pacLocation), qPrintable(QCFString::toQString(pacErrorDescription)));
- return result;
- }
-
- CFIndex size = CFArrayGetCount(proxies);
- for (CFIndex i = 0; i < size; ++i) {
- CFDictionaryRef proxy = (CFDictionaryRef)CFArrayGetValueAtIndex(proxies, i);
- result << proxyFromDictionary(proxy);
- }
+ QCFType<CFDataRef> pacData;
+ QCFType<CFURLRef> pacUrl = CFURLCreateWithString(kCFAllocatorDefault, cfPacLocation, NULL);
+ if (!pacUrl) {
+ qWarning("Invalid PAC URL \"%s\"", qPrintable(QCFString::toQString(cfPacLocation)));
return result;
- } else {
+ }
+ SInt32 errorCode;
+ if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, pacUrl, &pacData, NULL, NULL, &errorCode)) {
QString pacLocation = QCFString::toQString(cfPacLocation);
- qWarning("Mac system proxy: PAC script at \"%s\" not handled", qPrintable(pacLocation));
+ qWarning("Unable to get the PAC script at \"%s\" (%s)", qPrintable(pacLocation), cfurlErrorDescription(errorCode));
+ return result;
+ }
+ if (!pacData) {
+ qWarning("\"%s\" returned an empty PAC script", qPrintable(QCFString::toQString(cfPacLocation)));
+ return result;
+ }
+ QCFType<CFStringRef> pacScript = CFStringCreateFromExternalRepresentation(kCFAllocatorDefault, pacData, kCFStringEncodingISOLatin1);
+ if (!pacScript) {
+ // This should never happen, but the documentation says it may return NULL if there was a problem creating the object.
+ QString pacLocation = QCFString::toQString(cfPacLocation);
+ qWarning("Unable to read the PAC script at \"%s\"", qPrintable(pacLocation));
+ return result;
+ }
+
+ QByteArray encodedURL = query.url().toEncoded(); // converted to UTF-8
+ if (encodedURL.isEmpty()) {
+ return result; // Invalid URL, abort
+ }
+
+ QCFType<CFURLRef> targetURL = CFURLCreateWithBytes(kCFAllocatorDefault, (UInt8*)encodedURL.data(), encodedURL.size(), kCFStringEncodingUTF8, NULL);
+ if (!targetURL) {
+ return result; // URL creation problem, abort
+ }
+
+ QCFType<CFErrorRef> pacError;
+ QCFType<CFArrayRef> proxies = CFNetworkCopyProxiesForAutoConfigurationScript(pacScript, targetURL, &pacError);
+ if (!proxies) {
+ QString pacLocation = QCFString::toQString(cfPacLocation);
+ QCFType<CFStringRef> pacErrorDescription = CFErrorCopyDescription(pacError);
+ qWarning("Execution of PAC script at \"%s\" failed: %s", qPrintable(pacLocation), qPrintable(QCFString::toQString(pacErrorDescription)));
+ return result;
+ }
+
+ CFIndex size = CFArrayGetCount(proxies);
+ for (CFIndex i = 0; i < size; ++i) {
+ CFDictionaryRef proxy = (CFDictionaryRef)CFArrayGetValueAtIndex(proxies, i);
+ result << proxyFromDictionary(proxy);
}
+ return result;
}
}
diff --git a/src/network/kernel/qnetworkproxy_p.h b/src/network/kernel/qnetworkproxy_p.h
index 74cc4105a0..0b0dcd3a68 100644
--- a/src/network/kernel/qnetworkproxy_p.h
+++ b/src/network/kernel/qnetworkproxy_p.h
@@ -52,6 +52,8 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
+
#ifndef QT_NO_NETWORKPROXY
QT_BEGIN_NAMESPACE
diff --git a/src/network/kernel/qnetworkproxy_win.cpp b/src/network/kernel/qnetworkproxy_win.cpp
index 513eeaac12..949f9fe12b 100644
--- a/src/network/kernel/qnetworkproxy_win.cpp
+++ b/src/network/kernel/qnetworkproxy_win.cpp
@@ -53,7 +53,6 @@
#include <qt_windows.h>
#include <wininet.h>
#include <lmcons.h>
-#include "qnetworkfunctions_wince.h"
/*
* Information on the WinHTTP DLL:
@@ -123,7 +122,6 @@ static PtrWinHttpGetIEProxyConfigForCurrentUser ptrWinHttpGetIEProxyConfigForCur
static PtrWinHttpCloseHandle ptrWinHttpCloseHandle = 0;
-#ifndef Q_OS_WINCE
static bool currentProcessIsService()
{
typedef BOOL (WINAPI *PtrGetUserName)(LPTSTR lpBuffer, LPDWORD lpnSize);
@@ -153,7 +151,6 @@ static bool currentProcessIsService()
}
return false;
}
-#endif // ! Q_OS_WINCE
static QStringList splitSpaceSemicolon(const QString &source)
{
@@ -235,9 +232,15 @@ static QList<QNetworkProxy> filterProxyListByCapabilities(const QList<QNetworkPr
case QNetworkProxyQuery::UdpSocket:
requiredCaps = QNetworkProxy::UdpTunnelingCapability;
break;
+ case QNetworkProxyQuery::SctpSocket:
+ requiredCaps = QNetworkProxy::SctpTunnelingCapability;
+ break;
case QNetworkProxyQuery::TcpServer:
requiredCaps = QNetworkProxy::ListeningCapability;
break;
+ case QNetworkProxyQuery::SctpServer:
+ requiredCaps = QNetworkProxy::SctpListeningCapability;
+ break;
default:
return proxyList;
break;
@@ -284,7 +287,10 @@ static QList<QNetworkProxy> parseServerList(const QNetworkProxyQuery &query, con
QList<QNetworkProxy> result;
QHash<QString, QNetworkProxy> taggedProxies;
const QString requiredTag = query.protocolTag();
- bool checkTags = !requiredTag.isEmpty() && query.queryType() != QNetworkProxyQuery::TcpServer; //windows tags are only for clients
+ // windows tags are only for clients
+ bool checkTags = !requiredTag.isEmpty()
+ && query.queryType() != QNetworkProxyQuery::TcpServer
+ && query.queryType() != QNetworkProxyQuery::SctpServer;
for (const QString &entry : proxyList) {
int server = 0;
@@ -361,7 +367,7 @@ static QList<QNetworkProxy> parseServerList(const QNetworkProxyQuery &query, con
return removeDuplicateProxies(result);
}
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
namespace {
class QRegistryWatcher {
public:
@@ -412,7 +418,7 @@ private:
QVector<HKEY> m_registryHandles;
};
} // namespace
-#endif // !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#endif // !defined(Q_OS_WINRT)
class QWindowsSystemProxy
{
@@ -431,7 +437,7 @@ public:
QStringList proxyServerList;
QStringList proxyBypass;
QList<QNetworkProxy> defaultResult;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
QRegistryWatcher proxySettingsWatcher;
#endif
bool initialized;
@@ -467,7 +473,7 @@ void QWindowsSystemProxy::reset()
void QWindowsSystemProxy::init()
{
bool proxySettingsChanged = false;
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
proxySettingsChanged = proxySettingsWatcher.hasChanged();
#endif
@@ -477,12 +483,7 @@ void QWindowsSystemProxy::init()
reset();
-#ifdef Q_OS_WINCE
- // Windows CE does not have any of the following API
- return;
-#else
-
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT)
proxySettingsWatcher.clear(); // needs reset to trigger a new detection
proxySettingsWatcher.addLocation(HKEY_CURRENT_USER, QStringLiteral("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"));
proxySettingsWatcher.addLocation(HKEY_LOCAL_MACHINE, QStringLiteral("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"));
@@ -570,7 +571,6 @@ void QWindowsSystemProxy::init()
}
functional = isAutoConfig || !proxyServerList.isEmpty();
-#endif
}
QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkProxyQuery &query)
diff --git a/src/network/kernel/qtnetworkglobal.h b/src/network/kernel/qtnetworkglobal.h
new file mode 100644
index 0000000000..192601970a
--- /dev/null
+++ b/src/network/kernel/qtnetworkglobal.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTNETWORKGLOBAL_H
+#define QTNETWORKGLOBAL_H
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_STATIC
+# if defined(QT_BUILD_NETWORK_LIB)
+# define Q_NETWORK_EXPORT Q_DECL_EXPORT
+# else
+# define Q_NETWORK_EXPORT Q_DECL_IMPORT
+# endif
+#else
+# define Q_NETWORK_EXPORT
+#endif
+
+QT_END_NAMESPACE
+
+#endif
+
diff --git a/src/network/kernel/qtnetworkglobal_p.h b/src/network/kernel/qtnetworkglobal_p.h
new file mode 100644
index 0000000000..51347e440d
--- /dev/null
+++ b/src/network/kernel/qtnetworkglobal_p.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTNETWORKGLOBAL_P_H
+#define QTNETWORKGLOBAL_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtNetwork/qtnetworkglobal.h>
+#include <QtCore/private/qglobal_p.h>
+
+#endif // QTNETWORKGLOBAL_P_H
diff --git a/src/network/kernel/qurlinfo_p.h b/src/network/kernel/qurlinfo_p.h
index b239f94c31..3a430a3321 100644
--- a/src/network/kernel/qurlinfo_p.h
+++ b/src/network/kernel/qurlinfo_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qstring.h>
#include <QtCore/qiodevice.h>
diff --git a/src/network/network.pro b/src/network/network.pro
index 256d718df6..75105bd681 100644
--- a/src/network/network.pro
+++ b/src/network/network.pro
@@ -9,6 +9,7 @@ DEFINES += QT_NO_USING_NAMESPACE QT_NO_FOREACH
#DEFINES += QABSTRACTSOCKET_DEBUG QNATIVESOCKETENGINE_DEBUG
#DEFINES += QTCPSOCKETENGINE_DEBUG QTCPSOCKET_DEBUG QTCPSERVER_DEBUG QSSLSOCKET_DEBUG
#DEFINES += QUDPSOCKET_DEBUG QUDPSERVER_DEBUG
+#DEFINES += QSCTPSOCKET_DEBUG QSCTPSERVER_DEBUG
win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x64000000
QMAKE_DOCS = $$PWD/doc/qtnetwork.qdocconf
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 5a51017264..662c8e957e 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -267,7 +267,8 @@
\value TcpSocket TCP
\value UdpSocket UDP
- \value UnknownSocketType Other than TCP and UDP
+ \value SctpSocket SCTP
+ \value UnknownSocketType Other than TCP, UDP and SCTP
\sa QAbstractSocket::socketType()
*/
@@ -563,6 +564,7 @@ QAbstractSocketPrivate::QAbstractSocketPrivate()
cachedSocketDescriptor(-1),
readBufferMaxSize(0),
isBuffered(false),
+ hasPendingData(false),
connectTimer(0),
disconnectTimer(0),
hostLookupId(-1),
@@ -593,6 +595,7 @@ void QAbstractSocketPrivate::resetSocketLayer()
qDebug("QAbstractSocketPrivate::resetSocketLayer()");
#endif
+ hasPendingData = false;
if (socketEngine) {
socketEngine->close();
socketEngine->disconnect();
@@ -624,6 +627,7 @@ bool QAbstractSocketPrivate::initSocketLayer(QAbstractSocket::NetworkLayerProtoc
QString typeStr;
if (q->socketType() == QAbstractSocket::TcpSocket) typeStr = QLatin1String("TcpSocket");
else if (q->socketType() == QAbstractSocket::UdpSocket) typeStr = QLatin1String("UdpSocket");
+ else if (q->socketType() == QAbstractSocket::SctpSocket) typeStr = QLatin1String("SctpSocket");
else typeStr = QLatin1String("UnknownSocketType");
QString protocolStr;
if (protocol == QAbstractSocket::IPv4Protocol) protocolStr = QLatin1String("IPv4Protocol");
@@ -668,6 +672,12 @@ bool QAbstractSocketPrivate::initSocketLayer(QAbstractSocket::NetworkLayerProtoc
*/
void QAbstractSocketPrivate::configureCreatedSocket()
{
+#ifndef QT_NO_SCTP
+ Q_Q(QAbstractSocket);
+ // Set single stream mode for unbuffered SCTP socket
+ if (socketEngine && q->socketType() == QAbstractSocket::SctpSocket)
+ socketEngine->setOption(QAbstractSocketEngine::MaxStreamsSocketOption, 1);
+#endif
}
/*! \internal
@@ -683,8 +693,13 @@ bool QAbstractSocketPrivate::canReadNotification()
qDebug("QAbstractSocketPrivate::canReadNotification()");
#endif
- if (!isBuffered)
- socketEngine->setReadNotificationEnabled(false);
+ if (!isBuffered) {
+ if (hasPendingData) {
+ socketEngine->setReadNotificationEnabled(false);
+ return true;
+ }
+ hasPendingData = true;
+ }
// If buffered, read data from the socket into the read buffer
if (isBuffered) {
@@ -692,6 +707,7 @@ bool QAbstractSocketPrivate::canReadNotification()
// Return if there is no space in the buffer
if (readBufferMaxSize && oldBufferSize >= readBufferMaxSize) {
+ socketEngine->setReadNotificationEnabled(false);
#if defined (QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocketPrivate::canReadNotification() buffer is full");
#endif
@@ -714,11 +730,6 @@ bool QAbstractSocketPrivate::canReadNotification()
// to indicate that the data was discarded.
return !q->isReadable();
}
-
- // If read buffer is full, disable the read socket notifier.
- if (readBufferMaxSize && buffer.size() == readBufferMaxSize) {
- socketEngine->setReadNotificationEnabled(false);
- }
}
emitReadyRead();
@@ -732,10 +743,6 @@ bool QAbstractSocketPrivate::canReadNotification()
return true;
}
- // turn the socket engine off if we've reached the buffer size limit
- if (socketEngine && isBuffered)
- socketEngine->setReadNotificationEnabled(readBufferMaxSize == 0 || readBufferMaxSize > q->bytesAvailable());
-
return true;
}
@@ -776,7 +783,8 @@ void QAbstractSocketPrivate::canCloseNotification()
QMetaObject::invokeMethod(socketEngine, "closeNotification", Qt::QueuedConnection);
}
- } else if (socketType == QAbstractSocket::TcpSocket && socketEngine) {
+ } else if ((socketType == QAbstractSocket::TcpSocket ||
+ socketType == QAbstractSocket::SctpSocket) && socketEngine) {
emitReadyRead();
}
}
@@ -792,12 +800,8 @@ bool QAbstractSocketPrivate::canWriteNotification()
#if defined (QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocketPrivate::canWriteNotification() flushing");
#endif
- bool dataWasWritten = writeToSocket();
- if (socketEngine && writeBuffer.isEmpty() && socketEngine->bytesToWrite() == 0)
- socketEngine->setWriteNotificationEnabled(false);
-
- return dataWasWritten;
+ return writeToSocket();
}
/*! \internal
@@ -837,8 +841,12 @@ bool QAbstractSocketPrivate::writeToSocket()
#endif
// this covers the case when the buffer was empty, but we had to wait for the socket engine to finish
- if (state == QAbstractSocket::ClosingState)
+ if (state == QAbstractSocket::ClosingState) {
q->disconnectFromHost();
+ } else {
+ if (socketEngine)
+ socketEngine->setWriteNotificationEnabled(false);
+ }
return false;
}
@@ -867,17 +875,12 @@ bool QAbstractSocketPrivate::writeToSocket()
if (written > 0) {
// Remove what we wrote so far.
writeBuffer.free(written);
- // Don't emit bytesWritten() recursively.
- if (!emittedBytesWritten) {
- QScopedValueRollback<bool> r(emittedBytesWritten);
- emittedBytesWritten = true;
- emit q->bytesWritten(written);
- }
- emit q->channelBytesWritten(0, written);
+
+ // Emit notifications.
+ emitBytesWritten(written);
}
- if (writeBuffer.isEmpty() && socketEngine && socketEngine->isWriteNotificationEnabled()
- && !socketEngine->bytesToWrite())
+ if (writeBuffer.isEmpty() && socketEngine && !socketEngine->bytesToWrite())
socketEngine->setWriteNotificationEnabled(false);
if (state == QAbstractSocket::ClosingState)
q->disconnectFromHost();
@@ -895,7 +898,7 @@ bool QAbstractSocketPrivate::flush()
{
bool dataWasWritten = false;
- while (!writeBuffer.isEmpty() && writeToSocket())
+ while (!allWriteBuffersEmpty() && writeToSocket())
dataWasWritten = true;
return dataWasWritten;
@@ -918,6 +921,8 @@ void QAbstractSocketPrivate::resolveProxy(const QString &hostname, quint16 port)
QNetworkProxyQuery query(hostname, port, QString(),
socketType == QAbstractSocket::TcpSocket ?
QNetworkProxyQuery::TcpSocket :
+ socketType == QAbstractSocket::SctpSocket ?
+ QNetworkProxyQuery::SctpSocket :
QNetworkProxyQuery::UdpSocket);
proxies = QNetworkProxyFactory::proxyForQuery(query);
}
@@ -932,6 +937,10 @@ void QAbstractSocketPrivate::resolveProxy(const QString &hostname, quint16 port)
(p.capabilities() & QNetworkProxy::TunnelingCapability) == 0)
continue;
+ if (socketType == QAbstractSocket::SctpSocket &&
+ (p.capabilities() & QNetworkProxy::SctpTunnelingCapability) == 0)
+ continue;
+
proxyInUse = p;
return;
}
@@ -1150,12 +1159,10 @@ void QAbstractSocketPrivate::_q_connectToNextAddress()
*/
void QAbstractSocketPrivate::_q_testConnection()
{
- if (socketEngine) {
- if (threadData->hasEventDispatcher()) {
- if (connectTimer)
- connectTimer->stop();
- }
+ if (connectTimer)
+ connectTimer->stop();
+ if (socketEngine) {
if (socketEngine->state() == QAbstractSocket::ConnectedState) {
// Fetch the parameters if our connection is completed;
// otherwise, fall out and try the next address.
@@ -1172,11 +1179,6 @@ void QAbstractSocketPrivate::_q_testConnection()
addresses.clear();
}
- if (threadData->hasEventDispatcher()) {
- if (connectTimer)
- connectTimer->stop();
- }
-
#if defined(QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocketPrivate::_q_testConnection() connection failed,"
" checking for alternative addresses");
@@ -1291,18 +1293,36 @@ bool QAbstractSocketPrivate::readFromSocket()
/*! \internal
- Prevents from the recursive readyRead() emission.
+ Emits readyRead(), protecting against recursion.
*/
-void QAbstractSocketPrivate::emitReadyRead()
+void QAbstractSocketPrivate::emitReadyRead(int channel)
{
Q_Q(QAbstractSocket);
// Only emit readyRead() when not recursing.
- if (!emittedReadyRead) {
+ if (!emittedReadyRead && channel == currentReadChannel) {
QScopedValueRollback<bool> r(emittedReadyRead);
emittedReadyRead = true;
emit q->readyRead();
}
- emit q->channelReadyRead(0);
+ // channelReadyRead() can be emitted recursively - even for the same channel.
+ emit q->channelReadyRead(channel);
+}
+
+/*! \internal
+
+ Emits bytesWritten(), protecting against recursion.
+*/
+void QAbstractSocketPrivate::emitBytesWritten(qint64 bytes, int channel)
+{
+ Q_Q(QAbstractSocket);
+ // Only emit bytesWritten() when not recursing.
+ if (!emittedBytesWritten && channel == currentWriteChannel) {
+ QScopedValueRollback<bool> r(emittedBytesWritten);
+ emittedBytesWritten = true;
+ emit q->bytesWritten(bytes);
+ }
+ // channelBytesWritten() can be emitted recursively - even for the same channel.
+ emit q->channelBytesWritten(channel, bytes);
}
/*! \internal
@@ -1413,8 +1433,8 @@ QAbstractSocket::QAbstractSocket(SocketType socketType,
Q_D(QAbstractSocket);
#if defined(QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocket::QAbstractSocket(%sSocket, QAbstractSocketPrivate == %p, parent == %p)",
- socketType == TcpSocket ? "Tcp" : socketType == UdpSocket
- ? "Udp" : "Unknown", &dd, parent);
+ socketType == TcpSocket ? "Tcp" : socketType == UdpSocket ? "Udp"
+ : socketType == SctpSocket ? "Sctp" : "Unknown", &dd, parent);
#endif
d->socketType = socketType;
}
@@ -1678,9 +1698,9 @@ void QAbstractSocket::connectToHost(const QString &hostName, quint16 port,
#endif
if (openMode & QIODevice::Unbuffered)
- d->isBuffered = false; // Unbuffered QTcpSocket
+ d->isBuffered = false;
else if (!d_func()->isBuffered)
- openMode |= QAbstractSocket::Unbuffered; // QUdpSocket
+ openMode |= QAbstractSocket::Unbuffered;
QIODevice::open(openMode);
d->readChannelCount = d->writeChannelCount = 0;
@@ -2385,11 +2405,6 @@ void QAbstractSocket::abort()
return;
}
#endif
- if (d->connectTimer) {
- d->connectTimer->stop();
- delete d->connectTimer;
- d->connectTimer = 0;
- }
d->abortCalled = true;
close();
@@ -2436,15 +2451,7 @@ bool QAbstractSocket::atEnd() const
// Note! docs copied to QSslSocket::flush()
bool QAbstractSocket::flush()
{
- Q_D(QAbstractSocket);
-#ifndef QT_NO_SSL
- // Manual polymorphism; flush() isn't virtual, but QSslSocket overloads
- // it.
- if (QSslSocket *socket = qobject_cast<QSslSocket *>(this))
- return socket->flush();
-#endif
- Q_CHECK_SOCKETENGINE(false);
- return d->flush();
+ return d_func()->flush();
}
/*! \reimp
@@ -2467,8 +2474,9 @@ qint64 QAbstractSocket::readData(char *data, qint64 maxSize)
d->setError(d->socketEngine->error(), d->socketEngine->errorString());
d->resetSocketLayer();
d->state = QAbstractSocket::UnconnectedState;
- } else if (!d->socketEngine->isReadNotificationEnabled()) {
+ } else {
// Only do this when there was no error
+ d->hasPendingData = false;
d->socketEngine->setReadNotificationEnabled(true);
}
@@ -2528,10 +2536,8 @@ qint64 QAbstractSocket::writeData(const char *data, qint64 size)
qt_prettyDebug(data, qMin((int)size, 32), size).data(),
size, written);
#endif
- if (written >= 0) {
- emit bytesWritten(written);
- emit channelBytesWritten(0, written);
- }
+ if (written >= 0)
+ d->emitBytesWritten(written);
return written;
}
@@ -2731,14 +2737,14 @@ void QAbstractSocket::disconnectFromHost()
}
// Wait for pending data to be written.
- if (d->socketEngine && d->socketEngine->isValid() && (d->writeBuffer.size() > 0
+ if (d->socketEngine && d->socketEngine->isValid() && (!d->allWriteBuffersEmpty()
|| d->socketEngine->bytesToWrite() > 0)) {
// hack: when we are waiting for the socket engine to write bytes (only
// possible when using Socks5 or HTTP socket engine), then close
// anyway after 2 seconds. This is to prevent a timeout on Mac, where we
// sometimes just did not get the write notifier from the underlying
// CFSocket and no progress was made.
- if (d->writeBuffer.size() == 0 && d->socketEngine->bytesToWrite() > 0) {
+ if (d->allWriteBuffersEmpty() && d->socketEngine->bytesToWrite() > 0) {
if (!d->disconnectTimer) {
d->disconnectTimer = new QTimer(this);
connect(d->disconnectTimer, SIGNAL(timeout()), this,
@@ -2827,12 +2833,12 @@ void QAbstractSocket::setReadBufferSize(qint64 size)
if (d->readBufferMaxSize == size)
return;
d->readBufferMaxSize = size;
- if (!d->emittedReadyRead && d->socketEngine) {
- // ensure that the read notification is enabled if we've now got
- // room in the read buffer
- // but only if we're not inside canReadNotification -- that will take care on its own
- if ((size == 0 || d->buffer.size() < size) && d->state == QAbstractSocket::ConnectedState) // Do not change the notifier unless we are connected.
- d->socketEngine->setReadNotificationEnabled(true);
+
+ // Do not change the notifier unless we are connected.
+ if (d->socketEngine && d->state == QAbstractSocket::ConnectedState) {
+ // Ensure that the read notification is enabled if we've now got
+ // room in the read buffer.
+ d->socketEngine->setReadNotificationEnabled(size == 0 || d->buffer.size() < size);
}
}
diff --git a/src/network/socket/qabstractsocket.h b/src/network/socket/qabstractsocket.h
index aabdcd4776..73a8f11537 100644
--- a/src/network/socket/qabstractsocket.h
+++ b/src/network/socket/qabstractsocket.h
@@ -40,6 +40,7 @@
#ifndef QABSTRACTSOCKET_H
#define QABSTRACTSOCKET_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qiodevice.h>
#include <QtCore/qobject.h>
#ifndef QT_NO_DEBUG_STREAM
@@ -63,6 +64,7 @@ public:
enum SocketType {
TcpSocket,
UdpSocket,
+ SctpSocket,
UnknownSocketType = -1
};
Q_ENUM(SocketType)
diff --git a/src/network/socket/qabstractsocket_p.h b/src/network/socket/qabstractsocket_p.h
index b718c21ff5..1578d7bb35 100644
--- a/src/network/socket/qabstractsocket_p.h
+++ b/src/network/socket/qabstractsocket_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "QtNetwork/qabstractsocket.h"
#include "QtCore/qbytearray.h"
#include "QtCore/qlist.h"
@@ -85,7 +86,7 @@ public:
virtual bool bind(const QHostAddress &address, quint16 port, QAbstractSocket::BindMode mode);
- bool canReadNotification();
+ virtual bool canReadNotification();
bool canWriteNotification();
void canCloseNotification();
@@ -128,22 +129,23 @@ public:
inline void resolveProxy(quint16 port) { resolveProxy(QString(), port); }
void resetSocketLayer();
- bool flush();
+ virtual bool flush();
bool initSocketLayer(QAbstractSocket::NetworkLayerProtocol protocol);
virtual void configureCreatedSocket();
void startConnectingByName(const QString &host);
void fetchConnectionParameters();
- void setupSocketNotifiers();
bool readFromSocket();
- bool writeToSocket();
- void emitReadyRead();
+ virtual bool writeToSocket();
+ void emitReadyRead(int channel = 0);
+ void emitBytesWritten(qint64 bytes, int channel = 0);
void setError(QAbstractSocket::SocketError errorCode, const QString &errorString);
void setErrorAndEmit(QAbstractSocket::SocketError errorCode, const QString &errorString);
qint64 readBufferMaxSize;
bool isBuffered;
+ bool hasPendingData;
QTimer *connectTimer;
QTimer *disconnectTimer;
diff --git a/src/network/socket/qabstractsocketengine_p.h b/src/network/socket/qabstractsocketengine_p.h
index 0073a8b1f2..0cb519ce90 100644
--- a/src/network/socket/qabstractsocketengine_p.h
+++ b/src/network/socket/qabstractsocketengine_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "QtNetwork/qhostaddress.h"
#include "QtNetwork/qabstractsocket.h"
#include "private/qobject_p.h"
@@ -103,7 +104,8 @@ public:
MulticastLoopbackOption,
TypeOfServiceOption,
ReceivePacketInformation,
- ReceiveHopLimit
+ ReceiveHopLimit,
+ MaxStreamsSocketOption
};
enum PacketHeaderOption {
@@ -111,6 +113,8 @@ public:
WantDatagramSender = 0x01,
WantDatagramDestination = 0x02,
WantDatagramHopLimit = 0x04,
+ WantStreamNumber = 0x08,
+ WantEndOfRecord = 0x10,
WantAll = 0xff
};
@@ -146,13 +150,13 @@ public:
virtual bool setMulticastInterface(const QNetworkInterface &iface) = 0;
#endif // QT_NO_NETWORKINTERFACE
- virtual qint64 readDatagram(char *data, qint64 maxlen, QIpPacketHeader *header = 0,
- PacketHeaderOptions = WantNone) = 0;
- virtual qint64 writeDatagram(const char *data, qint64 len, const QIpPacketHeader &header) = 0;
virtual bool hasPendingDatagrams() const = 0;
virtual qint64 pendingDatagramSize() const = 0;
#endif // QT_NO_UDPSOCKET
+ virtual qint64 readDatagram(char *data, qint64 maxlen, QIpPacketHeader *header = 0,
+ PacketHeaderOptions = WantNone) = 0;
+ virtual qint64 writeDatagram(const char *data, qint64 len, const QIpPacketHeader &header) = 0;
virtual qint64 bytesToWrite() const = 0;
virtual int option(SocketOption option) const = 0;
diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp
index f9ff958525..899c02fba6 100644
--- a/src/network/socket/qhttpsocketengine.cpp
+++ b/src/network/socket/qhttpsocketengine.cpp
@@ -289,34 +289,34 @@ bool QHttpSocketEngine::setMulticastInterface(const QNetworkInterface &)
}
#endif // QT_NO_NETWORKINTERFACE
-qint64 QHttpSocketEngine::readDatagram(char *, qint64, QIpPacketHeader *, PacketHeaderOptions)
+bool QHttpSocketEngine::hasPendingDatagrams() const
{
qWarning("Operation is not supported");
- setError(QAbstractSocket::UnsupportedSocketOperationError,
- QLatin1String("Unsupported socket operation"));
- return -1;
+ return false;
}
-qint64 QHttpSocketEngine::writeDatagram(const char *, qint64, const QIpPacketHeader &)
+qint64 QHttpSocketEngine::pendingDatagramSize() const
{
qWarning("Operation is not supported");
- setError(QAbstractSocket::UnsupportedSocketOperationError,
- QLatin1String("Unsupported socket operation"));
return -1;
}
+#endif // QT_NO_UDPSOCKET
-bool QHttpSocketEngine::hasPendingDatagrams() const
+qint64 QHttpSocketEngine::readDatagram(char *, qint64, QIpPacketHeader *, PacketHeaderOptions)
{
qWarning("Operation is not supported");
- return false;
+ setError(QAbstractSocket::UnsupportedSocketOperationError,
+ QLatin1String("Unsupported socket operation"));
+ return -1;
}
-qint64 QHttpSocketEngine::pendingDatagramSize() const
+qint64 QHttpSocketEngine::writeDatagram(const char *, qint64, const QIpPacketHeader &)
{
qWarning("Operation is not supported");
+ setError(QAbstractSocket::UnsupportedSocketOperationError,
+ QLatin1String("Unsupported socket operation"));
return -1;
}
-#endif // QT_NO_UDPSOCKET
qint64 QHttpSocketEngine::bytesToWrite() const
{
diff --git a/src/network/socket/qhttpsocketengine_p.h b/src/network/socket/qhttpsocketengine_p.h
index 1cc168afec..07815a7e51 100644
--- a/src/network/socket/qhttpsocketengine_p.h
+++ b/src/network/socket/qhttpsocketengine_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "private/qabstractsocketengine_p.h"
#include "qabstractsocket.h"
#include "qnetworkproxy.h"
@@ -111,13 +112,13 @@ public:
bool setMulticastInterface(const QNetworkInterface &iface) Q_DECL_OVERRIDE;
#endif // QT_NO_NETWORKINTERFACE
- qint64 readDatagram(char *data, qint64 maxlen, QIpPacketHeader *,
- PacketHeaderOptions) Q_DECL_OVERRIDE;
- qint64 writeDatagram(const char *data, qint64 len, const QIpPacketHeader &) Q_DECL_OVERRIDE;
bool hasPendingDatagrams() const Q_DECL_OVERRIDE;
qint64 pendingDatagramSize() const Q_DECL_OVERRIDE;
#endif // QT_NO_UDPSOCKET
+ qint64 readDatagram(char *data, qint64 maxlen, QIpPacketHeader *,
+ PacketHeaderOptions) Q_DECL_OVERRIDE;
+ qint64 writeDatagram(const char *data, qint64 len, const QIpPacketHeader &) Q_DECL_OVERRIDE;
qint64 bytesToWrite() const Q_DECL_OVERRIDE;
int option(SocketOption option) const Q_DECL_OVERRIDE;
diff --git a/src/network/socket/qlocalserver.h b/src/network/socket/qlocalserver.h
index 52f0813746..786885b6cd 100644
--- a/src/network/socket/qlocalserver.h
+++ b/src/network/socket/qlocalserver.h
@@ -40,6 +40,7 @@
#ifndef QLOCALSERVER_H
#define QLOCALSERVER_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtNetwork/qabstractsocket.h>
QT_BEGIN_NAMESPACE
diff --git a/src/network/socket/qlocalserver_p.h b/src/network/socket/qlocalserver_p.h
index 28d2b08902..988140c1a4 100644
--- a/src/network/socket/qlocalserver_p.h
+++ b/src/network/socket/qlocalserver_p.h
@@ -51,6 +51,8 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
+
#ifndef QT_NO_LOCALSERVER
#include "qlocalserver.h"
diff --git a/src/network/socket/qlocalsocket.h b/src/network/socket/qlocalsocket.h
index 0eecab206b..ea074db90e 100644
--- a/src/network/socket/qlocalsocket.h
+++ b/src/network/socket/qlocalsocket.h
@@ -40,6 +40,7 @@
#ifndef QLOCALSOCKET_H
#define QLOCALSOCKET_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qiodevice.h>
#include <QtNetwork/qabstractsocket.h>
diff --git a/src/network/socket/qlocalsocket_p.h b/src/network/socket/qlocalsocket_p.h
index 56f8b590f1..560d74328e 100644
--- a/src/network/socket/qlocalsocket_p.h
+++ b/src/network/socket/qlocalsocket_p.h
@@ -51,6 +51,8 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
+
#ifndef QT_NO_LOCALSOCKET
#include "qlocalsocket.h"
diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp
index 9ba9d5317e..f2bc3cec94 100644
--- a/src/network/socket/qnativesocketengine.cpp
+++ b/src/network/socket/qnativesocketengine.cpp
@@ -111,7 +111,7 @@
\value WantAll this is a catch-all value to indicate the caller is
interested in all the available information
- \sa readDatagram()
+ \sa readDatagram(), QNetworkDatagram
*/
#include "qnativesocketengine_p.h"
@@ -174,6 +174,12 @@ QT_BEGIN_NAMESPACE
" socket other than "#type""); \
return (returnValue); \
} } while (0)
+#define Q_CHECK_TYPES(function, type1, type2, returnValue) do { \
+ if (d->socketType != (type1) && d->socketType != (type2)) { \
+ qWarning(#function" was called by a" \
+ " socket other than "#type1" or "#type2); \
+ return (returnValue); \
+ } } while (0)
#define Q_TR(a) QT_TRANSLATE_NOOP(QNativeSocketEngine, a)
/*! \internal
@@ -417,6 +423,7 @@ bool QNativeSocketEngine::initialize(QAbstractSocket::SocketType socketType, QAb
QString typeStr = QLatin1String("UnknownSocketType");
if (socketType == QAbstractSocket::TcpSocket) typeStr = QLatin1String("TcpSocket");
else if (socketType == QAbstractSocket::UdpSocket) typeStr = QLatin1String("UdpSocket");
+ else if (socketType == QAbstractSocket::SctpSocket) typeStr = QLatin1String("SctpSocket");
QString protocolStr = QLatin1String("UnknownProtocol");
if (protocol == QAbstractSocket::IPv4Protocol) protocolStr = QLatin1String("IPv4Protocol");
else if (protocol == QAbstractSocket::IPv6Protocol) protocolStr = QLatin1String("IPv6Protocol");
@@ -659,7 +666,12 @@ bool QNativeSocketEngine::listen()
Q_D(QNativeSocketEngine);
Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::listen(), false);
Q_CHECK_STATE(QNativeSocketEngine::listen(), QAbstractSocket::BoundState, false);
+#ifndef QT_NO_SCTP
+ Q_CHECK_TYPES(QNativeSocketEngine::listen(), QAbstractSocket::TcpSocket,
+ QAbstractSocket::SctpSocket, false);
+#else
Q_CHECK_TYPE(QNativeSocketEngine::listen(), QAbstractSocket::TcpSocket, false);
+#endif
// We're using a backlog of 50. Most modern kernels support TCP
// syncookies by default, and if they do, the backlog is ignored.
@@ -680,7 +692,12 @@ int QNativeSocketEngine::accept()
Q_D(QNativeSocketEngine);
Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::accept(), -1);
Q_CHECK_STATE(QNativeSocketEngine::accept(), QAbstractSocket::ListeningState, -1);
+#ifndef QT_NO_SCTP
+ Q_CHECK_TYPES(QNativeSocketEngine::accept(), QAbstractSocket::TcpSocket,
+ QAbstractSocket::SctpSocket, -1);
+#else
Q_CHECK_TYPE(QNativeSocketEngine::accept(), QAbstractSocket::TcpSocket, -1);
+#endif
return d->nativeAccept();
}
@@ -793,6 +810,7 @@ qint64 QNativeSocketEngine::pendingDatagramSize() const
return d->nativePendingDatagramSize();
}
+#endif // QT_NO_UDPSOCKET
/*!
Reads up to \a maxSize bytes of a datagram from the socket,
@@ -800,9 +818,10 @@ qint64 QNativeSocketEngine::pendingDatagramSize() const
address, port, and other IP header fields are stored in \a header
according to the request in \a options.
- To avoid unnecessarily loss of data, call pendingDatagramSize() to
- determine the size of the pending message before reading it. If \a
- maxSize is too small, the rest of the datagram will be lost.
+ For UDP sockets, to avoid unnecessarily loss of data, call
+ pendingDatagramSize() to determine the size of the pending message
+ before reading it. If \a maxSize is too small, the rest of the
+ datagram will be lost.
Returns -1 if an error occurred.
@@ -813,13 +832,14 @@ qint64 QNativeSocketEngine::readDatagram(char *data, qint64 maxSize, QIpPacketHe
{
Q_D(QNativeSocketEngine);
Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::readDatagram(), -1);
- Q_CHECK_TYPE(QNativeSocketEngine::readDatagram(), QAbstractSocket::UdpSocket, -1);
+ Q_CHECK_STATES(QNativeSocketEngine::readDatagram(), QAbstractSocket::BoundState,
+ QAbstractSocket::ConnectedState, -1);
return d->nativeReceiveDatagram(data, maxSize, header, options);
}
/*!
- Writes a UDP datagram of size \a size bytes to the socket from
+ Writes a datagram of size \a size bytes to the socket from
\a data to the destination contained in \a header, and returns the
number of bytes written, or -1 if an error occurred. If \a header
contains other settings like hop limit or source address, this function
@@ -844,11 +864,11 @@ qint64 QNativeSocketEngine::writeDatagram(const char *data, qint64 size, const Q
{
Q_D(QNativeSocketEngine);
Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::writeDatagram(), -1);
- Q_CHECK_TYPE(QNativeSocketEngine::writeDatagram(), QAbstractSocket::UdpSocket, -1);
+ Q_CHECK_STATES(QNativeSocketEngine::writeDatagram(), QAbstractSocket::BoundState,
+ QAbstractSocket::ConnectedState, -1);
return d->nativeSendDatagram(data, size, header);
}
-#endif // QT_NO_UDPSOCKET
/*!
Writes a block of \a size bytes from \a data to the socket.
@@ -881,7 +901,11 @@ qint64 QNativeSocketEngine::read(char *data, qint64 maxSize)
qint64 readBytes = d->nativeRead(data, maxSize);
// Handle remote close
- if (readBytes == 0 && d->socketType == QAbstractSocket::TcpSocket) {
+ if (readBytes == 0 && (d->socketType == QAbstractSocket::TcpSocket
+#ifndef QT_NO_SCTP
+ || d->socketType == QAbstractSocket::SctpSocket
+#endif
+ )) {
d->setError(QAbstractSocket::RemoteHostClosedError,
QNativeSocketEnginePrivate::RemoteHostClosedErrorString);
close();
@@ -1007,26 +1031,28 @@ bool QNativeSocketEngine::waitForWrite(int msecs, bool *timedOut)
// select(writable) is successful. In this case we should not
// issue a second call to WSAConnect()
#if defined (Q_OS_WIN)
- if (ret > 0) {
- setState(QAbstractSocket::ConnectedState);
- d_func()->fetchConnectionParameters();
- return true;
- } else {
- int value = 0;
- int valueSize = sizeof(value);
- if (::getsockopt(d->socketDescriptor, SOL_SOCKET, SO_ERROR, (char *) &value, &valueSize) == 0) {
- if (value == WSAECONNREFUSED) {
- d->setError(QAbstractSocket::ConnectionRefusedError, QNativeSocketEnginePrivate::ConnectionRefusedErrorString);
- d->socketState = QAbstractSocket::UnconnectedState;
- return false;
- } else if (value == WSAETIMEDOUT) {
- d->setError(QAbstractSocket::NetworkError, QNativeSocketEnginePrivate::ConnectionTimeOutErrorString);
- d->socketState = QAbstractSocket::UnconnectedState;
- return false;
- } else if (value == WSAEHOSTUNREACH) {
- d->setError(QAbstractSocket::NetworkError, QNativeSocketEnginePrivate::HostUnreachableErrorString);
- d->socketState = QAbstractSocket::UnconnectedState;
- return false;
+ if (state() == QAbstractSocket::ConnectingState) {
+ if (ret > 0) {
+ setState(QAbstractSocket::ConnectedState);
+ d_func()->fetchConnectionParameters();
+ return true;
+ } else {
+ int value = 0;
+ int valueSize = sizeof(value);
+ if (::getsockopt(d->socketDescriptor, SOL_SOCKET, SO_ERROR, (char *) &value, &valueSize) == 0) {
+ if (value == WSAECONNREFUSED) {
+ d->setError(QAbstractSocket::ConnectionRefusedError, QNativeSocketEnginePrivate::ConnectionRefusedErrorString);
+ d->socketState = QAbstractSocket::UnconnectedState;
+ return false;
+ } else if (value == WSAETIMEDOUT) {
+ d->setError(QAbstractSocket::NetworkError, QNativeSocketEnginePrivate::ConnectionTimeOutErrorString);
+ d->socketState = QAbstractSocket::UnconnectedState;
+ return false;
+ } else if (value == WSAEHOSTUNREACH) {
+ d->setError(QAbstractSocket::NetworkError, QNativeSocketEnginePrivate::HostUnreachableErrorString);
+ d->socketState = QAbstractSocket::UnconnectedState;
+ return false;
+ }
}
}
}
@@ -1060,26 +1086,28 @@ bool QNativeSocketEngine::waitForReadOrWrite(bool *readyToRead, bool *readyToWri
// select(writable) is successful. In this case we should not
// issue a second call to WSAConnect()
#if defined (Q_OS_WIN)
- if (checkWrite && ((readyToWrite && *readyToWrite) || !readyToWrite) && ret > 0) {
- setState(QAbstractSocket::ConnectedState);
- d_func()->fetchConnectionParameters();
- return true;
- } else {
- int value = 0;
- int valueSize = sizeof(value);
- if (::getsockopt(d->socketDescriptor, SOL_SOCKET, SO_ERROR, (char *) &value, &valueSize) == 0) {
- if (value == WSAECONNREFUSED) {
- d->setError(QAbstractSocket::ConnectionRefusedError, QNativeSocketEnginePrivate::ConnectionRefusedErrorString);
- d->socketState = QAbstractSocket::UnconnectedState;
- return false;
- } else if (value == WSAETIMEDOUT) {
- d->setError(QAbstractSocket::NetworkError, QNativeSocketEnginePrivate::ConnectionTimeOutErrorString);
- d->socketState = QAbstractSocket::UnconnectedState;
- return false;
- } else if (value == WSAEHOSTUNREACH) {
- d->setError(QAbstractSocket::NetworkError, QNativeSocketEnginePrivate::HostUnreachableErrorString);
- d->socketState = QAbstractSocket::UnconnectedState;
- return false;
+ if (state() == QAbstractSocket::ConnectingState) {
+ if (checkWrite && ((readyToWrite && *readyToWrite) || !readyToWrite) && ret > 0) {
+ setState(QAbstractSocket::ConnectedState);
+ d_func()->fetchConnectionParameters();
+ return true;
+ } else {
+ int value = 0;
+ int valueSize = sizeof(value);
+ if (::getsockopt(d->socketDescriptor, SOL_SOCKET, SO_ERROR, (char *) &value, &valueSize) == 0) {
+ if (value == WSAECONNREFUSED) {
+ d->setError(QAbstractSocket::ConnectionRefusedError, QNativeSocketEnginePrivate::ConnectionRefusedErrorString);
+ d->socketState = QAbstractSocket::UnconnectedState;
+ return false;
+ } else if (value == WSAETIMEDOUT) {
+ d->setError(QAbstractSocket::NetworkError, QNativeSocketEnginePrivate::ConnectionTimeOutErrorString);
+ d->socketState = QAbstractSocket::UnconnectedState;
+ return false;
+ } else if (value == WSAEHOSTUNREACH) {
+ d->setError(QAbstractSocket::NetworkError, QNativeSocketEnginePrivate::HostUnreachableErrorString);
+ d->socketState = QAbstractSocket::UnconnectedState;
+ return false;
+ }
}
}
}
diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h
index 19e9e1d9b7..1ca0fa0213 100644
--- a/src/network/socket/qnativesocketengine_p.h
+++ b/src/network/socket/qnativesocketengine_p.h
@@ -51,6 +51,8 @@
//
// We mean it.
//
+
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "QtNetwork/qhostaddress.h"
#include "QtNetwork/qnetworkinterface.h"
#include "private/qabstractsocketengine_p.h"
@@ -66,21 +68,20 @@
QT_BEGIN_NAMESPACE
#ifdef Q_OS_WIN
-#define QT_SOCKLEN_T int
-#define QT_SOCKOPTLEN_T int
+# define QT_SOCKLEN_T int
+# define QT_SOCKOPTLEN_T int
// The following definitions are copied from the MinGW header mswsock.h which
// was placed in the public domain. The WSASendMsg and WSARecvMsg functions
// were introduced with Windows Vista, so some Win32 headers are lacking them.
// There are no known versions of Windows CE or Embedded that contain them.
-#ifndef Q_OS_WINCE
# ifndef WSAID_WSARECVMSG
typedef INT (WINAPI *LPFN_WSARECVMSG)(SOCKET s, LPWSAMSG lpMsg,
LPDWORD lpdwNumberOfBytesRecvd,
LPWSAOVERLAPPED lpOverlapped,
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
# define WSAID_WSARECVMSG {0xf689d7c8,0x6f1f,0x436b,{0x8a,0x53,0xe5,0x4f,0xe3,0x51,0xc3,0x22}}
-# endif
+# endif // !WSAID_WSARECVMSG
# ifndef WSAID_WSASENDMSG
typedef struct {
LPWSAMSG lpMsg;
@@ -96,9 +97,8 @@ typedef INT (WSAAPI *LPFN_WSASENDMSG)(SOCKET s, LPWSAMSG lpMsg, DWORD dwFlags,
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
# define WSAID_WSASENDMSG {0xa441e712,0x754f,0x43ca,{0x84,0xa7,0x0d,0xee,0x44,0xcf,0x60,0x6d}}
-# endif
-#endif
-#endif
+# endif // !WSAID_WSASENDMSG
+#endif // Q_OS_WIN
union qt_sockaddr {
sockaddr a;
@@ -157,13 +157,13 @@ public:
bool setMulticastInterface(const QNetworkInterface &iface) Q_DECL_OVERRIDE;
#endif
- qint64 readDatagram(char *data, qint64 maxlen, QIpPacketHeader * = 0,
- PacketHeaderOptions = WantNone) Q_DECL_OVERRIDE;
- qint64 writeDatagram(const char *data, qint64 len, const QIpPacketHeader &) Q_DECL_OVERRIDE;
bool hasPendingDatagrams() const Q_DECL_OVERRIDE;
qint64 pendingDatagramSize() const Q_DECL_OVERRIDE;
#endif // QT_NO_UDPSOCKET
+ qint64 readDatagram(char *data, qint64 maxlen, QIpPacketHeader * = 0,
+ PacketHeaderOptions = WantNone) Q_DECL_OVERRIDE;
+ qint64 writeDatagram(const char *data, qint64 len, const QIpPacketHeader &) Q_DECL_OVERRIDE;
qint64 bytesToWrite() const Q_DECL_OVERRIDE;
qint64 receiveBufferSize() const;
@@ -210,7 +210,7 @@ public:
QSocketNotifier *readNotifier, *writeNotifier, *exceptNotifier;
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
LPFN_WSASENDMSG sendmsg;
LPFN_WSARECVMSG recvmsg;
# endif
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index 2d50cc1f8d..d1efc21e09 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -68,6 +68,11 @@
#endif
#include <netinet/tcp.h>
+#ifndef QT_NO_SCTP
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/sctp.h>
+#endif
QT_BEGIN_NAMESPACE
@@ -142,6 +147,7 @@ static void convertToLevelAndOption(QNativeSocketEngine::SocketOption opt,
switch (opt) {
case QNativeSocketEngine::NonBlockingSocketOption: // fcntl, not setsockopt
case QNativeSocketEngine::BindExclusively: // not handled on Unix
+ case QNativeSocketEngine::MaxStreamsSocketOption:
Q_UNREACHABLE();
case QNativeSocketEngine::BroadcastSocketOption:
@@ -229,13 +235,28 @@ static void convertToLevelAndOption(QNativeSocketEngine::SocketOption opt,
bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType socketType,
QAbstractSocket::NetworkLayerProtocol &socketProtocol)
{
- int protocol = (socketProtocol == QAbstractSocket::IPv6Protocol || socketProtocol == QAbstractSocket::AnyIPProtocol) ? AF_INET6 : AF_INET;
+#ifndef QT_NO_SCTP
+ int protocol = (socketType == QAbstractSocket::SctpSocket) ? IPPROTO_SCTP : 0;
+#else
+ if (socketType == QAbstractSocket::SctpSocket) {
+ setError(QAbstractSocket::UnsupportedSocketOperationError,
+ ProtocolUnsupportedErrorString);
+#if defined (QNATIVESOCKETENGINE_DEBUG)
+ qDebug("QNativeSocketEnginePrivate::createNewSocket(%d, %d): unsupported protocol",
+ socketType, socketProtocol);
+#endif
+ return false;
+ }
+ int protocol = 0;
+#endif // QT_NO_SCTP
+ int domain = (socketProtocol == QAbstractSocket::IPv6Protocol
+ || socketProtocol == QAbstractSocket::AnyIPProtocol) ? AF_INET6 : AF_INET;
int type = (socketType == QAbstractSocket::UdpSocket) ? SOCK_DGRAM : SOCK_STREAM;
- int socket = qt_safe_socket(protocol, type, 0, O_NONBLOCK);
+ int socket = qt_safe_socket(domain, type, protocol, O_NONBLOCK);
if (socket < 0 && socketProtocol == QAbstractSocket::AnyIPProtocol && errno == EAFNOSUPPORT) {
- protocol = AF_INET;
- socket = qt_safe_socket(protocol, type, 0, O_NONBLOCK);
+ domain = AF_INET;
+ socket = qt_safe_socket(domain, type, protocol, O_NONBLOCK);
socketProtocol = QAbstractSocket::IPv4Protocol;
}
@@ -291,10 +312,26 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co
if (!q->isValid())
return -1;
- // handle non-getsockopt cases first
- if (opt == QNativeSocketEngine::BindExclusively || opt == QNativeSocketEngine::NonBlockingSocketOption
- || opt == QNativeSocketEngine::BroadcastSocketOption)
+ // handle non-getsockopt and specific cases first
+ switch (opt) {
+ case QNativeSocketEngine::BindExclusively:
+ case QNativeSocketEngine::NonBlockingSocketOption:
+ case QNativeSocketEngine::BroadcastSocketOption:
+ return -1;
+ case QNativeSocketEngine::MaxStreamsSocketOption: {
+#ifndef QT_NO_SCTP
+ sctp_initmsg sctpInitMsg;
+ QT_SOCKOPTLEN_T sctpInitMsgSize = sizeof(sctpInitMsg);
+ if (::getsockopt(socketDescriptor, SOL_SCTP, SCTP_INITMSG, &sctpInitMsg,
+ &sctpInitMsgSize) == 0)
+ return int(qMin(sctpInitMsg.sinit_num_ostreams, sctpInitMsg.sinit_max_instreams));
+#endif
return -1;
+ }
+
+ default:
+ break;
+ }
int n, level;
int v = -1;
@@ -317,7 +354,7 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt
if (!q->isValid())
return false;
- // handle non-setsockopt cases first
+ // handle non-setsockopt and specific cases first
switch (opt) {
case QNativeSocketEngine::NonBlockingSocketOption: {
// Make the socket nonblocking.
@@ -351,6 +388,20 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt
case QNativeSocketEngine::BindExclusively:
return true;
+ case QNativeSocketEngine::MaxStreamsSocketOption: {
+#ifndef QT_NO_SCTP
+ sctp_initmsg sctpInitMsg;
+ QT_SOCKOPTLEN_T sctpInitMsgSize = sizeof(sctpInitMsg);
+ if (::getsockopt(socketDescriptor, SOL_SCTP, SCTP_INITMSG, &sctpInitMsg,
+ &sctpInitMsgSize) == 0) {
+ sctpInitMsg.sinit_num_ostreams = sctpInitMsg.sinit_max_instreams = uint16_t(v);
+ return ::setsockopt(socketDescriptor, SOL_SCTP, SCTP_INITMSG, &sctpInitMsg,
+ sctpInitMsgSize) == 0;
+ }
+#endif
+ return false;
+ }
+
default:
break;
}
@@ -830,6 +881,9 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxS
#if !defined(IP_PKTINFO) && defined(IP_RECVIF) && defined(Q_OS_BSD4)
+ CMSG_SPACE(sizeof(sockaddr_dl))
#endif
+#ifndef QT_NO_SCTP
+ + CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))
+#endif
+ sizeof(quintptr) - 1) / sizeof(quintptr)];
struct msghdr msg;
@@ -848,7 +902,8 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxS
msg.msg_name = &aa;
msg.msg_namelen = sizeof(aa);
}
- if (options & (QAbstractSocketEngine::WantDatagramHopLimit | QAbstractSocketEngine::WantDatagramDestination)) {
+ if (options & (QAbstractSocketEngine::WantDatagramHopLimit | QAbstractSocketEngine::WantDatagramDestination
+ | QAbstractSocketEngine::WantStreamNumber)) {
msg.msg_control = cbuf;
msg.msg_controllen = sizeof(cbuf);
}
@@ -859,13 +914,27 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxS
} while (recvResult == -1 && errno == EINTR);
if (recvResult == -1) {
- setError(QAbstractSocket::NetworkError, ReceiveDatagramErrorString);
+ switch (errno) {
+#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
+ case EWOULDBLOCK:
+#endif
+ case EAGAIN:
+ // No datagram was available for reading
+ recvResult = -2;
+ break;
+ case ECONNREFUSED:
+ setError(QAbstractSocket::ConnectionRefusedError, ConnectionRefusedErrorString);
+ break;
+ default:
+ setError(QAbstractSocket::NetworkError, ReceiveDatagramErrorString);
+ }
if (header)
header->clear();
} else if (options != QAbstractSocketEngine::WantNone) {
Q_ASSERT(header);
qt_socket_getPortAndAddress(&aa, &header->senderPort, &header->senderAddress);
header->destinationPort = localPort;
+ header->endOfRecord = (msg.msg_flags & MSG_EOR) != 0;
// parse the ancillary data
struct cmsghdr *cmsgptr;
@@ -912,6 +981,15 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxS
|| (cmsgptr->cmsg_level == IPPROTO_IP && cmsgptr->cmsg_type == IP_TTL))) {
header->hopLimit = *reinterpret_cast<int *>(CMSG_DATA(cmsgptr));
}
+
+#ifndef QT_NO_SCTP
+ if (cmsgptr->cmsg_level == IPPROTO_SCTP && cmsgptr->cmsg_type == SCTP_SNDRCV
+ && cmsgptr->cmsg_len >= CMSG_LEN(sizeof(sctp_sndrcvinfo))) {
+ sctp_sndrcvinfo *rcvInfo = reinterpret_cast<sctp_sndrcvinfo *>(CMSG_DATA(cmsgptr));
+
+ header->streamNumber = int(rcvInfo->sinfo_stream);
+ }
+#endif
}
}
@@ -924,13 +1002,17 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxS
? header->senderPort : 0, (qint64) recvResult);
#endif
- return qint64(maxSize ? recvResult : recvResult == -1 ? -1 : 0);
+ return qint64((maxSize || recvResult < 0) ? recvResult : Q_INT64_C(0));
}
qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 len, const QIpPacketHeader &header)
{
// we use quintptr to force the alignment
- quintptr cbuf[(CMSG_SPACE(sizeof(struct in6_pktinfo)) + CMSG_SPACE(sizeof(int)) + sizeof(quintptr) - 1) / sizeof(quintptr)];
+ quintptr cbuf[(CMSG_SPACE(sizeof(struct in6_pktinfo)) + CMSG_SPACE(sizeof(int))
+#ifndef QT_NO_SCTP
+ + CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))
+#endif
+ + sizeof(quintptr) - 1) / sizeof(quintptr)];
struct cmsghdr *cmsgptr = reinterpret_cast<struct cmsghdr *>(cbuf);
struct msghdr msg;
@@ -943,10 +1025,13 @@ qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 l
vec.iov_len = len;
msg.msg_iov = &vec;
msg.msg_iovlen = 1;
- msg.msg_name = &aa.a;
msg.msg_control = &cbuf;
- setPortAndAddress(header.destinationPort, header.destinationAddress, &aa, &msg.msg_namelen);
+ if (header.destinationPort != 0) {
+ msg.msg_name = &aa.a;
+ setPortAndAddress(header.destinationPort, header.destinationAddress,
+ &aa, &msg.msg_namelen);
+ }
if (msg.msg_namelen == sizeof(aa.a6)) {
if (header.hopLimit != -1) {
@@ -1001,15 +1086,37 @@ qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 l
#endif
}
+#ifndef QT_NO_SCTP
+ if (header.streamNumber != -1) {
+ struct sctp_sndrcvinfo *data = reinterpret_cast<sctp_sndrcvinfo *>(CMSG_DATA(cmsgptr));
+ memset(data, 0, sizeof(*data));
+ msg.msg_controllen += CMSG_SPACE(sizeof(sctp_sndrcvinfo));
+ cmsgptr->cmsg_len = CMSG_LEN(sizeof(sctp_sndrcvinfo));
+ cmsgptr->cmsg_level = IPPROTO_SCTP;
+ cmsgptr->cmsg_type = SCTP_SNDRCV;
+ data->sinfo_stream = uint16_t(header.streamNumber);
+ cmsgptr = reinterpret_cast<cmsghdr *>(reinterpret_cast<char *>(cmsgptr) + CMSG_SPACE(sizeof(*data)));
+ }
+#endif
+
if (msg.msg_controllen == 0)
msg.msg_control = 0;
ssize_t sentBytes = qt_safe_sendmsg(socketDescriptor, &msg, 0);
if (sentBytes < 0) {
switch (errno) {
+#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
+ case EWOULDBLOCK:
+#endif
+ case EAGAIN:
+ sentBytes = -2;
+ break;
case EMSGSIZE:
setError(QAbstractSocket::DatagramTooLargeError, DatagramTooLargeErrorString);
break;
+ case ECONNRESET:
+ setError(QAbstractSocket::RemoteHostClosedError, RemoteHostClosedErrorString);
+ break;
default:
setError(QAbstractSocket::NetworkError, SendDatagramErrorString);
}
@@ -1082,21 +1189,51 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters()
#endif
// Determine the remote address
- if (!::getpeername(socketDescriptor, &sa.a, &sockAddrSize)) {
+ bool connected = ::getpeername(socketDescriptor, &sa.a, &sockAddrSize) == 0;
+ if (connected) {
qt_socket_getPortAndAddress(&sa, &peerPort, &peerAddress);
inboundStreamCount = outboundStreamCount = 1;
}
- // Determine the socket type (UDP/TCP)
+ // Determine the socket type (UDP/TCP/SCTP)
int value = 0;
QT_SOCKOPTLEN_T valueSize = sizeof(int);
if (::getsockopt(socketDescriptor, SOL_SOCKET, SO_TYPE, &value, &valueSize) == 0) {
- if (value == SOCK_STREAM)
- socketType = QAbstractSocket::TcpSocket;
- else if (value == SOCK_DGRAM)
- socketType = QAbstractSocket::UdpSocket;
- else
- socketType = QAbstractSocket::UnknownSocketType;
+ if (value == SOCK_STREAM) {
+#ifndef QT_NO_SCTP
+ if (option(QNativeSocketEngine::MaxStreamsSocketOption) != -1) {
+ socketType = QAbstractSocket::SctpSocket;
+ if (connected) {
+ sctp_status sctpStatus;
+ QT_SOCKOPTLEN_T sctpStatusSize = sizeof(sctpStatus);
+ sctp_event_subscribe sctpEvents;
+
+ memset(&sctpEvents, 0, sizeof(sctpEvents));
+ sctpEvents.sctp_data_io_event = 1;
+ if (::getsockopt(socketDescriptor, SOL_SCTP, SCTP_STATUS, &sctpStatus,
+ &sctpStatusSize) == 0 &&
+ ::setsockopt(socketDescriptor, SOL_SCTP, SCTP_EVENTS, &sctpEvents,
+ sizeof(sctpEvents)) == 0) {
+ inboundStreamCount = int(sctpStatus.sstat_instrms);
+ outboundStreamCount = int(sctpStatus.sstat_outstrms);
+ } else {
+ setError(QAbstractSocket::UnsupportedSocketOperationError,
+ InvalidSocketErrorString);
+ return false;
+ }
+ }
+ } else {
+ socketType = QAbstractSocket::TcpSocket;
+ }
+#else
+ socketType = QAbstractSocket::TcpSocket;
+#endif
+ } else {
+ if (value == SOCK_DGRAM)
+ socketType = QAbstractSocket::UdpSocket;
+ else
+ socketType = QAbstractSocket::UnknownSocketType;
+ }
}
#if defined (QNATIVESOCKETENGINE_DEBUG)
QString socketProtocolStr = QStringLiteral("UnknownProtocol");
@@ -1106,6 +1243,7 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters()
QString socketTypeStr = QStringLiteral("UnknownSocketType");
if (socketType == QAbstractSocket::TcpSocket) socketTypeStr = QStringLiteral("TcpSocket");
else if (socketType == QAbstractSocket::UdpSocket) socketTypeStr = QStringLiteral("UdpSocket");
+ else if (socketType == QAbstractSocket::SctpSocket) socketTypeStr = QStringLiteral("SctpSocket");
qDebug("QNativeSocketEnginePrivate::fetchConnectionParameters() local == %s:%i,"
" peer == %s:%i, socket == %s - %s, inboundStreamCount == %i, outboundStreamCount == %i",
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp
index 5ffe7b11b8..9ae2d8ba8f 100644
--- a/src/network/socket/qnativesocketengine_win.cpp
+++ b/src/network/socket/qnativesocketengine_win.cpp
@@ -214,6 +214,7 @@ static void convertToLevelAndOption(QNativeSocketEngine::SocketOption opt,
switch (opt) {
case QNativeSocketEngine::NonBlockingSocketOption: // WSAIoctl
case QNativeSocketEngine::TypeOfServiceOption: // not supported
+ case QNativeSocketEngine::MaxStreamsSocketOption:
Q_UNREACHABLE();
case QNativeSocketEngine::ReceiveBufferSocketOption:
@@ -325,6 +326,14 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc
return -1;
}
*/
+
+ //### SCTP not implemented
+ if (socketType == QAbstractSocket::SctpSocket) {
+ setError(QAbstractSocket::UnsupportedSocketOperationError,
+ ProtocolUnsupportedErrorString);
+ return false;
+ }
+
QSysInfo::WinVersion osver = QSysInfo::windowsVersion();
//Windows XP and 2003 support IPv6 but not dual stack sockets
@@ -387,7 +396,6 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc
return false;
}
-#if !defined(Q_OS_WINCE)
if (socketType == QAbstractSocket::UdpSocket) {
// enable new behavior using
// SIO_UDP_CONNRESET
@@ -414,7 +422,6 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc
&sendmsgguid, sizeof(sendmsgguid),
&sendmsg, sizeof(sendmsg), &bytesReturned, NULL, NULL) == SOCKET_ERROR)
sendmsg = 0;
-#endif
socketDescriptor = socket;
if (socket != INVALID_SOCKET) {
@@ -453,6 +460,7 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co
break;
}
case QNativeSocketEngine::TypeOfServiceOption:
+ case QNativeSocketEngine::MaxStreamsSocketOption:
return -1;
default:
@@ -503,6 +511,7 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt
break;
}
case QNativeSocketEngine::TypeOfServiceOption:
+ case QNativeSocketEngine::MaxStreamsSocketOption:
return false;
default:
@@ -1091,7 +1100,6 @@ qint64 QNativeSocketEnginePrivate::nativeBytesAvailable() const
bool QNativeSocketEnginePrivate::nativeHasPendingDatagrams() const
{
-#if !defined(Q_OS_WINCE)
// Create a sockaddr struct and reset its port number.
qt_sockaddr storage;
QT_SOCKLEN_T storageSize = sizeof(storage);
@@ -1118,18 +1126,6 @@ bool QNativeSocketEnginePrivate::nativeHasPendingDatagrams() const
result = true;
}
-#else // Q_OS_WINCE
- bool result = false;
- fd_set readS;
- FD_ZERO(&readS);
- FD_SET((SOCKET)socketDescriptor, &readS);
- timeval timeout;
- timeout.tv_sec = 0;
- timeout.tv_usec = 5000;
- int available = ::select(1, &readS, 0, 0, &timeout);
- result = available > 0;
-#endif
-
#if defined (QNATIVESOCKETENGINE_DEBUG)
qDebug("QNativeSocketEnginePrivate::nativeHasPendingDatagrams() == %s",
result ? "true" : "false");
@@ -1141,7 +1137,6 @@ bool QNativeSocketEnginePrivate::nativeHasPendingDatagrams() const
qint64 QNativeSocketEnginePrivate::nativePendingDatagramSize() const
{
qint64 ret = -1;
-#if !defined(Q_OS_WINCE)
int recvResult = 0;
DWORD flags;
DWORD bufferCount = 5;
@@ -1186,18 +1181,6 @@ qint64 QNativeSocketEnginePrivate::nativePendingDatagramSize() const
if (buf)
delete[] buf;
-#else // Q_OS_WINCE
- DWORD size = -1;
- DWORD bytesReturned;
- int ioResult = WSAIoctl(socketDescriptor, FIONREAD, 0,0, &size, sizeof(size), &bytesReturned, 0, 0);
- if (ioResult == SOCKET_ERROR) {
- int err = WSAGetLastError();
- WS_ERROR_DEBUG(err);
- } else {
- ret = qint64(size);
- }
-#endif
-
#if defined (QNATIVESOCKETENGINE_DEBUG)
qDebug("QNativeSocketEnginePrivate::nativePendingDatagramSize() == %lli", ret);
#endif
@@ -1205,12 +1188,6 @@ qint64 QNativeSocketEnginePrivate::nativePendingDatagramSize() const
return ret;
}
-#ifdef Q_OS_WINCE
-// Windows CE has no support for sendmsg or recvmsg. We set it to null here to simplify the code below.
-static int (*const recvmsg)(...) = 0;
-static int (*const sendmsg)(...) = 0;
-#endif
-
qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxLength, QIpPacketHeader *header,
QAbstractSocketEngine::PacketHeaderOptions options)
{
@@ -1330,12 +1307,7 @@ qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 l
memset(&msg, 0, sizeof(msg));
memset(&aa, 0, sizeof(aa));
-#if !defined(Q_OS_WINCE)
buf.buf = len ? (char*)data : 0;
-#else
- char tmp;
- buf.buf = len ? (char*)data : &tmp;
-#endif
msg.lpBuffers = &buf;
msg.dwBufferCount = 1;
msg.name = &aa.a;
@@ -1497,9 +1469,6 @@ qint64 QNativeSocketEnginePrivate::nativeRead(char *data, qint64 maxLength)
buf.len = maxLength;
DWORD flags = 0;
DWORD bytesRead = 0;
-#if defined(Q_OS_WINCE)
- WSASetLastError(0);
-#endif
if (::WSARecv(socketDescriptor, &buf, 1, &bytesRead, &flags, 0,0) == SOCKET_ERROR) {
int err = WSAGetLastError();
WS_ERROR_DEBUG(err);
@@ -1613,11 +1582,7 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout,
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;
-#if !defined(Q_OS_WINCE)
ret = select(socketDescriptor + 1, &fdread, &fdwrite, &fdexception, timeout < 0 ? 0 : &tv);
-#else
- ret = select(1, &fdread, &fdwrite, &fdexception, timeout < 0 ? 0 : &tv);
-#endif
//... but if it is actually set, pretend it did not happen
if (ret > 0 && FD_ISSET((SOCKET)socketDescriptor, &fdexception))
diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp
index 9817d4c57d..641863b4fd 100644
--- a/src/network/socket/qnativesocketengine_winrt.cpp
+++ b/src/network/socket/qnativesocketengine_winrt.cpp
@@ -632,6 +632,7 @@ qint64 QNativeSocketEngine::write(const char *data, qint64 len)
qint64 QNativeSocketEngine::readDatagram(char *data, qint64 maxlen, QIpPacketHeader *header,
PacketHeaderOptions)
{
+#ifndef QT_NO_UDPSOCKET
Q_D(QNativeSocketEngine);
if (d->socketType != QAbstractSocket::UdpSocket || d->pendingDatagrams.isEmpty()) {
if (header)
@@ -654,10 +655,17 @@ qint64 QNativeSocketEngine::readDatagram(char *data, qint64 maxlen, QIpPacketHea
}
memcpy(data, readOrigin, qMin(maxlen, qint64(datagram.data.length())));
return readOrigin.length();
+#else
+ Q_UNUSED(data)
+ Q_UNUSED(maxlen)
+ Q_UNUSED(header)
+ return -1;
+#endif // QT_NO_UDPSOCKET
}
qint64 QNativeSocketEngine::writeDatagram(const char *data, qint64 len, const QIpPacketHeader &header)
{
+#ifndef QT_NO_UDPSOCKET
Q_D(QNativeSocketEngine);
if (d->socketType != QAbstractSocket::UdpSocket)
return -1;
@@ -684,6 +692,12 @@ qint64 QNativeSocketEngine::writeDatagram(const char *data, qint64 len, const QI
Q_ASSERT_SUCCEEDED(hr);
return writeIOStream(stream, data, len);
+#else
+ Q_UNUSED(data)
+ Q_UNUSED(len)
+ Q_UNUSED(header)
+ return -1;
+#endif // QT_NO_UDPSOCKET
}
bool QNativeSocketEngine::hasPendingDatagrams() const
@@ -1088,6 +1102,7 @@ int QNativeSocketEnginePrivate::option(QAbstractSocketEngine::SocketOption opt)
case QAbstractSocketEngine::MulticastTtlOption:
case QAbstractSocketEngine::MulticastLoopbackOption:
case QAbstractSocketEngine::TypeOfServiceOption:
+ case QAbstractSocketEngine::MaxStreamsSocketOption:
default:
return -1;
}
@@ -1146,6 +1161,7 @@ bool QNativeSocketEnginePrivate::setOption(QAbstractSocketEngine::SocketOption o
case QAbstractSocketEngine::MulticastTtlOption:
case QAbstractSocketEngine::MulticastLoopbackOption:
case QAbstractSocketEngine::TypeOfServiceOption:
+ case QAbstractSocketEngine::MaxStreamsSocketOption:
default:
return false;
}
diff --git a/src/network/socket/qnativesocketengine_winrt_p.h b/src/network/socket/qnativesocketengine_winrt_p.h
index 5b76c2d223..ef219e61df 100644
--- a/src/network/socket/qnativesocketengine_winrt_p.h
+++ b/src/network/socket/qnativesocketengine_winrt_p.h
@@ -50,6 +50,8 @@
//
// We mean it.
//
+
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include <QtCore/QEventLoop>
#include <QtCore/QBuffer>
#include <QtCore/QMutex>
diff --git a/src/network/socket/qnet_unix_p.h b/src/network/socket/qnet_unix_p.h
index 8d2a4ae852..46fbc9757a 100644
--- a/src/network/socket/qnet_unix_p.h
+++ b/src/network/socket/qnet_unix_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "private/qcore_unix_p.h"
#include <sys/types.h>
diff --git a/src/network/socket/qsctpserver.cpp b/src/network/socket/qsctpserver.cpp
new file mode 100644
index 0000000000..24f18e1ee8
--- /dev/null
+++ b/src/network/socket/qsctpserver.cpp
@@ -0,0 +1,250 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//#define QSCTPSERVER_DEBUG
+
+/*!
+ \class QSctpServer
+ \since 5.8
+
+ \brief The QSctpServer class provides an SCTP-based server.
+
+ \ingroup network
+ \inmodule QtNetwork
+
+ SCTP (Stream Control Transmission Protocol) is a transport layer
+ protocol serving in a similar role as the popular protocols TCP
+ and UDP. Like UDP, SCTP is message-oriented, but it ensures reliable,
+ in-sequence transport of messages with congestion control like
+ TCP. See the QSctpSocket documentation for more protocol details.
+
+ QSctpServer is a convenience subclass of QTcpServer that allows
+ you to accept incoming SCTP socket connections either in TCP
+ emulation or in datagram mode.
+
+ The most common way to use QSctpServer is to construct an object
+ and set the maximum number of channels that the server is
+ prepared to support, by calling setMaxChannelCount(). You can set
+ the TCP emulation mode by passing a negative argument in this
+ call. Also, a special value of 0 (the default) indicates to use
+ the peer's value as the actual number of channels. The new incoming
+ connection inherits this number from the server socket descriptor
+ and adjusts it according to the remote endpoint settings.
+
+ In TCP emulation mode, accepted clients use a single continuous
+ byte stream for data transmission, and QSctpServer acts like a
+ plain QTcpServer. Call nextPendingConnection() to accept the
+ pending connection as a connected QTcpSocket. The function returns
+ a pointer to a QTcpSocket in QAbstractSocket::ConnectedState that
+ you can use for communicating with the client. This mode gives
+ access only to basic SCTP protocol features. The socket transmits SCTP
+ packets over IP at system level and interacts through the
+ QTcpSocket interface with the application.
+
+ In contrast, datagram mode is message-oriented and provides a
+ complete simultaneous transmission of multiple data streams
+ between endpoints. Call nextPendingDatagramConnection() to accept
+ the pending datagram-mode connection as a connected QSctpSocket.
+
+ \note This feature is not supported on the Windows platform.
+
+ \sa QTcpServer, QSctpSocket, QAbstractSocket
+*/
+
+#include "qsctpserver.h"
+#include "qsctpserver_p.h"
+
+#include "qsctpsocket.h"
+#include "qabstractsocketengine_p.h"
+
+#ifdef QSCTPSERVER_DEBUG
+#include <qdebug.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+/*! \internal
+*/
+QSctpServerPrivate::QSctpServerPrivate()
+ : maxChannelCount(0)
+{
+}
+
+/*! \internal
+*/
+QSctpServerPrivate::~QSctpServerPrivate()
+{
+}
+
+/*! \internal
+*/
+void QSctpServerPrivate::configureCreatedSocket()
+{
+ QTcpServerPrivate::configureCreatedSocket();
+ if (socketEngine)
+ socketEngine->setOption(QAbstractSocketEngine::MaxStreamsSocketOption,
+ maxChannelCount == -1 ? 1 : maxChannelCount);
+}
+
+/*!
+ Constructs a QSctpServer object.
+
+ Sets the datagram operation mode. The \a parent argument is passed
+ to QObject's constructor.
+
+ \sa setMaxChannelCount(), listen(), setSocketDescriptor()
+*/
+QSctpServer::QSctpServer(QObject *parent)
+ : QTcpServer(QAbstractSocket::SctpSocket, *new QSctpServerPrivate, parent)
+{
+#if defined(QSCTPSERVER_DEBUG)
+ qDebug("QSctpServer::QSctpServer()");
+#endif
+}
+
+/*!
+ Destroys the QSctpServer object. If the server is listening for
+ connections, the socket is automatically closed.
+
+ \sa close()
+*/
+QSctpServer::~QSctpServer()
+{
+#if defined(QSCTPSERVER_DEBUG)
+ qDebug("QSctpServer::~QSctpServer()");
+#endif
+}
+
+/*!
+ Sets the maximum number of channels that the server is prepared to
+ support in datagram mode, to \a count. If \a count is 0, endpoint
+ maximum number of channels value would be used. Negative \a count
+ sets a TCP emulation mode.
+
+ Call this method only when QSctpServer is in UnconnectedState.
+
+ \sa maxChannelCount(), QSctpSocket
+*/
+void QSctpServer::setMaxChannelCount(int count)
+{
+ Q_D(QSctpServer);
+ if (d->state != QAbstractSocket::UnconnectedState) {
+ qWarning("QSctpServer::setMaxChannelCount() is only allowed in UnconnectedState");
+ return;
+ }
+#if defined(QSCTPSERVER_DEBUG)
+ qDebug("QSctpServer::setMaxChannelCount(%i)", count);
+#endif
+ d->maxChannelCount = count;
+}
+
+/*!
+ Returns the maximum number of channels that the accepted sockets are
+ able to support.
+
+ A value of 0 (the default) means that the number of connection
+ channels would be set by the remote endpoint.
+
+ Returns -1, if QSctpServer running in TCP emulation mode.
+
+ \sa setMaxChannelCount()
+*/
+int QSctpServer::maxChannelCount() const
+{
+ return d_func()->maxChannelCount;
+}
+
+/*! \reimp
+*/
+void QSctpServer::incomingConnection(qintptr socketDescriptor)
+{
+#if defined (QSCTPSERVER_DEBUG)
+ qDebug("QSctpServer::incomingConnection(%i)", socketDescriptor);
+#endif
+
+ QSctpSocket *socket = new QSctpSocket(this);
+ socket->setMaxChannelCount(d_func()->maxChannelCount);
+ socket->setSocketDescriptor(socketDescriptor);
+ addPendingConnection(socket);
+}
+
+/*!
+ Returns the next pending datagram-mode connection as a connected
+ QSctpSocket object.
+
+ Datagram-mode connection provides a message-oriented, multi-stream
+ communication.
+
+ The socket is created as a child of the server, which means that
+ it is automatically deleted when the QSctpServer object is
+ destroyed. It is still a good idea to delete the object
+ explicitly when you are done with it, to avoid wasting memory.
+
+ This function returns null if there are no pending datagram-mode
+ connections.
+
+ \note The returned QSctpSocket object cannot be used from another
+ thread. If you want to use an incoming connection from another
+ thread, you need to override incomingConnection().
+
+ \sa hasPendingConnections(), nextPendingConnection(), QSctpSocket
+*/
+QSctpSocket *QSctpServer::nextPendingDatagramConnection()
+{
+ Q_D(QSctpServer);
+
+ QMutableListIterator<QTcpSocket *> i(d->pendingConnections);
+ while (i.hasNext()) {
+ QSctpSocket *socket = qobject_cast<QSctpSocket *>(i.next());
+ Q_ASSERT(socket);
+
+ if (socket->inDatagramMode()) {
+ i.remove();
+ Q_ASSERT(d->socketEngine);
+ d->socketEngine->setReadNotificationEnabled(true);
+ return socket;
+ }
+ }
+
+ return nullptr;
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qsctpserver.cpp"
diff --git a/src/corelib/io/qurl_mac.mm b/src/network/socket/qsctpserver.h
index 04d05f1b23..fb017a924d 100644
--- a/src/corelib/io/qurl_mac.mm
+++ b/src/network/socket/qsctpserver.h
@@ -1,9 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the QtCore module of the Qt Toolkit.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -37,38 +37,41 @@
**
****************************************************************************/
-#include "qurl.h"
+#ifndef QSCTPSERVER_H
+#define QSCTPSERVER_H
-#ifdef Q_OS_MAC
-#include <Foundation/Foundation.h>
-#endif
+#include <QtNetwork/qtcpserver.h>
QT_BEGIN_NAMESPACE
-QUrl QUrl::fromCFURL(CFURLRef url)
-{
- return QUrl(QString::fromCFString(CFURLGetString(url)));
-}
-CFURLRef QUrl::toCFURL() const
-{
- CFURLRef url = 0;
- CFStringRef str = toString(FullyEncoded).toCFString();
- if (str) {
- url = CFURLCreateWithString(0, str, 0);
- CFRelease(str);
- }
- return url;
-}
+#ifndef QT_NO_SCTP
-QUrl QUrl::fromNSURL(const NSURL *url)
-{
- return QUrl(QString::fromNSString([url absoluteString]));
-}
+class QSctpServerPrivate;
+class QSctpSocket;
-NSURL *QUrl::toNSURL() const
+class Q_NETWORK_EXPORT QSctpServer : public QTcpServer
{
- return [NSURL URLWithString:toString(FullyEncoded).toNSString()];
-}
+ Q_OBJECT
+public:
+ explicit QSctpServer(QObject *parent = nullptr);
+ virtual ~QSctpServer();
+
+ void setMaxChannelCount(int count);
+ int maxChannelCount() const;
+
+ QSctpSocket *nextPendingDatagramConnection();
+
+protected:
+ void incomingConnection(qintptr handle) Q_DECL_OVERRIDE;
+
+private:
+ Q_DISABLE_COPY(QSctpServer)
+ Q_DECLARE_PRIVATE(QSctpServer)
+};
+
+#endif // QT_NO_SCTP
QT_END_NAMESPACE
+
+#endif // QSCTPSERVER_H
diff --git a/src/network/socket/qsctpserver_p.h b/src/network/socket/qsctpserver_p.h
new file mode 100644
index 0000000000..32760caffe
--- /dev/null
+++ b/src/network/socket/qsctpserver_p.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSCTPSERVER_P_H
+#define QSCTPSERVER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the QLibrary class. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "private/qtcpserver_p.h"
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_SCTP
+
+class QSctpServerPrivate : public QTcpServerPrivate
+{
+ Q_DECLARE_PUBLIC(QSctpServer)
+public:
+ QSctpServerPrivate();
+ virtual ~QSctpServerPrivate();
+
+ int maxChannelCount;
+
+ void configureCreatedSocket() Q_DECL_OVERRIDE;
+};
+
+#endif // QT_NO_SCTP
+
+QT_END_NAMESPACE
+
+#endif // QSCTPSERVER_P_H
diff --git a/src/network/socket/qsctpsocket.cpp b/src/network/socket/qsctpsocket.cpp
new file mode 100644
index 0000000000..f65ffa765d
--- /dev/null
+++ b/src/network/socket/qsctpsocket.cpp
@@ -0,0 +1,547 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//#define QSCTPSOCKET_DEBUG
+
+/*!
+ \class QSctpSocket
+ \since 5.8
+
+ \brief The QSctpSocket class provides an SCTP socket.
+
+ \ingroup network
+ \inmodule QtNetwork
+
+ SCTP (Stream Control Transmission Protocol) is a transport layer
+ protocol serving in a similar role as the popular protocols TCP
+ and UDP. Like UDP, SCTP is message-oriented, but it ensures reliable,
+ in-sequence transport of messages with congestion control like
+ TCP.
+
+ SCTP is connection-oriented protocol, which provides the complete
+ simultaneous transmission of multiple data streams between
+ endpoints. This multi-streaming allows data to be delivered by
+ independent channels, so that if there is data loss in one stream,
+ delivery will not be affected for the other streams.
+
+ Being message-oriented, SCTP transports a sequence of messages,
+ rather than transporting an unbroken stream of bytes as does TCP.
+ Like in UDP, in SCTP a sender sends a message in one operation,
+ and that exact message is passed to the receiving application
+ process in one operation. But unlike UDP, the delivery is
+ guaranteed.
+
+ It also supports multi-homing, meaning that a connected endpoint
+ can have alternate IP addresses associated with it in order to
+ route around network failure or changing conditions.
+
+ QSctpSocket is a convenience subclass of QTcpSocket that allows
+ you to emulate TCP data stream over SCTP or establish an SCTP
+ connection for reliable datagram service.
+
+ QSctpSocket can operate in one of two possible modes:
+
+ \list
+ \li Continuous byte stream (TCP emulation).
+ \li Multi-streamed datagram mode.
+ \endlist
+
+ To set a continuous byte stream mode, instantiate QSctpSocket and
+ call setMaxChannelCount() with a negative value. This gives the
+ ability to use QSctpSocket as a regular buffered QTcpSocket. You
+ can call connectToHost() to initiate connection with endpoint,
+ write() to transmit and read() to receive data from the peer, but
+ you cannot distinguish message boundaries.
+
+ By default, QSctpSocket operates in datagram mode. Before
+ connecting, call setMaxChannelCount() to set the maximum number of
+ channels that the application is prepared to support. This number
+ is a parameter negotiated with the remote endpoint and its value
+ can be bounded by the operating system. The default value of 0
+ indicates to use the peer's value. If both endpoints have default
+ values, then number of connection channels is system-dependent.
+ After establishing a connection, you can fetch the actual number
+ of channels by calling readChannelCount() and writeChannelCount().
+
+ \snippet code/src_network_socket_qsctpsocket.cpp 0
+
+ In datagram mode, QSctpSocket performs the buffering of datagrams
+ independently for each channel. You can queue a datagram to the
+ buffer of the current channel by calling writeDatagram() and read
+ a pending datagram by calling readDatagram() respectively.
+
+ Using the standard QIODevice functions read(), readLine(), write(),
+ etc. is allowed in datagram mode with the same limitations as in
+ continuous byte stream mode.
+
+ \note This feature is not supported on the Windows platform.
+
+ \sa QSctpServer, QTcpSocket, QAbstractSocket
+*/
+
+#include "qsctpsocket.h"
+#include "qsctpsocket_p.h"
+
+#include "qabstractsocketengine_p.h"
+#include "private/qbytearray_p.h"
+
+#ifdef QSCTPSOCKET_DEBUG
+#include <qdebug.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+/*! \internal
+*/
+QSctpSocketPrivate::QSctpSocketPrivate()
+ : maxChannelCount(0)
+{
+}
+
+/*! \internal
+*/
+QSctpSocketPrivate::~QSctpSocketPrivate()
+{
+}
+
+/*! \internal
+*/
+bool QSctpSocketPrivate::canReadNotification()
+{
+ Q_Q(QSctpSocket);
+#if defined (QSCTPSOCKET_DEBUG)
+ qDebug("QSctpSocketPrivate::canReadNotification()");
+#endif
+
+ // Handle TCP emulation mode in the base implementation.
+ if (!q->inDatagramMode())
+ return QTcpSocketPrivate::canReadNotification();
+
+ const int savedCurrentChannel = currentReadChannel;
+ bool currentChannelRead = false;
+ do {
+ int datagramSize = incomingDatagram.size();
+ QIpPacketHeader header;
+
+ do {
+ // Determine the size of the pending datagram.
+ qint64 bytesToRead = socketEngine->bytesAvailable();
+ if (bytesToRead == 0) {
+ // As a corner case, if we can't determine the size of the pending datagram,
+ // try to read 4K of data from the socket. Subsequent ::recvmsg call either
+ // fails or returns the actual length of the datagram.
+ bytesToRead = 4096;
+ }
+
+ Q_ASSERT((datagramSize + int(bytesToRead)) < MaxByteArraySize);
+ incomingDatagram.resize(datagramSize + int(bytesToRead));
+
+#if defined (QSCTPSOCKET_DEBUG)
+ qDebug("QSctpSocketPrivate::canReadNotification() about to read %lli bytes",
+ bytesToRead);
+#endif
+ qint64 readBytes = socketEngine->readDatagram(
+ incomingDatagram.data() + datagramSize, bytesToRead, &header,
+ QAbstractSocketEngine::WantAll);
+ if (readBytes <= 0) {
+ if (readBytes == -2) { // no data available for reading
+ incomingDatagram.resize(datagramSize);
+ return currentChannelRead;
+ }
+
+ socketEngine->close();
+ if (readBytes == 0) {
+ setErrorAndEmit(QAbstractSocket::RemoteHostClosedError,
+ QSctpSocket::tr("The remote host closed the connection"));
+ } else {
+#if defined (QSCTPSOCKET_DEBUG)
+ qDebug("QSctpSocketPrivate::canReadNotification() read failed: %s",
+ socketEngine->errorString().toLatin1().constData());
+#endif
+ setErrorAndEmit(socketEngine->error(), socketEngine->errorString());
+ }
+
+#if defined (QSCTPSOCKET_DEBUG)
+ qDebug("QSctpSocketPrivate::canReadNotification() disconnecting socket");
+#endif
+ q->disconnectFromHost();
+ return currentChannelRead;
+ }
+ datagramSize += int(readBytes); // update datagram size
+ } while (!header.endOfRecord);
+
+#if defined (QSCTPSOCKET_DEBUG)
+ qDebug("QSctpSocketPrivate::canReadNotification() got datagram from channel %i, size = %i",
+ header.streamNumber, datagramSize);
+#endif
+
+ // Drop the datagram, if opened only for writing
+ if (!q->isReadable()) {
+ incomingDatagram.clear();
+ continue;
+ }
+
+ // Store datagram in the channel buffer
+ Q_ASSERT(header.streamNumber < readBuffers.size());
+ incomingDatagram.resize(datagramSize);
+ readBuffers[header.streamNumber].setChunkSize(0); // set packet mode on channel buffer
+ readBuffers[header.streamNumber].append(incomingDatagram);
+ incomingDatagram = QByteArray();
+
+ if (readHeaders.size() != readBuffers.size())
+ readHeaders.resize(readBuffers.size());
+ readHeaders[header.streamNumber].push_back(header);
+
+ // Emit notifications.
+ if (header.streamNumber == savedCurrentChannel)
+ currentChannelRead = true;
+ emitReadyRead(header.streamNumber);
+
+ } while (state == QAbstractSocket::ConnectedState);
+
+ return currentChannelRead;
+}
+
+/*! \internal
+*/
+bool QSctpSocketPrivate::writeToSocket()
+{
+ Q_Q(QSctpSocket);
+#if defined (QSCTPSOCKET_DEBUG)
+ qDebug("QSctpSocketPrivate::writeToSocket()");
+#endif
+
+ // Handle TCP emulation mode in the base implementation.
+ if (!q->inDatagramMode())
+ return QTcpSocketPrivate::writeToSocket();
+
+ if (!socketEngine)
+ return false;
+
+ QIpPacketHeader defaultHeader;
+ const int savedCurrentChannel = currentWriteChannel;
+ bool currentChannelWritten = false;
+ bool transmitting;
+ do {
+ transmitting = false;
+
+ for (int channel = 0; channel < writeBuffers.size(); ++channel) {
+ QRingBuffer &channelBuffer = writeBuffers[channel];
+
+ if (channelBuffer.isEmpty())
+ continue;
+
+ const bool hasHeader = (channel < writeHeaders.size())
+ && !writeHeaders[channel].empty();
+ QIpPacketHeader &header = hasHeader ? writeHeaders[channel].front() : defaultHeader;
+ header.streamNumber = channel;
+ qint64 sent = socketEngine->writeDatagram(channelBuffer.readPointer(),
+ channelBuffer.nextDataBlockSize(),
+ header);
+ if (sent < 0) {
+ if (sent == -2) // temporary error in writeDatagram
+ return currentChannelWritten;
+
+ socketEngine->close();
+#if defined (QSCTPSOCKET_DEBUG)
+ qDebug("QSctpSocketPrivate::writeToSocket() write error, aborting. %s",
+ socketEngine->errorString().toLatin1().constData());
+#endif
+ setErrorAndEmit(socketEngine->error(), socketEngine->errorString());
+ // An unexpected error so close the socket.
+ q->disconnectFromHost();
+ return currentChannelWritten;
+ }
+ Q_ASSERT(sent == channelBuffer.nextDataBlockSize());
+#if defined (QSCTPSOCKET_DEBUG)
+ qDebug("QSctpSocketPrivate::writeToSocket() sent datagram of size %lli to channel %i",
+ sent, channel);
+#endif
+ transmitting = true;
+
+ // Remove datagram from the buffer
+ channelBuffer.read();
+ if (hasHeader)
+ writeHeaders[channel].pop_front();
+
+ // Emit notifications.
+ if (channel == savedCurrentChannel)
+ currentChannelWritten = true;
+ emitBytesWritten(sent, channel);
+
+ // If we were closed as a result of the bytesWritten() signal, return.
+ if (state == QAbstractSocket::UnconnectedState) {
+#if defined (QSCTPSOCKET_DEBUG)
+ qDebug("QSctpSocketPrivate::writeToSocket() socket is closing - returning");
+#endif
+ return currentChannelWritten;
+ }
+ }
+ } while (transmitting);
+
+ // At this point socket is either in Connected or Closing state,
+ // write buffers are empty.
+ if (state == QAbstractSocket::ClosingState)
+ q->disconnectFromHost();
+ else
+ socketEngine->setWriteNotificationEnabled(false);
+
+ return currentChannelWritten;
+}
+
+/*! \internal
+*/
+void QSctpSocketPrivate::configureCreatedSocket()
+{
+ if (socketEngine)
+ socketEngine->setOption(QAbstractSocketEngine::MaxStreamsSocketOption,
+ maxChannelCount < 0 ? 1 : maxChannelCount);
+}
+
+/*!
+ Creates a QSctpSocket object in state \c UnconnectedState.
+
+ Sets the datagram operation mode. The \a parent argument is passed
+ to QObject's constructor.
+
+ \sa socketType(), setMaxChannelCount()
+*/
+QSctpSocket::QSctpSocket(QObject *parent)
+ : QTcpSocket(SctpSocket, *new QSctpSocketPrivate, parent)
+{
+#if defined(QSCTPSOCKET_DEBUG)
+ qDebug("QSctpSocket::QSctpSocket()");
+#endif
+ d_func()->isBuffered = true;
+}
+
+/*!
+ Destroys the socket, closing the connection if necessary.
+
+ \sa close()
+*/
+QSctpSocket::~QSctpSocket()
+{
+#if defined(QSCTPSOCKET_DEBUG)
+ qDebug("QSctpSocket::~QSctpSocket()");
+#endif
+}
+
+/*! \reimp
+*/
+qint64 QSctpSocket::readData(char *data, qint64 maxSize)
+{
+ Q_D(QSctpSocket);
+
+ // Cleanup headers, if the user calls the standard QIODevice functions
+ if (d->currentReadChannel < d->readHeaders.size())
+ d->readHeaders[d->currentReadChannel].clear();
+
+ return QTcpSocket::readData(data, maxSize);
+}
+
+/*! \reimp
+*/
+qint64 QSctpSocket::readLineData(char *data, qint64 maxlen)
+{
+ Q_D(QSctpSocket);
+
+ // Cleanup headers, if the user calls the standard QIODevice functions
+ if (d->currentReadChannel < d->readHeaders.size())
+ d->readHeaders[d->currentReadChannel].clear();
+
+ return QTcpSocket::readLineData(data, maxlen);
+}
+
+/*! \reimp
+*/
+void QSctpSocket::close()
+{
+ QTcpSocket::close();
+ d_func()->readHeaders.clear();
+}
+
+/*! \reimp
+*/
+void QSctpSocket::disconnectFromHost()
+{
+ Q_D(QSctpSocket);
+
+ QTcpSocket::disconnectFromHost();
+ if (d->state == QAbstractSocket::UnconnectedState) {
+ d->incomingDatagram.clear();
+ d->writeHeaders.clear();
+ }
+}
+
+/*!
+ Sets the maximum number of channels that the application is
+ prepared to support in datagram mode, to \a count. If \a count
+ is 0, endpoint's value for maximum number of channels is used.
+ Negative \a count sets a continuous byte stream mode.
+
+ Call this method only when QSctpSocket is in UnconnectedState.
+
+ \sa maxChannelCount(), readChannelCount(), writeChannelCount()
+*/
+void QSctpSocket::setMaxChannelCount(int count)
+{
+ Q_D(QSctpSocket);
+ if (d->state != QAbstractSocket::UnconnectedState) {
+ qWarning("QSctpSocket::setMaxChannelCount() is only allowed in UnconnectedState");
+ return;
+ }
+#if defined(QSCTPSOCKET_DEBUG)
+ qDebug("QSctpSocket::setMaxChannelCount(%i)", count);
+#endif
+ d->maxChannelCount = qMax(count, -1);
+}
+
+/*!
+ Returns the maximum number of channels that QSctpSocket is able to
+ support.
+
+ A value of 0 (the default) means that the number of connection
+ channels would be set by the remote endpoint.
+
+ Returns -1 if QSctpSocket is running in continuous byte stream
+ mode.
+
+ \sa setMaxChannelCount(), readChannelCount(), writeChannelCount()
+*/
+int QSctpSocket::maxChannelCount() const
+{
+ return d_func()->maxChannelCount;
+}
+
+/*!
+ Returns \c true if the socket is running in datagram mode.
+
+ \sa setMaxChannelCount()
+*/
+bool QSctpSocket::inDatagramMode() const
+{
+ Q_D(const QSctpSocket);
+ return d->maxChannelCount != -1 && d->isBuffered;
+}
+
+/*!
+ Reads a datagram from the buffer of the current read channel, and
+ returns it as a QNetworkDatagram object, along with the sender's
+ host address and port. If possible, this function will also try to
+ determine the datagram's destination address, port, and the number
+ of hop counts at reception time.
+
+ On failure, returns a QNetworkDatagram that reports \l
+ {QNetworkDatagram::isValid()}{not valid}.
+
+ \sa writeDatagram(), inDatagramMode(), currentReadChannel()
+*/
+QNetworkDatagram QSctpSocket::readDatagram()
+{
+ Q_D(QSctpSocket);
+
+ if (!isReadable() || !inDatagramMode()) {
+ qWarning("QSctpSocket::readDatagram(): operation is not permitted");
+ return QNetworkDatagram();
+ }
+
+ if (d->currentReadChannel >= d->readHeaders.size()
+ || d->readHeaders[d->currentReadChannel].size() == 0) {
+ Q_ASSERT(d->buffer.isEmpty());
+ return QNetworkDatagram();
+ }
+
+ QNetworkDatagram result(*new QNetworkDatagramPrivate(d->buffer.read(),
+ d->readHeaders[d->currentReadChannel].front()));
+ d->readHeaders[d->currentReadChannel].pop_front();
+
+#if defined (QSCTPSOCKET_DEBUG)
+ qDebug("QSctpSocket::readDatagram() returning datagram (%p, %i, \"%s\", %i)",
+ result.d->data.constData(),
+ result.d->data.size(),
+ result.senderAddress().toString().toLatin1().constData(),
+ result.senderPort());
+#endif
+
+ return result;
+}
+
+/*!
+ Writes a datagram to the buffer of the current write channel.
+ Returns true on success; otherwise returns false.
+
+ \sa readDatagram(), inDatagramMode(), currentWriteChannel()
+*/
+bool QSctpSocket::writeDatagram(const QNetworkDatagram &datagram)
+{
+ Q_D(QSctpSocket);
+
+ if (!isWritable() || d->state != QAbstractSocket::ConnectedState || !d->socketEngine
+ || !d->socketEngine->isValid() || !inDatagramMode()) {
+ qWarning("QSctpSocket::writeDatagram(): operation is not permitted");
+ return false;
+ }
+
+ if (datagram.d->data.isEmpty()) {
+ qWarning("QSctpSocket::writeDatagram() is called with empty datagram");
+ return false;
+ }
+
+
+#if defined QSCTPSOCKET_DEBUG
+ qDebug("QSctpSocket::writeDatagram(%p, %i, \"%s\", %i)",
+ datagram.d->data.constData(),
+ datagram.d->data.size(),
+ datagram.destinationAddress().toString().toLatin1().constData(),
+ datagram.destinationPort());
+#endif
+
+ if (d->writeHeaders.size() != d->writeBuffers.size())
+ d->writeHeaders.resize(d->writeBuffers.size());
+ Q_ASSERT(d->currentWriteChannel < d->writeHeaders.size());
+ d->writeHeaders[d->currentWriteChannel].push_back(datagram.d->header);
+ d->writeBuffer.setChunkSize(0); // set packet mode on channel buffer
+ d->writeBuffer.append(datagram.d->data);
+
+ d->socketEngine->setWriteNotificationEnabled(true);
+ return true;
+}
+
+QT_END_NAMESPACE
diff --git a/src/network/socket/qsctpsocket.h b/src/network/socket/qsctpsocket.h
new file mode 100644
index 0000000000..aaa4e1ecca
--- /dev/null
+++ b/src/network/socket/qsctpsocket.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSCTPSOCKET_H
+#define QSCTPSOCKET_H
+
+#include <QtNetwork/qtcpsocket.h>
+#include <QtNetwork/qnetworkdatagram.h>
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_SCTP
+
+class QSctpSocketPrivate;
+
+class Q_NETWORK_EXPORT QSctpSocket : public QTcpSocket
+{
+ Q_OBJECT
+public:
+ explicit QSctpSocket(QObject *parent = nullptr);
+ virtual ~QSctpSocket();
+
+ void close() Q_DECL_OVERRIDE;
+ void disconnectFromHost() Q_DECL_OVERRIDE;
+
+ void setMaxChannelCount(int count);
+ int maxChannelCount() const;
+ bool inDatagramMode() const;
+
+ QNetworkDatagram readDatagram();
+ bool writeDatagram(const QNetworkDatagram &datagram);
+
+protected:
+ qint64 readData(char *data, qint64 maxlen) Q_DECL_OVERRIDE;
+ qint64 readLineData(char *data, qint64 maxlen) Q_DECL_OVERRIDE;
+
+private:
+ Q_DISABLE_COPY(QSctpSocket)
+ Q_DECLARE_PRIVATE(QSctpSocket)
+};
+
+#endif // QT_NO_SCTP
+
+QT_END_NAMESPACE
+
+#endif // QSCTPSOCKET_H
diff --git a/src/network/socket/qsctpsocket_p.h b/src/network/socket/qsctpsocket_p.h
new file mode 100644
index 0000000000..f38095330f
--- /dev/null
+++ b/src/network/socket/qsctpsocket_p.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSCTPSOCKET_P_H
+#define QSCTPSOCKET_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the QLibrary class. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtNetwork/qsctpsocket.h>
+#include <private/qtcpsocket_p.h>
+#include <QtCore/qbytearray.h>
+#include <QtCore/qvector.h>
+#include <private/qnetworkdatagram_p.h>
+
+#include <deque>
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_SCTP
+
+class QSctpSocketPrivate : public QTcpSocketPrivate
+{
+ Q_DECLARE_PUBLIC(QSctpSocket)
+public:
+ QSctpSocketPrivate();
+ virtual ~QSctpSocketPrivate();
+
+ bool canReadNotification() Q_DECL_OVERRIDE;
+ bool writeToSocket() Q_DECL_OVERRIDE;
+
+ QByteArray incomingDatagram;
+ int maxChannelCount;
+
+ typedef std::deque<QIpPacketHeader> IpHeaderList;
+ QVector<IpHeaderList> readHeaders;
+ QVector<IpHeaderList> writeHeaders;
+
+ void configureCreatedSocket() Q_DECL_OVERRIDE;
+};
+
+#endif // QT_NO_SCTP
+
+QT_END_NAMESPACE
+
+#endif // QSCTPSOCKET_P_H
diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp
index a57a1dca2c..518ec21f90 100644
--- a/src/network/socket/qsocks5socketengine.cpp
+++ b/src/network/socket/qsocks5socketengine.cpp
@@ -64,11 +64,7 @@ static const int MaxWriteBufferSize = 128*1024;
//#define QSOCKS5SOCKETLAYER_DEBUG
#define MAX_DATA_DUMP 256
-#if !defined(Q_OS_WINCE)
#define SOCKS5_BLOCKING_BIND_TIMEOUT 5000
-#else
-#define SOCKS5_BLOCKING_BIND_TIMEOUT 10000
-#endif
#define Q_INIT_CHECK(returnValue) do { \
if (!d->data) { \
@@ -1609,8 +1605,31 @@ bool QSocks5SocketEngine::setMulticastInterface(const QNetworkInterface &)
}
#endif // QT_NO_NETWORKINTERFACE
+bool QSocks5SocketEngine::hasPendingDatagrams() const
+{
+ Q_D(const QSocks5SocketEngine);
+ Q_INIT_CHECK(false);
+
+ d->checkForDatagrams();
+
+ return !d->udpData->pendingDatagrams.isEmpty();
+}
+
+qint64 QSocks5SocketEngine::pendingDatagramSize() const
+{
+ Q_D(const QSocks5SocketEngine);
+
+ d->checkForDatagrams();
+
+ if (!d->udpData->pendingDatagrams.isEmpty())
+ return d->udpData->pendingDatagrams.head().data.size();
+ return 0;
+}
+#endif // QT_NO_UDPSOCKET
+
qint64 QSocks5SocketEngine::readDatagram(char *data, qint64 maxlen, QIpPacketHeader *header, PacketHeaderOptions)
{
+#ifndef QT_NO_UDPSOCKET
Q_D(QSocks5SocketEngine);
d->checkForDatagrams();
@@ -1624,10 +1643,17 @@ qint64 QSocks5SocketEngine::readDatagram(char *data, qint64 maxlen, QIpPacketHea
header->senderAddress = datagram.address;
header->senderPort = datagram.port;
return copyLen;
+#else
+ Q_UNUSED(data)
+ Q_UNUSED(maxlen)
+ Q_UNUSED(header)
+ return -1;
+#endif // QT_NO_UDPSOCKET
}
qint64 QSocks5SocketEngine::writeDatagram(const char *data, qint64 len, const QIpPacketHeader &header)
{
+#ifndef QT_NO_UDPSOCKET
Q_D(QSocks5SocketEngine);
// it is possible to send with out first binding with udp, but socks5 requires a bind.
@@ -1664,29 +1690,13 @@ qint64 QSocks5SocketEngine::writeDatagram(const char *data, qint64 len, const QI
}
return len;
-}
-
-bool QSocks5SocketEngine::hasPendingDatagrams() const
-{
- Q_D(const QSocks5SocketEngine);
- Q_INIT_CHECK(false);
-
- d->checkForDatagrams();
-
- return !d->udpData->pendingDatagrams.isEmpty();
-}
-
-qint64 QSocks5SocketEngine::pendingDatagramSize() const
-{
- Q_D(const QSocks5SocketEngine);
-
- d->checkForDatagrams();
-
- if (!d->udpData->pendingDatagrams.isEmpty())
- return d->udpData->pendingDatagrams.head().data.size();
- return 0;
-}
+#else
+ Q_UNUSED(data)
+ Q_UNUSED(len)
+ Q_UNUSED(header)
+ return -1;
#endif // QT_NO_UDPSOCKET
+}
qint64 QSocks5SocketEngine::bytesToWrite() const
{
diff --git a/src/network/socket/qsocks5socketengine_p.h b/src/network/socket/qsocks5socketengine_p.h
index 30caa4b50c..864b163489 100644
--- a/src/network/socket/qsocks5socketengine_p.h
+++ b/src/network/socket/qsocks5socketengine_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qabstractsocketengine_p.h"
#include "qnetworkproxy.h"
@@ -99,13 +100,13 @@ public:
bool setMulticastInterface(const QNetworkInterface &iface) Q_DECL_OVERRIDE;
#endif // QT_NO_NETWORKINTERFACE
- qint64 readDatagram(char *data, qint64 maxlen, QIpPacketHeader * = 0,
- PacketHeaderOptions = WantNone) Q_DECL_OVERRIDE;
- qint64 writeDatagram(const char *data, qint64 len, const QIpPacketHeader &) Q_DECL_OVERRIDE;
bool hasPendingDatagrams() const Q_DECL_OVERRIDE;
qint64 pendingDatagramSize() const Q_DECL_OVERRIDE;
#endif // QT_NO_UDPSOCKET
+ qint64 readDatagram(char *data, qint64 maxlen, QIpPacketHeader * = 0,
+ PacketHeaderOptions = WantNone) Q_DECL_OVERRIDE;
+ qint64 writeDatagram(const char *data, qint64 len, const QIpPacketHeader &) Q_DECL_OVERRIDE;
qint64 bytesToWrite() const Q_DECL_OVERRIDE;
int option(SocketOption option) const Q_DECL_OVERRIDE;
diff --git a/src/network/socket/qtcpserver.cpp b/src/network/socket/qtcpserver.cpp
index de1dc29cfb..eddf789921 100644
--- a/src/network/socket/qtcpserver.cpp
+++ b/src/network/socket/qtcpserver.cpp
@@ -119,6 +119,7 @@ QT_BEGIN_NAMESPACE
*/
QTcpServerPrivate::QTcpServerPrivate()
: port(0)
+ , socketType(QAbstractSocket::UnknownSocketType)
, state(QAbstractSocket::UnconnectedState)
, socketEngine(0)
, serverSocketError(QAbstractSocket::UnknownSocketError)
@@ -148,13 +149,21 @@ QNetworkProxy QTcpServerPrivate::resolveProxy(const QHostAddress &address, quint
proxies << proxy;
} else {
// try the application settings instead
- QNetworkProxyQuery query(port, QString(), QNetworkProxyQuery::TcpServer);
+ QNetworkProxyQuery query(port, QString(),
+ socketType == QAbstractSocket::SctpSocket ?
+ QNetworkProxyQuery::SctpServer :
+ QNetworkProxyQuery::TcpServer);
proxies = QNetworkProxyFactory::proxyForQuery(query);
}
// return the first that we can use
for (const QNetworkProxy &p : qAsConst(proxies)) {
- if (p.capabilities() & QNetworkProxy::ListeningCapability)
+ if (socketType == QAbstractSocket::TcpSocket &&
+ (p.capabilities() & QNetworkProxy::ListeningCapability) != 0)
+ return p;
+
+ if (socketType == QAbstractSocket::SctpSocket &&
+ (p.capabilities() & QNetworkProxy::SctpListeningCapability) != 0)
return p;
}
@@ -228,9 +237,11 @@ void QTcpServerPrivate::readNotification()
QTcpServer::QTcpServer(QObject *parent)
: QObject(*new QTcpServerPrivate, parent)
{
+ Q_D(QTcpServer);
#if defined(QTCPSERVER_DEBUG)
qDebug("QTcpServer::QTcpServer(%p)", parent);
#endif
+ d->socketType = QAbstractSocket::TcpSocket;
}
/*!
@@ -251,13 +262,22 @@ QTcpServer::~QTcpServer()
}
/*! \internal
+
+ Constructs a new server object with socket of type \a socketType. The \a
+ parent argument is passed to QObject's constructor.
*/
-QTcpServer::QTcpServer(QTcpServerPrivate &dd, QObject *parent)
- : QObject(dd, parent)
+QTcpServer::QTcpServer(QAbstractSocket::SocketType socketType, QTcpServerPrivate &dd,
+ QObject *parent) : QObject(dd, parent)
{
+ Q_D(QTcpServer);
#if defined(QTCPSERVER_DEBUG)
- qDebug("QTcpServer::QTcpServer(QTcpServerPrivate == %p, parent == %p)", &dd, parent);
+ qDebug("QTcpServer::QTcpServer(%sSocket, QTcpServerPrivate == %p, parent == %p)",
+ socketType == QAbstractSocket::TcpSocket ? "Tcp"
+ : socketType == QAbstractSocket::UdpSocket ? "Udp"
+ : socketType == QAbstractSocket::SctpSocket ? "Sctp"
+ : "Unknown", &dd, parent);
#endif
+ d->socketType = socketType;
}
/*!
@@ -288,7 +308,7 @@ bool QTcpServer::listen(const QHostAddress &address, quint16 port)
#endif
delete d->socketEngine;
- d->socketEngine = QAbstractSocketEngine::createSocketEngine(QAbstractSocket::TcpSocket, proxy, this);
+ d->socketEngine = QAbstractSocketEngine::createSocketEngine(d->socketType, proxy, this);
if (!d->socketEngine) {
d->serverSocketError = QAbstractSocket::UnsupportedSocketOperationError;
d->serverSocketErrorString = tr("Operation on socket is not supported");
@@ -298,7 +318,7 @@ bool QTcpServer::listen(const QHostAddress &address, quint16 port)
//copy network session down to the socket engine (if it has been set)
d->socketEngine->setProperty("_q_networksession", property("_q_networksession"));
#endif
- if (!d->socketEngine->initialize(QAbstractSocket::TcpSocket, proto)) {
+ if (!d->socketEngine->initialize(d->socketType, proto)) {
d->serverSocketError = d->socketEngine->error();
d->serverSocketErrorString = d->socketEngine->errorString();
return false;
@@ -543,8 +563,11 @@ QTcpSocket *QTcpServer::nextPendingConnection()
if (d->pendingConnections.isEmpty())
return 0;
- if (!d->socketEngine->isReadNotificationEnabled())
+ if (!d->socketEngine) {
+ qWarning("QTcpServer::nextPendingConnection() called while not listening");
+ } else if (!d->socketEngine->isReadNotificationEnabled()) {
d->socketEngine->setReadNotificationEnabled(true);
+ }
return d->pendingConnections.takeFirst();
}
diff --git a/src/network/socket/qtcpserver.h b/src/network/socket/qtcpserver.h
index 90781564b4..192cbce54c 100644
--- a/src/network/socket/qtcpserver.h
+++ b/src/network/socket/qtcpserver.h
@@ -40,6 +40,7 @@
#ifndef QTCPSERVER_H
#define QTCPSERVER_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qobject.h>
#include <QtNetwork/qabstractsocket.h>
#include <QtNetwork/qhostaddress.h>
@@ -93,7 +94,8 @@ protected:
virtual void incomingConnection(qintptr handle);
void addPendingConnection(QTcpSocket* socket);
- QTcpServer(QTcpServerPrivate &dd, QObject *parent = Q_NULLPTR);
+ QTcpServer(QAbstractSocket::SocketType socketType, QTcpServerPrivate &dd,
+ QObject *parent = Q_NULLPTR);
Q_SIGNALS:
void newConnection();
diff --git a/src/network/socket/qtcpserver_p.h b/src/network/socket/qtcpserver_p.h
index b53f53b921..b11dd93718 100644
--- a/src/network/socket/qtcpserver_p.h
+++ b/src/network/socket/qtcpserver_p.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
@@ -51,6 +52,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "QtNetwork/qtcpserver.h"
#include "private/qobject_p.h"
#include "private/qabstractsocketengine_p.h"
@@ -73,6 +75,7 @@ public:
quint16 port;
QHostAddress address;
+ QAbstractSocket::SocketType socketType;
QAbstractSocket::SocketState state;
QAbstractSocketEngine *socketEngine;
diff --git a/src/network/socket/qtcpsocket.h b/src/network/socket/qtcpsocket.h
index b2c89dcad2..3c3e3b69fd 100644
--- a/src/network/socket/qtcpsocket.h
+++ b/src/network/socket/qtcpsocket.h
@@ -40,6 +40,7 @@
#ifndef QTCPSOCKET_H
#define QTCPSOCKET_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtNetwork/qabstractsocket.h>
#include <QtCore/qvariant.h>
diff --git a/src/network/socket/qtcpsocket_p.h b/src/network/socket/qtcpsocket_p.h
index dfa55a6109..17c44b343c 100644
--- a/src/network/socket/qtcpsocket_p.h
+++ b/src/network/socket/qtcpsocket_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include <QtNetwork/qtcpsocket.h>
#include <private/qabstractsocket_p.h>
diff --git a/src/network/socket/qudpsocket.cpp b/src/network/socket/qudpsocket.cpp
index c406009069..37b385dfb5 100644
--- a/src/network/socket/qudpsocket.cpp
+++ b/src/network/socket/qudpsocket.cpp
@@ -55,10 +55,10 @@
datagrams.
The most common way to use this class is to bind to an address and port
- using bind(), then call writeDatagram() and readDatagram() to transfer
- data. If you want to use the standard QIODevice functions read(),
- readLine(), write(), etc., you must first connect the socket directly to a
- peer by calling connectToHost().
+ using bind(), then call writeDatagram() and readDatagram() /
+ receiveDatagram() to transfer data. If you want to use the standard
+ QIODevice functions read(), readLine(), write(), etc., you must first
+ connect the socket directly to a peer by calling connectToHost().
The socket emits the bytesWritten() signal every time a datagram
is written to the network. If you just want to send datagrams,
@@ -67,7 +67,7 @@
The readyRead() signal is emitted whenever datagrams arrive. In
that case, hasPendingDatagrams() returns \c true. Call
pendingDatagramSize() to obtain the size of the first pending
- datagram, and readDatagram() to read it.
+ datagram, and readDatagram() or receiveDatagram() to read it.
\note An incoming datagram should be read when you receive the readyRead()
signal, otherwise this signal will not be emitted for the next datagram.
@@ -94,11 +94,12 @@
\l{multicastreceiver}{Multicast Receiver} examples illustrate how
to use QUdpSocket in applications.
- \sa QTcpSocket
+ \sa QTcpSocket, QNetworkDatagram
*/
#include "qudpsocket.h"
#include "qhostaddress.h"
+#include "qnetworkdatagram.h"
#include "qnetworkinterface.h"
#include "qabstractsocket_p.h"
@@ -346,6 +347,12 @@ qint64 QUdpSocket::writeDatagram(const char *data, qint64 size, const QHostAddre
if (sent >= 0) {
emit bytesWritten(sent);
} else {
+ if (sent == -2) {
+ // Socket engine reports EAGAIN. Treat as a temporary error.
+ d->setErrorAndEmit(QAbstractSocket::TemporaryError,
+ tr("Unable to send a datagram"));
+ return -1;
+ }
d->setErrorAndEmit(d->socketEngine->error(), d->socketEngine->errorString());
}
return sent;
@@ -358,7 +365,101 @@ qint64 QUdpSocket::writeDatagram(const char *data, qint64 size, const QHostAddre
Sends the datagram \a datagram to the host address \a host and at
port \a port.
+
+ The function returns the number of bytes sent if it succeeded or -1 if it
+ encountered an error.
+*/
+
+/*!
+ \overload
+
+ Sends the datagram \a datagram to the host address and port numbers
+ contained in \a datagram, using the network interface and hop count limits
+ also set there. If the destination address and port numbers are unset, this
+ function will send to the address that was passed to connectToHost().
+
+ If the destination address is IPv6 with a non-empty
+ \l{QHostAddress::scopeId()}{scope id} but differs from the interface index
+ in \a datagram, it is undefined which interface the operating system will
+ choose to send on.
+
+ The function returns the number of bytes sent if it succeeded or -1 if it
+ encountered an error.
+
+ \warning Calling this function on a connected UDP socket may
+ result in an error and no packet being sent. If you are using a
+ connected socket, use write() to send datagrams.
+
+ \sa QNetworkDatagram::setDestination(), QNetworkDatagram::setHopLimit(), QNetworkDatagram::setInterfaceIndex()
+*/
+qint64 QUdpSocket::writeDatagram(const QNetworkDatagram &datagram)
+{
+ Q_D(QUdpSocket);
+#if defined QUDPSOCKET_DEBUG
+ qDebug("QUdpSocket::writeDatagram(%p, %i, \"%s\", %i)",
+ datagram.d->data.constData(),
+ datagram.d->data.size(),
+ datagram.destinationAddress().toString().toLatin1().constData(),
+ datagram.destinationPort());
+#endif
+ if (!d->doEnsureInitialized(QHostAddress::Any, 0, datagram.destinationAddress()))
+ return -1;
+ if (state() == UnconnectedState)
+ bind();
+
+ qint64 sent = d->socketEngine->writeDatagram(datagram.d->data,
+ datagram.d->data.size(),
+ datagram.d->header);
+ d->cachedSocketDescriptor = d->socketEngine->socketDescriptor();
+
+ if (sent >= 0) {
+ emit bytesWritten(sent);
+ } else {
+ d->setErrorAndEmit(d->socketEngine->error(), d->socketEngine->errorString());
+ }
+ return sent;
+}
+
+/*!
+ Receives a datagram no larger than \a maxSize bytes and returns it in the
+ QNetworkDatagram object, along with the sender's host address and port. If
+ possible, this function will also try to determine the datagram's
+ destination address, port, and the number of hop counts at reception time.
+
+ On failure, returns a QNetworkDatagram that reports \l
+ {QNetworkDatagram::isValid()}{not valid}.
+
+ If \a maxSize is too small, the rest of the datagram will be lost. If \a
+ maxSize is 0, the datagram will be discarded. If \a maxSize is -1 (the
+ default), this function will attempt to read the entire datagram.
+
+ \sa writeDatagram(), hasPendingDatagrams(), pendingDatagramSize()
*/
+QNetworkDatagram QUdpSocket::receiveDatagram(qint64 maxSize)
+{
+ Q_D(QUdpSocket);
+
+#if defined QUDPSOCKET_DEBUG
+ qDebug("QUdpSocket::receiveDatagram(%lld)", maxSize);
+#endif
+ QT_CHECK_BOUND("QUdpSocket::receiveDatagram()", QNetworkDatagram());
+
+ if (maxSize < 0)
+ maxSize = d->socketEngine->pendingDatagramSize();
+ if (maxSize < 0)
+ return QNetworkDatagram();
+
+ QNetworkDatagram result(QByteArray(maxSize, Qt::Uninitialized));
+ qint64 readBytes = d->socketEngine->readDatagram(result.d->data.data(), maxSize, &result.d->header,
+ QAbstractSocketEngine::WantAll);
+ d->hasPendingData = false;
+ d->socketEngine->setReadNotificationEnabled(true);
+ if (readBytes < 0)
+ d->setErrorAndEmit(d->socketEngine->error(), d->socketEngine->errorString());
+ else if (readBytes != result.d->data.size())
+ result.d->data.truncate(readBytes);
+ return result;
+}
/*!
Receives a datagram no larger than \a maxSize bytes and stores
@@ -398,11 +499,20 @@ qint64 QUdpSocket::readDatagram(char *data, qint64 maxSize, QHostAddress *addres
readBytes = d->socketEngine->readDatagram(data, maxSize);
}
- d_func()->socketEngine->setReadNotificationEnabled(true);
- if (readBytes < 0)
+ d->hasPendingData = false;
+ d->socketEngine->setReadNotificationEnabled(true);
+ if (readBytes < 0) {
+ if (readBytes == -2) {
+ // No pending datagram. Treat as a temporary error.
+ d->setErrorAndEmit(QAbstractSocket::TemporaryError,
+ tr("No datagram available for reading"));
+ return -1;
+ }
d->setErrorAndEmit(d->socketEngine->error(), d->socketEngine->errorString());
+ }
return readBytes;
}
+
#endif // QT_NO_UDPSOCKET
QT_END_NAMESPACE
diff --git a/src/network/socket/qudpsocket.h b/src/network/socket/qudpsocket.h
index cf2f05c86d..6ef10e2edb 100644
--- a/src/network/socket/qudpsocket.h
+++ b/src/network/socket/qudpsocket.h
@@ -40,6 +40,7 @@
#ifndef QUDPSOCKET_H
#define QUDPSOCKET_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtNetwork/qabstractsocket.h>
#include <QtNetwork/qhostaddress.h>
@@ -48,6 +49,7 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_UDPSOCKET
+class QNetworkDatagram;
class QNetworkInterface;
class QUdpSocketPrivate;
@@ -72,7 +74,10 @@ public:
bool hasPendingDatagrams() const;
qint64 pendingDatagramSize() const;
+ QNetworkDatagram receiveDatagram(qint64 maxSize = -1);
qint64 readDatagram(char *data, qint64 maxlen, QHostAddress *host = Q_NULLPTR, quint16 *port = Q_NULLPTR);
+
+ qint64 writeDatagram(const QNetworkDatagram &datagram);
qint64 writeDatagram(const char *data, qint64 len, const QHostAddress &host, quint16 port);
inline qint64 writeDatagram(const QByteArray &datagram, const QHostAddress &host, quint16 port)
{ return writeDatagram(datagram.constData(), datagram.size(), host, port); }
diff --git a/src/network/socket/socket.pri b/src/network/socket/socket.pri
index f50a7b1229..b1c0b6bd6e 100644
--- a/src/network/socket/socket.pri
+++ b/src/network/socket/socket.pri
@@ -25,6 +25,18 @@ SOURCES += socket/qabstractsocketengine.cpp \
socket/qlocalsocket.cpp \
socket/qlocalserver.cpp
+# SCTP support.
+
+contains(QT_CONFIG, sctp) {
+ HEADERS += socket/qsctpserver.h \
+ socket/qsctpserver_p.h \
+ socket/qsctpsocket.h \
+ socket/qsctpsocket_p.h
+
+ SOURCES += socket/qsctpserver.cpp \
+ socket/qsctpsocket.cpp
+}
+
!winrt {
SOURCES += socket/qnativesocketengine.cpp
HEADERS += socket/qnativesocketengine_p.h
@@ -39,11 +51,15 @@ unix: {
unix:HEADERS += \
socket/qnet_unix_p.h
+# Suppress deprecation warnings with moc because MS headers have
+# invalid C/C++ code otherwise.
+msvc: QMAKE_MOC_OPTIONS += -D_WINSOCK_DEPRECATED_NO_WARNINGS
+
win32:!winrt:SOURCES += socket/qnativesocketengine_win.cpp \
socket/qlocalsocket_win.cpp \
socket/qlocalserver_win.cpp
-win32:!wince:!winrt:LIBS_PRIVATE += -ladvapi32
+win32:!winrt:LIBS_PRIVATE += -ladvapi32
winrt {
SOURCES += socket/qnativesocketengine_winrt.cpp \
@@ -54,15 +70,6 @@ winrt {
DEFINES += QT_LOCALSOCKET_TCP
}
-wince {
- SOURCES -= socket/qlocalsocket_win.cpp \
- socket/qlocalserver_win.cpp
- SOURCES += socket/qlocalsocket_tcp.cpp \
- socket/qlocalserver_tcp.cpp
-
- DEFINES += QT_LOCALSOCKET_TCP
-}
-
integrity: {
SOURCES -= socket/qlocalsocket_unix.cpp \
socket/qlocalserver_unix.cpp
diff --git a/src/network/ssl/qasn1element_p.h b/src/network/ssl/qasn1element_p.h
index c636351bf9..f532cec530 100644
--- a/src/network/ssl/qasn1element_p.h
+++ b/src/network/ssl/qasn1element_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qmap.h>
diff --git a/src/network/ssl/qssl.h b/src/network/ssl/qssl.h
index 7742844246..c2a468c97c 100644
--- a/src/network/ssl/qssl.h
+++ b/src/network/ssl/qssl.h
@@ -41,7 +41,7 @@
#ifndef QSSL_H
#define QSSL_H
-#include <QtCore/qglobal.h>
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/QFlags>
QT_BEGIN_NAMESPACE
diff --git a/src/network/ssl/qssl_p.h b/src/network/ssl/qssl_p.h
index 85eb59ae35..83ccdc7fc3 100644
--- a/src/network/ssl/qssl_p.h
+++ b/src/network/ssl/qssl_p.h
@@ -53,6 +53,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include <QtCore/QLoggingCategory>
QT_BEGIN_NAMESPACE
diff --git a/src/network/ssl/qsslcertificate.h b/src/network/ssl/qsslcertificate.h
index 814c6a701d..8b051a5c88 100644
--- a/src/network/ssl/qsslcertificate.h
+++ b/src/network/ssl/qsslcertificate.h
@@ -45,6 +45,7 @@
#undef verify
#endif
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qnamespace.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qcryptographichash.h>
diff --git a/src/network/ssl/qsslcertificate_p.h b/src/network/ssl/qsslcertificate_p.h
index 8b83f754e4..616b5aec6d 100644
--- a/src/network/ssl/qsslcertificate_p.h
+++ b/src/network/ssl/qsslcertificate_p.h
@@ -41,6 +41,7 @@
#ifndef QSSLCERTIFICATE_OPENSSL_P_H
#define QSSLCERTIFICATE_OPENSSL_P_H
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qsslcertificate.h"
//
diff --git a/src/network/ssl/qsslcertificateextension.h b/src/network/ssl/qsslcertificateextension.h
index 795dd0ce80..2ce2112687 100644
--- a/src/network/ssl/qsslcertificateextension.h
+++ b/src/network/ssl/qsslcertificateextension.h
@@ -40,6 +40,7 @@
#ifndef QSSLCERTIFICATEEXTENSION_H
#define QSSLCERTIFICATEEXTENSION_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qnamespace.h>
#include <QtCore/qshareddata.h>
#include <QtCore/qstring.h>
diff --git a/src/network/ssl/qsslcertificateextension_p.h b/src/network/ssl/qsslcertificateextension_p.h
index a7ff53d4a3..373f92a5cf 100644
--- a/src/network/ssl/qsslcertificateextension_p.h
+++ b/src/network/ssl/qsslcertificateextension_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qsslcertificateextension.h"
QT_BEGIN_NAMESPACE
diff --git a/src/network/ssl/qsslcipher.h b/src/network/ssl/qsslcipher.h
index 8bb404ffa7..c6328e0169 100644
--- a/src/network/ssl/qsslcipher.h
+++ b/src/network/ssl/qsslcipher.h
@@ -41,6 +41,7 @@
#ifndef QSSLCIPHER_H
#define QSSLCIPHER_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qstring.h>
#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qssl.h>
diff --git a/src/network/ssl/qsslcipher_p.h b/src/network/ssl/qsslcipher_p.h
index 1714617361..b8629f9f96 100644
--- a/src/network/ssl/qsslcipher_p.h
+++ b/src/network/ssl/qsslcipher_p.h
@@ -40,6 +40,7 @@
#ifndef QSSLCIPHER_P_H
#define QSSLCIPHER_P_H
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qsslcipher.h"
QT_BEGIN_NAMESPACE
diff --git a/src/network/ssl/qsslconfiguration.cpp b/src/network/ssl/qsslconfiguration.cpp
index c8040dec7f..75a880f115 100644
--- a/src/network/ssl/qsslconfiguration.cpp
+++ b/src/network/ssl/qsslconfiguration.cpp
@@ -53,6 +53,7 @@ const QSsl::SslOptions QSslConfigurationPrivate::defaultSslOptions = QSsl::SslOp
|QSsl::SslOptionDisableCompression
|QSsl::SslOptionDisableSessionPersistence;
+const char QSslConfiguration::ALPNProtocolHTTP2[] = "h2";
const char QSslConfiguration::NextProtocolSpdy3_0[] = "spdy/3";
const char QSslConfiguration::NextProtocolHttp1_1[] = "http/1.1";
@@ -119,7 +120,8 @@ const char QSslConfiguration::NextProtocolHttp1_1[] = "http/1.1";
/*!
\enum QSslConfiguration::NextProtocolNegotiationStatus
- Describes the status of the Next Protocol Negotiation (NPN).
+ Describes the status of the Next Protocol Negotiation (NPN) or
+ Application-Layer Protocol Negotiation (ALPN).
\value NextProtocolNegotiationNone No application protocol
has been negotiated (yet).
@@ -209,9 +211,11 @@ bool QSslConfiguration::operator==(const QSslConfiguration &other) const
d->privateKey == other.d->privateKey &&
d->sessionCipher == other.d->sessionCipher &&
d->sessionProtocol == other.d->sessionProtocol &&
+ d->preSharedKeyIdentityHint == other.d->preSharedKeyIdentityHint &&
d->ciphers == other.d->ciphers &&
d->ellipticCurves == other.d->ellipticCurves &&
d->ephemeralServerKey == other.d->ephemeralServerKey &&
+ d->dhParams == other.d->dhParams &&
d->caCertificates == other.d->caCertificates &&
d->protocol == other.d->protocol &&
d->peerVerifyMode == other.d->peerVerifyMode &&
@@ -254,6 +258,7 @@ bool QSslConfiguration::isNull() const
d->ciphers.count() == 0 &&
d->ellipticCurves.isEmpty() &&
d->ephemeralServerKey.isNull() &&
+ d->dhParams == QSslDiffieHellmanParameters::defaultParameters() &&
d->localCertificateChain.isEmpty() &&
d->privateKey.isNull() &&
d->peerCertificate.isNull() &&
@@ -261,6 +266,7 @@ bool QSslConfiguration::isNull() const
d->sslOptions == QSslConfigurationPrivate::defaultSslOptions &&
d->sslSession.isNull() &&
d->sslSessionTicketLifeTimeHint == -1 &&
+ d->preSharedKeyIdentityHint.isNull() &&
d->nextAllowedProtocols.isEmpty() &&
d->nextNegotiatedProtocol.isNull() &&
d->nextProtocolNegotiationStatus == QSslConfiguration::NextProtocolNegotiationNone);
@@ -811,11 +817,65 @@ QVector<QSslEllipticCurve> QSslConfiguration::supportedEllipticCurves()
}
/*!
+ \since 5.8
+
+ Returns the identity hint.
+
+ \sa setPreSharedKeyIdentityHint()
+*/
+QByteArray QSslConfiguration::preSharedKeyIdentityHint() const
+{
+ return d->preSharedKeyIdentityHint;
+}
+
+/*!
+ \since 5.8
+
+ Sets the identity hint for a preshared key authentication to \a hint. This will
+ affect the next initiated handshake; calling this function on an already-encrypted
+ socket will not affect the socket's identity hint.
+
+ The identity hint is used in QSslSocket::SslServerMode only!
+*/
+void QSslConfiguration::setPreSharedKeyIdentityHint(const QByteArray &hint)
+{
+ d->preSharedKeyIdentityHint = hint;
+}
+
+/*!
+ \since 5.8
+
+ Retrieves the current set of Diffie-Hellman parameters.
+
+ If no Diffie-Hellman parameters have been set, the QSslConfiguration object
+ defaults to using the 1024-bit MODP group from RFC 2409.
+ */
+QSslDiffieHellmanParameters QSslConfiguration::diffieHellmanParameters() const
+{
+ return d->dhParams;
+}
+
+/*!
+ \since 5.8
+
+ Sets a custom set of Diffie-Hellman parameters to be used by this socket when functioning as
+ a server to \a dhparams.
+
+ If no Diffie-Hellman parameters have been set, the QSslConfiguration object
+ defaults to using the 1024-bit MODP group from RFC 2409.
+ */
+void QSslConfiguration::setDiffieHellmanParameters(const QSslDiffieHellmanParameters &dhparams)
+{
+ d->dhParams = dhparams;
+}
+
+/*!
\since 5.3
This function returns the protocol negotiated with the server
- if the Next Protocol Negotiation (NPN) TLS extension was enabled.
- In order for the NPN extension to be enabled, setAllowedNextProtocols()
+ if the Next Protocol Negotiation (NPN) or Application-Layer Protocol
+ Negotiation (ALPN) TLS extension was enabled.
+ In order for the NPN/ALPN extension to be enabled, setAllowedNextProtocols()
needs to be called explicitly before connecting to the server.
If no protocol could be negotiated or the extension was not enabled,
@@ -832,9 +892,10 @@ QByteArray QSslConfiguration::nextNegotiatedProtocol() const
\since 5.3
This function sets the allowed \a protocols to be negotiated with the
- server through the Next Protocol Negotiation (NPN) TLS extension; each
+ server through the Next Protocol Negotiation (NPN) or Application-Layer
+ Protocol Negotiation (ALPN) TLS extension; each
element in \a protocols must define one allowed protocol.
- The function must be called explicitly before connecting to send the NPN
+ The function must be called explicitly before connecting to send the NPN/ALPN
extension in the SSL handshake.
Whether or not the negotiation succeeded can be queried through
nextProtocolNegotiationStatus().
@@ -854,8 +915,8 @@ void QSslConfiguration::setAllowedNextProtocols(QList<QByteArray> protocols)
\since 5.3
This function returns the allowed protocols to be negotiated with the
- server through the Next Protocol Negotiation (NPN) TLS extension, as set
- by setAllowedNextProtocols().
+ server through the Next Protocol Negotiation (NPN) or Application-Layer
+ Protocol Negotiation (ALPN) TLS extension, as set by setAllowedNextProtocols().
\sa nextNegotiatedProtocol(), nextProtocolNegotiationStatus(), setAllowedNextProtocols(), QSslConfiguration::NextProtocolSpdy3_0, QSslConfiguration::NextProtocolHttp1_1
*/
@@ -867,7 +928,8 @@ QList<QByteArray> QSslConfiguration::allowedNextProtocols() const
/*!
\since 5.3
- This function returns the status of the Next Protocol Negotiation (NPN).
+ This function returns the status of the Next Protocol Negotiation (NPN)
+ or Application-Layer Protocol Negotiation (ALPN).
If the feature has not been enabled through setAllowedNextProtocols(),
this function returns NextProtocolNegotiationNone.
The status will be set before emitting the encrypted() signal.
diff --git a/src/network/ssl/qsslconfiguration.h b/src/network/ssl/qsslconfiguration.h
index f0754d7ef5..1c57bebd65 100644
--- a/src/network/ssl/qsslconfiguration.h
+++ b/src/network/ssl/qsslconfiguration.h
@@ -56,6 +56,7 @@
#ifndef QSSLCONFIGURATION_H
#define QSSLCONFIGURATION_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qshareddata.h>
#include <QtNetwork/qsslsocket.h>
#include <QtNetwork/qssl.h>
@@ -69,6 +70,7 @@ class QSslCertificate;
class QSslCipher;
class QSslKey;
class QSslEllipticCurve;
+class QSslDiffieHellmanParameters;
class QSslConfigurationPrivate;
class Q_NETWORK_EXPORT QSslConfiguration
@@ -141,6 +143,12 @@ public:
void setEllipticCurves(const QVector<QSslEllipticCurve> &curves);
static QVector<QSslEllipticCurve> supportedEllipticCurves();
+ QByteArray preSharedKeyIdentityHint() const;
+ void setPreSharedKeyIdentityHint(const QByteArray &hint);
+
+ QSslDiffieHellmanParameters diffieHellmanParameters() const;
+ void setDiffieHellmanParameters(const QSslDiffieHellmanParameters &dhparams);
+
static QSslConfiguration defaultConfiguration();
static void setDefaultConfiguration(const QSslConfiguration &configuration);
@@ -160,6 +168,7 @@ public:
QByteArray nextNegotiatedProtocol() const;
NextProtocolNegotiationStatus nextProtocolNegotiationStatus() const;
+ static const char ALPNProtocolHTTP2[];
static const char NextProtocolSpdy3_0[];
static const char NextProtocolHttp1_1[];
diff --git a/src/network/ssl/qsslconfiguration_p.h b/src/network/ssl/qsslconfiguration_p.h
index 364bba92ec..6adf2c9b54 100644
--- a/src/network/ssl/qsslconfiguration_p.h
+++ b/src/network/ssl/qsslconfiguration_p.h
@@ -67,12 +67,14 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qsslconfiguration.h"
#include "qlist.h"
#include "qsslcertificate.h"
#include "qsslcipher.h"
#include "qsslkey.h"
#include "qsslellipticcurve.h"
+#include "qssldiffiehellmanparameters.h"
QT_BEGIN_NAMESPACE
@@ -87,8 +89,10 @@ public:
allowRootCertOnDemandLoading(true),
peerSessionShared(false),
sslOptions(QSslConfigurationPrivate::defaultSslOptions),
+ dhParams(QSslDiffieHellmanParameters::defaultParameters()),
sslSessionTicketLifeTimeHint(-1),
ephemeralServerKey(),
+ preSharedKeyIdentityHint(),
nextProtocolNegotiationStatus(QSslConfiguration::NextProtocolNegotiationNone)
{ }
@@ -117,11 +121,15 @@ public:
QVector<QSslEllipticCurve> ellipticCurves;
+ QSslDiffieHellmanParameters dhParams;
+
QByteArray sslSession;
int sslSessionTicketLifeTimeHint;
QSslKey ephemeralServerKey;
+ QByteArray preSharedKeyIdentityHint;
+
QList<QByteArray> nextAllowedProtocols;
QByteArray nextNegotiatedProtocol;
QSslConfiguration::NextProtocolNegotiationStatus nextProtocolNegotiationStatus;
diff --git a/src/network/ssl/qsslcontext_openssl.cpp b/src/network/ssl/qsslcontext_openssl.cpp
index f132d0228c..c92d8fc3f8 100644
--- a/src/network/ssl/qsslcontext_openssl.cpp
+++ b/src/network/ssl/qsslcontext_openssl.cpp
@@ -41,6 +41,7 @@
#include <QtNetwork/qsslsocket.h>
+#include <QtNetwork/qssldiffiehellmanparameters.h>
#include <QtCore/qmutex.h>
#include "private/qssl_p.h"
@@ -48,6 +49,7 @@
#include "private/qsslsocket_p.h"
#include "private/qsslsocket_openssl_p.h"
#include "private/qsslsocket_openssl_symbols_p.h"
+#include "private/qssldiffiehellmanparameters_p.h"
QT_BEGIN_NAMESPACE
@@ -55,22 +57,6 @@ QT_BEGIN_NAMESPACE
extern int q_X509Callback(int ok, X509_STORE_CTX *ctx);
extern QString getErrorsFromOpenSsl();
-static DH *get_dh1024()
-{
- // Default DH params
- // 1024-bit MODP Group
- // From RFC 2409
- QByteArray params = QByteArray::fromBase64(
- QByteArrayLiteral("MIGHAoGBAP//////////yQ/aoiFowjTExmKLgNwc0SkCTgiKZ8x0Agu+pjsTmyJR" \
- "Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL" \
- "/1y29Aa37e44a/taiZ+lrp8kEXxLH+ZJKGZR7OZTgf//////////AgEC"));
-
- const char *ptr = params.constData();
- DH *dh = q_d2i_DHparams(NULL, reinterpret_cast<const unsigned char **>(&ptr), params.length());
-
- return dh;
-}
-
QSslContext::QSslContext()
: ctx(0),
pkey(0),
@@ -325,10 +311,23 @@ init_context:
sslContext->setSessionASN1(configuration.sessionTicket());
// Set temp DH params
- DH *dh = 0;
- dh = get_dh1024();
- q_SSL_CTX_set_tmp_dh(sslContext->ctx, dh);
- q_DH_free(dh);
+ QSslDiffieHellmanParameters dhparams = configuration.diffieHellmanParameters();
+
+ if (!dhparams.isValid()) {
+ sslContext->errorStr = QSslSocket::tr("Diffie-Hellman parameters are not valid");
+ sslContext->errorCode = QSslError::UnspecifiedError;
+ return;
+ }
+
+ if (!dhparams.isEmpty()) {
+ const QByteArray &params = dhparams.d->derData;
+ const char *ptr = params.constData();
+ DH *dh = q_d2i_DHparams(NULL, reinterpret_cast<const unsigned char **>(&ptr), params.length());
+ if (dh == NULL)
+ qFatal("q_d2i_DHparams failed to convert QSslDiffieHellmanParameters to DER form");
+ q_SSL_CTX_set_tmp_dh(sslContext->ctx, dh);
+ q_DH_free(dh);
+ }
#ifndef OPENSSL_NO_EC
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
@@ -345,6 +344,11 @@ init_context:
}
#endif // OPENSSL_NO_EC
+#if OPENSSL_VERSION_NUMBER >= 0x10001000L && !defined(OPENSSL_NO_PSK)
+ if (!client)
+ q_SSL_CTX_use_psk_identity_hint(sslContext->ctx, sslContext->sslConfiguration.preSharedKeyIdentityHint().constData());
+#endif // OPENSSL_VERSION_NUMBER >= 0x10001000L && !defined(OPENSSL_NO_PSK)
+
const QVector<QSslEllipticCurve> qcurves = sslContext->sslConfiguration.ellipticCurves();
if (!qcurves.isEmpty()) {
#if OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(OPENSSL_NO_EC)
@@ -458,6 +462,23 @@ SSL* QSslContext::createSsl()
m_npnContext.data = reinterpret_cast<unsigned char *>(m_supportedNPNVersions.data());
m_npnContext.len = m_supportedNPNVersions.count();
m_npnContext.status = QSslConfiguration::NextProtocolNegotiationNone;
+#if OPENSSL_VERSION_NUMBER >= 0x10002000L
+ if (q_SSLeay() >= 0x10002000L) {
+ // Callback's type has a parameter 'const unsigned char ** out'
+ // since it was introduced in 1.0.2. Internally, OpenSSL's own code
+ // (tests/examples) cast it to unsigned char * (since it's 'out').
+ // We just re-use our NPN callback and cast here:
+ typedef int (*alpn_callback_t) (SSL *, const unsigned char **, unsigned char *,
+ const unsigned char *, unsigned int, void *);
+ // With ALPN callback is for a server side only, for a client m_npnContext.status
+ // will stay in NextProtocolNegotiationNone.
+ q_SSL_CTX_set_alpn_select_cb(ctx, alpn_callback_t(next_proto_cb), &m_npnContext);
+ // Client:
+ q_SSL_set_alpn_protos(ssl, m_npnContext.data, m_npnContext.len);
+ }
+#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L ...
+
+ // And in case our peer does not support ALPN, but supports NPN:
q_SSL_CTX_set_next_proto_select_cb(ctx, next_proto_cb, &m_npnContext);
}
#endif // OPENSSL_VERSION_NUMBER >= 0x1000100fL ...
diff --git a/src/network/ssl/qsslcontext_openssl_p.h b/src/network/ssl/qsslcontext_openssl_p.h
index ef4dc6f815..06a31af5e5 100644
--- a/src/network/ssl/qsslcontext_openssl_p.h
+++ b/src/network/ssl/qsslcontext_openssl_p.h
@@ -53,6 +53,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include <QtCore/qvariant.h>
#include <QtNetwork/qsslcertificate.h>
#include <QtNetwork/qsslconfiguration.h>
diff --git a/src/network/ssl/qssldiffiehellmanparameters.cpp b/src/network/ssl/qssldiffiehellmanparameters.cpp
new file mode 100644
index 0000000000..d0fcb3189a
--- /dev/null
+++ b/src/network/ssl/qssldiffiehellmanparameters.cpp
@@ -0,0 +1,324 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Mikkel Krautz <mikkel@krautz.dk>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+/*!
+ \class QSslDiffieHellmanParameters
+ \brief The QSslDiffieHellmanParameters class provides an interface for Diffie-Hellman parameters for servers.
+ \since 5.8
+
+ \reentrant
+ \ingroup network
+ \ingroup ssl
+ \ingroup shared
+ \inmodule QtNetwork
+
+ QSslDiffieHellmanParameters provides an interface for setting Diffie-Hellman parameters to servers based on QSslSocket.
+
+ \sa QSslSocket, QSslCipher, QSslConfiguration
+*/
+
+#include "qssldiffiehellmanparameters.h"
+#include "qssldiffiehellmanparameters_p.h"
+#include "qsslsocket.h"
+#include "qsslsocket_p.h"
+
+#include <QtCore/qcoreapplication.h>
+#include <QtCore/qatomic.h>
+#include <QtCore/qbytearray.h>
+#include <QtCore/qbytearraymatcher.h>
+#include <QtCore/qiodevice.h>
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ Returns the default QSslDiffieHellmanParameters used by QSslSocket.
+
+ This is currently the 1024-bit MODP group from RFC 2459, also
+ known as the Second Oakley Group.
+*/
+QSslDiffieHellmanParameters QSslDiffieHellmanParameters::defaultParameters()
+{
+ // The 1024-bit MODP group from RFC 2459 (Second Oakley Group)
+ return fromEncoded(
+ QByteArray::fromBase64(QByteArrayLiteral(
+ "MIGHAoGBAP//////////yQ/aoiFowjTExmKLgNwc0SkCTgiKZ8x0Agu+pjsTmyJR"
+ "Sgh5jjQE3e+VGbPNOkMbMCsKbfJfFDdP4TVtbVHCReSFtXZiXn7G9ExC6aY37WsL"
+ "/1y29Aa37e44a/taiZ+lrp8kEXxLH+ZJKGZR7OZTgf//////////AgEC"
+ )),
+ QSsl::Der
+ );
+}
+
+/*!
+ Constructs an empty QSslDiffieHellmanParameters instance.
+
+ If an empty QSslDiffieHellmanParameters instance is set on a
+ QSslConfiguration object, Diffie-Hellman negotiation will
+ be disabled.
+
+ \sa isValid()
+ \sa QSslConfiguration
+*/
+QSslDiffieHellmanParameters::QSslDiffieHellmanParameters()
+ : d(new QSslDiffieHellmanParametersPrivate)
+{
+ d->ref.ref();
+}
+
+/*!
+ Constructs a QSslDiffieHellmanParameters object using
+ the byte array \a encoded in either PEM or DER form as specified by \a encoding.
+
+ Use the isValid() method on the returned object to
+ check whether the Diffie-Hellman parameters were valid and
+ loaded correctly.
+
+ \sa isValid()
+ \sa QSslConfiguration
+*/
+QSslDiffieHellmanParameters QSslDiffieHellmanParameters::fromEncoded(const QByteArray &encoded, QSsl::EncodingFormat encoding)
+{
+ QSslDiffieHellmanParameters result;
+ switch (encoding) {
+ case QSsl::Der:
+ result.d->decodeDer(encoded);
+ break;
+ case QSsl::Pem:
+ result.d->decodePem(encoded);
+ break;
+ }
+ return result;
+}
+
+/*!
+ Constructs a QSslDiffieHellmanParameters object by
+ reading from \a device in either PEM or DER form as specified by \a encoding.
+
+ Use the isValid() method on the returned object
+ to check whether the Diffie-Hellman parameters were valid
+ and loaded correctly.
+
+ In particular, if \a device is \c nullptr or not open for reading, an invalid
+ object will be returned.
+
+ \sa isValid()
+ \sa QSslConfiguration
+*/
+QSslDiffieHellmanParameters QSslDiffieHellmanParameters::fromEncoded(QIODevice *device, QSsl::EncodingFormat encoding)
+{
+ if (device)
+ return fromEncoded(device->readAll(), encoding);
+ else
+ return QSslDiffieHellmanParameters();
+}
+
+/*!
+ Constructs an identical copy of \a other.
+*/
+QSslDiffieHellmanParameters::QSslDiffieHellmanParameters(const QSslDiffieHellmanParameters &other)
+ : d(other.d)
+{
+ if (d)
+ d->ref.ref();
+}
+
+/*!
+ \fn QSslDiffieHellmanParameters(QSslDiffieHellmanParameters &&other)
+
+ Move-constructs from \a other.
+
+ \note The moved-from object \a other is placed in a partially-formed state, in which
+ the only valid operations are destruction and assignment of a new value.
+*/
+
+/*!
+ Destroys the QSslDiffieHellmanParameters object.
+*/
+QSslDiffieHellmanParameters::~QSslDiffieHellmanParameters()
+{
+ if (d && !d->ref.deref())
+ delete d;
+}
+
+/*!
+ Copies the contents of \a other into this QSslDiffieHellmanParameters, making the two QSslDiffieHellmanParameters
+ identical.
+
+ Returns a reference to this QSslDiffieHellmanParameters.
+*/
+QSslDiffieHellmanParameters &QSslDiffieHellmanParameters::operator=(const QSslDiffieHellmanParameters &other)
+{
+ QSslDiffieHellmanParameters copy(other);
+ swap(copy);
+ return *this;
+}
+
+/*!
+ \fn QSslDiffieHellmanParameters &QSslDiffieHellmanParameters::operator=(QSslDiffieHellmanParameters &&other)
+
+ Move-assigns \a other to this QSslDiffieHellmanParameters instance.
+
+ \note The moved-from object \a other is placed in a partially-formed state, in which
+ the only valid operations are destruction and assignment of a new value.
+*/
+
+/*!
+ \fn void QSslDiffieHellmanParameters::swap(QSslDiffieHellmanParameters &other)
+
+ Swaps this QSslDiffieHellmanParameters with \a other. This function is very fast and
+ never fails.
+*/
+
+/*!
+ Returns \c true if this is a an empty QSslDiffieHellmanParameters instance.
+
+ Setting an empty QSslDiffieHellmanParameters instance on a QSslSocket-based
+ server will disable Diffie-Hellman key exchange.
+*/
+bool QSslDiffieHellmanParameters::isEmpty() const Q_DECL_NOTHROW
+{
+ return d->derData.isNull() && d->error == QSslDiffieHellmanParameters::NoError;
+}
+
+/*!
+ Returns \c true if this is a valid QSslDiffieHellmanParameters; otherwise false.
+
+ This method should be used after constructing a QSslDiffieHellmanParameters
+ object to determine its validity.
+
+ If a QSslDiffieHellmanParameters object is not valid, you can use the error()
+ method to determine what error prevented the object from being constructed.
+
+ \sa error()
+*/
+bool QSslDiffieHellmanParameters::isValid() const Q_DECL_NOTHROW
+{
+ return d->error == QSslDiffieHellmanParameters::NoError;
+}
+
+/*!
+ \enum QSslDiffieHellmanParameters::Error
+
+ Describes a QSslDiffieHellmanParameters error.
+
+ \value NoError No error occurred.
+
+ \value InvalidInputDataError The given input data could not be used to
+ construct a QSslDiffieHellmanParameters
+ object.
+
+ \value UnsafeParametersError The Diffie-Hellman parameters are unsafe
+ and should not be used.
+*/
+
+/*!
+ Returns the error that caused the QSslDiffieHellmanParameters object
+ to be invalid.
+*/
+QSslDiffieHellmanParameters::Error QSslDiffieHellmanParameters::error() const Q_DECL_NOTHROW
+{
+ return d->error;
+}
+
+/*!
+ Returns a human-readable description of the error that caused the
+ QSslDiffieHellmanParameters object to be invalid.
+*/
+QString QSslDiffieHellmanParameters::errorString() const Q_DECL_NOTHROW
+{
+ switch (d->error) {
+ case QSslDiffieHellmanParameters::NoError:
+ return QCoreApplication::translate("QSslDiffieHellmanParameter", "No error");
+ case QSslDiffieHellmanParameters::InvalidInputDataError:
+ return QCoreApplication::translate("QSslDiffieHellmanParameter", "Invalid input data");
+ case QSslDiffieHellmanParameters::UnsafeParametersError:
+ return QCoreApplication::translate("QSslDiffieHellmanParameter", "The given Diffie-Hellman parameters are deemed unsafe");
+ }
+
+ Q_UNREACHABLE();
+ return QString();
+}
+
+/*!
+ \since 5.8
+ \relates QSslDiffieHellmanParameters
+
+ Returns \c true if \a lhs is equal to \a rhs; otherwise returns \c false.
+*/
+bool operator==(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) Q_DECL_NOTHROW
+{
+ return lhs.d->derData == rhs.d->derData;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+/*!
+ \since 5.8
+ \relates QSslDiffieHellmanParameters
+
+ Writes the set of Diffie-Hellman parameters in \a dhparam into the debug object \a debug for
+ debugging purposes.
+
+ The Diffie-Hellman parameters will be represented in Base64-encoded DER form.
+
+ \sa {Debugging Techniques}
+*/
+QDebug operator<<(QDebug debug, const QSslDiffieHellmanParameters &dhparam)
+{
+ QDebugStateSaver saver(debug);
+ debug.resetFormat().nospace();
+ debug << "QSslDiffieHellmanParameters(" << dhparam.d->derData.toBase64() << ')';
+ return debug;
+}
+#endif
+
+/*!
+ \since 5.8
+ \relates QSslDiffieHellmanParameters
+
+ Returns an hash value for \a dhparam, using \a seed to seed
+ the calculation.
+*/
+uint qHash(const QSslDiffieHellmanParameters &dhparam, uint seed) Q_DECL_NOTHROW
+{
+ return qHash(dhparam.d->derData, seed);
+}
+
+QT_END_NAMESPACE
diff --git a/src/network/ssl/qssldiffiehellmanparameters.h b/src/network/ssl/qssldiffiehellmanparameters.h
new file mode 100644
index 0000000000..4533ea4ed2
--- /dev/null
+++ b/src/network/ssl/qssldiffiehellmanparameters.h
@@ -0,0 +1,118 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Mikkel Krautz <mikkel@krautz.dk>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QSSLDIFFIEHELLMANPARAMETERS_H
+#define QSSLDIFFIEHELLMANPARAMETERS_H
+
+#include <QtNetwork/qssl.h>
+#include <QtCore/qnamespace.h>
+#include <QtCore/qbytearray.h>
+#include <QtCore/qshareddata.h>
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_SSL
+
+class QIODevice;
+class QSslContext;
+class QSslDiffieHellmanParametersPrivate;
+
+class QSslDiffieHellmanParameters;
+// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4)
+Q_NETWORK_EXPORT uint qHash(const QSslDiffieHellmanParameters &dhparam, uint seed = 0) Q_DECL_NOTHROW;
+
+#ifndef QT_NO_DEBUG_STREAM
+class QDebug;
+Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslDiffieHellmanParameters &dhparams);
+#endif
+
+Q_NETWORK_EXPORT bool operator==(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) Q_DECL_NOTHROW;
+
+inline bool operator!=(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) Q_DECL_NOTHROW
+{
+ return !operator==(lhs, rhs);
+}
+
+class QSslDiffieHellmanParameters
+{
+public:
+ enum Error {
+ NoError,
+ InvalidInputDataError,
+ UnsafeParametersError
+ };
+
+ Q_NETWORK_EXPORT static QSslDiffieHellmanParameters defaultParameters();
+
+ Q_NETWORK_EXPORT QSslDiffieHellmanParameters();
+ Q_NETWORK_EXPORT QSslDiffieHellmanParameters(const QSslDiffieHellmanParameters &other);
+ QSslDiffieHellmanParameters(QSslDiffieHellmanParameters &&other) Q_DECL_NOTHROW : d(other.d) { other.d = nullptr; }
+ Q_NETWORK_EXPORT ~QSslDiffieHellmanParameters();
+
+ Q_NETWORK_EXPORT QSslDiffieHellmanParameters &operator=(const QSslDiffieHellmanParameters &other);
+ QSslDiffieHellmanParameters &operator=(QSslDiffieHellmanParameters &&other) Q_DECL_NOTHROW { swap(other); return *this; }
+
+ void swap(QSslDiffieHellmanParameters &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
+
+ Q_NETWORK_EXPORT static QSslDiffieHellmanParameters fromEncoded(const QByteArray &encoded, QSsl::EncodingFormat format = QSsl::Pem);
+ Q_NETWORK_EXPORT static QSslDiffieHellmanParameters fromEncoded(QIODevice *device, QSsl::EncodingFormat format = QSsl::Pem);
+
+ Q_NETWORK_EXPORT bool isEmpty() const Q_DECL_NOTHROW;
+ Q_NETWORK_EXPORT bool isValid() const Q_DECL_NOTHROW;
+ Q_NETWORK_EXPORT Error error() const Q_DECL_NOTHROW;
+ Q_NETWORK_EXPORT QString errorString() const Q_DECL_NOTHROW;
+
+private:
+ QSslDiffieHellmanParametersPrivate *d;
+ friend class QSslContext;
+ friend Q_NETWORK_EXPORT bool operator==(const QSslDiffieHellmanParameters &lhs, const QSslDiffieHellmanParameters &rhs) Q_DECL_NOTHROW;
+#ifndef QT_NO_DEBUG_STREAM
+ friend Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QSslDiffieHellmanParameters &dhparam);
+#endif
+ friend Q_NETWORK_EXPORT uint qHash(const QSslDiffieHellmanParameters &dhparam, uint seed) Q_DECL_NOTHROW;
+};
+
+Q_DECLARE_SHARED(QSslDiffieHellmanParameters)
+
+#endif // QT_NO_SSL
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/network/ssl/qssldiffiehellmanparameters_dummy.cpp b/src/network/ssl/qssldiffiehellmanparameters_dummy.cpp
new file mode 100644
index 0000000000..220c017f4c
--- /dev/null
+++ b/src/network/ssl/qssldiffiehellmanparameters_dummy.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Mikkel Krautz <mikkel@krautz.dk>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qssldiffiehellmanparameters.h"
+#include "qssldiffiehellmanparameters_p.h"
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qbytearray.h>
+
+QT_BEGIN_NAMESPACE
+
+void QSslDiffieHellmanParametersPrivate::decodeDer(const QByteArray &)
+{
+}
+
+void QSslDiffieHellmanParametersPrivate::decodePem(const QByteArray &)
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp b/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
new file mode 100644
index 0000000000..949da1b7df
--- /dev/null
+++ b/src/network/ssl/qssldiffiehellmanparameters_openssl.cpp
@@ -0,0 +1,164 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Mikkel Krautz <mikkel@krautz.dk>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qssldiffiehellmanparameters.h"
+#include "qssldiffiehellmanparameters_p.h"
+#include "qsslsocket_openssl_symbols_p.h"
+#include "qsslsocket.h"
+#include "qsslsocket_p.h"
+
+#include <QtCore/qatomic.h>
+#include <QtCore/qbytearray.h>
+#include <QtCore/qiodevice.h>
+#ifndef QT_NO_DEBUG_STREAM
+#include <QtCore/qdebug.h>
+#endif
+
+// For q_BN_is_word.
+#include <openssl/bn.h>
+
+QT_BEGIN_NAMESPACE
+
+static bool isSafeDH(DH *dh)
+{
+ int status = 0;
+ int bad = 0;
+
+ QSslSocketPrivate::ensureInitialized();
+
+ // Mark p < 1024 bits as unsafe.
+ if (q_BN_num_bits(dh->p) < 1024) {
+ return false;
+ }
+
+ if (q_DH_check(dh, &status) != 1)
+ return false;
+
+ // From https://wiki.openssl.org/index.php/Diffie-Hellman_parameters:
+ //
+ // The additional call to BN_mod_word(dh->p, 24)
+ // (and unmasking of DH_NOT_SUITABLE_GENERATOR)
+ // is performed to ensure your program accepts
+ // IETF group parameters. OpenSSL checks the prime
+ // is congruent to 11 when g = 2; while the IETF's
+ // primes are congruent to 23 when g = 2.
+ // Without the test, the IETF parameters would
+ // fail validation. For details, see Diffie-Hellman
+ // Parameter Check (when g = 2, must p mod 24 == 11?).
+ if (q_BN_is_word(dh->g, DH_GENERATOR_2)) {
+ long residue = q_BN_mod_word(dh->p, 24);
+ if (residue == 11 || residue == 23)
+ status &= ~DH_NOT_SUITABLE_GENERATOR;
+ }
+
+ bad |= DH_CHECK_P_NOT_PRIME;
+ bad |= DH_CHECK_P_NOT_SAFE_PRIME;
+ bad |= DH_NOT_SUITABLE_GENERATOR;
+
+ return !(status & bad);
+}
+
+void QSslDiffieHellmanParametersPrivate::decodeDer(const QByteArray &der)
+{
+ if (der.isEmpty()) {
+ error = QSslDiffieHellmanParameters::InvalidInputDataError;
+ return;
+ }
+
+ const unsigned char *data = reinterpret_cast<const unsigned char *>(der.data());
+ int len = der.size();
+
+ QSslSocketPrivate::ensureInitialized();
+
+ DH *dh = q_d2i_DHparams(NULL, &data, len);
+ if (dh) {
+ if (isSafeDH(dh))
+ derData = der;
+ else
+ error = QSslDiffieHellmanParameters::UnsafeParametersError;
+ } else {
+ error = QSslDiffieHellmanParameters::InvalidInputDataError;
+ }
+
+ q_DH_free(dh);
+}
+
+void QSslDiffieHellmanParametersPrivate::decodePem(const QByteArray &pem)
+{
+ if (pem.isEmpty()) {
+ error = QSslDiffieHellmanParameters::InvalidInputDataError;
+ return;
+ }
+
+ if (!QSslSocket::supportsSsl()) {
+ error = QSslDiffieHellmanParameters::InvalidInputDataError;
+ return;
+ }
+
+ QSslSocketPrivate::ensureInitialized();
+
+ BIO *bio = q_BIO_new_mem_buf(const_cast<char *>(pem.data()), pem.size());
+ if (!bio) {
+ error = QSslDiffieHellmanParameters::InvalidInputDataError;
+ return;
+ }
+
+ DH *dh = Q_NULLPTR;
+ q_PEM_read_bio_DHparams(bio, &dh, 0, 0);
+
+ if (dh) {
+ if (isSafeDH(dh)) {
+ char *buf = Q_NULLPTR;
+ int len = q_i2d_DHparams(dh, reinterpret_cast<unsigned char **>(&buf));
+ if (len > 0)
+ derData = QByteArray(buf, len);
+ else
+ error = QSslDiffieHellmanParameters::InvalidInputDataError;
+ } else {
+ error = QSslDiffieHellmanParameters::UnsafeParametersError;
+ }
+ } else {
+ error = QSslDiffieHellmanParameters::InvalidInputDataError;
+ }
+
+ q_DH_free(dh);
+ q_BIO_free(bio);
+}
+
+QT_END_NAMESPACE
diff --git a/src/network/ssl/qssldiffiehellmanparameters_p.h b/src/network/ssl/qssldiffiehellmanparameters_p.h
new file mode 100644
index 0000000000..06ecf292ff
--- /dev/null
+++ b/src/network/ssl/qssldiffiehellmanparameters_p.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 Mikkel Krautz <mikkel@krautz.dk>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QSSLDIFFIEHELLMANPARAMETERS_P_H
+#define QSSLDIFFIEHELLMANPARAMETERS_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of qssldiffiehellmanparameters.cpp. This header file may change from version to version
+// without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtNetwork/private/qtnetworkglobal_p.h>
+#include <QSharedData>
+
+#include "qsslkey.h"
+#include "qssldiffiehellmanparameters.h"
+#include "qsslsocket_p.h" // includes wincrypt.h
+
+QT_BEGIN_NAMESPACE
+
+class QSslDiffieHellmanParametersPrivate : public QSharedData
+{
+public:
+ QSslDiffieHellmanParametersPrivate() : error(QSslDiffieHellmanParameters::NoError) {};
+
+ void decodeDer(const QByteArray &der);
+ void decodePem(const QByteArray &pem);
+
+ QSslDiffieHellmanParameters::Error error;
+ QByteArray derData;
+};
+
+QT_END_NAMESPACE
+
+#endif // QSSLDIFFIEHELLMANPARAMETERS_P_H
diff --git a/src/network/ssl/qsslellipticcurve.h b/src/network/ssl/qsslellipticcurve.h
index 6ee66d1ec1..0e7cc60e31 100644
--- a/src/network/ssl/qsslellipticcurve.h
+++ b/src/network/ssl/qsslellipticcurve.h
@@ -40,7 +40,7 @@
#ifndef QSSLELLIPTICCURVE_H
#define QSSLELLIPTICCURVE_H
-#include <QtCore/QtGlobal>
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/QString>
#include <QtCore/QMetaType>
#if QT_DEPRECATED_SINCE(5, 6)
diff --git a/src/network/ssl/qsslerror.h b/src/network/ssl/qsslerror.h
index 82db2e58e4..d7c959423d 100644
--- a/src/network/ssl/qsslerror.h
+++ b/src/network/ssl/qsslerror.h
@@ -41,6 +41,7 @@
#ifndef QSSLERROR_H
#define QSSLERROR_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qvariant.h>
#include <QtNetwork/qsslcertificate.h>
diff --git a/src/network/ssl/qsslkey.h b/src/network/ssl/qsslkey.h
index 39c3659fb8..6de02b1e44 100644
--- a/src/network/ssl/qsslkey.h
+++ b/src/network/ssl/qsslkey.h
@@ -41,6 +41,7 @@
#ifndef QSSLKEY_H
#define QSSLKEY_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qnamespace.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qsharedpointer.h>
diff --git a/src/network/ssl/qsslkey_p.cpp b/src/network/ssl/qsslkey_p.cpp
index 34f664093c..e66ec953a0 100644
--- a/src/network/ssl/qsslkey_p.cpp
+++ b/src/network/ssl/qsslkey_p.cpp
@@ -56,6 +56,9 @@
#include "qsslkey.h"
#include "qsslkey_p.h"
+#ifndef QT_NO_OPENSSL
+#include "qsslsocket_openssl_symbols_p.h"
+#endif
#include "qsslsocket.h"
#include "qsslsocket_p.h"
@@ -277,18 +280,23 @@ QSslKey::QSslKey(QIODevice *device, QSsl::KeyAlgorithm algorithm, QSsl::Encoding
\a type specifies whether the key is public or private.
QSslKey will take ownership for this key and you must not
- free the key using the native library. The algorithm used
- when creating a key from a handle will always be QSsl::Opaque.
+ free the key using the native library.
*/
QSslKey::QSslKey(Qt::HANDLE handle, QSsl::KeyType type)
: d(new QSslKeyPrivate)
{
#ifndef QT_NO_OPENSSL
- d->opaque = reinterpret_cast<EVP_PKEY *>(handle);
+ EVP_PKEY *evpKey = reinterpret_cast<EVP_PKEY *>(handle);
+ if (!evpKey || !d->fromEVP_PKEY(evpKey)) {
+ d->opaque = evpKey;
+ d->algorithm = QSsl::Opaque;
+ } else {
+ q_EVP_PKEY_free(evpKey);
+ }
#else
d->opaque = handle;
-#endif
d->algorithm = QSsl::Opaque;
+#endif
d->type = type;
d->isNull = !d->opaque;
}
diff --git a/src/network/ssl/qsslkey_p.h b/src/network/ssl/qsslkey_p.h
index c17183a059..c93941c198 100644
--- a/src/network/ssl/qsslkey_p.h
+++ b/src/network/ssl/qsslkey_p.h
@@ -41,8 +41,6 @@
#ifndef QSSLKEY_OPENSSL_P_H
#define QSSLKEY_OPENSSL_P_H
-#include "qsslkey.h"
-
//
// W A R N I N G
// -------------
@@ -54,6 +52,8 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
+#include "qsslkey.h"
#include "qsslsocket_p.h" // includes wincrypt.h
#ifndef QT_NO_OPENSSL
diff --git a/src/network/ssl/qsslpresharedkeyauthenticator.h b/src/network/ssl/qsslpresharedkeyauthenticator.h
index f34a2cee75..a012ff489a 100644
--- a/src/network/ssl/qsslpresharedkeyauthenticator.h
+++ b/src/network/ssl/qsslpresharedkeyauthenticator.h
@@ -40,7 +40,7 @@
#ifndef QSSLPRESHAREDKEYAUTHENTICATOR_H
#define QSSLPRESHAREDKEYAUTHENTICATOR_H
-#include <QtCore/QtGlobal>
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/QString>
#include <QtCore/QSharedDataPointer>
#include <QtCore/QMetaType>
diff --git a/src/network/ssl/qsslpresharedkeyauthenticator_p.h b/src/network/ssl/qsslpresharedkeyauthenticator_p.h
index b9aa6eb28c..e5566c3b3c 100644
--- a/src/network/ssl/qsslpresharedkeyauthenticator_p.h
+++ b/src/network/ssl/qsslpresharedkeyauthenticator_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include <QSharedData>
QT_BEGIN_NAMESPACE
diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp
index fc60f48d93..29e1f32815 100644
--- a/src/network/ssl/qsslsocket.cpp
+++ b/src/network/ssl/qsslsocket.cpp
@@ -837,15 +837,7 @@ bool QSslSocket::atEnd() const
// Note! docs copied from QAbstractSocket::flush()
bool QSslSocket::flush()
{
- Q_D(QSslSocket);
-#ifdef QSSLSOCKET_DEBUG
- qCDebug(lcSsl) << "QSslSocket::flush()";
-#endif
- if (d->mode != UnencryptedMode)
- // encrypt any unencrypted bytes in our buffer
- d->transmit();
-
- return d->plainSocket ? d->plainSocket->flush() : false;
+ return d_func()->flush();
}
/*!
@@ -924,6 +916,8 @@ void QSslSocket::setSslConfiguration(const QSslConfiguration &configuration)
d->configuration.privateKey = configuration.privateKey();
d->configuration.ciphers = configuration.ciphers();
d->configuration.ellipticCurves = configuration.ellipticCurves();
+ d->configuration.preSharedKeyIdentityHint = configuration.preSharedKeyIdentityHint();
+ d->configuration.dhParams = configuration.diffieHellmanParameters();
d->configuration.caCertificates = configuration.caCertificates();
d->configuration.peerVerifyDepth = configuration.peerVerifyDepth();
d->configuration.peerVerifyMode = configuration.peerVerifyMode();
@@ -2623,6 +2617,22 @@ QByteArray QSslSocketPrivate::peek(qint64 maxSize)
/*!
\internal
*/
+bool QSslSocketPrivate::flush()
+{
+#ifdef QSSLSOCKET_DEBUG
+ qCDebug(lcSsl) << "QSslSocketPrivate::flush()";
+#endif
+ if (mode != QSslSocket::UnencryptedMode) {
+ // encrypt any unencrypted bytes in our buffer
+ transmit();
+ }
+
+ return plainSocket && plainSocket->flush();
+}
+
+/*!
+ \internal
+*/
bool QSslSocketPrivate::rootCertOnDemandLoadingSupported()
{
return s_loadRootCertsOnDemand;
diff --git a/src/network/ssl/qsslsocket.h b/src/network/ssl/qsslsocket.h
index c069ff2f9d..1b29cd4637 100644
--- a/src/network/ssl/qsslsocket.h
+++ b/src/network/ssl/qsslsocket.h
@@ -41,6 +41,7 @@
#ifndef QSSLSOCKET_H
#define QSSLSOCKET_H
+#include <QtNetwork/qtnetworkglobal.h>
#include <QtCore/qlist.h>
#include <QtCore/qregexp.h>
#ifndef QT_NO_SSL
@@ -116,7 +117,7 @@ public:
bool canReadLine() const Q_DECL_OVERRIDE;
void close() Q_DECL_OVERRIDE;
bool atEnd() const Q_DECL_OVERRIDE;
- bool flush();
+ bool flush(); // ### Qt6: remove me (implementation moved to private flush())
void abort();
// From QAbstractSocket:
diff --git a/src/network/ssl/qsslsocket_mac.cpp b/src/network/ssl/qsslsocket_mac.cpp
index fd82d53fa8..438ea9a38e 100644
--- a/src/network/ssl/qsslsocket_mac.cpp
+++ b/src/network/ssl/qsslsocket_mac.cpp
@@ -68,57 +68,18 @@ QT_BEGIN_NAMESPACE
static SSLContextRef qt_createSecureTransportContext(QSslSocket::SslMode mode)
{
const bool isServer = mode == QSslSocket::SslServerMode;
- SSLContextRef context = Q_NULLPTR;
-
-#ifndef Q_OS_OSX
const SSLProtocolSide side = isServer ? kSSLServerSide : kSSLClientSide;
// We never use kSSLDatagramType, so it's kSSLStreamType unconditionally.
- context = SSLCreateContext(Q_NULLPTR, side, kSSLStreamType);
+ SSLContextRef context = SSLCreateContext(Q_NULLPTR, side, kSSLStreamType);
if (!context)
qCWarning(lcSsl) << "SSLCreateContext failed";
-#else // Q_OS_OSX
-
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_8, __IPHONE_NA)
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
- const SSLProtocolSide side = isServer ? kSSLServerSide : kSSLClientSide;
- // We never use kSSLDatagramType, so it's kSSLStreamType unconditionally.
- context = SSLCreateContext(Q_NULLPTR, side, kSSLStreamType);
- if (!context)
- qCWarning(lcSsl) << "SSLCreateContext failed";
- } else {
-#else
- {
-#endif
- const OSStatus errCode = SSLNewContext(isServer, &context);
- if (errCode != noErr || !context)
- qCWarning(lcSsl) << "SSLNewContext failed with error:" << errCode;
- }
-#endif // !Q_OS_OSX
-
return context;
}
static void qt_releaseSecureTransportContext(SSLContextRef context)
{
- if (!context)
- return;
-
-#ifndef Q_OS_OSX
- CFRelease(context);
-#else
-
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_8, __IPHONE_NA)
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
+ if (context)
CFRelease(context);
- } else {
-#else
- {
-#endif // QT_MAC_PLATFORM_...
- const OSStatus errCode = SSLDisposeContext(context);
- if (errCode != noErr)
- qCWarning(lcSsl) << "SSLDisposeContext failed with error:" << errCode;
- }
-#endif // !Q_OS_OSX
}
static bool qt_setSessionProtocol(SSLContextRef context, const QSslConfigurationPrivate &configuration,
@@ -132,7 +93,6 @@ static bool qt_setSessionProtocol(SSLContextRef context, const QSslConfiguration
OSStatus err = noErr;
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_8, __IPHONE_5_0)
if (configuration.protocol == QSsl::SslV3) {
#ifdef QSSLSOCKET_DEBUG
qCDebug(lcSsl) << plainSocket << "requesting : SSLv3";
@@ -210,117 +170,10 @@ static bool qt_setSessionProtocol(SSLContextRef context, const QSslConfiguration
#endif
return false;
}
-#endif
return err == noErr;
}
-#ifdef Q_OS_OSX
-
-static bool qt_setSessionProtocolOSX(SSLContextRef context, const QSslConfigurationPrivate &configuration,
- QTcpSocket *plainSocket)
-{
- // This function works with (now) deprecated API that does not even exist on
- // iOS but is the only API we have on OS X below 10.8
-
- // Without SSLSetProtocolVersionMin/Max functions it's quite difficult
- // to have the required result:
- // If we use SSLSetProtocolVersion - any constant except the ones with 'Only' suffix -
- // allows a negotiation and we can not set the lower limit.
- // SSLSetProtocolVersionEnabled supports only a limited subset of constants, if you believe their docs:
- // kSSLProtocol2
- // kSSLProtocol3
- // kTLSProtocol1
- // kSSLProtocolAll
- // Here we can only have a look into the SecureTransport's code and hope that what we see there
- // and what we have on 10.7 is similar:
- // SSLSetProtocoLVersionEnabled actually accepts other constants also,
- // called twice with two different protocols it sets a range,
- // called once with a protocol (when all protocols were disabled)
- // - only this protocol is enabled (without a lower limit negotiation).
-
- Q_ASSERT(context);
-
-#ifndef QSSLSOCKET_DEBUG
- Q_UNUSED(plainSocket)
-#endif
-
- OSStatus err = noErr;
-
- // First, disable ALL:
- if (SSLSetProtocolVersionEnabled(context, kSSLProtocolAll, false) != noErr)
- return false;
-
- if (configuration.protocol == QSsl::SslV3) {
- #ifdef QSSLSOCKET_DEBUG
- qCDebug(lcSsl) << plainSocket << "requesting : SSLv3";
- #endif
- err = SSLSetProtocolVersion(context, kSSLProtocol3Only);
- } else if (configuration.protocol == QSsl::TlsV1_0) {
- #ifdef QSSLSOCKET_DEBUG
- qCDebug(lcSsl) << plainSocket << "requesting : TLSv1.0";
- #endif
- err = SSLSetProtocolVersion(context, kTLSProtocol1Only);
- } else if (configuration.protocol == QSsl::TlsV1_1) {
- #ifdef QSSLSOCKET_DEBUG
- qCDebug(lcSsl) << plainSocket << "requesting : TLSv1.1";
- #endif
- err = SSLSetProtocolVersionEnabled(context, kTLSProtocol11, true);
- } else if (configuration.protocol == QSsl::TlsV1_2) {
- #ifdef QSSLSOCKET_DEBUG
- qCDebug(lcSsl) << plainSocket << "requesting : TLSv1.2";
- #endif
- err = SSLSetProtocolVersionEnabled(context, kTLSProtocol12, true);
- } else if (configuration.protocol == QSsl::AnyProtocol) {
- #ifdef QSSLSOCKET_DEBUG
- qCDebug(lcSsl) << plainSocket << "requesting : any";
- #endif
- err = SSLSetProtocolVersionEnabled(context, kSSLProtocolAll, true);
- } else if (configuration.protocol == QSsl::TlsV1SslV3) {
- #ifdef QSSLSOCKET_DEBUG
- qCDebug(lcSsl) << plainSocket << "requesting : SSLv3 - TLSv1.2";
- #endif
- err = SSLSetProtocolVersionEnabled(context, kTLSProtocol12, true);
- if (err == noErr)
- err = SSLSetProtocolVersionEnabled(context, kSSLProtocol3, true);
- } else if (configuration.protocol == QSsl::SecureProtocols) {
- #ifdef QSSLSOCKET_DEBUG
- qCDebug(lcSsl) << plainSocket << "requesting : TLSv1 - TLSv1.2";
- #endif
- err = SSLSetProtocolVersionEnabled(context, kTLSProtocol12, true);
- if (err == noErr)
- err = SSLSetProtocolVersionEnabled(context, kTLSProtocol1, true);
- } else if (configuration.protocol == QSsl::TlsV1_0OrLater) {
- #ifdef QSSLSOCKET_DEBUG
- qCDebug(lcSsl) << plainSocket << "requesting : TLSv1 - TLSv1.2";
- #endif
- err = SSLSetProtocolVersionEnabled(context, kTLSProtocol12, true);
- if (err == noErr)
- err = SSLSetProtocolVersionEnabled(context, kTLSProtocol1, true);
- } else if (configuration.protocol == QSsl::TlsV1_1OrLater) {
- #ifdef QSSLSOCKET_DEBUG
- qCDebug(lcSsl) << plainSocket << "requesting : TLSv1.1 - TLSv1.2";
- #endif
- err = SSLSetProtocolVersionEnabled(context, kTLSProtocol12, true);
- if (err == noErr)
- err = SSLSetProtocolVersionEnabled(context, kTLSProtocol11, true);
- } else if (configuration.protocol == QSsl::TlsV1_2OrLater) {
- #ifdef QSSLSOCKET_DEBUG
- qCDebug(lcSsl) << plainSocket << "requesting : TLSv1.2";
- #endif
- err = SSLSetProtocolVersionEnabled(context, kTLSProtocol12, true);
- } else {
- #ifdef QSSLSOCKET_DEBUG
- qCDebug(lcSsl) << plainSocket << "no protocol version found in the configuration";
- #endif
- return false;
- }
-
- return err == noErr;
-}
-
-#endif // Q_OS_OSX
-
QSecureTransportContext::QSecureTransportContext(SSLContextRef c)
: context(c)
{
@@ -351,7 +204,7 @@ bool QSslSocketPrivate::s_loadedCiphersAndCerts = false;
bool QSslSocketPrivate::s_loadRootCertsOnDemand = false;
-#ifndef Q_OS_IOS // dhparam is not used on iOS. (see the SSLSetDiffieHellmanParams call below)
+#if !defined(QT_PLATFORM_UIKIT) // dhparam is not used on iOS or tvOS. (see the SSLSetDiffieHellmanParams call below)
static const uint8_t dhparam[] =
"\x30\x82\x01\x08\x02\x82\x01\x01\x00\x97\xea\xd0\x46\xf7\xae\xa7\x76\x80"
"\x9c\x74\x56\x98\xd8\x56\x97\x2b\x20\x6c\x77\xe2\x82\xbb\xc8\x84\xbe\xe7"
@@ -370,8 +223,8 @@ static const uint8_t dhparam[] =
"\x90\x0b\x35\x64\xff\xd9\xe3\xac\xf2\xf2\xeb\x3a\x63\x02\x01\x02";
#endif
-// No ioErr on iOS. (defined in MacErrors.h on OS X)
-#ifdef Q_OS_IOS
+// No ioErr on iOS/tvOS. (defined in MacErrors.h on OS X)
+#if defined(QT_PLATFORM_UIKIT)
# define ioErr -36
#endif
@@ -959,21 +812,6 @@ bool QSslSocketBackendPrivate::initSslContext()
return false;
}
-#ifdef Q_OS_OSX
- if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_8) {
- // Starting from OS X 10.8 SSLSetSessionOption with kSSLSessionOptionBreakOnServerAuth/
- // kSSLSessionOptionBreakOnClientAuth disables automatic certificate validation.
- // But for OS X versions below 10.8 we have to do it explicitly:
- const OSStatus err = SSLSetEnableCertVerify(context, false);
- if (err != noErr) {
- destroySslContext();
- setErrorAndEmit(QSslSocket::SslInternalError,
- QStringLiteral("SSLSetEnableCertVerify failed: %1").arg(err));
- return false;
- }
- }
-#endif
-
if (mode == QSslSocket::SslClientMode) {
// enable Server Name Indication (SNI)
QString tlsHostName(verificationPeerName.isEmpty() ? q->peerName() : verificationPeerName);
@@ -1011,7 +849,7 @@ bool QSslSocketBackendPrivate::initSslContext()
return false;
}
}
-#ifndef Q_OS_IOS
+#if !defined(QT_PLATFORM_UIKIT)
// No SSLSetDiffieHellmanParams on iOS; calling it is optional according to docs.
SSLSetDiffieHellmanParams(context, dhparam, sizeof(dhparam));
#endif
@@ -1128,20 +966,7 @@ bool QSslSocketBackendPrivate::setSessionProtocol()
return false;
}
-#ifndef Q_OS_OSX
return qt_setSessionProtocol(context, configuration, plainSocket);
-#else
-
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_8, __IPHONE_NA)
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
- return qt_setSessionProtocol(context, configuration, plainSocket);
- } else {
-#else
- {
-#endif
- return qt_setSessionProtocolOSX(context, configuration, plainSocket);
- }
-#endif
}
bool QSslSocketBackendPrivate::canIgnoreTrustVerificationFailure() const
diff --git a/src/network/ssl/qsslsocket_mac_p.h b/src/network/ssl/qsslsocket_mac_p.h
index 09b6f392cd..9e1d18981e 100644
--- a/src/network/ssl/qsslsocket_mac_p.h
+++ b/src/network/ssl/qsslsocket_mac_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include <QtCore/qstring.h>
#include <QtCore/qglobal.h>
#include <QtCore/qlist.h>
diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp
index b3820aea97..aca7507d13 100644
--- a/src/network/ssl/qsslsocket_openssl.cpp
+++ b/src/network/ssl/qsslsocket_openssl.cpp
@@ -201,6 +201,15 @@ static unsigned int q_ssl_psk_client_callback(SSL *ssl,
Q_ASSERT(d);
return d->tlsPskClientCallback(hint, identity, max_identity_len, psk, max_psk_len);
}
+
+static unsigned int q_ssl_psk_server_callback(SSL *ssl,
+ const char *identity,
+ unsigned char *psk, unsigned int max_psk_len)
+{
+ QSslSocketBackendPrivate *d = reinterpret_cast<QSslSocketBackendPrivate *>(q_SSL_get_ex_data(ssl, QSslSocketBackendPrivate::s_indexForSSLExtraData));
+ Q_ASSERT(d);
+ return d->tlsPskServerCallback(identity, psk, max_psk_len);
+}
#endif
} // extern "C"
@@ -436,8 +445,12 @@ bool QSslSocketBackendPrivate::initSslContext()
#if OPENSSL_VERSION_NUMBER >= 0x10001000L && !defined(OPENSSL_NO_PSK)
// Set the client callback for PSK
- if (q_SSLeay() >= 0x10001000L && mode == QSslSocket::SslClientMode)
- q_SSL_set_psk_client_callback(ssl, &q_ssl_psk_client_callback);
+ if (q_SSLeay() >= 0x10001000L) {
+ if (mode == QSslSocket::SslClientMode)
+ q_SSL_set_psk_client_callback(ssl, &q_ssl_psk_client_callback);
+ else if (mode == QSslSocket::SslServerMode)
+ q_SSL_set_psk_server_callback(ssl, &q_ssl_psk_server_callback);
+ }
#endif
return true;
@@ -522,15 +535,9 @@ void QSslSocketPrivate::ensureCiphersAndCertsLoaded()
#if defined(Q_OS_WIN)
HINSTANCE hLib = LoadLibraryW(L"Crypt32");
if (hLib) {
-#if defined(Q_OS_WINCE)
- ptrCertOpenSystemStoreW = (PtrCertOpenSystemStoreW)GetProcAddress(hLib, L"CertOpenStore");
- ptrCertFindCertificateInStore = (PtrCertFindCertificateInStore)GetProcAddress(hLib, L"CertFindCertificateInStore");
- ptrCertCloseStore = (PtrCertCloseStore)GetProcAddress(hLib, L"CertCloseStore");
-#else
ptrCertOpenSystemStoreW = (PtrCertOpenSystemStoreW)GetProcAddress(hLib, "CertOpenSystemStoreW");
ptrCertFindCertificateInStore = (PtrCertFindCertificateInStore)GetProcAddress(hLib, "CertFindCertificateInStore");
ptrCertCloseStore = (PtrCertCloseStore)GetProcAddress(hLib, "CertCloseStore");
-#endif
if (!ptrCertOpenSystemStoreW || !ptrCertFindCertificateInStore || !ptrCertCloseStore)
qCWarning(lcSsl, "could not resolve symbols in crypt32 library"); // should never happen
} else {
@@ -691,15 +698,7 @@ QList<QSslCertificate> QSslSocketPrivate::systemCaCertificates()
#if defined(Q_OS_WIN)
if (ptrCertOpenSystemStoreW && ptrCertFindCertificateInStore && ptrCertCloseStore) {
HCERTSTORE hSystemStore;
-#if defined(Q_OS_WINCE)
- hSystemStore = ptrCertOpenSystemStoreW(CERT_STORE_PROV_SYSTEM_W,
- 0,
- 0,
- CERT_STORE_NO_CRYPT_RELEASE_FLAG|CERT_SYSTEM_STORE_CURRENT_USER,
- L"ROOT");
-#else
hSystemStore = ptrCertOpenSystemStoreW(0, L"ROOT");
-#endif
if(hSystemStore) {
PCCERT_CONTEXT pc = NULL;
while(1) {
@@ -1278,6 +1277,31 @@ unsigned int QSslSocketBackendPrivate::tlsPskClientCallback(const char *hint,
return pskLength;
}
+unsigned int QSslSocketBackendPrivate::tlsPskServerCallback(const char *identity,
+ unsigned char *psk, unsigned int max_psk_len)
+{
+ QSslPreSharedKeyAuthenticator authenticator;
+
+ // Fill in some read-only fields (for the user)
+ authenticator.d->identityHint = configuration.preSharedKeyIdentityHint;
+ authenticator.d->identity = identity;
+ authenticator.d->maximumIdentityLength = 0; // user cannot set an identity
+ authenticator.d->maximumPreSharedKeyLength = int(max_psk_len);
+
+ // Let the client provide the remaining bits...
+ Q_Q(QSslSocket);
+ emit q->preSharedKeyAuthenticationRequired(&authenticator);
+
+ // No PSK set? Return now to make the handshake fail
+ if (authenticator.preSharedKey().isEmpty())
+ return 0;
+
+ // Copy data back into OpenSSL
+ const int pskLength = qMin(authenticator.preSharedKey().length(), authenticator.maximumPreSharedKeyLength());
+ ::memcpy(psk, authenticator.preSharedKey().constData(), pskLength);
+ return pskLength;
+}
+
#ifdef Q_OS_WIN
void QSslSocketBackendPrivate::fetchCaRootForCert(const QSslCertificate &cert)
@@ -1579,7 +1603,22 @@ void QSslSocketBackendPrivate::continueHandshake()
} else {
const unsigned char *proto = 0;
unsigned int proto_len = 0;
- q_SSL_get0_next_proto_negotiated(ssl, &proto, &proto_len);
+#if OPENSSL_VERSION_NUMBER >= 0x10002000L
+ if (q_SSLeay() >= 0x10002000L) {
+ q_SSL_get0_alpn_selected(ssl, &proto, &proto_len);
+ if (proto_len && mode == QSslSocket::SslClientMode) {
+ // Client does not have a callback that sets it ...
+ configuration.nextProtocolNegotiationStatus = QSslConfiguration::NextProtocolNegotiationNegotiated;
+ }
+ }
+
+ if (!proto_len) { // Test if NPN was more lucky ...
+#else
+ {
+#endif
+ q_SSL_get0_next_proto_negotiated(ssl, &proto, &proto_len);
+ }
+
if (proto_len)
configuration.nextNegotiatedProtocol = QByteArray(reinterpret_cast<const char *>(proto), proto_len);
else
diff --git a/src/network/ssl/qsslsocket_openssl_android.cpp b/src/network/ssl/qsslsocket_openssl_android.cpp
index d73ed8995e..b5d2458d56 100644
--- a/src/network/ssl/qsslsocket_openssl_android.cpp
+++ b/src/network/ssl/qsslsocket_openssl_android.cpp
@@ -70,6 +70,7 @@ QList<QByteArray> QSslSocketPrivate::fetchSslCertificateData()
QJNIEnvironmentPrivate env;
jobjectArray jcertificates = static_cast<jobjectArray>(certificates.object());
const jint nCertificates = env->GetArrayLength(jcertificates);
+ certificateData.reserve(static_cast<int>(nCertificates));
for (int i = 0; i < nCertificates; ++i) {
jbyteArray jCert = static_cast<jbyteArray>(env->GetObjectArrayElement(jcertificates, i));
diff --git a/src/network/ssl/qsslsocket_openssl_p.h b/src/network/ssl/qsslsocket_openssl_p.h
index 0674c05d71..755a08ef6e 100644
--- a/src/network/ssl/qsslsocket_openssl_p.h
+++ b/src/network/ssl/qsslsocket_openssl_p.h
@@ -66,6 +66,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qsslsocket_p.h"
#ifdef Q_OS_WIN
@@ -143,6 +144,7 @@ public:
bool checkSslErrors();
void storePeerCertificates();
unsigned int tlsPskClientCallback(const char *hint, char *identity, unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len);
+ unsigned int tlsPskServerCallback(const char *identity, unsigned char *psk, unsigned int max_psk_len);
#ifdef Q_OS_WIN
void fetchCaRootForCert(const QSslCertificate &cert);
void _q_caRootLoaded(QSslCertificate,QSslCertificate) Q_DECL_OVERRIDE;
diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp
index d420f78dc7..88fed69d3a 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols.cpp
+++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp
@@ -151,6 +151,10 @@ DEFINEFUNC3(int, BIO_read, BIO *a, a, void *b, b, int c, c, return -1, return)
DEFINEFUNC(BIO_METHOD *, BIO_s_mem, void, DUMMYARG, return 0, return)
DEFINEFUNC3(int, BIO_write, BIO *a, a, const void *b, b, int c, c, return -1, return)
DEFINEFUNC(int, BN_num_bits, const BIGNUM *a, a, return 0, return)
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+DEFINEFUNC2(int, BN_is_word, BIGNUM *a, a, BN_ULONG w, w, return 0, return)
+#endif
+DEFINEFUNC2(BN_ULONG, BN_mod_word, const BIGNUM *a, a, BN_ULONG w, w, return -1, return)
#ifndef OPENSSL_NO_EC
DEFINEFUNC(const EC_GROUP*, EC_KEY_get0_group, const EC_KEY* k, k, return 0, return)
DEFINEFUNC(int, EC_GROUP_get_degree, const EC_GROUP* g, g, return 0, return)
@@ -202,17 +206,20 @@ DEFINEFUNC(int, OBJ_obj2nid, const ASN1_OBJECT *a, a, return NID_undef, return)
DEFINEFUNC6(void *, PEM_ASN1_read_bio, d2i_of_void *a, a, const char *b, b, BIO *c, c, void **d, d, pem_password_cb *e, e, void *f, f, return 0, return)
DEFINEFUNC6(void *, PEM_ASN1_write_bio, d2i_of_void *a, a, const char *b, b, BIO *c, c, void **d, d, pem_password_cb *e, e, void *f, f, return 0, return)
#else
+DEFINEFUNC4(EVP_PKEY *, PEM_read_bio_PrivateKey, BIO *a, a, EVP_PKEY **b, b, pem_password_cb *c, c, void *d, d, return 0, return)
DEFINEFUNC4(DSA *, PEM_read_bio_DSAPrivateKey, BIO *a, a, DSA **b, b, pem_password_cb *c, c, void *d, d, return 0, return)
DEFINEFUNC4(RSA *, PEM_read_bio_RSAPrivateKey, BIO *a, a, RSA **b, b, pem_password_cb *c, c, void *d, d, return 0, return)
#ifndef OPENSSL_NO_EC
DEFINEFUNC4(EC_KEY *, PEM_read_bio_ECPrivateKey, BIO *a, a, EC_KEY **b, b, pem_password_cb *c, c, void *d, d, return 0, return)
#endif
+DEFINEFUNC4(DH *, PEM_read_bio_DHparams, BIO *a, a, DH **b, b, pem_password_cb *c, c, void *d, d, return 0, return)
DEFINEFUNC7(int, PEM_write_bio_DSAPrivateKey, BIO *a, a, DSA *b, b, const EVP_CIPHER *c, c, unsigned char *d, d, int e, e, pem_password_cb *f, f, void *g, g, return 0, return)
DEFINEFUNC7(int, PEM_write_bio_RSAPrivateKey, BIO *a, a, RSA *b, b, const EVP_CIPHER *c, c, unsigned char *d, d, int e, e, pem_password_cb *f, f, void *g, g, return 0, return)
#ifndef OPENSSL_NO_EC
DEFINEFUNC7(int, PEM_write_bio_ECPrivateKey, BIO *a, a, EC_KEY *b, b, const EVP_CIPHER *c, c, unsigned char *d, d, int e, e, pem_password_cb *f, f, void *g, g, return 0, return)
#endif
#endif
+DEFINEFUNC4(EVP_PKEY *, PEM_read_bio_PUBKEY, BIO *a, a, EVP_PKEY **b, b, pem_password_cb *c, c, void *d, d, return 0, return)
DEFINEFUNC4(DSA *, PEM_read_bio_DSA_PUBKEY, BIO *a, a, DSA **b, b, pem_password_cb *c, c, void *d, d, return 0, return)
DEFINEFUNC4(RSA *, PEM_read_bio_RSA_PUBKEY, BIO *a, a, RSA **b, b, pem_password_cb *c, c, void *d, d, return 0, return)
#ifndef OPENSSL_NO_EC
@@ -300,6 +307,8 @@ DEFINEFUNC2(void *, SSL_get_ex_data, const SSL *ssl, ssl, int idx, idx, return N
#endif
#if OPENSSL_VERSION_NUMBER >= 0x10001000L && !defined(OPENSSL_NO_PSK)
DEFINEFUNC2(void, SSL_set_psk_client_callback, SSL* ssl, ssl, q_psk_client_callback_t callback, callback, return, DUMMYARG)
+DEFINEFUNC2(void, SSL_set_psk_server_callback, SSL* ssl, ssl, q_psk_server_callback_t callback, callback, return, DUMMYARG)
+DEFINEFUNC2(int, SSL_CTX_use_psk_identity_hint, SSL_CTX* ctx, ctx, const char *hint, hint, return 0, return)
#endif
#if OPENSSL_VERSION_NUMBER >= 0x10000000L
#ifndef OPENSSL_NO_SSL2
@@ -418,10 +427,24 @@ DEFINEFUNC3(void, SSL_CTX_set_next_proto_select_cb, SSL_CTX *s, s,
void *arg, arg, return, DUMMYARG)
DEFINEFUNC3(void, SSL_get0_next_proto_negotiated, const SSL *s, s,
const unsigned char **data, data, unsigned *len, len, return, DUMMYARG)
+#if OPENSSL_VERSION_NUMBER >= 0x10002000L
+DEFINEFUNC3(int, SSL_set_alpn_protos, SSL *s, s, const unsigned char *protos, protos,
+ unsigned protos_len, protos_len, return -1, return)
+DEFINEFUNC3(void, SSL_CTX_set_alpn_select_cb, SSL_CTX *s, s,
+ int (*cb) (SSL *ssl, const unsigned char **out,
+ unsigned char *outlen,
+ const unsigned char *in,
+ unsigned int inlen, void *arg), cb,
+ void *arg, arg, return, DUMMYARG)
+DEFINEFUNC3(void, SSL_get0_alpn_selected, const SSL *s, s, const unsigned char **data, data,
+ unsigned *len, len, return, DUMMYARG)
+#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L ...
#endif // OPENSSL_VERSION_NUMBER >= 0x1000100fL ...
DEFINEFUNC(DH *, DH_new, DUMMYARG, DUMMYARG, return 0, return)
DEFINEFUNC(void, DH_free, DH *dh, dh, return, DUMMYARG)
DEFINEFUNC3(DH *, d2i_DHparams, DH**a, a, const unsigned char **pp, pp, long length, length, return 0, return)
+DEFINEFUNC2(int, i2d_DHparams, DH *a, a, unsigned char **p, p, return -1, return)
+DEFINEFUNC2(int, DH_check, DH *dh, dh, int *codes, codes, return 0, return)
DEFINEFUNC3(BIGNUM *, BN_bin2bn, const unsigned char *s, s, int len, len, BIGNUM *ret, ret, return 0, return)
#ifndef OPENSSL_NO_EC
DEFINEFUNC(EC_KEY *, EC_KEY_dup, const EC_KEY *ec, ec, return 0, return)
@@ -768,6 +791,10 @@ bool q_resolveOpenSslSymbols()
RESOLVEFUNC(EC_GROUP_get_degree)
#endif
RESOLVEFUNC(BN_num_bits)
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+ RESOLVEFUNC(BN_is_word)
+#endif
+ RESOLVEFUNC(BN_mod_word)
RESOLVEFUNC(CRYPTO_free)
RESOLVEFUNC(CRYPTO_num_locks)
RESOLVEFUNC(CRYPTO_set_id_callback)
@@ -811,17 +838,20 @@ bool q_resolveOpenSslSymbols()
#ifdef SSLEAY_MACROS // ### verify
RESOLVEFUNC(PEM_ASN1_read_bio)
#else
+ RESOLVEFUNC(PEM_read_bio_PrivateKey)
RESOLVEFUNC(PEM_read_bio_DSAPrivateKey)
RESOLVEFUNC(PEM_read_bio_RSAPrivateKey)
#ifndef OPENSSL_NO_EC
RESOLVEFUNC(PEM_read_bio_ECPrivateKey)
#endif
+ RESOLVEFUNC(PEM_read_bio_DHparams)
RESOLVEFUNC(PEM_write_bio_DSAPrivateKey)
RESOLVEFUNC(PEM_write_bio_RSAPrivateKey)
#ifndef OPENSSL_NO_EC
RESOLVEFUNC(PEM_write_bio_ECPrivateKey)
#endif
#endif
+ RESOLVEFUNC(PEM_read_bio_PUBKEY)
RESOLVEFUNC(PEM_read_bio_DSA_PUBKEY)
RESOLVEFUNC(PEM_read_bio_RSA_PUBKEY)
#ifndef OPENSSL_NO_EC
@@ -889,6 +919,8 @@ bool q_resolveOpenSslSymbols()
#endif
#if OPENSSL_VERSION_NUMBER >= 0x10001000L && !defined(OPENSSL_NO_PSK)
RESOLVEFUNC(SSL_set_psk_client_callback)
+ RESOLVEFUNC(SSL_set_psk_server_callback)
+ RESOLVEFUNC(SSL_CTX_use_psk_identity_hint)
#endif
RESOLVEFUNC(SSL_write)
#ifndef OPENSSL_NO_SSL2
@@ -972,9 +1004,16 @@ bool q_resolveOpenSslSymbols()
RESOLVEFUNC(SSL_CTX_set_next_proto_select_cb)
RESOLVEFUNC(SSL_get0_next_proto_negotiated)
#endif // OPENSSL_VERSION_NUMBER >= 0x1000100fL ...
+#if OPENSSL_VERSION_NUMBER >= 0x10002000L
+ RESOLVEFUNC(SSL_set_alpn_protos)
+ RESOLVEFUNC(SSL_CTX_set_alpn_select_cb)
+ RESOLVEFUNC(SSL_get0_alpn_selected)
+#endif // OPENSSL_VERSION_NUMBER >= 0x10002000L ...
RESOLVEFUNC(DH_new)
RESOLVEFUNC(DH_free)
RESOLVEFUNC(d2i_DHparams)
+ RESOLVEFUNC(i2d_DHparams)
+ RESOLVEFUNC(DH_check)
RESOLVEFUNC(BN_bin2bn)
#ifndef OPENSSL_NO_EC
RESOLVEFUNC(EC_KEY_dup)
diff --git a/src/network/ssl/qsslsocket_openssl_symbols_p.h b/src/network/ssl/qsslsocket_openssl_symbols_p.h
index df17fd8a9c..508fdc2a4b 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols_p.h
+++ b/src/network/ssl/qsslsocket_openssl_symbols_p.h
@@ -67,6 +67,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qsslsocket_openssl_p.h"
#include <QtCore/qglobal.h>
@@ -220,13 +221,28 @@ unsigned char * q_ASN1_STRING_data(ASN1_STRING *a);
int q_ASN1_STRING_length(ASN1_STRING *a);
int q_ASN1_STRING_to_UTF8(unsigned char **a, ASN1_STRING *b);
long q_BIO_ctrl(BIO *a, int b, long c, void *d);
-int q_BIO_free(BIO *a);
-BIO *q_BIO_new(BIO_METHOD *a);
+Q_AUTOTEST_EXPORT int q_BIO_free(BIO *a);
+Q_AUTOTEST_EXPORT BIO *q_BIO_new(BIO_METHOD *a);
BIO *q_BIO_new_mem_buf(void *a, int b);
int q_BIO_read(BIO *a, void *b, int c);
-BIO_METHOD *q_BIO_s_mem();
-int q_BIO_write(BIO *a, const void *b, int c);
+Q_AUTOTEST_EXPORT BIO_METHOD *q_BIO_s_mem();
+Q_AUTOTEST_EXPORT int q_BIO_write(BIO *a, const void *b, int c);
int q_BN_num_bits(const BIGNUM *a);
+#if OPENSSL_VERSION_NUMBER >= 0x10100000L
+int q_BN_is_word(BIGNUM *a, BN_ULONG w);
+#else
+// BN_is_word is implemented purely as a
+// macro in OpenSSL < 1.1. It doesn't
+// call any functions.
+//
+// The implementation of BN_is_word is
+// 100% the same between 1.0.0, 1.0.1
+// and 1.0.2.
+//
+// Users are required to include <openssl/bn.h>.
+#define q_BN_is_word BN_is_word
+#endif // OPENSSL_VERSION_NUMBER >= 0x10100000L
+BN_ULONG q_BN_mod_word(const BIGNUM *a, BN_ULONG w);
#ifndef OPENSSL_NO_EC
const EC_GROUP* q_EC_KEY_get0_group(const EC_KEY* k);
int q_EC_GROUP_get_degree(const EC_GROUP* g);
@@ -279,11 +295,13 @@ void *q_PEM_ASN1_read_bio(d2i_of_void *a, const char *b, BIO *c, void **d, pem_p
void *f);
// ### ditto for write
#else
+Q_AUTOTEST_EXPORT EVP_PKEY *q_PEM_read_bio_PrivateKey(BIO *a, EVP_PKEY **b, pem_password_cb *c, void *d);
DSA *q_PEM_read_bio_DSAPrivateKey(BIO *a, DSA **b, pem_password_cb *c, void *d);
RSA *q_PEM_read_bio_RSAPrivateKey(BIO *a, RSA **b, pem_password_cb *c, void *d);
#ifndef OPENSSL_NO_EC
EC_KEY *q_PEM_read_bio_ECPrivateKey(BIO *a, EC_KEY **b, pem_password_cb *c, void *d);
#endif
+DH *q_PEM_read_bio_DHparams(BIO *a, DH **b, pem_password_cb *c, void *d);
int q_PEM_write_bio_DSAPrivateKey(BIO *a, DSA *b, const EVP_CIPHER *c, unsigned char *d,
int e, pem_password_cb *f, void *g);
int q_PEM_write_bio_RSAPrivateKey(BIO *a, RSA *b, const EVP_CIPHER *c, unsigned char *d,
@@ -293,6 +311,7 @@ int q_PEM_write_bio_ECPrivateKey(BIO *a, EC_KEY *b, const EVP_CIPHER *c, unsigne
int e, pem_password_cb *f, void *g);
#endif
#endif
+Q_AUTOTEST_EXPORT EVP_PKEY *q_PEM_read_bio_PUBKEY(BIO *a, EVP_PKEY **b, pem_password_cb *c, void *d);
DSA *q_PEM_read_bio_DSA_PUBKEY(BIO *a, DSA **b, pem_password_cb *c, void *d);
RSA *q_PEM_read_bio_RSA_PUBKEY(BIO *a, RSA **b, pem_password_cb *c, void *d);
#ifndef OPENSSL_NO_EC
@@ -376,6 +395,9 @@ void *q_SSL_get_ex_data(const SSL *ssl, int idx);
#if OPENSSL_VERSION_NUMBER >= 0x10001000L && !defined(OPENSSL_NO_PSK)
typedef unsigned int (*q_psk_client_callback_t)(SSL *ssl, const char *hint, char *identity, unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len);
void q_SSL_set_psk_client_callback(SSL *ssl, q_psk_client_callback_t callback);
+typedef unsigned int (*q_psk_server_callback_t)(SSL *ssl, const char *identity, unsigned char *psk, unsigned int max_psk_len);
+void q_SSL_set_psk_server_callback(SSL *ssl, q_psk_server_callback_t callback);
+int q_SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *hint);
#endif // OPENSSL_VERSION_NUMBER >= 0x10001000L && !defined(OPENSSL_NO_PSK)
#if OPENSSL_VERSION_NUMBER >= 0x10000000L
#ifndef OPENSSL_NO_SSL2
@@ -472,6 +494,8 @@ STACK_OF(X509) *q_X509_STORE_CTX_get_chain(X509_STORE_CTX *ctx);
DH *q_DH_new();
void q_DH_free(DH *dh);
DH *q_d2i_DHparams(DH **a, const unsigned char **pp, long length);
+int q_i2d_DHparams(DH *a, unsigned char **p);
+int q_DH_check(DH *dh, int *codes);
BIGNUM *q_BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret);
#define q_SSL_CTX_set_tmp_dh(ctx, dh) q_SSL_CTX_ctrl((ctx), SSL_CTRL_SET_TMP_DH, 0, (char *)dh)
@@ -518,6 +542,9 @@ DSA *q_d2i_DSAPrivateKey(DSA **a, unsigned char **pp, long length);
#define q_PEM_write_bio_DSAPrivateKey(bp,x,enc,kstr,klen,cb,u) \
PEM_ASN1_write_bio((int (*)(void*, unsigned char**))q_i2d_DSAPrivateKey,PEM_STRING_DSA,\
bp,(char *)x,enc,kstr,klen,cb,u)
+#define q_PEM_read_bio_DHparams(bp, dh, cb, u) \
+ (DH *)q_PEM_ASN1_read_bio( \
+ (void *(*)(void**, const unsigned char**, long int))q_d2i_DHparams, PEM_STRING_DHPARAMS, bp, (void **)x, cb, u)
#endif
#define q_SSL_CTX_set_options(ctx,op) q_SSL_CTX_ctrl((ctx),SSL_CTRL_OPTIONS,(op),NULL)
#define q_SSL_CTX_set_mode(ctx,op) q_SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL)
@@ -558,6 +585,19 @@ void q_SSL_CTX_set_next_proto_select_cb(SSL_CTX *s,
void *arg);
void q_SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data,
unsigned *len);
+#if OPENSSL_VERSION_NUMBER >= 0x10002000L
+int q_SSL_set_alpn_protos(SSL *ssl, const unsigned char *protos,
+ unsigned protos_len);
+void q_SSL_CTX_set_alpn_select_cb(SSL_CTX *ctx,
+ int (*cb) (SSL *ssl,
+ const unsigned char **out,
+ unsigned char *outlen,
+ const unsigned char *in,
+ unsigned int inlen,
+ void *arg), void *arg);
+void q_SSL_get0_alpn_selected(const SSL *ssl, const unsigned char **data,
+ unsigned *len);
+#endif
#endif // OPENSSL_VERSION_NUMBER >= 0x1000100fL ...
// Helper function
diff --git a/src/network/ssl/qsslsocket_p.h b/src/network/ssl/qsslsocket_p.h
index 5d4d52cd6d..696827daff 100644
--- a/src/network/ssl/qsslsocket_p.h
+++ b/src/network/ssl/qsslsocket_p.h
@@ -54,6 +54,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include <private/qtcpsocket_p.h>
#include "qsslkey.h"
#include "qsslconfiguration_p.h"
@@ -89,11 +90,7 @@ QT_BEGIN_NAMESPACE
#endif
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
-#if defined(Q_OS_WINCE)
- typedef HCERTSTORE (WINAPI *PtrCertOpenSystemStoreW)(LPCSTR, DWORD, HCRYPTPROV_LEGACY, DWORD, const void*);
-#else
typedef HCERTSTORE (WINAPI *PtrCertOpenSystemStoreW)(HCRYPTPROV_LEGACY, LPCWSTR);
-#endif
typedef PCCERT_CONTEXT (WINAPI *PtrCertFindCertificateInStore)(HCERTSTORE, DWORD, DWORD, DWORD, const void*, PCCERT_CONTEXT);
typedef BOOL (WINAPI *PtrCertCloseStore)(HCERTSTORE, DWORD);
#endif // Q_OS_WIN && !Q_OS_WINRT
@@ -193,6 +190,7 @@ public:
virtual qint64 peek(char *data, qint64 maxSize) Q_DECL_OVERRIDE;
virtual QByteArray peek(qint64 maxSize) Q_DECL_OVERRIDE;
+ bool flush() Q_DECL_OVERRIDE;
// Platform specific functions
virtual void startClientEncryption() = 0;
diff --git a/src/network/ssl/qsslsocket_winrt.cpp b/src/network/ssl/qsslsocket_winrt.cpp
index edc8ca0bbb..f5dc9fcdcd 100644
--- a/src/network/ssl/qsslsocket_winrt.cpp
+++ b/src/network/ssl/qsslsocket_winrt.cpp
@@ -215,7 +215,9 @@ QList<QSslCipher> QSslSocketBackendPrivate::defaultCiphers()
const QString protocolStrings[] = { QStringLiteral("SSLv3"), QStringLiteral("TLSv1"),
QStringLiteral("TLSv1.1"), QStringLiteral("TLSv1.2") };
const QSsl::SslProtocol protocols[] = { QSsl::SslV3, QSsl::TlsV1_0, QSsl::TlsV1_1, QSsl::TlsV1_2 };
- for (int i = 0; i < ARRAYSIZE(protocols); ++i) {
+ const int size = static_cast<int>(ARRAYSIZE(protocols));
+ ciphers.reserve(size);
+ for (int i = 0; i < size; ++i) {
QSslCipher cipher;
cipher.d->isNull = false;
cipher.d->name = QStringLiteral("WINRT");
diff --git a/src/network/ssl/qsslsocket_winrt_p.h b/src/network/ssl/qsslsocket_winrt_p.h
index 3946a0e60b..1043aeee11 100644
--- a/src/network/ssl/qsslsocket_winrt_p.h
+++ b/src/network/ssl/qsslsocket_winrt_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtNetwork/private/qtnetworkglobal_p.h>
#include "qsslsocket_p.h"
#include <wrl.h>
diff --git a/src/network/ssl/ssl.pri b/src/network/ssl/ssl.pri
index c70664ef9b..edbbeadf51 100644
--- a/src/network/ssl/ssl.pri
+++ b/src/network/ssl/ssl.pri
@@ -1,5 +1,5 @@
# OpenSSL support; compile in QSslSocket.
-contains(QT_CONFIG, ssl) | contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) {
+contains(QT_CONFIG, ssl) {
HEADERS += ssl/qasn1element_p.h \
ssl/qssl.h \
ssl/qssl_p.h \
@@ -9,6 +9,8 @@ contains(QT_CONFIG, ssl) | contains(QT_CONFIG, openssl) | contains(QT_CONFIG, op
ssl/qsslconfiguration_p.h \
ssl/qsslcipher.h \
ssl/qsslcipher_p.h \
+ ssl/qssldiffiehellmanparameters.h \
+ ssl/qssldiffiehellmanparameters_p.h \
ssl/qsslellipticcurve.h \
ssl/qsslerror.h \
ssl/qsslkey.h \
@@ -24,6 +26,7 @@ contains(QT_CONFIG, ssl) | contains(QT_CONFIG, openssl) | contains(QT_CONFIG, op
ssl/qsslcertificate.cpp \
ssl/qsslconfiguration.cpp \
ssl/qsslcipher.cpp \
+ ssl/qssldiffiehellmanparameters.cpp \
ssl/qsslellipticcurve.cpp \
ssl/qsslkey_p.cpp \
ssl/qsslerror.cpp \
@@ -35,6 +38,7 @@ contains(QT_CONFIG, ssl) | contains(QT_CONFIG, openssl) | contains(QT_CONFIG, op
HEADERS += ssl/qsslsocket_winrt_p.h
SOURCES += ssl/qsslcertificate_qt.cpp \
ssl/qsslcertificate_winrt.cpp \
+ ssl/qssldiffiehellmanparameters_dummy.cpp \
ssl/qsslkey_qt.cpp \
ssl/qsslkey_winrt.cpp \
ssl/qsslsocket_winrt.cpp \
@@ -44,43 +48,45 @@ contains(QT_CONFIG, ssl) | contains(QT_CONFIG, openssl) | contains(QT_CONFIG, op
contains(QT_CONFIG, securetransport) {
HEADERS += ssl/qsslsocket_mac_p.h
SOURCES += ssl/qsslcertificate_qt.cpp \
+ ssl/qssldiffiehellmanparameters_dummy.cpp \
ssl/qsslkey_qt.cpp \
ssl/qsslkey_mac.cpp \
ssl/qsslsocket_mac_shared.cpp \
ssl/qsslsocket_mac.cpp \
ssl/qsslellipticcurve_dummy.cpp
}
-}
-contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) {
- HEADERS += ssl/qsslcontext_openssl_p.h \
- ssl/qsslsocket_openssl_p.h \
- ssl/qsslsocket_openssl_symbols_p.h
- SOURCES += ssl/qsslcertificate_openssl.cpp \
- ssl/qsslcontext_openssl.cpp \
- ssl/qsslellipticcurve_openssl.cpp \
- ssl/qsslkey_openssl.cpp \
- ssl/qsslsocket_openssl.cpp \
- ssl/qsslsocket_openssl_symbols.cpp
+ contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) {
+ HEADERS += ssl/qsslcontext_openssl_p.h \
+ ssl/qsslsocket_openssl_p.h \
+ ssl/qsslsocket_openssl_symbols_p.h
+ SOURCES += ssl/qsslcertificate_openssl.cpp \
+ ssl/qsslcontext_openssl.cpp \
+ ssl/qssldiffiehellmanparameters_openssl.cpp \
+ ssl/qsslellipticcurve_openssl.cpp \
+ ssl/qsslkey_openssl.cpp \
+ ssl/qsslsocket_openssl.cpp \
+ ssl/qsslsocket_openssl_symbols.cpp
- darwin:SOURCES += ssl/qsslsocket_mac_shared.cpp
+ darwin:SOURCES += ssl/qsslsocket_mac_shared.cpp
- android: SOURCES += ssl/qsslsocket_openssl_android.cpp
+ android: SOURCES += ssl/qsslsocket_openssl_android.cpp
- # Add optional SSL libs
- # Static linking of OpenSSL with msvc:
- # - Binaries http://slproweb.com/products/Win32OpenSSL.html
- # - also needs -lUser32 -lAdvapi32 -lGdi32 -lCrypt32
- # - libs in <OPENSSL_DIR>\lib\VC\static
- # - configure: -openssl -openssl-linked -I <OPENSSL_DIR>\include -L <OPENSSL_DIR>\lib\VC\static OPENSSL_LIBS="-lUser32 -lAdvapi32 -lGdi32" OPENSSL_LIBS_DEBUG="-lssleay32MDd -llibeay32MDd" OPENSSL_LIBS_RELEASE="-lssleay32MD -llibeay32MD"
+ # Add optional SSL libs
+ # Static linking of OpenSSL with msvc:
+ # - Binaries http://slproweb.com/products/Win32OpenSSL.html
+ # - also needs -lUser32 -lAdvapi32 -lGdi32 -lCrypt32
+ # - libs in <OPENSSL_DIR>\lib\VC\static
+ # - configure: -openssl -openssl-linked -I <OPENSSL_DIR>\include -L <OPENSSL_DIR>\lib\VC\static OPENSSL_LIBS="-lUser32 -lAdvapi32 -lGdi32" OPENSSL_LIBS_DEBUG="-lssleay32MDd -llibeay32MDd" OPENSSL_LIBS_RELEASE="-lssleay32MD -llibeay32MD"
- CONFIG(debug, debug|release) {
- LIBS_PRIVATE += $$OPENSSL_LIBS_DEBUG
- } else {
- LIBS_PRIVATE += $$OPENSSL_LIBS_RELEASE
- }
+ CONFIG(debug, debug|release) {
+ LIBS_PRIVATE += $$OPENSSL_LIBS_DEBUG
+ } else {
+ LIBS_PRIVATE += $$OPENSSL_LIBS_RELEASE
+ }
- QMAKE_CXXFLAGS += $$OPENSSL_CFLAGS
- LIBS_PRIVATE += $$OPENSSL_LIBS
- win32: LIBS_PRIVATE += -lcrypt32
+ QMAKE_CXXFLAGS += $$OPENSSL_CFLAGS
+ LIBS_PRIVATE += $$OPENSSL_LIBS
+ win32: LIBS_PRIVATE += -lcrypt32
+ }
}
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 868e9ed265..6365a7421b 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -1006,11 +1006,11 @@ void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(const float *data,
glStencilMask(0xff); // Enable stencil writes
if (dirtyStencilRegion.intersects(currentScissorBounds)) {
- QVector<QRect> clearRegion = dirtyStencilRegion.intersected(currentScissorBounds).rects();
+ const QRegion clearRegion = dirtyStencilRegion.intersected(currentScissorBounds);
glClearStencil(0); // Clear to zero
- for (int i = 0; i < clearRegion.size(); ++i) {
+ for (const QRect &rect : clearRegion) {
#ifndef QT_GL_NO_SCISSOR_TEST
- setScissor(clearRegion.at(i));
+ setScissor(rect);
#endif
glClear(GL_STENCIL_BUFFER_BIT);
}
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 6b0501e8d0..5aa807b12c 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -1918,7 +1918,8 @@ void QGLTextureCache::insert(QGLContext* ctx, qint64 key, QGLTexture* texture, i
{
QWriteLocker locker(&m_lock);
const QGLTextureCacheKey cacheKey = {key, QGLContextPrivate::contextGroup(ctx)};
- m_cache.insert(cacheKey, texture, cost);
+ const bool inserted = m_cache.insert(cacheKey, texture, cost);
+ Q_UNUSED(inserted) Q_ASSERT(inserted);
}
void QGLTextureCache::remove(qint64 key)
diff --git a/src/platformsupport/cglconvenience/cglconvenience.mm b/src/platformsupport/cglconvenience/cglconvenience.mm
index a18510a9e2..28cde1264d 100644
--- a/src/platformsupport/cglconvenience/cglconvenience.mm
+++ b/src/platformsupport/cglconvenience/cglconvenience.mm
@@ -78,22 +78,15 @@ void *qcgl_createNSOpenGLPixelFormat(const QSurfaceFormat &format)
if (format.swapBehavior() != QSurfaceFormat::SingleBuffer)
attrs.append(NSOpenGLPFADoubleBuffer);
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
- if (format.profile() == QSurfaceFormat::CoreProfile
- && ((format.majorVersion() == 3 && format.minorVersion() >= 2)
- || format.majorVersion() > 3)) {
- attrs << NSOpenGLPFAOpenGLProfile;
- attrs << NSOpenGLProfileVersion3_2Core;
- } else {
- attrs << NSOpenGLPFAOpenGLProfile;
- attrs << NSOpenGLProfileVersionLegacy;
- }
+ if (format.profile() == QSurfaceFormat::CoreProfile
+ && ((format.majorVersion() == 3 && format.minorVersion() >= 2)
+ || format.majorVersion() > 3)) {
+ attrs << NSOpenGLPFAOpenGLProfile;
+ attrs << NSOpenGLProfileVersion3_2Core;
+ } else {
+ attrs << NSOpenGLPFAOpenGLProfile;
+ attrs << NSOpenGLProfileVersionLegacy;
}
-#else
- if (format.profile() == QSurfaceFormat::CoreProfile)
- qWarning("Mac OSX >= 10.7 is needed for OpenGL Core Profile support");
-#endif
if (format.depthBufferSize() > 0)
attrs << NSOpenGLPFADepthSize << format.depthBufferSize();
diff --git a/src/platformsupport/clipboard/qmacmime.mm b/src/platformsupport/clipboard/qmacmime.mm
index f2b9afa2b5..d48da8da15 100644
--- a/src/platformsupport/clipboard/qmacmime.mm
+++ b/src/platformsupport/clipboard/qmacmime.mm
@@ -43,7 +43,7 @@
#import <AppKit/AppKit.h>
#endif
-#if defined(Q_OS_IOS)
+#if defined(QT_PLATFORM_UIKIT)
#import <UIKit/UIKit.h>
#endif
@@ -520,11 +520,6 @@ QString QMacPasteboardMimeRtfText::mimeFor(QString flav)
bool QMacPasteboardMimeRtfText::canConvert(const QString &mime, QString flav)
{
-#if defined(Q_OS_IOS)
- if (QSysInfo::MacintoshVersion < QSysInfo::MV_IOS_7_0)
- return false;
-#endif
-
return mime == mimeFor(flav);
}
diff --git a/src/platformsupport/eventdispatchers/eventdispatchers.pri b/src/platformsupport/eventdispatchers/eventdispatchers.pri
index a0b37cae1a..6a4689eb19 100644
--- a/src/platformsupport/eventdispatchers/eventdispatchers.pri
+++ b/src/platformsupport/eventdispatchers/eventdispatchers.pri
@@ -17,6 +17,6 @@ HEADERS +=\
contains(QT_CONFIG, glib) {
SOURCES +=$$PWD/qeventdispatcher_glib.cpp
HEADERS +=$$PWD/qeventdispatcher_glib_p.h
- QMAKE_CXXFLAGS += $$QT_CFLAGS_GLIB
- LIBS_PRIVATE += $$QT_LIBS_GLIB
+ QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_GLIB
+ LIBS_PRIVATE += $$QMAKE_LIBS_GLIB
}
diff --git a/src/platformsupport/eventdispatchers/qwindowsguieventdispatcher.cpp b/src/platformsupport/eventdispatchers/qwindowsguieventdispatcher.cpp
index 7d49c35d84..de369e0b00 100644
--- a/src/platformsupport/eventdispatchers/qwindowsguieventdispatcher.cpp
+++ b/src/platformsupport/eventdispatchers/qwindowsguieventdispatcher.cpp
@@ -151,11 +151,10 @@ messageDebugEntries[] = {
{WM_IME_ENDCOMPOSITION, "WM_IME_ENDCOMPOSITION", true},
{WM_IME_NOTIFY, "WM_IME_NOTIFY", true},
{WM_IME_REQUEST, "WM_IME_REQUEST", true},
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
{WM_QUERYENDSESSION, "WM_QUERYENDSESSION", true},
{WM_ENDSESSION, "WM_ENDSESSION", true},
#endif
-#ifndef Q_OS_WINCE
{WM_MOUSEACTIVATE,"WM_MOUSEACTIVATE", true},
{WM_CHILDACTIVATE, "WM_CHILDACTIVATE", true},
{WM_PARENTNOTIFY, "WM_PARENTNOTIFY", true},
@@ -181,7 +180,6 @@ messageDebugEntries[] = {
{WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN", true},
{WM_DISPLAYCHANGE, "WM_DISPLAYCHANGE", true},
{WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD", true},
-#endif // !Q_OS_WINCE
{WM_THEMECHANGED, "WM_THEMECHANGED", true}
};
diff --git a/src/platformsupport/fbconvenience/qfbbackingstore.cpp b/src/platformsupport/fbconvenience/qfbbackingstore.cpp
index fa1b8d0acd..2cad3441e4 100644
--- a/src/platformsupport/fbconvenience/qfbbackingstore.cpp
+++ b/src/platformsupport/fbconvenience/qfbbackingstore.cpp
@@ -81,6 +81,12 @@ const QImage QFbBackingStore::image()
return mImage;
}
+
+QImage QFbBackingStore::toImage() const
+{
+ return mImage;
+}
+
void QFbBackingStore::lock()
{
mImageMutex.lock();
@@ -110,4 +116,3 @@ void QFbBackingStore::endPaint()
}
QT_END_NAMESPACE
-
diff --git a/src/platformsupport/fbconvenience/qfbbackingstore_p.h b/src/platformsupport/fbconvenience/qfbbackingstore_p.h
index fc06b95475..c8dfe3489c 100644
--- a/src/platformsupport/fbconvenience/qfbbackingstore_p.h
+++ b/src/platformsupport/fbconvenience/qfbbackingstore_p.h
@@ -72,6 +72,7 @@ public:
void resize(const QSize &size, const QRegion &region) Q_DECL_OVERRIDE;
const QImage image();
+ QImage toImage() const override;
void lock();
void unlock();
diff --git a/src/platformsupport/fbconvenience/qfbscreen.cpp b/src/platformsupport/fbconvenience/qfbscreen.cpp
index 4066743cc2..01de2a59b2 100644
--- a/src/platformsupport/fbconvenience/qfbscreen.cpp
+++ b/src/platformsupport/fbconvenience/qfbscreen.cpp
@@ -206,15 +206,13 @@ void QFbScreen::generateRects()
remainingScreen -= localGeometry;
QRegion windowRegion(localGeometry);
windowRegion -= remainingScreen;
- foreach (const QRect &rect, windowRegion.rects()) {
+ for (const QRect &rect : windowRegion)
mCachedRects += QPair<QRect, int>(rect, i);
- }
}
#endif
}
- const QVector<QRect> remainingScreenRects = remainingScreen.rects();
- mCachedRects.reserve(mCachedRects.count() + remainingScreenRects.count());
- foreach (const QRect &rect, remainingScreenRects)
+ mCachedRects.reserve(mCachedRects.count() + remainingScreen.rectCount());
+ for (const QRect &rect : remainingScreen)
mCachedRects += QPair<QRect, int>(rect, -1);
mIsUpToDate = true;
}
@@ -254,7 +252,7 @@ QRegion QFbScreen::doRedraw()
rectRegion -= intersect;
// we only expect one rectangle, but defensive coding...
- foreach (const QRect &rect, intersect.rects()) {
+ for (const QRect &rect : intersect) {
bool firstLayer = true;
if (layer == -1) {
mCompositePainter->setCompositionMode(QPainter::CompositionMode_Source);
diff --git a/src/platformsupport/fontdatabases/basic/basic.pri b/src/platformsupport/fontdatabases/basic/basic.pri
index d70b3b6a1a..52cf771b2a 100644
--- a/src/platformsupport/fontdatabases/basic/basic.pri
+++ b/src/platformsupport/fontdatabases/basic/basic.pri
@@ -8,6 +8,4 @@ SOURCES += \
$$PWD/qbasicfontdatabase.cpp \
$$QT_SOURCE_TREE/src/gui/text/qfontengine_ft.cpp
-CONFIG += opentype
-
include($$QT_SOURCE_TREE/src/3rdparty/freetype_dependency.pri)
diff --git a/src/platformsupport/fontdatabases/mac/coretext.pri b/src/platformsupport/fontdatabases/mac/coretext.pri
index ebb64d15b4..272e7591ba 100644
--- a/src/platformsupport/fontdatabases/mac/coretext.pri
+++ b/src/platformsupport/fontdatabases/mac/coretext.pri
@@ -5,11 +5,10 @@ contains(QT_CONFIG, freetype) {
include($$QT_SOURCE_TREE/src/3rdparty/freetype_dependency.pri)
HEADERS += $$QT_SOURCE_TREE/src/gui/text/qfontengine_ft_p.h
SOURCES += $$QT_SOURCE_TREE/src/gui/text/qfontengine_ft.cpp
- CONFIG += opentype
}
-ios: \
- # On iOS CoreText and CoreGraphics are stand-alone frameworks
+uikit: \
+ # On iOS/tvOS CoreText and CoreGraphics are stand-alone frameworks
LIBS_PRIVATE += -framework CoreText -framework CoreGraphics
else: \
# On Mac OS they are part of the ApplicationServices umbrella framework,
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
index 5be7e3aadc..5fec53d1ed 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
@@ -44,7 +44,7 @@
#if defined(Q_OS_OSX)
#import <AppKit/AppKit.h>
#import <IOKit/graphics/IOGraphicsLib.h>
-#elif defined(Q_OS_IOS)
+#elif defined(QT_PLATFORM_UIKIT)
#import <UIKit/UIFont.h>
#endif
@@ -191,7 +191,7 @@ static CFArrayRef availableFamilyNames()
{
#if defined(Q_OS_OSX)
return CTFontManagerCopyAvailableFontFamilyNames();
-#elif defined(Q_OS_IOS)
+#elif defined(QT_PLATFORM_UIKIT)
return (CFArrayRef) [[UIFont familyNames] retain];
#endif
}
@@ -523,46 +523,37 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo
static QHash<QString, QStringList> fallbackLists;
if (!family.isEmpty()) {
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_8, __IPHONE_6_0)
- // CTFontCopyDefaultCascadeListForLanguages is available in the SDK
- #if QT_MAC_DEPLOYMENT_TARGET_BELOW(__MAC_10_8, __IPHONE_6_0)
- // But we have to feature check at runtime
- if (&CTFontCopyDefaultCascadeListForLanguages)
- #endif
- {
- QCFType<CFMutableDictionaryRef> attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- CFDictionaryAddValue(attributes, kCTFontFamilyNameAttribute, QCFString(family));
- if (QCFType<CTFontDescriptorRef> fontDescriptor = CTFontDescriptorCreateWithAttributes(attributes)) {
- if (QCFType<CTFontRef> font = CTFontCreateWithFontDescriptor(fontDescriptor, 12.0, 0)) {
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- NSArray *languages = [defaults stringArrayForKey: @"AppleLanguages"];
-
- QCFType<CFArrayRef> cascadeList = (CFArrayRef) CTFontCopyDefaultCascadeListForLanguages(font, (CFArrayRef) languages);
- if (cascadeList) {
- QStringList fallbackList;
- const int numCascades = CFArrayGetCount(cascadeList);
- for (int i = 0; i < numCascades; ++i) {
- CTFontDescriptorRef fontFallback = (CTFontDescriptorRef) CFArrayGetValueAtIndex(cascadeList, i);
- QCFString fallbackFamilyName = (CFStringRef) CTFontDescriptorCopyAttribute(fontFallback, kCTFontFamilyNameAttribute);
- fallbackList.append(QCFString::toQString(fallbackFamilyName));
- }
+ QCFType<CFMutableDictionaryRef> attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ CFDictionaryAddValue(attributes, kCTFontFamilyNameAttribute, QCFString(family));
+ if (QCFType<CTFontDescriptorRef> fontDescriptor = CTFontDescriptorCreateWithAttributes(attributes)) {
+ if (QCFType<CTFontRef> font = CTFontCreateWithFontDescriptor(fontDescriptor, 12.0, 0)) {
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+ NSArray *languages = [defaults stringArrayForKey: @"AppleLanguages"];
+
+ QCFType<CFArrayRef> cascadeList = (CFArrayRef) CTFontCopyDefaultCascadeListForLanguages(font, (CFArrayRef) languages);
+ if (cascadeList) {
+ QStringList fallbackList;
+ const int numCascades = CFArrayGetCount(cascadeList);
+ for (int i = 0; i < numCascades; ++i) {
+ CTFontDescriptorRef fontFallback = (CTFontDescriptorRef) CFArrayGetValueAtIndex(cascadeList, i);
+ QCFString fallbackFamilyName = (CFStringRef) CTFontDescriptorCopyAttribute(fontFallback, kCTFontFamilyNameAttribute);
+ fallbackList.append(QCFString::toQString(fallbackFamilyName));
+ }
#if defined(Q_OS_OSX)
- // Since we are only returning a list of default fonts for the current language, we do not
- // cover all unicode completely. This was especially an issue for some of the common script
- // symbols such as mathematical symbols, currency or geometric shapes. To minimize the risk
- // of missing glyphs, we add Arial Unicode MS as a final fail safe, since this covers most
- // of Unicode 2.1.
- if (!fallbackList.contains(QStringLiteral("Arial Unicode MS")))
- fallbackList.append(QStringLiteral("Arial Unicode MS"));
+ // Since we are only returning a list of default fonts for the current language, we do not
+ // cover all unicode completely. This was especially an issue for some of the common script
+ // symbols such as mathematical symbols, currency or geometric shapes. To minimize the risk
+ // of missing glyphs, we add Arial Unicode MS as a final fail safe, since this covers most
+ // of Unicode 2.1.
+ if (!fallbackList.contains(QStringLiteral("Arial Unicode MS")))
+ fallbackList.append(QStringLiteral("Arial Unicode MS"));
#endif
- return fallbackList;
- }
+ return fallbackList;
}
}
}
-#endif
}
// We were not able to find a fallback for the specific family,
@@ -625,7 +616,6 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo
return fallbackLists[styleLookupKey.arg(styleHint)];
}
-#if HAVE_CORETEXT
static CFArrayRef createDescriptorArrayForFont(CTFontRef font, const QString &fileName = QString())
{
CFMutableArrayRef array = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
@@ -643,7 +633,7 @@ static CFArrayRef createDescriptorArrayForFont(CTFontRef font, const QString &fi
// QUrl::fromLocalFile() doesn't accept qrc pseudo-paths like ":/fonts/myfont.ttf".
// Therefore construct from QString with the qrc:// scheme -> "qrc:///fonts/myfont.ttf".
fontURL = QUrl(QStringLiteral("qrc://") + fileName.mid(1)).toCFURL();
- } else if (!fileName.isEmpty()) {
+ } else {
// At this point we hope that filename is in a format that QUrl can handle.
fontURL = QUrl::fromLocalFile(fileName).toCFURL();
}
@@ -658,104 +648,41 @@ static CFArrayRef createDescriptorArrayForFont(CTFontRef font, const QString &fi
CFArrayAppendValue(array, descriptor);
return array;
}
-#endif
QStringList QCoreTextFontDatabase::addApplicationFont(const QByteArray &fontData, const QString &fileName)
{
QCFType<CFArrayRef> fonts;
QStringList families;
-#if HAVE_CORETEXT
- if (&CTFontManagerRegisterGraphicsFont) {
- CFErrorRef error = 0;
- if (!fontData.isEmpty()) {
- QByteArray* fontDataCopy = new QByteArray(fontData);
- QCFType<CGDataProviderRef> dataProvider = CGDataProviderCreateWithData(fontDataCopy,
- fontDataCopy->constData(), fontDataCopy->size(), releaseFontData);
- QCFType<CGFontRef> cgFont = CGFontCreateWithDataProvider(dataProvider);
- if (cgFont) {
- if (CTFontManagerRegisterGraphicsFont(cgFont, &error)) {
- QCFType<CTFontRef> font = CTFontCreateWithGraphicsFont(cgFont, 0.0, NULL, NULL);
- fonts = createDescriptorArrayForFont(font
+ CFErrorRef error = 0;
+ if (!fontData.isEmpty()) {
+ QByteArray* fontDataCopy = new QByteArray(fontData);
+ QCFType<CGDataProviderRef> dataProvider = CGDataProviderCreateWithData(fontDataCopy,
+ fontDataCopy->constData(), fontDataCopy->size(), releaseFontData);
+ QCFType<CGFontRef> cgFont = CGFontCreateWithDataProvider(dataProvider);
+ if (cgFont) {
+ if (CTFontManagerRegisterGraphicsFont(cgFont, &error)) {
+ QCFType<CTFontRef> font = CTFontCreateWithGraphicsFont(cgFont, 0.0, NULL, NULL);
+ fonts = createDescriptorArrayForFont(font
#ifndef QT_NO_FREETYPE
- , m_useFreeType ? fileName : QString()
-#endif
- );
- m_applicationFonts.append(QVariant::fromValue(QCFType<CGFontRef>::constructFromGet(cgFont)));
- }
- }
- } else {
- QCFType<CFURLRef> fontURL = CFURLCreateWithFileSystemPath(NULL, QCFString(fileName), kCFURLPOSIXPathStyle, false);
- if (CTFontManagerRegisterFontsForURL(fontURL, kCTFontManagerScopeProcess, &error)) {
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_6, __IPHONE_7_0)
- if (&CTFontManagerCreateFontDescriptorsFromURL)
- fonts = CTFontManagerCreateFontDescriptorsFromURL(fontURL);
- else
+ , m_useFreeType ? fileName : QString()
#endif
- {
- // We're limited to a single font per file, unless we dive into the font tables
- QCFType<CFMutableDictionaryRef> attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 1,
- &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- CFDictionaryAddValue(attributes, kCTFontURLAttribute, fontURL);
- QCFType<CTFontDescriptorRef> descriptor = CTFontDescriptorCreateWithAttributes(attributes);
- QCFType<CTFontRef> font = CTFontCreateWithFontDescriptor(descriptor, 0.0, NULL);
- fonts = createDescriptorArrayForFont(font);
- }
-
- m_applicationFonts.append(QVariant::fromValue(QCFType<CFURLRef>::constructFromGet(fontURL)));
+ );
+ m_applicationFonts.append(QVariant::fromValue(QCFType<CGFontRef>::constructFromGet(cgFont)));
}
}
-
- if (error) {
- NSLog(@"Unable to register font: %@", error);
- CFRelease(error);
+ } else {
+ QCFType<CFURLRef> fontURL = CFURLCreateWithFileSystemPath(NULL, QCFString(fileName), kCFURLPOSIXPathStyle, false);
+ if (CTFontManagerRegisterFontsForURL(fontURL, kCTFontManagerScopeProcess, &error)) {
+ fonts = CTFontManagerCreateFontDescriptorsFromURL(fontURL);
+ m_applicationFonts.append(QVariant::fromValue(QCFType<CFURLRef>::constructFromGet(fontURL)));
}
}
-#endif
-#if HAVE_CORETEXT && HAVE_ATS
- else
-#endif
-#if HAVE_ATS
- {
- ATSFontContainerRef fontContainer;
- OSStatus e;
-
- if (!fontData.isEmpty()) {
- e = ATSFontActivateFromMemory((void *) fontData.constData(), fontData.size(),
- kATSFontContextLocal, kATSFontFormatUnspecified, NULL,
- kATSOptionFlagsDefault, &fontContainer);
- } else {
- FSRef ref;
- if (FSPathMakeRef(reinterpret_cast<const UInt8 *>(fileName.toUtf8().constData()),
- &ref, 0) != noErr)
- return QStringList();
- e = ATSFontActivateFromFileReference(&ref, kATSFontContextLocal, kATSFontFormatUnspecified, 0,
- kATSOptionFlagsDefault, &fontContainer);
- }
-
- if (e == noErr) {
- ItemCount fontCount = 0;
- e = ATSFontFindFromContainer(fontContainer, kATSOptionFlagsDefault, 0, 0, &fontCount);
- if (e != noErr)
- return QStringList();
-
- QVarLengthArray<ATSFontRef> containedFonts(fontCount);
- e = ATSFontFindFromContainer(fontContainer, kATSOptionFlagsDefault, fontCount, containedFonts.data(), &fontCount);
- if (e != noErr)
- return QStringList();
-
- CFMutableArrayRef fontsArray = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
- for (int i = 0; i < containedFonts.size(); ++i) {
- QCFType<CTFontRef> font = CTFontCreateWithPlatformFont(containedFonts[i], 12.0, NULL, NULL);
- CFArrayAppendValue(fontsArray, QCFType<CTFontDescriptorRef>(CTFontCopyFontDescriptor(font)));
- }
- fonts = fontsArray;
-
- m_applicationFonts.append(QVariant::fromValue(fontContainer));
- }
+ if (error) {
+ NSLog(@"Unable to register font: %@", error);
+ CFRelease(error);
}
-#endif
if (fonts) {
const int numFonts = CFArrayGetCount(fonts);
@@ -852,41 +779,39 @@ static CTFontUIFontType fontTypeFromTheme(QPlatformTheme::Font f)
static CTFontDescriptorRef fontDescriptorFromTheme(QPlatformTheme::Font f)
{
-#ifdef Q_OS_IOS
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_7_0) {
- // Use Dynamic Type to resolve theme fonts if possible, to get
- // correct font sizes and style based on user configuration.
- NSString *textStyle = 0;
- switch (f) {
- case QPlatformTheme::TitleBarFont:
- case QPlatformTheme::HeaderViewFont:
- textStyle = UIFontTextStyleHeadline;
- break;
- case QPlatformTheme::MdiSubWindowTitleFont:
- textStyle = UIFontTextStyleSubheadline;
- break;
- case QPlatformTheme::TipLabelFont:
- case QPlatformTheme::SmallFont:
- textStyle = UIFontTextStyleFootnote;
- break;
- case QPlatformTheme::MiniFont:
- textStyle = UIFontTextStyleCaption2;
- break;
- case QPlatformTheme::FixedFont:
- // Fall back to regular code path, as iOS doesn't provide
- // an appropriate text style for this theme font.
- break;
- default:
- textStyle = UIFontTextStyleBody;
- break;
- }
+#if defined(QT_PLATFORM_UIKIT)
+ // Use Dynamic Type to resolve theme fonts if possible, to get
+ // correct font sizes and style based on user configuration.
+ NSString *textStyle = 0;
+ switch (f) {
+ case QPlatformTheme::TitleBarFont:
+ case QPlatformTheme::HeaderViewFont:
+ textStyle = UIFontTextStyleHeadline;
+ break;
+ case QPlatformTheme::MdiSubWindowTitleFont:
+ textStyle = UIFontTextStyleSubheadline;
+ break;
+ case QPlatformTheme::TipLabelFont:
+ case QPlatformTheme::SmallFont:
+ textStyle = UIFontTextStyleFootnote;
+ break;
+ case QPlatformTheme::MiniFont:
+ textStyle = UIFontTextStyleCaption2;
+ break;
+ case QPlatformTheme::FixedFont:
+ // Fall back to regular code path, as iOS doesn't provide
+ // an appropriate text style for this theme font.
+ break;
+ default:
+ textStyle = UIFontTextStyleBody;
+ break;
+ }
- if (textStyle) {
- UIFontDescriptor *desc = [UIFontDescriptor preferredFontDescriptorWithTextStyle:textStyle];
- return static_cast<CTFontDescriptorRef>(CFBridgingRetain(desc));
- }
+ if (textStyle) {
+ UIFontDescriptor *desc = [UIFontDescriptor preferredFontDescriptorWithTextStyle:textStyle];
+ return static_cast<CTFontDescriptorRef>(CFBridgingRetain(desc));
}
-#endif // Q_OS_IOS
+#endif // Q_OS_IOS, Q_OS_TVOS
// OSX default case and iOS fallback case
CTFontUIFontType fontType = fontTypeFromTheme(f);
@@ -953,31 +878,15 @@ void QCoreTextFontDatabase::removeApplicationFonts()
return;
foreach (const QVariant &font, m_applicationFonts) {
-#if HAVE_CORETEXT
- if (&CTFontManagerUnregisterGraphicsFont && &CTFontManagerUnregisterFontsForURL) {
- CFErrorRef error;
- if (font.canConvert(qMetaTypeId<QCFType<CGFontRef> >())) {
- CTFontManagerUnregisterGraphicsFont(font.value<QCFType<CGFontRef> >(), &error);
- } else if (font.canConvert(qMetaTypeId<QCFType<CFURLRef> >())) {
- CTFontManagerUnregisterFontsForURL(font.value<QCFType<CFURLRef> >(), kCTFontManagerScopeProcess, &error);
- }
+ CFErrorRef error;
+ if (font.canConvert(qMetaTypeId<QCFType<CGFontRef> >())) {
+ CTFontManagerUnregisterGraphicsFont(font.value<QCFType<CGFontRef> >(), &error);
+ } else if (font.canConvert(qMetaTypeId<QCFType<CFURLRef> >())) {
+ CTFontManagerUnregisterFontsForURL(font.value<QCFType<CFURLRef> >(), kCTFontManagerScopeProcess, &error);
}
-#endif
-#if HAVE_CORETEXT && HAVE_ATS
- else
-#endif
-#if HAVE_ATS
- if (font.canConvert(qMetaTypeId<ATSFontContainerRef>())) {
- ATSFontDeactivate(font.value<ATSFontContainerRef>(), 0, kATSOptionFlagsDoNotNotify);
- }
-#endif
}
m_applicationFonts.clear();
-
-#if HAVE_ATS
- ATSFontNotify(kATSFontNotifyActionFontsChanged, 0);
-#endif
}
#ifndef QT_NO_FREETYPE
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
index 2cc6b09a15..1bc3522bda 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase_p.h
@@ -52,27 +52,20 @@
//
#include <qglobal.h>
-#define HAVE_CORETEXT QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_8, __IPHONE_4_1)
-#define HAVE_ATS QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_5, __IPHONE_NA)
#include <qpa/qplatformfontdatabase.h>
#include <qpa/qplatformtheme.h>
#include <private/qcore_mac_p.h>
-#ifndef Q_OS_IOS
+#ifdef Q_OS_OSX
#include <ApplicationServices/ApplicationServices.h>
#else
#include <CoreText/CoreText.h>
#include <CoreGraphics/CoreGraphics.h>
#endif
-#if HAVE_CORETEXT
Q_DECLARE_METATYPE(QCFType<CGFontRef>);
Q_DECLARE_METATYPE(QCFType<CFURLRef>);
-#endif
-#if HAVE_ATS
-Q_DECLARE_METATYPE(ATSFontContainerRef);
-#endif
QT_BEGIN_NAMESPACE
diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
index d11676ced7..fbad61af43 100644
--- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
+++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm
@@ -51,7 +51,7 @@
#import <AppKit/AppKit.h>
#endif
-#if defined(Q_OS_IOS) && !QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_8_2)
+#if defined(QT_PLATFORM_UIKIT) && !QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_8_2)
#import <UIKit/UIKit.h>
#endif
@@ -78,7 +78,7 @@
#define kCTFontWeightBold NSFontWeightBold
#define kCTFontWeightHeavy NSFontWeightHeavy
#define kCTFontWeightBlack NSFontWeightBlack
-#elif defined(Q_OS_IOS)
+#elif defined(QT_PLATFORM_UIKIT)
#define kCTFontWeightUltraLight UIFontWeightUltraLight
#define kCTFontWeightThin UIFontWeightThin
#define kCTFontWeightLight UIFontWeightLight
@@ -256,6 +256,9 @@ void QCoreTextFontEngine::init()
} else
avgCharWidth = QFontEngine::averageCharWidth();
+ underlineThickness = QFixed::fromReal(CTFontGetUnderlineThickness(ctfont));
+ underlinePos = -QFixed::fromReal(CTFontGetUnderlinePosition(ctfont));
+
cache_cost = (CTFontGetAscent(ctfont) + CTFontGetDescent(ctfont)) * avgCharWidth.toInt() * 2000;
// HACK hb_coretext requires both CTFont and CGFont but user_data is only void*
@@ -437,31 +440,25 @@ void QCoreTextFontEngine::draw(CGContextRef ctx, qreal x, qreal y, const QTextIt
CGContextSetTextDrawingMode(ctx, kCGTextFill);
-
- QVarLengthArray<CGSize> advances(glyphs.size());
+ QVarLengthArray<CGPoint> cgPositions(glyphs.size());
QVarLengthArray<CGGlyph> cgGlyphs(glyphs.size());
-
- for (int i = 0; i < glyphs.size() - 1; ++i) {
- advances[i].width = (positions[i + 1].x - positions[i].x).toReal();
- advances[i].height = (positions[i + 1].y - positions[i].y).toReal();
+ const qreal firstX = positions[0].x.toReal();
+ const qreal firstY = positions[0].y.toReal();
+ for (int i = 0; i < glyphs.size(); ++i) {
+ cgPositions[i].x = positions[i].x.toReal() - firstX;
+ cgPositions[i].y = positions[i].y.toReal() - firstY;
cgGlyphs[i] = glyphs[i];
}
- advances[glyphs.size() - 1].width = 0;
- advances[glyphs.size() - 1].height = 0;
- cgGlyphs[glyphs.size() - 1] = glyphs[glyphs.size() - 1];
- CGContextSetFont(ctx, cgFont);
//NSLog(@"Font inDraw %@ ctfont %@", CGFontCopyFullName(cgFont), CTFontCopyFamilyName(ctfont));
CGContextSetTextPosition(ctx, positions[0].x.toReal(), positions[0].y.toReal());
-
- CGContextShowGlyphsWithAdvances(ctx, cgGlyphs.data(), advances.data(), glyphs.size());
+ CTFontDrawGlyphs(ctfont, cgGlyphs.data(), cgPositions.data(), glyphs.size(), ctx);
if (synthesisFlags & QFontEngine::SynthesizedBold) {
CGContextSetTextPosition(ctx, positions[0].x.toReal() + 0.5 * lineThickness().toReal(),
positions[0].y.toReal());
-
- CGContextShowGlyphsWithAdvances(ctx, cgGlyphs.data(), advances.data(), glyphs.size());
+ CTFontDrawGlyphs(ctfont, cgGlyphs.data(), cgPositions.data(), glyphs.size(), ctx);
}
CGContextSetTextMatrix(ctx, oldTextMatrix);
@@ -606,7 +603,7 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition
if (!im.width() || !im.height())
return im;
-#ifndef Q_OS_IOS
+#ifdef Q_OS_OSX
CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
#else
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
@@ -645,14 +642,13 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition
CGContextSetTextMatrix(ctx, cgMatrix);
CGContextSetRGBFillColor(ctx, 1, 1, 1, 1);
CGContextSetTextDrawingMode(ctx, kCGTextFill);
- CGContextSetFont(ctx, cgFont);
CGContextSetTextPosition(ctx, pos_x, pos_y);
- CGContextShowGlyphsWithAdvances(ctx, &cgGlyph, &CGSizeZero, 1);
+ CTFontDrawGlyphs(ctfont, &cgGlyph, &CGPointZero, 1, ctx);
if (synthesisFlags & QFontEngine::SynthesizedBold) {
CGContextSetTextPosition(ctx, pos_x + 0.5 * lineThickness().toReal(), pos_y);
- CGContextShowGlyphsWithAdvances(ctx, &cgGlyph, &CGSizeZero, 1);
+ CTFontDrawGlyphs(ctfont, &cgGlyph, &CGPointZero, 1, ctx);
}
} else {
// CGContextSetTextMatrix does not work with color glyphs, so we use
@@ -800,6 +796,16 @@ bool QCoreTextFontEngine::supportsTransformation(const QTransform &transform) co
return false;
}
+QFixed QCoreTextFontEngine::lineThickness() const
+{
+ return underlineThickness;
+}
+
+QFixed QCoreTextFontEngine::underlinePosition() const
+{
+ return underlinePos;
+}
+
QFontEngine::Properties QCoreTextFontEngine::properties() const
{
Properties result;
diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
index 22008162f7..b7c9edc528 100644
--- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
+++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext_p.h
@@ -54,7 +54,7 @@
#include <private/qfontengine_p.h>
#include <private/qcore_mac_p.h>
-#ifndef Q_OS_IOS
+#ifdef Q_OS_OSX
#include <ApplicationServices/ApplicationServices.h>
#else
#include <CoreText/CoreText.h>
@@ -92,6 +92,9 @@ public:
int synthesized() const Q_DECL_OVERRIDE { return synthesisFlags; }
bool supportsSubPixelPositions() const Q_DECL_OVERRIDE { return true; }
+ QFixed lineThickness() const Q_DECL_OVERRIDE;
+ QFixed underlinePosition() const Q_DECL_OVERRIDE;
+
void draw(CGContextRef ctx, qreal x, qreal y, const QTextItemInt &ti, int paintDeviceHeight);
FaceId faceId() const Q_DECL_OVERRIDE;
@@ -126,6 +129,8 @@ private:
int synthesisFlags;
CGAffineTransform transform;
QFixed avgCharWidth;
+ QFixed underlineThickness;
+ QFixed underlinePos;
QFontEngine::FaceId face_id;
mutable bool kerningPairsLoaded;
};
diff --git a/src/platformsupport/graphics/qrasterbackingstore.cpp b/src/platformsupport/graphics/qrasterbackingstore.cpp
index 3b1a87b8cd..58e811dff1 100644
--- a/src/platformsupport/graphics/qrasterbackingstore.cpp
+++ b/src/platformsupport/graphics/qrasterbackingstore.cpp
@@ -89,7 +89,7 @@ bool QRasterBackingStore::scroll(const QRegion &region, int dx, int dy)
const qreal devicePixelRatio = m_image.devicePixelRatio();
const QPoint delta(dx * devicePixelRatio, dy * devicePixelRatio);
- foreach (const QRect &rect, region.rects())
+ for (const QRect &rect : region)
qt_scrollRectInImage(m_image, QRect(rect.topLeft() * devicePixelRatio, rect.size() * devicePixelRatio), delta);
return true;
@@ -103,7 +103,7 @@ void QRasterBackingStore::beginPaint(const QRegion &region)
QPainter painter(&m_image);
painter.setCompositionMode(QPainter::CompositionMode_Source);
const QColor blank = Qt::transparent;
- foreach (const QRect &rect, region.rects())
+ for (const QRect &rect : region)
painter.fillRect(rect, blank);
}
diff --git a/src/platformsupport/input/evdevtouch/evdevtouch.pri b/src/platformsupport/input/evdevtouch/evdevtouch.pri
index c2edc13143..44eb9da113 100644
--- a/src/platformsupport/input/evdevtouch/evdevtouch.pri
+++ b/src/platformsupport/input/evdevtouch/evdevtouch.pri
@@ -6,6 +6,8 @@ SOURCES += \
$$PWD/qevdevtouchhandler.cpp \
$$PWD/qevdevtouchmanager.cpp
+INCLUDEPATH += $$PWD/../shared
+
contains(QT_CONFIG, libudev) {
LIBS_PRIVATE += $$QMAKE_LIBS_LIBUDEV
}
@@ -14,4 +16,3 @@ contains(QT_CONFIG, mtdev) {
CONFIG += link_pkgconfig
PKGCONFIG_PRIVATE += mtdev
}
-
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
index 435f411f96..f9e81e840f 100644
--- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
+++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
@@ -38,6 +38,7 @@
****************************************************************************/
#include "qevdevtouchhandler_p.h"
+#include "qtouchoutputmapping_p.h"
#include <QStringList>
#include <QHash>
#include <QSocketNotifier>
@@ -116,6 +117,7 @@ public:
int findClosestContact(const QHash<int, Contact> &contacts, int x, int y, int *dist);
void addTouchPoint(const Contact &contact, Qt::TouchPointStates *combinedStates);
void reportPoints();
+ void loadMultiScreenMappings();
int hw_range_x_min;
int hw_range_x_max;
@@ -124,10 +126,12 @@ public:
int hw_pressure_min;
int hw_pressure_max;
QString hw_name;
+ QString deviceNode;
bool m_forceToActiveWindow;
bool m_typeB;
QTransform m_rotate;
bool m_singleTouch;
+ int m_screenIndex;
};
QEvdevTouchScreenData::QEvdevTouchScreenData(QEvdevTouchScreenHandler *q_ptr, const QStringList &args)
@@ -137,7 +141,8 @@ QEvdevTouchScreenData::QEvdevTouchScreenData(QEvdevTouchScreenHandler *q_ptr, co
hw_range_x_min(0), hw_range_x_max(0),
hw_range_y_min(0), hw_range_y_max(0),
hw_pressure_min(0), hw_pressure_max(0),
- m_typeB(false), m_singleTouch(false)
+ m_typeB(false), m_singleTouch(false),
+ m_screenIndex(-1)
{
m_forceToActiveWindow = args.contains(QLatin1String("force_window"));
}
@@ -222,7 +227,9 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const
}
#endif
- qCDebug(qLcEvdevTouch, "evdevtouch: %s: Protocol type %c %s (%s)", qPrintable(device),
+ d->deviceNode = device;
+
+ qCDebug(qLcEvdevTouch, "evdevtouch: %s: Protocol type %c %s (%s)", qPrintable(d->deviceNode),
d->m_typeB ? 'B' : 'A', mtdevStr, d->m_singleTouch ? "single" : "multi");
input_absinfo absInfo;
@@ -292,6 +299,14 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const
if (inverty)
d->m_rotate *= QTransform::fromTranslate(0.5, 0.5).scale(1.0, -1.0).translate(-0.5, -0.5);
+ QTouchOutputMapping mapping;
+ if (mapping.load()) {
+ d->m_screenIndex = mapping.screenIndexForDeviceNode(d->deviceNode);
+ if (d->m_screenIndex >= 0)
+ qCDebug(qLcEvdevTouch, "evdevtouch: Mapping device %s to screen index %d",
+ qPrintable(d->deviceNode), d->m_screenIndex);
+ }
+
registerTouchDevice();
}
@@ -647,8 +662,23 @@ void QEvdevTouchScreenData::reportPoints()
return;
winRect = QHighDpi::toNativePixels(win->geometry(), win);
} else {
- QScreen *primary = QGuiApplication::primaryScreen();
- winRect = QHighDpi::toNativePixels(primary->geometry(), primary);
+ // Now it becomes tricky. Traditionally we picked the primaryScreen()
+ // and were done with it. But then, enter multiple screens, and
+ // suddenly it was all broken.
+ //
+ // For now we only support the display configuration of the KMS/DRM
+ // backends of eglfs. See QTouchOutputMapping.
+ //
+ // The good news it that once winRect refers to the correct screen
+ // geometry in the full virtual desktop space, there is nothing else
+ // left to do since qguiapp will handle the rest.
+ QScreen *screen = QGuiApplication::primaryScreen();
+ if (m_screenIndex >= 0) {
+ const QList<QScreen *> screens = QGuiApplication::screens();
+ if (m_screenIndex < screens.count())
+ screen = screens.at(m_screenIndex);
+ }
+ winRect = QHighDpi::toNativePixels(screen->geometry(), screen);
}
const int hw_w = hw_range_x_max - hw_range_x_min;
@@ -679,10 +709,12 @@ void QEvdevTouchScreenData::reportPoints()
tp.pressure = (tp.pressure - hw_pressure_min) / qreal(hw_pressure_max - hw_pressure_min);
}
+ // Let qguiapp pick the target window.
QWindowSystemInterface::handleTouchEvent(Q_NULLPTR, q->touchDevice(), m_touchPoints);
}
+
QEvdevTouchScreenHandlerThread::QEvdevTouchScreenHandlerThread(const QString &device, const QString &spec, QObject *parent)
: QDaemonThread(parent), m_device(device), m_spec(spec), m_handler(Q_NULLPTR), m_touchDeviceRegistered(false)
{
diff --git a/src/platformsupport/input/input.pri b/src/platformsupport/input/input.pri
index 3b9593eb31..5ce9e6844f 100644
--- a/src/platformsupport/input/input.pri
+++ b/src/platformsupport/input/input.pri
@@ -12,3 +12,7 @@ contains(QT_CONFIG, tslib) {
contains(QT_CONFIG, libinput) {
include($$PWD/libinput/libinput.pri)
}
+
+contains(QT_CONFIG, evdev)|contains(QT_CONFIG, libinput) {
+ include($$PWD/shared/shared.pri)
+}
diff --git a/src/platformsupport/input/libinput/libinput.pri b/src/platformsupport/input/libinput/libinput.pri
index 35d962ff3c..aeba6c725a 100644
--- a/src/platformsupport/input/libinput/libinput.pri
+++ b/src/platformsupport/input/libinput/libinput.pri
@@ -13,6 +13,8 @@ SOURCES += \
INCLUDEPATH += $$QMAKE_INCDIR_LIBUDEV $$QMAKE_INCDIR_LIBINPUT
LIBS_PRIVATE += $$QMAKE_LIBS_LIBUDEV $$QMAKE_LIBS_LIBINPUT
+INCLUDEPATH += $$PWD/../shared
+
contains(QT_CONFIG, xkbcommon-evdev) {
INCLUDEPATH += $$QMAKE_INCDIR_XKBCOMMON_EVDEV
LIBS_PRIVATE += $$QMAKE_LIBS_XKBCOMMON_EVDEV
diff --git a/src/platformsupport/input/libinput/qlibinputtouch.cpp b/src/platformsupport/input/libinput/qlibinputtouch.cpp
index 0a0e9daccb..42925a18e1 100644
--- a/src/platformsupport/input/libinput/qlibinputtouch.cpp
+++ b/src/platformsupport/input/libinput/qlibinputtouch.cpp
@@ -41,6 +41,7 @@
#include <libinput.h>
#include <QtGui/QGuiApplication>
#include <QtGui/QScreen>
+#include <QtGui/private/qhighdpiscaling_p.h>
QT_BEGIN_NAMESPACE
@@ -63,10 +64,14 @@ QLibInputTouch::DeviceState *QLibInputTouch::deviceState(libinput_event_touch *e
static inline QPointF getPos(libinput_event_touch *e)
{
- const QSize screenSize = QGuiApplication::primaryScreen()->geometry().size();
- const double x = libinput_event_touch_get_x_transformed(e, screenSize.width());
- const double y = libinput_event_touch_get_y_transformed(e, screenSize.height());
- return QPointF(x, y);
+ // TODO Map to correct screen using QTouchOutputMapping.
+ // Perhaps investigate libinput_device_get_output_name as well.
+ // For now just use the primary screen.
+ QScreen *screen = QGuiApplication::primaryScreen();
+ const QRect geom = QHighDpi::toNativePixels(screen->geometry(), screen);
+ const double x = libinput_event_touch_get_x_transformed(e, geom.width());
+ const double y = libinput_event_touch_get_y_transformed(e, geom.height());
+ return geom.topLeft() + QPointF(x, y);
}
void QLibInputTouch::registerDevice(libinput_device *dev)
diff --git a/src/corelib/tools/qbytearray_mac.mm b/src/platformsupport/input/shared/qtouchoutputmapping.cpp
index 9386a966f0..55c1dc34f4 100644
--- a/src/corelib/tools/qbytearray_mac.mm
+++ b/src/platformsupport/input/shared/qtouchoutputmapping.cpp
@@ -1,10 +1,9 @@
/****************************************************************************
**
-** Copyright (C) 2014 Samuel Gaist <samuel.gaist@edeltech.ch>
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the QtCore module of the Qt Toolkit.
+** This file is part of the plugins module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -38,62 +37,55 @@
**
****************************************************************************/
-#include "qbytearray.h"
-
-#import <Foundation/Foundation.h>
+#include "qtouchoutputmapping_p.h"
+#include <QFile>
+#include <QVariantMap>
+#include <QJsonDocument>
+#include <QJsonObject>
+#include <QJsonArray>
QT_BEGIN_NAMESPACE
-QByteArray QByteArray::fromCFData(CFDataRef data)
+bool QTouchOutputMapping::load()
{
- if (!data)
- return QByteArray();
+ static QByteArray configFile = qgetenv("QT_QPA_EGLFS_KMS_CONFIG");
+ if (configFile.isEmpty())
+ return false;
- return QByteArray(reinterpret_cast<const char *>(CFDataGetBytePtr(data)), CFDataGetLength(data));
-}
+ QFile file(QString::fromUtf8(configFile));
+ if (!file.open(QFile::ReadOnly)) {
+ qWarning("touch input support: Failed to open %s", configFile.constData());
+ return false;
+ }
-QByteArray QByteArray::fromRawCFData(CFDataRef data)
-{
- if (!data)
- return QByteArray();
+ const QJsonDocument doc = QJsonDocument::fromJson(file.readAll());
+ if (!doc.isObject()) {
+ qWarning("touch input support: Failed to parse %s", configFile.constData());
+ return false;
+ }
- return QByteArray::fromRawData(reinterpret_cast<const char *>(CFDataGetBytePtr(data)), CFDataGetLength(data));
-}
+ // What we are interested is the virtualIndex and touchDevice properties for
+ // each element in the outputs array.
+ const QJsonArray outputs = doc.object().value(QLatin1String("outputs")).toArray();
+ for (int i = 0; i < outputs.size(); ++i) {
+ const QVariantMap output = outputs.at(i).toObject().toVariantMap();
+ if (!output.contains(QStringLiteral("touchDevice")))
+ continue;
+ if (!output.contains(QStringLiteral("virtualIndex"))) {
+ qWarning("evdevtouch: Output %d specifies touchDevice but not virtualIndex, this is wrong", i);
+ continue;
+ }
+ const QString &deviceNode = output.value(QStringLiteral("touchDevice")).toString();
+ const int screenIndex = output.value(QStringLiteral("virtualIndex")).toInt();
+ m_screenIndexTable.insert(deviceNode, screenIndex);
+ }
-CFDataRef QByteArray::toCFData() const
-{
- return CFDataCreate(kCFAllocatorDefault, reinterpret_cast<const UInt8 *>(data()), length());
-}
-
-CFDataRef QByteArray::toRawCFData() const
-{
- return CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const UInt8 *>(data()),
- length(), kCFAllocatorNull);
-}
-
-QByteArray QByteArray::fromNSData(const NSData *data)
-{
- if (!data)
- return QByteArray();
- return QByteArray(reinterpret_cast<const char *>([data bytes]), [data length]);
-}
-
-QByteArray QByteArray::fromRawNSData(const NSData *data)
-{
- if (!data)
- return QByteArray();
- return QByteArray::fromRawData(reinterpret_cast<const char *>([data bytes]), [data length]);
-}
-
-NSData *QByteArray::toNSData() const
-{
- return [NSData dataWithBytes:constData() length:size()];
+ return true;
}
-NSData *QByteArray::toRawNSData() const
+int QTouchOutputMapping::screenIndexForDeviceNode(const QString &deviceNode)
{
- // const_cast is fine here because NSData is immutable thus will never modify bytes we're giving it
- return [NSData dataWithBytesNoCopy:const_cast<char *>(constData()) length:size() freeWhenDone:NO];
+ return m_screenIndexTable.value(deviceNode, -1);
}
QT_END_NAMESPACE
diff --git a/src/gui/image/qnativeimage_p.h b/src/platformsupport/input/shared/qtouchoutputmapping_p.h
index 2398a6e2ce..74999d93ce 100644
--- a/src/gui/image/qnativeimage_p.h
+++ b/src/platformsupport/input/shared/qtouchoutputmapping_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
-** This file is part of the QtGui module of the Qt Toolkit.
+** This file is part of the plugins module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QNATIVEIMAGE_P_H
-#define QNATIVEIMAGE_P_H
+#ifndef QTOUCHOUTPUTMAPPING_P_H
+#define QTOUCHOUTPUTMAPPING_P_H
//
// W A R N I N G
@@ -51,34 +51,21 @@
// We mean it.
//
-#include "qimage.h"
-
+#include <QString>
+#include <QHash>
QT_BEGIN_NAMESPACE
-class QWindow;
-
-class QNativeImage
+class QTouchOutputMapping
{
public:
- QNativeImage(int width, int height, QImage::Format format, bool isTextBuffer = false, QWindow *window = 0);
- ~QNativeImage();
-
- inline int width() const;
- inline int height() const;
-
- QImage image;
-
- static QImage::Format systemFormat();
-
+ bool load();
+ int screenIndexForDeviceNode(const QString &deviceNode);
private:
- Q_DISABLE_COPY(QNativeImage)
+ QHash<QString, int> m_screenIndexTable;
};
-inline int QNativeImage::width() const { return image.width(); }
-inline int QNativeImage::height() const { return image.height(); }
-
QT_END_NAMESPACE
-#endif // QNATIVEIMAGE_P_H
+#endif // QTOUCHOUTPUTMAPPING_P_H
diff --git a/src/platformsupport/input/shared/shared.pri b/src/platformsupport/input/shared/shared.pri
new file mode 100644
index 0000000000..1443235244
--- /dev/null
+++ b/src/platformsupport/input/shared/shared.pri
@@ -0,0 +1,5 @@
+HEADERS += \
+ $$PWD/qtouchoutputmapping_p.h
+
+SOURCES += \
+ $$PWD/qtouchoutputmapping.cpp
diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
index 8366c56a09..f6c126a771 100644
--- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
+++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp
@@ -778,9 +778,8 @@ void AtSpiAdaptor::updateEventListeners()
QDBusReply<QSpiEventListenerArray> listenersReply = m_dbus->connection().call(m);
if (listenersReply.isValid()) {
const QSpiEventListenerArray evList = listenersReply.value();
- Q_FOREACH (const QSpiEventListener &ev, evList) {
+ for (const QSpiEventListener &ev : evList)
setBitFlag(ev.eventName);
- }
m_applicationAdaptor->sendEvents(!evList.isEmpty());
} else {
qAtspiDebug("Could not query active accessibility event listeners.");
@@ -1508,11 +1507,10 @@ QStringList AtSpiAdaptor::accessibleInterfaces(QAccessibleInterface *interface)
QSpiRelationArray AtSpiAdaptor::relationSet(QAccessibleInterface *interface, const QDBusConnection &connection) const
{
typedef QPair<QAccessibleInterface*, QAccessible::Relation> RelationPair;
- QVector<RelationPair> relationInterfaces;
- relationInterfaces = interface->relations();
+ const QVector<RelationPair> relationInterfaces = interface->relations();
QSpiRelationArray relations;
- Q_FOREACH (const RelationPair &pair, relationInterfaces) {
+ for (const RelationPair &pair : relationInterfaces) {
// FIXME: this loop seems a bit strange... "related" always have one item when we check.
//And why is it a list, when it always have one item? And it seems to assume that the QAccessible::Relation enum maps directly to AtSpi
QSpiObjectReferenceArray related;
@@ -1757,24 +1755,20 @@ QSpiActionArray AtSpiAdaptor::getActions(QAccessibleInterface *interface) const
QSpiActionArray actions;
const QStringList actionNames = QAccessibleBridgeUtils::effectiveActionNames(interface);
actions.reserve(actionNames.size());
- Q_FOREACH (const QString &actionName, actionNames) {
+ for (const QString &actionName : actionNames) {
QSpiAction action;
- QStringList keyBindings;
action.name = actionName;
if (actionInterface) {
action.description = actionInterface->localizedActionDescription(actionName);
- keyBindings = actionInterface->keyBindingsForAction(actionName);
+ const QStringList keyBindings = actionInterface->keyBindingsForAction(actionName);
+ if (!keyBindings.isEmpty())
+ action.keyBinding = keyBindings.front();
} else {
action.description = qAccessibleLocalizedActionDescription(actionName);
}
- if (keyBindings.length() > 0)
- action.keyBinding = keyBindings[0];
- else
- action.keyBinding = QString();
-
- actions << action;
+ actions.append(std::move(action));
}
return actions;
}
diff --git a/src/platformsupport/platformcompositor/qopenglcompositor.cpp b/src/platformsupport/platformcompositor/qopenglcompositor.cpp
index 610619a4e4..0f4946f81a 100644
--- a/src/platformsupport/platformcompositor/qopenglcompositor.cpp
+++ b/src/platformsupport/platformcompositor/qopenglcompositor.cpp
@@ -40,7 +40,6 @@
#include <QtGui/QOpenGLContext>
#include <QtGui/QOpenGLFramebufferObject>
#include <QtGui/QWindow>
-#include <QtGui/QMatrix4x4>
#include <qpa/qplatformbackingstore.h>
#include "qopenglcompositor_p.h"
@@ -78,7 +77,8 @@ static QOpenGLCompositor *compositor = 0;
QOpenGLCompositor::QOpenGLCompositor()
: m_context(0),
- m_targetWindow(0)
+ m_targetWindow(0),
+ m_rotation(0)
{
Q_ASSERT(!compositor);
m_updateTimer.setSingleShot(true);
@@ -93,10 +93,19 @@ QOpenGLCompositor::~QOpenGLCompositor()
compositor = 0;
}
-void QOpenGLCompositor::setTarget(QOpenGLContext *context, QWindow *targetWindow)
+void QOpenGLCompositor::setTarget(QOpenGLContext *context, QWindow *targetWindow,
+ const QRect &nativeTargetGeometry)
{
m_context = context;
m_targetWindow = targetWindow;
+ m_nativeTargetGeometry = nativeTargetGeometry;
+}
+
+void QOpenGLCompositor::setRotation(int degrees)
+{
+ m_rotation = degrees;
+ m_rotationMatrix.setToIdentity();
+ m_rotationMatrix.rotate(degrees, 0, 0, 1);
}
void QOpenGLCompositor::update()
@@ -109,7 +118,7 @@ QImage QOpenGLCompositor::grab()
{
Q_ASSERT(m_context && m_targetWindow);
m_context->makeCurrent(m_targetWindow);
- QScopedPointer<QOpenGLFramebufferObject> fbo(new QOpenGLFramebufferObject(m_targetWindow->geometry().size()));
+ QScopedPointer<QOpenGLFramebufferObject> fbo(new QOpenGLFramebufferObject(m_nativeTargetGeometry.size()));
renderAll(fbo.data());
return fbo->toImage();
}
@@ -127,9 +136,7 @@ void QOpenGLCompositor::renderAll(QOpenGLFramebufferObject *fbo)
fbo->bind();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
-
- const QRect targetWindowRect(QPoint(0, 0), m_targetWindow->geometry().size());
- glViewport(0, 0, targetWindowRect.width(), targetWindowRect.height());
+ glViewport(0, 0, m_nativeTargetGeometry.width(), m_nativeTargetGeometry.height());
if (!m_blitter.isCreated())
m_blitter.create();
@@ -181,7 +188,8 @@ static inline QRect toBottomLeftRect(const QRect &topLeftRect, int windowHeight)
topLeftRect.width(), topLeftRect.height());
}
-static void clippedBlit(const QPlatformTextureList *textures, int idx, const QRect &targetWindowRect, QOpenGLTextureBlitter *blitter)
+static void clippedBlit(const QPlatformTextureList *textures, int idx, const QRect &targetWindowRect,
+ QOpenGLTextureBlitter *blitter, QMatrix4x4 *rotationMatrix)
{
const QRect clipRect = textures->clipRect(idx);
if (clipRect.isEmpty())
@@ -191,7 +199,10 @@ static void clippedBlit(const QPlatformTextureList *textures, int idx, const QRe
const QRect clippedRectInWindow = rectInWindow & clipRect.translated(rectInWindow.topLeft());
const QRect srcRect = toBottomLeftRect(clipRect, rectInWindow.height());
- const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(clippedRectInWindow, targetWindowRect);
+ QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(clippedRectInWindow, targetWindowRect);
+ if (rotationMatrix)
+ target = *rotationMatrix * target;
+
const QMatrix3x3 source = QOpenGLTextureBlitter::sourceTransform(srcRect, rectInWindow.size(),
QOpenGLTextureBlitter::OriginBottomLeft);
@@ -219,25 +230,29 @@ void QOpenGLCompositor::render(QOpenGLCompositorWindow *window)
if (textures->count() > 1 && i == textures->count() - 1) {
// Backingstore for a widget with QOpenGLWidget subwidgets
blend.set(true);
- const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect);
+ QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect);
+ if (m_rotation)
+ target = m_rotationMatrix * target;
m_blitter.blit(textureId, target, QOpenGLTextureBlitter::OriginTopLeft);
} else if (textures->count() == 1) {
// A regular QWidget window
const bool translucent = window->sourceWindow()->requestedFormat().alphaBufferSize() > 0;
blend.set(translucent);
- const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect);
+ QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(textures->geometry(i), targetWindowRect);
+ if (m_rotation)
+ target = m_rotationMatrix * target;
m_blitter.blit(textureId, target, QOpenGLTextureBlitter::OriginTopLeft);
} else if (!textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop)) {
// Texture from an FBO belonging to a QOpenGLWidget
blend.set(false);
- clippedBlit(textures, i, targetWindowRect, &m_blitter);
+ clippedBlit(textures, i, targetWindowRect, &m_blitter, m_rotation ? &m_rotationMatrix : nullptr);
}
}
for (int i = 0; i < textures->count(); ++i) {
if (textures->flags(i).testFlag(QPlatformTextureList::StacksOnTop)) {
blend.set(true);
- clippedBlit(textures, i, targetWindowRect, &m_blitter);
+ clippedBlit(textures, i, targetWindowRect, &m_blitter, m_rotation ? &m_rotationMatrix : nullptr);
}
}
diff --git a/src/platformsupport/platformcompositor/qopenglcompositor_p.h b/src/platformsupport/platformcompositor/qopenglcompositor_p.h
index 2c34fba409..dece41f676 100644
--- a/src/platformsupport/platformcompositor/qopenglcompositor_p.h
+++ b/src/platformsupport/platformcompositor/qopenglcompositor_p.h
@@ -52,7 +52,8 @@
//
#include <QtCore/QTimer>
-#include <QtGui/private/qopengltextureblitter_p.h>
+#include <QtGui/QOpenGLTextureBlitter>
+#include <QtGui/QMatrix4x4>
QT_BEGIN_NAMESPACE
@@ -78,7 +79,8 @@ public:
static QOpenGLCompositor *instance();
static void destroy();
- void setTarget(QOpenGLContext *context, QWindow *window);
+ void setTarget(QOpenGLContext *context, QWindow *window, const QRect &nativeTargetGeometry);
+ void setRotation(int degrees);
QOpenGLContext *context() const { return m_context; }
QWindow *targetWindow() const { return m_targetWindow; }
@@ -106,6 +108,9 @@ private:
QOpenGLContext *m_context;
QWindow *m_targetWindow;
+ QRect m_nativeTargetGeometry;
+ int m_rotation;
+ QMatrix4x4 m_rotationMatrix;
QTimer m_updateTimer;
QOpenGLTextureBlitter m_blitter;
QList<QOpenGLCompositorWindow *> m_windows;
diff --git a/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp b/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
index 7c29be7804..dbaaf524e8 100644
--- a/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
+++ b/src/platformsupport/platformcompositor/qopenglcompositorbackingstore.cpp
@@ -140,7 +140,7 @@ void QOpenGLCompositorBackingStore::updateTexture()
QOpenGLContext *ctx = QOpenGLContext::currentContext();
if (!ctx->isOpenGLES() || ctx->format().majorVersion() >= 3) {
- foreach (const QRect &rect, m_dirty.rects()) {
+ for (const QRect &rect : m_dirty) {
QRect r = imageRect & rect;
glPixelStorei(GL_UNPACK_ROW_LENGTH, m_image.width());
glTexSubImage2D(GL_TEXTURE_2D, 0, r.x(), r.y(), r.width(), r.height(), GL_RGBA, GL_UNSIGNED_BYTE,
@@ -148,7 +148,7 @@ void QOpenGLCompositorBackingStore::updateTexture()
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
}
} else {
- foreach (const QRect &rect, m_dirty.rects()) {
+ for (const QRect &rect : m_dirty) {
// intersect with image rect to be sure
QRect r = imageRect & rect;
@@ -161,7 +161,7 @@ void QOpenGLCompositorBackingStore::updateTexture()
fixed |= r;
}
- foreach (const QRect &rect, fixed.rects()) {
+ for (const QRect &rect : fixed) {
// if the sub-rect is full-width we can pass the image data directly to
// OpenGL instead of copying, since there's no gap between scanlines
if (rect.width() == imageRect.width()) {
@@ -258,7 +258,7 @@ void QOpenGLCompositorBackingStore::beginPaint(const QRegion &region)
if (m_image.hasAlphaChannel()) {
QPainter p(&m_image);
p.setCompositionMode(QPainter::CompositionMode_Source);
- foreach (const QRect &r, region.rects())
+ for (const QRect &r : region)
p.fillRect(r, Qt::transparent);
}
}
diff --git a/src/platformsupport/platformsupport.pro b/src/platformsupport/platformsupport.pro
index 60be964b74..9f6f3380e1 100644
--- a/src/platformsupport/platformsupport.pro
+++ b/src/platformsupport/platformsupport.pro
@@ -29,6 +29,6 @@ include(platformcompositor/platformcompositor.pri)
include(dbusmenu/dbusmenu.pri)
include(dbustray/dbustray.pri)
}
-ios: include(graphics/graphics.pri)
+uikit: include(graphics/graphics.pri)
load(qt_module)
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
index 9abcd04063..a5001f6e80 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
@@ -50,6 +50,7 @@
#include <QtCore/QFile>
#include <QtCore/QDebug>
#include <QtCore/QHash>
+#include <QtCore/QMimeDatabase>
#include <QtCore/QLoggingCategory>
#include <QtCore/QSettings>
#include <QtCore/QVariant>
@@ -231,6 +232,28 @@ QVariant QGenericUnixTheme::themeHint(ThemeHint hint) const
return QPlatformTheme::themeHint(hint);
}
+// Helper functions for implementing QPlatformTheme::fileIcon() for XDG icon themes.
+static QList<QSize> availableXdgFileIconSizes()
+{
+ return QIcon::fromTheme(QStringLiteral("inode-directory")).availableSizes();
+}
+
+static QIcon xdgFileIcon(const QFileInfo &fileInfo)
+{
+ QMimeDatabase mimeDatabase;
+ QMimeType mimeType = mimeDatabase.mimeTypeForFile(fileInfo);
+ if (!mimeType.isValid())
+ return QIcon();
+ const QString &iconName = mimeType.iconName();
+ if (!iconName.isEmpty()) {
+ const QIcon icon = QIcon::fromTheme(iconName);
+ if (!icon.isNull())
+ return icon;
+ }
+ const QString &genericIconName = mimeType.genericIconName();
+ return genericIconName.isEmpty() ? QIcon() : QIcon::fromTheme(genericIconName);
+}
+
#ifndef QT_NO_SETTINGS
class QKdeThemePrivate : public QPlatformThemePrivate
{
@@ -506,6 +529,8 @@ QVariant QKdeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
return QVariant(d->iconFallbackThemeName);
case QPlatformTheme::IconThemeSearchPaths:
return QVariant(d->kdeIconThemeSearchPaths(d->kdeDirs));
+ case QPlatformTheme::IconPixmapSizes:
+ return QVariant::fromValue(availableXdgFileIconSizes());
case QPlatformTheme::StyleNames:
return QVariant(d->styleNames);
case QPlatformTheme::KeyboardScheme:
@@ -520,6 +545,11 @@ QVariant QKdeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
return QPlatformTheme::themeHint(hint);
}
+QIcon QKdeTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions) const
+{
+ return xdgFileIcon(fileInfo);
+}
+
const QPalette *QKdeTheme::palette(Palette type) const
{
Q_D(const QKdeTheme);
@@ -657,6 +687,8 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
return QVariant(QStringLiteral("gnome"));
case QPlatformTheme::IconThemeSearchPaths:
return QVariant(QGenericUnixTheme::xdgIconThemePaths());
+ case QPlatformTheme::IconPixmapSizes:
+ return QVariant::fromValue(availableXdgFileIconSizes());
case QPlatformTheme::StyleNames: {
QStringList styleNames;
styleNames << QStringLiteral("fusion") << QStringLiteral("windows");
@@ -666,12 +698,19 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
return QVariant(int(GnomeKeyboardScheme));
case QPlatformTheme::PasswordMaskCharacter:
return QVariant(QChar(0x2022));
+ case QPlatformTheme::UiEffects:
+ return QVariant(int(HoverEffect));
default:
break;
}
return QPlatformTheme::themeHint(hint);
}
+QIcon QGnomeTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions) const
+{
+ return xdgFileIcon(fileInfo);
+}
+
const QFont *QGnomeTheme::font(Font type) const
{
Q_D(const QGnomeTheme);
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h
index 952658e130..da13390662 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes_p.h
@@ -107,6 +107,9 @@ public:
static QPlatformTheme *createKdeTheme();
QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE;
+ QIcon fileIcon(const QFileInfo &fileInfo,
+ QPlatformTheme::IconOptions iconOptions = 0) const override;
+
const QPalette *palette(Palette type = SystemPalette) const Q_DECL_OVERRIDE;
const QFont *font(Font type) const Q_DECL_OVERRIDE;
@@ -129,6 +132,8 @@ class QGnomeTheme : public QPlatformTheme
public:
QGnomeTheme();
QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE;
+ QIcon fileIcon(const QFileInfo &fileInfo,
+ QPlatformTheme::IconOptions = 0) const override;
const QFont *font(Font type) const Q_DECL_OVERRIDE;
QString standardButtonText(int button) const Q_DECL_OVERRIDE;
diff --git a/src/platformsupport/themes/qabstractfileiconengine.cpp b/src/platformsupport/themes/qabstractfileiconengine.cpp
new file mode 100644
index 0000000000..19a8eee47b
--- /dev/null
+++ b/src/platformsupport/themes/qabstractfileiconengine.cpp
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qabstractfileiconengine_p.h"
+
+#include <qpixmapcache.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QAbstractFileIconEngine
+ \brief Helper base class for retrieving icons for files for usage by QFileIconProvider and related.
+
+ Reimplement availableSizes() and new virtual filePixmap() and return icons created
+ with this engine from QPlatformTheme::fileIcon().
+
+ Note: The class internally caches pixmaps for files by suffix (with the exception
+ of some files on Windows), but not for directories (since directory icons may have
+ overlay icons on Windows). You might want to cache pixmaps for directories
+ in your implementation.
+
+ \since 5.8
+ \internal
+ \sa QFileIconProvider::DontUseCustomDirectoryIcons, QPlatformTheme
+ \ingroup qpa
+*/
+QPixmap QAbstractFileIconEngine::pixmap(const QSize &size, QIcon::Mode mode,
+ QIcon::State state)
+{
+ Q_UNUSED(mode);
+ Q_UNUSED(state);
+
+ if (!size.isValid())
+ return QPixmap();
+
+ QString key = cacheKey();
+ if (key.isEmpty())
+ return filePixmap(size, mode, state);
+
+ key += QLatin1Char('_');
+ key += QString::number(size.width());
+
+ QPixmap result;
+ if (!QPixmapCache::find(key, result)) {
+ result = filePixmap(size, mode, state);
+ if (!result.isNull())
+ QPixmapCache::insert(key, result);
+ }
+
+ return result;
+}
+
+QSize QAbstractFileIconEngine::actualSize(const QSize &size, QIcon::Mode mode,
+ QIcon::State state)
+{
+ const QList<QSize> &sizes = availableSizes(mode, state);
+ const int numberSizes = sizes.length();
+ if (numberSizes == 0)
+ return QSize();
+
+ // Find the smallest available size whose area is still larger than the input
+ // size. Otherwise, use the largest area available size. (We don't assume the
+ // platform theme sizes are sorted, hence the extra logic.)
+ const int sizeArea = size.width() * size.height();
+ QSize actualSize = sizes.first();
+ int actualArea = actualSize.width() * actualSize.height();
+ for (int i = 1; i < numberSizes; ++i) {
+ const QSize &s = sizes.at(i);
+ const int a = s.width() * s.height();
+ if ((sizeArea <= a && a < actualArea) || (actualArea < sizeArea && actualArea < a)) {
+ actualSize = s;
+ actualArea = a;
+ }
+ }
+
+ if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height()))
+ actualSize.scale(size, Qt::KeepAspectRatio);
+
+ return actualSize;
+}
+
+/* Reimplement to return a cache key for the entry. An empty result indicates
+ * the icon should not be cached (for example, directory icons having custom icons). */
+QString QAbstractFileIconEngine::cacheKey() const
+{
+ if (!m_fileInfo.isFile() || m_fileInfo.isSymLink() || m_fileInfo.isExecutable())
+ return QString();
+
+ const QString &suffix = m_fileInfo.suffix();
+ return QLatin1String("qt_.")
+ + (suffix.isEmpty() ? m_fileInfo.fileName() : suffix); // handle "Makefile" ;)
+}
+
+QT_END_NAMESPACE
diff --git a/src/platformsupport/themes/qabstractfileiconengine_p.h b/src/platformsupport/themes/qabstractfileiconengine_p.h
new file mode 100644
index 0000000000..ce38cf262e
--- /dev/null
+++ b/src/platformsupport/themes/qabstractfileiconengine_p.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QABSTRACTFILEICONENGINE_P_H
+#define QABSTRACTFILEICONENGINE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qfileinfo.h>
+#include <private/qicon_p.h>
+#include <qpa/qplatformtheme.h>
+
+QT_BEGIN_NAMESPACE
+
+class QAbstractFileIconEngine : public QPixmapIconEngine
+{
+public:
+ explicit QAbstractFileIconEngine(const QFileInfo &info, QPlatformTheme::IconOptions opts)
+ : QPixmapIconEngine(), m_fileInfo(info), m_options(opts) {}
+
+ QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State) override;
+ QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) override;
+
+ QFileInfo fileInfo() const { return m_fileInfo; }
+ QPlatformTheme::IconOptions options() const { return m_options; }
+
+ // Helper to convert a sequence of ints to a list of QSize
+ template <class It> static QList<QSize> toSizeList(It i1, It i2);
+
+protected:
+ virtual QPixmap filePixmap(const QSize &size, QIcon::Mode mode, QIcon::State) = 0;
+ virtual QString cacheKey() const;
+
+private:
+ const QFileInfo m_fileInfo;
+ const QPlatformTheme::IconOptions m_options;
+};
+
+template <class It>
+inline QList<QSize> QAbstractFileIconEngine::toSizeList(It i1, It i2)
+{
+ QList<QSize> result;
+ result.reserve(int(i2 - i1));
+ for ( ; i1 != i2; ++i1)
+ result.append(QSize(*i1, *i1));
+ return result;
+}
+
+QT_END_NAMESPACE
+
+#endif // QABSTRACTFILEICONENGINE_P_H
diff --git a/src/platformsupport/themes/themes.pri b/src/platformsupport/themes/themes.pri
index adee852626..552973431f 100644
--- a/src/platformsupport/themes/themes.pri
+++ b/src/platformsupport/themes/themes.pri
@@ -1,3 +1,9 @@
unix:!mac {
include($$PWD/genericunix/genericunix.pri)
}
+
+HEADERS += \
+ $$PWD/qabstractfileiconengine_p.h
+
+SOURCES += \
+ $$PWD/qabstractfileiconengine.cpp
diff --git a/src/plugins/bearer/bearer.pro b/src/plugins/bearer/bearer.pro
index cc590cc545..8028e65147 100644
--- a/src/plugins/bearer/bearer.pro
+++ b/src/plugins/bearer/bearer.pro
@@ -7,7 +7,7 @@ TEMPLATE = subdirs
#win32:SUBDIRS += nla
win32:SUBDIRS += generic
-win32:!wince:!winrt: SUBDIRS += nativewifi
+win32:!winrt: SUBDIRS += nativewifi
mac:contains(QT_CONFIG, corewlan):SUBDIRS += corewlan
mac:SUBDIRS += generic
android:SUBDIRS += android
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm
index 52e76219e6..7ce5f28f99 100644
--- a/src/plugins/bearer/corewlan/qcorewlanengine.mm
+++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm
@@ -502,27 +502,27 @@ void QCoreWlanEngine::connectToId(const QString &id)
if(!err) {
for (CWNetwork *apNetwork in scanSet) {
- CFDataRef ssidData = (CFDataRef)[apNetwork ssidData];
+ NSData *ssidData = [apNetwork ssidData];
bool result = false;
SecIdentityRef identity = 0;
// Check first whether we require IEEE 802.1X authentication for the wanted SSID
- if (CWKeychainCopyEAPIdentity(ssidData, &identity) == errSecSuccess) {
- CFStringRef username = 0;
- CFStringRef password = 0;
- if (CWKeychainCopyEAPUsernameAndPassword(ssidData, &username, &password) == errSecSuccess) {
+ if (CWKeychainCopyWiFiEAPIdentity(kCWKeychainDomainSystem, ssidData, &identity) == errSecSuccess) {
+ NSString *username = nil;
+ NSString *password = nil;
+ if (CWKeychainFindWiFiEAPUsernameAndPassword(kCWKeychainDomainSystem, ssidData, &username, &password) == errSecSuccess) {
result = [wifiInterface associateToEnterpriseNetwork:apNetwork
identity:identity username:(NSString *)username password:(NSString *)password
error:&err];
- CFRelease(username);
- CFRelease(password);
+ [username release];
+ [password release];
}
CFRelease(identity);
} else {
- CFStringRef password = 0;
- if (CWKeychainCopyPassword(ssidData, &password) == errSecSuccess) {
+ NSString *password = nil;
+ if (CWKeychainFindWiFiPassword(kCWKeychainDomainSystem, ssidData, &password) == errSecSuccess) {
result = [wifiInterface associateToNetwork:apNetwork password:(NSString *)password error:&err];
- CFRelease(password);
+ [password release];
}
}
diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp
index aa0fc6b945..02ea7abf88 100644
--- a/src/plugins/bearer/generic/qgenericengine.cpp
+++ b/src/plugins/bearer/generic/qgenericengine.cpp
@@ -50,17 +50,10 @@
#include <QtCore/qdebug.h>
#include <QtCore/private/qcoreapplication_p.h>
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN32)
#include "../platformdefs_win.h"
#endif
-#ifdef Q_OS_WINCE
-typedef ULONG NDIS_OID, *PNDIS_OID;
-# ifndef QT_NO_WINCE_NUIOUSER
-# include <nuiouser.h>
-# endif
-#endif // Q_OS_WINCE
-
#ifdef Q_OS_WINRT
#include <qfunctions_winrt.h>
@@ -92,36 +85,22 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_NETWORKINTERFACE
static QNetworkConfiguration::BearerType qGetInterfaceType(const QString &interface)
{
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN32)
DWORD bytesWritten;
NDIS_MEDIUM medium;
NDIS_PHYSICAL_MEDIUM physicalMedium;
-#if defined(Q_OS_WINCE) && !defined(QT_NO_WINCE_NUIOUSER)
- NDISUIO_QUERY_OID nicGetOid;
- HANDLE handle = CreateFile((PTCHAR)NDISUIO_DEVICE_NAME, 0,
- FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
-#else
unsigned long oid;
HANDLE handle = CreateFile((TCHAR *)QString::fromLatin1("\\\\.\\%1").arg(interface).utf16(), 0,
FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
-#endif
if (handle == INVALID_HANDLE_VALUE)
return QNetworkConfiguration::BearerUnknown;
bytesWritten = 0;
-#if defined(Q_OS_WINCE) && !defined(QT_NO_WINCE_NUIOUSER)
- ZeroMemory(&nicGetOid, sizeof(NDISUIO_QUERY_OID));
- nicGetOid.Oid = OID_GEN_MEDIA_SUPPORTED;
- nicGetOid.ptcDeviceName = (PTCHAR)interface.utf16();
- bool result = DeviceIoControl(handle, IOCTL_NDISUIO_QUERY_OID_VALUE, &nicGetOid, sizeof(nicGetOid),
- &nicGetOid, sizeof(nicGetOid), &bytesWritten, 0);
-#else
oid = OID_GEN_MEDIA_SUPPORTED;
bool result = DeviceIoControl(handle, IOCTL_NDIS_QUERY_GLOBAL_STATS, &oid, sizeof(oid),
&medium, sizeof(medium), &bytesWritten, 0);
-#endif
if (!result) {
CloseHandle(handle);
return QNetworkConfiguration::BearerUnknown;
@@ -129,22 +108,9 @@ static QNetworkConfiguration::BearerType qGetInterfaceType(const QString &interf
bytesWritten = 0;
-#if defined(Q_OS_WINCE) && !defined(QT_NO_WINCE_NUIOUSER)
- medium = NDIS_MEDIUM( *(LPDWORD)nicGetOid.Data );
-
- ZeroMemory(&nicGetOid, sizeof(NDISUIO_QUERY_OID));
- nicGetOid.Oid = OID_GEN_PHYSICAL_MEDIUM;
- nicGetOid.ptcDeviceName = (PTCHAR)interface.utf16();
-
- result = DeviceIoControl(handle, IOCTL_NDISUIO_QUERY_OID_VALUE, &nicGetOid, sizeof(nicGetOid),
- &nicGetOid, sizeof(nicGetOid), &bytesWritten, 0);
-
- physicalMedium = NDIS_PHYSICAL_MEDIUM( *(LPDWORD)nicGetOid.Data );
-#else
oid = OID_GEN_PHYSICAL_MEDIUM;
result = DeviceIoControl(handle, IOCTL_NDIS_QUERY_GLOBAL_STATS, &oid, sizeof(oid),
&physicalMedium, sizeof(physicalMedium), &bytesWritten, 0);
-#endif
if (!result) {
CloseHandle(handle);
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
index b0bc8a265e..3cd9290420 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
@@ -553,14 +553,13 @@ void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path,
emit configurationAdded(ptr);
}
-bool QNetworkManagerEngine::isConnectionActive(const QString &settingsPath)
+bool QNetworkManagerEngine::isConnectionActive(const QString &settingsPath) const
{
- QHashIterator<QString, QNetworkManagerConnectionActive*> i(activeConnectionsList);
- while (i.hasNext()) {
- i.next();
- if (i.value()->connection().path() == settingsPath) {
- if (i.value()->state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATING
- || i.value()->state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
+ for (QNetworkManagerConnectionActive *activeConnection : activeConnectionsList) {
+ if (activeConnection->connection().path() == settingsPath) {
+ const auto state = activeConnection->state();
+ if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATING
+ || state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
return true;
} else {
break;
@@ -848,9 +847,7 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri
if (ofonoManager && ofonoManager->isValid()) {
const QString contextPart = connectionPath.section('/', -1);
- QHashIterator<QString, QOfonoDataConnectionManagerInterface*> i(ofonoContextManagers);
- while (i.hasNext()) {
- i.next();
+ for (auto i = ofonoContextManagers.cbegin(), end = ofonoContextManagers.cend(); i != end; ++i) {
const QString path = i.key() + QLatin1Char('/') +contextPart;
if (isActiveContext(path)) {
cpPriv->state |= QNetworkConfiguration::Active;
@@ -863,14 +860,12 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri
return cpPriv;
}
-bool QNetworkManagerEngine::isActiveContext(const QString &contextPath)
+bool QNetworkManagerEngine::isActiveContext(const QString &contextPath) const
{
if (ofonoManager && ofonoManager->isValid()) {
const QString contextPart = contextPath.section('/', -1);
- QHashIterator<QString, QOfonoDataConnectionManagerInterface*> i(ofonoContextManagers);
- while (i.hasNext()) {
- i.next();
- PathPropertiesList list = i.value()->contextsWithProperties();
+ for (QOfonoDataConnectionManagerInterface *iface : ofonoContextManagers) {
+ const PathPropertiesList list = iface->contextsWithProperties();
for (int i = 0; i < list.size(); ++i) {
if (list.at(i).path.path().contains(contextPart)) {
return list.at(i).properties.value(QStringLiteral("Active")).toBool();
@@ -1012,10 +1007,7 @@ QNetworkSessionPrivate *QNetworkManagerEngine::createSessionBackend()
QNetworkConfigurationPrivatePointer QNetworkManagerEngine::defaultConfiguration()
{
- QHashIterator<QString, QNetworkManagerConnectionActive*> i(activeConnectionsList);
- while (i.hasNext()) {
- i.next();
- QNetworkManagerConnectionActive *activeConnection = i.value();
+ for (QNetworkManagerConnectionActive *activeConnection : qAsConst(activeConnectionsList)) {
if ((activeConnection->defaultRoute() || activeConnection->default6Route())) {
return accessPointConfigurations.value(activeConnection->connection().path());
}
@@ -1024,12 +1016,10 @@ QNetworkConfigurationPrivatePointer QNetworkManagerEngine::defaultConfiguration(
return QNetworkConfigurationPrivatePointer();
}
-QNetworkConfiguration::BearerType QNetworkManagerEngine::currentBearerType(const QString &id)
+QNetworkConfiguration::BearerType QNetworkManagerEngine::currentBearerType(const QString &id) const
{
QString contextPart = id.section('/', -1);
- QHashIterator<QString, QOfonoDataConnectionManagerInterface*> i(ofonoContextManagers);
- while (i.hasNext()) {
- i.next();
+ for (auto i = ofonoContextManagers.begin(), end = ofonoContextManagers.end(); i != end; ++i) {
QString contextPath = i.key() + QLatin1Char('/') +contextPart;
if (i.value()->contexts().contains(contextPath)) {
@@ -1055,13 +1045,11 @@ QNetworkConfiguration::BearerType QNetworkManagerEngine::currentBearerType(const
return QNetworkConfiguration::BearerUnknown;
}
-QString QNetworkManagerEngine::contextName(const QString &path)
+QString QNetworkManagerEngine::contextName(const QString &path) const
{
QString contextPart = path.section('/', -1);
- QHashIterator<QString, QOfonoDataConnectionManagerInterface*> i(ofonoContextManagers);
- while (i.hasNext()) {
- i.next();
- PathPropertiesList list = i.value()->contextsWithProperties();
+ for (QOfonoDataConnectionManagerInterface *iface : ofonoContextManagers) {
+ const PathPropertiesList list = iface->contextsWithProperties();
for (int i = 0; i < list.size(); ++i) {
if (list.at(i).path.path().contains(contextPart)) {
return list.at(i).properties.value(QStringLiteral("Name")).toString();
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
index e8c40a881d..2f425ddc02 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
@@ -74,26 +74,26 @@ public:
bool networkManagerAvailable() const;
- QString getInterfaceFromId(const QString &id);
- bool hasIdentifier(const QString &id);
+ QString getInterfaceFromId(const QString &id) override;
+ bool hasIdentifier(const QString &id) override;
- void connectToId(const QString &id);
- void disconnectFromId(const QString &id);
+ void connectToId(const QString &id) override;
+ void disconnectFromId(const QString &id) override;
Q_INVOKABLE void initialize();
Q_INVOKABLE void requestUpdate();
- QNetworkSession::State sessionStateForId(const QString &id);
+ QNetworkSession::State sessionStateForId(const QString &id) override;
- quint64 bytesWritten(const QString &id);
- quint64 bytesReceived(const QString &id);
- quint64 startTime(const QString &id);
+ quint64 bytesWritten(const QString &id) override;
+ quint64 bytesReceived(const QString &id) override;
+ quint64 startTime(const QString &id) override;
- QNetworkConfigurationManager::Capabilities capabilities() const;
+ QNetworkConfigurationManager::Capabilities capabilities() const override;
- QNetworkSessionPrivate *createSessionBackend();
+ QNetworkSessionPrivate *createSessionBackend() override;
- QNetworkConfigurationPrivatePointer defaultConfiguration();
+ QNetworkConfigurationPrivatePointer defaultConfiguration() override;
private Q_SLOTS:
void interfacePropertiesChanged(const QMap<QString, QVariant> &properties);
@@ -140,14 +140,14 @@ private:
QOfonoManagerInterface *ofonoManager;
QHash <QString, QOfonoDataConnectionManagerInterface *> ofonoContextManagers;
- QNetworkConfiguration::BearerType currentBearerType(const QString &id);
- QString contextName(const QString &path);
+ QNetworkConfiguration::BearerType currentBearerType(const QString &id) const;
+ QString contextName(const QString &path) const;
- bool isConnectionActive(const QString &settingsPath);
+ bool isConnectionActive(const QString &settingsPath) const;
QDBusServiceWatcher *ofonoWatcher;
QDBusServiceWatcher *nmWatcher;
- bool isActiveContext(const QString &contextPath);
+ bool isActiveContext(const QString &contextPath) const;
bool nmAvailable;
void setupConfigurations();
};
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
index 6c3c661db6..081cb1288d 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
@@ -215,9 +215,7 @@ QString QNetworkManagerInterface::version() const
void QNetworkManagerInterface::propertiesSwap(QMap<QString,QVariant> map)
{
- QMapIterator<QString, QVariant> i(map);
- while (i.hasNext()) {
- i.next();
+ for (auto i = map.cbegin(), end = map.cend(); i != end; ++i) {
propertyMap.insert(i.key(),i.value());
if (i.key() == QLatin1String("State")) {
@@ -334,11 +332,8 @@ quint32 QNetworkManagerInterfaceAccessPoint::strength() const
void QNetworkManagerInterfaceAccessPoint::propertiesSwap(QMap<QString,QVariant> map)
{
- QMapIterator<QString, QVariant> i(map);
- while (i.hasNext()) {
- i.next();
+ for (auto i = map.cbegin(), end = map.cend(); i != end; ++i)
propertyMap.insert(i.key(),i.value());
- }
}
QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent)
@@ -421,9 +416,7 @@ QDBusObjectPath QNetworkManagerInterfaceDevice::ip4config() const
void QNetworkManagerInterfaceDevice::propertiesSwap(QMap<QString,QVariant> map)
{
- QMapIterator<QString, QVariant> i(map);
- while (i.hasNext()) {
- i.next();
+ for (auto i = map.cbegin(), end = map.cend(); i != end; ++i) {
if (i.key() == QLatin1String("AvailableConnections")) { //Device
const QDBusArgument &dbusArgs = i.value().value<QDBusArgument>();
QDBusObjectPath path;
@@ -516,9 +509,7 @@ QStringList QNetworkManagerInterfaceDeviceWired::availableConnections()
void QNetworkManagerInterfaceDeviceWired::propertiesSwap(QMap<QString,QVariant> map)
{
- QMapIterator<QString, QVariant> i(map);
- while (i.hasNext()) {
- i.next();
+ for (auto i = map.cbegin(), end = map.cend(); i != end; ++i) {
propertyMap.insert(i.key(),i.value());
if (i.key() == QLatin1String("Carrier"))
Q_EMIT carrierChanged(i.value().toBool());
@@ -694,9 +685,7 @@ void QNetworkManagerInterfaceDeviceWireless::requestScan()
void QNetworkManagerInterfaceDeviceWireless::propertiesSwap(QMap<QString,QVariant> map)
{
- QMapIterator<QString, QVariant> i(map);
- while (i.hasNext()) {
- i.next();
+ for (auto i = map.cbegin(), end = map.cend(); i != end; ++i) {
propertyMap.insert(i.key(),i.value());
if (i.key() == QLatin1String("ActiveAccessPoint")) //DeviceWireless
Q_EMIT propertiesChanged(map);
@@ -753,11 +742,8 @@ QNetworkManagerInterfaceDeviceModem::ModemCapabilities QNetworkManagerInterfaceD
void QNetworkManagerInterfaceDeviceModem::propertiesSwap(QMap<QString,QVariant> map)
{
- QMapIterator<QString, QVariant> i(map);
- while (i.hasNext()) {
- i.next();
+ for (auto i = map.cbegin(), end = map.cend(); i != end; ++i)
propertyMap.insert(i.key(),i.value());
- }
Q_EMIT propertiesChanged(map);
}
@@ -1051,9 +1037,7 @@ bool QNetworkManagerConnectionActive::default6Route() const
void QNetworkManagerConnectionActive::propertiesSwap(QMap<QString,QVariant> map)
{
- QMapIterator<QString, QVariant> i(map);
- while (i.hasNext()) {
- i.next();
+ for (auto i = map.cbegin(), end = map.cend(); i != end; ++i) {
propertyMap.insert(i.key(),i.value());
if (i.key() == QLatin1String("State")) {
quint32 state = i.value().toUInt();
diff --git a/src/plugins/bearer/nla/nla.pro b/src/plugins/bearer/nla/nla.pro
index 32ff5446e5..113d0667d2 100644
--- a/src/plugins/bearer/nla/nla.pro
+++ b/src/plugins/bearer/nla/nla.pro
@@ -2,11 +2,7 @@ TARGET = qnlabearer
QT = core core-private network network-private
-!wince* {
- LIBS += -lws2_32
-} else {
- LIBS += -lws2
-}
+LIBS += -lws2_32
HEADERS += qnlaengine.h \
../platformdefs_win.h \
diff --git a/src/plugins/bearer/qnetworksession_impl.cpp b/src/plugins/bearer/qnetworksession_impl.cpp
index a692d3c63f..426cca139d 100644
--- a/src/plugins/bearer/qnetworksession_impl.cpp
+++ b/src/plugins/bearer/qnetworksession_impl.cpp
@@ -285,7 +285,7 @@ quint64 QNetworkSessionPrivateImpl::bytesReceived() const
quint64 QNetworkSessionPrivateImpl::activeTime() const
{
if (state == QNetworkSession::Connected && startTime != Q_UINT64_C(0))
- return QDateTime::currentDateTimeUtc().toTime_t() - startTime;
+ return QDateTime::currentSecsSinceEpoch() - startTime;
return Q_UINT64_C(0);
}
diff --git a/src/plugins/generic/bsdkeyboard/bsdkeyboard.json b/src/plugins/generic/bsdkeyboard/bsdkeyboard.json
new file mode 100644
index 0000000000..46a8127c46
--- /dev/null
+++ b/src/plugins/generic/bsdkeyboard/bsdkeyboard.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "BsdKeyboard" ]
+}
diff --git a/src/plugins/generic/bsdkeyboard/bsdkeyboard.pro b/src/plugins/generic/bsdkeyboard/bsdkeyboard.pro
new file mode 100644
index 0000000000..c14c38c839
--- /dev/null
+++ b/src/plugins/generic/bsdkeyboard/bsdkeyboard.pro
@@ -0,0 +1,16 @@
+TARGET = qbsdkeyboardplugin
+
+PLUGIN_TYPE = generic
+PLUGIN_EXTENDS = -
+PLUGIN_CLASS_NAME = QBsdKeyboardPlugin
+load(qt_plugin)
+
+QT += core gui-private
+
+HEADERS = qbsdkeyboard.h
+SOURCES = main.cpp \
+ qbsdkeyboard.cpp
+
+OTHER_FILES += \
+ qbsdkeyboard.json
+
diff --git a/src/plugins/generic/bsdkeyboard/main.cpp b/src/plugins/generic/bsdkeyboard/main.cpp
new file mode 100644
index 0000000000..f48af0ae28
--- /dev/null
+++ b/src/plugins/generic/bsdkeyboard/main.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2015-2016 Oleksandr Tymoshenko <gonzo@bluezbox.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/qgenericplugin.h>
+#include "qbsdkeyboard.h"
+
+QT_BEGIN_NAMESPACE
+
+class QBsdKeyboardPlugin : public QGenericPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "bsdkeyboard.json")
+
+public:
+ QObject *create(const QString &key, const QString &specification) override;
+};
+
+QObject *QBsdKeyboardPlugin::create(const QString &key,
+ const QString &specification)
+{
+ if (!key.compare(QLatin1String("BsdKeyboard"), Qt::CaseInsensitive))
+ return new QBsdKeyboardHandler(key, specification);
+
+ return nullptr;
+}
+
+QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/src/plugins/generic/bsdkeyboard/qbsdkeyboard.cpp b/src/plugins/generic/bsdkeyboard/qbsdkeyboard.cpp
new file mode 100644
index 0000000000..6f34d066c6
--- /dev/null
+++ b/src/plugins/generic/bsdkeyboard/qbsdkeyboard.cpp
@@ -0,0 +1,408 @@
+/****************************************************************************
+**
+** Copyright (C) 2015-2016 Oleksandr Tymoshenko <gonzo@bluezbox.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbsdkeyboard.h"
+
+#include <QByteArray>
+#include <QFile>
+#include <QGuiApplication>
+#include <QPoint>
+#include <QSocketNotifier>
+#include <QString>
+#include <QStringList>
+
+#include <QtCore/qglobal.h>
+#include <qpa/qwindowsysteminterface.h>
+#include <private/qcore_unix_p.h>
+#include <private/qguiapplication_p.h>
+#include <private/qinputdevicemanager_p_p.h>
+
+#include <qdebug.h>
+#include <cstdio>
+
+#include <cerrno>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <termios.h>
+#include <sys/kbio.h>
+
+// #define QT_BSD_KEYBOARD_DEBUG
+
+#ifdef QT_BSD_KEYBOARD_DEBUG
+#include <qdebug.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+enum {
+ Bsd_KeyCodeMask = 0x7f,
+ Bsd_KeyPressedMask = 0x80
+};
+
+#include "qbsdkeyboard_defaultmap.h"
+
+QBsdKeyboardHandler::QBsdKeyboardHandler(const QString &key, const QString &specification)
+{
+ Q_UNUSED(key);
+
+ setObjectName(QLatin1String("BSD Keyboard Handler"));
+
+ QByteArray device;
+ if (specification.startsWith("/dev/"))
+ device = QFile::encodeName(specification);
+
+ if (device.isEmpty()) {
+ device = QByteArrayLiteral("STDIN");
+ m_fd = fileno(stdin);
+ }
+ else {
+ m_fd = QT_OPEN(device.constData(), O_RDONLY);
+ if (!m_fd) {
+ qErrnoWarning(errno, "open(%s) failed", device.constData());
+ return;
+ }
+ m_shouldClose = true;
+ }
+
+ if (ioctl(m_fd, KDGKBMODE, &m_origKbdMode)) {
+ qErrnoWarning(errno, "ioctl(%s, KDGKBMODE) failed", device.constData());
+ revertTTYSettings();
+ return;
+ }
+
+ if (ioctl(m_fd, KDSKBMODE, K_CODE) < 0) {
+ qErrnoWarning(errno, "ioctl(%s, KDSKBMODE) failed", device.constData());
+ revertTTYSettings();
+ return;
+ }
+
+ termios kbdtty;
+ if (tcgetattr(m_fd, &kbdtty) == 0) {
+
+ m_kbdOrigTty.reset(new termios);
+ *m_kbdOrigTty = kbdtty;
+
+ kbdtty.c_iflag = IGNPAR | IGNBRK;
+ kbdtty.c_oflag = 0;
+ kbdtty.c_cflag = CREAD | CS8;
+ kbdtty.c_lflag = 0;
+ kbdtty.c_cc[VTIME] = 0;
+ kbdtty.c_cc[VMIN] = 0;
+ cfsetispeed(&kbdtty, 9600);
+ cfsetospeed(&kbdtty, 9600);
+ if (tcsetattr(m_fd, TCSANOW, &kbdtty) < 0) {
+ qErrnoWarning(errno, "tcsetattr(%s) failed", device.constData());
+
+ // TTY is still at old settings so we can
+ // dispose of original termios data
+ m_kbdOrigTty.reset();
+
+ revertTTYSettings();
+ return;
+ }
+ } else {
+ qErrnoWarning(errno, "tcgetattr(%s) failed", device.constData());
+ revertTTYSettings();
+ return;
+ }
+
+ if (fcntl(m_fd, F_SETFL, O_NONBLOCK)) {
+ qErrnoWarning(errno, "fcntl(%s, F_SETFL, O_NONBLOCK) failed", device.constData());
+ revertTTYSettings();
+ return;
+ }
+
+ resetKeymap();
+
+ m_notifier.reset(new QSocketNotifier(m_fd, QSocketNotifier::Read, this));
+ connect(m_notifier.data(), &QSocketNotifier::activated, this, &QBsdKeyboardHandler::readKeyboardData);
+ QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
+ QInputDeviceManager::DeviceTypeKeyboard, 1);
+}
+
+QBsdKeyboardHandler::~QBsdKeyboardHandler()
+{
+ revertTTYSettings();
+}
+
+void QBsdKeyboardHandler::revertTTYSettings()
+{
+ if (m_fd >= 0) {
+ if (m_kbdOrigTty) {
+ tcsetattr(m_fd, TCSANOW, m_kbdOrigTty.data());
+ m_kbdOrigTty.reset();
+ }
+
+ if (m_origKbdMode != Bsd_NoKeyMode) {
+ ioctl(m_fd, KDSKBMODE, m_origKbdMode);
+ m_origKbdMode = Bsd_NoKeyMode;
+ }
+
+ if (m_shouldClose)
+ close(m_fd);
+ m_fd = -1;
+ }
+}
+
+void QBsdKeyboardHandler::readKeyboardData()
+{
+
+ for (;;) {
+ uint8_t buffer[32];
+ int bytesRead = qt_safe_read(m_fd, buffer, sizeof(buffer));
+
+ if (!bytesRead) {
+ qWarning("Got EOF from the input device.");
+ return;
+ } else if (bytesRead < 0) {
+ if (errno != EINTR && errno != EAGAIN)
+ qWarning("Could not read from input device: %s", strerror(errno));
+ return;
+ }
+
+ for (int i = 0; i < bytesRead; ++i) {
+ const quint16 code = buffer[i] & Bsd_KeyCodeMask;
+ const bool pressed = (buffer[i] & Bsd_KeyPressedMask) ? false : true;
+
+ processKeycode(code, pressed, false);
+ }
+ }
+}
+
+void QBsdKeyboardHandler::processKeyEvent(int nativecode, int unicode, int qtcode,
+ Qt::KeyboardModifiers modifiers, bool isPress,
+ bool autoRepeat)
+{
+ const QString text = (unicode != 0xffff ) ? QString(unicode) : QString();
+ const QEvent::Type eventType = isPress ? QEvent::KeyPress : QEvent::KeyRelease;
+
+ QWindowSystemInterface::handleExtendedKeyEvent(0, eventType, qtcode, modifiers, nativecode, 0,
+ int(modifiers), text, autoRepeat);
+}
+
+void QBsdKeyboardHandler::processKeycode(quint16 keycode, bool pressed, bool autorepeat)
+{
+ const bool first_press = pressed && !autorepeat;
+
+ const QBsdKeyboardMap::Mapping *map_plain = nullptr;
+ const QBsdKeyboardMap::Mapping *map_withmod = nullptr;
+
+ quint8 modifiers = m_modifiers;
+
+ // get a specific and plain mapping for the keycode and the current modifiers
+ for (const QBsdKeyboardMap::Mapping &m : m_keymap) {
+ if (m.keycode == keycode) {
+ if (m.modifiers == 0)
+ map_plain = &m;
+
+ quint8 testmods = m_modifiers;
+ if (m_capsLock && (m.flags & QBsdKeyboardMap::IsLetter))
+ testmods ^= QBsdKeyboardMap::ModShift;
+ if (m.modifiers == testmods)
+ map_withmod = &m;
+ }
+ }
+
+ if (m_capsLock && map_withmod && (map_withmod->flags & QBsdKeyboardMap::IsLetter))
+ modifiers ^= QBsdKeyboardMap::ModShift;
+
+#ifdef QT_BSD_KEYBOARD_DEBUG
+ qWarning("Processing key event: keycode=%3d, modifiers=%02x pressed=%d, autorepeat=%d", \
+ keycode, modifiers, pressed ? 1 : 0, autorepeat ? 1 : 0);
+#endif
+
+ const QBsdKeyboardMap::Mapping *it = map_withmod ? map_withmod : map_plain;
+
+ if (!it) {
+#ifdef QT_BSD_KEYBOARD_DEBUG
+ // we couldn't even find a plain mapping
+ qWarning("Could not find a suitable mapping for keycode: %3d, modifiers: %02x", keycode, modifiers);
+#endif
+ return;
+ }
+
+ bool skip = false;
+ quint16 unicode = it->unicode;
+ quint32 qtcode = it->qtcode;
+
+ if ((it->flags & QBsdKeyboardMap::IsModifier) && it->special) {
+ // this is a modifier, i.e. Shift, Alt, ...
+ if (pressed)
+ m_modifiers |= quint8(it->special);
+ else
+ m_modifiers &= ~quint8(it->special);
+ } else if (qtcode >= Qt::Key_CapsLock && qtcode <= Qt::Key_ScrollLock) {
+ // (Caps|Num|Scroll)Lock
+ if (first_press) {
+ switch (qtcode) {
+ case Qt::Key_CapsLock:
+ m_capsLock = !m_capsLock;
+ switchLed(LED_CAP, m_capsLock);
+ break;
+ case Qt::Key_NumLock:
+ m_numLock = !m_numLock;
+ switchLed(LED_NUM, m_numLock);
+ break;
+ case Qt::Key_ScrollLock:
+ m_scrollLock = !m_scrollLock;
+ switchLed(LED_SCR, m_scrollLock);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ if (!skip) {
+ // a normal key was pressed
+ const int modmask = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier
+ | Qt::MetaModifier | Qt::KeypadModifier;
+
+ // we couldn't find a specific mapping for the current modifiers,
+ // or that mapping didn't have special modifiers:
+ // so just report the plain mapping with additional modifiers.
+ if ((it == map_plain && it != map_withmod) ||
+ (map_withmod && !(map_withmod->qtcode & modmask))) {
+ qtcode |= QBsdKeyboardHandler::toQtModifiers(modifiers);
+ }
+
+#ifdef QT_BSD_KEYBOARD_DEBUG
+ qWarning("Processing: uni=%04x, qt=%08x, qtmod=%08x", unicode, qtcode & ~modmask, (qtcode & modmask));
+#endif
+ //If NumLockOff and keypad key pressed remap event sent
+ if (!m_numLock &&
+ (qtcode & Qt::KeypadModifier)) {
+ unicode = 0xffff;
+ const int oldMask = (qtcode & modmask);
+ switch (qtcode & ~modmask) {
+ case Qt::Key_7: //7 --> Home
+ qtcode = Qt::Key_Home;
+ break;
+ case Qt::Key_8: //8 --> Up
+ qtcode = Qt::Key_Up;
+ break;
+ case Qt::Key_9: //9 --> PgUp
+ qtcode = Qt::Key_PageUp;
+ break;
+ case Qt::Key_4: //4 --> Left
+ qtcode = Qt::Key_Left;
+ break;
+ case Qt::Key_5: //5 --> Clear
+ qtcode = Qt::Key_Clear;
+ break;
+ case Qt::Key_6: //6 --> right
+ qtcode = Qt::Key_Right;
+ break;
+ case Qt::Key_1: //1 --> End
+ qtcode = Qt::Key_End;
+ break;
+ case Qt::Key_2: //2 --> Down
+ qtcode = Qt::Key_Down;
+ break;
+ case Qt::Key_3: //3 --> PgDn
+ qtcode = Qt::Key_PageDown;
+ break;
+ case Qt::Key_0: //0 --> Ins
+ qtcode = Qt::Key_Insert;
+ break;
+ case Qt::Key_Period: //. --> Del
+ qtcode = Qt::Key_Delete;
+ break;
+ }
+ qtcode |= oldMask;
+ }
+
+ // send the result to the server
+ processKeyEvent(keycode, unicode, qtcode & ~modmask,
+ Qt::KeyboardModifiers(qtcode & modmask), pressed, autorepeat);
+ }
+}
+
+void QBsdKeyboardHandler::switchLed(int led, bool state)
+{
+#ifdef QT_BSD_KEYBOARD_DEBUG
+ qWarning() << "switchLed" << led << state;
+#endif
+ int leds = 0;
+ if (ioctl(m_fd, KDGETLED, &leds) < 0) {
+ qWarning("switchLed: Failed to query led states.");
+ return;
+ }
+
+ if (state)
+ leds |= led;
+ else
+ leds &= ~led;
+
+ if (ioctl(m_fd, KDSETLED, leds) < 0)
+ qWarning("switchLed: Failed to set led states.");
+}
+
+void QBsdKeyboardHandler::resetKeymap()
+{
+#ifdef QT_BSD_KEYBOARD_DEBUG
+ qWarning() << "Unload current keymap and restore built-in";
+#endif
+
+ m_keymap.clear();
+
+ const size_t mappingSize = sizeof(keymapDefault) / sizeof(keymapDefault[0]);
+ m_keymap.resize(mappingSize);
+ std::copy_n( &keymapDefault[0], mappingSize, m_keymap.begin() );
+
+ // reset state, so we could switch keymaps at runtime
+ m_modifiers = 0;
+ m_capsLock = false;
+ m_numLock = false;
+ m_scrollLock = false;
+
+ //Set locks according to keyboard leds
+ int leds = 0;
+ if (ioctl(m_fd, KDGETLED, &leds) < 0) {
+ qWarning("Failed to query led states. Settings numlock & capslock off");
+ switchLed(LED_NUM, false);
+ switchLed(LED_CAP, false);
+ switchLed(LED_SCR, false);
+ } else {
+ if ((leds & LED_CAP) > 0)
+ m_capsLock = true;
+ if ((leds & LED_NUM) > 0)
+ m_numLock = true;
+ if ((leds & LED_SCR) > 0)
+ m_scrollLock = true;
+#ifdef QT_BSD_KEYBOARD_DEBUG
+ qWarning("numlock=%d , capslock=%d, scrolllock=%d",m_numLock, m_capsLock, m_scrollLock);
+#endif
+ }
+}
diff --git a/src/plugins/generic/bsdkeyboard/qbsdkeyboard.h b/src/plugins/generic/bsdkeyboard/qbsdkeyboard.h
new file mode 100644
index 0000000000..1a7cbc1f9a
--- /dev/null
+++ b/src/plugins/generic/bsdkeyboard/qbsdkeyboard.h
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2015-2016 Oleksandr Tymoshenko <gonzo@bluezbox.com>
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBSDKEYBOARD_H
+#define QBSDKEYBOARD_H
+
+#include <qobject.h>
+#include <QDataStream>
+#include <QVector>
+
+QT_BEGIN_NAMESPACE
+
+class QSocketNotifier;
+
+struct termios;
+
+enum {
+ Bsd_NoKeyMode = -1
+};
+
+namespace QBsdKeyboardMap {
+ const quint32 FileMagic = 0x514d4150; // 'QMAP'
+
+ struct Mapping {
+ quint16 keycode;
+ quint16 unicode;
+ quint32 qtcode;
+ quint8 modifiers;
+ quint8 flags;
+ quint16 special;
+
+ };
+
+ enum Flags {
+ NoFlags = 0x00,
+ IsLetter = 0x01,
+ IsModifier = 0x02
+ };
+
+ enum Modifiers {
+ ModPlain = 0x00,
+ ModShift = 0x01,
+ ModAltGr = 0x02,
+ ModControl = 0x04,
+ ModAlt = 0x08,
+ ModShiftL = 0x10,
+ ModShiftR = 0x20,
+ ModCtrlL = 0x40,
+ ModCtrlR = 0x80
+ // ModCapsShift = 0x100, // not supported!
+ };
+}
+
+inline QDataStream &operator>>(QDataStream &ds, QBsdKeyboardMap::Mapping &m)
+{
+ return ds >> m.keycode >> m.unicode >> m.qtcode >> m.modifiers >> m.flags >> m.special;
+}
+
+class QBsdKeyboardHandler : public QObject
+{
+ Q_OBJECT
+
+public:
+ QBsdKeyboardHandler(const QString &key, const QString &specification);
+ ~QBsdKeyboardHandler() override;
+
+ static Qt::KeyboardModifiers toQtModifiers(quint8 mod)
+ {
+ Qt::KeyboardModifiers qtmod = Qt::NoModifier;
+
+ if (mod & (QBsdKeyboardMap::ModShift | QBsdKeyboardMap::ModShiftL | QBsdKeyboardMap::ModShiftR))
+ qtmod |= Qt::ShiftModifier;
+ if (mod & (QBsdKeyboardMap::ModControl | QBsdKeyboardMap::ModCtrlL | QBsdKeyboardMap::ModCtrlR))
+ qtmod |= Qt::ControlModifier;
+ if (mod & QBsdKeyboardMap::ModAlt)
+ qtmod |= Qt::AltModifier;
+
+ return qtmod;
+ }
+
+protected:
+ void switchLed(int led, bool state);
+ void processKeycode(quint16 keycode, bool pressed, bool autorepeat);
+ void processKeyEvent(int nativecode, int unicode, int qtcode,
+ Qt::KeyboardModifiers modifiers, bool isPress, bool autoRepeat);
+ void revertTTYSettings();
+ void resetKeymap();
+ void readKeyboardData();
+
+private:
+ QScopedPointer<QSocketNotifier> m_notifier;
+ QScopedPointer<termios> m_kbdOrigTty;
+ int m_origKbdMode = Bsd_NoKeyMode;
+ int m_fd = -1;
+ bool m_shouldClose = false;
+ QString m_spec;
+
+ // keymap handling
+ quint8 m_modifiers = 0;
+ bool m_capsLock = false;
+ bool m_numLock = false;
+ bool m_scrollLock = false;
+
+ QVector<QBsdKeyboardMap::Mapping> m_keymap;
+};
+
+QT_END_NAMESPACE
+
+#endif // QBSDKEYBOARD_H
diff --git a/src/plugins/generic/bsdkeyboard/qbsdkeyboard_defaultmap.h b/src/plugins/generic/bsdkeyboard/qbsdkeyboard_defaultmap.h
new file mode 100644
index 0000000000..45cf5944bc
--- /dev/null
+++ b/src/plugins/generic/bsdkeyboard/qbsdkeyboard_defaultmap.h
@@ -0,0 +1,622 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015-2016 Oleksandr Tymoshenko <gonzo@bluezbox.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBSDKEYBOARD_DEFAULTMAP_P_H
+#define QBSDKEYBOARD_DEFAULTMAP_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qnamespace.h"
+
+// no QT_BEGIN_NAMESPACE, since we include it internally...
+using namespace QBsdKeyboardMap;
+
+#define QCTRL(x) ((x) | Qt::ControlModifier)
+#define QALT(x) ((x) | Qt::AltModifier)
+#define QKEYPAD(x) ((x) | Qt::KeypadModifier)
+
+const QBsdKeyboardMap::Mapping keymapDefault[] = {
+ { 1, 0xffff, Qt::Key_Escape, ModPlain, NoFlags, 0x0000 },
+ { 2, 0x0031, Qt::Key_1, ModPlain, NoFlags, 0x0000 },
+ { 2, 0x0021, Qt::Key_Exclam, ModShift, NoFlags, 0x0000 },
+ { 3, 0x0032, Qt::Key_2, ModPlain, NoFlags, 0x0000 },
+ { 3, 0x0040, Qt::Key_At, ModShift, NoFlags, 0x0000 },
+ { 3, 0x0040, Qt::Key_At, ModAltGr, NoFlags, 0x0000 },
+ { 4, 0x0033, Qt::Key_3, ModPlain, NoFlags, 0x0000 },
+ { 4, 0x0023, Qt::Key_NumberSign, ModShift, NoFlags, 0x0000 },
+ { 4, 0xffff, Qt::Key_Escape, ModControl, NoFlags, 0x0000 },
+ { 5, 0x0034, Qt::Key_4, ModPlain, NoFlags, 0x0000 },
+ { 5, 0x0024, Qt::Key_Dollar, ModShift, NoFlags, 0x0000 },
+ { 5, 0x0024, Qt::Key_Dollar, ModAltGr, NoFlags, 0x0000 },
+ { 5, 0x005c, QCTRL(Qt::Key_Backslash), ModControl, NoFlags, 0x0000 },
+ { 6, 0x0035, Qt::Key_5, ModPlain, NoFlags, 0x0000 },
+ { 6, 0x0025, Qt::Key_Percent, ModShift, NoFlags, 0x0000 },
+ { 6, 0x005d, QCTRL(Qt::Key_BracketRight), ModControl, NoFlags, 0x0000 },
+ { 7, 0x0036, Qt::Key_6, ModPlain, NoFlags, 0x0000 },
+ { 7, 0x005e, Qt::Key_AsciiCircum, ModShift, NoFlags, 0x0000 },
+ { 7, 0x005e, QCTRL(Qt::Key_AsciiCircum), ModControl, NoFlags, 0x0000 },
+ { 8, 0x0037, Qt::Key_7, ModPlain, NoFlags, 0x0000 },
+ { 8, 0x0026, Qt::Key_Ampersand, ModShift, NoFlags, 0x0000 },
+ { 8, 0x007b, Qt::Key_BraceLeft, ModAltGr, NoFlags, 0x0000 },
+ { 8, 0x005f, QCTRL(Qt::Key_Underscore), ModControl, NoFlags, 0x0000 },
+ { 9, 0x0038, Qt::Key_8, ModPlain, NoFlags, 0x0000 },
+ { 9, 0x002a, Qt::Key_Asterisk, ModShift, NoFlags, 0x0000 },
+ { 9, 0x005b, Qt::Key_BracketLeft, ModAltGr, NoFlags, 0x0000 },
+ { 9, 0xffff, Qt::Key_Backspace, ModControl, NoFlags, 0x0000 },
+ { 10, 0x0039, Qt::Key_9, ModPlain, NoFlags, 0x0000 },
+ { 10, 0x0028, Qt::Key_ParenLeft, ModShift, NoFlags, 0x0000 },
+ { 10, 0x005d, Qt::Key_BracketRight, ModAltGr, NoFlags, 0x0000 },
+ { 11, 0x0030, Qt::Key_0, ModPlain, NoFlags, 0x0000 },
+ { 11, 0x0029, Qt::Key_ParenRight, ModShift, NoFlags, 0x0000 },
+ { 11, 0x007d, Qt::Key_BraceRight, ModAltGr, NoFlags, 0x0000 },
+ { 12, 0x002d, Qt::Key_Minus, ModPlain, NoFlags, 0x0000 },
+ { 12, 0x005f, Qt::Key_Underscore, ModShift, NoFlags, 0x0000 },
+ { 12, 0x005c, Qt::Key_Backslash, ModAltGr, NoFlags, 0x0000 },
+ { 12, 0x005f, QCTRL(Qt::Key_Underscore), ModControl, NoFlags, 0x0000 },
+ { 12, 0x005f, QCTRL(Qt::Key_Underscore), ModShift | ModControl, NoFlags, 0x0000 },
+ { 13, 0x003d, Qt::Key_Equal, ModPlain, NoFlags, 0x0000 },
+ { 13, 0x002b, Qt::Key_Plus, ModShift, NoFlags, 0x0000 },
+ { 14, 0xffff, Qt::Key_Backspace, ModPlain, NoFlags, 0x0000 },
+ { 15, 0xffff, Qt::Key_Tab, ModPlain, NoFlags, 0x0000 },
+ { 16, 0x0071, Qt::Key_Q, ModPlain, IsLetter, 0x0000 },
+ { 16, 0x0051, Qt::Key_Q, ModShift, IsLetter, 0x0000 },
+ { 16, 0x0071, Qt::Key_Q, ModAltGr, IsLetter, 0x0000 },
+ { 16, 0x0051, Qt::Key_Q, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 16, 0x0071, QCTRL(Qt::Key_Q), ModControl, IsLetter, 0x0000 },
+ { 16, 0x0071, QCTRL(Qt::Key_Q), ModShift | ModControl, IsLetter, 0x0000 },
+ { 16, 0x0071, QCTRL(Qt::Key_Q), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 16, 0x0071, QCTRL(Qt::Key_Q), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 16, 0x0071, QALT(Qt::Key_Q), ModAlt, IsLetter, 0x0000 },
+ { 16, 0x0071, QALT(Qt::Key_Q), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 16, 0x0071, QALT(Qt::Key_Q), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 16, 0x0071, QALT(Qt::Key_Q), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 16, 0x0071, QCTRL(QALT(Qt::Key_Q)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 16, 0x0071, QCTRL(QALT(Qt::Key_Q)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 16, 0x0071, QCTRL(QALT(Qt::Key_Q)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 16, 0x0071, QCTRL(QALT(Qt::Key_Q)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 17, 0x0077, Qt::Key_W, ModPlain, IsLetter, 0x0000 },
+ { 17, 0x0057, Qt::Key_W, ModShift, IsLetter, 0x0000 },
+ { 17, 0x0077, Qt::Key_W, ModAltGr, IsLetter, 0x0000 },
+ { 17, 0x0057, Qt::Key_W, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 17, 0x0077, QCTRL(Qt::Key_W), ModControl, IsLetter, 0x0000 },
+ { 17, 0x0077, QCTRL(Qt::Key_W), ModShift | ModControl, IsLetter, 0x0000 },
+ { 17, 0x0077, QCTRL(Qt::Key_W), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 17, 0x0077, QCTRL(Qt::Key_W), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 17, 0x0077, QALT(Qt::Key_W), ModAlt, IsLetter, 0x0000 },
+ { 17, 0x0077, QALT(Qt::Key_W), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 17, 0x0077, QALT(Qt::Key_W), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 17, 0x0077, QALT(Qt::Key_W), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 17, 0x0077, QCTRL(QALT(Qt::Key_W)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 17, 0x0077, QCTRL(QALT(Qt::Key_W)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 17, 0x0077, QCTRL(QALT(Qt::Key_W)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 17, 0x0077, QCTRL(QALT(Qt::Key_W)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 18, 0x0065, Qt::Key_E, ModPlain, IsLetter, 0x0000 },
+ { 18, 0x0045, Qt::Key_E, ModShift, IsLetter, 0x0000 },
+ { 18, 0x0065, Qt::Key_E, ModAltGr, IsLetter, 0x0000 },
+ { 18, 0x0045, Qt::Key_E, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 18, 0x0065, QCTRL(Qt::Key_E), ModControl, IsLetter, 0x0000 },
+ { 18, 0x0065, QCTRL(Qt::Key_E), ModShift | ModControl, IsLetter, 0x0000 },
+ { 18, 0x0065, QCTRL(Qt::Key_E), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 18, 0x0065, QCTRL(Qt::Key_E), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 18, 0x0065, QALT(Qt::Key_E), ModAlt, IsLetter, 0x0000 },
+ { 18, 0x0065, QALT(Qt::Key_E), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 18, 0x0065, QALT(Qt::Key_E), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 18, 0x0065, QALT(Qt::Key_E), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 18, 0x0065, QCTRL(QALT(Qt::Key_E)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 18, 0x0065, QCTRL(QALT(Qt::Key_E)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 18, 0x0065, QCTRL(QALT(Qt::Key_E)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 18, 0x0065, QCTRL(QALT(Qt::Key_E)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 19, 0x0072, Qt::Key_R, ModPlain, IsLetter, 0x0000 },
+ { 19, 0x0052, Qt::Key_R, ModShift, IsLetter, 0x0000 },
+ { 19, 0x0072, Qt::Key_R, ModAltGr, IsLetter, 0x0000 },
+ { 19, 0x0052, Qt::Key_R, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 19, 0x0072, QCTRL(Qt::Key_R), ModControl, IsLetter, 0x0000 },
+ { 19, 0x0072, QCTRL(Qt::Key_R), ModShift | ModControl, IsLetter, 0x0000 },
+ { 19, 0x0072, QCTRL(Qt::Key_R), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 19, 0x0072, QCTRL(Qt::Key_R), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 19, 0x0072, QALT(Qt::Key_R), ModAlt, IsLetter, 0x0000 },
+ { 19, 0x0072, QALT(Qt::Key_R), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 19, 0x0072, QALT(Qt::Key_R), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 19, 0x0072, QALT(Qt::Key_R), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 19, 0x0072, QCTRL(QALT(Qt::Key_R)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 19, 0x0072, QCTRL(QALT(Qt::Key_R)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 19, 0x0072, QCTRL(QALT(Qt::Key_R)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 19, 0x0072, QCTRL(QALT(Qt::Key_R)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 20, 0x0074, Qt::Key_T, ModPlain, IsLetter, 0x0000 },
+ { 20, 0x0054, Qt::Key_T, ModShift, IsLetter, 0x0000 },
+ { 20, 0x0074, Qt::Key_T, ModAltGr, IsLetter, 0x0000 },
+ { 20, 0x0054, Qt::Key_T, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 20, 0x0074, QCTRL(Qt::Key_T), ModControl, IsLetter, 0x0000 },
+ { 20, 0x0074, QCTRL(Qt::Key_T), ModShift | ModControl, IsLetter, 0x0000 },
+ { 20, 0x0074, QCTRL(Qt::Key_T), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 20, 0x0074, QCTRL(Qt::Key_T), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 20, 0x0074, QALT(Qt::Key_T), ModAlt, IsLetter, 0x0000 },
+ { 20, 0x0074, QALT(Qt::Key_T), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 20, 0x0074, QALT(Qt::Key_T), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 20, 0x0074, QALT(Qt::Key_T), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 20, 0x0074, QCTRL(QALT(Qt::Key_T)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 20, 0x0074, QCTRL(QALT(Qt::Key_T)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 20, 0x0074, QCTRL(QALT(Qt::Key_T)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 20, 0x0074, QCTRL(QALT(Qt::Key_T)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 21, 0x0079, Qt::Key_Y, ModPlain, IsLetter, 0x0000 },
+ { 21, 0x0059, Qt::Key_Y, ModShift, IsLetter, 0x0000 },
+ { 21, 0x0079, Qt::Key_Y, ModAltGr, IsLetter, 0x0000 },
+ { 21, 0x0059, Qt::Key_Y, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 21, 0x0079, QCTRL(Qt::Key_Y), ModControl, IsLetter, 0x0000 },
+ { 21, 0x0079, QCTRL(Qt::Key_Y), ModShift | ModControl, IsLetter, 0x0000 },
+ { 21, 0x0079, QCTRL(Qt::Key_Y), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 21, 0x0079, QCTRL(Qt::Key_Y), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 21, 0x0079, QALT(Qt::Key_Y), ModAlt, IsLetter, 0x0000 },
+ { 21, 0x0079, QALT(Qt::Key_Y), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 21, 0x0079, QALT(Qt::Key_Y), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 21, 0x0079, QALT(Qt::Key_Y), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 21, 0x0079, QCTRL(QALT(Qt::Key_Y)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 21, 0x0079, QCTRL(QALT(Qt::Key_Y)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 21, 0x0079, QCTRL(QALT(Qt::Key_Y)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 21, 0x0079, QCTRL(QALT(Qt::Key_Y)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 22, 0x0075, Qt::Key_U, ModPlain, IsLetter, 0x0000 },
+ { 22, 0x0055, Qt::Key_U, ModShift, IsLetter, 0x0000 },
+ { 22, 0x0075, Qt::Key_U, ModAltGr, IsLetter, 0x0000 },
+ { 22, 0x0055, Qt::Key_U, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 22, 0x0075, QCTRL(Qt::Key_U), ModControl, IsLetter, 0x0000 },
+ { 22, 0x0075, QCTRL(Qt::Key_U), ModShift | ModControl, IsLetter, 0x0000 },
+ { 22, 0x0075, QCTRL(Qt::Key_U), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 22, 0x0075, QCTRL(Qt::Key_U), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 22, 0x0075, QALT(Qt::Key_U), ModAlt, IsLetter, 0x0000 },
+ { 22, 0x0075, QALT(Qt::Key_U), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 22, 0x0075, QALT(Qt::Key_U), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 22, 0x0075, QALT(Qt::Key_U), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 22, 0x0075, QCTRL(QALT(Qt::Key_U)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 22, 0x0075, QCTRL(QALT(Qt::Key_U)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 22, 0x0075, QCTRL(QALT(Qt::Key_U)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 22, 0x0075, QCTRL(QALT(Qt::Key_U)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 23, 0x0069, Qt::Key_I, ModPlain, IsLetter, 0x0000 },
+ { 23, 0x0049, Qt::Key_I, ModShift, IsLetter, 0x0000 },
+ { 23, 0x0069, Qt::Key_I, ModAltGr, IsLetter, 0x0000 },
+ { 23, 0x0049, Qt::Key_I, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 23, 0x0069, QCTRL(Qt::Key_I), ModControl, IsLetter, 0x0000 },
+ { 23, 0x0069, QCTRL(Qt::Key_I), ModShift | ModControl, IsLetter, 0x0000 },
+ { 23, 0x0069, QCTRL(Qt::Key_I), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 23, 0x0069, QCTRL(Qt::Key_I), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 23, 0x0069, QALT(Qt::Key_I), ModAlt, IsLetter, 0x0000 },
+ { 23, 0x0069, QALT(Qt::Key_I), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 23, 0x0069, QALT(Qt::Key_I), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 23, 0x0069, QALT(Qt::Key_I), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 23, 0x0069, QCTRL(QALT(Qt::Key_I)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 23, 0x0069, QCTRL(QALT(Qt::Key_I)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 23, 0x0069, QCTRL(QALT(Qt::Key_I)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 23, 0x0069, QCTRL(QALT(Qt::Key_I)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 24, 0x006f, Qt::Key_O, ModPlain, IsLetter, 0x0000 },
+ { 24, 0x004f, Qt::Key_O, ModShift, IsLetter, 0x0000 },
+ { 24, 0x006f, Qt::Key_O, ModAltGr, IsLetter, 0x0000 },
+ { 24, 0x004f, Qt::Key_O, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 24, 0x006f, QCTRL(Qt::Key_O), ModControl, IsLetter, 0x0000 },
+ { 24, 0x006f, QCTRL(Qt::Key_O), ModShift | ModControl, IsLetter, 0x0000 },
+ { 24, 0x006f, QCTRL(Qt::Key_O), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 24, 0x006f, QCTRL(Qt::Key_O), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 24, 0x006f, QALT(Qt::Key_O), ModAlt, IsLetter, 0x0000 },
+ { 24, 0x006f, QALT(Qt::Key_O), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 24, 0x006f, QALT(Qt::Key_O), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 24, 0x006f, QALT(Qt::Key_O), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 24, 0x006f, QCTRL(QALT(Qt::Key_O)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 24, 0x006f, QCTRL(QALT(Qt::Key_O)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 24, 0x006f, QCTRL(QALT(Qt::Key_O)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 24, 0x006f, QCTRL(QALT(Qt::Key_O)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 25, 0x0070, Qt::Key_P, ModPlain, IsLetter, 0x0000 },
+ { 25, 0x0050, Qt::Key_P, ModShift, IsLetter, 0x0000 },
+ { 25, 0x0070, Qt::Key_P, ModAltGr, IsLetter, 0x0000 },
+ { 25, 0x0050, Qt::Key_P, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 25, 0x0070, QCTRL(Qt::Key_P), ModControl, IsLetter, 0x0000 },
+ { 25, 0x0070, QCTRL(Qt::Key_P), ModShift | ModControl, IsLetter, 0x0000 },
+ { 25, 0x0070, QCTRL(Qt::Key_P), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 25, 0x0070, QCTRL(Qt::Key_P), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 25, 0x0070, QALT(Qt::Key_P), ModAlt, IsLetter, 0x0000 },
+ { 25, 0x0070, QALT(Qt::Key_P), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 25, 0x0070, QALT(Qt::Key_P), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 25, 0x0070, QALT(Qt::Key_P), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 25, 0x0070, QCTRL(QALT(Qt::Key_P)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 25, 0x0070, QCTRL(QALT(Qt::Key_P)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 25, 0x0070, QCTRL(QALT(Qt::Key_P)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 25, 0x0070, QCTRL(QALT(Qt::Key_P)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 26, 0x005b, Qt::Key_BracketLeft, ModPlain, NoFlags, 0x0000 },
+ { 26, 0x007b, Qt::Key_BraceLeft, ModShift, NoFlags, 0x0000 },
+ { 26, 0xffff, Qt::Key_Escape, ModControl, NoFlags, 0x0000 },
+ { 27, 0x005d, Qt::Key_BracketRight, ModPlain, NoFlags, 0x0000 },
+ { 27, 0x007d, Qt::Key_BraceRight, ModShift, NoFlags, 0x0000 },
+ { 27, 0x007e, Qt::Key_AsciiTilde, ModAltGr, NoFlags, 0x0000 },
+ { 27, 0x005d, QCTRL(Qt::Key_BracketRight), ModControl, NoFlags, 0x0000 },
+ { 28, 0xffff, Qt::Key_Return, ModPlain, NoFlags, 0x0000 },
+ { 28, 0x006d, QCTRL(QALT(Qt::Key_M)), ModAlt, NoFlags, 0x0000 },
+ { 29, 0xffff, Qt::Key_Control, ModPlain, IsModifier, ModControl },
+ { 30, 0x0061, Qt::Key_A, ModPlain, IsLetter, 0x0000 },
+ { 30, 0x0041, Qt::Key_A, ModShift, IsLetter, 0x0000 },
+ { 30, 0x0061, Qt::Key_A, ModAltGr, IsLetter, 0x0000 },
+ { 30, 0x0041, Qt::Key_A, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 30, 0x0061, QCTRL(Qt::Key_A), ModControl, IsLetter, 0x0000 },
+ { 30, 0x0061, QCTRL(Qt::Key_A), ModShift | ModControl, IsLetter, 0x0000 },
+ { 30, 0x0061, QCTRL(Qt::Key_A), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 30, 0x0061, QCTRL(Qt::Key_A), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 30, 0x0061, QALT(Qt::Key_A), ModAlt, IsLetter, 0x0000 },
+ { 30, 0x0061, QALT(Qt::Key_A), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 30, 0x0061, QALT(Qt::Key_A), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 30, 0x0061, QALT(Qt::Key_A), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 30, 0x0061, QCTRL(QALT(Qt::Key_A)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 30, 0x0061, QCTRL(QALT(Qt::Key_A)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 30, 0x0061, QCTRL(QALT(Qt::Key_A)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 30, 0x0061, QCTRL(QALT(Qt::Key_A)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 31, 0x0073, Qt::Key_S, ModPlain, IsLetter, 0x0000 },
+ { 31, 0x0053, Qt::Key_S, ModShift, IsLetter, 0x0000 },
+ { 31, 0x0073, Qt::Key_S, ModAltGr, IsLetter, 0x0000 },
+ { 31, 0x0053, Qt::Key_S, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 31, 0x0073, QCTRL(Qt::Key_S), ModControl, IsLetter, 0x0000 },
+ { 31, 0x0073, QCTRL(Qt::Key_S), ModShift | ModControl, IsLetter, 0x0000 },
+ { 31, 0x0073, QCTRL(Qt::Key_S), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 31, 0x0073, QCTRL(Qt::Key_S), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 31, 0x0073, QALT(Qt::Key_S), ModAlt, IsLetter, 0x0000 },
+ { 31, 0x0073, QALT(Qt::Key_S), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 31, 0x0073, QALT(Qt::Key_S), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 31, 0x0073, QALT(Qt::Key_S), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 31, 0x0073, QCTRL(QALT(Qt::Key_S)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 31, 0x0073, QCTRL(QALT(Qt::Key_S)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 31, 0x0073, QCTRL(QALT(Qt::Key_S)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 31, 0x0073, QCTRL(QALT(Qt::Key_S)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 32, 0x0064, Qt::Key_D, ModPlain, IsLetter, 0x0000 },
+ { 32, 0x0044, Qt::Key_D, ModShift, IsLetter, 0x0000 },
+ { 32, 0x0064, Qt::Key_D, ModAltGr, IsLetter, 0x0000 },
+ { 32, 0x0044, Qt::Key_D, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 32, 0x0064, QCTRL(Qt::Key_D), ModControl, IsLetter, 0x0000 },
+ { 32, 0x0064, QCTRL(Qt::Key_D), ModShift | ModControl, IsLetter, 0x0000 },
+ { 32, 0x0064, QCTRL(Qt::Key_D), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 32, 0x0064, QCTRL(Qt::Key_D), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 32, 0x0064, QALT(Qt::Key_D), ModAlt, IsLetter, 0x0000 },
+ { 32, 0x0064, QALT(Qt::Key_D), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 32, 0x0064, QALT(Qt::Key_D), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 32, 0x0064, QALT(Qt::Key_D), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 32, 0x0064, QCTRL(QALT(Qt::Key_D)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 32, 0x0064, QCTRL(QALT(Qt::Key_D)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 32, 0x0064, QCTRL(QALT(Qt::Key_D)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 32, 0x0064, QCTRL(QALT(Qt::Key_D)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 33, 0x0066, Qt::Key_F, ModPlain, IsLetter, 0x0000 },
+ { 33, 0x0046, Qt::Key_F, ModShift, IsLetter, 0x0000 },
+ { 33, 0x0066, Qt::Key_F, ModAltGr, IsLetter, 0x0000 },
+ { 33, 0x0046, Qt::Key_F, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 33, 0x0066, QCTRL(Qt::Key_F), ModControl, IsLetter, 0x0000 },
+ { 33, 0x0066, QCTRL(Qt::Key_F), ModShift | ModControl, IsLetter, 0x0000 },
+ { 33, 0x0066, QCTRL(Qt::Key_F), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 33, 0x0066, QCTRL(Qt::Key_F), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 33, 0x0066, QALT(Qt::Key_F), ModAlt, IsLetter, 0x0000 },
+ { 33, 0x0066, QALT(Qt::Key_F), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 33, 0x0066, QALT(Qt::Key_F), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 33, 0x0066, QALT(Qt::Key_F), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 33, 0x0066, QCTRL(QALT(Qt::Key_F)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 33, 0x0066, QCTRL(QALT(Qt::Key_F)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 33, 0x0066, QCTRL(QALT(Qt::Key_F)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 33, 0x0066, QCTRL(QALT(Qt::Key_F)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 34, 0x0067, Qt::Key_G, ModPlain, IsLetter, 0x0000 },
+ { 34, 0x0047, Qt::Key_G, ModShift, IsLetter, 0x0000 },
+ { 34, 0x0067, Qt::Key_G, ModAltGr, IsLetter, 0x0000 },
+ { 34, 0x0047, Qt::Key_G, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 34, 0x0067, QCTRL(Qt::Key_G), ModControl, IsLetter, 0x0000 },
+ { 34, 0x0067, QCTRL(Qt::Key_G), ModShift | ModControl, IsLetter, 0x0000 },
+ { 34, 0x0067, QCTRL(Qt::Key_G), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 34, 0x0067, QCTRL(Qt::Key_G), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 34, 0x0067, QALT(Qt::Key_G), ModAlt, IsLetter, 0x0000 },
+ { 34, 0x0067, QALT(Qt::Key_G), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 34, 0x0067, QALT(Qt::Key_G), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 34, 0x0067, QALT(Qt::Key_G), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 34, 0x0067, QCTRL(QALT(Qt::Key_G)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 34, 0x0067, QCTRL(QALT(Qt::Key_G)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 34, 0x0067, QCTRL(QALT(Qt::Key_G)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 34, 0x0067, QCTRL(QALT(Qt::Key_G)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 35, 0x0068, Qt::Key_H, ModPlain, IsLetter, 0x0000 },
+ { 35, 0x0048, Qt::Key_H, ModShift, IsLetter, 0x0000 },
+ { 35, 0x0068, Qt::Key_H, ModAltGr, IsLetter, 0x0000 },
+ { 35, 0x0048, Qt::Key_H, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 35, 0x0068, QCTRL(Qt::Key_H), ModControl, IsLetter, 0x0000 },
+ { 35, 0x0068, QCTRL(Qt::Key_H), ModShift | ModControl, IsLetter, 0x0000 },
+ { 35, 0x0068, QCTRL(Qt::Key_H), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 35, 0x0068, QCTRL(Qt::Key_H), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 35, 0x0068, QALT(Qt::Key_H), ModAlt, IsLetter, 0x0000 },
+ { 35, 0x0068, QALT(Qt::Key_H), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 35, 0x0068, QALT(Qt::Key_H), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 35, 0x0068, QALT(Qt::Key_H), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 35, 0x0068, QCTRL(QALT(Qt::Key_H)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 35, 0x0068, QCTRL(QALT(Qt::Key_H)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 35, 0x0068, QCTRL(QALT(Qt::Key_H)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 35, 0x0068, QCTRL(QALT(Qt::Key_H)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 36, 0x006a, Qt::Key_J, ModPlain, IsLetter, 0x0000 },
+ { 36, 0x004a, Qt::Key_J, ModShift, IsLetter, 0x0000 },
+ { 36, 0x006a, Qt::Key_J, ModAltGr, IsLetter, 0x0000 },
+ { 36, 0x004a, Qt::Key_J, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 36, 0x006a, QCTRL(Qt::Key_J), ModControl, IsLetter, 0x0000 },
+ { 36, 0x006a, QCTRL(Qt::Key_J), ModShift | ModControl, IsLetter, 0x0000 },
+ { 36, 0x006a, QCTRL(Qt::Key_J), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 36, 0x006a, QCTRL(Qt::Key_J), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 36, 0x006a, QALT(Qt::Key_J), ModAlt, IsLetter, 0x0000 },
+ { 36, 0x006a, QALT(Qt::Key_J), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 36, 0x006a, QALT(Qt::Key_J), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 36, 0x006a, QALT(Qt::Key_J), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 36, 0x006a, QCTRL(QALT(Qt::Key_J)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 36, 0x006a, QCTRL(QALT(Qt::Key_J)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 36, 0x006a, QCTRL(QALT(Qt::Key_J)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 36, 0x006a, QCTRL(QALT(Qt::Key_J)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 37, 0x006b, Qt::Key_K, ModPlain, IsLetter, 0x0000 },
+ { 37, 0x004b, Qt::Key_K, ModShift, IsLetter, 0x0000 },
+ { 37, 0x006b, Qt::Key_K, ModAltGr, IsLetter, 0x0000 },
+ { 37, 0x004b, Qt::Key_K, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 37, 0x006b, QCTRL(Qt::Key_K), ModControl, IsLetter, 0x0000 },
+ { 37, 0x006b, QCTRL(Qt::Key_K), ModShift | ModControl, IsLetter, 0x0000 },
+ { 37, 0x006b, QCTRL(Qt::Key_K), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 37, 0x006b, QCTRL(Qt::Key_K), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 37, 0x006b, QALT(Qt::Key_K), ModAlt, IsLetter, 0x0000 },
+ { 37, 0x006b, QALT(Qt::Key_K), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 37, 0x006b, QALT(Qt::Key_K), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 37, 0x006b, QALT(Qt::Key_K), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 37, 0x006b, QCTRL(QALT(Qt::Key_K)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 37, 0x006b, QCTRL(QALT(Qt::Key_K)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 37, 0x006b, QCTRL(QALT(Qt::Key_K)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 37, 0x006b, QCTRL(QALT(Qt::Key_K)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 38, 0x006c, Qt::Key_L, ModPlain, IsLetter, 0x0000 },
+ { 38, 0x004c, Qt::Key_L, ModShift, IsLetter, 0x0000 },
+ { 38, 0x006c, Qt::Key_L, ModAltGr, IsLetter, 0x0000 },
+ { 38, 0x004c, Qt::Key_L, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 38, 0x006c, QCTRL(Qt::Key_L), ModControl, IsLetter, 0x0000 },
+ { 38, 0x006c, QCTRL(Qt::Key_L), ModShift | ModControl, IsLetter, 0x0000 },
+ { 38, 0x006c, QCTRL(Qt::Key_L), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 38, 0x006c, QCTRL(Qt::Key_L), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 38, 0x006c, QALT(Qt::Key_L), ModAlt, IsLetter, 0x0000 },
+ { 38, 0x006c, QALT(Qt::Key_L), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 38, 0x006c, QALT(Qt::Key_L), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 38, 0x006c, QALT(Qt::Key_L), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 38, 0x006c, QCTRL(QALT(Qt::Key_L)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 38, 0x006c, QCTRL(QALT(Qt::Key_L)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 38, 0x006c, QCTRL(QALT(Qt::Key_L)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 38, 0x006c, QCTRL(QALT(Qt::Key_L)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 39, 0x003b, Qt::Key_Semicolon, ModPlain, NoFlags, 0x0000 },
+ { 39, 0x003a, Qt::Key_Colon, ModShift, NoFlags, 0x0000 },
+ { 40, 0x0027, Qt::Key_Apostrophe, ModPlain, NoFlags, 0x0000 },
+ { 40, 0x0022, Qt::Key_QuoteDbl, ModShift, NoFlags, 0x0000 },
+ { 40, 0x0067, QCTRL(Qt::Key_G), ModControl, NoFlags, 0x0000 },
+ { 41, 0x0060, Qt::Key_QuoteLeft, ModPlain, NoFlags, 0x0000 },
+ { 41, 0x007e, Qt::Key_AsciiTilde, ModShift, NoFlags, 0x0000 },
+ { 42, 0xffff, Qt::Key_Shift, ModPlain, IsModifier, ModShift },
+ { 43, 0x005c, Qt::Key_Backslash, ModPlain, NoFlags, 0x0000 },
+ { 43, 0x007c, Qt::Key_Bar, ModShift, NoFlags, 0x0000 },
+ { 43, 0x005c, QCTRL(Qt::Key_Backslash), ModControl, NoFlags, 0x0000 },
+ { 44, 0x007a, Qt::Key_Z, ModPlain, IsLetter, 0x0000 },
+ { 44, 0x005a, Qt::Key_Z, ModShift, IsLetter, 0x0000 },
+ { 44, 0x007a, Qt::Key_Z, ModAltGr, IsLetter, 0x0000 },
+ { 44, 0x005a, Qt::Key_Z, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 44, 0x007a, QCTRL(Qt::Key_Z), ModControl, IsLetter, 0x0000 },
+ { 44, 0x007a, QCTRL(Qt::Key_Z), ModShift | ModControl, IsLetter, 0x0000 },
+ { 44, 0x007a, QCTRL(Qt::Key_Z), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 44, 0x007a, QCTRL(Qt::Key_Z), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 44, 0x007a, QALT(Qt::Key_Z), ModAlt, IsLetter, 0x0000 },
+ { 44, 0x007a, QALT(Qt::Key_Z), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 44, 0x007a, QALT(Qt::Key_Z), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 44, 0x007a, QALT(Qt::Key_Z), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 44, 0x007a, QCTRL(QALT(Qt::Key_Z)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 44, 0x007a, QCTRL(QALT(Qt::Key_Z)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 44, 0x007a, QCTRL(QALT(Qt::Key_Z)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 44, 0x007a, QCTRL(QALT(Qt::Key_Z)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 45, 0x0078, Qt::Key_X, ModPlain, IsLetter, 0x0000 },
+ { 45, 0x0058, Qt::Key_X, ModShift, IsLetter, 0x0000 },
+ { 45, 0x0078, Qt::Key_X, ModAltGr, IsLetter, 0x0000 },
+ { 45, 0x0058, Qt::Key_X, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 45, 0x0078, QCTRL(Qt::Key_X), ModControl, IsLetter, 0x0000 },
+ { 45, 0x0078, QCTRL(Qt::Key_X), ModShift | ModControl, IsLetter, 0x0000 },
+ { 45, 0x0078, QCTRL(Qt::Key_X), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 45, 0x0078, QCTRL(Qt::Key_X), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 45, 0x0078, QALT(Qt::Key_X), ModAlt, IsLetter, 0x0000 },
+ { 45, 0x0078, QALT(Qt::Key_X), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 45, 0x0078, QALT(Qt::Key_X), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 45, 0x0078, QALT(Qt::Key_X), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 45, 0x0078, QCTRL(QALT(Qt::Key_X)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 45, 0x0078, QCTRL(QALT(Qt::Key_X)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 45, 0x0078, QCTRL(QALT(Qt::Key_X)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 45, 0x0078, QCTRL(QALT(Qt::Key_X)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 46, 0x0063, Qt::Key_C, ModPlain, IsLetter, 0x0000 },
+ { 46, 0x0043, Qt::Key_C, ModShift, IsLetter, 0x0000 },
+ { 46, 0x0063, Qt::Key_C, ModAltGr, IsLetter, 0x0000 },
+ { 46, 0x0043, Qt::Key_C, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 46, 0x0063, QCTRL(Qt::Key_C), ModControl, IsLetter, 0x0000 },
+ { 46, 0x0063, QCTRL(Qt::Key_C), ModShift | ModControl, IsLetter, 0x0000 },
+ { 46, 0x0063, QCTRL(Qt::Key_C), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 46, 0x0063, QCTRL(Qt::Key_C), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 46, 0x0063, QALT(Qt::Key_C), ModAlt, IsLetter, 0x0000 },
+ { 46, 0x0063, QALT(Qt::Key_C), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 46, 0x0063, QALT(Qt::Key_C), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 46, 0x0063, QALT(Qt::Key_C), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 46, 0x0063, QCTRL(QALT(Qt::Key_C)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 46, 0x0063, QCTRL(QALT(Qt::Key_C)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 46, 0x0063, QCTRL(QALT(Qt::Key_C)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 46, 0x0063, QCTRL(QALT(Qt::Key_C)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 47, 0x0076, Qt::Key_V, ModPlain, IsLetter, 0x0000 },
+ { 47, 0x0056, Qt::Key_V, ModShift, IsLetter, 0x0000 },
+ { 47, 0x0076, Qt::Key_V, ModAltGr, IsLetter, 0x0000 },
+ { 47, 0x0056, Qt::Key_V, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 47, 0x0076, QCTRL(Qt::Key_V), ModControl, IsLetter, 0x0000 },
+ { 47, 0x0076, QCTRL(Qt::Key_V), ModShift | ModControl, IsLetter, 0x0000 },
+ { 47, 0x0076, QCTRL(Qt::Key_V), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 47, 0x0076, QCTRL(Qt::Key_V), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 47, 0x0076, QALT(Qt::Key_V), ModAlt, IsLetter, 0x0000 },
+ { 47, 0x0076, QALT(Qt::Key_V), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 47, 0x0076, QALT(Qt::Key_V), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 47, 0x0076, QALT(Qt::Key_V), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 47, 0x0076, QCTRL(QALT(Qt::Key_V)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 47, 0x0076, QCTRL(QALT(Qt::Key_V)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 47, 0x0076, QCTRL(QALT(Qt::Key_V)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 47, 0x0076, QCTRL(QALT(Qt::Key_V)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 48, 0x0062, Qt::Key_B, ModPlain, IsLetter, 0x0000 },
+ { 48, 0x0042, Qt::Key_B, ModShift, IsLetter, 0x0000 },
+ { 48, 0x0062, Qt::Key_B, ModAltGr, IsLetter, 0x0000 },
+ { 48, 0x0042, Qt::Key_B, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 48, 0x0062, QCTRL(Qt::Key_B), ModControl, IsLetter, 0x0000 },
+ { 48, 0x0062, QCTRL(Qt::Key_B), ModShift | ModControl, IsLetter, 0x0000 },
+ { 48, 0x0062, QCTRL(Qt::Key_B), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 48, 0x0062, QCTRL(Qt::Key_B), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 48, 0x0062, QALT(Qt::Key_B), ModAlt, IsLetter, 0x0000 },
+ { 48, 0x0062, QALT(Qt::Key_B), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 48, 0x0062, QALT(Qt::Key_B), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 48, 0x0062, QALT(Qt::Key_B), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 48, 0x0062, QCTRL(QALT(Qt::Key_B)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 48, 0x0062, QCTRL(QALT(Qt::Key_B)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 48, 0x0062, QCTRL(QALT(Qt::Key_B)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 48, 0x0062, QCTRL(QALT(Qt::Key_B)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 49, 0x006e, Qt::Key_N, ModPlain, IsLetter, 0x0000 },
+ { 49, 0x004e, Qt::Key_N, ModShift, IsLetter, 0x0000 },
+ { 49, 0x006e, Qt::Key_N, ModAltGr, IsLetter, 0x0000 },
+ { 49, 0x004e, Qt::Key_N, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 49, 0x006e, QCTRL(Qt::Key_N), ModControl, IsLetter, 0x0000 },
+ { 49, 0x006e, QCTRL(Qt::Key_N), ModShift | ModControl, IsLetter, 0x0000 },
+ { 49, 0x006e, QCTRL(Qt::Key_N), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 49, 0x006e, QCTRL(Qt::Key_N), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 49, 0x006e, QALT(Qt::Key_N), ModAlt, IsLetter, 0x0000 },
+ { 49, 0x006e, QALT(Qt::Key_N), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 49, 0x006e, QALT(Qt::Key_N), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 49, 0x006e, QALT(Qt::Key_N), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 49, 0x006e, QCTRL(QALT(Qt::Key_N)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 49, 0x006e, QCTRL(QALT(Qt::Key_N)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 49, 0x006e, QCTRL(QALT(Qt::Key_N)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 49, 0x006e, QCTRL(QALT(Qt::Key_N)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 50, 0x006d, Qt::Key_M, ModPlain, IsLetter, 0x0000 },
+ { 50, 0x004d, Qt::Key_M, ModShift, IsLetter, 0x0000 },
+ { 50, 0x006d, Qt::Key_M, ModAltGr, IsLetter, 0x0000 },
+ { 50, 0x004d, Qt::Key_M, ModShift | ModAltGr, IsLetter, 0x0000 },
+ { 50, 0x006d, QCTRL(Qt::Key_M), ModControl, IsLetter, 0x0000 },
+ { 50, 0x006d, QCTRL(Qt::Key_M), ModShift | ModControl, IsLetter, 0x0000 },
+ { 50, 0x006d, QCTRL(Qt::Key_M), ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 50, 0x006d, QCTRL(Qt::Key_M), ModShift | ModAltGr | ModControl, IsLetter, 0x0000 },
+ { 50, 0x006d, QALT(Qt::Key_M), ModAlt, IsLetter, 0x0000 },
+ { 50, 0x006d, QALT(Qt::Key_M), ModShift | ModAlt, IsLetter, 0x0000 },
+ { 50, 0x006d, QALT(Qt::Key_M), ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 50, 0x006d, QALT(Qt::Key_M), ModShift | ModAltGr | ModAlt, IsLetter, 0x0000 },
+ { 50, 0x006d, QCTRL(QALT(Qt::Key_M)), ModControl | ModAlt, IsLetter, 0x0000 },
+ { 50, 0x006d, QCTRL(QALT(Qt::Key_M)), ModShift | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 50, 0x006d, QCTRL(QALT(Qt::Key_M)), ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 50, 0x006d, QCTRL(QALT(Qt::Key_M)), ModShift | ModAltGr | ModControl | ModAlt, IsLetter, 0x0000 },
+ { 51, 0x002c, Qt::Key_Comma, ModPlain, NoFlags, 0x0000 },
+ { 51, 0x003c, Qt::Key_Less, ModShift, NoFlags, 0x0000 },
+ { 52, 0x002e, Qt::Key_Period, ModPlain, NoFlags, 0x0000 },
+ { 52, 0x003e, Qt::Key_Greater, ModShift, NoFlags, 0x0000 },
+ { 52, 0xffff, Qt::Key_Multi_key, ModAltGr, NoFlags, 0x0000 },
+ { 53, 0x002f, Qt::Key_Slash, ModPlain, NoFlags, 0x0000 },
+ { 53, 0x003f, Qt::Key_Question, ModShift, NoFlags, 0x0000 },
+ { 53, 0xffff, Qt::Key_Backspace, ModControl, NoFlags, 0x0000 },
+ { 54, 0xffff, Qt::Key_Shift, ModPlain, IsModifier, ModShift },
+ { 55, 0x002a, QKEYPAD(Qt::Key_Asterisk), ModPlain, NoFlags, 0x0000 },
+ { 56, 0xffff, Qt::Key_Alt, ModPlain, IsModifier, ModAlt },
+ { 57, 0x0020, Qt::Key_Space, ModPlain, NoFlags, 0x0000 },
+ { 58, 0xffff, Qt::Key_CapsLock, ModPlain, NoFlags, 0x0000 },
+ { 59, 0xffff, Qt::Key_F1, ModPlain, NoFlags, 0x0000 },
+ { 59, 0xffff, Qt::Key_F13, ModShift, NoFlags, 0x0000 },
+ { 59, 0xffff, Qt::Key_F25, ModControl, NoFlags, 0x0000 },
+ { 60, 0xffff, Qt::Key_F2, ModPlain, NoFlags, 0x0000 },
+ { 60, 0xffff, Qt::Key_F14, ModShift, NoFlags, 0x0000 },
+ { 60, 0xffff, Qt::Key_F26, ModControl, NoFlags, 0x0000 },
+ { 61, 0xffff, Qt::Key_F3, ModPlain, NoFlags, 0x0000 },
+ { 61, 0xffff, Qt::Key_F15, ModShift, NoFlags, 0x0000 },
+ { 61, 0xffff, Qt::Key_F27, ModControl, NoFlags, 0x0000 },
+ { 62, 0xffff, Qt::Key_F4, ModPlain, NoFlags, 0x0000 },
+ { 62, 0xffff, Qt::Key_F16, ModShift, NoFlags, 0x0000 },
+ { 62, 0xffff, Qt::Key_F28, ModControl, NoFlags, 0x0000 },
+ { 63, 0xffff, Qt::Key_F5, ModPlain, NoFlags, 0x0000 },
+ { 63, 0xffff, Qt::Key_F17, ModShift, NoFlags, 0x0000 },
+ { 63, 0xffff, Qt::Key_F29, ModControl, NoFlags, 0x0000 },
+ { 64, 0xffff, Qt::Key_F6, ModPlain, NoFlags, 0x0000 },
+ { 64, 0xffff, Qt::Key_F18, ModShift, NoFlags, 0x0000 },
+ { 64, 0xffff, Qt::Key_F30, ModControl, NoFlags, 0x0000 },
+ { 65, 0xffff, Qt::Key_F7, ModPlain, NoFlags, 0x0000 },
+ { 65, 0xffff, Qt::Key_F19, ModShift, NoFlags, 0x0000 },
+ { 65, 0xffff, Qt::Key_F31, ModControl, NoFlags, 0x0000 },
+ { 66, 0xffff, Qt::Key_F8, ModPlain, NoFlags, 0x0000 },
+ { 66, 0xffff, Qt::Key_F20, ModShift, NoFlags, 0x0000 },
+ { 66, 0xffff, Qt::Key_F32, ModControl, NoFlags, 0x0000 },
+ { 67, 0xffff, Qt::Key_F9, ModPlain, NoFlags, 0x0000 },
+ { 67, 0xffff, Qt::Key_F21, ModShift, NoFlags, 0x0000 },
+ { 67, 0xffff, Qt::Key_F33, ModControl, NoFlags, 0x0000 },
+ { 68, 0xffff, Qt::Key_F10, ModPlain, NoFlags, 0x0000 },
+ { 68, 0xffff, Qt::Key_F22, ModShift, NoFlags, 0x0000 },
+ { 68, 0xffff, Qt::Key_F34, ModControl, NoFlags, 0x0000 },
+ { 69, 0xffff, Qt::Key_NumLock, ModPlain, NoFlags, 0x0000 },
+ { 70, 0xffff, Qt::Key_ScrollLock, ModPlain, NoFlags, 0x0000 },
+ { 70, 0xffff, Qt::Key_ScrollLock, ModAlt, NoFlags, 0x0000 },
+ { 71, 0x0037, QKEYPAD(Qt::Key_7), ModPlain, NoFlags, 0x0000 },
+ { 72, 0x0038, QKEYPAD(Qt::Key_8), ModPlain, NoFlags, 0x0000 },
+ { 73, 0x0039, QKEYPAD(Qt::Key_9), ModPlain, NoFlags, 0x0000 },
+ { 74, 0x002d, QKEYPAD(Qt::Key_Minus), ModPlain, NoFlags, 0x0000 },
+ { 75, 0x0034, QKEYPAD(Qt::Key_4), ModPlain, NoFlags, 0x0000 },
+ { 76, 0x0035, QKEYPAD(Qt::Key_5), ModPlain, NoFlags, 0x0000 },
+ { 77, 0x0036, QKEYPAD(Qt::Key_6), ModPlain, NoFlags, 0x0000 },
+ { 78, 0x002b, QKEYPAD(Qt::Key_Plus), ModPlain, NoFlags, 0x0000 },
+ { 79, 0x0031, QKEYPAD(Qt::Key_1), ModPlain, NoFlags, 0x0000 },
+ { 80, 0x0032, QKEYPAD(Qt::Key_2), ModPlain, NoFlags, 0x0000 },
+ { 81, 0x0033, QKEYPAD(Qt::Key_3), ModPlain, NoFlags, 0x0000 },
+ { 82, 0x0030, QKEYPAD(Qt::Key_0), ModPlain, NoFlags, 0x0000 },
+ { 83, 0x002e, QKEYPAD(Qt::Key_Period), ModPlain, NoFlags, 0x0000 },
+ { 86, 0x003c, Qt::Key_Less, ModPlain, NoFlags, 0x0000 },
+ { 86, 0x003e, Qt::Key_Greater, ModShift, NoFlags, 0x0000 },
+ { 86, 0x007c, Qt::Key_Bar, ModAltGr, NoFlags, 0x0000 },
+ { 87, 0xffff, Qt::Key_F11, ModPlain, NoFlags, 0x0000 },
+ { 87, 0xffff, Qt::Key_F23, ModShift, NoFlags, 0x0000 },
+ { 87, 0xffff, Qt::Key_F35, ModControl, NoFlags, 0x0000 },
+ { 88, 0xffff, Qt::Key_F12, ModPlain, NoFlags, 0x0000 },
+ { 88, 0xffff, Qt::Key_F24, ModShift, NoFlags, 0x0000 },
+ { 89, 0xffff, QKEYPAD(Qt::Key_Enter), ModPlain, NoFlags, 0x0000 },
+ { 90, 0xffff, Qt::Key_Control, ModPlain, IsModifier, ModControl },
+ { 91, 0x002f, QKEYPAD(Qt::Key_Slash), ModPlain, NoFlags, 0x0000 },
+ { 92, 0x005c, QCTRL(Qt::Key_Backslash), ModPlain, NoFlags, 0x0000 },
+ { 93, 0xffff, Qt::Key_AltGr, ModPlain, IsModifier, ModAltGr },
+ { 94, 0xffff, Qt::Key_Home, ModPlain, NoFlags, 0x0000 },
+ { 95, 0xffff, Qt::Key_Up, ModPlain, NoFlags, 0x0000 },
+ { 96, 0xffff, Qt::Key_PageUp, ModPlain, NoFlags, 0x0000 },
+ { 97, 0xffff, Qt::Key_Left, ModPlain, NoFlags, 0x0000 },
+ { 98, 0xffff, Qt::Key_Right, ModPlain, NoFlags, 0x0000 },
+ { 99, 0xffff, Qt::Key_End, ModPlain, NoFlags, 0x0000 },
+ { 100, 0xffff, Qt::Key_Down, ModPlain, NoFlags, 0x0000 },
+ { 101, 0xffff, Qt::Key_PageDown, ModPlain, NoFlags, 0x0000 },
+ { 102, 0xffff, Qt::Key_Insert, ModPlain, NoFlags, 0x0000 },
+ { 103, 0xffff, Qt::Key_Delete, ModPlain, NoFlags, 0x0000 },
+};
+
+#endif // QBSDKEYBOARD_DEFAULTMAP_P_H
diff --git a/src/plugins/generic/bsdmouse/bsdmouse.json b/src/plugins/generic/bsdmouse/bsdmouse.json
new file mode 100644
index 0000000000..33974a62f2
--- /dev/null
+++ b/src/plugins/generic/bsdmouse/bsdmouse.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "BsdMouse" ]
+}
diff --git a/src/plugins/generic/bsdmouse/bsdmouse.pro b/src/plugins/generic/bsdmouse/bsdmouse.pro
new file mode 100644
index 0000000000..11949b95d5
--- /dev/null
+++ b/src/plugins/generic/bsdmouse/bsdmouse.pro
@@ -0,0 +1,16 @@
+TARGET = qbsdmouseplugin
+
+PLUGIN_TYPE = generic
+PLUGIN_EXTENDS = -
+PLUGIN_CLASS_NAME = QBsdMousePlugin
+load(qt_plugin)
+
+QT += core-private gui-private
+
+HEADERS = qbsdmouse.h
+SOURCES = main.cpp \
+ qbsdmouse.cpp
+
+OTHER_FILES += \
+ qbsdmouse.json
+
diff --git a/src/plugins/generic/bsdmouse/main.cpp b/src/plugins/generic/bsdmouse/main.cpp
new file mode 100644
index 0000000000..4abc7609c1
--- /dev/null
+++ b/src/plugins/generic/bsdmouse/main.cpp
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2015-2016 Oleksandr Tymoshenko <gonzo@bluezbox.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/qgenericplugin.h>
+#include "qbsdmouse.h"
+
+QT_BEGIN_NAMESPACE
+
+class QBsdMousePlugin : public QGenericPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QGenericPluginFactoryInterface" FILE "bsdmouse.json")
+
+public:
+ QObject *create(const QString &key, const QString &specification) override;
+};
+
+QObject *QBsdMousePlugin::create(const QString &key, const QString &specification)
+{
+ if (!key.compare(QLatin1String("BsdMouse"), Qt::CaseInsensitive))
+ return new QBsdMouseHandler(key, specification);
+
+ return nullptr;
+}
+
+QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/src/plugins/generic/bsdmouse/qbsdmouse.cpp b/src/plugins/generic/bsdmouse/qbsdmouse.cpp
new file mode 100644
index 0000000000..4875fd96bd
--- /dev/null
+++ b/src/plugins/generic/bsdmouse/qbsdmouse.cpp
@@ -0,0 +1,165 @@
+/****************************************************************************
+**
+** Copyright (C) 2015-2016 Oleksandr Tymoshenko <gonzo@bluezbox.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbsdmouse.h"
+
+#include <QSocketNotifier>
+#include <QStringList>
+#include <QPoint>
+#include <QGuiApplication>
+#include <qpa/qwindowsysteminterface.h>
+#include <private/qguiapplication_p.h>
+#include <private/qinputdevicemanager_p_p.h>
+
+#include <private/qcore_unix_p.h>
+#include <qdebug.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/mouse.h>
+#include <unistd.h>
+
+QT_BEGIN_NAMESPACE
+
+enum {
+ PsmLevelBasic = 0,
+ PsmLevelExtended = 1,
+ PsmLevelNative = 2
+};
+
+QBsdMouseHandler::QBsdMouseHandler(const QString &key, const QString &specification)
+{
+ Q_UNUSED(key);
+
+ setObjectName(QLatin1String("BSD Sysmouse Handler"));
+
+ QByteArray device;
+ if (specification.startsWith("/dev/"))
+ device = QFile::encodeName(specification);
+
+ if (device.isEmpty())
+ device = QByteArrayLiteral("/dev/sysmouse");
+
+ m_devFd = QT_OPEN(device.constData(), O_RDONLY);
+ if (m_devFd < 0) {
+ qErrnoWarning(errno, "open(%s) failed", device.constData());
+ return;
+ }
+
+ int level = 0;
+ if (ioctl(m_devFd, MOUSE_GETLEVEL, &level)) {
+ qErrnoWarning(errno, "ioctl(%s, MOUSE_GETLEVEL) failed", device.constData());
+ close(m_devFd);
+ m_devFd = -1;
+ return;
+ }
+
+ switch (level) {
+ case PsmLevelBasic:
+ m_packetSize = 5;
+ break;
+ case PsmLevelExtended:
+ m_packetSize = 8;
+ break;
+ default:
+ qWarning("Unsupported mouse device operation level: %d", level);
+ close(m_devFd);
+ m_devFd = -1;
+ return;
+ }
+
+ if (fcntl(m_devFd, F_SETFL, O_NONBLOCK)) {
+ qErrnoWarning(errno, "fcntl(%s, F_SETFL, O_NONBLOCK) failed", device.constData());
+ close(m_devFd);
+ m_devFd = -1;
+ return;
+ }
+
+ m_notifier.reset(new QSocketNotifier(m_devFd, QSocketNotifier::Read, this));
+ connect(m_notifier.data(), &QSocketNotifier::activated, this, &QBsdMouseHandler::readMouseData);
+ QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
+ QInputDeviceManager::DeviceTypePointer, 1);
+}
+
+QBsdMouseHandler::~QBsdMouseHandler()
+{
+ if (m_devFd != -1)
+ close(m_devFd);
+}
+
+void QBsdMouseHandler::readMouseData()
+{
+ if (m_devFd < 0)
+ return;
+
+ if (m_packetSize == 0)
+ return;
+
+ // packet format described in mouse(4)
+ qint8 packet[MOUSE_SYS_PACKETSIZE];
+ quint8 status = 0;
+ while (read(m_devFd, packet, m_packetSize) == m_packetSize) {
+ const qint16 relx = packet[1] + packet[3];
+ const qint16 rely = -(packet[2] + packet[4]);
+
+ m_x += relx;
+ m_y += rely;
+
+ status = packet[0] & MOUSE_SYS_STDBUTTONS;
+ }
+
+ // clamp to screen geometry
+ const QRect g = QGuiApplication::primaryScreen()->virtualGeometry();
+ if (m_x + m_xOffset < g.left())
+ m_x = g.left() - m_xOffset;
+ else if (m_x + m_xOffset > g.right())
+ m_x = g.right() - m_xOffset;
+
+ if (m_y + m_yOffset < g.top())
+ m_y = g.top() - m_yOffset;
+ else if (m_y + m_yOffset > g.bottom())
+ m_y = g.bottom() - m_yOffset;
+
+ const QPoint pos(m_x + m_xOffset, m_y + m_yOffset);
+ m_buttons = Qt::NoButton;
+ if (!(status & MOUSE_SYS_BUTTON1UP))
+ m_buttons |= Qt::LeftButton;
+ if (!(status & MOUSE_SYS_BUTTON2UP))
+ m_buttons |= Qt::MiddleButton;
+ if (!(status & MOUSE_SYS_BUTTON3UP))
+ m_buttons |= Qt::RightButton;
+
+ QWindowSystemInterface::handleMouseEvent(0, pos, pos, m_buttons);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/generic/bsdmouse/qbsdmouse.h b/src/plugins/generic/bsdmouse/qbsdmouse.h
new file mode 100644
index 0000000000..9a4cb8dd82
--- /dev/null
+++ b/src/plugins/generic/bsdmouse/qbsdmouse.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2015-2016 Oleksandr Tymoshenko <gonzo@bluezbox.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBSDMOUSE_H
+#define QBSDMOUSE_H
+
+#include <QString>
+#include <QScopedPointer>
+#include <QSocketNotifier>
+
+#include <qobject.h>
+
+QT_BEGIN_NAMESPACE
+
+class QSocketNotifier;
+
+class QBsdMouseHandler : public QObject
+{
+ Q_OBJECT
+public:
+ QBsdMouseHandler(const QString &key, const QString &specification);
+ ~QBsdMouseHandler() override;
+
+private:
+ void readMouseData();
+
+private:
+ QScopedPointer<QSocketNotifier> m_notifier;
+ int m_devFd = -1;
+ int m_packetSize = 0;
+ int m_x = 0;
+ int m_y = 0;
+ int m_xOffset = 0;
+ int m_yOffset = 0;
+ Qt::MouseButtons m_buttons = Qt::NoButton;
+};
+
+QT_END_NAMESPACE
+
+#endif // QBSDMOUSE_H
diff --git a/src/plugins/generic/generic.pro b/src/plugins/generic/generic.pro
index 0c1943b7dd..182a60fdb5 100644
--- a/src/plugins/generic/generic.pro
+++ b/src/plugins/generic/generic.pro
@@ -17,3 +17,7 @@ contains(QT_CONFIG, tslib) {
contains(QT_CONFIG, libinput) {
SUBDIRS += libinput
}
+
+freebsd {
+ SUBDIRS += bsdkeyboard bsdmouse
+}
diff --git a/src/plugins/generic/tuiotouch/qtuiohandler.cpp b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
index 5d34e0ea38..38105fe656 100644
--- a/src/plugins/generic/tuiotouch/qtuiohandler.cpp
+++ b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
@@ -43,10 +43,12 @@
#include <QWindow>
#include <QGuiApplication>
#include <QTouchDevice>
+#include <qmath.h>
#include <qpa/qwindowsysteminterface.h>
#include "qtuiocursor_p.h"
+#include "qtuiotoken_p.h"
#include "qtuiohandler_p.h"
#include "qoscbundle_p.h"
@@ -55,6 +57,12 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(lcTuioSource, "qt.qpa.tuio.source")
Q_LOGGING_CATEGORY(lcTuioSet, "qt.qpa.tuio.set")
+// With TUIO the first application takes exclusive ownership of the "device"
+// we cannot attach more than one application to the same port anyway.
+// Forcing delivery makes it easy to use simulators in the same machine
+// and forget about headaches about unfocused TUIO windows.
+static bool forceDelivery = qEnvironmentVariableIsSet("QT_TUIOTOUCH_DELIVER_WITHOUT_FOCUS");
+
QTuioHandler::QTuioHandler(const QString &specification)
: m_device(new QTouchDevice) // not leaked, QTouchDevice cleans up registered devices itself
{
@@ -157,29 +165,49 @@ void QTuioHandler::processPackets()
messages.push_back(msg);
}
- foreach (const QOscMessage &message, messages) {
- if (message.addressPattern() != "/tuio/2Dcur") {
- qWarning() << "Ignoring unknown address pattern " << message.addressPattern();
- continue;
- }
-
- QList<QVariant> arguments = message.arguments();
- if (arguments.count() == 0) {
- qWarning("Ignoring TUIO message with no arguments");
- continue;
- }
-
- QByteArray messageType = arguments.at(0).toByteArray();
- if (messageType == "source") {
- process2DCurSource(message);
- } else if (messageType == "alive") {
- process2DCurAlive(message);
- } else if (messageType == "set") {
- process2DCurSet(message);
- } else if (messageType == "fseq") {
- process2DCurFseq(message);
+ for (const QOscMessage &message : messages) {
+ if (message.addressPattern() == "/tuio/2Dcur") {
+ QList<QVariant> arguments = message.arguments();
+ if (arguments.count() == 0) {
+ qWarning("Ignoring TUIO message with no arguments");
+ continue;
+ }
+
+ QByteArray messageType = arguments.at(0).toByteArray();
+ if (messageType == "source") {
+ process2DCurSource(message);
+ } else if (messageType == "alive") {
+ process2DCurAlive(message);
+ } else if (messageType == "set") {
+ process2DCurSet(message);
+ } else if (messageType == "fseq") {
+ process2DCurFseq(message);
+ } else {
+ qWarning() << "Ignoring unknown TUIO message type: " << messageType;
+ continue;
+ }
+ } else if (message.addressPattern() == "/tuio/2Dobj") {
+ QList<QVariant> arguments = message.arguments();
+ if (arguments.count() == 0) {
+ qWarning("Ignoring TUIO message with no arguments");
+ continue;
+ }
+
+ QByteArray messageType = arguments.at(0).toByteArray();
+ if (messageType == "source") {
+ process2DObjSource(message);
+ } else if (messageType == "alive") {
+ process2DObjAlive(message);
+ } else if (messageType == "set") {
+ process2DObjSet(message);
+ } else if (messageType == "fseq") {
+ process2DObjFseq(message);
+ } else {
+ qWarning() << "Ignoring unknown TUIO message type: " << messageType;
+ continue;
+ }
} else {
- qWarning() << "Ignoring unknown TUIO message type: " << messageType;
+ qWarning() << "Ignoring unknown address pattern " << message.addressPattern();
continue;
}
}
@@ -327,11 +355,6 @@ void QTuioHandler::process2DCurFseq(const QOscMessage &message)
Q_UNUSED(message); // TODO: do we need to do anything with the frame id?
QWindow *win = QGuiApplication::focusWindow();
- // With TUIO the first application takes exclusive ownership of the "device"
- // we cannot attach more than one application to the same port anyway.
- // Forcing delivery makes it easy to use simulators in the same machine
- // and forget about headaches about unfocused TUIO windows.
- static bool forceDelivery = qEnvironmentVariableIsSet("QT_TUIOTOUCH_DELIVER_WITHOUT_FOCUS");
if (!win && QGuiApplication::topLevelWindows().length() > 0 && forceDelivery)
win = QGuiApplication::topLevelWindows().at(0);
@@ -341,12 +364,12 @@ void QTuioHandler::process2DCurFseq(const QOscMessage &message)
QList<QWindowSystemInterface::TouchPoint> tpl;
tpl.reserve(m_activeCursors.size() + m_deadCursors.size());
- foreach (const QTuioCursor &tc, m_activeCursors) {
+ for (const QTuioCursor &tc : m_activeCursors) {
QWindowSystemInterface::TouchPoint tp = cursorToTouchPoint(tc, win);
tpl.append(tp);
}
- foreach (const QTuioCursor &tc, m_deadCursors) {
+ for (const QTuioCursor &tc : m_deadCursors) {
QWindowSystemInterface::TouchPoint tp = cursorToTouchPoint(tc, win);
tp.state = Qt::TouchPointReleased;
tpl.append(tp);
@@ -356,5 +379,180 @@ void QTuioHandler::process2DCurFseq(const QOscMessage &message)
m_deadCursors.clear();
}
+void QTuioHandler::process2DObjSource(const QOscMessage &message)
+{
+ QList<QVariant> arguments = message.arguments();
+ if (arguments.count() != 2) {
+ qWarning() << "Ignoring malformed TUIO source message: " << arguments.count();
+ return;
+ }
+
+ if (QMetaType::Type(arguments.at(1).type()) != QMetaType::QByteArray) {
+ qWarning("Ignoring malformed TUIO source message (bad argument type)");
+ return;
+ }
+
+ qCDebug(lcTuioSource) << "Got TUIO source message from: " << arguments.at(1).toByteArray();
+}
+
+void QTuioHandler::process2DObjAlive(const QOscMessage &message)
+{
+ QList<QVariant> arguments = message.arguments();
+
+ // delta the notified tokens that are active, against the ones we already
+ // know of.
+ //
+ // TBD: right now we're assuming one 2DObj alive message corresponds to a
+ // new data source from the input. is this correct, or do we need to store
+ // changes and only process the deltas on fseq?
+ QMap<int, QTuioToken> oldActiveTokens = m_activeTokens;
+ QMap<int, QTuioToken> newActiveTokens;
+
+ for (int i = 1; i < arguments.count(); ++i) {
+ if (QMetaType::Type(arguments.at(i).type()) != QMetaType::Int) {
+ qWarning() << "Ignoring malformed TUIO alive message (bad argument on position" << i << arguments << ')';
+ return;
+ }
+
+ int sessionId = arguments.at(i).toInt();
+ if (!oldActiveTokens.contains(sessionId)) {
+ // newly active
+ QTuioToken token(sessionId);
+ token.setState(Qt::TouchPointPressed);
+ newActiveTokens.insert(sessionId, token);
+ } else {
+ // we already know about it, remove it so it isn't marked as released
+ QTuioToken token = oldActiveTokens.value(sessionId);
+ token.setState(Qt::TouchPointStationary); // position change in SET will update if needed
+ newActiveTokens.insert(sessionId, token);
+ oldActiveTokens.remove(sessionId);
+ }
+ }
+
+ // anything left is dead now
+ QMap<int, QTuioToken>::ConstIterator it = oldActiveTokens.constBegin();
+
+ // deadTokens should be cleared from the last FSEQ now
+ m_deadTokens.reserve(oldActiveTokens.size());
+
+ // TODO: there could be an issue of resource exhaustion here if FSEQ isn't
+ // sent in a timely fashion. we should probably track message counts and
+ // force-flush if we get too many built up.
+ while (it != oldActiveTokens.constEnd()) {
+ m_deadTokens.append(it.value());
+ ++it;
+ }
+
+ m_activeTokens = newActiveTokens;
+}
+
+void QTuioHandler::process2DObjSet(const QOscMessage &message)
+{
+ QList<QVariant> arguments = message.arguments();
+ if (arguments.count() < 7) {
+ qWarning() << "Ignoring malformed TUIO set message with too few arguments: " << arguments.count();
+ return;
+ }
+
+ if (QMetaType::Type(arguments.at(1).type()) != QMetaType::Int ||
+ QMetaType::Type(arguments.at(2).type()) != QMetaType::Int ||
+ QMetaType::Type(arguments.at(3).type()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(4).type()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(5).type()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(6).type()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(7).type()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(8).type()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(9).type()) != QMetaType::Float ||
+ QMetaType::Type(arguments.at(10).type()) != QMetaType::Float) {
+ qWarning() << "Ignoring malformed TUIO set message with bad types: " << arguments;
+ return;
+ }
+
+ int id = arguments.at(1).toInt();
+ int classId = arguments.at(2).toInt();
+ float x = arguments.at(3).toFloat();
+ float y = arguments.at(4).toFloat();
+ float angle = arguments.at(5).toFloat();
+ float vx = arguments.at(6).toFloat();
+ float vy = arguments.at(7).toFloat();
+ float angularVelocity = arguments.at(8).toFloat();
+ float acceleration = arguments.at(9).toFloat();
+ float angularAcceleration = arguments.at(10).toFloat();
+
+ QMap<int, QTuioToken>::Iterator it = m_activeTokens.find(id);
+ if (it == m_activeTokens.end()) {
+ qWarning() << "Ignoring malformed TUIO set for nonexistent token " << classId;
+ return;
+ }
+
+ qCDebug(lcTuioSet) << "Processing SET for token " << classId << id << " @ " << x << y << "∡" << angle <<
+ "vel" << vx << vy << angularVelocity << "acc" << acceleration << angularAcceleration;
+ QTuioToken &tok = *it;
+ tok.setClassId(classId);
+ tok.setX(x);
+ tok.setY(y);
+ tok.setVX(vx);
+ tok.setVY(vy);
+ tok.setAcceleration(acceleration);
+ tok.setAngle(angle);
+ tok.setAngularVelocity(angularAcceleration);
+ tok.setAngularAcceleration(angularAcceleration);
+}
+
+QWindowSystemInterface::TouchPoint QTuioHandler::tokenToTouchPoint(const QTuioToken &tc, QWindow *win)
+{
+ QWindowSystemInterface::TouchPoint tp;
+ tp.id = tc.id();
+ tp.uniqueId = tc.classId(); // TODO TUIO 2.0: populate a QVariant, and register the mapping from int to arbitrary UID data
+ tp.flags = QTouchEvent::TouchPoint::Token;
+ tp.pressure = 1.0f;
+
+ tp.normalPosition = QPointF(tc.x(), tc.y());
+
+ if (!m_transform.isIdentity())
+ tp.normalPosition = m_transform.map(tp.normalPosition);
+
+ tp.state = tc.state();
+
+ // We map the token position to the size of the window.
+ QPointF relPos = QPointF(win->size().width() * tp.normalPosition.x(), win->size().height() * tp.normalPosition.y());
+ QPointF delta = relPos - relPos.toPoint();
+ tp.area.moveCenter(win->mapToGlobal(relPos.toPoint()) + delta);
+ tp.velocity = QVector2D(win->size().width() * tc.vx(), win->size().height() * tc.vy());
+ tp.rotation = tc.angle() * 180.0 / M_PI; // convert radians to degrees
+ return tp;
+}
+
+
+void QTuioHandler::process2DObjFseq(const QOscMessage &message)
+{
+ Q_UNUSED(message); // TODO: do we need to do anything with the frame id?
+
+ QWindow *win = QGuiApplication::focusWindow();
+ if (!win && QGuiApplication::topLevelWindows().length() > 0 && forceDelivery)
+ win = QGuiApplication::topLevelWindows().at(0);
+
+ if (!win)
+ return;
+
+ QList<QWindowSystemInterface::TouchPoint> tpl;
+ tpl.reserve(m_activeTokens.size() + m_deadTokens.size());
+
+ for (const QTuioToken & t : m_activeTokens) {
+ QWindowSystemInterface::TouchPoint tp = tokenToTouchPoint(t, win);
+ tpl.append(tp);
+ }
+
+ for (const QTuioToken & t : m_deadTokens) {
+ QWindowSystemInterface::TouchPoint tp = tokenToTouchPoint(t, win);
+ tp.state = Qt::TouchPointReleased;
+ tp.velocity = QVector2D();
+ tpl.append(tp);
+ }
+ QWindowSystemInterface::handleTouchEvent(win, m_device, tpl);
+
+ m_deadTokens.clear();
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/generic/tuiotouch/qtuiohandler_p.h b/src/plugins/generic/tuiotouch/qtuiohandler_p.h
index 3034872aae..2e444f2a0d 100644
--- a/src/plugins/generic/tuiotouch/qtuiohandler_p.h
+++ b/src/plugins/generic/tuiotouch/qtuiohandler_p.h
@@ -54,6 +54,7 @@ QT_BEGIN_NAMESPACE
class QTouchDevice;
class QOscMessage;
class QTuioCursor;
+class QTuioToken;
class QTuioHandler : public QObject
{
@@ -69,14 +70,21 @@ private slots:
void process2DCurAlive(const QOscMessage &message);
void process2DCurSet(const QOscMessage &message);
void process2DCurFseq(const QOscMessage &message);
+ void process2DObjSource(const QOscMessage &message);
+ void process2DObjAlive(const QOscMessage &message);
+ void process2DObjSet(const QOscMessage &message);
+ void process2DObjFseq(const QOscMessage &message);
private:
QWindowSystemInterface::TouchPoint cursorToTouchPoint(const QTuioCursor &tc, QWindow *win);
+ QWindowSystemInterface::TouchPoint tokenToTouchPoint(const QTuioToken &tc, QWindow *win);
QTouchDevice *m_device;
QUdpSocket m_socket;
QMap<int, QTuioCursor> m_activeCursors;
QVector<QTuioCursor> m_deadCursors;
+ QMap<int, QTuioToken> m_activeTokens;
+ QVector<QTuioToken> m_deadTokens;
QTransform m_transform;
};
diff --git a/src/plugins/generic/tuiotouch/qtuiotoken_p.h b/src/plugins/generic/tuiotouch/qtuiotoken_p.h
new file mode 100644
index 0000000000..5084aeed11
--- /dev/null
+++ b/src/plugins/generic/tuiotouch/qtuiotoken_p.h
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTUIOOBJECT_P_H
+#define QTUIOOBJECT_P_H
+
+#include <Qt>
+#include <qmath.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \internal
+
+ A fiducial object, or token, represented by 2Dobj in TUIO 1.x and tok in TUIO 2:
+ a physical object whose position and rotation can be uniquely tracked
+ on the touchscreen surface.
+*/
+class QTuioToken
+{
+public:
+ QTuioToken(int id = -1)
+ : m_id(id)
+ , m_classId(-1)
+ , m_x(0)
+ , m_y(0)
+ , m_vx(0)
+ , m_vy(0)
+ , m_acceleration(0)
+ , m_angle(0)
+ , m_angularVelocity(0)
+ , m_angularAcceleration(0)
+ , m_state(Qt::TouchPointPressed)
+ {
+ }
+
+ int id() const { return m_id; }
+
+ int classId() const { return m_classId; }
+ void setClassId(int classId) { m_classId = classId; }
+
+ void setX(float x)
+ {
+ if (state() == Qt::TouchPointStationary &&
+ !qFuzzyCompare(m_x + 2.0, x + 2.0)) { // +2 because 1 is a valid value, and qFuzzyCompare can't cope with 0.0
+ setState(Qt::TouchPointMoved);
+ }
+ m_x = x;
+ }
+ float x() const { return m_x; }
+
+ void setY(float y)
+ {
+ if (state() == Qt::TouchPointStationary &&
+ !qFuzzyCompare(m_y + 2.0, y + 2.0)) { // +2 because 1 is a valid value, and qFuzzyCompare can't cope with 0.0
+ setState(Qt::TouchPointMoved);
+ }
+ m_y = y;
+ }
+ float y() const { return m_y; }
+
+ void setVX(float vx) { m_vx = vx; }
+ float vx() const { return m_vx; }
+
+ void setVY(float vy) { m_vy = vy; }
+ float vy() const { return m_vy; }
+
+ void setAcceleration(float acceleration) { m_acceleration = acceleration; }
+ float acceleration() const { return m_acceleration; }
+
+ float angle() const { return m_angle; }
+ void setAngle(float angle)
+ {
+ if (angle > M_PI)
+ angle = angle - M_PI * 2.0; // zero is pointing upwards, and is the default; but we want to have negative angles when rotating left
+ if (state() == Qt::TouchPointStationary &&
+ !qFuzzyCompare(m_angle + 2.0, angle + 2.0)) { // +2 because 1 is a valid value, and qFuzzyCompare can't cope with 0.0
+ setState(Qt::TouchPointMoved);
+ }
+ m_angle = angle;
+ }
+
+ float angularVelocity() const { return m_angularVelocity; }
+ void setAngularVelocity(float angularVelocity) { m_angularVelocity = angularVelocity; }
+
+ float angularAcceleration() const { return m_angularAcceleration; }
+ void setAngularAcceleration(float angularAcceleration) { m_angularAcceleration = angularAcceleration; }
+
+ void setState(const Qt::TouchPointState &state) { m_state = state; }
+ Qt::TouchPointState state() const { return m_state; }
+
+private:
+ int m_id; // sessionID, temporary object ID
+ int m_classId; // classID (e.g. marker ID)
+ float m_x;
+ float m_y;
+ float m_vx;
+ float m_vy;
+ float m_acceleration;
+ float m_angle;
+ float m_angularVelocity;
+ float m_angularAcceleration;
+ Qt::TouchPointState m_state;
+};
+
+QT_END_NAMESPACE
+
+#endif // QTUIOOBJECT_P_H
diff --git a/src/plugins/generic/tuiotouch/tuiotouch.pro b/src/plugins/generic/tuiotouch/tuiotouch.pro
index ae2ccde058..ad6a1c6876 100644
--- a/src/plugins/generic/tuiotouch/tuiotouch.pro
+++ b/src/plugins/generic/tuiotouch/tuiotouch.pro
@@ -15,7 +15,8 @@ HEADERS += \
qoscbundle_p.h \
qoscmessage_p.h \
qtuiohandler_p.h \
- qtuiocursor_p.h
+ qtuiocursor_p.h \
+ qtuiotoken_p.h
OTHER_FILES += \
tuiotouch.json
diff --git a/src/plugins/imageformats/gif/gif.pro b/src/plugins/imageformats/gif/gif.pro
index a361bc2532..c2625be85a 100644
--- a/src/plugins/imageformats/gif/gif.pro
+++ b/src/plugins/imageformats/gif/gif.pro
@@ -1,9 +1,8 @@
TARGET = qgif
-include(../../../gui/image/qgifhandler.pri)
-INCLUDEPATH += ../../../gui/image
-SOURCES += $$PWD/main.cpp
-HEADERS += $$PWD/main.h
+SOURCES += main.cpp qgifhandler.cpp
+HEADERS += main.h qgifhandler_p.h
+
OTHER_FILES += gif.json
PLUGIN_TYPE = imageformats
diff --git a/src/gui/image/qgifhandler.cpp b/src/plugins/imageformats/gif/qgifhandler.cpp
index 476b456563..476b456563 100644
--- a/src/gui/image/qgifhandler.cpp
+++ b/src/plugins/imageformats/gif/qgifhandler.cpp
diff --git a/src/gui/image/qgifhandler_p.h b/src/plugins/imageformats/gif/qgifhandler_p.h
index bc3debe83c..bc3debe83c 100644
--- a/src/gui/image/qgifhandler_p.h
+++ b/src/plugins/imageformats/gif/qgifhandler_p.h
diff --git a/src/plugins/imageformats/ico/ico.pro b/src/plugins/imageformats/ico/ico.pro
index 60afdaed70..7ca1f18cb1 100644
--- a/src/plugins/imageformats/ico/ico.pro
+++ b/src/plugins/imageformats/ico/ico.pro
@@ -1,10 +1,7 @@
TARGET = qico
-QTDIR_build:REQUIRES = "!contains(QT_CONFIG, no-ico)"
-
-HEADERS += qicohandler.h main.h
-SOURCES += main.cpp \
- qicohandler.cpp
+HEADERS += main.h qicohandler.h
+SOURCES += main.cpp qicohandler.cpp
OTHER_FILES += ico.json
PLUGIN_TYPE = imageformats
diff --git a/src/plugins/imageformats/imageformats.pro b/src/plugins/imageformats/imageformats.pro
index 2b05f2feec..3de77c056d 100644
--- a/src/plugins/imageformats/imageformats.pro
+++ b/src/plugins/imageformats/imageformats.pro
@@ -1,5 +1,5 @@
TEMPLATE = subdirs
-!contains(QT_CONFIG, no-jpeg):!contains(QT_CONFIG, jpeg):SUBDIRS += jpeg
-!contains(QT_CONFIG, no-gif):!contains(QT_CONFIG, gif):SUBDIRS += gif
!contains(QT_CONFIG, no-ico):SUBDIRS += ico
+contains(QT_CONFIG, jpeg): SUBDIRS += jpeg
+contains(QT_CONFIG, gif): SUBDIRS += gif
diff --git a/src/plugins/imageformats/jpeg/jpeg.pro b/src/plugins/imageformats/jpeg/jpeg.pro
index 526556179c..8954cc6402 100644
--- a/src/plugins/imageformats/jpeg/jpeg.pro
+++ b/src/plugins/imageformats/jpeg/jpeg.pro
@@ -1,13 +1,19 @@
TARGET = qjpeg
-QT += core-private
+QT += core-private gui-private
-QTDIR_build:REQUIRES = "!contains(QT_CONFIG, no-jpeg)"
+SOURCES += main.cpp qjpeghandler.cpp
+HEADERS += main.h qjpeghandler_p.h
+
+contains(QT_CONFIG, system-jpeg) {
+ msvc: \
+ LIBS += libjpeg.lib
+ else: \
+ LIBS += -ljpeg
+} else {
+ include($$PWD/../../../3rdparty/libjpeg.pri)
+}
-include(../../../gui/image/qjpeghandler.pri)
-INCLUDEPATH += ../../../gui/image
-SOURCES += main.cpp
-HEADERS += main.h
OTHER_FILES += jpeg.json
PLUGIN_TYPE = imageformats
diff --git a/src/gui/image/qjpeghandler.cpp b/src/plugins/imageformats/jpeg/qjpeghandler.cpp
index 52e8b39f11..d89b8d398b 100644
--- a/src/gui/image/qjpeghandler.cpp
+++ b/src/plugins/imageformats/jpeg/qjpeghandler.cpp
@@ -45,6 +45,7 @@
#include <qbuffer.h>
#include <qmath.h>
#include <private/qsimd_p.h>
+#include <private/qimage_p.h> // for qt_getImageText
#include <stdio.h> // jpeglib needs this to be pre-included
#include <setjmp.h>
@@ -491,30 +492,10 @@ inline my_jpeg_destination_mgr::my_jpeg_destination_mgr(QIODevice *device)
free_in_buffer = max_buf;
}
-
static inline void set_text(const QImage &image, j_compress_ptr cinfo, const QString &description)
{
- QMap<QString, QString> text;
- foreach (const QString &key, image.textKeys()) {
- if (!key.isEmpty())
- text.insert(key, image.text(key));
- }
- foreach (const QString &pair, description.split(QLatin1String("\n\n"))) {
- int index = pair.indexOf(QLatin1Char(':'));
- if (index >= 0 && pair.indexOf(QLatin1Char(' ')) < index) {
- QString s = pair.simplified();
- if (!s.isEmpty())
- text.insert(QLatin1String("Description"), s);
- } else {
- QString key = pair.left(index);
- if (!key.simplified().isEmpty())
- text.insert(key, pair.mid(index + 2).simplified());
- }
- }
- if (text.isEmpty())
- return;
-
- for (QMap<QString, QString>::ConstIterator it = text.constBegin(); it != text.constEnd(); ++it) {
+ const QMap<QString, QString> text = qt_getImageText(image, description);
+ for (auto it = text.begin(), end = text.end(); it != end; ++it) {
QByteArray comment = it.key().toLatin1();
if (!comment.isEmpty())
comment += ": ";
diff --git a/src/gui/image/qjpeghandler_p.h b/src/plugins/imageformats/jpeg/qjpeghandler_p.h
index 534ce12115..534ce12115 100644
--- a/src/gui/image/qjpeghandler_p.h
+++ b/src/plugins/imageformats/jpeg/qjpeghandler_p.h
diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
index 200d5789a8..994fe8386b 100644
--- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
+++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
@@ -278,7 +278,7 @@ void QIBusPlatformInputContext::updatePreeditText(const QDBusVariant &text, uint
QList<QInputMethodEvent::Attribute> attributes = t.attributes.imAttributes();
if (!t.text.isEmpty())
- attributes += QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursorPos, visible ? 1 : 0, QVariant());
+ attributes += QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursorPos, visible ? 1 : 0);
QInputMethodEvent event(t.text, attributes);
QCoreApplication::sendEvent(input, &event);
diff --git a/src/plugins/platforminputcontexts/ibus/qibustypes.cpp b/src/plugins/platforminputcontexts/ibus/qibustypes.cpp
index ac82fa3931..a2551f1320 100644
--- a/src/plugins/platforminputcontexts/ibus/qibustypes.cpp
+++ b/src/plugins/platforminputcontexts/ibus/qibustypes.cpp
@@ -73,10 +73,7 @@ void QIBusSerializable::serializeTo(QDBusArgument &argument) const
argument.beginMap(qMetaTypeId<QString>(), qMetaTypeId<QDBusVariant>());
- QHashIterator<QString, QDBusArgument> i(attachments);
- while (i.hasNext()) {
- i.next();
-
+ for (auto i = attachments.begin(), end = attachments.end(); i != end; ++i) {
argument.beginMapEntry();
argument << i.key();
diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp
index dc420775cf..125a03469f 100644
--- a/src/plugins/platforms/android/qandroidinputcontext.cpp
+++ b/src/plugins/platforms/android/qandroidinputcontext.cpp
@@ -645,7 +645,7 @@ jboolean QAndroidInputContext::commitText(const QString &text, jint newCursorPos
: localPos - text.length() + newCursorPosition;
//move the cursor
attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Selection,
- newLocalPos, 0, QVariant()));
+ newLocalPos, 0));
}
}
m_blockUpdateSelection = updateSelectionWasBlocked;
@@ -691,7 +691,7 @@ jboolean QAndroidInputContext::finishComposingText()
// Moving Qt's cursor to where the preedit cursor used to be
QList<QInputMethodEvent::Attribute> attributes;
- attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Selection, localCursorPos, 0, QVariant()));
+ attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Selection, localCursorPos, 0));
QInputMethodEvent event(QString(), attributes);
event.setCommitString(m_composingText);
@@ -848,8 +848,7 @@ jboolean QAndroidInputContext::setComposingText(const QString &text, jint newCur
QList<QInputMethodEvent::Attribute> attributes;
attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor,
newCursorPosition,
- 1,
- QVariant()));
+ 1));
// Show compose text underlined
QTextCharFormat underlined;
underlined.setFontUnderline(true);
@@ -921,7 +920,7 @@ jboolean QAndroidInputContext::setComposingRegion(jint start, jint end)
QVariant(underlined)));
// Keep the cursor position unchanged (don't move to end of preedit)
- attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, currentCursor - start, 1, QVariant()));
+ attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, currentCursor - start, 1));
QInputMethodEvent event(m_composingText, attributes);
event.setCommitString(QString(), relativeStart, length);
@@ -955,7 +954,7 @@ jboolean QAndroidInputContext::setSelection(jint start, jint end)
// preedit cursor
int localOldPos = query->value(Qt::ImCursorPosition).toInt();
int pos = localCursorPos - localOldPos;
- attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, pos, 1, QVariant()));
+ attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, pos, 1));
//but we have to tell Qt about the compose text all over again
@@ -970,8 +969,7 @@ jboolean QAndroidInputContext::setSelection(jint start, jint end)
// actually changing the selection
attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Selection,
localCursorPos,
- end - start,
- QVariant()));
+ end - start));
}
QInputMethodEvent event(m_composingText, attributes);
sendInputMethodEventThreadSafe(&event);
diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp
index 80d7e31aa3..e10bd95e12 100644
--- a/src/plugins/platforms/android/qandroidplatformintegration.cpp
+++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp
@@ -80,6 +80,8 @@ Qt::ScreenOrientation QAndroidPlatformIntegration::m_nativeOrientation = Qt::Pri
Qt::ApplicationState QAndroidPlatformIntegration::m_defaultApplicationState = Qt::ApplicationActive;
+bool QAndroidPlatformIntegration::m_showPasswordEnabled = false;
+
void *QAndroidPlatformNativeInterface::nativeResourceForIntegration(const QByteArray &resource)
{
if (resource=="JavaVM")
@@ -191,6 +193,19 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList &para
}
QWindowSystemInterface::registerTouchDevice(m_touchDevice);
}
+
+ auto contentResolver = javaActivity.callObjectMethod("getContentResolver", "()Landroid/content/ContentResolver;");
+ Q_ASSERT(contentResolver.isValid());
+ QJNIObjectPrivate txtShowPassValue = QJNIObjectPrivate::callStaticObjectMethod("android/provider/Settings$System",
+ "getString",
+ "(Landroid/content/ContentResolver;Ljava/lang/String;)Ljava/lang/String;",
+ contentResolver.object(),
+ QJNIObjectPrivate::getStaticObjectField("android/provider/Settings$System", "TEXT_SHOW_PASSWORD", "Ljava/lang/String;").object());
+ if (txtShowPassValue.isValid()) {
+ bool ok = false;
+ const int txtShowPass = txtShowPassValue.toString().toInt(&ok);
+ m_showPasswordEnabled = ok ? (txtShowPass == 1) : false;
+ }
}
QGuiApplicationPrivate::instance()->setApplicationState(m_defaultApplicationState);
@@ -313,6 +328,9 @@ QPlatformServices *QAndroidPlatformIntegration::services() const
QVariant QAndroidPlatformIntegration::styleHint(StyleHint hint) const
{
switch (hint) {
+ case PasswordMaskDelay:
+ // this number is from a hard-coded value in Android code (cf. PasswordTransformationMethod)
+ return m_showPasswordEnabled ? 1500 : 0;
case ShowIsMaximized:
return true;
default:
diff --git a/src/plugins/platforms/android/qandroidplatformintegration.h b/src/plugins/platforms/android/qandroidplatformintegration.h
index 1f06c23d0b..bda0bee9ad 100644
--- a/src/plugins/platforms/android/qandroidplatformintegration.h
+++ b/src/plugins/platforms/android/qandroidplatformintegration.h
@@ -143,6 +143,8 @@ private:
static Qt::ApplicationState m_defaultApplicationState;
+ static bool m_showPasswordEnabled;
+
QPlatformFontDatabase *m_androidFDB;
QAndroidPlatformNativeInterface *m_androidPlatformNativeInterface;
QAndroidPlatformServices *m_androidPlatformServices;
diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp
index a73550606b..155d6bfb8d 100644
--- a/src/plugins/platforms/android/qandroidplatformscreen.cpp
+++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp
@@ -379,9 +379,8 @@ void QAndroidPlatformScreen::doRedraw()
}
}
- foreach (const QRect &rect, visibleRegion.rects()) {
+ for (const QRect &rect : visibleRegion)
compositePainter.fillRect(rect, QColor(Qt::transparent));
- }
ret = ANativeWindow_unlockAndPost(m_nativeSurface);
if (ret >= 0)
diff --git a/src/plugins/platforms/bsdfb/bsdfb.json b/src/plugins/platforms/bsdfb/bsdfb.json
new file mode 100644
index 0000000000..97b3e7707e
--- /dev/null
+++ b/src/plugins/platforms/bsdfb/bsdfb.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "bsdfb" ]
+}
diff --git a/src/plugins/platforms/bsdfb/bsdfb.pro b/src/plugins/platforms/bsdfb/bsdfb.pro
new file mode 100644
index 0000000000..c24d8dd9e5
--- /dev/null
+++ b/src/plugins/platforms/bsdfb/bsdfb.pro
@@ -0,0 +1,15 @@
+TARGET = qbsdfb
+
+QT += core-private gui-private platformsupport-private
+
+SOURCES = main.cpp qbsdfbintegration.cpp qbsdfbscreen.cpp
+HEADERS = qbsdfbintegration.h qbsdfbscreen.h
+
+CONFIG += qpa/genericunixfontdatabase
+
+OTHER_FILES += bsdfb.json
+
+PLUGIN_TYPE = platforms
+PLUGIN_CLASS_NAME = QBsdFbIntegrationPlugin
+!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -
+load(qt_plugin)
diff --git a/src/plugins/platforms/bsdfb/main.cpp b/src/plugins/platforms/bsdfb/main.cpp
new file mode 100644
index 0000000000..f4ab3dee39
--- /dev/null
+++ b/src/plugins/platforms/bsdfb/main.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2015-2016 Oleksandr Tymoshenko <gonzo@bluezbox.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qpa/qplatformintegrationplugin.h>
+#include "qbsdfbintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QBsdFbIntegrationPlugin : public QPlatformIntegrationPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "bsdfb.json")
+public:
+ QPlatformIntegration *create(const QString&, const QStringList&) override;
+};
+
+QPlatformIntegration* QBsdFbIntegrationPlugin::create(const QString& system, const QStringList& paramList)
+{
+ Q_UNUSED(paramList);
+ if (!system.compare(QLatin1String("bsdfb"), Qt::CaseInsensitive))
+ return new QBsdFbIntegration(paramList);
+
+ return nullptr;
+}
+
+QT_END_NAMESPACE
+
+#include "main.moc"
+
diff --git a/src/plugins/platforms/bsdfb/qbsdfbintegration.cpp b/src/plugins/platforms/bsdfb/qbsdfbintegration.cpp
new file mode 100644
index 0000000000..edb4f4e660
--- /dev/null
+++ b/src/plugins/platforms/bsdfb/qbsdfbintegration.cpp
@@ -0,0 +1,142 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2015-2016 Oleksandr Tymoshenko <gonzo@bluezbox.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbsdfbintegration.h"
+#include "qbsdfbscreen.h"
+
+#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
+#include <QtPlatformSupport/private/qgenericunixservices_p.h>
+#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
+
+#include <QtPlatformSupport/private/qfbvthandler_p.h>
+#include <QtPlatformSupport/private/qfbbackingstore_p.h>
+#include <QtPlatformSupport/private/qfbwindow_p.h>
+#include <QtPlatformSupport/private/qfbcursor_p.h>
+
+#include <QtGui/private/qguiapplication_p.h>
+#include <qpa/qplatforminputcontext.h>
+#include <qpa/qplatforminputcontextfactory_p.h>
+
+#if !defined(QT_NO_TSLIB)
+#include <QtPlatformSupport/private/qtslib_p.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+QBsdFbIntegration::QBsdFbIntegration(const QStringList &paramList)
+{
+ m_fontDb.reset(new QGenericUnixFontDatabase);
+ m_services.reset(new QGenericUnixServices);
+ m_primaryScreen.reset(new QBsdFbScreen(paramList));
+}
+
+QBsdFbIntegration::~QBsdFbIntegration()
+{
+ destroyScreen(m_primaryScreen.data());
+}
+
+void QBsdFbIntegration::initialize()
+{
+ if (m_primaryScreen->initialize())
+ screenAdded(m_primaryScreen.data());
+ else
+ qWarning("bsdfb: Failed to initialize screen");
+
+ m_inputContext.reset(QPlatformInputContextFactory::create());
+ m_nativeInterface.reset(new QPlatformNativeInterface);
+ m_vtHandler.reset(new QFbVtHandler);
+
+ if (!qEnvironmentVariableIntValue("QT_QPA_FB_DISABLE_INPUT"))
+ createInputHandlers();
+}
+
+bool QBsdFbIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+ switch (cap) {
+ case ThreadedPixmaps:
+ return true;
+ case WindowManagement:
+ return false;
+ default:
+ return QPlatformIntegration::hasCapability(cap);
+ }
+}
+
+QPlatformBackingStore *QBsdFbIntegration::createPlatformBackingStore(QWindow *window) const
+{
+ return new QFbBackingStore(window);
+}
+
+QPlatformWindow *QBsdFbIntegration::createPlatformWindow(QWindow *window) const
+{
+ return new QFbWindow(window);
+}
+
+QAbstractEventDispatcher *QBsdFbIntegration::createEventDispatcher() const
+{
+ return createUnixEventDispatcher();
+}
+
+QList<QPlatformScreen *> QBsdFbIntegration::screens() const
+{
+ QList<QPlatformScreen *> list;
+ list.append(m_primaryScreen.data());
+ return list;
+}
+
+QPlatformFontDatabase *QBsdFbIntegration::fontDatabase() const
+{
+ return m_fontDb.data();
+}
+
+QPlatformServices *QBsdFbIntegration::services() const
+{
+ return m_services.data();
+}
+
+void QBsdFbIntegration::createInputHandlers()
+{
+#ifndef QT_NO_TSLIB
+ const bool useTslib = qEnvironmentVariableIntValue("QT_QPA_FB_TSLIB");
+ if (useTslib)
+ new QTsLibMouseHandler(QLatin1String("TsLib"), QString());
+#endif
+}
+
+QPlatformNativeInterface *QBsdFbIntegration::nativeInterface() const
+{
+ return m_nativeInterface.data();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/bsdfb/qbsdfbintegration.h b/src/plugins/platforms/bsdfb/qbsdfbintegration.h
new file mode 100644
index 0000000000..2be5ea260d
--- /dev/null
+++ b/src/plugins/platforms/bsdfb/qbsdfbintegration.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBSDFBINTEGRATION_H
+#define QBSDFBINTEGRATION_H
+
+#include <qpa/qplatformintegration.h>
+#include <qpa/qplatformnativeinterface.h>
+
+QT_BEGIN_NAMESPACE
+
+class QAbstractEventDispatcher;
+class QBsdFbScreen;
+class QFbVtHandler;
+
+class QBsdFbIntegration : public QPlatformIntegration, public QPlatformNativeInterface
+{
+public:
+ explicit QBsdFbIntegration(const QStringList &paramList);
+ ~QBsdFbIntegration() override;
+
+ void initialize() override;
+ bool hasCapability(QPlatformIntegration::Capability cap) const override;
+
+ QPlatformWindow *createPlatformWindow(QWindow *window) const override;
+ QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override;
+
+ QAbstractEventDispatcher *createEventDispatcher() const override;
+
+ QPlatformFontDatabase *fontDatabase() const override;
+ QPlatformServices *services() const override;
+ QPlatformInputContext *inputContext() const override { return m_inputContext.data(); }
+
+ QPlatformNativeInterface *nativeInterface() const override;
+
+ QList<QPlatformScreen *> screens() const;
+
+private:
+ void createInputHandlers();
+
+ QScopedPointer<QBsdFbScreen> m_primaryScreen;
+ QScopedPointer<QPlatformInputContext> m_inputContext;
+ QScopedPointer<QPlatformFontDatabase> m_fontDb;
+ QScopedPointer<QPlatformServices> m_services;
+ QScopedPointer<QFbVtHandler> m_vtHandler;
+ QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+};
+
+QT_END_NAMESPACE
+
+#endif // QBSDFBINTEGRATION_H
diff --git a/src/plugins/platforms/bsdfb/qbsdfbscreen.cpp b/src/plugins/platforms/bsdfb/qbsdfbscreen.cpp
new file mode 100644
index 0000000000..ee2dce6867
--- /dev/null
+++ b/src/plugins/platforms/bsdfb/qbsdfbscreen.cpp
@@ -0,0 +1,276 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2015-2016 Oleksandr Tymoshenko <gonzo@bluezbox.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qbsdfbscreen.h"
+#include <QtPlatformSupport/private/qfbcursor_p.h>
+#include <QtPlatformSupport/private/qfbwindow_p.h>
+#include <QtCore/QRegularExpression>
+#include <QtGui/QPainter>
+
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
+#include <qimage.h>
+#include <qdebug.h>
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <limits.h>
+#include <signal.h>
+
+#include <sys/consio.h>
+#include <sys/fbio.h>
+
+QT_BEGIN_NAMESPACE
+
+enum {
+ DefaultDPI = 100
+};
+
+static int openFramebufferDevice(const QString &dev)
+{
+ const QByteArray devPath = QFile::encodeName(dev);
+
+ int fd = QT_OPEN(devPath.constData(), O_RDWR);
+
+ if (fd == -1)
+ fd = QT_OPEN(devPath.constData(), O_RDONLY);
+
+ return fd;
+}
+
+static QRect determineGeometry(const struct fbtype &fb, const QRect &userGeometry)
+{
+ int xoff = 0;
+ int yoff = 0;
+ int w = 0;
+ int h = 0;
+
+ if (userGeometry.isValid()) {
+ w = qMin(userGeometry.width(), fb.fb_width);
+ h = qMin(userGeometry.height(), fb.fb_height);
+
+ int xxoff = userGeometry.x(), yyoff = userGeometry.y();
+ if (xxoff != 0 || yyoff != 0) {
+ if (xxoff < 0 || xxoff + w > fb.fb_width)
+ xxoff = fb.fb_width - w;
+ if (yyoff < 0 || yyoff + h > fb.fb_height)
+ yyoff = fb.fb_height - h;
+ xoff += xxoff;
+ yoff += yyoff;
+ } else {
+ xoff += (fb.fb_width - w)/2;
+ yoff += (fb.fb_height - h)/2;
+ }
+ } else {
+ w = fb.fb_width;
+ h = fb.fb_height;
+ }
+
+ if (w == 0 || h == 0) {
+ qWarning("Unable to find screen geometry, using 320x240");
+ w = 320;
+ h = 240;
+ }
+
+ return QRect(xoff, yoff, w, h);
+}
+
+static QSizeF determinePhysicalSize(const QSize &mmSize, const QSize &res)
+{
+ int mmWidth = mmSize.width();
+ int mmHeight = mmSize.height();
+
+ if (mmWidth <= 0 && mmHeight <= 0) {
+ const int dpi = DefaultDPI;
+ mmWidth = qRound(res.width() * 25.4 / dpi);
+ mmHeight = qRound(res.height() * 25.4 / dpi);
+ } else if (mmWidth > 0 && mmHeight <= 0) {
+ mmHeight = res.height() * mmWidth/res.width();
+ } else if (mmHeight > 0 && mmWidth <= 0) {
+ mmWidth = res.width() * mmHeight/res.height();
+ }
+
+ return QSize(mmWidth, mmHeight);
+}
+
+QBsdFbScreen::QBsdFbScreen(const QStringList &args)
+ : m_arguments(args)
+{
+}
+
+QBsdFbScreen::~QBsdFbScreen()
+{
+ if (m_framebufferFd != -1) {
+ munmap(m_mmap.data - m_mmap.offset, m_mmap.size);
+ qt_safe_close(m_framebufferFd);
+ }
+}
+
+bool QBsdFbScreen::initialize()
+{
+ QRegularExpression fbRx(QLatin1String("fb=(.*)"));
+ QRegularExpression mmSizeRx(QLatin1String("mmsize=(\\d+)x(\\d+)"));
+ QRegularExpression sizeRx(QLatin1String("size=(\\d+)x(\\d+)"));
+ QRegularExpression offsetRx(QLatin1String("offset=(\\d+)x(\\d+)"));
+
+ QString fbDevice;
+ QSize userMmSize;
+ QRect userGeometry;
+
+ // Parse arguments
+ for (const QString &arg : qAsConst(m_arguments)) {
+ QRegularExpressionMatch match;
+ if (arg.contains(mmSizeRx, &match))
+ userMmSize = QSize(match.captured(1).toInt(), match.captured(2).toInt());
+ else if (arg.contains(sizeRx, &match))
+ userGeometry.setSize(QSize(match.captured(1).toInt(), match.captured(2).toInt()));
+ else if (arg.contains(offsetRx, &match))
+ userGeometry.setTopLeft(QPoint(match.captured(1).toInt(), match.captured(2).toInt()));
+ else if (arg.contains(fbRx, &match))
+ fbDevice = match.captured(1);
+ }
+
+ if (!fbDevice.isEmpty()) {
+ // Open the device
+ m_framebufferFd = openFramebufferDevice(fbDevice);
+ } else {
+ m_framebufferFd = STDIN_FILENO;
+ }
+
+ if (m_framebufferFd == -1) {
+ qErrnoWarning(errno, "Failed to open framebuffer %s", qPrintable(fbDevice));
+ return false;
+ }
+
+ struct fbtype fb;
+ if (ioctl(m_framebufferFd, FBIOGTYPE, &fb) != 0) {
+ qErrnoWarning(errno, "Error reading framebuffer information");
+ return false;
+ }
+
+ int line_length = 0;
+ if (ioctl(m_framebufferFd, FBIO_GETLINEWIDTH, &line_length) != 0) {
+ qErrnoWarning(errno, "Error reading line length information");
+ return false;
+ }
+
+ mDepth = fb.fb_depth;
+
+ m_bytesPerLine = line_length;
+ const QRect geometry = determineGeometry(fb, userGeometry);
+ mGeometry = QRect(QPoint(0, 0), geometry.size());
+ switch (mDepth) {
+ case 32:
+ mFormat = QImage::Format_RGB32;
+ break;
+ case 24:
+ mFormat = QImage::Format_RGB888;
+ break;
+ case 16:
+ // falling back
+ default:
+ mFormat = QImage::Format_RGB16;
+ break;
+ }
+ mPhysicalSize = determinePhysicalSize(userMmSize, geometry.size());
+
+ // mmap the framebuffer
+ const size_t pagemask = getpagesize() - 1;
+ m_mmap.size = (m_bytesPerLine * fb.fb_height + pagemask) & ~pagemask;
+ uchar *data = static_cast<uchar*>(mmap(nullptr, m_mmap.size, PROT_READ | PROT_WRITE, MAP_SHARED, m_framebufferFd, 0));
+ if (data == MAP_FAILED) {
+ qErrnoWarning(errno, "Failed to mmap framebuffer");
+ return false;
+ }
+
+ m_mmap.offset = geometry.y() * m_bytesPerLine + geometry.x() * mDepth / 8;
+ m_mmap.data = data + m_mmap.offset;
+
+ QFbScreen::initializeCompositor();
+ m_onscreenImage = QImage(m_mmap.data, geometry.width(), geometry.height(), m_bytesPerLine, mFormat);
+
+ mCursor = new QFbCursor(this);
+
+ return true;
+}
+
+QRegion QBsdFbScreen::doRedraw()
+{
+ const QRegion touched = QFbScreen::doRedraw();
+
+ if (touched.isEmpty())
+ return touched;
+
+ if (!m_blitter)
+ m_blitter.reset(new QPainter(&m_onscreenImage));
+
+ const auto rects = touched.rects();
+ for (const QRect &rect : rects)
+ m_blitter->drawImage(rect, *mScreenImage, rect);
+ return touched;
+}
+
+// grabWindow() grabs "from the screen" not from the backingstores.
+QPixmap QBsdFbScreen::grabWindow(WId wid, int x, int y, int width, int height) const
+{
+ if (!wid) {
+ if (width < 0)
+ width = m_onscreenImage.width() - x;
+ if (height < 0)
+ height = m_onscreenImage.height() - y;
+ return QPixmap::fromImage(m_onscreenImage).copy(x, y, width, height);
+ }
+
+ const QFbWindow *window = windowForId(wid);
+ if (window) {
+ const QRect geom = window->geometry();
+ if (width < 0)
+ width = geom.width() - x;
+ if (height < 0)
+ height = geom.height() - y;
+ QRect rect(geom.topLeft() + QPoint(x, y), QSize(width, height));
+ rect &= window->geometry();
+ return QPixmap::fromImage(m_onscreenImage).copy(rect);
+ }
+
+ return QPixmap();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/bsdfb/qbsdfbscreen.h b/src/plugins/platforms/bsdfb/qbsdfbscreen.h
new file mode 100644
index 0000000000..0d9964afd5
--- /dev/null
+++ b/src/plugins/platforms/bsdfb/qbsdfbscreen.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2015-2016 Oleksandr Tymoshenko <gonzo@bluezbox.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBSDFBSCREEN_H
+#define QBSDFBSCREEN_H
+
+#include <QtPlatformSupport/private/qfbscreen_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QPainter;
+
+class QBsdFbScreen : public QFbScreen
+{
+ Q_OBJECT
+public:
+ explicit QBsdFbScreen(const QStringList &args);
+ ~QBsdFbScreen() override;
+
+ bool initialize();
+
+ QPixmap grabWindow(WId wid, int x, int y, int width, int height) const override;
+
+ QRegion doRedraw() override;
+
+private:
+ QStringList m_arguments;
+ int m_framebufferFd = -1;
+ QImage m_onscreenImage;
+
+ int m_bytesPerLine = -1;
+
+ struct {
+ uchar *data;
+ int offset, size;
+ } m_mmap;
+
+ QScopedPointer<QPainter> m_blitter;
+};
+
+QT_END_NAMESPACE
+
+#endif // QBSDFBSCREEN_H
diff --git a/src/plugins/platforms/cocoa/qcocoaapplication.h b/src/plugins/platforms/cocoa/qcocoaapplication.h
index e92bef4011..7bd3c8c76c 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplication.h
+++ b/src/plugins/platforms/cocoa/qcocoaapplication.h
@@ -95,7 +95,6 @@
@interface NSApplication (QT_MANGLE_NAMESPACE(QApplicationIntegration))
- (void)QT_MANGLE_NAMESPACE(qt_setDockMenu):(NSMenu *)newMenu;
-- (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader);
- (int)QT_MANGLE_NAMESPACE(qt_validModesForFontPanel):(NSFontPanel *)fontPanel;
- (void)QT_MANGLE_NAMESPACE(qt_sendPostedMessage):(NSEvent *)event;
diff --git a/src/plugins/platforms/cocoa/qcocoaapplication.mm b/src/plugins/platforms/cocoa/qcocoaapplication.mm
index c496134606..c5ae4bc2bf 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplication.mm
+++ b/src/plugins/platforms/cocoa/qcocoaapplication.mm
@@ -71,11 +71,11 @@
**
****************************************************************************/
-#include <qcocoaapplication.h>
+#include "qcocoaapplication.h"
-#include <qcocoaintrospection.h>
-#include <qcocoaapplicationdelegate.h>
-#include <qcocoahelpers.h>
+#include "qcocoaintrospection.h"
+#include "qcocoaapplicationdelegate.h"
+#include "qcocoahelpers.h"
#include <qguiapplication.h>
#include <qdebug.h>
@@ -88,11 +88,6 @@ QT_USE_NAMESPACE
[[QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate] setDockMenu:newMenu];
}
-- (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)
-{
- return [[QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate] menuLoader];
-}
-
- (int)QT_MANGLE_NAMESPACE(qt_validModesForFontPanel):(NSFontPanel *)fontPanel
{
Q_UNUSED(fontPanel);
diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h
index 68a028ed8a..59c71017e3 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h
+++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h
@@ -95,14 +95,11 @@
@interface QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) : NSObject <NSApplicationDelegate> {
bool startedQuit;
NSMenu *dockMenu;
- QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader;
NSObject <NSApplicationDelegate> *reflectionDelegate;
bool inLaunch;
}
+ (QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate)*)sharedDelegate;
- (void)setDockMenu:(NSMenu *)newMenu;
-- (void)setMenuLoader:(QT_MANGLE_NAMESPACE(QCocoaMenuLoader)*)menuLoader;
-- (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)menuLoader;
- (void)setReflectionDelegate:(NSObject <NSApplicationDelegate> *)oldDelegate;
- (void)getUrl:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
- (void) removeAppleEventHandlers;
diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
index d18df35b80..4874fcf807 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
+++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
@@ -122,7 +122,6 @@ QT_END_NAMESPACE
{
sharedCocoaApplicationDelegate = nil;
[dockMenu release];
- [qtMenuLoader release];
if (reflectionDelegate) {
[[NSApplication sharedApplication] setDelegate:reflectionDelegate];
[reflectionDelegate release];
@@ -169,24 +168,12 @@ QT_END_NAMESPACE
return [[dockMenu retain] autorelease];
}
-- (void)setMenuLoader:(QCocoaMenuLoader *)menuLoader
-{
- [menuLoader retain];
- [qtMenuLoader release];
- qtMenuLoader = menuLoader;
-}
-
-- (QCocoaMenuLoader *)menuLoader
-{
- return [[qtMenuLoader retain] autorelease];
-}
-
- (BOOL) canQuit
{
[[NSApp mainMenu] cancelTracking];
bool handle_quit = true;
- NSMenuItem *quitMenuItem = [[[QCocoaApplicationDelegate sharedDelegate] menuLoader] quitMenuItem];
+ NSMenuItem *quitMenuItem = [[QT_MANGLE_NAMESPACE(QCocoaMenuLoader) sharedMenuLoader] quitMenuItem];
if (!QGuiApplicationPrivate::instance()->modalWindowList.isEmpty()
&& [quitMenuItem isEnabled]) {
int visible = 0;
@@ -447,10 +434,4 @@ QT_END_NAMESPACE
[NSApp terminate:self];
}
-- (void)qtDispatcherToQAction:(id)sender
-{
- Q_UNUSED(sender);
- [qtMenuLoader qtDispatcherToQPAMenuItem:sender];
-}
-
@end
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.h b/src/plugins/platforms/cocoa/qcocoabackingstore.h
index fa05626d18..52a3e756b9 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.h
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.h
@@ -57,11 +57,8 @@ public:
QPaintDevice *paintDevice() Q_DECL_OVERRIDE;
void flush(QWindow *widget, const QRegion &region, const QPoint &offset) Q_DECL_OVERRIDE;
-#ifndef QT_NO_OPENGL
QImage toImage() const Q_DECL_OVERRIDE;
-#else
- QImage toImage() const; // No QPlatformBackingStore::toImage() for NO_OPENGL builds.
-#endif
+
void resize (const QSize &size, const QRegion &) Q_DECL_OVERRIDE;
bool scroll(const QRegion &area, int dx, int dy) Q_DECL_OVERRIDE;
void beginPaint(const QRegion &region) Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
index b060d6a082..20233518b3 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
@@ -96,9 +96,8 @@ bool QCocoaBackingStore::scroll(const QRegion &area, int dx, int dy)
extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset);
const qreal devicePixelRatio = m_qImage.devicePixelRatio();
QPoint qpoint(dx * devicePixelRatio, dy * devicePixelRatio);
- const QVector<QRect> qrects = area.rects();
- for (int i = 0; i < qrects.count(); ++i) {
- const QRect &qrect = QRect(qrects.at(i).topLeft() * devicePixelRatio, qrects.at(i).size() * devicePixelRatio);
+ for (const QRect &rect : area) {
+ const QRect qrect(rect.topLeft() * devicePixelRatio, rect.size() * devicePixelRatio);
qt_scrollRectInImage(m_qImage, qrect, qpoint);
}
return true;
@@ -109,10 +108,9 @@ void QCocoaBackingStore::beginPaint(const QRegion &region)
if (m_qImage.hasAlphaChannel()) {
QPainter p(&m_qImage);
p.setCompositionMode(QPainter::CompositionMode_Source);
- const QVector<QRect> rects = region.rects();
const QColor blank = Qt::transparent;
- for (QVector<QRect>::const_iterator it = rects.begin(), end = rects.end(); it != end; ++it)
- p.fillRect(*it, blank);
+ for (const QRect &rect : region)
+ p.fillRect(rect, blank);
}
}
diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
index 85468009f3..aaa12c6edb 100644
--- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
@@ -132,7 +132,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
- (void)setDialogHelper:(QCocoaColorDialogHelper *)helper
{
mHelper = helper;
- [mColorPanel setShowsAlpha:mHelper->options()->testOption(QColorDialogOptions::ShowAlphaChannel)];
+
if (mHelper->options()->testOption(QColorDialogOptions::NoButtons)) {
[self restoreOriginalContentView];
} else if (!mStolenContentView) {
@@ -483,6 +483,14 @@ bool QCocoaColorDialogHelper::show(Qt::WindowFlags, Qt::WindowModality windowMod
{
if (windowModality == Qt::WindowModal)
windowModality = Qt::ApplicationModal;
+
+ // Workaround for Apple rdar://25792119: If you invoke
+ // -setShowsAlpha: multiple times before showing the color
+ // picker, its height grows irrevocably. Instead, only
+ // invoke it once, when we show the dialog.
+ [[NSColorPanel sharedColorPanel] setShowsAlpha:
+ options()->testOption(QColorDialogOptions::ShowAlphaChannel)];
+
sharedColorPanel()->init(this);
return sharedColorPanel()->show(windowModality, parent);
}
diff --git a/src/plugins/platforms/cocoa/qcocoadrag.mm b/src/plugins/platforms/cocoa/qcocoadrag.mm
index bb8d12e3ce..13ae0382ab 100644
--- a/src/plugins/platforms/cocoa/qcocoadrag.mm
+++ b/src/plugins/platforms/cocoa/qcocoadrag.mm
@@ -131,7 +131,7 @@ Qt::DropAction QCocoaDrag::drag(QDrag *o)
QPixmap pm = dragPixmap(m_drag, hotSpot);
QSize pmDeviceIndependentSize = pm.size() / pm.devicePixelRatio();
NSImage *nsimage = qt_mac_create_nsimage(pm);
- [nsimage setSize : qt_mac_toNSSize(pmDeviceIndependentSize)];
+ [nsimage setSize:pmDeviceIndependentSize.toCGSize()];
QMacPasteboard dragBoard((CFStringRef) NSDragPboard, QMacInternalPasteboardMime::MIME_DND);
m_drag->mimeData()->setData(QLatin1String("application/x-qt-mime-type-name"), QByteArray("dummy"));
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
index 475e6c7afb..31a0a3d600 100644
--- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm
@@ -61,6 +61,8 @@
#include <qvarlengtharray.h>
#include <stdlib.h>
#include <qabstracteventdispatcher.h>
+#include <qsysinfo.h>
+#include <qglobal.h>
#include <QDir>
#include <qpa/qplatformnativeinterface.h>
@@ -160,6 +162,11 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSOpenSavePanelDelegate);
// here to make sure it gets the correct value.
[mSavePanel setDelegate:self];
+#if QT_OSX_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_11)
+ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_11)
+ mOpenPanel.accessoryViewDisclosed = YES;
+#endif
+
if (mOptions->isLabelExplicitlySet(QFileDialogOptions::Accept))
[mSavePanel setPrompt:[self strip:options->labelText(QFileDialogOptions::Accept)]];
if (mOptions->isLabelExplicitlySet(QFileDialogOptions::FileName))
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h
index ec2f7f8cf1..9b061bbae8 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.h
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.h
@@ -77,10 +77,6 @@ CGImageRef qt_mac_toCGImageMask(const QImage &qImage);
QImage qt_mac_toQImage(CGImageRef image);
QPixmap qt_mac_toQPixmap(const NSImage *image, const QSizeF &size);
-NSSize qt_mac_toNSSize(const QSize &qtSize);
-NSRect qt_mac_toNSRect(const QRect &rect);
-QRect qt_mac_toQRect(const NSRect &rect);
-
QColor qt_mac_toQColor(const NSColor *color);
QColor qt_mac_toQColor(CGColorRef color);
@@ -114,10 +110,6 @@ NSRect qt_mac_flipRect(const QRect &rect);
Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum);
-bool qt_mac_execute_apple_script(const char *script, long script_len, AEDesc *ret);
-bool qt_mac_execute_apple_script(const char *script, AEDesc *ret);
-bool qt_mac_execute_apple_script(const QString &script, AEDesc *ret);
-
// strip out '&' characters, and convert "&&" to a single '&', in menu
// text - since menu text is sometimes decorated with these for Windows
// accelerators.
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm
index 606b2e7032..6920f75887 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.mm
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm
@@ -101,65 +101,23 @@ void *qt_mac_QStringListToNSMutableArrayVoid(const QStringList &list)
return result;
}
-static void qt_mac_deleteImage(void *image, const void *, size_t)
-{
- delete static_cast<QImage *>(image);
-}
-
-// Creates a CGDataProvider with the data from the given image.
-// The data provider retains a copy of the image.
-CGDataProviderRef qt_mac_CGDataProvider(const QImage &image)
-{
- return CGDataProviderCreateWithData(new QImage(image), image.bits(),
- image.byteCount(), qt_mac_deleteImage);
-}
-
CGImageRef qt_mac_toCGImage(const QImage &inImage)
{
- if (inImage.isNull())
- return 0;
+ CGImageRef cgImage = inImage.toCGImage();
+ if (cgImage)
+ return cgImage;
- QImage image = inImage;
-
- uint cgflags = kCGImageAlphaNone;
- switch (image.format()) {
- case QImage::Format_ARGB32:
- cgflags = kCGImageAlphaFirst | kCGBitmapByteOrder32Host;
- break;
- case QImage::Format_RGB32:
- cgflags = kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Host;
- break;
- case QImage::Format_RGB888:
- cgflags = kCGImageAlphaNone | kCGBitmapByteOrder32Big;
- break;
- case QImage::Format_RGBA8888_Premultiplied:
- cgflags = kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big;
- break;
- case QImage::Format_RGBA8888:
- cgflags = kCGImageAlphaLast | kCGBitmapByteOrder32Big;
- break;
- case QImage::Format_RGBX8888:
- cgflags = kCGImageAlphaNoneSkipLast | kCGBitmapByteOrder32Big;
- break;
- default:
- // Everything not recognized explicitly is converted to ARGB32_Premultiplied.
- image = inImage.convertToFormat(QImage::Format_ARGB32_Premultiplied);
- // no break;
- case QImage::Format_ARGB32_Premultiplied:
- cgflags = kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host;
- break;
- }
-
- QCFType<CGDataProviderRef> dataProvider = qt_mac_CGDataProvider(image);
- return CGImageCreate(image.width(), image.height(), 8, 32,
- image.bytesPerLine(),
- qt_mac_genericColorSpace(),
- cgflags, dataProvider, 0, false, kCGRenderingIntentDefault);
+ // Convert image data to a known-good format if the fast conversion fails.
+ return inImage.convertToFormat(QImage::Format_ARGB32_Premultiplied).toCGImage();
}
CGImageRef qt_mac_toCGImageMask(const QImage &image)
{
- QCFType<CGDataProviderRef> dataProvider = qt_mac_CGDataProvider(image);
+ static const auto deleter = [](void *image, const void *, size_t) { delete static_cast<QImage *>(image); };
+ QCFType<CGDataProviderRef> dataProvider =
+ CGDataProviderCreateWithData(new QImage(image), image.bits(),
+ image.byteCount(), deleter);
+
return CGImageMaskCreate(image.width(), image.height(), 8, image.depth(),
image.bytesPerLine(), dataProvider, NULL, false);
}
@@ -202,34 +160,13 @@ NSImage *qt_mac_create_nsimage(const QIcon &icon)
HIMutableShapeRef qt_mac_QRegionToHIMutableShape(const QRegion &region)
{
HIMutableShapeRef shape = HIShapeCreateMutable();
- QVector<QRect> rects = region.rects();
- if (!rects.isEmpty()) {
- int n = rects.count();
- const QRect *qt_r = rects.constData();
- while (n--) {
- CGRect cgRect = CGRectMake(qt_r->x(), qt_r->y(), qt_r->width(), qt_r->height());
- HIShapeUnionWithRect(shape, &cgRect);
- ++qt_r;
- }
+ for (const QRect &rect : region) {
+ CGRect cgRect = CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
+ HIShapeUnionWithRect(shape, &cgRect);
}
return shape;
}
-NSSize qt_mac_toNSSize(const QSize &qtSize)
-{
- return NSMakeSize(qtSize.width(), qtSize.height());
-}
-
-NSRect qt_mac_toNSRect(const QRect &rect)
-{
- return NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height());
-}
-
-QRect qt_mac_toQRect(const NSRect &rect)
-{
- return QRect(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
-}
-
QColor qt_mac_toQColor(const NSColor *color)
{
QColor qtColor;
@@ -340,38 +277,8 @@ QBrush qt_mac_toQBrush(const NSColor *color, QPalette::ColorGroup colorGroup)
// (and providing no public API to get the underlying color without this insanity)
if (qt_mac_isSystemColorOrInstance(color, @"controlColor", @"NSGradientPatternColor") ||
qt_mac_isSystemColorOrInstance(color, @"windowBackgroundColor", @"NSGradientPatternColor")) {
- static QColor newColor;
- if (!newColor.isValid()) {
-#if QT_MAC_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_8, __IPHONE_NA)
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
- newColor = qt_mac_toQColor(color.CGColor);
- } else
-#endif
- {
- NSBitmapImageRep *offscreenRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil
- pixelsWide:1
- pixelsHigh:1
- bitsPerSample:8
- samplesPerPixel:4
- hasAlpha:YES
- isPlanar:NO
- colorSpaceName:NSDeviceRGBColorSpace
- bytesPerRow:4
- bitsPerPixel:32];
- [NSGraphicsContext saveGraphicsState];
- [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithBitmapImageRep:offscreenRep]];
- NSEraseRect(NSMakeRect(0, 0, 1, 1));
- [color drawSwatchInRect:NSMakeRect(0, 0, 1, 1)];
- [NSGraphicsContext restoreGraphicsState];
- NSUInteger pixel[4];
- [offscreenRep getPixel:pixel atX:0 y:0];
- [offscreenRep release];
- newColor = QColor(pixel[0], pixel[1], pixel[2], pixel[3]);
- }
- }
-
qtBrush.setStyle(Qt::SolidPattern);
- qtBrush.setColor(newColor);
+ qtBrush.setColor(qt_mac_toQColor(color.CGColor));
return qtBrush;
}
@@ -687,66 +594,6 @@ Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum)
return Qt::NoButton;
}
-bool qt_mac_execute_apple_script(const char *script, long script_len, AEDesc *ret) {
- OSStatus err;
- AEDesc scriptTextDesc;
- ComponentInstance theComponent = 0;
- OSAID scriptID = kOSANullScript, resultID = kOSANullScript;
-
- // set up locals to a known state
- AECreateDesc(typeNull, 0, 0, &scriptTextDesc);
- scriptID = kOSANullScript;
- resultID = kOSANullScript;
-
- // open the scripting component
- theComponent = OpenDefaultComponent(kOSAComponentType, typeAppleScript);
- if (!theComponent) {
- err = paramErr;
- goto bail;
- }
-
- // put the script text into an aedesc
- err = AECreateDesc(typeUTF8Text, script, script_len, &scriptTextDesc);
- if (err != noErr)
- goto bail;
-
- // compile the script
- err = OSACompile(theComponent, &scriptTextDesc, kOSAModeNull, &scriptID);
- if (err != noErr)
- goto bail;
-
- // run the script
- err = OSAExecute(theComponent, scriptID, kOSANullScript, kOSAModeNull, &resultID);
-
- // collect the results - if any
- if (ret) {
- AECreateDesc(typeNull, 0, 0, ret);
- if (err == errOSAScriptError)
- OSAScriptError(theComponent, kOSAErrorMessage, typeChar, ret);
- else if (err == noErr && resultID != kOSANullScript)
- OSADisplay(theComponent, resultID, typeChar, kOSAModeNull, ret);
- }
-bail:
- AEDisposeDesc(&scriptTextDesc);
- if (scriptID != kOSANullScript)
- OSADispose(theComponent, scriptID);
- if (resultID != kOSANullScript)
- OSADispose(theComponent, resultID);
- if (theComponent)
- CloseComponent(theComponent);
- return err == noErr;
-}
-
-bool qt_mac_execute_apple_script(const char *script, AEDesc *ret)
-{
- return qt_mac_execute_apple_script(script, qstrlen(script), ret);
-}
-
-bool qt_mac_execute_apple_script(const QString &script, AEDesc *ret)
-{
- const QByteArray l = script.toUtf8(); return qt_mac_execute_apple_script(l.constData(), l.size(), ret);
-}
-
QString qt_mac_removeAmpersandEscapes(QString s)
{
return QPlatformTheme::removeMnemonics(s).trimmed();
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index f02dad675e..c3890bcd46 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -331,10 +331,8 @@ QCocoaIntegration::QCocoaIntegration(const QStringList &paramList)
[cocoaApplication setDelegate:newDelegate];
// Load the application menu. This menu contains Preferences, Hide, Quit.
- QCocoaMenuLoader *qtMenuLoader = [[QCocoaMenuLoader alloc] init];
- qt_mac_loadMenuNib(qtMenuLoader);
+ QCocoaMenuLoader *qtMenuLoader = [QCocoaMenuLoader sharedMenuLoader];
[cocoaApplication setMenu:[qtMenuLoader menu]];
- [newDelegate setMenuLoader:qtMenuLoader];
}
// The presentation options such as whether or not the dock and/or menu bar is
diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.h b/src/plugins/platforms/cocoa/qcocoakeymapper.h
index 93ebc5b9dc..4ba615efeb 100644
--- a/src/plugins/platforms/cocoa/qcocoakeymapper.h
+++ b/src/plugins/platforms/cocoa/qcocoakeymapper.h
@@ -40,7 +40,7 @@
#ifndef QCOCOAKEYMAPPER_H
#define QCOCOAKEYMAPPER_H
-#include <qcocoahelpers.h>
+#include "qcocoahelpers.h"
#include <AppKit/AppKit.h>
#include <Carbon/Carbon.h>
diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm
index 06ec2aa479..32cf9ebc53 100644
--- a/src/plugins/platforms/cocoa/qcocoamenu.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenu.mm
@@ -74,11 +74,6 @@ NSString *qt_mac_removePrivateUnicode(NSString* string)
return string;
}
-static inline QCocoaMenuLoader *getMenuLoader()
-{
- return [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
-}
-
QT_END_NAMESPACE
@interface QT_MANGLE_NAMESPACE(QCocoaMenuDelegate) : NSObject <NSMenuDelegate> {
@@ -408,7 +403,7 @@ void QCocoaMenu::syncMenuItem(QPlatformMenuItem *menuItem)
}
bool wasMerged = cocoaItem->isMerged();
- NSMenu *oldMenu = wasMerged ? [getMenuLoader() applicationMenu] : m_nativeMenu;
+ NSMenu *oldMenu = wasMerged ? [[QCocoaMenuLoader sharedMenuLoader] applicationMenu] : m_nativeMenu;
NSMenuItem *oldItem = [oldMenu itemWithTag:(NSInteger) cocoaItem];
if (cocoaItem->sync() != oldItem) {
diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm
index 96b40259b4..ded7ab541b 100644
--- a/src/plugins/platforms/cocoa/qcocoamenubar.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm
@@ -52,11 +52,6 @@ QT_BEGIN_NAMESPACE
static QList<QCocoaMenuBar*> static_menubars;
-static inline QCocoaMenuLoader *getMenuLoader()
-{
- return [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
-}
-
QCocoaMenuBar::QCocoaMenuBar() :
m_window(0)
{
@@ -330,7 +325,7 @@ void QCocoaMenuBar::updateMenuBarImmediately()
menu->syncModalState(disableForModal);
}
- QCocoaMenuLoader *loader = getMenuLoader();
+ QCocoaMenuLoader *loader = [QCocoaMenuLoader sharedMenuLoader];
[loader ensureAppMenuInMenu:mb->nsMenu()];
NSMutableSet *mergedItems = [[NSMutableSet setWithCapacity:0] retain];
diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
index 64c460feb9..3504f967bf 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
@@ -53,12 +53,6 @@
QT_BEGIN_NAMESPACE
-static inline QCocoaMenuLoader *getMenuLoader()
-{
- return [NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)];
-}
-
-
static quint32 constructModifierMask(quint32 accel_key)
{
quint32 ret = 0;
@@ -221,7 +215,7 @@ NSMenuItem *QCocoaMenuItem::sync()
if ((m_role != NoRole && !m_textSynced) || m_merged) {
NSMenuItem *mergeItem = nil;
- QCocoaMenuLoader *loader = getMenuLoader();
+ QCocoaMenuLoader *loader = [QCocoaMenuLoader sharedMenuLoader];
switch (m_role) {
case ApplicationSpecificRole:
mergeItem = [loader appSpecificMenuItem:reinterpret_cast<NSInteger>(this)];
@@ -359,7 +353,7 @@ QT_END_NAMESPACE
QString QCocoaMenuItem::mergeText()
{
- QCocoaMenuLoader *loader = getMenuLoader();
+ QCocoaMenuLoader *loader = [QCocoaMenuLoader sharedMenuLoader];
if (m_native == [loader aboutMenuItem]) {
return qt_mac_applicationmenu_string(6).arg(qt_mac_applicationName());
} else if (m_native== [loader aboutQtMenuItem]) {
@@ -379,7 +373,7 @@ QString QCocoaMenuItem::mergeText()
QKeySequence QCocoaMenuItem::mergeAccel()
{
- QCocoaMenuLoader *loader = getMenuLoader();
+ QCocoaMenuLoader *loader = [QCocoaMenuLoader sharedMenuLoader];
if (m_native == [loader preferencesMenuItem])
return QKeySequence(QKeySequence::Preferences);
else if (m_native == [loader quitMenuItem])
diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.h b/src/plugins/platforms/cocoa/qcocoamenuloader.h
index 6f58b2f24c..95f347646c 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuloader.h
+++ b/src/plugins/platforms/cocoa/qcocoamenuloader.h
@@ -68,6 +68,8 @@
NSMenuItem *hideAllOthersItem;
NSMenuItem *showAllItem;
}
++ (instancetype)sharedMenuLoader;
+- (instancetype)init;
- (void)ensureAppMenuInMenu:(NSMenu *)menu;
- (void)removeActionsFromAppMenu;
- (NSMenu *)applicationMenu;
@@ -92,10 +94,4 @@
QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaMenuLoader);
-QT_BEGIN_NAMESPACE
-
-void qt_mac_loadMenuNib(QCocoaMenuLoader *qtMenuLoader);
-
-QT_END_NAMESPACE
-
#endif // QCOCOAMENULOADER_P_H
diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.mm b/src/plugins/platforms/cocoa/qcocoamenuloader.mm
index e440a9080c..22e90f8dc8 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuloader.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenuloader.mm
@@ -55,86 +55,127 @@
QT_FORWARD_DECLARE_CLASS(QCFString)
QT_FORWARD_DECLARE_CLASS(QString)
+@implementation QCocoaMenuLoader
-QT_BEGIN_NAMESPACE
-
-/*
- Loads and instantiates the main app menu from the menu nib file(s).
-
- The main app menu contains the Quit, Hide About, Preferences entries, and
- The reason for having the nib file is that those can not be created
- programmatically. To ease deployment the nib files are stored in Qt resources
- and written to QDir::temp() before loading. (Earlier Qt versions used
- to require having the nib file in the Qt GUI framework.)
-*/
-void qt_mac_loadMenuNib(QCocoaMenuLoader *qtMenuLoader)
++ (instancetype)sharedMenuLoader
{
- // Create qt_menu.nib dir in temp.
- QDir temp = QDir::temp();
- temp.mkdir("qt_menu.nib");
- QString nibDir = temp.canonicalPath() + QLatin1String("/") + QLatin1String("qt_menu.nib/");
- if (!QDir(nibDir).exists()) {
- qWarning("qt_mac_loadMenuNib: could not create nib directory in temp");
- return;
- }
-
- // Copy nib files from resources to temp.
- QDir nibResource(":/qt-project.org/mac/qt_menu.nib/");
- if (!nibResource.exists()) {
- qWarning("qt_mac_loadMenuNib: could not load nib from resources");
- return;
- }
- foreach (const QFileInfo &file, nibResource.entryInfoList()) {
- QFileInfo destinationFile(nibDir + QLatin1String("/") + file.fileName());
- if (destinationFile.exists() && destinationFile.size() != file.size())
- QFile::remove(destinationFile.absoluteFilePath());
+ static QCocoaMenuLoader *shared = nil;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ shared = [[self alloc] init];
+ });
+ return shared;
+}
- QFile::copy(file.absoluteFilePath(), destinationFile.absoluteFilePath());
+- (instancetype)init
+{
+ if ((self = [super init])) {
+ NSString *appName = qt_mac_applicationName().toNSString();
+
+ // Menubar as menu. Title as set in the NIB file
+ theMenu = [[NSMenu alloc] initWithTitle:@"Main Menu"];
+
+ // Application menu. Since 10.6, the first menu
+ // is always identified as the application menu.
+ NSMenuItem *appItem = [[[NSMenuItem alloc] init] autorelease];
+ appItem.title = appName;
+ [theMenu addItem:appItem];
+ appMenu = [[NSMenu alloc] initWithTitle:appName];
+ appItem.submenu = appMenu;
+
+ // About Application
+ aboutItem = [[NSMenuItem alloc] initWithTitle:[@"About " stringByAppendingString:appName]
+ action:@selector(orderFrontStandardAboutPanel:)
+ keyEquivalent:@""];
+ aboutItem.target = self;
+ // Disable until a QAction is associated
+ aboutItem.enabled = NO;
+ aboutItem.hidden = YES;
+ [appMenu addItem:aboutItem];
+
+ // About Qt (shameless self-promotion)
+ aboutQtItem = [[NSMenuItem alloc] init];
+ aboutQtItem.title = @"About Qt";
+ // Disable until a QAction is associated
+ aboutQtItem.enabled = NO;
+ aboutQtItem.hidden = YES;
+ [appMenu addItem:aboutQtItem];
+
+ [appMenu addItem:[NSMenuItem separatorItem]];
+
+ // Preferences
+ preferencesItem = [[NSMenuItem alloc] initWithTitle:@"Preferences…"
+ action:@selector(qtDispatcherToQPAMenuItem:)
+ keyEquivalent:@","];
+ preferencesItem.target = self;
+ // Disable until a QAction is associated
+ preferencesItem.enabled = NO;
+ preferencesItem.hidden = YES;
+ [appMenu addItem:preferencesItem];
+
+ [appMenu addItem:[NSMenuItem separatorItem]];
+
+ // Services item and menu
+ servicesItem = [[NSMenuItem alloc] init];
+ servicesItem.title = @"Services";
+ NSMenu *servicesMenu = [[[NSMenu alloc] initWithTitle:@"Services"] autorelease];
+ servicesItem.submenu = servicesMenu;
+ [NSApplication sharedApplication].servicesMenu = servicesMenu;
+ [appMenu addItem:servicesItem];
+
+ [appMenu addItem:[NSMenuItem separatorItem]];
+
+ // Hide Application
+ hideItem = [[NSMenuItem alloc] initWithTitle:[@"Hide " stringByAppendingString:appName]
+ action:@selector(hide:)
+ keyEquivalent:@"h"];
+ hideItem.target = self;
+ [appMenu addItem:hideItem];
+
+ // Hide Others
+ hideAllOthersItem = [[NSMenuItem alloc] initWithTitle:@"Hide Others"
+ action:@selector(hideOtherApplications:)
+ keyEquivalent:@"h"];
+ hideAllOthersItem.target = self;
+ hideAllOthersItem.keyEquivalentModifierMask = NSCommandKeyMask | NSAlternateKeyMask;
+ [appMenu addItem:hideAllOthersItem];
+
+ // Show All
+ showAllItem = [[NSMenuItem alloc] initWithTitle:@"Show All"
+ action:@selector(unhideAllApplications:)
+ keyEquivalent:@""];
+ showAllItem.target = self;
+ [appMenu addItem:showAllItem];
+
+ [appMenu addItem:[NSMenuItem separatorItem]];
+
+ // Quit Application
+ quitItem = [[NSMenuItem alloc] initWithTitle:[@"Quit " stringByAppendingString:appName]
+ action:@selector(terminate:)
+ keyEquivalent:@"q"];
+ quitItem.target = self;
+ [appMenu addItem:quitItem];
}
- // Load and instantiate nib file from temp
- NSURL *nibUrl = [NSURL fileURLWithPath : QCFString::toNSString(nibDir)];
- NSNib *nib = [[NSNib alloc] initWithContentsOfURL : nibUrl];
- [nib autorelease];
- if(!nib) {
- qWarning("qt_mac_loadMenuNib: could not load nib from temp");
- return;
- }
- bool ok = [nib instantiateNibWithOwner : qtMenuLoader topLevelObjects : nil];
- if (!ok) {
- qWarning("qt_mac_loadMenuNib: could not instantiate nib");
- }
+ return self;
}
-QT_END_NAMESPACE
+- (void)dealloc
+{
+ [theMenu release];
+ [appMenu release];
+ [aboutItem release];
+ [aboutQtItem release];
+ [preferencesItem release];
+ [servicesItem release];
+ [hideItem release];
+ [hideAllOthersItem release];
+ [showAllItem release];
+ [quitItem release];
-@implementation QCocoaMenuLoader
+ [lastAppSpecificItem release];
-- (void)awakeFromNib
-{
- servicesItem = [[appMenu itemWithTitle:@"Services"] retain];
- hideAllOthersItem = [[appMenu itemWithTitle:@"Hide Others"] retain];
- showAllItem = [[appMenu itemWithTitle:@"Show All"] retain];
-
- // Get the names in the nib to match the app name set by Qt.
- const NSString *appName = qt_mac_applicationName().toNSString();
- [quitItem setTitle:[[quitItem title] stringByReplacingOccurrencesOfString:@"NewApplication"
- withString:const_cast<NSString *>(appName)]];
- [hideItem setTitle:[[hideItem title] stringByReplacingOccurrencesOfString:@"NewApplication"
- withString:const_cast<NSString *>(appName)]];
- [aboutItem setTitle:[[aboutItem title] stringByReplacingOccurrencesOfString:@"NewApplication"
- withString:const_cast<NSString *>(appName)]];
- // Disable the items that don't do anything. If someone associates a QAction with them
- // They should get synced back in.
- [preferencesItem setEnabled:NO];
- [preferencesItem setHidden:YES];
-
- // should set this in the NIB
- [preferencesItem setTarget: self];
- [preferencesItem setAction: @selector(qtDispatcherToQPAMenuItem:)];
-
- [aboutItem setEnabled:NO];
- [aboutItem setHidden:YES];
+ [super dealloc];
}
- (void)ensureAppMenuInMenu:(NSMenu *)menu
@@ -179,18 +220,6 @@ QT_END_NAMESPACE
[item setTag:0];
}
-- (void)dealloc
-{
- [servicesItem release];
- [hideAllOthersItem release];
- [showAllItem release];
-
- [lastAppSpecificItem release];
- [theMenu release];
- [appMenu release];
- [super dealloc];
-}
-
- (NSMenu *)menu
{
return [[theMenu retain] autorelease];
diff --git a/src/plugins/platforms/cocoa/qcocoaresources.qrc b/src/plugins/platforms/cocoa/qcocoaresources.qrc
index 9e0640db7d..4255bfba9d 100644
--- a/src/plugins/platforms/cocoa/qcocoaresources.qrc
+++ b/src/plugins/platforms/cocoa/qcocoaresources.qrc
@@ -9,9 +9,4 @@
<qresource prefix="/qt-project.org/mac/style">
<file>images/leopard-unified-toolbar-on.png</file>
</qresource>
-<qresource prefix="/qt-project.org/mac/">
-<file>qt_menu.nib/classes.nib</file>
-<file>qt_menu.nib/info.nib</file>
-<file>qt_menu.nib/keyedobjects.nib</file>
-</qresource>
</RCC>
diff --git a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
index 0cbdc5d9c8..e8d8a473c3 100644
--- a/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
+++ b/src/plugins/platforms/cocoa/qcocoasystemtrayicon.mm
@@ -91,11 +91,8 @@ QT_USE_NAMESPACE
@class QT_MANGLE_NAMESPACE(QNSMenu);
@class QT_MANGLE_NAMESPACE(QNSImageView);
-@interface QT_MANGLE_NAMESPACE(QNSStatusItem) : NSObject
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
- <NSUserNotificationCenterDelegate>
-#endif
- {
+@interface QT_MANGLE_NAMESPACE(QNSStatusItem) : NSObject <NSUserNotificationCenterDelegate>
+{
@public
QCocoaSystemTrayIcon *systray;
NSStatusItem *item;
@@ -109,11 +106,8 @@ QT_USE_NAMESPACE
-(QRectF)geometry;
- (void)triggerSelector:(id)sender button:(Qt::MouseButton)mouseButton;
- (void)doubleClickSelector:(id)sender;
-
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification;
- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification;
-#endif
@end
@interface QT_MANGLE_NAMESPACE(QNSImageView) : NSImageView {
@@ -142,19 +136,11 @@ class QSystemTrayIconSys
public:
QSystemTrayIconSys(QCocoaSystemTrayIcon *sys) {
item = [[QNSStatusItem alloc] initWithSysTray:sys];
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
- [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:item];
- }
-#endif
+ [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:item];
}
~QSystemTrayIconSys() {
[[[item item] view] setHidden: YES];
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
- [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:nil];
- }
-#endif
+ [[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:nil];
[item release];
}
QNSStatusItem *item;
@@ -296,71 +282,15 @@ bool QCocoaSystemTrayIcon::supportsMessages() const
void QCocoaSystemTrayIcon::showMessage(const QString &title, const QString &message,
const QIcon& icon, MessageIcon, int)
{
+ Q_UNUSED(icon);
if (!m_sys)
return;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
- NSUserNotification *notification = [[NSUserNotification alloc] init];
- notification.title = [NSString stringWithUTF8String:title.toUtf8().data()];
- notification.informativeText = [NSString stringWithUTF8String:message.toUtf8().data()];
-
- [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
+ NSUserNotification *notification = [[NSUserNotification alloc] init];
+ notification.title = [NSString stringWithUTF8String:title.toUtf8().data()];
+ notification.informativeText = [NSString stringWithUTF8String:message.toUtf8().data()];
- return;
- }
-#endif
-
-#ifdef QT_MAC_SYSTEMTRAY_USE_GROWL
- // Make sure that we have Growl installed on the machine we are running on.
- QCFType<CFURLRef> cfurl;
- OSStatus status = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator,
- CFSTR("growlTicket"), kLSRolesAll, 0, &cfurl);
- if (status == kLSApplicationNotFoundErr)
- return;
- QCFType<CFBundleRef> bundle = CFBundleCreate(0, cfurl);
-
- if (CFStringCompare(CFBundleGetIdentifier(bundle), CFSTR("com.Growl.GrowlHelperApp"),
- kCFCompareCaseInsensitive | kCFCompareBackwards) != kCFCompareEqualTo)
- return;
- QPixmap notificationIconPixmap = icon.pixmap(32, 32);
- QTemporaryFile notificationIconFile;
- QString notificationType(QLatin1String("Notification")), notificationIcon, notificationApp(qt_mac_applicationName());
- if (notificationApp.isEmpty())
- notificationApp = QLatin1String("Application");
- if (!notificationIconPixmap.isNull() && notificationIconFile.open()) {
- QImageWriter writer(&notificationIconFile, "PNG");
- if (writer.write(notificationIconPixmap.toImage()))
- notificationIcon = QLatin1String("image from location \"file://") + notificationIconFile.fileName() + QLatin1String("\"");
- }
- const QString script(QLatin1String(
- "tell application \"System Events\"\n"
- "set isRunning to (count of (every process whose bundle identifier is \"com.Growl.GrowlHelperApp\")) > 0\n"
- "end tell\n"
- "if isRunning\n"
- "tell application id \"com.Growl.GrowlHelperApp\"\n"
- "-- Make a list of all the notification types (all)\n"
- "set the allNotificationsList to {\"") + notificationType + QLatin1String("\"}\n"
-
- "-- Make a list of the notifications (enabled)\n"
- "set the enabledNotificationsList to {\"") + notificationType + QLatin1String("\"}\n"
-
- "-- Register our script with growl.\n"
- "register as application \"") + notificationApp + QLatin1String("\" all notifications allNotificationsList default notifications enabledNotificationsList\n"
-
- "-- Send a Notification...\n") +
- QLatin1String("notify with name \"") + notificationType +
- QLatin1String("\" title \"") + title +
- QLatin1String("\" description \"") + message +
- QLatin1String("\" application name \"") + notificationApp +
- QLatin1String("\" ") + notificationIcon +
- QLatin1String("\nend tell\nend if"));
- qt_mac_execute_apple_script(script, 0);
-#else
- Q_UNUSED(icon);
- Q_UNUSED(title);
- Q_UNUSED(message);
-#endif
+ [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
}
QT_END_NAMESPACE
@@ -499,7 +429,6 @@ QT_END_NAMESPACE
emit systray->activated(QPlatformSystemTrayIcon::DoubleClick);
}
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification {
Q_UNUSED(center);
Q_UNUSED(notification);
@@ -511,7 +440,6 @@ QT_END_NAMESPACE
Q_UNUSED(notification);
emit systray->messageClicked();
}
-#endif
@end
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.h b/src/plugins/platforms/cocoa/qcocoatheme.h
index 282e527b0b..d47e620fbb 100644
--- a/src/plugins/platforms/cocoa/qcocoatheme.h
+++ b/src/plugins/platforms/cocoa/qcocoatheme.h
@@ -70,9 +70,7 @@ public:
const QPalette *palette(Palette type = SystemPalette) const Q_DECL_OVERRIDE;
const QFont *font(Font type = SystemFont) const Q_DECL_OVERRIDE;
QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const Q_DECL_OVERRIDE;
- QPixmap fileIconPixmap(const QFileInfo &fileInfo,
- const QSizeF &size,
- QPlatformTheme::IconOptions options = 0) const Q_DECL_OVERRIDE;
+ QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions options = 0) const override;
QVariant themeHint(ThemeHint hint) const Q_DECL_OVERRIDE;
QString standardButtonText(int button) const Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm
index 831f1cfcf4..3a3d634f5a 100644
--- a/src/plugins/platforms/cocoa/qcocoatheme.mm
+++ b/src/plugins/platforms/cocoa/qcocoatheme.mm
@@ -58,6 +58,7 @@
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/qpainter.h>
#include <QtPlatformSupport/private/qcoretextfontdatabase_p.h>
+#include <QtPlatformSupport/private/qabstractfileiconengine_p.h>
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformnativeinterface.h>
@@ -274,16 +275,41 @@ QPixmap QCocoaTheme::standardPixmap(StandardPixmap sp, const QSizeF &size) const
return QPlatformTheme::standardPixmap(sp, size);
}
-QPixmap QCocoaTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size,
- QPlatformTheme::IconOptions iconOptions) const
+class QCocoaFileIconEngine : public QAbstractFileIconEngine
{
- Q_UNUSED(iconOptions);
- QMacAutoReleasePool pool;
+public:
+ explicit QCocoaFileIconEngine(const QFileInfo &info,
+ QPlatformTheme::IconOptions opts) :
+ QAbstractFileIconEngine(info, opts) {}
+
+ static QList<QSize> availableIconSizes()
+ {
+ const qreal devicePixelRatio = qGuiApp->devicePixelRatio();
+ const int sizes[] = {
+ qRound(16 * devicePixelRatio), qRound(32 * devicePixelRatio),
+ qRound(64 * devicePixelRatio), qRound(128 * devicePixelRatio)
+ };
+ return QAbstractFileIconEngine::toSizeList(sizes, sizes + sizeof(sizes) / sizeof(sizes[0]));
+ }
+
+ QList<QSize> availableSizes(QIcon::Mode = QIcon::Normal, QIcon::State = QIcon::Off) const override
+ { return QCocoaFileIconEngine::availableIconSizes(); }
- NSImage *iconImage = [[NSWorkspace sharedWorkspace] iconForFile:QCFString::toNSString(fileInfo.canonicalFilePath())];
- if (!iconImage)
- return QPixmap();
- return qt_mac_toQPixmap(iconImage, size);
+protected:
+ QPixmap filePixmap(const QSize &size, QIcon::Mode, QIcon::State) override
+ {
+ QMacAutoReleasePool pool;
+
+ NSImage *iconImage = [[NSWorkspace sharedWorkspace] iconForFile:QCFString::toNSString(fileInfo().canonicalFilePath())];
+ if (!iconImage)
+ return QPixmap();
+ return qt_mac_toQPixmap(iconImage, size);
+ }
+};
+
+QIcon QCocoaTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions) const
+{
+ return QIcon(new QCocoaFileIconEngine(fileInfo, iconOptions));
}
QVariant QCocoaTheme::themeHint(ThemeHint hint) const
@@ -298,17 +324,12 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const
case TabFocusBehavior:
return QVariant([[NSApplication sharedApplication] isFullKeyboardAccessEnabled] ?
int(Qt::TabFocusAllControls) : int(Qt::TabFocusTextControls | Qt::TabFocusListControls));
- case IconPixmapSizes: {
- qreal devicePixelRatio = qGuiApp->devicePixelRatio();
- QList<int> sizes;
- sizes << 16 * devicePixelRatio
- << 32 * devicePixelRatio
- << 64 * devicePixelRatio
- << 128 * devicePixelRatio;
- return QVariant::fromValue(sizes);
- }
+ case IconPixmapSizes:
+ return QVariant::fromValue(QCocoaFileIconEngine::availableIconSizes());
case QPlatformTheme::PasswordMaskCharacter:
return QVariant(QChar(kBulletUnicode));
+ case QPlatformTheme::UiEffects:
+ return QVariant(int(HoverEffect));
default:
break;
}
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index d9e94735ac..b016004b23 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -219,6 +219,7 @@ public:
void windowDidResize();
void windowDidEndLiveResize();
bool windowShouldClose();
+ void windowWillClose();
bool windowIsPopupType(Qt::WindowType type = Qt::Widget) const;
void setSynchedWindowStateFromWindow();
@@ -275,6 +276,7 @@ protected:
void syncWindowState(Qt::WindowState newState);
void reinsertChildWindow(QCocoaWindow *child);
void removeChildWindow(QCocoaWindow *child);
+ bool isNativeWindowTypeInconsistent();
// private:
public: // for QNSView
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 91ce91004f..7fb695630b 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -78,6 +78,14 @@ static bool isMouseEvent(NSEvent *ev)
}
}
+static void qt_closePopups()
+{
+ while (QCocoaWindow *popup = QCocoaIntegration::instance()->popPopupWindow()) {
+ QWindowSystemInterface::handleCloseEvent(popup->window());
+ QWindowSystemInterface::flushWindowSystemEvents();
+ }
+}
+
@implementation QNSWindowHelper
@synthesize window = _window;
@@ -505,7 +513,7 @@ QRect QCocoaWindow::geometry() const
NSRect screenRect = [[m_contentView window] convertRectToScreen:NSMakeRect(windowPoint.x, windowPoint.y, 1, 1)];
NSPoint screenPoint = screenRect.origin;
QPoint position = qt_mac_flipPoint(screenPoint).toPoint();
- QSize size = qt_mac_toQRect([m_contentView bounds]).size();
+ QSize size = QRectF::fromCGRect([m_contentView bounds]).toRect().size();
return QRect(position, size);
}
@@ -652,7 +660,7 @@ void QCocoaWindow::setVisible(bool visible)
if (visible) {
// We need to recreate if the modality has changed as the style mask will need updating
- if (m_windowModality != window()->modality())
+ if (m_windowModality != window()->modality() || isNativeWindowTypeInconsistent())
recreateWindow(parent());
// Register popup windows. The Cocoa platform plugin will forward mouse events
@@ -1023,9 +1031,7 @@ void QCocoaWindow::raise()
}
static bool raiseProcess = qt_mac_resolveOption(true, "QT_MAC_SET_RAISE_PROCESS");
if (raiseProcess) {
- ProcessSerialNumber psn;
- GetCurrentProcess(&psn);
- SetFrontProcessWithOptions(&psn, kSetFrontProcessFrontWindowOnly);
+ [NSApp activateIgnoringOtherApps:YES];
}
}
}
@@ -1107,11 +1113,10 @@ void QCocoaWindow::propagateSizeHints()
// sizeIncrement is observed to take values of (-1, -1) and (0, 0) for windows that should be
// resizable and that have no specific size increment set. Cocoa expects (1.0, 1.0) in this case.
- const QSize sizeIncrement = windowSizeIncrement();
- if (!sizeIncrement.isEmpty())
- [m_nsWindow setResizeIncrements : qt_mac_toNSSize(sizeIncrement)];
- else
- [m_nsWindow setResizeIncrements : NSMakeSize(1.0, 1.0)];
+ QSize sizeIncrement = windowSizeIncrement();
+ if (sizeIncrement.isEmpty())
+ sizeIncrement = QSize(1, 1);
+ [m_nsWindow setResizeIncrements:sizeIncrement.toCGSize()];
QRect rect = geometry();
QSize baseSize = windowBaseSize();
@@ -1223,10 +1228,7 @@ void QCocoaWindow::setEmbeddedInForeignView(bool embedded)
void QCocoaWindow::windowWillMove()
{
// Close any open popups on window move
- while (QCocoaWindow *popup = QCocoaIntegration::instance()->popPopupWindow()) {
- QWindowSystemInterface::handleCloseEvent(popup->window());
- QWindowSystemInterface::flushWindowSystemEvents();
- }
+ qt_closePopups();
}
void QCocoaWindow::windowDidMove()
@@ -1270,6 +1272,13 @@ bool QCocoaWindow::windowShouldClose()
return accepted;
}
+void QCocoaWindow::windowWillClose()
+{
+ // Close any open popups on window closing.
+ if (window() && !windowIsPopupType(window()->type()))
+ qt_closePopups();
+}
+
void QCocoaWindow::setSynchedWindowStateFromWindow()
{
if (QWindow *w = window())
@@ -1532,6 +1541,17 @@ void QCocoaWindow::removeChildWindow(QCocoaWindow *child)
[m_nsWindow removeChildWindow:child->m_nsWindow];
}
+bool QCocoaWindow::isNativeWindowTypeInconsistent()
+{
+ if (!m_nsWindow)
+ return false;
+
+ const bool isPanel = [m_nsWindow isKindOfClass:[QNSPanel class]];
+ const bool usePanel = shouldUseNSPanel();
+
+ return isPanel != usePanel;
+}
+
void QCocoaWindow::removeMonitor()
{
if (!monitor)
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h
index 00d65ea7f8..02ae64a58e 100644
--- a/src/plugins/platforms/cocoa/qnsview.h
+++ b/src/plugins/platforms/cocoa/qnsview.h
@@ -85,7 +85,6 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
bool m_resendKeyEvent;
bool m_scrolling;
bool m_updatingDrag;
- bool m_exposedOnMoveToWindow;
NSEvent *m_currentlyInterpretedKeyEvent;
bool m_isMenuView;
QSet<quint32> m_acceptedKeyDowns;
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 0566541945..af324c07ff 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -39,8 +39,6 @@
#include <QtCore/qglobal.h>
-#include <dlfcn.h>
-
#include "qnsview.h"
#include "qcocoawindow.h"
#include "qcocoahelpers.h"
@@ -72,9 +70,6 @@ Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
static QTouchDevice *touchDevice = 0;
-// ### HACK Remove once 10.8 is unsupported
-static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
-
static bool _q_dontOverrideCtrlLMB = false;
@interface NSEvent (Qt_Compile_Leopard_DeviceDelta)
@@ -134,10 +129,6 @@ static bool _q_dontOverrideCtrlLMB = false;
+ (void)initialize
{
- NSString **notificationNameVar = (NSString **)dlsym(RTLD_NEXT, "NSWindowDidChangeOcclusionStateNotification");
- if (notificationNameVar)
- _q_NSWindowDidChangeOcclusionStateNotification = *notificationNameVar;
-
_q_dontOverrideCtrlLMB = qt_mac_resolveOption(false, "QT_MAC_DONT_OVERRIDE_CTRL_LMB");
}
@@ -291,18 +282,6 @@ static bool _q_dontOverrideCtrlLMB = false;
- (void)viewDidMoveToWindow
{
m_backingStore = Q_NULLPTR;
- m_isMenuView = [self.window.className isEqualToString:@"NSCarbonMenuWindow"];
- if (self.window) {
- // This is the case of QWidgetAction's generated QWidget inserted in an NSMenu.
- // 10.9 and newer get the NSWindowDidChangeOcclusionStateNotification
- if (!_q_NSWindowDidChangeOcclusionStateNotification && m_isMenuView) {
- m_exposedOnMoveToWindow = true;
- m_platformWindow->exposeWindow();
- }
- } else if (m_exposedOnMoveToWindow) {
- m_exposedOnMoveToWindow = false;
- m_platformWindow->obscureWindow();
- }
}
- (void)viewWillMoveToWindow:(NSWindow *)newWindow
@@ -343,9 +322,9 @@ static bool _q_dontOverrideCtrlLMB = false;
if (m_platformWindow->m_isNSWindowChild) {
return;
#if 0
- //geometry = qt_mac_toQRect([self frame]);
+ //geometry = QRectF::fromCGRect([self frame]).toRect();
qDebug() << "nsview updateGeometry" << m_platformWindow->window();
- QRect screenRect = qt_mac_toQRect([m_platformWindow->m_nsWindow convertRectToScreen:[self frame]]);
+ QRect screenRect = QRectF::fromCGRect([m_platformWindow->m_nsWindow convertRectToScreen:[self frame]]).toRect();
qDebug() << "screenRect" << screenRect;
screenRect.moveTop(qt_mac_flipYCoordinate(screenRect.y() + screenRect.height()));
@@ -360,10 +339,10 @@ static bool _q_dontOverrideCtrlLMB = false;
geometry = QRect(windowRect.origin.x, qt_mac_flipYCoordinate(windowRect.origin.y + rect.size.height), rect.size.width, rect.size.height);
} else if (m_platformWindow->m_contentViewIsToBeEmbedded) {
// embedded child window, use the frame rect ### merge with case below
- geometry = qt_mac_toQRect([self bounds]);
+ geometry = QRectF::fromCGRect([self bounds]).toRect();
} else {
// child window, use the frame rect
- geometry = qt_mac_toQRect([self frame]);
+ geometry = QRectF::fromCGRect([self frame]).toRect();
}
if (m_platformWindow->m_nsWindow && geometry == m_platformWindow->geometry())
@@ -432,7 +411,7 @@ static bool _q_dontOverrideCtrlLMB = false;
// set the active window to zero here, the new key window's
// NSWindowDidBecomeKeyNotification hander will change the active window
NSWindow *keyWindow = [NSApp keyWindow];
- if (!keyWindow) {
+ if (!keyWindow || keyWindow == windowNotification.object) {
// no new key window, go ahead and set the active window to zero
if (!m_platformWindow->windowIsPopupType() && !m_isMenuView)
QWindowSystemInterface::handleWindowActivated(0);
@@ -446,14 +425,7 @@ static bool _q_dontOverrideCtrlLMB = false;
m_platformWindow->obscureWindow();
} else if ([notificationName isEqualToString: @"NSWindowDidOrderOnScreenAndFinishAnimatingNotification"]) {
m_platformWindow->exposeWindow();
- } else if (_q_NSWindowDidChangeOcclusionStateNotification
- && [notificationName isEqualToString:_q_NSWindowDidChangeOcclusionStateNotification]) {
-#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9
-// ### HACK Remove the enum declaration, the warning disabling and the cast further down once 10.8 is unsupported
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_CLANG("-Wobjc-method-access")
- enum { NSWindowOcclusionStateVisible = 1UL << 1 };
-#endif
+ } else if ([notificationName isEqualToString:NSWindowDidChangeOcclusionStateNotification]) {
// Several unit tests expect paint and/or expose events for windows that are
// sometimes (unpredictably) occluded and some unit tests depend on QWindow::isExposed -
// don't send Expose/Obscure events when running under QTestLib.
@@ -466,9 +438,6 @@ QT_WARNING_DISABLE_CLANG("-Wobjc-method-access")
m_platformWindow->obscureWindow();
}
}
-#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9
-QT_WARNING_POP
-#endif
} else if (notificationName == NSWindowDidChangeScreenNotification) {
if (m_window) {
NSUInteger screenIndex = [[NSScreen screens] indexOfObject:self.window.screen];
@@ -526,7 +495,7 @@ QT_WARNING_POP
m_backingStore = backingStore;
m_backingStoreOffset = offset * m_backingStore->getBackingStoreDevicePixelRatio();
- foreach (QRect rect, region.rects())
+ for (const QRect &rect : region)
[self setNeedsDisplayInRect:NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height())];
}
@@ -587,7 +556,7 @@ QT_WARNING_POP
- (void) drawRect:(NSRect)dirtyRect
{
- qCDebug(lcQpaCocoaWindow) << "[QNSView drawRect:]" << m_window << qt_mac_toQRect(dirtyRect);
+ qCDebug(lcQpaCocoaWindow) << "[QNSView drawRect:]" << m_window << QRectF::fromCGRect(dirtyRect);
#ifndef QT_NO_OPENGL
if (m_glContext && m_shouldSetGLContextinDrawRect) {
@@ -1396,7 +1365,6 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
[event magnification], windowPoint, screenPoint);
}
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
- (void)smartMagnifyWithEvent:(NSEvent *)event
{
static bool zoomIn = true;
@@ -1409,7 +1377,6 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
zoomIn ? 1.0f : 0.0f, windowPoint, screenPoint);
zoomIn = !zoomIn;
}
-#endif
- (void)rotateWithEvent:(NSEvent *)event
{
@@ -1525,16 +1492,12 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
NSEventPhase phase = [theEvent phase];
Qt::ScrollPhase ph = Qt::ScrollUpdate;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
- if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
- // On 10.8 and above, MayBegin is likely to happen. We treat it the same as an actual begin.
- if (phase == NSEventPhaseMayBegin) {
- m_scrolling = true;
- ph = Qt::ScrollBegin;
- }
- }
-#endif
- if (phase == NSEventPhaseBegan) {
+
+ // MayBegin is likely to happen. We treat it the same as an actual begin.
+ if (phase == NSEventPhaseMayBegin) {
+ m_scrolling = true;
+ ph = Qt::ScrollBegin;
+ } else if (phase == NSEventPhaseBegan) {
// If MayBegin did not happen, Began is the actual beginning.
if (!m_scrolling)
ph = Qt::ScrollBegin;
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.h b/src/plugins/platforms/cocoa/qnswindowdelegate.h
index ac1e8d62eb..46e8d40efb 100644
--- a/src/plugins/platforms/cocoa/qnswindowdelegate.h
+++ b/src/plugins/platforms/cocoa/qnswindowdelegate.h
@@ -57,6 +57,7 @@
- (void)windowWillMove:(NSNotification *)notification;
- (BOOL)windowShouldClose:(NSNotification *)notification;
- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame;
+- (void)windowWillClose:(NSNotification *)notification;
@end
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
index faa53b06ef..b96a9491e8 100644
--- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm
+++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm
@@ -115,4 +115,11 @@
return YES;
}
+- (void)windowWillClose:(NSNotification *)notification
+{
+ Q_UNUSED(notification);
+ if (m_cocoaWindow)
+ m_cocoaWindow->windowWillClose();
+}
+
@end
diff --git a/src/plugins/platforms/cocoa/qpaintengine_mac.mm b/src/plugins/platforms/cocoa/qpaintengine_mac.mm
index 395c25c915..759c4d26a5 100644
--- a/src/plugins/platforms/cocoa/qpaintengine_mac.mm
+++ b/src/plugins/platforms/cocoa/qpaintengine_mac.mm
@@ -88,10 +88,7 @@ static void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransfor
if (rgn.isEmpty()) {
CGContextAddRect(hd, CGRectMake(0, 0, 0, 0));
} else {
- QVector<QRect> rects = rgn.rects();
- const int count = rects.size();
- for (int i = 0; i < count; i++) {
- const QRect &r = rects[i];
+ for (const QRect &r : rgn) {
CGRect mac_r = CGRectMake(r.x(), r.y(), r.width(), r.height());
CGContextAddRect(hd, mac_r);
}
diff --git a/src/plugins/platforms/cocoa/qt_mac_p.h b/src/plugins/platforms/cocoa/qt_mac_p.h
index 03eae1b2e7..902cf5c636 100644
--- a/src/plugins/platforms/cocoa/qt_mac_p.h
+++ b/src/plugins/platforms/cocoa/qt_mac_p.h
@@ -90,22 +90,6 @@ public:
}
};
-class Q_WIDGETS_EXPORT QMacWindowChangeEvent
-{
-private:
- static QList<QMacWindowChangeEvent*> *change_events;
-public:
- QMacWindowChangeEvent() {
- }
- virtual ~QMacWindowChangeEvent() {
- }
- static inline void exec(bool ) {
- }
-protected:
- virtual void windowChanged() = 0;
- virtual void flushWindowChanged() = 0;
-};
-
class QMacCGContext
{
CGContextRef context;
diff --git a/src/plugins/platforms/cocoa/qt_menu.nib/classes.nib b/src/plugins/platforms/cocoa/qt_menu.nib/classes.nib
deleted file mode 100644
index 78941153c2..0000000000
--- a/src/plugins/platforms/cocoa/qt_menu.nib/classes.nib
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>IBClasses</key>
- <array>
- <dict>
- <key>ACTIONS</key>
- <dict>
- <key>hide</key>
- <string>id</string>
- <key>hideOtherApplications</key>
- <string>id</string>
- <key>orderFrontStandardAboutPanel</key>
- <string>id</string>
- <key>qtDispatcherToQPAMenuItem</key>
- <string>id</string>
- <key>terminate</key>
- <string>id</string>
- <key>unhideAllApplications</key>
- <string>id</string>
- </dict>
- <key>CLASS</key>
- <string>QCocoaMenuLoader</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>OUTLETS</key>
- <dict>
- <key>aboutItem</key>
- <string>NSMenuItem</string>
- <key>aboutQtItem</key>
- <string>NSMenuItem</string>
- <key>appMenu</key>
- <string>NSMenu</string>
- <key>hideItem</key>
- <string>NSMenuItem</string>
- <key>preferencesItem</key>
- <string>NSMenuItem</string>
- <key>quitItem</key>
- <string>NSMenuItem</string>
- <key>theMenu</key>
- <string>NSMenu</string>
- </dict>
- <key>SUPERCLASS</key>
- <string>NSResponder</string>
- </dict>
- <dict>
- <key>CLASS</key>
- <string>FirstResponder</string>
- <key>LANGUAGE</key>
- <string>ObjC</string>
- <key>SUPERCLASS</key>
- <string>NSObject</string>
- </dict>
- </array>
- <key>IBVersion</key>
- <string>1</string>
-</dict>
-</plist>
diff --git a/src/plugins/platforms/cocoa/qt_menu.nib/info.nib b/src/plugins/platforms/cocoa/qt_menu.nib/info.nib
deleted file mode 100644
index 02e5cca562..0000000000
--- a/src/plugins/platforms/cocoa/qt_menu.nib/info.nib
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>IBFramework Version</key>
- <string>672</string>
- <key>IBOldestOS</key>
- <integer>5</integer>
- <key>IBOpenObjects</key>
- <array>
- <integer>57</integer>
- </array>
- <key>IBSystem Version</key>
- <string>9L31a</string>
- <key>targetFramework</key>
- <string>IBCocoaFramework</string>
-</dict>
-</plist>
diff --git a/src/plugins/platforms/cocoa/qt_menu.nib/keyedobjects.nib b/src/plugins/platforms/cocoa/qt_menu.nib/keyedobjects.nib
deleted file mode 100644
index 67207ca628..0000000000
--- a/src/plugins/platforms/cocoa/qt_menu.nib/keyedobjects.nib
+++ /dev/null
Binary files differ
diff --git a/src/plugins/platforms/direct2d/direct2d.pro b/src/plugins/platforms/direct2d/direct2d.pro
index 005a4da6db..f4c3b5cc3b 100644
--- a/src/plugins/platforms/direct2d/direct2d.pro
+++ b/src/plugins/platforms/direct2d/direct2d.pro
@@ -4,7 +4,7 @@ QT *= core-private
QT *= gui-private
QT *= platformsupport-private
-LIBS *= -ld2d1 -ld3d11 -ldwrite -lVersion -lgdi32
+LIBS += -ldwmapi -ld2d1 -ld3d11 -ldwrite -lVersion -lgdi32
include(../windows/windows.pri)
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.cpp
index 97eadb207b..38f2352934 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.cpp
@@ -95,7 +95,7 @@ void QWindowsDirect2DBackingStore::beginPaint(const QRegion &region)
painter.setCompositionMode(QPainter::CompositionMode_Source);
- foreach (const QRect &r, region.rects())
+ for (const QRect &r : region)
painter.fillRect(r, clear);
}
@@ -127,10 +127,14 @@ void QWindowsDirect2DBackingStore::resize(const QSize &size, const QRegion &regi
QPixmap *newPixmap = nativeWindow(window())->pixmap();
if (!old.isNull()) {
- foreach (const QRect &rect, region.rects()) {
+ for (const QRect &rect : region)
platformPixmap(newPixmap)->copy(old.handle(), rect);
- }
}
}
+QImage QWindowsDirect2DBackingStore::toImage() const
+{
+ return nativeWindow(window())->pixmap()->toImage();
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.h b/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.h
index 9d754866cc..670c4e9840 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.h
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dbackingstore.h
@@ -60,6 +60,8 @@ public:
QPaintDevice *paintDevice() Q_DECL_OVERRIDE;
void flush(QWindow *targetWindow, const QRegion &region, const QPoint &offset) Q_DECL_OVERRIDE;
void resize(const QSize &size, const QRegion &staticContents) Q_DECL_OVERRIDE;
+
+ QImage toImage() const override;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp
index 4e677166b2..c750b02078 100644
--- a/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp
+++ b/src/plugins/platforms/direct2d/qwindowsdirect2dwindow.cpp
@@ -122,7 +122,7 @@ void QWindowsDirect2DWindow::flush(QWindowsDirect2DBitmap *bitmap, const QRegion
QRegion clipped = region;
clipped &= QRect(QPoint(), size);
- foreach (const QRect &rect, clipped.rects()) {
+ for (const QRect &rect : clipped) {
QRectF rectF(rect);
dc->DrawBitmap(bitmap->bitmap(),
to_d2d_rect_f(rectF),
diff --git a/src/plugins/platforms/directfb/qdirectfbbackingstore.cpp b/src/plugins/platforms/directfb/qdirectfbbackingstore.cpp
index 0bcf93aa3d..8d5e1e50c4 100644
--- a/src/plugins/platforms/directfb/qdirectfbbackingstore.cpp
+++ b/src/plugins/platforms/directfb/qdirectfbbackingstore.cpp
@@ -70,9 +70,7 @@ void QDirectFbBackingStore::flush(QWindow *, const QRegion &region, const QPoint
{
m_pmdata->blittable()->unlock();
- QVector<QRect> rects = region.rects();
- for (int i = 0 ; i < rects.size(); i++) {
- const QRect rect = rects.at(i);
+ for (const QRect &rect : region) {
DFBRegion dfbReg(rect.x() + offset.x(),rect.y() + offset.y(),rect.right() + offset.x(),rect.bottom() + offset.y());
m_dfbSurface->Flip(m_dfbSurface.data(), &dfbReg, DFBSurfaceFlipFlags(DSFLIP_BLIT|DSFLIP_ONSYNC));
}
@@ -108,13 +106,15 @@ bool QDirectFbBackingStore::scroll(const QRegion &area, int dx, int dy)
if (area.rectCount() == 1) {
scrollSurface(m_dfbSurface.data(), area.boundingRect(), dx, dy);
} else {
- const QVector<QRect> rects = area.rects();
- const int n = rects.size();
- for (int i=0; i<n; ++i) {
- scrollSurface(m_dfbSurface.data(), rects.at(i), dx, dy);
- }
+ for (const QRect &rect : area)
+ scrollSurface(m_dfbSurface.data(), rect, dx, dy);
}
return true;
}
+QImage QDirectFbBackingStore::toImage() const
+{
+ return m_pixmap.data()->toImage();
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/directfb/qdirectfbbackingstore.h b/src/plugins/platforms/directfb/qdirectfbbackingstore.h
index 33ab1c111d..af1ce92e64 100644
--- a/src/plugins/platforms/directfb/qdirectfbbackingstore.h
+++ b/src/plugins/platforms/directfb/qdirectfbbackingstore.h
@@ -59,6 +59,8 @@ public:
void resize (const QSize &size, const QRegion &staticContents);
bool scroll(const QRegion &area, int dx, int dy);
+ QImage toImage() const override;
+
private:
void lockSurfaceToImage();
diff --git a/src/plugins/platforms/eglfs/api/api.pri b/src/plugins/platforms/eglfs/api/api.pri
new file mode 100644
index 0000000000..957dee554c
--- /dev/null
+++ b/src/plugins/platforms/eglfs/api/api.pri
@@ -0,0 +1,15 @@
+
+SOURCES += $$PWD/qeglfswindow.cpp \
+ $$PWD/qeglfsscreen.cpp \
+ $$PWD/qeglfscursor.cpp \
+ $$PWD/qeglfshooks.cpp \
+ $$PWD/qeglfsdeviceintegration.cpp
+
+HEADERS += $$PWD/qeglfswindow_p.h \
+ $$PWD/qeglfsscreen_p.h \
+ $$PWD/qeglfscursor_p.h \
+ $$PWD/qeglfshooks_p.h \
+ $$PWD/qeglfsdeviceintegration_p.h \
+ $$PWD/qeglfsglobal.h
+
+INCLUDEPATH += $$PWD
diff --git a/src/plugins/platforms/eglfs/qeglfscursor.cpp b/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
index 6c8c35b1dc..0040ecd59d 100644
--- a/src/plugins/platforms/eglfs/qeglfscursor.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfscursor.cpp
@@ -37,9 +37,9 @@
**
****************************************************************************/
-#include "qeglfscursor.h"
+#include "qeglfscursor_p.h"
#include "qeglfsintegration.h"
-#include "qeglfsscreen.h"
+#include "qeglfsscreen_p.h"
#include <qpa/qwindowsysteminterface.h>
#include <QtGui/QOpenGLContext>
@@ -59,12 +59,11 @@
QT_BEGIN_NAMESPACE
QEglFSCursor::QEglFSCursor(QPlatformScreen *screen)
- : m_visible(true),
- m_screen(static_cast<QEglFSScreen *>(screen)),
- m_program(0),
- m_textureEntry(0),
- m_deviceListener(0),
- m_updateRequested(false)
+ : m_visible(true),
+ m_screen(static_cast<QEglFSScreen *>(screen)),
+ m_activeScreen(nullptr),
+ m_deviceListener(0),
+ m_updateRequested(false)
{
QByteArray hideCursorVal = qgetenv("QT_QPA_EGLFS_HIDECURSOR");
if (!hideCursorVal.isEmpty())
@@ -72,6 +71,10 @@ QEglFSCursor::QEglFSCursor(QPlatformScreen *screen)
if (!m_visible)
return;
+ int rotation = qEnvironmentVariableIntValue("QT_QPA_EGLFS_ROTATION");
+ if (rotation)
+ m_rotationMatrix.rotate(rotation, 0, 0, 1);
+
// Try to load the cursor atlas. If this fails, m_visible is set to false and
// paintOnScreen() and setCurrentCursor() become no-ops.
initCursorAtlas();
@@ -112,15 +115,14 @@ void QEglFSCursorDeviceListener::onDeviceListChanged(QInputDeviceManager::Device
void QEglFSCursor::resetResources()
{
- if (QOpenGLContext::currentContext()) {
- delete m_program;
- glDeleteTextures(1, &m_cursor.customCursorTexture);
- glDeleteTextures(1, &m_cursorAtlas.texture);
+ if (QOpenGLContext *ctx = QOpenGLContext::currentContext()) {
+ GraphicsContextData &gfx(m_gfx[ctx]);
+ delete gfx.program;
+ glDeleteTextures(1, &gfx.customCursorTexture);
+ glDeleteTextures(1, &gfx.atlasTexture);
+ gfx = GraphicsContextData();
}
- m_program = 0;
- m_cursor.customCursorTexture = 0;
m_cursor.customCursorPending = !m_cursor.customCursorImage.isNull();
- m_cursorAtlas.texture = 0;
}
void QEglFSCursor::createShaderPrograms()
@@ -129,9 +131,10 @@ void QEglFSCursor::createShaderPrograms()
"attribute highp vec2 vertexCoordEntry;\n"
"attribute highp vec2 textureCoordEntry;\n"
"varying highp vec2 textureCoord;\n"
+ "uniform highp mat4 mat;\n"
"void main() {\n"
" textureCoord = textureCoordEntry;\n"
- " gl_Position = vec4(vertexCoordEntry, 1.0, 1.0);\n"
+ " gl_Position = mat * vec4(vertexCoordEntry, 1.0, 1.0);\n"
"}\n";
static const char *textureFragmentProgram =
@@ -141,14 +144,16 @@ void QEglFSCursor::createShaderPrograms()
" gl_FragColor = texture2D(texture, textureCoord).bgra;\n"
"}\n";
- m_program = new QOpenGLShaderProgram;
- m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, textureVertexProgram);
- m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, textureFragmentProgram);
- m_program->bindAttributeLocation("vertexCoordEntry", 0);
- m_program->bindAttributeLocation("textureCoordEntry", 1);
- m_program->link();
+ GraphicsContextData &gfx(m_gfx[QOpenGLContext::currentContext()]);
+ gfx.program = new QOpenGLShaderProgram;
+ gfx.program->addShaderFromSourceCode(QOpenGLShader::Vertex, textureVertexProgram);
+ gfx.program->addShaderFromSourceCode(QOpenGLShader::Fragment, textureFragmentProgram);
+ gfx.program->bindAttributeLocation("vertexCoordEntry", 0);
+ gfx.program->bindAttributeLocation("textureCoordEntry", 1);
+ gfx.program->link();
- m_textureEntry = m_program->uniformLocation("texture");
+ gfx.textureEntry = gfx.program->uniformLocation("texture");
+ gfx.matEntry = gfx.program->uniformLocation("mat");
}
void QEglFSCursor::createCursorTexture(uint *texture, const QImage &image)
@@ -208,7 +213,7 @@ void QEglFSCursor::changeCursor(QCursor *cursor, QWindow *window)
Q_UNUSED(window);
const QRect oldCursorRect = cursorRect();
if (setCurrentCursor(cursor))
- update(oldCursorRect | cursorRect());
+ update(oldCursorRect | cursorRect(), false);
}
bool QEglFSCursor::setCurrentCursor(QCursor *cursor)
@@ -232,16 +237,17 @@ bool QEglFSCursor::setCurrentCursor(QCursor *cursor)
hs * (m_cursor.shape / m_cursorAtlas.cursorsPerRow),
ws, hs);
m_cursor.hotSpot = m_cursorAtlas.hotSpots[m_cursor.shape];
- m_cursor.texture = m_cursorAtlas.texture;
+ m_cursor.useCustomCursor = false;
m_cursor.size = QSize(m_cursorAtlas.cursorWidth, m_cursorAtlas.cursorHeight);
} else {
QImage image = cursor->pixmap().toImage();
m_cursor.textureRect = QRectF(0, 0, 1, 1);
m_cursor.hotSpot = cursor->hotSpot();
- m_cursor.texture = 0; // will get updated in the next render()
+ m_cursor.useCustomCursor = false; // will get updated in the next render()
m_cursor.size = image.size();
m_cursor.customCursorImage = image;
m_cursor.customCursorPending = true;
+ m_cursor.customCursorKey = m_cursor.customCursorImage.cacheKey();
}
return true;
@@ -251,17 +257,20 @@ bool QEglFSCursor::setCurrentCursor(QCursor *cursor)
class CursorUpdateEvent : public QEvent
{
public:
- CursorUpdateEvent(const QPoint &pos, const QRegion &rgn)
+ CursorUpdateEvent(const QPoint &pos, const QRect &rect, bool allScreens)
: QEvent(QEvent::Type(QEvent::User + 1)),
m_pos(pos),
- m_region(rgn)
+ m_rect(rect),
+ m_allScreens(allScreens)
{ }
QPoint pos() const { return m_pos; }
- QRegion region() const { return m_region; }
+ QRegion rect() const { return m_rect; }
+ bool allScreens() const { return m_allScreens; }
private:
QPoint m_pos;
- QRegion m_region;
+ QRect m_rect;
+ bool m_allScreens;
};
bool QEglFSCursor::event(QEvent *e)
@@ -269,21 +278,30 @@ bool QEglFSCursor::event(QEvent *e)
if (e->type() == QEvent::User + 1) {
CursorUpdateEvent *ev = static_cast<CursorUpdateEvent *>(e);
m_updateRequested = false;
- QWindowSystemInterface::handleExposeEvent(m_screen->topLevelAt(ev->pos()), ev->region());
- QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
+ if (!ev->allScreens()) {
+ QWindow *w = m_screen->topLevelAt(ev->pos()); // works for the entire virtual desktop, no need to loop
+ if (w) {
+ QWindowSystemInterface::handleExposeEvent(w, ev->rect());
+ QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
+ }
+ } else {
+ for (QWindow *w : qGuiApp->topLevelWindows())
+ QWindowSystemInterface::handleExposeEvent(w, w->geometry());
+ QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
+ }
return true;
}
return QPlatformCursor::event(e);
}
-void QEglFSCursor::update(const QRegion &rgn)
+void QEglFSCursor::update(const QRect &rect, bool allScreens)
{
if (!m_updateRequested) {
// Must not flush the window system events directly from here since we are likely to
// be a called directly from QGuiApplication's processMouseEvents. Flushing events
// could cause reentering by dispatching more queued mouse events.
m_updateRequested = true;
- QCoreApplication::postEvent(this, new CursorUpdateEvent(m_cursor.pos, rgn));
+ QCoreApplication::postEvent(this, new CursorUpdateEvent(m_cursor.pos, rect, allScreens));
}
}
@@ -302,8 +320,9 @@ void QEglFSCursor::setPos(const QPoint &pos)
QGuiApplicationPrivate::inputDeviceManager()->setCursorPos(pos);
const QRect oldCursorRect = cursorRect();
m_cursor.pos = pos;
- update(oldCursorRect | cursorRect());
- m_screen->handleCursorMove(m_cursor.pos);
+ update(oldCursorRect | cursorRect(), false);
+ for (QPlatformScreen *screen : m_screen->virtualSiblings())
+ static_cast<QEglFSScreen *>(screen)->handleCursorMove(m_cursor.pos);
}
void QEglFSCursor::pointerEvent(const QMouseEvent &event)
@@ -312,8 +331,9 @@ void QEglFSCursor::pointerEvent(const QMouseEvent &event)
return;
const QRect oldCursorRect = cursorRect();
m_cursor.pos = event.screenPos().toPoint();
- update(oldCursorRect | cursorRect());
- m_screen->handleCursorMove(m_cursor.pos);
+ update(oldCursorRect | cursorRect(), false);
+ for (QPlatformScreen *screen : m_screen->virtualSiblings())
+ static_cast<QEglFSScreen *>(screen)->handleCursorMove(m_cursor.pos);
}
void QEglFSCursor::paintOnScreen()
@@ -321,15 +341,35 @@ void QEglFSCursor::paintOnScreen()
if (!m_visible)
return;
- const QRectF cr = cursorRect();
- const QRect screenRect(m_screen->geometry());
- const GLfloat x1 = 2 * (cr.left() / screenRect.width()) - 1;
- const GLfloat x2 = 2 * (cr.right() / screenRect.width()) - 1;
- const GLfloat y1 = 1 - (cr.top() / screenRect.height()) * 2;
- const GLfloat y2 = 1 - (cr.bottom() / screenRect.height()) * 2;
- QRectF r(QPointF(x1, y1), QPointF(x2, y2));
+ QRect cr = cursorRect(); // hotspot included
+
+ // Support virtual desktop too. Backends with multi-screen support (e.g. all
+ // variants of KMS/DRM) will enable this by default. In this case all
+ // screens are siblings of each other. When not enabled, the sibling list
+ // only contains m_screen itself.
+ for (QPlatformScreen *screen : m_screen->virtualSiblings()) {
+ if (screen->geometry().contains(cr.topLeft() + m_cursor.hotSpot)
+ && QOpenGLContext::currentContext()->screen() == screen->screen())
+ {
+ cr.translate(-screen->geometry().topLeft());
+ const QSize screenSize = screen->geometry().size();
+ const GLfloat x1 = 2 * (cr.left() / GLfloat(screenSize.width())) - 1;
+ const GLfloat x2 = 2 * (cr.right() / GLfloat(screenSize.width())) - 1;
+ const GLfloat y1 = 1 - (cr.top() / GLfloat(screenSize.height())) * 2;
+ const GLfloat y2 = 1 - (cr.bottom() / GLfloat(screenSize.height())) * 2;
+ QRectF r(QPointF(x1, y1), QPointF(x2, y2));
+
+ draw(r);
+
+ if (screen != m_activeScreen) {
+ m_activeScreen = screen;
+ // Do not want a leftover cursor on the screen the cursor just left.
+ update(cursorRect(), true);
+ }
- draw(r);
+ break;
+ }
+ }
}
// In order to prevent breaking code doing custom OpenGL rendering while
@@ -431,30 +471,33 @@ void QEglFSCursor::draw(const QRectF &r)
{
StateSaver stateSaver;
- if (!m_program) {
+ GraphicsContextData &gfx(m_gfx[QOpenGLContext::currentContext()]);
+ if (!gfx.program) {
// one time initialization
initializeOpenGLFunctions();
createShaderPrograms();
- if (!m_cursorAtlas.texture) {
- createCursorTexture(&m_cursorAtlas.texture, m_cursorAtlas.image);
+ if (!gfx.atlasTexture) {
+ createCursorTexture(&gfx.atlasTexture, m_cursorAtlas.image);
if (m_cursor.shape != Qt::BitmapCursor)
- m_cursor.texture = m_cursorAtlas.texture;
+ m_cursor.useCustomCursor = false;
}
}
- if (m_cursor.shape == Qt::BitmapCursor && m_cursor.customCursorPending) {
+ if (m_cursor.shape == Qt::BitmapCursor && (m_cursor.customCursorPending || m_cursor.customCursorKey != gfx.customCursorKey)) {
// upload the custom cursor
- createCursorTexture(&m_cursor.customCursorTexture, m_cursor.customCursorImage);
- m_cursor.texture = m_cursor.customCursorTexture;
+ createCursorTexture(&gfx.customCursorTexture, m_cursor.customCursorImage);
+ m_cursor.useCustomCursor = true;
m_cursor.customCursorPending = false;
+ gfx.customCursorKey = m_cursor.customCursorKey;
}
- Q_ASSERT(m_cursor.texture);
+ GLuint cursorTexture = !m_cursor.useCustomCursor ? gfx.atlasTexture : gfx.customCursorTexture;
+ Q_ASSERT(cursorTexture);
- m_program->bind();
+ gfx.program->bind();
const GLfloat x1 = r.left();
const GLfloat x2 = r.right();
@@ -479,19 +522,20 @@ void QEglFSCursor::draw(const QRectF &r)
};
glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, m_cursor.texture);
+ glBindTexture(GL_TEXTURE_2D, cursorTexture);
if (stateSaver.vaoHelper->isValid())
stateSaver.vaoHelper->glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
- m_program->enableAttributeArray(0);
- m_program->enableAttributeArray(1);
- m_program->setAttributeArray(0, cursorCoordinates, 2);
- m_program->setAttributeArray(1, textureCoordinates, 2);
+ gfx.program->enableAttributeArray(0);
+ gfx.program->enableAttributeArray(1);
+ gfx.program->setAttributeArray(0, cursorCoordinates, 2);
+ gfx.program->setAttributeArray(1, textureCoordinates, 2);
- m_program->setUniformValue(m_textureEntry, 0);
+ gfx.program->setUniformValue(gfx.textureEntry, 0);
+ gfx.program->setUniformValue(gfx.matEntry, m_rotationMatrix);
glDisable(GL_CULL_FACE);
glFrontFace(GL_CCW);
@@ -501,9 +545,9 @@ void QEglFSCursor::draw(const QRectF &r)
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- m_program->disableAttributeArray(0);
- m_program->disableAttributeArray(1);
- m_program->release();
+ gfx.program->disableAttributeArray(0);
+ gfx.program->disableAttributeArray(1);
+ gfx.program->release();
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfscursor.h b/src/plugins/platforms/eglfs/api/qeglfscursor_p.h
index bb30d53d6c..8ccbe4493c 100644
--- a/src/plugins/platforms/eglfs/qeglfscursor.h
+++ b/src/plugins/platforms/eglfs/api/qeglfscursor_p.h
@@ -54,6 +54,7 @@
#include "qeglfsglobal.h"
#include <qpa/qplatformcursor.h>
#include <qpa/qplatformscreen.h>
+#include <QtGui/QMatrix4x4>
#include <QtGui/QOpenGLFunctions>
#include <QtGui/private/qinputdevicemanager_p.h>
@@ -104,30 +105,29 @@ private:
bool setCurrentCursor(QCursor *cursor);
#endif
void draw(const QRectF &rect);
- void update(const QRegion &region);
+ void update(const QRect &rect, bool allScreens);
void createShaderPrograms();
void createCursorTexture(uint *texture, const QImage &image);
void initCursorAtlas();
// current cursor information
struct Cursor {
- Cursor() : texture(0), shape(Qt::BlankCursor), customCursorTexture(0), customCursorPending(false) { }
- uint texture; // a texture from 'image' or the atlas
+ Cursor() : shape(Qt::BlankCursor), customCursorPending(false), customCursorKey(0), useCustomCursor(false) { }
Qt::CursorShape shape;
QRectF textureRect; // normalized rect inside texture
QSize size; // size of the cursor
QPoint hotSpot;
QImage customCursorImage;
QPoint pos; // current cursor position
- uint customCursorTexture;
bool customCursorPending;
+ qint64 customCursorKey;
+ bool useCustomCursor;
} m_cursor;
// cursor atlas information
struct CursorAtlas {
- CursorAtlas() : cursorsPerRow(0), texture(0), cursorWidth(0), cursorHeight(0) { }
+ CursorAtlas() : cursorsPerRow(0), cursorWidth(0), cursorHeight(0) { }
int cursorsPerRow;
- uint texture;
int width, height; // width and height of the atlas
int cursorWidth, cursorHeight; // width and height of cursors inside the atlas
QList<QPoint> hotSpots;
@@ -136,10 +136,22 @@ private:
bool m_visible;
QEglFSScreen *m_screen;
- QOpenGLShaderProgram *m_program;
- int m_textureEntry;
+ QPlatformScreen *m_activeScreen;
QEglFSCursorDeviceListener *m_deviceListener;
bool m_updateRequested;
+ QMatrix4x4 m_rotationMatrix;
+
+ struct GraphicsContextData {
+ GraphicsContextData() : program(nullptr), textureEntry(0), matEntry(0),
+ customCursorTexture(0), atlasTexture(0), customCursorKey(0) { }
+ QOpenGLShaderProgram *program;
+ int textureEntry;
+ int matEntry;
+ uint customCursorTexture;
+ uint atlasTexture;
+ qint64 customCursorKey;
+ };
+ QHash<QOpenGLContext *, GraphicsContextData> m_gfx;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp
index fc41dc5643..6f65929913 100644
--- a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp
@@ -37,10 +37,13 @@
**
****************************************************************************/
-#include "qeglfsdeviceintegration.h"
+#include "qeglfsdeviceintegration_p.h"
#include "qeglfsintegration.h"
-#include "qeglfscursor.h"
-#include "qeglfswindow.h"
+#include "qeglfscursor_p.h"
+#include "qeglfswindow_p.h"
+#include "qeglfsscreen_p.h"
+#include "qeglfshooks_p.h"
+
#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <QGuiApplication>
#include <private/qguiapplication_p.h>
@@ -64,14 +67,15 @@ QT_BEGIN_NAMESPACE
Q_LOGGING_CATEGORY(qLcEglDevDebug, "qt.qpa.egldeviceintegration")
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QEGLDeviceIntegrationFactoryInterface_iid, QLatin1String("/egldeviceintegrations"), Qt::CaseInsensitive))
+ (QEglFSDeviceIntegrationFactoryInterface_iid, QLatin1String("/egldeviceintegrations"), Qt::CaseInsensitive))
#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
- (QEGLDeviceIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
+ (QEglFSDeviceIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
+
#endif // QT_NO_LIBRARY
-QStringList QEGLDeviceIntegrationFactory::keys(const QString &pluginPath)
+QStringList QEglFSDeviceIntegrationFactory::keys(const QString &pluginPath)
{
QStringList list;
#ifndef QT_NO_LIBRARY
@@ -95,19 +99,19 @@ QStringList QEGLDeviceIntegrationFactory::keys(const QString &pluginPath)
return list;
}
-QEGLDeviceIntegration *QEGLDeviceIntegrationFactory::create(const QString &key, const QString &pluginPath)
+QEglFSDeviceIntegration *QEglFSDeviceIntegrationFactory::create(const QString &key, const QString &pluginPath)
{
- QEGLDeviceIntegration *integration = Q_NULLPTR;
+ QEglFSDeviceIntegration *integration = Q_NULLPTR;
#ifndef QT_NO_LIBRARY
if (!pluginPath.isEmpty()) {
QCoreApplication::addLibraryPath(pluginPath);
- integration = qLoadPlugin<QEGLDeviceIntegration, QEGLDeviceIntegrationPlugin>(directLoader(), key);
+ integration = qLoadPlugin<QEglFSDeviceIntegration, QEglFSDeviceIntegrationPlugin>(directLoader(), key);
}
#else
Q_UNUSED(pluginPath);
#endif
if (!integration)
- integration = qLoadPlugin<QEGLDeviceIntegration, QEGLDeviceIntegrationPlugin>(loader(), key);
+ integration = qLoadPlugin<QEglFSDeviceIntegration, QEglFSDeviceIntegrationPlugin>(loader(), key);
if (integration)
qCDebug(qLcEglDevDebug) << "Using EGL device integration" << key;
else
@@ -118,7 +122,7 @@ QEGLDeviceIntegration *QEGLDeviceIntegrationFactory::create(const QString &key,
static int framebuffer = -1;
-QByteArray QEGLDeviceIntegration::fbDeviceName() const
+QByteArray QEglFSDeviceIntegration::fbDeviceName() const
{
#ifdef Q_OS_LINUX
QByteArray fbDev = qgetenv("QT_QPA_EGLFS_FB");
@@ -131,7 +135,7 @@ QByteArray QEGLDeviceIntegration::fbDeviceName() const
#endif
}
-int QEGLDeviceIntegration::framebufferIndex() const
+int QEglFSDeviceIntegration::framebufferIndex() const
{
int fbIndex = 0;
#ifndef QT_NO_REGULAREXPRESSION
@@ -143,7 +147,7 @@ int QEGLDeviceIntegration::framebufferIndex() const
return fbIndex;
}
-void QEGLDeviceIntegration::platformInit()
+void QEglFSDeviceIntegration::platformInit()
{
#ifdef Q_OS_LINUX
QByteArray fbDev = fbDeviceName();
@@ -161,7 +165,7 @@ void QEGLDeviceIntegration::platformInit()
#endif
}
-void QEGLDeviceIntegration::platformDestroy()
+void QEglFSDeviceIntegration::platformDestroy()
{
#ifdef Q_OS_LINUX
if (framebuffer != -1)
@@ -169,27 +173,27 @@ void QEGLDeviceIntegration::platformDestroy()
#endif
}
-EGLNativeDisplayType QEGLDeviceIntegration::platformDisplay() const
+EGLNativeDisplayType QEglFSDeviceIntegration::platformDisplay() const
{
return EGL_DEFAULT_DISPLAY;
}
-EGLDisplay QEGLDeviceIntegration::createDisplay(EGLNativeDisplayType nativeDisplay)
+EGLDisplay QEglFSDeviceIntegration::createDisplay(EGLNativeDisplayType nativeDisplay)
{
return eglGetDisplay(nativeDisplay);
}
-bool QEGLDeviceIntegration::usesDefaultScreen()
+bool QEglFSDeviceIntegration::usesDefaultScreen()
{
return true;
}
-void QEGLDeviceIntegration::screenInit()
+void QEglFSDeviceIntegration::screenInit()
{
// Nothing to do here. Called only when usesDefaultScreen is false.
}
-void QEGLDeviceIntegration::screenDestroy()
+void QEglFSDeviceIntegration::screenDestroy()
{
QGuiApplication *app = qGuiApp;
QEglFSIntegration *platformIntegration = static_cast<QEglFSIntegration *>(
@@ -198,17 +202,17 @@ void QEGLDeviceIntegration::screenDestroy()
platformIntegration->removeScreen(app->screens().last()->handle());
}
-QSizeF QEGLDeviceIntegration::physicalScreenSize() const
+QSizeF QEglFSDeviceIntegration::physicalScreenSize() const
{
return q_physicalScreenSizeFromFb(framebuffer, screenSize());
}
-QSize QEGLDeviceIntegration::screenSize() const
+QSize QEglFSDeviceIntegration::screenSize() const
{
return q_screenSizeFromFb(framebuffer);
}
-QDpi QEGLDeviceIntegration::logicalDpi() const
+QDpi QEglFSDeviceIntegration::logicalDpi() const
{
const QSizeF ps = physicalScreenSize();
const QSize s = screenSize();
@@ -220,42 +224,42 @@ QDpi QEGLDeviceIntegration::logicalDpi() const
return QDpi(100, 100);
}
-qreal QEGLDeviceIntegration::pixelDensity() const
+qreal QEglFSDeviceIntegration::pixelDensity() const
{
return qRound(logicalDpi().first / qreal(100));
}
-Qt::ScreenOrientation QEGLDeviceIntegration::nativeOrientation() const
+Qt::ScreenOrientation QEglFSDeviceIntegration::nativeOrientation() const
{
return Qt::PrimaryOrientation;
}
-Qt::ScreenOrientation QEGLDeviceIntegration::orientation() const
+Qt::ScreenOrientation QEglFSDeviceIntegration::orientation() const
{
return Qt::PrimaryOrientation;
}
-int QEGLDeviceIntegration::screenDepth() const
+int QEglFSDeviceIntegration::screenDepth() const
{
return q_screenDepthFromFb(framebuffer);
}
-QImage::Format QEGLDeviceIntegration::screenFormat() const
+QImage::Format QEglFSDeviceIntegration::screenFormat() const
{
return screenDepth() == 16 ? QImage::Format_RGB16 : QImage::Format_RGB32;
}
-qreal QEGLDeviceIntegration::refreshRate() const
+qreal QEglFSDeviceIntegration::refreshRate() const
{
return q_refreshRateFromFb(framebuffer);
}
-EGLint QEGLDeviceIntegration::surfaceType() const
+EGLint QEglFSDeviceIntegration::surfaceType() const
{
return EGL_WINDOW_BIT;
}
-QSurfaceFormat QEGLDeviceIntegration::surfaceFormatFor(const QSurfaceFormat &inputFormat) const
+QSurfaceFormat QEglFSDeviceIntegration::surfaceFormatFor(const QSurfaceFormat &inputFormat) const
{
QSurfaceFormat format = inputFormat;
@@ -269,17 +273,17 @@ QSurfaceFormat QEGLDeviceIntegration::surfaceFormatFor(const QSurfaceFormat &inp
return format;
}
-bool QEGLDeviceIntegration::filterConfig(EGLDisplay, EGLConfig) const
+bool QEglFSDeviceIntegration::filterConfig(EGLDisplay, EGLConfig) const
{
return true;
}
-QEglFSWindow *QEGLDeviceIntegration::createWindow(QWindow *window) const
+QEglFSWindow *QEglFSDeviceIntegration::createWindow(QWindow *window) const
{
return new QEglFSWindow(window);
}
-EGLNativeWindowType QEGLDeviceIntegration::createNativeWindow(QPlatformWindow *platformWindow,
+EGLNativeWindowType QEglFSDeviceIntegration::createNativeWindow(QPlatformWindow *platformWindow,
const QSize &size,
const QSurfaceFormat &format)
{
@@ -289,29 +293,29 @@ EGLNativeWindowType QEGLDeviceIntegration::createNativeWindow(QPlatformWindow *p
return 0;
}
-EGLNativeWindowType QEGLDeviceIntegration::createNativeOffscreenWindow(const QSurfaceFormat &format)
+EGLNativeWindowType QEglFSDeviceIntegration::createNativeOffscreenWindow(const QSurfaceFormat &format)
{
Q_UNUSED(format);
return 0;
}
-void QEGLDeviceIntegration::destroyNativeWindow(EGLNativeWindowType window)
+void QEglFSDeviceIntegration::destroyNativeWindow(EGLNativeWindowType window)
{
Q_UNUSED(window);
}
-bool QEGLDeviceIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+bool QEglFSDeviceIntegration::hasCapability(QPlatformIntegration::Capability cap) const
{
Q_UNUSED(cap);
return false;
}
-QPlatformCursor *QEGLDeviceIntegration::createCursor(QPlatformScreen *screen) const
+QPlatformCursor *QEglFSDeviceIntegration::createCursor(QPlatformScreen *screen) const
{
- return new QEglFSCursor(screen);
+ return new QEglFSCursor(static_cast<QEglFSScreen *>(screen));
}
-void QEGLDeviceIntegration::waitForVSync(QPlatformSurface *surface) const
+void QEglFSDeviceIntegration::waitForVSync(QPlatformSurface *surface) const
{
Q_UNUSED(surface);
@@ -325,24 +329,42 @@ void QEGLDeviceIntegration::waitForVSync(QPlatformSurface *surface) const
#endif
}
-void QEGLDeviceIntegration::presentBuffer(QPlatformSurface *surface)
+void QEglFSDeviceIntegration::presentBuffer(QPlatformSurface *surface)
{
Q_UNUSED(surface);
}
-bool QEGLDeviceIntegration::supportsPBuffers() const
+bool QEglFSDeviceIntegration::supportsPBuffers() const
{
return true;
}
-bool QEGLDeviceIntegration::supportsSurfacelessContexts() const
+bool QEglFSDeviceIntegration::supportsSurfacelessContexts() const
{
return true;
}
-void *QEGLDeviceIntegration::wlDisplay() const
+void *QEglFSDeviceIntegration::wlDisplay() const
{
return Q_NULLPTR;
}
+EGLConfig QEglFSDeviceIntegration::chooseConfig(EGLDisplay display, const QSurfaceFormat &format)
+{
+ class Chooser : public QEglConfigChooser {
+ public:
+ Chooser(EGLDisplay display)
+ : QEglConfigChooser(display) { }
+ bool filterConfig(EGLConfig config) const Q_DECL_OVERRIDE {
+ return qt_egl_device_integration()->filterConfig(display(), config)
+ && QEglConfigChooser::filterConfig(config);
+ }
+ };
+
+ Chooser chooser(display);
+ chooser.setSurfaceType(qt_egl_device_integration()->surfaceType());
+ chooser.setSurfaceFormat(format);
+ return chooser.chooseConfig();
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration_p.h
index f1a5bde331..819e4818ab 100644
--- a/src/plugins/platforms/eglfs/qeglfsdeviceintegration.h
+++ b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration_p.h
@@ -63,12 +63,12 @@ QT_BEGIN_NAMESPACE
class QPlatformSurface;
class QEglFSWindow;
-#define QEGLDeviceIntegrationFactoryInterface_iid "org.qt-project.qt.qpa.egl.QEGLDeviceIntegrationFactoryInterface.5.5"
+#define QEglFSDeviceIntegrationFactoryInterface_iid "org.qt-project.qt.qpa.egl.QEglFSDeviceIntegrationFactoryInterface.5.5"
-class Q_EGLFS_EXPORT QEGLDeviceIntegration
+class Q_EGLFS_EXPORT QEglFSDeviceIntegration
{
public:
- virtual ~QEGLDeviceIntegration() { }
+ virtual ~QEglFSDeviceIntegration() { }
virtual void platformInit();
virtual void platformDestroy();
@@ -105,25 +105,27 @@ public:
virtual bool supportsSurfacelessContexts() const;
virtual void *wlDisplay() const;
+
+ static EGLConfig chooseConfig(EGLDisplay display, const QSurfaceFormat &format);
};
-class Q_EGLFS_EXPORT QEGLDeviceIntegrationPlugin : public QObject
+class Q_EGLFS_EXPORT QEglFSDeviceIntegrationPlugin : public QObject
{
Q_OBJECT
public:
- virtual QEGLDeviceIntegration *create() = 0;
+ virtual QEglFSDeviceIntegration *create() = 0;
// the pattern expected by qLoadPlugin calls for a QString argument.
// we don't need it, so don't bother subclasses with it:
- QEGLDeviceIntegration *create(const QString &) { return create(); }
+ QEglFSDeviceIntegration *create(const QString &) { return create(); }
};
-class Q_EGLFS_EXPORT QEGLDeviceIntegrationFactory
+class Q_EGLFS_EXPORT QEglFSDeviceIntegrationFactory
{
public:
static QStringList keys(const QString &pluginPath = QString());
- static QEGLDeviceIntegration *create(const QString &name, const QString &platformPluginPath = QString());
+ static QEglFSDeviceIntegration *create(const QString &name, const QString &platformPluginPath = QString());
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsglobal.h b/src/plugins/platforms/eglfs/api/qeglfsglobal.h
index 309655e86c..655ab7eaef 100644
--- a/src/plugins/platforms/eglfs/qeglfsglobal.h
+++ b/src/plugins/platforms/eglfs/api/qeglfsglobal.h
@@ -40,7 +40,11 @@
#ifndef QEGLFSGLOBAL_H
#define QEGLFSGLOBAL_H
-#include <qglobal.h>
+#include <QtCore/qglobal.h>
+
+#include <QtPlatformSupport/private/qt_egl_p.h>
+
+QT_BEGIN_NAMESPACE
#ifdef QT_BUILD_EGL_DEVICE_LIB
#define Q_EGLFS_EXPORT Q_DECL_EXPORT
@@ -48,7 +52,6 @@
#define Q_EGLFS_EXPORT Q_DECL_IMPORT
#endif
-#include <QtPlatformSupport/private/qt_egl_p.h>
#undef Status
#undef None
#undef Bool
@@ -61,4 +64,6 @@
#undef Expose
#undef Unsorted
+QT_END_NAMESPACE
+
#endif
diff --git a/src/plugins/platforms/eglfs/qeglfshooks.cpp b/src/plugins/platforms/eglfs/api/qeglfshooks.cpp
index 87285428df..b67d8fab54 100644
--- a/src/plugins/platforms/eglfs/qeglfshooks.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfshooks.cpp
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include "qeglfshooks.h"
+#include "qeglfshooks_p.h"
#include <QLoggingCategory>
QT_BEGIN_NAMESPACE
@@ -46,7 +46,7 @@ Q_DECLARE_LOGGING_CATEGORY(qLcEglDevDebug)
#ifdef EGLFS_PLATFORM_HOOKS
-QEGLDeviceIntegration *qt_egl_device_integration()
+QEglFSDeviceIntegration *qt_egl_device_integration()
{
extern QEglFSHooks *platformHooks;
return platformHooks;
@@ -59,16 +59,16 @@ class DeviceIntegration
public:
DeviceIntegration();
~DeviceIntegration() { delete m_integration; }
- QEGLDeviceIntegration *integration() { return m_integration; }
+ QEglFSDeviceIntegration *integration() { return m_integration; }
private:
- QEGLDeviceIntegration *m_integration;
+ QEglFSDeviceIntegration *m_integration;
};
Q_GLOBAL_STATIC(DeviceIntegration, deviceIntegration)
DeviceIntegration::DeviceIntegration() : m_integration(0)
{
- QStringList pluginKeys = QEGLDeviceIntegrationFactory::keys();
+ QStringList pluginKeys = QEglFSDeviceIntegrationFactory::keys();
if (!pluginKeys.isEmpty()) {
// Some built-in logic: Prioritize either X11 or KMS/DRM.
if (qEnvironmentVariableIsSet("DISPLAY")) {
@@ -113,7 +113,7 @@ DeviceIntegration::DeviceIntegration() : m_integration(0)
while (!m_integration && !pluginKeys.isEmpty()) {
QString key = pluginKeys.takeFirst();
qCDebug(qLcEglDevDebug) << "Trying to load device EGL integration" << key;
- m_integration = QEGLDeviceIntegrationFactory::create(key);
+ m_integration = QEglFSDeviceIntegrationFactory::create(key);
}
}
}
@@ -122,11 +122,11 @@ DeviceIntegration::DeviceIntegration() : m_integration(0)
// Use a default, non-specialized device integration when no plugin is available.
// For some systems this is sufficient.
qCDebug(qLcEglDevDebug) << "Using base device integration";
- m_integration = new QEGLDeviceIntegration;
+ m_integration = new QEglFSDeviceIntegration;
}
}
-QEGLDeviceIntegration *qt_egl_device_integration()
+QEglFSDeviceIntegration *qt_egl_device_integration()
{
return deviceIntegration()->integration();
}
diff --git a/src/plugins/platforms/eglfs/api/qeglfshooks_p.h b/src/plugins/platforms/eglfs/api/qeglfshooks_p.h
new file mode 100644
index 0000000000..e379f7a76d
--- /dev/null
+++ b/src/plugins/platforms/eglfs/api/qeglfshooks_p.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QEGLFSHOOKS_H
+#define QEGLFSHOOKS_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qeglfsglobal.h"
+#include "qeglfsdeviceintegration_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QEglFSHooks : public QEglFSDeviceIntegration
+{
+};
+
+Q_EGLFS_EXPORT QEglFSDeviceIntegration *qt_egl_device_integration();
+
+QT_END_NAMESPACE
+
+#endif // QEGLFSHOOKS_H
diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp
index a1ab854db1..b0c32e5176 100644
--- a/src/plugins/platforms/eglfs/qeglfsscreen.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfsscreen.cpp
@@ -43,9 +43,9 @@
#include <qpa/qplatformcursor.h>
#include <QtPlatformSupport/private/qopenglcompositor_p.h>
-#include "qeglfsscreen.h"
-#include "qeglfswindow.h"
-#include "qeglfshooks.h"
+#include "qeglfsscreen_p.h"
+#include "qeglfswindow_p.h"
+#include "qeglfshooks_p.h"
QT_BEGIN_NAMESPACE
@@ -65,6 +65,31 @@ QEglFSScreen::~QEglFSScreen()
QRect QEglFSScreen::geometry() const
{
+ QRect r = rawGeometry();
+
+ static int rotation = qEnvironmentVariableIntValue("QT_QPA_EGLFS_ROTATION");
+ switch (rotation) {
+ case 0:
+ case 180:
+ case -180:
+ break;
+ case 90:
+ case -90: {
+ int h = r.height();
+ r.setHeight(r.width());
+ r.setWidth(h);
+ break;
+ }
+ default:
+ qWarning("Invalid rotation %d specified in QT_QPA_EGLFS_ROTATION", rotation);
+ break;
+ }
+
+ return r;
+}
+
+QRect QEglFSScreen::rawGeometry() const
+{
return QRect(QPoint(0, 0), qt_egl_device_integration()->screenSize());
}
diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.h b/src/plugins/platforms/eglfs/api/qeglfsscreen_p.h
index 57d68ca572..daba9fc591 100644
--- a/src/plugins/platforms/eglfs/qeglfsscreen.h
+++ b/src/plugins/platforms/eglfs/api/qeglfsscreen_p.h
@@ -40,9 +40,22 @@
#ifndef QEGLFSSCREEN_H
#define QEGLFSSCREEN_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include "qeglfsglobal.h"
#include <QtCore/QPointer>
+#include <qpa/qplatformscreen.h>
+
QT_BEGIN_NAMESPACE
class QEglFSWindow;
@@ -55,6 +68,7 @@ public:
~QEglFSScreen();
QRect geometry() const Q_DECL_OVERRIDE;
+ virtual QRect rawGeometry() const;
int depth() const Q_DECL_OVERRIDE;
QImage::Format format() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp
index 556d3942cd..5ce88e6bd8 100644
--- a/src/plugins/platforms/eglfs/qeglfswindow.cpp
+++ b/src/plugins/platforms/eglfs/api/qeglfswindow.cpp
@@ -46,9 +46,10 @@
#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <QtPlatformSupport/private/qopenglcompositorbackingstore_p.h>
-#include "qeglfswindow.h"
-#include "qeglfscursor.h"
-#include "qeglfshooks.h"
+#include "qeglfswindow_p.h"
+#include "qeglfscursor_p.h"
+#include "qeglfshooks_p.h"
+#include "qeglfsdeviceintegration_p.h"
QT_BEGIN_NAMESPACE
@@ -141,7 +142,8 @@ void QEglFSWindow::create()
context->setScreen(window()->screen());
if (Q_UNLIKELY(!context->create()))
qFatal("EGLFS: Failed to create compositing context");
- compositor->setTarget(context, window());
+ compositor->setTarget(context, window(), screen->rawGeometry());
+ compositor->setRotation(qEnvironmentVariableIntValue("QT_QPA_EGLFS_ROTATION"));
// If there is a "root" window into which raster and QOpenGLWidget content is
// composited, all other contexts must share with its context.
if (!qt_gl_global_share_context()) {
@@ -186,9 +188,10 @@ void QEglFSWindow::resetSurface()
EGLDisplay display = screen()->display();
QSurfaceFormat platformFormat = qt_egl_device_integration()->surfaceFormatFor(window()->requestedFormat());
- m_config = QEglFSIntegration::chooseConfig(display, platformFormat);
+ m_config = QEglFSDeviceIntegration::chooseConfig(display, platformFormat);
m_format = q_glFormatFromConfig(display, m_config, platformFormat);
- m_window = qt_egl_device_integration()->createNativeWindow(this, screen()->geometry().size(), m_format);
+ const QSize surfaceSize = screen()->rawGeometry().size();
+ m_window = qt_egl_device_integration()->createNativeWindow(this, surfaceSize, m_format);
m_surface = eglCreateWindowSurface(display, m_config, m_window, NULL);
}
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.h b/src/plugins/platforms/eglfs/api/qeglfswindow_p.h
index d607c8bd62..aea4ed4806 100644
--- a/src/plugins/platforms/eglfs/qeglfswindow.h
+++ b/src/plugins/platforms/eglfs/api/qeglfswindow_p.h
@@ -40,9 +40,20 @@
#ifndef QEGLFSWINDOW_H
#define QEGLFSWINDOW_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include "qeglfsglobal.h"
#include "qeglfsintegration.h"
-#include "qeglfsscreen.h"
+#include "qeglfsscreen_p.h"
#include <qpa/qplatformwindow.h>
#include <QtPlatformSupport/private/qopenglcompositor_p.h>
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/eglfs_brcm.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/eglfs_brcm.pro
index 2b710ac24c..d65e136a96 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/eglfs_brcm.pro
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/eglfs_brcm.pro
@@ -1,6 +1,6 @@
TARGET = qeglfs-brcm-integration
-QT += core-private gui-private platformsupport-private eglfs_device_lib-private
+QT += core-private gui-private platformsupport-private eglfsdeviceintegration-private
INCLUDEPATH += $$PWD/../..
CONFIG += egl
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmintegration.h
index 8f78b51190..5af628dedd 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmintegration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmintegration.h
@@ -40,11 +40,11 @@
#ifndef QEGLFSBRCMINTEGRATION_H
#define QEGLFSBRCMINTEGRATION_H
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
QT_BEGIN_NAMESPACE
-class QEglFSBrcmIntegration : public QEGLDeviceIntegration
+class QEglFSBrcmIntegration : public QEglFSDeviceIntegration
{
public:
void platformInit() Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmmain.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmmain.cpp
index 0bd54ba239..80d7631931 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmmain.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_brcm/qeglfsbrcmmain.cpp
@@ -37,18 +37,18 @@
**
****************************************************************************/
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
#include "qeglfsbrcmintegration.h"
QT_BEGIN_NAMESPACE
-class QEglFSBrcmIntegrationPlugin : public QEGLDeviceIntegrationPlugin
+class QEglFSBrcmIntegrationPlugin : public QEglFSDeviceIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID QEGLDeviceIntegrationFactoryInterface_iid FILE "eglfs_brcm.json")
+ Q_PLUGIN_METADATA(IID QEglFSDeviceIntegrationFactoryInterface_iid FILE "eglfs_brcm.json")
public:
- QEGLDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSBrcmIntegration; }
+ QEglFSDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSBrcmIntegration; }
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro
index b1791240ab..6670a4c0bc 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/eglfs_kms.pro
@@ -4,7 +4,7 @@ PLUGIN_TYPE = egldeviceintegrations
PLUGIN_CLASS_NAME = QEglFSKmsGbmIntegrationPlugin
load(qt_plugin)
-QT += core-private gui-private platformsupport-private eglfs_device_lib-private eglfs_kms_support-private
+QT += core-private gui-private platformsupport-private eglfsdeviceintegration-private eglfs_kms_support-private
INCLUDEPATH += $$PWD/../.. $$PWD/../eglfs_kms_support
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp
index 278752bddf..99f6cfb0ca 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp
@@ -142,10 +142,10 @@ void QEglFSKmsGbmDevice::handleDrmEvent()
drmHandleEvent(fd(), &drmEvent);
}
-QEglFSKmsScreen *QEglFSKmsGbmDevice::createScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, QEglFSKmsOutput output, QPoint position)
+QEglFSKmsScreen *QEglFSKmsGbmDevice::createScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, QEglFSKmsOutput output)
{
static bool firstScreen = true;
- QEglFSKmsGbmScreen *screen = new QEglFSKmsGbmScreen(integration, device, output, position);
+ QEglFSKmsGbmScreen *screen = new QEglFSKmsGbmScreen(integration, device, output);
if (firstScreen && integration->hwCursor()) {
m_globalCursor = new QEglFSKmsGbmCursor(screen);
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h
index 6a45f9ffa0..7c0af84422 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.h
@@ -68,8 +68,7 @@ public:
virtual QEglFSKmsScreen *createScreen(QEglFSKmsIntegration *integration,
QEglFSKmsDevice *device,
- QEglFSKmsOutput output,
- QPoint position) Q_DECL_OVERRIDE;
+ QEglFSKmsOutput output) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(QEglFSKmsGbmDevice)
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp
index 1c0a8e1b5f..a5ab73cca4 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmintegration.cpp
@@ -43,7 +43,7 @@
#include "qeglfskmsgbmdevice.h"
#include "qeglfskmsgbmscreen.h"
#include "qeglfskmsgbmcursor.h"
-#include "qeglfscursor.h"
+#include "private/qeglfscursor_p.h"
#include <QtPlatformSupport/private/qdevicediscovery_p.h>
#include <QtCore/QLoggingCategory>
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmmain.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmmain.cpp
index 8e8779ca10..f34e4859c6 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmmain.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmmain.cpp
@@ -38,18 +38,18 @@
**
****************************************************************************/
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
#include "qeglfskmsgbmintegration.h"
QT_BEGIN_NAMESPACE
-class QEglFSKmsGbmIntegrationPlugin : public QEGLDeviceIntegrationPlugin
+class QEglFSKmsGbmIntegrationPlugin : public QEglFSDeviceIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID QEGLDeviceIntegrationFactoryInterface_iid FILE "eglfs_kms.json")
+ Q_PLUGIN_METADATA(IID QEglFSDeviceIntegrationFactoryInterface_iid FILE "eglfs_kms.json")
public:
- QEGLDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSKmsGbmIntegration; }
+ QEglFSDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSKmsGbmIntegration; }
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp
index 7a17b60a5e..dde386fc57 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.cpp
@@ -93,10 +93,9 @@ QEglFSKmsGbmScreen::FrameBuffer *QEglFSKmsGbmScreen::framebufferForBufferObject(
}
QEglFSKmsGbmScreen::QEglFSKmsGbmScreen(QEglFSKmsIntegration *integration,
- QEglFSKmsDevice *device,
- QEglFSKmsOutput output,
- QPoint position)
- : QEglFSKmsScreen(integration, device, output, position)
+ QEglFSKmsDevice *device,
+ QEglFSKmsOutput output)
+ : QEglFSKmsScreen(integration, device, output)
, m_gbm_surface(Q_NULLPTR)
, m_gbm_bo_current(Q_NULLPTR)
, m_gbm_bo_next(Q_NULLPTR)
@@ -130,8 +129,8 @@ gbm_surface *QEglFSKmsGbmScreen::createSurface()
if (!m_gbm_surface) {
qCDebug(qLcEglfsKmsDebug) << "Creating window for screen" << name();
m_gbm_surface = gbm_surface_create(static_cast<QEglFSKmsGbmDevice *>(device())->gbmDevice(),
- geometry().width(),
- geometry().height(),
+ rawGeometry().width(),
+ rawGeometry().height(),
GBM_FORMAT_XRGB8888,
GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
}
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h
index 3381bbfdbb..d7ad348291 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmscreen.h
@@ -55,9 +55,8 @@ class QEglFSKmsGbmScreen : public QEglFSKmsScreen
{
public:
QEglFSKmsGbmScreen(QEglFSKmsIntegration *integration,
- QEglFSKmsDevice *device,
- QEglFSKmsOutput output,
- QPoint position);
+ QEglFSKmsDevice *device,
+ QEglFSKmsOutput output);
~QEglFSKmsGbmScreen();
QPlatformCursor *cursor() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro
index e2263f6cbf..f613d68ecb 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/eglfs_kms_egldevice.pro
@@ -1,6 +1,6 @@
TARGET = qeglfs-kms-egldevice-integration
-QT += core-private gui-private platformsupport-private eglfs_device_lib-private eglfs_kms_support-private
+QT += core-private gui-private platformsupport-private eglfsdeviceintegration-private eglfs_kms_support-private
INCLUDEPATH += $$PWD/../.. $$PWD/../eglfs_kms_support
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp
index 743f714cf0..d30963ff96 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.cpp
@@ -40,11 +40,15 @@
#include "qeglfskmsegldevice.h"
#include "qeglfskmsegldevicescreen.h"
#include "qeglfskmsegldeviceintegration.h"
+#include "private/qeglfscursor_p.h"
#include <QtCore/private/qcore_unix_p.h>
+QT_BEGIN_NAMESPACE
+
QEglFSKmsEglDevice::QEglFSKmsEglDevice(QEglFSKmsIntegration *integration, const QString &path)
- : QEglFSKmsDevice(integration, path)
+ : QEglFSKmsDevice(integration, path),
+ m_globalCursor(nullptr)
{
}
@@ -52,6 +56,8 @@ bool QEglFSKmsEglDevice::open()
{
Q_ASSERT(fd() == -1);
+ qCDebug(qLcEglfsKmsDebug, "Opening DRM device %s", qPrintable(devicePath()));
+
int fd = drmOpen(devicePath().toLocal8Bit().constData(), Q_NULLPTR);
if (Q_UNLIKELY(fd < 0))
qFatal("Could not open DRM device");
@@ -63,6 +69,8 @@ bool QEglFSKmsEglDevice::open()
void QEglFSKmsEglDevice::close()
{
+ qCDebug(qLcEglfsKmsDebug, "Closing DRM device");
+
if (qt_safe_close(fd()) == -1)
qErrnoWarning("Could not close DRM device");
@@ -74,7 +82,26 @@ EGLNativeDisplayType QEglFSKmsEglDevice::nativeDisplay() const
return static_cast<QEglFSKmsEglDeviceIntegration *>(m_integration)->eglDevice();
}
-QEglFSKmsScreen *QEglFSKmsEglDevice::createScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, QEglFSKmsOutput output, QPoint position)
+QEglFSKmsScreen *QEglFSKmsEglDevice::createScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device,
+ QEglFSKmsOutput output)
{
- return new QEglFSKmsEglDeviceScreen(integration, device, output, position);
+ QEglFSKmsScreen *screen = new QEglFSKmsEglDeviceScreen(integration, device, output);
+
+ if (!m_globalCursor && !integration->separateScreens()) {
+ qCDebug(qLcEglfsKmsDebug, "Creating new global mouse cursor");
+ m_globalCursor = new QEglFSCursor(screen);
+ }
+
+ return screen;
}
+
+void QEglFSKmsEglDevice::destroyGlobalCursor()
+{
+ if (m_globalCursor) {
+ qCDebug(qLcEglfsKmsDebug, "Destroying global mouse cursor");
+ delete m_globalCursor;
+ m_globalCursor = nullptr;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h
index b1c98f3fe6..8c8f79f70c 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevice.h
@@ -42,6 +42,10 @@
#include <qeglfskmsdevice.h>
+QT_BEGIN_NAMESPACE
+
+class QPlatformCursor;
+
class QEglFSKmsEglDevice: public QEglFSKmsDevice
{
public:
@@ -54,8 +58,15 @@ public:
virtual QEglFSKmsScreen *createScreen(QEglFSKmsIntegration *integration,
QEglFSKmsDevice *device,
- QEglFSKmsOutput output,
- QPoint position) Q_DECL_OVERRIDE;
+ QEglFSKmsOutput output) Q_DECL_OVERRIDE;
+
+ QPlatformCursor *globalCursor() { return m_globalCursor; }
+ void destroyGlobalCursor();
+
+private:
+ QPlatformCursor *m_globalCursor;
};
+QT_END_NAMESPACE
+
#endif // QEGLFSKMSEGLDEVICE_H
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp
index 838569d5c6..ddb2499751 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.cpp
@@ -40,7 +40,8 @@
#include "qeglfskmsegldeviceintegration.h"
#include <QtPlatformSupport/private/qeglconvenience_p.h>
-#include "qeglfswindow.h"
+#include "private/qeglfswindow_p.h"
+#include "private/qeglfscursor_p.h"
#include "qeglfskmsegldevice.h"
#include "qeglfskmsscreen.h"
#include <QLoggingCategory>
@@ -189,12 +190,12 @@ void QEglJetsonTK1Window::resetSurface()
if (!m_integration->m_funcs->stream_consumer_output(display, m_egl_stream, layer))
qWarning("resetSurface: Unable to connect stream");
- m_config = QEglFSIntegration::chooseConfig(display, m_integration->surfaceFormatFor(window()->requestedFormat()));
+ m_config = QEglFSDeviceIntegration::chooseConfig(display, m_integration->surfaceFormatFor(window()->requestedFormat()));
m_format = q_glFormatFromConfig(display, m_config);
qCDebug(qLcEglfsKmsDebug) << "Stream producer format is" << m_format;
- const int w = cur_screen->geometry().width();
- const int h = cur_screen->geometry().height();
+ const int w = cur_screen->rawGeometry().width();
+ const int h = cur_screen->rawGeometry().height();
qCDebug(qLcEglfsKmsDebug, "Creating stream producer surface of size %dx%d", w, h);
const EGLint stream_producer_attribs[] = {
@@ -222,11 +223,6 @@ QEglFSWindow *QEglFSKmsEglDeviceIntegration::createWindow(QWindow *window) const
return eglWindow;
}
-bool QEglFSKmsEglDeviceIntegration::separateScreens() const
-{
- return true;
-}
-
QEglFSKmsDevice *QEglFSKmsEglDeviceIntegration::createDevice(const QString &devicePath)
{
Q_UNUSED(devicePath)
@@ -263,4 +259,9 @@ bool QEglFSKmsEglDeviceIntegration::query_egl_device()
return true;
}
+QPlatformCursor *QEglFSKmsEglDeviceIntegration::createCursor(QPlatformScreen *screen) const
+{
+ return separateScreens() ? new QEglFSCursor(screen) : nullptr;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h
index f04c42267a..375c388548 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldeviceintegration.h
@@ -61,12 +61,11 @@ public:
bool supportsPBuffers() const Q_DECL_OVERRIDE;
QEglFSWindow *createWindow(QWindow *window) const Q_DECL_OVERRIDE;
- virtual bool separateScreens() const Q_DECL_OVERRIDE;
-
EGLDeviceEXT eglDevice() const { return m_egl_device; }
protected:
QEglFSKmsDevice *createDevice(const QString &devicePath) Q_DECL_OVERRIDE;
+ QPlatformCursor *createCursor(QPlatformScreen *screen) const Q_DECL_OVERRIDE;
private:
bool setup_kms();
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicemain.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicemain.cpp
index 63571f796f..42fec073f1 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicemain.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicemain.cpp
@@ -41,13 +41,13 @@
QT_BEGIN_NAMESPACE
-class QEglFSKmsEglDeviceIntegrationPlugin : public QEGLDeviceIntegrationPlugin
+class QEglFSKmsEglDeviceIntegrationPlugin : public QEglFSDeviceIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID QEGLDeviceIntegrationFactoryInterface_iid FILE "eglfs_kms_egldevice.json")
+ Q_PLUGIN_METADATA(IID QEglFSDeviceIntegrationFactoryInterface_iid FILE "eglfs_kms_egldevice.json")
public:
- QEGLDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSKmsEglDeviceIntegration; }
+ QEglFSDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSKmsEglDeviceIntegration; }
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp
index da1b577801..55d5941e5f 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.cpp
@@ -39,10 +39,30 @@
#include "qeglfskmsegldevicescreen.h"
#include "qeglfskmsegldevice.h"
+#include <QGuiApplication>
-QEglFSKmsEglDeviceScreen::QEglFSKmsEglDeviceScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, QEglFSKmsOutput output, QPoint position)
- : QEglFSKmsScreen(integration, device, output, position)
+QT_BEGIN_NAMESPACE
+
+QEglFSKmsEglDeviceScreen::QEglFSKmsEglDeviceScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, QEglFSKmsOutput output)
+ : QEglFSKmsScreen(integration, device, output)
+{
+}
+
+QEglFSKmsEglDeviceScreen::~QEglFSKmsEglDeviceScreen()
{
+ const int remainingScreenCount = qGuiApp->screens().count();
+ qCDebug(qLcEglfsKmsDebug, "Screen dtor. Remaining screens: %d", remainingScreenCount);
+ if (!remainingScreenCount && !m_integration->separateScreens())
+ static_cast<QEglFSKmsEglDevice *>(device())->destroyGlobalCursor();
+}
+
+QPlatformCursor *QEglFSKmsEglDeviceScreen::cursor() const
+{
+ // The base class creates a cursor via integration->createCursor()
+ // in its ctor. With separateScreens just use that. Otherwise
+ // there's a virtual desktop and the device has a global cursor
+ // and the base class has no dedicated cursor at all.
+ return m_integration->separateScreens() ? QEglFSScreen::cursor() : static_cast<QEglFSKmsEglDevice *>(device())->globalCursor();
}
void QEglFSKmsEglDeviceScreen::waitForFlip()
@@ -76,3 +96,5 @@ void QEglFSKmsEglDeviceScreen::waitForFlip()
}
}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h
index 0cd46e9f9d..c57f52c6b7 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_egldevice/qeglfskmsegldevicescreen.h
@@ -42,15 +42,21 @@
#include <qeglfskmsscreen.h>
+QT_BEGIN_NAMESPACE
+
class QEglFSKmsEglDeviceScreen : public QEglFSKmsScreen
{
public:
QEglFSKmsEglDeviceScreen(QEglFSKmsIntegration *integration,
QEglFSKmsDevice *device,
- QEglFSKmsOutput output,
- QPoint position);
+ QEglFSKmsOutput output);
+ ~QEglFSKmsEglDeviceScreen();
+
+ QPlatformCursor *cursor() const Q_DECL_OVERRIDE;
void waitForFlip() Q_DECL_OVERRIDE;
};
+QT_END_NAMESPACE
+
#endif // QEGLFSKMSEGLDEVICESCREEN_H
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro
index 32f15f33fb..cc77810793 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/eglfs_kms_support.pro
@@ -2,7 +2,7 @@ TARGET = QtEglFsKmsSupport
CONFIG += no_module_headers internal_module
load(qt_module)
-QT += core-private gui-private platformsupport-private eglfs_device_lib-private
+QT += core-private gui-private platformsupport-private eglfsdeviceintegration-private
INCLUDEPATH += $$PWD/../..
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp
index f4ffee569d..5944e8d51f 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.cpp
@@ -159,7 +159,7 @@ static bool parseModeline(const QByteArray &text, drmModeModeInfoPtr mode)
return true;
}
-QEglFSKmsScreen *QEglFSKmsDevice::screenForConnector(drmModeResPtr resources, drmModeConnectorPtr connector, QPoint pos)
+QEglFSKmsScreen *QEglFSKmsDevice::createScreenForConnector(drmModeResPtr resources, drmModeConnectorPtr connector, int *virtualIndex)
{
const QByteArray connectorName = nameForConnector(connector);
@@ -173,8 +173,11 @@ QEglFSKmsScreen *QEglFSKmsDevice::screenForConnector(drmModeResPtr resources, dr
QSize configurationSize;
drmModeModeInfo configurationModeline;
- const QByteArray mode = m_integration->outputSettings().value(QString::fromUtf8(connectorName))
- .value(QStringLiteral("mode"), QStringLiteral("preferred")).toByteArray().toLower();
+ auto userConfig = m_integration->outputSettings();
+ auto userConnectorConfig = userConfig.value(QString::fromUtf8(connectorName));
+ // default to the preferred mode unless overridden in the config
+ const QByteArray mode = userConnectorConfig.value(QStringLiteral("mode"), QStringLiteral("preferred"))
+ .toByteArray().toLower();
if (mode == "off") {
configuration = OutputConfigOff;
} else if (mode == "preferred") {
@@ -189,6 +192,8 @@ QEglFSKmsScreen *QEglFSKmsDevice::screenForConnector(drmModeResPtr resources, dr
qWarning("Invalid mode \"%s\" for output %s", mode.constData(), connectorName.constData());
configuration = OutputConfigPreferred;
}
+ if (virtualIndex)
+ *virtualIndex = userConnectorConfig.value(QStringLiteral("virtualIndex"), INT_MAX).toInt();
const uint32_t crtc_id = resources->crtcs[crtc];
@@ -287,18 +292,26 @@ QEglFSKmsScreen *QEglFSKmsDevice::screenForConnector(drmModeResPtr resources, dr
qCDebug(qLcEglfsKmsDebug) << "Selected mode" << selected_mode << ":" << width << "x" << height
<< '@' << refresh << "hz for output" << connectorName;
}
+
+ // physical size from connector < config values < env vars
static const int width = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_WIDTH");
static const int height = qEnvironmentVariableIntValue("QT_QPA_EGLFS_PHYSICAL_HEIGHT");
- QSizeF size(width, height);
- if (size.isEmpty()) {
- size.setWidth(connector->mmWidth);
- size.setHeight(connector->mmHeight);
+ QSizeF physSize(width, height);
+ if (physSize.isEmpty()) {
+ physSize = QSize(userConnectorConfig.value(QStringLiteral("physicalWidth")).toInt(),
+ userConnectorConfig.value(QStringLiteral("physicalHeight")).toInt());
+ if (physSize.isEmpty()) {
+ physSize.setWidth(connector->mmWidth);
+ physSize.setHeight(connector->mmHeight);
+ }
}
+ qCDebug(qLcEglfsKmsDebug) << "Physical size is" << physSize << "mm" << "for output" << connectorName;
+
QEglFSKmsOutput output = {
QString::fromUtf8(connectorName),
connector->connector_id,
crtc_id,
- size,
+ physSize,
selected_mode,
false,
drmModeGetCrtc(m_dri_fd, crtc_id),
@@ -310,7 +323,7 @@ QEglFSKmsScreen *QEglFSKmsDevice::screenForConnector(drmModeResPtr resources, dr
m_crtc_allocator |= (1 << output.crtc_id);
m_connector_allocator |= (1 << output.connector_id);
- return createScreen(m_integration, this, output, pos);
+ return createScreen(m_integration, this, output);
}
drmModePropertyPtr QEglFSKmsDevice::connectorProperty(drmModeConnectorPtr connector, const QByteArray &name)
@@ -342,6 +355,26 @@ QEglFSKmsDevice::~QEglFSKmsDevice()
{
}
+struct OrderedScreen
+{
+ OrderedScreen() : screen(nullptr), index(-1) { }
+ OrderedScreen(QEglFSKmsScreen *screen, int index) : screen(screen), index(index) { }
+ QEglFSKmsScreen *screen;
+ int index;
+};
+
+QDebug operator<<(QDebug dbg, const OrderedScreen &s)
+{
+ QDebugStateSaver saver(dbg);
+ dbg.nospace() << "OrderedScreen(" << s.screen << " : " << s.index << ")";
+ return dbg;
+}
+
+static bool orderedScreenLessThan(const OrderedScreen &a, const OrderedScreen &b)
+{
+ return a.index < b.index;
+}
+
void QEglFSKmsDevice::createScreens()
{
drmModeResPtr resources = drmModeGetResources(m_dri_fd);
@@ -350,32 +383,49 @@ void QEglFSKmsDevice::createScreens()
return;
}
- QEglFSKmsScreen *primaryScreen = Q_NULLPTR;
- QList<QPlatformScreen *> siblings;
- QPoint pos(0, 0);
- QEglFSIntegration *integration = static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration());
+ QVector<OrderedScreen> screens;
for (int i = 0; i < resources->count_connectors; i++) {
drmModeConnectorPtr connector = drmModeGetConnector(m_dri_fd, resources->connectors[i]);
if (!connector)
continue;
- QEglFSKmsScreen *screen = screenForConnector(resources, connector, pos);
- if (screen) {
- integration->addScreen(screen);
- pos.rx() += screen->geometry().width();
- siblings << screen;
-
- if (!primaryScreen)
- primaryScreen = screen;
- }
+ int virtualIndex;
+ QEglFSKmsScreen *screen = createScreenForConnector(resources, connector, &virtualIndex);
+ if (screen)
+ screens.append(OrderedScreen(screen, virtualIndex));
drmModeFreeConnector(connector);
}
drmModeFreeResources(resources);
+ // Use stable sort to preserve the original order for outputs with unspecified indices.
+ std::stable_sort(screens.begin(), screens.end(), orderedScreenLessThan);
+ qCDebug(qLcEglfsKmsDebug) << "Sorted screen list:" << screens;
+
+ QPoint pos(0, 0);
+ QList<QPlatformScreen *> siblings;
+ QEglFSIntegration *qpaIntegration = static_cast<QEglFSIntegration *>(QGuiApplicationPrivate::platformIntegration());
+
+ for (const OrderedScreen &orderedScreen : screens) {
+ QEglFSKmsScreen *s = orderedScreen.screen;
+ // set up a horizontal or vertical virtual desktop
+ s->setVirtualPosition(pos);
+ if (m_integration->virtualDesktopLayout() == QEglFSKmsIntegration::VirtualDesktopLayoutVertical)
+ pos.ry() += s->geometry().height();
+ else
+ pos.rx() += s->geometry().width();
+ qCDebug(qLcEglfsKmsDebug) << "Adding screen" << s << "to QPA with geometry" << s->geometry();
+ // The order in qguiapp's screens list will match the order set by
+ // virtualIndex. This is not only handy but also required since for instance
+ // evdevtouch relies on it when performing touch device - screen mapping.
+ qpaIntegration->addScreen(s);
+ siblings << s;
+ }
+
if (!m_integration->separateScreens()) {
+ // enable the virtual desktop
Q_FOREACH (QPlatformScreen *screen, siblings)
static_cast<QEglFSKmsScreen *>(screen)->setVirtualSiblings(siblings);
}
@@ -391,9 +441,9 @@ QString QEglFSKmsDevice::devicePath() const
return m_path;
}
-QEglFSKmsScreen *QEglFSKmsDevice::createScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, QEglFSKmsOutput output, QPoint position)
+QEglFSKmsScreen *QEglFSKmsDevice::createScreen(QEglFSKmsIntegration *integration, QEglFSKmsDevice *device, QEglFSKmsOutput output)
{
- return new QEglFSKmsScreen(integration, device, output, position);
+ return new QEglFSKmsScreen(integration, device, output);
}
void QEglFSKmsDevice::setFd(int fd)
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h
index 041c063695..4aad2e0143 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsdevice.h
@@ -68,8 +68,7 @@ public:
protected:
virtual QEglFSKmsScreen *createScreen(QEglFSKmsIntegration *integration,
QEglFSKmsDevice *device,
- QEglFSKmsOutput output,
- QPoint position);
+ QEglFSKmsOutput output);
void setFd(int fd);
QEglFSKmsIntegration *m_integration;
@@ -80,7 +79,7 @@ protected:
quint32 m_connector_allocator;
int crtcForConnector(drmModeResPtr resources, drmModeConnectorPtr connector);
- QEglFSKmsScreen *screenForConnector(drmModeResPtr resources, drmModeConnectorPtr connector, QPoint pos);
+ QEglFSKmsScreen *createScreenForConnector(drmModeResPtr resources, drmModeConnectorPtr connector, int *virtualIndex);
drmModePropertyPtr connectorProperty(drmModeConnectorPtr connector, const QByteArray &name);
static void pageFlipHandler(int fd,
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp
index 07ea7d4439..6c30e8f930 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.cpp
@@ -42,8 +42,8 @@
#include "qeglfskmsintegration.h"
#include "qeglfskmsdevice.h"
#include "qeglfskmsscreen.h"
-#include "qeglfswindow.h"
-#include "qeglfscursor.h"
+#include "private/qeglfswindow_p.h"
+#include "private/qeglfscursor_p.h"
#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <QtCore/QJsonDocument>
@@ -65,6 +65,7 @@ QEglFSKmsIntegration::QEglFSKmsIntegration()
, m_hwCursor(false)
, m_pbuffers(false)
, m_separateScreens(false)
+ , m_virtualDesktopLayout(VirtualDesktopLayoutHorizontal)
{}
void QEglFSKmsIntegration::platformInit()
@@ -149,6 +150,11 @@ bool QEglFSKmsIntegration::separateScreens() const
return m_separateScreens;
}
+QEglFSKmsIntegration::VirtualDesktopLayout QEglFSKmsIntegration::virtualDesktopLayout() const
+{
+ return m_virtualDesktopLayout;
+}
+
QMap<QString, QVariantMap> QEglFSKmsIntegration::outputSettings() const
{
return m_outputSettings;
@@ -169,15 +175,15 @@ void QEglFSKmsIntegration::loadConfig()
QFile file(QString::fromUtf8(json));
if (!file.open(QFile::ReadOnly)) {
- qCDebug(qLcEglfsKmsDebug) << "Could not open config file"
- << json << "for reading";
+ qCWarning(qLcEglfsKmsDebug) << "Could not open config file"
+ << json << "for reading";
return;
}
const QJsonDocument doc = QJsonDocument::fromJson(file.readAll());
if (!doc.isObject()) {
- qCDebug(qLcEglfsKmsDebug) << "Invalid config file" << json
- << "- no top-level JSON object";
+ qCWarning(qLcEglfsKmsDebug) << "Invalid config file" << json
+ << "- no top-level JSON object";
return;
}
@@ -188,6 +194,16 @@ void QEglFSKmsIntegration::loadConfig()
m_devicePath = object.value(QLatin1String("device")).toString();
m_separateScreens = object.value(QLatin1String("separateScreens")).toBool(m_separateScreens);
+ const QString vdOriString = object.value(QLatin1String("virtualDesktopLayout")).toString();
+ if (!vdOriString.isEmpty()) {
+ if (vdOriString == QLatin1String("horizontal"))
+ m_virtualDesktopLayout = VirtualDesktopLayoutHorizontal;
+ else if (vdOriString == QLatin1String("vertical"))
+ m_virtualDesktopLayout = VirtualDesktopLayoutVertical;
+ else
+ qCWarning(qLcEglfsKmsDebug) << "Unknown virtualDesktopOrientation value" << vdOriString;
+ }
+
const QJsonArray outputs = object.value(QLatin1String("outputs")).toArray();
for (int i = 0; i < outputs.size(); i++) {
const QVariantMap outputSettings = outputs.at(i).toObject().toVariantMap();
@@ -207,6 +223,7 @@ void QEglFSKmsIntegration::loadConfig()
<< "\thwcursor:" << m_hwCursor << "\n"
<< "\tpbuffers:" << m_pbuffers << "\n"
<< "\tseparateScreens:" << m_separateScreens << "\n"
+ << "\tvirtualDesktopLayout:" << m_virtualDesktopLayout << "\n"
<< "\toutputs:" << m_outputSettings;
}
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.h
index 34ac5385a5..ba49945715 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsintegration.h
@@ -42,7 +42,7 @@
#ifndef QEGLFSKMSINTEGRATION_H
#define QEGLFSKMSINTEGRATION_H
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
#include <QtCore/QMap>
#include <QtCore/QVariant>
#include <QtCore/QLoggingCategory>
@@ -53,9 +53,14 @@ class QEglFSKmsDevice;
Q_EGLFS_EXPORT Q_DECLARE_LOGGING_CATEGORY(qLcEglfsKmsDebug)
-class Q_EGLFS_EXPORT QEglFSKmsIntegration : public QEGLDeviceIntegration
+class Q_EGLFS_EXPORT QEglFSKmsIntegration : public QEglFSDeviceIntegration
{
public:
+ enum VirtualDesktopLayout {
+ VirtualDesktopLayoutHorizontal,
+ VirtualDesktopLayoutVertical
+ };
+
QEglFSKmsIntegration();
void platformInit() Q_DECL_OVERRIDE;
@@ -70,6 +75,7 @@ public:
virtual bool hwCursor() const;
virtual bool separateScreens() const;
+ virtual VirtualDesktopLayout virtualDesktopLayout() const;
QMap<QString, QVariantMap> outputSettings() const;
QEglFSKmsDevice *device() const;
@@ -83,6 +89,7 @@ protected:
bool m_hwCursor;
bool m_pbuffers;
bool m_separateScreens;
+ VirtualDesktopLayout m_virtualDesktopLayout;
QString m_devicePath;
QMap<QString, QVariantMap> m_outputSettings;
};
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp
index e6b256f6b2..f690cd668e 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.cpp
@@ -71,17 +71,15 @@ private:
QEglFSKmsScreen::QEglFSKmsScreen(QEglFSKmsIntegration *integration,
QEglFSKmsDevice *device,
- QEglFSKmsOutput output,
- QPoint position)
+ QEglFSKmsOutput output)
: QEglFSScreen(eglGetDisplay(device->nativeDisplay()))
, m_integration(integration)
, m_device(device)
, m_output(output)
- , m_pos(position)
, m_powerState(PowerStateOn)
, m_interruptHandler(new QEglFSKmsInterruptHandler(this))
{
- m_siblings << this;
+ m_siblings << this; // gets overridden by QEglFSKmsDevice later if !separateScreens
}
QEglFSKmsScreen::~QEglFSKmsScreen()
@@ -98,7 +96,14 @@ QEglFSKmsScreen::~QEglFSKmsScreen()
delete m_interruptHandler;
}
-QRect QEglFSKmsScreen::geometry() const
+void QEglFSKmsScreen::setVirtualPosition(const QPoint &pos)
+{
+ m_pos = pos;
+}
+
+// Reimplement rawGeometry(), not geometry(). The base class implementation of
+// geometry() calls rawGeometry() and may apply additional transforms.
+QRect QEglFSKmsScreen::rawGeometry() const
{
const int mode = m_output.mode;
return QRect(m_pos.x(), m_pos.y(),
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h
index aa698e1b5d..2b6a0ffe6c 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms_support/qeglfskmsscreen.h
@@ -43,7 +43,7 @@
#define QEGLFSKMSSCREEN_H
#include "qeglfskmsintegration.h"
-#include "qeglfsscreen.h"
+#include "private/qeglfsscreen_p.h"
#include <QtCore/QList>
#include <QtCore/QMutex>
@@ -74,11 +74,13 @@ class Q_EGLFS_EXPORT QEglFSKmsScreen : public QEglFSScreen
public:
QEglFSKmsScreen(QEglFSKmsIntegration *integration,
QEglFSKmsDevice *device,
- QEglFSKmsOutput output,
- QPoint position);
+ QEglFSKmsOutput output);
~QEglFSKmsScreen();
- QRect geometry() const Q_DECL_OVERRIDE;
+ void setVirtualPosition(const QPoint &pos);
+
+ QRect rawGeometry() const Q_DECL_OVERRIDE;
+
int depth() const Q_DECL_OVERRIDE;
QImage::Format format() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/eglfs_mali.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/eglfs_mali.pro
index 3e486bd1bd..6e32ca26d0 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/eglfs_mali.pro
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/eglfs_mali.pro
@@ -1,6 +1,6 @@
TARGET = qeglfs-mali-integration
-QT += core-private gui-private platformsupport-private eglfs_device_lib-private
+QT += core-private gui-private platformsupport-private eglfsdeviceintegration-private
# Avoid X11 header collision, use generic EGL native types
DEFINES += QT_EGL_NO_X11
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.cpp
index ffdb7a686b..cd468c989f 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.cpp
@@ -56,7 +56,7 @@ struct fbdev_window {
void QEglFSMaliIntegration::platformInit()
{
// Keep the non-overridden base class functions based on fb0 working.
- QEGLDeviceIntegration::platformInit();
+ QEglFSDeviceIntegration::platformInit();
int fd = qt_safe_open("/dev/fb0", O_RDWR, 0);
if (fd == -1)
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.h
index 35a2c64951..56883a3676 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmaliintegration.h
@@ -40,11 +40,11 @@
#ifndef QEGLFSMALIINTEGRATION_H
#define QEGLFSMALIINTEGRATION_H
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
QT_BEGIN_NAMESPACE
-class QEglFSMaliIntegration : public QEGLDeviceIntegration
+class QEglFSMaliIntegration : public QEglFSDeviceIntegration
{
public:
void platformInit() Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmalimain.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmalimain.cpp
index 0754e1af5b..a3c804f54d 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmalimain.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_mali/qeglfsmalimain.cpp
@@ -37,18 +37,18 @@
**
****************************************************************************/
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
#include "qeglfsmaliintegration.h"
QT_BEGIN_NAMESPACE
-class QEglFSMaliIntegrationPlugin : public QEGLDeviceIntegrationPlugin
+class QEglFSMaliIntegrationPlugin : public QEglFSDeviceIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID QEGLDeviceIntegrationFactoryInterface_iid FILE "eglfs_mali.json")
+ Q_PLUGIN_METADATA(IID QEglFSDeviceIntegrationFactoryInterface_iid FILE "eglfs_mali.json")
public:
- QEGLDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSMaliIntegration; }
+ QEglFSDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSMaliIntegration; }
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/eglfs_viv.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/eglfs_viv.pro
index 6fac2f529a..16880535e3 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/eglfs_viv.pro
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/eglfs_viv.pro
@@ -1,11 +1,10 @@
TARGET = qeglfs-viv-integration
-QT += core-private gui-private platformsupport-private eglfs_device_lib-private
+QT += core-private gui-private platformsupport-private eglfsdeviceintegration-private
INCLUDEPATH += $$PWD/../..
CONFIG += egl
DEFINES += LINUX=1 EGL_API_FB=1
-LIBS += -lGAL
QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
SOURCES += $$PWD/qeglfsvivmain.cpp \
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp
index ca97f6c8f9..f2fcc0d3ff 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.cpp
@@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
void QEglFSVivIntegration::platformInit()
{
- QEGLDeviceIntegration::platformInit();
+ QEglFSDeviceIntegration::platformInit();
int width, height;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.h
index 4a8cd5c385..2e98c2b4b1 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivintegration.h
@@ -40,11 +40,11 @@
#ifndef QEGLFSVIVINTEGRATION_H
#define QEGLFSVIVINTEGRATION_H
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
QT_BEGIN_NAMESPACE
-class QEglFSVivIntegration : public QEGLDeviceIntegration
+class QEglFSVivIntegration : public QEglFSDeviceIntegration
{
public:
void platformInit() Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivmain.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivmain.cpp
index d1c9fb4086..ebe2091b1e 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivmain.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv/qeglfsvivmain.cpp
@@ -37,18 +37,18 @@
**
****************************************************************************/
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
#include "qeglfsvivintegration.h"
QT_BEGIN_NAMESPACE
-class QEglFSVivIntegrationPlugin : public QEGLDeviceIntegrationPlugin
+class QEglFSVivIntegrationPlugin : public QEglFSDeviceIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID QEGLDeviceIntegrationFactoryInterface_iid FILE "eglfs_viv.json")
+ Q_PLUGIN_METADATA(IID QEglFSDeviceIntegrationFactoryInterface_iid FILE "eglfs_viv.json")
public:
- QEGLDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSVivIntegration; }
+ QEglFSDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSVivIntegration; }
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro
index 44f75c40e0..374c5bba6b 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/eglfs_viv_wl.pro
@@ -1,11 +1,10 @@
TARGET = qeglfs-viv-wl-integration
-QT += core-private gui-private platformsupport-private eglfs_device_lib-private
+QT += core-private gui-private platformsupport-private eglfsdeviceintegration-private
INCLUDEPATH += $$PWD/../..
CONFIG += egl
DEFINES += LINUX=1 EGL_API_FB=1
-LIBS += -lGAL
QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
SOURCES += $$PWD/qeglfsvivwlmain.cpp \
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.cpp
index 5c113456e4..61e2f17766 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.cpp
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
void QEglFSVivWaylandIntegration::platformInit()
{
- QEGLDeviceIntegration::platformInit();
+ QEglFSDeviceIntegration::platformInit();
int width, height;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.h
index 40eacc8f2f..9abbe817a6 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlintegration.h
@@ -40,12 +40,12 @@
#ifndef QEGLFSVIVINTEGRATION_H
#define QEGLFSVIVINTEGRATION_H
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
struct wl_display;
QT_BEGIN_NAMESPACE
-class QEglFSVivWaylandIntegration : public QEGLDeviceIntegration
+class QEglFSVivWaylandIntegration : public QEglFSDeviceIntegration
{
public:
void platformInit() Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlmain.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlmain.cpp
index 02ef9c566c..3b26feda07 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlmain.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_viv_wl/qeglfsvivwlmain.cpp
@@ -37,18 +37,18 @@
**
****************************************************************************/
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
#include "qeglfsvivwlintegration.h"
QT_BEGIN_NAMESPACE
-class QEglFSVivWaylandIntegrationPlugin : public QEGLDeviceIntegrationPlugin
+class QEglFSVivWaylandIntegrationPlugin : public QEglFSDeviceIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID QEGLDeviceIntegrationFactoryInterface_iid FILE "eglfs_viv_wl.json")
+ Q_PLUGIN_METADATA(IID QEglFSDeviceIntegrationFactoryInterface_iid FILE "eglfs_viv_wl.json")
public:
- QEGLDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSVivWaylandIntegration; }
+ QEglFSDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSVivWaylandIntegration; }
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro
index 1948d73750..17be384955 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/eglfs_x11.pro
@@ -1,6 +1,6 @@
TARGET = qeglfs-x11-integration
-QT += core-private gui-private platformsupport-private eglfs_device_lib-private
+QT += core-private gui-private platformsupport-private eglfsdeviceintegration-private
# Avoid X11 header collision, use generic EGL native types
DEFINES += QT_EGL_NO_X11
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h
index a3d0b01baf..c0f0ee5f22 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.h
@@ -40,7 +40,7 @@
#ifndef QEGLFSX11INTEGRATION_H
#define QEGLFSX11INTEGRATION_H
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatformwindow.h>
@@ -64,7 +64,7 @@ namespace Atoms {
class EventReader;
-class QEglFSX11Integration : public QEGLDeviceIntegration
+class QEglFSX11Integration : public QEglFSDeviceIntegration
{
public:
QEglFSX11Integration() : m_connection(0), m_window(0), m_eventReader(0) {}
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11main.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11main.cpp
index 314a85694b..c15e05b657 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11main.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11main.cpp
@@ -37,18 +37,18 @@
**
****************************************************************************/
-#include "qeglfsdeviceintegration.h"
+#include "private/qeglfsdeviceintegration_p.h"
#include "qeglfsx11integration.h"
QT_BEGIN_NAMESPACE
-class QEglFSX11IntegrationPlugin : public QEGLDeviceIntegrationPlugin
+class QEglFSX11IntegrationPlugin : public QEglFSDeviceIntegrationPlugin
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID QEGLDeviceIntegrationFactoryInterface_iid FILE "eglfs_x11.json")
+ Q_PLUGIN_METADATA(IID QEglFSDeviceIntegrationFactoryInterface_iid FILE "eglfs_x11.json")
public:
- QEGLDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSX11Integration; }
+ QEglFSDeviceIntegration *create() Q_DECL_OVERRIDE { return new QEglFSX11Integration; }
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/eglfs-plugin.pro b/src/plugins/platforms/eglfs/eglfs-plugin.pro
index a628cdccd9..90b8a9fb32 100644
--- a/src/plugins/platforms/eglfs/eglfs-plugin.pro
+++ b/src/plugins/platforms/eglfs/eglfs-plugin.pro
@@ -1,6 +1,6 @@
TARGET = qeglfs
-QT += platformsupport-private eglfs_device_lib-private
+QT += platformsupport-private eglfsdeviceintegration-private
SOURCES += $$PWD/qeglfsmain.cpp
diff --git a/src/plugins/platforms/eglfs/eglfs.pro b/src/plugins/platforms/eglfs/eglfs.pro
index 03c96ca1d9..d91ffd60a1 100644
--- a/src/plugins/platforms/eglfs/eglfs.pro
+++ b/src/plugins/platforms/eglfs/eglfs.pro
@@ -1,6 +1,6 @@
TEMPLATE = subdirs
CONFIG += ordered
-SUBDIRS += eglfs_device_lib.pro
+SUBDIRS += eglfsdeviceintegration.pro
SUBDIRS += eglfs-plugin.pro
SUBDIRS += deviceintegration
diff --git a/src/plugins/platforms/eglfs/eglfs_device_lib.pro b/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro
index 974b85b1dd..eb0ce73118 100644
--- a/src/plugins/platforms/eglfs/eglfs_device_lib.pro
+++ b/src/plugins/platforms/eglfs/eglfsdeviceintegration.pro
@@ -3,8 +3,9 @@
# have to keep the QObject magic like qobject_cast working.
# Hence this header-less, private-only module.
-TARGET = QtEglDeviceIntegration
-CONFIG += no_module_headers internal_module
+TARGET = QtEglFSDeviceIntegration
+CONFIG += internal_module
+MODULE = eglfsdeviceintegration
QT += core-private gui-private platformsupport-private
LIBS += $$QMAKE_LIBS_DYNLOAD
@@ -15,22 +16,14 @@ DEFINES += QT_EGL_NO_X11
DEFINES += QT_BUILD_EGL_DEVICE_LIB
SOURCES += $$PWD/qeglfsintegration.cpp \
- $$PWD/qeglfswindow.cpp \
- $$PWD/qeglfsscreen.cpp \
- $$PWD/qeglfscursor.cpp \
- $$PWD/qeglfshooks.cpp \
$$PWD/qeglfscontext.cpp \
$$PWD/qeglfsoffscreenwindow.cpp \
- $$PWD/qeglfsdeviceintegration.cpp
HEADERS += $$PWD/qeglfsintegration.h \
- $$PWD/qeglfswindow.h \
- $$PWD/qeglfsscreen.h \
- $$PWD/qeglfscursor.h \
- $$PWD/qeglfshooks.h \
$$PWD/qeglfscontext.h \
$$PWD/qeglfsoffscreenwindow.h \
- $$PWD/qeglfsdeviceintegration.h
+
+include($$PWD/api/api.pri)
QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
diff --git a/src/plugins/platforms/eglfs/qeglfscontext.cpp b/src/plugins/platforms/eglfs/qeglfscontext.cpp
index 6acb362bf0..8d479873cf 100644
--- a/src/plugins/platforms/eglfs/qeglfscontext.cpp
+++ b/src/plugins/platforms/eglfs/qeglfscontext.cpp
@@ -43,9 +43,9 @@
#include <QtPlatformSupport/private/qeglpbuffer_p.h>
#include "qeglfscontext.h"
-#include "qeglfswindow.h"
-#include "qeglfshooks.h"
-#include "qeglfscursor.h"
+#include "qeglfswindow_p.h"
+#include "qeglfshooks_p.h"
+#include "qeglfscursor_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
index 6f38a96f45..8c8ef99bc2 100644
--- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
@@ -52,11 +52,11 @@
#include <private/qgenericunixthemes_p.h>
#include "qeglfsintegration.h"
-#include "qeglfswindow.h"
-#include "qeglfshooks.h"
+#include "qeglfswindow_p.h"
+#include "qeglfshooks_p.h"
#include "qeglfscontext.h"
#include "qeglfsoffscreenwindow.h"
-#include "qeglfscursor.h"
+#include "qeglfscursor_p.h"
#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
@@ -205,7 +205,7 @@ QPlatformOpenGLContext *QEglFSIntegration::createPlatformOpenGLContext(QOpenGLCo
QEglFSContext *ctx;
QSurfaceFormat adjustedFormat = qt_egl_device_integration()->surfaceFormatFor(context->format());
if (nativeHandle.isNull()) {
- EGLConfig config = QEglFSIntegration::chooseConfig(dpy, adjustedFormat);
+ EGLConfig config = QEglFSDeviceIntegration::chooseConfig(dpy, adjustedFormat);
ctx = new QEglFSContext(adjustedFormat, share, dpy, &config, QVariant());
} else {
ctx = new QEglFSContext(adjustedFormat, share, dpy, 0, nativeHandle);
@@ -436,22 +436,4 @@ EGLNativeDisplayType QEglFSIntegration::nativeDisplay() const
return qt_egl_device_integration()->platformDisplay();
}
-EGLConfig QEglFSIntegration::chooseConfig(EGLDisplay display, const QSurfaceFormat &format)
-{
- class Chooser : public QEglConfigChooser {
- public:
- Chooser(EGLDisplay display)
- : QEglConfigChooser(display) { }
- bool filterConfig(EGLConfig config) const Q_DECL_OVERRIDE {
- return qt_egl_device_integration()->filterConfig(display(), config)
- && QEglConfigChooser::filterConfig(config);
- }
- };
-
- Chooser chooser(display);
- chooser.setSurfaceType(qt_egl_device_integration()->surfaceType());
- chooser.setSurfaceFormat(format);
- return chooser.chooseConfig();
-}
-
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.h b/src/plugins/platforms/eglfs/qeglfsintegration.h
index 678452a8db..9c5439a22f 100644
--- a/src/plugins/platforms/eglfs/qeglfsintegration.h
+++ b/src/plugins/platforms/eglfs/qeglfsintegration.h
@@ -92,8 +92,6 @@ public:
void addScreen(QPlatformScreen *screen);
void removeScreen(QPlatformScreen *screen);
- static EGLConfig chooseConfig(EGLDisplay display, const QSurfaceFormat &format);
-
private:
EGLNativeDisplayType nativeDisplay() const;
void createInputHandlers();
diff --git a/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.cpp b/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.cpp
index 11b101970b..0334ac9785 100644
--- a/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsoffscreenwindow.cpp
@@ -38,7 +38,7 @@
****************************************************************************/
#include "qeglfsoffscreenwindow.h"
-#include "qeglfshooks.h"
+#include "qeglfshooks_p.h"
#include <QtGui/QOffscreenSurface>
#include <QtPlatformSupport/private/qeglconvenience_p.h>
diff --git a/src/plugins/platforms/ios/ios.pro b/src/plugins/platforms/ios/ios.pro
index 7b0a573ffa..2c85a68f0b 100644
--- a/src/plugins/platforms/ios/ios.pro
+++ b/src/plugins/platforms/ios/ios.pro
@@ -1,7 +1,7 @@
TARGET = qios
QT += core-private gui-private platformsupport-private
-LIBS += -framework Foundation -framework UIKit -framework QuartzCore -framework AssetsLibrary -framework AudioToolbox
+LIBS += -framework Foundation -framework UIKit -framework QuartzCore -framework AudioToolbox
OBJECTIVE_SOURCES = \
plugin.mm \
@@ -19,15 +19,9 @@ OBJECTIVE_SOURCES = \
qiosglobal.mm \
qiosservices.mm \
quiview.mm \
- qiosclipboard.mm \
quiaccessibilityelement.mm \
qiosplatformaccessibility.mm \
- qiostextresponder.mm \
- qiosmenu.mm \
- qiosfileengineassetslibrary.mm \
- qiosfiledialog.mm \
- qiosmessagedialog.mm \
- qiostextinputoverlay.mm
+ qiostextresponder.mm
HEADERS = \
qiosintegration.h \
@@ -44,16 +38,28 @@ HEADERS = \
qiosglobal.h \
qiosservices.h \
quiview.h \
- qiosclipboard.h \
quiaccessibilityelement.h \
qiosplatformaccessibility.h \
qiostextresponder.h \
- qiosmenu.h \
- qiosfileenginefactory.h \
- qiosfileengineassetslibrary.h \
- qiosfiledialog.h \
- qiosmessagedialog.h \
- qiostextinputoverlay.h
+ qiosfileenginefactory.h
+
+!tvos {
+ LIBS += -framework AssetsLibrary
+ OBJECTIVE_SOURCES += \
+ qiosclipboard.mm \
+ qiosmenu.mm \
+ qiosfileengineassetslibrary.mm \
+ qiosfiledialog.mm \
+ qiosmessagedialog.mm \
+ qiostextinputoverlay.mm
+ HEADERS += \
+ qiosclipboard.h \
+ qiosmenu.h \
+ qiosfileengineassetslibrary.h \
+ qiosfiledialog.h \
+ qiosmessagedialog.h \
+ qiostextinputoverlay.h
+}
OTHER_FILES = \
quiview_textinput.mm \
diff --git a/src/plugins/platforms/ios/plugin.mm b/src/plugins/platforms/ios/plugin.mm
index b854dfdaa0..83760f2f39 100644
--- a/src/plugins/platforms/ios/plugin.mm
+++ b/src/plugins/platforms/ios/plugin.mm
@@ -54,8 +54,10 @@ class QIOSIntegrationPlugin : public QPlatformIntegrationPlugin
QPlatformIntegration * QIOSIntegrationPlugin::create(const QString& system, const QStringList& paramList)
{
Q_UNUSED(paramList);
- if (!system.compare(QLatin1String("ios"), Qt::CaseInsensitive))
+ if (!system.compare(QLatin1String("ios"), Qt::CaseInsensitive)
+ || !system.compare(QLatin1String("tvos"), Qt::CaseInsensitive)) {
return new QIOSIntegration;
+ }
return 0;
}
diff --git a/src/plugins/platforms/ios/qioseventdispatcher.mm b/src/plugins/platforms/ios/qioseventdispatcher.mm
index 8d82364cc0..f49f81912e 100644
--- a/src/plugins/platforms/ios/qioseventdispatcher.mm
+++ b/src/plugins/platforms/ios/qioseventdispatcher.mm
@@ -493,7 +493,7 @@ void QIOSEventDispatcher::handleRunLoopExit(CFRunLoopActivity activity)
Q_UNUSED(activity);
Q_ASSERT(activity == kCFRunLoopExit);
- if (m_processEventLevel == 1 && !QThreadData::current()->eventLoops.top()->isRunning()) {
+ if (m_processEventLevel == 1 && !currentEventLoop()->isRunning()) {
qEventDispatcherDebug() << "Root runloop level exited";
interruptEventLoopExec();
}
diff --git a/src/plugins/platforms/ios/qiosfileenginefactory.h b/src/plugins/platforms/ios/qiosfileenginefactory.h
index b71fa64460..87665ac603 100644
--- a/src/plugins/platforms/ios/qiosfileenginefactory.h
+++ b/src/plugins/platforms/ios/qiosfileenginefactory.h
@@ -51,8 +51,12 @@ public:
{
static QLatin1String assetsScheme("assets-library:");
+#ifndef Q_OS_TVOS
if (fileName.toLower().startsWith(assetsScheme))
return new QIOSFileEngineAssetsLibrary(fileName);
+#else
+ Q_UNUSED(fileName);
+#endif
return 0;
}
diff --git a/src/plugins/platforms/ios/qiosglobal.h b/src/plugins/platforms/ios/qiosglobal.h
index 0fe81ceb91..50bedd7b28 100644
--- a/src/plugins/platforms/ios/qiosglobal.h
+++ b/src/plugins/platforms/ios/qiosglobal.h
@@ -61,13 +61,10 @@ class QPlatformScreen;
bool isQtApplication();
-CGRect toCGRect(const QRectF &rect);
-QRectF fromCGRect(const CGRect &rect);
-CGPoint toCGPoint(const QPointF &point);
-QPointF fromCGPoint(const CGPoint &point);
-
+#ifndef Q_OS_TVOS
Qt::ScreenOrientation toQtScreenOrientation(UIDeviceOrientation uiDeviceOrientation);
UIDeviceOrientation fromQtScreenOrientation(Qt::ScreenOrientation qtOrientation);
+#endif
int infoPlistValue(NSString* key, int defaultValue);
diff --git a/src/plugins/platforms/ios/qiosglobal.mm b/src/plugins/platforms/ios/qiosglobal.mm
index c2f3d6b9e1..7ca3c66971 100644
--- a/src/plugins/platforms/ios/qiosglobal.mm
+++ b/src/plugins/platforms/ios/qiosglobal.mm
@@ -58,26 +58,7 @@ bool isQtApplication()
return isQt;
}
-CGRect toCGRect(const QRectF &rect)
-{
- return CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
-}
-
-QRectF fromCGRect(const CGRect &rect)
-{
- return QRectF(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
-}
-
-CGPoint toCGPoint(const QPointF &point)
-{
- return CGPointMake(point.x(), point.y());
-}
-
-QPointF fromCGPoint(const CGPoint &point)
-{
- return QPointF(point.x, point.y);
-}
-
+#ifndef Q_OS_TVOS
Qt::ScreenOrientation toQtScreenOrientation(UIDeviceOrientation uiDeviceOrientation)
{
Qt::ScreenOrientation qtOrientation;
@@ -124,6 +105,7 @@ UIDeviceOrientation fromQtScreenOrientation(Qt::ScreenOrientation qtOrientation)
}
return uiOrientation;
}
+#endif
int infoPlistValue(NSString* key, int defaultValue)
{
diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm
index ef93d68cf0..c6cbb9b101 100644
--- a/src/plugins/platforms/ios/qiosinputcontext.mm
+++ b/src/plugins/platforms/ios/qiosinputcontext.mm
@@ -117,6 +117,7 @@ static QUIView *focusView()
self.cancelsTouchesInView = NO;
self.delaysTouchesEnded = NO;
+#ifndef Q_OS_TVOS
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self
@@ -134,6 +135,7 @@ static QUIView *focusView()
[notificationCenter addObserver:self
selector:@selector(keyboardDidChangeFrame:)
name:UIKeyboardDidChangeFrameNotification object:nil];
+#endif
}
return self;
@@ -377,6 +379,9 @@ void QIOSInputContext::clearCurrentFocusObject()
void QIOSInputContext::updateKeyboardState(NSNotification *notification)
{
+#ifdef Q_OS_TVOS
+ Q_UNUSED(notification);
+#else
static CGRect currentKeyboardRect = CGRectZero;
KeyboardState previousState = m_keyboardState;
@@ -412,7 +417,7 @@ void QIOSInputContext::updateKeyboardState(NSNotification *notification)
m_keyboardState.animationDuration = [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
m_keyboardState.keyboardAnimating = m_keyboardState.animationDuration > 0 && !atEndOfKeyboardTransition;
- qImDebug() << qPrintable(QString::fromNSString(notification.name)) << "from" << fromCGRect(frameBegin) << "to" << fromCGRect(frameEnd)
+ qImDebug() << qPrintable(QString::fromNSString(notification.name)) << "from" << QRectF::fromCGRect(frameBegin) << "to" << QRectF::fromCGRect(frameEnd)
<< "(curve =" << m_keyboardState.animationCurve << "duration =" << m_keyboardState.animationDuration << "s)";
} else {
qImDebug("No notification to update keyboard state based on, just updating keyboard rect");
@@ -421,7 +426,7 @@ void QIOSInputContext::updateKeyboardState(NSNotification *notification)
if (!focusView() || CGRectIsEmpty(currentKeyboardRect))
m_keyboardState.keyboardRect = QRectF();
else // QInputmethod::keyboardRectangle() is documented to be in window coordinates.
- m_keyboardState.keyboardRect = fromCGRect([focusView() convertRect:currentKeyboardRect fromView:nil]);
+ m_keyboardState.keyboardRect = QRectF::fromCGRect([focusView() convertRect:currentKeyboardRect fromView:nil]);
// Emit for all changed properties
if (m_keyboardState.keyboardVisible != previousState.keyboardVisible)
@@ -430,6 +435,7 @@ void QIOSInputContext::updateKeyboardState(NSNotification *notification)
emitAnimatingChanged();
if (m_keyboardState.keyboardRect != previousState.keyboardRect)
emitKeyboardRectChanged();
+#endif
}
bool QIOSInputContext::isInputPanelVisible() const
@@ -549,7 +555,11 @@ void QIOSInputContext::scroll(int y)
if (keyboardScrollIsActive && !originalWindowLevels.contains(window))
originalWindowLevels.insert(window, window.windowLevel);
+#ifndef Q_OS_TVOS
UIWindowLevel windowLevelAdjustment = keyboardScrollIsActive ? UIWindowLevelStatusBar : 0;
+#else
+ UIWindowLevel windowLevelAdjustment = 0;
+#endif
window.windowLevel = originalWindowLevels.value(window) + windowLevelAdjustment;
if (!keyboardScrollIsActive)
diff --git a/src/plugins/platforms/ios/qiosintegration.h b/src/plugins/platforms/ios/qiosintegration.h
index a50d9aa571..36c3bbf6f1 100644
--- a/src/plugins/platforms/ios/qiosintegration.h
+++ b/src/plugins/platforms/ios/qiosintegration.h
@@ -46,7 +46,9 @@
#include "qiosapplicationstate.h"
#include "qiosfileenginefactory.h"
+#ifndef Q_OS_TVOS
#include "qiostextinputoverlay.h"
+#endif
QT_BEGIN_NAMESPACE
@@ -102,14 +104,18 @@ public:
private:
QPlatformFontDatabase *m_fontDatabase;
+#ifndef Q_OS_TVOS
QPlatformClipboard *m_clipboard;
+#endif
QPlatformInputContext *m_inputContext;
QTouchDevice *m_touchDevice;
QIOSApplicationState m_applicationState;
QIOSServices *m_platformServices;
mutable QPlatformAccessibility *m_accessibility;
QIOSFileEngineFactory m_fileEngineFactory;
+#ifndef Q_OS_TVOS
QIOSTextInputOverlay m_textInputOverlay;
+#endif
bool m_debugWindowManagement;
};
@@ -117,4 +123,3 @@ private:
QT_END_NAMESPACE
#endif
-
diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm
index fa12d54b28..297b549ec2 100644
--- a/src/plugins/platforms/ios/qiosintegration.mm
+++ b/src/plugins/platforms/ios/qiosintegration.mm
@@ -45,7 +45,9 @@
#include "qiosscreen.h"
#include "qiosplatformaccessibility.h"
#include "qioscontext.h"
+#ifndef Q_OS_TVOS
#include "qiosclipboard.h"
+#endif
#include "qiosinputcontext.h"
#include "qiostheme.h"
#include "qiosservices.h"
@@ -72,7 +74,9 @@ QIOSIntegration *QIOSIntegration::instance()
QIOSIntegration::QIOSIntegration()
: m_fontDatabase(new QCoreTextFontDatabase)
+#ifndef Q_OS_TVOS
, m_clipboard(new QIOSClipboard)
+#endif
, m_inputContext(0)
, m_platformServices(new QIOSServices)
, m_accessibility(0)
@@ -127,8 +131,10 @@ QIOSIntegration::~QIOSIntegration()
delete m_fontDatabase;
m_fontDatabase = 0;
+#ifndef Q_OS_TVOS
delete m_clipboard;
m_clipboard = 0;
+#endif
QMacInternalPasteboardMime::destroyMimeTypes();
delete m_inputContext;
@@ -217,7 +223,11 @@ QPlatformFontDatabase * QIOSIntegration::fontDatabase() const
QPlatformClipboard *QIOSIntegration::clipboard() const
{
+#ifndef Q_OS_TVOS
return m_clipboard;
+#else
+ return 0;
+#endif
}
QPlatformInputContext *QIOSIntegration::inputContext() const
diff --git a/src/plugins/platforms/ios/qiosmenu.mm b/src/plugins/platforms/ios/qiosmenu.mm
index db1b5b8cc8..d5211cdd8a 100644
--- a/src/plugins/platforms/ios/qiosmenu.mm
+++ b/src/plugins/platforms/ios/qiosmenu.mm
@@ -570,7 +570,7 @@ void QIOSMenu::repositionMenu()
switch (m_effectiveMenuType) {
case EditMenu: {
UIView *view = reinterpret_cast<UIView *>(m_parentWindow->winId());
- [[UIMenuController sharedMenuController] setTargetRect:toCGRect(m_targetRect) inView:view];
+ [[UIMenuController sharedMenuController] setTargetRect:m_targetRect.toCGRect() inView:view];
[[UIMenuController sharedMenuController] setMenuVisible:YES animated:YES];
break; }
default:
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm
index d53f0df846..b9c77e9bba 100644
--- a/src/plugins/platforms/ios/qiosscreen.mm
+++ b/src/plugins/platforms/ios/qiosscreen.mm
@@ -143,21 +143,25 @@ static QIOSScreen* qtPlatformScreenFor(UIScreen *uiScreen)
self = [super init];
if (self) {
m_screen = screen;
+#ifndef Q_OS_TVOS
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(orientationChanged:)
name:@"UIDeviceOrientationDidChangeNotification" object:nil];
+#endif
}
return self;
}
- (void)dealloc
{
+#ifndef Q_OS_TVOS
[[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:@"UIDeviceOrientationDidChangeNotification" object:nil];
+#endif
[super dealloc];
}
@@ -256,9 +260,14 @@ void QIOSScreen::updateProperties()
QRect previousGeometry = m_geometry;
QRect previousAvailableGeometry = m_availableGeometry;
- m_geometry = fromCGRect(m_uiScreen.bounds).toRect();
- m_availableGeometry = fromCGRect(m_uiScreen.applicationFrame).toRect();
+ m_geometry = QRectF::fromCGRect(m_uiScreen.bounds).toRect();
+#ifdef Q_OS_TVOS
+ m_availableGeometry = m_geometry;
+#else
+ m_availableGeometry = QRectF::fromCGRect(m_uiScreen.applicationFrame).toRect();
+#endif
+#ifndef Q_OS_TVOS
if (m_uiScreen == [UIScreen mainScreen]) {
Qt::ScreenOrientation statusBarOrientation = toQtScreenOrientation(UIDeviceOrientation([UIApplication sharedApplication].statusBarOrientation));
@@ -286,6 +295,7 @@ void QIOSScreen::updateProperties()
m_availableGeometry = transform.mapRect(m_availableGeometry);
}
}
+#endif
if (m_geometry != previousGeometry) {
QRectF physicalGeometry;
@@ -298,7 +308,7 @@ void QIOSScreen::updateProperties()
// before being output on the physical display. We have to take this into account when
// computing the physical size. Note that unlike the native bounds, the physical size
// follows the primary orientation of the screen.
- physicalGeometry = mapBetween(nativeOrientation(), primaryOrientation, fromCGRect(m_uiScreen.nativeBounds).toRect());
+ physicalGeometry = mapBetween(nativeOrientation(), primaryOrientation, QRectF::fromCGRect(m_uiScreen.nativeBounds).toRect());
} else {
physicalGeometry = QRectF(0, 0, m_geometry.width() * devicePixelRatio(), m_geometry.height() * devicePixelRatio());
}
@@ -393,7 +403,7 @@ qreal QIOSScreen::devicePixelRatio() const
Qt::ScreenOrientation QIOSScreen::nativeOrientation() const
{
CGRect nativeBounds =
-#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_8_0)
+#if !defined(Q_OS_TVOS) && QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_8_0)
QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_8_0 ? m_uiScreen.nativeBounds :
#endif
m_uiScreen.bounds;
@@ -406,6 +416,9 @@ Qt::ScreenOrientation QIOSScreen::nativeOrientation() const
Qt::ScreenOrientation QIOSScreen::orientation() const
{
+#ifdef Q_OS_TVOS
+ return Qt::PrimaryOrientation;
+#else
// Auxiliary screens are always the same orientation as their primary orientation
if (m_uiScreen != [UIScreen mainScreen])
return Qt::PrimaryOrientation;
@@ -430,6 +443,7 @@ Qt::ScreenOrientation QIOSScreen::orientation() const
}
return toQtScreenOrientation(deviceOrientation);
+#endif
}
void QIOSScreen::setOrientationUpdateMask(Qt::ScreenOrientations mask)
diff --git a/src/plugins/platforms/ios/qiostextinputoverlay.mm b/src/plugins/platforms/ios/qiostextinputoverlay.mm
index 733367f3be..ff260d02dc 100644
--- a/src/plugins/platforms/ios/qiostextinputoverlay.mm
+++ b/src/plugins/platforms/ios/qiostextinputoverlay.mm
@@ -136,7 +136,7 @@ static void executeBlockWithoutAnimation(Block block)
// first responder, which is normally QIOSTextResponder.
QRectF cr = qApp->inputMethod()->cursorRectangle();
QRectF ar = qApp->inputMethod()->anchorRectangle();
- CGRect targetRect = toCGRect(cr.united(ar));
+ CGRect targetRect = cr.united(ar).toCGRect();
UIView *focusView = reinterpret_cast<UIView *>(qApp->focusWindow()->winId());
[[UIMenuController sharedMenuController] setTargetRect:targetRect inView:focusView];
[[UIMenuController sharedMenuController] setMenuVisible:YES animated:YES];
@@ -496,12 +496,12 @@ static void executeBlockWithoutAnimation(Block block)
QGuiApplication::styleHints()->setCursorFlashTime(0);
if (!_loupeLayer)
[self createLoupe];
- [self updateFocalPoint:fromCGPoint(_lastTouchPoint)];
+ [self updateFocalPoint:QPointF::fromCGPoint(_lastTouchPoint)];
_loupeLayer.visible = YES;
break;
case UIGestureRecognizerStateChanged:
// Tell the sub class to move the loupe to the correct position
- [self updateFocalPoint:fromCGPoint(_lastTouchPoint)];
+ [self updateFocalPoint:QPointF::fromCGPoint(_lastTouchPoint)];
break;
case UIGestureRecognizerStateEnded:
// Restore cursor blinking, and hide the loupe
@@ -526,12 +526,12 @@ static void executeBlockWithoutAnimation(Block block)
- (QPointF)focalPoint
{
- return fromCGPoint([_loupeLayer.targetView convertPoint:_loupeLayer.focalPoint toView:_focusView]);
+ return QPointF::fromCGPoint([_loupeLayer.targetView convertPoint:_loupeLayer.focalPoint toView:_focusView]);
}
- (void)setFocalPoint:(QPointF)point
{
- _loupeLayer.focalPoint = [_loupeLayer.targetView convertPoint:toCGPoint(point) fromView:_focusView];
+ _loupeLayer.focalPoint = [_loupeLayer.targetView convertPoint:point.toCGPoint() fromView:_focusView];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
@@ -548,7 +548,7 @@ static void executeBlockWithoutAnimation(Block block)
// If the touch point is accepted by the sub class (e.g touch on cursor), we start a
// press'n'hold timer that eventually will move the state to UIGestureRecognizerStateBegan.
- if ([self acceptTouchesBegan:fromCGPoint(_firstTouchPoint)])
+ if ([self acceptTouchesBegan:QPointF::fromCGPoint(_firstTouchPoint)])
_triggerStateBeganTimer.start();
else
self.state = UIGestureRecognizerStateFailed;
@@ -856,8 +856,8 @@ static void executeBlockWithoutAnimation(Block block)
// Adjust handles and input rect to match the new selection
QRectF inputRect = QGuiApplication::inputMethod()->inputItemClipRectangle();
- CGRect cursorRect = toCGRect(QGuiApplication::inputMethod()->cursorRectangle());
- CGRect anchorRect = toCGRect(QGuiApplication::inputMethod()->anchorRectangle());
+ CGRect cursorRect = QGuiApplication::inputMethod()->cursorRectangle().toCGRect();
+ CGRect anchorRect = QGuiApplication::inputMethod()->anchorRectangle().toCGRect();
if (!_multiLine) {
// Resize the layer a bit bigger to ensure that the handles are
@@ -866,7 +866,7 @@ static void executeBlockWithoutAnimation(Block block)
inputRect.adjust(-margin / 2, -margin, margin / 2, margin);
}
- executeBlockWithoutAnimation(^{ _clipRectLayer.frame = toCGRect(inputRect); });
+ executeBlockWithoutAnimation(^{ _clipRectLayer.frame = inputRect.toCGRect(); });
_cursorLayer.cursorRectangle = [self.focusView.layer convertRect:cursorRect toLayer:_clipRectLayer];
_anchorLayer.cursorRectangle = [self.focusView.layer convertRect:anchorRect toLayer:_clipRectLayer];
_cursorLayer.visible = YES;
@@ -934,7 +934,7 @@ static void executeBlockWithoutAnimation(Block block)
}
QRectF inputRect = QGuiApplication::inputMethod()->inputItemClipRectangle();
- QPointF touchPos = fromCGPoint([static_cast<UITouch *>([touches anyObject]) locationInView:_focusView]);
+ QPointF touchPos = QPointF::fromCGPoint([static_cast<UITouch *>([touches anyObject]) locationInView:_focusView]);
if (!inputRect.contains(touchPos))
self.state = UIGestureRecognizerStateFailed;
@@ -943,7 +943,7 @@ static void executeBlockWithoutAnimation(Block block)
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
- QPointF touchPos = fromCGPoint([static_cast<UITouch *>([touches anyObject]) locationInView:_focusView]);
+ QPointF touchPos = QPointF::fromCGPoint([static_cast<UITouch *>([touches anyObject]) locationInView:_focusView]);
const QTransform mapToLocal = QGuiApplication::inputMethod()->inputItemTransform().inverted();
int cursorPosOnRelease = QInputMethod::queryFocusObject(Qt::ImCursorPosition, touchPos * mapToLocal).toInt();
diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm
index 37d5557794..5ec05ec8ce 100644
--- a/src/plugins/platforms/ios/qiostextresponder.mm
+++ b/src/plugins/platforms/ios/qiostextresponder.mm
@@ -680,11 +680,7 @@
if (markedTextFormat.isEmpty()) {
// There seems to be no way to query how the preedit text
// should be drawn. So we need to hard-code the color.
- QSysInfo::MacVersion iosVersion = QSysInfo::MacintoshVersion;
- if (iosVersion < QSysInfo::MV_IOS_7_0)
- markedTextFormat.setBackground(QColor(235, 239, 247));
- else
- markedTextFormat.setBackground(QColor(206, 221, 238));
+ markedTextFormat.setBackground(QColor(206, 221, 238));
}
QList<QInputMethodEvent::Attribute> attrs;
@@ -812,7 +808,7 @@
[self sendEventToFocusObject:e];
}
- return toCGRect(startRect.united(endRect));
+ return startRect.united(endRect).toCGRect();
}
- (NSArray *)selectionRectsForRange:(UITextRange *)range
@@ -830,7 +826,7 @@
// Assume for now that position is always the same as
// cursor index until a better API is in place:
QRectF cursorRect = qApp->inputMethod()->cursorRectangle();
- return toCGRect(cursorRect);
+ return cursorRect.toCGRect();
}
- (void)replaceRange:(UITextRange *)range withText:(NSString *)text
@@ -897,6 +893,7 @@
// text instead of just guessing...
}
+#ifndef Q_OS_TVOS
- (NSDictionary *)textStylingAtPosition:(UITextPosition *)position inDirection:(UITextStorageDirection)direction
{
Q_UNUSED(position);
@@ -916,6 +913,7 @@
return [NSDictionary dictionary];
return [NSDictionary dictionaryWithObject:uifont forKey:UITextInputTextFontKey];
}
+#endif
- (NSDictionary *)markedTextStyle
{
diff --git a/src/plugins/platforms/ios/qiostheme.mm b/src/plugins/platforms/ios/qiostheme.mm
index 486c146af9..83a8176478 100644
--- a/src/plugins/platforms/ios/qiostheme.mm
+++ b/src/plugins/platforms/ios/qiostheme.mm
@@ -51,9 +51,11 @@
#include <UIKit/UIFont.h>
#include <UIKit/UIInterface.h>
+#ifndef Q_OS_TVOS
#include "qiosmenu.h"
#include "qiosfiledialog.h"
#include "qiosmessagedialog.h"
+#endif
QT_BEGIN_NAMESPACE
@@ -80,12 +82,20 @@ const QPalette *QIOSTheme::palette(QPlatformTheme::Palette type) const
QPlatformMenuItem* QIOSTheme::createPlatformMenuItem() const
{
+#ifdef Q_OS_TVOS
+ return 0;
+#else
return new QIOSMenuItem();
+#endif
}
QPlatformMenu* QIOSTheme::createPlatformMenu() const
{
+#ifdef Q_OS_TVOS
+ return 0;
+#else
return new QIOSMenu();
+#endif
}
bool QIOSTheme::usePlatformNativeDialog(QPlatformTheme::DialogType type) const
@@ -102,12 +112,14 @@ bool QIOSTheme::usePlatformNativeDialog(QPlatformTheme::DialogType type) const
QPlatformDialogHelper *QIOSTheme::createPlatformDialogHelper(QPlatformTheme::DialogType type) const
{
switch (type) {
+#ifndef Q_OS_TVOS
case FileDialog:
return new QIOSFileDialog();
break;
case MessageDialog:
return new QIOSMessageDialog();
break;
+#endif
default:
return 0;
}
diff --git a/src/plugins/platforms/ios/qiosviewcontroller.h b/src/plugins/platforms/ios/qiosviewcontroller.h
index e97aeb32ed..92c4e59d1a 100644
--- a/src/plugins/platforms/ios/qiosviewcontroller.h
+++ b/src/plugins/platforms/ios/qiosviewcontroller.h
@@ -46,12 +46,16 @@ class QIOSScreen;
- (id)initWithQIOSScreen:(QIOSScreen *)screen;
- (void)updateProperties;
+#ifndef Q_OS_TVOS
@property (nonatomic, assign) UIInterfaceOrientation lockedOrientation;
+#endif
// UIViewController
@property (nonatomic, assign) BOOL prefersStatusBarHidden;
+#ifndef Q_OS_TVOS
@property (nonatomic, assign) UIStatusBarAnimation preferredStatusBarUpdateAnimation;
@property (nonatomic, assign) UIStatusBarStyle preferredStatusBarStyle;
+#endif
@end
diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm
index 2acb247572..c8c07bd298 100644
--- a/src/plugins/platforms/ios/qiosviewcontroller.mm
+++ b/src/plugins/platforms/ios/qiosviewcontroller.mm
@@ -37,6 +37,7 @@
**
****************************************************************************/
+#include "qiosglobal.h"
#import "qiosviewcontroller.h"
#include <QtCore/qscopedvaluerollback.h>
@@ -233,33 +234,16 @@
if (self = [self init]) {
m_screen = screen;
-#if QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_7_0)
- QSysInfo::MacVersion iosVersion = QSysInfo::MacintoshVersion;
-
- // We prefer to keep the root viewcontroller in fullscreen layout, so that
- // we don't have to compensate for the viewcontroller position. This also
- // gives us the same behavior on iOS 5/6 as on iOS 7, where full screen layout
- // is the only way.
- if (iosVersion < QSysInfo::MV_IOS_7_0)
- self.wantsFullScreenLayout = YES;
-
- // Use translucent statusbar by default on iOS6 iPhones (unless the user changed
- // the default in the Info.plist), so that windows placed under the stausbar are
- // still visible, just like on iOS7.
- if (screen->uiScreen() == [UIScreen mainScreen]
- && iosVersion >= QSysInfo::MV_IOS_6_0 && iosVersion < QSysInfo::MV_IOS_7_0
- && [UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone
- && [UIApplication sharedApplication].statusBarStyle == UIStatusBarStyleDefault)
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
-#endif
- self.lockedOrientation = UIInterfaceOrientationUnknown;
self.changingOrientation = NO;
+#ifndef Q_OS_TVOS
+ self.lockedOrientation = UIInterfaceOrientationUnknown;
// Status bar may be initially hidden at startup through Info.plist
self.prefersStatusBarHidden = infoPlistValue(@"UIStatusBarHidden", false);
self.preferredStatusBarUpdateAnimation = UIStatusBarAnimationNone;
self.preferredStatusBarStyle = UIStatusBarStyle(infoPlistValue(@"UIStatusBarStyle", UIStatusBarStyleDefault));
+#endif
m_focusWindowChangeConnection = QObject::connect(qApp, &QGuiApplication::focusWindowChanged, [self]() {
[self updateProperties];
@@ -284,6 +268,7 @@
{
[super viewDidLoad];
+#ifndef Q_OS_TVOS
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self selector:@selector(willChangeStatusBarFrame:)
name:UIApplicationWillChangeStatusBarFrameNotification
@@ -292,6 +277,7 @@
[center addObserver:self selector:@selector(didChangeStatusBarOrientation:)
name:UIApplicationDidChangeStatusBarOrientationNotification
object:[UIApplication sharedApplication]];
+#endif
}
- (void)viewDidUnload
@@ -304,10 +290,13 @@
- (BOOL)shouldAutorotate
{
+#ifndef Q_OS_TVOS
return m_screen && m_screen->uiScreen() == [UIScreen mainScreen] && !self.lockedOrientation;
+#else
+ return NO;
+#endif
}
-#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_6_0)
- (NSUInteger)supportedInterfaceOrientations
{
// As documented by Apple in the iOS 6.0 release notes, setStatusBarOrientation:animated:
@@ -318,15 +307,6 @@
// supportedInterfaceOrientations says, which states that the method should not return 0.
return [self shouldAutorotate] ? UIInterfaceOrientationMaskAll : 0;
}
-#endif
-
-#if QT_IOS_DEPLOYMENT_TARGET_BELOW(__IPHONE_6_0)
-- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
-{
- Q_UNUSED(interfaceOrientation);
- return [self shouldAutorotate];
-}
-#endif
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)orientation duration:(NSTimeInterval)duration
{
@@ -435,6 +415,7 @@
// All decisions are based on the the top level window
focusWindow = qt_window_private(focusWindow)->topLevelWindow();
+#ifndef Q_OS_TVOS
UIApplication *uiApplication = [UIApplication sharedApplication];
// -------------- Status bar style and visbility ---------------
@@ -443,30 +424,16 @@
if (focusWindow->flags() & Qt::MaximizeUsingFullscreenGeometryHint)
self.preferredStatusBarStyle = UIStatusBarStyleDefault;
else
- self.preferredStatusBarStyle = QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_7_0 ?
- UIStatusBarStyleLightContent : UIStatusBarStyleBlackTranslucent;
-
- if (self.preferredStatusBarStyle != oldStatusBarStyle) {
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_7_0)
- [self setNeedsStatusBarAppearanceUpdate];
- else
- [uiApplication setStatusBarStyle:self.preferredStatusBarStyle];
- }
+ self.preferredStatusBarStyle = UIStatusBarStyleLightContent;
+
+ if (self.preferredStatusBarStyle != oldStatusBarStyle)
+ [self setNeedsStatusBarAppearanceUpdate];
bool currentStatusBarVisibility = self.prefersStatusBarHidden;
self.prefersStatusBarHidden = focusWindow->windowState() == Qt::WindowFullScreen;
if (self.prefersStatusBarHidden != currentStatusBarVisibility) {
-#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_7_0)
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_IOS_7_0) {
- [self setNeedsStatusBarAppearanceUpdate];
- } else
-#endif
- {
- [uiApplication setStatusBarHidden:self.prefersStatusBarHidden
- withAnimation:self.preferredStatusBarUpdateAnimation];
- }
-
+ [self setNeedsStatusBarAppearanceUpdate];
[self.view setNeedsLayout];
}
@@ -512,6 +479,7 @@
[UIViewController attemptRotationToDeviceOrientation];
}
}
+#endif
}
@end
diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm
index ddf856d7a4..cddfbe6b06 100644
--- a/src/plugins/platforms/ios/qioswindow.mm
+++ b/src/plugins/platforms/ios/qioswindow.mm
@@ -211,7 +211,7 @@ void QIOSWindow::applyGeometry(const QRect &rect)
// The baseclass takes care of persisting this for us.
QPlatformWindow::setGeometry(rect);
- m_view.frame = toCGRect(rect);
+ m_view.frame = rect.toCGRect();
// iOS will automatically trigger -[layoutSubviews:] for resize,
// but not for move, so we force it just in case.
diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm
index e38be68343..9f910dfe5e 100644
--- a/src/plugins/platforms/ios/quiview.mm
+++ b/src/plugins/platforms/ios/quiview.mm
@@ -44,10 +44,13 @@
#include "qiosviewcontroller.h"
#include "qiostextresponder.h"
#include "qioswindow.h"
+#ifndef Q_OS_TVOS
#include "qiosmenu.h"
+#endif
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/private/qwindow_p.h>
+#include <qpa/qwindowsysteminterface_p.h>
@implementation QUIView
@@ -58,7 +61,7 @@
- (id)initWithQIOSWindow:(QIOSWindow *)window
{
- if (self = [self initWithFrame:toCGRect(window->geometry())])
+ if (self = [self initWithFrame:window->geometry().toCGRect()])
m_qioswindow = window;
m_accessibleElements = [[NSMutableArray alloc] init];
@@ -78,7 +81,9 @@
if (isQtApplication())
self.hidden = YES;
+#ifndef Q_OS_TVOS
self.multipleTouchEnabled = YES;
+#endif
if (QIOSIntegration::instance()->debugWindowManagement()) {
static CGFloat hue = 0.0;
@@ -149,7 +154,7 @@
// from what we end up with after applying window constraints.
QRect requestedGeometry = m_qioswindow->geometry();
- QRect actualGeometry = fromCGRect(self.frame).toRect();
+ QRect actualGeometry = QRectF::fromCGRect(self.frame).toRect();
// Persist the actual/new geometry so that QWindow::geometry() can
// be queried on the resize event.
@@ -184,7 +189,7 @@
QRegion region;
if (m_qioswindow->isExposed()) {
- QSize bounds = fromCGRect(self.layer.bounds).toRect().size();
+ QSize bounds = QRectF::fromCGRect(self.layer.bounds).toRect().size();
Q_ASSERT(m_qioswindow->geometry().size() == bounds);
Q_ASSERT(self.hidden == !m_qioswindow->window()->isVisible());
@@ -324,7 +329,8 @@
// Touch positions are expected to be in QScreen global coordinates, and
// as we already have the QWindow positioned at the right place, we can
// just map from the local view position to global coordinates.
- QPoint localViewPosition = fromCGPoint([uiTouch locationInView:self]).toPoint();
+ // tvOS: all touches start at the center of the screen and move from there.
+ QPoint localViewPosition = QPointF::fromCGPoint([uiTouch locationInView:self]).toPoint();
QPoint globalScreenPosition = m_qioswindow->mapToGlobal(localViewPosition);
touchPoint.area = QRectF(globalScreenPosition, QSize(0, 0));
@@ -437,16 +443,78 @@
QWindowSystemInterface::flushWindowSystemEvents();
}
+- (int)mapPressTypeToKey:(UIPress*)press
+{
+ switch (press.type) {
+ case UIPressTypeUpArrow: return Qt::Key_Up;
+ case UIPressTypeDownArrow: return Qt::Key_Down;
+ case UIPressTypeLeftArrow: return Qt::Key_Left;
+ case UIPressTypeRightArrow: return Qt::Key_Right;
+ case UIPressTypeSelect: return Qt::Key_Select;
+ case UIPressTypeMenu: return Qt::Key_Menu;
+ case UIPressTypePlayPause: return Qt::Key_MediaTogglePlayPause;
+ }
+ return Qt::Key_unknown;
+}
+
+- (bool)processPresses:(NSSet *)presses withType:(QEvent::Type)type {
+ // Presses on Menu button will generate a Menu key event. By default, not handling
+ // this event will cause the application to return to Headboard (tvOS launcher).
+ // When handling the event (for example, as a back button), both press and
+ // release events must be handled accordingly.
+
+ QScopedValueRollback<bool> syncRollback(QWindowSystemInterfacePrivate::synchronousWindowSystemEvents, true);
+
+ bool handled = false;
+ for (UIPress* press in presses) {
+ int key = [self mapPressTypeToKey:press];
+ if (key == Qt::Key_unknown)
+ continue;
+ if (QWindowSystemInterface::handleKeyEvent(m_qioswindow->window(), type, key, Qt::NoModifier))
+ handled = true;
+ }
+
+ return handled;
+}
+
+- (void)pressesBegan:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event
+{
+ if (![self processPresses:presses withType:QEvent::KeyPress])
+ [super pressesBegan:presses withEvent:event];
+}
+
+- (void)pressesChanged:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event
+{
+ if (![self processPresses:presses withType:QEvent::KeyPress])
+ [super pressesChanged:presses withEvent:event];
+}
+
+- (void)pressesEnded:(NSSet<UIPress *> *)presses withEvent:(UIPressesEvent *)event
+{
+ if (![self processPresses:presses withType:QEvent::KeyRelease])
+ [super pressesEnded:presses withEvent:event];
+}
+
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
+#ifndef Q_OS_TVOS
// Check first if QIOSMenu should handle the action before continuing up the responder chain
return [QIOSMenu::menuActionTarget() targetForAction:action withSender:sender] != 0;
+#else
+ Q_UNUSED(action)
+ Q_UNUSED(sender)
+ return false;
+#endif
}
- (id)forwardingTargetForSelector:(SEL)selector
{
Q_UNUSED(selector)
+#ifndef Q_OS_TVOS
return QIOSMenu::menuActionTarget();
+#else
+ return nil;
+#endif
}
@end
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
index 1fd2b84e37..6ca651fdf7 100644
--- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
+++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
@@ -412,11 +412,9 @@ QRegion QLinuxFbScreen::doRedraw()
if (!mBlitter)
mBlitter = new QPainter(&mFbScreenImage);
- const QVector<QRect> rects = touched.rects();
mBlitter->setCompositionMode(QPainter::CompositionMode_Source);
-
- for (int i = 0; i < rects.size(); ++i)
- mBlitter->drawImage(rects[i], *mScreenImage, rects[i]);
+ for (const QRect &rect : touched)
+ mBlitter->drawImage(rect, *mScreenImage, rect);
return touched;
}
diff --git a/src/plugins/platforms/mirclient/qmirclientbackingstore.cpp b/src/plugins/platforms/mirclient/qmirclientbackingstore.cpp
index 465ad355b9..a4bb8864ab 100644
--- a/src/plugins/platforms/mirclient/qmirclientbackingstore.cpp
+++ b/src/plugins/platforms/mirclient/qmirclientbackingstore.cpp
@@ -43,7 +43,7 @@
#include <QtGui/QOpenGLContext>
#include <QtGui/QOpenGLTexture>
#include <QtGui/QMatrix4x4>
-#include <QtGui/private/qopengltextureblitter_p.h>
+#include <QtGui/qopengltextureblitter.h>
#include <QtGui/qopenglfunctions.h>
QMirClientBackingStore::QMirClientBackingStore(QWindow* window)
@@ -76,7 +76,7 @@ void QMirClientBackingStore::flush(QWindow* window, const QRegion& region, const
mBlitter->create();
mBlitter->bind();
- mBlitter->setSwizzleRB(true);
+ mBlitter->setRedBlueSwizzle(true);
mBlitter->blit(mTexture->textureId(), QMatrix4x4(), QOpenGLTextureBlitter::OriginTopLeft);
mBlitter->release();
@@ -100,7 +100,7 @@ void QMirClientBackingStore::updateTexture()
QRegion fixed;
QRect imageRect = mImage.rect();
- Q_FOREACH (const QRect &rect, mDirty.rects()) {
+ for (const QRect &rect : mDirty) {
// intersect with image rect to be sure
QRect r = imageRect & rect;
@@ -113,7 +113,7 @@ void QMirClientBackingStore::updateTexture()
fixed |= r;
}
- Q_FOREACH (const QRect &rect, fixed.rects()) {
+ for (const QRect &rect : fixed) {
// if the sub-rect is full-width we can pass the image data directly to
// OpenGL instead of copying, since there is no gap between scanlines
if (rect.width() == imageRect.width()) {
diff --git a/src/plugins/platforms/offscreen/qoffscreencommon.cpp b/src/plugins/platforms/offscreen/qoffscreencommon.cpp
index ed1a81c2b3..a63aacdbfe 100644
--- a/src/plugins/platforms/offscreen/qoffscreencommon.cpp
+++ b/src/plugins/platforms/offscreen/qoffscreencommon.cpp
@@ -179,9 +179,8 @@ bool QOffscreenBackingStore::scroll(const QRegion &area, int dx, int dy)
if (m_image.isNull())
return false;
- const QVector<QRect> rects = area.rects();
- for (int i = 0; i < rects.size(); ++i)
- qt_scrollRectInImage(m_image, rects.at(i), QPoint(dx, dy));
+ for (const QRect &rect : area)
+ qt_scrollRectInImage(m_image, rect, QPoint(dx, dy));
return true;
}
diff --git a/src/plugins/platforms/platforms.pro b/src/plugins/platforms/platforms.pro
index a5b64636af..4bed5312ec 100644
--- a/src/plugins/platforms/platforms.pro
+++ b/src/plugins/platforms/platforms.pro
@@ -10,10 +10,8 @@ contains(QT_CONFIG, xcb) {
SUBDIRS += xcb
}
-mac {
- ios: SUBDIRS += ios
- else: SUBDIRS += cocoa
-}
+uikit: SUBDIRS += ios
+osx: SUBDIRS += cocoa
win32:!winrt: SUBDIRS += windows
winrt: SUBDIRS += winrt
@@ -37,6 +35,12 @@ contains(QT_CONFIG, directfb) {
contains(QT_CONFIG, linuxfb): SUBDIRS += linuxfb
+unix:!android:!darwin: SUBDIRS += vnc
+
+freebsd {
+ SUBDIRS += bsdfb
+}
+
haiku {
SUBDIRS += haiku
}
diff --git a/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp b/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp
index a08ac2b839..90a09d3087 100644
--- a/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp
+++ b/src/plugins/platforms/qnx/qqnxbuttoneventnotifier.cpp
@@ -97,7 +97,7 @@ void QQnxButtonEventNotifier::start()
m_readNotifier = new QSocketNotifier(m_fd, QSocketNotifier::Read);
QObject::connect(m_readNotifier, SIGNAL(activated(int)), this, SLOT(updateButtonStates()));
- qButtonDebug() << "successfully connected to Navigator. fd =" << m_fd;
+ qButtonDebug("successfully connected to Navigator. fd = %d", m_fd);
}
void QQnxButtonEventNotifier::updateButtonStates()
@@ -121,7 +121,7 @@ void QQnxButtonEventNotifier::updateButtonStates()
// Ensure data is null terminated
buffer[bytes] = '\0';
- qButtonDebug() << "received PPS message:\n" << buffer;
+ qButtonDebug("received PPS message:\n%s", buffer);
// Process received message
QByteArray ppsData = QByteArray::fromRawData(buffer, bytes);
diff --git a/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp b/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp
index 79ff74b113..ce3a445d7c 100644
--- a/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp
+++ b/src/plugins/platforms/qnx/qqnxinputcontext_imf.cpp
@@ -721,7 +721,7 @@ void QQnxInputContext::update(Qt::InputMethodQueries queries)
initEvent(&caretEvent.event, sInputSession, EVENT_CARET, CARET_POS_CHANGED, sizeof(caretEvent));
caretEvent.old_pos = lastCaret;
caretEvent.new_pos = m_caretPosition;
- qInputContextDebug() << "ictrl_dispatch_event caret changed" << lastCaret << m_caretPosition;
+ qInputContextDebug("ictrl_dispatch_event caret changed %d %d", lastCaret, m_caretPosition);
p_ictrl_dispatch_event(&caretEvent.event);
}
}
@@ -914,7 +914,7 @@ bool QQnxInputContext::handleKeyboardEvent(int flags, int sym, int mod, int scan
navigation_event_t navEvent;
initEvent(&navEvent.event, sInputSession, EVENT_NAVIGATION, key, sizeof(navEvent));
navEvent.magnitude = 1;
- qInputContextDebug() << "ictrl_dispatch_even navigation" << key;
+ qInputContextDebug("ictrl_dispatch_even navigation %d", key);
p_ictrl_dispatch_event(&navEvent.event);
}
} else {
@@ -927,7 +927,7 @@ bool QQnxInputContext::handleKeyboardEvent(int flags, int sym, int mod, int scan
keyEvent.sequence_id = sequenceId;
p_ictrl_dispatch_event(&keyEvent.event);
- qInputContextDebug() << "ictrl_dispatch_even key" << key;
+ qInputContextDebug("ictrl_dispatch_even key %d", key);
}
return true;
@@ -943,7 +943,7 @@ void QQnxInputContext::updateCursorPosition()
QCoreApplication::sendEvent(input, &query);
m_caretPosition = query.value(Qt::ImCursorPosition).toInt();
- qInputContextDebug() << m_caretPosition;
+ qInputContextDebug("%d", m_caretPosition);
}
void QQnxInputContext::endComposition()
@@ -1116,7 +1116,7 @@ int32_t QQnxInputContext::processEvent(event_t *event)
int flags = KEY_SYM_VALID | KEY_CAP_VALID;
if (event->event_id == IMF_KEY_DOWN)
flags |= KEY_DOWN;
- qInputContextDebug() << "EVENT_KEY" << flags << keySym;
+ qInputContextDebug("EVENT_KEY %d %d", flags, keySym);
QQnxScreenEventHandler::injectKeyboardEvent(flags, keySym, modifiers, 0, keyCap);
result = 0;
break;
@@ -1156,7 +1156,7 @@ int32_t QQnxInputContext::onCommitText(spannable_string_t *text, int32_t new_cur
int32_t QQnxInputContext::onDeleteSurroundingText(int32_t left_length, int32_t right_length)
{
- qInputContextDebug() << "L:" << left_length << " R:" << right_length;
+ qInputContextDebug("L: %d R: %d", int(left_length), int(right_length));
QObject *input = qGuiApp->focusObject();
if (!input)
diff --git a/src/plugins/platforms/qnx/qqnxintegration.cpp b/src/plugins/platforms/qnx/qqnxintegration.cpp
index 3a0e97af6e..9d38742d6f 100644
--- a/src/plugins/platforms/qnx/qqnxintegration.cpp
+++ b/src/plugins/platforms/qnx/qqnxintegration.cpp
@@ -453,11 +453,11 @@ void QQnxIntegration::createDisplays()
Q_SCREEN_CHECKERROR(result, "Failed to query display attachment");
if (!isAttached) {
- qIntegrationDebug() << "Skipping non-attached display" << i;
+ qIntegrationDebug("Skipping non-attached display %d", i);
continue;
}
- qIntegrationDebug() << "Creating screen for display" << i;
+ qIntegrationDebug("Creating screen for display %d", i);
createDisplay(displays[i], /*isPrimary=*/false);
} // of displays iteration
}
diff --git a/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp b/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp
index 4955938a3a..0e16764b79 100644
--- a/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp
+++ b/src/plugins/platforms/qnx/qqnxnavigatoreventhandler.cpp
@@ -63,14 +63,14 @@ bool QQnxNavigatorEventHandler::handleOrientationCheck(int angle)
{
// reply to navigator that (any) orientation is acceptable
// TODO: check if top window flags prohibit orientation change
- qNavigatorEventHandlerDebug() << "angle=" << angle;
+ qNavigatorEventHandlerDebug("angle=%d", angle);
return true;
}
void QQnxNavigatorEventHandler::handleOrientationChange(int angle)
{
// update screen geometry and reply to navigator that we're ready
- qNavigatorEventHandlerDebug() << "angle=" << angle;
+ qNavigatorEventHandlerDebug("angle=%d", angle);
emit rotationChanged(angle);
}
diff --git a/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp b/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp
index 9ccda2d94a..1f630863b7 100644
--- a/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp
+++ b/src/plugins/platforms/qnx/qqnxnavigatoreventnotifier.cpp
@@ -91,8 +91,7 @@ void QQnxNavigatorEventNotifier::start()
errno = 0;
m_fd = open(navigatorControlPath, O_RDWR);
if (m_fd == -1) {
- qNavigatorEventNotifierDebug() << "failed to open navigator pps:"
- << strerror(errno);
+ qNavigatorEventNotifierDebug("failed to open navigator pps: %s", strerror(errno));
return;
}
diff --git a/src/plugins/platforms/qnx/qqnxnavigatorpps.cpp b/src/plugins/platforms/qnx/qqnxnavigatorpps.cpp
index fd1bbc4a85..d5234ca92f 100644
--- a/src/plugins/platforms/qnx/qqnxnavigatorpps.cpp
+++ b/src/plugins/platforms/qnx/qqnxnavigatorpps.cpp
@@ -79,7 +79,7 @@ bool QQnxNavigatorPps::openPpsConnection()
return false;
}
- qNavigatorDebug() << "successfully connected to Navigator. fd=" << m_fd;
+ qNavigatorDebug("successfully connected to Navigator. fd=%d", m_fd);
return true;
}
diff --git a/src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp b/src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp
index c9a89def41..a758bdf7f4 100644
--- a/src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp
+++ b/src/plugins/platforms/qnx/qqnxrasterbackingstore.cpp
@@ -139,7 +139,7 @@ void QQnxRasterBackingStore::beginPaint(const QRegion &region)
platformWindow()->adjustBufferSize();
if (window()->requestedFormat().alphaBufferSize() > 0) {
- foreach (const QRect &r, region.rects()) {
+ for (const QRect &r : region) {
// Clear transparent regions
const int bg[] = {
SCREEN_BLIT_COLOR, 0x00000000,
diff --git a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp
index 3ac3d23c88..7f11de228e 100644
--- a/src/plugins/platforms/qnx/qqnxrasterwindow.cpp
+++ b/src/plugins/platforms/qnx/qqnxrasterwindow.cpp
@@ -215,10 +215,9 @@ void QQnxRasterWindow::blitPreviousToCurrent(const QRegion &region, int dx, int
QQnxBuffer &previousBuffer = m_buffers[m_previousBufferIndex];
// Break down region into non-overlapping rectangles
- const QVector<QRect> rects = region.rects();
- for (int i = rects.size() - 1; i >= 0; i--) {
+ for (auto rit = region.rbegin(), rend = region.rend(); rit != rend; ++rit) {
// Clip rectangle to bounds of target
- const QRect rect = rects[i].intersected(currentBuffer.rect());
+ const QRect rect = rit->intersected(currentBuffer.rect());
if (rect.isEmpty())
continue;
diff --git a/src/plugins/platforms/qnx/qqnxscreen.cpp b/src/plugins/platforms/qnx/qqnxscreen.cpp
index 16ddcd784b..f8ae5121d1 100644
--- a/src/plugins/platforms/qnx/qqnxscreen.cpp
+++ b/src/plugins/platforms/qnx/qqnxscreen.cpp
@@ -340,11 +340,12 @@ qreal QQnxScreen::refreshRate() const
qWarning("QQnxScreen: Failed to query screen mode. Using default value of 60Hz");
return 60.0;
}
- qScreenDebug() << "screen mode:" << endl
- << " width =" << displayMode.width << endl
- << " height =" << displayMode.height << endl
- << " refresh =" << displayMode.refresh << endl
- << " interlaced =" << displayMode.interlaced;
+ qScreenDebug("screen mode:\n"
+ " width = %u\n"
+ " height = %u\n"
+ " refresh = %u\n"
+ " interlaced = %u",
+ uint(displayMode.width), uint(displayMode.height), uint(displayMode.refresh), uint(displayMode.interlaced));
return static_cast<qreal>(displayMode.refresh);
}
@@ -384,10 +385,8 @@ Qt::ScreenOrientation QQnxScreen::orientation() const
QWindow *QQnxScreen::topLevelAt(const QPoint &point) const
{
- QListIterator<QQnxWindow*> it(m_childWindows);
- it.toBack();
- while (it.hasPrevious()) {
- QWindow *win = it.previous()->window();
+ for (auto it = m_childWindows.rbegin(), end = m_childWindows.rend(); it != end; ++it) {
+ QWindow *win = (*it)->window();
if (win->geometry().contains(point))
return win;
}
@@ -404,7 +403,7 @@ static bool isOrthogonal(int angle1, int angle2)
void QQnxScreen::setRotation(int rotation)
{
- qScreenDebug() << "orientation =" << rotation;
+ qScreenDebug("orientation = %d", rotation);
// Check if rotation changed
// We only want to rotate if we are the primary screen
if (m_currentRotation != rotation && isPrimaryScreen()) {
diff --git a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
index 599d43a8c8..42651732c2 100644
--- a/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
+++ b/src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
@@ -147,7 +147,7 @@ bool QQnxScreenEventHandler::handleEvent(screen_event_t event, int qnxType)
default:
// event ignored
- qScreenEventDebug() << "unknown event" << qnxType;
+ qScreenEventDebug("unknown event %d", qnxType);
return false;
}
diff --git a/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp b/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp
index 1174dc6ab3..025c03c058 100644
--- a/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp
+++ b/src/plugins/platforms/qnx/qqnxvirtualkeyboardpps.cpp
@@ -164,7 +164,7 @@ void QQnxVirtualKeyboardPps::ppsDataReady()
{
ssize_t nread = qt_safe_read(m_fd, m_buffer, ms_bufferSize - 1);
- qVirtualKeyboardDebug() << "keyboardMessage size: " << nread;
+ qVirtualKeyboardDebug("keyboardMessage size: %zd", nread);
if (nread < 0){
connect(); // reconnect
return;
@@ -230,7 +230,7 @@ void QQnxVirtualKeyboardPps::handleKeyboardInfoMessage()
}
setHeight(newHeight);
- qVirtualKeyboardDebug() << "size=" << newHeight;
+ qVirtualKeyboardDebug("size=%d", newHeight);
}
bool QQnxVirtualKeyboardPps::showKeyboard()
diff --git a/src/gui/image/qnativeimage.cpp b/src/plugins/platforms/vnc/main.cpp
index 38e67761b1..6ee8bf1ec6 100644
--- a/src/gui/image/qnativeimage.cpp
+++ b/src/plugins/platforms/vnc/main.cpp
@@ -37,36 +37,29 @@
**
****************************************************************************/
-#include <qdebug.h>
-#include "qnativeimage_p.h"
-#include <qpa/qplatformscreen.h>
-#include "private/qguiapplication_p.h"
-#include "qscreen.h"
-
-#include "private/qpaintengine_raster_p.h"
-
+#include <qpa/qplatformintegrationplugin.h>
+#include "qvncintegration.h"
+#include "qvnc_p.h"
QT_BEGIN_NAMESPACE
-
-QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool /* isTextBuffer */, QWindow *)
- : image(width, height, format)
+class QVncIntegrationPlugin : public QPlatformIntegrationPlugin
{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "vnc.json")
+public:
+ QPlatformIntegration *create(const QString&, const QStringList&) Q_DECL_OVERRIDE;
+};
-}
-
-
-QNativeImage::~QNativeImage()
+QPlatformIntegration* QVncIntegrationPlugin::create(const QString& system, const QStringList& paramList)
{
-}
+ if (!system.compare(QLatin1String("vnc"), Qt::CaseInsensitive))
+ return new QVncIntegration(paramList);
-QImage::Format QNativeImage::systemFormat()
-{
- if (!QGuiApplication::primaryScreen())
- return QImage::Format_Invalid;
- return QGuiApplication::primaryScreen()->handle()->format();
+ return 0;
}
-
QT_END_NAMESPACE
+#include "main.moc"
+
diff --git a/src/plugins/platforms/vnc/qvnc.cpp b/src/plugins/platforms/vnc/qvnc.cpp
new file mode 100644
index 0000000000..b3613cf18f
--- /dev/null
+++ b/src/plugins/platforms/vnc/qvnc.cpp
@@ -0,0 +1,680 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qvnc_p.h"
+#include "qvncscreen.h"
+#include "qvncclient.h"
+#include "QtNetwork/qtcpserver.h"
+#include "QtNetwork/qtcpsocket.h"
+#include <qthread.h>
+
+#include <QtGui/qguiapplication.h>
+#include <QtGui/QWindow>
+
+#ifdef Q_OS_WIN
+#include <Winsock2.h>
+#else
+#include <arpa/inet.h>
+#endif
+
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+Q_LOGGING_CATEGORY(lcVnc, "qt.qpa.vnc");
+
+QVncDirtyMap::QVncDirtyMap(QVncScreen *screen)
+ : screen(screen), bytesPerPixel(0), numDirty(0)
+{
+ bytesPerPixel = (screen->depth() + 7) / 8;
+ bufferWidth = screen->geometry().width();
+ bufferHeight = screen->geometry().height();
+ bufferStride = bufferWidth * bytesPerPixel;
+ buffer = new uchar[bufferHeight * bufferStride];
+
+ mapWidth = (bufferWidth + MAP_TILE_SIZE - 1) / MAP_TILE_SIZE;
+ mapHeight = (bufferHeight + MAP_TILE_SIZE - 1) / MAP_TILE_SIZE;
+ numTiles = mapWidth * mapHeight;
+ map = new uchar[numTiles];
+}
+
+QVncDirtyMap::~QVncDirtyMap()
+{
+ delete[] map;
+ delete[] buffer;
+}
+
+void QVncDirtyMap::reset()
+{
+ memset(map, 1, numTiles);
+ memset(buffer, 0, bufferHeight * bufferStride);
+ numDirty = numTiles;
+}
+
+inline bool QVncDirtyMap::dirty(int x, int y) const
+{
+ return map[y * mapWidth + x];
+}
+
+inline void QVncDirtyMap::setClean(int x, int y)
+{
+ map[y * mapWidth + x] = 0;
+ --numDirty;
+}
+
+template <class T>
+void QVncDirtyMapOptimized<T>::setDirty(int tileX, int tileY, bool force)
+{
+ static bool alwaysForce = qEnvironmentVariableIsSet("QT_VNC_NO_COMPAREBUFFER");
+ if (alwaysForce)
+ force = true;
+
+ bool changed = false;
+
+ if (!force) {
+ const int lstep = bufferStride;
+ const int startX = tileX * MAP_TILE_SIZE;
+ const int startY = tileY * MAP_TILE_SIZE;
+ const uchar *scrn = screen->image()->constBits()
+ + startY * lstep + startX * bytesPerPixel;
+ uchar *old = buffer + startY * bufferStride + startX * sizeof(T);
+
+ const int tileHeight = (startY + MAP_TILE_SIZE > bufferHeight ?
+ bufferHeight - startY : MAP_TILE_SIZE);
+ const int tileWidth = (startX + MAP_TILE_SIZE > bufferWidth ?
+ bufferWidth - startX : MAP_TILE_SIZE);
+ const bool doInlines = (tileWidth == MAP_TILE_SIZE);
+
+ int y = tileHeight;
+
+ if (doInlines) { // hw: memcmp/memcpy is inlined when using constants
+ while (y) {
+ if (memcmp(old, scrn, sizeof(T) * MAP_TILE_SIZE)) {
+ changed = true;
+ break;
+ }
+ scrn += lstep;
+ old += bufferStride;
+ --y;
+ }
+
+ while (y) {
+ memcpy(old, scrn, sizeof(T) * MAP_TILE_SIZE);
+ scrn += lstep;
+ old += bufferStride;
+ --y;
+ }
+ } else {
+ while (y) {
+ if (memcmp(old, scrn, sizeof(T) * tileWidth)) {
+ changed = true;
+ break;
+ }
+ scrn += lstep;
+ old += bufferStride;
+ --y;
+ }
+
+ while (y) {
+ memcpy(old, scrn, sizeof(T) * tileWidth);
+ scrn += lstep;
+ old += bufferStride;
+ --y;
+ }
+ }
+ }
+
+ const int mapIndex = tileY * mapWidth + tileX;
+ if ((force || changed) && !map[mapIndex]) {
+ map[mapIndex] = 1;
+ ++numDirty;
+ }
+}
+
+template class QVncDirtyMapOptimized<unsigned char>;
+template class QVncDirtyMapOptimized<unsigned short>;
+template class QVncDirtyMapOptimized<unsigned int>;
+
+static const struct {
+ int keysym;
+ int keycode;
+} keyMap[] = {
+ { 0xff08, Qt::Key_Backspace },
+ { 0xff09, Qt::Key_Tab },
+ { 0xff0d, Qt::Key_Return },
+ { 0xff1b, Qt::Key_Escape },
+ { 0xff63, Qt::Key_Insert },
+ { 0xffff, Qt::Key_Delete },
+ { 0xff50, Qt::Key_Home },
+ { 0xff57, Qt::Key_End },
+ { 0xff55, Qt::Key_PageUp },
+ { 0xff56, Qt::Key_PageDown },
+ { 0xff51, Qt::Key_Left },
+ { 0xff52, Qt::Key_Up },
+ { 0xff53, Qt::Key_Right },
+ { 0xff54, Qt::Key_Down },
+ { 0xffbe, Qt::Key_F1 },
+ { 0xffbf, Qt::Key_F2 },
+ { 0xffc0, Qt::Key_F3 },
+ { 0xffc1, Qt::Key_F4 },
+ { 0xffc2, Qt::Key_F5 },
+ { 0xffc3, Qt::Key_F6 },
+ { 0xffc4, Qt::Key_F7 },
+ { 0xffc5, Qt::Key_F8 },
+ { 0xffc6, Qt::Key_F9 },
+ { 0xffc7, Qt::Key_F10 },
+ { 0xffc8, Qt::Key_F11 },
+ { 0xffc9, Qt::Key_F12 },
+ { 0xffe1, Qt::Key_Shift },
+ { 0xffe2, Qt::Key_Shift },
+ { 0xffe3, Qt::Key_Control },
+ { 0xffe4, Qt::Key_Control },
+ { 0xffe7, Qt::Key_Meta },
+ { 0xffe8, Qt::Key_Meta },
+ { 0xffe9, Qt::Key_Alt },
+ { 0xffea, Qt::Key_Alt },
+
+ { 0xffb0, Qt::Key_0 },
+ { 0xffb1, Qt::Key_1 },
+ { 0xffb2, Qt::Key_2 },
+ { 0xffb3, Qt::Key_3 },
+ { 0xffb4, Qt::Key_4 },
+ { 0xffb5, Qt::Key_5 },
+ { 0xffb6, Qt::Key_6 },
+ { 0xffb7, Qt::Key_7 },
+ { 0xffb8, Qt::Key_8 },
+ { 0xffb9, Qt::Key_9 },
+
+ { 0xff8d, Qt::Key_Return },
+ { 0xffaa, Qt::Key_Asterisk },
+ { 0xffab, Qt::Key_Plus },
+ { 0xffad, Qt::Key_Minus },
+ { 0xffae, Qt::Key_Period },
+ { 0xffaf, Qt::Key_Slash },
+
+ { 0xff95, Qt::Key_Home },
+ { 0xff96, Qt::Key_Left },
+ { 0xff97, Qt::Key_Up },
+ { 0xff98, Qt::Key_Right },
+ { 0xff99, Qt::Key_Down },
+ { 0xff9a, Qt::Key_PageUp },
+ { 0xff9b, Qt::Key_PageDown },
+ { 0xff9c, Qt::Key_End },
+ { 0xff9e, Qt::Key_Insert },
+ { 0xff9f, Qt::Key_Delete },
+
+ { 0, 0 }
+};
+
+void QRfbRect::read(QTcpSocket *s)
+{
+ quint16 buf[4];
+ s->read((char*)buf, 8);
+ x = ntohs(buf[0]);
+ y = ntohs(buf[1]);
+ w = ntohs(buf[2]);
+ h = ntohs(buf[3]);
+}
+
+void QRfbRect::write(QTcpSocket *s) const
+{
+ quint16 buf[4];
+ buf[0] = htons(x);
+ buf[1] = htons(y);
+ buf[2] = htons(w);
+ buf[3] = htons(h);
+ s->write((char*)buf, 8);
+}
+
+void QRfbPixelFormat::read(QTcpSocket *s)
+{
+ char buf[16];
+ s->read(buf, 16);
+ bitsPerPixel = buf[0];
+ depth = buf[1];
+ bigEndian = buf[2];
+ trueColor = buf[3];
+
+ quint16 a = ntohs(*(quint16 *)(buf + 4));
+ redBits = 0;
+ while (a) { a >>= 1; redBits++; }
+
+ a = ntohs(*(quint16 *)(buf + 6));
+ greenBits = 0;
+ while (a) { a >>= 1; greenBits++; }
+
+ a = ntohs(*(quint16 *)(buf + 8));
+ blueBits = 0;
+ while (a) { a >>= 1; blueBits++; }
+
+ redShift = buf[10];
+ greenShift = buf[11];
+ blueShift = buf[12];
+}
+
+void QRfbPixelFormat::write(QTcpSocket *s)
+{
+ char buf[16];
+ buf[0] = bitsPerPixel;
+ buf[1] = depth;
+ buf[2] = bigEndian;
+ buf[3] = trueColor;
+
+ quint16 a = 0;
+ for (int i = 0; i < redBits; i++) a = (a << 1) | 1;
+ *(quint16 *)(buf + 4) = htons(a);
+
+ a = 0;
+ for (int i = 0; i < greenBits; i++) a = (a << 1) | 1;
+ *(quint16 *)(buf + 6) = htons(a);
+
+ a = 0;
+ for (int i = 0; i < blueBits; i++) a = (a << 1) | 1;
+ *(quint16 *)(buf + 8) = htons(a);
+
+ buf[10] = redShift;
+ buf[11] = greenShift;
+ buf[12] = blueShift;
+ s->write(buf, 16);
+}
+
+
+void QRfbServerInit::setName(const char *n)
+{
+ delete[] name;
+ name = new char [strlen(n) + 1];
+ strcpy(name, n);
+}
+
+void QRfbServerInit::read(QTcpSocket *s)
+{
+ s->read((char *)&width, 2);
+ width = ntohs(width);
+ s->read((char *)&height, 2);
+ height = ntohs(height);
+ format.read(s);
+
+ quint32 len;
+ s->read((char *)&len, 4);
+ len = ntohl(len);
+
+ name = new char [len + 1];
+ s->read(name, len);
+ name[len] = '\0';
+}
+
+void QRfbServerInit::write(QTcpSocket *s)
+{
+ quint16 t = htons(width);
+ s->write((char *)&t, 2);
+ t = htons(height);
+ s->write((char *)&t, 2);
+ format.write(s);
+ quint32 len = strlen(name);
+ len = htonl(len);
+ s->write((char *)&len, 4);
+ s->write(name, strlen(name));
+}
+
+bool QRfbSetEncodings::read(QTcpSocket *s)
+{
+ if (s->bytesAvailable() < 3)
+ return false;
+
+ char tmp;
+ s->read(&tmp, 1); // padding
+ s->read((char *)&count, 2);
+ count = ntohs(count);
+
+ return true;
+}
+
+bool QRfbFrameBufferUpdateRequest::read(QTcpSocket *s)
+{
+ if (s->bytesAvailable() < 9)
+ return false;
+
+ s->read(&incremental, 1);
+ rect.read(s);
+
+ return true;
+}
+
+bool QRfbKeyEvent::read(QTcpSocket *s)
+{
+ if (s->bytesAvailable() < 7)
+ return false;
+
+ s->read(&down, 1);
+ quint16 tmp;
+ s->read((char *)&tmp, 2); // padding
+
+ quint32 key;
+ s->read((char *)&key, 4);
+ key = ntohl(key);
+
+ unicode = 0;
+ keycode = 0;
+ int i = 0;
+ while (keyMap[i].keysym && !keycode) {
+ if (keyMap[i].keysym == (int)key)
+ keycode = keyMap[i].keycode;
+ i++;
+ }
+
+ if (keycode >= ' ' && keycode <= '~')
+ unicode = keycode;
+
+ if (!keycode) {
+ if (key <= 0xff) {
+ unicode = key;
+ if (key >= 'a' && key <= 'z')
+ keycode = Qt::Key_A + key - 'a';
+ else if (key >= ' ' && key <= '~')
+ keycode = Qt::Key_Space + key - ' ';
+ }
+ }
+
+ return true;
+}
+
+bool QRfbPointerEvent::read(QTcpSocket *s)
+{
+ if (s->bytesAvailable() < 5)
+ return false;
+
+ char buttonMask;
+ s->read(&buttonMask, 1);
+ buttons = Qt::NoButton;
+ if (buttonMask & 1)
+ buttons |= Qt::LeftButton;
+ if (buttonMask & 2)
+ buttons |= Qt::MidButton;
+ if (buttonMask & 4)
+ buttons |= Qt::RightButton;
+
+ quint16 tmp;
+ s->read((char *)&tmp, 2);
+ x = ntohs(tmp);
+ s->read((char *)&tmp, 2);
+ y = ntohs(tmp);
+
+ return true;
+}
+
+bool QRfbClientCutText::read(QTcpSocket *s)
+{
+ if (s->bytesAvailable() < 7)
+ return false;
+
+ char tmp[3];
+ s->read(tmp, 3); // padding
+ s->read((char *)&length, 4);
+ length = ntohl(length);
+
+ return true;
+}
+
+void QRfbRawEncoder::write()
+{
+// QVncDirtyMap *map = server->dirtyMap();
+ QTcpSocket *socket = client->clientSocket();
+
+ const int bytesPerPixel = client->clientBytesPerPixel();
+
+ // create a region from the dirty rects and send the region's merged rects.
+ // ### use the tile map again
+ QRegion rgn = client->dirtyRegion();
+ qCDebug(lcVnc) << "QRfbRawEncoder::write()" << rgn;
+// if (map) {
+// for (int y = 0; y < map->mapHeight; ++y) {
+// for (int x = 0; x < map->mapWidth; ++x) {
+// if (!map->dirty(x, y))
+// continue;
+// rgn += QRect(x * MAP_TILE_SIZE, y * MAP_TILE_SIZE,
+// MAP_TILE_SIZE, MAP_TILE_SIZE);
+// map->setClean(x, y);
+// }
+// }
+
+// rgn &= QRect(0, 0, server->screen()->geometry().width(),
+// server->screen()->geometry().height());
+// }
+ const QVector<QRect> rects = rgn.rects();
+
+ {
+ const char tmp[2] = { 0, 0 }; // msg type, padding
+ socket->write(tmp, sizeof(tmp));
+ }
+
+ {
+ const quint16 count = htons(rects.size());
+ socket->write((char *)&count, sizeof(count));
+ }
+
+ if (rects.size() <= 0)
+ return;
+
+ const QImage screenImage = client->server()->screenImage();
+
+ for (const QRect &tileRect: rects) {
+ const QRfbRect rect(tileRect.x(), tileRect.y(),
+ tileRect.width(), tileRect.height());
+ rect.write(socket);
+
+ const quint32 encoding = htonl(0); // raw encoding
+ socket->write((char *)&encoding, sizeof(encoding));
+
+ int linestep = screenImage.bytesPerLine();
+ const uchar *screendata = screenImage.scanLine(rect.y)
+ + rect.x * screenImage.depth() / 8;
+
+ if (client->doPixelConversion()) {
+ const int bufferSize = rect.w * rect.h * bytesPerPixel;
+ if (bufferSize > buffer.size())
+ buffer.resize(bufferSize);
+
+ // convert pixels
+ char *b = buffer.data();
+ const int bstep = rect.w * bytesPerPixel;
+ for (int i = 0; i < rect.h; ++i) {
+ client->convertPixels(b, (const char*)screendata, rect.w);
+ screendata += linestep;
+ b += bstep;
+ }
+ socket->write(buffer.constData(), bufferSize);
+ } else {
+ for (int i = 0; i < rect.h; ++i) {
+ socket->write((const char*)screendata, rect.w * bytesPerPixel);
+ screendata += linestep;
+ }
+ }
+ if (socket->state() == QAbstractSocket::UnconnectedState)
+ break;
+ }
+ socket->flush();
+}
+
+QVncClientCursor::QVncClientCursor()
+{
+ QWindow *w = QGuiApplication::focusWindow();
+ QCursor c = w ? w->cursor() : QCursor(Qt::ArrowCursor);
+ changeCursor(&c, 0);
+}
+
+QVncClientCursor::~QVncClientCursor()
+{
+}
+
+void QVncClientCursor::write(QVncClient *client) const
+{
+ QTcpSocket *socket = client->clientSocket();
+
+ // FramebufferUpdate header
+ {
+ const quint16 tmp[6] = { htons(0),
+ htons(1),
+ htons(hotspot.x()), htons(hotspot.y()),
+ htons(cursor.width()),
+ htons(cursor.height()) };
+ socket->write((char*)tmp, sizeof(tmp));
+
+ const quint32 encoding = htonl(-239);
+ socket->write((char*)(&encoding), sizeof(encoding));
+ }
+
+ if (cursor.isNull())
+ return;
+
+ // write pixels
+ Q_ASSERT(cursor.hasAlphaChannel());
+ const QImage img = cursor.convertToFormat(client->server()->screen()->format());
+ const int n = client->clientBytesPerPixel() * img.width();
+ char *buffer = new char[n];
+ for (int i = 0; i < img.height(); ++i) {
+ client->convertPixels(buffer, (const char*)img.scanLine(i), img.width());
+ socket->write(buffer, n);
+ }
+ delete[] buffer;
+
+ // write mask
+ const QImage bitmap = cursor.createAlphaMask().convertToFormat(QImage::Format_Mono);
+ Q_ASSERT(bitmap.depth() == 1);
+ Q_ASSERT(bitmap.size() == img.size());
+ const int width = (bitmap.width() + 7) / 8;
+ for (int i = 0; i < bitmap.height(); ++i)
+ socket->write((const char*)bitmap.scanLine(i), width);
+}
+
+#ifndef QT_NO_CURSOR
+void QVncClientCursor::changeCursor(QCursor *widgetCursor, QWindow *window)
+{
+ Q_UNUSED(window);
+ const Qt::CursorShape shape = widgetCursor ? widgetCursor->shape() : Qt::ArrowCursor;
+
+ if (shape == Qt::BitmapCursor) {
+ // application supplied cursor
+ hotspot = widgetCursor->hotSpot();
+ cursor = widgetCursor->pixmap().toImage();
+ } else {
+ // system cursor
+ QPlatformCursorImage platformImage(0, 0, 0, 0, 0, 0);
+ platformImage.set(shape);
+ cursor = *platformImage.image();
+ hotspot = platformImage.hotspot();
+ }
+ for (auto client : clients)
+ client->setDirtyCursor();
+}
+
+void QVncClientCursor::addClient(QVncClient *client)
+{
+ if (!clients.contains(client))
+ clients.append(client);
+}
+
+uint QVncClientCursor::removeClient(QVncClient *client)
+{
+ clients.removeOne(client);
+ return clients.count();
+}
+#endif
+
+QVncServer::QVncServer(QVncScreen *screen, quint16 port)
+ : qvnc_screen(screen)
+ , m_port(port)
+{
+ QMetaObject::invokeMethod(this, "init", Qt::QueuedConnection);
+}
+
+void QVncServer::init()
+{
+ serverSocket = new QTcpServer(this);
+ if (!serverSocket->listen(QHostAddress::Any, m_port))
+ qWarning() << "QVncServer could not connect:" << serverSocket->errorString();
+ else
+ qWarning("QVncServer created on port %d", m_port);
+
+ connect(serverSocket, SIGNAL(newConnection()), this, SLOT(newConnection()));
+
+}
+
+QVncServer::~QVncServer()
+{
+ for (auto client : clients) {
+ delete client;
+ }
+}
+
+void QVncServer::setDirty()
+{
+ for (auto client : clients) {
+ client->setDirty(qvnc_screen->dirtyRegion);
+ }
+ qvnc_screen->clearDirty();
+}
+
+
+void QVncServer::newConnection()
+{
+ auto clientSocket = serverSocket->nextPendingConnection();
+ clients.append(new QVncClient(clientSocket, this));
+
+ dirtyMap()->reset();
+
+ qCDebug(lcVnc) << "new Connection from: " << clientSocket->localAddress();
+
+ qvnc_screen->setPowerState(QPlatformScreen::PowerStateOn);
+}
+
+void QVncServer::discardClient(QVncClient *client)
+{
+ clients.removeOne(client);
+ client->deleteLater();
+ if (clients.isEmpty()) {
+ qvnc_screen->disableClientCursor(client);
+ qvnc_screen->setPowerState(QPlatformScreen::PowerStateOff);
+ }
+}
+
+inline QImage QVncServer::screenImage() const
+{
+ return *qvnc_screen->image();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/vnc/qvnc_p.h b/src/plugins/platforms/vnc/qvnc_p.h
new file mode 100644
index 0000000000..1c44cd1569
--- /dev/null
+++ b/src/plugins/platforms/vnc/qvnc_p.h
@@ -0,0 +1,417 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QVNC_P_H
+#define QVNC_P_H
+
+#include "qvncscreen.h"
+
+#include <QtCore/QLoggingCategory>
+#include <QtCore/qbytearray.h>
+#include <QtCore/qvarlengtharray.h>
+#include <qpa/qplatformcursor.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_DECLARE_LOGGING_CATEGORY(lcVnc)
+
+class QTcpSocket;
+class QTcpServer;
+
+class QVncScreen;
+class QVncServer;
+class QVncClientCursor;
+class QVncClient;
+
+// This fits with the VNC hextile messages
+#define MAP_TILE_SIZE 16
+
+class QVncDirtyMap
+{
+public:
+ QVncDirtyMap(QVncScreen *screen);
+ virtual ~QVncDirtyMap();
+
+ void reset();
+ bool dirty(int x, int y) const;
+ virtual void setDirty(int x, int y, bool force = false) = 0;
+ void setClean(int x, int y);
+
+ QVncScreen *screen;
+ int bytesPerPixel;
+ int numDirty;
+ int mapWidth;
+ int mapHeight;
+
+protected:
+ uchar *map;
+ uchar *buffer;
+ int bufferWidth;
+ int bufferHeight;
+ int bufferStride;
+ int numTiles;
+};
+
+template <class T>
+class QVncDirtyMapOptimized : public QVncDirtyMap
+{
+public:
+ QVncDirtyMapOptimized(QVncScreen *screen) : QVncDirtyMap(screen) {}
+ ~QVncDirtyMapOptimized() {}
+
+ void setDirty(int x, int y, bool force = false);
+};
+
+
+class QRfbRect
+{
+public:
+ QRfbRect() {}
+ QRfbRect(quint16 _x, quint16 _y, quint16 _w, quint16 _h) {
+ x = _x; y = _y; w = _w; h = _h;
+ }
+
+ void read(QTcpSocket *s);
+ void write(QTcpSocket *s) const;
+
+ quint16 x;
+ quint16 y;
+ quint16 w;
+ quint16 h;
+};
+
+class QRfbPixelFormat
+{
+public:
+ static int size() { return 16; }
+
+ void read(QTcpSocket *s);
+ void write(QTcpSocket *s);
+
+ int bitsPerPixel;
+ int depth;
+ bool bigEndian;
+ bool trueColor;
+ int redBits;
+ int greenBits;
+ int blueBits;
+ int redShift;
+ int greenShift;
+ int blueShift;
+};
+
+class QRfbServerInit
+{
+public:
+ QRfbServerInit() { name = 0; }
+ ~QRfbServerInit() { delete[] name; }
+
+ int size() const { return QRfbPixelFormat::size() + 8 + strlen(name); }
+ void setName(const char *n);
+
+ void read(QTcpSocket *s);
+ void write(QTcpSocket *s);
+
+ quint16 width;
+ quint16 height;
+ QRfbPixelFormat format;
+ char *name;
+};
+
+class QRfbSetEncodings
+{
+public:
+ bool read(QTcpSocket *s);
+
+ quint16 count;
+};
+
+class QRfbFrameBufferUpdateRequest
+{
+public:
+ bool read(QTcpSocket *s);
+
+ char incremental;
+ QRfbRect rect;
+};
+
+class QRfbKeyEvent
+{
+public:
+ bool read(QTcpSocket *s);
+
+ char down;
+ int keycode;
+ int unicode;
+};
+
+class QRfbPointerEvent
+{
+public:
+ bool read(QTcpSocket *s);
+
+ Qt::MouseButtons buttons;
+ quint16 x;
+ quint16 y;
+};
+
+class QRfbClientCutText
+{
+public:
+ bool read(QTcpSocket *s);
+
+ quint32 length;
+};
+
+class QRfbEncoder
+{
+public:
+ QRfbEncoder(QVncClient *s) : client(s) {}
+ virtual ~QRfbEncoder() {}
+
+ virtual void write() = 0;
+
+protected:
+ QVncClient *client;
+};
+
+class QRfbRawEncoder : public QRfbEncoder
+{
+public:
+ QRfbRawEncoder(QVncClient *s) : QRfbEncoder(s) {}
+
+ void write();
+
+private:
+ QByteArray buffer;
+};
+
+template <class SRC> class QRfbHextileEncoder;
+
+template <class SRC>
+class QRfbSingleColorHextile
+{
+public:
+ QRfbSingleColorHextile(QRfbHextileEncoder<SRC> *e) : encoder(e) {}
+ bool read(const uchar *data, int width, int height, int stride);
+ void write(QTcpSocket *socket) const;
+
+private:
+ QRfbHextileEncoder<SRC> *encoder;
+};
+
+template <class SRC>
+class QRfbDualColorHextile
+{
+public:
+ QRfbDualColorHextile(QRfbHextileEncoder<SRC> *e) : encoder(e) {}
+ bool read(const uchar *data, int width, int height, int stride);
+ void write(QTcpSocket *socket) const;
+
+private:
+ struct Rect {
+ quint8 xy;
+ quint8 wh;
+ } Q_PACKED rects[8 * 16];
+
+ quint8 numRects;
+ QRfbHextileEncoder<SRC> *encoder;
+
+private:
+ inline int lastx() const { return rectx(numRects); }
+ inline int lasty() const { return recty(numRects); }
+ inline int rectx(int r) const { return rects[r].xy >> 4; }
+ inline int recty(int r) const { return rects[r].xy & 0x0f; }
+ inline int width(int r) const { return (rects[r].wh >> 4) + 1; }
+ inline int height(int r) const { return (rects[r].wh & 0x0f) + 1; }
+
+ inline void setX(int r, int x) {
+ rects[r].xy = (x << 4) | (rects[r].xy & 0x0f);
+ }
+ inline void setY(int r, int y) {
+ rects[r].xy = (rects[r].xy & 0xf0) | y;
+ }
+ inline void setWidth(int r, int width) {
+ rects[r].wh = ((width - 1) << 4) | (rects[r].wh & 0x0f);
+ }
+ inline void setHeight(int r, int height) {
+ rects[r].wh = (rects[r].wh & 0xf0) | (height - 1);
+ }
+
+ inline void setWidth(int width) { setWidth(numRects, width); }
+ inline void setHeight(int height) { setHeight(numRects, height); }
+ inline void setX(int x) { setX(numRects, x); }
+ inline void setY(int y) { setY(numRects, y); }
+ void next();
+};
+
+template <class SRC>
+class QRfbMultiColorHextile
+{
+public:
+ QRfbMultiColorHextile(QRfbHextileEncoder<SRC> *e) : encoder(e) {}
+ bool read(const uchar *data, int width, int height, int stride);
+ void write(QTcpSocket *socket) const;
+
+private:
+ inline quint8* rect(int r) {
+ return rects.data() + r * (bpp + 2);
+ }
+ inline const quint8* rect(int r) const {
+ return rects.constData() + r * (bpp + 2);
+ }
+ inline void setX(int r, int x) {
+ quint8 *ptr = rect(r) + bpp;
+ *ptr = (x << 4) | (*ptr & 0x0f);
+ }
+ inline void setY(int r, int y) {
+ quint8 *ptr = rect(r) + bpp;
+ *ptr = (*ptr & 0xf0) | y;
+ }
+ void setColor(SRC color);
+ inline int rectx(int r) const {
+ const quint8 *ptr = rect(r) + bpp;
+ return *ptr >> 4;
+ }
+ inline int recty(int r) const {
+ const quint8 *ptr = rect(r) + bpp;
+ return *ptr & 0x0f;
+ }
+ inline void setWidth(int r, int width) {
+ quint8 *ptr = rect(r) + bpp + 1;
+ *ptr = ((width - 1) << 4) | (*ptr & 0x0f);
+ }
+ inline void setHeight(int r, int height) {
+ quint8 *ptr = rect(r) + bpp + 1;
+ *ptr = (*ptr & 0xf0) | (height - 1);
+ }
+
+ bool beginRect();
+ void endRect();
+
+ static const int maxRectsSize = 16 * 16;
+ QVarLengthArray<quint8, maxRectsSize> rects;
+
+ quint8 bpp;
+ quint8 numRects;
+ QRfbHextileEncoder<SRC> *encoder;
+};
+
+template <class SRC>
+class QRfbHextileEncoder : public QRfbEncoder
+{
+public:
+ QRfbHextileEncoder(QVncServer *s);
+ void write();
+
+private:
+ enum SubEncoding {
+ Raw = 1,
+ BackgroundSpecified = 2,
+ ForegroundSpecified = 4,
+ AnySubrects = 8,
+ SubrectsColoured = 16
+ };
+
+ QByteArray buffer;
+ QRfbSingleColorHextile<SRC> singleColorHextile;
+ QRfbDualColorHextile<SRC> dualColorHextile;
+ QRfbMultiColorHextile<SRC> multiColorHextile;
+
+ SRC bg;
+ SRC fg;
+ bool newBg;
+ bool newFg;
+
+ friend class QRfbSingleColorHextile<SRC>;
+ friend class QRfbDualColorHextile<SRC>;
+ friend class QRfbMultiColorHextile<SRC>;
+};
+
+class QVncClientCursor : public QPlatformCursor
+{
+public:
+ QVncClientCursor();
+ ~QVncClientCursor();
+
+ void write(QVncClient *client) const;
+
+ void changeCursor(QCursor *widgetCursor, QWindow *window);
+
+ void addClient(QVncClient *client);
+ uint removeClient(QVncClient *client);
+
+ QImage cursor;
+ QPoint hotspot;
+ QVector<QVncClient *> clients;
+};
+
+
+class QVncServer : public QObject
+{
+ Q_OBJECT
+public:
+ QVncServer(QVncScreen *screen, quint16 port = 5900);
+ ~QVncServer();
+
+ enum ServerMsg { FramebufferUpdate = 0,
+ SetColourMapEntries = 1 };
+
+ void setDirty();
+
+
+ inline QVncScreen* screen() const { return qvnc_screen; }
+ inline QVncDirtyMap* dirtyMap() const { return qvnc_screen->dirty; }
+ QImage screenImage() const;
+ void discardClient(QVncClient *client);
+
+private slots:
+ void newConnection();
+ void init();
+
+private:
+ QTcpServer *serverSocket;
+ QVector<QVncClient*> clients;
+ QVncScreen *qvnc_screen;
+ quint16 m_port;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/plugins/platforms/vnc/qvncclient.cpp b/src/plugins/platforms/vnc/qvncclient.cpp
new file mode 100644
index 0000000000..dae3e83f37
--- /dev/null
+++ b/src/plugins/platforms/vnc/qvncclient.cpp
@@ -0,0 +1,662 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qvncclient.h"
+#include "qvnc_p.h"
+
+#include <QtNetwork/QTcpSocket>
+#include <QtCore/QCoreApplication>
+
+#include <qpa/qwindowsysteminterface.h>
+#include <QtGui/qguiapplication.h>
+
+#ifdef Q_OS_WIN
+#include <Winsock2.h>
+#else
+#include <arpa/inet.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+QVncClient::QVncClient(QTcpSocket *clientSocket, QVncServer *server)
+ : QObject(server)
+ , m_server(server)
+ , m_clientSocket(clientSocket)
+ , m_encoder(nullptr)
+ , m_msgType(0)
+ , m_handleMsg(false)
+ , m_encodingsPending(0)
+ , m_cutTextPending(0)
+ , m_supportHextile(false)
+ , m_wantUpdate(false)
+ , m_keymod(0)
+ , m_dirtyCursor(false)
+ , m_updatePending(false)
+ , m_protocolVersion(V3_3)
+{
+ connect(m_clientSocket,SIGNAL(readyRead()),this,SLOT(readClient()));
+ connect(m_clientSocket,SIGNAL(disconnected()),this,SLOT(discardClient()));
+
+ // send protocol version
+ const char *proto = "RFB 003.003\n";
+ m_clientSocket->write(proto, 12);
+ m_state = Protocol;
+}
+
+QVncClient::~QVncClient()
+{
+ delete m_encoder;
+}
+
+QTcpSocket *QVncClient::clientSocket() const
+{
+ return m_clientSocket;
+}
+
+void QVncClient::setDirty(const QRegion &region)
+{
+ m_dirtyRegion += region;
+ if (m_state == Connected &&
+ ((m_server->dirtyMap()->numDirty > 0) || m_dirtyCursor)) {
+ scheduleUpdate();
+ }
+}
+
+void QVncClient::convertPixels(char *dst, const char *src, int count) const
+{
+ const int screendepth = m_server->screen()->depth();
+
+ // cutoffs
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ if (!m_swapBytes)
+#endif
+ if (m_sameEndian) {
+ if (screendepth == m_pixelFormat.bitsPerPixel) { // memcpy cutoffs
+
+ switch (screendepth) {
+ case 32:
+ memcpy(dst, src, count * sizeof(quint32));
+ return;
+ case 16:
+ if (m_pixelFormat.redBits == 5
+ && m_pixelFormat.greenBits == 6
+ && m_pixelFormat.blueBits == 5)
+ {
+ memcpy(dst, src, count * sizeof(quint16));
+ return;
+ }
+ }
+ }
+ }
+
+ const int bytesPerPixel = (m_pixelFormat.bitsPerPixel + 7) / 8;
+
+ for (int i = 0; i < count; ++i) {
+ int r, g, b;
+
+ switch (screendepth) {
+ case 8: {
+ QRgb rgb = m_server->screen()->image()->colorTable()[int(*src)];
+ r = qRed(rgb);
+ g = qGreen(rgb);
+ b = qBlue(rgb);
+ src++;
+ break;
+ }
+ case 16: {
+ quint16 p = *reinterpret_cast<const quint16*>(src);
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ if (swapBytes)
+ p = ((p & 0xff) << 8) | ((p & 0xff00) >> 8);
+#endif
+ r = (p >> 11) & 0x1f;
+ g = (p >> 5) & 0x3f;
+ b = p & 0x1f;
+ r <<= 3;
+ g <<= 2;
+ b <<= 3;
+ src += sizeof(quint16);
+ break;
+ }
+ case 32: {
+ quint32 p = *reinterpret_cast<const quint32*>(src);
+ r = (p >> 16) & 0xff;
+ g = (p >> 8) & 0xff;
+ b = p & 0xff;
+ src += sizeof(quint32);
+ break;
+ }
+ default: {
+ r = g = b = 0;
+ qWarning("QVNCServer: don't support %dbpp display", screendepth);
+ return;
+ }
+ }
+
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ if (m_swapBytes)
+ qSwap(r, b);
+#endif
+
+ r >>= (8 - m_pixelFormat.redBits);
+ g >>= (8 - m_pixelFormat.greenBits);
+ b >>= (8 - m_pixelFormat.blueBits);
+
+ int pixel = (r << m_pixelFormat.redShift) |
+ (g << m_pixelFormat.greenShift) |
+ (b << m_pixelFormat.blueShift);
+
+ if (m_sameEndian || m_pixelFormat.bitsPerPixel == 8) {
+ memcpy(dst, &pixel, bytesPerPixel);
+ dst += bytesPerPixel;
+ continue;
+ }
+
+
+ if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
+ switch (m_pixelFormat.bitsPerPixel) {
+ case 16:
+ pixel = (((pixel & 0x0000ff00) << 8) |
+ ((pixel & 0x000000ff) << 24));
+ break;
+ case 32:
+ pixel = (((pixel & 0xff000000) >> 24) |
+ ((pixel & 0x00ff0000) >> 8) |
+ ((pixel & 0x0000ff00) << 8) |
+ ((pixel & 0x000000ff) << 24));
+ break;
+ default:
+ qWarning("Cannot handle %d bpp client", m_pixelFormat.bitsPerPixel);
+ }
+ } else { // QSysInfo::ByteOrder == QSysInfo::LittleEndian
+ switch (m_pixelFormat.bitsPerPixel) {
+ case 16:
+ pixel = (((pixel & 0xff000000) >> 8) |
+ ((pixel & 0x00ff0000) << 8));
+ break;
+ case 32:
+ pixel = (((pixel & 0xff000000) >> 24) |
+ ((pixel & 0x00ff0000) >> 8) |
+ ((pixel & 0x0000ff00) << 8) |
+ ((pixel & 0x000000ff) << 24));
+ break;
+ default:
+ qWarning("Cannot handle %d bpp client",
+ m_pixelFormat.bitsPerPixel);
+ break;
+ }
+ }
+ memcpy(dst, &pixel, bytesPerPixel);
+ dst += bytesPerPixel;
+ }
+}
+
+void QVncClient::readClient()
+{
+ qCDebug(lcVnc) << "readClient" << m_state;
+ switch (m_state) {
+ case Disconnected:
+
+ break;
+ case Protocol:
+ if (m_clientSocket->bytesAvailable() >= 12) {
+ char proto[13];
+ m_clientSocket->read(proto, 12);
+ proto[12] = '\0';
+ qCDebug(lcVnc, "Client protocol version %s", proto);
+ if (!strcmp(proto, "RFB 003.008\n")) {
+ m_protocolVersion = V3_8;
+ } else if (!strcmp(proto, "RFB 003.007\n")) {
+ m_protocolVersion = V3_7;
+ } else {
+ m_protocolVersion = V3_3;
+ }
+
+ if (m_protocolVersion == V3_3) {
+ // No authentication
+ quint32 auth = htonl(1);
+ m_clientSocket->write((char *) &auth, sizeof(auth));
+ m_state = Init;
+ }
+ }
+ break;
+ case Authentication:
+
+ break;
+ case Init:
+ if (m_clientSocket->bytesAvailable() >= 1) {
+ quint8 shared;
+ m_clientSocket->read((char *) &shared, 1);
+
+ // Server Init msg
+ QRfbServerInit sim;
+ QRfbPixelFormat &format = sim.format;
+ switch (m_server->screen()->depth()) {
+ case 32:
+ format.bitsPerPixel = 32;
+ format.depth = 32;
+ format.bigEndian = 0;
+ format.trueColor = true;
+ format.redBits = 8;
+ format.greenBits = 8;
+ format.blueBits = 8;
+ format.redShift = 16;
+ format.greenShift = 8;
+ format.blueShift = 0;
+ break;
+
+ case 24:
+ format.bitsPerPixel = 24;
+ format.depth = 24;
+ format.bigEndian = 0;
+ format.trueColor = true;
+ format.redBits = 8;
+ format.greenBits = 8;
+ format.blueBits = 8;
+ format.redShift = 16;
+ format.greenShift = 8;
+ format.blueShift = 0;
+ break;
+
+ case 18:
+ format.bitsPerPixel = 24;
+ format.depth = 18;
+ format.bigEndian = 0;
+ format.trueColor = true;
+ format.redBits = 6;
+ format.greenBits = 6;
+ format.blueBits = 6;
+ format.redShift = 12;
+ format.greenShift = 6;
+ format.blueShift = 0;
+ break;
+
+ case 16:
+ format.bitsPerPixel = 16;
+ format.depth = 16;
+ format.bigEndian = 0;
+ format.trueColor = true;
+ format.redBits = 5;
+ format.greenBits = 6;
+ format.blueBits = 5;
+ format.redShift = 11;
+ format.greenShift = 5;
+ format.blueShift = 0;
+ break;
+
+ case 15:
+ format.bitsPerPixel = 16;
+ format.depth = 15;
+ format.bigEndian = 0;
+ format.trueColor = true;
+ format.redBits = 5;
+ format.greenBits = 5;
+ format.blueBits = 5;
+ format.redShift = 10;
+ format.greenShift = 5;
+ format.blueShift = 0;
+ break;
+
+ case 12:
+ format.bitsPerPixel = 16;
+ format.depth = 12;
+ format.bigEndian = 0;
+ format.trueColor = true;
+ format.redBits = 4;
+ format.greenBits = 4;
+ format.blueBits = 4;
+ format.redShift = 8;
+ format.greenShift = 4;
+ format.blueShift = 0;
+ break;
+
+ case 8:
+ case 4:
+ format.bitsPerPixel = 8;
+ format.depth = 8;
+ format.bigEndian = 0;
+ format.trueColor = false;
+ format.redBits = 0;
+ format.greenBits = 0;
+ format.blueBits = 0;
+ format.redShift = 0;
+ format.greenShift = 0;
+ format.blueShift = 0;
+ break;
+
+ default:
+ qWarning("QVNC cannot drive depth %d", m_server->screen()->depth());
+ discardClient();
+ return;
+ }
+ sim.width = m_server->screen()->geometry().width();
+ sim.height = m_server->screen()->geometry().height();
+ sim.setName("Qt for Embedded Linux VNC Server");
+ sim.write(m_clientSocket);
+ m_state = Connected;
+ }
+ break;
+
+ case Connected:
+ do {
+ if (!m_handleMsg) {
+ m_clientSocket->read((char *)&m_msgType, 1);
+ m_handleMsg = true;
+ }
+ if (m_handleMsg) {
+ switch (m_msgType ) {
+ case SetPixelFormat:
+ setPixelFormat();
+ break;
+ case FixColourMapEntries:
+ qWarning("Not supported: FixColourMapEntries");
+ m_handleMsg = false;
+ break;
+ case SetEncodings:
+ setEncodings();
+ break;
+ case FramebufferUpdateRequest:
+ frameBufferUpdateRequest();
+ break;
+ case KeyEvent:
+ keyEvent();
+ break;
+ case PointerEvent:
+ pointerEvent();
+ break;
+ case ClientCutText:
+ clientCutText();
+ break;
+ default:
+ qWarning("Unknown message type: %d", (int)m_msgType);
+ m_handleMsg = false;
+ }
+ }
+ } while (!m_handleMsg && m_clientSocket->bytesAvailable());
+ break;
+ default:
+ break;
+ }
+}
+
+void QVncClient::discardClient()
+{
+ m_state = Disconnected;
+ m_server->discardClient(this);
+}
+
+void QVncClient::checkUpdate()
+{
+ if (!m_wantUpdate)
+ return;
+
+ if (m_dirtyCursor) {
+ m_server->screen()->clientCursor->write(this);
+ m_dirtyCursor = false;
+ m_wantUpdate = false;
+ return;
+ }
+
+ if (!m_dirtyRegion.isEmpty()) {
+ if (m_encoder)
+ m_encoder->write();
+ m_wantUpdate = false;
+ m_dirtyRegion = QRegion();
+ }
+}
+
+void QVncClient::scheduleUpdate()
+{
+ if (!m_updatePending) {
+ m_updatePending = true;
+ QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest));
+ }
+}
+
+bool QVncClient::event(QEvent *event)
+{
+ if (event->type() == QEvent::UpdateRequest) {
+ m_updatePending = false;
+ checkUpdate();
+ return true;
+ }
+ return QObject::event(event);
+}
+
+void QVncClient::setPixelFormat()
+{
+ if (m_clientSocket->bytesAvailable() >= 19) {
+ char buf[3];
+ m_clientSocket->read(buf, 3); // just padding
+ m_pixelFormat.read(m_clientSocket);
+ qCDebug(lcVnc, "Want format: %d %d %d %d %d %d %d %d %d %d",
+ int(m_pixelFormat.bitsPerPixel),
+ int(m_pixelFormat.depth),
+ int(m_pixelFormat.bigEndian),
+ int(m_pixelFormat.trueColor),
+ int(m_pixelFormat.redBits),
+ int(m_pixelFormat.greenBits),
+ int(m_pixelFormat.blueBits),
+ int(m_pixelFormat.redShift),
+ int(m_pixelFormat.greenShift),
+ int(m_pixelFormat.blueShift));
+ if (!m_pixelFormat.trueColor) {
+ qWarning("Can only handle true color clients");
+ discardClient();
+ }
+ m_handleMsg = false;
+ m_sameEndian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) == !!m_pixelFormat.bigEndian;
+ m_needConversion = pixelConversionNeeded();
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ m_swapBytes = qvnc_screen->swapBytes();
+#endif
+ }
+}
+
+void QVncClient::setEncodings()
+{
+ QRfbSetEncodings enc;
+
+ if (!m_encodingsPending && enc.read(m_clientSocket)) {
+ m_encodingsPending = enc.count;
+ if (!m_encodingsPending)
+ m_handleMsg = false;
+ }
+
+ if (m_encoder) {
+ delete m_encoder;
+ m_encoder = nullptr;
+ }
+
+ enum Encodings {
+ Raw = 0,
+ CopyRect = 1,
+ RRE = 2,
+ CoRRE = 4,
+ Hextile = 5,
+ ZRLE = 16,
+ Cursor = -239,
+ DesktopSize = -223
+ };
+
+ if (m_encodingsPending && (unsigned)m_clientSocket->bytesAvailable() >=
+ m_encodingsPending * sizeof(quint32)) {
+ for (int i = 0; i < m_encodingsPending; ++i) {
+ qint32 enc;
+ m_clientSocket->read((char *)&enc, sizeof(qint32));
+ enc = ntohl(enc);
+ qCDebug(lcVnc, "QVncServer::setEncodings: %d", enc);
+ switch (enc) {
+ case Raw:
+ if (!m_encoder) {
+ m_encoder = new QRfbRawEncoder(this);
+ qCDebug(lcVnc, "QVncServer::setEncodings: using raw");
+ }
+ break;
+ case CopyRect:
+ m_supportCopyRect = true;
+ break;
+ case RRE:
+ m_supportRRE = true;
+ break;
+ case CoRRE:
+ m_supportCoRRE = true;
+ break;
+ case Hextile:
+ m_supportHextile = true;
+ if (m_encoder)
+ break;
+ break;
+ case ZRLE:
+ m_supportZRLE = true;
+ break;
+ case Cursor:
+ m_supportCursor = true;
+ m_server->screen()->enableClientCursor(this);
+ break;
+ case DesktopSize:
+ m_supportDesktopSize = true;
+ break;
+ default:
+ break;
+ }
+ }
+ m_handleMsg = false;
+ m_encodingsPending = 0;
+ }
+
+ if (!m_encoder) {
+ m_encoder = new QRfbRawEncoder(this);
+ qCDebug(lcVnc, "QVncServer::setEncodings: fallback using raw");
+ }
+}
+
+void QVncClient::frameBufferUpdateRequest()
+{
+ qCDebug(lcVnc) << "FramebufferUpdateRequest";
+ QRfbFrameBufferUpdateRequest ev;
+
+ if (ev.read(m_clientSocket)) {
+ if (!ev.incremental) {
+ QRect r(ev.rect.x, ev.rect.y, ev.rect.w, ev.rect.h);
+ r.translate(m_server->screen()->geometry().topLeft());
+ setDirty(r);
+ }
+ m_wantUpdate = true;
+ checkUpdate();
+ m_handleMsg = false;
+ }
+}
+
+void QVncClient::pointerEvent()
+{
+ QRfbPointerEvent ev;
+ if (ev.read(m_clientSocket)) {
+ const QPoint pos = m_server->screen()->geometry().topLeft() + QPoint(ev.x, ev.y);
+ QWindowSystemInterface::handleMouseEvent(0, pos, pos, ev.buttons, QGuiApplication::keyboardModifiers());
+ m_handleMsg = false;
+ }
+}
+
+void QVncClient::keyEvent()
+{
+ QRfbKeyEvent ev;
+
+ if (ev.read(m_clientSocket)) {
+ if (ev.keycode == Qt::Key_Shift)
+ m_keymod = ev.down ? m_keymod | Qt::ShiftModifier :
+ m_keymod & ~Qt::ShiftModifier;
+ else if (ev.keycode == Qt::Key_Control)
+ m_keymod = ev.down ? m_keymod | Qt::ControlModifier :
+ m_keymod & ~Qt::ControlModifier;
+ else if (ev.keycode == Qt::Key_Alt)
+ m_keymod = ev.down ? m_keymod | Qt::AltModifier :
+ m_keymod & ~Qt::AltModifier;
+ if (ev.unicode || ev.keycode)
+ QWindowSystemInterface::handleKeyEvent(0, ev.down ? QEvent::KeyPress : QEvent::KeyRelease, ev.keycode, m_keymod, QString(ev.unicode));
+ m_handleMsg = false;
+ }
+}
+
+void QVncClient::clientCutText()
+{
+ QRfbClientCutText ev;
+
+ if (m_cutTextPending == 0 && ev.read(m_clientSocket)) {
+ m_cutTextPending = ev.length;
+ if (!m_cutTextPending)
+ m_handleMsg = false;
+ }
+
+ if (m_cutTextPending && m_clientSocket->bytesAvailable() >= m_cutTextPending) {
+ char *text = new char [m_cutTextPending+1];
+ m_clientSocket->read(text, m_cutTextPending);
+ delete [] text;
+ m_cutTextPending = 0;
+ m_handleMsg = false;
+ }
+}
+
+bool QVncClient::pixelConversionNeeded() const
+{
+ if (!m_sameEndian)
+ return true;
+
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ if (qvnc_screen->swapBytes())
+ return true;
+#endif
+
+ const int screendepth = m_server->screen()->depth();
+ if (screendepth != m_pixelFormat.bitsPerPixel)
+ return true;
+
+ switch (screendepth) {
+ case 32:
+ case 24:
+ return false;
+ case 16:
+ return (m_pixelFormat.redBits == 5
+ && m_pixelFormat.greenBits == 6
+ && m_pixelFormat.blueBits == 5);
+ }
+ return true;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/vnc/qvncclient.h b/src/plugins/platforms/vnc/qvncclient.h
new file mode 100644
index 0000000000..a7a6b6b361
--- /dev/null
+++ b/src/plugins/platforms/vnc/qvncclient.h
@@ -0,0 +1,149 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QVNCCLIENT_H
+#define QVNCCLIENT_H
+
+#include <QObject>
+
+#include "qvnc_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QTcpSocket;
+class QVncServer;
+
+class QVncClient : public QObject
+{
+ Q_OBJECT
+public:
+ enum ClientMsg {
+ SetPixelFormat = 0,
+ FixColourMapEntries = 1,
+ SetEncodings = 2,
+ FramebufferUpdateRequest = 3,
+ KeyEvent = 4,
+ PointerEvent = 5,
+ ClientCutText = 6
+ };
+
+ explicit QVncClient(QTcpSocket *clientSocket, QVncServer *server);
+ ~QVncClient();
+ QTcpSocket *clientSocket() const;
+ QVncServer *server() const { return m_server; }
+
+ void setDirty(const QRegion &region);
+ void setDirtyCursor() { m_dirtyCursor = true; scheduleUpdate(); }
+ QRegion dirtyRegion() const { return m_dirtyRegion; }
+ inline bool isConnected() const { return m_state == Connected; }
+
+ inline int clientBytesPerPixel() const {
+ return m_pixelFormat.bitsPerPixel / 8;
+ }
+
+ void convertPixels(char *dst, const char *src, int count) const;
+ inline bool doPixelConversion() const { return m_needConversion; }
+
+signals:
+
+private slots:
+ void readClient();
+ void discardClient();
+ void checkUpdate();
+ void scheduleUpdate();
+
+protected:
+ bool event(QEvent *event) override;
+
+private:
+ enum ClientState {
+ Disconnected,
+ Protocol,
+ Authentication,
+ Init,
+ Connected
+ };
+ enum ProtocolVersion {
+ V3_3,
+ V3_7,
+ V3_8
+ };
+
+ void setPixelFormat();
+ void setEncodings();
+ void frameBufferUpdateRequest();
+ void pointerEvent();
+ void keyEvent();
+ void clientCutText();
+ bool pixelConversionNeeded() const;
+
+ QVncServer *m_server;
+ QTcpSocket *m_clientSocket;
+ QRfbEncoder *m_encoder;
+
+ // Client State
+ ClientState m_state;
+ quint8 m_msgType;
+ bool m_handleMsg;
+ QRfbPixelFormat m_pixelFormat;
+ bool m_sameEndian;
+ bool m_needConversion;
+ int m_encodingsPending;
+ int m_cutTextPending;
+ uint m_supportCopyRect : 1;
+ uint m_supportRRE : 1;
+ uint m_supportCoRRE : 1;
+ uint m_supportHextile : 1;
+ uint m_supportZRLE : 1;
+ uint m_supportCursor : 1;
+ uint m_supportDesktopSize : 1;
+ bool m_wantUpdate;
+ Qt::KeyboardModifiers m_keymod;
+ bool m_dirtyCursor;
+ bool m_updatePending;
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ bool m_swapBytes;
+#endif
+ QRegion m_dirtyRegion;
+ ProtocolVersion m_protocolVersion;
+};
+
+QT_END_NAMESPACE
+
+#endif // QVNCCLIENT_H
diff --git a/src/plugins/platforms/vnc/qvncintegration.cpp b/src/plugins/platforms/vnc/qvncintegration.cpp
new file mode 100644
index 0000000000..810c5d2a90
--- /dev/null
+++ b/src/plugins/platforms/vnc/qvncintegration.cpp
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the FOO module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later 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 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qvncintegration.h"
+#include "qvncscreen.h"
+#include "qvnc_p.h"
+
+#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
+#include <QtPlatformSupport/private/qgenericunixservices_p.h>
+#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
+
+#include <QtPlatformSupport/private/qfbbackingstore_p.h>
+#include <QtPlatformSupport/private/qfbwindow_p.h>
+#include <QtPlatformSupport/private/qfbcursor_p.h>
+
+#include <QtGui/private/qguiapplication_p.h>
+#include <qpa/qplatforminputcontextfactory_p.h>
+#include <private/qinputdevicemanager_p_p.h>
+#ifndef QT_NO_LIBINPUT
+#include <QtPlatformSupport/private/qlibinputhandler_p.h>
+#endif
+
+#include <QtCore/QRegularExpression>
+
+QT_BEGIN_NAMESPACE
+
+QVncIntegration::QVncIntegration(const QStringList &paramList)
+ : m_fontDb(new QGenericUnixFontDatabase),
+ m_services(new QGenericUnixServices)
+{
+ QRegularExpression portRx(QLatin1String("port=(\\d+)"));
+ quint16 port = 5900;
+ for (const QString &arg : paramList) {
+ QRegularExpressionMatch match;
+ if (arg.contains(portRx, &match))
+ port = match.captured(1).toInt();
+ }
+
+ m_primaryScreen = new QVncScreen(paramList);
+ m_server = new QVncServer(m_primaryScreen, port);
+ m_primaryScreen->vncServer = m_server;
+}
+
+QVncIntegration::~QVncIntegration()
+{
+ delete m_server;
+ destroyScreen(m_primaryScreen);
+}
+
+void QVncIntegration::initialize()
+{
+ if (m_primaryScreen->initialize())
+ screenAdded(m_primaryScreen);
+ else
+ qWarning("vnc: Failed to initialize screen");
+
+ m_inputContext = QPlatformInputContextFactory::create();
+
+ m_nativeInterface.reset(new QPlatformNativeInterface);
+
+ // we always have exactly one mouse and keyboard
+ QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
+ QInputDeviceManager::DeviceTypePointer, 1);
+ QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
+ QInputDeviceManager::DeviceTypeKeyboard, 1);
+
+}
+
+bool QVncIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+ switch (cap) {
+ case ThreadedPixmaps: return true;
+ case WindowManagement: return false;
+ default: return QPlatformIntegration::hasCapability(cap);
+ }
+}
+
+QPlatformBackingStore *QVncIntegration::createPlatformBackingStore(QWindow *window) const
+{
+ return new QFbBackingStore(window);
+}
+
+QPlatformWindow *QVncIntegration::createPlatformWindow(QWindow *window) const
+{
+ return new QFbWindow(window);
+}
+
+QAbstractEventDispatcher *QVncIntegration::createEventDispatcher() const
+{
+ return createUnixEventDispatcher();
+}
+
+QList<QPlatformScreen *> QVncIntegration::screens() const
+{
+ QList<QPlatformScreen *> list;
+ list.append(m_primaryScreen);
+ return list;
+}
+
+QPlatformFontDatabase *QVncIntegration::fontDatabase() const
+{
+ return m_fontDb.data();
+}
+
+QPlatformServices *QVncIntegration::services() const
+{
+ return m_services.data();
+}
+
+QPlatformNativeInterface *QVncIntegration::nativeInterface() const
+{
+ return m_nativeInterface.data();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/vnc/qvncintegration.h b/src/plugins/platforms/vnc/qvncintegration.h
new file mode 100644
index 0000000000..293ff54376
--- /dev/null
+++ b/src/plugins/platforms/vnc/qvncintegration.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QVNCINTEGRATION_H
+#define QVNCINTEGRATION_H
+
+#include <qpa/qplatformintegration.h>
+#include <qpa/qplatformnativeinterface.h>
+
+QT_BEGIN_NAMESPACE
+
+class QAbstractEventDispatcher;
+class QVncScreen;
+class QVncServer;
+
+class QVncIntegration : public QPlatformIntegration, public QPlatformNativeInterface
+{
+public:
+ QVncIntegration(const QStringList &paramList);
+ ~QVncIntegration();
+
+ void initialize() Q_DECL_OVERRIDE;
+ bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE;
+
+ QPlatformWindow *createPlatformWindow(QWindow *window) const Q_DECL_OVERRIDE;
+ QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const Q_DECL_OVERRIDE;
+
+ QAbstractEventDispatcher *createEventDispatcher() const Q_DECL_OVERRIDE;
+
+ QPlatformFontDatabase *fontDatabase() const Q_DECL_OVERRIDE;
+ QPlatformServices *services() const Q_DECL_OVERRIDE;
+ QPlatformInputContext *inputContext() const Q_DECL_OVERRIDE { return m_inputContext; }
+
+ QPlatformNativeInterface *nativeInterface() const Q_DECL_OVERRIDE;
+
+ QList<QPlatformScreen *> screens() const;
+
+private:
+ mutable QVncServer *m_server;
+ QVncScreen *m_primaryScreen;
+ QPlatformInputContext *m_inputContext;
+ QScopedPointer<QPlatformFontDatabase> m_fontDb;
+ QScopedPointer<QPlatformServices> m_services;
+ QScopedPointer<QPlatformNativeInterface> m_nativeInterface;
+};
+
+QT_END_NAMESPACE
+
+#endif // QVNCINTEGRATION_H
diff --git a/src/plugins/platforms/vnc/qvncscreen.cpp b/src/plugins/platforms/vnc/qvncscreen.cpp
new file mode 100644
index 0000000000..6d117c62bf
--- /dev/null
+++ b/src/plugins/platforms/vnc/qvncscreen.cpp
@@ -0,0 +1,187 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qvncscreen.h"
+#include "qvnc_p.h"
+#include <QtPlatformSupport/private/qfbwindow_p.h>
+#include <QtPlatformSupport/private/qfbcursor_p.h>
+
+#include <QtGui/QPainter>
+#include <QtCore/QRegularExpression>
+
+
+QT_BEGIN_NAMESPACE
+
+
+QVncScreen::QVncScreen(const QStringList &args)
+ : mArgs(args)
+{
+ initialize();
+}
+
+QVncScreen::~QVncScreen()
+{
+ if (clientCursor)
+ delete clientCursor;
+}
+
+bool QVncScreen::initialize()
+{
+ QRegularExpression sizeRx(QLatin1String("size=(\\d+)x(\\d+)"));
+ QRegularExpression mmSizeRx(QLatin1String("mmsize=(?<width>(\\d*\\.)?\\d+)x(?<height>(\\d*\\.)?\\d+)"));
+ QRegularExpression depthRx(QLatin1String("depth=(\\d+)"));
+
+ mGeometry = QRect(0, 0, 1024, 768);
+ mFormat = QImage::Format_ARGB32_Premultiplied;
+ mDepth = 32;
+ mPhysicalSize = QSizeF(mGeometry.width()/96.*25.4, mGeometry.height()/96.*25.4);
+
+ for (const QString &arg : mArgs) {
+ QRegularExpressionMatch match;
+ if (arg.contains(mmSizeRx, &match)) {
+ mPhysicalSize = QSizeF(match.captured("width").toDouble(), match.captured("height").toDouble());
+ } else if (arg.contains(sizeRx, &match)) {
+ mGeometry.setSize(QSize(match.captured(1).toInt(), match.captured(2).toInt()));
+ } else if (arg.contains(depthRx, &match)) {
+ mDepth = match.captured(1).toInt();
+ }
+ }
+
+ QFbScreen::initializeCompositor();
+
+ switch (depth()) {
+ case 32:
+ dirty = new QVncDirtyMapOptimized<quint32>(this);
+ break;
+ case 16:
+ dirty = new QVncDirtyMapOptimized<quint16>(this);
+ break;
+ case 8:
+ dirty = new QVncDirtyMapOptimized<quint8>(this);
+ break;
+ default:
+ qWarning("QVNCScreen::initDevice: No support for screen depth %d",
+ depth());
+ dirty = 0;
+ return false;
+ }
+
+ setPowerState(PowerStateOff);
+
+ return true;
+}
+
+QRegion QVncScreen::doRedraw()
+{
+ QRegion touched = QFbScreen::doRedraw();
+
+ if (touched.isEmpty())
+ return touched;
+ dirtyRegion += touched;
+
+ vncServer->setDirty();
+ return touched;
+}
+
+void QVncScreen::enableClientCursor(QVncClient *client)
+{
+ delete mCursor;
+ mCursor = nullptr;
+ if (!clientCursor)
+ clientCursor = new QVncClientCursor();
+ clientCursor->addClient(client);
+}
+
+void QVncScreen::disableClientCursor(QVncClient *client)
+{
+ uint clientCount = clientCursor->removeClient(client);
+ if (clientCount == 0) {
+ delete clientCursor;
+ clientCursor = nullptr;
+ }
+
+ mCursor = new QFbCursor(this);
+}
+
+QPlatformCursor *QVncScreen::cursor() const
+{
+ return mCursor ? static_cast<QPlatformCursor *>(mCursor) : static_cast<QPlatformCursor *>(clientCursor);
+}
+
+// grabWindow() grabs "from the screen" not from the backingstores.
+// In linuxfb's case it will also include the mouse cursor.
+QPixmap QVncScreen::grabWindow(WId wid, int x, int y, int width, int height) const
+{
+ if (!wid) {
+ if (width < 0)
+ width = mScreenImage->width() - x;
+ if (height < 0)
+ height = mScreenImage->height() - y;
+ return QPixmap::fromImage(*mScreenImage).copy(x, y, width, height);
+ }
+
+ QFbWindow *window = windowForId(wid);
+ if (window) {
+ const QRect geom = window->geometry();
+ if (width < 0)
+ width = geom.width() - x;
+ if (height < 0)
+ height = geom.height() - y;
+ QRect rect(geom.topLeft() + QPoint(x, y), QSize(width, height));
+ rect &= window->geometry();
+ return QPixmap::fromImage(*mScreenImage).copy(rect);
+ }
+
+ return QPixmap();
+}
+
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+bool QVNCScreen::swapBytes() const
+{
+ if (depth() != 16)
+ return false;
+
+ if (screen())
+ return screen()->frameBufferLittleEndian();
+ return frameBufferLittleEndian();
+}
+#endif
+
+QT_END_NAMESPACE
+
diff --git a/src/plugins/platforms/vnc/qvncscreen.h b/src/plugins/platforms/vnc/qvncscreen.h
new file mode 100644
index 0000000000..e3c6651781
--- /dev/null
+++ b/src/plugins/platforms/vnc/qvncscreen.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtGui module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QVncScreen_H
+#define QVncScreen_H
+
+#include <QtPlatformSupport/private/qfbscreen_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QPainter;
+class QFbCursor;
+class QTcpSocket;
+class QVncServer;
+class QVncDirtyMap;
+class QVncClientCursor;
+class QVncClient;
+
+class QVncScreen : public QFbScreen
+{
+ Q_OBJECT
+public:
+ QVncScreen(const QStringList &args);
+ ~QVncScreen();
+
+ bool initialize();
+
+ QPixmap grabWindow(WId wid, int x, int y, int width, int height) const Q_DECL_OVERRIDE;
+
+ QRegion doRedraw() Q_DECL_OVERRIDE;
+ QImage *image() const { return mScreenImage; }
+
+ void enableClientCursor(QVncClient *client);
+ void disableClientCursor(QVncClient *client);
+ QPlatformCursor *cursor() const Q_DECL_OVERRIDE;
+
+ void clearDirty() { dirtyRegion = QRegion(); }
+
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+ bool swapBytes() const
+#endif
+
+ QStringList mArgs;
+
+ qreal dpiX = 96;
+ qreal dpiY = 96;
+ QVncDirtyMap *dirty = 0;
+ QRegion dirtyRegion;
+ int refreshRate = 30;
+ QVncServer *vncServer = 0;
+ QVncClientCursor *clientCursor = 0;
+};
+
+QT_END_NAMESPACE
+
+#endif // QVncScreen_H
+
diff --git a/src/plugins/platforms/vnc/vnc.json b/src/plugins/platforms/vnc/vnc.json
new file mode 100644
index 0000000000..6a16b08ca8
--- /dev/null
+++ b/src/plugins/platforms/vnc/vnc.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "vnc" ]
+}
diff --git a/src/plugins/platforms/vnc/vnc.pro b/src/plugins/platforms/vnc/vnc.pro
new file mode 100644
index 0000000000..9a1428ac39
--- /dev/null
+++ b/src/plugins/platforms/vnc/vnc.pro
@@ -0,0 +1,25 @@
+TARGET = qvnc
+
+PLUGIN_TYPE = platforms
+PLUGIN_CLASS_NAME = QVncIntegrationPlugin
+!equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = -
+load(qt_plugin)
+
+QT += core-private gui-private platformsupport-private network
+
+SOURCES = \
+ main.cpp \
+ qvncintegration.cpp \
+ qvncscreen.cpp \
+ qvnc.cpp \
+ qvncclient.cpp
+
+HEADERS = \
+ qvncintegration.h \
+ qvncscreen.h \
+ qvnc_p.h \
+ qvncclient.h
+
+CONFIG += qpa/genericunixfontdatabase
+
+OTHER_FILES += vnc.json
diff --git a/src/plugins/platforms/windows/accessible/accessible.pri b/src/plugins/platforms/windows/accessible/accessible.pri
index 0774d907f2..0e3aacc558 100644
--- a/src/plugins/platforms/windows/accessible/accessible.pri
+++ b/src/plugins/platforms/windows/accessible/accessible.pri
@@ -6,15 +6,13 @@ HEADERS += \
$$PWD/qwindowsaccessibility.h \
$$PWD/comutils.h
-!wince: {
- SOURCES += $$PWD/qwindowsmsaaaccessible.cpp
- HEADERS += $$PWD/qwindowsmsaaaccessible.h
+SOURCES += $$PWD/qwindowsmsaaaccessible.cpp
+HEADERS += $$PWD/qwindowsmsaaaccessible.h
- !mingw: {
- SOURCES += $$PWD/iaccessible2.cpp
- HEADERS += $$PWD/iaccessible2.h
- include(../../../../3rdparty/iaccessible2/iaccessible2.pri)
- }
+!mingw: {
+ SOURCES += $$PWD/iaccessible2.cpp
+ HEADERS += $$PWD/iaccessible2.h
+ include(../../../../3rdparty/iaccessible2/iaccessible2.pri)
}
mingw: LIBS *= -luuid
diff --git a/src/plugins/platforms/windows/accessible/comutils.cpp b/src/plugins/platforms/windows/accessible/comutils.cpp
index 7655bdf622..1c072c5e2c 100644
--- a/src/plugins/platforms/windows/accessible/comutils.cpp
+++ b/src/plugins/platforms/windows/accessible/comutils.cpp
@@ -170,7 +170,6 @@ bool QVariant2VARIANT(const QVariant &var, VARIANT &arg, const QByteArray &typeN
case QVariant::LongLong:
if (out && arg.vt == (VT_CY|VT_BYREF)) {
arg.pcyVal->int64 = qvar.toLongLong();
-#if !defined(Q_OS_WINCE) && defined(_MSC_VER) && _MSC_VER >= 1400
} else if (out && arg.vt == (VT_I8|VT_BYREF)) {
*arg.pllVal = qvar.toLongLong();
} else {
@@ -181,22 +180,11 @@ bool QVariant2VARIANT(const QVariant &var, VARIANT &arg, const QByteArray &typeN
arg.vt |= VT_BYREF;
}
}
-#else
- } else {
- arg.vt = VT_CY;
- arg.cyVal.int64 = qvar.toLongLong();
- if (out) {
- arg.pcyVal = new CY(arg.cyVal);
- arg.vt |= VT_BYREF;
- }
- }
-#endif
break;
case QVariant::ULongLong:
if (out && arg.vt == (VT_CY|VT_BYREF)) {
arg.pcyVal->int64 = qvar.toULongLong();
-#if !defined(Q_OS_WINCE) && defined(_MSC_VER) && _MSC_VER >= 1400
} else if (out && arg.vt == (VT_UI8|VT_BYREF)) {
*arg.pullVal = qvar.toULongLong();
} else {
@@ -207,18 +195,6 @@ bool QVariant2VARIANT(const QVariant &var, VARIANT &arg, const QByteArray &typeN
arg.vt |= VT_BYREF;
}
}
-#else
- } else {
- arg.vt = VT_CY;
- arg.cyVal.int64 = qvar.toULongLong();
- if (out) {
- arg.pcyVal = new CY(arg.cyVal);
- arg.vt |= VT_BYREF;
- }
- }
-
-#endif
-
break;
case QVariant::Bool:
diff --git a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp
index 4a3f0ccb2b..7cf24421f8 100644
--- a/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp
+++ b/src/plugins/platforms/windows/accessible/qwindowsaccessibility.cpp
@@ -56,12 +56,10 @@
#include <QtGui/qguiapplication.h>
#include "qwindowsaccessibility.h"
-#if !defined(Q_OS_WINCE)
-# ifdef Q_CC_MINGW
-# include "qwindowsmsaaaccessible.h"
-# else
-# include "iaccessible2.h"
-# endif
+#ifdef Q_CC_MINGW
+# include "qwindowsmsaaaccessible.h"
+#else
+# include "iaccessible2.h"
#endif
#include "comutils.h"
@@ -74,11 +72,7 @@
#include <winuser.h>
#if !defined(WINABLEAPI)
-# if defined(Q_OS_WINCE)
-# include <bldver.h>
-# else
-# include <winable.h>
-# endif
+# include <winable.h>
#endif
#include <servprov.h>
@@ -86,7 +80,7 @@
#include <comdef.h>
#endif
-#include "../qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
QT_BEGIN_NAMESPACE
@@ -153,10 +147,6 @@ void QWindowsAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event)
}
}
-#if defined(Q_OS_WINCE) // ### TODO: check for NotifyWinEvent in CE 6.0
- // There is no user32.lib nor NotifyWinEvent for CE
- return;
-#else
// An event has to be associated with a window,
// so find the first parent that is a widget and that has a WId
QAccessibleInterface *iface = event->accessibleInterface();
@@ -179,7 +169,6 @@ void QWindowsAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event)
event->type() != QAccessible::ObjectDestroyed) {
::NotifyWinEvent(event->type(), hWnd, OBJID_CLIENT, QAccessible::uniqueId(iface));
}
-#endif // Q_OS_WINCE
}
QWindow *QWindowsAccessibility::windowHelper(const QAccessibleInterface *iface)
@@ -202,11 +191,6 @@ QWindow *QWindowsAccessibility::windowHelper(const QAccessibleInterface *iface)
*/
IAccessible *QWindowsAccessibility::wrap(QAccessibleInterface *acc)
{
-#if defined(Q_OS_WINCE)
- Q_UNUSED(acc);
-
- return 0;
-#else
if (!acc)
return 0;
@@ -222,12 +206,10 @@ IAccessible *QWindowsAccessibility::wrap(QAccessibleInterface *acc)
IAccessible *iacc = 0;
wacc->QueryInterface(IID_IAccessible, reinterpret_cast<void **>(&iacc));
return iacc;
-#endif // defined(Q_OS_WINCE)
}
bool QWindowsAccessibility::handleAccessibleObjectFromWindowRequest(HWND hwnd, WPARAM wParam, LPARAM lParam, LRESULT *lResult)
{
-#if !defined(Q_OS_WINCE)
if (static_cast<long>(lParam) == static_cast<long>(UiaRootObjectId)) {
/* For UI Automation */
} else if (DWORD(lParam) == DWORD(OBJID_CLIENT)) {
@@ -263,12 +245,6 @@ bool QWindowsAccessibility::handleAccessibleObjectFromWindowRequest(HWND hwnd, W
}
}
}
-#else
- Q_UNUSED(hwnd);
- Q_UNUSED(wParam);
- Q_UNUSED(lParam);
- Q_UNUSED(lResult);
-#endif // !defined(Q_OS_WINCE)
return false;
}
diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp
index 0e2165cdcb..ff115a2249 100644
--- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp
+++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp
@@ -67,7 +67,7 @@
#endif
-#include "../qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h
index 2f8602e320..fd00f8ac8b 100644
--- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h
+++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.h
@@ -43,7 +43,7 @@
#ifndef QT_NO_ACCESSIBILITY
#include <QtCore/qglobal.h>
-#include "../qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtCore/qsharedpointer.h>
#include <QtGui/qaccessible.h>
#ifndef Q_CC_MINGW
diff --git a/src/plugins/platforms/windows/qplatformfunctions_wince.h b/src/plugins/platforms/windows/qplatformfunctions_wince.h
deleted file mode 100644
index 309191537a..0000000000
--- a/src/plugins/platforms/windows/qplatformfunctions_wince.h
+++ /dev/null
@@ -1,371 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPLATFORMFUNCTIONS_WCE_H
-#define QPLATFORMFUNCTIONS_WCE_H
-//
-// W A R N I N G
-// -------------
-//
-// This file is part of the QPA API and is not meant to be used
-// in applications. Usage of this API may make your code
-// source and binary incompatible with future versions of Qt.
-//
-
-#ifdef Q_OS_WINCE
-#include <QtCore/qfunctions_wince.h>
-#define UNDER_NT
-#include <wingdi.h>
-#include <objidl.h>
-
-#ifndef WM_MOUSELEAVE
-# define WM_MOUSELEAVE 0x02A3
-#endif
-
-#ifndef WM_TOUCH
-# define WM_TOUCH 0x0240
-#endif
-
-#ifndef WM_GETOBJECT
-#define WM_GETOBJECT 0x003D
-#endif
-
-#define GetWindowLongPtr GetWindowLong
-#define SetWindowLongPtr SetWindowLong
-#define GWLP_USERDATA GWL_USERDATA
-
-#ifndef CWP_SKIPINVISIBLE
-#define CWP_SKIPINVISIBLE 0x0001
-#define CWP_SKIPTRANSPARENT 0x0004
-#endif
-
-#ifndef CS_OWNDC
-#define CS_OWNDC 0x0020
-#endif
-
-#ifndef HWND_MESSAGE
-#define HWND_MESSAGE 0
-#endif
-
-// Real Value would be 0x40000000, but if we pass this to Windows Embedded Compact
-// he blits it wrongly, so lets not do any harm and define it to 0
-#ifndef CAPTUREBLT
-#define CAPTUREBLT (DWORD)0x0
-#endif
-
-#define SW_SHOWMINIMIZED SW_MINIMIZE
-#define SW_SHOWMINNOACTIVE SW_MINIMIZE
-
-#ifndef CF_DIBV5
-#define CF_DIBV5 17
-#endif
-
-#ifndef WM_MOUSEACTIVATE
-#define WM_MOUSEACTIVATE 0x0021
-#endif
-
-#ifndef WM_CHILDACTIVATE
-#define WM_CHILDACTIVATE 0x0022
-#endif
-
-#ifndef WM_PARENTNOTIFY
-#define WM_PARENTNOTIFY 0x0210
-#endif
-
-#ifndef WM_ENTERIDLE
-#define WM_ENTERIDLE 0x0121
-#endif
-
-#ifndef WM_GETMINMAXINFO
-#define WM_GETMINMAXINFO 0x0024
-#endif
-
-#ifndef WM_WINDOWPOSCHANGING
-#define WM_WINDOWPOSCHANGING 0x0046
-#endif
-
-#ifndef WM_NCMOUSEMOVE
-#define WM_NCMOUSEMOVE 0x00A0
-#endif
-
-#ifndef WM_NCMBUTTONDBLCLK
-#define WM_NCMBUTTONDBLCLK 0x00A
-#endif
-
-#ifndef WM_NCCREATE
-#define WM_NCCREATE 0x0081
-#endif
-
-#ifndef WM_NCCALCSIZE
-#define WM_NCCALCSIZE 0x0083
-#endif
-
-#ifndef WM_NCACTIVATE
-#define WM_NCACTIVATE 0x0086
-#endif
-
-#ifndef WM_NCMOUSELEAVE
-#define WM_NCMOUSELEAVE 0x02A2
-#endif
-
-#ifndef WM_NCLBUTTONDOWN
-#define WM_NCLBUTTONDOWN 0x00A1
-#endif
-
-#ifndef WM_NCLBUTTONUP
-#define WM_NCLBUTTONUP 0x00A2
-#endif
-
-#ifndef WM_NCPAINT
-#define WM_NCPAINT 0x0085
-#endif
-
-#ifndef WM_NCHITTEST
-#define WM_NCHITTEST 0x0084
-#endif
-
-#ifndef WM_THEMECHANGED
-#define WM_THEMECHANGED 0x031A
-#endif
-
-#ifndef WM_DISPLAYCHANGE
-#define WM_DISPLAYCHANGE 0x007E
-#endif
-
-#ifndef VREFRESH
-#define VREFRESH 116
-#endif
-
-#ifndef SM_SWAPBUTTON
-#define SM_SWAPBUTTON 23
-#endif
-
-// application defines
-#define SPI_SETNONCLIENTMETRICS 72
-#define SPI_SETICONTITLELOGFONT 0x0022
-#define WM_ACTIVATEAPP 0x001c
-#define SW_PARENTCLOSING 1
-#define SW_OTHERMAXIMIZED 2
-#define SW_PARENTOPENING 3
-#define SW_OTHERRESTORED 4
-#define GET_XBUTTON_WPARAM(wParam) (HIWORD(wParam))
-
-// drag n drop
-#ifndef CFSTR_PERFORMEDDROPEFFECT
-#define CFSTR_PERFORMEDDROPEFFECT TEXT("Performed DropEffect")
-#endif
-
-// QWidget
-#define SW_SHOWMINIMIZED SW_MINIMIZE
-
-// QRegion
-#define ALTERNATE 0
-#define WINDING 1
-
-// QFontEngine
-typedef struct _FIXED {
- WORD fract;
- short value;
-} FIXED;
-
-typedef struct tagPOINTFX {
- FIXED x;
- FIXED y;
-} POINTFX;
-
-typedef struct _MAT2 {
- FIXED eM11;
- FIXED eM12;
- FIXED eM21;
- FIXED eM22;
-} MAT2;
-
-typedef struct _GLYPHMETRICS {
- UINT gmBlackBoxX;
- UINT gmBlackBoxY;
- POINT gmptGlyphOrigin;
- short gmCellIncX;
- short gmCellIncY;
-} GLYPHMETRICS;
-
-typedef struct tagTTPOLYGONHEADER
-{
- DWORD cb;
- DWORD dwType;
- POINTFX pfxStart;
-} TTPOLYGONHEADER;
-
-typedef struct tagTTPOLYCURVE
-{
- WORD wType;
- WORD cpfx;
- POINTFX apfx[1];
-} TTPOLYCURVE;
-
-#define GGO_NATIVE 2
-#define GGO_GLYPH_INDEX 0x0080
-#define TT_PRIM_LINE 1
-#define TT_PRIM_QSPLINE 2
-#define TT_PRIM_CSPLINE 3
-#define ANSI_VAR_FONT 12
-
-#ifndef OleInitialize
-#define OleInitialize(a) 0
-#endif
-
-#ifndef SPI_GETSNAPTODEFBUTTON
-#define SPI_GETSNAPTODEFBUTTON 95
-#endif
-
-#ifndef WS_EX_LAYERED
-#define WS_EX_LAYERED 0x00080000
-#endif
-
-// Clipboard --------------------------------------------------------
-#ifndef WM_CHANGECBCHAIN
-#define WM_CHANGECBCHAIN 0x030D
-#endif
-
-#ifndef WM_DRAWCLIPBOARD
-#define WM_DRAWCLIPBOARD 0x0308
-#endif
-
-#include <QFileInfo>
-
-inline bool IsIconic( HWND /*hWnd*/ )
-{
- return false;
-}
-
-inline int AddFontResourceExW( LPCWSTR name, DWORD /*fl*/, PVOID /*res*/)
-{
- QString fName = QString::fromWCharArray(name);
- QFileInfo fileinfo(fName);
- fName = fileinfo.absoluteFilePath();
- return AddFontResource((LPCWSTR)fName.utf16());
-}
-
-inline bool RemoveFontResourceExW( LPCWSTR /*name*/, DWORD /*fl*/, PVOID /*pdv*/)
-{
- return 0;
-}
-
-inline void OleUninitialize()
-{
-}
-
-inline DWORD GetGlyphOutline( HDC /*hdc*/, UINT /*uChar*/, INT /*fuFormat*/, GLYPHMETRICS * /*lpgm*/,
- DWORD /*cjBuffer*/, LPVOID /*pvBuffer*/, CONST MAT2 * /*lpmat2*/ )
-{
- qFatal("GetGlyphOutline() not supported under Windows CE. Please try using freetype font-rendering, by "
- "passing the command line argument -platform windows:fontengine=freetype to the application.");
- return GDI_ERROR;
-}
-
-inline HWND GetAncestor(HWND hWnd, UINT /*gaFlags*/)
-{
- return GetParent(hWnd);
-}
-
-#ifndef GA_PARENT
-# define GA_PARENT 1
-#endif
-
-#ifndef SPI_SETFONTSMOOTHINGTYPE
-# define SPI_SETFONTSMOOTHINGTYPE 0x200B
-#endif
-#ifndef SPI_GETFONTSMOOTHINGTYPE
-# define SPI_GETFONTSMOOTHINGTYPE 0x200A
-#endif
-#ifndef FE_FONTSMOOTHINGCLEARTYPE
-# define FE_FONTSMOOTHINGCLEARTYPE 0x0002
-#endif
-
-#ifndef DEVICE_FONTTYPE
-#define DEVICE_FONTTYPE 0x0002
-#endif
-
-#ifndef RASTER_FONTTYPE
-#define RASTER_FONTTYPE 0x0001
-#endif
-
-#ifndef WM_DISPLAYCHANGE
-#define WM_DISPLAYCHANGE 0x007E
-#endif
-
-BOOL qt_wince_ChangeClipboardChain(
- HWND hWndRemove, // handle to window to remove
- HWND hWndNewNext // handle to next window
-);
-#define ChangeClipboardChain(a,b) qt_wince_ChangeClipboardChain(a,b);
-
-HWND qt_wince_SetClipboardViewer(
- HWND hWndNewViewer // handle to clipboard viewer window
-);
-#define SetClipboardViewer(a) qt_wince_SetClipboardViewer(a)
-
-/* Shell stock icon IDs
- SHGetStockIconInfo() is not available on CE, but we're using these
- constants in code that is built on CE as well */
- enum
- {
- SIID_INVALID = -1,
- SIID_DOCNOASSOC = 0,
- SIID_FOLDER = 3,
- SIID_FOLDEROPEN = 4,
- SIID_DRIVE35 = 6,
- SIID_DRIVEFIXED = 8,
- SIID_DRIVENET = 9,
- SIID_DRIVECD = 11,
- SIID_HELP = 23,
- SIID_RECYCLER = 31,
- SIID_DRIVEDVD = 59,
- SIID_SHIELD = 77,
- SIID_WARNING = 78,
- SIID_INFO = 79,
- SIID_ERROR = 80
-};
-
-#ifndef SHGSI_LINKOVERLAY
-// Value is wrong, but doesn't matter, not used at runtime
-#define SHGSI_LINKOVERLAY 0
-#endif
-
-#endif // Q_OS_WINCE
-#endif // QPLATFORMFUNCTIONS_WCE_H
diff --git a/src/plugins/platforms/windows/qtwindows_additional.h b/src/plugins/platforms/windows/qtwindows_additional.h
deleted file mode 100644
index 898a09fba7..0000000000
--- a/src/plugins/platforms/windows/qtwindows_additional.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTWINDOWS_ADDITIONAL_H
-#define QTWINDOWS_ADDITIONAL_H
-
-#include <QtCore/QtGlobal> // get compiler define
-#include <QtCore/qt_windows.h>
-
-#ifndef WM_THEMECHANGED
-# define WM_THEMECHANGED 0x031A
-#endif
-
-#ifndef WM_DWMCOMPOSITIONCHANGED
-# define WM_DWMCOMPOSITIONCHANGED 0x31E
-#endif
-
-#ifndef GWL_HWNDPARENT
-# define GWL_HWNDPARENT (-8)
-#endif
-
-/* Complement the definitions and declarations missing
- * when using MinGW or older Windows SDKs. */
-
-#if defined(Q_CC_MINGW)
-# if !defined(ULW_ALPHA)
-# define ULW_ALPHA 0x00000002
-# define LWA_ALPHA 0x00000002
-# endif // !defined(ULW_ALPHA)
-# define SPI_GETFONTSMOOTHINGTYPE 0x200A
-# define FE_FONTSMOOTHINGCLEARTYPE 0x0002
-# define CLEARTYPE_QUALITY 5
-# define SPI_GETDROPSHADOW 0x1024
-# define COLOR_MENUHILIGHT 29
-# define COLOR_MENUBAR 30
-# define CF_DIBV5 17
-
-#if !defined(CO_E_NOT_SUPPORTED)
-#define CO_E_NOT_SUPPORTED _HRESULT_TYPEDEF_(0x80004021L)
-#endif
-
-#define IFMETHOD HRESULT STDMETHODCALLTYPE
-#define IFACEMETHODIMP STDMETHODIMP
-#define IFACEMETHODIMP_(type) STDMETHODIMP_(type)
-
-// For accessibility:
-#ifdef __cplusplus
- #define EXTERN_C extern "C"
-#else
- #define EXTERN_C extern
-#endif
-
-#define CHILDID_SELF 0
-#define WM_GETOBJECT 0x003D
-
-#ifndef SHGFI_ADDOVERLAYS // Shell structures for icons.
-typedef struct _SHSTOCKICONINFO
-{
- DWORD cbSize;
- HICON hIcon;
- int iSysImageIndex;
- int iIcon;
- WCHAR szPath[MAX_PATH];
-} SHSTOCKICONINFO;
-
-# define SIID_SHIELD 77
-# define SHGFI_ADDOVERLAYS 0x20
-# define SHGFI_OVERLAYINDEX 0x40
-#endif // SIID_SHIELD
-
-#if !defined(__MINGW64_VERSION_MAJOR)
-
-#define STATE_SYSTEM_HASPOPUP 0x40000000
-#define STATE_SYSTEM_PROTECTED 0x20000000
-
-typedef struct tagUPDATELAYEREDWINDOWINFO {
- DWORD cbSize;
- HDC hdcDst;
- const POINT *pptDst;
- const SIZE *psize;
- HDC hdcSrc;
- const POINT *pptSrc;
- COLORREF crKey;
- const BLENDFUNCTION *pblend;
- DWORD dwFlags;
- const RECT *prcDirty;
-} UPDATELAYEREDWINDOWINFO, *PUPDATELAYEREDWINDOWINFO;
-
-#endif // if !defined(__MINGW64_VERSION_MAJOR)
-
-// OpenGL Pixelformat flags.
-#define PFD_SUPPORT_DIRECTDRAW 0x00002000
-#define PFD_DIRECT3D_ACCELERATED 0x00004000
-#define PFD_SUPPORT_COMPOSITION 0x00008000
-
-// IME.
-#define IMR_CONFIRMRECONVERTSTRING 0x0005
-
-#ifndef MAPVK_VK_TO_CHAR
-# define MAPVK_VK_TO_CHAR 2
-#endif
-
-#endif // if defined(Q_CC_MINGW)
-
-/* Touch is supported from Windows 7 onwards and data structures
- * are present in the Windows SDK's, but not in older MSVC Express
- * versions. */
-
-#if defined(Q_CC_MINGW) || !defined(TOUCHEVENTF_MOVE)
-
-#define WM_TOUCH 0x0240
-
-typedef struct tagTOUCHINPUT {
- LONG x;
- LONG y;
- HANDLE hSource;
- DWORD dwID;
- DWORD dwFlags;
- DWORD dwMask;
- DWORD dwTime;
- ULONG_PTR dwExtraInfo;
- DWORD cxContact;
- DWORD cyContact;
-} TOUCHINPUT, *PTOUCHINPUT;
-typedef TOUCHINPUT const * PCTOUCHINPUT;
-
-# define TOUCHEVENTF_MOVE 0x0001
-# define TOUCHEVENTF_DOWN 0x0002
-# define TOUCHEVENTF_UP 0x0004
-# define TOUCHEVENTF_INRANGE 0x0008
-# define TOUCHEVENTF_PRIMARY 0x0010
-# define TOUCHEVENTF_NOCOALESCE 0x0020
-# define TOUCHEVENTF_PALM 0x0080
-# define TOUCHINPUTMASKF_CONTACTAREA 0x0004
-# define TOUCHINPUTMASKF_EXTRAINFO 0x0002
-
-#endif // if defined(Q_CC_MINGW) || !defined(TOUCHEVENTF_MOVE)
-
-#ifndef WM_GESTURE
-# define WM_GESTURE 0x0119
-#endif
-
-#endif // QTWINDOWS_ADDITIONAL_H
diff --git a/src/plugins/platforms/windows/qtwindowsglobal.h b/src/plugins/platforms/windows/qtwindowsglobal.h
index 90008663e7..ec6a8f62ae 100644
--- a/src/plugins/platforms/windows/qtwindowsglobal.h
+++ b/src/plugins/platforms/windows/qtwindowsglobal.h
@@ -41,10 +41,19 @@
#ifndef QTWINDOWSGLOBAL_H
#define QTWINDOWSGLOBAL_H
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtCore/qnamespace.h>
-#ifdef Q_OS_WINCE
-# include "qplatformfunctions_wince.h"
+
+#ifndef WM_DWMCOMPOSITIONCHANGED // MinGW.
+# define WM_DWMCOMPOSITIONCHANGED 0x31E
+#endif
+
+#ifndef WM_TOUCH
+# define WM_TOUCH 0x0240
+#endif
+
+#ifndef WM_GESTURE
+# define WM_GESTURE 0x0119
#endif
QT_BEGIN_NAMESPACE
@@ -158,10 +167,8 @@ inline QtWindows::WindowsEventType windowsEventType(UINT message, WPARAM wParamI
case WM_MOUSEWHEEL:
case WM_MOUSEHWHEEL:
return QtWindows::MouseWheelEvent;
-#ifndef Q_OS_WINCE
case WM_WINDOWPOSCHANGING:
return QtWindows::GeometryChangingEvent;
-#endif
case WM_MOVE:
return QtWindows::MoveEvent;
case WM_SHOWWINDOW:
@@ -172,10 +179,8 @@ inline QtWindows::WindowsEventType windowsEventType(UINT message, WPARAM wParamI
return QtWindows::ResizeEvent;
case WM_NCCALCSIZE:
return QtWindows::CalculateSize;
-#ifndef Q_OS_WINCE
case WM_NCHITTEST:
return QtWindows::NonClientHitTest;
-#endif // !Q_OS_WINCE
case WM_GETMINMAXINFO:
return QtWindows::QuerySizeHints;
case WM_KEYDOWN: // keyboard event
@@ -243,12 +248,10 @@ inline QtWindows::WindowsEventType windowsEventType(UINT message, WPARAM wParamI
return QtWindows::ContextMenu;
#endif
case WM_SYSCOMMAND:
-#ifndef Q_OS_WINCE
if ((wParamIn & 0xfff0) == SC_CONTEXTHELP)
return QtWindows::WhatsThisEvent;
-#endif
break;
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
case WM_QUERYENDSESSION:
return QtWindows::QueryEndSessionApplicationEvent;
case WM_ENDSESSION:
diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.cpp b/src/plugins/platforms/windows/qwindowsbackingstore.cpp
index 7123ed826d..3b7374dc92 100644
--- a/src/plugins/platforms/windows/qwindowsbackingstore.cpp
+++ b/src/plugins/platforms/windows/qwindowsbackingstore.cpp
@@ -87,7 +87,6 @@ void QWindowsBackingStore::flush(QWindow *window, const QRegion &region,
QWindowsWindow *rw = QWindowsWindow::windowsWindowOf(window);
Q_ASSERT(rw);
-#ifndef Q_OS_WINCE
const bool hasAlpha = rw->format().hasAlpha();
const Qt::WindowFlags flags = window->flags();
if ((flags & Qt::FramelessWindowHint) && QWindowsWindow::setWindowLayered(rw->handle(), flags, hasAlpha, rw->opacity()) && hasAlpha) {
@@ -101,21 +100,16 @@ void QWindowsBackingStore::flush(QWindow *window, const QRegion &region,
POINT ptDst = {r.x(), r.y()};
POINT ptSrc = {0, 0};
BLENDFUNCTION blend = {AC_SRC_OVER, 0, BYTE(qRound(255.0 * rw->opacity())), AC_SRC_ALPHA};
- if (QWindowsContext::user32dll.updateLayeredWindowIndirect) {
- RECT dirty = {dirtyRect.x(), dirtyRect.y(),
- dirtyRect.x() + dirtyRect.width(), dirtyRect.y() + dirtyRect.height()};
- UPDATELAYEREDWINDOWINFO info = {sizeof(info), NULL, &ptDst, &size, m_image->hdc(), &ptSrc, 0, &blend, ULW_ALPHA, &dirty};
- const BOOL result = QWindowsContext::user32dll.updateLayeredWindowIndirect(rw->handle(), &info);
- if (!result)
- qErrnoWarning("UpdateLayeredWindowIndirect failed for ptDst=(%d, %d),"
- " size=(%dx%d), dirty=(%dx%d %d, %d)", r.x(), r.y(),
- r.width(), r.height(), dirtyRect.width(), dirtyRect.height(),
- dirtyRect.x(), dirtyRect.y());
- } else {
- QWindowsContext::user32dll.updateLayeredWindow(rw->handle(), NULL, &ptDst, &size, m_image->hdc(), &ptSrc, 0, &blend, ULW_ALPHA);
- }
+ RECT dirty = {dirtyRect.x(), dirtyRect.y(),
+ dirtyRect.x() + dirtyRect.width(), dirtyRect.y() + dirtyRect.height()};
+ UPDATELAYEREDWINDOWINFO info = {sizeof(info), NULL, &ptDst, &size, m_image->hdc(), &ptSrc, 0, &blend, ULW_ALPHA, &dirty};
+ const BOOL result = UpdateLayeredWindowIndirect(rw->handle(), &info);
+ if (!result)
+ qErrnoWarning("UpdateLayeredWindowIndirect failed for ptDst=(%d, %d),"
+ " size=(%dx%d), dirty=(%dx%d %d, %d)", r.x(), r.y(),
+ r.width(), r.height(), dirtyRect.width(), dirtyRect.height(),
+ dirtyRect.x(), dirtyRect.y());
} else {
-#endif
const HDC dc = rw->getDC();
if (!dc) {
qErrnoWarning("%s: GetDC failed", __FUNCTION__);
@@ -129,9 +123,7 @@ void QWindowsBackingStore::flush(QWindow *window, const QRegion &region,
qErrnoWarning(int(lastError), "%s: BitBlt failed", __FUNCTION__);
}
rw->releaseDC();
-#ifndef Q_OS_WINCE
}
-#endif
// Write image for debug purposes.
if (QWindowsContext::verbose > 2 && lcQpaBackingStore().isDebugEnabled()) {
@@ -175,7 +167,7 @@ void QWindowsBackingStore::resize(const QSize &size, const QRegion &region)
staticRegion &= QRect(0, 0, newimg.width(), newimg.height());
QPainter painter(&newimg);
painter.setCompositionMode(QPainter::CompositionMode_Source);
- foreach (const QRect &rect, staticRegion.rects())
+ for (const QRect &rect : staticRegion)
painter.drawImage(rect, oldimg, rect);
}
@@ -190,10 +182,9 @@ bool QWindowsBackingStore::scroll(const QRegion &area, int dx, int dy)
if (m_image.isNull() || m_image->image().isNull())
return false;
- const QVector<QRect> rects = area.rects();
const QPoint offset(dx, dy);
- for (int i = 0; i < rects.size(); ++i)
- qt_scrollRectInImage(m_image->image(), rects.at(i), offset);
+ for (const QRect &rect : area)
+ qt_scrollRectInImage(m_image->image(), rect, offset);
return true;
}
@@ -207,7 +198,7 @@ void QWindowsBackingStore::beginPaint(const QRegion &region)
QPainter p(&m_image->image());
p.setCompositionMode(QPainter::CompositionMode_Source);
const QColor blank = Qt::transparent;
- foreach (const QRect &r, region.rects())
+ for (const QRect &r : region)
p.fillRect(r, blank);
}
}
@@ -219,8 +210,6 @@ HDC QWindowsBackingStore::getDC() const
return 0;
}
-#ifndef QT_NO_OPENGL
-
QImage QWindowsBackingStore::toImage() const
{
if (m_image.isNull()) {
@@ -230,6 +219,4 @@ QImage QWindowsBackingStore::toImage() const
return m_image.data()->image();
}
-#endif // !QT_NO_OPENGL
-
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsbackingstore.h b/src/plugins/platforms/windows/qwindowsbackingstore.h
index 26c79348a9..46a7fcc676 100644
--- a/src/plugins/platforms/windows/qwindowsbackingstore.h
+++ b/src/plugins/platforms/windows/qwindowsbackingstore.h
@@ -40,7 +40,7 @@
#ifndef QWINDOWSBACKINGSTORE_H
#define QWINDOWSBACKINGSTORE_H
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <qpa/qplatformbackingstore.h>
#include <QtCore/QScopedPointer>
@@ -65,9 +65,7 @@ public:
HDC getDC() const;
-#ifndef QT_NO_OPENGL
QImage toImage() const Q_DECL_OVERRIDE;
-#endif
private:
QScopedPointer<QWindowsNativeImage> m_image;
diff --git a/src/plugins/platforms/windows/qwindowsclipboard.cpp b/src/plugins/platforms/windows/qwindowsclipboard.cpp
index d527e07308..21bc9d7377 100644
--- a/src/plugins/platforms/windows/qwindowsclipboard.cpp
+++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp
@@ -237,8 +237,7 @@ void QWindowsClipboard::propagateClipboardMessage(UINT message, WPARAM wParam, L
return;
// In rare cases, a clipboard viewer can hang (application crashed,
// suspended by a shell prompt 'Select' or debugger).
- if (QWindowsContext::user32dll.isHungAppWindow
- && QWindowsContext::user32dll.isHungAppWindow(m_nextClipboardViewer)) {
+ if (IsHungAppWindow(m_nextClipboardViewer)) {
qWarning("Cowardly refusing to send clipboard message to hung application...");
return;
}
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index 1dbac78fca..3a683bd7a0 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -52,7 +52,7 @@
#ifndef QT_NO_ACCESSIBILITY
# include "accessible/qwindowsaccessibility.h"
#endif
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
# include <private/qsessionmanager_p.h>
# include "qwindowssessionmanager.h"
#endif
@@ -77,9 +77,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <windowsx.h>
-#ifndef Q_OS_WINCE
-# include <comdef.h>
-#endif
+#include <comdef.h>
QT_BEGIN_NAMESPACE
@@ -100,45 +98,29 @@ int QWindowsContext::verbose = 0;
# define LANG_SYRIAC 0x5a
#endif
-static inline bool useRTL_Extensions(QSysInfo::WinVersion ver)
+static inline bool useRTL_Extensions()
{
- // This is SDK dependent on CE so out of scope for now
- if (QSysInfo::windowsVersion() & QSysInfo::WV_CE_based)
- return false;
- if ((ver & QSysInfo::WV_NT_based) && (ver >= QSysInfo::WV_VISTA)) {
- // Since the IsValidLanguageGroup/IsValidLocale functions always return true on
- // Vista, check the Keyboard Layouts for enabling RTL.
- if (const int nLayouts = GetKeyboardLayoutList(0, 0)) {
- QScopedArrayPointer<HKL> lpList(new HKL[nLayouts]);
- GetKeyboardLayoutList(nLayouts, lpList.data());
- for (int i = 0; i < nLayouts; ++i) {
- switch (PRIMARYLANGID((quintptr)lpList[i])) {
- case LANG_ARABIC:
- case LANG_HEBREW:
- case LANG_FARSI:
- case LANG_SYRIAC:
- return true;
- default:
- break;
- }
+ // Since the IsValidLanguageGroup/IsValidLocale functions always return true on
+ // Vista, check the Keyboard Layouts for enabling RTL.
+ if (const int nLayouts = GetKeyboardLayoutList(0, 0)) {
+ QScopedArrayPointer<HKL> lpList(new HKL[nLayouts]);
+ GetKeyboardLayoutList(nLayouts, lpList.data());
+ for (int i = 0; i < nLayouts; ++i) {
+ switch (PRIMARYLANGID((quintptr)lpList[i])) {
+ case LANG_ARABIC:
+ case LANG_HEBREW:
+ case LANG_FARSI:
+ case LANG_SYRIAC:
+ return true;
+ default:
+ break;
}
}
- return false;
- } // NT/Vista
-#ifndef Q_OS_WINCE
- // Pre-NT: figure out whether a RTL language is installed
- return IsValidLanguageGroup(LGRPID_ARABIC, LGRPID_INSTALLED)
- || IsValidLanguageGroup(LGRPID_HEBREW, LGRPID_INSTALLED)
- || IsValidLocale(MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED)
- || IsValidLocale(MAKELCID(MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED)
- || IsValidLocale(MAKELCID(MAKELANGID(LANG_SYRIAC, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED)
- || IsValidLocale(MAKELCID(MAKELANGID(LANG_FARSI, SUBLANG_DEFAULT), SORT_DEFAULT), LCID_INSTALLED);
-#else
+ }
return false;
-#endif
}
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
static inline QWindowsSessionManager *platformSessionManager() {
QGuiApplicationPrivate *guiPrivate = static_cast<QGuiApplicationPrivate*>(QObjectPrivate::get(qApp));
QSessionManagerPrivate *managerPrivate = static_cast<QSessionManagerPrivate*>(QObjectPrivate::get(guiPrivate->session_manager));
@@ -161,13 +143,8 @@ static inline QWindowsSessionManager *platformSessionManager() {
\internal
\ingroup qt-lighthouse-win
*/
-
-#ifndef Q_OS_WINCE
-
QWindowsUser32DLL::QWindowsUser32DLL() :
- setLayeredWindowAttributes(0), updateLayeredWindow(0),
- updateLayeredWindowIndirect(0),
- isHungAppWindow(0), isTouchWindow(0),
+ isTouchWindow(0),
registerTouchWindow(0), unregisterTouchWindow(0),
getTouchInputInfo(0), closeTouchInputHandle(0), setProcessDPIAware(0),
addClipboardFormatListener(0), removeClipboardFormatListener(0),
@@ -178,20 +155,11 @@ QWindowsUser32DLL::QWindowsUser32DLL() :
void QWindowsUser32DLL::init()
{
QSystemLibrary library(QStringLiteral("user32"));
- // MinGW (g++ 3.4.5) accepts only C casts.
- setLayeredWindowAttributes = (SetLayeredWindowAttributes)(library.resolve("SetLayeredWindowAttributes"));
- updateLayeredWindow = (UpdateLayeredWindow)(library.resolve("UpdateLayeredWindow"));
- if (Q_UNLIKELY(!setLayeredWindowAttributes || !updateLayeredWindow))
- qFatal("This version of Windows is not supported (User32.dll is missing the symbols 'SetLayeredWindowAttributes', 'UpdateLayeredWindow').");
-
- updateLayeredWindowIndirect = (UpdateLayeredWindowIndirect)(library.resolve("UpdateLayeredWindowIndirect"));
- isHungAppWindow = (IsHungAppWindow)library.resolve("IsHungAppWindow");
setProcessDPIAware = (SetProcessDPIAware)library.resolve("SetProcessDPIAware");
- if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) {
- addClipboardFormatListener = (AddClipboardFormatListener)library.resolve("AddClipboardFormatListener");
- removeClipboardFormatListener = (RemoveClipboardFormatListener)library.resolve("RemoveClipboardFormatListener");
- }
+ addClipboardFormatListener = (AddClipboardFormatListener)library.resolve("AddClipboardFormatListener");
+ removeClipboardFormatListener = (RemoveClipboardFormatListener)library.resolve("RemoveClipboardFormatListener");
+
getDisplayAutoRotationPreferences = (GetDisplayAutoRotationPreferences)library.resolve("GetDisplayAutoRotationPreferences");
setDisplayAutoRotationPreferences = (SetDisplayAutoRotationPreferences)library.resolve("SetDisplayAutoRotationPreferences");
}
@@ -209,38 +177,6 @@ bool QWindowsUser32DLL::initTouch()
return isTouchWindow && registerTouchWindow && unregisterTouchWindow && getTouchInputInfo && closeTouchInputHandle;
}
-/*!
- \class QWindowsShell32DLL
- \brief Struct that contains dynamically resolved symbols of Shell32.dll.
-
- The stub libraries shipped with the MinGW compiler miss some of the
- functions. They need to be retrieved dynamically.
-
- \sa QWindowsUser32DLL
-
- \internal
- \ingroup qt-lighthouse-win
-*/
-
-QWindowsShell32DLL::QWindowsShell32DLL()
- : sHCreateItemFromParsingName(0)
- , sHGetKnownFolderIDList(0)
- , sHGetStockIconInfo(0)
- , sHGetImageList(0)
- , sHCreateItemFromIDList(0)
-{
-}
-
-void QWindowsShell32DLL::init()
-{
- QSystemLibrary library(QStringLiteral("shell32"));
- sHCreateItemFromParsingName = (SHCreateItemFromParsingName)(library.resolve("SHCreateItemFromParsingName"));
- sHGetKnownFolderIDList = (SHGetKnownFolderIDList)(library.resolve("SHGetKnownFolderIDList"));
- sHGetStockIconInfo = (SHGetStockIconInfo)library.resolve("SHGetStockIconInfo");
- sHGetImageList = (SHGetImageList)library.resolve("SHGetImageList");
- sHCreateItemFromIDList = (SHCreateItemFromIDList)library.resolve("SHCreateItemFromIDList");
-}
-
QWindowsShcoreDLL::QWindowsShcoreDLL()
: getProcessDpiAwareness(0)
, setProcessDpiAwareness(0)
@@ -259,11 +195,8 @@ void QWindowsShcoreDLL::init()
}
QWindowsUser32DLL QWindowsContext::user32dll;
-QWindowsShell32DLL QWindowsContext::shell32dll;
QWindowsShcoreDLL QWindowsContext::shcoredll;
-#endif // !Q_OS_WINCE
-
QWindowsContext *QWindowsContext::m_instance = 0;
/*!
@@ -292,7 +225,7 @@ struct QWindowsContextPrivate {
QWindowsMimeConverter m_mimeConverter;
QWindowsScreenManager m_screenManager;
QSharedPointer<QWindowCreationContext> m_creationContext;
-#if !defined(QT_NO_TABLETEVENT) && !defined(Q_OS_WINCE)
+#if !defined(QT_NO_TABLETEVENT)
QScopedPointer<QWindowsTabletSupport> m_tabletSupport;
#endif
const HRESULT m_oleInitializeResult;
@@ -307,18 +240,14 @@ QWindowsContextPrivate::QWindowsContextPrivate()
, m_eventType(QByteArrayLiteral("windows_generic_MSG"))
, m_lastActiveWindow(0), m_asyncExpose(0)
{
- const QSysInfo::WinVersion ver = QSysInfo::windowsVersion();
-#ifndef Q_OS_WINCE
QWindowsContext::user32dll.init();
- QWindowsContext::shell32dll.init();
QWindowsContext::shcoredll.init();
if (m_mouseHandler.touchDevice() && QWindowsContext::user32dll.initTouch())
m_systemInfo |= QWindowsContext::SI_SupportsTouch;
-#endif // !Q_OS_WINCE
m_displayContext = GetDC(0);
m_defaultDPI = GetDeviceCaps(m_displayContext, LOGPIXELSY);
- if (useRTL_Extensions(ver)) {
+ if (useRTL_Extensions()) {
m_systemInfo |= QWindowsContext::SI_RTL_Extensions;
m_keyMapper.setUseRTLExtensions(true);
}
@@ -339,7 +268,7 @@ QWindowsContext::QWindowsContext() :
const QByteArray bv = qgetenv("QT_QPA_VERBOSE");
if (!bv.isEmpty())
QLoggingCategory::setFilterRules(QString::fromLocal8Bit(bv));
-#if !defined(QT_NO_TABLETEVENT) && !defined(Q_OS_WINCE)
+#if !defined(QT_NO_TABLETEVENT)
d->m_tabletSupport.reset(QWindowsTabletSupport::create());
qCDebug(lcQpaTablet) << "Tablet support: " << (d->m_tabletSupport.isNull() ? QStringLiteral("None") : d->m_tabletSupport->description());
#endif
@@ -347,7 +276,7 @@ QWindowsContext::QWindowsContext() :
QWindowsContext::~QWindowsContext()
{
-#if !defined(QT_NO_TABLETEVENT) && !defined(Q_OS_WINCE)
+#if !defined(QT_NO_TABLETEVENT)
d->m_tabletSupport.reset(); // Destroy internal window before unregistering classes.
#endif
unregisterWindowClasses();
@@ -372,12 +301,10 @@ bool QWindowsContext::initTouch(unsigned integrationOptions)
if (!touchDevice)
return false;
-#ifndef Q_OS_WINCE
if (!QWindowsContext::user32dll.initTouch()) {
delete touchDevice;
return false;
}
-#endif // !Q_OS_WINCE
if (!(integrationOptions & QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch))
touchDevice->setCapabilities(touchDevice->capabilities() | QTouchDevice::MouseEmulation);
@@ -390,7 +317,7 @@ bool QWindowsContext::initTouch(unsigned integrationOptions)
void QWindowsContext::setTabletAbsoluteRange(int a)
{
-#if !defined(QT_NO_TABLETEVENT) && !defined(Q_OS_WINCE)
+#if !defined(QT_NO_TABLETEVENT)
if (!d->m_tabletSupport.isNull())
d->m_tabletSupport->setAbsoluteRange(a);
#else
@@ -400,19 +327,16 @@ void QWindowsContext::setTabletAbsoluteRange(int a)
int QWindowsContext::processDpiAwareness()
{
-#ifndef Q_OS_WINCE
int result;
if (QWindowsContext::shcoredll.getProcessDpiAwareness
&& SUCCEEDED(QWindowsContext::shcoredll.getProcessDpiAwareness(NULL, &result))) {
return result;
}
-#endif // !Q_OS_WINCE
return -1;
}
void QWindowsContext::setProcessDpiAwareness(QtWindows::ProcessDpiAwareness dpiAwareness)
{
-#ifndef Q_OS_WINCE
qCDebug(lcQpaWindows) << __FUNCTION__ << dpiAwareness;
if (QWindowsContext::shcoredll.isValid()) {
const HRESULT hr = QWindowsContext::shcoredll.setProcessDpiAwareness(dpiAwareness);
@@ -429,9 +353,6 @@ void QWindowsContext::setProcessDpiAwareness(QtWindows::ProcessDpiAwareness dpiA
qErrnoWarning("SetProcessDPIAware() failed");
}
}
-#else // !Q_OS_WINCE
- Q_UNUSED(dpiAwareness)
-#endif
}
QWindowsContext *QWindowsContext::instance()
@@ -563,19 +484,14 @@ QString QWindowsContext::registerWindowClass(QString cname,
if (d->m_registeredWindowClassNames.contains(cname)) // already registered in our list
return cname;
-#ifndef Q_OS_WINCE
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
-#else
- WNDCLASS wc;
-#endif
wc.style = style;
wc.lpfnWndProc = proc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = appInstance;
wc.hCursor = 0;
-#ifndef Q_OS_WINCE
wc.hbrBackground = brush;
if (icon) {
wc.hIcon = static_cast<HICON>(LoadImage(appInstance, L"IDI_ICON1", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE));
@@ -591,22 +507,10 @@ QString QWindowsContext::registerWindowClass(QString cname,
wc.hIcon = 0;
wc.hIconSm = 0;
}
-#else
- if (icon) {
- wc.hIcon = (HICON)LoadImage(appInstance, L"IDI_ICON1", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE);
- } else {
- wc.hIcon = 0;
- }
-#endif
wc.lpszMenuName = 0;
wc.lpszClassName = reinterpret_cast<LPCWSTR>(cname.utf16());
-#ifndef Q_OS_WINCE
ATOM atom = RegisterClassEx(&wc);
-#else
- ATOM atom = RegisterClass(&wc);
-#endif
-
if (!atom)
qErrnoWarning("QApplication::regClass: Registering window class '%s' failed.",
qPrintable(cname));
@@ -724,28 +628,14 @@ static inline bool findPlatformWindowHelper(const POINT &screenPoint, unsigned c
POINT point = screenPoint;
ScreenToClient(*hwnd, &point);
// Returns parent if inside & none matched.
-#ifndef Q_OS_WINCE
const HWND child = ChildWindowFromPointEx(*hwnd, point, cwexFlags);
-#else
-// Under Windows CE we don't use ChildWindowFromPointEx as it's not available
-// and ChildWindowFromPoint does not work properly.
- Q_UNUSED(cwexFlags)
- const HWND child = WindowFromPoint(point);
-#endif
if (!child || child == *hwnd)
return false;
if (QWindowsWindow *window = context->findPlatformWindow(child)) {
*result = window;
*hwnd = child;
-#ifndef Q_OS_WINCE
return true;
-#else
-// WindowFromPoint does not return same handle in two sequential calls, which leads
-// to an endless loop, but calling WindowFromPoint once is good enough.
- return false;
-#endif
}
-#ifndef Q_OS_WINCE // Does not have WS_EX_TRANSPARENT .
// QTBUG-40555: despite CWP_SKIPINVISIBLE, it is possible to hit on invisible
// full screen windows of other applications that have WS_EX_TRANSPARENT set
// (for example created by screen sharing applications). In that case, try to
@@ -761,7 +651,6 @@ static inline bool findPlatformWindowHelper(const POINT &screenPoint, unsigned c
return true;
}
}
-#endif // !Q_OS_WINCE
*hwnd = child;
return true;
}
@@ -788,7 +677,7 @@ QWindowsScreenManager &QWindowsContext::screenManager()
QWindowsTabletSupport *QWindowsContext::tabletSupport() const
{
-#if !defined(QT_NO_TABLETEVENT) && !defined(Q_OS_WINCE)
+#if !defined(QT_NO_TABLETEVENT)
return d->m_tabletSupport.data();
#else
return 0;
@@ -814,7 +703,6 @@ HWND QWindowsContext::createDummyWindow(const QString &classNameIn,
HWND_MESSAGE, NULL, static_cast<HINSTANCE>(GetModuleHandle(0)), NULL);
}
-#ifndef Q_OS_WINCE
// Re-engineered from the inline function _com_error::ErrorMessage().
// We cannot use it directly since it uses swprintf_s(), which is not
// present in the MSVCRT.DLL found on Windows XP (QTBUG-35617).
@@ -833,7 +721,6 @@ static inline QString errorMessageFromComError(const _com_error &comError)
return QString::asprintf("IDispatch error #%u", uint(wCode));
return QString::asprintf("Unknown error 0x0%x", uint(comError.Error()));
}
-#endif // !Q_OS_WINCE
/*!
\brief Common COM error strings.
@@ -901,12 +788,10 @@ QByteArray QWindowsContext::comErrorString(HRESULT hr)
default:
break;
}
-#ifndef Q_OS_WINCE
_com_error error(hr);
result += QByteArrayLiteral(" (");
result += errorMessageFromComError(error);
result += ')';
-#endif // !Q_OS_WINCE
return result;
}
@@ -942,9 +827,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
ClientToScreen(msg.hwnd, &msg.pt);
}
} else {
-#ifndef Q_OS_WINCE
GetCursorPos(&msg.pt);
-#endif
}
// Run the native event filters.
@@ -987,7 +870,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
switch (et) {
case QtWindows::GestureEvent:
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
return platformSessionManager()->isInteractionBlocked() ? true : d->m_mouseHandler.translateGestureEvent(platformWindow->window(), hwnd, et, msg, result);
#else
return d->m_mouseHandler.translateGestureEvent(platformWindow->window(), hwnd, et, msg, result);
@@ -1028,11 +911,9 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
// Pass on to current creation context
if (!platformWindow && !d->m_creationContext.isNull()) {
switch (et) {
-#ifndef Q_OS_WINCE // maybe available on some SDKs revisit WM_GETMINMAXINFO
case QtWindows::QuerySizeHints:
d->m_creationContext->applyToMinMaxInfo(reinterpret_cast<MINMAXINFO *>(lParam));
return true;
-#endif
case QtWindows::ResizeEvent:
d->m_creationContext->obtainedGeometry.setSize(QSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)));
return true;
@@ -1070,7 +951,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
case QtWindows::InputMethodKeyEvent:
case QtWindows::InputMethodKeyDownEvent:
case QtWindows::AppCommandEvent:
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
return platformSessionManager()->isInteractionBlocked() ? true : d->m_keyMapper.translateKeyEvent(platformWindow->window(), hwnd, msg, result);
#else
return d->m_keyMapper.translateKeyEvent(platformWindow->window(), hwnd, msg, result);
@@ -1081,7 +962,6 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
case QtWindows::ResizeEvent:
platformWindow->handleResized(static_cast<int>(wParam));
return true;
-#ifndef Q_OS_WINCE // maybe available on some SDKs revisit WM_GETMINMAXINFO
case QtWindows::QuerySizeHints:
platformWindow->getSizeHints(reinterpret_cast<MINMAXINFO *>(lParam));
return true;// maybe available on some SDKs revisit WM_NCCALCSIZE
@@ -1091,30 +971,18 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
return platformWindow->handleNonClientHitTest(QPoint(msg.pt.x, msg.pt.y), result);
case QtWindows::GeometryChangingEvent:
return platformWindow->QWindowsWindow::handleGeometryChanging(&msg);
-#endif // !Q_OS_WINCE
case QtWindows::ExposeEvent:
return platformWindow->handleWmPaint(hwnd, message, wParam, lParam);
case QtWindows::NonClientMouseEvent:
if (platformWindow->frameStrutEventsEnabled())
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
return platformSessionManager()->isInteractionBlocked() ? true : d->m_mouseHandler.translateMouseEvent(platformWindow->window(), hwnd, et, msg, result);
#else
return d->m_mouseHandler.translateMouseEvent(platformWindow->window(), hwnd, et, msg, result);
#endif
break;
-/* the mouse tracking on windows already handles the reset of the cursor
- * and does not like somebody else handling it.
- * on WINCE its necessary to handle this event to get the correct cursor
- */
-#ifdef Q_OS_WINCE
- case QtWindows::CursorEvent:
- {
- QWindowsWindow::baseWindowOf(platformWindow->window())->applyCursor();
- return true;
- }
-#endif
case QtWindows::ScrollEvent:
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
return platformSessionManager()->isInteractionBlocked() ? true : d->m_mouseHandler.translateScrollEvent(platformWindow->window(), hwnd, msg, result);
#else
return d->m_mouseHandler.translateScrollEvent(platformWindow->window(), hwnd, msg, result);
@@ -1122,13 +990,13 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
case QtWindows::MouseWheelEvent:
case QtWindows::MouseEvent:
case QtWindows::LeaveEvent:
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
return platformSessionManager()->isInteractionBlocked() ? true : d->m_mouseHandler.translateMouseEvent(platformWindow->window(), hwnd, et, msg, result);
#else
return d->m_mouseHandler.translateMouseEvent(platformWindow->window(), hwnd, et, msg, result);
#endif
case QtWindows::TouchEvent:
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
return platformSessionManager()->isInteractionBlocked() ? true : d->m_mouseHandler.translateTouchEvent(platformWindow->window(), hwnd, et, msg, result);
#else
return d->m_mouseHandler.translateTouchEvent(platformWindow->window(), hwnd, et, msg, result);
@@ -1161,7 +1029,6 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
case QtWindows::CompositionSettingsChanged:
platformWindow->handleCompositionSettingsChanged();
return true;
-#ifndef Q_OS_WINCE
case QtWindows::ActivateWindowEvent:
if (platformWindow->window()->flags() & Qt::WindowDoesNotAcceptFocus) {
*result = LRESULT(MA_NOACTIVATE);
@@ -1184,7 +1051,6 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
return true;
}
break;
-#endif
#ifndef QT_NO_CONTEXTMENU
case QtWindows::ContextMenu:
return handleContextMenuEvent(platformWindow->window(), msg);
@@ -1195,7 +1061,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
return true;
#endif
} break;
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
case QtWindows::QueryEndSessionApplicationEvent: {
QWindowsSessionManager *sessionManager = platformSessionManager();
if (sessionManager->isActive()) { // bogus message from windows
@@ -1235,7 +1101,7 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
}
return true;
}
-#endif // !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#endif // !defined(QT_NO_SESSIONMANAGER)
default:
break;
}
diff --git a/src/plugins/platforms/windows/qwindowscontext.h b/src/plugins/platforms/windows/qwindowscontext.h
index 3559335747..843f7e2ad6 100644
--- a/src/plugins/platforms/windows/qwindowscontext.h
+++ b/src/plugins/platforms/windows/qwindowscontext.h
@@ -41,7 +41,7 @@
#define QWINDOWSCONTEXT_H
#include "qtwindowsglobal.h"
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtCore/QScopedPointer>
#include <QtCore/QSharedPointer>
@@ -79,38 +79,23 @@ class QPoint;
class QKeyEvent;
class QTouchDevice;
-#ifndef Q_OS_WINCE
struct QWindowsUser32DLL
{
QWindowsUser32DLL();
inline void init();
inline bool initTouch();
- typedef BOOL (WINAPI *IsTouchWindow)(HWND, PULONG);
+ typedef BOOL (WINAPI *IsTouchWindow)(HWND, PULONG); // Windows 7
typedef BOOL (WINAPI *RegisterTouchWindow)(HWND, ULONG);
typedef BOOL (WINAPI *UnregisterTouchWindow)(HWND);
typedef BOOL (WINAPI *GetTouchInputInfo)(HANDLE, UINT, PVOID, int);
typedef BOOL (WINAPI *CloseTouchInputHandle)(HANDLE);
- typedef BOOL (WINAPI *SetLayeredWindowAttributes)(HWND, COLORREF, BYTE, DWORD);
- typedef BOOL (WINAPI *UpdateLayeredWindow)(HWND, HDC , const POINT *,
- const SIZE *, HDC, const POINT *, COLORREF,
- const BLENDFUNCTION *, DWORD);
- typedef BOOL (WINAPI *UpdateLayeredWindowIndirect)(HWND, const UPDATELAYEREDWINDOWINFO *);
- typedef BOOL (WINAPI *IsHungAppWindow)(HWND);
typedef BOOL (WINAPI *SetProcessDPIAware)();
typedef BOOL (WINAPI *AddClipboardFormatListener)(HWND);
typedef BOOL (WINAPI *RemoveClipboardFormatListener)(HWND);
typedef BOOL (WINAPI *GetDisplayAutoRotationPreferences)(DWORD *);
typedef BOOL (WINAPI *SetDisplayAutoRotationPreferences)(DWORD);
- // Functions missing in Q_CC_GNU stub libraries.
- SetLayeredWindowAttributes setLayeredWindowAttributes;
- UpdateLayeredWindow updateLayeredWindow;
-
- // Functions missing in older versions of Windows
- UpdateLayeredWindowIndirect updateLayeredWindowIndirect;
- IsHungAppWindow isHungAppWindow;
-
// Touch functions from Windows 7 onwards (also for use with Q_CC_MSVC).
IsTouchWindow isTouchWindow;
RegisterTouchWindow registerTouchWindow;
@@ -121,7 +106,8 @@ struct QWindowsUser32DLL
// Windows Vista onwards
SetProcessDPIAware setProcessDPIAware;
- // Clipboard listeners, Windows Vista onwards
+ // Clipboard listeners are present on Windows Vista onwards
+ // but missing in MinGW 4.9 stub libs. Can be removed in MinGW 5.
AddClipboardFormatListener addClipboardFormatListener;
RemoveClipboardFormatListener removeClipboardFormatListener;
@@ -130,24 +116,6 @@ struct QWindowsUser32DLL
SetDisplayAutoRotationPreferences setDisplayAutoRotationPreferences;
};
-struct QWindowsShell32DLL
-{
- QWindowsShell32DLL();
- inline void init();
-
- typedef HRESULT (WINAPI *SHCreateItemFromParsingName)(PCWSTR, IBindCtx *, const GUID&, void **);
- typedef HRESULT (WINAPI *SHGetKnownFolderIDList)(const GUID &, DWORD, HANDLE, PIDLIST_ABSOLUTE *);
- typedef HRESULT (WINAPI *SHGetStockIconInfo)(int , int , _SHSTOCKICONINFO *);
- typedef HRESULT (WINAPI *SHGetImageList)(int, REFIID , void **);
- typedef HRESULT (WINAPI *SHCreateItemFromIDList)(PCIDLIST_ABSOLUTE, REFIID, void **);
-
- SHCreateItemFromParsingName sHCreateItemFromParsingName;
- SHGetKnownFolderIDList sHGetKnownFolderIDList;
- SHGetStockIconInfo sHGetStockIconInfo;
- SHGetImageList sHGetImageList;
- SHCreateItemFromIDList sHCreateItemFromIDList;
-};
-
// Shell scaling library (Windows 8.1 onwards)
struct QWindowsShcoreDLL {
QWindowsShcoreDLL();
@@ -163,8 +131,6 @@ struct QWindowsShcoreDLL {
GetDpiForMonitor getDpiForMonitor;
};
-#endif // Q_OS_WINCE
-
class QWindowsContext
{
Q_DISABLE_COPY(QWindowsContext)
@@ -236,11 +202,9 @@ public:
QWindowsMimeConverter &mimeConverter() const;
QWindowsScreenManager &screenManager();
QWindowsTabletSupport *tabletSupport() const;
-#ifndef Q_OS_WINCE
+
static QWindowsUser32DLL user32dll;
- static QWindowsShell32DLL shell32dll;
static QWindowsShcoreDLL shcoredll;
-#endif
static QByteArray comErrorString(HRESULT hr);
bool asyncExpose() const;
diff --git a/src/plugins/platforms/windows/qwindowscursor.cpp b/src/plugins/platforms/windows/qwindowscursor.cpp
index d02648fade..1bebe88df7 100644
--- a/src/plugins/platforms/windows/qwindowscursor.cpp
+++ b/src/plugins/platforms/windows/qwindowscursor.cpp
@@ -56,7 +56,7 @@
static bool initResources()
{
-#if !defined (Q_OS_WINCE) && !defined (QT_NO_IMAGEFORMAT_PNG)
+#if !defined (QT_NO_IMAGEFORMAT_PNG)
Q_INIT_RESOURCE(cursors);
#endif
return true;
@@ -143,7 +143,6 @@ static HCURSOR createBitmapCursor(const QImage &bbits, const QImage &mbits,
if (hotSpot.y() < 0)
hotSpot.setY(height / 2);
const int n = qMax(1, width / 8);
-#if !defined(Q_OS_WINCE)
QScopedArrayPointer<uchar> xBits(new uchar[height * n]);
QScopedArrayPointer<uchar> xMask(new uchar[height * n]);
int x = 0;
@@ -164,54 +163,6 @@ static HCURSOR createBitmapCursor(const QImage &bbits, const QImage &mbits,
}
return CreateCursor(GetModuleHandle(0), hotSpot.x(), hotSpot.y(), width, height,
xBits.data(), xMask.data());
-#elif defined(GWES_ICONCURS) // Q_OS_WINCE
- // Windows CE only supports fixed cursor size.
- int sysW = GetSystemMetrics(SM_CXCURSOR);
- int sysH = GetSystemMetrics(SM_CYCURSOR);
- int sysN = qMax(1, sysW / 8);
- uchar* xBits = new uchar[sysH * sysN];
- uchar* xMask = new uchar[sysH * sysN];
- int x = 0;
- for (int i = 0; i < sysH; ++i) {
- if (i >= height) {
- memset(&xBits[x] , 255, sysN);
- memset(&xMask[x] , 0, sysN);
- x += sysN;
- } else {
- int fillWidth = n > sysN ? sysN : n;
- const uchar *bits = bbits.constScanLine(i);
- const uchar *mask = mbits.constScanLine(i);
- for (int j = 0; j < fillWidth; ++j) {
- uchar b = bits[j];
- uchar m = mask[j];
- if (invb)
- b ^= 0xFF;
- if (invm)
- m ^= 0xFF;
- xBits[x] = ~m;
- xMask[x] = b ^ m;
- ++x;
- }
- for (int j = fillWidth; j < sysN; ++j ) {
- xBits[x] = 255;
- xMask[x] = 0;
- ++x;
- }
- }
- }
-
- HCURSOR hcurs = CreateCursor(qWinAppInst(), hotSpot.x(), hotSpot.y(), sysW, sysH,
- xBits, xMask);
- delete [] xBits;
- delete [] xMask;
- return hcurs;
-#else
- Q_UNUSED(n);
- Q_UNUSED(invm);
- Q_UNUSED(invb);
- Q_UNUSED(mbits);
- return 0;
-#endif
}
// Create a cursor from image and mask of the format QImage::Format_Mono.
@@ -252,7 +203,7 @@ static QSize systemCursorSize(const QPlatformScreen *screen = Q_NULLPTR)
return primaryScreenCursorSize;
}
-#if defined (Q_OS_WINCE) || defined (QT_NO_IMAGEFORMAT_PNG)
+#if defined (QT_NO_IMAGEFORMAT_PNG)
static inline QSize standardCursorSize() { return QSize(32, 32); }
@@ -468,7 +419,7 @@ QWindowsCursor::PixmapCursor QWindowsCursor::customCursor(Qt::CursorShape cursor
return QWindowsCursor::PixmapCursor();
}
-#else // Q_OS_WINCE || QT_NO_IMAGEFORMAT_PNG
+#else // QT_NO_IMAGEFORMAT_PNG
struct QWindowsCustomPngCursor {
Qt::CursorShape shape;
int size;
@@ -526,7 +477,7 @@ QWindowsCursor::PixmapCursor QWindowsCursor::customCursor(Qt::CursorShape cursor
QString::fromLatin1(bestFit->fileName));
return PixmapCursor(rawImage, QPoint(bestFit->hotSpotX, bestFit->hotSpotY));
}
-#endif // Q_OS_WINCE || QT_NO_IMAGEFORMAT_PNG
+#endif // !QT_NO_IMAGEFORMAT_PNG
struct QWindowsStandardCursorMapping {
Qt::CursorShape shape;
@@ -575,13 +526,8 @@ HCURSOR QWindowsCursor::createCursorFromShape(Qt::CursorShape cursorShape, const
// Load available standard cursors from resources
const QWindowsStandardCursorMapping *sEnd = standardCursors + sizeof(standardCursors) / sizeof(standardCursors[0]);
for (const QWindowsStandardCursorMapping *s = standardCursors; s < sEnd; ++s) {
- if (s->shape == cursorShape) {
-#ifndef Q_OS_WINCE
+ if (s->shape == cursorShape)
return static_cast<HCURSOR>(LoadImage(0, s->resource, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED));
-#else
- return LoadCursor(0, s->resource);
-#endif
- }
}
qWarning("%s: Invalid cursor shape %d", __FUNCTION__, cursorShape);
@@ -677,7 +623,6 @@ QPoint QWindowsCursor::mousePosition()
QWindowsCursor::CursorState QWindowsCursor::cursorState()
{
-#ifndef Q_OS_WINCE
enum { cursorShowing = 0x1, cursorSuppressed = 0x2 }; // Windows 8: CURSOR_SUPPRESSED
CURSORINFO cursorInfo;
cursorInfo.cbSize = sizeof(CURSORINFO);
@@ -687,7 +632,6 @@ QWindowsCursor::CursorState QWindowsCursor::cursorState()
if (cursorInfo.flags & cursorSuppressed)
return CursorSuppressed;
}
-#endif // !Q_OS_WINCE
return CursorHidden;
}
@@ -758,7 +702,6 @@ QPixmap QWindowsCursor::dragDefaultCursor(Qt::DropAction action) const
"...............XXXX....."};
if (m_ignoreDragCursor.isNull()) {
-#if !defined (Q_OS_WINCE)
HCURSOR cursor = LoadCursor(NULL, IDC_NO);
ICONINFO iconInfo = {0, 0, 0, 0, 0};
GetIconInfo(cursor, &iconInfo);
@@ -782,9 +725,6 @@ QPixmap QWindowsCursor::dragDefaultCursor(Qt::DropAction action) const
DeleteObject(iconInfo.hbmMask);
DeleteObject(iconInfo.hbmColor);
DestroyCursor(cursor);
-#else // !Q_OS_WINCE
- m_ignoreDragCursor = QPixmap(ignoreDragCursorXpmC);
-#endif // !Q_OS_WINCE
}
return m_ignoreDragCursor;
}
diff --git a/src/plugins/platforms/windows/qwindowscursor.h b/src/plugins/platforms/windows/qwindowscursor.h
index c0f9235c30..6fff5f9ab1 100644
--- a/src/plugins/platforms/windows/qwindowscursor.h
+++ b/src/plugins/platforms/windows/qwindowscursor.h
@@ -40,7 +40,7 @@
#ifndef QWINDOWSCURSOR_H
#define QWINDOWSCURSOR_H
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <qpa/qplatformcursor.h>
#include <QtCore/QSharedPointer>
diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
index d5e5f87e5c..a7106c972b 100644
--- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
+++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
@@ -70,300 +70,10 @@
#include <algorithm>
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
// #define USE_NATIVE_COLOR_DIALOG /* Testing purposes only */
-#ifdef Q_CC_MINGW /* Add missing declarations for MinGW */
-
-#ifndef __IShellLibrary_FWD_DEFINED__
-
-/* Constants obtained by running the below stream operator for
- * CLSID, IID on the constants in the Windows SDK libraries. */
-
-static const IID IID_IFileOpenDialog = {0xd57c7288, 0xd4ad, 0x4768, {0xbe, 0x02, 0x9d, 0x96, 0x95, 0x32, 0xd9, 0x60}};
-static const IID IID_IFileSaveDialog = {0x84bccd23, 0x5fde, 0x4cdb,{0xae, 0xa4, 0xaf, 0x64, 0xb8, 0x3d, 0x78, 0xab}};
-#ifdef __MINGW64_VERSION_MAJOR
-static const IID q_IID_IShellItem = {0x43826d1e, 0xe718, 0x42ee, {0xbc, 0x55, 0xa1, 0xe2, 0x61, 0xc3, 0x7b, 0xfe}};
-#define IID_IShellItem q_IID_IShellItem
-#else
-static const IID IID_IShellItem = {0x43826d1e, 0xe718, 0x42ee, {0xbc, 0x55, 0xa1, 0xe2, 0x61, 0xc3, 0x7b, 0xfe}};
-static const IID IID_IShellItemArray = {0xb63ea76d, 0x1f85, 0x456f, {0xa1, 0x9c, 0x48, 0x15, 0x9e, 0xfa, 0x85, 0x8b}};
-# define LFF_FORCEFILESYSTEM 1
-#endif
-static const IID IID_IFileDialogEvents = {0x973510db, 0x7d7f, 0x452b,{0x89, 0x75, 0x74, 0xa8, 0x58, 0x28, 0xd3, 0x54}};
-static const CLSID CLSID_FileOpenDialog = {0xdc1c5a9c, 0xe88a, 0x4dde, {0xa5, 0xa1, 0x60, 0xf8, 0x2a, 0x20, 0xae, 0xf7}};
-static const CLSID CLSID_FileSaveDialog = {0xc0b4e2f3, 0xba21, 0x4773,{0x8d, 0xba, 0x33, 0x5e, 0xc9, 0x46, 0xeb, 0x8b}};
-
-typedef struct _COMDLG_FILTERSPEC
-{
- LPCWSTR pszName;
- LPCWSTR pszSpec;
-} COMDLG_FILTERSPEC;
-
-
-#define FOS_OVERWRITEPROMPT 0x2
-#define FOS_STRICTFILETYPES 0x4
-#define FOS_NOCHANGEDIR 0x8
-#define FOS_PICKFOLDERS 0x20
-#define FOS_FORCEFILESYSTEM 0x40
-#define FOS_ALLNONSTORAGEITEMS 0x80
-#define FOS_NOVALIDATE 0x100
-#define FOS_ALLOWMULTISELECT 0x200
-#define FOS_PATHMUSTEXIST 0x800
-#define FOS_FILEMUSTEXIST 0x1000
-#define FOS_CREATEPROMPT 0x2000
-#define FOS_SHAREAWARE 0x4000
-#define FOS_NOREADONLYRETURN 0x8000
-#define FOS_NOTESTFILECREATE 0x10000
-#define FOS_HIDEMRUPLACES 0x20000
-#define FOS_HIDEPINNEDPLACES 0x40000
-#define FOS_NODEREFERENCELINKS 0x100000
-#define FOS_DONTADDTORECENT 0x2000000
-#define FOS_FORCESHOWHIDDEN 0x10000000
-#define FOS_DEFAULTNOMINIMODE 0x20000000
-#define FOS_FORCEPREVIEWPANEON 0x40000000
-
-#if __MINGW64_VERSION_MAJOR < 2
-typedef int GETPROPERTYSTOREFLAGS;
-#define GPS_DEFAULT 0x00000000
-#define GPS_HANDLERPROPERTIESONLY 0x00000001
-#define GPS_READWRITE 0x00000002
-#define GPS_TEMPORARY 0x00000004
-#define GPS_FASTPROPERTIESONLY 0x00000008
-#define GPS_OPENSLOWITEM 0x00000010
-#define GPS_DELAYCREATION 0x00000020
-#define GPS_BESTEFFORT 0x00000040
-#define GPS_MASK_VALID 0x0000007F
-#endif
-
-typedef int (QT_WIN_CALLBACK* BFFCALLBACK)(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData);
-// message from browser
-#define BFFM_INITIALIZED 1
-#define BFFM_SELCHANGED 2
-#define BFFM_ENABLEOK (WM_USER + 101)
-// Browsing for directory.
-#define BIF_NONEWFOLDERBUTTON 0x0200
-#define BIF_NOTRANSLATETARGETS 0x0400
-#define BIF_BROWSEFORCOMPUTER 0x1000
-#define BIF_BROWSEFORPRINTER 0x2000
-#define BIF_BROWSEINCLUDEFILES 0x4000
-#define BIF_SHAREABLE 0x8000
-
-//the enums
-typedef enum {
- SIATTRIBFLAGS_AND = 0x1,
- SIATTRIBFLAGS_OR = 0x2,
- SIATTRIBFLAGS_APPCOMPAT = 0x3,
- SIATTRIBFLAGS_MASK = 0x3
-} SIATTRIBFLAGS;
-#ifndef __MINGW64_VERSION_MAJOR
-typedef enum {
- SIGDN_NORMALDISPLAY = 0x00000000,
- SIGDN_PARENTRELATIVEPARSING = 0x80018001,
- SIGDN_PARENTRELATIVEFORADDRESSBAR = 0x8001c001,
- SIGDN_DESKTOPABSOLUTEPARSING = 0x80028000,
- SIGDN_PARENTRELATIVEEDITING = 0x80031001,
- SIGDN_DESKTOPABSOLUTEEDITING = 0x8004c000,
- SIGDN_FILESYSPATH = 0x80058000,
- SIGDN_URL = 0x80068000
-} SIGDN;
-#endif
-typedef enum {
- FDAP_BOTTOM = 0x00000000,
- FDAP_TOP = 0x00000001
-} FDAP;
-typedef enum {
- FDESVR_DEFAULT = 0x00000000,
- FDESVR_ACCEPT = 0x00000001,
- FDESVR_REFUSE = 0x00000002
-} FDE_SHAREVIOLATION_RESPONSE;
-typedef FDE_SHAREVIOLATION_RESPONSE FDE_OVERWRITE_RESPONSE;
-
-//the structs
-typedef struct {
- LPCWSTR pszName;
- LPCWSTR pszSpec;
-} qt_COMDLG_FILTERSPEC;
-typedef struct {
- GUID fmtid;
- DWORD pid;
-} qt_PROPERTYKEY;
-
-typedef struct {
- USHORT cb;
- BYTE abID[1];
-} qt_SHITEMID, *qt_LPSHITEMID;
-typedef struct {
- qt_SHITEMID mkid;
-} qt_ITEMIDLIST, *qt_LPITEMIDLIST;
-typedef const qt_ITEMIDLIST *qt_LPCITEMIDLIST;
-typedef struct {
- HWND hwndOwner;
- qt_LPCITEMIDLIST pidlRoot;
- LPWSTR pszDisplayName;
- LPCWSTR lpszTitle;
- UINT ulFlags;
- BFFCALLBACK lpfn;
- LPARAM lParam;
- int iImage;
-} qt_BROWSEINFO;
-
-#endif // __IShellLibrary_FWD_DEFINED__
-
-#ifndef __IFileDialogEvents_FWD_DEFINED__
-DECLARE_INTERFACE(IFileDialogEvents);
-#endif
-
-#ifndef __IShellItem_INTERFACE_DEFINED__
-DECLARE_INTERFACE_(IShellItem, IUnknown)
-{
- STDMETHOD(BindToHandler)(THIS_ IBindCtx *pbc, REFGUID bhid, REFIID riid, void **ppv) PURE;
- STDMETHOD(GetParent)(THIS_ IShellItem **ppsi) PURE;
- STDMETHOD(GetDisplayName)(THIS_ SIGDN sigdnName, LPWSTR *ppszName) PURE;
- STDMETHOD(GetAttributes)(THIS_ ULONG sfgaoMask, ULONG *psfgaoAttribs) PURE;
- STDMETHOD(Compare)(THIS_ IShellItem *psi, DWORD hint, int *piOrder) PURE;
-};
-#endif
-
-#ifndef __IShellItemFilter_INTERFACE_DEFINED__
-DECLARE_INTERFACE_(IShellItemFilter, IUnknown)
-{
- STDMETHOD(IncludeItem)(THIS_ IShellItem *psi) PURE;
- STDMETHOD(GetEnumFlagsForItem)(THIS_ IShellItem *psi, DWORD *pgrfFlags) PURE;
-};
-#endif
-
-#ifndef __IEnumShellItems_INTERFACE_DEFINED__
-DECLARE_INTERFACE_(IEnumShellItems, IUnknown)
-{
- STDMETHOD(Next)(THIS_ ULONG celt, IShellItem **rgelt, ULONG *pceltFetched) PURE;
- STDMETHOD(Skip)(THIS_ ULONG celt) PURE;
- STDMETHOD(Reset)(THIS_) PURE;
- STDMETHOD(Clone)(THIS_ IEnumShellItems **ppenum) PURE;
-};
-#endif
-
-#ifndef __IShellItemArray_INTERFACE_DEFINED__
-DECLARE_INTERFACE_(IShellItemArray, IUnknown)
-{
- STDMETHOD(BindToHandler)(THIS_ IBindCtx *pbc, REFGUID rbhid, REFIID riid, void **ppvOut) PURE;
- STDMETHOD(GetPropertyStore)(THIS_ GETPROPERTYSTOREFLAGS flags, REFIID riid, void **ppv) PURE;
- STDMETHOD(GetPropertyDescriptionList)(THIS_ const qt_PROPERTYKEY *keyType, REFIID riid, void **ppv) PURE;
- STDMETHOD(GetAttributes)(THIS_ SIATTRIBFLAGS dwAttribFlags, ULONG sfgaoMask, ULONG *psfgaoAttribs) PURE;
- STDMETHOD(GetCount)(THIS_ DWORD *pdwNumItems) PURE;
- STDMETHOD(GetItemAt)(THIS_ DWORD dwIndex, IShellItem **ppsi) PURE;
- STDMETHOD(EnumItems)(THIS_ IEnumShellItems **ppenumShellItems) PURE;
-};
-#endif
-
-#ifndef __IShellLibrary_INTERFACE_DEFINED__
-
-enum LIBRARYOPTIONFLAGS {};
-enum DEFAULTSAVEFOLDERTYPE { DSFT_DETECT = 1 };
-enum LIBRARYSAVEFLAGS {};
-
-DECLARE_INTERFACE_(IShellLibrary, IUnknown)
-{
- STDMETHOD(LoadLibraryFromItem)(THIS_ IShellItem *psiLibrary, DWORD grfMode) PURE;
- STDMETHOD(LoadLibraryFromKnownFolder)(THIS_ const GUID &kfidLibrary, DWORD grfMode) PURE;
- STDMETHOD(AddFolder)(THIS_ IShellItem *psiLocation) PURE;
- STDMETHOD(RemoveFolder)(THIS_ IShellItem *psiLocation) PURE;
- STDMETHOD(GetFolders)(THIS_ int lff, REFIID riid, void **ppv) PURE;
- STDMETHOD(ResolveFolder)(THIS_ IShellItem *psiFolderToResolve, DWORD dwTimeout, REFIID riid, void **ppv) PURE;
- STDMETHOD(GetDefaultSaveFolder)(THIS_ DEFAULTSAVEFOLDERTYPE dsft, REFIID riid, void **ppv) PURE;
- STDMETHOD(SetDefaultSaveFolder)(THIS_ DEFAULTSAVEFOLDERTYPE dsft, IShellItem *psi) PURE;
- STDMETHOD(GetOptions)(THIS_ LIBRARYOPTIONFLAGS *plofOptions) PURE;
- STDMETHOD(SetOptions)(THIS_ LIBRARYOPTIONFLAGS lofMask, LIBRARYOPTIONFLAGS lofOptions) PURE;
- STDMETHOD(GetFolderType)(THIS_ GUID *pftid) PURE;
- STDMETHOD(SetFolderType)(THIS_ const GUID &ftid) PURE;
- STDMETHOD(GetIcon)(THIS_ LPWSTR *ppszIcon) PURE;
- STDMETHOD(SetIcon)(THIS_ LPCWSTR pszIcon) PURE;
- STDMETHOD(Commit)(THIS_) PURE;
- STDMETHOD(Save)(THIS_ IShellItem *psiFolderToSaveIn, LPCWSTR pszLibraryName, LIBRARYSAVEFLAGS lsf, IShellItem **ppsiSavedTo) PURE;
- STDMETHOD(SaveInKnownFolder)(THIS_ const GUID &kfidToSaveIn, LPCWSTR pszLibraryName, LIBRARYSAVEFLAGS lsf,IShellItem **ppsiSavedTo) PURE;
-};
-#endif
-
-#ifndef __IModalWindow_INTERFACE_DEFINED__
-DECLARE_INTERFACE_(IModalWindow, IUnknown)
-{
- STDMETHOD(Show)(THIS_ HWND hwndParent) PURE;
-};
-#endif
-
-#ifndef __IFileDialog_INTERFACE_DEFINED__
-DECLARE_INTERFACE_(IFileDialog, IModalWindow)
-{
- STDMETHOD(SetFileTypes)(THIS_ UINT cFileTypes, const COMDLG_FILTERSPEC *rgFilterSpec) PURE;
- STDMETHOD(SetFileTypeIndex)(THIS_ UINT iFileType) PURE;
- STDMETHOD(GetFileTypeIndex)(THIS_ UINT *piFileType) PURE;
- STDMETHOD(Advise)(THIS_ IFileDialogEvents *pfde, DWORD *pdwCookie) PURE;
- STDMETHOD(Unadvise)(THIS_ DWORD dwCookie) PURE;
- STDMETHOD(SetOptions)(THIS_ DWORD fos) PURE;
- STDMETHOD(GetOptions)(THIS_ DWORD *pfos) PURE;
- STDMETHOD(SetDefaultFolder)(THIS_ IShellItem *psi) PURE;
- STDMETHOD(SetFolder)(THIS_ IShellItem *psi) PURE;
- STDMETHOD(GetFolder)(THIS_ IShellItem **ppsi) PURE;
- STDMETHOD(GetCurrentSelection)(THIS_ IShellItem **ppsi) PURE;
- STDMETHOD(SetFileName)(THIS_ LPCWSTR pszName) PURE;
- STDMETHOD(GetFileName)(THIS_ LPWSTR *pszName) PURE;
- STDMETHOD(SetTitle)(THIS_ LPCWSTR pszTitle) PURE;
- STDMETHOD(SetOkButtonLabel)(THIS_ LPCWSTR pszText) PURE;
- STDMETHOD(SetFileNameLabel)(THIS_ LPCWSTR pszLabel) PURE;
- STDMETHOD(GetResult)(THIS_ IShellItem **ppsi) PURE;
- STDMETHOD(AddPlace)(THIS_ IShellItem *psi, FDAP fdap) PURE;
- STDMETHOD(SetDefaultExtension)(THIS_ LPCWSTR pszDefaultExtension) PURE;
- STDMETHOD(Close)(THIS_ HRESULT hr) PURE;
- STDMETHOD(SetClientGuid)(THIS_ REFGUID guid) PURE;
- STDMETHOD(ClearClientData)(THIS_) PURE;
- STDMETHOD(SetFilter)(THIS_ IShellItemFilter *pFilter) PURE;
-};
-#endif
-
-#ifndef __IFileDialogEvents_INTERFACE_DEFINED__
-DECLARE_INTERFACE_(IFileDialogEvents, IUnknown)
-{
- STDMETHOD(OnFileOk)(THIS_ IFileDialog *pfd) PURE;
- STDMETHOD(OnFolderChanging)(THIS_ IFileDialog *pfd, IShellItem *psiFolder) PURE;
- STDMETHOD(OnFolderChange)(THIS_ IFileDialog *pfd) PURE;
- STDMETHOD(OnSelectionChange)(THIS_ IFileDialog *pfd) PURE;
- STDMETHOD(OnShareViolation)(THIS_ IFileDialog *pfd, IShellItem *psi, FDE_SHAREVIOLATION_RESPONSE *pResponse) PURE;
- STDMETHOD(OnTypeChange)(THIS_ IFileDialog *pfd) PURE;
- STDMETHOD(OnOverwrite)(THIS_ IFileDialog *pfd, IShellItem *psi, FDE_OVERWRITE_RESPONSE *pResponse) PURE;
-};
-#endif
-
-#ifndef __IFileOpenDialog_INTERFACE_DEFINED__
-DECLARE_INTERFACE_(IFileOpenDialog, IFileDialog)
-{
- STDMETHOD(GetResults)(THIS_ IShellItemArray **ppenum) PURE;
- STDMETHOD(GetSelectedItems)(THIS_ IShellItemArray **ppsai) PURE;
-};
-#endif
-
-#ifndef __IPropertyStore_FWD_DEFINED__
-typedef IUnknown IPropertyStore;
-#endif
-
-#ifndef __IFileOperationProgressSink_FWD_DEFINED__
-typedef IUnknown IFileOperationProgressSink;
-#endif
-
-#ifndef __IFileSaveDialog_INTERFACE_DEFINED__
-DECLARE_INTERFACE_(IFileSaveDialog, IFileDialog)
-{
-public:
- STDMETHOD(SetSaveAsItem)(THIS_ IShellItem *psi) PURE;
- STDMETHOD(SetProperties)(THIS_ IPropertyStore *pStore) PURE;
- STDMETHOD(SetCollectedProperties)(THIS_ IPropertyStore *pStore) PURE;
- STDMETHOD(GetProperties)(THIS_ IPropertyStore **ppStore) PURE;
- STDMETHOD(ApplyProperties)(THIS_ IShellItem *psi, IPropertyStore *pStore, HWND hwnd, IFileOperationProgressSink *pSink) PURE;
-};
-#endif
-
-#endif // Q_CC_MINGW
-
QT_BEGIN_NAMESPACE
#ifndef QT_NO_DEBUG_STREAM
@@ -637,7 +347,6 @@ void QWindowsDialogHelperBase<BaseClass>::stopTimer()
}
}
-#ifndef Q_OS_WINCE
// Find a file dialog window created by IFileDialog by process id, window
// title and class, which starts with a hash '#'.
@@ -673,7 +382,6 @@ static inline HWND findDialogWindow(const QString &title)
EnumWindows(findDialogEnumWindowsProc, reinterpret_cast<LPARAM>(&context));
return context.hwnd;
}
-#endif // !Q_OS_WINCE
template <class BaseClass>
void QWindowsDialogHelperBase<BaseClass>::hide()
@@ -989,24 +697,19 @@ void QWindowsNativeFileDialogBase::setWindowTitle(const QString &title)
IShellItem *QWindowsNativeFileDialogBase::shellItem(const QUrl &url)
{
-#ifndef Q_OS_WINCE
if (url.isLocalFile()) {
- if (!QWindowsContext::shell32dll.sHCreateItemFromParsingName)
- return Q_NULLPTR;
IShellItem *result = Q_NULLPTR;
const QString native = QDir::toNativeSeparators(url.toLocalFile());
const HRESULT hr =
- QWindowsContext::shell32dll.sHCreateItemFromParsingName(reinterpret_cast<const wchar_t *>(native.utf16()),
- NULL, IID_IShellItem,
- reinterpret_cast<void **>(&result));
+ SHCreateItemFromParsingName(reinterpret_cast<const wchar_t *>(native.utf16()),
+ NULL, IID_IShellItem,
+ reinterpret_cast<void **>(&result));
if (FAILED(hr)) {
qErrnoWarning("%s: SHCreateItemFromParsingName(%s)) failed", __FUNCTION__, qPrintable(url.toString()));
return Q_NULLPTR;
}
return result;
} else if (url.scheme() == QLatin1String("clsid")) {
- if (!QWindowsContext::shell32dll.sHGetKnownFolderIDList || !QWindowsContext::shell32dll.sHCreateItemFromIDList)
- return Q_NULLPTR;
// Support for virtual folders via GUID
// (see https://msdn.microsoft.com/en-us/library/windows/desktop/dd378457(v=vs.85).aspx)
// specified as "clsid:<GUID>" (without '{', '}').
@@ -1017,12 +720,12 @@ IShellItem *QWindowsNativeFileDialogBase::shellItem(const QUrl &url)
return Q_NULLPTR;
}
PIDLIST_ABSOLUTE idList;
- HRESULT hr = QWindowsContext::shell32dll.sHGetKnownFolderIDList(uuid, 0, 0, &idList);
+ HRESULT hr = SHGetKnownFolderIDList(uuid, 0, 0, &idList);
if (FAILED(hr)) {
qErrnoWarning("%s: SHGetKnownFolderIDList(%s)) failed", __FUNCTION__, qPrintable(url.toString()));
return Q_NULLPTR;
}
- hr = QWindowsContext::shell32dll.sHCreateItemFromIDList(idList, IID_IShellItem, reinterpret_cast<void **>(&result));
+ hr = SHCreateItemFromIDList(idList, IID_IShellItem, reinterpret_cast<void **>(&result));
CoTaskMemFree(idList);
if (FAILED(hr)) {
qErrnoWarning("%s: SHCreateItemFromIDList(%s)) failed", __FUNCTION__, qPrintable(url.toString()));
@@ -1032,9 +735,6 @@ IShellItem *QWindowsNativeFileDialogBase::shellItem(const QUrl &url)
} else {
qWarning() << __FUNCTION__ << ": Unhandled scheme: " << url.scheme();
}
-#else // !Q_OS_WINCE
- Q_UNUSED(url)
-#endif
return 0;
}
@@ -1050,11 +750,9 @@ void QWindowsNativeFileDialogBase::setDirectory(const QUrl &directory)
QString QWindowsNativeFileDialogBase::directory() const
{
-#ifndef Q_OS_WINCE
IShellItem *item = 0;
if (m_fileDialog && SUCCEEDED(m_fileDialog->GetFolder(&item)) && item)
return QWindowsNativeFileDialogBase::itemPath(item);
-#endif
return QString();
}
@@ -1106,7 +804,7 @@ void QWindowsNativeFileDialogBase::setMode(QFileDialogOptions::FileMode mode,
qErrnoWarning("%s: SetOptions() failed", __FUNCTION__);
}
-#if !defined(Q_OS_WINCE) && defined(__IShellLibrary_INTERFACE_DEFINED__) // Windows SDK 7
+#if defined(__IShellLibrary_INTERFACE_DEFINED__) // Windows SDK 7
// Helper for "Libraries": collections of folders appearing from Windows 7
// on, visible in the file dialogs.
@@ -1159,7 +857,7 @@ QString QWindowsNativeFileDialogBase::libraryItemDefaultSaveFolder(IShellItem *i
return result;
}
-#else // !Q_OS_WINCE && __IShellLibrary_INTERFACE_DEFINED__
+#else // __IShellLibrary_INTERFACE_DEFINED__
QList<QUrl> QWindowsNativeFileDialogBase::libraryItemFolders(IShellItem *)
{
@@ -1171,7 +869,7 @@ QString QWindowsNativeFileDialogBase::libraryItemDefaultSaveFolder(IShellItem *)
return QString();
}
-#endif // Q_OS_WINCE || !__IShellLibrary_INTERFACE_DEFINED__
+#endif // !__IShellLibrary_INTERFACE_DEFINED__
QString QWindowsNativeFileDialogBase::itemPath(IShellItem *item)
{
@@ -1417,14 +1115,12 @@ bool QWindowsNativeFileDialogBase::onFileOk()
void QWindowsNativeFileDialogBase::close()
{
m_fileDialog->Close(S_OK);
-#ifndef Q_OS_WINCE
// IFileDialog::Close() does not work unless invoked from a callback.
// Try to find the window and send it a WM_CLOSE in addition.
const HWND hwnd = findDialogWindow(m_title);
qCDebug(lcQpaDialogs) << __FUNCTION__ << "closing" << hwnd;
if (hwnd && IsWindowVisible(hwnd))
PostMessageW(hwnd, WM_CLOSE, 0, 0);
-#endif // !Q_OS_WINCE
}
HRESULT QWindowsNativeFileDialogEventHandler::OnFolderChanging(IFileDialog *, IShellItem *item)
@@ -1725,8 +1421,6 @@ QString QWindowsFileDialogHelper::selectedNameFilter() const
return m_data.selectedNameFilter();
}
-#ifndef Q_OS_WINCE
-
/*!
\class QWindowsXpNativeFileDialog
\brief Native Windows directory dialog for Windows XP using SHlib-functions.
@@ -2050,8 +1744,6 @@ QString QWindowsXpFileDialogHelper::selectedNameFilter() const
return m_data.selectedNameFilter();
}
-#endif // Q_OS_WINCE
-
/*!
\class QWindowsNativeColorDialog
\brief Native Windows color dialog.
@@ -2179,7 +1871,6 @@ namespace QWindowsDialogs {
// QWindowsDialogHelperBase creation functions
bool useHelper(QPlatformTheme::DialogType type)
{
-#if !defined(_WIN32_WCE) || _WIN32_WCE < 0x800
if (QWindowsIntegration::instance()->options() & QWindowsIntegration::NoNativeDialogs)
return false;
switch (type) {
@@ -2198,28 +1889,20 @@ bool useHelper(QPlatformTheme::DialogType type)
break;
}
return false;
-#else
- return false;
-#endif // !defined(_WIN32_WCE) || _WIN32_WCE < 0x800
}
QPlatformDialogHelper *createHelper(QPlatformTheme::DialogType type)
{
-#if !defined(_WIN32_WCE) || _WIN32_WCE < 0x800
if (QWindowsIntegration::instance()->options() & QWindowsIntegration::NoNativeDialogs)
return 0;
switch (type) {
- case QPlatformTheme::FileDialog:
-#ifndef Q_OS_WINCE // Note: "Windows XP Professional x64 Edition has version number WV_5_2 (WV_2003).
+ case QPlatformTheme::FileDialog: // Note: "Windows XP Professional x64 Edition has version number WV_5_2 (WV_2003).
if (QWindowsIntegration::instance()->options() & QWindowsIntegration::XpNativeDialogs
|| QSysInfo::windowsVersion() <= QSysInfo::WV_2003) {
return new QWindowsXpFileDialogHelper();
}
if (QSysInfo::windowsVersion() > QSysInfo::WV_2003)
return new QWindowsFileDialogHelper();
-#else
- return new QWindowsFileDialogHelper();
-#endif // Q_OS_WINCE
case QPlatformTheme::ColorDialog:
#ifdef USE_NATIVE_COLOR_DIALOG
return new QWindowsColorDialogHelper();
@@ -2233,9 +1916,6 @@ QPlatformDialogHelper *createHelper(QPlatformTheme::DialogType type)
break;
}
return 0;
-#else
- return 0;
-#endif // !defined(_WIN32_WCE) || _WIN32_WCE < 0x800
}
} // namespace QWindowsDialogs
diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.h b/src/plugins/platforms/windows/qwindowsdialoghelpers.h
index b643d9a920..b3101a1419 100644
--- a/src/plugins/platforms/windows/qwindowsdialoghelpers.h
+++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.h
@@ -40,7 +40,7 @@
#ifndef QWINDOWSDIALOGHELPER_H
#define QWINDOWSDIALOGHELPER_H
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <qpa/qplatformdialoghelper.h>
#include <qpa/qplatformtheme.h>
#include <QtCore/QStringList>
diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp
index 246f53ef2f..26a5131927 100644
--- a/src/plugins/platforms/windows/qwindowsdrag.cpp
+++ b/src/plugins/platforms/windows/qwindowsdrag.cpp
@@ -45,7 +45,7 @@
#endif
#include "qwindowsintegration.h"
#include "qwindowsole.h"
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include "qwindowswindow.h"
#include "qwindowsmousehandler.h"
#include "qwindowscursor.h"
diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp
index 4261c01ac8..a4738dc100 100644
--- a/src/plugins/platforms/windows/qwindowseglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp
@@ -95,13 +95,9 @@ static void *resolveFunc(HMODULE lib, const char *name)
return proc;
}
#else
-static void *resolveFunc(HMODULE lib, const char *name)
+static inline void *resolveFunc(HMODULE lib, const char *name)
{
-# ifndef Q_OS_WINCE
- return (void *) ::GetProcAddress(lib, name);
-# else
- return (void *) ::GetProcAddress(lib, (const wchar_t *) QString::fromLatin1(name).utf16());
-# endif // Q_OS_WINCE
+ return ::GetProcAddress(lib, name);
}
#endif // Q_CC_MINGW
@@ -121,7 +117,7 @@ void *QWindowsLibEGL::resolve(const char *name)
bool QWindowsLibEGL::init()
{
const char dllName[] = QT_STRINGIFY(LIBEGL_NAME)
-#if defined(QT_DEBUG) && !defined(Q_OS_WINCE)
+#if defined(QT_DEBUG)
"d"
#endif
"";
@@ -178,7 +174,7 @@ bool QWindowsLibGLESv2::init()
{
const char dllName[] = QT_STRINGIFY(LIBGLESV2_NAME)
-#if defined(QT_DEBUG) && !defined(Q_OS_WINCE)
+#if defined(QT_DEBUG)
"d"
#endif
"";
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
index 314da702eb..65f2cd14f6 100644
--- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
@@ -43,7 +43,7 @@
#include "qwindowsintegration.h"
#include "qwindowsfontengine.h"
#include "qwindowsfontenginedirectwrite.h"
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtGui/QFont>
#include <QtGui/QGuiApplication>
@@ -58,10 +58,6 @@
#include <wchar.h>
-#ifdef Q_OS_WINCE
-# include "qplatformfunctions_wince.h"
-#endif
-
#if !defined(QT_NO_DIRECTWRITE)
# if defined(QT_USE_DIRECTWRITE2)
# include <dwrite_2.h>
@@ -759,50 +755,115 @@ static inline quint16 getUShort(const unsigned char *p)
return val;
}
-static QString getEnglishName(const uchar *table, quint32 bytes)
+namespace {
+
+struct FontNames {
+ QString name; // e.g. "DejaVu Sans Condensed"
+ QString style; // e.g. "Italic"
+ QString preferredName; // e.g. "DejaVu Sans"
+ QString preferredStyle; // e.g. "Condensed Italic"
+};
+
+static QString readName(bool unicode, const uchar *string, int length)
{
- QString i18n_name;
- enum {
- NameRecordSize = 12,
- FamilyId = 1,
- MS_LangIdEnglish = 0x009
- };
+ QString out;
+ if (unicode) {
+ // utf16
+
+ length /= 2;
+ out.resize(length);
+ QChar *uc = out.data();
+ for (int i = 0; i < length; ++i)
+ uc[i] = getUShort(string + 2*i);
+ } else {
+ // Apple Roman
+
+ out.resize(length);
+ QChar *uc = out.data();
+ for (int i = 0; i < length; ++i)
+ uc[i] = QLatin1Char(char(string[i]));
+ }
+ return out;
+}
+
+enum FieldTypeValue {
+ FamilyId = 1,
+ StyleId = 2,
+ PreferredFamilyId = 16,
+ PreferredStyleId = 17,
+};
+
+enum PlatformFieldValue {
+ PlatformId_Unicode = 0,
+ PlatformId_Apple = 1,
+ PlatformId_Microsoft = 3
+};
+
+static FontNames getCanonicalFontNames(const uchar *table, quint32 bytes)
+{
+ FontNames out;
+ const int NameRecordSize = 12;
+ const int MS_LangIdEnglish = 0x009;
// get the name table
quint16 count;
quint16 string_offset;
const unsigned char *names;
- int microsoft_id = -1;
- int apple_id = -1;
- int unicode_id = -1;
+ if (bytes < 8)
+ return out;
if (getUShort(table) != 0)
- goto error;
+ return out;
count = getUShort(table+2);
string_offset = getUShort(table+4);
names = table + 6;
if (string_offset >= bytes || 6 + count*NameRecordSize > string_offset)
- goto error;
+ return out;
+
+ enum PlatformIdType {
+ NotFound = 0,
+ Unicode = 1,
+ Apple = 2,
+ Microsoft = 3
+ };
+
+ PlatformIdType idStatus[4] = { NotFound, NotFound, NotFound, NotFound };
+ int ids[4] = { -1, -1, -1, -1 };
for (int i = 0; i < count; ++i) {
- // search for the correct name entry
+ // search for the correct name entries
quint16 platform_id = getUShort(names + i*NameRecordSize);
quint16 encoding_id = getUShort(names + 2 + i*NameRecordSize);
quint16 language_id = getUShort(names + 4 + i*NameRecordSize);
quint16 name_id = getUShort(names + 6 + i*NameRecordSize);
- if (name_id != FamilyId)
- continue;
+ PlatformIdType *idType = nullptr;
+ int *id = nullptr;
- enum {
- PlatformId_Unicode = 0,
- PlatformId_Apple = 1,
- PlatformId_Microsoft = 3
- };
+ switch (name_id) {
+ case FamilyId:
+ idType = &idStatus[0];
+ id = &ids[0];
+ break;
+ case StyleId:
+ idType = &idStatus[1];
+ id = &ids[1];
+ break;
+ case PreferredFamilyId:
+ idType = &idStatus[2];
+ id = &ids[2];
+ break;
+ case PreferredStyleId:
+ idType = &idStatus[3];
+ id = &ids[3];
+ break;
+ default:
+ continue;
+ }
quint16 length = getUShort(names + 8 + i*NameRecordSize);
quint16 offset = getUShort(names + 10 + i*NameRecordSize);
@@ -812,63 +873,52 @@ static QString getEnglishName(const uchar *table, quint32 bytes)
if ((platform_id == PlatformId_Microsoft
&& (encoding_id == 0 || encoding_id == 1))
&& (language_id & 0x3ff) == MS_LangIdEnglish
- && microsoft_id == -1)
- microsoft_id = i;
+ && *idType < Microsoft) {
+ *id = i;
+ *idType = Microsoft;
+ }
// not sure if encoding id 4 for Unicode is utf16 or ucs4...
- else if (platform_id == PlatformId_Unicode && encoding_id < 4 && unicode_id == -1)
- unicode_id = i;
- else if (platform_id == PlatformId_Apple && encoding_id == 0 && language_id == 0)
- apple_id = i;
- }
- {
- bool unicode = false;
- int id = -1;
- if (microsoft_id != -1) {
- id = microsoft_id;
- unicode = true;
- } else if (apple_id != -1) {
- id = apple_id;
- unicode = false;
- } else if (unicode_id != -1) {
- id = unicode_id;
- unicode = true;
+ else if (platform_id == PlatformId_Unicode && encoding_id < 4 && *idType < Unicode) {
+ *id = i;
+ *idType = Unicode;
}
- if (id != -1) {
- quint16 length = getUShort(names + 8 + id*NameRecordSize);
- quint16 offset = getUShort(names + 10 + id*NameRecordSize);
- if (unicode) {
- // utf16
-
- length /= 2;
- i18n_name.resize(length);
- QChar *uc = const_cast<QChar *>(i18n_name.unicode());
- const unsigned char *string = table + string_offset + offset;
- for (int i = 0; i < length; ++i)
- uc[i] = getUShort(string + 2*i);
- } else {
- // Apple Roman
-
- i18n_name.resize(length);
- QChar *uc = const_cast<QChar *>(i18n_name.unicode());
- const unsigned char *string = table + string_offset + offset;
- for (int i = 0; i < length; ++i)
- uc[i] = QLatin1Char(char(string[i]));
- }
+ else if (platform_id == PlatformId_Apple && encoding_id == 0 && language_id == 0 && *idType < Apple) {
+ *id = i;
+ *idType = Apple;
}
}
-error:
- //qDebug("got i18n name of '%s' for font '%s'", i18n_name.latin1(), familyName.toLocal8Bit().data());
- return i18n_name;
+
+ QString strings[4];
+ for (int i = 0; i < 4; ++i) {
+ if (idStatus[0] == NotFound)
+ continue;
+ int id = ids[i];
+ quint16 length = getUShort(names + 8 + id * NameRecordSize);
+ quint16 offset = getUShort(names + 10 + id * NameRecordSize);
+ const unsigned char *string = table + string_offset + offset;
+ strings[i] = readName(idStatus[i] != Apple, string, length);
+ }
+
+ out.name = strings[0];
+ out.style = strings[1];
+ out.preferredName = strings[2];
+ out.preferredStyle = strings[3];
+ return out;
}
+} // namespace
+
QString getEnglishName(const QString &familyName)
{
QString i18n_name;
+ QString faceName = familyName;
+ faceName.truncate(LF_FACESIZE - 1);
HDC hdc = GetDC( 0 );
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
- memcpy(lf.lfFaceName, familyName.utf16(), qMin(familyName.length(), LF_FACESIZE - 1) * sizeof(wchar_t));
+ faceName.toWCharArray(lf.lfFaceName);
+ lf.lfFaceName[faceName.size()] = 0;
lf.lfCharSet = DEFAULT_CHARSET;
HFONT hfont = CreateFontIndirect(&lf);
@@ -896,7 +946,7 @@ QString getEnglishName(const QString &familyName)
if ( bytes == GDI_ERROR )
goto error;
- i18n_name = getEnglishName(table, bytes);
+ i18n_name = getCanonicalFontNames(table, bytes).name;
error:
delete [] table;
SelectObject( hdc, oldobj );
@@ -960,17 +1010,6 @@ static bool addFontToDatabase(const QString &familyName, uchar charSet,
quint32 codePageRange[2] = {
signature->fsCsb[0], signature->fsCsb[1]
};
-#ifdef Q_OS_WINCE
- if (signature->fsUsb[0] == 0) {
- // If the unicode ranges bit mask is zero then
- // EnumFontFamiliesEx failed to determine it properly.
- // In this case we just pretend that the font supports all languages.
- unicodeRange[0] = 0xbfffffff; // second most significant bit must be zero
- unicodeRange[1] = 0xffffffff;
- unicodeRange[2] = 0xffffffff;
- unicodeRange[3] = 0xffffffff;
- }
-#endif
writingSystems = QPlatformFontDatabase::writingSystemsFromTrueTypeBits(unicodeRange, codePageRange);
// ### Hack to work around problem with Thai text on Windows 7. Segoe UI contains
// the symbol for Baht, and Windows thus reports that it supports the Thai script.
@@ -1130,9 +1169,8 @@ QWindowsFontEngineDataPtr sharedFontData()
}
#endif // QT_NO_THREAD
-#ifndef Q_OS_WINCE
extern Q_GUI_EXPORT bool qt_needs_a8_gamma_correction;
-#endif
+
QWindowsFontDatabase::QWindowsFontDatabase()
{
// Properties accessed by QWin32PrintEngine (Qt Print Support)
@@ -1146,9 +1184,7 @@ QWindowsFontDatabase::QWindowsFontDatabase()
qCDebug(lcQpaFonts) << __FUNCTION__ << "Clear type: "
<< data->clearTypeEnabled << "gamma: " << data->fontSmoothingGamma;
}
-#ifndef Q_OS_WINCE
qt_needs_a8_gamma_correction = true;
-#endif
}
QWindowsFontDatabase::~QWindowsFontDatabase()
@@ -1364,7 +1400,7 @@ static void getFontTable(const uchar *fileBegin, const uchar *data, quint32 tag,
}
static void getFamiliesAndSignatures(const QByteArray &fontData,
- QStringList *families,
+ QList<FontNames> *families,
QVector<FONTSIGNATURE> *signatures)
{
const uchar *data = reinterpret_cast<const uchar *>(fontData.constData());
@@ -1380,11 +1416,11 @@ static void getFamiliesAndSignatures(const QByteArray &fontData,
getFontTable(data, font, MAKE_TAG('n', 'a', 'm', 'e'), &table, &length);
if (!table)
continue;
- QString name = getEnglishName(table, length);
- if (name.isEmpty())
+ FontNames names = getCanonicalFontNames(table, length);
+ if (names.name.isEmpty())
continue;
- families->append(name);
+ families->append(qMove(names));
if (signatures) {
FONTSIGNATURE signature;
@@ -1411,12 +1447,13 @@ QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData,
WinApplicationFont font;
font.fileName = fileName;
QVector<FONTSIGNATURE> signatures;
- QStringList families;
+ QList<FontNames> families;
+ QStringList familyNames;
if (!fontData.isEmpty()) {
getFamiliesAndSignatures(fontData, &families, &signatures);
if (families.isEmpty())
- return families;
+ return familyNames;
DWORD dummy = 0;
font.handle =
@@ -1427,7 +1464,8 @@ QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData,
// Memory fonts won't show up in enumeration, so do add them the hard way.
for (int j = 0; j < families.count(); ++j) {
- const QString familyName = families.at(j);
+ const QString familyName = families.at(j).name;
+ familyNames << familyName;
HDC hdc = GetDC(0);
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
@@ -1449,13 +1487,13 @@ QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData,
} else {
QFile f(fileName);
if (!f.open(QIODevice::ReadOnly))
- return families;
+ return QStringList();
QByteArray data = f.readAll();
f.close();
getFamiliesAndSignatures(data, &families, 0);
if (families.isEmpty())
- return families;
+ return QStringList();
if (AddFontResourceExW((wchar_t*)fileName.utf16(), FR_PRIVATE, 0) == 0)
return QStringList();
@@ -1463,13 +1501,16 @@ QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData,
font.handle = 0;
// Fonts based on files are added via populate, as they will show up in font enumeration.
- for (int j = 0; j < families.count(); ++j)
- populateFamily(families.at(j), true);
+ for (int j = 0; j < families.count(); ++j) {
+ const QString familyName = families.at(j).name;
+ familyNames << familyName;
+ populateFamily(familyName, true);
+ }
}
m_applicationFonts << font;
- return families;
+ return familyNames;
}
void QWindowsFontDatabase::removeApplicationFonts()
@@ -1595,14 +1636,12 @@ LOGFONT QWindowsFontDatabase::fontDefToLOGFONT(const QFontDef &request)
int strat = OUT_DEFAULT_PRECIS;
if (request.styleStrategy & QFont::PreferBitmap) {
strat = OUT_RASTER_PRECIS;
-#ifndef Q_OS_WINCE
} else if (request.styleStrategy & QFont::PreferDevice) {
strat = OUT_DEVICE_PRECIS;
} else if (request.styleStrategy & QFont::PreferOutline) {
strat = OUT_OUTLINE_PRECIS;
} else if (request.styleStrategy & QFont::ForceOutline) {
strat = OUT_TT_ONLY_PRECIS;
-#endif
}
lf.lfOutPrecision = strat;
@@ -1611,10 +1650,8 @@ LOGFONT QWindowsFontDatabase::fontDefToLOGFONT(const QFontDef &request)
if (request.styleStrategy & QFont::PreferMatch)
qual = DRAFT_QUALITY;
-#ifndef Q_OS_WINCE
else if (request.styleStrategy & QFont::PreferQuality)
qual = PROOF_QUALITY;
-#endif
if (request.styleStrategy & QFont::PreferAntialias) {
if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && !(request.styleStrategy & QFont::NoSubpixelAntialias)) {
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.h b/src/plugins/platforms/windows/qwindowsfontdatabase.h
index 574e20ef30..8b8c9c15f4 100644
--- a/src/plugins/platforms/windows/qwindowsfontdatabase.h
+++ b/src/plugins/platforms/windows/qwindowsfontdatabase.h
@@ -42,7 +42,7 @@
#include <qpa/qplatformfontdatabase.h>
#include <QtCore/QSharedPointer>
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#if !defined(QT_NO_DIRECTWRITE)
struct IDWriteFactory;
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp
index fb75e75dcd..d782519c68 100644
--- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp
@@ -53,10 +53,6 @@
#include <QtGui/QFontDatabase>
#include <wchar.h>
-#ifdef Q_OS_WINCE
-#include <QtCore/QFile>
-#include <QtEndian>
-#endif
QT_BEGIN_NAMESPACE
@@ -108,8 +104,6 @@ static FontFile * createFontFile(const QString &fileName, int index)
extern bool localizedName(const QString &name);
extern QString getEnglishName(const QString &familyName);
-#ifndef Q_OS_WINCE
-
namespace {
struct FontKey
{
@@ -165,223 +159,6 @@ static const FontKey *findFontKey(const QString &name, int *indexIn = Q_NULLPTR)
return Q_NULLPTR;
}
-#else // Q_OS_WINCE
-
-typedef struct {
- quint16 majorVersion;
- quint16 minorVersion;
- quint16 numTables;
- quint16 searchRange;
- quint16 entrySelector;
- quint16 rangeShift;
-} OFFSET_TABLE;
-
-typedef struct {
- quint32 tag;
- quint32 checkSum;
- quint32 offset;
- quint32 length;
-} TABLE_DIRECTORY;
-
-typedef struct {
- quint16 fontSelector;
- quint16 nrCount;
- quint16 storageOffset;
-} NAME_TABLE_HEADER;
-
-typedef struct {
- quint16 platformID;
- quint16 encodingID;
- quint16 languageID;
- quint16 nameID;
- quint16 stringLength;
- quint16 stringOffset;
-} NAME_RECORD;
-
-typedef struct {
- quint32 tag;
- quint16 majorVersion;
- quint16 minorVersion;
- quint32 numFonts;
-} TTC_TABLE_HEADER;
-
-static QString fontNameFromTTFile(const QString &filename, int startPos = 0)
-{
- QFile f(filename);
- QString retVal;
- qint64 bytesRead;
- qint64 bytesToRead;
-
- if (f.open(QIODevice::ReadOnly)) {
- f.seek(startPos);
- OFFSET_TABLE ttOffsetTable;
- bytesToRead = sizeof(OFFSET_TABLE);
- bytesRead = f.read((char*)&ttOffsetTable, bytesToRead);
- if (bytesToRead != bytesRead)
- return retVal;
- ttOffsetTable.numTables = qFromBigEndian(ttOffsetTable.numTables);
- ttOffsetTable.majorVersion = qFromBigEndian(ttOffsetTable.majorVersion);
- ttOffsetTable.minorVersion = qFromBigEndian(ttOffsetTable.minorVersion);
-
- if (ttOffsetTable.majorVersion != 1 || ttOffsetTable.minorVersion != 0)
- return retVal;
-
- TABLE_DIRECTORY tblDir;
- bool found = false;
-
- for (int i = 0; i < ttOffsetTable.numTables; i++) {
- bytesToRead = sizeof(TABLE_DIRECTORY);
- bytesRead = f.read((char*)&tblDir, bytesToRead);
- if (bytesToRead != bytesRead)
- return retVal;
- if (qFromBigEndian(tblDir.tag) == MAKE_TAG('n', 'a', 'm', 'e')) {
- found = true;
- tblDir.length = qFromBigEndian(tblDir.length);
- tblDir.offset = qFromBigEndian(tblDir.offset);
- break;
- }
- }
-
- if (found) {
- f.seek(tblDir.offset);
- NAME_TABLE_HEADER ttNTHeader;
- bytesToRead = sizeof(NAME_TABLE_HEADER);
- bytesRead = f.read((char*)&ttNTHeader, bytesToRead);
- if (bytesToRead != bytesRead)
- return retVal;
- ttNTHeader.nrCount = qFromBigEndian(ttNTHeader.nrCount);
- ttNTHeader.storageOffset = qFromBigEndian(ttNTHeader.storageOffset);
- NAME_RECORD ttRecord;
- found = false;
-
- for (int i = 0; i < ttNTHeader.nrCount; i++) {
- bytesToRead = sizeof(NAME_RECORD);
- bytesRead = f.read((char*)&ttRecord, bytesToRead);
- if (bytesToRead != bytesRead)
- return retVal;
- ttRecord.nameID = qFromBigEndian(ttRecord.nameID);
- if (ttRecord.nameID == 1) {
- ttRecord.stringLength = qFromBigEndian(ttRecord.stringLength);
- ttRecord.stringOffset = qFromBigEndian(ttRecord.stringOffset);
- int nPos = f.pos();
- f.seek(tblDir.offset + ttRecord.stringOffset + ttNTHeader.storageOffset);
-
- QByteArray nameByteArray = f.read(ttRecord.stringLength);
- if (!nameByteArray.isEmpty()) {
- if (ttRecord.encodingID == 256 || ttRecord.encodingID == 768) {
- //This is UTF-16 in big endian
- int stringLength = ttRecord.stringLength / 2;
- retVal.resize(stringLength);
- QChar *data = retVal.data();
- const ushort *srcData = (const ushort *)nameByteArray.data();
- for (int i = 0; i < stringLength; ++i)
- data[i] = qFromBigEndian(srcData[i]);
- return retVal;
- } else if (ttRecord.encodingID == 0) {
- //This is Latin1
- retVal = QString::fromLatin1(nameByteArray);
- } else {
- qWarning("Could not retrieve Font name from file: %s", qPrintable(QDir::toNativeSeparators(filename)));
- }
- break;
- }
- f.seek(nPos);
- }
- }
- }
- f.close();
- }
- return retVal;
-}
-
-static QStringList fontNamesFromTTCFile(const QString &filename)
-{
- QFile f(filename);
- QStringList retVal;
- qint64 bytesRead;
- qint64 bytesToRead;
-
- if (f.open(QIODevice::ReadOnly)) {
- TTC_TABLE_HEADER ttcTableHeader;
- bytesToRead = sizeof(TTC_TABLE_HEADER);
- bytesRead = f.read((char*)&ttcTableHeader, bytesToRead);
- if (bytesToRead != bytesRead)
- return retVal;
- ttcTableHeader.majorVersion = qFromBigEndian(ttcTableHeader.majorVersion);
- ttcTableHeader.minorVersion = qFromBigEndian(ttcTableHeader.minorVersion);
- ttcTableHeader.numFonts = qFromBigEndian(ttcTableHeader.numFonts);
-
- if (ttcTableHeader.majorVersion < 1 || ttcTableHeader.majorVersion > 2)
- return retVal;
- QVarLengthArray<quint32> offsetTable(ttcTableHeader.numFonts);
- bytesToRead = sizeof(quint32) * ttcTableHeader.numFonts;
- bytesRead = f.read((char*)offsetTable.data(), bytesToRead);
- if (bytesToRead != bytesRead)
- return retVal;
- f.close();
- for (int i = 0; i < (int)ttcTableHeader.numFonts; ++i)
- retVal << fontNameFromTTFile(filename, qFromBigEndian(offsetTable[i]));
- }
- return retVal;
-}
-
-static inline QString fontSettingsOrganization() { return QStringLiteral("Qt-Project"); }
-static inline QString fontSettingsApplication() { return QStringLiteral("Qtbase"); }
-static inline QString fontSettingsGroup() { return QStringLiteral("CEFontCache"); }
-
-static QString findFontFile(const QString &faceName)
-{
- static QHash<QString, QString> fontCache;
-
- if (fontCache.isEmpty()) {
- QSettings settings(QSettings::SystemScope, fontSettingsOrganization(), fontSettingsApplication());
- settings.beginGroup(fontSettingsGroup());
- foreach (const QString &fontName, settings.allKeys())
- fontCache.insert(fontName, settings.value(fontName).toString());
- settings.endGroup();
- }
-
- QString value = fontCache.value(faceName);
-
- //Fallback if we haven't cached the font yet or the font got removed/renamed iterate again over all fonts
- if (value.isEmpty() || !QFile::exists(value)) {
- QSettings settings(QSettings::SystemScope, fontSettingsOrganization(), fontSettingsApplication());
- settings.beginGroup(fontSettingsGroup());
-
- //empty the cache first, as it seems that it is dirty
- settings.remove(QString());
-
- QDirIterator it(QStringLiteral("/Windows"), QStringList() << QStringLiteral("*.ttf") << QStringLiteral("*.ttc"), QDir::Files | QDir::Hidden | QDir::System);
- const QLatin1Char lowerF('f');
- const QLatin1Char upperF('F');
- while (it.hasNext()) {
- const QString fontFile = it.next();
- QStringList fontNames;
- const QChar c = fontFile[fontFile.size() - 1];
- if (c == lowerF || c == upperF)
- fontNames << fontNameFromTTFile(fontFile);
- else
- fontNames << fontNamesFromTTCFile(fontFile);
- foreach (const QString fontName, fontNames) {
- if (fontName.isEmpty())
- continue;
- fontCache.insert(fontName, fontFile);
- settings.setValue(fontName, fontFile);
-
- if (localizedName(fontName)) {
- QString englishFontName = getEnglishName(fontName);
- fontCache.insert(englishFontName, fontFile);
- settings.setValue(englishFontName, fontFile);
- }
- }
- }
- settings.endGroup();
- value = fontCache.value(faceName);
- }
- return value;
-}
-#endif // Q_OS_WINCE
-
static bool addFontToDatabase(const QString &faceName,
const QString &fullName,
uchar charSet,
@@ -453,7 +230,6 @@ static bool addFontToDatabase(const QString &faceName,
}
int index = 0;
-#ifndef Q_OS_WINCE
const FontKey *key = findFontKey(faceName, &index);
if (!key) {
key = findFontKey(fullName, &index);
@@ -465,19 +241,11 @@ static bool addFontToDatabase(const QString &faceName,
return false;
}
QString value = key->fileName;
-#else
- QString value = findFontFile(faceName);
-#endif
-
if (value.isEmpty())
return false;
if (!QDir::isAbsolutePath(value))
-#ifndef Q_OS_WINCE
value.prepend(QFile::decodeName(qgetenv("windir") + "\\Fonts\\"));
-#else
- value.prepend(QFile::decodeName("/Windows/"));
-#endif
QPlatformFontDatabase::registerFont(faceName, QString(), foundryName, weight, style, stretch,
antialias, scalable, size, fixed, writingSystems, createFontFile(value, index));
@@ -501,24 +269,6 @@ static bool addFontToDatabase(const QString &faceName,
return true;
}
-#ifdef Q_OS_WINCE
-static QByteArray getFntTable(HFONT hfont, uint tag)
-{
- HDC hdc = GetDC(0);
- HGDIOBJ oldFont = SelectObject(hdc, hfont);
- quint32 t = qFromBigEndian<quint32>(tag);
- QByteArray buffer;
-
- DWORD length = GetFontData(hdc, t, 0, NULL, 0);
- if (length != GDI_ERROR) {
- buffer.resize(length);
- GetFontData(hdc, t, 0, reinterpret_cast<uchar *>(buffer.data()), length);
- }
- SelectObject(hdc, oldFont);
- return buffer;
-}
-#endif
-
static int QT_WIN_CALLBACK storeFont(const LOGFONT *logFont, const TEXTMETRIC *textmetric,
DWORD type, LPARAM)
{
@@ -576,8 +326,6 @@ struct PopulateFamiliesContext
};
} // namespace
-#ifndef Q_OS_WINCE
-
// Delayed population of font families
static int QT_WIN_CALLBACK populateFontFamilies(const LOGFONT *logFont, const TEXTMETRIC *textmetric,
@@ -633,74 +381,6 @@ void QWindowsFontDatabaseFT::populateFontDatabase()
QPlatformFontDatabase::registerFontFamily(context.systemDefaultFont);
}
-#else // !Q_OS_WINCE
-
-// Non-delayed population of fonts (Windows CE).
-
-static int QT_WIN_CALLBACK populateFontCe(ENUMLOGFONTEX* f, NEWTEXTMETRICEX *textmetric,
- int type, LPARAM lparam)
-{
- // the "@family" fonts are just the same as "family". Ignore them.
- const wchar_t *faceNameW = f->elfLogFont.lfFaceName;
- if (faceNameW[0] && faceNameW[0] != L'@' && wcsncmp(faceNameW, L"WST_", 4)) {
- const uchar charSet = f->elfLogFont.lfCharSet;
-
- FONTSIGNATURE signature;
- QByteArray table;
-
- if (type & TRUETYPE_FONTTYPE) {
- HFONT hfont = CreateFontIndirect(&f->elfLogFont);
- table = getFntTable(hfont, MAKE_TAG('O', 'S', '/', '2'));
- DeleteObject((HGDIOBJ)hfont);
- }
-
- if (table.length() >= 86) {
- // See also qfontdatabase_mac.cpp, offsets taken from OS/2 table in the TrueType spec
- uchar *tableData = reinterpret_cast<uchar *>(table.data());
-
- signature.fsUsb[0] = qFromBigEndian<quint32>(tableData + 42);
- signature.fsUsb[1] = qFromBigEndian<quint32>(tableData + 46);
- signature.fsUsb[2] = qFromBigEndian<quint32>(tableData + 50);
- signature.fsUsb[3] = qFromBigEndian<quint32>(tableData + 54);
-
- signature.fsCsb[0] = qFromBigEndian<quint32>(tableData + 78);
- signature.fsCsb[1] = qFromBigEndian<quint32>(tableData + 82);
- } else {
- memset(&signature, 0, sizeof(signature));
- }
-
- // NEWTEXTMETRICEX is a NEWTEXTMETRIC, which according to the documentation is
- // identical to a TEXTMETRIC except for the last four members, which we don't use
- // anyway
- const QString faceName = QString::fromWCharArray(f->elfLogFont.lfFaceName);
- if (addFontToDatabase(faceName, QString::fromWCharArray(f->elfFullName),
- charSet, (TEXTMETRIC *)textmetric, &signature, type, true)) {
- PopulateFamiliesContext *context = reinterpret_cast<PopulateFamiliesContext *>(lparam);
- if (!context->seenSystemDefaultFont && faceName == context->systemDefaultFont)
- context->seenSystemDefaultFont = true;
- }
- }
-
- // keep on enumerating
- return 1;
-}
-
-void QWindowsFontDatabaseFT::populateFontDatabase()
-{
- LOGFONT lf;
- lf.lfCharSet = DEFAULT_CHARSET;
- HDC dummy = GetDC(0);
- lf.lfFaceName[0] = 0;
- lf.lfPitchAndFamily = 0;
- PopulateFamiliesContext context(QWindowsFontDatabase::systemDefaultFont().family());
- EnumFontFamiliesEx(dummy, &lf, (FONTENUMPROC)populateFontCe, reinterpret_cast<LPARAM>(&context), 0);
- ReleaseDC(0, dummy);
- // Work around EnumFontFamiliesEx() not listing the system font, see below.
- if (!context.seenSystemDefaultFont)
- populateFamily(context.systemDefaultFont);
-}
-#endif // Q_OS_WINCE
-
QFontEngine * QWindowsFontDatabaseFT::fontEngine(const QFontDef &fontDef, void *handle)
{
QFontEngine *fe = QBasicFontDatabase::fontEngine(fontDef, handle);
@@ -718,21 +398,8 @@ QFontEngine *QWindowsFontDatabaseFT::fontEngine(const QByteArray &fontData, qrea
QStringList QWindowsFontDatabaseFT::fallbacksForFamily(const QString &family, QFont::Style style, QFont::StyleHint styleHint, QChar::Script script) const
{
QStringList result;
-
result.append(QWindowsFontDatabase::familyForStyleHint(styleHint));
-
-#ifdef Q_OS_WINCE
- QSettings settings(QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\FontLink\\SystemLink"), QSettings::NativeFormat);
- const QStringList fontList = settings.value(family).toStringList();
- foreach (const QString &fallback, fontList) {
- const int sep = fallback.indexOf(QLatin1Char(','));
- if (sep > 0)
- result << fallback.mid(sep + 1);
- }
-#endif
-
result.append(QWindowsFontDatabase::extraTryFontsForFamily(family));
-
result.append(QBasicFontDatabase::fallbacksForFamily(family, style, styleHint, script));
qCDebug(lcQpaFonts) << __FUNCTION__ << family << style << styleHint
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.h b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.h
index 988b0012f7..fa8f777133 100644
--- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.h
+++ b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.h
@@ -42,7 +42,7 @@
#include <QtPlatformSupport/private/qbasicfontdatabase_p.h>
#include <QtCore/QSharedPointer>
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp
index 4f3df32f16..744d882bb2 100644
--- a/src/plugins/platforms/windows/qwindowsfontengine.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp
@@ -42,7 +42,7 @@
#include "qwindowsnativeimage.h"
#include "qwindowscontext.h"
#include "qwindowsfontdatabase.h"
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include "qwindowsfontenginedirectwrite.h"
#include <QtGui/private/qtextengine_p.h> // glyph_metrics_t
@@ -65,10 +65,6 @@
#include <limits.h>
-#ifdef Q_OS_WINCE
-# include "qplatformfunctions_wince.h"
-#endif
-
#if !defined(QT_NO_DIRECTWRITE)
# include <dwrite.h>
#endif
@@ -205,9 +201,6 @@ int QWindowsFontEngine::getGlyphIndexes(const QChar *str, int numChars, QGlyphLa
{
int glyph_pos = 0;
{
-#if defined(Q_OS_WINCE)
- {
-#else
if (symbol) {
QStringIterator it(str, str + numChars);
while (it.hasNext()) {
@@ -225,7 +218,6 @@ int QWindowsFontEngine::getGlyphIndexes(const QChar *str, int numChars, QGlyphLa
++glyph_pos;
}
} else {
-#endif
QStringIterator it(str, str + numChars);
while (it.hasNext()) {
const uint uc = it.next();
@@ -329,21 +321,16 @@ QWindowsFontEngine::~QWindowsFontEngine()
glyph_t QWindowsFontEngine::glyphIndex(uint ucs4) const
{
- glyph_t glyph;
+ glyph_t glyph = 0;
-#if !defined(Q_OS_WINCE)
if (symbol) {
glyph = getTrueTypeGlyphIndex(cmap, cmapSize, ucs4);
if (glyph == 0 && ucs4 < 0x100)
glyph = getTrueTypeGlyphIndex(cmap, cmapSize, ucs4 + 0xf000);
} else if (ttf) {
glyph = getTrueTypeGlyphIndex(cmap, cmapSize, ucs4);
- } else
-#endif
- if (ucs4 >= tm.tmFirstChar && ucs4 <= tm.tmLastChar) {
+ } else if (ucs4 >= tm.tmFirstChar && ucs4 <= tm.tmLastChar) {
glyph = ucs4;
- } else {
- glyph = 0;
}
return glyph;
@@ -377,12 +364,8 @@ bool QWindowsFontEngine::stringToCMap(const QChar *str, int len, QGlyphLayout *g
inline void calculateTTFGlyphWidth(HDC hdc, UINT glyph, int &width)
{
-#if defined(Q_OS_WINCE)
- GetCharWidth32(hdc, glyph, glyph, &width);
-#else
if (ptrGetCharWidthI)
ptrGetCharWidthI(hdc, glyph, 1, 0, &width);
-#endif
}
void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags flags) const
@@ -467,7 +450,7 @@ glyph_metrics_t QWindowsFontEngine::boundingBox(const QGlyphLayout &glyphs)
return glyph_metrics_t(0, -tm.tmAscent, w - lastRightBearing(glyphs), tm.tmHeight, w, 0);
}
-#ifndef Q_OS_WINCE
+
bool QWindowsFontEngine::getOutlineMetrics(glyph_t glyph, const QTransform &t, glyph_metrics_t *metrics) const
{
Q_ASSERT(metrics != 0);
@@ -520,11 +503,9 @@ bool QWindowsFontEngine::getOutlineMetrics(glyph_t glyph, const QTransform &t, g
return false;
}
}
-#endif
glyph_metrics_t QWindowsFontEngine::boundingBox(glyph_t glyph, const QTransform &t)
{
-#ifndef Q_OS_WINCE
HDC hdc = m_fontEngineData->hdc;
SelectObject(hdc, hfont);
@@ -542,34 +523,6 @@ glyph_metrics_t QWindowsFontEngine::boundingBox(glyph_t glyph, const QTransform
}
return glyphMetrics;
-#else
- HDC hdc = m_fontEngineData->hdc;
- HGDIOBJ oldFont = SelectObject(hdc, hfont);
-
- ABC abc;
- int width;
- int advance;
-#ifdef GWES_MGTT // true type fonts
- if (GetCharABCWidths(hdc, glyph, glyph, &abc)) {
- width = qAbs(abc.abcA) + abc.abcB + qAbs(abc.abcC);
- advance = abc.abcA + abc.abcB + abc.abcC;
- }
- else
-#endif
-#if defined(GWES_MGRAST) || defined(GWES_MGRAST2) // raster fonts
- if (GetCharWidth32(hdc, glyph, glyph, &width)) {
- advance = width;
- }
- else
-#endif
- { // fallback
- width = tm.tmMaxCharWidth;
- advance = width;
- }
-
- SelectObject(hdc, oldFont);
- return glyph_metrics_t(0, -tm.tmAscent, width, tm.tmHeight, advance, 0).transformed(t);
-#endif
}
QFixed QWindowsFontEngine::ascent() const
@@ -636,22 +589,16 @@ void QWindowsFontEngine::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qre
HDC hdc = m_fontEngineData->hdc;
SelectObject(hdc, hfont);
-#ifndef Q_OS_WINCE
- if (ttf)
-#endif
- {
+ if (ttf) {
ABC abcWidths;
GetCharABCWidthsI(hdc, glyph, 1, 0, &abcWidths);
if (leftBearing)
*leftBearing = abcWidths.abcA;
if (rightBearing)
*rightBearing = abcWidths.abcC;
- }
-#ifndef Q_OS_WINCE
- else {
+ } else {
QFontEngine::getGlyphBearings(glyph, leftBearing, rightBearing);
}
-#endif
}
#endif // Q_CC_MINGW
@@ -670,7 +617,6 @@ qreal QWindowsFontEngine::minLeftBearing() const
qreal QWindowsFontEngine::minRightBearing() const
{
-#ifndef Q_OS_WINCE
if (rbearing == SHRT_MIN) {
int ml = 0;
int mr = 0;
@@ -726,40 +672,6 @@ qreal QWindowsFontEngine::minRightBearing() const
}
return rbearing;
-#else // !Q_OS_WINCE
- if (rbearing == SHRT_MIN) {
- int ml = 0;
- int mr = 0;
- HDC hdc = m_fontEngineData->hdc;
- SelectObject(hdc, hfont);
- if (ttf) {
- ABC *abc = 0;
- int n = tm.tmLastChar - tm.tmFirstChar;
- if (n <= max_font_count) {
- abc = new ABC[n+1];
- GetCharABCWidths(hdc, tm.tmFirstChar, tm.tmLastChar, abc);
- } else {
- abc = new ABC[char_table_entries+1];
- for (int i = 0; i < char_table_entries; i++)
- GetCharABCWidths(hdc, char_table[i], char_table[i], abc+i);
- n = char_table_entries;
- }
- ml = abc[0].abcA;
- mr = abc[0].abcC;
- for (int i = 1; i < n; i++) {
- if (abc[i].abcA + abc[i].abcB + abc[i].abcC != 0) {
- ml = qMin(ml,abc[i].abcA);
- mr = qMin(mr,abc[i].abcC);
- }
- }
- delete [] abc;
- }
- lbearing = ml;
- rbearing = mr;
- }
-
- return rbearing;
-#endif // Q_OS_WINCE
}
static inline double qt_fixed_to_double(const FIXED &p) {
@@ -786,7 +698,6 @@ static bool addGlyphToPath(glyph_t glyph, const QFixedPoint &position, HDC hdc,
GLYPHMETRICS gMetric;
memset(&gMetric, 0, sizeof(GLYPHMETRICS));
-#ifndef Q_OS_WINCE
if (metric) {
// If metrics requested, retrieve first using GGO_METRICS, because the returned
// values are incorrect for OpenType PS fonts if obtained at the same time as the
@@ -801,7 +712,6 @@ static bool addGlyphToPath(glyph_t glyph, const QFixedPoint &position, HDC hdc,
int(gMetric.gmBlackBoxX), int(gMetric.gmBlackBoxY),
gMetric.gmCellIncX, gMetric.gmCellIncY);
}
-#endif
uint glyphFormat = GGO_NATIVE;
@@ -820,15 +730,6 @@ static bool addGlyphToPath(glyph_t glyph, const QFixedPoint &position, HDC hdc,
return false;
}
-#ifdef Q_OS_WINCE
- if (metric) {
- // #### obey scale
- *metric = glyph_metrics_t(gMetric.gmptGlyphOrigin.x, -gMetric.gmptGlyphOrigin.y,
- (int)gMetric.gmBlackBoxX, (int)gMetric.gmBlackBoxY,
- gMetric.gmCellIncX, gMetric.gmCellIncY);
- }
-#endif
-
DWORD offset = 0;
DWORD headerOffset = 0;
@@ -1052,7 +953,6 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph,
bool has_transformation = t.type() > QTransform::TxTranslate;
-#ifndef Q_OS_WINCE
unsigned int options = ttf ? ETO_GLYPH_INDEX : 0;
XFORM xform;
@@ -1095,13 +995,6 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph,
xform.eDx -= tgm.gmptGlyphOrigin.x;
xform.eDy += tgm.gmptGlyphOrigin.y;
}
-#else // else wince
- unsigned int options = 0;
- if (has_transformation) {
- qWarning() << "QWindowsFontEngine is unable to apply transformations other than translations for fonts on Windows CE."
- << "If you need them anyway, start your application with -platform windows:fontengine=freetype.";
- }
-#endif // wince
// The padding here needs to be kept in sync with the values in alphaMapBoundingBox.
QWindowsNativeImage *ni = new QWindowsNativeImage(iw + 2 * margin,
@@ -1123,14 +1016,11 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph,
HGDIOBJ old_font = SelectObject(hdc, font);
-#ifndef Q_OS_WINCE
if (has_transformation) {
SetGraphicsMode(hdc, GM_ADVANCED);
SetWorldTransform(hdc, &xform);
ExtTextOut(hdc, 0, 0, options, 0, reinterpret_cast<LPCWSTR>(&glyph), 1, 0);
- } else
-#endif // !Q_OS_WINCE
- {
+ } else {
ExtTextOut(hdc, -gx + margin, -gy + margin, options, 0, reinterpret_cast<LPCWSTR>(&glyph), 1, 0);
}
diff --git a/src/plugins/platforms/windows/qwindowsfontengine.h b/src/plugins/platforms/windows/qwindowsfontengine.h
index d4d98422a1..921351a4b0 100644
--- a/src/plugins/platforms/windows/qwindowsfontengine.h
+++ b/src/plugins/platforms/windows/qwindowsfontengine.h
@@ -57,7 +57,7 @@
#include <QtCore/QSharedPointer>
#include <QtCore/QMetaType>
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp
index 0a2d30319e..c1eb664324 100644
--- a/src/plugins/platforms/windows/qwindowsglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp
@@ -149,15 +149,9 @@ QT_BEGIN_NAMESPACE
QWindowsOpengl32DLL QOpenGLStaticContext::opengl32;
-PROC QWindowsOpengl32DLL::resolve(const char *name)
+FARPROC QWindowsOpengl32DLL::resolve(const char *name)
{
-#ifndef Q_OS_WINCE
- PROC proc = m_lib ? ::GetProcAddress(m_lib, name) : 0;
-#else
- PROC proc = m_lib ? ::GetProcAddress(m_lib, (const wchar_t *) QString::fromLatin1(name).utf16()) : 0;
-#endif
-
- return proc;
+ return m_lib ? ::GetProcAddress(m_lib, name) : nullptr;
}
bool QWindowsOpengl32DLL::init(bool softwareRendering)
diff --git a/src/plugins/platforms/windows/qwindowsglcontext.h b/src/plugins/platforms/windows/qwindowsglcontext.h
index 2944ab7192..4c804a612e 100644
--- a/src/plugins/platforms/windows/qwindowsglcontext.h
+++ b/src/plugins/platforms/windows/qwindowsglcontext.h
@@ -40,7 +40,7 @@
#ifndef QWINDOWSGLCONTEXT_H
#define QWINDOWSGLCONTEXT_H
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include "qwindowsopenglcontext.h"
#include <QtGui/QOpenGLContext>
@@ -122,7 +122,7 @@ struct QWindowsOpengl32DLL
void (APIENTRY * glGetIntegerv)(GLenum pname, GLint* params);
const GLubyte * (APIENTRY * glGetString)(GLenum name);
- PROC resolve(const char *name);
+ FARPROC resolve(const char *name);
private:
HMODULE m_lib;
bool m_nonOpengl32;
diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.cpp b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
index 501b956a68..8adbd494c4 100644
--- a/src/plugins/platforms/windows/qwindowsinputcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsinputcontext.cpp
@@ -190,11 +190,7 @@ bool QWindowsInputContext::hasCapability(Capability capability) const
{
switch (capability) {
case QPlatformInputContext::HiddenTextCapability:
-#ifndef Q_OS_WINCE
return false; // QTBUG-40691, do not show IME on desktop for password entry fields.
-#else
- break; // Windows CE: Show software keyboard.
-#endif
default:
break;
}
diff --git a/src/plugins/platforms/windows/qwindowsinputcontext.h b/src/plugins/platforms/windows/qwindowsinputcontext.h
index 4c08fa0ef2..a7fa2c4f94 100644
--- a/src/plugins/platforms/windows/qwindowsinputcontext.h
+++ b/src/plugins/platforms/windows/qwindowsinputcontext.h
@@ -40,7 +40,7 @@
#ifndef QWINDOWSINPUTCONTEXT_H
#define QWINDOWSINPUTCONTEXT_H
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtCore/QLocale>
#include <QtCore/QPointer>
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index b6d2c16f89..b9a63c7a89 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -64,7 +64,7 @@
#include <qpa/qplatformnativeinterface.h>
#include <qpa/qwindowsysteminterface.h>
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#ifndef QT_NO_SESSIONMANAGER
# include "qwindowssessionmanager.h"
#endif
#include <QtGui/qtouchdevice.h>
@@ -102,7 +102,7 @@ QT_BEGIN_NAMESPACE
It should compile with:
\list
- \li Microsoft Visual Studio 2008 or later (using the Microsoft Windows SDK,
+ \li Microsoft Visual Studio 2013 or later (using the Microsoft Windows SDK,
(\c Q_CC_MSVC).
\li Stock \l{http://mingw.org/}{MinGW} (\c Q_CC_MINGW).
This version ships with headers that are missing a lot of WinAPI.
@@ -112,15 +112,8 @@ QT_BEGIN_NAMESPACE
(\c Q_CC_MINGW and \c __MINGW64_VERSION_MAJOR indicating the version).
MinGW-w64 provides more complete headers (compared to stock MinGW from mingw.org),
including a considerable part of the Windows SDK.
- \li Visual Studio 2008 for Windows Embedded (\c Q_OS_WINCE).
\endlist
- The file \c qtwindows_additional.h contains defines and declarations that
- are missing in MinGW. When encountering missing declarations, it should
- be added there so that \c #ifdefs for MinGW can be avoided. Similarly,
- \c qplatformfunctions_wince.h contains defines and declarations for
- Windows Embedded.
-
When using a function from the WinAPI, the minimum supported Windows version
and Windows Embedded support should be checked. If the function is not supported
on Windows XP or is not present in the MinGW-headers, it should be dynamically
@@ -219,9 +212,7 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList &paramL
: m_options(0)
, m_fontDatabase(0)
{
-#ifndef Q_OS_WINCE
Q_INIT_RESOURCE(openglblacklists);
-#endif
static bool dpiAwarenessSet = false;
int tabletAbsoluteRange = -1;
@@ -483,46 +474,16 @@ QWindowsStaticOpenGLContext *QWindowsIntegration::staticOpenGLContext()
}
#endif // !QT_NO_OPENGL
-/* Workaround for QTBUG-24205: In 'Auto', pick the FreeType engine for
- * QML2 applications. */
-
-#ifdef Q_OS_WINCE
-// It's not easy to detect if we are running a QML application
-// Let's try to do so by checking if the Qt Quick module is loaded.
-inline bool isQMLApplication()
-{
- // check if the Qt Quick module is loaded
-#ifdef _DEBUG
- HMODULE handle = GetModuleHandle(L"Qt5Quick" QT_LIBINFIX L"d.dll");
-#else
- HMODULE handle = GetModuleHandle(L"Qt5Quick" QT_LIBINFIX L".dll");
-#endif
- return (handle != NULL);
-}
-#endif
-
QPlatformFontDatabase *QWindowsIntegration::fontDatabase() const
{
if (!d->m_fontDatabase) {
#ifdef QT_NO_FREETYPE
d->m_fontDatabase = new QWindowsFontDatabase();
#else // QT_NO_FREETYPE
- if (d->m_options & QWindowsIntegration::FontDatabaseFreeType) {
+ if (d->m_options & QWindowsIntegration::FontDatabaseFreeType)
d->m_fontDatabase = new QWindowsFontDatabaseFT;
- } else if (d->m_options & QWindowsIntegration::FontDatabaseNative){
- d->m_fontDatabase = new QWindowsFontDatabase;
- } else {
-#ifndef Q_OS_WINCE
+ else
d->m_fontDatabase = new QWindowsFontDatabase;
-#else
- if (isQMLApplication()) {
- qCDebug(lcQpaFonts) << "QML application detected, using FreeType rendering";
- d->m_fontDatabase = new QWindowsFontDatabaseFT;
- }
- else
- d->m_fontDatabase = new QWindowsFontDatabase;
-#endif
- }
#endif // QT_NO_FREETYPE
}
return d->m_fontDatabase;
@@ -610,7 +571,7 @@ unsigned QWindowsIntegration::options() const
return d->m_options;
}
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
QPlatformSessionManager *QWindowsIntegration::createPlatformSessionManager(const QString &id, const QString &key) const
{
return new QWindowsSessionManager(id, key);
diff --git a/src/plugins/platforms/windows/qwindowsintegration.h b/src/plugins/platforms/windows/qwindowsintegration.h
index 0c03274799..4258f908e7 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.h
+++ b/src/plugins/platforms/windows/qwindowsintegration.h
@@ -106,7 +106,7 @@ public:
void beep() const Q_DECL_OVERRIDE;
-#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
+#if !defined(QT_NO_SESSIONMANAGER)
QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const Q_DECL_OVERRIDE;
#endif
diff --git a/src/plugins/platforms/windows/qwindowsinternalmimedata.cpp b/src/plugins/platforms/windows/qwindowsinternalmimedata.cpp
index 2dfe7fc5f9..21ebee6262 100644
--- a/src/plugins/platforms/windows/qwindowsinternalmimedata.cpp
+++ b/src/plugins/platforms/windows/qwindowsinternalmimedata.cpp
@@ -39,7 +39,6 @@
#include "qwindowsinternalmimedata.h"
#include "qwindowscontext.h"
-#include "qplatformfunctions_wince.h"
#include "qwindowsmime.h"
#include <QDebug>
/*!
diff --git a/src/plugins/platforms/windows/qwindowsinternalmimedata.h b/src/plugins/platforms/windows/qwindowsinternalmimedata.h
index 4ac7a303af..4d775b1f21 100644
--- a/src/plugins/platforms/windows/qwindowsinternalmimedata.h
+++ b/src/plugins/platforms/windows/qwindowsinternalmimedata.h
@@ -40,7 +40,7 @@
#ifndef QWINDOWSINTERNALMIME_H
#define QWINDOWSINTERNALMIME_H
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtGui/private/qdnd_p.h> // QInternalMime
#include <QtCore/QVariant>
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp
index ae3c477399..79b5bbae41 100644
--- a/src/plugins/platforms/windows/qwindowskeymapper.cpp
+++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp
@@ -553,34 +553,6 @@ inline quint32 winceKeyBend(quint32 keyCode)
return KeyTbl[keyCode];
}
-#ifdef Q_OS_WINCE
-QT_BEGIN_INCLUDE_NAMESPACE
-int ToUnicode(UINT vk, int /*scancode*/, unsigned char* /*kbdBuffer*/, LPWSTR unicodeBuffer, int, int)
-{
- QT_USE_NAMESPACE
- QChar* buf = reinterpret_cast< QChar*>(unicodeBuffer);
- if (KeyTbl[vk] == 0) {
- buf[0] = vk;
- return 1;
- }
- return 0;
-}
-
-int ToAscii(UINT vk, int scancode, unsigned char *kbdBuffer, LPWORD unicodeBuffer, int flag)
-{
- return ToUnicode(vk, scancode, kbdBuffer, (LPWSTR) unicodeBuffer, 0, flag);
-
-}
-
-bool GetKeyboardState(unsigned char* kbuffer)
-{
- for (int i=0; i< 256; ++i)
- kbuffer[i] = GetAsyncKeyState(i);
- return true;
-}
-QT_END_INCLUDE_NAMESPACE
-#endif // Q_OS_WINCE
-
// Translate a VK into a Qt key code, or unicode character
static inline quint32 toKeyOrUnicode(quint32 vk, quint32 scancode, unsigned char *kbdBuffer, bool *isDeadkey = 0)
{
@@ -781,7 +753,6 @@ static void showSystemMenu(QWindow* w)
if (!menu)
return; // no menu for this window
-#ifndef Q_OS_WINCE
#define enabled (MF_BYCOMMAND | MF_ENABLED)
#define disabled (MF_BYCOMMAND | MF_GRAYED)
@@ -806,7 +777,6 @@ static void showSystemMenu(QWindow* w)
#undef enabled
#undef disabled
-#endif // !Q_OS_WINCE
const QPoint pos = QHighDpi::toNativePixels(topLevel->geometry().topLeft(), topLevel);
const int ret = TrackPopupMenuEx(menu,
TPM_LEFTALIGN | TPM_TOPALIGN | TPM_NONOTIFY | TPM_RETURNCMD,
@@ -1188,7 +1158,6 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
modifiers, scancode, quint32(msg.wParam), nModifiers, text, false);
result =true;
bool store = true;
-#ifndef Q_OS_WINCE
// Alt+<alphanumerical> go to the Win32 menu system if unhandled by Qt
if (msgType == WM_SYSKEYDOWN && !result && a) {
HWND parent = GetParent(QWindowsWindow::handleOf(receiver));
@@ -1202,7 +1171,6 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
parent = GetParent(parent);
}
}
-#endif // !Q_OS_WINCE
if (!store)
key_recorder.findKey(int(msg.wParam), true);
}
@@ -1232,7 +1200,6 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
nModifiers,
(rec ? rec->text : QString()), false);
result = true;
-#ifndef Q_OS_WINCE
// don't pass Alt to Windows unless we are embedded in a non-Qt window
if (code == Qt::Key_Alt) {
const QWindowsContext *context = QWindowsContext::instance();
@@ -1245,7 +1212,6 @@ bool QWindowsKeyMapper::translateKeyEventInternal(QWindow *window, const MSG &ms
parent = GetParent(parent);
}
}
-#endif
}
}
return result;
diff --git a/src/plugins/platforms/windows/qwindowskeymapper.h b/src/plugins/platforms/windows/qwindowskeymapper.h
index 1e32ddabcc..2657644780 100644
--- a/src/plugins/platforms/windows/qwindowskeymapper.h
+++ b/src/plugins/platforms/windows/qwindowskeymapper.h
@@ -40,7 +40,7 @@
#ifndef QWINDOWSKEYMAPPER_H
#define QWINDOWSKEYMAPPER_H
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtCore/QLocale>
diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp
index b86972996c..30d438a127 100644
--- a/src/plugins/platforms/windows/qwindowsmime.cpp
+++ b/src/plugins/platforms/windows/qwindowsmime.cpp
@@ -403,11 +403,9 @@ QDebug operator<<(QDebug d, const FORMATETC &tc)
case CF_UNICODETEXT:
d << "CF_UNICODETEXT";
break;
-#ifndef Q_OS_WINCE
case CF_ENHMETAFILE:
d << "CF_ENHMETAFILE";
break;
-#endif // !Q_OS_WINCE
default:
d << QWindowsMimeConverter::clipboardFormatName(tc.cfFormat);
break;
diff --git a/src/plugins/platforms/windows/qwindowsmime.h b/src/plugins/platforms/windows/qwindowsmime.h
index b727f13747..4c0cbf9f31 100644
--- a/src/plugins/platforms/windows/qwindowsmime.h
+++ b/src/plugins/platforms/windows/qwindowsmime.h
@@ -40,7 +40,7 @@
#ifndef QWINDOWSMIME_H
#define QWINDOWSMIME_H
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtCore/QVector>
#include <QtCore/QList>
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
index b92387d397..3f6230172e 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
@@ -56,6 +56,37 @@
#include <windowsx.h>
+/* Touch is supported from Windows 7 onwards and data structures
+ * are present in the Windows SDK's, but not in older MSVC Express
+ * versions. */
+
+#if defined(Q_CC_MINGW) || !defined(TOUCHEVENTF_MOVE)
+
+typedef struct tagTOUCHINPUT {
+ LONG x;
+ LONG y;
+ HANDLE hSource;
+ DWORD dwID;
+ DWORD dwFlags;
+ DWORD dwMask;
+ DWORD dwTime;
+ ULONG_PTR dwExtraInfo;
+ DWORD cxContact;
+ DWORD cyContact;
+} TOUCHINPUT, *PTOUCHINPUT;
+typedef TOUCHINPUT const * PCTOUCHINPUT;
+
+# define TOUCHEVENTF_MOVE 0x0001
+# define TOUCHEVENTF_DOWN 0x0002
+# define TOUCHEVENTF_UP 0x0004
+# define TOUCHEVENTF_INRANGE 0x0008
+# define TOUCHEVENTF_PRIMARY 0x0010
+# define TOUCHEVENTF_NOCOALESCE 0x0020
+# define TOUCHEVENTF_PALM 0x0080
+# define TOUCHINPUTMASKF_CONTACTAREA 0x0004
+# define TOUCHINPUTMASKF_EXTRAINFO 0x0002
+#endif // if defined(Q_CC_MINGW) || !defined(TOUCHEVENTF_MOVE)
+
QT_BEGIN_NAMESPACE
static inline void compressMouseMove(MSG *msg)
@@ -203,7 +234,6 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
Qt::MouseEventSource source = Qt::MouseEventNotSynthesized;
-#ifndef Q_OS_WINCE
// Check for events synthesized from touch. Lower byte is touch index, 0 means pen.
static const bool passSynthesizedMouseEvents =
!(QWindowsIntegration::instance()->options() & QWindowsIntegration::DontPassOsMouseEventsSynthesizedFromTouch);
@@ -218,7 +248,6 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
return false;
}
}
-#endif // !Q_OS_WINCE
const QPoint winEventPosition(GET_X_LPARAM(msg.lParam), GET_Y_LPARAM(msg.lParam));
if (et & QtWindows::NonClientEventFlag) {
@@ -320,7 +349,6 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
const bool hasCapture = platformWindow->hasMouseCapture();
const bool currentNotCapturing = hasCapture && currentWindowUnderMouse != window;
-#ifndef Q_OS_WINCE
// Enter new window: track to generate leave event.
// If there is an active capture, only track if the current window is capturing,
// so we don't get extra leave when cursor leaves the application.
@@ -334,7 +362,6 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd,
qWarning("TrackMouseEvent failed.");
m_trackedWindow = window;
}
-#endif // !Q_OS_WINCE
// No enter or leave events are sent as long as there is an autocapturing window.
if (!hasCapture || !platformWindow->testFlag(QWindowsWindow::AutoMouseCapture)) {
@@ -489,7 +516,6 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
QtWindows::WindowsEventType,
MSG msg, LRESULT *)
{
-#ifndef Q_OS_WINCE
typedef QWindowSystemInterface::TouchPoint QTouchPoint;
typedef QList<QWindowSystemInterface::TouchPoint> QTouchPointList;
@@ -565,109 +591,17 @@ bool QWindowsMouseHandler::translateTouchEvent(QWindow *window, HWND,
QWindowSystemInterface::handleTouchEvent(window,
m_touchDevice,
touchPoints);
-#else // !Q_OS_WINCE
- Q_UNUSED(window)
- Q_UNUSED(msg)
-#endif
return true;
-
}
bool QWindowsMouseHandler::translateGestureEvent(QWindow *window, HWND hwnd,
QtWindows::WindowsEventType,
MSG msg, LRESULT *)
{
-#ifndef Q_OS_WINCE
Q_UNUSED(window)
Q_UNUSED(hwnd)
Q_UNUSED(msg)
return false;
-#else // !Q_OS_WINCE
- GESTUREINFO gi;
- memset(&gi, 0, sizeof(GESTUREINFO));
- gi.cbSize = sizeof(GESTUREINFO);
-
- if (!GetGestureInfo((HGESTUREINFO)msg.lParam, &gi))
- return false;
-
- const QPoint position = QPoint(gi.ptsLocation.x, gi.ptsLocation.y);
-
- if (gi.dwID != GID_DIRECTMANIPULATION)
- return true;
- static QPoint lastTouchPos;
- const QScreen *screen = window->screen();
- if (!screen)
- screen = QGuiApplication::primaryScreen();
- if (!screen)
- return true;
- const QRect screenGeometry = screen->geometry();
- QWindowSystemInterface::TouchPoint touchPoint;
- static QWindowSystemInterface::TouchPoint touchPoint2;
- touchPoint.id = 0;//gi.dwInstanceID;
- touchPoint.pressure = 1.0;
-
- if (gi.dwFlags & GF_BEGIN)
- touchPoint.state = Qt::TouchPointPressed;
- else if (gi.dwFlags & GF_END)
- touchPoint.state = Qt::TouchPointReleased;
- else if (gi.dwFlags == 0)
- touchPoint.state = Qt::TouchPointMoved;
- else
- return true;
- touchPoint2.pressure = 1.0;
- touchPoint2.id = 1;
- const QPoint winEventPosition = position;
- const int deltaX = GID_DIRECTMANIPULATION_DELTA_X(gi.ullArguments);
- const int deltaY = GID_DIRECTMANIPULATION_DELTA_Y(gi.ullArguments);
- //Touch points are taken from the whole screen so map the position to the screen
- const QPoint globalPosition = QWindowsGeometryHint::mapToGlobal(hwnd, winEventPosition);
- const QPoint globalPosition2 = QWindowsGeometryHint::mapToGlobal(hwnd, QPoint(position.x() + deltaX, position.y() + deltaY));
-
- touchPoint.normalPosition =
- QPointF( (qreal)globalPosition.x() / screenGeometry.width(), (qreal)globalPosition.y() / screenGeometry.height() );
-
- touchPoint.area.moveCenter(globalPosition);
-
- QList<QWindowSystemInterface::TouchPoint> pointList;
- pointList.append(touchPoint);
- if (deltaX != 0 && deltaY != 0) {
- touchPoint2.state = m_had2ndTouchPoint ? Qt::TouchPointMoved : Qt::TouchPointPressed;
- m_had2ndTouchPoint = true;
- touchPoint2.normalPosition =
- QPointF( (qreal)globalPosition2.x() / screenGeometry.width(), (qreal)globalPosition2.y() / screenGeometry.height() );
-
- touchPoint2.area.moveCenter(globalPosition2);
- lastTouchPos = globalPosition2;
- pointList.append(touchPoint2);
- } else if (m_had2ndTouchPoint) {
- touchPoint2.normalPosition =
- QPointF( (qreal)lastTouchPos.x() / screenGeometry.width(), (qreal)lastTouchPos.y() / screenGeometry.height() );
-
- touchPoint2.area.moveCenter(lastTouchPos);
- touchPoint2.state = Qt::TouchPointReleased;
- pointList.append(touchPoint2);
- m_had2ndTouchPoint = false;
- }
-
- if (!m_touchDevice) {
- m_touchDevice = new QTouchDevice;
- // TODO: Device used to be hardcoded to screen in previous code.
- m_touchDevice->setType(QTouchDevice::TouchScreen);
- m_touchDevice->setCapabilities(QTouchDevice::Position | QTouchDevice::Area | QTouchDevice::NormalizedPosition);
- QWindowSystemInterface::registerTouchDevice(m_touchDevice);
- }
-
- QWindowSystemInterface::handleTouchEvent(window, m_touchDevice, pointList);
- // handle window focusing in/out
- if (window != m_windowUnderMouse) {
- if (m_windowUnderMouse)
- QWindowSystemInterface::handleLeaveEvent(m_windowUnderMouse);
- if (window)
- QWindowSystemInterface::handleEnterEvent(window);
- m_windowUnderMouse = window;
- }
- return true;
-#endif // Q_OS_WINCE
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.h b/src/plugins/platforms/windows/qwindowsmousehandler.h
index d16c9f9e02..bd36d9f44c 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.h
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.h
@@ -41,7 +41,7 @@
#define QWINDOWSMOUSEHANDLER_H
#include "qtwindowsglobal.h"
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtCore/QPointer>
#include <QtCore/QHash>
@@ -91,10 +91,6 @@ private:
QTouchDevice *m_touchDevice;
bool m_leftButtonDown;
QWindow *m_previousCaptureWindow;
-#ifdef Q_OS_WINCE
-//This is required to send a touch up if we don't get a second touch position any more
- bool m_had2ndTouchPoint;
-#endif
};
Qt::MouseButtons QWindowsMouseHandler::keyStateToMouseButtons(int wParam)
diff --git a/src/plugins/platforms/windows/qwindowsnativeimage.cpp b/src/plugins/platforms/windows/qwindowsnativeimage.cpp
index bc8bfda32b..ec9683ea8d 100644
--- a/src/plugins/platforms/windows/qwindowsnativeimage.cpp
+++ b/src/plugins/platforms/windows/qwindowsnativeimage.cpp
@@ -126,9 +126,7 @@ QWindowsNativeImage::QWindowsNativeImage(int width, int height,
m_image = QImage(width, height, format);
}
-#ifndef Q_OS_WINCE
GdiFlush();
-#endif
}
QWindowsNativeImage::~QWindowsNativeImage()
diff --git a/src/plugins/platforms/windows/qwindowsnativeimage.h b/src/plugins/platforms/windows/qwindowsnativeimage.h
index c96ca7937a..bfe0f07dfd 100644
--- a/src/plugins/platforms/windows/qwindowsnativeimage.h
+++ b/src/plugins/platforms/windows/qwindowsnativeimage.h
@@ -40,7 +40,7 @@
#ifndef QWINDOWSNATIVEIMAGE_H
#define QWINDOWSNATIVEIMAGE_H
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtGui/QImage>
diff --git a/src/plugins/platforms/windows/qwindowsole.h b/src/plugins/platforms/windows/qwindowsole.h
index 009111e55c..dc31c793e9 100644
--- a/src/plugins/platforms/windows/qwindowsole.h
+++ b/src/plugins/platforms/windows/qwindowsole.h
@@ -40,7 +40,7 @@
#ifndef QWINDOWSOLE_H
#define QWINDOWSOLE_H
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtCore/QMap>
#include <QtCore/QPointer>
diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp
index c24e0ba0ae..5283d6b260 100644
--- a/src/plugins/platforms/windows/qwindowsopengltester.cpp
+++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp
@@ -54,17 +54,14 @@
#include <private/qopengl_p.h>
#endif
-#ifndef Q_OS_WINCE
-# include <QtCore/qt_windows.h>
-# include <private/qsystemlibrary_p.h>
-# include <d3d9.h>
-#endif
+#include <QtCore/qt_windows.h>
+#include <private/qsystemlibrary_p.h>
+#include <d3d9.h>
QT_BEGIN_NAMESPACE
GpuDescription GpuDescription::detect()
{
-#ifndef Q_OS_WINCE
typedef IDirect3D9 * (WINAPI *PtrDirect3DCreate9)(UINT);
GpuDescription result;
@@ -95,13 +92,6 @@ GpuDescription GpuDescription::detect()
result.description = adapterIdentifier.Description;
}
return result;
-#else // !Q_OS_WINCE
- GpuDescription result;
- result.vendorId = result.deviceId = result.revision =1;
- result.driverVersion = QVersionNumber(1, 1, 1);
- result.driverName = result.description = QByteArrayLiteral("Generic");
- return result;
-#endif
}
#ifndef QT_NO_DEBUG_STREAM
@@ -155,7 +145,6 @@ QVariant GpuDescription::toVariant() const
QWindowsOpenGLTester::Renderer QWindowsOpenGLTester::requestedGlesRenderer()
{
-#ifndef Q_OS_WINCE
const char platformVar[] = "QT_ANGLE_PLATFORM";
if (qEnvironmentVariableIsSet(platformVar)) {
const QByteArray anglePlatform = qgetenv(platformVar);
@@ -167,13 +156,11 @@ QWindowsOpenGLTester::Renderer QWindowsOpenGLTester::requestedGlesRenderer()
return QWindowsOpenGLTester::AngleRendererD3d11Warp;
qCWarning(lcQpaGl) << "Invalid value set for " << platformVar << ": " << anglePlatform;
}
-#endif // !Q_OS_WINCE
return QWindowsOpenGLTester::InvalidRenderer;
}
QWindowsOpenGLTester::Renderer QWindowsOpenGLTester::requestedRenderer()
{
-#ifndef Q_OS_WINCE
const char openGlVar[] = "QT_OPENGL";
if (QCoreApplication::testAttribute(Qt::AA_UseOpenGLES)) {
const Renderer glesRenderer = QWindowsOpenGLTester::requestedGlesRenderer();
@@ -195,12 +182,9 @@ QWindowsOpenGLTester::Renderer QWindowsOpenGLTester::requestedRenderer()
return QWindowsOpenGLTester::SoftwareRasterizer;
qCWarning(lcQpaGl) << "Invalid value set for " << openGlVar << ": " << requested;
}
-#endif // !Q_OS_WINCE
return QWindowsOpenGLTester::InvalidRenderer;
}
-#ifndef Q_OS_WINCE
-
static inline QString resolveBugListFile(const QString &fileName)
{
if (QFileInfo(fileName).isAbsolute())
@@ -216,12 +200,10 @@ static inline QString resolveBugListFile(const QString &fileName)
return QStandardPaths::locate(QStandardPaths::ConfigLocation, fileName);
}
-# ifndef QT_NO_OPENGL
+#ifndef QT_NO_OPENGL
typedef QHash<QOpenGLConfig::Gpu, QWindowsOpenGLTester::Renderers> SupportedRenderersCache;
Q_GLOBAL_STATIC(SupportedRenderersCache, supportedRenderersCache)
-# endif
-
-#endif // !Q_OS_WINCE
+#endif
QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::detectSupportedRenderers(const GpuDescription &gpu, bool glesOnly)
{
@@ -229,8 +211,6 @@ QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::detectSupportedRenderers(c
Q_UNUSED(glesOnly)
#if defined(QT_NO_OPENGL)
return 0;
-#elif defined(Q_OS_WINCE)
- return QWindowsOpenGLTester::Gles;
#else
QOpenGLConfig::Gpu qgpu = QOpenGLConfig::Gpu::fromDevice(gpu.vendorId, gpu.deviceId, gpu.driverVersion, gpu.description);
SupportedRenderersCache *srCache = supportedRenderersCache();
@@ -281,7 +261,7 @@ QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::detectSupportedRenderers(c
}
srCache->insert(qgpu, result);
return result;
-#endif // !Q_OS_WINCE && !QT_NO_OPENGL
+#endif // !QT_NO_OPENGL
}
QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::supportedGlesRenderers()
@@ -302,7 +282,7 @@ QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::supportedRenderers()
bool QWindowsOpenGLTester::testDesktopGL()
{
-#if !defined(QT_NO_OPENGL) && !defined(Q_OS_WINCE)
+#if !defined(QT_NO_OPENGL)
HMODULE lib = 0;
HWND wnd = 0;
HDC dc = 0;
@@ -429,7 +409,7 @@ cleanup:
return result;
#else
return false;
-#endif // !QT_NO_OPENGL && !Q_OS_WINCE
+#endif // !QT_NO_OPENGL
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp
index b476c9be1d..23d43a95a5 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.cpp
+++ b/src/plugins/platforms/windows/qwindowsscreen.cpp
@@ -43,7 +43,7 @@
#include "qwindowsintegration.h"
#include "qwindowscursor.h"
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtCore/QSettings>
#include <QtGui/QPixmap>
@@ -68,8 +68,6 @@ static inline QDpi deviceDPI(HDC hdc)
return QDpi(GetDeviceCaps(hdc, LOGPIXELSX), GetDeviceCaps(hdc, LOGPIXELSY));
}
-#ifndef Q_OS_WINCE
-
static inline QDpi monitorDPI(HMONITOR hMonitor)
{
if (QWindowsContext::shcoredll.isValid()) {
@@ -81,8 +79,6 @@ static inline QDpi monitorDPI(HMONITOR hMonitor)
return QDpi(0, 0);
}
-#endif // !Q_OS_WINCE
-
typedef QList<QWindowsScreenData> WindowsScreenDataList;
static bool monitorData(HMONITOR hMonitor, QWindowsScreenData *data)
@@ -99,20 +95,9 @@ static bool monitorData(HMONITOR hMonitor, QWindowsScreenData *data)
if (data->name == QLatin1String("WinDisc")) {
data->flags |= QWindowsScreenData::LockScreen;
} else {
-#ifdef Q_OS_WINCE
- //Windows CE, just supports one Display and expects to get only DISPLAY,
- //instead of DISPLAY0 and so on, which are passed by info.szDevice
- HDC hdc = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
-#else
- HDC hdc = CreateDC(info.szDevice, NULL, NULL, NULL);
-#endif
- if (hdc) {
-#ifndef Q_OS_WINCE
+ if (const HDC hdc = CreateDC(info.szDevice, NULL, NULL, NULL)) {
const QDpi dpi = monitorDPI(hMonitor);
data->dpi = dpi.first ? dpi : deviceDPI(hdc);
-#else
- data->dpi = deviceDPI(hdc);
-#endif
data->depth = GetDeviceCaps(hdc, BITSPIXEL);
data->format = data->depth == 16 ? QImage::Format_RGB16 : QImage::Format_RGB32;
data->physicalSizeMM = QSizeF(GetDeviceCaps(hdc, HORZSIZE), GetDeviceCaps(hdc, VERTSIZE));
@@ -330,7 +315,6 @@ enum OrientationPreference // matching Win32 API ORIENTATION_PREFERENCE
bool QWindowsScreen::setOrientationPreference(Qt::ScreenOrientation o)
{
bool result = false;
-#ifndef Q_OS_WINCE
if (QWindowsContext::user32dll.setDisplayAutoRotationPreferences) {
DWORD orientationPreference = 0;
switch (o) {
@@ -352,14 +336,12 @@ bool QWindowsScreen::setOrientationPreference(Qt::ScreenOrientation o)
}
result = QWindowsContext::user32dll.setDisplayAutoRotationPreferences(orientationPreference);
}
-#endif // !Q_OS_WINCE
return result;
}
Qt::ScreenOrientation QWindowsScreen::orientationPreference()
{
Qt::ScreenOrientation result = Qt::PrimaryOrientation;
-#ifndef Q_OS_WINCE
if (QWindowsContext::user32dll.getDisplayAutoRotationPreferences) {
DWORD orientationPreference = 0;
if (QWindowsContext::user32dll.getDisplayAutoRotationPreferences(&orientationPreference)) {
@@ -379,7 +361,6 @@ Qt::ScreenOrientation QWindowsScreen::orientationPreference()
}
}
}
-#endif // !Q_OS_WINCE
return result;
}
@@ -388,7 +369,7 @@ Qt::ScreenOrientation QWindowsScreen::orientationPreference()
*/
QPlatformScreen::SubpixelAntialiasingType QWindowsScreen::subpixelAntialiasingTypeHint() const
{
-#if defined(Q_OS_WINCE) || !defined(FT_LCD_FILTER_H) || !defined(FT_CONFIG_OPTION_SUBPIXEL_RENDERING)
+#if !defined(FT_LCD_FILTER_H) || !defined(FT_CONFIG_OPTION_SUBPIXEL_RENDERING)
return QPlatformScreen::Subpixel_None;
#else
QPlatformScreen::SubpixelAntialiasingType type = QPlatformScreen::subpixelAntialiasingTypeHint();
diff --git a/src/plugins/platforms/windows/qwindowsscreen.h b/src/plugins/platforms/windows/qwindowsscreen.h
index 2afc410e07..02a9dc3bc3 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.h
+++ b/src/plugins/platforms/windows/qwindowsscreen.h
@@ -41,9 +41,6 @@
#define QWINDOWSSCREEN_H
#include "qtwindowsglobal.h"
-#ifdef Q_OS_WINCE
-# include "qplatformfunctions_wince.h"
-#endif
#include <QtCore/QList>
#include <QtCore/QVector>
diff --git a/src/plugins/platforms/windows/qwindowsservices.cpp b/src/plugins/platforms/windows/qwindowsservices.cpp
index 1fee56aeca..6cc56372ec 100644
--- a/src/plugins/platforms/windows/qwindowsservices.cpp
+++ b/src/plugins/platforms/windows/qwindowsservices.cpp
@@ -39,16 +39,14 @@
#define QT_NO_URL_CAST_FROM_STRING
#include "qwindowsservices.h"
-#include "qtwindows_additional.h"
+#include <QtCore/qt_windows.h>
#include <QtCore/QUrl>
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <shlobj.h>
-#ifndef Q_OS_WINCE
-# include <intshcut.h>
-#endif
+#include <intshcut.h>
QT_BEGIN_NAMESPACE
@@ -56,7 +54,6 @@ enum { debug = 0 };
static inline bool shellExecute(const QUrl &url)
{
-#ifndef Q_OS_WINCE
const QString nativeFilePath =
url.isLocalFile() ? QDir::toNativeSeparators(url.toLocalFile()) : url.toString(QUrl::FullyEncoded);
const quintptr result =
@@ -69,10 +66,6 @@ static inline bool shellExecute(const QUrl &url)
return false;
}
return true;
-#else
- Q_UNUSED(url);
- return false;
-#endif
}
// Retrieve the commandline for the default mail client. It contains a
@@ -106,13 +99,9 @@ static inline QString mailCommand()
}
if (!command[0])
return QString();
-#ifndef Q_OS_WINCE
wchar_t expandedCommand[MAX_PATH] = {0};
return ExpandEnvironmentStrings(command, expandedCommand, MAX_PATH) ?
QString::fromWCharArray(expandedCommand) : QString::fromWCharArray(command);
-#else
- return QString();
-#endif
}
static inline bool launchMail(const QUrl &url)
diff --git a/src/plugins/platforms/windows/qwindowstabletsupport.h b/src/plugins/platforms/windows/qwindowstabletsupport.h
index 4a24d62770..2c05dcddfc 100644
--- a/src/plugins/platforms/windows/qwindowstabletsupport.h
+++ b/src/plugins/platforms/windows/qwindowstabletsupport.h
@@ -42,7 +42,7 @@
#include "qtwindowsglobal.h"
-#if !defined(QT_NO_TABLETEVENT) && !defined(Q_OS_WINCE)
+#if !defined(QT_NO_TABLETEVENT)
#include <QtCore/QVector>
#include <QtCore/QPointF>
@@ -143,5 +143,5 @@ private:
QT_END_NAMESPACE
-#endif // !QT_NO_TABLETEVENT && !Q_OS_WINCE
+#endif // !QT_NO_TABLETEVENT
#endif // QWINDOWSTABLETSUPPORT_H
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
index ff4cfe63cb..79befc56c2 100644
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
@@ -49,17 +49,12 @@
#include "qwindowsintegration.h"
#include "qt_windows.h"
#include "qwindowsfontdatabase.h"
-#ifdef Q_OS_WINCE
-# include "qplatformfunctions_wince.h"
-# include "winuser.h"
-#else
-# include <commctrl.h>
-# include <objbase.h>
-# ifndef Q_CC_MINGW
-# include <commoncontrols.h>
-# endif
-# include <shellapi.h>
+#include <commctrl.h>
+#include <objbase.h>
+#ifndef Q_CC_MINGW
+# include <commoncontrols.h>
#endif
+#include <shellapi.h>
#include <QtCore/QVariant>
#include <QtCore/QCoreApplication>
@@ -73,6 +68,7 @@
#include <QtGui/QPainter>
#include <QtGui/QPixmapCache>
#include <qpa/qwindowsysteminterface.h>
+#include <QtPlatformSupport/private/qabstractfileiconengine_p.h>
#include <private/qhighdpiscaling_p.h>
#include <private/qsystemlibrary_p.h>
@@ -128,7 +124,6 @@ static inline QColor getSysColor(int index)
return COLORREFToQColor(GetSysColor(index));
}
-#ifndef QT_NO_WINCE_SHELLSDK
// QTBUG-48823/Windows 10: SHGetFileInfo() (as called by item views on file system
// models has been observed to trigger a WM_PAINT on the mainwindow. Suppress the
// behavior by running it in a thread.
@@ -170,7 +165,6 @@ static bool shGetFileInfoBackground(QWindowsThreadPoolRunner &r,
}
return result;
}
-#endif // !QT_NO_WINCE_SHELLSDK
// from QStyle::standardPalette
static inline QPalette standardPalette()
@@ -281,14 +275,9 @@ static inline QPalette menuPalette(const QPalette &systemPalette)
result.setColor(QPalette::Active, QPalette::ButtonText, menuTextColor);
result.setColor(QPalette::Disabled, QPalette::WindowText, disabled);
result.setColor(QPalette::Disabled, QPalette::Text, disabled);
-#ifndef Q_OS_WINCE
const bool isFlat = booleanSystemParametersInfo(SPI_GETFLATMENU, false);
result.setColor(QPalette::Disabled, QPalette::Highlight,
getSysColor(isFlat ? COLOR_MENUHILIGHT : COLOR_HIGHLIGHT));
-#else
- result.setColor(QPalette::Disabled, QPalette::Highlight,
- getSysColor(COLOR_HIGHLIGHT));
-#endif
result.setColor(QPalette::Disabled, QPalette::HighlightedText, disabled);
result.setColor(QPalette::Disabled, QPalette::Button,
result.color(QPalette::Active, QPalette::Button));
@@ -314,11 +303,7 @@ static inline QPalette *menuBarPalette(const QPalette &menuPalette)
QPalette *result = 0;
if (booleanSystemParametersInfo(SPI_GETFLATMENU, false)) {
result = new QPalette(menuPalette);
-#ifndef Q_OS_WINCE
const QColor menubar(getSysColor(COLOR_MENUBAR));
-#else
- const QColor menubar(getSysColor(COLOR_MENU));
-#endif
result->setColor(QPalette::Active, QPalette::Button, menubar);
result->setColor(QPalette::Disabled, QPalette::Button, menubar);
result->setColor(QPalette::Inactive, QPalette::Button, menubar);
@@ -330,6 +315,7 @@ const char *QWindowsTheme::name = "windows";
QWindowsTheme *QWindowsTheme::m_instance = 0;
QWindowsTheme::QWindowsTheme()
+ : m_threadPoolRunner(new QWindowsThreadPoolRunner)
{
m_instance = this;
std::fill(m_fonts, m_fonts + NFonts, static_cast<QFont *>(0));
@@ -364,7 +350,7 @@ static inline QStringList styleNames()
static inline int uiEffects()
{
- int result = 0;
+ int result = QPlatformTheme::HoverEffect;
if (booleanSystemParametersInfo(SPI_GETUIEFFECTS, false))
result |= QPlatformTheme::GeneralUiEffect;
if (booleanSystemParametersInfo(SPI_GETMENUANIMATION, false))
@@ -389,12 +375,10 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const
return QVariant(iconThemeSearchPaths());
case StyleNames:
return QVariant(styleNames());
-#ifndef Q_OS_WINCE
case TextCursorWidth:
return QVariant(int(dWordSystemParametersInfo(SPI_GETCARETWIDTH, 1u)));
case DropShadow:
return QVariant(booleanSystemParametersInfo(SPI_GETDROPSHADOW, false));
-#endif // !Q_OS_WINCE
case MaximumScrollBarDragDistance:
return QVariant(qRound(qreal(QWindowsContext::instance()->defaultDPI()) * 1.375));
case KeyboardScheme:
@@ -402,7 +386,7 @@ QVariant QWindowsTheme::themeHint(ThemeHint hint) const
case UiEffects:
return QVariant(uiEffects());
case IconPixmapSizes:
- return m_fileIconSizes;
+ return QVariant::fromValue(m_fileIconSizes);
case DialogSnapToDefaultButton:
return QVariant(booleanSystemParametersInfo(SPI_GETSNAPTODEFBUTTON, false));
case ContextMenuOnMouseRelease:
@@ -445,7 +429,6 @@ void QWindowsTheme::clearFonts()
void QWindowsTheme::refreshFonts()
{
-#ifndef Q_OS_WINCE // ALL THIS FUNCTIONALITY IS MISSING ON WINCE
clearFonts();
if (!QGuiApplication::desktopSettingsAware())
return;
@@ -474,7 +457,6 @@ void QWindowsTheme::refreshFonts()
m_fonts[DockWidgetTitleFont] = new QFont(titleFont);
m_fonts[ItemViewFont] = new QFont(iconTitleFont);
m_fonts[FixedFont] = new QFont(fixedFont);
-#endif // !Q_OS_WINCE
}
enum FileIconSize {
@@ -512,15 +494,14 @@ void QWindowsTheme::refreshIconPixmapSizes()
fileIconSizes[ExtraLargeFileIcon] =
fileIconSizes[LargeFileIcon] + fileIconSizes[LargeFileIcon] / 2;
fileIconSizes[JumboFileIcon] = 8 * fileIconSizes[LargeFileIcon]; // empirical, has not been observed to work
- QList<int> sizes;
- sizes << fileIconSizes[SmallFileIcon] << fileIconSizes[LargeFileIcon];
+
#ifdef USE_IIMAGELIST
- sizes << fileIconSizes[ExtraLargeFileIcon]; // sHIL_EXTRALARGE
- if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)
- sizes << fileIconSizes[JumboFileIcon]; // SHIL_JUMBO
+ int *availEnd = fileIconSizes + JumboFileIcon + 1;
+#else
+ int *availEnd = fileIconSizes + LargeFileIcon + 1;
#endif // USE_IIMAGELIST
- qCDebug(lcQpaWindows) << __FUNCTION__ << sizes;
- m_fileIconSizes = QVariant::fromValue(sizes);
+ m_fileIconSizes = QAbstractFileIconEngine::toSizeList(fileIconSizes, availEnd);
+ qCDebug(lcQpaWindows) << __FUNCTION__ << m_fileIconSizes;
}
// Defined in qpixmap_win.cpp
@@ -528,12 +509,7 @@ Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon);
static QPixmap loadIconFromShell32(int resourceId, QSizeF size)
{
-#ifdef Q_OS_WINCE
- HMODULE hmod = LoadLibrary(L"ceshell");
-#else
- HMODULE hmod = QSystemLibrary::load(L"shell32");
-#endif
- if (hmod) {
+ if (const HMODULE hmod = QSystemLibrary::load(L"shell32")) {
HICON iconHandle =
static_cast<HICON>(LoadImage(hmod, MAKEINTRESOURCE(resourceId),
IMAGE_ICON, int(size.width()), int(size.height()), 0));
@@ -549,7 +525,7 @@ static QPixmap loadIconFromShell32(int resourceId, QSizeF size)
QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &pixmapSize) const
{
int resourceId = -1;
- int stockId = SIID_INVALID;
+ SHSTOCKICONID stockId = SIID_INVALID;
UINT stockFlags = 0;
LPCTSTR iconName = 0;
switch (sp) {
@@ -612,7 +588,6 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &pixmapSiz
stockId = SIID_RECYCLER;
resourceId = 191;
break;
-#ifndef Q_OS_WINCE
case MessageBoxInformation:
stockId = SIID_INFO;
iconName = IDI_INFORMATION;
@@ -632,29 +607,22 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &pixmapSiz
case VistaShield:
stockId = SIID_SHIELD;
break;
-#endif
default:
break;
}
-#ifndef Q_OS_WINCE
if (stockId != SIID_INVALID) {
- if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
- && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)
- && QWindowsContext::shell32dll.sHGetStockIconInfo) {
- QPixmap pixmap;
- SHSTOCKICONINFO iconInfo;
- memset(&iconInfo, 0, sizeof(iconInfo));
- iconInfo.cbSize = sizeof(iconInfo);
- stockFlags |= (pixmapSize.width() > 16 ? SHGFI_LARGEICON : SHGFI_SMALLICON);
- if (QWindowsContext::shell32dll.sHGetStockIconInfo(stockId, SHGFI_ICON | stockFlags, &iconInfo) == S_OK) {
- pixmap = qt_pixmapFromWinHICON(iconInfo.hIcon);
- DestroyIcon(iconInfo.hIcon);
- return pixmap;
- }
+ QPixmap pixmap;
+ SHSTOCKICONINFO iconInfo;
+ memset(&iconInfo, 0, sizeof(iconInfo));
+ iconInfo.cbSize = sizeof(iconInfo);
+ stockFlags |= (pixmapSize.width() > 16 ? SHGFI_LARGEICON : SHGFI_SMALLICON);
+ if (SHGetStockIconInfo(stockId, SHGFI_ICON | stockFlags, &iconInfo) == S_OK) {
+ pixmap = qt_pixmapFromWinHICON(iconInfo.hIcon);
+ DestroyIcon(iconInfo.hIcon);
+ return pixmap;
}
}
-#endif
if (resourceId != -1) {
QPixmap pixmap = loadIconFromShell32(resourceId, pixmapSize);
@@ -729,14 +697,8 @@ static QPixmap pixmapFromShellImageList(int iImageList, const SHFILEINFO &info)
// For MinGW:
static const IID iID_IImageList = {0x46eb5926, 0x582e, 0x4017, {0x9f, 0xdf, 0xe8, 0x99, 0x8d, 0xaa, 0x9, 0x50}};
- if (!QWindowsContext::shell32dll.sHGetImageList)
- return result;
- if (iImageList == sHIL_JUMBO && QSysInfo::WindowsVersion < QSysInfo::WV_VISTA)
- return result;
-
IImageList *imageList = 0;
- HRESULT hr = QWindowsContext::shell32dll.sHGetImageList(iImageList, iID_IImageList,
- reinterpret_cast<void **>(&imageList));
+ HRESULT hr = SHGetImageList(iImageList, iID_IImageList, reinterpret_cast<void **>(&imageList));
if (hr != S_OK)
return result;
HICON hIcon;
@@ -753,8 +715,46 @@ static QPixmap pixmapFromShellImageList(int iImageList, const SHFILEINFO &info)
return result;
}
-QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size,
- QPlatformTheme::IconOptions iconOptions) const
+class QWindowsFileIconEngine : public QAbstractFileIconEngine
+{
+public:
+ explicit QWindowsFileIconEngine(const QFileInfo &info,
+ QPlatformTheme::IconOptions opts,
+ const QSharedPointer<QWindowsThreadPoolRunner> &runner) :
+ QAbstractFileIconEngine(info, opts), m_threadPoolRunner(runner) {}
+
+ QList<QSize> availableSizes(QIcon::Mode = QIcon::Normal, QIcon::State = QIcon::Off) const override
+ { return QWindowsTheme::instance()->availableFileIconSizes(); }
+
+protected:
+ QString cacheKey() const override;
+ QPixmap filePixmap(const QSize &size, QIcon::Mode mode, QIcon::State) override;
+
+private:
+ const QSharedPointer<QWindowsThreadPoolRunner> m_threadPoolRunner;
+};
+
+QString QWindowsFileIconEngine::cacheKey() const
+{
+ // Cache directories unless custom or drives, which have custom icons depending on type
+ if ((options() & QPlatformTheme::DontUseCustomDirectoryIcons) && fileInfo().isDir() && !fileInfo().isRoot())
+ return QStringLiteral("qt_/directory/");
+ if (!fileInfo().isFile())
+ return QString();
+ // Return "" for .exe, .lnk and .ico extensions.
+ // It is faster to just look at the file extensions;
+ // avoiding slow QFileInfo::isExecutable() (QTBUG-13182)
+ const QString &suffix = fileInfo().suffix();
+ if (!suffix.compare(QLatin1String("exe"), Qt::CaseInsensitive)
+ || !suffix.compare(QLatin1String("lnk"), Qt::CaseInsensitive)
+ || !suffix.compare(QLatin1String("ico"), Qt::CaseInsensitive)) {
+ return QString();
+ }
+ return QLatin1String("qt_.")
+ + (suffix.isEmpty() ? fileInfo().fileName() : suffix.toUpper()); // handle "Makefile" ;)
+}
+
+QPixmap QWindowsFileIconEngine::filePixmap(const QSize &size, QIcon::Mode, QIcon::State)
{
/* We don't use the variable, but by storing it statically, we
* ensure CoInitialize is only called once. */
@@ -764,10 +764,10 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s
static QCache<QString, FakePointer<int> > dirIconEntryCache(1000);
static QMutex mx;
static int defaultFolderIIcon = -1;
- const bool useDefaultFolderIcon = iconOptions & QPlatformTheme::DontUseCustomDirectoryIcons;
+ const bool useDefaultFolderIcon = options() & QPlatformTheme::DontUseCustomDirectoryIcons;
QPixmap pixmap;
- const QString filePath = QDir::toNativeSeparators(fileInfo.filePath());
+ const QString filePath = QDir::toNativeSeparators(fileInfo().filePath());
const int width = int(size.width());
const int iconSize = width > fileIconSizes[SmallFileIcon] ? SHGFI_LARGEICON : SHGFI_SMALLICON;
const int requestedImageListSize =
@@ -778,7 +778,7 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s
#else
0;
#endif // !USE_IIMAGELIST
- bool cacheableDirIcon = fileInfo.isDir() && !fileInfo.isRoot();
+ bool cacheableDirIcon = fileInfo().isDir() && !fileInfo().isRoot();
if (cacheableDirIcon) {
QMutexLocker locker(&mx);
int iIcon = (useDefaultFolderIcon && defaultFolderIIcon >= 0) ? defaultFolderIIcon
@@ -794,22 +794,13 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s
SHFILEINFO info;
const unsigned int flags =
-#ifndef Q_OS_WINCE
SHGFI_ICON|iconSize|SHGFI_SYSICONINDEX|SHGFI_ADDOVERLAYS|SHGFI_OVERLAYINDEX;
-#else
- iconSize|SHGFI_SYSICONINDEX;
-#endif // Q_OS_WINCE
-
-#if !defined(QT_NO_WINCE_SHELLSDK)
const bool val = cacheableDirIcon && useDefaultFolderIcon
- ? shGetFileInfoBackground(m_threadPoolRunner, L"dummy", FILE_ATTRIBUTE_DIRECTORY,
+ ? shGetFileInfoBackground(*m_threadPoolRunner.data(), L"dummy", FILE_ATTRIBUTE_DIRECTORY,
&info, flags | SHGFI_USEFILEATTRIBUTES)
- : shGetFileInfoBackground(m_threadPoolRunner, reinterpret_cast<const wchar_t *>(filePath.utf16()), 0,
+ : shGetFileInfoBackground(*m_threadPoolRunner.data(), reinterpret_cast<const wchar_t *>(filePath.utf16()), 0,
&info, flags);
-#else
- const bool val = false;
-#endif // !QT_NO_WINCE_SHELLSDK
// Even if GetFileInfo returns a valid result, hIcon can be empty in some cases
if (val && info.hIcon) {
@@ -848,9 +839,12 @@ QPixmap QWindowsTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &s
DestroyIcon(info.hIcon);
}
- if (!pixmap.isNull())
- return pixmap;
- return QPlatformTheme::fileIconPixmap(fileInfo, size);
+ return pixmap;
+}
+
+QIcon QWindowsTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions) const
+{
+ return QIcon(new QWindowsFileIconEngine(fileInfo, iconOptions, m_threadPoolRunner));
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowstheme.h b/src/plugins/platforms/windows/qwindowstheme.h
index fa1fb4d998..0384899efa 100644
--- a/src/plugins/platforms/windows/qwindowstheme.h
+++ b/src/plugins/platforms/windows/qwindowstheme.h
@@ -43,6 +43,7 @@
#include "qwindowsthreadpoolrunner.h"
#include <qpa/qplatformtheme.h>
+#include <QtCore/QSharedPointer>
#include <QtCore/QVariant>
QT_BEGIN_NAMESPACE
@@ -66,12 +67,14 @@ public:
{ return m_fonts[type]; }
QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const Q_DECL_OVERRIDE;
- QPixmap fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &size,
- QPlatformTheme::IconOptions iconOptions = 0) const Q_DECL_OVERRIDE;
+
+ QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions = 0) const override;
void windowsThemeChanged(QWindow *window);
void displayChanged() { refreshIconPixmapSizes(); }
+ QList<QSize> availableFileIconSizes() const { return m_fileIconSizes; }
+
static const char *name;
private:
@@ -85,8 +88,8 @@ private:
static QWindowsTheme *m_instance;
QPalette *m_palettes[NPalettes];
QFont *m_fonts[NFonts];
- mutable QWindowsThreadPoolRunner m_threadPoolRunner;
- QVariant m_fileIconSizes;
+ const QSharedPointer<QWindowsThreadPoolRunner> m_threadPoolRunner;
+ QList<QSize> m_fileIconSizes;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 434d0ad953..7289f8de6d 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -62,6 +62,8 @@
#include <QtCore/QDebug>
+#include <dwmapi.h>
+
QT_BEGIN_NAMESPACE
enum {
@@ -147,7 +149,6 @@ QDebug operator<<(QDebug d, const POINT &p)
return d;
}
-# ifndef Q_OS_WINCE
QDebug operator<<(QDebug d, const NCCALCSIZE_PARAMS &p)
{
QDebugStateSaver saver(d);
@@ -178,14 +179,12 @@ QDebug operator<<(QDebug d, const WINDOWPLACEMENT &wp)
<< ", rcNormalPosition=" << wp.rcNormalPosition;
return d;
}
-# endif // !Q_OS_WINCE
#endif // !QT_NO_DEBUG_STREAM
// QTBUG-43872, for windows that do not have WS_EX_TOOLWINDOW set, WINDOWPLACEMENT
// is in workspace/available area coordinates.
static QPoint windowPlacementOffset(HWND hwnd, const QPoint &point)
{
-#ifndef Q_OS_WINCE
if (GetWindowLongPtr(hwnd, GWL_EXSTYLE) & WS_EX_TOOLWINDOW)
return QPoint(0, 0);
const QWindowsScreenManager &screenManager = QWindowsContext::instance()->screenManager();
@@ -193,10 +192,6 @@ static QPoint windowPlacementOffset(HWND hwnd, const QPoint &point)
? screenManager.screens().constFirst() : screenManager.screenAtDp(point);
if (screen)
return screen->availableGeometry().topLeft() - screen->geometry().topLeft();
-#else
- Q_UNUSED(hwnd)
- Q_UNUSED(point)
-#endif
return QPoint(0, 0);
}
@@ -205,7 +200,6 @@ static QPoint windowPlacementOffset(HWND hwnd, const QPoint &point)
static inline QRect frameGeometry(HWND hwnd, bool topLevel)
{
RECT rect = { 0, 0, 0, 0 };
-#ifndef Q_OS_WINCE
if (topLevel) {
WINDOWPLACEMENT windowPlacement;
windowPlacement.length = sizeof(WINDOWPLACEMENT);
@@ -215,7 +209,6 @@ static inline QRect frameGeometry(HWND hwnd, bool topLevel)
return result.translated(windowPlacementOffset(hwnd, result.topLeft()));
}
}
-#endif // !Q_OS_WINCE
GetWindowRect(hwnd, &rect); // Screen coordinates.
const HWND parent = GetParent(hwnd);
if (parent && !topLevel) {
@@ -236,7 +229,6 @@ static QWindow::Visibility windowVisibility_sys(HWND hwnd)
{
if (!IsWindowVisible(hwnd))
return QWindow::Hidden;
-#ifndef Q_OS_WINCE
WINDOWPLACEMENT windowPlacement;
windowPlacement.length = sizeof(WINDOWPLACEMENT);
if (GetWindowPlacement(hwnd, &windowPlacement)) {
@@ -251,7 +243,6 @@ static QWindow::Visibility windowVisibility_sys(HWND hwnd)
break;
}
}
-#endif // !Q_OS_WINCE
return QWindow::Windowed;
}
@@ -269,65 +260,27 @@ static inline bool windowIsOpenGL(const QWindow *w)
static bool applyBlurBehindWindow(HWND hwnd)
{
-#ifdef Q_OS_WINCE
- Q_UNUSED(hwnd);
- return false;
-#else
- enum { dwmBbEnable = 0x1, dwmBbBlurRegion = 0x2 };
-
- struct DwmBlurBehind {
- DWORD dwFlags;
- BOOL fEnable;
- HRGN hRgnBlur;
- BOOL fTransitionOnMaximized;
- };
-
- typedef HRESULT (WINAPI *PtrDwmEnableBlurBehindWindow)(HWND, const DwmBlurBehind*);
- typedef HRESULT (WINAPI *PtrDwmIsCompositionEnabled)(BOOL *);
-
- // DWM API is available only from Windows Vista
- if (QSysInfo::windowsVersion() < QSysInfo::WV_VISTA)
- return false;
-
- static bool functionPointersResolved = false;
- static PtrDwmEnableBlurBehindWindow dwmBlurBehind = 0;
- static PtrDwmIsCompositionEnabled dwmIsCompositionEnabled = 0;
-
- if (Q_UNLIKELY(!functionPointersResolved)) {
- QSystemLibrary library(QStringLiteral("dwmapi"));
- if (library.load()) {
- dwmBlurBehind = (PtrDwmEnableBlurBehindWindow)(library.resolve("DwmEnableBlurBehindWindow"));
- dwmIsCompositionEnabled = (PtrDwmIsCompositionEnabled)(library.resolve("DwmIsCompositionEnabled"));
- }
-
- functionPointersResolved = true;
- }
-
- if (Q_UNLIKELY(!dwmBlurBehind || !dwmIsCompositionEnabled))
- return false;
-
BOOL compositionEnabled;
- if (dwmIsCompositionEnabled(&compositionEnabled) != S_OK)
+ if (DwmIsCompositionEnabled(&compositionEnabled) != S_OK)
return false;
- DwmBlurBehind blurBehind = {0, 0, 0, 0};
+ DWM_BLURBEHIND blurBehind = {0, 0, 0, 0};
if (compositionEnabled) {
- blurBehind.dwFlags = dwmBbEnable | dwmBbBlurRegion;
+ blurBehind.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION;
blurBehind.fEnable = TRUE;
blurBehind.hRgnBlur = CreateRectRgn(0, 0, -1, -1);
} else {
- blurBehind.dwFlags = dwmBbEnable;
+ blurBehind.dwFlags = DWM_BB_ENABLE;
blurBehind.fEnable = FALSE;
}
- const bool result = dwmBlurBehind(hwnd, &blurBehind) == S_OK;
+ const bool result = DwmEnableBlurBehindWindow(hwnd, &blurBehind) == S_OK;
if (blurBehind.hRgnBlur)
DeleteObject(blurBehind.hRgnBlur);
return result;
-#endif // Q_OS_WINCE
}
// from qwidget_win.cpp, pass flags separately in case they have been "autofixed".
@@ -346,7 +299,6 @@ static bool shouldShowMaximizeButton(const QWindow *w, Qt::WindowFlags flags)
// Qt::WindowTransparentForInput (in combination with WS_EX_TRANSPARENT).
bool QWindowsWindow::setWindowLayered(HWND hwnd, Qt::WindowFlags flags, bool hasAlpha, qreal opacity)
{
-#ifndef Q_OS_WINCE // maybe needs revisiting WS_EX_LAYERED
const LONG exStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
const bool needsLayered = (flags & Qt::WindowTransparentForInput)
|| (hasAlpha && (flags & Qt::FramelessWindowHint)) || opacity < 1.0;
@@ -359,36 +311,22 @@ bool QWindowsWindow::setWindowLayered(HWND hwnd, Qt::WindowFlags flags, bool has
}
}
return needsLayered;
-#else // !Q_OS_WINCE
- Q_UNUSED(hwnd);
- Q_UNUSED(flags);
- Q_UNUSED(hasAlpha);
- Q_UNUSED(opacity);
- return false;
-#endif // Q_OS_WINCE
}
static void setWindowOpacity(HWND hwnd, Qt::WindowFlags flags, bool hasAlpha, bool openGL, qreal level)
{
-#ifdef Q_OS_WINCE // WINCE does not support that feature and microsoft explicitly warns to use those calls
- Q_UNUSED(hwnd);
- Q_UNUSED(flags);
- Q_UNUSED(hasAlpha);
- Q_UNUSED(level);
-#else
if (QWindowsWindow::setWindowLayered(hwnd, flags, hasAlpha, level)) {
const BYTE alpha = BYTE(qRound(255.0 * level));
if (hasAlpha && !openGL && (flags & Qt::FramelessWindowHint)) {
// Non-GL windows with alpha: Use blend function to update.
BLENDFUNCTION blend = {AC_SRC_OVER, 0, alpha, AC_SRC_ALPHA};
- QWindowsContext::user32dll.updateLayeredWindow(hwnd, NULL, NULL, NULL, NULL, NULL, 0, &blend, ULW_ALPHA);
+ UpdateLayeredWindow(hwnd, NULL, NULL, NULL, NULL, NULL, 0, &blend, ULW_ALPHA);
} else {
- QWindowsContext::user32dll.setLayeredWindowAttributes(hwnd, 0, alpha, LWA_ALPHA);
+ SetLayeredWindowAttributes(hwnd, 0, alpha, LWA_ALPHA);
}
} else if (IsWindowVisible(hwnd)) { // Repaint when switching from layered.
InvalidateRect(hwnd, NULL, TRUE);
}
-#endif // !Q_OS_WINCE
}
static inline void updateGLWindowSettings(const QWindow *w, HWND hwnd, Qt::WindowFlags flags, qreal opacity)
@@ -604,12 +542,10 @@ void WindowCreationData::fromWindow(const QWindow *w, const Qt::WindowFlags flag
exStyle |= WS_EX_TOOLWINDOW;
}
-#ifndef Q_OS_WINCE
// make mouse events fall through this window
// NOTE: WS_EX_TRANSPARENT flag can make mouse inputs fall through a layered window
if (flagsIn & Qt::WindowTransparentForInput)
exStyle |= WS_EX_LAYERED | WS_EX_TRANSPARENT;
-#endif
}
}
@@ -650,10 +586,6 @@ QWindowsWindowData
context->frameX, context->frameY,
context->frameWidth, context->frameHeight,
parentHandle, NULL, appinst, NULL);
-#ifdef Q_OS_WINCE
- if (DisableGestures(result.hwnd, TGF_GID_ALL, TGF_SCOPE_WINDOW))
- EnableGestures(result.hwnd, TGF_GID_DIRECTMANIPULATION, TGF_SCOPE_WINDOW);
-#endif
qCDebug(lcQpaWindows).nospace()
<< "CreateWindowEx: returns " << w << ' ' << result.hwnd << " obtained geometry: "
<< context->obtainedGeometry << ' ' << context->margins;
@@ -764,9 +696,7 @@ bool QWindowsGeometryHint::validSize(const QSize &s) const
QMargins QWindowsGeometryHint::frame(DWORD style, DWORD exStyle)
{
RECT rect = {0,0,0,0};
-#ifndef Q_OS_WINCE
style &= ~(WS_OVERLAPPED); // Not permitted, see docs.
-#endif
if (!AdjustWindowRectEx(&rect, style, FALSE, exStyle))
qErrnoWarning("%s: AdjustWindowRectEx failed", __FUNCTION__);
const QMargins result(qAbs(rect.left), qAbs(rect.top),
@@ -779,7 +709,6 @@ QMargins QWindowsGeometryHint::frame(DWORD style, DWORD exStyle)
bool QWindowsGeometryHint::handleCalculateSize(const QMargins &customMargins, const MSG &msg, LRESULT *result)
{
-#ifndef Q_OS_WINCE
// NCCALCSIZE_PARAMS structure if wParam==TRUE
if (!msg.wParam || customMargins.isNull())
return false;
@@ -795,15 +724,8 @@ bool QWindowsGeometryHint::handleCalculateSize(const QMargins &customMargins, co
<< ncp->rgrc[0] << ' ' << ncp->rgrc[1] << ' ' << ncp->rgrc[2]
<< ' ' << ncp->lppos->cx << ',' << ncp->lppos->cy;
return true;
-#else
- Q_UNUSED(customMargins)
- Q_UNUSED(msg)
- Q_UNUSED(result)
- return false;
-#endif
}
-#ifndef Q_OS_WINCE
void QWindowsGeometryHint::applyToMinMaxInfo(HWND hwnd, MINMAXINFO *mmi) const
{
return applyToMinMaxInfo(DWORD(GetWindowLong(hwnd, GWL_STYLE)),
@@ -835,7 +757,6 @@ void QWindowsGeometryHint::applyToMinMaxInfo(DWORD style, DWORD exStyle, MINMAXI
<< " frame=" << margins << ' ' << frameWidth << ',' << frameHeight
<< " out " << *mmi;
}
-#endif // !Q_OS_WINCE
bool QWindowsGeometryHint::positionIncludesFrame(const QWindow *w)
{
@@ -1080,9 +1001,6 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data)
m_dropTarget(0),
m_savedStyle(0),
m_format(aWindow->requestedFormat()),
-#ifdef Q_OS_WINCE
- m_previouslyHidden(false),
-#endif
m_iconSmall(0),
m_iconBig(0),
m_surface(0)
@@ -1116,10 +1034,8 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data)
QWindowsWindow::~QWindowsWindow()
{
setFlag(WithinDestroy);
-#ifndef Q_OS_WINCE
if (testFlag(TouchRegistered))
QWindowsContext::user32dll.unregisterTouchWindow(m_data.hwnd);
-#endif // !Q_OS_WINCE
destroyWindow();
destroyIcon();
}
@@ -1163,14 +1079,6 @@ void QWindowsWindow::destroyWindow()
m_surface = 0;
}
#endif
-#ifdef Q_OS_WINCE
- if ((m_windowState & Qt::WindowFullScreen) && !m_previouslyHidden) {
- HWND handle = FindWindow(L"HHTaskBar", L"");
- if (handle) {
- ShowWindow(handle, SW_SHOW);
- }
- }
-#endif // !Q_OS_WINCE
DestroyWindow(m_data.hwnd);
context->removeWindow(m_data.hwnd);
m_data.hwnd = 0;
@@ -1338,7 +1246,6 @@ QPoint QWindowsWindow::mapFromGlobal(const QPoint &pos) const
return pos;
}
-#ifndef Q_OS_WINCE
static inline HWND transientParentHwnd(HWND hwnd)
{
if (GetAncestor(hwnd, GA_PARENT) == GetDesktopWindow()) {
@@ -1348,15 +1255,18 @@ static inline HWND transientParentHwnd(HWND hwnd)
}
return 0;
}
-#endif // !Q_OS_WINCE
// Update the transient parent for a toplevel window. The concept does not
// really exist on Windows, the relationship is set by passing a parent along with !WS_CHILD
// to window creation or by setting the parent using GWL_HWNDPARENT (as opposed to
// SetParent, which would make it a real child).
+
+#ifndef GWL_HWNDPARENT
+# define GWL_HWNDPARENT (-8)
+#endif
+
void QWindowsWindow::updateTransientParent() const
{
-#ifndef Q_OS_WINCE
if (window()->type() == Qt::Popup)
return; // QTBUG-34503, // a popup stays on top, no parent, see also WindowCreationData::fromWindow().
// Update transient parent.
@@ -1368,7 +1278,6 @@ void QWindowsWindow::updateTransientParent() const
newTransientParent = tw->handle();
if (newTransientParent != oldTransientParent)
SetWindowLongPtr(m_data.hwnd, GWL_HWNDPARENT, LONG_PTR(newTransientParent));
-#endif // !Q_OS_WINCE
}
static inline bool testShowWithoutActivating(const QWindow *window)
@@ -1486,16 +1395,12 @@ void QWindowsWindow::handleCompositionSettingsChanged()
static QRect normalFrameGeometry(HWND hwnd)
{
-#ifndef Q_OS_WINCE
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
if (GetWindowPlacement(hwnd, &wp)) {
const QRect result = qrectFromRECT(wp.rcNormalPosition);
return result.translated(windowPlacementOffset(hwnd, result.topLeft()));
}
-#else
- Q_UNUSED(hwnd)
-#endif
return QRect();
}
@@ -1615,7 +1520,6 @@ void QWindowsBaseWindow::setGeometry_sys(const QRect &rect) const
<< " new frame: " << frameGeometry;
bool result = false;
-#ifndef Q_OS_WINCE
const HWND hwnd = handle();
WINDOWPLACEMENT windowPlacement;
windowPlacement.length = sizeof(WINDOWPLACEMENT);
@@ -1628,9 +1532,7 @@ void QWindowsBaseWindow::setGeometry_sys(const QRect &rect) const
RECTfromQRect(frameGeometry.translated(-windowPlacementOffset(hwnd, frameGeometry.topLeft())));
windowPlacement.showCmd = windowPlacement.showCmd == SW_SHOWMINIMIZED ? SW_SHOWMINIMIZED : SW_HIDE;
result = SetWindowPlacement(hwnd, &windowPlacement);
- } else
-#endif // !Q_OS_WINCE
- {
+ } else {
result = MoveWindow(hwnd, frameGeometry.x(), frameGeometry.y(),
frameGeometry.width(), frameGeometry.height(), true);
}
@@ -1667,6 +1569,12 @@ void QWindowsWindow::releaseDC()
}
}
+static inline bool dwmIsCompositionEnabled()
+{
+ BOOL dWmCompositionEnabled = FALSE;
+ return SUCCEEDED(DwmIsCompositionEnabled(&dWmCompositionEnabled)) && dWmCompositionEnabled == TRUE;
+}
+
bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message,
WPARAM, LPARAM)
{
@@ -1680,8 +1588,7 @@ bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message,
BeginPaint(hwnd, &ps);
// Observed painting problems with Aero style disabled (QTBUG-7865).
- // 5.8: Consider making it dependent on !DwmIsCompositionEnabled().
- if (testFlag(OpenGLSurface) && testFlag(OpenGLDoubleBuffered))
+ if (Q_UNLIKELY(testFlag(OpenGLSurface) && testFlag(OpenGLDoubleBuffered) && !dwmIsCompositionEnabled()))
SelectClipRgn(ps.hdc, NULL);
// If the a window is obscured by another window (such as a child window)
@@ -1823,18 +1730,6 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
setFlag(FrameDirty);
if ((oldState == Qt::WindowFullScreen) != (newState == Qt::WindowFullScreen)) {
-#ifdef Q_OS_WINCE
- HWND handle = FindWindow(L"HHTaskBar", L"");
- if (handle) {
- if (newState == Qt::WindowFullScreen) {
- BOOL hidden = ShowWindow(handle, SW_HIDE);
- if (!hidden)
- m_previouslyHidden = true;
- } else if (!m_previouslyHidden){
- ShowWindow(handle, SW_SHOW);
- }
- }
-#endif
if (newState == Qt::WindowFullScreen) {
#ifndef Q_FLATTEN_EXPOSE
UINT newStyle = WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_POPUP;
@@ -1846,17 +1741,13 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
// Window state but emulated by changing geometry and style.
if (!m_savedStyle) {
m_savedStyle = style();
-#ifndef Q_OS_WINCE
if (oldState == Qt::WindowMinimized || oldState == Qt::WindowMaximized) {
const QRect nf = normalFrameGeometry(m_data.hwnd);
if (nf.isValid())
m_savedFrameGeometry = nf;
} else {
-#endif
m_savedFrameGeometry = frameGeometry_sys();
-#ifndef Q_OS_WINCE
}
-#endif
}
if (m_savedStyle & WS_SYSMENU)
newStyle |= WS_SYSMENU;
@@ -1969,7 +1860,6 @@ void QWindowsWindow::propagateSizeHints()
bool QWindowsWindow::handleGeometryChangingMessage(MSG *message, const QWindow *qWindow, const QMargins &margins)
{
-#ifndef Q_OS_WINCE
if (!qWindow->isTopLevel()) // Implement hasHeightForWidth().
return false;
WINDOWPOS *windowPos = reinterpret_cast<WINDOWPOS *>(message->lParam);
@@ -1989,10 +1879,6 @@ bool QWindowsWindow::handleGeometryChangingMessage(MSG *message, const QWindow *
windowPos->cx = correctedFrameGeometry.width();
windowPos->cy = correctedFrameGeometry.height();
return true;
-#else // !Q_OS_WINCE
- Q_UNUSED(message)
- return false;
-#endif
}
bool QWindowsWindow::handleGeometryChanging(MSG *message) const
@@ -2050,15 +1936,13 @@ static inline void addRectToWinRegion(const QRect &rect, HRGN *winRegion)
static HRGN qRegionToWinRegion(const QRegion &region)
{
- const QVector<QRect> rects = region.rects();
- if (rects.isEmpty())
- return NULL;
- const int rectCount = rects.size();
- if (rectCount == 1)
- return createRectRegion(region.boundingRect());
- HRGN hRegion = createRectRegion(rects.front());
- for (int i = 1; i < rectCount; ++i)
- addRectToWinRegion(rects.at(i), &hRegion);
+ auto it = region.begin();
+ const auto end = region.end();
+ if (it == end)
+ return nullptr;
+ HRGN hRegion = createRectRegion(*it);
+ while (++it != end)
+ addRectToWinRegion(*it, &hRegion);
return hRegion;
}
@@ -2087,7 +1971,6 @@ void QWindowsWindow::requestActivateWindow()
// 'Active' state handling is based in focus since it needs to work for
// child windows as well.
if (m_data.hwnd) {
-#ifndef Q_OS_WINCE
const DWORD currentThread = GetCurrentThreadId();
bool attached = false;
DWORD foregroundThread = 0;
@@ -2104,13 +1987,10 @@ void QWindowsWindow::requestActivateWindow()
attached = AttachThreadInput(foregroundThread, currentThread, TRUE) == TRUE;
}
}
-#endif // !Q_OS_WINCE
SetForegroundWindow(m_data.hwnd);
SetFocus(m_data.hwnd);
-#ifndef Q_OS_WINCE
if (attached)
AttachThreadInput(foregroundThread, currentThread, FALSE);
-#endif // !Q_OS_WINCE
}
}
@@ -2192,7 +2072,6 @@ void QWindowsWindow::setFrameStrutEventsEnabled(bool enabled)
}
}
-#ifndef Q_OS_WINCE // maybe available on some SDKs revisit WM_GETMINMAXINFO
void QWindowsWindow::getSizeHints(MINMAXINFO *mmi) const
{
const QWindowsGeometryHint hint(window(), m_data.customMargins);
@@ -2263,8 +2142,6 @@ bool QWindowsWindow::handleNonClientHitTest(const QPoint &globalPos, LRESULT *re
return false;
}
-#endif // !Q_OS_WINCE
-
#ifndef QT_NO_CURSOR
// Return the default cursor (Arrow) from QWindowsCursor's cache.
static inline CursorHandlePtr defaultCursor(const QWindow *w)
@@ -2331,7 +2208,6 @@ void QWindowsWindow::setCursor(const CursorHandlePtr &c)
#endif
}
-#ifndef Q_OS_WINCE
void QWindowsWindow::setAlertState(bool enabled)
{
if (isAlertState() == enabled)
@@ -2370,7 +2246,6 @@ void QWindowsWindow::stopAlertWindow()
info.uCount = 0;
FlashWindowEx(&info);
}
-#endif // !Q_OS_WINCE
bool QWindowsWindow::isEnabled() const
{
@@ -2486,7 +2361,6 @@ void QWindowsWindow::setTouchWindowTouchTypeStatic(QWindow *window, QWindowsWind
void QWindowsWindow::registerTouchWindow(QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes)
{
-#ifndef Q_OS_WINCE
if ((QWindowsContext::instance()->systemInfo() & QWindowsContext::SI_SupportsTouch)) {
ULONG touchFlags = 0;
const bool ret = QWindowsContext::user32dll.isTouchWindow(m_data.hwnd, &touchFlags);
@@ -2499,7 +2373,6 @@ void QWindowsWindow::registerTouchWindow(QWindowsWindowFunctions::TouchWindowTou
else
qErrnoWarning("RegisterTouchWindow() failed for window '%s'.", qPrintable(window()->objectName()));
}
-#endif // !Q_OS_WINCE
}
void QWindowsWindow::aboutToMakeCurrent()
diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h
index df7d2295a9..924f242e6e 100644
--- a/src/plugins/platforms/windows/qwindowswindow.h
+++ b/src/plugins/platforms/windows/qwindowswindow.h
@@ -40,10 +40,7 @@
#ifndef QWINDOWSWINDOW_H
#define QWINDOWSWINDOW_H
-#include "qtwindows_additional.h"
-#ifdef Q_OS_WINCE
-# include "qplatformfunctions_wince.h"
-#endif
+#include <QtCore/qt_windows.h>
#include "qwindowscursor.h"
#include <qpa/qplatformwindow.h>
@@ -60,10 +57,8 @@ struct QWindowsGeometryHint
explicit QWindowsGeometryHint(const QWindow *w, const QMargins &customMargins);
static QMargins frame(DWORD style, DWORD exStyle);
static bool handleCalculateSize(const QMargins &customMargins, const MSG &msg, LRESULT *result);
-#ifndef Q_OS_WINCE //MinMax maybe define struct if not available
void applyToMinMaxInfo(DWORD style, DWORD exStyle, MINMAXINFO *mmi) const;
void applyToMinMaxInfo(HWND hwnd, MINMAXINFO *mmi) const;
-#endif
bool validSize(const QSize &s) const;
static inline QPoint mapToGlobal(HWND hwnd, const QPoint &);
@@ -83,10 +78,8 @@ struct QWindowCreationContext
QWindowCreationContext(const QWindow *w, const QRect &r,
const QMargins &customMargins,
DWORD style, DWORD exStyle);
-#ifndef Q_OS_WINCE //MinMax maybe define struct if not available
void applyToMinMaxInfo(MINMAXINFO *mmi) const
{ geometryHint.applyToMinMaxInfo(style, exStyle, mmi); }
-#endif
QWindowsGeometryHint geometryHint;
const QWindow *window;
@@ -293,10 +286,8 @@ public:
HDC getDC();
void releaseDC();
-#ifndef Q_OS_WINCE // maybe available on some SDKs revisit WM_GETMINMAXINFO
void getSizeHints(MINMAXINFO *mmi) const;
bool handleNonClientHitTest(const QPoint &globalPos, LRESULT *result) const;
-#endif // !Q_OS_WINCE
#ifndef QT_NO_CURSOR
CursorHandlePtr cursor() const { return m_cursor; }
@@ -316,12 +307,10 @@ public:
void invalidateSurface() Q_DECL_OVERRIDE;
void aboutToMakeCurrent();
-#ifndef Q_OS_WINCE
void setAlertState(bool enabled) Q_DECL_OVERRIDE;
bool isAlertState() const Q_DECL_OVERRIDE { return testFlag(AlertState); }
void alertWindow(int durationMs = 0);
void stopAlertWindow();
-#endif
static void setTouchWindowTouchTypeStatic(QWindow *window, QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes);
void registerTouchWindow(QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes = QWindowsWindowFunctions::NormalTouch);
@@ -357,9 +346,6 @@ private:
unsigned m_savedStyle;
QRect m_savedFrameGeometry;
const QSurfaceFormat m_format;
-#ifdef Q_OS_WINCE
- bool m_previouslyHidden;
-#endif
HICON m_iconSmall;
HICON m_iconBig;
void *m_surface;
@@ -368,11 +354,9 @@ private:
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug d, const RECT &r);
QDebug operator<<(QDebug d, const POINT &);
-# ifndef Q_OS_WINCE
QDebug operator<<(QDebug d, const MINMAXINFO &i);
QDebug operator<<(QDebug d, const NCCALCSIZE_PARAMS &p);
QDebug operator<<(QDebug d, const WINDOWPLACEMENT &);
-# endif // !Q_OS_WINCE
#endif // !QT_NO_DEBUG_STREAM
// ---------- QWindowsGeometryHint inline functions.
@@ -436,11 +420,7 @@ inline void QWindowsWindow::destroyIcon()
inline bool QWindowsWindow::isLayered() const
{
-#ifndef Q_OS_WINCE
return GetWindowLongPtr(m_data.hwnd, GWL_EXSTYLE) & WS_EX_LAYERED;
-#else
- return false;
-#endif
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/windows.pri b/src/plugins/platforms/windows/windows.pri
index 48c53592d6..1cadcd1954 100644
--- a/src/plugins/platforms/windows/windows.pri
+++ b/src/plugins/platforms/windows/windows.pri
@@ -1,14 +1,11 @@
# Note: OpenGL32 must precede Gdi32 as it overwrites some functions.
-LIBS *= -lole32
-!wince: LIBS *= -luser32 -lwinspool -limm32 -lwinmm -loleaut32
+LIBS += -lole32 -luser32 -lwinspool -limm32 -lwinmm -loleaut32
contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles2):!contains(QT_CONFIG, dynamicgl): LIBS *= -lopengl32
mingw: LIBS *= -luuid
# For the dialog helpers:
-!wince: LIBS *= -lshlwapi -lshell32
-!wince: LIBS *= -ladvapi32
-wince: DEFINES *= QT_LIBINFIX=L"\"\\\"$${QT_LIBINFIX}\\\"\""
+LIBS += -lshlwapi -lshell32 -ladvapi32
DEFINES *= QT_NO_CAST_FROM_ASCII
@@ -53,7 +50,6 @@ HEADERS += \
$$PWD/qwindowsfontdatabase.h \
$$PWD/qwindowsmousehandler.h \
$$PWD/qtwindowsglobal.h \
- $$PWD/qtwindows_additional.h \
$$PWD/qwindowsole.h \
$$PWD/qwindowsmime.h \
$$PWD/qwindowsinternalmimedata.h \
@@ -62,7 +58,6 @@ HEADERS += \
$$PWD/qwindowstheme.h \
$$PWD/qwindowsdialoghelpers.h \
$$PWD/qwindowsservices.h \
- $$PWD/qplatformfunctions_wince.h \
$$PWD/qwindowsnativeimage.h \
$$PWD/qwindowsnativeinterface.h \
$$PWD/qwindowsopengltester.h \
@@ -101,37 +96,30 @@ contains(QT_CONFIG,dynamicgl) {
}
}
-!wince:!contains( DEFINES, QT_NO_TABLETEVENT ) {
+!contains( DEFINES, QT_NO_TABLETEVENT ) {
INCLUDEPATH += $$QT_SOURCE_TREE/src/3rdparty/wintab
HEADERS += $$PWD/qwindowstabletsupport.h
SOURCES += $$PWD/qwindowstabletsupport.cpp
}
-!wince:!contains( DEFINES, QT_NO_SESSIONMANAGER ) {
+!contains( DEFINES, QT_NO_SESSIONMANAGER ) {
SOURCES += $$PWD/qwindowssessionmanager.cpp
HEADERS += $$PWD/qwindowssessionmanager.h
}
-!wince:!contains( DEFINES, QT_NO_IMAGEFORMAT_PNG ) {
- RESOURCES += $$PWD/cursors.qrc
-}
+!contains( DEFINES, QT_NO_IMAGEFORMAT_PNG ):RESOURCES += $$PWD/cursors.qrc
-!wince: RESOURCES += $$PWD/openglblacklists.qrc
+RESOURCES += $$PWD/openglblacklists.qrc
contains(QT_CONFIG, freetype) {
- DEFINES *= QT_NO_FONTCONFIG
- include($$QT_SOURCE_TREE/src/3rdparty/freetype_dependency.pri)
- HEADERS += \
- $$PWD/qwindowsfontdatabase_ft.h
- SOURCES += \
- $$PWD/qwindowsfontdatabase_ft.cpp
-} else:contains(QT_CONFIG, system-freetype) {
- CONFIG += qpa/basicunixfontdatabase
- include($$QT_SOURCE_TREE/src/platformsupport/fontdatabases/basic/basic.pri)
- HEADERS += \
- $$PWD/qwindowsfontdatabase_ft.h
- SOURCES += \
- $$PWD/qwindowsfontdatabase_ft.cpp
+ HEADERS += $$PWD/qwindowsfontdatabase_ft.h
+ SOURCES += $$PWD/qwindowsfontdatabase_ft.cpp
+ contains(QT_CONFIG, system-freetype) {
+ include($$QT_SOURCE_TREE/src/platformsupport/fontdatabases/basic/basic.pri)
+ } else {
+ DEFINES *= QT_NO_FONTCONFIG
+ include($$QT_SOURCE_TREE/src/3rdparty/freetype_dependency.pri)
+ }
}
contains(QT_CONFIG, accessibility):include($$PWD/accessible/accessible.pri)
diff --git a/src/plugins/platforms/windows/windows.pro b/src/plugins/platforms/windows/windows.pro
index 2e0f723693..adafa830d5 100644
--- a/src/plugins/platforms/windows/windows.pro
+++ b/src/plugins/platforms/windows/windows.pro
@@ -4,7 +4,7 @@ QT *= core-private
QT *= gui-private
QT *= platformsupport-private
-!wince:LIBS *= -lgdi32
+LIBS += -lgdi32 -ldwmapi
include(windows.pri)
diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
index a999fb0aa2..130ae9be0c 100644
--- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp
+++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
@@ -223,14 +223,14 @@ bool QXcbShmImage::scroll(const QRegion &area, int dx, int dy)
preparePaint(area);
const QPoint delta(dx, dy);
- foreach (const QRect &rect, area.rects())
+ for (const QRect &rect : area)
qt_scrollRectInImage(*image(), rect, delta);
if (m_xcb_pixmap) {
flushPixmap(area);
ensureGC(m_xcb_pixmap);
const QRect bounds(QPoint(0, 0), size());
- foreach (const QRect &src, area.rects()) {
+ for (const QRect &src : area) {
const QRect dst = src.translated(delta).intersected(bounds);
Q_XCB_CALL(xcb_copy_area(xcb_connection(),
m_xcb_pixmap,
@@ -531,11 +531,9 @@ void QXcbBackingStore::beginPaint(const QRegion &region)
if (m_image->hasAlpha()) {
QPainter p(paintDevice());
p.setCompositionMode(QPainter::CompositionMode_Source);
- const QVector<QRect> rects = region.rects();
const QColor blank = Qt::transparent;
- for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
- p.fillRect(*it, blank);
- }
+ for (const QRect &rect : region)
+ p.fillRect(rect, blank);
}
}
@@ -555,22 +553,21 @@ void QXcbBackingStore::endPaint()
// Slow path: the paint device was m_rgbImage. Now copy with swapping red
// and blue into m_image.
- const QVector<QRect> rects = region.rects();
- if (rects.isEmpty())
+ auto it = region.begin();
+ const auto end = region.end();
+ if (it == end)
return;
QPainter p(m_image->image());
- for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
+ while (it != end) {
const QRect rect = *it;
p.drawImage(rect.topLeft(), m_rgbImage.copy(rect).rgbSwapped());
}
}
-#ifndef QT_NO_OPENGL
QImage QXcbBackingStore::toImage() const
{
return m_image && m_image->image() ? *m_image->image() : QImage();
}
-#endif
QPlatformGraphicsBuffer *QXcbBackingStore::graphicsBuffer() const
{
diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.h b/src/plugins/platforms/xcb/qxcbbackingstore.h
index 5a8f385c1b..6af679d28a 100644
--- a/src/plugins/platforms/xcb/qxcbbackingstore.h
+++ b/src/plugins/platforms/xcb/qxcbbackingstore.h
@@ -63,8 +63,8 @@ public:
void composeAndFlush(QWindow *window, const QRegion &region, const QPoint &offset,
QPlatformTextureList *textures, QOpenGLContext *context,
bool translucentBackground) Q_DECL_OVERRIDE;
- QImage toImage() const Q_DECL_OVERRIDE;
#endif
+ QImage toImage() const Q_DECL_OVERRIDE;
QPlatformGraphicsBuffer *graphicsBuffer() const Q_DECL_OVERRIDE;
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index fded4de76a..7065bb0ffb 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -1773,24 +1773,6 @@ void QXcbConnection::handleClientMessageEvent(const xcb_client_message_event_t *
window->handleClientMessageEvent(event);
}
-xcb_generic_event_t *QXcbConnection::checkEvent(int type)
-{
- QXcbEventArray *eventqueue = m_reader->lock();
-
- for (int i = 0; i < eventqueue->size(); ++i) {
- xcb_generic_event_t *event = eventqueue->at(i);
- if (event && event->response_type == type) {
- (*eventqueue)[i] = 0;
- m_reader->unlock();
- return event;
- }
- }
-
- m_reader->unlock();
-
- return 0;
-}
-
static const char * xcb_atomnames = {
// window-manager <-> client protocols
"WM_PROTOCOLS\0"
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index 891f0fbcb5..1336b3f5d3 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -447,7 +447,6 @@ public:
QXcbWindowEventListener *windowEventListenerFromId(xcb_window_t id);
QXcbWindow *platformWindowFromId(xcb_window_t id);
- xcb_generic_event_t *checkEvent(int type);
template<typename T>
inline xcb_generic_event_t *checkEvent(T &checker);
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 54c93bea39..10c8c8a2d8 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -2810,9 +2810,8 @@ void QXcbWindow::setMask(const QRegion &region)
XCB_SHAPE_SK_BOUNDING, xcb_window(), 0, 0, XCB_NONE);
} else {
QVector<xcb_rectangle_t> rects;
- const QVector<QRect> regionRects = region.rects();
- rects.reserve(regionRects.count());
- foreach (const QRect &r, regionRects)
+ rects.reserve(region.rectCount());
+ for (const QRect &r : region)
rects.push_back(qRectToXCBRectangle(r));
xcb_shape_rectangles(connection()->xcb_connection(), XCB_SHAPE_SO_SET,
XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED,
diff --git a/src/plugins/platforms/xcb/xcb_qpa_lib.pro b/src/plugins/platforms/xcb/xcb_qpa_lib.pro
index db9ea32cd8..2013f40dd0 100644
--- a/src/plugins/platforms/xcb/xcb_qpa_lib.pro
+++ b/src/plugins/platforms/xcb/xcb_qpa_lib.pro
@@ -48,10 +48,10 @@ contains(QT_CONFIG, xcb-xlib) {
DEFINES += XCB_USE_XINPUT2
SOURCES += qxcbconnection_xi2.cpp
LIBS += -lXi
- !isEmpty(QMAKE_LIBXI_VERSION_MAJOR) {
- DEFINES += LIBXI_MAJOR=$$QMAKE_LIBXI_VERSION_MAJOR \
- LIBXI_MINOR=$$QMAKE_LIBXI_VERSION_MINOR \
- LIBXI_PATCH=$$QMAKE_LIBXI_VERSION_PATCH
+ !isEmpty(QMAKE_XINPUT2_VERSION_MAJOR) {
+ DEFINES += LIBXI_MAJOR=$$QMAKE_XINPUT2_VERSION_MAJOR \
+ LIBXI_MINOR=$$QMAKE_XINPUT2_VERSION_MINOR \
+ LIBXI_PATCH=$$QMAKE_XINPUT2_VERSION_PATCH
}
}
}
@@ -81,7 +81,7 @@ CONFIG += qpa/genericunixfontdatabase
contains(QT_CONFIG, dbus-linked) {
QT += dbus
- LIBS += $$QT_LIBS_DBUS
+ LIBS += $$QMAKE_LIBS_DBUS
}
contains(QT_CONFIG, xcb-qt) {
diff --git a/src/plugins/platformthemes/gtk3/gtk3.pro b/src/plugins/platformthemes/gtk3/gtk3.pro
index cd19e73ed8..72a33efeac 100644
--- a/src/plugins/platformthemes/gtk3/gtk3.pro
+++ b/src/plugins/platformthemes/gtk3/gtk3.pro
@@ -8,14 +8,16 @@ load(qt_plugin)
QT += core-private gui-private platformsupport-private
CONFIG += X11
-QMAKE_CXXFLAGS += $$QT_CFLAGS_QGTK3
-LIBS += $$QT_LIBS_QGTK3
+QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_GTK3
+LIBS += $$QMAKE_LIBS_GTK3
HEADERS += \
qgtk3dialoghelpers.h \
+ qgtk3menu.h \
qgtk3theme.h
SOURCES += \
main.cpp \
qgtk3dialoghelpers.cpp \
+ qgtk3menu.cpp \
qgtk3theme.cpp
diff --git a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
index ced5fe7086..308eee5404 100644
--- a/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
+++ b/src/plugins/platformthemes/gtk3/qgtk3dialoghelpers.cpp
@@ -217,8 +217,10 @@ QColor QGtk3ColorDialogHelper::currentColor() const
void QGtk3ColorDialogHelper::onAccepted()
{
+ const QColor color = currentColor();
+ emit currentColorChanged(color);
emit accept();
- emit colorSelected(currentColor());
+ emit colorSelected(color);
}
void QGtk3ColorDialogHelper::onColorChanged(QGtk3ColorDialogHelper *dialog)
@@ -420,6 +422,9 @@ void QGtk3FileDialogHelper::applyOptions()
const bool confirmOverwrite = !opts->testOption(QFileDialogOptions::DontConfirmOverwrite);
gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(gtkDialog), confirmOverwrite);
+ const bool readOnly = opts->testOption(QFileDialogOptions::ReadOnly);
+ gtk_file_chooser_set_create_folders(GTK_FILE_CHOOSER(gtkDialog), !readOnly);
+
const QStringList nameFilters = opts->nameFilters();
if (!nameFilters.isEmpty())
setNameFilters(nameFilters);
@@ -588,9 +593,10 @@ QFont QGtk3FontDialogHelper::currentFont() const
void QGtk3FontDialogHelper::onAccepted()
{
- emit currentFontChanged(currentFont());
+ const QFont font = currentFont();
+ emit currentFontChanged(font);
emit accept();
- emit fontSelected(currentFont());
+ emit fontSelected(font);
}
void QGtk3FontDialogHelper::applyOptions()
diff --git a/src/plugins/platformthemes/gtk3/qgtk3menu.cpp b/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
new file mode 100644
index 0000000000..52757587b4
--- /dev/null
+++ b/src/plugins/platformthemes/gtk3/qgtk3menu.cpp
@@ -0,0 +1,489 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgtk3menu.h"
+
+#include <QtGui/qwindow.h>
+#include <QtGui/qpa/qplatformtheme.h>
+
+#undef signals
+#include <gtk/gtk.h>
+
+QT_BEGIN_NAMESPACE
+
+static guint qt_gdkKey(const QKeySequence &shortcut)
+{
+ if (shortcut.isEmpty())
+ return 0;
+
+ // TODO: proper mapping
+ Qt::KeyboardModifiers mods = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier;
+ return (shortcut[0] ^ mods) & shortcut[0];
+}
+
+static GdkModifierType qt_gdkModifiers(const QKeySequence &shortcut)
+{
+ if (shortcut.isEmpty())
+ return GdkModifierType(0);
+
+ guint mods = 0;
+ int m = shortcut[0];
+ if (m & Qt::ShiftModifier)
+ mods |= GDK_SHIFT_MASK;
+ if (m & Qt::ControlModifier)
+ mods |= GDK_CONTROL_MASK;
+ if (m & Qt::AltModifier)
+ mods |= GDK_MOD1_MASK;
+ if (m & Qt::MetaModifier)
+ mods |= GDK_META_MASK;
+
+ return static_cast<GdkModifierType>(mods);
+}
+
+QGtk3MenuItem::QGtk3MenuItem()
+ : m_visible(true),
+ m_separator(false),
+ m_checkable(false),
+ m_checked(false),
+ m_enabled(true),
+ m_underline(false),
+ m_invalid(true),
+ m_tag(reinterpret_cast<quintptr>(this)),
+ m_menu(nullptr),
+ m_item(nullptr)
+{
+}
+
+QGtk3MenuItem::~QGtk3MenuItem()
+{
+}
+
+bool QGtk3MenuItem::isInvalid() const
+{
+ return m_invalid;
+}
+
+GtkWidget *QGtk3MenuItem::create()
+{
+ if (m_invalid) {
+ if (m_item) {
+ gtk_widget_destroy(m_item);
+ m_item = nullptr;
+ }
+ m_invalid = false;
+ }
+
+ if (!m_item) {
+ if (m_separator) {
+ m_item = gtk_separator_menu_item_new();
+ } else {
+ if (m_checkable) {
+ m_item = gtk_check_menu_item_new();
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(m_item), m_checked);
+ g_signal_connect(m_item, "toggled", G_CALLBACK(onToggle), this);
+ } else {
+ m_item = gtk_menu_item_new();
+ g_signal_connect(m_item, "activate", G_CALLBACK(onActivate), this);
+ }
+ gtk_menu_item_set_label(GTK_MENU_ITEM(m_item), m_text.toUtf8());
+ gtk_menu_item_set_use_underline(GTK_MENU_ITEM(m_item), m_underline);
+ if (m_menu)
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(m_item), m_menu->handle());
+ g_signal_connect(m_item, "select", G_CALLBACK(onSelect), this);
+ if (!m_shortcut.isEmpty()) {
+ GtkWidget *label = gtk_bin_get_child(GTK_BIN(m_item));
+ gtk_accel_label_set_accel(GTK_ACCEL_LABEL(label), qt_gdkKey(m_shortcut), qt_gdkModifiers(m_shortcut));
+ }
+ }
+ gtk_widget_set_sensitive(m_item, m_enabled);
+ gtk_widget_set_visible(m_item, m_visible);
+ if (GTK_IS_CHECK_MENU_ITEM(m_item))
+ g_object_set(m_item, "draw-as-radio", m_exclusive, NULL);
+ }
+
+ return m_item;
+}
+
+GtkWidget *QGtk3MenuItem::handle() const
+{
+ return m_item;
+}
+
+quintptr QGtk3MenuItem::tag() const
+{
+ return m_tag;
+}
+
+void QGtk3MenuItem::setTag(quintptr tag)
+{
+ m_tag = tag;
+}
+
+QString QGtk3MenuItem::text() const
+{
+ return m_text;
+}
+
+static QString convertMnemonics(QString text, bool *found)
+{
+ *found = false;
+
+ int i = text.length() - 1;
+ while (i >= 0) {
+ const QChar c = text.at(i);
+ if (c == QLatin1Char('&')) {
+ if (i == 0 || text.at(i - 1) != QLatin1Char('&')) {
+ // convert Qt to GTK mnemonic
+ if (i < text.length() - 1 && !text.at(i + 1).isSpace()) {
+ text.replace(i, 1, QLatin1Char('_'));
+ *found = true;
+ }
+ } else if (text.at(i - 1) == QLatin1Char('&')) {
+ // unescape ampersand
+ text.replace(--i, 2, QLatin1Char('&'));
+ }
+ } else if (c == QLatin1Char('_')) {
+ // escape GTK mnemonic
+ text.insert(i, QLatin1Char('_'));
+ }
+ --i;
+ }
+
+ return text;
+}
+
+void QGtk3MenuItem::setText(const QString &text)
+{
+ m_text = convertMnemonics(text, &m_underline);
+ if (GTK_IS_MENU_ITEM(m_item)) {
+ gtk_menu_item_set_label(GTK_MENU_ITEM(m_item), m_text.toUtf8());
+ gtk_menu_item_set_use_underline(GTK_MENU_ITEM(m_item), m_underline);
+ }
+}
+
+QGtk3Menu *QGtk3MenuItem::menu() const
+{
+ return m_menu;
+}
+
+void QGtk3MenuItem::setMenu(QPlatformMenu *menu)
+{
+ m_menu = qobject_cast<QGtk3Menu *>(menu);
+ if (GTK_IS_MENU_ITEM(m_item))
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(m_item), m_menu ? m_menu->handle() : NULL);
+}
+
+bool QGtk3MenuItem::isVisible() const
+{
+ return m_visible;
+}
+
+void QGtk3MenuItem::setVisible(bool visible)
+{
+ if (m_visible == visible)
+ return;
+
+ m_visible = visible;
+ if (GTK_IS_MENU_ITEM(m_item))
+ gtk_widget_set_visible(m_item, visible);
+}
+
+bool QGtk3MenuItem::isSeparator() const
+{
+ return m_separator;
+}
+
+void QGtk3MenuItem::setIsSeparator(bool separator)
+{
+ if (m_separator == separator)
+ return;
+
+ m_invalid = true;
+ m_separator = separator;
+}
+
+bool QGtk3MenuItem::isCheckable() const
+{
+ return m_checkable;
+}
+
+void QGtk3MenuItem::setCheckable(bool checkable)
+{
+ if (m_checkable == checkable)
+ return;
+
+ m_invalid = true;
+ m_checkable = checkable;
+}
+
+bool QGtk3MenuItem::isChecked() const
+{
+ return m_checked;
+}
+
+void QGtk3MenuItem::setChecked(bool checked)
+{
+ if (m_checked == checked)
+ return;
+
+ m_checked = checked;
+ if (GTK_IS_CHECK_MENU_ITEM(m_item))
+ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(m_item), checked);
+}
+
+QKeySequence QGtk3MenuItem::shortcut() const
+{
+ return m_shortcut;
+}
+
+void QGtk3MenuItem::setShortcut(const QKeySequence& shortcut)
+{
+ if (m_shortcut == shortcut)
+ return;
+
+ m_shortcut = shortcut;
+ if (GTK_IS_MENU_ITEM(m_item)) {
+ GtkWidget *label = gtk_bin_get_child(GTK_BIN(m_item));
+ gtk_accel_label_set_accel(GTK_ACCEL_LABEL(label), qt_gdkKey(m_shortcut), qt_gdkModifiers(m_shortcut));
+ }
+}
+
+bool QGtk3MenuItem::isEnabled() const
+{
+ return m_enabled;
+}
+
+void QGtk3MenuItem::setEnabled(bool enabled)
+{
+ if (m_enabled == enabled)
+ return;
+
+ m_enabled = enabled;
+ if (m_item)
+ gtk_widget_set_sensitive(m_item, enabled);
+}
+
+bool QGtk3MenuItem::hasExclusiveGroup() const
+{
+ return m_exclusive;
+}
+
+void QGtk3MenuItem::setHasExclusiveGroup(bool exclusive)
+{
+ if (m_exclusive == exclusive)
+ return;
+
+ m_exclusive = exclusive;
+ if (GTK_IS_CHECK_MENU_ITEM(m_item))
+ g_object_set(m_item, "draw-as-radio", exclusive, NULL);
+}
+
+void QGtk3MenuItem::onSelect(GtkMenuItem *, void *data)
+{
+ QGtk3MenuItem *item = static_cast<QGtk3MenuItem *>(data);
+ if (item)
+ emit item->hovered();
+}
+
+void QGtk3MenuItem::onActivate(GtkMenuItem *, void *data)
+{
+ QGtk3MenuItem *item = static_cast<QGtk3MenuItem *>(data);
+ if (item)
+ emit item->activated();
+}
+
+void QGtk3MenuItem::onToggle(GtkCheckMenuItem *check, void *data)
+{
+ QGtk3MenuItem *item = static_cast<QGtk3MenuItem *>(data);
+ if (item) {
+ bool active = gtk_check_menu_item_get_active(check);
+ if (active != item->isChecked()) {
+ item->setChecked(active);
+ emit item->activated();
+ }
+ }
+}
+
+QGtk3Menu::QGtk3Menu()
+ : m_tag(reinterpret_cast<quintptr>(this))
+{
+ m_menu = gtk_menu_new();
+
+ g_signal_connect(m_menu, "show", G_CALLBACK(onShow), this);
+ g_signal_connect(m_menu, "hide", G_CALLBACK(onHide), this);
+}
+
+QGtk3Menu::~QGtk3Menu()
+{
+ if (GTK_IS_WIDGET(m_menu))
+ gtk_widget_destroy(m_menu);
+}
+
+GtkWidget *QGtk3Menu::handle() const
+{
+ return m_menu;
+}
+
+void QGtk3Menu::insertMenuItem(QPlatformMenuItem *item, QPlatformMenuItem *before)
+{
+ QGtk3MenuItem *gitem = static_cast<QGtk3MenuItem *>(item);
+ if (!gitem || m_items.contains(gitem))
+ return;
+
+ GtkWidget *handle = gitem->create();
+ int index = m_items.indexOf(static_cast<QGtk3MenuItem *>(before));
+ if (index < 0)
+ index = m_items.count();
+ m_items.insert(index, gitem);
+ gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), handle, index);
+}
+
+void QGtk3Menu::removeMenuItem(QPlatformMenuItem *item)
+{
+ QGtk3MenuItem *gitem = static_cast<QGtk3MenuItem *>(item);
+ if (!gitem || !m_items.removeOne(gitem))
+ return;
+
+ GtkWidget *handle = gitem->handle();
+ if (handle)
+ gtk_container_remove(GTK_CONTAINER(m_menu), handle);
+}
+
+void QGtk3Menu::syncMenuItem(QPlatformMenuItem *item)
+{
+ QGtk3MenuItem *gitem = static_cast<QGtk3MenuItem *>(item);
+ int index = m_items.indexOf(gitem);
+ if (index == -1 || !gitem->isInvalid())
+ return;
+
+ GtkWidget *handle = gitem->create();
+ if (handle)
+ gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), handle, index);
+}
+
+void QGtk3Menu::syncSeparatorsCollapsible(bool enable)
+{
+ Q_UNUSED(enable);
+}
+
+quintptr QGtk3Menu::tag() const
+{
+ return m_tag;
+}
+
+void QGtk3Menu::setTag(quintptr tag)
+{
+ m_tag = tag;
+}
+
+void QGtk3Menu::setEnabled(bool enabled)
+{
+ gtk_widget_set_sensitive(m_menu, enabled);
+}
+
+void QGtk3Menu::setVisible(bool visible)
+{
+ gtk_widget_set_visible(m_menu, visible);
+}
+
+static void qt_gtk_menu_position_func(GtkMenu *, gint *x, gint *y, gboolean *push_in, gpointer data)
+{
+ QGtk3Menu *menu = static_cast<QGtk3Menu *>(data);
+ QPoint targetPos = menu->targetPos();
+ *x = targetPos.x();
+ *y = targetPos.y();
+ *push_in = true;
+}
+
+QPoint QGtk3Menu::targetPos() const
+{
+ return m_targetPos;
+}
+
+void QGtk3Menu::showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item)
+{
+ int index = m_items.indexOf(static_cast<QGtk3MenuItem *>(const_cast<QPlatformMenuItem *>(item)));
+ if (index != -1)
+ gtk_menu_set_active(GTK_MENU(m_menu), index);
+
+ m_targetPos = targetRect.bottomLeft();
+ if (parentWindow)
+ m_targetPos = parentWindow->mapToGlobal(m_targetPos);
+
+ gtk_menu_popup(GTK_MENU(m_menu), NULL, NULL, qt_gtk_menu_position_func, this, 0, gtk_get_current_event_time());
+}
+
+void QGtk3Menu::dismiss()
+{
+ gtk_menu_popdown(GTK_MENU(m_menu));
+}
+
+QPlatformMenuItem *QGtk3Menu::menuItemAt(int position) const
+{
+ return m_items.value(position);
+}
+
+QPlatformMenuItem *QGtk3Menu::menuItemForTag(quintptr tag) const
+{
+ for (QGtk3MenuItem *item : m_items) {
+ if (item->tag() == tag)
+ return item;
+ }
+ return nullptr;
+}
+
+QPlatformMenuItem *QGtk3Menu::createMenuItem() const
+{
+ return new QGtk3MenuItem;
+}
+
+QPlatformMenu *QGtk3Menu::createSubMenu() const
+{
+ return new QGtk3Menu;
+}
+
+void QGtk3Menu::onShow(GtkWidget *, void *data)
+{
+ QGtk3Menu *menu = static_cast<QGtk3Menu *>(data);
+ if (menu)
+ emit menu->aboutToShow();
+}
+
+void QGtk3Menu::onHide(GtkWidget *, void *data)
+{
+ QGtk3Menu *menu = static_cast<QGtk3Menu *>(data);
+ if (menu)
+ emit menu->aboutToHide();
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platformthemes/gtk3/qgtk3menu.h b/src/plugins/platformthemes/gtk3/qgtk3menu.h
new file mode 100644
index 0000000000..ad108f1218
--- /dev/null
+++ b/src/plugins/platformthemes/gtk3/qgtk3menu.h
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGTK3MENU_H
+#define QGTK3MENU_H
+
+#include <QtGui/qpa/qplatformmenu.h>
+
+typedef struct _GtkWidget GtkWidget;
+typedef struct _GtkMenuItem GtkMenuItem;
+typedef struct _GtkCheckMenuItem GtkCheckMenuItem;
+
+QT_BEGIN_NAMESPACE
+
+class QGtk3Menu;
+
+class QGtk3MenuItem: public QPlatformMenuItem
+{
+public:
+ QGtk3MenuItem();
+ ~QGtk3MenuItem();
+
+ bool isInvalid() const;
+
+ GtkWidget *create();
+ GtkWidget *handle() const;
+
+ quintptr tag() const;
+ void setTag(quintptr tag) override;
+
+ QString text() const;
+ void setText(const QString &text) override;
+
+ QGtk3Menu *menu() const;
+ void setMenu(QPlatformMenu *menu) override;
+
+ bool isVisible() const;
+ void setVisible(bool visible) override;
+
+ bool isSeparator() const;
+ void setIsSeparator(bool separator) override;
+
+ bool isCheckable() const;
+ void setCheckable(bool checkable) override;
+
+ bool isChecked() const;
+ void setChecked(bool checked) override;
+
+ QKeySequence shortcut() const;
+ void setShortcut(const QKeySequence &shortcut) override;
+
+ bool isEnabled() const;
+ void setEnabled(bool enabled) override;
+
+ bool hasExclusiveGroup() const;
+ void setHasExclusiveGroup(bool exclusive) override;
+
+ void setRole(MenuRole role) override { Q_UNUSED(role); }
+ void setFont(const QFont &font) override { Q_UNUSED(font); }
+ void setIcon(const QIcon &icon) override { Q_UNUSED(icon); }
+ void setIconSize(int size) override { Q_UNUSED(size); }
+
+protected:
+ static void onSelect(GtkMenuItem *item, void *data);
+ static void onActivate(GtkMenuItem *item, void *data);
+ static void onToggle(GtkCheckMenuItem *item, void *data);
+
+private:
+ bool m_visible;
+ bool m_separator;
+ bool m_checkable;
+ bool m_checked;
+ bool m_enabled;
+ bool m_exclusive;
+ bool m_underline;
+ bool m_invalid;
+ quintptr m_tag;
+ QGtk3Menu *m_menu;
+ GtkWidget *m_item;
+ QString m_text;
+ QKeySequence m_shortcut;
+};
+
+class QGtk3Menu : public QPlatformMenu
+{
+ Q_OBJECT
+
+public:
+ QGtk3Menu();
+ ~QGtk3Menu();
+
+ GtkWidget *handle() const;
+
+ void insertMenuItem(QPlatformMenuItem *item, QPlatformMenuItem *before) override;
+ void removeMenuItem(QPlatformMenuItem *item) override;
+ void syncMenuItem(QPlatformMenuItem *item) override;
+ void syncSeparatorsCollapsible(bool enable) override;
+
+ quintptr tag() const override;
+ void setTag(quintptr tag) override;
+
+ void setEnabled(bool enabled) override;
+ void setVisible(bool visible) override;
+
+ void setIcon(const QIcon &icon) override { Q_UNUSED(icon); }
+ void setText(const QString &text) override { Q_UNUSED(text); }
+
+ QPoint targetPos() const;
+
+ void showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item) override;
+ void dismiss() override;
+
+ QPlatformMenuItem *menuItemAt(int position) const override;
+ QPlatformMenuItem *menuItemForTag(quintptr tag) const override;
+
+ QPlatformMenuItem *createMenuItem() const override;
+ QPlatformMenu *createSubMenu() const override;
+
+protected:
+ static void onShow(GtkWidget *menu, void *data);
+ static void onHide(GtkWidget *menu, void *data);
+
+private:
+ quintptr m_tag;
+ GtkWidget *m_menu;
+ QPoint m_targetPos;
+ QVector<QGtk3MenuItem *> m_items;
+};
+
+QT_END_NAMESPACE
+
+#endif // QGTK3MENU_H
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
index 65bec3dbd1..6df631bff3 100644
--- a/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
+++ b/src/plugins/platformthemes/gtk3/qgtk3theme.cpp
@@ -39,6 +39,7 @@
#include "qgtk3theme.h"
#include "qgtk3dialoghelpers.h"
+#include "qgtk3menu.h"
#include <QVariant>
#undef signals
@@ -142,4 +143,14 @@ QPlatformDialogHelper *QGtk3Theme::createPlatformDialogHelper(DialogType type) c
}
}
+QPlatformMenu* QGtk3Theme::createPlatformMenu() const
+{
+ return new QGtk3Menu;
+}
+
+QPlatformMenuItem* QGtk3Theme::createPlatformMenuItem() const
+{
+ return new QGtk3MenuItem;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platformthemes/gtk3/qgtk3theme.h b/src/plugins/platformthemes/gtk3/qgtk3theme.h
index 8bb9adeab8..52036680c6 100644
--- a/src/plugins/platformthemes/gtk3/qgtk3theme.h
+++ b/src/plugins/platformthemes/gtk3/qgtk3theme.h
@@ -55,6 +55,9 @@ public:
bool usePlatformNativeDialog(DialogType type) const Q_DECL_OVERRIDE;
QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const Q_DECL_OVERRIDE;
+ QPlatformMenu* createPlatformMenu() const Q_DECL_OVERRIDE;
+ QPlatformMenuItem* createPlatformMenuItem() const Q_DECL_OVERRIDE;
+
static const char *name;
};
diff --git a/src/plugins/sqldrivers/db2/db2.pro b/src/plugins/sqldrivers/db2/db2.pro
index 2365c5bc0e..31822ef8dc 100644
--- a/src/plugins/sqldrivers/db2/db2.pro
+++ b/src/plugins/sqldrivers/db2/db2.pro
@@ -1,8 +1,15 @@
TARGET = qsqldb2
-SOURCES = main.cpp
+HEADERS += $$PWD/qsql_db2_p.h
+SOURCES += $$PWD/qsql_db2.cpp $$PWD/main.cpp
+
+unix {
+ !contains(LIBS, .*db2.*):LIBS += -ldb2
+} else {
+ !contains(LIBS, .*db2.*):LIBS += -ldb2cli
+}
+
OTHER_FILES += db2.json
-include(../../../sql/drivers/db2/qsql_db2.pri)
PLUGIN_CLASS_NAME = QDB2DriverPlugin
include(../qsqldriverbase.pri)
diff --git a/src/plugins/sqldrivers/db2/main.cpp b/src/plugins/sqldrivers/db2/main.cpp
index 3869d7798d..97338b8eef 100644
--- a/src/plugins/sqldrivers/db2/main.cpp
+++ b/src/plugins/sqldrivers/db2/main.cpp
@@ -39,7 +39,7 @@
#include <qsqldriverplugin.h>
#include <qstringlist.h>
-#include "../../../sql/drivers/db2/qsql_db2_p.h"
+#include "qsql_db2_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/sql/drivers/db2/qsql_db2.cpp b/src/plugins/sqldrivers/db2/qsql_db2.cpp
index 4ccc3aca9e..4ccc3aca9e 100644
--- a/src/sql/drivers/db2/qsql_db2.cpp
+++ b/src/plugins/sqldrivers/db2/qsql_db2.cpp
diff --git a/src/sql/drivers/db2/qsql_db2_p.h b/src/plugins/sqldrivers/db2/qsql_db2_p.h
index fa6d739479..fa6d739479 100644
--- a/src/sql/drivers/db2/qsql_db2_p.h
+++ b/src/plugins/sqldrivers/db2/qsql_db2_p.h
diff --git a/src/plugins/sqldrivers/ibase/ibase.pro b/src/plugins/sqldrivers/ibase/ibase.pro
index 1f29597a2b..8237245183 100644
--- a/src/plugins/sqldrivers/ibase/ibase.pro
+++ b/src/plugins/sqldrivers/ibase/ibase.pro
@@ -1,8 +1,17 @@
TARGET = qsqlibase
-SOURCES = main.cpp
+HEADERS += $$PWD/qsql_ibase_p.h
+SOURCES += $$PWD/qsql_ibase.cpp $$PWD/main.cpp
+
+unix {
+ !contains(LIBS, .*gds.*):!contains(LIBS, .*libfb.*):LIBS += -lgds
+} else {
+ !contains(LIBS, .*gds.*):!contains(LIBS, .*fbclient.*) {
+ LIBS += -lgds32_ms
+ }
+}
+
OTHER_FILES += ibase.json
-include(../../../sql/drivers/ibase/qsql_ibase.pri)
PLUGIN_CLASS_NAME = QIBaseDriverPlugin
include(../qsqldriverbase.pri)
diff --git a/src/plugins/sqldrivers/ibase/main.cpp b/src/plugins/sqldrivers/ibase/main.cpp
index c6f0b785de..8d462afcdc 100644
--- a/src/plugins/sqldrivers/ibase/main.cpp
+++ b/src/plugins/sqldrivers/ibase/main.cpp
@@ -39,7 +39,7 @@
#include <qsqldriverplugin.h>
#include <qstringlist.h>
-#include "../../../sql/drivers/ibase/qsql_ibase_p.h"
+#include "qsql_ibase_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/sql/drivers/ibase/qsql_ibase.cpp b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
index 6fd91b6b76..6fd91b6b76 100644
--- a/src/sql/drivers/ibase/qsql_ibase.cpp
+++ b/src/plugins/sqldrivers/ibase/qsql_ibase.cpp
diff --git a/src/sql/drivers/ibase/qsql_ibase_p.h b/src/plugins/sqldrivers/ibase/qsql_ibase_p.h
index c7cee41462..c7cee41462 100644
--- a/src/sql/drivers/ibase/qsql_ibase_p.h
+++ b/src/plugins/sqldrivers/ibase/qsql_ibase_p.h
diff --git a/src/plugins/sqldrivers/mysql/main.cpp b/src/plugins/sqldrivers/mysql/main.cpp
index 855a6eeb9c..00d9c5bb34 100644
--- a/src/plugins/sqldrivers/mysql/main.cpp
+++ b/src/plugins/sqldrivers/mysql/main.cpp
@@ -39,7 +39,7 @@
#include <qsqldriverplugin.h>
#include <qstringlist.h>
-#include "../../../sql/drivers/mysql/qsql_mysql_p.h"
+#include "qsql_mysql_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/sqldrivers/mysql/mysql.pro b/src/plugins/sqldrivers/mysql/mysql.pro
index c917bfca48..3bd8cd0040 100644
--- a/src/plugins/sqldrivers/mysql/mysql.pro
+++ b/src/plugins/sqldrivers/mysql/mysql.pro
@@ -1,8 +1,23 @@
TARGET = qsqlmysql
-SOURCES = main.cpp
+HEADERS += $$PWD/qsql_mysql_p.h
+SOURCES += $$PWD/qsql_mysql.cpp $$PWD/main.cpp
+
+QMAKE_CXXFLAGS *= $$QMAKE_CFLAGS_MYSQL
+LIBS += $$QMAKE_LIBS_MYSQL
+
+unix {
+ isEmpty(QMAKE_LIBS_MYSQL) {
+ !contains(LIBS, .*mysqlclient.*):!contains(LIBS, .*mysqld.*) {
+ use_libmysqlclient_r:LIBS += -lmysqlclient_r
+ else:LIBS += -lmysqlclient
+ }
+ }
+} else {
+ !contains(LIBS, .*mysql.*):!contains(LIBS, .*mysqld.*):LIBS += -llibmysql
+}
+
OTHER_FILES += mysql.json
-include(../../../sql/drivers/mysql/qsql_mysql.pri)
PLUGIN_CLASS_NAME = QMYSQLDriverPlugin
include(../qsqldriverbase.pri)
diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
index b13e10e3a5..30a0a04f44 100644
--- a/src/sql/drivers/mysql/qsql_mysql.cpp
+++ b/src/plugins/sqldrivers/mysql/qsql_mysql.cpp
@@ -1414,8 +1414,13 @@ bool QMYSQLDriver::open(const QString& db,
}
#if (MYSQL_VERSION_ID >= 40113 && MYSQL_VERSION_ID < 50000) || MYSQL_VERSION_ID >= 50007
- // force the communication to be utf8
- mysql_set_character_set(d->mysql, "utf8");
+ if (mysql_get_client_version() >= 50503 && mysql_get_server_version(d->mysql) >= 50503) {
+ // force the communication to be utf8mb4 (only utf8mb4 supports 4-byte characters)
+ mysql_set_character_set(d->mysql, "utf8mb4");
+ } else {
+ // force the communication to be utf8
+ mysql_set_character_set(d->mysql, "utf8");
+ }
#endif
#ifndef QT_NO_TEXTCODEC
d->tc = codec(d->mysql);
diff --git a/src/sql/drivers/mysql/qsql_mysql_p.h b/src/plugins/sqldrivers/mysql/qsql_mysql_p.h
index 7641f9aa34..7641f9aa34 100644
--- a/src/sql/drivers/mysql/qsql_mysql_p.h
+++ b/src/plugins/sqldrivers/mysql/qsql_mysql_p.h
diff --git a/src/plugins/sqldrivers/oci/main.cpp b/src/plugins/sqldrivers/oci/main.cpp
index 980116123d..e576928d31 100644
--- a/src/plugins/sqldrivers/oci/main.cpp
+++ b/src/plugins/sqldrivers/oci/main.cpp
@@ -39,7 +39,7 @@
#include <qsqldriverplugin.h>
#include <qstringlist.h>
-#include "../../../sql/drivers/oci/qsql_oci_p.h"
+#include "qsql_oci_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/sqldrivers/oci/oci.pro b/src/plugins/sqldrivers/oci/oci.pro
index 96a0dd9ab6..a22d1181bf 100644
--- a/src/plugins/sqldrivers/oci/oci.pro
+++ b/src/plugins/sqldrivers/oci/oci.pro
@@ -1,8 +1,16 @@
TARGET = qsqloci
-SOURCES = main.cpp
+HEADERS += $$PWD/qsql_oci_p.h
+SOURCES += $$PWD/qsql_oci.cpp $$PWD/main.cpp
+
+unix {
+ !contains(LIBS, .*clnts.*):LIBS += -lclntsh
+} else {
+ LIBS *= -loci
+}
+darwin:QMAKE_LFLAGS += -Wl,-flat_namespace,-U,_environ
+
OTHER_FILES += oci.json
-include(../../../sql/drivers/oci/qsql_oci.pri)
PLUGIN_CLASS_NAME = QOCIDriverPlugin
include(../qsqldriverbase.pri)
diff --git a/src/sql/drivers/oci/qsql_oci.cpp b/src/plugins/sqldrivers/oci/qsql_oci.cpp
index 47d6db7ea4..47d6db7ea4 100644
--- a/src/sql/drivers/oci/qsql_oci.cpp
+++ b/src/plugins/sqldrivers/oci/qsql_oci.cpp
diff --git a/src/sql/drivers/oci/qsql_oci_p.h b/src/plugins/sqldrivers/oci/qsql_oci_p.h
index 69911f4bee..69911f4bee 100644
--- a/src/sql/drivers/oci/qsql_oci_p.h
+++ b/src/plugins/sqldrivers/oci/qsql_oci_p.h
diff --git a/src/plugins/sqldrivers/odbc/main.cpp b/src/plugins/sqldrivers/odbc/main.cpp
index 69ea7b1f8e..ac63941a82 100644
--- a/src/plugins/sqldrivers/odbc/main.cpp
+++ b/src/plugins/sqldrivers/odbc/main.cpp
@@ -39,7 +39,7 @@
#include <qsqldriverplugin.h>
#include <qstringlist.h>
-#include "../../../sql/drivers/odbc/qsql_odbc_p.h"
+#include "qsql_odbc_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/sqldrivers/odbc/odbc.pro b/src/plugins/sqldrivers/odbc/odbc.pro
index c0020c065f..0e49f1ac66 100644
--- a/src/plugins/sqldrivers/odbc/odbc.pro
+++ b/src/plugins/sqldrivers/odbc/odbc.pro
@@ -1,8 +1,19 @@
TARGET = qsqlodbc
-SOURCES = main.cpp
+HEADERS += $$PWD/qsql_odbc_p.h
+SOURCES += $$PWD/qsql_odbc.cpp $$PWD/main.cpp
+
+unix {
+ DEFINES += UNICODE
+ !contains(LIBS, .*odbc.*) {
+ osx:LIBS += -liodbc
+ else:LIBS += $$QMAKE_LIBS_ODBC
+ }
+} else {
+ LIBS *= -lodbc32
+}
+
OTHER_FILES += odbc.json
-include(../../../sql/drivers/odbc/qsql_odbc.pri)
PLUGIN_CLASS_NAME = QODBCDriverPlugin
include(../qsqldriverbase.pri)
diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
index 59ef42d609..59ef42d609 100644
--- a/src/sql/drivers/odbc/qsql_odbc.cpp
+++ b/src/plugins/sqldrivers/odbc/qsql_odbc.cpp
diff --git a/src/sql/drivers/odbc/qsql_odbc_p.h b/src/plugins/sqldrivers/odbc/qsql_odbc_p.h
index f4ce8bc243..f4ce8bc243 100644
--- a/src/sql/drivers/odbc/qsql_odbc_p.h
+++ b/src/plugins/sqldrivers/odbc/qsql_odbc_p.h
diff --git a/src/plugins/sqldrivers/psql/main.cpp b/src/plugins/sqldrivers/psql/main.cpp
index eae1c1c554..7657fcbfdf 100644
--- a/src/plugins/sqldrivers/psql/main.cpp
+++ b/src/plugins/sqldrivers/psql/main.cpp
@@ -39,7 +39,7 @@
#include <qsqldriverplugin.h>
#include <qstringlist.h>
-#include "../../../sql/drivers/psql/qsql_psql_p.h"
+#include "qsql_psql_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/sqldrivers/psql/psql.pro b/src/plugins/sqldrivers/psql/psql.pro
index 0fabe0e616..4a05266120 100644
--- a/src/plugins/sqldrivers/psql/psql.pro
+++ b/src/plugins/sqldrivers/psql/psql.pro
@@ -1,8 +1,17 @@
TARGET = qsqlpsql
-SOURCES = main.cpp
+HEADERS += $$PWD/qsql_psql_p.h
+SOURCES += $$PWD/qsql_psql.cpp $$PWD/main.cpp
+
+unix|mingw {
+ LIBS += $$QMAKE_LIBS_PSQL
+ !contains(LIBS, .*pq.*):LIBS += -lpq
+ QMAKE_CXXFLAGS *= $$QMAKE_CFLAGS_PSQL
+} else {
+ !contains(LIBS, .*pq.*):LIBS += -llibpq -lws2_32 -ladvapi32
+}
+
OTHER_FILES += psql.json
-include(../../../sql/drivers/psql/qsql_psql.pri)
PLUGIN_CLASS_NAME = QPSQLDriverPlugin
include(../qsqldriverbase.pri)
diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/plugins/sqldrivers/psql/qsql_psql.cpp
index fcf75af298..fcf75af298 100644
--- a/src/sql/drivers/psql/qsql_psql.cpp
+++ b/src/plugins/sqldrivers/psql/qsql_psql.cpp
diff --git a/src/sql/drivers/psql/qsql_psql_p.h b/src/plugins/sqldrivers/psql/qsql_psql_p.h
index 8468b9af93..8468b9af93 100644
--- a/src/sql/drivers/psql/qsql_psql_p.h
+++ b/src/plugins/sqldrivers/psql/qsql_psql_p.h
diff --git a/src/plugins/sqldrivers/sqldrivers.pro b/src/plugins/sqldrivers/sqldrivers.pro
index 39c58d4f2b..37dbd2394e 100644
--- a/src/plugins/sqldrivers/sqldrivers.pro
+++ b/src/plugins/sqldrivers/sqldrivers.pro
@@ -1,11 +1,11 @@
TEMPLATE = subdirs
-contains(sql-plugins, psql) : SUBDIRS += psql
-contains(sql-plugins, mysql) : SUBDIRS += mysql
-contains(sql-plugins, odbc) : SUBDIRS += odbc
-contains(sql-plugins, tds) : SUBDIRS += tds
-contains(sql-plugins, oci) : SUBDIRS += oci
-contains(sql-plugins, db2) : SUBDIRS += db2
-contains(sql-plugins, sqlite) : SUBDIRS += sqlite
-contains(sql-plugins, sqlite2) : SUBDIRS += sqlite2
-contains(sql-plugins, ibase) : SUBDIRS += ibase
+contains(sql-drivers, psql) : SUBDIRS += psql
+contains(sql-drivers, mysql) : SUBDIRS += mysql
+contains(sql-drivers, odbc) : SUBDIRS += odbc
+contains(sql-drivers, tds) : SUBDIRS += tds
+contains(sql-drivers, oci) : SUBDIRS += oci
+contains(sql-drivers, db2) : SUBDIRS += db2
+contains(sql-drivers, sqlite) : SUBDIRS += sqlite
+contains(sql-drivers, sqlite2) : SUBDIRS += sqlite2
+contains(sql-drivers, ibase) : SUBDIRS += ibase
diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
index 2a45b73d14..ef4ef2e93c 100644
--- a/src/sql/drivers/sqlite/qsql_sqlite.cpp
+++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp
@@ -59,6 +59,7 @@
#endif
#include <sqlite3.h>
+#include <functional>
Q_DECLARE_OPAQUE_POINTER(sqlite3*)
Q_DECLARE_METATYPE(sqlite3*)
@@ -140,6 +141,7 @@ public:
inline QSQLiteDriverPrivate() : QSqlDriverPrivate(), access(0) { dbmsType = QSqlDriver::SQLite; }
sqlite3 *access;
QList <QSQLiteResult *> results;
+ QStringList notificationid;
};
@@ -571,6 +573,7 @@ QSQLiteDriver::QSQLiteDriver(sqlite3 *connection, QObject *parent)
QSQLiteDriver::~QSQLiteDriver()
{
+ close();
}
bool QSQLiteDriver::hasFeature(DriverFeature f) const
@@ -585,11 +588,11 @@ bool QSQLiteDriver::hasFeature(DriverFeature f) const
case SimpleLocking:
case FinishQuery:
case LowPrecisionNumbers:
+ case EventNotifications:
return true;
case QuerySize:
case NamedPlaceholders:
case BatchOperations:
- case EventNotifications:
case MultipleResultSets:
case CancelQuery:
return false;
@@ -664,9 +667,13 @@ void QSQLiteDriver::close()
for (QSQLiteResult *result : qAsConst(d->results))
result->d_func()->finalize();
+ if (d->access && (d->notificationid.count() > 0)) {
+ d->notificationid.clear();
+ sqlite3_update_hook(d->access, NULL, NULL);
+ }
+
if (sqlite3_close(d->access) != SQLITE_OK)
- setLastError(qMakeError(d->access, tr("Error closing database"),
- QSqlError::ConnectionError));
+ setLastError(qMakeError(d->access, tr("Error closing database"), QSqlError::ConnectionError));
d->access = 0;
setOpen(false);
setOpenError(false);
@@ -825,4 +832,72 @@ QString QSQLiteDriver::escapeIdentifier(const QString &identifier, IdentifierTyp
return _q_escapeIdentifier(identifier);
}
+static void handle_sqlite_callback(void *qobj,int aoperation, char const *adbname, char const *atablename,
+ sqlite3_int64 arowid)
+{
+ Q_UNUSED(aoperation);
+ Q_UNUSED(adbname);
+ QSQLiteDriver *driver = static_cast<QSQLiteDriver *>(qobj);
+ if (driver) {
+ QMetaObject::invokeMethod(driver, "handleNotification", Qt::QueuedConnection,
+ Q_ARG(QString, QString::fromUtf8(atablename)), Q_ARG(qint64, arowid));
+ }
+}
+
+bool QSQLiteDriver::subscribeToNotification(const QString &name)
+{
+ Q_D(QSQLiteDriver);
+ if (!isOpen()) {
+ qWarning("Database not open.");
+ return false;
+ }
+
+ if (d->notificationid.contains(name)) {
+ qWarning("Already subscribing to '%s'.", qPrintable(name));
+ return false;
+ }
+
+ //sqlite supports only one notification callback, so only the first is registered
+ d->notificationid << name;
+ if (d->notificationid.count() == 1)
+ sqlite3_update_hook(d->access, &handle_sqlite_callback, reinterpret_cast<void *> (this));
+
+ return true;
+}
+
+bool QSQLiteDriver::unsubscribeFromNotification(const QString &name)
+{
+ Q_D(QSQLiteDriver);
+ if (!isOpen()) {
+ qWarning("Database not open.");
+ return false;
+ }
+
+ if (!d->notificationid.contains(name)) {
+ qWarning("Not subscribed to '%s'.", qPrintable(name));
+ return false;
+ }
+
+ d->notificationid.removeAll(name);
+ if (d->notificationid.isEmpty())
+ sqlite3_update_hook(d->access, NULL, NULL);
+
+ return true;
+}
+
+QStringList QSQLiteDriver::subscribedToNotifications() const
+{
+ Q_D(const QSQLiteDriver);
+ return d->notificationid;
+}
+
+void QSQLiteDriver::handleNotification(const QString &tableName, qint64 rowid)
+{
+ Q_D(const QSQLiteDriver);
+ if (d->notificationid.contains(tableName)) {
+ emit notification(tableName);
+ emit notification(tableName, QSqlDriver::UnknownSource, QVariant(rowid));
+ }
+}
+
QT_END_NAMESPACE
diff --git a/src/sql/drivers/sqlite/qsql_sqlite_p.h b/src/plugins/sqldrivers/sqlite/qsql_sqlite_p.h
index c9b7708698..ca969a4b53 100644
--- a/src/sql/drivers/sqlite/qsql_sqlite_p.h
+++ b/src/plugins/sqldrivers/sqlite/qsql_sqlite_p.h
@@ -93,6 +93,12 @@ public:
QSqlIndex primaryIndex(const QString &table) const Q_DECL_OVERRIDE;
QVariant handle() const Q_DECL_OVERRIDE;
QString escapeIdentifier(const QString &identifier, IdentifierType) const Q_DECL_OVERRIDE;
+
+ bool subscribeToNotification(const QString &name) Q_DECL_OVERRIDE;
+ bool unsubscribeFromNotification(const QString &name) Q_DECL_OVERRIDE;
+ QStringList subscribedToNotifications() const Q_DECL_OVERRIDE;
+private Q_SLOTS:
+ void handleNotification(const QString &tableName, qint64 rowid);
};
QT_END_NAMESPACE
diff --git a/src/plugins/sqldrivers/sqlite/smain.cpp b/src/plugins/sqldrivers/sqlite/smain.cpp
index 94b41c9878..2ad466a61e 100644
--- a/src/plugins/sqldrivers/sqlite/smain.cpp
+++ b/src/plugins/sqldrivers/sqlite/smain.cpp
@@ -39,7 +39,7 @@
#include <qsqldriverplugin.h>
#include <qstringlist.h>
-#include "../../../../src/sql/drivers/sqlite/qsql_sqlite_p.h"
+#include "qsql_sqlite_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/sqldrivers/sqlite/sqlite.pro b/src/plugins/sqldrivers/sqlite/sqlite.pro
index cc6d02cbe8..c98655f85c 100644
--- a/src/plugins/sqldrivers/sqlite/sqlite.pro
+++ b/src/plugins/sqldrivers/sqlite/sqlite.pro
@@ -1,8 +1,16 @@
TARGET = qsqlite
-SOURCES = smain.cpp
+HEADERS += $$PWD/qsql_sqlite_p.h
+SOURCES += $$PWD/qsql_sqlite.cpp $$PWD/smain.cpp
+
+!system-sqlite:!contains(LIBS, .*sqlite3.*) {
+ include($$PWD/../../../3rdparty/sqlite.pri)
+} else {
+ LIBS += $$QMAKE_LIBS_SQLITE
+ QMAKE_CXXFLAGS *= $$QMAKE_CFLAGS_SQLITE
+}
+
OTHER_FILES += sqlite.json
-include(../../../sql/drivers/sqlite/qsql_sqlite.pri)
PLUGIN_CLASS_NAME = QSQLiteDriverPlugin
include(../qsqldriverbase.pri)
diff --git a/src/sql/drivers/sqlite2/qsql_sqlite2.cpp b/src/plugins/sqldrivers/sqlite2/qsql_sqlite2.cpp
index 67c24e4168..67c24e4168 100644
--- a/src/sql/drivers/sqlite2/qsql_sqlite2.cpp
+++ b/src/plugins/sqldrivers/sqlite2/qsql_sqlite2.cpp
diff --git a/src/sql/drivers/sqlite2/qsql_sqlite2_p.h b/src/plugins/sqldrivers/sqlite2/qsql_sqlite2_p.h
index 83b248ec6a..83b248ec6a 100644
--- a/src/sql/drivers/sqlite2/qsql_sqlite2_p.h
+++ b/src/plugins/sqldrivers/sqlite2/qsql_sqlite2_p.h
diff --git a/src/plugins/sqldrivers/sqlite2/smain.cpp b/src/plugins/sqldrivers/sqlite2/smain.cpp
index 06b428c8ef..3a5734f8c9 100644
--- a/src/plugins/sqldrivers/sqlite2/smain.cpp
+++ b/src/plugins/sqldrivers/sqlite2/smain.cpp
@@ -39,7 +39,7 @@
#include <qsqldriverplugin.h>
#include <qstringlist.h>
-#include "../../../../src/sql/drivers/sqlite2/qsql_sqlite2_p.h"
+#include "qsql_sqlite2_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/sqldrivers/sqlite2/sqlite2.pro b/src/plugins/sqldrivers/sqlite2/sqlite2.pro
index d69afc119f..d0ab0eef41 100644
--- a/src/plugins/sqldrivers/sqlite2/sqlite2.pro
+++ b/src/plugins/sqldrivers/sqlite2/sqlite2.pro
@@ -1,8 +1,11 @@
TARGET = qsqlite2
-SOURCES = smain.cpp
+HEADERS += $$PWD/qsql_sqlite2_p.h
+SOURCES += $$PWD/qsql_sqlite2.cpp $$PWD/smain.cpp
+
+!contains(LIBS, .*sqlite.*):LIBS += -lsqlite
+
OTHER_FILES += sqlite2.json
-include(../../../sql/drivers/sqlite2/qsql_sqlite2.pri)
PLUGIN_CLASS_NAME = QSQLite2DriverPlugin
include(../qsqldriverbase.pri)
diff --git a/src/plugins/sqldrivers/tds/main.cpp b/src/plugins/sqldrivers/tds/main.cpp
index ffb31ae179..4aa1444608 100644
--- a/src/plugins/sqldrivers/tds/main.cpp
+++ b/src/plugins/sqldrivers/tds/main.cpp
@@ -45,7 +45,7 @@
#define _WINSCARD_H_
#include <windows.h>
#endif
-#include "../../../sql/drivers/tds/qsql_tds_p.h"
+#include "qsql_tds_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/sql/drivers/tds/qsql_tds.cpp b/src/plugins/sqldrivers/tds/qsql_tds.cpp
index 10d9fe7298..940fd05c74 100644
--- a/src/sql/drivers/tds/qsql_tds.cpp
+++ b/src/plugins/sqldrivers/tds/qsql_tds.cpp
@@ -163,7 +163,7 @@ class QTDSResult : public QSqlCachedResult
public:
explicit QTDSResult(const QTDSDriver* db);
~QTDSResult();
- QVariant handle() const;
+ QVariant handle() const Q_DECL_OVERRIDE;
protected:
void cleanup();
diff --git a/src/sql/drivers/tds/qsql_tds_p.h b/src/plugins/sqldrivers/tds/qsql_tds_p.h
index d0914455a2..d0914455a2 100644
--- a/src/sql/drivers/tds/qsql_tds_p.h
+++ b/src/plugins/sqldrivers/tds/qsql_tds_p.h
diff --git a/src/plugins/sqldrivers/tds/tds.pro b/src/plugins/sqldrivers/tds/tds.pro
index 88f4b7c451..b5d32ae5a8 100644
--- a/src/plugins/sqldrivers/tds/tds.pro
+++ b/src/plugins/sqldrivers/tds/tds.pro
@@ -1,8 +1,17 @@
TARGET = qsqltds
-SOURCES = main.cpp
+HEADERS += $$PWD/qsql_tds_p.h
+SOURCES += $$PWD/qsql_tds.cpp $$PWD/main.cpp
+
+unix|mingw: {
+ LIBS += $$QMAKE_LIBS_TDS
+ !contains(LIBS, .*sybdb.*):LIBS += -lsybdb
+ QMAKE_CXXFLAGS *= $$QMAKE_CFLAGS_TDS
+} else {
+ LIBS *= -lNTWDBLIB
+}
+
OTHER_FILES += tds.json
-include(../../../sql/drivers/tds/qsql_tds.pri)
PLUGIN_CLASS_NAME = QTDSDriverPlugin
include(../qsqldriverbase.pri)
diff --git a/src/printsupport/dialogs/qabstractprintdialog.h b/src/printsupport/dialogs/qabstractprintdialog.h
index 8ce3687272..e8eee2ca9c 100644
--- a/src/printsupport/dialogs/qabstractprintdialog.h
+++ b/src/printsupport/dialogs/qabstractprintdialog.h
@@ -40,8 +40,8 @@
#ifndef QABSTRACTPRINTDIALOG_H
#define QABSTRACTPRINTDIALOG_H
-#include <QtWidgets/qdialog.h>
#include <QtPrintSupport/qtprintsupportglobal.h>
+#include <QtWidgets/qdialog.h>
QT_BEGIN_NAMESPACE
diff --git a/src/printsupport/dialogs/qabstractprintdialog_p.h b/src/printsupport/dialogs/qabstractprintdialog_p.h
index 977c720cd0..fe4e18cfc3 100644
--- a/src/printsupport/dialogs/qabstractprintdialog_p.h
+++ b/src/printsupport/dialogs/qabstractprintdialog_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtPrintSupport/private/qtprintsupportglobal_p.h>
#include "private/qdialog_p.h"
#ifndef QT_NO_PRINTDIALOG
diff --git a/src/printsupport/dialogs/qpagesetupdialog.h b/src/printsupport/dialogs/qpagesetupdialog.h
index fa8f6b7fad..124d215700 100644
--- a/src/printsupport/dialogs/qpagesetupdialog.h
+++ b/src/printsupport/dialogs/qpagesetupdialog.h
@@ -40,8 +40,8 @@
#ifndef QPAGESETUPDIALOG_H
#define QPAGESETUPDIALOG_H
-#include <QtWidgets/qdialog.h>
#include <QtPrintSupport/qtprintsupportglobal.h>
+#include <QtWidgets/qdialog.h>
QT_BEGIN_NAMESPACE
diff --git a/src/printsupport/dialogs/qpagesetupdialog_p.h b/src/printsupport/dialogs/qpagesetupdialog_p.h
index 4f803ae234..46e178fef9 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_p.h
+++ b/src/printsupport/dialogs/qpagesetupdialog_p.h
@@ -52,6 +52,7 @@
//
//
+#include <QtPrintSupport/private/qtprintsupportglobal_p.h>
#include "private/qdialog_p.h"
#ifndef QT_NO_PRINTDIALOG
diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix_p.h b/src/printsupport/dialogs/qpagesetupdialog_unix_p.h
index c35ad761f4..3c9733dd83 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_unix_p.h
+++ b/src/printsupport/dialogs/qpagesetupdialog_unix_p.h
@@ -51,7 +51,7 @@
//
//
-#include "qglobal.h"
+#include <QtPrintSupport/private/qtprintsupportglobal_p.h>
#ifndef QT_NO_PRINTDIALOG
diff --git a/src/printsupport/dialogs/qprintdialog.h b/src/printsupport/dialogs/qprintdialog.h
index 36187b28d6..a1d79b2310 100644
--- a/src/printsupport/dialogs/qprintdialog.h
+++ b/src/printsupport/dialogs/qprintdialog.h
@@ -40,6 +40,7 @@
#ifndef QPRINTDIALOG_H
#define QPRINTDIALOG_H
+#include <QtPrintSupport/qtprintsupportglobal.h>
#include <QtPrintSupport/qabstractprintdialog.h>
QT_BEGIN_NAMESPACE
diff --git a/src/printsupport/dialogs/qprintpreviewdialog.h b/src/printsupport/dialogs/qprintpreviewdialog.h
index 0d2b3a523c..903083167c 100644
--- a/src/printsupport/dialogs/qprintpreviewdialog.h
+++ b/src/printsupport/dialogs/qprintpreviewdialog.h
@@ -40,8 +40,8 @@
#ifndef QPRINTPREVIEWDIALOG_H
#define QPRINTPREVIEWDIALOG_H
-#include <QtWidgets/qdialog.h>
#include <QtPrintSupport/qtprintsupportglobal.h>
+#include <QtWidgets/qdialog.h>
#ifndef QT_NO_PRINTPREVIEWDIALOG
diff --git a/src/printsupport/kernel/kernel.pri b/src/printsupport/kernel/kernel.pri
index cbbb14342a..bf95d9e8f6 100644
--- a/src/printsupport/kernel/kernel.pri
+++ b/src/printsupport/kernel/kernel.pri
@@ -11,6 +11,7 @@ HEADERS += \
$$PWD/qplatformprintdevice.h \
$$PWD/qplatformprintplugin.h \
$$PWD/qplatformprintersupport.h \
+ $$PWD/qtprintsupportglobal_p.h \
$$PWD/qtprintsupportglobal.h
SOURCES += \
diff --git a/src/printsupport/kernel/qcups_p.h b/src/printsupport/kernel/qcups_p.h
index 6045ddbaa5..139b18c509 100644
--- a/src/printsupport/kernel/qcups_p.h
+++ b/src/printsupport/kernel/qcups_p.h
@@ -50,6 +50,8 @@
//
// We mean it.
//
+
+#include <QtPrintSupport/private/qtprintsupportglobal_p.h>
#include "QtCore/qstring.h"
#include "QtCore/qstringlist.h"
#include "QtPrintSupport/qprinter.h"
diff --git a/src/printsupport/kernel/qpaintengine_alpha_p.h b/src/printsupport/kernel/qpaintengine_alpha_p.h
index bc3dbfabbf..b5ba98bf88 100644
--- a/src/printsupport/kernel/qpaintengine_alpha_p.h
+++ b/src/printsupport/kernel/qpaintengine_alpha_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtPrintSupport/private/qtprintsupportglobal_p.h>
#ifndef QT_NO_PRINTER
#include "private/qpaintengine_p.h"
diff --git a/src/printsupport/kernel/qpaintengine_preview_p.h b/src/printsupport/kernel/qpaintengine_preview_p.h
index 6eb4daae7c..6277451bfa 100644
--- a/src/printsupport/kernel/qpaintengine_preview_p.h
+++ b/src/printsupport/kernel/qpaintengine_preview_p.h
@@ -52,6 +52,7 @@
//
//
+#include <QtPrintSupport/private/qtprintsupportglobal_p.h>
#include <QtGui/qpaintengine.h>
#include <QtPrintSupport/qprintengine.h>
diff --git a/src/printsupport/kernel/qplatformprintdevice.h b/src/printsupport/kernel/qplatformprintdevice.h
index 6460d2f596..44a3a966f4 100644
--- a/src/printsupport/kernel/qplatformprintdevice.h
+++ b/src/printsupport/kernel/qplatformprintdevice.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtPrintSupport/qtprintsupportglobal.h>
#include <private/qprint_p.h>
#include <QtCore/qvector.h>
diff --git a/src/printsupport/kernel/qplatformprintersupport.h b/src/printsupport/kernel/qplatformprintersupport.h
index 779b7dd8a1..d3da4295a1 100644
--- a/src/printsupport/kernel/qplatformprintersupport.h
+++ b/src/printsupport/kernel/qplatformprintersupport.h
@@ -48,6 +48,7 @@
// source and binary incompatible with future versions of Qt.
//
+#include <QtPrintSupport/qtprintsupportglobal.h>
#include <QtPrintSupport/qprinter.h>
#include <QtCore/qstringlist.h>
diff --git a/src/printsupport/kernel/qplatformprintplugin.h b/src/printsupport/kernel/qplatformprintplugin.h
index 69cb55b4d9..3e909519c2 100644
--- a/src/printsupport/kernel/qplatformprintplugin.h
+++ b/src/printsupport/kernel/qplatformprintplugin.h
@@ -49,9 +49,9 @@
// source and binary incompatible with future versions of Qt.
//
+#include <QtPrintSupport/qtprintsupportglobal.h>
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
-#include <QtPrintSupport/qtprintsupportglobal.h>
QT_BEGIN_NAMESPACE
diff --git a/src/printsupport/kernel/qprint_p.h b/src/printsupport/kernel/qprint_p.h
index ed9e8e272b..47dfce3787 100644
--- a/src/printsupport/kernel/qprint_p.h
+++ b/src/printsupport/kernel/qprint_p.h
@@ -51,12 +51,13 @@
// We mean it.
//
+#include <QtPrintSupport/private/qtprintsupportglobal_p.h>
#include <QtPrintSupport/qprinter.h>
#include <QtCore/qstring.h>
#include <QtCore/qlist.h>
-#if (defined Q_OS_MAC && !defined Q_OS_IOS) || (defined Q_OS_UNIX && !defined QT_NO_CUPS)
+#if (defined Q_OS_OSX) || (defined Q_OS_UNIX && !defined QT_NO_CUPS)
#include <cups/ppd.h> // Use for type defs only, don't want to actually link in main module
#endif
@@ -244,7 +245,7 @@ public:
return QByteArray();
}
-#if (defined Q_OS_MAC && !defined Q_OS_IOS) || (defined Q_OS_UNIX && !defined QT_NO_CUPS)
+#if (defined Q_OS_OSX) || (defined Q_OS_UNIX && !defined QT_NO_CUPS)
// PPD utilities shared by CUPS and Mac plugins requiring CUPS headers
// May turn into a proper internal QPpd class if enough shared between Mac and CUPS,
diff --git a/src/printsupport/kernel/qprintdevice_p.h b/src/printsupport/kernel/qprintdevice_p.h
index b4173b50b1..1e0d3983e9 100644
--- a/src/printsupport/kernel/qprintdevice_p.h
+++ b/src/printsupport/kernel/qprintdevice_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtPrintSupport/private/qtprintsupportglobal_p.h>
#include "private/qprint_p.h"
#include <QtCore/qsharedpointer.h>
diff --git a/src/printsupport/kernel/qprintengine.h b/src/printsupport/kernel/qprintengine.h
index bb8749c113..698f7548cf 100644
--- a/src/printsupport/kernel/qprintengine.h
+++ b/src/printsupport/kernel/qprintengine.h
@@ -40,6 +40,7 @@
#ifndef QPRINTENGINE_H
#define QPRINTENGINE_H
+#include <QtPrintSupport/qtprintsupportglobal.h>
#include <QtCore/qvariant.h>
#include <QtPrintSupport/qprinter.h>
diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp
index 228607d7e3..b3dc33895b 100644
--- a/src/printsupport/kernel/qprintengine_win.cpp
+++ b/src/printsupport/kernel/qprintengine_win.cpp
@@ -1719,7 +1719,6 @@ static void draw_text_item_win(const QPointF &pos, const QTextItemInt &ti, HDC h
}
}
-#if !defined(Q_OS_WINCE)
// Scale, rotate and translate here.
XFORM win_xform;
win_xform.eM11 = xform.m11();
@@ -1731,7 +1730,6 @@ static void draw_text_item_win(const QPointF &pos, const QTextItemInt &ti, HDC h
SetGraphicsMode(hdc, GM_ADVANCED);
SetWorldTransform(hdc, &win_xform);
-#endif
if (fast) {
// fast path
@@ -1784,11 +1782,9 @@ static void draw_text_item_win(const QPointF &pos, const QTextItemInt &ti, HDC h
}
}
-#if !defined(Q_OS_WINCE)
win_xform.eM11 = win_xform.eM22 = 1.0;
win_xform.eM12 = win_xform.eM21 = win_xform.eDx = win_xform.eDy = 0.0;
SetWorldTransform(hdc, &win_xform);
-#endif
SelectObject(hdc, old_font);
}
diff --git a/src/printsupport/kernel/qprintengine_win_p.h b/src/printsupport/kernel/qprintengine_win_p.h
index 32da184b08..f2c6eeca4c 100644
--- a/src/printsupport/kernel/qprintengine_win_p.h
+++ b/src/printsupport/kernel/qprintengine_win_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtPrintSupport/private/qtprintsupportglobal_p.h>
#ifndef QT_NO_PRINTER
diff --git a/src/printsupport/kernel/qprinter.h b/src/printsupport/kernel/qprinter.h
index d5c63dbf2c..4650d5432a 100644
--- a/src/printsupport/kernel/qprinter.h
+++ b/src/printsupport/kernel/qprinter.h
@@ -40,11 +40,11 @@
#ifndef QPRINTER_H
#define QPRINTER_H
+#include <QtPrintSupport/qtprintsupportglobal.h>
#include <QtCore/qstring.h>
#include <QtCore/qscopedpointer.h>
#include <QtGui/qpagedpaintdevice.h>
#include <QtGui/qpagelayout.h>
-#include <QtPrintSupport/qtprintsupportglobal.h>
QT_BEGIN_NAMESPACE
diff --git a/src/printsupport/kernel/qprinter_p.h b/src/printsupport/kernel/qprinter_p.h
index d3b869077e..18dfad926c 100644
--- a/src/printsupport/kernel/qprinter_p.h
+++ b/src/printsupport/kernel/qprinter_p.h
@@ -52,7 +52,7 @@
//
-#include "QtCore/qglobal.h"
+#include <QtPrintSupport/private/qtprintsupportglobal_p.h>
#ifndef QT_NO_PRINTER
diff --git a/src/printsupport/kernel/qprinterinfo.h b/src/printsupport/kernel/qprinterinfo.h
index ed22efc503..8bac395ab3 100644
--- a/src/printsupport/kernel/qprinterinfo.h
+++ b/src/printsupport/kernel/qprinterinfo.h
@@ -40,6 +40,7 @@
#ifndef QPRINTERINFO_H
#define QPRINTERINFO_H
+#include <QtPrintSupport/qtprintsupportglobal.h>
#include <QtPrintSupport/qprinter.h>
#include <QtCore/QList>
diff --git a/src/printsupport/kernel/qprinterinfo_p.h b/src/printsupport/kernel/qprinterinfo_p.h
index 5d883d54db..727457a959 100644
--- a/src/printsupport/kernel/qprinterinfo_p.h
+++ b/src/printsupport/kernel/qprinterinfo_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include "QtCore/qglobal.h"
+#include <QtPrintSupport/private/qtprintsupportglobal_p.h>
#ifndef QT_NO_PRINTER
diff --git a/src/printsupport/kernel/qtprintsupportglobal.h b/src/printsupport/kernel/qtprintsupportglobal.h
index 3772cd23b4..c060b98958 100644
--- a/src/printsupport/kernel/qtprintsupportglobal.h
+++ b/src/printsupport/kernel/qtprintsupportglobal.h
@@ -40,7 +40,7 @@
#ifndef QTPRINTSUPPORTGLOBAL_H
#define QTPRINTSUPPORTGLOBAL_H
-#include <QtCore/qglobal.h>
+#include <QtWidgets/qtwidgetsglobal.h>
QT_BEGIN_NAMESPACE
diff --git a/src/printsupport/kernel/qtprintsupportglobal_p.h b/src/printsupport/kernel/qtprintsupportglobal_p.h
new file mode 100644
index 0000000000..2f6b924ed0
--- /dev/null
+++ b/src/printsupport/kernel/qtprintsupportglobal_p.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtPrintSupport module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTPRINTSUPPORTGLOBAL_P_H
+#define QTPRINTSUPPORTGLOBAL_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtPrintSupport/qtprintsupportglobal.h>
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
+
+#endif // QTPRINTSUPPORTGLOBAL_P_H
diff --git a/src/printsupport/widgets/qcupsjobwidget_p.h b/src/printsupport/widgets/qcupsjobwidget_p.h
index 26fc644f65..e08b8b0574 100644
--- a/src/printsupport/widgets/qcupsjobwidget_p.h
+++ b/src/printsupport/widgets/qcupsjobwidget_p.h
@@ -53,6 +53,7 @@
//
//
+#include <QtPrintSupport/private/qtprintsupportglobal_p.h>
#include <ui_qcupsjobwidget.h>
#include <private/qcups_p.h>
diff --git a/src/printsupport/widgets/qprintpreviewwidget.h b/src/printsupport/widgets/qprintpreviewwidget.h
index bc4dd59ea5..dec7092eb1 100644
--- a/src/printsupport/widgets/qprintpreviewwidget.h
+++ b/src/printsupport/widgets/qprintpreviewwidget.h
@@ -40,6 +40,7 @@
#ifndef QPRINTPREVIEWWIDGET_H
#define QPRINTPREVIEWWIDGET_H
+#include <QtPrintSupport/qtprintsupportglobal.h>
#include <QtWidgets/qwidget.h>
#include <QtPrintSupport/qprinter.h>
diff --git a/src/sql/doc/src/qtsql.qdoc b/src/sql/doc/src/qtsql.qdoc
index 9d3a8fbfed..56d714becf 100644
--- a/src/sql/doc/src/qtsql.qdoc
+++ b/src/sql/doc/src/qtsql.qdoc
@@ -51,6 +51,19 @@
QT += sql
\endcode
+ \section1 Licenses and Attributions
+
+ Qt SQL is available under commercial licenses from \l{The Qt Company}.
+ In addition, it is available under the
+ \l{GNU Lesser General Public License, version 3}, or
+ the \l{GNU General Public License, version 2}.
+ See \l{Qt Licensing} for further details.
+
+ Furthermore Qt SQL potentially contains third party
+ modules under following permissive licenses:
+
+ \generatelist{groupsbymodule attributions-qtsql}
+
\section1 Related Information
These are links to the API reference materials and related pages.
diff --git a/src/sql/drivers/db2/qsql_db2.pri b/src/sql/drivers/db2/qsql_db2.pri
deleted file mode 100644
index c9e65e2c2e..0000000000
--- a/src/sql/drivers/db2/qsql_db2.pri
+++ /dev/null
@@ -1,8 +0,0 @@
-HEADERS += $$PWD/qsql_db2_p.h
-SOURCES += $$PWD/qsql_db2.cpp
-
-unix {
- !contains(LIBS, .*db2.*):LIBS += -ldb2
-} else {
- !contains(LIBS, .*db2.*):LIBS += -ldb2cli
-}
diff --git a/src/sql/drivers/drivers.pri b/src/sql/drivers/drivers.pri
deleted file mode 100644
index 87cc0b1d9e..0000000000
--- a/src/sql/drivers/drivers.pri
+++ /dev/null
@@ -1,11 +0,0 @@
-contains(sql-drivers, all):sql-driver += psql mysql odbc oci tds db2 sqlite ibase
-
-contains(sql-drivers, psql):include($$PWD/psql/qsql_psql.pri)
-contains(sql-drivers, mysql):include($$PWD/mysql/qsql_mysql.pri)
-contains(sql-drivers, odbc):include($$PWD/odbc/qsql_odbc.pri)
-contains(sql-drivers, oci):include($$PWD/oci/qsql_oci.pri)
-contains(sql-drivers, tds):include($$PWD/tds/qsql_tds.pri)
-contains(sql-drivers, db2):include($$PWD/db2/qsql_db2.pri)
-contains(sql-drivers, ibase):include($$PWD/ibase/qsql_ibase.pri)
-contains(sql-drivers, sqlite2):include($$PWD/sqlite2/qsql_sqlite2.pri)
-contains(sql-drivers, sqlite):include($$PWD/sqlite/qsql_sqlite.pri)
diff --git a/src/sql/drivers/ibase/qsql_ibase.pri b/src/sql/drivers/ibase/qsql_ibase.pri
deleted file mode 100644
index ef3b68d34e..0000000000
--- a/src/sql/drivers/ibase/qsql_ibase.pri
+++ /dev/null
@@ -1,10 +0,0 @@
-HEADERS += $$PWD/qsql_ibase_p.h
-SOURCES += $$PWD/qsql_ibase.cpp
-
-unix {
- !contains(LIBS, .*gds.*):!contains(LIBS, .*libfb.*):LIBS += -lgds
-} else {
- !contains(LIBS, .*gds.*):!contains(LIBS, .*fbclient.*) {
- LIBS += -lgds32_ms
- }
-}
diff --git a/src/sql/drivers/mysql/qsql_mysql.pri b/src/sql/drivers/mysql/qsql_mysql.pri
deleted file mode 100644
index 3cfb6144a1..0000000000
--- a/src/sql/drivers/mysql/qsql_mysql.pri
+++ /dev/null
@@ -1,16 +0,0 @@
-HEADERS += $$PWD/qsql_mysql_p.h
-SOURCES += $$PWD/qsql_mysql.cpp
-
-QMAKE_CXXFLAGS *= $$QT_CFLAGS_MYSQL
-LIBS += $$QT_LFLAGS_MYSQL
-
-unix {
- isEmpty(QT_LFLAGS_MYSQL) {
- !contains(LIBS, .*mysqlclient.*):!contains(LIBS, .*mysqld.*) {
- use_libmysqlclient_r:LIBS += -lmysqlclient_r
- else:LIBS += -lmysqlclient
- }
- }
-} else {
- !contains(LIBS, .*mysql.*):!contains(LIBS, .*mysqld.*):LIBS += -llibmysql
-}
diff --git a/src/sql/drivers/oci/qsql_oci.pri b/src/sql/drivers/oci/qsql_oci.pri
deleted file mode 100644
index 66ccdb1abb..0000000000
--- a/src/sql/drivers/oci/qsql_oci.pri
+++ /dev/null
@@ -1,9 +0,0 @@
-HEADERS += $$PWD/qsql_oci_p.h
-SOURCES += $$PWD/qsql_oci.cpp
-
-unix {
- !contains(LIBS, .*clnts.*):LIBS += -lclntsh
-} else {
- LIBS *= -loci
-}
-mac:QMAKE_LFLAGS += -Wl,-flat_namespace,-U,_environ
diff --git a/src/sql/drivers/odbc/qsql_odbc.pri b/src/sql/drivers/odbc/qsql_odbc.pri
deleted file mode 100644
index b206df37c3..0000000000
--- a/src/sql/drivers/odbc/qsql_odbc.pri
+++ /dev/null
@@ -1,12 +0,0 @@
-HEADERS += $$PWD/qsql_odbc_p.h
-SOURCES += $$PWD/qsql_odbc.cpp
-
-unix {
- DEFINES += UNICODE
- !contains(LIBS, .*odbc.*) {
- macx:LIBS += -liodbc
- else:LIBS += $$QT_LFLAGS_ODBC
- }
-} else {
- LIBS *= -lodbc32
-}
diff --git a/src/sql/drivers/psql/qsql_psql.pri b/src/sql/drivers/psql/qsql_psql.pri
deleted file mode 100644
index 867be3edb8..0000000000
--- a/src/sql/drivers/psql/qsql_psql.pri
+++ /dev/null
@@ -1,10 +0,0 @@
-HEADERS += $$PWD/qsql_psql_p.h
-SOURCES += $$PWD/qsql_psql.cpp
-
-unix|mingw {
- LIBS += $$QT_LFLAGS_PSQL
- !contains(LIBS, .*pq.*):LIBS += -lpq
- QMAKE_CXXFLAGS *= $$QT_CFLAGS_PSQL
-} else {
- !contains(LIBS, .*pq.*):LIBS += -llibpq -lws2_32 -ladvapi32
-}
diff --git a/src/sql/drivers/sqlite/qsql_sqlite.pri b/src/sql/drivers/sqlite/qsql_sqlite.pri
deleted file mode 100644
index e323f2eba5..0000000000
--- a/src/sql/drivers/sqlite/qsql_sqlite.pri
+++ /dev/null
@@ -1,9 +0,0 @@
-HEADERS += $$PWD/qsql_sqlite_p.h
-SOURCES += $$PWD/qsql_sqlite.cpp
-
-!system-sqlite:!contains(LIBS, .*sqlite3.*) {
- include($$PWD/../../../3rdparty/sqlite.pri)
-} else {
- LIBS += $$QT_LFLAGS_SQLITE
- QMAKE_CXXFLAGS *= $$QT_CFLAGS_SQLITE
-}
diff --git a/src/sql/drivers/sqlite2/qsql_sqlite2.pri b/src/sql/drivers/sqlite2/qsql_sqlite2.pri
deleted file mode 100644
index 5baba30db0..0000000000
--- a/src/sql/drivers/sqlite2/qsql_sqlite2.pri
+++ /dev/null
@@ -1,4 +0,0 @@
-HEADERS += $$PWD/qsql_sqlite2_p.h
-SOURCES += $$PWD/qsql_sqlite2.cpp
-
-!contains(LIBS, .*sqlite.*):LIBS += -lsqlite
diff --git a/src/sql/drivers/tds/qsql_tds.pri b/src/sql/drivers/tds/qsql_tds.pri
deleted file mode 100644
index 8c528c154d..0000000000
--- a/src/sql/drivers/tds/qsql_tds.pri
+++ /dev/null
@@ -1,10 +0,0 @@
-HEADERS += $$PWD/qsql_tds_p.h
-SOURCES += $$PWD/qsql_tds.cpp
-
-unix|mingw: {
- LIBS += $$QT_LFLAGS_TDS
- !contains(LIBS, .*sybdb.*):LIBS += -lsybdb
- QMAKE_CXXFLAGS *= $$QT_CFLAGS_TDS
-} else {
- LIBS *= -lNTWDBLIB
-}
diff --git a/src/sql/kernel/kernel.pri b/src/sql/kernel/kernel.pri
index dad3b46781..fd6ace8277 100644
--- a/src/sql/kernel/kernel.pri
+++ b/src/sql/kernel/kernel.pri
@@ -1,4 +1,5 @@
-HEADERS += kernel/qsql.h \
+HEADERS += kernel/qtsqlglobal.h \
+ kernel/qtsqlglobal_p.h \
kernel/qsqlquery.h \
kernel/qsqldatabase.h \
kernel/qsqlfield.h \
diff --git a/src/sql/kernel/qsqlcachedresult_p.h b/src/sql/kernel/qsqlcachedresult_p.h
index cad581d755..9bcfd49f1a 100644
--- a/src/sql/kernel/qsqlcachedresult_p.h
+++ b/src/sql/kernel/qsqlcachedresult_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtSql/private/qtsqlglobal_p.h>
#include "QtSql/qsqlresult.h"
#include "QtSql/private/qsqlresult_p.h"
diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp
index 62e1b6a7a5..d91e502b96 100644
--- a/src/sql/kernel/qsqldatabase.cpp
+++ b/src/sql/kernel/qsqldatabase.cpp
@@ -39,51 +39,6 @@
#include "qsqldatabase.h"
#include "qsqlquery.h"
-
-#ifdef Q_OS_WIN32
-// Conflicting declarations of LPCBYTE in sqlfront.h and winscard.h
-#define _WINSCARD_H_
-#endif
-
-#ifdef QT_SQL_PSQL
-#include "../drivers/psql/qsql_psql_p.h"
-#endif
-#ifdef QT_SQL_MYSQL
-#include "../drivers/mysql/qsql_mysql_p.h"
-#endif
-#ifdef QT_SQL_ODBC
-#include "../drivers/odbc/qsql_odbc_p.h"
-#endif
-#ifdef QT_SQL_OCI
-#include "../drivers/oci/qsql_oci_p.h"
-#endif
-#ifdef QT_SQL_TDS
-// conflicting RETCODE typedef between odbc and freetds
-#define RETCODE DBRETCODE
-#include "../drivers/tds/qsql_tds_p.h"
-#undef RETCODE
-#endif
-#ifdef QT_SQL_DB2
-#include "../drivers/db2/qsql_db2_p.h"
-#endif
-#ifdef QT_SQL_SQLITE
-#include "../drivers/sqlite/qsql_sqlite_p.h"
-#endif
-#ifdef QT_SQL_SQLITE2
-#include "../drivers/sqlite2/qsql_sqlite2_p.h"
-#endif
-#ifdef QT_SQL_IBASE
-#undef SQL_FLOAT // avoid clash with ODBC
-#undef SQL_DOUBLE
-#undef SQL_TIMESTAMP
-#undef SQL_TYPE_TIME
-#undef SQL_TYPE_DATE
-#undef SQL_DATE
-#define SCHAR IBASE_SCHAR // avoid clash with ODBC (older versions of ibase.h with Firebird)
-#include "../drivers/ibase/qsql_ibase_p.h"
-#undef SCHAR
-#endif
-
#include "qdebug.h"
#include "qcoreapplication.h"
#include "qreadwritelock.h"
@@ -542,39 +497,6 @@ QStringList QSqlDatabase::drivers()
{
QStringList list;
-#ifdef QT_SQL_PSQL
- list << QLatin1String("QPSQL7");
- list << QLatin1String("QPSQL");
-#endif
-#ifdef QT_SQL_MYSQL
- list << QLatin1String("QMYSQL3");
- list << QLatin1String("QMYSQL");
-#endif
-#ifdef QT_SQL_ODBC
- list << QLatin1String("QODBC3");
- list << QLatin1String("QODBC");
-#endif
-#ifdef QT_SQL_OCI
- list << QLatin1String("QOCI8");
- list << QLatin1String("QOCI");
-#endif
-#ifdef QT_SQL_TDS
- list << QLatin1String("QTDS7");
- list << QLatin1String("QTDS");
-#endif
-#ifdef QT_SQL_DB2
- list << QLatin1String("QDB2");
-#endif
-#ifdef QT_SQL_SQLITE
- list << QLatin1String("QSQLITE");
-#endif
-#ifdef QT_SQL_SQLITE2
- list << QLatin1String("QSQLITE2");
-#endif
-#ifdef QT_SQL_IBASE
- list << QLatin1String("QIBASE");
-#endif
-
if (QFactoryLoader *fl = loader()) {
typedef QMultiMap<int, QString> PluginKeyMap;
typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;
@@ -726,45 +648,6 @@ void QSqlDatabasePrivate::init(const QString &type)
drvName = type;
if (!driver) {
-#ifdef QT_SQL_PSQL
- if (type == QLatin1String("QPSQL") || type == QLatin1String("QPSQL7"))
- driver = new QPSQLDriver();
-#endif
-#ifdef QT_SQL_MYSQL
- if (type == QLatin1String("QMYSQL") || type == QLatin1String("QMYSQL3"))
- driver = new QMYSQLDriver();
-#endif
-#ifdef QT_SQL_ODBC
- if (type == QLatin1String("QODBC") || type == QLatin1String("QODBC3"))
- driver = new QODBCDriver();
-#endif
-#ifdef QT_SQL_OCI
- if (type == QLatin1String("QOCI") || type == QLatin1String("QOCI8"))
- driver = new QOCIDriver();
-#endif
-#ifdef QT_SQL_TDS
- if (type == QLatin1String("QTDS") || type == QLatin1String("QTDS7"))
- driver = new QTDSDriver();
-#endif
-#ifdef QT_SQL_DB2
- if (type == QLatin1String("QDB2"))
- driver = new QDB2Driver();
-#endif
-#ifdef QT_SQL_SQLITE
- if (type == QLatin1String("QSQLITE"))
- driver = new QSQLiteDriver();
-#endif
-#ifdef QT_SQL_SQLITE2
- if (type == QLatin1String("QSQLITE2"))
- driver = new QSQLite2Driver();
-#endif
-#ifdef QT_SQL_IBASE
- if (type == QLatin1String("QIBASE"))
- driver = new QIBaseDriver();
-#endif
- }
-
- if (!driver) {
DriverDict dict = QSqlDatabasePrivate::driverDict();
for (DriverDict::const_iterator it = dict.constBegin();
it != dict.constEnd() && !driver; ++it) {
diff --git a/src/sql/kernel/qsqldatabase.h b/src/sql/kernel/qsqldatabase.h
index ad071a6954..0b4aca8cdd 100644
--- a/src/sql/kernel/qsqldatabase.h
+++ b/src/sql/kernel/qsqldatabase.h
@@ -40,8 +40,8 @@
#ifndef QSQLDATABASE_H
#define QSQLDATABASE_H
+#include <QtSql/qtsqlglobal.h>
#include <QtCore/qstring.h>
-#include <QtSql/qsql.h>
QT_BEGIN_NAMESPACE
diff --git a/src/sql/kernel/qsqldriver.h b/src/sql/kernel/qsqldriver.h
index 222b848d63..1296bd5d51 100644
--- a/src/sql/kernel/qsqldriver.h
+++ b/src/sql/kernel/qsqldriver.h
@@ -40,10 +40,10 @@
#ifndef QSQLDRIVER_H
#define QSQLDRIVER_H
+#include <QtSql/qtsqlglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qstring.h>
#include <QtCore/qstringlist.h>
-#include <QtSql/qsql.h>
QT_BEGIN_NAMESPACE
diff --git a/src/sql/kernel/qsqldriver_p.h b/src/sql/kernel/qsqldriver_p.h
index 3a01ae54ed..c8ec961124 100644
--- a/src/sql/kernel/qsqldriver_p.h
+++ b/src/sql/kernel/qsqldriver_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtSql/private/qtsqlglobal_p.h>
#include "private/qobject_p.h"
#include "qsqldriver.h"
#include "qsqlerror.h"
diff --git a/src/sql/kernel/qsqldriverplugin.h b/src/sql/kernel/qsqldriverplugin.h
index cfdf1f32ee..c0f4c00943 100644
--- a/src/sql/kernel/qsqldriverplugin.h
+++ b/src/sql/kernel/qsqldriverplugin.h
@@ -40,9 +40,9 @@
#ifndef QSQLDRIVERPLUGIN_H
#define QSQLDRIVERPLUGIN_H
+#include <QtSql/qtsqlglobal.h>
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
-#include <QtSql/qsql.h>
QT_BEGIN_NAMESPACE
diff --git a/src/sql/kernel/qsqlerror.h b/src/sql/kernel/qsqlerror.h
index 0d241e9578..0ccd32159d 100644
--- a/src/sql/kernel/qsqlerror.h
+++ b/src/sql/kernel/qsqlerror.h
@@ -40,8 +40,8 @@
#ifndef QSQLERROR_H
#define QSQLERROR_H
+#include <QtSql/qtsqlglobal.h>
#include <QtCore/qstring.h>
-#include <QtSql/qsql.h>
QT_BEGIN_NAMESPACE
diff --git a/src/sql/kernel/qsqlfield.h b/src/sql/kernel/qsqlfield.h
index 3bf29a8db9..0d8c51f801 100644
--- a/src/sql/kernel/qsqlfield.h
+++ b/src/sql/kernel/qsqlfield.h
@@ -40,9 +40,9 @@
#ifndef QSQLFIELD_H
#define QSQLFIELD_H
+#include <QtSql/qtsqlglobal.h>
#include <QtCore/qvariant.h>
#include <QtCore/qstring.h>
-#include <QtSql/qsql.h>
QT_BEGIN_NAMESPACE
diff --git a/src/sql/kernel/qsqlindex.h b/src/sql/kernel/qsqlindex.h
index 83c5de2cec..b6fbdbbaaf 100644
--- a/src/sql/kernel/qsqlindex.h
+++ b/src/sql/kernel/qsqlindex.h
@@ -40,6 +40,7 @@
#ifndef QSQLINDEX_H
#define QSQLINDEX_H
+#include <QtSql/qtsqlglobal.h>
#include <QtSql/qsqlrecord.h>
#include <QtCore/qstring.h>
#include <QtCore/qvector.h>
diff --git a/src/sql/kernel/qsqlnulldriver_p.h b/src/sql/kernel/qsqlnulldriver_p.h
index 766323e697..92d8d30485 100644
--- a/src/sql/kernel/qsqlnulldriver_p.h
+++ b/src/sql/kernel/qsqlnulldriver_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtSql/private/qtsqlglobal_p.h>
#include "QtCore/qvariant.h"
#include "QtSql/qsqldriver.h"
#include "QtSql/qsqlerror.h"
diff --git a/src/sql/kernel/qsqlquery.h b/src/sql/kernel/qsqlquery.h
index 243e4a046e..cbbc25c4ec 100644
--- a/src/sql/kernel/qsqlquery.h
+++ b/src/sql/kernel/qsqlquery.h
@@ -40,7 +40,7 @@
#ifndef QSQLQUERY_H
#define QSQLQUERY_H
-#include <QtSql/qsql.h>
+#include <QtSql/qtsqlglobal.h>
#include <QtSql/qsqldatabase.h>
#include <QtCore/qstring.h>
diff --git a/src/sql/kernel/qsqlrecord.h b/src/sql/kernel/qsqlrecord.h
index 71c1b8a38f..94631bafd9 100644
--- a/src/sql/kernel/qsqlrecord.h
+++ b/src/sql/kernel/qsqlrecord.h
@@ -40,8 +40,8 @@
#ifndef QSQLRECORD_H
#define QSQLRECORD_H
+#include <QtSql/qtsqlglobal.h>
#include <QtCore/qstring.h>
-#include <QtSql/qsql.h>
QT_BEGIN_NAMESPACE
diff --git a/src/sql/kernel/qsqlresult.h b/src/sql/kernel/qsqlresult.h
index c6611c925f..d4192bfad2 100644
--- a/src/sql/kernel/qsqlresult.h
+++ b/src/sql/kernel/qsqlresult.h
@@ -40,9 +40,9 @@
#ifndef QSQLRESULT_H
#define QSQLRESULT_H
+#include <QtSql/qtsqlglobal.h>
#include <QtCore/qvariant.h>
#include <QtCore/qvector.h>
-#include <QtSql/qsql.h>
// for testing:
class tst_QSqlQuery;
diff --git a/src/sql/kernel/qsqlresult_p.h b/src/sql/kernel/qsqlresult_p.h
index 4fb2bcc1e1..7b312800c1 100644
--- a/src/sql/kernel/qsqlresult_p.h
+++ b/src/sql/kernel/qsqlresult_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtSql/private/qtsqlglobal_p.h>
#include <QtCore/qpointer.h>
#include "qsqlerror.h"
#include "qsqlresult.h"
diff --git a/src/sql/kernel/qsql.h b/src/sql/kernel/qtsqlglobal.h
index 02ebae7adc..d421adc84b 100644
--- a/src/sql/kernel/qsql.h
+++ b/src/sql/kernel/qtsqlglobal.h
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QSQL_H
-#define QSQL_H
+#ifndef QTSQLGLOBAL_H
+#define QTSQLGLOBAL_H
#include <QtCore/qglobal.h>
diff --git a/src/sql/kernel/qtsqlglobal_p.h b/src/sql/kernel/qtsqlglobal_p.h
new file mode 100644
index 0000000000..ab45f6cd38
--- /dev/null
+++ b/src/sql/kernel/qtsqlglobal_p.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtSql module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTSQLGLOBAL_P_H
+#define QTSQLGLOBAL_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtSql/qtsqlglobal.h>
+#include <QtCore/private/qglobal_p.h>
+
+#endif // QTSQLGLOBAL_P_H
diff --git a/src/sql/models/qsqlquerymodel.h b/src/sql/models/qsqlquerymodel.h
index d7c41196e5..f786f71300 100644
--- a/src/sql/models/qsqlquerymodel.h
+++ b/src/sql/models/qsqlquerymodel.h
@@ -40,6 +40,7 @@
#ifndef QSQLQUERYMODEL_H
#define QSQLQUERYMODEL_H
+#include <QtSql/qtsqlglobal.h>
#include <QtCore/qabstractitemmodel.h>
#include <QtSql/qsqldatabase.h>
diff --git a/src/sql/models/qsqlquerymodel_p.h b/src/sql/models/qsqlquerymodel_p.h
index 7b35ba5197..ffc34b9f95 100644
--- a/src/sql/models/qsqlquerymodel_p.h
+++ b/src/sql/models/qsqlquerymodel_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtSql/private/qtsqlglobal_p.h>
#include "private/qabstractitemmodel_p.h"
#include "QtSql/qsqlerror.h"
#include "QtSql/qsqlquery.h"
diff --git a/src/sql/models/qsqlrelationaldelegate.h b/src/sql/models/qsqlrelationaldelegate.h
index 94097a244d..e98bf28d3b 100644
--- a/src/sql/models/qsqlrelationaldelegate.h
+++ b/src/sql/models/qsqlrelationaldelegate.h
@@ -40,6 +40,8 @@
#ifndef QSQLRELATIONALDELEGATE_H
#define QSQLRELATIONALDELEGATE_H
+#include <QtSql/qtsqlglobal.h>
+
#ifdef QT_WIDGETS_LIB
#include <QtWidgets/qitemdelegate.h>
diff --git a/src/sql/models/qsqlrelationaltablemodel.h b/src/sql/models/qsqlrelationaltablemodel.h
index 66da87cb83..4da460389c 100644
--- a/src/sql/models/qsqlrelationaltablemodel.h
+++ b/src/sql/models/qsqlrelationaltablemodel.h
@@ -40,6 +40,7 @@
#ifndef QSQLRELATIONALTABLEMODEL_H
#define QSQLRELATIONALTABLEMODEL_H
+#include <QtSql/qtsqlglobal.h>
#include <QtSql/qsqltablemodel.h>
QT_BEGIN_NAMESPACE
diff --git a/src/sql/models/qsqltablemodel.h b/src/sql/models/qsqltablemodel.h
index d88f195c2b..6a62c6993d 100644
--- a/src/sql/models/qsqltablemodel.h
+++ b/src/sql/models/qsqltablemodel.h
@@ -40,6 +40,7 @@
#ifndef QSQLTABLEMODEL_H
#define QSQLTABLEMODEL_H
+#include <QtSql/qtsqlglobal.h>
#include <QtSql/qsqldatabase.h>
#include <QtSql/qsqlquerymodel.h>
diff --git a/src/sql/models/qsqltablemodel_p.h b/src/sql/models/qsqltablemodel_p.h
index b0ed38b26f..4a79d5db36 100644
--- a/src/sql/models/qsqltablemodel_p.h
+++ b/src/sql/models/qsqltablemodel_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtSql/private/qtsqlglobal_p.h>
#include "private/qsqlquerymodel_p.h"
#include "QtSql/qsqlindex.h"
#include "QtCore/qmap.h"
diff --git a/src/sql/sql.pro b/src/sql/sql.pro
index 8846f03d78..133bf831c8 100644
--- a/src/sql/sql.pro
+++ b/src/sql/sql.pro
@@ -11,7 +11,6 @@ PRECOMPILED_HEADER = ../corelib/global/qt_pch.h
SQL_P = sql
include(kernel/kernel.pri)
-include(drivers/drivers.pri)
include(models/models.pri)
MODULE_PLUGIN_TYPES = \
diff --git a/src/src.pro b/src/src.pro
index 3d185408f8..c4da871abe 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -132,9 +132,9 @@ src_plugins.depends = src_sql src_xml src_network
src_android.subdir = $$PWD/android
# this order is important
-contains(QT_CONFIG, zlib)|cross_compile {
+!contains(QT_CONFIG, system-zlib)|cross_compile {
SUBDIRS += src_qtzlib
- contains(QT_CONFIG, zlib) {
+ !contains(QT_CONFIG, system-zlib) {
src_3rdparty_libpng.depends += src_corelib
src_3rdparty_freetype.depends += src_corelib
}
@@ -159,11 +159,11 @@ contains(QT_CONFIG, dbus) {
}
contains(QT_CONFIG, concurrent):SUBDIRS += src_concurrent
!contains(QT_CONFIG, no-gui) {
- contains(QT_CONFIG, harfbuzz) {
+ contains(QT_CONFIG, harfbuzz):!contains(QT_CONFIG, system-harfbuzz) {
SUBDIRS += src_3rdparty_harfbuzzng
src_gui.depends += src_3rdparty_harfbuzzng
}
- win32:contains(QT_CONFIG, angle)|contains(QT_CONFIG, dynamicgl) {
+ contains(QT_CONFIG, angle) {
SUBDIRS += src_angle
src_gui.depends += src_angle
}
@@ -172,7 +172,7 @@ contains(QT_CONFIG, concurrent):SUBDIRS += src_concurrent
src_3rdparty_freetype.depends += src_3rdparty_libpng
src_gui.depends += src_3rdparty_libpng
}
- contains(QT_CONFIG, freetype) {
+ contains(QT_CONFIG, freetype):!contains(QT_CONFIG, system-freetype) {
SUBDIRS += src_3rdparty_freetype
src_platformsupport.depends += src_3rdparty_freetype
}
diff --git a/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp b/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp
index 2cb174022d..2c57550c3d 100644
--- a/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp
+++ b/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp
@@ -241,17 +241,18 @@ QTest::qWaitForWindowShown(&widget);
//! [24]
//! [25]
+QTouchDevice *dev = QTest::createTouchDevice();
QWidget widget;
-QTest::touchEvent(&widget)
+QTest::touchEvent(&widget, dev)
.press(0, QPoint(10, 10));
-QTest::touchEvent(&widget)
+QTest::touchEvent(&widget, dev)
.stationary(0)
.press(1, QPoint(40, 10));
-QTest::touchEvent(&widget)
+QTest::touchEvent(&widget, dev)
.move(0, QPoint(12, 12))
.move(1, QPoint(45, 5));
-QTest::touchEvent(&widget)
+QTest::touchEvent(&widget, dev)
.release(0, QPoint(12, 12))
.release(1, QPoint(45, 5));
//! [25]
diff --git a/src/testlib/qabstracttestlogger.cpp b/src/testlib/qabstracttestlogger.cpp
index 72b5eb3ed7..8337600fa1 100644
--- a/src/testlib/qabstracttestlogger.cpp
+++ b/src/testlib/qabstracttestlogger.cpp
@@ -62,7 +62,7 @@ QAbstractTestLogger::QAbstractTestLogger(const char *filename)
stream = stdout;
return;
}
-#if defined(_MSC_VER) && _MSC_VER >= 1400 && !defined(Q_OS_WINCE)
+#if defined(_MSC_VER)
if (::fopen_s(&stream, filename, "wt")) {
#else
stream = ::fopen(filename, "wt");
diff --git a/src/testlib/qbenchmarkmetric.cpp b/src/testlib/qbenchmarkmetric.cpp
index 0a9072907f..0ba55dbeb7 100644
--- a/src/testlib/qbenchmarkmetric.cpp
+++ b/src/testlib/qbenchmarkmetric.cpp
@@ -56,6 +56,7 @@
\value CPUTicks CPU time
\value CPUMigrations Process migrations between CPUs
\value CPUCycles CPU cycles
+ \value RefCPUCycles Reference CPU cycles
\value BusCycles Bus cycles
\value StalledCycles Cycles stalled
\value InstructionReads Instruction reads
@@ -108,6 +109,8 @@ const char * QTest::benchmarkMetricName(QBenchmarkMetric metric)
return "CPUMigrations";
case CPUCycles:
return "CPUCycles";
+ case RefCPUCycles:
+ return "RefCPUCycles";
case BusCycles:
return "BusCycles";
case StalledCycles:
@@ -180,6 +183,8 @@ const char * QTest::benchmarkMetricUnit(QBenchmarkMetric metric)
return "CPU migrations";
case CPUCycles:
return "CPU cycles";
+ case RefCPUCycles:
+ return "Reference CPU cycles";
case BusCycles:
return "bus cycles";
case StalledCycles:
diff --git a/src/testlib/qbenchmarkmetric.h b/src/testlib/qbenchmarkmetric.h
index 44bf14b9b6..6e423473b1 100644
--- a/src/testlib/qbenchmarkmetric.h
+++ b/src/testlib/qbenchmarkmetric.h
@@ -78,7 +78,8 @@ enum QBenchmarkMetric {
MinorPageFaults,
MajorPageFaults,
AlignmentFaults,
- EmulationFaults
+ EmulationFaults,
+ RefCPUCycles,
};
}
diff --git a/src/testlib/qbenchmarkperfevents.cpp b/src/testlib/qbenchmarkperfevents.cpp
index 587d3e0124..d6db40ce52 100644
--- a/src/testlib/qbenchmarkperfevents.cpp
+++ b/src/testlib/qbenchmarkperfevents.cpp
@@ -153,6 +153,7 @@ bool QBenchmarkPerfEventsMeasurer::isAvailable()
Event type Event counter Unit Name and aliases
HARDWARE CPU_CYCLES CPUCycles cycles cpu-cycles
+ HARDWARE REF_CPU_CYCLES RefCPUCycles ref-cycles
HARDWARE INSTRUCTIONS Instructions instructions
HARDWARE CACHE_REFERENCES CacheReferences cache-references
HARDWARE CACHE_MISSES CacheMisses cache-misses
@@ -321,6 +322,7 @@ static const char eventlist_strings[] =
"migrations\0"
"minor-faults\0"
"page-faults\0"
+ "ref-cycles\0"
"stalled-cycles-backend\0"
"stalled-cycles-frontend\0"
"task-clock\0"
@@ -407,9 +409,10 @@ static const Events eventlist[] = {
{ 1256, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_CPU_MIGRATIONS, QTest::CPUMigrations },
{ 1267, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS_MIN, QTest::MinorPageFaults },
{ 1280, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_PAGE_FAULTS, QTest::PageFaults },
- { 1292, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND, QTest::StalledCycles },
- { 1315, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND, QTest::StalledCycles },
- { 1339, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_TASK_CLOCK, QTest::WalltimeMilliseconds },
+ { 1292, PERF_TYPE_HARDWARE, PERF_COUNT_HW_REF_CPU_CYCLES, QTest::RefCPUCycles },
+ { 1303, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_BACKEND, QTest::StalledCycles },
+ { 1326, PERF_TYPE_HARDWARE, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND, QTest::StalledCycles },
+ { 1350, PERF_TYPE_SOFTWARE, PERF_COUNT_SW_TASK_CLOCK, QTest::WalltimeMilliseconds },
{ 0, PERF_TYPE_MAX, 0, QTest::Events }
};
/* -- END GENERATED CODE -- */
diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp
index a286246acd..dc20d922e5 100644
--- a/src/testlib/qplaintestlogger.cpp
+++ b/src/testlib/qplaintestlogger.cpp
@@ -49,10 +49,6 @@
#include <stdlib.h>
#include <string.h>
-#ifdef Q_OS_WINCE
-#include <QtCore/QString>
-#endif
-
#ifdef min // windows.h without NOMINMAX is included by the benchmark headers.
# undef min
#endif
@@ -215,16 +211,7 @@ Q_CORE_EXPORT bool qt_logging_to_console(); // defined in qlogging.cpp
void QPlainTestLogger::outputMessage(const char *str)
{
-#if defined(Q_OS_WINCE)
- QString strUtf16 = QString::fromLocal8Bit(str);
- const int maxOutputLength = 255;
- do {
- QString tmp = strUtf16.left(maxOutputLength);
- OutputDebugString((wchar_t*)tmp.utf16());
- strUtf16.remove(0, maxOutputLength);
- } while (!strUtf16.isEmpty());
- if (stream != stdout)
-#elif defined(Q_OS_WIN)
+#if defined(Q_OS_WIN)
// log to system log only if output is not redirected, and no console is attached
if (!qt_logging_to_console() && stream == stdout) {
OutputDebugStringA(str);
diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h
index cf8dee4646..63e79c777f 100644
--- a/src/testlib/qtest.h
+++ b/src/testlib/qtest.h
@@ -212,6 +212,11 @@ template<> inline char *toString(const QHostAddress &addr)
}
#endif
+inline char *toString(std::nullptr_t)
+{
+ return toString(QLatin1String("nullptr"));
+}
+
template<>
inline bool qCompare(QString const &t1, QLatin1String const &t2, const char *actual,
const char *expected, const char *file, int line)
diff --git a/src/testlib/qtestblacklist.cpp b/src/testlib/qtestblacklist.cpp
index 05ad5cef5b..1fa76a692a 100644
--- a/src/testlib/qtestblacklist.cpp
+++ b/src/testlib/qtestblacklist.cpp
@@ -103,6 +103,9 @@ static QSet<QByteArray> keywords()
#ifdef Q_OS_IOS
<< "ios"
#endif
+#ifdef Q_OS_TVOS
+ << "tvos"
+#endif
#ifdef Q_OS_ANDROID
<< "android"
#endif
@@ -112,9 +115,6 @@ static QSet<QByteArray> keywords()
#ifdef Q_OS_WINRT
<< "winrt"
#endif
-#ifdef Q_OS_WINCE
- << "wince"
-#endif
#if QT_POINTER_SIZE == 8
<< "64bit"
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 703af6b677..e5dd0d694a 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -87,11 +87,9 @@
#endif
#ifdef Q_OS_WIN
-#ifndef Q_OS_WINCE
# if !defined(Q_CC_MINGW) || (defined(Q_CC_MINGW) && defined(__MINGW64_VERSION_MAJOR))
# include <crtdbg.h>
# endif
-#endif
#include <windows.h> // for Sleep
#endif
#ifdef Q_OS_UNIX
@@ -111,6 +109,36 @@ QT_BEGIN_NAMESPACE
using QtMiscUtils::toHexUpper;
using QtMiscUtils::fromHex;
+static bool debuggerPresent()
+{
+#if defined(Q_OS_LINUX)
+ int fd = open("/proc/self/status", O_RDONLY);
+ if (fd == -1)
+ return false;
+ char buffer[2048];
+ ssize_t size = read(fd, buffer, sizeof(buffer) - 1);
+ if (size == -1) {
+ close(fd);
+ return false;
+ }
+ buffer[size] = 0;
+ const char tracerPidToken[] = "\nTracerPid:";
+ char *tracerPid = strstr(buffer, tracerPidToken);
+ if (!tracerPid) {
+ close(fd);
+ return false;
+ }
+ tracerPid += sizeof(tracerPidToken);
+ long int pid = strtol(tracerPid, &tracerPid, 10);
+ close(fd);
+ return pid != 0;
+#elif defined(Q_OS_WIN)
+ return IsDebuggerPresent();
+#else
+ // TODO
+ return false;
+#endif
+}
static void stackTrace()
{
@@ -118,6 +146,10 @@ static void stackTrace()
const int disableStackDump = qEnvironmentVariableIntValue("QTEST_DISABLE_STACK_DUMP", &ok);
if (ok && disableStackDump == 1)
return;
+
+ if (debuggerPresent())
+ return;
+
#ifdef Q_OS_LINUX
fprintf(stderr, "\n========= Received signal, dumping stack ==============\n");
char cmd[512];
@@ -1251,37 +1283,6 @@ char *toPrettyUnicode(const ushort *p, int length)
return buffer.take();
}
-static bool debuggerPresent()
-{
-#if defined(Q_OS_LINUX)
- int fd = open("/proc/self/status", O_RDONLY);
- if (fd == -1)
- return false;
- char buffer[2048];
- ssize_t size = read(fd, buffer, sizeof(buffer) - 1);
- if (size == -1) {
- close(fd);
- return false;
- }
- buffer[size] = 0;
- const char tracerPidToken[] = "\nTracerPid:";
- char *tracerPid = strstr(buffer, tracerPidToken);
- if (!tracerPid) {
- close(fd);
- return false;
- }
- tracerPid += sizeof(tracerPidToken);
- long int pid = strtol(tracerPid, &tracerPid, 10);
- close(fd);
- return pid != 0;
-#elif defined(Q_OS_WIN)
- return IsDebuggerPresent();
-#else
- // TODO
- return false;
-#endif
-}
-
void TestMethods::invokeTests(QObject *testObject) const
{
const QMetaObject *metaObject = testObject->metaObject();
@@ -1385,7 +1386,9 @@ FatalSignalHandler::FatalSignalHandler()
act.sa_flags = SA_RESETHAND;
#endif
-#ifdef SA_ONSTACK
+// tvOS/watchOS both define SA_ONSTACK (in sys/signal.h) but mark sigaltstack() as
+// unavailable (__WATCHOS_PROHIBITED __TVOS_PROHIBITED in signal.h)
+#if defined(SA_ONSTACK) && !defined(Q_OS_TVOS)
// Let the signal handlers use an alternate stack
// This is necessary if SIGSEGV is to catch a stack overflow
# if defined(Q_CC_GNU) && defined(Q_OF_ELF)
@@ -1451,7 +1454,7 @@ FatalSignalHandler::~FatalSignalHandler()
} // namespace
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
// Helper class for resolving symbol names by dynamically loading "dbghelp.dll".
class DebugSymbolResolver
@@ -1589,7 +1592,7 @@ static LONG WINAPI windowsFaultHandler(struct _EXCEPTION_POINTERS *exInfo)
return EXCEPTION_EXECUTE_HANDLER;
}
-#endif // Q_OS_WIN) && !Q_OS_WINCE && !Q_OS_WINRT
+#endif // Q_OS_WIN) && !Q_OS_WINRT
static void initEnvironment()
{
@@ -1681,7 +1684,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
qtest_qParseArgs(argc, argv, false);
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
if (!noCrashHandler) {
# ifndef Q_CC_MINGW
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG);
@@ -1691,7 +1694,7 @@ int QTest::qExec(QObject *testObject, int argc, char **argv)
SetUnhandledExceptionFilter(windowsFaultHandler);
# endif
} // !noCrashHandler
-#endif // Q_OS_WIN) && !Q_OS_WINCE && !Q_OS_WINRT
+#endif // Q_OS_WIN
#ifdef QTESTLIB_USE_VALGRIND
if (QBenchmarkGlobalData::current->mode() == QBenchmarkGlobalData::CallgrindParentProcess) {
@@ -2426,6 +2429,14 @@ bool QTest::compare_string_helper(const char *t1, const char *t2, const char *ac
\internal
*/
+/*! \fn bool QTest::qCompare(T *t, std::nullptr_t, const char *actual, const char *expected, const char *file, int line)
+ \internal
+*/
+
+/*! \fn bool QTest::qCompare(std::nullptr_t, T *t, const char *actual, const char *expected, const char *file, int line)
+ \internal
+*/
+
/*! \fn bool QTest::qCompare(T *t1, T *t2, const char *actual, const char *expected, const char *file, int line)
\internal
*/
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h
index 83ecaab8df..09da575bc9 100644
--- a/src/testlib/qtestcase.h
+++ b/src/testlib/qtestcase.h
@@ -63,7 +63,7 @@ class QRegularExpression;
#define QVERIFY(statement) \
do {\
- if (!QTest::qVerify((statement), #statement, "", __FILE__, __LINE__))\
+ if (!QTest::qVerify(static_cast<bool>(statement), #statement, "", __FILE__, __LINE__))\
return;\
} while (0)
@@ -332,13 +332,27 @@ namespace QTest
Q_TESTLIB_EXPORT bool qCompare(double const &t1, double const &t2,
const char *actual, const char *expected, const char *file, int line);
- inline bool compare_ptr_helper(const void *t1, const void *t2, const char *actual,
+ inline bool compare_ptr_helper(const volatile void *t1, const volatile void *t2, const char *actual,
const char *expected, const char *file, int line)
{
return compare_helper(t1 == t2, "Compared pointers are not the same",
toString(t1), toString(t2), actual, expected, file, line);
}
+ inline bool compare_ptr_helper(const volatile void *t1, std::nullptr_t, const char *actual,
+ const char *expected, const char *file, int line)
+ {
+ return compare_helper(t1 == nullptr, "Compared pointers are not the same",
+ toString(t1), toString(nullptr), actual, expected, file, line);
+ }
+
+ inline bool compare_ptr_helper(std::nullptr_t, const volatile void *t2, const char *actual,
+ const char *expected, const char *file, int line)
+ {
+ return compare_helper(nullptr == t2, "Compared pointers are not the same",
+ toString(nullptr), toString(t2), actual, expected, file, line);
+ }
+
Q_TESTLIB_EXPORT bool compare_string_helper(const char *t1, const char *t2, const char *actual,
const char *expected, const char *file, int line);
@@ -388,6 +402,19 @@ namespace QTest
return compare_ptr_helper(t1, t2, actual, expected, file, line);
}
+ template <typename T>
+ inline bool qCompare(T *t1, std::nullptr_t, const char *actual, const char *expected,
+ const char *file, int line)
+ {
+ return compare_ptr_helper(t1, nullptr, actual, expected, file, line);
+ }
+ template <typename T>
+ inline bool qCompare(std::nullptr_t, T *t2, const char *actual, const char *expected,
+ const char *file, int line)
+ {
+ return compare_ptr_helper(nullptr, t2, actual, expected, file, line);
+ }
+
template <typename T1, typename T2>
inline bool qCompare(const T1 *t1, const T2 *t2, const char *actual, const char *expected,
const char *file, int line)
diff --git a/src/testlib/qtestcase.qdoc b/src/testlib/qtestcase.qdoc
index 85f71fc27f..8bf3b30ffb 100644
--- a/src/testlib/qtestcase.qdoc
+++ b/src/testlib/qtestcase.qdoc
@@ -907,6 +907,14 @@
*/
/*!
+ \fn char *QTest::toString(std::nullptr_t)
+ \overload
+ \since 5.8
+
+ Returns a string containing \c{nullptr}.
+*/
+
+/*!
\fn char *QTest::toString(const QString &string)
\overload
@@ -1114,6 +1122,20 @@
*/
/*!
+ \fn QTest::createTouchDevice()
+ \since 5.8
+
+ Creates a dummy touch device for simulation of touch events.
+
+ The touch device will be registered with the QPA window system interface,
+ and deleted automatically when the QCoreApplication is deleted. So you
+ should typically use createTouchDevice() to initialize a QTouchDevice
+ member variable in your test case class, and use the same instance for all tests.
+
+ \sa QTest::QTouchEventSequence
+*/
+
+/*!
\class QTest::QTouchEventSequence
\inmodule QtTest
\since 4.6
diff --git a/src/testlib/qtesttouch.h b/src/testlib/qtesttouch.h
index 2c57bf0420..bda185bfee 100644
--- a/src/testlib/qtesttouch.h
+++ b/src/testlib/qtesttouch.h
@@ -65,6 +65,7 @@ Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *w, QTouchDevice *device,
namespace QTest
{
+ Q_GUI_EXPORT QTouchDevice * createTouchDevice(QTouchDevice::DeviceType devType = QTouchDevice::TouchScreen);
class QTouchEventSequence
{
diff --git a/src/testlib/qxctestlogger.mm b/src/testlib/qxctestlogger.mm
index c50b50eb06..ffabe88db2 100644
--- a/src/testlib/qxctestlogger.mm
+++ b/src/testlib/qxctestlogger.mm
@@ -191,7 +191,7 @@ private:
name:[NSString stringWithFormat:@"%@DidFinishLaunchingNotification",
#if defined(Q_OS_OSX)
@"NSApplication"
- #elif defined(Q_OS_IOS)
+ #else
@"UIApplication"
#endif
]
diff --git a/src/testlib/qxunittestlogger.cpp b/src/testlib/qxunittestlogger.cpp
index 72faaeb9b1..ec33c29ae5 100644
--- a/src/testlib/qxunittestlogger.cpp
+++ b/src/testlib/qxunittestlogger.cpp
@@ -256,7 +256,7 @@ void QXunitTestLogger::addBenchmarkResult(const QBenchmarkResult &result)
benchmarkElement->addAttribute(
QTest::AI_Metric,
- QTest::benchmarkMetricName(QBenchmarkTestMethodData::current->result.metric));
+ QTest::benchmarkMetricName(result.metric));
benchmarkElement->addAttribute(QTest::AI_Tag, result.context.tag.toUtf8().data());
const qreal valuePerIteration = qreal(result.value) / qreal(result.iterations);
diff --git a/src/testlib/testlib.pro b/src/testlib/testlib.pro
index 372a69c3ed..386dfb6c0e 100644
--- a/src/testlib/testlib.pro
+++ b/src/testlib/testlib.pro
@@ -67,13 +67,6 @@ DEFINES *= QT_NO_CAST_TO_ASCII \
QT_NO_FOREACH \
QT_NO_DATASTREAM
embedded:QMAKE_CXXFLAGS += -fno-rtti
-wince: LIBS += \
- ole32.lib \
- oleaut32.lib \
- uuid.lib \
- commctrl.lib \
- coredll.lib \
- winsock.lib
mac {
LIBS += -framework Security
diff --git a/src/tools/bootstrap/bootstrap.pro b/src/tools/bootstrap/bootstrap.pro
index a43105297f..f763d0c8fe 100644
--- a/src/tools/bootstrap/bootstrap.pro
+++ b/src/tools/bootstrap/bootstrap.pro
@@ -119,12 +119,12 @@ mac {
LIBS += -framework Foundation
osx: LIBS_PRIVATE += -framework CoreServices
- ios: LIBS_PRIVATE += -framework UIKit
+ uikit: LIBS_PRIVATE += -framework UIKit
}
macx {
OBJECTIVE_SOURCES += \
- ../../corelib/tools/qstring_mac.mm \
+ ../../corelib/kernel/qcore_foundation.mm \
../../corelib/io/qstandardpaths_mac.mm
} else:unix {
SOURCES += \
@@ -134,7 +134,7 @@ macx {
../../corelib/io/qstandardpaths_win.cpp
}
-contains(QT_CONFIG, zlib)|cross_compile {
+!contains(QT_CONFIG, system-zlib)|cross_compile {
include(../../3rdparty/zlib.pri)
} else {
CONFIG += no_core_dep
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp
index 7de6fe632f..ccc6d795d7 100644
--- a/src/tools/moc/generator.cpp
+++ b/src/tools/moc/generator.cpp
@@ -878,9 +878,14 @@ void Generator::generateEnums(int index)
int i;
for (i = 0; i < cdef->enumList.count(); ++i) {
const EnumDef &e = cdef->enumList.at(i);
+ int flags = 0;
+ if (cdef->enumDeclarations.value(e.name))
+ flags |= EnumIsFlag;
+ if (e.isEnumClass)
+ flags |= EnumIsScoped;
fprintf(out, " %4d, 0x%.1x, %4d, %4d,\n",
stridx(e.name),
- cdef->enumDeclarations.value(e.name) ? 1 : 0,
+ flags,
e.values.count(),
index);
index += e.values.count() * 2;
diff --git a/src/tools/moc/main.cpp b/src/tools/moc/main.cpp
index 0734a92d5a..55cf7ed872 100644
--- a/src/tools/moc/main.cpp
+++ b/src/tools/moc/main.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the tools applications of the Qt Toolkit.
@@ -200,20 +201,24 @@ int runMoc(int argc, char **argv)
.arg(mocOutputRevision).arg(QString::fromLatin1(QT_VERSION_STR)));
parser.addHelpOption();
parser.addVersionOption();
+ parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
QCommandLineOption outputOption(QStringLiteral("o"));
outputOption.setDescription(QStringLiteral("Write output to file rather than stdout."));
outputOption.setValueName(QStringLiteral("file"));
+ outputOption.setFlags(QCommandLineOption::ShortOptionStyle);
parser.addOption(outputOption);
QCommandLineOption includePathOption(QStringLiteral("I"));
includePathOption.setDescription(QStringLiteral("Add dir to the include path for header files."));
includePathOption.setValueName(QStringLiteral("dir"));
+ includePathOption.setFlags(QCommandLineOption::ShortOptionStyle);
parser.addOption(includePathOption);
QCommandLineOption macFrameworkOption(QStringLiteral("F"));
macFrameworkOption.setDescription(QStringLiteral("Add Mac framework to the include path for header files."));
macFrameworkOption.setValueName(QStringLiteral("framework"));
+ macFrameworkOption.setFlags(QCommandLineOption::ShortOptionStyle);
parser.addOption(macFrameworkOption);
QCommandLineOption preprocessOption(QStringLiteral("E"));
@@ -223,18 +228,26 @@ int runMoc(int argc, char **argv)
QCommandLineOption defineOption(QStringLiteral("D"));
defineOption.setDescription(QStringLiteral("Define macro, with optional definition."));
defineOption.setValueName(QStringLiteral("macro[=def]"));
+ defineOption.setFlags(QCommandLineOption::ShortOptionStyle);
parser.addOption(defineOption);
QCommandLineOption undefineOption(QStringLiteral("U"));
undefineOption.setDescription(QStringLiteral("Undefine macro."));
undefineOption.setValueName(QStringLiteral("macro"));
+ undefineOption.setFlags(QCommandLineOption::ShortOptionStyle);
parser.addOption(undefineOption);
QCommandLineOption metadataOption(QStringLiteral("M"));
metadataOption.setDescription(QStringLiteral("Add key/value pair to plugin meta data"));
metadataOption.setValueName(QStringLiteral("key=value"));
+ metadataOption.setFlags(QCommandLineOption::ShortOptionStyle);
parser.addOption(metadataOption);
+ QCommandLineOption compilerFlavorOption(QStringLiteral("compiler-flavor"));
+ compilerFlavorOption.setDescription(QStringLiteral("Set the compiler flavor: either \"msvc\" or \"unix\"."));
+ compilerFlavorOption.setValueName(QStringLiteral("flavor"));
+ parser.addOption(compilerFlavorOption);
+
QCommandLineOption noIncludeOption(QStringLiteral("i"));
noIncludeOption.setDescription(QStringLiteral("Do not generate an #include statement."));
parser.addOption(noIncludeOption);
@@ -242,11 +255,13 @@ int runMoc(int argc, char **argv)
QCommandLineOption pathPrefixOption(QStringLiteral("p"));
pathPrefixOption.setDescription(QStringLiteral("Path prefix for included file."));
pathPrefixOption.setValueName(QStringLiteral("path"));
+ pathPrefixOption.setFlags(QCommandLineOption::ShortOptionStyle);
parser.addOption(pathPrefixOption);
QCommandLineOption forceIncludeOption(QStringLiteral("f"));
forceIncludeOption.setDescription(QStringLiteral("Force #include <file> (overwrite default)."));
forceIncludeOption.setValueName(QStringLiteral("file"));
+ forceIncludeOption.setFlags(QCommandLineOption::ShortOptionStyle);
parser.addOption(forceIncludeOption);
QCommandLineOption prependIncludeOption(QStringLiteral("b"));
@@ -254,9 +269,15 @@ int runMoc(int argc, char **argv)
prependIncludeOption.setValueName(QStringLiteral("file"));
parser.addOption(prependIncludeOption);
+ QCommandLineOption includeOption(QStringLiteral("include"));
+ includeOption.setDescription(QStringLiteral("Parse <file> as an #include before the main source(s)."));
+ includeOption.setValueName(QStringLiteral("file"));
+ parser.addOption(includeOption);
+
QCommandLineOption noNotesWarningsCompatOption(QStringLiteral("n"));
noNotesWarningsCompatOption.setDescription(QStringLiteral("Do not display notes (-nn) or warnings (-nw). Compatibility option."));
noNotesWarningsCompatOption.setValueName(QStringLiteral("which"));
+ noNotesWarningsCompatOption.setFlags(QCommandLineOption::ShortOptionStyle);
parser.addOption(noNotesWarningsCompatOption);
QCommandLineOption noNotesOption(QStringLiteral("no-notes"));
@@ -313,9 +334,32 @@ int runMoc(int argc, char **argv)
if (parser.isSet(pathPrefixOption))
moc.includePath = QFile::encodeName(parser.value(pathPrefixOption));
}
+
const auto includePaths = parser.values(includePathOption);
for (const QString &path : includePaths)
pp.includes += Preprocessor::IncludePath(QFile::encodeName(path));
+ QString compilerFlavor = parser.value(compilerFlavorOption);
+ if (compilerFlavor.isEmpty() || compilerFlavor == QLatin1String("unix")) {
+ // traditional Unix compilers use both CPATH and CPLUS_INCLUDE_PATH
+ // $CPATH feeds to #include <...> and #include "...", whereas
+ // CPLUS_INCLUDE_PATH is equivalent to GCC's -isystem, so we parse later
+ const auto cpath = qgetenv("CPATH").split(QDir::listSeparator().toLatin1());
+ for (const QByteArray &p : cpath)
+ pp.includes += Preprocessor::IncludePath(p);
+ const auto cplus_include_path = qgetenv("CPLUS_INCLUDE_PATH").split(QDir::listSeparator().toLatin1());
+ for (const QByteArray &p : cplus_include_path)
+ pp.includes += Preprocessor::IncludePath(p);
+ } else if (compilerFlavor == QLatin1String("msvc")) {
+ // MSVC uses one environment variable: INCLUDE
+ const auto include = qgetenv("INCLUDE").split(QDir::listSeparator().toLatin1());
+ for (const QByteArray &p : include)
+ pp.includes += Preprocessor::IncludePath(p);
+ } else {
+ error(qPrintable(QLatin1String("Unknown compiler flavor '") + compilerFlavor +
+ QLatin1String("'; valid values are: msvc, unix.")));
+ parser.showHelp(1);
+ }
+
const auto macFrameworks = parser.values(macFrameworkOption);
for (const QString &path : macFrameworks) {
// minimalistic framework support for the mac
@@ -410,7 +454,31 @@ int runMoc(int argc, char **argv)
moc.includes = pp.includes;
// 1. preprocess
- moc.symbols = pp.preprocessed(moc.filename, &in);
+ const auto includeFiles = parser.values(includeOption);
+ for (const QString &includeName : includeFiles) {
+ QByteArray rawName = pp.resolveInclude(QFile::encodeName(includeName), moc.filename);
+ if (rawName.isEmpty()) {
+ fprintf(stderr, "Warning: Failed to resolve include \"%s\" for moc file %s\n",
+ includeName.toLocal8Bit().constData(),
+ moc.filename.isEmpty() ? "<standard input>" : moc.filename.constData());
+ } else {
+ QFile f(QFile::decodeName(rawName));
+ if (f.open(QIODevice::ReadOnly)) {
+ moc.symbols += Symbol(0, MOC_INCLUDE_BEGIN, rawName);
+ moc.symbols += pp.preprocessed(rawName, &f);
+ moc.symbols += Symbol(0, MOC_INCLUDE_END, rawName);
+ } else {
+ fprintf(stderr, "Warning: Cannot open %s included by moc file %s: %s\n",
+ rawName.constData(),
+ moc.filename.isEmpty() ? "<standard input>" : moc.filename.constData(),
+ f.errorString().toLocal8Bit().constData());
+ }
+ }
+ }
+ moc.symbols += pp.preprocessed(moc.filename, &in);
+
+ // We obviously do not support MS extensions
+ pp.macros.remove("_MSC_EXTENSIONS");
if (!pp.preprocessOnly) {
// 2. parse
diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp
index 74c75eda5b..415003e6b1 100644
--- a/src/tools/moc/preprocessor.cpp
+++ b/src/tools/moc/preprocessor.cpp
@@ -696,13 +696,10 @@ Symbols Preprocessor::macroExpandIdentifier(Preprocessor *that, SymbolStack &sym
next = arg.at(0);
}
- if (!expansion.isEmpty() && expansion.constLast().token == s.token) {
- Symbol last = expansion.constLast();
+ Symbol last = expansion.constLast();
+ if (!expansion.isEmpty() && last.token == s.token && last.token != STRING_LITERAL) {
expansion.pop_back();
- if (last.token == STRING_LITERAL || s.token == STRING_LITERAL)
- that->error("Can't concatenate non identifier tokens");
-
QByteArray lexem = last.lexem() + next.lexem();
expansion += Symbol(lineNum, last.token, lexem);
} else {
@@ -1008,6 +1005,36 @@ static void mergeStringLiterals(Symbols *_symbols)
}
}
+QByteArray Preprocessor::resolveInclude(const QByteArray &include, const QByteArray &relativeTo)
+{
+ // #### stringery
+ QFileInfo fi;
+ if (!relativeTo.isEmpty())
+ fi.setFile(QFileInfo(QString::fromLocal8Bit(relativeTo.constData())).dir(), QString::fromLocal8Bit(include.constData()));
+ for (int j = 0; j < Preprocessor::includes.size() && !fi.exists(); ++j) {
+ const IncludePath &p = Preprocessor::includes.at(j);
+ if (p.isFrameworkPath) {
+ const int slashPos = include.indexOf('/');
+ if (slashPos == -1)
+ continue;
+ fi.setFile(QString::fromLocal8Bit(p.path + '/' + include.left(slashPos) + ".framework/Headers/"),
+ QString::fromLocal8Bit(include.mid(slashPos + 1).constData()));
+ } else {
+ fi.setFile(QString::fromLocal8Bit(p.path.constData()), QString::fromLocal8Bit(include.constData()));
+ }
+ // try again, maybe there's a file later in the include paths with the same name
+ // (186067)
+ if (fi.isDir()) {
+ fi = QFileInfo();
+ continue;
+ }
+ }
+
+ if (!fi.exists() || fi.isDir())
+ return QByteArray();
+ return fi.canonicalFilePath().toLocal8Bit();
+}
+
void Preprocessor::preprocess(const QByteArray &filename, Symbols &preprocessed)
{
currentFilenames.push(filename);
@@ -1028,32 +1055,9 @@ void Preprocessor::preprocess(const QByteArray &filename, Symbols &preprocessed)
continue;
until(PP_NEWLINE);
- // #### stringery
- QFileInfo fi;
- if (local)
- fi.setFile(QFileInfo(QString::fromLocal8Bit(filename.constData())).dir(), QString::fromLocal8Bit(include.constData()));
- for (int j = 0; j < Preprocessor::includes.size() && !fi.exists(); ++j) {
- const IncludePath &p = Preprocessor::includes.at(j);
- if (p.isFrameworkPath) {
- const int slashPos = include.indexOf('/');
- if (slashPos == -1)
- continue;
- fi.setFile(QString::fromLocal8Bit(p.path + '/' + include.left(slashPos) + ".framework/Headers/"),
- QString::fromLocal8Bit(include.mid(slashPos + 1).constData()));
- } else {
- fi.setFile(QString::fromLocal8Bit(p.path.constData()), QString::fromLocal8Bit(include.constData()));
- }
- // try again, maybe there's a file later in the include paths with the same name
- // (186067)
- if (fi.isDir()) {
- fi = QFileInfo();
- continue;
- }
- }
-
- if (!fi.exists() || fi.isDir())
+ include = resolveInclude(include, local ? filename : QByteArray());
+ if (include.isNull())
continue;
- include = fi.canonicalFilePath().toLocal8Bit();
if (Preprocessor::preprocessedIncludes.contains(include))
continue;
@@ -1208,6 +1212,7 @@ Symbols Preprocessor::preprocessed(const QByteArray &filename, QFile *file)
input = cleaned(input);
// phase 2: tokenize for the preprocessor
+ index = 0;
symbols = tokenize(input);
#if 0
diff --git a/src/tools/moc/preprocessor.h b/src/tools/moc/preprocessor.h
index 9a49751eb0..a7eb1a19e1 100644
--- a/src/tools/moc/preprocessor.h
+++ b/src/tools/moc/preprocessor.h
@@ -62,6 +62,7 @@ public:
QList<QByteArray> frameworks;
QSet<QByteArray> preprocessedIncludes;
Macros macros;
+ QByteArray resolveInclude(const QByteArray &filename, const QByteArray &relativeTo);
Symbols preprocessed(const QByteArray &filename, QFile *device);
void parseDefineArguments(Macro *m);
diff --git a/src/tools/uic/cpp/cppwritedeclaration.cpp b/src/tools/uic/cpp/cppwritedeclaration.cpp
index 4c9d2db6df..3aadc878e3 100644
--- a/src/tools/uic/cpp/cppwritedeclaration.cpp
+++ b/src/tools/uic/cpp/cppwritedeclaration.cpp
@@ -44,27 +44,16 @@ QT_BEGIN_NAMESPACE
namespace {
void openNameSpaces(const QStringList &namespaceList, QTextStream &output) {
- if (namespaceList.empty())
- return;
- const QStringList::const_iterator cend = namespaceList.constEnd();
- for (QStringList::const_iterator it = namespaceList.constBegin(); it != cend; ++it) {
- if (!it->isEmpty()) {
+ for (auto it = namespaceList.begin(), end = namespaceList.end(); it != end; ++it) {
+ if (!it->isEmpty())
output << "namespace " << *it << " {\n";
- }
}
}
void closeNameSpaces(const QStringList &namespaceList, QTextStream &output) {
- if (namespaceList.empty())
- return;
-
- QListIterator<QString> it(namespaceList);
- it.toBack();
- while (it.hasPrevious()) {
- const QString ns = it.previous();
- if (!ns.isEmpty()) {
- output << "} // namespace " << ns << "\n";
- }
+ for (auto it = namespaceList.rbegin(), end = namespaceList.rend(); it != end; ++it) {
+ if (!it->isEmpty())
+ output << "} // namespace " << *it << "\n";
}
}
diff --git a/src/tools/uic/cpp/cppwriteinitialization.cpp b/src/tools/uic/cpp/cppwriteinitialization.cpp
index 714841d6cf..3e5242fc9d 100644
--- a/src/tools/uic/cpp/cppwriteinitialization.cpp
+++ b/src/tools/uic/cpp/cppwriteinitialization.cpp
@@ -774,22 +774,22 @@ void WriteInitialization::acceptWidget(DomWidget *node)
//
// Special handling for qtableview/qtreeview fake header attributes
//
- static const QStringList realPropertyNames =
- (QStringList() << QLatin1String("visible")
- << QLatin1String("cascadingSectionResizes")
- << QLatin1String("defaultSectionSize")
- << QLatin1String("highlightSections")
- << QLatin1String("minimumSectionSize")
- << QLatin1String("showSortIndicator")
- << QLatin1String("stretchLastSection"));
+ static const QLatin1String realPropertyNames[] = {
+ QLatin1String("visible"),
+ QLatin1String("cascadingSectionResizes"),
+ QLatin1String("defaultSectionSize"),
+ QLatin1String("highlightSections"),
+ QLatin1String("minimumSectionSize"),
+ QLatin1String("showSortIndicator"),
+ QLatin1String("stretchLastSection"),
+ };
if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QTreeView"))
|| m_uic->customWidgetsInfo()->extends(className, QLatin1String("QTreeWidget"))) {
DomPropertyList headerProperties;
- for (const QString &realPropertyName : realPropertyNames) {
- const QString upperPropertyName = realPropertyName.at(0).toUpper()
- + realPropertyName.mid(1);
- const QString fakePropertyName = QLatin1String("header") + upperPropertyName;
+ for (auto realPropertyName : realPropertyNames) {
+ const QString fakePropertyName = QLatin1String("header")
+ + QChar(realPropertyName.at(0)).toUpper() + realPropertyName.mid(1);
if (DomProperty *fakeProperty = attributes.value(fakePropertyName)) {
fakeProperty->setAttributeName(realPropertyName);
headerProperties << fakeProperty;
@@ -801,16 +801,16 @@ void WriteInitialization::acceptWidget(DomWidget *node)
} else if (m_uic->customWidgetsInfo()->extends(className, QLatin1String("QTableView"))
|| m_uic->customWidgetsInfo()->extends(className, QLatin1String("QTableWidget"))) {
- static const QStringList headerPrefixes =
- (QStringList() << QLatin1String("horizontalHeader")
- << QLatin1String("verticalHeader"));
+ static const QLatin1String headerPrefixes[] = {
+ QLatin1String("horizontalHeader"),
+ QLatin1String("verticalHeader"),
+ };
- for (const QString &headerPrefix : headerPrefixes) {
+ for (auto headerPrefix : headerPrefixes) {
DomPropertyList headerProperties;
- for (const QString &realPropertyName : realPropertyNames) {
- const QString upperPropertyName = realPropertyName.at(0).toUpper()
- + realPropertyName.mid(1);
- const QString fakePropertyName = headerPrefix + upperPropertyName;
+ for (auto realPropertyName : realPropertyNames) {
+ const QString fakePropertyName = headerPrefix
+ + QChar(realPropertyName.at(0)).toUpper() + realPropertyName.mid(1);
if (DomProperty *fakeProperty = attributes.value(fakePropertyName)) {
fakeProperty->setAttributeName(realPropertyName);
headerProperties << fakeProperty;
@@ -1717,9 +1717,7 @@ void WriteInitialization::writeColorGroup(DomColorGroup *colorGroup, const QStri
// new format
const QList<DomColorRole *> colorRoles = colorGroup->elementColorRole();
- QListIterator<DomColorRole *> itRole(colorRoles);
- while (itRole.hasNext()) {
- const DomColorRole *colorRole = itRole.next();
+ for (const DomColorRole *colorRole : colorRoles) {
if (colorRole->hasAttributeRole()) {
const QString brushName = writeBrushInitialization(colorRole->elementBrush());
m_output << m_indent << paletteName << ".setBrush(" << group
@@ -1796,9 +1794,7 @@ void WriteInitialization::writeBrush(const DomBrush *brush, const QString &brush
}
const QList<DomGradientStop *> stops = gradient->elementGradientStop();
- QListIterator<DomGradientStop *> it(stops);
- while (it.hasNext()) {
- const DomGradientStop *stop = it.next();
+ for (const DomGradientStop *stop : stops) {
const DomColor *color = stop->elementColor();
m_output << m_indent << gradientName << ".setColorAt("
<< stop->attributePosition() << ", "
diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp
index 8faa73b68b..463019dbd0 100644
--- a/src/widgets/accessible/complexwidgets.cpp
+++ b/src/widgets/accessible/complexwidgets.cpp
@@ -120,19 +120,26 @@ public:
{
if (!isValid())
return QString();
+ QString str;
switch (t) {
case QAccessible::Name:
- return qt_accStripAmp(m_parent->tabText(m_index));
+ str = m_parent->accessibleTabName(m_index);
+ if (str.isEmpty())
+ str = qt_accStripAmp(m_parent->tabText(m_index));
+ break;
case QAccessible::Accelerator:
- return qt_accHotKey(m_parent->tabText(m_index));
+ str = qt_accHotKey(m_parent->tabText(m_index));
+ break;
case QAccessible::Description:
- return m_parent->tabToolTip(m_index);
+ str = m_parent->tabToolTip(m_index);
+ break;
case QAccessible::Help:
- return m_parent->tabWhatsThis(m_index);
+ str = m_parent->tabWhatsThis(m_index);
+ break;
default:
break;
}
- return QString();
+ return str;
}
void setText(QAccessible::Text, const QString &) Q_DECL_OVERRIDE {}
@@ -237,7 +244,12 @@ int QAccessibleTabBar::childCount() const
QString QAccessibleTabBar::text(QAccessible::Text t) const
{
if (t == QAccessible::Name) {
- return qt_accStripAmp(tabBar()->tabText(tabBar()->currentIndex()));
+ const QTabBar *tBar = tabBar();
+ int idx = tBar->currentIndex();
+ QString str = tBar->accessibleTabName(idx);
+ if (str.isEmpty())
+ str = qt_accStripAmp(tBar->tabText(idx));
+ return str;
} else if (t == QAccessible::Accelerator) {
return qt_accHotKey(tabBar()->tabText(tabBar()->currentIndex()));
}
diff --git a/src/widgets/accessible/complexwidgets_p.h b/src/widgets/accessible/complexwidgets_p.h
index 44549086ba..d43b06f4a4 100644
--- a/src/widgets/accessible/complexwidgets_p.h
+++ b/src/widgets/accessible/complexwidgets_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtCore/qpointer.h>
#include <QtWidgets/qaccessiblewidget.h>
#include <QtWidgets/qabstractitemview.h>
diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp
index ebe8efc79e..ecb84d8b50 100644
--- a/src/widgets/accessible/itemviews.cpp
+++ b/src/widgets/accessible/itemviews.cpp
@@ -512,7 +512,7 @@ QAccessibleInterface *QAccessibleTable::child(int logicalIndex) const
if (!iface) {
QModelIndex index = view()->model()->index(row, column, view()->rootIndex());
if (Q_UNLIKELY(!index.isValid())) {
- qWarning() << "QAccessibleTable::child: Invalid index at: " << row << column;
+ qWarning("QAccessibleTable::child: Invalid index at: %d %d", row, column);
return 0;
}
iface = new QAccessibleTableCell(view(), index, cellRole());
@@ -783,7 +783,7 @@ QAccessibleInterface *QAccessibleTree::cellAt(int row, int column) const
{
QModelIndex index = indexFromLogical(row, column);
if (Q_UNLIKELY(!index.isValid())) {
- qWarning() << "Requested invalid tree cell: " << row << column;
+ qWarning("Requested invalid tree cell: %d %d", row, column);
return 0;
}
const QTreeView *treeView = qobject_cast<const QTreeView*>(view());
diff --git a/src/widgets/accessible/itemviews_p.h b/src/widgets/accessible/itemviews_p.h
index 95a0032139..ed421d3146 100644
--- a/src/widgets/accessible/itemviews_p.h
+++ b/src/widgets/accessible/itemviews_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QtCore/qpointer.h"
#include <QtGui/qaccessible.h>
#include <QtWidgets/qaccessiblewidget.h>
diff --git a/src/widgets/accessible/qaccessiblemenu_p.h b/src/widgets/accessible/qaccessiblemenu_p.h
index 5a5a4a3222..52afeb5a04 100644
--- a/src/widgets/accessible/qaccessiblemenu_p.h
+++ b/src/widgets/accessible/qaccessiblemenu_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtWidgets/qaccessiblewidget.h>
#include <QtCore/qpointer.h>
diff --git a/src/widgets/accessible/qaccessiblewidget.h b/src/widgets/accessible/qaccessiblewidget.h
index ebba30b2d5..e09c3ff489 100644
--- a/src/widgets/accessible/qaccessiblewidget.h
+++ b/src/widgets/accessible/qaccessiblewidget.h
@@ -40,6 +40,7 @@
#ifndef QACCESSIBLEWIDGET_H
#define QACCESSIBLEWIDGET_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtGui/qaccessibleobject.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/accessible/qaccessiblewidgetfactory_p.h b/src/widgets/accessible/qaccessiblewidgetfactory_p.h
index 2571399060..5da609ddca 100644
--- a/src/widgets/accessible/qaccessiblewidgetfactory_p.h
+++ b/src/widgets/accessible/qaccessiblewidgetfactory_p.h
@@ -37,6 +37,7 @@
**
****************************************************************************/
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtGui/qaccessible.h>
#ifndef QACCESSIBLEWIDGETFACTORY_H
diff --git a/src/widgets/accessible/qaccessiblewidgets_p.h b/src/widgets/accessible/qaccessiblewidgets_p.h
index 986f2b2789..052958d4c7 100644
--- a/src/widgets/accessible/qaccessiblewidgets_p.h
+++ b/src/widgets/accessible/qaccessiblewidgets_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtWidgets/qaccessiblewidget.h>
#ifndef QT_NO_ACCESSIBILITY
diff --git a/src/widgets/accessible/rangecontrols_p.h b/src/widgets/accessible/rangecontrols_p.h
index cd351fbb3c..28f613462d 100644
--- a/src/widgets/accessible/rangecontrols_p.h
+++ b/src/widgets/accessible/rangecontrols_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtWidgets/qaccessiblewidget.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/accessible/simplewidgets_p.h b/src/widgets/accessible/simplewidgets_p.h
index ec9cc893a5..8bd0af8261 100644
--- a/src/widgets/accessible/simplewidgets_p.h
+++ b/src/widgets/accessible/simplewidgets_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtCore/qcoreapplication.h>
#include <QtWidgets/qaccessiblewidget.h>
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
index 23436d1bf0..d4764c019e 100644
--- a/src/widgets/dialogs/qcolordialog.cpp
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -92,7 +92,7 @@ public:
SetColorAll = ShowColor | SelectColor
};
- QColorDialogPrivate() : options(new QColorDialogOptions)
+ QColorDialogPrivate() : options(QColorDialogOptions::create())
#ifdef Q_OS_WIN32
, updateTimer(0)
#endif
@@ -1180,14 +1180,10 @@ QColorShower::QColorShower(QColorDialog *parent)
gl->setMargin(gl->spacing());
lab = new QColorShowLabel(this);
-#ifndef Q_OS_WINCE
#ifdef QT_SMALL_COLORDIALOG
lab->setMinimumHeight(60);
#endif
lab->setMinimumWidth(60);
-#else
- lab->setMinimumWidth(20);
-#endif
// For QVGA screens only the comboboxes and color label are visible.
// For nHD screens only color and luminence pickers and color label are visible.
@@ -1702,7 +1698,7 @@ void QColorDialogPrivate::initWidgets()
leftLay = 0;
-#if defined(Q_OS_WINCE) || defined(QT_SMALL_COLORDIALOG)
+#if defined(QT_SMALL_COLORDIALOG)
smallDisplay = true;
const int lumSpace = 20;
#else
@@ -1725,7 +1721,7 @@ void QColorDialogPrivate::initWidgets()
leftLay->addWidget(lblBasicColors);
leftLay->addWidget(standard);
-#if !defined(Q_OS_WINCE) && !defined(QT_SMALL_COLORDIALOG)
+#if !defined(QT_SMALL_COLORDIALOG)
// The screen color picker button
screenColorPickerButton = new QPushButton();
leftLay->addWidget(screenColorPickerButton);
@@ -1734,9 +1730,7 @@ void QColorDialogPrivate::initWidgets()
q->connect(screenColorPickerButton, SIGNAL(clicked()), SLOT(_q_pickScreenColor()));
#endif
-#if !defined(Q_OS_WINCE)
leftLay->addStretch();
-#endif
custom = new QColorWell(q, customColorRows, colorColumns, QColorDialogOptions::customColors());
custom->setAcceptDrops(true);
@@ -1931,10 +1925,8 @@ static const Qt::WindowFlags DefaultWindowFlags =
Constructs a color dialog with the given \a parent.
*/
QColorDialog::QColorDialog(QWidget *parent)
- : QDialog(*new QColorDialogPrivate, parent, DefaultWindowFlags)
+ : QColorDialog(QColor(Qt::white), parent)
{
- Q_D(QColorDialog);
- d->init(Qt::white);
}
/*!
diff --git a/src/widgets/dialogs/qcolordialog.h b/src/widgets/dialogs/qcolordialog.h
index b036570427..3b56f0b5d1 100644
--- a/src/widgets/dialogs/qcolordialog.h
+++ b/src/widgets/dialogs/qcolordialog.h
@@ -40,6 +40,7 @@
#ifndef QCOLORDIALOG_H
#define QCOLORDIALOG_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qdialog.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp
index bfc943966f..8dfcf2c6d6 100644
--- a/src/widgets/dialogs/qdialog.cpp
+++ b/src/widgets/dialogs/qdialog.cpp
@@ -427,31 +427,6 @@ void QDialogPrivate::resetModalitySetByOpen()
resetModalityTo = -1;
}
-#if defined(Q_OS_WINCE)
-#ifdef Q_OS_WINCE_WM
-void QDialogPrivate::_q_doneAction()
-{
- //Done...
- QApplication::postEvent(q_func(), new QEvent(QEvent::OkRequest));
-}
-#endif
-
-/*!
- \reimp
-*/
-bool QDialog::event(QEvent *e)
-{
- bool result = QWidget::event(e);
-#ifdef Q_OS_WINCE
- if (e->type() == QEvent::OkRequest) {
- accept();
- result = true;
- }
-#endif
- return result;
-}
-#endif
-
/*!
In general returns the modal dialog's result code, \c Accepted or
\c Rejected.
diff --git a/src/widgets/dialogs/qdialog.h b/src/widgets/dialogs/qdialog.h
index db5baf24f9..265790b0e5 100644
--- a/src/widgets/dialogs/qdialog.h
+++ b/src/widgets/dialogs/qdialog.h
@@ -40,6 +40,7 @@
#ifndef QDIALOG_H
#define QDIALOG_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
QT_BEGIN_NAMESPACE
@@ -98,9 +99,6 @@ public Q_SLOTS:
protected:
QDialog(QDialogPrivate &, QWidget *parent, Qt::WindowFlags f = Qt::WindowFlags());
-#if defined(Q_OS_WINCE)
- bool event(QEvent *e);
-#endif
void keyPressEvent(QKeyEvent *);
void closeEvent(QCloseEvent *);
void showEvent(QShowEvent *);
@@ -113,10 +111,6 @@ protected:
private:
Q_DECLARE_PRIVATE(QDialog)
Q_DISABLE_COPY(QDialog)
-
-#ifdef Q_OS_WINCE_WM
- Q_PRIVATE_SLOT(d_func(), void _q_doneAction())
-#endif
};
QT_END_NAMESPACE
diff --git a/src/widgets/dialogs/qdialog_p.h b/src/widgets/dialogs/qdialog_p.h
index 6a9b5bae57..1c7c5f3c2a 100644
--- a/src/widgets/dialogs/qdialog_p.h
+++ b/src/widgets/dialogs/qdialog_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qwidget_p.h"
#include "QtCore/qeventloop.h"
#include "QtCore/qpointer.h"
@@ -99,10 +100,6 @@ public:
void hideDefault();
void resetModalitySetByOpen();
-#ifdef Q_OS_WINCE_WM
- void _q_doneAction();
-#endif
-
int rescode;
int resetModalityTo;
bool wasModalitySet;
diff --git a/src/widgets/dialogs/qerrormessage.cpp b/src/widgets/dialogs/qerrormessage.cpp
index 77d9eb29ac..5fcbe3fe9d 100644
--- a/src/widgets/dialogs/qerrormessage.cpp
+++ b/src/widgets/dialogs/qerrormessage.cpp
@@ -60,11 +60,6 @@
#include <stdio.h>
#include <stdlib.h>
-#ifdef Q_OS_WINCE
-extern bool qt_wince_is_mobile(); //defined in qguifunctions_wince.cpp
-extern bool qt_wince_is_high_dpi(); //defined in qguifunctions_wince.cpp
-#endif
-
QT_BEGIN_NAMESPACE
class QErrorMessagePrivate : public QDialogPrivate
@@ -100,32 +95,12 @@ public:
QSize QErrorMessageTextView::minimumSizeHint() const
{
-#ifdef Q_OS_WINCE
- if (qt_wince_is_mobile())
- if (qt_wince_is_high_dpi())
- return QSize(200, 200);
- else
- return QSize(100, 100);
- else
- return QSize(70, 70);
-#else
return QSize(50, 50);
-#endif
}
QSize QErrorMessageTextView::sizeHint() const
{
-#ifdef Q_OS_WINCE
- if (qt_wince_is_mobile())
- if (qt_wince_is_high_dpi())
- return QSize(400, 200);
- else
- return QSize(320, 120);
- else
- return QSize(300, 100);
-#else
return QSize(250, 75);
-#endif //Q_OS_WINCE
}
/*!
@@ -248,9 +223,6 @@ QErrorMessage::QErrorMessage(QWidget * parent)
d->icon->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
#endif
d->again->setChecked(true);
-#if defined(Q_OS_WINCE)
- d->ok->setFixedSize(0,0);
-#endif
d->ok->setFocus();
d->retranslateStrings();
diff --git a/src/widgets/dialogs/qerrormessage.h b/src/widgets/dialogs/qerrormessage.h
index 03d0dbf5c5..5ffa568c10 100644
--- a/src/widgets/dialogs/qerrormessage.h
+++ b/src/widgets/dialogs/qerrormessage.h
@@ -40,6 +40,7 @@
#ifndef QERRORMESSAGE_H
#define QERRORMESSAGE_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qdialog.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index acda6bac3e..b4ca853c5d 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -60,15 +60,7 @@
#include <qmimedatabase.h>
#include <qapplication.h>
#include <qstylepainter.h>
-#if !defined(Q_OS_WINCE)
#include "ui_qfiledialog.h"
-#else
-#define Q_EMBEDDED_SMALLSCREEN
-#include "ui_qfiledialog_embedded.h"
-#if defined(Q_OS_WINCE)
-extern bool qt_priv_ptr_valid;
-#endif
-#endif
#if defined(Q_OS_UNIX)
#include <pwd.h>
#include <unistd.h> // for pathconf() on OS X
@@ -533,7 +525,7 @@ QFileDialogPrivate::QFileDialogPrivate()
showHiddenAction(0),
useDefaultCaption(true),
qFileDialogUi(0),
- options(new QFileDialogOptions)
+ options(QFileDialogOptions::create())
{
}
@@ -1750,7 +1742,7 @@ int QFileDialogPrivate::maxNameLength(const QString &path)
{
#if defined(Q_OS_UNIX)
return ::pathconf(QFile::encodeName(path).data(), _PC_NAME_MAX);
-#elif defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
+#elif defined(Q_OS_WINRT)
Q_UNUSED(path);
return MAX_PATH;
#elif defined(Q_OS_WIN)
@@ -4015,7 +4007,7 @@ QString QFSCompleter::pathFromIndex(const QModelIndex &index) const
QString currentLocation = dirModel->rootPath();
QString path = index.data(QFileSystemModel::FilePathRole).toString();
if (!currentLocation.isEmpty() && path.startsWith(currentLocation)) {
-#if defined(Q_OS_UNIX) || defined(Q_OS_WINCE)
+#if defined(Q_OS_UNIX)
if (currentLocation == QDir::separator())
return path.mid(currentLocation.length());
#endif
diff --git a/src/widgets/dialogs/qfiledialog.h b/src/widgets/dialogs/qfiledialog.h
index f13cb98e96..4ade50793d 100644
--- a/src/widgets/dialogs/qfiledialog.h
+++ b/src/widgets/dialogs/qfiledialog.h
@@ -40,6 +40,7 @@
#ifndef QFILEDIALOG_H
#define QFILEDIALOG_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qdir.h>
#include <QtCore/qstring.h>
#include <QtCore/qurl.h>
diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h
index f273a4fb37..afebad4457 100644
--- a/src/widgets/dialogs/qfiledialog_p.h
+++ b/src/widgets/dialogs/qfiledialog_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#ifndef QT_NO_FILEDIALOG
@@ -177,10 +177,6 @@ public:
#if defined(Q_OS_WIN)
QString n(path);
n.replace(QLatin1Char('\\'), QLatin1Char('/'));
-#if defined(Q_OS_WINCE)
- if ((n.size() > 1) && (n.startsWith(QLatin1String("//"))))
- n = n.mid(1);
-#endif
return n;
#else // the compile should optimize away this
return path;
diff --git a/src/widgets/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp
index 014792ea93..6df020dd58 100644
--- a/src/widgets/dialogs/qfileinfogatherer.cpp
+++ b/src/widgets/dialogs/qfileinfogatherer.cpp
@@ -263,7 +263,7 @@ QExtendedInformation QFileInfoGatherer::getInfo(const QFileInfo &fileInfo) const
static QString translateDriveName(const QFileInfo &drive)
{
QString driveName = drive.absoluteFilePath();
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
if (driveName.startsWith(QLatin1Char('/'))) // UNC host
return drive.fileName();
if (driveName.endsWith(QLatin1Char('/')))
diff --git a/src/widgets/dialogs/qfileinfogatherer_p.h b/src/widgets/dialogs/qfileinfogatherer_p.h
index a6ae136c21..3186e9d015 100644
--- a/src/widgets/dialogs/qfileinfogatherer_p.h
+++ b/src/widgets/dialogs/qfileinfogatherer_p.h
@@ -51,6 +51,8 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
+
#include <qthread.h>
#include <qmutex.h>
#include <qwaitcondition.h>
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index 7fc51f4262..11b3659990 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -366,7 +366,7 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS
// ### TODO can we use bool QAbstractFileEngine::caseSensitive() const?
QStringList pathElements = absolutePath.split(QLatin1Char('/'), QString::SkipEmptyParts);
if ((pathElements.isEmpty())
-#if !defined(Q_OS_WIN) || defined(Q_OS_WINCE)
+#if !defined(Q_OS_WIN)
&& QDir::fromNativeSeparators(longPath) != QLatin1String("/")
#endif
)
@@ -375,7 +375,7 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS
QString elementPath;
QChar separator = QLatin1Char('/');
QString trailingSeparator;
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
if (absolutePath.startsWith(QLatin1String("//"))) { // UNC path
QString host = QLatin1String("\\\\") + pathElements.constFirst();
if (absolutePath == QDir::fromNativeSeparators(host))
@@ -840,7 +840,7 @@ QString QFileSystemModelPrivate::name(const QModelIndex &index) const
*/
QString QFileSystemModelPrivate::displayName(const QModelIndex &index) const
{
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
QFileSystemNode *dirNode = node(index);
if (!dirNode->volumeName.isNull())
return dirNode->volumeName + QLatin1String(" (") + name(index) + QLatin1Char(')');
@@ -1292,11 +1292,10 @@ QString QFileSystemModelPrivate::filePath(const QModelIndex &index) const
idx = idx.parent();
}
QString fullPath = QDir::fromNativeSeparators(path.join(QDir::separator()));
-#if !defined(Q_OS_WIN) || defined(Q_OS_WINCE)
+#if !defined(Q_OS_WIN)
if ((fullPath.length() > 2) && fullPath[0] == QLatin1Char('/') && fullPath[1] == QLatin1Char('/'))
fullPath = fullPath.mid(1);
-#endif
-#if defined(Q_OS_WIN)
+#else
if (fullPath.length() == 2 && fullPath.endsWith(QLatin1Char(':')))
fullPath.append(QLatin1Char('/'));
#endif
@@ -1687,7 +1686,7 @@ QFileSystemModelPrivate::QFileSystemNode* QFileSystemModelPrivate::addNode(QFile
#else
Q_UNUSED(info)
#endif
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
//The parentNode is "" so we are listing the drives
if (parentNode->fileName.isEmpty()) {
wchar_t name[MAX_PATH + 1];
diff --git a/src/widgets/dialogs/qfilesystemmodel.h b/src/widgets/dialogs/qfilesystemmodel.h
index 6d50d0b606..7d790124c8 100644
--- a/src/widgets/dialogs/qfilesystemmodel.h
+++ b/src/widgets/dialogs/qfilesystemmodel.h
@@ -40,6 +40,7 @@
#ifndef QFILESYSTEMMODEL_H
#define QFILESYSTEMMODEL_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qabstractitemmodel.h>
#include <QtCore/qpair.h>
#include <QtCore/qdir.h>
diff --git a/src/widgets/dialogs/qfilesystemmodel_p.h b/src/widgets/dialogs/qfilesystemmodel_p.h
index af3406b699..92398d981f 100644
--- a/src/widgets/dialogs/qfilesystemmodel_p.h
+++ b/src/widgets/dialogs/qfilesystemmodel_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qfilesystemmodel.h"
#ifndef QT_NO_FILESYSTEMMODEL
@@ -95,7 +96,7 @@ public:
}
QString fileName;
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
QString volumeName;
#endif
diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp
index 2a500d3a08..1c4166c567 100644
--- a/src/widgets/dialogs/qfontdialog.cpp
+++ b/src/widgets/dialogs/qfontdialog.cpp
@@ -110,7 +110,7 @@ static const Qt::WindowFlags DefaultWindowFlags =
QFontDialogPrivate::QFontDialogPrivate()
: writingSystem(QFontDatabase::Any),
- options(QSharedPointer<QFontDialogOptions>::create())
+ options(QFontDialogOptions::create())
{
}
@@ -168,10 +168,8 @@ QFontDialog::QFontDialog(QWidget *parent)
\a initial color.
*/
QFontDialog::QFontDialog(const QFont &initial, QWidget *parent)
- : QDialog(*new QFontDialogPrivate, parent, DefaultWindowFlags)
+ : QFontDialog(parent)
{
- Q_D(QFontDialog);
- d->init();
setCurrentFont(initial);
}
@@ -321,11 +319,7 @@ void QFontDialogPrivate::init()
buttonBox->addButton(QDialogButtonBox::Cancel);
QObject::connect(buttonBox, SIGNAL(rejected()), q, SLOT(reject()));
-#if defined(Q_OS_WINCE)
- q->resize(180, 120);
-#else
q->resize(500, 360);
-#endif // Q_OS_WINCE
sizeEdit->installEventFilter(q);
familyList->installEventFilter(q);
diff --git a/src/widgets/dialogs/qfontdialog.h b/src/widgets/dialogs/qfontdialog.h
index f76ce1b7f3..276f8f5e83 100644
--- a/src/widgets/dialogs/qfontdialog.h
+++ b/src/widgets/dialogs/qfontdialog.h
@@ -40,6 +40,7 @@
#ifndef QFONTDIALOG_H
#define QFONTDIALOG_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtGui/qwindowdefs.h>
#include <QtWidgets/qdialog.h>
#include <QtGui/qfont.h>
diff --git a/src/widgets/dialogs/qfontdialog_p.h b/src/widgets/dialogs/qfontdialog_p.h
index d6a6e87ee2..033f5a2be8 100644
--- a/src/widgets/dialogs/qfontdialog_p.h
+++ b/src/widgets/dialogs/qfontdialog_p.h
@@ -52,6 +52,7 @@
//
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qdialog_p.h"
#include "qfontdatabase.h"
#include "qfontdialog.h"
diff --git a/src/widgets/dialogs/qfscompleter_p.h b/src/widgets/dialogs/qfscompleter_p.h
index a3341999f7..c073fa1521 100644
--- a/src/widgets/dialogs/qfscompleter_p.h
+++ b/src/widgets/dialogs/qfscompleter_p.h
@@ -51,9 +51,12 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qcompleter.h"
#include <QtWidgets/qfilesystemmodel.h>
+
QT_BEGIN_NAMESPACE
+
#ifndef QT_NO_FSCOMPLETER
/*!
@@ -74,7 +77,10 @@ public:
QAbstractProxyModel *proxyModel;
QFileSystemModel *sourceModel;
};
+
#endif // QT_NO_FSCOMPLETER
+
QT_END_NAMESPACE
+
#endif // QFSCOMPLETOR_P_H
diff --git a/src/widgets/dialogs/qinputdialog.h b/src/widgets/dialogs/qinputdialog.h
index 8adaf5a430..2fbea908cb 100644
--- a/src/widgets/dialogs/qinputdialog.h
+++ b/src/widgets/dialogs/qinputdialog.h
@@ -40,6 +40,7 @@
#ifndef QINPUTDIALOG_H
#define QINPUTDIALOG_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qdialog.h>
#include <QtCore/qstring.h>
#include <QtWidgets/qlineedit.h>
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index 3d52cb206a..ff31a7e874 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -200,7 +200,7 @@ public:
#endif
compatMode(false), autoAddOkButton(true),
detectedEscapeButton(0), informativeLabel(0),
- options(new QMessageDialogOptions) { }
+ options(QMessageDialogOptions::create()) { }
void init(const QString &title = QString(), const QString &text = QString());
void setupLayout();
@@ -218,9 +218,6 @@ public:
int layoutMinimumWidth();
void retranslateStrings();
-#ifdef Q_OS_WINCE
- void hideSpecial();
-#endif
static int showOldMessageBox(QWidget *parent, QMessageBox::Icon icon,
const QString &title, const QString &text,
int button0, int button1, int button2);
@@ -362,24 +359,15 @@ void QMessageBoxPrivate::updateSize()
return;
QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size();
-#if defined(Q_OS_WINCE)
- // the width of the screen, less the window border.
- int hardLimit = screenSize.width() - (q->frameGeometry().width() - q->geometry().width());
-#else
int hardLimit = qMin(screenSize.width() - 480, 1000); // can never get bigger than this
// on small screens allows the messagebox be the same size as the screen
if (screenSize.width() <= 1024)
hardLimit = screenSize.width();
-#endif
#ifdef Q_OS_MAC
int softLimit = qMin(screenSize.width()/2, 420);
#else
// note: ideally on windows, hard and soft limits but it breaks compat
-#ifndef Q_OS_WINCE
int softLimit = qMin(screenSize.width()/2, 500);
-#else
- int softLimit = qMin(screenSize.width() * 3 / 4, 500);
-#endif //Q_OS_WINCE
#endif
if (informativeLabel)
@@ -436,28 +424,6 @@ void QMessageBoxPrivate::updateSize()
QCoreApplication::removePostedEvents(q, QEvent::LayoutRequest);
}
-
-#ifdef Q_OS_WINCE
-/*!
- \internal
- Hides special buttons which are rather shown in the title bar
- on WinCE, to conserve screen space.
-*/
-
-void QMessageBoxPrivate::hideSpecial()
-{
- Q_Q(QMessageBox);
- QList<QPushButton*> list = q->findChildren<QPushButton*>();
- for (int i=0; i<list.size(); ++i) {
- QPushButton *pb = list.at(i);
- QString text = pb->text();
- text.remove(QChar::fromLatin1('&'));
- if (text == QApplication::translate("QMessageBox", "OK" ))
- pb->setFixedSize(0,0);
- }
-}
-#endif
-
static int oldButton(int button)
{
switch (button & QMessageBox::ButtonMask) {
@@ -1368,24 +1334,6 @@ bool QMessageBox::event(QEvent *e)
case QEvent::LanguageChange:
d_func()->retranslateStrings();
break;
-#ifdef Q_OS_WINCE
- case QEvent::OkRequest:
- case QEvent::HelpRequest: {
- QString bName =
- (e->type() == QEvent::OkRequest)
- ? QApplication::translate("QMessageBox", "OK")
- : QApplication::translate("QMessageBox", "Help");
- QList<QPushButton*> list = findChildren<QPushButton*>();
- for (int i=0; i<list.size(); ++i) {
- QPushButton *pb = list.at(i);
- if (pb->text() == bName) {
- if (pb->isEnabled())
- pb->click();
- return pb->isEnabled();
- }
- }
- }
-#endif
default:
break;
}
@@ -1525,20 +1473,6 @@ void QMessageBox::keyPressEvent(QKeyEvent *e)
QDialog::keyPressEvent(e);
}
-#ifdef Q_OS_WINCE
-/*!
- \reimp
-*/
-void QMessageBox::setVisible(bool visible)
-{
- Q_D(QMessageBox);
- if (visible)
- d->hideSpecial();
- QDialog::setVisible(visible);
-}
-#endif
-
-
/*!
\overload
@@ -1596,9 +1530,6 @@ void QMessageBox::showEvent(QShowEvent *e)
Q_D(QMessageBox);
if (d->autoAddOkButton) {
addButton(Ok);
-#if defined(Q_OS_WINCE)
- d->hideSpecial();
-#endif
}
if (d->detailsButton)
addButton(d->detailsButton, QMessageBox::ActionRole);
@@ -1912,9 +1843,6 @@ void QMessageBox::aboutQt(QWidget *parent, const QString &title)
QPixmap pm(QLatin1String(":/qt-project.org/qmessagebox/images/qtlogo-64.png"));
if (!pm.isNull())
msgBox->setIconPixmap(pm);
-#if defined(Q_OS_WINCE)
- msgBox->setDefaultButton(msgBox->addButton(QMessageBox::Ok));
-#endif
// should perhaps be a style hint
#ifdef Q_OS_MAC
diff --git a/src/widgets/dialogs/qmessagebox.h b/src/widgets/dialogs/qmessagebox.h
index c958e4c352..c6a55964fe 100644
--- a/src/widgets/dialogs/qmessagebox.h
+++ b/src/widgets/dialogs/qmessagebox.h
@@ -40,6 +40,7 @@
#ifndef QMESSAGEBOX_H
#define QMESSAGEBOX_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qdialog.h>
QT_BEGIN_NAMESPACE
@@ -142,10 +143,6 @@ public:
QPushButton *addButton(StandardButton button);
void removeButton(QAbstractButton *button);
-#ifdef Q_OS_WINCE
- void setVisible(bool visible);
-#endif
-
using QDialog::open;
void open(QObject *receiver, const char *member);
diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp
index f3fe500d26..26a8fcc92d 100644
--- a/src/widgets/dialogs/qprogressdialog.cpp
+++ b/src/widgets/dialogs/qprogressdialog.cpp
@@ -138,9 +138,10 @@ void QProgressDialogPrivate::init(const QString &labelText, const QString &cance
void QProgressDialogPrivate::layout()
{
Q_Q(QProgressDialog);
- int sp = q->style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing);
- int mtb = q->style()->pixelMetric(QStyle::PM_DefaultTopLevelMargin);
- int mlr = qMin(q->width() / 10, mtb);
+ int sp = q->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing, 0, q);
+ int mb = q->style()->pixelMetric(QStyle::PM_LayoutBottomMargin, 0, q);
+ int ml = qMin(q->width() / 10, q->style()->pixelMetric(QStyle::PM_LayoutLeftMargin, 0, q));
+ int mr = qMin(q->width() / 10, q->style()->pixelMetric(QStyle::PM_LayoutRightMargin, 0, q));
const bool centered =
bool(q->style()->styleHint(QStyle::SH_ProgressDialog_CenterCancelButton, 0, q));
@@ -154,12 +155,12 @@ void QProgressDialogPrivate::layout()
// dialog can be made very small if the user demands it so.
for (int attempt=5; attempt--;) {
cspc = cancel ? cs.height() + sp : 0;
- lh = qMax(0, q->height() - mtb - bh.height() - sp - cspc);
+ lh = qMax(0, q->height() - mb - bh.height() - sp - cspc);
if (lh < q->height()/4) {
// Getting cramped
sp /= 2;
- mtb /= 2;
+ mb /= 2;
if (cancel) {
cs.setHeight(qMax(4,cs.height()-sp-2));
}
@@ -171,14 +172,14 @@ void QProgressDialogPrivate::layout()
if (cancel) {
cancel->setGeometry(
- centered ? q->width()/2 - cs.width()/2 : q->width() - mlr - cs.width(),
- q->height() - mtb - cs.height(),
+ centered ? q->width()/2 - cs.width()/2 : q->width() - mr - cs.width(),
+ q->height() - mb - cs.height(),
cs.width(), cs.height());
}
if (label)
- label->setGeometry(mlr, additionalSpacing, q->width() - mlr * 2, lh);
- bar->setGeometry(mlr, lh + sp + additionalSpacing, q->width() - mlr * 2, bh.height());
+ label->setGeometry(ml, additionalSpacing, q->width() - ml - mr, lh);
+ bar->setGeometry(ml, lh + sp + additionalSpacing, q->width() - ml - mr, bh.height());
}
void QProgressDialogPrivate::retranslateStrings()
diff --git a/src/widgets/dialogs/qprogressdialog.h b/src/widgets/dialogs/qprogressdialog.h
index 888deac046..a5e333259f 100644
--- a/src/widgets/dialogs/qprogressdialog.h
+++ b/src/widgets/dialogs/qprogressdialog.h
@@ -40,6 +40,7 @@
#ifndef QPROGRESSDIALOG_H
#define QPROGRESSDIALOG_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qdialog.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/dialogs/qsidebar_p.h b/src/widgets/dialogs/qsidebar_p.h
index 210c86be01..3e177e7e68 100644
--- a/src/widgets/dialogs/qsidebar_p.h
+++ b/src/widgets/dialogs/qsidebar_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <qlistwidget.h>
#include <qstandarditemmodel.h>
#include <qstyleditemdelegate.h>
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp
index fed35ef638..bcad069b50 100644
--- a/src/widgets/dialogs/qwizard.cpp
+++ b/src/widgets/dialogs/qwizard.cpp
@@ -69,10 +69,6 @@
#include "private/qdialog_p.h"
#include <qdebug.h>
-#ifdef Q_OS_WINCE
-extern bool qt_wince_is_mobile(); //defined in qguifunctions_wce.cpp
-#endif
-
#include <string.h> // for memset()
#include <algorithm>
@@ -2215,10 +2211,6 @@ QWizard::QWizard(QWidget *parent, Qt::WindowFlags flags)
{
Q_D(QWizard);
d->init();
-#ifdef Q_OS_WINCE
- if (!qt_wince_is_mobile())
- setWindowFlags(windowFlags() & ~Qt::WindowOkButtonHint);
-#endif
}
/*!
diff --git a/src/widgets/dialogs/qwizard.h b/src/widgets/dialogs/qwizard.h
index a188833ef3..9ce68b6566 100644
--- a/src/widgets/dialogs/qwizard.h
+++ b/src/widgets/dialogs/qwizard.h
@@ -40,6 +40,7 @@
#ifndef QWIZARD_H
#define QWIZARD_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qdialog.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp
index 8bc5ba7f56..9d8e7c4b66 100644
--- a/src/widgets/dialogs/qwizard_win.cpp
+++ b/src/widgets/dialogs/qwizard_win.cpp
@@ -41,7 +41,6 @@
#ifndef QT_NO_STYLE_WINDOWSVISTA
#include "qwizard_win_p.h"
-#include <private/qsystemlibrary_p.h>
#include <private/qapplication_p.h>
#include <qpa/qplatformnativeinterface.h>
#include "qwizard.h"
@@ -54,112 +53,19 @@
#include <QtWidgets/QDesktopWidget>
#include <uxtheme.h>
+#include <vssym32.h>
+#include <dwmapi.h>
Q_DECLARE_METATYPE(QMargins)
-QT_BEGIN_NAMESPACE
+#ifndef WM_DWMCOMPOSITIONCHANGED
+# define WM_DWMCOMPOSITIONCHANGED 0x031E
+#endif
-//DWM related
-typedef struct { //MARGINS
- int cxLeftWidth; // width of left border that retains its size
- int cxRightWidth; // width of right border that retains its size
- int cyTopHeight; // height of top border that retains its size
- int cyBottomHeight; // height of bottom border that retains its size
-} WIZ_MARGINS;
-typedef struct { //DTTOPTS
- DWORD dwSize;
- DWORD dwFlags;
- COLORREF crText;
- COLORREF crBorder;
- COLORREF crShadow;
- int eTextShadowType;
- POINT ptShadowOffset;
- int iBorderSize;
- int iFontPropId;
- int iColorPropId;
- int iStateId;
- BOOL fApplyOverlay;
- int iGlowSize;
-} WIZ_DTTOPTS;
-
-typedef struct {
- DWORD dwFlags;
- DWORD dwMask;
-} WIZ_WTA_OPTIONS;
-
-#define WIZ_WM_THEMECHANGED 0x031A
-#define WIZ_WM_DWMCOMPOSITIONCHANGED 0x031E
-
-enum WIZ_WINDOWTHEMEATTRIBUTETYPE {
- WIZ_WTA_NONCLIENT = 1
-};
-
-#define WIZ_WTNCA_NODRAWCAPTION 0x00000001
-#define WIZ_WTNCA_NODRAWICON 0x00000002
-
-#define WIZ_DT_CENTER 0x00000001 //DT_CENTER
-#define WIZ_DT_VCENTER 0x00000004
-#define WIZ_DT_SINGLELINE 0x00000020
-#define WIZ_DT_NOPREFIX 0x00000800
-
-enum WIZ_NAVIGATIONPARTS { //NAVIGATIONPARTS
- WIZ_NAV_BACKBUTTON = 1,
- WIZ_NAV_FORWARDBUTTON = 2,
- WIZ_NAV_MENUBUTTON = 3,
-};
-
-enum WIZ_NAV_BACKBUTTONSTATES { //NAV_BACKBUTTONSTATES
- WIZ_NAV_BB_NORMAL = 1,
- WIZ_NAV_BB_HOT = 2,
- WIZ_NAV_BB_PRESSED = 3,
- WIZ_NAV_BB_DISABLED = 4,
-};
-
-#define WIZ_TMT_CAPTIONFONT (801) //TMT_CAPTIONFONT
-#define WIZ_DTT_COMPOSITED (1UL << 13) //DTT_COMPOSITED
-#define WIZ_DTT_GLOWSIZE (1UL << 11) //DTT_GLOWSIZE
-
-#define WIZ_WM_NCMOUSELEAVE 674 //WM_NCMOUSELEAVE
-
-#define WIZ_WP_CAPTION 1 //WP_CAPTION
-#define WIZ_CS_ACTIVE 1 //CS_ACTIVE
-#define WIZ_TMT_FILLCOLORHINT 3821 //TMT_FILLCOLORHINT
-#define WIZ_TMT_BORDERCOLORHINT 3822 //TMT_BORDERCOLORHINT
-
-typedef BOOL (WINAPI *PtrDwmDefWindowProc)(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *plResult);
-typedef HRESULT (WINAPI *PtrDwmIsCompositionEnabled)(BOOL* pfEnabled);
-typedef HRESULT (WINAPI *PtrDwmExtendFrameIntoClientArea)(HWND hWnd, const WIZ_MARGINS* pMarInset);
-typedef HRESULT (WINAPI *PtrSetWindowThemeAttribute)(HWND hwnd, enum WIZ_WINDOWTHEMEATTRIBUTETYPE eAttribute, PVOID pvAttribute, DWORD cbAttribute);
-
-static PtrDwmDefWindowProc pDwmDefWindowProc = 0;
-static PtrDwmIsCompositionEnabled pDwmIsCompositionEnabled = 0;
-static PtrDwmExtendFrameIntoClientArea pDwmExtendFrameIntoClientArea = 0;
-static PtrSetWindowThemeAttribute pSetWindowThemeAttribute = 0;
-
-//Theme related
-typedef bool (WINAPI *PtrIsAppThemed)();
-typedef bool (WINAPI *PtrIsThemeActive)();
-typedef HANDLE (WINAPI *PtrOpenThemeData)(HWND hwnd, LPCWSTR pszClassList);
-typedef HRESULT (WINAPI *PtrCloseThemeData)(HANDLE hTheme);
-typedef HRESULT (WINAPI *PtrGetThemeSysFont)(HANDLE hTheme, int iFontId, LOGFONTW *plf);
-typedef HRESULT (WINAPI *PtrDrawThemeTextEx)(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int cchText, DWORD dwTextFlags, LPRECT pRect, const WIZ_DTTOPTS *pOptions);
-typedef HRESULT (WINAPI *PtrDrawThemeBackground)(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, OPTIONAL const RECT *pClipRect);
-typedef HRESULT (WINAPI *PtrGetThemePartSize)(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, OPTIONAL RECT *prc, enum THEMESIZE eSize, OUT SIZE *psz);
-typedef HRESULT (WINAPI *PtrGetThemeColor)(HANDLE hTheme, int iPartId, int iStateId, int iPropId, OUT COLORREF *pColor);
-
-static PtrIsAppThemed pIsAppThemed = 0;
-static PtrIsThemeActive pIsThemeActive = 0;
-static PtrOpenThemeData pOpenThemeData = 0;
-static PtrCloseThemeData pCloseThemeData = 0;
-static PtrGetThemeSysFont pGetThemeSysFont = 0;
-static PtrDrawThemeTextEx pDrawThemeTextEx = 0;
-static PtrDrawThemeBackground pDrawThemeBackground = 0;
-static PtrGetThemePartSize pGetThemePartSize = 0;
-static PtrGetThemeColor pGetThemeColor = 0;
+QT_BEGIN_NAMESPACE
int QVistaHelper::instanceCount = 0;
int QVistaHelper::m_devicePixelRatio = 1;
-bool QVistaHelper::is_vista = false;
QVistaHelper::VistaState QVistaHelper::cachedVistaState = QVistaHelper::Dirty;
/******************************************************************************
@@ -179,14 +85,6 @@ QSize QVistaBackButton::sizeHint() const
ensurePolished();
int size = int(QStyleHelper::dpiScaled(32));
int width = size, height = size;
-/*
- HANDLE theme = pOpenThemeData(0, L"Navigation");
- SIZE size;
- if (pGetThemePartSize(theme, 0, WIZ_NAV_BACKBUTTON, WIZ_NAV_BB_NORMAL, 0, TS_TRUE, &size) == S_OK) {
- width = size.cx;
- height = size.cy;
- }
-*/
return QSize(width, height);
}
@@ -208,7 +106,7 @@ void QVistaBackButton::paintEvent(QPaintEvent *)
{
QPainter p(this);
QRect r = rect();
- HANDLE theme = pOpenThemeData(0, L"Navigation");
+ const HANDLE theme = OpenThemeData(0, L"Navigation");
//RECT rect;
QPoint origin;
const HDC hdc = QVistaHelper::backingStoreDC(parentWidget(), &origin);
@@ -225,19 +123,17 @@ void QVistaBackButton::paintEvent(QPaintEvent *)
clipRect.left = rDp.left() + xoffsetDp;
clipRect.right = rDp.right() + xoffsetDp;
- int state = WIZ_NAV_BB_NORMAL;
+ int state = NAV_BB_NORMAL;
if (!isEnabled())
- state = WIZ_NAV_BB_DISABLED;
+ state = NAV_BB_DISABLED;
else if (isDown())
- state = WIZ_NAV_BB_PRESSED;
+ state = NAV_BB_PRESSED;
else if (underMouse())
- state = WIZ_NAV_BB_HOT;
-
- WIZ_NAVIGATIONPARTS buttonType = (layoutDirection() == Qt::LeftToRight
- ? WIZ_NAV_BACKBUTTON
- : WIZ_NAV_FORWARDBUTTON);
+ state = NAV_BB_HOT;
- pDrawThemeBackground(theme, hdc, buttonType, state, &clipRect, &clipRect);
+ DrawThemeBackground(theme, hdc,
+ layoutDirection() == Qt::LeftToRight ? NAV_BACKBUTTON : NAV_FORWARDBUTTON,
+ state, &clipRect, &clipRect);
}
/******************************************************************************
@@ -251,13 +147,10 @@ QVistaHelper::QVistaHelper(QWizard *wizard)
, backButton_(0)
{
QVistaHelper::m_devicePixelRatio = wizard->devicePixelRatio();
- is_vista = resolveSymbols();
if (instanceCount++ == 0)
cachedVistaState = Dirty;
- if (is_vista) {
- backButton_ = new QVistaBackButton(wizard);
- backButton_->hide();
- }
+ backButton_ = new QVistaBackButton(wizard);
+ backButton_->hide();
// Handle diff between Windows 7 and Vista
iconSpacing = QStyleHelper::dpiScaled(7);
@@ -292,20 +185,13 @@ void QVistaHelper::updateCustomMargins(bool vistaMargins)
bool QVistaHelper::isCompositionEnabled()
{
- bool value = is_vista;
- if (is_vista) {
- HRESULT hr;
- BOOL bEnabled;
-
- hr = pDwmIsCompositionEnabled(&bEnabled);
- value = (SUCCEEDED(hr) && bEnabled);
- }
- return value;
+ BOOL bEnabled;
+ return SUCCEEDED(DwmIsCompositionEnabled(&bEnabled)) && bEnabled;
}
bool QVistaHelper::isThemeActive()
{
- return is_vista && pIsThemeActive();
+ return IsThemeActive();
}
QVistaHelper::VistaState QVistaHelper::vistaState()
@@ -326,11 +212,9 @@ QColor QVistaHelper::basicWindowFrameColor()
{
DWORD rgb;
HWND handle = QApplicationPrivate::getHWNDForWidget(QApplication::desktop());
- HANDLE hTheme = pOpenThemeData(handle, L"WINDOW");
- pGetThemeColor(
- hTheme, WIZ_WP_CAPTION, WIZ_CS_ACTIVE,
- wizard->isActiveWindow() ? WIZ_TMT_FILLCOLORHINT : WIZ_TMT_BORDERCOLORHINT,
- &rgb);
+ const HANDLE hTheme = OpenThemeData(handle, L"WINDOW");
+ GetThemeColor(hTheme, WP_CAPTION, CS_ACTIVE,
+ wizard->isActiveWindow() ? TMT_FILLCOLORHINT : TMT_BORDERCOLORHINT, &rgb);
BYTE r = GetRValue(rgb);
BYTE g = GetGValue(rgb);
BYTE b = GetBValue(rgb);
@@ -341,13 +225,13 @@ bool QVistaHelper::setDWMTitleBar(TitleBarChangeType type)
{
bool value = false;
if (vistaState() == VistaAero) {
- WIZ_MARGINS mar = {0, 0, 0, 0};
+ MARGINS mar = {0, 0, 0, 0};
if (type == NormalTitleBar)
mar.cyTopHeight = 0;
else
mar.cyTopHeight = (titleBarSize() + topOffset()) * QVistaHelper::m_devicePixelRatio;
if (const HWND wizardHandle = wizardHWND())
- if (SUCCEEDED(pDwmExtendFrameIntoClientArea(wizardHandle, &mar)))
+ if (SUCCEEDED(DwmExtendFrameIntoClientArea(wizardHandle, &mar)))
value = true;
}
return value;
@@ -359,7 +243,7 @@ static LOGFONT getCaptionLogFont(HANDLE hTheme)
{
LOGFONT result = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { 0 } };
- if (!hTheme || FAILED(pGetThemeSysFont(hTheme, WIZ_TMT_CAPTIONFONT, &result))) {
+ if (!hTheme || FAILED(GetThemeSysFont(hTheme, TMT_CAPTIONFONT, &result))) {
NONCLIENTMETRICS ncm;
ncm.cbSize = sizeof(NONCLIENTMETRICS);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, false);
@@ -370,10 +254,8 @@ static LOGFONT getCaptionLogFont(HANDLE hTheme)
static bool getCaptionQFont(int dpi, QFont *result)
{
- if (!pOpenThemeData)
- return false;
const HANDLE hTheme =
- pOpenThemeData(QApplicationPrivate::getHWNDForWidget(QApplication::desktop()), L"WINDOW");
+ OpenThemeData(QApplicationPrivate::getHWNDForWidget(QApplication::desktop()), L"WINDOW");
if (!hTheme)
return false;
// Call into QWindowsNativeInterface to convert the LOGFONT into a QFont.
@@ -448,16 +330,14 @@ void QVistaHelper::drawTitleBar(QPainter *painter)
void QVistaHelper::setTitleBarIconAndCaptionVisible(bool visible)
{
- if (is_vista) {
- WIZ_WTA_OPTIONS opt;
- opt.dwFlags = WIZ_WTNCA_NODRAWICON | WIZ_WTNCA_NODRAWCAPTION;
- if (visible)
- opt.dwMask = 0;
- else
- opt.dwMask = WIZ_WTNCA_NODRAWICON | WIZ_WTNCA_NODRAWCAPTION;
- if (const HWND handle = wizardHWND())
- pSetWindowThemeAttribute(handle, WIZ_WTA_NONCLIENT, &opt, sizeof(WIZ_WTA_OPTIONS));
- }
+ WTA_OPTIONS opt;
+ opt.dwFlags = WTNCA_NODRAWICON | WTNCA_NODRAWCAPTION;
+ if (visible)
+ opt.dwMask = 0;
+ else
+ opt.dwMask = WTNCA_NODRAWICON | WTNCA_NODRAWCAPTION;
+ if (const HWND handle = wizardHWND())
+ SetWindowThemeAttribute(handle, WTA_NONCLIENT, &opt, sizeof(WTA_OPTIONS));
}
bool QVistaHelper::winEvent(MSG* msg, long* result)
@@ -466,7 +346,7 @@ bool QVistaHelper::winEvent(MSG* msg, long* result)
case WM_NCHITTEST: {
LRESULT lResult;
// Perform hit testing using DWM
- if (pDwmDefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam, &lResult)) {
+ if (DwmDefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam, &lResult)) {
// DWM returned a hit, no further processing necessary
*result = lResult;
} else {
@@ -485,7 +365,7 @@ bool QVistaHelper::winEvent(MSG* msg, long* result)
default:
LRESULT lResult;
// Pass to DWM to handle
- if (pDwmDefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam, &lResult))
+ if (DwmDefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam, &lResult))
*result = lResult;
// If the message wasn't handled by DWM, continue processing it as normal
else
@@ -524,7 +404,7 @@ void QVistaHelper::mouseEvent(QEvent *event)
bool QVistaHelper::handleWinEvent(MSG *message, long *result)
{
- if (message->message == WIZ_WM_THEMECHANGED || message->message == WIZ_WM_DWMCOMPOSITIONCHANGED)
+ if (message->message == WM_THEMECHANGED || message->message == WM_DWMCOMPOSITIONCHANGED)
cachedVistaState = Dirty;
bool status = false;
@@ -707,7 +587,7 @@ bool QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const Q
const QRect rectDp = QRect(rect.topLeft() * QVistaHelper::m_devicePixelRatio,
rect.size() * QVistaHelper::m_devicePixelRatio);
HWND handle = QApplicationPrivate::getHWNDForWidget(QApplication::desktop());
- HANDLE hTheme = pOpenThemeData(handle, L"WINDOW");
+ const HANDLE hTheme = OpenThemeData(handle, L"WINDOW");
if (!hTheme) return false;
// Set up a memory DC and bitmap that we'll draw into
HDC dcMem;
@@ -732,15 +612,16 @@ bool QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const Q
HFONT hOldFont = (HFONT)SelectObject(dcMem, (HGDIOBJ) hCaptionFont);
// Draw the text!
- WIZ_DTTOPTS dto;
- dto.dwSize = sizeof(WIZ_DTTOPTS);
- const UINT uFormat = WIZ_DT_SINGLELINE|WIZ_DT_CENTER|WIZ_DT_VCENTER|WIZ_DT_NOPREFIX;
+ DTTOPTS dto;
+ memset(&dto, 0, sizeof(dto));
+ dto.dwSize = sizeof(dto);
+ const UINT uFormat = DT_SINGLELINE|DT_CENTER|DT_VCENTER|DT_NOPREFIX;
RECT rctext ={0,0, rectDp.width(), rectDp.height()};
- dto.dwFlags = WIZ_DTT_COMPOSITED|WIZ_DTT_GLOWSIZE;
+ dto.dwFlags = DTT_COMPOSITED|DTT_GLOWSIZE;
dto.iGlowSize = glowSize();
- pDrawThemeTextEx(hTheme, dcMem, 0, 0, (LPCWSTR)text.utf16(), -1, uFormat, &rctext, &dto );
+ DrawThemeTextEx(hTheme, dcMem, 0, 0, reinterpret_cast<LPCWSTR>(text.utf16()), -1, uFormat, &rctext, &dto );
BitBlt(hdc, rectDp.left(), rectDp.top(), rectDp.width(), rectDp.height(), dcMem, 0, 0, SRCCOPY);
SelectObject(dcMem, (HGDIOBJ) hOldBmp);
SelectObject(dcMem, (HGDIOBJ) hOldFont);
@@ -813,51 +694,6 @@ int QVistaHelper::captionSizeDp()
return GetSystemMetrics(SM_CYCAPTION);
}
-bool QVistaHelper::resolveSymbols()
-{
- static bool tried = false;
- if (!tried) {
- tried = true;
- QSystemLibrary dwmLib(L"dwmapi");
- pDwmIsCompositionEnabled =
- (PtrDwmIsCompositionEnabled)dwmLib.resolve("DwmIsCompositionEnabled");
- if (pDwmIsCompositionEnabled) {
- pDwmDefWindowProc = (PtrDwmDefWindowProc)dwmLib.resolve("DwmDefWindowProc");
- pDwmExtendFrameIntoClientArea =
- (PtrDwmExtendFrameIntoClientArea)dwmLib.resolve("DwmExtendFrameIntoClientArea");
- }
- QSystemLibrary themeLib(L"uxtheme");
- pIsAppThemed = (PtrIsAppThemed)themeLib.resolve("IsAppThemed");
- if (pIsAppThemed) {
- pDrawThemeBackground = (PtrDrawThemeBackground)themeLib.resolve("DrawThemeBackground");
- pGetThemePartSize = (PtrGetThemePartSize)themeLib.resolve("GetThemePartSize");
- pGetThemeColor = (PtrGetThemeColor)themeLib.resolve("GetThemeColor");
- pIsThemeActive = (PtrIsThemeActive)themeLib.resolve("IsThemeActive");
- pOpenThemeData = (PtrOpenThemeData)themeLib.resolve("OpenThemeData");
- pCloseThemeData = (PtrCloseThemeData)themeLib.resolve("CloseThemeData");
- pGetThemeSysFont = (PtrGetThemeSysFont)themeLib.resolve("GetThemeSysFont");
- pDrawThemeTextEx = (PtrDrawThemeTextEx)themeLib.resolve("DrawThemeTextEx");
- pSetWindowThemeAttribute = (PtrSetWindowThemeAttribute)themeLib.resolve("SetWindowThemeAttribute");
- }
- }
-
- return (
- pDwmIsCompositionEnabled != 0
- && pDwmDefWindowProc != 0
- && pDwmExtendFrameIntoClientArea != 0
- && pIsAppThemed != 0
- && pDrawThemeBackground != 0
- && pGetThemePartSize != 0
- && pGetThemeColor != 0
- && pIsThemeActive != 0
- && pOpenThemeData != 0
- && pCloseThemeData != 0
- && pGetThemeSysFont != 0
- && pDrawThemeTextEx != 0
- && pSetWindowThemeAttribute != 0
- );
-}
-
int QVistaHelper::titleOffset()
{
int iconOffset = wizard ->windowIcon().isNull() ? 0 : iconSize() + textSpacing;
diff --git a/src/widgets/dialogs/qwizard_win_p.h b/src/widgets/dialogs/qwizard_win_p.h
index 42b4dee784..288e7adaf5 100644
--- a/src/widgets/dialogs/qwizard_win_p.h
+++ b/src/widgets/dialogs/qwizard_win_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#ifndef QT_NO_WIZARD
#ifndef QT_NO_STYLE_WINDOWSVISTA
@@ -126,7 +126,6 @@ private:
int leftMargin() { return backButton_->isVisible() ? backButtonSize() + iconSpacing : 0; }
int titleOffset();
- bool resolveSymbols();
void drawTitleBar(QPainter *painter);
void setMouseCursor(QPoint pos);
void collapseTopFrameStrut();
@@ -137,7 +136,6 @@ private:
bool eventFilter(QObject *obj, QEvent *event);
static int instanceCount;
- static bool is_vista;
static VistaState cachedVistaState;
static bool isCompositionEnabled();
static bool isThemeActive();
diff --git a/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp b/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp
index c39a0d83bb..a907a0421f 100644
--- a/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp
+++ b/src/widgets/doc/snippets/code/src_gui_kernel_qapplication.cpp
@@ -77,6 +77,7 @@ QApplication::setStyle(QStyleFactory::create("Fusion"));
//! [1]
+// ### fixme: Qt 6: Remove [2]
//! [2]
int main(int argc, char *argv[])
{
diff --git a/src/widgets/effects/qgraphicseffect.h b/src/widgets/effects/qgraphicseffect.h
index 07c826fc93..06ee78f2a0 100644
--- a/src/widgets/effects/qgraphicseffect.h
+++ b/src/widgets/effects/qgraphicseffect.h
@@ -40,6 +40,7 @@
#ifndef QGRAPHICSEFFECT_H
#define QGRAPHICSEFFECT_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qpoint.h>
#include <QtCore/qrect.h>
diff --git a/src/widgets/effects/qgraphicseffect_p.h b/src/widgets/effects/qgraphicseffect_p.h
index 3c8dc0338d..12bdbfe6fc 100644
--- a/src/widgets/effects/qgraphicseffect_p.h
+++ b/src/widgets/effects/qgraphicseffect_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qgraphicseffect.h"
#include <QPixmapCache>
diff --git a/src/widgets/effects/qpixmapfilter_p.h b/src/widgets/effects/qpixmapfilter_p.h
index 0aeedaf827..b9af3ae916 100644
--- a/src/widgets/effects/qpixmapfilter_p.h
+++ b/src/widgets/effects/qpixmapfilter_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtCore/qnamespace.h>
#include <QtGui/qpixmap.h>
#include <QtWidgets/qgraphicseffect.h>
diff --git a/src/widgets/graphicsview/qgraph_p.h b/src/widgets/graphicsview/qgraph_p.h
index 14f7122d5c..b0bf3c91c9 100644
--- a/src/widgets/graphicsview/qgraph_p.h
+++ b/src/widgets/graphicsview/qgraph_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtCore/QHash>
#include <QtCore/QQueue>
#include <QtCore/QString>
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout.h b/src/widgets/graphicsview/qgraphicsanchorlayout.h
index e824edfd0a..6d69957400 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout.h
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout.h
@@ -40,6 +40,7 @@
#ifndef QGRAPHICSANCHORLAYOUT_H
#define QGRAPHICSANCHORLAYOUT_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qgraphicsitem.h>
#include <QtWidgets/qgraphicslayout.h>
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h
index c284e6ace3..ee11cb8561 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QGraphicsWidget>
#include <private/qobject_p.h>
diff --git a/src/widgets/graphicsview/qgraphicsgridlayout.h b/src/widgets/graphicsview/qgraphicsgridlayout.h
index 0687511966..c7c2edd2a2 100644
--- a/src/widgets/graphicsview/qgraphicsgridlayout.h
+++ b/src/widgets/graphicsview/qgraphicsgridlayout.h
@@ -40,6 +40,7 @@
#ifndef QGRAPHICSGRIDLAYOUT_H
#define QGRAPHICSGRIDLAYOUT_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qgraphicsitem.h>
#include <QtWidgets/qgraphicslayout.h>
diff --git a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h
index 08e4af6f8c..a099dace6b 100644
--- a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h
+++ b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtGui/private/qgridlayoutengine_p.h>
#ifndef QT_NO_GRAPHICSVIEW
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index df81d70742..4b5e380f4b 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -1439,9 +1439,8 @@ void QGraphicsItemPrivate::initStyleOption(QStyleOptionGraphicsItem *option, con
// Determine the item's exposed area
option->exposedRect = QRectF();
const QTransform reverseMap = worldTransform.inverted();
- const QVector<QRect> exposedRects(exposedRegion.rects());
- for (int i = 0; i < exposedRects.size(); ++i) {
- option->exposedRect |= reverseMap.mapRect(QRectF(exposedRects.at(i)));
+ for (const QRect &exposedRect : exposedRegion) {
+ option->exposedRect |= reverseMap.mapRect(QRectF(exposedRect));
if (option->exposedRect.contains(brect))
break;
}
@@ -5350,8 +5349,7 @@ QRegion QGraphicsItem::boundingRegion(const QTransform &itemToDeviceTransform) c
QTransform unscale = QTransform::fromScale(1 / granularity, 1 / granularity);
QRegion r;
QBitmap colorMask = QBitmap::fromImage(mask.createMaskFromColor(0));
- const auto rects = QRegion(colorMask).rects();
- for (const QRect &rect : rects) {
+ for (const QRect &rect : QRegion(colorMask)) {
QRect xrect = unscale.mapRect(rect).translated(deviceRect.topLeft() - QPoint(pad, pad));
r += xrect.adjusted(-1, -1, 1, 1) & deviceRect;
}
@@ -5915,9 +5913,8 @@ void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect)
// Append newly exposed areas. Note that the exposed region is currently
// in pixmap coordinates, so we have to translate it to item coordinates.
exposed.translate(cache->boundingRect.topLeft());
- const QVector<QRect> exposedRects = exposed.rects();
- for (int i = 0; i < exposedRects.size(); ++i)
- cache->exposed += exposedRects.at(i);
+ for (const QRect &exposedRect : exposed)
+ cache->exposed += exposedRect;
// Trigger update. This will redraw the newly exposed area and make sure
// the pixmap is re-blitted in case there are overlapping items.
diff --git a/src/widgets/graphicsview/qgraphicsitem.h b/src/widgets/graphicsview/qgraphicsitem.h
index fa51739bb9..59656f5b0b 100644
--- a/src/widgets/graphicsview/qgraphicsitem.h
+++ b/src/widgets/graphicsview/qgraphicsitem.h
@@ -40,7 +40,7 @@
#ifndef QGRAPHICSITEM_H
#define QGRAPHICSITEM_H
-#include <QtCore/qglobal.h>
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qvariant.h>
#include <QtCore/qrect.h>
diff --git a/src/widgets/graphicsview/qgraphicsitem_p.h b/src/widgets/graphicsview/qgraphicsitem_p.h
index e45e18c484..c88236d6e8 100644
--- a/src/widgets/graphicsview/qgraphicsitem_p.h
+++ b/src/widgets/graphicsview/qgraphicsitem_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qgraphicsitem.h"
#include "qset.h"
#include "qpixmapcache.h"
diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.h b/src/widgets/graphicsview/qgraphicsitemanimation.h
index 9c2a26e5d5..f02e0ac793 100644
--- a/src/widgets/graphicsview/qgraphicsitemanimation.h
+++ b/src/widgets/graphicsview/qgraphicsitemanimation.h
@@ -40,6 +40,7 @@
#ifndef QGRAPHICSITEMANIMATION_H
#define QGRAPHICSITEMANIMATION_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qobject.h>
#if !defined(QT_NO_GRAPHICSVIEW)
diff --git a/src/widgets/graphicsview/qgraphicslayout.h b/src/widgets/graphicsview/qgraphicslayout.h
index bf79f29f48..5b1c465414 100644
--- a/src/widgets/graphicsview/qgraphicslayout.h
+++ b/src/widgets/graphicsview/qgraphicslayout.h
@@ -40,6 +40,7 @@
#ifndef QGRAPHICSLAYOUT_H
#define QGRAPHICSLAYOUT_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qgraphicslayoutitem.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/graphicsview/qgraphicslayout_p.h b/src/widgets/graphicsview/qgraphicslayout_p.h
index 043d2cf077..47d8611786 100644
--- a/src/widgets/graphicsview/qgraphicslayout_p.h
+++ b/src/widgets/graphicsview/qgraphicslayout_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#if !defined(QT_NO_GRAPHICSVIEW)
diff --git a/src/widgets/graphicsview/qgraphicslayoutitem.h b/src/widgets/graphicsview/qgraphicslayoutitem.h
index 639f04f1bd..02bda0ad8d 100644
--- a/src/widgets/graphicsview/qgraphicslayoutitem.h
+++ b/src/widgets/graphicsview/qgraphicslayoutitem.h
@@ -40,6 +40,7 @@
#ifndef QGRAPHICSLAYOUTITEM_H
#define QGRAPHICSLAYOUTITEM_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qscopedpointer.h>
#include <QtWidgets/qsizepolicy.h>
#include <QtGui/qevent.h>
diff --git a/src/widgets/graphicsview/qgraphicslayoutitem_p.h b/src/widgets/graphicsview/qgraphicslayoutitem_p.h
index 355e2ab47d..96e7cc7fd9 100644
--- a/src/widgets/graphicsview/qgraphicslayoutitem_p.h
+++ b/src/widgets/graphicsview/qgraphicslayoutitem_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtCore/QSizeF>
#include <QtWidgets/QSizePolicy>
diff --git a/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h b/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h
index 7edc61ef12..9d3aa22548 100644
--- a/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h
+++ b/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h
@@ -50,6 +50,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtGui/private/qabstractlayoutstyleinfo_p.h>
#include <QtWidgets/qstyleoption.h>
diff --git a/src/widgets/graphicsview/qgraphicslinearlayout.h b/src/widgets/graphicsview/qgraphicslinearlayout.h
index c30f11b1b2..ebe8e903d9 100644
--- a/src/widgets/graphicsview/qgraphicslinearlayout.h
+++ b/src/widgets/graphicsview/qgraphicslinearlayout.h
@@ -40,6 +40,7 @@
#ifndef QGRAPHICSLINEARLAYOUT_H
#define QGRAPHICSLINEARLAYOUT_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qgraphicsitem.h>
#include <QtWidgets/qgraphicslayout.h>
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.h b/src/widgets/graphicsview/qgraphicsproxywidget.h
index 7fbfba6dac..8112c65d63 100644
--- a/src/widgets/graphicsview/qgraphicsproxywidget.h
+++ b/src/widgets/graphicsview/qgraphicsproxywidget.h
@@ -40,6 +40,7 @@
#ifndef QGRAPHICSPROXYWIDGET_H
#define QGRAPHICSPROXYWIDGET_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qgraphicswidget.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget_p.h b/src/widgets/graphicsview/qgraphicsproxywidget_p.h
index 1e49bcb143..0797ba7066 100644
--- a/src/widgets/graphicsview/qgraphicsproxywidget_p.h
+++ b/src/widgets/graphicsview/qgraphicsproxywidget_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qgraphicsproxywidget.h"
#include "private/qgraphicswidget_p.h"
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index b63686cd77..aa781e8f8b 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -4657,8 +4657,7 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
for (int i = 0; i < exposed.size(); ++i)
br |= exposed.at(i);
QTransform pixmapToItem = itemToPixmap.inverted();
- const auto rects = scrollExposure.rects();
- for (const QRect &r : rects)
+ for (const QRect &r : scrollExposure)
br |= pixmapToItem.mapRect(r);
}
styleOptionTmp = *option;
@@ -5431,12 +5430,14 @@ bool QGraphicsScene::focusNextPrevChild(bool next)
return true;
}
if (d->activePanel->isWidget()) {
- QGraphicsWidget *fw = static_cast<QGraphicsWidget *>(d->activePanel)->d_func()->focusNext;
+ QGraphicsWidget *test = static_cast<QGraphicsWidget *>(d->activePanel);
+ QGraphicsWidget *fw = next ? test->d_func()->focusNext : test->d_func()->focusPrev;
do {
if (fw->focusPolicy() & Qt::TabFocus) {
setFocusItem(fw, next ? Qt::TabFocusReason : Qt::BacktabFocusReason);
return true;
}
+ fw = next ? fw->d_func()->focusNext : fw->d_func()->focusPrev;
} while (fw != d->activePanel);
}
}
diff --git a/src/widgets/graphicsview/qgraphicsscene.h b/src/widgets/graphicsview/qgraphicsscene.h
index 5535295676..b1846303f7 100644
--- a/src/widgets/graphicsview/qgraphicsscene.h
+++ b/src/widgets/graphicsview/qgraphicsscene.h
@@ -40,6 +40,7 @@
#ifndef QGRAPHICSSCENE_H
#define QGRAPHICSSCENE_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qpoint.h>
#include <QtCore/qrect.h>
diff --git a/src/widgets/graphicsview/qgraphicsscene_bsp_p.h b/src/widgets/graphicsview/qgraphicsscene_bsp_p.h
index 5b83817911..1ab9c10d6a 100644
--- a/src/widgets/graphicsview/qgraphicsscene_bsp_p.h
+++ b/src/widgets/graphicsview/qgraphicsscene_bsp_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtCore/qlist.h>
#if !defined(QT_NO_GRAPHICSVIEW)
diff --git a/src/widgets/graphicsview/qgraphicsscene_p.h b/src/widgets/graphicsview/qgraphicsscene_p.h
index ed9dd99822..795676878b 100644
--- a/src/widgets/graphicsview/qgraphicsscene_p.h
+++ b/src/widgets/graphicsview/qgraphicsscene_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qgraphicsscene.h"
#if !defined(QT_NO_GRAPHICSVIEW)
diff --git a/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h b/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h
index faa847ff80..b195a4757c 100644
--- a/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h
+++ b/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h
@@ -51,7 +51,7 @@
#ifndef QGRAPHICSBSPTREEINDEX_H
#define QGRAPHICSBSPTREEINDEX_H
-#include <QtCore/qglobal.h>
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#if !defined(QT_NO_GRAPHICSVIEW)
diff --git a/src/widgets/graphicsview/qgraphicssceneevent.h b/src/widgets/graphicsview/qgraphicssceneevent.h
index 3b4eaa828e..4d6cde1b87 100644
--- a/src/widgets/graphicsview/qgraphicssceneevent.h
+++ b/src/widgets/graphicsview/qgraphicssceneevent.h
@@ -40,6 +40,7 @@
#ifndef QGRAPHICSSCENEEVENT_H
#define QGRAPHICSSCENEEVENT_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qcoreevent.h>
#include <QtCore/qpoint.h>
#include <QtCore/qscopedpointer.h>
diff --git a/src/widgets/graphicsview/qgraphicssceneindex_p.h b/src/widgets/graphicsview/qgraphicssceneindex_p.h
index 79936aee66..2085acd532 100644
--- a/src/widgets/graphicsview/qgraphicssceneindex_p.h
+++ b/src/widgets/graphicsview/qgraphicssceneindex_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qgraphicsscene_p.h"
#include "qgraphicsscene.h"
#include <private/qobject_p.h>
diff --git a/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h b/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h
index 7ad14d1e6e..a9d73459c0 100644
--- a/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h
+++ b/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#if !defined(QT_NO_GRAPHICSVIEW)
diff --git a/src/widgets/graphicsview/qgraphicstransform.h b/src/widgets/graphicsview/qgraphicstransform.h
index 7d5004c7a0..6a76926725 100644
--- a/src/widgets/graphicsview/qgraphicstransform.h
+++ b/src/widgets/graphicsview/qgraphicstransform.h
@@ -40,6 +40,7 @@
#ifndef QGRAPHICSTRANSFORM_H
#define QGRAPHICSTRANSFORM_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/QObject>
#include <QtGui/QVector3D>
#include <QtGui/QTransform>
diff --git a/src/widgets/graphicsview/qgraphicstransform_p.h b/src/widgets/graphicsview/qgraphicstransform_p.h
index 85ebdf87ba..39f7ab5487 100644
--- a/src/widgets/graphicsview/qgraphicstransform_p.h
+++ b/src/widgets/graphicsview/qgraphicstransform_p.h
@@ -51,8 +51,11 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qobject_p.h"
+
#ifndef QT_NO_GRAPHICSVIEW
+
QT_BEGIN_NAMESPACE
class QGraphicsItem;
@@ -73,6 +76,7 @@ public:
};
QT_END_NAMESPACE
+
#endif //QT_NO_GRAPHCISVIEW
#endif // QGRAPHICSTRANSFORM_P_H
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp
index 442918169a..3f7d2d1cd1 100644
--- a/src/widgets/graphicsview/qgraphicsview.cpp
+++ b/src/widgets/graphicsview/qgraphicsview.cpp
@@ -1029,9 +1029,7 @@ bool QGraphicsViewPrivate::updateRegion(const QRectF &rect, const QTransform &xf
if (!intersectsViewport(viewRect, viewport->width(), viewport->height()))
return false; // Update region for sure outside viewport.
- const QVector<QRect> &rects = region.rects();
- for (int i = 0; i < rects.size(); ++i) {
- viewRect = rects.at(i);
+ for (QRect viewRect : region) {
if (dontAdjustForAntialiasing)
viewRect.adjust(-1, -1, 1, 1);
else
@@ -1146,8 +1144,7 @@ QList<QGraphicsItem *> QGraphicsViewPrivate::findItems(const QRegion &exposedReg
// the expose region, convert it to a path, and then search for items
// using QGraphicsScene::items(QPainterPath);
QRegion adjustedRegion;
- const auto rects = exposedRegion.rects();
- for (const QRect &r : rects)
+ for (const QRect &r : exposedRegion)
adjustedRegion += r.adjusted(-1, -1, 1, 1);
const QPainterPath exposedScenePath(q->mapToScene(qt_regionToPath(adjustedRegion)));
@@ -2676,11 +2673,9 @@ void QGraphicsView::updateScene(const QList<QRectF> &rects)
// Extract and reset dirty scene rect info.
QVector<QRect> dirtyViewportRects;
- const QVector<QRect> &dirtyRects = d->dirtyRegion.rects();
- const int dirtyRectsCount = dirtyRects.size();
- dirtyViewportRects.reserve(dirtyRectsCount + rects.count());
- for (int i = 0; i < dirtyRectsCount; ++i)
- dirtyViewportRects += dirtyRects.at(i);
+ dirtyViewportRects.reserve(d->dirtyRegion.rectCount() + rects.count());
+ for (const QRect &dirtyRect : d->dirtyRegion)
+ dirtyViewportRects += dirtyRect;
d->dirtyRegion = QRegion();
d->dirtyBoundingRect = QRect();
diff --git a/src/widgets/graphicsview/qgraphicsview.h b/src/widgets/graphicsview/qgraphicsview.h
index 97152d3bca..327a75c374 100644
--- a/src/widgets/graphicsview/qgraphicsview.h
+++ b/src/widgets/graphicsview/qgraphicsview.h
@@ -40,6 +40,7 @@
#ifndef QGRAPHICSVIEW_H
#define QGRAPHICSVIEW_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qmetatype.h>
#include <QtGui/qpainter.h>
#include <QtWidgets/qscrollarea.h>
diff --git a/src/widgets/graphicsview/qgraphicsview_p.h b/src/widgets/graphicsview/qgraphicsview_p.h
index 7c4058b18b..9065650216 100644
--- a/src/widgets/graphicsview/qgraphicsview_p.h
+++ b/src/widgets/graphicsview/qgraphicsview_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qgraphicsview.h"
#if !defined(QT_NO_GRAPHICSVIEW)
diff --git a/src/widgets/graphicsview/qgraphicswidget.h b/src/widgets/graphicsview/qgraphicswidget.h
index e147c06fc9..5cb97db381 100644
--- a/src/widgets/graphicsview/qgraphicswidget.h
+++ b/src/widgets/graphicsview/qgraphicswidget.h
@@ -40,6 +40,7 @@
#ifndef QGRAPHICSWIDGET_H
#define QGRAPHICSWIDGET_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtGui/qfont.h>
#include <QtWidgets/qgraphicslayoutitem.h>
#include <QtWidgets/qgraphicsitem.h>
diff --git a/src/widgets/graphicsview/qgraphicswidget_p.h b/src/widgets/graphicsview/qgraphicswidget_p.h
index 195704f915..18542c68e6 100644
--- a/src/widgets/graphicsview/qgraphicswidget_p.h
+++ b/src/widgets/graphicsview/qgraphicswidget_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <private/qobject_p.h>
#include "qgraphicsitem_p.h"
#include "qgraphicswidget.h"
diff --git a/src/widgets/graphicsview/qsimplex_p.h b/src/widgets/graphicsview/qsimplex_p.h
index 61af6fbc3d..634b2e0425 100644
--- a/src/widgets/graphicsview/qsimplex_p.h
+++ b/src/widgets/graphicsview/qsimplex_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtCore/qhash.h>
#include <QtCore/qpair.h>
#include <QtCore/qstring.h>
diff --git a/src/widgets/itemviews/qabstractitemdelegate.h b/src/widgets/itemviews/qabstractitemdelegate.h
index 9fe72655ab..9f7a7716af 100644
--- a/src/widgets/itemviews/qabstractitemdelegate.h
+++ b/src/widgets/itemviews/qabstractitemdelegate.h
@@ -40,6 +40,7 @@
#ifndef QABSTRACTITEMDELEGATE_H
#define QABSTRACTITEMDELEGATE_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qobject.h>
#include <QtWidgets/qstyleoption.h>
diff --git a/src/widgets/itemviews/qabstractitemdelegate_p.h b/src/widgets/itemviews/qabstractitemdelegate_p.h
index 958737dd01..0b03be63f0 100644
--- a/src/widgets/itemviews/qabstractitemdelegate_p.h
+++ b/src/widgets/itemviews/qabstractitemdelegate_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qabstractitemdelegate.h"
#include <private/qobject_p.h>
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index 578f040f77..42b35ac644 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -340,8 +340,8 @@ void QAbstractItemViewPrivate::_q_scrollerStateChanged()
This enum indicates how the view responds to user selections:
\value SingleSelection When the user selects an item, any already-selected
- item becomes unselected, and the user cannot unselect the selected item by
- clicking on it.
+ item becomes unselected. It is possible for the user to deselect the selected
+ item.
\value ContiguousSelection When the user selects an item in the usual way,
the selection is cleared and the new item selected. However, if the user
diff --git a/src/widgets/itemviews/qabstractitemview.h b/src/widgets/itemviews/qabstractitemview.h
index 4741833654..d6c5d58934 100644
--- a/src/widgets/itemviews/qabstractitemview.h
+++ b/src/widgets/itemviews/qabstractitemview.h
@@ -40,6 +40,7 @@
#ifndef QABSTRACTITEMVIEW_H
#define QABSTRACTITEMVIEW_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qabstractscrollarea.h>
#include <QtCore/qabstractitemmodel.h>
#include <QtCore/qitemselectionmodel.h>
diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h
index fcbe25d735..f8ada6df08 100644
--- a/src/widgets/itemviews/qabstractitemview_p.h
+++ b/src/widgets/itemviews/qabstractitemview_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qabstractscrollarea_p.h"
#include "private/qabstractitemmodel_p.h"
#include "QtWidgets/qapplication.h"
diff --git a/src/widgets/itemviews/qbsptree_p.h b/src/widgets/itemviews/qbsptree_p.h
index 4e57297296..5fd7a5c45f 100644
--- a/src/widgets/itemviews/qbsptree_p.h
+++ b/src/widgets/itemviews/qbsptree_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <qvector.h>
#include <qrect.h>
diff --git a/src/widgets/itemviews/qcolumnview.h b/src/widgets/itemviews/qcolumnview.h
index 1cf6acc405..7d5e2f5cd1 100644
--- a/src/widgets/itemviews/qcolumnview.h
+++ b/src/widgets/itemviews/qcolumnview.h
@@ -40,6 +40,7 @@
#ifndef QCOLUMNVIEW_H
#define QCOLUMNVIEW_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qabstractitemview.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/itemviews/qcolumnview_p.h b/src/widgets/itemviews/qcolumnview_p.h
index 73d3e440d5..7eff0f66cd 100644
--- a/src/widgets/itemviews/qcolumnview_p.h
+++ b/src/widgets/itemviews/qcolumnview_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qcolumnview.h"
#ifndef QT_NO_QCOLUMNVIEW
diff --git a/src/widgets/itemviews/qcolumnviewgrip_p.h b/src/widgets/itemviews/qcolumnviewgrip_p.h
index 8c82486968..3447f9f824 100644
--- a/src/widgets/itemviews/qcolumnviewgrip_p.h
+++ b/src/widgets/itemviews/qcolumnviewgrip_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <private/qwidget_p.h>
#ifndef QT_NO_QCOLUMNVIEW
diff --git a/src/widgets/itemviews/qdatawidgetmapper.h b/src/widgets/itemviews/qdatawidgetmapper.h
index e7e4bc7210..4d244349ad 100644
--- a/src/widgets/itemviews/qdatawidgetmapper.h
+++ b/src/widgets/itemviews/qdatawidgetmapper.h
@@ -40,6 +40,7 @@
#ifndef QDATAWIDGETMAPPER_H
#define QDATAWIDGETMAPPER_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include "QtCore/qobject.h"
#ifndef QT_NO_DATAWIDGETMAPPER
diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp
index 1546037c2c..95e6a1840d 100644
--- a/src/widgets/itemviews/qdirmodel.cpp
+++ b/src/widgets/itemviews/qdirmodel.cpp
@@ -858,7 +858,7 @@ QModelIndex QDirModel::index(const QString &path, int column) const
return QModelIndex();
QString absolutePath = QDir(path).absolutePath();
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
absolutePath = absolutePath.toLower();
// On Windows, "filename......." and "filename" are equivalent
if (absolutePath.endsWith(QLatin1Char('.'))) {
@@ -873,7 +873,7 @@ QModelIndex QDirModel::index(const QString &path, int column) const
QStringList pathElements = absolutePath.split(QLatin1Char('/'), QString::SkipEmptyParts);
if ((pathElements.isEmpty() || !QFileInfo::exists(path))
-#if !defined(Q_OS_WIN) || defined(Q_OS_WINCE)
+#if !defined(Q_OS_WIN)
&& path != QLatin1String("/")
#endif
)
@@ -883,7 +883,7 @@ QModelIndex QDirModel::index(const QString &path, int column) const
if (!d->root.populated) // make sure the root is populated
d->populate(&d->root);
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
if (absolutePath.startsWith(QLatin1String("//"))) { // UNC path
QString host = pathElements.constFirst();
int r = 0;
@@ -901,7 +901,7 @@ QModelIndex QDirModel::index(const QString &path, int column) const
emit const_cast<QDirModel*>(this)->layoutChanged();
} else
#endif
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
if (pathElements.at(0).endsWith(QLatin1Char(':'))) {
pathElements[0] += QLatin1Char('/');
}
@@ -925,7 +925,7 @@ QModelIndex QDirModel::index(const QString &path, int column) const
const QFileInfo& fi = parent->children.at(j).info;
QString childFileName;
childFileName = idx.isValid() ? fi.fileName() : fi.absoluteFilePath();
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
childFileName = childFileName.toLower();
#endif
if (childFileName == element) {
@@ -938,15 +938,7 @@ QModelIndex QDirModel::index(const QString &path, int column) const
// we couldn't find the path element, we create a new node since we _know_ that the path is valid
if (row == -1) {
-#if defined(Q_OS_WINCE)
- QString newPath;
- if (parent->info.isRoot())
- newPath = parent->info.absoluteFilePath() + element;
- else
- newPath = parent->info.absoluteFilePath() + QLatin1Char('/') + element;
-#else
QString newPath = parent->info.absoluteFilePath() + QLatin1Char('/') + element;
-#endif
if (!d->allowAppendChild || !QFileInfo(newPath).isDir())
return QModelIndex();
d->appendChild(parent, newPath);
@@ -1290,7 +1282,7 @@ QString QDirModelPrivate::name(const QModelIndex &index) const
const QFileInfo info = n->info;
if (info.isRoot()) {
QString name = info.absoluteFilePath();
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
if (name.startsWith(QLatin1Char('/'))) // UNC host
return info.fileName();
if (name.endsWith(QLatin1Char('/')))
diff --git a/src/widgets/itemviews/qdirmodel.h b/src/widgets/itemviews/qdirmodel.h
index 7b4b859e0e..90a9809986 100644
--- a/src/widgets/itemviews/qdirmodel.h
+++ b/src/widgets/itemviews/qdirmodel.h
@@ -40,6 +40,7 @@
#ifndef QDIRMODEL_H
#define QDIRMODEL_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qabstractitemmodel.h>
#include <QtCore/qdir.h>
#include <QtWidgets/qfileiconprovider.h>
diff --git a/src/widgets/itemviews/qfileiconprovider.cpp b/src/widgets/itemviews/qfileiconprovider.cpp
index 66c0ffcd58..8c3cf3859e 100644
--- a/src/widgets/itemviews/qfileiconprovider.cpp
+++ b/src/widgets/itemviews/qfileiconprovider.cpp
@@ -60,106 +60,6 @@
QT_BEGIN_NAMESPACE
-static bool isCacheable(const QFileInfo &fi);
-
-class QFileIconEngine : public QPixmapIconEngine
-{
-public:
- QFileIconEngine(const QFileInfo &info, QFileIconProvider::Options opts)
- : QPixmapIconEngine(), m_fileInfo(info), m_fipOpts(opts)
- { }
-
- QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) Q_DECL_OVERRIDE
- {
- Q_UNUSED(mode);
- Q_UNUSED(state);
- QPixmap pixmap;
-
- if (!size.isValid())
- return pixmap;
-
- const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme();
- if (!theme)
- return pixmap;
-
- const QString &keyBase = QLatin1String("qt_.") + m_fileInfo.suffix().toUpper();
-
- bool cacheable = isCacheable(m_fileInfo);
- if (cacheable) {
- QPixmapCache::find(keyBase + QString::number(size.width()), pixmap);
- if (!pixmap.isNull())
- return pixmap;
- }
-
- QPlatformTheme::IconOptions iconOptions;
- if (m_fipOpts & QFileIconProvider::DontUseCustomDirectoryIcons)
- iconOptions |= QPlatformTheme::DontUseCustomDirectoryIcons;
-
- pixmap = theme->fileIconPixmap(m_fileInfo, size, iconOptions);
- if (!pixmap.isNull()) {
- if (cacheable)
- QPixmapCache::insert(keyBase + QString::number(size.width()), pixmap);
- }
-
- return pixmap;
- }
-
- QList<QSize> availableSizes(QIcon::Mode mode = QIcon::Normal, QIcon::State state = QIcon::Off) const Q_DECL_OVERRIDE
- {
- Q_UNUSED(mode);
- Q_UNUSED(state);
- static QList<QSize> sizes;
- static QPlatformTheme *theme = 0;
- if (!theme) {
- theme = QGuiApplicationPrivate::platformTheme();
- if (!theme)
- return sizes;
-
- QList<int> themeSizes = theme->themeHint(QPlatformTheme::IconPixmapSizes).value<QList<int> >();
- if (themeSizes.isEmpty())
- return sizes;
-
- sizes.reserve(themeSizes.count());
- foreach (int size, themeSizes)
- sizes << QSize(size, size);
- }
- return sizes;
- }
-
- QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) Q_DECL_OVERRIDE
- {
- const QList<QSize> &sizes = availableSizes(mode, state);
- const int numberSizes = sizes.length();
- if (numberSizes == 0)
- return QSize();
-
- // Find the smallest available size whose area is still larger than the input
- // size. Otherwise, use the largest area available size. (We don't assume the
- // platform theme sizes are sorted, hence the extra logic.)
- const int sizeArea = size.width() * size.height();
- QSize actualSize = sizes.first();
- int actualArea = actualSize.width() * actualSize.height();
- for (int i = 1; i < numberSizes; ++i) {
- const QSize &s = sizes.at(i);
- const int a = s.width() * s.height();
- if ((sizeArea <= a && a < actualArea) || (actualArea < sizeArea && actualArea < a)) {
- actualSize = s;
- actualArea = a;
- }
- }
-
- if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height()))
- actualSize.scale(size, Qt::KeepAspectRatio);
-
- return actualSize;
- }
-
-private:
- QFileInfo m_fileInfo;
- QFileIconProvider::Options m_fipOpts;
-};
-
-
/*!
\class QFileIconProvider
@@ -322,34 +222,17 @@ QIcon QFileIconProvider::icon(IconType type) const
return QIcon();
}
-static bool isCacheable(const QFileInfo &fi)
+static inline QPlatformTheme::IconOptions toThemeIconOptions(QFileIconProvider::Options options)
{
- if (!fi.isFile())
- return false;
-
-#ifdef Q_OS_WIN
- // On windows it's faster to just look at the file extensions. QTBUG-13182
- const QString fileExtension = fi.suffix();
- // Will return false for .exe, .lnk and .ico extensions
- return fileExtension.compare(QLatin1String("exe"), Qt::CaseInsensitive) &&
- fileExtension.compare(QLatin1String("lnk"), Qt::CaseInsensitive) &&
- fileExtension.compare(QLatin1String("ico"), Qt::CaseInsensitive);
-#else
- return !fi.isExecutable() && !fi.isSymLink();
-#endif
+ QPlatformTheme::IconOptions result;
+ if (options & QFileIconProvider::DontUseCustomDirectoryIcons)
+ result |= QPlatformTheme::DontUseCustomDirectoryIcons;
+ return result;
}
QIcon QFileIconProviderPrivate::getIcon(const QFileInfo &fi) const
{
- const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme();
- if (!theme)
- return QIcon();
-
- QList<int> sizes = theme->themeHint(QPlatformTheme::IconPixmapSizes).value<QList<int> >();
- if (sizes.isEmpty())
- return QIcon();
-
- return QIcon(new QFileIconEngine(fi, options));
+ return QGuiApplicationPrivate::platformTheme()->fileIcon(fi, toThemeIconOptions(options));
}
/*!
@@ -365,7 +248,7 @@ QIcon QFileIconProvider::icon(const QFileInfo &info) const
return retIcon;
if (info.isRoot())
-#if defined (Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined (Q_OS_WIN) && !defined(Q_OS_WINRT)
{
UINT type = GetDriveType((wchar_t *)info.absoluteFilePath().utf16());
diff --git a/src/widgets/itemviews/qfileiconprovider.h b/src/widgets/itemviews/qfileiconprovider.h
index e4c8c0d23e..732ca1ac8e 100644
--- a/src/widgets/itemviews/qfileiconprovider.h
+++ b/src/widgets/itemviews/qfileiconprovider.h
@@ -40,6 +40,7 @@
#ifndef QFILEICONPROVIDER_H
#define QFILEICONPROVIDER_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qfileinfo.h>
#include <QtCore/qscopedpointer.h>
#include <QtGui/qicon.h>
diff --git a/src/widgets/itemviews/qfileiconprovider_p.h b/src/widgets/itemviews/qfileiconprovider_p.h
index 1cf7f947ad..4726b15816 100644
--- a/src/widgets/itemviews/qfileiconprovider_p.h
+++ b/src/widgets/itemviews/qfileiconprovider_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qfileiconprovider.h"
#include <QtCore/qstring.h>
diff --git a/src/widgets/itemviews/qheaderview.h b/src/widgets/itemviews/qheaderview.h
index c2e3a1f05e..4be97c0c7e 100644
--- a/src/widgets/itemviews/qheaderview.h
+++ b/src/widgets/itemviews/qheaderview.h
@@ -40,6 +40,7 @@
#ifndef QHEADERVIEW_H
#define QHEADERVIEW_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qabstractitemview.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h
index bbef2127a6..0356d79ff7 100644
--- a/src/widgets/itemviews/qheaderview_p.h
+++ b/src/widgets/itemviews/qheaderview_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qabstractitemview_p.h"
#ifndef QT_NO_ITEMVIEWS
diff --git a/src/widgets/itemviews/qitemdelegate.h b/src/widgets/itemviews/qitemdelegate.h
index e02da15f5e..3d98419c80 100644
--- a/src/widgets/itemviews/qitemdelegate.h
+++ b/src/widgets/itemviews/qitemdelegate.h
@@ -40,6 +40,7 @@
#ifndef QITEMDELEGATE_H
#define QITEMDELEGATE_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qabstractitemdelegate.h>
#include <QtCore/qstring.h>
#include <QtGui/qpixmap.h>
diff --git a/src/widgets/itemviews/qitemeditorfactory.h b/src/widgets/itemviews/qitemeditorfactory.h
index b5f8fa2354..785d4d84ea 100644
--- a/src/widgets/itemviews/qitemeditorfactory.h
+++ b/src/widgets/itemviews/qitemeditorfactory.h
@@ -40,6 +40,7 @@
#ifndef QITEMEDITORFACTORY_H
#define QITEMEDITORFACTORY_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qmetaobject.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qhash.h>
diff --git a/src/widgets/itemviews/qitemeditorfactory_p.h b/src/widgets/itemviews/qitemeditorfactory_p.h
index 3b080c3a44..91edcf65ba 100644
--- a/src/widgets/itemviews/qitemeditorfactory_p.h
+++ b/src/widgets/itemviews/qitemeditorfactory_p.h
@@ -52,7 +52,7 @@
//
-
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <qlineedit.h>
#ifndef QT_NO_ITEMVIEWS
diff --git a/src/widgets/itemviews/qlistview.h b/src/widgets/itemviews/qlistview.h
index f44cf90616..e918e66d38 100644
--- a/src/widgets/itemviews/qlistview.h
+++ b/src/widgets/itemviews/qlistview.h
@@ -40,6 +40,7 @@
#ifndef QLISTVIEW_H
#define QLISTVIEW_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qabstractitemview.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/itemviews/qlistview_p.h b/src/widgets/itemviews/qlistview_p.h
index 90fb9e1407..42cb6b4eef 100644
--- a/src/widgets/itemviews/qlistview_p.h
+++ b/src/widgets/itemviews/qlistview_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qabstractitemview_p.h"
#include "qrubberband.h"
#include "qbitarray.h"
diff --git a/src/widgets/itemviews/qlistwidget.h b/src/widgets/itemviews/qlistwidget.h
index 06e2469398..c70e0522b7 100644
--- a/src/widgets/itemviews/qlistwidget.h
+++ b/src/widgets/itemviews/qlistwidget.h
@@ -40,6 +40,7 @@
#ifndef QLISTWIDGET_H
#define QLISTWIDGET_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qlistview.h>
#include <QtCore/qvariant.h>
#include <QtCore/qvector.h>
diff --git a/src/widgets/itemviews/qlistwidget_p.h b/src/widgets/itemviews/qlistwidget_p.h
index bb0c35db5f..eaddfc6e6e 100644
--- a/src/widgets/itemviews/qlistwidget_p.h
+++ b/src/widgets/itemviews/qlistwidget_p.h
@@ -50,6 +50,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtCore/qabstractitemmodel.h>
#include <QtWidgets/qabstractitemview.h>
#include <QtWidgets/qlistwidget.h>
diff --git a/src/widgets/itemviews/qstyleditemdelegate.h b/src/widgets/itemviews/qstyleditemdelegate.h
index bf011cdf10..d30e6e0e9c 100644
--- a/src/widgets/itemviews/qstyleditemdelegate.h
+++ b/src/widgets/itemviews/qstyleditemdelegate.h
@@ -40,6 +40,7 @@
#ifndef QSTYLEDITEMDELEGATE_H
#define QSTYLEDITEMDELEGATE_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qabstractitemdelegate.h>
#include <QtCore/qstring.h>
#include <QtGui/qpixmap.h>
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index eebd0de9bb..c7cc1d155e 100644
--- a/src/widgets/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
@@ -1398,8 +1398,7 @@ void QTableView::paintEvent(QPaintEvent *event)
firstVisualRow, lastVisualRow, firstVisualColumn, lastVisualColumn);
}
- const QVector<QRect> rects = region.rects();
- for (auto dirtyArea : rects) {
+ for (QRect dirtyArea : region) {
dirtyArea.setBottom(qMin(dirtyArea.bottom(), int(y)));
if (rightToLeft) {
dirtyArea.setLeft(qMax(dirtyArea.left(), d->viewport->width() - int(x)));
diff --git a/src/widgets/itemviews/qtableview.h b/src/widgets/itemviews/qtableview.h
index 5ab05b91bf..8c9ac379bc 100644
--- a/src/widgets/itemviews/qtableview.h
+++ b/src/widgets/itemviews/qtableview.h
@@ -40,6 +40,7 @@
#ifndef QTABLEVIEW_H
#define QTABLEVIEW_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qabstractitemview.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/itemviews/qtableview_p.h b/src/widgets/itemviews/qtableview_p.h
index 617ecb1642..2ca158d657 100644
--- a/src/widgets/itemviews/qtableview_p.h
+++ b/src/widgets/itemviews/qtableview_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtCore/QList>
#include <QtCore/QLinkedList>
#include <QtCore/QMap>
diff --git a/src/widgets/itemviews/qtablewidget.h b/src/widgets/itemviews/qtablewidget.h
index 91249e47ee..5dde93f628 100644
--- a/src/widgets/itemviews/qtablewidget.h
+++ b/src/widgets/itemviews/qtablewidget.h
@@ -40,6 +40,7 @@
#ifndef QTABLEWIDGET_H
#define QTABLEWIDGET_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qtableview.h>
#include <QtCore/qvariant.h>
#include <QtCore/qvector.h>
diff --git a/src/widgets/itemviews/qtablewidget_p.h b/src/widgets/itemviews/qtablewidget_p.h
index d3a2f02205..313577befe 100644
--- a/src/widgets/itemviews/qtablewidget_p.h
+++ b/src/widgets/itemviews/qtablewidget_p.h
@@ -50,6 +50,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <qheaderview.h>
#include <qtablewidget.h>
#include <qabstractitemmodel.h>
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index 4ce7da0229..cfe68d6b6a 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -1477,13 +1477,12 @@ void QTreeView::drawTree(QPainter *painter, const QRegion &region) const
QPoint hoverPos = d->viewport->mapFromGlobal(QCursor::pos());
d->hoverBranch = d->itemDecorationAt(hoverPos);
- QVector<QRect> rects = region.rects();
QVector<int> drawn;
- bool multipleRects = (rects.size() > 1);
- for (int a = 0; a < rects.size(); ++a) {
+ bool multipleRects = (region.rectCount() > 1);
+ for (const QRect &a : region) {
const QRect area = (multipleRects
- ? QRect(0, rects.at(a).y(), viewportWidth, rects.at(a).height())
- : rects.at(a));
+ ? QRect(0, a.y(), viewportWidth, a.height())
+ : a);
d->leftAndRight = d->startAndEndColumns(area);
int i = firstVisibleItem; // the first item at the top of the viewport
diff --git a/src/widgets/itemviews/qtreeview.h b/src/widgets/itemviews/qtreeview.h
index d7166a3b33..3c7cbddfbb 100644
--- a/src/widgets/itemviews/qtreeview.h
+++ b/src/widgets/itemviews/qtreeview.h
@@ -40,6 +40,7 @@
#ifndef QTREEVIEW_H
#define QTREEVIEW_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qabstractitemview.h>
class tst_QTreeView;
diff --git a/src/widgets/itemviews/qtreeview_p.h b/src/widgets/itemviews/qtreeview_p.h
index a3619ce13b..56f3340966 100644
--- a/src/widgets/itemviews/qtreeview_p.h
+++ b/src/widgets/itemviews/qtreeview_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qabstractitemview_p.h"
#include <QtCore/qvariantanimation.h>
#include <QtCore/qabstractitemmodel.h>
diff --git a/src/widgets/itemviews/qtreewidget.h b/src/widgets/itemviews/qtreewidget.h
index e360d62c5f..36ba9985bd 100644
--- a/src/widgets/itemviews/qtreewidget.h
+++ b/src/widgets/itemviews/qtreewidget.h
@@ -40,6 +40,7 @@
#ifndef QTREEWIDGET_H
#define QTREEWIDGET_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qtreeview.h>
#include <QtWidgets/qtreewidgetitemiterator.h>
#include <QtCore/qvariant.h>
diff --git a/src/widgets/itemviews/qtreewidget_p.h b/src/widgets/itemviews/qtreewidget_p.h
index 7e7e8e9e35..7789693db4 100644
--- a/src/widgets/itemviews/qtreewidget_p.h
+++ b/src/widgets/itemviews/qtreewidget_p.h
@@ -50,6 +50,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtCore/qabstractitemmodel.h>
#include <private/qabstractitemmodel_p.h>
#include <QtCore/qpair.h>
diff --git a/src/widgets/itemviews/qtreewidgetitemiterator.h b/src/widgets/itemviews/qtreewidgetitemiterator.h
index 2cdf03fd7a..db17a96abd 100644
--- a/src/widgets/itemviews/qtreewidgetitemiterator.h
+++ b/src/widgets/itemviews/qtreewidgetitemiterator.h
@@ -40,7 +40,7 @@
#ifndef QTREEWIDGETITEMITERATOR_H
#define QTREEWIDGETITEMITERATOR_H
-#include <QtCore/qglobal.h>
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qscopedpointer.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/itemviews/qwidgetitemdata_p.h b/src/widgets/itemviews/qwidgetitemdata_p.h
index 6c100553ba..b7ed6ed862 100644
--- a/src/widgets/itemviews/qwidgetitemdata_p.h
+++ b/src/widgets/itemviews/qwidgetitemdata_p.h
@@ -40,6 +40,7 @@
#ifndef QWIDGETITEMDATA_P_H
#define QWIDGETITEMDATA_P_H
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtCore/qdatastream.h>
//
diff --git a/src/widgets/kernel/kernel.pri b/src/widgets/kernel/kernel.pri
index 0060ad2d31..b40a33b2af 100644
--- a/src/widgets/kernel/kernel.pri
+++ b/src/widgets/kernel/kernel.pri
@@ -5,8 +5,10 @@ PRECOMPILED_HEADER = kernel/qt_widgets_pch.h
KERNEL_P= kernel
HEADERS += \
- kernel/qaction.h \
- kernel/qaction_p.h \
+ kernel/qtwidgetsglobal.h \
+ kernel/qtwidgetsglobal_p.h \
+ kernel/qaction.h \
+ kernel/qaction_p.h \
kernel/qactiongroup.h \
kernel/qapplication.h \
kernel/qapplication_p.h \
diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp
index 81cf9ea754..e5bf606901 100644
--- a/src/widgets/kernel/qaction.cpp
+++ b/src/widgets/kernel/qaction.cpp
@@ -279,12 +279,8 @@ void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map)
group the action will be automatically inserted into the group.
*/
QAction::QAction(QObject* parent)
- : QObject(*(new QActionPrivate), parent)
+ : QAction(*new QActionPrivate, parent)
{
- Q_D(QAction);
- d->group = qobject_cast<QActionGroup *>(parent);
- if (d->group)
- d->group->addAction(this);
}
@@ -302,13 +298,10 @@ QAction::QAction(QObject* parent)
*/
QAction::QAction(const QString &text, QObject* parent)
- : QObject(*(new QActionPrivate), parent)
+ : QAction(parent)
{
Q_D(QAction);
d->text = text;
- d->group = qobject_cast<QActionGroup *>(parent);
- if (d->group)
- d->group->addAction(this);
}
/*!
@@ -324,14 +317,10 @@ QAction::QAction(const QString &text, QObject* parent)
setToolTip().
*/
QAction::QAction(const QIcon &icon, const QString &text, QObject* parent)
- : QObject(*(new QActionPrivate), parent)
+ : QAction(text, parent)
{
Q_D(QAction);
d->icon = icon;
- d->text = text;
- d->group = qobject_cast<QActionGroup *>(parent);
- if (d->group)
- d->group->addAction(this);
}
/*!
diff --git a/src/widgets/kernel/qaction.h b/src/widgets/kernel/qaction.h
index bd491c89ca..97948a2457 100644
--- a/src/widgets/kernel/qaction.h
+++ b/src/widgets/kernel/qaction.h
@@ -40,6 +40,7 @@
#ifndef QACTION_H
#define QACTION_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtGui/qkeysequence.h>
#include <QtCore/qstring.h>
#include <QtWidgets/qwidget.h>
diff --git a/src/widgets/kernel/qaction_p.h b/src/widgets/kernel/qaction_p.h
index 84c6774141..8ee71a5ff0 100644
--- a/src/widgets/kernel/qaction_p.h
+++ b/src/widgets/kernel/qaction_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QtWidgets/qaction.h"
#include "QtWidgets/qmenu.h"
#include "private/qgraphicswidget_p.h"
diff --git a/src/widgets/kernel/qactiongroup.h b/src/widgets/kernel/qactiongroup.h
index b9d82aeb8c..61c90b911d 100644
--- a/src/widgets/kernel/qactiongroup.h
+++ b/src/widgets/kernel/qactiongroup.h
@@ -40,6 +40,7 @@
#ifndef QACTIONGROUP_H
#define QACTIONGROUP_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qaction.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 68308153ea..afc1be7458 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -101,23 +101,13 @@
#include "qdatetime.h"
-#ifdef Q_OS_WINCE
-extern bool qt_wince_is_smartphone(); //qguifunctions_wince.cpp
-extern bool qt_wince_is_mobile(); //qguifunctions_wince.cpp
-extern bool qt_wince_is_pocket_pc(); //qguifunctions_wince.cpp
-#endif
-
#include <qpa/qplatformwindow.h>
//#define ALIEN_DEBUG
static void initResources()
{
-#if defined(Q_OS_WINCE)
- Q_INIT_RESOURCE(qstyle_wince);
-#else
Q_INIT_RESOURCE(qstyle);
-#endif
Q_INIT_RESOURCE(qmessagebox);
}
@@ -171,12 +161,7 @@ static QByteArray nativeStyleClassName()
return name;
}
-#ifdef Q_OS_WINCE
-int QApplicationPrivate::autoMaximizeThreshold = -1;
-bool QApplicationPrivate::autoSipEnabled = false;
-#else
bool QApplicationPrivate::autoSipEnabled = true;
-#endif
QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, int flags)
: QApplicationPrivateBase(argc, argv, flags)
@@ -352,8 +337,10 @@ void QApplicationPrivate::createEventDispatcher()
\sa QCoreApplication, QAbstractEventDispatcher, QEventLoop, QSettings
*/
+// ### fixme: Qt 6: Remove ColorSpec and accessors.
/*!
\enum QApplication::ColorSpec
+ \obsolete
\value NormalColor the default color allocation policy
\value CustomColor the same as NormalColor for X11; allocates colors
@@ -410,8 +397,6 @@ QString QApplicationPrivate::styleSheet; // default application styles
#endif
QPointer<QWidget> QApplicationPrivate::leaveAfterRelease = 0;
-int QApplicationPrivate::app_cspec = QApplication::NormalColor;
-
QPalette *QApplicationPrivate::sys_pal = 0; // default system palette
QPalette *QApplicationPrivate::set_pal = 0; // default palette set by programmer
@@ -657,17 +642,6 @@ void QApplicationPrivate::initialize()
if (qEnvironmentVariableIntValue("QT_USE_NATIVE_WINDOWS") > 0)
QCoreApplication::setAttribute(Qt::AA_NativeWindows);
-#ifdef Q_OS_WINCE
-#ifdef QT_AUTO_MAXIMIZE_THRESHOLD
- autoMaximizeThreshold = QT_AUTO_MAXIMIZE_THRESHOLD;
-#else
- if (qt_wince_is_mobile())
- autoMaximizeThreshold = 50;
- else
- autoMaximizeThreshold = -1;
-#endif //QT_AUTO_MAXIMIZE_THRESHOLD
-#endif //Q_OS_WINCE
-
#ifndef QT_NO_WHEELEVENT
QApplicationPrivate::wheel_scroll_lines = 3;
#endif
@@ -894,6 +868,7 @@ QApplication::~QApplication()
#endif
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
// #fixme: Remove.
static HDC displayDC = 0; // display device context
@@ -906,6 +881,7 @@ Q_WIDGETS_EXPORT HDC qt_win_display_dc() // get display D
return displayDC;
}
#endif
+#endif
void qt_cleanup()
{
@@ -913,12 +889,14 @@ void qt_cleanup()
QColormap::cleanup();
QApplicationPrivate::active_window = 0; //### this should not be necessary
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
if (displayDC) {
ReleaseDC(0, displayDC);
displayDC = 0;
}
#endif
+#endif
}
/*!
@@ -1023,30 +1001,6 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis
*/
/*!
- \property QApplication::autoMaximizeThreshold
- \since 4.4
- \brief defines a threshold for auto maximizing widgets
-
- \b{The auto maximize threshold is only available as part of Qt for
- Windows CE.}
-
- This property defines a threshold for the size of a window as a percentage
- of the screen size. If the minimum size hint of a window exceeds the
- threshold, calling show() will cause the window to be maximized
- automatically.
-
- Setting the threshold to 100 or greater means that the widget will always
- be maximized. Alternatively, setting the threshold to 50 means that the
- widget will be maximized only if the vertical minimum size hint is at least
- 50% of the vertical screen size.
-
- Setting the threshold to -1 disables the feature.
-
- On Windows CE the default is -1 (i.e., it is disabled).
- On Windows Mobile the default is 40.
-*/
-
-/*!
\property QApplication::autoSipEnabled
\since 4.5
\brief toggles automatic SIP (software input panel) visibility
@@ -1061,19 +1015,6 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis
The default is platform dependent.
*/
-
-#ifdef Q_OS_WINCE
-void QApplication::setAutoMaximizeThreshold(const int threshold)
-{
- QApplicationPrivate::autoMaximizeThreshold = threshold;
-}
-
-int QApplication::autoMaximizeThreshold() const
-{
- return QApplicationPrivate::autoMaximizeThreshold;
-}
-#endif
-
void QApplication::setAutoSipEnabled(const bool enabled)
{
QApplicationPrivate::autoSipEnabled = enabled;
@@ -1314,17 +1255,21 @@ QStyle* QApplication::setStyle(const QString& style)
/*!
Returns the color specification.
+ \obsolete
\sa QApplication::setColorSpec()
*/
int QApplication::colorSpec()
{
- return QApplicationPrivate::app_cspec;
+ return QApplication::NormalColor;
}
/*!
Sets the color specification for the application to \a spec.
+ \obsolete
+
+ This call has no effect.
The color specification controls how the application allocates colors when
run on a display with a limited amount of colors, e.g. 8 bit / 256 color
@@ -1380,10 +1325,7 @@ int QApplication::colorSpec()
void QApplication::setColorSpec(int spec)
{
- if (Q_UNLIKELY(qApp))
- qWarning("QApplication::setColorSpec: This function must be "
- "called before the QApplication object is created");
- QApplicationPrivate::app_cspec = spec;
+ Q_UNUSED(spec)
}
/*!
@@ -3637,7 +3579,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
// We may get here if the widget is subscribed to a gesture,
// but has not accepted TouchBegin. Propagate touch events
// only if TouchBegin has been accepted.
- if (widget && widget->testAttribute(Qt::WA_WState_AcceptedTouchBeginEvent))
+ if (widget->testAttribute(Qt::WA_WState_AcceptedTouchBeginEvent))
res = d->notify_helper(widget, e);
break;
}
@@ -3777,7 +3719,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
if (receiver->isWidgetType()) {
QWidget *widget = static_cast<QWidget *>(receiver);
-#if !defined(Q_OS_WINCE) || (defined(GWES_ICONCURS) && !defined(QT_NO_CURSOR))
+#if !defined(QT_NO_CURSOR)
// toggle HasMouse widget state on enter and leave
if ((e->type() == QEvent::Enter || e->type() == QEvent::DragEnter) &&
(!QApplication::activePopupWidget() || QApplication::activePopupWidget() == widget->window()))
diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h
index b27fba620e..be5ec2ad05 100644
--- a/src/widgets/kernel/qapplication.h
+++ b/src/widgets/kernel/qapplication.h
@@ -40,6 +40,7 @@
#ifndef QAPPLICATION_H
#define QAPPLICATION_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qcoreapplication.h>
#include <QtGui/qwindowdefs.h>
#include <QtCore/qpoint.h>
@@ -84,9 +85,6 @@ class Q_WIDGETS_EXPORT QApplication : public QGuiApplication
#ifndef QT_NO_STYLE_STYLESHEET
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
#endif
-#ifdef Q_OS_WINCE
- Q_PROPERTY(int autoMaximizeThreshold READ autoMaximizeThreshold WRITE setAutoMaximizeThreshold)
-#endif
Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled)
public:
@@ -101,8 +99,10 @@ public:
static void setStyle(QStyle*);
static QStyle *setStyle(const QString&);
enum ColorSpec { NormalColor=0, CustomColor=1, ManyColor=2 };
- static int colorSpec();
- static void setColorSpec(int);
+#if QT_DEPRECATED_SINCE(5, 8)
+ QT_DEPRECATED static int colorSpec();
+ QT_DEPRECATED static void setColorSpec(int);
+#endif // QT_DEPRECATED_SINCE(5, 8)
#if QT_DEPRECATED_SINCE(5, 0)
QT_DEPRECATED static inline void setGraphicsSystem(const QString &) {}
#endif
@@ -195,10 +195,6 @@ public Q_SLOTS:
#ifndef QT_NO_STYLE_STYLESHEET
void setStyleSheet(const QString& sheet);
#endif
-#ifdef Q_OS_WINCE
- void setAutoMaximizeThreshold(const int threshold);
- int autoMaximizeThreshold() const;
-#endif
void setAutoSipEnabled(const bool enabled);
bool autoSipEnabled() const;
static void closeAllWindows();
diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h
index 3358cce744..dd0edc7c80 100644
--- a/src/widgets/kernel/qapplication_p.h
+++ b/src/widgets/kernel/qapplication_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QtWidgets/qapplication.h"
#include "QtGui/qevent.h"
#include "QtGui/qfont.h"
@@ -90,11 +91,8 @@ extern Q_GUI_EXPORT bool qt_is_gui_used;
extern QClipboard *qt_clipboard;
#endif
-#if defined (Q_OS_WIN32) || defined (Q_OS_CYGWIN) || defined(Q_OS_WINCE)
+#if defined (Q_OS_WIN32) || defined (Q_OS_CYGWIN)
extern QSysInfo::WinVersion qt_winver;
-# ifdef Q_OS_WINCE
- extern DWORD qt_cever;
-# endif
#elif defined (Q_OS_MAC)
extern QSysInfo::MacVersion qt_macver;
#endif
@@ -126,9 +124,6 @@ public:
#endif
static void reset_instance_pointer();
#endif
-#ifdef Q_OS_WINCE
- static int autoMaximizeThreshold;
-#endif
static bool autoSipEnabled;
static QString desktopStyleKey();
@@ -189,7 +184,6 @@ public:
static QWidgetList *popupWidgets;
static QStyle *app_style;
static bool overrides_native_style;
- static int app_cspec;
static QPalette *sys_pal;
static QPalette *set_pal;
diff --git a/src/widgets/kernel/qboxlayout.h b/src/widgets/kernel/qboxlayout.h
index 6c548fbbca..9c7d0e593f 100644
--- a/src/widgets/kernel/qboxlayout.h
+++ b/src/widgets/kernel/qboxlayout.h
@@ -40,6 +40,7 @@
#ifndef QBOXLAYOUT_H
#define QBOXLAYOUT_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qlayout.h>
#ifdef QT_INCLUDE_COMPAT
#include <QtWidgets/qwidget.h>
diff --git a/src/widgets/kernel/qdesktopwidget.h b/src/widgets/kernel/qdesktopwidget.h
index 9fb6b293f7..64e1c568eb 100644
--- a/src/widgets/kernel/qdesktopwidget.h
+++ b/src/widgets/kernel/qdesktopwidget.h
@@ -40,6 +40,7 @@
#ifndef QDESKTOPWIDGET_H
#define QDESKTOPWIDGET_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/kernel/qdesktopwidget_p.h b/src/widgets/kernel/qdesktopwidget_p.h
index a590024b7c..4846a868aa 100644
--- a/src/widgets/kernel/qdesktopwidget_p.h
+++ b/src/widgets/kernel/qdesktopwidget_p.h
@@ -51,6 +51,7 @@
#ifndef QDESKTOPWIDGET_P_H
#define QDESKTOPWIDGET_P_H
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QDesktopWidget"
#include "private/qwidget_p.h"
diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp
index 4500b5b25d..73e82c577c 100644
--- a/src/widgets/kernel/qformlayout.cpp
+++ b/src/widgets/kernel/qformlayout.cpp
@@ -66,6 +66,7 @@ public:
int rowCount() const { return m_storage.size() / NumColumns; }
void insertRow(int r, const T &value);
+ void removeRow(int r);
// Hmmpf.. Some things are faster that way.
const Storage &storage() const { return m_storage; }
@@ -85,6 +86,12 @@ void FixedColumnMatrix<T, NumColumns>::insertRow(int r, const T &value)
}
template <class T, int NumColumns>
+void FixedColumnMatrix<T, NumColumns>::removeRow(int r)
+{
+ m_storage.remove(r * NumColumns, NumColumns);
+}
+
+template <class T, int NumColumns>
void FixedColumnMatrix<T, NumColumns>::storageIndexToPosition(int idx, int *rowPtr, int *colPtr)
{
*rowPtr = idx / NumColumns;
@@ -157,6 +164,7 @@ public:
int insertRow(int row);
void insertRows(int row, int count);
+ void removeRow(int row);
void setItem(int row, QFormLayout::ItemRole role, QLayoutItem *item);
void setLayout(int row, QFormLayout::ItemRole role, QLayout *layout);
void setWidget(int row, QFormLayout::ItemRole role, QWidget *widget);
@@ -919,6 +927,12 @@ void QFormLayoutPrivate::insertRows(int row, int count)
}
}
+void QFormLayoutPrivate::removeRow(int row)
+{
+ if (uint(row) < uint(m_matrix.rowCount()))
+ m_matrix.removeRow(row);
+}
+
void QFormLayoutPrivate::setItem(int row, QFormLayout::ItemRole role, QLayoutItem *item)
{
const bool fullRow = role == QFormLayout::SpanningRole;
@@ -1150,6 +1164,28 @@ QLayoutItem* QFormLayoutPrivate::replaceAt(int index, QLayoutItem *newitem)
*/
/*!
+ \since 5.8
+
+ \struct QFormLayout::TakeRowResult
+
+ \brief Contains the result of a QFormLayout::takeRow() call.
+
+ \sa QFormLayout::takeRow()
+*/
+
+/*!
+ \variable QFormLayout::TakeRowResult::labelItem
+
+ Contains the layout item corresponding to the label of the row.
+*/
+
+/*!
+ \variable QFormLayout::TakeRowResult::fieldItem
+
+ Contains the layout item corresponding to the field of the row.
+*/
+
+/*!
Constructs a new form layout with the given \a parent widget.
\sa QWidget::setLayout()
@@ -1352,6 +1388,287 @@ void QFormLayout::insertRow(int row, QLayout *layout)
invalidate();
}
+static QLayoutItem *ownershipCleanedItem(QFormLayoutItem *item, QFormLayout *layout)
+{
+ if (!item)
+ return nullptr;
+
+ // grab ownership back from the QFormLayoutItem
+ QLayoutItem *i = item->item;
+ item->item = nullptr;
+ delete item;
+
+ if (QLayout *l = i->layout()) {
+ // sanity check in case the user passed something weird to QObject::setParent()
+ if (l->parent() == layout)
+ l->setParent(nullptr);
+ }
+
+ return i;
+}
+
+static void clearQLayoutItem(QLayoutItem *item)
+{
+ if (Q_LIKELY(item)) {
+ if (QLayout *layout = item->layout()) {
+ while (QLayoutItem *child = layout->takeAt(0)) {
+ clearQLayoutItem(child);
+ delete child;
+ }
+ delete layout;
+ }
+ delete item->widget();
+ delete item->spacerItem();
+ }
+}
+
+/*!
+ \since 5.8
+
+ Deletes row \a row from this form layout.
+
+ \a row must be non-negative and less than rowCount().
+
+ After this call, rowCount() is decremented by one. All widgets and
+ nested layouts that occupied this row are deleted. That includes both
+ the field widget(s) and the label, if any. All following rows are shifted
+ up one row and the freed vertical space is redistributed amongst the remaining rows.
+
+ You can use this function to undo a previous addRow() or insertRow():
+ \code
+ QFormLayout *flay = ...;
+ QPointer<QLineEdit> le = new QLineEdit;
+ flay->insertRow(2, "User:", le);
+ // later:
+ flay->removeRow(2); // le == nullptr at this point
+ \endcode
+
+ If you want to remove the row from the layout without deleting the widgets, use takeRow() instead.
+
+ \sa takeRow()
+*/
+void QFormLayout::removeRow(int row)
+{
+ TakeRowResult result = takeRow(row);
+ clearQLayoutItem(result.labelItem);
+ clearQLayoutItem(result.fieldItem);
+}
+
+/*!
+ \since 5.8
+
+ \overload
+
+ Deletes the row corresponding to \a widget from this form layout.
+
+ After this call, rowCount() is decremented by one. All widgets and
+ nested layouts that occupied this row are deleted. That includes both
+ the field widget(s) and the label, if any. All following rows are shifted
+ up one row and the freed vertical space is redistributed amongst the remaining rows.
+
+ You can use this function to undo a previous addRow() or insertRow():
+ \code
+ QFormLayout *flay = ...;
+ QPointer<QLineEdit> le = new QLineEdit;
+ flay->insertRow(2, "User:", le);
+ // later:
+ flay->removeRow(le); // le == nullptr at this point
+ \endcode
+
+ If you want to remove the row from the layout without deleting the widgets, use takeRow() instead.
+
+ \sa takeRow()
+*/
+void QFormLayout::removeRow(QWidget *widget)
+{
+ TakeRowResult result = takeRow(widget);
+ clearQLayoutItem(result.labelItem);
+ clearQLayoutItem(result.fieldItem);
+}
+
+/*!
+ \since 5.8
+
+ \overload
+
+ Deletes the row corresponding to \a layout from this form layout.
+
+ After this call, rowCount() is decremented by one. All widgets and
+ nested layouts that occupied this row are deleted. That includes both
+ the field widget(s) and the label, if any. All following rows are shifted
+ up one row and the freed vertical space is redistributed amongst the remaining rows.
+
+ You can use this function to undo a previous addRow() or insertRow():
+ \code
+ QFormLayout *flay = ...;
+ QPointer<QVBoxLayout> vbl = new QVBoxLayout;
+ flay->insertRow(2, "User:", vbl);
+ // later:
+ flay->removeRow(layout); // vbl == nullptr at this point
+ \endcode
+
+ If you want to remove the row from the form layout without deleting the inserted layout,
+ use takeRow() instead.
+
+ \sa takeRow()
+*/
+void QFormLayout::removeRow(QLayout *layout)
+{
+ TakeRowResult result = takeRow(layout);
+ clearQLayoutItem(result.labelItem);
+ clearQLayoutItem(result.fieldItem);
+}
+
+/*!
+ \since 5.8
+
+ Removes the specified \a row from this form layout.
+
+ \a row must be non-negative and less than rowCount().
+
+ \note This function doesn't delete anything.
+
+ After this call, rowCount() is decremented by one. All following rows are shifted
+ up one row and the freed vertical space is redistributed amongst the remaining rows.
+
+ You can use this function to undo a previous addRow() or insertRow():
+ \code
+ QFormLayout *flay = ...;
+ QPointer<QLineEdit> le = new QLineEdit;
+ flay->insertRow(2, "User:", le);
+ // later:
+ QFormLayout::TakeRowResult result = flay->takeRow(2);
+ \endcode
+
+ If you want to remove the row from the layout and delete the widgets, use removeRow() instead.
+
+ \return A structure containing both the widget and
+ corresponding label layout items
+
+ \sa removeRow()
+*/
+QFormLayout::TakeRowResult QFormLayout::takeRow(int row)
+{
+ Q_D(QFormLayout);
+
+ const int storageIndex = storageIndexFromLayoutItem(d->m_matrix, d->m_things.value(row));
+ if (Q_UNLIKELY(storageIndex == -1)) {
+ qWarning("QFormLayout::takeRow: Invalid row %d", row);
+ return TakeRowResult();
+ }
+
+ int storageRow, dummy;
+ QFormLayoutPrivate::ItemMatrix::storageIndexToPosition(storageIndex, &storageRow, &dummy);
+ Q_ASSERT(d->m_matrix(storageRow, dummy));
+
+ QFormLayoutItem *label = d->m_matrix(storageRow, 0);
+ QFormLayoutItem *field = d->m_matrix(storageRow, 1);
+
+ Q_ASSERT(field);
+
+ d->m_things.removeOne(label);
+ d->m_things.removeOne(field);
+ d->m_matrix.removeRow(storageRow);
+
+ invalidate();
+
+ TakeRowResult result;
+ result.labelItem = ownershipCleanedItem(label, this);
+ result.fieldItem = ownershipCleanedItem(field, this);
+ return result;
+}
+
+/*!
+ \since 5.8
+
+ \overload
+
+ Removes the specified \a widget from this form layout.
+
+ \note This function doesn't delete anything.
+
+ After this call, rowCount() is decremented by one. All following rows are shifted
+ up one row and the freed vertical space is redistributed amongst the remaining rows.
+
+ \code
+ QFormLayout *flay = ...;
+ QPointer<QLineEdit> le = new QLineEdit;
+ flay->insertRow(2, "User:", le);
+ // later:
+ QFormLayout::TakeRowResult result = flay->takeRow(widget);
+ \endcode
+
+ If you want to remove the row from the layout and delete the widgets, use removeRow() instead.
+
+ \return A structure containing both the widget and
+ corresponding label layout items
+
+ \sa removeRow()
+*/
+QFormLayout::TakeRowResult QFormLayout::takeRow(QWidget *widget)
+{
+ Q_D(QFormLayout);
+ if (Q_UNLIKELY(!d->checkWidget(widget)))
+ return TakeRowResult();
+
+ int row;
+ ItemRole role;
+ getWidgetPosition(widget, &row, &role);
+
+ if (Q_UNLIKELY(row < 0)) {
+ qWarning("QFormLayout::takeRow: Invalid widget");
+ return TakeRowResult();
+ }
+
+ return takeRow(row);
+}
+
+/*!
+ \since 5.8
+
+ \overload
+
+ Removes the specified \a layout from this form layout.
+
+ \note This function doesn't delete anything.
+
+ After this call, rowCount() is decremented by one. All following rows are shifted
+ up one row and the freed vertical space is redistributed amongst the remaining rows.
+
+ \code
+ QFormLayout *flay = ...;
+ QPointer<QVBoxLayout> vbl = new QVBoxLayout;
+ flay->insertRow(2, "User:", vbl);
+ // later:
+ QFormLayout::TakeRowResult result = flay->takeRow(widget);
+ \endcode
+
+ If you want to remove the row from the form layout and delete the inserted layout,
+ use removeRow() instead.
+
+ \return A structure containing both the widget and
+ corresponding label layout items
+
+ \sa removeRow()
+*/
+QFormLayout::TakeRowResult QFormLayout::takeRow(QLayout *layout)
+{
+ Q_D(QFormLayout);
+ if (Q_UNLIKELY(!d->checkLayout(layout)))
+ return TakeRowResult();
+
+ int row;
+ ItemRole role;
+ getLayoutPosition(layout, &row, &role);
+
+ if (Q_UNLIKELY(row < 0)) {
+ qWarning("QFormLayout::takeRow: Invalid layout");
+ return TakeRowResult();
+ }
+
+ return takeRow(row);
+}
+
/*!
\reimp
*/
@@ -1408,18 +1725,7 @@ QLayoutItem *QFormLayout::takeAt(int index)
invalidate();
- // grab ownership back from the QFormLayoutItem
- QLayoutItem *i = item->item;
- item->item = 0;
- delete item;
-
- if (QLayout *l = i->layout()) {
- // sanity check in case the user passed something weird to QObject::setParent()
- if (l->parent() == this)
- l->setParent(0);
- }
-
- return i;
+ return ownershipCleanedItem(item, this);
}
/*!
diff --git a/src/widgets/kernel/qformlayout.h b/src/widgets/kernel/qformlayout.h
index 8e4f7b7309..b4185374fd 100644
--- a/src/widgets/kernel/qformlayout.h
+++ b/src/widgets/kernel/qformlayout.h
@@ -40,6 +40,7 @@
#ifndef QFORMLAYOUT_H
#define QFORMLAYOUT_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/QLayout>
QT_BEGIN_NAMESPACE
@@ -80,6 +81,11 @@ public:
};
Q_ENUM(ItemRole)
+ struct TakeRowResult {
+ QLayoutItem *labelItem;
+ QLayoutItem *fieldItem;
+ };
+
explicit QFormLayout(QWidget *parent = Q_NULLPTR);
~QFormLayout();
@@ -114,6 +120,14 @@ public:
void insertRow(int row, QWidget *widget);
void insertRow(int row, QLayout *layout);
+ void removeRow(int row);
+ void removeRow(QWidget *widget);
+ void removeRow(QLayout *layout);
+
+ TakeRowResult takeRow(int row);
+ TakeRowResult takeRow(QWidget *widget);
+ TakeRowResult takeRow(QLayout *layout);
+
void setItem(int row, ItemRole role, QLayoutItem *item);
void setWidget(int row, ItemRole role, QWidget *widget);
void setLayout(int row, ItemRole role, QLayout *layout);
@@ -153,6 +167,8 @@ private:
void resetFormAlignment();
};
+Q_DECLARE_TYPEINFO(QFormLayout::TakeRowResult, Q_PRIMITIVE_TYPE);
+
QT_END_NAMESPACE
#endif
diff --git a/src/widgets/kernel/qgesture.h b/src/widgets/kernel/qgesture.h
index 57b59abf60..034d1d88c1 100644
--- a/src/widgets/kernel/qgesture.h
+++ b/src/widgets/kernel/qgesture.h
@@ -40,6 +40,7 @@
#ifndef QGESTURE_H
#define QGESTURE_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qlist.h>
#include <QtCore/qdatetime.h>
diff --git a/src/widgets/kernel/qgesture_p.h b/src/widgets/kernel/qgesture_p.h
index b438b81e31..636103c1e1 100644
--- a/src/widgets/kernel/qgesture_p.h
+++ b/src/widgets/kernel/qgesture_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qrect.h"
#include "qpoint.h"
#include "qgesture.h"
diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp
index df72c6c4d2..c901285d1a 100644
--- a/src/widgets/kernel/qgesturemanager.cpp
+++ b/src/widgets/kernel/qgesturemanager.cpp
@@ -75,7 +75,7 @@ static inline int panTouchPoints()
const int result = qEnvironmentVariableIntValue(panTouchPointVariable, &ok);
if (ok && result >= 1)
return result;
- qWarning() << "Ignoring invalid value of " << panTouchPointVariable;
+ qWarning("Ignoring invalid value of %s", panTouchPointVariable);
}
// Pan should use 1 finger on a touch screen and 2 fingers on touch pads etc.
// where 1 finger movements are used for mouse event synthetization. For now,
diff --git a/src/widgets/kernel/qgesturemanager_p.h b/src/widgets/kernel/qgesturemanager_p.h
index 9cd1f79418..ec51466a63 100644
--- a/src/widgets/kernel/qgesturemanager_p.h
+++ b/src/widgets/kernel/qgesturemanager_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qobject.h"
#include "qbasictimer.h"
#include "private/qwidget_p.h"
diff --git a/src/widgets/kernel/qgesturerecognizer.h b/src/widgets/kernel/qgesturerecognizer.h
index f44f763217..04e85c46cc 100644
--- a/src/widgets/kernel/qgesturerecognizer.h
+++ b/src/widgets/kernel/qgesturerecognizer.h
@@ -40,7 +40,7 @@
#ifndef QGESTURERECOGNIZER_H
#define QGESTURERECOGNIZER_H
-#include <QtCore/qglobal.h>
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qnamespace.h>
#ifndef QT_NO_GESTURES
diff --git a/src/widgets/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp
index b58e7fdc9e..29df38f19c 100644
--- a/src/widgets/kernel/qgridlayout.cpp
+++ b/src/widgets/kernel/qgridlayout.cpp
@@ -746,9 +746,13 @@ void QGridLayoutPrivate::setupSpacings(QVector<QLayoutStruct> &chain,
if (orientation == Qt::Vertical) {
QGridBox *sibling = vReversed ? previousBox : box;
if (sibling) {
- QWidget *wid = sibling->item()->widget();
- if (wid)
- spacing = qMax(spacing, sibling->item()->geometry().top() - wid->geometry().top() );
+ if (sibling->item()->isEmpty()) {
+ spacing = 0;
+ } else {
+ QWidget *wid = sibling->item()->widget();
+ if (wid)
+ spacing = qMax(spacing, sibling->item()->geometry().top() - wid->geometry().top());
+ }
}
}
}
diff --git a/src/widgets/kernel/qgridlayout.h b/src/widgets/kernel/qgridlayout.h
index fc6e70748f..51dd65d181 100644
--- a/src/widgets/kernel/qgridlayout.h
+++ b/src/widgets/kernel/qgridlayout.h
@@ -40,6 +40,7 @@
#ifndef QGRIDLAYOUT_H
#define QGRIDLAYOUT_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qlayout.h>
#ifdef QT_INCLUDE_COMPAT
#include <QtWidgets/qwidget.h>
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index 240f525722..0a21ece1dd 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -810,7 +810,7 @@ static bool layoutDebug()
{
static int checked_env = -1;
if(checked_env == -1)
- checked_env = !!qgetenv("QT_LAYOUT_DEBUG").toInt();
+ checked_env = !!qEnvironmentVariableIntValue("QT_LAYOUT_DEBUG");
return checked_env;
}
@@ -945,12 +945,7 @@ void QLayout::addChildWidget(QWidget *w)
void QLayout::setMenuBar(QWidget *widget)
{
Q_D(QLayout);
-
-#ifdef Q_OS_WINCE_WM
- if (widget && widget->size().height() > 0)
-#else
if (widget)
-#endif
addChildWidget(widget);
d->menubar = widget;
}
diff --git a/src/widgets/kernel/qlayout.h b/src/widgets/kernel/qlayout.h
index d76e12ca8c..2de12b4f99 100644
--- a/src/widgets/kernel/qlayout.h
+++ b/src/widgets/kernel/qlayout.h
@@ -40,6 +40,7 @@
#ifndef QLAYOUT_H
#define QLAYOUT_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qobject.h>
#include <QtWidgets/qlayoutitem.h>
#include <QtWidgets/qsizepolicy.h>
diff --git a/src/widgets/kernel/qlayout_p.h b/src/widgets/kernel/qlayout_p.h
index 0d70c74fe5..8a1b12a6be 100644
--- a/src/widgets/kernel/qlayout_p.h
+++ b/src/widgets/kernel/qlayout_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qobject_p.h"
#include "qstyle.h"
#include "qsizepolicy.h"
diff --git a/src/widgets/kernel/qlayoutengine_p.h b/src/widgets/kernel/qlayoutengine_p.h
index 0f7d3fdb90..812fa7cf3b 100644
--- a/src/widgets/kernel/qlayoutengine_p.h
+++ b/src/widgets/kernel/qlayoutengine_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QtWidgets/qlayoutitem.h"
#include "QtWidgets/qstyle.h"
diff --git a/src/widgets/kernel/qlayoutitem.h b/src/widgets/kernel/qlayoutitem.h
index b54a59084b..6f701b9f82 100644
--- a/src/widgets/kernel/qlayoutitem.h
+++ b/src/widgets/kernel/qlayoutitem.h
@@ -40,6 +40,7 @@
#ifndef QLAYOUTITEM_H
#define QLAYOUTITEM_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qsizepolicy.h>
#include <QtCore/qrect.h>
diff --git a/src/widgets/kernel/qmacgesturerecognizer_p.h b/src/widgets/kernel/qmacgesturerecognizer_p.h
index 844d4a6460..be3f3266ac 100644
--- a/src/widgets/kernel/qmacgesturerecognizer_p.h
+++ b/src/widgets/kernel/qmacgesturerecognizer_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qtimer.h"
#include "qpoint.h"
#include "qgesturerecognizer.h"
diff --git a/src/widgets/kernel/qopenglwidget.h b/src/widgets/kernel/qopenglwidget.h
index acbbb24c40..b60d79bedb 100644
--- a/src/widgets/kernel/qopenglwidget.h
+++ b/src/widgets/kernel/qopenglwidget.h
@@ -40,7 +40,7 @@
#ifndef QOPENGLWIDGET_H
#define QOPENGLWIDGET_H
-#include <QtCore/qglobal.h>
+#include <QtWidgets/qtwidgetsglobal.h>
#ifndef QT_NO_OPENGL
diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp
index bf162249d0..7bd9e74924 100644
--- a/src/widgets/kernel/qshortcut.cpp
+++ b/src/widgets/kernel/qshortcut.cpp
@@ -456,12 +456,11 @@ QShortcut::QShortcut(QWidget *parent)
QShortcut::QShortcut(const QKeySequence &key, QWidget *parent,
const char *member, const char *ambiguousMember,
Qt::ShortcutContext context)
- : QObject(*new QShortcutPrivate, parent)
+ : QShortcut(parent)
{
QAPP_CHECK("QShortcut");
Q_D(QShortcut);
- Q_ASSERT(parent != 0);
d->sc_context = context;
d->sc_sequence = key;
d->redoGrab(qApp->d_func()->shortcutMap);
diff --git a/src/widgets/kernel/qshortcut.h b/src/widgets/kernel/qshortcut.h
index c3ccbe3c08..22c667c9c1 100644
--- a/src/widgets/kernel/qshortcut.h
+++ b/src/widgets/kernel/qshortcut.h
@@ -40,6 +40,7 @@
#ifndef QSHORTCUT_H
#define QSHORTCUT_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
#include <QtGui/qkeysequence.h>
diff --git a/src/widgets/kernel/qsizepolicy.h b/src/widgets/kernel/qsizepolicy.h
index 7a1e22fdc2..63b578fbf3 100644
--- a/src/widgets/kernel/qsizepolicy.h
+++ b/src/widgets/kernel/qsizepolicy.h
@@ -40,6 +40,7 @@
#ifndef QSIZEPOLICY_H
#define QSIZEPOLICY_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qobject.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/kernel/qstackedlayout.h b/src/widgets/kernel/qstackedlayout.h
index fb83fddc43..6f5eded1f0 100644
--- a/src/widgets/kernel/qstackedlayout.h
+++ b/src/widgets/kernel/qstackedlayout.h
@@ -40,6 +40,7 @@
#ifndef QSTACKEDLAYOUT_H
#define QSTACKEDLAYOUT_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qlayout.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/kernel/qstandardgestures_p.h b/src/widgets/kernel/qstandardgestures_p.h
index abda1a3f6e..9b2cffaa9a 100644
--- a/src/widgets/kernel/qstandardgestures_p.h
+++ b/src/widgets/kernel/qstandardgestures_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qgesturerecognizer.h"
#include "private/qgesture_p.h"
diff --git a/src/widgets/kernel/qt_widgets_pch.h b/src/widgets/kernel/qt_widgets_pch.h
index f58a8895eb..f30202d89e 100644
--- a/src/widgets/kernel/qt_widgets_pch.h
+++ b/src/widgets/kernel/qt_widgets_pch.h
@@ -47,7 +47,7 @@
// from corelib/global/qt_pch.h
#if defined __cplusplus
-#include <qglobal.h>
+#include <qtwidgetsglobal.h>
#ifdef Q_DEAD_CODE_FROM_QT4_WIN
diff --git a/src/widgets/kernel/qtooltip.h b/src/widgets/kernel/qtooltip.h
index aad6e941c8..5e68eef0a7 100644
--- a/src/widgets/kernel/qtooltip.h
+++ b/src/widgets/kernel/qtooltip.h
@@ -40,6 +40,7 @@
#ifndef QTOOLTIP_H
#define QTOOLTIP_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/kernel/qwidgetsfunctions_wince.h b/src/widgets/kernel/qtwidgetsglobal.h
index f2c620a966..f6d003e629 100644
--- a/src/widgets/kernel/qwidgetsfunctions_wince.h
+++ b/src/widgets/kernel/qtwidgetsglobal.h
@@ -36,25 +36,24 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#ifndef QWIDGETSFUNCTIONS_WCE_H
-#define QWIDGETSFUNCTIONS_WCE_H
-#include <QtCore/qglobal.h>
+#ifndef QTWIDGETSGLOBAL_H
+#define QTWIDGETSGLOBAL_H
-#ifdef Q_OS_WINCE
-#include <QtCore/qfunctions_wince.h>
+#include <QtGui/qtguiglobal.h>
-#ifdef QT_BUILD_GUI_LIB
QT_BEGIN_NAMESPACE
-QT_END_NAMESPACE
-#endif
-
-//WinCe 7 has shell support
-#ifndef ShellExecute
-HINSTANCE qt_wince_ShellExecute(HWND hwnd, LPCWSTR operation, LPCWSTR file, LPCWSTR params, LPCWSTR dir, int showCmd);
-#define ShellExecute(a,b,c,d,e,f) qt_wince_ShellExecute(a,b,c,d,e,f)
+#ifndef QT_STATIC
+# if defined(QT_BUILD_WIDGETS_LIB)
+# define Q_WIDGETS_EXPORT Q_DECL_EXPORT
+# else
+# define Q_WIDGETS_EXPORT Q_DECL_IMPORT
+# endif
+#else
+# define Q_WIDGETS_EXPORT
#endif
-#endif // Q_OS_WINCE
-#endif // QWIDGETSFUNCTIONS_WCE_H
+QT_END_NAMESPACE
+
+#endif // QTGUIGLOBAL_H
diff --git a/src/widgets/kernel/qtwidgetsglobal_p.h b/src/widgets/kernel/qtwidgetsglobal_p.h
new file mode 100644
index 0000000000..7dd545415c
--- /dev/null
+++ b/src/widgets/kernel/qtwidgetsglobal_p.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtWidgets module 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 The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTWIDGETSGLOBAL_P_H
+#define QTWIDGETSGLOBAL_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtWidgets/qtwidgetsglobal.h>
+#include <QtGui/private/qtguiglobal_p.h>
+
+#endif // QTWIDGETSGLOBAL_P_H
diff --git a/src/widgets/kernel/qwhatsthis.h b/src/widgets/kernel/qwhatsthis.h
index 0889653e2c..746fd3ff22 100644
--- a/src/widgets/kernel/qwhatsthis.h
+++ b/src/widgets/kernel/qwhatsthis.h
@@ -40,6 +40,7 @@
#ifndef QWHATSTHIS_H
#define QWHATSTHIS_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qobject.h>
#include <QtGui/qcursor.h>
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index c2c9e1f618..693f254de1 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -1109,11 +1109,7 @@ void QWidgetPrivate::adjustFlags(Qt::WindowFlags &flags, QWidget *w)
if (customize)
; // don't modify window flags if the user explicitly set them.
else if (type == Qt::Dialog || type == Qt::Sheet)
-#ifndef Q_OS_WINCE
flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint | Qt::WindowCloseButtonHint;
-#else
- flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint;
-#endif
else if (type == Qt::Tool)
flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint;
else
@@ -2406,9 +2402,8 @@ static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QBrus
painter->fillRect(0, 0, painter->device()->width(), painter->device()->height(), brush);
painter->restore();
} else {
- const QVector<QRect> &rects = rgn.rects();
- for (int i = 0; i < rects.size(); ++i)
- painter->fillRect(rects.at(i), brush);
+ for (const QRect &rect : rgn)
+ painter->fillRect(rect, brush);
}
}
@@ -4554,7 +4549,7 @@ const QPalette &QWidget::palette() const
if (!isEnabled()) {
data->pal.setCurrentColorGroup(QPalette::Disabled);
} else if ((!isVisible() || isActiveWindow())
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
&& !QApplicationPrivate::isBlockedByModal(const_cast<QWidget *>(this))
#endif
) {
@@ -8557,13 +8552,9 @@ QSize QWidgetPrivate::adjustedSize() const
#else // all others
QRect screen = QApplication::desktop()->screenGeometry(q->pos());
#endif
-#if defined (Q_OS_WINCE)
- s.setWidth(qMin(s.width(), screen.width()));
- s.setHeight(qMin(s.height(), screen.height()));
-#else
s.setWidth(qMin(s.width(), screen.width()*2/3));
s.setHeight(qMin(s.height(), screen.height()*2/3));
-#endif
+
if (QTLWExtra *extra = maybeTopData())
extra->sizeAdjusted = true;
}
@@ -9535,7 +9526,7 @@ void QWidget::focusOutEvent(QFocusEvent *)
if (focusPolicy() != Qt::NoFocus || !isWindow())
update();
-#ifndef Q_OS_IOS
+#if !defined(QT_PLATFORM_UIKIT)
// FIXME: revisit autoSIP logic, QTBUG-42906
if (qApp->autoSipEnabled() && testAttribute(Qt::WA_InputMethodEnabled))
QGuiApplication::inputMethod()->hide();
@@ -10751,10 +10742,8 @@ void QWidget::scroll(int dx, int dy)
// Graphics View maintains its own dirty region as a list of rects;
// until we can connect item updates directly to the view, we must
// separately add a translated dirty region.
- if (!d->dirty.isEmpty()) {
- foreach (const QRect &rect, (d->dirty.translated(dx, dy)).rects())
- proxy->update(rect);
- }
+ for (const QRect &rect : d->dirty)
+ proxy->update(rect.translated(dx, dy));
proxy->scroll(dx, dy, proxy->subWidgetRect(this));
return;
}
@@ -10794,7 +10783,7 @@ void QWidget::scroll(int dx, int dy, const QRect &r)
// until we can connect item updates directly to the view, we must
// separately add a translated dirty region.
if (!d->dirty.isEmpty()) {
- foreach (const QRect &rect, (d->dirty.translated(dx, dy) & r).rects())
+ for (const QRect &rect : d->dirty.translated(dx, dy) & r)
proxy->update(rect);
}
proxy->scroll(dx, dy, r.translated(proxy->subWidgetRect(this).topLeft().toPoint()));
diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h
index a810e0b089..bca89fe2c5 100644
--- a/src/widgets/kernel/qwidget.h
+++ b/src/widgets/kernel/qwidget.h
@@ -40,6 +40,7 @@
#ifndef QWIDGET_H
#define QWIDGET_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtGui/qwindowdefs.h>
#include <QtCore/qobject.h>
#include <QtCore/qmargins.h>
diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h
index 71691a4afa..f2884e7b17 100644
--- a/src/widgets/kernel/qwidget_p.h
+++ b/src/widgets/kernel/qwidget_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QtWidgets/qwidget.h"
#include "private/qobject_p.h"
#include "QtCore/qrect.h"
diff --git a/src/widgets/kernel/qwidgetaction.h b/src/widgets/kernel/qwidgetaction.h
index 4adb9b61ea..3da691a430 100644
--- a/src/widgets/kernel/qwidgetaction.h
+++ b/src/widgets/kernel/qwidgetaction.h
@@ -40,6 +40,7 @@
#ifndef QWIDGETACTION_H
#define QWIDGETACTION_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qaction.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/kernel/qwidgetaction_p.h b/src/widgets/kernel/qwidgetaction_p.h
index 20da855185..1fbcf236a1 100644
--- a/src/widgets/kernel/qwidgetaction_p.h
+++ b/src/widgets/kernel/qwidgetaction_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qaction_p.h"
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp
index 4d37c7f682..81fbe49a43 100644
--- a/src/widgets/kernel/qwidgetbackingstore.cpp
+++ b/src/widgets/kernel/qwidgetbackingstore.cpp
@@ -67,7 +67,9 @@ QT_BEGIN_NAMESPACE
extern QRegion qt_dirtyRegion(QWidget *);
+#ifndef QT_NO_OPENGL
Q_GLOBAL_STATIC(QPlatformTextureList, qt_dummy_platformTextureList)
+#endif
/**
* Flushes the contents of the \a backingStore into the screen area of \a widget.
@@ -174,7 +176,7 @@ static void showYellowThing_win(QWidget *widget, const QRegion &region, int msec
}
i = (i + 1) & 3;
- foreach (const QRect &rect, region.rects()) {
+ for (const QRect &rect : region) {
RECT winRect;
SetRect(&winRect, rect.left(), rect.top(), rect.right(), rect.bottom());
FillRect(hdc, &winRect, brush);
@@ -301,7 +303,7 @@ bool QWidgetBackingStore::bltRect(const QRect &rect, int dx, int dy, QWidget *wi
{
const QPoint pos(tlwOffset + widget->mapTo(tlw, rect.topLeft()));
const QRect tlwRect(QRect(pos, rect.size()));
- if (fullUpdatePending || dirty.intersects(tlwRect))
+ if (dirty.intersects(tlwRect))
return false; // We don't want to scroll junk.
return store->scroll(tlwRect, dx, dy);
}
@@ -370,7 +372,7 @@ QRegion QWidgetBackingStore::dirtyRegion(QWidget *widget) const
const bool widgetDirty = widget && widget != tlw;
const QRect tlwRect(topLevelRect());
const QRect surfaceGeometry(tlwRect.topLeft(), store->size());
- if (fullUpdatePending || (surfaceGeometry != tlwRect && surfaceGeometry.size() != tlwRect.size())) {
+ if (surfaceGeometry != tlwRect && surfaceGeometry.size() != tlwRect.size()) {
if (widgetDirty) {
const QRect dirtyTlwRect = QRect(QPoint(), tlwRect.size());
const QPoint offset(widget->mapTo(tlw, QPoint()));
@@ -548,13 +550,6 @@ void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget,
return;
}
- //### FIXME fullUpdatePending seems to be always false????
- if (fullUpdatePending) {
- if (updateTime == UpdateNow)
- sendUpdateRequest(tlw, updateTime);
- return;
- }
-
const QPoint offset = widget->mapTo(tlw, QPoint());
if (QWidgetPrivate::get(widget)->renderToTexture) {
@@ -647,12 +642,6 @@ void QWidgetBackingStore::markDirty(const QRect &rect, QWidget *widget,
return;
}
- if (fullUpdatePending) {
- if (updateTime == UpdateNow)
- sendUpdateRequest(tlw, updateTime);
- return;
- }
-
if (QWidgetPrivate::get(widget)->renderToTexture) {
if (!widget->d_func()->inDirtyList)
addDirtyRenderToTextureWidget(widget);
@@ -789,7 +778,6 @@ void QWidgetBackingStore::updateLists(QWidget *cur)
QWidgetBackingStore::QWidgetBackingStore(QWidget *topLevel)
: tlw(topLevel),
dirtyOnScreenWidgets(0),
- fullUpdatePending(0),
updateRequestSent(0),
textureListWatcher(0),
perfFrames(0)
@@ -1168,7 +1156,6 @@ void QWidgetBackingStore::sync()
for (int i = 0; i < dirtyWidgets.size(); ++i)
resetWidget(dirtyWidgets.at(i));
dirtyWidgets.clear();
- fullUpdatePending = false;
}
return;
}
@@ -1185,7 +1172,7 @@ void QWidgetBackingStore::doSync()
const bool inTopLevelResize = tlw->d_func()->maybeTopData()->inTopLevelResize;
const QRect tlwRect(topLevelRect());
const QRect surfaceGeometry(tlwRect.topLeft(), store->size());
- if ((fullUpdatePending || inTopLevelResize || surfaceGeometry.size() != tlwRect.size()) && !updatesDisabled) {
+ if ((inTopLevelResize || surfaceGeometry.size() != tlwRect.size()) && !updatesDisabled) {
if (hasStaticContents() && !store->size().isEmpty() ) {
// Repaint existing dirty area and newly visible area.
const QRect clipRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height());
@@ -1281,7 +1268,6 @@ void QWidgetBackingStore::doSync()
tlwExtra->widgetTextures.clear();
findAllTextureWidgetsRecursively(tlw, tlw);
qt_window_private(tlw->windowHandle())->compositing = false; // will get updated in qt_flush()
- fullUpdatePending = false;
#endif
if (toClean.isEmpty()) {
@@ -1347,9 +1333,8 @@ void QWidgetBackingStore::doSync()
updateStaticContentsSize();
dirty = QRegion();
updateRequestSent = false;
- const QVector<QRect> rects(toClean.rects());
- for (int i = 0; i < rects.size(); ++i)
- tlw->d_func()->extra->proxyWidget->update(rects.at(i));
+ for (const QRect &rect : toClean)
+ tlw->d_func()->extra->proxyWidget->update(rect);
return;
}
#endif
diff --git a/src/widgets/kernel/qwidgetbackingstore_p.h b/src/widgets/kernel/qwidgetbackingstore_p.h
index fa2b934ff8..16b36423a6 100644
--- a/src/widgets/kernel/qwidgetbackingstore_p.h
+++ b/src/widgets/kernel/qwidgetbackingstore_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QDebug>
#include <QtWidgets/qwidget.h>
#include <private/qwidget_p.h>
@@ -116,7 +117,7 @@ public:
inline bool isDirty() const
{
- return !(dirtyWidgets.isEmpty() && dirty.isEmpty() && !fullUpdatePending && dirtyRenderToTextureWidgets.isEmpty());
+ return !(dirtyWidgets.isEmpty() && dirty.isEmpty() && dirtyRenderToTextureWidgets.isEmpty());
}
// ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
@@ -135,7 +136,6 @@ private:
QVector<QWidget *> *dirtyOnScreenWidgets;
QList<QWidget *> staticWidgets;
QBackingStore *store;
- uint fullUpdatePending : 1;
uint updateRequestSent : 1;
QPoint tlwOffset;
diff --git a/src/widgets/kernel/qwidgetsfunctions_wince.cpp b/src/widgets/kernel/qwidgetsfunctions_wince.cpp
deleted file mode 100644
index 2bf8c6563b..0000000000
--- a/src/widgets/kernel/qwidgetsfunctions_wince.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "qwidgetsfunctions_wince.h"
-#include <shellapi.h>
-
-QT_USE_NAMESPACE
-
-#ifndef ShellExecute
-HINSTANCE qt_wince_ShellExecute(HWND hwnd, LPCWSTR, LPCWSTR file, LPCWSTR params, LPCWSTR dir, int showCmd)
-{
- SHELLEXECUTEINFO info;
- info.hwnd = hwnd;
- info.lpVerb = L"Open";
- info.lpFile = file;
- info.lpParameters = params;
- info.lpDirectory = dir;
- info.nShow = showCmd;
- info.cbSize = sizeof(info);
- ShellExecuteEx(&info);
- return info.hInstApp;
-}
-#endif
-
-// Internal Qt -----------------------------------------------------
-bool qt_wince_is_platform(const QString &platformString) {
- wchar_t tszPlatform[64];
- if (SystemParametersInfo(SPI_GETPLATFORMNAME, sizeof(tszPlatform) / sizeof(wchar_t), tszPlatform, 0))
- if (0 == _tcsicmp(reinterpret_cast<const wchar_t *> (platformString.utf16()), tszPlatform))
- return true;
- return false;
-}
-
-int qt_wince_get_build()
-{
- OSVERSIONINFO osvi;
- osvi.dwOSVersionInfoSize = sizeof(osvi);
- if (GetVersionEx(&osvi))
- return osvi.dwBuildNumber;
- return 0;
-}
-
-int qt_wince_get_version()
-{
- OSVERSIONINFO osvi;
- osvi.dwOSVersionInfoSize = sizeof(osvi);
- if (GetVersionEx(&osvi))
- return (osvi.dwMajorVersion * 10 + osvi.dwMinorVersion);
- return 0;
-}
-
-bool qt_wince_is_windows_mobile_65()
-{
- const DWORD dwFirstWM65BuildNumber = 21139;
- OSVERSIONINFO osvi;
- osvi.dwOSVersionInfoSize = sizeof(osvi);
- if (!GetVersionEx(&osvi))
- return false;
- return osvi.dwMajorVersion > 5
- || (osvi.dwMajorVersion == 5 && (osvi.dwMinorVersion > 2 ||
- (osvi.dwMinorVersion == 2 && osvi.dwBuildNumber >= dwFirstWM65BuildNumber)));
-}
-
-bool qt_wince_is_pocket_pc() {
- return qt_wince_is_platform(QString::fromLatin1("PocketPC"));
-}
-
-bool qt_wince_is_smartphone() {
- return qt_wince_is_platform(QString::fromLatin1("Smartphone"));
-}
-bool qt_wince_is_mobile() {
- return (qt_wince_is_smartphone() || qt_wince_is_pocket_pc());
-}
-
-bool qt_wince_is_high_dpi() {
- if (!qt_wince_is_pocket_pc())
- return false;
- HDC deviceContext = GetDC(0);
- int dpi = GetDeviceCaps(deviceContext, LOGPIXELSX);
- ReleaseDC(0, deviceContext);
- if ((dpi < 1000) && (dpi > 0))
- return dpi > 96;
- else
- return false;
-}
diff --git a/src/widgets/kernel/qwidgetwindow_p.h b/src/widgets/kernel/qwidgetwindow_p.h
index a0d79b2b72..edf2383596 100644
--- a/src/widgets/kernel/qwidgetwindow_p.h
+++ b/src/widgets/kernel/qwidgetwindow_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtGui/qwindow.h>
#include <QtCore/private/qobject_p.h>
diff --git a/src/widgets/kernel/qwindowcontainer_p.h b/src/widgets/kernel/qwindowcontainer_p.h
index 557a56169e..1d838c8dd6 100644
--- a/src/widgets/kernel/qwindowcontainer_p.h
+++ b/src/widgets/kernel/qwindowcontainer_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtWidgets/qwidget.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/kernel/win.pri b/src/widgets/kernel/win.pri
index e2d5afdeec..7cef2d14a8 100644
--- a/src/widgets/kernel/win.pri
+++ b/src/widgets/kernel/win.pri
@@ -2,6 +2,6 @@
# --------------------------------------------------------------------
INCLUDEPATH += ../3rdparty/wintab
-!wince:!winrt {
- LIBS_PRIVATE *= -lshell32
-}
+!winrt: LIBS_PRIVATE *= -lshell32 -luxtheme -ldwmapi
+# Override MinGW's definition in _mingw.h
+mingw: DEFINES += WINVER=0x600 _WIN32_WINNT=0x0600
diff --git a/src/widgets/statemachine/qbasickeyeventtransition_p.h b/src/widgets/statemachine/qbasickeyeventtransition_p.h
index 0af3ce8051..576c5beb5d 100644
--- a/src/widgets/statemachine/qbasickeyeventtransition_p.h
+++ b/src/widgets/statemachine/qbasickeyeventtransition_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtCore/qabstracttransition.h>
#ifndef QT_NO_STATEMACHINE
diff --git a/src/widgets/statemachine/qbasicmouseeventtransition_p.h b/src/widgets/statemachine/qbasicmouseeventtransition_p.h
index a9f7999355..72320a52dc 100644
--- a/src/widgets/statemachine/qbasicmouseeventtransition_p.h
+++ b/src/widgets/statemachine/qbasicmouseeventtransition_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtCore/qabstracttransition.h>
#ifndef QT_NO_STATEMACHINE
diff --git a/src/widgets/statemachine/qkeyeventtransition.h b/src/widgets/statemachine/qkeyeventtransition.h
index dc62f7909d..1e3f02acd8 100644
--- a/src/widgets/statemachine/qkeyeventtransition.h
+++ b/src/widgets/statemachine/qkeyeventtransition.h
@@ -40,6 +40,7 @@
#ifndef QKEYEVENTTRANSITION_H
#define QKEYEVENTTRANSITION_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qeventtransition.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/statemachine/qmouseeventtransition.h b/src/widgets/statemachine/qmouseeventtransition.h
index f9e9ba7a21..43185b140d 100644
--- a/src/widgets/statemachine/qmouseeventtransition.h
+++ b/src/widgets/statemachine/qmouseeventtransition.h
@@ -40,6 +40,7 @@
#ifndef QMOUSEEVENTTRANSITION_H
#define QMOUSEEVENTTRANSITION_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qeventtransition.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/styles/qandroidstyle_p.h b/src/widgets/styles/qandroidstyle_p.h
index 0c9d2469f0..4649d90852 100644
--- a/src/widgets/styles/qandroidstyle_p.h
+++ b/src/widgets/styles/qandroidstyle_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtCore/QList>
#include <QtCore/QMargins>
#include <QtCore/QHash>
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index cf81f53ad0..6cdfc061e1 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -3724,6 +3724,8 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
btnOpt.state &= ~State_MouseOver;
int bsx = 0;
int bsy = 0;
+ const int buttonIconMetric = proxy()->pixelMetric(PM_TitleBarButtonIconSize, &btnOpt, widget);
+ const QSize buttonIconSize(buttonIconMetric, buttonIconMetric);
if (opt->subControls & QStyle::SC_MdiCloseButton) {
if (opt->activeSubControls & QStyle::SC_MdiCloseButton && (opt->state & State_Sunken)) {
btnOpt.state |= State_Sunken;
@@ -3738,7 +3740,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
}
btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiCloseButton, widget);
proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget);
- QPixmap pm = proxy()->standardIcon(SP_TitleBarCloseButton).pixmap(qt_getWindow(widget), QSize(16, 16));
+ QPixmap pm = proxy()->standardIcon(SP_TitleBarCloseButton).pixmap(qt_getWindow(widget), buttonIconSize);
proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
}
if (opt->subControls & QStyle::SC_MdiNormalButton) {
@@ -3755,7 +3757,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
}
btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiNormalButton, widget);
proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget);
- QPixmap pm = proxy()->standardIcon(SP_TitleBarNormalButton).pixmap(qt_getWindow(widget), QSize(16, 16));
+ QPixmap pm = proxy()->standardIcon(SP_TitleBarNormalButton).pixmap(qt_getWindow(widget), buttonIconSize);
proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
}
if (opt->subControls & QStyle::SC_MdiMinButton) {
@@ -3772,7 +3774,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
}
btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiMinButton, widget);
proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget);
- QPixmap pm = proxy()->standardIcon(SP_TitleBarMinButton).pixmap(qt_getWindow(widget), QSize(16, 16));
+ QPixmap pm = proxy()->standardIcon(SP_TitleBarMinButton).pixmap(qt_getWindow(widget), buttonIconSize);
proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
}
}
@@ -4393,6 +4395,13 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid
}
break; }
+ case PM_TitleBarButtonSize:
+ ret = int(QStyleHelper::dpiScaled(16.));
+ break;
+ case PM_TitleBarButtonIconSize:
+ ret = int(QStyleHelper::dpiScaled(16.));
+ break;
+
case PM_ScrollBarSliderMin:
ret = int(QStyleHelper::dpiScaled(9.));
break;
@@ -4845,16 +4854,18 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
#endif // QT_NO_GROUPBOX
case CT_MdiControls:
if (const QStyleOptionComplex *styleOpt = qstyleoption_cast<const QStyleOptionComplex *>(opt)) {
+ const int buttonSize = proxy()->pixelMetric(PM_TitleBarButtonSize, styleOpt, widget);
int width = 1;
if (styleOpt->subControls & SC_MdiMinButton)
- width += 16 + 1;
+ width += buttonSize + 1;
if (styleOpt->subControls & SC_MdiNormalButton)
- width += 16 + 1;
+ width += buttonSize + 1;
if (styleOpt->subControls & SC_MdiCloseButton)
- width += 16 + 1;
- sz = QSize(width, 16);
+ width += buttonSize + 1;
+ sz = QSize(width, buttonSize);
} else {
- sz = QSize(52, 16);
+ const int buttonSize = proxy()->pixelMetric(PM_TitleBarButtonSize, opt, widget);
+ sz = QSize(1 + 3 * (buttonSize + 1), buttonSize);
}
break;
#ifndef QT_NO_ITEMVIEWS
@@ -5902,14 +5913,14 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) {
QPlatformTheme::StandardPixmap sp = static_cast<QPlatformTheme::StandardPixmap>(standardIcon);
QIcon retIcon;
- QList<int> sizes = theme->themeHint(QPlatformTheme::IconPixmapSizes).value<QList<int> >();
- Q_FOREACH (int size, sizes) {
+ const QList<QSize> sizes = theme->themeHint(QPlatformTheme::IconPixmapSizes).value<QList<QSize> >();
+ for (const QSize &size : sizes) {
QPixmap mainIcon;
- const QString cacheKey = QLatin1String("qt_mac_constructQIconFromIconRef") + QString::number(standardIcon) + QString::number(size);
+ const QString cacheKey = QLatin1String("qt_mac_constructQIconFromIconRef") + QString::number(standardIcon) + QString::number(size.width());
if (standardIcon >= QStyle::SP_CustomBase) {
- mainIcon = theme->standardPixmap(sp, QSizeF(size, size));
+ mainIcon = theme->standardPixmap(sp, QSizeF(size));
} else if (QPixmapCache::find(cacheKey, mainIcon) == false) {
- mainIcon = theme->standardPixmap(sp, QSizeF(size, size));
+ mainIcon = theme->standardPixmap(sp, QSizeF(size));
QPixmapCache::insert(cacheKey, mainIcon);
}
diff --git a/src/widgets/styles/qcommonstyle.h b/src/widgets/styles/qcommonstyle.h
index 9eb1c548bd..ed880a150f 100644
--- a/src/widgets/styles/qcommonstyle.h
+++ b/src/widgets/styles/qcommonstyle.h
@@ -40,6 +40,7 @@
#ifndef QCOMMONSTYLE_H
#define QCOMMONSTYLE_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qstyle.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/styles/qcommonstyle_p.h b/src/widgets/styles/qcommonstyle_p.h
index 031789fc5f..2ef7f30d21 100644
--- a/src/widgets/styles/qcommonstyle_p.h
+++ b/src/widgets/styles/qcommonstyle_p.h
@@ -40,6 +40,7 @@
#ifndef QCOMMONSTYLE_P_H
#define QCOMMONSTYLE_P_H
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qcommonstyle.h"
#include "qstyle_p.h"
#include "qstyleanimation_p.h"
diff --git a/src/widgets/styles/qcommonstylepixmaps_p.h b/src/widgets/styles/qcommonstylepixmaps_p.h
index 8842bc8b76..58b979465a 100644
--- a/src/widgets/styles/qcommonstylepixmaps_p.h
+++ b/src/widgets/styles/qcommonstylepixmaps_p.h
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include <QtCore/qglobal.h>
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#ifndef QT_NO_IMAGEFORMAT_XPM
diff --git a/src/widgets/styles/qdrawutil.h b/src/widgets/styles/qdrawutil.h
index adb4478bc9..121221dfc9 100644
--- a/src/widgets/styles/qdrawutil.h
+++ b/src/widgets/styles/qdrawutil.h
@@ -40,6 +40,7 @@
#ifndef QDRAWUTIL_H
#define QDRAWUTIL_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qnamespace.h>
#include <QtCore/qstring.h> // char*->QString conversion
#include <QtCore/qmargins.h>
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index 3a39441785..06c3101643 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -3101,6 +3101,9 @@ int QFusionStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, co
case PM_DockWidgetTitleBarButtonMargin:
val = 2;
break;
+ case PM_TitleBarButtonSize:
+ val = 19;
+ break;
case PM_MaximumDragDistance:
return -1; // Do not dpi-scale because the value is magic
case PM_TabCloseIndicatorWidth:
@@ -3224,18 +3227,7 @@ QSize QFusionStyle::sizeFromContents(ContentsType type, const QStyleOption *opti
newSize += QSize(4, 4);
break;
case CT_MdiControls:
- if (const QStyleOptionComplex *styleOpt = qstyleoption_cast<const QStyleOptionComplex *>(option)) {
- int width = 0;
- if (styleOpt->subControls & SC_MdiMinButton)
- width += 19 + 1;
- if (styleOpt->subControls & SC_MdiNormalButton)
- width += 19 + 1;
- if (styleOpt->subControls & SC_MdiCloseButton)
- width += 19 + 1;
- newSize = QSize(width, 19);
- } else {
- newSize = QSize(60, 19);
- }
+ newSize -= QSize(1, 0);
break;
default:
break;
@@ -3631,7 +3623,7 @@ int QFusionStyle::styleHint(StyleHint hint, const QStyleOption *option, const QW
case SH_Menu_SupportsSections:
return 1;
-#if defined(Q_OS_IOS)
+#if defined(QT_PLATFORM_UIKIT)
case SH_ComboBox_UseNativePopup:
return 1;
#endif
diff --git a/src/widgets/styles/qfusionstyle_p.h b/src/widgets/styles/qfusionstyle_p.h
index c836b9e193..126fb96e78 100644
--- a/src/widgets/styles/qfusionstyle_p.h
+++ b/src/widgets/styles/qfusionstyle_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtWidgets/qcommonstyle.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/styles/qfusionstyle_p_p.h b/src/widgets/styles/qfusionstyle_p_p.h
index e45055f2c2..8d1d27d244 100644
--- a/src/widgets/styles/qfusionstyle_p_p.h
+++ b/src/widgets/styles/qfusionstyle_p_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qcommonstyle.h"
#include "qcommonstyle_p.h"
#include <qpa/qplatformtheme.h>
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index 9a07eaf851..47a6156662 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -587,7 +587,7 @@ HIMutableShapeRef qt_mac_toHIMutableShape(const QRegion &region)
CGRect cgRect = CGRectMake(qtRect.x(), qtRect.y(), qtRect.width(), qtRect.height());
HIShapeUnionWithRect(shape, &cgRect);
} else {
- foreach (const QRect &qtRect, region.rects()) {
+ for (const QRect &qtRect : region) {
CGRect cgRect = CGRectMake(qtRect.x(), qtRect.y(), qtRect.width(), qtRect.height());
HIShapeUnionWithRect(shape, &cgRect);
}
@@ -1400,7 +1400,7 @@ void QMacStylePrivate::initComboboxBdi(const QStyleOptionComboBox *combo, HIThem
bdi->adornment = kThemeAdornmentFocus;
if (combo->activeSubControls & QStyle::SC_ComboBoxArrow)
bdi->state = kThemeStatePressed;
- else if (tds == kThemeStateInactive && QSysInfo::MacintoshVersion <= QSysInfo::MV_10_9)
+ else if (tds == kThemeStateInactive && QSysInfo::MacintoshVersion < QSysInfo::MV_10_10)
bdi->state = kThemeStateActive;
else
bdi->state = tds;
@@ -1719,7 +1719,7 @@ void QMacStylePrivate::getSliderInfo(QStyle::ComplexControl cc, const QStyleOpti
|| slider->tickPosition == QSlider::TicksBothSides;
tdi->bounds = qt_hirectForQRect(slider->rect);
- if (isScrollbar || QSysInfo::MacintoshVersion <= QSysInfo::MV_10_9) {
+ if (isScrollbar || QSysInfo::MacintoshVersion < QSysInfo::MV_10_10) {
tdi->min = slider->minimum;
tdi->max = slider->maximum;
tdi->value = slider->sliderPosition;
@@ -2253,9 +2253,7 @@ void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QBrush
CGContextSaveGState(cg);
HIThemeSetFill(kThemeBrushDialogBackgroundActive, 0, cg, kHIThemeOrientationInverted);
- const QVector<QRect> &rects = rgn.rects();
- for (int i = 0; i < rects.size(); ++i) {
- const QRect rect(rects.at(i));
+ for (const QRect &rect : rgn) {
// Anchor the pattern to the top so it stays put when the window is resized.
CGContextSetPatternPhase(cg, CGSizeMake(rect.width(), rect.height()));
CGRect mac_rect = CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
@@ -4022,7 +4020,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
bool hasIcon = !btn.icon.isNull();
bool hasText = !btn.text.isEmpty();
- if (!hasMenu && QSysInfo::QSysInfo::MacintoshVersion > QSysInfo::MV_10_9) {
+ if (!hasMenu && QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_10) {
if (tds == kThemeStatePressed
|| (tds == kThemeStateActive
&& ((btn.features & QStyleOptionButton::DefaultButton && !d->autoDefaultButton)
@@ -4127,8 +4125,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
QStyleOptionComboBox comboCopy = *cb;
comboCopy.direction = Qt::LeftToRight;
if (opt->state & QStyle::State_Small)
- comboCopy.rect.translate(0, w ? (QSysInfo::macVersion() > QSysInfo::MV_10_8 ? 0 : -1) :
- (QSysInfo::macVersion() > QSysInfo::MV_10_9 ? 0 : -2)); // Supports Qt Quick Controls
+ comboCopy.rect.translate(0, w ? 0 : (QSysInfo::macVersion() >= QSysInfo::MV_10_10 ? 0 : -2)); // Supports Qt Quick Controls
else if (QSysInfo::macVersion() == QSysInfo::MV_10_9)
comboCopy.rect.translate(0, 1);
QCommonStyle::drawControl(CE_ComboBoxLabel, &comboCopy, p, w);
@@ -5467,7 +5464,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
opacity = anim->currentValue();
}
- shouldExpand = (opt->activeSubControls || wasActive) && QSysInfo::macVersion() >= QSysInfo::MV_10_8;
+ shouldExpand = (opt->activeSubControls || wasActive);
if (shouldExpand) {
if (!anim && !oldActiveControls) {
// Start expand animation only once and when entering
@@ -5964,7 +5961,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
drawToolbarButtonArrow(tb->rect, tds, cg);
}
if (tb->state & State_On) {
- if (QSysInfo::MacintoshVersion > QSysInfo::MV_MAVERICKS) {
+ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_10) {
QWindow *window = 0;
if (widget && widget->window())
window = widget->window()->windowHandle();
@@ -6326,7 +6323,7 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
switch (sc) {
case SC_ComboBoxEditField:{
ret = QMacStylePrivate::comboboxEditBounds(combo->rect, bdi);
- if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_9)
+ if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_10)
ret.setHeight(ret.height() - 1);
break; }
case SC_ComboBoxArrow:{
@@ -7115,11 +7112,11 @@ void qt_mac_scale_region(QRegion *region, qreal scaleFactor)
return;
QVector<QRect> scaledRects;
- scaledRects.reserve(region->rects().count());
+ scaledRects.reserve(region->rectCount());
- foreach (const QRect &rect, region->rects()) {
+ for (const QRect &rect : *region)
scaledRects.append(QRect(rect.topLeft() * scaleFactor, rect.size() * scaleFactor));
- }
+
region->setRects(&scaledRects[0], scaledRects.count());
}
diff --git a/src/widgets/styles/qmacstyle_mac_p.h b/src/widgets/styles/qmacstyle_mac_p.h
index 7ff3d25952..fdc22794b4 100644
--- a/src/widgets/styles/qmacstyle_mac_p.h
+++ b/src/widgets/styles/qmacstyle_mac_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtWidgets/qcommonstyle.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h
index 31ba8c3464..798f6ed90b 100644
--- a/src/widgets/styles/qmacstyle_mac_p_p.h
+++ b/src/widgets/styles/qmacstyle_mac_p_p.h
@@ -44,6 +44,7 @@
#include <Carbon/Carbon.h>
#undef check
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qmacstyle_mac_p.h"
#include "qcommonstyle_p.h"
#include <private/qapplication_p.h>
diff --git a/src/widgets/styles/qpixmapstyle_p.h b/src/widgets/styles/qpixmapstyle_p.h
index 4255cba2de..618d6d2f50 100644
--- a/src/widgets/styles/qpixmapstyle_p.h
+++ b/src/widgets/styles/qpixmapstyle_p.h
@@ -42,6 +42,7 @@
#ifndef QPIXMAPSTYLE_H
#define QPIXMAPSTYLE_H
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtWidgets/QCommonStyle>
#include <QtWidgets/QTileRules>
diff --git a/src/widgets/styles/qpixmapstyle_p_p.h b/src/widgets/styles/qpixmapstyle_p_p.h
index 3400729c4c..481262d5c5 100644
--- a/src/widgets/styles/qpixmapstyle_p_p.h
+++ b/src/widgets/styles/qpixmapstyle_p_p.h
@@ -40,6 +40,7 @@
#ifndef QPIXMAPSTYLE_P_H
#define QPIXMAPSTYLE_P_H
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qpixmapstyle_p.h"
#include "qcommonstyle_p.h"
diff --git a/src/widgets/styles/qproxystyle.cpp b/src/widgets/styles/qproxystyle.cpp
index 182c974729..5739678932 100644
--- a/src/widgets/styles/qproxystyle.cpp
+++ b/src/widgets/styles/qproxystyle.cpp
@@ -131,16 +131,9 @@ QProxyStyle::QProxyStyle(QStyle *style) :
\sa QStyleFactory::create()
*/
-QProxyStyle::QProxyStyle(const QString &key) :
- QCommonStyle(*new QProxyStylePrivate())
+QProxyStyle::QProxyStyle(const QString &key)
+ : QProxyStyle(QStyleFactory::create(key))
{
- Q_D(QProxyStyle);
- QStyle *style = QStyleFactory::create(key);
- if (style) {
- d->baseStyle = style;
- style->setProxy(this);
- style->setParent(this); // Take ownership
- }
}
/*!
diff --git a/src/widgets/styles/qproxystyle.h b/src/widgets/styles/qproxystyle.h
index d98155d249..20a0f12868 100644
--- a/src/widgets/styles/qproxystyle.h
+++ b/src/widgets/styles/qproxystyle.h
@@ -40,6 +40,7 @@
#ifndef QPROXYSTYLE_H
#define QPROXYSTYLE_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/QCommonStyle>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/styles/qproxystyle_p.h b/src/widgets/styles/qproxystyle_p.h
index 3ec12d4634..2343a03e2a 100644
--- a/src/widgets/styles/qproxystyle_p.h
+++ b/src/widgets/styles/qproxystyle_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qcommonstyle.h"
#include "qcommonstyle_p.h"
#include "qproxystyle.h"
diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp
index 9714168afc..01d972af65 100644
--- a/src/widgets/styles/qstyle.cpp
+++ b/src/widgets/styles/qstyle.cpp
@@ -1494,6 +1494,11 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
\value PM_HeaderDefaultSectionSizeVertical The default size of sections
in a vertical header. This enum value has been introduced in Qt 5.5.
+ \value PM_TitleBarButtonIconSize The size of button icons on a title bar.
+ This enum value has been introduced in Qt 5.8.
+ \value PM_TitleBarButtonSize The size of buttons on a title bar.
+ This enum value has been introduced in Qt 5.8.
+
\value PM_CustomBase Base value for custom pixel metrics. Custom
values must be greater than this value.
diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h
index 0f1259160e..ce33dbed62 100644
--- a/src/widgets/styles/qstyle.h
+++ b/src/widgets/styles/qstyle.h
@@ -40,6 +40,7 @@
#ifndef QSTYLE_H
#define QSTYLE_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qrect.h>
#include <QtCore/qsize.h>
@@ -570,6 +571,9 @@ public:
PM_HeaderDefaultSectionSizeHorizontal,
PM_HeaderDefaultSectionSizeVertical,
+ PM_TitleBarButtonIconSize,
+ PM_TitleBarButtonSize,
+
// do not add any values below/greater than this
PM_CustomBase = 0xf0000000
};
diff --git a/src/widgets/styles/qstyle_wince.qrc b/src/widgets/styles/qstyle_wince.qrc
deleted file mode 100644
index c3d643fac7..0000000000
--- a/src/widgets/styles/qstyle_wince.qrc
+++ /dev/null
@@ -1,97 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource prefix="/qt-project.org/styles/commonstyle">
-<file>images/filelink-16.png</file>
-<file>images/filelink-32.png</file>
-<file>images/file-16.png</file>
-<file>images/file-32.png</file>
-<file>images/newdirectory-16.png</file>
-<file>images/newdirectory-32.png</file>
-<file>images/parentdir-16.png</file>
-<file>images/parentdir-32.png</file>
-<file>images/dvd-16.png</file>
-<file>images/dvd-32.png</file>
-<file>images/cdr-16.png</file>
-<file>images/cdr-32.png</file>
-<file>images/floppy-16.png</file>
-<file>images/floppy-32.png</file>
-<file>images/harddrive-16.png</file>
-<file>images/harddrive-32.png</file>
-<file>images/trash-16.png</file>
-<file>images/trash-32.png</file>
-<file>images/networkdrive-16.png</file>
-<file>images/networkdrive-32.png</file>
-<file>images/computer-16.png</file>
-<file>images/computer-32.png</file>
-<file>images/desktop-16.png</file>
-<file>images/desktop-32.png</file>
-<file>images/dirclosed-16.png</file>
-<file>images/dirclosed-32.png</file>
-<file>images/dirlink-16.png</file>
-<file>images/dirlink-32.png</file>
-<file>images/diropen-16.png</file>
-<file>images/diropen-32.png</file>
-<file>images/left-16.png</file>
-<file>images/left-32.png</file>
-<file>images/right-16.png</file>
-<file>images/right-32.png</file>
-<file>images/up-16.png</file>
-<file>images/up-32.png</file>
-<file>images/down-16.png</file>
-<file>images/down-32.png</file>
-<file>images/filecontents-16.png</file>
-<file>images/filecontents-32.png</file>
-<file>images/fileinfo-16.png</file>
-<file>images/fileinfo-32.png</file>
-<file>images/viewdetailed-16.png</file>
-<file>images/viewdetailed-32.png</file>
-<file>images/viewlist-16.png</file>
-<file>images/viewlist-32.png</file>
-<file>images/fontbitmap-16.png</file>
-<file>images/fonttruetype-16.png</file>
-<file>images/standardbutton-apply-16.png</file>
-<file>images/standardbutton-apply-32.png</file>
-<file>images/standardbutton-cancel-16.png</file>
-<file>images/standardbutton-cancel-32.png</file>
-<file>images/standardbutton-clear-16.png</file>
-<file>images/standardbutton-clear-32.png</file>
-<file>images/standardbutton-close-16.png</file>
-<file>images/standardbutton-close-32.png</file>
-<file>images/standardbutton-delete-16.png</file>
-<file>images/standardbutton-delete-32.png</file>
-<file>images/standardbutton-help-16.png</file>
-<file>images/standardbutton-help-32.png</file>
-<file>images/standardbutton-no-16.png</file>
-<file>images/standardbutton-no-32.png</file>
-<file>images/standardbutton-ok-16.png</file>
-<file>images/standardbutton-ok-32.png</file>
-<file>images/standardbutton-open-16.png</file>
-<file>images/standardbutton-open-32.png</file>
-<file>images/standardbutton-save-16.png</file>
-<file>images/standardbutton-save-32.png</file>
-<file>images/standardbutton-yes-16.png</file>
-<file>images/standardbutton-yes-32.png</file>
-<file>images/standardbutton-closetab-16.png</file>
-<file>images/standardbutton-closetab-down-16.png</file>
-<file>images/standardbutton-closetab-hover-16.png</file>
-<file>images/refresh-24.png</file>
-<file>images/refresh-32.png</file>
-<file>images/stop-24.png</file>
-<file>images/stop-32.png</file>
-<file>images/media-stop-16.png</file>
-<file>images/media-stop-32.png</file>
-<file>images/media-play-16.png</file>
-<file>images/media-play-32.png</file>
-<file>images/media-pause-16.png</file>
-<file>images/media-pause-32.png</file>
-<file>images/media-seek-forward-16.png</file>
-<file>images/media-seek-forward-32.png</file>
-<file>images/media-seek-backward-16.png</file>
-<file>images/media-seek-backward-32.png</file>
-<file>images/media-skip-forward-16.png</file>
-<file>images/media-skip-forward-32.png</file>
-<file>images/media-skip-backward-16.png</file>
-<file>images/media-skip-backward-32.png</file>
-<file>images/media-volume-16.png</file>
-<file>images/media-volume-muted-16.png</file>
-</qresource>
-</RCC>
diff --git a/src/widgets/styles/qstyleanimation_p.h b/src/widgets/styles/qstyleanimation_p.h
index ed802a450e..3b10eeea27 100644
--- a/src/widgets/styles/qstyleanimation_p.h
+++ b/src/widgets/styles/qstyleanimation_p.h
@@ -40,6 +40,7 @@
#ifndef QSTYLEANIMATION_P_H
#define QSTYLEANIMATION_P_H
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qabstractanimation.h"
#include "qdatetime.h"
#include "qimage.h"
diff --git a/src/widgets/styles/qstylefactory.cpp b/src/widgets/styles/qstylefactory.cpp
index bebd322c9e..bb849c148f 100644
--- a/src/widgets/styles/qstylefactory.cpp
+++ b/src/widgets/styles/qstylefactory.cpp
@@ -56,12 +56,6 @@
#ifndef QT_NO_STYLE_WINDOWSVISTA
#include "qwindowsvistastyle_p.h"
#endif
-#ifndef QT_NO_STYLE_WINDOWSCE
-#include "qwindowscestyle_p.h"
-#endif
-#ifndef QT_NO_STYLE_WINDOWSMOBILE
-#include "qwindowsmobilestyle_p.h"
-#endif
#if !defined(QT_NO_STYLE_MAC) && defined(Q_OS_MAC)
# include "qmacstyle_mac_p.h"
@@ -114,16 +108,6 @@ QStyle *QStyleFactory::create(const QString& key)
ret = new QWindowsStyle;
else
#endif
-#ifndef QT_NO_STYLE_WINDOWSCE
- if (style == QLatin1String("windowsce"))
- ret = new QWindowsCEStyle;
- else
-#endif
-#ifndef QT_NO_STYLE_WINDOWSMOBILE
- if (style == QLatin1String("windowsmobile"))
- ret = new QWindowsMobileStyle;
- else
-#endif
#ifndef QT_NO_STYLE_WINDOWSXP
if (style == QLatin1String("windowsxp"))
ret = new QWindowsXPStyle;
@@ -180,14 +164,6 @@ QStringList QStyleFactory::keys()
if (!list.contains(QLatin1String("Windows")))
list << QLatin1String("Windows");
#endif
-#ifndef QT_NO_STYLE_WINDOWSCE
- if (!list.contains(QLatin1String("WindowsCE")))
- list << QLatin1String("WindowsCE");
-#endif
-#ifndef QT_NO_STYLE_WINDOWSMOBILE
- if (!list.contains(QLatin1String("WindowsMobile")))
- list << QLatin1String("WindowsMobile");
-#endif
#ifndef QT_NO_STYLE_WINDOWSXP
if (!list.contains(QLatin1String("WindowsXP")) &&
(QSysInfo::WindowsVersion >= QSysInfo::WV_XP && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)))
diff --git a/src/widgets/styles/qstylefactory.h b/src/widgets/styles/qstylefactory.h
index c5393c3a66..50c3750b6c 100644
--- a/src/widgets/styles/qstylefactory.h
+++ b/src/widgets/styles/qstylefactory.h
@@ -40,6 +40,7 @@
#ifndef QSTYLEFACTORY_H
#define QSTYLEFACTORY_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qstringlist.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/styles/qstylehelper_p.h b/src/widgets/styles/qstylehelper_p.h
index b00b873731..88eb05f1d7 100644
--- a/src/widgets/styles/qstylehelper_p.h
+++ b/src/widgets/styles/qstylehelper_p.h
@@ -37,7 +37,7 @@
**
****************************************************************************/
-#include <QtCore/qglobal.h>
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtCore/qpoint.h>
#include <QtCore/qstring.h>
#include <QtGui/qpolygon.h>
diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h
index b03e2cc860..896024f73a 100644
--- a/src/widgets/styles/qstyleoption.h
+++ b/src/widgets/styles/qstyleoption.h
@@ -40,6 +40,7 @@
#ifndef QSTYLEOPTION_H
#define QSTYLEOPTION_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qvariant.h>
#include <QtWidgets/qabstractspinbox.h>
#include <QtGui/qicon.h>
diff --git a/src/widgets/styles/qstylepainter.h b/src/widgets/styles/qstylepainter.h
index 27d4c43550..191360727e 100644
--- a/src/widgets/styles/qstylepainter.h
+++ b/src/widgets/styles/qstylepainter.h
@@ -40,6 +40,7 @@
#ifndef QSTYLEPAINTER_H
#define QSTYLEPAINTER_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtGui/qpainter.h>
#include <QtWidgets/qstyle.h>
#include <QtWidgets/qwidget.h>
diff --git a/src/widgets/styles/qstyleplugin.h b/src/widgets/styles/qstyleplugin.h
index 72dfa8b6ed..d44f57d208 100644
--- a/src/widgets/styles/qstyleplugin.h
+++ b/src/widgets/styles/qstyleplugin.h
@@ -40,6 +40,7 @@
#ifndef QSTYLEPLUGIN_H
#define QSTYLEPLUGIN_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
diff --git a/src/widgets/styles/qstylesheetstyle_p.h b/src/widgets/styles/qstylesheetstyle_p.h
index 80bac0c789..55dd2df329 100644
--- a/src/widgets/styles/qstylesheetstyle_p.h
+++ b/src/widgets/styles/qstylesheetstyle_p.h
@@ -40,6 +40,7 @@
#ifndef QSTYLESHEETSTYLE_P_H
#define QSTYLESHEETSTYLE_P_H
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qwindowsstyle_p.h"
#ifndef QT_NO_STYLE_STYLESHEET
diff --git a/src/widgets/styles/qwindowscestyle.cpp b/src/widgets/styles/qwindowscestyle.cpp
deleted file mode 100644
index 4633659963..0000000000
--- a/src/widgets/styles/qwindowscestyle.cpp
+++ /dev/null
@@ -1,2429 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwindowscestyle_p.h"
-
-#if !defined(QT_NO_STYLE_WINDOWSCE) || defined(QT_PLUGIN)
-
-#include "qpainterpath.h"
-#include "qapplication.h"
-#include "qdockwidget.h"
-#include "qtoolbar.h"
-#include "qpaintengine.h"
-#include "qpainter.h"
-#include "qstyleoption.h"
-#include "qwindowscestyle_p_p.h"
-#include "qdebug.h"
-#include "qdrawutil.h"
-
-QT_BEGIN_NAMESPACE
-
-static const int windowsItemFrame = 2; // menu item frame width
-static const int windowsItemHMargin = 3; // menu item hor text margin
-static const int windowsItemVMargin = 2; // menu item ver text margin
-static const int windowsArrowHMargin = 6; // arrow horizontal margin
-static const int windowsRightBorder = 15; // right border on windows
-static const int windowsCheckMarkWidth = 14; // checkmarks width on windows
-
-static const int windowsCEitemViewCheckBoxSize = 14;
-static const int windowsCEFrameGroupBoxOffset = 9;
-static const int windowsCEIndicatorSize = 14;
-static const int windowsCEExclusiveIndicatorSize = 14;
-static const int windowsCESliderThickness = 24;
-static const int windowsCEIconSize = 16;
-
-static const QColor windowsCECheckBoxGradientColorBegin = QColor(222, 224, 214);
-static const QColor windowsCECheckBoxGradientColorEnd = QColor(255, 255, 255);
-
-enum QSliderDirection { SlUp, SlDown, SlLeft, SlRight };
-
-QWindowsCEStyle::QWindowsCEStyle() : QWindowsStyle() {
- qApp->setEffectEnabled(Qt::UI_FadeMenu, false);
- qApp->setEffectEnabled(Qt::UI_AnimateMenu, false);
-}
-
-QWindowsCEStyle::~QWindowsCEStyle()
-{
-}
-
-void QWindowsCEStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
- QPainter *painter, const QWidget *widget) const {
-
- bool doRestore = false;
- QRect rect = option->rect;
-
- switch (element) {
- case PE_PanelButtonTool: {
- if (
-#ifndef QT_NO_TOOLBAR
- (widget && qobject_cast<QToolBar*>(widget->parentWidget())) ||
-#endif
-#ifndef QT_NO_DOCKWIDGET
- (widget && widget->inherits("QDockWidgetTitleButton")) ||
-#endif
- (option->state & (State_Sunken | State_On)))
- QWindowsCEStylePrivate::drawWinCEButton(painter, option->rect.adjusted(0, 0, 0, 0),
- option->palette, option->state & (State_Sunken | State_On),
- &option->palette.button());
- if (option->state & (State_On)){
- QBrush fill = QBrush(option->palette.midlight().color(), Qt::Dense4Pattern);
- painter->fillRect(option->rect.adjusted(windowsItemFrame , windowsItemFrame ,
- -windowsItemFrame , -windowsItemFrame ), fill);
- }
- break; }
- case PE_IndicatorButtonDropDown:
- QWindowsCEStylePrivate::drawWinCEButton(painter, option->rect, option->palette,
- option->state & (State_Sunken | State_On),
- &option->palette.brush(QPalette::Button));
- break;
-#ifndef QT_NO_TABBAR
- case PE_IndicatorTabTear:
- if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
- bool rtl = tab->direction == Qt::RightToLeft;
- QRect rect = tab->rect;
- QPainterPath path;
- rect.setTop(rect.top() + ((tab->state & State_Selected) ? 1 : 3));
- rect.setBottom(rect.bottom() - ((tab->state & State_Selected) ? 0 : 2));
- path.moveTo(QPoint(rtl ? rect.right() : rect.left(), rect.top()));
- int count = 3;
- for(int jags = 1; jags <= count; ++jags, rtl = !rtl)
- path.lineTo(QPoint(rtl ? rect.left() : rect.right(), rect.top() + jags * rect.height()/count));
-
- painter->setPen(QPen(tab->palette.light(), qreal(.8)));
- painter->setBrush(tab->palette.background());
- painter->setRenderHint(QPainter::Antialiasing);
- painter->drawPath(path);
- }
- break;
-#endif //QT_NO_TABBAR
-#ifndef QT_NO_TOOLBAR
- case PE_IndicatorToolBarSeparator:
- //nothing to draw on WindowsCE
- break;
- case PE_IndicatorToolBarHandle:
- painter->save();
- painter->translate(option->rect.x(), option->rect.y());
- if (option->state & State_Horizontal) {
- int x = option->rect.width() / 2 - 4;
- if (QApplication::layoutDirection() == Qt::RightToLeft)
- x -= 2;
- if (option->rect.height() > 4) {
- QWindowsCEStylePrivate::drawWinCEButton(painter,x - 1, 0, 7, option->rect.height(),
- option->palette, false, 0);
- QWindowsCEStylePrivate::drawWinCEPanel(painter, x, 1, 3, option->rect.height() - 1,
- option->palette, false, 0);
- QWindowsCEStylePrivate::drawWinCEPanel(painter, x + 3, 1, 3, option->rect.height() - 1,
- option->palette, false, 0);
- painter->setPen(option->palette.button().color());
- painter->drawLine(x + 4, 2, x + 4,option->rect.height() - 2);
- }
- } else {
- if (option->rect.width() > 4) {
- int y = option->rect.height() / 2 - 4;
- QWindowsCEStylePrivate::drawWinCEPanel(painter, 2, y, option->rect.width() - 2, 3,
- option->palette, false, 0);
- QWindowsCEStylePrivate::drawWinCEPanel(painter, 2, y + 3, option->rect.width() - 2, 3,
- option->palette, false, 0);
- }
- }
- painter->restore();
- break;
-
-#endif // QT_NO_TOOLBAR
- case PE_FrameButtonTool: {
-#ifndef QT_NO_DOCKWIDGET
- if (widget && widget->inherits("QDockWidgetTitleButton")) {
- if (const QDockWidget *dw = qobject_cast<const QDockWidget *>(widget->parent()))
- if (dw->isFloating()){
- QWindowsCEStylePrivate::drawWinCEButton(painter, option->rect.adjusted(1, 1, 0, 0),
- option->palette, option->state & (State_Sunken | State_On),
- &option->palette.button());
- return;
- }
- }
-#endif // QT_NO_DOCKWIDGET
- QBrush fill;
- bool stippled;
- bool panel = (element == PE_PanelButtonTool);
- if ((!(option->state & State_Sunken ))
- && (!(option->state & State_Enabled)
- || ((option->state & State_Enabled ) && !(option->state & State_MouseOver)))
- && (option->state & State_On)) {
- fill = QBrush(option->palette.light().color(), Qt::Dense4Pattern);
- stippled = true;
- } else {
- fill = option->palette.brush(QPalette::Button);
- stippled = false;
- }
- if (option->state & (State_Raised | State_Sunken | State_On)) {
- if (option->state & State_AutoRaise) {
- if(option->state & (State_Enabled | State_Sunken | State_On)){
- if (panel)
- QWindowsCEStylePrivate::drawWinCEPanel(painter, option->rect, option->palette,
- option->state & (State_Sunken | State_On), &fill);
- else
- qDrawShadeRect(painter, option->rect, option->palette,
- option->state & (State_Sunken | State_On), 1);
- }
- if (stippled) {
- painter->setPen(option->palette.button().color());
- painter->drawRect(option->rect.adjusted(1, 1, -2, -2));
- }
- } else {
- QWindowsCEStylePrivate::drawWinCEButton(painter, option->rect, option->palette,
- option->state & (State_Sunken | State_On), panel ? &fill : 0);
- }
- } else {
- painter->fillRect(option->rect, fill);
- }
- break; }
-
- case PE_PanelButtonBevel: {
- QBrush fill;
- bool panel = element != PE_FrameButtonBevel;
- painter->setBrushOrigin(option->rect.topLeft());
- if (!(option->state & State_Sunken) && (option->state & State_On))
- fill = QBrush(option->palette.light().color(), Qt::Dense4Pattern);
- else
- fill = option->palette.brush(QPalette::Button);
-
- if (option->state & (State_Raised | State_On | State_Sunken)) {
- QWindowsCEStylePrivate::drawWinCEButton(painter, option->rect, option->palette,
- option->state & (State_Sunken | State_On),
- panel ? &fill : 0); ;
- } else {
- if (panel)
- painter->fillRect(option->rect, fill);
- else
- painter->drawRect(option->rect);
- }
- break; }
-
- case PE_FrameGroupBox:
- if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
- QRect fr = frame->rect;
- painter->setPen(frame->palette.shadow().color());
- painter->drawRect(fr.x(), fr.y(), fr.x() + fr.width() - 1,
- fr.y() + fr.height() - windowsCEFrameGroupBoxOffset);
- }
- break;
-
- case PE_IndicatorCheckBox: {
- QBrush fill;
- if (option->state & State_NoChange)
- fill = QBrush(option->palette.base().color(), Qt::Dense4Pattern);
- else if (option->state & State_Sunken)
- fill = option->palette.button();
- else if (option->state & State_Enabled)
- fill = option->palette.base();
- else
- fill = option->palette.background();
- painter->save();
- doRestore = true;
- painter->fillRect(option->rect,fill);
- painter->setPen(option->palette.dark().color());
- painter->drawRect(option->rect);
- painter->setPen(option->palette.shadow().color());
- painter->drawLine(option->rect.x() + 1,option->rect.y() + 1,
- option->rect.x() + option->rect.width() - 1, option->rect.y() + 1);
- painter->drawLine(option->rect.x() + 1,option->rect.y() + 1,
- option->rect.x() + 1, option->rect.y() + option->rect.height() - 1);
- //fall through...
- }
- case PE_IndicatorViewItemCheck: {
- if (!doRestore) {
- painter->save();
- doRestore = true;
- }
- int arrowSize= 2;
- if (element == PE_IndicatorViewItemCheck) {
- QLinearGradient linearGradient(QPoint(option->rect.x(),option->rect.y()), QPoint(option->rect.x()+option->rect.width(),
- option->rect.y()+option->rect.height()));
- linearGradient.setColorAt(0, windowsCECheckBoxGradientColorBegin);
- linearGradient.setColorAt(1, windowsCECheckBoxGradientColorEnd);
- painter->setBrush(linearGradient);
- painter->setPen(Qt::NoPen);
- if (option->state & State_NoChange)
- painter->setBrush(option->palette.brush(QPalette::Button));
- painter->setPen(option->palette.link().color());
- painter->drawRect(option->rect.x(), option->rect.y(), windowsCEitemViewCheckBoxSize, windowsCEitemViewCheckBoxSize);
- painter->setPen(option->palette.brightText().color());
- arrowSize= 3;
- }
- if (!(option->state & State_Off)) {
- QLineF lines[9];
- int i, xx, yy;
- xx = option->rect.x() + 4;
- yy = option->rect.y() + 6;
- for (i = 0; i < 4; ++i) {
- lines[i] = QLineF(xx, yy, xx, yy + arrowSize);
- ++xx;
- ++yy;
- }
- yy -= 2;
- for (i = 4; i < 9; ++i) {
- lines[i] = QLineF(xx, yy, xx, yy + arrowSize);
- ++xx;
- --yy;
- }
- painter->drawLines(lines, 9);
- }
- if (doRestore)
- painter->restore();
-
- break; }
- case PE_IndicatorRadioButton: {
- QRect ir = option->rect;
- painter->save();
- painter->setPen(Qt::NoPen);
- painter->setBrush(option->palette.light());
- painter->drawEllipse(option->rect);
- painter->setPen(option->palette.shadow().color());
- painter->setBrush(option->palette.shadow().color());
- painter->drawArc(option->rect, 0, 360 * 16);
- painter->drawArc(option->rect.x() + 1, option->rect.y() + 1, option->rect.width() - 2,
- option->rect.height() - 2, 40 * 16, 180 * 16);
- painter->setPen(option->palette.light().color());
- painter->drawPoint(option->rect.x() + 11, option->rect.y() + 3);
- painter->drawPoint(option->rect.x() + 3,option->rect.y() + 3);
- painter->setPen(option->palette.shadow().color());
- painter->drawPoint(option->rect.x() +3,option->rect.y() + 12);
- if (option->state & (State_Sunken | State_On)) {
- painter->setPen(Qt::NoPen);
- painter->setBrush(option->palette.text());
- painter->drawEllipse(option->rect.x() +3,option->rect.y()+ 2,9,10);
- }
- painter->restore();
- break; }
- case PE_PanelMenuBar:
- painter->save();
- painter->setPen(option->palette.shadow().color());
- painter->drawRect(option->rect);
- painter->restore();
- break;
- case PE_PanelButtonCommand:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- QBrush fill;
- State flags = option->state;
- QPalette pal = option->palette;
- QRect r = option->rect;
- if (! (flags & State_Sunken) && (flags & State_On))
- fill = QBrush(pal.light().color(), Qt::Dense4Pattern);
- else
- fill = pal.brush(QPalette::Button);
- if (btn->features & QStyleOptionButton::DefaultButton && flags & State_Sunken) {
- painter->setPen(pal.dark().color());
- painter->setBrush(fill);
- painter->drawRect(r.adjusted(0, 0, -1, -1));
- } else if (flags & (State_Raised | State_Sunken | State_On | State_Sunken)) {
- QWindowsCEStylePrivate::drawWinCEButton(painter, r, pal, flags & (State_Sunken | State_On),
- &fill);
- } else {
- painter->fillRect(r, fill);
- }
-
- }
- break;
- case PE_FrameDefaultButton: {
- painter->setPen(option->palette.shadow().color());
- QRect rect = option->rect;
- rect.adjust(0, 0, -1, -1);
- painter->drawRect(rect);
- break; }
- case PE_IndicatorSpinPlus:
- case PE_IndicatorSpinMinus: {
- QRect r = option->rect;
- int fw = pixelMetric(PM_DefaultFrameWidth, option, widget)+2;
- QRect br = r.adjusted(fw, fw, -fw, -fw);
- int offset = (option->state & State_Sunken) ? 1 : 0;
- int step = (br.width() + 4) / 5;
- painter->fillRect(br.x() + offset, br.y() + offset +br.height() / 2 - step / 2,
- br.width(), step,
- option->palette.buttonText());
- if (element == PE_IndicatorSpinPlus)
- painter->fillRect(br.x() + br.width() / 2 - step / 2 + offset, br.y() + offset+4,
- step, br.height()-7,
- option->palette.buttonText());
- break; }
- case PE_IndicatorSpinUp:
- case PE_IndicatorSpinDown: {
- painter->save();
- QPoint points[7];
- switch (element) {
- case PE_IndicatorSpinUp:
- points[0] = QPoint(-2, -4);
- points[1] = QPoint(-2, 2);
- points[2] = QPoint(-1, -3);
- points[3] = QPoint(-1, 1);
- points[4] = QPoint(0, -2);
- points[5] = QPoint(0, 0);
- points[6] = QPoint(1, -1);
- break;
- case PE_IndicatorSpinDown:
- points[0] = QPoint(0, -4);
- points[1] = QPoint(0, 2);
- points[2] = QPoint(-1, -3);
- points[3] = QPoint(-1, 1);
- points[4] = QPoint(-2, -2);
- points[5] = QPoint(-2, 0);
- points[6] = QPoint(-3, -1);
- break;
- default:
- break;
- }
- if (option->state & State_Sunken)
- painter->translate(pixelMetric(PM_ButtonShiftHorizontal),
- pixelMetric(PM_ButtonShiftVertical));
- if (option->state & State_Enabled) {
- painter->translate(option->rect.x() + option->rect.width() / 2,
- option->rect.y() + option->rect.height() / 2);
- painter->setPen(option->palette.buttonText().color());
- painter->drawLine(points[0], points[1]);
- painter->drawLine(points[2], points[3]);
- painter->drawLine(points[4], points[5]);
- painter->drawPoint(points[6]);
- } else {
- painter->translate(option->rect.x() + option->rect.width() / 2 + 1,
- option->rect.y() + option->rect.height() / 2 + 1);
- painter->setPen(option->palette.light().color());
- painter->drawLine(points[0], points[1]);
- painter->drawLine(points[2], points[3]);
- painter->drawLine(points[4], points[5]);
- painter->drawPoint(points[6]);
- painter->translate(-1, -1);
- painter->setPen(option->palette.mid().color());
- painter->drawLine(points[0], points[1]);
- painter->drawLine(points[2], points[3]);
- painter->drawLine(points[4], points[5]);
- painter->drawPoint(points[6]);
- }
-
- painter->restore();
- break; }
- case PE_IndicatorArrowUp:
- case PE_IndicatorArrowDown:
- case PE_IndicatorArrowRight:
- case PE_IndicatorArrowLeft: {
- painter->save();
- QPoint points[9];
- switch (element) {
- case PE_IndicatorArrowUp:
-
- points[0] = QPoint(-4, 2);
- points[1] = QPoint(4, 2);
- points[2] = QPoint(-3, 1);
- points[3] = QPoint(3, 1);
- points[4] = QPoint(-2, 0);
- points[5] = QPoint(2, 0);
- points[6] = QPoint(-1, -1);
- points[7] = QPoint(1, -1);
- points[8] = QPoint(0, -2);
- break;
- case PE_IndicatorArrowDown:
-
- points[0] = QPoint(-4, -2);
- points[1] = QPoint(4, -2);
- points[2] = QPoint(-3, -1);
- points[3] = QPoint(3, -1);
- points[4] = QPoint(-2, 0);
- points[5] = QPoint(2, 0);
- points[6] = QPoint(-1, 1);
- points[7] = QPoint(1, 1);
- points[8] = QPoint(0, 2);
- break;
- case PE_IndicatorArrowRight:
- points[0] = QPoint(-3, -4);
- points[1] = QPoint(-3, 4);
- points[2] = QPoint(-2, -3);
- points[3] = QPoint(-2, 3);
- points[4] = QPoint(-1, -2);
- points[5] = QPoint(-1, 2);
- points[6] = QPoint(0, -1);
- points[7] = QPoint(0, 1);
- points[8] = QPoint(1, 0);
- break;
- case PE_IndicatorArrowLeft:
- points[0] = QPoint(1, -4);
- points[1] = QPoint(1, 4);
- points[2] = QPoint(0, -3);
- points[3] = QPoint(0, 3);
- points[4] = QPoint(-1, -2);
- points[5] = QPoint(-1, 2);
- points[6] = QPoint(-2, -1);
- points[7] = QPoint(-2, 1);
- points[8] = QPoint(-3, 0);
- break;
- default:
- break;
- }
- if (option->state & State_Sunken)
- painter->translate(pixelMetric(PM_ButtonShiftHorizontal),
- pixelMetric(PM_ButtonShiftVertical));
- if (option->state & State_Enabled) {
- painter->translate(option->rect.x() + option->rect.width() / 2,
- option->rect.y() + option->rect.height() / 2);
- painter->setPen(option->palette.buttonText().color());
- painter->drawLine(points[0], points[1]);
- painter->drawLine(points[2], points[3]);
- painter->drawLine(points[4], points[5]);
- painter->drawLine(points[6], points[7]);
- painter->drawPoint(points[8]);
- } else {
- painter->translate(option->rect.x() + option->rect.width() / 2 + 1,
- option->rect.y() + option->rect.height() / 2 + 1);
- painter->setPen(option->palette.light().color());
- painter->drawLine(points[0], points[1]);
- painter->drawLine(points[2], points[3]);
- painter->drawLine(points[4], points[5]);
- painter->drawLine(points[6], points[7]);
- painter->drawPoint(points[8]);
- painter->translate(-1, -1);
- painter->setPen(option->palette.mid().color());
- painter->drawLine(points[0], points[1]);
- painter->drawLine(points[2], points[3]);
- painter->drawLine(points[4], points[5]);
- painter->drawLine(points[6], points[7]);
- painter->drawPoint(points[8]);
- }
- painter->restore();
- break; }
-
- case PE_FrameWindow: {
- QPalette popupPal = option->palette;
- popupPal.setColor(QPalette::Light, option->palette.background().color());
- popupPal.setColor(QPalette::Midlight, option->palette.light().color());
- QWindowsCEStylePrivate::drawWinCEPanel(painter, option->rect, popupPal, option->state & State_Sunken);
- break; }
-
- case PE_Frame:
- case PE_FrameMenu:
- if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
- QPalette popupPal = frame->palette;
- QRect r = frame->rect;
- qDrawPlainRect(painter, r, frame->palette.shadow().color(),1);
- }
- break;
- case PE_FrameStatusBar:
- QWindowsCEStylePrivate::drawWinCEPanel(painter, option->rect, option->palette, true, 0);
- break;
-
- case PE_FrameTabWidget: {
- QRect rect = option->rect;
- QPalette pal = option->palette;
- QWindowsCEStylePrivate::drawWinCEButton(painter, option->rect, option->palette, false, 0);
- break; }
- default:
- QWindowsStyle::drawPrimitive(element, option, painter, widget);
- break;
- }
-}
-
-void QWindowsCEStyle::drawControl(ControlElement element, const QStyleOption *option,
- QPainter *painter, const QWidget *widget) const {
- switch (element) {
- #ifndef QT_NO_MENU
- case CE_MenuTearoff: {
- if(option->state & State_Selected) {
- if(pixelMetric(PM_MenuPanelWidth, option, widget) > 1)
- qDrawShadePanel(painter, option->rect.x(), option->rect.y(), option->rect.width(),
- option->rect.height(), option->palette, false, 2,
- &option->palette.brush(QPalette::Button));
- else
- qDrawShadePanel(painter, option->rect.x() + 1, option->rect.y() + 1, option->rect.width() - 2,
- option->rect.height() - 2, option->palette, true, 1, &option->palette.brush(QPalette::Button));
- } else {
- painter->fillRect(option->rect, option->palette.brush(QPalette::Button));
- }
- painter->setPen(QPen(option->palette.dark().color(), 1, Qt::DashLine));
- painter->drawLine(option->rect.x()+2, option->rect.y()+option->rect.height()/2-1, option->rect.x()+option->rect.width()-4,
- option->rect.y()+option->rect.height()/2-1);
- painter->setPen(QPen(option->palette.light().color(), 1, Qt::DashLine));
- painter->drawLine(option->rect.x()+2, option->rect.y()+option->rect.height()/2, option->rect.x()+option->rect.width()-4,
- option->rect.y()+option->rect.height()/2);
- break; }
-
-
- case CE_MenuBarItem:
- if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
- bool active = mbi->state & State_Selected;
- bool hasFocus = mbi->state & State_HasFocus;
- bool down = mbi->state & State_Sunken;
- QStyleOptionMenuItem newMbi = *mbi;
- if (active || hasFocus) {
- QBrush b = mbi->palette.brush(QPalette::Highlight);
- if (active && down) {
- painter->fillRect(mbi->rect.adjusted(0, 1, 0, -1), b);
- }
- }
- uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip
- | Qt::TextSingleLine;
- if (!styleHint(SH_UnderlineShortcut, mbi, widget))
- alignment |= Qt::TextHideMnemonic;
-
- painter->save();
- QFont f = painter->font();
- f.setBold(true);
- painter->setFont(f);
- QPixmap pix = mbi->icon.pixmap(pixelMetric(PM_SmallIconSize),
- (mbi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
- if (!pix.isNull())
- drawItemPixmap(painter,mbi->rect, alignment, pix);
- else
- if (active && down)
- drawItemText(painter, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled,
- mbi->text, QPalette::Light);
- else
- drawItemText(painter, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled,
- mbi->text, QPalette::ButtonText);
- painter->restore();
- }
- break;
-
- case CE_MenuBarEmptyArea:
- painter->save();
- painter->setPen(option->palette.shadow().color());
- if (widget && !widget->testAttribute(Qt::WA_NoSystemBackground)) {
- painter->eraseRect(option->rect);
- QRect r = option->rect;
- painter->drawLine(r.x() + 1, r.y() + 1, r.x()+ 1, r.y()+ r.height() - 2);
- painter->drawLine(r.x() - 2 + r.width(), r.y() + 1, r.x() - 2 + r.width(), r.y() + r.height() - 2);
- painter->drawLine(r.x() + 1, r.y() +1, r.x() - 1 + r.width(), r.y() + 1);
- painter->drawLine(r.x() + 1, r.y() + r.height()-2 , r.x() - 2 + r.width(), r.y() + r.height() - 2);
- }
- painter->restore();
- break;
-
- case CE_MenuItem:
- if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
- int x, y, w, h;
- menuitem->rect.getRect(&x, &y, &w, &h);
- int tab = menuitem->tabWidth;
- bool dis = !(menuitem->state & State_Enabled);
- bool checked = menuitem->checkType != QStyleOptionMenuItem::NotCheckable
- ? menuitem->checked : false;
- bool act = menuitem->state & State_Selected;
-
- // windows always has a check column, regardless whether we have an icon or not
- int checkcol = qMax(menuitem->maxIconWidth, windowsCheckMarkWidth);
- QBrush fill = menuitem->palette.brush(act ? QPalette::Highlight : QPalette::Button);
- painter->fillRect(menuitem->rect.adjusted(1, 1, 0, 0), fill);
-
- if (menuitem->menuItemType == QStyleOptionMenuItem::Separator) {
- int yoff = y-1 + h / 2;
- painter->setPen(menuitem->palette.shadow().color());
- painter->drawLine(x + 4, yoff + 1, x + w - 8, yoff + 1);
- return;
- }
-
- QRect vCheckRect = visualRect(option->direction, menuitem->rect, QRect(menuitem->rect.x(),
- menuitem->rect.y(), checkcol, menuitem->rect.height()));
- if (checked) {
- if (act && !dis) {
- qDrawPlainRect(painter, vCheckRect,
- menuitem->palette.button().color(), 1,
- &menuitem->palette.brush(QPalette::Button));
- } else {
- QBrush fill(menuitem->palette.button().color(), Qt::Dense4Pattern);
- qDrawPlainRect(painter, vCheckRect,menuitem->palette.button().color(), 1, &fill);
- }
- } else if (!act) {
- painter->fillRect(vCheckRect, menuitem->palette.brush(QPalette::Button));
- }
- // On Windows Style, if we have a checkable item and an icon we
- // draw the icon recessed to indicate an item is checked. If we
- // have no icon, we draw a checkmark instead.
- if (!menuitem->icon.isNull()) {
- QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
- if (act && !dis)
- mode = QIcon::Active;
- QPixmap pixmap;
- if (checked)
- pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize), mode, QIcon::On);
- else
- pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize), mode);
- const int pixw = pixmap.width() / pixmap.devicePixelRatio();
- const int pixh = pixmap.height() / pixmap.devicePixelRatio();
- if (act && !dis && !checked)
- qDrawPlainRect(painter, vCheckRect, menuitem->palette.button().color(), 1,
- &menuitem->palette.brush(QPalette::Button));
- QRect pmr(0, 0, pixw, pixh);
- pmr.moveCenter(vCheckRect.center());
- painter->setPen(menuitem->palette.text().color());
- painter->drawPixmap(pmr.topLeft(), pixmap);
- } else if (checked) {
- QStyleOptionMenuItem newMi = *menuitem;
- newMi.state = State_None;
- if (!dis)
- newMi.state |= State_Enabled;
- if (act)
- newMi.state |= State_On;
- newMi.rect = visualRect(option->direction, menuitem->rect, QRect(menuitem->rect.x()
- + windowsItemFrame, menuitem->rect.y() + windowsItemFrame,
- checkcol - 2 * windowsItemFrame, menuitem->rect.height() - 2*windowsItemFrame));
- drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, painter, widget);
- }
- painter->setPen(act ? menuitem->palette.highlightedText().color() : menuitem->palette.buttonText().color());
-
- QColor discol;
- if (dis) {
- discol = menuitem->palette.text().color();
- painter->setPen(discol);
- }
- int xm = windowsItemFrame + checkcol + windowsItemHMargin;
- int xpos = menuitem->rect.x() + xm;
- QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
- QRect vTextRect = visualRect(option->direction, menuitem->rect, textRect);
- QString s = menuitem->text;
- if (!s.isEmpty()) { // draw text
- painter->save();
- int t = s.indexOf(QLatin1Char('\t'));
- int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
- if (!styleHint(SH_UnderlineShortcut, menuitem, widget))
- text_flags |= Qt::TextHideMnemonic;
- text_flags |= Qt::AlignLeft;
- if (t >= 0) {
- QRect vShortcutRect = visualRect(option->direction, menuitem->rect,
- QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom())));
- if (dis && !act)
- painter->setPen(discol);
- painter->drawText(vShortcutRect, text_flags, s.mid(t + 1));
- s = s.left(t);
- }
- QFont font = menuitem->font;
- if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
- font.setBold(true);
- painter->setFont(font);
- if (dis && !act)
- painter->setPen(discol);
- painter->drawText(vTextRect, text_flags, s.left(t));
- painter->restore();
- }
- if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
- int dim = (h - 2 * windowsItemFrame) / 2;
- PrimitiveElement arrow;
- arrow = (option->direction == Qt::RightToLeft) ? PE_IndicatorSpinDown : PE_IndicatorSpinUp;
- xpos = x + w - windowsArrowHMargin - windowsItemFrame - dim;
- QRect vSubMenuRect = visualRect(option->direction, menuitem->rect, QRect(xpos, y + h / 2 - dim / 2, dim, dim));
- QStyleOptionMenuItem newMI = *menuitem;
- newMI.rect = vSubMenuRect;
- newMI.state = dis ? State_None : State_Enabled;
- if (act)
- newMI.palette.setColor(QPalette::ButtonText,
- newMI.palette.highlightedText().color());
- drawPrimitive(arrow, &newMI, painter, widget);
- }
- }
- break;
-#endif // QT_NO_MENU
- case CE_MenuVMargin:
- painter->fillRect(option->rect, Qt::white);
- break;
- case CE_MenuEmptyArea:
- QWindowsStyle::drawControl(element,option, painter, widget);
- break;
-
-#ifndef QT_NO_TABBAR
- case CE_TabBarTab:
- if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
- drawControl(CE_TabBarTabShape, tab, painter, widget);
- drawControl(CE_TabBarTabLabel, tab, painter, widget);
- }
- break;
- case CE_TabBarTabShape:
- if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
- bool rtlHorTabs = (tab->direction == Qt::RightToLeft
- && (tab->shape == QTabBar::RoundedNorth
- || tab->shape == QTabBar::RoundedSouth));
- bool selected = tab->state & State_Selected;
- bool lastTab = ((!rtlHorTabs && tab->position == QStyleOptionTab::End)
- || (rtlHorTabs
- && tab->position == QStyleOptionTab::Beginning));
- bool firstTab = ((!rtlHorTabs
- && tab->position == QStyleOptionTab::Beginning)
- || (rtlHorTabs
- && tab->position == QStyleOptionTab::End));
- bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
- bool previousSelected =
- ((!rtlHorTabs
- && tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)
- || (rtlHorTabs
- && tab->selectedPosition == QStyleOptionTab::NextIsSelected));
- bool nextSelected =
- ((!rtlHorTabs
- && tab->selectedPosition == QStyleOptionTab::NextIsSelected)
- || (rtlHorTabs
- && tab->selectedPosition
- == QStyleOptionTab::PreviousIsSelected));
- int tabBarAlignment = styleHint(SH_TabBar_Alignment, tab, widget);
- bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft)
- || (rtlHorTabs
- && tabBarAlignment == Qt::AlignRight);
-
- bool rightAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignRight)
- || (rtlHorTabs
- && tabBarAlignment == Qt::AlignLeft);
- QColor light = tab->palette.light().color();
- QColor midlight = tab->palette.midlight().color();
- QColor dark = tab->palette.dark().color();
- QColor shadow = tab->palette.shadow().color();
- QColor background = tab->palette.background().color();
- int borderThinkness = pixelMetric(PM_TabBarBaseOverlap, tab, widget);
- if (selected)
- borderThinkness /= 2;
- QRect r2(option->rect);
- int x1 = r2.left();
- int x2 = r2.right();
- int y1 = r2.top();
- int y2 = r2.bottom();
- switch (tab->shape) {
- default:
- QCommonStyle::drawControl(element, tab, painter, widget);
- break;
- case QTabBar::RoundedNorth: {
- if (!selected) {
- y1 += 2;
- x1 += firstTab ? borderThinkness : 0;
- x2 -= lastTab ? borderThinkness : 0;
- }
-
- painter->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 2), tab->palette.background());
-
- // Delete border
- if (selected) {
- painter->setPen(background);
- painter->drawLine(x1, y2 - 1, x2, y2 - 1);
- painter->drawLine(x1, y2 + 1, x2, y2 + 1);
- painter->drawLine(x1, y2, x2, y2);
- }
- // Left
- if (firstTab || selected || onlyOne || !previousSelected) {
- painter->setPen(dark);
- painter->drawLine(x1, y1 + 2, x1, y2 - ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
- painter->drawPoint(x1 + 1, y1 + 1);
- painter->setPen(midlight);
- painter->drawLine(x1 + 1, y1 + 2, x1 + 1, y2 -
- ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
-
- }
- // Top
- {
- int beg = x1 + (previousSelected ? 0 : 2);
- int end = x2 - (nextSelected ? 0 : 2);
- painter->setPen(dark);
- painter->drawLine(beg, y1, end, y1);
-
- painter->setPen(midlight);
- painter->drawLine(beg, y1 + 1, end, y1 + 1);
-
- }
- // Right
- if (lastTab || selected || onlyOne || !nextSelected) {
- painter->setPen(shadow);
- painter->drawLine(x2, y1 + 2, x2, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
- painter->drawPoint(x2 - 1, y1 + 1);
- painter->setPen(dark);
- painter->drawLine(x2 - 1, y1 + 2, x2 - 1, y2 - ((onlyOne || lastTab) && selected && rightAligned ? 0 : borderThinkness));
- }
- break; }
- case QTabBar::RoundedSouth: {
- if (!selected) {
- y2 -= 2;
- x1 += firstTab ? borderThinkness : 0;
- x2 -= lastTab ? borderThinkness : 0;
- }
-
- painter->fillRect(QRect(x1 + 1, y1 + 2, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.background());
-
- // Delete border
- if (selected) {
- painter->setPen(background);
- painter->drawLine(x1, y1 + 1, x2 - 1, y1 + 1);
- painter->drawLine(x1, y1 - 1, x2 - 1, y1 - 1);
- painter->drawLine(x1, y1, x2 - 1, y1);
- }
- // Left
- if (firstTab || selected || onlyOne || !previousSelected) {
- painter->setPen(dark);
- painter->drawLine(x1, y2 - 2, x1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
- painter->drawPoint(x1 + 1, y2 - 1);
- painter->setPen(midlight);
- painter->drawLine(x1 + 1, y2 - 2, x1 + 1, y1 + ((onlyOne || firstTab) && selected && leftAligned ? 0 : borderThinkness));
- }
- // Bottom
- {
- int beg = x1 + (previousSelected ? 0 : 2);
- int end = x2 - (nextSelected ? 0 : 2);
- painter->setPen(shadow);
- painter->drawLine(beg, y2, end, y2);
- painter->setPen(dark);
- painter->drawLine(beg, y2 - 1, end, y2 - 1);
- }
- // Right
- if (lastTab || selected || onlyOne || !nextSelected) {
- painter->setPen(shadow);
- painter->drawLine(x2, y2 - 2, x2, y1 + ((onlyOne || lastTab) && selected &&
- rightAligned ? 0 : borderThinkness));
- painter->drawPoint(x2 - 1, y2 - 1);
- painter->setPen(dark);
- painter->drawLine(x2 - 1, y2 - 2, x2 - 1, y1 + ((onlyOne || lastTab) && selected &&
- rightAligned ? 0 : borderThinkness));
- }
- break; }
- case QTabBar::RoundedWest: {
- if (!selected) {
- x1 += 2;
- y1 += firstTab ? borderThinkness : 0;
- y2 -= lastTab ? borderThinkness : 0;
- }
-
- painter->fillRect(QRect(x1 + 1, y1 + 1, (x2 - x1) - 2, (y2 - y1) - 1), tab->palette.background());
-
- // Delete border
- if (selected) {
- painter->setPen(background);
- painter->drawLine(x2 - 1, y1, x2 - 1, y2);
- painter->drawLine(x2, y1, x2, y2);
- }
- // Top
- if (firstTab || selected || onlyOne || !previousSelected) {
- painter->setPen(dark);
- painter->drawLine(x1 + 2, y1, x2 - ((onlyOne || firstTab) && selected &&
- leftAligned ? 0 : borderThinkness), y1);
- painter->drawPoint(x1 + 1, y1 + 1);
- painter->setPen(midlight);
- painter->drawLine(x1 + 2, y1 + 1, x2 - ((onlyOne || firstTab) && selected &&
- leftAligned ? 0 : borderThinkness), y1 + 1);
- }
- // Left
- {
- int beg = y1 + (previousSelected ? 0 : 2);
- int end = y2 - (nextSelected ? 0 : 2);
- painter->setPen(dark);
- painter->drawLine(x1, beg, x1, end);
- painter->setPen(midlight);
- painter->drawLine(x1 + 1, beg, x1 + 1, end);
- }
- // Bottom
- if (lastTab || selected || onlyOne || !nextSelected) {
- painter->setPen(shadow);
- painter->drawLine(x1 + 3, y2, x2 - ((onlyOne || lastTab) && selected &&
- rightAligned ? 0 : borderThinkness), y2);
- painter->drawPoint(x1 + 2, y2 - 1);
- painter->setPen(dark);
- painter->drawLine(x1 + 3, y2 - 1, x2 - ((onlyOne || lastTab) && selected &&
- rightAligned ? 0 : borderThinkness), y2 - 1);
- painter->drawPoint(x1 + 1, y2 - 1);
- painter->drawPoint(x1 + 2, y2);
- }
- break; }
- case QTabBar::RoundedEast: {
- if (!selected) {
- x2 -= 2;
- y1 += firstTab ? borderThinkness : 0;
- y2 -= lastTab ? borderThinkness : 0;
- }
-
- painter->fillRect(QRect(x1 + 2, y1 + 1, (x2 - x1) - 1, (y2 - y1) - 1), tab->palette.background());
-
- // Delete border
- if (selected) {
- painter->setPen(background);
- painter->drawLine(x1 + 1, y1, x1 + 1, y2 - 1);
- painter->drawLine(x1, y1, x1, y2 - 1);
- }
- // Top
- if (firstTab || selected || onlyOne || !previousSelected) {
- painter->setPen(dark);
- painter->drawLine(x2 - 2, y1, x1 + ((onlyOne || firstTab) && selected &&
- leftAligned ? 0 : borderThinkness), y1);
- painter->drawPoint(x2 - 1, y1 + 1);
- painter->setPen(midlight);
- painter->drawLine(x2 - 3, y1 + 1, x1 + ((onlyOne || firstTab) &&
- selected && leftAligned ? 0 : borderThinkness), y1 + 1);
- painter->drawPoint(x2 - 1, y1);
-
- }
- // Right
- {
- int beg = y1 + (previousSelected ? 0 : 2);
- int end = y2 - (nextSelected ? 0 : 2);
- painter->setPen(shadow);
- painter->drawLine(x2, beg, x2, end);
- painter->setPen(dark);
- painter->drawLine(x2 - 1, beg, x2 - 1, end);
- }
- // Bottom
- if (lastTab || selected || onlyOne || !nextSelected) {
- painter->setPen(shadow);
- painter->drawLine(x2 - 2, y2, x1 + ((onlyOne || lastTab) &&
- selected && rightAligned ? 0 : borderThinkness), y2);
- painter->drawPoint(x2 - 1, y2 - 1);
- painter->setPen(dark);
- painter->drawLine(x2 - 2, y2 - 1, x1 + ((onlyOne || lastTab) &&
- selected && rightAligned ? 0 : borderThinkness), y2 - 1);
- }
- break; }
- }
- }
- break;
-#endif // QT_NO_TABBAR
-
- case CE_ToolBar: {
- QRect rect = option->rect;
- painter->setPen(QPen(option->palette.dark().color()));
- painter->drawLine(rect.topRight().x()-1,
- rect.topRight().y(),
- rect.bottomRight().x()-1,
- rect.bottomRight().y());
- painter->drawLine(rect.bottomLeft().x(),
- rect.bottomLeft().y(),
- rect.bottomRight().x(),
- rect.bottomRight().y());
- painter->setPen(QPen(option->palette.light().color()));
- painter->drawLine(rect.topRight().x(),
- rect.topRight().y(),
- rect.bottomRight().x(),
- rect.bottomRight().y());
- painter->drawLine(rect.topLeft().x(),
- rect.topLeft().y(),
- rect.topRight().x(),
- rect.topRight().y());
-
- break; }
-#ifndef QT_NO_SCROLLBAR
- case CE_ScrollBarSubLine:
- case CE_ScrollBarAddLine: {
- if (option->state & State_Sunken) {
- QStyleOption buttonOpt = *option;
-
- drawPrimitive(PE_PanelButtonBevel, &buttonOpt, painter, widget);
- } else {
- QStyleOption buttonOpt = *option;
- if (!(buttonOpt.state & State_Sunken))
- buttonOpt.state |= State_Raised;
- drawPrimitive(PE_PanelButtonBevel, &buttonOpt, painter, widget);
- }
- PrimitiveElement arrow;
- if (option->state & State_Horizontal) {
- if (element == CE_ScrollBarAddLine)
- arrow = option->direction == Qt::LeftToRight ? PE_IndicatorArrowRight : PE_IndicatorArrowLeft;
- else
- arrow = option->direction == Qt::LeftToRight ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
- } else {
- if (element == CE_ScrollBarAddLine)
- arrow = PE_IndicatorArrowDown;
- else
- arrow = PE_IndicatorArrowUp;
- }
- drawPrimitive(arrow, option, painter, widget);
- break; }
- case CE_ScrollBarAddPage:
- case CE_ScrollBarSubPage: {
- QBrush br;
- QBrush bg = painter->background();
- Qt::BGMode bg_mode = painter->backgroundMode();
- painter->setPen(Qt::NoPen);
- painter->setBackgroundMode(Qt::OpaqueMode);
-
- if (option->state & State_Sunken) {
- br = QBrush(option->palette.shadow().color(), Qt::Dense4Pattern);
- painter->setBackground(option->palette.dark().color());
- painter->setBrush(br);
- } else {
- QPixmap pm = option->palette.brush(QPalette::Light).texture();
- if (option->state & State_Enabled)
- br = !pm.isNull() ? QBrush(pm) : QBrush(option->palette.button().color(), Qt::Dense4Pattern);
- else
- br = !pm.isNull() ? QBrush(pm) : QBrush(option->palette.light().color(), Qt::Dense4Pattern);
- painter->setBackground(option->palette.base().color());
- painter->setBrush(br);
- }
- painter->drawRect(option->rect);
- painter->setBackground(bg);
- painter->setBackgroundMode(bg_mode);
- break; }
- case CE_ScrollBarSlider:
- if (!(option->state & State_Enabled)) {
- QStyleOptionButton buttonOpt;
- buttonOpt.QStyleOption::operator=(*option);
- buttonOpt.state = State_Enabled | State_Raised;
- drawPrimitive(PE_PanelButtonBevel, &buttonOpt, painter, widget);
- QPixmap pm = option->palette.brush(QPalette::Light).texture();
- QBrush br = !pm.isNull() ? QBrush(pm) : QBrush(option->palette.light().color(), Qt::Dense4Pattern);
- painter->setPen(Qt::NoPen);
- painter->setBrush(br);
- painter->setBackgroundMode(Qt::OpaqueMode);
- painter->drawRect(option->rect.adjusted(2, 2, -2, -2));
- } else {
- QStyleOptionButton buttonOpt;
- buttonOpt.QStyleOption::operator=(*option);
- buttonOpt.state = State_Enabled | State_Raised;
- drawPrimitive(PE_PanelButtonBevel, &buttonOpt, painter, widget);
- }
- break;
-#endif // QT_NO_SCROLLBAR
- case CE_HeaderSection: {
- QBrush fill;
- if (option->state & State_On)
- fill = QBrush(option->palette.light().color(), Qt::Dense4Pattern);
- else
- fill = option->palette.brush(QPalette::Button);
-
- if (option->state & (State_Raised | State_Sunken)) {
- QWindowsCEStylePrivate::drawWinCEButton(painter, option->rect, option->palette,
- option->state & State_Sunken, &fill);
- } else {
- painter->fillRect(option->rect, fill);
- }
- break; }
-
- case CE_DockWidgetTitle:
- QWindowsStyle::drawControl(element,option, painter, widget);
- break;
-
- case CE_PushButtonLabel:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- painter->save();
- QFont f = painter->font();
- f.setBold(true);
- painter->setFont(f);
- QRect ir = btn->rect;
- uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic;
- if (!styleHint(SH_UnderlineShortcut, btn, widget))
- tf |= Qt::TextHideMnemonic;
-
- if (btn->state & (State_On | State_Sunken))
- ir.translate(pixelMetric(PM_ButtonShiftHorizontal, option, widget),
- pixelMetric(PM_ButtonShiftVertical, option, widget));
- if (!btn->icon.isNull()) {
- QIcon::Mode mode = btn->state & State_Enabled ? QIcon::Normal
- : QIcon::Disabled;
- if (mode == QIcon::Normal && btn->state & State_HasFocus)
- mode = QIcon::Active;
- QIcon::State state = QIcon::Off;
- if (btn->state & State_On)
- state = QIcon::On;
- QPixmap pixmap = btn->icon.pixmap(btn->iconSize, mode, state);
- int pixw = pixmap.width();
- int pixh = pixmap.height();
- //Center the icon if there is no text
-
- QPoint point;
- if (btn->text.isEmpty()) {
- point = QPoint(ir.x() + ir.width() / 2 - pixw / 2,
- ir.y() + ir.height() / 2 - pixh / 2);
- } else {
- point = QPoint(ir.x() + 2, ir.y() + ir.height() / 2 - pixh / 2);
- }
- if (btn->direction == Qt::RightToLeft)
- point.rx() += pixw;
-
- if ((btn->state & (State_On | State_Sunken)) && btn->direction == Qt::RightToLeft)
- point.rx() -= pixelMetric(PM_ButtonShiftHorizontal, option, widget) * 2;
-
- painter->drawPixmap(visualPos(btn->direction, btn->rect, point), pixmap);
-
- if (btn->direction == Qt::RightToLeft)
- ir.translate(-4, 0);
- else
- ir.translate(pixw + 4, 0);
- ir.setWidth(ir.width() - (pixw + 4));
- // left-align text if there is
- if (!btn->text.isEmpty())
- tf |= Qt::AlignLeft;
- } else {
- tf |= Qt::AlignHCenter;
- }
- drawItemText(painter, ir, tf, btn->palette, (btn->state & State_Enabled),
- btn->text, QPalette::ButtonText);
- painter->restore();
- }
- break;
- default:
- QWindowsStyle::drawControl(element, option, painter, widget);
- break;
- }
-}
-
-void QWindowsCEStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
- QPainter *painter, const QWidget *widget) const {
- switch (control) {
- #ifndef QT_NO_SLIDER
- case CC_Slider:
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
- int thickness = pixelMetric(PM_SliderControlThickness, slider, widget);
- int len = pixelMetric(PM_SliderLength, slider, widget);
- int ticks = slider->tickPosition;
- QRect groove = subControlRect(CC_Slider, slider, SC_SliderGroove, widget);
- QRect handle = subControlRect(CC_Slider, slider, SC_SliderHandle, widget);
-
- if ((slider->subControls & SC_SliderGroove) && groove.isValid()) {
- int mid = thickness / 2;
- if (ticks & QSlider::TicksAbove)
- mid += len / 8;
- if (ticks & QSlider::TicksBelow)
- mid -= len / 8;
-
- painter->setPen(slider->palette.shadow().color());
- if (slider->orientation == Qt::Horizontal) {
- QWindowsCEStylePrivate::drawWinCEPanel(painter, groove.x(), groove.y() + mid - 2,
- groove.width(), 4, option->palette, true);
- painter->drawLine(groove.x() + 1, groove.y() + mid - 1,
- groove.x() + groove.width() - 3, groove.y() + mid - 1);
- } else {
- QWindowsCEStylePrivate::drawWinCEPanel(painter, groove.x() + mid - 2, groove.y(),
- 4, groove.height(), option->palette, true);
- painter->drawLine(groove.x() + mid - 1, groove.y() + 1,
- groove.x() + mid - 1, groove.y() + groove.height() - 3);
- }
- }
- if (slider->subControls & SC_SliderTickmarks) {
- QStyleOptionSlider tmpSlider = *slider;
- tmpSlider.subControls = SC_SliderTickmarks;
- QCommonStyle::drawComplexControl(control, &tmpSlider, painter, widget);
- }
-
- if (slider->subControls & SC_SliderHandle) {
- // 4444440
- // 4333310
- // 4322210
- // 4322210
- // 4322210
- // 4322210
- // *43210*
- // **440**
- // ***0***
- const QColor c0 = slider->palette.shadow().color();
- const QColor c1 = slider->palette.dark().color();
- // const QColor c2 = g.button();
- const QColor c3 = slider->palette.midlight().color();
- const QColor c4 = slider->palette.dark().color();
- QBrush handleBrush;
-
- if (slider->state & State_Enabled) {
- handleBrush = slider->palette.color(QPalette::Button);
- } else {
- handleBrush = QBrush(slider->palette.color(QPalette::Button),
- Qt::Dense4Pattern);
- }
-
- int x = handle.x(), y = handle.y(),
- wi = handle.width(), he = handle.height();
-
- int x1 = x;
- int x2 = x + wi - 1;
- int y1 = y;
- int y2 = y + he - 1;
-
- Qt::Orientation orient = slider->orientation;
- bool tickAbove = slider->tickPosition == QSlider::TicksAbove;
- bool tickBelow = slider->tickPosition == QSlider::TicksBelow;
-
- if (slider->state & State_HasFocus) {
- QStyleOptionFocusRect fropt;
- fropt.QStyleOption::operator=(*slider);
- fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget);
- drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
- }
- if ((tickAbove && tickBelow) || (!tickAbove && !tickBelow)) {
- Qt::BGMode oldMode = painter->backgroundMode();
- painter->setBackgroundMode(Qt::OpaqueMode);
- QWindowsCEStylePrivate::drawWinCEButton(painter, QRect(x, y, wi, he), slider->palette, false,
- &handleBrush);
- painter->setBackgroundMode(oldMode);
- QBrush fill = QBrush(option->palette.light().color(), Qt::Dense4Pattern);
- if (slider->state & State_Sunken)
- painter->fillRect(QRectF(x1 + 2, y1 + 2, x2 - x1 - 3, y2 - y1 - 3),fill);
- return;
- }
- QSliderDirection dir;
- if (orient == Qt::Horizontal)
- if (tickAbove)
- dir = SlUp;
- else
- dir = SlDown;
- else
- if (tickAbove)
- dir = SlLeft;
- else
- dir = SlRight;
- QPolygon a;
- int d = 0;
- switch (dir) {
- case SlUp:
- x2++;
- y1 = y1 + wi / 2;
- d = (wi + 1) / 2 - 1;
- a.setPoints(5, x1, y1, x1, y2, x2, y2, x2, y1, x1 + d, y1 - d);
- break;
- case SlDown:
- x2++;
- y2 = y2 - wi / 2;
- d = (wi + 1) / 2 - 1;
- a.setPoints(5, x1, y1, x1, y2, x1 + d, y2+d, x2, y2, x2, y1);
- break;
- case SlLeft:
- d = (he + 1) / 2 - 1;
- x1 = x1 + he / 2;
- a.setPoints(5, x1, y1, x1 - d, y1 + d, x1, y2, x2, y2, x2, y1);
- y1--;
- break;
- case SlRight:
- d = (he + 1) / 2 - 1;
- x2 = x2 - he / 2;
- a.setPoints(5, x1, y1, x1, y2, x2, y2, x2 + d, y1 + d, x2, y1);
- y1--;
- break;
- }
- QBrush oldBrush = painter->brush();
- painter->setPen(Qt::NoPen);
- painter->setBrush(handleBrush);
- Qt::BGMode oldMode = painter->backgroundMode();
- painter->setBackgroundMode(Qt::OpaqueMode);
- painter->drawRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
- painter->drawPolygon(a);
- QBrush fill = QBrush(option->palette.light().color(), Qt::Dense4Pattern);
- if (slider->state & State_Sunken)
- painter->fillRect(QRectF(x1, y1, x2 - x1 + 1, y2 - y1 + 1),fill);
- painter->setBrush(oldBrush);
- painter->setBackgroundMode(oldMode);
-
- if (dir != SlUp) {
- painter->setPen(c4);
- painter->drawLine(x1, y1, x2, y1);
- painter->setPen(c3);
- painter->drawLine(x1, y1 + 1, x2, y1 + 1);
- }
- if (dir != SlLeft) {
- painter->setPen(c3);
- painter->drawLine(x1 + 1, y1 + 1, x1 + 1, y2);
- painter->setPen(c4);
- painter->drawLine(x1, y1, x1, y2);
- }
- if (dir != SlRight) {
- painter->setPen(c0);
- painter->drawLine(x2, y1, x2, y2);
- painter->setPen(c1);
- painter->drawLine(x2 - 1, y1 + 1, x2 - 1, y2 - 1);
- }
- if (dir != SlDown) {
- painter->setPen(c0);
- painter->drawLine(x1, y2, x2, y2);
- painter->setPen(c1);
- painter->drawLine(x1+1, y2 - 1, x2 - 1, y2 - 1);
- }
-
- switch (dir) {
- case SlUp:
- if (slider->state & State_Sunken)
- painter->fillRect(QRectF(x1 + 3, y1 - d + 2, x2 - x1 - 4,y1), fill);
- painter->setPen(c4);
- painter->drawLine(x1, y1, x1 + d, y1 - d);
- painter->setPen(c0);
- d = wi - d - 1;
- painter->drawLine(x2, y1, x2 - d, y1 - d);
- d--;
- painter->setPen(c3);
- painter->drawLine(x1 + 1, y1, x1 + 1 + d-1, y1 - d + 1);
- painter->setPen(c1);
- painter->drawLine(x2 - 1, y1, x2-1 - d, y1 - d);
- break;
- case SlDown:
- if (slider->state & State_Sunken)
- painter->fillRect(QRectF(x1 + 3, y2 - d, x2 - x1 - 4,y2 - 8), fill);
- painter->setPen(c4);
- painter->drawLine(x1, y2, x1 + d, y2 + d);
- painter->setPen(c0);
- d = wi - d - 1;
- painter->drawLine(x2, y2, x2 - d, y2 + d);
- d--;
- painter->setPen(c3);
- painter->drawLine(x1 + 1, y2, x1 + 1 + d - 1, y2 + d - 1);
- painter->setPen(c1);
- painter->drawLine(x2 - 1, y2, x2 - 1 - d, y2 + d);
- break;
- case SlLeft:
- if (slider->state & State_Sunken)
- painter->fillRect(QRectF(x1 - d + 2, y1 + 2, x1,y2 - y1 - 3), fill);
- painter->setPen(c4);
- painter->drawLine(x1, y1, x1 - d, y1 + d);
- painter->setPen(c0);
- d = he - d - 1;
- painter->drawLine(x1, y2, x1 - d, y2 - d);
- d--;
- painter->setPen(c3);
- painter->drawLine(x1, y1 + 1, x1 - d + 1, y1 + 1 + d - 1);
- painter->setPen(c1);
- painter->drawLine(x1, y2 - 1, x1 - d, y2 - 1 - d);
- break;
- case SlRight:
- if (slider->state & State_Sunken)
- painter->fillRect(QRectF(x2 - d - 4, y1 + 2, x2 - 4, y2 - y1 - 3), fill);
- painter->setPen(c4);
- painter->drawLine(x2, y1, x2 + d, y1 + d);
- painter->setPen(c0);
- d = he - d - 1;
- painter->drawLine(x2, y2, x2 + d, y2 - d);
- d--;
- painter->setPen(c3);
- painter->drawLine(x2, y1 + 1, x2 + d - 1, y1 + 1 + d - 1);
- painter->setPen(c1);
- painter->drawLine(x2, y2 - 1, x2 + d, y2 - 1 - d);
- break;
- }
- }
- }
- break;
-#endif // QT_NO_SLIDER
- case CC_ToolButton:
- if (const QStyleOptionToolButton *toolbutton
- = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
- QRect button, menuarea;
-
-#ifndef QT_NO_TOOLBAR
- bool flat = !(widget ? qobject_cast<QToolBar*>(widget->parentWidget()) : 0);
-#else
- bool flat = true;
-#endif
-
- button = subControlRect(control, toolbutton, SC_ToolButton, widget);
- menuarea = subControlRect(control, toolbutton, SC_ToolButtonMenu, widget);
-
- if (flat && (toolbutton->subControls & SC_ToolButtonMenu)) {
- menuarea.setLeft(menuarea.left() - 4);
- button.setRight(button.right() - 4);
- }
-
- State bflags = toolbutton->state;
-
- if (bflags & State_AutoRaise)
- if (!(bflags & State_MouseOver)) {
- bflags &= ~State_Raised;
- }
- State mflags = bflags;
-
- if (toolbutton->activeSubControls & SC_ToolButton)
- bflags |= State_Sunken;
- if (toolbutton->activeSubControls & SC_ToolButtonMenu)
- mflags |= State_Sunken;
-
- QStyleOption tool = *toolbutton;
- if (toolbutton->subControls & SC_ToolButton) {
- tool.rect = button;
- tool.state = bflags;
- drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
- }
-
- if (toolbutton->subControls & SC_ToolButtonMenu) {
- tool.rect = menuarea;
- tool.state = mflags;
- tool.state = bflags;
- drawPrimitive(PE_IndicatorButtonDropDown, &tool, painter, widget);
-
- if (!flat) {
-
- //connect buttons
- painter->save();
- painter->setPen(tool.palette.button().color());
- painter->drawLine(tool.rect.x() - 2, tool.rect.y(), tool.rect.x() - 2, tool.rect.y() + tool.rect.height());
- painter->drawLine(tool.rect.x() - 1, tool.rect.y(), tool.rect.x() - 1, tool.rect.y() + tool.rect.height());
- painter->drawLine(tool.rect.x(), tool.rect.y(), tool.rect.x(), tool.rect.y() + tool.rect.height());
- painter->drawLine(tool.rect.x() + 1, tool.rect.y(), tool.rect.x() + 1, tool.rect.y() + tool.rect.height());
-
- if (tool.state & State_Sunken)
- {
- painter->setPen(tool.palette.midlight().color());
- painter->drawLine(tool.rect.x() - 2, tool.rect.y() + tool.rect.height() - 2,
- tool.rect.x() + 1, tool.rect.y() + tool.rect.height() -2 );
- painter->setPen(tool.palette.shadow().color());
- painter->drawLine(tool.rect.x() - 2, tool.rect.y() + 1,tool.rect.x() + 1, tool.rect.y() + 1);
- painter->drawLine(tool.rect.x() - 2, tool.rect.y(), tool.rect.x() + 1, tool.rect.y());
- painter->setPen(tool.palette.light().color());
- painter->drawLine(tool.rect.x() - 2, tool.rect.y() + tool.rect.height() - 1,
- tool.rect.x() + 1, tool.rect.y() + tool.rect.height() - 1);
- }
- else
- {
- painter->setPen(tool.palette.dark().color());
- painter->drawLine(tool.rect.x() - 2, tool.rect.y(),tool.rect.x() + 1, tool.rect.y());
- painter->drawLine(tool.rect.x() - 2, tool.rect.y()+tool.rect.height() - 2,tool.rect.x() + 1,
- tool.rect.y() + tool.rect.height() - 2);
- painter->setPen(tool.palette.midlight().color());
- painter->drawLine(tool.rect.x() - 2, tool.rect.y() + 1,tool.rect.x() + 1, tool.rect.y() + 1);
- painter->setPen(tool.palette.shadow().color());
- painter->drawLine(tool.rect.x() - 2, tool.rect.y() + tool.rect.height() - 1,
- tool.rect.x() + 1, tool.rect.y() + tool.rect.height() - 1);
- }
- painter->restore();
- }
-
-
- if (!flat) {
- tool.rect.adjust(-3,0,-3,0);
- painter->save();
- painter->setPen(tool.palette.button().color());
- if (tool.state & State_Sunken)
- painter->drawLine(tool.rect.x() + 2, tool.rect.y() + 10,
- tool.rect.x() + tool.rect.width(), tool.rect.y() + 10);
- else
- painter->drawLine(tool.rect.x() + 1, tool.rect.y() + 9, tool.rect.x() +
- tool.rect.width() - 1, tool.rect.y() + 9);
- painter->restore();
- } else {
- tool.rect.adjust(-1,0,-1,0);
- }
-
- drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget);
- }
-
- if (toolbutton->state & State_HasFocus) {
- QStyleOptionFocusRect fr;
- fr.QStyleOption::operator=(*toolbutton);
- fr.rect.adjust(3, 3, -3, -3);
- if (toolbutton->features & QStyleOptionToolButton::Menu)
- fr.rect.adjust(0, 0, -pixelMetric(QStyle::PM_MenuButtonIndicator,
- toolbutton, widget), 0);
- drawPrimitive(PE_FrameFocusRect, &fr, painter, widget);
- }
- QStyleOptionToolButton label = *toolbutton;
- int fw = pixelMetric(PM_DefaultFrameWidth, option, widget);
- label.rect = button.adjusted(fw, fw, -fw, -fw);
- drawControl(CE_ToolButtonLabel, &label, painter, widget);
- }
- break;
-
-#ifndef QT_NO_GROUPBOX
- case CC_GroupBox:
- if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
- // Draw frame
- painter->save();
- QFont f = painter->font();
- f.setBold(true);
- painter->setFont(f);
- QStyleOptionGroupBox groupBoxFont = *groupBox;
- groupBoxFont.fontMetrics = QFontMetrics(f);
- QRect textRect = subControlRect(CC_GroupBox, &groupBoxFont, SC_GroupBoxLabel, widget);
- QRect checkBoxRect = subControlRect(CC_GroupBox, option, SC_GroupBoxCheckBox, widget);
- if (groupBox->subControls & QStyle::SC_GroupBoxFrame) {
- QStyleOptionFrame frame;
- frame.QStyleOption::operator=(*groupBox);
- frame.features = groupBox->features;
- frame.lineWidth = groupBox->lineWidth;
- frame.midLineWidth = groupBox->midLineWidth;
- frame.rect = subControlRect(CC_GroupBox, option, SC_GroupBoxFrame, widget);
- painter->save();
-
- QRegion region(groupBox->rect);
- if (!groupBox->text.isEmpty()) {
- bool ltr = groupBox->direction == Qt::LeftToRight;
- QRect finalRect = checkBoxRect.united(textRect);
- if (groupBox->subControls & QStyle::SC_GroupBoxCheckBox)
- finalRect.adjust(ltr ? -4 : 0, 0, ltr ? 0 : 4, 0);
- region -= finalRect;
- }
- painter->setClipRegion(region);
- drawPrimitive(PE_FrameGroupBox, &frame, painter, widget);
- painter->restore();
- }
-
- // Draw title
- if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {
- QColor textColor = groupBox->textColor;
- if (textColor.isValid())
- painter->setPen(textColor);
- int alignment = int(groupBox->textAlignment);
- if (!styleHint(QStyle::SH_UnderlineShortcut, option, widget))
- alignment |= Qt::TextHideMnemonic;
-
- drawItemText(painter, textRect, Qt::TextShowMnemonic | Qt::AlignHCenter | alignment,
- groupBox->palette, groupBox->state & State_Enabled, groupBox->text,
- textColor.isValid() ? QPalette::NoRole : QPalette::WindowText);
-
- if (groupBox->state & State_HasFocus) {
- QStyleOptionFocusRect fropt;
- fropt.QStyleOption::operator=(*groupBox);
- fropt.rect = textRect;
- drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
- }
- }
- // Draw checkbox
- if (groupBox->subControls & SC_GroupBoxCheckBox) {
- QStyleOptionButton box;
- box.QStyleOption::operator=(*groupBox);
- box.rect = checkBoxRect;
- drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget);
- }
- painter->restore();
- }
- break;
-#endif //QT_NO_GROUPBOX
-#ifndef QT_NO_COMBOBOX
- case CC_ComboBox:
- if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
- QBrush editBrush = cmb->palette.brush(QPalette::Base);
- if ((cmb->subControls & SC_ComboBoxFrame) && cmb->frame)
- QWindowsCEStylePrivate::drawWinCEPanel(painter, option->rect, option->palette, true, &editBrush);
- else
- painter->fillRect(option->rect, editBrush);
-
- if (cmb->subControls & SC_ComboBoxArrow) {
- State flags = State_None;
-
- QRect ar = subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget);
- if (cmb->activeSubControls == SC_ComboBoxArrow) {
- painter->setPen(cmb->palette.dark().color());
- painter->setBrush(cmb->palette.brush(QPalette::Button));
- painter->drawRect(ar.adjusted(0, 0, -1, -1));
- QWindowsCEStylePrivate::drawWinCEButton(painter, ar.adjusted(0, 0, -1, -1), option->palette, true,
- &cmb->palette.brush(QPalette::Button));
- } else {
- // Make qDrawWinButton use the right colors for drawing the shade of the button
-
- QWindowsCEStylePrivate::drawWinCEButton(painter, ar, option->palette, false,
- &cmb->palette.brush(QPalette::Button));
- }
-
- ar.adjust(2, 2, -2, -2);
- if (option->state & State_Enabled)
- flags |= State_Enabled;
-
- if (cmb->activeSubControls == SC_ComboBoxArrow)
- flags |= State_Sunken;
- QStyleOption arrowOpt = *cmb;
- arrowOpt.rect = ar;
- arrowOpt.state = flags;
- drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget);
- }
- if (cmb->subControls & SC_ComboBoxEditField) {
- QRect re = subControlRect(CC_ComboBox, cmb, SC_ComboBoxEditField, widget);
- if (cmb->state & State_HasFocus && !cmb->editable)
- painter->fillRect(re.x(), re.y(), re.width(), re.height(),
- cmb->palette.brush(QPalette::Highlight));
- if (cmb->state & State_HasFocus) {
- painter->setPen(cmb->palette.highlightedText().color());
- painter->setBackground(cmb->palette.highlight());
- } else {
- painter->setPen(cmb->palette.text().color());
- painter->setBackground(cmb->palette.background());
- }
- if (cmb->state & State_HasFocus && !cmb->editable) {
- QStyleOptionFocusRect focus;
- focus.QStyleOption::operator=(*cmb);
- focus.rect = subElementRect(SE_ComboBoxFocusRect, cmb, widget);
- focus.state |= State_FocusAtBorder;
- focus.backgroundColor = cmb->palette.highlight().color();
- drawPrimitive(PE_FrameFocusRect, &focus, painter, widget);
- }
- }
- }
- break;
-#endif // QT_NO_COMBOBOX
-#ifndef QT_NO_SPINBOX
- case CC_SpinBox:
- if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
- QStyleOptionSpinBox copy = *sb;
- PrimitiveElement pe;
-
- if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) {
- QRect r = subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget);
- QWindowsCEStylePrivate::drawWinCEPanel(painter, r, option->palette, true);
- }
- QPalette shadePal(option->palette);
- shadePal.setColor(QPalette::Button, option->palette.light().color());
- shadePal.setColor(QPalette::Light, option->palette.button().color());
-
- bool reverse = QApplication::layoutDirection() == Qt::RightToLeft;
-
- if (sb->subControls & SC_SpinBoxUp) {
- copy.subControls = SC_SpinBoxUp;
- QPalette pal2 = sb->palette;
- if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
- pal2.setCurrentColorGroup(QPalette::Disabled);
- copy.state &= ~State_Enabled;
- }
- copy.palette = pal2;
- if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken)) {
- copy.state |= State_On;
- copy.state |= State_Sunken;
- } else {
- copy.state |= State_Raised;
- copy.state &= ~State_Sunken;
- }
- if (reverse)
- pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
- : PE_IndicatorSpinDown);
- else
- pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
- : PE_IndicatorSpinUp);
- copy.rect = subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget);
- QWindowsCEStylePrivate::drawWinCEButton(painter, copy.rect, option->palette, copy.state & (State_Sunken | State_On),
- &copy.palette.brush(QPalette::Button));
- copy.rect.adjust(3, 0, -4, 0);
- drawPrimitive(pe, &copy, painter, widget);
- }
- if (sb->subControls & SC_SpinBoxDown) {
- copy.subControls = SC_SpinBoxDown;
- copy.state = sb->state;
- QPalette pal2 = sb->palette;
- if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
- pal2.setCurrentColorGroup(QPalette::Disabled);
- copy.state &= ~State_Enabled;
- }
- copy.palette = pal2;
-
- if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken)) {
- copy.state |= State_On;
- copy.state |= State_Sunken;
- } else {
- copy.state |= State_Raised;
- copy.state &= ~State_Sunken;
- }
- if (reverse)
- pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
- : PE_IndicatorSpinUp);
- else
- pe = (sb->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
- : PE_IndicatorSpinDown);
- copy.rect = subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget);
- QWindowsCEStylePrivate::drawWinCEButton(painter, copy.rect, shadePal, copy.state & (State_Sunken | State_On),
- &copy.palette.brush(QPalette::Button));
-
- copy.rect.adjust(3, 0, -4, 0);
- if (pe == PE_IndicatorArrowUp || pe == PE_IndicatorArrowDown) {
- copy.rect = copy.rect.adjusted(1, 1, -1, -1);
- drawPrimitive(pe, &copy, painter, widget);
- }
- else {
- drawPrimitive(pe, &copy, painter, widget);
- }
- if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) {
- QRect r = subControlRect(CC_SpinBox, sb, SC_SpinBoxEditField, widget);
- painter->save();
- painter->setPen(option->palette.light().color());
- painter->drawLine(r.x() + 1 + r.width(), r.y() - 2, r.x() + 1 + r.width(), r.y() + r.height() + 1);
- painter->setPen(option->palette.midlight().color());
- painter->drawLine(r.x() + r.width(), r.y() - 1, r.x() + r.width(), r.y() + r.height());
- painter->restore();
- }
- }
- }
- break;
-#endif // QT_NO_SPINBOX
-
- default:
- QWindowsStyle::drawComplexControl(control, option, painter, widget);
- break;
- }
-}
-
-void QWindowsCEStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal,
- bool enabled, const QString& text, QPalette::ColorRole textRole) const {
- if (text.isEmpty())
- return;
- QPen savedPen;
- if (textRole != QPalette::NoRole) {
- savedPen = painter->pen();
- painter->setPen(pal.color(textRole));
- }
- if (!enabled) {
- QPen pen = painter->pen();
- painter->setPen(pal.light().color());
- //painter->drawText(rect.adjusted(1, 1, 1, 1), alignment, text);
- painter->setPen(pen);
- }
- painter->drawText(rect, alignment, text);
- if (textRole != QPalette::NoRole)
- painter->setPen(savedPen);
-}
-
-
-QSize QWindowsCEStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
- const QSize &size, const QWidget *widget) const {
- QSize newSize = QWindowsStyle::sizeFromContents(type, option, size, widget);
- switch (type) {
- case CT_PushButton:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- newSize = QWindowsStyle::sizeFromContents(type, option, size, widget);
- int w = newSize.width(),
- h = newSize.height();
- int defwidth = 0;
- if (btn->features & QStyleOptionButton::AutoDefaultButton)
- defwidth = 2 * pixelMetric(PM_ButtonDefaultIndicator, btn, widget);
- if (w < 75 + defwidth && btn->icon.isNull())
- w = 75 + defwidth;
- if (h < 23 + defwidth)
- h = 23 + defwidth;
- newSize = QSize(w+14, h);
- }
- break;
-
- case CT_RadioButton:
- case CT_CheckBox:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- bool isRadio = (type == CT_RadioButton);
- QRect irect = visualRect(btn->direction, btn->rect,
- subElementRect(isRadio ? SE_RadioButtonIndicator
- : SE_CheckBoxIndicator, btn, widget));
- int h = pixelMetric(isRadio ? PM_ExclusiveIndicatorHeight
- : PM_IndicatorHeight, btn, widget);
- int margins = (!btn->icon.isNull() && btn->text.isEmpty()) ? 0 : 10;
- newSize += QSize(irect.right() + margins, 4);
- newSize.setHeight(qMax(newSize.height(), h));
- }
- break;
- case CT_ComboBox:
- if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
- int fw = cmb->frame ? pixelMetric(PM_ComboBoxFrameWidth, option, widget) * 2 : 0;
- newSize = QSize(newSize.width() + fw -1, qMax(24, newSize.height() + fw-1));
- }
- break;
-#ifndef QT_NO_SPINBOX
- case CT_SpinBox:
- if (const QStyleOptionSpinBox *spnb = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
- int fw = spnb->frame ? pixelMetric(PM_SpinBoxFrameWidth, option, widget) * 2 : 0;
- newSize = QSize(newSize.width() + fw - 5, newSize.height() + fw - 6);
- }
- break;
-#endif
- case CT_LineEdit:
- newSize += QSize(0,1);
- break;
- case CT_MenuBarItem:
- newSize += QSize(5, 1);
- break;
- case CT_MenuItem:
- newSize += QSize(0, -2);
- break;
- case CT_MenuBar:
- newSize += QSize(0, -1);
- break;
- case CT_ToolButton:
- if (const QStyleOptionToolButton *b = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
- if (b->toolButtonStyle != Qt::ToolButtonIconOnly)
- newSize = QSize(newSize.width() + 1, newSize.height() - 1);
- else
- newSize = QSize(newSize.width() + 1, newSize.height());
- }
- break;
-
- default:
- break;
- }
- return newSize;
-}
-
-QRect QWindowsCEStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const {
- QRect rect = QWindowsStyle::subElementRect(element, option, widget);
- switch (element) {
-#ifndef QT_NO_COMBOBOX
- case SE_ComboBoxFocusRect:
- if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
- int margin = cb->frame ? 3 : 0;
- rect.setRect(margin, margin, option->rect.width() - 2*margin - 20, option->rect.height() - 2*margin);
- rect = visualRect(option->direction, option->rect, rect);
- }
- break;
-#endif // QT_NO_COMBOBOX
- default:
- break;
- }
- return rect;
-}
-
-QRect QWindowsCEStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option,
- SubControl subControl, const QWidget *widget) const {
- QRect rect = QWindowsStyle::subControlRect(control, option, subControl, widget);
- switch (control) {
-#ifndef QT_NO_SLIDER
- case CC_Slider:
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
- int tickOffset = pixelMetric(PM_SliderTickmarkOffset, slider, widget);
- int thickness = pixelMetric(PM_SliderControlThickness, slider, widget);
-
- switch (subControl) {
- case SC_SliderHandle: {
- int sliderPos = 0;
- int len = pixelMetric(PM_SliderLength, slider, widget);
- bool horizontal = slider->orientation == Qt::Horizontal;
- sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum,
- slider->sliderPosition,
- (horizontal ? slider->rect.width()
- : slider->rect.height()) - len,
- slider->upsideDown);
- if (horizontal)
- rect.setRect(slider->rect.x() + sliderPos, slider->rect.y() + tickOffset, len, thickness);
- else
- rect.setRect(slider->rect.x() + tickOffset, slider->rect.y() + sliderPos, thickness, len);
- break; }
- default:
- break;
- }
- rect = visualRect(slider->direction, slider->rect, rect);
- }
- break;
-#endif //QT_NO_SLIDER
-#ifndef QT_NO_COMBOBOX
- case CC_ComboBox:
- if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
- int x = cb->rect.x(),
- y = cb->rect.y(),
- wi = cb->rect.width(),
- he = cb->rect.height();
- int xpos = x;
- int margin = cb->frame ? 3 : 0;
- int bmarg = cb->frame ? 2 : 0;
- xpos += wi - (he - 2*bmarg) - bmarg;
- switch (subControl) {
- case SC_ComboBoxArrow:
- rect.setRect(xpos, y + bmarg, he - 2*bmarg, he - 2*bmarg);
- break;
- case SC_ComboBoxEditField:
- rect.setRect(x + margin, y + margin, wi - 2 * margin - (he - 2*bmarg), he - 2 * margin);
- break;
- case SC_ComboBoxListBoxPopup:
- rect = cb->rect;
- break;
- case SC_ComboBoxFrame:
- rect = cb->rect;
- break;
- default:
- break;
- }
- rect = visualRect(cb->direction, cb->rect, rect);
- }
-#endif //QT_NO_COMBOBOX
-#ifndef QT_NO_SPINBOX
- case CC_SpinBox:
- if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
- QSize bs;
- int fw = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0;
- bs.setWidth(qMax(18, (spinbox->rect.height() / 2 - fw + 1)));
- // 1.6 -approximate golden mean
- bs.setHeight(qMax(18, qMin((bs.height() * 8 / 5), (spinbox->rect.width() / 4))));
- bs = bs.expandedTo(QApplication::globalStrut());
- int y = fw;
- int x, lx, rx;
- x = spinbox->rect.width() - y - bs.width() * 2;
- lx = fw;
- rx = x - fw;
- switch (subControl) {
- case SC_SpinBoxUp:
- rect = QRect(x + bs.width(), y, bs.width(), bs.height());
- break;
- case SC_SpinBoxDown:
- rect = QRect(x, y , bs.width(), bs.height());
- break;
- case SC_SpinBoxEditField:
- if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons) {
- rect = QRect(lx, fw, spinbox->rect.width() - 2*fw - 2, spinbox->rect.height() - 2*fw);
- } else {
- rect = QRect(lx, fw, rx-2, spinbox->rect.height() - 2*fw);
- }
- break;
- case SC_SpinBoxFrame:
- rect = spinbox->rect;
- default:
- break;
- }
- rect = visualRect(spinbox->direction, spinbox->rect, rect);
- }
- break;
-#endif // Qt_NO_SPINBOX
-#ifndef QT_NO_GROUPBOX
- case CC_GroupBox: {
- if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
- switch (subControl) {
- case SC_GroupBoxFrame:
- // FALL THROUGH
- case SC_GroupBoxContents: {
- int topMargin = 0;
- int topHeight = 0;
- int bottomMargin = 0;
- int noLabelMargin = 0;
- QRect frameRect = groupBox->rect;
- int verticalAlignment = styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget);
- if (groupBox->text.size()) {
- topHeight = groupBox->fontMetrics.height();
- if (verticalAlignment & Qt::AlignVCenter)
- topMargin = topHeight / 2;
- else if (verticalAlignment & Qt::AlignTop)
- topMargin = -topHeight/2;
- }
- else {
- topHeight = groupBox->fontMetrics.height();
- noLabelMargin = topHeight / 2;
- if (verticalAlignment & Qt::AlignVCenter) {
- topMargin = topHeight / 4 - 4;
- bottomMargin = topHeight / 4 - 4;
- }
- else if (verticalAlignment & Qt::AlignTop) {
- topMargin = topHeight/2 - 4;
- bottomMargin = topHeight/2 - 4;
- }
- }
-
- if (subControl == SC_GroupBoxFrame) {
- frameRect.setTop(topMargin);
- frameRect.setBottom(frameRect.height() + bottomMargin);
- rect = frameRect;
- break;
- }
-
- int frameWidth = 0;
- if ((groupBox->features & QStyleOptionFrame::Flat) == 0)
- frameWidth = pixelMetric(PM_DefaultFrameWidth, groupBox, widget);
- rect = frameRect.adjusted(frameWidth, frameWidth + topHeight, -frameWidth, -frameWidth - noLabelMargin);
- break;
- }
- case SC_GroupBoxCheckBox:
- // FALL THROUGH
- case SC_GroupBoxLabel: {
- QFontMetrics fontMetrics = groupBox->fontMetrics;
- int h = fontMetrics.height();
- int tw = fontMetrics.size(Qt::TextShowMnemonic, groupBox->text + QLatin1Char(' ')).width();
- const int marg = (groupBox->features & QStyleOptionFrame::Flat) ? 0 : 8;
- rect = groupBox->rect.adjusted(marg, 0, -marg, 0);
- rect.setHeight(h);
-
- int indicatorWidth = pixelMetric(PM_IndicatorWidth, option, widget);
- int indicatorSpace = pixelMetric(PM_CheckBoxLabelSpacing, option, widget) - 1;
- bool hasCheckBox = groupBox->subControls & QStyle::SC_GroupBoxCheckBox;
- int checkBoxSize = hasCheckBox ? (indicatorWidth + indicatorSpace) : 0;
-
- // Adjusted rect for label + indicatorWidth + indicatorSpace
- QRect totalRect = alignedRect(groupBox->direction, groupBox->textAlignment,
- QSize(tw + checkBoxSize, h), rect);
-
- // Adjust totalRect if checkbox is set
- if (hasCheckBox) {
- bool ltr = groupBox->direction == Qt::LeftToRight;
- int left = 0;
- // Adjust for check box
- if (subControl == SC_GroupBoxCheckBox) {
- int indicatorHeight = pixelMetric(PM_IndicatorHeight, option, widget);
- left = ltr ? totalRect.left() : (totalRect.right() - indicatorWidth);
- int top = totalRect.top() + (fontMetrics.height() - indicatorHeight) / 2;
- totalRect.setRect(left, top, indicatorWidth, indicatorHeight);
- // Adjust for label
- } else {
- left = ltr ? (totalRect.left() + checkBoxSize - 2) : totalRect.left();
- totalRect.setRect(left, totalRect.top(),
- totalRect.width() - checkBoxSize, totalRect.height());
- }
- }
- rect = totalRect;
- break;
- }
- default:
- break;
- }
- }
- break;
- }
-#endif // QT_NO_GROUPBOX
- default:
- break;
- }
- return rect;
-}
-
-QStyle::SubControl QWindowsCEStyle::hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option,
- const QPoint &pos, const QWidget *widget) const {
- /*switch (control) {
- default:
- break;
- }*/
- return QWindowsStyle::hitTestComplexControl(control, option, pos, widget);
-}
-
-
-QPalette QWindowsCEStyle::standardPalette() const {
- QPalette palette (Qt::black,QColor(198, 195, 198), QColor(222, 223, 222 ),
- QColor(132, 130, 132), QColor(198, 195, 198) , Qt::black, Qt::white, Qt::white, QColor(198, 195, 198));
- palette.setColor(QPalette::Window, QColor(198, 195, 198));
- palette.setColor(QPalette::Base, Qt::white);
- palette.setColor(QPalette::Button, QColor(198, 195, 198));
- palette.setColor(QPalette::Highlight, QColor(0, 0, 132));
- palette.setColor(QPalette::Light, Qt::white);
- palette.setColor(QPalette::Midlight, QColor(222, 223, 222 ));
- palette.setColor(QPalette::Dark, QColor(132, 130, 132));
- palette.setColor(QPalette::Mid, QColor(132, 130, 132));
- palette.setColor(QPalette::Shadow, QColor(0, 0, 0));
- palette.setColor(QPalette::BrightText, QColor(33, 162, 33)); //color for ItemView checked indicator (arrow)
- palette.setColor(QPalette::Link, QColor(24,81,132)); // color for the box around the ItemView indicator
-
- return palette;
-}
-
-void QWindowsCEStyle::polish(QApplication *app) {
- QWindowsStyle::polish(app);
-}
-
-void QWindowsCEStyle::polish(QWidget *widget) {
- QWindowsStyle::polish(widget);
-}
-
-void QWindowsCEStyle::polish(QPalette &palette) {
- QWindowsStyle::polish(palette);
-}
-
-int QWindowsCEStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QWidget *widget) const {
- int ret;
-
- switch (pm) {
- case PM_DefaultFrameWidth:
- ret = 1;
- break;
-
- case PM_MenuBarHMargin:
- ret = 2;
- break;
- case PM_MenuBarVMargin:
- ret = 2;
- break;
- /*case PM_MenuBarItemSpacing:
- ret = 2;
- break;*/
-
- case PM_MenuButtonIndicator:
- ret = 10;
- break;
-
- case PM_SpinBoxFrameWidth:
- ret = 2;
- break;
- case PM_ButtonDefaultIndicator:
- case PM_ButtonShiftHorizontal:
- case PM_ButtonShiftVertical:
- ret = 1;
- break;
-#ifndef QT_NO_TABBAR
- case PM_TabBarTabShiftHorizontal:
- ret = 0;
- break;
- case PM_TabBarTabShiftVertical:
- ret = 6;
- break;
-#endif
- case PM_MaximumDragDistance:
- ret = 60;
- break;
-
- case PM_IndicatorWidth:
- ret = windowsCEIndicatorSize;
- break;
-
- case PM_IndicatorHeight:
- ret = windowsCEIndicatorSize;
- break;
-
- case PM_ExclusiveIndicatorWidth:
- ret = windowsCEExclusiveIndicatorSize;
- break;
-
- case PM_ExclusiveIndicatorHeight:
- ret = windowsCEExclusiveIndicatorSize;;
- break;
-
-#ifndef QT_NO_SLIDER
- case PM_SliderLength:
- ret = 12;
- break;
- case PM_SliderThickness:
- ret = windowsCESliderThickness;
- break;
-
- case PM_TabBarScrollButtonWidth:
- ret = 18;
- break;
-
- // Returns the number of pixels to use for the business part of the
- // slider (i.e., the non-tickmark portion). The remaining space is shared
- // equally between the tickmark regions.
- case PM_SliderControlThickness:
- if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
- int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height() : sl->rect.width();
- int ticks = sl->tickPosition;
- int n = 0;
- if (ticks & QSlider::TicksAbove)
- ++n;
- if (ticks & QSlider::TicksBelow)
- ++n;
- if (!n) {
- ret = space;
- break;
- }
- int thick = 12;
- if (ticks != QSlider::TicksBothSides && ticks != QSlider::NoTicks)
- thick += pixelMetric(PM_SliderLength, sl, widget) / 4;
-
- space -= thick;
- if (space > 0)
- thick += (space * 2) / (n + 2);
- ret = thick;
- } else {
- ret = 0;
- }
- break;
-#endif // QT_NO_SLIDER
-
-#ifndef QT_NO_MENU
-
- case PM_SmallIconSize:
- ret = windowsCEIconSize;
- break;
- case PM_ButtonMargin:
- ret = 6;
- break;
-
- case PM_LargeIconSize:
- ret = 32;
- break;
-
- case PM_IconViewIconSize:
- ret = pixelMetric(PM_LargeIconSize, opt, widget);
- break;
-
- case PM_ToolBarIconSize:
- ret = windowsCEIconSize;
- break;
- case PM_DockWidgetTitleMargin:
- ret = 2;
- break;
-#if defined(Q_DEAD_CODE_FROM_QT4_WIN)
-// case PM_DockWidgetFrameWidth:
-// ret = GetSystemMetrics(SM_CXFRAME);
-// break;
-#else
- case PM_DockWidgetFrameWidth:
- ret = 4;
- break;
-#endif // Q_DEAD_CODE_FROM_QT4_WIN
- break;
-
-#endif // QT_NO_MENU
-
- case PM_TitleBarHeight:
- ret = 30;
- break;
- case PM_ScrollBarExtent:
- ret = 19;
- break;
- case PM_SplitterWidth:
- ret = qMax(4, QApplication::globalStrut().width());
- break;
-
-#if defined(Q_DEAD_CODE_FROM_QT4_WIN)
- case PM_MDIFrameWidth:
- ret = 3;
- break;
-#endif
- case PM_ToolBarItemMargin:
- ret = 1;
- break;
- case PM_ToolBarItemSpacing:
- ret = 0;
- break;
- case PM_ToolBarHandleExtent:
- ret = 10;
- break;
- case PM_ButtonIconSize:
- ret = 22;
- break;
- default:
- ret = QWindowsStyle::pixelMetric(pm, opt, widget);
- break;
- }
- return ret;
-}
-
-QPixmap QWindowsCEStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
- const QWidget *widget) const {
-#ifndef QT_NO_IMAGEFORMAT_XPM
- /*switch (standardPixmap) {
-
- default:
- break;
- }*/
-#endif //QT_NO_IMAGEFORMAT_XPM
- return QWindowsStyle::standardPixmap(standardPixmap, opt, widget);
-}
-
-int QWindowsCEStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *widget,
- QStyleHintReturn *returnData) const {
- int ret;
- switch (hint) {
- case SH_TabBar_ElideMode:
- ret = Qt::ElideMiddle;
- break;
- case SH_EtchDisabledText:
- ret = false;
- break;
- case SH_RequestSoftwareInputPanel:
- ret = RSIP_OnMouseClick;
- break;
- default:
- ret = QWindowsStyle::styleHint(hint, opt, widget, returnData);
- break;
- }
- return ret;
-}
-
-void QWindowsCEStylePrivate::drawWinShades(QPainter *p,
- int x, int y, int w, int h,
- const QColor &c1, const QColor &c2,
- const QColor &c3, const QColor &c4,
- const QBrush *fill) {
- if (w < 2 || h < 2) // can't do anything with that
- return;
- QPen oldPen = p->pen();
- QPoint a[3] = { QPoint(x, y+h-2), QPoint(x, y), QPoint(x+w-2, y) };
- p->setPen(c1);
- p->drawPolyline(a, 3);
- QPoint b[3] = { QPoint(x, y+h-1), QPoint(x+w-1, y+h-1), QPoint(x+w-1, y) };
- p->setPen(c2);
- p->drawPolyline(b, 3);
- if (w > 4 && h > 4) {
- QPoint c[3] = { QPoint(x+1, y+h-3), QPoint(x+1, y+1), QPoint(x+w-3, y+1) };
- p->setPen(c3);
- p->drawPolyline(c, 3);
- QPoint d[3] = { QPoint(x+1, y+h-2), QPoint(x+w-2, y+h-2), QPoint(x+w-2, y+1) };
- p->setPen(c4);
- p->drawPolyline(d, 3);
- if (fill)
- p->fillRect(QRect(x+2, y+2, w-4, h-4), *fill);
- }
- p->setPen(oldPen);
-}
-
-void QWindowsCEStylePrivate::drawWinCEShades(QPainter *p,
- int x, int y, int w, int h,
- const QColor &c1, const QColor &c2,
- const QColor &c3, const QColor &c4,
- const QBrush *fill) {
- if (w < 2 || h < 2) // can't do anything with that
- return;
- QPen oldPen = p->pen();
- QPoint b[3] = { QPoint(x, y+h-1), QPoint(x+w-1, y+h-1), QPoint(x+w-1, y) };
- p->setPen(c2);
- p->drawPolyline(b, 3);
- if (w > 4 && h > 4) {
- QPoint c[3] = { QPoint(x+1, y+h-3), QPoint(x+1, y+1), QPoint(x+w-3, y+1) };
- p->setPen(c3);
- p->drawPolyline(c, 3);
- QPoint d[5] = { QPoint(x, y+h-2), QPoint(x+w-2, y+h-2), QPoint(x+w-2, y), QPoint(x, y), QPoint(x, y+h-2) };
- p->setPen(c4);
- p->drawPolyline(d, 5);
- if (fill)
- p->fillRect(QRect(x+2, y+2, w-4, h-4), *fill);
- }
- QPoint a[3] = { QPoint(x+1, y+h-3), QPoint(x+1, y+1), QPoint(x+w-3, y+1) };
- p->setPen(c1);
- p->drawPolyline(a, 3);
- p->setPen(oldPen);
-}
-
-void QWindowsCEStylePrivate::drawWinCEShadesSunken(QPainter *p,
- int x, int y, int w, int h,
- const QColor &c1, const QColor &c2,
- const QColor &c3, const QColor &c4,
- const QBrush *fill) {
- if (w < 2 || h < 2) // can't do anything with that
- return;
- QPen oldPen = p->pen();
-
- QPoint b[3] = { QPoint(x, y+h-1), QPoint(x+w-1, y+h-1), QPoint(x+w-1, y) };
- p->setPen(c2);
- p->drawPolyline(b, 3);
- if (w > 4 && h > 4) {
- QPoint d[3] = { QPoint(x, y+h-2), QPoint(x+w-2, y+h-2), QPoint(x+w-2, y) };
- p->setPen(c4);
- p->drawPolyline(d, 3);
- QPoint c[3] = { QPoint(x, y+h-2), QPoint(x, y), QPoint(x+w-2, y) };
- p->setPen(c3);
- p->drawPolyline(c, 3);
- if (fill)
- p->fillRect(QRect(x+2, y+2, w-4, h-4), *fill);
- }
- QPoint a[3] = { QPoint(x+1, y+h-3), QPoint(x+1, y+1), QPoint(x+w-3, y+1) };
- p->setPen(c1);
- p->drawPolyline(a, 3);
- p->setPen(oldPen);
-}
-
-
-void QWindowsCEStylePrivate::drawWinCEButton(QPainter *p, int x, int y, int w, int h,
- const QPalette &pal, bool sunken,
- const QBrush *fill) {
- if (sunken)
- drawWinCEShadesSunken(p, x, y, w, h,
- pal.shadow().color(), pal.light().color(), pal.shadow().color(),
- pal.midlight().color(), fill);
- else
- drawWinCEShades(p, x, y, w, h,
- pal.midlight().color(), pal.shadow().color(), pal.button().color(),
- pal.dark().color(), fill);
-}
-
-void QWindowsCEStylePrivate::drawWinCEPanel(QPainter *p, int x, int y, int w, int h,
- const QPalette &pal, bool sunken,
- const QBrush *fill) {
- if (sunken)
- drawWinShades(p, x, y, w, h,
- pal.dark().color(), pal.light().color(), pal.shadow().color(),
- pal.midlight().color(), fill);
- else
- drawWinShades(p, x, y, w, h,
- pal.light().color(), pal.shadow().color(), pal.button().color(),
- pal.midlight().color(), fill);
-}
-
-void QWindowsCEStylePrivate::drawWinCEButton(QPainter *p, const QRect &r,
- const QPalette &pal, bool sunken, const QBrush *fill) {
- drawWinCEButton(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill);
-}
-
-void QWindowsCEStylePrivate::drawWinCEPanel(QPainter *p, const QRect &r,
- const QPalette &pal, bool sunken, const QBrush *fill) {
- drawWinCEPanel(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill);
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_STYLE_WINDOWSCE
diff --git a/src/widgets/styles/qwindowscestyle_p.h b/src/widgets/styles/qwindowscestyle_p.h
deleted file mode 100644
index 1530fdcf0f..0000000000
--- a/src/widgets/styles/qwindowscestyle_p.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSCESTYLE_P_H
-#define QWINDOWSCESTYLE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <private/qwindowsstyle_p.h>
-
-QT_BEGIN_NAMESPACE
-
-
-#if !defined(QT_NO_STYLE_WINDOWSCE)
-
-class QWindowsCEStyle : public QWindowsStyle
-{
- Q_OBJECT
-public:
- QWindowsCEStyle();
- ~QWindowsCEStyle();
-
- void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
- QPainter *painter, const QWidget *widget = 0) const;
-
- void drawControl(ControlElement element, const QStyleOption *option,
- QPainter *painter, const QWidget *widget) const;
-
- void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
- QPainter *painter, const QWidget *widget) const;
-
- virtual void drawItemText(QPainter *painter, const QRect &rect,
- int flags, const QPalette &pal, bool enabled,
- const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const;
-
- QSize sizeFromContents(ContentsType type, const QStyleOption *option,
- const QSize &size, const QWidget *widget) const;
-
- QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const;
- QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
- SubControl sc, const QWidget *widget) const;
-
- SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option,
- const QPoint &pos, const QWidget *widget = 0) const;
-
- QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
- const QWidget *widget = 0) const;
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
-
- int styleHint(StyleHint hint, const QStyleOption *opt = 0, const QWidget *widget = 0,
- QStyleHintReturn *returnData = 0) const;
-
- void polish(QWidget *widget);
- void polish(QPalette &palette);
- void polish(QApplication *app);
- QPalette standardPalette() const;
-};
-
-#endif // QT_NO_STYLE_WINDOWSCE
-
-QT_END_NAMESPACE
-
-#endif // QWINDOWSCESTYLE_P_H
diff --git a/src/widgets/styles/qwindowscestyle_p_p.h b/src/widgets/styles/qwindowscestyle_p_p.h
deleted file mode 100644
index 2920413287..0000000000
--- a/src/widgets/styles/qwindowscestyle_p_p.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSCESTYLE_P_P_H
-#define QWINDOWSCESTYLE_P_P_H
-
-#include "qwindowscestyle_p.h"
-#include <private/qwindowsstyle_p_p.h>
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
-// file may change from version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-QT_BEGIN_NAMESPACE
-
-class QPainter;
-class QPalette;
-class QPoint;
-class QColor;
-class QBrush;
-class QRect;
-
-// Private class
-class QWindowsCEStylePrivate : public QWindowsStylePrivate
-{
- Q_DECLARE_PUBLIC(QWindowsCEStyle)
-public:
- inline QWindowsCEStylePrivate()
- { }
-
-
-static void drawWinCEButton(QPainter *p, int x, int y, int w, int h,
- const QPalette &pal, bool sunken = false,
- const QBrush *fill = 0);
-
-static void drawWinCEButton(QPainter *p, const QRect &r,
- const QPalette &pal, bool sunken = false,
- const QBrush *fill = 0);
-
-static void drawWinCEPanel(QPainter *p, int x, int y, int w, int h,
- const QPalette &pal, bool sunken = false,
- const QBrush *fill = 0);
-
-static void drawWinCEPanel(QPainter *p, const QRect &r,
- const QPalette &pal, bool sunken = false,
- const QBrush *fill = 0);
-
-static void drawWinShades(QPainter *p,
- int x, int y, int w, int h,
- const QColor &c1, const QColor &c2,
- const QColor &c3, const QColor &c4,
- const QBrush *fill);
-
-static void drawWinCEShades(QPainter *p,
- int x, int y, int w, int h,
- const QColor &c1, const QColor &c2,
- const QColor &c3, const QColor &c4,
- const QBrush *fill);
-
-static void drawWinCEShadesSunken(QPainter *p,
- int x, int y, int w, int h,
- const QColor &c1, const QColor &c2,
- const QColor &c3, const QColor &c4,
- const QBrush *fill);
-
-
-
-
-};
-
-QT_END_NAMESPACE
-
-#endif //QWINDOWSCESTYLE_P_P_H
diff --git a/src/widgets/styles/qwindowsmobilestyle.cpp b/src/widgets/styles/qwindowsmobilestyle.cpp
deleted file mode 100644
index e1609e040c..0000000000
--- a/src/widgets/styles/qwindowsmobilestyle.cpp
+++ /dev/null
@@ -1,7272 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwindowsmobilestyle_p.h"
-#include "qwindowsmobilestyle_p_p.h"
-
-#if !defined(QT_NO_STYLE_WINDOWSMOBILE) || defined(QT_PLUGIN)
-
-#include "qpainterpath.h"
-#include "qapplication.h"
-#include "qdesktopwidget.h"
-#include "qwidget.h"
-#include "qdockwidget.h"
-#include "qframe.h"
-#include "qmenu.h"
-#include "qpaintengine.h"
-#include "qpainter.h"
-#include "qgroupbox.h"
-#include "qstyleoption.h"
-#include "qlistview.h"
-#include "qdrawutil.h"
-#include "qtoolbar.h"
-#include "qabstractscrollarea.h"
-#include "qabstractbutton.h"
-#include "qcombobox.h"
-#include "qscrollbar.h"
-#include "qabstractitemview.h"
-#include "qmenubar.h"
-#include "qtoolbutton.h"
-#include "qtextedit.h"
-#include "qdialog.h"
-#include "qdebug.h"
-#include "qtabwidget.h"
-
-#ifdef Q_OS_WINCE
-#include "qt_windows.h"
-extern bool qt_wince_is_high_dpi(); //defined in qguifunctions_wince.cpp
-extern bool qt_wince_is_smartphone(); //defined in qguifunctions_wince.cpp
-extern bool qt_wince_is_windows_mobile_65(); //defined in qguifunctions_wince.cpp
-#endif // Q_OS_WINCE
-
-#include "qstylehelper_p.h"
-
-QT_BEGIN_NAMESPACE
-
-static const int windowsItemFrame = 1; // menu item frame width
-
-static const int windowsMobileitemViewCheckBoxSize = 13;
-static const int windowsMobileFrameGroupBoxOffset = 9;
-static const int windowsMobileIndicatorSize = 14;
-static const int windowsMobileExclusiveIndicatorSize = 14;
-static const int windowsMobileSliderThickness = 6;
-static const int windowsMobileIconSize = 16;
-static const int PE_IndicatorArrowUpBig = 0xf000101;
-static const int PE_IndicatorArrowDownBig = 0xf000102;
-static const int PE_IndicatorArrowLeftBig = 0xf000103;
-static const int PE_IndicatorArrowRightBig = 0xf000104;
-
-/* XPM */
-static const char *const radiobutton_xpm[] = {
- "30 30 2 1",
- " c None",
- ". c #000000",
- " ........ ",
- " .............. ",
- " .... .... ",
- " .... .... ",
- " ... ... ",
- " ... ... ",
- " .. .. ",
- " .. .. ",
- " ... ... ",
- " .. .. ",
- " .. .. ",
- ".. ..",
- ".. ..",
- ".. ..",
- ".. ..",
- ".. ..",
- ".. ..",
- ".. ..",
- ".. ..",
- " .. .. ",
- " .. .. ",
- " ... ... ",
- " .. .. ",
- " .. .. ",
- " ... ... ",
- " ... ... ",
- " .... .... ",
- " .... .... ",
- " .............. ",
- " ........ "};
-
-/* XPM */
-static const char * const radiobutton_low_xpm[] = {
- "15 15 2 1",
- " c None",
- ". c #000000",
- " ..... ",
- " .. .. ",
- " . . ",
- " . . ",
- " . . ",
- ". .",
- ". .",
- ". .",
- ". .",
- ". .",
- " . . ",
- " . . ",
- " . . ",
- " .. .. ",
- " ..... "};
-
-/* XPM */
- static const char * const arrowleft_big_xpm[] = {
- "9 17 2 1",
- " c None",
- ". c #000000",
- " .",
- " ..",
- " ...",
- " ....",
- " .....",
- " ......",
- " .......",
- " ........",
- ".........",
- " ........",
- " .......",
- " ......",
- " .....",
- " ....",
- " ...",
- " ..",
- " ."};
-
-/* XPM */
- static const char * const arrowleft_xpm[] = {
- "8 15 2 1",
- " c None",
- ". c #000000",
- " .",
- " ..",
- " ...",
- " ....",
- " .....",
- " ......",
- " .......",
- "........",
- " .......",
- " ......",
- " .....",
- " ....",
- " ...",
- " ..",
- " ."};
-
-
-
-/* XPM */
-static const char *const horlines_xpm[] = {
- "2 2 2 1",
- " c None",
- ". c #000000",
- " ",
- ".."};
-
-/* XPM */
-static const char *const vertlines_xpm[] = {
- "2 2 2 1",
- " c None",
- ". c #000000",
- ". ",
- ". "};
-
-/* XPM */
-static const char *const radiochecked_xpm[] = {
- "18 18 2 1",
- " c None",
- ". c #000000",
- " ...... ",
- " .......... ",
- " .............. ",
- " .............. ",
- " ................ ",
- " ................ ",
- "..................",
- "..................",
- "..................",
- "..................",
- "..................",
- "..................",
- " ................ ",
- " ................ ",
- " .............. ",
- " .............. ",
- " .......... ",
- " ...... "};
-
-/* XPM */
-static const char * const radiochecked_low_xpm[] = {
- "9 9 2 1",
- " c None",
- ". c #000000",
- " ... ",
- " ....... ",
- " ....... ",
- ".........",
- ".........",
- ".........",
- " ....... ",
- " ....... ",
- " ... "};
-
-static const char *const arrowdown_xpm[] = {
- "15 8 2 1",
- " c None",
- ". c #000000",
- "...............",
- " ............. ",
- " ........... ",
- " ......... ",
- " ....... ",
- " ..... ",
- " ... ",
- " . "};
-
-
-static const char *const arrowdown_big_xpm[] = {
- "17 9 2 1",
- " c None",
- ". c #000000",
- ".................",
- " ............... ",
- " ............. ",
- " ........... ",
- " ......... ",
- " ....... ",
- " ..... ",
- " ... ",
- " . "};
-
-
-/* XPM */
-static const char *const checkedlight_xpm[] = {
- "24 24 2 1",
- " c None",
- ". c #000000",
- " ",
- " ",
- " ",
- " ",
- " ",
- " . ",
- " .. ",
- " ... ",
- " .... ",
- " ..... ",
- " ...... ",
- " . ...... ",
- " .. ...... ",
- " ... ...... ",
- " .... ...... ",
- " .......... ",
- " ......... ",
- " ....... ",
- " ..... ",
- " ... ",
- " . ",
- " ",
- " ",
- " "};
-
-
-/* XPM */
-static const char *const checkedbold_xpm[] = {
- "26 26 2 1",
- " c None",
- ". c #000000",
- " ",
- " ",
- " ",
- " ",
- " ",
- " ",
- " .. ",
- " ... ",
- " .... ",
- " ..... ",
- " .. ...... ",
- " ... ....... ",
- " .... ....... ",
- " ..... ....... ",
- " ...... ....... ",
- " .............. ",
- " ............ ",
- " .......... ",
- " ........ ",
- " ...... ",
- " .... ",
- " .. ",
- " ",
- " ",
- " ",
- " "};
-
-/* XPM */
-static const char * const checkedbold_low_xpm[] = {
- "9 8 2 1",
- " c None",
- ". c #000000",
- " .",
- " ..",
- ". ...",
- ".. ... ",
- "... ... ",
- " ..... ",
- " ... ",
- " . "};
-
-/* XPM */
-static const char * const checkedlight_low_xpm[] = {
- "8 8 2 1",
- " c None",
- ". c #000000",
- " .",
- " ..",
- " ...",
- ". ... ",
- ".. ... ",
- "..... ",
- " ... ",
- " . "};
-
-/* XPM */
-static const char * const highlightedradiobutton_xpm[] = {
- "30 30 3 1",
- " c None",
- ". c #000000",
- "+ c #0078CC",
- " ........ ",
- " .............. ",
- " ....++++++++.... ",
- " ....++++++++++++.... ",
- " ...++++ ++++... ",
- " ...+++ +++... ",
- " ..++ ++.. ",
- " ..++ ++.. ",
- " ...++ ++... ",
- " ..++ ++.. ",
- " ..++ ++.. ",
- "..++ ++..",
- "..++ ++..",
- "..++ ++..",
- "..++ ++..",
- "..++ ++..",
- "..++ ++..",
- "..++ ++..",
- "..++ ++..",
- " ..++ ++.. ",
- " ..++ ++.. ",
- " ...++ ++... ",
- " ..++ ++.. ",
- " ..++ ++.. ",
- " ...+++ +++... ",
- " ...++++ ++++... ",
- " ....++++++++++++.... ",
- " ....++++++++.... ",
- " .............. ",
- " ........ "};
-
-/* XPM */
-static const char * const highlightedradiobutton_low_xpm[] = {
- "15 15 3 1",
- " c None",
- ". c #000000",
- "+ c #3192D6",
- " ..... ",
- " ..+++++.. ",
- " .++ ++. ",
- " .+ +. ",
- " .+ +. ",
- ".+ +.",
- ".+ +.",
- ".+ +.",
- ".+ +.",
- ".+ +.",
- " .+ +. ",
- " .+ +. ",
- " .++ ++. ",
- " ..+++++.. ",
- " ..... "};
-
-/* XPM */
-static const char * const cross_big_xpm[] = {
-"28 28 4 1",
-" c #09454A",
-". c #218C98",
-"+ c #47D8E5",
-"@ c #FDFFFC",
-" ",
-" ",
-" ++++++++++++++++++++++++ ",
-" ++++++++++++++++++++++++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++..@@@..........@@@..++ ",
-" ++..@@@@........@@@@..++ ",
-" ++..@@@@@......@@@@@..++ ",
-" ++...@@@@@....@@@@@...++ ",
-" ++....@@@@@..@@@@@....++ ",
-" ++.....@@@@@@@@@@.....++ ",
-" ++......@@@@@@@@......++ ",
-" ++.......@@@@@@.......++ ",
-" ++.......@@@@@@.......++ ",
-" ++......@@@@@@@@......++ ",
-" ++.....@@@@@@@@@@.....++ ",
-" ++....@@@@@..@@@@@....++ ",
-" ++...@@@@@....@@@@@...++ ",
-" ++..@@@@@......@@@@@..++ ",
-" ++..@@@@........@@@@..++ ",
-" ++..@@@..........@@@..++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++++++++++++++++++++++++ ",
-" ++++++++++++++++++++++++ ",
-" ",
-" "};
-
-/* XPM */
-static const char * const cross_small_xpm[] = {
-"14 14 4 1",
-" c #09454A",
-". c #218C98",
-"+ c #47D8E5",
-"@ c #FCFFFC",
-" ",
-" ++++++++++++ ",
-" +..........+ ",
-" +.@@....@@.+ ",
-" +.@@@..@@@.+ ",
-" +..@@@@@@..+ ",
-" +...@@@@...+ ",
-" +...@@@@...+ ",
-" +..@@@@@@..+ ",
-" +.@@@..@@@.+ ",
-" +.@@....@@.+ ",
-" +..........+ ",
-" ++++++++++++ ",
-" "};
-
-/* XPM */
-static const char * const max_big_xpm[] = {
-"28 28 4 1",
-" c #09454A",
-". c #218C98",
-"+ c #47D8E5",
-"@ c #FDFFFC",
-" ",
-" ",
-" ++++++++++++++++++++++++ ",
-" ++++++++++++++++++++++++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++..@@@@@@@@@@@@@@@@..++ ",
-" ++..@@@@@@@@@@@@@@@@..++ ",
-" ++..@@@@@@@@@@@@@@@@..++ ",
-" ++..@@@@@@@@@@@@@@@@..++ ",
-" ++..@@............@@..++ ",
-" ++..@@............@@..++ ",
-" ++..@@............@@..++ ",
-" ++..@@............@@..++ ",
-" ++..@@............@@..++ ",
-" ++..@@............@@..++ ",
-" ++..@@@@@@@@@@@@@@@@..++ ",
-" ++..@@@@@@@@@@@@@@@@..++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++++++++++++++++++++++++ ",
-" ++++++++++++++++++++++++ ",
-" ",
-" "};
-
-/* XPM */
-static const char * const max_small_xpm[] = {
-"14 14 4 1",
-" c #09454A",
-". c #218C98",
-"+ c #47D8E5",
-"@ c #FCFFFC",
-" ",
-" ++++++++++++ ",
-" +..........+ ",
-" +..........+ ",
-" +.@@@@@@@@.+ ",
-" +.@@@@@@@@.+ ",
-" +.@......@.+ ",
-" +.@......@.+ ",
-" +.@......@.+ ",
-" +.@@@@@@@@.+ ",
-" +..........+ ",
-" +..........+ ",
-" ++++++++++++ ",
-" "};
-
-/* XPM */
-static const char * const normal_big_xpm[] = {
-"28 28 4 1",
-" c #09454A",
-". c #218C98",
-"+ c #47D8E5",
-"@ c #FDFFFC",
-" ",
-" ",
-" ++++++++++++++++++++++++ ",
-" ++++++++++++++++++++++++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++..@@@@@@@@@@@@@@@@..++ ",
-" ++..@@@@@@@@@@@@@@@@..++ ",
-" ++..@@............@@..++ ",
-" ++..@@............@@..++ ",
-" ++..@@............@@..++ ",
-" ++..@@............@@..++ ",
-" ++..@@............@@..++ ",
-" ++..@@............@@..++ ",
-" ++..@@............@@..++ ",
-" ++..@@............@@..++ ",
-" ++..@@............@@..++ ",
-" ++..@@............@@..++ ",
-" ++..@@............@@..++ ",
-" ++..@@............@@..++ ",
-" ++..@@@@@@@@@@@@@@@@..++ ",
-" ++..@@@@@@@@@@@@@@@@..++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++++++++++++++++++++++++ ",
-" ++++++++++++++++++++++++ ",
-" ",
-" "};
-
-/* XPM */
-static const char * const normal_small_xpm[] = {
-"14 14 4 1",
-" c #09454A",
-". c #218C98",
-"+ c #47D8E5",
-"@ c #FCFFFC",
-" ",
-" ++++++++++++ ",
-" +..........+ ",
-" +.@@@@@@@@.+ ",
-" +.@......@.+ ",
-" +.@......@.+ ",
-" +.@......@.+ ",
-" +.@......@.+ ",
-" +.@......@.+ ",
-" +.@......@.+ ",
-" +.@@@@@@@@.+ ",
-" +..........+ ",
-" ++++++++++++ ",
-" "};
-
-
-/* XPM */
-static const char * const min_big_xpm[] = {
-"28 28 4 1",
-" c #09454A",
-". c #218C98",
-"+ c #47D8E5",
-"@ c #FDFFFC",
-" ",
-" ",
-" ++++++++++++++++++++++++ ",
-" ++++++++++++++++++++++++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++..@@@@@@@@@@@@@@@@..++ ",
-" ++..@@@@@@@@@@@@@@@@..++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++....................++ ",
-" ++++++++++++++++++++++++ ",
-" ++++++++++++++++++++++++ ",
-" ",
-" "};
-
-/* XPM */
-static const char * const min_small_xpm[] = {
-"14 14 4 1",
-" c #09454A",
-". c #218C98",
-"+ c #47D8E5",
-"@ c #FCFFFC",
-" ",
-" ++++++++++++ ",
-" +..........+ ",
-" +..........+ ",
-" +..........+ ",
-" +..........+ ",
-" +..........+ ",
-" +..........+ ",
-" +..........+ ",
-" +.@@@@@@@@.+ ",
-" +..........+ ",
-" +..........+ ",
-" ++++++++++++ ",
-" "};
-
-#ifdef Q_OS_WINCE_WM
-
-static char * sbhandleup_xpm[] = {
-"26 41 45 1",
-" c None",
-". c #000000",
-"+ c #E7E7E7",
-"@ c #D6D7D6",
-"# c #949294",
-"$ c #737573",
-"% c #636563",
-"& c #636163",
-"* c #5A5D5A",
-"= c #5A595A",
-"- c #525552",
-"; c #525152",
-"> c #4A4D4A",
-", c #7B797B",
-"' c #CECFCE",
-") c #CED3CE",
-"! c #6B6D6B",
-"~ c #6B696B",
-"{ c #737173",
-"] c #7B7D7B",
-"^ c #848684",
-"/ c #848284",
-"( c #8C8A8C",
-"_ c #8C8E8C",
-": c #B5B2B5",
-"< c #FFFFFF",
-"[ c #949694",
-"} c #B5B6B5",
-"| c #9C9A9C",
-"1 c #ADAEAD",
-"2 c #9C9E9C",
-"3 c #BDBABD",
-"4 c #BDBEBD",
-"5 c #F7F3F7",
-"6 c #C6C3C6",
-"7 c #C6C7C6",
-"8 c #A5A2A5",
-"9 c #CECBCE",
-"0 c #FFFBFF",
-"a c #ADAAAD",
-"b c #A5A6A5",
-"c c #D6D3D6",
-"d c #B5BAB5",
-"e c #DEDFDE",
-"f c #DEDBDE",
-"..........................",
-"+@#$%%&&&**===---;;;;>=,'+",
-"+@#$%%&&&**===---;;;;>=$'+",
-")$!!~~%%&&&**===---;;;;>;'",
-"#{$]],,$${{{!!~~%%%&&&*-;]",
-"#{$]],,$${{{!!~~%%%&&&*-;]",
-",$^//]],,$${{{!!~~%%%&&*;*",
-",,(^^//]],$${!!!!!~~%%%&-*",
-",,(^^//]],$${!!!!!~~%%%&-*",
-"]]_((^^//]$!%%~!{{!!~~%%-*",
-"//#__((^^]{:<<:~!{{{!!~~=*",
-"//#__((^^]{:<<:~!{{{!!~~=&",
-"//###__(/$:<<<<:~{${{!!~*&",
-"^^[[##_^]:<<<<<<}!{$${{!*%",
-"^^[[##_^]:<<<<<<}!{$${{!*%",
-"((|[[#_/:<<<<<<<<}!$$${{&~",
-"((||[#^1<<<<1:<<<<}!$$$$&~",
-"((||[#^1<<<<1:<<<<}!$$$$&~",
-"__2|#(1<<<<}],}<<<<}{$,$%~",
-"##2|_1<<<<}^((]3<<<<}{$,~!",
-"##2|_1<<<<}^((]3<<<<}{$,~!",
-"##2#1<<<<3^###(/4<<<<}{,~{",
-"##2#1<<<<3^###(/4<<<<}{,~!",
-"[[2_5<<<4(#|[[#_/6<<<<,,!{",
-"[|2_5<<4_[||||[[_/7<<<,]{$",
-"[|2_5<<4_[||||[[_/7<<<,]{$",
-"||8_5<6#|2222|||[_/9<<,]{$",
-"228#06[28888222||[_/'<,/$,",
-"228#06[28888222||[_/'<,/$,",
-"22a|6[8bbbb88822||[(/c](,]",
-"881b8baaabbbb88222|[(^(_,]",
-"881b8baaabbbb88222|[(^(_,]",
-"88111111aaabbb88822|[###]/",
-"bb:::11111aaabbb8822||[[/^",
-"bb:::11111aaabbb8822||[[//",
-"bb:::::1111aaabbb8822||[/(",
-"3a1::::::1111aaabb8822|_^8",
-"da1::::::1111aaabb8822|_^8",
-"e1aaabbbb888822||[[##__((@",
-"+e4:aaabbbb88822||[[[#[b@+",
-"+e4:aaabbbb88822||[[[#[bf+"};
-
-static char * sbhandledown_xpm[] = {
-"26 40 46 1",
-" c None",
-". c #E7E7E7",
-"+ c #DEDFDE",
-"@ c #BDBEBD",
-"# c #B5B2B5",
-"$ c #ADAAAD",
-"% c #A5A6A5",
-"& c #A5A2A5",
-"* c #9C9E9C",
-"= c #9C9A9C",
-"- c #949694",
-"; c #949294",
-"> c #D6D7D6",
-", c #DEDBDE",
-"' c #D6DBD6",
-") c #ADAEAD",
-"! c #8C8E8C",
-"~ c #8C8A8C",
-"{ c #BDBABD",
-"] c #848684",
-"^ c #B5BAB5",
-"/ c #848284",
-"( c #848A84",
-"_ c #7B7D7B",
-": c #7B797B",
-"< c #C6C3C6",
-"[ c #D6D3D6",
-"} c #FFFBFF",
-"| c #CECFCE",
-"1 c #FFFFFF",
-"2 c #737573",
-"3 c #F7F3F7",
-"4 c #CECBCE",
-"5 c #737173",
-"6 c #C6C7C6",
-"7 c #6B6D6B",
-"8 c #B5B6B5",
-"9 c #6B696B",
-"0 c #636563",
-"a c #636163",
-"b c #5A5D5A",
-"c c #5A595A",
-"d c #525552",
-"e c #525152",
-"f c #4A4D4A",
-"g c #C6CBC6",
-".+@#$$$%%%%&&&**==---;-%>.",
-".+@#$$$%%%%&&&**==---;-%,.",
-"')$$$%%%%&&&&**==--;;!!~~>",
-"{$)######))))$$$%%&&**=!]&",
-"^$)######))))$$$%%&&**=!]&",
-"%%#####))))$$$%%%&&**==-/(",
-"%%###)))))$$$%%%&&**==--/]",
-"%%###)))))$$$%%%&&**==--//",
-"&&))))))$$$%%%&&&**=-;;;_/",
-"&&)%&%$$$%%%%&&***=-~]~!:_",
-"&&)%&%$$$%%%%&&***=-~]~!:_",
-"**$=<-&%%%%&&&**==-~/[_~:_",
-"**&;}<-*&&&&***==-!/|1:/2:",
-"**&;}<-*&&&&***==-!/|1:/2:",
-"==&!31<;=****===-!/411:_5:",
-"-=*!311@!-====--!/6111:_52",
-"-=*!311@!-====--!/6111:_52",
-"--*!3111@~;=--;!/<1111::75",
-";;*;)1111{];;;~/@111185:95",
-";;*;)1111{];;;~/@111185:97",
-";;*=!)11118]~~_{1111852:97",
-";;*=!)11118]~~_{1111852:97",
-"!!*=;~)11118_:81111852:207",
-"~~==-;])1111)#1111872222a9",
-"~~==-;])1111)#1111872222a9",
-"~~=--;!/#111111118722255a0",
-"]]--;;!]_#11111187522557b0",
-"]]--;;!]_#11111187522557b0",
-"//;;;!!~/2#1111#95255779ba",
-"//;!!~~]]_5#11#975557799cb",
-"//;!!~~]]_5#11#975557799ca",
-"__!~~]]//_27009755779900db",
-"::~]]//__:2257777799000adb",
-"::~]]//__:2257777799000adb",
-":2]//__::225557799000aabeb",
-";52__::225557799000aaabde_",
-";52__::225557799000aaabde_",
-"[2779900aaabbcccdddeeeefeg",
-".>;200aaabbcccdddeeeefc:|.",
-".>;200aaabbcccdddeeeefc2|."};
-
-static char * sbgripdown_xpm[] = {
-"26 34 39 1",
-" c None",
-". c #949294",
-"+ c #9C9E9C",
-"@ c #9C9A9C",
-"# c #949694",
-"$ c #8C8E8C",
-"% c #8C8A8C",
-"& c #848684",
-"* c #848284",
-"= c #7B7D7B",
-"- c #7B797B",
-"; c #6B696B",
-"> c #636563",
-", c #737573",
-"' c #636163",
-") c #737173",
-"! c #5A5D5A",
-"~ c #6B6D6B",
-"{ c #5A595A",
-"] c #B5B6B5",
-"^ c #BDBEBD",
-"/ c #ADAEAD",
-"( c #BDBABD",
-"_ c #525552",
-": c #313031",
-"< c #525152",
-"[ c #ADAAAD",
-"} c #BDBAB5",
-"| c #4A4D4A",
-"1 c #4A494A",
-"2 c #C6C3C6",
-"3 c #C6CBC6",
-"4 c #E7E7E7",
-"5 c #DEDFDE",
-"6 c #E7E3E7",
-"7 c #DEE3DE",
-"8 c #CECBCE",
-"9 c #8C928C",
-"0 c #CECFCE",
-"..+++@@@###...$$%&&**==-;>",
-"$.++@@@@##...$$%%&**==-->>",
-"$$+@@@@###..$$%%&&*==--,>>",
-"$$@@@@###..$$%%&&**==-,,>'",
-"%%@@@###..$$$%&&**==--,,''",
-"%%@@###..$$$%&&**==--,,)''",
-"%%@###...$$%%&&*==--,,))'!",
-"&&###...$$%%&&**==--,)))!!",
-"&&##...$$%%&&**==--,,))~!!",
-"&&#...$$%%&&**==--,,))~~!{",
-"**...$$%%&&**==--,,))~~;!{",
-"**..$$%%&&**===--,)))~~;{{",
-"**.$$%%&]^&===//,,))~~;;{{",
-"==$$%%&&]^*==-((,))~~;;>{_",
-"==$%%&&***::--,,::~~;;;>__",
-"==%%&&&**=::-,,)::~~;;>>__",
-"--%&&&**==--,,)))~~;;>>>__",
-"--&&&**==--,,)))~~;;>>>'_<",
-",-&&**==]^-,))[[~;;>>>''<<",
-",,&**==-]^-)))}};;>>>'''<<",
-",,**==--,,::)~~;::>>'''!<<",
-"))*==--,,)::~~;;::>'''!!<|",
-"))==--,,)))~~;;;>>'''!!!||",
-"))=--,,)))~~;;;>>'''!!!{||",
-"~~--,,)))~~;;;>>'''!!!{{||",
-"~~-,,)))~~;;>>>'''!!!{{{|1",
-";;,,)))~~;;>>>'''!!!{{{_1<",
-"~;,)))~~;;>>>'''!!!{{{__1'",
-"%>~))~~;;>>>'''!!!{{{__|1$",
-"2>>~~~;;>>>''!!!{{{{__<113",
-"4%'';;;>>>''!!!{{{{__<11%4",
-"45-!!'>>>''!!!{{{{_<|11)64",
-"447+!{{___<<<||||1111|+444",
-"444489~__<<<||||111>$04444"};
-
-static char * sbgripup_xpm[] = {
-"26 34 38 1",
-" c None",
-". c #E7E7E7",
-"+ c #D6DBD6",
-"@ c #C6C7C6",
-"# c #B5B6B5",
-"$ c #ADAEAD",
-"% c #ADAAAD",
-"& c #A5A6A5",
-"* c #A5A2A5",
-"= c #BDBEBD",
-"- c #DEDFDE",
-"; c #C6CBC6",
-"> c #9C9E9C",
-", c #E7E3E7",
-"' c #BDBABD",
-") c #B5B2B5",
-"! c #9C9A9C",
-"~ c #DEE3DE",
-"{ c #949694",
-"] c #D6D7D6",
-"^ c #949294",
-"/ c #DEDBDE",
-"( c #8C8E8C",
-"_ c #8C8A8C",
-": c #848684",
-"< c #D6D3CE",
-"[ c #CECBCE",
-"} c #D6D3D6",
-"| c #848284",
-"1 c #313031",
-"2 c #7B7D7B",
-"3 c #CECFCE",
-"4 c #CECBC6",
-"5 c #7B797B",
-"6 c #737573",
-"7 c #737173",
-"8 c #6B6D6B",
-"9 c #6B696B",
-"....+@#$$%%%%&&&***$=-....",
-"...;$$$$$%%%&&&&**>>>>@...",
-".,'$$)#'#####)))$$$%*!!$~.",
-".=$)#'''####))))$$$%%*!{'.",
-"]$$''''#####)))$$$%%%&*{^/",
-"=$#'''#####)))$$$$%%&&&!^#",
-"$$'''#####))))$$$%%%&&*>(!",
-"$$''#####))))$$$%%%&&&*>(^",
-"$$######))))$$$$%%&&&**>(_",
-"%$#####))))$$$$%%%&&***>__",
-"%$####))))$$$$%%%&&&**>>__",
-"%%###)))))$$$%%%&&&**>>>_:",
-"%%##))))<])$$%[[&&***>>!::",
-"%%#)))))<]$$%%}<&&**>>!!:|",
-"&%)))))$$$11%%&&11*>>>!!:|",
-"&&))))$$$$11%&&&11*>>!!{||",
-"&&)))$$$$$%%%&&&**>>!!!{|2",
-"&&))$$$$$%%%&&&**>>>!!{{|2",
-"*&)$$$$$3]%&&&4@*>>!!{{{22",
-"**$$$$$%3]%&&&<<>>!!!{{^25",
-"**$$$$%%%%11&**>11!!{{^^25",
-"**$$$%%%%&11***>11!!{{^^55",
-"**$$%%%%&&&***>>!!!{{^^(55",
-">>$%%%%&&&***>>>!!{{^^((56",
-">>%%%%&&&&***>>!!!{{^^((66",
-">>%%%&&&&***>>!!!{{^^((_67",
-"!>%%&&&&***>>>!!{{{^^(__67",
-"!!%&&&&***>>>!!!{{^^((_:77",
-"!!&&&&***>>>!!!{{^^((__:77",
-"!!&&&****>>!!!{{^^^(__::78",
-"{!&&****>>>!!{{{^^((_::|88",
-"{{&****>>>!!!{{^^((__:||88",
-"{{****>>>!!!{{^^^(__::|289",
-"{{***>>>!!!{{{^^((_::||289"};
-
-static char * sbgripmiddle_xpm[] = {
-"26 2 12 1",
-" c None",
-". c #949294",
-"+ c #A5A2A5",
-"@ c #9C9E9C",
-"# c #9C9A9C",
-"$ c #949694",
-"% c #8C8E8C",
-"& c #8C8A8C",
-"* c #848684",
-"= c #848284",
-"- c #7B7D7B",
-"; c #6B696B",
-"..++@@@###$$$..%%&&*==--;;",
-"..++@@@###$$$..%%&&*==--;;"};
-
-
-static char * listviewhighmiddle_xpm[] = {
-"8 46 197 2",
-" c None",
-". c #66759E",
-"+ c #6C789D",
-"@ c #6A789E",
-"# c #6B789E",
-"$ c #6A779D",
-"% c #6C789C",
-"& c #6F7D9B",
-"* c #6F7D9A",
-"= c #9DB6EE",
-"- c #9DB6ED",
-"; c #9CB6ED",
-"> c #A1B6EF",
-", c #A2B6F0",
-"' c #93AAE9",
-") c #95ABEA",
-"! c #94ABEA",
-"~ c #94A9E8",
-"{ c #8BA8EA",
-"] c #8BA7EA",
-"^ c #8AA7EA",
-"/ c #8EAAE8",
-"( c #8FAAE8",
-"_ c #88A2E7",
-": c #8CA3E8",
-"< c #8BA3E7",
-"[ c #8BA3E8",
-"} c #8BA2E7",
-"| c #8CA2E7",
-"1 c #8DA2E7",
-"2 c #87A1E8",
-"3 c #87A1E9",
-"4 c #86A0E8",
-"5 c #86A1E7",
-"6 c #87A2E7",
-"7 c #859EE9",
-"8 c #849DE9",
-"9 c #869EE9",
-"0 c #869FE9",
-"a c #7C9BEA",
-"b c #7C9CEA",
-"c c #7B9CEA",
-"d c #7C9BE9",
-"e c #7E9CE9",
-"f c #7B9AEA",
-"g c #7C99E9",
-"h c #7C9AEA",
-"i c #7B9AE8",
-"j c #7A9AEA",
-"k c #7996E1",
-"l c #7C96E4",
-"m c #7B96E3",
-"n c #7B95E3",
-"o c #7E95E5",
-"p c #7E95E6",
-"q c #7292E1",
-"r c #7490DF",
-"s c #7591E0",
-"t c #7590DF",
-"u c #7392E1",
-"v c #6D8CDE",
-"w c #6F8EDD",
-"x c #6E8DDD",
-"y c #6E8DDE",
-"z c #6F8EDE",
-"A c #6E8EDE",
-"B c #718EDD",
-"C c #728EDD",
-"D c #6B89E0",
-"E c #6C89DF",
-"F c #6D89E0",
-"G c #6D89DF",
-"H c #6C88DF",
-"I c #6D88DF",
-"J c #6D86DD",
-"K c #6086E0",
-"L c #6686E0",
-"M c #6586E0",
-"N c #6486E0",
-"O c #6485E0",
-"P c #6786DF",
-"Q c #5F85E0",
-"R c #6583DE",
-"S c #6683DE",
-"T c #6682DD",
-"U c #6086DF",
-"V c #5F86E0",
-"W c #567ED7",
-"X c #567ED8",
-"Y c #557DD7",
-"Z c #5A7FD8",
-"` c #6281DA",
-" . c #5379D9",
-".. c #5278D9",
-"+. c #547BD8",
-"@. c #4C73D7",
-"#. c #4B72D2",
-"$. c #4C73D4",
-"%. c #4C73D3",
-"&. c #4B72D4",
-"*. c #4F75D3",
-"=. c #5074D2",
-"-. c #4971D0",
-";. c #4871D0",
-">. c #335ECF",
-",. c #325ECB",
-"'. c #335ECD",
-"). c #335ECE",
-"!. c #325DCD",
-"~. c #2E59C9",
-"{. c #3059C9",
-"]. c #2F59C9",
-"^. c #2F59C8",
-"/. c #2B59CA",
-"(. c #3355C6",
-"_. c #3354C5",
-":. c #3156C7",
-"<. c #3056C7",
-"[. c #3355C7",
-"}. c #3355C5",
-"|. c #254EBF",
-"1. c #1F51C1",
-"2. c #234FC0",
-"3. c #234FBF",
-"4. c #2350C0",
-"5. c #1E50BE",
-"6. c #1D50C0",
-"7. c #264DBE",
-"8. c #264CBD",
-"9. c #254DBE",
-"0. c #244EBF",
-"a. c #254DBF",
-"b. c #234CBF",
-"c. c #244CC0",
-"d. c #244BC0",
-"e. c #234BC0",
-"f. c #234BBF",
-"g. c #234CBE",
-"h. c #2049B7",
-"i. c #2A49B5",
-"j. c #2749B5",
-"k. c #2749B6",
-"l. c #2D49B4",
-"m. c #2649B6",
-"n. c #2946B5",
-"o. c #2A48B6",
-"p. c #2947B5",
-"q. c #2946B6",
-"r. c #2848B6",
-"s. c #2549B5",
-"t. c #2648B6",
-"u. c #2744B5",
-"v. c #2744B4",
-"w. c #2744AF",
-"x. c #2543B4",
-"y. c #2543B2",
-"z. c #2442B2",
-"A. c #2442B3",
-"B. c #2442B5",
-"C. c #2543B3",
-"D. c #1F40B1",
-"E. c #1E40B1",
-"F. c #243EAE",
-"G. c #273BAC",
-"H. c #263DAC",
-"I. c #253CAB",
-"J. c #273CAB",
-"K. c #273CAC",
-"L. c #263BAA",
-"M. c #253CAE",
-"N. c #263BA6",
-"O. c #253BA5",
-"P. c #253AA5",
-"Q. c #253BA6",
-"R. c #253CA7",
-"S. c #263AA6",
-"T. c #243CA6",
-"U. c #253CA5",
-"V. c #273BA8",
-"W. c #2F4DA4",
-"X. c #2F4DA3",
-"Y. c #1B2F85",
-"Z. c #B5B5B6",
-"`. c #B5B5B5",
-" + c #B5B6B6",
-".+ c #B5B4B6",
-"++ c #C2C3C5",
-"@+ c #C0C3C3",
-"#+ c #C1C3C4",
-"$+ c #E3E3E3",
-"%+ c #E3E3E4",
-"&+ c #E4E3E4",
-"*+ c #E2E3E4",
-"=+ c #ECEEEB",
-"-+ c #EBEDEA",
-";+ c #EEF0ED",
-">+ c #EFF0EE",
-". + @ @ # # $ % ",
-"& & * & & & & & ",
-"= = - = = ; > , ",
-"' ) ! ! ! ) ' ~ ",
-"{ ] { { { ^ / ( ",
-"_ : < [ : } | 1 ",
-"2 2 2 3 2 4 5 6 ",
-"7 7 7 7 7 8 9 0 ",
-"a b a a a c d e ",
-"f g h h h h i j ",
-"k l m m m n o p ",
-"q q q q q q q q ",
-"r r s s s t q u ",
-"v w x y z A B C ",
-"D E F F G F H I ",
-"J K L M N O P Q ",
-"R R S S S T U V ",
-"W W X X X Y Z ` ",
-" . . . . ...+.W ",
-" . . . . ..... .",
-"@.#.$.$.%.&.*.=.",
-"-.-.;.-.-.-.-.-.",
-">.,.'.).).!.!.>.",
-"~.{.].^.].^././.",
-"(.(.(.(.(._.:.<.",
-"(.(.[.[.[.[.(.}.",
-"|.1.2.3.3.4.5.6.",
-"7.7.7.7.7.8.9.0.",
-"a.b.c.d.c.e.f.g.",
-"h.i.j.k.j.k.l.m.",
-"n.o.p.q.r.p.s.t.",
-"u.u.v.u.u.u.u.u.",
-"w.x.y.z.A.y.B.C.",
-"D.D.E.D.D.D.D.D.",
-"D.D.E.D.D.D.D.D.",
-"F.G.H.I.J.K.L.M.",
-"N.N.O.N.N.P.Q.R.",
-"N.N.S.N.N.N.N.N.",
-"T.N.T.T.T.U.N.V.",
-"W.W.X.W.W.W.W.W.",
-"W.W.W.W.W.W.W.W.",
-"Y.Y.Y.Y.Y.Y.Y.Y.",
-"Z.`. + +.+Z.`.`.",
-"++@+#+#+#+#+@+@+",
-"$+%+&+&+*+%+%+%+",
-"=+-+;+-+-+>+-+-+"};
-
-
-
-static char * listviewhighcornerleft_xpm[] = {
-"100 46 1475 2",
-" c None",
-". c #FBFBFC",
-"+ c #E8EAE7",
-"@ c #758DC3",
-"# c #42599E",
-"$ c #28418A",
-"% c #19418F",
-"& c #3F5695",
-"* c #415896",
-"= c #435A98",
-"- c #445C99",
-"; c #465E9B",
-"> c #48609B",
-", c #49629C",
-"' c #4A639D",
-") c #49639D",
-"! c #4A629D",
-"~ c #4B639D",
-"{ c #4B649D",
-"] c #4C659D",
-"^ c #4D669D",
-"/ c #4E689D",
-"( c #506A9D",
-"_ c #516A9D",
-": c #536B9C",
-"< c #546C9C",
-"[ c #566D9B",
-"} c #576D9B",
-"| c #586E9C",
-"1 c #5B6F9D",
-"2 c #61739D",
-"3 c #63749E",
-"4 c #64749E",
-"5 c #68769E",
-"6 c #6A779E",
-"7 c #6B789E",
-"8 c #66759E",
-"9 c #6C789D",
-"0 c #EEF0ED",
-"a c #D0D3DC",
-"b c #3E51A3",
-"c c #28428B",
-"d c #29428C",
-"e c #425996",
-"f c #455C99",
-"g c #485F9C",
-"h c #49619E",
-"i c #4A63A0",
-"j c #4B64A1",
-"k c #4B65A1",
-"l c #4C66A2",
-"m c #4D67A2",
-"n c #4F69A1",
-"o c #516AA1",
-"p c #536CA0",
-"q c #556DA1",
-"r c #576EA0",
-"s c #586F9F",
-"t c #586E9F",
-"u c #596F9E",
-"v c #5A6F9E",
-"w c #5C709E",
-"x c #5E719E",
-"y c #5F729F",
-"z c #62739F",
-"A c #63739E",
-"B c #64749D",
-"C c #65749E",
-"D c #69769D",
-"E c #6C799E",
-"F c #6D799F",
-"G c #707D9F",
-"H c #717F9E",
-"I c #6E7AA1",
-"J c #6C789E",
-"K c #6F7C9C",
-"L c #6F7D9B",
-"M c #2A4AA0",
-"N c #4971D0",
-"O c #4C72D8",
-"P c #5472C0",
-"Q c #5573BF",
-"R c #5774BF",
-"S c #5875BF",
-"T c #5976C1",
-"U c #5A76C1",
-"V c #5C78C2",
-"W c #5E7AC2",
-"X c #607CC3",
-"Y c #627EC3",
-"Z c #637FC4",
-"` c #6581C5",
-" . c #6682C6",
-".. c #6783C7",
-"+. c #6984C8",
-"@. c #6B85C9",
-"#. c #6D87CA",
-"$. c #6F89CB",
-"%. c #718CCD",
-"&. c #748ECF",
-"*. c #7690D0",
-"=. c #7992D2",
-"-. c #7A93D3",
-";. c #7C95D5",
-">. c #7F98D7",
-",. c #8099D8",
-"'. c #859CDB",
-"). c #8AA0DD",
-"!. c #8DA3DF",
-"~. c #8FA5E0",
-"{. c #90A5E0",
-"]. c #91A6E1",
-"^. c #91A5E1",
-"/. c #90A4E0",
-"(. c #8EA3DE",
-"_. c #92A6E2",
-":. c #8FA4DF",
-"<. c #90A5DE",
-"[. c #90A5DC",
-"}. c #90A6DB",
-"|. c #91A6E0",
-"1. c #93A7E2",
-"2. c #95AAE6",
-"3. c #99AEEA",
-"4. c #9AB2EA",
-"5. c #99B1E9",
-"6. c #99B1E7",
-"7. c #98AFE6",
-"8. c #93A8E2",
-"9. c #97ACE7",
-"0. c #9AB3EB",
-"a. c #9DB5ED",
-"b. c #9DB6EE",
-"c. c #375095",
-"d. c #4056AD",
-"e. c #506DCD",
-"f. c #4360CC",
-"g. c #345ED6",
-"h. c #335ECF",
-"i. c #355ED6",
-"j. c #355FD6",
-"k. c #365FD6",
-"l. c #355FD0",
-"m. c #3760D5",
-"n. c #3A63D4",
-"o. c #3C63D1",
-"p. c #3B63CD",
-"q. c #3B63C9",
-"r. c #3B62C9",
-"s. c #3D63C8",
-"t. c #4065C5",
-"u. c #4567C5",
-"v. c #496BC5",
-"w. c #4F70C7",
-"x. c #5273C8",
-"y. c #5475CA",
-"z. c #5777CB",
-"A. c #5879CD",
-"B. c #5A7BCE",
-"C. c #5D7DCF",
-"D. c #5F7ECF",
-"E. c #617FD0",
-"F. c #6381D1",
-"G. c #6583D2",
-"H. c #6785D2",
-"I. c #6886D3",
-"J. c #6A88D4",
-"K. c #6C89D5",
-"L. c #6E8BD6",
-"M. c #708CD7",
-"N. c #718DD8",
-"O. c #738EDA",
-"P. c #748FDB",
-"Q. c #7691DC",
-"R. c #7893DD",
-"S. c #7994DD",
-"T. c #7A96DE",
-"U. c #7B97DF",
-"V. c #7C98E0",
-"W. c #7E9AE2",
-"X. c #7F9BE3",
-"Y. c #829DE4",
-"Z. c #849FE5",
-"`. c #87A0E6",
-" + c #88A1E7",
-".+ c #89A2E6",
-"++ c #8CA3E7",
-"@+ c #8EA5E9",
-"#+ c #8EA6E9",
-"$+ c #8FA7E9",
-"%+ c #8FA8E8",
-"&+ c #8FA9E8",
-"*+ c #91A9E8",
-"=+ c #90A7E8",
-"-+ c #8FA8EA",
-";+ c #90AAEA",
-">+ c #93ABEA",
-",+ c #95ABEA",
-"'+ c #93ABE9",
-")+ c #94ABEA",
-"!+ c #90A9EA",
-"~+ c #93AAE9",
-"{+ c #273E7E",
-"]+ c #345ED5",
-"^+ c #3D60CE",
-"/+ c #3D60CF",
-"(+ c #345ECF",
-"_+ c #335ED0",
-":+ c #355FD3",
-"<+ c #3A60CE",
-"[+ c #3A5FCB",
-"}+ c #385FC9",
-"|+ c #3B60C8",
-"1+ c #3C63CB",
-"2+ c #3E64CB",
-"3+ c #4166CA",
-"4+ c #4568C9",
-"5+ c #4A6CC7",
-"6+ c #4F71C8",
-"7+ c #5172CA",
-"8+ c #5475CE",
-"9+ c #5678D3",
-"0+ c #597CD6",
-"a+ c #5C7ED7",
-"b+ c #5E7FD8",
-"c+ c #6181D9",
-"d+ c #6383DA",
-"e+ c #6585DA",
-"f+ c #6786DB",
-"g+ c #6988DC",
-"h+ c #6B8ADD",
-"i+ c #6D8BDE",
-"j+ c #6F8DDE",
-"k+ c #718EDF",
-"l+ c #728FE0",
-"m+ c #7390E1",
-"n+ c #7390E2",
-"o+ c #7491E3",
-"p+ c #7592E4",
-"q+ c #7693E4",
-"r+ c #7794E5",
-"s+ c #7894E5",
-"t+ c #7995E6",
-"u+ c #7B96E6",
-"v+ c #7C97E7",
-"w+ c #7D9AE8",
-"x+ c #7F9CE9",
-"y+ c #829DE9",
-"z+ c #849EE9",
-"A+ c #859EE9",
-"B+ c #87A0E7",
-"C+ c #8AA2E7",
-"D+ c #8BA3E8",
-"E+ c #89A2E7",
-"F+ c #8CA6EA",
-"G+ c #8BA6EA",
-"H+ c #8BA7EA",
-"I+ c #8CA3E8",
-"J+ c #8BA8EA",
-"K+ c #8CA7EA",
-"L+ c #8CA8EA",
-"M+ c #4659C7",
-"N+ c #355ECF",
-"O+ c #3660CF",
-"P+ c #3860CE",
-"Q+ c #3961CD",
-"R+ c #3B61CB",
-"S+ c #3B61CA",
-"T+ c #3D62CA",
-"U+ c #3D63CA",
-"V+ c #4165CB",
-"W+ c #456ACB",
-"X+ c #4B6FCD",
-"Y+ c #5174CE",
-"Z+ c #5275D1",
-"`+ c #5477D4",
-" @ c #5678D9",
-".@ c #587ADB",
-"+@ c #597BDB",
-"@@ c #5B7DDC",
-"#@ c #5E7FDC",
-"$@ c #6081DD",
-"%@ c #6283DE",
-"&@ c #6484DF",
-"*@ c #6787E0",
-"=@ c #6989E1",
-"-@ c #6B8BE1",
-";@ c #6D8DE2",
-">@ c #6F8EE3",
-",@ c #718FE4",
-"'@ c #7290E4",
-")@ c #7491E5",
-"!@ c #7692E6",
-"~@ c #7793E5",
-"{@ c #7894E6",
-"]@ c #7895E7",
-"^@ c #7996E8",
-"/@ c #7A97E8",
-"(@ c #7B98E9",
-"_@ c #7D99E8",
-":@ c #7F9AE8",
-"<@ c #7F9BE9",
-"[@ c #7F9CEA",
-"}@ c #859EE8",
-"|@ c #859FE8",
-"1@ c #85A0E9",
-"2@ c #869FE9",
-"3@ c #86A1E7",
-"4@ c #86A0E9",
-"5@ c #87A1E7",
-"6@ c #88A2E7",
-"7@ c #87A1E9",
-"8@ c #5A6FCA",
-"9@ c #365FCF",
-"0@ c #345ED0",
-"a@ c #385FCC",
-"b@ c #385FCE",
-"c@ c #3A61CC",
-"d@ c #3B62CD",
-"e@ c #3E64CD",
-"f@ c #4167CF",
-"g@ c #4469CF",
-"h@ c #486CD1",
-"i@ c #4D71D2",
-"j@ c #5175D4",
-"k@ c #5376D6",
-"l@ c #5578DA",
-"m@ c #5679DC",
-"n@ c #587BDD",
-"o@ c #5A7DDE",
-"p@ c #5D80DE",
-"q@ c #5F82DF",
-"r@ c #6284DF",
-"s@ c #6585E0",
-"t@ c #6787E1",
-"u@ c #6988E2",
-"v@ c #6B8AE2",
-"w@ c #6D8CE3",
-"x@ c #6E8DE3",
-"y@ c #708EE4",
-"z@ c #718FE3",
-"A@ c #7391E4",
-"B@ c #7592E5",
-"C@ c #7895E5",
-"D@ c #7996E6",
-"E@ c #7A97E6",
-"F@ c #7B98E7",
-"G@ c #7A98E8",
-"H@ c #7B99E9",
-"I@ c #7E9AE9",
-"J@ c #7D9AE9",
-"K@ c #7E9AEA",
-"L@ c #809CE9",
-"M@ c #819DE8",
-"N@ c #7F9BEA",
-"O@ c #819DE9",
-"P@ c #819CE9",
-"Q@ c #839EE9",
-"R@ c #839EE8",
-"S@ c #839DEA",
-"T@ c #859FE9",
-"U@ c #87A0E8",
-"V@ c #86A0E8",
-"W@ c #87A1E8",
-"X@ c #3760CF",
-"Y@ c #3A61CE",
-"Z@ c #3A62CD",
-"`@ c #3F66CE",
-" # c #4368D0",
-".# c #466CD2",
-"+# c #496DD5",
-"@# c #4E72D6",
-"## c #5175D8",
-"$# c #5276DA",
-"%# c #5578DC",
-"&# c #577ADC",
-"*# c #597CDD",
-"=# c #5B7DDD",
-"-# c #5D7FDE",
-";# c #5E81DE",
-"># c #6183DF",
-",# c #6386DF",
-"'# c #6687E0",
-")# c #6888E0",
-"!# c #6A89E1",
-"~# c #6C8AE1",
-"{# c #6E8CE2",
-"]# c #6F8DE2",
-"^# c #7390E4",
-"/# c #7390E3",
-"(# c #7491E4",
-"_# c #7693E5",
-":# c #7895E6",
-"<# c #7896E6",
-"[# c #7997E7",
-"}# c #7B97E7",
-"|# c #7B98E8",
-"1# c #7C98E8",
-"2# c #7E9BE9",
-"3# c #809CEA",
-"4# c #819CEA",
-"5# c #839DE9",
-"6# c #365FD0",
-"7# c #3660D0",
-"8# c #3961CF",
-"9# c #3B63CF",
-"0# c #3D64D0",
-"a# c #4067D0",
-"b# c #4469D2",
-"c# c #466BD3",
-"d# c #496ED5",
-"e# c #4C71D6",
-"f# c #4E72D8",
-"g# c #5074D9",
-"h# c #5376DB",
-"i# c #5578DB",
-"j# c #587ADC",
-"k# c #5B7CDC",
-"l# c #5D7EDD",
-"m# c #5F80DD",
-"n# c #6081DE",
-"o# c #6383DE",
-"p# c #6686DF",
-"q# c #6887E0",
-"r# c #6988E0",
-"s# c #6B89E1",
-"t# c #6C8AE0",
-"u# c #6E8CE1",
-"v# c #708EE2",
-"w# c #718FE2",
-"x# c #7290E3",
-"y# c #7391E2",
-"z# c #7492E1",
-"A# c #7592E2",
-"B# c #7691E3",
-"C# c #7591E3",
-"D# c #7692E3",
-"E# c #7693E3",
-"F# c #7793E4",
-"G# c #7893E4",
-"H# c #7994E5",
-"I# c #7D97E8",
-"J# c #7E98E8",
-"K# c #7D98E8",
-"L# c #7D99E9",
-"M# c #7D9BEA",
-"N# c #7D9CEA",
-"O# c #7E99E8",
-"P# c #7D9AEA",
-"Q# c #7C9BEA",
-"R# c #7C9CEA",
-"S# c #355FCF",
-"T# c #3860D0",
-"U# c #3A62D0",
-"V# c #3C64D1",
-"W# c #4167D1",
-"X# c #4369D3",
-"Y# c #466BD4",
-"Z# c #486DD5",
-"`# c #4A6ED7",
-" $ c #4C70D8",
-".$ c #5478D9",
-"+$ c #577BDA",
-"@$ c #597DDB",
-"#$ c #5B7EDB",
-"$$ c #5D7FDC",
-"%$ c #6182DE",
-"&$ c #6284DE",
-"*$ c #6485DF",
-"=$ c #6586DF",
-"-$ c #6787DF",
-";$ c #6888DF",
-">$ c #6A8ADF",
-",$ c #6C8BE0",
-"'$ c #6D8CE0",
-")$ c #6E8DE1",
-"!$ c #6F8DE1",
-"~$ c #708EE1",
-"{$ c #718FE0",
-"]$ c #728FE1",
-"^$ c #7390E0",
-"/$ c #738FE0",
-"($ c #7490E1",
-"_$ c #7590E1",
-":$ c #7591E1",
-"<$ c #7592E1",
-"[$ c #7692E2",
-"}$ c #7794E2",
-"|$ c #7894E3",
-"1$ c #7996E3",
-"2$ c #7A96E5",
-"3$ c #7B98E6",
-"4$ c #7B9AE8",
-"5$ c #7C99E8",
-"6$ c #7C96E5",
-"7$ c #7D97E7",
-"8$ c #7C99E9",
-"9$ c #7B9AE9",
-"0$ c #7B9AEA",
-"a$ c #5B6DCF",
-"b$ c #305EC8",
-"c$ c #335ECE",
-"d$ c #305ECA",
-"e$ c #345FCF",
-"f$ c #3761D0",
-"g$ c #3A62D1",
-"h$ c #3C64D2",
-"i$ c #4066D3",
-"j$ c #466BD5",
-"k$ c #486ED6",
-"l$ c #4A6ED6",
-"m$ c #4D71D8",
-"n$ c #4F72D9",
-"o$ c #5073D9",
-"p$ c #4F72D8",
-"q$ c #5074D8",
-"r$ c #5276D9",
-"s$ c #587ADA",
-"t$ c #5B7CDB",
-"u$ c #5D7EDC",
-"v$ c #5F7FDD",
-"w$ c #6081DC",
-"x$ c #6182DD",
-"y$ c #6283DD",
-"z$ c #6484DE",
-"A$ c #6585DD",
-"B$ c #6787DE",
-"C$ c #6988DF",
-"D$ c #6A89DE",
-"E$ c #6C8ADF",
-"F$ c #6D8BDF",
-"G$ c #6E8CE0",
-"H$ c #6F8DE0",
-"I$ c #718EE0",
-"J$ c #728FDF",
-"K$ c #728FDE",
-"L$ c #7290E0",
-"M$ c #7190E0",
-"N$ c #7291E0",
-"O$ c #7191E0",
-"P$ c #7392E1",
-"Q$ c #7493E1",
-"R$ c #7594E1",
-"S$ c #7594E2",
-"T$ c #7694E2",
-"U$ c #7695E2",
-"V$ c #7A96E4",
-"W$ c #7895E2",
-"X$ c #7A96E2",
-"Y$ c #7A96E3",
-"Z$ c #7B96E3",
-"`$ c #7996E1",
-" % c #7C96E4",
-".% c #305EC9",
-"+% c #315ECC",
-"@% c #325ECE",
-"#% c #3760D0",
-"$% c #3962D1",
-"%% c #3E66D3",
-"&% c #4268D4",
-"*% c #446BD5",
-"=% c #476CD6",
-"-% c #496ED7",
-";% c #4B6FD7",
-">% c #4C70D7",
-",% c #4E71D7",
-"'% c #5074D7",
-")% c #5276D8",
-"!% c #5376D8",
-"~% c #5779DA",
-"{% c #597ADA",
-"]% c #5A7BDB",
-"^% c #5B7CDA",
-"/% c #5D7EDB",
-"(% c #5E7FDB",
-"_% c #6182DB",
-":% c #6384DC",
-"<% c #6586DD",
-"[% c #6686DC",
-"}% c #6887DD",
-"|% c #6988DD",
-"1% c #6A8ADE",
-"2% c #6B8BDE",
-"3% c #6C8CDE",
-"4% c #6E8DDF",
-"5% c #6E8CDF",
-"6% c #6D8DDF",
-"7% c #6C8BDF",
-"8% c #6F8DDF",
-"9% c #718FDF",
-"0% c #7290DF",
-"a% c #7391E0",
-"b% c #7491E0",
-"c% c #7292E1",
-"d% c #3959C5",
-"e% c #345BC5",
-"f% c #315EC8",
-"g% c #355BC5",
-"h% c #325EC8",
-"i% c #315ECB",
-"j% c #345DCC",
-"k% c #335ECD",
-"l% c #345ECD",
-"m% c #355FCE",
-"n% c #3862D0",
-"o% c #3E66D2",
-"p% c #456BD5",
-"q% c #476CD5",
-"r% c #4B6ED7",
-"s% c #4B6FD6",
-"t% c #4B6FD5",
-"u% c #4D71D6",
-"v% c #5073D7",
-"w% c #5174D7",
-"x% c #5275D8",
-"y% c #5577D8",
-"z% c #5678D8",
-"A% c #5779D9",
-"B% c #587AD8",
-"C% c #597CD9",
-"D% c #5B7DD9",
-"E% c #5D7FDA",
-"F% c #5F80DB",
-"G% c #6182DC",
-"H% c #6484DC",
-"I% c #6585DC",
-"J% c #6787DD",
-"K% c #6988DE",
-"L% c #6B8ADE",
-"M% c #6B8ADF",
-"N% c #6989DE",
-"O% c #6B89DE",
-"P% c #6E8BDF",
-"Q% c #708CDE",
-"R% c #708DDF",
-"S% c #708FDF",
-"T% c #728EDF",
-"U% c #6F8EDD",
-"V% c #728EDD",
-"W% c #7390DF",
-"X% c #7490DF",
-"Y% c #335DC8",
-"Z% c #3759C5",
-"`% c #3859C5",
-" & c #335EC8",
-".& c #325DCA",
-"+& c #345CCB",
-"@& c #335DCC",
-"#& c #345DCD",
-"$& c #355FCD",
-"%& c #3861D0",
-"&& c #3B64D1",
-"*& c #3E65D2",
-"=& c #4168D3",
-"-& c #456AD5",
-";& c #4B6ED5",
-">& c #4C6FD4",
-",& c #4D70D5",
-"'& c #4F72D6",
-")& c #5173D6",
-"!& c #5375D7",
-"~& c #5476D8",
-"{& c #5577D7",
-"]& c #5477D8",
-"^& c #5677D8",
-"/& c #5879D9",
-"(& c #597AD9",
-"_& c #5C7DDA",
-":& c #6080DC",
-"<& c #6080DB",
-"[& c #6181DC",
-"}& c #6282DC",
-"|& c #6383DD",
-"1& c #6484DD",
-"2& c #6686DE",
-"3& c #6685DE",
-"4& c #6786DE",
-"5& c #6687DE",
-"6& c #6887DE",
-"7& c #6987DE",
-"8& c #6788DF",
-"9& c #6785DF",
-"0& c #6B89DF",
-"a& c #6C89DF",
-"b& c #6F8DDD",
-"c& c #6D8CDE",
-"d& c #445BBB",
-"e& c #3759BE",
-"f& c #375AC6",
-"g& c #355CC8",
-"h& c #345CCA",
-"i& c #355ECC",
-"j& c #365FCD",
-"k& c #3761CE",
-"l& c #3A63D0",
-"m& c #3D65D1",
-"n& c #466AD4",
-"o& c #476BD4",
-"p& c #486CD3",
-"q& c #4A6ED4",
-"r& c #4B6ED4",
-"s& c #4E71D6",
-"t& c #4F71D5",
-"u& c #5072D6",
-"v& c #5274D7",
-"w& c #5273D7",
-"x& c #5274D6",
-"y& c #5476D7",
-"z& c #5779D8",
-"A& c #587AD9",
-"B& c #5A7CDA",
-"C& c #5C7DDB",
-"D& c #5D7EDA",
-"E& c #6081DA",
-"F& c #6181DB",
-"G& c #6283DC",
-"H& c #6483DD",
-"I& c #6483DE",
-"J& c #6585DE",
-"K& c #6786DF",
-"L& c #6886DE",
-"M& c #6887DF",
-"N& c #6987DF",
-"O& c #6A88DF",
-"P& c #6786E0",
-"Q& c #6A86DE",
-"R& c #6B89E0",
-"S& c #365BC8",
-"T& c #365CC8",
-"U& c #375DCA",
-"V& c #375FCB",
-"W& c #3860CD",
-"X& c #3C63D0",
-"Y& c #4167D2",
-"Z& c #4268D2",
-"`& c #4368D2",
-" * c #4367D2",
-".* c #4568D2",
-"+* c #466AD2",
-"@* c #496CD3",
-"#* c #4A6DD3",
-"$* c #4A6DD4",
-"%* c #4D70D4",
-"&* c #4F72D5",
-"** c #4C70D4",
-"=* c #4E72D5",
-"-* c #5173D5",
-";* c #5375D6",
-">* c #597BDA",
-",* c #5B7DDA",
-"'* c #5C7EDB",
-")* c #5D7FDB",
-"!* c #5E80DB",
-"~* c #5E81DA",
-"{* c #5F81DB",
-"]* c #5F82DB",
-"^* c #6384DD",
-"/* c #6384DE",
-"(* c #6585DF",
-"_* c #6486E0",
-":* c #6583DD",
-"<* c #6386E0",
-"[* c #6686E0",
-"}* c #6B86DD",
-"|* c #6D86DD",
-"1* c #6086E0",
-"2* c #5573CD",
-"3* c #3959C3",
-"4* c #3959C4",
-"5* c #3759C0",
-"6* c #375BC7",
-"7* c #365CC7",
-"8* c #395FCC",
-"9* c #3B62CE",
-"0* c #3E64D0",
-"a* c #4066D1",
-"b* c #4166D1",
-"c* c #4064CF",
-"d* c #4065CF",
-"e* c #4266D0",
-"f* c #4468D1",
-"g* c #4569D1",
-"h* c #476BD2",
-"i* c #466AD1",
-"j* c #476AD2",
-"k* c #456AD1",
-"l* c #496DD2",
-"m* c #4A6FD3",
-"n* c #496ED2",
-"o* c #4B70D4",
-"p* c #4D71D4",
-"q* c #4E72D4",
-"r* c #5073D4",
-"s* c #5174D5",
-"t* c #5175D5",
-"u* c #5276D6",
-"v* c #5377D6",
-"w* c #5478D7",
-"x* c #5579D7",
-"y* c #567AD8",
-"z* c #577BD9",
-"A* c #597CD8",
-"B* c #5A7DD9",
-"C* c #5A7ED9",
-"D* c #5B7FDA",
-"E* c #5C80DA",
-"F* c #5D80DA",
-"G* c #5E81DB",
-"H* c #5D80DB",
-"I* c #6082DC",
-"J* c #6183DD",
-"K* c #6183DE",
-"L* c #6082DB",
-"M* c #6282DE",
-"N* c #6682DE",
-"O* c #6583DE",
-"P* c #3759BF",
-"Q* c #375AC2",
-"R* c #375AC1",
-"S* c #375AC4",
-"T* c #395DCA",
-"U* c #3A5ECA",
-"V* c #3C60CC",
-"W* c #3D61CD",
-"X* c #3D61CC",
-"Y* c #3C61CD",
-"Z* c #3E62CD",
-"`* c #3F64CE",
-" = c #4266CF",
-".= c #4468D0",
-"+= c #4267CF",
-"@= c #4166CE",
-"#= c #4065CE",
-"$= c #4166CD",
-"%= c #4267CE",
-"&= c #456AD0",
-"*= c #4368CE",
-"== c #4468CF",
-"-= c #4569D0",
-";= c #486BD1",
-">= c #4B6FD3",
-",= c #4C70D3",
-"'= c #4F73D4",
-")= c #5275D5",
-"!= c #5477D6",
-"~= c #577BD7",
-"{= c #587CD8",
-"]= c #577CD8",
-"^= c #597DD9",
-"/= c #5A7DDA",
-"(= c #597DDA",
-"_= c #587CDA",
-":= c #5A7EDA",
-"<= c #567BD8",
-"[= c #557AD9",
-"}= c #567BD9",
-"|= c #577CD9",
-"1= c #587DD9",
-"2= c #587ED9",
-"3= c #577ED8",
-"4= c #587DD8",
-"5= c #587ED8",
-"6= c #567ED7",
-"7= c #526ABD",
-"8= c #3759C1",
-"9= c #385BC7",
-"0= c #395CC8",
-"a= c #3B5DC9",
-"b= c #3B5ECA",
-"c= c #3A5FCA",
-"d= c #3B60CC",
-"e= c #3C61CC",
-"f= c #3D62CD",
-"g= c #3E63CD",
-"h= c #3C61CB",
-"i= c #3C61CA",
-"j= c #3D62CB",
-"k= c #3F64CC",
-"l= c #4065CD",
-"m= c #4669D0",
-"n= c #476AD0",
-"o= c #496BD1",
-"p= c #4A6DD2",
-"q= c #4B6ED2",
-"r= c #4D71D3",
-"s= c #4E73D4",
-"t= c #4F74D4",
-"u= c #5075D5",
-"v= c #5276D5",
-"w= c #5377D7",
-"x= c #5278D7",
-"y= c #5277D6",
-"z= c #5378D7",
-"A= c #5379D8",
-"B= c #5379D9",
-"C= c #5278D8",
-"D= c #5178D7",
-"E= c #3355C0",
-"F= c #3556C1",
-"G= c #395AC6",
-"H= c #385AC7",
-"I= c #395BC7",
-"J= c #395EC9",
-"K= c #395FCA",
-"L= c #3B60CA",
-"M= c #3B60CB",
-"N= c #375DC7",
-"O= c #385EC8",
-"P= c #395FC9",
-"Q= c #3A60CA",
-"R= c #3D63CC",
-"S= c #4367CF",
-"T= c #476BD1",
-"U= c #4A6ED2",
-"V= c #4B6FD2",
-"W= c #4C6FD2",
-"X= c #4D70D1",
-"Y= c #4E71D2",
-"Z= c #4E72D2",
-"`= c #4E74D4",
-" - c #4E75D5",
-".- c #4E75D4",
-"+- c #4F75D3",
-"@- c #5075D2",
-"#- c #5075D3",
-"$- c #5177D7",
-"%- c #5178D8",
-"&- c #4F75D5",
-"*- c #5076D5",
-"=- c #4F76D6",
-"-- c #5279D9",
-";- c #3C52B1",
-">- c #3656C3",
-",- c #3757C5",
-"'- c #3758C6",
-")- c #3759C6",
-"!- c #375BC6",
-"~- c #385CC7",
-"{- c #385DC8",
-"]- c #365CC6",
-"^- c #355BC6",
-"/- c #355CC6",
-"(- c #365DC7",
-"_- c #375EC8",
-":- c #375CC6",
-"<- c #385EC6",
-"[- c #3A5FC7",
-"}- c #3C60C8",
-"|- c #3D61C9",
-"1- c #3E62CA",
-"2- c #4063CC",
-"3- c #4165CE",
-"4- c #4268D0",
-"5- c #4269D1",
-"6- c #436AD2",
-"7- c #446AD2",
-"8- c #456BD2",
-"9- c #496CD1",
-"0- c #4C6CD0",
-"a- c #4D6CCF",
-"b- c #4E6DD0",
-"c- c #4F6ECF",
-"d- c #4E6FCF",
-"e- c #4C70CF",
-"f- c #4A71D0",
-"g- c #4F6FCF",
-"h- c #4B71D0",
-"i- c #4A72D1",
-"j- c #4B73D4",
-"k- c #4F70D0",
-"l- c #4C73D3",
-"m- c #4C73D6",
-"n- c #4B72D2",
-"o- c #4B71D1",
-"p- c #4C73D7",
-"q- c #3354C0",
-"r- c #3152BE",
-"s- c #3052BE",
-"t- c #3051BF",
-"u- c #2E4FBF",
-"v- c #2E4FBE",
-"w- c #2E50BF",
-"x- c #2F50BF",
-"y- c #3156C4",
-"z- c #2F56C5",
-"A- c #2E57C5",
-"B- c #2F57C5",
-"C- c #3057C6",
-"D- c #3258C6",
-"E- c #3459C7",
-"F- c #365AC7",
-"G- c #385BC8",
-"H- c #3B5DCA",
-"I- c #3B5DCB",
-"J- c #3C5ECC",
-"K- c #3C60CD",
-"L- c #3C62CE",
-"M- c #3D65D0",
-"N- c #3D66D1",
-"O- c #4166D2",
-"P- c #4667D2",
-"Q- c #4A67D1",
-"R- c #4C68D0",
-"S- c #4C69CF",
-"T- c #4D6BCE",
-"U- c #4E6DCD",
-"V- c #4E6ECE",
-"W- c #4E6DCE",
-"X- c #4970D0",
-"Y- c #4770D0",
-"Z- c #4B6BCE",
-"`- c #4A6CCE",
-" ; c #496DCF",
-".; c #476FD0",
-"+; c #4870D0",
-"@; c #486DCF",
-"#; c #242F79",
-"$; c #2F41AC",
-"%; c #2040B8",
-"&; c #2041B8",
-"*; c #2243B3",
-"=; c #2243B8",
-"-; c #2343B8",
-";; c #2444B8",
-">; c #2445B8",
-",; c #2445B6",
-"'; c #2445B7",
-"); c #2444B9",
-"!; c #2949BE",
-"~; c #2649BF",
-"{; c #234BBF",
-"]; c #224CBF",
-"^; c #224AC0",
-"/; c #244CC0",
-"(; c #254DC0",
-"_; c #254DC1",
-":; c #264DC2",
-"<; c #274EC3",
-"[; c #274CC3",
-"}; c #274DC4",
-"|; c #254DC5",
-"1; c #214EC5",
-"2; c #204FC6",
-"3; c #1F50C8",
-"4; c #2151C9",
-"5; c #2B53C8",
-"6; c #3154C7",
-"7; c #3255C6",
-"8; c #2F57C7",
-"9; c #2C58C9",
-"0; c #2D59CA",
-"a; c #2D58C9",
-"b; c #2E5BCC",
-"c; c #325ECC",
-"d; c #325ECB",
-"e; c #1F40B1",
-"f; c #1F40B2",
-"g; c #1F40B3",
-"h; c #2A44BD",
-"i; c #2845BE",
-"j; c #2745BE",
-"k; c #2646BF",
-"l; c #2546BE",
-"m; c #2347BF",
-"n; c #2147BF",
-"o; c #2048C0",
-"p; c #1D48C0",
-"q; c #1C48C0",
-"r; c #1B47C0",
-"s; c #1C48BF",
-"t; c #1E49BE",
-"u; c #214ABD",
-"v; c #244CBD",
-"w; c #264DBE",
-"x; c #254EC0",
-"y; c #214FC2",
-"z; c #1B51C5",
-"A; c #1C51C7",
-"B; c #2250C8",
-"C; c #2A52C8",
-"D; c #3254C6",
-"E; c #3355C5",
-"F; c #3154C8",
-"G; c #3355C6",
-"H; c #2F57C8",
-"I; c #2E58C9",
-"J; c #2E59C9",
-"K; c #3059C9",
-"L; c #2040B6",
-"M; c #2743BB",
-"N; c #2844BC",
-"O; c #2743BD",
-"P; c #2844BE",
-"Q; c #2844BD",
-"R; c #2346BE",
-"S; c #2047BF",
-"T; c #1E48C0",
-"U; c #1D47C0",
-"V; c #1D49BF",
-"W; c #1F49BF",
-"X; c #204ABE",
-"Y; c #254DBF",
-"Z; c #234EC0",
-"`; c #2050C1",
-" > c #1C51C3",
-".> c #1F51C6",
-"+> c #2651C8",
-"@> c #2D53C7",
-"#> c #3155C6",
-"$> c #3155C7",
-"%> c #3355C7",
-"&> c #3254C7",
-"*> c #1E40B1",
-"=> c #2141B8",
-"-> c #2442B9",
-";> c #2744BB",
-">> c #2945BB",
-",> c #2A45BB",
-"'> c #2944BA",
-")> c #2745BB",
-"!> c #2545BC",
-"~> c #2246BD",
-"{> c #2047BE",
-"]> c #1F47BD",
-"^> c #1D48BE",
-"/> c #1E49C0",
-"(> c #1F4AC0",
-"_> c #214BBF",
-":> c #244CBE",
-"<> c #254DBE",
-"[> c #244DBE",
-"}> c #224FBF",
-"|> c #2051C1",
-"1> c #2151C3",
-"2> c #2252C5",
-"3> c #2151C1",
-"4> c #2851C6",
-"5> c #2A50C6",
-"6> c #2E54C6",
-"7> c #1F51C2",
-"8> c #1D52C5",
-"9> c #2651C9",
-"0> c #2950C7",
-"a> c #2D40A5",
-"b> c #2040B0",
-"c> c #1F40B0",
-"d> c #223CAE",
-"e> c #233CAE",
-"f> c #253BAC",
-"g> c #253BAD",
-"h> c #233CB0",
-"i> c #213EB2",
-"j> c #1F3FB4",
-"k> c #1E40B6",
-"l> c #1F3FB7",
-"m> c #1E3EB8",
-"n> c #1F3FB8",
-"o> c #2040B7",
-"p> c #2141B6",
-"q> c #2140B7",
-"r> c #2241B6",
-"s> c #2342B5",
-"t> c #2442B6",
-"u> c #2543B5",
-"v> c #2643B4",
-"w> c #2544B6",
-"x> c #2346B8",
-"y> c #2247B9",
-"z> c #2048BC",
-"A> c #1F48BF",
-"B> c #2049C0",
-"C> c #214AC0",
-"D> c #224BBF",
-"E> c #234CBE",
-"F> c #244DBF",
-"G> c #234CBF",
-"H> c #264DC0",
-"I> c #274EBF",
-"J> c #264DBF",
-"K> c #254EBF",
-"L> c #2050C0",
-"M> c #1F51C1",
-"N> c #1E42A4",
-"O> c #263BA6",
-"P> c #253BA7",
-"Q> c #253CA7",
-"R> c #1E41A5",
-"S> c #1F40AF",
-"T> c #273AAC",
-"U> c #1E40B0",
-"V> c #1F40B5",
-"W> c #1F40B6",
-"X> c #1F40B8",
-"Y> c #1E40B8",
-"Z> c #1F3EB8",
-"`> c #203FB7",
-" , c #2240B6",
-"., c #2341B7",
-"+, c #2345B9",
-"@, c #2147BB",
-"#, c #2148BA",
-"$, c #2049BB",
-"%, c #2049BD",
-"&, c #2049BF",
-"*, c #224BBE",
-"=, c #244DBD",
-"-, c #244CBF",
-";, c #182969",
-">, c #273BAD",
-",, c #2739AB",
-"', c #263AAC",
-"), c #243CAE",
-"!, c #233DAE",
-"~, c #213EAF",
-"{, c #1F3FB0",
-"], c #2040B4",
-"^, c #1F3FB6",
-"/, c #1E3EB7",
-"(, c #2240B7",
-"_, c #2341B6",
-":, c #2543B4",
-"<, c #2644B3",
-"[, c #2544B5",
-"}, c #2545B5",
-"|, c #2547B6",
-"1, c #2548B7",
-"2, c #2349BA",
-"3, c #1F49BE",
-"4, c #2149BD",
-"5, c #2049BE",
-"6, c #214BBE",
-"7, c #2249BE",
-"8, c #234CBD",
-"9, c #2149BE",
-"0, c #1E49BF",
-"a, c #253BA9",
-"b, c #253BAB",
-"c, c #263AAB",
-"d, c #213DAF",
-"e, c #203EAF",
-"f, c #1D40AF",
-"g, c #1D40B0",
-"h, c #1E40B4",
-"i, c #2241B7",
-"j, c #2643B6",
-"k, c #2744B5",
-"l, c #2643B5",
-"m, c #2346B6",
-"n, c #2147B7",
-"o, c #2644B6",
-"p, c #2247B7",
-"q, c #2248B8",
-"r, c #2647B7",
-"s, c #2549B7",
-"t, c #2645B7",
-"u, c #2148B8",
-"v, c #2847B6",
-"w, c #2549B6",
-"x, c #2849B6",
-"y, c #2049B7",
-"z, c #2A49B5",
-"A, c #243BA4",
-"B, c #253BA5",
-"C, c #253BA6",
-"D, c #263AA7",
-"E, c #263AA8",
-"F, c #2739AA",
-"G, c #243CAD",
-"H, c #223DAE",
-"I, c #1F3EAF",
-"J, c #1E3FB0",
-"K, c #1D40B1",
-"L, c #1E3FB1",
-"M, c #1F3FB3",
-"N, c #1F3FB5",
-"O, c #2140B6",
-"P, c #2140B8",
-"Q, c #2744B4",
-"R, c #2746B6",
-"S, c #2947B6",
-"T, c #2946B5",
-"U, c #2A48B6",
-"V, c #3551A8",
-"W, c #1F399C",
-"X, c #143D9F",
-"Y, c #263BA5",
-"Z, c #273BA8",
-"`, c #273BAA",
-" ' c #263AAD",
-".' c #233CAD",
-"+' c #213DAE",
-"@' c #203FB2",
-"#' c #2342B6",
-"$' c #2443B6",
-"%' c #2543B6",
-"&' c #2644B5",
-"*' c #133D9E",
-"=' c #263BA7",
-"-' c #263BA9",
-";' c #273BA9",
-">' c #263AAA",
-",' c #2539AB",
-"'' c #2639AB",
-")' c #253AAC",
-"!' c #243BAD",
-"~' c #223DAF",
-"{' c #203FB0",
-"]' c #2040B1",
-"^' c #2140B3",
-"/' c #2543B1",
-"(' c #2744AF",
-"_' c #1A3CA0",
-":' c #1D3BA2",
-"<' c #233BA4",
-"[' c #263AA5",
-"}' c #253AA5",
-"|' c #263AA6",
-"1' c #263BA4",
-"2' c #243BA5",
-"3' c #263BA8",
-"4' c #223EAF",
-"5' c #3B4CA5",
-"6' c #1D379A",
-"7' c #1E389C",
-"8' c #1E399F",
-"9' c #1F3BA2",
-"0' c #1F3BA3",
-"a' c #213BA4",
-"b' c #233AA3",
-"c' c #243AA3",
-"d' c #2539A4",
-"e' c #253AA6",
-"f' c #243BA7",
-"g' c #253CAA",
-"h' c #253CAC",
-"i' c #253CAD",
-"j' c #253CAE",
-"k' c #243DAE",
-"l' c #213FAF",
-"m' c #223FAF",
-"n' c #2040AF",
-"o' c #253D93",
-"p' c #1D3894",
-"q' c #1F379A",
-"r' c #1E389B",
-"s' c #1D399C",
-"t' c #1C3A9D",
-"u' c #1B3A9D",
-"v' c #183B9E",
-"w' c #163C9E",
-"x' c #153C9E",
-"y' c #163B9D",
-"z' c #173B9D",
-"A' c #193A9D",
-"B' c #1C3A9E",
-"C' c #1F3AA1",
-"D' c #223AA4",
-"E' c #253BA8",
-"F' c #273BA7",
-"G' c #263CAB",
-"H' c #263CAC",
-"I' c #243EAE",
-"J' c #273BAC",
-"K' c #2A3795",
-"L' c #1F389B",
-"M' c #1D389B",
-"N' c #1C399C",
-"O' c #1B399C",
-"P' c #1A3A9D",
-"Q' c #1D399B",
-"R' c #1B399B",
-"S' c #1A3A9C",
-"T' c #1B3A9F",
-"U' c #1D3AA0",
-"V' c #203BA2",
-"W' c #203BA3",
-"X' c #2639A6",
-"Y' c #1B3692",
-"Z' c #1C3794",
-"`' c #1D3796",
-" ) c #1E3898",
-".) c #1E389A",
-"+) c #1F399B",
-"@) c #1A399C",
-"#) c #193A9E",
-"$) c #1A3BA0",
-"%) c #1C3BA2",
-"&) c #1D3CA3",
-"*) c #203CA4",
-"=) c #223BA5",
-"-) c #3C4699",
-";) c #2B4595",
-">) c #1C3793",
-",) c #1D3895",
-"') c #1E3897",
-")) c #1F3998",
-"!) c #1F3999",
-"~) c #1F399A",
-"{) c #1E399C",
-"]) c #1C3B9E",
-"^) c #1D3BA0",
-"/) c #1E3CA2",
-"() c #223CA5",
-"_) c #243CA6",
-":) c #596FA9",
-"<) c #3B4894",
-"[) c #314993",
-"}) c #29499F",
-"|) c #28489E",
-"1) c #2B4BA1",
-"2) c #2C4BA1",
-"3) c #2D4CA2",
-"4) c #2E4CA3",
-"5) c #2F4CA4",
-"6) c #2E4CA4",
-"7) c #2F4DA3",
-"8) c #2F4DA4",
-"9) c #D3D5D2",
-"0) c #3B4794",
-"a) c #314791",
-"b) c #304892",
-"c) c #304893",
-"d) c #2F4995",
-"e) c #2F4997",
-"f) c #2D4A9A",
-"g) c #2A4A9D",
-"h) c #294A9F",
-"i) c #284AA0",
-"j) c #294AA0",
-"k) c #2B4AA1",
-"l) c #2D4CA3",
-"m) c #C9CAC9",
-"n) c #455D9B",
-"o) c #242F78",
-"p) c #1B2F85",
-"q) c #C6C3C8",
-"r) c #B5B2B6",
-"s) c #B5B7B4",
-"t) c #B5B7B3",
-"u) c #B5B2B5",
-"v) c #B5B3B4",
-"w) c #B5B5B4",
-"x) c #B5B6B3",
-"y) c #B5B4B4",
-"z) c #B5B3B5",
-"A) c #B5B4B5",
-"B) c #B5B5B5",
-"C) c #B5B5B3",
-"D) c #B5B5B6",
-"E) c #BAC3BE",
-"F) c #B9C3BD",
-"G) c #C1C3C4",
-"H) c #BFC3C2",
-"I) c #B9C3BE",
-"J) c #BBC3BF",
-"K) c #BDC3C1",
-"L) c #C0C3C3",
-"M) c #BEC3C1",
-"N) c #C2C3C5",
-"O) c #E6E3E8",
-"P) c #E0E2DF",
-"Q) c #E1E1E1",
-"R) c #E2E1E3",
-"S) c #E4E1E6",
-"T) c #E4E2E7",
-"U) c #E4E2E6",
-"V) c #E3E3E4",
-"W) c #E2E3E3",
-"X) c #E1E3E2",
-"Y) c #E3E3E3",
-"Z) c #E3E3E2",
-"`) c #EBEDEA",
-" ! c #EAECE9",
-".! c #E9EBE8",
-"+! c #ECEEEB",
-". . + @ # $ $ $ $ $ $ $ % $ $ $ $ $ % $ $ $ $ $ $ % $ $ $ $ $ % $ $ $ $ $ $ $ $ $ % $ $ & * = - ; > , , ' ) ! ! ~ { ] ^ / ( _ : < [ } | | 1 2 3 3 4 4 4 4 4 4 4 5 6 4 4 4 5 6 7 8 9 4 5 6 7 8 9 6 7 8 9 ",
-"0 a b % $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ c d d d d $ $ $ $ $ c d e f g h i i i i j k l m n o p q r s t u v w x y z 4 A B C D 9 9 E 9 E F G H I F J K L L L L J K L L L L L L L L ",
-"@ % M N O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O O P Q R S T U V W X Y Z ` ...+.@.#.$.%.&.*.=.-.;.>.,.'.).!.~.{.].^./.(._.:.<.[.}.|.1.2.3.4.5.6.7.8.9.0.a.b.b.b.b.b.b.",
-"c.$ d.O e.f.g.g.g.h.g.g.g.g.g.h.h.g.g.g.g.g.h.h.g.g.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.W.X.Y.Z.`. +.+++@+#+$+@+$+%+&+*+=+$+-+;+>+,+'+)+!+;+>+,+~+,+>+,+~+,+",
-"$ {+N N f.f.f.f.h.h.h.g.f.f.h.h.h.h.g.f.f.h.h.h.h.]+^+/+(+h._+:+<+[+}+|+1+2+3+4+5+6+7+8+9+0+a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+w+x+y+z+A+B+.+C+D+E+D+F+G+H+C+I+F+G+J+K+L+H+F+G+J+K+L+H+J+H+J+H+",
-"{+{+N N M+M+h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.N+N+h.h.(+O+P+P+Q+R+S+T+U+V+W+X+Y+Z+`+ @.@+@@@#@$@%@&@*@=@-@;@>@,@'@)@!@~@{@]@^@/@(@_@:@<@[@[@y+}@|@1@A+1@2@3@ +2@4@2@5@C+D+6@D+7@5@C+D+6@I+C+D+6@I+",
-"{+{+8@N M+M+h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.9@9@0@N+a@b@c@d@e@f@g@h@i@j@k@l@m@n@o@p@q@r@s@t@u@v@w@x@y@z@A@B@q+r+C@D@E@F@G@H@_@I@J@K@<@L@M@N@O@P@Q@R@S@T@A+A+U@V@W@W@A+2@U@V@W@W@U@V@W@W@",
-"{+{+8@N f.M+h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.(+(+(+9@9@X@Y@Z@e@`@ #.#+#@###$#%#&#*#=#-#;#>#,#'#)#!#~#{#]#z@^#/#(#p+_#r+:#s+t+<#[#}#|#|#1#_@|#_@_@2#L@3#4#y+y+5#z+z+z+5#z+z+z+z+A+A+A+A+A+",
-"{+{+8@8@f.f.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.(+6#7#8#9#0#a#b#c#d#e#f#g#h#i#j#k#l#m#n#o#&@p#q#r#s#t#u#v#w#x#x#y#y#z#A#B#C#D#E#E#F#G#H#F#H#H#u+v+I#J#K#L#J@J@M#N#O#P#M#M#M#N#M#Q#Q#R#",
-"$ {+8@e.f.f.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.h.S#l.7#T#U#V#W#X#Y#Z#`# $f#g###.$+$@$#$$$$@%$&$*$=$-$;$>$,$'$)$!$~$~${$]$^$/$($($_$_$:$<$_$<$[$}$|$|$1$2$2$3$}#4$5$6$7$8$8$9$8$8$8$0$8$",
-"$ {+a$e.f.f.h.h.h.h.h.h.h.h.h.b$h.c$c$c$c$c$d$c$c$c$c$c$c$c$c$c$c$e$e$7#f$g$h$i$X#j$k$l$m$n$o$p$q$r$l@s$t$u$v$w$x$y$z$A$B$C$D$E$F$G$G$H$I$J$J$K$K$J$L$L$L$L$L$M$N$O$P$Q$R$S$T$U$1$V$T$W$X$Y$1$V$Y$Z$`$ %",
-"$ $ a$a$f.f.b$b$b$b$b$b$b$b$b$b$b$b$b$b$b$b$b$b$.%b$b$b$.%d$+%+%@%h.e$l.#%$%h$%%&%*%=%-%;%>%,%'%)%!% @ @~%{%]%^%/%(%w$_%:%<%[%}%|%D$1%2%3%4%5%4%4%6%5%5%4%4%4%5%7%5%8%9%L$0%a%a%a%P$b%P$P$z#z#z#P$c%c%c%",
-"$ $ 8@e.f.f.d%b$b$b$b$b$d%b$b$b$b$b$b$e%f%b$b$b$b$b$g%h%b$.%i%i%j%k%l%m%X@n%h$o%&%p%q%`#r%s%t%u%v%w%x%y% @z%A%B%C%D%E%F%G%:%H%I%[%J%}%K%|%D$K%D$D$L%M%M%M%M%M%D$N%O%i+P%j+Q%R%S%T%0%U%V%W%W%W%W%X%X%X%X%",
-"$ $ 8@8@f.f.d%d%b$b$b$b$d%d%b$b$b$h%Y%Z%Z%h%f%f%h%Y%`%`% &h%h%.&+&@&#&$&X@%&&&*&=&-&j$Z#+#;&>&,&'&)&)&!&~&{&]&^&/&(&^%_&(%:&<&[&}&|&1&A$A$2&3&4&4&5&B$6&7&B$7&8&9&6&7&0&a&a&i+i+i+b&a&a&j+U%c&U%j+U%c&U%",
-"$ $ 8@8@d&e&d%d%d%d%d%d%d%d%d%d%d%`%d%d%d%d%`%`%`%d%d%d%d%`%`%f&g&h&j%i&j&k&l&m&=&X#Y#n&o&p&q&r&>&s&t&t&u&v&w&x&y&{&z&A&B&C&D&(%(%F%F%E&F&}&}&|&G&|&H&1&I%I&A$1&}&z$z$J&K&L&M&N&O&0&P&Q&0&a&R&a&a&a&R&a&",
-"{+$ 8@8@e&e&d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%`%f&S&T&U&V&W&Y@X&Y&Z&`& *.*+*@*#*@*r&$*#*r&%*&***=*-*;*y&z%A%z&A&A&>*B&,*,*'*)*!*!*~*{*F&}&{*}&{*]*G%G%y$^*/*J&(*2&_*:*<*=$[*}*<*=$<*|*1*",
-"{+{+8@2*e&e&d%d%d%d%d%d%d%d%d%e&3*4*4*4*4*4*5*4*4*4*4*4*4*4*4*4*`%f&6*6*7*8*9*0*a*b*c*d*e*f*g*h*i*j*+*k*h*l*m*n*m*o*p*q*r*s*t*u*v*w*x*y*y*z*A*B*C*D*E*F*G*E*G*F*H*G*F*~*]*{*I*x$J*K*L*G%K*M*o#o#I&N*O*O*",
-"{+{+8@2*e&e&e&e&e&e&e&e&e&e&e&e&e&e&e&P*e&e&e&e&e&e&P*P*e&e&e&P*P*5*Q*R*S*T*U*V*W*X*Y*Z*`*d* =.=+=@=#=$=%=g@&=*===-=i*;=l*>=,=q*'=s*)=k@!=x*~={=]=^=/=(=_=:=(=<=<=]=[=}=|=]=]=1=2=3=|=4=5=2=2=2=3=6=6=6=",
-"{+{+7=e.e&e&e&e&e&e&e&e&e&e&e&e&e&e&e&e&e&e&e&e&e&e&e&e&e&e&e&e&e&e&P*P*8=9=0=a=b=U*c=d=e=f=e@#=g=h=i=i=j=k=k=l=%===m=n=o=p=q=,=r=s=t=u=v=v*w=x=x=y=z=z=A=z=A=B=C=B=D=C=B=x=B=B=B=B=B=B=B=B=B=B=B=B=B=B=",
-"{+{+7=7=e&e&e&e&E=E=e&e&e&e&E=E=E=e&e&e&e&E=E=E=e&e&e&e&E=E=e&e&e&e&E=E=E=F=d%G=G=H=I=J=K=L=M=R+}+N=O=P=Q=j=i=h=R=e@@=S=-=T=h@l*U=V=W=X=Y=Z=`= - - -.-+-@- -#-$-%-$-&-*-$-=-%-----C=$-%---------B=B=B=B=",
-"{+{+7=7=;-;-E=E=E=E=E=E=E=E=E=E=E=E=E=E=E=E=E=E=E=E=E=E=E=E=E=E=E=E=E=E=E=E=>-,-'-)-!-6*~-{-{-]-^-/-/-(-_-:-N=<-[-}-|-1-2-3- =4-5-6-7-8-9-0-0-a-b-c-d-e-f-g-h-h-i-j-k-h-h-i-j-l-m-n-o-i-j-l-m-n-j-l-p-n-",
-"{+{+7=7=;-;-E=E=E=E=E=E=E=E=q-r-s-t-t-u-u-v-v-v-u-w-x-u-u-u-u-u-u-u-u-v-v-u-u-u-u-u-v-v-u-u-u-u-v-v-u-y-z-A-B-C-D-E-E-F-G-H-I-J-K-L-M-N-O-P-Q-R-S-T-U-U-V-W-V-e-X-Y-Z-`- ;.;Y-N N +;@;.;Y-N N N N N N N ",
-"#;#;d&d&$;$;%;%;%;%;%;%;%;%;&;*;=;-;-;-;;;>;,;>;>;>;;;>;>;>;>;>;>;>;>;>;';);>;>;>;>;>;';>;>;>;>;>;';);!;~;{;];^;/;(;_;_;:;<;[;};};|;1;2;3;4;5;6;7;8;9;9;0;a;0;0;b;h.a;0;0;b;h.c;h.d;0;b;h.c;h.d;h.c;h.d;",
-"#;#;;-;-$;$;e;e;e;e;e;e;e;e;e;e;e;f;f;f;f;e;e;e;f;f;f;f;f;f;f;f;f;f;f;f;g;%;f;f;f;f;f;g;f;f;f;f;f;g;%;h;i;j;k;l;m;n;o;p;q;r;r;s;t;u;v;w;x;y;z;A;B;C;6;D;E;F;G;G;H;I;F;G;G;H;I;J;J;K;G;H;I;J;J;K;I;J;J;K;",
-"#;#;;-;-$;$;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;L;e;e;e;e;e;e;e;e;e;e;e;e;L;M;N;O;P;Q;i;i;k;R;S;T;U;q;q;V;W;X;{;Y;Z;`; >.>+>@>#>+>$>6;#>#>+>%>&>G;G;G;G;G;&>G;G;G;G;G;G;G;G;G;",
-"#;#;d.;-$;$;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;*>e;e;e;e;e;e;e;e;e;e;e;e;*>=>->;>>>,>'>'>)>!>~>{>]>^>^>V;V;/>(>_>:><>[>}>|>1>2>3>2>4>5>6>7>8>9>0>G;G;G;G;9>0>G;G;G;G;G;G;G;G;",
-"#;#;d.d.a>a>e;e;e;e;e;e;e;e;e;e;b>b>c>c>c>c>c>b>e;e;e;e;e;e;e;e;e;e;e;e;e;e;d>e>f>g>h>i>j>k>l>l>m>m>n>n>o>o>p>q>r>r>s>t>u>v>v>u>w>';x>y>z>t;A>B>C>D>E>E>F>G>F>H>H>I>F>Y;J>w;K>L>K>M>J>w;K>L>K>M>K>L>K>M>",
-"#;#;d.d.a>a>N>e;N>O>O>O>N>e;N>O>O>P>Q>R>S>R>Q>O>O>O>N>e;N>O>O>O>N>e;N>N>O>T>e;e;e;U>U>U>U>f;V>W>o>o>o>o>X>X>Y>Y>n>n>Z>Z>`> ,.,t>t>u>u>w>+,@,#,$,%,A>&,*,=,B>[>-,w;<>C>[>-,w;w;w;w;w;-,w;w;w;w;w;w;w;w;w;",
-"#;;,;-;-a>a>N>N>N>O>O>O>N>N>N>O>O>O>O>N>N>N>O>O>O>O>N>N>N>O>O>O>N>N>N>N>O>>,,,,,,,',g>),!,~,{,{,*>U>e;f;],o>%;o>^,^,/,/,l>q>(,_,t>u>:,<,v>[,},|,1,2,%,%,3,4,5,6,7,8,9,5,6,0,G>G>Y;G>6,0,G>G>Y;G>G>G>Y;G>",
-";,;,;-;-O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>P>a,b,',',c,c,f>),e>d,e,{,{,U>U>f,f,U>U>g,g,*>g;h,^,^,`>`>q>i,t>j,k,k,l,w>m,n,o,p,q,r,s,t,p,u,v,w,x,y,z,u,v,w,x,y,z,w,x,y,z,",
-";,;,b b O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>A,A,A,B,C,D,E,F,c,',g>G,!,H,~,e,{,I,J,J,K,K,U>f,f,J,L,M,N,L;O,i,P,.,l,Q,k,k,k,k,k,k,R,v,k,k,k,R,v,S,T,U,k,R,v,S,T,U,v,S,T,U,",
-";,;,b V,W,W,X,X,O>X,X,X,X,X,O>X,X,X,X,X,X,O>X,X,X,X,X,X,O>X,X,X,X,X,O>X,X,O>O>O>O>B,B,B,B,Y,O>O>Z,`,T>T> '',g>.'+'e,{,{,e,+'+'e,e,{,J,K,e;@'N,O,#'$'%'%'j,%'j,&'k,k,%'j,&'k,k,k,k,k,&'k,k,k,k,k,k,k,k,k,",
-";,;,b V,W,W,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,*'O>O>O>O>O>O>O>O>B,B,A,A,B,C,='-'`,;'>'>',''')'!'!'e>e>~'~'~,~,{'{,*>*>e;]']']']']']'^'/']']']'^'/':,(':,]'^'/':,(':,/':,(':,",
-";,;,V,V,W,W,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,_':'<'['}'|'|'O>O>O>O>O>O>O>Y,Y,1'1'B,B,2'2'C,3'-'>'c,)')'!'),4'{'e;]'e;*>*>e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;e;",
-";,;,5'5'W,W,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,W,6'6'6'7'8'9'0'a'b'c'd'd'}'}'O>O>O>O>O>O>O>O>Y,1'1'['['e'e'f'g'h'i'j'k'G,),!,l'j'm'n'b>b>),m'b>e;e;e;e;e;b>e;e;e;e;e;e;e;e;e;",
-";,;,b b o'o'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'W,q'q'q'r's't'u'v'w'x'y'z'A'B'C'D'2'2'B,B,O>O>O>O>O>O>O>O>O>O>O>Y,Y,C,C,='='='E'F'3'3'3'G'Z,='F'F'G'H'I'J'F'F'G'H'I'J'G'H'I'J'",
-";,;,b b K'K'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'W,W,W,W,W,L'L'q'r'M'N'O'P'u'N's'Q'R'S'A'T'U'C'V'9'0'W'D'}'X'|'O>O>B,B,O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>",
-";,;,b b K'K'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'p'Y'Y'Y'Z'`' ).)+)+)+)W,W,W,W,L'L'q'q'r'r's'M'N'P'@)A'#)$)%)&)*)=)B,|'|'O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>O>",
-"{+;,$ -);)K'p'p'o'p'p'p'p'p'o'p'p'p'p'p'p'o'p'p'p'p'p'p'o'p'p'p'p'p'o'o'p'p'p'p'p'p'p'p'p'p'>)>)Y'Y'>)Z',)')))!)~)+)W,W,W,W,W,W,W,W,W,W,W,L'L'{)s't'])^)/)])/)/)O>()])/)/)O>()O>_)O>/)O>()O>_)O>()O>_)O>",
-":);,;,;)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)[)M M M M M M M M M M M M M M M M M M })})|)|)})M M 1)2)3)4)5)6)6)6)7)7)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)",
-"9)#;;,;,$ -)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)<)0)a)a)a)b)c)d)e)f)g)h)i)i)j)j)M M M M M M M M M M M })})})})M k)k)M M k)l)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)",
-"+ 9)m)n)$ #;#;#;#;#;#;#;#;#;#;#;#;#;#;#;#;#;#;#;#;#;#;#;#;#;#;#;#;#;#;#;#;o)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)p)",
-"+ + 9)a m)q)r)s)r)s)r)s)r)s)r)r)s)r)s)r)s)r)r)s)r)s)r)s)r)s)r)s)r)s)r)s)r)t)u)v)w)x)x)w)y)z)A)A)B)B)B)B)w)w)C)C)w)w)B)B)B)B)B)w)w)w)w)B)B)B)B)B)B)B)B)B)B)B)B)B)B)B)B)B)B)B)B)B)D)B)B)B)B)B)D)B)B)B)D)B)",
-". + + 9)9)9)q)E)q)E)q)E)q)E)q)q)E)q)E)q)E)q)q)E)q)E)q)E)q)E)q)E)q)E)q)E)q)F)G)H)E)I)J)K)H)L)L)L)L)L)L)L)H)H)M)M)H)H)L)L)G)L)L)H)H)H)H)L)L)L)L)L)L)L)L)L)L)L)L)L)L)L)L)L)L)L)L)L)N)L)L)L)L)L)N)L)L)L)N)L)",
-". . 0 . + O)P)O)P)O)P)O)P)O)P)P)O)P)O)P)O)P)P)O)P)O)P)O)P)O)P)O)P)O)P)O)P)O)Q)R)S)T)U)V)W)X)W)W)V)V)V)V)V)V)V)V)Y)Y)Z)Z)Y)Z)Z)Y)Y)V)V)V)V)V)V)V)V)V)V)V)V)V)V)V)V)V)V)V)V)V)V)V)Y)V)V)V)V)V)Y)V)V)V)Y)V)",
-". . . 0 0 0 . 0 0 0 + 0 + 0 + 0 + 0 + 0 + 0 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 0 `) !+ + + .! !`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)`)+!`)`)`)`)`)+!`)`)`)+!`)"};
-
-
-static char * listviewhighcornerright_xpm[] = {
-"100 46 780 2",
-" c None",
-". c #6A779D",
-"+ c #6C789C",
-"@ c #6C789D",
-"# c #6B789D",
-"$ c #6A779E",
-"% c #66759E",
-"& c #64749E",
-"* c #63749E",
-"= c #61739D",
-"- c #576D9B",
-"; c #556C9C",
-"> c #4D679D",
-", c #4A649D",
-"' c #49629D",
-") c #465E9C",
-"! c #40579C",
-"~ c #3B5394",
-"{ c #2C4E97",
-"] c #314993",
-"^ c #2B4595",
-"/ c #1B4296",
-"( c #253D93",
-"_ c #19418F",
-": c #0F3C96",
-"< c #42599E",
-"[ c #758DC3",
-"} c #E8EAE7",
-"| c #EEF0ED",
-"1 c #FBFBFC",
-"2 c #6F7D9B",
-"3 c #6F7D9A",
-"4 c #6E7B9C",
-"5 c #67759E",
-"6 c #63739E",
-"7 c #62739D",
-"8 c #596F9C",
-"9 c #4A639D",
-"0 c #47609C",
-"a c #445B9F",
-"b c #3E5697",
-"c c #2E509A",
-"d c #2D509A",
-"e c #2D4F99",
-"f c #2D4F98",
-"g c #28418A",
-"h c #3E51A3",
-"i c #D0D3DC",
-"j c #A1B6EF",
-"k c #A2B6F0",
-"l c #A1B6F0",
-"m c #A3B6F0",
-"n c #A0B6EF",
-"o c #9DB6EE",
-"p c #9CB5EF",
-"q c #9CB2F0",
-"r c #9FB5EE",
-"s c #9CB4EB",
-"t c #9AB3EC",
-"u c #9AB0EC",
-"v c #9DB3EB",
-"w c #9BB4EC",
-"x c #9BB4EE",
-"y c #9BB1EF",
-"z c #9BB0F0",
-"A c #90ACF0",
-"B c #93ABEE",
-"C c #91A8EB",
-"D c #8BA3E8",
-"E c #88A1E7",
-"F c #809DE9",
-"G c #7A99E8",
-"H c #7491E5",
-"I c #698AE4",
-"J c #6184E3",
-"K c #507EDC",
-"L c #4E7CDB",
-"M c #4F7DDC",
-"N c #5479DA",
-"O c #567BDC",
-"P c #577CDD",
-"Q c #5074DA",
-"R c #5174DB",
-"S c #5175DC",
-"T c #5276DD",
-"U c #4D71DE",
-"V c #4C72D8",
-"W c #3A6CE0",
-"X c #2B49A6",
-"Y c #E0E2DF",
-"Z c #93AAE9",
-"` c #94A9E8",
-" . c #94AAE9",
-".. c #93A9E9",
-"+. c #92AAE9",
-"@. c #8DA9E8",
-"#. c #8CA7E9",
-"$. c #92ABE9",
-"%. c #8EAAE9",
-"&. c #8EA9E9",
-"*. c #8FAAE9",
-"=. c #8CA8E9",
-"-. c #8CA2E7",
-";. c #86A1E6",
-">. c #839EE9",
-",. c #7F9CE9",
-"'. c #7A97E8",
-"). c #7693E7",
-"!. c #6E8EE8",
-"~. c #678AE9",
-"{. c #5D84E3",
-"]. c #577CDF",
-"^. c #4E77DF",
-"/. c #4A70DB",
-"(. c #4870DB",
-"_. c #4870DC",
-":. c #4770E3",
-"<. c #496FDC",
-"[. c #486EDB",
-"}. c #466FE4",
-"|. c #466EE3",
-"1. c #4167D9",
-"2. c #4066D8",
-"3. c #3F66D8",
-"4. c #3D64D7",
-"5. c #3960DA",
-"6. c #476DD9",
-"7. c #446EE5",
-"8. c #305EC8",
-"9. c #8EAAE8",
-"0. c #8FAAE8",
-"a. c #91AAE9",
-"b. c #8FA9E8",
-"c. c #8BA8E8",
-"d. c #8AA7E9",
-"e. c #8BA5EA",
-"f. c #8AA7E8",
-"g. c #87A2E6",
-"h. c #859FE8",
-"i. c #7F9DE8",
-"j. c #7C9AE8",
-"k. c #7B95E7",
-"l. c #7090E8",
-"m. c #6B8BE9",
-"n. c #6386E6",
-"o. c #5881E1",
-"p. c #5479DE",
-"q. c #4D74DE",
-"r. c #476EDB",
-"s. c #446EE1",
-"t. c #446EE0",
-"u. c #446EDF",
-"v. c #446DE0",
-"w. c #426ADF",
-"x. c #3C64DA",
-"y. c #4360CC",
-"z. c #D3D5D2",
-"A. c #E6E3E8",
-"B. c #8DA2E7",
-"C. c #8CA6EA",
-"D. c #8DA3E9",
-"E. c #88A2E7",
-"F. c #87A1E7",
-"G. c #8AA1E7",
-"H. c #849EE9",
-"I. c #7D9AE9",
-"J. c #7B98E8",
-"K. c #7796E5",
-"L. c #7191E7",
-"M. c #688CE9",
-"N. c #6687E5",
-"O. c #5C83E1",
-"P. c #557BDE",
-"Q. c #4F76DE",
-"R. c #4C72DE",
-"S. c #456EDF",
-"T. c #426AD9",
-"U. c #4269D9",
-"V. c #4269D8",
-"W. c #3D64D9",
-"X. c #3A61DA",
-"Y. c #345ED6",
-"Z. c #335ECF",
-"`. c #C6C3C8",
-" + c #86A1E7",
-".+ c #87A2E7",
-"++ c #87A0E7",
-"@+ c #859EE8",
-"#+ c #849DE9",
-"$+ c #7E9BE9",
-"%+ c #7A99E9",
-"&+ c #7A95E5",
-"*+ c #7593E7",
-"=+ c #6F8EE9",
-"-+ c #668AE5",
-";+ c #6386E0",
-">+ c #5B82DF",
-",+ c #5379DE",
-"'+ c #5075DE",
-")+ c #4B6FDC",
-"!+ c #446AD7",
-"~+ c #4269D6",
-"{+ c #4269D5",
-"]+ c #3E65D7",
-"^+ c #C9CAC9",
-"/+ c #869EE9",
-"(+ c #859FE9",
-"_+ c #849FE9",
-":+ c #829DE8",
-"<+ c #819DE8",
-"[+ c #7B9AE9",
-"}+ c #7A96E6",
-"|+ c #7290E8",
-"1+ c #698CE6",
-"2+ c #6689E0",
-"3+ c #5D84E0",
-"4+ c #587FDF",
-"5+ c #5377DD",
-"6+ c #4B74DE",
-"7+ c #496BD8",
-"8+ c #7C9BE9",
-"9+ c #7E9CE9",
-"0+ c #7D9AEA",
-"a+ c #7D9BEA",
-"b+ c #7D98E8",
-"c+ c #7C98E8",
-"d+ c #7796E4",
-"e+ c #7592E6",
-"f+ c #7390E1",
-"g+ c #698DE0",
-"h+ c #6588DE",
-"i+ c #5E84E0",
-"j+ c #5880DF",
-"k+ c #5479DC",
-"l+ c #4F75DE",
-"m+ c #4A6FDB",
-"n+ c #436AD7",
-"o+ c #3F65D7",
-"p+ c #BAC3BE",
-"q+ c #7B9AE8",
-"r+ c #7B9AEA",
-"s+ c #7A9AEA",
-"t+ c #7B99E9",
-"u+ c #7D97E7",
-"v+ c #7D95E6",
-"w+ c #7D95E5",
-"x+ c #7C95E6",
-"y+ c #7493E3",
-"z+ c #7290DF",
-"A+ c #6C8DDE",
-"B+ c #6B89E1",
-"C+ c #6486DF",
-"D+ c #5D81DF",
-"E+ c #567DDE",
-"F+ c #4F73DE",
-"G+ c #496EDA",
-"H+ c #355ED6",
-"I+ c #345ED5",
-"J+ c #7E95E5",
-"K+ c #7C97E8",
-"L+ c #7C97E7",
-"M+ c #7B94E6",
-"N+ c #7A95E4",
-"O+ c #7695E5",
-"P+ c #7694E4",
-"Q+ c #7994E6",
-"R+ c #7995E4",
-"S+ c #7594E4",
-"T+ c #7391E2",
-"U+ c #6E8EDE",
-"V+ c #6B8ADE",
-"W+ c #6688DF",
-"X+ c #5F84E0",
-"Y+ c #5980E0",
-"Z+ c #4D72DD",
-"`+ c #456BD7",
-" @ c #4168D6",
-".@ c #3C64D7",
-"+@ c #335ED0",
-"@@ c #4659C7",
-"#@ c #7292E1",
-"$@ c #7392E1",
-"%@ c #7492E1",
-"&@ c #718FDF",
-"*@ c #6F8EDE",
-"=@ c #6D8BDE",
-"-@ c #6B88DF",
-";@ c #597FDF",
-">@ c #557ADD",
-",@ c #5176DC",
-"'@ c #4D74DD",
-")@ c #496DDA",
-"!@ c #3860D8",
-"~@ c #7391E0",
-"{@ c #7290DE",
-"]@ c #6D8EDD",
-"^@ c #6D8DDD",
-"/@ c #7190E0",
-"(@ c #6C8DDD",
-"_@ c #6B89DF",
-":@ c #6487E0",
-"<@ c #6085DF",
-"[@ c #5F81DE",
-"}@ c #567EDE",
-"|@ c #4F74D9",
-"1@ c #466BD7",
-"2@ c #4067D5",
-"3@ c #3C63D7",
-"4@ c #335ED3",
-"5@ c #335ED1",
-"6@ c #718EDD",
-"7@ c #728EDD",
-"8@ c #748EDD",
-"9@ c #708EDD",
-"0@ c #6F8DDD",
-"a@ c #6E8DDD",
-"b@ c #6C8ADE",
-"c@ c #6C89DF",
-"d@ c #6988DF",
-"e@ c #6387DF",
-"f@ c #6282DE",
-"g@ c #5681E0",
-"h@ c #577BDD",
-"i@ c #5277DB",
-"j@ c #4D73D8",
-"k@ c #4A70D8",
-"l@ c #436AD5",
-"m@ c #3F66D6",
-"n@ c #3C63D8",
-"o@ c #3960D8",
-"p@ c #3860D7",
-"q@ c #335ED2",
-"r@ c #345ED4",
-"s@ c #6C88DF",
-"t@ c #6D88DF",
-"u@ c #6B89DE",
-"v@ c #6888DF",
-"w@ c #6587E0",
-"x@ c #6989DF",
-"y@ c #6687E0",
-"z@ c #6287E0",
-"A@ c #6281DD",
-"B@ c #5881E0",
-"C@ c #557ADB",
-"D@ c #5176D9",
-"E@ c #4E75D7",
-"F@ c #4A6FD8",
-"G@ c #476BD6",
-"H@ c #4067D6",
-"I@ c #3C62D7",
-"J@ c #3C60D4",
-"K@ c #365ED1",
-"L@ c #345ED3",
-"M@ c #6786DF",
-"N@ c #5F85E0",
-"O@ c #5F86E0",
-"P@ c #6186DF",
-"Q@ c #6286E0",
-"R@ c #6284DF",
-"S@ c #6384DF",
-"T@ c #5B7FDE",
-"U@ c #577DDC",
-"V@ c #557BDA",
-"W@ c #5278D8",
-"X@ c #4E76D6",
-"Y@ c #4C72D7",
-"Z@ c #486DD8",
-"`@ c #4469D6",
-" # c #3F62D2",
-".# c #3C60CF",
-"+# c #345ECF",
-"@# c #6086DF",
-"## c #6085E0",
-"$# c #6285DF",
-"%# c #6383DD",
-"&# c #6481DC",
-"*# c #6380DD",
-"=# c #6183DE",
-"-# c #6083DD",
-";# c #6081DC",
-"># c #6080DD",
-",# c #6083DE",
-"'# c #6181DC",
-")# c #6280DD",
-"!# c #577EDB",
-"~# c #557CD7",
-"{# c #4F76D6",
-"]# c #4E74D7",
-"^# c #466CD7",
-"/# c #3B64D6",
-"(# c #4261CD",
-"_# c #375FCE",
-":# c #5A7FD8",
-"<# c #6281DA",
-"[# c #5F81D8",
-"}# c #5C80D8",
-"|# c #557DD7",
-"1# c #577ED8",
-"2# c #567ED7",
-"3# c #587DD8",
-"4# c #577DD8",
-"5# c #587ED8",
-"6# c #567DD8",
-"7# c #5379D9",
-"8# c #5177D7",
-"9# c #4D74D5",
-"0# c #486ED9",
-"a# c #4068D4",
-"b# c #3D65D2",
-"c# c #4361CC",
-"d# c #345ECE",
-"e# c #325DCF",
-"f# c #2C5AD1",
-"g# c #3959C5",
-"h# c #547BD8",
-"i# c #567DD7",
-"j# c #557BD8",
-"k# c #5279D9",
-"l# c #5278D9",
-"m# c #4D74D6",
-"n# c #4B71D8",
-"o# c #496CD8",
-"p# c #4669D7",
-"q# c #3D66D3",
-"r# c #3F62CF",
-"s# c #4260CC",
-"t# c #5379D8",
-"u# c #4E75D4",
-"v# c #4C73D7",
-"w# c #476CD7",
-"x# c #4869D0",
-"y# c #4067D2",
-"z# c #3D64D1",
-"A# c #4261CC",
-"B# c #395FCE",
-"C# c #4F75D3",
-"D# c #5074D2",
-"E# c #5174D1",
-"F# c #5175D1",
-"G# c #4F74D3",
-"H# c #4C73D5",
-"I# c #4C73D4",
-"J# c #4A72D1",
-"K# c #4B70CF",
-"L# c #506CCC",
-"M# c #4D6BCE",
-"N# c #4167D0",
-"O# c #3D65D1",
-"P# c #3F63CF",
-"Q# c #3B5FCD",
-"R# c #3159CD",
-"S# c #4971D0",
-"T# c #4870CF",
-"U# c #4C6FCF",
-"V# c #4E6CCE",
-"W# c #4E6BCE",
-"X# c #4769CF",
-"Y# c #3D66D0",
-"Z# c #3C65D1",
-"`# c #4062CE",
-" $ c #3D5FCD",
-".$ c #365FCF",
-"+$ c #325DCD",
-"@$ c #2D5AD0",
-"#$ c #3859C5",
-"$$ c #355FCF",
-"%$ c #355ECF",
-"&$ c #335ECE",
-"*$ c #305CCD",
-"=$ c #2B5ACE",
-"-$ c #3056C9",
-";$ c #2553C6",
-">$ c #2153C8",
-",$ c #1F4FC7",
-"'$ c #274CC5",
-")$ c #214AC7",
-"!$ c #1C48C8",
-"~$ c #1244C9",
-"{$ c #1043C9",
-"]$ c #1144C9",
-"^$ c #2A45BE",
-"/$ c #2744B5",
-"($ c #1D49C0",
-"_$ c #2B58DE",
-":$ c #002D94",
-"<$ c #2B59CA",
-"[$ c #2A59CA",
-"}$ c #2E57C8",
-"|$ c #3255C6",
-"1$ c #3355C5",
-"2$ c #1C52C8",
-"3$ c #1D50C7",
-"4$ c #234FC6",
-"5$ c #264CC5",
-"6$ c #1D48C7",
-"7$ c #1245C8",
-"8$ c #1F44C2",
-"9$ c #2945BE",
-"0$ c #2A45BD",
-"a$ c #2040BF",
-"b$ c #3156C7",
-"c$ c #3056C7",
-"d$ c #3354C5",
-"e$ c #3355C6",
-"f$ c #3255C5",
-"g$ c #3254C5",
-"h$ c #1952C7",
-"i$ c #1951C8",
-"j$ c #2050C7",
-"k$ c #274CC4",
-"l$ c #244CC6",
-"m$ c #1F49C7",
-"n$ c #1E47C5",
-"o$ c #2045C3",
-"p$ c #1C44BF",
-"q$ c #2045BE",
-"r$ c #2040B8",
-"s$ c #3254C6",
-"t$ c #3055C6",
-"u$ c #2A54C6",
-"v$ c #2353C7",
-"w$ c #3054C5",
-"x$ c #2F55C5",
-"y$ c #2A54C5",
-"z$ c #2553C5",
-"A$ c #2F54C5",
-"B$ c #3155C6",
-"C$ c #2A54C7",
-"D$ c #1A52C8",
-"E$ c #204FC2",
-"F$ c #264DC6",
-"G$ c #234BC5",
-"H$ c #1D48C1",
-"I$ c #1E48BF",
-"J$ c #2646BE",
-"K$ c #2B45BD",
-"L$ c #1E43BE",
-"M$ c #2643BF",
-"N$ c #2243BF",
-"O$ c #3049BC",
-"P$ c #1E50BE",
-"Q$ c #1D50C0",
-"R$ c #1D50BF",
-"S$ c #1852C1",
-"T$ c #1E51C0",
-"U$ c #214FBF",
-"V$ c #2050C0",
-"W$ c #244EBF",
-"X$ c #2151C0",
-"Y$ c #234FBF",
-"Z$ c #2350C0",
-"`$ c #2351C0",
-" % c #244FBF",
-".% c #2250C0",
-"+% c #2051C0",
-"@% c #1E50C0",
-"#% c #244DBE",
-"$% c #274DBF",
-"%% c #244CBF",
-"&% c #1C48C0",
-"*% c #2247BF",
-"=% c #2C44BD",
-"-% c #1C44BE",
-";% c #1444BF",
-">% c #1841BF",
-",% c #1F40BF",
-"'% c #254DBE",
-")% c #224FBE",
-"!% c #224FBF",
-"~% c #234EBF",
-"{% c #254CBD",
-"]% c #244DBD",
-"^% c #244CBD",
-"/% c #264DBE",
-"(% c #264DBD",
-"_% c #214BC0",
-":% c #1D48C0",
-"<% c #2347BF",
-"[% c #2B44BD",
-"}% c #2444BE",
-"|% c #0F42BF",
-"1% c #0641BF",
-"2% c #0F41BF",
-"3% c #1741BE",
-"4% c #1F40BD",
-"5% c #234BBF",
-"6% c #234CBE",
-"7% c #214BBE",
-"8% c #244CBE",
-"9% c #214ABE",
-"0% c #214ABF",
-"a% c #1F48C0",
-"b% c #2746BE",
-"c% c #1F43BE",
-"d% c #0941BE",
-"e% c #0342BA",
-"f% c #0242BC",
-"g% c #1241B8",
-"h% c #1F40B7",
-"i% c #2F41AC",
-"j% c #2644AE",
-"k% c #2D49B4",
-"l% c #2649B6",
-"m% c #2949B7",
-"n% c #2849B5",
-"o% c #2149B8",
-"p% c #1E49B9",
-"q% c #1F48B8",
-"r% c #1F49B9",
-"s% c #2545B6",
-"t% c #2744B7",
-"u% c #2844B7",
-"v% c #2043B8",
-"w% c #1241B7",
-"x% c #1340B8",
-"y% c #0D41B8",
-"z% c #1941B8",
-"A% c #1F40B8",
-"B% c #203FB8",
-"C% c #2549B5",
-"D% c #2648B6",
-"E% c #2547B7",
-"F% c #2248B7",
-"G% c #2048B7",
-"H% c #2346B6",
-"I% c #2146B6",
-"J% c #2247B7",
-"K% c #2148B7",
-"L% c #2743B4",
-"M% c #2643B5",
-"N% c #2542B6",
-"O% c #1D42B7",
-"P% c #0E42B8",
-"Q% c #0C41B8",
-"R% c #1341B8",
-"S% c #1740B8",
-"T% c #1C41B8",
-"U% c #1F40B1",
-"V% c #2644B5",
-"W% c #2544B5",
-"X% c #2544B4",
-"Y% c #2444B5",
-"Z% c #2444B4",
-"`% c #2744B4",
-" & c #2241B7",
-".& c #1D41B8",
-"+& c #0B42B8",
-"@& c #0942B8",
-"#& c #0C42B8",
-"$& c #0F41B8",
-"%& c #1641B8",
-"&& c #2442B5",
-"*& c #2543B3",
-"=& c #2342B2",
-"-& c #2341B4",
-";& c #2141B3",
-">& c #2141B5",
-",& c #2140B5",
-"'& c #2040B5",
-")& c #1C40B7",
-"!& c #1B41B3",
-"~& c #0142B6",
-"{& c #0E41B7",
-"]& c #1141B7",
-"^& c #1440B2",
-"/& c #113FB0",
-"(& c #1440B0",
-"_& c #213EAF",
-":& c #233DAE",
-"<& c #223EAF",
-"[& c #1E40B1",
-"}& c #173EAD",
-"|& c #1440AF",
-"1& c #0D40AF",
-"2& c #0941B0",
-"3& c #0D3FAE",
-"4& c #1B3CAC",
-"5& c #233CAD",
-"6& c #203FB0",
-"7& c #273BAD",
-"8& c #1D40B0",
-"9& c #2040B1",
-"0& c #1E40B0",
-"a& c #1C40B0",
-"b& c #1B3DAC",
-"c& c #143DAC",
-"d& c #193DAD",
-"e& c #1B3DAD",
-"f& c #173DAD",
-"g& c #153DAC",
-"h& c #1C3CAC",
-"i& c #243CAD",
-"j& c #213FB0",
-"k& c #263BAA",
-"l& c #253CAE",
-"m& c #273AAC",
-"n& c #273AAD",
-"o& c #253BAD",
-"p& c #1D3CAC",
-"q& c #243BAD",
-"r& c #1E3CAC",
-"s& c #263BAD",
-"t& c #1A3DAC",
-"u& c #143DAB",
-"v& c #163DAC",
-"w& c #1A3CAC",
-"x& c #1F3CAD",
-"y& c #263BAB",
-"z& c #263BA6",
-"A& c #1E42A4",
-"B& c #2D40A5",
-"C& c #253BA6",
-"D& c #253CA7",
-"E& c #263AA5",
-"F& c #253BA7",
-"G& c #1E3BA6",
-"H& c #193DA6",
-"I& c #173DA5",
-"J& c #143DA6",
-"K& c #1A3DA7",
-"L& c #133DA6",
-"M& c #123DA5",
-"N& c #1A3CA7",
-"O& c #243BA6",
-"P& c #263AA7",
-"Q& c #273BA7",
-"R& c #263AA6",
-"S& c #223BA6",
-"T& c #1D3BA6",
-"U& c #173CA6",
-"V& c #133DA5",
-"W& c #1B3DA6",
-"X& c #193DA5",
-"Y& c #123DA4",
-"Z& c #163CA5",
-"`& c #213CA6",
-" * c #273BA8",
-".* c #263BA7",
-"+* c #253BA5",
-"@* c #263BA5",
-"#* c #1C3BA6",
-"$* c #1B3BA9",
-"%* c #133BA8",
-"&* c #0A3BA7",
-"** c #083AA6",
-"=* c #123CA5",
-"-* c #0839A8",
-";* c #0239A6",
-">* c #123AA8",
-",* c #1F49C8",
-"'* c #2F4DA4",
-")* c #2E4DA3",
-"!* c #384CA4",
-"~* c #3C4DA7",
-"{* c #394EA7",
-"]* c #3B4CA5",
-"^* c #3C52B1",
-"/* c #3551A8",
-"(* c #3759BE",
-"_* c #4161C7",
-":* c #0033A8",
-"<* c #596FA9",
-"[* c #2F4DA3",
-"}* c #2D4BA5",
-"|* c #2E4CA4",
-"1* c #2C4AA5",
-"2* c #2D4BA4",
-"3* c #354DA4",
-"4* c #3A4BA4",
-"5* c #394DA6",
-"6* c #4056AD",
-"7* c #445BBB",
-"8* c #B5B7B4",
-"9* c #1B2F85",
-"0* c #242F79",
-"a* c #B5B5B5",
-"b* c #B5B2B6",
-"c* c #C0C3C3",
-"d* c #E3E3E4",
-"e* c #EBEDEA",
-". + @ + # $ % & # $ % & # $ % & # $ % & & * = - ; > , ' ) ! ~ { { { { { { { ] ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ / / / ( / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / _ _ / / : / < [ } | | | 1 1 ",
-"2 2 2 2 3 2 4 @ 3 2 4 @ 3 2 4 @ 3 2 4 @ # 5 6 7 8 ; > 9 0 a b c d e f { { { ] ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ( ( ( ( ( ( ( ( ( / / / / / / / / / / / / / / / / / _ _ _ _ _ _ _ _ _ _ _ g g _ / / : : : h i } 1 | 1 ",
-"j k l m n o p q n o p q r s t u v w x y z A B C D E F G H I J K L M N O P O O Q R S T T T T T T T T T T T T T T T T T T U U U U U U U U U U U U U U U U U U U U U U U U U U U U V V V U U W X : [ Y | | ",
-"Z ` . ...+.@.#...+.@.#.Z $.%.&.Z $.*.=.-.;.>.,.'.).!.~.{.].^./.(._.:.<.[.}.|.1.2.3.4.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.6.7.8.: h Y } 1 ",
-"9.0.a.b.c.c.d.e.f.c.d.e.f.c.d.e.f.c.d.e.g.h.i.j.k.l.m.n.o.p.q.r.s.s.t.u.u.v.w.x.4.4.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.y.5.7.6.: / z.A.} ",
-"-.B.C.D.-.E.g.F.G.E.g.F.G.E.g.F.G.E.g.F.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.V.U.U.W.X.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Z.y.Y.7.7.: : `.z.} ",
-" +.+g.;.++F.@+#+++F.@+#+++F.@+#+++F.@+#+$+%+&+*+=+-+;+>+,+'+)+!+~+{+]+{+{+4.4.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.Y.Y.5.5.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Z.Z.Z.y.y.5.7.7.: : ^+z.Y ",
-"/+(+_+#+H.H.>.:+H.H.>.:+H.H.>.:+H.H.>.<+[+}+*+|+1+2+3+4+5+6+7+{+{+4.4.4.4.4.4.5.5.5.5.5.5.5.5.5.5.5.5.5.5.5.Y.Y.Y.Y.Y.Y.Y.5.Y.Y.Y.Y.Y.Y.Y.Y.5.Y.Y.5.5.5.5.Y.Y.Y.Y.Y.Y.Z.Z.Z.Z.y.y.y.y.y.y.7.7.: : ^+i } ",
-"8+9+0+0+a+0+0+b+a+0+0+b+a+0+0+b+a+0+0+c+d+e+f+g+h+i+j+k+l+m+n+o+4.4.4.4.5.5.5.5.5.5.Y.Y.5.5.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Y.Y.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.7.7.: : p+z.Y ",
-"q+r+r+s+t+u+v+w+t+u+v+w+t+u+v+w+t+u+x+&+y+z+A+B+C+D+E+5+F+G+~+4.4.4.4.5.5.5.5.5.H+Y.Y.Y.Y.Y.Y.Y.Y.I+Y.Z.Y.Y.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.7.7.: : `.z.A.",
-"J+v+K+L+M+N+O+P+Q+R+O+P+Q+R+O+P+Q+R+O+S+T+U+V+W+X+Y+P.T Z+`+ @4.4..@5.5.5.5.5.5.Y.Y.Y.I+I+I+I+I++@+@Z.Z.Y.Y.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.@@Z.7.7.: : p+z.Y ",
-"#@$@$@%@%@$@#@&@#@#@#@&@#@#@#@&@#@#@#@*@=@-@;+i+;@>@,@'@)@ @4.X.5.5.H+Y.Y.Y.!@Y.Y.I++@+@Z.Z.+@Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.y.Z.6.6.: : `.z.A.",
-"#@$@~@~@~@{@]@^@/@{@]@^@/@{@]@^@/@{@]@(@_@:@<@[@}@k+|@V 1@2@3@5.5.5.Y.Y.I+4@I+5@+@Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.y.Z.6.6.: : p+z.Y ",
-"6@7@8@9@0@a@b@c@a@a@b@c@a@a@b@c@a@a@b@d@e@<@f@g@h@i@j@k@l@m@n@o@o@p@Y.I+q@q@r@+@Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.y.Z.6.6.: : `.z.A.",
-"s@t@u@_@_@v@w@w@x@v@w@w@x@v@y@y@x@v@:@z@A@B@P C@D@E@F@G@H@I@J@K@5@+@+@+@r@I+L@Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.@@Z.W W : : p+z.Y ",
-"M@N@O@P@C+Q@Q@R@C+;+Q@R@C+;+;+S@C+Q@Q@R@T@U@V@W@X@Y@Z@`@4. #.#+#Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.8.Z.Z.Z.Z.8.8.Z.Z.y.@@@@W W : : `.z.A.",
-"@#O@O@##$#%#&#*#=#-#;#>#,#-#;#>#,#-#'#)#!#~#W@{#]#k@^#H@/#(#_#Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.Z.8.8.Z.Z.Z.Z.Z.Z.Z.8.8.8.8.8.8.8.8.8.8.8.Z.Z.y.y.@@W W : : p+z.Y ",
-":#<#[#}#|#1#2#3#4#5#1#4#4#1#1#4#4#1#1#6#7#8#9#V 0#`+a#b#c#d#e#Z.Z.Z.f#Z.Z.Z.f#f#f#f#f#f#f#f#f#f#g#g#g#g#g#8.8.8.8.8.8.8.8.8.g#g#g#g#8.g#8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.y.y.@@W W : : `.z.A.",
-"h#2#i#6#|#j#7#k#|#j#7#7#|#j#7#7#|#j#7#l#8#m#n#n#o#p#q#r#s#d#e#Z.Z.Z.f#f#f#f#Z.f#f#g#g#g#g#g#g#g#g#g#g#g#g#8.8.8.g#g#8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.8.y.y.y.y.8.8.8.y.y.@@W W : : p+z.Y ",
-"l#7#7#l#7#7#7#W@7#7#7#W@7#7#k#W@t#7#7#W@u#v#n#w#x#y#z#A#B#Z.e#f#f#Z.f#f#f#Z.Z.g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#8.8.8.g#g#g#g#8.8.g#g#g#g#g#g#8.8.g#8.8.y.8.8.y.y.8.y.y.y.y.@@W W : : `.z.A.",
-"C#D#E#F#G#H#I#J#G#H#I#J#G#H#I#J#G#H#I#J#K#L#M#N#O#P#s#Q#+#f#R#f#f#f#f#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#@@@@y.y.@@@@y.y.W W : : p+z.Y ",
-"S#S#S#S#S#T#S#U#S#T#S#U#S#T#S#U#S#T#S#U#V#W#X#Y#Z#`# $.$+$@$#$g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#g#@@@@@@@@@@@@@@@@@@y.y.W W : : `.z.A.",
-"+$Z..$$$%$+$&$*$%$+$&$*$%$+$&$*$%$+$&$*$=$-$;$>$,$'$)$!$~${$]$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$/$/$/$/$($($_$_$:$:$p+z.Y ",
-"<$<$<$<$<$[$}$|$<$[$}$|$<$[$}$|$<$[$}$|$1$2$3$4$5$)$6$7$8$9$0$a$a$a$a$a$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$/$/$/$^$^$^$/$/$/$/$/$/$/$/$/$/$/$/$/$/$($($_$_$:$:$`.z.A.",
-"b$c$c$c$d$e$e$f$g$|$|$1$d$e$e$1$d$e$e$1$h$i$j$k$l$m$n$o$p$9$q$a$a$a$a$a$a$a$a$^$a$a$^$^$^$^$^$^$a$r$r$r$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$^$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$($($_$_$:$:$p+z.Y ",
-"e$1$s$s$1$t$u$v$w$x$y$z$A$x$u$v$g$B$C$>$D$E$F$G$H$I$J$K$L$M$N$a$a$a$a$a$a$a$a$^$r$r$a$^$^$^$a$r$r$r$r$r$/$^$r$^$^$^$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$O$($_$_$:$:$`.z.A.",
-"P$Q$R$S$T$U$V$W$X$Y$Z$W$`$ %.%W$+%U$@%#%$%%%&%($*%=%-%;%>%>%,%r$r$r$r$r$a$a$a$/$/$/$r$r$r$r$r$r$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$O$($_$_$:$:$p+z.Y ",
-"'%W$)%!%~%{%'%]%~%^%'%]%~%^%'%]%~%^%/%(%_%&%:%<%[%}%|%1%2%3%4%r$r$r$r$r$r$r$r$r$r$r$r$r$r$r$r$r$/$r$/$/$r$r$r$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$/$r$/$/$/$/$/$O$($_$_$:$:$`.z.A.",
-"5%6%'%'%6%7%8%9%6%7%8%9%6%7%8%9%6%7%8%0%&%a%<%b%[%c%d%e%f%g%h%r$r$r$r$r$r$r$r$r$r$r$r$r$r$r$/$r$r$r$r$r$r$r$r$r$r$r$r$r$r$r$r$r$r$r$r$/$/$/$/$/$/$/$/$/$/$/$/$/$/$r$r$/$/$r$r$/$r$i%j%O$($_$_$:$:$p+z.Y ",
-"k%l%m%n%o%o%p%q%o%o%r%q%o%o%r%q%o%o%p%q%s%t%/$u%v%w%x%y%z%A%B%r$r$r$r$r$r$r$r$r$r$r$r$r$r$r$r$r$r$r$r$r$r$/$/$/$/$/$/$/$r$r$i%i%i%r$r$i%i%i%i%i%i%i%i%i%i%i%i%r$/$/$j%j%j%j%j%j%j%j%j%O$($_$_$:$:$`.z.A.",
-"C%D%E%F%G%H%I%J%K%H%I%J%K%H%I%J%K%H%I%J%L%M%N%O%P%Q%R%S%T%A%B%r$r$r$r$r$r$r$r$r$r$r$r$r$r$r$U%U%r$r$i%i%/$/$r$r$/$/$/$/$r$r$i%i%i%i%i%i%i%i%i%i%i%i%i%i%j%i%j%j%j%j%j%j%j%j%j%j%j%j%j%O$($_$_$:$:$p+z.Y ",
-"/$/$/$/$V%V%W%X%W%Y%Y%Z%W%W%Y%Z%W%W%W%`%`% &B%.&+&@&#&$&%&A%B%r$r$r$U%U%U%U%r$U%U%U%U%U%U%U%U%U%U%i%i%i%i%i%i%i%i%/$/$/$i%i%i%i%i%i%i%i%i%j%j%j%j%i%i%i%i%i%j%j%j%i%i%j%j%j%j%j%j%j%j%O$($_$_$:$:$`.z.A.",
-"&&*&=&-&=&;&>&,&=&;&>&,&=&;&>&,&=&;&>&'&)&!&~&{&]&^&/&(&_&:&<&U%U%U%U%U%U%U%U%U%U%U%U%U%i%i%U%U%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%O$($_$_$:$:$p+z.Y ",
-"U%U%U%U%U%U%U%U%U%U%U%U%U%U%U%U%U%U%U%U%[&}&|&1&2&3&4&5&_&6&U%7&U%U%U%U%U%U%U%U%i%i%U%U%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%O$O$_$_$:$:$`.z.A.",
-"U%U%U%U%U%U%[&8&U%9&[&0&U%9&[&0&U%9&[&a&:&b&c&d&e&f&g&h&i&<&j&U%U%U%U%U%U%U%U%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%i%O$O$_$_$:$:$p+z.Y ",
-"k&l&m&7&7&n&o&p&7&n&q&r&s&s&q&r&s&n&o&p&t&u&u&g&v&w&x&q&n&m&y&7&7&U%U%7&z&7&z&U%A&B&i%i%B&B&i%i%B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&i%B&O$O$_$_$:$:$`.z.A.",
-"C&D&E&z&z&E&F&G&z&E&F&G&z&E&F&G&z&E&F&G&H&I&J&K&L&M&N&O&P&Q&z&z&z&z&z&z&z&z&z&z&z&z&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&O$O$_$_$:$:$p+z.Y ",
-"z&z&z&z&R&S&T&U&R&S&T&U&R&S&T&U&R&S&T&U&V&V&W&X&Y&Z&`&C&R&z&z&z&z&z&z&z&z&z&z&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&O$O$_$_$:$:$^+z.A.",
-"z& *.*+*@*#*$*%*@*#*$*%*@*#*$*%*@*#*$*%*&***=*-*;*>*k&P&+*z&z&z&z&z&z&z&z&z&z&z&z&z&z&z&z&z&z&z&z&z&z&z&z&z&z&z&z&z&z&z&B&B&B&B&z&z&z&B&B&B&z&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&B&/$O$O$@@_$,*:$/ ^+z.Y ",
-"'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*'*)*'*!*~*{*]*^*^*^*/*/*/*/*/*/*/*^*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*^*/*/*/*/*/*h h ^*h h ^*^*h h ^*^*^*^*h ^*^*^*^*h ^*^*^*(*_*_*_*_*_$:*:$<*`.z.} ",
-"'*'*'*'*'*[*}*|*'*[*}*|*'*[*}*|*'*[*}*|*1*1*2*}*}*2*[*)*3*4*5*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*/*h h h h h h h h h h h h h h h h 6*7*_*_*_*_*^*:*:$: 8*z.Y } ",
-"9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*9*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*0*( <*8*^+z.Y } 1 ",
-"a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*8*b*8*b*8*b*8*b*b*8*b*8*b*8*b*8*b*8*b*8*b*8*b*8*b*8*b*8*b*8*b*8*b*8*b*8*b*8*b*8*b*8*b*8*b*8*b*8*b*8*b*8*b*8*b*8*b*8*8*8*8*b*8*`.z.A.Y | | ",
-"c*c*c*c*c*c*c*c*c*c*c*c*c*c*c*c*c*c*c*c*c*c*c*c*c*c*c*c*c*c*c*p+`.p+`.p+`.p+`.`.p+`.p+`.p+`.p+`.p+`.p+`.p+`.p+`.p+`.p+`.p+`.p+`.p+`.p+`.p+`.p+`.p+`.p+`.p+`.p+`.p+`.p+`.p+`.p+`.p+^+`.^+^+z.z.Y Y | | 1 ",
-"d*d*d*d*d*d*d*d*d*d*d*d*d*d*d*d*d*d*d*d*d*d*d*d*d*d*d*d*d*d*d*A.Y A.Y A.Y A.Y Y A.Y A.Y A.Y A.Y A.Y A.Y A.Y A.Y A.Y A.Y A.Y A.Y A.Y A.Y A.Y A.Y A.Y A.Y A.Y A.Y A.Y A.Y A.Y A.Y A.Y A.Y } } | | | | 1 1 ",
-"e*e*e*e*e*e*e*e*e*e*e*e*e*e*e*e*e*e*e*e*e*e*e*e*e*e*e*e*e*e*e*} | } | } | } | | } | } | } | } | } | } | } | } | } | } | } | } | } | } | } | } | } | } | } | } | } | } | } | } | } | | | | 1 | | | 1 1 1 "};
-
-
-static char * tabmiddle_xpm[] = {
-"33 42 32 1",
-" c None",
-". c #CECFEF",
-"+ c #CECBE7",
-"@ c #C6C7E7",
-"# c #C6CBE7",
-"$ c #BDBEDE",
-"% c #BDC3DE",
-"& c #CECBEF",
-"* c #B5B6D6",
-"= c #ADAECE",
-"- c #ADB2CE",
-"; c #BDBAD6",
-"> c #B5BAD6",
-", c #C6C3DE",
-"' c #ADAAC6",
-") c #B5B2CE",
-"! c #B5B6CE",
-"~ c #A5A2BD",
-"{ c #A5A6BD",
-"] c #9C9EB5",
-"^ c #9CA2BD",
-"/ c #ADAEC6",
-"( c #C6C3E7",
-"_ c #9C9AB5",
-": c #A5A6C6",
-"< c #949AAD",
-"[ c #A5AAC6",
-"} c #9496AD",
-"| c #BDBADE",
-"1 c #BDBED6",
-"2 c #9CA2B5",
-"3 c #A5AABD",
-"..........................+@.#.#.",
-"........................$@%&#.#..",
-"......................**$$@@&#.#.",
-".....................=-;>,%+@.#..",
-"....................'')!$$@@&#.#.",
-"...................~{=)$$@@&#.#..",
-"..................]^'/;;(%&#.#...",
-"................._]:/*>,%&@.#.#..",
-".................<{[)!$%+@.#.#...",
-"................}~{=!$%@@.#......",
-"................]^/-|$@@.#.......",
-"................]'/*;@@&#........",
-"...............<~[)>,%&#.#.......",
-"...............]~=)$%+#.#........",
-"...............]'/;1@@.#.........",
-"...............~{)*,%&#..........",
-"...............2/-$$@#...........",
-"...............~[*>(@&#..........",
-"...............^=)$%+#...........",
-"...............{'*>(@.#..........",
-"...............^=)$%+#...........",
-"...............{'*>(@.#..........",
-"...............^=)$%+#...........",
-"...............{'*>(@.#..........",
-"...............^=)$%+#...........",
-"...............{'*>(@.#..........",
-"...............^=)$%+#...........",
-"...............{'*>@@.#..........",
-"...............^=!$%&#...........",
-"...............{/*;@@.#..........",
-"...............{)!$%&#...........",
-"..............]'/;1@@.#..........",
-"..............23)>,%&#...........",
-"..............~=-$$@@.#..........",
-".............]{/*;@@.#...........",
-"............<^[)>,%&#............",
-"............]{/!$%@@.#...........",
-"..........]^[-!$%@@.#............",
-".........]^3/!>$@@.#.............",
-".......<]^3/!>$@@&#..............",
-".....<]2{[/!>$%@&#.#.............",
-"}<<_]2{3/-!>$%@&#.#.............."};
-
-
-static char * tabselectedbeginn_xpm[] = {
-"33 39 28 1",
-" c None",
-". c #CECFEF",
-"+ c #EFF3EF",
-"@ c #FFFBFF",
-"# c #F7FBF7",
-"$ c #FFFFFF",
-"% c #EFEFEF",
-"& c #F7F7F7",
-"* c #DEDFDE",
-"= c #E7E7E7",
-"- c #D6D3D6",
-"; c #DEE3DE",
-"> c #EFEBEF",
-", c #F7F3F7",
-"' c #CECBCE",
-") c #CECFCE",
-"! c #D6D7D6",
-"~ c #DEDBDE",
-"{ c #E7EBE7",
-"] c #C6C7C6",
-"^ c #E7E3E7",
-"/ c #BDC3BD",
-"( c #CED3CE",
-"_ c #BDBABD",
-": c #C6C3C6",
-"< c #C6CBC6",
-"[ c #D6DBD6",
-"} c #BDBEBD",
-"..........................+@#$#$$",
-"........................%%&&@#$#$",
-"......................*==%%&&@#$$",
-"....................--*;>%,&@#$#$",
-"...................')!~={,+@#$#$$",
-"...................]-!^=%%&&@#$#$",
-"................../'(~;>%&&@#$#$$",
-"................._])!*={,&@#$#$$$",
-"................_])~*>%&&$#$$$$$$",
-"................:<![={&&@#$$$$$$$",
-"................:)!^=,+@#$$$$$$$$",
-"...............}'(*^%+@#$#$$$$$$$",
-"...............:<!*>%&&$#$$$$$$$$",
-".............../)!^{,&@#$$$$$$$$$",
-"...............](*^%+@#$$$$$$$$$$",
-"...............]!~=%&&$$$$$$$$$$$",
-"...............'(*=,+@#$$$$$$$$$$",
-"...............<!*>%&&$$$$$$$$$$$",
-"...............'-^=,+@#$$$$$$$$$$",
-"...............<!*>%&#$$$$$$$$$$$",
-"...............'-^=,+@#$$$$$$$$$$",
-"...............<!*>%&#$$$$$$$$$$$",
-"...............'-^=,+@#$$$$$$$$$$",
-"...............<!*>%&#$$$$$$$$$$$",
-"...............'-^=,+@#$$$$$$$$$$",
-"...............<!*>%&#$$$$$$$$$$$",
-"...............'!^=,&@#$$$$$$$$$$",
-"...............<~*>%&#$$$$$$$$$$$",
-"...............)!^{,&@#$$$$$$$$$$",
-"..............])~;%+@#$$$$$$$$$$$",
-"..............]-[={&&$#$$$$$$$$$$",
-".............])!^=,&@#$$$$$$$$$$$",
-"............:'-*^%+@#$$$$$$$$$$$$",
-"............])~*>%&&$#$$$$$$$$$$$",
-"...........:'!*={,&@#$$$$$$$$$$$$",
-"..........:'-~^=,+@#$$$$$$$$$$$$$",
-".......}]'-~^=%,&@#$$$$$$$$$$$$$$",
-".....}:])-~^=%,+@#$#$$$$$$$$$$$$$",
-"}}}:]')-!*^=%,&@#$#$$$$$$$$$$$$$$"};
-
-
-static char * tabselectedend_xpm[] = {
-"33 42 33 1",
-" c None",
-". c #FFFFFF",
-"+ c #CECBE7",
-"@ c #C6C7E7",
-"# c #CECFEF",
-"$ c #C6CBE7",
-"% c #BDBEDE",
-"& c #BDC3DE",
-"* c #CECBEF",
-"= c #B5B6D6",
-"- c #ADAECE",
-"; c #ADB2CE",
-"> c #BDBAD6",
-", c #B5BAD6",
-"' c #C6C3DE",
-") c #ADAAC6",
-"! c #B5B2CE",
-"~ c #B5B6CE",
-"{ c #A5A2BD",
-"] c #A5A6BD",
-"^ c #9C9EB5",
-"/ c #9CA2BD",
-"( c #ADAEC6",
-"_ c #C6C3E7",
-": c #9C9AB5",
-"< c #A5A6C6",
-"[ c #949AAD",
-"} c #A5AAC6",
-"| c #9496AD",
-"1 c #BDBADE",
-"2 c #BDBED6",
-"3 c #9CA2B5",
-"4 c #A5AABD",
-"..........................+@#$#$#",
-"........................%@&*$#$##",
-"......................==%%@@*$#$#",
-".....................-;>,'&+@#$##",
-"....................))!~%%@@*$#$#",
-"...................{]-!%%@@*$#$##",
-"..................^/)(>>_&*$#$###",
-".................:^<(=,'&*@#$#$##",
-".................[]}!~%&+@#$#$###",
-"................|{]-~%&@@#$######",
-"................^/(;1%@@#$#######",
-"................^)(=>@@*$########",
-"...............[{}!,'&*$#$#######",
-"...............^{-!%&+$#$########",
-"...............^)(>2@@#$#########",
-"...............{]!='&*$##########",
-"...............3(;%%@$###########",
-"...............{}=,_@*$##########",
-".............../-!%&+$###########",
-"...............])=,_@#$##########",
-".............../-!%&+$###########",
-"...............])=,_@#$##########",
-".............../-!%&+$###########",
-"...............])=,_@#$##########",
-".............../-!%&+$###########",
-"...............])=,_@#$##########",
-".............../-!%&+$###########",
-"...............])=,@@#$##########",
-".............../-~%&*$###########",
-"...............](=>@@#$##########",
-"...............]!~%&*$###########",
-"..............^)(>2@@#$##########",
-"..............34!,'&*$###########",
-"..............{-;%%@@#$##########",
-".............^](=>@@#$###########",
-"............[/}!,'&*$############",
-"............^](~%&@@#$###########",
-"..........^/};~%&@@#$############",
-".........^/4(~,%@@#$#############",
-".......[^/4(~,%@@*$##############",
-".....[^3]}(~,%&@*$#$#############",
-"|[[:^3]4(;~,%&@*$#$##############"};
-
-
-static char * tabend_xpm[] = {
-"33 42 3 1",
-" c None",
-". c #CECFEF",
-"+ c #FFFFFF",
-"..........................+++++++",
-"........................+++++++++",
-"......................+++++++++++",
-".....................++++++++++++",
-"....................+++++++++++++",
-"...................++++++++++++++",
-"..................+++++++++++++++",
-".................++++++++++++++++",
-".................++++++++++++++++",
-"................+++++++++++++++++",
-"................+++++++++++++++++",
-"................+++++++++++++++++",
-"...............++++++++++++++++++",
-"...............++++++++++++++++++",
-"...............++++++++++++++++++",
-"...............++++++++++++++++++",
-"...............++++++++++++++++++",
-"...............++++++++++++++++++",
-"...............++++++++++++++++++",
-"...............++++++++++++++++++",
-"...............++++++++++++++++++",
-"...............++++++++++++++++++",
-"...............++++++++++++++++++",
-"...............++++++++++++++++++",
-"...............++++++++++++++++++",
-"...............++++++++++++++++++",
-"...............++++++++++++++++++",
-"...............++++++++++++++++++",
-"...............++++++++++++++++++",
-"...............++++++++++++++++++",
-"...............++++++++++++++++++",
-"..............+++++++++++++++++++",
-"..............+++++++++++++++++++",
-"..............+++++++++++++++++++",
-".............++++++++++++++++++++",
-"............+++++++++++++++++++++",
-"............+++++++++++++++++++++",
-"..........+++++++++++++++++++++++",
-".........++++++++++++++++++++++++",
-".......++++++++++++++++++++++++++",
-".....++++++++++++++++++++++++++++",
-"+++++++++++++++++++++++++++++++++"};
-
-
-
-
-QColor fromHsl(QColor c)
-{
- const qreal h = c.hueF();
- const qreal s = c.saturationF();
- const qreal l = c.valueF();
-
- qreal ca[3] = {0, 0, 0};
-
- if (s == 0 || h == 1) {
- // achromatic case
- ca[0] = ca[1] = ca[2] = l;
- } else {
- // chromatic case
- qreal temp2;
- if (l < qreal(0.5))
- temp2 = l * (qreal(1.0) + s);
- else
- temp2 = l + s - (l * s);
-
- const qreal temp1 = (qreal(2.0) * l) - temp2;
- qreal temp3[3] = { h + (qreal(1.0) / qreal(3.0)),
- h,
- h - (qreal(1.0) / qreal(3.0)) };
-
- for (int i = 0; i != 3; ++i) {
- if (temp3[i] < qreal(0.0))
- temp3[i] += qreal(1.0);
- else if (temp3[i] > qreal(1.0))
- temp3[i] -= qreal(1.0);
-
- const qreal sixtemp3 = temp3[i] * qreal(6.0);
-
- if (sixtemp3 < qreal(1.0))
- ca[i] = ((temp1 + (temp2 - temp1) * sixtemp3));
- else if ((temp3[i] * qreal(2.0)) < qreal(1.0))
- ca[i] = (temp2);
- else if ((temp3[i] * qreal(3.0)) < qreal(2.0))
- ca[i] = temp1 + (temp2 -temp1) * (qreal(2.0) /qreal(3.0) - temp3[i]) * qreal(6.0);
- else ca[i] = temp1;
- }
- }
-
- return QColor::fromRgbF(ca[0], ca[1], ca[2]);
-}
-
-#define Q_MAX_3(a, b, c) ( ( a > b && a > c) ? a : (b > c ? b : c) )
-#define Q_MIN_3(a, b, c) ( ( a < b && a < c) ? a : (b < c ? b : c) )
-
-QColor toHsl(QColor c)
-{
- QColor color;
- qreal h;
- qreal s;
- qreal l;
-
- const qreal r = c.redF();
- const qreal g = c.greenF();
- const qreal b = c.blueF();
- const qreal max = Q_MAX_3(r, g, b);
- const qreal min = Q_MIN_3(r, g, b);
- const qreal delta = max - min;
- const qreal delta2 = max + min;
- const qreal lightness = qreal(0.5) * delta2;
- l = (lightness);
- if (qFuzzyIsNull(delta)) {
- // achromatic case, hue is undefined
- h = 0;
- s = 0;
- } else {
- // chromatic case
- qreal hue = 0;
- if (lightness < qreal(0.5))
- s = ((delta / delta2));
- else
- s = ((delta / (qreal(2.0) - delta2)));
- if (qFuzzyCompare(r, max)) {
- hue = ((g - b) /delta);
- } else if (qFuzzyCompare(g, max)) {
- hue = (2.0 + (b - r) / delta);
- } else if (qFuzzyCompare(b, max)) {
- hue = (4.0 + (r - g) / delta);
- } else {
- Q_ASSERT_X(false, "QColor::toHsv", "internal error");
- }
- hue *= 60.0;
- if (hue < 0.0)
- hue += 360.0;
- h = (hue * 100);
- }
-
- h = h / 36000;
-
- return QColor::fromHsvF(h, s, l);
-}
-
-void tintColor(QColor &color, QColor tintColor, qreal _saturation)
-{
- tintColor = toHsl(tintColor);
- color = toHsl(color);
- qreal hue = tintColor.hueF();
-
- qreal saturation = color.saturationF();
- if (_saturation)
- saturation = _saturation;
- qreal lightness = color.valueF();
- color.setHsvF(hue, saturation, lightness);
-
- color = fromHsl(color);
- color.toRgb();
-}
-
-void tintImagePal(QImage *image, QColor color, qreal saturation)
-{
- QVector<QRgb> colorTable = image->colorTable();
- for (int i=2;i< colorTable.size();i++) {
- QColor c(toHsl(colorTable.at(i)));
- tintColor(c, color, saturation);
- colorTable[i] = c.rgb();
- }
- image->setColorTable(colorTable);
-}
-
-
-void tintImage(QImage *image, QColor color, qreal saturation)
-{
- *image = image->convertToFormat(QImage::Format_RGB32);
-
- for (int x = 0; x < image->width(); x++)
- for (int y = 0; y < image->height(); y++) {
- QColor c(image->pixel(x,y));
- tintColor(c, color, saturation);
- image->setPixel(x, y, c.rgb());
- }
-}
-
-#endif //Q_OS_WINCE_WM
-
-
-enum QSliderDirection { SliderUp, SliderDown, SliderLeft, SliderRight };
-
-#ifdef Q_OS_WINCE_WM
-
-void QWindowsMobileStylePrivate::tintImagesButton(QColor color)
-{
- if (currentTintButton == color)
- return;
- currentTintButton = color;
-
- imageTabEnd = QImage(tabend_xpm);
- imageTabSelectedEnd = QImage(tabselectedend_xpm);
- imageTabSelectedBegin = QImage(tabselectedbeginn_xpm);
- imageTabMiddle = QImage(tabmiddle_xpm);
- tintImage(&imageTabEnd, color, 0.0);
- tintImage(&imageTabSelectedEnd, color, 0.0);
- tintImage(&imageTabSelectedBegin, color, 0.0);
- tintImage(&imageTabMiddle, color, 0.0);
-
- if (!doubleControls) {
- int height = imageTabMiddle.height() / 2 + 1;
- imageTabEnd = imageTabEnd.scaledToHeight(height);
- imageTabMiddle = imageTabMiddle.scaledToHeight(height);
- imageTabSelectedEnd = imageTabSelectedEnd.scaledToHeight(height);
- imageTabSelectedBegin = imageTabSelectedBegin.scaledToHeight(height);
- }
-}
-
-void QWindowsMobileStylePrivate::tintImagesHigh(QColor color)
-{
- if (currentTintHigh == color)
- return;
- currentTintHigh = color;
- tintListViewHighlight(color);
- imageScrollbarHandleUpHigh = imageScrollbarHandleUp;
- imageScrollbarHandleDownHigh = imageScrollbarHandleDown;
- tintImagePal(&imageScrollbarHandleDownHigh, color, qreal(0.8));
- tintImagePal(&imageScrollbarHandleUpHigh, color, qreal(0.8));
-}
-
-void QWindowsMobileStylePrivate::tintListViewHighlight(QColor color)
-{
- imageListViewHighlightCornerRight = QImage(listviewhighcornerright_xpm);
- tintImage(&imageListViewHighlightCornerRight, color, qreal(0.0));
-
- imageListViewHighlightCornerLeft = QImage(listviewhighcornerleft_xpm);
- tintImage(&imageListViewHighlightCornerLeft, color, qreal(0.0));
-
- imageListViewHighlightMiddle = QImage(listviewhighmiddle_xpm);
- tintImage(&imageListViewHighlightMiddle, color, qreal(0.0));
-
- int height = imageListViewHighlightMiddle.height();
- if (!doubleControls) {
- height = height / 2;
- imageListViewHighlightCornerRight = imageListViewHighlightCornerRight.scaledToHeight(height);
- imageListViewHighlightCornerLeft = imageListViewHighlightCornerLeft.scaledToHeight(height);
- imageListViewHighlightMiddle = imageListViewHighlightMiddle.scaledToHeight(height);
- }
-}
-
-#endif //Q_OS_WINCE_WM
-
-void QWindowsMobileStylePrivate::setupWindowsMobileStyle65()
-{
-#ifdef Q_OS_WINCE_WM
- wm65 = qt_wince_is_windows_mobile_65();
- if (wm65) {
- imageScrollbarHandleUp = QImage(sbhandleup_xpm);
- imageScrollbarHandleDown = QImage(sbhandledown_xpm);
- imageScrollbarGripUp = QImage(sbgripup_xpm);
- imageScrollbarGripDown = QImage(sbgripdown_xpm);
- imageScrollbarGripMiddle = QImage(sbgripmiddle_xpm);
-
- if (!doubleControls) {
- imageScrollbarHandleUp = imageScrollbarHandleUp.scaledToHeight(imageScrollbarHandleUp.height() / 2);
- imageScrollbarHandleDown = imageScrollbarHandleDown.scaledToHeight(imageScrollbarHandleDown.height() / 2);
- imageScrollbarGripMiddle = imageScrollbarGripMiddle.scaledToHeight(imageScrollbarGripMiddle.height() / 2);
- imageScrollbarGripUp = imageScrollbarGripUp.scaledToHeight(imageScrollbarGripUp.height() / 2);
- imageScrollbarGripDown = imageScrollbarGripDown.scaledToHeight(imageScrollbarGripDown.height() / 2);
- } else {
- }
- tintImagesHigh(Qt::blue);
- }
-#endif //Q_OS_WINCE_WM
-}
-
-void QWindowsMobileStylePrivate::drawTabBarTab(QPainter *painter, const QStyleOptionTab *tab)
-{
-#ifndef QT_NO_TABBAR
-#ifdef Q_OS_WINCE_WM
- if (wm65) {
- tintImagesButton(tab->palette.button().color());
- QRect r;
- r.setTopLeft(tab->rect.topRight() - QPoint(imageTabMiddle.width(), 0));
- r.setBottomRight(tab->rect.bottomRight());
- if (tab->state & QStyle::State_Selected) {
- painter->fillRect(tab->rect, tab->palette.window());
- } else {
- painter->fillRect(tab->rect, QColor(imageTabMiddle.pixel(0,0)));
- }
- if (tab->selectedPosition == QStyleOptionTab::NextIsSelected) {
- painter->drawImage(r, imageTabSelectedBegin);
- } else if (tab->position == QStyleOptionTab::End ||
- tab->position == QStyleOptionTab::OnlyOneTab) {
- if (!(tab->state & QStyle::State_Selected)) {
- painter->drawImage(r, imageTabEnd);
- }
- } else if (tab->state & QStyle::State_Selected) {
- painter->drawImage(r, imageTabSelectedEnd);
- } else {
- painter->drawImage(r, imageTabMiddle);
- }
- if (tab->position == QStyleOptionTab::Beginning && ! (tab->state & QStyle::State_Selected)) {
- painter->drawImage(tab->rect.topLeft() - QPoint(imageTabMiddle.width() * 0.60, 0), imageTabSelectedEnd);
- }
- //imageTabBarBig
- return;
- }
-#endif //Q_OS_WINCE_WM
- painter->save();
- painter->setPen(tab->palette.shadow().color());
- if (doubleControls) {
- QPen pen = painter->pen();
- pen.setWidth(2);
- pen.setCapStyle(Qt::FlatCap);
- painter->setPen(pen);
- }
- if(tab->shape == QTabBar::RoundedNorth) {
- if (tab->state & QStyle::State_Selected) {
- painter->fillRect(tab->rect, tab->palette.light());
- painter->drawLine(tab->rect.topRight(), tab->rect.bottomRight());
- }
- else {
- painter->fillRect(tab->rect, tab->palette.button());
- painter->drawLine(tab->rect.bottomLeft() , tab->rect.bottomRight());
- painter->drawLine(tab->rect.topRight(), tab->rect.bottomRight());
- }
- }
- else if(tab->shape == QTabBar::RoundedSouth) {
- if (tab->state & QStyle::State_Selected) {
- painter->fillRect(tab->rect.adjusted(0,-2,0,0), tab->palette.light());
- painter->drawLine(tab->rect.topRight(), tab->rect.bottomRight());
- }
- else {
- painter->fillRect(tab->rect, tab->palette.button());
- if (doubleControls)
- painter->drawLine(tab->rect.topLeft() + QPoint(0,1), tab->rect.topRight() + QPoint(0,1));
- else
- painter->drawLine(tab->rect.topLeft(), tab->rect.topRight());
- painter->drawLine(tab->rect.topRight(), tab->rect.bottomRight());
- }
- }
- else if(tab->shape == QTabBar::RoundedEast) {
- if (tab->state & QStyle::State_Selected) {
- painter->fillRect(tab->rect, tab->palette.light());
- painter->drawLine(tab->rect.topLeft(), tab->rect.topRight());
- }
- else {
- painter->fillRect(tab->rect, tab->palette.button());
- painter->drawLine(tab->rect.topLeft(), tab->rect.bottomLeft());
- painter->drawLine(tab->rect.topLeft(), tab->rect.topRight());
- }
- }
- else if(tab->shape == QTabBar::RoundedWest) {
- if (tab->state & QStyle::State_Selected) {
- painter->fillRect(tab->rect, tab->palette.light());
- painter->drawLine(tab->rect.bottomLeft(), tab->rect.bottomRight());
- }
- else {
- painter->fillRect(tab->rect, tab->palette.button());
- painter->drawLine(tab->rect.topRight(), tab->rect.bottomRight());
- painter->drawLine(tab->rect.bottomLeft(), tab->rect.bottomRight());
- }
- }
- painter->restore();
-#endif //QT_NO_TABBAR
-}
-
-void QWindowsMobileStylePrivate::drawPanelItemViewSelected(QPainter *painter, const QStyleOptionViewItem *option, QRect rect)
-{
-#ifdef Q_OS_WINCE_WM
- if (wm65) {
- QRect r;
- if (rect.isValid())
- r = rect;
- else
- r = option->rect;
- tintImagesHigh(option->palette.highlight().color());
-
- painter->setPen(QColor(Qt::lightGray));
-
- if (option->viewItemPosition == QStyleOptionViewItem::Middle) {
- painter->drawImage(r, imageListViewHighlightMiddle);
- } else if (option->viewItemPosition == QStyleOptionViewItem::Beginning) {
- painter->drawImage(r.adjusted(10, 0, 0, 0), imageListViewHighlightMiddle);
- } else if (option->viewItemPosition == QStyleOptionViewItem::End) {
- painter->drawImage(r.adjusted(0, 0, -10, 0), imageListViewHighlightMiddle);
- } else {
- painter->drawImage(r.adjusted(10, 0, -10, 0), imageListViewHighlightMiddle);
- }
-
- QImage cornerLeft = imageListViewHighlightCornerLeft;
- QImage cornerRight = imageListViewHighlightCornerRight;
-
- int width = r.width() > cornerRight.width() ? r.width() : cornerRight.width();
-
- if ((width * 2) > r.width()) {
- width = (r.width() - 5) / 2;
- }
-
- cornerLeft = cornerLeft.scaled(width, r.height());
- cornerRight = cornerRight.scaled(width, r.height());
-
- if ((option->viewItemPosition == QStyleOptionViewItem::Beginning) || (option->viewItemPosition == QStyleOptionViewItem::OnlyOne) || !option->viewItemPosition) {
- painter->drawImage(r.topLeft(), cornerLeft);
- }
- if ((option->viewItemPosition == QStyleOptionViewItem::End) || (option->viewItemPosition == QStyleOptionViewItem::OnlyOne) || !option->viewItemPosition) {
- painter->drawImage(r.topRight() - QPoint(cornerRight.width(),0), cornerRight);
- }
- return;
- }
-#endif //Q_OS_WINCE_WM
- QPalette::ColorGroup cg = option->state & QStyle::State_Enabled
- ? QPalette::Normal : QPalette::Disabled;
-
- if (rect.isValid())
- painter->fillRect(rect, option->palette.brush(cg, QPalette::Highlight));
- else
- painter->fillRect(option->rect, option->palette.brush(cg, QPalette::Highlight));
-}
-
-void QWindowsMobileStylePrivate::drawScrollbarGrip(QPainter *p, QStyleOptionSlider *newScrollbar, const QStyleOptionComplex *option, bool drawCompleteFrame)
-{
-#ifdef Q_OS_WINCE_WM
- if (wm65) {
- if (newScrollbar->orientation == Qt::Horizontal) {
- QTransform transform;
- transform.rotate(-90);
- QRect r = newScrollbar->rect;
- p->drawImage(r.adjusted(10, 0, -10, 0), imageScrollbarGripMiddle.transformed(transform));
- p->drawImage(r.topLeft(), imageScrollbarGripUp.transformed(transform));
- p->drawImage(r.topRight() - QPoint(imageScrollbarGripDown.height() - 1, 0), imageScrollbarGripDown.transformed(transform));
- } else {
- QRect r = newScrollbar->rect;
- p->drawImage(r.adjusted(0, 10, 0, -10), imageScrollbarGripMiddle);
- p->drawImage(r.topLeft(), imageScrollbarGripUp);
- p->drawImage(r.bottomLeft() - QPoint(0, imageScrollbarGripDown.height() - 1), imageScrollbarGripDown);
- }
- return ;
- }
-#endif
- if (newScrollbar->orientation == Qt::Horizontal) {
- p->fillRect(newScrollbar->rect,option->palette.button());
- QRect r = newScrollbar->rect;
- p->drawLine(r.topLeft(), r.bottomLeft());
- p->drawLine(r.topRight(), r.bottomRight());
- if (smartphone) {
- p->drawLine(r.topLeft(), r.topRight());
- p->drawLine(r.bottomLeft(), r.bottomRight());
- }
- }
- else {
- p->fillRect(newScrollbar->rect,option->palette.button());
- QRect r = newScrollbar->rect;
- p->drawLine(r.topLeft(), r.topRight());
- p->drawLine(r.bottomLeft(), r.bottomRight());
- if (smartphone) {
- p->drawLine(r.topLeft(), r.bottomLeft());
- p->drawLine(r.topRight(), r.bottomRight());
- }
- }
- if (newScrollbar->state & QStyle::State_HasFocus) {
- QStyleOptionFocusRect fropt;
- fropt.QStyleOption::operator=(*newScrollbar);
- fropt.rect.setRect(newScrollbar->rect.x() + 2, newScrollbar->rect.y() + 2,
- newScrollbar->rect.width() - 5,
- newScrollbar->rect.height() - 5);
- }
- int gripMargin = doubleControls ? 4 : 2;
- int doubleLines = doubleControls ? 2 : 1;
- //If there is a frame around the scrollbar (abstractScrollArea),
- //then the margin is different, because of the missing frame
- int gripMarginFrame = doubleControls ? 3 : 1;
- if (drawCompleteFrame)
- gripMarginFrame = 0;
- //draw grips
- if (!smartphone)
- if (newScrollbar->orientation == Qt::Horizontal) {
- for (int i = -3; i < 3; i += 2) {
- p->drawLine(
- QPoint(newScrollbar->rect.center().x() + i * doubleLines + 1,
- newScrollbar->rect.top() + gripMargin +gripMarginFrame),
- QPoint(newScrollbar->rect.center().x() + i * doubleLines + 1,
- newScrollbar->rect.bottom() - gripMargin));
- }
- } else {
- for (int i = -2; i < 4 ; i += 2) {
- p->drawLine(
- QPoint(newScrollbar->rect.left() + gripMargin + gripMarginFrame ,
- newScrollbar->rect.center().y() + 1 + i * doubleLines - 1),
- QPoint(newScrollbar->rect.right() - gripMargin,
- newScrollbar->rect.center().y() + 1 + i * doubleLines - 1));
- }
- }
- if (!smartphone) {
- QRect r;
- if (doubleControls)
- r = option->rect.adjusted(1, 1, -1, 0);
- else
- r = option->rect.adjusted(0, 0, -1, 0);
- if (drawCompleteFrame && doubleControls)
- r.adjust(0, 0, 0, -1);
- //Check if the scrollbar is part of an abstractItemView and draw the frame according
- if (drawCompleteFrame)
- p->drawRect(r);
- else
- if (newScrollbar->orientation == Qt::Horizontal)
- p->drawLine(r.topLeft(), r.topRight());
- else
- p->drawLine(r.topLeft(), r.bottomLeft());
- }
-}
-
-void QWindowsMobileStylePrivate::drawScrollbarHandleUp(QPainter *p, QStyleOptionSlider *opt, bool completeFrame, bool )
-{
-#ifdef Q_OS_WINCE_WM
- if (wm65) {
- tintImagesHigh(opt->palette.highlight().color());
- QRect r = opt->rect;
- if (opt->orientation == Qt::Horizontal) {
- QTransform transform;
- transform.rotate(-90);
- if (opt->state & QStyle::State_Sunken)
- p->drawImage(r.topLeft(), imageScrollbarHandleUpHigh.transformed(transform));
- else
- p->drawImage(r.topLeft(), imageScrollbarHandleUp.transformed(transform));
- } else {
- if (opt->state & QStyle::State_Sunken)
- p->drawImage(r.topLeft(), imageScrollbarHandleUpHigh);
- else
- p->drawImage(r.topLeft(), imageScrollbarHandleUp);
- }
- return ;
- }
-#endif //Q_OS_WINCE_WM
-
- QBrush fill = opt->palette.button();
- if (opt->state & QStyle::State_Sunken)
- fill = opt->palette.shadow();
-
- QStyleOption arrowOpt = *opt;
- if (doubleControls)
- arrowOpt.rect = opt->rect.adjusted(4, 6, -5, -3);
- else
- arrowOpt.rect = opt->rect.adjusted(5, 6, -4, -3);
-
- bool horizontal = (opt->orientation == Qt::Horizontal);
-
- if (horizontal) {
- p->fillRect(opt->rect,fill);
- QRect r = opt->rect.adjusted(0,0,1,0);
- p->drawLine(r.topRight(), r.bottomRight());
- if (doubleControls)
- arrowOpt.rect.adjust(0, -2 ,0, -2);
- q_func()->proxy()->drawPrimitive(QStyle::PE_IndicatorArrowLeft, &arrowOpt, p, 0);
- } else {
- p->fillRect(opt->rect,fill);
- QRect r = opt->rect.adjusted(0, 0, 0, 1);
- p->drawLine(r.bottomLeft(), r.bottomRight());
- if (completeFrame)
- arrowOpt.rect.adjust(-2, 0, -2, 0);
- if (doubleControls)
- arrowOpt.rect.adjust(0, -4 , 0, -4);
- if (completeFrame && doubleControls)
- arrowOpt.rect.adjust(2, 0, 2, 0);
- q_func()->proxy()->drawPrimitive(QStyle::PE_IndicatorArrowUp, &arrowOpt, p, 0);
- }
-}
-
-void QWindowsMobileStylePrivate::drawScrollbarHandleDown(QPainter *p, QStyleOptionSlider *opt, bool completeFrame, bool secondScrollBar)
-{
-#ifndef QT_NO_SCROLLBAR
-#ifdef Q_OS_WINCE_WM
- if (wm65) {
- tintImagesHigh(opt->palette.highlight().color());
- QRect r = opt->rect;
- if (opt->orientation == Qt::Horizontal) {
- QTransform transform;
- transform.rotate(-90);
- if (opt->state & QStyle::State_Sunken)
- p->drawImage(r.topLeft(), imageScrollbarHandleDownHigh.transformed(transform));
- else
- p->drawImage(r.topLeft(), imageScrollbarHandleDown.transformed(transform));
- } else {
- if (opt->state & QStyle::State_Sunken)
- p->drawImage(r.topLeft(), imageScrollbarHandleDownHigh);
- else
- p->drawImage(r.topLeft(), imageScrollbarHandleDown);
- }
- return ;
- }
-#endif //Q_OS_WINCE_WM
-
- QBrush fill = opt->palette.button();
- if (opt->state & QStyle::State_Sunken)
- fill = opt->palette.shadow();
-
- QStyleOption arrowOpt = *opt;
- if (doubleControls)
- arrowOpt.rect = opt->rect.adjusted(4, 0, -5, 3);
- else
- arrowOpt.rect = opt->rect.adjusted(5, 6, -4, -3);
-
- bool horizontal = (opt->orientation == Qt::Horizontal);
-
- if (horizontal) {
- p->fillRect(opt->rect,fill);
- QRect r = opt->rect.adjusted(0, 0, 0, 0);
- p->drawLine(r.topLeft(), r.bottomLeft());
- if (secondScrollBar)
- p->drawLine(r.topRight(), r.bottomRight());
- if (doubleControls)
- arrowOpt.rect.adjust(0, 4, 0, 4 );
- q_func()->proxy()->drawPrimitive(QStyle::PE_IndicatorArrowRight, &arrowOpt, p, 0);
- } else {
- p->fillRect(opt->rect,fill);
- QRect r = opt->rect.adjusted(0, -1, 0, -1);
- p->drawLine(r.topLeft(), r.topRight());
- if (secondScrollBar)
- p->drawLine(r.bottomLeft() + QPoint(0,1), r.bottomRight() + QPoint(0, 1));
- if (completeFrame)
- arrowOpt.rect.adjust(-2, 0, -2, 0);
- if (doubleControls)
- arrowOpt.rect.adjust(1, 0, 1, 0 );
- if (completeFrame && doubleControls)
- arrowOpt.rect.adjust(1, 0, 1, 0);
- q_func()->proxy()->drawPrimitive(QStyle::PE_IndicatorArrowDown, &arrowOpt, p, 0);
- }
-#endif //QT_NO_SCROLLBAR
-}
-
-void QWindowsMobileStylePrivate::drawScrollbarGroove(QPainter *p,const QStyleOptionSlider *opt)
-{
-#ifndef QT_NO_SCROLLBAR
-#ifdef Q_OS_WINCE_WM
- if (wm65) {
- p->fillRect(opt->rect, QColor(231, 231, 231));
- return ;
- }
-#endif
- QBrush fill;
- if (smartphone) {
- fill = opt->palette.light();
- p->fillRect(opt->rect, fill);
- fill = opt->palette.button();
- QImage image;
-#ifndef QT_NO_IMAGEFORMAT_XPM
- if (opt->orientation == Qt::Horizontal)
- image = QImage(vertlines_xpm);
- else
- image = QImage(horlines_xpm);
-#endif
- image.setColor(1, opt->palette.button().color().rgb());
- fill.setTextureImage(image);
- }
- else {
- fill = opt->palette.light();
- }
- p->fillRect(opt->rect, fill);
-#endif //QT_NO_SCROLLBAR
-}
-
-QWindowsMobileStyle::QWindowsMobileStyle(QWindowsMobileStylePrivate &dd) : QWindowsStyle(dd) {
- qApp->setEffectEnabled(Qt::UI_FadeMenu, false);
- qApp->setEffectEnabled(Qt::UI_AnimateMenu, false);
-}
-
-QWindowsMobileStyle::QWindowsMobileStyle() : QWindowsStyle(*new QWindowsMobileStylePrivate) {
- qApp->setEffectEnabled(Qt::UI_FadeMenu, false);
- qApp->setEffectEnabled(Qt::UI_AnimateMenu, false);
-}
-
-QWindowsMobileStyle::~QWindowsMobileStyle()
-{
-}
-
-QWindowsMobileStylePrivate::QWindowsMobileStylePrivate() :QWindowsStylePrivate() {
-
-#ifdef Q_OS_WINCE
- doubleControls = qt_wince_is_high_dpi();
- smartphone = qt_wince_is_smartphone();
-#else
- doubleControls = false;
- smartphone = false;
-#endif //Q_OS_WINCE
-
-#ifndef QT_NO_IMAGEFORMAT_XPM
-
- imageArrowDown = QImage(arrowdown_xpm);
- imageArrowUp = QImage(arrowdown_xpm).mirrored();
- imageArrowLeft = QImage(arrowleft_xpm);
- imageArrowRight = QImage(arrowleft_xpm).mirrored(true, false);
- if (doubleControls) {
- imageRadioButton = QImage(radiobutton_xpm);
- imageRadioButtonChecked = QImage(radiochecked_xpm);
- imageChecked = QImage(checkedlight_xpm);
- imageCheckedBold = QImage(checkedbold_xpm);
- imageRadioButtonHighlighted = QImage(highlightedradiobutton_xpm);
- imageClose = QImage(cross_big_xpm);
- imageMaximize = QImage(max_big_xpm);
- imageMinimize = QImage(min_big_xpm);
- imageNormalize = QImage(normal_big_xpm);
- } else {
- imageRadioButton = QImage(radiobutton_low_xpm);
- imageRadioButtonChecked = QImage(radiochecked_low_xpm);
- imageChecked = QImage(checkedlight_low_xpm);
- imageCheckedBold = QImage(checkedbold_low_xpm);
- imageRadioButtonHighlighted = QImage(highlightedradiobutton_low_xpm);
- imageClose = QImage(cross_small_xpm);
- imageMaximize = QImage(max_small_xpm);
- imageMinimize = QImage(min_small_xpm);
- imageNormalize = QImage(normal_small_xpm);
- }
-
- setupWindowsMobileStyle65();
-
-
- imageArrowDownBig = QImage(arrowdown_big_xpm);
- imageArrowUpBig = QImage(arrowdown_big_xpm).mirrored();
- imageArrowLeftBig = QImage(arrowleft_big_xpm);
- imageArrowRightBig = QImage(arrowleft_big_xpm).mirrored(true, false);
-
-#endif
-}
-
-void QWindowsMobileStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
- QPainter *painter, const QWidget *widget) const {
-
- QWindowsMobileStylePrivate *d = const_cast<QWindowsMobileStylePrivate*>(d_func());
-
- bool doRestore = false;
- QRect rect = option->rect;
- painter->setClipping(false);
-
- switch (element) {
- case PE_PanelButtonTool: {
- int penSize = 1;
- if (d->doubleControls)
- penSize = 2;
- if (widget)
- if (QWidget *parent = widget->parentWidget())
-#ifndef QT_NO_TABWIDGET
- if (qobject_cast<QTabWidget *>(parent->parentWidget())) {
-#else
- if (false) {
-#endif //QT_NO_TABBAR
- rect.adjust(0,2*penSize,0,-1*penSize);
- qDrawPlainRect(painter, rect, option->palette.shadow().color(), penSize, &option->palette.light());
- if (option->state & (State_Sunken))
- qDrawPlainRect(painter, rect, option->palette.shadow().color(), penSize, &option->palette.shadow());
- }
- else {
- if (!(option->state & State_AutoRaise) || (option->state & (State_Sunken | State_On)))
- qDrawPlainRect(painter,option->rect.adjusted(0, penSize, 0, -1 * penSize) ,
- option->palette.button().color(), 0, &option->palette.button());
- if (option->state & (State_Sunken)) {
- qDrawPlainRect(painter, rect, option->palette.shadow().color(), penSize, &option->palette.light());
- }
- if (option->state & (State_On)){
- QBrush fill = QBrush(option->palette.light().color());
- painter->fillRect(rect.adjusted(windowsItemFrame , windowsItemFrame ,
- -windowsItemFrame , -windowsItemFrame ), fill);
- qDrawPlainRect(painter, rect, option->palette.shadow().color(), penSize, &option->palette.light());
- }
- }
- break; }
- case PE_IndicatorButtonDropDown:
- if (d->doubleControls)
- qDrawPlainRect(painter, option->rect, option->palette.shadow().color(), 2, &option->palette.button());
- else
- qDrawPlainRect(painter, option->rect, option->palette.shadow().color(), 1, &option->palette.button());
- break;
-#ifndef QT_NO_TABBAR
- case PE_IndicatorTabTear:
- if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
- bool rtl = tab->direction == Qt::RightToLeft;
- QRect rect = tab->rect;
- QPainterPath path;
- rect.setTop(rect.top() + ((tab->state & State_Selected) ? 1 : 3));
- rect.setBottom(rect.bottom() - ((tab->state & State_Selected) ? 0 : 2));
- path.moveTo(QPoint(rtl ? rect.right() : rect.left(), rect.top()));
- int count = 3;
- for(int jags = 1; jags <= count; ++jags, rtl = !rtl)
- path.lineTo(QPoint(rtl ? rect.left() : rect.right(), rect.top() + jags * rect.height()/count));
- painter->setPen(QPen(tab->palette.light(), qreal(.8)));
- painter->setBrush(tab->palette.background());
- painter->setRenderHint(QPainter::Antialiasing);
- painter->drawPath(path);
- }
- break;
-#endif //QT_NO_TABBAR
-
-#ifndef QT_NO_TOOLBAR
- case PE_IndicatorToolBarSeparator: {
- painter->save();
- QPoint p1, p2;
- if (option->state & State_Horizontal) {
- p1 = QPoint(option->rect.width()/2, 0);
- p2 = QPoint(p1.x(), option->rect.height());
- } else {
- p1 = QPoint(0, option->rect.height()/2);
- p2 = QPoint(option->rect.width(), p1.y());
- }
-
-
- painter->setPen(option->palette.mid().color());
- if (d->doubleControls) {
- QPen pen = painter->pen();
- pen.setWidth(2);
- pen.setCapStyle(Qt::FlatCap);
- painter->setPen(pen);
- }
- painter->drawLine(p1, p2);
- painter->restore();
- break; }
-#endif // QT_NO_TOOLBAR
- case PE_IndicatorToolBarHandle:
- painter->save();
- painter->translate(option->rect.x(), option->rect.y());
- if (option->state & State_Horizontal) {
- int x = option->rect.width() / 2 - 4;
- if (QApplication::layoutDirection() == Qt::RightToLeft)
- x -= 2;
- if (option->rect.height() > 4) {
- qDrawWinButton(painter,x-1,0,7,option->rect.height(), option->palette, false, 0);
-
- qDrawShadePanel(painter, x, 1, 3, option->rect.height() - 1,
- option->palette, false, 0);
- qDrawShadePanel(painter, x + 3, 1, 3, option->rect.height() - 1,
- option->palette, false, 0);
- painter->setPen(option->palette.button().color());
- }
- } else {
- if (option->rect.width() > 4) {
- int y = option->rect.height() / 2 - 4;
- qDrawShadePanel(painter, 2, y, option->rect.width() - 2, 3,
- option->palette, false, 0);
- qDrawShadePanel(painter, 2, y + 3, option->rect.width() - 2, 3,
- option->palette, false, 0);
- }
- }
- painter->restore();
- break;
-
-#ifndef QT_NO_PROGRESSBAR
- case PE_IndicatorProgressChunk: {
- bool vertical = false;
- if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option))
- vertical = pb->orientation == Qt::Vertical;
- if (!vertical) {
- painter->fillRect(option->rect.x(), option->rect.y()+2, option->rect.width(), option->rect.height()-4,
- option->palette.brush(QPalette::Highlight));
- } else {
- painter->fillRect(option->rect.x()+2, option->rect.y(), option->rect.width()-4, option->rect.height(),
- option->palette.brush(QPalette::Highlight));
- }
- }
- break;
-#endif // QT_NO_PROGRESSBAR
-
- case PE_FrameButtonTool: {
-#ifndef QT_NO_DOCKWIDGET
- if (widget && widget->inherits("QDockWidgetTitleButton")) {
- if (const QDockWidget *dw = qobject_cast<const QDockWidget *>(widget->parent()))
- if (dw->isFloating()){
- qDrawPlainRect(painter,option->rect.adjusted(1, 1, 0, 0),
- option->palette.shadow().color(),1,&option->palette.button());
- return;
- }
- }
-#endif // QT_NO_DOCKWIDGET
- QBrush fill;
- bool stippled;
- bool panel = (element == PE_PanelButtonTool);
- if ((!(option->state & State_Sunken ))
- && (!(option->state & State_Enabled)
- || ((option->state & State_Enabled ) && !(option->state & State_MouseOver)))
- && (option->state & State_On)) {
- fill = QBrush(option->palette.light().color(), Qt::Dense4Pattern);
- stippled = true;
- } else {
- fill = option->palette.brush(QPalette::Button);
- stippled = false;
- }
- if (option->state & (State_Raised | State_Sunken | State_On)) {
- if (option->state & State_AutoRaise) {
- if(option->state & (State_Enabled | State_Sunken | State_On)){
- if (panel)
- qDrawPlainRect(painter, option->rect,option->palette.shadow().color(),d->doubleControls, &fill);
- else
- qDrawPlainRect(painter, option->rect,option->palette.shadow().color(),d->doubleControls, &fill);
- }
- if (stippled) {
- painter->setPen(option->palette.button().color());
- painter->drawRect(option->rect.adjusted(1, 1, -2, -2));
- }
- } else {
- qDrawPlainRect(painter, option->rect,option->palette.shadow().color(),d->doubleControls, &fill);
- }
- } else {
- painter->fillRect(option->rect, fill);
- }
- break; }
-
- case PE_FrameFocusRect:
- if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(option)) {
- //### check for d->alt_down
- int penSize;
- d->doubleControls ? penSize = 2 : penSize = 1;
- bool alternateFocusStyle = false;
- if (!widget)
- alternateFocusStyle = true;
-#ifndef QT_NO_COMBOBOX
- if (qobject_cast<const QComboBox*>(widget))
- alternateFocusStyle = true;
-#endif
- if (!(fropt->state & State_KeyboardFocusChange) && !styleHint(SH_UnderlineShortcut, option))
- return;
- QRect r = option->rect;
- painter->save();
- painter->setBackgroundMode(Qt::TransparentMode);
- if (alternateFocusStyle) {
- QColor bg_col = fropt->backgroundColor;
- if (!bg_col.isValid())
- bg_col = painter->background().color();
- // Create an "XOR" color.
- QColor patternCol((bg_col.red() ^ 0xff) & 0xff,
- (bg_col.green() ^ 0xff) & 0xff,
- (bg_col.blue() ^ 0xff) & 0xff);
- painter->setBrush(QBrush(patternCol, Qt::Dense4Pattern));
- painter->setBrushOrigin(r.topLeft());
- }
- else {
- painter->setPen(option->palette.highlight().color());
- painter->setBrush(option->palette.highlight());
- }
- painter->setPen(Qt::NoPen);
- painter->setBrushOrigin(r.topLeft());
- painter->drawRect(r.left(), r.top(), r.width(), penSize); // Top
- painter->drawRect(r.left(), r.bottom(), r.width() + penSize - 1, penSize); // Bottom
- painter->drawRect(r.left(), r.top(), penSize, r.height()); // Left
- painter->drawRect(r.right(), r.top(), penSize, r.height()); // Right
- painter->restore();
- }
- break;
-
- case PE_PanelButtonBevel: {
- QBrush fill;
- bool panel = element != PE_FrameButtonBevel;
- painter->setBrushOrigin(option->rect.topLeft());
- if (!(option->state & State_Sunken) && (option->state & State_On))
- fill = QBrush(option->palette.light().color(), Qt::Dense4Pattern);
- else
- fill = option->palette.brush(QPalette::Button);
-
- if (option->state & (State_Raised | State_On | State_Sunken)) {
- if (d->doubleControls)
- qDrawPlainRect(painter, option->rect,option->palette.shadow().color(),2,&fill);
- else
- qDrawPlainRect(painter, option->rect,option->palette.shadow().color(),1,&fill);
- } else {
- if (panel)
- painter->fillRect(option->rect, fill);
- else
- painter->drawRect(option->rect);
- }
- break; }
-
- case PE_FrameGroupBox:
- if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
-
- if (!(frame->features & QStyleOptionFrame::Flat)) {
- QPen oldPen = painter->pen();
- QRect r = frame->rect;
- painter->setPen(frame->palette.shadow().color());
- painter->fillRect(r.x(), r.y(), r.x() + r.width()-1,
- r.y() + r.height() - windowsMobileFrameGroupBoxOffset,
- frame->palette.light());
- painter ->drawLine(r.topLeft() + QPoint(-2, 1), r.topRight()+ QPoint(0, 1));
- if (d->doubleControls)
- painter ->drawLine(r.topLeft() + QPoint(-2, 2), r.topRight()+ QPoint(0, 2));
- painter->setPen(oldPen);
- }
- }
- break;
-
- case PE_IndicatorCheckBox: {
- QBrush fill;
- QRect r = d->doubleControls ? option->rect.adjusted(0,1,0,-1) : option->rect;
- if (option->state & State_NoChange)
- fill = QBrush(option->palette.shadow().color(), Qt::Dense4Pattern);
- else if (option->state & State_Sunken)
- fill = option->palette.button();
- else if (option->state & State_Enabled)
- fill = option->palette.base();
- else
- fill = option->palette.background();
- painter->save();
- doRestore = true;
- if (d->doubleControls && (option->state & State_NoChange))
- painter->fillRect(r, fill);
- else
- painter->fillRect(option->rect, fill);
- painter->setPen(option->palette.shadow().color());
- painter->drawLine(r.topLeft(), r.topRight());
- painter->drawLine(r.topRight(), r.bottomRight());
- painter->drawLine(r.bottomLeft(), r.bottomRight());
- painter->drawLine(r.bottomLeft(), r.topLeft());
- if (d->doubleControls) {
- QRect r0 = r.adjusted(1, 1, -1, -1);
- painter->drawLine(r0.topLeft(), r0.topRight());
- painter->drawLine(r0.topRight(), r0.bottomRight());
- painter->drawLine(r0.bottomLeft(), r0.bottomRight());
- painter->drawLine(r0.bottomLeft(), r0.topLeft());
- }
- if (option->state & State_HasFocus) {
- painter->setPen(option->palette.highlight().color());
- QRect r2 = d->doubleControls ? r.adjusted(2, 2, -2, -2) : r.adjusted(1, 1, -1, -1);
- painter->drawLine(r2.topLeft(), r2.topRight());
- painter->drawLine(r2.topRight(), r2.bottomRight());
- painter->drawLine(r2.bottomLeft(), r2.bottomRight());
- painter->drawLine(r2.bottomLeft(), r2.topLeft());
- if (d->doubleControls) {
- QRect r3 = r2.adjusted(1, 1, -1, -1);
- painter->drawLine(r3.topLeft(), r3.topRight());
- painter->drawLine(r3.topRight(), r3.bottomRight());
- painter->drawLine(r3.bottomLeft(), r3.bottomRight());
- painter->drawLine(r3.bottomLeft(), r3.topLeft());
- }
- painter->setPen(option->palette.shadow().color());
- }
- //fall through...
- }
- case PE_IndicatorViewItemCheck: {
- if (!doRestore) {
- painter->save();
- doRestore = true;
- }
- if (element == PE_IndicatorViewItemCheck) {
- painter->setPen(option->palette.shadow().color());
- if (option->state & State_NoChange)
- painter->setBrush(option->palette.brush(QPalette::Button));
- if (d->doubleControls) {
- QRect r = QRect(option->rect.x(), option->rect.y(), windowsMobileitemViewCheckBoxSize * 2, windowsMobileitemViewCheckBoxSize * 2);
- qDrawPlainRect(painter, r, option->palette.shadow().color(), 2);
- } else {
- QRect r = QRect(option->rect.x(), option->rect.y(), windowsMobileitemViewCheckBoxSize, windowsMobileitemViewCheckBoxSize);
- qDrawPlainRect(painter, r, option->palette.shadow().color(), 1);
- }
- if (option->state & State_Enabled)
- d->imageChecked.setColor(1, option->palette.shadow().color().rgba());
- else
- d->imageChecked.setColor(1, option->palette.dark().color().rgba());
- if (!(option->state & State_Off)) {
- if (d->doubleControls)
- painter->drawImage(option->rect.x(), option->rect.y(), d->imageChecked);
- else
- painter->drawImage(option->rect.x() + 3, option->rect.y() + 3, d->imageChecked);
- }
- }
- else {
- if (option->state & State_NoChange)
- d->imageCheckedBold.setColor(1, option->palette.dark().color().rgba());
- else if (option->state & State_Enabled)
- d->imageCheckedBold.setColor(1, option->palette.shadow().color().rgba());
- else
- d->imageCheckedBold.setColor(1, option->palette.dark().color().rgba());
- if (!(option->state & State_Off)) {
- if (d->doubleControls)
- painter->drawImage(option->rect.x() + 2, option->rect.y(), d->imageCheckedBold);
- else
- painter->drawImage(option->rect.x() + 3, option->rect.y() + 3, d->imageCheckedBold);
- }
- }
- if (doRestore)
- painter->restore();
- break; }
- case PE_IndicatorRadioButton: {
- painter->save();
-
- if (option->state & State_HasFocus) {
- d->imageRadioButtonHighlighted.setColor(1, option->palette.shadow().color().rgba());
- d->imageRadioButtonHighlighted.setColor(2, option->palette.highlight().color().rgba());
- painter->drawImage(option->rect.x(), option->rect.y(), d->imageRadioButtonHighlighted);
- }
- else {
- d->imageRadioButton.setColor(1, option->palette.shadow().color().rgba());
- painter->drawImage(option->rect.x(), option->rect.y(), d->imageRadioButton);
- }
- if (option->state & (State_Sunken | State_On)) {
- if (option->state & State_Enabled)
- d->imageRadioButtonChecked.setColor(1, option->palette.shadow().color().rgba());
- else
- d->imageRadioButtonChecked.setColor(1, option->palette.dark().color().rgba());
-
- static const int offset = d->doubleControls ? 6 : 3;
- painter->drawImage(option->rect.x() + offset, option->rect.y() + offset, d->imageRadioButtonChecked);
- }
- painter->restore();
- break; }
- case PE_PanelButtonCommand:
- if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- QBrush fill;
- State flags = option->state;
- QPalette pal = option->palette;
- QRect r = option->rect;
- if ((flags & State_Sunken || flags & State_On) )
- fill = pal.brush(QPalette::Shadow);
- else
- fill = pal.brush(QPalette::Button);
- int singleLine = 1;
- int doubleLine = 2;
- if (d->doubleControls) {
- singleLine = 2;
- doubleLine = 4;
- }
- if (button->features & QStyleOptionButton::DefaultButton && flags & State_Sunken) {
- if (d->doubleControls) {
- qDrawPlainRect(painter, r, pal.shadow().color(), 1, &fill);
- qDrawPlainRect(painter, r.adjusted(1, 1, -1, 1), pal.shadow().color(), 1, &fill);
- }
- else {
- qDrawPlainRect(painter, r, pal.shadow().color(), 1, &fill);
- }
- } else if (flags & (State_Raised | State_Sunken | State_On | State_Sunken)) {
- qDrawPlainRect(painter, r, pal.shadow().color(), singleLine, &fill);
- } else {
- painter->fillRect(r, fill);
- }
- }
- break;
- case PE_FrameDefaultButton: {
- painter->save();
- painter->setPen(option->palette.shadow().color());
- QRect rect = option->rect;
- if (d->doubleControls) {
- rect.adjust(1, 1, -2, -2);
- painter->drawRect(rect);
- painter->drawRect(rect.adjusted(1, 1, -1, -1));
- }
-
- else {
- rect.adjust(2, 2, -3, -3);
- painter->drawRect(rect);
- }
- painter->restore();
- break; }
- case PE_IndicatorSpinPlus:
- case PE_IndicatorSpinMinus: {
- QRect r = option->rect;
- int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget)+2;
- QRect br = r.adjusted(fw, fw, -fw, -fw);
- int offset = (option->state & State_Sunken) ? 1 : 0;
- int step = (br.width() + 4) / 5;
- painter->fillRect(br.x() + offset, br.y() + offset +br.height() / 2 - step / 2,
- br.width(), step, option->palette.buttonText());
- if (element == PE_IndicatorSpinPlus)
- painter->fillRect(br.x() + br.width() / 2 - step / 2 + offset, br.y() + offset+4,
- step, br.height() - 7, option->palette.buttonText());
- break; }
- case PE_IndicatorSpinUp:
- case PE_IndicatorSpinDown: {
- painter->save();
- QPoint points[7];
- switch (element) {
- case PE_IndicatorSpinUp:
- points[0] = QPoint(-2, -4);
- points[1] = QPoint(-2, 2);
- points[2] = QPoint(-1, -3);
- points[3] = QPoint(-1, 1);
- points[4] = QPoint(0, -2);
- points[5] = QPoint(0, 0);
- points[6] = QPoint(1, -1);
- break;
- case PE_IndicatorSpinDown:
- points[0] = QPoint(0, -4);
- points[1] = QPoint(0, 2);
- points[2] = QPoint(-1, -3);
- points[3] = QPoint(-1, 1);
- points[4] = QPoint(-2, -2);
- points[5] = QPoint(-2, 0);
- points[6] = QPoint(-3, -1);
- break;
- default:
- break;
- }
- if (option->state & State_Sunken)
- painter->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal),
- proxy()->pixelMetric(PM_ButtonShiftVertical));
- if (option->state & State_Enabled) {
- painter->translate(option->rect.x() + option->rect.width() / 2,
- option->rect.y() + option->rect.height() / 2);
- painter->setPen(option->palette.buttonText().color());
- painter->drawLine(points[0], points[1]);
- painter->drawLine(points[2], points[3]);
- painter->drawLine(points[4], points[5]);
- painter->drawPoint(points[6]);
- } else {
- painter->translate(option->rect.x() + option->rect.width() / 2 + 1,
- option->rect.y() + option->rect.height() / 2 + 1);
- painter->setPen(option->palette.light().color());
- painter->drawLine(points[0], points[1]);
- painter->drawLine(points[2], points[3]);
- painter->drawLine(points[4], points[5]);
- painter->drawPoint(points[6]);
- painter->translate(-1, -1);
- painter->setPen(option->palette.mid().color());
- painter->drawLine(points[0], points[1]);
- painter->drawLine(points[2], points[3]);
- painter->drawLine(points[4], points[5]);
- painter->drawPoint(points[6]);
- }
- painter->restore();
- break; }
-
- case PE_IndicatorArrowUpBig:
- case PE_IndicatorArrowDownBig:
- case PE_IndicatorArrowLeftBig:
- case PE_IndicatorArrowRightBig:
-
- case PE_IndicatorArrowUp:
- case PE_IndicatorArrowDown:
- case PE_IndicatorArrowRight:
- case PE_IndicatorArrowLeft: {
- painter->save();
-
- if (d->doubleControls) {
- QColor color;
- if (option->state & State_Sunken)
- color = option->palette.light().color();
- else
- color = option->palette.buttonText().color();
- QImage image;
- int xoffset, yoffset;
- bool isTabBarArrow = widget && widget->parent()
- && widget->inherits("QToolButton")
- && widget->parent()->inherits("QTabBar");
-
- switch (element) {
- case PE_IndicatorArrowUp:
- image = d->imageArrowUp;
- xoffset = 1;
- yoffset = 12;
- break;
- case PE_IndicatorArrowDown:
- image = d->imageArrowDown;
- xoffset = 1;
- yoffset =12;
- break;
- case PE_IndicatorArrowLeft:
- image = d->imageArrowLeft;
- xoffset = 8;
- yoffset = isTabBarArrow ? 12 : 2;
- break;
- case PE_IndicatorArrowRight:
- image = d->imageArrowRight;
- xoffset = 8;
- yoffset = isTabBarArrow ? 12 : 2;
- break;
- case PE_IndicatorArrowUpBig:
- image = d->imageArrowUpBig;
- xoffset = 3;
- yoffset = 12;
- break;
- case PE_IndicatorArrowDownBig:
- image = d->imageArrowDownBig;
- xoffset = 2;
- yoffset =12;
- break;
- case PE_IndicatorArrowLeftBig:
- image = d->imageArrowLeftBig;
- xoffset = 8;
- yoffset = 2;
- break;
- case PE_IndicatorArrowRightBig:
- image = d->imageArrowRightBig;
- xoffset = 8;
- yoffset = 2;
- break;
- default:
- break;
- }
- image.setColor(1, color.rgba());
- painter->drawImage(option->rect.x() + xoffset, option->rect.y() + yoffset, image);
- }
- else {
- QPoint points[7];
- switch (element) {
- case PE_IndicatorArrowUp:
- case PE_IndicatorArrowUpBig:
- points[0] = QPoint(-3, 1);
- points[1] = QPoint(3, 1);
- points[2] = QPoint(-2, 0);
- points[3] = QPoint(2, 0);
- points[4] = QPoint(-1, -1);
- points[5] = QPoint(1, -1);
- points[6] = QPoint(0, -2);
- break;
- case PE_IndicatorArrowDown:
- case PE_IndicatorArrowDownBig:
- points[0] = QPoint(-3, -1);
- points[1] = QPoint(3, -1);
- points[2] = QPoint(-2, 0);
- points[3] = QPoint(2, 0);
- points[4] = QPoint(-1, 1);
- points[5] = QPoint(1, 1);
- points[6] = QPoint(0, 2);
- break;
- case PE_IndicatorArrowRight:
- case PE_IndicatorArrowRightBig:
- points[0] = QPoint(-2, -3);
- points[1] = QPoint(-2, 3);
- points[2] = QPoint(-1, -2);
- points[3] = QPoint(-1, 2);
- points[4] = QPoint(0, -1);
- points[5] = QPoint(0, 1);
- points[6] = QPoint(1, 0);
- break;
- case PE_IndicatorArrowLeft:
- case PE_IndicatorArrowLeftBig:
- points[0] = QPoint(0, -3);
- points[1] = QPoint(0, 3);
- points[2] = QPoint(-1, -2);
- points[3] = QPoint(-1, 2);
- points[4] = QPoint(-2, -1);
- points[5] = QPoint(-2, 1);
- points[6] = QPoint(-3, 0);
- break;
- default:
- break;
- }
- if (option->state & State_Sunken)
- painter->setPen(option->palette.light().color());
- else
- painter->setPen(option->palette.buttonText().color());
- if (option->state & State_Enabled) {
- painter->translate(option->rect.x() + option->rect.width() / 2,
- option->rect.y() + option->rect.height() / 2 - 1);
- painter->drawLine(points[0], points[1]);
- painter->drawLine(points[2], points[3]);
- painter->drawLine(points[4], points[5]);
- painter->drawPoint(points[6]);
- } else {
- painter->translate(option->rect.x() + option->rect.width() / 2,
- option->rect.y() + option->rect.height() / 2 - 1);
- painter->setPen(option->palette.mid().color());
- painter->drawLine(points[0], points[1]);
- painter->drawLine(points[2], points[3]);
- painter->drawLine(points[4], points[5]);
- painter->drawPoint(points[6]);
- }
- }
- painter->restore();
- break; }
-#ifndef QT_NO_TABWIDGET
- case PE_FrameTabWidget:
- if (const QStyleOptionTabWidgetFrame *tab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) {
- QRect rect = option->rect;
- QPalette pal = option->palette;
- painter->save();
- QBrush fill = pal.light();
- painter->fillRect(rect, fill);
- painter->setPen(pal.shadow().color());
- if (d->doubleControls) {
- QPen pen = painter->pen();
- pen.setWidth(2);
- pen.setCapStyle(Qt::FlatCap);
- painter->setPen(pen);
- }
- switch (tab->shape) {
- case QTabBar::RoundedNorth:
-#ifdef Q_OS_WINCE_WM
- if (!d->wm65)
-#endif
- {
- if (d->doubleControls)
- painter->drawLine(rect.topLeft() + QPoint(0, 1), rect.topRight() + QPoint(0, 1));
- else
- painter->drawLine(rect.topLeft(), rect.topRight());
- }
- break;
- case QTabBar::RoundedSouth:
-#ifdef Q_OS_WINCE_WM
- if (!d->wm65)
-#endif
- {
- if (d->doubleControls)
- painter->drawLine(rect.bottomLeft(), rect.bottomRight());
- else
- painter->drawLine(rect.bottomLeft(), rect.bottomRight());
- }
- break;
- case QTabBar::RoundedEast:
-#ifdef Q_OS_WINCE_WM
- if (!d->wm65)
-#endif
- painter->drawLine(rect.topRight(), rect.bottomRight());
- break;
- case QTabBar::RoundedWest:
-#ifdef Q_OS_WINCE_WM
- if (!d->wm65)
-#endif
- painter->drawLine(rect.topLeft(), rect.bottomLeft());
- break;
- case QTabBar::TriangularWest:
- case QTabBar::TriangularEast:
- case QTabBar::TriangularSouth:
- case QTabBar::TriangularNorth:
- if (d->doubleControls)
- qDrawPlainRect(painter, rect.adjusted(0,-2,0,0), option->palette.shadow().color(),2,&pal.light());
- else
- qDrawPlainRect(painter, rect, option->palette.shadow().color(),1,&pal.light());
- break;
- default:
- break;
- }
- painter->restore();
- }
- break;
-#endif //QT_NO_TABBAR
-#ifndef QT_NO_ITEMVIEWS
- case PE_PanelItemViewRow:
- if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(option)) {
- QPalette::ColorGroup cg = vopt->state & QStyle::State_Enabled
- ? QPalette::Normal : QPalette::Disabled;
- if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
- cg = QPalette::Inactive;
-
- if ((vopt->state & QStyle::State_Selected) && proxy()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, option, widget))
- d->drawPanelItemViewSelected(painter, vopt);
- else if (vopt->features & QStyleOptionViewItem::Alternate)
- painter->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::AlternateBase));
- else if (!(vopt->state & QStyle::State_Enabled))
- painter->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::Base));
- }
- break;
- case PE_PanelItemViewItem:
- if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(option)) {
- QPalette::ColorGroup cg = vopt->state & QStyle::State_Enabled
- ? QPalette::Normal : QPalette::Disabled;
- if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
- cg = QPalette::Inactive;
-
- if (vopt->showDecorationSelected && (vopt->state & QStyle::State_Selected)) {
- d->drawPanelItemViewSelected(painter, vopt);
- } else {
- if (vopt->backgroundBrush.style() != Qt::NoBrush) {
- QPointF oldBO = painter->brushOrigin();
- painter->setBrushOrigin(vopt->rect.topLeft());
- painter->fillRect(vopt->rect, vopt->backgroundBrush);
- painter->setBrushOrigin(oldBO);
- }
-
- if (vopt->state & QStyle::State_Selected) {
- QRect textRect = proxy()->subElementRect(QStyle::SE_ItemViewItemText, option, widget);
- d->drawPanelItemViewSelected(painter, vopt, textRect);
- }
- }
- }
- break;
-#endif //QT_NO_ITEMVIEWS
-
- case PE_FrameWindow: {
- QPalette popupPal = option->palette;
- popupPal.setColor(QPalette::Light, option->palette.background().color());
- popupPal.setColor(QPalette::Midlight, option->palette.light().color());
- if (d->doubleControls)
- qDrawPlainRect(painter, option->rect, popupPal.shadow().color(),2,0);
- else
- qDrawPlainRect(painter, option->rect, popupPal.shadow().color(),1,0);
- break; }
- case PE_FrameTabBarBase: {
- break; }
- case PE_Widget:
- break;
- case PE_IndicatorMenuCheckMark: {
- int markW = option->rect.width() > 7 ? 7 : option->rect.width();
- int markH = markW;
- if (d->doubleControls)
- markW*=2;
- markH*=2;
- int posX = option->rect.x() + (option->rect.width() - markW)/2 + 1;
- int posY = option->rect.y() + (option->rect.height() - markH)/2;
-
- QVector<QLineF> a;
- a.reserve(markH);
-
- int i, xx, yy;
- xx = posX;
- yy = 3 + posY;
- for (i = 0; i < markW/2; ++i) {
- a << QLineF(xx, yy, xx, yy + 2);
- ++xx;
- ++yy;
- }
- yy -= 2;
- for (; i < markH; ++i) {
- a << QLineF(xx, yy, xx, yy + 2);
- ++xx;
- --yy;
- }
- if (!(option->state & State_Enabled) && !(option->state & State_On)) {
- int pnt;
- painter->setPen(option->palette.highlightedText().color());
- QPoint offset(1, 1);
- for (pnt = 0; pnt < a.size(); ++pnt)
- a[pnt].translate(offset.x(), offset.y());
- painter->drawLines(a);
- for (pnt = 0; pnt < a.size(); ++pnt)
- a[pnt].translate(offset.x(), offset.y());
- }
- painter->setPen(option->palette.text().color());
- painter->drawLines(a);
- break; }
- case PE_IndicatorBranch: {
- // Copied from the Windows style.
- static const int decoration_size = d->doubleControls ? 18 : 9;
- static const int ofsA = d->doubleControls ? 4 : 2;
- static const int ofsB = d->doubleControls ? 8 : 4;
- static const int ofsC = d->doubleControls ? 12 : 6;
- static const int ofsD = d->doubleControls ? 1 : 0;
- int mid_h = option->rect.x() + option->rect.width() / 2;
- int mid_v = option->rect.y() + option->rect.height() / 2;
- int bef_h = mid_h;
- int bef_v = mid_v;
- int aft_h = mid_h;
- int aft_v = mid_v;
- if (option->state & State_Children) {
- int delta = decoration_size / 2;
- bef_h -= delta;
- bef_v -= delta;
- aft_h += delta;
- aft_v += delta;
- QPen oldPen = painter->pen();
- QPen crossPen = oldPen;
- crossPen.setWidth(2);
- painter->setPen(crossPen);
- painter->drawLine(bef_h + ofsA + ofsD, bef_v + ofsB + ofsD, bef_h + ofsC + ofsD, bef_v + ofsB + ofsD);
- if (!(option->state & State_Open))
- painter->drawLine(bef_h + ofsB + ofsD, bef_v + ofsA + ofsD, bef_h + ofsB + ofsD, bef_v + ofsC + ofsD);
- painter->setPen(option->palette.dark().color());
- painter->drawRect(bef_h, bef_v, decoration_size - 1, decoration_size - 1);
- if (d->doubleControls)
- painter->drawRect(bef_h + 1, bef_v + 1, decoration_size - 3, decoration_size - 3);
- painter->setPen(oldPen);
- }
- QBrush brush(option->palette.dark().color(), Qt::Dense4Pattern);
- if (option->state & State_Item) {
- if (option->direction == Qt::RightToLeft)
- painter->fillRect(option->rect.left(), mid_v, bef_h - option->rect.left(), 1, brush);
- else
- painter->fillRect(aft_h, mid_v, option->rect.right() - aft_h + 1, 1, brush);
- }
- if (option->state & State_Sibling)
- painter->fillRect(mid_h, aft_v, 1, option->rect.bottom() - aft_v + 1, brush);
- if (option->state & (State_Open | State_Children | State_Item | State_Sibling))
- painter->fillRect(mid_h, option->rect.y(), 1, bef_v - option->rect.y(), brush);
- break; }
- case PE_Frame:
- qDrawPlainRect(painter, option->rect, option->palette.shadow().color(),
- d->doubleControls ? 2 : 1, &option->palette.background());
- break;
- case PE_FrameLineEdit:
- case PE_FrameMenu:
- if (d->doubleControls)
- qDrawPlainRect(painter, option->rect, option->palette.shadow().color(),2);
- else
- qDrawPlainRect(painter, option->rect, option->palette.shadow().color(),1);
- break;
- case PE_FrameStatusBar:
- if (d->doubleControls)
- qDrawPlainRect(painter, option->rect, option->palette.shadow().color(),2,0);
- else
- qDrawPlainRect(painter, option->rect, option->palette.shadow().color(),1,0);
- break;
-
- default:
- QWindowsStyle::drawPrimitive(element, option, painter, widget);
- break;
- }
-}
-
-void QWindowsMobileStyle::drawControl(ControlElement element, const QStyleOption *option,
- QPainter *painter, const QWidget *widget) const {
-
-
- QWindowsMobileStylePrivate *d = const_cast<QWindowsMobileStylePrivate*>(d_func());
-
-
- painter->setClipping(false);
- switch (element) {
- case CE_MenuBarEmptyArea:
- painter->setClipping(true);
- QWindowsStyle::drawControl(element, option, painter, widget);
- break;
- case CE_PushButtonBevel:
- if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- QRect br = button->rect;
- int dbi = proxy()->pixelMetric(PM_ButtonDefaultIndicator, button, widget);
-
- if (button->features & QStyleOptionButton::AutoDefaultButton)
- br.setCoords(br.left() + dbi, br.top() + dbi, br.right() - dbi, br.bottom() - dbi);
- QStyleOptionButton tmpBtn = *button;
- tmpBtn.rect = br;
- proxy()->drawPrimitive(PE_PanelButtonCommand, &tmpBtn, painter, widget);
- if (button->features & QStyleOptionButton::HasMenu) {
- int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, button, widget);
- QRect ir = button->rect;
- QStyleOptionButton newButton = *button;
- if (d->doubleControls)
- newButton.rect = QRect(ir.right() - mbi, ir.height() - 30, mbi, ir.height() - 4);
- else
- newButton.rect = QRect(ir.right() - mbi, ir.height() - 20, mbi, ir.height() - 4);
- proxy()->drawPrimitive(PE_IndicatorArrowDown, &newButton, painter, widget);
- }
- if (button->features & QStyleOptionButton::DefaultButton)
- proxy()->drawPrimitive(PE_FrameDefaultButton, option, painter, widget);
- }
- break;
- case CE_RadioButton:
- case CE_CheckBox:
- if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- bool isRadio = (element == CE_RadioButton);
- QStyleOptionButton subopt = *button;
- subopt.rect = proxy()->subElementRect(isRadio ? SE_RadioButtonIndicator
- : SE_CheckBoxIndicator, button, widget);
- proxy()->drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox,
- &subopt, painter, widget);
- subopt.rect = proxy()->subElementRect(isRadio ? SE_RadioButtonContents
- : SE_CheckBoxContents, button, widget);
- proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, painter, widget);
- if (button->state & State_HasFocus) {
- QStyleOptionFocusRect fropt;
- fropt.QStyleOption::operator=(*button);
- fropt.rect = proxy()->subElementRect(isRadio ? SE_RadioButtonFocusRect
- : SE_CheckBoxFocusRect, button, widget);
- proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
- }
- }
- break;
- case CE_RadioButtonLabel:
- case CE_CheckBoxLabel:
- if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- uint alignment = visualAlignment(button->direction, Qt::AlignLeft | Qt::AlignVCenter);
- if (!styleHint(SH_UnderlineShortcut, button, widget))
- alignment |= Qt::TextHideMnemonic;
- QPixmap pix;
- QRect textRect = button->rect;
- if (!button->icon.isNull()) {
- pix = button->icon.pixmap(button->iconSize, button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled);
- proxy()->drawItemPixmap(painter, button->rect, alignment, pix);
- if (button->direction == Qt::RightToLeft)
- textRect.setRight(textRect.right() - button->iconSize.width() - 4);
- else
- textRect.setLeft(textRect.left() + button->iconSize.width() + 4);
- }
- if (!button->text.isEmpty()){
- if (button->state & State_Enabled)
- proxy()->drawItemText(painter, textRect, alignment | Qt::TextShowMnemonic,
- button->palette, false, button->text, QPalette::WindowText);
- else
- proxy()->drawItemText(painter, textRect, alignment | Qt::TextShowMnemonic,
- button->palette, false, button->text, QPalette::Mid);
- }
- }
- break;
-#ifndef QT_NO_PROGRESSBAR
- case CE_ProgressBarGroove:
- if (d->doubleControls)
- qDrawPlainRect(painter, option->rect, option->palette.shadow().color(), 2, &option->palette.brush(QPalette::Window));
- else
- qDrawPlainRect(painter, option->rect, option->palette.shadow().color(), 1, &option->palette.brush(QPalette::Window));
- break;
-#endif //QT_NO_PROGRESSBAR
-#ifndef QT_NO_TABBAR
- case CE_TabBarTab:
- if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
- proxy()->drawControl(CE_TabBarTabShape, tab, painter, widget);
- proxy()->drawControl(CE_TabBarTabLabel, tab, painter, widget);
- }
- break;
- case CE_TabBarTabShape:
- if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
-
- if (tab->shape == QTabBar::RoundedNorth || tab->shape == QTabBar::RoundedEast ||
- tab->shape == QTabBar::RoundedSouth || tab->shape == QTabBar::RoundedWest) {
- d->drawTabBarTab(painter, tab);
- } else {
- QCommonStyle::drawControl(element, option, painter, widget);
- }
- break; }
-
-#endif // QT_NO_TABBAR
-
-#ifndef QT_NO_TOOLBAR
- case CE_ToolBar:
- if (const QStyleOptionToolBar *toolBar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
- QRect rect = option->rect;
- painter->save();
- painter->setPen(option->palette.dark().color());
- painter->fillRect(rect,option->palette.button());
- if (d->doubleControls) {
- QPen pen = painter->pen();
- pen.setWidth(4);
- painter->setPen(pen);
- }
- if (toolBar->toolBarArea == Qt::TopToolBarArea)
- painter->drawLine(rect.bottomLeft(), rect.bottomRight());
- else
- painter->drawLine(rect.topLeft(), rect.topRight());
- painter->restore();
- break; }
-#endif //QT_NO_TOOLBAR
- case CE_Header:
- if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
- QRegion clipRegion = painter->clipRegion();
- painter->setClipRect(option->rect);
- proxy()->drawControl(CE_HeaderSection, header, painter, widget);
- QStyleOptionHeader subopt = *header;
- subopt.rect = proxy()->subElementRect(SE_HeaderLabel, header, widget);
- if (header->state & State_Sunken)
- subopt.palette.setColor(QPalette::ButtonText, header->palette.brightText().color());
- subopt.state |= QStyle::State_On;
- if (subopt.rect.isValid())
- proxy()->drawControl(CE_HeaderLabel, &subopt, painter, widget);
- if (header->sortIndicator != QStyleOptionHeader::None) {
- subopt.rect = proxy()->subElementRect(SE_HeaderArrow, option, widget);
- proxy()->drawPrimitive(PE_IndicatorHeaderArrow, &subopt, painter, widget);
- }
- painter->setClipRegion(clipRegion);
- }
- break;
-
- case CE_HeaderSection:
- if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
- QBrush fill;
- QColor color;
- QRect rect = option->rect;
- painter->setPen(option->palette.shadow().color());
-
- int penSize = 1;
-
- if (d->doubleControls) {
- penSize = 2;
- QPen pen = painter->pen();
- pen.setWidth(2);
- pen.setCapStyle(Qt::FlatCap);
- painter->setPen(pen);
- }
-
- //fix Frame
-
- if (header->position == QStyleOptionHeader::End
- || (header->position == QStyleOptionHeader::OnlyOneSection
- && !header->text.isEmpty()))
- if (Qt::Horizontal == header->orientation )
- rect.adjust(0, 0, penSize, 0);
- else
- rect.adjust(0, 0, 0, penSize);
-
- if (option->state & State_Sunken) {
- fill = option->palette.brush(QPalette::Shadow);
- color = option->palette.light().color();
- painter->drawLine(rect.bottomLeft(), rect.bottomRight());
- painter->drawLine(rect.topRight(), rect.bottomRight());
- rect.adjust(0, 0, -penSize, -penSize);
- }
- else {
- fill = option->palette.brush(QPalette::Button);
- color = option->palette.shadow().color();
- if (Qt::Horizontal == header->orientation )
- rect.adjust(-penSize, 0, 0, 0);
- else
- rect.adjust(0, -penSize, 0, 0);
- }
- if (Qt::Horizontal == header->orientation )
- rect.adjust(0,-penSize,0,0);
- else
- rect.adjust(-penSize, 0, 0, 0);
-
- if (option->state & State_Sunken) {
- qDrawPlainRect(painter, rect, color, penSize, &fill);
- } else {
- //Corner
- rect.adjust(-penSize, 0, 0, 0);
- qDrawPlainRect(painter, rect, color, penSize, &fill);
- }
-
- //Hack to get rid of some double lines... StyleOptions need a clean flag for that
- rect = option->rect;
-#ifndef QT_NO_SCROLLAREA
- if (const QAbstractScrollArea *abstractScrollArea = qobject_cast<const QAbstractScrollArea *> (widget) ) {
- QRect rectScrollArea = abstractScrollArea->geometry();
- if (Qt::Horizontal == header->orientation )
- if ((rectScrollArea.right() - rect.right() ) > 1)
- painter->drawLine(rect.topRight(), rect.bottomRight());
- else ;
- else
- if ((rectScrollArea.bottom() - rect.bottom() ) > 1)
- painter->drawLine(rect.bottomLeft(), rect.bottomRight());
- }
-#endif // QT_NO_SCROLLAREA
- break;
- }
-#ifndef QT_NO_COMBOBOX
- case CE_ComboBoxLabel:
- // This is copied from qcommonstyle.cpp with the difference, that
- // the editRect isn't adjusted when calling drawItemText.
- if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
- QRect editRect = proxy()->subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget);
- painter->save();
- painter->setClipRect(editRect);
- if (!cb->currentIcon.isNull()) {
- QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal
- : QIcon::Disabled;
- QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode);
- QRect iconRect(editRect);
- iconRect.setWidth(cb->iconSize.width() + 4);
- iconRect = alignedRect(cb->direction,
- Qt::AlignLeft | Qt::AlignVCenter,
- iconRect.size(), editRect);
- if (cb->editable)
- painter->fillRect(iconRect, option->palette.brush(QPalette::Base));
- proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap);
-
- if (cb->direction == Qt::RightToLeft)
- editRect.translate(-4 - cb->iconSize.width(), 0);
- else
- editRect.translate(cb->iconSize.width() + 4, 0);
- }
- if (!cb->currentText.isEmpty() && !cb->editable) {
- proxy()->drawItemText(painter, editRect,
- visualAlignment(cb->direction, Qt::AlignLeft | Qt::AlignVCenter),
- cb->palette, cb->state & State_Enabled, cb->currentText);
- }
- painter->restore();
- }
- break;
-#endif // QT_NO_COMBOBOX
-#ifndef QT_NO_DOCKWIDGET
- case CE_DockWidgetTitle:
- if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) {
-
- const bool verticalTitleBar = dwOpt->verticalTitleBar;
-
- QRect rect = dwOpt->rect;
- QRect r = rect;
-
- if (verticalTitleBar) {
- r = r.transposed();
-
- painter->save();
- painter->translate(r.left(), r.top() + r.width());
- painter->rotate(-90);
- painter->translate(-r.left(), -r.top());
- }
-
- bool floating = false;
- bool active = dwOpt->state & State_Active;
- int menuOffset = 0; //used to center text when floated
- QColor inactiveCaptionTextColor = option->palette.highlightedText().color();
- if (dwOpt->movable) {
- QColor left, right;
-
- //Titlebar gradient
- if (widget && widget->isWindow()) {
- floating = true;
- if (active) {
- right = option->palette.highlight().color();
- left = right.lighter(125);
- } else {
- left = option->palette.highlight().color().lighter(125);
- right = QColor(0xff, 0xff, 0xff);
- }
- menuOffset = 2;
- QBrush fillBrush(left);
- if (left != right) {
- QPoint p1(r.x(), r.top() + r.height()/2);
- QPoint p2(rect.right(), r.top() + r.height()/2);
- QLinearGradient lg(p1, p2);
- lg.setColorAt(0, left);
- lg.setColorAt(1, right);
- fillBrush = lg;
- }
- painter->fillRect(r.adjusted(0, 0, 0, -3), fillBrush);
- } else {
- painter->fillRect(r.adjusted(0, 0, 0, -3), option->palette.button().color());
- }
- painter->setPen(dwOpt->palette.color(QPalette::Light));
- if (!widget || !widget->isWindow()) {
- painter->drawLine(r.topLeft(), r.topRight());
- painter->setPen(dwOpt->palette.color(QPalette::Dark));
- painter->drawLine(r.bottomLeft(), r.bottomRight()); }
- }
- if (!dwOpt->title.isEmpty()) {
- QFont oldFont = painter->font();
- QFont newFont = oldFont;
- if (newFont.pointSize() > 2)
- newFont.setPointSize(newFont.pointSize() - 2);
- if (floating)
- newFont.setBold(true);
- painter->setFont(newFont);
- QPalette palette = dwOpt->palette;
- palette.setColor(QPalette::Window, inactiveCaptionTextColor);
- QRect titleRect = proxy()->subElementRect(SE_DockWidgetTitleBarText, option, widget);
- if (verticalTitleBar) {
- titleRect = QRect(r.left() + rect.bottom()
- - titleRect.bottom(),
- r.top() + titleRect.left() - rect.left(),
- titleRect.height(), titleRect.width());
- }
- proxy()->drawItemText(painter, titleRect,
- Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, palette,
- dwOpt->state & State_Enabled, dwOpt->title,
- floating ? (active ? QPalette::BrightText : QPalette::Window) : QPalette::WindowText);
- painter->setFont(oldFont);
- }
- if (verticalTitleBar)
- painter->restore();
- }
- return;
-#endif // QT_NO_DOCKWIDGET
-
- case CE_PushButtonLabel:
- if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- painter->save();
- QRect ir = button->rect;
- QPalette::ColorRole colorRole;
- uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic;
- if (!styleHint(SH_UnderlineShortcut, button, widget))
- tf |= Qt::TextHideMnemonic;
-
- if (button->state & (State_On | State_Sunken))
- colorRole = QPalette::Light;
- else
- colorRole = QPalette::ButtonText;
-
- if (!button->icon.isNull()) {
- QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal
- : QIcon::Disabled;
- if (mode == QIcon::Normal && button->state & State_HasFocus)
- mode = QIcon::Active;
- QIcon::State state = QIcon::Off;
- if (button->state & State_On)
- state = QIcon::On;
- QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state);
- int pixw = pixmap.width();
- int pixh = pixmap.height();
- //Center the icon if there is no text
-
- QPoint point;
- if (button->text.isEmpty()) {
- point = QPoint(ir.x() + ir.width() / 2 - pixw / 2,
- ir.y() + ir.height() / 2 - pixh / 2);
- } else {
- point = QPoint(ir.x() + 2, ir.y() + ir.height() / 2 - pixh / 2);
- }
- if (button->direction == Qt::RightToLeft)
- point.rx() += pixw;
-
- if ((button->state & (State_On | State_Sunken)) && button->direction == Qt::RightToLeft)
- point.rx() -= proxy()->pixelMetric(PM_ButtonShiftHorizontal, option, widget) * 2;
-
- painter->drawPixmap(visualPos(button->direction, button->rect, point), pixmap);
-
- if (button->direction == Qt::RightToLeft)
- ir.translate(-4, 0);
- else
- ir.translate(pixw + 4, 0);
- ir.setWidth(ir.width() - (pixw + 4));
- // left-align text if there is
- if (!button->text.isEmpty())
- tf |= Qt::AlignLeft;
- } else {
- tf |= Qt::AlignHCenter;
- }
- if (button->state & State_Enabled)
- proxy()->drawItemText(painter, ir, tf, button->palette, true, button->text, colorRole);
- else
- proxy()->drawItemText(painter, ir, tf, button->palette, true, button->text, QPalette::Mid);
- painter->restore();
- }
- break;
- default:
- QWindowsStyle::drawControl(element, option, painter, widget);
- break;
- }
-}
-
-void QWindowsMobileStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
- QPainter *painter, const QWidget *widget) const {
-
- painter->setClipping(false);
- QWindowsMobileStylePrivate *d = const_cast<QWindowsMobileStylePrivate*>(d_func());
-
- switch (control) {
-#ifndef QT_NO_SLIDER
- case CC_Slider:
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
- int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget);
- int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
- int ticks = slider->tickPosition;
- QRect groove = proxy()->subControlRect(CC_Slider, slider, SC_SliderGroove, widget);
- QRect handle = proxy()->subControlRect(CC_Slider, slider, SC_SliderHandle, widget);
-
- if ((slider->subControls & SC_SliderGroove) && groove.isValid()) {
- int mid = thickness / 2;
- if (ticks & QSlider::TicksAbove)
- mid += len / 8;
- if (ticks & QSlider::TicksBelow)
- mid -= len / 8;
-
- painter->setPen(slider->palette.shadow().color());
- if (slider->orientation == Qt::Horizontal) {
- qDrawPlainRect(painter, groove.x(), groove.y() + mid - 2,
- groove.width(), 4, option->palette.shadow().color(),1,0);
- } else {
- qDrawPlainRect(painter, groove.x()+mid-2, groove.y(),
- 4, groove.height(), option->palette.shadow().color(),1,0);
- }
- }
- if (slider->subControls & SC_SliderTickmarks) {
- QStyleOptionSlider tmpSlider = *slider;
- tmpSlider.subControls = SC_SliderTickmarks;
- QCommonStyle::drawComplexControl(control, &tmpSlider, painter, widget);
- }
-
- if (slider->subControls & SC_SliderHandle) {
- const QColor c0 = slider->palette.shadow().color();
- const QColor c1 = slider->palette.dark().color();
- const QColor c3 = slider->palette.midlight().color();
- const QColor c4 = slider->palette.dark().color();
- QBrush handleBrush;
-
- if (slider->state & State_Enabled) {
- handleBrush = slider->palette.color(QPalette::Light);
- } else {
- handleBrush = QBrush(slider->palette.color(QPalette::Shadow),
- Qt::Dense4Pattern);
- }
- int x = handle.x(), y = handle.y(),
- wi = handle.width(), he = handle.height();
- int x1 = x;
- int x2 = x+wi-1;
- int y1 = y;
- int y2 = y+he-1;
-
- Qt::Orientation orient = slider->orientation;
- bool tickAbove = slider->tickPosition == QSlider::TicksAbove;
- bool tickBelow = slider->tickPosition == QSlider::TicksBelow;
-
- if (slider->state & State_HasFocus) {
- QStyleOptionFocusRect fropt;
- fropt.QStyleOption::operator=(*slider);
- fropt.rect = proxy()->subElementRect(SE_SliderFocusRect, slider, widget);
- proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
- }
- if ((tickAbove && tickBelow) || (!tickAbove && !tickBelow)) {
- Qt::BGMode oldMode = painter->backgroundMode();
- painter->setBackgroundMode(Qt::OpaqueMode);
- qDrawPlainRect(painter, QRect(x, y, wi, he)
- ,slider->palette.shadow().color(),1,&handleBrush);
- painter->setBackgroundMode(oldMode);
- QBrush fill = QBrush(option->palette.light().color(), Qt::Dense4Pattern);
- if (slider->state & State_Sunken)
- painter->fillRect(QRectF(x1 + 2, y1 + 2, x2 - x1 - 3, y2 - y1 - 3),fill);
- return;
- }
- QSliderDirection dir;
- if (orient == Qt::Horizontal)
- if (tickAbove)
- dir = SliderUp;
- else
- dir = SliderDown;
- else
- if (tickAbove)
- dir = SliderLeft;
- else
- dir = SliderRight;
- QPolygon polygon;
- int d = 0;
- switch (dir) {
- case SliderUp:
- x2++;
- y1 = y1 + wi / 2;
- d = (wi + 1) / 2 - 1;
- polygon.setPoints(5, x1, y1, x1, y2, x2, y2, x2, y1, x1 + d,y1 - d);
- break;
- case SliderDown:
- x2++;
- y2 = y2 - wi/2;
- d = (wi + 1) / 2 - 1;
- polygon.setPoints(5, x1, y1, x1, y2, x1 + d,y2 + d, x2, y2, x2, y1);
- break;
- case SliderLeft:
- d = (he + 1) / 2 - 1;
- x1 = x1 + he/2;
- polygon.setPoints(5, x1, y1, x1 - d, y1 + d, x1,y2, x2, y2, x2, y1);
- y1--;
- break;
- case SliderRight:
- d = (he + 1) / 2 - 1;
- x2 = x2 - he/2;
- polygon.setPoints(5, x1, y1, x1, y2, x2,y2, x2 + d, y1 + d, x2, y1);
- y1--;
- break;
- }
- QBrush oldBrush = painter->brush();
- painter->setPen(Qt::NoPen);
- painter->setBrush(handleBrush);
- Qt::BGMode oldMode = painter->backgroundMode();
- painter->setBackgroundMode(Qt::OpaqueMode);
- painter->drawRect(x1, y1, x2-x1+1, y2-y1+1);
- painter->drawPolygon(polygon);
- QBrush fill = QBrush(option->palette.button().color(), Qt::Dense4Pattern);
- painter->setBrush(oldBrush);
- painter->setBackgroundMode(oldMode);
- if (slider->state & State_Sunken)
- painter->fillRect(QRectF(x1, y1, x2 - x1 + 1, y2 - y1 + 1),fill);
-
- if (dir != SliderUp) {
- painter->setPen(c0);
- painter->drawLine(x1, y1, x2, y1);
- }
- if (dir != SliderLeft) {
- painter->setPen(c0);
- painter->drawLine(x1, y1, x1, y2);
- }
- if (dir != SliderRight) {
- painter->setPen(c0);
- painter->drawLine(x2, y1, x2, y2);
- }
- if (dir != SliderDown) {
- painter->setPen(c0);
- painter->drawLine(x1, y2, x2, y2);
- }
- switch (dir) {
- case SliderUp:
- if (slider->state & State_Sunken)
- painter->fillRect(QRectF(x1 + 3, y1 - d + 2, x2 - x1 - 4, y1),fill);
- painter->setPen(c0);
- painter->drawLine(x1, y1, x1 + d, y1 - d);
- d = wi - d - 1;
- painter->drawLine(x2, y1, x2 -d , y1 -d );
- d--;
- break;
- case SliderDown:
- if (slider->state & State_Sunken)
- painter->fillRect(QRectF(x1+3, y2 - d, x2 - x1 -4,y2 - 8),fill);
- painter->setPen(c0);
- painter->drawLine(x1, y2, x1 + d, y2 + d);
- d = wi - d - 1;
- painter->drawLine(x2, y2, x2 - d, y2 + d);
- d--;
- break;
- case SliderLeft:
- if (slider->state & State_Sunken)
- painter->fillRect(QRectF(x1 - d + 2, y1 + 2, x1, y2 - y1 - 3),fill);
- painter->setPen(c0);
- painter->drawLine(x1, y1, x1 - d, y1 + d);
- d = he - d - 1;
- painter->drawLine(x1, y2, x1 - d, y2 - d);
- d--;
- break;
- case SliderRight:
- if (slider->state & State_Sunken)
- painter->fillRect(QRectF(x2 - d - 4, y1 + 2, x2 - 4, y2 - y1 - 3),fill);
- painter->setPen(c0);
- painter->drawLine(x2, y1, x2 + d, y1 + d);
- painter->setPen(c0);
- d = he - d - 1;
- painter->drawLine(x2, y2, x2 + d, y2 - d);
- d--;
- break;
- }
- }
- }
- break;
-#endif //QT_NO_SLIDER
-#ifndef QT_NO_SCROLLBAR
- case CC_ScrollBar:
- painter->save();
- painter->setPen(option->palette.shadow().color());
- if (d->doubleControls) {
- QPen pen = painter->pen();
- pen.setWidth(2);
- pen.setCapStyle(Qt::SquareCap);
- painter->setPen(pen);
- }
- if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
- d->drawScrollbarGroove(painter, scrollbar);
- // Make a copy here and reset it for each primitive.
- QStyleOptionSlider newScrollbar = *scrollbar;
- State saveFlags = scrollbar->state;
- //Check if the scrollbar is part of an abstractItemView and draw the frame according
- bool drawCompleteFrame = true;
- bool secondScrollBar = false;
- if (widget)
- if (QWidget *parent = widget->parentWidget()) {
- if (QAbstractScrollArea *abstractScrollArea = qobject_cast<QAbstractScrollArea *>(parent->parentWidget())) {
- drawCompleteFrame = (abstractScrollArea->frameStyle() == QFrame::NoFrame) || (abstractScrollArea->frameStyle() == QFrame::StyledPanel);
- secondScrollBar = (abstractScrollArea->horizontalScrollBar()->isVisible()
- && abstractScrollArea->verticalScrollBar()->isVisible()) ;
- }
-#ifndef QT_NO_LISTVIEW
- if (QListView *listView = qobject_cast<QListView *>(parent->parentWidget()))
- drawCompleteFrame = false;
-#endif
- }
- if (scrollbar->minimum == scrollbar->maximum)
- saveFlags |= State_Enabled;
- if (scrollbar->subControls & SC_ScrollBarSubLine) {
- newScrollbar.state = saveFlags;
- newScrollbar.rect = proxy()->subControlRect(control, &newScrollbar, SC_ScrollBarSubLine, widget);
- if (newScrollbar.rect.isValid()) {
- if (!(scrollbar->activeSubControls & SC_ScrollBarSubLine))
- newScrollbar.state &= ~(State_Sunken | State_MouseOver);
- d->drawScrollbarHandleUp(painter, &newScrollbar, drawCompleteFrame, secondScrollBar);
- }
- }
- if (scrollbar->subControls & SC_ScrollBarAddLine) {
- newScrollbar.rect = scrollbar->rect;
- newScrollbar.state = saveFlags;
- newScrollbar.rect = proxy()->subControlRect(control, &newScrollbar, SC_ScrollBarAddLine, widget);
- if (newScrollbar.rect.isValid()) {
- if (!(scrollbar->activeSubControls & SC_ScrollBarAddLine))
- newScrollbar.state &= ~(State_Sunken | State_MouseOver);
- d->drawScrollbarHandleDown(painter, &newScrollbar, drawCompleteFrame, secondScrollBar);
- }
- }
- if (scrollbar->subControls & SC_ScrollBarSlider) {
-
- newScrollbar.rect = scrollbar->rect;
- newScrollbar.state = saveFlags;
- newScrollbar.rect = proxy()->subControlRect(control, &newScrollbar, SC_ScrollBarSlider, widget);
-
- if (newScrollbar.rect.isValid()) {
- if (!(scrollbar->activeSubControls & SC_ScrollBarSlider))
- newScrollbar.state &= ~(State_Sunken | State_MouseOver);
- d->drawScrollbarGrip(painter, &newScrollbar, option, drawCompleteFrame);
- }
- }
- }
- painter->restore();
- break;
-#endif // QT_NO_SCROLLBAR
- case CC_ToolButton:
- if (const QStyleOptionToolButton *toolbutton
- = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
- QRect button, menuarea;
- bool isTabWidget = false;
-#ifndef QT_NO_TABWIDGET
- if (widget)
- if (QWidget *parent = widget->parentWidget())
- isTabWidget = (qobject_cast<QTabWidget *>(parent->parentWidget()));
-#endif //QT_NO_TABWIDGET
-
- button = proxy()->subControlRect(control, toolbutton, SC_ToolButton, widget);
- menuarea = proxy()->subControlRect(control, toolbutton, SC_ToolButtonMenu, widget);
- State buttonFlags = toolbutton->state;
- if (buttonFlags & State_AutoRaise) {
- if (!(buttonFlags & State_MouseOver)) {
- buttonFlags &= ~State_Raised;
- }
- }
- State menuFlags = buttonFlags;
- if (toolbutton->activeSubControls & SC_ToolButton)
- buttonFlags |= State_Sunken;
- if (toolbutton->activeSubControls & SC_ToolButtonMenu)
- menuFlags |= State_On;
- QStyleOption tool = *toolbutton;
- if (toolbutton->subControls & SC_ToolButton) {
- tool.rect = button;
- tool.state = buttonFlags;
- proxy()->drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
- }
- if (toolbutton->subControls & SC_ToolButtonMenu) {
- tool.rect = menuarea;
- tool.state = buttonFlags & State_Enabled;
- QStyleOption toolMenu = *toolbutton;
- toolMenu.state = menuFlags;
- if (buttonFlags & State_Sunken)
- proxy()->drawPrimitive(PE_PanelButtonTool, &toolMenu, painter, widget);
- QStyleOption arrowOpt = toolMenu;
- State flags = State_None;
- if (menuFlags & State_Enabled)
- flags |= State_Enabled;
- if ((menuFlags & State_On) && !(buttonFlags & State_Sunken)) {
- flags |= State_Sunken;
- painter->fillRect(menuarea, option->palette.shadow());
- }
- arrowOpt.state = flags;
- proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget);
- }
- if (toolbutton->state & State_HasFocus) {
- QStyleOptionFocusRect focusRect;
- focusRect.QStyleOption::operator=(*toolbutton);
- focusRect.rect.adjust(3, 3, -3, -3);
- if (toolbutton->features & QStyleOptionToolButton::Menu)
- focusRect.rect.adjust(0, 0, -proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator,
- toolbutton, widget), 0);
- proxy()->drawPrimitive(PE_FrameFocusRect, &focusRect, painter, widget);
- }
- QStyleOptionToolButton label = *toolbutton;
- if (isTabWidget)
- label.state = toolbutton->state;
- else
- label.state = toolbutton->state & State_Enabled;
- int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget);
- label.rect = button.adjusted(fw, fw, -fw, -fw);
- proxy()->drawControl(CE_ToolButtonLabel, &label, painter, widget);
- }
- break;
-
-#ifndef QT_NO_GROUPBOX
- case CC_GroupBox:
- if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
- // Draw frame
- painter->save();
- QFont font = painter->font();
- font.setBold(true);
- painter->setFont(font);
- QStyleOptionGroupBox groupBoxFont = *groupBox;
- groupBoxFont.fontMetrics = QFontMetrics(font);
- QRect textRect = proxy()->subControlRect(CC_GroupBox, &groupBoxFont, SC_GroupBoxLabel, widget);
- QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, option, SC_GroupBoxCheckBox, widget).adjusted(0,0,0,0);
- if (groupBox->subControls & QStyle::SC_GroupBoxFrame) {
- QStyleOptionFrame frame;
- frame.QStyleOption::operator=(*groupBox);
- frame.features = groupBox->features;
- frame.lineWidth = groupBox->lineWidth;
- frame.midLineWidth = groupBox->midLineWidth;
- frame.rect = proxy()->subControlRect(CC_GroupBox, option, SC_GroupBoxFrame, widget);
- painter->save();
- QRegion region(groupBox->rect);
- if (!groupBox->text.isEmpty()) {
- bool ltr = groupBox->direction == Qt::LeftToRight;
- QRect finalRect = checkBoxRect.united(textRect);
- if (groupBox->subControls & QStyle::SC_GroupBoxCheckBox)
- finalRect.adjust(ltr ? -4 : 0, 0, ltr ? 0 : 4, 0);
- region -= finalRect;
- }
- proxy()->drawPrimitive(PE_FrameGroupBox, &frame, painter, widget);
- painter->restore();
- }
- // Draw checkbox
- if (groupBox->subControls & SC_GroupBoxCheckBox) {
- QStyleOptionButton box;
- box.QStyleOption::operator=(*groupBox);
- box.rect = checkBoxRect;
- proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget);
- }
- // Draw title
- if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {
- QColor textColor = groupBox->textColor;
- if (textColor.isValid())
- painter->setPen(textColor);
- else
- painter->setPen(groupBox->palette.link().color());
- painter->setPen(groupBox->palette.link().color());
-
- int alignment = int(groupBox->textAlignment);
- if (!styleHint(QStyle::SH_UnderlineShortcut, option, widget))
- alignment |= Qt::TextHideMnemonic;
-
- if (groupBox->state & State_Enabled)
- proxy()->drawItemText(painter, textRect, Qt::TextShowMnemonic | Qt::AlignHCenter | alignment,
- groupBox->palette, true, groupBox->text,
- textColor.isValid() ? QPalette::NoRole : QPalette::Link);
- else
- proxy()->drawItemText(painter, textRect, Qt::TextShowMnemonic | Qt::AlignHCenter | alignment,
- groupBox->palette, true, groupBox->text, QPalette::Mid);
- if (groupBox->state & State_HasFocus) {
- QStyleOptionFocusRect fropt;
- fropt.QStyleOption::operator=(*groupBox);
- fropt.rect = textRect;
- proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
- }
- }
- painter->restore();
- }
- break;
-#endif //QT_NO_GROUPBOX
-
-#ifndef QT_NO_COMBOBOX
- case CC_ComboBox:
- if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
- QBrush editBrush = cmb->palette.brush(QPalette::Base);
- if ((cmb->subControls & SC_ComboBoxFrame) && cmb->frame)
- qDrawPlainRect(painter, option->rect, option->palette.shadow().color(), proxy()->pixelMetric(PM_ComboBoxFrameWidth, option, widget), &editBrush);
- else
- painter->fillRect(option->rect, editBrush);
- State flags = State_None;
- QRect ar = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxArrow, widget);
- if ((option->state & State_On)) {
- painter->fillRect(ar.adjusted(0, 0, 1, 1),cmb->palette.brush(QPalette::Shadow));
- }
- if (d->doubleControls)
- ar.adjust(5, 0, 5, 0);
- else
- ar.adjust(2, 0, -2, 0);
- if (option->state & State_Enabled)
- flags |= State_Enabled;
- if (option->state & State_On)
- flags |= State_Sunken;
- QStyleOption arrowOpt = *cmb;
- arrowOpt.rect = ar;
- arrowOpt.state = flags;
- proxy()->drawPrimitive(PrimitiveElement(PE_IndicatorArrowDownBig), &arrowOpt, painter, widget);
- if (cmb->subControls & SC_ComboBoxEditField) {
- QRect re = proxy()->subControlRect(CC_ComboBox, cmb, SC_ComboBoxEditField, widget);
- if (cmb->state & State_HasFocus && !cmb->editable)
- painter->fillRect(re.x(), re.y(), re.width(), re.height(),
- cmb->palette.brush(QPalette::Highlight));
- if (cmb->state & State_HasFocus) {
- painter->setPen(cmb->palette.highlightedText().color());
- painter->setBackground(cmb->palette.highlight());
- } else {
- painter->setPen(cmb->palette.text().color());
- painter->setBackground(cmb->palette.background());
- }
- if (cmb->state & State_HasFocus && !cmb->editable) {
- QStyleOptionFocusRect focus;
- focus.QStyleOption::operator=(*cmb);
- focus.rect = proxy()->subElementRect(SE_ComboBoxFocusRect, cmb, widget);
- focus.state |= State_FocusAtBorder;
- focus.backgroundColor = cmb->palette.highlight().color();
- if ((option->state & State_On))
- proxy()->drawPrimitive(PE_FrameFocusRect, &focus, painter, widget);
- }
- }
- }
- break;
-#endif // QT_NO_COMBOBOX
-
-
-#ifndef QT_NO_SPINBOX
- case CC_SpinBox:
- if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
- QStyleOptionSpinBox copy = *spinBox;
- //PrimitiveElement primitiveElement;
- int primitiveElement;
-
- if (spinBox->frame && (spinBox->subControls & SC_SpinBoxFrame)) {
- QRect r = proxy()->subControlRect(CC_SpinBox, spinBox, SC_SpinBoxFrame, widget);
- qDrawPlainRect(painter, r, option->palette.shadow().color(), proxy()->pixelMetric(PM_SpinBoxFrameWidth, option, widget),0);
- }
- QPalette shadePal(option->palette);
- shadePal.setColor(QPalette::Button, option->palette.light().color());
- shadePal.setColor(QPalette::Light, option->palette.base().color());
- if (spinBox->subControls & SC_SpinBoxUp) {
- copy.subControls = SC_SpinBoxUp;
- QPalette pal2 = spinBox->palette;
- if (!(spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
- pal2.setCurrentColorGroup(QPalette::Disabled);
- copy.state &= ~State_Enabled;
- }
- copy.palette = pal2;
- if (spinBox->activeSubControls == SC_SpinBoxUp && (spinBox->state & State_Sunken)) {
- copy.state |= State_On;
- copy.state |= State_Sunken;
- } else {
- copy.state |= State_Raised;
- copy.state &= ~State_Sunken;
- }
- primitiveElement = (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorArrowUpBig
- : PE_IndicatorArrowUpBig);
- copy.rect = proxy()->subControlRect(CC_SpinBox, spinBox, SC_SpinBoxUp, widget);
- if (copy.state & (State_Sunken | State_On))
- qDrawPlainRect(painter, copy.rect, option->palette.shadow().color(), proxy()->pixelMetric(PM_SpinBoxFrameWidth, option, widget), &copy.palette.brush(QPalette::Shadow));
- else
- qDrawPlainRect(painter, copy.rect, option->palette.shadow().color(), proxy()->pixelMetric(PM_SpinBoxFrameWidth, option, widget), &copy.palette.brush(QPalette::Base));
- copy.rect.adjust(proxy()->pixelMetric(PM_SpinBoxFrameWidth, option, widget), 0, -pixelMetric(PM_SpinBoxFrameWidth, option, widget), 0);
- proxy()->drawPrimitive(PrimitiveElement(primitiveElement), &copy, painter, widget);
- }
- if (spinBox->subControls & SC_SpinBoxDown) {
- copy.subControls = SC_SpinBoxDown;
- copy.state = spinBox->state;
- QPalette pal2 = spinBox->palette;
- if (!(spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
- pal2.setCurrentColorGroup(QPalette::Disabled);
- copy.state &= ~State_Enabled;
- }
- copy.palette = pal2;
- if (spinBox->activeSubControls == SC_SpinBoxDown && (spinBox->state & State_Sunken)) {
- copy.state |= State_On;
- copy.state |= State_Sunken;
- } else {
- copy.state |= State_Raised;
- copy.state &= ~State_Sunken;
- }
- primitiveElement = (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorArrowDownBig
- : PE_IndicatorArrowDownBig);
- copy.rect = proxy()->subControlRect(CC_SpinBox, spinBox, SC_SpinBoxDown, widget);
- qDrawPlainRect(painter, copy.rect, option->palette.shadow().color(), proxy()->pixelMetric(PM_SpinBoxFrameWidth, option, widget), &copy.palette.brush(QPalette::Base));
- if (copy.state & (State_Sunken | State_On))
- qDrawPlainRect(painter, copy.rect, option->palette.shadow().color(), proxy()->pixelMetric(PM_SpinBoxFrameWidth, option, widget), &copy.palette.brush(QPalette::Shadow));
- else
- qDrawPlainRect(painter, copy.rect, option->palette.shadow().color(), proxy()->pixelMetric(PM_SpinBoxFrameWidth, option, widget), &copy.palette.brush(QPalette::Base));
- copy.rect.adjust(3, 0, -4, 0);
- if (primitiveElement == PE_IndicatorArrowUp || primitiveElement == PE_IndicatorArrowDown) {
- int frameWidth = proxy()->pixelMetric(PM_SpinBoxFrameWidth, option, widget);
- copy.rect = copy.rect.adjusted(frameWidth, frameWidth, -frameWidth, -frameWidth);
- proxy()->drawPrimitive(PrimitiveElement(primitiveElement), &copy, painter, widget);
- }
- else {
- proxy()->drawPrimitive(PrimitiveElement(primitiveElement), &copy, painter, widget);
- }
- if (spinBox->frame && (spinBox->subControls & SC_SpinBoxFrame)) {
- QRect r = proxy()->subControlRect(CC_SpinBox, spinBox, SC_SpinBoxEditField, widget);
- }
- }
- }
- break;
-#endif // QT_NO_SPINBOX
-
- default:
- QWindowsStyle::drawComplexControl(control, option, painter, widget);
- break;
- }
-}
-
-QSize QWindowsMobileStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
- const QSize &size, const QWidget *widget) const {
-
- QSize newSize = QWindowsStyle::sizeFromContents(type, option, size, widget);
- switch (type) {
- case CT_PushButton:
- if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- newSize = QCommonStyle::sizeFromContents(type, option, size, widget);
- int w = newSize.width(),
- h = newSize.height();
- int defwidth = 0;
- if (button->features & QStyleOptionButton::AutoDefaultButton)
- defwidth = 2 * proxy()->pixelMetric(PM_ButtonDefaultIndicator, button, widget);
-
- int minwidth = int(QStyleHelper::dpiScaled(55.0f));
- int minheight = int(QStyleHelper::dpiScaled(19.0f));
-
- if (w < minwidth + defwidth && button->icon.isNull())
- w = minwidth + defwidth;
- if (h < minheight + defwidth)
- h = minheight + defwidth;
- newSize = QSize(w + 4, h + 4);
- }
- break;
-
-#ifndef QT_NO_GROUPBOX
- case CT_GroupBox:
- if (const QGroupBox *grb = static_cast<const QGroupBox *>(widget)) {
- newSize = size + QSize(!grb->isFlat() ? 16 : 0, !grb->isFlat() ? 16 : 0);
- }
- break;
-#endif // QT_NO_GROUPBOX
-
- case CT_RadioButton:
- case CT_CheckBox:
- newSize = size;
- if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- bool isRadio = (type == CT_RadioButton);
- QRect irect = visualRect(button->direction, button->rect,
- proxy()->subElementRect(isRadio ? SE_RadioButtonIndicator
- : SE_CheckBoxIndicator, button, widget));
- int h = proxy()->pixelMetric(isRadio ? PM_ExclusiveIndicatorHeight
- : PM_IndicatorHeight, button, widget);
- int margins = (!button->icon.isNull() && button->text.isEmpty()) ? 0 : 10;
- if (d_func()->doubleControls)
- margins *= 2;
- newSize += QSize(irect.right() + margins, 1);
- newSize.setHeight(qMax(newSize.height(), h));
- }
- break;
-#ifndef QT_NO_COMBOBOX
- case CT_ComboBox:
- if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
- int fw = comboBox->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, option, widget) * 2 : 0;
- newSize = QSize(newSize.width() + fw + 9, newSize.height() + fw); //Nine is a magic Number - See CommonStyle for real magic (23)
- }
- break;
-#endif
-#ifndef QT_NO_SPINBOX
- case CT_SpinBox:
- if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
- int fw = spinBox->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, option, widget) * 2 : 0;
- newSize = QSize(newSize.width() + fw-5, newSize.height() + fw-6);
- }
- break;
-#endif
-#ifndef QT_NO_LINEEDIT
- case CT_LineEdit:
- newSize += QSize(0,1);
- break;
-#endif
- case CT_ToolButton:
- newSize = QSize(newSize.width() + 1, newSize.height());
- break;
- case CT_TabBarTab:
- if (d_func()->doubleControls)
- newSize = QSize(newSize.width(), 42);
- else
- newSize = QSize(newSize.width(), 21);
- break;
- case CT_HeaderSection:
- newSize += QSize(4, 2);
- break;
-#ifndef QT_NO_ITEMVIEWS
-#ifdef Q_OS_WINCE_WM
- case CT_ItemViewItem:
- if (d_func()->wm65)
- if (d_func()->doubleControls)
- newSize.setHeight(46);
- else
- newSize.setHeight(23);
- break;
-#endif //Q_OS_WINCE_WM
-#endif //QT_NO_ITEMVIEWS
- default:
- break;
- }
- return newSize;
-}
-
-QRect QWindowsMobileStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const {
-
- QWindowsMobileStylePrivate *d = const_cast<QWindowsMobileStylePrivate*>(d_func());
- QRect rect = QWindowsStyle::subElementRect(element, option, widget);
- switch (element) {
-#ifndef QT_NO_TABWIDGET
- case SE_TabWidgetTabBar:
- if (d->doubleControls)
- rect.adjust(-2, 0, 2, 0);
- else
- rect.adjust(-2, 0, 2, 0);
- break;
-#endif //QT_NO_TABWIDGET
- case SE_CheckBoxFocusRect:
- rect.adjust(1,0,-2,-1);
- break;
- case SE_RadioButtonFocusRect:
- rect.adjust(1,1,-2,-2);
- break;
- default:
- break;
-#ifndef QT_NO_SLIDER
- case SE_SliderFocusRect:
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
- rect = slider->rect;
- }
- break;
- case SE_PushButtonFocusRect:
- if (d->doubleControls)
- rect.adjust(-1, -1, 0, 0);
- break;
-#endif // QT_NO_SLIDER
-#ifndef QT_NO_ITEMVIEWS
- case SE_ItemViewItemFocusRect:
-#ifdef Q_OS_WINCE_WM
- if (d->wm65)
- rect = QRect();
-#endif
- break;
-#endif //QT_NO_ITEMVIEWS
- }
- return rect;
-}
-
-QRect QWindowsMobileStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option,
- SubControl subControl, const QWidget *widget) const {
-
- QWindowsMobileStylePrivate *d = const_cast<QWindowsMobileStylePrivate*>(d_func());
-
- QRect rect = QCommonStyle::subControlRect(control, option, subControl, widget);
- switch (control) {
-
-#ifndef QT_NO_SCROLLBAR
- case CC_ScrollBar:
- if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
- int sliderButtonExtent = proxy()->pixelMetric(PM_ScrollBarExtent, scrollbar, widget);
- float stretchFactor = 1.4f;
- int sliderButtonExtentDir = int (sliderButtonExtent * stretchFactor);
-
-#ifdef Q_OS_WINCE_WM
- if (d->wm65)
- {
- sliderButtonExtent = d->imageScrollbarHandleUp.width();
- sliderButtonExtentDir = d->imageScrollbarHandleUp.height();
- }
-#endif //Q_OS_WINCE_WM
-
- int sliderlen;
- int maxlen = ((scrollbar->orientation == Qt::Horizontal) ?
- scrollbar->rect.width() : scrollbar->rect.height()) - (sliderButtonExtentDir * 2);
- // calculate slider length
- if (scrollbar->maximum != scrollbar->minimum) {
- uint range = scrollbar->maximum - scrollbar->minimum;
- sliderlen = (qint64(scrollbar->pageStep) * maxlen) / (range + scrollbar->pageStep);
-
- int slidermin = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollbar, widget);
- if (sliderlen < slidermin || range > INT_MAX / 2)
- sliderlen = slidermin;
- if (sliderlen > maxlen)
- sliderlen = maxlen;
- } else {
- sliderlen = maxlen;
- }
- int sliderstart = sliderButtonExtentDir + sliderPositionFromValue(scrollbar->minimum,
- scrollbar->maximum,
- scrollbar->sliderPosition,
- maxlen - sliderlen,
- scrollbar->upsideDown);
- if (d->smartphone) {
- sliderstart -= sliderButtonExtentDir;
- sliderlen += 2*sliderButtonExtent;
- }
- switch (subControl) {
- case SC_ScrollBarSubLine: // top/left button
- if (scrollbar->orientation == Qt::Horizontal) {
- int buttonWidth = qMin(scrollbar->rect.width() / 2, sliderButtonExtentDir );
- rect.setRect(0, 0, buttonWidth, sliderButtonExtent);
- } else {
- int buttonHeight = qMin(scrollbar->rect.height() / 2, sliderButtonExtentDir);
- rect.setRect(0, 0, sliderButtonExtent, buttonHeight);
- }
- if (d->smartphone)
- rect.setRect(0, 0, 0, 0);
- break;
- case SC_ScrollBarAddLine: // bottom/right button
- if (scrollbar->orientation == Qt::Horizontal) {
- int buttonWidth = qMin(scrollbar->rect.width()/2, sliderButtonExtentDir);
- rect.setRect(scrollbar->rect.width() - buttonWidth, 0, buttonWidth, sliderButtonExtent);
- } else {
- int buttonHeight = qMin(scrollbar->rect.height()/2, sliderButtonExtentDir );
- rect.setRect(0, scrollbar->rect.height() - buttonHeight, sliderButtonExtent, buttonHeight);
- }
- if (d->smartphone)
- rect.setRect(0, 0, 0, 0);
- break;
- case SC_ScrollBarSubPage: // between top/left button and slider
- if (scrollbar->orientation == Qt::Horizontal)
- if (d->smartphone)
- rect.setRect(0, 0, sliderstart, sliderButtonExtent);
- else
- rect.setRect(sliderButtonExtent, 0, sliderstart - sliderButtonExtent, sliderButtonExtent);
- else
- if (d->smartphone)
- rect.setRect(0, 0, sliderButtonExtent, sliderstart);
- else
- rect.setRect(0, sliderButtonExtent, sliderButtonExtent, sliderstart - sliderButtonExtent);
- break;
- case SC_ScrollBarAddPage: // between bottom/right button and slider
- if (scrollbar->orientation == Qt::Horizontal)
- if (d->smartphone)
- rect.setRect(sliderstart + sliderlen, 0,
- maxlen - sliderstart - sliderlen + 2*sliderButtonExtent, sliderButtonExtent);
- else
- rect.setRect(sliderstart + sliderlen, 0,
- maxlen - sliderstart - sliderlen + sliderButtonExtent, sliderButtonExtent);
- else
- if (d->smartphone)
- rect.setRect(0, sliderstart + sliderlen, sliderButtonExtent,
- maxlen - sliderstart - sliderlen + 2*sliderButtonExtent);
- else
- rect.setRect(0, sliderstart + sliderlen, sliderButtonExtent,
- maxlen - sliderstart - sliderlen + sliderButtonExtent);
- break;
- case SC_ScrollBarGroove:
- if (scrollbar->orientation == Qt::Horizontal)
- rect.setRect(sliderButtonExtent, 0, scrollbar->rect.width() - sliderButtonExtent * 2,
- scrollbar->rect.height());
- else
- rect.setRect(0, sliderButtonExtent, scrollbar->rect.width(),
- scrollbar->rect.height() - sliderButtonExtent * 2);
- break;
- case SC_ScrollBarSlider:
- if (scrollbar->orientation == Qt::Horizontal)
- rect.setRect(sliderstart, 0, sliderlen, sliderButtonExtent);
- else
- rect.setRect(0, sliderstart, sliderButtonExtent, sliderlen);
- break;
- default:
- break;
- }
- rect = visualRect(scrollbar->direction, scrollbar->rect, rect);
- }
- break;
-#endif // QT_NO_SCROLLBAR
-
-
-
-#ifndef QT_NO_TOOLBUTTON
- case CC_ToolButton:
- if (const QStyleOptionToolButton *toolButton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
- int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolButton, widget);
- rect = toolButton->rect;
- switch (subControl) {
- case SC_ToolButton:
- if ((toolButton->features
- & (QStyleOptionToolButton::Menu | QStyleOptionToolButton::PopupDelay))
- == QStyleOptionToolButton::Menu)
- rect.adjust(0, 0, -mbi, 0);
- break;
- case SC_ToolButtonMenu:
- if ((toolButton->features
- & (QStyleOptionToolButton::Menu | QStyleOptionToolButton::PopupDelay))
- == QStyleOptionToolButton::Menu)
- rect.adjust(rect.width() - mbi, 1, 0, 1);
- break;
- default:
- break;
- }
- rect = visualRect(toolButton->direction, toolButton->rect, rect);
- }
- break;
-#endif // QT_NO_TOOLBUTTON
-
-#ifndef QT_NO_SLIDER
- case CC_Slider:
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
- int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget);
- int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget);
- switch (subControl) {
- case SC_SliderHandle: {
- int sliderPos = 0;
- int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
- bool horizontal = slider->orientation == Qt::Horizontal;
- sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum,
- slider->sliderPosition,
- (horizontal ? slider->rect.width()
- : slider->rect.height()) - len,
- slider->upsideDown);
- if (horizontal)
- rect.setRect(slider->rect.x() + sliderPos, slider->rect.y() + tickOffset, len, thickness);
- else
- rect.setRect(slider->rect.x() + tickOffset, slider->rect.y() + sliderPos, thickness, len);
- break; }
- default:
- break;
- }
- rect = visualRect(slider->direction, slider->rect, rect);
- }
- break;
-#endif //QT_NO_SLIDER
-#ifndef QT_NO_COMBOBOX
- case CC_ComboBox:
- if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
- int x = comboBox->rect.x(),
- y = comboBox->rect.y(),
- wi = comboBox->rect.width(),
- he = comboBox->rect.height();
- int xpos = x;
- int margin = comboBox->frame ? (d->doubleControls ? 2 : 1) : 0;
- int bmarg = comboBox->frame ? (d->doubleControls ? 2 : 1) : 0;
- if (subControl == SC_ComboBoxArrow)
- xpos += wi - int((he - 2*bmarg)*0.9) - bmarg;
- else
- xpos += wi - (he - 2*bmarg) - bmarg;
- switch (subControl) {
- case SC_ComboBoxArrow:
- rect.setRect(xpos, y + bmarg, he - 2*bmarg, he - 2*bmarg);
- break;
- case SC_ComboBoxEditField:
- rect.setRect(x + margin, y + margin, wi - 2 * margin - int((he - 2*bmarg) * 0.84f), he - 2 * margin);
- if (d->doubleControls) {
- if (comboBox->editable)
- rect.adjust(2, 0, 0, 0);
- else
- rect.adjust(4, 2, 0, -2);
- } else if (!comboBox->editable) {
- rect.adjust(2, 1, 0, -1);
- }
- break;
- case SC_ComboBoxFrame:
- rect = comboBox->rect;
- break;
- default:
- break;
- }
- }
-#endif //QT_NO_COMBOBOX
-#ifndef QT_NO_SPINBOX
- case CC_SpinBox:
- if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
- QSize bs;
- int fw = spinBox->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, spinBox, widget) : 0;
- bs.setHeight(qMax(d->doubleControls ? 28 : 14, (spinBox->rect.height())));
- // 1.6 -approximate golden mean
- bs.setWidth(qMax(d->doubleControls ? 28 : 14, qMin((bs.height()*7/8), (spinBox->rect.width() / 8))));
- bs = bs.expandedTo(QApplication::globalStrut());
- int x, lx, rx;
- x = spinBox->rect.width() - bs.width()*2;
- lx = fw;
- rx = x - fw;
- switch (subControl) {
- case SC_SpinBoxUp:
- rect = QRect(x + proxy()->pixelMetric(PM_SpinBoxFrameWidth, option, widget), 0 , bs.width(), bs.height());
- break;
- case SC_SpinBoxDown:
- rect = QRect(x + bs.width(), 0, bs.width(), bs.height());
- break;
- case SC_SpinBoxEditField:
- if (spinBox->buttonSymbols == QAbstractSpinBox::NoButtons) {
- rect = QRect(lx, fw, spinBox->rect.width() - 2*fw - 2, spinBox->rect.height() - 2*fw);
- } else {
- rect = QRect(lx, fw, rx-2, spinBox->rect.height() - 2*fw);
- }
- break;
- case SC_SpinBoxFrame:
- rect = spinBox->rect;
- default:
- break;
- }
- rect = visualRect(spinBox->direction, spinBox->rect, rect);
- }
- break;
-#endif // Qt_NO_SPINBOX
-#ifndef QT_NO_GROUPBOX
- case CC_GroupBox: {
- if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
- switch (subControl) {
- case SC_GroupBoxFrame:
- // FALL THROUGH
- case SC_GroupBoxContents: {
- int topMargin = 0;
- int topHeight = 0;
- int bottomMargin = 0;
- int labelMargin = 2;
-
- QRect frameRect = groupBox->rect;
- int verticalAlignment = styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget);
- if (groupBox->text.size()) {
- topHeight = groupBox->fontMetrics.height();
- if (verticalAlignment & Qt::AlignVCenter)
- topMargin = topHeight+5;
- else if (verticalAlignment & Qt::AlignTop)
- topMargin = -topHeight+5;
- }
- if (subControl == SC_GroupBoxFrame) {
- frameRect.setTop(topMargin);
- frameRect.setBottom(frameRect.height() + bottomMargin);
- rect = frameRect;
- break;
- }
- int frameWidth = 0;
- if (groupBox->text.size()) {
- frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth, groupBox, widget);
- rect = frameRect.adjusted(frameWidth, frameWidth + topHeight + labelMargin, -frameWidth, -frameWidth);
- }
- else {
- rect = groupBox->rect;
- }
- break;
- }
- case SC_GroupBoxCheckBox:
- // FALL THROUGH
- case SC_GroupBoxLabel: {
- QFontMetrics fontMetrics = groupBox->fontMetrics;
- int h = fontMetrics.height();
- int textWidth = fontMetrics.size(Qt::TextShowMnemonic, groupBox->text + QLatin1Char(' ')).width();
- const int margX = (groupBox->features & QStyleOptionFrame::Flat) ? 0 : 2;
- const int margY = (groupBox->features & QStyleOptionFrame::Flat) ? 0 : 2;
- rect = groupBox->rect.adjusted(margX, margY, -margX, 0);
- if (groupBox->text.size())
- rect.setHeight(h);
- else
- rect.setHeight(0);
- int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget);
- int indicatorSpace = proxy()->pixelMetric(PM_CheckBoxLabelSpacing, option, widget) - 1;
- bool hasCheckBox = groupBox->subControls & QStyle::SC_GroupBoxCheckBox;
- int checkBoxSize = hasCheckBox ? (indicatorWidth + indicatorSpace) : 0;
-
- // Adjusted rect for label + indicatorWidth + indicatorSpace
- QRect totalRect = alignedRect(groupBox->direction, groupBox->textAlignment,
- QSize(textWidth + checkBoxSize, h), rect);
-
- // Adjust totalRect if checkbox is set
- if (hasCheckBox) {
- bool ltr = groupBox->direction == Qt::LeftToRight;
- int left = 2;
- // Adjust for check box
- if (subControl == SC_GroupBoxCheckBox) {
- int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, option, widget);
- left = ltr ? totalRect.left() : (totalRect.right() - indicatorWidth);
- int top = totalRect.top() + (fontMetrics.height() - indicatorHeight) / 2;
- totalRect.setRect(left, top, indicatorWidth, indicatorHeight);
- // Adjust for label
- } else {
- left = ltr ? (totalRect.left() + checkBoxSize - 2) : totalRect.left();
- totalRect.setRect(left, totalRect.top(),
- totalRect.width() - checkBoxSize, totalRect.height());
- }
- }
- if ((subControl== SC_GroupBoxLabel))
- totalRect.adjust(-2,0,6,0);
- rect = totalRect;
- break;
- }
- default:
- break;
- }
- }
- break;
- }
-#endif // QT_NO_GROUPBOX
- default:
- break;
- }
- return rect;
-}
-
-QPalette QWindowsMobileStyle::standardPalette() const {
- QPalette palette (Qt::black,QColor(198, 195, 198), QColor(222, 223, 222 ),
- QColor(132, 130, 132), QColor(198, 195, 198), Qt::black, Qt::white, Qt::white, QColor(198, 195, 198));
- palette.setColor(QPalette::Window, QColor(206, 223, 239));
- palette.setColor(QPalette::Link, QColor(8,77,123)); //Alternate TextColor for labels...
- palette.setColor(QPalette::Base, Qt::white);
- palette.setColor(QPalette::Button, QColor(206, 223, 239));
- palette.setColor(QPalette::Highlight, QColor(49, 146, 214));
- palette.setColor(QPalette::Light, Qt::white);
- palette.setColor(QPalette::Text, Qt::black);
- palette.setColor(QPalette::ButtonText, Qt::black);
- palette.setColor(QPalette::Midlight, QColor(222, 223, 222 ));
- palette.setColor(QPalette::Dark, QColor(132, 130, 132));
- palette.setColor(QPalette::Mid, QColor(189, 190, 189));
- palette.setColor(QPalette::Shadow, QColor(0, 0, 0));
- palette.setColor(QPalette::BrightText, QColor(33, 162, 33)); //color for ItemView checked indicator (arrow)
- return palette;
-}
-
-
-/*! \reimp */
-void QWindowsMobileStyle::polish(QApplication *application) {
- QWindowsStyle::polish(application);
-}
-
-/*! \reimp */
-void QWindowsMobileStyle::polish(QWidget *widget) {
-
-#ifndef QT_NO_TOOLBAR
- if (QToolBar *toolBar = qobject_cast<QToolBar*>(widget)) {
- QPalette pal = toolBar->palette();
- pal.setColor(QPalette::Background, pal.button().color());
- toolBar->setPalette(pal);
- }
- else
-#endif //QT_NO_TOOLBAR
-
- QWindowsStyle::polish(widget);
-}
-
-void QWindowsMobileStyle::unpolish(QWidget *widget)
-{
- QWindowsStyle::unpolish(widget);
-}
-
-void QWindowsMobileStyle::unpolish(QApplication *app)
-{
- QWindowsStyle::unpolish(app);
-}
-
-/*! \reimp */
-void QWindowsMobileStyle::polish(QPalette &palette) {
- QWindowsStyle::polish(palette);
-}
-
-int QWindowsMobileStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QWidget *widget) const {
-
- QWindowsMobileStylePrivate *d = const_cast<QWindowsMobileStylePrivate*>(d_func());
- int ret;
-
- switch (pm) {
- case PM_DefaultTopLevelMargin:
- ret =0;
- break;
- case PM_DefaultLayoutSpacing:
- d->doubleControls ? ret = 8 : ret = 4;
- break;
- case PM_HeaderMargin:
- d->doubleControls ? ret = 2 : ret = 1;
- break;
- case PM_DefaultChildMargin:
- d->doubleControls ? ret = 10 : ret = 5;
- break;
- case PM_ToolBarSeparatorExtent:
- d->doubleControls ? ret = 6 : ret = 3;
- break;
- case PM_DefaultFrameWidth:
- d->doubleControls ? ret = 2 : ret = 1;
- break;
- case PM_MenuVMargin:
- ret = 1;
- break;
- case PM_MenuHMargin:
- ret = 1;
- break;
- case PM_MenuButtonIndicator:
- ret = d->doubleControls ? 24 : 14;
- break;
- case PM_ComboBoxFrameWidth:
- d->doubleControls ? ret = 2 : ret = 1;
- break;
- case PM_SpinBoxFrameWidth:
- d->doubleControls ? ret = 2 : ret = 1;
- break;
- case PM_ButtonDefaultIndicator:
- case PM_ButtonShiftHorizontal:
- case PM_ButtonShiftVertical:
- d->doubleControls ? ret = 2 : ret = 1;
- break;
-#ifndef QT_NO_TABBAR
- case PM_TabBarTabShiftHorizontal:
- ret = 0;
- break;
- case PM_TabBarTabShiftVertical:
- ret = 0;
- break;
-#endif
- case PM_MaximumDragDistance:
- ret = 60;
- break;
- case PM_TabBarTabVSpace:
- ret = d->doubleControls ? 12 : 6;
- break;
- case PM_TabBarBaseHeight:
- ret = 0;
- break;
- case PM_IndicatorWidth:
- ret = d->doubleControls ? windowsMobileIndicatorSize * 2 : windowsMobileIndicatorSize;
- break;
- case PM_IndicatorHeight:
- ret = d->doubleControls ? windowsMobileIndicatorSize * 2 : windowsMobileIndicatorSize;
- break;
- case PM_ExclusiveIndicatorWidth:
- ret = d->doubleControls ? windowsMobileExclusiveIndicatorSize * 2 + 4: windowsMobileExclusiveIndicatorSize + 2;
- break;
- case PM_ExclusiveIndicatorHeight:
- ret = d->doubleControls ? windowsMobileExclusiveIndicatorSize * 2 + 4: windowsMobileExclusiveIndicatorSize + 2;
- break;
-#ifndef QT_NO_SLIDER
- case PM_SliderLength:
- ret = d->doubleControls ? 16 : 8;
- break;
- case PM_FocusFrameHMargin:
- ret = d->doubleControls ? 1 : 2;
- break;
- case PM_SliderThickness:
- ret = d->doubleControls ? windowsMobileSliderThickness * 2: windowsMobileSliderThickness;
- break;
- case PM_TabBarScrollButtonWidth:
- ret = d->doubleControls ? 14 * 2 : 18;
- break;
- case PM_CheckBoxLabelSpacing:
- case PM_RadioButtonLabelSpacing:
- ret = d->doubleControls ? 6 * 2 : 6;
- break;
- // Returns the number of pixels to use for the business part of the
- // slider (i.e., the non-tickmark portion). The remaining space is shared
- // equally between the tickmark regions.
- case PM_SliderControlThickness:
- if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
- int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height() : sl->rect.width();
- int ticks = sl->tickPosition;
- int n = 0;
- if (ticks & QSlider::TicksAbove)
- ++n;
- if (ticks & QSlider::TicksBelow)
- ++n;
- if (!n) {
- ret = space;
- break;
- }
- int thick = 8;
- if (ticks != QSlider::TicksBothSides && ticks != QSlider::NoTicks)
- thick += proxy()->pixelMetric(PM_SliderLength, sl, widget) / 4;
-
- space -= thick;
- if (space > 0)
- thick += (space * 2) / (n + 2);
- ret = thick;
- } else {
- ret = 0;
- }
- break;
-#endif // QT_NO_SLIDER
-#ifndef QT_NO_MENU
- case PM_SmallIconSize:
- d->doubleControls ? ret = windowsMobileIconSize * 2 : ret = windowsMobileIconSize;
- break;
- case PM_ButtonMargin:
- d->doubleControls ? ret = 8 : ret = 4;
- break;
- case PM_LargeIconSize:
- d->doubleControls ? ret = 64 : ret = 32;
- break;
- case PM_IconViewIconSize:
- ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget);
- break;
- case PM_ToolBarIconSize:
- d->doubleControls ? ret = 2 * windowsMobileIconSize : ret = windowsMobileIconSize;
- break;
- case PM_DockWidgetTitleMargin:
- ret = 2;
- break;
-#if defined(Q_DEAD_CODE_FROM_QT4_WIN)
-#else
- case PM_DockWidgetFrameWidth:
- ret = 4;
- break;
-#endif // Q_DEAD_CODE_FROM_QT4_WIN
- break;
-#endif // QT_NO_MENU
-
- case PM_TitleBarHeight:
- d->doubleControls ? ret = 42 : ret = 21;
- break;
- case PM_ScrollBarSliderMin:
-#ifdef Q_OS_WINCE_WM
- if (d->wm65)
-#else
- if (false)
-#endif
- {
- d->doubleControls ? ret = 68 : ret = 34;
- } else {
- d->doubleControls ? ret = 36 : ret = 18;
- }
- break;
- case PM_ScrollBarExtent: {
-
- if (d->smartphone)
- ret = 9;
- else
- d->doubleControls ? ret = 25 : ret = 13;
-
-#ifdef Q_OS_WINCE_WM
- if (d->wm65)
-#else
- if (false)
-#endif
- {
- d->doubleControls ? ret = 26 : ret = 13;
- break;
- }
-
-#ifndef QT_NO_SCROLLAREA
- //Check if the scrollbar is part of an abstractItemView and set size according
- if (widget)
- if (QWidget *parent = widget->parentWidget())
- if (qobject_cast<QAbstractScrollArea *>(parent->parentWidget()))
- if (d->smartphone)
- ret = 8;
- else
- d->doubleControls ? ret = 24 : ret = 12;
-#endif
- }
- break;
- case PM_SplitterWidth:
- ret = qMax(4, QApplication::globalStrut().width());
- break;
-
-#if defined(Q_DEAD_CODE_FROM_QT4_WIN)
- case PM_MDIFrameWidth:
- ret = 1;
- break;
-#endif
- case PM_ToolBarExtensionExtent:
- d->doubleControls ? ret = 32 : ret = 16;
- break;
- case PM_ToolBarItemMargin:
- d->doubleControls ? ret = 2 : ret = 1;
- break;
- case PM_ToolBarItemSpacing:
- d->doubleControls ? ret = 2 : ret = 1;
- break;
- case PM_ToolBarHandleExtent:
- d->doubleControls ? ret = 16 : ret = 8;
- break;
- case PM_ButtonIconSize:
- d->doubleControls ? ret = 32 : ret = 16;
- break;
- case PM_TextCursorWidth:
- ret = 2;
- break;
- case PM_TabBar_ScrollButtonOverlap:
- ret = 0;
- break;
- default:
- ret = QWindowsStyle::pixelMetric(pm, opt, widget);
- break;
- }
- return ret;
-}
-
-int QWindowsMobileStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *widget,
- QStyleHintReturn *returnData) const {
-
- int ret;
- switch (hint) {
- case SH_Menu_MouseTracking:
- case SH_ComboBox_ListMouseTracking:
- case SH_EtchDisabledText:
- ret = 0;
- break;
- case SH_DitherDisabledText:
- ret = 0;
- break;
- case SH_ItemView_ShowDecorationSelected:
- ret = 0;
- break;
-#ifndef QT_NO_TABWIDGET
- case SH_TabWidget_DefaultTabPosition:
- ret = QTabWidget::South;
- break;
-#endif
- case SH_ToolBar_Movable:
- ret = false;
- break;
- case SH_ScrollBar_ContextMenu:
- ret = false;
- break;
- case SH_MenuBar_AltKeyNavigation:
- ret = false;
- break;
- case SH_RequestSoftwareInputPanel:
- ret = RSIP_OnMouseClick;
- break;
- default:
- ret = QWindowsStyle::styleHint(hint, opt, widget, returnData);
- break;
- }
- return ret;
-}
-
-QPixmap QWindowsMobileStyle::standardPixmap(StandardPixmap sp, const QStyleOption *option,
- const QWidget *widget) const {
-
- QWindowsMobileStylePrivate *d = const_cast<QWindowsMobileStylePrivate*>(d_func());
- switch (sp) {
-#ifndef QT_NO_IMAGEFORMAT_XPM
- case SP_ToolBarHorizontalExtensionButton: {
- QPixmap pixmap = QCommonStyle::standardPixmap(sp, option, widget);
- if (d->doubleControls)
- return pixmap.scaledToHeight(pixmap.height() * 2);
- else
- return pixmap;
- }
- case SP_TitleBarMaxButton:
- case SP_TitleBarCloseButton:
- case SP_TitleBarNormalButton:
- case SP_TitleBarMinButton: {
- QImage image;
- switch (sp) {
- case SP_TitleBarMaxButton:
- image = d->imageMaximize;
- break;
- case SP_TitleBarCloseButton:
- image = d->imageClose;
- break;
- case SP_TitleBarNormalButton:
- image = d->imageNormalize;
- break;
- case SP_TitleBarMinButton:
- image = d->imageMinimize;
- break;
- default:
- break;
- }
- if (option) {
- image.setColor(0, option->palette.shadow().color().rgba());
- image.setColor(1, option->palette.highlight().color().rgba());
- image.setColor(2, option->palette.highlight().color().lighter(150).rgba());
- image.setColor(3, option->palette.highlightedText().color().rgba());
- }
-
- return QPixmap::fromImage(image);
- }
-
-#endif
- default:
- return QWindowsStyle::standardPixmap(sp, option, widget);
- }
-}
-
-QPixmap QWindowsMobileStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
- const QStyleOption *option) const {
-
- switch (iconMode) {
- case QIcon::Selected: {
-#ifdef Q_OS_WINCE_WM
- if (d_func()->wm65)
- return pixmap;
-#endif //Q_OS_WINCE_WM
- QImage img = pixmap.toImage().convertToFormat(QImage::Format_ARGB32);
- int imgh = img.height();
- int imgw = img.width();
- for (int y = 0; y < imgh; y += 2) {
- for (int x = 0; x < imgw; x += 2) {
- QColor c = option->palette.highlight().color().rgb();
- c.setAlpha( qAlpha(img.pixel(x, y)));
- QRgb pixel = c.rgba();
- img.setPixel(x, y, pixel);
- }
- }
- return QPixmap::fromImage(img);
- }
- default:
- break;
- }
- return QWindowsStyle::generatedIconPixmap(iconMode, pixmap, option);
-}
-
-
-bool QWindowsMobileStyle::doubleControls() const {
-
- QWindowsMobileStylePrivate *d = const_cast<QWindowsMobileStylePrivate*>(d_func());
-
- return d->doubleControls;
-}
-
-void QWindowsMobileStyle::setDoubleControls(bool doubleControls) {
-
- QWindowsMobileStylePrivate *d = const_cast<QWindowsMobileStylePrivate*>(d_func());
-
- d->doubleControls = doubleControls;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_STYLE_WINDOWSMOBILE
-
diff --git a/src/widgets/styles/qwindowsmobilestyle_p.h b/src/widgets/styles/qwindowsmobilestyle_p.h
deleted file mode 100644
index 68dfbfb412..0000000000
--- a/src/widgets/styles/qwindowsmobilestyle_p.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSMOBILESTYLE_P_H
-#define QWINDOWSMOBILESTYLE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <private/qwindowsstyle_p.h>
-
-QT_BEGIN_NAMESPACE
-
-
-#if !defined(QT_NO_STYLE_WINDOWSMOBILE)
-
-class QWindowsMobileStylePrivate;
-
-class QWindowsMobileStyle : public QWindowsStyle
-{
- Q_OBJECT
-public:
- QWindowsMobileStyle();
- ~QWindowsMobileStyle();
-
- void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
- QPainter *painter, const QWidget *widget = 0) const;
-
- void drawControl(ControlElement element, const QStyleOption *option,
- QPainter *painter, const QWidget *widget) const;
-
- void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
- QPainter *painter, const QWidget *widget) const;
-
- QSize sizeFromContents(ContentsType type, const QStyleOption *option,
- const QSize &size, const QWidget *widget) const;
-
- QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const;
-
- QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
- SubControl sc, const QWidget *widget) const;
-
- QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
- const QStyleOption *option) const;
-
- QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *option,
- const QWidget *widget) const;
-
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
-
- int styleHint(StyleHint hint, const QStyleOption *opt = 0, const QWidget *widget = 0,
- QStyleHintReturn *returnData = 0) const;
-
- void polish(QApplication*);
- void unpolish(QApplication*);
- void polish(QWidget *widget);
- void unpolish(QWidget *widget);
- void polish(QPalette &);
-
- QPalette standardPalette() const;
-
- bool doubleControls() const;
-
- void setDoubleControls(bool);
-
-protected:
- QWindowsMobileStyle(QWindowsMobileStylePrivate &dd);
-
-private:
- Q_DECLARE_PRIVATE(QWindowsMobileStyle)
-};
-
-#endif // QT_NO_STYLE_WINDOWSMOBILE
-
-QT_END_NAMESPACE
-
-#endif //QWINDOWSMOBILESTYLE_P_H
diff --git a/src/widgets/styles/qwindowsmobilestyle_p_p.h b/src/widgets/styles/qwindowsmobilestyle_p_p.h
deleted file mode 100644
index cd9e4636ec..0000000000
--- a/src/widgets/styles/qwindowsmobilestyle_p_p.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSMOBILESTYLE_P_P_H
-#define QWINDOWSMOBILESTYLE_P_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
-// file may change from version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qwindowsmobilestyle_p.h"
-#include "qwindowsstyle_p_p.h"
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_STYLE_WINDOWSMOBILE
-
-class QStyleOptionTab;
-class QStyleOptionSlider;
-
-class QWindowsMobileStylePrivate : public QWindowsStylePrivate
-{
- Q_DECLARE_PUBLIC(QWindowsMobileStyle)
-public:
- QWindowsMobileStylePrivate();
- bool doubleControls;
- bool smartphone;
-#ifdef Q_OS_WINCE_WM
- bool wm65;
-#endif
-
- QImage imageRadioButton;
- QImage imageRadioButtonChecked;
- QImage imageRadioButtonHighlighted;
- QImage imageChecked;
- QImage imageCheckedBold;
- QImage imageArrowDown;
- QImage imageArrowUp;
- QImage imageArrowLeft;
- QImage imageArrowRight;
- QImage imageArrowDownBig;
- QImage imageArrowUpBig;
- QImage imageArrowLeftBig;
- QImage imageArrowRightBig;
- QImage imageClose;
- QImage imageMaximize;
- QImage imageNormalize;
- QImage imageMinimize;
-
- void setupWindowsMobileStyle65();
-
-#ifdef Q_OS_WINCE_WM
- //Windows Mobile 6.5 images
- QImage imageScrollbarHandleUp;
- QImage imageScrollbarHandleDown;
- QImage imageScrollbarHandleUpHigh;
- QImage imageScrollbarHandleDownHigh;
- QImage imageScrollbarGripUp;
- QImage imageScrollbarGripDown;
- QImage imageScrollbarGripMiddle;
- QImage imageListViewHighlightCornerLeft;
- QImage imageListViewHighlightCornerRight;
- QImage imageListViewHighlightMiddle;
- QImage imageTabEnd;
- QImage imageTabSelectedEnd;
- QImage imageTabSelectedBegin;
- QImage imageTabMiddle;
-
- QColor currentTintHigh;
- QColor currentTintButton;
-
- void tintImagesHigh(QColor color);
- void tintImagesButton(QColor color);
- void tintListViewHighlight(QColor color);
-
-#endif //Q_OS_WINCE_WM
-
- void drawScrollbarHandleUp(QPainter *p, QStyleOptionSlider *opt, bool completeFrame = false, bool secondScrollBar = false);
- void drawScrollbarHandleDown(QPainter *p, QStyleOptionSlider *opt, bool completeFrame = false, bool secondScrollBar = false);
- void drawScrollbarGroove(QPainter *p, const QStyleOptionSlider *opt);
- void drawScrollbarGrip(QPainter *p, QStyleOptionSlider *newScrollbar, const QStyleOptionComplex *option, bool drawCompleteFrame);
- void drawTabBarTab(QPainter *p, const QStyleOptionTab *tab);
- void drawPanelItemViewSelected(QPainter *painter, const QStyleOptionViewItem *option, QRect rect = QRect());
-
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_STYLE_WINDOWSMOBILE
-#endif //QWINDOWSMOBILESTYLE_P_P_H
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp
index 075cb3719f..c3a50968e2 100644
--- a/src/widgets/styles/qwindowsstyle.cpp
+++ b/src/widgets/styles/qwindowsstyle.cpp
@@ -42,7 +42,6 @@
#if !defined(QT_NO_STYLE_WINDOWS) || defined(QT_PLUGIN)
-#include <private/qsystemlibrary_p.h>
#include "qapplication.h"
#include "qbitmap.h"
#include "qdrawutil.h" // for now
@@ -91,26 +90,7 @@ QT_END_INCLUDE_NAMESPACE
# define COLOR_GRADIENTINACTIVECAPTION 28
# endif
-
-typedef struct
-{
- DWORD cbSize;
- HICON hIcon;
- int iSysImageIndex;
- int iIcon;
- WCHAR szPath[MAX_PATH];
-} QSHSTOCKICONINFO;
-
-#define _SHGFI_SMALLICON 0x000000001
-#define _SHGFI_LARGEICON 0x000000000
-#define _SHGFI_ICON 0x000000100
-#define _SIID_SHIELD 77
-
-typedef HRESULT (WINAPI *PtrSHGetStockIconInfo)(int siid, int uFlags, QSHSTOCKICONINFO *psii);
-static PtrSHGetStockIconInfo pSHGetStockIconInfo = 0;
-
Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &);
-Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon);
#endif //Q_OS_WIN
QT_BEGIN_INCLUDE_NAMESPACE
@@ -126,13 +106,6 @@ enum QSliderDirection { SlUp, SlDown, SlLeft, SlRight };
QWindowsStylePrivate::QWindowsStylePrivate()
: alt_down(false), menuBarTimer(0)
{
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
- if ((QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
- && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))) {
- QSystemLibrary shellLib(QLatin1String("shell32"));
- pSHGetStockIconInfo = (PtrSHGetStockIconInfo)shellLib.resolve("SHGetStockIconInfo");
- }
-#endif
}
qreal QWindowsStylePrivate::appDevicePixelRatio()
@@ -309,25 +282,15 @@ int QWindowsStylePrivate::pixelMetricFromSystemDp(QStyle::PixelMetric pm, const
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
switch (pm) {
case QStyle::PM_DockWidgetFrameWidth:
-# ifndef Q_OS_WINCE
return GetSystemMetrics(SM_CXFRAME);
-# else
- return GetSystemMetrics(SM_CXDLGFRAME);
-# endif
- break;
case QStyle::PM_TitleBarHeight:
if (widget && (widget->windowType() == Qt::Tool)) {
// MS always use one less than they say
-# ifndef Q_OS_WINCE
return GetSystemMetrics(SM_CYSMCAPTION) - 1;
-# else
- return GetSystemMetrics(SM_CYCAPTION) - 1;
-# endif
}
return GetSystemMetrics(SM_CYCAPTION) - 1;
-# ifndef Q_OS_WINCE
case QStyle::PM_ScrollBarExtent:
{
NONCLIENTMETRICS ncm;
@@ -336,14 +299,9 @@ int QWindowsStylePrivate::pixelMetricFromSystemDp(QStyle::PixelMetric pm, const
return qMax(ncm.iScrollHeight, ncm.iScrollWidth);
}
break;
-# endif // !Q_OS_WINCE
case QStyle::PM_MdiSubWindowFrameWidth:
-# ifndef Q_OS_WINCE
return GetSystemMetrics(SM_CYFRAME);
-# else
- return GetSystemMetrics(SM_CYDLGFRAME);
-# endif
default:
break;
@@ -521,7 +479,7 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW
QPixmap QWindowsStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
const QWidget *widget) const
{
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
QPixmap desktopIcon;
switch(standardPixmap) {
case SP_DriveCDIcon:
@@ -560,7 +518,7 @@ QPixmap QWindowsStyle::standardPixmap(StandardPixmap standardPixmap, const QStyl
if (!desktopIcon.isNull()) {
return desktopIcon;
}
-#endif // Q_OS_WIN && !Q_OS_WINCE && !Q_OS_WINRT
+#endif // Q_OS_WIN && !Q_OS_WINRT
return QCommonStyle::standardPixmap(standardPixmap, opt, widget);
}
@@ -637,12 +595,12 @@ int QWindowsStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWid
#endif // Q_OS_WIN && !Q_OS_WINRT
case SH_Menu_SubMenuSloppyCloseTimeout:
case SH_Menu_SubMenuPopupDelay: {
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
DWORD delay;
if (SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, &delay, 0))
ret = delay;
else
-#endif // Q_OS_WIN && !Q_OS_WINCE && !Q_OS_WINRT
+#endif // Q_OS_WIN && !Q_OS_WINRT
ret = 400;
break;
}
diff --git a/src/widgets/styles/qwindowsstyle_p.h b/src/widgets/styles/qwindowsstyle_p.h
index f9d174d3c6..5d68bfeba0 100644
--- a/src/widgets/styles/qwindowsstyle_p.h
+++ b/src/widgets/styles/qwindowsstyle_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtWidgets/qcommonstyle.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/styles/qwindowsstyle_p_p.h b/src/widgets/styles/qwindowsstyle_p_p.h
index f034255837..0c23f4b4a8 100644
--- a/src/widgets/styles/qwindowsstyle_p_p.h
+++ b/src/widgets/styles/qwindowsstyle_p_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qwindowsstyle_p.h"
#include "qcommonstyle_p.h"
diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp
index 1f4598ea14..c2cce5770f 100644
--- a/src/widgets/styles/qwindowsvistastyle.cpp
+++ b/src/widgets/styles/qwindowsvistastyle.cpp
@@ -43,7 +43,6 @@
#include <qwindow.h>
#include <private/qstyleanimation_p.h>
#include <private/qstylehelper_p.h>
-#include <private/qsystemlibrary_p.h>
#include <private/qapplication_p.h>
#include <qpa/qplatformnativeinterface.h>
@@ -88,8 +87,7 @@ bool QWindowsVistaStylePrivate::useVista()
{
return (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
&& (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))
- && QWindowsVistaStylePrivate::useXP()
- && QWindowsVistaStylePrivate::pGetThemeTransitionDuration != Q_NULLPTR;
+ && QWindowsVistaStylePrivate::useXP();
}
/* \internal
@@ -356,13 +354,13 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
HTHEME theme;
int partId;
- int duration;
+ DWORD duration;
int fromState = 0;
int toState = 0;
//translate state flags to UXTHEME states :
if (element == PE_FrameLineEdit) {
- theme = QWindowsXPStylePrivate::pOpenThemeData(0, L"Edit");
+ theme = OpenThemeData(0, L"Edit");
partId = EP_EDITBORDER_NOSCROLL;
if (oldState & State_MouseOver)
@@ -380,7 +378,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
toState = ETS_NORMAL;
} else {
- theme = QWindowsXPStylePrivate::pOpenThemeData(0, L"Button");
+ theme = OpenThemeData(0, L"Button");
if (element == PE_IndicatorRadioButton)
partId = BP_RADIOBUTTON;
else if (element == PE_IndicatorCheckBox)
@@ -393,9 +391,9 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
}
// Retrieve the transition time between the states from the system.
- if (theme && QWindowsXPStylePrivate::pGetThemeTransitionDuration(theme, partId, fromState, toState,
- TMT_TRANSITIONDURATIONS, &duration) == S_OK)
- {
+ if (theme
+ && SUCCEEDED(GetThemeTransitionDuration(theme, partId, fromState, toState,
+ TMT_TRANSITIONDURATIONS, &duration))) {
t->setDuration(duration);
}
t->setStartTime(QTime::currentTime());
@@ -513,7 +511,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
EP_EDITBORDER_HVSCROLL, stateId, option->rect);
// Since EP_EDITBORDER_HVSCROLL does not us borderfill, theme.noContent cannot be used for clipping
int borderSize = 1;
- QWindowsXPStylePrivate::pGetThemeInt(theme.handle(), theme.partId, theme.stateId, TMT_BORDERSIZE, &borderSize);
+ GetThemeInt(theme.handle(), theme.partId, theme.stateId, TMT_BORDERSIZE, &borderSize);
QRegion clipRegion = option->rect;
QRegion content = option->rect.adjusted(borderSize, borderSize, -borderSize, -borderSize);
clipRegion ^= content;
@@ -548,22 +546,18 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
return;
}
int bgType;
- QWindowsXPStylePrivate::pGetThemeEnumValue( theme.handle(),
- partId,
- stateId,
- TMT_BGTYPE,
- &bgType);
+ GetThemeEnumValue(theme.handle(), partId, stateId, TMT_BGTYPE, &bgType);
if( bgType == BT_IMAGEFILE ) {
d->drawBackground(theme);
} else {
QBrush fillColor = option->palette.brush(QPalette::Base);
if (!isEnabled) {
PROPERTYORIGIN origin = PO_NOTFOUND;
- QWindowsXPStylePrivate::pGetThemePropertyOrigin(theme.handle(), theme.partId, theme.stateId, TMT_FILLCOLOR, &origin);
+ GetThemePropertyOrigin(theme.handle(), theme.partId, theme.stateId, TMT_FILLCOLOR, &origin);
// Use only if the fill property comes from our part
if ((origin == PO_PART || origin == PO_STATE)) {
COLORREF bgRef;
- QWindowsXPStylePrivate::pGetThemeColor(theme.handle(), partId, stateId, TMT_FILLCOLOR, &bgRef);
+ GetThemeColor(theme.handle(), partId, stateId, TMT_FILLCOLOR, &bgRef);
fillColor = QBrush(qRgb(GetRValue(bgRef), GetGValue(bgRef), GetBValue(bgRef)));
}
}
@@ -899,12 +893,12 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
t->setEndImage(endImage);
- int duration = 0;
- HTHEME theme = QWindowsXPStylePrivate::pOpenThemeData(0, L"Button");
+ DWORD duration = 0;
+ const HTHEME theme = OpenThemeData(0, L"Button");
int fromState = buttonStateId(oldState, BP_PUSHBUTTON);
int toState = buttonStateId(option->state, BP_PUSHBUTTON);
- if (QWindowsXPStylePrivate::pGetThemeTransitionDuration(theme, BP_PUSHBUTTON, fromState, toState, TMT_TRANSITIONDURATIONS, &duration) == S_OK)
+ if (GetThemeTransitionDuration(theme, BP_PUSHBUTTON, fromState, toState, TMT_TRANSITIONDURATIONS, &duration) == S_OK)
t->setDuration(duration);
else
t->setDuration(0);
@@ -1456,7 +1450,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
// We cannot currently get the correct selection color for "explorer style" views
COLORREF cref = 0;
XPThemeData theme(d->treeViewHelper(), 0, QLatin1String("LISTVIEW"), 0, 0);
- unsigned int res = pGetThemeColor(theme.handle(), LVP_LISTITEM, LISS_SELECTED, TMT_TEXTCOLOR, &cref);
+ unsigned int res = GetThemeColor(theme.handle(), LVP_LISTITEM, LISS_SELECTED, TMT_TEXTCOLOR, &cref);
QColor textColor(GetRValue(cref), GetGValue(cref), GetBValue(cref));
*/
QPalette palette = vopt->palette;
@@ -1925,7 +1919,7 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption
case SE_PushButtonContents:
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
MARGINS borderSize;
- HTHEME theme = QWindowsXPStylePrivate::pOpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"Button");
+ const HTHEME theme = OpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"Button");
if (theme) {
int stateId = PBS_NORMAL;
if (!(option->state & State_Enabled))
@@ -1940,15 +1934,7 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption
int border = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget);
rect = option->rect.adjusted(border, border, -border, -border);
- int result = QWindowsXPStylePrivate::pGetThemeMargins(theme,
- NULL,
- BP_PUSHBUTTON,
- stateId,
- TMT_CONTENTMARGINS,
- NULL,
- &borderSize);
-
- if (result == S_OK) {
+ if (SUCCEEDED(GetThemeMargins(theme, NULL, BP_PUSHBUTTON, stateId, TMT_CONTENTMARGINS, NULL, &borderSize))) {
rect.adjust(borderSize.cxLeftWidth, borderSize.cyTopHeight,
-borderSize.cxRightWidth, -borderSize.cyBottomHeight);
rect = visualRect(option->direction, option->rect, rect);
@@ -2318,14 +2304,12 @@ void QWindowsVistaStyle::polish(QWidget *widget)
//we do not have to care about unpolishing
widget->setContentsMargins(3, 0, 4, 0);
COLORREF bgRef;
- HTHEME theme = QWindowsXPStylePrivate::pOpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"TOOLTIP");
- if (theme) {
- if (QWindowsXPStylePrivate::pGetThemeColor(theme, TTP_STANDARD, TTSS_NORMAL, TMT_TEXTCOLOR, &bgRef) == S_OK) {
- QColor textColor = QColor::fromRgb(bgRef);
- QPalette pal;
- pal.setColor(QPalette::All, QPalette::ToolTipText, textColor);
- widget->setPalette(pal);
- }
+ HTHEME theme = OpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"TOOLTIP");
+ if (theme && SUCCEEDED(GetThemeColor(theme, TTP_STANDARD, TTSS_NORMAL, TMT_TEXTCOLOR, &bgRef))) {
+ QColor textColor = QColor::fromRgb(bgRef);
+ QPalette pal;
+ pal.setColor(QPalette::All, QPalette::ToolTipText, textColor);
+ widget->setPalette(pal);
}
} else if (qobject_cast<QMessageBox *> (widget)) {
widget->setAttribute(Qt::WA_StyledBackground);
diff --git a/src/widgets/styles/qwindowsvistastyle_p.h b/src/widgets/styles/qwindowsvistastyle_p.h
index 406051f227..0289f404dd 100644
--- a/src/widgets/styles/qwindowsvistastyle_p.h
+++ b/src/widgets/styles/qwindowsvistastyle_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <private/qwindowsxpstyle_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/styles/qwindowsvistastyle_p_p.h b/src/widgets/styles/qwindowsvistastyle_p_p.h
index e207a27a66..4ca47fec2c 100644
--- a/src/widgets/styles/qwindowsvistastyle_p_p.h
+++ b/src/widgets/styles/qwindowsvistastyle_p_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qwindowsvistastyle_p.h"
#if !defined(QT_NO_STYLE_WINDOWSVISTA)
diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp
index ed4271505b..ffedc37edb 100644
--- a/src/widgets/styles/qwindowsxpstyle.cpp
+++ b/src/widgets/styles/qwindowsxpstyle.cpp
@@ -47,7 +47,6 @@
#include <qpa/qplatformnativeinterface.h>
#include <private/qstylehelper_p.h>
#include <private/qwidget_p.h>
-#include <private/qsystemlibrary_p.h>
#include <qpainter.h>
#include <qpaintengine.h>
#include <qwidget.h>
@@ -76,78 +75,6 @@
QT_BEGIN_NAMESPACE
-// Runtime resolved theme engine function calls
-
-QWindowsUxThemeLib::PtrIsAppThemed QWindowsUxThemeLib::pIsAppThemed = Q_NULLPTR;
-QWindowsUxThemeLib::PtrIsThemeActive QWindowsUxThemeLib::pIsThemeActive = Q_NULLPTR;
-QWindowsUxThemeLib::PtrOpenThemeData QWindowsUxThemeLib::pOpenThemeData = Q_NULLPTR;
-QWindowsUxThemeLib::PtrCloseThemeData QWindowsUxThemeLib::pCloseThemeData = Q_NULLPTR;
-QWindowsUxThemeLib::PtrDrawThemeBackground QWindowsUxThemeLib::pDrawThemeBackground = Q_NULLPTR;
-QWindowsUxThemeLib::PtrDrawThemeBackgroundEx QWindowsUxThemeLib::pDrawThemeBackgroundEx = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetCurrentThemeName QWindowsUxThemeLib::pGetCurrentThemeName = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeBool QWindowsUxThemeLib::pGetThemeBool = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeColor QWindowsUxThemeLib::pGetThemeColor = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeEnumValue QWindowsUxThemeLib::pGetThemeEnumValue = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeFilename QWindowsUxThemeLib::pGetThemeFilename = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeFont QWindowsUxThemeLib::pGetThemeFont = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeInt QWindowsUxThemeLib::pGetThemeInt = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeIntList QWindowsUxThemeLib::pGetThemeIntList = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeMargins QWindowsUxThemeLib::pGetThemeMargins = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeMetric QWindowsUxThemeLib::pGetThemeMetric = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemePartSize QWindowsUxThemeLib::pGetThemePartSize = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemePosition QWindowsUxThemeLib::pGetThemePosition = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemePropertyOrigin QWindowsUxThemeLib::pGetThemePropertyOrigin = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeRect QWindowsUxThemeLib::pGetThemeRect = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeString QWindowsUxThemeLib::pGetThemeString = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeBackgroundRegion QWindowsUxThemeLib::pGetThemeBackgroundRegion = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeDocumentationProperty QWindowsUxThemeLib::pGetThemeDocumentationProperty = Q_NULLPTR;
-QWindowsUxThemeLib::PtrIsThemeBackgroundPartiallyTransparent
- QWindowsUxThemeLib::pIsThemeBackgroundPartiallyTransparent = Q_NULLPTR;
-QWindowsUxThemeLib::PtrSetWindowTheme QWindowsUxThemeLib::pSetWindowTheme = Q_NULLPTR;
-QWindowsUxThemeLib::PtrGetThemeTransitionDuration QWindowsUxThemeLib::pGetThemeTransitionDuration = Q_NULLPTR;
-
-bool QWindowsUxThemeLib::resolveSymbols()
-{
- static bool tried = false;
- if (tried)
- return pIsAppThemed != Q_NULLPTR;
- tried = true;
- QSystemLibrary themeLib(QLatin1String("uxtheme"));
- if (!themeLib.load())
- return false;
- pIsAppThemed = (PtrIsAppThemed)themeLib.resolve("IsAppThemed");
- if (!pIsAppThemed)
- return false;
- pIsThemeActive = (PtrIsThemeActive )themeLib.resolve("IsThemeActive");
- pGetThemePartSize = (PtrGetThemePartSize )themeLib.resolve("GetThemePartSize");
- pOpenThemeData = (PtrOpenThemeData )themeLib.resolve("OpenThemeData");
- pCloseThemeData = (PtrCloseThemeData )themeLib.resolve("CloseThemeData");
- pDrawThemeBackground = (PtrDrawThemeBackground )themeLib.resolve("DrawThemeBackground");
- pDrawThemeBackgroundEx = (PtrDrawThemeBackgroundEx )themeLib.resolve("DrawThemeBackgroundEx");
- pGetCurrentThemeName = (PtrGetCurrentThemeName )themeLib.resolve("GetCurrentThemeName");
- pGetThemeBool = (PtrGetThemeBool )themeLib.resolve("GetThemeBool");
- pGetThemeColor = (PtrGetThemeColor )themeLib.resolve("GetThemeColor");
- pGetThemeEnumValue = (PtrGetThemeEnumValue )themeLib.resolve("GetThemeEnumValue");
- pGetThemeFilename = (PtrGetThemeFilename )themeLib.resolve("GetThemeFilename");
- pGetThemeFont = (PtrGetThemeFont )themeLib.resolve("GetThemeFont");
- pGetThemeInt = (PtrGetThemeInt )themeLib.resolve("GetThemeInt");
- pGetThemeIntList = (PtrGetThemeIntList )themeLib.resolve("GetThemeIntList");
- pGetThemeMargins = (PtrGetThemeMargins )themeLib.resolve("GetThemeMargins");
- pGetThemeMetric = (PtrGetThemeMetric )themeLib.resolve("GetThemeMetric");
- pGetThemePartSize = (PtrGetThemePartSize )themeLib.resolve("GetThemePartSize");
- pGetThemePosition = (PtrGetThemePosition )themeLib.resolve("GetThemePosition");
- pGetThemePropertyOrigin = (PtrGetThemePropertyOrigin)themeLib.resolve("GetThemePropertyOrigin");
- pGetThemeRect = (PtrGetThemeRect )themeLib.resolve("GetThemeRect");
- pGetThemeString = (PtrGetThemeString )themeLib.resolve("GetThemeString");
- pGetThemeBackgroundRegion = (PtrGetThemeBackgroundRegion )themeLib.resolve("GetThemeBackgroundRegion");
- pGetThemeDocumentationProperty = (PtrGetThemeDocumentationProperty )themeLib.resolve("GetThemeDocumentationProperty");
- pIsThemeBackgroundPartiallyTransparent = (PtrIsThemeBackgroundPartiallyTransparent)themeLib.resolve("IsThemeBackgroundPartiallyTransparent");
- pSetWindowTheme = (PtrSetWindowTheme )themeLib.resolve("SetWindowTheme");
- if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA)
- pGetThemeTransitionDuration = (PtrGetThemeTransitionDuration)themeLib.resolve("GetThemeTransitionDuration");
- return true;
-}
-
// General const values
static const int windowsItemFrame = 2; // menu item frame width
static const int windowsItemHMargin = 3; // menu item hor text margin
@@ -231,7 +158,7 @@ RECT XPThemeData::toRECT(const QRect &qr)
*/
HRGN XPThemeData::mask(QWidget *widget)
{
- if (!QWindowsXPStylePrivate::pIsThemeBackgroundPartiallyTransparent(handle(), partId, stateId))
+ if (!IsThemeBackgroundPartiallyTransparent(handle(), partId, stateId))
return 0;
HRGN hrgn;
@@ -239,7 +166,7 @@ HRGN XPThemeData::mask(QWidget *widget)
if (widget)
dc = hdcForWidgetBackingStore(widget);
RECT nativeRect = toRECT(rect);
- QWindowsXPStylePrivate::pGetThemeBackgroundRegion(handle(), dc, partId, stateId, &nativeRect, &hrgn);
+ GetThemeBackgroundRegion(handle(), dc, partId, stateId, &nativeRect, &hrgn);
return hrgn;
}
@@ -272,7 +199,7 @@ static HRGN qt_hrgn_from_qregion(const QRegion &region)
qt_add_rect(hRegion, region.boundingRect());
return hRegion;
}
- foreach (const QRect &rect, region.rects())
+ for (const QRect &rect : region)
qt_add_rect(hRegion, rect);
return hRegion;
}
@@ -285,8 +212,7 @@ bool QWindowsXPStylePrivate::useXP(bool update)
{
if (!update)
return use_xp;
- return (use_xp = QWindowsUxThemeLib::resolveSymbols() && pIsThemeActive()
- && (pIsAppThemed() || !QApplication::instance()));
+ return use_xp = IsThemeActive() && (IsAppThemed() || !QApplication::instance());
}
/* \internal
@@ -366,7 +292,7 @@ bool QWindowsXPStylePrivate::initVistaTreeViewTheming()
qWarning("Unable to create the treeview helper window.");
return false;
}
- if (FAILED(QWindowsXPStylePrivate::pSetWindowTheme(m_vistaTreeViewHelper, L"explorer", NULL))) {
+ if (FAILED(SetWindowTheme(m_vistaTreeViewHelper, L"explorer", NULL))) {
qErrnoWarning("SetWindowTheme() failed.");
cleanupVistaTreeViewTheming();
return false;
@@ -391,7 +317,7 @@ void QWindowsXPStylePrivate::cleanupHandleMap()
{
for (int i = 0; i < NThemes; ++i)
if (m_themes[i]) {
- pCloseThemeData(m_themes[i]);
+ CloseThemeData(m_themes[i]);
m_themes[i] = 0;
}
QWindowsXPStylePrivate::cleanupVistaTreeViewTheming();
@@ -407,7 +333,7 @@ HTHEME QWindowsXPStylePrivate::createTheme(int theme, HWND hwnd)
const wchar_t *name = themeNames[theme];
if (theme == VistaTreeViewTheme && QWindowsXPStylePrivate::initVistaTreeViewTheming())
hwnd = QWindowsXPStylePrivate::m_vistaTreeViewHelper;
- m_themes[theme] = pOpenThemeData(hwnd, name);
+ m_themes[theme] = OpenThemeData(hwnd, name);
if (Q_UNLIKELY(!m_themes[theme]))
qErrnoWarning("OpenThemeData() failed for theme %d (%s).",
theme, qPrintable(themeName(theme)));
@@ -505,48 +431,6 @@ const QPixmap *QWindowsXPStylePrivate::tabBody(QWidget *widget)
}
/*! \internal
- Returns \c true if all the necessary theme engine symbols were
- resolved.
-*/
-bool QWindowsXPStylePrivate::resolveSymbols()
-{
- static bool tried = false;
- if (!tried) {
- tried = true;
- QSystemLibrary themeLib(QLatin1String("uxtheme"));
- pIsAppThemed = (PtrIsAppThemed)themeLib.resolve("IsAppThemed");
- if (pIsAppThemed) {
- pIsThemeActive = (PtrIsThemeActive )themeLib.resolve("IsThemeActive");
- pGetThemePartSize = (PtrGetThemePartSize )themeLib.resolve("GetThemePartSize");
- pOpenThemeData = (PtrOpenThemeData )themeLib.resolve("OpenThemeData");
- pCloseThemeData = (PtrCloseThemeData )themeLib.resolve("CloseThemeData");
- pDrawThemeBackground = (PtrDrawThemeBackground )themeLib.resolve("DrawThemeBackground");
- pDrawThemeBackgroundEx = (PtrDrawThemeBackgroundEx )themeLib.resolve("DrawThemeBackgroundEx");
- pGetCurrentThemeName = (PtrGetCurrentThemeName )themeLib.resolve("GetCurrentThemeName");
- pGetThemeBool = (PtrGetThemeBool )themeLib.resolve("GetThemeBool");
- pGetThemeColor = (PtrGetThemeColor )themeLib.resolve("GetThemeColor");
- pGetThemeEnumValue = (PtrGetThemeEnumValue )themeLib.resolve("GetThemeEnumValue");
- pGetThemeFilename = (PtrGetThemeFilename )themeLib.resolve("GetThemeFilename");
- pGetThemeFont = (PtrGetThemeFont )themeLib.resolve("GetThemeFont");
- pGetThemeInt = (PtrGetThemeInt )themeLib.resolve("GetThemeInt");
- pGetThemeIntList = (PtrGetThemeIntList )themeLib.resolve("GetThemeIntList");
- pGetThemeMargins = (PtrGetThemeMargins )themeLib.resolve("GetThemeMargins");
- pGetThemeMetric = (PtrGetThemeMetric )themeLib.resolve("GetThemeMetric");
- pGetThemePartSize = (PtrGetThemePartSize )themeLib.resolve("GetThemePartSize");
- pGetThemePosition = (PtrGetThemePosition )themeLib.resolve("GetThemePosition");
- pGetThemePropertyOrigin = (PtrGetThemePropertyOrigin)themeLib.resolve("GetThemePropertyOrigin");
- pGetThemeRect = (PtrGetThemeRect )themeLib.resolve("GetThemeRect");
- pGetThemeString = (PtrGetThemeString )themeLib.resolve("GetThemeString");
- pGetThemeBackgroundRegion = (PtrGetThemeBackgroundRegion )themeLib.resolve("GetThemeBackgroundRegion");
- pGetThemeDocumentationProperty = (PtrGetThemeDocumentationProperty )themeLib.resolve("GetThemeDocumentationProperty");
- pIsThemeBackgroundPartiallyTransparent = (PtrIsThemeBackgroundPartiallyTransparent)themeLib.resolve("IsThemeBackgroundPartiallyTransparent");
- }
- }
-
- return pIsAppThemed != 0;
-}
-
-/*! \internal
Returns a native buffer (DIB section) of at least the size of
( \a x , \a y ). The buffer has a 32 bit depth, to not lose
the alpha values on proper alpha-pixmaps.
@@ -567,8 +451,11 @@ HBITMAP QWindowsXPStylePrivate::buffer(int w, int h)
w = qMax(bufferW, w);
h = qMax(bufferH, h);
- if (!bufferDC)
- bufferDC = CreateCompatibleDC(qt_win_display_dc());
+ if (!bufferDC) {
+ HDC displayDC = GetDC(0);
+ bufferDC = CreateCompatibleDC(displayDC);
+ ReleaseDC(0, displayDC);
+ }
// Define the header
BITMAPINFO bmi;
@@ -614,8 +501,8 @@ HBITMAP QWindowsXPStylePrivate::buffer(int w, int h)
*/
bool QWindowsXPStylePrivate::isTransparent(XPThemeData &themeData)
{
- return pIsThemeBackgroundPartiallyTransparent(themeData.handle(), themeData.partId,
- themeData.stateId);
+ return IsThemeBackgroundPartiallyTransparent(themeData.handle(), themeData.partId,
+ themeData.stateId);
}
@@ -626,9 +513,10 @@ QRegion QWindowsXPStylePrivate::region(XPThemeData &themeData)
{
HRGN hRgn = 0;
RECT rect = themeData.toRECT(themeData.rect);
- if (!SUCCEEDED(pGetThemeBackgroundRegion(themeData.handle(), bufferHDC(), themeData.partId,
- themeData.stateId, &rect, &hRgn)))
+ if (!SUCCEEDED(GetThemeBackgroundRegion(themeData.handle(), bufferHDC(), themeData.partId,
+ themeData.stateId, &rect, &hRgn))) {
return QRegion();
+ }
HRGN dest = CreateRectRgn(0, 0, 0, 0);
const bool success = CombineRgn(dest, hRgn, 0, RGN_COPY) != ERROR;
@@ -822,7 +710,6 @@ bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData)
bool canDrawDirectly = false;
if (themeData.widget && painter->opacity() == 1.0 && !themeData.rotate
&& tt != ComplexTransform && !themeData.mirrorVertically
- && (!themeData.mirrorHorizontally || pDrawThemeBackgroundEx)
&& !translucentToplevel) {
// Draw on backing store DC only for real widgets or backing store images.
const QPaintDevice *enginePaintDevice = painter->paintEngine()->paintDevice();
@@ -904,44 +791,7 @@ bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeDa
| (themeData.noContent ? DTBG_OMITCONTENT : 0)
| (themeData.mirrorHorizontally ? DTBG_MIRRORDC : 0);
- HRESULT result = S_FALSE;
- if (pDrawThemeBackgroundEx != 0) {
- result = pDrawThemeBackgroundEx(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &drawOptions);
- } else {
- // We are running on a system where the uxtheme.dll does not have
- // the DrawThemeBackgroundEx function, so we need to clip away
- // borders or contents manually. All flips and mirrors uses the
- // fallback implementation
-
- int borderSize = 0;
- PROPERTYORIGIN origin = PO_NOTFOUND;
- pGetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERSIZE, &origin);
- pGetThemeInt(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERSIZE, &borderSize);
-
- // Clip away border region
- QRegion extraClip = sysRgn;
- if ((origin == PO_CLASS || origin == PO_PART || origin == PO_STATE) && borderSize > 0) {
- if (themeData.noBorder) {
- // extraClip &= area is already done
- drawRECT = themeData.toRECT(area.adjusted(-borderSize, -borderSize, borderSize, borderSize));
- }
-
- // Clip away content region
- if (themeData.noContent) {
- QRegion content = area.adjusted(borderSize, borderSize, -borderSize, -borderSize);
- extraClip ^= content;
- }
-
- // Set the clip region, if used..
- if (themeData.noBorder || themeData.noContent) {
- DeleteObject(hrgn);
- hrgn = qt_hrgn_from_qregion(extraClip);
- SelectClipRgn(dc, hrgn);
- }
- }
-
- result = pDrawThemeBackground(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &(drawOptions.rcClip));
- }
+ const HRESULT result = DrawThemeBackgroundEx(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &drawOptions);
SelectClipRgn(dc, 0);
DeleteObject(hrgn);
return SUCCEEDED(result);
@@ -1020,17 +870,17 @@ bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa
BOOL tmt_borderonly = false;
COLORREF tmt_transparentcolor = 0x0;
PROPERTYORIGIN proporigin = PO_NOTFOUND;
- pGetThemeBool(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERONLY, &tmt_borderonly);
- pGetThemeColor(themeData.handle(), themeData.partId, themeData.stateId, TMT_TRANSPARENTCOLOR, &tmt_transparentcolor);
- pGetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, TMT_CAPTIONMARGINS, &proporigin);
+ GetThemeBool(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERONLY, &tmt_borderonly);
+ GetThemeColor(themeData.handle(), themeData.partId, themeData.stateId, TMT_TRANSPARENTCOLOR, &tmt_transparentcolor);
+ GetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, TMT_CAPTIONMARGINS, &proporigin);
partIsTransparent = isTransparent(themeData);
potentialInvalidAlpha = false;
- pGetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, TMT_GLYPHTYPE, &proporigin);
+ GetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, TMT_GLYPHTYPE, &proporigin);
if (proporigin == PO_PART || proporigin == PO_STATE) {
int tmt_glyphtype = GT_NONE;
- pGetThemeEnumValue(themeData.handle(), themeData.partId, themeData.stateId, TMT_GLYPHTYPE, &tmt_glyphtype);
+ GetThemeEnumValue(themeData.handle(), themeData.partId, themeData.stateId, TMT_GLYPHTYPE, &tmt_glyphtype);
potentialInvalidAlpha = partIsTransparent && tmt_glyphtype == GT_IMAGEGLYPH;
}
@@ -1060,8 +910,8 @@ bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa
int borderSize = 0;
PROPERTYORIGIN origin = PO_NOTFOUND;
- pGetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERSIZE, &origin);
- pGetThemeInt(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERSIZE, &borderSize);
+ GetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERSIZE, &origin);
+ GetThemeInt(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERSIZE, &borderSize);
// Clip away border region
if ((origin == PO_CLASS || origin == PO_PART || origin == PO_STATE) && borderSize > 0) {
@@ -1094,8 +944,6 @@ bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa
// Difference between area and rect
int dx = area.x() - rect.x();
int dy = area.y() - rect.y();
- int dr = area.right() - rect.right();
- int db = area.bottom() - rect.bottom();
// Adjust so painting rect starts from Origo
rect.moveTo(0,0);
@@ -1108,24 +956,8 @@ bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa
| (themeData.noContent ? DTBG_OMITCONTENT : 0);
// Drawing the part into the backing store
- if (pDrawThemeBackgroundEx != 0) {
- RECT rect(themeData.toRECT(area));
- pDrawThemeBackgroundEx(themeData.handle(), dc, themeData.partId, themeData.stateId, &rect, &drawOptions);
- } else {
- // Set the clip region, if used..
- if (addBorderContentClipping) {
- HRGN hrgn = qt_hrgn_from_qregion(extraClip);
- SelectClipRgn(dc, hrgn);
- // Compensate for the noBorder area difference (noContent has the same area)
- drawOptions.rcClip = themeData.toRECT(rect.adjusted(dx, dy, dr, db));
- DeleteObject(hrgn);
- }
-
- pDrawThemeBackground(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawOptions.rcClip), 0);
-
- if (addBorderContentClipping)
- SelectClipRgn(dc, 0);
- }
+ RECT wRect(themeData.toRECT(area));
+ DrawThemeBackgroundEx(themeData.handle(), dc, themeData.partId, themeData.stateId, &wRect, &drawOptions);
// If not cached, analyze the buffer data to figure
// out alpha type, and if it contains data
@@ -1183,11 +1015,8 @@ bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeDa
painter->setClipRegion(newRegion);
#if defined(DEBUG_XP_STYLE) && 0
printf("Using region:\n");
- QVector<QRect> rects = newRegion.rects();
- for (int i = 0; i < rects.count(); ++i) {
- const QRect &r = rects.at(i);
+ for (const QRect &r : newRegion)
printf(" (%d, %d, %d, %d)\n", r.x(), r.y(), r.right(), r.bottom());
- }
#endif
}
@@ -1345,12 +1174,12 @@ void QWindowsXPStyle::polish(QWidget *widget)
// Get text color for group box labels
COLORREF cref;
XPThemeData theme(widget, 0, QWindowsXPStylePrivate::ButtonTheme, 0, 0);
- QWindowsXPStylePrivate::pGetThemeColor(theme.handle(), BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR, &cref);
+ GetThemeColor(theme.handle(), BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR, &cref);
d->groupBoxTextColor = qRgb(GetRValue(cref), GetGValue(cref), GetBValue(cref));
- QWindowsXPStylePrivate::pGetThemeColor(theme.handle(), BP_GROUPBOX, GBS_DISABLED, TMT_TEXTCOLOR, &cref);
+ GetThemeColor(theme.handle(), BP_GROUPBOX, GBS_DISABLED, TMT_TEXTCOLOR, &cref);
d->groupBoxTextColorDisabled = qRgb(GetRValue(cref), GetGValue(cref), GetBValue(cref));
// Where does this color come from?
- //pGetThemeColor(theme.handle(), TKP_TICS, TSS_NORMAL, TMT_COLOR, &cref);
+ //GetThemeColor(theme.handle(), TKP_TICS, TSS_NORMAL, TMT_COLOR, &cref);
d->sliderTickColor = qRgb(165, 162, 148);
d->hasInitColors = true;
}
@@ -1472,15 +1301,7 @@ QRect QWindowsXPStyle::subElementRect(SubElement sr, const QStyleOption *option,
int border = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget);
rect = option->rect.adjusted(border, border, -border, -border);
- int result = QWindowsXPStylePrivate::pGetThemeMargins(theme,
- NULL,
- BP_PUSHBUTTON,
- stateId,
- TMT_CONTENTMARGINS,
- NULL,
- &borderSize);
-
- if (result == S_OK) {
+ if (SUCCEEDED(GetThemeMargins(theme, NULL, BP_PUSHBUTTON, stateId, TMT_CONTENTMARGINS, NULL, &borderSize))) {
rect.adjust(borderSize.cxLeftWidth, borderSize.cyTopHeight,
-borderSize.cxRightWidth, -borderSize.cyBottomHeight);
rect = visualRect(option->direction, option->rect, rect);
@@ -1667,14 +1488,14 @@ case PE_Frame:
else
stateId = ETS_NORMAL;
int fillType;
- if (QWindowsXPStylePrivate::pGetThemeEnumValue(theme.handle(), partId, stateId, TMT_BGTYPE, &fillType) == S_OK) {
+ if (GetThemeEnumValue(theme.handle(), partId, stateId, TMT_BGTYPE, &fillType) == S_OK) {
if (fillType == BT_BORDERFILL) {
COLORREF bcRef;
- QWindowsXPStylePrivate::pGetThemeColor(theme.handle(), partId, stateId, TMT_BORDERCOLOR, &bcRef);
+ GetThemeColor(theme.handle(), partId, stateId, TMT_BORDERCOLOR, &bcRef);
QColor bordercolor(qRgb(GetRValue(bcRef), GetGValue(bcRef), GetBValue(bcRef)));
QPen oldPen = p->pen();
// int borderSize = 1;
- // pGetThemeInt(theme.handle(), partId, stateId, TMT_BORDERCOLOR, &borderSize);
+ // GetThemeInt(theme.handle(), partId, stateId, TMT_BORDERCOLOR, &borderSize);
// Inner white border
p->setPen(QPen(option->palette.base().color(), 1));
@@ -1733,11 +1554,7 @@ case PE_Frame:
return;
}
int bgType;
- QWindowsXPStylePrivate::pGetThemeEnumValue( theme.handle(),
- partId,
- stateId,
- TMT_BGTYPE,
- &bgType);
+ GetThemeEnumValue(theme.handle(), partId, stateId, TMT_BGTYPE, &bgType);
if( bgType == BT_IMAGEFILE ) {
theme.mirrorHorizontally = hMirrored;
theme.mirrorVertically = vMirrored;
@@ -1750,11 +1567,11 @@ case PE_Frame:
if (!isEnabled) {
PROPERTYORIGIN origin = PO_NOTFOUND;
- QWindowsXPStylePrivate::pGetThemePropertyOrigin(theme.handle(), theme.partId, theme.stateId, TMT_FILLCOLOR, &origin);
+ GetThemePropertyOrigin(theme.handle(), theme.partId, theme.stateId, TMT_FILLCOLOR, &origin);
// Use only if the fill property comes from our part
if ((origin == PO_PART || origin == PO_STATE)) {
COLORREF bgRef;
- QWindowsXPStylePrivate::pGetThemeColor(theme.handle(), partId, stateId, TMT_FILLCOLOR, &bgRef);
+ GetThemeColor(theme.handle(), partId, stateId, TMT_FILLCOLOR, &bgRef);
fillColor = QBrush(qRgb(GetRValue(bgRef), GetGValue(bgRef), GetBValue(bgRef)));
}
}
@@ -1780,7 +1597,7 @@ case PE_Frame:
wchar_t themeFileName[maxlength];
wchar_t themeColor[maxlength];
// Due to a a scaling issue with the XP Silver theme, tab gradients are not used with it
- if (QWindowsXPStylePrivate::pGetCurrentThemeName(themeFileName, maxlength, themeColor, maxlength, NULL, 0) == S_OK) {
+ if (GetCurrentThemeName(themeFileName, maxlength, themeColor, maxlength, NULL, 0) == S_OK) {
wchar_t *offset = 0;
if ((offset = wcsrchr(themeFileName, QChar(QLatin1Char('\\')).unicode())) != NULL) {
offset++;
@@ -2567,10 +2384,10 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op
= p->fontMetrics().elidedText(dwOpt->title, Qt::ElideRight, titleRect.width());
int result = TST_NONE;
- QWindowsXPStylePrivate::pGetThemeEnumValue(theme.handle(), WP_SMALLCAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWTYPE, &result);
+ GetThemeEnumValue(theme.handle(), WP_SMALLCAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWTYPE, &result);
if (result != TST_NONE) {
COLORREF textShadowRef;
- QWindowsXPStylePrivate::pGetThemeColor(theme.handle(), WP_SMALLCAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWCOLOR, &textShadowRef);
+ GetThemeColor(theme.handle(), WP_SMALLCAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWCOLOR, &textShadowRef);
QColor textShadow = qRgb(GetRValue(textShadowRef), GetGValue(textShadowRef), GetBValue(textShadowRef));
p->setPen(textShadow);
drawItemText(p, titleRect.adjusted(1, 1, 1, 1),
@@ -3165,10 +2982,10 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
QRect ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarLabel, widget);
int result = TST_NONE;
- QWindowsXPStylePrivate::pGetThemeEnumValue(theme.handle(), WP_CAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWTYPE, &result);
+ GetThemeEnumValue(theme.handle(), WP_CAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWTYPE, &result);
if (result != TST_NONE) {
COLORREF textShadowRef;
- QWindowsXPStylePrivate::pGetThemeColor(theme.handle(), WP_CAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWCOLOR, &textShadowRef);
+ GetThemeColor(theme.handle(), WP_CAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWCOLOR, &textShadowRef);
QColor textShadow = qRgb(GetRValue(textShadowRef), GetGValue(textShadowRef), GetBValue(textShadowRef));
p->setPen(textShadow);
p->drawText(ir.x() + 3, ir.y() + 2, ir.width() - 1, ir.height(),
@@ -4200,7 +4017,7 @@ void QWindowsXPStylePrivate::dumpNativeDIB(int w, int h)
static void showProperty(XPThemeData &themeData, const PropPair &prop)
{
PROPERTYORIGIN origin = PO_NOTFOUND;
- pGetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &origin);
+ GetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &origin);
const char *originStr;
switch(origin) {
case PO_STATE:
@@ -4225,35 +4042,35 @@ static void showProperty(XPThemeData &themeData, const PropPair &prop)
case TMT_STRING:
{
wchar_t buffer[512];
- pGetThemeString(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, buffer, 512);
+ GetThemeString(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, buffer, 512);
printf(" (%sString) %-20S: %S\n", originStr, prop.propName, buffer);
}
break;
case TMT_ENUM:
{
int result = -1;
- pGetThemeEnumValue(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
+ GetThemeEnumValue(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
printf(" (%sEnum) %-20S: %d\n", originStr, prop.propName, result);
}
break;
case TMT_INT:
{
int result = -1;
- pGetThemeInt(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
+ GetThemeInt(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
printf(" (%sint) %-20S: %d\n", originStr, prop.propName, result);
}
break;
case TMT_BOOL:
{
BOOL result = false;
- pGetThemeBool(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
+ GetThemeBool(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
printf(" (%sbool) %-20S: %d\n", originStr, prop.propName, result);
}
break;
case TMT_COLOR:
{
COLORREF result = 0;
- pGetThemeColor(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
+ GetThemeColor(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
printf(" (%scolor) %-20S: 0x%08X\n", originStr, prop.propName, result);
}
break;
@@ -4261,7 +4078,7 @@ static void showProperty(XPThemeData &themeData, const PropPair &prop)
{
MARGINS result;
memset(&result, 0, sizeof(result));
- pGetThemeMargins(themeData.handle(), 0, themeData.partId, themeData.stateId, prop.propValue, 0, &result);
+ GetThemeMargins(themeData.handle(), 0, themeData.partId, themeData.stateId, prop.propValue, 0, &result);
printf(" (%smargins) %-20S: (%d, %d, %d, %d)\n", originStr,
prop.propName, result.cxLeftWidth, result.cyTopHeight, result.cxRightWidth, result.cyBottomHeight);
}
@@ -4269,7 +4086,7 @@ static void showProperty(XPThemeData &themeData, const PropPair &prop)
case TMT_FILENAME:
{
wchar_t buffer[512];
- pGetThemeFilename(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, buffer, 512);
+ GetThemeFilename(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, buffer, 512);
printf(" (%sfilename)%-20S: %S\n", originStr, prop.propName, buffer);
}
break;
@@ -4281,9 +4098,9 @@ static void showProperty(XPThemeData &themeData, const PropPair &prop)
memset(&result1, 0, sizeof(result1));
memset(&result2, 0, sizeof(result2));
memset(&result3, 0, sizeof(result3));
- pGetThemePartSize(themeData.handle(), 0, themeData.partId, themeData.stateId, 0, TS_MIN, &result1);
- pGetThemePartSize(themeData.handle(), 0, themeData.partId, themeData.stateId, 0, TS_TRUE, &result2);
- pGetThemePartSize(themeData.handle(), 0, themeData.partId, themeData.stateId, 0, TS_DRAW, &result3);
+ GetThemePartSize(themeData.handle(), 0, themeData.partId, themeData.stateId, 0, TS_MIN, &result1);
+ GetThemePartSize(themeData.handle(), 0, themeData.partId, themeData.stateId, 0, TS_TRUE, &result2);
+ GetThemePartSize(themeData.handle(), 0, themeData.partId, themeData.stateId, 0, TS_DRAW, &result3);
printf(" (%ssize) %-20S: Min (%d, %d), True(%d, %d), Draw(%d, %d)\n", originStr, prop.propName,
result1.cx, result1.cy, result2.cx, result2.cy, result3.cx, result3.cy);
}
@@ -4292,7 +4109,7 @@ static void showProperty(XPThemeData &themeData, const PropPair &prop)
{
POINT result;
memset(&result, 0, sizeof(result));
- pGetThemePosition(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
+ GetThemePosition(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
printf(" (%sPosition)%-20S: (%d, %d)\n", originStr, prop.propName, result.x, result.y);
}
break;
@@ -4300,7 +4117,7 @@ static void showProperty(XPThemeData &themeData, const PropPair &prop)
{
RECT result;
memset(&result, 0, sizeof(result));
- pGetThemeRect(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
+ GetThemeRect(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
printf(" (%sRect) %-20S: (%d, %d, %d, %d)\n", originStr, prop.propName, result.left, result.top, result.right, result.bottom);
}
break;
@@ -4308,7 +4125,7 @@ static void showProperty(XPThemeData &themeData, const PropPair &prop)
{
LOGFONT result;
memset(&result, 0, sizeof(result));
- pGetThemeFont(themeData.handle(), 0, themeData.partId, themeData.stateId, prop.propValue, &result);
+ GetThemeFont(themeData.handle(), 0, themeData.partId, themeData.stateId, prop.propValue, &result);
printf(" (%sFont) %-20S: %S height(%d) width(%d) weight(%d)\n", originStr, prop.propName,
result.lfFaceName, result.lfHeight, result.lfWidth, result.lfWeight);
}
@@ -4317,7 +4134,7 @@ static void showProperty(XPThemeData &themeData, const PropPair &prop)
{
INTLIST result;
memset(&result, 0, sizeof(result));
- pGetThemeIntList(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
+ GetThemeIntList(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
printf(" (%sInt list)%-20S: { ", originStr, prop.propName);
for (int i = 0; i < result.iValueCount; ++i)
printf("%d ", result.iValues[i]);
@@ -4369,7 +4186,7 @@ void QWindowsXPStylePrivate::showProperties(XPThemeData &themeData)
for (int j = 0; j < all_props.count(); ++j) {
PropPair prop = all_props.at(j);
wchar_t buf[500];
- pGetThemeDocumentationProperty(themeName, prop.propName, buf, 500);
+ GetThemeDocumentationProperty(themeName, prop.propName, buf, 500);
printf("%3d: (%4d) %-20S %S\n", j, prop.propValue, prop.propName, buf);
}
}
@@ -4379,7 +4196,7 @@ void QWindowsXPStylePrivate::showProperties(XPThemeData &themeData)
for (int j = 0; j < all_props.count(); ++j) {
PropPair prop = all_props.at(j);
PROPERTYORIGIN origin = PO_NOTFOUND;
- pGetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &origin);
+ GetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &origin);
if (origin == PO_GLOBAL) {
showProperty(themeData, prop);
}
@@ -4390,7 +4207,7 @@ void QWindowsXPStylePrivate::showProperties(XPThemeData &themeData)
for (int j = 0; j < all_props.count(); ++j) {
PropPair prop = all_props.at(j);
PROPERTYORIGIN origin = PO_NOTFOUND;
- pGetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &origin);
+ GetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &origin);
if (origin != PO_NOTFOUND)
{
showProperty(themeData, prop);
diff --git a/src/widgets/styles/qwindowsxpstyle_p.h b/src/widgets/styles/qwindowsxpstyle_p.h
index 61bb508511..088178cb5a 100644
--- a/src/widgets/styles/qwindowsxpstyle_p.h
+++ b/src/widgets/styles/qwindowsxpstyle_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <private/qwindowsstyle_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h
index 8ee4d1a641..7cbccdaf67 100644
--- a/src/widgets/styles/qwindowsxpstyle_p_p.h
+++ b/src/widgets/styles/qwindowsxpstyle_p_p.h
@@ -51,107 +51,19 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qwindowsxpstyle_p.h"
#include "qwindowsstyle_p_p.h"
#include <qmap.h>
#include <qt_windows.h>
#include <uxtheme.h>
-
-#if WINVER >= 0x0600
#include <vssym32.h>
-#else
-#include <tmschema.h>
-#endif
#include <limits.h>
QT_BEGIN_NAMESPACE
-// Older Platform SDKs do not have the extended DrawThemeBackgroundEx
-// function. We add the needed parts here, and use the extended
-// function dynamically, if available in uxtheme.dll. Else, we revert
-// back to using the DrawThemeBackground function.
-#ifndef DTBG_OMITBORDER
-# ifndef DTBG_CLIPRECT
-# define DTBG_CLIPRECT 0x00000001
-# endif
-# ifndef DTBG_DRAWSOLID
-# define DTBG_DRAWSOLID 0x00000002
-# endif
-# ifndef DTBG_OMITBORDER
-# define DTBG_OMITBORDER 0x00000004
-# endif
-# ifndef DTBG_OMITCONTENT
-# define DTBG_OMITCONTENT 0x00000008
-# endif
-# ifndef DTBG_COMPUTINGREGION
-# define DTBG_COMPUTINGREGION 0x00000010
-# endif
-# ifndef DTBG_MIRRORDC
-# define DTBG_MIRRORDC 0x00000020
-# endif
- typedef struct _DTBGOPTS
- {
- DWORD dwSize;
- DWORD dwFlags;
- RECT rcClip;
- } DTBGOPTS, *PDTBGOPTS;
-#endif // _DTBGOPTS
-
-// Undefined for some compile environments
-#ifndef TMT_TEXTCOLOR
-# define TMT_TEXTCOLOR 3803
-#endif
-#ifndef TMT_BORDERCOLORHINT
-# define TMT_BORDERCOLORHINT 3822
-#endif
-#ifndef TMT_BORDERSIZE
-# define TMT_BORDERSIZE 2403
-#endif
-#ifndef TMT_BORDERONLY
-# define TMT_BORDERONLY 2203
-#endif
-#ifndef TMT_TRANSPARENTCOLOR
-# define TMT_TRANSPARENTCOLOR 3809
-#endif
-#ifndef TMT_CAPTIONMARGINS
-# define TMT_CAPTIONMARGINS 3603
-#endif
-#ifndef TMT_CONTENTMARGINS
-# define TMT_CONTENTMARGINS 3602
-#endif
-#ifndef TMT_SIZINGMARGINS
-# define TMT_SIZINGMARGINS 3601
-#endif
-#ifndef TMT_GLYPHTYPE
-# define TMT_GLYPHTYPE 4012
-#endif
-#ifndef TMT_BGTYPE
-# define TMT_BGTYPE 4001
-#endif
-#ifndef TMT_TEXTSHADOWTYPE
-# define TMT_TEXTSHADOWTYPE 4010
-#endif
-#ifndef TMT_BORDERCOLOR
-# define TMT_BORDERCOLOR 3801
-#endif
-#ifndef BT_IMAGEFILE
-# define BT_IMAGEFILE 0
-#endif
-#ifndef BT_BORDERFILL
-# define BT_BORDERFILL 1
-#endif
-#ifndef BT_NONE
-# define BT_NONE 2
-#endif
-#ifndef TMT_FILLCOLOR
-# define TMT_FILLCOLOR 3802
-#endif
-#ifndef TMT_PROGRESSCHUNKSIZE
-# define TMT_PROGRESSCHUNKSIZE 2411
-#endif
-
// TMT_TEXTSHADOWCOLOR is wrongly defined in mingw
#if TMT_TEXTSHADOWCOLOR != 3818
#undef TMT_TEXTSHADOWCOLOR
@@ -161,13 +73,6 @@ QT_BEGIN_NAMESPACE
# define TST_NONE 0
#endif
-#ifndef GT_NONE
-# define GT_NONE 0
-#endif
-#ifndef GT_IMAGEGLYPH
-# define GT_IMAGEGLYPH 1
-#endif
-
// These defines are missing from the tmschema, but still exist as
// states for their parts
#ifndef MINBS_INACTIVE
@@ -278,65 +183,7 @@ struct ThemeMapData {
hasAlphaChannel(false), wasAlphaSwapped(false), hadInvalidAlpha(false) {}
};
-struct QWindowsUxThemeLib {
- typedef bool (WINAPI *PtrIsAppThemed)();
- typedef bool (WINAPI *PtrIsThemeActive)();
- typedef HTHEME (WINAPI *PtrOpenThemeData)(HWND hwnd, LPCWSTR pszClassList);
- typedef HRESULT (WINAPI *PtrCloseThemeData)(HTHEME hTheme);
- typedef HRESULT (WINAPI *PtrDrawThemeBackground)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, OPTIONAL const RECT *pClipRect);
- typedef HRESULT (WINAPI *PtrDrawThemeBackgroundEx)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, OPTIONAL const DTBGOPTS *pOptions);
- typedef HRESULT (WINAPI *PtrGetCurrentThemeName)(OUT LPWSTR pszThemeFileName, int cchMaxNameChars, OUT OPTIONAL LPWSTR pszColorBuff, int cchMaxColorChars, OUT OPTIONAL LPWSTR pszSizeBuff, int cchMaxSizeChars);
- typedef HRESULT (WINAPI *PtrGetThemeDocumentationProperty)(LPCWSTR pszThemeName, LPCWSTR pszPropertyName, OUT LPWSTR pszValueBuff, int cchMaxValChars);
- typedef HRESULT (WINAPI *PtrGetThemeBool)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT BOOL *pfVal);
- typedef HRESULT (WINAPI *PtrGetThemeColor)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT COLORREF *pColor);
- typedef HRESULT (WINAPI *PtrGetThemeEnumValue)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT int *piVal);
- typedef HRESULT (WINAPI *PtrGetThemeFilename)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT LPWSTR pszThemeFileName, int cchMaxBuffChars);
- typedef HRESULT (WINAPI *PtrGetThemeFont)(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, int iStateId, int iPropId, OUT LOGFONT *pFont);
- typedef HRESULT (WINAPI *PtrGetThemeInt)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT int *piVal);
- typedef HRESULT (WINAPI *PtrGetThemeIntList)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT INTLIST *pIntList);
- typedef HRESULT (WINAPI *PtrGetThemeMargins)(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, int iStateId, int iPropId, OPTIONAL RECT *prc, OUT MARGINS *pMargins);
- typedef HRESULT (WINAPI *PtrGetThemeMetric)(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, int iStateId, int iPropId, OUT int *piVal);
- typedef HRESULT (WINAPI *PtrGetThemePartSize)(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, OPTIONAL RECT *prc, enum THEMESIZE eSize, OUT SIZE *psz);
- typedef HRESULT (WINAPI *PtrGetThemePosition)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT POINT *pPoint);
- typedef HRESULT (WINAPI *PtrGetThemePropertyOrigin)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT enum PROPERTYORIGIN *pOrigin);
- typedef HRESULT (WINAPI *PtrGetThemeRect)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT RECT *pRect);
- typedef HRESULT (WINAPI *PtrGetThemeString)(HTHEME hTheme, int iPartId, int iStateId, int iPropId, OUT LPWSTR pszBuff, int cchMaxBuffChars);
- typedef HRESULT (WINAPI *PtrGetThemeBackgroundRegion)(HTHEME hTheme, OPTIONAL HDC hdc, int iPartId, int iStateId, const RECT *pRect, OUT HRGN *pRegion);
- typedef BOOL (WINAPI *PtrIsThemeBackgroundPartiallyTransparent)(HTHEME hTheme, int iPartId, int iStateId);
- typedef HRESULT (WINAPI *PtrSetWindowTheme)(HWND hwnd, LPCWSTR pszSubAppName, LPCWSTR pszSubIdList);
- typedef HRESULT (WINAPI *PtrGetThemeTransitionDuration)(HTHEME hTheme, int iPartId, int iStateFromId, int iStateToId, int iPropId, int *pDuration);
-
- static bool resolveSymbols();
-
- static PtrIsAppThemed pIsAppThemed;
- static PtrIsThemeActive pIsThemeActive;
- static PtrOpenThemeData pOpenThemeData;
- static PtrCloseThemeData pCloseThemeData;
- static PtrDrawThemeBackground pDrawThemeBackground;
- static PtrDrawThemeBackgroundEx pDrawThemeBackgroundEx;
- static PtrGetCurrentThemeName pGetCurrentThemeName;
- static PtrGetThemeBool pGetThemeBool;
- static PtrGetThemeColor pGetThemeColor;
- static PtrGetThemeEnumValue pGetThemeEnumValue;
- static PtrGetThemeFilename pGetThemeFilename;
- static PtrGetThemeFont pGetThemeFont;
- static PtrGetThemeInt pGetThemeInt;
- static PtrGetThemeIntList pGetThemeIntList;
- static PtrGetThemeMargins pGetThemeMargins;
- static PtrGetThemeMetric pGetThemeMetric;
- static PtrGetThemePartSize pGetThemePartSize;
- static PtrGetThemePosition pGetThemePosition;
- static PtrGetThemePropertyOrigin pGetThemePropertyOrigin;
- static PtrGetThemeRect pGetThemeRect;
- static PtrGetThemeString pGetThemeString;
- static PtrGetThemeBackgroundRegion pGetThemeBackgroundRegion;
- static PtrGetThemeDocumentationProperty pGetThemeDocumentationProperty;
- static PtrIsThemeBackgroundPartiallyTransparent pIsThemeBackgroundPartiallyTransparent;
- static PtrSetWindowTheme pSetWindowTheme;
- static PtrGetThemeTransitionDuration pGetThemeTransitionDuration; // Windows Vista onwards.
-};
-
-class QWindowsXPStylePrivate : public QWindowsStylePrivate, public QWindowsUxThemeLib
+class QWindowsXPStylePrivate : public QWindowsStylePrivate
{
Q_DECLARE_PUBLIC(QWindowsXPStyle)
public:
@@ -385,7 +232,6 @@ public:
HDC bufferHDC()
{ return bufferDC;}
- static bool resolveSymbols();
static bool useXP(bool update = false);
static QRect scrollBarGripperBounds(QStyle::State flags, const QWidget *widget, XPThemeData *theme);
@@ -443,7 +289,7 @@ inline QSizeF XPThemeData::size()
QSizeF result(0, 0);
if (isValid()) {
SIZE size;
- if (SUCCEEDED(QWindowsXPStylePrivate::pGetThemePartSize(handle(), 0, partId, stateId, 0, TS_TRUE, &size)))
+ if (SUCCEEDED(GetThemePartSize(handle(), 0, partId, stateId, 0, TS_TRUE, &size)))
result = QSize(size.cx, size.cy);
}
return result;
@@ -455,7 +301,7 @@ inline QMarginsF XPThemeData::margins(const QRect &qRect, int propId)
if (isValid()) {
MARGINS margins;
RECT rect = XPThemeData::toRECT(qRect);
- if (SUCCEEDED(QWindowsXPStylePrivate::pGetThemeMargins(handle(), 0, partId, stateId, propId, &rect, &margins)))
+ if (SUCCEEDED(GetThemeMargins(handle(), 0, partId, stateId, propId, &rect, &margins)))
result = QMargins(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight);
}
return result;
@@ -466,7 +312,7 @@ inline QMarginsF XPThemeData::margins(int propId)
QMarginsF result(0, 0, 0 ,0);
if (isValid()) {
MARGINS margins;
- if (SUCCEEDED(QWindowsXPStylePrivate::pGetThemeMargins(handle(), 0, partId, stateId, propId, NULL, &margins)))
+ if (SUCCEEDED(GetThemeMargins(handle(), 0, partId, stateId, propId, NULL, &margins)))
result = QMargins(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight);
}
return result;
diff --git a/src/widgets/styles/styles.pri b/src/widgets/styles/styles.pri
index 11f7d973cc..1805e4a8af 100644
--- a/src/widgets/styles/styles.pri
+++ b/src/widgets/styles/styles.pri
@@ -33,11 +33,7 @@ SOURCES += \
styles/qstylesheetstyle_default.cpp \
styles/qpixmapstyle.cpp
-wince* {
- RESOURCES += styles/qstyle_wince.qrc
-} else {
- RESOURCES += styles/qstyle.qrc
-}
+RESOURCES += styles/qstyle.qrc
contains( styles, all ) {
styles = fusion mac windows windowsxp windowsvista
@@ -95,22 +91,6 @@ contains( styles, fusion ) {
DEFINES += QT_NO_STYLE_FUSION
}
-contains( styles, windowsce ) {
- HEADERS += styles/qwindowscestyle_p.h
- HEADERS += styles/qwindowscestyle_p_p.h
- SOURCES += styles/qwindowscestyle.cpp
-} else {
- DEFINES += QT_NO_STYLE_WINDOWSCE
-}
-
-contains( styles, windowsmobile ) {
- HEADERS += styles/qwindowsmobilestyle_p.h
- HEADERS += styles/qwindowsmobilestyle_p_p.h
- SOURCES += styles/qwindowsmobilestyle.cpp
-} else {
- DEFINES += QT_NO_STYLE_WINDOWSMOBILE
-}
-
contains( styles, android ) {
HEADERS += styles/qandroidstyle_p.h
SOURCES += styles/qandroidstyle.cpp
diff --git a/src/widgets/util/qcolormap.h b/src/widgets/util/qcolormap.h
index 0c752d4a22..8e652d8154 100644
--- a/src/widgets/util/qcolormap.h
+++ b/src/widgets/util/qcolormap.h
@@ -40,6 +40,7 @@
#ifndef QCOLORMAP_H
#define QCOLORMAP_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qatomic.h>
#include <QtGui/qrgb.h>
#include <QtCore/qvector.h>
diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp
index 2c7dbf63be..3006f0c9ce 100644
--- a/src/widgets/util/qcompleter.cpp
+++ b/src/widgets/util/qcompleter.cpp
@@ -480,7 +480,7 @@ QMatchData QCompletionEngine::filterHistory()
for (int i = 0; i < source->rowCount(); i++) {
QString str = source->index(i, c->column).data().toString();
if (str.startsWith(c->prefix, c->cs)
-#if !defined(Q_OS_WIN) || defined(Q_OS_WINCE)
+#if !defined(Q_OS_WIN)
&& ((!isFsModel && !isDirModel) || QDir::toNativeSeparators(str) != QDir::separator())
#endif
)
@@ -1055,7 +1055,7 @@ void QCompleter::setModel(QAbstractItemModel *model)
delete oldModel;
#ifndef QT_NO_DIRMODEL
if (qobject_cast<QDirModel *>(model)) {
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
setCaseSensitivity(Qt::CaseInsensitive);
#else
setCaseSensitivity(Qt::CaseSensitive);
@@ -1065,7 +1065,7 @@ void QCompleter::setModel(QAbstractItemModel *model)
#ifndef QT_NO_FILESYSTEMMODEL
QFileSystemModel *fsModel = qobject_cast<QFileSystemModel *>(model);
if (fsModel) {
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
setCaseSensitivity(Qt::CaseInsensitive);
#else
setCaseSensitivity(Qt::CaseSensitive);
@@ -1790,7 +1790,7 @@ QString QCompleter::pathFromIndex(const QModelIndex& index) const
idx = parent.sibling(parent.row(), index.column());
} while (idx.isValid());
-#if !defined(Q_OS_WIN) || defined(Q_OS_WINCE)
+#if !defined(Q_OS_WIN)
if (list.count() == 1) // only the separator or some other text
return list[0];
list[0].clear() ; // the join below will provide the separator
@@ -1830,7 +1830,7 @@ QStringList QCompleter::splitPath(const QString& path) const
return QStringList(completionPrefix());
QString pathCopy = QDir::toNativeSeparators(path);
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
if (pathCopy == QLatin1String("\\") || pathCopy == QLatin1String("\\\\"))
return QStringList(pathCopy);
const bool startsWithDoubleSlash = pathCopy.startsWith(QLatin1String("\\\\"));
@@ -1841,7 +1841,7 @@ QStringList QCompleter::splitPath(const QString& path) const
const QChar sep = QDir::separator();
QStringList parts = pathCopy.split(sep);
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
if (startsWithDoubleSlash)
parts[0].prepend(QLatin1String("\\\\"));
#else
diff --git a/src/widgets/util/qcompleter.h b/src/widgets/util/qcompleter.h
index 435639be99..33e6540264 100644
--- a/src/widgets/util/qcompleter.h
+++ b/src/widgets/util/qcompleter.h
@@ -40,6 +40,7 @@
#ifndef QCOMPLETER_H
#define QCOMPLETER_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qpoint.h>
#include <QtCore/qstring.h>
diff --git a/src/widgets/util/qcompleter_p.h b/src/widgets/util/qcompleter_p.h
index 10dde975c0..c35f70b451 100644
--- a/src/widgets/util/qcompleter_p.h
+++ b/src/widgets/util/qcompleter_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qobject_p.h"
#ifndef QT_NO_COMPLETER
diff --git a/src/widgets/util/qflickgesture_p.h b/src/widgets/util/qflickgesture_p.h
index 1b82a314ee..fa70806ef7 100644
--- a/src/widgets/util/qflickgesture_p.h
+++ b/src/widgets/util/qflickgesture_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qevent.h"
#include "qgesturerecognizer.h"
#include "private/qgesture_p.h"
diff --git a/src/widgets/util/qscroller.h b/src/widgets/util/qscroller.h
index 1e017a2410..561dcfaefc 100644
--- a/src/widgets/util/qscroller.h
+++ b/src/widgets/util/qscroller.h
@@ -40,6 +40,7 @@
#ifndef QSCROLLER_H
#define QSCROLLER_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/QObject>
#include <QtCore/QPointF>
#include <QtWidgets/QScrollerProperties>
diff --git a/src/widgets/util/qscroller_p.h b/src/widgets/util/qscroller_p.h
index 24ad841a91..4557e7cc33 100644
--- a/src/widgets/util/qscroller_p.h
+++ b/src/widgets/util/qscroller_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QObject>
#include <QPointer>
#include <QQueue>
diff --git a/src/widgets/util/qscrollerproperties.h b/src/widgets/util/qscrollerproperties.h
index 67f3d0e15d..4fdc9bd32f 100644
--- a/src/widgets/util/qscrollerproperties.h
+++ b/src/widgets/util/qscrollerproperties.h
@@ -40,6 +40,7 @@
#ifndef QSCROLLERPROPERTIES_H
#define QSCROLLERPROPERTIES_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/QScopedPointer>
#include <QtCore/QMetaType>
#include <QtCore/QVariant>
diff --git a/src/widgets/util/qscrollerproperties_p.h b/src/widgets/util/qscrollerproperties_p.h
index d480d8d829..7965171321 100644
--- a/src/widgets/util/qscrollerproperties_p.h
+++ b/src/widgets/util/qscrollerproperties_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QPointF>
#include <QEasingCurve>
#include <qscrollerproperties.h>
diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp
index 74feb05d9b..2a418167f1 100644
--- a/src/widgets/util/qsystemtrayicon.cpp
+++ b/src/widgets/util/qsystemtrayicon.cpp
@@ -141,7 +141,7 @@ QSystemTrayIcon::QSystemTrayIcon(QObject *parent)
\sa visible
*/
QSystemTrayIcon::QSystemTrayIcon(const QIcon &icon, QObject *parent)
-: QObject(*new QSystemTrayIconPrivate(), parent)
+ : QSystemTrayIcon(parent)
{
setIcon(icon);
}
@@ -446,19 +446,11 @@ QBalloonTip::QBalloonTip(QSystemTrayIcon::MessageIcon icon, const QString& title
titleLabel->setText(title);
QFont f = titleLabel->font();
f.setBold(true);
-#ifdef Q_OS_WINCE
- f.setPointSize(f.pointSize() - 2);
-#endif
titleLabel->setFont(f);
titleLabel->setTextFormat(Qt::PlainText); // to maintain compat with windows
-#ifdef Q_OS_WINCE
- const int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize);
- const int closeButtonSize = style()->pixelMetric(QStyle::PM_SmallIconSize) - 2;
-#else
const int iconSize = 18;
const int closeButtonSize = 15;
-#endif
QPushButton *closeButton = new QPushButton;
closeButton->setIcon(style()->standardIcon(QStyle::SP_TitleBarCloseButton));
@@ -468,21 +460,13 @@ QBalloonTip::QBalloonTip(QSystemTrayIcon::MessageIcon icon, const QString& title
QObject::connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
QLabel *msgLabel = new QLabel;
-#ifdef Q_OS_WINCE
- f.setBold(false);
- msgLabel->setFont(f);
-#endif
msgLabel->installEventFilter(this);
msgLabel->setText(message);
msgLabel->setTextFormat(Qt::PlainText);
msgLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
// smart size for the message label
-#ifdef Q_OS_WINCE
- int limit = QApplication::desktop()->availableGeometry(msgLabel).size().width() / 2;
-#else
int limit = QApplication::desktop()->availableGeometry(msgLabel).size().width() / 3;
-#endif
if (msgLabel->sizeHint().width() > limit) {
msgLabel->setWordWrap(true);
if (msgLabel->sizeHint().width() > limit) {
@@ -493,15 +477,9 @@ QBalloonTip::QBalloonTip(QSystemTrayIcon::MessageIcon icon, const QString& title
control->document()->setDefaultTextOption(opt);
}
}
-#ifdef Q_OS_WINCE
- // Make sure that the text isn't wrapped "somewhere" in the balloon widget
- // in the case that we have a long title label.
- setMaximumWidth(limit);
-#else
// Here we allow the text being much smaller than the balloon widget
// to emulate the weird standard windows behavior.
msgLabel->setFixedSize(limit, msgLabel->heightForWidth(limit));
-#endif
}
QIcon si;
@@ -753,9 +731,8 @@ void QSystemTrayIconPrivate::addPlatformMenu(QMenu *menu) const
// The recursion depth is the same as menu depth, so should not
// be higher than 3 levels.
- QListIterator<QAction *> it(menu->actions());
- while (it.hasNext()) {
- QAction *action = it.next();
+ const auto actions = menu->actions();
+ for (QAction *action : actions) {
if (action->menu())
addPlatformMenu(action->menu());
}
diff --git a/src/widgets/util/qsystemtrayicon.h b/src/widgets/util/qsystemtrayicon.h
index 105e25f44e..fb238c92b0 100644
--- a/src/widgets/util/qsystemtrayicon.h
+++ b/src/widgets/util/qsystemtrayicon.h
@@ -40,6 +40,7 @@
#ifndef QSYSTEMTRAYICON_H
#define QSYSTEMTRAYICON_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qobject.h>
#ifndef QT_NO_SYSTEMTRAYICON
diff --git a/src/widgets/util/qsystemtrayicon_p.h b/src/widgets/util/qsystemtrayicon_p.h
index 396a91eea6..7aca6631cc 100644
--- a/src/widgets/util/qsystemtrayicon_p.h
+++ b/src/widgets/util/qsystemtrayicon_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qsystemtrayicon.h"
#include "private/qobject_p.h"
diff --git a/src/widgets/util/qsystemtrayicon_win.cpp b/src/widgets/util/qsystemtrayicon_win.cpp
index 7cbf979901..2da24e482b 100644
--- a/src/widgets/util/qsystemtrayicon_win.cpp
+++ b/src/widgets/util/qsystemtrayicon_win.cpp
@@ -200,7 +200,7 @@ QSystemTrayIconSys::QSystemTrayIconSys(HWND hwnd, QSystemTrayIcon *object)
MYWM_TASKBARCREATED = RegisterWindowMessage(L"TaskbarCreated");
}
- // Allow the WM_TASKBARCREATED message through the UIPI filter on Windows Vista and higher
+ // Allow the WM_TASKBARCREATED message through the UIPI filter on Windows 7 and higher
static PtrChangeWindowMessageFilterEx pChangeWindowMessageFilterEx =
(PtrChangeWindowMessageFilterEx)QSystemLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilterEx");
@@ -208,13 +208,14 @@ QSystemTrayIconSys::QSystemTrayIconSys(HWND hwnd, QSystemTrayIcon *object)
// Call the safer ChangeWindowMessageFilterEx API if available (Windows 7 onwards)
pChangeWindowMessageFilterEx(m_hwnd, MYWM_TASKBARCREATED, Q_MSGFLT_ALLOW, 0);
} else {
+ // Call the deprecated ChangeWindowMessageFilter API otherwise (Vista onwards)
+ // May 2016: Still resolved at runtime since the definition is not present in MinGW 4.9.
+ // TODO: Replace by direct invocation when upgrading MinGW.
static PtrChangeWindowMessageFilter pChangeWindowMessageFilter =
(PtrChangeWindowMessageFilter)QSystemLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilter");
- if (pChangeWindowMessageFilter) {
- // Call the deprecated ChangeWindowMessageFilter API otherwise
+ if (pChangeWindowMessageFilter)
pChangeWindowMessageFilter(MYWM_TASKBARCREATED, Q_MSGFLT_ALLOW);
- }
}
}
@@ -416,6 +417,7 @@ QRect QSystemTrayIconSys::findIconGeometry(UINT iconId)
UINT uID;
};
+ // Windows 7 onwards.
static PtrShell_NotifyIconGetRect Shell_NotifyIconGetRect =
(PtrShell_NotifyIconGetRect)QSystemLibrary::resolve(QLatin1String("shell32"),
"Shell_NotifyIconGetRect");
diff --git a/src/widgets/util/qsystemtrayicon_wince.cpp b/src/widgets/util/qsystemtrayicon_wince.cpp
deleted file mode 100644
index fa876574f8..0000000000
--- a/src/widgets/util/qsystemtrayicon_wince.cpp
+++ /dev/null
@@ -1,301 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qsystemtrayicon_p.h"
-#ifndef QT_NO_SYSTEMTRAYICON
-#define _WIN32_IE 0x0600 //required for NOTIFYICONDATA_V2_SIZE
-
-#include <qt_windows.h>
-#include <shlwapi.h>
-#include <QApplication>
-
-QT_BEGIN_NAMESPACE
-
-static const UINT q_uNOTIFYICONID = 13; // IDs from 0 to 12 are reserved on WinCE.
-#define MYWM_NOTIFYICON (WM_APP+101)
-
-struct Q_NOTIFYICONIDENTIFIER {
- DWORD cbSize;
- HWND hWnd;
- UINT uID;
- GUID guidItem;
-};
-
-class QSystemTrayIconSys : QWidget
-{
-public:
- QSystemTrayIconSys(QSystemTrayIcon *object);
- ~QSystemTrayIconSys();
- bool winEvent( MSG *m, long *result );
- bool trayMessage(DWORD msg);
- void setIconContents(NOTIFYICONDATA &data);
- void createIcon();
- QRect findTrayGeometry();
- HICON hIcon;
- QPoint globalPos;
- QSystemTrayIcon *q;
-private:
- uint notifyIconSize;
- int maxTipLength;
- bool ignoreNextMouseRelease;
-};
-
-QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *object)
- : hIcon(0), q(object), ignoreNextMouseRelease(false)
-
-{
- notifyIconSize = FIELD_OFFSET(NOTIFYICONDATA, szTip[64]); // NOTIFYICONDATAW_V1_SIZE;
- maxTipLength = 64;
-}
-
-QSystemTrayIconSys::~QSystemTrayIconSys()
-{
- if (hIcon)
- DestroyIcon(hIcon);
-}
-
-QRect QSystemTrayIconSys::findTrayGeometry()
-{
- // Use lower right corner as fallback
- QPoint brCorner = qApp->desktop()->screenGeometry().bottomRight();
- QRect ret(brCorner.x() - 10, brCorner.y() - 10, 10, 10);
- return ret;
-}
-
-void QSystemTrayIconSys::setIconContents(NOTIFYICONDATA &tnd)
-{
- tnd.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
- tnd.uCallbackMessage = MYWM_NOTIFYICON;
- tnd.hIcon = hIcon;
- QString tip = q->toolTip();
-
- if (!tip.isNull()) {
- tip = tip.left(maxTipLength - 1) + QChar();
- memcpy(tnd.szTip, tip.utf16(), qMin(tip.length() + 1, maxTipLength) * sizeof(wchar_t));
- }
-}
-
-bool QSystemTrayIconSys::trayMessage(DWORD msg)
-{
- NOTIFYICONDATA tnd;
- memset(&tnd, 0, notifyIconSize);
- tnd.uID = q_uNOTIFYICONID;
- tnd.cbSize = notifyIconSize;
- tnd.hWnd = winId();
-
- Q_ASSERT(testAttribute(Qt::WA_WState_Created));
-
- if (msg != NIM_DELETE) {
- setIconContents(tnd);
- }
-
- return Shell_NotifyIcon(msg, &tnd);
-}
-
-void QSystemTrayIconSys::createIcon()
-{
- hIcon = 0;
- QIcon icon = q->icon();
- if (icon.isNull())
- return;
-
- //const QSize preferredSize(GetSystemMetrics(SM_CXSMICON) * 2, GetSystemMetrics(SM_CYSMICON) * 2);
- const QSize preferredSize(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON));
- QPixmap pm = icon.pixmap(preferredSize);
- if (pm.isNull())
- return;
-
- hIcon = pm.toWinHICON();
-}
-
-bool QSystemTrayIconSys::winEvent( MSG *m, long *result )
-{
- switch(m->message) {
- case WM_CREATE:
- SetWindowLong(winId(), GWL_USERDATA, (LONG)((CREATESTRUCTW*)m->lParam)->lpCreateParams);
- break;
-
- case MYWM_NOTIFYICON:
- {
- QPoint gpos = QCursor::pos();
-
- switch (m->lParam) {
- case WM_LBUTTONUP:
- if (ignoreNextMouseRelease)
- ignoreNextMouseRelease = false;
- else
- emit q->activated(QSystemTrayIcon::Trigger);
- break;
-
- case WM_LBUTTONDBLCLK:
- ignoreNextMouseRelease = true; // Since DBLCLICK Generates a second mouse
- // release we must ignore it
- emit q->activated(QSystemTrayIcon::DoubleClick);
- break;
-
- case WM_RBUTTONUP:
- if (q->contextMenu()) {
- q->contextMenu()->popup(gpos);
-
- // We must ensure that the popup menu doesn't show up behind the task bar.
- QRect desktopRect = qApp->desktop()->availableGeometry();
- int maxY = desktopRect.y() + desktopRect.height() - q->contextMenu()->height();
- if (gpos.y() > maxY) {
- gpos.ry() = maxY;
- q->contextMenu()->move(gpos);
- }
- }
- emit q->activated(QSystemTrayIcon::Context);
- break;
-
- case WM_MBUTTONUP:
- emit q->activated(QSystemTrayIcon::MiddleClick);
- break;
-
- default:
- break;
- }
- break;
- }
- default:
- return QWidget::winEvent(m, result);
- }
- return 0;
-}
-
-QSystemTrayIconPrivate::QSystemTrayIconPrivate()
- : sys(0),
- visible(false)
-{
-}
-
-QSystemTrayIconPrivate::~QSystemTrayIconPrivate()
-{
-}
-
-void QSystemTrayIconPrivate::install_sys()
-{
- Q_Q(QSystemTrayIcon);
- if (!sys) {
- sys = new QSystemTrayIconSys(q);
- sys->createIcon();
- sys->trayMessage(NIM_ADD);
- }
-}
-
-void QSystemTrayIconPrivate::showMessage_sys(const QString &title, const QString &message, QSystemTrayIcon::MessageIcon type, int timeOut)
-{
- if (!sys)
- return;
-
- uint uSecs = 0;
- if ( timeOut < 0)
- uSecs = 10000; //10 sec default
- else uSecs = (int)timeOut;
-
- //message is limited to 255 chars + NULL
- QString messageString;
- if (message.isEmpty() && !title.isEmpty())
- messageString = QLatin1Char(' '); //ensures that the message shows when only title is set
- else
- messageString = message.left(255) + QChar();
-
- //title is limited to 63 chars + NULL
- QString titleString = title.left(63) + QChar();
-
- //show QBalloonTip
- QRect trayRect = sys->findTrayGeometry();
- QBalloonTip::showBalloon(type, title, message, sys->q, QPoint(trayRect.left(),
- trayRect.center().y()), uSecs, false);
-}
-
-QRect QSystemTrayIconPrivate::geometry_sys() const
-{
- return QRect();
-}
-
-void QSystemTrayIconPrivate::remove_sys()
-{
- if (!sys)
- return;
-
- sys->trayMessage(NIM_DELETE);
- delete sys;
- sys = 0;
-}
-
-void QSystemTrayIconPrivate::updateIcon_sys()
-{
- if (!sys)
- return;
-
- HICON hIconToDestroy = sys->hIcon;
-
- sys->createIcon();
- sys->trayMessage(NIM_MODIFY);
-
- if (hIconToDestroy)
- DestroyIcon(hIconToDestroy);
-}
-
-void QSystemTrayIconPrivate::updateMenu_sys()
-{
-
-}
-
-void QSystemTrayIconPrivate::updateToolTip_sys()
-{
- // Calling sys->trayMessage(NIM_MODIFY) on an existing icon is broken on Windows CE.
- // So we need to call updateIcon_sys() which creates a new icon handle.
- updateIcon_sys();
-}
-
-bool QSystemTrayIconPrivate::isSystemTrayAvailable_sys()
-{
- return true;
-}
-
-bool QSystemTrayIconPrivate::supportsMessages_sys()
-{
- return true;
-}
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/widgets/util/qundogroup.h b/src/widgets/util/qundogroup.h
index f4243d483e..4e2fdeed26 100644
--- a/src/widgets/util/qundogroup.h
+++ b/src/widgets/util/qundogroup.h
@@ -40,6 +40,7 @@
#ifndef QUNDOGROUP_H
#define QUNDOGROUP_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qstring.h>
diff --git a/src/widgets/util/qundostack.cpp b/src/widgets/util/qundostack.cpp
index 307debc03f..18f85ca505 100644
--- a/src/widgets/util/qundostack.cpp
+++ b/src/widgets/util/qundostack.cpp
@@ -110,10 +110,8 @@ QT_BEGIN_NAMESPACE
*/
QUndoCommand::QUndoCommand(const QString &text, QUndoCommand *parent)
+ : QUndoCommand(parent)
{
- d = new QUndoCommandPrivate;
- if (parent != 0)
- parent->d->child_list.append(this);
setText(text);
}
diff --git a/src/widgets/util/qundostack.h b/src/widgets/util/qundostack.h
index fbd8f237ee..f4db78300b 100644
--- a/src/widgets/util/qundostack.h
+++ b/src/widgets/util/qundostack.h
@@ -40,6 +40,7 @@
#ifndef QUNDOSTACK_H
#define QUNDOSTACK_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qstring.h>
diff --git a/src/widgets/util/qundostack_p.h b/src/widgets/util/qundostack_p.h
index 9bfe527306..1bfe992426 100644
--- a/src/widgets/util/qundostack_p.h
+++ b/src/widgets/util/qundostack_p.h
@@ -40,6 +40,7 @@
#ifndef QUNDOSTACK_P_H
#define QUNDOSTACK_P_H
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <private/qobject_p.h>
#include <QtCore/qlist.h>
#include <QtCore/qstring.h>
diff --git a/src/widgets/util/qundoview.h b/src/widgets/util/qundoview.h
index fab040ba0e..3ed9ea5989 100644
--- a/src/widgets/util/qundoview.h
+++ b/src/widgets/util/qundoview.h
@@ -40,6 +40,7 @@
#ifndef QUNDOVIEW_H
#define QUNDOVIEW_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qlistview.h>
#include <QtCore/qstring.h>
diff --git a/src/widgets/util/util.pri b/src/widgets/util/util.pri
index 9f43dc42f0..700831771d 100644
--- a/src/widgets/util/util.pri
+++ b/src/widgets/util/util.pri
@@ -27,7 +27,7 @@ SOURCES += \
util/qundostack.cpp \
util/qundoview.cpp
-win32:!wince:!winrt {
+win32:!winrt {
SOURCES += util/qsystemtrayicon_win.cpp
} else:contains(QT_CONFIG, xcb) {
SOURCES += util/qsystemtrayicon_x11.cpp
diff --git a/src/widgets/widgets.pro b/src/widgets/widgets.pro
index b609e4c434..e4f7640a10 100644
--- a/src/widgets/widgets.pro
+++ b/src/widgets/widgets.pro
@@ -1,5 +1,4 @@
TARGET = QtWidgets
-wince: ORIG_TARGET = $$TARGET
QT = core-private gui-private
MODULE_CONFIG = uic
diff --git a/src/widgets/widgets/qabstractbutton.h b/src/widgets/widgets/qabstractbutton.h
index bd18c394f2..7bf0e0b9d6 100644
--- a/src/widgets/widgets/qabstractbutton.h
+++ b/src/widgets/widgets/qabstractbutton.h
@@ -40,6 +40,7 @@
#ifndef QABSTRACTBUTTON_H
#define QABSTRACTBUTTON_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtGui/qicon.h>
#include <QtGui/qkeysequence.h>
#include <QtWidgets/qwidget.h>
diff --git a/src/widgets/widgets/qabstractbutton_p.h b/src/widgets/widgets/qabstractbutton_p.h
index f65a0527fc..8f67c0d367 100644
--- a/src/widgets/widgets/qabstractbutton_p.h
+++ b/src/widgets/widgets/qabstractbutton_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qabstractbutton.h"
#include "QtCore/qbasictimer.h"
diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp
index 1482b990a6..2587a7a03b 100644
--- a/src/widgets/widgets/qabstractscrollarea.cpp
+++ b/src/widgets/widgets/qabstractscrollarea.cpp
@@ -493,9 +493,6 @@ void QAbstractScrollAreaPrivate::layoutChildren()
horizontalScrollBarRect.adjust(vsbExt, 0, 0, 0);
#endif
if (!hasCornerWidget && htransient)
-#ifdef Q_OS_MAC
- if (QSysInfo::macVersion() >= QSysInfo::MV_10_8)
-#endif
horizontalScrollBarRect.adjust(0, 0, cornerOffset.x(), 0);
scrollBarContainers[Qt::Horizontal]->setGeometry(QStyle::visualRect(opt.direction, opt.rect, horizontalScrollBarRect));
scrollBarContainers[Qt::Horizontal]->raise();
@@ -504,9 +501,6 @@ void QAbstractScrollAreaPrivate::layoutChildren()
if (needv) {
QRect verticalScrollBarRect (QPoint(cornerPoint.x(), controlsRect.top() + hHeaderBottom), QPoint(controlsRect.right(), cornerPoint.y() - 1));
if (!hasCornerWidget && vtransient)
-#ifdef Q_OS_MAC
- if (QSysInfo::macVersion() >= QSysInfo::MV_10_8)
-#endif
verticalScrollBarRect.adjust(0, 0, 0, cornerOffset.y());
scrollBarContainers[Qt::Vertical]->setGeometry(QStyle::visualRect(opt.direction, opt.rect, verticalScrollBarRect));
scrollBarContainers[Qt::Vertical]->raise();
@@ -1316,7 +1310,7 @@ void QAbstractScrollArea::mouseMoveEvent(QMouseEvent *e)
void QAbstractScrollArea::wheelEvent(QWheelEvent *e)
{
Q_D(QAbstractScrollArea);
- if (static_cast<QWheelEvent*>(e)->orientation() == Qt::Horizontal)
+ if (e->orientation() == Qt::Horizontal)
QApplication::sendEvent(d->hbar, e);
else
QApplication::sendEvent(d->vbar, e);
diff --git a/src/widgets/widgets/qabstractscrollarea.h b/src/widgets/widgets/qabstractscrollarea.h
index 9f8ea27408..476914b781 100644
--- a/src/widgets/widgets/qabstractscrollarea.h
+++ b/src/widgets/widgets/qabstractscrollarea.h
@@ -40,6 +40,7 @@
#ifndef QABSTRACTSCROLLAREA_H
#define QABSTRACTSCROLLAREA_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qframe.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qabstractscrollarea_p.h b/src/widgets/widgets/qabstractscrollarea_p.h
index 5239f72ec4..600c834c29 100644
--- a/src/widgets/widgets/qabstractscrollarea_p.h
+++ b/src/widgets/widgets/qabstractscrollarea_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qframe_p.h"
#include "qabstractscrollarea.h"
diff --git a/src/widgets/widgets/qabstractslider.h b/src/widgets/widgets/qabstractslider.h
index 4f8d12fd49..86d6830f10 100644
--- a/src/widgets/widgets/qabstractslider.h
+++ b/src/widgets/widgets/qabstractslider.h
@@ -40,6 +40,7 @@
#ifndef QABSTRACTSLIDER_H
#define QABSTRACTSLIDER_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qabstractslider_p.h b/src/widgets/widgets/qabstractslider_p.h
index e78cf7a27c..600616061a 100644
--- a/src/widgets/widgets/qabstractslider_p.h
+++ b/src/widgets/widgets/qabstractslider_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QtCore/qbasictimer.h"
#include "QtCore/qelapsedtimer.h"
#include "private/qwidget_p.h"
diff --git a/src/widgets/widgets/qabstractspinbox.h b/src/widgets/widgets/qabstractspinbox.h
index 8d31c1f503..d93489e663 100644
--- a/src/widgets/widgets/qabstractspinbox.h
+++ b/src/widgets/widgets/qabstractspinbox.h
@@ -40,6 +40,7 @@
#ifndef QABSTRACTSPINBOX_H
#define QABSTRACTSPINBOX_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
#include <QtGui/qvalidator.h>
diff --git a/src/widgets/widgets/qabstractspinbox_p.h b/src/widgets/widgets/qabstractspinbox_p.h
index a54659ecaa..47ca10a183 100644
--- a/src/widgets/widgets/qabstractspinbox_p.h
+++ b/src/widgets/widgets/qabstractspinbox_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QtWidgets/qabstractspinbox.h"
#ifndef QT_NO_SPINBOX
diff --git a/src/widgets/widgets/qbuttongroup.h b/src/widgets/widgets/qbuttongroup.h
index 58da20540f..ff931b1ee0 100644
--- a/src/widgets/widgets/qbuttongroup.h
+++ b/src/widgets/widgets/qbuttongroup.h
@@ -40,6 +40,7 @@
#ifndef QBUTTONGROUP_H
#define QBUTTONGROUP_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qobject.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qbuttongroup_p.h b/src/widgets/widgets/qbuttongroup_p.h
index 95a72eb4fd..b94dd170b4 100644
--- a/src/widgets/widgets/qbuttongroup_p.h
+++ b/src/widgets/widgets/qbuttongroup_p.h
@@ -45,6 +45,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtWidgets/qbuttongroup.h>
#ifndef QT_NO_BUTTONGROUP
diff --git a/src/widgets/widgets/qcalendarwidget.h b/src/widgets/widgets/qcalendarwidget.h
index ef473cba94..7780065117 100644
--- a/src/widgets/widgets/qcalendarwidget.h
+++ b/src/widgets/widgets/qcalendarwidget.h
@@ -40,6 +40,7 @@
#ifndef QCALENDARWIDGET_H
#define QCALENDARWIDGET_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
#include <QtCore/qdatetime.h>
diff --git a/src/widgets/widgets/qcheckbox.cpp b/src/widgets/widgets/qcheckbox.cpp
index 19369d6cb1..d4ba17b08e 100644
--- a/src/widgets/widgets/qcheckbox.cpp
+++ b/src/widgets/widgets/qcheckbox.cpp
@@ -204,10 +204,8 @@ QCheckBox::QCheckBox(QWidget *parent)
*/
QCheckBox::QCheckBox(const QString &text, QWidget *parent)
- : QAbstractButton (*new QCheckBoxPrivate, parent)
+ : QCheckBox(parent)
{
- Q_D(QCheckBox);
- d->init();
setText(text);
}
diff --git a/src/widgets/widgets/qcheckbox.h b/src/widgets/widgets/qcheckbox.h
index 70aac38488..22f26b6667 100644
--- a/src/widgets/widgets/qcheckbox.h
+++ b/src/widgets/widgets/qcheckbox.h
@@ -40,6 +40,7 @@
#ifndef QCHECKBOX_H
#define QCHECKBOX_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qabstractbutton.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h
index 095a06fe31..2da1ceb047 100644
--- a/src/widgets/widgets/qcombobox.h
+++ b/src/widgets/widgets/qcombobox.h
@@ -40,6 +40,7 @@
#ifndef QCOMBOBOX_H
#define QCOMBOBOX_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
#include <QtWidgets/qabstractitemdelegate.h>
#include <QtCore/qabstractitemmodel.h>
diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h
index 3c92b09e9a..7ca077abf9 100644
--- a/src/widgets/widgets/qcombobox_p.h
+++ b/src/widgets/widgets/qcombobox_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QtWidgets/qcombobox.h"
#ifndef QT_NO_COMBOBOX
diff --git a/src/widgets/widgets/qcommandlinkbutton.cpp b/src/widgets/widgets/qcommandlinkbutton.cpp
index 2ec8b1c41a..b6ec2a8d31 100644
--- a/src/widgets/widgets/qcommandlinkbutton.cpp
+++ b/src/widgets/widgets/qcommandlinkbutton.cpp
@@ -281,23 +281,18 @@ QCommandLinkButton::QCommandLinkButton(QWidget *parent)
*/
QCommandLinkButton::QCommandLinkButton(const QString &text, QWidget *parent)
- : QPushButton(*new QCommandLinkButtonPrivate, parent)
+ : QCommandLinkButton(parent)
{
- Q_D(QCommandLinkButton);
setText(text);
- d->init();
}
/*!
Constructs a command link with a \a text, a \a description, and a \a parent.
*/
QCommandLinkButton::QCommandLinkButton(const QString &text, const QString &description, QWidget *parent)
- : QPushButton(*new QCommandLinkButtonPrivate, parent)
+ : QCommandLinkButton(text, parent)
{
- Q_D(QCommandLinkButton);
- setText(text);
setDescription(description);
- d->init();
}
/*!
diff --git a/src/widgets/widgets/qcommandlinkbutton.h b/src/widgets/widgets/qcommandlinkbutton.h
index c794b60506..4f81651ce4 100644
--- a/src/widgets/widgets/qcommandlinkbutton.h
+++ b/src/widgets/widgets/qcommandlinkbutton.h
@@ -40,6 +40,7 @@
#ifndef QCOMMANDLINKBUTTON_H
#define QCOMMANDLINKBUTTON_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qpushbutton.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qdatetimeedit.h b/src/widgets/widgets/qdatetimeedit.h
index f050061dea..c261ce369b 100644
--- a/src/widgets/widgets/qdatetimeedit.h
+++ b/src/widgets/widgets/qdatetimeedit.h
@@ -40,6 +40,7 @@
#ifndef QDATETIMEEDIT_H
#define QDATETIMEEDIT_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtCore/qdatetime.h>
#include <QtCore/qvariant.h>
#include <QtWidgets/qabstractspinbox.h>
diff --git a/src/widgets/widgets/qdatetimeedit_p.h b/src/widgets/widgets/qdatetimeedit_p.h
index be7bc213a2..6889bda041 100644
--- a/src/widgets/widgets/qdatetimeedit_p.h
+++ b/src/widgets/widgets/qdatetimeedit_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QtWidgets/qcombobox.h"
#include "QtWidgets/qcalendarwidget.h"
#include "QtWidgets/qspinbox.h"
diff --git a/src/widgets/widgets/qdial.h b/src/widgets/widgets/qdial.h
index 7884d9fe27..3629ebf8f6 100644
--- a/src/widgets/widgets/qdial.h
+++ b/src/widgets/widgets/qdial.h
@@ -41,6 +41,7 @@
#ifndef QDIAL_H
#define QDIAL_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qabstractslider.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp
index 4ed326576c..657eda3c68 100644
--- a/src/widgets/widgets/qdialogbuttonbox.cpp
+++ b/src/widgets/widgets/qdialogbuttonbox.cpp
@@ -462,9 +462,8 @@ void QDialogButtonBoxPrivate::retranslateStrings()
\sa orientation, addButton()
*/
QDialogButtonBox::QDialogButtonBox(QWidget *parent)
- : QWidget(*new QDialogButtonBoxPrivate(Qt::Horizontal), parent, 0)
+ : QDialogButtonBox(Qt::Horizontal, parent)
{
- d_func()->initLayout();
}
/*!
@@ -487,10 +486,8 @@ QDialogButtonBox::QDialogButtonBox(Qt::Orientation orientation, QWidget *parent)
\sa orientation, addButton()
*/
QDialogButtonBox::QDialogButtonBox(StandardButtons buttons, QWidget *parent)
- : QWidget(*new QDialogButtonBoxPrivate(Qt::Horizontal), parent, 0)
+ : QDialogButtonBox(buttons, Qt::Horizontal, parent)
{
- d_func()->initLayout();
- d_func()->createStandardButtons(buttons);
}
/*!
@@ -501,9 +498,8 @@ QDialogButtonBox::QDialogButtonBox(StandardButtons buttons, QWidget *parent)
*/
QDialogButtonBox::QDialogButtonBox(StandardButtons buttons, Qt::Orientation orientation,
QWidget *parent)
- : QWidget(*new QDialogButtonBoxPrivate(orientation), parent, 0)
+ : QDialogButtonBox(orientation, parent)
{
- d_func()->initLayout();
d_func()->createStandardButtons(buttons);
}
diff --git a/src/widgets/widgets/qdialogbuttonbox.h b/src/widgets/widgets/qdialogbuttonbox.h
index dfec453c67..699547c32f 100644
--- a/src/widgets/widgets/qdialogbuttonbox.h
+++ b/src/widgets/widgets/qdialogbuttonbox.h
@@ -40,6 +40,7 @@
#ifndef QDIALOGBUTTONBOX_H
#define QDIALOGBUTTONBOX_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index fd155bf156..b347e93807 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -1493,8 +1493,10 @@ bool QDockAreaLayoutInfo::hasFixedSize() const
return perp(o, minimumSize()) == perp(o, maximumSize());
}
-
-void QDockAreaLayoutInfo::apply(bool animate)
+/*! \internal
+ Applies the layout and returns the activated QDockWidget or nullptr.
+ */
+QDockWidget *QDockAreaLayoutInfo::apply(bool animate)
{
QWidgetAnimator &widgetAnimator = mainWindowLayout()->widgetAnimator;
@@ -1533,6 +1535,8 @@ void QDockAreaLayoutInfo::apply(bool animate)
}
#endif // QT_NO_TABBAR
+ QDockWidget *activated = nullptr;
+
for (int i = 0; i < item_list.size(); ++i) {
QDockAreaLayoutItem &item = item_list[i];
@@ -1561,6 +1565,7 @@ void QDockAreaLayoutInfo::apply(bool animate)
} else if (r.isValid()
&& (geo.right() < 0 || geo.bottom() < 0)) {
emit dw->visibilityChanged(true);
+ activated = dw;
}
}
}
@@ -1568,6 +1573,8 @@ void QDockAreaLayoutInfo::apply(bool animate)
if (*sep == 1)
updateSeparatorWidgets();
#endif //QT_NO_TABBAR
+
+ return activated;
}
static void paintSep(QPainter *p, QWidget *w, const QRect &r, Qt::Orientation o, bool mouse_over)
diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h
index 0ae1350394..aa6e4232e0 100644
--- a/src/widgets/widgets/qdockarealayout_p.h
+++ b/src/widgets/widgets/qdockarealayout_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QtCore/qrect.h"
#include "QtCore/qpair.h"
#include "QtCore/qlist.h"
@@ -174,7 +175,7 @@ public:
QList<int> indexOf(QWidget *widget) const;
QList<int> indexOfPlaceHolder(const QString &objectName) const;
- void apply(bool animate);
+ QDockWidget *apply(bool animate);
void paintSeparators(QPainter *p, QWidget *widget, const QRegion &clip,
const QPoint &mouse) const;
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index d664727d89..9e95d086bd 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -230,7 +230,7 @@ bool QDockWidgetLayout::nativeWindowDeco() const
*/
bool QDockWidgetLayout::wmSupportsNativeWindowDeco()
{
-#if defined(Q_OS_WINCE) || defined(Q_OS_ANDROID)
+#if defined(Q_OS_ANDROID)
return false;
#else
static const bool xcb = !QGuiApplication::platformName().compare(QLatin1String("xcb"), Qt::CaseInsensitive);
@@ -1225,10 +1225,8 @@ QDockWidget::QDockWidget(QWidget *parent, Qt::WindowFlags flags)
\sa setWindowTitle()
*/
QDockWidget::QDockWidget(const QString &title, QWidget *parent, Qt::WindowFlags flags)
- : QWidget(*new QDockWidgetPrivate, parent, flags)
+ : QDockWidget(parent, flags)
{
- Q_D(QDockWidget);
- d->init();
setWindowTitle(title);
}
diff --git a/src/widgets/widgets/qdockwidget.h b/src/widgets/widgets/qdockwidget.h
index e0aaf54d0e..7b3f8d0ddb 100644
--- a/src/widgets/widgets/qdockwidget.h
+++ b/src/widgets/widgets/qdockwidget.h
@@ -40,6 +40,7 @@
#ifndef QDYNAMICDOCKWIDGET_H
#define QDYNAMICDOCKWIDGET_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qdockwidget_p.h b/src/widgets/widgets/qdockwidget_p.h
index 765747b101..94a3ad3b34 100644
--- a/src/widgets/widgets/qdockwidget_p.h
+++ b/src/widgets/widgets/qdockwidget_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QtWidgets/qstyleoption.h"
#include "private/qwidget_p.h"
#include "QtWidgets/qboxlayout.h"
diff --git a/src/widgets/widgets/qeffects.cpp b/src/widgets/widgets/qeffects.cpp
index a2ba50695a..b02651767c 100644
--- a/src/widgets/widgets/qeffects.cpp
+++ b/src/widgets/widgets/qeffects.cpp
@@ -110,7 +110,7 @@ QAlphaWidget::QAlphaWidget(QWidget* w, Qt::WindowFlags f)
QAlphaWidget::~QAlphaWidget()
{
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
// Restore user-defined opacity value
if (widget)
widget->setWindowOpacity(1);
@@ -144,7 +144,7 @@ void QAlphaWidget::run(int time)
checkTime.start();
showWidget = true;
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
qApp->installEventFilter(this);
widget->setWindowOpacity(0.0);
widget->show();
@@ -251,7 +251,7 @@ void QAlphaWidget::render()
else
alpha = 1;
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN)
if (alpha >= 1 || !showWidget) {
anim.stop();
qApp->removeEventFilter(this);
@@ -268,10 +268,6 @@ void QAlphaWidget::render()
if (widget) {
if (!showWidget) {
-#ifdef Q_OS_WIN
- setEnabled(true);
- setFocus();
-#endif // Q_OS_WIN
widget->hide();
} else {
//Since we are faking the visibility of the widget
@@ -288,7 +284,7 @@ void QAlphaWidget::render()
pm = QPixmap::fromImage(mixedImage);
repaint();
}
-#endif // defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#endif // defined(Q_OS_WIN)
}
/*
diff --git a/src/widgets/widgets/qfocusframe.h b/src/widgets/widgets/qfocusframe.h
index a1b2032e05..a1fc6d345d 100644
--- a/src/widgets/widgets/qfocusframe.h
+++ b/src/widgets/widgets/qfocusframe.h
@@ -40,6 +40,7 @@
#ifndef QFOCUSFRAME_H
#define QFOCUSFRAME_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qfontcombobox.h b/src/widgets/widgets/qfontcombobox.h
index 0db077cd87..c409d33fef 100644
--- a/src/widgets/widgets/qfontcombobox.h
+++ b/src/widgets/widgets/qfontcombobox.h
@@ -40,6 +40,7 @@
#ifndef QFONTCOMBOBOX_H
#define QFONTCOMBOBOX_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qcombobox.h>
#include <QtGui/qfontdatabase.h>
diff --git a/src/widgets/widgets/qframe.h b/src/widgets/widgets/qframe.h
index e38ec60d42..986915a28f 100644
--- a/src/widgets/widgets/qframe.h
+++ b/src/widgets/widgets/qframe.h
@@ -40,6 +40,7 @@
#ifndef QFRAME_H
#define QFRAME_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qframe_p.h b/src/widgets/widgets/qframe_p.h
index 54d2ba869d..e3c101e87c 100644
--- a/src/widgets/widgets/qframe_p.h
+++ b/src/widgets/widgets/qframe_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qwidget_p.h"
#include "qframe.h"
diff --git a/src/widgets/widgets/qgroupbox.cpp b/src/widgets/widgets/qgroupbox.cpp
index 5bdd6f20e6..a9b32ae065 100644
--- a/src/widgets/widgets/qgroupbox.cpp
+++ b/src/widgets/widgets/qgroupbox.cpp
@@ -194,10 +194,8 @@ QGroupBox::QGroupBox(QWidget *parent)
*/
QGroupBox::QGroupBox(const QString &title, QWidget *parent)
- : QWidget(*new QGroupBoxPrivate, parent, 0)
+ : QGroupBox(parent)
{
- Q_D(QGroupBox);
- d->init();
setTitle(title);
}
diff --git a/src/widgets/widgets/qgroupbox.h b/src/widgets/widgets/qgroupbox.h
index 0bff3aa6f9..a132d48e16 100644
--- a/src/widgets/widgets/qgroupbox.h
+++ b/src/widgets/widgets/qgroupbox.h
@@ -40,6 +40,7 @@
#ifndef QGROUPBOX_H
#define QGROUPBOX_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qframe.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp
index f8a3be366e..2fbc42330d 100644
--- a/src/widgets/widgets/qkeysequenceedit.cpp
+++ b/src/widgets/widgets/qkeysequenceedit.cpp
@@ -138,21 +138,17 @@ void QKeySequenceEditPrivate::finishEditing()
/*!
Constructs a QKeySequenceEdit widget with the given \a parent.
*/
-QKeySequenceEdit::QKeySequenceEdit(QWidget *parent) :
- QWidget(*new QKeySequenceEditPrivate, parent, 0)
+QKeySequenceEdit::QKeySequenceEdit(QWidget *parent)
+ : QKeySequenceEdit(*new QKeySequenceEditPrivate, parent, 0)
{
- Q_D(QKeySequenceEdit);
- d->init();
}
/*!
Constructs a QKeySequenceEdit widget with the given \a keySequence and \a parent.
*/
-QKeySequenceEdit::QKeySequenceEdit(const QKeySequence &keySequence, QWidget *parent) :
- QWidget(*new QKeySequenceEditPrivate, parent, 0)
+QKeySequenceEdit::QKeySequenceEdit(const QKeySequence &keySequence, QWidget *parent)
+ : QKeySequenceEdit(parent)
{
- Q_D(QKeySequenceEdit);
- d->init();
setKeySequence(keySequence);
}
diff --git a/src/widgets/widgets/qkeysequenceedit.h b/src/widgets/widgets/qkeysequenceedit.h
index 85a2177d32..81339a9852 100644
--- a/src/widgets/widgets/qkeysequenceedit.h
+++ b/src/widgets/widgets/qkeysequenceedit.h
@@ -41,6 +41,7 @@
#ifndef QKEYSEQUENCEEDIT_H
#define QKEYSEQUENCEEDIT_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qkeysequenceedit_p.h b/src/widgets/widgets/qkeysequenceedit_p.h
index a85530645c..67e60b4032 100644
--- a/src/widgets/widgets/qkeysequenceedit_p.h
+++ b/src/widgets/widgets/qkeysequenceedit_p.h
@@ -52,6 +52,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qkeysequenceedit.h"
#include <private/qwidget_p.h>
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp
index 5db1013fd2..76713d9880 100644
--- a/src/widgets/widgets/qlabel.cpp
+++ b/src/widgets/widgets/qlabel.cpp
@@ -233,10 +233,8 @@ QLabel::QLabel(QWidget *parent, Qt::WindowFlags f)
\sa setText(), setAlignment(), setFrameStyle(), setIndent()
*/
QLabel::QLabel(const QString &text, QWidget *parent, Qt::WindowFlags f)
- : QFrame(*new QLabelPrivate(), parent, f)
+ : QLabel(parent, f)
{
- Q_D(QLabel);
- d->init();
setText(text);
}
diff --git a/src/widgets/widgets/qlabel.h b/src/widgets/widgets/qlabel.h
index 46a2ce8ee4..1f76937a63 100644
--- a/src/widgets/widgets/qlabel.h
+++ b/src/widgets/widgets/qlabel.h
@@ -40,6 +40,7 @@
#ifndef QLABEL_H
#define QLABEL_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qframe.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qlabel_p.h b/src/widgets/widgets/qlabel_p.h
index dce9ba7168..d13c05fc99 100644
--- a/src/widgets/widgets/qlabel_p.h
+++ b/src/widgets/widgets/qlabel_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qlabel.h"
#include "private/qtextdocumentlayout_p.h"
diff --git a/src/widgets/widgets/qlcdnumber.cpp b/src/widgets/widgets/qlcdnumber.cpp
index 543a7aee11..2703e5d8a3 100644
--- a/src/widgets/widgets/qlcdnumber.cpp
+++ b/src/widgets/widgets/qlcdnumber.cpp
@@ -338,11 +338,8 @@ static const char *getSegments(char ch) // gets list of segments f
*/
QLCDNumber::QLCDNumber(QWidget *parent)
- : QFrame(*new QLCDNumberPrivate, parent)
+ : QLCDNumber(5, parent)
{
- Q_D(QLCDNumber);
- d->ndigits = 5;
- d->init();
}
diff --git a/src/widgets/widgets/qlcdnumber.h b/src/widgets/widgets/qlcdnumber.h
index 1169862193..33669fa900 100644
--- a/src/widgets/widgets/qlcdnumber.h
+++ b/src/widgets/widgets/qlcdnumber.h
@@ -40,6 +40,7 @@
#ifndef QLCDNUMBER_H
#define QLCDNUMBER_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qframe.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index 56965923b7..2bc715724d 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -260,10 +260,8 @@ void QLineEdit::initStyleOption(QStyleOptionFrame *option) const
\sa setText(), setMaxLength()
*/
QLineEdit::QLineEdit(QWidget* parent)
- : QWidget(*new QLineEditPrivate, parent,0)
+ : QLineEdit(QString(), parent)
{
- Q_D(QLineEdit);
- d->init(QString());
}
/*!
@@ -1911,13 +1909,19 @@ void QLineEdit::paintEvent(QPaintEvent *)
if (d->shouldShowPlaceholderText()) {
if (!d->placeholderText.isEmpty()) {
+ const Qt::LayoutDirection layoutDir = d->placeholderText.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight;
+ const Qt::Alignment alignPhText = QStyle::visualAlignment(layoutDir, QFlag(d->alignment));
QColor col = pal.text().color();
col.setAlpha(128);
QPen oldpen = p.pen();
p.setPen(col);
- QString elidedText = fm.elidedText(d->placeholderText, Qt::ElideRight, lineRect.width());
- p.drawText(lineRect, va, elidedText);
+ Qt::LayoutDirection oldLayoutDir = p.layoutDirection();
+ p.setLayoutDirection(layoutDir);
+
+ const QString elidedText = fm.elidedText(d->placeholderText, Qt::ElideRight, lineRect.width());
+ p.drawText(lineRect, alignPhText, elidedText);
p.setPen(oldpen);
+ p.setLayoutDirection(oldLayoutDir);
}
}
diff --git a/src/widgets/widgets/qlineedit.h b/src/widgets/widgets/qlineedit.h
index 12fd998c45..1bdcfaf848 100644
--- a/src/widgets/widgets/qlineedit.h
+++ b/src/widgets/widgets/qlineedit.h
@@ -40,6 +40,7 @@
#ifndef QLINEEDIT_H
#define QLINEEDIT_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qframe.h>
#include <QtGui/qtextcursor.h>
#include <QtCore/qstring.h>
diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h
index a14cd66398..0a08aefab3 100644
--- a/src/widgets/widgets/qlineedit_p.h
+++ b/src/widgets/widgets/qlineedit_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include "QtCore/qglobal.h"
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#ifndef QT_NO_LINEEDIT
#include "private/qwidget_p.h"
diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.h b/src/widgets/widgets/qmaccocoaviewcontainer_mac.h
index c53cc643cd..d926ef8569 100644
--- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.h
+++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.h
@@ -40,6 +40,7 @@
#ifndef QCOCOAVIEWCONTAINER_H
#define QCOCOAVIEWCONTAINER_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/QWidget>
Q_FORWARD_DECLARE_OBJC_CLASS(NSView);
diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
index 3145ab1553..725cc637d6 100644
--- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
+++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
@@ -100,8 +100,9 @@ inline QPlatformNativeInterface::NativeResourceForIntegrationFunction resolvePla
QPlatformNativeInterface::NativeResourceForIntegrationFunction function =
nativeInterface->nativeResourceFunctionForIntegration(functionName);
if (Q_UNLIKELY(!function))
- qWarning() << "Qt could not resolve function" << functionName
- << "from QGuiApplication::platformNativeInterface()->nativeResourceFunctionForIntegration()";
+ qWarning("Qt could not resolve function %s from "
+ "QGuiApplication::platformNativeInterface()->nativeResourceFunctionForIntegration()",
+ functionName.constData());
return function;
}
} //namespsace
diff --git a/src/widgets/widgets/qmacnativewidget_mac.h b/src/widgets/widgets/qmacnativewidget_mac.h
index 559f15f287..44e793f174 100644
--- a/src/widgets/widgets/qmacnativewidget_mac.h
+++ b/src/widgets/widgets/qmacnativewidget_mac.h
@@ -40,6 +40,7 @@
#ifndef QMACNATIVEWIDGET_H
#define QMACNATIVEWIDGET_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/QWidget>
Q_FORWARD_DECLARE_OBJC_CLASS(NSView);
diff --git a/src/widgets/widgets/qmacnativewidget_mac.mm b/src/widgets/widgets/qmacnativewidget_mac.mm
index a8f1a3745d..936bd35187 100644
--- a/src/widgets/widgets/qmacnativewidget_mac.mm
+++ b/src/widgets/widgets/qmacnativewidget_mac.mm
@@ -89,8 +89,9 @@ inline QPlatformNativeInterface::NativeResourceForIntegrationFunction resolvePla
QPlatformNativeInterface::NativeResourceForIntegrationFunction function =
nativeInterface->nativeResourceFunctionForIntegration(functionName);
if (Q_UNLIKELY(!function))
- qWarning() << "Qt could not resolve function" << functionName
- << "from QGuiApplication::platformNativeInterface()->nativeResourceFunctionForIntegration()";
+ qWarning("Qt could not resolve function %s from "
+ "QGuiApplication::platformNativeInterface()->nativeResourceFunctionForIntegration()",
+ functionName.constData());
return function;
}
} //namespsace
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index 5f7cfec5af..2477510520 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -377,6 +377,18 @@ void QMainWindowPrivate::init()
\sa setToolButtonStyle()
*/
+#ifndef QT_NO_DOCKWIDGET
+/*!
+ \fn void QMainWindow::tabifiedDockWidgetActivated(QDockWidget *dockWidget)
+
+ This signal is emitted when the tabified dock widget is activated by
+ selecting the tab. The activated dock widget is passed in \a dockWidget.
+
+ \since 5.8
+ \sa tabifyDockWidget(), tabifiedDockWidgets()
+*/
+#endif
+
/*!
Constructs a QMainWindow with the given \a parent and the specified
widget \a flags.
diff --git a/src/widgets/widgets/qmainwindow.h b/src/widgets/widgets/qmainwindow.h
index aab1448b8f..9bd7eb1cd8 100644
--- a/src/widgets/widgets/qmainwindow.h
+++ b/src/widgets/widgets/qmainwindow.h
@@ -40,6 +40,7 @@
#ifndef QDYNAMICMAINWINDOW_H
#define QDYNAMICMAINWINDOW_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
#include <QtWidgets/qtabwidget.h>
@@ -195,6 +196,9 @@ public Q_SLOTS:
Q_SIGNALS:
void iconSizeChanged(const QSize &iconSize);
void toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle);
+#ifndef QT_NO_DOCKWIDGET
+ void tabifiedDockWidgetActivated(QDockWidget *dockWidget);
+#endif
protected:
#ifndef QT_NO_CONTEXTMENU
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index b2c7225e8a..c5b08387a3 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -1686,7 +1686,11 @@ void QMainWindowLayout::tabChanged()
QDockAreaLayoutInfo *info = dockInfo(tb);
if (info == 0)
return;
- info->apply(false);
+
+ QDockWidget *activated = info->apply(false);
+
+ if (activated)
+ emit static_cast<QMainWindow *>(parentWidget())->tabifiedDockWidgetActivated(activated);
if (QWidget *w = centralWidget())
w->raise();
diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h
index 4c61374d83..7f35f78111 100644
--- a/src/widgets/widgets/qmainwindowlayout_p.h
+++ b/src/widgets/widgets/qmainwindowlayout_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qmainwindow.h"
#ifndef QT_NO_MAINWINDOW
diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp
index b42ebe7e48..5f3aff5e10 100644
--- a/src/widgets/widgets/qmdiarea.cpp
+++ b/src/widgets/widgets/qmdiarea.cpp
@@ -2670,9 +2670,8 @@ void QMdiArea::paintEvent(QPaintEvent *paintEvent)
{
Q_D(QMdiArea);
QPainter painter(d->viewport);
- const QVector<QRect> &exposedRects = paintEvent->region().rects();
- for (int i = 0; i < exposedRects.size(); ++i)
- painter.fillRect(exposedRects.at(i), d->background);
+ for (const QRect &exposedRect : paintEvent->region())
+ painter.fillRect(exposedRect, d->background);
}
/*!
diff --git a/src/widgets/widgets/qmdiarea.h b/src/widgets/widgets/qmdiarea.h
index b093c4bb4b..44a40948af 100644
--- a/src/widgets/widgets/qmdiarea.h
+++ b/src/widgets/widgets/qmdiarea.h
@@ -40,6 +40,7 @@
#ifndef QMDIAREA_H
#define QMDIAREA_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qabstractscrollarea.h>
#include <QtWidgets/qtabwidget.h>
diff --git a/src/widgets/widgets/qmdiarea_p.h b/src/widgets/widgets/qmdiarea_p.h
index dde7b1a7ce..353144a6ab 100644
--- a/src/widgets/widgets/qmdiarea_p.h
+++ b/src/widgets/widgets/qmdiarea_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qmdiarea.h"
#include "qmdisubwindow.h"
diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp
index 610cb1201f..afe87c6af9 100644
--- a/src/widgets/widgets/qmdisubwindow.cpp
+++ b/src/widgets/widgets/qmdisubwindow.cpp
@@ -412,6 +412,10 @@ bool ControlLabel::event(QEvent *event)
{
if (event->type() == QEvent::WindowIconChange)
updateWindowIcon();
+ else if (event->type() == QEvent::StyleChange) {
+ updateWindowIcon();
+ setFixedSize(label.size());
+ }
#ifndef QT_NO_TOOLTIP
else if (event->type() == QEvent::ToolTip) {
QStyleOptionTitleBar options;
@@ -480,7 +484,8 @@ void ControlLabel::updateWindowIcon()
QIcon menuIcon = windowIcon();
if (menuIcon.isNull())
menuIcon = style()->standardIcon(QStyle::SP_TitleBarMenuButton, 0, parentWidget());
- label = menuIcon.pixmap(16, 16);
+ const int iconSize = style()->pixelMetric(QStyle::PM_TitleBarButtonIconSize, 0, parentWidget());
+ label = menuIcon.pixmap(iconSize);
update();
}
@@ -556,7 +561,8 @@ QSize ControllerWidget::sizeHint() const
ensurePolished();
QStyleOptionComplex opt;
initStyleOption(&opt);
- QSize size(48, 16);
+ const int buttonSize = style()->pixelMetric(QStyle::PM_TitleBarButtonSize, &opt, mdiArea);
+ QSize size(3 * buttonSize, buttonSize);
return style()->sizeFromContents(QStyle::CT_MdiControls, &opt, size, mdiArea);
}
@@ -1769,7 +1775,7 @@ bool QMdiSubWindowPrivate::drawTitleBarWhenMaximized() const
if (isChildOfTabbedQMdiArea(q))
return false;
-#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC) || defined(Q_OS_WINCE_WM)
+#if defined(Q_OS_DARWIN) && !defined(QT_NO_STYLE_MAC)
Q_UNUSED(isChildOfQMdiSubWindow);
return true;
#else
diff --git a/src/widgets/widgets/qmdisubwindow.h b/src/widgets/widgets/qmdisubwindow.h
index 54ef33befa..e2bb533ddf 100644
--- a/src/widgets/widgets/qmdisubwindow.h
+++ b/src/widgets/widgets/qmdisubwindow.h
@@ -40,6 +40,7 @@
#ifndef QMDISUBWINDOW_H
#define QMDISUBWINDOW_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qmdisubwindow_p.h b/src/widgets/widgets/qmdisubwindow_p.h
index 4faf421a92..46a8e99d0a 100644
--- a/src/widgets/widgets/qmdisubwindow_p.h
+++ b/src/widgets/widgets/qmdisubwindow_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qmdisubwindow.h"
#ifndef QT_NO_MDIAREA
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 1d5432c206..e2271f3d62 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -1481,10 +1481,9 @@ QMenu::QMenu(QWidget *parent)
\sa title
*/
QMenu::QMenu(const QString &title, QWidget *parent)
- : QWidget(*new QMenuPrivate, parent, Qt::Popup)
+ : QMenu(parent)
{
Q_D(QMenu);
- d->init();
d->menuAction->setText(title);
}
@@ -3358,17 +3357,6 @@ void QMenu::actionEvent(QActionEvent *e)
d->platformMenu->syncSeparatorsCollapsible(d->collapsibleSeparators);
}
-#if defined(Q_OS_WINCE) && !defined(QT_NO_MENUBAR)
- if (!d->wce_menu)
- d->wce_menu = new QMenuPrivate::QWceMenuPrivate;
- if (e->type() == QEvent::ActionAdded)
- d->wce_menu->addAction(e->action(), d->wce_menu->findAction(e->before()));
- else if (e->type() == QEvent::ActionRemoved)
- d->wce_menu->removeAction(e->action());
- else if (e->type() == QEvent::ActionChanged)
- d->wce_menu->syncAction(e->action());
-#endif
-
if (isVisible()) {
d->updateActionRects();
resize(sizeHint());
diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h
index 7dda38456a..bcbd0a95c4 100644
--- a/src/widgets/widgets/qmenu.h
+++ b/src/widgets/widgets/qmenu.h
@@ -40,14 +40,12 @@
#ifndef QMENU_H
#define QMENU_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
#include <QtCore/qstring.h>
#include <QtGui/qicon.h>
#include <QtWidgets/qaction.h>
-#ifdef Q_OS_WINCE
-#include <windef.h> // for HMENU
-#endif
#ifdef Q_OS_OSX
Q_FORWARD_DECLARE_OBJC_CLASS(NSMenu);
#endif
@@ -85,11 +83,17 @@ public:
QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0);
#ifdef Q_QDOC
+ template<typename PointerToMemberFunction>
QAction *addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0);
+ template<typename Functor>
QAction *addAction(const QString &text, Functor functor, const QKeySequence &shortcut = 0);
+ template<typename Functor>
QAction *addAction(const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut = 0);
+ template<typename PointerToMemberFunction>
QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0);
+ template<typename Functor>
QAction *addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut = 0);
+ template<typename Functor>
QAction *addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut = 0);
#else
// addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
@@ -208,9 +212,6 @@ public:
QPlatformMenu *platformMenu();
void setPlatformMenu(QPlatformMenu *platformMenu);
-#ifdef Q_OS_WINCE
- HMENU wceMenu();
-#endif
#ifdef Q_OS_OSX
NSMenu* toNSMenu();
void setAsDockMenu();
@@ -249,10 +250,6 @@ protected:
bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE;
void initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const;
-#ifdef Q_OS_WINCE
- QAction* wceCommands(uint command);
-#endif
-
private Q_SLOTS:
void internalDelayedPopup();
diff --git a/src/widgets/widgets/qmenu_mac.mm b/src/widgets/widgets/qmenu_mac.mm
index 82379c6509..fef1eb2cf4 100644
--- a/src/widgets/widgets/qmenu_mac.mm
+++ b/src/widgets/widgets/qmenu_mac.mm
@@ -62,8 +62,9 @@ inline QPlatformNativeInterface::NativeResourceForIntegrationFunction resolvePla
QPlatformNativeInterface::NativeResourceForIntegrationFunction function =
nativeInterface->nativeResourceFunctionForIntegration(functionName);
if (Q_UNLIKELY(!function))
- qWarning() << "Qt could not resolve function" << functionName
- << "from QGuiApplication::platformNativeInterface()->nativeResourceFunctionForIntegration()";
+ qWarning("Qt could not resolve function %s from "
+ "QGuiApplication::platformNativeInterface()->nativeResourceFunctionForIntegration()",
+ functionName.constData());
return function;
}
} //namespsace
diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h
index 0705cd12ea..dbc0958f03 100644
--- a/src/widgets/widgets/qmenu_p.h
+++ b/src/widgets/widgets/qmenu_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QtWidgets/qmenubar.h"
#include "QtWidgets/qstyleoption.h"
#include "QtCore/qdatetime.h"
@@ -68,15 +69,6 @@ QT_BEGIN_NAMESPACE
class QTornOffMenu;
class QEventLoop;
-#ifdef Q_OS_WINCE
-struct QWceMenuAction {
- uint command;
- QPointer<QAction> action;
- HMENU menuHandle;
- QWceMenuAction() : menuHandle(0), command(0) {}
-};
-#endif
-
template <typename T>
class QSetValueOnDestroy
{
@@ -301,19 +293,13 @@ public:
#endif
scroll(0), eventLoop(0), tearoff(0), tornoff(0), tearoffHighlighted(0),
hasCheckableItems(0), doChildEffects(false), platformMenu(0)
-
-#if defined(Q_OS_WINCE) && !defined(QT_NO_MENUBAR)
- ,wce_menu(0)
-#endif
{ }
+
~QMenuPrivate()
{
delete scroll;
if (!platformMenu.isNull() && !platformMenu->parent())
delete platformMenu.data();
-#if defined(Q_OS_WINCE) && !defined(QT_NO_MENUBAR)
- delete wce_menu;
-#endif
}
void init();
void setPlatformMenu(QPlatformMenu *menu);
@@ -473,31 +459,6 @@ public:
QPointer<QAction> actionAboutToTrigger;
-#if defined(Q_OS_WINCE) && !defined(QT_NO_MENUBAR)
- struct QWceMenuPrivate {
- QList<QWceMenuAction*> actionItems;
- HMENU menuHandle;
- QWceMenuPrivate();
- ~QWceMenuPrivate();
- void addAction(QAction *, QWceMenuAction* =0);
- void addAction(QWceMenuAction *, QWceMenuAction* =0);
- void syncAction(QWceMenuAction *);
- inline void syncAction(QAction *a) { syncAction(findAction(a)); }
- void removeAction(QWceMenuAction *);
- void rebuild();
- inline void removeAction(QAction *a) { removeAction(findAction(a)); }
- inline QWceMenuAction *findAction(QAction *a) {
- for(int i = 0; i < actionItems.size(); i++) {
- QWceMenuAction *act = actionItems[i];
- if(a == act->action)
- return act;
- }
- return 0;
- }
- } *wce_menu;
- HMENU wceMenu();
- QAction* wceCommands(uint command);
-#endif
QPointer<QWidget> noReplayFor;
static QPointer<QMenu> previousMouseMenu;
};
diff --git a/src/widgets/widgets/qmenu_wince.cpp b/src/widgets/widgets/qmenu_wince.cpp
deleted file mode 100644
index d7397746fc..0000000000
--- a/src/widgets/widgets/qmenu_wince.cpp
+++ /dev/null
@@ -1,666 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//Native menubars are only supported for Windows Mobile not the standard SDK/generic WinCE
-#ifdef Q_OS_WINCE
-#include "qmenu.h"
-#include "qt_windows.h"
-#include "qapplication.h"
-#include "qmainwindow.h"
-#include "qtoolbar.h"
-#include "qevent.h"
-#include "qstyle.h"
-#include "qdebug.h"
-#include "qwidgetaction.h"
-#include <private/qapplication_p.h>
-#include <private/qmenu_p.h>
-#include <private/qmenubar_p.h>
-
-#include "qmenu_wince_resource_p.h"
-
-#include <QtCore/qlibrary.h>
-#include <commctrl.h>
-#if Q_OS_WINCE_WM
-# include <windowsm.h>
-#endif
-
-#ifndef QT_NO_MENUBAR
-
-#ifndef SHCMBF_EMPTYBAR
-#define SHCMBF_EMPTYBAR 0x0001
-#endif
-
-#ifndef SHCMBM_GETSUBMENU
-#define SHCMBM_GETSUBMENU (WM_USER + 401)
-#endif
-
-#ifdef Q_OS_WINCE_WM
-# define SHMBOF_NODEFAULT 0x00000001
-# define SHMBOF_NOTIFY 0x00000002
-# define SHCMBM_OVERRIDEKEY (WM_USER + 0x193)
-#endif
-
-extern bool qt_wince_is_smartphone();//defined in qguifunctions_wce.cpp
-extern bool qt_wince_is_pocket_pc(); //defined in qguifunctions_wce.cpp
-
-QT_BEGIN_NAMESPACE
-
-static uint qt_wce_menu_static_cmd_id = 200;
-static QList<QMenuBar*> nativeMenuBars;
-
-struct qt_SHMENUBARINFO
-{
- DWORD cbSize;
- HWND hwndParent;
- DWORD dwFlags;
- UINT nToolBarId;
- HINSTANCE hInstRes;
- int nBmpId;
- int cBmpImages;
- HWND hwndMB;
- COLORREF clrBk;
-};
-
-typedef BOOL (WINAPI *AygCreateMenuBar)(qt_SHMENUBARINFO*);
-typedef HRESULT (WINAPI *AygEnableSoftKey)(HWND,UINT,BOOL,BOOL);
-
-static bool aygResolved = false;
-static AygCreateMenuBar ptrCreateMenuBar = 0;
-static AygEnableSoftKey ptrEnableSoftKey = 0;
-
-static void resolveAygLibs()
-{
- if (!aygResolved) {
- aygResolved = true;
- QLibrary aygLib(QLatin1String("aygshell"));
- ptrCreateMenuBar = (AygCreateMenuBar) aygLib.resolve("SHCreateMenuBar");
- ptrEnableSoftKey = (AygEnableSoftKey) aygLib.resolve("SHEnableSoftkey");
- }
-}
-
-static void qt_wce_enable_soft_key(HWND handle, uint command)
-{
- resolveAygLibs();
- if (ptrEnableSoftKey)
- ptrEnableSoftKey(handle, command, false, true);
-}
-
-static void qt_wce_disable_soft_key(HWND handle, uint command)
-{
- resolveAygLibs();
- if (ptrEnableSoftKey)
- ptrEnableSoftKey(handle, command, false, false);
-}
-
-static void qt_wce_delete_action_list(QList<QWceMenuAction*> *list)
-{
- for(QList<QWceMenuAction*>::Iterator it = list->begin(); it != list->end(); ++it) {
- QWceMenuAction *action = (*it);
- delete action;
- action = 0;
- }
- list->clear();
-}
-
-//search for first QuitRole in QMenuBar
-static QAction* qt_wce_get_quit_action(QList<QAction *> actionItems)
-{
- QAction *returnAction = 0;
- for (int i = 0; i < actionItems.size(); ++i) {
- QAction *action = actionItems.at(i);
- if (action->menuRole() == QAction::QuitRole)
- returnAction = action;
- else
- if (action->menu())
- returnAction = qt_wce_get_quit_action(action->menu()->actions());
- if (returnAction)
- return returnAction; //return first action found
- }
- return 0; //nothing found;
-}
-
-static QAction* qt_wce_get_quit_action(QList<QWceMenuAction*> actionItems)
-{
- for (int i = 0; i < actionItems.size(); ++i) {
- if (actionItems.at(i)->action->menuRole() == QAction::QuitRole)
- return actionItems.at(i)->action;
- else if (actionItems.at(i)->action->menu()) {
- QAction *returnAction = qt_wce_get_quit_action(actionItems.at(i)->action->menu()->actions());
- if (returnAction)
- return returnAction;
- }
- }
- return 0;
-}
-
-static HMODULE qt_wce_get_module_handle()
-{
- HMODULE module = 0; //handle to resources
- if (!(module = GetModuleHandle(L"QtGui4"))) //release dynamic
- if (!(module = GetModuleHandle(L"QtGuid4"))) //debug dynamic
- module = (HINSTANCE)qWinAppInst(); //static
- Q_ASSERT_X(module, "qt_wce_get_module_handle()", "cannot get handle to module?");
- return module;
-}
-
-static void qt_wce_change_command(HWND menuHandle, int item, int command)
-{
-TBBUTTONINFOA tbbi;
- memset(&tbbi,0,sizeof(tbbi));
- tbbi.cbSize = sizeof(tbbi);
- tbbi.dwMask = TBIF_COMMAND;
- tbbi.idCommand = command;
- SendMessage(menuHandle, TB_SETBUTTONINFO, item, (LPARAM)&tbbi);
-}
-
-static void qt_wce_rename_menu_item(HWND menuHandle, int item, const QString &newText)
-{
- TBBUTTONINFOA tbbi;
- memset(&tbbi,0,sizeof(tbbi));
- tbbi.cbSize = sizeof(tbbi);
- tbbi.dwMask = TBIF_TEXT;
- QString text = newText;
- text.remove(QChar::fromLatin1('&'));
- tbbi.pszText = (LPSTR) text.utf16();
- SendMessage(menuHandle, TB_SETBUTTONINFO, item, (LPARAM)&tbbi);
-}
-
-static HWND qt_wce_create_menubar(HWND parentHandle, HINSTANCE resourceHandle, int toolbarID, int flags = 0)
-{
- resolveAygLibs();
-
- if (ptrCreateMenuBar) {
- qt_SHMENUBARINFO mbi;
- memset(&mbi, 0, sizeof(qt_SHMENUBARINFO));
- mbi.cbSize = sizeof(qt_SHMENUBARINFO);
- mbi.hwndParent = parentHandle;
- mbi.hInstRes = resourceHandle;
- mbi.dwFlags = flags;
- mbi.nToolBarId = toolbarID;
-
- if (ptrCreateMenuBar(&mbi)) {
-#ifdef Q_OS_WINCE_WM
- // Tell the menu bar that we want to override hot key behaviour.
- LPARAM lparam = MAKELPARAM(SHMBOF_NODEFAULT | SHMBOF_NOTIFY,
- SHMBOF_NODEFAULT | SHMBOF_NOTIFY);
- SendMessage(mbi.hwndMB, SHCMBM_OVERRIDEKEY, VK_TBACK, lparam);
-#endif
- return mbi.hwndMB;
- }
- }
- return 0;
-}
-
-static void qt_wce_insert_action(HMENU menu, QWceMenuAction *action)
-{
- Q_ASSERT_X(menu, "AppendMenu", "menu is 0");
- if (action->action->isVisible()) {
- int flags;
- action->action->isEnabled() ? flags = MF_ENABLED : flags = MF_GRAYED;
-
- QString text = action->action->iconText();
- text.remove(QChar::fromLatin1('&'));
- if (action->action->isSeparator()) {
- AppendMenu (menu, MF_SEPARATOR , 0, 0);
- }
- else if (action->action->menu()) {
- text.remove(QChar::fromLatin1('&'));
- AppendMenu (menu, MF_STRING | flags | MF_POPUP,
- (UINT) action->action->menu()->wceMenu(), reinterpret_cast<const wchar_t *> (text.utf16()));
- }
- else {
- AppendMenu (menu, MF_STRING | flags, action->command, reinterpret_cast<const wchar_t *> (text.utf16()));
- }
- if (action->action->isCheckable())
- if (action->action->isChecked())
- CheckMenuItem(menu, action->command, MF_BYCOMMAND | MF_CHECKED);
- else
- CheckMenuItem(menu, action->command, MF_BYCOMMAND | MF_UNCHECKED);
- }
-}
-
-// Removes all items from the menu without destroying the handles.
-static void qt_wce_clear_menu(HMENU hMenu)
-{
- while (RemoveMenu(hMenu, 0, MF_BYPOSITION));
-}
-
-/*!
- \internal
-
- This function refreshes the native Windows CE menu.
-*/
-
-void QMenuBar::wceRefresh()
-{
- for (int i = 0; i < nativeMenuBars.size(); ++i)
- nativeMenuBars.at(i)->d_func()->wceRefresh();
-}
-
-void QMenuBarPrivate::wceRefresh()
-{
- DrawMenuBar(wce_menubar->menubarHandle);
-}
-
-/*!
- \internal
-
- This function sends native Windows CE commands to Qt menus.
-*/
-
-QAction* QMenu::wceCommands(uint command)
-{
- Q_D(QMenu);
- return d->wceCommands(command);
-}
-
-/*!
- \internal
-
- This function sends native Windows CE commands to Qt menu bars
- and all their child menus.
-*/
-
-void QMenuBar::wceCommands(uint command)
-{
- const HWND hwndActiveWindow = GetActiveWindow();
- for (int i = 0; i < nativeMenuBars.size(); ++i) {
- QMenuBarPrivate* nativeMenuBar = nativeMenuBars.at(i)->d_func();
- if (hwndActiveWindow == nativeMenuBar->wce_menubar->parentWindowHandle)
- nativeMenuBar->wceCommands(command);
- }
-}
-
-bool QMenuBarPrivate::wceEmitSignals(QList<QWceMenuAction*> actions, uint command)
-{
- QAction *foundAction = 0;
- for (int i = 0; i < actions.size(); ++i) {
- QWceMenuAction *action = actions.at(i);
- if (action->action->menu()) {
- foundAction = action->action->menu()->wceCommands(command);
- if (foundAction)
- break;
- }
- else if (action->command == command) {
- action->action->activate(QAction::Trigger);
- return true;
- }
- }
- if (foundAction) {
- emit q_func()->triggered(foundAction);
- return true;
- }
- return false;
-}
-
-void QMenuBarPrivate::wceCommands(uint command)
-{
- if (wceClassicMenu) {
- for (int i = 0; i < wce_menubar->actionItemsClassic.size(); ++i)
- wceEmitSignals(wce_menubar->actionItemsClassic.at(i), command);
- } else {
- if (wceEmitSignals(wce_menubar->actionItems, command)) {
- return;
- }
- else if (wce_menubar->leftButtonIsMenu) {//check if command is on the left quick button
- wceEmitSignals(wce_menubar->actionItemsLeftButton, command);
- }
- else if ((wce_menubar->leftButtonAction) && (command == wce_menubar->leftButtonCommand)) {
- emit q_func()->triggered(wce_menubar->leftButtonAction);
- wce_menubar->leftButtonAction->activate(QAction::Trigger);
- }
- }
-}
-
-QAction *QMenuPrivate::wceCommands(uint command)
-{
- QAction *foundAction = 0;
- for (int i = 0; i < wce_menu->actionItems.size(); ++i) {
- if (foundAction)
- break;
- QWceMenuAction *action = wce_menu->actionItems.at(i);
- if (action->action->menu()) {
- foundAction = action->action->menu()->d_func()->wceCommands(command);
- }
- else if (action->command == command) {
- activateAction(action->action, QAction::Trigger);
- return action->action;
- }
- }
- if (foundAction)
- emit q_func()->triggered(foundAction);
- return foundAction;
-}
-
-void QMenuBarPrivate::wceCreateMenuBar(QWidget *parent)
-{
- Q_Q(QMenuBar);
- wce_menubar = new QWceMenuBarPrivate(this);
-
- wce_menubar->parentWindowHandle = parent ? QApplicationPrivate::getHWNDForWidget(parent) :
- QApplicationPrivate::getHWNDForWidget(q);
- wce_menubar->leftButtonAction = defaultAction;
-
- wce_menubar->menubarHandle = qt_wce_create_menubar(wce_menubar->parentWindowHandle, (HINSTANCE)qWinAppInst(), 0, SHCMBF_EMPTYBAR);
- Q_ASSERT_X(wce_menubar->menubarHandle, "wceCreateMenuBar", "cannot create empty menu bar");
- DrawMenuBar(wce_menubar->menubarHandle);
- nativeMenuBars.append(q);
- wceClassicMenu = (!qt_wince_is_smartphone() && !qt_wince_is_pocket_pc());
-}
-
-void QMenuBarPrivate::wceDestroyMenuBar()
-{
- Q_Q(QMenuBar);
- int index = nativeMenuBars.indexOf(q);
- nativeMenuBars.removeAt(index);
- if (wce_menubar) {
- delete wce_menubar;
- wce_menubar = 0;
- }
-}
-
-QMenuBarPrivate::QWceMenuBarPrivate::QWceMenuBarPrivate(QMenuBarPrivate *menubar)
-: menubarHandle(0), menuHandle(0), leftButtonMenuHandle(0),
- leftButtonAction(0), leftButtonIsMenu(false), d(menubar)
-{
-}
-
-QMenuBarPrivate::QWceMenuBarPrivate::~QWceMenuBarPrivate()
-{
- if (menubarHandle)
- DestroyWindow(menubarHandle);
- qt_wce_delete_action_list(&actionItems);
- qt_wce_delete_action_list(&actionItemsLeftButton);
-
- for (int i=0; i<actionItemsClassic.size(); ++i)
- if (!actionItemsClassic.value(i).empty())
- qt_wce_delete_action_list(&actionItemsClassic[i]);
- actionItemsClassic.clear();
-
- menubarHandle = 0;
- menuHandle = 0;
- leftButtonMenuHandle = 0;
- leftButtonCommand = 0;
- QMenuBar::wceRefresh();
-}
-
-QMenuPrivate::QWceMenuPrivate::QWceMenuPrivate()
-: menuHandle(0)
-{
-}
-
-QMenuPrivate::QWceMenuPrivate::~QWceMenuPrivate()
-{
- qt_wce_delete_action_list(&actionItems);
- if (menuHandle)
- DestroyMenu(menuHandle);
-}
-
-void QMenuPrivate::QWceMenuPrivate::addAction(QAction *a, QWceMenuAction *before)
-{
- QWceMenuAction *action = new QWceMenuAction;
- action->action = a;
- action->command = qt_wce_menu_static_cmd_id++;
- addAction(action, before);
-}
-
-void QMenuPrivate::QWceMenuPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before)
-{
- if (!action)
- return;
- int before_index = actionItems.indexOf(before);
- if (before_index < 0) {
- before = 0;
- before_index = actionItems.size();
- }
- actionItems.insert(before_index, action);
- rebuild();
-}
-
-/*!
- \internal
-
- This function will return the HMENU used to create the native
- Windows CE menu bar bindings.
-*/
-
-HMENU QMenu::wceMenu()
-{
- return d_func()->wceMenu();
-}
-
-HMENU QMenuPrivate::wceMenu()
-{
- if (!wce_menu)
- wce_menu = new QWceMenuPrivate;
- if (!wce_menu->menuHandle)
- wce_menu->rebuild();
- return wce_menu->menuHandle;
-}
-
-void QMenuPrivate::QWceMenuPrivate::rebuild()
-{
- if (!menuHandle)
- menuHandle = CreatePopupMenu();
- else
- qt_wce_clear_menu(menuHandle);
-
- for (int i = 0; i < actionItems.size(); ++i) {
- QWceMenuAction *action = actionItems.at(i);
- action->menuHandle = menuHandle;
- qt_wce_insert_action(menuHandle, action);
- }
- QMenuBar::wceRefresh();
-}
-
-void QMenuPrivate::QWceMenuPrivate::syncAction(QWceMenuAction *)
-{
- rebuild();
-}
-
-void QMenuPrivate::QWceMenuPrivate::removeAction(QWceMenuAction *action)
-{
- actionItems.removeAll(action);
- delete action;
- rebuild();
-}
-
-void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QAction *a, QAction *before)
-{
- QWceMenuAction *action = new QWceMenuAction;
- action->action = a;
- action->command = qt_wce_menu_static_cmd_id++;
- addAction(action, findAction(before));
-}
-
-void QMenuBarPrivate::QWceMenuBarPrivate::addAction(QWceMenuAction *action, QWceMenuAction *before)
-{
- if (!action)
- return;
- int before_index = actionItems.indexOf(before);
- if (before_index < 0) {
- before = 0;
- before_index = actionItems.size();
- }
- actionItems.insert(before_index, action);
- rebuild();
-}
-
-void QMenuBarPrivate::QWceMenuBarPrivate::syncAction(QWceMenuAction*)
-{
- QMenuBar::wceRefresh();
- rebuild();
-}
-
-void QMenuBarPrivate::QWceMenuBarPrivate::removeAction(QWceMenuAction *action)
-{
- actionItems.removeAll(action);
- delete action;
- rebuild();
-}
-
-void QMenuBarPrivate::_q_updateDefaultAction()
-{
- if (wce_menubar)
- wce_menubar->rebuild();
-}
-
-void QMenuBarPrivate::QWceMenuBarPrivate::rebuild()
-{
- d->q_func()->resize(0,0);
- parentWindowHandle = d->q_func()->parentWidget() ? QApplicationPrivate::getHWNDForWidget(d->q_func()->parentWidget()) :
- QApplicationPrivate::getHWNDForWidget(d->q_func());
- if (d->wceClassicMenu) {
- QList<QAction*> actions = d->actions;
- int maxEntries;
- int resourceHandle;
- if (actions.size() < 5) {
- maxEntries = 4;
- resourceHandle = IDR_MAIN_MENU3;
- } else if (actions.size() < 7) {
- maxEntries = 6;
- resourceHandle = IDR_MAIN_MENU4;
- }
- else {
- maxEntries = 8;
- resourceHandle = IDR_MAIN_MENU5;
- }
- Q_ASSERT_X(menubarHandle, "rebuild !created", "menubar already deleted");
- qt_wce_clear_menu(menuHandle);
- DestroyWindow(menubarHandle);
- menubarHandle = qt_wce_create_menubar(parentWindowHandle, qt_wce_get_module_handle(), resourceHandle);
- Q_ASSERT_X(menubarHandle, "rebuild classic menu", "cannot create menubar from resource");
- DrawMenuBar(menubarHandle);
- QList<int> menu_ids;
- QList<int> item_ids;
- menu_ids << IDM_MENU1 << IDM_MENU2 << IDM_MENU3 << IDM_MENU4 << IDM_MENU5 << IDM_MENU6 << IDM_MENU7 << IDM_MENU8;
- item_ids << IDM_ITEM1 << IDM_ITEM2 << IDM_ITEM3 << IDM_ITEM4 << IDM_ITEM5 << IDM_ITEM6 << IDM_ITEM7 << IDM_ITEM8;
-
- for (int i = 0; i < actionItemsClassic.size(); ++i)
- if (!actionItemsClassic.value(i).empty())
- qt_wce_delete_action_list(&actionItemsClassic[i]);
- actionItemsClassic.clear();
-
- for (int i = 0; i < actions.size(); ++i) {
- qt_wce_rename_menu_item(menubarHandle, menu_ids.at(i), actions.at(i)->text());
- QList<QAction *> subActions = actions.at(i)->menu()->actions();
- HMENU subMenuHandle = (HMENU) SendMessage(menubarHandle, SHCMBM_GETSUBMENU,0 , menu_ids.at(i));
- DeleteMenu(subMenuHandle, item_ids.at(i), MF_BYCOMMAND);
- for (int c = 0; c < subActions.size(); ++c) {
- QList<QWceMenuAction*> list;
- actionItemsClassic.append(list);
- QWceMenuAction *action = new QWceMenuAction;
- action->action = subActions.at(c);
- action->command = qt_wce_menu_static_cmd_id++;
- action->menuHandle = subMenuHandle;
- actionItemsClassic.last().append(action);
- qt_wce_insert_action(subMenuHandle, action);
- }
- }
- for (int i = actions.size();i<maxEntries;++i) {
- qt_wce_rename_menu_item(menubarHandle, menu_ids.at(i), QString());
- qt_wce_disable_soft_key(menubarHandle, menu_ids.at(i));
- }
- } else {
- leftButtonAction = d->defaultAction;
- if (!leftButtonAction)
- leftButtonAction = qt_wce_get_quit_action(actionItems);
-
- leftButtonIsMenu = (leftButtonAction && leftButtonAction->menu());
- Q_ASSERT_X(menubarHandle, "rebuild !created", "menubar already deleted");
- qt_wce_clear_menu(menuHandle);
- DestroyWindow(menubarHandle);
- if (leftButtonIsMenu) {
- menubarHandle = qt_wce_create_menubar(parentWindowHandle, qt_wce_get_module_handle(), IDR_MAIN_MENU2);
- Q_ASSERT_X(menubarHandle, "rebuild !created left menubar", "cannot create menubar from resource");
- menuHandle = (HMENU) SendMessage(menubarHandle, SHCMBM_GETSUBMENU,0,IDM_MENU);
- Q_ASSERT_X(menuHandle, "rebuild !created", "IDM_MENU not found - invalid resource?");
- DeleteMenu(menuHandle, IDM_ABOUT, MF_BYCOMMAND);
- leftButtonMenuHandle = (HMENU) SendMessage(menubarHandle, SHCMBM_GETSUBMENU,0,IDM_LEFTMENU);
- Q_ASSERT_X(leftButtonMenuHandle, "rebuild !created", "IDM_LEFTMENU not found - invalid resource?");
- DeleteMenu(leftButtonMenuHandle, IDM_VIEW, MF_BYCOMMAND);
- } else {
- menubarHandle = qt_wce_create_menubar(parentWindowHandle, qt_wce_get_module_handle(), IDR_MAIN_MENU);
- Q_ASSERT_X(menubarHandle, "rebuild !created no left menubar", "cannot create menubar from resource");
- menuHandle = (HMENU) SendMessage(menubarHandle, SHCMBM_GETSUBMENU,0,IDM_MENU);
- Q_ASSERT_X(menuHandle, "rebuild !created", "IDM_MENU not found - invalid resource?");
- DeleteMenu(menuHandle, IDM_ABOUT, MF_BYCOMMAND);
- leftButtonMenuHandle = 0;
- leftButtonCommand = qt_wce_menu_static_cmd_id++;
- qt_wce_change_command(menubarHandle, IDM_EXIT, leftButtonCommand);
- }
-
- if (actionItems.size() == 0) {
- qt_wce_rename_menu_item(menubarHandle, IDM_MENU, QLatin1String(""));
- qt_wce_disable_soft_key(menubarHandle, IDM_MENU);
- }
- for (int i = 0; i < actionItems.size(); ++i) {
- QWceMenuAction *action = actionItems.at(i);
- action->menuHandle = menuHandle;
- qt_wce_insert_action(menuHandle, action);
- }
- if (!leftButtonIsMenu) {
- if (leftButtonAction) {
- qt_wce_rename_menu_item(menubarHandle, leftButtonCommand, leftButtonAction->text());
- qt_wce_enable_soft_key(menubarHandle, leftButtonCommand);
- } else {
- qt_wce_rename_menu_item(menubarHandle, leftButtonCommand, QLatin1String(""));
- qt_wce_disable_soft_key(menubarHandle, leftButtonCommand);
- }
- } else {
- qt_wce_rename_menu_item(menubarHandle, IDM_LEFTMENU, leftButtonAction->text());
- QList<QAction *> actions = leftButtonAction->menu()->actions();
- qt_wce_delete_action_list(&actionItemsLeftButton);
- for (int i=0; i<actions.size(); ++i) {
- QWceMenuAction *action = new QWceMenuAction;
- action->action = actions.at(i);
- action->command = qt_wce_menu_static_cmd_id++;
- action->menuHandle = leftButtonMenuHandle;
- actionItemsLeftButton.append(action);
- qt_wce_insert_action(leftButtonMenuHandle, action);
- }
- }
- }
- DrawMenuBar(menubarHandle);
-}
-
-QT_END_NAMESPACE
-
-#endif //QT_NO_MENUBAR
-#endif //Q_OS_WINCE
diff --git a/src/widgets/widgets/qmenu_wince.rc b/src/widgets/widgets/qmenu_wince.rc
deleted file mode 100644
index 0bcd32c7e5..0000000000
--- a/src/widgets/widgets/qmenu_wince.rc
+++ /dev/null
@@ -1,231 +0,0 @@
-#include "qmenu_wince_resource_p.h"
-
-#include <commctrl.h>
-#include "winuser.h"
-
-#if defined (_DEBUG) && defined(QT_SHARED)
-#include "Qt5Widgetsd_resource.rc"
-#elif defined(QT_SHARED)
-#include "Qt5Widgets_resource.rc"
-#endif
-
-#define DIALOGEX DIALOG DISCARDABLE
-#define SHMENUBAR RCDATA
-#define I_IMAGENONE (-2)
-#define NOMENU 0xFFFF
-
-IDR_MAIN_MENU MENU DISCARDABLE
-BEGIN
- POPUP "Menu"
- BEGIN
- MENUITEM "About", IDM_ABOUT
- END
-END
-
-IDR_MAIN_MENU2 MENU DISCARDABLE
-BEGIN
- POPUP "Menu"
- BEGIN
- MENUITEM "About", IDM_ABOUT
- END
- POPUP "Display"
- BEGIN
- MENUITEM "View", IDM_VIEW
- END
-END
-
-
-IDR_MAIN_MENU3 MENU DISCARDABLE
-BEGIN
- POPUP "Menu1"
- BEGIN
- MENUITEM "Item1", IDM_ITEM1
- END
- POPUP "Menu2"
- BEGIN
- MENUITEM "Item2", IDM_ITEM2
- END
- POPUP "Menu3"
- BEGIN
- MENUITEM "Item3", IDM_ITEM3
- END
- POPUP "Menu4"
- BEGIN
- MENUITEM "Item4", IDM_ITEM4
- END
-END
-
-IDR_MAIN_MENU4 MENU DISCARDABLE
-BEGIN
- POPUP "Menu1"
- BEGIN
- MENUITEM "Item1", IDM_ITEM1
- END
- POPUP "Menu2"
- BEGIN
- MENUITEM "Item2", IDM_ITEM2
- END
- POPUP "Menu3"
- BEGIN
- MENUITEM "Item3", IDM_ITEM3
- END
- POPUP "Menu4"
- BEGIN
- MENUITEM "Item4", IDM_ITEM4
- END
- POPUP "Menu5"
- BEGIN
- MENUITEM "Item5", IDM_ITEM5
- END
- POPUP "Menu6"
- BEGIN
- MENUITEM "Item6", IDM_ITEM6
- END
-END
-
-IDR_MAIN_MENU5 MENU DISCARDABLE
-BEGIN
- POPUP "Menu1"
- BEGIN
- MENUITEM "Item1", IDM_ITEM1
- END
- POPUP "Menu2"
- BEGIN
- MENUITEM "Item2", IDM_ITEM2
- END
- POPUP "Menu3"
- BEGIN
- MENUITEM "Item3", IDM_ITEM3
- END
- POPUP "Menu4"
- BEGIN
- MENUITEM "Item4", IDM_ITEM4
- END
- POPUP "Menu5"
- BEGIN
- MENUITEM "Item5", IDM_ITEM5
- END
- POPUP "Menu6"
- BEGIN
- MENUITEM "Item6", IDM_ITEM6
- END
- POPUP "Menu7"
- BEGIN
- MENUITEM "Item7", IDM_ITEM7
- END
- POPUP "Menu8"
- BEGIN
- MENUITEM "Item8", IDM_ITEM8
- END
-END
-
-STRINGTABLE
-BEGIN
- IDS_EXIT "Exit"
- IDS_MENU "Menu"
- IDS_LEFTMENU "Display"
- IDS_MENU1 "Menu__1"
- IDS_MENU2 "Menu__2"
- IDS_MENU3 "Menu__3"
- IDS_MENU4 "Menu__4"
- IDS_MENU5 "Menu__5"
- IDS_MENU6 "Menu__6"
- IDS_MENU7 "Menu__7"
- IDS_MENU8 "Menu__8"
-END
-
-IDR_MAIN_MENU SHMENUBAR DISCARDABLE
-BEGIN
- IDR_MAIN_MENU,
- 2,
-
- I_IMAGENONE, IDM_EXIT, TBSTATE_ENABLED, TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE,
- IDS_EXIT, 0, NOMENU,
-
- I_IMAGENONE, IDM_MENU, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
- IDS_MENU, 0, 0,
-END
-
-IDR_MAIN_MENU2 SHMENUBAR DISCARDABLE
-BEGIN
- IDR_MAIN_MENU2,
- 2,
-
- I_IMAGENONE, IDM_LEFTMENU, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
- IDS_LEFTMENU, 0, 1,
-
- I_IMAGENONE, IDM_MENU, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
- IDS_MENU, 0, 0,
-END
-
-IDR_MAIN_MENU3 SHMENUBAR DISCARDABLE
-BEGIN
- IDR_MAIN_MENU3,
- 4,
-
- I_IMAGENONE, IDM_MENU1, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
- IDS_MENU1, 0, 0,
-
- I_IMAGENONE, IDM_MENU2, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
- IDS_MENU2, 0, 1,
-
- I_IMAGENONE, IDM_MENU3, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
- IDS_MENU3, 0, 2,
-
- I_IMAGENONE, IDM_MENU4, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
- IDS_MENU4, 0, 3,
-END
-
-IDR_MAIN_MENU4 SHMENUBAR DISCARDABLE
-BEGIN
- IDR_MAIN_MENU4,
- 6,
-
- I_IMAGENONE, IDM_MENU1, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
- IDS_MENU1, 0, 0,
-
- I_IMAGENONE, IDM_MENU2, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
- IDS_MENU2, 0, 1,
-
- I_IMAGENONE, IDM_MENU3, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
- IDS_MENU3, 0, 2,
-
- I_IMAGENONE, IDM_MENU4, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
- IDS_MENU4, 0, 3,
-
- I_IMAGENONE, IDM_MENU5, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
- IDS_MENU5, 0, 4,
-
- I_IMAGENONE, IDM_MENU6, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
- IDS_MENU6, 0, 5,
-END
-
-IDR_MAIN_MENU5 SHMENUBAR DISCARDABLE
-BEGIN
- IDR_MAIN_MENU5,
- 8,
-
- I_IMAGENONE, IDM_MENU1, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
- IDS_MENU1, 0, 0,
-
- I_IMAGENONE, IDM_MENU2, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
- IDS_MENU2, 0, 1,
-
- I_IMAGENONE, IDM_MENU3, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
- IDS_MENU3, 0, 2,
-
- I_IMAGENONE, IDM_MENU4, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
- IDS_MENU4, 0, 3,
-
- I_IMAGENONE, IDM_MENU5, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
- IDS_MENU5, 0, 4,
-
- I_IMAGENONE, IDM_MENU6, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
- IDS_MENU6, 0, 5,
-
- I_IMAGENONE, IDM_MENU7, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
- IDS_MENU7, 0, 6,
-
- I_IMAGENONE, IDM_MENU8, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE,
- IDS_MENU8, 0, 7,
-END
diff --git a/src/widgets/widgets/qmenu_wince_resource_p.h b/src/widgets/widgets/qmenu_wince_resource_p.h
deleted file mode 100644
index 3bd83d934f..0000000000
--- a/src/widgets/widgets/qmenu_wince_resource_p.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-
-#define IDR_MAIN_MENU 102
-#define IDR_MAIN_MENU2 103
-#define IDR_MAIN_MENU3 104
-#define IDS_EXIT 105
-#define IDS_MENU 106
-#define IDS_LEFTMENU 107
-#define IDM_ABOUT 108
-#define IDM_VIEW 109
-#define IDM_ITEM1 108
-#define IDM_ITEM2 109
-#define IDM_ITEM3 110
-#define IDM_ITEM4 111
-#define IDM_ITEM5 112
-#define IDM_ITEM6 113
-#define IDM_ITEM7 114
-#define IDM_ITEM8 115
-#define IDS_MENU1 116
-#define IDS_MENU2 117
-#define IDS_MENU3 118
-#define IDS_MENU4 119
-#define IDS_MENU5 120
-#define IDS_MENU6 121
-#define IDS_MENU7 122
-#define IDS_MENU8 123
-#define IDR_MAIN_MENU4 124
-#define IDR_MAIN_MENU5 125
-#define IDM_EXIT 40000
-#define IDM_MENU 40001
-#define IDM_LEFTMENU 40002
-#define IDM_MENU1 40003
-#define IDM_MENU2 40004
-#define IDM_MENU3 40005
-#define IDM_MENU4 40006
-#define IDM_MENU5 40007
-#define IDM_MENU6 40008
-#define IDM_MENU7 40009
-#define IDM_MENU8 40010
-
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index 399c07c42d..45b7b3091a 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -64,10 +64,6 @@
#include "qmenubar_p.h"
#include "qdebug.h"
-#ifdef Q_OS_WINCE
-extern bool qt_wince_is_mobile(); //defined in qguifunctions_wce.cpp
-#endif
-
QT_BEGIN_NAMESPACE
class QMenuBarExtension : public QToolButton
@@ -701,16 +697,6 @@ void QMenuBarPrivate::init()
if (platformMenuBar)
q->hide();
-#ifdef Q_OS_WINCE
- if (qt_wince_is_mobile()) {
- wceCreateMenuBar(q->parentWidget());
- if(wce_menubar)
- q->hide();
- }
- else {
- QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, true);
- }
-#endif
q->setBackgroundRole(QPalette::Button);
handleReparent();
q->setMouseTracking(q->style()->styleHint(QStyle::SH_MenuBar_MouseTracking, 0, q));
@@ -760,11 +746,6 @@ QMenuBar::~QMenuBar()
Q_D(QMenuBar);
delete d->platformMenuBar;
d->platformMenuBar = 0;
-
-#ifdef Q_OS_WINCE
- if (qt_wince_is_mobile())
- d->wceDestroyMenuBar();
-#endif
}
/*!
@@ -1016,7 +997,7 @@ void QMenuBar::paintEvent(QPaintEvent *e)
*/
void QMenuBar::setVisible(bool visible)
{
-#if defined(Q_OS_MAC) || defined(Q_OS_WINCE)
+#if defined(Q_OS_DARWIN)
if (isNativeMenuBar()) {
if (!visible)
QWidget::setVisible(false);
@@ -1233,11 +1214,7 @@ void QMenuBar::actionEvent(QActionEvent *e)
d->itemsDirty = true;
if (d->platformMenuBar) {
-#if !defined(Q_OS_WINCE)
QPlatformMenuBar *nativeMenuBar = d->platformMenuBar;
-#else
- QMenuBarPrivate::QWceMenuBarPrivate *nativeMenuBar = d->wce_menubar;
-#endif
if (!nativeMenuBar)
return;
@@ -1389,11 +1366,6 @@ void QMenuBarPrivate::handleReparent()
platformMenuBar->handleReparent(0);
}
}
-
-#ifdef Q_OS_WINCE
- if (qt_wince_is_mobile() && wce_menubar)
- wce_menubar->rebuild();
-#endif
}
/*!
@@ -1572,7 +1544,7 @@ QRect QMenuBar::actionGeometry(QAction *act) const
QSize QMenuBar::minimumSizeHint() const
{
Q_D(const QMenuBar);
-#if defined(Q_OS_MAC) || defined(Q_OS_WINCE)
+#if defined(Q_OS_DARWIN)
const bool as_gui_menubar = !isNativeMenuBar();
#else
const bool as_gui_menubar = true;
@@ -1628,7 +1600,7 @@ QSize QMenuBar::minimumSizeHint() const
QSize QMenuBar::sizeHint() const
{
Q_D(const QMenuBar);
-#if defined(Q_OS_MAC) || defined(Q_OS_WINCE)
+#if defined(Q_OS_DARWIN)
const bool as_gui_menubar = !isNativeMenuBar();
#else
const bool as_gui_menubar = true;
@@ -1686,7 +1658,7 @@ QSize QMenuBar::sizeHint() const
int QMenuBar::heightForWidth(int) const
{
Q_D(const QMenuBar);
-#if defined(Q_OS_MAC) || defined(Q_OS_WINCE)
+#if defined(Q_OS_DARWIN)
const bool as_gui_menubar = !isNativeMenuBar();
#else
const bool as_gui_menubar = true;
@@ -1871,55 +1843,6 @@ QPlatformMenuBar *QMenuBar::platformMenuBar()
}
/*!
- \since 4.4
-
- Sets the default action to \a act.
-
- The default action is assigned to the left soft key. The menu is assigned
- to the right soft key.
-
- Currently there is only support for the default action on Windows
- Mobile. On all other platforms this method is not available.
-
- \sa defaultAction()
-*/
-
-#ifdef Q_OS_WINCE
-void QMenuBar::setDefaultAction(QAction *act)
-{
- Q_D(QMenuBar);
- if (d->defaultAction == act)
- return;
- if (qt_wince_is_mobile())
- if (d->defaultAction) {
- disconnect(d->defaultAction, SIGNAL(changed()), this, SLOT(_q_updateDefaultAction()));
- disconnect(d->defaultAction, SIGNAL(destroyed()), this, SLOT(_q_updateDefaultAction()));
- }
- d->defaultAction = act;
- if (qt_wince_is_mobile())
- if (d->defaultAction) {
- connect(d->defaultAction, SIGNAL(changed()), this, SLOT(_q_updateDefaultAction()));
- connect(d->defaultAction, SIGNAL(destroyed()), this, SLOT(_q_updateDefaultAction()));
- }
- if (d->wce_menubar) {
- d->wce_menubar->rebuild();
- }
-}
-
-/*!
- \since 4.4
-
- Returns the current default action.
-
- \sa setDefaultAction()
-*/
-QAction *QMenuBar::defaultAction() const
-{
- return d_func()->defaultAction;
-}
-#endif
-
-/*!
\fn void QMenuBar::triggered(QAction *action)
This signal is emitted when an action in a menu belonging to this menubar
diff --git a/src/widgets/widgets/qmenubar.h b/src/widgets/widgets/qmenubar.h
index d3f5e503ac..ec15155710 100644
--- a/src/widgets/widgets/qmenubar.h
+++ b/src/widgets/widgets/qmenubar.h
@@ -40,6 +40,7 @@
#ifndef QMENUBAR_H
#define QMENUBAR_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qmenu.h>
QT_BEGIN_NAMESPACE
@@ -95,13 +96,6 @@ public:
void setCornerWidget(QWidget *w, Qt::Corner corner = Qt::TopRightCorner);
QWidget *cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const;
-#ifdef Q_OS_WINCE
- void setDefaultAction(QAction *);
- QAction *defaultAction() const;
-
- static void wceCommands(uint command);
- static void wceRefresh();
-#endif
#ifdef Q_OS_OSX
NSMenu* toNSMenu();
#endif
@@ -141,10 +135,6 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_internalShortcutActivated(int))
Q_PRIVATE_SLOT(d_func(), void _q_updateLayout())
-#ifdef Q_OS_WINCE
- Q_PRIVATE_SLOT(d_func(), void _q_updateDefaultAction())
-#endif
-
friend class QMenu;
friend class QMenuPrivate;
friend class QWindowsStyle;
diff --git a/src/widgets/widgets/qmenubar_p.h b/src/widgets/widgets/qmenubar_p.h
index c88e4af836..153df35297 100644
--- a/src/widgets/widgets/qmenubar_p.h
+++ b/src/widgets/widgets/qmenubar_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QtWidgets/qstyleoption.h"
#include <private/qmenu_p.h> // Mac needs what in this file!
#include <qpa/qplatformmenu.h>
@@ -66,17 +67,11 @@ public:
QMenuBarPrivate() : itemsDirty(0), currentAction(0), mouseDown(0),
closePopupMode(0), defaultPopDown(1), popupState(0), keyboardState(0), altPressed(0),
nativeMenuBar(-1), doChildEffects(false), platformMenuBar(0)
+ { }
-#ifdef Q_OS_WINCE
- , wce_menubar(0), wceClassicMenu(false)
-#endif
- { }
~QMenuBarPrivate()
{
delete platformMenuBar;
-#ifdef Q_OS_WINCE
- delete wce_menubar;
-#endif
}
void init();
@@ -118,10 +113,6 @@ public:
void _q_internalShortcutActivated(int);
void _q_updateLayout();
-#ifdef Q_OS_WINCE
- void _q_updateDefaultAction();
-#endif
-
//extra widgets in the menubar
QPointer<QWidget> leftWidget, rightWidget;
QMenuBarExtension *extension;
@@ -145,47 +136,6 @@ public:
QPlatformMenu *getPlatformMenu(QAction *action);
inline int indexOf(QAction *act) const { return q_func()->actions().indexOf(act); }
-
-#ifdef Q_OS_WINCE
- void wceCreateMenuBar(QWidget *);
- void wceDestroyMenuBar();
- struct QWceMenuBarPrivate {
- QList<QWceMenuAction*> actionItems;
- QList<QWceMenuAction*> actionItemsLeftButton;
- QList<QList<QWceMenuAction*>> actionItemsClassic;
- HMENU menuHandle;
- HMENU leftButtonMenuHandle;
- HWND menubarHandle;
- HWND parentWindowHandle;
- bool leftButtonIsMenu;
- QPointer<QAction> leftButtonAction;
- QMenuBarPrivate *d;
- int leftButtonCommand;
-
- QWceMenuBarPrivate(QMenuBarPrivate *menubar);
- ~QWceMenuBarPrivate();
- void addAction(QAction *, QAction *);
- void addAction(QAction *, QWceMenuAction* =0);
- void addAction(QWceMenuAction *, QWceMenuAction* =0);
- void syncAction(QWceMenuAction *);
- inline void syncAction(QAction *a) { syncAction(findAction(a)); }
- void removeAction(QWceMenuAction *);
- void rebuild();
- inline void removeAction(QAction *a) { removeAction(findAction(a)); }
- inline QWceMenuAction *findAction(QAction *a) {
- for(int i = 0; i < actionItems.size(); i++) {
- QWceMenuAction *act = actionItems[i];
- if(a == act->action)
- return act;
- }
- return 0;
- }
- } *wce_menubar;
- bool wceClassicMenu;
- void wceCommands(uint command);
- void wceRefresh();
- bool wceEmitSignals(QList<QWceMenuAction*> actions, uint command);
-#endif
};
#endif // QT_NO_MENUBAR
diff --git a/src/widgets/widgets/qplaintextedit.h b/src/widgets/widgets/qplaintextedit.h
index 021308493a..432ec85a57 100644
--- a/src/widgets/widgets/qplaintextedit.h
+++ b/src/widgets/widgets/qplaintextedit.h
@@ -40,6 +40,7 @@
#ifndef QPLAINTEXTEDIT_H
#define QPLAINTEXTEDIT_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qtextedit.h>
#include <QtWidgets/qabstractscrollarea.h>
diff --git a/src/widgets/widgets/qplaintextedit_p.h b/src/widgets/widgets/qplaintextedit_p.h
index f5a027be42..f0dd1c0ed4 100644
--- a/src/widgets/widgets/qplaintextedit_p.h
+++ b/src/widgets/widgets/qplaintextedit_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qabstractscrollarea_p.h"
#include "QtGui/qtextdocumentfragment.h"
#include "QtWidgets/qscrollbar.h"
diff --git a/src/widgets/widgets/qprogressbar.h b/src/widgets/widgets/qprogressbar.h
index 5ab702e9d0..2dbb7240c5 100644
--- a/src/widgets/widgets/qprogressbar.h
+++ b/src/widgets/widgets/qprogressbar.h
@@ -40,6 +40,7 @@
#ifndef QPROGRESSBAR_H
#define QPROGRESSBAR_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qframe.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qpushbutton.cpp b/src/widgets/widgets/qpushbutton.cpp
index a3bb06c063..5608a4aff9 100644
--- a/src/widgets/widgets/qpushbutton.cpp
+++ b/src/widgets/widgets/qpushbutton.cpp
@@ -254,11 +254,9 @@ QPushButton::QPushButton(QWidget *parent)
*/
QPushButton::QPushButton(const QString &text, QWidget *parent)
- : QAbstractButton(*new QPushButtonPrivate, parent)
+ : QPushButton(parent)
{
- Q_D(QPushButton);
setText(text);
- d->init();
}
@@ -270,12 +268,10 @@ QPushButton::QPushButton(const QString &text, QWidget *parent)
*/
QPushButton::QPushButton(const QIcon& icon, const QString &text, QWidget *parent)
- : QAbstractButton(*new QPushButtonPrivate, parent)
+ : QPushButton(*new QPushButtonPrivate, parent)
{
- Q_D(QPushButton);
setText(text);
setIcon(icon);
- d->init();
}
/*! \internal
diff --git a/src/widgets/widgets/qpushbutton.h b/src/widgets/widgets/qpushbutton.h
index 0afd99bccc..56d4d1de20 100644
--- a/src/widgets/widgets/qpushbutton.h
+++ b/src/widgets/widgets/qpushbutton.h
@@ -40,6 +40,7 @@
#ifndef QPUSHBUTTON_H
#define QPUSHBUTTON_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qabstractbutton.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qpushbutton_p.h b/src/widgets/widgets/qpushbutton_p.h
index 048f8aad2d..cd453a1339 100644
--- a/src/widgets/widgets/qpushbutton_p.h
+++ b/src/widgets/widgets/qpushbutton_p.h
@@ -40,6 +40,7 @@
#ifndef QPUSHBUTTON_P_H
#define QPUSHBUTTON_P_H
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qabstractbutton_p.h"
//
diff --git a/src/widgets/widgets/qradiobutton.cpp b/src/widgets/widgets/qradiobutton.cpp
index 55a584078a..284c5f56cf 100644
--- a/src/widgets/widgets/qradiobutton.cpp
+++ b/src/widgets/widgets/qradiobutton.cpp
@@ -155,10 +155,8 @@ QRadioButton::~QRadioButton()
*/
QRadioButton::QRadioButton(const QString &text, QWidget *parent)
- : QAbstractButton(*new QRadioButtonPrivate, parent)
+ : QRadioButton(parent)
{
- Q_D(QRadioButton);
- d->init();
setText(text);
}
diff --git a/src/widgets/widgets/qradiobutton.h b/src/widgets/widgets/qradiobutton.h
index 76f5c1aae4..2dcb0d0fdf 100644
--- a/src/widgets/widgets/qradiobutton.h
+++ b/src/widgets/widgets/qradiobutton.h
@@ -40,6 +40,7 @@
#ifndef QRADIOBUTTON_H
#define QRADIOBUTTON_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qabstractbutton.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qrubberband.h b/src/widgets/widgets/qrubberband.h
index 30ca96abef..217261bf75 100644
--- a/src/widgets/widgets/qrubberband.h
+++ b/src/widgets/widgets/qrubberband.h
@@ -40,6 +40,7 @@
#ifndef QRUBBERBAND_H
#define QRUBBERBAND_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qscrollarea.h b/src/widgets/widgets/qscrollarea.h
index c530ed23ed..92ce287566 100644
--- a/src/widgets/widgets/qscrollarea.h
+++ b/src/widgets/widgets/qscrollarea.h
@@ -40,6 +40,7 @@
#ifndef QSCROLLAREA_H
#define QSCROLLAREA_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qabstractscrollarea.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qscrollarea_p.h b/src/widgets/widgets/qscrollarea_p.h
index c628d1485e..f7c0725dbe 100644
--- a/src/widgets/widgets/qscrollarea_p.h
+++ b/src/widgets/widgets/qscrollarea_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#ifndef QT_NO_SCROLLAREA
diff --git a/src/widgets/widgets/qscrollbar.cpp b/src/widgets/widgets/qscrollbar.cpp
index 7dd41f6a0c..79bfedb8c4 100644
--- a/src/widgets/widgets/qscrollbar.cpp
+++ b/src/widgets/widgets/qscrollbar.cpp
@@ -348,10 +348,8 @@ void QScrollBar::initStyleOption(QStyleOptionSlider *option) const
initial \l {QAbstractSlider::value} {value} of 0.
*/
QScrollBar::QScrollBar(QWidget *parent)
- : QAbstractSlider(*new QScrollBarPrivate, parent)
+ : QScrollBar(Qt::Vertical, parent)
{
- d_func()->orientation = Qt::Vertical;
- d_func()->init();
}
/*!
@@ -397,12 +395,6 @@ void QScrollBarPrivate::init()
q->setSizePolicy(sp);
q->setAttribute(Qt::WA_WState_OwnSizePolicy, false);
q->setAttribute(Qt::WA_OpaquePaintEvent);
-
-#if !defined(QT_NO_CONTEXTMENU) && defined(Q_OS_WINCE)
- if (!q->style()->styleHint(QStyle::SH_ScrollBar_ContextMenu, 0, q)) {
- q->setContextMenuPolicy(Qt::PreventContextMenu);
- }
-#endif
}
#ifndef QT_NO_CONTEXTMENU
diff --git a/src/widgets/widgets/qscrollbar.h b/src/widgets/widgets/qscrollbar.h
index 4c4a374917..2b8a110c99 100644
--- a/src/widgets/widgets/qscrollbar.h
+++ b/src/widgets/widgets/qscrollbar.h
@@ -40,6 +40,7 @@
#ifndef QSCROLLBAR_H
#define QSCROLLBAR_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
#include <QtWidgets/qabstractslider.h>
diff --git a/src/widgets/widgets/qscrollbar_p.h b/src/widgets/widgets/qscrollbar_p.h
index 97ea27afdb..e748edf6a9 100644
--- a/src/widgets/widgets/qscrollbar_p.h
+++ b/src/widgets/widgets/qscrollbar_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qabstractslider_p.h"
#include "qstyle.h"
diff --git a/src/widgets/widgets/qsizegrip.h b/src/widgets/widgets/qsizegrip.h
index a0e7de4fd8..831b146dd2 100644
--- a/src/widgets/widgets/qsizegrip.h
+++ b/src/widgets/widgets/qsizegrip.h
@@ -40,6 +40,7 @@
#ifndef QSIZEGRIP_H
#define QSIZEGRIP_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qslider.cpp b/src/widgets/widgets/qslider.cpp
index 7b675fccbd..744a43253a 100644
--- a/src/widgets/widgets/qslider.cpp
+++ b/src/widgets/widgets/qslider.cpp
@@ -284,10 +284,8 @@ QStyle::SubControl QSliderPrivate::newHoverControl(const QPoint &pos)
Constructs a vertical slider with the given \a parent.
*/
QSlider::QSlider(QWidget *parent)
- : QAbstractSlider(*new QSliderPrivate, parent)
+ : QSlider(Qt::Vertical, parent)
{
- d_func()->orientation = Qt::Vertical;
- d_func()->init();
}
/*!
diff --git a/src/widgets/widgets/qslider.h b/src/widgets/widgets/qslider.h
index 66b52c99bd..33b90ece06 100644
--- a/src/widgets/widgets/qslider.h
+++ b/src/widgets/widgets/qslider.h
@@ -40,6 +40,7 @@
#ifndef QSLIDER_H
#define QSLIDER_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qabstractslider.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qspinbox.h b/src/widgets/widgets/qspinbox.h
index 3464aa86e6..2e77f0be7a 100644
--- a/src/widgets/widgets/qspinbox.h
+++ b/src/widgets/widgets/qspinbox.h
@@ -40,6 +40,7 @@
#ifndef QSPINBOX_H
#define QSPINBOX_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qabstractspinbox.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qsplashscreen.h b/src/widgets/widgets/qsplashscreen.h
index 23588004a7..de58d86592 100644
--- a/src/widgets/widgets/qsplashscreen.h
+++ b/src/widgets/widgets/qsplashscreen.h
@@ -40,6 +40,7 @@
#ifndef QSPLASHSCREEN_H
#define QSPLASHSCREEN_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtGui/qpixmap.h>
#include <QtWidgets/qwidget.h>
diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp
index 17b7a9ebb3..910904e96e 100644
--- a/src/widgets/widgets/qsplitter.cpp
+++ b/src/widgets/widgets/qsplitter.cpp
@@ -941,11 +941,8 @@ QSplitterLayoutStruct *QSplitterPrivate::insertWidget(int index, QWidget *w)
\sa setOrientation()
*/
QSplitter::QSplitter(QWidget *parent)
- : QFrame(*new QSplitterPrivate, parent)
+ : QSplitter(Qt::Horizontal, parent)
{
- Q_D(QSplitter);
- d->orient = Qt::Horizontal;
- d->init();
}
diff --git a/src/widgets/widgets/qsplitter.h b/src/widgets/widgets/qsplitter.h
index a99bc1c78f..9cfde9fed3 100644
--- a/src/widgets/widgets/qsplitter.h
+++ b/src/widgets/widgets/qsplitter.h
@@ -40,6 +40,7 @@
#ifndef QSPLITTER_H
#define QSPLITTER_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qframe.h>
#include <QtWidgets/qsizepolicy.h>
diff --git a/src/widgets/widgets/qsplitter_p.h b/src/widgets/widgets/qsplitter_p.h
index 8bd44fab2b..4422d9a8a4 100644
--- a/src/widgets/widgets/qsplitter_p.h
+++ b/src/widgets/widgets/qsplitter_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qframe_p.h"
#include "qrubberband.h"
diff --git a/src/widgets/widgets/qstackedwidget.h b/src/widgets/widgets/qstackedwidget.h
index 266c59134b..36088ae033 100644
--- a/src/widgets/widgets/qstackedwidget.h
+++ b/src/widgets/widgets/qstackedwidget.h
@@ -40,6 +40,7 @@
#ifndef QSTACKEDWIDGET_H
#define QSTACKEDWIDGET_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qframe.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qstatusbar.cpp b/src/widgets/widgets/qstatusbar.cpp
index 7de1d92acf..5f1c373bb1 100644
--- a/src/widgets/widgets/qstatusbar.cpp
+++ b/src/widgets/widgets/qstatusbar.cpp
@@ -749,9 +749,6 @@ bool QStatusBar::event(QEvent *e)
#ifndef Q_DEAD_CODE_FROM_QT4_MAC
return QWidget::event(e);
#else
- if (QSysInfo::MacintoshVersion <= QSysInfo::MV_10_4)
- return QWidget::event(e);
-
// Enable drag-click only if the status bar is the status bar for a
// QMainWindow with a unifed toolbar.
if (parent() == 0 || qobject_cast<QMainWindow *>(parent()) == 0 ||
diff --git a/src/widgets/widgets/qstatusbar.h b/src/widgets/widgets/qstatusbar.h
index 45416e46b3..aaabb99a27 100644
--- a/src/widgets/widgets/qstatusbar.h
+++ b/src/widgets/widgets/qstatusbar.h
@@ -40,6 +40,7 @@
#ifndef QSTATUSBAR_H
#define QSTATUSBAR_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index 11700fe6f1..d56c6b39d1 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -2548,6 +2548,34 @@ QWidget *QTabBar::tabButton(int index, ButtonPosition position) const
return d->tabList.at(index).rightWidget;
}
+#ifndef QT_NO_ACCESSIBILITY
+/*!
+ Sets the accessibleName of the tab at position \a index to \a name.
+*/
+void QTabBar::setAccessibleTabName(int index, const QString &name)
+{
+ Q_D(QTabBar);
+ if (QTabBarPrivate::Tab *tab = d->at(index)) {
+ tab->accessibleName = name;
+ QAccessibleEvent event(this, QAccessible::NameChanged);
+ event.setChild(index);
+ QAccessible::updateAccessibility(&event);
+ }
+}
+
+/*!
+ Returns the accessibleName of the tab at position \a index, or an empty
+ string if \a index is out of range.
+*/
+QString QTabBar::accessibleTabName(int index) const
+{
+ Q_D(const QTabBar);
+ if (const QTabBarPrivate::Tab *tab = d->at(index))
+ return tab->accessibleName;
+ return QString();
+}
+#endif // QT_NO_ACCESSIBILITY
+
CloseButton::CloseButton(QWidget *parent)
: QAbstractButton(parent)
{
diff --git a/src/widgets/widgets/qtabbar.h b/src/widgets/widgets/qtabbar.h
index 138c5470c6..71ca58c993 100644
--- a/src/widgets/widgets/qtabbar.h
+++ b/src/widgets/widgets/qtabbar.h
@@ -40,6 +40,7 @@
#ifndef QTABBAR_H
#define QTABBAR_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
QT_BEGIN_NAMESPACE
@@ -172,6 +173,11 @@ public:
bool changeCurrentOnDrag() const;
void setChangeCurrentOnDrag(bool change);
+#ifndef QT_NO_ACCESSIBILITY
+ QString accessibleTabName(int index) const;
+ void setAccessibleTabName(int index, const QString &name);
+#endif
+
public Q_SLOTS:
void setCurrentIndex(int index);
diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h
index a73c3e11e2..0e9dce84b3 100644
--- a/src/widgets/widgets/qtabbar_p.h
+++ b/src/widgets/widgets/qtabbar_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qtabbar.h"
#include "private/qwidget_p.h"
@@ -131,6 +132,9 @@ public:
QWidget *rightWidget;
int lastTab;
int dragOffset;
+#ifndef QT_NO_ACCESSIBILITY
+ QString accessibleName;
+#endif
#ifndef QT_NO_ANIMATION
~Tab() { delete animation; }
diff --git a/src/widgets/widgets/qtabwidget.h b/src/widgets/widgets/qtabwidget.h
index c931fb9b83..59fcea223f 100644
--- a/src/widgets/widgets/qtabwidget.h
+++ b/src/widgets/widgets/qtabwidget.h
@@ -40,6 +40,7 @@
#ifndef QTABWIDGET_H
#define QTABWIDGET_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qwidget.h>
#include <QtGui/qicon.h>
diff --git a/src/widgets/widgets/qtextbrowser.h b/src/widgets/widgets/qtextbrowser.h
index 018c617f88..48b64d1216 100644
--- a/src/widgets/widgets/qtextbrowser.h
+++ b/src/widgets/widgets/qtextbrowser.h
@@ -40,6 +40,7 @@
#ifndef QTEXTBROWSER_H
#define QTEXTBROWSER_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qtextedit.h>
#include <QtCore/qurl.h>
diff --git a/src/widgets/widgets/qtextedit.h b/src/widgets/widgets/qtextedit.h
index 68ad54152b..3b523e3ed0 100644
--- a/src/widgets/widgets/qtextedit.h
+++ b/src/widgets/widgets/qtextedit.h
@@ -40,6 +40,7 @@
#ifndef QTEXTEDIT_H
#define QTEXTEDIT_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qabstractscrollarea.h>
#include <QtGui/qtextdocument.h>
#include <QtGui/qtextoption.h>
diff --git a/src/widgets/widgets/qtextedit_p.h b/src/widgets/widgets/qtextedit_p.h
index c2f41aca66..cca315ce30 100644
--- a/src/widgets/widgets/qtextedit_p.h
+++ b/src/widgets/widgets/qtextedit_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qabstractscrollarea_p.h"
#include "QtGui/qtextdocumentfragment.h"
#include "QtWidgets/qscrollbar.h"
diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp
index e7d3f841d5..61bc6d19cf 100644
--- a/src/widgets/widgets/qtoolbar.cpp
+++ b/src/widgets/widgets/qtoolbar.cpp
@@ -520,10 +520,8 @@ QToolBar::QToolBar(QWidget *parent)
\sa setWindowTitle()
*/
QToolBar::QToolBar(const QString &title, QWidget *parent)
- : QWidget(*new QToolBarPrivate, parent, 0)
+ : QToolBar(parent)
{
- Q_D(QToolBar);
- d->init();
setWindowTitle(title);
}
@@ -1186,17 +1184,6 @@ bool QToolBar::event(QEvent *event)
if (d->mouseMoveEvent(static_cast<QMouseEvent*>(event)))
return true;
break;
-#ifdef Q_OS_WINCE
- case QEvent::ContextMenu:
- {
- QContextMenuEvent* contextMenuEvent = static_cast<QContextMenuEvent*>(event);
- QWidget* child = childAt(contextMenuEvent->pos());
- QAbstractButton* button = qobject_cast<QAbstractButton*>(child);
- if (button)
- button->setDown(false);
- }
- break;
-#endif
case QEvent::Leave:
if (d->state != 0 && d->state->dragging) {
#ifdef Q_OS_WIN
diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h
index 774d47b913..d361513bbf 100644
--- a/src/widgets/widgets/qtoolbar.h
+++ b/src/widgets/widgets/qtoolbar.h
@@ -40,6 +40,7 @@
#ifndef QDYNAMICTOOLBAR_H
#define QDYNAMICTOOLBAR_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qaction.h>
#include <QtWidgets/qwidget.h>
@@ -100,11 +101,17 @@ public:
QAction *addAction(const QIcon &icon, const QString &text,
const QObject *receiver, const char* member);
#ifdef Q_QDOC
+ template<typename PointerToMemberFunction>
QAction *addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method);
+ template<typename Functor>
QAction *addAction(const QString &text, Functor functor);
+ template<typename Functor>
QAction *addAction(const QString &text, const QObject *context, Functor functor);
+ template<typename PointerToMemberFunction>
QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method);
+ template<typename Functor>
QAction *addAction(const QIcon &icon, const QString &text, Functor functor);
+ template<typename Functor>
QAction *addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor);
#else
// addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
diff --git a/src/widgets/widgets/qtoolbar_p.h b/src/widgets/widgets/qtoolbar_p.h
index 7782b56962..616f53f717 100644
--- a/src/widgets/widgets/qtoolbar_p.h
+++ b/src/widgets/widgets/qtoolbar_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "qtoolbar.h"
#include "QtWidgets/qaction.h"
#include "private/qwidget_p.h"
diff --git a/src/widgets/widgets/qtoolbararealayout_p.h b/src/widgets/widgets/qtoolbararealayout_p.h
index a1ae68130c..901f04cf14 100644
--- a/src/widgets/widgets/qtoolbararealayout_p.h
+++ b/src/widgets/widgets/qtoolbararealayout_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QList>
#include <QSize>
#include <QRect>
diff --git a/src/widgets/widgets/qtoolbarextension_p.h b/src/widgets/widgets/qtoolbarextension_p.h
index ea159ce986..c4d803165c 100644
--- a/src/widgets/widgets/qtoolbarextension_p.h
+++ b/src/widgets/widgets/qtoolbarextension_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QtWidgets/qtoolbutton.h"
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qtoolbarlayout_p.h b/src/widgets/widgets/qtoolbarlayout_p.h
index 1f93f04a53..9a81c4e50e 100644
--- a/src/widgets/widgets/qtoolbarlayout_p.h
+++ b/src/widgets/widgets/qtoolbarlayout_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtWidgets/qlayout.h>
#include <private/qlayoutengine_p.h>
#include <QVector>
diff --git a/src/widgets/widgets/qtoolbarseparator_p.h b/src/widgets/widgets/qtoolbarseparator_p.h
index 38e1f130f6..8c9cf9f46a 100644
--- a/src/widgets/widgets/qtoolbarseparator_p.h
+++ b/src/widgets/widgets/qtoolbarseparator_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QtWidgets/qwidget.h"
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qtoolbox.h b/src/widgets/widgets/qtoolbox.h
index 2e32668193..6556d8a202 100644
--- a/src/widgets/widgets/qtoolbox.h
+++ b/src/widgets/widgets/qtoolbox.h
@@ -40,6 +40,7 @@
#ifndef QTOOLBOX_H
#define QTOOLBOX_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qframe.h>
#include <QtGui/qicon.h>
diff --git a/src/widgets/widgets/qtoolbutton.h b/src/widgets/widgets/qtoolbutton.h
index 7b6114b5c1..95d159f12d 100644
--- a/src/widgets/widgets/qtoolbutton.h
+++ b/src/widgets/widgets/qtoolbutton.h
@@ -40,6 +40,7 @@
#ifndef QTOOLBUTTON_H
#define QTOOLBUTTON_H
+#include <QtWidgets/qtwidgetsglobal.h>
#include <QtWidgets/qabstractbutton.h>
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/widgets/qwidgetanimator_p.h b/src/widgets/widgets/qwidgetanimator_p.h
index 4f16f7b3e5..6db8b67820 100644
--- a/src/widgets/widgets/qwidgetanimator_p.h
+++ b/src/widgets/widgets/qwidgetanimator_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <qobject.h>
#include <qhash.h>
#include <qpointer.h>
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index 8b6b76c55e..66f17dbe33 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -441,7 +441,7 @@ QRect QWidgetLineControl::anchorRect() const
{
if (!hasSelectedText())
return cursorRect();
- return rectForPos(m_selstart < m_selend ? m_selstart : m_selend);
+ return rectForPos(m_cursor == m_selstart ? m_selend : m_selstart);
}
/*!
diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h
index 5e52e29a51..db9039e302 100644
--- a/src/widgets/widgets/qwidgetlinecontrol_p.h
+++ b/src/widgets/widgets/qwidgetlinecontrol_p.h
@@ -51,7 +51,7 @@
// We mean it.
//
-#include "QtCore/qglobal.h"
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#ifndef QT_NO_LINEEDIT
#include "private/qwidget_p.h"
diff --git a/src/widgets/widgets/qwidgetresizehandler_p.h b/src/widgets/widgets/qwidgetresizehandler_p.h
index b955d8b7c3..7bb7d6cd94 100644
--- a/src/widgets/widgets/qwidgetresizehandler_p.h
+++ b/src/widgets/widgets/qwidgetresizehandler_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QtCore/qobject.h"
#include "QtCore/qpoint.h"
diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h
index 89b96fa667..e1687f83a3 100644
--- a/src/widgets/widgets/qwidgettextcontrol_p.h
+++ b/src/widgets/widgets/qwidgettextcontrol_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include <QtGui/qtextdocument.h>
#include <QtGui/qtextoption.h>
#include <QtGui/qtextcursor.h>
diff --git a/src/widgets/widgets/qwidgettextcontrol_p_p.h b/src/widgets/widgets/qwidgettextcontrol_p_p.h
index fea72d98ff..35027ff82a 100644
--- a/src/widgets/widgets/qwidgettextcontrol_p_p.h
+++ b/src/widgets/widgets/qwidgettextcontrol_p_p.h
@@ -51,6 +51,7 @@
// We mean it.
//
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QtGui/qtextdocumentfragment.h"
#include "QtWidgets/qscrollbar.h"
#include "QtGui/qtextcursor.h"
diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri
index 784055ed62..abba3e0472 100644
--- a/src/widgets/widgets/widgets.pri
+++ b/src/widgets/widgets/widgets.pri
@@ -155,19 +155,3 @@ macx {
widgets/qmacnativewidget_mac.mm \
widgets/qmaccocoaviewcontainer_mac.mm
}
-
-wince {
- SOURCES += widgets/qmenu_wince.cpp
- HEADERS += widgets/qmenu_wince_resource_p.h
- RC_FILE = widgets/qmenu_wince.rc
- !static: QMAKE_WRITE_DEFAULT_RC = 1
- !isEmpty(QT_LIBINFIX) {
- ORIG_RCFILE = $${TARGET}_resource.rc
- copyrcc.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
- copyrcc.input = ORIG_RCFILE
- CONFIG(debug, debug|release):copyrcc.output = $${ORIG_TARGET}d_resource.rc
- else:copyrcc.output = $${ORIG_TARGET}_resource.rc
- copyrcc.CONFIG = target_predeps no_link
- QMAKE_EXTRA_COMPILERS += copyrcc
- }
-}
diff --git a/src/winmain/qtmain_win.cpp b/src/winmain/qtmain_win.cpp
index bf416e11d3..7087176110 100644
--- a/src/winmain/qtmain_win.cpp
+++ b/src/winmain/qtmain_win.cpp
@@ -53,9 +53,7 @@
#include "qstring.h"
#include "qvector.h"
-#ifndef Q_OS_WINCE
-# include <shlobj.h>
-#endif
+#include <shlobj.h>
/*
This file contains the code in the qtmain library for Windows.
@@ -69,11 +67,7 @@
QT_BEGIN_NAMESPACE
-#if defined(Q_OS_WINCE)
-extern void __cdecl qWinMain(HINSTANCE, HINSTANCE, LPSTR, int, int &, QVector<char *> &);
-#else
extern void qWinMain(HINSTANCE, HINSTANCE, LPSTR, int, int &, QVector<char *> &);
-#endif
QT_END_NAMESPACE
@@ -84,12 +78,8 @@ QT_USE_NAMESPACE
int qMain(int, char **);
#define main qMain
#else
-#ifdef Q_OS_WINCE
-extern "C" int __cdecl main(int, char **);
-#else
extern "C" int main(int, char **);
#endif
-#endif
/*
WinMain() - Initializes Windows and calls user's startup function main().
@@ -97,8 +87,6 @@ extern "C" int main(int, char **);
application.
*/
-#ifndef Q_OS_WINCE
-
// Convert a wchar_t to char string, equivalent to QString::toLocal8Bit()
// when passed CP_ACP.
static inline char *wideToMulti(int codePage, const wchar_t *aw)
@@ -126,48 +114,3 @@ extern "C" int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR /*cmdParamarg*/, int
delete [] argv;
return exitCode;
}
-
-#else // !Q_OS_WINCE
-
-int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR /*wCmdParam*/, int cmdShow)
-{
- QByteArray cmdParam = QString::fromWCharArray(GetCommandLine()).toLocal8Bit();
-
- wchar_t appName[MAX_PATH];
- GetModuleFileName(0, appName, MAX_PATH);
- cmdParam.prepend(QString(QLatin1String("\"%1\" ")).arg(QString::fromWCharArray(appName)).toLocal8Bit());
-
- int argc = 0;
- QVector<char *> argv(8);
- qWinMain(instance, prevInstance, cmdParam.data(), cmdShow, argc, argv);
-
- wchar_t uniqueAppID[MAX_PATH];
- GetModuleFileName(0, uniqueAppID, MAX_PATH);
- QString uid = QString::fromWCharArray(uniqueAppID).toLower().replace(QLatin1String("\\"), QLatin1String("_"));
-
- // If there exists an other instance of this application
- // it will be the owner of a mutex with the unique ID.
- HANDLE mutex = CreateMutex(NULL, TRUE, (LPCWSTR)uid.utf16());
- if (mutex && ERROR_ALREADY_EXISTS == GetLastError()) {
- CloseHandle(mutex);
-
- // The app is already running, so we use the unique
- // ID to create a unique messageNo, which is used
- // as the registered class name for the windows
- // created. Set the first instance's window to the
- // foreground, else just terminate.
- // Use bitwise 0x01 OR to reactivate window state if
- // it was hidden
- UINT msgNo = RegisterWindowMessage((LPCWSTR)uid.utf16());
- HWND aHwnd = FindWindow((LPCWSTR)QString::number(msgNo).utf16(), 0);
- if (aHwnd)
- SetForegroundWindow((HWND)(((ULONG)aHwnd) | 0x01));
- return 0;
- }
-
- int result = main(argc, argv.data());
- CloseHandle(mutex);
- return result;
-}
-
-#endif // Q_OS_WINCE
diff --git a/src/winmain/winmain.pro b/src/winmain/winmain.pro
index b4977653ce..2bb7529456 100644
--- a/src/winmain/winmain.pro
+++ b/src/winmain/winmain.pro
@@ -23,7 +23,7 @@ winrt {
} else {
SOURCES = qtmain_win.cpp
- !wince: LIBS += -lshell32
+ LIBS += -lshell32
}
load(qt_installs)
@@ -33,5 +33,3 @@ TARGET = $$qtLibraryTarget($$TARGET$$QT_LIBINFIX) #do this towards the end
load(qt_targets)
load(qt_build_paths)
load(qt_common)
-
-wince: QMAKE_POST_LINK =