summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-09-26 16:08:55 +0200
committerLiang Qi <liang.qi@qt.io>2017-09-26 16:14:54 +0200
commitaadfe7d634de04519102c5827ca885dc2e2199c9 (patch)
treed92db346ca95332b177036a53f1f6beb2e24fb74
parent4b6c1448047362b8c38d265e6414f0e3e59b8d37 (diff)
parenta732e16d5fd9dbf8a0289fec9f948b12e9ba2c19 (diff)
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts: src/gui/kernel/qguiapplication.cpp src/platformsupport/input/libinput/qlibinputpointer.cpp src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h src/plugins/platforms/cocoa/qcocoawindow.h src/testlib/qtestsystem.h Change-Id: I5975ffb3261c2dd82fe02ec4e57df7c0950226c5
-rw-r--r--config_help.txt1
-rw-r--r--configure.json17
-rw-r--r--dist/changes-5.6.3288
-rw-r--r--examples/corelib/ipc/localfortuneclient/client.cpp67
-rw-r--r--examples/corelib/ipc/localfortuneclient/client.h13
-rw-r--r--examples/corelib/ipc/localfortuneclient/main.cpp1
-rw-r--r--examples/corelib/ipc/localfortuneserver/main.cpp2
-rw-r--r--examples/corelib/ipc/localfortuneserver/server.cpp36
-rw-r--r--examples/corelib/ipc/localfortuneserver/server.h4
-rw-r--r--examples/network/broadcastsender/sender.cpp22
-rw-r--r--examples/network/broadcastsender/sender.h19
-rw-r--r--examples/network/doc/images/http-example.pngbin7006 -> 8099 bytes
-rw-r--r--examples/network/http/httpwindow.cpp32
-rw-r--r--examples/network/http/httpwindow.h4
-rw-r--r--examples/network/multicastsender/sender.cpp41
-rw-r--r--examples/network/multicastsender/sender.h32
-rw-r--r--examples/network/securesocketclient/certificateinfo.cpp22
-rw-r--r--examples/network/securesocketclient/certificateinfo.h13
-rw-r--r--examples/network/securesocketclient/certificateinfo.ui2
-rw-r--r--examples/network/securesocketclient/main.cpp7
-rw-r--r--examples/network/securesocketclient/securesocketclient.pro2
-rw-r--r--examples/network/securesocketclient/sslclient.cpp168
-rw-r--r--examples/network/securesocketclient/sslclient.h25
-rw-r--r--examples/network/securesocketclient/sslclient.ui10
-rw-r--r--examples/opengl/hellogl2/glwidget.cpp7
-rw-r--r--examples/opengl/hellogl2/glwidget.h5
-rw-r--r--examples/opengl/hellogl2/main.cpp27
-rw-r--r--examples/opengl/hellowindow/main.cpp27
-rw-r--r--examples/opengl/qopenglwidget/main.cpp19
-rw-r--r--examples/opengl/threadedqopenglwidget/main.cpp15
-rw-r--r--examples/sql/cachedtable/tableeditor.cpp6
-rw-r--r--examples/sql/cachedtable/tableeditor.h2
-rw-r--r--examples/sql/connection.h12
-rw-r--r--examples/sql/doc/src/drilldown.qdoc33
-rw-r--r--examples/sql/drilldown/imageitem.cpp6
-rw-r--r--examples/sql/drilldown/imageitem.h4
-rw-r--r--examples/sql/drilldown/informationwindow.cpp18
-rw-r--r--examples/sql/drilldown/informationwindow.h20
-rw-r--r--examples/sql/drilldown/main.cpp11
-rw-r--r--examples/sql/drilldown/view.cpp36
-rw-r--r--examples/sql/drilldown/view.h4
-rw-r--r--examples/sql/masterdetail/database.h12
-rw-r--r--examples/sql/masterdetail/dialog.cpp12
-rw-r--r--examples/sql/masterdetail/dialog.h8
-rw-r--r--examples/sql/masterdetail/main.cpp13
-rw-r--r--examples/sql/masterdetail/mainwindow.cpp43
-rw-r--r--examples/sql/masterdetail/mainwindow.h2
-rw-r--r--examples/sql/querymodel/customsqlmodel.h2
-rw-r--r--examples/sql/querymodel/editablesqlmodel.h2
-rw-r--r--examples/sql/querymodel/main.cpp9
-rw-r--r--examples/sql/relationaltablemodel/relationaltablemodel.cpp3
-rw-r--r--examples/sql/sqlbrowser/browser.cpp6
-rw-r--r--examples/sql/sqlbrowser/browser.h6
-rw-r--r--examples/sql/sqlbrowser/connectionwidget.cpp5
-rw-r--r--examples/sql/sqlbrowser/connectionwidget.h2
-rw-r--r--examples/sql/sqlbrowser/main.cpp14
-rw-r--r--examples/sql/sqlbrowser/qsqlconnectiondialog.h2
-rw-r--r--examples/sql/sqlwidgetmapper/window.cpp12
-rw-r--r--examples/sql/sqlwidgetmapper/window.h2
-rw-r--r--examples/sql/tablemodel/tablemodel.cpp10
-rw-r--r--examples/widgets/dialogs/dialogs.pro1
-rw-r--r--examples/widgets/itemviews/storageview/main.cpp10
-rw-r--r--examples/widgets/itemviews/storageview/storagemodel.cpp53
-rw-r--r--examples/widgets/itemviews/storageview/storagemodel.h14
-rw-r--r--mkspecs/android-g++/qmake.conf12
-rw-r--r--mkspecs/common/android-base-head.conf1
-rw-r--r--mkspecs/common/android-base-tail.conf10
-rw-r--r--mkspecs/features/moc.prf2
-rw-r--r--mkspecs/features/qt_common.prf4
-rw-r--r--mkspecs/features/toolchain.prf6
-rw-r--r--mkspecs/features/unix/ccache.prf19
-rw-r--r--qmake/main.cpp23
-rwxr-xr-xsrc/3rdparty/pcre2/import_from_pcre2_tarball.sh1
-rw-r--r--src/3rdparty/pcre2/pcre2.pro3
-rw-r--r--src/3rdparty/pcre2/src/pcre2_printint.c831
-rw-r--r--src/corelib/doc/snippets/qstring/main.cpp4
-rw-r--r--src/corelib/global/qoperatingsystemversion.cpp23
-rw-r--r--src/corelib/global/qoperatingsystemversion.h24
-rw-r--r--src/corelib/global/qoperatingsystemversion_p.h19
-rw-r--r--src/corelib/global/qrandom.cpp69
-rw-r--r--src/corelib/global/qrandom.h35
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp1
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp13
-rw-r--r--src/corelib/io/qtemporaryfile.cpp2
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.h2
-rw-r--r--src/corelib/kernel/qcore_mac_objc.mm66
-rw-r--r--src/corelib/kernel/qcore_mac_p.h4
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp61
-rw-r--r--src/corelib/kernel/qcoreapplication_p.h4
-rw-r--r--src/corelib/kernel/qvariant.cpp92
-rw-r--r--src/corelib/thread/qthread.cpp24
-rw-r--r--src/corelib/thread/qthread.h128
-rw-r--r--src/corelib/thread/qthreadpool.cpp10
-rw-r--r--src/corelib/tools/qhash.cpp2
-rw-r--r--src/corelib/tools/qlocale.cpp2
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h9
-rw-r--r--src/corelib/tools/qstring.cpp38
-rw-r--r--src/corelib/tools/qstringalgorithms.h2
-rw-r--r--src/corelib/tools/qstringview.h22
-rw-r--r--src/gui/image/qimage.cpp23
-rw-r--r--src/gui/kernel/qevent.cpp30
-rw-r--r--src/gui/kernel/qevent.h10
-rw-r--r--src/gui/kernel/qguiapplication.cpp63
-rw-r--r--src/gui/kernel/qguiapplication.h2
-rw-r--r--src/gui/kernel/qsimpledrag.cpp8
-rw-r--r--src/gui/kernel/qtouchdevice.cpp9
-rw-r--r--src/gui/kernel/qtouchdevice_p.h1
-rw-r--r--src/gui/kernel/qwindow.h4
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp12
-rw-r--r--src/gui/kernel/qwindowsysteminterface.h6
-rw-r--r--src/gui/kernel/qwindowsysteminterface_p.h5
-rw-r--r--src/gui/painting/qpdf.cpp14
-rw-r--r--src/network/access/access.pri25
-rw-r--r--src/network/access/qftp.cpp4
-rw-r--r--src/network/access/qftp_p.h7
-rw-r--r--src/network/access/qnetworkaccesscachebackend.cpp2
-rw-r--r--src/network/access/qnetworkaccessfilebackend.cpp2
-rw-r--r--src/network/access/qnetworkaccessftpbackend.cpp4
-rw-r--r--src/network/access/qnetworkaccessftpbackend_p.h4
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp8
-rw-r--r--src/network/access/qnetworkdiskcache.cpp4
-rw-r--r--src/network/access/qnetworkdiskcache.h7
-rw-r--r--src/network/access/qnetworkdiskcache_p.h4
-rw-r--r--src/network/kernel/kernel.pri11
-rw-r--r--src/network/kernel/qhostaddress.cpp114
-rw-r--r--src/network/kernel/qhostaddress_p.h27
-rw-r--r--src/network/kernel/qnetworkinterface.cpp4
-rw-r--r--src/network/kernel/qnetworkinterface_p.h2
-rw-r--r--src/network/kernel/qnetworkinterface_win.cpp91
-rw-r--r--src/network/kernel/qnetworkproxy.cpp10
-rw-r--r--src/network/kernel/qurlinfo.cpp4
-rw-r--r--src/network/kernel/qurlinfo_p.h7
-rw-r--r--src/network/socket/qnativesocketengine.cpp3
-rw-r--r--src/network/socket/qnativesocketengine_p.h2
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp44
-rw-r--r--src/network/socket/qnativesocketengine_win.cpp8
-rw-r--r--src/network/socket/qsocks5socketengine.cpp4
-rw-r--r--src/network/socket/qsocks5socketengine_p.h7
-rw-r--r--src/network/ssl/qsslsocket.cpp12
-rw-r--r--src/network/ssl/qsslsocket.h1
-rw-r--r--src/network/ssl/qsslsocket_openssl.cpp5
-rw-r--r--src/network/ssl/qsslsocket_openssl_symbols.cpp18
-rw-r--r--src/network/ssl/qsslsocket_p.h1
-rw-r--r--src/platformsupport/cglconvenience/cglconvenience.mm135
-rw-r--r--src/platformsupport/cglconvenience/cglconvenience.pro17
-rw-r--r--src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp20
-rw-r--r--src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp2
-rw-r--r--src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h2
-rw-r--r--src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp6
-rw-r--r--src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h2
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp3
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h5
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp30
-rw-r--r--src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h4
-rw-r--r--src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp6
-rw-r--r--src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h3
-rw-r--r--src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp7
-rw-r--r--src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h2
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp2
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h2
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp7
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h2
-rw-r--r--src/platformsupport/input/libinput/qlibinputhandler.cpp22
-rw-r--r--src/platformsupport/input/libinput/qlibinputhandler_p.h8
-rw-r--r--src/platformsupport/input/libinput/qlibinputkeyboard_p.h3
-rw-r--r--src/platformsupport/input/libinput/qlibinputpointer.cpp23
-rw-r--r--src/platformsupport/platformsupport.pro2
-rw-r--r--src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp11
-rw-r--r--src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h1
-rw-r--r--src/plugins/platforms/cocoa/cocoa.pro4
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.mm32
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm63
-rw-r--r--src/plugins/platforms/cocoa/qcocoahelpers.h4
-rw-r--r--src/plugins/platforms/cocoa/qcocoainputcontext.mm17
-rw-r--r--src/plugins/platforms/cocoa/qcocoakeymapper.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoakeymapper.mm11
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenubar.mm10
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h6
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm109
-rw-r--r--src/plugins/platforms/cocoa/qmultitouch_mac.mm19
-rw-r--r--src/plugins/platforms/cocoa/qmultitouch_mac_p.h2
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h11
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm165
-rw-r--r--src/plugins/platforms/cocoa/qnswindow.h2
-rw-r--r--src/plugins/platforms/cocoa/qnswindow.mm22
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp71
-rw-r--r--src/plugins/platforms/ios/qioseventdispatcher.mm2
-rw-r--r--src/plugins/platforms/ios/qiosmessagedialog.mm4
-rw-r--r--src/plugins/platforms/ios/qiosscreen.mm32
-rw-r--r--src/plugins/platforms/ios/qiostextinputoverlay.mm9
-rw-r--r--src/plugins/platforms/vnc/qvncintegration.cpp3
-rw-r--r--src/plugins/platforms/windows/openglblacklists/default.json17
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp17
-rw-r--r--src/plugins/platforms/windows/qwindowsdrag.cpp4
-rw-r--r--src/plugins/platforms/windows/qwindowsdropdataobject.cpp98
-rw-r--r--src/plugins/platforms/windows/qwindowsdropdataobject.h (renamed from src/platformsupport/cglconvenience/cglconvenience_p.h)40
-rw-r--r--src/plugins/platforms/windows/windows.pri2
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac.mm648
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac_p_p.h17
-rw-r--r--src/plugins/styles/windowsvista/qwindowsvistastyle.cpp18
-rw-r--r--src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h4
-rw-r--r--src/plugins/styles/windowsvista/qwindowsxpstyle.cpp32
-rw-r--r--src/printsupport/configure.json1
-rw-r--r--src/printsupport/dialogs/qprintdialog_unix.cpp4
-rw-r--r--src/sql/kernel/qsqldatabase.cpp8
-rw-r--r--src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp8
-rw-r--r--src/testlib/qtestcase.cpp2
-rw-r--r--src/testlib/qtestcase.h2
-rw-r--r--src/testlib/qtestcase.qdoc15
-rw-r--r--src/testlib/qtestmouse.h6
-rw-r--r--src/testlib/qtestsystem.h65
-rw-r--r--src/widgets/accessible/complexwidgets.cpp8
-rw-r--r--src/widgets/accessible/complexwidgets_p.h4
-rw-r--r--src/widgets/accessible/qaccessiblemenu.cpp18
-rw-r--r--src/widgets/accessible/qaccessiblemenu_p.h8
-rw-r--r--src/widgets/accessible/qaccessiblewidget.cpp4
-rw-r--r--src/widgets/accessible/qaccessiblewidgetfactory.cpp20
-rw-r--r--src/widgets/accessible/qaccessiblewidgets.cpp31
-rw-r--r--src/widgets/accessible/qaccessiblewidgets_p.h12
-rw-r--r--src/widgets/accessible/rangecontrols.cpp15
-rw-r--r--src/widgets/accessible/rangecontrols_p.h8
-rw-r--r--src/widgets/accessible/simplewidgets.cpp23
-rw-r--r--src/widgets/accessible/simplewidgets_p.h4
-rw-r--r--src/widgets/configure.json3
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp4
-rw-r--r--src/widgets/dialogs/qdialog.cpp20
-rw-r--r--src/widgets/dialogs/qdialog_p.h4
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp8
-rw-r--r--src/widgets/dialogs/qfiledialog_p.h2
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp26
-rw-r--r--src/widgets/dialogs/qmessagebox.h4
-rw-r--r--src/widgets/dialogs/qsidebar.cpp6
-rw-r--r--src/widgets/dialogs/qsidebar_p.h2
-rw-r--r--src/widgets/dialogs/qwizard.cpp8
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget.cpp4
-rw-r--r--src/widgets/itemviews/qabstractitemdelegate.cpp13
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp8
-rw-r--r--src/widgets/itemviews/qitemeditorfactory.cpp22
-rw-r--r--src/widgets/itemviews/qitemeditorfactory_p.h6
-rw-r--r--src/widgets/itemviews/qstyleditemdelegate.cpp6
-rw-r--r--src/widgets/kernel/qaction.cpp6
-rw-r--r--src/widgets/kernel/qaction.h2
-rw-r--r--src/widgets/kernel/qaction_p.h2
-rw-r--r--src/widgets/kernel/qapplication.cpp9
-rw-r--r--src/widgets/kernel/qdesktopwidget.cpp22
-rw-r--r--src/widgets/kernel/qlayout.cpp18
-rw-r--r--src/widgets/kernel/qlayoutitem.cpp2
-rw-r--r--src/widgets/kernel/qshortcut.cpp10
-rw-r--r--src/widgets/kernel/qtooltip.cpp8
-rw-r--r--src/widgets/kernel/qwidget.cpp39
-rw-r--r--src/widgets/kernel/qwidget_p.h1
-rw-r--r--src/widgets/kernel/qwindowcontainer.cpp6
-rw-r--r--src/widgets/styles/qcommonstyle.cpp68
-rw-r--r--src/widgets/styles/qfusionstyle.cpp6
-rw-r--r--src/widgets/styles/qpixmapstyle.cpp4
-rw-r--r--src/widgets/styles/qstylehelper.cpp4
-rw-r--r--src/widgets/styles/qstyleoption.cpp12
-rw-r--r--src/widgets/styles/qstyleoption.h13
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp74
-rw-r--r--src/widgets/styles/qwindowsstyle.cpp48
-rw-r--r--src/widgets/util/qcompleter.cpp6
-rw-r--r--src/widgets/util/qcompleter.h7
-rw-r--r--src/widgets/util/qcompleter_p.h6
-rw-r--r--src/widgets/util/qsystemtrayicon.cpp6
-rw-r--r--src/widgets/util/qsystemtrayicon.h2
-rw-r--r--src/widgets/util/qsystemtrayicon_p.h3
-rw-r--r--src/widgets/util/qsystemtrayicon_x11.cpp2
-rw-r--r--src/widgets/util/util.pri13
-rw-r--r--src/widgets/widgets/qabstractbutton.cpp38
-rw-r--r--src/widgets/widgets/qabstractbutton.h2
-rw-r--r--src/widgets/widgets/qabstractbutton_p.h2
-rw-r--r--src/widgets/widgets/qabstractscrollarea.cpp4
-rw-r--r--src/widgets/widgets/qabstractscrollarea.h4
-rw-r--r--src/widgets/widgets/qabstractscrollarea_p.h4
-rw-r--r--src/widgets/widgets/qabstractspinbox.cpp6
-rw-r--r--src/widgets/widgets/qabstractspinbox.h7
-rw-r--r--src/widgets/widgets/qabstractspinbox_p.h6
-rw-r--r--src/widgets/widgets/qbuttongroup.cpp4
-rw-r--r--src/widgets/widgets/qbuttongroup.h7
-rw-r--r--src/widgets/widgets/qbuttongroup_p.h6
-rw-r--r--src/widgets/widgets/qcombobox.cpp44
-rw-r--r--src/widgets/widgets/qcombobox.h11
-rw-r--r--src/widgets/widgets/qcombobox_p.h6
-rw-r--r--src/widgets/widgets/qdockwidget.cpp12
-rw-r--r--src/widgets/widgets/qeffects.cpp3
-rw-r--r--src/widgets/widgets/qeffects_p.h5
-rw-r--r--src/widgets/widgets/qkeysequenceedit.cpp4
-rw-r--r--src/widgets/widgets/qkeysequenceedit.h6
-rw-r--r--src/widgets/widgets/qkeysequenceedit_p.h6
-rw-r--r--src/widgets/widgets/qlabel_p.h2
-rw-r--r--src/widgets/widgets/qlineedit.cpp17
-rw-r--r--src/widgets/widgets/qlineedit.h11
-rw-r--r--src/widgets/widgets/qlineedit_p.cpp11
-rw-r--r--src/widgets/widgets/qlineedit_p.h9
-rw-r--r--src/widgets/widgets/qmainwindow.cpp19
-rw-r--r--src/widgets/widgets/qmainwindow.h11
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp3
-rw-r--r--src/widgets/widgets/qmainwindowlayout_p.h6
-rw-r--r--src/widgets/widgets/qmdiarea.cpp11
-rw-r--r--src/widgets/widgets/qmdiarea.h6
-rw-r--r--src/widgets/widgets/qmdiarea_p.h4
-rw-r--r--src/widgets/widgets/qmdisubwindow.cpp98
-rw-r--r--src/widgets/widgets/qmdisubwindow.h11
-rw-r--r--src/widgets/widgets/qmdisubwindow_p.h24
-rw-r--r--src/widgets/widgets/qmenu.cpp61
-rw-r--r--src/widgets/widgets/qmenu.h7
-rw-r--r--src/widgets/widgets/qmenu_mac.mm10
-rw-r--r--src/widgets/widgets/qmenu_p.h9
-rw-r--r--src/widgets/widgets/qmenubar.cpp10
-rw-r--r--src/widgets/widgets/qmenubar.h7
-rw-r--r--src/widgets/widgets/qmenubar_p.h5
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp6
-rw-r--r--src/widgets/widgets/qplaintextedit.h6
-rw-r--r--src/widgets/widgets/qplaintextedit_p.h8
-rw-r--r--src/widgets/widgets/qpushbutton.cpp14
-rw-r--r--src/widgets/widgets/qpushbutton.h6
-rw-r--r--src/widgets/widgets/qpushbutton_p.h2
-rw-r--r--src/widgets/widgets/qradiobutton.cpp2
-rw-r--r--src/widgets/widgets/qscrollarea.cpp4
-rw-r--r--src/widgets/widgets/qscrollarea.h7
-rw-r--r--src/widgets/widgets/qscrollarea_p.h6
-rw-r--r--src/widgets/widgets/qscrollbar.cpp6
-rw-r--r--src/widgets/widgets/qsizegrip.cpp8
-rw-r--r--src/widgets/widgets/qsizegrip.h5
-rw-r--r--src/widgets/widgets/qslider.cpp3
-rw-r--r--src/widgets/widgets/qslider.h7
-rw-r--r--src/widgets/widgets/qspinbox.cpp4
-rw-r--r--src/widgets/widgets/qspinbox.h7
-rw-r--r--src/widgets/widgets/qstackedwidget.cpp4
-rw-r--r--src/widgets/widgets/qstackedwidget.h7
-rw-r--r--src/widgets/widgets/qstatusbar.cpp24
-rw-r--r--src/widgets/widgets/qtextedit.cpp11
-rw-r--r--src/widgets/widgets/qtextedit.h6
-rw-r--r--src/widgets/widgets/qtextedit_p.h8
-rw-r--r--src/widgets/widgets/qtoolbar.cpp2
-rw-r--r--src/widgets/widgets/qtoolbutton.cpp31
-rw-r--r--src/widgets/widgets/qtoolbutton.h8
-rw-r--r--src/widgets/widgets/qwidgetanimator.cpp8
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp22
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol_p.h12
-rw-r--r--src/widgets/widgets/qwidgetresizehandler.cpp5
-rw-r--r--src/widgets/widgets/qwidgetresizehandler_p.h4
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp16
-rw-r--r--src/widgets/widgets/qwidgettextcontrol_p.h6
-rw-r--r--src/widgets/widgets/qwidgettextcontrol_p_p.h2
-rw-r--r--src/widgets/widgets/widgets.pri182
-rw-r--r--sync.profile1
-rw-r--r--tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp56
-rw-r--r--tests/auto/corelib/io/qdir/tst_qdir.cpp4
-rw-r--r--tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp12
-rw-r--r--tests/auto/corelib/kernel/kernel.pro3
-rw-r--r--tests/auto/corelib/thread/qmutex/tst_qmutex.cpp3
-rw-r--r--tests/auto/corelib/tools/qmacautoreleasepool/qmacautoreleasepool.pro4
-rw-r--r--tests/auto/corelib/tools/qmacautoreleasepool/tst_qmacautoreleasepool.mm111
-rw-r--r--tests/auto/corelib/tools/qstringview/tst_qstringview.cpp44
-rw-r--r--tests/auto/corelib/tools/tools.pro1
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp13
-rw-r--r--tests/auto/gui/qopengl/BLACKLIST2
-rw-r--r--tests/auto/network/access/qftp/tst_qftp.cpp4
-rw-r--r--tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp9
-rw-r--r--tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp33
-rw-r--r--tests/auto/network/kernel/qnetworkproxyfactory/BLACKLIST2
-rw-r--r--tests/auto/network/kernel/qnetworkproxyfactory/qnetworkproxyfactory.pro2
-rw-r--r--tests/auto/network/kernel/qnetworkproxyfactory/tst_qnetworkproxyfactory.cpp4
-rw-r--r--tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp4
-rw-r--r--tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp2
-rw-r--r--tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp6
-rw-r--r--tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp23
-rw-r--r--tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp4
-rw-r--r--tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp4
-rw-r--r--tests/auto/sql/kernel/qsqldriver/tst_qsqldriver.cpp8
-rw-r--r--tests/auto/widgets/dialogs/qdialog/tst_qdialog.cpp16
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/BLACKLIST2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/BLACKLIST2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp48
-rw-r--r--tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST2
-rw-r--r--tests/auto/widgets/kernel/qwidget/BLACKLIST1
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp216
-rw-r--r--tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp6
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/main.cpp5
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/qfilesystemiterator.cpp5
-rw-r--r--tests/benchmarks/dbus/dbus.pro4
-rw-r--r--tests/manual/cocoa/qt_on_cocoa/main.mm43
-rw-r--r--tests/manual/cocoa/qt_on_cocoa/rasterwindow.cpp27
-rw-r--r--tests/manual/cocoa/qt_on_cocoa/rasterwindow.h3
385 files changed, 4138 insertions, 3758 deletions
diff --git a/config_help.txt b/config_help.txt
index d1b0ac56b0..f06584a480 100644
--- a/config_help.txt
+++ b/config_help.txt
@@ -144,6 +144,7 @@ Build options:
-ltcg ................ Use Link Time Code Generation [no]
-use-gold-linker ..... Use the GNU gold linker [auto]
-incredibuild-xge .... Use the IncrediBuild XGE [no] (Windows only)
+ -ccache .............. Use the ccache compiler cache [no] (Unix only)
-make-tool <tool> .... Use <tool> to build qmake [nmake] (Windows only)
-mp .................. Use multiple processors for compilation (MSVC only)
diff --git a/configure.json b/configure.json
index 803178a597..26e1572f32 100644
--- a/configure.json
+++ b/configure.json
@@ -61,6 +61,7 @@
"avx2": "boolean",
"avx512": { "type": "boolean", "name": "avx512f" },
"c++std": "cxxstd",
+ "ccache": { "type": "boolean", "name": "ccache" },
"commercial": "void",
"compile-examples": { "type": "boolean", "name": "compile_examples" },
"confirm-license": "void",
@@ -635,6 +636,11 @@
"label": "IncrediBuild",
"type": "files",
"files": [ "BuildConsole.exe", "xgConsole.exe" ]
+ },
+ "ccache": {
+ "label": "ccache",
+ "type": "files",
+ "files": [ "ccache" ]
}
},
@@ -1246,6 +1252,12 @@
"condition": "tests.incredibuild_xge",
"output": [ "publicConfig" ]
},
+ "ccache": {
+ "label": "Using ccache",
+ "autoDetect": false,
+ "condition": "config.unix && tests.ccache",
+ "output": [ "privateConfig" ]
+ },
"msvc_mp": {
"label": "Use multiple processors when compiling with MSVC",
"emitIf": "config.msvc",
@@ -1353,6 +1365,11 @@ Configure with '-qreal float' to create a build that is binary-compatible with 5
"type": "firstAvailableFeature",
"args": "c++1z c++14 c++11"
},
+ {
+ "type": "feature",
+ "args": "ccache",
+ "condition": "config.unix"
+ },
"use_gold_linker",
{
"type": "feature",
diff --git a/dist/changes-5.6.3 b/dist/changes-5.6.3
new file mode 100644
index 0000000000..6bda3cefe4
--- /dev/null
+++ b/dist/changes-5.6.3
@@ -0,0 +1,288 @@
+Qt 5.6.3 is a bug-fix release. It maintains both forward and backward
+compatibility (source and binary) with previous Qt 5.6.x releases.
+
+For more details, refer to the online documentation included in this
+distribution. The documentation is also available online:
+
+ http://doc.qt.io/qt-5/index.html
+
+The Qt version 5.6 series is binary compatible with the 5.5.x series.
+Applications compiled for 5.5 will continue to run with 5.6.
+
+Some of the changes listed in this file include issue tracking numbers
+corresponding to tasks in the Qt Bug Tracker:
+
+ https://bugreports.qt.io/
+
+Each of these identifiers can be entered in the bug tracker to obtain more
+information about a particular change.
+
+*****************************************************************************
+* License Changes *
+*****************************************************************************
+
+ - Static libraries that are linked into executables (winmain and
+ qopenglextensions) are now licensed under BSD _and_ commercial licenses.
+
+******************************************************************************
+* Important Behavior Changes *
+******************************************************************************
+
+ - QPluginLoader:
+ * [QTBUG-49061] QPluginLoader no longer performs the actual unloading of
+ the plugin either on destruction or when unload() is called. This does
+ not affect QLibrary and QLibrary::unload().
+
+******************************************************************************
+* Library *
+******************************************************************************
+
+QtCore
+------
+
+ - QDir:
+ * [QTBUG-58390] Fixed the implementation of mkpath() to not attempt to
+ mkdir directories that already exist, especially those in automount
+ filesystems (like /home).
+
+ - QHash / QMultiHash:
+ * [QTBUG-60395] Fixed a bug that caused operator== not to return true if
+ two containers had the elements with duplicate keys but in different
+ order.
+
+ - QLocale:
+ * [QTBUG-59159] Fixed the parsing of day-of-week names that start with the
+ name of another day.
+
+ - QObject:
+ * [QTBUG-59500] disconnectNotify() is now called when a connection is
+ disconnected using its QMetaObject::Connection handle.
+ * [QTBUG-52439] Fixed a bug that would cause applications compiled with the
+ Intel compiler to fail to connect signals and slots.
+
+ - QUrl:
+ * [QTBUG-60364] Fixed a bug that caused certain domain names that look
+ like Internationalized Domain Names to become corrupt in decoded forms
+ of QUrl, notably toString() and toDisplayString().
+ * Updated the table of valid top level domains
+
+ - QVarLengthArray:
+ * Fixed a bug involving appending an item already in the container to
+ the container again.
+ * [QTBUG-57277] Fixed a crash when initializing the array with an empty
+ std::initializer_list.
+
+QtSql
+-----
+
+ - MySql
+ * Fixed the build of MySql plugin with MySql 5.0
+ * [QTBUG-53397] Fixed the parsing of tinyint(1) when used via prepared
+ statements.
+
+ - PostgreSQL:
+ * [QTBUG-59524] Fixed datetime formats when the system locale doesn't use
+ arabic numerals
+
+QtDBus
+------
+
+ - QDBusServer
+ * [QTBUG-55087] Fixed a bug causing certain messages that arrive soon after
+ the client connects not to be processed.
+
+QtNetwork
+---------
+
+ - QNetworkInterface
+ * Fixed the reporting of virtual interfaces on Linux.
+
+ - QSslSocket
+ * [QTBUG-43388][QTBUG-55170] Fixed a bug that caused the read buffer's max
+ size not to be respected when using SecureTransport
+ * [QTBUG-49554] Made sure that the QSslConfiguration is up-to-date when the
+ QNetworkReply::encrypted() signal is emitted.
+
+QtGui
+-----
+
+ - Various fixes to our high DPI support.
+
+ - CSS parser:
+ * [QTBUG-53919] Fixed a crash while parsing malformed CSS.
+
+ - PDF writer:
+ * [QTBUG-56489] Monochrome images are now handled correctly.
+
+ - QImage:
+ * Fixed a crash when rendering to GrayScale8 images.
+ * [QTBUG-56252] Fixed an illegal memory access when rotating images.
+ * [QTBUG-59211] Improved rejection of corrupt images with invalid header
+ info.
+
+ - QMatrix4x4:
+ * operator*=() now calculates the correct result even if the RHS and LHS
+ are the same object.
+
+ - QPainter
+ * [QTBUG-14614] Fixed a read-after-free when using gradients.
+ * [QTBUG-56969] Fixed painting artifacts for certain dashed lines.
+
+ - Text:
+ * [QTBUG-55222] Always return a correct list of fallback fonts
+ * [QTBUG-55255][QTBUG-56714] Trailing whitespace are now properly taken
+ into account when shaping lines
+ * [QTBUG-53911] Fixed a crash that could happen if you were doing many
+ different text layouts with different fonts and superscript or
+ subscript alignment.
+ * [QTBUG-56659] Fixed a regression where raster fonts on Windows were
+ detected as smoothly scalable and thus rendering with said fonts in Qt
+ Quick would break.
+ * [QTBUG-51223] Fixed synthesized oblique for non-latin text on
+ platforms using the basic font database, such as Android.
+ * [QTBUG-56714] Fixed a bug where a no-break space would sometimes cause
+ the first character of the containing line to not be displayed.
+ * [QTBUG-48005] Fixed clipping errors and too small bounding rects for
+ some right-to-left text.
+ * [QTBUG-57241] Fixed a crash for very tall glyphs.
+ * [QTBUG-55569] Fixed Myanmar rendering with some fonts.
+ * [QTBUG-56659] Fixed the reporting of whether fonts are smoothly scalable
+ on Windows.
+ * [QTBUG-58364][QTBUG-42074][QTBUG-57003] Formatting characters are now
+ accepted as valid input.
+
+QtWidgets
+---------
+
+ - Input:
+ * [QTBUG-42074][QTBUG-57003] Characters in Private Use Area, as well as
+ zero-width joiners and zero-width non-joiners are now accepted as input
+ in QLineEdit and QTextEdit.
+
+ - QDockWidget:
+ * [QTBUG-7460][QTBUG-52354] Size of widgets no longer changed just because
+ they are in a floating dock.
+ * [QTBUG-58036] Dock widgets now have the correct parent after a drag.
+ * [QTBUG-58049] Fixed clearing the dock indicator when not over a floating
+ dock group window.
+
+ - QMainWindow:
+ * [QTBUG-56628] Fixed crash using takeCentralWidget when the central
+ widget was not set.
+
+ - QPixmapStyle:
+ * Now handles progress bars with minimum != 0 correctly.
+
+ - QPopup
+ * [QTBUG-57292] Popups blocked by modal dialogs are now properly closed.
+
+ - QTextEdit
+ * [QTBUG-55758] Placeholder text is no longer shown while composing text.
+
+ - QTooltip:
+ * [QTBUG-55523] QTooltip is now properly hidden when a close event is
+ received.
+ * [QTBUG-55523] Tooltips no longer prevent closing of the app on
+ lastWindowClosed()
+
+ - QWidget:
+ * [QTBUG-50589] Show and hide events are now properly sent to children on
+ minimize/restore.
+ * [QTBUG-53068] Fixed enter/leave events on popup menus.
+
+ - Style sheets:
+ * [QTBUG-55597] Now honors the font set on HeaderView section.
+
+******************************************************************************
+* Platform-specific Changes *
+******************************************************************************
+
+Android
+-------
+
+ - [QTBUG-44697] Removed old work-around which was causing OpenGL shader
+ compilation to fail on updated Android emulators.
+
+Darwin
+------
+
+ - [QTBUG-61034] QT_NO_EXCEPTIONS is now correctly set for Objective C++
+ source files.
+ - [QTBUG-57165] Made QDir::tempPath() return the same directory as
+ NSTemporaryDirectory, instead of a hardcoded "/tmp".
+ - [QTBUG-55896] Fixed a bug that would cause QFileSystemWatcher to fail to
+ watch certain paths containing non-ASCII characters.
+ - [QTBUG-56124] Fixed a bug that would cause data corruption in QSettings
+ when storing QStrings containing NULs, when storing to native format.
+
+ - iOS specific:
+ * Starting from iOS 10, Apple requires all apps that need access to photos
+ to have the key 'NSPhotoLibraryUsageDescription' in the Info.plist.
+ Therefore, to get the same support in Qt (when, e.g., using a file
+ dialog), the Info.plist assigned to QMAKE_INFO_PLIST will need this key
+ as well.
+ * [QTBUG-49893] The shortcuts bar on iPad is now hidden when showing menus.
+
+ - macOS specific:
+ * Speech to text dictation now works for Qt text input.
+ * Various bug fixes to menu bar handling.
+
+QNX
+---
+
+ - Qt can now handle more than 256 file descriptors open in the same process,
+ up to a limit of 1000.
+
+WinRT
+-----
+
+ - Various fixes in our event and timer handling.
+
+X11
+---
+
+ - [QTBUG-55942] Qt::WindowNoState event is no longer sent when hiding
+ minimized windows.
+ - [QTBUG-49645] Fixed keyboard modifier state for drops from external apps.
+ - [QTBUG-48795] Fixed the keyboard state when processing key events.
+
+******************************************************************************
+* Compiler Specific Changes *
+******************************************************************************
+
+Visual Studio
+-------------
+
+ - Visual Studio 2017 is now supported.
+ - [QTBUG-56594] PDB files are now properly generated even for static builds.
+
+******************************************************************************
+* Tools *
+******************************************************************************
+
+configure
+---------
+
+ - Fixed builds that explicitly asked for -sdk iphoneos.
+ - [QTBUG-56388] Fixed the detection of the Microsoft compiler version when
+ the CL environment variable was set or when the compiler was configured to
+ another language (other than English).
+
+qmake
+-----
+
+ - [QTBUG-55505] Fixed an issue with iOS when the project path had a
+ whitespace.
+ - [QTBUG-56289] When cross-compiling on Windows to Unix targets, qmake no
+ longer generates chmod calls.
+ - [QTBUG-53905] Fixed qmake not to run moc twice on Objective C++ sources
+ listed in the OBJECTIVE_SOURCES variable.
+ - [QTBUG-56507] Fixed builds where a lex source refers to a file generated
+ by yacc.
+ - [QTBUG-57090][Darwin] Fixed the installation of asset catalog files.
+
+qdbusxml2cpp
+------------
+
+ - [QTBUG-21577] Fixed the generation of signals when the direction argument
+ was inverted from expected.
diff --git a/examples/corelib/ipc/localfortuneclient/client.cpp b/examples/corelib/ipc/localfortuneclient/client.cpp
index d5a1525769..8d415f73aa 100644
--- a/examples/corelib/ipc/localfortuneclient/client.cpp
+++ b/examples/corelib/ipc/localfortuneclient/client.cpp
@@ -54,45 +54,45 @@
#include "client.h"
Client::Client(QWidget *parent)
- : QDialog(parent)
+ : QDialog(parent),
+ hostLineEdit(new QLineEdit("fortune")),
+ getFortuneButton(new QPushButton(tr("Get Fortune"))),
+ statusLabel(new QLabel(tr("This examples requires that you run the "
+ "Local Fortune Server example as well."))),
+ socket(new QLocalSocket(this))
{
- hostLabel = new QLabel(tr("&Server name:"));
- hostLineEdit = new QLineEdit("fortune");
-
+ setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
+ QLabel *hostLabel = new QLabel(tr("&Server name:"));
hostLabel->setBuddy(hostLineEdit);
- statusLabel = new QLabel(tr("This examples requires that you run the "
- "Fortune Server example as well."));
statusLabel->setWordWrap(true);
- getFortuneButton = new QPushButton(tr("Get Fortune"));
getFortuneButton->setDefault(true);
+ QPushButton *quitButton = new QPushButton(tr("Quit"));
- quitButton = new QPushButton(tr("Quit"));
-
- buttonBox = new QDialogButtonBox;
+ QDialogButtonBox *buttonBox = new QDialogButtonBox;
buttonBox->addButton(getFortuneButton, QDialogButtonBox::ActionRole);
buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);
- socket = new QLocalSocket(this);
+ in.setDevice(socket);
+ in.setVersion(QDataStream::Qt_5_10);
- connect(hostLineEdit, SIGNAL(textChanged(QString)),
- this, SLOT(enableGetFortuneButton()));
- connect(getFortuneButton, SIGNAL(clicked()),
- this, SLOT(requestNewFortune()));
- connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
- connect(socket, SIGNAL(readyRead()), this, SLOT(readFortune()));
- connect(socket, SIGNAL(error(QLocalSocket::LocalSocketError)),
- this, SLOT(displayError(QLocalSocket::LocalSocketError)));
+ connect(hostLineEdit, &QLineEdit::textChanged,
+ this, &Client::enableGetFortuneButton);
+ connect(getFortuneButton, &QPushButton::clicked,
+ this, &Client::requestNewFortune);
+ connect(quitButton, &QPushButton::clicked, this, &Client::close);
+ connect(socket, &QLocalSocket::readyRead, this, &Client::readFortune);
+ connect(socket, QOverload<QLocalSocket::LocalSocketError>::of(&QLocalSocket::error),
+ this, &Client::displayError);
- QGridLayout *mainLayout = new QGridLayout;
+ QGridLayout *mainLayout = new QGridLayout(this);
mainLayout->addWidget(hostLabel, 0, 0);
mainLayout->addWidget(hostLineEdit, 0, 1);
mainLayout->addWidget(statusLabel, 2, 0, 1, 2);
mainLayout->addWidget(buttonBox, 3, 0, 1, 2);
- setLayout(mainLayout);
- setWindowTitle(tr("Fortune Client"));
+ setWindowTitle(QGuiApplication::applicationDisplayName());
hostLineEdit->setFocus();
}
@@ -106,11 +106,9 @@ void Client::requestNewFortune()
void Client::readFortune()
{
- QDataStream in(socket);
- in.setVersion(QDataStream::Qt_4_0);
-
if (blockSize == 0) {
- // Relies on the fact that QDataStream format streams a quint32 into sizeof(quint32) bytes
+ // Relies on the fact that QDataStream serializes a quint32 into
+ // sizeof(quint32) bytes
if (socket->bytesAvailable() < (int)sizeof(quint32))
return;
in >> blockSize;
@@ -123,7 +121,7 @@ void Client::readFortune()
in >> nextFortune;
if (nextFortune == currentFortune) {
- QTimer::singleShot(0, this, SLOT(requestNewFortune()));
+ QTimer::singleShot(0, this, &Client::requestNewFortune);
return;
}
@@ -136,21 +134,22 @@ void Client::displayError(QLocalSocket::LocalSocketError socketError)
{
switch (socketError) {
case QLocalSocket::ServerNotFoundError:
- QMessageBox::information(this, tr("Fortune Client"),
- tr("The host was not found. Please check the "
- "host name and port settings."));
+ QMessageBox::information(this, tr("Local Fortune Client"),
+ tr("The host was not found. Please make sure "
+ "that the server is running and that the "
+ "server name is correct."));
break;
case QLocalSocket::ConnectionRefusedError:
- QMessageBox::information(this, tr("Fortune Client"),
+ QMessageBox::information(this, tr("Local Fortune Client"),
tr("The connection was refused by the peer. "
"Make sure the fortune server is running, "
- "and check that the host name and port "
- "settings are correct."));
+ "and check that the server name "
+ "is correct."));
break;
case QLocalSocket::PeerClosedError:
break;
default:
- QMessageBox::information(this, tr("Fortune Client"),
+ QMessageBox::information(this, tr("Local Fortune Client"),
tr("The following error occurred: %1.")
.arg(socket->errorString()));
}
diff --git a/examples/corelib/ipc/localfortuneclient/client.h b/examples/corelib/ipc/localfortuneclient/client.h
index 8e628efcee..0c1ede94c9 100644
--- a/examples/corelib/ipc/localfortuneclient/client.h
+++ b/examples/corelib/ipc/localfortuneclient/client.h
@@ -52,11 +52,11 @@
#define CLIENT_H
#include <QDialog>
+#include <QDataStream>
#include <qlocalsocket.h>
QT_BEGIN_NAMESPACE
-class QDialogButtonBox;
class QLabel;
class QLineEdit;
class QPushButton;
@@ -68,7 +68,7 @@ class Client : public QDialog
Q_OBJECT
public:
- Client(QWidget *parent = 0);
+ explicit Client(QWidget *parent = nullptr);
private slots:
void requestNewFortune();
@@ -77,16 +77,15 @@ private slots:
void enableGetFortuneButton();
private:
- QLabel *hostLabel;
QLineEdit *hostLineEdit;
- QLabel *statusLabel;
QPushButton *getFortuneButton;
- QPushButton *quitButton;
- QDialogButtonBox *buttonBox;
+ QLabel *statusLabel;
QLocalSocket *socket;
- QString currentFortune;
+ QDataStream in;
quint32 blockSize;
+
+ QString currentFortune;
};
#endif
diff --git a/examples/corelib/ipc/localfortuneclient/main.cpp b/examples/corelib/ipc/localfortuneclient/main.cpp
index dd13a05be9..ed5cf4c569 100644
--- a/examples/corelib/ipc/localfortuneclient/main.cpp
+++ b/examples/corelib/ipc/localfortuneclient/main.cpp
@@ -55,6 +55,7 @@
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
+ QGuiApplication::setApplicationDisplayName(Client::tr("Local Fortune Client"));
Client client;
client.show();
return app.exec();
diff --git a/examples/corelib/ipc/localfortuneserver/main.cpp b/examples/corelib/ipc/localfortuneserver/main.cpp
index cd066a0acd..6f8ec539fe 100644
--- a/examples/corelib/ipc/localfortuneserver/main.cpp
+++ b/examples/corelib/ipc/localfortuneserver/main.cpp
@@ -58,8 +58,8 @@
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
+ QGuiApplication::setApplicationDisplayName(Server::tr("Local Fortune Server"));
Server server;
server.show();
- qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
return app.exec();
}
diff --git a/examples/corelib/ipc/localfortuneserver/server.cpp b/examples/corelib/ipc/localfortuneserver/server.cpp
index 2eee4760be..9b8b08bd17 100644
--- a/examples/corelib/ipc/localfortuneserver/server.cpp
+++ b/examples/corelib/ipc/localfortuneserver/server.cpp
@@ -60,22 +60,21 @@
Server::Server(QWidget *parent)
: QDialog(parent)
{
- statusLabel = new QLabel;
- statusLabel->setWordWrap(true);
- quitButton = new QPushButton(tr("Quit"));
- quitButton->setAutoDefault(false);
+ setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
server = new QLocalServer(this);
if (!server->listen("fortune")) {
- QMessageBox::critical(this, tr("Fortune Server"),
+ QMessageBox::critical(this, tr("Local Fortune Server"),
tr("Unable to start the server: %1.")
.arg(server->errorString()));
close();
return;
}
+ QLabel *statusLabel = new QLabel;
+ statusLabel->setWordWrap(true);
statusLabel->setText(tr("The server is running.\n"
- "Run the Fortune Client example now."));
+ "Run the Local Fortune Client example now."));
fortunes << tr("You've been leading a dog's life. Stay off the furniture.")
<< tr("You've got to think about tomorrow.")
@@ -85,35 +84,36 @@ Server::Server(QWidget *parent)
<< tr("You cannot kill time without injuring eternity.")
<< tr("Computers are not intelligent. They only think they are.");
- connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
- connect(server, SIGNAL(newConnection()), this, SLOT(sendFortune()));
+ QPushButton *quitButton = new QPushButton(tr("Quit"));
+ quitButton->setAutoDefault(false);
+ connect(quitButton, &QPushButton::clicked, this, &Server::close);
+ connect(server, &QLocalServer::newConnection, this, &Server::sendFortune);
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addStretch(1);
buttonLayout->addWidget(quitButton);
buttonLayout->addStretch(1);
- QVBoxLayout *mainLayout = new QVBoxLayout;
+ QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(statusLabel);
mainLayout->addLayout(buttonLayout);
- setLayout(mainLayout);
- setWindowTitle(tr("Fortune Server"));
+ setWindowTitle(QGuiApplication::applicationDisplayName());
}
void Server::sendFortune()
{
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
- out.setVersion(QDataStream::Qt_4_0);
- out << (quint32)0;
- out << fortunes.at(qrand() % fortunes.size());
- out.device()->seek(0);
- out << (quint32)(block.size() - sizeof(quint32));
+ out.setVersion(QDataStream::Qt_5_10);
+ const int fortuneIndex = QRandomGenerator::bounded(0, fortunes.size());
+ const QString &message = fortunes.at(fortuneIndex);
+ out << quint32(message.size());
+ out << message;
QLocalSocket *clientConnection = server->nextPendingConnection();
- connect(clientConnection, SIGNAL(disconnected()),
- clientConnection, SLOT(deleteLater()));
+ connect(clientConnection, &QLocalSocket::disconnected,
+ clientConnection, &QLocalSocket::deleteLater);
clientConnection->write(block);
clientConnection->flush();
diff --git a/examples/corelib/ipc/localfortuneserver/server.h b/examples/corelib/ipc/localfortuneserver/server.h
index c77b4e8127..6b90ba5932 100644
--- a/examples/corelib/ipc/localfortuneserver/server.h
+++ b/examples/corelib/ipc/localfortuneserver/server.h
@@ -64,14 +64,12 @@ class Server : public QDialog
Q_OBJECT
public:
- Server(QWidget *parent = 0);
+ explicit Server(QWidget *parent = nullptr);
private slots:
void sendFortune();
private:
- QLabel *statusLabel;
- QPushButton *quitButton;
QLocalServer *server;
QStringList fortunes;
};
diff --git a/examples/network/broadcastsender/sender.cpp b/examples/network/broadcastsender/sender.cpp
index 344f898683..ee4896e9dd 100644
--- a/examples/network/broadcastsender/sender.cpp
+++ b/examples/network/broadcastsender/sender.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -50,6 +50,7 @@
#include <QtWidgets>
#include <QtNetwork>
+#include <QtCore>
#include "sender.h"
@@ -60,23 +61,21 @@ Sender::Sender(QWidget *parent)
statusLabel->setWordWrap(true);
startButton = new QPushButton(tr("&Start"));
- quitButton = new QPushButton(tr("&Quit"));
+ auto quitButton = new QPushButton(tr("&Quit"));
- buttonBox = new QDialogButtonBox;
+ auto buttonBox = new QDialogButtonBox;
buttonBox->addButton(startButton, QDialogButtonBox::ActionRole);
buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);
- timer = new QTimer(this);
//! [0]
udpSocket = new QUdpSocket(this);
//! [0]
- messageNo = 1;
- connect(startButton, SIGNAL(clicked()), this, SLOT(startBroadcasting()));
- connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
- connect(timer, SIGNAL(timeout()), this, SLOT(broadcastDatagram()));
+ connect(startButton, &QPushButton::clicked, this, &Sender::startBroadcasting);
+ connect(quitButton, &QPushButton::clicked, this, &Sender::close);
+ connect(&timer, &QTimer::timeout, this, &Sender::broadcastDatagram);
- QVBoxLayout *mainLayout = new QVBoxLayout;
+ auto mainLayout = new QVBoxLayout;
mainLayout->addWidget(statusLabel);
mainLayout->addWidget(buttonBox);
setLayout(mainLayout);
@@ -87,7 +86,7 @@ Sender::Sender(QWidget *parent)
void Sender::startBroadcasting()
{
startButton->setEnabled(false);
- timer->start(1000);
+ timer.start(1000);
}
void Sender::broadcastDatagram()
@@ -95,8 +94,7 @@ void Sender::broadcastDatagram()
statusLabel->setText(tr("Now broadcasting datagram %1").arg(messageNo));
//! [1]
QByteArray datagram = "Broadcast message " + QByteArray::number(messageNo);
- udpSocket->writeDatagram(datagram.data(), datagram.size(),
- QHostAddress::Broadcast, 45454);
+ udpSocket->writeDatagram(datagram, QHostAddress::Broadcast, 45454);
//! [1]
++messageNo;
}
diff --git a/examples/network/broadcastsender/sender.h b/examples/network/broadcastsender/sender.h
index e9c1076dd3..f91c7769ec 100644
--- a/examples/network/broadcastsender/sender.h
+++ b/examples/network/broadcastsender/sender.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -52,12 +52,11 @@
#define SENDER_H
#include <QWidget>
+#include <QTimer>
QT_BEGIN_NAMESPACE
-class QDialogButtonBox;
class QLabel;
class QPushButton;
-class QTimer;
class QUdpSocket;
QT_END_NAMESPACE
@@ -66,20 +65,18 @@ class Sender : public QWidget
Q_OBJECT
public:
- Sender(QWidget *parent = 0);
+ explicit Sender(QWidget *parent = nullptr);
private slots:
void startBroadcasting();
void broadcastDatagram();
private:
- QLabel *statusLabel;
- QPushButton *startButton;
- QPushButton *quitButton;
- QDialogButtonBox *buttonBox;
- QUdpSocket *udpSocket;
- QTimer *timer;
- int messageNo;
+ QLabel *statusLabel = nullptr;
+ QPushButton *startButton = nullptr;
+ QUdpSocket *udpSocket = nullptr;
+ QTimer timer;
+ int messageNo = 1;
};
#endif
diff --git a/examples/network/doc/images/http-example.png b/examples/network/doc/images/http-example.png
index 16b0539b1b..c5f3ef1649 100644
--- a/examples/network/doc/images/http-example.png
+++ b/examples/network/doc/images/http-example.png
Binary files differ
diff --git a/examples/network/http/httpwindow.cpp b/examples/network/http/httpwindow.cpp
index 9640907673..ec90b8f7fe 100644
--- a/examples/network/http/httpwindow.cpp
+++ b/examples/network/http/httpwindow.cpp
@@ -55,12 +55,12 @@
#include "httpwindow.h"
#include "ui_authenticationdialog.h"
-#ifndef QT_NO_SSL
-static const char defaultUrl[] = "https://www.qt.io/";
+#if QT_CONFIG(ssl)
+const char defaultUrl[] = "https://www.qt.io/";
#else
-static const char defaultUrl[] = "http://www.qt.io/";
+const char defaultUrl[] = "http://www.qt.io/";
#endif
-static const char defaultFileName[] = "index.html";
+const char defaultFileName[] = "index.html";
ProgressDialog::ProgressDialog(const QUrl &url, QWidget *parent)
: QProgressDialog(parent)
@@ -71,6 +71,7 @@ ProgressDialog::ProgressDialog(const QUrl &url, QWidget *parent)
setMinimum(0);
setValue(0);
setMinimumDuration(0);
+ setMinimumSize(QSize(400, 75));
}
void ProgressDialog::networkReplyProgress(qint64 bytesRead, qint64 totalBytes)
@@ -174,15 +175,22 @@ void HttpWindow::downloadFile()
if (fileName.isEmpty())
fileName = defaultFileName;
QString downloadDirectory = QDir::cleanPath(downloadDirectoryLineEdit->text().trimmed());
- if (!downloadDirectory.isEmpty() && QFileInfo(downloadDirectory).isDir())
+ bool useDirectory = !downloadDirectory.isEmpty() && QFileInfo(downloadDirectory).isDir();
+ if (useDirectory)
fileName.prepend(downloadDirectory + '/');
if (QFile::exists(fileName)) {
if (QMessageBox::question(this, tr("Overwrite Existing File"),
- tr("There already exists a file called %1 in "
- "the current directory. Overwrite?").arg(fileName),
- QMessageBox::Yes|QMessageBox::No, QMessageBox::No)
- == QMessageBox::No)
+ tr("There already exists a file called %1%2."
+ " Overwrite?")
+ .arg(fileName,
+ useDirectory
+ ? QString()
+ : QStringLiteral(" in the current directory")),
+ QMessageBox::Yes | QMessageBox::No,
+ QMessageBox::No)
+ == QMessageBox::No) {
return;
+ }
QFile::remove(fileName);
}
@@ -252,7 +260,9 @@ void HttpWindow::httpFinished()
if (QMessageBox::question(this, tr("Redirect"),
tr("Redirect to %1 ?").arg(redirectedUrl.toString()),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) {
+ QFile::remove(fi.absoluteFilePath());
downloadButton->setEnabled(true);
+ statusLabel->setText(tr("Download failed:\nRedirect rejected."));
return;
}
file = openFileForWrite(fi.absoluteFilePath());
@@ -286,7 +296,7 @@ void HttpWindow::enableDownloadButton()
downloadButton->setEnabled(!urlLineEdit->text().isEmpty());
}
-void HttpWindow::slotAuthenticationRequired(QNetworkReply*,QAuthenticator *authenticator)
+void HttpWindow::slotAuthenticationRequired(QNetworkReply *, QAuthenticator *authenticator)
{
QDialog authenticationDialog;
Ui::Dialog ui;
@@ -306,7 +316,7 @@ void HttpWindow::slotAuthenticationRequired(QNetworkReply*,QAuthenticator *authe
}
#ifndef QT_NO_SSL
-void HttpWindow::sslErrors(QNetworkReply*,const QList<QSslError> &errors)
+void HttpWindow::sslErrors(QNetworkReply *, const QList<QSslError> &errors)
{
QString errorString;
foreach (const QSslError &error, errors) {
diff --git a/examples/network/http/httpwindow.h b/examples/network/http/httpwindow.h
index f942c33952..20ad2bb4da 100644
--- a/examples/network/http/httpwindow.h
+++ b/examples/network/http/httpwindow.h
@@ -92,9 +92,9 @@ private slots:
void httpFinished();
void httpReadyRead();
void enableDownloadButton();
- void slotAuthenticationRequired(QNetworkReply*,QAuthenticator *);
+ void slotAuthenticationRequired(QNetworkReply *, QAuthenticator *authenticator);
#ifndef QT_NO_SSL
- void sslErrors(QNetworkReply*,const QList<QSslError> &errors);
+ void sslErrors(QNetworkReply *, const QList<QSslError> &errors);
#endif
private:
diff --git a/examples/network/multicastsender/sender.cpp b/examples/network/multicastsender/sender.cpp
index 4aa65fee27..cb4bf45672 100644
--- a/examples/network/multicastsender/sender.cpp
+++ b/examples/network/multicastsender/sender.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -48,43 +48,35 @@
**
****************************************************************************/
-#include <QtWidgets>
-#include <QtNetwork>
-
#include "sender.h"
Sender::Sender(QWidget *parent)
- : QDialog(parent)
+ : QDialog(parent),
+ groupAddress(QStringLiteral("239.255.43.21"))
{
- groupAddress = QHostAddress("239.255.43.21");
-
statusLabel = new QLabel(tr("Ready to multicast datagrams to group %1 on port 45454").arg(groupAddress.toString()));
- ttlLabel = new QLabel(tr("TTL for multicast datagrams:"));
- ttlSpinBox = new QSpinBox;
+ auto ttlLabel = new QLabel(tr("TTL for multicast datagrams:"));
+ auto ttlSpinBox = new QSpinBox;
ttlSpinBox->setRange(0, 255);
- QHBoxLayout *ttlLayout = new QHBoxLayout;
+ auto ttlLayout = new QHBoxLayout;
ttlLayout->addWidget(ttlLabel);
ttlLayout->addWidget(ttlSpinBox);
startButton = new QPushButton(tr("&Start"));
- quitButton = new QPushButton(tr("&Quit"));
+ auto quitButton = new QPushButton(tr("&Quit"));
- buttonBox = new QDialogButtonBox;
+ auto buttonBox = new QDialogButtonBox;
buttonBox->addButton(startButton, QDialogButtonBox::ActionRole);
buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);
- timer = new QTimer(this);
- udpSocket = new QUdpSocket(this);
- messageNo = 1;
-
- connect(ttlSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ttlChanged(int)));
- connect(startButton, SIGNAL(clicked()), this, SLOT(startSending()));
- connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
- connect(timer, SIGNAL(timeout()), this, SLOT(sendDatagram()));
+ connect(ttlSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &Sender::ttlChanged);
+ connect(startButton, &QPushButton::clicked, this, &Sender::startSending);
+ connect(quitButton, &QPushButton::clicked, this, &Sender::close);
+ connect(&timer, &QTimer::timeout, this, &Sender::sendDatagram);
- QVBoxLayout *mainLayout = new QVBoxLayout;
+ auto mainLayout = new QVBoxLayout;
mainLayout->addWidget(statusLabel);
mainLayout->addLayout(ttlLayout);
mainLayout->addWidget(buttonBox);
@@ -96,20 +88,19 @@ Sender::Sender(QWidget *parent)
void Sender::ttlChanged(int newTtl)
{
- udpSocket->setSocketOption(QAbstractSocket::MulticastTtlOption, newTtl);
+ udpSocket.setSocketOption(QAbstractSocket::MulticastTtlOption, newTtl);
}
void Sender::startSending()
{
startButton->setEnabled(false);
- timer->start(1000);
+ timer.start(1000);
}
void Sender::sendDatagram()
{
statusLabel->setText(tr("Now sending datagram %1").arg(messageNo));
QByteArray datagram = "Multicast message " + QByteArray::number(messageNo);
- udpSocket->writeDatagram(datagram.data(), datagram.size(),
- groupAddress, 45454);
+ udpSocket.writeDatagram(datagram, groupAddress, 45454);
++messageNo;
}
diff --git a/examples/network/multicastsender/sender.h b/examples/network/multicastsender/sender.h
index 8e10f88c0d..5d8769790e 100644
--- a/examples/network/multicastsender/sender.h
+++ b/examples/network/multicastsender/sender.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -51,24 +51,16 @@
#ifndef SENDER_H
#define SENDER_H
-#include <QDialog>
-#include <QHostAddress>
-
-QT_BEGIN_NAMESPACE
-class QDialogButtonBox;
-class QLabel;
-class QPushButton;
-class QTimer;
-class QUdpSocket;
-class QSpinBox;
-QT_END_NAMESPACE
+#include <QtWidgets>
+#include <QtNetwork>
+#include <QtCore>
class Sender : public QDialog
{
Q_OBJECT
public:
- Sender(QWidget *parent = 0);
+ explicit Sender(QWidget *parent = nullptr);
private slots:
void ttlChanged(int newTtl);
@@ -76,16 +68,12 @@ private slots:
void sendDatagram();
private:
- QLabel *statusLabel;
- QLabel *ttlLabel;
- QSpinBox *ttlSpinBox;
- QPushButton *startButton;
- QPushButton *quitButton;
- QDialogButtonBox *buttonBox;
- QUdpSocket *udpSocket;
- QTimer *timer;
+ QLabel *statusLabel = nullptr;
+ QPushButton *startButton = nullptr;
+ QUdpSocket udpSocket;
+ QTimer timer;
QHostAddress groupAddress;
- int messageNo;
+ int messageNo = 1;
};
#endif
diff --git a/examples/network/securesocketclient/certificateinfo.cpp b/examples/network/securesocketclient/certificateinfo.cpp
index c8cd86bc72..81429fc655 100644
--- a/examples/network/securesocketclient/certificateinfo.cpp
+++ b/examples/network/securesocketclient/certificateinfo.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -57,8 +57,8 @@ CertificateInfo::CertificateInfo(QWidget *parent)
form = new Ui_CertificateInfo;
form->setupUi(this);
- connect(form->certificationPathView, SIGNAL(currentIndexChanged(int)),
- this, SLOT(updateCertificateInfo(int)));
+ connect(form->certificationPathView, QOverload<int>::of(&QComboBox::currentIndexChanged),
+ this, &CertificateInfo::updateCertificateInfo);
}
CertificateInfo::~CertificateInfo()
@@ -68,25 +68,23 @@ CertificateInfo::~CertificateInfo()
void CertificateInfo::setCertificateChain(const QList<QSslCertificate> &chain)
{
- this->chain = chain;
+ certificateChain = chain;
form->certificationPathView->clear();
-
- for (int i = 0; i < chain.size(); ++i) {
- const QSslCertificate &cert = chain.at(i);
+ for (int i = 0; i < certificateChain.size(); ++i) {
+ const QSslCertificate &cert = certificateChain.at(i);
form->certificationPathView->addItem(tr("%1%2 (%3)").arg(!i ? QString() : tr("Issued by: "))
.arg(cert.subjectInfo(QSslCertificate::Organization).join(QLatin1Char(' ')))
.arg(cert.subjectInfo(QSslCertificate::CommonName).join(QLatin1Char(' '))));
}
-
form->certificationPathView->setCurrentIndex(0);
}
void CertificateInfo::updateCertificateInfo(int index)
{
form->certificateInfoView->clear();
- if (index >= 0 && index < chain.size()) {
- const QSslCertificate &cert = chain.at(index);
+ if (index >= 0 && index < certificateChain.size()) {
+ const QSslCertificate &cert = certificateChain.at(index);
QStringList lines;
lines << tr("Organization: %1").arg(cert.subjectInfo(QSslCertificate::Organization).join(QLatin1Char(' ')))
<< tr("Subunit: %1").arg(cert.subjectInfo(QSslCertificate::OrganizationalUnitName).join(QLatin1Char(' ')))
@@ -101,9 +99,7 @@ void CertificateInfo::updateCertificateInfo(int index)
<< tr("Issuer Locality: %1").arg(cert.issuerInfo(QSslCertificate::LocalityName).join(QLatin1Char(' ')))
<< tr("Issuer State/Province: %1").arg(cert.issuerInfo(QSslCertificate::StateOrProvinceName).join(QLatin1Char(' ')))
<< tr("Issuer Common Name: %1").arg(cert.issuerInfo(QSslCertificate::CommonName).join(QLatin1Char(' ')));
- foreach (QString line, lines)
+ for (const auto &line : lines)
form->certificateInfoView->addItem(line);
- } else {
- form->certificateInfoView->clear();
}
}
diff --git a/examples/network/securesocketclient/certificateinfo.h b/examples/network/securesocketclient/certificateinfo.h
index abc56dfbcd..9e079c5603 100644
--- a/examples/network/securesocketclient/certificateinfo.h
+++ b/examples/network/securesocketclient/certificateinfo.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -51,8 +51,9 @@
#ifndef CERTIFICATEINFO_H
#define CERTIFICATEINFO_H
-#include <QtWidgets/QDialog>
-#include <QtNetwork/QSslCertificate>
+#include <QDialog>
+#include <QList>
+#include <QSslCertificate>
QT_BEGIN_NAMESPACE
class Ui_CertificateInfo;
@@ -62,7 +63,7 @@ class CertificateInfo : public QDialog
{
Q_OBJECT
public:
- CertificateInfo(QWidget *parent = 0);
+ explicit CertificateInfo(QWidget *parent = nullptr);
~CertificateInfo();
void setCertificateChain(const QList<QSslCertificate> &chain);
@@ -71,8 +72,8 @@ private slots:
void updateCertificateInfo(int index);
private:
- Ui_CertificateInfo *form;
- QList<QSslCertificate> chain;
+ Ui_CertificateInfo *form = nullptr;
+ QList<QSslCertificate> certificateChain;
};
#endif
diff --git a/examples/network/securesocketclient/certificateinfo.ui b/examples/network/securesocketclient/certificateinfo.ui
index c5238eb3e1..3bea255e9e 100644
--- a/examples/network/securesocketclient/certificateinfo.ui
+++ b/examples/network/securesocketclient/certificateinfo.ui
@@ -42,7 +42,7 @@
<widget class="QListWidget" name="certificateInfoView">
<property name="font">
<font>
- <pointsize>8</pointsize>
+ <pointsize>10</pointsize>
</font>
</property>
<property name="wordWrap">
diff --git a/examples/network/securesocketclient/main.cpp b/examples/network/securesocketclient/main.cpp
index e6dc60736f..e9c413577f 100644
--- a/examples/network/securesocketclient/main.cpp
+++ b/examples/network/securesocketclient/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -50,6 +50,9 @@
#include <QApplication>
#include <QMessageBox>
+#include <QtNetwork>
+
+QT_REQUIRE_CONFIG(ssl);
#include "sslclient.h"
@@ -61,7 +64,7 @@ int main(int argc, char **argv)
if (!QSslSocket::supportsSsl()) {
QMessageBox::information(0, "Secure Socket Client",
- "This system does not support OpenSSL.");
+ "This system does not support SSL/TLS.");
return -1;
}
diff --git a/examples/network/securesocketclient/securesocketclient.pro b/examples/network/securesocketclient/securesocketclient.pro
index f13ed57247..98d2041754 100644
--- a/examples/network/securesocketclient/securesocketclient.pro
+++ b/examples/network/securesocketclient/securesocketclient.pro
@@ -1,3 +1,5 @@
+requires(qtHaveModule(network))
+
HEADERS += certificateinfo.h \
sslclient.h
SOURCES += certificateinfo.cpp \
diff --git a/examples/network/securesocketclient/sslclient.cpp b/examples/network/securesocketclient/sslclient.cpp
index 46d1919fd0..afeec033ff 100644
--- a/examples/network/securesocketclient/sslclient.cpp
+++ b/examples/network/securesocketclient/sslclient.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -50,29 +50,17 @@
#include "certificateinfo.h"
#include "sslclient.h"
+
#include "ui_sslclient.h"
#include "ui_sslerrors.h"
-#include <QtWidgets/QScrollBar>
-#include <QtWidgets/QStyle>
-#include <QtWidgets/QToolButton>
-#include <QtWidgets/QMessageBox>
-#include <QtNetwork/QSslCipher>
+#include <QtCore>
SslClient::SslClient(QWidget *parent)
- : QWidget(parent), socket(0), padLock(0), executingDialog(false)
+ : QWidget(parent)
{
- form = new Ui_Form;
- form->setupUi(this);
- form->hostNameEdit->setSelection(0, form->hostNameEdit->text().size());
- form->sessionOutput->setHtml(tr("&lt;not connected&gt;"));
-
- connect(form->hostNameEdit, SIGNAL(textChanged(QString)),
- this, SLOT(updateEnabledState()));
- connect(form->connectButton, SIGNAL(clicked()),
- this, SLOT(secureConnect()));
- connect(form->sendButton, SIGNAL(clicked()),
- this, SLOT(sendData()));
+ setupUi();
+ setupSecureSocket();
}
SslClient::~SslClient()
@@ -82,17 +70,15 @@ SslClient::~SslClient()
void SslClient::updateEnabledState()
{
- bool unconnected = !socket || socket->state() == QAbstractSocket::UnconnectedState;
-
+ const bool unconnected = socket->state() == QAbstractSocket::UnconnectedState;
form->hostNameEdit->setReadOnly(!unconnected);
form->hostNameEdit->setFocusPolicy(unconnected ? Qt::StrongFocus : Qt::NoFocus);
-
form->hostNameLabel->setEnabled(unconnected);
form->portBox->setEnabled(unconnected);
form->portLabel->setEnabled(unconnected);
form->connectButton->setEnabled(unconnected && !form->hostNameEdit->text().isEmpty());
- bool connected = socket && socket->state() == QAbstractSocket::ConnectedState;
+ const bool connected = socket->state() == QAbstractSocket::ConnectedState;
form->sessionOutput->setEnabled(connected);
form->sessionInput->setEnabled(connected);
form->sessionInputLabel->setEnabled(connected);
@@ -101,20 +87,6 @@ void SslClient::updateEnabledState()
void SslClient::secureConnect()
{
- if (!socket) {
- socket = new QSslSocket(this);
- connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
- this, SLOT(socketStateChanged(QAbstractSocket::SocketState)));
- connect(socket, SIGNAL(encrypted()),
- this, SLOT(socketEncrypted()));
- connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
- this, SLOT(socketError(QAbstractSocket::SocketError)));
- connect(socket, SIGNAL(sslErrors(QList<QSslError>)),
- this, SLOT(sslErrors(QList<QSslError>)));
- connect(socket, SIGNAL(readyRead()),
- this, SLOT(socketReadyRead()));
- }
-
socket->connectToHostEncrypted(form->hostNameEdit->text(), form->portBox->value());
updateEnabledState();
}
@@ -125,20 +97,18 @@ void SslClient::socketStateChanged(QAbstractSocket::SocketState state)
return;
updateEnabledState();
+
if (state == QAbstractSocket::UnconnectedState) {
+ form->sessionInput->clear();
form->hostNameEdit->setPalette(QPalette());
form->hostNameEdit->setFocus();
form->cipherLabel->setText(tr("<none>"));
- if (padLock)
- padLock->hide();
+ padLock->hide();
}
}
void SslClient::socketEncrypted()
{
- if (!socket)
- return; // might have disconnected already
-
form->sessionOutput->clear();
form->sessionInput->setFocus();
@@ -146,36 +116,12 @@ void SslClient::socketEncrypted()
palette.setColor(QPalette::Base, QColor(255, 255, 192));
form->hostNameEdit->setPalette(palette);
- QSslCipher ciph = socket->sessionCipher();
- QString cipher = QString("%1, %2 (%3/%4)").arg(ciph.authenticationMethod())
- .arg(ciph.name()).arg(ciph.usedBits()).arg(ciph.supportedBits());;
- form->cipherLabel->setText(cipher);
-
- if (!padLock) {
- padLock = new QToolButton;
- padLock->setIcon(QIcon(":/encrypted.png"));
-#ifndef QT_NO_CURSOR
- padLock->setCursor(Qt::ArrowCursor);
-#endif
- padLock->setToolTip(tr("Display encryption details."));
-
- int extent = form->hostNameEdit->height() - 2;
- padLock->resize(extent, extent);
- padLock->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
-
- QHBoxLayout *layout = new QHBoxLayout(form->hostNameEdit);
- layout->setMargin(form->hostNameEdit->style()->pixelMetric(QStyle::PM_DefaultFrameWidth));
- layout->setSpacing(0);
- layout->addStretch();
- layout->addWidget(padLock);
-
- form->hostNameEdit->setLayout(layout);
-
- connect(padLock, SIGNAL(clicked()),
- this, SLOT(displayCertificateInfo()));
- } else {
- padLock->show();
- }
+ const QSslCipher cipher = socket->sessionCipher();
+ const QString cipherInfo = QString("%1, %2 (%3/%4)").arg(cipher.authenticationMethod())
+ .arg(cipher.name()).arg(cipher.usedBits())
+ .arg(cipher.supportedBits());;
+ form->cipherLabel->setText(cipherInfo);
+ padLock->show();
}
void SslClient::socketReadyRead()
@@ -185,7 +131,7 @@ void SslClient::socketReadyRead()
void SslClient::sendData()
{
- QString input = form->sessionInput->text();
+ const QString input = form->sessionInput->text();
appendString(input + '\n');
socket->write(input.toUtf8() + "\r\n");
form->sessionInput->clear();
@@ -193,7 +139,12 @@ void SslClient::sendData()
void SslClient::socketError(QAbstractSocket::SocketError)
{
+ if (handlingSocketError)
+ return;
+
+ handlingSocketError = true;
QMessageBox::critical(this, tr("Connection error"), socket->errorString());
+ handlingSocketError = false;
}
void SslClient::sslErrors(const QList<QSslError> &errors)
@@ -201,10 +152,10 @@ void SslClient::sslErrors(const QList<QSslError> &errors)
QDialog errorDialog(this);
Ui_SslErrors ui;
ui.setupUi(&errorDialog);
- connect(ui.certificateChainButton, SIGNAL(clicked()),
- this, SLOT(displayCertificateInfo()));
+ connect(ui.certificateChainButton, &QPushButton::clicked,
+ this, &SslClient::displayCertificateInfo);
- foreach (const QSslError &error, errors)
+ for (const auto &error : errors)
ui.sslErrorList->addItem(error.errorString());
executingDialog = true;
@@ -219,10 +170,69 @@ void SslClient::sslErrors(const QList<QSslError> &errors)
void SslClient::displayCertificateInfo()
{
- CertificateInfo *info = new CertificateInfo(this);
- info->setCertificateChain(socket->peerCertificateChain());
- info->exec();
- info->deleteLater();
+ CertificateInfo info;
+ info.setCertificateChain(socket->peerCertificateChain());
+ info.exec();
+}
+
+void SslClient::setupUi()
+{
+ if (form)
+ return;
+
+ form = new Ui_Form;
+ form->setupUi(this);
+ form->hostNameEdit->setSelection(0, form->hostNameEdit->text().size());
+ form->sessionOutput->setHtml(tr("&lt;not connected&gt;"));
+
+ connect(form->hostNameEdit, SIGNAL(textChanged(QString)),
+ this, SLOT(updateEnabledState()));
+ connect(form->connectButton, SIGNAL(clicked()),
+ this, SLOT(secureConnect()));
+ connect(form->sendButton, SIGNAL(clicked()),
+ this, SLOT(sendData()));
+
+ padLock = new QToolButton;
+ padLock->setIcon(QIcon(":/encrypted.png"));
+ connect(padLock, SIGNAL(clicked()), this, SLOT(displayCertificateInfo()));
+
+#if QT_CONFIG(cursor)
+ padLock->setCursor(Qt::ArrowCursor);
+#endif
+ padLock->setToolTip(tr("Display encryption details."));
+
+ const int extent = form->hostNameEdit->height() - 2;
+ padLock->resize(extent, extent);
+ padLock->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
+
+ QHBoxLayout *layout = new QHBoxLayout(form->hostNameEdit);
+ layout->setMargin(form->hostNameEdit->style()->pixelMetric(QStyle::PM_DefaultFrameWidth));
+ layout->setSpacing(0);
+ layout->addStretch();
+ layout->addWidget(padLock);
+
+ form->hostNameEdit->setLayout(layout);
+ padLock->hide();
+}
+
+void SslClient::setupSecureSocket()
+{
+ if (socket)
+ return;
+
+ socket = new QSslSocket(this);
+
+ connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)),
+ this, SLOT(socketStateChanged(QAbstractSocket::SocketState)));
+ connect(socket, SIGNAL(encrypted()),
+ this, SLOT(socketEncrypted()));
+ connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
+ this, SLOT(socketError(QAbstractSocket::SocketError)));
+ connect(socket, SIGNAL(sslErrors(QList<QSslError>)),
+ this, SLOT(sslErrors(QList<QSslError>)));
+ connect(socket, SIGNAL(readyRead()),
+ this, SLOT(socketReadyRead()));
+
}
void SslClient::appendString(const QString &line)
diff --git a/examples/network/securesocketclient/sslclient.h b/examples/network/securesocketclient/sslclient.h
index d3baefbc56..63fdbef77d 100644
--- a/examples/network/securesocketclient/sslclient.h
+++ b/examples/network/securesocketclient/sslclient.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of the Qt Toolkit.
@@ -51,13 +51,13 @@
#ifndef SSLCLIENT_H
#define SSLCLIENT_H
-#include <QtWidgets/QWidget>
-#include <QtNetwork/QAbstractSocket>
-#include <QtNetwork/QSslSocket>
+#include <QtNetwork>
+
+QT_REQUIRE_CONFIG(ssl);
+
+#include <QtWidgets>
QT_BEGIN_NAMESPACE
-class QSslSocket;
-class QToolButton;
class Ui_Form;
QT_END_NAMESPACE
@@ -65,7 +65,7 @@ class SslClient : public QWidget
{
Q_OBJECT
public:
- SslClient(QWidget *parent = 0);
+ explicit SslClient(QWidget *parent = nullptr);
~SslClient();
private slots:
@@ -80,12 +80,15 @@ private slots:
void displayCertificateInfo();
private:
+ void setupUi();
+ void setupSecureSocket();
void appendString(const QString &line);
- QSslSocket *socket;
- QToolButton *padLock;
- Ui_Form *form;
- bool executingDialog;
+ QSslSocket *socket = nullptr;
+ QToolButton *padLock = nullptr;
+ Ui_Form *form = nullptr;
+ bool handlingSocketError = false;
+ bool executingDialog = false;
};
#endif
diff --git a/examples/network/securesocketclient/sslclient.ui b/examples/network/securesocketclient/sslclient.ui
index 19bae83a09..7821b04e76 100644
--- a/examples/network/securesocketclient/sslclient.ui
+++ b/examples/network/securesocketclient/sslclient.ui
@@ -10,6 +10,12 @@
<height>320</height>
</rect>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>343</width>
+ <height>320</height>
+ </size>
+ </property>
<property name="windowTitle">
<string>Secure Socket Client</string>
</property>
@@ -114,8 +120,8 @@
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
-&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'.SF NS Text'; font-size:13pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
diff --git a/examples/opengl/hellogl2/glwidget.cpp b/examples/opengl/hellogl2/glwidget.cpp
index fc961da4c4..318adb5043 100644
--- a/examples/opengl/hellogl2/glwidget.cpp
+++ b/examples/opengl/hellogl2/glwidget.cpp
@@ -54,6 +54,8 @@
#include <QCoreApplication>
#include <math.h>
+bool GLWidget::m_transparent = false;
+
GLWidget::GLWidget(QWidget *parent)
: QOpenGLWidget(parent),
m_xRot(0),
@@ -61,10 +63,9 @@ GLWidget::GLWidget(QWidget *parent)
m_zRot(0),
m_program(0)
{
- m_core = QCoreApplication::arguments().contains(QStringLiteral("--coreprofile"));
+ m_core = QSurfaceFormat::defaultFormat().profile() == QSurfaceFormat::CoreProfile;
// --transparent causes the clear color to be transparent. Therefore, on systems that
// support it, the widget will become transparent apart from the logo.
- m_transparent = QCoreApplication::arguments().contains(QStringLiteral("--transparent"));
if (m_transparent) {
QSurfaceFormat fmt = format();
fmt.setAlphaBufferSize(8);
@@ -127,6 +128,8 @@ void GLWidget::setZRotation(int angle)
void GLWidget::cleanup()
{
+ if (m_program == nullptr)
+ return;
makeCurrent();
m_logoVbo.destroy();
delete m_program;
diff --git a/examples/opengl/hellogl2/glwidget.h b/examples/opengl/hellogl2/glwidget.h
index cff5633893..21dd200dc7 100644
--- a/examples/opengl/hellogl2/glwidget.h
+++ b/examples/opengl/hellogl2/glwidget.h
@@ -68,6 +68,9 @@ public:
GLWidget(QWidget *parent = 0);
~GLWidget();
+ static bool isTransparent() { return m_transparent; }
+ static void setTransparent(bool t) { m_transparent = t; }
+
QSize minimumSizeHint() const override;
QSize sizeHint() const override;
@@ -108,7 +111,7 @@ private:
QMatrix4x4 m_proj;
QMatrix4x4 m_camera;
QMatrix4x4 m_world;
- bool m_transparent;
+ static bool m_transparent;
};
#endif
diff --git a/examples/opengl/hellogl2/main.cpp b/examples/opengl/hellogl2/main.cpp
index 143f659eb6..b52a5a37d3 100644
--- a/examples/opengl/hellogl2/main.cpp
+++ b/examples/opengl/hellogl2/main.cpp
@@ -51,25 +51,46 @@
#include <QApplication>
#include <QDesktopWidget>
#include <QSurfaceFormat>
+#include <QCommandLineParser>
+#include <QCommandLineOption>
+#include "glwidget.h"
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
+ QCoreApplication::setApplicationName("Qt Hello GL 2 Example");
+ QCoreApplication::setOrganizationName("QtProject");
+ QCoreApplication::setApplicationVersion(QT_VERSION_STR);
+ QCommandLineParser parser;
+ parser.setApplicationDescription(QCoreApplication::applicationName());
+ parser.addHelpOption();
+ parser.addVersionOption();
+ QCommandLineOption multipleSampleOption("multisample", "Multisampling");
+ parser.addOption(multipleSampleOption);
+ QCommandLineOption coreProfileOption("coreprofile", "Use core profile");
+ parser.addOption(coreProfileOption);
+ QCommandLineOption transparentOption("transparent", "Transparent window");
+ parser.addOption(transparentOption);
+
+ parser.process(app);
+
QSurfaceFormat fmt;
fmt.setDepthBufferSize(24);
- if (QCoreApplication::arguments().contains(QStringLiteral("--multisample")))
+ if (parser.isSet(multipleSampleOption))
fmt.setSamples(4);
- if (QCoreApplication::arguments().contains(QStringLiteral("--coreprofile"))) {
+ if (parser.isSet(coreProfileOption)) {
fmt.setVersion(3, 2);
fmt.setProfile(QSurfaceFormat::CoreProfile);
}
QSurfaceFormat::setDefaultFormat(fmt);
MainWindow mainWindow;
- if (QCoreApplication::arguments().contains(QStringLiteral("--transparent"))) {
+
+ GLWidget::setTransparent(parser.isSet(transparentOption));
+ if (GLWidget::isTransparent()) {
mainWindow.setAttribute(Qt::WA_TranslucentBackground);
mainWindow.setAttribute(Qt::WA_NoSystemBackground, false);
}
diff --git a/examples/opengl/hellowindow/main.cpp b/examples/opengl/hellowindow/main.cpp
index a20e7002a1..7f0be39f5d 100644
--- a/examples/opengl/hellowindow/main.cpp
+++ b/examples/opengl/hellowindow/main.cpp
@@ -52,6 +52,8 @@
#include <qpa/qplatformintegration.h>
+#include <QCommandLineParser>
+#include <QCommandLineOption>
#include <QGuiApplication>
#include <QScreen>
#include <QThread>
@@ -60,9 +62,26 @@ int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
+ QCoreApplication::setApplicationName("Qt HelloWindow GL Example");
+ QCoreApplication::setOrganizationName("QtProject");
+ QCoreApplication::setApplicationVersion(QT_VERSION_STR);
+ QCommandLineParser parser;
+ parser.setApplicationDescription(QCoreApplication::applicationName());
+ parser.addHelpOption();
+ parser.addVersionOption();
+ QCommandLineOption multipleOption("multiple", "Create multiple windows");
+ parser.addOption(multipleOption);
+ QCommandLineOption multipleSampleOption("multisample", "Multisampling");
+ parser.addOption(multipleSampleOption);
+ QCommandLineOption multipleScreenOption("multiscreen", "Run on multiple screens");
+ parser.addOption(multipleScreenOption);
+ QCommandLineOption timeoutOption("timeout", "Close after 10s");
+ parser.addOption(timeoutOption);
+ parser.process(app);
+
// Some platforms can only have one window per screen. Therefore we need to differentiate.
- const bool multipleWindows = QGuiApplication::arguments().contains(QStringLiteral("--multiple"));
- const bool multipleScreens = QGuiApplication::arguments().contains(QStringLiteral("--multiscreen"));
+ const bool multipleWindows = parser.isSet(multipleOption);
+ const bool multipleScreens = parser.isSet(multipleScreenOption);
QScreen *screen = QGuiApplication::primaryScreen();
@@ -70,7 +89,7 @@ int main(int argc, char *argv[])
QSurfaceFormat format;
format.setDepthBufferSize(16);
- if (QGuiApplication::arguments().contains(QStringLiteral("--multisample")))
+ if (parser.isSet(multipleSampleOption))
format.setSamples(4);
QPoint center = QPoint(screenGeometry.center().x(), screenGeometry.top() + 80);
@@ -136,7 +155,7 @@ int main(int argc, char *argv[])
}
// Quit after 10 seconds. For platforms that do not have windows that are closeable.
- if (QCoreApplication::arguments().contains(QStringLiteral("--timeout")))
+ if (parser.isSet(timeoutOption))
QTimer::singleShot(10000, qGuiApp, &QCoreApplication::quit);
const int exitValue = app.exec();
diff --git a/examples/opengl/qopenglwidget/main.cpp b/examples/opengl/qopenglwidget/main.cpp
index f9b5731b8f..42fc772445 100644
--- a/examples/opengl/qopenglwidget/main.cpp
+++ b/examples/opengl/qopenglwidget/main.cpp
@@ -51,6 +51,8 @@
#include <QApplication>
#include <QMainWindow>
#include <QSurfaceFormat>
+#include <QCommandLineParser>
+#include <QCommandLineOption>
#include "mainwindow.h"
int main( int argc, char ** argv )
@@ -58,12 +60,25 @@ int main( int argc, char ** argv )
Q_INIT_RESOURCE(texture);
QApplication a( argc, argv );
+ QCoreApplication::setApplicationName("Qt QOpenGLWidget Example");
+ QCoreApplication::setOrganizationName("QtProject");
+ QCoreApplication::setApplicationVersion(QT_VERSION_STR);
+ QCommandLineParser parser;
+ parser.setApplicationDescription(QCoreApplication::applicationName());
+ parser.addHelpOption();
+ parser.addVersionOption();
+ QCommandLineOption multipleSampleOption("multisample", "Multisampling");
+ parser.addOption(multipleSampleOption);
+ QCommandLineOption srgbOption("srgb", "Use sRGB Color Space");
+ parser.addOption(srgbOption);
+ parser.process(a);
+
QSurfaceFormat format;
format.setDepthBufferSize(24);
format.setStencilBufferSize(8);
- if (QCoreApplication::arguments().contains(QStringLiteral("--srgb")))
+ if (parser.isSet(srgbOption))
format.setColorSpace(QSurfaceFormat::sRGBColorSpace);
- if (QCoreApplication::arguments().contains(QStringLiteral("--multisample")))
+ if (parser.isSet(multipleSampleOption))
format.setSamples(4);
QSurfaceFormat::setDefaultFormat(format);
diff --git a/examples/opengl/threadedqopenglwidget/main.cpp b/examples/opengl/threadedqopenglwidget/main.cpp
index c22cee9228..b9e491040f 100644
--- a/examples/opengl/threadedqopenglwidget/main.cpp
+++ b/examples/opengl/threadedqopenglwidget/main.cpp
@@ -53,6 +53,8 @@
#include <QDesktopWidget>
#include <QSurfaceFormat>
#include <QOpenGLContext>
+#include <QCommandLineParser>
+#include <QCommandLineOption>
#include "mainwindow.h"
#include "glwidget.h"
@@ -67,6 +69,17 @@ int main( int argc, char ** argv )
{
QApplication a( argc, argv );
+ QCoreApplication::setApplicationName("Qt Threaded QOpenGLWidget Example");
+ QCoreApplication::setOrganizationName("QtProject");
+ QCoreApplication::setApplicationVersion(QT_VERSION_STR);
+ QCommandLineParser parser;
+ parser.setApplicationDescription(QCoreApplication::applicationName());
+ parser.addHelpOption();
+ parser.addVersionOption();
+ QCommandLineOption singleOption("single", "Single thread");
+ parser.addOption(singleOption);
+ parser.process(a);
+
QSurfaceFormat format;
format.setDepthBufferSize(16);
QSurfaceFormat::setDefaultFormat(format);
@@ -93,7 +106,7 @@ int main( int argc, char ** argv )
QScopedPointer<MainWindow> mw1;
QScopedPointer<MainWindow> mw2;
- if (!QApplication::arguments().contains(QStringLiteral("--single"))) {
+ if (!parser.isSet(singleOption)) {
if (supportsThreading) {
pos += QPoint(100, 100);
mw1.reset(new MainWindow);
diff --git a/examples/sql/cachedtable/tableeditor.cpp b/examples/sql/cachedtable/tableeditor.cpp
index 71e441486d..95c3047c76 100644
--- a/examples/sql/cachedtable/tableeditor.cpp
+++ b/examples/sql/cachedtable/tableeditor.cpp
@@ -85,9 +85,9 @@ TableEditor::TableEditor(const QString &tableName, QWidget *parent)
//! [2]
//! [3]
- connect(submitButton, SIGNAL(clicked()), this, SLOT(submit()));
- connect(revertButton, SIGNAL(clicked()), model, SLOT(revertAll()));
- connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
+ connect(submitButton, &QPushButton::clicked, this, &TableEditor::submit);
+ connect(revertButton, &QPushButton::clicked, model, &QSqlTableModel::revertAll);
+ connect(quitButton, &QPushButton::clicked, this, &TableEditor::close);
//! [3]
//! [4]
diff --git a/examples/sql/cachedtable/tableeditor.h b/examples/sql/cachedtable/tableeditor.h
index 6544276cbe..727aa88ab3 100644
--- a/examples/sql/cachedtable/tableeditor.h
+++ b/examples/sql/cachedtable/tableeditor.h
@@ -65,7 +65,7 @@ class TableEditor : public QWidget
Q_OBJECT
public:
- explicit TableEditor(const QString &tableName, QWidget *parent = 0);
+ explicit TableEditor(const QString &tableName, QWidget *parent = nullptr);
private slots:
void submit();
diff --git a/examples/sql/connection.h b/examples/sql/connection.h
index 3bedf4b061..482feff5b4 100644
--- a/examples/sql/connection.h
+++ b/examples/sql/connection.h
@@ -70,12 +70,12 @@ static bool createConnection()
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(":memory:");
if (!db.open()) {
- QMessageBox::critical(0, qApp->tr("Cannot open database"),
- qApp->tr("Unable to establish a database connection.\n"
- "This example needs SQLite support. Please read "
- "the Qt SQL driver documentation for information how "
- "to build it.\n\n"
- "Click Cancel to exit."), QMessageBox::Cancel);
+ QMessageBox::critical(nullptr, QObject::tr("Cannot open database"),
+ QObject::tr("Unable to establish a database connection.\n"
+ "This example needs SQLite support. Please read "
+ "the Qt SQL driver documentation for information how "
+ "to build it.\n\n"
+ "Click Cancel to exit."), QMessageBox::Cancel);
return false;
}
diff --git a/examples/sql/doc/src/drilldown.qdoc b/examples/sql/doc/src/drilldown.qdoc
index 29c0b613f6..7a8aa2037a 100644
--- a/examples/sql/doc/src/drilldown.qdoc
+++ b/examples/sql/doc/src/drilldown.qdoc
@@ -172,11 +172,20 @@
\snippet drilldown/informationwindow.cpp 4
Finally, we connect the "something's changed" signals in the
- editors to our custom \c enableButtons() slot, enabling the users
- to either submit or revert their changes. We add all the widgets
- into a layout, store the item ID and the name of the displayed
- image file for future reference, and set the window title and
- initial size.
+ editors to our custom \c enableButtons slot, enabling the users
+ to either submit or revert their changes.
+ We need to use lambdas for connecting the \c enableButtons slot
+ because its signature does not match \c QTextEdit::textChanged
+ and \c QComboBox::currentIndexChanged.
+ Since the latter has another overload with the signature
+ \c {const QString &} and the selected signal would be ambiguous,
+ we need to use \c QOverload<int>::of to select a specific overload
+ for \c currentIndexChanged.
+
+ We add all the widgets into a layout, store the item ID and the
+ name of the displayed image file for future reference, and set
+ the window title and initial size.
+
Note that we also set the Qt::Window window flag to indicate that
our widget is in fact a window, with a window system frame and a
@@ -389,19 +398,21 @@
\snippet drilldown/view.cpp 6
The \c showInformation() function is given an \c ImageItem object
- as argument, and starts off by extracting the item's item
- ID. Then it determines if there already is created an information
- window for this location. If it is, and the window is visible, it
- ensures that the window is raised to the top of the widget stack
- and activated. If the window exists but is hidden, calling its \l
- {QWidget::}{show()} slot gives the same result.
+ as argument, and starts off by extracting the item's item ID.
+ Then it determines if there already is created an information
+ window for this location.
If no window for the given location exists, we create one by
passing the item ID, a pointer to the model, and our view as a
parent, to the \c InformationWindow constructor. Note that we
connect the information window's \c imageChanged() signal to \e
this widget's \c updateImage() slot, before we give it a suitable
position and add it to the list of existing windows.
+ If there is a window for the given location, and that window is
+ visible, it ensures that the window is raised to the top of the
+ widget stack and activated. If it is hidden, calling its \l
+ {QWidget::}{show()} slot gives the same result.
+
\snippet drilldown/view.cpp 7
diff --git a/examples/sql/drilldown/imageitem.cpp b/examples/sql/drilldown/imageitem.cpp
index 4e440fc786..04ec614755 100644
--- a/examples/sql/drilldown/imageitem.cpp
+++ b/examples/sql/drilldown/imageitem.cpp
@@ -60,8 +60,8 @@ ImageItem::ImageItem(int id, const QPixmap &pixmap, QGraphicsItem *parent)
timeLine.setDuration(150);
timeLine.setFrameRange(0, 150);
- connect(&timeLine, SIGNAL(frameChanged(int)), this, SLOT(setFrame(int)));
- connect(&timeLine, SIGNAL(finished()), this, SLOT(updateItemPosition()));
+ connect(&timeLine, &QTimeLine::frameChanged, this, &ImageItem::setFrame);
+ connect(&timeLine, &QTimeLine::finished, this, &ImageItem::updateItemPosition);
adjust();
}
@@ -116,7 +116,7 @@ void ImageItem::adjust()
//! [4]
//! [5]
-int ImageItem::id()
+int ImageItem::id() const
{
return recordId;
}
diff --git a/examples/sql/drilldown/imageitem.h b/examples/sql/drilldown/imageitem.h
index 4f773a6dfc..abb9103c7e 100644
--- a/examples/sql/drilldown/imageitem.h
+++ b/examples/sql/drilldown/imageitem.h
@@ -60,10 +60,10 @@ class ImageItem : public QObject, public QGraphicsPixmapItem
Q_OBJECT
public:
- ImageItem(int id, const QPixmap &pixmap, QGraphicsItem *parent = 0);
+ ImageItem(int id, const QPixmap &pixmap, QGraphicsItem *parent = nullptr);
void adjust();
- int id();
+ int id() const;
protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
diff --git a/examples/sql/drilldown/informationwindow.cpp b/examples/sql/drilldown/informationwindow.cpp
index 2536b0ca91..0007432672 100644
--- a/examples/sql/drilldown/informationwindow.cpp
+++ b/examples/sql/drilldown/informationwindow.cpp
@@ -84,10 +84,12 @@ InformationWindow::InformationWindow(int id, QSqlRelationalTableModel *items,
//! [3]
//! [4]
- connect(descriptionEditor, SIGNAL(textChanged()),
- this, SLOT(enableButtons()));
- connect(imageFileEditor, SIGNAL(currentIndexChanged(int)),
- this, SLOT(enableButtons()));
+ connect(descriptionEditor, &QTextEdit::textChanged, [=]() {
+ enableButtons();
+ });
+ connect(imageFileEditor, QOverload<int>::of(&QComboBox::currentIndexChanged), [=]() {
+ enableButtons();
+ });
QFormLayout *formLayout = new QFormLayout;
formLayout->addRow(itemLabel, itemText);
@@ -109,7 +111,7 @@ InformationWindow::InformationWindow(int id, QSqlRelationalTableModel *items,
//! [4]
//! [5]
-int InformationWindow::id()
+int InformationWindow::id() const
{
return itemId;
}
@@ -149,9 +151,9 @@ void InformationWindow::createButtons()
closeButton->setDefault(true);
- connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
- connect(revertButton, SIGNAL(clicked()), this, SLOT(revert()));
- connect(submitButton, SIGNAL(clicked()), this, SLOT(submit()));
+ connect(closeButton, &QPushButton::clicked, this, &InformationWindow::close);
+ connect(revertButton, &QPushButton::clicked, this, &InformationWindow::revert);
+ connect(submitButton, &QPushButton::clicked, this, &InformationWindow::submit);
//! [8]
//! [9]
diff --git a/examples/sql/drilldown/informationwindow.h b/examples/sql/drilldown/informationwindow.h
index 6e87cea65a..653837d722 100644
--- a/examples/sql/drilldown/informationwindow.h
+++ b/examples/sql/drilldown/informationwindow.h
@@ -61,9 +61,9 @@ class InformationWindow : public QDialog
public:
InformationWindow(int id, QSqlRelationalTableModel *items,
- QWidget *parent = 0);
+ QWidget *parent = nullptr);
- int id();
+ int id() const;
signals:
void imageChanged(int id, const QString &fileName);
@@ -83,16 +83,16 @@ private:
int itemId;
QString displayedImage;
- QComboBox *imageFileEditor;
- QLabel *itemText;
- QTextEdit *descriptionEditor;
+ QComboBox *imageFileEditor = nullptr;
+ QLabel *itemText = nullptr;
+ QTextEdit *descriptionEditor = nullptr;
- QPushButton *closeButton;
- QPushButton *submitButton;
- QPushButton *revertButton;
- QDialogButtonBox *buttonBox;
+ QPushButton *closeButton = nullptr;
+ QPushButton *submitButton = nullptr;
+ QPushButton *revertButton = nullptr;
+ QDialogButtonBox *buttonBox = nullptr;
- QDataWidgetMapper *mapper;
+ QDataWidgetMapper *mapper = nullptr;
};
//! [2]
diff --git a/examples/sql/drilldown/main.cpp b/examples/sql/drilldown/main.cpp
index 3465d11b4d..db3320de48 100644
--- a/examples/sql/drilldown/main.cpp
+++ b/examples/sql/drilldown/main.cpp
@@ -48,10 +48,13 @@
**
****************************************************************************/
-#include <QtWidgets>
-
-#include "../connection.h"
#include "view.h"
+#include "../connection.h"
+
+#include <QApplication>
+
+#include <stdlib.h>
+
int main(int argc, char *argv[])
{
@@ -60,7 +63,7 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
if (!createConnection())
- return 1;
+ return EXIT_FAILURE;
View view("items", "images");
view.show();
diff --git a/examples/sql/drilldown/view.cpp b/examples/sql/drilldown/view.cpp
index fc05d2fcaf..13e9310061 100644
--- a/examples/sql/drilldown/view.cpp
+++ b/examples/sql/drilldown/view.cpp
@@ -89,8 +89,6 @@ void View::addItems()
int topMargin = 40;
for (int i = 0; i < itemCount; i++) {
- ImageItem *image;
- QGraphicsTextItem *label;
QSqlRecord record = itemTable->record(i);
int id = record.value("id").toInt();
@@ -101,12 +99,12 @@ void View::addItems()
int x = ((i % 2) * imageOffset) + leftMargin + columnOffset;
int y = ((i / 2) * imageOffset) + topMargin;
- image = new ImageItem(id, QPixmap(":/" + file));
+ ImageItem *image = new ImageItem(id, QPixmap(":/" + file));
image->setData(0, i);
image->setPos(x, y);
scene->addItem(image);
- label = scene->addText(item);
+ QGraphicsTextItem *label = scene->addText(item);
label->setDefaultTextColor(QColor("#d7d6d5"));
QPointF labelOffset((120 - label->boundingRect().width()) / 2, 120.0);
label->setPos(QPointF(x, y) + labelOffset);
@@ -133,22 +131,22 @@ void View::showInformation(ImageItem *image)
return;
InformationWindow *window = findWindow(id);
- if (window && window->isVisible()) {
- window->raise();
- window->activateWindow();
- } else if (window && !window->isVisible()) {
- window->show();
- } else {
- InformationWindow *window;
+ if (!window) {
window = new InformationWindow(id, itemTable, this);
- connect(window, SIGNAL(imageChanged(int,QString)),
- this, SLOT(updateImage(int,QString)));
+ connect(window, QOverload<int,const QString &>::of(&InformationWindow::imageChanged),
+ this, QOverload<int,const QString &>::of(&View::updateImage));
window->move(pos() + QPoint(20, 40));
window->show();
informationWindows.append(window);
}
+
+ if (window->isVisible()) {
+ window->raise();
+ window->activateWindow();
+ } else
+ window->show();
}
//! [6]
@@ -172,19 +170,13 @@ void View::updateImage(int id, const QString &fileName)
//! [7]
//! [8]
-InformationWindow* View::findWindow(int id)
+InformationWindow *View::findWindow(int id) const
{
- QList<InformationWindow*>::iterator i, beginning, end;
-
- beginning = informationWindows.begin();
- end = informationWindows.end();
-
- for (i = beginning; i != end; ++i) {
- InformationWindow *window = (*i);
+ for (auto window : informationWindows) {
if (window && (window->id() == id))
return window;
}
- return 0;
+ return nullptr;
}
//! [8]
diff --git a/examples/sql/drilldown/view.h b/examples/sql/drilldown/view.h
index 9d6ef0e853..5afa1a25e9 100644
--- a/examples/sql/drilldown/view.h
+++ b/examples/sql/drilldown/view.h
@@ -63,7 +63,7 @@ class View : public QGraphicsView
Q_OBJECT
public:
- View(const QString &items, const QString &images, QWidget *parent = 0);
+ View(const QString &items, const QString &images, QWidget *parent = nullptr);
protected:
void mouseReleaseEvent(QMouseEvent *event) override;
@@ -77,7 +77,7 @@ private slots:
//! [2]
private:
void addItems();
- InformationWindow* findWindow(int id);
+ InformationWindow *findWindow(int id) const;
void showInformation(ImageItem *image);
QGraphicsScene *scene;
diff --git a/examples/sql/masterdetail/database.h b/examples/sql/masterdetail/database.h
index 3139deb0b2..9cbca6f749 100644
--- a/examples/sql/masterdetail/database.h
+++ b/examples/sql/masterdetail/database.h
@@ -61,12 +61,12 @@ static bool createConnection()
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(":memory:");
if (!db.open()) {
- QMessageBox::critical(0, qApp->tr("Cannot open database"),
- qApp->tr("Unable to establish a database connection.\n"
- "This example needs SQLite support. Please read "
- "the Qt SQL driver documentation for information how "
- "to build it.\n\n"
- "Click Cancel to exit."), QMessageBox::Cancel);
+ QMessageBox::critical(nullptr, QObject::tr("Cannot open database"),
+ QObject::tr("Unable to establish a database connection.\n"
+ "This example needs SQLite support. Please read "
+ "the Qt SQL driver documentation for information how "
+ "to build it.\n\n"
+ "Click Cancel to exit."), QMessageBox::Cancel);
return false;
}
diff --git a/examples/sql/masterdetail/dialog.cpp b/examples/sql/masterdetail/dialog.cpp
index 5bb213230e..bb1812eace 100644
--- a/examples/sql/masterdetail/dialog.cpp
+++ b/examples/sql/masterdetail/dialog.cpp
@@ -155,12 +155,12 @@ int Dialog::addNewAlbum(const QString &title, int artistId)
return id;
}
-void Dialog::addTracks(int albumId, QStringList tracks)
+void Dialog::addTracks(int albumId, const QStringList &tracks)
{
QDomElement albumNode = albumDetails.createElement("album");
albumNode.setAttribute("id", albumId);
- for (int i = 0; i < tracks.count(); i++) {
+ for (int i = 0; i < tracks.count(); ++i) {
QString trackNumber = QString::number(i);
if (i < 10)
trackNumber.prepend('0');
@@ -254,9 +254,9 @@ QDialogButtonBox *Dialog::createButtons()
closeButton->setDefault(true);
- connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
- connect(revertButton, SIGNAL(clicked()), this, SLOT(revert()));
- connect(submitButton, SIGNAL(clicked()), this, SLOT(submit()));
+ connect(closeButton, &QPushButton::clicked, this, &Dialog::close);
+ connect(revertButton, &QPushButton::clicked, this, &Dialog::revert);
+ connect(submitButton, &QPushButton::clicked, this, &Dialog::submit);
QDialogButtonBox *buttonBox = new QDialogButtonBox;
buttonBox->addButton(submitButton, QDialogButtonBox::ResetRole);
@@ -270,7 +270,7 @@ QModelIndex Dialog::indexOfArtist(const QString &artist)
{
QSqlTableModel *artistModel = model->relationModel(2);
- for (int i = 0; i < artistModel->rowCount(); i++) {
+ for (int i = 0; i < artistModel->rowCount(); ++i) {
QSqlRecord record = artistModel->record(i);
if (record.value("artist") == artist)
return artistModel->index(i, 1);
diff --git a/examples/sql/masterdetail/dialog.h b/examples/sql/masterdetail/dialog.h
index 1789207d8d..31c4d8552c 100644
--- a/examples/sql/masterdetail/dialog.h
+++ b/examples/sql/masterdetail/dialog.h
@@ -61,7 +61,7 @@ class Dialog : public QDialog
public:
Dialog(QSqlRelationalTableModel *albums, QDomDocument details,
- QFile *output, QWidget *parent = 0);
+ QFile *output, QWidget *parent = nullptr);
private slots:
void revert();
@@ -70,12 +70,12 @@ private slots:
private:
int addNewAlbum(const QString &title, int artistId);
int addNewArtist(const QString &name);
- void addTracks(int albumId, QStringList tracks);
+ void addTracks(int albumId, const QStringList &tracks);
QDialogButtonBox *createButtons();
QGroupBox *createInputWidgets();
int findArtistId(const QString &artist);
- int generateAlbumId();
- int generateArtistId();
+ static int generateAlbumId();
+ static int generateArtistId();
void increaseAlbumCount(QModelIndex artistIndex);
QModelIndex indexOfArtist(const QString &artist);
diff --git a/examples/sql/masterdetail/main.cpp b/examples/sql/masterdetail/main.cpp
index cc1a1c4a21..9a4172e55f 100644
--- a/examples/sql/masterdetail/main.cpp
+++ b/examples/sql/masterdetail/main.cpp
@@ -48,11 +48,14 @@
**
****************************************************************************/
-#include <QtWidgets>
-
#include "database.h"
#include "mainwindow.h"
+#include <QApplication>
+#include <QFile>
+
+#include <stdlib.h>
+
int main(int argc, char *argv[])
{
Q_INIT_RESOURCE(masterdetail);
@@ -60,10 +63,10 @@ int main(int argc, char *argv[])
QApplication app(argc, argv);
if (!createConnection())
- return 1;
+ return EXIT_FAILURE;
- QFile *albumDetails = new QFile("albumdetails.xml");
- MainWindow window("artists", "albums", albumDetails);
+ QFile albumDetails("albumdetails.xml");
+ MainWindow window("artists", "albums", &albumDetails);
window.show();
return app.exec();
}
diff --git a/examples/sql/masterdetail/mainwindow.cpp b/examples/sql/masterdetail/mainwindow.cpp
index 9fbc4c43a4..7f3479619a 100644
--- a/examples/sql/masterdetail/mainwindow.cpp
+++ b/examples/sql/masterdetail/mainwindow.cpp
@@ -78,10 +78,10 @@ MainWindow::MainWindow(const QString &artistTable, const QString &albumTable,
uniqueAlbumId = model->rowCount();
uniqueArtistId = artistView->count();
- connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)),
- this, SLOT(updateHeader(QModelIndex,int,int)));
- connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
- this, SLOT(updateHeader(QModelIndex,int,int)));
+ connect(model, &QSqlRelationalTableModel::rowsInserted,
+ this, &MainWindow::updateHeader);
+ connect(model, &QSqlRelationalTableModel::rowsRemoved,
+ this, &MainWindow::updateHeader);
QGridLayout *layout = new QGridLayout;
layout->addWidget(artists, 0, 0);
@@ -145,7 +145,7 @@ void MainWindow::showAlbumDetails(QModelIndex index)
titleLabel->show();
QDomNodeList albums = albumData.elementsByTagName("album");
- for (int i = 0; i < albums.count(); i++) {
+ for (int i = 0; i < albums.count(); ++i) {
QDomNode album = albums.item(i);
if (album.toElement().attribute("id") == albumId) {
getTrackList(album.toElement());
@@ -164,9 +164,9 @@ void MainWindow::getTrackList(QDomNode album)
QDomNode track;
QString trackNumber;
- for (int j = 0; j < tracks.count(); j++) {
+ for (int i = 0; i < tracks.count(); ++i) {
- track = tracks.item(j);
+ track = tracks.item(i);
trackNumber = track.toElement().attribute("number");
QListWidgetItem *item = new QListWidgetItem(trackList);
@@ -222,7 +222,7 @@ void MainWindow::removeAlbumFromFile(int id)
QDomNodeList albums = albumData.elementsByTagName("album");
- for (int i = 0; i < albums.count(); i++) {
+ for (int i = 0; i < albums.count(); ++i) {
QDomNode node = albums.item(i);
if (node.toElement().attribute("id").toInt() == id) {
albumData.elementsByTagName("archive").item(0).removeChild(node);
@@ -283,8 +283,8 @@ QGroupBox* MainWindow::createArtistGroupBox()
artistView->setModel(model->relationModel(2));
artistView->setModelColumn(1);
- connect(artistView, SIGNAL(currentIndexChanged(int)),
- this, SLOT(changeArtist(int)));
+ connect(artistView, QOverload<int>::of(&QComboBox::currentIndexChanged),
+ this, &MainWindow::changeArtist);
QGroupBox *box = new QGroupBox(tr("Artist"));
@@ -314,10 +314,10 @@ QGroupBox* MainWindow::createAlbumGroupBox()
locale.setNumberOptions(QLocale::OmitGroupSeparator);
albumView->setLocale(locale);
- connect(albumView, SIGNAL(clicked(QModelIndex)),
- this, SLOT(showAlbumDetails(QModelIndex)));
- connect(albumView, SIGNAL(activated(QModelIndex)),
- this, SLOT(showAlbumDetails(QModelIndex)));
+ connect(albumView, &QTableView::clicked,
+ this, &MainWindow::showAlbumDetails);
+ connect(albumView, &QTableView::activated,
+ this, &MainWindow::showAlbumDetails);
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(albumView, 0, 0);
@@ -383,11 +383,16 @@ void MainWindow::createMenuBar()
helpMenu->addAction(aboutAction);
helpMenu->addAction(aboutQtAction);
- connect(addAction, SIGNAL(triggered(bool)), this, SLOT(addAlbum()));
- connect(deleteAction, SIGNAL(triggered(bool)), this, SLOT(deleteAlbum()));
- connect(quitAction, SIGNAL(triggered(bool)), this, SLOT(close()));
- connect(aboutAction, SIGNAL(triggered(bool)), this, SLOT(about()));
- connect(aboutQtAction, SIGNAL(triggered(bool)), qApp, SLOT(aboutQt()));
+ connect(addAction, &QAction::triggered,
+ this, &MainWindow::addAlbum);
+ connect(deleteAction, &QAction::triggered,
+ this, &MainWindow::deleteAlbum);
+ connect(quitAction, &QAction::triggered,
+ this, &MainWindow::close);
+ connect(aboutAction, &QAction::triggered,
+ this, &MainWindow::about);
+ connect(aboutQtAction, &QAction::triggered,
+ qApp, &QApplication::aboutQt);
}
void MainWindow::showImageLabel()
diff --git a/examples/sql/masterdetail/mainwindow.h b/examples/sql/masterdetail/mainwindow.h
index be3c6c94f4..dc6d8d1613 100644
--- a/examples/sql/masterdetail/mainwindow.h
+++ b/examples/sql/masterdetail/mainwindow.h
@@ -71,7 +71,7 @@ class MainWindow : public QMainWindow
public:
MainWindow(const QString &artistTable, const QString &albumTable,
- QFile *albumDetails, QWidget *parent = 0);
+ QFile *albumDetails, QWidget *parent = nullptr);
private slots:
void about();
diff --git a/examples/sql/querymodel/customsqlmodel.h b/examples/sql/querymodel/customsqlmodel.h
index 5d2f625665..462d2ab822 100644
--- a/examples/sql/querymodel/customsqlmodel.h
+++ b/examples/sql/querymodel/customsqlmodel.h
@@ -59,7 +59,7 @@ class CustomSqlModel : public QSqlQueryModel
Q_OBJECT
public:
- CustomSqlModel(QObject *parent = 0);
+ CustomSqlModel(QObject *parent = nullptr);
QVariant data(const QModelIndex &item, int role) const override;
};
diff --git a/examples/sql/querymodel/editablesqlmodel.h b/examples/sql/querymodel/editablesqlmodel.h
index 1341dd372a..e8caad2765 100644
--- a/examples/sql/querymodel/editablesqlmodel.h
+++ b/examples/sql/querymodel/editablesqlmodel.h
@@ -58,7 +58,7 @@ class EditableSqlModel : public QSqlQueryModel
Q_OBJECT
public:
- EditableSqlModel(QObject *parent = 0);
+ EditableSqlModel(QObject *parent = nullptr);
Qt::ItemFlags flags(const QModelIndex &index) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
diff --git a/examples/sql/querymodel/main.cpp b/examples/sql/querymodel/main.cpp
index 83804682f9..da19939dd8 100644
--- a/examples/sql/querymodel/main.cpp
+++ b/examples/sql/querymodel/main.cpp
@@ -48,12 +48,15 @@
**
****************************************************************************/
-#include <QtWidgets>
-
#include "../connection.h"
#include "customsqlmodel.h"
#include "editablesqlmodel.h"
+#include <QApplication>
+#include <QTableView>
+
+#include <stdlib.h>
+
void initializeModel(QSqlQueryModel *model)
{
model->setQuery("select * from person");
@@ -80,7 +83,7 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
if (!createConnection())
- return 1;
+ return EXIT_FAILURE;
QSqlQueryModel plainModel;
EditableSqlModel editableModel;
diff --git a/examples/sql/relationaltablemodel/relationaltablemodel.cpp b/examples/sql/relationaltablemodel/relationaltablemodel.cpp
index 5292256cd9..c3c7d48d70 100644
--- a/examples/sql/relationaltablemodel/relationaltablemodel.cpp
+++ b/examples/sql/relationaltablemodel/relationaltablemodel.cpp
@@ -110,7 +110,8 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
if (!createConnection())
- return 1;
+ return EXIT_FAILURE;
+
createRelationalTables();
QSqlRelationalTableModel model;
diff --git a/examples/sql/sqlbrowser/browser.cpp b/examples/sql/sqlbrowser/browser.cpp
index d86c54404d..b05cf52099 100644
--- a/examples/sql/sqlbrowser/browser.cpp
+++ b/examples/sql/sqlbrowser/browser.cpp
@@ -165,11 +165,12 @@ void Browser::showTable(const QString &t)
model->select();
if (model->lastError().type() != QSqlError::NoError)
emit statusMessage(model->lastError().text());
+
table->setModel(model);
table->setEditTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
+ connect(table->selectionModel(), &QItemSelectionModel::currentRowChanged,
+ this, &Browser::currentChanged);
- connect(table->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
- this, SLOT(currentChanged()));
updateActions();
}
@@ -189,7 +190,6 @@ void Browser::showMetaData(const QString &t)
model->setHeaderData(5, Qt::Horizontal, "AutoValue");
model->setHeaderData(6, Qt::Horizontal, "DefaultValue");
-
for (int i = 0; i < rec.count(); ++i) {
QSqlField fld = rec.field(i);
model->setData(model->index(i, 0), fld.name());
diff --git a/examples/sql/sqlbrowser/browser.h b/examples/sql/sqlbrowser/browser.h
index fef410778b..3f98f487c3 100644
--- a/examples/sql/sqlbrowser/browser.h
+++ b/examples/sql/sqlbrowser/browser.h
@@ -65,7 +65,7 @@ class Browser: public QWidget, private Ui::Browser
{
Q_OBJECT
public:
- Browser(QWidget *parent = 0);
+ Browser(QWidget *parent = nullptr);
virtual ~Browser();
QSqlError addConnection(const QString &driver, const QString &dbName, const QString &host,
@@ -116,7 +116,9 @@ class CustomModel: public QSqlTableModel
{
Q_OBJECT
public:
- explicit CustomModel(QObject *parent = 0, QSqlDatabase db = QSqlDatabase()):QSqlTableModel(parent, db) {}
+ explicit CustomModel(QObject *parent = nullptr, QSqlDatabase db = QSqlDatabase())
+ : QSqlTableModel(parent, db) {}
+
QVariant data(const QModelIndex &idx, int role) const override
{
if (role == Qt::BackgroundRole && isDirty(idx))
diff --git a/examples/sql/sqlbrowser/connectionwidget.cpp b/examples/sql/sqlbrowser/connectionwidget.cpp
index 888579c9af..658cfb77dc 100644
--- a/examples/sql/sqlbrowser/connectionwidget.cpp
+++ b/examples/sql/sqlbrowser/connectionwidget.cpp
@@ -63,8 +63,8 @@ ConnectionWidget::ConnectionWidget(QWidget *parent)
tree->header()->setSectionResizeMode(QHeaderView::Stretch);
QAction *refreshAction = new QAction(tr("Refresh"), tree);
metaDataAction = new QAction(tr("Show Schema"), tree);
- connect(refreshAction, SIGNAL(triggered()), SLOT(refresh()));
- connect(metaDataAction, SIGNAL(triggered()), SLOT(showMetaData()));
+ connect(refreshAction, &QAction::triggered, this, &ConnectionWidget::refresh);
+ connect(metaDataAction, &QAction::triggered, this, &ConnectionWidget::showMetaData);
tree->addAction(refreshAction);
tree->addAction(metaDataAction);
tree->setContextMenuPolicy(Qt::ActionsContextMenu);
@@ -146,7 +146,6 @@ void ConnectionWidget::setActive(QTreeWidgetItem *item)
void ConnectionWidget::on_tree_itemActivated(QTreeWidgetItem *item, int /* column */)
{
-
if (!item)
return;
diff --git a/examples/sql/sqlbrowser/connectionwidget.h b/examples/sql/sqlbrowser/connectionwidget.h
index 8b8e3a9a62..a805765f69 100644
--- a/examples/sql/sqlbrowser/connectionwidget.h
+++ b/examples/sql/sqlbrowser/connectionwidget.h
@@ -62,7 +62,7 @@ class ConnectionWidget: public QWidget
{
Q_OBJECT
public:
- ConnectionWidget(QWidget *parent = 0);
+ ConnectionWidget(QWidget *parent = nullptr);
virtual ~ConnectionWidget();
QSqlDatabase currentDatabase() const;
diff --git a/examples/sql/sqlbrowser/main.cpp b/examples/sql/sqlbrowser/main.cpp
index 002dbc3242..ea4649b68d 100644
--- a/examples/sql/sqlbrowser/main.cpp
+++ b/examples/sql/sqlbrowser/main.cpp
@@ -80,16 +80,18 @@ int main(int argc, char *argv[])
mainWin.setCentralWidget(&browser);
QMenu *fileMenu = mainWin.menuBar()->addMenu(QObject::tr("&File"));
- fileMenu->addAction(QObject::tr("Add &Connection..."), &browser, SLOT(addConnection()));
+ fileMenu->addAction(QObject::tr("Add &Connection..."),
+ [&]() { browser.addConnection(); });
fileMenu->addSeparator();
- fileMenu->addAction(QObject::tr("&Quit"), &app, SLOT(quit()));
+ fileMenu->addAction(QObject::tr("&Quit"), []() { qApp->quit(); });
QMenu *helpMenu = mainWin.menuBar()->addMenu(QObject::tr("&Help"));
- helpMenu->addAction(QObject::tr("About"), &browser, SLOT(about()));
- helpMenu->addAction(QObject::tr("About Qt"), qApp, SLOT(aboutQt()));
+ helpMenu->addAction(QObject::tr("About"), [&]() { browser.about(); });
+ helpMenu->addAction(QObject::tr("About Qt"), []() { qApp->aboutQt(); });
- QObject::connect(&browser, SIGNAL(statusMessage(QString)),
- mainWin.statusBar(), SLOT(showMessage(QString)));
+ QObject::connect(&browser, &Browser::statusMessage, [&mainWin](const QString &text) {
+ mainWin.statusBar()->showMessage(text);
+ });
addConnectionsFromCommandline(app.arguments(), &browser);
mainWin.show();
diff --git a/examples/sql/sqlbrowser/qsqlconnectiondialog.h b/examples/sql/sqlbrowser/qsqlconnectiondialog.h
index d43955acdc..fc998d7ee9 100644
--- a/examples/sql/sqlbrowser/qsqlconnectiondialog.h
+++ b/examples/sql/sqlbrowser/qsqlconnectiondialog.h
@@ -60,7 +60,7 @@ class QSqlConnectionDialog: public QDialog
{
Q_OBJECT
public:
- QSqlConnectionDialog(QWidget *parent = 0);
+ QSqlConnectionDialog(QWidget *parent = nullptr);
~QSqlConnectionDialog();
QString driverName() const;
diff --git a/examples/sql/sqlwidgetmapper/window.cpp b/examples/sql/sqlwidgetmapper/window.cpp
index 21ce152169..b6946e2386 100644
--- a/examples/sql/sqlwidgetmapper/window.cpp
+++ b/examples/sql/sqlwidgetmapper/window.cpp
@@ -87,12 +87,12 @@ Window::Window(QWidget *parent)
//! [Set up the mapper]
//! [Set up connections and layouts]
- connect(previousButton, SIGNAL(clicked()),
- mapper, SLOT(toPrevious()));
- connect(nextButton, SIGNAL(clicked()),
- mapper, SLOT(toNext()));
- connect(mapper, SIGNAL(currentIndexChanged(int)),
- this, SLOT(updateButtons(int)));
+ connect(previousButton, &QPushButton::clicked,
+ mapper, &QDataWidgetMapper::toPrevious);
+ connect(nextButton, &QPushButton::clicked,
+ mapper, &QDataWidgetMapper::toNext);
+ connect(mapper, &QDataWidgetMapper::currentIndexChanged,
+ this, &Window::updateButtons);
QGridLayout *layout = new QGridLayout();
layout->addWidget(nameLabel, 0, 0, 1, 1);
diff --git a/examples/sql/sqlwidgetmapper/window.h b/examples/sql/sqlwidgetmapper/window.h
index bff074d954..b336997360 100644
--- a/examples/sql/sqlwidgetmapper/window.h
+++ b/examples/sql/sqlwidgetmapper/window.h
@@ -72,7 +72,7 @@ class Window : public QWidget
Q_OBJECT
public:
- Window(QWidget *parent = 0);
+ Window(QWidget *parent = nullptr);
private slots:
void updateButtons(int row);
diff --git a/examples/sql/tablemodel/tablemodel.cpp b/examples/sql/tablemodel/tablemodel.cpp
index c22e25cbef..a6e0341c23 100644
--- a/examples/sql/tablemodel/tablemodel.cpp
+++ b/examples/sql/tablemodel/tablemodel.cpp
@@ -47,11 +47,13 @@
** $QT_END_LICENSE$
**
****************************************************************************/
+#include "../connection.h"
-#include <QtWidgets>
-#include <QtSql>
+#include <QApplication>
+#include <QSqlTableModel>
+#include <QTableView>
-#include "../connection.h"
+#include <stdlib.h>
void initializeModel(QSqlTableModel *model)
{
@@ -76,7 +78,7 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
if (!createConnection())
- return 1;
+ return EXIT_FAILURE;
QSqlTableModel model;
diff --git a/examples/widgets/dialogs/dialogs.pro b/examples/widgets/dialogs/dialogs.pro
index 82e814dcb0..a29903938e 100644
--- a/examples/widgets/dialogs/dialogs.pro
+++ b/examples/widgets/dialogs/dialogs.pro
@@ -14,4 +14,3 @@ SUBDIRS = classwizard \
!qtConfig(wizard) {
SUBDIRS -= trivialwizard licensewizard classwizard
}
-wince: SUBDIRS += sipdialog
diff --git a/examples/widgets/itemviews/storageview/main.cpp b/examples/widgets/itemviews/storageview/main.cpp
index c8057186fc..f349e58fad 100644
--- a/examples/widgets/itemviews/storageview/main.cpp
+++ b/examples/widgets/itemviews/storageview/main.cpp
@@ -51,6 +51,7 @@
#include <QtWidgets/QApplication>
#include <QtWidgets/QHeaderView>
+#include <QtWidgets/QShortcut>
#include <QtWidgets/QTreeView>
#include "storagemodel.h"
@@ -60,9 +61,16 @@ int main(int argc, char *argv[])
QApplication a(argc, argv);
QTreeView view;
- view.setModel(new StorageModel(&view));
view.resize(640, 480);
+ view.setWindowTitle("Storage View");
view.setSelectionBehavior(QAbstractItemView::SelectRows);
+
+ StorageModel *model = new StorageModel(&view);
+ model->refresh();
+ QShortcut *refreshShortcut = new QShortcut(Qt::CTRL + Qt::Key_R, &view);
+ QObject::connect(refreshShortcut, &QShortcut::activated, model, &StorageModel::refresh);
+ view.setModel(model);
+
int columnCount = view.model()->columnCount();
for (int c = 0; c < columnCount; ++c)
view.resizeColumnToContents(c);
diff --git a/examples/widgets/itemviews/storageview/storagemodel.cpp b/examples/widgets/itemviews/storageview/storagemodel.cpp
index 1395c9f208..063f126d86 100644
--- a/examples/widgets/itemviews/storageview/storagemodel.cpp
+++ b/examples/widgets/itemviews/storageview/storagemodel.cpp
@@ -54,14 +54,27 @@
#include <QDir>
#include <QLocale>
#include <qmath.h>
+#include <algorithm>
#include <cmath>
StorageModel::StorageModel(QObject *parent) :
- QAbstractTableModel(parent),
- m_volumes(QStorageInfo::mountedVolumes())
+ QAbstractTableModel(parent)
{
}
+void StorageModel::refresh()
+{
+ beginResetModel();
+ m_volumes = QStorageInfo::mountedVolumes();
+ std::sort(m_volumes.begin(), m_volumes.end(),
+ [](const QStorageInfo &st1, const QStorageInfo &st2) {
+ static const QString rootSortString = QStringLiteral(" ");
+ return (st1.isRoot() ? rootSortString : st1.rootPath())
+ < (st2.isRoot() ? rootSortString : st2.rootPath());
+ });
+ endResetModel();
+}
+
int StorageModel::columnCount(const QModelIndex &/*parent*/) const
{
return ColumnCount;
@@ -74,6 +87,22 @@ int StorageModel::rowCount(const QModelIndex &parent) const
return m_volumes.count();
}
+Qt::ItemFlags StorageModel::flags(const QModelIndex &index) const
+{
+ Qt::ItemFlags result = QAbstractTableModel::flags(index);
+ switch (index.column()) {
+ case ColumnAvailable:
+ case ColumnIsReady:
+ case ColumnIsReadOnly:
+ case ColumnIsValid:
+ result |= Qt::ItemIsUserCheckable;
+ break;
+ default:
+ break;
+ }
+ return result;
+}
+
QVariant StorageModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
@@ -96,6 +125,12 @@ QVariant StorageModel::data(const QModelIndex &index, int role) const
return QLocale().formattedDataSize(volume.bytesFree());
case ColumnAvailable:
return QLocale().formattedDataSize(volume.bytesAvailable());
+ default:
+ break;
+ }
+ } else if (role == Qt::CheckStateRole) {
+ const QStorageInfo &volume = m_volumes.at(index.row());
+ switch (index.column()) {
case ColumnIsReady:
return volume.isReady();
case ColumnIsReadOnly:
@@ -105,6 +140,16 @@ QVariant StorageModel::data(const QModelIndex &index, int role) const
default:
break;
}
+ } else if (role == Qt::TextAlignmentRole) {
+ switch (index.column()) {
+ case ColumnTotal:
+ case ColumnFree:
+ case ColumnAvailable:
+ return Qt::AlignTrailing;
+ default:
+ break;
+ }
+ return Qt::AlignLeading;
} else if (role == Qt::ToolTipRole) {
QLocale locale;
const QStorageInfo &volume = m_volumes.at(index.row());
@@ -147,13 +192,13 @@ QVariant StorageModel::headerData(int section, Qt::Orientation orientation, int
switch (section) {
case ColumnRootPath:
- return tr("Root path");
+ return tr("Root Path");
case ColumnName:
return tr("Volume Name");
case ColumnDevice:
return tr("Device");
case ColumnFileSystemName:
- return tr("File system");
+ return tr("File System");
case ColumnTotal:
return tr("Total");
case ColumnFree:
diff --git a/examples/widgets/itemviews/storageview/storagemodel.h b/examples/widgets/itemviews/storageview/storagemodel.h
index 2b37414d8d..787b2f04de 100644
--- a/examples/widgets/itemviews/storageview/storagemodel.h
+++ b/examples/widgets/itemviews/storageview/storagemodel.h
@@ -74,13 +74,17 @@ public:
ColumnCount
};
- explicit StorageModel(QObject *parent = 0);
+ explicit StorageModel(QObject *parent = nullptr);
- int columnCount(const QModelIndex &parent) const;
- int rowCount(const QModelIndex &parent) const;
+ int columnCount(const QModelIndex &parent) const override;
+ int rowCount(const QModelIndex &parent) const override;
- QVariant data(const QModelIndex &index, int role) const;
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ QVariant data(const QModelIndex &index, int role) const override;
+ Qt::ItemFlags flags(const QModelIndex &index) const override;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
+
+public slots:
+ void refresh();
private:
QList<QStorageInfo> m_volumes;
diff --git a/mkspecs/android-g++/qmake.conf b/mkspecs/android-g++/qmake.conf
index 5e8a97c9d7..c8145ae66b 100644
--- a/mkspecs/android-g++/qmake.conf
+++ b/mkspecs/android-g++/qmake.conf
@@ -9,16 +9,20 @@ include(../common/linux.conf)
include(../common/gcc-base-unix.conf)
include(../common/android-base-head.conf)
-QMAKE_CC = $$NDK_TOOLCHAIN_PATH/bin/$$NDK_TOOLS_PREFIX-gcc
-QMAKE_CXX = $$NDK_TOOLCHAIN_PATH/bin/$$NDK_TOOLS_PREFIX-g++
+QMAKE_CC = $${CROSS_COMPILE}gcc
+QMAKE_CXX = $${CROSS_COMPILE}g++
QMAKE_LINK = $$QMAKE_CXX
ANDROID_SOURCES_CXX_STL_LIBDIR = $$NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$$NDK_TOOLCHAIN_VERSION/libs/$$ANDROID_TARGET_ARCH
ANDROID_STDCPP_PATH = $$ANDROID_SOURCES_CXX_STL_LIBDIR/libgnustl_shared.so
ANDROID_CXX_STL_LIBS = -lgnustl_shared -lgcc
-QMAKE_CFLAGS += --sysroot=$$ANDROID_PLATFORM_ROOT_PATH \
- -isystem $$NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$$NDK_TOOLCHAIN_VERSION/include \
+exists($$NDK_ROOT/sysroot/usr/include): \
+ QMAKE_CFLAGS += --sysroot=$$NDK_ROOT/sysroot \
+ -isystem $$NDK_ROOT/sysroot/usr/include/$$NDK_TOOLS_PREFIX
+else: QMAKE_CFLAGS += --sysroot=$$ANDROID_PLATFORM_ROOT_PATH
+
+QMAKE_CFLAGS += -isystem $$NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$$NDK_TOOLCHAIN_VERSION/include \
-isystem $$ANDROID_SOURCES_CXX_STL_LIBDIR/include
equals(ANDROID_TARGET_ARCH, armeabi)|equals(ANDROID_TARGET_ARCH, armeabi-v7a): \
diff --git a/mkspecs/common/android-base-head.conf b/mkspecs/common/android-base-head.conf
index 90cc71247a..9be6111915 100644
--- a/mkspecs/common/android-base-head.conf
+++ b/mkspecs/common/android-base-head.conf
@@ -74,3 +74,4 @@ ANDROID_PLATFORM_PATH = $$ANDROID_PLATFORM_ROOT_PATH/usr
equals(ANDROID_TARGET_ARCH, x86_64)|equals(ANDROID_TARGET_ARCH, mips64): \
QMAKE_ANDROID_PLATFORM_LIBDIR = $${QMAKE_ANDROID_PLATFORM_LIBDIR}64
+CROSS_COMPILE = $$NDK_TOOLCHAIN_PATH/bin/$$NDK_TOOLS_PREFIX-
diff --git a/mkspecs/common/android-base-tail.conf b/mkspecs/common/android-base-tail.conf
index 3472dfdf77..160caf011f 100644
--- a/mkspecs/common/android-base-tail.conf
+++ b/mkspecs/common/android-base-tail.conf
@@ -57,14 +57,14 @@ QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD
QMAKE_CXXFLAGS_HIDESYMS = $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden
# modifications to linux.conf
-QMAKE_AR = $$NDK_TOOLCHAIN_PATH/bin/$$NDK_TOOLS_PREFIX-ar cqs
-QMAKE_OBJCOPY = $$NDK_TOOLCHAIN_PATH/bin/$$NDK_TOOLS_PREFIX-objcopy
-QMAKE_NM = $$NDK_TOOLCHAIN_PATH/bin/$$NDK_TOOLS_PREFIX-nm -P
+QMAKE_AR = $${CROSS_COMPILE}ar cqs
+QMAKE_OBJCOPY = $${CROSS_COMPILE}objcopy
+QMAKE_NM = $${CROSS_COMPILE}nm -P
QMAKE_STRIP =
-#$$NDK_TOOLCHAIN_PATH/bin/$$NDK_TOOLS_PREFIX-strip
+#$${CROSS_COMPILE}strip
-QMAKE_RANLIB = $$NDK_TOOLCHAIN_PATH/bin/$$NDK_TOOLS_PREFIX-ranlib
+QMAKE_RANLIB = $${CROSS_COMPILE}ranlib
QMAKE_INCDIR_POST =
QMAKE_LIBDIR_POST = $$ANDROID_SOURCES_CXX_STL_LIBDIR
diff --git a/mkspecs/features/moc.prf b/mkspecs/features/moc.prf
index 48b05b3471..37194b2eb8 100644
--- a/mkspecs/features/moc.prf
+++ b/mkspecs/features/moc.prf
@@ -45,7 +45,7 @@ if(gcc|intel_icl|msvc):!rim_qcc:!uikit:!no_moc_predefs:if(!macos|count(QMAKE_APP
defineReplace(mocCmdBase) {
!isEmpty(WIN_INCLUDETEMP) {
- incvar = @$$WIN_INCLUDETEMP
+ incvar = @$$shell_quote($$WIN_INCLUDETEMP)
} else {
incvar =
for (inc, MOC_INCLUDEPATH): \
diff --git a/mkspecs/features/qt_common.prf b/mkspecs/features/qt_common.prf
index 65574d2635..b8e397cda3 100644
--- a/mkspecs/features/qt_common.prf
+++ b/mkspecs/features/qt_common.prf
@@ -74,10 +74,10 @@ warnings_are_errors:warning_clean {
# compiler.
clang {
# Apple clang 4.0-4.2,5.0-5.1,6.0-6.4,7.0-7.3
- # Regular clang 3.3-3.9, 4.0
+ # Regular clang 3.x-5.0
apple_ver = $${QT_APPLE_CLANG_MAJOR_VERSION}.$${QT_APPLE_CLANG_MINOR_VERSION}
reg_ver = $${QT_CLANG_MAJOR_VERSION}.$${QT_CLANG_MINOR_VERSION}
- contains(apple_ver, "4\\.[012]|5\\.[01]|6\\.[01234]|7\\.[0123]")|contains(reg_ver, "3\\.[3-9]|4\\.0") {
+ contains(apple_ver, "4\\.[012]|5\\.[01]|6\\.[01234]|7\\.[0123]")|contains(reg_ver, "[34]\\.|5\\.0") {
QMAKE_CXXFLAGS_WARN_ON += -Werror -Wno-error=\\$${LITERAL_HASH}warnings -Wno-error=deprecated-declarations $$WERROR
}
} else:intel_icc:linux {
diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf
index 21c18c7f7b..35175f1744 100644
--- a/mkspecs/features/toolchain.prf
+++ b/mkspecs/features/toolchain.prf
@@ -232,17 +232,17 @@ QMAKE_COMPILER_DEFINES += __cplusplus=$$QT_COMPILER_STDCXX
QMAKE_COMPILER_DEFINES += __INTEL_COMPILER=$$QMAKE_ICC_VER __INTEL_COMPILER_UPDATE=$$QMAKE_ICC_UPDATE_VER
!isEmpty(QMAKE_APPLE_CC): \
QMAKE_COMPILER_DEFINES += __APPLE_CC__=$$QMAKE_APPLE_CC
-!isEmpty(QT_APPLE_CLANG_MAJOR_VERSION): \
+!isEmpty(QMAKE_APPLE_CLANG_MAJOR_VERSION): \
QMAKE_COMPILER_DEFINES += __clang__ \
__clang_major__=$$QMAKE_APPLE_CLANG_MAJOR_VERSION \
__clang_minor__=$$QMAKE_APPLE_CLANG_MINOR_VERSION \
__clang_patchlevel__=$$QMAKE_APPLE_CLANG_PATCH_VERSION
-!isEmpty(QT_CLANG_MAJOR_VERSION): \
+!isEmpty(QMAKE_CLANG_MAJOR_VERSION): \
QMAKE_COMPILER_DEFINES += __clang__ \
__clang_major__=$$QMAKE_CLANG_MAJOR_VERSION \
__clang_minor__=$$QMAKE_CLANG_MINOR_VERSION \
__clang_patchlevel__=$$QMAKE_CLANG_PATCH_VERSION
-!isEmpty(QT_GCC_MAJOR_VERSION): \
+!isEmpty(QMAKE_GCC_MAJOR_VERSION): \
QMAKE_COMPILER_DEFINES += \
__GNUC__=$$QMAKE_GCC_MAJOR_VERSION \
__GNUC_MINOR__=$$QMAKE_GCC_MINOR_VERSION \
diff --git a/mkspecs/features/unix/ccache.prf b/mkspecs/features/unix/ccache.prf
new file mode 100644
index 0000000000..d5739d3eab
--- /dev/null
+++ b/mkspecs/features/unix/ccache.prf
@@ -0,0 +1,19 @@
+macx-xcode: return()
+
+darwin: load(sdk)
+
+ccache_prefix = ccache
+
+precompile_header {
+ CCACHE_SLOPPINESS += pch_defines time_macros
+
+ ccache_prefix = \
+ CCACHE_SLOPPINESS=\"$$join(CCACHE_SLOPPINESS, ',')\$${CCACHE_SLOPPINESS+,\$$CCACHE_SLOPPINESS}\" \
+ # Make sure we build sources directly, not from their preprocessed version,
+ # otherwise precompiled headers will not be used during cache misses.
+ CCACHE_CPP2=true \
+ $$ccache_prefix
+}
+
+for(tool, $$list(QMAKE_CC QMAKE_CXX QMAKE_LINK QMAKE_LINK_SHLIB QMAKE_LINK_C)): \
+ $$tool = $$ccache_prefix $$eval($$tool)
diff --git a/qmake/main.cpp b/qmake/main.cpp
index 13b18d018a..85709dc9bf 100644
--- a/qmake/main.cpp
+++ b/qmake/main.cpp
@@ -245,9 +245,15 @@ static int doLink(int argc, char **argv)
static int installFile(const QString &source, const QString &target, bool exe = false)
{
QFile sourceFile(source);
-
- QFile::remove(target);
- QDir::root().mkpath(QFileInfo(target).absolutePath());
+ QFile targetFile(target);
+ if (targetFile.exists()) {
+#ifdef Q_OS_WIN
+ targetFile.setPermissions(targetFile.permissions() | QFile::WriteUser);
+#endif
+ QFile::remove(target);
+ } else {
+ QDir::root().mkpath(QFileInfo(target).absolutePath());
+ }
if (!sourceFile.copy(target)) {
fprintf(stderr, "Error copying %s to %s: %s\n", source.toLatin1().constData(), qPrintable(target), qPrintable(sourceFile.errorString()));
@@ -255,7 +261,6 @@ static int installFile(const QString &source, const QString &target, bool exe =
}
if (exe) {
- QFile targetFile(target);
if (!targetFile.setPermissions(sourceFile.permissions() | QFileDevice::ExeOwner | QFileDevice::ExeUser |
QFileDevice::ExeGroup | QFileDevice::ExeOther)) {
fprintf(stderr, "Error setting execute permissions on %s: %s\n",
@@ -266,10 +271,20 @@ static int installFile(const QString &source, const QString &target, bool exe =
// Copy file times
QString error;
+#ifdef Q_OS_WIN
+ const QFile::Permissions permissions = targetFile.permissions();
+ const bool readOnly = !(permissions & QFile::WriteUser);
+ if (readOnly)
+ targetFile.setPermissions(permissions | QFile::WriteUser);
+#endif
if (!IoUtils::touchFile(target, sourceFile.fileName(), &error)) {
fprintf(stderr, "%s", qPrintable(error));
return 3;
}
+#ifdef Q_OS_WIN
+ if (readOnly)
+ targetFile.setPermissions(permissions);
+#endif
return 0;
}
diff --git a/src/3rdparty/pcre2/import_from_pcre2_tarball.sh b/src/3rdparty/pcre2/import_from_pcre2_tarball.sh
index 9e9c90b4bf..dc2fb05453 100755
--- a/src/3rdparty/pcre2/import_from_pcre2_tarball.sh
+++ b/src/3rdparty/pcre2/import_from_pcre2_tarball.sh
@@ -100,7 +100,6 @@ FILES="
src/pcre2_newline.c
src/pcre2_ord2utf.c
src/pcre2_pattern_info.c
- src/pcre2_printint.c
src/pcre2_serialize.c
src/pcre2_string_utils.c
src/pcre2_study.c
diff --git a/src/3rdparty/pcre2/pcre2.pro b/src/3rdparty/pcre2/pcre2.pro
index d3a4e08bc5..3dde2f62f8 100644
--- a/src/3rdparty/pcre2/pcre2.pro
+++ b/src/3rdparty/pcre2/pcre2.pro
@@ -15,7 +15,7 @@ load(qt_helper_lib)
DEFINES += HAVE_CONFIG_H
# platform/compiler specific definitions
-ios|qnx|winrt: DEFINES += PCRE2_DISABLE_JIT
+uikit|qnx|winrt: DEFINES += PCRE2_DISABLE_JIT
SOURCES += \
$$PWD/src/pcre2_auto_possess.c \
@@ -33,7 +33,6 @@ SOURCES += \
$$PWD/src/pcre2_newline.c \
$$PWD/src/pcre2_ord2utf.c \
$$PWD/src/pcre2_pattern_info.c \
- $$PWD/src/pcre2_printint.c \
$$PWD/src/pcre2_serialize.c \
$$PWD/src/pcre2_string_utils.c \
$$PWD/src/pcre2_study.c \
diff --git a/src/3rdparty/pcre2/src/pcre2_printint.c b/src/3rdparty/pcre2/src/pcre2_printint.c
deleted file mode 100644
index e4dd53fe8c..0000000000
--- a/src/3rdparty/pcre2/src/pcre2_printint.c
+++ /dev/null
@@ -1,831 +0,0 @@
-/*************************************************
-* Perl-Compatible Regular Expressions *
-*************************************************/
-
-/* PCRE is a library of functions to support regular expressions whose syntax
-and semantics are as close as possible to those of the Perl 5 language.
-
- Written by Philip Hazel
- Original API code Copyright (c) 1997-2012 University of Cambridge
- New API code Copyright (c) 2016-2017 University of Cambridge
-
------------------------------------------------------------------------------
-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 University of Cambridge 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.
------------------------------------------------------------------------------
-*/
-
-
-/* This module contains a PCRE private debugging function for printing out the
-internal form of a compiled regular expression, along with some supporting
-local functions. This source file is #included in pcre2test.c at each supported
-code unit width, with PCRE2_SUFFIX set appropriately, just like the functions
-that comprise the library. It can also optionally be included in
-pcre2_compile.c for detailed debugging in error situations. */
-
-
-/* Tables of operator names. The same 8-bit table is used for all code unit
-widths, so it must be defined only once. The list itself is defined in
-pcre2_internal.h, which is #included by pcre2test before this file. */
-
-#ifndef OP_LISTS_DEFINED
-static const char *OP_names[] = { OP_NAME_LIST };
-#define OP_LISTS_DEFINED
-#endif
-
-/* The functions and tables herein must all have mode-dependent names. */
-
-#define OP_lengths PCRE2_SUFFIX(OP_lengths_)
-#define get_ucpname PCRE2_SUFFIX(get_ucpname_)
-#define pcre2_printint PCRE2_SUFFIX(pcre2_printint_)
-#define print_char PCRE2_SUFFIX(print_char_)
-#define print_custring PCRE2_SUFFIX(print_custring_)
-#define print_custring_bylen PCRE2_SUFFIX(print_custring_bylen_)
-#define print_prop PCRE2_SUFFIX(print_prop_)
-
-/* Table of sizes for the fixed-length opcodes. It's defined in a macro so that
-the definition is next to the definition of the opcodes in pcre2_internal.h.
-The contents of the table are, however, mode-dependent. */
-
-static const uint8_t OP_lengths[] = { OP_LENGTHS };
-
-
-
-/*************************************************
-* Print one character from a string *
-*************************************************/
-
-/* In UTF mode the character may occupy more than one code unit.
-
-Arguments:
- f file to write to
- ptr pointer to first code unit of the character
- utf TRUE if string is UTF (will be FALSE if UTF is not supported)
-
-Returns: number of additional code units used
-*/
-
-static unsigned int
-print_char(FILE *f, PCRE2_SPTR ptr, BOOL utf)
-{
-uint32_t c = *ptr;
-BOOL one_code_unit = !utf;
-
-/* If UTF is supported and requested, check for a valid single code unit. */
-
-#ifdef SUPPORT_UNICODE
-if (utf)
- {
-#if PCRE2_CODE_UNIT_WIDTH == 8
- one_code_unit = c < 0x80;
-#elif PCRE2_CODE_UNIT_WIDTH == 16
- one_code_unit = (c & 0xfc00) != 0xd800;
-#else
- one_code_unit = (c & 0xfffff800u) != 0xd800u;
-#endif /* CODE_UNIT_WIDTH */
- }
-#endif /* SUPPORT_UNICODE */
-
-/* Handle a valid one-code-unit character at any width. */
-
-if (one_code_unit)
- {
- if (PRINTABLE(c)) fprintf(f, "%c", (char)c);
- else if (c < 0x80) fprintf(f, "\\x%02x", c);
- else fprintf(f, "\\x{%02x}", c);
- return 0;
- }
-
-/* Code for invalid UTF code units and multi-unit UTF characters is different
-for each width. If UTF is not supported, control should never get here, but we
-need a return statement to keep the compiler happy. */
-
-#ifndef SUPPORT_UNICODE
-return 0;
-#else
-
-/* Malformed UTF-8 should occur only if the sanity check has been turned off.
-Rather than swallow random bytes, just stop if we hit a bad one. Print it with
-\X instead of \x as an indication. */
-
-#if PCRE2_CODE_UNIT_WIDTH == 8
-if ((c & 0xc0) != 0xc0)
- {
- fprintf(f, "\\X{%x}", c); /* Invalid starting byte */
- return 0;
- }
-else
- {
- int i;
- int a = PRIV(utf8_table4)[c & 0x3f]; /* Number of additional bytes */
- int s = 6*a;
- c = (c & PRIV(utf8_table3)[a]) << s;
- for (i = 1; i <= a; i++)
- {
- if ((ptr[i] & 0xc0) != 0x80)
- {
- fprintf(f, "\\X{%x}", c); /* Invalid secondary byte */
- return i - 1;
- }
- s -= 6;
- c |= (ptr[i] & 0x3f) << s;
- }
- fprintf(f, "\\x{%x}", c);
- return a;
-}
-#endif /* PCRE2_CODE_UNIT_WIDTH == 8 */
-
-/* UTF-16: rather than swallow a low surrogate, just stop if we hit a bad one.
-Print it with \X instead of \x as an indication. */
-
-#if PCRE2_CODE_UNIT_WIDTH == 16
-if ((ptr[1] & 0xfc00) != 0xdc00)
- {
- fprintf(f, "\\X{%x}", c);
- return 0;
- }
-c = (((c & 0x3ff) << 10) | (ptr[1] & 0x3ff)) + 0x10000;
-fprintf(f, "\\x{%x}", c);
-return 1;
-#endif /* PCRE2_CODE_UNIT_WIDTH == 16 */
-
-/* For UTF-32 we get here only for a malformed code unit, which should only
-occur if the sanity check has been turned off. Print it with \X instead of \x
-as an indication. */
-
-#if PCRE2_CODE_UNIT_WIDTH == 32
-fprintf(f, "\\X{%x}", c);
-return 0;
-#endif /* PCRE2_CODE_UNIT_WIDTH == 32 */
-#endif /* SUPPORT_UNICODE */
-}
-
-
-
-/*************************************************
-* Print string as a list of code units *
-*************************************************/
-
-/* These take no account of UTF as they always print each individual code unit.
-The string is zero-terminated for print_custring(); the length is given for
-print_custring_bylen().
-
-Arguments:
- f file to write to
- ptr point to the string
- len length for print_custring_bylen()
-
-Returns: nothing
-*/
-
-static void
-print_custring(FILE *f, PCRE2_SPTR ptr)
-{
-while (*ptr != '\0')
- {
- uint32_t c = *ptr++;
- if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x{%x}", c);
- }
-}
-
-static void
-print_custring_bylen(FILE *f, PCRE2_SPTR ptr, PCRE2_UCHAR len)
-{
-for (; len > 0; len--)
- {
- uint32_t c = *ptr++;
- if (PRINTABLE(c)) fprintf(f, "%c", c); else fprintf(f, "\\x{%x}", c);
- }
-}
-
-
-
-/*************************************************
-* Find Unicode property name *
-*************************************************/
-
-/* When there is no UTF/UCP support, the table of names does not exist. This
-function should not be called in such configurations, because a pattern that
-tries to use Unicode properties won't compile. Rather than put lots of #ifdefs
-into the main code, however, we just put one into this function. */
-
-static const char *
-get_ucpname(unsigned int ptype, unsigned int pvalue)
-{
-#ifdef SUPPORT_UNICODE
-int i;
-for (i = PRIV(utt_size) - 1; i >= 0; i--)
- {
- if (ptype == PRIV(utt)[i].type && pvalue == PRIV(utt)[i].value) break;
- }
-return (i >= 0)? PRIV(utt_names) + PRIV(utt)[i].name_offset : "??";
-#else /* No UTF support */
-(void)ptype;
-(void)pvalue;
-return "??";
-#endif /* SUPPORT_UNICODE */
-}
-
-
-
-/*************************************************
-* Print Unicode property value *
-*************************************************/
-
-/* "Normal" properties can be printed from tables. The PT_CLIST property is a
-pseudo-property that contains a pointer to a list of case-equivalent
-characters.
-
-Arguments:
- f file to write to
- code pointer in the compiled code
- before text to print before
- after text to print after
-
-Returns: nothing
-*/
-
-static void
-print_prop(FILE *f, PCRE2_SPTR code, const char *before, const char *after)
-{
-if (code[1] != PT_CLIST)
- {
- fprintf(f, "%s%s %s%s", before, OP_names[*code], get_ucpname(code[1],
- code[2]), after);
- }
-else
- {
- const char *not = (*code == OP_PROP)? "" : "not ";
- const uint32_t *p = PRIV(ucd_caseless_sets) + code[2];
- fprintf (f, "%s%sclist", before, not);
- while (*p < NOTACHAR) fprintf(f, " %04x", *p++);
- fprintf(f, "%s", after);
- }
-}
-
-
-
-/*************************************************
-* Print compiled pattern *
-*************************************************/
-
-/* The print_lengths flag controls whether offsets and lengths of items are
-printed. Lenths can be turned off from pcre2test so that automatic tests on
-bytecode can be written that do not depend on the value of LINK_SIZE.
-
-Arguments:
- re a compiled pattern
- f the file to write to
- print_lengths show various lengths
-
-Returns: nothing
-*/
-
-static void
-pcre2_printint(pcre2_code *re, FILE *f, BOOL print_lengths)
-{
-PCRE2_SPTR codestart, nametable, code;
-uint32_t nesize = re->name_entry_size;
-BOOL utf = (re->overall_options & PCRE2_UTF) != 0;
-
-nametable = (PCRE2_SPTR)((uint8_t *)re + sizeof(pcre2_real_code));
-code = codestart = nametable + re->name_count * re->name_entry_size;
-
-for(;;)
- {
- PCRE2_SPTR ccode;
- uint32_t c;
- int i;
- const char *flag = " ";
- unsigned int extra = 0;
-
- if (print_lengths)
- fprintf(f, "%3d ", (int)(code - codestart));
- else
- fprintf(f, " ");
-
- switch(*code)
- {
-/* ========================================================================== */
- /* These cases are never obeyed. This is a fudge that causes a compile-
- time error if the vectors OP_names or OP_lengths, which are indexed
- by opcode, are not the correct length. It seems to be the only way to do
- such a check at compile time, as the sizeof() operator does not work in
- the C preprocessor. */
-
- case OP_TABLE_LENGTH:
- case OP_TABLE_LENGTH +
- ((sizeof(OP_names)/sizeof(const char *) == OP_TABLE_LENGTH) &&
- (sizeof(OP_lengths) == OP_TABLE_LENGTH)):
- return;
-/* ========================================================================== */
-
- case OP_END:
- fprintf(f, " %s\n", OP_names[*code]);
- fprintf(f, "------------------------------------------------------------------\n");
- return;
-
- case OP_CHAR:
- fprintf(f, " ");
- do
- {
- code++;
- code += 1 + print_char(f, code, utf);
- }
- while (*code == OP_CHAR);
- fprintf(f, "\n");
- continue;
-
- case OP_CHARI:
- fprintf(f, " /i ");
- do
- {
- code++;
- code += 1 + print_char(f, code, utf);
- }
- while (*code == OP_CHARI);
- fprintf(f, "\n");
- continue;
-
- case OP_CBRA:
- case OP_CBRAPOS:
- case OP_SCBRA:
- case OP_SCBRAPOS:
- if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
- else fprintf(f, " ");
- fprintf(f, "%s %d", OP_names[*code], GET2(code, 1+LINK_SIZE));
- break;
-
- case OP_BRA:
- case OP_BRAPOS:
- case OP_SBRA:
- case OP_SBRAPOS:
- case OP_KETRMAX:
- case OP_KETRMIN:
- case OP_KETRPOS:
- case OP_ALT:
- case OP_KET:
- case OP_ASSERT:
- case OP_ASSERT_NOT:
- case OP_ASSERTBACK:
- case OP_ASSERTBACK_NOT:
- case OP_ONCE:
- case OP_COND:
- case OP_SCOND:
- case OP_REVERSE:
- if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
- else fprintf(f, " ");
- fprintf(f, "%s", OP_names[*code]);
- break;
-
- case OP_CLOSE:
- fprintf(f, " %s %d", OP_names[*code], GET2(code, 1));
- break;
-
- case OP_CREF:
- fprintf(f, "%3d %s", GET2(code,1), OP_names[*code]);
- break;
-
- case OP_DNCREF:
- {
- PCRE2_SPTR entry = nametable + (GET2(code, 1) * nesize) + IMM2_SIZE;
- fprintf(f, " %s Cond ref <", flag);
- print_custring(f, entry);
- fprintf(f, ">%d", GET2(code, 1 + IMM2_SIZE));
- }
- break;
-
- case OP_RREF:
- c = GET2(code, 1);
- if (c == RREF_ANY)
- fprintf(f, " Cond recurse any");
- else
- fprintf(f, " Cond recurse %d", c);
- break;
-
- case OP_DNRREF:
- {
- PCRE2_SPTR entry = nametable + (GET2(code, 1) * nesize) + IMM2_SIZE;
- fprintf(f, " %s Cond recurse <", flag);
- print_custring(f, entry);
- fprintf(f, ">%d", GET2(code, 1 + IMM2_SIZE));
- }
- break;
-
- case OP_FALSE:
- fprintf(f, " Cond false");
- break;
-
- case OP_TRUE:
- fprintf(f, " Cond true");
- break;
-
- case OP_STARI:
- case OP_MINSTARI:
- case OP_POSSTARI:
- case OP_PLUSI:
- case OP_MINPLUSI:
- case OP_POSPLUSI:
- case OP_QUERYI:
- case OP_MINQUERYI:
- case OP_POSQUERYI:
- flag = "/i";
- /* Fall through */
- case OP_STAR:
- case OP_MINSTAR:
- case OP_POSSTAR:
- case OP_PLUS:
- case OP_MINPLUS:
- case OP_POSPLUS:
- case OP_QUERY:
- case OP_MINQUERY:
- case OP_POSQUERY:
- case OP_TYPESTAR:
- case OP_TYPEMINSTAR:
- case OP_TYPEPOSSTAR:
- case OP_TYPEPLUS:
- case OP_TYPEMINPLUS:
- case OP_TYPEPOSPLUS:
- case OP_TYPEQUERY:
- case OP_TYPEMINQUERY:
- case OP_TYPEPOSQUERY:
- fprintf(f, " %s ", flag);
-
- if (*code >= OP_TYPESTAR)
- {
- if (code[1] == OP_PROP || code[1] == OP_NOTPROP)
- {
- print_prop(f, code + 1, "", " ");
- extra = 2;
- }
- else fprintf(f, "%s", OP_names[code[1]]);
- }
- else extra = print_char(f, code+1, utf);
- fprintf(f, "%s", OP_names[*code]);
- break;
-
- case OP_EXACTI:
- case OP_UPTOI:
- case OP_MINUPTOI:
- case OP_POSUPTOI:
- flag = "/i";
- /* Fall through */
- case OP_EXACT:
- case OP_UPTO:
- case OP_MINUPTO:
- case OP_POSUPTO:
- fprintf(f, " %s ", flag);
- extra = print_char(f, code + 1 + IMM2_SIZE, utf);
- fprintf(f, "{");
- if (*code != OP_EXACT && *code != OP_EXACTI) fprintf(f, "0,");
- fprintf(f, "%d}", GET2(code,1));
- if (*code == OP_MINUPTO || *code == OP_MINUPTOI) fprintf(f, "?");
- else if (*code == OP_POSUPTO || *code == OP_POSUPTOI) fprintf(f, "+");
- break;
-
- case OP_TYPEEXACT:
- case OP_TYPEUPTO:
- case OP_TYPEMINUPTO:
- case OP_TYPEPOSUPTO:
- if (code[1 + IMM2_SIZE] == OP_PROP || code[1 + IMM2_SIZE] == OP_NOTPROP)
- {
- print_prop(f, code + IMM2_SIZE + 1, " ", " ");
- extra = 2;
- }
- else fprintf(f, " %s", OP_names[code[1 + IMM2_SIZE]]);
- fprintf(f, "{");
- if (*code != OP_TYPEEXACT) fprintf(f, "0,");
- fprintf(f, "%d}", GET2(code,1));
- if (*code == OP_TYPEMINUPTO) fprintf(f, "?");
- else if (*code == OP_TYPEPOSUPTO) fprintf(f, "+");
- break;
-
- case OP_NOTI:
- flag = "/i";
- /* Fall through */
- case OP_NOT:
- fprintf(f, " %s [^", flag);
- extra = print_char(f, code + 1, utf);
- fprintf(f, "]");
- break;
-
- case OP_NOTSTARI:
- case OP_NOTMINSTARI:
- case OP_NOTPOSSTARI:
- case OP_NOTPLUSI:
- case OP_NOTMINPLUSI:
- case OP_NOTPOSPLUSI:
- case OP_NOTQUERYI:
- case OP_NOTMINQUERYI:
- case OP_NOTPOSQUERYI:
- flag = "/i";
- /* Fall through */
-
- case OP_NOTSTAR:
- case OP_NOTMINSTAR:
- case OP_NOTPOSSTAR:
- case OP_NOTPLUS:
- case OP_NOTMINPLUS:
- case OP_NOTPOSPLUS:
- case OP_NOTQUERY:
- case OP_NOTMINQUERY:
- case OP_NOTPOSQUERY:
- fprintf(f, " %s [^", flag);
- extra = print_char(f, code + 1, utf);
- fprintf(f, "]%s", OP_names[*code]);
- break;
-
- case OP_NOTEXACTI:
- case OP_NOTUPTOI:
- case OP_NOTMINUPTOI:
- case OP_NOTPOSUPTOI:
- flag = "/i";
- /* Fall through */
-
- case OP_NOTEXACT:
- case OP_NOTUPTO:
- case OP_NOTMINUPTO:
- case OP_NOTPOSUPTO:
- fprintf(f, " %s [^", flag);
- extra = print_char(f, code + 1 + IMM2_SIZE, utf);
- fprintf(f, "]{");
- if (*code != OP_NOTEXACT && *code != OP_NOTEXACTI) fprintf(f, "0,");
- fprintf(f, "%d}", GET2(code,1));
- if (*code == OP_NOTMINUPTO || *code == OP_NOTMINUPTOI) fprintf(f, "?");
- else
- if (*code == OP_NOTPOSUPTO || *code == OP_NOTPOSUPTOI) fprintf(f, "+");
- break;
-
- case OP_RECURSE:
- if (print_lengths) fprintf(f, "%3d ", GET(code, 1));
- else fprintf(f, " ");
- fprintf(f, "%s", OP_names[*code]);
- break;
-
- case OP_REFI:
- flag = "/i";
- /* Fall through */
- case OP_REF:
- fprintf(f, " %s \\%d", flag, GET2(code,1));
- ccode = code + OP_lengths[*code];
- goto CLASS_REF_REPEAT;
-
- case OP_DNREFI:
- flag = "/i";
- /* Fall through */
- case OP_DNREF:
- {
- PCRE2_SPTR entry = nametable + (GET2(code, 1) * nesize) + IMM2_SIZE;
- fprintf(f, " %s \\k<", flag);
- print_custring(f, entry);
- fprintf(f, ">%d", GET2(code, 1 + IMM2_SIZE));
- }
- ccode = code + OP_lengths[*code];
- goto CLASS_REF_REPEAT;
-
- case OP_CALLOUT:
- fprintf(f, " %s %d %d %d", OP_names[*code], code[1 + 2*LINK_SIZE],
- GET(code, 1), GET(code, 1 + LINK_SIZE));
- break;
-
- case OP_CALLOUT_STR:
- c = code[1 + 4*LINK_SIZE];
- fprintf(f, " %s %c", OP_names[*code], c);
- extra = GET(code, 1 + 2*LINK_SIZE);
- print_custring_bylen(f, code + 2 + 4*LINK_SIZE, extra - 3 - 4*LINK_SIZE);
- for (i = 0; PRIV(callout_start_delims)[i] != 0; i++)
- if (c == PRIV(callout_start_delims)[i])
- {
- c = PRIV(callout_end_delims)[i];
- break;
- }
- fprintf(f, "%c %d %d %d", c, GET(code, 1 + 3*LINK_SIZE), GET(code, 1),
- GET(code, 1 + LINK_SIZE));
- break;
-
- case OP_PROP:
- case OP_NOTPROP:
- print_prop(f, code, " ", "");
- break;
-
- /* OP_XCLASS cannot occur in 8-bit, non-UTF mode. However, there's no harm
- in having this code always here, and it makes it less messy without all
- those #ifdefs. */
-
- case OP_CLASS:
- case OP_NCLASS:
- case OP_XCLASS:
- {
- unsigned int min, max;
- BOOL printmap;
- BOOL invertmap = FALSE;
- uint8_t *map;
- uint8_t inverted_map[32];
-
- fprintf(f, " [");
-
- if (*code == OP_XCLASS)
- {
- extra = GET(code, 1);
- ccode = code + LINK_SIZE + 1;
- printmap = (*ccode & XCL_MAP) != 0;
- if ((*ccode & XCL_NOT) != 0)
- {
- invertmap = (*ccode & XCL_HASPROP) == 0;
- fprintf(f, "^");
- }
- ccode++;
- }
- else
- {
- printmap = TRUE;
- ccode = code + 1;
- }
-
- /* Print a bit map */
-
- if (printmap)
- {
- map = (uint8_t *)ccode;
- if (invertmap)
- {
- for (i = 0; i < 32; i++) inverted_map[i] = ~map[i];
- map = inverted_map;
- }
-
- for (i = 0; i < 256; i++)
- {
- if ((map[i/8] & (1 << (i&7))) != 0)
- {
- int j;
- for (j = i+1; j < 256; j++)
- if ((map[j/8] & (1 << (j&7))) == 0) break;
- if (i == '-' || i == ']') fprintf(f, "\\");
- if (PRINTABLE(i)) fprintf(f, "%c", i);
- else fprintf(f, "\\x%02x", i);
- if (--j > i)
- {
- if (j != i + 1) fprintf(f, "-");
- if (j == '-' || j == ']') fprintf(f, "\\");
- if (PRINTABLE(j)) fprintf(f, "%c", j);
- else fprintf(f, "\\x%02x", j);
- }
- i = j;
- }
- }
- ccode += 32 / sizeof(PCRE2_UCHAR);
- }
-
- /* For an XCLASS there is always some additional data */
-
- if (*code == OP_XCLASS)
- {
- PCRE2_UCHAR ch;
- while ((ch = *ccode++) != XCL_END)
- {
- BOOL not = FALSE;
- const char *notch = "";
-
- switch(ch)
- {
- case XCL_NOTPROP:
- not = TRUE;
- notch = "^";
- /* Fall through */
-
- case XCL_PROP:
- {
- unsigned int ptype = *ccode++;
- unsigned int pvalue = *ccode++;
-
- switch(ptype)
- {
- case PT_PXGRAPH:
- fprintf(f, "[:%sgraph:]", notch);
- break;
-
- case PT_PXPRINT:
- fprintf(f, "[:%sprint:]", notch);
- break;
-
- case PT_PXPUNCT:
- fprintf(f, "[:%spunct:]", notch);
- break;
-
- default:
- fprintf(f, "\\%c{%s}", (not? 'P':'p'),
- get_ucpname(ptype, pvalue));
- break;
- }
- }
- break;
-
- default:
- ccode += 1 + print_char(f, ccode, utf);
- if (ch == XCL_RANGE)
- {
- fprintf(f, "-");
- ccode += 1 + print_char(f, ccode, utf);
- }
- break;
- }
- }
- }
-
- /* Indicate a non-UTF class which was created by negation */
-
- fprintf(f, "]%s", (*code == OP_NCLASS)? " (neg)" : "");
-
- /* Handle repeats after a class or a back reference */
-
- CLASS_REF_REPEAT:
- switch(*ccode)
- {
- case OP_CRSTAR:
- case OP_CRMINSTAR:
- case OP_CRPLUS:
- case OP_CRMINPLUS:
- case OP_CRQUERY:
- case OP_CRMINQUERY:
- case OP_CRPOSSTAR:
- case OP_CRPOSPLUS:
- case OP_CRPOSQUERY:
- fprintf(f, "%s", OP_names[*ccode]);
- extra += OP_lengths[*ccode];
- break;
-
- case OP_CRRANGE:
- case OP_CRMINRANGE:
- case OP_CRPOSRANGE:
- min = GET2(ccode,1);
- max = GET2(ccode,1 + IMM2_SIZE);
- if (max == 0) fprintf(f, "{%u,}", min);
- else fprintf(f, "{%u,%u}", min, max);
- if (*ccode == OP_CRMINRANGE) fprintf(f, "?");
- else if (*ccode == OP_CRPOSRANGE) fprintf(f, "+");
- extra += OP_lengths[*ccode];
- break;
-
- /* Do nothing if it's not a repeat; this code stops picky compilers
- warning about the lack of a default code path. */
-
- default:
- break;
- }
- }
- break;
-
- case OP_MARK:
- case OP_PRUNE_ARG:
- case OP_SKIP_ARG:
- case OP_THEN_ARG:
- fprintf(f, " %s ", OP_names[*code]);
- print_custring_bylen(f, code + 2, code[1]);
- extra += code[1];
- break;
-
- case OP_THEN:
- fprintf(f, " %s", OP_names[*code]);
- break;
-
- case OP_CIRCM:
- case OP_DOLLM:
- flag = "/m";
- /* Fall through */
-
- /* Anything else is just an item with no data, but possibly a flag. */
-
- default:
- fprintf(f, " %s %s", flag, OP_names[*code]);
- break;
- }
-
- code += OP_lengths[*code] + extra;
- fprintf(f, "\n");
- }
-}
-
-/* End of pcre2_printint.c */
diff --git a/src/corelib/doc/snippets/qstring/main.cpp b/src/corelib/doc/snippets/qstring/main.cpp
index 3a6f6483fb..f740888fe7 100644
--- a/src/corelib/doc/snippets/qstring/main.cpp
+++ b/src/corelib/doc/snippets/qstring/main.cpp
@@ -263,14 +263,14 @@ void Widget::argFunction()
//! [11]
{
- //! [11]
+ //! [11-qstringview]
int i; // current file's number
int total; // number of files to process
QStringView fileName; // current file's name
QString status = QString("Processing file %1 of %2: %3")
.arg(i).arg(total).arg(fileName);
- //! [11]
+ //! [11-qstringview]
}
//! [12] //! [13]
diff --git a/src/corelib/global/qoperatingsystemversion.cpp b/src/corelib/global/qoperatingsystemversion.cpp
index 594dc6bc17..682c9bab61 100644
--- a/src/corelib/global/qoperatingsystemversion.cpp
+++ b/src/corelib/global/qoperatingsystemversion.cpp
@@ -43,6 +43,7 @@
#endif
#include <qversionnumber.h>
+#include <qdebug.h>
#if defined(Q_OS_ANDROID)
#include <private/qjni_p.h>
@@ -154,6 +155,8 @@ QT_BEGIN_NAMESPACE
\fn QOperatingSystemVersion QOperatingSystemVersion::current()
Returns a QOperatingSystemVersion indicating the current OS and its version number.
+
+ \sa currentType()
*/
#if !defined(Q_OS_DARWIN) && !defined(Q_OS_WIN)
QOperatingSystemVersion QOperatingSystemVersion::current()
@@ -300,6 +303,14 @@ int QOperatingSystemVersion::compare(const QOperatingSystemVersion &v1,
*/
/*!
+ \fn QOperatingSystemVersion::OSType QOperatingSystemVersion::currentType()
+
+ Returns the current OS type without constructing a QOperatingSystemVersion instance.
+
+ \sa current()
+*/
+
+/*!
\fn QString QOperatingSystemVersion::name() const
Returns a string representation of the OS type identified by the QOperatingSystemVersion.
@@ -510,4 +521,16 @@ const QOperatingSystemVersion QOperatingSystemVersion::AndroidNougat_MR1 =
const QOperatingSystemVersion QOperatingSystemVersion::AndroidOreo =
QOperatingSystemVersion(QOperatingSystemVersion::Android, 8, 0);
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug debug, const QOperatingSystemVersion &ov)
+{
+ QDebugStateSaver saver(debug);
+ debug.nospace();
+ debug << "QOperatingSystemVersion(" << ov.name()
+ << ", " << ov.majorVersion() << '.' << ov.minorVersion()
+ << '.' << ov.microVersion() << ')';
+ return debug;
+}
+#endif // !QT_NO_DEBUG_STREAM
+
QT_END_NAMESPACE
diff --git a/src/corelib/global/qoperatingsystemversion.h b/src/corelib/global/qoperatingsystemversion.h
index 1f3ff8e1ab..5f27deab9e 100644
--- a/src/corelib/global/qoperatingsystemversion.h
+++ b/src/corelib/global/qoperatingsystemversion.h
@@ -92,6 +92,25 @@ public:
static QOperatingSystemVersion current();
+ static Q_DECL_CONSTEXPR OSType currentType()
+ {
+#if defined(Q_OS_WIN)
+ return Windows;
+#elif defined(Q_OS_MACOS)
+ return MacOS;
+#elif defined(Q_OS_IOS)
+ return IOS;
+#elif defined(Q_OS_TVOS)
+ return TvOS;
+#elif defined(Q_OS_WATCHOS)
+ return WatchOS;
+#elif defined(Q_OS_ANDROID)
+ return Android;
+#else
+ return Unknown;
+#endif
+ }
+
Q_DECL_CONSTEXPR int majorVersion() const { return m_major; }
Q_DECL_CONSTEXPR int minorVersion() const { return m_minor; }
Q_DECL_CONSTEXPR int microVersion() const { return m_micro; }
@@ -128,6 +147,11 @@ private:
};
Q_DECLARE_TYPEINFO(QOperatingSystemVersion, QT_VERSION < QT_VERSION_CHECK(6, 0, 0) ? Q_RELOCATABLE_TYPE : Q_PRIMITIVE_TYPE);
+#ifndef QT_NO_DEBUG_STREAM
+class QDebug;
+Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QOperatingSystemVersion &ov);
+#endif
+
QT_END_NAMESPACE
#endif // QOPERATINGSYSTEMVERSION_H
diff --git a/src/corelib/global/qoperatingsystemversion_p.h b/src/corelib/global/qoperatingsystemversion_p.h
index 78d0daf0c6..6922f4ad54 100644
--- a/src/corelib/global/qoperatingsystemversion_p.h
+++ b/src/corelib/global/qoperatingsystemversion_p.h
@@ -63,25 +63,6 @@ QT_BEGIN_NAMESPACE
OSVERSIONINFOEX qWindowsVersionInfo();
#endif
-static inline QOperatingSystemVersion::OSType currentType()
-{
-#if defined(Q_OS_WIN)
- return QOperatingSystemVersion::Windows;
-#elif defined(Q_OS_MACOS)
- return QOperatingSystemVersion::MacOS;
-#elif defined(Q_OS_IOS)
- return QOperatingSystemVersion::IOS;
-#elif defined(Q_OS_TVOS)
- return QOperatingSystemVersion::TvOS;
-#elif defined(Q_OS_WATCHOS)
- return QOperatingSystemVersion::WatchOS;
-#elif defined(Q_OS_ANDROID)
- return QOperatingSystemVersion::Android;
-#else
- return QOperatingSystemVersion::Unknown;
-#endif
-}
-
QT_END_NAMESPACE
#endif // QOPERATINGSYSTEMVERSION_P_H
diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp
index 395bf0b0cb..2247394363 100644
--- a/src/corelib/global/qrandom.cpp
+++ b/src/corelib/global/qrandom.cpp
@@ -458,14 +458,14 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd)
reliable sequence, which may be needed for debugging.
The class can generate 32-bit or 64-bit quantities, or fill an array of
- those. The most common way of generating new values is to call the get32(),
+ those. The most common way of generating new values is to call the generate(),
get64() or fillRange() functions. One would use it as:
\code
- quint32 value = QRandomGenerator::get32();
+ quint32 value = QRandomGenerator::generate();
\endcode
- Additionally, it provides a floating-point function getReal() that returns
+ Additionally, it provides a floating-point function generateDouble() that returns
a number in the range [0, 1) (that is, inclusive of zero and exclusive of
1). There's also a set of convenience functions that facilitate obtaining a
random number in a bounded, integral range.
@@ -567,7 +567,7 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd)
Generates a 32-bit random quantity and returns it.
- \sa QRandomGenerator::get32(), QRandomGenerator::get64()
+ \sa QRandomGenerator::generate(), QRandomGenerator::generate64()
*/
/*!
@@ -611,7 +611,7 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd)
and \a end. This function is equivalent to (and is implemented as):
\code
- std::generate(begin, end, []() { return get32(); });
+ std::generate(begin, end, []() { return generate(); });
\endcode
This function complies with the requirements for the function
@@ -683,7 +683,7 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd)
*/
/*!
- \fn qreal QRandomGenerator::getReal()
+ \fn qreal QRandomGenerator::generateReal()
Generates one random qreal in the canonical range [0, 1) (that is,
inclusive of zero and exclusive of 1).
@@ -698,7 +698,7 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd)
\c{\l{http://en.cppreference.com/w/cpp/numeric/random/uniform_real_distribution}{std::uniform_real_distribution}}
with parameters 0 and 1.
- \sa get32(), get64(), bounded()
+ \sa generate(), get64(), bounded()
*/
/*!
@@ -708,10 +708,10 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd)
sup (exclusive). This function is equivalent to and is implemented as:
\code
- return getReal() * sup;
+ return generateDouble() * sup;
\endcode
- \sa getReal(), bounded()
+ \sa generateDouble(), bounded()
*/
/*!
@@ -730,13 +730,13 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd)
quint32 v = QRandomGenerator::bounded(256);
\endcode
- Naturally, the same could also be obtained by masking the result of get32()
+ Naturally, the same could also be obtained by masking the result of generate()
to only the lower 8 bits. Either solution is as efficient.
Note that this function cannot be used to obtain values in the full 32-bit
- range of quint32. Instead, use get32().
+ range of quint32. Instead, use generate().
- \sa get32(), get64(), getReal()
+ \sa generate(), get64(), generateDouble()
*/
/*!
@@ -747,9 +747,9 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd)
\a sup (exclusive). \a sup must not be negative.
Note that this function cannot be used to obtain values in the full 32-bit
- range of int. Instead, use get32() and cast to int.
+ range of int. Instead, use generate() and cast to int.
- \sa get32(), get64(), getReal()
+ \sa generate(), get64(), generateDouble()
*/
/*!
@@ -771,9 +771,9 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd)
Note that this function cannot be used to obtain values in the full 32-bit
- range of quint32. Instead, use get32().
+ range of quint32. Instead, use generate().
- \sa get32(), get64(), getReal()
+ \sa generate(), get64(), generateDouble()
*/
/*!
@@ -784,9 +784,9 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd)
(inclusive) and \a sup (exclusive), both of which may be negative.
Note that this function cannot be used to obtain values in the full 32-bit
- range of int. Instead, use get32() and cast to int.
+ range of int. Instead, use generate() and cast to int.
- \sa get32(), get64(), getReal()
+ \sa generate(), get64(), generateDouble()
*/
/*!
@@ -798,7 +798,7 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd)
from a high-quality, seed-less Random Number Generator.
QRandomGenerator64 is a simple adaptor class around QRandomGenerator, making the
- QRandomGenerator::get64() function the default for operator()(), instead of the
+ QRandomGenerator::generate64() function the default for operator()(), instead of the
function that returns 32-bit quantities. This class is intended to be used
in conjunction with Standard Library algorithms that need 64-bit quantities
instead of 32-bit ones.
@@ -824,11 +824,28 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd)
*/
/*!
+ \fn quint64 QRandomGenerator64::generate()
+
+ Generates one 64-bit random value and returns it.
+
+ Note about casting to a signed integer: all bits returned by this function
+ are random, so there's a 50% chance that the most significant bit will be
+ set. If you wish to cast the returned value to qint64 and keep it positive,
+ you should mask the sign bit off:
+
+ \code
+ qint64 value = QRandomGenerator64::generate() & std::numeric_limits<qint64>::max();
+ \endcode
+
+ \sa QRandomGenerator, QRandomGenerator::generate64()
+ */
+
+/*!
\fn result_type QRandomGenerator64::operator()()
Generates a 64-bit random quantity and returns it.
- \sa QRandomGenerator::get32(), QRandomGenerator::get64()
+ \sa QRandomGenerator::generate(), QRandomGenerator::generate64()
*/
/*!
@@ -874,12 +891,12 @@ static Q_NEVER_INLINE void fill(void *buffer, void *bufferEnd)
you should mask the sign bit off:
\code
- int value = QRandomGenerator::get32() & std::numeric_limits<int>::max();
+ int value = QRandomGenerator::generate() & std::numeric_limits<int>::max();
\endcode
- \sa get64(), getReal()
+ \sa get64(), generateDouble()
*/
-quint32 QRandomGenerator::get32()
+quint32 QRandomGenerator::generate()
{
quint32 ret;
fill(&ret, &ret + 1);
@@ -895,12 +912,12 @@ quint32 QRandomGenerator::get32()
you should mask the sign bit off:
\code
- qint64 value = QRandomGenerator::get64() & std::numeric_limits<qint64>::max();
+ qint64 value = QRandomGenerator::generate64() & std::numeric_limits<qint64>::max();
\endcode
- \sa get32(), getReal(), QRandomGenerator64
+ \sa generate(), generateDouble(), QRandomGenerator64
*/
-quint64 QRandomGenerator::get64()
+quint64 QRandomGenerator::generate64()
{
quint64 ret;
fill(&ret, &ret + 1);
diff --git a/src/corelib/global/qrandom.h b/src/corelib/global/qrandom.h
index 3bede87fa6..7f96cd6749 100644
--- a/src/corelib/global/qrandom.h
+++ b/src/corelib/global/qrandom.h
@@ -53,29 +53,27 @@ class QRandomGenerator
public:
QRandomGenerator() = default;
- static Q_CORE_EXPORT quint32 get32();
- static Q_CORE_EXPORT quint64 get64();
- static qreal getReal()
+ // ### REMOVE BEFORE 5.10
+ static quint32 get32() { return generate(); }
+ static quint64 get64() { return generate64(); }
+ static qreal getReal() { return generateDouble(); }
+
+ static Q_CORE_EXPORT quint32 generate();
+ static Q_CORE_EXPORT quint64 generate64();
+ static double generateDouble()
{
- const int digits = std::numeric_limits<qreal>::digits;
- if (digits < std::numeric_limits<quint32>::digits) {
- // use get32()
- return qreal(get32()) / ((max)() + qreal(1.0));
- } else {
- // use get64()
- // we won't have enough bits for a __float128 though
- return qreal(get64()) / ((std::numeric_limits<quint64>::max)() + qreal(1.0));
- }
+ // use get64() to get enough bits
+ return double(generate64()) / ((std::numeric_limits<quint64>::max)() + double(1.0));
}
static qreal bounded(qreal sup)
{
- return getReal() * sup;
+ return generateDouble() * sup;
}
static quint32 bounded(quint32 sup)
{
- quint64 value = get32();
+ quint64 value = generate();
value *= sup;
value /= (max)() + quint64(1);
return quint32(value);
@@ -112,7 +110,8 @@ public:
template <typename ForwardIterator>
void generate(ForwardIterator begin, ForwardIterator end)
{
- std::generate(begin, end, &QRandomGenerator::get32);
+ auto generator = static_cast<quint32 (*)()>(&QRandomGenerator::generate);
+ std::generate(begin, end, generator);
}
void generate(quint32 *begin, quint32 *end)
@@ -122,7 +121,7 @@ public:
// API like std::random_device
typedef quint32 result_type;
- result_type operator()() { return get32(); }
+ result_type operator()() { return generate(); }
double entropy() const Q_DECL_NOTHROW { return 0.0; }
static Q_DECL_CONSTEXPR result_type min() { return (std::numeric_limits<result_type>::min)(); }
static Q_DECL_CONSTEXPR result_type max() { return (std::numeric_limits<result_type>::max)(); }
@@ -137,9 +136,11 @@ class QRandomGenerator64
public:
QRandomGenerator64() = default;
+ static quint64 generate() { return QRandomGenerator::generate64(); }
+
// API like std::random_device
typedef quint64 result_type;
- result_type operator()() { return QRandomGenerator::get64(); }
+ result_type operator()() { return QRandomGenerator::generate64(); }
double entropy() const Q_DECL_NOTHROW { return 0.0; }
static Q_DECL_CONSTEXPR result_type min() { return (std::numeric_limits<result_type>::min)(); }
static Q_DECL_CONSTEXPR result_type max() { return (std::numeric_limits<result_type>::max)(); }
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index 2828c85048..9fb3855472 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -47,6 +47,7 @@
#include <QtCore/private/qcore_unix_p.h>
#include <QtCore/qvarlengtharray.h>
+#include <pwd.h>
#include <stdlib.h> // for realpath()
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 79a9936785..35ddb41215 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -440,12 +440,17 @@ QFileSystemEntry QFileSystemEngine::getLinkTarget(const QFileSystemEntry &link,
if (data.missingFlags(QFileSystemMetaData::LinkType))
QFileSystemEngine::fillMetaData(link, data, QFileSystemMetaData::LinkType);
- QString ret;
+ QString target;
if (data.isLnkFile())
- ret = readLink(link);
+ target = readLink(link);
else if (data.isLink())
- ret = readSymLink(link);
- return QFileSystemEntry(ret);
+ target = readSymLink(link);
+ QFileSystemEntry ret(target);
+ if (!target.isEmpty() && ret.isRelative()) {
+ target.prepend(absoluteName(link).path() + QLatin1Char('/'));
+ ret = QFileSystemEntry(QDir::cleanPath(target));
+ }
+ return ret;
}
//static
diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp
index 3ecc24a5db..5865d9e19a 100644
--- a/src/corelib/io/qtemporaryfile.cpp
+++ b/src/corelib/io/qtemporaryfile.cpp
@@ -165,7 +165,7 @@ QFileSystemEntry::NativePath QTemporaryFileName::generateNext()
Char *rIter = placeholderEnd;
while (rIter != placeholderStart) {
- quint32 rnd = QRandomGenerator::get32();
+ quint32 rnd = QRandomGenerator::generate();
auto applyOne = [&]() {
quint32 v = rnd & ((1 << BitsPerCharacter) - 1);
rnd >>= BitsPerCharacter;
diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h
index d012be6c61..cd294ef8fa 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.h
+++ b/src/corelib/itemmodels/qabstractitemmodel.h
@@ -79,7 +79,7 @@ public:
return r < other.r
|| (r == other.r && (c < other.c
|| (c == other.c && (i < other.i
- || (i == other.i && m < other.m )))));
+ || (i == other.i && std::less<const QAbstractItemModel *>()(m, other.m))))));
}
private:
inline QModelIndex(int arow, int acolumn, void *ptr, const QAbstractItemModel *amodel) Q_DECL_NOTHROW
diff --git a/src/corelib/kernel/qcore_mac_objc.mm b/src/corelib/kernel/qcore_mac_objc.mm
index db7e55f4b1..24d73fa8be 100644
--- a/src/corelib/kernel/qcore_mac_objc.mm
+++ b/src/corelib/kernel/qcore_mac_objc.mm
@@ -84,18 +84,82 @@ QT_FOR_EACH_MUTABLE_CORE_GRAPHICS_TYPE(QT_DECLARE_WEAK_QDEBUG_OPERATOR_FOR_CF_TY
// -------------------------------------------------------------------------
+QT_END_NAMESPACE
+QT_USE_NAMESPACE
+@interface QT_MANGLE_NAMESPACE(QMacAutoReleasePoolTracker) : NSObject
+{
+ NSAutoreleasePool **m_pool;
+}
+-(id)initWithPool:(NSAutoreleasePool**)pool;
+@end
+@implementation QT_MANGLE_NAMESPACE(QMacAutoReleasePoolTracker)
+-(id)initWithPool:(NSAutoreleasePool**)pool
+{
+ if (self = [super init])
+ m_pool = pool;
+ return self;
+}
+-(void)dealloc
+{
+ if (*m_pool) {
+ // The pool is still valid, which means we're not being drained from
+ // the corresponding QMacAutoReleasePool (see below).
+
+ // QMacAutoReleasePool has only a single member, the NSAutoreleasePool*
+ // so the address of that member is also the QMacAutoReleasePool itself.
+ QMacAutoReleasePool *pool = reinterpret_cast<QMacAutoReleasePool *>(m_pool);
+ qWarning() << "Premature drain of" << pool << "This can happen if you've allocated"
+ << "the pool on the heap, or as a member of a heap-allocated object. This is not a"
+ << "supported use of QMacAutoReleasePool, and might result in crashes when objects"
+ << "in the pool are deallocated and then used later on under the assumption they"
+ << "will be valid until" << pool << "has been drained.";
+
+ // Reset the pool so that it's not drained again later on
+ *m_pool = nullptr;
+ }
+
+ [super dealloc];
+}
+@end
+QT_NAMESPACE_ALIAS_OBJC_CLASS(QMacAutoReleasePoolTracker);
+QT_BEGIN_NAMESPACE
+
QMacAutoReleasePool::QMacAutoReleasePool()
: pool([[NSAutoreleasePool alloc] init])
{
+ [[[QMacAutoReleasePoolTracker alloc] initWithPool:
+ reinterpret_cast<NSAutoreleasePool **>(&pool)] autorelease];
}
QMacAutoReleasePool::~QMacAutoReleasePool()
{
+ if (!pool) {
+ qWarning() << "Prematurely drained pool" << this << "finally drained. Any objects belonging"
+ << "to this pool have already been released, and have potentially been invalid since the"
+ << "premature drain earlier on.";
+ return;
+ }
+
+ // Save and reset pool before draining, so that the pool tracker can know
+ // that it's being drained by its owning pool.
+ NSAutoreleasePool *savedPool = static_cast<NSAutoreleasePool*>(pool);
+ pool = nullptr;
+
// Drain behaves the same as release, with the advantage that
// if we're ever used in a garbage-collected environment, the
// drain acts as a hint to the garbage collector to collect.
- [static_cast<NSAutoreleasePool*>(pool) drain];
+ [savedPool drain];
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug debug, const QMacAutoReleasePool *pool)
+{
+ QDebugStateSaver saver(debug);
+ debug.nospace();
+ debug << "QMacAutoReleasePool(" << (const void *)pool << ')';
+ return debug;
}
+#endif // !QT_NO_DEBUG_STREAM
#ifdef Q_OS_MACOS
/*
diff --git a/src/corelib/kernel/qcore_mac_p.h b/src/corelib/kernel/qcore_mac_p.h
index 5522a617b3..13143a08bb 100644
--- a/src/corelib/kernel/qcore_mac_p.h
+++ b/src/corelib/kernel/qcore_mac_p.h
@@ -153,6 +153,10 @@ Q_CORE_EXPORT QChar qt_mac_qtKey2CocoaKey(Qt::Key key);
Q_CORE_EXPORT Qt::Key qt_mac_cocoaKey2QtKey(QChar keyCode);
#endif
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug debug, const QMacAutoReleasePool *pool);
+#endif
+
Q_CORE_EXPORT void qt_apple_check_os_version();
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 19db06b015..d1640bdc49 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -263,7 +263,7 @@ Q_GLOBAL_STATIC(QStartUpFuncList, preRList)
typedef QList<QtCleanUpFunction> QVFuncList;
Q_GLOBAL_STATIC(QVFuncList, postRList)
#ifndef QT_NO_QOBJECT
-static QBasicMutex globalPreRoutinesMutex;
+static QBasicMutex globalRoutinesMutex;
#endif
/*!
@@ -277,13 +277,15 @@ void qAddPreRoutine(QtStartUpFunction p)
QStartUpFuncList *list = preRList();
if (!list)
return;
+
+ if (QCoreApplication::instance())
+ p();
+
// Due to C++11 parallel dynamic initialization, this can be called
// from multiple threads.
#ifndef QT_NO_THREAD
- QMutexLocker locker(&globalPreRoutinesMutex);
+ QMutexLocker locker(&globalRoutinesMutex);
#endif
- if (QCoreApplication::instance())
- p();
list->prepend(p); // in case QCoreApplication is re-created, see qt_call_pre_routines
}
@@ -292,6 +294,9 @@ void qAddPostRoutine(QtCleanUpFunction p)
QVFuncList *list = postRList();
if (!list)
return;
+#ifndef QT_NO_THREAD
+ QMutexLocker locker(&globalRoutinesMutex);
+#endif
list->prepend(p);
}
@@ -300,6 +305,9 @@ void qRemovePostRoutine(QtCleanUpFunction p)
QVFuncList *list = postRList();
if (!list)
return;
+#ifndef QT_NO_THREAD
+ QMutexLocker locker(&globalRoutinesMutex);
+#endif
list->removeAll(p);
}
@@ -308,15 +316,18 @@ static void qt_call_pre_routines()
if (!preRList.exists())
return;
+ QVFuncList list;
+ {
#ifndef QT_NO_THREAD
- QMutexLocker locker(&globalPreRoutinesMutex);
+ QMutexLocker locker(&globalRoutinesMutex);
#endif
- QVFuncList *list = &(*preRList);
- // Unlike qt_call_post_routines, we don't empty the list, because
- // Q_COREAPP_STARTUP_FUNCTION is a macro, so the user expects
- // the function to be executed every time QCoreApplication is created.
- for (int i = 0; i < list->count(); ++i)
- list->at(i)();
+ // Unlike qt_call_post_routines, we don't empty the list, because
+ // Q_COREAPP_STARTUP_FUNCTION is a macro, so the user expects
+ // the function to be executed every time QCoreApplication is created.
+ list = *preRList;
+ }
+ for (int i = 0; i < list.count(); ++i)
+ list.at(i)();
}
void Q_CORE_EXPORT qt_call_post_routines()
@@ -324,9 +335,21 @@ void Q_CORE_EXPORT qt_call_post_routines()
if (!postRList.exists())
return;
- QVFuncList *list = &(*postRList);
- while (!list->isEmpty())
- (list->takeFirst())();
+ forever {
+ QVFuncList list;
+ {
+ // extract the current list and make the stored list empty
+#ifndef QT_NO_THREAD
+ QMutexLocker locker(&globalRoutinesMutex);
+#endif
+ qSwap(*postRList, list);
+ }
+
+ if (list.isEmpty())
+ break;
+ for (QtCleanUpFunction f : qAsConst(list))
+ f();
+ }
}
@@ -2864,6 +2887,7 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc
/*!
\fn void qAddPostRoutine(QtCleanUpFunction ptr)
+ \threadsafe
\relates QCoreApplication
Adds a global routine that will be called from the QCoreApplication
@@ -2877,10 +2901,10 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc
\snippet code/src_corelib_kernel_qcoreapplication.cpp 4
- Note that for an application- or module-wide cleanup, qaddPostRoutine()
+ Note that for an application- or module-wide cleanup, qAddPostRoutine()
is often not suitable. For example, if the program is split into dynamically
loaded modules, the relevant module may be unloaded long before the
- QCoreApplication destructor is called. In such cases, if using qaddPostRoutine()
+ QCoreApplication destructor is called. In such cases, if using qAddPostRoutine()
is still desirable, qRemovePostRoutine() can be used to prevent a routine
from being called by the QCoreApplication destructor. For example, if that
routine was called before the module was unloaded.
@@ -2896,11 +2920,14 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc
By selecting the right parent object, this can often be made to
clean up the module's data at the right moment.
+ \note This function has been thread-safe since Qt 5.10.
+
\sa qRemovePostRoutine()
*/
/*!
\fn void qRemovePostRoutine(QtCleanUpFunction ptr)
+ \threadsafe
\relates QCoreApplication
\since 5.3
@@ -2909,6 +2936,8 @@ void QCoreApplication::setEventDispatcher(QAbstractEventDispatcher *eventDispatc
must have been previously added to the list by a call to
qAddPostRoutine(), otherwise this function has no effect.
+ \note This function has been thread-safe since Qt 5.10.
+
\sa qAddPostRoutine()
*/
diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h
index 963aec70e8..cd995c17f1 100644
--- a/src/corelib/kernel/qcoreapplication_p.h
+++ b/src/corelib/kernel/qcoreapplication_p.h
@@ -89,10 +89,6 @@ public:
QString appName() const;
QString appVersion() const;
-#ifdef Q_OS_MACOS
- QMacRootLevelAutoReleasePool autoReleasePool;
-#endif
-
#ifdef Q_OS_DARWIN
static QString infoDictionaryStringProperty(const QString &propertyName);
#endif
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index b79716ff4c..29429b5e55 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -3173,6 +3173,9 @@ static bool canConvertMetaObject(int fromId, int toId, QObject *fromObject)
*/
bool QVariant::canConvert(int targetTypeId) const
{
+ if (d.type == targetTypeId)
+ return true;
+
if ((targetTypeId == QMetaType::QModelIndex && d.type == QMetaType::QPersistentModelIndex)
|| (targetTypeId == QMetaType::QPersistentModelIndex && d.type == QMetaType::QModelIndex))
return true;
@@ -3639,29 +3642,36 @@ static int numericCompare(const QVariant::Private *d1, const QVariant::Private *
*/
bool QVariant::cmp(const QVariant &v) const
{
+ auto cmp_helper = [] (const QVariant::Private &d1, const QVariant::Private &d2)
+ {
+ Q_ASSERT(d1.type == d2.type);
+ if (d1.type >= QMetaType::User) {
+ int result;
+ if (QMetaType::equals(QT_PREPEND_NAMESPACE(constData(d1)), QT_PREPEND_NAMESPACE(constData(d2)), d1.type, &result))
+ return result == 0;
+ }
+ return handlerManager[d1.type]->compare(&d1, &d2);
+ };
+
// try numerics first, with C++ type promotion rules (no conversion)
if (qIsNumericType(d.type) && qIsNumericType(v.d.type))
return numericCompare(&d, &v.d) == 0;
+ if (d.type == v.d.type)
+ return cmp_helper(d, v.d);
+
QVariant v1 = *this;
QVariant v2 = v;
- if (d.type != v2.d.type) {
- if (v2.canConvert(v1.d.type)) {
- if (!v2.convert(v1.d.type))
- return false;
- } else {
- // try the opposite conversion, it might work
- qSwap(v1, v2);
- if (!v2.convert(v1.d.type))
- return false;
- }
- }
- if (v1.d.type >= QMetaType::User) {
- int result;
- if (QMetaType::equals(QT_PREPEND_NAMESPACE(constData(v1.d)), QT_PREPEND_NAMESPACE(constData(v2.d)), v1.d.type, &result))
- return result == 0;
+ if (v2.canConvert(v1.d.type)) {
+ if (!v2.convert(v1.d.type))
+ return false;
+ } else {
+ // try the opposite conversion, it might work
+ qSwap(v1, v2);
+ if (!v2.convert(v1.d.type))
+ return false;
}
- return handlerManager[v1.d.type]->compare(&v1.d, &v2.d);
+ return cmp_helper(v1.d, v2.d);
}
/*!
@@ -3677,51 +3687,53 @@ int QVariant::compare(const QVariant &v) const
if (cmp(v))
return 0;
- QVariant v1 = *this;
- QVariant v2 = v;
+ const QVariant *v1 = this;
+ const QVariant *v2 = &v;
+ QVariant converted1;
+ QVariant converted2;
- if (v1.d.type != v2.d.type) {
+ if (d.type != v.d.type) {
// if both types differ, try to convert
- if (v2.canConvert(v1.d.type)) {
- QVariant temp = v2;
- if (temp.convert(v1.d.type))
- v2 = temp;
+ if (v2->canConvert(v1->d.type)) {
+ converted2 = *v2;
+ if (converted2.convert(v1->d.type))
+ v2 = &converted2;
}
- if (v1.d.type != v2.d.type && v1.canConvert(v2.d.type)) {
- QVariant temp = v1;
- if (temp.convert(v2.d.type))
- v1 = temp;
+ if (v1->d.type != v2->d.type && v1->canConvert(v2->d.type)) {
+ converted1 = *v1;
+ if (converted1.convert(v2->d.type))
+ v1 = &converted1;
}
- if (v1.d.type != v2.d.type) {
+ if (v1->d.type != v2->d.type) {
// if conversion fails, default to toString
- int r = v1.toString().compare(v2.toString(), Qt::CaseInsensitive);
+ int r = v1->toString().compare(v2->toString(), Qt::CaseInsensitive);
if (r == 0) {
// cmp(v) returned false, so we should try to agree with it.
- return (v1.d.type < v2.d.type) ? -1 : 1;
+ return (v1->d.type < v2->d.type) ? -1 : 1;
}
return r;
}
// did we end up with two numerics? If so, restart
- if (qIsNumericType(v1.d.type) && qIsNumericType(v2.d.type))
- return v1.compare(v2);
+ if (qIsNumericType(v1->d.type) && qIsNumericType(v2->d.type))
+ return v1->compare(*v2);
}
- if (v1.d.type >= QMetaType::User) {
+ if (v1->d.type >= QMetaType::User) {
int result;
- if (QMetaType::compare(QT_PREPEND_NAMESPACE(constData(d)), QT_PREPEND_NAMESPACE(constData(v2.d)), d.type, &result))
+ if (QMetaType::compare(QT_PREPEND_NAMESPACE(constData(d)), QT_PREPEND_NAMESPACE(constData(v2->d)), d.type, &result))
return result;
}
- switch (v1.d.type) {
+ switch (v1->d.type) {
case QVariant::Date:
- return v1.toDate() < v2.toDate() ? -1 : 1;
+ return v1->toDate() < v2->toDate() ? -1 : 1;
case QVariant::Time:
- return v1.toTime() < v2.toTime() ? -1 : 1;
+ return v1->toTime() < v2->toTime() ? -1 : 1;
case QVariant::DateTime:
- return v1.toDateTime() < v2.toDateTime() ? -1 : 1;
+ return v1->toDateTime() < v2->toDateTime() ? -1 : 1;
case QVariant::StringList:
- return v1.toStringList() < v2.toStringList() ? -1 : 1;
+ return v1->toStringList() < v2->toStringList() ? -1 : 1;
}
- int r = v1.toString().compare(v2.toString(), Qt::CaseInsensitive);
+ int r = v1->toString().compare(v2->toString(), Qt::CaseInsensitive);
if (r == 0) {
// cmp(v) returned false, so we should try to agree with it.
return (d.type < v.d.type) ? -1 : 1;
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index 1ec626a53b..e3ba1e4449 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -925,6 +925,30 @@ bool QThread::isInterruptionRequested() const
\sa start()
*/
+#ifdef QTHREAD_HAS_CREATE
+class QThreadCreateThread : public QThread
+{
+public:
+ explicit QThreadCreateThread(std::future<void> &&future)
+ : m_future(std::move(future))
+ {
+ }
+
+private:
+ void run() override
+ {
+ m_future.get();
+ }
+
+ std::future<void> m_future;
+};
+
+QThread *QThread::createThreadImpl(std::future<void> &&future)
+{
+ return new QThreadCreateThread(std::move(future));
+}
+#endif // QTHREAD_HAS_CREATE
+
/*!
\class QDaemonThread
\since 5.5
diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h
index b1d02a2b75..d18152a52d 100644
--- a/src/corelib/thread/qthread.h
+++ b/src/corelib/thread/qthread.h
@@ -119,6 +119,12 @@ public:
bool event(QEvent *event) override;
int loopLevel() const;
+#ifdef Q_QDOC
+ template <typename Function, typename... Args>
+ static QThread *create(Function &&f, Args &&... args);
+ template <typename Function>
+ static QThread *create(Function &&f);
+#else
#ifdef QTHREAD_HAS_CREATE
#ifdef QTHREAD_HAS_VARIADIC_CREATE
template <typename Function, typename... Args>
@@ -128,6 +134,7 @@ public:
static QThread *create(Function &&f);
#endif
#endif
+#endif
public Q_SLOTS:
void start(Priority = InheritPriority);
@@ -158,98 +165,81 @@ protected:
private:
Q_DECLARE_PRIVATE(QThread)
+#ifdef QTHREAD_HAS_CREATE
+ static QThread *createThreadImpl(std::future<void> &&future);
+#endif
+
friend class QCoreApplication;
friend class QThreadData;
};
#ifdef QTHREAD_HAS_CREATE
-namespace QtPrivate {
-class QThreadCreateThread : public QThread
+#ifdef QTHREAD_HAS_VARIADIC_CREATE
+// C++17: std::thread's constructor complying call
+template <typename Function, typename... Args>
+QThread *QThread::create(Function &&f, Args &&... args)
{
-public:
-#if defined(QTHREAD_HAS_VARIADIC_CREATE)
- // C++17: std::thread's constructor complying call
- template <typename Function, typename... Args>
- explicit QThreadCreateThread(Function &&f, Args &&... args)
- : m_future(std::async(std::launch::deferred,
- [f = static_cast<typename std::decay<Function>::type>(std::forward<Function>(f))](auto &&... largs) mutable -> void
- {
- (void)std::invoke(std::move(f), std::forward<decltype(largs)>(largs)...);
- }, std::forward<Args>(args)...))
- {
- }
-#elif defined(__cpp_init_captures) && __cpp_init_captures >= 201304
- // C++14: implementation for just one callable
- template <typename Function>
- explicit QThreadCreateThread(Function &&f)
- : m_future(std::async(std::launch::deferred,
- [f = static_cast<typename std::decay<Function>::type>(std::forward<Function>(f))]() mutable -> void
- {
- (void)f();
- }))
- {
- }
-#else
-private:
- // C++11: same as C++14, but with a workaround for not having generalized lambda captures
- template <typename Function>
- struct Callable
- {
- explicit Callable(Function &&f)
- : m_function(std::forward<Function>(f))
+ using DecayedFunction = typename std::decay<Function>::type;
+ auto threadFunction =
+ [f = static_cast<DecayedFunction>(std::forward<Function>(f))](auto &&... largs) mutable -> void
{
- }
-
-#if defined(Q_COMPILER_DEFAULT_MEMBERS) && defined(Q_COMPILER_DELETE_MEMBERS)
- // Apply the same semantics of a lambda closure type w.r.t. the special
- // member functions, if possible: delete the copy assignment operator,
- // bring back all the others as per the RO5 (cf. §8.1.5.1/11 [expr.prim.lambda.closure])
- ~Callable() = default;
- Callable(const Callable &) = default;
- Callable(Callable &&) = default;
- Callable &operator=(const Callable &) = delete;
- Callable &operator=(Callable &&) = default;
-#endif
+ (void)std::invoke(std::move(f), std::forward<decltype(largs)>(largs)...);
+ };
- void operator()()
+ return createThreadImpl(std::async(std::launch::deferred,
+ std::move(threadFunction),
+ std::forward<Args>(args)...));
+}
+#elif defined(__cpp_init_captures) && __cpp_init_captures >= 201304
+// C++14: implementation for just one callable
+template <typename Function>
+QThread *QThread::create(Function &&f)
+{
+ using DecayedFunction = typename std::decay<Function>::type;
+ auto threadFunction =
+ [f = static_cast<DecayedFunction>(std::forward<Function>(f))]() mutable -> void
{
- (void)m_function();
- }
-
- typename std::decay<Function>::type m_function;
- };
+ (void)f();
+ };
-public:
- template <typename Function>
- explicit QThreadCreateThread(Function &&f)
- : m_future(std::async(std::launch::deferred, Callable<Function>(std::forward<Function>(f))))
+ return createThreadImpl(std::async(std::launch::deferred, std::move(threadFunction)));
+}
+#else
+// C++11: same as C++14, but with a workaround for not having generalized lambda captures
+namespace QtPrivate {
+template <typename Function>
+struct Callable
+{
+ explicit Callable(Function &&f)
+ : m_function(std::forward<Function>(f))
{
}
-#endif // QTHREAD_HAS_VARIADIC_CREATE
-private:
- void run() override
+#if defined(Q_COMPILER_DEFAULT_MEMBERS) && defined(Q_COMPILER_DELETE_MEMBERS)
+ // Apply the same semantics of a lambda closure type w.r.t. the special
+ // member functions, if possible: delete the copy assignment operator,
+ // bring back all the others as per the RO5 (cf. §8.1.5.1/11 [expr.prim.lambda.closure])
+ ~Callable() = default;
+ Callable(const Callable &) = default;
+ Callable(Callable &&) = default;
+ Callable &operator=(const Callable &) = delete;
+ Callable &operator=(Callable &&) = default;
+#endif
+
+ void operator()()
{
- m_future.get();
+ (void)m_function();
}
- std::future<void> m_future;
+ typename std::decay<Function>::type m_function;
};
-
} // namespace QtPrivate
-#ifdef QTHREAD_HAS_VARIADIC_CREATE
-template <typename Function, typename... Args>
-QThread *QThread::create(Function &&f, Args &&... args)
-{
- return new QtPrivate::QThreadCreateThread(std::forward<Function>(f), std::forward<Args>(args)...);
-}
-#else
template <typename Function>
QThread *QThread::create(Function &&f)
{
- return new QtPrivate::QThreadCreateThread(std::forward<Function>(f));
+ return createThreadImpl(std::async(std::launch::deferred, QtPrivate::Callable<Function>(std::forward<Function>(f))));
}
#endif // QTHREAD_HAS_VARIADIC_CREATE
diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp
index 2ebf910992..fd5a1106a0 100644
--- a/src/corelib/thread/qthreadpool.cpp
+++ b/src/corelib/thread/qthreadpool.cpp
@@ -606,17 +606,19 @@ void QThreadPool::reserveThread()
++d->reservedThreads;
}
-/*! \property QThreadPool::stacksize
+/*! \property QThreadPool::stackSize
This property contains the stack size for the thread pool worker
threads.
- The value of the property is uses when the thread pool creates
- new threads only. Changing it has no effect for already created
+ The value of the property is only used when the thread pool creates
+ new threads. Changing it has no effect for already created
or running threads.
The default value is 0, which makes QThread use the operating
- system default stack stize.
+ system default stack size.
+
+ \since 5.10
*/
void QThreadPool::setStackSize(uint stackSize)
{
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index e336b7e618..485c6591c2 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -296,7 +296,7 @@ static uint qt_create_qhash_seed()
return seed;
}
- seed = QRandomGenerator::get32();
+ seed = QRandomGenerator::generate();
#endif // QT_BOOTSTRAPPED
return seed;
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 5db181885c..9a46018ede 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -3814,8 +3814,6 @@ QString QLocale::toCurrencyString(double value, const QString &symbol, int preci
1000. DataSizeIecFormat uses the new IEC standard quantifiers Ki, Mi and so
on, whereas DataSizeSIFormat uses and DataSizeTraditionalFormat abuses the
older SI quantifiers k, M, etc.
-
- \sa refresh(), caching()
*/
QString QLocale::formattedDataSize(qint64 bytes, int precision, DataSizeFormats format)
{
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index 736049b722..a0e408b94a 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -851,17 +851,20 @@ Q_INLINE_TEMPLATE typename QSharedPointer<X>::difference_type operator-(T *ptr1,
template <class T, class X>
Q_INLINE_TEMPLATE bool operator<(const QSharedPointer<T> &ptr1, const QSharedPointer<X> &ptr2)
{
- return ptr1.data() < ptr2.data();
+ using CT = typename std::common_type<T *, X *>::type;
+ return std::less<CT>()(ptr1.data(), ptr2.data());
}
template <class T, class X>
Q_INLINE_TEMPLATE bool operator<(const QSharedPointer<T> &ptr1, X *ptr2)
{
- return ptr1.data() < ptr2;
+ using CT = typename std::common_type<T *, X *>::type;
+ return std::less<CT>()(ptr1.data(), ptr2);
}
template <class T, class X>
Q_INLINE_TEMPLATE bool operator<(T *ptr1, const QSharedPointer<X> &ptr2)
{
- return ptr1 < ptr2.data();
+ using CT = typename std::common_type<T *, X *>::type;
+ return std::less<CT>()(ptr1, ptr2.data());
}
//
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index ea157a23d0..eeeff280ff 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -72,6 +72,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
+#include <wchar.h>
#include "qchar.cpp"
#include "qstringmatcher.cpp"
@@ -159,6 +160,43 @@ static inline bool qt_ends_with(QStringView haystack, QStringView needle, Qt::Ca
static inline bool qt_ends_with(QStringView haystack, QLatin1String needle, Qt::CaseSensitivity cs);
static inline bool qt_ends_with(QStringView haystack, QChar needle, Qt::CaseSensitivity cs);
+qssize_t qustrlen(const ushort *str) Q_DECL_NOTHROW
+{
+ qssize_t result = 0;
+
+#ifdef __SSE2__
+ // progress until we get an aligned pointer
+ const ushort *ptr = str;
+ while (*ptr && quintptr(ptr) % 16)
+ ++ptr;
+ if (*ptr == 0)
+ return ptr - str;
+
+ // load 16 bytes and see if we have a null
+ // (aligned loads can never segfault)
+ int mask;
+ const __m128i zeroes = _mm_setzero_si128();
+ do {
+ __m128i data = _mm_load_si128(reinterpret_cast<const __m128i *>(ptr));
+ ptr += 8;
+
+ __m128i comparison = _mm_cmpeq_epi16(data, zeroes);
+ mask = _mm_movemask_epi8(comparison);
+ } while (mask == 0);
+
+ // found a null
+ uint idx = qCountTrailingZeroBits(quint32(mask));
+ return ptr - str - 8 + idx / 2;
+#endif
+
+ if (sizeof(wchar_t) == sizeof(ushort))
+ return wcslen(reinterpret_cast<const wchar_t *>(str));
+
+ while (*str++)
+ ++result;
+ return result;
+}
+
#if defined(Q_COMPILER_LAMBDA) && !defined(__OPTIMIZE_SIZE__)
namespace {
template <uint MaxCount> struct UnrollTailLoop
diff --git a/src/corelib/tools/qstringalgorithms.h b/src/corelib/tools/qstringalgorithms.h
index e1b8b90428..eaa7207bec 100644
--- a/src/corelib/tools/qstringalgorithms.h
+++ b/src/corelib/tools/qstringalgorithms.h
@@ -53,6 +53,8 @@ class QLatin1String;
class QStringView;
template <typename T> class QVector;
+Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION qssize_t qustrlen(const ushort *str) Q_DECL_NOTHROW;
+
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int qCompareStrings(QStringView lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int qCompareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW;
Q_REQUIRED_RESULT Q_CORE_EXPORT Q_DECL_PURE_FUNCTION int qCompareStrings(QLatin1String lhs, QStringView rhs, Qt::CaseSensitivity cs = Qt::CaseSensitive) Q_DECL_NOTHROW;
diff --git a/src/corelib/tools/qstringview.h b/src/corelib/tools/qstringview.h
index 24be441b00..764da71d0b 100644
--- a/src/corelib/tools/qstringview.h
+++ b/src/corelib/tools/qstringview.h
@@ -143,20 +143,22 @@ private:
{
return qssize_t(N - 1);
}
+
template <typename Char>
- static Q_DECL_RELAXED_CONSTEXPR qssize_t lengthHelperPointer(const Char *str) Q_DECL_NOTHROW
+ static qssize_t lengthHelperPointer(const Char *str) Q_DECL_NOTHROW
{
- qssize_t result = 0;
- while (*str++)
- ++result;
- return result;
+#if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
+ if (__builtin_constant_p(*str)) {
+ qssize_t result = 0;
+ while (*str++)
+ ++result;
+ }
+#endif
+ return qustrlen(reinterpret_cast<const ushort *>(str));
}
- static Q_DECL_RELAXED_CONSTEXPR qssize_t lengthHelperPointer(const QChar *str) Q_DECL_NOTHROW
+ static qssize_t lengthHelperPointer(const QChar *str) Q_DECL_NOTHROW
{
- qssize_t result = 0;
- while (!str++->isNull())
- ++result;
- return result;
+ return qustrlen(reinterpret_cast<const ushort *>(str));
}
template <typename Char>
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 4412e722f6..097033280a 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -2113,8 +2113,8 @@ static QImage convertWithPalette(const QImage &src, QImage::Format format,
Returns a copy of the image converted to the given \a format,
using the specified \a colorTable.
- Conversion from 32 bit to 8 bit indexed is a slow operation and
- will use a straightforward nearest color approach, with no
+ Conversion from RGB formats to indexed formats is a slow operation
+ and will use a straightforward nearest color approach, with no
dithering.
*/
QImage QImage::convertToFormat(Format format, const QVector<QRgb> &colorTable, Qt::ImageConversionFlags flags) const
@@ -2122,23 +2122,12 @@ QImage QImage::convertToFormat(Format format, const QVector<QRgb> &colorTable, Q
if (!d || d->format == format)
return *this;
- if (format <= QImage::Format_Indexed8 && depth() == 32) {
- return convertWithPalette(*this, format, colorTable);
- }
-
- const Image_Converter *converterPtr = &qimage_converter_map[d->format][format];
- Image_Converter converter = *converterPtr;
- if (!converter)
+ if (format == QImage::Format_Invalid)
return QImage();
+ if (format <= QImage::Format_Indexed8)
+ return convertWithPalette(convertToFormat(QImage::Format_ARGB32, flags), format, colorTable);
- QImage image(d->width, d->height, format);
- QIMAGE_SANITYCHECK_MEMORY(image);
-
- image.d->offset = offset();
- copyMetadata(image.d, d);
-
- converter(image.d, d, flags);
- return image;
+ return convertToFormat(format, flags);
}
/*!
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 5000cc35dd..55339cac8c 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -40,6 +40,7 @@
#include "qevent.h"
#include "qcursor.h"
#include "private/qguiapplication_p.h"
+#include "private/qtouchdevice_p.h"
#include "qpa/qplatformintegration.h"
#include "qpa/qplatformdrag.h"
#include "private/qevent_p.h"
@@ -2757,22 +2758,47 @@ Qt::MouseButtons QTabletEvent::buttons() const
*/
/*!
- Constructs a native gesture event of type \a type.
+ \deprecated The QTouchDevice parameter is now required
+*/
+#if QT_DEPRECATED_SINCE(5, 10)
+QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QPointF &localPos, const QPointF &windowPos,
+ const QPointF &screenPos, qreal realValue, ulong sequenceId, quint64 intValue)
+ : QInputEvent(QEvent::NativeGesture), mGestureType(type), mTouchDeviceId(255),
+ mLocalPos(localPos), mWindowPos(windowPos), mScreenPos(screenPos), mRealValue(realValue),
+ mSequenceId(sequenceId), mIntValue(intValue)
+{ }
+#endif
+
+/*!
+ Constructs a native gesture event of type \a type originating from \a device.
The points \a localPos, \a windowPos and \a screenPos specify the
gesture position relative to the receiving widget or item,
window, and screen, respectively.
\a realValue is the \macos event parameter, \a sequenceId and \a intValue are the Windows event parameters.
+ \since 5.10
*/
-QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QPointF &localPos, const QPointF &windowPos,
+QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QTouchDevice *device, const QPointF &localPos, const QPointF &windowPos,
const QPointF &screenPos, qreal realValue, ulong sequenceId, quint64 intValue)
: QInputEvent(QEvent::NativeGesture), mGestureType(type),
+ mTouchDeviceId(QTouchDevicePrivate::get(const_cast<QTouchDevice *>(device))->id),
mLocalPos(localPos), mWindowPos(windowPos), mScreenPos(screenPos), mRealValue(realValue),
mSequenceId(sequenceId), mIntValue(intValue)
{ }
/*!
+ \since 5.10
+
+ Returns the device.
+*/
+
+const QTouchDevice *QNativeGestureEvent::device() const
+{
+ return QTouchDevicePrivate::deviceById(mTouchDeviceId);
+}
+
+/*!
\fn QNativeGestureEvent::gestureType() const
\since 5.2
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index c4afde8afd..c3c7e52ece 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -301,7 +301,11 @@ protected:
class Q_GUI_EXPORT QNativeGestureEvent : public QInputEvent
{
public:
- QNativeGestureEvent(Qt::NativeGestureType type, const QPointF &localPos, const QPointF &windowPos,
+#if QT_DEPRECATED_SINCE(5, 10)
+ QT_DEPRECATED QNativeGestureEvent(Qt::NativeGestureType type, const QPointF &localPos, const QPointF &windowPos,
+ const QPointF &screenPos, qreal value, ulong sequenceId, quint64 intArgument);
+#endif
+ QNativeGestureEvent(Qt::NativeGestureType type, const QTouchDevice *dev, const QPointF &localPos, const QPointF &windowPos,
const QPointF &screenPos, qreal value, ulong sequenceId, quint64 intArgument);
Qt::NativeGestureType gestureType() const { return mGestureType; }
qreal value() const { return mRealValue; }
@@ -314,8 +318,12 @@ public:
const QPointF &windowPos() const { return mWindowPos; }
const QPointF &screenPos() const { return mScreenPos; }
+ const QTouchDevice *device() const;
+
protected:
Qt::NativeGestureType mGestureType;
+ quint8 mTouchDeviceId; // QTouchDevicePrivate::id
+ quint8 mReserved[3]; // if qreal == double clang will pad the QPointF below to a 8-byte boundary
QPointF mLocalPos;
QPointF mWindowPos;
QPointF mScreenPos;
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 88d04f978e..35332831d4 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -988,6 +988,34 @@ QList<QScreen *> QGuiApplication::screens()
}
/*!
+ Returns the screen at \a point, or \c nullptr if outside of any screen.
+
+ The \a point is in relation to the virtualGeometry() of each set of virtual
+ siblings. If the point maps to more than one set of virtual siblings the first
+ match is returned.
+
+ \since 5.10
+*/
+QScreen *QGuiApplication::screenAt(const QPoint &point)
+{
+ QVarLengthArray<const QScreen *, 8> visitedScreens;
+ for (const QScreen *screen : QGuiApplication::screens()) {
+ if (visitedScreens.contains(screen))
+ continue;
+
+ // The virtual siblings include the screen itself, so iterate directly
+ for (QScreen *sibling : screen->virtualSiblings()) {
+ if (sibling->geometry().contains(point))
+ return sibling;
+
+ visitedScreens.append(sibling);
+ }
+ }
+
+ return nullptr;
+}
+
+/*!
\fn void QGuiApplication::screenAdded(QScreen *screen)
This signal is emitted whenever a new screen \a screen has been added to the system.
@@ -1050,36 +1078,9 @@ qreal QGuiApplication::devicePixelRatio() const
*/
QWindow *QGuiApplication::topLevelAt(const QPoint &pos)
{
- const QList<QScreen *> screens = QGuiApplication::screens();
- if (!screens.isEmpty()) {
- const QList<QScreen *> primaryScreens = screens.first()->virtualSiblings();
- QScreen *windowScreen = nullptr;
-
- // Find the window on the primary virtual desktop first
- for (QScreen *screen : primaryScreens) {
- if (screen->geometry().contains(pos)) {
- windowScreen = screen;
- break;
- }
- }
-
- // If the window is not found on primary virtual desktop, find it on all screens
- // except the first which was for sure in the previous loop. Some other screens
- // may repeat. Find only when there is more than one virtual desktop.
- if (!windowScreen && screens.count() != primaryScreens.count()) {
- for (int i = 1; i < screens.size(); ++i) {
- QScreen *screen = screens.at(i);
- if (screen->geometry().contains(pos)) {
- windowScreen = screen;
- break;
- }
- }
- }
-
- if (windowScreen) {
- const QPoint devicePosition = QHighDpi::toNativePixels(pos, windowScreen);
- return windowScreen->handle()->topLevelAt(devicePosition);
- }
+ if (QScreen *windowScreen = screenAt(pos)) {
+ const QPoint devicePosition = QHighDpi::toNativePixels(pos, windowScreen);
+ return windowScreen->handle()->topLevelAt(devicePosition);
}
return nullptr;
}
@@ -2419,7 +2420,7 @@ void QGuiApplicationPrivate::processGestureEvent(QWindowSystemInterfacePrivate::
if (e->window.isNull())
return;
- QNativeGestureEvent ev(e->type, e->pos, e->pos, e->globalPos, e->realValue, e->sequenceId, e->intValue);
+ QNativeGestureEvent ev(e->type, e->device, e->pos, e->pos, e->globalPos, e->realValue, e->sequenceId, e->intValue);
ev.setTimestamp(e->timestamp);
QGuiApplication::sendSpontaneousEvent(e->window, &ev);
}
diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h
index 4394787d54..8560fcf18a 100644
--- a/src/gui/kernel/qguiapplication.h
+++ b/src/gui/kernel/qguiapplication.h
@@ -110,6 +110,8 @@ public:
static QScreen *primaryScreen();
static QList<QScreen *> screens();
+ static QScreen *screenAt(const QPoint &point);
+
qreal devicePixelRatio() const;
#ifndef QT_NO_CURSOR
diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp
index 1fba649354..1b56c7d9f2 100644
--- a/src/gui/kernel/qsimpledrag.cpp
+++ b/src/gui/kernel/qsimpledrag.cpp
@@ -117,9 +117,9 @@ void QBasicDrag::disableEventFilter()
}
-static inline QPoint getNativeMousePos(QEvent *e, QObject *o)
+static inline QPoint getNativeMousePos(QEvent *e, QWindow *window)
{
- return QHighDpi::toNativePixels(static_cast<QMouseEvent *>(e)->globalPos(), qobject_cast<QWindow*>(o));
+ return QHighDpi::toNativePixels(static_cast<QMouseEvent *>(e)->globalPos(), window);
}
bool QBasicDrag::eventFilter(QObject *o, QEvent *e)
@@ -156,14 +156,14 @@ bool QBasicDrag::eventFilter(QObject *o, QEvent *e)
case QEvent::MouseMove:
{
- QPoint nativePosition = getNativeMousePos(e, o);
+ QPoint nativePosition = getNativeMousePos(e, m_drag_icon_window);
move(nativePosition);
return true; // Eat all mouse move events
}
case QEvent::MouseButtonRelease:
disableEventFilter();
if (canDrop()) {
- QPoint nativePosition = getNativeMousePos(e, o);
+ QPoint nativePosition = getNativeMousePos(e, m_drag_icon_window);
drop(nativePosition);
} else {
cancel();
diff --git a/src/gui/kernel/qtouchdevice.cpp b/src/gui/kernel/qtouchdevice.cpp
index 0f13412fb1..511e92566e 100644
--- a/src/gui/kernel/qtouchdevice.cpp
+++ b/src/gui/kernel/qtouchdevice.cpp
@@ -235,6 +235,15 @@ bool QTouchDevicePrivate::isRegistered(const QTouchDevice *dev)
return deviceList()->contains(dev);
}
+const QTouchDevice *QTouchDevicePrivate::deviceById(quint8 id)
+{
+ QMutexLocker locker(&devicesMutex);
+ for (const QTouchDevice *dev : *deviceList())
+ if (QTouchDevicePrivate::get(const_cast<QTouchDevice *>(dev))->id == id)
+ return dev;
+ return nullptr;
+}
+
/*!
\internal
*/
diff --git a/src/gui/kernel/qtouchdevice_p.h b/src/gui/kernel/qtouchdevice_p.h
index 18d2af46a7..fc45066c2d 100644
--- a/src/gui/kernel/qtouchdevice_p.h
+++ b/src/gui/kernel/qtouchdevice_p.h
@@ -78,6 +78,7 @@ public:
static void registerDevice(const QTouchDevice *dev);
static void unregisterDevice(const QTouchDevice *dev);
static bool isRegistered(const QTouchDevice *dev);
+ static const QTouchDevice *deviceById(quint8 id);
static QTouchDevicePrivate *get(QTouchDevice *q) { return q->d; }
};
diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h
index cbb0c6a51c..ac5543f884 100644
--- a/src/gui/kernel/qwindow.h
+++ b/src/gui/kernel/qwindow.h
@@ -218,8 +218,6 @@ public:
void setBaseSize(const QSize &size);
void setSizeIncrement(const QSize &size);
- void setGeometry(int posx, int posy, int w, int h);
- void setGeometry(const QRect &rect);
QRect geometry() const;
QMargins frameMargins() const;
@@ -300,6 +298,8 @@ public Q_SLOTS:
void setY(int arg);
void setWidth(int arg);
void setHeight(int arg);
+ void setGeometry(int posx, int posy, int w, int h);
+ void setGeometry(const QRect &rect);
void setMinimumWidth(int w);
void setMinimumHeight(int h);
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index 85b2aae7dd..f9580291bc 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -850,28 +850,28 @@ void QWindowSystemInterface::handleTabletLeaveProximityEvent(int device, int poi
}
#ifndef QT_NO_GESTURES
-void QWindowSystemInterface::handleGestureEvent(QWindow *window, ulong timestamp, Qt::NativeGestureType type,
+void QWindowSystemInterface::handleGestureEvent(QWindow *window, QTouchDevice *device, ulong timestamp, Qt::NativeGestureType type,
QPointF &local, QPointF &global)
{
QWindowSystemInterfacePrivate::GestureEvent *e =
- new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, local, global);
+ new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, device, local, global);
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
}
-void QWindowSystemInterface::handleGestureEventWithRealValue(QWindow *window, ulong timestamp, Qt::NativeGestureType type,
+void QWindowSystemInterface::handleGestureEventWithRealValue(QWindow *window, QTouchDevice *device, ulong timestamp, Qt::NativeGestureType type,
qreal value, QPointF &local, QPointF &global)
{
QWindowSystemInterfacePrivate::GestureEvent *e =
- new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, local, global);
+ new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, device, local, global);
e->realValue = value;
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
}
-void QWindowSystemInterface::handleGestureEventWithSequenceIdAndValue(QWindow *window, ulong timestamp, Qt::NativeGestureType type,
+void QWindowSystemInterface::handleGestureEventWithSequenceIdAndValue(QWindow *window, QTouchDevice *device, ulong timestamp, Qt::NativeGestureType type,
ulong sequenceId, quint64 value, QPointF &local, QPointF &global)
{
QWindowSystemInterfacePrivate::GestureEvent *e =
- new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, local, global);
+ new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, device, local, global);
e->sequenceId = sequenceId;
e->intValue = value;
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h
index 566abe37a9..b9d8200c43 100644
--- a/src/gui/kernel/qwindowsysteminterface.h
+++ b/src/gui/kernel/qwindowsysteminterface.h
@@ -225,11 +225,11 @@ public:
static void handleTabletLeaveProximityEvent(int device, int pointerType, qint64 uid);
#ifndef QT_NO_GESTURES
- static void handleGestureEvent(QWindow *window, ulong timestamp, Qt::NativeGestureType type,
+ static void handleGestureEvent(QWindow *window, QTouchDevice *device, ulong timestamp, Qt::NativeGestureType type,
QPointF &local, QPointF &global);
- static void handleGestureEventWithRealValue(QWindow *window, ulong timestamp, Qt::NativeGestureType type,
+ static void handleGestureEventWithRealValue(QWindow *window, QTouchDevice *device, ulong timestamp, Qt::NativeGestureType type,
qreal value, QPointF &local, QPointF &global);
- static void handleGestureEventWithSequenceIdAndValue(QWindow *window, ulong timestamp,Qt::NativeGestureType type,
+ static void handleGestureEventWithSequenceIdAndValue(QWindow *window, QTouchDevice *device, ulong timestamp,Qt::NativeGestureType type,
ulong sequenceId, quint64 value, QPointF &local, QPointF &global);
#endif // QT_NO_GESTURES
diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h
index 060aaa4db7..c45d13cde6 100644
--- a/src/gui/kernel/qwindowsysteminterface_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_p.h
@@ -421,9 +421,9 @@ public:
#ifndef QT_NO_GESTURES
class GestureEvent : public InputEvent {
public:
- GestureEvent(QWindow *window, ulong time, Qt::NativeGestureType type, QPointF pos, QPointF globalPos)
+ GestureEvent(QWindow *window, ulong time, Qt::NativeGestureType type, QTouchDevice *dev, QPointF pos, QPointF globalPos)
: InputEvent(window, time, Gesture, Qt::NoModifier), type(type), pos(pos), globalPos(globalPos),
- realValue(0), sequenceId(0), intValue(0) { }
+ realValue(0), sequenceId(0), intValue(0), device(dev) { }
Qt::NativeGestureType type;
QPointF pos;
QPointF globalPos;
@@ -432,6 +432,7 @@ public:
// Windows
ulong sequenceId;
quint64 intValue;
+ QTouchDevice *device;
};
#endif
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp
index 2b892159c5..e421055ef3 100644
--- a/src/gui/painting/qpdf.cpp
+++ b/src/gui/painting/qpdf.cpp
@@ -1063,7 +1063,12 @@ void QPdfEngine::drawHyperlink(const QRectF &r, const QUrl &url)
char buf[256];
const QRectF rr = d->pageMatrix().mapRect(r);
- d->xprintf("<<\n/Type /Annot\n/Subtype /Link\n/Rect [");
+ d->xprintf("<<\n/Type /Annot\n/Subtype /Link\n");
+
+ if (d->pdfVersion == QPdfEngine::Version_A1b)
+ d->xprintf("/F 4\n"); // enable print flag, disable all other
+
+ d->xprintf("/Rect [");
d->xprintf("%s ", qt_real_to_string(rr.left(), buf));
d->xprintf("%s ", qt_real_to_string(rr.top(), buf));
d->xprintf("%s ", qt_real_to_string(rr.right(), buf));
@@ -2831,7 +2836,12 @@ void QPdfEnginePrivate::drawTextItem(const QPointF &p, const QTextItemInt &ti)
x2s.setNum(static_cast<double>(x2), 'f');
y2s.setNum(static_cast<double>(y2), 'f');
QByteArray rectData = x1s + ' ' + y1s + ' ' + x2s + ' ' + y2s;
- xprintf("<<\n/Type /Annot\n/Subtype /Link\n/Rect [");
+ xprintf("<<\n/Type /Annot\n/Subtype /Link\n");
+
+ if (pdfVersion == QPdfEngine::Version_A1b)
+ xprintf("/F 4\n"); // enable print flag, disable all other
+
+ xprintf("/Rect [");
xprintf(rectData.constData());
#ifdef Q_DEBUG_PDF_LINKS
xprintf("]\n/Border [16 16 1]\n/A <<\n");
diff --git a/src/network/access/access.pri b/src/network/access/access.pri
index 4281a870a7..e8669dcec8 100644
--- a/src/network/access/access.pri
+++ b/src/network/access/access.pri
@@ -1,7 +1,6 @@
# Qt network access module
HEADERS += \
- access/qftp_p.h \
access/qhttpnetworkheader_p.h \
access/qhttpnetworkrequest_p.h \
access/qhttpnetworkreply_p.h \
@@ -18,7 +17,6 @@ HEADERS += \
access/qnetworkaccessdebugpipebackend_p.h \
access/qnetworkaccessfilebackend_p.h \
access/qnetworkaccesscachebackend_p.h \
- access/qnetworkaccessftpbackend_p.h \
access/qnetworkcookie.h \
access/qnetworkcookie_p.h \
access/qnetworkcookiejar.h \
@@ -33,8 +31,6 @@ HEADERS += \
access/qnetworkreplyfileimpl_p.h \
access/qabstractnetworkcache_p.h \
access/qabstractnetworkcache.h \
- access/qnetworkdiskcache_p.h \
- access/qnetworkdiskcache.h \
access/qhttpthreaddelegate_p.h \
access/qhttpmultipart.h \
access/qhttpmultipart_p.h \
@@ -45,7 +41,6 @@ HEADERS += \
access/qhstsstore_p.h
SOURCES += \
- access/qftp.cpp \
access/qhttpnetworkheader.cpp \
access/qhttpnetworkrequest.cpp \
access/qhttpnetworkreply.cpp \
@@ -61,7 +56,6 @@ SOURCES += \
access/qnetworkaccessdebugpipebackend.cpp \
access/qnetworkaccessfilebackend.cpp \
access/qnetworkaccesscachebackend.cpp \
- access/qnetworkaccessftpbackend.cpp \
access/qnetworkcookie.cpp \
access/qnetworkcookiejar.cpp \
access/qnetworkrequest.cpp \
@@ -71,7 +65,6 @@ SOURCES += \
access/qnetworkreplyhttpimpl.cpp \
access/qnetworkreplyfileimpl.cpp \
access/qabstractnetworkcache.cpp \
- access/qnetworkdiskcache.cpp \
access/qhttpthreaddelegate.cpp \
access/qhttpmultipart.cpp \
access/qnetworkfile.cpp \
@@ -80,6 +73,24 @@ SOURCES += \
access/qhstspolicy.cpp \
access/qhstsstore.cpp
+qtConfig(ftp) {
+ HEADERS += \
+ access/qftp_p.h \
+ access/qnetworkaccessftpbackend_p.h
+
+ SOURCES += \
+ access/qftp.cpp \
+ access/qnetworkaccessftpbackend.cpp
+}
+
+qtConfig(networkdiskcache) {
+ HEADERS += \
+ access/qnetworkdiskcache_p.h \
+ access/qnetworkdiskcache.h
+
+ SOURCES += access/qnetworkdiskcache.cpp
+}
+
mac: LIBS_PRIVATE += -framework Security
include($$PWD/../../3rdparty/zlib_dependency.pri)
diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp
index 47579ba654..762ef00225 100644
--- a/src/network/access/qftp.cpp
+++ b/src/network/access/qftp.cpp
@@ -43,8 +43,6 @@
#include "private/qftp_p.h"
#include "qabstractsocket.h"
-#ifndef QT_NO_FTP
-
#include "qcoreapplication.h"
#include "qtcpsocket.h"
#include "qurlinfo_p.h"
@@ -2453,5 +2451,3 @@ QT_END_NAMESPACE
#include "qftp.moc"
#include "moc_qftp_p.cpp"
-
-#endif // QT_NO_FTP
diff --git a/src/network/access/qftp_p.h b/src/network/access/qftp_p.h
index 6cf5116798..bba1f9b09d 100644
--- a/src/network/access/qftp_p.h
+++ b/src/network/access/qftp_p.h
@@ -56,10 +56,9 @@
#include <private/qurlinfo_p.h>
#include <QtCore/qobject.h>
-QT_BEGIN_NAMESPACE
-
+QT_REQUIRE_CONFIG(ftp);
-#ifndef QT_NO_FTP
+QT_BEGIN_NAMESPACE
class QFtpPrivate;
@@ -169,8 +168,6 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_piFtpReply(int, const QString&))
};
-#endif // QT_NO_FTP
-
QT_END_NAMESPACE
#endif // QFTP_P_H
diff --git a/src/network/access/qnetworkaccesscachebackend.cpp b/src/network/access/qnetworkaccesscachebackend.cpp
index 95d87d909c..0c9a88596d 100644
--- a/src/network/access/qnetworkaccesscachebackend.cpp
+++ b/src/network/access/qnetworkaccesscachebackend.cpp
@@ -42,7 +42,9 @@
#include "qnetworkaccesscachebackend_p.h"
#include "qabstractnetworkcache.h"
#include "qfileinfo.h"
+#if QT_CONFIG(ftp)
#include "qurlinfo_p.h"
+#endif
#include "qdir.h"
#include "qcoreapplication.h"
diff --git a/src/network/access/qnetworkaccessfilebackend.cpp b/src/network/access/qnetworkaccessfilebackend.cpp
index 604394383d..a5e7daff11 100644
--- a/src/network/access/qnetworkaccessfilebackend.cpp
+++ b/src/network/access/qnetworkaccessfilebackend.cpp
@@ -39,7 +39,9 @@
#include "qnetworkaccessfilebackend_p.h"
#include "qfileinfo.h"
+#if QT_CONFIG(ftp)
#include "qurlinfo_p.h"
+#endif
#include "qdir.h"
#include "private/qnoncontiguousbytedevice_p.h"
diff --git a/src/network/access/qnetworkaccessftpbackend.cpp b/src/network/access/qnetworkaccessftpbackend.cpp
index 239f37daf5..c5404e4221 100644
--- a/src/network/access/qnetworkaccessftpbackend.cpp
+++ b/src/network/access/qnetworkaccessftpbackend.cpp
@@ -43,8 +43,6 @@
#include "private/qnoncontiguousbytedevice_p.h"
#include <QStringList>
-#ifndef QT_NO_FTP
-
QT_BEGIN_NAMESPACE
enum {
@@ -382,5 +380,3 @@ void QNetworkAccessFtpBackend::ftpRawCommandReply(int code, const QString &text)
}
QT_END_NAMESPACE
-
-#endif // QT_NO_FTP
diff --git a/src/network/access/qnetworkaccessftpbackend_p.h b/src/network/access/qnetworkaccessftpbackend_p.h
index 39a6b957f1..4bd082fb67 100644
--- a/src/network/access/qnetworkaccessftpbackend_p.h
+++ b/src/network/access/qnetworkaccessftpbackend_p.h
@@ -60,7 +60,7 @@
#include "QtCore/qpointer.h"
-#ifndef QT_NO_FTP
+QT_REQUIRE_CONFIG(ftp);
QT_BEGIN_NAMESPACE
@@ -122,6 +122,4 @@ public:
QT_END_NAMESPACE
-#endif // QT_NO_FTP
-
#endif
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 15a0359391..8bbef0a0d8 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -51,7 +51,9 @@
#include "QtNetwork/qnetworksession.h"
#include "QtNetwork/private/qsharednetworksession_p.h"
+#if QT_CONFIG(ftp)
#include "qnetworkaccessftpbackend_p.h"
+#endif
#include "qnetworkaccessfilebackend_p.h"
#include "qnetworkaccessdebugpipebackend_p.h"
#include "qnetworkaccesscachebackend_p.h"
@@ -76,9 +78,9 @@
QT_BEGIN_NAMESPACE
Q_GLOBAL_STATIC(QNetworkAccessFileBackendFactory, fileBackend)
-#ifndef QT_NO_FTP
+#if QT_CONFIG(ftp)
Q_GLOBAL_STATIC(QNetworkAccessFtpBackendFactory, ftpBackend)
-#endif // QT_NO_FTP
+#endif // QT_CONFIG(ftp)
#ifdef QT_BUILD_INTERNAL
Q_GLOBAL_STATIC(QNetworkAccessDebugPipeBackendFactory, debugpipeBackend)
@@ -146,7 +148,7 @@ bool getProxyAuth(const QString& proxyHostname, const QString &scheme, QString&
static void ensureInitialized()
{
-#ifndef QT_NO_FTP
+#if QT_CONFIG(ftp)
(void) ftpBackend();
#endif
diff --git a/src/network/access/qnetworkdiskcache.cpp b/src/network/access/qnetworkdiskcache.cpp
index d72791c1f0..fca880d9b3 100644
--- a/src/network/access/qnetworkdiskcache.cpp
+++ b/src/network/access/qnetworkdiskcache.cpp
@@ -60,8 +60,6 @@
#define MAX_COMPRESSION_SIZE (1024 * 1024 * 3)
-#ifndef QT_NO_NETWORKDISKCACHE
-
QT_BEGIN_NAMESPACE
/*!
@@ -737,5 +735,3 @@ bool QCacheItem::read(QFile *device, bool readData)
}
QT_END_NAMESPACE
-
-#endif // QT_NO_NETWORKDISKCACHE
diff --git a/src/network/access/qnetworkdiskcache.h b/src/network/access/qnetworkdiskcache.h
index ffdfd0fd1b..ff7d3192e8 100644
--- a/src/network/access/qnetworkdiskcache.h
+++ b/src/network/access/qnetworkdiskcache.h
@@ -43,10 +43,9 @@
#include <QtNetwork/qtnetworkglobal.h>
#include <QtNetwork/qabstractnetworkcache.h>
-QT_BEGIN_NAMESPACE
-
+QT_REQUIRE_CONFIG(networkdiskcache);
-#ifndef QT_NO_NETWORKDISKCACHE
+QT_BEGIN_NAMESPACE
class QNetworkDiskCachePrivate;
class Q_NETWORK_EXPORT QNetworkDiskCache : public QAbstractNetworkCache
@@ -84,8 +83,6 @@ private:
Q_DISABLE_COPY(QNetworkDiskCache)
};
-#endif // QT_NO_NETWORKDISKCACHE
-
QT_END_NAMESPACE
#endif // QNETWORKDISKCACHE_H
diff --git a/src/network/access/qnetworkdiskcache_p.h b/src/network/access/qnetworkdiskcache_p.h
index e47b93b09d..f7988e7dda 100644
--- a/src/network/access/qnetworkdiskcache_p.h
+++ b/src/network/access/qnetworkdiskcache_p.h
@@ -58,7 +58,7 @@
#include <qhash.h>
#include <qtemporaryfile.h>
-#ifndef QT_NO_NETWORKDISKCACHE
+QT_REQUIRE_CONFIG(networkdiskcache);
QT_BEGIN_NAMESPACE
@@ -123,6 +123,4 @@ public:
QT_END_NAMESPACE
-#endif // QT_NO_NETWORKDISKCACHE
-
#endif // QNETWORKDISKCACHE_P_H
diff --git a/src/network/kernel/kernel.pri b/src/network/kernel/kernel.pri
index ac6bebbfae..716f745bc9 100644
--- a/src/network/kernel/kernel.pri
+++ b/src/network/kernel/kernel.pri
@@ -17,8 +17,7 @@ HEADERS += kernel/qtnetworkglobal.h \
kernel/qnetworkdatagram_p.h \
kernel/qnetworkinterface.h \
kernel/qnetworkinterface_p.h \
- kernel/qnetworkproxy.h \
- kernel/qurlinfo_p.h
+ kernel/qnetworkproxy.h
SOURCES += kernel/qauthenticator.cpp \
kernel/qdnslookup.cpp \
@@ -26,8 +25,12 @@ SOURCES += kernel/qauthenticator.cpp \
kernel/qhostinfo.cpp \
kernel/qnetworkdatagram.cpp \
kernel/qnetworkinterface.cpp \
- kernel/qnetworkproxy.cpp \
- kernel/qurlinfo.cpp
+ kernel/qnetworkproxy.cpp
+
+qtConfig(ftp) {
+ HEADERS += kernel/qurlinfo_p.h
+ SOURCES += kernel/qurlinfo.cpp
+}
unix {
!integrity: SOURCES += kernel/qdnslookup_unix.cpp
diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp
index 7d8de71421..4f4c674d20 100644
--- a/src/network/kernel/qhostaddress.cpp
+++ b/src/network/kernel/qhostaddress.cpp
@@ -44,6 +44,7 @@
#include "qdebug.h"
#if defined(Q_OS_WIN)
# include <winsock2.h>
+# include <ws2tcpip.h>
#else
# include <netinet/in.h>
#endif
@@ -63,36 +64,6 @@
QT_BEGIN_NAMESPACE
-#ifdef Q_OS_WIN
-// 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_WINRT)
-# if !defined(u_char)
-# define u_char unsigned char
-# endif
-# if !defined(u_short)
-# define u_short unsigned short
-# endif
-# if !defined(u_long)
-# define u_long unsigned long
-# endif
-#endif
-struct qt_in6_addr {
- u_char qt_s6_addr[16];
-};
-typedef struct {
- short sin6_family; /* AF_INET6 */
- u_short sin6_port; /* Transport level port number */
- u_long sin6_flowinfo; /* IPv6 flow information */
- struct qt_in6_addr sin6_addr; /* IPv6 address */
- u_long sin6_scope_id; /* set of interfaces for a scope */
-} qt_sockaddr_in6;
-#else
-#define qt_sockaddr_in6 sockaddr_in6
-#define qt_s6_addr s6_addr
-#endif
-
class QHostAddressPrivate : public QSharedData
{
@@ -235,18 +206,8 @@ void QHostAddressPrivate::clear()
}
-bool QNetmaskAddress::setAddress(const QString &address)
-{
- d.detach();
- length = -1;
- QHostAddress other;
- return other.setAddress(address) && setAddress(other);
-}
-
-bool QNetmaskAddress::setAddress(const QHostAddress &address)
+bool QNetmask::setAddress(const QHostAddress &address)
{
- d.detach();
-
static const quint8 zeroes[16] = { 0 };
union {
quint32 v4;
@@ -258,16 +219,13 @@ bool QNetmaskAddress::setAddress(const QHostAddress &address)
quint8 *end;
length = -1;
- QHostAddress::operator=(address);
-
- if (d->protocol == QAbstractSocket::IPv4Protocol) {
- ip.v4 = qToBigEndian(d->a);
+ if (address.protocol() == QAbstractSocket::IPv4Protocol) {
+ ip.v4 = qToBigEndian(address.toIPv4Address());
end = ptr + 4;
- } else if (d->protocol == QAbstractSocket::IPv6Protocol) {
- memcpy(ip.v6, d->a6.c, 16);
+ } else if (address.protocol() == QAbstractSocket::IPv6Protocol) {
+ memcpy(ip.v6, address.toIPv6Address().c, 16);
end = ptr + 16;
} else {
- d->clear();
return false;
}
@@ -279,7 +237,6 @@ bool QNetmaskAddress::setAddress(const QHostAddress &address)
continue;
default:
- d->clear();
return false; // invalid IP-style netmask
case 254:
@@ -310,10 +267,8 @@ bool QNetmaskAddress::setAddress(const QHostAddress &address)
}
// confirm that the rest is only zeroes
- if (ptr < end && memcmp(ptr + 1, zeroes, end - ptr - 1) != 0) {
- d->clear();
+ if (ptr < end && memcmp(ptr + 1, zeroes, end - ptr - 1) != 0)
return false;
- }
length = netmask;
return true;
@@ -333,35 +288,25 @@ static void clearBits(quint8 *where, int start, int end)
memset(where + (start + 7) / 8, 0, end / 8 - (start + 7) / 8);
}
-int QNetmaskAddress::prefixLength() const
+QHostAddress QNetmask::address(QAbstractSocket::NetworkLayerProtocol protocol) const
{
- return length;
-}
-
-void QNetmaskAddress::setPrefixLength(QAbstractSocket::NetworkLayerProtocol proto, int newLength)
-{
- d.detach();
- length = newLength;
- if (length < 0 || length > (proto == QAbstractSocket::IPv4Protocol ? 32 :
- proto == QAbstractSocket::IPv6Protocol ? 128 : -1)) {
- // invalid information, reject
- d->protocol = QAbstractSocket::UnknownNetworkLayerProtocol;
- length = -1;
- return;
- }
-
- d->protocol = proto;
- if (d->protocol == QAbstractSocket::IPv4Protocol) {
- if (length == 0) {
- d->a = 0;
- } else if (length == 32) {
- d->a = quint32(0xffffffff);
- } else {
- d->a = quint32(0xffffffff) >> (32 - length) << (32 - length);
- }
+ if (length == 255 || protocol == QAbstractSocket::AnyIPProtocol ||
+ protocol == QAbstractSocket::UnknownNetworkLayerProtocol) {
+ return QHostAddress();
+ } else if (protocol == QAbstractSocket::IPv4Protocol) {
+ quint32 a;
+ if (length == 0)
+ a = 0;
+ else if (length == 32)
+ a = quint32(0xffffffff);
+ else
+ a = quint32(0xffffffff) >> (32 - length) << (32 - length);
+ return QHostAddress(a);
} else {
- memset(d->a6.c, 0xFF, sizeof(d->a6));
- clearBits(d->a6.c, length, 128);
+ Q_IPV6ADDR a6;
+ memset(a6.c, 0xFF, sizeof(a6));
+ clearBits(a6.c, length, 128);
+ return QHostAddress(a6);
}
}
@@ -495,7 +440,7 @@ QHostAddress::QHostAddress(const struct sockaddr *sockaddr)
if (sockaddr->sa_family == AF_INET)
setAddress(htonl(((const sockaddr_in *)sockaddr)->sin_addr.s_addr));
else if (sockaddr->sa_family == AF_INET6)
- setAddress(((const qt_sockaddr_in6 *)sockaddr)->sin6_addr.qt_s6_addr);
+ setAddress(((const sockaddr_in6 *)sockaddr)->sin6_addr.s6_addr);
#else
Q_UNUSED(sockaddr)
#endif
@@ -718,7 +663,7 @@ void QHostAddress::setAddress(const struct sockaddr *sockaddr)
if (sockaddr->sa_family == AF_INET)
setAddress(htonl(((const sockaddr_in *)sockaddr)->sin_addr.s_addr));
else if (sockaddr->sa_family == AF_INET6)
- setAddress(((const qt_sockaddr_in6 *)sockaddr)->sin6_addr.qt_s6_addr);
+ setAddress(((const sockaddr_in6 *)sockaddr)->sin6_addr.s6_addr);
#else
Q_UNUSED(sockaddr)
#endif
@@ -1133,8 +1078,11 @@ QPair<QHostAddress, int> QHostAddress::parseSubnet(const QString &subnet)
// is the netmask given in IP-form or in bit-count form?
if (!isIpv6 && subnet.indexOf(QLatin1Char('.'), slash + 1) != -1) {
// IP-style, convert it to bit-count form
- QNetmaskAddress parser;
- if (!parser.setAddress(subnet.mid(slash + 1)))
+ QHostAddress mask;
+ QNetmask parser;
+ if (!mask.setAddress(subnet.mid(slash + 1)))
+ return invalid;
+ if (!parser.setAddress(mask))
return invalid;
netmask = parser.prefixLength();
} else {
diff --git a/src/network/kernel/qhostaddress_p.h b/src/network/kernel/qhostaddress_p.h
index 55c3e5afde..5106760ed9 100644
--- a/src/network/kernel/qhostaddress_p.h
+++ b/src/network/kernel/qhostaddress_p.h
@@ -57,17 +57,32 @@
QT_BEGIN_NAMESPACE
-class QNetmaskAddress: public QHostAddress
+class QNetmask
{
- int length;
+ // stores 0-32 for IPv4, 0-128 for IPv6, or 255 for invalid
+ quint8 length;
public:
- QNetmaskAddress() : QHostAddress(), length(-1) { }
+ Q_DECL_CONSTEXPR QNetmask() : length(255) {}
- bool setAddress(const QString &address);
bool setAddress(const QHostAddress &address);
+ QHostAddress address(QAbstractSocket::NetworkLayerProtocol protocol) const;
- int prefixLength() const;
- void setPrefixLength(QAbstractSocket::NetworkLayerProtocol proto, int len);
+ int prefixLength() const { return length == 255 ? -1 : length; }
+ void setPrefixLength(QAbstractSocket::NetworkLayerProtocol proto, int len)
+ {
+ int maxlen = -1;
+ if (proto == QAbstractSocket::IPv4Protocol)
+ maxlen = 32;
+ else if (proto == QAbstractSocket::IPv6Protocol)
+ maxlen = 128;
+ if (len > maxlen || len < 0)
+ length = 255U;
+ else
+ length = unsigned(len);
+ }
+
+ friend bool operator==(QNetmask n1, QNetmask n2)
+ { return n1.length == n2.length; }
};
QT_END_NAMESPACE
diff --git a/src/network/kernel/qnetworkinterface.cpp b/src/network/kernel/qnetworkinterface.cpp
index c5d1adbef0..2c28ae9ed9 100644
--- a/src/network/kernel/qnetworkinterface.cpp
+++ b/src/network/kernel/qnetworkinterface.cpp
@@ -257,7 +257,7 @@ void QNetworkAddressEntry::setIp(const QHostAddress &newIp)
*/
QHostAddress QNetworkAddressEntry::netmask() const
{
- return d->netmask;
+ return d->netmask.address(d->address.protocol());
}
/*!
@@ -270,7 +270,7 @@ QHostAddress QNetworkAddressEntry::netmask() const
void QNetworkAddressEntry::setNetmask(const QHostAddress &newNetmask)
{
if (newNetmask.protocol() != ip().protocol()) {
- d->netmask = QNetmaskAddress();
+ d->netmask = QNetmask();
return;
}
diff --git a/src/network/kernel/qnetworkinterface_p.h b/src/network/kernel/qnetworkinterface_p.h
index ec25fdf37e..51901eeda8 100644
--- a/src/network/kernel/qnetworkinterface_p.h
+++ b/src/network/kernel/qnetworkinterface_p.h
@@ -68,8 +68,8 @@ class QNetworkAddressEntryPrivate
{
public:
QHostAddress address;
- QNetmaskAddress netmask;
QHostAddress broadcast;
+ QNetmask netmask;
};
class QNetworkInterfacePrivate: public QSharedData
diff --git a/src/network/kernel/qnetworkinterface_win.cpp b/src/network/kernel/qnetworkinterface_win.cpp
index c2efcea625..8344fb04c2 100644
--- a/src/network/kernel/qnetworkinterface_win.cpp
+++ b/src/network/kernel/qnetworkinterface_win.cpp
@@ -103,53 +103,13 @@ QString QNetworkInterfaceManager::interfaceNameFromIndex(uint index)
return QString::number(index);
}
-static QHash<QHostAddress, QHostAddress> ipv4Netmasks()
-{
- //Retrieve all the IPV4 addresses & netmasks
- IP_ADAPTER_INFO staticBuf[2]; // 2 is arbitrary
- PIP_ADAPTER_INFO pAdapter = staticBuf;
- ULONG bufSize = sizeof staticBuf;
- QHash<QHostAddress, QHostAddress> ipv4netmasks;
-
- DWORD retval = GetAdaptersInfo(pAdapter, &bufSize);
- if (retval == ERROR_BUFFER_OVERFLOW) {
- // need more memory
- pAdapter = (IP_ADAPTER_INFO *)malloc(bufSize);
- if (!pAdapter)
- return ipv4netmasks;
- // try again
- if (GetAdaptersInfo(pAdapter, &bufSize) != ERROR_SUCCESS) {
- free(pAdapter);
- return ipv4netmasks;
- }
- } else if (retval != ERROR_SUCCESS) {
- // error
- return ipv4netmasks;
- }
-
- // iterate over the list and add the entries to our listing
- for (PIP_ADAPTER_INFO ptr = pAdapter; ptr; ptr = ptr->Next) {
- for (PIP_ADDR_STRING addr = &ptr->IpAddressList; addr; addr = addr->Next) {
- QHostAddress address(QLatin1String(addr->IpAddress.String));
- QHostAddress mask(QLatin1String(addr->IpMask.String));
- ipv4netmasks[address] = mask;
- }
- }
- if (pAdapter != staticBuf)
- free(pAdapter);
-
- return ipv4netmasks;
-
-}
-
-static QList<QNetworkInterfacePrivate *> interfaceListingWinXP()
+static QList<QNetworkInterfacePrivate *> interfaceListing()
{
QList<QNetworkInterfacePrivate *> interfaces;
IP_ADAPTER_ADDRESSES staticBuf[2]; // 2 is arbitrary
PIP_ADAPTER_ADDRESSES pAdapter = staticBuf;
ULONG bufSize = sizeof staticBuf;
- const QHash<QHostAddress, QHostAddress> &ipv4netmasks = ipv4Netmasks();
ULONG flags = GAA_FLAG_INCLUDE_PREFIX |
GAA_FLAG_SKIP_DNS_SERVER |
GAA_FLAG_SKIP_MULTICAST;
@@ -171,11 +131,17 @@ static QList<QNetworkInterfacePrivate *> interfaceListingWinXP()
// iterate over the list and add the entries to our listing
for (PIP_ADAPTER_ADDRESSES ptr = pAdapter; ptr; ptr = ptr->Next) {
+ // the structure grows over time, so let's make sure the fields
+ // introduced in Windows Vista are present (Luid is the furthest
+ // field we access from IP_ADAPTER_ADDRESSES_LH)
+ Q_ASSERT(ptr->Length >= offsetof(IP_ADAPTER_ADDRESSES, Luid));
+ Q_ASSERT(ptr->Length >= offsetof(IP_ADAPTER_ADDRESSES, Ipv6IfIndex));
+
QNetworkInterfacePrivate *iface = new QNetworkInterfacePrivate;
interfaces << iface;
iface->index = 0;
- if (ptr->Length >= offsetof(IP_ADAPTER_ADDRESSES, Ipv6IfIndex) && ptr->Ipv6IfIndex != 0)
+ if (ptr->Ipv6IfIndex != 0)
iface->index = ptr->Ipv6IfIndex;
else if (ptr->IfIndex != 0)
iface->index = ptr->IfIndex;
@@ -188,13 +154,11 @@ static QList<QNetworkInterfacePrivate *> interfaceListingWinXP()
if (ptr->IfType == IF_TYPE_PPP)
iface->flags |= QNetworkInterface::IsPointToPoint;
- if (ptr->Length >= offsetof(IP_ADAPTER_ADDRESSES, Luid)) {
- // use ConvertInterfaceLuidToNameW because that returns a friendlier name, though not
- // as friendly as FriendlyName below
- WCHAR buf[IF_MAX_STRING_SIZE + 1];
- if (ConvertInterfaceLuidToNameW(&ptr->Luid, buf, sizeof(buf)/sizeof(buf[0])) == NO_ERROR)
- iface->name = QString::fromWCharArray(buf);
- }
+ // use ConvertInterfaceLuidToNameW because that returns a friendlier name, though not
+ // as "friendly" as FriendlyName below
+ WCHAR buf[IF_MAX_STRING_SIZE + 1];
+ if (ConvertInterfaceLuidToNameW(&ptr->Luid, buf, sizeof(buf)/sizeof(buf[0])) == NO_ERROR)
+ iface->name = QString::fromWCharArray(buf);
if (iface->name.isEmpty())
iface->name = QString::fromLocal8Bit(ptr->AdapterName);
@@ -206,28 +170,17 @@ static QList<QNetworkInterfacePrivate *> interfaceListingWinXP()
// loopback if it has no address
iface->flags |= QNetworkInterface::IsLoopBack;
- // The GetAdaptersAddresses call has an interesting semantic:
- // It can return a number N of addresses and a number M of prefixes.
- // But if you have IPv6 addresses, generally N > M.
- // I cannot find a way to relate the Address to the Prefix, aside from stopping
- // the iteration at the last Prefix entry and assume that it applies to all addresses
- // from that point on.
- PIP_ADAPTER_PREFIX pprefix = 0;
- if (ptr->Length >= offsetof(IP_ADAPTER_ADDRESSES, FirstPrefix))
- pprefix = ptr->FirstPrefix;
+ // parse the IP (unicast) addresses
for (PIP_ADAPTER_UNICAST_ADDRESS addr = ptr->FirstUnicastAddress; addr; addr = addr->Next) {
+ Q_ASSERT(addr->Length >= offsetof(IP_ADAPTER_UNICAST_ADDRESS, OnLinkPrefixLength));
+
+ // skip addresses in invalid state
+ if (addr->DadState == IpDadStateInvalid)
+ continue;
+
QNetworkAddressEntry entry;
entry.setIp(addressFromSockaddr(addr->Address.lpSockaddr));
- if (pprefix) {
- if (entry.ip().protocol() == QAbstractSocket::IPv4Protocol) {
- entry.setNetmask(ipv4netmasks[entry.ip()]);
-
- // broadcast address is set on postProcess()
- } else { //IPV6
- entry.setPrefixLength(pprefix->PrefixLength);
- }
- pprefix = pprefix->Next ? pprefix->Next : pprefix;
- }
+ entry.setPrefixLength(addr->OnLinkPrefixLength);
iface->addressEntries << entry;
}
}
@@ -240,7 +193,7 @@ static QList<QNetworkInterfacePrivate *> interfaceListingWinXP()
QList<QNetworkInterfacePrivate *> QNetworkInterfaceManager::scan()
{
- return interfaceListingWinXP();
+ return interfaceListing();
}
QString QHostInfo::localDomainName()
diff --git a/src/network/kernel/qnetworkproxy.cpp b/src/network/kernel/qnetworkproxy.cpp
index 37f3f84653..6b53b4b58e 100644
--- a/src/network/kernel/qnetworkproxy.cpp
+++ b/src/network/kernel/qnetworkproxy.cpp
@@ -227,7 +227,9 @@
#ifndef QT_NO_NETWORKPROXY
#include "private/qnetworkrequest_p.h"
+#if QT_CONFIG(socks5)
#include "private/qsocks5socketengine_p.h"
+#endif
#include "private/qhttpsocketengine_p.h"
#include "qauthenticator.h"
#include "qdebug.h"
@@ -251,7 +253,7 @@ public:
: mutex(QMutex::Recursive)
, applicationLevelProxy(0)
, applicationLevelProxyFactory(0)
-#ifndef QT_NO_SOCKS5
+#if QT_CONFIG(socks5)
, socks5SocketEngineHandler(0)
#endif
#ifndef QT_NO_HTTP
@@ -263,7 +265,7 @@ public:
, useSystemProxies(false)
#endif
{
-#ifndef QT_NO_SOCKS5
+#if QT_CONFIG(socks5)
socks5SocketEngineHandler = new QSocks5SocketEngineHandler();
#endif
#ifndef QT_NO_HTTP
@@ -275,7 +277,7 @@ public:
{
delete applicationLevelProxy;
delete applicationLevelProxyFactory;
-#ifndef QT_NO_SOCKS5
+#if QT_CONFIG(socks5)
delete socks5SocketEngineHandler;
#endif
#ifndef QT_NO_HTTP
@@ -335,7 +337,7 @@ private:
QMutex mutex;
QNetworkProxy *applicationLevelProxy;
QNetworkProxyFactory *applicationLevelProxyFactory;
-#ifndef QT_NO_SOCKS5
+#if QT_CONFIG(socks5)
QSocks5SocketEngineHandler *socks5SocketEngineHandler;
#endif
#ifndef QT_NO_HTTP
diff --git a/src/network/kernel/qurlinfo.cpp b/src/network/kernel/qurlinfo.cpp
index 300a51d3e7..7ae6822fb4 100644
--- a/src/network/kernel/qurlinfo.cpp
+++ b/src/network/kernel/qurlinfo.cpp
@@ -39,8 +39,6 @@
#include "qurlinfo_p.h"
-#ifndef QT_NO_FTP
-
#include "qurl.h"
#include "qdir.h"
#include <limits.h>
@@ -727,5 +725,3 @@ bool QUrlInfo::isValid() const
}
QT_END_NAMESPACE
-
-#endif // QT_NO_FTP
diff --git a/src/network/kernel/qurlinfo_p.h b/src/network/kernel/qurlinfo_p.h
index 3a430a3321..8180796f49 100644
--- a/src/network/kernel/qurlinfo_p.h
+++ b/src/network/kernel/qurlinfo_p.h
@@ -56,10 +56,9 @@
#include <QtCore/qstring.h>
#include <QtCore/qiodevice.h>
-QT_BEGIN_NAMESPACE
-
+QT_REQUIRE_CONFIG(ftp);
-#ifndef QT_NO_FTP
+QT_BEGIN_NAMESPACE
class QUrl;
class QUrlInfoPrivate;
@@ -129,8 +128,6 @@ private:
QUrlInfoPrivate *d;
};
-#endif // QT_NO_FTP
-
QT_END_NAMESPACE
#endif // QURLINFO_H
diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp
index 3f7c0d94e1..03395a37f0 100644
--- a/src/network/socket/qnativesocketengine.cpp
+++ b/src/network/socket/qnativesocketengine.cpp
@@ -1162,6 +1162,7 @@ bool QNativeSocketEngine::waitForReadOrWrite(bool *readyToRead, bool *readyToWri
return ret > 0;
}
+#if 0 // currently unused
/*!
Returns the size of the operating system's socket receive
buffer. Depending on the operating system, this size may be
@@ -1220,7 +1221,7 @@ void QNativeSocketEngine::setSendBufferSize(qint64 size)
Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::setSendBufferSize(), Q_VOID);
setOption(SendBufferSocketOption, size);
}
-
+#endif
/*!
Sets the option \a option to the value \a value.
diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h
index bfea824bcb..aa61b74823 100644
--- a/src/network/socket/qnativesocketengine_p.h
+++ b/src/network/socket/qnativesocketengine_p.h
@@ -166,11 +166,13 @@ public:
qint64 writeDatagram(const char *data, qint64 len, const QIpPacketHeader &) override;
qint64 bytesToWrite() const override;
+#if 0 // currently unused
qint64 receiveBufferSize() const;
void setReceiveBufferSize(qint64 bufferSize);
qint64 sendBufferSize() const;
void setSendBufferSize(qint64 bufferSize);
+#endif
int option(SocketOption option) const override;
bool setOption(SocketOption option, int value) override;
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index a8f756dc31..cb0a521360 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -829,18 +829,10 @@ qint64 QNativeSocketEnginePrivate::nativeBytesAvailable() const
bool QNativeSocketEnginePrivate::nativeHasPendingDatagrams() const
{
- // Create a sockaddr struct and reset its port number.
- qt_sockaddr storage;
- QT_SOCKLEN_T storageSize = sizeof(storage);
- memset(&storage, 0, storageSize);
-
- // Peek 1 bytes into the next message. The size of the message may
- // well be 0, so we can't check recvfrom's return value.
+ // Peek 1 bytes into the next message.
ssize_t readBytes;
- do {
- char c;
- readBytes = ::recvfrom(socketDescriptor, &c, 1, MSG_PEEK, &storage.a, &storageSize);
- } while (readBytes == -1 && errno == EINTR);
+ char c;
+ EINTR_LOOP(readBytes, ::recv(socketDescriptor, &c, 1, MSG_PEEK));
// If there's no error, or if our buffer was too small, there must be a
// pending datagram.
@@ -868,22 +860,42 @@ qint64 QNativeSocketEnginePrivate::nativePendingDatagramSize() const
if (recvResult != -1)
recvResult = value;
#else
- QVarLengthArray<char, 8192> udpMessagePeekBuffer(8192);
+ // We need to grow the buffer to fit the entire datagram.
+ // We start at 1500 bytes (the MTU for Ethernet V2), which should catch
+ // almost all uses (effective MTU for UDP under IPv4 is 1468), except
+ // for localhost datagrams and those reassembled by the IP layer.
+ char udpMessagePeekBuffer[1500];
+ struct msghdr msg;
+ struct iovec vec;
+
+ memset(&msg, 0, sizeof(msg));
+ msg.msg_iov = &vec;
+ msg.msg_iovlen = 1;
+ vec.iov_base = udpMessagePeekBuffer;
+ vec.iov_len = sizeof(udpMessagePeekBuffer);
for (;;) {
// the data written to udpMessagePeekBuffer is discarded, so
// this function is still reentrant although it might not look
// so.
- recvResult = ::recv(socketDescriptor, udpMessagePeekBuffer.data(),
- udpMessagePeekBuffer.size(), MSG_PEEK);
+ recvResult = ::recvmsg(socketDescriptor, &msg, MSG_PEEK);
if (recvResult == -1 && errno == EINTR)
continue;
- if (recvResult != (ssize_t) udpMessagePeekBuffer.size())
+ // was the result truncated?
+ if ((msg.msg_flags & MSG_TRUNC) == 0)
break;
- udpMessagePeekBuffer.resize(udpMessagePeekBuffer.size() * 2);
+ // grow by 16 times
+ msg.msg_iovlen *= 16;
+ if (msg.msg_iov != &vec)
+ delete[] msg.msg_iov;
+ msg.msg_iov = new struct iovec[msg.msg_iovlen];
+ std::fill_n(msg.msg_iov, msg.msg_iovlen, vec);
}
+
+ if (msg.msg_iov != &vec)
+ delete[] msg.msg_iov;
#endif
#if defined (QNATIVESOCKETENGINE_DEBUG)
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp
index e21bf29d4b..7556bb98f4 100644
--- a/src/network/socket/qnativesocketengine_win.cpp
+++ b/src/network/socket/qnativesocketengine_win.cpp
@@ -1146,10 +1146,10 @@ qint64 QNativeSocketEnginePrivate::nativePendingDatagramSize() const
DWORD bufferCount = 5;
WSABUF * buf = 0;
for (;;) {
- // the data written to udpMessagePeekBuffer is discarded, so
- // this function is still reentrant although it might not look
- // so.
- static char udpMessagePeekBuffer[8192];
+ // We start at 1500 bytes (the MTU for Ethernet V2), which should catch
+ // almost all uses (effective MTU for UDP under IPv4 is 1468), except
+ // for localhost datagrams and those reassembled by the IP layer.
+ char udpMessagePeekBuffer[1500];
buf = new WSABUF[bufferCount];
for (DWORD i=0; i<bufferCount; i++) {
diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp
index 64bbdedcfd..a07ea65046 100644
--- a/src/network/socket/qsocks5socketengine.cpp
+++ b/src/network/socket/qsocks5socketengine.cpp
@@ -39,8 +39,6 @@
#include "qsocks5socketengine_p.h"
-#ifndef QT_NO_SOCKS5
-
#include "qtcpsocket.h"
#include "qudpsocket.h"
#include "qtcpserver.h"
@@ -1938,6 +1936,4 @@ QAbstractSocketEngine *QSocks5SocketEngineHandler::createSocketEngine(qintptr so
return 0;
}
-#endif // QT_NO_SOCKS5
-
QT_END_NAMESPACE
diff --git a/src/network/socket/qsocks5socketengine_p.h b/src/network/socket/qsocks5socketengine_p.h
index 38139b065f..1942eff4ca 100644
--- a/src/network/socket/qsocks5socketengine_p.h
+++ b/src/network/socket/qsocks5socketengine_p.h
@@ -55,9 +55,9 @@
#include "qabstractsocketengine_p.h"
#include "qnetworkproxy.h"
-QT_BEGIN_NAMESPACE
+QT_REQUIRE_CONFIG(socks5);
-#ifndef QT_NO_SOCKS5
+QT_BEGIN_NAMESPACE
class QSocks5SocketEnginePrivate;
@@ -291,7 +291,6 @@ public:
virtual QAbstractSocketEngine *createSocketEngine(qintptr socketDescriptor, QObject *parent) override;
};
-
QT_END_NAMESPACE
-#endif // QT_NO_SOCKS5
+
#endif // QSOCKS5SOCKETENGINE_H
diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp
index 9b62240767..5c9ebac283 100644
--- a/src/network/ssl/qsslsocket.cpp
+++ b/src/network/ssl/qsslsocket.cpp
@@ -2293,6 +2293,9 @@ void QSslSocketPrivate::createPlainSocket(QIODevice::OpenMode openMode)
q->connect(plainSocket, SIGNAL(channelBytesWritten(int, qint64)),
q, SLOT(_q_channelBytesWrittenSlot(int, qint64)),
Qt::DirectConnection);
+ q->connect(plainSocket, SIGNAL(readChannelFinished()),
+ q, SLOT(_q_readChannelFinishedSlot()),
+ Qt::DirectConnection);
#ifndef QT_NO_NETWORKPROXY
q->connect(plainSocket, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
q, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
@@ -2514,6 +2517,15 @@ void QSslSocketPrivate::_q_channelBytesWrittenSlot(int channel, qint64 written)
/*!
\internal
*/
+void QSslSocketPrivate::_q_readChannelFinishedSlot()
+{
+ Q_Q(QSslSocket);
+ emit q->readChannelFinished();
+}
+
+/*!
+ \internal
+*/
void QSslSocketPrivate::_q_flushWriteBuffer()
{
Q_Q(QSslSocket);
diff --git a/src/network/ssl/qsslsocket.h b/src/network/ssl/qsslsocket.h
index d76361029c..c66ebdde54 100644
--- a/src/network/ssl/qsslsocket.h
+++ b/src/network/ssl/qsslsocket.h
@@ -224,6 +224,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_channelReadyReadSlot(int))
Q_PRIVATE_SLOT(d_func(), void _q_bytesWrittenSlot(qint64))
Q_PRIVATE_SLOT(d_func(), void _q_channelBytesWrittenSlot(int, qint64))
+ Q_PRIVATE_SLOT(d_func(), void _q_readChannelFinishedSlot())
Q_PRIVATE_SLOT(d_func(), void _q_flushWriteBuffer())
Q_PRIVATE_SLOT(d_func(), void _q_flushReadBuffer())
Q_PRIVATE_SLOT(d_func(), void _q_resumeImplementation())
diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp
index 23a63ed063..2d771b5637 100644
--- a/src/network/ssl/qsslsocket_openssl.cpp
+++ b/src/network/ssl/qsslsocket_openssl.cpp
@@ -54,7 +54,6 @@
****************************************************************************/
//#define QSSLSOCKET_DEBUG
-//#define QT_DECRYPT_SSL_TRAFFIC
#include "qssl_p.h"
#include "qsslsocket_openssl_p.h"
@@ -213,6 +212,7 @@ int q_X509Callback(int ok, X509_STORE_CTX *ctx)
if (!ok) {
// Store the error and at which depth the error was detected.
_q_sslErrorList()->errors << QSslErrorEntry::fromStoreContext(ctx);
+#if !QT_CONFIG(opensslv11)
#ifdef QSSLSOCKET_DEBUG
qCDebug(lcSsl) << "verification error: dumping bad certificate";
qCDebug(lcSsl) << QSslCertificatePrivate::QSslCertificate_from_X509(q_X509_STORE_CTX_get_current_cert(ctx)).toPem();
@@ -233,7 +233,8 @@ int q_X509Callback(int ok, X509_STORE_CTX *ctx)
<< "ST=" << cert.subjectInfo(QSslCertificate::StateOrProvinceName);
qCDebug(lcSsl) << "Valid:" << cert.effectiveDate() << '-' << cert.expiryDate();
}
-#endif
+#endif // QSSLSOCKET_DEBUG
+#endif // !QT_CONFIG(opensslv11)
}
// Always return OK to allow verification to continue. We handle the
// errors gracefully after collecting all errors, after verification has
diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp
index 0ef8bf6b5e..3a236a1300 100644
--- a/src/network/ssl/qsslsocket_openssl_symbols.cpp
+++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp
@@ -699,6 +699,23 @@ static QPair<QSystemLibrary*, QSystemLibrary*> loadOpenSslWin32()
pair.first = 0;
pair.second = 0;
+#if QT_CONFIG(opensslv11)
+ // With OpenSSL 1.1 the names have changed to libssl-1_1(-x64) and libcrypto-1_1(-x64), for builds using
+ // MSVC and GCC, (-x64 suffix for 64-bit builds).
+
+#ifdef Q_PROCESSOR_X86_64
+#define QT_SSL_SUFFIX "-x64"
+#else // !Q_PROCESSOFR_X86_64
+#define QT_SSL_SUFFIX
+#endif // !Q_PROCESSOR_x86_64
+
+ tryToLoadOpenSslWin32Library(QLatin1String("libssl-1_1" QT_SSL_SUFFIX),
+ QLatin1String("libcrypto-1_1" QT_SSL_SUFFIX), pair);
+
+#undef QT_SSL_SUFFIX
+
+#else // QT_CONFIG(opensslv11)
+
// When OpenSSL is built using MSVC then the libraries are named 'ssleay32.dll' and 'libeay32'dll'.
// When OpenSSL is built using GCC then different library names are used (depending on the OpenSSL version)
// The oldest version of a GCC-based OpenSSL which can be detected by the code below is 0.9.8g (released in 2007)
@@ -709,6 +726,7 @@ static QPair<QSystemLibrary*, QSystemLibrary*> loadOpenSslWin32()
}
}
}
+#endif // !QT_CONFIG(opensslv11)
return pair;
}
diff --git a/src/network/ssl/qsslsocket_p.h b/src/network/ssl/qsslsocket_p.h
index a545c618ce..9d45d01695 100644
--- a/src/network/ssl/qsslsocket_p.h
+++ b/src/network/ssl/qsslsocket_p.h
@@ -180,6 +180,7 @@ public:
void _q_channelReadyReadSlot(int);
void _q_bytesWrittenSlot(qint64);
void _q_channelBytesWrittenSlot(int, qint64);
+ void _q_readChannelFinishedSlot();
void _q_flushWriteBuffer();
void _q_flushReadBuffer();
void _q_resumeImplementation();
diff --git a/src/platformsupport/cglconvenience/cglconvenience.mm b/src/platformsupport/cglconvenience/cglconvenience.mm
deleted file mode 100644
index 44238f2273..0000000000
--- a/src/platformsupport/cglconvenience/cglconvenience.mm
+++ /dev/null
@@ -1,135 +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$
-**
-****************************************************************************/
-
-#include "cglconvenience_p.h"
-#include <QtCore/qglobal.h>
-#include <QtCore/private/qcore_mac_p.h>
-#include <AppKit/AppKit.h>
-#include <QVector>
-#include <qdebug.h>
-
-// Match up with createNSOpenGLPixelFormat below!
-QSurfaceFormat qcgl_surfaceFormat()
-{
- QSurfaceFormat format;
- format.setRenderableType(QSurfaceFormat::OpenGL);
- format.setRedBufferSize(8);
- format.setGreenBufferSize(8);
- format.setBlueBufferSize(8);
- format.setAlphaBufferSize(8);
-/*
- format.setDepthBufferSize(24);
- format.setAccumBufferSize(0);
- format.setStencilBufferSize(8);
- format.setSampleBuffers(false);
- format.setSamples(1);
- format.setDepth(true);
- format.setRgba(true);
- format.setAlpha(true);
- format.setAccum(false);
- format.setStencil(true);
- format.setStereo(false);
- format.setDirectRendering(false);
-*/
- return format;
-}
-
-void *qcgl_createNSOpenGLPixelFormat(const QSurfaceFormat &format)
-{
-
- QVector<NSOpenGLPixelFormatAttribute> attrs;
-
- if (format.swapBehavior() == QSurfaceFormat::DoubleBuffer
- || format.swapBehavior() == QSurfaceFormat::DefaultSwapBehavior)
- attrs.append(NSOpenGLPFADoubleBuffer);
- else if (format.swapBehavior() == QSurfaceFormat::TripleBuffer)
- attrs.append(NSOpenGLPFATripleBuffer);
-
-
- // Select OpenGL profile
- attrs << NSOpenGLPFAOpenGLProfile;
- if (format.profile() == QSurfaceFormat::CoreProfile) {
- if (format.version() >= qMakePair(4, 1))
- attrs << NSOpenGLProfileVersion4_1Core;
- else if (format.version() >= qMakePair(3, 2))
- attrs << NSOpenGLProfileVersion3_2Core;
- else
- attrs << NSOpenGLProfileVersionLegacy;
- } else {
- attrs << NSOpenGLProfileVersionLegacy;
- }
-
- if (format.depthBufferSize() > 0)
- attrs << NSOpenGLPFADepthSize << format.depthBufferSize();
- if (format.stencilBufferSize() > 0)
- attrs << NSOpenGLPFAStencilSize << format.stencilBufferSize();
- if (format.alphaBufferSize() > 0)
- attrs << NSOpenGLPFAAlphaSize << format.alphaBufferSize();
- if ((format.redBufferSize() > 0) &&
- (format.greenBufferSize() > 0) &&
- (format.blueBufferSize() > 0)) {
- const int colorSize = format.redBufferSize() +
- format.greenBufferSize() +
- format.blueBufferSize();
- attrs << NSOpenGLPFAColorSize << colorSize << NSOpenGLPFAMinimumPolicy;
- }
-
- if (format.samples() > 0) {
- attrs << NSOpenGLPFAMultisample
- << NSOpenGLPFASampleBuffers << (NSOpenGLPixelFormatAttribute) 1
- << NSOpenGLPFASamples << (NSOpenGLPixelFormatAttribute) format.samples();
- }
-
- if (format.stereo())
- attrs << NSOpenGLPFAStereo;
-
- attrs << NSOpenGLPFAAllowOfflineRenderers;
-
- QByteArray useLayer = qgetenv("QT_MAC_WANTS_LAYER");
- if (!useLayer.isEmpty() && useLayer.toInt() > 0) {
- // Disable the software rendering fallback. This makes compositing
- // OpenGL and raster NSViews using Core Animation layers possible.
- attrs << NSOpenGLPFANoRecovery;
- }
-
- attrs << 0;
-
- NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs.constData()];
- return pixelFormat;
-}
diff --git a/src/platformsupport/cglconvenience/cglconvenience.pro b/src/platformsupport/cglconvenience/cglconvenience.pro
deleted file mode 100644
index 89d1fc4643..0000000000
--- a/src/platformsupport/cglconvenience/cglconvenience.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-TARGET = QtCglSupport
-MODULE = cgl_support
-
-QT = core-private gui
-CONFIG += static internal_module
-
-DEFINES += QT_NO_CAST_FROM_ASCII
-
-HEADERS += \
- cglconvenience_p.h
-
-OBJECTIVE_SOURCES += \
- cglconvenience.mm
-
-LIBS_PRIVATE += -framework AppKit -framework OpenGL
-
-load(qt_module)
diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp
index 1f976be066..5198ffb9f8 100644
--- a/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp
+++ b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp
@@ -1621,6 +1621,7 @@ void QWindowsFontDatabase::refUniqueFont(const QString &uniqueFont)
m_uniqueFontData[uniqueFont].refCount.ref();
}
+// ### fixme Qt 6 (QTBUG-58610): See comment at QWindowsFontDatabase::systemDefaultFont()
HFONT QWindowsFontDatabase::systemFont()
{
static const HFONT stock_sysfont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
@@ -1961,12 +1962,31 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request, const Q
QFont QWindowsFontDatabase::systemDefaultFont()
{
+#if QT_VERSION >= 0x060000
+ // Qt 6: Obtain default GUI font (typically "Segoe UI, 9pt", see QTBUG-58610)
+ NONCLIENTMETRICS ncm;
+ ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICS, lfMessageFont) + sizeof(LOGFONT);
+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, ncm.cbSize , &ncm, 0);
+ const QFont systemFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfMessageFont);
+#else
LOGFONT lf;
GetObject(QWindowsFontDatabase::systemFont(), sizeof(lf), &lf);
QFont systemFont = QWindowsFontDatabase::LOGFONT_to_QFont(lf);
// "MS Shell Dlg 2" is the correct system font >= Win2k
if (systemFont.family() == QLatin1String("MS Shell Dlg"))
systemFont.setFamily(QStringLiteral("MS Shell Dlg 2"));
+ // Qt 5 by (Qt 4) legacy uses GetStockObject(DEFAULT_GUI_FONT) to
+ // obtain the default GUI font (typically "MS Shell Dlg 2, 8pt"). This has been
+ // long deprecated; the message font of the NONCLIENTMETRICS structure obtained by
+ // SystemParametersInfo(SPI_GETNONCLIENTMETRICS) should be used instead (see
+ // QWindowsTheme::refreshFonts(), typically "Segoe UI, 9pt"), which is larger.
+ // In single monitor setups, the point sizes revolve around 8 (depending on UI
+ // scale factor, but not proportional to it). However, in multi monitor setups,
+ // where the DPI of the primary monitor are smaller than those of the secondary,
+ // large bogus values are returned. Limit to 8.25 in that case.
+ if (GetSystemMetrics(SM_CMONITORS) > 1 && systemFont.pointSizeF() > 8.25)
+ systemFont.setPointSizeF(8.25);
+#endif // Qt 5
qCDebug(lcQpaFonts) << __FUNCTION__ << systemFont;
return systemFont;
}
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
index d6c7173d3c..2d6426db7f 100644
--- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
+++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
@@ -87,7 +87,7 @@ QEvdevKeyboardHandler::QEvdevKeyboardHandler(const QString &device, QFdContainer
// socket notifier for events on the keyboard device
m_notify = new QSocketNotifier(m_fd.get(), QSocketNotifier::Read, this);
- connect(m_notify, SIGNAL(activated(int)), this, SLOT(readKeycode()));
+ connect(m_notify, &QSocketNotifier::activated, this, &QEvdevKeyboardHandler::readKeycode);
}
QEvdevKeyboardHandler::~QEvdevKeyboardHandler()
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h
index 1ec4915855..7c64c4febb 100644
--- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h
+++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler_p.h
@@ -145,7 +145,6 @@ public:
class QEvdevKeyboardHandler : public QObject
{
- Q_OBJECT
public:
QEvdevKeyboardHandler(const QString &device, QFdContainer &fd, bool disableZap, bool enableCompose, const QString &keymapFile);
~QEvdevKeyboardHandler();
@@ -190,7 +189,6 @@ public:
bool loadKeymap(const QString &file);
void unloadKeymap();
-private slots:
void readKeycode();
KeycodeAction processKeycode(quint16 keycode, bool pressed, bool autorepeat);
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp
index 94ebae8f42..85e6a80879 100644
--- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp
+++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager.cpp
@@ -88,8 +88,10 @@ QEvdevKeyboardManager::QEvdevKeyboardManager(const QString &key, const QString &
for (const QString &device : devices)
addKeyboard(device);
- connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addKeyboard(QString)));
- connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeKeyboard(QString)));
+ connect(m_deviceDiscovery, &QDeviceDiscovery::deviceDetected,
+ this, &QEvdevKeyboardManager::addKeyboard);
+ connect(m_deviceDiscovery, &QDeviceDiscovery::deviceRemoved,
+ this, &QEvdevKeyboardManager::removeKeyboard);
}
}
}
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h
index d2e34fead3..27ea7e468e 100644
--- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h
+++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardmanager_p.h
@@ -63,14 +63,12 @@ QT_BEGIN_NAMESPACE
class QEvdevKeyboardManager : public QObject
{
- Q_OBJECT
public:
QEvdevKeyboardManager(const QString &key, const QString &specification, QObject *parent = 0);
~QEvdevKeyboardManager();
void loadKeymap(const QString &file);
-private slots:
void addKeyboard(const QString &deviceNode = QString());
void removeKeyboard(const QString &deviceNode);
diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp
index bcc5a21669..cd7eec3861 100644
--- a/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp
+++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler.cpp
@@ -116,7 +116,8 @@ QEvdevMouseHandler::QEvdevMouseHandler(const QString &device, int fd, bool abs,
// socket notifier for events on the mouse device
m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
- connect(m_notify, SIGNAL(activated(int)), this, SLOT(readMouseData()));
+ connect(m_notify, &QSocketNotifier::activated,
+ this, &QEvdevMouseHandler::readMouseData);
}
QEvdevMouseHandler::~QEvdevMouseHandler()
diff --git a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h
index 79156645da..6cad4b9173 100644
--- a/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h
+++ b/src/platformsupport/input/evdevmouse/qevdevmousehandler_p.h
@@ -66,13 +66,12 @@ public:
static QEvdevMouseHandler *create(const QString &device, const QString &specification);
~QEvdevMouseHandler();
+ void readMouseData();
+
signals:
void handleMouseEvent(int x, int y, bool abs, Qt::MouseButtons buttons);
void handleWheelEvent(QPoint delta);
-private slots:
- void readMouseData();
-
private:
QEvdevMouseHandler(const QString &device, int fd, bool abs, bool compression, int jitterLimit);
diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp
index 6264e4ada2..ba94bcd460 100644
--- a/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp
+++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager.cpp
@@ -94,13 +94,19 @@ QEvdevMouseManager::QEvdevMouseManager(const QString &key, const QString &specif
for (const QString &device : devices)
addMouse(device);
- connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addMouse(QString)));
- connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeMouse(QString)));
+ connect(m_deviceDiscovery, &QDeviceDiscovery::deviceDetected,
+ this, &QEvdevMouseManager::addMouse);
+ connect(m_deviceDiscovery, &QDeviceDiscovery::deviceRemoved,
+ this, &QEvdevMouseManager::removeMouse);
}
}
- connect(QGuiApplicationPrivate::inputDeviceManager(), SIGNAL(cursorPositionChangeRequested(QPoint)),
- this, SLOT(handleCursorPositionChange(QPoint)));
+ QInputDeviceManager *manager = QGuiApplicationPrivate::inputDeviceManager();
+ connect(manager, &QInputDeviceManager::cursorPositionChangeRequested, [=](const QPoint &pos) {
+ m_x = pos.x();
+ m_y = pos.y();
+ clampPosition();
+ });
}
QEvdevMouseManager::~QEvdevMouseManager()
@@ -153,11 +159,12 @@ void QEvdevMouseManager::handleWheelEvent(QPoint delta)
void QEvdevMouseManager::addMouse(const QString &deviceNode)
{
qCDebug(qLcEvdevMouse) << "Adding mouse at" << deviceNode;
- QEvdevMouseHandler *handler;
- handler = QEvdevMouseHandler::create(deviceNode, m_spec);
+ QEvdevMouseHandler *handler = QEvdevMouseHandler::create(deviceNode, m_spec);
if (handler) {
- connect(handler, SIGNAL(handleMouseEvent(int,int,bool,Qt::MouseButtons)), this, SLOT(handleMouseEvent(int,int,bool,Qt::MouseButtons)));
- connect(handler, SIGNAL(handleWheelEvent(QPoint)), this, SLOT(handleWheelEvent(QPoint)));
+ connect(handler, &QEvdevMouseHandler::handleMouseEvent,
+ this, &QEvdevMouseManager::handleMouseEvent);
+ connect(handler, &QEvdevMouseHandler::handleWheelEvent,
+ this, &QEvdevMouseManager::handleWheelEvent);
m_mice.insert(deviceNode, handler);
QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
QInputDeviceManager::DeviceTypePointer, m_mice.count());
@@ -178,11 +185,4 @@ void QEvdevMouseManager::removeMouse(const QString &deviceNode)
}
}
-void QEvdevMouseManager::handleCursorPositionChange(const QPoint &pos)
-{
- m_x = pos.x();
- m_y = pos.y();
- clampPosition();
-}
-
QT_END_NAMESPACE
diff --git a/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h b/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h
index 7cabfac0d8..10703655b3 100644
--- a/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h
+++ b/src/platformsupport/input/evdevmouse/qevdevmousemanager_p.h
@@ -64,19 +64,15 @@ class QDeviceDiscovery;
class QEvdevMouseManager : public QObject
{
- Q_OBJECT
public:
QEvdevMouseManager(const QString &key, const QString &specification, QObject *parent = 0);
~QEvdevMouseManager();
-public slots:
void handleMouseEvent(int x, int y, bool abs, Qt::MouseButtons buttons);
void handleWheelEvent(QPoint delta);
-private slots:
void addMouse(const QString &deviceNode = QString());
void removeMouse(const QString &deviceNode);
- void handleCursorPositionChange(const QPoint &pos);
private:
void clampPosition();
diff --git a/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp b/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp
index cfc17a79c3..dbab2f6a24 100644
--- a/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp
+++ b/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp
@@ -149,9 +149,11 @@ void QEvdevTabletData::report()
qreal pressure = pressureRange ? (state.p - minValues.p) / qreal(pressureRange) : qreal(1);
if (state.down || state.lastReportDown) {
- QWindowSystemInterface::handleTabletEvent(0, state.down, QPointF(), globalPos,
+ QWindowSystemInterface::handleTabletEvent(0, QPointF(), globalPos,
QTabletEvent::Stylus, pointer,
- pressure, 0, 0, 0, 0, 0, q->deviceId(), qGuiApp->keyboardModifiers());
+ state.down ? Qt::LeftButton : Qt::NoButton,
+ pressure, 0, 0, 0, 0, 0, q->deviceId(),
+ qGuiApp->keyboardModifiers());
}
if (state.lastReportTool && !state.tool)
diff --git a/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h b/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h
index cd760ba40a..66e821117a 100644
--- a/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h
+++ b/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h
@@ -63,15 +63,12 @@ class QEvdevTabletData;
class QEvdevTabletHandler : public QObject
{
- Q_OBJECT
-
public:
explicit QEvdevTabletHandler(const QString &device, const QString &spec = QString(), QObject *parent = 0);
~QEvdevTabletHandler();
qint64 deviceId() const;
-private slots:
void readData();
private:
diff --git a/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp b/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp
index 4b00424e92..90949408ac 100644
--- a/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp
+++ b/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp
@@ -88,8 +88,11 @@ QEvdevTabletManager::QEvdevTabletManager(const QString &key, const QString &spec
const QStringList devices = m_deviceDiscovery->scanConnectedDevices();
for (const QString &device : devices)
addDevice(device);
- connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addDevice(QString)));
- connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeDevice(QString)));
+
+ connect(m_deviceDiscovery, &QDeviceDiscovery::deviceDetected,
+ this, &QEvdevTabletManager::addDevice);
+ connect(m_deviceDiscovery, &QDeviceDiscovery::deviceRemoved,
+ this, &QEvdevTabletManager::removeDevice);
}
}
}
diff --git a/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h b/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h
index d166c06cf3..cde91c55aa 100644
--- a/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h
+++ b/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h
@@ -62,12 +62,10 @@ class QEvdevTabletHandlerThread;
class QEvdevTabletManager : public QObject
{
- Q_OBJECT
public:
QEvdevTabletManager(const QString &key, const QString &spec, QObject *parent = 0);
~QEvdevTabletManager();
-private slots:
void addDevice(const QString &deviceNode);
void removeDevice(const QString &deviceNode);
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
index 15e00cea82..c889965805 100644
--- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
+++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
@@ -229,7 +229,7 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const
if (m_fd >= 0) {
m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
- connect(m_notify, SIGNAL(activated(int)), this, SLOT(readData()));
+ connect(m_notify, &QSocketNotifier::activated, this, &QEvdevTouchScreenHandler::readData);
} else {
qErrnoWarning(errno, "evdevtouch: Cannot open input device %s", qPrintable(device));
return;
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h b/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h
index 04e22e1b5e..56308d0352 100644
--- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h
+++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler_p.h
@@ -82,7 +82,6 @@ public:
bool isFiltered() const;
-private slots:
void readData();
signals:
@@ -116,7 +115,6 @@ public:
bool eventFilter(QObject *object, QEvent *event) override;
-public slots:
void scheduleTouchPointUpdate();
signals:
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp
index ab71d08fb1..4cacbf03e5 100644
--- a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp
+++ b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp
@@ -88,8 +88,11 @@ QEvdevTouchManager::QEvdevTouchManager(const QString &key, const QString &specif
const QStringList devices = m_deviceDiscovery->scanConnectedDevices();
for (const QString &device : devices)
addDevice(device);
- connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addDevice(QString)));
- connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeDevice(QString)));
+
+ connect(m_deviceDiscovery, &QDeviceDiscovery::deviceDetected,
+ this, &QEvdevTouchManager::addDevice);
+ connect(m_deviceDiscovery, &QDeviceDiscovery::deviceRemoved,
+ this, &QEvdevTouchManager::removeDevice);
}
}
}
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h b/src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h
index 84e857ca57..e524c516f1 100644
--- a/src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h
+++ b/src/platformsupport/input/evdevtouch/qevdevtouchmanager_p.h
@@ -62,12 +62,10 @@ class QEvdevTouchScreenHandlerThread;
class QEvdevTouchManager : public QObject
{
- Q_OBJECT
public:
QEvdevTouchManager(const QString &key, const QString &spec, QObject *parent = 0);
~QEvdevTouchManager();
-private slots:
void addDevice(const QString &deviceNode);
void removeDevice(const QString &deviceNode);
diff --git a/src/platformsupport/input/libinput/qlibinputhandler.cpp b/src/platformsupport/input/libinput/qlibinputhandler.cpp
index 4775eb0724..52eaa18f4b 100644
--- a/src/platformsupport/input/libinput/qlibinputhandler.cpp
+++ b/src/platformsupport/input/libinput/qlibinputhandler.cpp
@@ -107,14 +107,17 @@ QLibInputHandler::QLibInputHandler(const QString &key, const QString &spec)
m_liFd = libinput_get_fd(m_li);
m_notifier.reset(new QSocketNotifier(m_liFd, QSocketNotifier::Read));
- connect(m_notifier.data(), SIGNAL(activated(int)), SLOT(onReadyRead()));
+
+ connect(m_notifier.data(), &QSocketNotifier::activated, this, &QLibInputHandler::onReadyRead);
m_pointer.reset(new QLibInputPointer);
m_keyboard.reset(new QLibInputKeyboard);
m_touch.reset(new QLibInputTouch);
- connect(QGuiApplicationPrivate::inputDeviceManager(), SIGNAL(cursorPositionChangeRequested(QPoint)),
- this, SLOT(onCursorPositionChangeRequested(QPoint)));
+ QInputDeviceManager *manager = QGuiApplicationPrivate::inputDeviceManager();
+ connect(manager, &QInputDeviceManager::cursorPositionChangeRequested, [=](const QPoint &pos) {
+ m_pointer->setPos(pos);
+ });
// Process the initial burst of DEVICE_ADDED events.
onReadyRead();
@@ -154,10 +157,6 @@ void QLibInputHandler::processEvent(libinput_event *ev)
// This is not just for hotplugging, it is also called for each input
// device libinput reads from on startup. Hence it is suitable for doing
// touch device registration.
- const char *sysname = libinput_device_get_sysname(dev); // node name without path
- const char *name = libinput_device_get_name(dev);
- emit deviceAdded(QString::fromUtf8(sysname), QString::fromUtf8(name));
-
QInputDeviceManagerPrivate *inputManagerPriv = QInputDeviceManagerPrivate::get(
QGuiApplicationPrivate::inputDeviceManager());
if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TOUCH)) {
@@ -180,10 +179,6 @@ void QLibInputHandler::processEvent(libinput_event *ev)
}
case LIBINPUT_EVENT_DEVICE_REMOVED:
{
- const char *sysname = libinput_device_get_sysname(dev);
- const char *name = libinput_device_get_name(dev);
- emit deviceRemoved(QString::fromUtf8(sysname), QString::fromUtf8(name));
-
QInputDeviceManagerPrivate *inputManagerPriv = QInputDeviceManagerPrivate::get(
QGuiApplicationPrivate::inputDeviceManager());
if (libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TOUCH)) {
@@ -236,9 +231,4 @@ void QLibInputHandler::processEvent(libinput_event *ev)
}
}
-void QLibInputHandler::onCursorPositionChangeRequested(const QPoint &pos)
-{
- m_pointer->setPos(pos);
-}
-
QT_END_NAMESPACE
diff --git a/src/platformsupport/input/libinput/qlibinputhandler_p.h b/src/platformsupport/input/libinput/qlibinputhandler_p.h
index f3dcf0f0be..ac7a267a4d 100644
--- a/src/platformsupport/input/libinput/qlibinputhandler_p.h
+++ b/src/platformsupport/input/libinput/qlibinputhandler_p.h
@@ -68,19 +68,11 @@ class QLibInputTouch;
class QLibInputHandler : public QObject
{
- Q_OBJECT
-
public:
QLibInputHandler(const QString &key, const QString &spec);
~QLibInputHandler();
-signals:
- void deviceAdded(const QString &sysname, const QString &name);
- void deviceRemoved(const QString &sysname, const QString &name);
-
-private slots:
void onReadyRead();
- void onCursorPositionChangeRequested(const QPoint &pos);
private:
void processEvent(libinput_event *ev);
diff --git a/src/platformsupport/input/libinput/qlibinputkeyboard_p.h b/src/platformsupport/input/libinput/qlibinputkeyboard_p.h
index 12a3eb06eb..b7ee8a363f 100644
--- a/src/platformsupport/input/libinput/qlibinputkeyboard_p.h
+++ b/src/platformsupport/input/libinput/qlibinputkeyboard_p.h
@@ -64,8 +64,6 @@ QT_BEGIN_NAMESPACE
class QLibInputKeyboard : public QObject
{
- Q_OBJECT
-
public:
QLibInputKeyboard();
~QLibInputKeyboard();
@@ -73,7 +71,6 @@ public:
void processKey(libinput_event_keyboard *e);
#ifndef QT_NO_XKBCOMMON_EVDEV
-private slots:
void handleRepeat();
private:
diff --git a/src/platformsupport/input/libinput/qlibinputpointer.cpp b/src/platformsupport/input/libinput/qlibinputpointer.cpp
index b20cc4c095..d85a01b7d7 100644
--- a/src/platformsupport/input/libinput/qlibinputpointer.cpp
+++ b/src/platformsupport/input/libinput/qlibinputpointer.cpp
@@ -96,21 +96,28 @@ void QLibInputPointer::processMotion(libinput_event_pointer *e)
void QLibInputPointer::processAxis(libinput_event_pointer *e)
{
+ double value; // default axis value is 15 degrees per wheel click
+ QPoint angleDelta;
#if !QT_CONFIG(libinput_axis_api)
- const double v = libinput_event_pointer_get_axis_value(e) * 120;
- const Qt::Orientation ori = libinput_event_pointer_get_axis(e) == LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL
- ? Qt::Vertical : Qt::Horizontal;
- QWindowSystemInterface::handleWheelEvent(nullptr, m_pos, m_pos, qRound(-v), ori, QGuiApplication::keyboardModifiers());
+ value = libinput_event_pointer_get_axis_value(e);
+ if (libinput_event_pointer_get_axis(e) == LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)
+ angleDelta.setY(qRound(value));
+ else
+ angleDelta.setX(qRound(value));
#else
if (libinput_event_pointer_has_axis(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) {
- const double v = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL) * 120;
- QWindowSystemInterface::handleWheelEvent(nullptr, m_pos, m_pos, qRound(-v), Qt::Vertical, QGuiApplication::keyboardModifiers());
+ value = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
+ angleDelta.setY(qRound(value));
}
if (libinput_event_pointer_has_axis(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) {
- const double v = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL) * 120;
- QWindowSystemInterface::handleWheelEvent(nullptr, m_pos, m_pos, qRound(-v), Qt::Horizontal, QGuiApplication::keyboardModifiers());
+ value = libinput_event_pointer_get_axis_value(e, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL);
+ angleDelta.setX(qRound(value));
}
#endif
+ const int factor = 8;
+ angleDelta *= -factor;
+ Qt::KeyboardModifiers mods = QGuiApplication::keyboardModifiers();
+ QWindowSystemInterface::handleWheelEvent(nullptr, m_pos, m_pos, QPoint(), angleDelta, mods);
}
void QLibInputPointer::setPos(const QPoint &pos)
diff --git a/src/platformsupport/platformsupport.pro b/src/platformsupport/platformsupport.pro
index 248c1ae667..5549984d6a 100644
--- a/src/platformsupport/platformsupport.pro
+++ b/src/platformsupport/platformsupport.pro
@@ -40,8 +40,6 @@ darwin {
SUBDIRS += \
clipboard \
graphics
- macos: \
- SUBDIRS += cglconvenience
}
qtConfig(vulkan): \
diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
index a9e1b655a1..379e428cb0 100644
--- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
+++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
@@ -137,6 +137,17 @@ bool QIBusPlatformInputContext::isValid() const
return d->valid && d->busConnected;
}
+bool QIBusPlatformInputContext::hasCapability(Capability capability) const
+{
+ switch (capability) {
+ case QPlatformInputContext::HiddenTextCapability:
+ return false; // QTBUG-40691, do not show IME on desktop for password entry fields.
+ default:
+ break;
+ }
+ return true;
+}
+
void QIBusPlatformInputContext::invokeAction(QInputMethod::Action a, int)
{
if (!d->busConnected)
diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h
index aab161c954..f78c99e2bd 100644
--- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h
+++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h
@@ -95,6 +95,7 @@ public:
void update(Qt::InputMethodQueries) override;
bool filterEvent(const QEvent *event) override;
QLocale locale() const override;
+ bool hasCapability(Capability capability) const override;
public Q_SLOTS:
void commitText(const QDBusVariant &text);
diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro
index 1e6ea70161..6ac5021ea9 100644
--- a/src/plugins/platforms/cocoa/cocoa.pro
+++ b/src/plugins/platforms/cocoa/cocoa.pro
@@ -75,12 +75,12 @@ qtConfig(opengl.*) {
RESOURCES += qcocoaresources.qrc
-LIBS += -framework AppKit -framework Carbon -framework IOKit -lcups
+LIBS += -framework AppKit -framework Carbon -framework IOKit -framework QuartzCore -lcups
QT += \
core-private gui-private \
accessibility_support-private clipboard_support-private theme_support-private \
- fontdatabase_support-private graphics_support-private cgl_support-private
+ fontdatabase_support-private graphics_support-private
CONFIG += no_app_extension_api_only
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
index 61f44e37d1..1f39d787be 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
@@ -79,7 +79,15 @@ void QCocoaBackingStore::beginPaint(const QRegion &region)
void QCocoaBackingStore::endPaint()
{
QRasterBackingStore::endPaint();
- m_cgImage = m_image.toCGImage();
+
+ // Prevent potentially costly color conversion by assiging the display
+ // color space to the backingstore image.
+ NSView *view = static_cast<QCocoaWindow *>(window()->handle())->view();
+ CGColorSpaceRef displayColorSpace = view.window.screen.colorSpace.CGColorSpace;
+ QCFType<CGImageRef> displayColorSpaceImage =
+ CGImageCreateCopyWithColorSpace(m_image.toCGImage(), displayColorSpace);
+
+ m_cgImage = displayColorSpaceImage;
}
#if !QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_12)
@@ -190,14 +198,15 @@ void QCocoaBackingStore::flush(QWindow *window, const QRegion &region, const QPo
// Create temporary image to use for blitting, without copying image data
NSImage *backingStoreImage = [[[NSImage alloc] initWithCGImage:m_cgImage size:NSZeroSize] autorelease];
- if ([topLevelView hasMask]) {
- // FIXME: Implement via NSBezierPath and addClip
- CGRect boundingRect = region.boundingRect().toCGRect();
- QCFType<CGImageRef> subMask = CGImageCreateWithImageInRect([topLevelView maskImage], boundingRect);
- CGContextClipToMask(graphicsContext.CGContext, boundingRect, subMask);
+ QRegion clippedRegion = region;
+ for (QWindow *w = window; w; w = w->parent()) {
+ if (!w->mask().isEmpty()) {
+ clippedRegion &= w == window ? w->mask()
+ : w->mask().translated(window->mapFromGlobal(w->mapToGlobal(QPoint(0, 0))));
+ }
}
- for (const QRect &viewLocalRect : region) {
+ for (const QRect &viewLocalRect : clippedRegion) {
QPoint backingStoreOffset = viewLocalRect.topLeft() + offset;
QRect backingStoreRect(backingStoreOffset * devicePixelRatio, viewLocalRect.size() * devicePixelRatio);
if (graphicsContext.flipped) // Flip backingStoreRect to match graphics context
@@ -225,6 +234,12 @@ void QCocoaBackingStore::flush(QWindow *window, const QRegion &region, const QPo
#endif
}
+ QCocoaWindow *topLevelCocoaWindow = static_cast<QCocoaWindow *>(topLevelWindow->handle());
+ if (Q_UNLIKELY(topLevelCocoaWindow->m_needsInvalidateShadow)) {
+ [topLevelView.window invalidateShadow];
+ topLevelCocoaWindow->m_needsInvalidateShadow = false;
+ }
+
// -------------------------------------------------------------------------
if (shouldHandleViewLockManually)
@@ -234,9 +249,6 @@ void QCocoaBackingStore::flush(QWindow *window, const QRegion &region, const QPo
redrawRoundedBottomCorners([view convertRect:region.boundingRect().toCGRect() toView:nil]);
[view.window flushWindow];
}
-
- // FIXME: Tie to changing window flags and/or mask instead
- [view invalidateWindowShadowIfNeeded];
}
/*
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
index 9e688f4d1b..75ac348802 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -42,7 +42,6 @@
#include "qcocoahelpers.h"
#include <qdebug.h>
#include <QtCore/private/qcore_mac_p.h>
-#include <QtCglSupport/private/cglconvenience_p.h>
#include <QtPlatformHeaders/qcocoanativecontext.h>
#include <dlfcn.h>
@@ -154,7 +153,7 @@ QCocoaGLContext::QCocoaGLContext(const QSurfaceFormat &format, QPlatformOpenGLCo
QMacAutoReleasePool pool; // For the SG Canvas render thread
// create native context for the requested pixel format and share
- NSOpenGLPixelFormat *pixelFormat = static_cast <NSOpenGLPixelFormat *>(qcgl_createNSOpenGLPixelFormat(m_format));
+ NSOpenGLPixelFormat *pixelFormat = createNSOpenGLPixelFormat(m_format);
m_shareContext = share ? static_cast<QCocoaGLContext *>(share)->nsOpenGLContext() : nil;
m_context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:m_shareContext];
@@ -202,7 +201,6 @@ QVariant QCocoaGLContext::nativeHandle() const
return QVariant::fromValue<QCocoaNativeContext>(QCocoaNativeContext(m_context));
}
-// Match up with createNSOpenGLPixelFormat!
QSurfaceFormat QCocoaGLContext::format() const
{
return m_format;
@@ -362,7 +360,64 @@ void QCocoaGLContext::update()
NSOpenGLPixelFormat *QCocoaGLContext::createNSOpenGLPixelFormat(const QSurfaceFormat &format)
{
- return static_cast<NSOpenGLPixelFormat *>(qcgl_createNSOpenGLPixelFormat(format));
+ QVector<NSOpenGLPixelFormatAttribute> attrs;
+
+ if (format.swapBehavior() == QSurfaceFormat::DoubleBuffer
+ || format.swapBehavior() == QSurfaceFormat::DefaultSwapBehavior)
+ attrs.append(NSOpenGLPFADoubleBuffer);
+ else if (format.swapBehavior() == QSurfaceFormat::TripleBuffer)
+ attrs.append(NSOpenGLPFATripleBuffer);
+
+
+ // Select OpenGL profile
+ attrs << NSOpenGLPFAOpenGLProfile;
+ if (format.profile() == QSurfaceFormat::CoreProfile) {
+ if (format.version() >= qMakePair(4, 1))
+ attrs << NSOpenGLProfileVersion4_1Core;
+ else if (format.version() >= qMakePair(3, 2))
+ attrs << NSOpenGLProfileVersion3_2Core;
+ else
+ attrs << NSOpenGLProfileVersionLegacy;
+ } else {
+ attrs << NSOpenGLProfileVersionLegacy;
+ }
+
+ if (format.depthBufferSize() > 0)
+ attrs << NSOpenGLPFADepthSize << format.depthBufferSize();
+ if (format.stencilBufferSize() > 0)
+ attrs << NSOpenGLPFAStencilSize << format.stencilBufferSize();
+ if (format.alphaBufferSize() > 0)
+ attrs << NSOpenGLPFAAlphaSize << format.alphaBufferSize();
+ if ((format.redBufferSize() > 0) &&
+ (format.greenBufferSize() > 0) &&
+ (format.blueBufferSize() > 0)) {
+ const int colorSize = format.redBufferSize() +
+ format.greenBufferSize() +
+ format.blueBufferSize();
+ attrs << NSOpenGLPFAColorSize << colorSize << NSOpenGLPFAMinimumPolicy;
+ }
+
+ if (format.samples() > 0) {
+ attrs << NSOpenGLPFAMultisample
+ << NSOpenGLPFASampleBuffers << (NSOpenGLPixelFormatAttribute) 1
+ << NSOpenGLPFASamples << (NSOpenGLPixelFormatAttribute) format.samples();
+ }
+
+ if (format.stereo())
+ attrs << NSOpenGLPFAStereo;
+
+ attrs << NSOpenGLPFAAllowOfflineRenderers;
+
+ QByteArray useLayer = qgetenv("QT_MAC_WANTS_LAYER");
+ if (!useLayer.isEmpty() && useLayer.toInt() > 0) {
+ // Disable the software rendering fallback. This makes compositing
+ // OpenGL and raster NSViews using Core Animation layers possible.
+ attrs << NSOpenGLPFANoRecovery;
+ }
+
+ attrs << 0;
+
+ return [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs.constData()];
}
NSOpenGLContext *QCocoaGLContext::nsOpenGLContext() const
diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h
index 1f4f9cd276..7810733255 100644
--- a/src/plugins/platforms/cocoa/qcocoahelpers.h
+++ b/src/plugins/platforms/cocoa/qcocoahelpers.h
@@ -223,7 +223,7 @@ ReturnType qt_msgSendSuper(id receiver, SEL selector, Args... args)
typedef ReturnType (*SuperFn)(objc_super *, SEL, Args...);
SuperFn superFn = reinterpret_cast<SuperFn>(objc_msgSendSuper);
- objc_super sup = { receiver, class_getSuperclass(object_getClass(receiver)) };
+ objc_super sup = { receiver, [receiver superclass] };
return superFn(&sup, selector, args...);
}
@@ -236,7 +236,7 @@ ReturnType qt_msgSendSuper_stret(id receiver, SEL selector, Args... args)
typedef void (*SuperStretFn)(ReturnType *, objc_super *, SEL, Args...);
SuperStretFn superStretFn = reinterpret_cast<SuperStretFn>(objc_msgSendSuper_stret);
- objc_super sup = { receiver, class_getSuperclass(object_getClass(receiver)) };
+ objc_super sup = { receiver, [receiver superclass] };
ReturnType ret;
superStretFn(&ret, &sup, selector, args...);
return ret;
diff --git a/src/plugins/platforms/cocoa/qcocoainputcontext.mm b/src/plugins/platforms/cocoa/qcocoainputcontext.mm
index 9e3d747cd7..9221099a57 100644
--- a/src/plugins/platforms/cocoa/qcocoainputcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoainputcontext.mm
@@ -124,7 +124,22 @@ void QCocoaInputContext::connectSignals()
void QCocoaInputContext::focusObjectChanged(QObject *focusObject)
{
Q_UNUSED(focusObject);
- mWindow = QGuiApplication::focusWindow();
+ if (mWindow == QGuiApplication::focusWindow()) {
+ if (!mWindow)
+ return;
+
+ QCocoaWindow *window = static_cast<QCocoaWindow *>(mWindow->handle());
+ QNSView *view = qnsview_cast(window->view());
+ if (!view)
+ return;
+
+ if (NSTextInputContext *ctxt = [NSTextInputContext currentInputContext]) {
+ [ctxt discardMarkedText];
+ [view cancelComposingText];
+ }
+ } else {
+ mWindow = QGuiApplication::focusWindow();
+ }
}
void QCocoaInputContext::updateLocale()
diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.h b/src/plugins/platforms/cocoa/qcocoakeymapper.h
index 4ba615efeb..a75e275077 100644
--- a/src/plugins/platforms/cocoa/qcocoakeymapper.h
+++ b/src/plugins/platforms/cocoa/qcocoakeymapper.h
@@ -91,8 +91,6 @@ public:
private:
QCFType<TISInputSourceRef> currentInputSource;
- QLocale keyboardInputLocale;
- Qt::LayoutDirection keyboardInputDirection;
enum { NullMode, UnicodeMode, OtherMode } keyboard_mode;
union {
const UCKeyboardLayout *unicode;
diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.mm b/src/plugins/platforms/cocoa/qcocoakeymapper.mm
index 5fa062bbe0..80140505d1 100644
--- a/src/plugins/platforms/cocoa/qcocoakeymapper.mm
+++ b/src/plugins/platforms/cocoa/qcocoakeymapper.mm
@@ -376,18 +376,7 @@ bool QCocoaKeyMapper::updateKeyboard()
}
currentInputSource = source;
keyboard_dead = 0;
- CFStringRef iso639Code;
- CFArrayRef array = static_cast<CFArrayRef>(TISGetInputSourceProperty(currentInputSource, kTISPropertyInputSourceLanguages));
- iso639Code = static_cast<CFStringRef>(CFArrayGetValueAtIndex(array, 0)); // Actually a RFC3066bis, but it's close enough
-
- if (iso639Code) {
- keyboardInputLocale = QLocale(QString::fromCFString(iso639Code));
- keyboardInputDirection = keyboardInputLocale.textDirection();
- } else {
- keyboardInputLocale = QLocale::c();
- keyboardInputDirection = Qt::LeftToRight;
- }
return true;
}
diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm
index edefe7bd9a..36655dffab 100644
--- a/src/plugins/platforms/cocoa/qcocoamenubar.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm
@@ -86,6 +86,7 @@ QCocoaMenuBar::~QCocoaMenuBar()
// the menu bar was updated
qDeleteAll(children());
updateMenuBarImmediately();
+ resetKnownMenuItemsToQt();
}
}
@@ -306,16 +307,9 @@ void QCocoaMenuBar::resetKnownMenuItemsToQt()
foreach (QCocoaMenuBar *mb, static_menubars) {
foreach (QCocoaMenu *m, mb->m_menus) {
foreach (QCocoaMenuItem *i, m->items()) {
- switch (i->effectiveRole()) {
- case QPlatformMenuItem::CutRole:
- case QPlatformMenuItem::CopyRole:
- case QPlatformMenuItem::PasteRole:
- case QPlatformMenuItem::SelectAllRole:
+ if (i->effectiveRole() >= QPlatformMenuItem::ApplicationSpecificRole) {
[i->nsItem() setTarget:m->nsMenu().delegate];
[i->nsItem() setAction:@selector(itemFired:)];
- break;
- default:
- break;
}
}
}
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index 7f5a87ea3d..1244b46620 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -123,6 +123,7 @@ public:
bool isForeignWindow() const override;
+ void requestUpdate() override;
void requestActivateWindow() override;
WId winId() const override;
@@ -174,8 +175,6 @@ public:
void setMenubar(QCocoaMenuBar *mb);
QCocoaMenuBar *menubar() const;
- NSCursor *effectiveWindowCursor() const;
- void applyEffectiveWindowCursor();
void setWindowCursor(NSCursor *cursor);
void registerTouch(bool enable);
@@ -257,7 +256,8 @@ public: // for QNSView
QCocoaGLContext *m_glContext;
#endif
QCocoaMenuBar *m_menubar;
- NSCursor *m_windowCursor;
+
+ bool m_needsInvalidateShadow;
bool m_hasModalSession;
bool m_frameStrutEventsEnabled;
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index e906f0fd1c..63ee8c10ac 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -57,6 +57,7 @@
#include <QtGui/private/qhighdpiscaling_p.h>
#include <AppKit/AppKit.h>
+#include <QuartzCore/QuartzCore.h>
#include <QDebug>
@@ -149,7 +150,7 @@ QCocoaWindow::QCocoaWindow(QWindow *win, WId nativeHandle)
, m_glContext(0)
#endif
, m_menubar(0)
- , m_windowCursor(0)
+ , m_needsInvalidateShadow(false)
, m_hasModalSession(false)
, m_frameStrutEventsEnabled(false)
, m_isExposed(false)
@@ -228,7 +229,6 @@ QCocoaWindow::~QCocoaWindow()
[m_view release];
[m_nsWindow release];
- [m_windowCursor release];
}
QSurfaceFormat QCocoaWindow::format() const
@@ -323,6 +323,12 @@ void QCocoaWindow::setVisible(bool visible)
// We need to recreate if the modality has changed as the style mask will need updating
recreateWindowIfNeeded();
+ // We didn't send geometry changes during creation, as that would have confused
+ // Qt, which expects a show-event to be sent before any resize events. But now
+ // that the window is made visible, we know that the show-event has been sent
+ // so we can send the geometry change. FIXME: Get rid of this workaround.
+ handleGeometryChange();
+
// Register popup windows. The Cocoa platform plugin will forward mouse events
// to them and close them when needed.
if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip)
@@ -693,7 +699,7 @@ bool QCocoaWindow::isOpaque() const
bool translucent = window()->format().alphaBufferSize() > 0
|| window()->opacity() < 1
- || [qnsview_cast(m_view) hasMask]
+ || !window()->mask().isEmpty()
|| (surface()->supportsOpenGL() && openglSourfaceOrder == -1);
return !translucent;
}
@@ -743,17 +749,40 @@ void QCocoaWindow::setOpacity(qreal level)
return;
m_view.window.alphaValue = level;
- m_view.window.opaque = isOpaque();
}
void QCocoaWindow::setMask(const QRegion &region)
{
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::setMask" << window() << region;
- if (isContentView())
- m_view.window.backgroundColor = !region.isEmpty() ? [NSColor clearColor] : nil;
- [qnsview_cast(m_view) setMaskRegion:&region];
- m_view.window.opaque = isOpaque();
+ if (m_view.layer) {
+ if (!region.isEmpty()) {
+ QCFType<CGMutablePathRef> maskPath = CGPathCreateMutable();
+ for (const QRect &r : region)
+ CGPathAddRect(maskPath, nullptr, r.toCGRect());
+ CAShapeLayer *maskLayer = [CAShapeLayer layer];
+ maskLayer.path = maskPath;
+ m_view.layer.mask = maskLayer;
+ } else {
+ m_view.layer.mask = nil;
+ }
+ }
+
+ if (isContentView()) {
+ // Setting the mask requires invalidating the NSWindow shadow, but that needs
+ // to happen after the backingstore has been redrawn, so that AppKit can pick
+ // up the new window shape based on the backingstore content. Doing a display
+ // directly here is not an option, as the window might not be exposed at this
+ // time, and so would not result in an updated backingstore.
+ m_needsInvalidateShadow = true;
+ [m_view setNeedsDisplay:YES];
+
+ // FIXME: [NSWindow invalidateShadow] has no effect when in layer-backed mode,
+ // so if the mask is changed after the initial mask is applied, it will not
+ // result in any visual change to the shadow. This is an Apple bug, and there
+ // may be ways to work around it, such as calling setFrame on the window to
+ // trigger some internal invalidation, but that needs more research.
+ }
}
bool QCocoaWindow::setKeyboardGrabEnabled(bool grab)
@@ -1067,6 +1096,15 @@ void QCocoaWindow::handleExposeEvent(const QRegion &region)
&& !region.isEmpty()
&& !m_view.hiddenOrHasHiddenAncestor;
+
+ QWindowPrivate *windowPrivate = qt_window_private(window());
+ if (m_isExposed && windowPrivate->updateRequestPending) {
+ // FIXME: Should this logic for expose events be in QGuiApplication?
+ qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::handleExposeEvent" << window() << region << "as update request";
+ windowPrivate->deliverUpdateRequest();
+ return;
+ }
+
qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::handleExposeEvent" << window() << region << "isExposed" << isExposed();
QWindowSystemInterface::handleExposeEvent<QWindowSystemInterface::SynchronousDelivery>(window(), region);
}
@@ -1237,6 +1275,12 @@ void QCocoaWindow::recreateWindowIfNeeded()
updateNSToolbar();
}
+void QCocoaWindow::requestUpdate()
+{
+ qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::requestUpdate" << window();
+ [m_view setNeedsDisplay:YES];
+}
+
void QCocoaWindow::requestActivateWindow()
{
NSWindow *window = [m_view window];
@@ -1312,11 +1356,6 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBePanel)
nsWindow.restorable = NO;
nsWindow.level = windowLevel(flags);
- if (!isOpaque()) {
- nsWindow.backgroundColor = [NSColor clearColor];
- nsWindow.opaque = NO;
- }
-
if (shouldBePanel) {
// Qt::Tool windows hide on app deactivation, unless Qt::WA_MacAlwaysShowToolWindow is set
nsWindow.hidesOnDeactivate = ((type & Qt::Tool) == Qt::Tool) && !alwaysShowToolWindow();
@@ -1515,51 +1554,19 @@ QCocoaMenuBar *QCocoaWindow::menubar() const
return m_menubar;
}
-// Finds the effective cursor for this window by walking up the
-// ancestor chain (including this window) until a set cursor is
-// found. Returns nil if there is not set cursor.
-NSCursor *QCocoaWindow::effectiveWindowCursor() const
-{
-
- if (m_windowCursor)
- return m_windowCursor;
- if (!QPlatformWindow::parent())
- return nil;
- return static_cast<QCocoaWindow *>(QPlatformWindow::parent())->effectiveWindowCursor();
-}
-
-// Applies the cursor as returned by effectiveWindowCursor(), handles
-// the special no-cursor-set case by setting the arrow cursor.
-void QCocoaWindow::applyEffectiveWindowCursor()
-{
- NSCursor *effectiveCursor = effectiveWindowCursor();
- if (effectiveCursor) {
- [effectiveCursor set];
- } else {
- // We wold like to _unset_ the cursor here; but there is no such
- // API. Fall back to setting the default arrow cursor.
- [[NSCursor arrowCursor] set];
- }
-}
-
void QCocoaWindow::setWindowCursor(NSCursor *cursor)
{
- if (m_windowCursor == cursor)
+ // Setting a cursor in a foreign view is not supported
+ if (isForeignWindow())
return;
- // Setting a cursor in a foregin view is not supported.
- if (isForeignWindow())
+ QNSView *view = qnsview_cast(m_view);
+ if (cursor == view.cursor)
return;
- [m_windowCursor release];
- m_windowCursor = cursor;
- [m_windowCursor retain];
+ view.cursor = cursor;
- // The installed view tracking area (see QNSView updateTrackingAreas) will
- // handle cursor updates on mouse enter/leave. Handle the case where the
- // mouse is on the this window by changing the cursor immediately.
- if (m_windowUnderMouse)
- applyEffectiveWindowCursor();
+ [m_view.window invalidateCursorRectsForView:m_view];
}
void QCocoaWindow::registerTouch(bool enable)
diff --git a/src/plugins/platforms/cocoa/qmultitouch_mac.mm b/src/plugins/platforms/cocoa/qmultitouch_mac.mm
index f0ea3b1e66..79f8af7783 100644
--- a/src/plugins/platforms/cocoa/qmultitouch_mac.mm
+++ b/src/plugins/platforms/cocoa/qmultitouch_mac.mm
@@ -39,10 +39,14 @@
#include "qmultitouch_mac_p.h"
#include "qcocoahelpers.h"
+#include <private/qtouchdevice_p.h>
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcInputDevices, "qt.qpa.input.devices")
+
QHash<qint64, QCocoaTouch*> QCocoaTouch::_currentTouches;
+QHash<quint64, QTouchDevice*> QCocoaTouch::_touchDevices;
QPointF QCocoaTouch::_screenReferencePos;
QPointF QCocoaTouch::_trackpadReferencePos;
int QCocoaTouch::_idAssignmentCount = 0;
@@ -209,4 +213,19 @@ QCocoaTouch::getCurrentTouchPointList(NSEvent *event, bool acceptSingleTouch)
return touchPoints.values();
}
+QTouchDevice *QCocoaTouch::getTouchDevice(QTouchDevice::DeviceType type, quint64 id)
+{
+ QTouchDevice *ret = _touchDevices.value(id);
+ if (!ret) {
+ ret = new QTouchDevice;
+ ret->setType(type);
+ ret->setCapabilities(QTouchDevice::Position | QTouchDevice::NormalizedPosition | QTouchDevice::MouseEmulation);
+ QWindowSystemInterface::registerTouchDevice(ret);
+ _touchDevices.insert(id, ret);
+ qCDebug(lcInputDevices) << "touch device" << id << "of type" << type
+ << "registered as Qt device" << QTouchDevicePrivate::get(ret)->id;
+ }
+ return ret;
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qmultitouch_mac_p.h b/src/plugins/platforms/cocoa/qmultitouch_mac_p.h
index 77af86c9c7..044bcd1882 100644
--- a/src/plugins/platforms/cocoa/qmultitouch_mac_p.h
+++ b/src/plugins/platforms/cocoa/qmultitouch_mac_p.h
@@ -66,8 +66,10 @@ class QCocoaTouch
public:
static QList<QWindowSystemInterface::TouchPoint> getCurrentTouchPointList(NSEvent *event, bool acceptSingleTouch);
static void setMouseInDraggingState(bool inDraggingState);
+ static QTouchDevice *getTouchDevice(QTouchDevice::DeviceType type, quint64 id);
private:
+ static QHash<quint64, QTouchDevice*> _touchDevices;
static QHash<qint64, QCocoaTouch*> _currentTouches;
static QPointF _screenReferencePos;
static QPointF _trackpadReferencePos;
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h
index dcf8cf677a..f8903725a6 100644
--- a/src/plugins/platforms/cocoa/qnsview.h
+++ b/src/plugins/platforms/cocoa/qnsview.h
@@ -57,15 +57,13 @@ QT_END_NAMESPACE
Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
@interface QT_MANGLE_NAMESPACE(QNSView) : NSView <NSTextInputClient> {
- QRegion m_maskRegion;
- CGImageRef m_maskImage;
- bool m_shouldInvalidateWindowShadow;
QPointer<QCocoaWindow> m_platformWindow;
NSTrackingArea *m_trackingArea;
Qt::MouseButtons m_buttons;
Qt::MouseButtons m_acceptedMouseDowns;
Qt::MouseButtons m_frameStrutButtons;
QString m_composingText;
+ QPointer<QObject> m_composingFocusObject;
bool m_sendKeyEvent;
QStringList *currentCustomDragTypes;
bool m_dontOverrideCtrlLMB;
@@ -85,23 +83,22 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
QSet<quint32> m_acceptedKeyDowns;
}
+@property (nonatomic, retain) NSCursor *cursor;
+
- (id)init;
- (id)initWithCocoaWindow:(QCocoaWindow *)platformWindow;
#ifndef QT_NO_OPENGL
- (void)setQCocoaGLContext:(QCocoaGLContext *)context;
#endif
-- (void)setMaskRegion:(const QRegion *)region;
-- (CGImageRef)maskImage;
-- (void)invalidateWindowShadowIfNeeded;
- (void)drawRect:(NSRect)dirtyRect;
- (void)textInputContextKeyboardSelectionDidChangeNotification : (NSNotification *) textInputContextKeyboardSelectionDidChangeNotification;
- (void)viewDidHide;
- (void)removeFromSuperview;
+- (void)cancelComposingText;
- (BOOL)isFlipped;
- (BOOL)acceptsFirstResponder;
- (BOOL)becomeFirstResponder;
-- (BOOL)hasMask;
- (BOOL)isOpaque;
- (void)convertFromScreen:(NSPoint)mouseLocation toWindowPoint:(QPointF *)qtWindowPoint andScreenPoint:(QPointF *)qtScreenPoint;
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 924173b4c5..643d3b3a30 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -53,6 +53,7 @@
#include <QtCore/qsysinfo.h>
#include <private/qguiapplication_p.h>
#include <private/qcoregraphics_p.h>
+#include <private/qwindow_p.h>
#include "qcocoabackingstore.h"
#ifndef QT_NO_OPENGL
#include "qcocoaglcontext.h"
@@ -69,8 +70,6 @@ Q_LOGGING_CATEGORY(lcQpaGestures, "qt.qpa.input.gestures")
#endif
Q_LOGGING_CATEGORY(lcQpaTablet, "qt.qpa.input.tablet")
-static QTouchDevice *touchDevice = 0;
-
@interface QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) : NSObject
{
QNSView *view;
@@ -113,7 +112,7 @@ static QTouchDevice *touchDevice = 0;
- (void)cursorUpdate:(NSEvent *)theEvent
{
- [self cursorUpdate:theEvent];
+ [view cursorUpdate:theEvent];
}
@end
@@ -128,8 +127,6 @@ static QTouchDevice *touchDevice = 0;
- (id) init
{
if (self = [super initWithFrame:NSZeroRect]) {
- m_maskImage = 0;
- m_shouldInvalidateWindowShadow = false;
m_buttons = Qt::NoButton;
m_acceptedMouseDowns = Qt::NoButton;
m_frameStrutButtons = Qt::NoButton;
@@ -147,28 +144,19 @@ static QTouchDevice *touchDevice = 0;
m_scrolling = false;
m_updatingDrag = false;
m_currentlyInterpretedKeyEvent = 0;
-
- if (!touchDevice) {
- touchDevice = new QTouchDevice;
- touchDevice->setType(QTouchDevice::TouchPad);
- touchDevice->setCapabilities(QTouchDevice::Position | QTouchDevice::NormalizedPosition | QTouchDevice::MouseEmulation);
- QWindowSystemInterface::registerTouchDevice(touchDevice);
- }
-
m_isMenuView = false;
self.focusRingType = NSFocusRingTypeNone;
+ self.cursor = nil;
}
return self;
}
- (void)dealloc
{
- CGImageRelease(m_maskImage);
if (m_trackingArea) {
[self removeTrackingArea:m_trackingArea];
[m_trackingArea release];
}
- m_maskImage = 0;
[m_inputSource release];
[[NSNotificationCenter defaultCenter] removeObserver:self];
[m_mouseMoveHelper release];
@@ -304,11 +292,6 @@ static QTouchDevice *touchDevice = 0;
[super removeFromSuperview];
}
-- (BOOL) hasMask
-{
- return !m_maskRegion.isEmpty();
-}
-
- (BOOL) isOpaque
{
if (!m_platformWindow)
@@ -316,48 +299,6 @@ static QTouchDevice *touchDevice = 0;
return m_platformWindow->isOpaque();
}
-- (void) setMaskRegion:(const QRegion *)region
-{
- m_shouldInvalidateWindowShadow = true;
- m_maskRegion = *region;
- if (m_maskImage)
- CGImageRelease(m_maskImage);
- if (region->isEmpty()) {
- m_maskImage = 0;
- return;
- }
-
- const QRect &rect = region->boundingRect();
- QImage tmp(rect.size(), QImage::Format_RGB32);
- tmp.fill(Qt::white);
- QPainter p(&tmp);
- p.setClipRegion(*region);
- p.fillRect(rect, Qt::black);
- p.end();
- QImage maskImage = QImage(rect.size(), QImage::Format_Indexed8);
- for (int y=0; y<rect.height(); ++y) {
- const uint *src = (const uint *) tmp.constScanLine(y);
- uchar *dst = maskImage.scanLine(y);
- for (int x=0; x<rect.width(); ++x) {
- dst[x] = src[x] & 0xff;
- }
- }
- m_maskImage = qt_mac_toCGImageMask(maskImage);
-}
-
-- (CGImageRef)maskImage
-{
- return m_maskImage;
-}
-
-- (void)invalidateWindowShadowIfNeeded
-{
- if (m_shouldInvalidateWindowShadow && m_platformWindow->isContentView()) {
- [m_platformWindow->nativeWindow() invalidateShadow];
- m_shouldInvalidateWindowShadow = false;
- }
-}
-
- (void)drawRect:(NSRect)dirtyRect
{
Q_UNUSED(dirtyRect);
@@ -382,6 +323,17 @@ static QTouchDevice *touchDevice = 0;
#endif
m_platformWindow->handleExposeEvent(exposedRegion);
+
+ // A call to QWindow::requestUpdate was issued during the expose event, but
+ // AppKit will reset the needsDisplay state of the view after completing the
+ // current display cycle, so we need to defer the request to redisplay.
+ // FIXME: Perhaps this should be a trigger to enable CADisplayLink?
+ if (qt_window_private(m_platformWindow->window())->updateRequestPending) {
+ qCDebug(lcQpaCocoaWindow) << "[QNSView drawRect:] deferring setNeedsDisplay";
+ dispatch_async(dispatch_get_main_queue (), ^{
+ [self setNeedsDisplay:YES];
+ });
+ }
}
- (BOOL)wantsUpdateLayer
@@ -614,7 +566,8 @@ static QTouchDevice *touchDevice = 0;
Q_UNUSED(qtScreenPoint);
// Maintain masked state for the button for use by MouseDragged and MouseUp.
- const bool masked = [self hasMask] && !m_maskRegion.contains(qtWindowPoint.toPoint());
+ QRegion mask = m_platformWindow->window()->mask();
+ const bool masked = !mask.isEmpty() && !mask.contains(qtWindowPoint.toPoint());
if (masked)
m_acceptedMouseDowns &= ~button;
else
@@ -712,8 +665,8 @@ static QTouchDevice *touchDevice = 0;
[self convertFromScreen:[self screenMousePoint:theEvent] toWindowPoint:&qtWindowPoint andScreenPoint:&qtScreenPoint];
Q_UNUSED(qtScreenPoint);
- const bool masked = [self hasMask] && !m_maskRegion.contains(qtWindowPoint.toPoint());
-
+ QRegion mask = m_platformWindow->window()->mask();
+ const bool masked = !mask.isEmpty() && !mask.contains(qtWindowPoint.toPoint());
// Maintain masked state for the button for use by MouseDragged and Up.
if (masked)
m_acceptedMouseDowns &= ~Qt::LeftButton;
@@ -826,8 +779,16 @@ static QTouchDevice *touchDevice = 0;
- (void)cursorUpdate:(NSEvent *)theEvent
{
- Q_UNUSED(theEvent);
- m_platformWindow->applyEffectiveWindowCursor();
+ qCDebug(lcQpaCocoaWindow) << "[QNSView cursorUpdate:]" << self.cursor;
+
+ // Note: We do not get this callback when moving from a subview that
+ // uses the legacy cursorRect API, so the cursor is reset to the arrow
+ // cursor. See rdar://34183708
+
+ if (self.cursor)
+ [self.cursor set];
+ else
+ [super cursorUpdate:theEvent];
}
- (void)mouseMovedImpl:(NSEvent *)theEvent
@@ -1094,8 +1055,8 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
const NSTimeInterval timestamp = [event timestamp];
const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]);
- qCDebug(lcQpaTouch) << "touchesBeganWithEvent" << points;
- QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, touchDevice, points);
+ qCDebug(lcQpaTouch) << "touchesBeganWithEvent" << points << "from device" << hex << [event deviceID];
+ QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), points);
}
- (void)touchesMovedWithEvent:(NSEvent *)event
@@ -1105,8 +1066,8 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
const NSTimeInterval timestamp = [event timestamp];
const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]);
- qCDebug(lcQpaTouch) << "touchesMovedWithEvent" << points;
- QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, touchDevice, points);
+ qCDebug(lcQpaTouch) << "touchesMovedWithEvent" << points << "from device" << hex << [event deviceID];
+ QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), points);
}
- (void)touchesEndedWithEvent:(NSEvent *)event
@@ -1116,8 +1077,8 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
const NSTimeInterval timestamp = [event timestamp];
const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]);
- qCDebug(lcQpaTouch) << "touchesEndedWithEvent" << points;
- QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, touchDevice, points);
+ qCDebug(lcQpaTouch) << "touchesEndedWithEvent" << points << "from device" << hex << [event deviceID];
+ QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), points);
}
- (void)touchesCancelledWithEvent:(NSEvent *)event
@@ -1127,8 +1088,8 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
const NSTimeInterval timestamp = [event timestamp];
const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]);
- qCDebug(lcQpaTouch) << "touchesCancelledWithEvent" << points;
- QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, touchDevice, points);
+ qCDebug(lcQpaTouch) << "touchesCancelledWithEvent" << points << "from device" << hex << [event deviceID];
+ QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), points);
}
#ifndef QT_NO_GESTURES
@@ -1158,12 +1119,12 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
if ([self handleGestureAsBeginEnd:event])
return;
- qCDebug(lcQpaGestures) << "magnifyWithEvent" << [event magnification];
+ qCDebug(lcQpaGestures) << "magnifyWithEvent" << [event magnification] << "from device" << hex << [event deviceID];
const NSTimeInterval timestamp = [event timestamp];
QPointF windowPoint;
QPointF screenPoint;
[self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
- QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp, Qt::ZoomNativeGesture,
+ QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), timestamp, Qt::ZoomNativeGesture,
[event magnification], windowPoint, screenPoint);
}
@@ -1173,12 +1134,12 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
return;
static bool zoomIn = true;
- qCDebug(lcQpaGestures) << "smartMagnifyWithEvent" << zoomIn;
+ qCDebug(lcQpaGestures) << "smartMagnifyWithEvent" << zoomIn << "from device" << hex << [event deviceID];
const NSTimeInterval timestamp = [event timestamp];
QPointF windowPoint;
QPointF screenPoint;
[self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
- QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp, Qt::SmartZoomNativeGesture,
+ QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), timestamp, Qt::SmartZoomNativeGesture,
zoomIn ? 1.0f : 0.0f, windowPoint, screenPoint);
zoomIn = !zoomIn;
}
@@ -1195,7 +1156,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
QPointF windowPoint;
QPointF screenPoint;
[self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
- QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp, Qt::RotateNativeGesture,
+ QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), timestamp, Qt::RotateNativeGesture,
-[event rotation], windowPoint, screenPoint);
}
@@ -1204,7 +1165,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
if (!m_platformWindow)
return;
- qCDebug(lcQpaGestures) << "swipeWithEvent" << [event deltaX] << [event deltaY];
+ qCDebug(lcQpaGestures) << "swipeWithEvent" << [event deltaX] << [event deltaY] << "from device" << hex << [event deviceID];
const NSTimeInterval timestamp = [event timestamp];
QPointF windowPoint;
QPointF screenPoint;
@@ -1220,7 +1181,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
else if ([event deltaY] == -1)
angle = 270.0f;
- QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp, Qt::SwipeNativeGesture,
+ QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), timestamp, Qt::SwipeNativeGesture,
angle, windowPoint, screenPoint);
}
@@ -1233,8 +1194,8 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
QPointF windowPoint;
QPointF screenPoint;
[self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
- qCDebug(lcQpaGestures) << "beginGestureWithEvent @" << windowPoint;
- QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), timestamp, Qt::BeginNativeGesture,
+ qCDebug(lcQpaGestures) << "beginGestureWithEvent @" << windowPoint << "from device" << hex << [event deviceID];
+ QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), timestamp, Qt::BeginNativeGesture,
windowPoint, screenPoint);
}
@@ -1243,12 +1204,12 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
if (!m_platformWindow)
return;
- qCDebug(lcQpaGestures) << "endGestureWithEvent";
+ qCDebug(lcQpaGestures) << "endGestureWithEvent" << "from device" << hex << [event deviceID];
const NSTimeInterval timestamp = [event timestamp];
QPointF windowPoint;
QPointF screenPoint;
[self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint];
- QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), timestamp, Qt::EndNativeGesture,
+ QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), QCocoaTouch::getTouchDevice(QTouchDevice::TouchPad, [event deviceID]), timestamp, Qt::EndNativeGesture,
windowPoint, screenPoint);
}
#endif // QT_NO_GESTURES
@@ -1377,10 +1338,16 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
QChar ch = QChar::ReplacementCharacter;
int keyCode = Qt::Key_unknown;
- if ([characters length] != 0) {
+
+ // If a dead key occurs as a result of pressing a key combination then
+ // characters will have 0 length, but charactersIgnoringModifiers will
+ // have a valid character in it. This enables key combinations such as
+ // ALT+E to be used as a shortcut with an English keyboard even though
+ // pressing ALT+E will give a dead key while doing normal text input.
+ if ([characters length] != 0 || [charactersIgnoringModifiers length] != 0) {
if (((modifiers & Qt::MetaModifier) || (modifiers & Qt::AltModifier)) && ([charactersIgnoringModifiers length] != 0))
ch = QChar([charactersIgnoringModifiers characterAtIndex:0]);
- else
+ else if ([characters length] != 0)
ch = QChar([characters characterAtIndex:0]);
keyCode = [self convertKeyCode:ch];
}
@@ -1573,6 +1540,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
}
m_composingText.clear();
+ m_composingFocusObject = nullptr;
}
- (void) setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange
@@ -1627,6 +1595,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
m_composingText = preeditString;
if (QObject *fo = m_platformWindow->window()->focusObject()) {
+ m_composingFocusObject = fo;
QInputMethodQueryEvent queryEvent(Qt::ImEnabled);
if (QCoreApplication::sendEvent(fo, &queryEvent)) {
if (queryEvent.value(Qt::ImEnabled).toBool()) {
@@ -1639,6 +1608,25 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
}
}
+- (void)cancelComposingText
+{
+ if (m_composingText.isEmpty())
+ return;
+
+ if (m_composingFocusObject) {
+ QInputMethodQueryEvent queryEvent(Qt::ImEnabled);
+ if (QCoreApplication::sendEvent(m_composingFocusObject, &queryEvent)) {
+ if (queryEvent.value(Qt::ImEnabled).toBool()) {
+ QInputMethodEvent e;
+ QCoreApplication::sendEvent(m_composingFocusObject, &e);
+ }
+ }
+ }
+
+ m_composingText.clear();
+ m_composingFocusObject = nullptr;
+}
+
- (void) unmarkText
{
if (!m_composingText.isEmpty()) {
@@ -1654,6 +1642,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
}
}
m_composingText.clear();
+ m_composingFocusObject = nullptr;
}
- (BOOL) hasMarkedText
diff --git a/src/plugins/platforms/cocoa/qnswindow.h b/src/plugins/platforms/cocoa/qnswindow.h
index ac9cbb978f..1258fddb31 100644
--- a/src/plugins/platforms/cocoa/qnswindow.h
+++ b/src/plugins/platforms/cocoa/qnswindow.h
@@ -58,6 +58,8 @@ QT_FORWARD_DECLARE_CLASS(QCocoaWindow)
- (void)sendEvent:(NSEvent*)theEvent;
- (void)closeAndRelease;
- (void)dealloc;
+- (BOOL)isOpaque;
+- (NSColor *)backgroundColor;
@property (nonatomic, readonly) QCocoaWindow *platformWindow;
@end
diff --git a/src/plugins/platforms/cocoa/qnswindow.mm b/src/plugins/platforms/cocoa/qnswindow.mm
index e5ddd3ca0f..513c7f22b5 100644
--- a/src/plugins/platforms/cocoa/qnswindow.mm
+++ b/src/plugins/platforms/cocoa/qnswindow.mm
@@ -153,6 +153,28 @@ static bool isMouseEvent(NSEvent *ev)
return canBecomeMain;
}
+- (BOOL)isOpaque
+{
+ return self.platformWindow ?
+ self.platformWindow->isOpaque() : qt_objcDynamicSuper();
+}
+
+/*!
+ Borderless windows need a transparent background
+
+ Technically windows with NSTexturedBackgroundWindowMask (such
+ as windows with unified toolbars) need to draw the textured
+ background of the NSWindow, and can't have a transparent
+ background, but as NSBorderlessWindowMask is 0, you can't
+ have a window with NSTexturedBackgroundWindowMask that is
+ also borderless.
+*/
+- (NSColor *)backgroundColor
+{
+ return self.styleMask == NSBorderlessWindowMask
+ ? [NSColor clearColor] : qt_objcDynamicSuper();
+}
+
- (void)sendEvent:(NSEvent*)theEvent
{
// We might get events for a NSWindow after the corresponding platform
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp
index 64d0d9b515..2e84915c80 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp
@@ -63,83 +63,12 @@ private:
QAtomicInt running;
-static Qt::MouseButtons translateMouseButtons(int s)
-{
- Qt::MouseButtons ret = 0;
- if (s & XCB_BUTTON_MASK_1)
- ret |= Qt::LeftButton;
- if (s & XCB_BUTTON_MASK_2)
- ret |= Qt::MidButton;
- if (s & XCB_BUTTON_MASK_3)
- ret |= Qt::RightButton;
- return ret;
-}
-
-static Qt::MouseButton translateMouseButton(xcb_button_t s)
-{
- switch (s) {
- case 1: return Qt::LeftButton;
- case 2: return Qt::MidButton;
- case 3: return Qt::RightButton;
- // Button values 4-7 were already handled as Wheel events, and won't occur here.
- case 8: return Qt::BackButton; // Also known as Qt::ExtraButton1
- case 9: return Qt::ForwardButton; // Also known as Qt::ExtraButton2
- case 10: return Qt::ExtraButton3;
- case 11: return Qt::ExtraButton4;
- case 12: return Qt::ExtraButton5;
- case 13: return Qt::ExtraButton6;
- case 14: return Qt::ExtraButton7;
- case 15: return Qt::ExtraButton8;
- case 16: return Qt::ExtraButton9;
- case 17: return Qt::ExtraButton10;
- case 18: return Qt::ExtraButton11;
- case 19: return Qt::ExtraButton12;
- case 20: return Qt::ExtraButton13;
- case 21: return Qt::ExtraButton14;
- case 22: return Qt::ExtraButton15;
- case 23: return Qt::ExtraButton16;
- case 24: return Qt::ExtraButton17;
- case 25: return Qt::ExtraButton18;
- case 26: return Qt::ExtraButton19;
- case 27: return Qt::ExtraButton20;
- case 28: return Qt::ExtraButton21;
- case 29: return Qt::ExtraButton22;
- case 30: return Qt::ExtraButton23;
- case 31: return Qt::ExtraButton24;
- default: return Qt::NoButton;
- }
-}
-
void EventReader::run()
{
- Qt::MouseButtons buttons;
-
xcb_generic_event_t *event = nullptr;
while (running.load() && (event = xcb_wait_for_event(m_integration->connection()))) {
uint response_type = event->response_type & ~0x80;
switch (response_type) {
- case XCB_BUTTON_PRESS: {
- xcb_button_press_event_t *press = (xcb_button_press_event_t *)event;
- QPoint p(press->event_x, press->event_y);
- buttons = (buttons & ~0x7) | translateMouseButtons(press->state);
- buttons |= translateMouseButton(press->detail);
- QWindowSystemInterface::handleMouseEvent(0, press->time, p, p, buttons);
- break;
- }
- case XCB_BUTTON_RELEASE: {
- xcb_button_release_event_t *release = (xcb_button_release_event_t *)event;
- QPoint p(release->event_x, release->event_y);
- buttons = (buttons & ~0x7) | translateMouseButtons(release->state);
- buttons &= ~translateMouseButton(release->detail);
- QWindowSystemInterface::handleMouseEvent(0, release->time, p, p, buttons);
- break;
- }
- case XCB_MOTION_NOTIFY: {
- xcb_motion_notify_event_t *motion = (xcb_motion_notify_event_t *)event;
- QPoint p(motion->event_x, motion->event_y);
- QWindowSystemInterface::handleMouseEvent(0, motion->time, p, p, buttons);
- break;
- }
case XCB_CLIENT_MESSAGE: {
xcb_client_message_event_t *client = (xcb_client_message_event_t *) event;
const xcb_atom_t *atoms = m_integration->atoms();
diff --git a/src/plugins/platforms/ios/qioseventdispatcher.mm b/src/plugins/platforms/ios/qioseventdispatcher.mm
index f49f81912e..cf7680529a 100644
--- a/src/plugins/platforms/ios/qioseventdispatcher.mm
+++ b/src/plugins/platforms/ios/qioseventdispatcher.mm
@@ -372,7 +372,7 @@ static bool rootLevelRunLoopIntegration()
// We treat applicationWillTerminate as SIGTERM, even if it can't be ignored,
// and follow the bash convention of encoding the signal number in the upper
// four bits of the exit code (exit(3) will only pass on the lower 8 bits).
-static const char kApplicationWillTerminateExitCode = SIGTERM | 0x80;
+static const char kApplicationWillTerminateExitCode = char(SIGTERM | 0x80);
+ (void)applicationWillTerminate
{
diff --git a/src/plugins/platforms/ios/qiosmessagedialog.mm b/src/plugins/platforms/ios/qiosmessagedialog.mm
index 58b2b36b49..9d05b792c2 100644
--- a/src/plugins/platforms/ios/qiosmessagedialog.mm
+++ b/src/plugins/platforms/ios/qiosmessagedialog.mm
@@ -39,7 +39,6 @@
#import <UIKit/UIKit.h>
-#include <QtCore/qoperatingsystemversion.h>
#include <QtGui/qwindow.h>
#include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatformtheme.h>
@@ -109,8 +108,7 @@ bool QIOSMessageDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality win
Q_UNUSED(windowFlags);
if (m_alertController // Ensure that the dialog is not showing already
|| !options() // Some message dialogs don't have options (QErrorMessage)
- || windowModality == Qt::NonModal // We can only do modal dialogs
- || QOperatingSystemVersion::current() < QOperatingSystemVersion(QOperatingSystemVersion::IOS, 8)) // API limitation
+ || windowModality == Qt::NonModal) // We can only do modal dialogs
return false;
m_alertController = [[UIAlertController
diff --git a/src/plugins/platforms/ios/qiosscreen.mm b/src/plugins/platforms/ios/qiosscreen.mm
index 3514bf63bb..e8854a4c4b 100644
--- a/src/plugins/platforms/ios/qiosscreen.mm
+++ b/src/plugins/platforms/ios/qiosscreen.mm
@@ -45,7 +45,6 @@
#include "qiosapplicationdelegate.h"
#include "qiosviewcontroller.h"
#include "quiview.h"
-#include <QtCore/qoperatingsystemversion.h>
#include <QtGui/private/qwindow_p.h>
#include <private/qcoregraphics_p.h>
@@ -275,14 +274,6 @@ void QIOSScreen::updateProperties()
if (m_uiScreen == [UIScreen mainScreen]) {
Qt::ScreenOrientation statusBarOrientation = toQtScreenOrientation(UIDeviceOrientation([UIApplication sharedApplication].statusBarOrientation));
- if (QOperatingSystemVersion::current() < QOperatingSystemVersion(QOperatingSystemVersion::IOS, 8)) {
- // On iOS < 8.0 the UIScreen geometry is always in portait, and the system applies
- // the screen rotation to the root view-controller's view instead of directly to the
- // screen, like iOS 8 and above does.
- m_geometry = mapBetween(Qt::PortraitOrientation, statusBarOrientation, m_geometry);
- m_availableGeometry = transformBetween(Qt::PortraitOrientation, statusBarOrientation, m_geometry).mapRect(m_availableGeometry);
- }
-
QIOSViewController *qtViewController = [m_uiWindow.rootViewController isKindOfClass:[QIOSViewController class]] ?
static_cast<QIOSViewController *>(m_uiWindow.rootViewController) : nil;
@@ -302,20 +293,15 @@ void QIOSScreen::updateProperties()
#endif
if (m_geometry != previousGeometry) {
- QRectF physicalGeometry;
- if (QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::IOS, 8)) {
- // We can't use the primaryOrientation of screen(), as we haven't reported the new geometry yet
- Qt::ScreenOrientation primaryOrientation = m_geometry.width() >= m_geometry.height() ?
- Qt::LandscapeOrientation : Qt::PortraitOrientation;
-
- // On iPhone 6+ devices, or when display zoom is enabled, the render buffer is scaled
- // 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, QRectF::fromCGRect(m_uiScreen.nativeBounds).toRect());
- } else {
- physicalGeometry = QRectF(0, 0, m_geometry.width() * devicePixelRatio(), m_geometry.height() * devicePixelRatio());
- }
+ // We can't use the primaryOrientation of screen(), as we haven't reported the new geometry yet
+ Qt::ScreenOrientation primaryOrientation = m_geometry.width() >= m_geometry.height() ?
+ Qt::LandscapeOrientation : Qt::PortraitOrientation;
+
+ // On iPhone 6+ devices, or when display zoom is enabled, the render buffer is scaled
+ // 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.
+ const QRectF physicalGeometry = mapBetween(nativeOrientation(), primaryOrientation, QRectF::fromCGRect(m_uiScreen.nativeBounds).toRect());
static const qreal millimetersPerInch = 25.4;
m_physicalSize = physicalGeometry.size() / m_physicalDpi * millimetersPerInch;
diff --git a/src/plugins/platforms/ios/qiostextinputoverlay.mm b/src/plugins/platforms/ios/qiostextinputoverlay.mm
index 034c1bba08..fe3c29d037 100644
--- a/src/plugins/platforms/ios/qiostextinputoverlay.mm
+++ b/src/plugins/platforms/ios/qiostextinputoverlay.mm
@@ -229,12 +229,6 @@ static void executeBlockWithoutAnimation(Block block)
borderLayer.cornerRadius = cornerRadius;
borderLayer.borderColor = [[UIColor lightGrayColor] CGColor];
[self addSublayer:borderLayer];
-
- if (QOperatingSystemVersion::current() < QOperatingSystemVersion(QOperatingSystemVersion::IOS, 7)) {
- // [UIView snapshotViewAfterScreenUpdates:] is available since iOS 7.0.
- // Just silently ignore showing the loupe for older versions.
- self.hidden = YES;
- }
}
return self;
@@ -278,9 +272,6 @@ static void executeBlockWithoutAnimation(Block block)
- (void)display
{
- if (QOperatingSystemVersion::current() < QOperatingSystemVersion(QOperatingSystemVersion::IOS, 7))
- return;
-
// Take a snapshow of the target view, magnify the area around the focal
// point, and add the snapshow layer as a child of the container layer
// to make it look like a loupe. Then place this layer at the position of
diff --git a/src/plugins/platforms/vnc/qvncintegration.cpp b/src/plugins/platforms/vnc/qvncintegration.cpp
index 8516e994f5..1e2cf6292c 100644
--- a/src/plugins/platforms/vnc/qvncintegration.cpp
+++ b/src/plugins/platforms/vnc/qvncintegration.cpp
@@ -52,9 +52,6 @@
#include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatforminputcontextfactory_p.h>
#include <private/qinputdevicemanager_p_p.h>
-#if QT_CONFIG(libinput)
-#include <QtInputSupport/private/qlibinputhandler_p.h>
-#endif
#include <QtCore/QRegularExpression>
diff --git a/src/plugins/platforms/windows/openglblacklists/default.json b/src/plugins/platforms/windows/openglblacklists/default.json
index 69f4a54d05..d1e9f85247 100644
--- a/src/plugins/platforms/windows/openglblacklists/default.json
+++ b/src/plugins/platforms/windows/openglblacklists/default.json
@@ -126,6 +126,21 @@
"features": [
"disable_desktopgl"
]
- }
+ },
+ {
+ "id": 11,
+ "description": "Intel driver version 8.15.10.1749 causes GPU process hangs (QTBUG-56360)",
+ "vendor_id": "0x8086",
+ "os": {
+ "type": "win"
+ },
+ "driver_version": {
+ "op": "=",
+ "value": "8.15.10.1749"
+ },
+ "features": [
+ "disable_desktopgl", "disable_d3d11", "disable_d3d9"
+ ]
+ }
]
}
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index 2848bb4a4e..45d6b50162 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -65,6 +65,7 @@
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatformnativeinterface.h>
#include <QtGui/QGuiApplication>
+#include <QtGui/QOpenGLContext>
#include <QtCore/QSet>
#include <QtCore/QHash>
@@ -867,6 +868,18 @@ static inline bool resizeOnDpiChanged(const QWindow *w)
return result;
}
+static bool shouldHaveNonClientDpiScaling(const QWindow *window)
+{
+ return QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS10
+ && window->isTopLevel()
+ && !window->property(QWindowsWindow::embeddedNativeParentHandleProperty).isValid()
+#if QT_CONFIG(opengl) // /QTBUG-62901, EnableNonClientDpiScaling has problems with GL
+ && (window->surfaceType() != QSurface::OpenGLSurface
+ || QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGL)
+#endif
+ ;
+}
+
/*!
\brief Main windows procedure registered for windows.
@@ -988,10 +1001,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
d->m_creationContext->obtainedGeometry.moveTo(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
return true;
case QtWindows::NonClientCreate:
- if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS10 && d->m_creationContext->window->isTopLevel()
- && !d->m_creationContext->window->property(QWindowsWindow::embeddedNativeParentHandleProperty).isValid()) {
+ if (shouldHaveNonClientDpiScaling(d->m_creationContext->window))
enableNonClientDpiScaling(msg.hwnd);
- }
return false;
case QtWindows::CalculateSize:
return QWindowsGeometryHint::handleCalculateSize(d->m_creationContext->customMargins, msg, result);
diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp
index 857db7a65c..aa6454ef63 100644
--- a/src/plugins/platforms/windows/qwindowsdrag.cpp
+++ b/src/plugins/platforms/windows/qwindowsdrag.cpp
@@ -44,7 +44,7 @@
# include "qwindowsclipboard.h"
#endif
#include "qwindowsintegration.h"
-#include "qwindowsole.h"
+#include "qwindowsdropdataobject.h"
#include <QtCore/qt_windows.h>
#include "qwindowswindow.h"
#include "qwindowsmousehandler.h"
@@ -673,7 +673,7 @@ Qt::DropAction QWindowsDrag::drag(QDrag *drag)
QWindowsDrag::m_canceled = false;
QWindowsOleDropSource *windowDropSource = new QWindowsOleDropSource(this);
windowDropSource->createCursors();
- QWindowsOleDataObject *dropDataObject = new QWindowsOleDataObject(dropData);
+ QWindowsDropDataObject *dropDataObject = new QWindowsDropDataObject(dropData);
const Qt::DropActions possibleActions = drag->supportedActions();
const DWORD allowedEffects = translateToWinDragEffects(possibleActions);
qCDebug(lcQpaMime) << '>' << __FUNCTION__ << "possible Actions=0x"
diff --git a/src/plugins/platforms/windows/qwindowsdropdataobject.cpp b/src/plugins/platforms/windows/qwindowsdropdataobject.cpp
new file mode 100644
index 0000000000..bd532ab70e
--- /dev/null
+++ b/src/plugins/platforms/windows/qwindowsdropdataobject.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2017 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 "qwindowsdropdataobject.h"
+
+#include <QtCore/QUrl>
+#include <QtCore/QMimeData>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QWindowsDropDataObject
+ \brief QWindowsOleDataObject subclass specialized for handling Drag&Drop.
+
+ Only allows "text/uri-list" data to be exported as CF_HDROP, to allow dropped
+ files to be attached to Office applications (instead of adding an URL link).
+
+ \internal
+ \ingroup qt-lighthouse-win
+*/
+
+QWindowsDropDataObject::QWindowsDropDataObject(QMimeData *mimeData) :
+ QWindowsOleDataObject(mimeData)
+{
+}
+
+QWindowsDropDataObject::~QWindowsDropDataObject()
+{
+}
+
+STDMETHODIMP
+QWindowsDropDataObject::GetData(LPFORMATETC pformatetc, LPSTGMEDIUM pmedium)
+{
+ if (shouldIgnore(pformatetc))
+ return ResultFromScode(DATA_E_FORMATETC);
+
+ return QWindowsOleDataObject::GetData(pformatetc, pmedium);
+}
+
+STDMETHODIMP
+QWindowsDropDataObject::QueryGetData(LPFORMATETC pformatetc)
+{
+ if (shouldIgnore(pformatetc))
+ return ResultFromScode(DATA_E_FORMATETC);
+
+ return QWindowsOleDataObject::QueryGetData(pformatetc);
+}
+
+// If the data is text/uri-list for local files, tell we can only export it as CF_HDROP.
+bool QWindowsDropDataObject::shouldIgnore(LPFORMATETC pformatetc) const
+{
+ QMimeData *dropData = mimeData();
+
+ if (dropData && dropData->hasFormat(QStringLiteral("text/uri-list")) && (pformatetc->cfFormat != CF_HDROP)) {
+ QList<QUrl> urls = dropData->urls();
+ return std::any_of(urls.cbegin(), urls.cend(), [] (const QUrl &u) { return u.isLocalFile(); });
+ }
+
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/platformsupport/cglconvenience/cglconvenience_p.h b/src/plugins/platforms/windows/qwindowsdropdataobject.h
index e531e73549..5ef72c9336 100644
--- a/src/platformsupport/cglconvenience/cglconvenience_p.h
+++ b/src/plugins/platforms/windows/qwindowsdropdataobject.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
@@ -37,25 +37,27 @@
**
****************************************************************************/
-#ifndef QMACGLCONVENIENCE_H
-#define QMACGLCONVENIENCE_H
+#ifndef QWINDOWSDROPDATAOBJECT_H
+#define QWINDOWSDROPDATAOBJECT_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 "qwindowsole.h"
-#include <QSurfaceFormat>
-#include <QString>
-#include <OpenGL/OpenGL.h>
+QT_BEGIN_NAMESPACE
-QSurfaceFormat qcgl_surfaceFormat();
-void *qcgl_createNSOpenGLPixelFormat(const QSurfaceFormat &format);
+class QWindowsDropDataObject : public QWindowsOleDataObject
+{
+public:
+ explicit QWindowsDropDataObject(QMimeData *mimeData);
+ virtual ~QWindowsDropDataObject();
-#endif // QMACGLCONVENIENCE_H
+ // overridden IDataObject methods
+ STDMETHOD(GetData)(LPFORMATETC pformatetcIn, LPSTGMEDIUM pmedium);
+ STDMETHOD(QueryGetData)(LPFORMATETC pformatetc);
+
+private:
+ bool shouldIgnore(LPFORMATETC pformatetc) const;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWINDOWSDROPDATAOBJECT_H
diff --git a/src/plugins/platforms/windows/windows.pri b/src/plugins/platforms/windows/windows.pri
index 3ecd164c74..b7790a66e3 100644
--- a/src/plugins/platforms/windows/windows.pri
+++ b/src/plugins/platforms/windows/windows.pri
@@ -19,6 +19,7 @@ SOURCES += \
$$PWD/qwindowskeymapper.cpp \
$$PWD/qwindowsmousehandler.cpp \
$$PWD/qwindowsole.cpp \
+ $$PWD/qwindowsdropdataobject.cpp \
$$PWD/qwindowsmime.cpp \
$$PWD/qwindowsinternalmimedata.cpp \
$$PWD/qwindowscursor.cpp \
@@ -41,6 +42,7 @@ HEADERS += \
$$PWD/qwindowsmousehandler.h \
$$PWD/qtwindowsglobal.h \
$$PWD/qwindowsole.h \
+ $$PWD/qwindowsdropdataobject.h \
$$PWD/qwindowsmime.h \
$$PWD/qwindowsinternalmimedata.h \
$$PWD/qwindowscursor.h \
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm
index 16762cf6d6..05585ba07c 100644
--- a/src/plugins/styles/mac/qmacstyle_mac.mm
+++ b/src/plugins/styles/mac/qmacstyle_mac.mm
@@ -74,10 +74,18 @@
#include <qgroupbox.h>
#include <qhash.h>
#include <qheaderview.h>
+#if QT_CONFIG(lineedit)
#include <qlineedit.h>
+#endif
+#if QT_CONFIG(mainwindow)
#include <qmainwindow.h>
+#endif
+#if QT_CONFIG(mdiarea)
#include <qmdisubwindow.h>
+#endif
+#if QT_CONFIG(menubar)
#include <qmenubar.h>
+#endif
#include <qpaintdevice.h>
#include <qpainter.h>
#include <qpixmapcache.h>
@@ -95,7 +103,9 @@
#if QT_CONFIG(scrollbar)
#include <qscrollbar.h>
#endif
+#if QT_CONFIG(sizegrip)
#include <qsizegrip.h>
+#endif
#include <qstyleoption.h>
#include <qtoolbar.h>
#if QT_CONFIG(toolbutton)
@@ -327,6 +337,40 @@ static bool setupScroller(NSScroller *scroller, const QStyleOptionSlider *sb)
return true;
}
+static bool setupSlider(NSSlider *slider, const QStyleOptionSlider *sl)
+{
+ if (sl->minimum >= sl->maximum)
+ return false;
+
+ slider.frame = sl->rect.toCGRect();
+ slider.minValue = sl->minimum;
+ slider.maxValue = sl->maximum;
+ slider.intValue = sl->sliderPosition;
+ slider.enabled = sl->state & QStyle::State_Enabled;
+ if (sl->tickPosition != QSlider::NoTicks) {
+ // Set numberOfTickMarks, but TicksBothSides will be treated differently
+ int interval = sl->tickInterval;
+ if (interval == 0) {
+ interval = sl->pageStep;
+ if (interval == 0)
+ interval = sl->singleStep;
+ if (interval == 0)
+ interval = 1; // return false?
+ }
+ slider.numberOfTickMarks = 1 + ((sl->maximum - sl->minimum) / interval);
+
+ const bool ticksAbove = sl->tickPosition == QSlider::TicksAbove;
+ if (sl->orientation == Qt::Horizontal)
+ slider.tickMarkPosition = ticksAbove ? NSTickMarkAbove : NSTickMarkBelow;
+ else
+ slider.tickMarkPosition = ticksAbove ? NSTickMarkLeft : NSTickMarkRight;
+ } else {
+ slider.numberOfTickMarks = 0;
+ }
+
+ return true;
+}
+
static bool isInMacUnifiedToolbarArea(QWindow *window, int windowY)
{
QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
@@ -656,7 +700,6 @@ const int macItemFrame = 2; // menu item frame width
const int macItemHMargin = 3; // menu item hor text margin
const int macRightBorder = 12; // right border on mac
const ThemeWindowType QtWinType = kThemeDocumentWindow; // Window type we use for QTitleBar.
-QPixmap *qt_mac_backgroundPattern = 0; // stores the standard widget background.
/*****************************************************************************
QMacCGStyle utility functions
@@ -799,17 +842,17 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
else if (qobject_cast<const QProgressBar *>(widg))
ct = QStyle::CT_ProgressBar;
#endif
-#ifndef QT_NO_LINEEDIT
+#if QT_CONFIG(lineedit)
else if (qobject_cast<const QLineEdit *>(widg))
ct = QStyle::CT_LineEdit;
#endif
else if (qobject_cast<const QHeaderView *>(widg))
ct = QStyle::CT_HeaderSection;
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
else if (qobject_cast<const QMenuBar *>(widg))
ct = QStyle::CT_MenuBar;
#endif
-#ifndef QT_NO_SIZEGRIP
+#if QT_CONFIG(sizegrip)
else if (qobject_cast<const QSizeGrip *>(widg))
ct = QStyle::CT_SizeGrip;
#endif
@@ -897,7 +940,7 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
gbi.size = sz == QStyleHelper::SizeSmall ? kHIThemeGrowBoxSizeSmall : kHIThemeGrowBoxSizeNormal;
if (HIThemeGetGrowBoxBounds(&p, &gbi, &r) == noErr) {
int width = 0;
-#ifndef QT_NO_MDIAREA
+#if QT_CONFIG(mdiarea)
if (widg && qobject_cast<QMdiSubWindow *>(widg->parentWidget()))
width = r.size.width;
#endif
@@ -1085,7 +1128,7 @@ static QStyleHelper::WidgetSizePolicy qt_aqua_guess_size(const QWidget *widg, QS
return QStyleHelper::SizeLarge;
}
-#ifndef QT_NO_MAINWINDOW
+#if QT_CONFIG(mainwindow)
if (qEnvironmentVariableIsSet("QWIDGET_ALL_SMALL")) {
//if (small.width() != -1 || small.height() != -1)
return QStyleHelper::SizeSmall;
@@ -1732,7 +1775,7 @@ void QMacStylePrivate::drawCombobox(const CGRect &outerBounds, const HIThemeButt
void QMacStylePrivate::drawTableHeader(const CGRect &outerBounds,
bool drawTopBorder, bool drawLeftBorder, const HIThemeButtonDrawInfo &bdi, QPainter *p)
{
- static SInt32 headerHeight = qt_mac_aqua_get_metric(ListHeaderHeight);
+ static int headerHeight = qt_mac_aqua_get_metric(ListHeaderHeight);
QPixmap buffer;
QString key = QString(QLatin1String("$qt_tableh%1-%2-%3")).arg(int(bdi.state)).arg(int(bdi.adornment)).arg(int(bdi.value));
@@ -1788,69 +1831,6 @@ void QMacStylePrivate::drawTableHeader(const CGRect &outerBounds,
p->translate(-outerBounds.origin.x, -outerBounds.origin.y);
}
-void QMacStylePrivate::getSliderInfo(QStyle::ComplexControl cc, const QStyleOptionSlider *slider,
- HIThemeTrackDrawInfo *tdi, const QWidget *needToRemoveMe) const
-{
- Q_UNUSED(cc);
- memset(tdi, 0, sizeof(HIThemeTrackDrawInfo)); // We don't get it all for some reason or another...
- tdi->version = qt_mac_hitheme_version;
- tdi->reserved = 0;
- tdi->filler1 = 0;
- switch (aquaSizeConstrain(slider, needToRemoveMe)) {
- case QStyleHelper::SizeDefault:
- case QStyleHelper::SizeLarge:
- tdi->kind = kThemeMediumSlider;
- break;
- case QStyleHelper::SizeMini:
- tdi->kind = kThemeMiniSlider;
- break;
- case QStyleHelper::SizeSmall:
- tdi->kind = kThemeSmallSlider;
- break;
- }
-
- bool usePlainKnob = slider->tickPosition == QSlider::NoTicks
- || slider->tickPosition == QSlider::TicksBothSides;
-
- tdi->bounds = slider->rect.toCGRect();
- // Fix min and max positions. HITheme seems confused when it comes to rendering
- // a slider at those positions. We give it a hand by extending and offsetting
- // the slider range accordingly. See also comment for CC_Slider in drawComplexControl()
- tdi->min = 0;
- if (slider->orientation == Qt::Horizontal)
- tdi->max = 10 * slider->rect.width();
- else
- tdi->max = 10 * slider->rect.height();
-
- int range = slider->maximum - slider->minimum;
- if (range == 0) {
- tdi->value = 0;
- } else if (usePlainKnob || slider->orientation == Qt::Horizontal) {
- int endsCorrection = usePlainKnob ? 25 : 10;
- tdi->value = (tdi->max + 2 * endsCorrection) * (slider->sliderPosition - slider->minimum) / range - endsCorrection;
- } else {
- tdi->value = (tdi->max + 30) * (slider->sliderPosition - slider->minimum) / range - 20;
- }
-
- tdi->attributes = kThemeTrackShowThumb;
- if (slider->upsideDown)
- tdi->attributes |= kThemeTrackRightToLeft;
- if (slider->orientation == Qt::Horizontal) {
- tdi->attributes |= kThemeTrackHorizontal;
- }
-
- tdi->enableState = (slider->state & QStyle::State_Enabled) ? kThemeTrackActive
- : kThemeTrackDisabled;
- if (slider->state & QStyle::QStyle::State_HasFocus)
- tdi->attributes |= kThemeTrackHasFocus;
- if (usePlainKnob)
- tdi->trackInfo.slider.thumbDir = kThemeThumbPlain;
- else if (slider->tickPosition == QSlider::TicksAbove)
- tdi->trackInfo.slider.thumbDir = kThemeThumbUpward;
- else
- tdi->trackInfo.slider.thumbDir = kThemeThumbDownward;
-}
-
QMacStylePrivate::QMacStylePrivate()
: backingStoreNSView(nil)
{
@@ -1963,11 +1943,11 @@ NSView *QMacStylePrivate::cocoaControl(QCocoaWidget widget) const
// at construction time, and it cannot be changed later.
bv = [[NSScroller alloc] initWithFrame:NSMakeRect(0, 0, 20, 200)];
else if (widget.first == QCocoaHorizontalSlider)
- bv = [[NSSlider alloc] init];
+ bv = [[NSSlider alloc] initWithFrame:NSMakeRect(0, 0, 200, 20)];
else if (widget.first == QCocoaVerticalSlider)
// Cocoa sets the orientation from the view's frame
// at construction time, and it cannot be changed later.
- bv = [[NSSlider alloc] initWithFrame:NSMakeRect(0, 0, 10, 100)];
+ bv = [[NSSlider alloc] initWithFrame:NSMakeRect(0, 0, 20, 200)];
else
bv = [[NSButton alloc] init];
@@ -2289,79 +2269,10 @@ QMacStyle::~QMacStyle()
[[NSNotificationCenter defaultCenter] removeObserver:d->receiver];
[d->receiver release];
-
- delete qt_mac_backgroundPattern;
- qt_mac_backgroundPattern = 0;
}
-/*! \internal
- Generates the standard widget background pattern.
-*/
-QPixmap QMacStylePrivate::generateBackgroundPattern() const
+void QMacStyle::polish(QPalette &)
{
- QMacAutoReleasePool pool;
- QPixmap px(4, 4);
- QMacCGContext cg(&px);
- HIThemeSetFill(kThemeBrushDialogBackgroundActive, 0, cg, kHIThemeOrientationNormal);
- const CGRect cgRect = CGRectMake(0, 0, px.width(), px.height());
- CGContextFillRect(cg, cgRect);
- return px;
-}
-
-/*! \internal
- Fills the given \a rect with the pattern stored in \a brush. As an optimization,
- HIThemeSetFill us used directly if we are filling with the standard background.
-*/
-void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush)
-{
-#if 0
- QPoint dummy;
- const QPaintDevice *target = painter->device();
- const QPaintDevice *redirected = QPainter::redirected(target, &dummy);
- //const bool usePainter = redirected && redirected != target;
-
- if (!usePainter && qt_mac_backgroundPattern
- && qt_mac_backgroundPattern->cacheKey() == brush.texture().cacheKey()) {
-
- painter->setClipRegion(rgn);
-
- QMacCGContext cg(target);
- CGContextSaveGState(cg);
- HIThemeSetFill(kThemeBrushDialogBackgroundActive, 0, cg, kHIThemeOrientationInverted);
-
- 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());
- CGContextFillRect(cg, mac_rect);
- }
-
- CGContextRestoreGState(cg);
- } else {
-#endif
- const QRect rect(rgn.boundingRect());
- painter->setClipRegion(rgn);
- painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft());
-// }
-}
-
-void QMacStyle::polish(QPalette &pal)
-{
- Q_D(QMacStyle);
- if (!qt_mac_backgroundPattern) {
- if (!qApp)
- return;
- qt_mac_backgroundPattern = new QPixmap(d->generateBackgroundPattern());
- }
-
-
- QCFString theme;
- const OSErr err = CopyThemeIdentifier(&theme);
- if (err == noErr && CFStringCompare(theme, kThemeAppearanceAquaGraphite, 0) == kCFCompareEqualTo) {
- pal.setBrush(QPalette::All, QPalette::AlternateBase, QColor(240, 240, 240));
- } else {
- pal.setBrush(QPalette::All, QPalette::AlternateBase, QColor(237, 243, 254));
- }
}
void QMacStyle::polish(QApplication *)
@@ -2374,7 +2285,7 @@ void QMacStyle::unpolish(QApplication *)
void QMacStyle::polish(QWidget* w)
{
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
if (qobject_cast<QMenu*>(w)
#if QT_CONFIG(combobox)
|| qobject_cast<QComboBoxPrivateContainer *>(w)
@@ -2433,7 +2344,7 @@ void QMacStyle::polish(QWidget* w)
void QMacStyle::unpolish(QWidget* w)
{
if (
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
qobject_cast<QMenu*>(w) &&
#endif
!w->testAttribute(Qt::WA_SetPalette)) {
@@ -2483,7 +2394,7 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
{
Q_D(const QMacStyle);
const int controlSize = getControlSize(opt, widget);
- SInt32 ret = 0;
+ int ret = 0;
switch (metric) {
case PM_TabCloseIndicatorWidth:
@@ -2541,7 +2452,7 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
ret = 15; // I hate having magic numbers in here...
break;
case PM_DefaultFrameWidth:
-#ifndef QT_NO_MAINWINDOW
+#if QT_CONFIG(mainwindow)
if (widget && (widget->isWindow() || !widget->parentWidget()
|| (qobject_cast<const QMainWindow*>(widget->parentWidget())
&& static_cast<QMainWindow *>(widget->parentWidget())->centralWidget() == widget))
@@ -2679,7 +2590,7 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
break;
case PM_ScrollBarExtent: {
const QStyleHelper::WidgetSizePolicy size = d->effectiveAquaSizeConstrain(opt, widget);
- ret = static_cast<SInt32>([NSScroller
+ ret = static_cast<int>([NSScroller
scrollerWidthForControlSize:static_cast<NSControlSize>(size)
scrollerStyle:[NSScroller preferredScrollerStyle]]);
break; }
@@ -2861,7 +2772,7 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w
{
QMacAutoReleasePool pool;
- SInt32 ret = 0;
+ int ret = 0;
switch (sh) {
case SH_Slider_SnapToValue:
case SH_PrintDialog_RightAlignButtons:
@@ -3154,7 +3065,7 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w
opt->rect.width(), opt->rect.height() - 8);
HIThemeMenuDrawInfo mdi;
mdi.version = 0;
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
if (w && qobject_cast<QMenu *>(w->parentWidget()))
mdi.menuType = kThemeMenuTypeHierarchical;
else
@@ -3570,7 +3481,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
HIThemeFrameDrawInfo fdi;
fdi.version = qt_mac_hitheme_version;
fdi.state = tds;
- SInt32 frame_size;
+ int frame_size;
fdi.kind = frame->features & QStyleOptionFrame::Rounded ? kHIThemeFrameTextFieldRound :
kHIThemeFrameTextFieldSquare;
frame_size = qt_mac_aqua_get_metric(EditTextFrameOutset);
@@ -3605,7 +3516,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
// Draw the focus frame for widgets other than QLineEdit (e.g. for line edits in Webkit).
// Focus frame is drawn outside the rectangle passed in the option-rect.
if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
-#ifndef QT_NO_LINEEDIT
+#if QT_CONFIG(lineedit)
if ((opt->state & State_HasFocus) && !qobject_cast<const QLineEdit*>(w)) {
int vmargin = pixelMetric(QStyle::PM_FocusFrameVMargin);
int hmargin = pixelMetric(QStyle::PM_FocusFrameHMargin);
@@ -4683,7 +4594,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
// the title bar. The following code fills the toolBar area with transparent pixels
// to make that gradient visible.
if (w) {
-#ifndef QT_NO_MAINWINDOW
+#if QT_CONFIG(mainwindow)
if (QMainWindow * mainWindow = qobject_cast<QMainWindow *>(w->window())) {
if (toolBar && toolBar->toolBarArea == Qt::TopToolBarArea && mainWindow->unifiedTitleAndToolBarOnMac()) {
@@ -4700,7 +4611,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
QPoint windowToolbarEnd = w->mapTo(w->window(), opt->rect.bottomLeft());
bool isEndOfUnifiedArea = !isInMacUnifiedToolbarArea(w->window()->windowHandle(), windowToolbarEnd.y() + 1);
if (isEndOfUnifiedArea) {
- SInt32 margin;
+ int margin;
margin = qt_mac_aqua_get_metric(SeparatorSize);
CGRect separatorRect = CGRectMake(opt->rect.left(), opt->rect.bottom(), opt->rect.width(), margin);
HIThemeSeparatorDrawInfo separatorDrawInfo;
@@ -5271,6 +5182,11 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
case CC_ScrollBar:
if (const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
+ const bool drawTrack = sb->subControls & SC_ScrollBarGroove;
+ const bool drawKnob = sb->subControls & SC_ScrollBarSlider;
+ if (!drawTrack && !drawKnob)
+ break;
+
const bool isHorizontal = sb->orientation == Qt::Horizontal;
if (opt && opt->styleObject && !QMacStylePrivate::scrollBars.contains(opt->styleObject))
@@ -5390,49 +5306,53 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
CGContextSetAlpha(cg, opacity);
}
- // Draw the track when hovering. Expand by shifting the track rect.
- if (!isTransient || opt->activeSubControls || wasActive) {
- CGRect trackRect = scroller.bounds;
- if (isHorizontal)
- trackRect.origin.y += expandOffset;
- else
- trackRect.origin.x += expandOffset;
- [scroller drawKnobSlotInRect:trackRect highlight:NO];
+ if (drawTrack) {
+ // Draw the track when hovering. Expand by shifting the track rect.
+ if (!isTransient || opt->activeSubControls || wasActive) {
+ CGRect trackRect = scroller.bounds;
+ if (isHorizontal)
+ trackRect.origin.y += expandOffset;
+ else
+ trackRect.origin.x += expandOffset;
+ [scroller drawKnobSlotInRect:trackRect highlight:NO];
+ }
}
- if (shouldExpand) {
- // -[NSScroller drawKnob] is not useful here because any scaling applied
- // will only be used to draw the hi-DPI artwork. And even if did scale,
- // the stretched knob would look wrong, actually. So we need to draw the
- // scroller manually when it's being hovered.
- const CGFloat scrollerWidth = [NSScroller scrollerWidthForControlSize:scroller.controlSize scrollerStyle:scroller.scrollerStyle];
- const CGFloat knobWidth = knobWidths[cocoaSize] * expandScale;
- // Cocoa can help get the exact knob length in the current orientation
- const CGRect scrollerKnobRect = CGRectInset([scroller rectForPart:NSScrollerKnob], 1, 1);
- const CGFloat knobLength = isHorizontal ? scrollerKnobRect.size.width : scrollerKnobRect.size.height;
- const CGFloat knobPos = isHorizontal ? scrollerKnobRect.origin.x : scrollerKnobRect.origin.y;
- const CGFloat knobOffset = qRound((scrollerWidth + expandOffset - knobWidth) / 2.0);
- const CGFloat knobRadius = knobWidth / 2.0;
- CGRect knobRect;
- if (isHorizontal)
- knobRect = CGRectMake(knobPos, knobOffset, knobLength, knobWidth);
- else
- knobRect = CGRectMake(knobOffset, knobPos, knobWidth, knobLength);
- QCFType<CGPathRef> knobPath = CGPathCreateWithRoundedRect(knobRect, knobRadius, knobRadius, nullptr);
- CGContextAddPath(cg, knobPath);
- CGContextSetAlpha(cg, 0.5);
- CGContextSetFillColorWithColor(cg, NSColor.blackColor.CGColor);
- CGContextFillPath(cg);
- } else {
- [scroller drawKnob];
-
- if (!isTransient && opt->activeSubControls) {
- // The knob should appear darker (going from 0.76 down to 0.49).
- // But no blending mode can help darken enough in a single pass,
- // so we resort to drawing the knob twice with a small help from
- // blending. This brings the gray level to a close enough 0.53.
- CGContextSetBlendMode(cg, kCGBlendModePlusDarker);
+ if (drawKnob) {
+ if (shouldExpand) {
+ // -[NSScroller drawKnob] is not useful here because any scaling applied
+ // will only be used to draw the hi-DPI artwork. And even if did scale,
+ // the stretched knob would look wrong, actually. So we need to draw the
+ // scroller manually when it's being hovered.
+ const CGFloat scrollerWidth = [NSScroller scrollerWidthForControlSize:scroller.controlSize scrollerStyle:scroller.scrollerStyle];
+ const CGFloat knobWidth = knobWidths[cocoaSize] * expandScale;
+ // Cocoa can help get the exact knob length in the current orientation
+ const CGRect scrollerKnobRect = CGRectInset([scroller rectForPart:NSScrollerKnob], 1, 1);
+ const CGFloat knobLength = isHorizontal ? scrollerKnobRect.size.width : scrollerKnobRect.size.height;
+ const CGFloat knobPos = isHorizontal ? scrollerKnobRect.origin.x : scrollerKnobRect.origin.y;
+ const CGFloat knobOffset = qRound((scrollerWidth + expandOffset - knobWidth) / 2.0);
+ const CGFloat knobRadius = knobWidth / 2.0;
+ CGRect knobRect;
+ if (isHorizontal)
+ knobRect = CGRectMake(knobPos, knobOffset, knobLength, knobWidth);
+ else
+ knobRect = CGRectMake(knobOffset, knobPos, knobWidth, knobLength);
+ QCFType<CGPathRef> knobPath = CGPathCreateWithRoundedRect(knobRect, knobRadius, knobRadius, nullptr);
+ CGContextAddPath(cg, knobPath);
+ CGContextSetAlpha(cg, 0.5);
+ CGContextSetFillColorWithColor(cg, NSColor.blackColor.CGColor);
+ CGContextFillPath(cg);
+ } else {
[scroller drawKnob];
+
+ if (!isTransient && opt->activeSubControls) {
+ // The knob should appear darker (going from 0.76 down to 0.49).
+ // But no blending mode can help darken enough in a single pass,
+ // so we resort to drawing the knob twice with a small help from
+ // blending. This brings the gray level to a close enough 0.53.
+ CGContextSetBlendMode(cg, kCGBlendModePlusDarker);
+ [scroller drawKnob];
+ }
}
}
@@ -5443,152 +5363,124 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
}
break;
case CC_Slider:
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
- const bool isHorizontal = slider->orientation == Qt::Horizontal;
+ if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
+ const bool isHorizontal = sl->orientation == Qt::Horizontal;
+ const auto cs = d->effectiveAquaSizeConstrain(opt, widget);
+ const auto cw = QCocoaWidget(isHorizontal ? QCocoaHorizontalSlider : QCocoaVerticalSlider, cs);
+ auto *slider = static_cast<NSSlider *>(d->cocoaControl(cw));
+ if (!setupSlider(slider, sl))
+ break;
+ const bool hasTicks = sl->tickPosition != QSlider::NoTicks;
+ const bool hasDoubleTicks = sl->tickPosition == QSlider::TicksBothSides;
+ const bool drawKnob = sl->subControls & SC_SliderHandle;
+ const bool drawBar = sl->subControls & SC_SliderGroove;
+ const bool drawTicks = sl->subControls & SC_SliderTickmarks;
+ const bool isPressed = sl->state & State_Sunken;
+
+ CGPoint pressPoint;
+ if (isPressed) {
+ const CGRect knobRect = [slider.cell knobRectFlipped:NO];
+ pressPoint.x = CGRectGetMidX(knobRect);
+ pressPoint.y = CGRectGetMidY(knobRect);
+ [slider.cell startTrackingAt:pressPoint inView:slider];
+ }
- HIThemeTrackDrawInfo tdi;
- d->getSliderInfo(cc, slider, &tdi, widget);
- if (slider->state & State_Sunken) {
- if (cc == CC_Slider) {
- if (slider->activeSubControls == SC_SliderHandle)
- tdi.trackInfo.slider.pressState = kThemeThumbPressed;
- else if (slider->activeSubControls == SC_SliderGroove)
- tdi.trackInfo.slider.pressState = kThemeLeftTrackPressed;
+ d->drawNSViewInRect(cw, slider, opt->rect, p, widget != 0, ^(CGContextRef ctx, const CGRect &rect) {
+ if (isHorizontal && sl->upsideDown) {
+ CGContextTranslateCTM(ctx, rect.size.width, 0);
+ CGContextScaleCTM(ctx, -1, 1);
}
- }
- CGRect macRect;
- bool tracking = slider->sliderPosition == slider->sliderValue;
- if (!tracking) {
- // Small optimization, the same as q->subControlRect
- QCFType<HIShapeRef> shape;
- HIThemeGetTrackThumbShape(&tdi, &shape);
- HIShapeGetBounds(shape, &macRect);
- tdi.value = slider->sliderValue;
- }
- if (!(slider->subControls & SC_SliderHandle))
- tdi.attributes &= ~kThemeTrackShowThumb;
- if (!(slider->subControls & SC_SliderGroove))
- tdi.attributes |= kThemeTrackHideTrack;
-
- // Fix min and max positions. (See also getSliderInfo()
- // for the slider values adjustments.)
- // HITheme seems to have forgotten how to render
- // a slide at those positions, leaving a gap between
- // the knob and the ends of the track.
- // We fix this by rendering the track first, and then
- // the knob on top. However, in order to not clip the
- // knob, we reduce the the drawing rect for the track.
- CGRect bounds = tdi.bounds;
- if (isHorizontal) {
- tdi.bounds.size.width -= 2;
- tdi.bounds.origin.x += 1;
- if (tdi.trackInfo.slider.thumbDir == kThemeThumbDownward)
- tdi.bounds.origin.y -= 2;
- else if (tdi.trackInfo.slider.thumbDir == kThemeThumbUpward)
- tdi.bounds.origin.y += 3;
- } else {
- tdi.bounds.size.height -= 2;
- tdi.bounds.origin.y += 1;
- if (tdi.trackInfo.slider.thumbDir == kThemeThumbDownward) // pointing right
- tdi.bounds.origin.x -= 4;
- else if (tdi.trackInfo.slider.thumbDir == kThemeThumbUpward) // pointing left
- tdi.bounds.origin.x += 2;
- }
+ if (hasDoubleTicks) {
+ // This ain't HIG kosher: eye-proved constants
+ if (isHorizontal)
+ CGContextTranslateCTM(ctx, 0, 4);
+ else
+ CGContextTranslateCTM(ctx, 1, 0);
+ }
- // Yosemite demands its blue progress track when no tickmarks are present
- if (!(slider->subControls & SC_SliderTickmarks)) {
- QCocoaWidgetKind sliderKind = slider->orientation == Qt::Horizontal ? QCocoaHorizontalSlider : QCocoaVerticalSlider;
- QCocoaWidget cw = QCocoaWidget(sliderKind, QStyleHelper::SizeLarge);
- NSSlider *sl = (NSSlider *)d->cocoaControl(cw);
- sl.minValue = slider->minimum;
- sl.maxValue = slider->maximum;
- sl.intValue = slider->sliderValue;
- sl.enabled = slider->state & QStyle::State_Enabled;
- d->drawNSViewInRect(cw, sl, opt->rect, p, widget != 0, ^(CGContextRef ctx, const CGRect &rect) {
- const bool isSierraOrLater = QOperatingSystemVersion::current() >= QOperatingSystemVersion::MacOSSierra;
- if (slider->upsideDown) {
- if (isHorizontal) {
- CGContextTranslateCTM(ctx, rect.size.width, 0);
- CGContextScaleCTM(ctx, -1, 1);
- }
- } else if (!isHorizontal && !isSierraOrLater) {
- CGContextTranslateCTM(ctx, 0, rect.size.height);
- CGContextScaleCTM(ctx, 1, -1);
- }
- const bool shouldFlip = isHorizontal || (slider->upsideDown && isSierraOrLater);
- [sl.cell drawBarInside:NSRectFromCGRect(tdi.bounds) flipped:shouldFlip];
- // No need to restore the CTM later, the context has been saved
- // and will be restored at the end of drawNSViewInRect()
- });
- tdi.attributes |= kThemeTrackHideTrack;
-
- tdi.bounds = bounds;
- }
+ // Since the GC is flipped, upsideDown means *not* inverted when vertical.
+ const bool verticalFlip = !isHorizontal && !sl->upsideDown; // FIXME: && !isSierraOrLater
- if (slider->subControls & SC_SliderTickmarks) {
-
- CGRect bounds;
- // As part of fixing the min and max positions,
- // we need to adjust the tickmarks as well
- bounds = tdi.bounds;
- if (slider->orientation == Qt::Horizontal) {
- tdi.bounds.size.width += 2;
- tdi.bounds.origin.x -= 1;
- if (tdi.trackInfo.slider.thumbDir == kThemeThumbUpward)
- tdi.bounds.origin.y -= 2;
- } else {
- tdi.bounds.size.height += 3;
- tdi.bounds.origin.y -= 3;
- tdi.bounds.origin.y += 1;
- if (tdi.trackInfo.slider.thumbDir == kThemeThumbUpward) // pointing left
- tdi.bounds.origin.x -= 2;
- }
+#if 0
+ // FIXME: Sadly, this part doesn't work. It seems to somehow polute the
+ // NSSlider's internal state and, when we need to use the "else" part,
+ // the slider's frame is not in sync with its cell dimensions.
+ const bool drawAllParts = drawKnob && drawBar && (!hasTicks || drawTicks);
+ if (drawAllParts && !hasDoubleTicks && (!verticalFlip || drawTicks)) {
+ // Draw eveything at once if we're going to, except for inverted vertical
+ // sliders which need to be drawn part by part because of the shadow below
+ // the knob. Same for two-sided tickmarks.
+ if (verticalFlip && drawTicks) {
+ // Since tickmarks are always rendered symmetrically, a vertically
+ // flipped slider with tickmarks only needs to get its value flipped.
+ slider.intValue = slider.maxValue - slider.intValue + slider.minValue;
+ }
+ [slider drawRect:CGRectZero];
+ } else
+#endif
+ {
+ [slider calcSize];
+ NSSliderCell *cell = slider.cell;
+
+ const int numberOfTickMarks = slider.numberOfTickMarks;
+ // This ain't HIG kosher: force tick-less bar position.
+ if (hasDoubleTicks)
+ slider.numberOfTickMarks = 0;
+
+ const CGRect barRect = [cell barRectFlipped:hasTicks];
+ if (drawBar) {
+ // This ain't HIG kosher: force unfilled bar look.
+ if (hasDoubleTicks)
+ slider.numberOfTickMarks = numberOfTickMarks;
+ [cell drawBarInside:barRect flipped:!verticalFlip];
+ }
- int interval = slider->tickInterval;
- if (interval == 0) {
- interval = slider->pageStep;
- if (interval == 0)
- interval = slider->singleStep;
- if (interval == 0)
- interval = 1;
- }
- int numMarks = 1 + ((slider->maximum - slider->minimum) / interval);
-
- if (tdi.trackInfo.slider.thumbDir == kThemeThumbPlain) {
- // They asked for both, so we'll give it to them.
- tdi.trackInfo.slider.thumbDir = kThemeThumbDownward;
- HIThemeDrawTrackTickMarks(&tdi, numMarks,
- cg,
- kHIThemeOrientationNormal);
- tdi.trackInfo.slider.thumbDir = kThemeThumbUpward;
- // 10.10 and above need a slight shift
- if (slider->orientation == Qt::Vertical)
- tdi.bounds.origin.x -= 2;
- HIThemeDrawTrackTickMarks(&tdi, numMarks,
- cg,
- kHIThemeOrientationNormal);
- // Reset to plain thumb to be drawn further down
- tdi.trackInfo.slider.thumbDir = kThemeThumbPlain;
- } else {
- HIThemeDrawTrackTickMarks(&tdi, numMarks,
- cg,
- kHIThemeOrientationNormal);
- }
+ if (hasTicks && drawTicks) {
+ if (!drawBar && hasDoubleTicks)
+ slider.numberOfTickMarks = numberOfTickMarks;
- tdi.bounds = bounds;
- }
+ [cell drawTickMarks];
- HIThemeDrawTrack(&tdi, tracking ? 0 : &macRect, cg,
- kHIThemeOrientationNormal);
+ if (hasDoubleTicks) {
+ // This ain't HIG kosher: just slap a set of tickmarks on each side, like we used to.
+ CGAffineTransform tickMarksFlip;
+ const CGRect tickMarkRect = [cell rectOfTickMarkAtIndex:0];
+ if (isHorizontal) {
+ tickMarksFlip = CGAffineTransformMakeTranslation(0, rect.size.height - tickMarkRect.size.height - 3);
+ tickMarksFlip = CGAffineTransformScale(tickMarksFlip, 1, -1);
+ } else {
+ tickMarksFlip = CGAffineTransformMakeTranslation(rect.size.width - tickMarkRect.size.width / 2, 0);
+ tickMarksFlip = CGAffineTransformScale(tickMarksFlip, -1, 1);
+ }
+ CGContextConcatCTM(ctx, tickMarksFlip);
+ [cell drawTickMarks];
+ CGContextConcatCTM(ctx, CGAffineTransformInvert(tickMarksFlip));
+ }
+ }
+
+ if (drawKnob) {
+ // This ain't HIG kosher: force round knob look.
+ if (hasDoubleTicks)
+ slider.numberOfTickMarks = 0;
+ // Draw the knob in the symmetrical position instead of flipping.
+ if (verticalFlip)
+ slider.intValue = slider.maxValue - slider.intValue + slider.minValue;
+ [cell drawKnob];
+ }
+ }
+ });
+
+ if (isPressed)
+ [slider.cell stopTracking:pressPoint at:pressPoint inView:slider mouseIsUp:NO];
}
break;
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
case CC_SpinBox:
if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) {
- SInt32 frame_size;
+ int frame_size;
frame_size = qt_mac_aqua_get_metric(EditTextFrameOutset);
QRect lineeditRect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxEditField, widget);
@@ -5618,15 +5510,16 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
const bool downPressed = sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken);
const CGFloat x = CGRectGetMidX(newRect);
const CGFloat y = upPressed ? -3 : 3; // FIXME Weird coordinate shift going on
+ const CGPoint pressPoint = CGPointMake(x, y);
// Pretend we're pressing the mouse on the right button. Unfortunately, NSStepperCell has no
// API to highlight a specific button. The highlighted property works only on the down button.
if (upPressed || downPressed)
- [cell startTrackingAt:CGPointMake(x, y) inView:d->backingStoreNSView];
+ [cell startTrackingAt:pressPoint inView:d->backingStoreNSView];
[cell drawWithFrame:newRect inView:d->backingStoreNSView];
if (upPressed || downPressed)
- [cell stopTracking:CGPointMake(x, y) at:CGPointMake(x, y) inView:d->backingStoreNSView mouseIsUp:NO];
+ [cell stopTracking:pressPoint at:pressPoint inView:d->backingStoreNSView mouseIsUp:NO];
d->restoreNSGraphicsContext(cg);
}
@@ -5941,16 +5834,28 @@ QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc,
}
break;
case CC_Slider:
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
- HIThemeTrackDrawInfo tdi;
- d->getSliderInfo(cc, slider, &tdi, widget);
- ControlPartCode part;
- CGPoint pos = CGPointMake(pt.x(), pt.y());
- if (HIThemeHitTestTrack(&tdi, &pos, &part)) {
- if (part == kControlPageUpPart || part == kControlPageDownPart)
- sc = SC_SliderGroove;
- else
- sc = SC_SliderHandle;
+ if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
+ if (!sl->rect.contains(pt))
+ break;
+
+ const bool hasTicks = sl->tickPosition != QSlider::NoTicks;
+ const bool isHorizontal = sl->orientation == Qt::Horizontal;
+ const auto cs = d->effectiveAquaSizeConstrain(opt, widget);
+ const auto cw = QCocoaWidget(isHorizontal ? QCocoaHorizontalSlider : QCocoaVerticalSlider, cs);
+ auto *slider = static_cast<NSSlider *>(d->cocoaControl(cw));
+ if (!setupSlider(slider, sl))
+ break;
+
+ [slider calcSize];
+ NSSliderCell *cell = slider.cell;
+ const auto barRect = QRectF::fromCGRect([cell barRectFlipped:hasTicks]);
+ const auto knobRect = QRectF::fromCGRect([cell knobRectFlipped:NO]);
+ if (knobRect.contains(pt)) {
+ sc = SC_SliderHandle;
+ } else if (barRect.contains(pt)) {
+ sc = SC_SliderGroove;
+ } else if (hasTicks) {
+ sc = SC_SliderTickmarks;
}
}
break;
@@ -6078,30 +5983,51 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
}
break;
case CC_Slider:
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
- HIThemeTrackDrawInfo tdi;
- d->getSliderInfo(cc, slider, &tdi, widget);
- CGRect macRect;
- QCFType<HIShapeRef> shape;
+ if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
+ const bool hasTicks = sl->tickPosition != QSlider::NoTicks;
+ const bool isHorizontal = sl->orientation == Qt::Horizontal;
+ const auto cs = d->effectiveAquaSizeConstrain(opt, widget);
+ const auto cw = QCocoaWidget(isHorizontal ? QCocoaHorizontalSlider : QCocoaVerticalSlider, cs);
+ auto *slider = static_cast<NSSlider *>(d->cocoaControl(cw));
+ if (!setupSlider(slider, sl))
+ break;
+
+ [slider calcSize];
+ NSSliderCell *cell = slider.cell;
if (sc == SC_SliderHandle) {
- HIThemeGetTrackThumbShape(&tdi, &shape);
- HIShapeGetBounds(shape, &macRect);
+ ret = QRectF::fromCGRect([cell knobRectFlipped:NO]).toRect();
+ if (isHorizontal) {
+ ret.setTop(sl->rect.top());
+ ret.setBottom(sl->rect.bottom());
+ } else {
+ ret.setLeft(sl->rect.left());
+ ret.setRight(sl->rect.right());
+ }
} else if (sc == SC_SliderGroove) {
- HIThemeGetTrackBounds(&tdi, &macRect);
+ ret = QRectF::fromCGRect([cell barRectFlipped:hasTicks]).toRect();
+ } else if (hasTicks && sc == SC_SliderTickmarks) {
+ const auto tickMarkRect = QRectF::fromCGRect([cell rectOfTickMarkAtIndex:0]);
+ if (isHorizontal)
+ ret = QRect(sl->rect.left(), tickMarkRect.top(), sl->rect.width(), tickMarkRect.height());
+ else
+ ret = QRect(tickMarkRect.left(), sl->rect.top(), tickMarkRect.width(), sl->rect.height());
}
- // FIXME No SC_SliderTickmarks?
- ret = QRectF::fromCGRect(macRect).toRect();
-
- // Tweak: the dark line between the sub/add line buttons belong to only one of the buttons
- // when doing hit-testing, but both of them have to repaint it. Extend the rect to cover
- // the line in the cases where HIThemeGetTrackPartBounds returns a rect that doesn't.
- if (slider->orientation == Qt::Horizontal) {
- if (slider->direction == Qt::LeftToRight && sc == SC_ScrollBarSubLine)
- ret.adjust(0, 0, 1, 0);
- else if (slider->direction == Qt::RightToLeft && sc == SC_ScrollBarAddLine)
- ret.adjust(-1, 0, 1, 0);
- } else if (sc == SC_ScrollBarAddLine) {
- ret.adjust(0, -1, 0, 1);
+
+ // Invert if needed and extend to the actual bounds of the slider
+ if (isHorizontal) {
+ if (sl->upsideDown) {
+ ret = QRect(sl->rect.right() - ret.right(), sl->rect.top(), ret.width(), sl->rect.height());
+ } else {
+ ret.setTop(sl->rect.top());
+ ret.setBottom(sl->rect.bottom());
+ }
+ } else {
+ if (!sl->upsideDown) {
+ ret = QRect(sl->rect.left(), sl->rect.bottom() - ret.bottom(), sl->rect.width(), ret.height());
+ } else {
+ ret.setLeft(sl->rect.left());
+ ret.setRight(sl->rect.right());
+ }
}
}
break;
@@ -6274,7 +6200,7 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
}
}
break;
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
case CC_SpinBox:
if (const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
QStyleHelper::WidgetSizePolicy aquaSize = d->effectiveAquaSizeConstrain(spin, widget);
@@ -6385,7 +6311,7 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
bool useAquaGuideline = true;
switch (ct) {
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
case CT_SpinBox:
if (const QStyleOptionSpinBox *vopt = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
// Add button + frame widths
@@ -6749,7 +6675,7 @@ bool QMacStyle::event(QEvent *e)
QWidget *top = f->parentWidget();
while (top && !top->isWindow() && !(top->windowType() == Qt::SubWindow))
top = top->parentWidget();
-#ifndef QT_NO_MAINWINDOW
+#if QT_CONFIG(mainwindow)
if (qobject_cast<QMainWindow *>(top)) {
QWidget *central = static_cast<QMainWindow *>(top)->centralWidget();
for (const QWidget *par = f; par; par = par->parentWidget()) {
diff --git a/src/plugins/styles/mac/qmacstyle_mac_p_p.h b/src/plugins/styles/mac/qmacstyle_mac_p_p.h
index b453e3c2d7..399edd82d4 100644
--- a/src/plugins/styles/mac/qmacstyle_mac_p_p.h
+++ b/src/plugins/styles/mac/qmacstyle_mac_p_p.h
@@ -74,13 +74,19 @@
#include <qhash.h>
#include <qheaderview.h>
#include <qlayout.h>
+#if QT_CONFIG(lineedit)
#include <qlineedit.h>
+#endif
#if QT_CONFIG(listview)
#include <qlistview.h>
#endif
+#if QT_CONFIG(mainwindow)
#include <qmainwindow.h>
+#endif
#include <qmap.h>
+#if QT_CONFIG(menubar)
#include <qmenubar.h>
+#endif
#include <qpaintdevice.h>
#include <qpainter.h>
#include <qpixmapcache.h>
@@ -95,8 +101,12 @@
#if QT_CONFIG(rubberband)
#include <qrubberband.h>
#endif
+#if QT_CONFIG(sizegrip)
#include <qsizegrip.h>
+#endif
+#if QT_CONFIG(spinbox)
#include <qspinbox.h>
+#endif
#if QT_CONFIG(splitter)
#include <qsplitter.h>
#endif
@@ -146,11 +156,11 @@ QT_BEGIN_NAMESPACE
/*
AHIG:
- Apple Human Interface Guidelines
- http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/
+ macOS Human Interface Guidelines
+ https://developer.apple.com/macos/human-interface-guidelines/overview/themes/
Builder:
- Apple Interface Builder v. 3.1.1
+ Interface Builder in Xcode 8 or later
*/
// this works as long as we have at most 16 different control types
@@ -246,7 +256,6 @@ public:
void initHIThemePushButton(const QStyleOptionButton *btn, const QWidget *widget,
const ThemeDrawState tds,
HIThemeButtonDrawInfo *bdi) const;
- QPixmap generateBackgroundPattern() const;
void setAutoDefaultButton(QObject *button) const;
diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp
index 60a5c25b1f..9e6880098f 100644
--- a/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp
+++ b/src/plugins/styles/windowsvista/qwindowsvistastyle.cpp
@@ -1173,7 +1173,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
}
}
break;
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
case CE_MenuItem:
if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
// windows always has a check column, regardless whether we have an icon or not
@@ -1331,7 +1331,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
}
}
break;
-#endif // QT_NO_MENU
+#endif // QT_CONFIG(menu)
case CE_HeaderSection:
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
partId = HP_HEADERITEM;
@@ -1772,7 +1772,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle
}
}
break;
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
case CC_SpinBox:
if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(option))
{
@@ -1830,7 +1830,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle
}
}
break;
-#endif // QT_NO_SPINBOX
+#endif // QT_CONFIG(spinbox)
default:
QWindowsXPStyle::drawComplexControl(control, option, painter, widget);
break;
@@ -1869,7 +1869,7 @@ QSize QWindowsVistaStyle::sizeFromContents(ContentsType type, const QStyleOption
sz.setHeight(minimumHeight);
}
return sz;
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
case CT_MenuBarItem:
if (!sz.isEmpty())
sz += QSize(windowsItemHMargin * 5 + 1, 5);
@@ -2290,11 +2290,11 @@ void QWindowsVistaStyle::polish(QApplication *app)
void QWindowsVistaStyle::polish(QWidget *widget)
{
QWindowsXPStyle::polish(widget);
-#ifndef QT_NO_LINEEDIT
+#if QT_CONFIG(lineedit)
if (qobject_cast<QLineEdit*>(widget))
widget->setAttribute(Qt::WA_Hover);
else
-#endif // QT_NO_LINEEDIT
+#endif // QT_CONFIG(lineedit)
if (qobject_cast<QGroupBox*>(widget))
widget->setAttribute(Qt::WA_Hover);
else if (qobject_cast<QCommandLinkButton*>(widget)) {
@@ -2351,11 +2351,11 @@ void QWindowsVistaStyle::unpolish(QWidget *widget)
d->stopAnimation(widget);
-#ifndef QT_NO_LINEEDIT
+#if QT_CONFIG(lineedit)
if (qobject_cast<QLineEdit*>(widget))
widget->setAttribute(Qt::WA_Hover, false);
else
-#endif // QT_NO_LINEEDIT
+#endif // QT_CONFIG(lineedit)
if (qobject_cast<QGroupBox*>(widget))
widget->setAttribute(Qt::WA_Hover, false);
else if (qobject_cast<QMessageBox *> (widget)) {
diff --git a/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h b/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h
index a6744ff915..b649426811 100644
--- a/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h
+++ b/src/plugins/styles/windowsvista/qwindowsvistastyle_p_p.h
@@ -65,12 +65,16 @@
#include <qpushbutton.h>
#endif
#include <qradiobutton.h>
+#if QT_CONFIG(lineedit)
#include <qlineedit.h>
+#endif
#include <qgroupbox.h>
#if QT_CONFIG(toolbutton)
#include <qtoolbutton.h>
#endif
+#if QT_CONFIG(spinbox)
#include <qspinbox.h>
+#endif
#include <qtoolbar.h>
#if QT_CONFIG(combobox)
#include <qcombobox.h>
diff --git a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp
index 9880edf0b4..0a47ccf68a 100644
--- a/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp
+++ b/src/plugins/styles/windowsvista/qwindowsxpstyle.cpp
@@ -68,11 +68,15 @@
#include <qscrollbar.h>
#endif
#include <qheaderview.h>
+#if QT_CONFIG(spinbox)
#include <qspinbox.h>
+#endif
#if QT_CONFIG(listview)
#include <qlistview.h>
#endif
+#if QT_CONFIG(stackedwidget)
#include <qstackedwidget.h>
+#endif
#if QT_CONFIG(pushbutton)
#include <qpushbutton.h>
#endif
@@ -379,10 +383,10 @@ bool QWindowsXPStylePrivate::isLineEditBaseColorSet(const QStyleOption *option,
// Since spin box includes a line edit we need to resolve the palette mask also from
// the parent, as while the color is always correct on the palette supplied by panel,
// the mask can still be empty. If either mask specifies custom base color, use that.
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
if (const QAbstractSpinBox *spinbox = qobject_cast<QAbstractSpinBox*>(widget->parentWidget()))
resolveMask |= spinbox->palette().resolve();
-#endif // QT_NO_SPINBOX
+#endif // QT_CONFIG(spinbox)
}
return (resolveMask & (1 << QPalette::Base)) != 0;
}
@@ -1167,10 +1171,10 @@ void QWindowsXPStyle::polish(QWidget *widget)
|| qobject_cast<QScrollBar*>(widget)
|| qobject_cast<QSlider*>(widget)
|| qobject_cast<QHeaderView*>(widget)
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
|| qobject_cast<QAbstractSpinBox*>(widget)
|| qobject_cast<QSpinBox*>(widget)
-#endif // QT_NO_SPINBOX
+#endif // QT_CONFIG(spinbox)
) {
widget->setAttribute(Qt::WA_Hover);
}
@@ -1242,10 +1246,10 @@ void QWindowsXPStyle::unpolish(QWidget *widget)
|| qobject_cast<QScrollBar*>(widget)
|| qobject_cast<QSlider*>(widget)
|| qobject_cast<QHeaderView*>(widget)
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
|| qobject_cast<QAbstractSpinBox*>(widget)
|| qobject_cast<QSpinBox*>(widget)
-#endif // QT_NO_SPINBOX
+#endif // QT_CONFIG(spinbox)
) {
widget->setAttribute(Qt::WA_Hover, false);
}
@@ -2511,7 +2515,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
flags |= State_MouseOver;
switch (cc) {
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
case CC_SpinBox:
if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(option))
{
@@ -2563,7 +2567,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
}
}
break;
-#endif // QT_NO_SPINBOX
+#endif // QT_CONFIG(spinbox)
#if QT_CONFIG(combobox)
case CC_ComboBox:
if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option))
@@ -2726,7 +2730,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
}
break;
-#ifndef QT_NO_SLIDER
+#if QT_CONFIG(slider)
case CC_Slider:
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option))
{
@@ -3178,7 +3182,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
}
break;
-#ifndef QT_NO_MDIAREA
+#if QT_CONFIG(mdiarea)
case CC_MdiControls:
{
QRect buttonRect;
@@ -3234,7 +3238,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
}
}
break;
-#endif //QT_NO_MDIAREA
+#endif // QT_CONFIG(mdiarea)
#if QT_CONFIG(dial)
case CC_Dial:
if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option))
@@ -3574,7 +3578,7 @@ QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionCompl
}
}
break;
-#ifndef QT_NO_MDIAREA
+#if QT_CONFIG(mdiarea)
case CC_MdiControls:
{
int numSubControls = 0;
@@ -3611,7 +3615,7 @@ QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionCompl
rect = QRect(offset, 0, buttonWidth, option->rect.height());
break;
}
-#endif // QT_NO_MDIAREA
+#endif // QT_CONFIG(mdiarea)
default:
rect = visualRect(option->direction, option->rect,
@@ -3665,7 +3669,7 @@ QSize QWindowsXPStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt
case CT_Menu:
sz += QSize(1, 0);
break;
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
case CT_MenuBarItem:
if (!sz.isEmpty())
sz += QSize(windowsItemHMargin * 5 + 1, 6);
diff --git a/src/printsupport/configure.json b/src/printsupport/configure.json
index e8cec22c09..abc704fa18 100644
--- a/src/printsupport/configure.json
+++ b/src/printsupport/configure.json
@@ -38,6 +38,7 @@
"label": "CUPS job control widget",
"section": "Widgets",
"condition": [
+ "features.buttongroup",
"features.calendarwidget",
"features.checkbox",
"features.combobox",
diff --git a/src/printsupport/dialogs/qprintdialog_unix.cpp b/src/printsupport/dialogs/qprintdialog_unix.cpp
index 91a6d47578..d55ed09cea 100644
--- a/src/printsupport/dialogs/qprintdialog_unix.cpp
+++ b/src/printsupport/dialogs/qprintdialog_unix.cpp
@@ -63,7 +63,9 @@
#include <QtWidgets/qdialogbuttonbox.h>
+#if QT_CONFIG(completer)
#include <private/qcompleter_p.h>
+#endif
#include "ui_qprintpropertieswidget.h"
#include "ui_qprintsettingsoutput.h"
#include "ui_qprintwidget.h"
@@ -679,7 +681,7 @@ QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p, QPrinter *
}
widget.properties->setEnabled(true);
-#if QT_CONFIG(filesystemmodel) && !defined(QT_NO_COMPLETER)
+#if QT_CONFIG(filesystemmodel) && QT_CONFIG(completer)
QFileSystemModel *fsm = new QFileSystemModel(widget.filename);
fsm->setRootPath(QDir::homePath());
widget.filename->setCompleter(new QCompleter(fsm, widget.filename));
diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp
index bca981a865..14374c7ca9 100644
--- a/src/sql/kernel/qsqldatabase.cpp
+++ b/src/sql/kernel/qsqldatabase.cpp
@@ -365,6 +365,14 @@ void QSqlDatabasePrivate::disable()
cloneDatabase() to create an independent database connection based
on an existing one.
+ \warning It is highly recommended that you do not keep a copy of the
+ QSqlDatabase around as a member of a class, as this will prevent the
+ instance from being correctly cleaned up on shutdown. If you need to
+ access an existing QSqlDatabase, it should be accessed with database().
+ If you chose to have a QSqlDatabase member variable, this needs to be
+ deleted before the QCoreApplication instance is deleted, otherwise it
+ may lead to undefined behavior.
+
If you create multiple database connections, specify a unique
connection name for each one, when you call addDatabase(). Use
database() with a connection name to get that connection. Use
diff --git a/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp b/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp
index 01ee8102f4..990b7a38d7 100644
--- a/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp
+++ b/src/testlib/doc/snippets/code/src_qtestlib_qtestcase.cpp
@@ -306,5 +306,13 @@ QTest::keyClick(myWindow, Qt::Key_Escape);
QTest::keyClick(myWindow, Qt::Key_Escape, Qt::ShiftModifier, 200);
//! [29]
+//! [30]
+MyObject obj;
+obj.startup();
+QTest::qWaitFor([&]() {
+ return obj.isReady();
+}, 3000);
+//! [30]
+
}
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 7e7f016bf6..eeaa30e9a0 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -582,7 +582,6 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
" -import dir : Specify an import directory.\n"
" -plugins dir : Specify a directory where to search for plugins.\n"
" -input dir/file : Specify the root directory for test cases or a single test case file.\n"
- " -qtquick1 : Run with QtQuick 1 rather than QtQuick 2.\n"
" -translation file : Specify the translation file.\n"
);
}
@@ -779,7 +778,6 @@ Q_TESTLIB_EXPORT void qtest_qParseArgs(int argc, char *argv[], bool qml)
" -import : Specify an import directory.\n"
" -plugins : Specify a directory where to search for plugins.\n"
" -input : Specify the root directory for test cases.\n"
- " -qtquick1 : Run with QtQuick 1 rather than QtQuick 2.\n"
);
}
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h
index 20e6f022b4..f38f7ed4df 100644
--- a/src/testlib/qtestcase.h
+++ b/src/testlib/qtestcase.h
@@ -147,6 +147,8 @@ do {\
} \
}
+// Ideally we'd use qWaitFor instead of QTRY_LOOP_IMPL, but due
+// to a compiler bug on MSVC < 2017 we can't (see QTBUG-59096)
#define QTRY_IMPL(expr, timeout)\
const int qt_test_step = 50; \
const int qt_test_timeoutValue = timeout; \
diff --git a/src/testlib/qtestcase.qdoc b/src/testlib/qtestcase.qdoc
index 2d1e27ec40..5b90419e28 100644
--- a/src/testlib/qtestcase.qdoc
+++ b/src/testlib/qtestcase.qdoc
@@ -1075,6 +1075,21 @@
\sa QTest::qSleep(), QSignalSpy::wait()
*/
+/*! \fn void QTest::qWaitFor(Functor predicate, int timeout)
+
+ Waits for \a timeout milliseconds or until the \a predicate returns true.
+
+ Returns \c true if the \a predicate returned true at any point, otherwise returns \c false.
+
+ Example:
+ \snippet code/src_qtestlib_qtestcase.cpp 30
+
+ The code above will wait for the object to become ready, for a
+ maximum of three seconds.
+
+ \since 5.10
+*/
+
/*! \fn bool QTest::qWaitForWindowExposed(QWindow *window, int timeout)
\since 5.0
diff --git a/src/testlib/qtestmouse.h b/src/testlib/qtestmouse.h
index 166622e950..8f55c1801f 100644
--- a/src/testlib/qtestmouse.h
+++ b/src/testlib/qtestmouse.h
@@ -94,8 +94,10 @@ namespace QTest
extern int Q_TESTLIB_EXPORT defaultMouseDelay();
// pos is in window local coordinates
- if (window->geometry().width() <= pos.x() || window->geometry().height() <= pos.y()) {
- QTest::qWarn("Mouse event occurs outside of target window.");
+ const QSize windowSize = window->geometry().size();
+ if (windowSize.width() <= pos.x() || windowSize.height() <= pos.y()) {
+ QTest::qWarn(qPrintable(QString::fromLatin1("Mouse event at %1, %2 occurs outside of target window (%3x%4).")
+ .arg(pos.x()).arg(pos.y()).arg(windowSize.width()).arg(windowSize.height())));
}
if (delay == -1 || delay < defaultMouseDelay())
diff --git a/src/testlib/qtestsystem.h b/src/testlib/qtestsystem.h
index dc6e481bb2..04c9c574f7 100644
--- a/src/testlib/qtestsystem.h
+++ b/src/testlib/qtestsystem.h
@@ -54,41 +54,60 @@ QT_BEGIN_NAMESPACE
namespace QTest
{
- Q_DECL_UNUSED inline static void qWait(int ms)
+ template <typename Functor>
+ static Q_REQUIRED_RESULT bool qWaitFor(Functor predicate, int timeout = 5000)
{
- Q_ASSERT(QCoreApplication::instance());
+ // We should not spint the event loop in case the predicate is already true,
+ // otherwise we might send new events that invalidate the predicate.
+ if (predicate())
+ return true;
+
+ // qWait() is expected to spin the event loop, even when called with a small
+ // timeout like 1ms, so we we can't use a simple while-loop here based on
+ // the deadline timer not having timed out. Use do-while instead.
+
+ int remaining = timeout;
+ QDeadlineTimer deadline(remaining, Qt::PreciseTimer);
- QDeadlineTimer timer(ms, Qt::PreciseTimer);
- int remaining = ms;
do {
QCoreApplication::processEvents(QEventLoop::AllEvents, remaining);
QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
- remaining = timer.remainingTime();
- if (remaining <= 0)
- break;
- QTest::qSleep(qMin(10, remaining));
- remaining = timer.remainingTime();
+
+ remaining = deadline.remainingTime();
+ if (remaining > 0) {
+ QTest::qSleep(qMin(10, remaining));
+ remaining = deadline.remainingTime();
+ }
+
+ if (predicate())
+ return true;
+
+ remaining = deadline.remainingTime();
} while (remaining > 0);
+
+ return predicate(); // Last chance
+ }
+
+ Q_DECL_UNUSED inline static void qWait(int ms)
+ {
+ Q_ASSERT(QCoreApplication::instance());
+ auto unconditionalWait = []() { return false; };
+ bool timedOut = !qWaitFor(unconditionalWait, ms);
+ Q_UNUSED(timedOut);
}
#ifdef QT_GUI_LIB
inline static bool qWaitForWindowActive(QWindow *window, int timeout = 5000)
{
- QDeadlineTimer timer(timeout, Qt::PreciseTimer);
- int remaining = timeout;
- while (!window->isActive() && remaining > 0) {
- QCoreApplication::processEvents(QEventLoop::AllEvents, remaining);
- QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
- QTest::qSleep(10);
- remaining = timer.remainingTime();
- }
+ bool becameActive = qWaitFor([&]() { return window->isActive(); }, timeout);
+
// Try ensuring the platform window receives the real position.
// (i.e. that window->pos() reflects reality)
// isActive() ( == FocusIn in case of X) does not guarantee this. It seems some WMs randomly
// send the final ConfigureNotify (the one with the non-bogus 0,0 position) after the FocusIn.
// If we just let things go, every mapTo/FromGlobal call the tests perform directly after
// qWaitForWindowShown() will generate bogus results.
- if (window->isActive()) {
+ if (becameActive) {
int waitNo = 0; // 0, 0 might be a valid position after all, so do not wait for ever
while (window->position().isNull()) {
if (waitNo++ > timeout / 10)
@@ -101,15 +120,7 @@ namespace QTest
inline static bool qWaitForWindowExposed(QWindow *window, int timeout = 5000)
{
- QDeadlineTimer timer(timeout, Qt::PreciseTimer);
- int remaining = timeout;
- while (!window->isExposed() && remaining > 0) {
- QCoreApplication::processEvents(QEventLoop::AllEvents, remaining);
- QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
- QTest::qSleep(10);
- remaining = timer.remainingTime();
- }
- return window->isExposed();
+ return qWaitFor([&]() { return window->isExposed(); }, timeout);
}
#endif
diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp
index 94ad011533..6cdc06d702 100644
--- a/src/widgets/accessible/complexwidgets.cpp
+++ b/src/widgets/accessible/complexwidgets.cpp
@@ -52,7 +52,9 @@
#if QT_CONFIG(combobox)
#include <qcombobox.h>
#endif
+#if QT_CONFIG(lineedit)
#include <qlineedit.h>
+#endif
#include <qstyle.h>
#include <qstyleoption.h>
#include <qtooltip.h>
@@ -60,7 +62,9 @@
#include <qwhatsthis.h>
#endif
#include <QAbstractScrollArea>
+#if QT_CONFIG(scrollarea)
#include <QScrollArea>
+#endif
#if QT_CONFIG(scrollbar)
#include <QScrollBar>
#endif
@@ -388,7 +392,7 @@ QStringList QAccessibleComboBox::keyBindingsForAction(const QString &/*actionNam
#endif // QT_CONFIG(combobox)
-#ifndef QT_NO_SCROLLAREA
+#if QT_CONFIG(scrollarea)
// ======================= QAccessibleAbstractScrollArea =======================
QAccessibleAbstractScrollArea::QAccessibleAbstractScrollArea(QWidget *widget)
: QAccessibleWidget(widget, QAccessible::Client)
@@ -497,7 +501,7 @@ QAccessibleScrollArea::QAccessibleScrollArea(QWidget *widget)
{
Q_ASSERT(qobject_cast<QScrollArea *>(widget));
}
-#endif // QT_NO_SCROLLAREA
+#endif // QT_CONFIG(scrollarea)
QT_END_NAMESPACE
diff --git a/src/widgets/accessible/complexwidgets_p.h b/src/widgets/accessible/complexwidgets_p.h
index c842490603..96db2dab70 100644
--- a/src/widgets/accessible/complexwidgets_p.h
+++ b/src/widgets/accessible/complexwidgets_p.h
@@ -70,7 +70,7 @@ class QTitleBar;
class QAbstractScrollArea;
class QScrollArea;
-#ifndef QT_NO_SCROLLAREA
+#if QT_CONFIG(scrollarea)
class QAccessibleAbstractScrollArea : public QAccessibleWidget
{
public:
@@ -105,7 +105,7 @@ class QAccessibleScrollArea : public QAccessibleAbstractScrollArea
public:
explicit QAccessibleScrollArea(QWidget *widget);
};
-#endif // QT_NO_SCROLLAREA
+#endif // QT_CONFIG(scrollarea)
#if QT_CONFIG(tabbar)
class QAccessibleTabBar : public QAccessibleWidget
diff --git a/src/widgets/accessible/qaccessiblemenu.cpp b/src/widgets/accessible/qaccessiblemenu.cpp
index 2391f74c2f..8b3353f625 100644
--- a/src/widgets/accessible/qaccessiblemenu.cpp
+++ b/src/widgets/accessible/qaccessiblemenu.cpp
@@ -39,8 +39,12 @@
#include "qaccessiblemenu_p.h"
+#if QT_CONFIG(menu)
#include <qmenu.h>
+#endif
+#if QT_CONFIG(menubar)
#include <qmenubar.h>
+#endif
#include <QtWidgets/QAction>
#include <qstyle.h>
@@ -48,7 +52,7 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
QString qt_accStripAmp(const QString &text);
QString qt_accHotKey(const QString &text);
@@ -139,7 +143,7 @@ int QAccessibleMenu::indexOfChild( const QAccessibleInterface *child) const
return -1;
}
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
QAccessibleMenuBar::QAccessibleMenuBar(QWidget *w)
: QAccessibleWidget(w, QAccessible::MenuBar)
{
@@ -173,7 +177,7 @@ int QAccessibleMenuBar::indexOfChild(const QAccessibleInterface *child) const
return -1;
}
-#endif // QT_NO_MENUBAR
+#endif // QT_CONFIG(menubar)
QAccessibleMenuItem::QAccessibleMenuItem(QWidget *owner, QAction *action)
: m_action(action), m_owner(owner)
@@ -253,13 +257,13 @@ QRect QAccessibleMenuItem::rect() const
{
QRect rect;
QWidget *own = owner();
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (QMenuBar *menuBar = qobject_cast<QMenuBar*>(own)) {
rect = menuBar->actionGeometry(m_action);
QPoint globalPos = menuBar->mapToGlobal(QPoint(0,0));
rect = rect.translated(globalPos);
} else
-#endif // QT_NO_MENUBAR
+#endif // QT_CONFIG(menubar)
if (QMenu *menu = qobject_cast<QMenu*>(own)) {
rect = menu->actionGeometry(m_action);
QPoint globalPos = menu->mapToGlobal(QPoint(0,0));
@@ -289,7 +293,7 @@ QAccessible::State QAccessibleMenuItem::state() const
if (QMenu *menu = qobject_cast<QMenu*>(own)) {
if (menu->activeAction() == m_action)
s.focused = true;
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
} else if (QMenuBar *menuBar = qobject_cast<QMenuBar*>(own)) {
if (menuBar->activeAction() == m_action)
s.focused = true;
@@ -387,7 +391,7 @@ QWidget *QAccessibleMenuItem::owner() const
return m_owner;
}
-#endif // QT_NO_MENU
+#endif // QT_CONFIG(menu)
QT_END_NAMESPACE
diff --git a/src/widgets/accessible/qaccessiblemenu_p.h b/src/widgets/accessible/qaccessiblemenu_p.h
index 4372ae4dcc..9acd2a42f9 100644
--- a/src/widgets/accessible/qaccessiblemenu_p.h
+++ b/src/widgets/accessible/qaccessiblemenu_p.h
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_ACCESSIBILITY
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
class QMenu;
class QMenuBar;
class QAction;
@@ -82,7 +82,7 @@ protected:
QMenu *menu() const;
};
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
class QAccessibleMenuBar : public QAccessibleWidget
{
public:
@@ -96,7 +96,7 @@ public:
protected:
QMenuBar *menuBar() const;
};
-#endif // QT_NO_MENUBAR
+#endif // QT_CONFIG(menubar)
class QAccessibleMenuItem : public QAccessibleInterface, public QAccessibleActionInterface
@@ -136,7 +136,7 @@ private:
QPointer<QWidget> m_owner; // can hold either QMenu or the QMenuBar that contains the action
};
-#endif // QT_NO_MENU
+#endif // QT_CONFIG(menu)
QT_END_NAMESPACE
#endif // QT_NO_ACCESSIBILITY
diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp
index e3dd7383b2..c96d213e7b 100644
--- a/src/widgets/accessible/qaccessiblewidget.cpp
+++ b/src/widgets/accessible/qaccessiblewidget.cpp
@@ -60,7 +60,9 @@
#include <QRubberBand>
#endif
#include <QFocusFrame>
+#if QT_CONFIG(menu)
#include <QMenu>
+#endif
#include <QtWidgets/private/qwidget_p.h>
QT_BEGIN_NAMESPACE
@@ -72,7 +74,7 @@ static QList<QWidget*> childWidgets(const QWidget *widget)
QWidget *w = qobject_cast<QWidget *>(o);
if (w && !w->isWindow()
&& !qobject_cast<QFocusFrame*>(w)
-#if !defined(QT_NO_MENU)
+#if QT_CONFIG(menu)
&& !qobject_cast<QMenu*>(w)
#endif
&& w->objectName() != QLatin1String("qt_rubberband")
diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp
index 3fbc9714f5..0bac45de27 100644
--- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp
+++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp
@@ -76,7 +76,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje
return iface;
if (false) {
-#ifndef QT_NO_LINEEDIT
+#if QT_CONFIG(lineedit)
} else if (classname == QLatin1String("QLineEdit")) {
if (widget->objectName() == QLatin1String("qt_spinbox_lineedit"))
iface = 0;
@@ -87,7 +87,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje
} else if (classname == QLatin1String("QComboBox")) {
iface = new QAccessibleComboBox(widget);
#endif
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
} else if (classname == QLatin1String("QAbstractSpinBox")) {
iface = new QAccessibleAbstractSpinBox(widget);
} else if (classname == QLatin1String("QSpinBox")) {
@@ -99,7 +99,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje
} else if (classname == QLatin1String("QScrollBar")) {
iface = new QAccessibleScrollBar(widget);
#endif
-#ifndef QT_NO_SLIDER
+#if QT_CONFIG(slider)
} else if (classname == QLatin1String("QAbstractSlider")) {
iface = new QAccessibleAbstractSlider(widget);
} else if (classname == QLatin1String("QSlider")) {
@@ -120,7 +120,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje
iface = new QAccessibleWidget(widget, QAccessible::Dialog);
} else if (classname == QLatin1String("QMessageBox")) {
iface = new QAccessibleWidget(widget, QAccessible::AlertMessage);
-#ifndef QT_NO_MAINWINDOW
+#if QT_CONFIG(mainwindow)
} else if (classname == QLatin1String("QMainWindow")) {
iface = new QAccessibleMainWindow(widget);
#endif
@@ -138,11 +138,11 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje
#endif
} else if (classname == QLatin1String("QToolBar")) {
iface = new QAccessibleWidget(widget, QAccessible::ToolBar, widget->windowTitle());
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
} else if (classname == QLatin1String("QMenuBar")) {
iface = new QAccessibleMenuBar(widget);
#endif
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
} else if (classname == QLatin1String("QMenu")) {
iface = new QAccessibleMenu(widget);
#endif
@@ -167,7 +167,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje
} else if (classname == QLatin1String("QSplitterHandle")) {
iface = new QAccessibleWidget(widget, QAccessible::Grip);
#endif
-#if !defined(QT_NO_TEXTEDIT) && !defined(QT_NO_CURSOR)
+#if QT_CONFIG(textedit) && !defined(QT_NO_CURSOR)
} else if (classname == QLatin1String("QTextEdit")) {
iface = new QAccessibleTextEdit(widget);
} else if (classname == QLatin1String("QPlainTextEdit")) {
@@ -177,7 +177,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje
iface = new QAccessibleDisplay(widget, QAccessible::ToolTip);
} else if (classname == QLatin1String("QFrame")) {
iface = new QAccessibleWidget(widget, QAccessible::Border);
-#ifndef QT_NO_STACKEDWIDGET
+#if QT_CONFIG(stackedwidget)
} else if (classname == QLatin1String("QStackedWidget")) {
iface = new QAccessibleStackedWidget(widget);
#endif
@@ -185,7 +185,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje
} else if (classname == QLatin1String("QToolBox")) {
iface = new QAccessibleToolBox(widget);
#endif
-#ifndef QT_NO_MDIAREA
+#if QT_CONFIG(mdiarea)
} else if (classname == QLatin1String("QMdiArea")) {
iface = new QAccessibleMdiArea(widget);
} else if (classname == QLatin1String("QMdiSubWindow")) {
@@ -207,7 +207,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje
} else if (classname == QLatin1String("QTextBrowser")) {
iface = new QAccessibleTextBrowser(widget);
#endif
-#ifndef QT_NO_SCROLLAREA
+#if QT_CONFIG(scrollarea)
} else if (classname == QLatin1String("QAbstractScrollArea")) {
iface = new QAccessibleAbstractScrollArea(widget);
} else if (classname == QLatin1String("QScrollArea")) {
diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp
index 4e7ba78620..f869ab1129 100644
--- a/src/widgets/accessible/qaccessiblewidgets.cpp
+++ b/src/widgets/accessible/qaccessiblewidgets.cpp
@@ -41,23 +41,29 @@
#include "qabstracttextdocumentlayout.h"
#include "qapplication.h"
#include "qclipboard.h"
-#include "qtextedit.h"
-#include "private/qtextedit_p.h"
#include "qtextdocument.h"
#include "qtextobject.h"
+#if QT_CONFIG(textedit)
#include "qplaintextedit.h"
+#include "qtextedit.h"
+#include "private/qtextedit_p.h"
+#endif
#include "qtextboundaryfinder.h"
#if QT_CONFIG(scrollbar)
#include "qscrollbar.h"
#endif
#include "qdebug.h"
#include <QApplication>
+#if QT_CONFIG(stackedwidget)
#include <QStackedWidget>
+#endif
#if QT_CONFIG(toolbox)
#include <QToolBox>
#endif
+#if QT_CONFIG(mdiarea)
#include <QMdiArea>
#include <QMdiSubWindow>
+#endif
#if QT_CONFIG(dialogbuttonbox)
#include <QDialogButtonBox>
#endif
@@ -78,8 +84,13 @@
#include <QDockWidget>
#include <private/qdockwidget_p.h>
#endif
+#if QT_CONFIG(mainwindow)
#include <QMainWindow>
+#endif
#include <QFocusFrame>
+#if QT_CONFIG(menu)
+#include <QMenu>
+#endif
#ifndef QT_NO_ACCESSIBILITY
@@ -111,7 +122,7 @@ QList<QWidget*> childWidgets(const QWidget *widget)
return widgets;
}
-#if !defined(QT_NO_TEXTEDIT) && !defined(QT_NO_CURSOR)
+#if QT_CONFIG(textedit) && !defined(QT_NO_CURSOR)
QAccessiblePlainTextEdit::QAccessiblePlainTextEdit(QWidget* o)
:QAccessibleTextWidget(o)
@@ -308,9 +319,9 @@ void QAccessibleTextEdit::scrollToSubstring(int startIndex, int endIndex)
qWarning("AccessibleTextEdit::scrollToSubstring failed!");
}
-#endif // QT_NO_TEXTEDIT && QT_NO_CURSOR
+#endif // QT_CONFIG(textedit) && QT_NO_CURSOR
-#ifndef QT_NO_STACKEDWIDGET
+#if QT_CONFIG(stackedwidget)
// ======================= QAccessibleStackedWidget ======================
QAccessibleStackedWidget::QAccessibleStackedWidget(QWidget *widget)
: QAccessibleWidget(widget, QAccessible::LayeredPane)
@@ -356,7 +367,7 @@ QStackedWidget *QAccessibleStackedWidget::stackedWidget() const
{
return static_cast<QStackedWidget *>(object());
}
-#endif // QT_NO_STACKEDWIDGET
+#endif // QT_CONFIG(stackedwidget)
#if QT_CONFIG(toolbox)
// ======================= QAccessibleToolBox ======================
@@ -373,7 +384,7 @@ QToolBox * QAccessibleToolBox::toolBox() const
#endif // QT_CONFIG(toolbox)
// ======================= QAccessibleMdiArea ======================
-#ifndef QT_NO_MDIAREA
+#if QT_CONFIG(mdiarea)
QAccessibleMdiArea::QAccessibleMdiArea(QWidget *widget)
: QAccessibleWidget(widget, QAccessible::LayeredPane)
{
@@ -493,7 +504,7 @@ QMdiSubWindow *QAccessibleMdiSubWindow::mdiSubWindow() const
{
return static_cast<QMdiSubWindow *>(object());
}
-#endif // QT_NO_MDIAREA
+#endif // QT_CONFIG(mdiarea)
#if QT_CONFIG(dialogbuttonbox)
// ======================= QAccessibleDialogButtonBox ======================
@@ -1088,7 +1099,7 @@ void QAccessibleTextWidget::replaceText(int startOffset, int endOffset, const QS
#endif // QT_NO_CURSOR
-#ifndef QT_NO_MAINWINDOW
+#if QT_CONFIG(mainwindow)
QAccessibleMainWindow::QAccessibleMainWindow(QWidget *widget)
: QAccessibleWidget(widget, QAccessible::Window) { }
@@ -1137,7 +1148,7 @@ QMainWindow *QAccessibleMainWindow::mainWindow() const
return qobject_cast<QMainWindow *>(object());
}
-#endif //QT_NO_MAINWINDOW
+#endif // QT_CONFIG(mainwindow)
QT_END_NAMESPACE
diff --git a/src/widgets/accessible/qaccessiblewidgets_p.h b/src/widgets/accessible/qaccessiblewidgets_p.h
index e663d70de6..87f0b888a0 100644
--- a/src/widgets/accessible/qaccessiblewidgets_p.h
+++ b/src/widgets/accessible/qaccessiblewidgets_p.h
@@ -132,7 +132,7 @@ protected:
virtual QWidget *viewport() const = 0;
};
-#ifndef QT_NO_TEXTEDIT
+#if QT_CONFIG(textedit)
class QAccessiblePlainTextEdit : public QAccessibleTextWidget
{
public:
@@ -184,7 +184,7 @@ protected:
QTextDocument *textDocument() const override;
QWidget *viewport() const override;
};
-#endif // QT_NO_TEXTEDIT
+#endif // QT_CONFIG(textedit)
#endif //QT_NO_CURSOR
class QAccessibleStackedWidget : public QAccessibleWidget
@@ -216,7 +216,7 @@ protected:
QToolBox *toolBox() const;
};
-#ifndef QT_NO_MDIAREA
+#if QT_CONFIG(mdiarea)
class QAccessibleMdiArea : public QAccessibleWidget
{
public:
@@ -246,7 +246,7 @@ public:
protected:
QMdiSubWindow *mdiSubWindow() const;
};
-#endif // QT_NO_MDIAREA
+#endif // QT_CONFIG(mdiarea)
#if QT_CONFIG(dialogbuttonbox)
class QAccessibleDialogButtonBox : public QAccessibleWidget
@@ -304,7 +304,7 @@ protected:
#endif // QT_CONFIG(dockwidget)
-#ifndef QT_NO_MAINWINDOW
+#if QT_CONFIG(mainwindow)
class QAccessibleMainWindow : public QAccessibleWidget
{
public:
@@ -317,7 +317,7 @@ public:
QMainWindow *mainWindow() const;
};
-#endif //QT_NO_MAINWINDOW
+#endif // QT_CONFIG(mainwindow)
#endif // QT_NO_ACCESSIBILITY
diff --git a/src/widgets/accessible/rangecontrols.cpp b/src/widgets/accessible/rangecontrols.cpp
index 4aa948ed33..b5b8608418 100644
--- a/src/widgets/accessible/rangecontrols.cpp
+++ b/src/widgets/accessible/rangecontrols.cpp
@@ -39,11 +39,15 @@
#include "rangecontrols_p.h"
+#if QT_CONFIG(slider)
#include <qslider.h>
+#endif
#if QT_CONFIG(dial)
#include <qdial.h>
#endif
+#if QT_CONFIG(spinbox)
#include <qspinbox.h>
+#endif
#if QT_CONFIG(scrollbar)
#include <qscrollbar.h>
#endif
@@ -51,8 +55,9 @@
#include <qstyleoption.h>
#include <qdebug.h>
#include <qglobal.h>
-#include <QDoubleSpinBox>
+#if QT_CONFIG(lineedit)
#include <QtWidgets/qlineedit.h>
+#endif
#include <qmath.h>
#include <private/qmath_p.h>
@@ -62,7 +67,7 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_ACCESSIBILITY
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
QAccessibleAbstractSpinBox::QAccessibleAbstractSpinBox(QWidget *w)
: QAccessibleWidget(w, QAccessible::SpinBox), lineEdit(nullptr)
{
@@ -285,7 +290,7 @@ QString QAccessibleDoubleSpinBox::text(QAccessible::Text textType) const
return QAccessibleWidget::text(textType);
}
-#endif // QT_NO_SPINBOX
+#endif // QT_CONFIG(spinbox)
#if QT_CONFIG(scrollbar)
/*!
@@ -322,7 +327,7 @@ QString QAccessibleScrollBar::text(QAccessible::Text t) const
#endif // QT_CONFIG(scrollbar)
-#ifndef QT_NO_SLIDER
+#if QT_CONFIG(slider)
/*!
\class QAccessibleSlider
\brief The QAccessibleSlider class implements the QAccessibleInterface for sliders.
@@ -399,7 +404,7 @@ QAbstractSlider *QAccessibleAbstractSlider::abstractSlider() const
return static_cast<QAbstractSlider *>(object());
}
-#endif // QT_NO_SLIDER
+#endif // QT_CONFIG(slider)
#if QT_CONFIG(dial)
// ======================================= QAccessibleDial ======================================
diff --git a/src/widgets/accessible/rangecontrols_p.h b/src/widgets/accessible/rangecontrols_p.h
index 41c3747c05..1eada8e456 100644
--- a/src/widgets/accessible/rangecontrols_p.h
+++ b/src/widgets/accessible/rangecontrols_p.h
@@ -67,7 +67,7 @@ class QDoubleSpinBox;
class QDial;
class QAccessibleLineEdit;
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
class QAccessibleAbstractSpinBox:
public QAccessibleWidget,
public QAccessibleValueInterface,
@@ -141,7 +141,7 @@ public:
protected:
QDoubleSpinBox *doubleSpinBox() const;
};
-#endif // QT_NO_SPINBOX
+#endif // QT_CONFIG(spinbox)
#if QT_CONFIG(slider)
class QAccessibleAbstractSlider: public QAccessibleWidget, public QAccessibleValueInterface
@@ -174,7 +174,7 @@ protected:
};
#endif // QT_CONFIG(scrollbar)
-#ifndef QT_NO_SLIDER
+#if QT_CONFIG(slider)
class QAccessibleSlider : public QAccessibleAbstractSlider
{
public:
@@ -184,7 +184,7 @@ public:
protected:
QSlider *slider() const;
};
-#endif // QT_NO_SLIDER
+#endif // QT_CONFIG(slider)
#if QT_CONFIG(dial)
class QAccessibleDial : public QAccessibleAbstractSlider
diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp
index b6fe003452..73de51ff45 100644
--- a/src/widgets/accessible/simplewidgets.cpp
+++ b/src/widgets/accessible/simplewidgets.cpp
@@ -60,7 +60,9 @@
#if QT_CONFIG(toolbutton)
#include <qtoolbutton.h>
#endif
+#if QT_CONFIG(menu)
#include <qmenu.h>
+#endif
#if QT_CONFIG(label)
#include <qlabel.h>
#endif
@@ -70,14 +72,17 @@
#if QT_CONFIG(lcdnumber)
#include <qlcdnumber.h>
#endif
+#if QT_CONFIG(lineedit)
#include <qlineedit.h>
#include <private/qlineedit_p.h>
+#endif
#include <qstyle.h>
#include <qstyleoption.h>
#include <qtextdocument.h>
#include <qwindow.h>
#include <private/qwindowcontainer_p.h>
#include <QtCore/qvarlengtharray.h>
+#include <QtGui/qvalidator.h>
#ifdef Q_OS_MAC
#include <qfocusframe.h>
@@ -175,7 +180,7 @@ QAccessible::State QAccessibleButton::state() const
if (pb) {
if (pb->isDefault())
state.defaultButton = true;
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
if (pb->menu())
state.hasPopup = true;
#endif
@@ -214,7 +219,7 @@ QAccessible::Role QAccessibleButton::role() const
{
QAbstractButton *ab = button();
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
if (QPushButton *pb = qobject_cast<QPushButton*>(ab)) {
if (pb->menu())
return QAccessible::ButtonMenu;
@@ -257,7 +262,7 @@ void QAccessibleButton::doAction(const QString &actionName)
return;
if (actionName == pressAction() ||
actionName == showMenuAction()) {
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
QPushButton *pb = qobject_cast<QPushButton*>(object());
if (pb && pb->menu())
pb->showMenu();
@@ -311,7 +316,7 @@ QToolButton *QAccessibleToolButton::toolButton() const
*/
bool QAccessibleToolButton::isSplitButton() const
{
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
return toolButton()->menu() && toolButton()->popupMode() == QToolButton::MenuButtonPopup;
#else
return false;
@@ -323,7 +328,7 @@ QAccessible::State QAccessibleToolButton::state() const
QAccessible::State st = QAccessibleButton::state();
if (toolButton()->autoRaise())
st.hotTracked = true;
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
if (toolButton()->menu())
st.hasPopup = true;
#endif
@@ -337,7 +342,7 @@ int QAccessibleToolButton::childCount() const
QAccessible::Role QAccessibleToolButton::role() const
{
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
QAbstractButton *ab = button();
QToolButton *tb = qobject_cast<QToolButton*>(ab);
if (!tb->menu())
@@ -351,7 +356,7 @@ QAccessible::Role QAccessibleToolButton::role() const
QAccessibleInterface *QAccessibleToolButton::child(int index) const
{
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
if (index == 0 && toolButton()->menu())
{
return QAccessible::queryAccessibleInterface(toolButton()->menu());
@@ -658,7 +663,7 @@ QStringList QAccessibleGroupBox::keyBindingsForAction(const QString &) const
#endif
-#ifndef QT_NO_LINEEDIT
+#if QT_CONFIG(lineedit)
/*!
\class QAccessibleLineEdit
\brief The QAccessibleLineEdit class implements the QAccessibleInterface for widgets with editable text
@@ -895,7 +900,7 @@ void QAccessibleLineEdit::replaceText(int startOffset, int endOffset, const QStr
lineEdit()->setText(lineEdit()->text().replace(startOffset, endOffset - startOffset, text));
}
-#endif // QT_NO_LINEEDIT
+#endif // QT_CONFIG(lineedit)
#if QT_CONFIG(progressbar)
QAccessibleProgressBar::QAccessibleProgressBar(QWidget *o)
diff --git a/src/widgets/accessible/simplewidgets_p.h b/src/widgets/accessible/simplewidgets_p.h
index 08ce1a9d77..fcd0e7df47 100644
--- a/src/widgets/accessible/simplewidgets_p.h
+++ b/src/widgets/accessible/simplewidgets_p.h
@@ -148,7 +148,7 @@ private:
};
#endif
-#ifndef QT_NO_LINEEDIT
+#if QT_CONFIG(lineedit)
class QAccessibleLineEdit : public QAccessibleWidget, public QAccessibleTextInterface, public QAccessibleEditableTextInterface
{
public:
@@ -188,7 +188,7 @@ protected:
QLineEdit *lineEdit() const;
friend class QAccessibleAbstractSpinBox;
};
-#endif // QT_NO_LINEEDIT
+#endif // QT_CONFIG(lineedit)
#if QT_CONFIG(progressbar)
class QAccessibleProgressBar : public QAccessibleDisplay, public QAccessibleValueInterface
diff --git a/src/widgets/configure.json b/src/widgets/configure.json
index 2c183dad65..4c596c09a5 100644
--- a/src/widgets/configure.json
+++ b/src/widgets/configure.json
@@ -74,7 +74,8 @@
"effects": {
"label": "Effects",
"purpose": "Provides special widget effects (e.g. fading and scrolling).",
- "section": "Kernel"
+ "section": "Kernel",
+ "output": [ "privateFeature" ]
},
"filesystemmodel": {
"label": "QFileSystemModel",
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
index 8cc0812125..03505e78c8 100644
--- a/src/widgets/dialogs/qcolordialog.cpp
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -49,7 +49,9 @@
#include "qlabel.h"
#include "qlayout.h"
#include "qlineedit.h"
+#if QT_CONFIG(menu)
#include "qmenu.h"
+#endif
#include "qpainter.h"
#include "qpixmap.h"
#include "qpushbutton.h"
@@ -428,7 +430,7 @@ void QWellArray::setSelected(int row, int col)
if (row >= 0)
emit selected(row, col);
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
if (isVisible() && qobject_cast<QMenu*>(parentWidget()))
parentWidget()->close();
#endif
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp
index 9e62f79a8e..f5db4481ee 100644
--- a/src/widgets/dialogs/qdialog.cpp
+++ b/src/widgets/dialogs/qdialog.cpp
@@ -53,11 +53,15 @@
#include <private/qdesktopwidget_p.h>
#include "qapplication.h"
#include "qlayout.h"
+#if QT_CONFIG(sizegrip)
#include "qsizegrip.h"
+#endif
#if QT_CONFIG(whatsthis)
#include "qwhatsthis.h"
#endif
+#if QT_CONFIG(menu)
#include "qmenu.h"
+#endif
#include "qcursor.h"
#if QT_CONFIG(messagebox)
#include "qmessagebox.h"
@@ -621,7 +625,7 @@ bool QDialog::eventFilter(QObject *o, QEvent *e)
/*! \reimp */
void QDialog::contextMenuEvent(QContextMenuEvent *e)
{
-#if !QT_CONFIG(whatsthis) || defined(QT_NO_MENU)
+#if !QT_CONFIG(whatsthis) || !QT_CONFIG(menu)
Q_UNUSED(e);
#else
QWidget *w = childAt(e->pos());
@@ -1006,7 +1010,7 @@ void QDialog::showExtension(bool showIt)
setFixedSize(w, height() + s.height());
}
d->extension->show();
-#ifndef QT_NO_SIZEGRIP
+#if QT_CONFIG(sizegrip)
const bool sizeGripEnabled = isSizeGripEnabled();
setSizeGripEnabled(false);
d->sizeGripEnabled = sizeGripEnabled;
@@ -1019,7 +1023,7 @@ void QDialog::showExtension(bool showIt)
resize(d->size);
if (layout())
layout()->setEnabled(true);
-#ifndef QT_NO_SIZEGRIP
+#if QT_CONFIG(sizegrip)
setSizeGripEnabled(d->sizeGripEnabled);
#endif
}
@@ -1080,7 +1084,7 @@ void QDialog::setModal(bool modal)
bool QDialog::isSizeGripEnabled() const
{
-#ifndef QT_NO_SIZEGRIP
+#if QT_CONFIG(sizegrip)
Q_D(const QDialog);
return !!d->resizer;
#else
@@ -1091,11 +1095,11 @@ bool QDialog::isSizeGripEnabled() const
void QDialog::setSizeGripEnabled(bool enabled)
{
-#ifdef QT_NO_SIZEGRIP
+#if !QT_CONFIG(sizegrip)
Q_UNUSED(enabled);
#else
Q_D(QDialog);
-#ifndef QT_NO_SIZEGRIP
+#if QT_CONFIG(sizegrip)
d->sizeGripEnabled = enabled;
if (enabled && d->doShowExtension)
return;
@@ -1116,7 +1120,7 @@ void QDialog::setSizeGripEnabled(bool enabled)
d->resizer = 0;
}
}
-#endif //QT_NO_SIZEGRIP
+#endif // QT_CONFIG(sizegrip)
}
@@ -1124,7 +1128,7 @@ void QDialog::setSizeGripEnabled(bool enabled)
/*! \reimp */
void QDialog::resizeEvent(QResizeEvent *)
{
-#ifndef QT_NO_SIZEGRIP
+#if QT_CONFIG(sizegrip)
Q_D(QDialog);
if (d->resizer) {
if (isRightToLeft())
diff --git a/src/widgets/dialogs/qdialog_p.h b/src/widgets/dialogs/qdialog_p.h
index c4677918a4..99fff08e65 100644
--- a/src/widgets/dialogs/qdialog_p.h
+++ b/src/widgets/dialogs/qdialog_p.h
@@ -78,7 +78,7 @@ public:
mainDef(0),
#endif
orientation(Qt::Horizontal),extension(0), doShowExtension(false),
-#ifndef QT_NO_SIZEGRIP
+#if QT_CONFIG(sizegrip)
resizer(0),
sizeGripEnabled(false),
#endif
@@ -99,7 +99,7 @@ public:
QWidget *extension;
bool doShowExtension;
QSize size, min, max;
-#ifndef QT_NO_SIZEGRIP
+#if QT_CONFIG(sizegrip)
QSizeGrip *resizer;
bool sizeGripEnabled;
#endif
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 28cc7f8884..e375a957de 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -50,7 +50,9 @@
#include <qheaderview.h>
#include <qshortcut.h>
#include <qgridlayout.h>
+#if QT_CONFIG(menu)
#include <qmenu.h>
+#endif
#if QT_CONFIG(messagebox)
#include <qmessagebox.h>
#endif
@@ -3353,7 +3355,7 @@ void QFileDialogPrivate::_q_showDetailsView()
*/
void QFileDialogPrivate::_q_showContextMenu(const QPoint &position)
{
-#ifdef QT_NO_MENU
+#if !QT_CONFIG(menu)
Q_UNUSED(position);
#else
Q_Q(QFileDialog);
@@ -3382,7 +3384,7 @@ void QFileDialogPrivate::_q_showContextMenu(const QPoint &position)
menu.addAction(newFolderAction);
}
menu.exec(view->viewport()->mapToGlobal(position));
-#endif // QT_NO_MENU
+#endif // QT_CONFIG(menu)
}
/*!
@@ -4130,7 +4132,7 @@ QStringList QFSCompleter::splitPath(const QString &path) const
return parts;
}
-#endif // QT_NO_COMPLETER
+#endif // QT_CONFIG(completer)
QT_END_NAMESPACE
diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h
index db54bd39cb..17290381d3 100644
--- a/src/widgets/dialogs/qfiledialog_p.h
+++ b/src/widgets/dialogs/qfiledialog_p.h
@@ -69,7 +69,9 @@
#include <qstackedwidget.h>
#include <qdialogbuttonbox.h>
#include <qabstractproxymodel.h>
+#if QT_CONFIG(completer)
#include <qcompleter.h>
+#endif
#include <qpointer.h>
#include <qdebug.h>
#include "qsidebar_p.h"
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index 3fe6a7ea7d..190ce93439 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -54,8 +54,12 @@
#include <QtGui/qicon.h>
#include <QtGui/qtextdocument.h>
#include <QtWidgets/qapplication.h>
+#if QT_CONFIG(textedit)
#include <QtWidgets/qtextedit.h>
+#endif
+#if QT_CONFIG(menu)
#include <QtWidgets/qmenu.h>
+#endif
#include "qdialog_p.h"
#include <QtGui/qfont.h>
#include <QtGui/qfontmetrics.h>
@@ -84,7 +88,7 @@ enum Button { Old_Ok = 1, Old_Cancel = 2, Old_Yes = 3, Old_No = 4, Old_Abort = 5
NewButtonMask = 0xFFFFFC00 };
enum DetailButtonLabel { ShowLabel = 0, HideLabel = 1 };
-#ifndef QT_NO_TEXTEDIT
+#if QT_CONFIG(textedit)
class QMessageBoxDetailsText : public QWidget
{
Q_OBJECT
@@ -153,7 +157,7 @@ private:
bool copyAvailable;
TextEdit *textEdit;
};
-#endif // QT_NO_TEXTEDIT
+#endif // QT_CONFIG(textedit)
class DetailButton : public QPushButton
{
@@ -193,7 +197,7 @@ class QMessageBoxPrivate : public QDialogPrivate
public:
QMessageBoxPrivate() : escapeButton(0), defaultButton(0), checkbox(0), clickedButton(0), detailsButton(0),
-#ifndef QT_NO_TEXTEDIT
+#if QT_CONFIG(textedit)
detailsText(0),
#endif
compatMode(false), autoAddOkButton(true),
@@ -243,7 +247,7 @@ public:
QCheckBox *checkbox;
QAbstractButton *clickedButton;
DetailButton *detailsButton;
-#ifndef QT_NO_TEXTEDIT
+#if QT_CONFIG(textedit)
QMessageBoxDetailsText *detailsText;
#endif
bool compatMode;
@@ -464,7 +468,7 @@ int QMessageBoxPrivate::execReturnCode(QAbstractButton *button)
void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button)
{
Q_Q(QMessageBox);
-#ifndef QT_NO_TEXTEDIT
+#if QT_CONFIG(textedit)
if (detailsButton && detailsText && button == detailsButton) {
detailsButton->setLabel(detailsText->isHidden() ? HideLabel : ShowLabel);
detailsText->setHidden(!detailsText->isHidden());
@@ -1418,7 +1422,7 @@ void QMessageBox::keyPressEvent(QKeyEvent *e)
#if !defined(QT_NO_CLIPBOARD) && !defined(QT_NO_SHORTCUT)
-#if !defined(QT_NO_TEXTEDIT)
+#if QT_CONFIG(textedit)
if (e == QKeySequence::Copy) {
if (d->detailsText && d->detailsText->isVisible() && d->detailsText->copy()) {
e->setAccepted(true);
@@ -1429,7 +1433,7 @@ void QMessageBox::keyPressEvent(QKeyEvent *e)
e->setAccepted(true);
return;
}
-#endif // !QT_NO_TEXTEDIT
+#endif // QT_CONFIG(textedit)
#if defined(Q_OS_WIN)
if (e == QKeySequence::Copy) {
@@ -1445,7 +1449,7 @@ void QMessageBox::keyPressEvent(QKeyEvent *e)
for (const auto *button : buttons)
textToCopy += button->text() + QLatin1String(" ");
textToCopy += QLatin1Char('\n') + separator;
-#ifndef QT_NO_TEXTEDIT
+#if QT_CONFIG(textedit)
if (d->detailsText)
textToCopy += d->detailsText->text() + QLatin1Char('\n') + separator;
#endif
@@ -1983,7 +1987,7 @@ int QMessageBoxPrivate::showOldMessageBox(QWidget *parent, QMessageBox::Icon ico
void QMessageBoxPrivate::retranslateStrings()
{
-#ifndef QT_NO_TEXTEDIT
+#if QT_CONFIG(textedit)
if (detailsButton)
detailsButton->setLabel(detailsText->isHidden() ? ShowLabel : HideLabel);
#endif
@@ -2438,7 +2442,7 @@ void QMessageBox::setButtonText(int button, const QString &text)
}
}
-#ifndef QT_NO_TEXTEDIT
+#if QT_CONFIG(textedit)
/*!
\property QMessageBox::detailedText
\brief the text to be displayed in the details area.
@@ -2486,7 +2490,7 @@ void QMessageBox::setDetailedText(const QString &text)
}
d->setupLayout();
}
-#endif // QT_NO_TEXTEDIT
+#endif // QT_CONFIG(textedit)
/*!
\property QMessageBox::informativeText
diff --git a/src/widgets/dialogs/qmessagebox.h b/src/widgets/dialogs/qmessagebox.h
index c2ce1ab333..4b993a9e65 100644
--- a/src/widgets/dialogs/qmessagebox.h
+++ b/src/widgets/dialogs/qmessagebox.h
@@ -61,7 +61,7 @@ class Q_WIDGETS_EXPORT QMessageBox : public QDialog
Q_PROPERTY(QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap)
Q_PROPERTY(Qt::TextFormat textFormat READ textFormat WRITE setTextFormat)
Q_PROPERTY(StandardButtons standardButtons READ standardButtons WRITE setStandardButtons)
-#ifndef QT_NO_TEXTEDIT
+#if QT_CONFIG(textedit)
Q_PROPERTY(QString detailedText READ detailedText WRITE setDetailedText)
#endif
Q_PROPERTY(QString informativeText READ informativeText WRITE setInformativeText)
@@ -270,7 +270,7 @@ public:
QString informativeText() const;
void setInformativeText(const QString &text);
-#ifndef QT_NO_TEXTEDIT
+#if QT_CONFIG(textedit)
QString detailedText() const;
void setDetailedText(const QString &text);
#endif
diff --git a/src/widgets/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp
index b8b042ddb5..f77b10ecbc 100644
--- a/src/widgets/dialogs/qsidebar.cpp
+++ b/src/widgets/dialogs/qsidebar.cpp
@@ -42,7 +42,9 @@
#include <qaction.h>
#include <qurl.h>
+#if QT_CONFIG(menu)
#include <qmenu.h>
+#endif
#include <qmimedata.h>
#include <qevent.h>
#include <qdebug.h>
@@ -435,7 +437,7 @@ void QSidebar::selectUrl(const QUrl &url)
this, SLOT(clicked(QModelIndex)));
}
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
/*!
\internal
@@ -454,7 +456,7 @@ void QSidebar::showContextMenu(const QPoint &position)
if (actions.count() > 0)
QMenu::exec(actions, mapToGlobal(position));
}
-#endif // QT_NO_MENU
+#endif // QT_CONFIG(menu)
/*!
\internal
diff --git a/src/widgets/dialogs/qsidebar_p.h b/src/widgets/dialogs/qsidebar_p.h
index 58ac3569d5..07aaa5abd2 100644
--- a/src/widgets/dialogs/qsidebar_p.h
+++ b/src/widgets/dialogs/qsidebar_p.h
@@ -148,7 +148,7 @@ protected:
private Q_SLOTS:
void clicked(const QModelIndex &index);
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
void showContextMenu(const QPoint &position);
#endif
void removeEntry();
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp
index f5dfe76c39..8b90028fbb 100644
--- a/src/widgets/dialogs/qwizard.cpp
+++ b/src/widgets/dialogs/qwizard.cpp
@@ -40,7 +40,9 @@
#include "qwizard.h"
#include <QtWidgets/private/qtwidgetsglobal_p.h>
+#if QT_CONFIG(spinbox)
#include "qabstractspinbox.h"
+#endif
#include "qalgorithms.h"
#include "qapplication.h"
#include "qboxlayout.h"
@@ -50,7 +52,9 @@
#include "qevent.h"
#include "qframe.h"
#include "qlabel.h"
+#if QT_CONFIG(lineedit)
#include "qlineedit.h"
+#endif
#include "qpainter.h"
#include "qwindow.h"
#include "qpushbutton.h"
@@ -3680,13 +3684,13 @@ bool QWizardPage::isComplete() const
if (value == field.initialValue)
return false;
-#ifndef QT_NO_LINEEDIT
+#if QT_CONFIG(lineedit)
if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(field.object)) {
if (!lineEdit->hasAcceptableInput())
return false;
}
#endif
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
if (QAbstractSpinBox *spinBox = qobject_cast<QAbstractSpinBox *>(field.object)) {
if (!spinBox->hasAcceptableInput())
return false;
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
index ebd245c4e7..94ce102a68 100644
--- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
@@ -53,8 +53,12 @@
#include <QtGui/qpainter.h>
#include <QtWidgets/qstyleoption.h>
#include <QtWidgets/qgraphicsview.h>
+#if QT_CONFIG(lineedit)
#include <QtWidgets/qlineedit.h>
+#endif
+#if QT_CONFIG(textedit)
#include <QtWidgets/qtextedit.h>
+#endif
QT_BEGIN_NAMESPACE
diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp
index fd4699409c..d532221092 100644
--- a/src/widgets/itemviews/qabstractitemdelegate.cpp
+++ b/src/widgets/itemviews/qabstractitemdelegate.cpp
@@ -49,10 +49,15 @@
#include <qevent.h>
#include <qstring.h>
#include <qdebug.h>
+#if QT_CONFIG(lineedit)
#include <qlineedit.h>
+#endif
+#if QT_CONFIG(textedit)
#include <qtextedit.h>
#include <qplaintextedit.h>
+#endif
#include <qapplication.h>
+#include <qvalidator.h>
#include <private/qtextengine_p.h>
#include <private/qabstractitemdelegate_p.h>
@@ -432,7 +437,7 @@ QAbstractItemDelegatePrivate::QAbstractItemDelegatePrivate()
static bool editorHandlesKeyEvent(QWidget *editor, const QKeyEvent *event)
{
-#ifndef QT_NO_TEXTEDIT
+#if QT_CONFIG(textedit)
// do not filter enter / return / tab / backtab for QTextEdit or QPlainTextEdit
if (qobject_cast<QTextEdit *>(editor) || qobject_cast<QPlainTextEdit *>(editor)) {
switch (event->key()) {
@@ -446,7 +451,7 @@ static bool editorHandlesKeyEvent(QWidget *editor, const QKeyEvent *event)
break;
}
}
-#endif // QT_NO_TEXTEDIT
+#endif // QT_CONFIG(textedit)
Q_UNUSED(editor);
Q_UNUSED(event);
@@ -535,7 +540,7 @@ bool QAbstractItemDelegatePrivate::editorEventFilter(QObject *object, QEvent *ev
bool QAbstractItemDelegatePrivate::tryFixup(QWidget *editor)
{
-#ifndef QT_NO_LINEEDIT
+#if QT_CONFIG(lineedit)
if (QLineEdit *e = qobject_cast<QLineEdit*>(editor)) {
if (!e->hasAcceptableInput()) {
#if QT_CONFIG(validator)
@@ -550,7 +555,7 @@ bool QAbstractItemDelegatePrivate::tryFixup(QWidget *editor)
}
#else
Q_UNUSED(editor)
-#endif // QT_NO_LINEEDIT
+#endif // QT_CONFIG(lineedit)
return true;
}
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index ed87de4e18..fe27be8522 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -49,8 +49,12 @@
#include <qscrollbar.h>
#include <qtooltip.h>
#include <qdatetime.h>
+#if QT_CONFIG(lineedit)
#include <qlineedit.h>
+#endif
+#if QT_CONFIG(spinbox)
#include <qspinbox.h>
+#endif
#include <qheaderview.h>
#include <qstyleditemdelegate.h>
#include <private/qabstractitemview_p.h>
@@ -4228,11 +4232,11 @@ QWidget *QAbstractItemViewPrivate::editor(const QModelIndex &index,
QWidget *focusWidget = w;
while (QWidget *fp = focusWidget->focusProxy())
focusWidget = fp;
-#ifndef QT_NO_LINEEDIT
+#if QT_CONFIG(lineedit)
if (QLineEdit *le = qobject_cast<QLineEdit*>(focusWidget))
le->selectAll();
#endif
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
if (QSpinBox *sb = qobject_cast<QSpinBox*>(focusWidget))
sb->selectAll();
else if (QDoubleSpinBox *dsb = qobject_cast<QDoubleSpinBox*>(focusWidget))
diff --git a/src/widgets/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp
index b1e9af1f0f..1d8e03569d 100644
--- a/src/widgets/itemviews/qitemeditorfactory.cpp
+++ b/src/widgets/itemviews/qitemeditorfactory.cpp
@@ -50,8 +50,12 @@
#if QT_CONFIG(label)
#include <qlabel.h>
#endif
+#if QT_CONFIG(lineedit)
#include <qlineedit.h>
+#endif
+#if QT_CONFIG(spinbox)
#include <qspinbox.h>
+#endif
#include <qstyle.h>
#include <qstyleoption.h>
#include <limits.h>
@@ -80,7 +84,7 @@ public:
#endif // QT_CONFIG(combobox)
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
class QUIntSpinBox : public QSpinBox
{
@@ -107,7 +111,7 @@ Q_SIGNALS:
void uintValueChanged();
};
-#endif // QT_NO_SPINBOX
+#endif // QT_CONFIG(spinbox)
/*!
\class QItemEditorFactory
@@ -242,7 +246,7 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent)
cb->setFrame(false);
return cb; }
#endif
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
case QVariant::UInt: {
QSpinBox *sb = new QUIntSpinBox(parent);
sb->setFrame(false);
@@ -274,7 +278,7 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent)
case QVariant::Pixmap:
return new QLabel(parent);
#endif
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
case QVariant::Double: {
QDoubleSpinBox *sb = new QDoubleSpinBox(parent);
sb->setFrame(false);
@@ -282,7 +286,7 @@ QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent)
sb->setMaximum(DBL_MAX);
return sb; }
#endif
-#ifndef QT_NO_LINEEDIT
+#if QT_CONFIG(lineedit)
case QVariant::String:
default: {
// the default editor is a lineedit
@@ -306,7 +310,7 @@ QByteArray QDefaultItemEditorFactory::valuePropertyName(int userType) const
case QVariant::Bool:
return "currentIndex";
#endif
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
case QVariant::UInt:
case QVariant::Int:
case QVariant::Double:
@@ -535,7 +539,7 @@ QItemEditorCreatorBase::~QItemEditorCreatorBase()
\reimp
*/
-#ifndef QT_NO_LINEEDIT
+#if QT_CONFIG(lineedit)
QExpandingLineEdit::QExpandingLineEdit(QWidget *parent)
: QLineEdit(parent), originalWidth(-1), widgetOwnsGeometry(false)
@@ -595,7 +599,7 @@ void QExpandingLineEdit::resizeToContents()
}
}
-#endif // QT_NO_LINEEDIT
+#endif // QT_CONFIG(lineedit)
#if QT_CONFIG(combobox)
@@ -620,7 +624,7 @@ bool QBooleanComboBox::value() const
QT_END_NAMESPACE
-#if !defined(QT_NO_LINEEDIT) || QT_CONFIG(combobox)
+#if QT_CONFIG(lineedit) || QT_CONFIG(combobox)
#include "qitemeditorfactory.moc"
#endif
diff --git a/src/widgets/itemviews/qitemeditorfactory_p.h b/src/widgets/itemviews/qitemeditorfactory_p.h
index 1b7718192c..e78f42b729 100644
--- a/src/widgets/itemviews/qitemeditorfactory_p.h
+++ b/src/widgets/itemviews/qitemeditorfactory_p.h
@@ -53,9 +53,9 @@
#include <QtWidgets/private/qtwidgetsglobal_p.h>
-#include <qlineedit.h>
-#ifndef QT_NO_LINEEDIT
+#if QT_CONFIG(lineedit)
+#include <qlineedit.h>
QT_REQUIRE_CONFIG(itemviews);
@@ -89,6 +89,6 @@ private:
QT_END_NAMESPACE
-#endif // QT_NO_LINEEDIT
+#endif // QT_CONFIG(lineedit)
#endif //QITEMEDITORFACTORY_P_H
diff --git a/src/widgets/itemviews/qstyleditemdelegate.cpp b/src/widgets/itemviews/qstyleditemdelegate.cpp
index bda3325adb..716df2c729 100644
--- a/src/widgets/itemviews/qstyleditemdelegate.cpp
+++ b/src/widgets/itemviews/qstyleditemdelegate.cpp
@@ -42,9 +42,13 @@
#include <qabstractitemmodel.h>
#include <qapplication.h>
#include <qbrush.h>
+#if QT_CONFIG(lineedit)
#include <qlineedit.h>
+#endif
+#if QT_CONFIG(textedit)
#include <qtextedit.h>
#include <qplaintextedit.h>
+#endif
#include <qpainter.h>
#include <qpalette.h>
#include <qpoint.h>
@@ -501,7 +505,7 @@ void QStyledItemDelegate::updateEditorGeometry(QWidget *editor,
// let the editor take up all available space
//if the editor is not a QLineEdit
//or it is in a QTableView
-#if QT_CONFIG(tableview) && !defined(QT_NO_LINEEDIT)
+#if QT_CONFIG(tableview) && QT_CONFIG(lineedit)
if (qobject_cast<QExpandingLineEdit*>(editor) && !qobject_cast<const QTableView*>(widget))
opt.showDecorationSelected = editor->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, 0, editor);
else
diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp
index a7116b1462..2813340ea2 100644
--- a/src/widgets/kernel/qaction.cpp
+++ b/src/widgets/kernel/qaction.cpp
@@ -48,7 +48,9 @@
#include "qstylehints.h"
#include <private/qshortcutmap_p.h>
#include <private/qapplication_p.h>
+#if QT_CONFIG(menu)
#include <private/qmenu_p.h>
+#endif
#include <private/qdebug_p.h>
#define QAPP_CHECK(functionName) \
@@ -645,7 +647,7 @@ QIcon QAction::icon() const
return d->icon;
}
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
/*!
Returns the menu contained by this action. Actions that contain
menus can be used to create menu items with submenus, or inserted
@@ -672,7 +674,7 @@ void QAction::setMenu(QMenu *menu)
menu->d_func()->setOverrideMenuAction(this);
d->sendDataChanged();
}
-#endif // QT_NO_MENU
+#endif // QT_CONFIG(menu)
/*!
If \a b is true then this action will be considered a separator.
diff --git a/src/widgets/kernel/qaction.h b/src/widgets/kernel/qaction.h
index 2cb30d0fc9..84bf92d2ac 100644
--- a/src/widgets/kernel/qaction.h
+++ b/src/widgets/kernel/qaction.h
@@ -121,7 +121,7 @@ public:
void setPriority(Priority priority);
Priority priority() const;
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
QMenu *menu() const;
void setMenu(QMenu *menu);
#endif
diff --git a/src/widgets/kernel/qaction_p.h b/src/widgets/kernel/qaction_p.h
index 4c1537b63b..19ae47c7b9 100644
--- a/src/widgets/kernel/qaction_p.h
+++ b/src/widgets/kernel/qaction_p.h
@@ -53,7 +53,9 @@
#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QtWidgets/qaction.h"
+#if QT_CONFIG(menu)
#include "QtWidgets/qmenu.h"
+#endif
#if QT_CONFIG(graphicsview)
#include "private/qgraphicswidget_p.h"
#endif
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index d141abce24..93e2db4b1a 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -2228,8 +2228,15 @@ QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool
if (test->isWindow())
seenWindow = true;
+ // If the next focus widget has a focus proxy, we need to check to ensure
+ // that the proxy is in the correct parent-child direction (according to
+ // \a next). This is to ensure that we can tab in and out of compound widgets
+ // without getting stuck in a tab-loop between parent and child.
+ QWidget *focusProxy = test->d_func()->deepestFocusProxy();
+
if ((test->focusPolicy() & focus_flag) == focus_flag
- && !(test->d_func()->extra && test->d_func()->extra->focus_proxy)
+ && !(next && focusProxy && focusProxy->isAncestorOf(test))
+ && !(!next && focusProxy && test->isAncestorOf(focusProxy))
&& test->isVisibleTo(toplevel) && test->isEnabled()
&& !(w->windowType() == Qt::SubWindow && !w->isAncestorOf(test))
&& (toplevel->windowType() != Qt::SubWindow || toplevel->isAncestorOf(test))) {
diff --git a/src/widgets/kernel/qdesktopwidget.cpp b/src/widgets/kernel/qdesktopwidget.cpp
index ff32540715..09e39c7cff 100644
--- a/src/widgets/kernel/qdesktopwidget.cpp
+++ b/src/widgets/kernel/qdesktopwidget.cpp
@@ -352,26 +352,8 @@ int QDesktopWidget::screenNumber(const QPoint &p) const
int QDesktopWidgetPrivate::screenNumber(const QPoint &p)
{
- const QList<QScreen *> screens = QGuiApplication::screens();
- if (!screens.isEmpty()) {
- const QList<QScreen *> primaryScreens = screens.first()->virtualSiblings();
- // Find the screen index on the primary virtual desktop first
- foreach (QScreen *screen, primaryScreens) {
- if (screen->geometry().contains(p))
- return screens.indexOf(screen);
- }
- // If the screen index is not found on primary virtual desktop, find
- // the screen index on all screens except the first which was for
- // sure in the previous loop. Some other screens may repeat. Find
- // only when there is more than one virtual desktop.
- if (screens.count() != primaryScreens.count()) {
- for (int i = 1; i < screens.size(); ++i) {
- if (screens[i]->geometry().contains(p))
- return i;
- }
- }
- }
- return primaryScreen(); //even better would be closest screen
+ QScreen *screen = QGuiApplication::screenAt(p);
+ return screen ? QGuiApplication::screens().indexOf(screen) : primaryScreen();
}
void QDesktopWidget::resizeEvent(QResizeEvent *)
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index 129c12885a..1e455b0d64 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -41,9 +41,13 @@
#include "qapplication.h"
#include "qlayoutengine_p.h"
+#if QT_CONFIG(menubar)
#include "qmenubar.h"
+#endif
#include "qtoolbar.h"
+#if QT_CONFIG(sizegrip)
#include "qsizegrip.h"
+#endif
#include "qevent.h"
#include "qstyle.h"
#include "qvariant.h"
@@ -583,7 +587,7 @@ void QLayoutPrivate::doResize(const QSize &r)
const int mbTop = rect.top();
rect.setTop(mbTop + mbh);
q->setGeometry(rect);
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (menubar)
menubar->setGeometry(rect.left(), mbTop, r.width(), mbh);
#endif
@@ -615,7 +619,7 @@ void QLayout::widgetEvent(QEvent *e)
{
QChildEvent *c = (QChildEvent *)e;
if (c->child()->isWidgetType()) {
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (c->child() == d->menubar)
d->menubar = 0;
#endif
@@ -664,7 +668,7 @@ int QLayout::totalHeightForWidth(int w) const
top += wd->topmargin + wd->bottommargin;
}
int h = heightForWidth(w - side) + top;
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
h += menuBarHeightForWidth(d->menubar, w);
#endif
return h;
@@ -687,7 +691,7 @@ QSize QLayout::totalMinimumSize() const
}
QSize s = minimumSize();
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
top += menuBarHeightForWidth(d->menubar, s.width() + side);
#endif
return s + QSize(side, top);
@@ -712,7 +716,7 @@ QSize QLayout::totalSizeHint() const
QSize s = sizeHint();
if (hasHeightForWidth())
s.setHeight(heightForWidth(s.width() + side));
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
top += menuBarHeightForWidth(d->menubar, s.width());
#endif
return s + QSize(side, top);
@@ -735,7 +739,7 @@ QSize QLayout::totalMaximumSize() const
}
QSize s = maximumSize();
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
top += menuBarHeightForWidth(d->menubar, s.width());
#endif
@@ -813,7 +817,7 @@ void QLayoutPrivate::reparentChildWidgets(QWidget *mw)
Q_Q(QLayout);
int n = q->count();
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (menubar && menubar->parentWidget() != mw) {
menubar->setParent(mw);
}
diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp
index 51793bf060..0bdac43c56 100644
--- a/src/widgets/kernel/qlayoutitem.cpp
+++ b/src/widgets/kernel/qlayoutitem.cpp
@@ -41,7 +41,9 @@
#include "qapplication.h"
#include "qlayoutengine_p.h"
+#if QT_CONFIG(menubar)
#include "qmenubar.h"
+#endif
#include "qtoolbar.h"
#include "qevent.h"
#include "qstyle.h"
diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp
index 891cf563d6..0585a59e89 100644
--- a/src/widgets/kernel/qshortcut.cpp
+++ b/src/widgets/kernel/qshortcut.cpp
@@ -45,8 +45,12 @@
#if QT_CONFIG(whatsthis)
#include <qwhatsthis.h>
#endif
+#if QT_CONFIG(menu)
#include <qmenu.h>
+#endif
+#if QT_CONFIG(menubar)
#include <qmenubar.h>
+#endif
#include <qapplication.h>
#include <private/qapplication_p.h>
#include <private/qshortcutmap_p.h>
@@ -143,7 +147,7 @@ bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context)
static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidget *active_window)
{
bool visible = w->isVisible();
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (QMenuBar *menuBar = qobject_cast<QMenuBar *>(w)) {
if (menuBar->isNativeMenuBar())
visible = true;
@@ -208,7 +212,7 @@ static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidge
static bool correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsWidget *w, QWidget *active_window)
{
bool visible = w->isVisible();
-#if defined(Q_OS_DARWIN) && !defined(QT_NO_MENUBAR)
+#if defined(Q_OS_DARWIN) && QT_CONFIG(menubar)
if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast<QMenuBar *>(w))
visible = true;
#endif
@@ -274,7 +278,7 @@ static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidge
#endif
for (int i = 0; i < widgets.size(); ++i) {
QWidget *w = widgets.at(i);
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
if (QMenu *menu = qobject_cast<QMenu *>(w)) {
#ifdef Q_OS_DARWIN
// On Mac, menu item shortcuts are processed before reaching any window.
diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp
index 12badcee3d..f30a83611d 100644
--- a/src/widgets/kernel/qtooltip.cpp
+++ b/src/widgets/kernel/qtooltip.cpp
@@ -40,6 +40,8 @@
# include <private/qcore_mac_p.h>
#endif
+#include <QtWidgets/private/qtwidgetsglobal_p.h>
+
#include <qapplication.h>
#include <qdesktopwidget.h>
#include <private/qdesktopwidget_p.h>
@@ -49,7 +51,9 @@
#include <qstyleoption.h>
#include <qstylepainter.h>
#include <qtimer.h>
+#if QT_CONFIG(effects)
#include <private/qeffects_p.h>
+#endif
#include <qtextdocument.h>
#include <qdebug.h>
#include <private/qstylesheetstyle_p.h>
@@ -286,7 +290,7 @@ void QTipLabel::timerEvent(QTimerEvent *e)
|| e->timerId() == expireTimer.timerId()){
hideTimer.stop();
expireTimer.stop();
-#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && !defined(QT_NO_EFFECTS)
+#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && QT_CONFIG(effects)
if (QApplication::isEffectEnabled(Qt::UI_FadeTooltip)){
// Fade out tip on mac (makes it invisible).
// The tip will not be deleted until a new tip is shown.
@@ -506,7 +510,7 @@ void QToolTip::showText(const QPoint &pos, const QString &text, QWidget *w, cons
QTipLabel::instance->setObjectName(QLatin1String("qtooltip_label"));
-#if !defined(QT_NO_EFFECTS) && !0 /* Used to be included in Qt4 for Q_WS_MAC */
+#if QT_CONFIG(effects) && !0 /* Used to be included in Qt4 for Q_WS_MAC */
if (QApplication::isEffectEnabled(Qt::UI_FadeTooltip))
qFadeEffect(QTipLabel::instance);
else if (QApplication::isEffectEnabled(Qt::UI_AnimateTooltip))
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index c245c7e2e7..4794a26804 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -45,7 +45,9 @@
#include "qdesktopwidget_p.h"
#include "qevent.h"
#include "qlayout.h"
+#if QT_CONFIG(menu)
#include "qmenu.h"
+#endif
#include "qmetaobject.h"
#include "qpixmap.h"
#include "qpointer.h"
@@ -2439,7 +2441,7 @@ void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int
{
Q_Q(const QWidget);
-#ifndef QT_NO_SCROLLAREA
+#if QT_CONFIG(scrollarea)
bool resetBrushOrigin = false;
QPointF oldBrushOrigin;
//If we are painting the viewport of a scrollarea, we must apply an offset to the brush in case we are drawing a texture
@@ -2452,7 +2454,7 @@ void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int
painter->setBrushOrigin(-priv->contentsOffset());
}
-#endif // QT_NO_SCROLLAREA
+#endif // QT_CONFIG(scrollarea)
const QBrush autoFillBrush = q->palette().brush(q->backgroundRole());
@@ -2479,10 +2481,10 @@ void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int
q->style()->drawPrimitive(QStyle::PE_Widget, &opt, painter, q);
}
-#ifndef QT_NO_SCROLLAREA
+#if QT_CONFIG(scrollarea)
if (resetBrushOrigin)
painter->setBrushOrigin(oldBrushOrigin);
-#endif // QT_NO_SCROLLAREA
+#endif // QT_CONFIG(scrollarea)
}
/*
@@ -6521,9 +6523,9 @@ void QWidget::setFocus(Qt::FocusReason reason)
if (!isEnabled())
return;
- QWidget *f = this;
- while (f->d_func()->extra && f->d_func()->extra->focus_proxy)
- f = f->d_func()->extra->focus_proxy;
+ QWidget *f = d_func()->deepestFocusProxy();
+ if (!f)
+ f = this;
if (QApplication::focusWidget() == f
#if 0 // Used to be included in Qt4 for Q_WS_WIN
@@ -6620,6 +6622,27 @@ void QWidget::setFocus(Qt::FocusReason reason)
}
}
+
+/*!\internal
+ * A focus proxy can have its own focus proxy, which can have its own
+ * proxy, and so on. This helper function returns the widget that sits
+ * at the bottom of the proxy chain, and therefore the one that should
+ * normally get focus if this widget receives a focus request.
+ */
+QWidget *QWidgetPrivate::deepestFocusProxy() const
+{
+ Q_Q(const QWidget);
+
+ QWidget *focusProxy = q->focusProxy();
+ if (!focusProxy)
+ return nullptr;
+
+ while (QWidget *nextFocusProxy = focusProxy->focusProxy())
+ focusProxy = nextFocusProxy;
+
+ return focusProxy;
+}
+
void QWidgetPrivate::setFocus_sys()
{
Q_Q(QWidget);
@@ -8983,7 +9006,7 @@ bool QWidget::event(QEvent *event)
case Qt::CustomContextMenu:
emit customContextMenuRequested(static_cast<QContextMenuEvent *>(event)->pos());
break;
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
case Qt::ActionsContextMenu:
if (d->actions.count()) {
QMenu::exec(d->actions, static_cast<QContextMenuEvent *>(event)->globalPos(),
diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h
index 57da51dcba..26f8b53392 100644
--- a/src/widgets/kernel/qwidget_p.h
+++ b/src/widgets/kernel/qwidget_p.h
@@ -369,6 +369,7 @@ public:
void lower_sys();
void stackUnder_sys(QWidget *);
+ QWidget *deepestFocusProxy() const;
void setFocus_sys();
void updateFocusChild();
diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp
index a17c69c5ce..d2ad7a466e 100644
--- a/src/widgets/kernel/qwindowcontainer.cpp
+++ b/src/widgets/kernel/qwindowcontainer.cpp
@@ -44,7 +44,9 @@
#include <qpa/qplatformintegration.h>
#include <QDebug>
+#if QT_CONFIG(mdiarea)
#include <QMdiSubWindow>
+#endif
#include <QAbstractScrollArea>
QT_BEGIN_NAMESPACE
@@ -98,10 +100,10 @@ public:
QWidget *p = q->parentWidget();
while (p) {
if (false
-#ifndef QT_NO_MDIAREA
+#if QT_CONFIG(mdiarea)
|| qobject_cast<QMdiSubWindow *>(p) != 0
#endif
-#ifndef QT_NO_SCROLLAREA
+#if QT_CONFIG(scrollarea)
|| qobject_cast<QAbstractScrollArea *>(p) != 0
#endif
) {
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index d5b8d2b32b..0ad508afd2 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -65,11 +65,15 @@
#include <qgroupbox.h>
#endif
#include <qmath.h>
+#if QT_CONFIG(menu)
#include <qmenu.h>
+#endif
#include <qpainter.h>
#include <qpaintengine.h>
#include <qpainterpath.h>
+#if QT_CONFIG(slider)
#include <qslider.h>
+#endif
#include <qstyleoption.h>
#if QT_CONFIG(tabbar)
#include <qtabbar.h>
@@ -512,7 +516,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
break;
}
#endif // QT_NO_TOOLBAR
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
case PE_IndicatorSpinPlus:
case PE_IndicatorSpinMinus: {
QRect r = opt->rect;
@@ -570,7 +574,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
}
p->restore();
break; }
-#endif // QT_NO_SPINBOX
+#endif // QT_CONFIG(spinbox)
case PE_PanelTipLabel: {
const QBrush brush(opt->palette.toolTipBase());
qDrawPlainRect(p, opt->rect, opt->palette.toolTipText().color(), 1, &brush);
@@ -611,7 +615,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
}
break;
#endif // QT_CONFIG(tabbar)
-#ifndef QT_NO_LINEEDIT
+#if QT_CONFIG(lineedit)
case PE_PanelLineEdit:
if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
p->fillRect(panel->rect.adjusted(panel->lineWidth, panel->lineWidth, -panel->lineWidth, -panel->lineWidth),
@@ -621,7 +625,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
proxy()->drawPrimitive(PE_FrameLineEdit, panel, p, widget);
}
break;
-#endif // QT_NO_LINEEDIT
+#endif // QT_CONFIG(lineedit)
#if QT_CONFIG(columnview)
case PE_IndicatorColumnViewArrow: {
if (const QStyleOptionViewItem *viewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
@@ -1371,7 +1375,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
}
}
break;
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
case CE_MenuScroller: {
QStyleOption arrowOpt = *opt;
arrowOpt.state |= State_Enabled;
@@ -1391,8 +1395,8 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
p->drawLine(opt->rect.x() + 2, opt->rect.y() + opt->rect.height() / 2,
opt->rect.x() + opt->rect.width() - 4, opt->rect.y() + opt->rect.height() / 2);
break;
-#endif // QT_NO_MENU
-#ifndef QT_NO_MENUBAR
+#endif // QT_CONFIG(menu)
+#if QT_CONFIG(menubar)
case CE_MenuBarItem:
if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip
@@ -1412,7 +1416,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
if (widget && !widget->testAttribute(Qt::WA_NoSystemBackground))
p->eraseRect(opt->rect);
break;
-#endif // QT_NO_MENUBAR
+#endif // QT_CONFIG(menubar)
#if QT_CONFIG(progressbar)
case CE_ProgressBar:
if (const QStyleOptionProgressBar *pb
@@ -1940,7 +1944,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
}
break;
#endif // QT_CONFIG(tabbar)
-#ifndef QT_NO_SIZEGRIP
+#if QT_CONFIG(sizegrip)
case CE_SizeGrip: {
p->save();
int x, y, w, h;
@@ -2013,7 +2017,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
}
p->restore();
break; }
-#endif // QT_NO_SIZEGRIP
+#endif // QT_CONFIG(sizegrip)
#if QT_CONFIG(rubberband)
case CE_RubberBand: {
if (const QStyleOptionRubberBand *rbOpt = qstyleoption_cast<const QStyleOptionRubberBand *>(opt)) {
@@ -2472,7 +2476,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
r = visualRect(btn->direction, btn->rect, r);
}
break;
-#ifndef QT_NO_SLIDER
+#if QT_CONFIG(slider)
case SE_SliderFocusRect:
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget);
@@ -2485,7 +2489,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
r = visualRect(opt->direction, opt->rect, r);
}
break;
-#endif // QT_NO_SLIDER
+#endif // QT_CONFIG(slider)
#if QT_CONFIG(progressbar)
case SE_ProgressBarGroove:
case SE_ProgressBarContents:
@@ -3140,7 +3144,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
QPainter *p, const QWidget *widget) const
{
switch (cc) {
-#ifndef QT_NO_SLIDER
+#if QT_CONFIG(slider)
case CC_Slider:
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
if (slider->subControls == SC_SliderTickmarks) {
@@ -3196,7 +3200,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
}
}
break;
-#endif // QT_NO_SLIDER
+#endif // QT_CONFIG(slider)
#if QT_CONFIG(scrollbar)
case CC_ScrollBar:
if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
@@ -3285,7 +3289,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
}
break;
#endif // QT_CONFIG(scrollbar)
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
case CC_SpinBox:
if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
QStyleOptionSpinBox copy = *sb;
@@ -3349,7 +3353,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
}
}
break;
-#endif // QT_NO_SPINBOX
+#endif // QT_CONFIG(spinbox)
#if QT_CONFIG(toolbutton)
case CC_ToolButton:
if (const QStyleOptionToolButton *toolbutton
@@ -3745,7 +3749,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
}
break;
#endif // QT_CONFIG(groupbox)
-#ifndef QT_NO_MDIAREA
+#if QT_CONFIG(mdiarea)
case CC_MdiControls:
{
QStyleOptionButton btnOpt;
@@ -3808,7 +3812,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
}
}
break;
-#endif // QT_NO_MDIAREA
+#endif // QT_CONFIG(mdiarea)
default:
qWarning("QCommonStyle::drawComplexControl: Control %d not handled", cc);
}
@@ -3822,7 +3826,7 @@ QStyle::SubControl QCommonStyle::hitTestComplexControl(ComplexControl cc, const
{
SubControl sc = SC_None;
switch (cc) {
-#ifndef QT_NO_SLIDER
+#if QT_CONFIG(slider)
case CC_Slider:
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
QRect r = proxy()->subControlRect(cc, slider, SC_SliderHandle, widget);
@@ -3835,7 +3839,7 @@ QStyle::SubControl QCommonStyle::hitTestComplexControl(ComplexControl cc, const
}
}
break;
-#endif // QT_NO_SLIDER
+#endif // QT_CONFIG(slider)
#if QT_CONFIG(scrollbar)
case CC_ScrollBar:
if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
@@ -3868,7 +3872,7 @@ QStyle::SubControl QCommonStyle::hitTestComplexControl(ComplexControl cc, const
}
break;
#endif // QT_CONFIG(toolbutton)
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
case CC_SpinBox:
if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
QRect r;
@@ -3883,7 +3887,7 @@ QStyle::SubControl QCommonStyle::hitTestComplexControl(ComplexControl cc, const
}
}
break;
-#endif // QT_NO_SPINBOX
+#endif // QT_CONFIG(spinbox)
case CC_TitleBar:
if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
QRect r;
@@ -3959,7 +3963,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex
{
QRect ret;
switch (cc) {
-#ifndef QT_NO_SLIDER
+#if QT_CONFIG(slider)
case CC_Slider:
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget);
@@ -3994,7 +3998,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex
ret = visualRect(slider->direction, slider->rect, ret);
}
break;
-#endif // QT_NO_SLIDER
+#endif // QT_CONFIG(slider)
#if QT_CONFIG(scrollbar)
case CC_ScrollBar:
if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
@@ -4080,7 +4084,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex
}
break;
#endif // QT_CONFIG(scrollbar)
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
case CC_SpinBox:
if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
QSize bs;
@@ -4339,7 +4343,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex
break;
}
#endif // QT_CONFIG(groupbox)
-#ifndef QT_NO_MDIAREA
+#if QT_CONFIG(mdiarea)
case CC_MdiControls:
{
int numSubControls = 0;
@@ -4382,7 +4386,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex
ret = QRect(offset, 0, buttonWidth, opt->rect.height());
break;
}
-#endif // QT_NO_MDIAREA
+#endif // QT_CONFIG(mdiarea)
default:
qWarning("QCommonStyle::subControlRect: Case %d not handled", cc);
}
@@ -4497,7 +4501,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid
ret = QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::MaximumScrollBarDragDistance).toInt();
break;
-#ifndef QT_NO_SLIDER
+#if QT_CONFIG(slider)
case PM_SliderThickness:
ret = int(QStyleHelper::dpiScaled(16.));
break;
@@ -4530,7 +4534,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid
ret = 0;
}
break;
-#endif // QT_NO_SLIDER
+#endif // QT_CONFIG(slider)
#if QT_CONFIG(dockwidget)
case PM_DockWidgetSeparatorExtent:
ret = int(QStyleHelper::dpiScaled(6.));
@@ -4812,7 +4816,7 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
sz.setHeight(qMax(sz.height(), h));
}
break;
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
case CT_MenuItem:
if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
bool checkable = mi->menuHasCheckableItems;
@@ -4840,7 +4844,7 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
sz = QSize(w, h);
}
break;
-#endif // QT_NO_MENU
+#endif // QT_CONFIG(menu)
#if QT_CONFIG(toolbutton)
case CT_ToolButton:
sz = QSize(sz.width() + 6, sz.height() + 5);
@@ -4917,7 +4921,7 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
#else
Q_UNUSED(d);
#endif // QT_CONFIG(itemviews)
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
case CT_SpinBox:
if (const QStyleOptionSpinBox *vopt = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
// Add button + frame widths
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index f20ffb0f92..074aa3ecec 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -55,7 +55,9 @@
#include <qdir.h>
#include <qstyleoption.h>
#include <qapplication.h>
+#if QT_CONFIG(mainwindow)
#include <qmainwindow.h>
+#endif
#include <qfont.h>
#if QT_CONFIG(groupbox)
#include <qgroupbox.h>
@@ -64,11 +66,15 @@
#if QT_CONFIG(scrollbar)
#include <qscrollbar.h>
#endif
+#if QT_CONFIG(spinbox)
#include <qspinbox.h>
+#endif
#if QT_CONFIG(abstractslider)
#include <qabstractslider.h>
#endif
+#if QT_CONFIG(slider)
#include <qslider.h>
+#endif
#if QT_CONFIG(splitter)
#include <qsplitter.h>
#endif
diff --git a/src/widgets/styles/qpixmapstyle.cpp b/src/widgets/styles/qpixmapstyle.cpp
index 975ebfcdbf..976bd2630e 100644
--- a/src/widgets/styles/qpixmapstyle.cpp
+++ b/src/widgets/styles/qpixmapstyle.cpp
@@ -43,7 +43,9 @@
#include "qpixmapstyle_p_p.h"
#include <QDebug>
+#if QT_CONFIG(textedit)
#include <QTextEdit>
+#endif
#include <QStringBuilder>
#include <QPainter>
#include <QPixmapCache>
@@ -52,7 +54,9 @@
#if QT_CONFIG(progressbar)
#include <QProgressBar>
#endif
+#if QT_CONFIG(slider)
#include <QSlider>
+#endif
#include <QEvent>
#if QT_CONFIG(combobox)
#include <QComboBox>
diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp
index 94376a63e3..e560e713fb 100644
--- a/src/widgets/styles/qstylehelper.cpp
+++ b/src/widgets/styles/qstylehelper.cpp
@@ -69,13 +69,13 @@ QString uniqueName(const QString &key, const QStyleOption *option, const QSize &
% HexString<uint>(size.width())
% HexString<uint>(size.height());
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
tmp = tmp % HexString<uint>(spinBox->buttonSymbols)
% HexString<uint>(spinBox->stepEnabled)
% QLatin1Char(spinBox->frame ? '1' : '0'); ;
}
-#endif // QT_NO_SPINBOX
+#endif // QT_CONFIG(spinbox)
// QTBUG-56743, try to create a palette cache key reflecting the value,
// as leaks may occur in conjunction with QStyleSheetStyle/QRenderRule modifying
diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp
index a346ee18c4..28bdadcdd1 100644
--- a/src/widgets/styles/qstyleoption.cpp
+++ b/src/widgets/styles/qstyleoption.cpp
@@ -1949,7 +1949,7 @@ QStyleOptionComplex::QStyleOptionComplex(int version, int type)
\sa QStyle::SubControl
*/
-#ifndef QT_NO_SLIDER
+#if QT_CONFIG(slider)
/*!
\class QStyleOptionSlider
\brief The QStyleOptionSlider class is used to describe the
@@ -2146,9 +2146,9 @@ QStyleOptionSlider::QStyleOptionSlider(int version)
\sa QAbstractSlider::pageStep
*/
-#endif // QT_NO_SLIDER
+#endif // QT_CONFIG(slider)
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
/*!
\class QStyleOptionSpinBox
\brief The QStyleOptionSpinBox class is used to describe the
@@ -2252,7 +2252,7 @@ QStyleOptionSpinBox::QStyleOptionSpinBox(int version)
The default value is false, i.e. the spin box has no frame.
*/
-#endif // QT_NO_SPINBOX
+#endif // QT_CONFIG(spinbox)
/*!
\class QStyleOptionDockWidget
@@ -3554,7 +3554,7 @@ QStyleOptionTabBarBase::QStyleOptionTabBarBase(int version)
#endif // QT_CONFIG(tabbar)
-#ifndef QT_NO_SIZEGRIP
+#if QT_CONFIG(sizegrip)
/*!
\class QStyleOptionSizeGrip
\brief The QStyleOptionSizeGrip class is used to describe the
@@ -3634,7 +3634,7 @@ QStyleOptionSizeGrip::QStyleOptionSizeGrip(int version)
\sa StyleOptionType
*/
-#endif // QT_NO_SIZEGRIP
+#endif // QT_CONFIG(sizegrip)
/*!
\class QStyleOptionGraphicsItem
diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h
index 36dc65151c..2880917510 100644
--- a/src/widgets/styles/qstyleoption.h
+++ b/src/widgets/styles/qstyleoption.h
@@ -41,11 +41,16 @@
#define QSTYLEOPTION_H
#include <QtWidgets/qtwidgetsglobal.h>
+#include <QtCore/qlocale.h>
#include <QtCore/qvariant.h>
+#if QT_CONFIG(spinbox)
#include <QtWidgets/qabstractspinbox.h>
+#endif
#include <QtGui/qicon.h>
#include <QtGui/qmatrix.h>
+#if QT_CONFIG(slider)
#include <QtWidgets/qslider.h>
+#endif
#include <QtWidgets/qstyle.h>
#if QT_CONFIG(tabbar)
#include <QtWidgets/qtabbar.h>
@@ -505,7 +510,7 @@ public:
QStyleOptionComplex(const QStyleOptionComplex &other) : QStyleOption(Version, Type) { *this = other; }
};
-#ifndef QT_NO_SLIDER
+#if QT_CONFIG(slider)
class Q_WIDGETS_EXPORT QStyleOptionSlider : public QStyleOptionComplex
{
public:
@@ -531,9 +536,9 @@ public:
protected:
QStyleOptionSlider(int version);
};
-#endif // QT_NO_SLIDER
+#endif // QT_CONFIG(slider)
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
class Q_WIDGETS_EXPORT QStyleOptionSpinBox : public QStyleOptionComplex
{
public:
@@ -550,7 +555,7 @@ public:
protected:
QStyleOptionSpinBox(int version);
};
-#endif // QT_NO_SPINBOX
+#endif // QT_CONFIG(spinbox)
class Q_WIDGETS_EXPORT QStyleOptionToolButton : public QStyleOptionComplex
{
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 6b611ab2b4..fd812d8d0d 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -45,11 +45,17 @@
#include "private/qcssutil_p.h"
#include <qdebug.h>
#include <qapplication.h>
+#if QT_CONFIG(menu)
#include <qmenu.h>
+#endif
+#if QT_CONFIG(menubar)
#include <qmenubar.h>
+#endif
#include <qpainter.h>
#include <qstyleoption.h>
+#if QT_CONFIG(lineedit)
#include <qlineedit.h>
+#endif
#include <private/qwindowsstyle_p.h>
#if QT_CONFIG(combobox)
#include <qcombobox.h>
@@ -83,16 +89,22 @@
#include <qtabbar.h>
#endif
#include <QMetaProperty>
+#if QT_CONFIG(mainwindow)
#include <qmainwindow.h>
+#endif
#if QT_CONFIG(dockwidget)
#include <qdockwidget.h>
#endif
+#if QT_CONFIG(mdiarea)
#include <qmdisubwindow.h>
+#endif
#if QT_CONFIG(dialog)
#include <qdialog.h>
#endif
#include <private/qwidget_p.h>
+#if QT_CONFIG(spinbox)
#include <QAbstractSpinBox>
+#endif
#if QT_CONFIG(label)
#include <QLabel>
#endif
@@ -1647,7 +1659,7 @@ int QStyleSheetStyle::nativeFrameWidth(const QWidget *w)
{
QStyle *base = baseStyle();
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
if (qobject_cast<const QAbstractSpinBox *>(w))
return base->pixelMetric(QStyle::PM_SpinBoxFrameWidth, 0, w);
#endif
@@ -1657,12 +1669,12 @@ int QStyleSheetStyle::nativeFrameWidth(const QWidget *w)
return base->pixelMetric(QStyle::PM_ComboBoxFrameWidth, 0, w);
#endif
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
if (qobject_cast<const QMenu *>(w))
return base->pixelMetric(QStyle::PM_MenuPanelWidth, 0, w);
#endif
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
if (qobject_cast<const QMenuBar *>(w))
return base->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, w);
#endif
@@ -1805,7 +1817,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption
case PseudoElement_SpinBoxDownButton:
case PseudoElement_SpinBoxUpArrow:
case PseudoElement_SpinBoxDownArrow:
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
bool on = false;
bool up = pseudoElement == PseudoElement_SpinBoxUpButton
@@ -1816,7 +1828,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption
on = true;
state |= (on ? QStyle::State_On : QStyle::State_Off);
}
-#endif // QT_NO_SPINBOX
+#endif // QT_CONFIG(spinbox)
break;
case PseudoElement_GroupBoxTitle:
state |= (complex->state & (QStyle::State_MouseOver | QStyle::State_Sunken));
@@ -1851,11 +1863,11 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption
extraClass |= PseudoClass_ReadOnly;
else
extraClass |= PseudoClass_Editable;
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
} else if (const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
if (!spin->frame)
extraClass |= PseudoClass_Frameless;
-#endif // QT_NO_SPINBOX
+#endif // QT_CONFIG(spinbox)
} else if (const QStyleOptionGroupBox *gb = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
if (gb->features & QStyleOptionFrame::Flat)
extraClass |= PseudoClass_Flat;
@@ -2034,7 +2046,7 @@ QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption
}
#endif
-#ifndef QT_NO_LINEEDIT
+#if QT_CONFIG(lineedit)
// LineEdit sets Sunken flag to indicate Sunken frame (argh)
if (const QLineEdit *lineEdit = qobject_cast<const QLineEdit *>(obj)) {
state &= ~QStyle::State_Sunken;
@@ -2360,12 +2372,12 @@ static QWidget *embeddedWidget(QWidget *w)
}
#endif
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
if (QAbstractSpinBox *sb = qobject_cast<QAbstractSpinBox *>(w))
return sb->findChild<QLineEdit *>();
#endif
-#ifndef QT_NO_SCROLLAREA
+#if QT_CONFIG(scrollarea)
if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(w))
return sa->viewport();
#endif
@@ -2382,21 +2394,21 @@ static QWidget *embeddedWidget(QWidget *w)
*/
static QWidget *containerWidget(const QWidget *w)
{
-#ifndef QT_NO_LINEEDIT
+#if QT_CONFIG(lineedit)
if (qobject_cast<const QLineEdit *>(w)) {
//if the QLineEdit is an embeddedWidget, we need the rule of the real widget
#if QT_CONFIG(combobox)
if (qobject_cast<const QComboBox *>(w->parentWidget()))
return w->parentWidget();
#endif
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
if (qobject_cast<const QAbstractSpinBox *>(w->parentWidget()))
return w->parentWidget();
#endif
}
-#endif // QT_NO_LINEEDIT
+#endif // QT_CONFIG(lineedit)
-#ifndef QT_NO_SCROLLAREA
+#if QT_CONFIG(scrollarea)
if (const QAbstractScrollArea *sa = qobject_cast<const QAbstractScrollArea *>(w->parentWidget())) {
if (sa->viewport() == w)
return w->parentWidget();
@@ -2455,7 +2467,7 @@ static quint64 extendedPseudoClass(const QWidget *w)
pc |= (combo->isEditable() ? PseudoClass_Editable : PseudoClass_ReadOnly);
} else
#endif
-#ifndef QT_NO_LINEEDIT
+#if QT_CONFIG(lineedit)
if (const QLineEdit *edit = qobject_cast<const QLineEdit *>(w)) {
pc |= (edit->isReadOnly() ? PseudoClass_ReadOnly : PseudoClass_Editable);
} else
@@ -2800,7 +2812,7 @@ void QStyleSheetStyle::polish(QWidget *w)
}
-#ifndef QT_NO_SCROLLAREA
+#if QT_CONFIG(scrollarea)
if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(w)) {
QRenderRule rule = renderRule(sa, PseudoElement_None, PseudoClass_Enabled);
if ((rule.hasBorder() && rule.border()->hasBorderImage())
@@ -2825,13 +2837,13 @@ void QStyleSheetStyle::polish(QWidget *w)
#ifndef QT_NO_FRAME
|| qobject_cast<QFrame *>(w)
#endif
-#ifndef QT_NO_MAINWINDOW
+#if QT_CONFIG(mainwindow)
|| qobject_cast<QMainWindow *>(w)
#endif
-#ifndef QT_NO_MDIAREA
+#if QT_CONFIG(mdiarea)
|| qobject_cast<QMdiSubWindow *>(w)
#endif
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
|| qobject_cast<QMenuBar *>(w)
#endif
#if QT_CONFIG(dialog)
@@ -2902,7 +2914,7 @@ void QStyleSheetStyle::unpolish(QWidget *w)
w->setProperty("_q_stylesheet_maxh", QVariant());
w->setAttribute(Qt::WA_StyleSheet, false);
QObject::disconnect(w, 0, this, 0);
-#ifndef QT_NO_SCROLLAREA
+#if QT_CONFIG(scrollarea)
if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(w)) {
QObject::disconnect(sa->horizontalScrollBar(), SIGNAL(valueChanged(int)),
sa, SLOT(update()));
@@ -2981,7 +2993,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
}
break;
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
case CC_SpinBox:
if (const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
QStyleOptionSpinBox spinOpt(*spin);
@@ -3044,7 +3056,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
return;
}
break;
-#endif // QT_NO_SPINBOX
+#endif // QT_CONFIG(spinbox)
case CC_GroupBox:
if (const QStyleOptionGroupBox *gb = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
@@ -3221,7 +3233,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
break;
#endif // QT_CONFIG(scrollbar)
-#ifndef QT_NO_SLIDER
+#if QT_CONFIG(slider)
case CC_Slider:
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
rule.drawRule(p, opt->rect);
@@ -3275,7 +3287,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
return;
}
break;
-#endif // QT_NO_SLIDER
+#endif // QT_CONFIG(slider)
case CC_MdiControls:
if (hasStyleRule(w, PseudoElement_MdiCloseButton)
@@ -4337,7 +4349,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
case PE_PanelLineEdit:
if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
if (w && qobject_cast<const QAbstractSpinBox *>(w->parentWidget())) {
QRenderRule spinboxRule = renderRule(w->parentWidget(), opt);
if (!spinboxRule.hasNativeBorder() || !spinboxRule.baseStyleCanDraw())
@@ -4374,7 +4386,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
}
break;
}
-#ifndef QT_NO_SCROLLAREA
+#if QT_CONFIG(scrollarea)
if (const QAbstractScrollArea *sa = qobject_cast<const QAbstractScrollArea *>(w)) {
const QAbstractScrollAreaPrivate *sap = sa->d_func();
rule.drawBackground(p, opt->rect, sap->contentsOffset());
@@ -4990,7 +5002,7 @@ QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *op
break;
case CT_GroupBox:
case CT_LineEdit:
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
if (qobject_cast<QAbstractSpinBox *>(w ? w->parentWidget() : 0))
return csz; // we only care about the size hint of the line edit
#endif
@@ -5388,7 +5400,7 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp
}
break;
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
case CC_SpinBox:
if (const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
QRenderRule upRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton);
@@ -5447,7 +5459,7 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp
: QWindowsStyle::subControlRect(cc, &spinBox, sc, w);
}
break;
-#endif // QT_NO_SPINBOX
+#endif // QT_CONFIG(spinbox)
case CC_GroupBox:
if (const QStyleOptionGroupBox *gb = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
@@ -5617,7 +5629,7 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp
break;
#endif // QT_CONFIG(scrollbar)
-#ifndef QT_NO_SLIDER
+#if QT_CONFIG(slider)
case CC_Slider:
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
QRenderRule subRule = renderRule(w, opt, PseudoElement_SliderGroove);
@@ -5650,7 +5662,7 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp
}
}
break;
-#endif // QT_NO_SLIDER
+#endif // QT_CONFIG(slider)
case CC_MdiControls:
if (hasStyleRule(w, PseudoElement_MdiCloseButton)
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp
index 9aaf9c6be0..9e53038348 100644
--- a/src/widgets/styles/qwindowsstyle.cpp
+++ b/src/widgets/styles/qwindowsstyle.cpp
@@ -46,9 +46,13 @@
#include "qbitmap.h"
#include "qdrawutil.h" // for now
#include "qevent.h"
+#if QT_CONFIG(menu)
#include "qmenu.h"
+#endif
+#if QT_CONFIG(menubar)
#include "qmenubar.h"
#include <private/qmenubar_p.h>
+#endif
#include "qpaintengine.h"
#include "qpainter.h"
#if QT_CONFIG(rubberband)
@@ -60,7 +64,9 @@
#endif
#include "qwidget.h"
#include "qdebug.h"
+#if QT_CONFIG(mainwindow)
#include "qmainwindow.h"
+#endif
#include "qfile.h"
#include "qtextstream.h"
#include "qpixmapcache.h"
@@ -166,7 +172,7 @@ bool QWindowsStyle::eventFilter(QObject *o, QEvent *e)
// Update state and repaint the menu bars.
d->alt_down = false;
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
QList<QMenuBar *> l = widget->findChildren<QMenuBar *>();
for (int i = 0; i < l.size(); ++i)
l.at(i)->update();
@@ -343,12 +349,12 @@ int QWindowsStylePrivate::fixedPixelMetric(QStyle::PixelMetric pm)
return 2;
#endif
-#ifndef QT_NO_SLIDER
+#if QT_CONFIG(slider)
case QStyle::PM_SliderLength:
return 11;
-#endif // QT_NO_SLIDER
+#endif // QT_CONFIG(slider)
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
case QStyle::PM_MenuBarHMargin:
case QStyle::PM_MenuBarVMargin:
case QStyle::PM_MenuBarPanelWidth:
@@ -363,7 +369,7 @@ int QWindowsStylePrivate::fixedPixelMetric(QStyle::PixelMetric pm)
case QStyle::PM_DockWidgetFrameWidth:
return 4;
-#endif // QT_NO_MENU
+#endif // QT_CONFIG(menu)
case QStyle::PM_ToolBarHandleExtent:
return 10;
default:
@@ -435,7 +441,7 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW
ret = 60;
break;
-#ifndef QT_NO_SLIDER
+#if QT_CONFIG(slider)
// 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.
@@ -463,7 +469,7 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW
ret = thick;
}
break;
-#endif // QT_NO_SLIDER
+#endif // QT_CONFIG(slider)
case PM_IconViewIconSize:
ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget);
@@ -574,7 +580,7 @@ int QWindowsStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWid
// Do nothing if we always paint underlines
Q_D(const QWindowsStyle);
if (!ret && widget && d) {
-#ifndef QT_NO_MENUBAR
+#if QT_CONFIG(menubar)
const QMenuBar *menuBar = qobject_cast<const QMenuBar *>(widget);
if (!menuBar && qobject_cast<const QMenu *>(widget)) {
QWidget *w = QApplication::activeWindow();
@@ -587,7 +593,7 @@ int QWindowsStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWid
ret = 1;
// Otherwise draw underlines if the toplevel widget has seen an alt-press
} else
-#endif // QT_NO_MENUBAR
+#endif // QT_CONFIG(menubar)
if (d->hasSeenAlt(widget)) {
ret = 1;
}
@@ -1111,7 +1117,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
break;
#endif // QT_CONFIG(rubberband)
-#if !defined(QT_NO_MENU) && !defined(QT_NO_MAINWINDOW)
+#if QT_CONFIG(menu) && QT_CONFIG(mainwindow)
case CE_MenuBarEmptyArea:
if (widget && qobject_cast<const QMainWindow *>(widget->parentWidget())) {
p->fillRect(opt->rect, opt->palette.button());
@@ -1122,7 +1128,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
}
break;
#endif
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
case CE_MenuItem:
if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
int x, y, w, h;
@@ -1259,8 +1265,8 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
}
break;
-#endif // QT_NO_MENU
-#ifndef QT_NO_MENUBAR
+#endif // QT_CONFIG(menu)
+#if QT_CONFIG(menubar)
case CE_MenuBarItem:
if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
bool active = mbi->state & State_Selected;
@@ -1284,7 +1290,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
QCommonStyle::drawControl(ce, &newMbi, p, widget);
}
break;
-#endif // QT_NO_MENUBAR
+#endif // QT_CONFIG(menubar)
#if QT_CONFIG(tabbar)
case CE_TabBarTabShape:
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
@@ -1922,7 +1928,7 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp
QPainter *p, const QWidget *widget) const
{
switch (cc) {
-#ifndef QT_NO_SLIDER
+#if QT_CONFIG(slider)
case CC_Slider:
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget);
@@ -2142,7 +2148,7 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp
}
}
break;
-#endif // QT_NO_SLIDER
+#endif // QT_CONFIG(slider)
#if QT_CONFIG(scrollbar)
case CC_ScrollBar:
if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
@@ -2227,7 +2233,7 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp
}
break;
#endif // QT_CONFIG(combobox)
-#ifndef QT_NO_SPINBOX
+#if QT_CONFIG(spinbox)
case CC_SpinBox:
if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
QStyleOptionSpinBox copy = *sb;
@@ -2316,7 +2322,7 @@ void QWindowsStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComp
}
}
break;
-#endif // QT_NO_SPINBOX
+#endif // QT_CONFIG(spinbox)
default:
QCommonStyle::drawComplexControl(cc, opt, p, widget);
@@ -2349,7 +2355,7 @@ QSize QWindowsStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
sz = QSize(w, h);
}
break;
-#ifndef QT_NO_MENU
+#if QT_CONFIG(menu)
case CT_MenuItem:
if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
int w = sz.width();
@@ -2391,8 +2397,8 @@ QSize QWindowsStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
sz.setWidth(w);
}
break;
-#endif // QT_NO_MENU
-#ifndef QT_NO_MENUBAR
+#endif // QT_CONFIG(menu)
+#if QT_CONFIG(menubar)
case CT_MenuBarItem:
if (!sz.isEmpty())
sz += QSize(QWindowsStylePrivate::windowsItemHMargin * 4, QWindowsStylePrivate::windowsItemVMargin * 2);
diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp
index 25e08c3921..d444fe6053 100644
--- a/src/widgets/util/qcompleter.cpp
+++ b/src/widgets/util/qcompleter.cpp
@@ -143,8 +143,6 @@
#include "qcompleter_p.h"
-#ifndef QT_NO_COMPLETER
-
#include "QtWidgets/qscrollbar.h"
#include "QtCore/qstringlistmodel.h"
#if QT_CONFIG(dirmodel)
@@ -161,7 +159,9 @@
#include "QtGui/qevent.h"
#include "QtWidgets/qdesktopwidget.h"
#include <private/qdesktopwidget_p.h>
+#if QT_CONFIG(lineedit)
#include "QtWidgets/qlineedit.h"
+#endif
QT_BEGIN_NAMESPACE
@@ -1920,5 +1920,3 @@ QT_END_NAMESPACE
#include "moc_qcompleter.cpp"
#include "moc_qcompleter_p.cpp"
-
-#endif // QT_NO_COMPLETER
diff --git a/src/widgets/util/qcompleter.h b/src/widgets/util/qcompleter.h
index 62c49ba8b4..de79302e15 100644
--- a/src/widgets/util/qcompleter.h
+++ b/src/widgets/util/qcompleter.h
@@ -47,10 +47,9 @@
#include <QtCore/qabstractitemmodel.h>
#include <QtCore/qrect.h>
-QT_BEGIN_NAMESPACE
-
+QT_REQUIRE_CONFIG(completer);
-#ifndef QT_NO_COMPLETER
+QT_BEGIN_NAMESPACE
class QCompleterPrivate;
class QAbstractItemView;
@@ -162,8 +161,6 @@ private:
Q_PRIVATE_SLOT(d_func(),