summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/accessible/complexwidgets.cpp32
-rw-r--r--src/widgets/accessible/complexwidgets_p.h36
-rw-r--r--src/widgets/accessible/itemviews_p.h178
-rw-r--r--src/widgets/accessible/qaccessiblemenu.cpp2
-rw-r--r--src/widgets/accessible/qaccessiblemenu_p.h54
-rw-r--r--src/widgets/accessible/qaccessiblewidget.h36
-rw-r--r--src/widgets/accessible/qaccessiblewidgets.cpp2
-rw-r--r--src/widgets/accessible/qaccessiblewidgets_p.h132
-rw-r--r--src/widgets/accessible/rangecontrols.cpp2
-rw-r--r--src/widgets/accessible/rangecontrols_p.h72
-rw-r--r--src/widgets/accessible/simplewidgets.cpp6
-rw-r--r--src/widgets/accessible/simplewidgets_p.h118
-rw-r--r--src/widgets/configure.json10
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp92
-rw-r--r--src/widgets/dialogs/qcolordialog.h14
-rw-r--r--src/widgets/dialogs/qdialog.cpp11
-rw-r--r--src/widgets/dialogs/qdialog.h2
-rw-r--r--src/widgets/dialogs/qdialog_p.h2
-rw-r--r--src/widgets/dialogs/qerrormessage.cpp4
-rw-r--r--src/widgets/dialogs/qerrormessage.h6
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp12
-rw-r--r--src/widgets/dialogs/qfiledialog.h38
-rw-r--r--src/widgets/dialogs/qfiledialog_p.h22
-rw-r--r--src/widgets/dialogs/qfileinfogatherer_p.h9
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp109
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.h42
-rw-r--r--src/widgets/dialogs/qfilesystemmodel_p.h8
-rw-r--r--src/widgets/dialogs/qfontdialog.cpp2
-rw-r--r--src/widgets/dialogs/qfontdialog.h16
-rw-r--r--src/widgets/dialogs/qfontdialog_p.h6
-rw-r--r--src/widgets/dialogs/qfscompleter_p.h4
-rw-r--r--src/widgets/dialogs/qinputdialog.cpp77
-rw-r--r--src/widgets/dialogs/qinputdialog.h30
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp17
-rw-r--r--src/widgets/dialogs/qmessagebox.h18
-rw-r--r--src/widgets/dialogs/qprogressdialog.cpp2
-rw-r--r--src/widgets/dialogs/qprogressdialog.h14
-rw-r--r--src/widgets/dialogs/qsidebar_p.h20
-rw-r--r--src/widgets/dialogs/qwizard.cpp44
-rw-r--r--src/widgets/dialogs/qwizard.h22
-rw-r--r--src/widgets/dialogs/qwizard_win.cpp13
-rw-r--r--src/widgets/dialogs/qwizard_win_p.h4
-rw-r--r--src/widgets/doc/images/stardelegate.pngbin12230 -> 21528 bytes
-rw-r--r--src/widgets/doc/images/stylesheet-coffee-xp.pngbin14200 -> 0 bytes
-rw-r--r--src/widgets/doc/images/widgets-tutorial-toplevel.pngbin6087 -> 2496 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-tabwidget.pngbin5220 -> 0 bytes
-rw-r--r--src/widgets/doc/images/windowsxp-treeview.pngbin5795 -> 0 bytes
-rw-r--r--src/widgets/doc/qtwidgets.qdocconf6
-rw-r--r--src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc4
-rw-r--r--src/widgets/doc/snippets/common-table-model/model.cpp12
-rw-r--r--src/widgets/doc/snippets/common-table-model/model.h22
-rw-r--r--src/widgets/doc/snippets/javastyle.cpp8
-rw-r--r--src/widgets/doc/snippets/macmainwindow.mm2
-rw-r--r--src/widgets/doc/snippets/stringlistmodel/model.cpp6
-rw-r--r--src/widgets/doc/snippets/stringlistmodel/model.h16
-rw-r--r--src/widgets/doc/src/qtwidgets-index.qdoc4
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/gallery.qdoc4
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc39
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/widgets.qdoc2
-rw-r--r--src/widgets/effects/qgraphicseffect.h26
-rw-r--r--src/widgets/effects/qpixmapfilter_p.h14
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout.h14
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout_p.h4
-rw-r--r--src/widgets/graphicsview/qgraphicsgridlayout.h14
-rw-r--r--src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h14
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp94
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.h272
-rw-r--r--src/widgets/graphicsview/qgraphicsitem_p.h22
-rw-r--r--src/widgets/graphicsview/qgraphicsitemanimation.h2
-rw-r--r--src/widgets/graphicsview/qgraphicslayout.h6
-rw-r--r--src/widgets/graphicsview/qgraphicslayoutitem.h2
-rw-r--r--src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h10
-rw-r--r--src/widgets/graphicsview/qgraphicslinearlayout.h16
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget.cpp8
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget.h66
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp2
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.h22
-rw-r--r--src/widgets/graphicsview/qgraphicsscene_bsp.cpp6
-rw-r--r--src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h20
-rw-r--r--src/widgets/graphicsview/qgraphicsscenelinearindex_p.h10
-rw-r--r--src/widgets/graphicsview/qgraphicstransform.h10
-rw-r--r--src/widgets/graphicsview/qgraphicsview.cpp3
-rw-r--r--src/widgets/graphicsview/qgraphicsview.h56
-rw-r--r--src/widgets/graphicsview/qgraphicswidget.cpp10
-rw-r--r--src/widgets/graphicsview/qgraphicswidget.h34
-rw-r--r--src/widgets/graphicsview/qgraphicswidget_p.cpp5
-rw-r--r--src/widgets/graphicsview/qgraphicswidget_p.h16
-rw-r--r--src/widgets/graphicsview/qsimplex_p.cpp2
-rw-r--r--src/widgets/itemviews/qabstractitemdelegate.cpp25
-rw-r--r--src/widgets/itemviews/qabstractitemdelegate.h4
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp46
-rw-r--r--src/widgets/itemviews/qabstractitemview.h46
-rw-r--r--src/widgets/itemviews/qcolumnview.cpp6
-rw-r--r--src/widgets/itemviews/qcolumnview.h40
-rw-r--r--src/widgets/itemviews/qcolumnview_p.h26
-rw-r--r--src/widgets/itemviews/qcolumnviewgrip_p.h10
-rw-r--r--src/widgets/itemviews/qdatawidgetmapper.h2
-rw-r--r--src/widgets/itemviews/qdirmodel.cpp17
-rw-r--r--src/widgets/itemviews/qdirmodel.h34
-rw-r--r--src/widgets/itemviews/qheaderview.cpp148
-rw-r--r--src/widgets/itemviews/qheaderview.h61
-rw-r--r--src/widgets/itemviews/qheaderview_p.h8
-rw-r--r--src/widgets/itemviews/qitemdelegate.cpp24
-rw-r--r--src/widgets/itemviews/qitemdelegate.h18
-rw-r--r--src/widgets/itemviews/qitemeditorfactory.cpp18
-rw-r--r--src/widgets/itemviews/qitemeditorfactory_p.h2
-rw-r--r--src/widgets/itemviews/qlistview.cpp12
-rw-r--r--src/widgets/itemviews/qlistview.h70
-rw-r--r--src/widgets/itemviews/qlistwidget.cpp56
-rw-r--r--src/widgets/itemviews/qlistwidget.h35
-rw-r--r--src/widgets/itemviews/qlistwidget_p.h4
-rw-r--r--src/widgets/itemviews/qstyleditemdelegate.cpp13
-rw-r--r--src/widgets/itemviews/qstyleditemdelegate.h18
-rw-r--r--src/widgets/itemviews/qtableview.cpp23
-rw-r--r--src/widgets/itemviews/qtableview.h54
-rw-r--r--src/widgets/itemviews/qtablewidget.cpp34
-rw-r--r--src/widgets/itemviews/qtablewidget.h27
-rw-r--r--src/widgets/itemviews/qtreeview.cpp25
-rw-r--r--src/widgets/itemviews/qtreeview.h77
-rw-r--r--src/widgets/itemviews/qtreewidget.cpp40
-rw-r--r--src/widgets/itemviews/qtreewidget.h26
-rw-r--r--src/widgets/itemviews/qtreewidget_p.h40
-rw-r--r--src/widgets/kernel/mac.pri2
-rw-r--r--src/widgets/kernel/qaction.cpp47
-rw-r--r--src/widgets/kernel/qaction.h7
-rw-r--r--src/widgets/kernel/qaction_p.h3
-rw-r--r--src/widgets/kernel/qapplication.cpp50
-rw-r--r--src/widgets/kernel/qapplication.h10
-rw-r--r--src/widgets/kernel/qapplication_p.h31
-rw-r--r--src/widgets/kernel/qboxlayout.cpp30
-rw-r--r--src/widgets/kernel/qboxlayout.h28
-rw-r--r--src/widgets/kernel/qdesktopwidget.cpp130
-rw-r--r--src/widgets/kernel/qdesktopwidget.h60
-rw-r--r--src/widgets/kernel/qdesktopwidget.qdoc58
-rw-r--r--src/widgets/kernel/qdesktopwidget_p.h25
-rw-r--r--src/widgets/kernel/qformlayout.cpp2
-rw-r--r--src/widgets/kernel/qformlayout.h28
-rw-r--r--src/widgets/kernel/qgesture.h12
-rw-r--r--src/widgets/kernel/qgesturemanager.cpp10
-rw-r--r--src/widgets/kernel/qgesturerecognizer.cpp2
-rw-r--r--src/widgets/kernel/qgridlayout.cpp2
-rw-r--r--src/widgets/kernel/qgridlayout.h26
-rw-r--r--src/widgets/kernel/qlayout.h24
-rw-r--r--src/widgets/kernel/qlayoutitem.cpp4
-rw-r--r--src/widgets/kernel/qopenglwidget.cpp162
-rw-r--r--src/widgets/kernel/qopenglwidget.h17
-rw-r--r--src/widgets/kernel/qshortcut.h4
-rw-r--r--src/widgets/kernel/qstackedlayout.cpp2
-rw-r--r--src/widgets/kernel/qstackedlayout.h18
-rw-r--r--src/widgets/kernel/qstandardgestures_p.h30
-rw-r--r--src/widgets/kernel/qtooltip.cpp26
-rw-r--r--src/widgets/kernel/qtooltip.h2
-rw-r--r--src/widgets/kernel/qwhatsthis.cpp23
-rw-r--r--src/widgets/kernel/qwhatsthis.h4
-rw-r--r--src/widgets/kernel/qwidget.cpp282
-rw-r--r--src/widgets/kernel/qwidget.h22
-rw-r--r--src/widgets/kernel/qwidget_p.h44
-rw-r--r--src/widgets/kernel/qwidgetaction.h4
-rw-r--r--src/widgets/kernel/qwidgetbackingstore.cpp34
-rw-r--r--src/widgets/kernel/qwidgetbackingstore_p.h6
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp148
-rw-r--r--src/widgets/kernel/qwidgetwindow_p.h11
-rw-r--r--src/widgets/kernel/qwindowcontainer.cpp13
-rw-r--r--src/widgets/kernel/qwindowcontainer_p.h2
-rw-r--r--src/widgets/kernel/win.pri2
-rw-r--r--src/widgets/statemachine/qbasickeyeventtransition_p.h4
-rw-r--r--src/widgets/statemachine/qbasicmouseeventtransition_p.h4
-rw-r--r--src/widgets/statemachine/qkeyeventtransition.h8
-rw-r--r--src/widgets/statemachine/qmouseeventtransition.h8
-rw-r--r--src/widgets/styles/images/closedock-10.pngbin0 -> 284 bytes
-rw-r--r--src/widgets/styles/images/closedock-16.pngbin516 -> 299 bytes
-rw-r--r--src/widgets/styles/images/closedock-20.pngbin0 -> 374 bytes
-rw-r--r--src/widgets/styles/images/closedock-32.pngbin0 -> 368 bytes
-rw-r--r--src/widgets/styles/images/closedock-48.pngbin0 -> 468 bytes
-rw-r--r--src/widgets/styles/images/closedock-64.pngbin0 -> 541 bytes
-rw-r--r--src/widgets/styles/images/closedock-down-macstyle-16.png (renamed from src/widgets/styles/images/closedock-down-16.png)bin578 -> 578 bytes
-rw-r--r--src/widgets/styles/images/closedock-macstyle-16.pngbin0 -> 516 bytes
-rw-r--r--src/widgets/styles/images/dockdock-down-macstyle-16.png (renamed from src/widgets/styles/images/dockdock-down-16.png)bin406 -> 406 bytes
-rw-r--r--src/widgets/styles/images/dockdock-macstyle-16.png (renamed from src/widgets/styles/images/dockdock-16.png)bin438 -> 438 bytes
-rw-r--r--src/widgets/styles/images/fusion_arrow.pngbin295 -> 0 bytes
-rw-r--r--src/widgets/styles/images/normalizedockup-10.pngbin0 -> 138 bytes
-rw-r--r--src/widgets/styles/images/normalizedockup-16.pngbin0 -> 256 bytes
-rw-r--r--src/widgets/styles/images/normalizedockup-20.pngbin0 -> 143 bytes
-rw-r--r--src/widgets/styles/images/normalizedockup-32.pngbin0 -> 273 bytes
-rw-r--r--src/widgets/styles/images/normalizedockup-48.pngbin0 -> 279 bytes
-rw-r--r--src/widgets/styles/images/normalizedockup-64.pngbin0 -> 291 bytes
-rw-r--r--src/widgets/styles/qandroidstyle.cpp1820
-rw-r--r--src/widgets/styles/qandroidstyle_p.h395
-rw-r--r--src/widgets/styles/qcommonstyle.cpp90
-rw-r--r--src/widgets/styles/qcommonstyle.h46
-rw-r--r--src/widgets/styles/qcommonstyle_p.h2
-rw-r--r--src/widgets/styles/qdrawutil.h20
-rw-r--r--src/widgets/styles/qfusionstyle.cpp263
-rw-r--r--src/widgets/styles/qfusionstyle_p.h44
-rw-r--r--src/widgets/styles/qmacstyle.qdoc207
-rw-r--r--src/widgets/styles/qmacstyle_mac_p.h139
-rw-r--r--src/widgets/styles/qmacstyle_mac_p_p.h292
-rw-r--r--src/widgets/styles/qpixmapstyle_p.h32
-rw-r--r--src/widgets/styles/qproxystyle.h50
-rw-r--r--src/widgets/styles/qstyle.cpp44
-rw-r--r--src/widgets/styles/qstyle.h38
-rw-r--r--src/widgets/styles/qstyle.qrc21
-rw-r--r--src/widgets/styles/qstyleanimation_p.h25
-rw-r--r--src/widgets/styles/qstylefactory.cpp61
-rw-r--r--src/widgets/styles/qstylehelper.cpp50
-rw-r--r--src/widgets/styles/qstylehelper_p.h23
-rw-r--r--src/widgets/styles/qstyleoption.cpp20
-rw-r--r--src/widgets/styles/qstyleoption.h8
-rw-r--r--src/widgets/styles/qstylepainter.h2
-rw-r--r--src/widgets/styles/qstyleplugin.h2
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp59
-rw-r--r--src/widgets/styles/qstylesheetstyle_default.cpp4
-rw-r--r--src/widgets/styles/qstylesheetstyle_p.h48
-rw-r--r--src/widgets/styles/qwindowsstyle.cpp148
-rw-r--r--src/widgets/styles/qwindowsstyle_p.h32
-rw-r--r--src/widgets/styles/qwindowsstyle_p_p.h4
-rw-r--r--src/widgets/styles/qwindowsvistastyle.cpp2492
-rw-r--r--src/widgets/styles/qwindowsvistastyle_p.h110
-rw-r--r--src/widgets/styles/qwindowsvistastyle_p_p.h204
-rw-r--r--src/widgets/styles/qwindowsxpstyle.cpp4240
-rw-r--r--src/widgets/styles/qwindowsxpstyle_p.h109
-rw-r--r--src/widgets/styles/qwindowsxpstyle_p_p.h345
-rw-r--r--src/widgets/styles/styles.pri23
-rw-r--r--src/widgets/util/qcompleter.cpp50
-rw-r--r--src/widgets/util/qcompleter.h10
-rw-r--r--src/widgets/util/qcompleter_p.h30
-rw-r--r--src/widgets/util/qflickgesture.cpp2
-rw-r--r--src/widgets/util/qscroller.cpp58
-rw-r--r--src/widgets/util/qscroller_p.h1
-rw-r--r--src/widgets/util/qsystemtrayicon.cpp29
-rw-r--r--src/widgets/util/qsystemtrayicon.h6
-rw-r--r--src/widgets/util/qsystemtrayicon_p.h8
-rw-r--r--src/widgets/util/qsystemtrayicon_win.cpp599
-rw-r--r--src/widgets/util/qsystemtrayicon_x11.cpp12
-rw-r--r--src/widgets/util/qundogroup.h2
-rw-r--r--src/widgets/util/qundostack.h6
-rw-r--r--src/widgets/util/qundoview.cpp10
-rw-r--r--src/widgets/util/qundoview.h6
-rw-r--r--src/widgets/util/util.pri4
-rw-r--r--src/widgets/widgets.pro1
-rw-r--r--src/widgets/widgets/qabstractbutton.h26
-rw-r--r--src/widgets/widgets/qabstractscrollarea.cpp2
-rw-r--r--src/widgets/widgets/qabstractscrollarea.h38
-rw-r--r--src/widgets/widgets/qabstractscrollarea_p.h2
-rw-r--r--src/widgets/widgets/qabstractslider.h14
-rw-r--r--src/widgets/widgets/qabstractspinbox.cpp25
-rw-r--r--src/widgets/widgets/qabstractspinbox.h4
-rw-r--r--src/widgets/widgets/qbuttongroup.h2
-rw-r--r--src/widgets/widgets/qcalendarwidget.cpp84
-rw-r--r--src/widgets/widgets/qcalendarwidget.h16
-rw-r--r--src/widgets/widgets/qcheckbox.cpp16
-rw-r--r--src/widgets/widgets/qcheckbox.h20
-rw-r--r--src/widgets/widgets/qcombobox.cpp76
-rw-r--r--src/widgets/widgets/qcombobox.h38
-rw-r--r--src/widgets/widgets/qcombobox_p.h4
-rw-r--r--src/widgets/widgets/qcommandlinkbutton.cpp2
-rw-r--r--src/widgets/widgets/qcommandlinkbutton.h16
-rw-r--r--src/widgets/widgets/qdatetimeedit.cpp20
-rw-r--r--src/widgets/widgets/qdatetimeedit.h18
-rw-r--r--src/widgets/widgets/qdatetimeedit_p.h34
-rw-r--r--src/widgets/widgets/qdial.cpp2
-rw-r--r--src/widgets/widgets/qdial.h20
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.cpp4
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.h18
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp137
-rw-r--r--src/widgets/widgets/qdockarealayout_p.h5
-rw-r--r--src/widgets/widgets/qdockwidget.cpp82
-rw-r--r--src/widgets/widgets/qdockwidget.h12
-rw-r--r--src/widgets/widgets/qdockwidget_p.h24
-rw-r--r--src/widgets/widgets/qeffects.cpp17
-rw-r--r--src/widgets/widgets/qfocusframe.h8
-rw-r--r--src/widgets/widgets/qfontcombobox.cpp15
-rw-r--r--src/widgets/widgets/qfontcombobox.h6
-rw-r--r--src/widgets/widgets/qframe.h12
-rw-r--r--src/widgets/widgets/qgroupbox.cpp2
-rw-r--r--src/widgets/widgets/qgroupbox.h24
-rw-r--r--src/widgets/widgets/qkeysequenceedit.h12
-rw-r--r--src/widgets/widgets/qlabel.cpp14
-rw-r--r--src/widgets/widgets/qlabel.h32
-rw-r--r--src/widgets/widgets/qlcdnumber.h10
-rw-r--r--src/widgets/widgets/qlineedit.cpp70
-rw-r--r--src/widgets/widgets/qlineedit.h44
-rw-r--r--src/widgets/widgets/qlineedit_p.cpp12
-rw-r--r--src/widgets/widgets/qlineedit_p.h8
-rw-r--r--src/widgets/widgets/qmaccocoaviewcontainer_mac.h2
-rw-r--r--src/widgets/widgets/qmaccocoaviewcontainer_mac.mm8
-rw-r--r--src/widgets/widgets/qmacnativewidget_mac.h2
-rw-r--r--src/widgets/widgets/qmacnativewidget_mac.mm3
-rw-r--r--src/widgets/widgets/qmainwindow.cpp261
-rw-r--r--src/widgets/widgets/qmainwindow.h6
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp722
-rw-r--r--src/widgets/widgets/qmainwindowlayout_p.h339
-rw-r--r--src/widgets/widgets/qmdiarea.cpp14
-rw-r--r--src/widgets/widgets/qmdiarea.h26
-rw-r--r--src/widgets/widgets/qmdiarea_p.h16
-rw-r--r--src/widgets/widgets/qmdisubwindow.cpp91
-rw-r--r--src/widgets/widgets/qmdisubwindow.h46
-rw-r--r--src/widgets/widgets/qmdisubwindow_p.h2
-rw-r--r--src/widgets/widgets/qmenu.cpp198
-rw-r--r--src/widgets/widgets/qmenu.h52
-rw-r--r--src/widgets/widgets/qmenu_mac.mm5
-rw-r--r--src/widgets/widgets/qmenu_p.h13
-rw-r--r--src/widgets/widgets/qmenubar.cpp55
-rw-r--r--src/widgets/widgets/qmenubar.h28
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp75
-rw-r--r--src/widgets/widgets/qplaintextedit.h79
-rw-r--r--src/widgets/widgets/qplaintextedit_p.h18
-rw-r--r--src/widgets/widgets/qprogressbar.cpp4
-rw-r--r--src/widgets/widgets/qprogressbar.h10
-rw-r--r--src/widgets/widgets/qpushbutton.cpp11
-rw-r--r--src/widgets/widgets/qpushbutton.h22
-rw-r--r--src/widgets/widgets/qradiobutton.cpp1
-rw-r--r--src/widgets/widgets/qradiobutton.h16
-rw-r--r--src/widgets/widgets/qrubberband.h14
-rw-r--r--src/widgets/widgets/qscrollarea.h18
-rw-r--r--src/widgets/widgets/qscrollbar.h24
-rw-r--r--src/widgets/widgets/qsizegrip.cpp3
-rw-r--r--src/widgets/widgets/qsizegrip.h22
-rw-r--r--src/widgets/widgets/qslider.h18
-rw-r--r--src/widgets/widgets/qspinbox.cpp12
-rw-r--r--src/widgets/widgets/qspinbox.h4
-rw-r--r--src/widgets/widgets/qsplashscreen.cpp5
-rw-r--r--src/widgets/widgets/qsplashscreen.h4
-rw-r--r--src/widgets/widgets/qsplitter.cpp2
-rw-r--r--src/widgets/widgets/qsplitter.h30
-rw-r--r--src/widgets/widgets/qstackedwidget.cpp2
-rw-r--r--src/widgets/widgets/qstackedwidget.h4
-rw-r--r--src/widgets/widgets/qstatusbar.cpp2
-rw-r--r--src/widgets/widgets/qstatusbar.h10
-rw-r--r--src/widgets/widgets/qtabbar.cpp4
-rw-r--r--src/widgets/widgets/qtabbar.h30
-rw-r--r--src/widgets/widgets/qtabbar_p.h22
-rw-r--r--src/widgets/widgets/qtabwidget.cpp5
-rw-r--r--src/widgets/widgets/qtabwidget.h22
-rw-r--r--src/widgets/widgets/qtextbrowser.cpp2
-rw-r--r--src/widgets/widgets/qtextbrowser.h20
-rw-r--r--src/widgets/widgets/qtextedit.cpp35
-rw-r--r--src/widgets/widgets/qtextedit.h64
-rw-r--r--src/widgets/widgets/qtoolbar.cpp13
-rw-r--r--src/widgets/widgets/qtoolbar.h16
-rw-r--r--src/widgets/widgets/qtoolbarextension_p.h4
-rw-r--r--src/widgets/widgets/qtoolbarlayout_p.h24
-rw-r--r--src/widgets/widgets/qtoolbarseparator_p.h4
-rw-r--r--src/widgets/widgets/qtoolbox.cpp6
-rw-r--r--src/widgets/widgets/qtoolbox.h8
-rw-r--r--src/widgets/widgets/qtoolbutton.cpp5
-rw-r--r--src/widgets/widgets/qtoolbutton.h32
-rw-r--r--src/widgets/widgets/qwidgetanimator.cpp4
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp12
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol_p.h6
-rw-r--r--src/widgets/widgets/qwidgetresizehandler.cpp11
-rw-r--r--src/widgets/widgets/qwidgetresizehandler_p.h2
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp13
-rw-r--r--src/widgets/widgets/qwidgettextcontrol_p.h8
354 files changed, 5451 insertions, 15418 deletions
diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp
index 0f88554415..6cdc06d702 100644
--- a/src/widgets/accessible/complexwidgets.cpp
+++ b/src/widgets/accessible/complexwidgets.cpp
@@ -93,16 +93,16 @@ public:
: m_parent(parent), m_index(index)
{}
- void *interface_cast(QAccessible::InterfaceType t) Q_DECL_OVERRIDE {
+ void *interface_cast(QAccessible::InterfaceType t) override {
if (t == QAccessible::ActionInterface) {
return static_cast<QAccessibleActionInterface*>(this);
}
return 0;
}
- QObject *object() const Q_DECL_OVERRIDE { return 0; }
- QAccessible::Role role() const Q_DECL_OVERRIDE { return QAccessible::PageTab; }
- QAccessible::State state() const Q_DECL_OVERRIDE {
+ QObject *object() const override { return 0; }
+ QAccessible::Role role() const override { return QAccessible::PageTab; }
+ QAccessible::State state() const override {
if (!isValid()) {
QAccessible::State s;
s.invalid = true;
@@ -110,7 +110,7 @@ public:
}
return parent()->state();
}
- QRect rect() const Q_DECL_OVERRIDE {
+ QRect rect() const override {
if (!isValid())
return QRect();
@@ -120,13 +120,13 @@ public:
return rec;
}
- bool isValid() const Q_DECL_OVERRIDE { return m_parent.data() && m_parent->count() > m_index; }
+ bool isValid() const override { return m_parent.data() && m_parent->count() > m_index; }
- QAccessibleInterface *childAt(int, int) const Q_DECL_OVERRIDE { return 0; }
- int childCount() const Q_DECL_OVERRIDE { return 0; }
- int indexOfChild(const QAccessibleInterface *) const Q_DECL_OVERRIDE { return -1; }
+ QAccessibleInterface *childAt(int, int) const override { return 0; }
+ int childCount() const override { return 0; }
+ int indexOfChild(const QAccessibleInterface *) const override { return -1; }
- QString text(QAccessible::Text t) const Q_DECL_OVERRIDE
+ QString text(QAccessible::Text t) const override
{
if (!isValid())
return QString();
@@ -156,26 +156,26 @@ public:
return str;
}
- void setText(QAccessible::Text, const QString &) Q_DECL_OVERRIDE {}
+ void setText(QAccessible::Text, const QString &) override {}
- QAccessibleInterface *parent() const Q_DECL_OVERRIDE {
+ QAccessibleInterface *parent() const override {
return QAccessible::queryAccessibleInterface(m_parent.data());
}
- QAccessibleInterface *child(int) const Q_DECL_OVERRIDE { return 0; }
+ QAccessibleInterface *child(int) const override { return 0; }
// action interface
- QStringList actionNames() const Q_DECL_OVERRIDE
+ QStringList actionNames() const override
{
return QStringList(pressAction());
}
- void doAction(const QString &actionName) Q_DECL_OVERRIDE
+ void doAction(const QString &actionName) override
{
if (isValid() && actionName == pressAction())
m_parent->setCurrentIndex(m_index);
}
- QStringList keyBindingsForAction(const QString &) const Q_DECL_OVERRIDE
+ QStringList keyBindingsForAction(const QString &) const override
{
return QStringList();
}
diff --git a/src/widgets/accessible/complexwidgets_p.h b/src/widgets/accessible/complexwidgets_p.h
index 1887f98dca..96db2dab70 100644
--- a/src/widgets/accessible/complexwidgets_p.h
+++ b/src/widgets/accessible/complexwidgets_p.h
@@ -85,11 +85,11 @@ public:
Undefined
};
- QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE;
- int childCount() const Q_DECL_OVERRIDE;
- int indexOfChild(const QAccessibleInterface *child) const Q_DECL_OVERRIDE;
- bool isValid() const Q_DECL_OVERRIDE;
- QAccessibleInterface *childAt(int x, int y) const Q_DECL_OVERRIDE;
+ QAccessibleInterface *child(int index) const override;
+ int childCount() const override;
+ int indexOfChild(const QAccessibleInterface *child) const override;
+ bool isValid() const override;
+ QAccessibleInterface *childAt(int x, int y) const override;
//protected:
QAbstractScrollArea *abstractScrollArea() const;
@@ -114,11 +114,11 @@ public:
explicit QAccessibleTabBar(QWidget *w);
~QAccessibleTabBar();
- int childCount() const Q_DECL_OVERRIDE;
- QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
+ int childCount() const override;
+ QString text(QAccessible::Text t) const override;
- QAccessibleInterface* child(int index) const Q_DECL_OVERRIDE;
- int indexOfChild(const QAccessibleInterface *child) const Q_DECL_OVERRIDE;
+ QAccessibleInterface* child(int index) const override;
+ int indexOfChild(const QAccessibleInterface *child) const override;
protected:
QTabBar *tabBar() const;
@@ -132,18 +132,18 @@ class QAccessibleComboBox : public QAccessibleWidget
public:
explicit QAccessibleComboBox(QWidget *w);
- int childCount() const Q_DECL_OVERRIDE;
- QAccessibleInterface *childAt(int x, int y) const Q_DECL_OVERRIDE;
- int indexOfChild(const QAccessibleInterface *child) const Q_DECL_OVERRIDE;
- QAccessibleInterface* child(int index) const Q_DECL_OVERRIDE;
+ int childCount() const override;
+ QAccessibleInterface *childAt(int x, int y) const override;
+ int indexOfChild(const QAccessibleInterface *child) const override;
+ QAccessibleInterface* child(int index) const override;
- QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
+ QString text(QAccessible::Text t) const override;
// QAccessibleActionInterface
- QStringList actionNames() const Q_DECL_OVERRIDE;
- QString localizedActionDescription(const QString &actionName) const Q_DECL_OVERRIDE;
- void doAction(const QString &actionName) Q_DECL_OVERRIDE;
- QStringList keyBindingsForAction(const QString &actionName) const Q_DECL_OVERRIDE;
+ QStringList actionNames() const override;
+ QString localizedActionDescription(const QString &actionName) const override;
+ void doAction(const QString &actionName) override;
+ QStringList keyBindingsForAction(const QString &actionName) const override;
protected:
QComboBox *comboBox() const;
diff --git a/src/widgets/accessible/itemviews_p.h b/src/widgets/accessible/itemviews_p.h
index 72841b8a0f..683ae9c948 100644
--- a/src/widgets/accessible/itemviews_p.h
+++ b/src/widgets/accessible/itemviews_p.h
@@ -71,48 +71,48 @@ class QAccessibleTable :public QAccessibleTableInterface, public QAccessibleObje
{
public:
explicit QAccessibleTable(QWidget *w);
- bool isValid() const Q_DECL_OVERRIDE;
+ bool isValid() const override;
- QAccessible::Role role() const Q_DECL_OVERRIDE;
- QAccessible::State state() const Q_DECL_OVERRIDE;
- QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
- QRect rect() const Q_DECL_OVERRIDE;
+ QAccessible::Role role() const override;
+ QAccessible::State state() const override;
+ QString text(QAccessible::Text t) const override;
+ QRect rect() const override;
- QAccessibleInterface *childAt(int x, int y) const Q_DECL_OVERRIDE;
- int childCount() const Q_DECL_OVERRIDE;
- int indexOfChild(const QAccessibleInterface *) const Q_DECL_OVERRIDE;
+ QAccessibleInterface *childAt(int x, int y) const override;
+ int childCount() const override;
+ int indexOfChild(const QAccessibleInterface *) const override;
- QAccessibleInterface *parent() const Q_DECL_OVERRIDE;
- QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE;
+ QAccessibleInterface *parent() const override;
+ QAccessibleInterface *child(int index) const override;
- void *interface_cast(QAccessible::InterfaceType t) Q_DECL_OVERRIDE;
+ void *interface_cast(QAccessible::InterfaceType t) override;
// table interface
- virtual QAccessibleInterface *cellAt(int row, int column) const Q_DECL_OVERRIDE;
- virtual QAccessibleInterface *caption() const Q_DECL_OVERRIDE;
- virtual QAccessibleInterface *summary() const Q_DECL_OVERRIDE;
- virtual QString columnDescription(int column) const Q_DECL_OVERRIDE;
- virtual QString rowDescription(int row) const Q_DECL_OVERRIDE;
- virtual int columnCount() const Q_DECL_OVERRIDE;
- virtual int rowCount() const Q_DECL_OVERRIDE;
+ virtual QAccessibleInterface *cellAt(int row, int column) const override;
+ virtual QAccessibleInterface *caption() const override;
+ virtual QAccessibleInterface *summary() const override;
+ virtual QString columnDescription(int column) const override;
+ virtual QString rowDescription(int row) const override;
+ virtual int columnCount() const override;
+ virtual int rowCount() const override;
// selection
- virtual int selectedCellCount() const Q_DECL_OVERRIDE;
- virtual int selectedColumnCount() const Q_DECL_OVERRIDE;
- virtual int selectedRowCount() const Q_DECL_OVERRIDE;
- virtual QList<QAccessibleInterface*> selectedCells() const Q_DECL_OVERRIDE;
- virtual QList<int> selectedColumns() const Q_DECL_OVERRIDE;
- virtual QList<int> selectedRows() const Q_DECL_OVERRIDE;
- virtual bool isColumnSelected(int column) const Q_DECL_OVERRIDE;
- virtual bool isRowSelected(int row) const Q_DECL_OVERRIDE;
- virtual bool selectRow(int row) Q_DECL_OVERRIDE;
- virtual bool selectColumn(int column) Q_DECL_OVERRIDE;
- virtual bool unselectRow(int row) Q_DECL_OVERRIDE;
- virtual bool unselectColumn(int column) Q_DECL_OVERRIDE;
+ virtual int selectedCellCount() const override;
+ virtual int selectedColumnCount() const override;
+ virtual int selectedRowCount() const override;
+ virtual QList<QAccessibleInterface*> selectedCells() const override;
+ virtual QList<int> selectedColumns() const override;
+ virtual QList<int> selectedRows() const override;
+ virtual bool isColumnSelected(int column) const override;
+ virtual bool isRowSelected(int row) const override;
+ virtual bool selectRow(int row) override;
+ virtual bool selectColumn(int column) override;
+ virtual bool unselectRow(int row) override;
+ virtual bool unselectColumn(int column) override;
QAbstractItemView *view() const;
- void modelChange(QAccessibleTableModelChangeEvent *event) Q_DECL_OVERRIDE;
+ void modelChange(QAccessibleTableModelChangeEvent *event) override;
protected:
inline QAccessible::Role cellRole() const {
@@ -153,19 +153,19 @@ public:
{}
- QAccessibleInterface *childAt(int x, int y) const Q_DECL_OVERRIDE;
- int childCount() const Q_DECL_OVERRIDE;
- QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE;
+ QAccessibleInterface *childAt(int x, int y) const override;
+ int childCount() const override;
+ QAccessibleInterface *child(int index) const override;
- int indexOfChild(const QAccessibleInterface *) const Q_DECL_OVERRIDE;
+ int indexOfChild(const QAccessibleInterface *) const override;
- int rowCount() const Q_DECL_OVERRIDE;
+ int rowCount() const override;
// table interface
- QAccessibleInterface *cellAt(int row, int column) const Q_DECL_OVERRIDE;
- QString rowDescription(int row) const Q_DECL_OVERRIDE;
- bool isRowSelected(int row) const Q_DECL_OVERRIDE;
- bool selectRow(int row) Q_DECL_OVERRIDE;
+ QAccessibleInterface *cellAt(int row, int column) const override;
+ QString rowDescription(int row) const override;
+ bool isRowSelected(int row) const override;
+ bool selectRow(int row) override;
private:
QModelIndex indexFromLogical(int row, int column = 0) const;
@@ -179,37 +179,37 @@ class QAccessibleTableCell: public QAccessibleInterface, public QAccessibleTable
public:
QAccessibleTableCell(QAbstractItemView *view, const QModelIndex &m_index, QAccessible::Role role);
- void *interface_cast(QAccessible::InterfaceType t) Q_DECL_OVERRIDE;
- QObject *object() const Q_DECL_OVERRIDE { return Q_NULLPTR; }
- QAccessible::Role role() const Q_DECL_OVERRIDE;
- QAccessible::State state() const Q_DECL_OVERRIDE;
- QRect rect() const Q_DECL_OVERRIDE;
- bool isValid() const Q_DECL_OVERRIDE;
+ void *interface_cast(QAccessible::InterfaceType t) override;
+ QObject *object() const override { return nullptr; }
+ QAccessible::Role role() const override;
+ QAccessible::State state() const override;
+ QRect rect() const override;
+ bool isValid() const override;
- QAccessibleInterface *childAt(int, int) const Q_DECL_OVERRIDE { return Q_NULLPTR; }
- int childCount() const Q_DECL_OVERRIDE { return 0; }
- int indexOfChild(const QAccessibleInterface *) const Q_DECL_OVERRIDE { return -1; }
+ QAccessibleInterface *childAt(int, int) const override { return nullptr; }
+ int childCount() const override { return 0; }
+ int indexOfChild(const QAccessibleInterface *) const override { return -1; }
- QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
- void setText(QAccessible::Text t, const QString &text) Q_DECL_OVERRIDE;
+ QString text(QAccessible::Text t) const override;
+ void setText(QAccessible::Text t, const QString &text) override;
- QAccessibleInterface *parent() const Q_DECL_OVERRIDE;
- QAccessibleInterface *child(int) const Q_DECL_OVERRIDE;
+ QAccessibleInterface *parent() const override;
+ QAccessibleInterface *child(int) const override;
// cell interface
- virtual int columnExtent() const Q_DECL_OVERRIDE;
- virtual QList<QAccessibleInterface*> columnHeaderCells() const Q_DECL_OVERRIDE;
- virtual int columnIndex() const Q_DECL_OVERRIDE;
- virtual int rowExtent() const Q_DECL_OVERRIDE;
- virtual QList<QAccessibleInterface*> rowHeaderCells() const Q_DECL_OVERRIDE;
- virtual int rowIndex() const Q_DECL_OVERRIDE;
- virtual bool isSelected() const Q_DECL_OVERRIDE;
- virtual QAccessibleInterface* table() const Q_DECL_OVERRIDE;
+ virtual int columnExtent() const override;
+ virtual QList<QAccessibleInterface*> columnHeaderCells() const override;
+ virtual int columnIndex() const override;
+ virtual int rowExtent() const override;
+ virtual QList<QAccessibleInterface*> rowHeaderCells() const override;
+ virtual int rowIndex() const override;
+ virtual bool isSelected() const override;
+ virtual QAccessibleInterface* table() const override;
//action interface
- virtual QStringList actionNames() const Q_DECL_OVERRIDE;
- virtual void doAction(const QString &actionName) Q_DECL_OVERRIDE;
- virtual QStringList keyBindingsForAction(const QString &actionName) const Q_DECL_OVERRIDE;
+ virtual QStringList actionNames() const override;
+ virtual void doAction(const QString &actionName) override;
+ virtual QStringList keyBindingsForAction(const QString &actionName) const override;
private:
QHeaderView *verticalHeader() const;
@@ -234,21 +234,21 @@ public:
// For header cells, pass the header view in addition
QAccessibleTableHeaderCell(QAbstractItemView *view, int index, Qt::Orientation orientation);
- QObject *object() const Q_DECL_OVERRIDE { return Q_NULLPTR; }
- QAccessible::Role role() const Q_DECL_OVERRIDE;
- QAccessible::State state() const Q_DECL_OVERRIDE;
- QRect rect() const Q_DECL_OVERRIDE;
- bool isValid() const Q_DECL_OVERRIDE;
+ QObject *object() const override { return nullptr; }
+ QAccessible::Role role() const override;
+ QAccessible::State state() const override;
+ QRect rect() const override;
+ bool isValid() const override;
- QAccessibleInterface *childAt(int, int) const Q_DECL_OVERRIDE { return Q_NULLPTR; }
- int childCount() const Q_DECL_OVERRIDE { return 0; }
- int indexOfChild(const QAccessibleInterface *) const Q_DECL_OVERRIDE { return -1; }
+ QAccessibleInterface *childAt(int, int) const override { return nullptr; }
+ int childCount() const override { return 0; }
+ int indexOfChild(const QAccessibleInterface *) const override { return -1; }
- QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
- void setText(QAccessible::Text t, const QString &text) Q_DECL_OVERRIDE;
+ QString text(QAccessible::Text t) const override;
+ void setText(QAccessible::Text t, const QString &text) override;
- QAccessibleInterface *parent() const Q_DECL_OVERRIDE;
- QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE;
+ QAccessibleInterface *parent() const override;
+ QAccessibleInterface *child(int index) const override;
private:
QHeaderView *headerView() const;
@@ -273,24 +273,24 @@ public:
:view(view_)
{}
- QObject *object() const Q_DECL_OVERRIDE { return Q_NULLPTR; }
- QAccessible::Role role() const Q_DECL_OVERRIDE { return QAccessible::Pane; }
- QAccessible::State state() const Q_DECL_OVERRIDE { return QAccessible::State(); }
- QRect rect() const Q_DECL_OVERRIDE { return QRect(); }
- bool isValid() const Q_DECL_OVERRIDE { return true; }
+ QObject *object() const override { return nullptr; }
+ QAccessible::Role role() const override { return QAccessible::Pane; }
+ QAccessible::State state() const override { return QAccessible::State(); }
+ QRect rect() const override { return QRect(); }
+ bool isValid() const override { return true; }
- QAccessibleInterface *childAt(int, int) const Q_DECL_OVERRIDE { return Q_NULLPTR; }
- int childCount() const Q_DECL_OVERRIDE { return 0; }
- int indexOfChild(const QAccessibleInterface *) const Q_DECL_OVERRIDE { return -1; }
+ QAccessibleInterface *childAt(int, int) const override { return nullptr; }
+ int childCount() const override { return 0; }
+ int indexOfChild(const QAccessibleInterface *) const override { return -1; }
- QString text(QAccessible::Text) const Q_DECL_OVERRIDE { return QString(); }
- void setText(QAccessible::Text, const QString &) Q_DECL_OVERRIDE {}
+ QString text(QAccessible::Text) const override { return QString(); }
+ void setText(QAccessible::Text, const QString &) override {}
- QAccessibleInterface *parent() const Q_DECL_OVERRIDE {
+ QAccessibleInterface *parent() const override {
return QAccessible::queryAccessibleInterface(view);
}
- QAccessibleInterface *child(int) const Q_DECL_OVERRIDE {
- return Q_NULLPTR;
+ QAccessibleInterface *child(int) const override {
+ return nullptr;
}
private:
diff --git a/src/widgets/accessible/qaccessiblemenu.cpp b/src/widgets/accessible/qaccessiblemenu.cpp
index d20c5bfc71..8b3353f625 100644
--- a/src/widgets/accessible/qaccessiblemenu.cpp
+++ b/src/widgets/accessible/qaccessiblemenu.cpp
@@ -242,7 +242,7 @@ QObject *QAccessibleMenuItem::object() const
/*! \reimp */
QWindow *QAccessibleMenuItem::window() const
{
- QWindow *result = Q_NULLPTR;
+ QWindow *result = nullptr;
if (!m_owner.isNull()) {
result = m_owner->windowHandle();
if (!result) {
diff --git a/src/widgets/accessible/qaccessiblemenu_p.h b/src/widgets/accessible/qaccessiblemenu_p.h
index 8b37e23333..9acd2a42f9 100644
--- a/src/widgets/accessible/qaccessiblemenu_p.h
+++ b/src/widgets/accessible/qaccessiblemenu_p.h
@@ -69,14 +69,14 @@ class QAccessibleMenu : public QAccessibleWidget
public:
explicit QAccessibleMenu(QWidget *w);
- int childCount() const Q_DECL_OVERRIDE;
- QAccessibleInterface *childAt(int x, int y) const Q_DECL_OVERRIDE;
+ int childCount() const override;
+ QAccessibleInterface *childAt(int x, int y) const override;
- QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
- QAccessible::Role role() const Q_DECL_OVERRIDE;
- QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE;
- QAccessibleInterface *parent() const Q_DECL_OVERRIDE;
- int indexOfChild( const QAccessibleInterface *child ) const Q_DECL_OVERRIDE;
+ QString text(QAccessible::Text t) const override;
+ QAccessible::Role role() const override;
+ QAccessibleInterface *child(int index) const override;
+ QAccessibleInterface *parent() const override;
+ int indexOfChild( const QAccessibleInterface *child ) const override;
protected:
QMenu *menu() const;
@@ -88,10 +88,10 @@ class QAccessibleMenuBar : public QAccessibleWidget
public:
explicit QAccessibleMenuBar(QWidget *w);
- QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE;
- int childCount() const Q_DECL_OVERRIDE;
+ QAccessibleInterface *child(int index) const override;
+ int childCount() const override;
- int indexOfChild(const QAccessibleInterface *child) const Q_DECL_OVERRIDE;
+ int indexOfChild(const QAccessibleInterface *child) const override;
protected:
QMenuBar *menuBar() const;
@@ -105,28 +105,28 @@ public:
explicit QAccessibleMenuItem(QWidget *owner, QAction *w);
~QAccessibleMenuItem();
- void *interface_cast(QAccessible::InterfaceType t) Q_DECL_OVERRIDE;
+ void *interface_cast(QAccessible::InterfaceType t) override;
- int childCount() const Q_DECL_OVERRIDE;
- QAccessibleInterface *childAt(int x, int y) const Q_DECL_OVERRIDE;
- bool isValid() const Q_DECL_OVERRIDE;
- int indexOfChild(const QAccessibleInterface * child) const Q_DECL_OVERRIDE;
+ int childCount() const override;
+ QAccessibleInterface *childAt(int x, int y) const override;
+ bool isValid() const override;
+ int indexOfChild(const QAccessibleInterface * child) const override;
- QAccessibleInterface *parent() const Q_DECL_OVERRIDE;
- QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE;
- QObject * object() const Q_DECL_OVERRIDE;
- QWindow *window() const Q_DECL_OVERRIDE;
+ QAccessibleInterface *parent() const override;
+ QAccessibleInterface *child(int index) const override;
+ QObject * object() const override;
+ QWindow *window() const override;
- QRect rect() const Q_DECL_OVERRIDE;
- QAccessible::Role role() const Q_DECL_OVERRIDE;
- void setText(QAccessible::Text t, const QString & text) Q_DECL_OVERRIDE;
- QAccessible::State state() const Q_DECL_OVERRIDE;
- QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
+ QRect rect() const override;
+ QAccessible::Role role() const override;
+ void setText(QAccessible::Text t, const QString & text) override;
+ QAccessible::State state() const override;
+ QString text(QAccessible::Text t) const override;
// QAccessibleActionInterface
- QStringList actionNames() const Q_DECL_OVERRIDE;
- void doAction(const QString &actionName) Q_DECL_OVERRIDE;
- QStringList keyBindingsForAction(const QString &actionName) const Q_DECL_OVERRIDE;
+ QStringList actionNames() const override;
+ void doAction(const QString &actionName) override;
+ QStringList keyBindingsForAction(const QString &actionName) const override;
QWidget *owner() const;
protected:
diff --git a/src/widgets/accessible/qaccessiblewidget.h b/src/widgets/accessible/qaccessiblewidget.h
index e09c3ff489..63789a595f 100644
--- a/src/widgets/accessible/qaccessiblewidget.h
+++ b/src/widgets/accessible/qaccessiblewidget.h
@@ -54,32 +54,32 @@ class Q_WIDGETS_EXPORT QAccessibleWidget : public QAccessibleObject, public QAcc
{
public:
explicit QAccessibleWidget(QWidget *o, QAccessible::Role r = QAccessible::Client, const QString& name = QString());
- bool isValid() const Q_DECL_OVERRIDE;
+ bool isValid() const override;
- QWindow *window() const Q_DECL_OVERRIDE;
- int childCount() const Q_DECL_OVERRIDE;
- int indexOfChild(const QAccessibleInterface *child) const Q_DECL_OVERRIDE;
- QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > relations(QAccessible::Relation match = QAccessible::AllRelations) const Q_DECL_OVERRIDE;
- QAccessibleInterface *focusChild() const Q_DECL_OVERRIDE;
+ QWindow *window() const override;
+ int childCount() const override;
+ int indexOfChild(const QAccessibleInterface *child) const override;
+ QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > relations(QAccessible::Relation match = QAccessible::AllRelations) const override;
+ QAccessibleInterface *focusChild() const override;
- QRect rect() const Q_DECL_OVERRIDE;
+ QRect rect() const override;
- QAccessibleInterface *parent() const Q_DECL_OVERRIDE;
- QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE;
+ QAccessibleInterface *parent() const override;
+ QAccessibleInterface *child(int index) const override;
- QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
- QAccessible::Role role() const Q_DECL_OVERRIDE;
- QAccessible::State state() const Q_DECL_OVERRIDE;
+ QString text(QAccessible::Text t) const override;
+ QAccessible::Role role() const override;
+ QAccessible::State state() const override;
- QColor foregroundColor() const Q_DECL_OVERRIDE;
- QColor backgroundColor() const Q_DECL_OVERRIDE;
+ QColor foregroundColor() const override;
+ QColor backgroundColor() const override;
- void *interface_cast(QAccessible::InterfaceType t) Q_DECL_OVERRIDE;
+ void *interface_cast(QAccessible::InterfaceType t) override;
// QAccessibleActionInterface
- QStringList actionNames() const Q_DECL_OVERRIDE;
- void doAction(const QString &actionName) Q_DECL_OVERRIDE;
- QStringList keyBindingsForAction(const QString &actionName) const Q_DECL_OVERRIDE;
+ QStringList actionNames() const override;
+ void doAction(const QString &actionName) override;
+ QStringList keyBindingsForAction(const QString &actionName) const override;
protected:
~QAccessibleWidget();
QWidget *widget() const;
diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp
index f869ab1129..872ddcded5 100644
--- a/src/widgets/accessible/qaccessiblewidgets.cpp
+++ b/src/widgets/accessible/qaccessiblewidgets.cpp
@@ -716,7 +716,7 @@ QRect QAccessibleTextWidget::characterRect(int offset) const
QFontMetrics fm(format.font());
const QString ch = text(offset, offset + 1);
if (!ch.isEmpty()) {
- int w = fm.width(ch);
+ int w = fm.horizontalAdvance(ch);
int h = fm.height();
r = QRect(layoutPosition.x() + x, layoutPosition.y() + line.y() + line.ascent() + fm.descent() - h,
w, h);
diff --git a/src/widgets/accessible/qaccessiblewidgets_p.h b/src/widgets/accessible/qaccessiblewidgets_p.h
index 75e1eff694..87f0b888a0 100644
--- a/src/widgets/accessible/qaccessiblewidgets_p.h
+++ b/src/widgets/accessible/qaccessiblewidgets_p.h
@@ -85,40 +85,40 @@ class QAccessibleTextWidget : public QAccessibleWidget,
public:
QAccessibleTextWidget(QWidget *o, QAccessible::Role r = QAccessible::EditableText, const QString &name = QString());
- QAccessible::State state() const Q_DECL_OVERRIDE;
+ QAccessible::State state() const override;
// QAccessibleTextInterface
// selection
- void selection(int selectionIndex, int *startOffset, int *endOffset) const Q_DECL_OVERRIDE;
- int selectionCount() const Q_DECL_OVERRIDE;
- void addSelection(int startOffset, int endOffset) Q_DECL_OVERRIDE;
- void removeSelection(int selectionIndex) Q_DECL_OVERRIDE;
- void setSelection(int selectionIndex, int startOffset, int endOffset) Q_DECL_OVERRIDE;
+ void selection(int selectionIndex, int *startOffset, int *endOffset) const override;
+ int selectionCount() const override;
+ void addSelection(int startOffset, int endOffset) override;
+ void removeSelection(int selectionIndex) override;
+ void setSelection(int selectionIndex, int startOffset, int endOffset) override;
// cursor
- int cursorPosition() const Q_DECL_OVERRIDE;
- void setCursorPosition(int position) Q_DECL_OVERRIDE;
+ int cursorPosition() const override;
+ void setCursorPosition(int position) override;
// text
- QString text(int startOffset, int endOffset) const Q_DECL_OVERRIDE;
+ QString text(int startOffset, int endOffset) const override;
QString textBeforeOffset(int offset, QAccessible::TextBoundaryType boundaryType,
- int *startOffset, int *endOffset) const Q_DECL_OVERRIDE;
+ int *startOffset, int *endOffset) const override;
QString textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType,
- int *startOffset, int *endOffset) const Q_DECL_OVERRIDE;
+ int *startOffset, int *endOffset) const override;
QString textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType,
- int *startOffset, int *endOffset) const Q_DECL_OVERRIDE;
- int characterCount() const Q_DECL_OVERRIDE;
+ int *startOffset, int *endOffset) const override;
+ int characterCount() const override;
// character <-> geometry
- QRect characterRect(int offset) const Q_DECL_OVERRIDE;
- int offsetAtPoint(const QPoint &point) const Q_DECL_OVERRIDE;
+ QRect characterRect(int offset) const override;
+ int offsetAtPoint(const QPoint &point) const override;
- QString attributes(int offset, int *startOffset, int *endOffset) const Q_DECL_OVERRIDE;
+ QString attributes(int offset, int *startOffset, int *endOffset) const override;
// QAccessibleEditableTextInterface
- void deleteText(int startOffset, int endOffset) Q_DECL_OVERRIDE;
- void insertText(int offset, const QString &text) Q_DECL_OVERRIDE;
- void replaceText(int startOffset, int endOffset, const QString &text) Q_DECL_OVERRIDE;
+ void deleteText(int startOffset, int endOffset) override;
+ void insertText(int offset, const QString &text) override;
+ void replaceText(int startOffset, int endOffset, const QString &text) override;
using QAccessibleWidget::text;
@@ -138,25 +138,25 @@ class QAccessiblePlainTextEdit : public QAccessibleTextWidget
public:
explicit QAccessiblePlainTextEdit(QWidget *o);
- QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
- void setText(QAccessible::Text t, const QString &text) Q_DECL_OVERRIDE;
- QAccessible::State state() const Q_DECL_OVERRIDE;
+ QString text(QAccessible::Text t) const override;
+ void setText(QAccessible::Text t, const QString &text) override;
+ QAccessible::State state() const override;
- void *interface_cast(QAccessible::InterfaceType t) Q_DECL_OVERRIDE;
+ void *interface_cast(QAccessible::InterfaceType t) override;
// QAccessibleTextInterface
- void scrollToSubstring(int startIndex, int endIndex) Q_DECL_OVERRIDE;
+ void scrollToSubstring(int startIndex, int endIndex) override;
using QAccessibleTextWidget::text;
protected:
QPlainTextEdit *plainTextEdit() const;
- QPoint scrollBarPosition() const Q_DECL_OVERRIDE;
- QTextCursor textCursor() const Q_DECL_OVERRIDE;
- void setTextCursor(const QTextCursor &textCursor) Q_DECL_OVERRIDE;
- QTextDocument *textDocument() const Q_DECL_OVERRIDE;
- QWidget *viewport() const Q_DECL_OVERRIDE;
+ QPoint scrollBarPosition() const override;
+ QTextCursor textCursor() const override;
+ void setTextCursor(const QTextCursor &textCursor) override;
+ QTextDocument *textDocument() const override;
+ QWidget *viewport() const override;
};
class QAccessibleTextEdit : public QAccessibleTextWidget
@@ -164,25 +164,25 @@ class QAccessibleTextEdit : public QAccessibleTextWidget
public:
explicit QAccessibleTextEdit(QWidget *o);
- QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
- void setText(QAccessible::Text t, const QString &text) Q_DECL_OVERRIDE;
- QAccessible::State state() const Q_DECL_OVERRIDE;
+ QString text(QAccessible::Text t) const override;
+ void setText(QAccessible::Text t, const QString &text) override;
+ QAccessible::State state() const override;
- void *interface_cast(QAccessible::InterfaceType t) Q_DECL_OVERRIDE;
+ void *interface_cast(QAccessible::InterfaceType t) override;
// QAccessibleTextInterface
- void scrollToSubstring(int startIndex, int endIndex) Q_DECL_OVERRIDE;
+ void scrollToSubstring(int startIndex, int endIndex) override;
using QAccessibleTextWidget::text;
protected:
QTextEdit *textEdit() const;
- QPoint scrollBarPosition() const Q_DECL_OVERRIDE;
- QTextCursor textCursor() const Q_DECL_OVERRIDE;
- void setTextCursor(const QTextCursor &textCursor) Q_DECL_OVERRIDE;
- QTextDocument *textDocument() const Q_DECL_OVERRIDE;
- QWidget *viewport() const Q_DECL_OVERRIDE;
+ QPoint scrollBarPosition() const override;
+ QTextCursor textCursor() const override;
+ void setTextCursor(const QTextCursor &textCursor) override;
+ QTextDocument *textDocument() const override;
+ QWidget *viewport() const override;
};
#endif // QT_CONFIG(textedit)
#endif //QT_NO_CURSOR
@@ -192,10 +192,10 @@ class QAccessibleStackedWidget : public QAccessibleWidget
public:
explicit QAccessibleStackedWidget(QWidget *widget);
- QAccessibleInterface *childAt(int x, int y) const Q_DECL_OVERRIDE;
- int childCount() const Q_DECL_OVERRIDE;
- int indexOfChild(const QAccessibleInterface *child) const Q_DECL_OVERRIDE;
- QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE;
+ QAccessibleInterface *childAt(int x, int y) const override;
+ int childCount() const override;
+ int indexOfChild(const QAccessibleInterface *child) const override;
+ QAccessibleInterface *child(int index) const override;
protected:
QStackedWidget *stackedWidget() const;
@@ -222,9 +222,9 @@ class QAccessibleMdiArea : public QAccessibleWidget
public:
explicit QAccessibleMdiArea(QWidget *widget);
- int childCount() const Q_DECL_OVERRIDE;
- QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE;
- int indexOfChild(const QAccessibleInterface *child) const Q_DECL_OVERRIDE;
+ int childCount() const override;
+ QAccessibleInterface *child(int index) const override;
+ int indexOfChild(const QAccessibleInterface *child) const override;
protected:
QMdiArea *mdiArea() const;
@@ -235,13 +235,13 @@ class QAccessibleMdiSubWindow : public QAccessibleWidget
public:
explicit QAccessibleMdiSubWindow(QWidget *widget);
- QString text(QAccessible::Text textType) const Q_DECL_OVERRIDE;
- void setText(QAccessible::Text textType, const QString &text) Q_DECL_OVERRIDE;
- QAccessible::State state() const Q_DECL_OVERRIDE;
- int childCount() const Q_DECL_OVERRIDE;
- QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE;
- int indexOfChild(const QAccessibleInterface *child) const Q_DECL_OVERRIDE;
- QRect rect() const Q_DECL_OVERRIDE;
+ QString text(QAccessible::Text textType) const override;
+ void setText(QAccessible::Text textType, const QString &text) override;
+ QAccessible::State state() const override;
+ int childCount() const override;
+ QAccessibleInterface *child(int index) const override;
+ int indexOfChild(const QAccessibleInterface *child) const override;
+ QRect rect() const override;
protected:
QMdiSubWindow *mdiSubWindow() const;
@@ -262,7 +262,7 @@ class QAccessibleTextBrowser : public QAccessibleTextEdit
public:
explicit QAccessibleTextBrowser(QWidget *widget);
- QAccessible::Role role() const Q_DECL_OVERRIDE;
+ QAccessible::Role role() const override;
};
#endif // QT_CONFIG(textbrowser) && QT_NO_CURSOR
@@ -272,10 +272,10 @@ class QAccessibleCalendarWidget : public QAccessibleWidget
public:
explicit QAccessibleCalendarWidget(QWidget *widget);
- int childCount() const Q_DECL_OVERRIDE;
- int indexOfChild(const QAccessibleInterface *child) const Q_DECL_OVERRIDE;
+ int childCount() const override;
+ int indexOfChild(const QAccessibleInterface *child) const override;
- QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE;
+ QAccessibleInterface *child(int index) const override;
protected:
QCalendarWidget *calendarWidget() const;
@@ -291,11 +291,11 @@ class QAccessibleDockWidget: public QAccessibleWidget
{
public:
explicit QAccessibleDockWidget(QWidget *widget);
- QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE;
- int indexOfChild(const QAccessibleInterface *child) const Q_DECL_OVERRIDE;
- int childCount() const Q_DECL_OVERRIDE;
- QRect rect () const Q_DECL_OVERRIDE;
- QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
+ QAccessibleInterface *child(int index) const override;
+ int indexOfChild(const QAccessibleInterface *child) const override;
+ int childCount() const override;
+ QRect rect () const override;
+ QString text(QAccessible::Text t) const override;
QDockWidget *dockWidget() const;
protected:
@@ -310,10 +310,10 @@ class QAccessibleMainWindow : public QAccessibleWidget
public:
explicit QAccessibleMainWindow(QWidget *widget);
- QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE;
- int childCount() const Q_DECL_OVERRIDE;
- int indexOfChild(const QAccessibleInterface *iface) const Q_DECL_OVERRIDE;
- QAccessibleInterface *childAt(int x, int y) const Q_DECL_OVERRIDE;
+ QAccessibleInterface *child(int index) const override;
+ int childCount() const override;
+ int indexOfChild(const QAccessibleInterface *iface) const override;
+ QAccessibleInterface *childAt(int x, int y) const override;
QMainWindow *mainWindow() const;
};
diff --git a/src/widgets/accessible/rangecontrols.cpp b/src/widgets/accessible/rangecontrols.cpp
index 190f0aa02f..b5b8608418 100644
--- a/src/widgets/accessible/rangecontrols.cpp
+++ b/src/widgets/accessible/rangecontrols.cpp
@@ -69,7 +69,7 @@ QT_BEGIN_NAMESPACE
#if QT_CONFIG(spinbox)
QAccessibleAbstractSpinBox::QAccessibleAbstractSpinBox(QWidget *w)
-: QAccessibleWidget(w, QAccessible::SpinBox), lineEdit(Q_NULLPTR)
+: QAccessibleWidget(w, QAccessible::SpinBox), lineEdit(nullptr)
{
Q_ASSERT(abstractSpinBox());
}
diff --git a/src/widgets/accessible/rangecontrols_p.h b/src/widgets/accessible/rangecontrols_p.h
index 8af86681a0..1eada8e456 100644
--- a/src/widgets/accessible/rangecontrols_p.h
+++ b/src/widgets/accessible/rangecontrols_p.h
@@ -78,41 +78,41 @@ public:
explicit QAccessibleAbstractSpinBox(QWidget *w);
virtual ~QAccessibleAbstractSpinBox();
- QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
- void *interface_cast(QAccessible::InterfaceType t) Q_DECL_OVERRIDE;
+ QString text(QAccessible::Text t) const override;
+ void *interface_cast(QAccessible::InterfaceType t) override;
// QAccessibleValueInterface
- QVariant currentValue() const Q_DECL_OVERRIDE;
- void setCurrentValue(const QVariant &value) Q_DECL_OVERRIDE;
- QVariant maximumValue() const Q_DECL_OVERRIDE;
- QVariant minimumValue() const Q_DECL_OVERRIDE;
- QVariant minimumStepSize() const Q_DECL_OVERRIDE;
+ QVariant currentValue() const override;
+ void setCurrentValue(const QVariant &value) override;
+ QVariant maximumValue() const override;
+ QVariant minimumValue() const override;
+ QVariant minimumStepSize() const override;
// QAccessibleTextInterface
- void addSelection(int startOffset, int endOffset) Q_DECL_OVERRIDE;
- QString attributes(int offset, int *startOffset, int *endOffset) const Q_DECL_OVERRIDE;
- int cursorPosition() const Q_DECL_OVERRIDE;
- QRect characterRect(int offset) const Q_DECL_OVERRIDE;
- int selectionCount() const Q_DECL_OVERRIDE;
- int offsetAtPoint(const QPoint &point) const Q_DECL_OVERRIDE;
- void selection(int selectionIndex, int *startOffset, int *endOffset) const Q_DECL_OVERRIDE;
- QString text(int startOffset, int endOffset) const Q_DECL_OVERRIDE;
+ void addSelection(int startOffset, int endOffset) override;
+ QString attributes(int offset, int *startOffset, int *endOffset) const override;
+ int cursorPosition() const override;
+ QRect characterRect(int offset) const override;
+ int selectionCount() const override;
+ int offsetAtPoint(const QPoint &point) const override;
+ void selection(int selectionIndex, int *startOffset, int *endOffset) const override;
+ QString text(int startOffset, int endOffset) const override;
QString textBeforeOffset (int offset, QAccessible::TextBoundaryType boundaryType,
- int *endOffset, int *startOffset) const Q_DECL_OVERRIDE;
+ int *endOffset, int *startOffset) const override;
QString textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType,
- int *startOffset, int *endOffset) const Q_DECL_OVERRIDE;
+ int *startOffset, int *endOffset) const override;
QString textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType,
- int *startOffset, int *endOffset) const Q_DECL_OVERRIDE;
- void removeSelection(int selectionIndex) Q_DECL_OVERRIDE;
- void setCursorPosition(int position) Q_DECL_OVERRIDE;
- void setSelection(int selectionIndex, int startOffset, int endOffset) Q_DECL_OVERRIDE;
- int characterCount() const Q_DECL_OVERRIDE;
- void scrollToSubstring(int startIndex, int endIndex) Q_DECL_OVERRIDE;
+ int *startOffset, int *endOffset) const override;
+ void removeSelection(int selectionIndex) override;
+ void setCursorPosition(int position) override;
+ void setSelection(int selectionIndex, int startOffset, int endOffset) override;
+ int characterCount() const override;
+ void scrollToSubstring(int startIndex, int endIndex) override;
// QAccessibleEditableTextInterface
- void deleteText(int startOffset, int endOffset) Q_DECL_OVERRIDE;
- void insertText(int offset, const QString &text) Q_DECL_OVERRIDE;
- void replaceText(int startOffset, int endOffset, const QString &text) Q_DECL_OVERRIDE;
+ void deleteText(int startOffset, int endOffset) override;
+ void insertText(int offset, const QString &text) override;
+ void replaceText(int startOffset, int endOffset, const QString &text) override;
protected:
QAbstractSpinBox *abstractSpinBox() const;
@@ -135,7 +135,7 @@ class QAccessibleDoubleSpinBox : public QAccessibleAbstractSpinBox
public:
explicit QAccessibleDoubleSpinBox(QWidget *widget);
- QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
+ QString text(QAccessible::Text t) const override;
using QAccessibleAbstractSpinBox::text;
protected:
@@ -148,14 +148,14 @@ class QAccessibleAbstractSlider: public QAccessibleWidget, public QAccessibleVal
{
public:
explicit QAccessibleAbstractSlider(QWidget *w, QAccessible::Role r = QAccessible::Slider);
- void *interface_cast(QAccessible::InterfaceType t) Q_DECL_OVERRIDE;
+ void *interface_cast(QAccessible::InterfaceType t) override;
// QAccessibleValueInterface
- QVariant currentValue() const Q_DECL_OVERRIDE;
- void setCurrentValue(const QVariant &value) Q_DECL_OVERRIDE;
- QVariant maximumValue() const Q_DECL_OVERRIDE;
- QVariant minimumValue() const Q_DECL_OVERRIDE;
- QVariant minimumStepSize() const Q_DECL_OVERRIDE;
+ QVariant currentValue() const override;
+ void setCurrentValue(const QVariant &value) override;
+ QVariant maximumValue() const override;
+ QVariant minimumValue() const override;
+ QVariant minimumStepSize() const override;
protected:
QAbstractSlider *abstractSlider() const;
@@ -167,7 +167,7 @@ class QAccessibleScrollBar : public QAccessibleAbstractSlider
{
public:
explicit QAccessibleScrollBar(QWidget *w);
- QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
+ QString text(QAccessible::Text t) const override;
protected:
QScrollBar *scrollBar() const;
@@ -179,7 +179,7 @@ class QAccessibleSlider : public QAccessibleAbstractSlider
{
public:
explicit QAccessibleSlider(QWidget *w);
- QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
+ QString text(QAccessible::Text t) const override;
protected:
QSlider *slider() const;
@@ -192,7 +192,7 @@ class QAccessibleDial : public QAccessibleAbstractSlider
public:
explicit QAccessibleDial(QWidget *w);
- QString text(QAccessible::Text textType) const Q_DECL_OVERRIDE;
+ QString text(QAccessible::Text textType) const override;
protected:
QDial *dial() const;
diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp
index bacb00fe2e..efcf4cdc8b 100644
--- a/src/widgets/accessible/simplewidgets.cpp
+++ b/src/widgets/accessible/simplewidgets.cpp
@@ -170,7 +170,7 @@ QAccessible::State QAccessibleButton::state() const
if (b->isChecked())
state.checked = true;
#if QT_CONFIG(checkbox)
- else if (cb && cb->checkState() == Qt::PartiallyChecked)
+ if (cb && cb->checkState() == Qt::PartiallyChecked)
state.checkStateMixed = true;
#endif
if (b->isDown())
@@ -704,6 +704,8 @@ QString QAccessibleLineEdit::text(QAccessible::Text t) const
}
if (str.isEmpty())
str = QAccessibleWidget::text(t);
+ if (str.isEmpty() && t == QAccessible::Description)
+ str = lineEdit()->placeholderText();
return str;
}
@@ -777,7 +779,7 @@ QRect QAccessibleLineEdit::characterRect(int offset) const
const QString ch = text(offset, offset + 1);
if (ch.isEmpty())
return QRect();
- int w = fm.width(ch);
+ int w = fm.horizontalAdvance(ch);
int h = fm.height();
QRect r(x, y, w, h);
r.moveTo(lineEdit()->mapToGlobal(r.topLeft()));
diff --git a/src/widgets/accessible/simplewidgets_p.h b/src/widgets/accessible/simplewidgets_p.h
index 902b403d5b..fcd0e7df47 100644
--- a/src/widgets/accessible/simplewidgets_p.h
+++ b/src/widgets/accessible/simplewidgets_p.h
@@ -72,14 +72,14 @@ class QAccessibleButton : public QAccessibleWidget
public:
QAccessibleButton(QWidget *w);
- QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
- QAccessible::State state() const Q_DECL_OVERRIDE;
- QRect rect() const Q_DECL_OVERRIDE;
- QAccessible::Role role() const Q_DECL_OVERRIDE;
+ QString text(QAccessible::Text t) const override;
+ QAccessible::State state() const override;
+ QRect rect() const override;
+ QAccessible::Role role() const override;
- QStringList actionNames() const Q_DECL_OVERRIDE;
- void doAction(const QString &actionName) Q_DECL_OVERRIDE;
- QStringList keyBindingsForAction(const QString &actionName) const Q_DECL_OVERRIDE;
+ QStringList actionNames() const override;
+ void doAction(const QString &actionName) override;
+ QStringList keyBindingsForAction(const QString &actionName) const override;
protected:
QAbstractButton *button() const;
@@ -92,15 +92,15 @@ class QAccessibleToolButton : public QAccessibleButton
public:
QAccessibleToolButton(QWidget *w);
- QAccessible::State state() const Q_DECL_OVERRIDE;
- QAccessible::Role role() const Q_DECL_OVERRIDE;
+ QAccessible::State state() const override;
+ QAccessible::Role role() const override;
- int childCount() const Q_DECL_OVERRIDE;
- QAccessibleInterface *child(int index) const Q_DECL_OVERRIDE;
+ int childCount() const override;
+ QAccessibleInterface *child(int index) const override;
// QAccessibleActionInterface
- QStringList actionNames() const Q_DECL_OVERRIDE;
- void doAction(const QString &actionName) Q_DECL_OVERRIDE;
+ QStringList actionNames() const override;
+ void doAction(const QString &actionName) override;
protected:
QToolButton *toolButton() const;
@@ -114,16 +114,16 @@ class QAccessibleDisplay : public QAccessibleWidget, public QAccessibleImageInte
public:
explicit QAccessibleDisplay(QWidget *w, QAccessible::Role role = QAccessible::StaticText);
- QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
- QAccessible::Role role() const Q_DECL_OVERRIDE;
+ QString text(QAccessible::Text t) const override;
+ QAccessible::Role role() const override;
- QVector<QPair<QAccessibleInterface*, QAccessible::Relation> >relations(QAccessible::Relation match = QAccessible::AllRelations) const Q_DECL_OVERRIDE;
- void *interface_cast(QAccessible::InterfaceType t) Q_DECL_OVERRIDE;
+ QVector<QPair<QAccessibleInterface*, QAccessible::Relation> >relations(QAccessible::Relation match = QAccessible::AllRelations) const override;
+ void *interface_cast(QAccessible::InterfaceType t) override;
// QAccessibleImageInterface
- QString imageDescription() const Q_DECL_OVERRIDE;
- QSize imageSize() const Q_DECL_OVERRIDE;
- QPoint imagePosition() const Q_DECL_OVERRIDE;
+ QString imageDescription() const override;
+ QSize imageSize() const override;
+ QPoint imagePosition() const override;
};
#if QT_CONFIG(groupbox)
@@ -132,16 +132,16 @@ class QAccessibleGroupBox : public QAccessibleWidget
public:
explicit QAccessibleGroupBox(QWidget *w);
- QAccessible::State state() const Q_DECL_OVERRIDE;
- QAccessible::Role role() const Q_DECL_OVERRIDE;
- QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
+ QAccessible::State state() const override;
+ QAccessible::Role role() const override;
+ QString text(QAccessible::Text t) const override;
- QVector<QPair<QAccessibleInterface*, QAccessible::Relation> >relations(QAccessible::Relation match = QAccessible::AllRelations) const Q_DECL_OVERRIDE;
+ QVector<QPair<QAccessibleInterface*, QAccessible::Relation> >relations(QAccessible::Relation match = QAccessible::AllRelations) const override;
//QAccessibleActionInterface
- QStringList actionNames() const Q_DECL_OVERRIDE;
- void doAction(const QString &actionName) Q_DECL_OVERRIDE;
- QStringList keyBindingsForAction(const QString &) const Q_DECL_OVERRIDE;
+ QStringList actionNames() const override;
+ void doAction(const QString &actionName) override;
+ QStringList keyBindingsForAction(const QString &) const override;
private:
QGroupBox *groupBox() const;
@@ -154,36 +154,36 @@ class QAccessibleLineEdit : public QAccessibleWidget, public QAccessibleTextInte
public:
explicit QAccessibleLineEdit(QWidget *o, const QString &name = QString());
- QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
- void setText(QAccessible::Text t, const QString &text) Q_DECL_OVERRIDE;
- QAccessible::State state() const Q_DECL_OVERRIDE;
- void *interface_cast(QAccessible::InterfaceType t) Q_DECL_OVERRIDE;
+ QString text(QAccessible::Text t) const override;
+ void setText(QAccessible::Text t, const QString &text) override;
+ QAccessible::State state() const override;
+ void *interface_cast(QAccessible::InterfaceType t) override;
// QAccessibleTextInterface
- void addSelection(int startOffset, int endOffset) Q_DECL_OVERRIDE;
- QString attributes(int offset, int *startOffset, int *endOffset) const Q_DECL_OVERRIDE;
- int cursorPosition() const Q_DECL_OVERRIDE;
- QRect characterRect(int offset) const Q_DECL_OVERRIDE;
- int selectionCount() const Q_DECL_OVERRIDE;
- int offsetAtPoint(const QPoint &point) const Q_DECL_OVERRIDE;
- void selection(int selectionIndex, int *startOffset, int *endOffset) const Q_DECL_OVERRIDE;
- QString text(int startOffset, int endOffset) const Q_DECL_OVERRIDE;
+ void addSelection(int startOffset, int endOffset) override;
+ QString attributes(int offset, int *startOffset, int *endOffset) const override;
+ int cursorPosition() const override;
+ QRect characterRect(int offset) const override;
+ int selectionCount() const override;
+ int offsetAtPoint(const QPoint &point) const override;
+ void selection(int selectionIndex, int *startOffset, int *endOffset) const override;
+ QString text(int startOffset, int endOffset) const override;
QString textBeforeOffset (int offset, QAccessible::TextBoundaryType boundaryType,
- int *startOffset, int *endOffset) const Q_DECL_OVERRIDE;
+ int *startOffset, int *endOffset) const override;
QString textAfterOffset(int offset, QAccessible::TextBoundaryType boundaryType,
- int *startOffset, int *endOffset) const Q_DECL_OVERRIDE;
+ int *startOffset, int *endOffset) const override;
QString textAtOffset(int offset, QAccessible::TextBoundaryType boundaryType,
- int *startOffset, int *endOffset) const Q_DECL_OVERRIDE;
- void removeSelection(int selectionIndex) Q_DECL_OVERRIDE;
- void setCursorPosition(int position) Q_DECL_OVERRIDE;
- void setSelection(int selectionIndex, int startOffset, int endOffset) Q_DECL_OVERRIDE;
- int characterCount() const Q_DECL_OVERRIDE;
- void scrollToSubstring(int startIndex, int endIndex) Q_DECL_OVERRIDE;
+ int *startOffset, int *endOffset) const override;
+ void removeSelection(int selectionIndex) override;
+ void setCursorPosition(int position) override;
+ void setSelection(int selectionIndex, int startOffset, int endOffset) override;
+ int characterCount() const override;
+ void scrollToSubstring(int startIndex, int endIndex) override;
// QAccessibleEditableTextInterface
- void deleteText(int startOffset, int endOffset) Q_DECL_OVERRIDE;
- void insertText(int offset, const QString &text) Q_DECL_OVERRIDE;
- void replaceText(int startOffset, int endOffset, const QString &text) Q_DECL_OVERRIDE;
+ void deleteText(int startOffset, int endOffset) override;
+ void insertText(int offset, const QString &text) override;
+ void replaceText(int startOffset, int endOffset, const QString &text) override;
protected:
QLineEdit *lineEdit() const;
friend class QAccessibleAbstractSpinBox;
@@ -195,14 +195,14 @@ class QAccessibleProgressBar : public QAccessibleDisplay, public QAccessibleValu
{
public:
explicit QAccessibleProgressBar(QWidget *o);
- void *interface_cast(QAccessible::InterfaceType t) Q_DECL_OVERRIDE;
+ void *interface_cast(QAccessible::InterfaceType t) override;
// QAccessibleValueInterface
- QVariant currentValue() const Q_DECL_OVERRIDE;
- QVariant maximumValue() const Q_DECL_OVERRIDE;
- QVariant minimumValue() const Q_DECL_OVERRIDE;
- QVariant minimumStepSize() const Q_DECL_OVERRIDE;
- void setCurrentValue(const QVariant &) Q_DECL_OVERRIDE {}
+ QVariant currentValue() const override;
+ QVariant maximumValue() const override;
+ QVariant minimumValue() const override;
+ QVariant minimumStepSize() const override;
+ void setCurrentValue(const QVariant &) override {}
protected:
QProgressBar *progressBar() const;
@@ -214,9 +214,9 @@ class QAccessibleWindowContainer : public QAccessibleWidget
{
public:
QAccessibleWindowContainer(QWidget *w);
- int childCount() const Q_DECL_OVERRIDE;
- int indexOfChild(const QAccessibleInterface *child) const Q_DECL_OVERRIDE;
- QAccessibleInterface *child(int i) const Q_DECL_OVERRIDE;
+ int childCount() const override;
+ int indexOfChild(const QAccessibleInterface *child) const override;
+ QAccessibleInterface *child(int i) const override;
private:
QWindowContainer *container() const;
diff --git a/src/widgets/configure.json b/src/widgets/configure.json
index 7ec5fe9ef8..b3a5227d26 100644
--- a/src/widgets/configure.json
+++ b/src/widgets/configure.json
@@ -10,7 +10,6 @@
"options": {
"gtk": { "type": "boolean", "name": "gtk3" },
"style-windows": "boolean",
- "style-windowsxp": "boolean",
"style-windowsvista": "boolean",
"style-fusion": "boolean",
"style-mac": "boolean",
@@ -55,14 +54,9 @@
"label": "Windows",
"output": [ "privateFeature", "styles" ]
},
- "style-windowsxp": {
- "label": "WindowsXP",
- "condition": "features.style-windows && config.win32 && !config.winrt && tests.uxtheme",
- "output": [ "privateFeature", "styles" ]
- },
"style-windowsvista": {
"label": "WindowsVista",
- "condition": "features.style-windowsxp",
+ "condition": "features.style-windows && config.win32 && !config.winrt && tests.uxtheme",
"output": [ "privateFeature", "styles" ]
},
"style-android": {
@@ -692,7 +686,7 @@
{
"message": "Styles",
"type": "featureList",
- "args": "style-fusion style-mac style-windows style-windowsxp style-windowsvista style-android"
+ "args": "style-fusion style-mac style-windows style-windowsvista style-android"
}
]
}
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
index 47c2333c21..896baed6c5 100644
--- a/src/widgets/dialogs/qcolordialog.cpp
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -41,6 +41,7 @@
#include "qapplication.h"
#include "qdesktopwidget.h"
+#include <private/qdesktopwidget_p.h>
#include "qdrawutil.h"
#include "qevent.h"
#include "qimage.h"
@@ -118,6 +119,7 @@ public:
void retranslateStrings();
void _q_addCustom();
+ void _q_setCustom(int index, QRgb color);
void _q_newHsv(int h, int s, int v);
void _q_newColorTypedIn(QRgb rgb);
@@ -133,7 +135,7 @@ public:
bool handleColorPickingMouseButtonRelease(QMouseEvent *e);
bool handleColorPickingKeyPress(QKeyEvent *e);
- bool canBeNativeDialog() const Q_DECL_OVERRIDE;
+ bool canBeNativeDialog() const override;
QWellArray *custom;
QWellArray *standard;
@@ -166,8 +168,8 @@ public:
#endif
private:
- virtual void initHelper(QPlatformDialogHelper *h) Q_DECL_OVERRIDE;
- virtual void helperPrepareShow(QPlatformDialogHelper *h) Q_DECL_OVERRIDE;
+ virtual void initHelper(QPlatformDialogHelper *h) override;
+ virtual void helperPrepareShow(QPlatformDialogHelper *h) override;
};
//////////// QWellArray BEGIN
@@ -191,7 +193,7 @@ public:
virtual void setCurrent(int row, int col);
virtual void setSelected(int row, int col);
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
inline int cellWidth() const
{ return cellw; }
@@ -236,17 +238,18 @@ public:
signals:
void selected(int row, int col);
void currentChanged(int row, int col);
+ void colorChanged(int index, QRgb color);
protected:
virtual void paintCell(QPainter *, int row, int col, const QRect&);
virtual void paintCellContents(QPainter *, int row, int col, const QRect&);
- void mousePressEvent(QMouseEvent*) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent*) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent*) Q_DECL_OVERRIDE;
- void focusInEvent(QFocusEvent*) Q_DECL_OVERRIDE;
- void focusOutEvent(QFocusEvent*) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
+ void mousePressEvent(QMouseEvent*) override;
+ void mouseReleaseEvent(QMouseEvent*) override;
+ void keyPressEvent(QKeyEvent*) override;
+ void focusInEvent(QFocusEvent*) override;
+ void focusOutEvent(QFocusEvent*) override;
+ void paintEvent(QPaintEvent *) override;
private:
Q_DISABLE_COPY(QWellArray)
@@ -494,7 +497,7 @@ class QColorPickingEventFilter : public QObject {
public:
explicit QColorPickingEventFilter(QColorDialogPrivate *dp, QObject *parent = 0) : QObject(parent), m_dp(dp) {}
- bool eventFilter(QObject *, QEvent *event) Q_DECL_OVERRIDE
+ bool eventFilter(QObject *, QEvent *event) override
{
switch (event->type()) {
case QEvent::MouseMove:
@@ -580,24 +583,24 @@ namespace {
class QColorWell : public QWellArray
{
public:
- QColorWell(QWidget *parent, int r, int c, QRgb *vals)
+ QColorWell(QWidget *parent, int r, int c, const QRgb *vals)
:QWellArray(r, c, parent), values(vals), mousePressed(false), oldCurrent(-1, -1)
{ setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); }
protected:
- void paintCellContents(QPainter *, int row, int col, const QRect&) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
+ void paintCellContents(QPainter *, int row, int col, const QRect&) override;
+ void mousePressEvent(QMouseEvent *e) override;
+ void mouseMoveEvent(QMouseEvent *e) override;
+ void mouseReleaseEvent(QMouseEvent *e) override;
#ifndef QT_NO_DRAGANDDROP
- void dragEnterEvent(QDragEnterEvent *e) Q_DECL_OVERRIDE;
- void dragLeaveEvent(QDragLeaveEvent *e) Q_DECL_OVERRIDE;
- void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE;
- void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE;
+ void dragEnterEvent(QDragEnterEvent *e) override;
+ void dragLeaveEvent(QDragLeaveEvent *e) override;
+ void dragMoveEvent(QDragMoveEvent *e) override;
+ void dropEvent(QDropEvent *e) override;
#endif
private:
- QRgb *values;
+ const QRgb *values;
bool mousePressed;
QPoint pressPos;
QPoint oldCurrent;
@@ -674,8 +677,7 @@ void QColorWell::dropEvent(QDropEvent *e)
QColor col = qvariant_cast<QColor>(e->mimeData()->colorData());
if (col.isValid()) {
int i = rowAt(e->pos().y()) + columnAt(e->pos().x()) * numRows();
- values[i] = col.rgb();
- update();
+ emit colorChanged(i, col.rgb());
e->accept();
} else {
e->ignore();
@@ -707,11 +709,11 @@ signals:
void newCol(int h, int s);
protected:
- QSize sizeHint() const Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ void paintEvent(QPaintEvent*) override;
+ void mouseMoveEvent(QMouseEvent *) override;
+ void mousePressEvent(QMouseEvent *) override;
+ void resizeEvent(QResizeEvent *) override;
private:
int hue;
@@ -744,9 +746,9 @@ signals:
void newHsv(int h, int s, int v);
protected:
- void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent*) override;
+ void mouseMoveEvent(QMouseEvent *) override;
+ void mousePressEvent(QMouseEvent *) override;
private:
enum { foff = 3, coff = 4 }; //frame and contents offset
@@ -1066,14 +1068,14 @@ signals:
void colorDropped(QRgb);
protected:
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent *) override;
+ void mousePressEvent(QMouseEvent *e) override;
+ void mouseMoveEvent(QMouseEvent *e) override;
+ void mouseReleaseEvent(QMouseEvent *e) override;
#ifndef QT_NO_DRAGANDDROP
- void dragEnterEvent(QDragEnterEvent *e) Q_DECL_OVERRIDE;
- void dragLeaveEvent(QDragLeaveEvent *e) Q_DECL_OVERRIDE;
- void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE;
+ void dragEnterEvent(QDragEnterEvent *e) override;
+ void dragLeaveEvent(QDragLeaveEvent *e) override;
+ void dropEvent(QDropEvent *e) override;
#endif
private:
@@ -1559,8 +1561,7 @@ bool QColorDialogPrivate::selectColor(const QColor &col)
QColor QColorDialogPrivate::grabScreenColor(const QPoint &p)
{
const QDesktopWidget *desktop = QApplication::desktop();
- const QPixmap pixmap = QGuiApplication::screens().at(desktop->screenNumber())->grabWindow(desktop->winId(),
- p.x(), p.y(), 1, 1);
+ const QPixmap pixmap = QGuiApplication::primaryScreen()->grabWindow(desktop->winId(), p.x(), p.y(), 1, 1);
QImage i = pixmap.toImage();
return i.pixel(0, 0);
}
@@ -1700,7 +1701,7 @@ void QColorDialogPrivate::initWidgets()
#else
// small displays (e.g. PDAs) cannot fit the full color dialog,
// so just use the color picker.
- smallDisplay = (QApplication::desktop()->width() < 480 || QApplication::desktop()->height() < 350);
+ smallDisplay = (QDesktopWidgetPrivate::width() < 480 || QDesktopWidgetPrivate::height() < 350);
const int lumSpace = topLay->spacing() / 2;
#endif
@@ -1733,6 +1734,13 @@ void QColorDialogPrivate::initWidgets()
q->connect(custom, SIGNAL(selected(int,int)), SLOT(_q_newCustom(int,int)));
q->connect(custom, SIGNAL(currentChanged(int,int)), SLOT(_q_nextCustom(int,int)));
+
+ q->connect(custom, &QWellArray::colorChanged, [=] (int index, QRgb color) {
+ QColorDialogOptions::setCustomColor(index, color);
+ if (custom)
+ custom->update();
+ });
+
lblCustomColors = new QLabel(q);
#ifndef QT_NO_SHORTCUT
lblCustomColors->setBuddy(custom);
@@ -1746,7 +1754,7 @@ void QColorDialogPrivate::initWidgets()
} else {
// better color picker size for small displays
#if defined(QT_SMALL_COLORDIALOG)
- QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size();
+ QSize screenSize = QDesktopWidgetPrivate::availableGeometry(QCursor::pos()).size();
pWidth = pHeight = qMin(screenSize.width(), screenSize.height());
pHeight -= 20;
if(screenSize.height() > screenSize.width())
diff --git a/src/widgets/dialogs/qcolordialog.h b/src/widgets/dialogs/qcolordialog.h
index a27cfaf953..6451ff9bde 100644
--- a/src/widgets/dialogs/qcolordialog.h
+++ b/src/widgets/dialogs/qcolordialog.h
@@ -68,8 +68,8 @@ public:
Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)
- explicit QColorDialog(QWidget *parent = Q_NULLPTR);
- explicit QColorDialog(const QColor &initial, QWidget *parent = Q_NULLPTR);
+ explicit QColorDialog(QWidget *parent = nullptr);
+ explicit QColorDialog(const QColor &initial, QWidget *parent = nullptr);
~QColorDialog();
void setCurrentColor(const QColor &color);
@@ -85,15 +85,15 @@ public:
using QDialog::open;
void open(QObject *receiver, const char *member);
- void setVisible(bool visible) Q_DECL_OVERRIDE;
+ void setVisible(bool visible) override;
static QColor getColor(const QColor &initial = Qt::white,
- QWidget *parent = Q_NULLPTR,
+ QWidget *parent = nullptr,
const QString &title = QString(),
ColorDialogOptions options = ColorDialogOptions());
// obsolete
- static QRgb getRgba(QRgb rgba = 0xffffffff, bool *ok = Q_NULLPTR, QWidget *parent = Q_NULLPTR);
+ static QRgb getRgba(QRgb rgba = 0xffffffff, bool *ok = nullptr, QWidget *parent = nullptr);
static int customCount();
static QColor customColor(int index);
@@ -106,8 +106,8 @@ Q_SIGNALS:
void colorSelected(const QColor &color);
protected:
- void changeEvent(QEvent *event) Q_DECL_OVERRIDE;
- void done(int result) Q_DECL_OVERRIDE;
+ void changeEvent(QEvent *event) override;
+ void done(int result) override;
private:
Q_DISABLE_COPY(QColorDialog)
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp
index 6f7567a94f..f5db4481ee 100644
--- a/src/widgets/dialogs/qdialog.cpp
+++ b/src/widgets/dialogs/qdialog.cpp
@@ -50,6 +50,7 @@
#include "qevent.h"
#include "qdesktopwidget.h"
+#include <private/qdesktopwidget_p.h>
#include "qapplication.h"
#include "qlayout.h"
#if QT_CONFIG(sizegrip)
@@ -815,13 +816,13 @@ void QDialog::adjustPosition(QWidget* w)
w = w->window();
QRect desk;
if (w) {
- scrn = QApplication::desktop()->screenNumber(w);
- } else if (QApplication::desktop()->isVirtualDesktop()) {
- scrn = QApplication::desktop()->screenNumber(QCursor::pos());
+ scrn = QDesktopWidgetPrivate::screenNumber(w);
+ } else if (QDesktopWidgetPrivate::isVirtualDesktop()) {
+ scrn = QDesktopWidgetPrivate::screenNumber(QCursor::pos());
} else {
- scrn = QApplication::desktop()->screenNumber(this);
+ scrn = QDesktopWidgetPrivate::screenNumber(this);
}
- desk = QApplication::desktop()->availableGeometry(scrn);
+ desk = QDesktopWidgetPrivate::availableGeometry(scrn);
QWidgetList list = QApplication::topLevelWidgets();
for (int i = 0; (extraw == 0 || extrah == 0) && i < list.size(); ++i) {
diff --git a/src/widgets/dialogs/qdialog.h b/src/widgets/dialogs/qdialog.h
index 72250172d3..7f267dd939 100644
--- a/src/widgets/dialogs/qdialog.h
+++ b/src/widgets/dialogs/qdialog.h
@@ -60,7 +60,7 @@ class Q_WIDGETS_EXPORT QDialog : public QWidget
Q_PROPERTY(bool modal READ isModal WRITE setModal)
public:
- explicit QDialog(QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
+ explicit QDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
~QDialog();
enum DialogCode { Rejected, Accepted };
diff --git a/src/widgets/dialogs/qdialog_p.h b/src/widgets/dialogs/qdialog_p.h
index 2ed414bd45..99fff08e65 100644
--- a/src/widgets/dialogs/qdialog_p.h
+++ b/src/widgets/dialogs/qdialog_p.h
@@ -143,7 +143,7 @@ public:
T *operator->() const Q_DECL_NOTHROW { return get(); }
T *get() const Q_DECL_NOTHROW { return o; }
T &operator*() const { return *get(); }
- operator RestrictedBool() const Q_DECL_NOTHROW { return o ? &internal::func : Q_NULLPTR; }
+ operator RestrictedBool() const Q_DECL_NOTHROW { return o ? &internal::func : nullptr; }
bool operator!() const Q_DECL_NOTHROW { return !o; }
private:
Q_DISABLE_COPY(QAutoPointer);
diff --git a/src/widgets/dialogs/qerrormessage.cpp b/src/widgets/dialogs/qerrormessage.cpp
index 39035b743d..fd68f19680 100644
--- a/src/widgets/dialogs/qerrormessage.cpp
+++ b/src/widgets/dialogs/qerrormessage.cpp
@@ -95,8 +95,8 @@ public:
QErrorMessageTextView(QWidget *parent)
: QTextEdit(parent) { setReadOnly(true); }
- virtual QSize minimumSizeHint() const Q_DECL_OVERRIDE;
- virtual QSize sizeHint() const Q_DECL_OVERRIDE;
+ virtual QSize minimumSizeHint() const override;
+ virtual QSize sizeHint() const override;
};
} // unnamed namespace
diff --git a/src/widgets/dialogs/qerrormessage.h b/src/widgets/dialogs/qerrormessage.h
index 4cb1fad845..220694e54e 100644
--- a/src/widgets/dialogs/qerrormessage.h
+++ b/src/widgets/dialogs/qerrormessage.h
@@ -55,7 +55,7 @@ class Q_WIDGETS_EXPORT QErrorMessage: public QDialog
Q_OBJECT
Q_DECLARE_PRIVATE(QErrorMessage)
public:
- explicit QErrorMessage(QWidget* parent = Q_NULLPTR);
+ explicit QErrorMessage(QWidget* parent = nullptr);
~QErrorMessage();
static QErrorMessage * qtHandler();
@@ -65,8 +65,8 @@ public Q_SLOTS:
void showMessage(const QString &message, const QString &type);
protected:
- void done(int) Q_DECL_OVERRIDE;
- void changeEvent(QEvent *e) Q_DECL_OVERRIDE;
+ void done(int) override;
+ void changeEvent(QEvent *e) override;
private:
Q_DISABLE_COPY(QErrorMessage)
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index cb2c534b24..3d91bdef34 100644
--- a/src/widgets/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
@@ -1994,7 +1994,7 @@ QFileIconProvider *QFileDialog::iconProvider() const
{
Q_D(const QFileDialog);
if (!d->model)
- return Q_NULLPTR;
+ return nullptr;
return d->model->iconProvider();
}
@@ -2953,10 +2953,10 @@ void QFileDialogPrivate::createWidgets()
qFileDialogUi->treeView->setModel(model);
QHeaderView *treeHeader = qFileDialogUi->treeView->header();
QFontMetrics fm(q->font());
- treeHeader->resizeSection(0, fm.width(QLatin1String("wwwwwwwwwwwwwwwwwwwwwwwwww")));
- treeHeader->resizeSection(1, fm.width(QLatin1String("128.88 GB")));
- treeHeader->resizeSection(2, fm.width(QLatin1String("mp3Folder")));
- treeHeader->resizeSection(3, fm.width(QLatin1String("10/29/81 02:02PM")));
+ treeHeader->resizeSection(0, fm.horizontalAdvance(QLatin1String("wwwwwwwwwwwwwwwwwwwwwwwwww")));
+ treeHeader->resizeSection(1, fm.horizontalAdvance(QLatin1String("128.88 GB")));
+ treeHeader->resizeSection(2, fm.horizontalAdvance(QLatin1String("mp3Folder")));
+ treeHeader->resizeSection(3, fm.horizontalAdvance(QLatin1String("10/29/81 02:02PM")));
treeHeader->setContextMenuPolicy(Qt::ActionsContextMenu);
QActionGroup *showActionGroup = new QActionGroup(q);
@@ -3624,7 +3624,7 @@ void QFileDialogPrivate::_q_enterDirectory(const QModelIndex &index)
}
} else {
// Do not accept when shift-clicking to multi-select a file in environments with single-click-activation (KDE)
- if (!q->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, Q_NULLPTR, qFileDialogUi->treeView)
+ if (!q->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick, nullptr, qFileDialogUi->treeView)
|| q->fileMode() != QFileDialog::ExistingFiles || !(QGuiApplication::keyboardModifiers() & Qt::CTRL)) {
q->accept();
}
diff --git a/src/widgets/dialogs/qfiledialog.h b/src/widgets/dialogs/qfiledialog.h
index b9092e036d..1cbd690f24 100644
--- a/src/widgets/dialogs/qfiledialog.h
+++ b/src/widgets/dialogs/qfiledialog.h
@@ -98,7 +98,7 @@ public:
Q_FLAG(Options)
QFileDialog(QWidget *parent, Qt::WindowFlags f);
- explicit QFileDialog(QWidget *parent = Q_NULLPTR,
+ explicit QFileDialog(QWidget *parent = nullptr,
const QString &caption = QString(),
const QString &directory = QString(),
const QString &filter = QString());
@@ -190,7 +190,7 @@ public:
using QDialog::open;
void open(QObject *receiver, const char *member);
- void setVisible(bool visible) Q_DECL_OVERRIDE;
+ void setVisible(bool visible) override;
Q_SIGNALS:
void fileSelected(const QString &file);
@@ -207,68 +207,68 @@ Q_SIGNALS:
public:
- static QString getOpenFileName(QWidget *parent = Q_NULLPTR,
+ static QString getOpenFileName(QWidget *parent = nullptr,
const QString &caption = QString(),
const QString &dir = QString(),
const QString &filter = QString(),
- QString *selectedFilter = Q_NULLPTR,
+ QString *selectedFilter = nullptr,
Options options = Options());
- static QUrl getOpenFileUrl(QWidget *parent = Q_NULLPTR,
+ static QUrl getOpenFileUrl(QWidget *parent = nullptr,
const QString &caption = QString(),
const QUrl &dir = QUrl(),
const QString &filter = QString(),
- QString *selectedFilter = Q_NULLPTR,
+ QString *selectedFilter = nullptr,
Options options = Options(),
const QStringList &supportedSchemes = QStringList());
- static QString getSaveFileName(QWidget *parent = Q_NULLPTR,
+ static QString getSaveFileName(QWidget *parent = nullptr,
const QString &caption = QString(),
const QString &dir = QString(),
const QString &filter = QString(),
- QString *selectedFilter = Q_NULLPTR,
+ QString *selectedFilter = nullptr,
Options options = Options());
- static QUrl getSaveFileUrl(QWidget *parent = Q_NULLPTR,
+ static QUrl getSaveFileUrl(QWidget *parent = nullptr,
const QString &caption = QString(),
const QUrl &dir = QUrl(),
const QString &filter = QString(),
- QString *selectedFilter = Q_NULLPTR,
+ QString *selectedFilter = nullptr,
Options options = Options(),
const QStringList &supportedSchemes = QStringList());
- static QString getExistingDirectory(QWidget *parent = Q_NULLPTR,
+ static QString getExistingDirectory(QWidget *parent = nullptr,
const QString &caption = QString(),
const QString &dir = QString(),
Options options = ShowDirsOnly);
- static QUrl getExistingDirectoryUrl(QWidget *parent = Q_NULLPTR,
+ static QUrl getExistingDirectoryUrl(QWidget *parent = nullptr,
const QString &caption = QString(),
const QUrl &dir = QUrl(),
Options options = ShowDirsOnly,
const QStringList &supportedSchemes = QStringList());
- static QStringList getOpenFileNames(QWidget *parent = Q_NULLPTR,
+ static QStringList getOpenFileNames(QWidget *parent = nullptr,
const QString &caption = QString(),
const QString &dir = QString(),
const QString &filter = QString(),
- QString *selectedFilter = Q_NULLPTR,
+ QString *selectedFilter = nullptr,
Options options = Options());
- static QList<QUrl> getOpenFileUrls(QWidget *parent = Q_NULLPTR,
+ static QList<QUrl> getOpenFileUrls(QWidget *parent = nullptr,
const QString &caption = QString(),
const QUrl &dir = QUrl(),
const QString &filter = QString(),
- QString *selectedFilter = Q_NULLPTR,
+ QString *selectedFilter = nullptr,
Options options = Options(),
const QStringList &supportedSchemes = QStringList());
protected:
QFileDialog(const QFileDialogArgs &args);
- void done(int result) Q_DECL_OVERRIDE;
- void accept() Q_DECL_OVERRIDE;
- void changeEvent(QEvent *e) Q_DECL_OVERRIDE;
+ void done(int result) override;
+ void accept() override;
+ void changeEvent(QEvent *e) override;
private:
Q_DECLARE_PRIVATE(QFileDialog)
diff --git a/src/widgets/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h
index 371826eccc..17290381d3 100644
--- a/src/widgets/dialogs/qfiledialog_p.h
+++ b/src/widgets/dialogs/qfiledialog_p.h
@@ -254,7 +254,7 @@ public:
// setVisible_sys returns true if it ends up showing a native
// dialog. Returning false means that a non-native dialog must be
// used instead.
- bool canBeNativeDialog() const Q_DECL_OVERRIDE;
+ bool canBeNativeDialog() const override;
inline bool usingWidgets() const;
inline void setDirectory_sys(const QUrl &directory);
@@ -286,9 +286,9 @@ public:
~QFileDialogPrivate();
private:
- virtual void initHelper(QPlatformDialogHelper *) Q_DECL_OVERRIDE;
- virtual void helperPrepareShow(QPlatformDialogHelper *) Q_DECL_OVERRIDE;
- virtual void helperDone(QDialog::DialogCode, QPlatformDialogHelper *) Q_DECL_OVERRIDE;
+ virtual void initHelper(QPlatformDialogHelper *) override;
+ virtual void helperPrepareShow(QPlatformDialogHelper *) override;
+ virtual void helperDone(QDialog::DialogCode, QPlatformDialogHelper *) override;
Q_DISABLE_COPY(QFileDialogPrivate)
};
@@ -298,7 +298,7 @@ class QFileDialogLineEdit : public QLineEdit
public:
QFileDialogLineEdit(QWidget *parent = 0) : QLineEdit(parent), d_ptr(0){}
void setFileDialogPrivate(QFileDialogPrivate *d_pointer) {d_ptr = d_pointer; }
- void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
+ void keyPressEvent(QKeyEvent *e) override;
bool hideOnEsc;
private:
QFileDialogPrivate *d_ptr;
@@ -309,10 +309,10 @@ class QFileDialogComboBox : public QComboBox
public:
QFileDialogComboBox(QWidget *parent = 0) : QComboBox(parent), urlModel(0) {}
void setFileDialogPrivate(QFileDialogPrivate *d_pointer);
- void showPopup() Q_DECL_OVERRIDE;
+ void showPopup() override;
void setHistory(const QStringList &paths);
QStringList history() const { return m_history; }
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent *) override;
private:
QUrlModel *urlModel;
@@ -325,9 +325,9 @@ class QFileDialogListView : public QListView
public:
QFileDialogListView(QWidget *parent = 0);
void setFileDialogPrivate(QFileDialogPrivate *d_pointer);
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
protected:
- void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
+ void keyPressEvent(QKeyEvent *e) override;
private:
QFileDialogPrivate *d_ptr;
};
@@ -337,10 +337,10 @@ class QFileDialogTreeView : public QTreeView
public:
QFileDialogTreeView(QWidget *parent);
void setFileDialogPrivate(QFileDialogPrivate *d_pointer);
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
protected:
- void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
+ void keyPressEvent(QKeyEvent *e) override;
private:
QFileDialogPrivate *d_ptr;
};
diff --git a/src/widgets/dialogs/qfileinfogatherer_p.h b/src/widgets/dialogs/qfileinfogatherer_p.h
index 0cf2ed1f58..cc82f42850 100644
--- a/src/widgets/dialogs/qfileinfogatherer_p.h
+++ b/src/widgets/dialogs/qfileinfogatherer_p.h
@@ -167,6 +167,13 @@ public:
explicit QFileInfoGatherer(QObject *parent = 0);
~QFileInfoGatherer();
+#if QT_CONFIG(filesystemwatcher) && defined(Q_OS_WIN)
+ QStringList watchedFiles() const { return watcher->files(); }
+ QStringList watchedDirectories() const { return watcher->directories(); }
+ void watchPaths(const QStringList &paths) { watcher->addPaths(paths); }
+ void unwatchPaths(const QStringList &paths) { watcher->removePaths(paths); }
+#endif // filesystemwatcher && Q_OS_WIN
+
// only callable from this->thread():
void clear();
void removePath(const QString &path);
@@ -186,7 +193,7 @@ private Q_SLOTS:
void driveRemoved();
private:
- void run() Q_DECL_OVERRIDE;
+ void run() override;
// called by run():
void getFileInfos(const QString &path, const QStringList &files);
void fetch(const QFileInfo &info, QElapsedTimer &base, bool &firstTime, QVector<QPair<QString, QFileInfo> > &updatedFiles, const QString &path);
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index bf88aaa467..33b8b51216 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -207,14 +207,17 @@ bool QFileSystemModel::remove(const QModelIndex &aindex)
const QString path = d->filePath(aindex);
const QFileInfo fileInfo(path);
+#if QT_CONFIG(filesystemwatcher) && defined(Q_OS_WIN)
+ // QTBUG-65683: Remove file system watchers prior to deletion to prevent
+ // failure due to locked files on Windows.
+ const QStringList watchedPaths = d->unwatchPathsAt(aindex);
+#endif // filesystemwatcher && Q_OS_WIN
const bool success = (fileInfo.isFile() || fileInfo.isSymLink())
? QFile::remove(path) : QDir(path).removeRecursively();
-#ifndef QT_NO_FILESYSTEMWATCHER
- if (success) {
- QFileSystemModelPrivate * d = const_cast<QFileSystemModelPrivate*>(d_func());
- d->fileInfoGatherer.removePath(path);
- }
-#endif
+#if QT_CONFIG(filesystemwatcher) && defined(Q_OS_WIN)
+ if (!success)
+ d->watchPaths(watchedPaths);
+#endif // filesystemwatcher && Q_OS_WIN
return success;
}
@@ -781,21 +784,7 @@ QString QFileSystemModelPrivate::size(const QModelIndex &index) const
QString QFileSystemModelPrivate::size(qint64 bytes)
{
- // According to the Si standard KB is 1000 bytes, KiB is 1024
- // but on windows sizes are calculated by dividing by 1024 so we do what they do.
- const qint64 kb = 1024;
- const qint64 mb = 1024 * kb;
- const qint64 gb = 1024 * mb;
- const qint64 tb = 1024 * gb;
- if (bytes >= tb)
- return QFileSystemModel::tr("%1 TB").arg(QLocale().toString(qreal(bytes) / tb, 'f', 3));
- if (bytes >= gb)
- return QFileSystemModel::tr("%1 GB").arg(QLocale().toString(qreal(bytes) / gb, 'f', 2));
- if (bytes >= mb)
- return QFileSystemModel::tr("%1 MB").arg(QLocale().toString(qreal(bytes) / mb, 'f', 1));
- if (bytes >= kb)
- return QFileSystemModel::tr("%1 KB").arg(QLocale().toString(bytes / kb));
- return QFileSystemModel::tr("%1 bytes").arg(QLocale().toString(bytes));
+ return QLocale::system().formattedDataSize(bytes);
}
/*!
@@ -865,6 +854,20 @@ QIcon QFileSystemModelPrivate::icon(const QModelIndex &index) const
return node(index)->icon();
}
+static void displayRenameFailedMessage(const QString &newName)
+{
+#if QT_CONFIG(messagebox)
+ const QString message =
+ QFileSystemModel::tr("<b>The name \"%1\" cannot be used.</b>"
+ "<p>Try using another name, with fewer characters or no punctuation marks.")
+ .arg(newName);
+ QMessageBox::information(nullptr, QFileSystemModel::tr("Invalid filename"),
+ message, QMessageBox::Ok);
+#else
+ Q_UNUSED(newName)
+#endif // QT_CONFIG(messagebox)
+}
+
/*!
\reimp
*/
@@ -885,15 +888,21 @@ bool QFileSystemModel::setData(const QModelIndex &idx, const QVariant &value, in
const QString parentPath = filePath(parent(idx));
- if (newName.isEmpty()
- || QDir::toNativeSeparators(newName).contains(QDir::separator())
- || !QDir(parentPath).rename(oldName, newName)) {
-#if QT_CONFIG(messagebox)
- QMessageBox::information(0, QFileSystemModel::tr("Invalid filename"),
- QFileSystemModel::tr("<b>The name \"%1\" can not be used.</b><p>Try using another name, with fewer characters or no punctuations marks.")
- .arg(newName),
- QMessageBox::Ok);
-#endif // QT_CONFIG(messagebox)
+ if (newName.isEmpty() || QDir::toNativeSeparators(newName).contains(QDir::separator())) {
+ displayRenameFailedMessage(newName);
+ return false;
+ }
+
+#if QT_CONFIG(filesystemwatcher) && defined(Q_OS_WIN)
+ // QTBUG-65683: Remove file system watchers prior to renaming to prevent
+ // failure due to locked files on Windows.
+ const QStringList watchedPaths = d->unwatchPathsAt(idx);
+#endif // filesystemwatcher && Q_OS_WIN
+ if (!QDir(parentPath).rename(oldName, newName)) {
+#if QT_CONFIG(filesystemwatcher) && defined(Q_OS_WIN)
+ d->watchPaths(watchedPaths);
+#endif
+ displayRenameFailedMessage(newName);
return false;
} else {
/*
@@ -1896,6 +1905,46 @@ void QFileSystemModelPrivate::_q_resolvedName(const QString &fileName, const QSt
resolvedSymLinks[fileName] = resolvedName;
}
+#if QT_CONFIG(filesystemwatcher) && defined(Q_OS_WIN)
+// Remove file system watchers at/below the index and return a list of previously
+// watched files. This should be called prior to operations like rename/remove
+// which might fail due to watchers on platforms like Windows. The watchers
+// should be restored on failure.
+QStringList QFileSystemModelPrivate::unwatchPathsAt(const QModelIndex &index)
+{
+ const QFileSystemModelPrivate::QFileSystemNode *indexNode = node(index);
+ if (indexNode == nullptr)
+ return QStringList();
+ const Qt::CaseSensitivity caseSensitivity = indexNode->caseSensitive()
+ ? Qt::CaseSensitive : Qt::CaseInsensitive;
+ const QString path = indexNode->fileInfo().absoluteFilePath();
+
+ QStringList result;
+ const auto filter = [path, caseSensitivity] (const QString &watchedPath)
+ {
+ const int pathSize = path.size();
+ if (pathSize == watchedPath.size()) {
+ return path.compare(watchedPath, caseSensitivity) == 0;
+ } else if (watchedPath.size() > pathSize) {
+ return watchedPath.at(pathSize) == QLatin1Char('/')
+ && watchedPath.startsWith(path, caseSensitivity);
+ }
+ return false;
+ };
+
+ const QStringList &watchedFiles = fileInfoGatherer.watchedFiles();
+ std::copy_if(watchedFiles.cbegin(), watchedFiles.cend(),
+ std::back_inserter(result), filter);
+
+ const QStringList &watchedDirectories = fileInfoGatherer.watchedDirectories();
+ std::copy_if(watchedDirectories.cbegin(), watchedDirectories.cend(),
+ std::back_inserter(result), filter);
+
+ fileInfoGatherer.unwatchPaths(result);
+ return result;
+}
+#endif // filesystemwatcher && Q_OS_WIN
+
/*!
\internal
*/
diff --git a/src/widgets/dialogs/qfilesystemmodel.h b/src/widgets/dialogs/qfilesystemmodel.h
index a5f23c9220..c2c8b8818e 100644
--- a/src/widgets/dialogs/qfilesystemmodel.h
+++ b/src/widgets/dialogs/qfilesystemmodel.h
@@ -75,36 +75,36 @@ public:
FilePermissions = Qt::UserRole + 3
};
- explicit QFileSystemModel(QObject *parent = Q_NULLPTR);
+ explicit QFileSystemModel(QObject *parent = nullptr);
~QFileSystemModel();
- QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
QModelIndex index(const QString &path, int column = 0) const;
- QModelIndex parent(const QModelIndex &child) const Q_DECL_OVERRIDE;
+ QModelIndex parent(const QModelIndex &child) const override;
using QObject::parent;
- QModelIndex sibling(int row, int column, const QModelIndex &idx) const Q_DECL_OVERRIDE;
- bool hasChildren(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
- bool canFetchMore(const QModelIndex &parent) const Q_DECL_OVERRIDE;
- void fetchMore(const QModelIndex &parent) Q_DECL_OVERRIDE;
+ QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
+ bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
+ bool canFetchMore(const QModelIndex &parent) const override;
+ void fetchMore(const QModelIndex &parent) override;
- int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
- int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant myComputer(int role = Qt::DisplayRole) const;
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
- bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) Q_DECL_OVERRIDE;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
- QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
- Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE;
+ Qt::ItemFlags flags(const QModelIndex &index) const override;
- void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) Q_DECL_OVERRIDE;
+ void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
- QStringList mimeTypes() const Q_DECL_OVERRIDE;
- QMimeData *mimeData(const QModelIndexList &indexes) const Q_DECL_OVERRIDE;
+ QStringList mimeTypes() const override;
+ QMimeData *mimeData(const QModelIndexList &indexes) const override;
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
- int row, int column, const QModelIndex &parent) Q_DECL_OVERRIDE;
- Qt::DropActions supportedDropActions() const Q_DECL_OVERRIDE;
+ int row, int column, const QModelIndex &parent) override;
+ Qt::DropActions supportedDropActions() const override;
// QFileSystemModel specific API
QModelIndex setRootPath(const QString &path);
@@ -144,9 +144,9 @@ public:
bool remove(const QModelIndex &index);
protected:
- QFileSystemModel(QFileSystemModelPrivate &, QObject *parent = Q_NULLPTR);
- void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE;
- bool event(QEvent *event) Q_DECL_OVERRIDE;
+ QFileSystemModel(QFileSystemModelPrivate &, QObject *parent = nullptr);
+ void timerEvent(QTimerEvent *event) override;
+ bool event(QEvent *event) override;
private:
Q_DECLARE_PRIVATE(QFileSystemModel)
diff --git a/src/widgets/dialogs/qfilesystemmodel_p.h b/src/widgets/dialogs/qfilesystemmodel_p.h
index e8bae4f659..a2a02e2d41 100644
--- a/src/widgets/dialogs/qfilesystemmodel_p.h
+++ b/src/widgets/dialogs/qfilesystemmodel_p.h
@@ -297,9 +297,13 @@ public:
static int naturalCompare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs);
QDir rootDir;
-#ifndef QT_NO_FILESYSTEMWATCHER
+#if QT_CONFIG(filesystemwatcher)
+# ifdef Q_OS_WIN
+ QStringList unwatchPathsAt(const QModelIndex &);
+ void watchPaths(const QStringList &paths) { fileInfoGatherer.watchPaths(paths); }
+# endif // Q_OS_WIN
QFileInfoGatherer fileInfoGatherer;
-#endif
+#endif // filesystemwatcher
QTimer delayedSortTimer;
bool forceSort;
int sortColumn;
diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp
index 587e31d8c5..5f912c582f 100644
--- a/src/widgets/dialogs/qfontdialog.cpp
+++ b/src/widgets/dialogs/qfontdialog.cpp
@@ -84,7 +84,7 @@ public:
int row = QListView::currentIndex().row();
return row < 0 ? QString() : model()->stringList().at(row);
}
- void currentChanged(const QModelIndex &current, const QModelIndex &previous) Q_DECL_OVERRIDE {
+ void currentChanged(const QModelIndex &current, const QModelIndex &previous) override {
QListView::currentChanged(current, previous);
if (current.isValid())
emit highlighted(current.row());
diff --git a/src/widgets/dialogs/qfontdialog.h b/src/widgets/dialogs/qfontdialog.h
index 3fb3997b85..ae1320e779 100644
--- a/src/widgets/dialogs/qfontdialog.h
+++ b/src/widgets/dialogs/qfontdialog.h
@@ -72,8 +72,8 @@ public:
Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)
- explicit QFontDialog(QWidget *parent = Q_NULLPTR);
- explicit QFontDialog(const QFont &initial, QWidget *parent = Q_NULLPTR);
+ explicit QFontDialog(QWidget *parent = nullptr);
+ explicit QFontDialog(const QFont &initial, QWidget *parent = nullptr);
~QFontDialog();
void setCurrentFont(const QFont &font);
@@ -89,10 +89,10 @@ public:
using QDialog::open;
void open(QObject *receiver, const char *member);
- void setVisible(bool visible) Q_DECL_OVERRIDE;
+ void setVisible(bool visible) override;
- static QFont getFont(bool *ok, QWidget *parent = Q_NULLPTR);
- static QFont getFont(bool *ok, const QFont &initial, QWidget *parent = Q_NULLPTR, const QString &title = QString(),
+ static QFont getFont(bool *ok, QWidget *parent = nullptr);
+ static QFont getFont(bool *ok, const QFont &initial, QWidget *parent = nullptr, const QString &title = QString(),
FontDialogOptions options = FontDialogOptions());
Q_SIGNALS:
@@ -100,9 +100,9 @@ Q_SIGNALS:
void fontSelected(const QFont &font);
protected:
- void changeEvent(QEvent *event) Q_DECL_OVERRIDE;
- void done(int result) Q_DECL_OVERRIDE;
- bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
+ void changeEvent(QEvent *event) override;
+ void done(int result) override;
+ bool eventFilter(QObject *object, QEvent *event) override;
private:
Q_DISABLE_COPY(QFontDialog)
diff --git a/src/widgets/dialogs/qfontdialog_p.h b/src/widgets/dialogs/qfontdialog_p.h
index ae923d94ed..202247a3b4 100644
--- a/src/widgets/dialogs/qfontdialog_p.h
+++ b/src/widgets/dialogs/qfontdialog_p.h
@@ -141,12 +141,12 @@ public:
QPointer<QObject> receiverToDisconnectOnClose;
QByteArray memberToDisconnectOnClose;
- bool canBeNativeDialog() const Q_DECL_OVERRIDE;
+ bool canBeNativeDialog() const override;
void _q_runNativeAppModalPanel();
private:
- virtual void initHelper(QPlatformDialogHelper *) Q_DECL_OVERRIDE;
- virtual void helperPrepareShow(QPlatformDialogHelper *) Q_DECL_OVERRIDE;
+ virtual void initHelper(QPlatformDialogHelper *) override;
+ virtual void helperPrepareShow(QPlatformDialogHelper *) override;
};
QT_END_NAMESPACE
diff --git a/src/widgets/dialogs/qfscompleter_p.h b/src/widgets/dialogs/qfscompleter_p.h
index ce0612f293..3b829d4a52 100644
--- a/src/widgets/dialogs/qfscompleter_p.h
+++ b/src/widgets/dialogs/qfscompleter_p.h
@@ -71,8 +71,8 @@ public:
setCaseSensitivity(Qt::CaseInsensitive);
#endif
}
- QString pathFromIndex(const QModelIndex &index) const Q_DECL_OVERRIDE;
- QStringList splitPath(const QString& path) const Q_DECL_OVERRIDE;
+ QString pathFromIndex(const QModelIndex &index) const override;
+ QStringList splitPath(const QString& path) const override;
QAbstractProxyModel *proxyModel;
QFileSystemModel *sourceModel;
diff --git a/src/widgets/dialogs/qinputdialog.cpp b/src/widgets/dialogs/qinputdialog.cpp
index 04d13045e5..5c6e0f45a5 100644
--- a/src/widgets/dialogs/qinputdialog.cpp
+++ b/src/widgets/dialogs/qinputdialog.cpp
@@ -71,10 +71,11 @@ static const char *candidateSignal(int which)
case IntValueSelectedSignal: return SIGNAL(intValueSelected(int));
case DoubleValueSelectedSignal: return SIGNAL(doubleValueSelected(double));
- case NumCandidateSignals: ; // fall through
+ case NumCandidateSignals:
+ break;
};
Q_UNREACHABLE();
- return Q_NULLPTR;
+ return nullptr;
}
static const char *signalForMember(const char *member)
@@ -115,7 +116,7 @@ private slots:
void notifyTextChanged() { emit textChanged(hasAcceptableInput()); }
private:
- void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE {
+ void keyPressEvent(QKeyEvent *event) override {
if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && !hasAcceptableInput()) {
#ifndef QT_NO_PROPERTIES
setProperty("value", property("value"));
@@ -126,7 +127,7 @@ private:
notifyTextChanged();
}
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE {
+ void mousePressEvent(QMouseEvent *event) override {
QSpinBox::mousePressEvent(event);
notifyTextChanged();
}
@@ -150,7 +151,7 @@ private slots:
void notifyTextChanged() { emit textChanged(hasAcceptableInput()); }
private:
- void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE {
+ void keyPressEvent(QKeyEvent *event) override {
if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && !hasAcceptableInput()) {
#ifndef QT_NO_PROPERTIES
setProperty("value", property("value"));
@@ -161,7 +162,7 @@ private:
notifyTextChanged();
}
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE {
+ void mousePressEvent(QMouseEvent *event) override {
QDoubleSpinBox::mousePressEvent(event);
notifyTextChanged();
}
@@ -239,7 +240,6 @@ void QInputDialogPrivate::ensureLayout()
QObject::connect(buttonBox, SIGNAL(rejected()), q, SLOT(reject()));
mainLayout = new QVBoxLayout(q);
- //we want to let the input dialog grow to available size on Symbian.
mainLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
mainLayout->addWidget(label);
mainLayout->addWidget(inputWidget);
@@ -1312,7 +1312,7 @@ int QInputDialog::getInt(QWidget *parent, const QString &title, const QString &l
}
/*!
- \fn QInputDialog::getInteger(QWidget *parent, const QString &title, const QString &label, int value, int min, int max, int step, bool *ok, Qt::WindowFlags flags)
+ \fn int QInputDialog::getInteger(QWidget *parent, const QString &title, const QString &label, int value, int min, int max, int step, bool *ok, Qt::WindowFlags flags)
\deprecated use getInt()
Static convenience function to get an integer input from the user.
@@ -1368,12 +1368,48 @@ double QInputDialog::getDouble(QWidget *parent, const QString &title, const QStr
double value, double min, double max, int decimals, bool *ok,
Qt::WindowFlags flags)
{
+ return QInputDialog::getDouble(parent, title, label, value, min, max, decimals, ok, flags, 1.0);
+}
+
+/*!
+ \overload
+ Static convenience function to get a floating point number from the user.
+
+ \a title is the text which is displayed in the title bar of the dialog.
+ \a label is the text which is shown to the user (it should say what should
+ be entered).
+ \a value is the default floating point number that the line edit will be
+ set to.
+ \a min and \a max are the minimum and maximum values the user may choose.
+ \a decimals is the maximum number of decimal places the number may have.
+ \a step is the amount by which the values change as the user presses the
+ arrow buttons to increment or decrement the value.
+
+ If \a ok is nonnull, *\a ok will be set to true if the user pressed \uicontrol OK
+ and to false if the user pressed \uicontrol Cancel. The dialog's parent is
+ \a parent. The dialog will be modal and uses the widget \a flags.
+
+ This function returns the floating point number which has been entered by
+ the user.
+
+ Use this static function like this:
+
+ \snippet dialogs/standarddialogs/dialog.cpp 1
+
+ \sa getText(), getInt(), getItem(), getMultiLineText()
+*/
+
+double QInputDialog::getDouble(QWidget *parent, const QString &title, const QString &label,
+ double value, double min, double max, int decimals, bool *ok,
+ Qt::WindowFlags flags, double step)
+{
QAutoPointer<QInputDialog> dialog(new QInputDialog(parent, flags));
dialog->setWindowTitle(title);
dialog->setLabelText(label);
dialog->setDoubleDecimals(decimals);
dialog->setDoubleRange(min, max);
dialog->setDoubleValue(value);
+ dialog->setDoubleStep(step);
const int ret = dialog->exec();
if (ok)
@@ -1439,6 +1475,31 @@ QString QInputDialog::getItem(QWidget *parent, const QString &title, const QStri
}
/*!
+ \property QInputDialog::doubleStep
+ \since 5.10
+ \brief the step by which the double value is increased and decreased
+
+ This property is only relevant when the input dialog is used in
+ DoubleInput mode.
+*/
+
+void QInputDialog::setDoubleStep(double step)
+{
+ Q_D(QInputDialog);
+ d->ensureDoubleSpinBox();
+ d->doubleSpinBox->setSingleStep(step);
+}
+
+double QInputDialog::doubleStep() const
+{
+ Q_D(const QInputDialog);
+ if (d->doubleSpinBox)
+ return d->doubleSpinBox->singleStep();
+ else
+ return 1.0;
+}
+
+/*!
\fn void QInputDialog::doubleValueChanged(double value)
This signal is emitted whenever the double value changes in the dialog.
diff --git a/src/widgets/dialogs/qinputdialog.h b/src/widgets/dialogs/qinputdialog.h
index 5f06785886..c3a5e59d53 100644
--- a/src/widgets/dialogs/qinputdialog.h
+++ b/src/widgets/dialogs/qinputdialog.h
@@ -74,6 +74,7 @@ class Q_WIDGETS_EXPORT QInputDialog : public QDialog
QDOC_PROPERTY(int doubleDecimals READ doubleDecimals WRITE setDoubleDecimals)
QDOC_PROPERTY(QString okButtonText READ okButtonText WRITE setOkButtonText)
QDOC_PROPERTY(QString cancelButtonText READ cancelButtonText WRITE setCancelButtonText)
+ QDOC_PROPERTY(double doubleStep READ doubleStep WRITE setDoubleStep)
public:
enum InputDialogOption {
@@ -90,7 +91,7 @@ public:
DoubleInput
};
- QInputDialog(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
+ QInputDialog(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
~QInputDialog();
void setInputMode(InputMode mode);
@@ -153,41 +154,48 @@ public:
using QDialog::open;
void open(QObject *receiver, const char *member);
- QSize minimumSizeHint() const Q_DECL_OVERRIDE;
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ QSize minimumSizeHint() const override;
+ QSize sizeHint() const override;
- void setVisible(bool visible) Q_DECL_OVERRIDE;
+ void setVisible(bool visible) override;
static QString getText(QWidget *parent, const QString &title, const QString &label,
QLineEdit::EchoMode echo = QLineEdit::Normal,
- const QString &text = QString(), bool *ok = Q_NULLPTR,
+ const QString &text = QString(), bool *ok = nullptr,
Qt::WindowFlags flags = Qt::WindowFlags(),
Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
static QString getMultiLineText(QWidget *parent, const QString &title, const QString &label,
- const QString &text = QString(), bool *ok = Q_NULLPTR,
+ const QString &text = QString(), bool *ok = nullptr,
Qt::WindowFlags flags = Qt::WindowFlags(),
Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
static QString getItem(QWidget *parent, const QString &title, const QString &label,
const QStringList &items, int current = 0, bool editable = true,
- bool *ok = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags(),
+ bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(),
Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
static int getInt(QWidget *parent, const QString &title, const QString &label, int value = 0,
int minValue = -2147483647, int maxValue = 2147483647,
- int step = 1, bool *ok = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
+ int step = 1, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
static double getDouble(QWidget *parent, const QString &title, const QString &label, double value = 0,
double minValue = -2147483647, double maxValue = 2147483647,
- int decimals = 1, bool *ok = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
+ int decimals = 1, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
+ // ### Qt 6: merge overloads
+ static double getDouble(QWidget *parent, const QString &title, const QString &label, double value,
+ double minValue, double maxValue, int decimals, bool *ok, Qt::WindowFlags flags,
+ double step);
#if QT_DEPRECATED_SINCE(5, 0)
QT_DEPRECATED static inline int getInteger(QWidget *parent, const QString &title, const QString &label, int value = 0,
int minValue = -2147483647, int maxValue = 2147483647,
- int step = 1, bool *ok = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags())
+ int step = 1, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags())
{
return getInt(parent, title, label, value, minValue, maxValue, step, ok, flags);
}
#endif
+ void setDoubleStep(double step);
+ double doubleStep() const;
+
Q_SIGNALS:
// ### emit signals!
void textValueChanged(const QString &text);
@@ -198,7 +206,7 @@ Q_SIGNALS:
void doubleValueSelected(double value);
public:
- void done(int result) Q_DECL_OVERRIDE;
+ void done(int result) override;
private:
Q_DISABLE_COPY(QInputDialog)
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index 9421ea2953..cb8ac1ccbf 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -64,6 +64,7 @@
#include <QtGui/qfont.h>
#include <QtGui/qfontmetrics.h>
#include <QtGui/qclipboard.h>
+#include <private/qdesktopwidget_p.h>
#ifdef Q_OS_WIN
# include <QtCore/qt_windows.h>
@@ -97,7 +98,7 @@ public:
public:
TextEdit(QWidget *parent=0) : QTextEdit(parent) { }
#ifndef QT_NO_CONTEXTMENU
- void contextMenuEvent(QContextMenuEvent * e) Q_DECL_OVERRIDE
+ void contextMenuEvent(QContextMenuEvent * e) override
{
QMenu *menu = createStandardContextMenu();
menu->setAttribute(Qt::WA_DeleteOnClose);
@@ -172,7 +173,7 @@ public:
void setLabel(DetailButtonLabel lbl)
{ setText(label(lbl)); }
- QSize sizeHint() const Q_DECL_OVERRIDE
+ QSize sizeHint() const override
{
ensurePolished();
QStyleOptionButton opt;
@@ -258,9 +259,9 @@ public:
QByteArray signalToDisconnectOnClose;
QSharedPointer<QMessageDialogOptions> options;
private:
- void initHelper(QPlatformDialogHelper *) Q_DECL_OVERRIDE;
- void helperPrepareShow(QPlatformDialogHelper *) Q_DECL_OVERRIDE;
- void helperDone(QDialog::DialogCode, QPlatformDialogHelper *) Q_DECL_OVERRIDE;
+ void initHelper(QPlatformDialogHelper *) override;
+ void helperPrepareShow(QPlatformDialogHelper *) override;
+ void helperDone(QDialog::DialogCode, QPlatformDialogHelper *) override;
};
void QMessageBoxPrivate::init(const QString &title, const QString &text)
@@ -361,7 +362,7 @@ void QMessageBoxPrivate::updateSize()
if (!q->isVisible())
return;
- QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size();
+ QSize screenSize = QDesktopWidgetPrivate::availableGeometry(QCursor::pos()).size();
int hardLimit = qMin(screenSize.width() - 480, 1000); // can never get bigger than this
// on small screens allows the messagebox be the same size as the screen
if (screenSize.width() <= 1024)
@@ -414,7 +415,7 @@ void QMessageBoxPrivate::updateSize()
}
QFontMetrics fm(QApplication::font("QMdiSubWindowTitleBar"));
- int windowTitleWidth = qMin(fm.width(q->windowTitle()) + 50, hardLimit);
+ int windowTitleWidth = qMin(fm.horizontalAdvance(q->windowTitle()) + 50, hardLimit);
if (windowTitleWidth > width)
width = windowTitleWidth;
@@ -2607,7 +2608,7 @@ QPixmap QMessageBoxPrivate::standardIcon(QMessageBox::Icon icon, QMessageBox *mb
break;
}
if (!tmpIcon.isNull()) {
- QWindow *window = Q_NULLPTR;
+ QWindow *window = nullptr;
if (mb) {
window = mb->windowHandle();
if (!window) {
diff --git a/src/widgets/dialogs/qmessagebox.h b/src/widgets/dialogs/qmessagebox.h
index fd7d7936b6..4b993a9e65 100644
--- a/src/widgets/dialogs/qmessagebox.h
+++ b/src/widgets/dialogs/qmessagebox.h
@@ -132,9 +132,9 @@ public:
Q_DECLARE_FLAGS(StandardButtons, StandardButton)
Q_FLAG(StandardButtons)
- explicit QMessageBox(QWidget *parent = Q_NULLPTR);
+ explicit QMessageBox(QWidget *parent = nullptr);
QMessageBox(Icon icon, const QString &title, const QString &text,
- StandardButtons buttons = NoButton, QWidget *parent = Q_NULLPTR,
+ StandardButtons buttons = NoButton, QWidget *parent = nullptr,
Qt::WindowFlags flags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
~QMessageBox();
@@ -201,7 +201,7 @@ public:
QMessageBox(const QString &title, const QString &text, Icon icon,
int button0, int button1, int button2,
- QWidget *parent = Q_NULLPTR,
+ QWidget *parent = nullptr,
Qt::WindowFlags f = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
static int information(QWidget *parent, const QString &title,
@@ -290,12 +290,12 @@ public Q_SLOTS:
#endif
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
- void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
- void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void changeEvent(QEvent *event) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
+ void resizeEvent(QResizeEvent *event) override;
+ void showEvent(QShowEvent *event) override;
+ void closeEvent(QCloseEvent *event) override;
+ void keyPressEvent(QKeyEvent *event) override;
+ void changeEvent(QEvent *event) override;
private:
Q_PRIVATE_SLOT(d_func(), void _q_buttonClicked(QAbstractButton *))
diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp
index 893920cbd9..a276e28a0c 100644
--- a/src/widgets/dialogs/qprogressdialog.cpp
+++ b/src/widgets/dialogs/qprogressdialog.cpp
@@ -242,7 +242,7 @@ void QProgressDialogPrivate::_q_disconnectOnClose()
A modeless progress dialog is suitable for operations that take
place in the background, where the user is able to interact with the
application. Such operations are typically based on QTimer (or
- QObject::timerEvent()), QSocketNotifier, or QUrlOperator; or performed
+ QObject::timerEvent()) or QSocketNotifier; or performed
in a separate thread. A QProgressBar in the status bar of your main window
is often an alternative to a modeless progress dialog.
diff --git a/src/widgets/dialogs/qprogressdialog.h b/src/widgets/dialogs/qprogressdialog.h
index 902a4de5d2..74adb6bd84 100644
--- a/src/widgets/dialogs/qprogressdialog.h
+++ b/src/widgets/dialogs/qprogressdialog.h
@@ -68,9 +68,9 @@ class Q_WIDGETS_EXPORT QProgressDialog : public QDialog
Q_PROPERTY(QString labelText READ labelText WRITE setLabelText)
public:
- explicit QProgressDialog(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
+ explicit QProgressDialog(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
QProgressDialog(const QString &labelText, const QString &cancelButtonText,
- int minimum, int maximum, QWidget *parent = Q_NULLPTR,
+ int minimum, int maximum, QWidget *parent = nullptr,
Qt::WindowFlags flags = Qt::WindowFlags());
~QProgressDialog();
@@ -85,7 +85,7 @@ public:
int value() const;
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
QString labelText() const;
int minimumDuration() const;
@@ -113,10 +113,10 @@ Q_SIGNALS:
void canceled();
protected:
- void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
- void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
- void changeEvent(QEvent *event) Q_DECL_OVERRIDE;
- void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
+ void resizeEvent(QResizeEvent *event) override;
+ void closeEvent(QCloseEvent *event) override;
+ void changeEvent(QEvent *event) override;
+ void showEvent(QShowEvent *event) override;
protected Q_SLOTS:
void forceShow();
diff --git a/src/widgets/dialogs/qsidebar_p.h b/src/widgets/dialogs/qsidebar_p.h
index 1f27d477a8..07aaa5abd2 100644
--- a/src/widgets/dialogs/qsidebar_p.h
+++ b/src/widgets/dialogs/qsidebar_p.h
@@ -69,7 +69,7 @@ class QSideBarDelegate : public QStyledItemDelegate
public:
QSideBarDelegate(QWidget *parent = 0) : QStyledItemDelegate(parent) {}
void initStyleOption(QStyleOptionViewItem *option,
- const QModelIndex &index) const Q_DECL_OVERRIDE;
+ const QModelIndex &index) const override;
};
class Q_AUTOTEST_EXPORT QUrlModel : public QStandardItemModel
@@ -84,14 +84,14 @@ public:
QUrlModel(QObject *parent = 0);
- QStringList mimeTypes() const Q_DECL_OVERRIDE;
- QMimeData *mimeData(const QModelIndexList &indexes) const Q_DECL_OVERRIDE;
+ QStringList mimeTypes() const override;
+ QMimeData *mimeData(const QModelIndexList &indexes) const override;
#ifndef QT_NO_DRAGANDDROP
bool canDrop(QDragEnterEvent *event);
- bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) Q_DECL_OVERRIDE;
+ bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
#endif
- Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE;
- bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) Q_DECL_OVERRIDE;
+ Qt::ItemFlags flags(const QModelIndex &index) const override;
+ bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override;
void setUrls(const QList<QUrl> &list);
void addUrls(const QList<QUrl> &urls, int row = -1, bool move = true);
@@ -131,7 +131,7 @@ public:
void setModelAndUrls(QFileSystemModel *model, const QList<QUrl> &newUrls);
~QSidebar();
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
void setUrls(const QList<QUrl> &list) { urlModel->setUrls(list); }
void addUrls(const QList<QUrl> &list, int row) { urlModel->addUrls(list, row); }
@@ -140,10 +140,10 @@ public:
void selectUrl(const QUrl &url);
protected:
- bool event(QEvent * e) Q_DECL_OVERRIDE;
- void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
+ bool event(QEvent * e) override;
+ void focusInEvent(QFocusEvent *event) override;
#ifndef QT_NO_DRAGANDDROP
- void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE;
+ void dragEnterEvent(QDragEnterEvent *event) override;
#endif
private Q_SLOTS:
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp
index a4ea7ae8de..3876cf16c6 100644
--- a/src/widgets/dialogs/qwizard.cpp
+++ b/src/widgets/dialogs/qwizard.cpp
@@ -48,6 +48,7 @@
#include "qboxlayout.h"
#include "qlayoutitem.h"
#include "qdesktopwidget.h"
+#include <private/qdesktopwidget_p.h>
#include "qevent.h"
#include "qframe.h"
#include "qlabel.h"
@@ -297,7 +298,7 @@ public:
Qt::TextFormat titleFormat, Qt::TextFormat subTitleFormat);
protected:
- void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent *event) override;
#if QT_CONFIG(style_windowsvista)
private:
bool vistaDisabled() const;
@@ -400,7 +401,7 @@ void QWizardHeader::setup(const QWizardLayoutInfo &info, const QString &title,
/*
There is no widthForHeight() function, so we simulate it with a loop.
*/
- int candidateSubTitleWidth = qMin(512, 2 * QApplication::desktop()->width() / 3);
+ int candidateSubTitleWidth = qMin(512, 2 * QDesktopWidgetPrivate::width() / 3);
int delta = candidateSubTitleWidth >> 1;
while (delta > 0) {
if (subTitleLabel->heightForWidth(candidateSubTitleWidth - delta)
@@ -453,7 +454,7 @@ public:
m_layout->addWidget(m_sideWidget);
}
- QSize minimumSizeHint() const Q_DECL_OVERRIDE {
+ QSize minimumSizeHint() const override {
if (pixmap() && !pixmap()->isNull())
return pixmap()->size();
return QFrame::minimumSizeHint();
@@ -500,6 +501,7 @@ public:
mutable TriState completeState;
bool explicitlyFinal;
bool commit;
+ bool initialized = false;
QMap<int, QString> buttonCustomTexts;
};
@@ -577,7 +579,7 @@ public:
, bottomRuler(0)
#if QT_CONFIG(style_windowsvista)
, vistaHelper(0)
- , vistaInitPending(false)
+ , vistaInitPending(true)
, vistaState(QVistaHelper::Dirty)
, vistaStateChanged(false)
, inHandleAeroStyleChange(false)
@@ -588,12 +590,6 @@ public:
, maximumHeight(QWIDGETSIZE_MAX)
{
std::fill(btns, btns + QWizard::NButtons, static_cast<QAbstractButton *>(0));
-
-#if QT_CONFIG(style_windowsvista)
- if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
- && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))
- vistaInitPending = true;
-#endif
}
void init();
@@ -635,7 +631,6 @@ public:
QMap<QString, int> fieldIndexMap;
QVector<QWizardDefaultProperty> defaultPropertyTable;
QList<int> history;
- QSet<int> initialized; // ### remove and move bit to QWizardPage?
int start;
bool startSetByUser;
int current;
@@ -774,7 +769,8 @@ void QWizardPrivate::reset()
for (int i = history.count() - 1; i >= 0; --i)
q->cleanupPage(history.at(i));
history.clear();
- initialized.clear();
+ for (QWizardPage *page : pageMap)
+ page->d_func()->initialized = false;
current = -1;
emit q->currentIdChanged(-1);
@@ -785,14 +781,12 @@ void QWizardPrivate::cleanupPagesNotInHistory()
{
Q_Q(QWizard);
- const QSet<int> original = initialized;
- QSet<int>::const_iterator i = original.constBegin();
- QSet<int>::const_iterator end = original.constEnd();
-
- for (; i != end; ++i) {
- if (!history.contains(*i)) {
- q->cleanupPage(*i);
- initialized.remove(*i);
+ for (auto it = pageMap.begin(), end = pageMap.end(); it != end; ++it) {
+ const auto idx = it.key();
+ const auto page = it.value()->d_func();
+ if (page->initialized && !history.contains(idx)) {
+ q->cleanupPage(idx);
+ page->initialized = false;
}
}
}
@@ -847,7 +841,7 @@ void QWizardPrivate::switchToPage(int newId, Direction direction)
if (direction == Backward) {
if (!(opts & QWizard::IndependentPages)) {
q->cleanupPage(oldId);
- initialized.remove(oldId);
+ oldPage->d_func()->initialized = false;
}
Q_ASSERT(history.constLast() == oldId);
history.removeLast();
@@ -860,8 +854,8 @@ void QWizardPrivate::switchToPage(int newId, Direction direction)
QWizardPage *newPage = q->currentPage();
if (newPage) {
if (direction == Forward) {
- if (!initialized.contains(current)) {
- initialized.insert(current);
+ if (!newPage->d_func()->initialized) {
+ newPage->d_func()->initialized = true;
q->initializePage(current);
}
history.append(current);
@@ -2361,9 +2355,9 @@ void QWizard::removePage(int id)
}
if (removedPage) {
- if (d->initialized.contains(id)) {
+ if (removedPage->d_func()->initialized) {
cleanupPage(id);
- d->initialized.remove(id);
+ removedPage->d_func()->initialized = false;
}
d->pageVBoxLayout->removeWidget(removedPage);
diff --git a/src/widgets/dialogs/qwizard.h b/src/widgets/dialogs/qwizard.h
index 4d03bf91d4..0dd837b197 100644
--- a/src/widgets/dialogs/qwizard.h
+++ b/src/widgets/dialogs/qwizard.h
@@ -120,7 +120,7 @@ public:
Q_DECLARE_FLAGS(WizardOptions, WizardOption)
Q_FLAG(WizardOptions)
- explicit QWizard(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
+ explicit QWizard(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
~QWizard();
int addPage(QWizardPage *page);
@@ -168,8 +168,8 @@ public:
void setDefaultProperty(const char *className, const char *property,
const char *changedSignal);
- void setVisible(bool visible) Q_DECL_OVERRIDE;
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ void setVisible(bool visible) override;
+ QSize sizeHint() const override;
Q_SIGNALS:
void currentIdChanged(int id);
@@ -184,13 +184,13 @@ public Q_SLOTS:
void restart();
protected:
- bool event(QEvent *event) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
+ bool event(QEvent *event) override;
+ void resizeEvent(QResizeEvent *event) override;
+ void paintEvent(QPaintEvent *event) override;
#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
- bool nativeEvent(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE;
+ bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
#endif
- void done(int result) Q_DECL_OVERRIDE;
+ void done(int result) override;
virtual void initializePage(int id);
virtual void cleanupPage(int id);
@@ -215,7 +215,7 @@ class Q_WIDGETS_EXPORT QWizardPage : public QWidget
Q_PROPERTY(QString subTitle READ subTitle WRITE setSubTitle)
public:
- explicit QWizardPage(QWidget *parent = Q_NULLPTR);
+ explicit QWizardPage(QWidget *parent = nullptr);
~QWizardPage();
void setTitle(const QString &title);
@@ -243,8 +243,8 @@ Q_SIGNALS:
protected:
void setField(const QString &name, const QVariant &value);
QVariant field(const QString &name) const;
- void registerField(const QString &name, QWidget *widget, const char *property = Q_NULLPTR,
- const char *changedSignal = Q_NULLPTR);
+ void registerField(const QString &name, QWidget *widget, const char *property = nullptr,
+ const char *changedSignal = nullptr);
QWizard *wizard() const;
private:
diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp
index 666b192e9c..6f0e436ae0 100644
--- a/src/widgets/dialogs/qwizard_win.cpp
+++ b/src/widgets/dialogs/qwizard_win.cpp
@@ -154,10 +154,7 @@ QVistaHelper::QVistaHelper(QWizard *wizard)
backButton_ = new QVistaBackButton(wizard);
backButton_->hide();
- // Handle diff between Windows 7 and Vista
iconSpacing = QStyleHelper::dpiScaled(7);
- textSpacing = QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS7 ?
- iconSpacing : QStyleHelper::dpiScaled(20);
}
QVistaHelper::~QVistaHelper()
@@ -263,7 +260,7 @@ static bool getCaptionQFont(int dpi, QFont *result)
QPlatformNativeInterface *ni = QGuiApplication::platformNativeInterface();
return ni && QMetaObject::invokeMethod(ni, "logFontToQFont", Qt::DirectConnection,
Q_RETURN_ARG(QFont, *result),
- Q_ARG(const void *, &logFont),
+ Q_ARG(const void*, &logFont),
Q_ARG(int, dpi));
}
@@ -666,12 +663,12 @@ bool QVistaHelper::drawBlackRect(const QRect &rect, HDC hdc)
return value;
}
-#if !defined(_MSC_VER) || _MSC_VER < 1700
+#ifndef Q_CC_MSVC
static inline int getWindowBottomMargin()
{
return GetSystemMetrics(SM_CYSIZEFRAME);
}
-#else // !_MSC_VER || _MSC_VER < 1700
+#else
// QTBUG-36192, GetSystemMetrics(SM_CYSIZEFRAME) returns bogus values
// for MSVC2012 which leads to the custom margin having no effect since
// that only works when removing the entire margin.
@@ -681,7 +678,7 @@ static inline int getWindowBottomMargin()
AdjustWindowRectEx(&rect, WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_THICKFRAME | WS_DLGFRAME, FALSE, 0);
return qAbs(rect.bottom);
}
-#endif // _MSC_VER >= 1700
+#endif // Q_CC_MSVC
int QVistaHelper::frameSizeDp()
{
@@ -695,7 +692,7 @@ int QVistaHelper::captionSizeDp()
int QVistaHelper::titleOffset()
{
- int iconOffset = wizard ->windowIcon().isNull() ? 0 : iconSize() + textSpacing;
+ int iconOffset = wizard ->windowIcon().isNull() ? 0 : iconSize() + iconSpacing;
return leftMargin() + iconOffset;
}
diff --git a/src/widgets/dialogs/qwizard_win_p.h b/src/widgets/dialogs/qwizard_win_p.h
index f9122865c2..7ca4899a1f 100644
--- a/src/widgets/dialogs/qwizard_win_p.h
+++ b/src/widgets/dialogs/qwizard_win_p.h
@@ -104,8 +104,7 @@ public:
static int titleBarSize() { return QVistaHelper::titleBarSizeDp() / QVistaHelper::m_devicePixelRatio; }
static int titleBarSizeDp() { return QVistaHelper::frameSizeDp() + QVistaHelper::captionSizeDp(); }
static int topPadding() { // padding under text
- return int(QStyleHelper::dpiScaled(
- QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS7 ? 4 : 6));
+ return int(QStyleHelper::dpiScaled(4));
}
static int topOffset();
@@ -150,7 +149,6 @@ private:
int titleBarOffset; // Extra spacing above the text
int iconSpacing; // Space between button and icon
- int textSpacing; // Space between icon and text
static int m_devicePixelRatio;
};
diff --git a/src/widgets/doc/images/stardelegate.png b/src/widgets/doc/images/stardelegate.png
index 24fa9fb0d7..66f55c5fc7 100644
--- a/src/widgets/doc/images/stardelegate.png
+++ b/src/widgets/doc/images/stardelegate.png
Binary files differ
diff --git a/src/widgets/doc/images/stylesheet-coffee-xp.png b/src/widgets/doc/images/stylesheet-coffee-xp.png
deleted file mode 100644
index 8bedd80ee9..0000000000
--- a/src/widgets/doc/images/stylesheet-coffee-xp.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/widgets-tutorial-toplevel.png b/src/widgets/doc/images/widgets-tutorial-toplevel.png
index a80d13c50d..bf7879f5aa 100644
--- a/src/widgets/doc/images/widgets-tutorial-toplevel.png
+++ b/src/widgets/doc/images/widgets-tutorial-toplevel.png
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-tabwidget.png b/src/widgets/doc/images/windowsxp-tabwidget.png
deleted file mode 100644
index 3c8e777a0b..0000000000
--- a/src/widgets/doc/images/windowsxp-tabwidget.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/windowsxp-treeview.png b/src/widgets/doc/images/windowsxp-treeview.png
deleted file mode 100644
index 050cc2f4d6..0000000000
--- a/src/widgets/doc/images/windowsxp-treeview.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/qtwidgets.qdocconf b/src/widgets/doc/qtwidgets.qdocconf
index d0cf9671b1..4700ee29bf 100644
--- a/src/widgets/doc/qtwidgets.qdocconf
+++ b/src/widgets/doc/qtwidgets.qdocconf
@@ -26,7 +26,7 @@ qhp.QtWidgets.subprojects.classes.sortPages = true
tagfile = ../../../doc/qtwidgets/qtwidgets.tags
-depends += qtcore qtgui qtdoc qtsql qtdesigner qtquick qmake qtplatformheaders qtsvg
+depends += qtcore qtgui qtdoc qtsql qtdesigner qtquick qmake qtplatformheaders qtsvg qtlinguist
headerdirs += ..
@@ -47,3 +47,7 @@ imagedirs += images \
navigation.landingpage = "Qt Widgets"
navigation.cppclassespage = "Qt Widgets C++ Classes"
+manifestmeta.highlighted.names = "QtWidgets/Calendar Widget Example" \
+ "QtWidgets/Editable Tree Model Example" \
+ "QtWidgets/Address Book Example" \
+ "QtWidgets/Application Example"
diff --git a/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc b/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc
index dfea9f2ca4..bf727dd380 100644
--- a/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc
+++ b/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc
@@ -1889,3 +1889,7 @@ QTableView::indicator:unchecked {
}
//! [161]
+//! [162]
+* { widget-animation-duration: 100 }
+//! [162]
+
diff --git a/src/widgets/doc/snippets/common-table-model/model.cpp b/src/widgets/doc/snippets/common-table-model/model.cpp
index 96df100f26..2f6e9f1144 100644
--- a/src/widgets/doc/snippets/common-table-model/model.cpp
+++ b/src/widgets/doc/snippets/common-table-model/model.cpp
@@ -68,7 +68,7 @@ TableModel::TableModel(int rows, int columns, QObject *parent)
QStringList newList;
for (int column = 0; column < qMax(1, columns); ++column) {
- newList.append("");
+ newList.append(QString());
}
for (int row = 0; row < qMax(1, rows); ++row) {
@@ -129,9 +129,9 @@ QVariant TableModel::headerData(int section, Qt::Orientation orientation,
return QVariant();
if (orientation == Qt::Horizontal)
- return QString("Column %1").arg(section);
+ return QStringLiteral("Column %1").arg(section);
else
- return QString("Row %1").arg(section);
+ return QStringLiteral("Row %1").arg(section);
}
/*!
@@ -164,7 +164,7 @@ bool TableModel::setData(const QModelIndex &index,
return false;
rowList[index.row()][index.column()] = value.toString();
- emit dataChanged(index, index);
+ emit dataChanged(index, index, {role});
return true;
}
@@ -180,7 +180,7 @@ bool TableModel::insertRows(int position, int rows, const QModelIndex &parent)
for (int row = 0; row < rows; ++row) {
QStringList items;
for (int column = 0; column < columns; ++column)
- items.append("");
+ items.append(QString());
rowList.insert(position, items);
}
@@ -202,7 +202,7 @@ bool TableModel::insertColumns(int position, int columns,
for (int row = 0; row < rows; ++row) {
for (int column = position; column < columns; ++column) {
- rowList[row].insert(position, "");
+ rowList[row].insert(position, QString());
}
}
diff --git a/src/widgets/doc/snippets/common-table-model/model.h b/src/widgets/doc/snippets/common-table-model/model.h
index 68e6c00702..5f152e0e78 100644
--- a/src/widgets/doc/snippets/common-table-model/model.h
+++ b/src/widgets/doc/snippets/common-table-model/model.h
@@ -60,22 +60,22 @@ class TableModel : public QAbstractTableModel
Q_OBJECT
public:
- TableModel(int rows = 1, int columns = 1, QObject *parent = 0);
+ TableModel(int rows = 1, int columns = 1, QObject *parent = nullptr);
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation,
- int role = Qt::DisplayRole) const;
+ int role = Qt::DisplayRole) const override;
- Qt::ItemFlags flags(const QModelIndex &index) const;
+ Qt::ItemFlags flags(const QModelIndex &index) const override;
bool setData(const QModelIndex &index, const QVariant &value,
- int role = Qt::EditRole);
+ int role = Qt::EditRole) override;
- bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex());
- bool insertColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
- bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex());
- bool removeColumns(int position, int columns, const QModelIndex &parent = QModelIndex());
+ bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex()) override;
+ bool insertColumns(int position, int columns, const QModelIndex &parent = QModelIndex()) override;
+ bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex()) override;
+ bool removeColumns(int position, int columns, const QModelIndex &parent = QModelIndex()) override;
private:
QList<QStringList> rowList;
diff --git a/src/widgets/doc/snippets/javastyle.cpp b/src/widgets/doc/snippets/javastyle.cpp
index bddc303f71..8657d5ed29 100644
--- a/src/widgets/doc/snippets/javastyle.cpp
+++ b/src/widgets/doc/snippets/javastyle.cpp
@@ -214,7 +214,7 @@ void JavaStyle::drawControl(ControlElement control, const QStyleOption *option,
painter->translate(box->rect.width(), -box->rect.height());
}
- int textWidth = box->fontMetrics.width(box->text) + 20;
+ int textWidth = box->fontMetrics.horizontalAdvance(box->text) + 20;
QPolygon innerLine;
innerLine << (box->rect.topLeft() + QPoint(0, 1)) <<
@@ -1016,7 +1016,7 @@ void JavaStyle::drawControl(ControlElement control, const QStyleOption *option,
int h = pixmap.height();
if (!button->text.isEmpty())
- w += button->fontMetrics.width(button->text) + 2;
+ w += button->fontMetrics.horizontalAdvance(button->text) + 2;
point = QPoint(ir.x() + ir.width() / 2 - w / 2,
ir.y() + ir.height() / 2 - h / 2);
@@ -2453,7 +2453,7 @@ QRect JavaStyle::subElementRect(SubElement element,
rect.moveTopLeft(box->rect.topLeft() + QPoint(0, 2));
rect.setHeight(box->rect.height() - 4);
- rect.setWidth(box->fontMetrics.width(box->text) + 15);
+ rect.setWidth(box->fontMetrics.horizontalAdvance(box->text) + 15);
break;
}
case SE_ProgressBarLabel:
@@ -2467,7 +2467,7 @@ QRect JavaStyle::subElementRect(SubElement element,
qstyleoption_cast<const QStyleOptionButton *>(option);
rect = btn->fontMetrics.boundingRect(btn->text);
- rect = QRect(0, 0, btn->fontMetrics.width(btn->text),
+ rect = QRect(0, 0, btn->fontMetrics.horizontalAdvance(btn->text),
rect.height());
if (!btn->icon.isNull()) {
diff --git a/src/widgets/doc/snippets/macmainwindow.mm b/src/widgets/doc/snippets/macmainwindow.mm
index d848e6442d..c63796a3f2 100644
--- a/src/widgets/doc/snippets/macmainwindow.mm
+++ b/src/widgets/doc/snippets/macmainwindow.mm
@@ -43,8 +43,6 @@
#if 0 // Used to be included in Qt4 for Q_WS_MAC
-#include <Carbon/Carbon.h>
-
//![0]
SearchWidget::SearchWidget(QWidget *parent)
: QMacCocoaViewContainer(0, parent)
diff --git a/src/widgets/doc/snippets/stringlistmodel/model.cpp b/src/widgets/doc/snippets/stringlistmodel/model.cpp
index f07f6b254f..52e78847d2 100644
--- a/src/widgets/doc/snippets/stringlistmodel/model.cpp
+++ b/src/widgets/doc/snippets/stringlistmodel/model.cpp
@@ -135,9 +135,9 @@ QVariant StringListModel::headerData(int section, Qt::Orientation orientation,
return QVariant();
if (orientation == Qt::Horizontal)
- return QString("Column %1").arg(section);
+ return QStringLiteral("Column %1").arg(section);
else
- return QString("Row %1").arg(section);
+ return QStringLiteral("Row %1").arg(section);
}
//! [2]
@@ -174,7 +174,7 @@ bool StringListModel::setData(const QModelIndex &index,
if (index.isValid() && role == Qt::EditRole) {
stringList.replace(index.row(), value.toString());
- emit dataChanged(index, index);
+ emit dataChanged(index, index, {role});
return true;
}
//! [4] //! [5]
diff --git a/src/widgets/doc/snippets/stringlistmodel/model.h b/src/widgets/doc/snippets/stringlistmodel/model.h
index 50769ef67f..7012152b27 100644
--- a/src/widgets/doc/snippets/stringlistmodel/model.h
+++ b/src/widgets/doc/snippets/stringlistmodel/model.h
@@ -61,26 +61,26 @@ class StringListModel : public QAbstractListModel
Q_OBJECT
public:
- StringListModel(const QStringList &strings, QObject *parent = 0)
+ StringListModel(const QStringList &strings, QObject *parent = nullptr)
: QAbstractListModel(parent), stringList(strings) {}
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role) const override;
QVariant headerData(int section, Qt::Orientation orientation,
//! [0] //! [1]
- int role = Qt::DisplayRole) const;
+ int role = Qt::DisplayRole) const override;
//! [1]
//! [2]
- Qt::ItemFlags flags(const QModelIndex &index) const;
+ Qt::ItemFlags flags(const QModelIndex &index) const override;
bool setData(const QModelIndex &index, const QVariant &value,
//! [2] //! [3]
- int role = Qt::EditRole);
+ int role = Qt::EditRole) override;
//! [3]
//! [4]
- bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex());
- bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex());
+ bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex()) override;
+ bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex()) override;
//! [4]
//! [5]
diff --git a/src/widgets/doc/src/qtwidgets-index.qdoc b/src/widgets/doc/src/qtwidgets-index.qdoc
index 31dd3dcf40..1a23d172dd 100644
--- a/src/widgets/doc/src/qtwidgets-index.qdoc
+++ b/src/widgets/doc/src/qtwidgets-index.qdoc
@@ -83,7 +83,7 @@ interfaces
\table
\row
- \li \image windowsxp-tabwidget.png
+ \li \image windowsvista-tabwidget.png
\li \image fusion-tabwidget.png
\li \image macos-tabwidget.png
\endtable
@@ -118,7 +118,7 @@ interfaces
which use lists and tables are structured to separate the data and view
using models, views, and delegates.
- \image windowsxp-treeview.png
+ \image windows-treeview.png
\section1 Graphics View
diff --git a/src/widgets/doc/src/widgets-and-layouts/gallery.qdoc b/src/widgets/doc/src/widgets-and-layouts/gallery.qdoc
index 5076970854..a82462a432 100644
--- a/src/widgets/doc/src/widgets-and-layouts/gallery.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/gallery.qdoc
@@ -41,10 +41,6 @@
\table
\row
- \li \image windows-xp-style.png Windows XP Style
- \li The Windows XP style ("windowsxp") is provided by
- QWindowsXPStyle.
- \row
\li The Windows style ("windows") is provided by QWindowsStyle.
\li \image windows-style.png Windows Style
\row
diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
index 6745b78898..be6a068d65 100644
--- a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
@@ -80,7 +80,7 @@
the QPalette::Button role to red for a QPushButton to obtain a
red push button. However, this wasn't guaranteed to work for all
styles, because style authors are restricted by the different
- platforms' guidelines and (on Windows XP and \macos) by the
+ platforms' guidelines and (on Windows and \macos) by the
native theme engine.
Style sheets let you perform all kinds of customizations that are
@@ -111,10 +111,8 @@
will.
\table
- \row \li \inlineimage stylesheet-coffee-xp.png
- \li \inlineimage stylesheet-pagefold.png
- \row \li Coffee theme running on Windows XP
- \li Pagefold theme running on Windows XP
+ \row \li \inlineimage stylesheet-pagefold.png
+ \row \li Pagefold theme running on Windows
\endtable
\table
@@ -128,7 +126,7 @@
is a wrapper "style sheet" style, \e not the platform-specific style. The
wrapper style ensures that any active style sheet is respected and
otherwise forwards the drawing operations to the underlying,
- platform-specific style (e.g., QWindowsXPStyle on Windows XP).
+ platform-specific style (e.g., QWindowsVistaStyle on Windows).
Since Qt 4.5, Qt style sheets fully supports \macos.
@@ -1793,8 +1791,9 @@
a QMessageBox. The possible values are 0
(\l{QDialogButtonBox::}{WinLayout}), 1
(\l{QDialogButtonBox::}{MacLayout}), 2
- (\l{QDialogButtonBox::}{KdeLayout}), and 3
- (\l{QDialogButtonBox::}{GnomeLayout}).
+ (\l{QDialogButtonBox::}{KdeLayout}), 3
+ (\l{QDialogButtonBox::}{GnomeLayout}) and 5
+ (\l{QDialogButtonBox::}{AndroidLayout}).
If this property is not specified, it defaults to the
value specified by the current style for the
@@ -2434,6 +2433,28 @@
\l{Qt Style Sheets Reference#subcontrol-origin-prop}{subcontrol-origin}.
\row
+ \li \b{\c titlebar-show-tooltips-on-buttons}}
+ \target titlebar-show-tooltips-on-buttons-prop
+ \li \c bool
+ \li Whether tool tips are shown on window title bar buttons.
+
+ \row
+ \li \b{\c widget-animation-duration*} \target widget-animation-duration
+ \li \l{#Number}{Number}
+ \li How much an animation should last (in milliseconds).
+ A value equal to zero means that the animations will be disabled.
+
+ If this property is not specified, it defaults to the
+ value specified by the current style for the
+ \l{QStyle::}{SH_Widget_Animation_Duration} style hint.
+
+ \b{This property was added in Qt 5.10.}
+
+ Example:
+
+ \snippet code/doc_src_stylesheet.qdoc 162
+
+ \row
\li \b{\c text-align} \target text-align-prop
\li \l{#Alignment}{Alignment}
\li The alignment of text and icon within the contents of the widget.
@@ -3525,7 +3546,7 @@
\list
\li We have made a request that cannot be satisfied using the
- native styles alone (e.g., the Windows XP theme engine doesn't
+ native styles alone (e.g., the Windows Vista theme engine doesn't
let us specify the background color of a button).
\li Therefore, the button is rendered using style sheets.
\li We haven't specified any values for
diff --git a/src/widgets/doc/src/widgets-and-layouts/widgets.qdoc b/src/widgets/doc/src/widgets-and-layouts/widgets.qdoc
index a444d5358c..3b134a3f96 100644
--- a/src/widgets/doc/src/widgets-and-layouts/widgets.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/widgets.qdoc
@@ -62,7 +62,7 @@
\table
\row
- \li \image windowsxp-treeview.png
+ \li \image windows-treeview.png
\li \image fusion-calendarwidget.png
\li \image qundoview.png
\endtable
diff --git a/src/widgets/effects/qgraphicseffect.h b/src/widgets/effects/qgraphicseffect.h
index 78d025ded5..f7c0769778 100644
--- a/src/widgets/effects/qgraphicseffect.h
+++ b/src/widgets/effects/qgraphicseffect.h
@@ -79,7 +79,7 @@ public:
PadToEffectiveBoundingRect
};
- QGraphicsEffect(QObject *parent = Q_NULLPTR);
+ QGraphicsEffect(QObject *parent = nullptr);
virtual ~QGraphicsEffect();
virtual QRectF boundingRectFor(const QRectF &sourceRect) const;
@@ -95,7 +95,7 @@ Q_SIGNALS:
void enabledChanged(bool enabled);
protected:
- QGraphicsEffect(QGraphicsEffectPrivate &d, QObject *parent = Q_NULLPTR);
+ QGraphicsEffect(QGraphicsEffectPrivate &d, QObject *parent = nullptr);
virtual void draw(QPainter *painter) = 0;
virtual void sourceChanged(ChangeFlags flags);
void updateBoundingRect();
@@ -104,7 +104,7 @@ protected:
QRectF sourceBoundingRect(Qt::CoordinateSystem system = Qt::LogicalCoordinates) const;
void drawSource(QPainter *painter);
QPixmap sourcePixmap(Qt::CoordinateSystem system = Qt::LogicalCoordinates,
- QPoint *offset = Q_NULLPTR,
+ QPoint *offset = nullptr,
PixmapPadMode mode = PadToEffectiveBoundingRect) const;
private:
@@ -129,7 +129,7 @@ class Q_WIDGETS_EXPORT QGraphicsColorizeEffect: public QGraphicsEffect
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
Q_PROPERTY(qreal strength READ strength WRITE setStrength NOTIFY strengthChanged)
public:
- QGraphicsColorizeEffect(QObject *parent = Q_NULLPTR);
+ QGraphicsColorizeEffect(QObject *parent = nullptr);
~QGraphicsColorizeEffect();
QColor color() const;
@@ -144,7 +144,7 @@ Q_SIGNALS:
void strengthChanged(qreal strength);
protected:
- void draw(QPainter *painter) Q_DECL_OVERRIDE;
+ void draw(QPainter *painter) override;
private:
Q_DECLARE_PRIVATE(QGraphicsColorizeEffect)
@@ -167,10 +167,10 @@ public:
Q_DECLARE_FLAGS(BlurHints, BlurHint)
Q_FLAG(BlurHints)
- QGraphicsBlurEffect(QObject *parent = Q_NULLPTR);
+ QGraphicsBlurEffect(QObject *parent = nullptr);
~QGraphicsBlurEffect();
- QRectF boundingRectFor(const QRectF &rect) const Q_DECL_OVERRIDE;
+ QRectF boundingRectFor(const QRectF &rect) const override;
qreal blurRadius() const;
BlurHints blurHints() const;
@@ -183,7 +183,7 @@ Q_SIGNALS:
void blurHintsChanged(BlurHints hints);
protected:
- void draw(QPainter *painter) Q_DECL_OVERRIDE;
+ void draw(QPainter *painter) override;
private:
Q_DECLARE_PRIVATE(QGraphicsBlurEffect)
@@ -202,10 +202,10 @@ class Q_WIDGETS_EXPORT QGraphicsDropShadowEffect: public QGraphicsEffect
Q_PROPERTY(qreal blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged)
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
public:
- QGraphicsDropShadowEffect(QObject *parent = Q_NULLPTR);
+ QGraphicsDropShadowEffect(QObject *parent = nullptr);
~QGraphicsDropShadowEffect();
- QRectF boundingRectFor(const QRectF &rect) const Q_DECL_OVERRIDE;
+ QRectF boundingRectFor(const QRectF &rect) const override;
QPointF offset() const;
inline qreal xOffset() const
@@ -241,7 +241,7 @@ Q_SIGNALS:
void colorChanged(const QColor &color);
protected:
- void draw(QPainter *painter) Q_DECL_OVERRIDE;
+ void draw(QPainter *painter) override;
private:
Q_DECLARE_PRIVATE(QGraphicsDropShadowEffect)
@@ -255,7 +255,7 @@ class Q_WIDGETS_EXPORT QGraphicsOpacityEffect: public QGraphicsEffect
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged)
Q_PROPERTY(QBrush opacityMask READ opacityMask WRITE setOpacityMask NOTIFY opacityMaskChanged)
public:
- QGraphicsOpacityEffect(QObject *parent = Q_NULLPTR);
+ QGraphicsOpacityEffect(QObject *parent = nullptr);
~QGraphicsOpacityEffect();
qreal opacity() const;
@@ -270,7 +270,7 @@ Q_SIGNALS:
void opacityMaskChanged(const QBrush &mask);
protected:
- void draw(QPainter *painter) Q_DECL_OVERRIDE;
+ void draw(QPainter *painter) override;
private:
Q_DECLARE_PRIVATE(QGraphicsOpacityEffect)
diff --git a/src/widgets/effects/qpixmapfilter_p.h b/src/widgets/effects/qpixmapfilter_p.h
index 399a835142..0f582bde60 100644
--- a/src/widgets/effects/qpixmapfilter_p.h
+++ b/src/widgets/effects/qpixmapfilter_p.h
@@ -105,8 +105,8 @@ public:
void setConvolutionKernel(const qreal *matrix, int rows, int columns);
- QRectF boundingRectFor(const QRectF &rect) const Q_DECL_OVERRIDE;
- void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const Q_DECL_OVERRIDE;
+ QRectF boundingRectFor(const QRectF &rect) const override;
+ void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const override;
private:
friend class QGLPixmapConvolutionFilter;
@@ -133,8 +133,8 @@ public:
qreal radius() const;
QGraphicsBlurEffect::BlurHints blurHints() const;
- QRectF boundingRectFor(const QRectF &rect) const Q_DECL_OVERRIDE;
- void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const Q_DECL_OVERRIDE;
+ QRectF boundingRectFor(const QRectF &rect) const override;
+ void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const override;
private:
friend class QGLPixmapBlurFilter;
@@ -157,7 +157,7 @@ public:
void setStrength(qreal strength);
qreal strength() const;
- void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const Q_DECL_OVERRIDE;
+ void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const override;
};
class QPixmapDropShadowFilterPrivate;
@@ -171,8 +171,8 @@ public:
QPixmapDropShadowFilter(QObject *parent = 0);
~QPixmapDropShadowFilter();
- QRectF boundingRectFor(const QRectF &rect) const Q_DECL_OVERRIDE;
- void draw(QPainter *p, const QPointF &pos, const QPixmap &px, const QRectF &src = QRectF()) const Q_DECL_OVERRIDE;
+ QRectF boundingRectFor(const QRectF &rect) const override;
+ void draw(QPainter *p, const QPointF &pos, const QPixmap &px, const QRectF &src = QRectF()) const override;
qreal blurRadius() const;
void setBlurRadius(qreal radius);
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout.h b/src/widgets/graphicsview/qgraphicsanchorlayout.h
index 01dc30718a..e392be1568 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout.h
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout.h
@@ -76,7 +76,7 @@ private:
class Q_WIDGETS_EXPORT QGraphicsAnchorLayout : public QGraphicsLayout
{
public:
- QGraphicsAnchorLayout(QGraphicsLayoutItem *parent = Q_NULLPTR);
+ QGraphicsAnchorLayout(QGraphicsLayoutItem *parent = nullptr);
virtual ~QGraphicsAnchorLayout();
QGraphicsAnchor *addAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
@@ -97,14 +97,14 @@ public:
qreal horizontalSpacing() const;
qreal verticalSpacing() const;
- void removeAt(int index) Q_DECL_OVERRIDE;
- void setGeometry(const QRectF &rect) Q_DECL_OVERRIDE;
- int count() const Q_DECL_OVERRIDE;
- QGraphicsLayoutItem *itemAt(int index) const Q_DECL_OVERRIDE;
+ void removeAt(int index) override;
+ void setGeometry(const QRectF &rect) override;
+ int count() const override;
+ QGraphicsLayoutItem *itemAt(int index) const override;
- void invalidate() Q_DECL_OVERRIDE;
+ void invalidate() override;
protected:
- QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const Q_DECL_OVERRIDE;
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const override;
private:
Q_DISABLE_COPY(QGraphicsAnchorLayout)
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h
index e785b486bb..6b2408b2eb 100644
--- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.h
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h
@@ -198,7 +198,7 @@ struct SequentialAnchorData : public AnchorData
#endif
}
- virtual void updateChildrenSizes() Q_DECL_OVERRIDE;
+ virtual void updateChildrenSizes() override;
void calculateSizeHints();
QVector<AnchorVertex*> m_children; // list of vertices in the sequence
@@ -226,7 +226,7 @@ struct ParallelAnchorData : public AnchorData
#endif
}
- virtual void updateChildrenSizes() Q_DECL_OVERRIDE;
+ virtual void updateChildrenSizes() override;
bool calculateSizeHints();
bool secondForward() const {
diff --git a/src/widgets/graphicsview/qgraphicsgridlayout.h b/src/widgets/graphicsview/qgraphicsgridlayout.h
index fb9bc2e32c..4c0a1b4527 100644
--- a/src/widgets/graphicsview/qgraphicsgridlayout.h
+++ b/src/widgets/graphicsview/qgraphicsgridlayout.h
@@ -53,7 +53,7 @@ class QGraphicsGridLayoutPrivate;
class Q_WIDGETS_EXPORT QGraphicsGridLayout : public QGraphicsLayout
{
public:
- QGraphicsGridLayout(QGraphicsLayoutItem *parent = Q_NULLPTR);
+ QGraphicsGridLayout(QGraphicsLayoutItem *parent = nullptr);
virtual ~QGraphicsGridLayout();
void addItem(QGraphicsLayoutItem *item, int row, int column, int rowSpan, int columnSpan,
@@ -106,16 +106,16 @@ public:
QGraphicsLayoutItem *itemAt(int row, int column) const;
// inherited from QGraphicsLayout
- int count() const Q_DECL_OVERRIDE;
- QGraphicsLayoutItem *itemAt(int index) const Q_DECL_OVERRIDE;
- void removeAt(int index) Q_DECL_OVERRIDE;
+ int count() const override;
+ QGraphicsLayoutItem *itemAt(int index) const override;
+ void removeAt(int index) override;
void removeItem(QGraphicsLayoutItem *item);
- void invalidate() Q_DECL_OVERRIDE;
+ void invalidate() override;
// inherited from QGraphicsLayoutItem
- void setGeometry(const QRectF &rect) Q_DECL_OVERRIDE;
- QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const Q_DECL_OVERRIDE;
+ void setGeometry(const QRectF &rect) override;
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const override;
// ####
//QRect cellRect(int row, int column, int rowSpan = 1, int columnSpan = 1) const;
diff --git a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h
index d797f784b8..370df9eed7 100644
--- a/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h
+++ b/src/widgets/graphicsview/qgraphicsgridlayoutengine_p.h
@@ -71,35 +71,35 @@ public:
Qt::Alignment alignment = 0)
: QGridLayoutItem(row, columns, rowSpan, columnSpan, alignment), q_layoutItem(item) {}
- virtual QLayoutPolicy::Policy sizePolicy(Qt::Orientation orientation) const Q_DECL_OVERRIDE
+ virtual QLayoutPolicy::Policy sizePolicy(Qt::Orientation orientation) const override
{
QSizePolicy sizePolicy(q_layoutItem->sizePolicy());
return (QLayoutPolicy::Policy)((orientation == Qt::Horizontal) ? sizePolicy.horizontalPolicy()
: sizePolicy.verticalPolicy());
}
- virtual QLayoutPolicy::ControlTypes controlTypes(LayoutSide) const Q_DECL_OVERRIDE
+ virtual QLayoutPolicy::ControlTypes controlTypes(LayoutSide) const override
{
const QSizePolicy::ControlType ct = q_layoutItem->sizePolicy().controlType();
return (QLayoutPolicy::ControlTypes)ct;
}
- virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const Q_DECL_OVERRIDE
+ virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const override
{
return q_layoutItem->effectiveSizeHint(which, constraint);
}
bool isHidden() const;
- virtual bool isIgnored() const Q_DECL_OVERRIDE;
+ virtual bool isIgnored() const override;
- virtual void setGeometry(const QRectF &rect) Q_DECL_OVERRIDE
+ virtual void setGeometry(const QRectF &rect) override
{
q_layoutItem->setGeometry(rect);
}
- virtual bool hasDynamicConstraint() const Q_DECL_OVERRIDE;
- virtual Qt::Orientation dynamicConstraintOrientation() const Q_DECL_OVERRIDE;
+ virtual bool hasDynamicConstraint() const override;
+ virtual Qt::Orientation dynamicConstraintOrientation() const override;
QGraphicsLayoutItem *layoutItem() const { return q_layoutItem; }
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index a649d61135..0bc3af2f77 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -268,27 +268,93 @@
*/
/*!
- \variable QGraphicsItem::Type
+ \enum QGraphicsItem::anonymous
- The type value returned by the virtual type() function in standard
- graphics item classes in Qt. All such standard graphics item
- classes in Qt are associated with a unique value for Type,
- e.g. the value returned by QGraphicsPathItem::type() is 2.
+ The value returned by the virtual type() function in standard
+ graphics item classes in Qt. All such standard graphics item classes
+ in Qt are associated with a unique value for Type, e.g. the value
+ returned by QGraphicsPathItem::type() is 2.
+
+ \value Type
\snippet code/src_gui_graphicsview_qgraphicsitem.cpp 18
+
+ \value UserType The lowest value returned by the virtual type()
+ function for custom subclasses of QGraphicsItem.
+
+ \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 1
*/
/*!
- \variable QGraphicsItem::UserType
+ \enum QGraphicsPathItem::anonymous
- The lowest permitted type value for custom items (subclasses
- of QGraphicsItem or any of the standard items). This value is
- used in conjunction with a reimplementation of QGraphicsItem::type()
- and declaring a Type enum value. Example:
+ The value returned by the virtual type() function.
- \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 1
+ \value Type A graphics path item
+*/
+
+/*!
+ \enum QGraphicsRectItem::anonymous
+
+ The value returned by the virtual type() function.
+
+ \value Type A graphics rect item
+*/
+
+/*!
+ \enum QGraphicsEllipseItem::anonymous
+
+ The value returned by the virtual type() function.
+
+ \value Type A graphics ellipse item
+*/
+
+/*!
+ \enum QGraphicsPolygonItem::anonymous
+
+ The value returned by the virtual type() function.
+
+ \value Type A graphics polygon item
+*/
+
+/*!
+ \enum QGraphicsPixmapItem::anonymous
+
+ The value returned by the virtual type() function.
+
+ \value Type A graphics pixmap item
+*/
+
+/*!
+ \enum QGraphicsTextItem::anonymous
+
+ The value returned by the virtual type() function.
+
+ \value Type A graphics text item
+*/
+
+/*!
+ \enum QGraphicsSimpleTextItem::anonymous
+
+ The value returned by the virtual type() function.
+
+ \value Type A graphics simple text item
+*/
+
+/*!
+ \enum QGraphicsItemGroup::anonymous
+
+ The value returned by the virtual type() function.
+
+ \value Type A graphics item group
+*/
+
+/*!
+ \enum QGraphicsLineItem::anonymous
+
+ The value returned by the virtual type() function.
- \note UserType = 65536
+ \value Type A graphics line item
*/
/*!
@@ -10574,7 +10640,7 @@ bool QGraphicsTextItemPrivate::_q_mouseOnEdge(QGraphicsSceneMouseEvent *event)
}
/*!
- \fn QGraphicsTextItem::linkActivated(const QString &link)
+ \fn void QGraphicsTextItem::linkActivated(const QString &link)
This signal is emitted when the user clicks on a link on a text item
that enables Qt::LinksAccessibleByMouse or Qt::LinksAccessibleByKeyboard.
@@ -10584,7 +10650,7 @@ bool QGraphicsTextItemPrivate::_q_mouseOnEdge(QGraphicsSceneMouseEvent *event)
*/
/*!
- \fn QGraphicsTextItem::linkHovered(const QString &link)
+ \fn void QGraphicsTextItem::linkHovered(const QString &link)
This signal is emitted when the user hovers over a link on a text item
that enables Qt::LinksAccessibleByMouse. \a link is
diff --git a/src/widgets/graphicsview/qgraphicsitem.h b/src/widgets/graphicsview/qgraphicsitem.h
index 11d872f6e6..c228e765d8 100644
--- a/src/widgets/graphicsview/qgraphicsitem.h
+++ b/src/widgets/graphicsview/qgraphicsitem.h
@@ -158,7 +158,7 @@ public:
SceneModal
};
- explicit QGraphicsItem(QGraphicsItem *parent = Q_NULLPTR);
+ explicit QGraphicsItem(QGraphicsItem *parent = nullptr);
virtual ~QGraphicsItem();
QGraphicsScene *scene() const;
@@ -194,7 +194,7 @@ public:
PanelModality panelModality() const;
void setPanelModality(PanelModality panelModality);
- bool isBlockedByModalPanel(QGraphicsItem **blockingPanel = Q_NULLPTR) const;
+ bool isBlockedByModalPanel(QGraphicsItem **blockingPanel = nullptr) const;
#ifndef QT_NO_TOOLTIP
QString toolTip() const;
@@ -290,7 +290,7 @@ public:
QTransform transform() const;
QTransform sceneTransform() const;
QTransform deviceTransform(const QTransform &viewportTransform) const;
- QTransform itemTransform(const QGraphicsItem *other, bool *ok = Q_NULLPTR) const;
+ QTransform itemTransform(const QGraphicsItem *other, bool *ok = nullptr) const;
void setTransform(const QTransform &matrix, bool combine = false);
void resetTransform();
#if QT_DEPRECATED_SINCE(5, 0)
@@ -341,7 +341,7 @@ public:
void setBoundingRegionGranularity(qreal granularity);
// Drawing
- virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) = 0;
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) = 0;
void update(const QRectF &rect = QRectF());
inline void update(qreal x, qreal y, qreal width, qreal height);
void scroll(qreal dx, qreal dy, const QRectF &rect = QRectF());
@@ -538,7 +538,7 @@ inline QRectF QGraphicsItem::mapRectFromScene(qreal ax, qreal ay, qreal w, qreal
class Q_WIDGETS_EXPORT QGraphicsObject : public QObject, public QGraphicsItem
{
Q_OBJECT
- Q_PROPERTY(QGraphicsObject * parent READ parentObject WRITE setParentItem NOTIFY parentChanged DESIGNABLE false)
+ Q_PROPERTY(QGraphicsObject* parent READ parentObject WRITE setParentItem NOTIFY parentChanged DESIGNABLE false)
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged FINAL)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
@@ -558,7 +558,7 @@ class Q_WIDGETS_EXPORT QGraphicsObject : public QObject, public QGraphicsItem
Q_CLASSINFO("DefaultProperty", "children")
Q_INTERFACES(QGraphicsItem)
public:
- explicit QGraphicsObject(QGraphicsItem *parent = Q_NULLPTR);
+ explicit QGraphicsObject(QGraphicsItem *parent = nullptr);
~QGraphicsObject();
using QObject::children;
@@ -588,7 +588,7 @@ Q_SIGNALS:
protected:
QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent);
- bool event(QEvent *ev) Q_DECL_OVERRIDE;
+ bool event(QEvent *ev) override;
private:
friend class QGraphicsItem;
@@ -600,7 +600,7 @@ class QAbstractGraphicsShapeItemPrivate;
class Q_WIDGETS_EXPORT QAbstractGraphicsShapeItem : public QGraphicsItem
{
public:
- explicit QAbstractGraphicsShapeItem(QGraphicsItem *parent = Q_NULLPTR);
+ explicit QAbstractGraphicsShapeItem(QGraphicsItem *parent = nullptr);
~QAbstractGraphicsShapeItem();
QPen pen() const;
@@ -609,8 +609,8 @@ public:
QBrush brush() const;
void setBrush(const QBrush &brush);
- bool isObscuredBy(const QGraphicsItem *item) const Q_DECL_OVERRIDE;
- QPainterPath opaqueArea() const Q_DECL_OVERRIDE;
+ bool isObscuredBy(const QGraphicsItem *item) const override;
+ QPainterPath opaqueArea() const override;
protected:
QAbstractGraphicsShapeItem(QAbstractGraphicsShapeItemPrivate &dd,
@@ -625,29 +625,29 @@ class QGraphicsPathItemPrivate;
class Q_WIDGETS_EXPORT QGraphicsPathItem : public QAbstractGraphicsShapeItem
{
public:
- explicit QGraphicsPathItem(QGraphicsItem *parent = Q_NULLPTR);
- explicit QGraphicsPathItem(const QPainterPath &path, QGraphicsItem *parent = Q_NULLPTR);
+ explicit QGraphicsPathItem(QGraphicsItem *parent = nullptr);
+ explicit QGraphicsPathItem(const QPainterPath &path, QGraphicsItem *parent = nullptr);
~QGraphicsPathItem();
QPainterPath path() const;
void setPath(const QPainterPath &path);
- QRectF boundingRect() const Q_DECL_OVERRIDE;
- QPainterPath shape() const Q_DECL_OVERRIDE;
- bool contains(const QPointF &point) const Q_DECL_OVERRIDE;
+ QRectF boundingRect() const override;
+ QPainterPath shape() const override;
+ bool contains(const QPointF &point) const override;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) Q_DECL_OVERRIDE;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
- bool isObscuredBy(const QGraphicsItem *item) const Q_DECL_OVERRIDE;
- QPainterPath opaqueArea() const Q_DECL_OVERRIDE;
+ bool isObscuredBy(const QGraphicsItem *item) const override;
+ QPainterPath opaqueArea() const override;
enum { Type = 2 };
- int type() const Q_DECL_OVERRIDE;
+ int type() const override;
protected:
- bool supportsExtension(Extension extension) const Q_DECL_OVERRIDE;
- void setExtension(Extension extension, const QVariant &variant) Q_DECL_OVERRIDE;
- QVariant extension(const QVariant &variant) const Q_DECL_OVERRIDE;
+ bool supportsExtension(Extension extension) const override;
+ void setExtension(Extension extension, const QVariant &variant) override;
+ QVariant extension(const QVariant &variant) const override;
private:
Q_DISABLE_COPY(QGraphicsPathItem)
@@ -658,31 +658,31 @@ class QGraphicsRectItemPrivate;
class Q_WIDGETS_EXPORT QGraphicsRectItem : public QAbstractGraphicsShapeItem
{
public:
- explicit QGraphicsRectItem(QGraphicsItem *parent = Q_NULLPTR);
- explicit QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent = Q_NULLPTR);
- explicit QGraphicsRectItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = Q_NULLPTR);
+ explicit QGraphicsRectItem(QGraphicsItem *parent = nullptr);
+ explicit QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent = nullptr);
+ explicit QGraphicsRectItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = nullptr);
~QGraphicsRectItem();
QRectF rect() const;
void setRect(const QRectF &rect);
inline void setRect(qreal x, qreal y, qreal w, qreal h);
- QRectF boundingRect() const Q_DECL_OVERRIDE;
- QPainterPath shape() const Q_DECL_OVERRIDE;
- bool contains(const QPointF &point) const Q_DECL_OVERRIDE;
+ QRectF boundingRect() const override;
+ QPainterPath shape() const override;
+ bool contains(const QPointF &point) const override;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) Q_DECL_OVERRIDE;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
- bool isObscuredBy(const QGraphicsItem *item) const Q_DECL_OVERRIDE;
- QPainterPath opaqueArea() const Q_DECL_OVERRIDE;
+ bool isObscuredBy(const QGraphicsItem *item) const override;
+ QPainterPath opaqueArea() const override;
enum { Type = 3 };
- int type() const Q_DECL_OVERRIDE;
+ int type() const override;
protected:
- bool supportsExtension(Extension extension) const Q_DECL_OVERRIDE;
- void setExtension(Extension extension, const QVariant &variant) Q_DECL_OVERRIDE;
- QVariant extension(const QVariant &variant) const Q_DECL_OVERRIDE;
+ bool supportsExtension(Extension extension) const override;
+ void setExtension(Extension extension, const QVariant &variant) override;
+ QVariant extension(const QVariant &variant) const override;
private:
Q_DISABLE_COPY(QGraphicsRectItem)
@@ -696,9 +696,9 @@ class QGraphicsEllipseItemPrivate;
class Q_WIDGETS_EXPORT QGraphicsEllipseItem : public QAbstractGraphicsShapeItem
{
public:
- explicit QGraphicsEllipseItem(QGraphicsItem *parent = Q_NULLPTR);
- explicit QGraphicsEllipseItem(const QRectF &rect, QGraphicsItem *parent = Q_NULLPTR);
- explicit QGraphicsEllipseItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = Q_NULLPTR);
+ explicit QGraphicsEllipseItem(QGraphicsItem *parent = nullptr);
+ explicit QGraphicsEllipseItem(const QRectF &rect, QGraphicsItem *parent = nullptr);
+ explicit QGraphicsEllipseItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = nullptr);
~QGraphicsEllipseItem();
QRectF rect() const;
@@ -711,22 +711,22 @@ public:
int spanAngle() const;
void setSpanAngle(int angle);
- QRectF boundingRect() const Q_DECL_OVERRIDE;
- QPainterPath shape() const Q_DECL_OVERRIDE;
- bool contains(const QPointF &point) const Q_DECL_OVERRIDE;
+ QRectF boundingRect() const override;
+ QPainterPath shape() const override;
+ bool contains(const QPointF &point) const override;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) Q_DECL_OVERRIDE;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
- bool isObscuredBy(const QGraphicsItem *item) const Q_DECL_OVERRIDE;
- QPainterPath opaqueArea() const Q_DECL_OVERRIDE;
+ bool isObscuredBy(const QGraphicsItem *item) const override;
+ QPainterPath opaqueArea() const override;
enum { Type = 4 };
- int type() const Q_DECL_OVERRIDE;
+ int type() const override;
protected:
- bool supportsExtension(Extension extension) const Q_DECL_OVERRIDE;
- void setExtension(Extension extension, const QVariant &variant) Q_DECL_OVERRIDE;
- QVariant extension(const QVariant &variant) const Q_DECL_OVERRIDE;
+ bool supportsExtension(Extension extension) const override;
+ void setExtension(Extension extension, const QVariant &variant) override;
+ QVariant extension(const QVariant &variant) const override;
private:
Q_DISABLE_COPY(QGraphicsEllipseItem)
@@ -740,9 +740,9 @@ class QGraphicsPolygonItemPrivate;
class Q_WIDGETS_EXPORT QGraphicsPolygonItem : public QAbstractGraphicsShapeItem
{
public:
- explicit QGraphicsPolygonItem(QGraphicsItem *parent = Q_NULLPTR);
+ explicit QGraphicsPolygonItem(QGraphicsItem *parent = nullptr);
explicit QGraphicsPolygonItem(const QPolygonF &polygon,
- QGraphicsItem *parent = Q_NULLPTR);
+ QGraphicsItem *parent = nullptr);
~QGraphicsPolygonItem();
QPolygonF polygon() const;
@@ -751,22 +751,22 @@ public:
Qt::FillRule fillRule() const;
void setFillRule(Qt::FillRule rule);
- QRectF boundingRect() const Q_DECL_OVERRIDE;
- QPainterPath shape() const Q_DECL_OVERRIDE;
- bool contains(const QPointF &point) const Q_DECL_OVERRIDE;
+ QRectF boundingRect() const override;
+ QPainterPath shape() const override;
+ bool contains(const QPointF &point) const override;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) Q_DECL_OVERRIDE;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
- bool isObscuredBy(const QGraphicsItem *item) const Q_DECL_OVERRIDE;
- QPainterPath opaqueArea() const Q_DECL_OVERRIDE;
+ bool isObscuredBy(const QGraphicsItem *item) const override;
+ QPainterPath opaqueArea() const override;
enum { Type = 5 };
- int type() const Q_DECL_OVERRIDE;
+ int type() const override;
protected:
- bool supportsExtension(Extension extension) const Q_DECL_OVERRIDE;
- void setExtension(Extension extension, const QVariant &variant) Q_DECL_OVERRIDE;
- QVariant extension(const QVariant &variant) const Q_DECL_OVERRIDE;
+ bool supportsExtension(Extension extension) const override;
+ void setExtension(Extension extension, const QVariant &variant) override;
+ QVariant extension(const QVariant &variant) const override;
private:
Q_DISABLE_COPY(QGraphicsPolygonItem)
@@ -777,9 +777,9 @@ class QGraphicsLineItemPrivate;
class Q_WIDGETS_EXPORT QGraphicsLineItem : public QGraphicsItem
{
public:
- explicit QGraphicsLineItem(QGraphicsItem *parent = Q_NULLPTR);
- explicit QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent = Q_NULLPTR);
- explicit QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent = Q_NULLPTR);
+ explicit QGraphicsLineItem(QGraphicsItem *parent = nullptr);
+ explicit QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent = nullptr);
+ explicit QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent = nullptr);
~QGraphicsLineItem();
QPen pen() const;
@@ -790,22 +790,22 @@ public:
inline void setLine(qreal x1, qreal y1, qreal x2, qreal y2)
{ setLine(QLineF(x1, y1, x2, y2)); }
- QRectF boundingRect() const Q_DECL_OVERRIDE;
- QPainterPath shape() const Q_DECL_OVERRIDE;
- bool contains(const QPointF &point) const Q_DECL_OVERRIDE;
+ QRectF boundingRect() const override;
+ QPainterPath shape() const override;
+ bool contains(const QPointF &point) const override;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) Q_DECL_OVERRIDE;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
- bool isObscuredBy(const QGraphicsItem *item) const Q_DECL_OVERRIDE;
- QPainterPath opaqueArea() const Q_DECL_OVERRIDE;
+ bool isObscuredBy(const QGraphicsItem *item) const override;
+ QPainterPath opaqueArea() const override;
enum { Type = 6 };
- int type() const Q_DECL_OVERRIDE;
+ int type() const override;
protected:
- bool supportsExtension(Extension extension) const Q_DECL_OVERRIDE;
- void setExtension(Extension extension, const QVariant &variant) Q_DECL_OVERRIDE;
- QVariant extension(const QVariant &variant) const Q_DECL_OVERRIDE;
+ bool supportsExtension(Extension extension) const override;
+ void setExtension(Extension extension, const QVariant &variant) override;
+ QVariant extension(const QVariant &variant) const override;
private:
Q_DISABLE_COPY(QGraphicsLineItem)
@@ -822,8 +822,8 @@ public:
HeuristicMaskShape
};
- explicit QGraphicsPixmapItem(QGraphicsItem *parent = Q_NULLPTR);
- explicit QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent = Q_NULLPTR);
+ explicit QGraphicsPixmapItem(QGraphicsItem *parent = nullptr);
+ explicit QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent = nullptr);
~QGraphicsPixmapItem();
QPixmap pixmap() const;
@@ -836,25 +836,25 @@ public:
void setOffset(const QPointF &offset);
inline void setOffset(qreal x, qreal y);
- QRectF boundingRect() const Q_DECL_OVERRIDE;
- QPainterPath shape() const Q_DECL_OVERRIDE;
- bool contains(const QPointF &point) const Q_DECL_OVERRIDE;
+ QRectF boundingRect() const override;
+ QPainterPath shape() const override;
+ bool contains(const QPointF &point) const override;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
- bool isObscuredBy(const QGraphicsItem *item) const Q_DECL_OVERRIDE;
- QPainterPath opaqueArea() const Q_DECL_OVERRIDE;
+ bool isObscuredBy(const QGraphicsItem *item) const override;
+ QPainterPath opaqueArea() const override;
enum { Type = 7 };
- int type() const Q_DECL_OVERRIDE;
+ int type() const override;
ShapeMode shapeMode() const;
void setShapeMode(ShapeMode mode);
protected:
- bool supportsExtension(Extension extension) const Q_DECL_OVERRIDE;
- void setExtension(Extension extension, const QVariant &variant) Q_DECL_OVERRIDE;
- QVariant extension(const QVariant &variant) const Q_DECL_OVERRIDE;
+ bool supportsExtension(Extension extension) const override;
+ void setExtension(Extension extension, const QVariant &variant) override;
+ QVariant extension(const QVariant &variant) const override;
private:
Q_DISABLE_COPY(QGraphicsPixmapItem)
@@ -874,8 +874,8 @@ class Q_WIDGETS_EXPORT QGraphicsTextItem : public QGraphicsObject
QDOC_PROPERTY(QTextCursor textCursor READ textCursor WRITE setTextCursor)
public:
- explicit QGraphicsTextItem(QGraphicsItem *parent = Q_NULLPTR);
- explicit QGraphicsTextItem(const QString &text, QGraphicsItem *parent = Q_NULLPTR);
+ explicit QGraphicsTextItem(QGraphicsItem *parent = nullptr);
+ explicit QGraphicsTextItem(const QString &text, QGraphicsItem *parent = nullptr);
~QGraphicsTextItem();
QString toHtml() const;
@@ -890,17 +890,17 @@ public:
void setDefaultTextColor(const QColor &c);
QColor defaultTextColor() const;
- QRectF boundingRect() const Q_DECL_OVERRIDE;
- QPainterPath shape() const Q_DECL_OVERRIDE;
- bool contains(const QPointF &point) const Q_DECL_OVERRIDE;
+ QRectF boundingRect() const override;
+ QPainterPath shape() const override;
+ bool contains(const QPointF &point) const override;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
- bool isObscuredBy(const QGraphicsItem *item) const Q_DECL_OVERRIDE;
- QPainterPath opaqueArea() const Q_DECL_OVERRIDE;
+ bool isObscuredBy(const QGraphicsItem *item) const override;
+ QPainterPath opaqueArea() const override;
enum { Type = 8 };
- int type() const Q_DECL_OVERRIDE;
+ int type() const override;
void setTextWidth(qreal width);
qreal textWidth() const;
@@ -927,30 +927,30 @@ Q_SIGNALS:
void linkHovered(const QString &);
protected:
- bool sceneEvent(QEvent *event) Q_DECL_OVERRIDE;
- void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
- void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
- void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
- void dragEnterEvent(QGraphicsSceneDragDropEvent *event) Q_DECL_OVERRIDE;
- void dragLeaveEvent(QGraphicsSceneDragDropEvent *event) Q_DECL_OVERRIDE;
- void dragMoveEvent(QGraphicsSceneDragDropEvent *event) Q_DECL_OVERRIDE;
- void dropEvent(QGraphicsSceneDragDropEvent *event) Q_DECL_OVERRIDE;
- void inputMethodEvent(QInputMethodEvent *event) Q_DECL_OVERRIDE;
- void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
- void hoverMoveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
- void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
-
- QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE;
-
- bool supportsExtension(Extension extension) const Q_DECL_OVERRIDE;
- void setExtension(Extension extension, const QVariant &variant) Q_DECL_OVERRIDE;
- QVariant extension(const QVariant &variant) const Q_DECL_OVERRIDE;
+ bool sceneEvent(QEvent *event) override;
+ void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
+ void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
+ void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
+ void keyPressEvent(QKeyEvent *event) override;
+ void keyReleaseEvent(QKeyEvent *event) override;
+ void focusInEvent(QFocusEvent *event) override;
+ void focusOutEvent(QFocusEvent *event) override;
+ void dragEnterEvent(QGraphicsSceneDragDropEvent *event) override;
+ void dragLeaveEvent(QGraphicsSceneDragDropEvent *event) override;
+ void dragMoveEvent(QGraphicsSceneDragDropEvent *event) override;
+ void dropEvent(QGraphicsSceneDragDropEvent *event) override;
+ void inputMethodEvent(QInputMethodEvent *event) override;
+ void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
+ void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override;
+ void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
+
+ QVariant inputMethodQuery(Qt::InputMethodQuery query) const override;
+
+ bool supportsExtension(Extension extension) const override;
+ void setExtension(Extension extension, const QVariant &variant) override;
+ QVariant extension(const QVariant &variant) const override;
private:
Q_DISABLE_COPY(QGraphicsTextItem)
@@ -965,8 +965,8 @@ class QGraphicsSimpleTextItemPrivate;
class Q_WIDGETS_EXPORT QGraphicsSimpleTextItem : public QAbstractGraphicsShapeItem
{
public:
- explicit QGraphicsSimpleTextItem(QGraphicsItem *parent = Q_NULLPTR);
- explicit QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent = Q_NULLPTR);
+ explicit QGraphicsSimpleTextItem(QGraphicsItem *parent = nullptr);
+ explicit QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent = nullptr);
~QGraphicsSimpleTextItem();
void setText(const QString &text);
@@ -975,22 +975,22 @@ public:
void setFont(const QFont &font);
QFont font() const;
- QRectF boundingRect() const Q_DECL_OVERRIDE;
- QPainterPath shape() const Q_DECL_OVERRIDE;
- bool contains(const QPointF &point) const Q_DECL_OVERRIDE;
+ QRectF boundingRect() const override;
+ QPainterPath shape() const override;
+ bool contains(const QPointF &point) const override;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
- bool isObscuredBy(const QGraphicsItem *item) const Q_DECL_OVERRIDE;
- QPainterPath opaqueArea() const Q_DECL_OVERRIDE;
+ bool isObscuredBy(const QGraphicsItem *item) const override;
+ QPainterPath opaqueArea() const override;
enum { Type = 9 };
- int type() const Q_DECL_OVERRIDE;
+ int type() const override;
protected:
- bool supportsExtension(Extension extension) const Q_DECL_OVERRIDE;
- void setExtension(Extension extension, const QVariant &variant) Q_DECL_OVERRIDE;
- QVariant extension(const QVariant &variant) const Q_DECL_OVERRIDE;
+ bool supportsExtension(Extension extension) const override;
+ void setExtension(Extension extension, const QVariant &variant) override;
+ QVariant extension(const QVariant &variant) const override;
private:
Q_DISABLE_COPY(QGraphicsSimpleTextItem)
@@ -1001,20 +1001,20 @@ class QGraphicsItemGroupPrivate;
class Q_WIDGETS_EXPORT QGraphicsItemGroup : public QGraphicsItem
{
public:
- explicit QGraphicsItemGroup(QGraphicsItem *parent = Q_NULLPTR);
+ explicit QGraphicsItemGroup(QGraphicsItem *parent = nullptr);
~QGraphicsItemGroup();
void addToGroup(QGraphicsItem *item);
void removeFromGroup(QGraphicsItem *item);
- QRectF boundingRect() const Q_DECL_OVERRIDE;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) Q_DECL_OVERRIDE;
+ QRectF boundingRect() const override;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
- bool isObscuredBy(const QGraphicsItem *item) const Q_DECL_OVERRIDE;
- QPainterPath opaqueArea() const Q_DECL_OVERRIDE;
+ bool isObscuredBy(const QGraphicsItem *item) const override;
+ QPainterPath opaqueArea() const override;
enum { Type = 10 };
- int type() const Q_DECL_OVERRIDE;
+ int type() const override;
private:
Q_DISABLE_COPY(QGraphicsItemGroup)
diff --git a/src/widgets/graphicsview/qgraphicsitem_p.h b/src/widgets/graphicsview/qgraphicsitem_p.h
index 86414263a7..bae38473f9 100644
--- a/src/widgets/graphicsview/qgraphicsitem_p.h
+++ b/src/widgets/graphicsview/qgraphicsitem_p.h
@@ -595,28 +595,28 @@ public:
: QGraphicsEffectSourcePrivate(), item(i), info(0)
{}
- void detach() Q_DECL_OVERRIDE
+ void detach() override
{
item->d_ptr->graphicsEffect = 0;
item->prepareGeometryChange();
}
- const QGraphicsItem *graphicsItem() const Q_DECL_OVERRIDE
+ const QGraphicsItem *graphicsItem() const override
{ return item; }
- const QWidget *widget() const Q_DECL_OVERRIDE
+ const QWidget *widget() const override
{ return 0; }
- void update() Q_DECL_OVERRIDE {
+ void update() override {
item->d_ptr->updateDueToGraphicsEffect = true;
item->update();
item->d_ptr->updateDueToGraphicsEffect = false;
}
- void effectBoundingRectChanged() Q_DECL_OVERRIDE
+ void effectBoundingRectChanged() override
{ item->prepareGeometryChange(); }
- bool isPixmap() const Q_DECL_OVERRIDE
+ bool isPixmap() const override
{
return item->type() == QGraphicsPixmapItem::Type
&& !(item->flags() & QGraphicsItem::ItemIsSelectable)
@@ -624,10 +624,10 @@ public:
//|| (item->d_ptr->isObject && qobject_cast<QDeclarativeImage *>(q_func()));
}
- const QStyleOption *styleOption() const Q_DECL_OVERRIDE
+ const QStyleOption *styleOption() const override
{ return info ? info->option : 0; }
- QRect deviceRect() const Q_DECL_OVERRIDE
+ QRect deviceRect() const override
{
if (!info || !info->widget) {
qWarning("QGraphicsEffectSource::deviceRect: Not yet implemented, lacking device context");
@@ -636,11 +636,11 @@ public:
return info->widget->rect();
}
- QRectF boundingRect(Qt::CoordinateSystem system) const Q_DECL_OVERRIDE;
- void draw(QPainter *) Q_DECL_OVERRIDE;
+ QRectF boundingRect(Qt::CoordinateSystem system) const override;
+ void draw(QPainter *) override;
QPixmap pixmap(Qt::CoordinateSystem system,
QPoint *offset,
- QGraphicsEffect::PixmapPadMode mode) const Q_DECL_OVERRIDE;
+ QGraphicsEffect::PixmapPadMode mode) const override;
QRect paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded = 0) const;
QGraphicsItem *item;
diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.h b/src/widgets/graphicsview/qgraphicsitemanimation.h
index a819acc880..7417d7729c 100644
--- a/src/widgets/graphicsview/qgraphicsitemanimation.h
+++ b/src/widgets/graphicsview/qgraphicsitemanimation.h
@@ -58,7 +58,7 @@ class Q_WIDGETS_EXPORT QGraphicsItemAnimation : public QObject
{
Q_OBJECT
public:
- QGraphicsItemAnimation(QObject *parent = Q_NULLPTR);
+ QGraphicsItemAnimation(QObject *parent = nullptr);
virtual ~QGraphicsItemAnimation();
QGraphicsItem *item() const;
diff --git a/src/widgets/graphicsview/qgraphicslayout.h b/src/widgets/graphicsview/qgraphicslayout.h
index bbe45bbdd6..28b335ceaa 100644
--- a/src/widgets/graphicsview/qgraphicslayout.h
+++ b/src/widgets/graphicsview/qgraphicslayout.h
@@ -54,16 +54,16 @@ class QGraphicsWidget;
class Q_WIDGETS_EXPORT QGraphicsLayout : public QGraphicsLayoutItem
{
public:
- QGraphicsLayout(QGraphicsLayoutItem *parent = Q_NULLPTR);
+ QGraphicsLayout(QGraphicsLayoutItem *parent = nullptr);
~QGraphicsLayout();
void setContentsMargins(qreal left, qreal top, qreal right, qreal bottom);
- void getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const Q_DECL_OVERRIDE;
+ void getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const override;
void activate();
bool isActivated() const;
virtual void invalidate();
- virtual void updateGeometry() Q_DECL_OVERRIDE;
+ virtual void updateGeometry() override;
virtual void widgetEvent(QEvent *e);
diff --git a/src/widgets/graphicsview/qgraphicslayoutitem.h b/src/widgets/graphicsview/qgraphicslayoutitem.h
index 10c7870412..44f430034b 100644
--- a/src/widgets/graphicsview/qgraphicslayoutitem.h
+++ b/src/widgets/graphicsview/qgraphicslayoutitem.h
@@ -54,7 +54,7 @@ class QGraphicsItem;
class Q_WIDGETS_EXPORT QGraphicsLayoutItem
{
public:
- QGraphicsLayoutItem(QGraphicsLayoutItem *parent = Q_NULLPTR, bool isLayout = false);
+ QGraphicsLayoutItem(QGraphicsLayoutItem *parent = nullptr, bool isLayout = false);
virtual ~QGraphicsLayoutItem();
void setSizePolicy(const QSizePolicy &policy);
diff --git a/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h b/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h
index 3463ae71bf..7886de432c 100644
--- a/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h
+++ b/src/widgets/graphicsview/qgraphicslayoutstyleinfo_p.h
@@ -70,17 +70,17 @@ public:
virtual qreal combinedLayoutSpacing(QLayoutPolicy::ControlTypes controls1,
QLayoutPolicy::ControlTypes controls2,
- Qt::Orientation orientation) const Q_DECL_OVERRIDE;
+ Qt::Orientation orientation) const override;
virtual qreal perItemSpacing(QLayoutPolicy::ControlType control1,
QLayoutPolicy::ControlType control2,
- Qt::Orientation orientation) const Q_DECL_OVERRIDE;
+ Qt::Orientation orientation) const override;
- virtual qreal spacing(Qt::Orientation orientation) const Q_DECL_OVERRIDE;
+ virtual qreal spacing(Qt::Orientation orientation) const override;
- virtual qreal windowMargin(Qt::Orientation orientation) const Q_DECL_OVERRIDE;
+ virtual qreal windowMargin(Qt::Orientation orientation) const override;
- virtual void invalidate() Q_DECL_OVERRIDE
+ virtual void invalidate() override
{
m_style = 0;
QAbstractLayoutStyleInfo::invalidate();
diff --git a/src/widgets/graphicsview/qgraphicslinearlayout.h b/src/widgets/graphicsview/qgraphicslinearlayout.h
index 8186eea987..d27191adb3 100644
--- a/src/widgets/graphicsview/qgraphicslinearlayout.h
+++ b/src/widgets/graphicsview/qgraphicslinearlayout.h
@@ -53,8 +53,8 @@ class QGraphicsLinearLayoutPrivate;
class Q_WIDGETS_EXPORT QGraphicsLinearLayout : public QGraphicsLayout
{
public:
- QGraphicsLinearLayout(QGraphicsLayoutItem *parent = Q_NULLPTR);
- QGraphicsLinearLayout(Qt::Orientation orientation, QGraphicsLayoutItem *parent = Q_NULLPTR);
+ QGraphicsLinearLayout(QGraphicsLayoutItem *parent = nullptr);
+ QGraphicsLinearLayout(Qt::Orientation orientation, QGraphicsLayoutItem *parent = nullptr);
virtual ~QGraphicsLinearLayout();
void setOrientation(Qt::Orientation orientation);
@@ -67,7 +67,7 @@ public:
void insertStretch(int index, int stretch = 1);
void removeItem(QGraphicsLayoutItem *item);
- void removeAt(int index) Q_DECL_OVERRIDE;
+ void removeAt(int index) override;
void setSpacing(qreal spacing);
qreal spacing() const;
@@ -80,13 +80,13 @@ public:
void setAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment);
Qt::Alignment alignment(QGraphicsLayoutItem *item) const;
- void setGeometry(const QRectF &rect) Q_DECL_OVERRIDE;
+ void setGeometry(const QRectF &rect) override;
- int count() const Q_DECL_OVERRIDE;
- QGraphicsLayoutItem *itemAt(int index) const Q_DECL_OVERRIDE;
+ int count() const override;
+ QGraphicsLayoutItem *itemAt(int index) const override;
- void invalidate() Q_DECL_OVERRIDE;
- QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const Q_DECL_OVERRIDE;
+ void invalidate() override;
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const override;
#if 0 // ###
Q5SizePolicy::ControlTypes controlTypes(LayoutSide side) const;
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
index 94ce102a68..442f08325d 100644
--- a/src/widgets/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
@@ -1537,6 +1537,14 @@ void QGraphicsProxyWidget::paint(QPainter *painter, const QStyleOptionGraphicsIt
}
/*!
+ \enum QGraphicsProxyWidget::anonymous
+
+ The value returned by the virtual type() function.
+
+ \value Type A graphics proxy widget
+*/
+
+/*!
\reimp
*/
int QGraphicsProxyWidget::type() const
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.h b/src/widgets/graphicsview/qgraphicsproxywidget.h
index fd6369a1fd..76fdf8aeba 100644
--- a/src/widgets/graphicsview/qgraphicsproxywidget.h
+++ b/src/widgets/graphicsview/qgraphicsproxywidget.h
@@ -53,7 +53,7 @@ class Q_WIDGETS_EXPORT QGraphicsProxyWidget : public QGraphicsWidget
{
Q_OBJECT
public:
- QGraphicsProxyWidget(QGraphicsItem *parent = Q_NULLPTR, Qt::WindowFlags wFlags = Qt::WindowFlags());
+ QGraphicsProxyWidget(QGraphicsItem *parent = nullptr, Qt::WindowFlags wFlags = Qt::WindowFlags());
~QGraphicsProxyWidget();
void setWidget(QWidget *widget);
@@ -61,63 +61,63 @@ public:
QRectF subWidgetRect(const QWidget *widget) const;
- void setGeometry(const QRectF &rect) Q_DECL_OVERRIDE;
+ void setGeometry(const QRectF &rect) override;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
enum {
Type = 12
};
- int type() const Q_DECL_OVERRIDE;
+ int type() const override;
QGraphicsProxyWidget *createProxyForChildWidget(QWidget *child);
protected:
- QVariant itemChange(GraphicsItemChange change, const QVariant &value) Q_DECL_OVERRIDE;
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
- bool event(QEvent *event) Q_DECL_OVERRIDE;
- bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
+ bool event(QEvent *event) override;
+ bool eventFilter(QObject *object, QEvent *event) override;
- void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
- void hideEvent(QHideEvent *event) Q_DECL_OVERRIDE;
+ void showEvent(QShowEvent *event) override;
+ void hideEvent(QHideEvent *event) override;
#ifndef QT_NO_CONTEXTMENU
- void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) Q_DECL_OVERRIDE;
+ void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
#endif
#ifndef QT_NO_DRAGANDDROP
- void dragEnterEvent(QGraphicsSceneDragDropEvent *event) Q_DECL_OVERRIDE;
- void dragLeaveEvent(QGraphicsSceneDragDropEvent *event) Q_DECL_OVERRIDE;
- void dragMoveEvent(QGraphicsSceneDragDropEvent *event) Q_DECL_OVERRIDE;
- void dropEvent(QGraphicsSceneDragDropEvent *event) Q_DECL_OVERRIDE;
+ void dragEnterEvent(QGraphicsSceneDragDropEvent *event) override;
+ void dragLeaveEvent(QGraphicsSceneDragDropEvent *event) override;
+ void dragMoveEvent(QGraphicsSceneDragDropEvent *event) override;
+ void dropEvent(QGraphicsSceneDragDropEvent *event) override;
#endif
- void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
- void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
- void hoverMoveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
- void grabMouseEvent(QEvent *event) Q_DECL_OVERRIDE;
- void ungrabMouseEvent(QEvent *event) Q_DECL_OVERRIDE;
+ void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
+ void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
+ void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override;
+ void grabMouseEvent(QEvent *event) override;
+ void ungrabMouseEvent(QEvent *event) override;
- void mouseMoveEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
- void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
+ void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
+ void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
#if QT_CONFIG(wheelevent)
- void wheelEvent(QGraphicsSceneWheelEvent *event) Q_DECL_OVERRIDE;
+ void wheelEvent(QGraphicsSceneWheelEvent *event) override;
#endif
- void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
+ void keyPressEvent(QKeyEvent *event) override;
+ void keyReleaseEvent(QKeyEvent *event) override;
- void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
- void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
- bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE;
+ void focusInEvent(QFocusEvent *event) override;
+ void focusOutEvent(QFocusEvent *event) override;
+ bool focusNextPrevChild(bool next) override;
- QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE;
- void inputMethodEvent(QInputMethodEvent *event) Q_DECL_OVERRIDE;
+ QVariant inputMethodQuery(Qt::InputMethodQuery query) const override;
+ void inputMethodEvent(QInputMethodEvent *event) override;
- QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const Q_DECL_OVERRIDE;
- void resizeEvent(QGraphicsSceneResizeEvent *event) Q_DECL_OVERRIDE;
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const override;
+ void resizeEvent(QGraphicsSceneResizeEvent *event) override;
protected Q_SLOTS:
QGraphicsProxyWidget *newProxyWidget(const QWidget *);
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index 8b088e7c01..25b77aa02f 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -5521,7 +5521,7 @@ bool QGraphicsScene::focusNextPrevChild(bool next)
*/
/*!
- \fn QGraphicsScene::focusItemChanged(QGraphicsItem *newFocusItem, QGraphicsItem *oldFocusItem, Qt::FocusReason reason)
+ \fn void QGraphicsScene::focusItemChanged(QGraphicsItem *newFocusItem, QGraphicsItem *oldFocusItem, Qt::FocusReason reason)
This signal is emitted by QGraphicsScene whenever focus changes in the
scene (i.e., when an item gains or loses input focus, or when focus
diff --git a/src/widgets/graphicsview/qgraphicsscene.h b/src/widgets/graphicsview/qgraphicsscene.h
index d515585067..8efbcd273e 100644
--- a/src/widgets/graphicsview/qgraphicsscene.h
+++ b/src/widgets/graphicsview/qgraphicsscene.h
@@ -121,9 +121,9 @@ public:
};
Q_DECLARE_FLAGS(SceneLayers, SceneLayer)
- QGraphicsScene(QObject *parent = Q_NULLPTR);
- QGraphicsScene(const QRectF &sceneRect, QObject *parent = Q_NULLPTR);
- QGraphicsScene(qreal x, qreal y, qreal width, qreal height, QObject *parent = Q_NULLPTR);
+ QGraphicsScene(QObject *parent = nullptr);
+ QGraphicsScene(const QRectF &sceneRect, QObject *parent = nullptr);
+ QGraphicsScene(qreal x, qreal y, qreal width, qreal height, QObject *parent = nullptr);
virtual ~QGraphicsScene();
QRectF sceneRect() const;
@@ -159,7 +159,7 @@ public:
#if QT_DEPRECATED_SINCE(5, 0)
QT_DEPRECATED inline QGraphicsItem *itemAt(const QPointF &position) const {
QList<QGraphicsItem *> itemsAtPoint = items(position);
- return itemsAtPoint.isEmpty() ? Q_NULLPTR : itemsAtPoint.first();
+ return itemsAtPoint.isEmpty() ? nullptr : itemsAtPoint.first();
}
#endif
QGraphicsItem *itemAt(const QPointF &pos, const QTransform &deviceTransform) const;
@@ -173,7 +173,7 @@ public:
#if QT_DEPRECATED_SINCE(5, 0)
QT_DEPRECATED inline QGraphicsItem *itemAt(qreal x, qreal y) const {
QList<QGraphicsItem *> itemsAtPoint = items(QPointF(x, y));
- return itemsAtPoint.isEmpty() ? Q_NULLPTR : itemsAtPoint.first();
+ return itemsAtPoint.isEmpty() ? nullptr : itemsAtPoint.first();
}
#endif
inline QGraphicsItem *itemAt(qreal x, qreal y, const QTransform &deviceTransform) const
@@ -261,8 +261,8 @@ public Q_SLOTS:
void clear();
protected:
- bool event(QEvent *event) Q_DECL_OVERRIDE;
- bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE;
+ bool event(QEvent *event) override;
+ bool eventFilter(QObject *watched, QEvent *event) override;
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
virtual void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
virtual void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
@@ -285,14 +285,10 @@ protected:
virtual void drawItems(QPainter *painter, int numItems,
QGraphicsItem *items[],
const QStyleOptionGraphicsItem options[],
- QWidget *widget = Q_NULLPTR);
+ QWidget *widget = nullptr);
protected Q_SLOTS:
- // ### Qt 6: make unconditional
-#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
- virtual
-#endif
- bool focusNextPrevChild(bool next);
+ QT6_VIRTUAL bool focusNextPrevChild(bool next);
Q_SIGNALS:
void changed(const QList<QRectF> &region);
diff --git a/src/widgets/graphicsview/qgraphicsscene_bsp.cpp b/src/widgets/graphicsview/qgraphicsscene_bsp.cpp
index 81d2953d8f..75eb50a3ac 100644
--- a/src/widgets/graphicsview/qgraphicsscene_bsp.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene_bsp.cpp
@@ -49,7 +49,7 @@ class QGraphicsSceneInsertItemBspTreeVisitor : public QGraphicsSceneBspTreeVisit
public:
QGraphicsItem *item;
- void visit(QList<QGraphicsItem *> *items) Q_DECL_OVERRIDE
+ void visit(QList<QGraphicsItem *> *items) override
{ items->prepend(item); }
};
@@ -58,7 +58,7 @@ class QGraphicsSceneRemoveItemBspTreeVisitor : public QGraphicsSceneBspTreeVisit
public:
QGraphicsItem *item;
- void visit(QList<QGraphicsItem *> *items) Q_DECL_OVERRIDE
+ void visit(QList<QGraphicsItem *> *items) override
{ items->removeAll(item); }
};
@@ -68,7 +68,7 @@ public:
QList<QGraphicsItem *> *foundItems;
bool onlyTopLevelItems;
- void visit(QList<QGraphicsItem *> *items) Q_DECL_OVERRIDE
+ void visit(QList<QGraphicsItem *> *items) override
{
for (int i = 0; i < items->size(); ++i) {
QGraphicsItem *item = items->at(i);
diff --git a/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h b/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h
index 8e78407762..b6387a2c56 100644
--- a/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h
+++ b/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h
@@ -77,25 +77,25 @@ public:
QGraphicsSceneBspTreeIndex(QGraphicsScene *scene = 0);
~QGraphicsSceneBspTreeIndex();
- QList<QGraphicsItem *> estimateItems(const QRectF &rect, Qt::SortOrder order) const Q_DECL_OVERRIDE;
- QList<QGraphicsItem *> estimateTopLevelItems(const QRectF &rect, Qt::SortOrder order) const Q_DECL_OVERRIDE;
- QList<QGraphicsItem *> items(Qt::SortOrder order = Qt::DescendingOrder) const Q_DECL_OVERRIDE;
+ QList<QGraphicsItem *> estimateItems(const QRectF &rect, Qt::SortOrder order) const override;
+ QList<QGraphicsItem *> estimateTopLevelItems(const QRectF &rect, Qt::SortOrder order) const override;
+ QList<QGraphicsItem *> items(Qt::SortOrder order = Qt::DescendingOrder) const override;
int bspTreeDepth() const;
void setBspTreeDepth(int depth);
protected Q_SLOTS:
- void updateSceneRect(const QRectF &rect) Q_DECL_OVERRIDE;
+ void updateSceneRect(const QRectF &rect) override;
protected:
- bool event(QEvent *event) Q_DECL_OVERRIDE;
- void clear() Q_DECL_OVERRIDE;
+ bool event(QEvent *event) override;
+ void clear() override;
- void addItem(QGraphicsItem *item) Q_DECL_OVERRIDE;
- void removeItem(QGraphicsItem *item) Q_DECL_OVERRIDE;
- void prepareBoundingRectChange(const QGraphicsItem *item) Q_DECL_OVERRIDE;
+ void addItem(QGraphicsItem *item) override;
+ void removeItem(QGraphicsItem *item) override;
+ void prepareBoundingRectChange(const QGraphicsItem *item) override;
- void itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const void *const value) Q_DECL_OVERRIDE;
+ void itemChange(const QGraphicsItem *item, QGraphicsItem::GraphicsItemChange change, const void *const value) override;
private :
Q_DECLARE_PRIVATE(QGraphicsSceneBspTreeIndex)
diff --git a/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h b/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h
index a59a8ac1b0..07d5d80ef1 100644
--- a/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h
+++ b/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h
@@ -70,10 +70,10 @@ public:
QGraphicsSceneLinearIndex(QGraphicsScene *scene = 0) : QGraphicsSceneIndex(scene), m_numSortedElements(0)
{ }
- QList<QGraphicsItem *> items(Qt::SortOrder order = Qt::DescendingOrder) const Q_DECL_OVERRIDE
+ QList<QGraphicsItem *> items(Qt::SortOrder order = Qt::DescendingOrder) const override
{ Q_UNUSED(order); return m_items; }
- virtual QList<QGraphicsItem *> estimateItems(const QRectF &rect, Qt::SortOrder order) const Q_DECL_OVERRIDE
+ virtual QList<QGraphicsItem *> estimateItems(const QRectF &rect, Qt::SortOrder order) const override
{
Q_UNUSED(rect);
Q_UNUSED(order);
@@ -81,16 +81,16 @@ public:
}
protected :
- virtual void clear() Q_DECL_OVERRIDE
+ virtual void clear() override
{
m_items.clear();
m_numSortedElements = 0;
}
- virtual void addItem(QGraphicsItem *item) Q_DECL_OVERRIDE
+ virtual void addItem(QGraphicsItem *item) override
{ m_items << item; }
- virtual void removeItem(QGraphicsItem *item) Q_DECL_OVERRIDE
+ virtual void removeItem(QGraphicsItem *item) override
{
// Sort m_items if needed
if (m_numSortedElements < m_items.size())
diff --git a/src/widgets/graphicsview/qgraphicstransform.h b/src/widgets/graphicsview/qgraphicstransform.h
index ceeb314c86..b8455781c5 100644
--- a/src/widgets/graphicsview/qgraphicstransform.h
+++ b/src/widgets/graphicsview/qgraphicstransform.h
@@ -57,7 +57,7 @@ class Q_WIDGETS_EXPORT QGraphicsTransform : public QObject
{
Q_OBJECT
public:
- QGraphicsTransform(QObject *parent = Q_NULLPTR);
+ QGraphicsTransform(QObject *parent = nullptr);
~QGraphicsTransform();
virtual void applyTo(QMatrix4x4 *matrix) const = 0;
@@ -85,7 +85,7 @@ class Q_WIDGETS_EXPORT QGraphicsScale : public QGraphicsTransform
Q_PROPERTY(qreal yScale READ yScale WRITE setYScale NOTIFY yScaleChanged)
Q_PROPERTY(qreal zScale READ zScale WRITE setZScale NOTIFY zScaleChanged)
public:
- QGraphicsScale(QObject *parent = Q_NULLPTR);
+ QGraphicsScale(QObject *parent = nullptr);
~QGraphicsScale();
QVector3D origin() const;
@@ -100,7 +100,7 @@ public:
qreal zScale() const;
void setZScale(qreal);
- void applyTo(QMatrix4x4 *matrix) const Q_DECL_OVERRIDE;
+ void applyTo(QMatrix4x4 *matrix) const override;
Q_SIGNALS:
void originChanged();
@@ -123,7 +123,7 @@ class Q_WIDGETS_EXPORT QGraphicsRotation : public QGraphicsTransform
Q_PROPERTY(qreal angle READ angle WRITE setAngle NOTIFY angleChanged)
Q_PROPERTY(QVector3D axis READ axis WRITE setAxis NOTIFY axisChanged)
public:
- QGraphicsRotation(QObject *parent = Q_NULLPTR);
+ QGraphicsRotation(QObject *parent = nullptr);
~QGraphicsRotation();
QVector3D origin() const;
@@ -136,7 +136,7 @@ public:
void setAxis(const QVector3D &axis);
void setAxis(Qt::Axis axis);
- void applyTo(QMatrix4x4 *matrix) const Q_DECL_OVERRIDE;
+ void applyTo(QMatrix4x4 *matrix) const override;
Q_SIGNALS:
void originChanged();
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp
index 4b7890e9ff..1cc8543fdd 100644
--- a/src/widgets/graphicsview/qgraphicsview.cpp
+++ b/src/widgets/graphicsview/qgraphicsview.cpp
@@ -284,6 +284,7 @@ static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; // largest prime <
#include <QtCore/qscopedvaluerollback.h>
#include <QtWidgets/qapplication.h>
#include <QtWidgets/qdesktopwidget.h>
+#include <private/qdesktopwidget_p.h>
#include <QtGui/qevent.h>
#include <QtWidgets/qlayout.h>
#include <QtGui/qtransform.h>
@@ -1248,7 +1249,7 @@ QSize QGraphicsView::sizeHint() const
if (d->scene) {
QSizeF baseSize = d->matrix.mapRect(sceneRect()).size();
baseSize += QSizeF(d->frameWidth * 2, d->frameWidth * 2);
- return baseSize.boundedTo((3 * QApplication::desktop()->size()) / 4).toSize();
+ return baseSize.boundedTo((3 * QDesktopWidgetPrivate::size()) / 4).toSize();
}
return QAbstractScrollArea::sizeHint();
}
diff --git a/src/widgets/graphicsview/qgraphicsview.h b/src/widgets/graphicsview/qgraphicsview.h
index a9e4efefaf..e02fba69c9 100644
--- a/src/widgets/graphicsview/qgraphicsview.h
+++ b/src/widgets/graphicsview/qgraphicsview.h
@@ -114,11 +114,11 @@ public:
};
Q_DECLARE_FLAGS(OptimizationFlags, OptimizationFlag)
- QGraphicsView(QWidget *parent = Q_NULLPTR);
- QGraphicsView(QGraphicsScene *scene, QWidget *parent = Q_NULLPTR);
+ QGraphicsView(QWidget *parent = nullptr);
+ QGraphicsView(QGraphicsScene *scene, QWidget *parent = nullptr);
~QGraphicsView();
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
QPainter::RenderHints renderHints() const;
void setRenderHint(QPainter::RenderHint hint, bool enabled = true);
@@ -214,7 +214,7 @@ public:
inline QPoint mapFromScene(qreal x, qreal y) const;
inline QPolygon mapFromScene(qreal x, qreal y, qreal w, qreal h) const;
- QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE;
+ QVariant inputMethodQuery(Qt::InputMethodQuery query) const override;
QBrush backgroundBrush() const;
void setBackgroundBrush(const QBrush &brush);
@@ -233,39 +233,39 @@ Q_SIGNALS:
#endif
protected Q_SLOTS:
- void setupViewport(QWidget *widget) Q_DECL_OVERRIDE;
+ void setupViewport(QWidget *widget) override;
protected:
- QGraphicsView(QGraphicsViewPrivate &, QWidget *parent = Q_NULLPTR);
- bool event(QEvent *event) Q_DECL_OVERRIDE;
- bool viewportEvent(QEvent *event) Q_DECL_OVERRIDE;
+ QGraphicsView(QGraphicsViewPrivate &, QWidget *parent = nullptr);
+ bool event(QEvent *event) override;
+ bool viewportEvent(QEvent *event) override;
#ifndef QT_NO_CONTEXTMENU
- void contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE;
+ void contextMenuEvent(QContextMenuEvent *event) override;
#endif
#if QT_CONFIG(draganddrop)
- void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE;
- void dragLeaveEvent(QDragLeaveEvent *event) Q_DECL_OVERRIDE;
- void dragMoveEvent(QDragMoveEvent *event) Q_DECL_OVERRIDE;
- void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE;
+ void dragEnterEvent(QDragEnterEvent *event) override;
+ void dragLeaveEvent(QDragLeaveEvent *event) override;
+ void dragMoveEvent(QDragMoveEvent *event) override;
+ void dropEvent(QDropEvent *event) override;
#endif
- void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
- bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE;
- void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+ void focusInEvent(QFocusEvent *event) override;
+ bool focusNextPrevChild(bool next) override;
+ void focusOutEvent(QFocusEvent *event) override;
+ void keyPressEvent(QKeyEvent *event) override;
+ void keyReleaseEvent(QKeyEvent *event) override;
+ void mouseDoubleClickEvent(QMouseEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
#if QT_CONFIG(wheelevent)
- void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
+ void wheelEvent(QWheelEvent *event) override;
#endif
- void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
- void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE;
- void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
- void inputMethodEvent(QInputMethodEvent *event) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent *event) override;
+ void resizeEvent(QResizeEvent *event) override;
+ void scrollContentsBy(int dx, int dy) override;
+ void showEvent(QShowEvent *event) override;
+ void inputMethodEvent(QInputMethodEvent *event) override;
virtual void drawBackground(QPainter *painter, const QRectF &rect);
virtual void drawForeground(QPainter *painter, const QRectF &rect);
diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp
index c658e40a9e..a4534c73dd 100644
--- a/src/widgets/graphicsview/qgraphicswidget.cpp
+++ b/src/widgets/graphicsview/qgraphicswidget.cpp
@@ -276,7 +276,7 @@ QGraphicsWidget::~QGraphicsWidget()
// Unset the parent here, when we're still a QGraphicsWidget.
// It is otherwise done in ~QGraphicsItem() where we'd be
// calling QGraphicsWidget members on an ex-QGraphicsWidget object
- setParentItem(Q_NULLPTR);
+ setParentItem(nullptr);
}
/*!
@@ -2228,6 +2228,14 @@ bool QGraphicsWidget::testAttribute(Qt::WidgetAttribute attribute) const
}
/*!
+ \enum QGraphicsWidget::anonymous
+
+ The value returned by the virtual type() function.
+
+ \value Type A graphics widget item
+*/
+
+/*!
\reimp
*/
int QGraphicsWidget::type() const
diff --git a/src/widgets/graphicsview/qgraphicswidget.h b/src/widgets/graphicsview/qgraphicswidget.h
index 831511d14a..481fb55db3 100644
--- a/src/widgets/graphicsview/qgraphicswidget.h
+++ b/src/widgets/graphicsview/qgraphicswidget.h
@@ -80,7 +80,7 @@ class Q_WIDGETS_EXPORT QGraphicsWidget : public QGraphicsObject, public QGraphic
Q_PROPERTY(bool autoFillBackground READ autoFillBackground WRITE setAutoFillBackground)
Q_PROPERTY(QGraphicsLayout* layout READ layout WRITE setLayout NOTIFY layoutChanged)
public:
- QGraphicsWidget(QGraphicsItem *parent = Q_NULLPTR, Qt::WindowFlags wFlags = Qt::WindowFlags());
+ QGraphicsWidget(QGraphicsItem *parent = nullptr, Qt::WindowFlags wFlags = Qt::WindowFlags());
~QGraphicsWidget();
QGraphicsLayout *layout() const;
void setLayout(QGraphicsLayout *layout);
@@ -106,12 +106,12 @@ public:
inline void resize(qreal w, qreal h) { resize(QSizeF(w, h)); }
QSizeF size() const;
- void setGeometry(const QRectF &rect) Q_DECL_OVERRIDE;
+ void setGeometry(const QRectF &rect) override;
inline void setGeometry(qreal x, qreal y, qreal w, qreal h);
inline QRectF rect() const { return QRectF(QPointF(), size()); }
void setContentsMargins(qreal left, qreal top, qreal right, qreal bottom);
- void getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const Q_DECL_OVERRIDE;
+ void getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const override;
void setWindowFrameMargins(qreal left, qreal top, qreal right, qreal bottom);
void getWindowFrameMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const;
@@ -161,12 +161,12 @@ public:
enum {
Type = 11
};
- int type() const Q_DECL_OVERRIDE;
+ int type() const override;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR) Q_DECL_OVERRIDE;
- virtual void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = Q_NULLPTR);
- QRectF boundingRect() const Q_DECL_OVERRIDE;
- QPainterPath shape() const Q_DECL_OVERRIDE;
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
+ virtual void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr);
+ QRectF boundingRect() const override;
+ QPainterPath shape() const override;
#if 0
void dumpFocusChain();
@@ -184,28 +184,28 @@ public Q_SLOTS:
protected:
virtual void initStyleOption(QStyleOption *option) const;
- QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const Q_DECL_OVERRIDE;
- void updateGeometry() Q_DECL_OVERRIDE;
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const override;
+ void updateGeometry() override;
// Notification
- QVariant itemChange(GraphicsItemChange change, const QVariant &value) Q_DECL_OVERRIDE;
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
virtual QVariant propertyChange(const QString &propertyName, const QVariant &value);
// Scene events
- bool sceneEvent(QEvent *event) Q_DECL_OVERRIDE;
+ bool sceneEvent(QEvent *event) override;
virtual bool windowFrameEvent(QEvent *e);
virtual Qt::WindowFrameSection windowFrameSectionAt(const QPointF& pos) const;
// Base event handlers
- bool event(QEvent *event) Q_DECL_OVERRIDE;
+ bool event(QEvent *event) override;
//virtual void actionEvent(QActionEvent *event);
virtual void changeEvent(QEvent *event);
virtual void closeEvent(QCloseEvent *event);
//void create(WId window = 0, bool initializeWindow = true, bool destroyOldWindow = true);
//void destroy(bool destroyWindow = true, bool destroySubWindows = true);
- void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
+ void focusInEvent(QFocusEvent *event) override;
virtual bool focusNextPrevChild(bool next);
- void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
+ void focusOutEvent(QFocusEvent *event) override;
virtual void hideEvent(QHideEvent *event);
//virtual int metric(PaintDeviceMetric m ) const;
virtual void moveEvent(QGraphicsSceneMoveEvent *event);
@@ -214,8 +214,8 @@ protected:
virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
virtual void showEvent(QShowEvent *event);
//virtual void tabletEvent(QTabletEvent *event);
- virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
- virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
+ virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override;
+ virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
virtual void grabMouseEvent(QEvent *event);
virtual void ungrabMouseEvent(QEvent *event);
virtual void grabKeyboardEvent(QEvent *event);
diff --git a/src/widgets/graphicsview/qgraphicswidget_p.cpp b/src/widgets/graphicsview/qgraphicswidget_p.cpp
index 8feed29a8f..1514fca456 100644
--- a/src/widgets/graphicsview/qgraphicswidget_p.cpp
+++ b/src/widgets/graphicsview/qgraphicswidget_p.cpp
@@ -50,9 +50,6 @@
#include <QtWidgets/qstyleoption.h>
#include <QtWidgets/QStyleOptionTitleBar>
#include <QtWidgets/QGraphicsSceneMouseEvent>
-#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && QT_CONFIG(style_mac)
-# include <private/qmacstyle_mac_p.h>
-#endif
QT_BEGIN_NAMESPACE
@@ -409,7 +406,7 @@ void QGraphicsWidgetPrivate::windowFrameMousePressEvent(QGraphicsSceneMouseEvent
event->setAccepted(windowData->grabbedSection != Qt::NoSection);
}
-/*!
+/*
Used to calculate the
Precondition:
\a widget should support either hfw or wfh
diff --git a/src/widgets/graphicsview/qgraphicswidget_p.h b/src/widgets/graphicsview/qgraphicswidget_p.h
index 0fb9fbba07..505a2a24c0 100644
--- a/src/widgets/graphicsview/qgraphicswidget_p.h
+++ b/src/widgets/graphicsview/qgraphicswidget_p.h
@@ -94,13 +94,13 @@ public:
QPalette palette;
uint inheritedPaletteResolveMask;
void setPalette_helper(const QPalette &palette);
- void resolvePalette(uint inheritedMask) Q_DECL_OVERRIDE;
+ void resolvePalette(uint inheritedMask) override;
void updatePalette(const QPalette &palette);
QPalette naturalWidgetPalette() const;
QFont font;
uint inheritedFontResolveMask;
void setFont_helper(const QFont &font);
- void resolveFont(uint inheritedMask) Q_DECL_OVERRIDE;
+ void resolveFont(uint inheritedMask) override;
void updateFont(const QFont &font);
QFont naturalWidgetFont() const;
@@ -115,13 +115,13 @@ public:
bool hasDecoration() const;
// Private Properties
- qreal width() const Q_DECL_OVERRIDE;
- void setWidth(qreal) Q_DECL_OVERRIDE;
- void resetWidth() Q_DECL_OVERRIDE;
+ qreal width() const override;
+ void setWidth(qreal) override;
+ void resetWidth() override;
- qreal height() const Q_DECL_OVERRIDE;
- void setHeight(qreal) Q_DECL_OVERRIDE;
- void resetHeight() Q_DECL_OVERRIDE;
+ qreal height() const override;
+ void setHeight(qreal) override;
+ void resetHeight() override;
void setGeometryFromSetPos();
// State
diff --git a/src/widgets/graphicsview/qsimplex_p.cpp b/src/widgets/graphicsview/qsimplex_p.cpp
index 1e847489bb..e6ffa856f1 100644
--- a/src/widgets/graphicsview/qsimplex_p.cpp
+++ b/src/widgets/graphicsview/qsimplex_p.cpp
@@ -209,7 +209,7 @@ bool QSimplex::setConstraints(const QList<QSimplexConstraint *> &newConstraints)
surplus->index = ++variableIndex;
constraints[i]->helper.first = surplus;
constraints[i]->helper.second = -1.0;
- // fall through
+ Q_FALLTHROUGH();
case QSimplexConstraint::Equal:
artificial = new QSimplexVariable;
constraints[i]->artificial = artificial;
diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp
index d532221092..3268fda2fc 100644
--- a/src/widgets/itemviews/qabstractitemdelegate.cpp
+++ b/src/widgets/itemviews/qabstractitemdelegate.cpp
@@ -58,6 +58,7 @@
#endif
#include <qapplication.h>
#include <qvalidator.h>
+#include <qjsonvalue.h>
#include <private/qtextengine_p.h>
#include <private/qabstractitemdelegate_p.h>
@@ -585,18 +586,26 @@ QString QAbstractItemDelegatePrivate::textForRole(Qt::ItemDataRole role, const Q
case QVariant::Time:
text = locale.toString(value.toTime(), formatType);
break;
- case QVariant::DateTime: {
- const QDateTime dateTime = value.toDateTime();
- text = locale.toString(dateTime.date(), formatType)
- + QLatin1Char(' ')
- + locale.toString(dateTime.time(), formatType);
- break; }
- default:
- text = value.toString();
+ case QVariant::DateTime:
+ text = locale.toString(value.toDateTime(), formatType);
+ break;
+ default: {
+ if (value.canConvert<QJsonValue>()) {
+ const QJsonValue val = value.toJsonValue();
+ if (val.isBool())
+ text = QVariant(val.toBool()).toString();
+ else if (val.isDouble())
+ text = locale.toString(val.toDouble(), 'g', precision);
+ else if (val.isString())
+ text = val.toString();
+ } else {
+ text = value.toString();
+ }
if (role == Qt::DisplayRole)
text.replace(QLatin1Char('\n'), QChar::LineSeparator);
break;
}
+ }
return text;
}
diff --git a/src/widgets/itemviews/qabstractitemdelegate.h b/src/widgets/itemviews/qabstractitemdelegate.h
index 9b6bde1c87..575728e806 100644
--- a/src/widgets/itemviews/qabstractitemdelegate.h
+++ b/src/widgets/itemviews/qabstractitemdelegate.h
@@ -69,7 +69,7 @@ public:
RevertModelCache
};
- explicit QAbstractItemDelegate(QObject *parent = Q_NULLPTR);
+ explicit QAbstractItemDelegate(QObject *parent = nullptr);
virtual ~QAbstractItemDelegate();
// painting
@@ -119,7 +119,7 @@ Q_SIGNALS:
void sizeHintChanged(const QModelIndex &);
protected:
- QAbstractItemDelegate(QObjectPrivate &, QObject *parent = Q_NULLPTR);
+ QAbstractItemDelegate(QObjectPrivate &, QObject *parent = nullptr);
private:
Q_DECLARE_PRIVATE(QAbstractItemDelegate)
Q_DISABLE_COPY(QAbstractItemDelegate)
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index 9870d9d49a..a07297863d 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -219,7 +219,7 @@ void QAbstractItemViewPrivate::_q_scrollerStateChanged()
q->selectionModel()->select(oldSelection, QItemSelectionModel::ClearAndSelect);
q->selectionModel()->setCurrentIndex(oldCurrent, QItemSelectionModel::NoUpdate);
}
- // fall through
+ Q_FALLTHROUGH();
default:
oldSelection = QItemSelection();
@@ -2194,7 +2194,7 @@ QAbstractItemViewPrivate::position(const QPoint &pos, const QRect &rect, const Q
{
QAbstractItemView::DropIndicatorPosition r = QAbstractItemView::OnViewport;
if (!overwrite) {
- const int margin = 2;
+ const int margin = qBound(2, qRound(qreal(rect.height()) / 5.5), 12);
if (pos.y() - rect.top() < margin) {
r = QAbstractItemView::AboveItem;
} else if (rect.bottom() - pos.y() < margin) {
@@ -2255,7 +2255,7 @@ void QAbstractItemView::focusInEvent(QFocusEvent *event)
/*!
This function is called with the given \a event when the widget
- looses the focus. By default, the event is ignored.
+ loses the focus. By default, the event is ignored.
\sa clearFocus(), focusInEvent()
*/
@@ -3135,7 +3135,7 @@ int QAbstractItemView::sizeHintForColumn(int column) const
Opens a persistent editor on the item at the given \a index.
If no editor exists, the delegate will create a new editor.
- \sa closePersistentEditor()
+ \sa closePersistentEditor(), isPersistentEditorOpen()
*/
void QAbstractItemView::openPersistentEditor(const QModelIndex &index)
{
@@ -3154,7 +3154,7 @@ void QAbstractItemView::openPersistentEditor(const QModelIndex &index)
/*!
Closes the persistent editor for the item at the given \a index.
- \sa openPersistentEditor()
+ \sa openPersistentEditor(), isPersistentEditorOpen()
*/
void QAbstractItemView::closePersistentEditor(const QModelIndex &index)
{
@@ -3169,6 +3169,19 @@ void QAbstractItemView::closePersistentEditor(const QModelIndex &index)
}
/*!
+ \since 5.10
+
+ Returns whether a persistent editor is open for the item at index \a index.
+
+ \sa openPersistentEditor(), closePersistentEditor()
+*/
+bool QAbstractItemView::isPersistentEditorOpen(const QModelIndex &index) const
+{
+ Q_D(const QAbstractItemView);
+ return d->editorForIndex(index).widget;
+}
+
+/*!
\since 4.1
Sets the given \a widget on the item at the given \a index, passing the
@@ -3204,12 +3217,14 @@ void QAbstractItemView::setIndexWidget(const QModelIndex &index, QWidget *widget
if (QWidget *oldWidget = indexWidget(index)) {
d->persistent.remove(oldWidget);
d->removeEditor(oldWidget);
+ oldWidget->removeEventFilter(this);
oldWidget->deleteLater();
}
if (widget) {
widget->setParent(viewport());
d->persistent.insert(widget);
d->addEditor(index, widget, true);
+ widget->installEventFilter(this);
widget->show();
dataChanged(index, index); // update the geometry
if (!d->delayedPendingLayout)
@@ -4418,8 +4433,7 @@ QItemViewPaintPairs QAbstractItemViewPrivate::draggablePaintPairs(const QModelIn
for (const auto &index : indexes) {
const QRect current = q->visualRect(index);
if (current.intersects(viewportRect)) {
- QItemViewPaintPair p = { current, index };
- ret += p;
+ ret.append({current, index});
rect |= current;
}
}
@@ -4487,6 +4501,24 @@ QModelIndexList QAbstractItemViewPrivate::selectedDraggableIndexes() const
return indexes;
}
+/*!
+ \reimp
+*/
+
+bool QAbstractItemView::eventFilter(QObject *object, QEvent *event)
+{
+ Q_D(QAbstractItemView);
+ if (object == this || object == viewport() || event->type() != QEvent::FocusIn)
+ return QAbstractScrollArea::eventFilter(object, event);
+ QWidget *widget = qobject_cast<QWidget *>(object);
+ // If it is not a persistent widget then we did not install
+ // the event filter on it, so assume a base implementation is
+ // filtering
+ if (!widget || !d->persistent.contains(widget))
+ return QAbstractScrollArea::eventFilter(object, event);
+ setCurrentIndex(d->indexForEditor(widget));
+ return false;
+}
QT_END_NAMESPACE
diff --git a/src/widgets/itemviews/qabstractitemview.h b/src/widgets/itemviews/qabstractitemview.h
index 6be776ec52..8a138bdb67 100644
--- a/src/widgets/itemviews/qabstractitemview.h
+++ b/src/widgets/itemviews/qabstractitemview.h
@@ -124,7 +124,7 @@ public:
};
Q_ENUM(ScrollMode)
- explicit QAbstractItemView(QWidget *parent = Q_NULLPTR);
+ explicit QAbstractItemView(QWidget *parent = nullptr);
~QAbstractItemView();
virtual void setModel(QAbstractItemModel *model);
@@ -212,6 +212,7 @@ public:
void openPersistentEditor(const QModelIndex &index);
void closePersistentEditor(const QModelIndex &index);
+ bool isPersistentEditorOpen(const QModelIndex &index) const;
void setIndexWidget(const QModelIndex &index, QWidget *widget);
QWidget *indexWidget(const QModelIndex &index) const;
@@ -224,7 +225,7 @@ public:
QAbstractItemDelegate *itemDelegate(const QModelIndex &index) const;
- virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE;
+ virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const override;
using QAbstractScrollArea::update;
@@ -269,7 +270,7 @@ Q_SIGNALS:
void iconSizeChanged(const QSize &size);
protected:
- QAbstractItemView(QAbstractItemViewPrivate &, QWidget *parent = Q_NULLPTR);
+ QAbstractItemView(QAbstractItemViewPrivate &, QWidget *parent = nullptr);
void setHorizontalStepsPerItem(int steps);
int horizontalStepsPerItem() const;
@@ -294,7 +295,7 @@ protected:
virtual bool edit(const QModelIndex &index, EditTrigger trigger, QEvent *event);
virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index,
- const QEvent *event = Q_NULLPTR) const;
+ const QEvent *event = nullptr) const;
#ifndef QT_NO_DRAGANDDROP
virtual void startDrag(Qt::DropActions supportedActions);
@@ -326,32 +327,33 @@ protected:
void stopAutoScroll();
void doAutoScroll();
- bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE;
- bool event(QEvent *event) Q_DECL_OVERRIDE;
- bool viewportEvent(QEvent *event) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+ bool focusNextPrevChild(bool next) override;
+ bool event(QEvent *event) override;
+ bool viewportEvent(QEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
+ void mouseDoubleClickEvent(QMouseEvent *event) override;
#ifndef QT_NO_DRAGANDDROP
- void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE;
- void dragMoveEvent(QDragMoveEvent *event) Q_DECL_OVERRIDE;
- void dragLeaveEvent(QDragLeaveEvent *event) Q_DECL_OVERRIDE;
- void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE;
+ void dragEnterEvent(QDragEnterEvent *event) override;
+ void dragMoveEvent(QDragMoveEvent *event) override;
+ void dragLeaveEvent(QDragLeaveEvent *event) override;
+ void dropEvent(QDropEvent *event) override;
#endif
- void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
- void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
- void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE;
- void inputMethodEvent(QInputMethodEvent *event) Q_DECL_OVERRIDE;
+ void focusInEvent(QFocusEvent *event) override;
+ void focusOutEvent(QFocusEvent *event) override;
+ void keyPressEvent(QKeyEvent *event) override;
+ void resizeEvent(QResizeEvent *event) override;
+ void timerEvent(QTimerEvent *event) override;
+ void inputMethodEvent(QInputMethodEvent *event) override;
+ bool eventFilter(QObject *object, QEvent *event) override;
#ifndef QT_NO_DRAGANDDROP
enum DropIndicatorPosition { OnItem, AboveItem, BelowItem, OnViewport };
DropIndicatorPosition dropIndicatorPosition() const;
#endif
- QSize viewportSizeHint() const Q_DECL_OVERRIDE;
+ QSize viewportSizeHint() const override;
private:
Q_DECLARE_PRIVATE(QAbstractItemView)
diff --git a/src/widgets/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp
index ea9bbb0fb9..d94f25de78 100644
--- a/src/widgets/itemviews/qcolumnview.cpp
+++ b/src/widgets/itemviews/qcolumnview.cpp
@@ -53,8 +53,6 @@
QT_BEGIN_NAMESPACE
-#define ANIMATION_DURATION_MSEC 150
-
/*!
\since 4.3
\class QColumnView
@@ -107,7 +105,6 @@ void QColumnViewPrivate::initialize()
q->setTextElideMode(Qt::ElideMiddle);
#ifndef QT_NO_ANIMATION
QObject::connect(&currentAnimation, SIGNAL(finished()), q, SLOT(_q_changeCurrentColumn()));
- currentAnimation.setDuration(ANIMATION_DURATION_MSEC);
currentAnimation.setTargetObject(hbar);
currentAnimation.setPropertyName("value");
currentAnimation.setEasingCurve(QEasingCurve::InOutQuad);
@@ -330,7 +327,8 @@ void QColumnView::scrollTo(const QModelIndex &index, ScrollHint hint)
}
#ifndef QT_NO_ANIMATION
- if (style()->styleHint(QStyle::SH_Widget_Animate, 0, this)) {
+ if (const int animationDuration = style()->styleHint(QStyle::SH_Widget_Animation_Duration, 0, this)) {
+ d->currentAnimation.setDuration(animationDuration);
d->currentAnimation.setEndValue(newScrollbarValue);
d->currentAnimation.start();
} else
diff --git a/src/widgets/itemviews/qcolumnview.h b/src/widgets/itemviews/qcolumnview.h
index 42eac7426a..5c62f9c9af 100644
--- a/src/widgets/itemviews/qcolumnview.h
+++ b/src/widgets/itemviews/qcolumnview.h
@@ -58,18 +58,18 @@ Q_SIGNALS:
void updatePreviewWidget(const QModelIndex &index);
public:
- explicit QColumnView(QWidget *parent = Q_NULLPTR);
+ explicit QColumnView(QWidget *parent = nullptr);
~QColumnView();
// QAbstractItemView overloads
- QModelIndex indexAt(const QPoint &point) const Q_DECL_OVERRIDE;
- void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) Q_DECL_OVERRIDE;
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QRect visualRect(const QModelIndex &index) const Q_DECL_OVERRIDE;
- void setModel(QAbstractItemModel *model) Q_DECL_OVERRIDE;
- void setSelectionModel(QItemSelectionModel * selectionModel) Q_DECL_OVERRIDE;
- void setRootIndex(const QModelIndex &index) Q_DECL_OVERRIDE;
- void selectAll() Q_DECL_OVERRIDE;
+ QModelIndex indexAt(const QPoint &point) const override;
+ void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) override;
+ QSize sizeHint() const override;
+ QRect visualRect(const QModelIndex &index) const override;
+ void setModel(QAbstractItemModel *model) override;
+ void setSelectionModel(QItemSelectionModel * selectionModel) override;
+ void setRootIndex(const QModelIndex &index) override;
+ void selectAll() override;
// QColumnView functions
void setResizeGripsVisible(bool visible);
@@ -82,21 +82,21 @@ public:
QList<int> columnWidths() const;
protected:
- QColumnView(QColumnViewPrivate &dd, QWidget *parent = Q_NULLPTR);
+ QColumnView(QColumnViewPrivate &dd, QWidget *parent = nullptr);
// QAbstractItemView overloads
- bool isIndexHidden(const QModelIndex &index) const Q_DECL_OVERRIDE;
- QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
- void setSelection(const QRect & rect, QItemSelectionModel::SelectionFlags command) Q_DECL_OVERRIDE;
- QRegion visualRegionForSelection(const QItemSelection &selection) const Q_DECL_OVERRIDE;
- int horizontalOffset() const Q_DECL_OVERRIDE;
- int verticalOffset() const Q_DECL_OVERRIDE;
- void rowsInserted(const QModelIndex &parent, int start, int end) Q_DECL_OVERRIDE;
- void currentChanged(const QModelIndex &current, const QModelIndex &previous) Q_DECL_OVERRIDE;
+ bool isIndexHidden(const QModelIndex &index) const override;
+ QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
+ void resizeEvent(QResizeEvent *event) override;
+ void setSelection(const QRect & rect, QItemSelectionModel::SelectionFlags command) override;
+ QRegion visualRegionForSelection(const QItemSelection &selection) const override;
+ int horizontalOffset() const override;
+ int verticalOffset() const override;
+ void rowsInserted(const QModelIndex &parent, int start, int end) override;
+ void currentChanged(const QModelIndex &current, const QModelIndex &previous) override;
// QColumnView functions
- void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE;
+ void scrollContentsBy(int dx, int dy) override;
virtual QAbstractItemView* createColumn(const QModelIndex &rootIndex);
void initializeColumn(QAbstractItemView *column) const;
diff --git a/src/widgets/itemviews/qcolumnview_p.h b/src/widgets/itemviews/qcolumnview_p.h
index fa276075fe..850ab02747 100644
--- a/src/widgets/itemviews/qcolumnview_p.h
+++ b/src/widgets/itemviews/qcolumnview_p.h
@@ -80,7 +80,7 @@ public:
setMinimumWidth(previewWidget->minimumWidth());
}
- void resizeEvent(QResizeEvent * event) Q_DECL_OVERRIDE{
+ void resizeEvent(QResizeEvent * event) override{
if (!previewWidget)
return;
previewWidget->resize(
@@ -96,7 +96,7 @@ public:
QAbstractScrollArea::resizeEvent(event);
}
- void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE
+ void scrollContentsBy(int dx, int dy) override
{
if (!previewWidget)
return;
@@ -106,36 +106,36 @@ public:
QAbstractItemView::scrollContentsBy(dx, dy);
}
- QRect visualRect(const QModelIndex &) const Q_DECL_OVERRIDE
+ QRect visualRect(const QModelIndex &) const override
{
return QRect();
}
- void scrollTo(const QModelIndex &, ScrollHint) Q_DECL_OVERRIDE
+ void scrollTo(const QModelIndex &, ScrollHint) override
{
}
- QModelIndex indexAt(const QPoint &) const Q_DECL_OVERRIDE
+ QModelIndex indexAt(const QPoint &) const override
{
return QModelIndex();
}
- QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers) Q_DECL_OVERRIDE
+ QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers) override
{
return QModelIndex();
}
- int horizontalOffset () const Q_DECL_OVERRIDE {
+ int horizontalOffset () const override {
return 0;
}
- int verticalOffset () const Q_DECL_OVERRIDE {
+ int verticalOffset () const override {
return 0;
}
- QRegion visualRegionForSelection(const QItemSelection &) const Q_DECL_OVERRIDE
+ QRegion visualRegionForSelection(const QItemSelection &) const override
{
return QRegion();
}
- bool isIndexHidden(const QModelIndex &) const Q_DECL_OVERRIDE
+ bool isIndexHidden(const QModelIndex &) const override
{
return false;
}
- void setSelection(const QRect &, QItemSelectionModel::SelectionFlags) Q_DECL_OVERRIDE
+ void setSelection(const QRect &, QItemSelectionModel::SelectionFlags) override
{
}
private:
@@ -163,7 +163,7 @@ public:
void _q_gripMoved(int offset);
void _q_changeCurrentColumn();
void _q_clicked(const QModelIndex &index);
- void _q_columnsInserted(const QModelIndex &parent, int start, int end) Q_DECL_OVERRIDE;
+ void _q_columnsInserted(const QModelIndex &parent, int start, int end) override;
QList<QAbstractItemView*> columns;
QVector<int> columnSizes; // used during init and corner moving
@@ -188,7 +188,7 @@ public:
void paint(QPainter *painter,
const QStyleOptionViewItem &option,
- const QModelIndex &index) const Q_DECL_OVERRIDE;
+ const QModelIndex &index) const override;
};
QT_END_NAMESPACE
diff --git a/src/widgets/itemviews/qcolumnviewgrip_p.h b/src/widgets/itemviews/qcolumnviewgrip_p.h
index 16c0aefada..7e2793074b 100644
--- a/src/widgets/itemviews/qcolumnviewgrip_p.h
+++ b/src/widgets/itemviews/qcolumnviewgrip_p.h
@@ -74,11 +74,11 @@ public:
protected:
QColumnViewGrip(QColumnViewGripPrivate &, QWidget *parent = 0, Qt::WindowFlags f = 0);
- void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
- void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent *event) override;
+ void mouseDoubleClickEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
private:
Q_DECLARE_PRIVATE(QColumnViewGrip)
diff --git a/src/widgets/itemviews/qdatawidgetmapper.h b/src/widgets/itemviews/qdatawidgetmapper.h
index 7d4d61378a..2d75b63a5e 100644
--- a/src/widgets/itemviews/qdatawidgetmapper.h
+++ b/src/widgets/itemviews/qdatawidgetmapper.h
@@ -61,7 +61,7 @@ class Q_WIDGETS_EXPORT QDataWidgetMapper: public QObject
Q_PROPERTY(SubmitPolicy submitPolicy READ submitPolicy WRITE setSubmitPolicy)
public:
- explicit QDataWidgetMapper(QObject *parent = Q_NULLPTR);
+ explicit QDataWidgetMapper(QObject *parent = nullptr);
~QDataWidgetMapper();
void setModel(QAbstractItemModel *model);
diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp
index 2cf76262e6..449850c42e 100644
--- a/src/widgets/itemviews/qdirmodel.cpp
+++ b/src/widgets/itemviews/qdirmodel.cpp
@@ -1309,22 +1309,7 @@ QString QDirModelPrivate::size(const QModelIndex &index) const
// Nautilus - "9 items" (the number of children)
}
- // According to the Si standard KB is 1000 bytes, KiB is 1024
- // but on windows sizes are calulated by dividing by 1024 so we do what they do.
- const quint64 kb = 1024;
- const quint64 mb = 1024 * kb;
- const quint64 gb = 1024 * mb;
- const quint64 tb = 1024 * gb;
- quint64 bytes = n->info.size();
- if (bytes >= tb)
- return QFileSystemModel::tr("%1 TB").arg(QLocale().toString(qreal(bytes) / tb, 'f', 3));
- if (bytes >= gb)
- return QFileSystemModel::tr("%1 GB").arg(QLocale().toString(qreal(bytes) / gb, 'f', 2));
- if (bytes >= mb)
- return QFileSystemModel::tr("%1 MB").arg(QLocale().toString(qreal(bytes) / mb, 'f', 1));
- if (bytes >= kb)
- return QFileSystemModel::tr("%1 KB").arg(QLocale().toString(bytes / kb));
- return QFileSystemModel::tr("%1 byte(s)").arg(QLocale().toString(bytes));
+ return QLocale::system().formattedDataSize(n->info.size());
}
QString QDirModelPrivate::type(const QModelIndex &index) const
diff --git a/src/widgets/itemviews/qdirmodel.h b/src/widgets/itemviews/qdirmodel.h
index 30810cf4f6..ab91bbd763 100644
--- a/src/widgets/itemviews/qdirmodel.h
+++ b/src/widgets/itemviews/qdirmodel.h
@@ -66,31 +66,31 @@ public:
};
QDirModel(const QStringList &nameFilters, QDir::Filters filters,
- QDir::SortFlags sort, QObject *parent = Q_NULLPTR);
- explicit QDirModel(QObject *parent = Q_NULLPTR);
+ QDir::SortFlags sort, QObject *parent = nullptr);
+ explicit QDirModel(QObject *parent = nullptr);
~QDirModel();
- QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
- QModelIndex parent(const QModelIndex &child) const Q_DECL_OVERRIDE;
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
+ QModelIndex parent(const QModelIndex &child) const override;
- int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
- int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
- bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) Q_DECL_OVERRIDE;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
- QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
- bool hasChildren(const QModelIndex &index = QModelIndex()) const Q_DECL_OVERRIDE;
- Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE;
+ bool hasChildren(const QModelIndex &index = QModelIndex()) const override;
+ Qt::ItemFlags flags(const QModelIndex &index) const override;
- void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) Q_DECL_OVERRIDE;
+ void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
- QStringList mimeTypes() const Q_DECL_OVERRIDE;
- QMimeData *mimeData(const QModelIndexList &indexes) const Q_DECL_OVERRIDE;
+ QStringList mimeTypes() const override;
+ QMimeData *mimeData(const QModelIndexList &indexes) const override;
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
- int row, int column, const QModelIndex &parent) Q_DECL_OVERRIDE;
- Qt::DropActions supportedDropActions() const Q_DECL_OVERRIDE;
+ int row, int column, const QModelIndex &parent) override;
+ Qt::DropActions supportedDropActions() const override;
// QDirModel specific API
@@ -133,7 +133,7 @@ public Q_SLOTS:
void refresh(const QModelIndex &parent = QModelIndex());
protected:
- QDirModel(QDirModelPrivate &, QObject *parent = Q_NULLPTR);
+ QDirModel(QDirModelPrivate &, QObject *parent = nullptr);
friend class QFileDialogPrivate;
private:
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index e1aec3f4bd..c90a61d4ff 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -361,7 +361,9 @@ void QHeaderView::setModel(QAbstractItemModel *model)
QObject::disconnect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)),
this, SLOT(_q_sectionsRemoved(QModelIndex,int,int)));
QObject::disconnect(d->model, SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
- this, SLOT(_q_layoutAboutToBeChanged()));
+ this, SLOT(_q_sectionsAboutToBeChanged()));
+ QObject::disconnect(d->model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
+ this, SLOT(_q_sectionsChanged()));
} else {
QObject::disconnect(d->model, SIGNAL(rowsInserted(QModelIndex,int,int)),
this, SLOT(sectionsInserted(QModelIndex,int,int)));
@@ -370,12 +372,16 @@ void QHeaderView::setModel(QAbstractItemModel *model)
QObject::disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
this, SLOT(_q_sectionsRemoved(QModelIndex,int,int)));
QObject::disconnect(d->model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
- this, SLOT(_q_layoutAboutToBeChanged()));
+ this, SLOT(_q_sectionsAboutToBeChanged()));
+ QObject::disconnect(d->model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+ this, SLOT(_q_sectionsChanged()));
}
QObject::disconnect(d->model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
this, SLOT(headerDataChanged(Qt::Orientation,int,int)));
QObject::disconnect(d->model, SIGNAL(layoutAboutToBeChanged()),
- this, SLOT(_q_layoutAboutToBeChanged()));
+ this, SLOT(_q_sectionsAboutToBeChanged()));
+ QObject::disconnect(d->model, SIGNAL(layoutChanged()),
+ this, SLOT(_q_sectionsChanged()));
}
if (model && model != QAbstractItemModelPrivate::staticEmptyModel()) {
@@ -387,7 +393,9 @@ void QHeaderView::setModel(QAbstractItemModel *model)
QObject::connect(model, SIGNAL(columnsRemoved(QModelIndex,int,int)),
this, SLOT(_q_sectionsRemoved(QModelIndex,int,int)));
QObject::connect(model, SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
- this, SLOT(_q_layoutAboutToBeChanged()));
+ this, SLOT(_q_sectionsAboutToBeChanged()));
+ QObject::connect(model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
+ this, SLOT(_q_sectionsChanged()));
} else {
QObject::connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)),
this, SLOT(sectionsInserted(QModelIndex,int,int)));
@@ -396,12 +404,16 @@ void QHeaderView::setModel(QAbstractItemModel *model)
QObject::connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
this, SLOT(_q_sectionsRemoved(QModelIndex,int,int)));
QObject::connect(model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
- this, SLOT(_q_layoutAboutToBeChanged()));
+ this, SLOT(_q_sectionsAboutToBeChanged()));
+ QObject::connect(model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
+ this, SLOT(_q_sectionsChanged()));
}
QObject::connect(model, SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
this, SLOT(headerDataChanged(Qt::Orientation,int,int)));
QObject::connect(model, SIGNAL(layoutAboutToBeChanged()),
- this, SLOT(_q_layoutAboutToBeChanged()));
+ this, SLOT(_q_sectionsAboutToBeChanged()));
+ QObject::connect(model, SIGNAL(layoutChanged()),
+ this, SLOT(_q_sectionsChanged()));
}
d->state = QHeaderViewPrivate::NoClear;
@@ -608,7 +620,7 @@ int QHeaderView::visualIndexAt(int position) const
return -1;
if (d->reverse())
- vposition = d->viewport->width() - vposition;
+ vposition = d->viewport->width() - vposition - 1;
vposition += d->offset;
if (vposition > d->length)
@@ -874,6 +886,10 @@ void QHeaderView::resizeSection(int logical, int size)
if (logical < 0 || logical >= count() || size < 0 || size > maxSizeSection)
return;
+ // make sure to not exceed bounds when setting size programmatically
+ if (size > 0)
+ size = qBound(minimumSectionSize(), size, maximumSectionSize());
+
if (isSectionHidden(logical)) {
d->hiddenSectionSize.insert(logical, size);
return;
@@ -1103,10 +1119,15 @@ int QHeaderView::logicalIndex(int visualIndex) const
/*!
\since 5.0
- If \a movable is true, the header may be moved by the user; otherwise it
- is fixed in place.
+ If \a movable is true, the header sections may be moved by the user;
+ otherwise they are fixed in place.
+
+ When used in combination with QTreeView, the first column is not
+ movable (since it contains the tree structure), by default.
+ You can make it movable with setFirstSectionMovable(true).
\sa sectionsMovable(), sectionMoved()
+ \sa setFirstSectionMovable()
*/
void QHeaderView::setSectionsMovable(bool movable)
@@ -1131,6 +1152,9 @@ void QHeaderView::setSectionsMovable(bool movable)
Returns \c true if the header can be moved by the user; otherwise returns
false.
+ By default, sections are movable in QTreeView (except for the first one),
+ and not movable in QTableView.
+
\sa setSectionsMovable()
*/
@@ -1151,6 +1175,39 @@ bool QHeaderView::sectionsMovable() const
*/
/*!
+ \since 5.10
+
+ If \a movable is true, the first column can be moved by the user.
+ In a QTreeView, the first column holds the tree structure and is
+ therefore non-movable by default, even after setSectionsMovable(true).
+
+ It can be made movable again, for instance in the case of flat lists
+ without a tree structure, by calling this method.
+ In such a scenario, it is recommended to call QTreeView::setRootIsDecorated(false)
+ as well.
+
+ This method has no effect unless setSectionsMovable(true) is called as well.
+ \sa setSectionsMovable()
+*/
+void QHeaderView::setFirstSectionMovable(bool movable)
+{
+ Q_D(QHeaderView);
+ d->allowUserMoveOfSection0 = movable;
+}
+
+/*!
+ \since 5.10
+
+ Returns \c true if the first column can be moved by the user,
+ when this header is used in a QTreeView.
+*/
+bool QHeaderView::firstSectionMovable() const
+{
+ Q_D(const QHeaderView);
+ return d->allowUserMoveOfSection0;
+}
+
+/*!
\since 5.0
If \a clickable is true, the header will respond to single clicks.
@@ -1608,9 +1665,25 @@ void QHeaderView::setMinimumSectionSize(int size)
Q_D(QHeaderView);
if (size < -1 || size > maxSizeSection)
return;
+ // larger new min size - check current section sizes
+ const bool needSizeCheck = size > d->minimumSectionSize;
d->minimumSectionSize = size;
if (d->minimumSectionSize > maximumSectionSize())
- d->maximumSectionSize = size;
+ setMaximumSectionSize(size);
+
+ if (needSizeCheck) {
+ if (d->hasAutoResizeSections()) {
+ d->doDelayedResizeSections();
+ } else {
+ for (int visual = 0; visual < d->sectionCount(); ++visual) {
+ if (d->isVisualIndexHidden(visual))
+ continue;
+ if (d->headerSectionSize(visual) < d->minimumSectionSize)
+ resizeSection(logicalIndex(visual), size);
+ }
+ }
+ }
+
}
/*!
@@ -1647,7 +1720,22 @@ void QHeaderView::setMaximumSectionSize(int size)
if (minimumSectionSize() > size)
d->minimumSectionSize = size;
+ // smaller new max size - check current section sizes
+ const bool needSizeCheck = size < d->maximumSectionSize;
d->maximumSectionSize = size;
+
+ if (needSizeCheck) {
+ if (d->hasAutoResizeSections()) {
+ d->doDelayedResizeSections();
+ } else {
+ for (int visual = 0; visual < d->sectionCount(); ++visual) {
+ if (d->isVisualIndexHidden(visual))
+ continue;
+ if (d->headerSectionSize(visual) > d->maximumSectionSize)
+ resizeSection(logicalIndex(visual), size);
+ }
+ }
+ }
}
@@ -2062,7 +2150,7 @@ void QHeaderViewPrivate::_q_sectionsRemoved(const QModelIndex &parent,
viewport->update();
}
-void QHeaderViewPrivate::_q_layoutAboutToBeChanged()
+void QHeaderViewPrivate::_q_sectionsAboutToBeChanged()
{
//if there is no row/column we can't have mapping for columns
//because no QModelIndex in the model would be valid
@@ -2096,7 +2184,7 @@ void QHeaderViewPrivate::_q_layoutAboutToBeChanged()
}
}
-void QHeaderViewPrivate::_q_layoutChanged()
+void QHeaderViewPrivate::_q_sectionsChanged()
{
Q_Q(QHeaderView);
viewport->update();
@@ -2565,8 +2653,20 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e)
if (handle != -1 && (sectionResizeMode(handle) == Interactive)) {
if (!hasCursor)
setCursor(d->orientation == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor);
- } else if (hasCursor) {
- unsetCursor();
+ } else {
+ if (hasCursor)
+ unsetCursor();
+#ifndef QT_NO_STATUSTIP
+ int logical = logicalIndexAt(pos);
+ QString statusTip;
+ if (logical != -1)
+ statusTip = d->model->headerData(logical, d->orientation, Qt::StatusTipRole).toString();
+ if (d->shouldClearStatusTip || !statusTip.isEmpty()) {
+ QStatusTipEvent tip(statusTip);
+ QCoreApplication::sendEvent(d->parent, &tip);
+ d->shouldClearStatusTip = !statusTip.isEmpty();
+ }
+#endif // !QT_NO_STATUSTIP
}
#endif
return;
@@ -2794,14 +2894,18 @@ void QHeaderView::paintSection(QPainter *painter, const QRect &rect, int logical
if (isSortIndicatorShown() && sortIndicatorSection() == logicalIndex && isHeaderArrowOnTheSide)
margin += style()->pixelMetric(QStyle::PM_HeaderMarkSize, 0, this);
- if (d->textElideMode != Qt::ElideNone)
- opt.text = opt.fontMetrics.elidedText(opt.text, d->textElideMode , rect.width() - margin);
-
- QVariant variant = d->model->headerData(logicalIndex, d->orientation,
- Qt::DecorationRole);
+ const QVariant variant = d->model->headerData(logicalIndex, d->orientation,
+ Qt::DecorationRole);
opt.icon = qvariant_cast<QIcon>(variant);
if (opt.icon.isNull())
opt.icon = qvariant_cast<QPixmap>(variant);
+ if (!opt.icon.isNull()) // see CT_HeaderSection
+ margin += style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this) +
+ style()->pixelMetric(QStyle::PM_HeaderMargin, 0, this);
+
+ if (d->textElideMode != Qt::ElideNone)
+ opt.text = opt.fontMetrics.elidedText(opt.text, d->textElideMode , rect.width() - margin);
+
QVariant foregroundBrush = d->model->headerData(logicalIndex, d->orientation,
Qt::ForegroundRole);
if (foregroundBrush.canConvert<QBrush>())
@@ -3412,9 +3516,11 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool
int logicalIndex = q->logicalIndex(i);
sectionSize = qMax(viewSectionSizeHint(logicalIndex),
q->sectionSizeHint(logicalIndex));
- if (sectionSize > q->maximumSectionSize())
- sectionSize = q->maximumSectionSize();
}
+ sectionSize = qBound(q->minimumSectionSize(),
+ sectionSize,
+ q->maximumSectionSize());
+
section_sizes.append(sectionSize);
lengthToStretch -= sectionSize;
}
diff --git a/src/widgets/itemviews/qheaderview.h b/src/widgets/itemviews/qheaderview.h
index ec4500d81e..cfe2d24453 100644
--- a/src/widgets/itemviews/qheaderview.h
+++ b/src/widgets/itemviews/qheaderview.h
@@ -74,16 +74,16 @@ public:
};
Q_ENUM(ResizeMode)
- explicit QHeaderView(Qt::Orientation orientation, QWidget *parent = Q_NULLPTR);
+ explicit QHeaderView(Qt::Orientation orientation, QWidget *parent = nullptr);
virtual ~QHeaderView();
- void setModel(QAbstractItemModel *model) Q_DECL_OVERRIDE;
+ void setModel(QAbstractItemModel *model) override;
Qt::Orientation orientation() const;
int offset() const;
int length() const;
- QSize sizeHint() const Q_DECL_OVERRIDE;
- void setVisible(bool v) Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ void setVisible(bool v) override;
int sectionSizeHint(int logicalIndex) const;
int visualIndexAt(int position) const;
@@ -118,6 +118,8 @@ public:
inline QT_DEPRECATED void setMovable(bool movable) { setSectionsMovable(movable); }
inline QT_DEPRECATED bool isMovable() const { return sectionsMovable(); }
#endif
+ void setFirstSectionMovable(bool movable);
+ bool firstSectionMovable() const;
void setSectionsClickable(bool clickable);
bool sectionsClickable() const;
@@ -172,7 +174,7 @@ public:
Qt::Alignment defaultAlignment() const;
void setDefaultAlignment(Qt::Alignment alignment);
- void doItemsLayout() Q_DECL_OVERRIDE;
+ void doItemsLayout() override;
bool sectionsMoved() const;
bool sectionsHidden() const;
@@ -181,7 +183,7 @@ public:
bool restoreState(const QByteArray &state);
#endif
- void reset() Q_DECL_OVERRIDE;
+ void reset() override;
public Q_SLOTS:
void setOffset(int offset);
@@ -208,41 +210,41 @@ protected Q_SLOTS:
void sectionsAboutToBeRemoved(const QModelIndex &parent, int logicalFirst, int logicalLast);
protected:
- QHeaderView(QHeaderViewPrivate &dd, Qt::Orientation orientation, QWidget *parent = Q_NULLPTR);
+ QHeaderView(QHeaderViewPrivate &dd, Qt::Orientation orientation, QWidget *parent = nullptr);
void initialize();
void initializeSections();
void initializeSections(int start, int end);
- void currentChanged(const QModelIndex &current, const QModelIndex &old) Q_DECL_OVERRIDE;
+ void currentChanged(const QModelIndex &current, const QModelIndex &old) override;
- bool event(QEvent *e) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- void mouseDoubleClickEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- bool viewportEvent(QEvent *e) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
+ void paintEvent(QPaintEvent *e) override;
+ void mousePressEvent(QMouseEvent *e) override;
+ void mouseMoveEvent(QMouseEvent *e) override;
+ void mouseReleaseEvent(QMouseEvent *e) override;
+ void mouseDoubleClickEvent(QMouseEvent *e) override;
+ bool viewportEvent(QEvent *e) override;
virtual void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const;
virtual QSize sectionSizeFromContents(int logicalIndex) const;
- int horizontalOffset() const Q_DECL_OVERRIDE;
- int verticalOffset() const Q_DECL_OVERRIDE;
- void updateGeometries() Q_DECL_OVERRIDE;
- void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE;
+ int horizontalOffset() const override;
+ int verticalOffset() const override;
+ void updateGeometries() override;
+ void scrollContentsBy(int dx, int dy) override;
- void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>()) Q_DECL_OVERRIDE;
- void rowsInserted(const QModelIndex &parent, int start, int end) Q_DECL_OVERRIDE;
+ void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>()) override;
+ void rowsInserted(const QModelIndex &parent, int start, int end) override;
- QRect visualRect(const QModelIndex &index) const Q_DECL_OVERRIDE;
- void scrollTo(const QModelIndex &index, ScrollHint hint) Q_DECL_OVERRIDE;
+ QRect visualRect(const QModelIndex &index) const override;
+ void scrollTo(const QModelIndex &index, ScrollHint hint) override;
- QModelIndex indexAt(const QPoint &p) const Q_DECL_OVERRIDE;
- bool isIndexHidden(const QModelIndex &index) const Q_DECL_OVERRIDE;
+ QModelIndex indexAt(const QPoint &p) const override;
+ bool isIndexHidden(const QModelIndex &index) const override;
- QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers) Q_DECL_OVERRIDE;
- void setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags flags) Q_DECL_OVERRIDE;
- QRegion visualRegionForSelection(const QItemSelection &selection) const Q_DECL_OVERRIDE;
+ QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers) override;
+ void setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags flags) override;
+ QRegion visualRegionForSelection(const QItemSelection &selection) const override;
void initStyleOption(QStyleOptionHeader *option) const;
friend class QTableView;
@@ -250,7 +252,8 @@ protected:
private:
Q_PRIVATE_SLOT(d_func(), void _q_sectionsRemoved(const QModelIndex &parent, int logicalFirst, int logicalLast))
- Q_PRIVATE_SLOT(d_func(), void _q_layoutAboutToBeChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_sectionsAboutToBeChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_sectionsChanged())
Q_DECLARE_PRIVATE(QHeaderView)
Q_DISABLE_COPY(QHeaderView)
};
diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h
index c9c2cf8493..24dc3bf075 100644
--- a/src/widgets/itemviews/qheaderview_p.h
+++ b/src/widgets/itemviews/qheaderview_p.h
@@ -120,8 +120,8 @@ public:
void updateHiddenSections(int logicalFirst, int logicalLast);
void resizeSections(QHeaderView::ResizeMode globalMode, bool useGlobalMode = false);
void _q_sectionsRemoved(const QModelIndex &,int,int);
- void _q_layoutAboutToBeChanged();
- void _q_layoutChanged() override;
+ void _q_sectionsAboutToBeChanged();
+ void _q_sectionsChanged();
bool isSectionSelected(int section) const;
bool isFirstVisibleSection(int section) const;
@@ -242,10 +242,6 @@ public:
}
}
- inline void setAllowUserMoveOfSection0(bool b) {
- allowUserMoveOfSection0 = b;
- }
-
void clear();
void flipSortIndicator(int section);
void cascadingResize(int visual, int newSize);
diff --git a/src/widgets/itemviews/qitemdelegate.cpp b/src/widgets/itemviews/qitemdelegate.cpp
index 68c02e9edb..91122283a4 100644
--- a/src/widgets/itemviews/qitemdelegate.cpp
+++ b/src/widgets/itemviews/qitemdelegate.cpp
@@ -94,10 +94,7 @@ public:
inline static QString replaceNewLine(QString text)
{
- const QChar nl = QLatin1Char('\n');
- for (int i = 0; i < text.count(); ++i)
- if (text.at(i) == nl)
- text[i] = QChar::LineSeparator;
+ text.replace(QLatin1Char('\n'), QChar::LineSeparator);
return text;
}
@@ -806,11 +803,14 @@ void QItemDelegate::doLayout(const QStyleOptionViewItem &option,
const bool hasCheck = checkRect->isValid();
const bool hasPixmap = pixmapRect->isValid();
const bool hasText = textRect->isValid();
- const int textMargin = hasText ? style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1 : 0;
- const int pixmapMargin = hasPixmap ? style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1 : 0;
- const int checkMargin = hasCheck ? style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1 : 0;
- int x = option.rect.left();
- int y = option.rect.top();
+ const bool hasMargin = (hasText | hasPixmap | hasCheck);
+ const int frameHMargin = hasMargin ?
+ style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1 : 0;
+ const int textMargin = hasText ? frameHMargin : 0;
+ const int pixmapMargin = hasPixmap ? frameHMargin : 0;
+ const int checkMargin = hasCheck ? frameHMargin : 0;
+ const int x = option.rect.left();
+ const int y = option.rect.top();
int w, h;
textRect->adjust(-textMargin, 0, textMargin, 0); // add width padding
@@ -845,7 +845,7 @@ void QItemDelegate::doLayout(const QStyleOptionViewItem &option,
if (option.direction == Qt::RightToLeft) {
check.setRect(x + w - cw, y, cw, h);
} else {
- check.setRect(x + checkMargin, y, cw, h);
+ check.setRect(x, y, cw, h);
}
}
@@ -988,7 +988,7 @@ QPixmap *QItemDelegate::selected(const QPixmap &pixmap, const QPalette &palette,
painter.end();
QPixmap selected = QPixmap(QPixmap::fromImage(img));
- int n = (img.byteCount() >> 10) + 1;
+ int n = (img.sizeInBytes() >> 10) + 1;
if (QPixmapCache::cacheLimit() < n)
QPixmapCache::setCacheLimit(n);
@@ -1090,7 +1090,7 @@ QRect QItemDelegate::textRectangle(QPainter * /*painter*/, const QRect &rect,
\endlist
In the case of \uicontrol Tab, \uicontrol Backtab, \uicontrol Enter and \uicontrol Return
- key press events, the \a editor's data is comitted to the model
+ key press events, the \a editor's data is committed to the model
and the editor is closed. If the \a event is a \uicontrol Tab key press
the view will open an editor on the next item in the
view. Likewise, if the \a event is a \uicontrol Backtab key press the
diff --git a/src/widgets/itemviews/qitemdelegate.h b/src/widgets/itemviews/qitemdelegate.h
index 21594327ef..539dec4374 100644
--- a/src/widgets/itemviews/qitemdelegate.h
+++ b/src/widgets/itemviews/qitemdelegate.h
@@ -59,7 +59,7 @@ class Q_WIDGETS_EXPORT QItemDelegate : public QAbstractItemDelegate
Q_PROPERTY(bool clipping READ hasClipping WRITE setClipping)
public:
- explicit QItemDelegate(QObject *parent = Q_NULLPTR);
+ explicit QItemDelegate(QObject *parent = nullptr);
~QItemDelegate();
bool hasClipping() const;
@@ -68,21 +68,21 @@ public:
// painting
void paint(QPainter *painter,
const QStyleOptionViewItem &option,
- const QModelIndex &index) const Q_DECL_OVERRIDE;
+ const QModelIndex &index) const override;
QSize sizeHint(const QStyleOptionViewItem &option,
- const QModelIndex &index) const Q_DECL_OVERRIDE;
+ const QModelIndex &index) const override;
// editing
QWidget *createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
- const QModelIndex &index) const Q_DECL_OVERRIDE;
+ const QModelIndex &index) const override;
- void setEditorData(QWidget *editor, const QModelIndex &index) const Q_DECL_OVERRIDE;
- void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const Q_DECL_OVERRIDE;
+ void setEditorData(QWidget *editor, const QModelIndex &index) const override;
+ void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
void updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option,
- const QModelIndex &index) const Q_DECL_OVERRIDE;
+ const QModelIndex &index) const override;
// editor factory
QItemEditorFactory *itemEditorFactory() const;
@@ -105,9 +105,9 @@ protected:
QRect rect(const QStyleOptionViewItem &option, const QModelIndex &index, int role) const;
- bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
+ bool eventFilter(QObject *object, QEvent *event) override;
bool editorEvent(QEvent *event, QAbstractItemModel *model,
- const QStyleOptionViewItem &option, const QModelIndex &index) Q_DECL_OVERRIDE;
+ const QStyleOptionViewItem &option, const QModelIndex &index) override;
QStyleOptionViewItem setOptions(const QModelIndex &index,
const QStyleOptionViewItem &option) const;
diff --git a/src/widgets/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp
index b580f0e840..0986da9707 100644
--- a/src/widgets/itemviews/qitemeditorfactory.cpp
+++ b/src/widgets/itemviews/qitemeditorfactory.cpp
@@ -233,8 +233,8 @@ class QDefaultItemEditorFactory : public QItemEditorFactory
{
public:
inline QDefaultItemEditorFactory() {}
- QWidget *createEditor(int userType, QWidget *parent) const Q_DECL_OVERRIDE;
- QByteArray valuePropertyName(int) const Q_DECL_OVERRIDE;
+ QWidget *createEditor(int userType, QWidget *parent) const override;
+ QByteArray valuePropertyName(int) const override;
};
QWidget *QDefaultItemEditorFactory::createEditor(int userType, QWidget *parent) const
@@ -468,7 +468,7 @@ QItemEditorCreatorBase::~QItemEditorCreatorBase()
*/
/*!
- \fn QItemEditorCreator::QItemEditorCreator(const QByteArray &valuePropertyName)
+ \fn template <class T> QItemEditorCreator<T>::QItemEditorCreator(const QByteArray &valuePropertyName)
Constructs an editor creator object using \a valuePropertyName
as the name of the property to be used for editing. The
@@ -480,12 +480,12 @@ QItemEditorCreatorBase::~QItemEditorCreatorBase()
*/
/*!
- \fn QWidget *QItemEditorCreator::createWidget(QWidget *parent) const
+ \fn template <class T> QWidget *QItemEditorCreator<T>::createWidget(QWidget *parent) const
\reimp
*/
/*!
- \fn QByteArray QItemEditorCreator::valuePropertyName() const
+ \fn template <class T> QByteArray QItemEditorCreator<T>::valuePropertyName() const
\reimp
*/
@@ -524,18 +524,18 @@ QItemEditorCreatorBase::~QItemEditorCreatorBase()
*/
/*!
- \fn QStandardItemEditorCreator::QStandardItemEditorCreator()
+ \fn template <class T> QStandardItemEditorCreator<T>::QStandardItemEditorCreator()
Constructs an editor creator object.
*/
/*!
- \fn QWidget *QStandardItemEditorCreator::createWidget(QWidget *parent) const
+ \fn template <class T> QWidget *QStandardItemEditorCreator<T>::createWidget(QWidget *parent) const
\reimp
*/
/*!
- \fn QByteArray QStandardItemEditorCreator::valuePropertyName() const
+ \fn template <class T> QByteArray QStandardItemEditorCreator<T>::valuePropertyName() const
\reimp
*/
@@ -587,7 +587,7 @@ void QExpandingLineEdit::resizeToContents()
originalWidth = oldWidth;
if (QWidget *parent = parentWidget()) {
QPoint position = pos();
- int hintWidth = minimumWidth() + fontMetrics().width(displayText());
+ int hintWidth = minimumWidth() + fontMetrics().horizontalAdvance(displayText());
int parentWidth = parent->width();
int maxWidth = isRightToLeft() ? position.x() + oldWidth : parentWidth - position.x();
int newWidth = qBound(originalWidth, hintWidth, maxWidth);
diff --git a/src/widgets/itemviews/qitemeditorfactory_p.h b/src/widgets/itemviews/qitemeditorfactory_p.h
index 46a8da1d8f..e78f42b729 100644
--- a/src/widgets/itemviews/qitemeditorfactory_p.h
+++ b/src/widgets/itemviews/qitemeditorfactory_p.h
@@ -74,7 +74,7 @@ public:
}
protected:
- void changeEvent(QEvent *e) Q_DECL_OVERRIDE;
+ void changeEvent(QEvent *e) override;
public Q_SLOTS:
void resizeToContents();
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
index 9217fec10e..6777b09043 100644
--- a/src/widgets/itemviews/qlistview.cpp
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -657,8 +657,7 @@ QItemViewPaintPairs QListViewPrivate::draggablePaintPairs(const QModelIndexList
for (const auto &index : indexes) {
if (std::binary_search(visibleIndexes.cbegin(), visibleIndexes.cend(), index)) {
const QRect current = q->visualRect(index);
- QItemViewPaintPair p = { current, index };
- ret += p;
+ ret.append({current, index});
rect |= current;
}
}
@@ -981,9 +980,18 @@ void QListView::paintEvent(QPaintEvent *e)
? qMax(viewport()->size().width(), d->contentsSize().width()) - 2 * d->spacing()
: qMax(viewport()->size().height(), d->contentsSize().height()) - 2 * d->spacing();
+ const int rowCount = d->commonListView->rowCount();
QVector<QModelIndex>::const_iterator end = toBeRendered.constEnd();
for (QVector<QModelIndex>::const_iterator it = toBeRendered.constBegin(); it != end; ++it) {
Q_ASSERT((*it).isValid());
+ if (rowCount == 1)
+ option.viewItemPosition = QStyleOptionViewItem::OnlyOne;
+ else if ((*it).row() == 0)
+ option.viewItemPosition = QStyleOptionViewItem::Beginning;
+ else if ((*it).row() == rowCount - 1)
+ option.viewItemPosition = QStyleOptionViewItem::End;
+ else
+ option.viewItemPosition = QStyleOptionViewItem::Middle;
option.rect = visualRect(*it);
if (flow() == TopToBottom)
diff --git a/src/widgets/itemviews/qlistview.h b/src/widgets/itemviews/qlistview.h
index 66ec9b18b1..2da510facf 100644
--- a/src/widgets/itemviews/qlistview.h
+++ b/src/widgets/itemviews/qlistview.h
@@ -78,7 +78,7 @@ public:
enum ViewMode { ListMode, IconMode };
Q_ENUM(ViewMode)
- explicit QListView(QWidget *parent = Q_NULLPTR);
+ explicit QListView(QWidget *parent = nullptr);
~QListView();
void setMovement(Movement movement);
@@ -125,67 +125,67 @@ public:
void setSelectionRectVisible(bool show);
bool isSelectionRectVisible() const;
- QRect visualRect(const QModelIndex &index) const Q_DECL_OVERRIDE;
- void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) Q_DECL_OVERRIDE;
- QModelIndex indexAt(const QPoint &p) const Q_DECL_OVERRIDE;
+ QRect visualRect(const QModelIndex &index) const override;
+ void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) override;
+ QModelIndex indexAt(const QPoint &p) const override;
- void doItemsLayout() Q_DECL_OVERRIDE;
- void reset() Q_DECL_OVERRIDE;
- void setRootIndex(const QModelIndex &index) Q_DECL_OVERRIDE;
+ void doItemsLayout() override;
+ void reset() override;
+ void setRootIndex(const QModelIndex &index) override;
Q_SIGNALS:
void indexesMoved(const QModelIndexList &indexes);
protected:
- QListView(QListViewPrivate &, QWidget *parent = Q_NULLPTR);
+ QListView(QListViewPrivate &, QWidget *parent = nullptr);
- bool event(QEvent *e) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
- void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE;
+ void scrollContentsBy(int dx, int dy) override;
void resizeContents(int width, int height);
QSize contentsSize() const;
- void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>()) Q_DECL_OVERRIDE;
- void rowsInserted(const QModelIndex &parent, int start, int end) Q_DECL_OVERRIDE;
- void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) Q_DECL_OVERRIDE;
+ void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>()) override;
+ void rowsInserted(const QModelIndex &parent, int start, int end) override;
+ void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override;
- void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
+ void mouseMoveEvent(QMouseEvent *e) override;
+ void mouseReleaseEvent(QMouseEvent *e) override;
#if QT_CONFIG(wheelevent)
- void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE;
+ void wheelEvent(QWheelEvent *e) override;
#endif
- void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
+ void timerEvent(QTimerEvent *e) override;
+ void resizeEvent(QResizeEvent *e) override;
#ifndef QT_NO_DRAGANDDROP
- void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE;
- void dragLeaveEvent(QDragLeaveEvent *e) Q_DECL_OVERRIDE;
- void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE;
- void startDrag(Qt::DropActions supportedActions) Q_DECL_OVERRIDE;
+ void dragMoveEvent(QDragMoveEvent *e) override;
+ void dragLeaveEvent(QDragLeaveEvent *e) override;
+ void dropEvent(QDropEvent *e) override;
+ void startDrag(Qt::DropActions supportedActions) override;
#endif // QT_NO_DRAGANDDROP
- QStyleOptionViewItem viewOptions() const Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
+ QStyleOptionViewItem viewOptions() const override;
+ void paintEvent(QPaintEvent *e) override;
- int horizontalOffset() const Q_DECL_OVERRIDE;
- int verticalOffset() const Q_DECL_OVERRIDE;
- QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE;
+ int horizontalOffset() const override;
+ int verticalOffset() const override;
+ QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
QRect rectForIndex(const QModelIndex &index) const;
void setPositionForIndex(const QPoint &position, const QModelIndex &index);
- void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) Q_DECL_OVERRIDE;
- QRegion visualRegionForSelection(const QItemSelection &selection) const Q_DECL_OVERRIDE;
- QModelIndexList selectedIndexes() const Q_DECL_OVERRIDE;
+ void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) override;
+ QRegion visualRegionForSelection(const QItemSelection &selection) const override;
+ QModelIndexList selectedIndexes() const override;
- void updateGeometries() Q_DECL_OVERRIDE;
+ void updateGeometries() override;
- bool isIndexHidden(const QModelIndex &index) const Q_DECL_OVERRIDE;
+ bool isIndexHidden(const QModelIndex &index) const override;
- void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) Q_DECL_OVERRIDE;
- void currentChanged(const QModelIndex &current, const QModelIndex &previous) Q_DECL_OVERRIDE;
+ void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override;
+ void currentChanged(const QModelIndex &current, const QModelIndex &previous) override;
- QSize viewportSizeHint() const Q_DECL_OVERRIDE;
+ QSize viewportSizeHint() const override;
private:
int visualIndex(const QModelIndex &index) const;
diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp
index 6c4746e086..1fedad80aa 100644
--- a/src/widgets/itemviews/qlistwidget.cpp
+++ b/src/widgets/itemviews/qlistwidget.cpp
@@ -189,8 +189,9 @@ int QListModel::rowCount(const QModelIndex &parent) const
return parent.isValid() ? 0 : items.count();
}
-QModelIndex QListModel::index(QListWidgetItem *item) const
+QModelIndex QListModel::index(const QListWidgetItem *item_) const
{
+ QListWidgetItem *item = const_cast<QListWidgetItem *>(item_);
if (!item || !item->view || static_cast<const QListModel *>(item->view->model()) != this
|| items.isEmpty())
return QModelIndex();
@@ -411,10 +412,10 @@ QList<QListWidgetItem*>::iterator QListModel::sortedInsertionIterator(
return std::lower_bound(begin, end, item, QListModelGreaterThan());
}
-void QListModel::itemChanged(QListWidgetItem *item)
+void QListModel::itemChanged(QListWidgetItem *item, const QVector<int> &roles)
{
- QModelIndex idx = index(item);
- emit dataChanged(idx, idx);
+ const QModelIndex idx = index(item);
+ emit dataChanged(idx, idx, roles);
}
QStringList QListModel::mimeTypes() const
@@ -710,8 +711,12 @@ void QListWidgetItem::setData(int role, const QVariant &value)
}
if (!found)
d->values.append(QWidgetItemData(role, value));
- if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0))
- model->itemChanged(this);
+ if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : nullptr)) {
+ const QVector<int> roles((role == Qt::DisplayRole) ?
+ QVector<int>({Qt::DisplayRole, Qt::EditRole}) :
+ QVector<int>({role}));
+ model->itemChanged(this, roles);
+ }
}
/*!
@@ -953,7 +958,8 @@ QDataStream &operator>>(QDataStream &in, QListWidgetItem &item)
\sa Qt::ItemFlags
*/
-void QListWidgetItem::setFlags(Qt::ItemFlags aflags) {
+void QListWidgetItem::setFlags(Qt::ItemFlags aflags)
+{
itemFlags = aflags;
if (QListModel *model = (view ? qobject_cast<QListModel*>(view->model()) : 0))
model->itemChanged(this);
@@ -1196,7 +1202,7 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
new current item and the item that was previously current.
\sa QListWidgetItem, QListView, QTreeView, {Model/View Programming},
- {Config Dialog Example}
+ {Tab Dialog Example}
*/
/*!
@@ -1619,7 +1625,7 @@ void QListWidget::editItem(QListWidgetItem *item)
Opens an editor for the given \a item. The editor remains open after
editing.
- \sa closePersistentEditor()
+ \sa closePersistentEditor(), isPersistentEditorOpen()
*/
void QListWidget::openPersistentEditor(QListWidgetItem *item)
{
@@ -1631,7 +1637,7 @@ void QListWidget::openPersistentEditor(QListWidgetItem *item)
/*!
Closes the persistent editor for the given \a item.
- \sa openPersistentEditor()
+ \sa openPersistentEditor(), isPersistentEditorOpen()
*/
void QListWidget::closePersistentEditor(QListWidgetItem *item)
{
@@ -1641,6 +1647,20 @@ void QListWidget::closePersistentEditor(QListWidgetItem *item)
}
/*!
+ \since 5.10
+
+ Returns whether a persistent editor is open for item \a item.
+
+ \sa openPersistentEditor(), closePersistentEditor()
+*/
+bool QListWidget::isPersistentEditorOpen(QListWidgetItem *item) const
+{
+ Q_D(const QListWidget);
+ const QModelIndex index = d->listModel()->index(item);
+ return QAbstractItemView::isPersistentEditorOpen(index);
+}
+
+/*!
\since 4.1
Returns the widget displayed in the given \a item.
@@ -1931,14 +1951,28 @@ QList<QListWidgetItem*> QListWidget::items(const QMimeData *data) const
/*!
Returns the QModelIndex associated with the given \a item.
+
+ \note In Qt versions prior to 5.10, this function took a non-\c{const} \a item.
*/
-QModelIndex QListWidget::indexFromItem(QListWidgetItem *item) const
+QModelIndex QListWidget::indexFromItem(const QListWidgetItem *item) const
{
Q_D(const QListWidget);
return d->listModel()->index(item);
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+/*!
+ \internal
+ \obsolete
+ \overload
+*/
+QModelIndex QListWidget::indexFromItem(QListWidgetItem *item) const
+{
+ return indexFromItem(const_cast<const QListWidgetItem *>(item));
+}
+#endif
+
/*!
Returns a pointer to the QListWidgetItem associated with the given \a index.
*/
diff --git a/src/widgets/itemviews/qlistwidget.h b/src/widgets/itemviews/qlistwidget.h
index 8471645fb0..8a31411429 100644
--- a/src/widgets/itemviews/qlistwidget.h
+++ b/src/widgets/itemviews/qlistwidget.h
@@ -61,10 +61,10 @@ class Q_WIDGETS_EXPORT QListWidgetItem
friend class QListWidget;
public:
enum ItemType { Type = 0, UserType = 1000 };
- explicit QListWidgetItem(QListWidget *view = Q_NULLPTR, int type = Type);
- explicit QListWidgetItem(const QString &text, QListWidget *view = Q_NULLPTR, int type = Type);
+ explicit QListWidgetItem(QListWidget *view = nullptr, int type = Type);
+ explicit QListWidgetItem(const QString &text, QListWidget *view = nullptr, int type = Type);
explicit QListWidgetItem(const QIcon &icon, const QString &text,
- QListWidget *view = Q_NULLPTR, int type = Type);
+ QListWidget *view = nullptr, int type = Type);
QListWidgetItem(const QListWidgetItem &other);
virtual ~QListWidgetItem();
@@ -204,10 +204,10 @@ class Q_WIDGETS_EXPORT QListWidget : public QListView
friend class QListWidgetItem;
friend class QListModel;
public:
- explicit QListWidget(QWidget *parent = Q_NULLPTR);
+ explicit QListWidget(QWidget *parent = nullptr);
~QListWidget();
- void setSelectionModel(QItemSelectionModel *selectionModel) Q_DECL_OVERRIDE;
+ void setSelectionModel(QItemSelectionModel *selectionModel) override;
QListWidgetItem *item(int row) const;
int row(const QListWidgetItem *item) const;
@@ -239,6 +239,8 @@ public:
void editItem(QListWidgetItem *item);
void openPersistentEditor(QListWidgetItem *item);
void closePersistentEditor(QListWidgetItem *item);
+ using QAbstractItemView::isPersistentEditorOpen;
+ bool isPersistentEditorOpen(QListWidgetItem *item) const;
QWidget *itemWidget(QListWidgetItem *item) const;
void setItemWidget(QListWidgetItem *item, QWidget *widget);
@@ -251,8 +253,11 @@ public:
bool isItemHidden(const QListWidgetItem *item) const;
void setItemHidden(const QListWidgetItem *item, bool hide);
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+protected:
+#endif
#if QT_CONFIG(draganddrop)
- void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE;
+ void dropEvent(QDropEvent *event) override;
#endif
public Q_SLOTS:
void scrollToItem(const QListWidgetItem *item, QAbstractItemView::ScrollHint hint = EnsureVisible);
@@ -264,6 +269,7 @@ Q_SIGNALS:
void itemDoubleClicked(QListWidgetItem *item);
void itemActivated(QListWidgetItem *item);
void itemEntered(QListWidgetItem *item);
+ // ### Qt 6: add changed roles
void itemChanged(QListWidgetItem *item);
void currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
@@ -273,7 +279,7 @@ Q_SIGNALS:
void itemSelectionChanged();
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
virtual QStringList mimeTypes() const;
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
virtual QMimeData *mimeData(const QList<QListWidgetItem *> &items) const;
@@ -284,13 +290,22 @@ protected:
virtual bool dropMimeData(int index, const QMimeData *data, Qt::DropAction action);
virtual Qt::DropActions supportedDropActions() const;
#endif
+
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+public:
+#else
+protected:
+#endif
QList<QListWidgetItem*> items(const QMimeData *data) const;
- QModelIndex indexFromItem(QListWidgetItem *item) const;
+ QModelIndex indexFromItem(const QListWidgetItem *item) const;
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ QModelIndex indexFromItem(QListWidgetItem *item) const; // ### Qt 6: remove
+#endif
QListWidgetItem *itemFromIndex(const QModelIndex &index) const;
private:
- void setModel(QAbstractItemModel *model) Q_DECL_OVERRIDE;
+ void setModel(QAbstractItemModel *model) override;
Qt::SortOrder sortOrder() const;
Q_DECLARE_PRIVATE(QListWidget)
@@ -308,7 +323,7 @@ private:
};
inline void QListWidget::removeItemWidget(QListWidgetItem *aItem)
-{ setItemWidget(aItem, Q_NULLPTR); }
+{ setItemWidget(aItem, nullptr); }
inline void QListWidget::addItem(QListWidgetItem *aitem)
{ insertItem(count(), aitem); }
diff --git a/src/widgets/itemviews/qlistwidget_p.h b/src/widgets/itemviews/qlistwidget_p.h
index e8f5540f9c..30b5016db6 100644
--- a/src/widgets/itemviews/qlistwidget_p.h
+++ b/src/widgets/itemviews/qlistwidget_p.h
@@ -95,7 +95,7 @@ public:
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
- QModelIndex index(QListWidgetItem *item) const;
+ QModelIndex index(const QListWidgetItem *item) const;
QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
@@ -119,7 +119,7 @@ public:
const QList<QListWidgetItem*>::iterator &end,
Qt::SortOrder order, QListWidgetItem *item);
- void itemChanged(QListWidgetItem *item);
+ void itemChanged(QListWidgetItem *item, const QVector<int> &roles = QVector<int>());
// dnd
QStringList mimeTypes() const override;
diff --git a/src/widgets/itemviews/qstyleditemdelegate.cpp b/src/widgets/itemviews/qstyleditemdelegate.cpp
index 716df2c729..0f7566e8ec 100644
--- a/src/widgets/itemviews/qstyleditemdelegate.cpp
+++ b/src/widgets/itemviews/qstyleditemdelegate.cpp
@@ -514,12 +514,13 @@ void QStyledItemDelegate::updateEditorGeometry(QWidget *editor,
QStyle *style = widget ? widget->style() : QApplication::style();
QRect geom = style->subElementRect(QStyle::SE_ItemViewItemText, &opt, widget);
- if ( editor->layoutDirection() == Qt::RightToLeft) {
- const int delta = qSmartMinSize(editor).width() - geom.width();
- if (delta > 0) {
- //we need to widen the geometry
+ const int delta = qSmartMinSize(editor).width() - geom.width();
+ if (delta > 0) {
+ //we need to widen the geometry
+ if (editor->layoutDirection() == Qt::RightToLeft)
geom.adjust(-delta, 0, 0, 0);
- }
+ else
+ geom.adjust(0, 0, delta, 0);
}
editor->setGeometry(geom);
@@ -570,7 +571,7 @@ void QStyledItemDelegate::setItemEditorFactory(QItemEditorFactory *factory)
\uicontrol Return keys are \e not handled.
In the case of \uicontrol Tab, \uicontrol Backtab, \uicontrol Enter and \uicontrol Return
- key press events, the \a editor's data is comitted to the model
+ key press events, the \a editor's data is committed to the model
and the editor is closed. If the \a event is a \uicontrol Tab key press
the view will open an editor on the next item in the
view. Likewise, if the \a event is a \uicontrol Backtab key press the
diff --git a/src/widgets/itemviews/qstyleditemdelegate.h b/src/widgets/itemviews/qstyleditemdelegate.h
index f3b7c4d1f4..2df2450f07 100644
--- a/src/widgets/itemviews/qstyleditemdelegate.h
+++ b/src/widgets/itemviews/qstyleditemdelegate.h
@@ -58,28 +58,28 @@ class Q_WIDGETS_EXPORT QStyledItemDelegate : public QAbstractItemDelegate
Q_OBJECT
public:
- explicit QStyledItemDelegate(QObject *parent = Q_NULLPTR);
+ explicit QStyledItemDelegate(QObject *parent = nullptr);
~QStyledItemDelegate();
// painting
void paint(QPainter *painter,
- const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE;
+ const QStyleOptionViewItem &option, const QModelIndex &index) const override;
QSize sizeHint(const QStyleOptionViewItem &option,
- const QModelIndex &index) const Q_DECL_OVERRIDE;
+ const QModelIndex &index) const override;
// editing
QWidget *createEditor(QWidget *parent,
const QStyleOptionViewItem &option,
- const QModelIndex &index) const Q_DECL_OVERRIDE;
+ const QModelIndex &index) const override;
- void setEditorData(QWidget *editor, const QModelIndex &index) const Q_DECL_OVERRIDE;
+ void setEditorData(QWidget *editor, const QModelIndex &index) const override;
void setModelData(QWidget *editor,
QAbstractItemModel *model,
- const QModelIndex &index) const Q_DECL_OVERRIDE;
+ const QModelIndex &index) const override;
void updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option,
- const QModelIndex &index) const Q_DECL_OVERRIDE;
+ const QModelIndex &index) const override;
// editor factory
QItemEditorFactory *itemEditorFactory() const;
@@ -91,9 +91,9 @@ protected:
virtual void initStyleOption(QStyleOptionViewItem *option,
const QModelIndex &index) const;
- bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
+ bool eventFilter(QObject *object, QEvent *event) override;
bool editorEvent(QEvent *event, QAbstractItemModel *model,
- const QStyleOptionViewItem &option, const QModelIndex &index) Q_DECL_OVERRIDE;
+ const QStyleOptionViewItem &option, const QModelIndex &index) override;
private:
Q_DECLARE_PRIVATE(QStyledItemDelegate)
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index 8ab811e9f7..ec25ccdb12 100644
--- a/src/widgets/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
@@ -585,7 +585,7 @@ class QTableCornerButton : public QAbstractButton
Q_OBJECT
public:
QTableCornerButton(QWidget *parent) : QAbstractButton(parent) {}
- void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE {
+ void paintEvent(QPaintEvent*) override {
QStyleOptionHeader opt;
opt.init(this);
QStyle::State state = QStyle::State_None;
@@ -971,6 +971,9 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS
option.rect.setHeight(height);
option.rect.setX(q->columnViewportPosition(index.column()));
option.rect.setWidth(q->columnWidth(index.column()));
+ // 1px less space when grid is shown (see drawCell)
+ if (showGrid)
+ option.rect.setWidth(option.rect.width() - 1);
}
hint = qMax(hint, q->itemDelegate(index)->sizeHint(option, index).height());
return hint;
@@ -1226,7 +1229,7 @@ void QTableView::setHorizontalHeader(QHeaderView *header)
delete d->horizontalHeader;
d->horizontalHeader = header;
d->horizontalHeader->setParent(this);
- d->horizontalHeader->d_func()->setAllowUserMoveOfSection0(true);
+ d->horizontalHeader->setFirstSectionMovable(true);
if (!d->horizontalHeader->model()) {
d->horizontalHeader->setModel(d->model);
if (d->selectionModel)
@@ -1264,7 +1267,7 @@ void QTableView::setVerticalHeader(QHeaderView *header)
delete d->verticalHeader;
d->verticalHeader = header;
d->verticalHeader->setParent(this);
- d->verticalHeader->d_func()->setAllowUserMoveOfSection0(true);
+ d->verticalHeader->setFirstSectionMovable(true);
if (!d->verticalHeader->model()) {
d->verticalHeader->setModel(d->model);
if (d->selectionModel)
@@ -1362,8 +1365,8 @@ void QTableView::paintEvent(QPaintEvent *event)
if (horizontalHeader->count() == 0 || verticalHeader->count() == 0 || !d->itemDelegate)
return;
- uint x = horizontalHeader->length() - horizontalHeader->offset() - (rightToLeft ? 0 : 1);
- uint y = verticalHeader->length() - verticalHeader->offset() - 1;
+ const int x = horizontalHeader->length() - horizontalHeader->offset() - (rightToLeft ? 0 : 1);
+ const int y = verticalHeader->length() - verticalHeader->offset() - 1;
//firstVisualRow is the visual index of the first visible row. lastVisualRow is the visual index of the last visible Row.
//same goes for ...VisualColumn
@@ -1415,10 +1418,10 @@ void QTableView::paintEvent(QPaintEvent *event)
int top = 0;
bool alternateBase = false;
if (alternate && verticalHeader->sectionsHidden()) {
- uint verticalOffset = verticalHeader->offset();
+ const int verticalOffset = verticalHeader->offset();
int row = verticalHeader->logicalIndex(top);
for (int y = 0;
- ((uint)(y += verticalHeader->sectionSize(top)) <= verticalOffset) && (top < bottom);
+ ((y += verticalHeader->sectionSize(top)) <= verticalOffset) && (top < bottom);
++top) {
row = verticalHeader->logicalIndex(top);
if (alternate && !verticalHeader->isSectionHidden(row))
@@ -2131,9 +2134,9 @@ void QTableView::updateGeometries()
// ### move this block into the if
QSize vsize = d->viewport->size();
QSize max = maximumViewportSize();
- uint horizontalLength = d->horizontalHeader->length();
- uint verticalLength = d->verticalHeader->length();
- if ((uint)max.width() >= horizontalLength && (uint)max.height() >= verticalLength)
+ const int horizontalLength = d->horizontalHeader->length();
+ const int verticalLength = d->verticalHeader->length();
+ if (max.width() >= horizontalLength && max.height() >= verticalLength)
vsize = max;
// horizontal scroll bar
diff --git a/src/widgets/itemviews/qtableview.h b/src/widgets/itemviews/qtableview.h
index 75f2e7b44c..60c2f34103 100644
--- a/src/widgets/itemviews/qtableview.h
+++ b/src/widgets/itemviews/qtableview.h
@@ -62,13 +62,13 @@ class Q_WIDGETS_EXPORT QTableView : public QAbstractItemView
#endif
public:
- explicit QTableView(QWidget *parent = Q_NULLPTR);
+ explicit QTableView(QWidget *parent = nullptr);
~QTableView();
- void setModel(QAbstractItemModel *model) Q_DECL_OVERRIDE;
- void setRootIndex(const QModelIndex &index) Q_DECL_OVERRIDE;
- void setSelectionModel(QItemSelectionModel *selectionModel) Q_DECL_OVERRIDE;
- void doItemsLayout() Q_DECL_OVERRIDE;
+ void setModel(QAbstractItemModel *model) override;
+ void setRootIndex(const QModelIndex &index) override;
+ void setSelectionModel(QItemSelectionModel *selectionModel) override;
+ void doItemsLayout() override;
QHeaderView *horizontalHeader() const;
QHeaderView *verticalHeader() const;
@@ -109,9 +109,9 @@ public:
bool isCornerButtonEnabled() const;
#endif
- QRect visualRect(const QModelIndex &index) const Q_DECL_OVERRIDE;
- void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) Q_DECL_OVERRIDE;
- QModelIndex indexAt(const QPoint &p) const Q_DECL_OVERRIDE;
+ QRect visualRect(const QModelIndex &index) const override;
+ void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) override;
+ QModelIndex indexAt(const QPoint &p) const override;
void setSpan(int row, int column, int rowSpan, int columnSpan);
int rowSpan(int row, int column) const;
@@ -144,37 +144,37 @@ protected Q_SLOTS:
protected:
QTableView(QTableViewPrivate &, QWidget *parent);
- void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE;
+ void scrollContentsBy(int dx, int dy) override;
- QStyleOptionViewItem viewOptions() const Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
+ QStyleOptionViewItem viewOptions() const override;
+ void paintEvent(QPaintEvent *e) override;
- void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE;
+ void timerEvent(QTimerEvent *event) override;
- int horizontalOffset() const Q_DECL_OVERRIDE;
- int verticalOffset() const Q_DECL_OVERRIDE;
- QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE;
+ int horizontalOffset() const override;
+ int verticalOffset() const override;
+ QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
- void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) Q_DECL_OVERRIDE;
- QRegion visualRegionForSelection(const QItemSelection &selection) const Q_DECL_OVERRIDE;
- QModelIndexList selectedIndexes() const Q_DECL_OVERRIDE;
+ void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) override;
+ QRegion visualRegionForSelection(const QItemSelection &selection) const override;
+ QModelIndexList selectedIndexes() const override;
- void updateGeometries() Q_DECL_OVERRIDE;
+ void updateGeometries() override;
- QSize viewportSizeHint() const Q_DECL_OVERRIDE;
+ QSize viewportSizeHint() const override;
- int sizeHintForRow(int row) const Q_DECL_OVERRIDE;
- int sizeHintForColumn(int column) const Q_DECL_OVERRIDE;
+ int sizeHintForRow(int row) const override;
+ int sizeHintForColumn(int column) const override;
- void verticalScrollbarAction(int action) Q_DECL_OVERRIDE;
- void horizontalScrollbarAction(int action) Q_DECL_OVERRIDE;
+ void verticalScrollbarAction(int action) override;
+ void horizontalScrollbarAction(int action) override;
- bool isIndexHidden(const QModelIndex &index) const Q_DECL_OVERRIDE;
+ bool isIndexHidden(const QModelIndex &index) const override;
void selectionChanged(const QItemSelection &selected,
- const QItemSelection &deselected) Q_DECL_OVERRIDE;
+ const QItemSelection &deselected) override;
void currentChanged(const QModelIndex &current,
- const QModelIndex &previous) Q_DECL_OVERRIDE;
+ const QModelIndex &previous) override;
private:
friend class QAccessibleItemView;
diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp
index d89fdc9000..1cb88cbeeb 100644
--- a/src/widgets/itemviews/qtablewidget.cpp
+++ b/src/widgets/itemviews/qtablewidget.cpp
@@ -2223,7 +2223,7 @@ void QTableWidget::editItem(QTableWidgetItem *item)
/*!
Opens an editor for the give \a item. The editor remains open after editing.
- \sa closePersistentEditor()
+ \sa closePersistentEditor(), isPersistentEditorOpen()
*/
void QTableWidget::openPersistentEditor(QTableWidgetItem *item)
{
@@ -2237,7 +2237,7 @@ void QTableWidget::openPersistentEditor(QTableWidgetItem *item)
/*!
Closes the persistent editor for \a item.
- \sa openPersistentEditor()
+ \sa openPersistentEditor(), isPersistentEditorOpen()
*/
void QTableWidget::closePersistentEditor(QTableWidgetItem *item)
{
@@ -2249,6 +2249,20 @@ void QTableWidget::closePersistentEditor(QTableWidgetItem *item)
}
/*!
+ \since 5.10
+
+ Returns whether a persistent editor is open for item \a item.
+
+ \sa openPersistentEditor(), closePersistentEditor()
+*/
+bool QTableWidget::isPersistentEditorOpen(QTableWidgetItem *item) const
+{
+ Q_D(const QTableWidget);
+ const QModelIndex index = d->tableModel()->index(item);
+ return QAbstractItemView::isPersistentEditorOpen(index);
+}
+
+/*!
\since 4.1
Returns the widget displayed in the cell in the given \a row and \a column.
@@ -2641,14 +2655,28 @@ QList<QTableWidgetItem*> QTableWidget::items(const QMimeData *data) const
/*!
Returns the QModelIndex associated with the given \a item.
+
+ \note In Qt versions prior to 5.10, this function took a non-\c{const} \a item.
*/
-QModelIndex QTableWidget::indexFromItem(QTableWidgetItem *item) const
+QModelIndex QTableWidget::indexFromItem(const QTableWidgetItem *item) const
{
Q_D(const QTableWidget);
return d->tableModel()->index(item);
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+/*!
+ \internal
+ \obsolete
+ \overload
+*/
+QModelIndex QTableWidget::indexFromItem(QTableWidgetItem *item) const
+{
+ return indexFromItem(const_cast<const QTableWidgetItem *>(item));
+}
+#endif
+
/*!
Returns a pointer to the QTableWidgetItem associated with the given \a index.
*/
diff --git a/src/widgets/itemviews/qtablewidget.h b/src/widgets/itemviews/qtablewidget.h
index 3fecf194e4..7322e3aed7 100644
--- a/src/widgets/itemviews/qtablewidget.h
+++ b/src/widgets/itemviews/qtablewidget.h
@@ -219,8 +219,8 @@ class Q_WIDGETS_EXPORT QTableWidget : public QTableView
friend class QTableModel;
public:
- explicit QTableWidget(QWidget *parent = Q_NULLPTR);
- QTableWidget(int rows, int columns, QWidget *parent = Q_NULLPTR);
+ explicit QTableWidget(QWidget *parent = nullptr);
+ QTableWidget(int rows, int columns, QWidget *parent = nullptr);
~QTableWidget();
void setRowCount(int rows);
@@ -261,6 +261,8 @@ public:
void editItem(QTableWidgetItem *item);
void openPersistentEditor(QTableWidgetItem *item);
void closePersistentEditor(QTableWidgetItem *item);
+ using QAbstractItemView::isPersistentEditorOpen;
+ bool isPersistentEditorOpen(QTableWidgetItem *item) const;
QWidget *cellWidget(int row, int column) const;
void setCellWidget(int row, int column, QWidget *widget);
@@ -316,7 +318,7 @@ Q_SIGNALS:
void currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn);
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
virtual QStringList mimeTypes() const;
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
virtual QMimeData *mimeData(const QList<QTableWidgetItem *> &items) const;
@@ -325,15 +327,26 @@ protected:
#endif
virtual bool dropMimeData(int row, int column, const QMimeData *data, Qt::DropAction action);
virtual Qt::DropActions supportedDropActions() const;
+
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+public:
+#else
+protected:
+#endif
QList<QTableWidgetItem*> items(const QMimeData *data) const;
- QModelIndex indexFromItem(QTableWidgetItem *item) const;
+ QModelIndex indexFromItem(const QTableWidgetItem *item) const;
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ QModelIndex indexFromItem(QTableWidgetItem *item) const; // ### Qt 6: remove
+#endif
QTableWidgetItem *itemFromIndex(const QModelIndex &index) const;
+
+protected:
#if QT_CONFIG(draganddrop)
- void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE;
+ void dropEvent(QDropEvent *event) override;
#endif
private:
- void setModel(QAbstractItemModel *model) Q_DECL_OVERRIDE;
+ void setModel(QAbstractItemModel *model) override;
Q_DECLARE_PRIVATE(QTableWidget)
Q_DISABLE_COPY(QTableWidget)
@@ -350,7 +363,7 @@ private:
};
inline void QTableWidget::removeCellWidget(int arow, int acolumn)
-{ setCellWidget(arow, acolumn, Q_NULLPTR); }
+{ setCellWidget(arow, acolumn, nullptr); }
inline QTableWidgetItem *QTableWidget::itemAt(int ax, int ay) const
{ return itemAt(QPoint(ax, ay)); }
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index 8d27305071..ebeefad682 100644
--- a/src/widgets/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
@@ -311,7 +311,7 @@ void QTreeView::setHeader(QHeaderView *header)
delete d->header;
d->header = header;
d->header->setParent(this);
- d->header->d_func()->setAllowUserMoveOfSection0(false);
+ d->header->setFirstSectionMovable(false);
if (!d->header->model()) {
d->header->setModel(d->model);
@@ -3057,7 +3057,7 @@ void QTreeViewPrivate::initialize()
header->setDefaultAlignment(Qt::AlignLeft|Qt::AlignVCenter);
q->setHeader(header);
#ifndef QT_NO_ANIMATION
- animationsEnabled = q->style()->styleHint(QStyle::SH_Widget_Animate, 0, q);
+ animationsEnabled = q->style()->styleHint(QStyle::SH_Widget_Animation_Duration, 0, q) > 0;
QObject::connect(&animatedOperation, SIGNAL(finished()), q, SLOT(_q_endAnimatedOperation()));
#endif //QT_NO_ANIMATION
}
@@ -4006,6 +4006,27 @@ int QTreeView::visualIndex(const QModelIndex &index) const
return d->viewIndex(index);
}
+/*!
+ \internal
+*/
+
+void QTreeView::verticalScrollbarValueChanged(int value)
+{
+ Q_D(QTreeView);
+ if (!d->viewItems.isEmpty() && value == verticalScrollBar()->maximum()) {
+ QModelIndex ret = d->viewItems.last().index;
+ // Root index will be handled by base class implementation
+ while (ret.isValid()) {
+ if (isExpanded(ret) && d->model->canFetchMore(ret)) {
+ d->model->fetchMore(ret);
+ break;
+ }
+ ret = ret.parent();
+ }
+ }
+ QAbstractItemView::verticalScrollbarValueChanged(value);
+}
+
QT_END_NAMESPACE
#include "moc_qtreeview.cpp"
diff --git a/src/widgets/itemviews/qtreeview.h b/src/widgets/itemviews/qtreeview.h
index c32c127cd1..e7ee55aa2a 100644
--- a/src/widgets/itemviews/qtreeview.h
+++ b/src/widgets/itemviews/qtreeview.h
@@ -68,12 +68,12 @@ class Q_WIDGETS_EXPORT QTreeView : public QAbstractItemView
Q_PROPERTY(bool expandsOnDoubleClick READ expandsOnDoubleClick WRITE setExpandsOnDoubleClick)
public:
- explicit QTreeView(QWidget *parent = Q_NULLPTR);
+ explicit QTreeView(QWidget *parent = nullptr);
~QTreeView();
- void setModel(QAbstractItemModel *model) Q_DECL_OVERRIDE;
- void setRootIndex(const QModelIndex &index) Q_DECL_OVERRIDE;
- void setSelectionModel(QItemSelectionModel *selectionModel) Q_DECL_OVERRIDE;
+ void setModel(QAbstractItemModel *model) override;
+ void setRootIndex(const QModelIndex &index) override;
+ void setSelectionModel(QItemSelectionModel *selectionModel) override;
QHeaderView *header() const;
void setHeader(QHeaderView *header);
@@ -132,21 +132,21 @@ public:
void setTreePosition(int logicalIndex);
int treePosition() const;
- void keyboardSearch(const QString &search) Q_DECL_OVERRIDE;
+ void keyboardSearch(const QString &search) override;
- QRect visualRect(const QModelIndex &index) const Q_DECL_OVERRIDE;
- void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) Q_DECL_OVERRIDE;
- QModelIndex indexAt(const QPoint &p) const Q_DECL_OVERRIDE;
+ QRect visualRect(const QModelIndex &index) const override;
+ void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) override;
+ QModelIndex indexAt(const QPoint &p) const override;
QModelIndex indexAbove(const QModelIndex &index) const;
QModelIndex indexBelow(const QModelIndex &index) const;
- void doItemsLayout() Q_DECL_OVERRIDE;
- void reset() Q_DECL_OVERRIDE;
+ void doItemsLayout() override;
+ void reset() override;
void sortByColumn(int column, Qt::SortOrder order);
- void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>()) Q_DECL_OVERRIDE;
- void selectAll() Q_DECL_OVERRIDE;
+ void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles = QVector<int>()) override;
+ void selectAll() override;
Q_SIGNALS:
void expanded(const QModelIndex &index);
@@ -169,23 +169,24 @@ protected Q_SLOTS:
void columnMoved();
void reexpand();
void rowsRemoved(const QModelIndex &parent, int first, int last);
+ void verticalScrollbarValueChanged(int value) override;
protected:
- QTreeView(QTreeViewPrivate &dd, QWidget *parent = Q_NULLPTR);
- void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE;
- void rowsInserted(const QModelIndex &parent, int start, int end) Q_DECL_OVERRIDE;
- void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) Q_DECL_OVERRIDE;
+ QTreeView(QTreeViewPrivate &dd, QWidget *parent = nullptr);
+ void scrollContentsBy(int dx, int dy) override;
+ void rowsInserted(const QModelIndex &parent, int start, int end) override;
+ void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) override;
- QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE;
- int horizontalOffset() const Q_DECL_OVERRIDE;
- int verticalOffset() const Q_DECL_OVERRIDE;
+ QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
+ int horizontalOffset() const override;
+ int verticalOffset() const override;
- void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) Q_DECL_OVERRIDE;
- QRegion visualRegionForSelection(const QItemSelection &selection) const Q_DECL_OVERRIDE;
- QModelIndexList selectedIndexes() const Q_DECL_OVERRIDE;
+ void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) override;
+ QRegion visualRegionForSelection(const QItemSelection &selection) const override;
+ QModelIndexList selectedIndexes() const override;
- void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
+ void timerEvent(QTimerEvent *event) override;
+ void paintEvent(QPaintEvent *event) override;
void drawTree(QPainter *painter, const QRegion &region) const;
virtual void drawRow(QPainter *painter,
@@ -195,30 +196,30 @@ protected:
const QRect &rect,
const QModelIndex &index) const;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
+ void mouseDoubleClickEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void keyPressEvent(QKeyEvent *event) override;
#ifndef QT_NO_DRAGANDDROP
- void dragMoveEvent(QDragMoveEvent *event) Q_DECL_OVERRIDE;
+ void dragMoveEvent(QDragMoveEvent *event) override;
#endif
- bool viewportEvent(QEvent *event) Q_DECL_OVERRIDE;
+ bool viewportEvent(QEvent *event) override;
- void updateGeometries() Q_DECL_OVERRIDE;
+ void updateGeometries() override;
- QSize viewportSizeHint() const Q_DECL_OVERRIDE;
+ QSize viewportSizeHint() const override;
- int sizeHintForColumn(int column) const Q_DECL_OVERRIDE;
+ int sizeHintForColumn(int column) const override;
int indexRowSizeHint(const QModelIndex &index) const;
int rowHeight(const QModelIndex &index) const;
- void horizontalScrollbarAction(int action) Q_DECL_OVERRIDE;
+ void horizontalScrollbarAction(int action) override;
- bool isIndexHidden(const QModelIndex &index) const Q_DECL_OVERRIDE;
+ bool isIndexHidden(const QModelIndex &index) const override;
void selectionChanged(const QItemSelection &selected,
- const QItemSelection &deselected) Q_DECL_OVERRIDE;
- void currentChanged(const QModelIndex &current, const QModelIndex &previous) Q_DECL_OVERRIDE;
+ const QItemSelection &deselected) override;
+ void currentChanged(const QModelIndex &current, const QModelIndex &previous) override;
private:
friend class ::tst_QTreeView;
diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp
index 762a19126e..de7f7c0b77 100644
--- a/src/widgets/itemviews/qtreewidget.cpp
+++ b/src/widgets/itemviews/qtreewidget.cpp
@@ -145,7 +145,7 @@ QTreeModel::QTreeModel(QTreeModelPrivate &dd, QTreeWidget *parent)
QTreeModel::~QTreeModel()
{
clear();
- headerItem->view = Q_NULLPTR;
+ headerItem->view = nullptr;
delete headerItem;
rootItem->view = 0;
delete rootItem;
@@ -2012,6 +2012,9 @@ void QTreeWidgetItem::addChildren(const QList<QTreeWidgetItem*> &children)
*/
void QTreeWidgetItem::insertChildren(int index, const QList<QTreeWidgetItem*> &children)
{
+ if (index < 0 || index > this->children.count() || children.isEmpty())
+ return;
+
if (view && view->isSortingEnabled()) {
for (int n = 0; n < children.count(); ++n)
insertChild(index, children.at(n));
@@ -2729,14 +2732,14 @@ void QTreeWidget::setHeaderItem(QTreeWidgetItem *item)
int oldCount = columnCount();
if (oldCount < item->columnCount())
- d->treeModel()->beginInsertColumns(QModelIndex(), oldCount, item->columnCount());
- else
- d->treeModel()->beginRemoveColumns(QModelIndex(), item->columnCount(), oldCount);
+ d->treeModel()->beginInsertColumns(QModelIndex(), oldCount, item->columnCount() - 1);
+ else if (oldCount > item->columnCount())
+ d->treeModel()->beginRemoveColumns(QModelIndex(), item->columnCount(), oldCount - 1);
delete d->treeModel()->headerItem;
d->treeModel()->headerItem = item;
if (oldCount < item->columnCount())
d->treeModel()->endInsertColumns();
- else
+ else if (oldCount > item->columnCount())
d->treeModel()->endRemoveColumns();
d->treeModel()->headerDataChanged(Qt::Horizontal, 0, oldCount);
}
@@ -2859,11 +2862,11 @@ QRect QTreeWidget::visualItemRect(const QTreeWidgetItem *item) const
Q_D(const QTreeWidget);
//the visual rect for an item is across all columns. So we need to determine
//what is the first and last column and get their visual index rects
- QModelIndex base = d->index(item);
+ const QModelIndex base = d->index(item);
const int firstVisiblesection = header()->logicalIndexAt(- header()->offset());
const int lastVisibleSection = header()->logicalIndexAt(header()->length() - header()->offset() - 1);
- QModelIndex first = base.sibling(base.row(), header()->logicalIndex(firstVisiblesection));
- QModelIndex last = base.sibling(base.row(), header()->logicalIndex(lastVisibleSection));
+ const QModelIndex first = base.sibling(base.row(), firstVisiblesection);
+ const QModelIndex last = base.sibling(base.row(), lastVisibleSection);
return visualRect(first) | visualRect(last);
}
@@ -2909,7 +2912,7 @@ void QTreeWidget::editItem(QTreeWidgetItem *item, int column)
/*!
Opens a persistent editor for the \a item in the given \a column.
- \sa closePersistentEditor()
+ \sa closePersistentEditor(), isPersistentEditorOpen()
*/
void QTreeWidget::openPersistentEditor(QTreeWidgetItem *item, int column)
@@ -2924,7 +2927,7 @@ void QTreeWidget::openPersistentEditor(QTreeWidgetItem *item, int column)
This function has no effect if no persistent editor is open for this
combination of item and column.
- \sa openPersistentEditor()
+ \sa openPersistentEditor(), isPersistentEditorOpen()
*/
void QTreeWidget::closePersistentEditor(QTreeWidgetItem *item, int column)
@@ -2934,6 +2937,21 @@ void QTreeWidget::closePersistentEditor(QTreeWidgetItem *item, int column)
}
/*!
+ \since 5.10
+
+ Returns whether a persistent editor is open for item \a item in
+ column \a column.
+
+ \sa openPersistentEditor(), closePersistentEditor()
+*/
+
+bool QTreeWidget::isPersistentEditorOpen(QTreeWidgetItem *item, int column) const
+{
+ Q_D(const QTreeWidget);
+ return QAbstractItemView::isPersistentEditorOpen(d->index(item, column));
+}
+
+/*!
\since 4.1
Returns the widget displayed in the cell specified by \a item and the given \a column.
@@ -3354,6 +3372,7 @@ QModelIndex QTreeWidget::indexFromItem(const QTreeWidgetItem *item, int column)
return d->index(item, column);
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
/*!
\overload
\internal
@@ -3362,6 +3381,7 @@ QModelIndex QTreeWidget::indexFromItem(QTreeWidgetItem *item, int column) const
{
return indexFromItem(const_cast<const QTreeWidgetItem *>(item), column);
}
+#endif
/*!
Returns a pointer to the QTreeWidgetItem associated with the given \a index.
diff --git a/src/widgets/itemviews/qtreewidget.h b/src/widgets/itemviews/qtreewidget.h
index 3bdeae08d8..a31af0428a 100644
--- a/src/widgets/itemviews/qtreewidget.h
+++ b/src/widgets/itemviews/qtreewidget.h
@@ -178,7 +178,7 @@ public:
inline QTreeWidgetItem *parent() const { return par; }
inline QTreeWidgetItem *child(int index) const {
if (index < 0 || index >= children.size())
- return Q_NULLPTR;
+ return nullptr;
executePendingSort();
return children.at(index);
}
@@ -261,7 +261,7 @@ class Q_WIDGETS_EXPORT QTreeWidget : public QTreeView
friend class QTreeModel;
friend class QTreeWidgetItem;
public:
- explicit QTreeWidget(QWidget *parent = Q_NULLPTR);
+ explicit QTreeWidget(QWidget *parent = nullptr);
~QTreeWidget();
int columnCount() const;
@@ -299,6 +299,8 @@ public:
void editItem(QTreeWidgetItem *item, int column = 0);
void openPersistentEditor(QTreeWidgetItem *item, int column = 0);
void closePersistentEditor(QTreeWidgetItem *item, int column = 0);
+ using QAbstractItemView::isPersistentEditorOpen;
+ bool isPersistentEditorOpen(QTreeWidgetItem *item, int column = 0) const;
QWidget *itemWidget(QTreeWidgetItem *item, int column) const;
void setItemWidget(QTreeWidgetItem *item, int column, QWidget *widget);
@@ -322,7 +324,7 @@ public:
QTreeWidgetItem *itemAbove(const QTreeWidgetItem *item) const;
QTreeWidgetItem *itemBelow(const QTreeWidgetItem *item) const;
- void setSelectionModel(QItemSelectionModel *selectionModel) Q_DECL_OVERRIDE;
+ void setSelectionModel(QItemSelectionModel *selectionModel) override;
public Q_SLOTS:
void scrollToItem(const QTreeWidgetItem *item,
@@ -344,7 +346,7 @@ Q_SIGNALS:
void itemSelectionChanged();
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
virtual QStringList mimeTypes() const;
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
virtual QMimeData *mimeData(const QList<QTreeWidgetItem *> &items) const;
@@ -354,16 +356,26 @@ protected:
virtual bool dropMimeData(QTreeWidgetItem *parent, int index,
const QMimeData *data, Qt::DropAction action);
virtual Qt::DropActions supportedDropActions() const;
+
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+public:
+#else
+protected:
+#endif
QList<QTreeWidgetItem*> items(const QMimeData *data) const;
QModelIndex indexFromItem(const QTreeWidgetItem *item, int column = 0) const;
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QModelIndex indexFromItem(QTreeWidgetItem *item, int column = 0) const; // ### Qt 6: remove
+#endif
QTreeWidgetItem *itemFromIndex(const QModelIndex &index) const;
+
+protected:
#if QT_CONFIG(draganddrop)
- void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE;
+ void dropEvent(QDropEvent *event) override;
#endif
private:
- void setModel(QAbstractItemModel *model) Q_DECL_OVERRIDE;
+ void setModel(QAbstractItemModel *model) override;
Q_DECLARE_PRIVATE(QTreeWidget)
Q_DISABLE_COPY(QTreeWidget)
@@ -383,7 +395,7 @@ private:
};
inline void QTreeWidget::removeItemWidget(QTreeWidgetItem *item, int column)
-{ setItemWidget(item, column, Q_NULLPTR); }
+{ setItemWidget(item, column, nullptr); }
inline QTreeWidgetItem *QTreeWidget::itemAt(int ax, int ay) const
{ return itemAt(QPoint(ax, ay)); }
diff --git a/src/widgets/itemviews/qtreewidget_p.h b/src/widgets/itemviews/qtreewidget_p.h
index 7aa4daefc0..f4625842ef 100644
--- a/src/widgets/itemviews/qtreewidget_p.h
+++ b/src/widgets/itemviews/qtreewidget_p.h
@@ -91,24 +91,24 @@ public:
void itemChanged(QTreeWidgetItem *item);
QModelIndex index(const QTreeWidgetItem *item, int column) const;
- QModelIndex index(int row, int column, const QModelIndex &parent) const Q_DECL_OVERRIDE;
- QModelIndex parent(const QModelIndex &child) const Q_DECL_OVERRIDE;
- int rowCount(const QModelIndex &parent) const Q_DECL_OVERRIDE;
- int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
- bool hasChildren(const QModelIndex &parent) const Q_DECL_OVERRIDE;
+ QModelIndex index(int row, int column, const QModelIndex &parent) const override;
+ QModelIndex parent(const QModelIndex &child) const override;
+ int rowCount(const QModelIndex &parent) const override;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ bool hasChildren(const QModelIndex &parent) const override;
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
- bool setData(const QModelIndex &index, const QVariant &value, int role) Q_DECL_OVERRIDE;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
+ bool setData(const QModelIndex &index, const QVariant &value, int role) override;
- QMap<int, QVariant> itemData(const QModelIndex &index) const Q_DECL_OVERRIDE;
+ QMap<int, QVariant> itemData(const QModelIndex &index) const override;
- QVariant headerData(int section, Qt::Orientation orientation, int role) const Q_DECL_OVERRIDE;
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value,
- int role) Q_DECL_OVERRIDE;
+ int role) override;
- Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE;
+ Qt::ItemFlags flags(const QModelIndex &index) const override;
- void sort(int column, Qt::SortOrder order) Q_DECL_OVERRIDE;
+ void sort(int column, Qt::SortOrder order) override;
void ensureSorted(int column, Qt::SortOrder order,
int start, int end, const QModelIndex &parent);
static bool itemLessThan(const QPair<QTreeWidgetItem*,int> &left,
@@ -120,17 +120,17 @@ public:
const QList<QTreeWidgetItem*>::iterator &end,
Qt::SortOrder order, QTreeWidgetItem *item);
- bool insertRows(int row, int count, const QModelIndex &) Q_DECL_OVERRIDE;
- bool insertColumns(int column, int count, const QModelIndex &) Q_DECL_OVERRIDE;
+ bool insertRows(int row, int count, const QModelIndex &) override;
+ bool insertColumns(int column, int count, const QModelIndex &) override;
- bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE;
+ bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
// dnd
- QStringList mimeTypes() const Q_DECL_OVERRIDE;
- QMimeData *mimeData(const QModelIndexList &indexes) const Q_DECL_OVERRIDE;
+ QStringList mimeTypes() const override;
+ QMimeData *mimeData(const QModelIndexList &indexes) const override;
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
- int row, int column, const QModelIndex &parent) Q_DECL_OVERRIDE;
- Qt::DropActions supportedDropActions() const Q_DECL_OVERRIDE;
+ int row, int column, const QModelIndex &parent) override;
+ Qt::DropActions supportedDropActions() const override;
QMimeData *internalMimeData() const;
@@ -145,7 +145,7 @@ protected:
void beginRemoveItems(QTreeWidgetItem *parent, int row, int count);
void endRemoveItems();
void sortItems(QList<QTreeWidgetItem*> *items, int column, Qt::SortOrder order);
- void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE;
+ void timerEvent(QTimerEvent *) override;
private:
QTreeWidgetItem *rootItem;
diff --git a/src/widgets/kernel/mac.pri b/src/widgets/kernel/mac.pri
index 8c694c5e05..f7e7aa869a 100644
--- a/src/widgets/kernel/mac.pri
+++ b/src/widgets/kernel/mac.pri
@@ -1,4 +1,4 @@
-!x11:osx {
+macos {
LIBS_PRIVATE += -framework AppKit -lz
*-mwerks:INCLUDEPATH += compat
}
diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp
index 7754defaac..967b0b8dde 100644
--- a/src/widgets/kernel/qaction.cpp
+++ b/src/widgets/kernel/qaction.cpp
@@ -45,6 +45,7 @@
#include "qapplication.h"
#include "qevent.h"
#include "qlist.h"
+#include "qstylehints.h"
#include <private/qshortcutmap_p.h>
#include <private/qapplication_p.h>
#if QT_CONFIG(menu)
@@ -65,7 +66,7 @@ QT_BEGIN_NAMESPACE
*/
static QString qt_strippedText(QString s)
{
- s.remove(QStringLiteral("..."));
+ s.remove(QLatin1String("..."));
for (int i = 0; i < s.size(); ++i) {
if (s.at(i) == QLatin1Char('&'))
s.remove(i, 1);
@@ -77,6 +78,7 @@ static QString qt_strippedText(QString s)
QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0),
visible(1), forceInvisible(0), checkable(0), checked(0), separator(0), fontSet(false),
iconVisibleInMenu(-1),
+ shortcutVisibleInContextMenu(-1),
menuRole(QAction::TextHeuristicRole),
priority(QAction::NormalPriority)
{
@@ -1282,8 +1284,7 @@ void QAction::setIconVisibleInMenu(bool visible)
d->iconVisibleInMenu = visible;
// Only send data changed if we really need to.
if (oldValue != -1
- || (oldValue == -1
- && visible == !QApplication::instance()->testAttribute(Qt::AA_DontShowIconsInMenus))) {
+ || visible == !QApplication::instance()->testAttribute(Qt::AA_DontShowIconsInMenus)) {
d->sendDataChanged();
}
}
@@ -1298,6 +1299,46 @@ bool QAction::isIconVisibleInMenu() const
return d->iconVisibleInMenu;
}
+/*!
+ \property QAction::shortcutVisibleInContextMenu
+ \brief Whether or not an action should show a shortcut in a context menu
+ \since 5.10
+
+ In some applications, it may make sense to have actions with shortcuts in
+ context menus. If true, the shortcut (if valid) is shown when the action is
+ shown via a context menu, when it is false, it is not shown.
+
+ The default is to follow whether the Qt::AA_DontShowShortcutsInContextMenus attribute
+ is set for the application, falling back to the widget style hint.
+ Explicitly setting this property overrides the presence (or abscence) of the attribute.
+
+ \sa QAction::shortcut, QCoreApplication::setAttribute()
+*/
+void QAction::setShortcutVisibleInContextMenu(bool visible)
+{
+ Q_D(QAction);
+ if (d->shortcutVisibleInContextMenu == -1 || visible != bool(d->shortcutVisibleInContextMenu)) {
+ int oldValue = d->shortcutVisibleInContextMenu;
+ d->shortcutVisibleInContextMenu = visible;
+ // Only send data changed if we really need to.
+ if (oldValue != -1
+ || visible == !QApplication::instance()->testAttribute(Qt::AA_DontShowShortcutsInContextMenus)) {
+ d->sendDataChanged();
+ }
+ }
+}
+
+bool QAction::isShortcutVisibleInContextMenu() const
+{
+ Q_D(const QAction);
+ if (d->shortcutVisibleInContextMenu == -1) {
+ if (QApplication::instance()->testAttribute(Qt::AA_DontShowIconsInMenus))
+ return false;
+ return qApp->styleHints()->showShortcutsInContextMenus();
+ }
+ return d->shortcutVisibleInContextMenu;
+}
+
#ifndef QT_NO_DEBUG_STREAM
Q_WIDGETS_EXPORT QDebug operator<<(QDebug d, const QAction *action)
{
diff --git a/src/widgets/kernel/qaction.h b/src/widgets/kernel/qaction.h
index 41e29e6ab9..84bf92d2ac 100644
--- a/src/widgets/kernel/qaction.h
+++ b/src/widgets/kernel/qaction.h
@@ -80,6 +80,7 @@ class Q_WIDGETS_EXPORT QAction : public QObject
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY changed)
Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+ Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
Q_PROPERTY(Priority priority READ priority WRITE setPriority)
public:
@@ -160,7 +161,7 @@ public:
enum ActionEvent { Trigger, Hover };
void activate(ActionEvent event);
- bool showStatusText(QWidget *widget = Q_NULLPTR);
+ bool showStatusText(QWidget *widget = nullptr);
void setMenuRole(MenuRole menuRole);
MenuRole menuRole() const;
@@ -168,6 +169,8 @@ public:
void setIconVisibleInMenu(bool visible);
bool isIconVisibleInMenu() const;
+ void setShortcutVisibleInContextMenu(bool show);
+ bool isShortcutVisibleInContextMenu() const;
QWidget *parentWidget() const;
@@ -177,7 +180,7 @@ public:
#endif
protected:
- bool event(QEvent *) Q_DECL_OVERRIDE;
+ bool event(QEvent *) override;
QAction(QActionPrivate &dd, QObject *parent);
public Q_SLOTS:
diff --git a/src/widgets/kernel/qaction_p.h b/src/widgets/kernel/qaction_p.h
index 992323f308..19ae47c7b9 100644
--- a/src/widgets/kernel/qaction_p.h
+++ b/src/widgets/kernel/qaction_p.h
@@ -109,7 +109,8 @@ public:
uint separator : 1;
uint fontSet : 1;
- int iconVisibleInMenu : 3; // Only has values -1, 0, and 1
+ int iconVisibleInMenu : 2; // Only has values -1, 0, and 1
+ int shortcutVisibleInContextMenu : 2; // Only has values -1, 0, and 1
QAction::MenuRole menuRole;
QAction::Priority priority;
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 26e9ffbbf0..9e4910ebd0 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -152,20 +152,6 @@ static void clearSystemPalette()
QApplicationPrivate::sys_pal = 0;
}
-static QByteArray get_style_class_name()
-{
- QScopedPointer<QStyle> s(QStyleFactory::create(QApplicationPrivate::desktopStyleKey()));
- if (!s.isNull())
- return s->metaObject()->className();
- return QByteArray();
-}
-
-static QByteArray nativeStyleClassName()
-{
- static QByteArray name = get_style_class_name();
- return name;
-}
-
bool QApplicationPrivate::autoSipEnabled = true;
QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, int flags)
@@ -395,8 +381,6 @@ void qt_init_tooltip_palette();
void qt_cleanup();
QStyle *QApplicationPrivate::app_style = 0; // default application style
-bool QApplicationPrivate::overrides_native_style = false; // whether native QApplication style is
- // overridden, i.e. not native
#ifndef QT_NO_STYLE_STYLESHEET
QString QApplicationPrivate::styleSheet; // default application stylesheet
#endif
@@ -1091,8 +1075,6 @@ QStyle *QApplication::style()
Q_ASSERT(!"No styles available!");
return 0;
}
- QApplicationPrivate::overrides_native_style =
- app_style->objectName() != QApplicationPrivate::desktopStyleKey();
}
// take ownership of the style
QApplicationPrivate::app_style->setParent(qApp);
@@ -1157,9 +1139,6 @@ void QApplication::setStyle(QStyle *style)
QStyle *old = QApplicationPrivate::app_style; // save
- QApplicationPrivate::overrides_native_style =
- nativeStyleClassName() == QByteArray(style->metaObject()->className());
-
#ifndef QT_NO_STYLE_STYLESHEET
if (!QApplicationPrivate::styleSheet.isEmpty() && !qobject_cast<QStyleSheetStyle *>(style)) {
// we have a stylesheet already and a new style is being set
@@ -1236,7 +1215,7 @@ void QApplication::setStyle(QStyle *style)
Requests a QStyle object for \a style from the QStyleFactory.
The string must be one of the QStyleFactory::keys(), typically one of
- "windows", "fusion", "windowsxp", or "macintosh". Style
+ "windows", "windowsvista", "fusion", or "macintosh". Style
names are case insensitive.
Returns 0 if an unknown \a style is passed, otherwise the QStyle object
@@ -1479,8 +1458,8 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char*
"selection-background-color" and "alternate-background-color".
\note Some styles do not use the palette for all drawing, for instance, if
- they make use of native theme engines. This is the case for the Windows XP,
- Windows Vista, and \macos styles.
+ they make use of native theme engines. This is the case for the
+ Windows Vista and \macos styles.
\sa QWidget::setPalette(), palette(), QStyle::polish()
*/
@@ -2228,8 +2207,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))) {
@@ -2735,7 +2721,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
case enter/leave events are genereated by the underlying windowing system.
*/
extern QPointer<QWidget> qt_last_mouse_receiver;
-extern QWidget *qt_button_down;
+extern Q_WIDGETS_EXPORT QWidget *qt_button_down;
void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget)
{
#ifndef QT_NO_CURSOR
@@ -2797,7 +2783,7 @@ void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget)
*/
QDesktopWidget *QApplication::desktop()
{
- CHECK_QAPP_INSTANCE(Q_NULLPTR)
+ CHECK_QAPP_INSTANCE(nullptr)
if (!qt_desktopWidget || // not created yet
!(qt_desktopWidget->windowType() == Qt::Desktop)) { // reparented away
qt_desktopWidget = new QDesktopWidget();
@@ -2964,6 +2950,9 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
// required in order to support Qt Test synthesized events. Real mouse
// and keyboard state updates from the platform plugin are managed by
// QGuiApplicationPrivate::process(Mouse|Wheel|Key|Touch|Tablet)Event();
+ // ### FIXME: Qt Test should not call qapp->notify(), but rather route
+ // the events through the proper QPA interface. This is required to
+ // properly generate all other events such as enter/leave etc.
switch (e->type()) {
case QEvent::MouseButtonPress:
{
@@ -3068,7 +3057,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
case QEvent::MouseButtonRelease:
case QEvent::MouseButtonDblClick:
d->toolTipFallAsleep.stop();
- // fall-through
+ Q_FALLTHROUGH();
case QEvent::Leave:
d->toolTipWakeUp.stop();
default:
@@ -3274,7 +3263,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
// sequence, so we reset wheel_widget in case no one accepts the event
// or if we didn't get (or missed) a ScrollEnd previously.
if (spontaneous && phase == Qt::ScrollBegin)
- QApplicationPrivate::wheel_widget = Q_NULLPTR;
+ QApplicationPrivate::wheel_widget = nullptr;
const QPoint &relpos = wheel->pos();
@@ -3324,7 +3313,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
d->notify_helper(QApplicationPrivate::wheel_widget, &we);
wheel->setAccepted(we.isAccepted());
if (phase == Qt::ScrollEnd)
- QApplicationPrivate::wheel_widget = Q_NULLPTR;
+ QApplicationPrivate::wheel_widget = nullptr;
}
}
break;
@@ -3760,7 +3749,6 @@ static void grabForPopup(QWidget *popup)
}
}
-extern QWidget *qt_button_down;
extern QWidget *qt_popup_down;
extern bool qt_replay_popup_mouse_event;
diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h
index 396d0c9474..7a5d7ba1a9 100644
--- a/src/widgets/kernel/qapplication.h
+++ b/src/widgets/kernel/qapplication.h
@@ -110,11 +110,11 @@ public:
using QGuiApplication::palette;
static QPalette palette(const QWidget *);
static QPalette palette(const char *className);
- static void setPalette(const QPalette &, const char* className = Q_NULLPTR);
+ static void setPalette(const QPalette &, const char* className = nullptr);
static QFont font();
static QFont font(const QWidget*);
static QFont font(const char *className);
- static void setFont(const QFont &, const char* className = Q_NULLPTR);
+ static void setFont(const QFont &, const char* className = nullptr);
static QFontMetrics fontMetrics();
#if QT_VERSION < 0x060000 // remove these forwarders in Qt 6
@@ -177,7 +177,7 @@ public:
#endif
static int exec();
- bool notify(QObject *, QEvent *) Q_DECL_OVERRIDE;
+ bool notify(QObject *, QEvent *) override;
#ifdef QT_KEYPAD_NAVIGATION
static Q_DECL_DEPRECATED void setKeypadNavigationEnabled(bool);
@@ -201,8 +201,8 @@ public Q_SLOTS:
static void aboutQt();
protected:
- bool event(QEvent *) Q_DECL_OVERRIDE;
- bool compressEvent(QEvent *, QObject *receiver, QPostEventList *) Q_DECL_OVERRIDE;
+ bool event(QEvent *) override;
+ bool compressEvent(QEvent *, QObject *receiver, QPostEventList *) override;
private:
Q_DISABLE_COPY(QApplication)
diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h
index 36de3cacaa..9983cc7d9e 100644
--- a/src/widgets/kernel/qapplication_p.h
+++ b/src/widgets/kernel/qapplication_p.h
@@ -92,7 +92,7 @@ extern QClipboard *qt_clipboard;
#endif
typedef QHash<QByteArray, QFont> FontHash;
-FontHash *qt_app_fonts_hash();
+Q_WIDGETS_EXPORT FontHash *qt_app_fonts_hash();
typedef QHash<QByteArray, QPalette> PaletteHash;
PaletteHash *qt_app_palettes_hash();
@@ -106,11 +106,11 @@ public:
QApplicationPrivate(int &argc, char **argv, int flags);
~QApplicationPrivate();
- virtual void notifyLayoutDirectionChange() Q_DECL_OVERRIDE;
- virtual void notifyActiveWindowChange(QWindow *) Q_DECL_OVERRIDE;
+ virtual void notifyLayoutDirectionChange() override;
+ virtual void notifyActiveWindowChange(QWindow *) override;
- virtual bool shouldQuit() Q_DECL_OVERRIDE;
- bool tryCloseAllWindows() Q_DECL_OVERRIDE;
+ virtual bool shouldQuit() override;
+ bool tryCloseAllWindows() override;
#if 0 // Used to be included in Qt4 for Q_WS_X11
#ifndef QT_NO_SETTINGS
@@ -122,13 +122,13 @@ public:
static QString desktopStyleKey();
- void createEventDispatcher() Q_DECL_OVERRIDE;
+ void createEventDispatcher() override;
static void dispatchEnterLeave(QWidget *enter, QWidget *leave, const QPointF &globalPosF);
- void notifyWindowIconChanged() Q_DECL_OVERRIDE;
+ void notifyWindowIconChanged() override;
//modality
- bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = 0) const Q_DECL_OVERRIDE;
+ bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = 0) const override;
static bool isBlockedByModal(QWidget *widget);
static bool modalState();
static bool tryModalHelper(QWidget *widget, QWidget **rettop = 0);
@@ -137,12 +137,6 @@ public:
bool canQuit();
#endif
- //style
- static bool usesNativeStyle()
- {
- return !overrides_native_style;
- }
-
bool notify_helper(QObject *receiver, QEvent * e);
void init(
@@ -158,7 +152,7 @@ public:
#endif
static bool inPopupMode();
- bool popupActive() Q_DECL_OVERRIDE { return inPopupMode(); }
+ bool popupActive() override { return inPopupMode(); }
void closePopup(QWidget *popup);
void openPopup(QWidget *popup);
static void setFocusWidget(QWidget *focus, Qt::FocusReason reason);
@@ -178,14 +172,13 @@ public:
static QSize app_strut;
static QWidgetList *popupWidgets;
static QStyle *app_style;
- static bool overrides_native_style;
static QPalette *sys_pal;
static QPalette *set_pal;
protected:
- void notifyThemeChanged() Q_DECL_OVERRIDE;
+ void notifyThemeChanged() override;
#ifndef QT_NO_DRAGANDDROP
- void notifyDragStarted(const QDrag *) Q_DECL_OVERRIDE;
+ void notifyDragStarted(const QDrag *) override;
#endif // QT_NO_DRAGANDDROP
public:
@@ -284,7 +277,7 @@ public:
ulong timestamp);
static void translateTouchCancel(QTouchDevice *device, ulong timestamp);
- QPixmap applyQIconStyleHelper(QIcon::Mode mode, const QPixmap& base) const Q_DECL_OVERRIDE;
+ QPixmap applyQIconStyleHelper(QIcon::Mode mode, const QPixmap& base) const override;
private:
static QApplicationPrivate *self;
static bool tryCloseAllWidgetWindows(QWindowList *processedWindows);
diff --git a/src/widgets/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp
index f2e3df5314..a368f379ad 100644
--- a/src/widgets/kernel/qboxlayout.cpp
+++ b/src/widgets/kernel/qboxlayout.cpp
@@ -124,7 +124,7 @@ public:
void calcHfw(int);
void effectiveMargins(int *left, int *top, int *right, int *bottom) const;
- QLayoutItem* replaceAt(int index, QLayoutItem*) Q_DECL_OVERRIDE;
+ QLayoutItem* replaceAt(int index, QLayoutItem*) override;
};
QBoxLayoutPrivate::~QBoxLayoutPrivate()
@@ -873,15 +873,9 @@ void QBoxLayout::insertSpacing(int index, int size)
else
b = QLayoutPrivate::createSpacerItem(this, 0, size, QSizePolicy::Minimum, QSizePolicy::Fixed);
- QT_TRY {
- QBoxLayoutItem *it = new QBoxLayoutItem(b);
- it->magic = true;
- d->list.insert(index, it);
-
- } QT_CATCH(...) {
- delete b;
- QT_RETHROW;
- }
+ QBoxLayoutItem *it = new QBoxLayoutItem(b);
+ it->magic = true;
+ d->list.insert(index, it);
invalidate();
}
@@ -985,20 +979,8 @@ void QBoxLayout::insertWidget(int index, QWidget *widget, int stretch,
QWidgetItem *b = QLayoutPrivate::createWidgetItem(this, widget);
b->setAlignment(alignment);
- QBoxLayoutItem *it;
- QT_TRY{
- it = new QBoxLayoutItem(b, stretch);
- } QT_CATCH(...) {
- delete b;
- QT_RETHROW;
- }
-
- QT_TRY{
- d->list.insert(index, it);
- } QT_CATCH(...) {
- delete it;
- QT_RETHROW;
- }
+ QBoxLayoutItem *it = new QBoxLayoutItem(b, stretch);
+ d->list.insert(index, it);
invalidate();
}
diff --git a/src/widgets/kernel/qboxlayout.h b/src/widgets/kernel/qboxlayout.h
index 9c7d0e593f..6bb8f8aafa 100644
--- a/src/widgets/kernel/qboxlayout.h
+++ b/src/widgets/kernel/qboxlayout.h
@@ -61,7 +61,7 @@ public:
enum Direction { LeftToRight, RightToLeft, TopToBottom, BottomToTop,
Down = TopToBottom, Up = BottomToTop };
- explicit QBoxLayout(Direction, QWidget *parent = Q_NULLPTR);
+ explicit QBoxLayout(Direction, QWidget *parent = nullptr);
~QBoxLayout();
@@ -74,7 +74,7 @@ public:
void addWidget(QWidget *, int stretch = 0, Qt::Alignment alignment = Qt::Alignment());
void addLayout(QLayout *layout, int stretch = 0);
void addStrut(int);
- void addItem(QLayoutItem *) Q_DECL_OVERRIDE;
+ void addItem(QLayoutItem *) override;
void insertSpacing(int index, int size);
void insertStretch(int index, int stretch = 0);
@@ -91,20 +91,20 @@ public:
void setStretch(int index, int stretch);
int stretch(int index) const;
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSize() const Q_DECL_OVERRIDE;
- QSize maximumSize() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ QSize minimumSize() const override;
+ QSize maximumSize() const override;
- bool hasHeightForWidth() const Q_DECL_OVERRIDE;
- int heightForWidth(int) const Q_DECL_OVERRIDE;
- int minimumHeightForWidth(int) const Q_DECL_OVERRIDE;
+ bool hasHeightForWidth() const override;
+ int heightForWidth(int) const override;
+ int minimumHeightForWidth(int) const override;
- Qt::Orientations expandingDirections() const Q_DECL_OVERRIDE;
- void invalidate() Q_DECL_OVERRIDE;
- QLayoutItem *itemAt(int) const Q_DECL_OVERRIDE;
- QLayoutItem *takeAt(int) Q_DECL_OVERRIDE;
- int count() const Q_DECL_OVERRIDE;
- void setGeometry(const QRect&) Q_DECL_OVERRIDE;
+ Qt::Orientations expandingDirections() const override;
+ void invalidate() override;
+ QLayoutItem *itemAt(int) const override;
+ QLayoutItem *takeAt(int) override;
+ int count() const override;
+ void setGeometry(const QRect&) override;
private:
Q_DISABLE_COPY(QBoxLayout)
diff --git a/src/widgets/kernel/qdesktopwidget.cpp b/src/widgets/kernel/qdesktopwidget.cpp
index 1e6fbfd239..5fb7882932 100644
--- a/src/widgets/kernel/qdesktopwidget.cpp
+++ b/src/widgets/kernel/qdesktopwidget.cpp
@@ -50,7 +50,7 @@
QT_BEGIN_NAMESPACE
QDesktopScreenWidget::QDesktopScreenWidget(QScreen *screen, const QRect &geometry)
- : QWidget(Q_NULLPTR, Qt::Desktop), m_screen(screen)
+ : QWidget(nullptr, Qt::Desktop), m_screen(screen)
{
setVisible(false);
if (QWindow *winHandle = windowHandle())
@@ -73,6 +73,11 @@ int QDesktopScreenWidget::screenNumber() const
const QRect QDesktopWidget::screenGeometry(const QWidget *widget) const
{
+ return QDesktopWidgetPrivate::screenGeometry(widget);
+}
+
+const QRect QDesktopWidgetPrivate::screenGeometry(const QWidget *widget)
+{
if (Q_UNLIKELY(!widget)) {
qWarning("QDesktopWidget::screenGeometry(): Attempt "
"to get the screen geometry of a null widget");
@@ -86,6 +91,11 @@ const QRect QDesktopWidget::screenGeometry(const QWidget *widget) const
const QRect QDesktopWidget::availableGeometry(const QWidget *widget) const
{
+ return QDesktopWidgetPrivate::availableGeometry(widget);
+}
+
+const QRect QDesktopWidgetPrivate::availableGeometry(const QWidget *widget)
+{
if (Q_UNLIKELY(!widget)) {
qWarning("QDesktopWidget::availableGeometry(): Attempt "
"to get the available geometry of a null widget");
@@ -104,7 +114,7 @@ QDesktopScreenWidget *QDesktopWidgetPrivate::widgetForScreen(QScreen *qScreen) c
if (widget->screen() == qScreen)
return widget;
}
- return Q_NULLPTR;
+ return nullptr;
}
void QDesktopWidgetPrivate::_q_updateScreens()
@@ -166,17 +176,26 @@ void QDesktopWidgetPrivate::_q_updateScreens()
// Notice that we trigger screenCountChanged even if a screen was removed and another one added,
// in which case the total number of screens did not change. This is the only way for applications
// to notice that a screen was swapped out against another one.
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
emit q->screenCountChanged(targetLength);
+QT_WARNING_POP
}
foreach (int changedScreen, changedScreens)
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
emit q->resized(changedScreen);
+QT_WARNING_POP
}
void QDesktopWidgetPrivate::_q_availableGeometryChanged()
{
Q_Q(QDesktopWidget);
if (QScreen *screen = qobject_cast<QScreen *>(q->sender()))
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
emit q->workAreaResized(QGuiApplication::screens().indexOf(screen));
+QT_WARNING_POP
}
QDesktopWidget::QDesktopWidget()
@@ -195,16 +214,51 @@ QDesktopWidget::~QDesktopWidget()
bool QDesktopWidget::isVirtualDesktop() const
{
+ return QDesktopWidgetPrivate::isVirtualDesktop();
+}
+
+bool QDesktopWidgetPrivate::isVirtualDesktop()
+{
return QGuiApplication::primaryScreen()->virtualSiblings().size() > 1;
}
+QRect QDesktopWidgetPrivate::geometry()
+{
+ return QGuiApplication::primaryScreen()->virtualGeometry();
+}
+
+QSize QDesktopWidgetPrivate::size()
+{
+ return geometry().size();
+}
+
+int QDesktopWidgetPrivate::width()
+{
+ return geometry().width();
+}
+
+int QDesktopWidgetPrivate::height()
+{
+ return geometry().height();
+}
+
int QDesktopWidget::primaryScreen() const
{
+ return QDesktopWidgetPrivate::primaryScreen();
+}
+
+int QDesktopWidgetPrivate::primaryScreen()
+{
return 0;
}
int QDesktopWidget::numScreens() const
{
+ return QDesktopWidgetPrivate::numScreens();
+}
+
+int QDesktopWidgetPrivate::numScreens()
+{
return qMax(QGuiApplication::screens().size(), 1);
}
@@ -218,28 +272,33 @@ QWidget *QDesktopWidget::screen(int screen)
const QRect QDesktopWidget::availableGeometry(int screenNo) const
{
- QList<QScreen *> screens = QGuiApplication::screens();
- if (screenNo == -1)
- screenNo = 0;
- if (screenNo < 0 || screenNo >= screens.size())
- return QRect();
- else
- return screens.at(screenNo)->availableGeometry();
+ return QDesktopWidgetPrivate::availableGeometry(screenNo);
+}
+
+const QRect QDesktopWidgetPrivate::availableGeometry(int screenNo)
+{
+ const QScreen *screen = QDesktopWidgetPrivate::screen(screenNo);
+ return screen ? screen->availableGeometry() : QRect();
}
const QRect QDesktopWidget::screenGeometry(int screenNo) const
{
- QList<QScreen *> screens = QGuiApplication::screens();
- if (screenNo == -1)
- screenNo = 0;
- if (screenNo < 0 || screenNo >= screens.size())
- return QRect();
- else
- return screens.at(screenNo)->geometry();
+ return QDesktopWidgetPrivate::screenGeometry(screenNo);
+}
+
+const QRect QDesktopWidgetPrivate::screenGeometry(int screenNo)
+{
+ const QScreen *screen = QDesktopWidgetPrivate::screen(screenNo);
+ return screen ? screen->geometry() : QRect();
}
int QDesktopWidget::screenNumber(const QWidget *w) const
{
+ return QDesktopWidgetPrivate::screenNumber(w);
+}
+
+int QDesktopWidgetPrivate::screenNumber(const QWidget *w)
+{
if (!w)
return primaryScreen();
@@ -270,7 +329,7 @@ int QDesktopWidget::screenNumber(const QWidget *w) const
if (!w->isWindow())
frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0)));
- QScreen *widgetScreen = Q_NULLPTR;
+ QScreen *widgetScreen = nullptr;
int largestArea = 0;
foreach (QScreen *screen, screens) {
const QRect deviceIndependentScreenGeometry =
@@ -287,26 +346,23 @@ int QDesktopWidget::screenNumber(const QWidget *w) const
int QDesktopWidget::screenNumber(const QPoint &p) const
{
- 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
+ return QDesktopWidgetPrivate::screenNumber(p);
+}
+
+int QDesktopWidgetPrivate::screenNumber(const QPoint &p)
+{
+ QScreen *screen = QGuiApplication::screenAt(p);
+ return screen ? QGuiApplication::screens().indexOf(screen) : primaryScreen();
+}
+
+QScreen *QDesktopWidgetPrivate::screen(int screenNo)
+{
+ QList<QScreen *> screens = QGuiApplication::screens();
+ if (screenNo == -1)
+ screenNo = 0;
+ if (screenNo < 0 || screenNo >= screens.size())
+ return nullptr;
+ return screens.at(screenNo);
}
void QDesktopWidget::resizeEvent(QResizeEvent *)
diff --git a/src/widgets/kernel/qdesktopwidget.h b/src/widgets/kernel/qdesktopwidget.h
index 64e1c568eb..f53d0fe9bb 100644
--- a/src/widgets/kernel/qdesktopwidget.h
+++ b/src/widgets/kernel/qdesktopwidget.h
@@ -59,35 +59,48 @@ public:
QDesktopWidget();
~QDesktopWidget();
- bool isVirtualDesktop() const;
+ int screenNumber(const QWidget *widget = nullptr) const;
+ const QRect screenGeometry(const QWidget *widget) const;
+ const QRect availableGeometry(const QWidget *widget) const;
- int numScreens() const;
- int screenCount() const;
- int primaryScreen() const;
+#if QT_DEPRECATED_SINCE(5, 11)
+ QT_DEPRECATED_X("Use QScreen::virtualSiblings() of primary screen") bool isVirtualDesktop() const;
- int screenNumber(const QWidget *widget = Q_NULLPTR) const;
- int screenNumber(const QPoint &) const;
+ QT_DEPRECATED_X("Use QGuiApplication::screens()") int numScreens() const;
+ QT_DEPRECATED_X("Use QGuiApplication::screens()") int screenCount() const;
+ QT_DEPRECATED_X("Use QGuiApplication::primaryScreen()") int primaryScreen() const;
- QWidget *screen(int screen = -1);
+ QT_DEPRECATED_X("Use QGuiApplication::screenAt()") int screenNumber(const QPoint &) const;
- const QRect screenGeometry(int screen = -1) const;
- const QRect screenGeometry(const QWidget *widget) const;
- const QRect screenGeometry(const QPoint &point) const
- { return screenGeometry(screenNumber(point)); }
+ QT_DEPRECATED_X("Use QScreen") QWidget *screen(int screen = -1);
- const QRect availableGeometry(int screen = -1) const;
- const QRect availableGeometry(const QWidget *widget) const;
- const QRect availableGeometry(const QPoint &point) const
- { return availableGeometry(screenNumber(point)); }
+ QT_DEPRECATED_X("Use QGuiApplication::screens()") const QRect screenGeometry(int screen = -1) const;
+ QT_DEPRECATED_X("Use QGuiApplication::screenAt()") const QRect screenGeometry(const QPoint &point) const
+ {
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+ return screenGeometry(screenNumber(point));
+QT_WARNING_POP
+ }
+
+ QT_DEPRECATED_X("Use QGuiApplication::screens()") const QRect availableGeometry(int screen = -1) const;
+ QT_DEPRECATED_X("Use QGuiApplication::screenAt()") const QRect availableGeometry(const QPoint &point) const
+ {
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+ return availableGeometry(screenNumber(point));
+QT_WARNING_POP
+ }
Q_SIGNALS:
- void resized(int);
- void workAreaResized(int);
- void screenCountChanged(int);
- void primaryScreenChanged();
+ QT_DEPRECATED_X("Use QScreen::geometryChanged()") void resized(int);
+ QT_DEPRECATED_X("Use QScreen::availableGeometryChanged()") void workAreaResized(int);
+ QT_DEPRECATED_X("Use QGuiApplication::screenAdded/Removed()") void screenCountChanged(int);
+ QT_DEPRECATED_X("Use QGuiApplication::primaryScreenChanged()") void primaryScreenChanged();
+#endif
protected:
- void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
+ void resizeEvent(QResizeEvent *e) override;
private:
Q_DISABLE_COPY(QDesktopWidget)
@@ -100,7 +113,12 @@ private:
};
inline int QDesktopWidget::screenCount() const
-{ return numScreens(); }
+{
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+ return numScreens();
+QT_WARNING_POP
+}
QT_END_NAMESPACE
diff --git a/src/widgets/kernel/qdesktopwidget.qdoc b/src/widgets/kernel/qdesktopwidget.qdoc
index 27d05ece8c..dd2d9535ae 100644
--- a/src/widgets/kernel/qdesktopwidget.qdoc
+++ b/src/widgets/kernel/qdesktopwidget.qdoc
@@ -32,6 +32,7 @@
\ingroup advanced
\ingroup desktop
\inmodule QtWidgets
+ \obsolete
Systems with more than one graphics card and monitor can manage the
physical screen space available either as multiple desktops, or as a
@@ -125,7 +126,7 @@
\obsolete
- This function is deprecated. Use screenCount instead.
+ Use QGuiApplication::screens() instead.
\sa primaryScreen
*/
@@ -140,6 +141,10 @@
have the geometry of the entire virtual desktop; i.e., bounding
every \a screen.
+ \obsolete
+
+ Use QScreen instead.
+
\sa primaryScreen, screenCount, virtualDesktop
*/
@@ -152,7 +157,11 @@
on \macos, or the task bar on Windows). The default screen is used if
\a screen is -1.
- \sa screenNumber(), screenGeometry()
+ \obsolete
+
+ Use QGuiApplication::screens() instead.
+
+ \sa screenNumber(), screenGeometry(), QScreen::availableGeometry()
*/
/*!
@@ -170,6 +179,10 @@
Returns the available geometry of the screen which contains \a p.
+ \obsolete
+
+ Use QGuiApplication::screenAt() instead.
+
\sa screenGeometry()
*/
@@ -180,6 +193,10 @@
Returns the geometry of the screen with index \a screen. The default
screen is used if \a screen is -1.
+ \obsolete
+
+ Use QGuiApplication::screens() instead.
+
\sa screenNumber()
*/
@@ -195,6 +212,10 @@
\overload
Returns the geometry of the screen which contains \a p.
+
+ \obsolete
+
+ Use QGuiApplication::screenAt() instead.
*/
@@ -214,30 +235,47 @@
Returns the index of the screen that contains the \a point, or the
screen which is the shortest distance from the \a point.
+ \obsolete
+
+ Use QGuiApplication::screenAt() instead.
+
\sa primaryScreen
*/
/*!
\fn void QDesktopWidget::resizeEvent(QResizeEvent *event)
\reimp
+ \internal
*/
/*!
\fn void QDesktopWidget::resized(int screen)
This signal is emitted when the size of \a screen changes.
+
+ \obsolete
+
+ Use QScreen::geometryChanged() instead.
*/
/*!
\fn void QDesktopWidget::workAreaResized(int screen)
This signal is emitted when the work area available on \a screen changes.
+
+ \obsolete
+
+ Use QScreen::availableGeometryChanged() instead.
*/
/*!
\property QDesktopWidget::screenCount
\brief the number of screens currently available on the system.
+ \obsolete
+
+ Use QGuiApplication::screens() instead.
+
\since 4.6
*/
@@ -245,6 +283,10 @@
\property QDesktopWidget::primaryScreen
\brief the index of the screen that is configured to be the primary screen
on the system.
+
+ \obsolete
+
+ Use QGuiApplication::primaryScreen() instead.
*/
/*!
@@ -255,6 +297,10 @@
For virtual desktops, screen() will always return the same widget.
The size of the virtual desktop is the size of this desktop
widget.
+
+ \obsolete
+
+ Use QScreen::virtualSiblings() of primary screen instead.
*/
/*!
@@ -264,6 +310,10 @@
This signal is emitted when the number of screens changes to \a newCount.
+ \obsolete
+
+ Use QGuiApplication::screenAdded and QGuiApplication::screenRemoved() instead.
+
\sa screenCount
*/
@@ -278,5 +328,9 @@
\note This doesn't mean the QDesktopWidget::primaryScreen index will
necessarily be different, but now it will refer to the new primary screen.
+ \obsolete
+
+ Use QGuiApplication::primaryScreenChanged() instead.
+
\sa primaryScreen, screenGeometry()
*/
diff --git a/src/widgets/kernel/qdesktopwidget_p.h b/src/widgets/kernel/qdesktopwidget_p.h
index dade4fe45e..69f87337b3 100644
--- a/src/widgets/kernel/qdesktopwidget_p.h
+++ b/src/widgets/kernel/qdesktopwidget_p.h
@@ -87,6 +87,31 @@ public:
void _q_availableGeometryChanged();
QDesktopScreenWidget *widgetForScreen(QScreen *qScreen) const;
+ static bool isVirtualDesktop();
+
+ static QRect geometry();
+ static QSize size();
+ static int width();
+ static int height();
+
+ static int numScreens();
+ static int primaryScreen();
+
+ static int screenNumber(const QWidget *widget = nullptr);
+ static int screenNumber(const QPoint &);
+
+ static QScreen *screen(int screenNo = -1);
+
+ static const QRect screenGeometry(int screen = -1);
+ static const QRect screenGeometry(const QWidget *widget);
+ static const QRect screenGeometry(const QPoint &point)
+ { return screenGeometry(screenNumber(point)); }
+
+ static const QRect availableGeometry(int screen = -1);
+ static const QRect availableGeometry(const QWidget *widget);
+ static const QRect availableGeometry(const QPoint &point)
+ { return availableGeometry(screenNumber(point)); }
+
QList<QDesktopScreenWidget *> screens;
};
diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp
index 868ac17b6f..8a5b863bb5 100644
--- a/src/widgets/kernel/qformlayout.cpp
+++ b/src/widgets/kernel/qformlayout.cpp
@@ -224,7 +224,7 @@ public:
int hSpacing;
int vSpacing;
- QLayoutItem* replaceAt(int index, QLayoutItem*) Q_DECL_OVERRIDE;
+ QLayoutItem* replaceAt(int index, QLayoutItem*) override;
};
QFormLayoutPrivate::QFormLayoutPrivate()
diff --git a/src/widgets/kernel/qformlayout.h b/src/widgets/kernel/qformlayout.h
index 5ec27433d3..40424f2a49 100644
--- a/src/widgets/kernel/qformlayout.h
+++ b/src/widgets/kernel/qformlayout.h
@@ -88,7 +88,7 @@ public:
QLayoutItem *fieldItem;
};
- explicit QFormLayout(QWidget *parent = Q_NULLPTR);
+ explicit QFormLayout(QWidget *parent = nullptr);
~QFormLayout();
void setFieldGrowthPolicy(FieldGrowthPolicy policy);
@@ -142,19 +142,19 @@ public:
QWidget *labelForField(QLayout *field) const;
// reimplemented from QLayout
- void addItem(QLayoutItem *item) Q_DECL_OVERRIDE;
- QLayoutItem *itemAt(int index) const Q_DECL_OVERRIDE;
- QLayoutItem *takeAt(int index) Q_DECL_OVERRIDE;
-
- void setGeometry(const QRect &rect) Q_DECL_OVERRIDE;
- QSize minimumSize() const Q_DECL_OVERRIDE;
- QSize sizeHint() const Q_DECL_OVERRIDE;
- void invalidate() Q_DECL_OVERRIDE;
-
- bool hasHeightForWidth() const Q_DECL_OVERRIDE;
- int heightForWidth(int width) const Q_DECL_OVERRIDE;
- Qt::Orientations expandingDirections() const Q_DECL_OVERRIDE;
- int count() const Q_DECL_OVERRIDE;
+ void addItem(QLayoutItem *item) override;
+ QLayoutItem *itemAt(int index) const override;
+ QLayoutItem *takeAt(int index) override;
+
+ void setGeometry(const QRect &rect) override;
+ QSize minimumSize() const override;
+ QSize sizeHint() const override;
+ void invalidate() override;
+
+ bool hasHeightForWidth() const override;
+ int heightForWidth(int width) const override;
+ Qt::Orientations expandingDirections() const override;
+ int count() const override;
int rowCount() const;
diff --git a/src/widgets/kernel/qgesture.h b/src/widgets/kernel/qgesture.h
index 1eda611d64..c5b2cee83d 100644
--- a/src/widgets/kernel/qgesture.h
+++ b/src/widgets/kernel/qgesture.h
@@ -70,7 +70,7 @@ class Q_WIDGETS_EXPORT QGesture : public QObject
Q_PROPERTY(bool hasHotSpot READ hasHotSpot)
public:
- explicit QGesture(QObject *parent = Q_NULLPTR);
+ explicit QGesture(QObject *parent = nullptr);
~QGesture();
Qt::GestureType gestureType() const;
@@ -114,7 +114,7 @@ class Q_WIDGETS_EXPORT QPanGesture : public QGesture
Q_PRIVATE_PROPERTY(QPanGesture::d_func(), qreal verticalVelocity READ verticalVelocity WRITE setVerticalVelocity)
public:
- explicit QPanGesture(QObject *parent = Q_NULLPTR);
+ explicit QPanGesture(QObject *parent = nullptr);
~QPanGesture();
QPointF lastOffset() const;
@@ -162,7 +162,7 @@ public:
Q_PROPERTY(QPointF centerPoint READ centerPoint WRITE setCenterPoint)
public:
- explicit QPinchGesture(QObject *parent = Q_NULLPTR);
+ explicit QPinchGesture(QObject *parent = nullptr);
~QPinchGesture();
ChangeFlags totalChangeFlags() const;
@@ -218,7 +218,7 @@ public:
enum SwipeDirection { NoDirection, Left, Right, Up, Down };
Q_ENUM(SwipeDirection)
- explicit QSwipeGesture(QObject *parent = Q_NULLPTR);
+ explicit QSwipeGesture(QObject *parent = nullptr);
~QSwipeGesture();
SwipeDirection horizontalDirection() const;
@@ -239,7 +239,7 @@ class Q_WIDGETS_EXPORT QTapGesture : public QGesture
Q_PROPERTY(QPointF position READ position WRITE setPosition)
public:
- explicit QTapGesture(QObject *parent = Q_NULLPTR);
+ explicit QTapGesture(QObject *parent = nullptr);
~QTapGesture();
QPointF position() const;
@@ -257,7 +257,7 @@ class Q_WIDGETS_EXPORT QTapAndHoldGesture : public QGesture
Q_PROPERTY(QPointF position READ position WRITE setPosition)
public:
- explicit QTapAndHoldGesture(QObject *parent = Q_NULLPTR);
+ explicit QTapAndHoldGesture(QObject *parent = nullptr);
~QTapAndHoldGesture();
QPointF position() const;
diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp
index f27961b817..5bf66d68e3 100644
--- a/src/widgets/kernel/qgesturemanager.cpp
+++ b/src/widgets/kernel/qgesturemanager.cpp
@@ -124,7 +124,7 @@ QGestureManager::~QGestureManager()
Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *recognizer)
{
- QGesture *dummy = recognizer->create(0);
+ const QScopedPointer<QGesture> dummy(recognizer->create(nullptr));
if (Q_UNLIKELY(!dummy)) {
qWarning("QGestureManager::registerGestureRecognizer: "
"the recognizer fails to create a gesture object, skipping registration.");
@@ -137,7 +137,6 @@ Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *r
type = Qt::GestureType(m_lastCustomGestureId);
}
m_recognizers.insertMulti(type, recognizer);
- delete dummy;
return type;
}
@@ -145,10 +144,9 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type)
{
QList<QGestureRecognizer *> list = m_recognizers.values(type);
while (QGestureRecognizer *recognizer = m_recognizers.take(type)) {
- if (!m_obsoleteGestures.contains(recognizer)) {
- // inserting even an empty QSet will cause the recognizer to be deleted on destruction of the manager
- m_obsoleteGestures.insert(recognizer, QSet<QGesture *>());
- }
+ // ensuring an entry exists causes the recognizer to be deleted on destruction of the manager
+ auto &gestures = m_obsoleteGestures[recognizer];
+ Q_UNUSED(gestures);
}
foreach (QGesture *g, m_gestureToRecognizer.keys()) {
QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g);
diff --git a/src/widgets/kernel/qgesturerecognizer.cpp b/src/widgets/kernel/qgesturerecognizer.cpp
index e7873d455e..65c46a5e56 100644
--- a/src/widgets/kernel/qgesturerecognizer.cpp
+++ b/src/widgets/kernel/qgesturerecognizer.cpp
@@ -193,7 +193,7 @@ void QGestureRecognizer::reset(QGesture *gesture)
}
/*!
- \fn QGestureRecognizer::recognize(QGesture *gesture, QObject *watched, QEvent *event)
+ \fn QGestureRecognizer::Result QGestureRecognizer::recognize(QGesture *gesture, QObject *watched, QEvent *event)
Handles the given \a event for the \a watched object, updating the state of the \a gesture
object as required, and returns a suitable result for the current recognition step.
diff --git a/src/widgets/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp
index 29df38f19c..db8ef89477 100644
--- a/src/widgets/kernel/qgridlayout.cpp
+++ b/src/widgets/kernel/qgridlayout.cpp
@@ -170,7 +170,7 @@ public:
}
return 0;
}
- QLayoutItem* replaceAt(int index, QLayoutItem *newitem) Q_DECL_OVERRIDE
+ QLayoutItem* replaceAt(int index, QLayoutItem *newitem) override
{
if (!newitem)
return 0;
diff --git a/src/widgets/kernel/qgridlayout.h b/src/widgets/kernel/qgridlayout.h
index 51dd65d181..0283ec2028 100644
--- a/src/widgets/kernel/qgridlayout.h
+++ b/src/widgets/kernel/qgridlayout.h
@@ -66,9 +66,9 @@ public:
~QGridLayout();
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSize() const Q_DECL_OVERRIDE;
- QSize maximumSize() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ QSize minimumSize() const override;
+ QSize maximumSize() const override;
void setHorizontalSpacing(int spacing);
int horizontalSpacing() const;
@@ -92,12 +92,12 @@ public:
QRect cellRect(int row, int column) const;
- bool hasHeightForWidth() const Q_DECL_OVERRIDE;
- int heightForWidth(int) const Q_DECL_OVERRIDE;
- int minimumHeightForWidth(int) const Q_DECL_OVERRIDE;
+ bool hasHeightForWidth() const override;
+ int heightForWidth(int) const override;
+ int minimumHeightForWidth(int) const override;
- Qt::Orientations expandingDirections() const Q_DECL_OVERRIDE;
- void invalidate() Q_DECL_OVERRIDE;
+ Qt::Orientations expandingDirections() const override;
+ void invalidate() override;
inline void addWidget(QWidget *w) { QLayout::addWidget(w); }
void addWidget(QWidget *, int row, int column, Qt::Alignment = Qt::Alignment());
@@ -108,11 +108,11 @@ public:
void setOriginCorner(Qt::Corner);
Qt::Corner originCorner() const;
- QLayoutItem *itemAt(int index) const Q_DECL_OVERRIDE;
+ QLayoutItem *itemAt(int index) const override;
QLayoutItem *itemAtPosition(int row, int column) const;
- QLayoutItem *takeAt(int index) Q_DECL_OVERRIDE;
- int count() const Q_DECL_OVERRIDE;
- void setGeometry(const QRect&) Q_DECL_OVERRIDE;
+ QLayoutItem *takeAt(int index) override;
+ int count() const override;
+ void setGeometry(const QRect&) override;
void addItem(QLayoutItem *item, int row, int column, int rowSpan = 1, int columnSpan = 1, Qt::Alignment = Qt::Alignment());
@@ -120,7 +120,7 @@ public:
void getItemPosition(int idx, int *row, int *column, int *rowSpan, int *columnSpan) const;
protected:
- void addItem(QLayoutItem *) Q_DECL_OVERRIDE;
+ void addItem(QLayoutItem *) override;
private:
Q_DISABLE_COPY(QGridLayout)
diff --git a/src/widgets/kernel/qlayout.h b/src/widgets/kernel/qlayout.h
index 2de12b4f99..bcc33a0811 100644
--- a/src/widgets/kernel/qlayout.h
+++ b/src/widgets/kernel/qlayout.h
@@ -104,8 +104,8 @@ public:
QWidget *parentWidget() const;
- void invalidate() Q_DECL_OVERRIDE;
- QRect geometry() const Q_DECL_OVERRIDE;
+ void invalidate() override;
+ QRect geometry() const override;
bool activate();
void update();
@@ -115,25 +115,25 @@ public:
void removeWidget(QWidget *w);
void removeItem(QLayoutItem *);
- Qt::Orientations expandingDirections() const Q_DECL_OVERRIDE;
- QSize minimumSize() const Q_DECL_OVERRIDE;
- QSize maximumSize() const Q_DECL_OVERRIDE;
- virtual void setGeometry(const QRect&) Q_DECL_OVERRIDE;
+ Qt::Orientations expandingDirections() const override;
+ QSize minimumSize() const override;
+ QSize maximumSize() const override;
+ virtual void setGeometry(const QRect&) override;
virtual QLayoutItem *itemAt(int index) const = 0;
virtual QLayoutItem *takeAt(int index) = 0;
virtual int indexOf(QWidget *) const;
virtual int count() const = 0;
- bool isEmpty() const Q_DECL_OVERRIDE;
- QSizePolicy::ControlTypes controlTypes() const Q_DECL_OVERRIDE;
+ bool isEmpty() const override;
+ QSizePolicy::ControlTypes controlTypes() const override;
- // ### Qt 6 make this function virtual
- QLayoutItem *replaceWidget(QWidget *from, QWidget *to, Qt::FindChildOptions options = Qt::FindChildrenRecursively);
+ QT6_VIRTUAL QLayoutItem *replaceWidget(QWidget *from, QWidget *to,
+ Qt::FindChildOptions options = Qt::FindChildrenRecursively);
int totalHeightForWidth(int w) const;
QSize totalMinimumSize() const;
QSize totalMaximumSize() const;
QSize totalSizeHint() const;
- QLayout *layout() Q_DECL_OVERRIDE;
+ QLayout *layout() override;
void setEnabled(bool);
bool isEnabled() const;
@@ -143,7 +143,7 @@ public:
protected:
void widgetEvent(QEvent *);
- void childEvent(QChildEvent *e) Q_DECL_OVERRIDE;
+ void childEvent(QChildEvent *e) override;
void addChildLayout(QLayout *l);
void addChildWidget(QWidget *w);
bool adoptLayout(QLayout *layout);
diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp
index 0bdac43c56..5c4fc20687 100644
--- a/src/widgets/kernel/qlayoutitem.cpp
+++ b/src/widgets/kernel/qlayoutitem.cpp
@@ -400,8 +400,8 @@ int QLayoutItem::minimumHeightForWidth(int w) const
/*!
- Returns the preferred height for this layout item, given the width
- \a w.
+ Returns the preferred height for this layout item, given the
+ width, which is not used in this default implementation.
The default implementation returns -1, indicating that the
preferred height is independent of the width of the item. Using
diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp
index 218d3c4a46..c96b6812c4 100644
--- a/src/widgets/kernel/qopenglwidget.cpp
+++ b/src/widgets/kernel/qopenglwidget.cpp
@@ -381,7 +381,7 @@ QT_BEGIN_NAMESPACE
QOpenGLContext. By connecting a slot, using direct connection, to this signal,
it is possible to perform cleanup whenever the the underlying native context
handle, or the entire QOpenGLContext instance, is going to be released. The
- following snippet is in principal equivalent to the previous one:
+ following snippet is in principle equivalent to the previous one:
\snippet code/doc_gui_widgets_qopenglwidget.cpp 5
@@ -536,8 +536,8 @@ public:
: QOpenGLPaintDevicePrivate(QSize()),
w(widget) { }
- void beginPaint() Q_DECL_OVERRIDE;
- void endPaint() Q_DECL_OVERRIDE;
+ void beginPaint() override;
+ void endPaint() override;
QOpenGLWidget *w;
};
@@ -547,7 +547,7 @@ class QOpenGLWidgetPaintDevice : public QOpenGLPaintDevice
public:
QOpenGLWidgetPaintDevice(QOpenGLWidget *widget)
: QOpenGLPaintDevice(*new QOpenGLWidgetPaintDevicePrivate(widget)) { }
- void ensureActiveTarget() Q_DECL_OVERRIDE;
+ void ensureActiveTarget() override;
};
class QOpenGLWidgetPrivate : public QWidgetPrivate
@@ -567,7 +567,8 @@ public:
paintDevice(0),
updateBehavior(QOpenGLWidget::NoPartialUpdate),
requestedSamples(0),
- inPaintGL(false)
+ inPaintGL(false),
+ textureFormat(0)
{
requestedFormat = QSurfaceFormat::defaultFormat();
}
@@ -575,7 +576,8 @@ public:
void reset();
void recreateFbo();
- GLuint textureId() const Q_DECL_OVERRIDE;
+ GLuint textureId() const override;
+ QPlatformTextureList::Flags textureListFlags() override;
void initialize();
void invokeUserPaint();
@@ -583,14 +585,14 @@ public:
void invalidateFbo();
- QImage grabFramebuffer() Q_DECL_OVERRIDE;
- void beginBackingStorePainting() Q_DECL_OVERRIDE { inBackingStorePaint = true; }
- void endBackingStorePainting() Q_DECL_OVERRIDE { inBackingStorePaint = false; }
- void beginCompose() Q_DECL_OVERRIDE;
- void endCompose() Q_DECL_OVERRIDE;
- void initializeViewportFramebuffer() Q_DECL_OVERRIDE;
- void resizeViewportFramebuffer() Q_DECL_OVERRIDE;
- void resolveSamples() Q_DECL_OVERRIDE;
+ QImage grabFramebuffer() override;
+ void beginBackingStorePainting() override { inBackingStorePaint = true; }
+ void endBackingStorePainting() override { inBackingStorePaint = false; }
+ void beginCompose() override;
+ void endCompose() override;
+ void initializeViewportFramebuffer() override;
+ void resizeViewportFramebuffer() override;
+ void resolveSamples() override;
QOpenGLContext *context;
QOpenGLFramebufferObject *fbo;
@@ -606,6 +608,7 @@ public:
QOpenGLWidget::UpdateBehavior updateBehavior;
int requestedSamples;
bool inPaintGL;
+ GLenum textureFormat;
};
void QOpenGLWidgetPaintDevicePrivate::beginPaint()
@@ -663,6 +666,35 @@ GLuint QOpenGLWidgetPrivate::textureId() const
return resolvedFbo ? resolvedFbo->texture() : (fbo ? fbo->texture() : 0);
}
+#ifndef GL_SRGB
+#define GL_SRGB 0x8C40
+#endif
+#ifndef GL_SRGB8
+#define GL_SRGB8 0x8C41
+#endif
+#ifndef GL_SRGB_ALPHA
+#define GL_SRGB_ALPHA 0x8C42
+#endif
+#ifndef GL_SRGB8_ALPHA8
+#define GL_SRGB8_ALPHA8 0x8C43
+#endif
+
+QPlatformTextureList::Flags QOpenGLWidgetPrivate::textureListFlags()
+{
+ QPlatformTextureList::Flags flags = QWidgetPrivate::textureListFlags();
+ switch (textureFormat) {
+ case GL_SRGB:
+ case GL_SRGB8:
+ case GL_SRGB_ALPHA:
+ case GL_SRGB8_ALPHA8:
+ flags |= QPlatformTextureList::TextureIsSrgb;
+ break;
+ default:
+ break;
+ }
+ return flags;
+}
+
void QOpenGLWidgetPrivate::reset()
{
Q_Q(QOpenGLWidget);
@@ -712,12 +744,16 @@ void QOpenGLWidgetPrivate::recreateFbo()
QOpenGLFramebufferObjectFormat format;
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
format.setSamples(samples);
+ if (textureFormat)
+ format.setInternalTextureFormat(textureFormat);
const QSize deviceSize = q->size() * q->devicePixelRatioF();
fbo = new QOpenGLFramebufferObject(deviceSize, format);
if (samples > 0)
resolvedFbo = new QOpenGLFramebufferObject(deviceSize);
+ textureFormat = fbo->format().internalTextureFormat();
+
fbo->bind();
context->functions()->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
@@ -755,10 +791,8 @@ void QOpenGLWidgetPrivate::initialize()
// texture usable by the underlying window's backingstore.
QWidget *tlw = q->window();
QOpenGLContext *shareContext = get(tlw)->shareContext();
- if (Q_UNLIKELY(!shareContext)) {
- qWarning("QOpenGLWidget: Cannot be used without a context shared with the toplevel.");
- return;
- }
+ // If shareContext is null, showing content on-screen will not work.
+ // However, offscreen rendering and grabFramebuffer() will stay fully functional.
// Do not include the sample count. Requesting a multisampled context is not necessary
// since we render into an FBO, never to an actual surface. What's more, attempting to
@@ -768,25 +802,31 @@ void QOpenGLWidgetPrivate::initialize()
requestedFormat.setSamples(0);
QScopedPointer<QOpenGLContext> ctx(new QOpenGLContext);
- ctx->setShareContext(shareContext);
ctx->setFormat(requestedFormat);
- ctx->setScreen(shareContext->screen());
+ if (shareContext) {
+ ctx->setShareContext(shareContext);
+ ctx->setScreen(shareContext->screen());
+ }
if (Q_UNLIKELY(!ctx->create())) {
qWarning("QOpenGLWidget: Failed to create context");
return;
}
- // Propagate settings that make sense only for the tlw.
- QSurfaceFormat tlwFormat = tlw->windowHandle()->format();
- if (requestedFormat.swapInterval() != tlwFormat.swapInterval()) {
- // Most platforms will pick up the changed swap interval on the next
- // makeCurrent or swapBuffers.
- tlwFormat.setSwapInterval(requestedFormat.swapInterval());
- tlw->windowHandle()->setFormat(tlwFormat);
- }
- if (requestedFormat.swapBehavior() != tlwFormat.swapBehavior()) {
- tlwFormat.setSwapBehavior(requestedFormat.swapBehavior());
- tlw->windowHandle()->setFormat(tlwFormat);
+ // Propagate settings that make sense only for the tlw. Note that this only
+ // makes sense for properties that get picked up even after the native
+ // window is created.
+ if (tlw->windowHandle()) {
+ QSurfaceFormat tlwFormat = tlw->windowHandle()->format();
+ if (requestedFormat.swapInterval() != tlwFormat.swapInterval()) {
+ // Most platforms will pick up the changed swap interval on the next
+ // makeCurrent or swapBuffers.
+ tlwFormat.setSwapInterval(requestedFormat.swapInterval());
+ tlw->windowHandle()->setFormat(tlwFormat);
+ }
+ if (requestedFormat.swapBehavior() != tlwFormat.swapBehavior()) {
+ tlwFormat.setSwapBehavior(requestedFormat.swapBehavior());
+ tlw->windowHandle()->setFormat(tlwFormat);
+ }
}
// The top-level window's surface is not good enough since it causes way too
@@ -880,9 +920,14 @@ extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_
QImage QOpenGLWidgetPrivate::grabFramebuffer()
{
Q_Q(QOpenGLWidget);
+
+ initialize();
if (!initialized)
return QImage();
+ if (!fbo) // could be completely offscreen, without ever getting a resize event
+ recreateFbo();
+
if (!inPaintGL)
render();
@@ -1000,7 +1045,6 @@ QOpenGLWidget::UpdateBehavior QOpenGLWidget::updateBehavior() const
*/
void QOpenGLWidget::setFormat(const QSurfaceFormat &format)
{
- Q_UNUSED(format);
Q_D(QOpenGLWidget);
if (Q_UNLIKELY(d->initialized)) {
qWarning("QOpenGLWidget: Already initialized, setting the format has no effect");
@@ -1033,6 +1077,47 @@ QSurfaceFormat QOpenGLWidget::format() const
}
/*!
+ Sets a custom internal texture format of \a texFormat.
+
+ When working with sRGB framebuffers, it will be necessary to specify a
+ format like \c{GL_SRGB8_ALPHA8}. This can be achieved by calling this
+ function.
+
+ \note This function has no effect if called after the widget has already
+ been shown and thus it performed initialization.
+
+ \note This function will typically have to be used in combination with a
+ QSurfaceFormat::setDefaultFormat() call that sets the color space to
+ QSurfaceFormat::sRGBColorSpace.
+
+ \since 5.10
+ */
+void QOpenGLWidget::setTextureFormat(GLenum texFormat)
+{
+ Q_D(QOpenGLWidget);
+ if (Q_UNLIKELY(d->initialized)) {
+ qWarning("QOpenGLWidget: Already initialized, setting the internal texture format has no effect");
+ return;
+ }
+
+ d->textureFormat = texFormat;
+}
+
+/*!
+ \return the active internal texture format if the widget has already
+ initialized, the requested format if one was set but the widget has not yet
+ been made visible, or 0 if setTextureFormat() was not called and the widget
+ has not yet been made visible.
+
+ \since 5.10
+ */
+GLenum QOpenGLWidget::textureFormat() const
+{
+ Q_D(const QOpenGLWidget);
+ return d->textureFormat;
+}
+
+/*!
\return \e true if the widget and OpenGL resources, like the context, have
been successfully initialized. Note that the return value is always false
until the widget is shown.
@@ -1293,7 +1378,7 @@ int QOpenGLWidget::metric(QPaintDevice::PaintDeviceMetric metric) const
if (window)
return int(window->devicePixelRatio() * devicePixelRatioFScale());
else
- return 1.0;
+ return int(devicePixelRatioFScale());
default:
qWarning("QOpenGLWidget::metric(): unknown metric %d", metric);
return 0;
@@ -1344,9 +1429,16 @@ bool QOpenGLWidget::event(QEvent *e)
d->reset();
if (isHidden())
break;
- // FALLTHROUGH
+ Q_FALLTHROUGH();
case QEvent::Show: // reparenting may not lead to a resize so reinitalize on Show too
- if (!d->initialized && !size().isEmpty() && window() && window()->windowHandle()) {
+ if (d->initialized && window()->windowHandle()
+ && d->context->shareContext() != QWidgetPrivate::get(window())->shareContext())
+ {
+ // Special case: did grabFramebuffer() for a hidden widget that then became visible.
+ // Recreate all resources since the context now needs to share with the TLW's.
+ d->reset();
+ }
+ if (!d->initialized && !size().isEmpty() && window()->windowHandle()) {
d->initialize();
if (d->initialized)
d->recreateFbo();
diff --git a/src/widgets/kernel/qopenglwidget.h b/src/widgets/kernel/qopenglwidget.h
index b60d79bedb..9eb4a9ba5a 100644
--- a/src/widgets/kernel/qopenglwidget.h
+++ b/src/widgets/kernel/qopenglwidget.h
@@ -63,7 +63,7 @@ public:
PartialUpdate
};
- explicit QOpenGLWidget(QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
+ explicit QOpenGLWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
~QOpenGLWidget();
void setUpdateBehavior(UpdateBehavior updateBehavior);
@@ -72,6 +72,9 @@ public:
void setFormat(const QSurfaceFormat &format);
QSurfaceFormat format() const;
+ GLenum textureFormat() const;
+ void setTextureFormat(GLenum texFormat);
+
bool isValid() const;
void makeCurrent();
@@ -93,13 +96,13 @@ protected:
virtual void resizeGL(int w, int h);
virtual void paintGL();
- void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
- bool event(QEvent *e) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent *e) override;
+ void resizeEvent(QResizeEvent *e) override;
+ bool event(QEvent *e) override;
- int metric(QPaintDevice::PaintDeviceMetric metric) const Q_DECL_OVERRIDE;
- QPaintDevice *redirected(QPoint *p) const Q_DECL_OVERRIDE;
- QPaintEngine *paintEngine() const Q_DECL_OVERRIDE;
+ int metric(QPaintDevice::PaintDeviceMetric metric) const override;
+ QPaintDevice *redirected(QPoint *p) const override;
+ QPaintEngine *paintEngine() const override;
private:
Q_DISABLE_COPY(QOpenGLWidget)
diff --git a/src/widgets/kernel/qshortcut.h b/src/widgets/kernel/qshortcut.h
index 22c667c9c1..6dcf4971b2 100644
--- a/src/widgets/kernel/qshortcut.h
+++ b/src/widgets/kernel/qshortcut.h
@@ -62,7 +62,7 @@ class Q_WIDGETS_EXPORT QShortcut : public QObject
public:
explicit QShortcut(QWidget *parent);
QShortcut(const QKeySequence& key, QWidget *parent,
- const char *member = Q_NULLPTR, const char *ambiguousMember = Q_NULLPTR,
+ const char *member = nullptr, const char *ambiguousMember = nullptr,
Qt::ShortcutContext context = Qt::WindowShortcut);
~QShortcut();
@@ -91,7 +91,7 @@ Q_SIGNALS:
void activatedAmbiguously();
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
};
#endif // QT_NO_SHORTCUT
diff --git a/src/widgets/kernel/qstackedlayout.cpp b/src/widgets/kernel/qstackedlayout.cpp
index b8b6f4302d..7430d833db 100644
--- a/src/widgets/kernel/qstackedlayout.cpp
+++ b/src/widgets/kernel/qstackedlayout.cpp
@@ -51,7 +51,7 @@ class QStackedLayoutPrivate : public QLayoutPrivate
Q_DECLARE_PUBLIC(QStackedLayout)
public:
QStackedLayoutPrivate() : index(-1), stackingMode(QStackedLayout::StackOne) {}
- QLayoutItem* replaceAt(int index, QLayoutItem *newitem) Q_DECL_OVERRIDE;
+ QLayoutItem* replaceAt(int index, QLayoutItem *newitem) override;
QList<QLayoutItem *> list;
int index;
QStackedLayout::StackingMode stackingMode;
diff --git a/src/widgets/kernel/qstackedlayout.h b/src/widgets/kernel/qstackedlayout.h
index 6f5eded1f0..966ee2aae4 100644
--- a/src/widgets/kernel/qstackedlayout.h
+++ b/src/widgets/kernel/qstackedlayout.h
@@ -75,20 +75,20 @@ public:
int currentIndex() const;
using QLayout::widget;
QWidget *widget(int) const;
- int count() const Q_DECL_OVERRIDE;
+ int count() const override;
StackingMode stackingMode() const;
void setStackingMode(StackingMode stackingMode);
// abstract virtual functions:
- void addItem(QLayoutItem *item) Q_DECL_OVERRIDE;
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSize() const Q_DECL_OVERRIDE;
- QLayoutItem *itemAt(int) const Q_DECL_OVERRIDE;
- QLayoutItem *takeAt(int) Q_DECL_OVERRIDE;
- void setGeometry(const QRect &rect) Q_DECL_OVERRIDE;
- bool hasHeightForWidth() const Q_DECL_OVERRIDE;
- int heightForWidth(int width) const Q_DECL_OVERRIDE;
+ void addItem(QLayoutItem *item) override;
+ QSize sizeHint() const override;
+ QSize minimumSize() const override;
+ QLayoutItem *itemAt(int) const override;
+ QLayoutItem *takeAt(int) override;
+ void setGeometry(const QRect &rect) override;
+ bool hasHeightForWidth() const override;
+ int heightForWidth(int width) const override;
Q_SIGNALS:
void widgetRemoved(int index);
diff --git a/src/widgets/kernel/qstandardgestures_p.h b/src/widgets/kernel/qstandardgestures_p.h
index 9b2cffaa9a..6de09361fe 100644
--- a/src/widgets/kernel/qstandardgestures_p.h
+++ b/src/widgets/kernel/qstandardgestures_p.h
@@ -64,9 +64,9 @@ class QPanGestureRecognizer : public QGestureRecognizer
public:
explicit QPanGestureRecognizer(int pointCount = 2) : m_pointCount(pointCount) {}
- QGesture *create(QObject *target) Q_DECL_OVERRIDE;
- QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event) Q_DECL_OVERRIDE;
- void reset(QGesture *state) Q_DECL_OVERRIDE;
+ QGesture *create(QObject *target) override;
+ QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event) override;
+ void reset(QGesture *state) override;
private:
const int m_pointCount;
@@ -77,9 +77,9 @@ class QPinchGestureRecognizer : public QGestureRecognizer
public:
QPinchGestureRecognizer();
- QGesture *create(QObject *target) Q_DECL_OVERRIDE;
- QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event) Q_DECL_OVERRIDE;
- void reset(QGesture *state) Q_DECL_OVERRIDE;
+ QGesture *create(QObject *target) override;
+ QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event) override;
+ void reset(QGesture *state) override;
};
class QSwipeGestureRecognizer : public QGestureRecognizer
@@ -87,9 +87,9 @@ class QSwipeGestureRecognizer : public QGestureRecognizer
public:
QSwipeGestureRecognizer();
- QGesture *create(QObject *target) Q_DECL_OVERRIDE;
- QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event) Q_DECL_OVERRIDE;
- void reset(QGesture *state) Q_DECL_OVERRIDE;
+ QGesture *create(QObject *target) override;
+ QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event) override;
+ void reset(QGesture *state) override;
};
class QTapGestureRecognizer : public QGestureRecognizer
@@ -97,9 +97,9 @@ class QTapGestureRecognizer : public QGestureRecognizer
public:
QTapGestureRecognizer();
- QGesture *create(QObject *target) Q_DECL_OVERRIDE;
- QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event) Q_DECL_OVERRIDE;
- void reset(QGesture *state) Q_DECL_OVERRIDE;
+ QGesture *create(QObject *target) override;
+ QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event) override;
+ void reset(QGesture *state) override;
};
class QTapAndHoldGestureRecognizer : public QGestureRecognizer
@@ -107,9 +107,9 @@ class QTapAndHoldGestureRecognizer : public QGestureRecognizer
public:
QTapAndHoldGestureRecognizer();
- QGesture *create(QObject *target) Q_DECL_OVERRIDE;
- QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event) Q_DECL_OVERRIDE;
- void reset(QGesture *state) Q_DECL_OVERRIDE;
+ QGesture *create(QObject *target) override;
+ QGestureRecognizer::Result recognize(QGesture *state, QObject *watched, QEvent *event) override;
+ void reset(QGesture *state) override;
};
QT_END_NAMESPACE
diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp
index c2610131f3..69b62ff7d7 100644
--- a/src/widgets/kernel/qtooltip.cpp
+++ b/src/widgets/kernel/qtooltip.cpp
@@ -44,6 +44,7 @@
#include <qapplication.h>
#include <qdesktopwidget.h>
+#include <private/qdesktopwidget_p.h>
#include <qevent.h>
#include <qpointer.h>
#include <qstyle.h>
@@ -126,7 +127,7 @@ public:
~QTipLabel();
static QTipLabel *instance;
- bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE;
+ bool eventFilter(QObject *, QEvent *) override;
QBasicTimer hideTimer, expireTimer;
@@ -142,10 +143,10 @@ public:
static int getTipScreen(const QPoint &pos, QWidget *w);
protected:
- void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
+ void timerEvent(QTimerEvent *e) override;
+ void paintEvent(QPaintEvent *e) override;
+ void mouseMoveEvent(QMouseEvent *e) override;
+ void resizeEvent(QResizeEvent *e) override;
#ifndef QT_NO_STYLE_STYLESHEET
public slots:
@@ -366,10 +367,10 @@ bool QTipLabel::eventFilter(QObject *o, QEvent *e)
int QTipLabel::getTipScreen(const QPoint &pos, QWidget *w)
{
- if (QApplication::desktop()->isVirtualDesktop())
- return QApplication::desktop()->screenNumber(pos);
+ if (QDesktopWidgetPrivate::isVirtualDesktop())
+ return QDesktopWidgetPrivate::screenNumber(pos);
else
- return QApplication::desktop()->screenNumber(w);
+ return QDesktopWidgetPrivate::screenNumber(w);
}
void QTipLabel::placeTip(const QPoint &pos, QWidget *w)
@@ -399,11 +400,11 @@ void QTipLabel::placeTip(const QPoint &pos, QWidget *w)
extern bool qt_mac_app_fullscreen; //qapplication_mac.mm
QRect screen;
if(qt_mac_app_fullscreen)
- screen = QApplication::desktop()->screenGeometry(getTipScreen(pos, w));
+ screen = QDesktopWidgetPrivate::screenGeometry(getTipScreen(pos, w));
else
- screen = QApplication::desktop()->availableGeometry(getTipScreen(pos, w));
+ screen = QDesktopWidgetPrivate::availableGeometry(getTipScreen(pos, w));
#else
- QRect screen = QApplication::desktop()->screenGeometry(getTipScreen(pos, w));
+ QRect screen = QDesktopWidgetPrivate::screenGeometry(getTipScreen(pos, w));
#endif
QPoint p = pos;
@@ -500,7 +501,10 @@ void QToolTip::showText(const QPoint &pos, const QString &text, QWidget *w, cons
#ifdef Q_OS_WIN32
// On windows, we can't use the widget as parent otherwise the window will be
// raised when the tooltip will be shown
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
new QTipLabel(text, QApplication::desktop()->screen(QTipLabel::getTipScreen(pos, w)), msecDisplayTime);
+QT_WARNING_POP
#else
new QTipLabel(text, w, msecDisplayTime); // sets QTipLabel::instance to itself
#endif
diff --git a/src/widgets/kernel/qtooltip.h b/src/widgets/kernel/qtooltip.h
index 5e68eef0a7..edf1de0c1d 100644
--- a/src/widgets/kernel/qtooltip.h
+++ b/src/widgets/kernel/qtooltip.h
@@ -53,7 +53,7 @@ class Q_WIDGETS_EXPORT QToolTip
QToolTip() Q_DECL_EQ_DELETE;
public:
// ### Qt 6 - merge the three showText functions below
- static void showText(const QPoint &pos, const QString &text, QWidget *w = Q_NULLPTR);
+ static void showText(const QPoint &pos, const QString &text, QWidget *w = nullptr);
static void showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect);
static void showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect, int msecShowTime);
static inline void hideText() { showText(QPoint(), QString()); }
diff --git a/src/widgets/kernel/qwhatsthis.cpp b/src/widgets/kernel/qwhatsthis.cpp
index e2cfebb8a1..96d0cf61c4 100644
--- a/src/widgets/kernel/qwhatsthis.cpp
+++ b/src/widgets/kernel/qwhatsthis.cpp
@@ -42,6 +42,7 @@
#include "qapplication.h"
#include <private/qguiapplication_p.h>
#include "qdesktopwidget.h"
+#include <private/qdesktopwidget_p.h>
#include "qevent.h"
#include "qpixmap.h"
#include "qscreen.h"
@@ -144,12 +145,12 @@ public:
static QWhatsThat *instance;
protected:
- void showEvent(QShowEvent *e) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent*) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent*) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent*) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent*) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE;
+ void showEvent(QShowEvent *e) override;
+ void mousePressEvent(QMouseEvent*) override;
+ void mouseReleaseEvent(QMouseEvent*) override;
+ void mouseMoveEvent(QMouseEvent*) override;
+ void keyPressEvent(QKeyEvent*) override;
+ void paintEvent(QPaintEvent*) override;
private:
QPointer<QWidget>widget;
@@ -209,7 +210,7 @@ QWhatsThat::QWhatsThat(const QString& txt, QWidget* parent, QWidget *showTextFor
}
else
{
- int sw = QApplication::desktop()->width() / 3;
+ int sw = QDesktopWidgetPrivate::width() / 3;
if (sw < 200)
sw = 200;
else if (sw > 300)
@@ -364,7 +365,7 @@ class QWhatsThisPrivate : public QObject
QWhatsThisPrivate();
~QWhatsThisPrivate();
static QWhatsThisPrivate *instance;
- bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE;
+ bool eventFilter(QObject *, QEvent *) override;
QPointer<QAction> action;
static void say(QWidget *, const QString &, int x = 0, int y = 0);
static void notifyToplevels(QEvent *e);
@@ -582,14 +583,14 @@ void QWhatsThisPrivate::say(QWidget * widget, const QString &text, int x, int y)
// okay, now to find a suitable location
int scr = (widget ?
- QApplication::desktop()->screenNumber(widget) :
+ QDesktopWidgetPrivate::screenNumber(widget) :
#if 0 /* Used to be included in Qt4 for Q_WS_X11 */ && !defined(QT_NO_CURSOR)
QCursor::x11Screen()
#else
- QApplication::desktop()->screenNumber(QPoint(x,y))
+ QDesktopWidgetPrivate::screenNumber(QPoint(x,y))
#endif
);
- QRect screen = QApplication::desktop()->screenGeometry(scr);
+ QRect screen = QDesktopWidgetPrivate::screenGeometry(scr);
int w = whatsThat->width();
int h = whatsThat->height();
diff --git a/src/widgets/kernel/qwhatsthis.h b/src/widgets/kernel/qwhatsthis.h
index 3211796d3e..1f0f82b2a2 100644
--- a/src/widgets/kernel/qwhatsthis.h
+++ b/src/widgets/kernel/qwhatsthis.h
@@ -59,10 +59,10 @@ public:
static bool inWhatsThisMode();
static void leaveWhatsThisMode();
- static void showText(const QPoint &pos, const QString &text, QWidget *w = Q_NULLPTR);
+ static void showText(const QPoint &pos, const QString &text, QWidget *w = nullptr);
static void hideText();
- static QAction *createAction(QObject *parent = Q_NULLPTR);
+ static QAction *createAction(QObject *parent = nullptr);
};
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 1fea3836ec..74f2dc0c41 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2017 The Qt Company Ltd.
** Copyright (C) 2016 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
@@ -69,7 +69,6 @@
# include <private/qmainwindowlayout_p.h>
#endif
#include <qpa/qplatformwindow.h>
-#include <qpa/qplatformbackingstore.h>
#include "private/qwidgetwindow_p.h"
#include "qpainter.h"
#include "qtooltip.h"
@@ -1106,9 +1105,12 @@ void QWidgetPrivate::adjustFlags(Qt::WindowFlags &flags, QWidget *w)
}
if (customize)
; // don't modify window flags if the user explicitly set them.
- else if (type == Qt::Dialog || type == Qt::Sheet)
- flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint | Qt::WindowCloseButtonHint;
- else if (type == Qt::Tool)
+ else if (type == Qt::Dialog || type == Qt::Sheet) {
+ flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint;
+ // ### fixme: Qt 6: Never set Qt::WindowContextHelpButtonHint flag automatically
+ if (!QApplicationPrivate::testAttribute(Qt::AA_DisableWindowContextHelpButton))
+ flags |= Qt::WindowContextHelpButtonHint;
+ } else if (type == Qt::Tool)
flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint;
else
flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint |
@@ -1153,7 +1155,7 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
if (targetScreen >= 0) {
topData()->initialScreenIndex = targetScreen;
if (QWindow *window = q->windowHandle())
- window->setScreen(QGuiApplication::screens().value(targetScreen, Q_NULLPTR));
+ window->setScreen(QGuiApplication::screens().value(targetScreen, nullptr));
}
data.fstrut_dirty = true;
@@ -1412,7 +1414,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
if (!q->testAttribute(Qt::WA_NativeWindow) && !q->isWindow())
return; // we only care about real toplevels
- QWindow *win = topData()->window;
+ QWidgetWindow *win = topData()->window;
// topData() ensures the extra is created but does not ensure 'window' is non-null
// in case the extra was already valid.
if (!win) {
@@ -1436,7 +1438,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
if (q->testAttribute(Qt::WA_ShowWithoutActivating))
win->setProperty("_q_showWithoutActivating", QVariant(true));
if (q->testAttribute(Qt::WA_MacAlwaysShowToolWindow))
- win->setProperty("_q_macAlwaysShowToolWindow", QVariant::fromValue(QVariant(true)));
+ win->setProperty("_q_macAlwaysShowToolWindow", QVariant(true));
setNetWmWindowTypes(true); // do nothing if none of WA_X11NetWmWindowType* is set
win->setFlags(flags);
fixPosIncludesFrame();
@@ -1450,9 +1452,9 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
topData()->initialScreenIndex = -1;
if (screenNumber < 0) {
screenNumber = q->windowType() != Qt::Desktop
- ? QApplication::desktop()->screenNumber(q) : 0;
+ ? QDesktopWidgetPrivate::screenNumber(q) : 0;
}
- win->setScreen(QGuiApplication::screens().value(screenNumber, Q_NULLPTR));
+ win->setScreen(QGuiApplication::screens().value(screenNumber, nullptr));
}
QSurfaceFormat format = win->requestedFormat();
@@ -1494,7 +1496,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
QBackingStore *store = q->backingStore();
if (!store) {
- if (win && q->windowType() != Qt::Desktop) {
+ if (q->windowType() != Qt::Desktop) {
if (q->isTopLevel())
q->setBackingStore(new QBackingStore(win));
} else {
@@ -1521,7 +1523,7 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
q->setAttribute(Qt::WA_OutsideWSRange, true);
} else if (q->isVisible()) {
// If widget is already shown, set window visible, too
- win->setVisible(true);
+ win->setNativeWindowVisibility(true);
}
}
@@ -1868,39 +1870,15 @@ static void deleteBackingStore(QWidgetPrivate *d)
{
QTLWExtra *topData = d->topData();
- // The context must be current when destroying the backing store as it may attempt to
- // release resources like textures and shader programs. The window may not be suitable
- // anymore as there will often not be a platform window underneath at this stage. Fall
- // back to a QOffscreenSurface in this case.
- QScopedPointer<QOffscreenSurface> tempSurface;
-#ifndef QT_NO_OPENGL
- if (d->textureChildSeen && topData->shareContext) {
- if (topData->window->handle()) {
- topData->shareContext->makeCurrent(topData->window);
- } else {
- tempSurface.reset(new QOffscreenSurface);
- tempSurface->setFormat(topData->shareContext->format());
- tempSurface->create();
- topData->shareContext->makeCurrent(tempSurface.data());
- }
- }
-#endif
-
delete topData->backingStore;
topData->backingStore = 0;
-
-#ifndef QT_NO_OPENGL
- if (d->textureChildSeen && topData->shareContext)
- topData->shareContext->doneCurrent();
-#endif
}
void QWidgetPrivate::deleteTLSysExtra()
{
if (extra && extra->topextra) {
//the qplatformbackingstore may hold a reference to the window, so the backingstore
- //needs to be deleted first. If the backingstore holds GL resources, we need to
- // make the context current here. This is taken care of by deleteBackingStore().
+ //needs to be deleted first.
extra->topextra->backingStoreTracker.destroy();
deleteBackingStore(this);
@@ -2107,14 +2085,15 @@ QRegion QWidgetPrivate::clipRegion() const
return r;
}
-void QWidgetPrivate::setSystemClip(QPaintDevice *paintDevice, const QRegion &region)
+void QWidgetPrivate::setSystemClip(QPaintEngine *paintEngine, qreal devicePixelRatio, const QRegion &region)
{
// Transform the system clip region from device-independent pixels to device pixels
- QPaintEngine *paintEngine = paintDevice->paintEngine();
QTransform scaleTransform;
- const qreal devicePixelRatio = paintDevice->devicePixelRatioF();
scaleTransform.scale(devicePixelRatio, devicePixelRatio);
- paintEngine->d_func()->systemClip = scaleTransform.map(region);
+
+ paintEngine->d_func()->baseSystemClip = region;
+ paintEngine->d_func()->setSystemTransform(scaleTransform);
+
}
#if QT_CONFIG(graphicseffect)
@@ -2643,11 +2622,7 @@ WId QWidget::effectiveWinId() const
QWindow *QWidget::windowHandle() const
{
Q_D(const QWidget);
- QTLWExtra *extra = d->maybeTopData();
- if (extra)
- return extra->window;
-
- return 0;
+ return d->windowHandle();
}
#ifndef QT_NO_STYLE_STYLESHEET
@@ -3042,17 +3017,6 @@ void QWidget::overrideWindowState(Qt::WindowStates newstate)
QApplication::sendEvent(this, &e);
}
-Qt::WindowState effectiveState(Qt::WindowStates state)
-{
- if (state & Qt::WindowMinimized)
- return Qt::WindowMinimized;
- else if (state & Qt::WindowFullScreen)
- return Qt::WindowFullScreen;
- else if (state & Qt::WindowMaximized)
- return Qt::WindowMaximized;
- return Qt::WindowNoState;
-}
-
/*!
\fn void QWidget::setWindowState(Qt::WindowStates windowState)
@@ -3094,19 +3058,17 @@ void QWidget::setWindowState(Qt::WindowStates newstate)
data->window_state = newstate;
data->in_set_window_state = 1;
- Qt::WindowState newEffectiveState = effectiveState(newstate);
- Qt::WindowState oldEffectiveState = effectiveState(oldstate);
- if (isWindow() && newEffectiveState != oldEffectiveState) {
+ if (isWindow()) {
// Ensure the initial size is valid, since we store it as normalGeometry below.
if (!testAttribute(Qt::WA_Resized) && !isVisible())
adjustSize();
d->createTLExtra();
- if (oldEffectiveState == Qt::WindowNoState)
+ if (!(oldstate & (Qt::WindowMinimized | Qt::WindowMaximized | Qt::WindowFullScreen)))
d->topData()->normalGeometry = geometry();
Q_ASSERT(windowHandle());
- windowHandle()->setWindowState(newEffectiveState);
+ windowHandle()->setWindowStates(newstate & ~Qt::WindowActive);
}
data->in_set_window_state = 0;
@@ -4527,7 +4489,7 @@ void QWidget::setForegroundRole(QPalette::ColorRole role)
The default depends on the system environment. QApplication maintains a
system/theme palette which serves as a default for all widgets. There may
also be special palette defaults for certain types of widgets (e.g., on
- Windows XP and Vista, all classes that derive from QMenuBar have a special
+ Windows Vista, all classes that derive from QMenuBar have a special
default palette). You can also define default palettes for widgets
yourself by passing a custom palette and the name of a widget to
QApplication::setPalette(). Finally, the style always has the option of
@@ -4545,8 +4507,8 @@ void QWidget::setForegroundRole(QPalette::ColorRole role)
The current style, which is used to render the content of all standard Qt
widgets, is free to choose colors and brushes from the widget palette, or
in some cases, to ignore the palette (partially, or completely). In
- particular, certain styles like GTK style, Mac style, Windows XP, and
- Vista style, depend on third party APIs to render the content of widgets,
+ particular, certain styles like GTK style, Mac style, and Windows Vista
+ style, depend on third party APIs to render the content of widgets,
and these styles typically do not follow the palette. Because of this,
assigning roles to a widget's palette is not guaranteed to change the
appearance of the widget. Instead, you may choose to apply a \l
@@ -4708,7 +4670,7 @@ void QWidgetPrivate::updateSystemBackground()
The current style, which is used to render the content of all standard Qt
widgets, is free to choose to use the widget font, or in some cases, to
ignore it (partially, or completely). In particular, certain styles like
- GTK style, Mac style, Windows XP, and Vista style, apply special
+ GTK style, Mac style, and Windows Vista style, apply special
modifications to the widget font to match the platform's native look and
feel. Because of this, assigning properties to a widget's font is not
guaranteed to change the appearance of the widget. Instead, you may choose
@@ -5210,6 +5172,7 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset,
// Save current system clip, viewport and transform,
const QTransform oldTransform = enginePriv->systemTransform;
const QRegion oldSystemClip = enginePriv->systemClip;
+ const QRegion oldBaseClip = enginePriv->baseSystemClip;
const QRegion oldSystemViewport = enginePriv->systemViewport;
// This ensures that all painting triggered by render() is clipped to the current engine clip.
@@ -5223,9 +5186,8 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset,
d->render(target, targetOffset, toBePainted, renderFlags);
// Restore system clip, viewport and transform.
- enginePriv->setSystemViewport(oldSystemViewport);
- enginePriv->setSystemTransform(oldTransform);
- enginePriv->systemClip = oldSystemClip;
+ enginePriv->baseSystemClip = oldBaseClip;
+ enginePriv->setSystemTransformAndViewport(oldTransform, oldSystemViewport);
enginePriv->systemStateChanged();
// Restore shared painter.
@@ -5517,12 +5479,12 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
QWidgetPaintContext context(pdev, rgn, offset, flags, sharedPainter, backingStore);
sourced->context = &context;
if (!sharedPainter) {
- setSystemClip(pdev, rgn.translated(offset));
+ setSystemClip(pdev->paintEngine(), pdev->devicePixelRatioF(), rgn.translated(offset));
QPainter p(pdev);
p.translate(offset);
context.painter = context.sharedPainter = &p;
graphicsEffect->draw(&p);
- setSystemClip(pdev, QRegion());
+ setSystemClip(pdev->paintEngine(), 1, QRegion());
} else {
context.painter = context.sharedPainter = sharedPainter;
if (sharedPainter->worldTransform() != sourced->lastEffectTransform) {
@@ -5531,7 +5493,9 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
}
sharedPainter->save();
sharedPainter->translate(offset);
+ setSystemClip(sharedPainter->paintEngine(), sharedPainter->device()->devicePixelRatioF(), rgn.translated(offset));
graphicsEffect->draw(sharedPainter);
+ setSystemClip(sharedPainter->paintEngine(), 1, QRegion());
sharedPainter->restore();
}
sourced->context = 0;
@@ -5583,7 +5547,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
#endif
if (sharedPainter)
- setSystemClip(pdev, toBePainted);
+ setSystemClip(pdev->paintEngine(), pdev->devicePixelRatioF(), toBePainted);
else
paintEngine->d_func()->systemRect = q->data->crect;
@@ -5601,7 +5565,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
}
if (!sharedPainter)
- setSystemClip(pdev, toBePainted.translated(offset));
+ setSystemClip(pdev->paintEngine(), pdev->devicePixelRatioF(), toBePainted.translated(offset));
if (!onScreen && !asRoot && !isOpaque && q->testAttribute(Qt::WA_TintedBackground)) {
#ifndef QT_NO_OPENGL
@@ -5671,7 +5635,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
else
paintEngine->d_func()->currentClipDevice = 0;
- setSystemClip(pdev, QRegion());
+ setSystemClip(pdev->paintEngine(), 1, QRegion());
}
q->setAttribute(Qt::WA_WState_InPaintEvent, false);
if (Q_UNLIKELY(q->paintingActive()))
@@ -6529,9 +6493,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
@@ -6628,6 +6592,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);
@@ -6930,6 +6915,9 @@ bool QWidget::isActiveWindow() const
/*!
Puts the \a second widget after the \a first widget in the focus order.
+ It effectively removes the \a second widget from its focus chain and
+ inserts it after the \a first widget.
+
Note that since the tab order of the \a second widget is changed, you
should order a chain like this:
@@ -6942,11 +6930,19 @@ bool QWidget::isActiveWindow() const
If \a first or \a second has a focus proxy, setTabOrder()
correctly substitutes the proxy.
+ \note Since Qt 5.10: A widget that has a child as focus proxy is understood as
+ a compound widget. When setting a tab order between one or two compound widgets, the
+ local tab order inside each will be preserved. This means that if both widgets are
+ compound widgets, the resulting tab order will be from the last child inside
+ \a first, to the first child inside \a second.
+
\sa setFocusPolicy(), setFocusProxy(), {Keyboard Focus in Widgets}
*/
void QWidget::setTabOrder(QWidget* first, QWidget *second)
{
- if (!first || !second || first->focusPolicy() == Qt::NoFocus || second->focusPolicy() == Qt::NoFocus)
+ if (!first || !second || first == second
+ || first->focusPolicy() == Qt::NoFocus
+ || second->focusPolicy() == Qt::NoFocus)
return;
if (Q_UNLIKELY(first->window() != second->window())) {
@@ -6954,54 +6950,56 @@ void QWidget::setTabOrder(QWidget* first, QWidget *second)
return;
}
- QWidget *fp = first->focusProxy();
- if (fp) {
- // If first is redirected, set first to the last child of first
- // that can take keyboard focus so that second is inserted after
- // that last child, and the focus order within first is (more
- // likely to be) preserved.
- QList<QWidget *> l = first->findChildren<QWidget *>();
- for (int i = l.size()-1; i >= 0; --i) {
- QWidget * next = l.at(i);
- if (next->window() == fp->window()) {
- fp = next;
- if (fp->focusPolicy() != Qt::NoFocus)
- break;
- }
- }
- first = fp;
- }
+ auto determineLastFocusChild = [](QWidget *target, QWidget *&lastFocusChild)
+ {
+ // Since we need to repeat the same logic for both 'first' and 'second', we add a function that
+ // determines the last focus child for a widget, taking proxies and compound widgets into account.
+ // If the target is not a compound widget (it doesn't have a focus proxy that points to a child),
+ // 'lastFocusChild' will be set to the target itself.
+ lastFocusChild = target;
+
+ QWidget *focusProxy = target->d_func()->deepestFocusProxy();
+ if (!focusProxy || !target->isAncestorOf(focusProxy))
+ return;
- if (fp == second)
- return;
+ lastFocusChild = focusProxy;
- if (QWidget *sp = second->focusProxy())
- second = sp;
+ for (QWidget *focusNext = lastFocusChild->d_func()->focus_next;
+ focusNext != focusProxy && target->isAncestorOf(focusNext) && focusNext->window() == focusProxy->window();
+ focusNext = focusNext->d_func()->focus_next) {
+ if (focusNext->focusPolicy() != Qt::NoFocus)
+ lastFocusChild = focusNext;
+ }
+ };
-// QWidget *fp = first->d_func()->focus_prev;
- QWidget *fn = first->d_func()->focus_next;
+ QWidget *lastFocusChildOfFirst, *lastFocusChildOfSecond;
+ determineLastFocusChild(first, lastFocusChildOfFirst);
+ determineLastFocusChild(second, lastFocusChildOfSecond);
- if (fn == second || first == second)
+ // If the tab order is already correct, exit early
+ if (lastFocusChildOfFirst->d_func()->focus_next == second)
return;
- QWidget *sp = second->d_func()->focus_prev;
- QWidget *sn = second->d_func()->focus_next;
-
- fn->d_func()->focus_prev = second;
- first->d_func()->focus_next = second;
-
- second->d_func()->focus_next = fn;
- second->d_func()->focus_prev = first;
+ // Note that we need to handle two different sections in the tab chain; The section
+ // that 'first' belongs to (firstSection), where we are about to insert 'second', and
+ // the section that 'second' used be a part of (secondSection). When we pull 'second'
+ // out of the second section and insert it into the first, we also need to ensure
+ // that we leave the second section in a connected state.
+ QWidget *firstChainOldSecond = lastFocusChildOfFirst->d_func()->focus_next;
+ QWidget *secondChainNewFirst = second->d_func()->focus_prev;
+ QWidget *secondChainNewSecond = lastFocusChildOfSecond->d_func()->focus_next;
- sp->d_func()->focus_next = sn;
- sn->d_func()->focus_prev = sp;
+ // Insert 'second' after 'first'
+ lastFocusChildOfFirst->d_func()->focus_next = second;
+ second->d_func()->focus_prev = lastFocusChildOfFirst;
+ // The widget that used to be 'second' in the first section, should now become 'third'
+ lastFocusChildOfSecond->d_func()->focus_next = firstChainOldSecond;
+ firstChainOldSecond->d_func()->focus_prev = lastFocusChildOfSecond;
- Q_ASSERT(first->d_func()->focus_next->d_func()->focus_prev == first);
- Q_ASSERT(first->d_func()->focus_prev->d_func()->focus_next == first);
-
- Q_ASSERT(second->d_func()->focus_next->d_func()->focus_prev == second);
- Q_ASSERT(second->d_func()->focus_prev->d_func()->focus_next == second);
+ // Repair the second section after we pulled 'second' out of it
+ secondChainNewFirst->d_func()->focus_next = secondChainNewSecond;
+ secondChainNewSecond->d_func()->focus_prev = secondChainNewFirst;
}
/*!\internal
@@ -7173,7 +7171,7 @@ void QWidgetPrivate::fixPosIncludesFrame()
if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
te->posIncludesFrame = 0;
} else {
- if (q->windowHandle()) {
+ if (q->windowHandle() && q->windowHandle()->handle()) {
updateFrameStrut();
if (!q->data->fstrut_dirty) {
data.crect.translate(te->frameStrut.x(), te->frameStrut.y());
@@ -7375,7 +7373,7 @@ QByteArray QWidget::saveGeometry() const
// - Qt 4.8.6 - today, 5.4 - today: Version 2.0, save screen width in addition to check for high DPI scaling.
quint16 majorVersion = 2;
quint16 minorVersion = 0;
- const int screenNumber = QApplication::desktop()->screenNumber(this);
+ const int screenNumber = QDesktopWidgetPrivate::screenNumber(this);
stream << magicNumber
<< majorVersion
<< minorVersion
@@ -7389,7 +7387,7 @@ QByteArray QWidget::saveGeometry() const
<< qint32(screenNumber)
<< quint8(windowState() & Qt::WindowMaximized)
<< quint8(windowState() & Qt::WindowFullScreen)
- << qint32(QApplication::desktop()->screenGeometry(screenNumber).width()); // 1.1 onwards
+ << qint32(QDesktopWidgetPrivate::screenGeometry(screenNumber).width()); // 1.1 onwards
return array;
}
@@ -7455,10 +7453,9 @@ bool QWidget::restoreGeometry(const QByteArray &geometry)
if (majorVersion > 1)
stream >> restoredScreenWidth;
- const QDesktopWidget * const desktop = QApplication::desktop();
- if (restoredScreenNumber >= desktop->numScreens())
- restoredScreenNumber = desktop->primaryScreen();
- const qreal screenWidthF = qreal(desktop->screenGeometry(restoredScreenNumber).width());
+ if (restoredScreenNumber >= QDesktopWidgetPrivate::numScreens())
+ restoredScreenNumber = QDesktopWidgetPrivate::primaryScreen();
+ const qreal screenWidthF = qreal(QDesktopWidgetPrivate::screenGeometry(restoredScreenNumber).width());
// Sanity check bailing out when large variations of screen sizes occur due to
// high DPI scaling or different levels of DPI awareness.
if (restoredScreenWidth) {
@@ -7485,7 +7482,7 @@ bool QWidget::restoreGeometry(const QByteArray &geometry)
.expandedTo(d_func()->adjustedSize()));
}
- const QRect availableGeometry = desktop->availableGeometry(restoredScreenNumber);
+ const QRect availableGeometry = QDesktopWidgetPrivate::availableGeometry(restoredScreenNumber);
// Modify the restored geometry if we are about to restore to coordinates
// that would make the window "lost". This happens if:
@@ -7526,7 +7523,7 @@ bool QWidget::restoreGeometry(const QByteArray &geometry)
// Setting a geometry on an already maximized window causes this to be
// restored into a broken, half-maximized state, non-resizable state (QTBUG-4397).
// Move the window in normal state if needed.
- if (restoredScreenNumber != desktop->screenNumber(this)) {
+ if (restoredScreenNumber != QDesktopWidgetPrivate::screenNumber(this)) {
setWindowState(Qt::WindowNoState);
setGeometry(restoredNormalGeometry);
}
@@ -7988,7 +7985,7 @@ void QWidgetPrivate::show_helper()
const bool isWindow = q->isWindow();
#if QT_CONFIG(graphicsview)
- bool isEmbedded = isWindow && q->graphicsProxyWidget() != Q_NULLPTR;
+ bool isEmbedded = isWindow && q->graphicsProxyWidget() != nullptr;
#else
bool isEmbedded = false;
#endif
@@ -8067,7 +8064,7 @@ void QWidgetPrivate::show_sys()
{
Q_Q(QWidget);
- QWindow *window = q->windowHandle();
+ QWidgetWindow *window = windowHandle();
if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
invalidateBuffer(q->rect());
@@ -8114,7 +8111,7 @@ void QWidgetPrivate::show_sys()
qt_qpa_set_cursor(q, false); // Needed in case cursor was set before show
#endif
invalidateBuffer(q->rect());
- window->setVisible(true);
+ window->setNativeWindowVisibility(true);
// Was the window moved by the Window system or QPlatformWindow::initialGeometry() ?
if (window->isTopLevel()) {
const QPoint crectTopLeft = q->data->crect.topLeft();
@@ -8206,7 +8203,7 @@ void QWidgetPrivate::hide_sys()
{
Q_Q(QWidget);
- QWindow *window = q->windowHandle();
+ QWidgetWindow *window = windowHandle();
if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
q->setAttribute(Qt::WA_Mapped, false);
@@ -8236,7 +8233,7 @@ void QWidgetPrivate::hide_sys()
}
if (window)
- window->setVisible(false);
+ window->setNativeWindowVisibility(false);
}
/*!
@@ -8678,9 +8675,9 @@ QSize QWidgetPrivate::adjustedSize() const
if (exp & Qt::Vertical)
s.setHeight(qMax(s.height(), 100));
#if 0 // Used to be included in Qt4 for Q_WS_X11
- QRect screen = QApplication::desktop()->screenGeometry(q->x11Info().screen());
+ QRect screen = QDesktopWidgetPrivate::screenGeometry(q->x11Info().screen());
#else // all others
- QRect screen = QApplication::desktop()->screenGeometry(q->pos());
+ QRect screen = QDesktopWidgetPrivate::screenGeometry(q->pos());
#endif
s.setWidth(qMin(s.width(), screen.width()*2/3));
s.setHeight(qMin(s.height(), screen.height()*2/3));
@@ -10113,6 +10110,7 @@ void QWidget::hideEvent(QHideEvent *)
\table
\header \li Platform \li Event Type Identifier \li Message Type \li Result Type
\row \li Windows \li "windows_generic_MSG" \li MSG * \li LRESULT
+ \row \li macOS \li "NSEvent" \li NSEvent * \li
\endtable
*/
@@ -10823,7 +10821,7 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
f |= Qt::Window;
if (targetScreen == -1) {
if (parent)
- targetScreen = QApplication::desktop()->screenNumber(q->parentWidget()->window());
+ targetScreen = QDesktopWidgetPrivate::screenNumber(q->parentWidget()->window());
}
}
@@ -11222,10 +11220,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
case Qt::WA_NoChildEventsFromChildren:
d->receiveChildEvents = !on;
break;
- case Qt::WA_MacBrushedMetal:
#if 0 // Used to be included in Qt4 for Q_WS_MAC
- d->setStyle_helper(style(), false, true); // Make sure things get unpolished/polished correctly.
- // fall through since changing the metal attribute affects the opaque size grip.
case Qt::WA_MacOpaqueSizeGrip:
d->macUpdateOpaqueSizeGrip();
break;
@@ -11238,12 +11233,10 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
case Qt::WA_Hover:
qt_mac_update_mouseTracking(this);
break;
-#endif
case Qt::WA_MacAlwaysShowToolWindow:
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
d->macUpdateHideOnSuspend();
-#endif
break;
+#endif
case Qt::WA_MacNormalSize:
case Qt::WA_MacSmallSize:
case Qt::WA_MacMiniSize:
@@ -12310,10 +12303,9 @@ QOpenGLContext *QWidgetPrivate::shareContext() const
#ifdef QT_NO_OPENGL
return 0;
#else
- if (Q_UNLIKELY(!extra || !extra->topextra || !extra->topextra->window)) {
- qWarning("Asking for share context for widget that does not have a window handle");
+ if (Q_UNLIKELY(!extra || !extra->topextra || !extra->topextra->window))
return 0;
- }
+
QWidgetPrivate *that = const_cast<QWidgetPrivate *>(this);
if (!extra->topextra->shareContext) {
QOpenGLContext *ctx = new QOpenGLContext;
@@ -12509,7 +12501,7 @@ static inline bool canMapPosition(QWindow *window)
#if QT_CONFIG(graphicsview)
static inline QGraphicsProxyWidget *graphicsProxyWidget(const QWidget *w)
{
- QGraphicsProxyWidget *result = Q_NULLPTR;
+ QGraphicsProxyWidget *result = nullptr;
const QWidgetPrivate *d = qt_widget_private(const_cast<QWidget *>(w));
if (d->extra)
result = d->extra->proxyWidget;
@@ -12525,7 +12517,7 @@ struct MapToGlobalTransformResult {
static MapToGlobalTransformResult mapToGlobalTransform(const QWidget *w)
{
MapToGlobalTransformResult result;
- result.window = Q_NULLPTR;
+ result.window = nullptr;
for ( ; w ; w = w->parentWidget()) {
#if QT_CONFIG(graphicsview)
if (QGraphicsProxyWidget *qgpw = graphicsProxyWidget(w)) {
diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h
index 732af4de09..5087d330ee 100644
--- a/src/widgets/kernel/qwidget.h
+++ b/src/widgets/kernel/qwidget.h
@@ -211,10 +211,10 @@ public:
};
Q_DECLARE_FLAGS(RenderFlags, RenderFlag)
- explicit QWidget(QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
+ explicit QWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
~QWidget();
- int devType() const Q_DECL_OVERRIDE;
+ int devType() const override;
WId winId() const;
void createWinId(); // internal, going away
@@ -578,7 +578,7 @@ public:
void setAttribute(Qt::WidgetAttribute, bool on = true);
inline bool testAttribute(Qt::WidgetAttribute) const;
- QPaintEngine *paintEngine() const Q_DECL_OVERRIDE;
+ QPaintEngine *paintEngine() const override;
void ensurePolished() const;
@@ -596,7 +596,7 @@ public:
QWindow *windowHandle() const;
- static QWidget *createWindowContainer(QWindow *window, QWidget *parent=Q_NULLPTR, Qt::WindowFlags flags=Qt::WindowFlags());
+ static QWidget *createWindowContainer(QWindow *window, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags());
friend class QDesktopScreenWidget;
@@ -608,7 +608,7 @@ Q_SIGNALS:
protected:
// Event handlers
- bool event(QEvent *event) Q_DECL_OVERRIDE;
+ bool event(QEvent *event) override;
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
virtual void mouseDoubleClickEvent(QMouseEvent *event);
@@ -650,10 +650,10 @@ protected:
// Misc. protected functions
virtual void changeEvent(QEvent *);
- int metric(PaintDeviceMetric) const Q_DECL_OVERRIDE;
- void initPainter(QPainter *painter) const Q_DECL_OVERRIDE;
- QPaintDevice *redirected(QPoint *offset) const Q_DECL_OVERRIDE;
- QPainter *sharedPainter() const Q_DECL_OVERRIDE;
+ int metric(PaintDeviceMetric) const override;
+ void initPainter(QPainter *painter) const override;
+ QPaintDevice *redirected(QPoint *offset) const override;
+ QPainter *sharedPainter() const override;
virtual void inputMethodEvent(QInputMethodEvent *);
public:
@@ -738,12 +738,12 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QWidget::RenderFlags)
#ifndef Q_QDOC
template <> inline QWidget *qobject_cast<QWidget*>(QObject *o)
{
- if (!o || !o->isWidgetType()) return Q_NULLPTR;
+ if (!o || !o->isWidgetType()) return nullptr;
return static_cast<QWidget*>(o);
}
template <> inline const QWidget *qobject_cast<const QWidget*>(const QObject *o)
{
- if (!o || !o->isWidgetType()) return Q_NULLPTR;
+ if (!o || !o->isWidgetType()) return nullptr;
return static_cast<const QWidget*>(o);
}
#endif // !Q_QDOC
diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h
index 15704f32c9..a9c73c6a26 100644
--- a/src/widgets/kernel/qwidget_p.h
+++ b/src/widgets/kernel/qwidget_p.h
@@ -73,19 +73,20 @@
#include "QtWidgets/qgraphicsview.h"
#endif
#include <private/qgesture_p.h>
+#include <qpa/qplatformbackingstore.h>
QT_BEGIN_NAMESPACE
// Extra QWidget data
// - to minimize memory usage for members that are seldom used.
// - top-level widgets have extra extra data to reduce cost further
+class QWidgetWindow;
class QPaintEngine;
class QPixmap;
class QWidgetBackingStore;
class QGraphicsProxyWidget;
class QWidgetItemV2;
class QOpenGLContext;
-class QPlatformTextureList;
class QStyle;
@@ -164,7 +165,7 @@ struct QTLWExtra {
QWidgetBackingStoreTracker backingStoreTracker;
QBackingStore *backingStore;
QPainter *sharedPainter;
- QWindow *window;
+ QWidgetWindow *window;
QOpenGLContext *shareContext;
// Implicit pointers (shared_null).
@@ -342,6 +343,7 @@ public:
QPainter *sharedPainter() const;
void setSharedPainter(QPainter *painter);
QWidgetBackingStore *maybeBackingStore() const;
+ QWidgetWindow *windowHandle() const;
template <typename T>
void repaint(T t);
@@ -374,6 +376,7 @@ public:
void lower_sys();
void stackUnder_sys(QWidget *);
+ QWidget *deepestFocusProxy() const;
void setFocus_sys();
void updateFocusChild();
@@ -420,7 +423,7 @@ public:
QRect clipRect() const;
QRegion clipRegion() const;
- void setSystemClip(QPaintDevice *paintDevice, const QRegion &region);
+ void setSystemClip(QPaintEngine *paintEngine, qreal devicePixelRatio, const QRegion &region);
void subtractOpaqueChildren(QRegion &rgn, const QRect &clipRect) const;
void subtractOpaqueSiblings(QRegion &source, bool *hasDirtySiblingsAbove = 0,
bool alsoNonOpaque = false) const;
@@ -644,6 +647,12 @@ public:
#ifndef QT_NO_OPENGL
virtual GLuint textureId() const { return 0; }
+ virtual QPlatformTextureList::Flags textureListFlags() {
+ Q_Q(QWidget);
+ return q->testAttribute(Qt::WA_AlwaysStackOnTop)
+ ? QPlatformTextureList::StacksOnTop
+ : QPlatformTextureList::Flags(0);
+ }
virtual QImage grabFramebuffer() { return QImage(); }
virtual void beginBackingStorePainting() { }
virtual void endBackingStorePainting() { }
@@ -904,26 +913,26 @@ public:
: QGraphicsEffectSourcePrivate(), m_widget(widget), context(0), updateDueToGraphicsEffect(false)
{}
- void detach() Q_DECL_OVERRIDE
+ void detach() override
{ m_widget->d_func()->graphicsEffect = 0; }
- const QGraphicsItem *graphicsItem() const Q_DECL_OVERRIDE
+ const QGraphicsItem *graphicsItem() const override
{ return 0; }
- const QWidget *widget() const Q_DECL_OVERRIDE
+ const QWidget *widget() const override
{ return m_widget; }
- void update() Q_DECL_OVERRIDE
+ void update() override
{
updateDueToGraphicsEffect = true;
m_widget->update();
updateDueToGraphicsEffect = false;
}
- bool isPixmap() const Q_DECL_OVERRIDE
+ bool isPixmap() const override
{ return false; }
- void effectBoundingRectChanged() Q_DECL_OVERRIDE
+ void effectBoundingRectChanged() override
{
// ### This function should take a rect parameter; then we can avoid
// updating too much on the parent widget.
@@ -933,16 +942,16 @@ public:
update();
}
- const QStyleOption *styleOption() const Q_DECL_OVERRIDE
+ const QStyleOption *styleOption() const override
{ return 0; }
- QRect deviceRect() const Q_DECL_OVERRIDE
+ QRect deviceRect() const override
{ return m_widget->window()->rect(); }
- QRectF boundingRect(Qt::CoordinateSystem system) const Q_DECL_OVERRIDE;
- void draw(QPainter *p) Q_DECL_OVERRIDE;
+ QRectF boundingRect(Qt::CoordinateSystem system) const override;
+ void draw(QPainter *p) override;
QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset,
- QGraphicsEffect::PixmapPadMode mode) const Q_DECL_OVERRIDE;
+ QGraphicsEffect::PixmapPadMode mode) const override;
QWidget *m_widget;
QWidgetPaintContext *context;
@@ -995,6 +1004,13 @@ inline QWidgetBackingStore *QWidgetPrivate::maybeBackingStore() const
return x ? x->backingStoreTracker.data() : 0;
}
+inline QWidgetWindow *QWidgetPrivate::windowHandle() const
+{
+ if (QTLWExtra *x = maybeTopData())
+ return x->window;
+ return nullptr;
+}
+
QT_END_NAMESPACE
#endif // QWIDGET_P_H
diff --git a/src/widgets/kernel/qwidgetaction.h b/src/widgets/kernel/qwidgetaction.h
index 3da691a430..4769332a23 100644
--- a/src/widgets/kernel/qwidgetaction.h
+++ b/src/widgets/kernel/qwidgetaction.h
@@ -66,8 +66,8 @@ public:
void releaseWidget(QWidget *widget);
protected:
- virtual bool event(QEvent *) Q_DECL_OVERRIDE;
- virtual bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE;
+ virtual bool event(QEvent *) override;
+ virtual bool eventFilter(QObject *, QEvent *) override;
virtual QWidget *createWidget(QWidget *parent);
virtual void deleteWidget(QWidget *widget);
QList<QWidget *> createdWidgets() const;
diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp
index 57564ce477..3b093283cd 100644
--- a/src/widgets/kernel/qwidgetbackingstore.cpp
+++ b/src/widgets/kernel/qwidgetbackingstore.cpp
@@ -77,11 +77,10 @@ Q_GLOBAL_STATIC(QPlatformTextureList, qt_dummy_platformTextureList)
/**
* Flushes the contents of the \a backingStore into the screen area of \a widget.
- * \a tlwOffset is the position of the top level widget relative to the window surface.
* \a region is the region to be updated in \a widget coordinates.
*/
void QWidgetBackingStore::qt_flush(QWidget *widget, const QRegion &region, QBackingStore *backingStore,
- QWidget *tlw, const QPoint &tlwOffset, QPlatformTextureList *widgetTextures,
+ QWidget *tlw, QPlatformTextureList *widgetTextures,
QWidgetBackingStore *widgetBackingStore)
{
#ifdef QT_NO_OPENGL
@@ -112,7 +111,7 @@ void QWidgetBackingStore::qt_flush(QWidget *widget, const QRegion &region, QBack
}
}
- QPoint offset = tlwOffset;
+ QPoint offset;
if (widget != tlw)
offset += widget->mapTo(tlw, QPoint());
@@ -144,10 +143,8 @@ void QWidgetBackingStore::qt_flush(QWidget *widget, const QRegion &region, QBack
// WA_TranslucentBackground. Therefore the compositor needs to know whether the app intends
// to rely on translucency, in order to decide if it should clear to transparent or opaque.
const bool translucentBackground = widget->testAttribute(Qt::WA_TranslucentBackground);
- // Use the tlw's context, not widget's. The difference is important with native child
- // widgets where tlw != widget.
- backingStore->handle()->composeAndFlush(widget->windowHandle(), effectiveRegion, offset, widgetTextures,
- tlw->d_func()->shareContext(), translucentBackground);
+ backingStore->handle()->composeAndFlush(widget->windowHandle(), effectiveRegion, offset,
+ widgetTextures, translucentBackground);
widget->window()->d_func()->sendComposeStatus(widget->window(), true);
} else
#endif
@@ -288,8 +285,7 @@ void QWidgetBackingStore::unflushPaint(QWidget *widget, const QRegion &rgn)
if (!tlwExtra)
return;
- const QPoint offset = widget->mapTo(tlw, QPoint());
- qt_flush(widget, rgn, tlwExtra->backingStoreTracker->store, tlw, offset, 0, tlw->d_func()->maybeBackingStore());
+ qt_flush(widget, rgn, tlwExtra->backingStoreTracker->store, tlw, 0, tlw->d_func()->maybeBackingStore());
}
#endif // QT_NO_PAINT_DEBUG
@@ -299,7 +295,7 @@ void QWidgetBackingStore::unflushPaint(QWidget *widget, const QRegion &rgn)
*/
bool QWidgetBackingStore::bltRect(const QRect &rect, int dx, int dy, QWidget *widget)
{
- const QPoint pos(tlwOffset + widget->mapTo(tlw, rect.topLeft()));
+ const QPoint pos(widget->mapTo(tlw, rect.topLeft()));
const QRect tlwRect(QRect(pos, rect.size()));
if (dirty.intersects(tlwRect))
return false; // We don't want to scroll junk.
@@ -949,9 +945,7 @@ static void findTextureWidgetsRecursively(QWidget *tlw, QWidget *widget, QPlatfo
{
QWidgetPrivate *wd = QWidgetPrivate::get(widget);
if (wd->renderToTexture) {
- QPlatformTextureList::Flags flags = 0;
- if (widget->testAttribute(Qt::WA_AlwaysStackOnTop))
- flags |= QPlatformTextureList::StacksOnTop;
+ QPlatformTextureList::Flags flags = wd->textureListFlags();
const QRect rect(widget->mapTo(tlw, QPoint()), widget->size());
widgetTextures->appendTexture(widget, wd->textureId(), rect, wd->clipRect(), flags);
}
@@ -1064,7 +1058,7 @@ static QPlatformTextureList *widgetTexturesFor(QWidget *tlw, QWidget *widget)
{
Q_UNUSED(tlw);
Q_UNUSED(widget);
- return Q_NULLPTR;
+ return nullptr;
}
#endif // QT_NO_OPENGL
@@ -1123,7 +1117,7 @@ void QWidgetBackingStore::sync(QWidget *exposedWidget, const QRegion &exposedReg
// Nothing to repaint.
if (!isDirty() && store->size().isValid()) {
QPlatformTextureList *tl = widgetTexturesFor(tlw, exposedWidget);
- qt_flush(exposedWidget, tl ? QRegion() : exposedRegion, store, tlw, tlwOffset, tl, this);
+ qt_flush(exposedWidget, tl ? QRegion() : exposedRegion, store, tlw, tl, this);
return;
}
@@ -1369,7 +1363,7 @@ void QWidgetBackingStore::doSync()
QRegion toBePainted(wd->dirty);
resetWidget(w);
- QPoint offset(tlwOffset);
+ QPoint offset;
if (w != tlw)
offset += w->mapTo(tlw, QPoint());
wd->drawWidget(store->paintDevice(), toBePainted, offset, flags, 0, this);
@@ -1378,7 +1372,7 @@ void QWidgetBackingStore::doSync()
// Paint the rest with composition.
if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
const int flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
- tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, tlwOffset, flags, 0, this);
+ tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, 0, this);
}
endPaint(toClean, store, &beginPaintInfo);
@@ -1397,7 +1391,7 @@ void QWidgetBackingStore::flush(QWidget *widget)
// Flush the region in dirtyOnScreen.
if (!dirtyOnScreen.isEmpty()) {
QWidget *target = widget ? widget : tlw;
- qt_flush(target, dirtyOnScreen, store, tlw, tlwOffset, widgetTexturesFor(tlw, tlw), this);
+ qt_flush(target, dirtyOnScreen, store, tlw, widgetTexturesFor(tlw, tlw), this);
dirtyOnScreen = QRegion();
flushed = true;
}
@@ -1409,7 +1403,7 @@ void QWidgetBackingStore::flush(QWidget *widget)
QPlatformTextureList *tl = widgetTexturesFor(tlw, tlw);
if (tl) {
QWidget *target = widget ? widget : tlw;
- qt_flush(target, QRegion(), store, tlw, tlwOffset, tl, this);
+ qt_flush(target, QRegion(), store, tlw, tl, this);
}
}
#endif
@@ -1423,7 +1417,7 @@ void QWidgetBackingStore::flush(QWidget *widget)
QWidgetPrivate *wd = w->d_func();
Q_ASSERT(wd->needsFlush);
QPlatformTextureList *widgetTexturesForNative = wd->textureChildSeen ? widgetTexturesFor(tlw, w) : 0;
- qt_flush(w, *wd->needsFlush, store, tlw, tlwOffset, widgetTexturesForNative, this);
+ qt_flush(w, *wd->needsFlush, store, tlw, widgetTexturesForNative, this);
*wd->needsFlush = QRegion();
}
dirtyOnScreenWidgets->clear();
diff --git a/src/widgets/kernel/qwidgetbackingstore_p.h b/src/widgets/kernel/qwidgetbackingstore_p.h
index fa51cb71de..53ccda850a 100644
--- a/src/widgets/kernel/qwidgetbackingstore_p.h
+++ b/src/widgets/kernel/qwidgetbackingstore_p.h
@@ -111,8 +111,6 @@ public:
void sync();
void flush(QWidget *widget = 0);
- inline QPoint topLevelOffset() const { return tlwOffset; }
-
QBackingStore *backingStore() const { return store; }
inline bool isDirty() const
@@ -138,8 +136,6 @@ private:
QBackingStore *store;
uint updateRequestSent : 1;
- QPoint tlwOffset;
-
QPlatformTextureListWatcher *textureListWatcher;
QElapsedTimer perfTime;
int perfFrames;
@@ -149,7 +145,7 @@ private:
static bool flushPaint(QWidget *widget, const QRegion &rgn);
static void unflushPaint(QWidget *widget, const QRegion &rgn);
static void qt_flush(QWidget *widget, const QRegion &region, QBackingStore *backingStore,
- QWidget *tlw, const QPoint &tlwOffset,
+ QWidget *tlw,
QPlatformTextureList *widgetTextures,
QWidgetBackingStore *widgetBackingStore);
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 165dce04e9..1078652234 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets();
-QWidget *qt_button_down = 0; // widget got last button-down
+Q_WIDGETS_EXPORT QWidget *qt_button_down = 0; // widget got last button-down
// popup control
QWidget *qt_popup_down = 0; // popup that contains the pressed widget
@@ -69,7 +69,16 @@ class QWidgetWindowPrivate : public QWindowPrivate
{
Q_DECLARE_PUBLIC(QWidgetWindow)
public:
- QWindow *eventReceiver() Q_DECL_OVERRIDE {
+ void setVisible(bool visible) override
+ {
+ Q_Q(QWidgetWindow);
+ if (QWidget *widget = q->widget())
+ widget->setVisible(visible);
+ else
+ QWindowPrivate::setVisible(visible);
+ }
+
+ QWindow *eventReceiver() override {
Q_Q(QWidgetWindow);
QWindow *w = q;
while (w->parent() && qobject_cast<QWidgetWindow *>(w) && qobject_cast<QWidgetWindow *>(w->parent())) {
@@ -78,7 +87,7 @@ public:
return w;
}
- void clearFocusObject() Q_DECL_OVERRIDE
+ void clearFocusObject() override
{
Q_Q(QWidgetWindow);
QWidget *widget = q->widget();
@@ -86,7 +95,10 @@ public:
widget->focusWidget()->clearFocus();
}
- QRectF closestAcceptableGeometry(const QRectF &rect) const Q_DECL_OVERRIDE;
+ QRectF closestAcceptableGeometry(const QRectF &rect) const override;
+#if QT_CONFIG(opengl)
+ QOpenGLContext *shareContext() const override;
+#endif
void processSafeAreaMarginsChanged() override
{
@@ -125,6 +137,15 @@ QRectF QWidgetWindowPrivate::closestAcceptableGeometry(const QRectF &rect) const
return result;
}
+#if QT_CONFIG(opengl)
+QOpenGLContext *QWidgetWindowPrivate::shareContext() const
+{
+ Q_Q(const QWidgetWindow);
+ const QWidgetPrivate *widgetPrivate = QWidgetPrivate::get(q->widget());
+ return widgetPrivate->shareContext();
+}
+#endif // opengl
+
QWidgetWindow::QWidgetWindow(QWidget *widget)
: QWindow(*new QWidgetWindowPrivate(), 0)
, m_widget(widget)
@@ -157,7 +178,7 @@ QObject *QWidgetWindow::focusObject() const
{
QWidget *windowWidget = m_widget;
if (!windowWidget)
- return Q_NULLPTR;
+ return nullptr;
// A window can't have a focus object if it's being destroyed.
if (QWidgetPrivate::get(windowWidget)->data.in_destructor)
@@ -175,6 +196,15 @@ QObject *QWidgetWindow::focusObject() const
return widget;
}
+void QWidgetWindow::setNativeWindowVisibility(bool visible)
+{
+ Q_D(QWidgetWindow);
+ // Call base class setVisible() implementation to run the QWindow
+ // visibility logic. Don't call QWidgetWindowPrivate::setVisible()
+ // since that will recurse back into QWidget code.
+ d->QWindowPrivate::setVisible(visible);
+}
+
static inline bool shouldBePropagatedToWidget(QEvent *event)
{
switch (event->type()) {
@@ -201,7 +231,7 @@ bool QWidgetWindow::event(QEvent *event)
// generated before WA_DontShowOnScreen was set
if (!shouldBePropagatedToWidget(event))
return true;
- return QCoreApplication::sendEvent(m_widget, event);
+ return QCoreApplication::forwardEvent(m_widget, event);
}
switch (event->type()) {
@@ -218,7 +248,7 @@ bool QWidgetWindow::event(QEvent *event)
// are sent by QApplicationPrivate::notifyActiveWindowChange()
case QEvent::FocusIn:
handleFocusInEvent(static_cast<QFocusEvent *>(event));
- // Fallthrough
+ Q_FALLTHROUGH();
case QEvent::FocusOut: {
#ifndef QT_NO_ACCESSIBILITY
QAccessible::State state;
@@ -233,7 +263,7 @@ bool QWidgetWindow::event(QEvent *event)
if (QApplicationPrivate::focus_widget->testAttribute(Qt::WA_InputMethodEnabled))
QGuiApplication::inputMethod()->commit();
- QGuiApplication::sendSpontaneousEvent(QApplicationPrivate::focus_widget, event);
+ QGuiApplication::forwardEvent(QApplicationPrivate::focus_widget, event);
}
return true;
@@ -302,7 +332,7 @@ bool QWidgetWindow::event(QEvent *event)
case QEvent::ThemeChange: {
QEvent widgetEvent(QEvent::ThemeChange);
- QGuiApplication::sendSpontaneousEvent(m_widget, &widgetEvent);
+ QCoreApplication::forwardEvent(m_widget, &widgetEvent, event);
}
return true;
@@ -340,7 +370,7 @@ bool QWidgetWindow::event(QEvent *event)
break;
}
- if (shouldBePropagatedToWidget(event) && QCoreApplication::sendEvent(m_widget, event))
+ if (shouldBePropagatedToWidget(event) && QCoreApplication::forwardEvent(m_widget, event))
return true;
return QWindow::event(event);
@@ -399,7 +429,7 @@ void QWidgetWindow::handleEnterLeaveEvent(QEvent *event)
const QEnterEvent *ee = static_cast<QEnterEvent *>(event);
QWidget *child = m_widget->childAt(ee->pos());
QWidget *receiver = child ? child : m_widget.data();
- QWidget *leave = Q_NULLPTR;
+ QWidget *leave = nullptr;
if (QApplicationPrivate::inPopupMode() && receiver == m_widget
&& qt_last_mouse_receiver != m_widget) {
// This allows to deliver the leave event to the native widget
@@ -449,7 +479,7 @@ void QWidgetWindow::handleFocusInEvent(QFocusEvent *e)
void QWidgetWindow::handleNonClientAreaMouseEvent(QMouseEvent *e)
{
- QApplication::sendSpontaneousEvent(m_widget, e);
+ QApplication::forwardEvent(m_widget, e);
}
void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
@@ -506,22 +536,25 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
// Prevent negative mouse position on enter event - this event
// should be properly handled in "handleEnterLeaveEvent()".
if (receiverMapped.x() >= 0 && receiverMapped.y() >= 0) {
- QApplicationPrivate::dispatchEnterLeave(receiver, Q_NULLPTR, event->screenPos());
+ QApplicationPrivate::dispatchEnterLeave(receiver, nullptr, event->screenPos());
qt_last_mouse_receiver = receiver;
}
} else {
- QApplicationPrivate::dispatchEnterLeave(Q_NULLPTR, qt_last_mouse_receiver, event->screenPos());
+ QApplicationPrivate::dispatchEnterLeave(nullptr, qt_last_mouse_receiver, event->screenPos());
qt_last_mouse_receiver = receiver;
receiver = activePopupWidget;
}
}
#endif
-
- QMouseEvent e(event->type(), widgetPos, event->windowPos(), event->screenPos(),
- event->button(), event->buttons(), event->modifiers(), event->source());
- e.setTimestamp(event->timestamp());
- QApplicationPrivate::sendMouseEvent(receiver, &e, receiver, receiver->window(), &qt_button_down, qt_last_mouse_receiver);
- qt_last_mouse_receiver = receiver;
+ if ((event->type() != QEvent::MouseButtonPress)
+ || !(event->flags().testFlag(Qt::MouseEventCreatedDoubleClick))) {
+
+ QMouseEvent e(event->type(), widgetPos, event->windowPos(), event->screenPos(),
+ event->button(), event->buttons(), event->modifiers(), event->source());
+ e.setTimestamp(event->timestamp());
+ QApplicationPrivate::sendMouseEvent(receiver, &e, receiver, receiver->window(), &qt_button_down, qt_last_mouse_receiver);
+ qt_last_mouse_receiver = receiver;
+ }
} else {
// close disabled popups when a mouse button is pressed or released
switch (event->type()) {
@@ -574,13 +607,13 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
} else if (event->type() == contextMenuTrigger
&& event->button() == Qt::RightButton
&& (openPopupCount == oldOpenPopupCount)) {
- QWidget *popupEvent = activePopupWidget;
+ QWidget *receiver = activePopupWidget;
if (qt_button_down)
- popupEvent = qt_button_down;
+ receiver = qt_button_down;
else if(popupChild)
- popupEvent = popupChild;
+ receiver = popupChild;
QContextMenuEvent e(QContextMenuEvent::Mouse, mapped, event->globalPos(), event->modifiers());
- QApplication::sendSpontaneousEvent(popupEvent, &e);
+ QApplication::forwardEvent(receiver, &e, event);
}
#else
Q_UNUSED(contextMenuTrigger)
@@ -611,12 +644,9 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
QWidget *receiver = QApplicationPrivate::pickMouseReceiver(m_widget, event->windowPos().toPoint(), &mapped, event->type(), event->buttons(),
qt_button_down, widget);
-
- if (!receiver) {
- if (event->type() == QEvent::MouseButtonRelease)
- QApplicationPrivate::mouse_buttons &= ~event->button();
+ if (!receiver)
return;
- }
+
if ((event->type() != QEvent::MouseButtonPress)
|| !(event->flags().testFlag(Qt::MouseEventCreatedDoubleClick))) {
@@ -633,7 +663,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
if (event->type() == contextMenuTrigger && event->button() == Qt::RightButton
&& m_widget->rect().contains(event->pos())) {
QContextMenuEvent e(QContextMenuEvent::Mouse, mapped, event->globalPos(), event->modifiers());
- QGuiApplication::sendSpontaneousEvent(receiver, &e);
+ QGuiApplication::forwardEvent(receiver, &e, event);
}
#endif
}
@@ -665,7 +695,7 @@ void QWidgetWindow::handleKeyEvent(QKeyEvent *event)
}
if (!receiver)
receiver = focusObject();
- QGuiApplication::sendSpontaneousEvent(receiver, event);
+ QGuiApplication::forwardEvent(receiver, event);
}
bool QWidgetWindow::updateSize()
@@ -737,8 +767,6 @@ void QWidgetWindow::repaintWindow()
QWidgetBackingStore::UpdateNow, QWidgetBackingStore::BufferInvalid);
}
-Qt::WindowState effectiveState(Qt::WindowStates state);
-
// Store normal geometry used for saving application settings.
void QWidgetWindow::updateNormalGeometry()
{
@@ -749,7 +777,7 @@ void QWidgetWindow::updateNormalGeometry()
QRect normalGeometry;
if (const QPlatformWindow *pw = handle())
normalGeometry = QHighDpi::fromNativePixels(pw->normalGeometry(), this);
- if (!normalGeometry.isValid() && effectiveState(m_widget->windowState()) == Qt::WindowNoState)
+ if (!normalGeometry.isValid() && !(m_widget->windowState() & ~Qt::WindowActive))
normalGeometry = m_widget->geometry();
if (normalGeometry.isValid())
tle->normalGeometry = normalGeometry;
@@ -758,7 +786,7 @@ void QWidgetWindow::updateNormalGeometry()
void QWidgetWindow::handleMoveEvent(QMoveEvent *event)
{
if (updatePos())
- QGuiApplication::sendSpontaneousEvent(m_widget, event);
+ QGuiApplication::forwardEvent(m_widget, event);
}
void QWidgetWindow::handleResizeEvent(QResizeEvent *event)
@@ -766,7 +794,7 @@ void QWidgetWindow::handleResizeEvent(QResizeEvent *event)
QSize oldSize = m_widget->data->crect.size();
if (updateSize()) {
- QGuiApplication::sendSpontaneousEvent(m_widget, event);
+ QGuiApplication::forwardEvent(m_widget, event);
if (m_widget->d_func()->paintOnScreen()) {
QRegion updateRegion(geometry());
@@ -812,7 +840,7 @@ void QWidgetWindow::handleWheelEvent(QWheelEvent *event)
QPoint mapped = widget->mapFrom(rootWidget, pos);
QWheelEvent translated(mapped, event->globalPos(), event->pixelDelta(), event->angleDelta(), event->delta(), event->orientation(), event->buttons(), event->modifiers(), event->phase(), event->source(), event->inverted());
- QGuiApplication::sendSpontaneousEvent(widget, &translated);
+ QGuiApplication::forwardEvent(widget, &translated, event);
}
#endif // QT_CONFIG(wheelevent)
@@ -839,7 +867,7 @@ void QWidgetWindow::handleDragEnterMoveEvent(QDragMoveEvent *event)
translated.accept();
translated.setDropAction(event->dropAction());
}
- QGuiApplication::sendSpontaneousEvent(widget, &translated);
+ QGuiApplication::forwardEvent(widget, &translated, event);
if (translated.isAccepted()) {
event->accept();
} else {
@@ -851,7 +879,7 @@ void QWidgetWindow::handleDragEnterMoveEvent(QDragMoveEvent *event)
// Target widget changed: Send DragLeave to previous, DragEnter to new if there is any
if (m_dragTarget.data()) {
QDragLeaveEvent le;
- QGuiApplication::sendSpontaneousEvent(m_dragTarget.data(), &le);
+ QGuiApplication::forwardEvent(m_dragTarget.data(), &le, event);
m_dragTarget = 0;
}
if (!widget) {
@@ -861,7 +889,7 @@ void QWidgetWindow::handleDragEnterMoveEvent(QDragMoveEvent *event)
m_dragTarget = widget;
const QPoint mapped = widget->mapFromGlobal(m_widget->mapToGlobal(event->pos()));
QDragEnterEvent translated(mapped, event->possibleActions(), event->mimeData(), event->mouseButtons(), event->keyboardModifiers());
- QGuiApplication::sendSpontaneousEvent(widget, &translated);
+ QGuiApplication::forwardEvent(widget, &translated, event);
if (translated.isAccepted()) {
event->accept();
} else {
@@ -873,7 +901,7 @@ void QWidgetWindow::handleDragEnterMoveEvent(QDragMoveEvent *event)
void QWidgetWindow::handleDragLeaveEvent(QDragLeaveEvent *event)
{
if (m_dragTarget)
- QGuiApplication::sendSpontaneousEvent(m_dragTarget.data(), event);
+ QGuiApplication::forwardEvent(m_dragTarget.data(), event);
m_dragTarget = 0;
}
@@ -886,7 +914,7 @@ void QWidgetWindow::handleDropEvent(QDropEvent *event)
}
const QPoint mapped = m_dragTarget.data()->mapFromGlobal(m_widget->mapToGlobal(event->pos()));
QDropEvent translated(mapped, event->possibleActions(), event->mimeData(), event->mouseButtons(), event->keyboardModifiers());
- QGuiApplication::sendSpontaneousEvent(m_dragTarget.data(), &translated);
+ QGuiApplication::forwardEvent(m_dragTarget.data(), &translated, event);
if (translated.isAccepted())
event->accept();
event->setDropAction(translated.dropAction());
@@ -909,7 +937,7 @@ void QWidgetWindow::handleExposeEvent(QExposeEvent *event)
// ... and they haven't been shown by this function yet - show it.
wPriv->showChildren(true);
QShowEvent showEvent;
- QCoreApplication::sendSpontaneousEvent(m_widget, &showEvent);
+ QCoreApplication::forwardEvent(m_widget, &showEvent, event);
wPriv->childrenShownByExpose = true;
}
} else {
@@ -921,7 +949,7 @@ void QWidgetWindow::handleExposeEvent(QExposeEvent *event)
// and then, the QPA can send next expose event with null exposed region (not exposed).
wPriv->hideChildren(true);
QHideEvent hideEvent;
- QCoreApplication::sendSpontaneousEvent(m_widget, &hideEvent);
+ QCoreApplication::forwardEvent(m_widget, &hideEvent, event);
wPriv->childrenShownByExpose = false;
}
}
@@ -941,30 +969,18 @@ void QWidgetWindow::handleWindowStateChangedEvent(QWindowStateChangeEvent *event
// QWindow does currently not know 'active'.
Qt::WindowStates eventState = event->oldState();
Qt::WindowStates widgetState = m_widget->windowState();
+ Qt::WindowStates windowState = windowStates();
if (widgetState & Qt::WindowActive)
eventState |= Qt::WindowActive;
// Determine the new widget state, remember maximized/full screen
// during minimized.
- switch (windowState()) {
- case Qt::WindowNoState:
- widgetState &= ~(Qt::WindowMinimized | Qt::WindowMaximized | Qt::WindowFullScreen);
- break;
- case Qt::WindowMinimized:
+ if (windowState & Qt::WindowMinimized) {
widgetState |= Qt::WindowMinimized;
- break;
- case Qt::WindowMaximized:
- updateNormalGeometry();
- widgetState |= Qt::WindowMaximized;
- widgetState &= ~(Qt::WindowMinimized | Qt::WindowFullScreen);
- break;
- case Qt::WindowFullScreen:
- updateNormalGeometry();
- widgetState |= Qt::WindowFullScreen;
- widgetState &= ~(Qt::WindowMinimized);
- break;
- case Qt::WindowActive: // Not handled by QWindow
- break;
+ } else {
+ widgetState = windowState | (widgetState & Qt::WindowActive);
+ if (windowState) // Maximized or FullScreen
+ updateNormalGeometry();
}
// Sent event if the state changed (that is, it is not triggered by
@@ -972,7 +988,7 @@ void QWidgetWindow::handleWindowStateChangedEvent(QWindowStateChangeEvent *event
if (widgetState != Qt::WindowStates::Int(m_widget->data->window_state)) {
m_widget->data->window_state = uint(widgetState);
QWindowStateChangeEvent widgetEvent(eventState);
- QGuiApplication::sendSpontaneousEvent(m_widget, &widgetEvent);
+ QGuiApplication::forwardEvent(m_widget, &widgetEvent, event);
}
}
@@ -1004,7 +1020,7 @@ void QWidgetWindow::handleTabletEvent(QTabletEvent *event)
event->pressure(), event->xTilt(), event->yTilt(), event->tangentialPressure(),
event->rotation(), event->z(), event->modifiers(), event->uniqueId(), event->button(), event->buttons());
ev.setTimestamp(event->timestamp());
- QGuiApplication::sendSpontaneousEvent(widget, &ev);
+ QGuiApplication::forwardEvent(widget, &ev, event);
event->setAccepted(ev.isAccepted());
}
@@ -1028,7 +1044,7 @@ void QWidgetWindow::handleGestureEvent(QNativeGestureEvent *e)
if (!receiver)
receiver = m_widget; // last resort
- QApplication::sendSpontaneousEvent(receiver, e);
+ QApplication::forwardEvent(receiver, e);
}
#endif // QT_NO_GESTURES
@@ -1056,7 +1072,7 @@ void QWidgetWindow::handleContextMenuEvent(QContextMenuEvent *e)
QPoint pos = fw->inputMethodQuery(Qt::ImMicroFocus).toRect().center();
QContextMenuEvent widgetEvent(QContextMenuEvent::Keyboard, pos, fw->mapToGlobal(pos),
e->modifiers());
- QGuiApplication::sendSpontaneousEvent(fw, &widgetEvent);
+ QGuiApplication::forwardEvent(fw, &widgetEvent, e);
}
}
#endif // QT_NO_CONTEXTMENU
diff --git a/src/widgets/kernel/qwidgetwindow_p.h b/src/widgets/kernel/qwidgetwindow_p.h
index 50a2cfd57c..d0f1d55c2a 100644
--- a/src/widgets/kernel/qwidgetwindow_p.h
+++ b/src/widgets/kernel/qwidgetwindow_p.h
@@ -63,22 +63,25 @@ QT_BEGIN_NAMESPACE
class QCloseEvent;
class QMoveEvent;
+class QWidgetWindowPrivate;
class QWidgetWindow : public QWindow
{
Q_OBJECT
+ Q_DECLARE_PRIVATE(QWidgetWindow)
public:
QWidgetWindow(QWidget *widget);
~QWidgetWindow();
QWidget *widget() const { return m_widget; }
#ifndef QT_NO_ACCESSIBILITY
- QAccessibleInterface *accessibleRoot() const Q_DECL_OVERRIDE;
+ QAccessibleInterface *accessibleRoot() const override;
#endif
- QObject *focusObject() const Q_DECL_OVERRIDE;
+ QObject *focusObject() const override;
+ void setNativeWindowVisibility(bool visible);
protected:
- bool event(QEvent *) Q_DECL_OVERRIDE;
+ bool event(QEvent *) override;
void handleCloseEvent(QCloseEvent *);
void handleEnterLeaveEvent(QEvent *);
@@ -99,7 +102,7 @@ protected:
#endif
void handleExposeEvent(QExposeEvent *);
void handleWindowStateChangedEvent(QWindowStateChangeEvent *event);
- bool nativeEvent(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE;
+ bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
#if QT_CONFIG(tabletevent)
void handleTabletEvent(QTabletEvent *);
#endif
diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp
index 56114350d2..d388327687 100644
--- a/src/widgets/kernel/qwindowcontainer.cpp
+++ b/src/widgets/kernel/qwindowcontainer.cpp
@@ -341,6 +341,19 @@ bool QWindowContainer::event(QEvent *e)
e->accept();
return true;
#endif
+
+ case QEvent::Paint:
+ {
+ static bool needsPunch = !QGuiApplicationPrivate::platformIntegration()->hasCapability(
+ QPlatformIntegration::TopStackedNativeChildWindows);
+ if (needsPunch) {
+ QPainter p(this);
+ p.setCompositionMode(QPainter::CompositionMode_Source);
+ p.fillRect(rect(), Qt::transparent);
+ }
+ break;
+ }
+
default:
break;
}
diff --git a/src/widgets/kernel/qwindowcontainer_p.h b/src/widgets/kernel/qwindowcontainer_p.h
index 1d838c8dd6..a8754232a8 100644
--- a/src/widgets/kernel/qwindowcontainer_p.h
+++ b/src/widgets/kernel/qwindowcontainer_p.h
@@ -75,7 +75,7 @@ public:
static void parentWasLowered(QWidget *parent);
protected:
- bool event(QEvent *ev) Q_DECL_OVERRIDE;
+ bool event(QEvent *ev) override;
private slots:
void focusWindowChanged(QWindow *focusWindow);
diff --git a/src/widgets/kernel/win.pri b/src/widgets/kernel/win.pri
index 7cef2d14a8..f6877b02db 100644
--- a/src/widgets/kernel/win.pri
+++ b/src/widgets/kernel/win.pri
@@ -3,5 +3,3 @@
INCLUDEPATH += ../3rdparty/wintab
!winrt: LIBS_PRIVATE *= -lshell32 -luxtheme -ldwmapi
-# Override MinGW's definition in _mingw.h
-mingw: DEFINES += WINVER=0x600 _WIN32_WINNT=0x0600
diff --git a/src/widgets/statemachine/qbasickeyeventtransition_p.h b/src/widgets/statemachine/qbasickeyeventtransition_p.h
index d3b90f6104..5007b79739 100644
--- a/src/widgets/statemachine/qbasickeyeventtransition_p.h
+++ b/src/widgets/statemachine/qbasickeyeventtransition_p.h
@@ -80,8 +80,8 @@ public:
void setModifierMask(Qt::KeyboardModifiers modifiers);
protected:
- bool eventTest(QEvent *event) Q_DECL_OVERRIDE;
- void onTransition(QEvent *) Q_DECL_OVERRIDE;
+ bool eventTest(QEvent *event) override;
+ void onTransition(QEvent *) override;
private:
Q_DISABLE_COPY(QBasicKeyEventTransition)
diff --git a/src/widgets/statemachine/qbasicmouseeventtransition_p.h b/src/widgets/statemachine/qbasicmouseeventtransition_p.h
index d6d37eb03e..93d2a5ec61 100644
--- a/src/widgets/statemachine/qbasicmouseeventtransition_p.h
+++ b/src/widgets/statemachine/qbasicmouseeventtransition_p.h
@@ -83,8 +83,8 @@ public:
void setHitTestPath(const QPainterPath &path);
protected:
- bool eventTest(QEvent *event) Q_DECL_OVERRIDE;
- void onTransition(QEvent *) Q_DECL_OVERRIDE;
+ bool eventTest(QEvent *event) override;
+ void onTransition(QEvent *) override;
private:
Q_DISABLE_COPY(QBasicMouseEventTransition)
diff --git a/src/widgets/statemachine/qkeyeventtransition.h b/src/widgets/statemachine/qkeyeventtransition.h
index 23ce3c40be..676f5f7846 100644
--- a/src/widgets/statemachine/qkeyeventtransition.h
+++ b/src/widgets/statemachine/qkeyeventtransition.h
@@ -54,9 +54,9 @@ class Q_WIDGETS_EXPORT QKeyEventTransition : public QEventTransition
Q_PROPERTY(int key READ key WRITE setKey)
Q_PROPERTY(Qt::KeyboardModifiers modifierMask READ modifierMask WRITE setModifierMask)
public:
- QKeyEventTransition(QState *sourceState = Q_NULLPTR);
+ QKeyEventTransition(QState *sourceState = nullptr);
QKeyEventTransition(QObject *object, QEvent::Type type, int key,
- QState *sourceState = Q_NULLPTR);
+ QState *sourceState = nullptr);
~QKeyEventTransition();
int key() const;
@@ -66,8 +66,8 @@ public:
void setModifierMask(Qt::KeyboardModifiers modifiers);
protected:
- void onTransition(QEvent *event) Q_DECL_OVERRIDE;
- bool eventTest(QEvent *event) Q_DECL_OVERRIDE;
+ void onTransition(QEvent *event) override;
+ bool eventTest(QEvent *event) override;
private:
Q_DISABLE_COPY(QKeyEventTransition)
diff --git a/src/widgets/statemachine/qmouseeventtransition.h b/src/widgets/statemachine/qmouseeventtransition.h
index 3f40224d8c..41f738d894 100644
--- a/src/widgets/statemachine/qmouseeventtransition.h
+++ b/src/widgets/statemachine/qmouseeventtransition.h
@@ -55,9 +55,9 @@ class Q_WIDGETS_EXPORT QMouseEventTransition : public QEventTransition
Q_PROPERTY(Qt::MouseButton button READ button WRITE setButton)
Q_PROPERTY(Qt::KeyboardModifiers modifierMask READ modifierMask WRITE setModifierMask)
public:
- QMouseEventTransition(QState *sourceState = Q_NULLPTR);
+ QMouseEventTransition(QState *sourceState = nullptr);
QMouseEventTransition(QObject *object, QEvent::Type type,
- Qt::MouseButton button, QState *sourceState = Q_NULLPTR);
+ Qt::MouseButton button, QState *sourceState = nullptr);
~QMouseEventTransition();
Qt::MouseButton button() const;
@@ -70,8 +70,8 @@ public:
void setHitTestPath(const QPainterPath &path);
protected:
- void onTransition(QEvent *event) Q_DECL_OVERRIDE;
- bool eventTest(QEvent *event) Q_DECL_OVERRIDE;
+ void onTransition(QEvent *event) override;
+ bool eventTest(QEvent *event) override;
private:
Q_DISABLE_COPY(QMouseEventTransition)
diff --git a/src/widgets/styles/images/closedock-10.png b/src/widgets/styles/images/closedock-10.png
new file mode 100644
index 0000000000..ee2af34550
--- /dev/null
+++ b/src/widgets/styles/images/closedock-10.png
Binary files differ
diff --git a/src/widgets/styles/images/closedock-16.png b/src/widgets/styles/images/closedock-16.png
index ab9d669eee..570012fc9a 100644
--- a/src/widgets/styles/images/closedock-16.png
+++ b/src/widgets/styles/images/closedock-16.png
Binary files differ
diff --git a/src/widgets/styles/images/closedock-20.png b/src/widgets/styles/images/closedock-20.png
new file mode 100644
index 0000000000..b5ea92d1de
--- /dev/null
+++ b/src/widgets/styles/images/closedock-20.png
Binary files differ
diff --git a/src/widgets/styles/images/closedock-32.png b/src/widgets/styles/images/closedock-32.png
new file mode 100644
index 0000000000..95a1ad014d
--- /dev/null
+++ b/src/widgets/styles/images/closedock-32.png
Binary files differ
diff --git a/src/widgets/styles/images/closedock-48.png b/src/widgets/styles/images/closedock-48.png
new file mode 100644
index 0000000000..3ca36d1394
--- /dev/null
+++ b/src/widgets/styles/images/closedock-48.png
Binary files differ
diff --git a/src/widgets/styles/images/closedock-64.png b/src/widgets/styles/images/closedock-64.png
new file mode 100644
index 0000000000..cbec2052ad
--- /dev/null
+++ b/src/widgets/styles/images/closedock-64.png
Binary files differ
diff --git a/src/widgets/styles/images/closedock-down-16.png b/src/widgets/styles/images/closedock-down-macstyle-16.png
index c1791dd2cc..c1791dd2cc 100644
--- a/src/widgets/styles/images/closedock-down-16.png
+++ b/src/widgets/styles/images/closedock-down-macstyle-16.png
Binary files differ
diff --git a/src/widgets/styles/images/closedock-macstyle-16.png b/src/widgets/styles/images/closedock-macstyle-16.png
new file mode 100644
index 0000000000..ab9d669eee
--- /dev/null
+++ b/src/widgets/styles/images/closedock-macstyle-16.png
Binary files differ
diff --git a/src/widgets/styles/images/dockdock-down-16.png b/src/widgets/styles/images/dockdock-down-macstyle-16.png
index 2e85a679be..2e85a679be 100644
--- a/src/widgets/styles/images/dockdock-down-16.png
+++ b/src/widgets/styles/images/dockdock-down-macstyle-16.png
Binary files differ
diff --git a/src/widgets/styles/images/dockdock-16.png b/src/widgets/styles/images/dockdock-macstyle-16.png
index 4ac9483176..4ac9483176 100644
--- a/src/widgets/styles/images/dockdock-16.png
+++ b/src/widgets/styles/images/dockdock-macstyle-16.png
Binary files differ
diff --git a/src/widgets/styles/images/fusion_arrow.png b/src/widgets/styles/images/fusion_arrow.png
deleted file mode 100644
index d7945e7f76..0000000000
--- a/src/widgets/styles/images/fusion_arrow.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/styles/images/normalizedockup-10.png b/src/widgets/styles/images/normalizedockup-10.png
new file mode 100644
index 0000000000..f380c65035
--- /dev/null
+++ b/src/widgets/styles/images/normalizedockup-10.png
Binary files differ
diff --git a/src/widgets/styles/images/normalizedockup-16.png b/src/widgets/styles/images/normalizedockup-16.png
new file mode 100644
index 0000000000..1b795a9e84
--- /dev/null
+++ b/src/widgets/styles/images/normalizedockup-16.png
Binary files differ
diff --git a/src/widgets/styles/images/normalizedockup-20.png b/src/widgets/styles/images/normalizedockup-20.png
new file mode 100644
index 0000000000..857338427f
--- /dev/null
+++ b/src/widgets/styles/images/normalizedockup-20.png
Binary files differ
diff --git a/src/widgets/styles/images/normalizedockup-32.png b/src/widgets/styles/images/normalizedockup-32.png
new file mode 100644
index 0000000000..d8993a1067
--- /dev/null
+++ b/src/widgets/styles/images/normalizedockup-32.png
Binary files differ
diff --git a/src/widgets/styles/images/normalizedockup-48.png b/src/widgets/styles/images/normalizedockup-48.png
new file mode 100644
index 0000000000..be48c9524c
--- /dev/null
+++ b/src/widgets/styles/images/normalizedockup-48.png
Binary files differ
diff --git a/src/widgets/styles/images/normalizedockup-64.png b/src/widgets/styles/images/normalizedockup-64.png
new file mode 100644
index 0000000000..7b540f04f8
--- /dev/null
+++ b/src/widgets/styles/images/normalizedockup-64.png
Binary files differ
diff --git a/src/widgets/styles/qandroidstyle.cpp b/src/widgets/styles/qandroidstyle.cpp
deleted file mode 100644
index 55f125c6b5..0000000000
--- a/src/widgets/styles/qandroidstyle.cpp
+++ /dev/null
@@ -1,1820 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qandroidstyle_p.h"
-
-#if QT_CONFIG(style_android) || defined(QT_PLUGIN)
-
-#include <QFile>
-#include <QFont>
-#include <QApplication>
-#include <qdrawutil.h>
-#include <QPixmapCache>
-#include <QFileInfo>
-#include <QStyleOption>
-#include <QPainter>
-#include <QJsonDocument>
-#include <QJsonObject>
-#include <QDebug>
-
-#include <QGuiApplication>
-#include <qpa/qplatformnativeinterface.h>
-#include <qpa/qplatformtheme.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace {
- const quint32 NO_COLOR = 1;
- const quint32 TRANSPARENT_COLOR = 0;
-}
-
-QAndroidStyle::QAndroidStyle()
- : QFusionStyle()
-{
- QPixmapCache::clear();
- checkBoxControl = NULL;
- QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
- QPalette *standardPalette = reinterpret_cast<QPalette *>(nativeInterface->nativeResourceForIntegration("AndroidStandardPalette"));
- if (standardPalette)
- m_standardPalette = *standardPalette;
-
- QHash<QByteArray, QFont> *qwidgetsFonts = reinterpret_cast<QHash<QByteArray, QFont> *>(nativeInterface->nativeResourceForIntegration("AndroidQWidgetFonts"));
- if (qwidgetsFonts) {
- for (auto it = qwidgetsFonts->constBegin(); it != qwidgetsFonts->constEnd(); ++it)
- QApplication::setFont(it.value(), it.key());
- qwidgetsFonts->clear(); // free the memory
- }
-
- QJsonObject *object = reinterpret_cast<QJsonObject *>(nativeInterface->nativeResourceForIntegration("AndroidStyleData"));
- if (!object)
- return;
-
- for (QJsonObject::const_iterator objectIterator = object->constBegin();
- objectIterator != object->constEnd();
- ++objectIterator) {
- QString key = objectIterator.key();
- QJsonValue value = objectIterator.value();
- if (Q_UNLIKELY(!value.isObject())) {
- qWarning("Style.json structure is unrecognized.");
- continue;
- }
-
- QJsonObject item = value.toObject();
- QAndroidStyle::ItemType itemType = qtControl(key);
- if (QC_UnknownType == itemType)
- continue;
-
- switch (itemType) {
- case QC_Checkbox:
- checkBoxControl = new AndroidCompoundButtonControl(item.toVariantMap(), itemType);
- m_androidControlsHash[int(itemType)] = checkBoxControl;
- break;
- case QC_RadioButton:
- m_androidControlsHash[int(itemType)] = new AndroidCompoundButtonControl(item.toVariantMap(),
- itemType);
- break;
-
- case QC_ProgressBar:
- m_androidControlsHash[int(itemType)] = new AndroidProgressBarControl(item.toVariantMap(),
- itemType);
- break;
-
- case QC_Slider:
- m_androidControlsHash[int(itemType)] = new AndroidSeekBarControl(item.toVariantMap(),
- itemType);
- break;
-
- case QC_Combobox:
- m_androidControlsHash[int(itemType)] = new AndroidSpinnerControl(item.toVariantMap(),
- itemType);
- break;
-
- default:
- m_androidControlsHash[int(itemType)] = new AndroidControl(item.toVariantMap(),
- itemType);
- break;
- }
- }
- *object = QJsonObject(); // free memory
-}
-
-QAndroidStyle::~QAndroidStyle()
-{
- qDeleteAll(m_androidControlsHash);
-}
-
-QAndroidStyle::ItemType QAndroidStyle::qtControl(const QString &android)
-{
- if (android == QLatin1String("buttonStyle"))
- return QC_Button;
- if (android == QLatin1String("editTextStyle"))
- return QC_EditText;
- if (android == QLatin1String("radioButtonStyle"))
- return QC_RadioButton;
- if (android == QLatin1String("checkboxStyle"))
- return QC_Checkbox;
- if (android == QLatin1String("textViewStyle"))
- return QC_View;
- if (android == QLatin1String("buttonStyleToggle"))
- return QC_Switch;
- if (android == QLatin1String("spinnerStyle"))
- return QC_Combobox;
- if (android == QLatin1String("progressBarStyleHorizontal"))
- return QC_ProgressBar;
- if (android == QLatin1String("seekBarStyle"))
- return QC_Slider;
-
- return QC_UnknownType;
-}
-
-QAndroidStyle::ItemType QAndroidStyle::qtControl(QStyle::ComplexControl control)
-{
- switch (control) {
- case CC_ComboBox:
- return QC_Combobox;
- case CC_Slider:
- return QC_Slider;
- default:
- return QC_UnknownType;
- }
-}
-
-QAndroidStyle::ItemType QAndroidStyle::qtControl(QStyle::ContentsType contentsType)
-{
- switch (contentsType) {
- case CT_PushButton:
- return QC_Button;
- case CT_CheckBox:
- return QC_Checkbox;
- case CT_RadioButton:
- return QC_RadioButton;
- case CT_ComboBox:
- return QC_Combobox;
- case CT_ProgressBar:
- return QC_ProgressBar;
- case CT_Slider:
- return QC_Slider;
- case CT_ScrollBar:
- return QC_Slider;
- case CT_TabWidget:
- return QC_Tab;
- case CT_TabBarTab:
- return QC_TabButton;
- case CT_LineEdit:
- return QC_EditText;
- case CT_GroupBox:
- return QC_GroupBox;
- default:
- return QC_UnknownType;
- }
-}
-
-QAndroidStyle::ItemType QAndroidStyle::qtControl(QStyle::ControlElement controlElement)
-{
- switch (controlElement) {
- case CE_PushButton:
- case CE_PushButtonBevel:
- case CE_PushButtonLabel:
- return QC_Button;
-
- case CE_CheckBox:
- case CE_CheckBoxLabel:
- return QC_Checkbox;
-
- case CE_RadioButton:
- case CE_RadioButtonLabel:
- return QC_RadioButton;
-
- case CE_TabBarTab:
- case CE_TabBarTabShape:
- case CE_TabBarTabLabel:
- return QC_Tab;
-
- case CE_ProgressBar:
- case CE_ProgressBarGroove:
- case CE_ProgressBarContents:
- case CE_ProgressBarLabel:
- return QC_ProgressBar;
-
- case CE_ComboBoxLabel:
- return QC_Combobox;
-
- case CE_ShapedFrame:
- return QC_View;
-
- default:
- return QC_UnknownType;
- }
-}
-
-QAndroidStyle::ItemType QAndroidStyle::qtControl(QStyle::PrimitiveElement primitiveElement)
-{
- switch (primitiveElement) {
- case QStyle::PE_PanelLineEdit:
- case QStyle::PE_FrameLineEdit:
- return QC_EditText;
-
- case QStyle::PE_IndicatorViewItemCheck:
- case QStyle::PE_IndicatorCheckBox:
- return QC_Checkbox;
-
- case QStyle::PE_FrameWindow:
- case QStyle::PE_Widget:
- case QStyle::PE_Frame:
- case QStyle::PE_FrameFocusRect:
- return QC_View;
- default:
- return QC_UnknownType;
- }
-}
-
-QAndroidStyle::ItemType QAndroidStyle::qtControl(QStyle::SubElement subElement)
-{
- switch (subElement) {
- case QStyle::SE_LineEditContents:
- return QC_EditText;
-
- case QStyle::SE_PushButtonContents:
- case QStyle::SE_PushButtonFocusRect:
- return QC_Button;
-
- case SE_RadioButtonContents:
- return QC_RadioButton;
-
- case SE_CheckBoxContents:
- return QC_Checkbox;
-
- default:
- return QC_UnknownType;
- }
-}
-
-void QAndroidStyle::drawPrimitive(PrimitiveElement pe,
- const QStyleOption *opt,
- QPainter *p,
- const QWidget *w) const
-{
- const ItemType itemType = qtControl(pe);
- AndroidControlsHash::const_iterator it = itemType != QC_UnknownType
- ? m_androidControlsHash.find(itemType)
- : m_androidControlsHash.end();
- if (it != m_androidControlsHash.end()) {
- if (itemType != QC_EditText) {
- it.value()->drawControl(opt, p, w);
- } else {
- QStyleOption copy(*opt);
- copy.state &= ~QStyle::State_Sunken;
- it.value()->drawControl(&copy, p, w);
- }
- } else if (pe == PE_FrameGroupBox) {
- if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
- if (frame->features & QStyleOptionFrame::Flat) {
- QRect fr = frame->rect;
- QPoint p1(fr.x(), fr.y() + 1);
- QPoint p2(fr.x() + fr.width(), p1.y());
- qDrawShadeLine(p, p1, p2, frame->palette, true,
- frame->lineWidth, frame->midLineWidth);
- } else {
- qDrawShadeRect(p, frame->rect.x(), frame->rect.y(), frame->rect.width(),
- frame->rect.height(), frame->palette, true,
- frame->lineWidth, frame->midLineWidth);
- }
- }
- } else {
- QFusionStyle::drawPrimitive(pe, opt, p, w);
- }
-}
-
-
-void QAndroidStyle::drawControl(QStyle::ControlElement element,
- const QStyleOption *opt,
- QPainter *p,
- const QWidget *w) const
-{
- const ItemType itemType = qtControl(element);
- AndroidControlsHash::const_iterator it = itemType != QC_UnknownType
- ? m_androidControlsHash.find(itemType)
- : m_androidControlsHash.end();
- if (it != m_androidControlsHash.end()) {
- AndroidControl *androidControl = it.value();
-
- if (element != QStyle::CE_CheckBoxLabel
- && element != QStyle::CE_PushButtonLabel
- && element != QStyle::CE_RadioButtonLabel
- && element != QStyle::CE_TabBarTabLabel
- && element != QStyle::CE_ProgressBarLabel) {
- androidControl->drawControl(opt, p, w);
- }
-
- if (element != QStyle::CE_PushButtonBevel
- && element != QStyle::CE_TabBarTabShape
- && element != QStyle::CE_ProgressBarGroove) {
- switch (itemType) {
- case QC_Button:
- if (const QStyleOptionButton *buttonOption =
- qstyleoption_cast<const QStyleOptionButton *>(opt)) {
- QMargins padding = androidControl->padding();
- QStyleOptionButton copy(*buttonOption);
- copy.rect.adjust(padding.left(), padding.top(), -padding.right(), -padding.bottom());
- QFusionStyle::drawControl(CE_PushButtonLabel, &copy, p, w);
- }
- break;
- case QC_Checkbox:
- case QC_RadioButton:
- if (const QStyleOptionButton *btn =
- qstyleoption_cast<const QStyleOptionButton *>(opt)) {
- const bool isRadio = (element == CE_RadioButton);
- QStyleOptionButton subopt(*btn);
- subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents
- : SE_CheckBoxContents, btn, w);
- QFusionStyle::drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p, w);
- }
- break;
- case QC_Combobox:
- if (const QStyleOptionComboBox *comboboxOption =
- qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
- QMargins padding = androidControl->padding();
- QStyleOptionComboBox copy (*comboboxOption);
- copy.rect.adjust(padding.left(), padding.top(), -padding.right(), -padding.bottom());
- QFusionStyle::drawControl(CE_ComboBoxLabel, comboboxOption, p, w);
- }
- break;
- default:
- QFusionStyle::drawControl(element, opt, p, w);
- break;
- }
- }
- } else {
- QFusionStyle::drawControl(element, opt, p, w);
- }
-}
-
-QRect QAndroidStyle::subElementRect(SubElement subElement,
- const QStyleOption *option,
- const QWidget *widget) const
-{
- const ItemType itemType = qtControl(subElement);
- AndroidControlsHash::const_iterator it = itemType != QC_UnknownType
- ? m_androidControlsHash.find(itemType)
- : m_androidControlsHash.end();
- if (it != m_androidControlsHash.end())
- return it.value()->subElementRect(subElement, option, widget);
- return QFusionStyle::subElementRect(subElement, option, widget);
-}
-
-void QAndroidStyle::drawComplexControl(ComplexControl cc,
- const QStyleOptionComplex *opt,
- QPainter *p,
- const QWidget *widget) const
-{
- const ItemType itemType = qtControl(cc);
- AndroidControlsHash::const_iterator it = itemType != QC_UnknownType
- ? m_androidControlsHash.find(itemType)
- : m_androidControlsHash.end();
- if (it != m_androidControlsHash.end()) {
- it.value()->drawControl(opt, p, widget);
- return;
- }
- if (cc == CC_GroupBox) {
- if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
- // Draw frame
- QRect textRect = subControlRect(CC_GroupBox, opt, SC_GroupBoxLabel, widget);
- QRect checkBoxRect;
- if (groupBox->subControls & SC_GroupBoxCheckBox)
- checkBoxRect = subControlRect(CC_GroupBox, opt, SC_GroupBoxCheckBox, widget);
- if (groupBox->subControls & QStyle::SC_GroupBoxFrame) {
- QStyleOptionFrame frame;
- frame.QStyleOption::operator=(*groupBox);
- frame.features = groupBox->features;
- frame.lineWidth = groupBox->lineWidth;
- frame.midLineWidth = groupBox->midLineWidth;
- frame.rect = subControlRect(CC_GroupBox, opt, SC_GroupBoxFrame, widget);
- p->save();
- QRegion region(groupBox->rect);
- if (!groupBox->text.isEmpty()) {
- bool ltr = groupBox->direction == Qt::LeftToRight;
- QRect finalRect;
- if (groupBox->subControls & QStyle::SC_GroupBoxCheckBox) {
- finalRect = checkBoxRect.united(textRect);
- finalRect.adjust(ltr ? -4 : 0, 0, ltr ? 0 : 4, 0);
- } else {
- finalRect = textRect;
- }
- region -= finalRect;
- }
- p->setClipRegion(region);
- drawPrimitive(PE_FrameGroupBox, &frame, p, widget);
- p->restore();
- }
-
- // Draw title
- if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {
- QColor textColor = groupBox->textColor;
- if (textColor.isValid())
- p->setPen(textColor);
- int alignment = int(groupBox->textAlignment);
- if (!styleHint(QStyle::SH_UnderlineShortcut, opt, widget))
- alignment |= Qt::TextHideMnemonic;
-
- drawItemText(p, textRect, Qt::TextShowMnemonic | Qt::AlignHCenter | alignment,
- groupBox->palette, groupBox->state & State_Enabled, groupBox->text,
- textColor.isValid() ? QPalette::NoRole : QPalette::WindowText);
-
- if (groupBox->state & State_HasFocus) {
- QStyleOptionFocusRect fropt;
- fropt.QStyleOption::operator=(*groupBox);
- fropt.rect = textRect;
- drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
- }
- }
-
- // Draw checkbox
- if (groupBox->subControls & SC_GroupBoxCheckBox) {
- QStyleOptionButton box;
- box.QStyleOption::operator=(*groupBox);
- box.rect = checkBoxRect;
- checkBoxControl->drawControl(&box, p, widget);
- }
- }
- return;
- }
- QFusionStyle::drawComplexControl(cc, opt, p, widget);
-}
-
-QStyle::SubControl QAndroidStyle::hitTestComplexControl(ComplexControl cc,
- const QStyleOptionComplex *opt,
- const QPoint &pt,
- const QWidget *widget) const
-{
- const ItemType itemType = qtControl(cc);
- AndroidControlsHash::const_iterator it = itemType != QC_UnknownType
- ? m_androidControlsHash.find(itemType)
- : m_androidControlsHash.end();
- if (it != m_androidControlsHash.end()) {
- switch (cc) {
- case CC_Slider:
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
- QRect r = it.value()->subControlRect(slider, SC_SliderHandle, widget);
- if (r.isValid() && r.contains(pt)) {
- return SC_SliderHandle;
- } else {
- r = it.value()->subControlRect(slider, SC_SliderGroove, widget);
- if (r.isValid() && r.contains(pt))
- return SC_SliderGroove;
- }
- }
- break;
- default:
- break;
- }
- }
- return QFusionStyle::hitTestComplexControl(cc, opt, pt, widget);
-}
-
-QRect QAndroidStyle::subControlRect(ComplexControl cc,
- const QStyleOptionComplex *opt,
- SubControl sc,
- const QWidget *widget) const
-{
- const ItemType itemType = qtControl(cc);
- AndroidControlsHash::const_iterator it = itemType != QC_UnknownType
- ? m_androidControlsHash.find(itemType)
- : m_androidControlsHash.end();
- if (it != m_androidControlsHash.end())
- return it.value()->subControlRect(opt, sc, widget);
- QRect rect = opt->rect;
- switch (cc) {
- case CC_GroupBox: {
- if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
- QSize textSize = opt->fontMetrics.boundingRect(groupBox->text).size() + QSize(2, 2);
- QSize checkBoxSize = checkBoxControl->size(opt);
- int indicatorWidth = checkBoxSize.width();
- int indicatorHeight = checkBoxSize.height();
- QRect checkBoxRect;
- if (opt->subControls & QStyle::SC_GroupBoxCheckBox) {
- checkBoxRect.setWidth(indicatorWidth);
- checkBoxRect.setHeight(indicatorHeight);
- }
- checkBoxRect.moveLeft(1);
- QRect textRect = checkBoxRect;
- textRect.setSize(textSize);
- if (opt->subControls & QStyle::SC_GroupBoxCheckBox)
- textRect.translate(indicatorWidth + 5, (indicatorHeight - textSize.height()) / 2);
- if (sc == SC_GroupBoxFrame) {
- rect = opt->rect.adjusted(0, 0, 0, 0);
- rect.translate(0, textRect.height() / 2);
- rect.setHeight(rect.height() - textRect.height() / 2);
- } else if (sc == SC_GroupBoxContents) {
- QRect frameRect = opt->rect.adjusted(0, 0, 0, -groupBox->lineWidth);
- int margin = 3;
- int leftMarginExtension = 0;
- int topMargin = qMax(pixelMetric(PM_ExclusiveIndicatorHeight), opt->fontMetrics.height()) + groupBox->lineWidth;
- frameRect.adjust(leftMarginExtension + margin, margin + topMargin, -margin, -margin - groupBox->lineWidth);
- frameRect.translate(0, textRect.height() / 2);
- rect = frameRect;
- rect.setHeight(rect.height() - textRect.height() / 2);
- } else if (sc == SC_GroupBoxCheckBox) {
- rect = checkBoxRect;
- } else if (sc == SC_GroupBoxLabel) {
- rect = textRect;
- }
- return visualRect(opt->direction, opt->rect, rect);
- }
-
- return rect;
- }
-
- default:
- break;
- }
-
-
- return QFusionStyle::subControlRect(cc, opt, sc, widget);
-}
-
-int QAndroidStyle::pixelMetric(PixelMetric metric, const QStyleOption *option,
- const QWidget *widget) const
-{
- switch (metric) {
- case PM_ButtonMargin:
- case PM_FocusFrameVMargin:
- case PM_FocusFrameHMargin:
- case PM_ComboBoxFrameWidth:
- case PM_SpinBoxFrameWidth:
- case PM_ScrollBarExtent:
- return 0;
- case PM_IndicatorWidth:
- return checkBoxControl->size(option).width();
- case PM_IndicatorHeight:
- return checkBoxControl->size(option).height();
- default:
- return QFusionStyle::pixelMetric(metric, option, widget);
- }
-
-}
-
-QSize QAndroidStyle::sizeFromContents(ContentsType ct,
- const QStyleOption *opt,
- const QSize &contentsSize,
- const QWidget *w) const
-{
- QSize sz = QFusionStyle::sizeFromContents(ct, opt, contentsSize, w);
- if (ct == CT_HeaderSection) {
- if (const QStyleOptionHeader *hdr = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
- bool nullIcon = hdr->icon.isNull();
- int margin = pixelMetric(QStyle::PM_HeaderMargin, hdr, w);
- int iconSize = nullIcon ? 0 : checkBoxControl->size(opt).width();
- QSize txt;
-/*
- * These next 4 lines are a bad hack to fix a bug in case a QStyleSheet is applied at QApplication level.
- * In that case, even if the stylesheet does not refer to headers, the header font is changed to application
- * font, which is wrong. Even worst, hdr->fontMetrics(...) does not report the proper size.
- */
- if (qApp->styleSheet().isEmpty())
- txt = hdr->fontMetrics.size(0, hdr->text);
- else
- txt = qApp->fontMetrics().size(0, hdr->text);
-
- sz.setHeight(margin + qMax(iconSize, txt.height()) + margin);
- sz.setWidth((nullIcon ? 0 : margin) + iconSize
- + (hdr->text.isNull() ? 0 : margin) + txt.width() + margin);
- if (hdr->sortIndicator != QStyleOptionHeader::None) {
- int margin = pixelMetric(QStyle::PM_HeaderMargin, hdr, w);
- if (hdr->orientation == Qt::Horizontal)
- sz.rwidth() += sz.height() + margin;
- else
- sz.rheight() += sz.width() + margin;
- }
- return sz;
- }
- }
- const ItemType itemType = qtControl(ct);
- AndroidControlsHash::const_iterator it = itemType != QC_UnknownType
- ? m_androidControlsHash.find(itemType)
- : m_androidControlsHash.end();
- if (it != m_androidControlsHash.end())
- return it.value()->sizeFromContents(opt, sz, w);
- if (ct == CT_GroupBox) {
- if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
- QSize textSize = opt->fontMetrics.boundingRect(groupBox->text).size() + QSize(2, 2);
- QSize checkBoxSize = checkBoxControl->size(opt);
- int indicatorWidth = checkBoxSize.width();
- int indicatorHeight = checkBoxSize.height();
- QRect checkBoxRect;
- if (groupBox->subControls & QStyle::SC_GroupBoxCheckBox) {
- checkBoxRect.setWidth(indicatorWidth);
- checkBoxRect.setHeight(indicatorHeight);
- }
- checkBoxRect.moveLeft(1);
- QRect textRect = checkBoxRect;
- textRect.setSize(textSize);
- if (groupBox->subControls & QStyle::SC_GroupBoxCheckBox)
- textRect.translate(indicatorWidth + 5, (indicatorHeight - textSize.height()) / 2);
- QRect u = textRect.united(checkBoxRect);
- sz = QSize(sz.width(), sz.height() + u.height());
- }
- }
- return sz;
-}
-
-QPixmap QAndroidStyle::standardPixmap(StandardPixmap standardPixmap,
- const QStyleOption *opt,
- const QWidget *widget) const
-{
- return QFusionStyle::standardPixmap(standardPixmap, opt, widget);
-}
-
-QPixmap QAndroidStyle::generatedIconPixmap(QIcon::Mode iconMode,
- const QPixmap &pixmap,
- const QStyleOption *opt) const
-{
- return QFusionStyle::generatedIconPixmap(iconMode, pixmap, opt);
-}
-
-int QAndroidStyle::styleHint(QStyle::StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const
-{
- switch (hint) {
- case SH_Slider_AbsoluteSetButtons:
- return Qt::LeftButton;
-
- case SH_Slider_PageSetButtons:
- return 0;
-
- case SH_RequestSoftwareInputPanel:
- return RSIP_OnMouseClick;
-
- default:
- return QFusionStyle::styleHint(hint, option, widget, returnData);
- }
-}
-
-QPalette QAndroidStyle::standardPalette() const
-{
- return m_standardPalette;
-}
-
-void QAndroidStyle::polish(QWidget *widget)
-{
- widget->setAttribute(Qt::WA_StyledBackground, true);
-}
-
-void QAndroidStyle::unpolish(QWidget *widget)
-{
- widget->setAttribute(Qt::WA_StyledBackground, false);
-}
-
-QAndroidStyle::AndroidDrawable::AndroidDrawable(const QVariantMap &drawable,
- QAndroidStyle::ItemType itemType)
-{
- initPadding(drawable);
- m_itemType = itemType;
-}
-
-QAndroidStyle::AndroidDrawable::~AndroidDrawable()
-{
-}
-
-void QAndroidStyle::AndroidDrawable::initPadding(const QVariantMap &drawable)
-{
- QVariantMap::const_iterator it = drawable.find(QLatin1String("padding"));
- if (it != drawable.end())
- m_padding = extractMargins(it.value().toMap());
-}
-
-const QMargins &QAndroidStyle::AndroidDrawable::padding() const
-{
- return m_padding;
-}
-
-QSize QAndroidStyle::AndroidDrawable::size() const
-{
- if (type() == Image || type() == NinePatch)
- return static_cast<const QAndroidStyle::AndroidImageDrawable *>(this)->size();
-
- return QSize();
-}
-
-QAndroidStyle::AndroidDrawable * QAndroidStyle::AndroidDrawable::fromMap(const QVariantMap &drawable,
- ItemType itemType)
-{
- const QString type = drawable.value(QLatin1String("type")).toString();
- if (type == QLatin1String("image"))
- return new QAndroidStyle::AndroidImageDrawable(drawable, itemType);
- if (type == QLatin1String("9patch"))
- return new QAndroidStyle::Android9PatchDrawable(drawable, itemType);
- if (type == QLatin1String("stateslist"))
- return new QAndroidStyle::AndroidStateDrawable(drawable, itemType);
- if (type == QLatin1String("layer"))
- return new QAndroidStyle::AndroidLayerDrawable(drawable, itemType);
- if (type == QLatin1String("gradient"))
- return new QAndroidStyle::AndroidGradientDrawable(drawable, itemType);
- if (type == QLatin1String("clipDrawable"))
- return new QAndroidStyle::AndroidClipDrawable(drawable, itemType);
- if (type == QLatin1String("color"))
- return new QAndroidStyle::AndroidColorDrawable(drawable, itemType);
- return 0;
-}
-
-QMargins QAndroidStyle::AndroidDrawable::extractMargins(const QVariantMap &value)
-{
- QMargins m;
- m.setLeft(value.value(QLatin1String("left")).toInt());
- m.setRight(value.value(QLatin1String("right")).toInt());
- m.setTop(value.value(QLatin1String("top")).toInt());
- m.setBottom(value.value(QLatin1String("bottom")).toInt());
- return m;
-}
-
-void QAndroidStyle::AndroidDrawable::setPaddingLeftToSizeWidth()
-{
- QSize sz = size();
- if (m_padding.isNull() && !sz.isNull())
- m_padding.setLeft(sz.width());
-}
-
-
-QAndroidStyle::AndroidImageDrawable::AndroidImageDrawable(const QVariantMap &drawable,
- QAndroidStyle::ItemType itemType)
- : AndroidDrawable(drawable, itemType)
-{
- m_filePath = drawable.value(QLatin1String("path")).toString();
- m_size.setHeight(drawable.value(QLatin1String("height")).toInt());
- m_size.setWidth(drawable.value(QLatin1String("width")).toInt());
-}
-
-QAndroidStyle::AndroidDrawableType QAndroidStyle::AndroidImageDrawable::type() const
-{
- return QAndroidStyle::Image;
-}
-
-void QAndroidStyle::AndroidImageDrawable::draw(QPainter *painter, const QStyleOption *opt) const
-{
- if (m_hashKey.isEmpty())
- m_hashKey = QFileInfo(m_filePath).fileName();
-
- QPixmap pm;
- if (!QPixmapCache::find(m_hashKey, &pm)) {
- pm.load(m_filePath);
- QPixmapCache::insert(m_hashKey, pm);
- }
-
- painter->drawPixmap(opt->rect.x(), opt->rect.y() + (opt->rect.height() - pm.height()) / 2, pm);
-}
-
-QSize QAndroidStyle::AndroidImageDrawable::size() const
-{
- return m_size;
-}
-
-QAndroidStyle::AndroidColorDrawable::AndroidColorDrawable(const QVariantMap &drawable,
- ItemType itemType)
- : AndroidDrawable(drawable, itemType)
-{
- m_color.setRgba(QRgb(drawable.value(QLatin1String("color")).toInt()));
-}
-
-QAndroidStyle::AndroidDrawableType QAndroidStyle::AndroidColorDrawable::type() const
-{
- return QAndroidStyle::Color;
-}
-
-void QAndroidStyle::AndroidColorDrawable::draw(QPainter *painter, const QStyleOption *opt) const
-{
- painter->fillRect(opt->rect, m_color);
-}
-
-QAndroidStyle::Android9PatchDrawable::Android9PatchDrawable(const QVariantMap &drawable,
- QAndroidStyle::ItemType itemType)
- : AndroidImageDrawable(drawable.value(QLatin1String("drawable")).toMap(), itemType)
-{
- initPadding(drawable);
- QVariantMap chunk = drawable.value(QLatin1String("chunkInfo")).toMap();
- extractIntArray(chunk.value(QLatin1String("xdivs")).toList(), m_chunkData.xDivs);
- extractIntArray(chunk.value(QLatin1String("ydivs")).toList(), m_chunkData.yDivs);
- extractIntArray(chunk.value(QLatin1String("colors")).toList(), m_chunkData.colors);
-}
-
-QAndroidStyle::AndroidDrawableType QAndroidStyle::Android9PatchDrawable::type() const
-{
- return QAndroidStyle::NinePatch;
-}
-
-int QAndroidStyle::Android9PatchDrawable::calculateStretch(int boundsLimit,
- int startingPoint,
- int srcSpace,
- int numStrechyPixelsRemaining,
- int numFixedPixelsRemaining)
-{
- int spaceRemaining = boundsLimit - startingPoint;
- int stretchySpaceRemaining = spaceRemaining - numFixedPixelsRemaining;
- return (float(srcSpace) * stretchySpaceRemaining / numStrechyPixelsRemaining + .5);
-}
-
-void QAndroidStyle::Android9PatchDrawable::extractIntArray(const QVariantList &values,
- QVector<int> & array)
-{
- for (const QVariant &value : values)
- array << value.toInt();
-}
-
-
-void QAndroidStyle::Android9PatchDrawable::draw(QPainter *painter, const QStyleOption *opt) const
-{
- if (m_hashKey.isEmpty())
- m_hashKey = QFileInfo(m_filePath).fileName();
-
- QPixmap pixmap;
- if (!QPixmapCache::find(m_hashKey, &pixmap)) {
- pixmap.load(m_filePath);
- QPixmapCache::insert(m_hashKey, pixmap);
- }
-
- const QRect &bounds = opt->rect;
-
- // shamelessly stolen from Android's sources (NinepatchImpl.cpp) and adapted for Qt
- const int pixmapWidth = pixmap.width();
- const int pixmapHeight = pixmap.height();
-
- if (bounds.isNull() || !pixmapWidth || !pixmapHeight)
- return;
-
- QPainter::RenderHints savedHints = painter->renderHints();
-
- // The patchs doesn't need smooth transform !
- painter->setRenderHints(QPainter::SmoothPixmapTransform, false);
-
- QRectF dst;
- QRectF src;
-
- const qint32 x0 = m_chunkData.xDivs[0];
- const qint32 y0 = m_chunkData.yDivs[0];
- const quint8 numXDivs = m_chunkData.xDivs.size();
- const quint8 numYDivs = m_chunkData.yDivs.size();
- int i;
- int j;
- int colorIndex = 0;
- quint32 color;
- bool xIsStretchable;
- const bool initialXIsStretchable = (x0 == 0);
- bool yIsStretchable = (y0 == 0);
- const int bitmapWidth = pixmap.width();
- const int bitmapHeight = pixmap.height();
-
- int *dstRights = static_cast<int *>(alloca((numXDivs + 1) * sizeof(int)));
- bool dstRightsHaveBeenCached = false;
-
- int numStretchyXPixelsRemaining = 0;
- for (i = 0; i < numXDivs; i += 2)
- numStretchyXPixelsRemaining += m_chunkData.xDivs[i + 1] - m_chunkData.xDivs[i];
-
- int numFixedXPixelsRemaining = bitmapWidth - numStretchyXPixelsRemaining;
- int numStretchyYPixelsRemaining = 0;
- for (i = 0; i < numYDivs; i += 2)
- numStretchyYPixelsRemaining += m_chunkData.yDivs[i + 1] - m_chunkData.yDivs[i];
-
- int numFixedYPixelsRemaining = bitmapHeight - numStretchyYPixelsRemaining;
- src.setTop(0);
- dst.setTop(bounds.top());
- // The first row always starts with the top being at y=0 and the bottom
- // being either yDivs[1] (if yDivs[0]=0) of yDivs[0]. In the former case
- // the first row is stretchable along the Y axis, otherwise it is fixed.
- // The last row always ends with the bottom being bitmap.height and the top
- // being either yDivs[numYDivs-2] (if yDivs[numYDivs-1]=bitmap.height) or
- // yDivs[numYDivs-1]. In the former case the last row is stretchable along
- // the Y axis, otherwise it is fixed.
- //
- // The first and last columns are similarly treated with respect to the X
- // axis.
- //
- // The above is to help explain some of the special casing that goes on the
- // code below.
-
- // The initial yDiv and whether the first row is considered stretchable or
- // not depends on whether yDiv[0] was zero or not.
- for (j = yIsStretchable ? 1 : 0;
- j <= numYDivs && src.top() < bitmapHeight;
- j++, yIsStretchable = !yIsStretchable) {
- src.setLeft(0);
- dst.setLeft(bounds.left());
- if (j == numYDivs) {
- src.setBottom(bitmapHeight);
- dst.setBottom(bounds.bottom());
- } else {
- src.setBottom(m_chunkData.yDivs[j]);
- const int srcYSize = src.bottom() - src.top();
- if (yIsStretchable) {
- dst.setBottom(dst.top() + calculateStretch(bounds.bottom(), dst.top(),
- srcYSize,
- numStretchyYPixelsRemaining,
- numFixedYPixelsRemaining));
- numStretchyYPixelsRemaining -= srcYSize;
- } else {
- dst.setBottom(dst.top() + srcYSize);
- numFixedYPixelsRemaining -= srcYSize;
- }
- }
-
- xIsStretchable = initialXIsStretchable;
- // The initial xDiv and whether the first column is considered
- // stretchable or not depends on whether xDiv[0] was zero or not.
- for (i = xIsStretchable ? 1 : 0;
- i <= numXDivs && src.left() < bitmapWidth;
- i++, xIsStretchable = !xIsStretchable) {
- color = m_chunkData.colors[colorIndex++];
- if (color != TRANSPARENT_COLOR)
- color = NO_COLOR;
- if (i == numXDivs) {
- src.setRight(bitmapWidth);
- dst.setRight(bounds.right());
- } else {
- src.setRight(m_chunkData.xDivs[i]);
- if (dstRightsHaveBeenCached) {
- dst.setRight(dstRights[i]);
- } else {
- const int srcXSize = src.right() - src.left();
- if (xIsStretchable) {
- dst.setRight(dst.left() + calculateStretch(bounds.right(), dst.left(),
- srcXSize,
- numStretchyXPixelsRemaining,
- numFixedXPixelsRemaining));
- numStretchyXPixelsRemaining -= srcXSize;
- } else {
- dst.setRight(dst.left() + srcXSize);
- numFixedXPixelsRemaining -= srcXSize;
- }
- dstRights[i] = dst.right();
- }
- }
- // If this horizontal patch is too small to be displayed, leave
- // the destination left edge where it is and go on to the next patch
- // in the source.
- if (src.left() >= src.right()) {
- src.setLeft(src.right());
- continue;
- }
- // Make sure that we actually have room to draw any bits
- if (dst.right() <= dst.left() || dst.bottom() <= dst.top()) {
- goto nextDiv;
- }
- // If this patch is transparent, skip and don't draw.
- if (color == TRANSPARENT_COLOR)
- goto nextDiv;
- if (color != NO_COLOR)
- painter->fillRect(dst, QRgb(color));
- else
- painter->drawPixmap(dst, pixmap, src);
-nextDiv:
- src.setLeft(src.right());
- dst.setLeft(dst.right());
- }
- src.setTop(src.bottom());
- dst.setTop(dst.bottom());
- dstRightsHaveBeenCached = true;
- }
- painter->setRenderHints(savedHints);
-}
-
-QAndroidStyle::AndroidGradientDrawable::AndroidGradientDrawable(const QVariantMap &drawable,
- QAndroidStyle::ItemType itemType)
- : AndroidDrawable(drawable, itemType), m_orientation(TOP_BOTTOM)
-{
- m_radius = drawable.value(QLatin1String("radius")).toInt();
- if (m_radius < 0)
- m_radius = 0;
-
- QVariantList colors = drawable.value(QLatin1String("colors")).toList();
- QVariantList positions = drawable.value(QLatin1String("positions")).toList();
- int min = colors.size() < positions.size() ? colors.size() : positions.size();
- for (int i = 0; i < min; i++)
- m_gradient.setColorAt(positions.at(i).toDouble(), QRgb(colors.at(i).toInt()));
-
- QByteArray orientation = drawable.value(QLatin1String("orientation")).toByteArray();
- if (orientation == "TOP_BOTTOM") // draw the gradient from the top to the bottom
- m_orientation = TOP_BOTTOM;
- else if (orientation == "TR_BL") // draw the gradient from the top-right to the bottom-left
- m_orientation = TR_BL;
- else if (orientation == "RIGHT_LEFT") // draw the gradient from the right to the left
- m_orientation = RIGHT_LEFT;
- else if (orientation == "BR_TL") // draw the gradient from the bottom-right to the top-left
- m_orientation = BR_TL;
- else if (orientation == "BOTTOM_TOP") // draw the gradient from the bottom to the top
- m_orientation = BOTTOM_TOP;
- else if (orientation == "BL_TR") // draw the gradient from the bottom-left to the top-right
- m_orientation = BL_TR;
- else if (orientation == "LEFT_RIGHT") // draw the gradient from the left to the right
- m_orientation = LEFT_RIGHT;
- else if (orientation == "TL_BR") // draw the gradient from the top-left to the bottom-right
- m_orientation = TL_BR;
- else
- qWarning("AndroidGradientDrawable: unknown orientation");
-}
-
-QAndroidStyle::AndroidDrawableType QAndroidStyle::AndroidGradientDrawable::type() const
-{
- return QAndroidStyle::Gradient;
-}
-
-void QAndroidStyle::AndroidGradientDrawable::draw(QPainter *painter, const QStyleOption *opt) const
-{
- const int width = opt->rect.width();
- const int height = opt->rect.height();
- switch (m_orientation) {
- case TOP_BOTTOM:
- // draw the gradient from the top to the bottom
- m_gradient.setStart(width / 2, 0);
- m_gradient.setFinalStop(width / 2, height);
- break;
- case TR_BL:
- // draw the gradient from the top-right to the bottom-left
- m_gradient.setStart(width, 0);
- m_gradient.setFinalStop(0, height);
- break;
- case RIGHT_LEFT:
- // draw the gradient from the right to the left
- m_gradient.setStart(width, height / 2);
- m_gradient.setFinalStop(0, height / 2);
- break;
- case BR_TL:
- // draw the gradient from the bottom-right to the top-left
- m_gradient.setStart(width, height);
- m_gradient.setFinalStop(0, 0);
- break;
- case BOTTOM_TOP:
- // draw the gradient from the bottom to the top
- m_gradient.setStart(width / 2, height);
- m_gradient.setFinalStop(width / 2, 0);
- break;
- case BL_TR:
- // draw the gradient from the bottom-left to the top-right
- m_gradient.setStart(0, height);
- m_gradient.setFinalStop(width, 0);
- break;
- case LEFT_RIGHT:
- // draw the gradient from the left to the right
- m_gradient.setStart(0, height / 2);
- m_gradient.setFinalStop(width, height / 2);
- break;
- case TL_BR:
- // draw the gradient from the top-left to the bottom-right
- m_gradient.setStart(0, 0);
- m_gradient.setFinalStop(width, height);
- break;
- }
-
- const QBrush &oldBrush = painter->brush();
- const QPen oldPen = painter->pen();
- painter->setPen(Qt::NoPen);
- painter->setBrush(m_gradient);
- painter->drawRoundedRect(opt->rect, m_radius, m_radius);
- painter->setBrush(oldBrush);
- painter->setPen(oldPen);
-}
-
-QSize QAndroidStyle::AndroidGradientDrawable::size() const
-{
- return QSize(m_radius * 2, m_radius * 2);
-}
-
-QAndroidStyle::AndroidClipDrawable::AndroidClipDrawable(const QVariantMap &drawable,
- QAndroidStyle::ItemType itemType)
- : AndroidDrawable(drawable, itemType)
-{
- m_drawable = fromMap(drawable.value(QLatin1String("drawable")).toMap(), itemType);
- m_factor = 0;
- m_orientation = Qt::Horizontal;
-}
-
-QAndroidStyle::AndroidClipDrawable::~AndroidClipDrawable()
-{
- delete m_drawable;
-}
-
-QAndroidStyle::AndroidDrawableType QAndroidStyle::AndroidClipDrawable::type() const
-{
- return QAndroidStyle::Clip;
-}
-
-void QAndroidStyle::AndroidClipDrawable::setFactor(double factor, Qt::Orientation orientation)
-{
- m_factor = factor;
- m_orientation = orientation;
-}
-
-void QAndroidStyle::AndroidClipDrawable::draw(QPainter *painter, const QStyleOption *opt) const
-{
- QStyleOption copy(*opt);
- if (m_orientation == Qt::Horizontal)
- copy.rect.setWidth(copy.rect.width() * m_factor);
- else
- copy.rect.setHeight(copy.rect.height() * m_factor);
-
- m_drawable->draw(painter, &copy);
-}
-
-QAndroidStyle::AndroidStateDrawable::AndroidStateDrawable(const QVariantMap &drawable,
- QAndroidStyle::ItemType itemType)
- : AndroidDrawable(drawable, itemType)
-{
- const QVariantList states = drawable.value(QLatin1String("stateslist")).toList();
- for (const QVariant &stateVariant : states) {
- QVariantMap state = stateVariant.toMap();
- const int s = extractState(state.value(QLatin1String("states")).toMap());
- if (-1 == s)
- continue;
- const AndroidDrawable *ad = fromMap(state.value(QLatin1String("drawable")).toMap(), itemType);
- if (!ad)
- continue;
- StateType item;
- item.first = s;
- item.second = ad;
- m_states<<item;
- }
-}
-
-QAndroidStyle::AndroidStateDrawable::~AndroidStateDrawable()
-{
- for (const StateType &type : qAsConst(m_states))
- delete type.second;
-}
-
-QAndroidStyle::AndroidDrawableType QAndroidStyle::AndroidStateDrawable::type() const
-{
- return QAndroidStyle::State;
-}
-
-void QAndroidStyle::AndroidStateDrawable::draw(QPainter *painter, const QStyleOption *opt) const
-{
- const AndroidDrawable *drawable = bestAndroidStateMatch(opt);
- if (drawable)
- drawable->draw(painter, opt);
-}
-QSize QAndroidStyle::AndroidStateDrawable::sizeImage(const QStyleOption *opt) const
-{
- QSize s;
- const AndroidDrawable *drawable = bestAndroidStateMatch(opt);
- if (drawable)
- s = drawable->size();
- return s;
-}
-
-const QAndroidStyle::AndroidDrawable * QAndroidStyle::AndroidStateDrawable::bestAndroidStateMatch(const QStyleOption *opt) const
-{
- const AndroidDrawable *bestMatch = 0;
- if (!opt) {
- if (m_states.size())
- return m_states[0].second;
- return bestMatch;
- }
-
- uint bestCost = 0xffff;
- for (const StateType & state : m_states) {
- if (int(opt->state) == state.first)
- return state.second;
- uint cost = 1;
-
- int difference = int(opt->state^state.first);
-
- if (difference & QStyle::State_Active)
- cost <<= 1;
-
- if (difference & QStyle::State_Enabled)
- cost <<= 1;
-
- if (difference & QStyle::State_Raised)
- cost <<= 1;
-
- if (difference & QStyle::State_Sunken)
- cost <<= 1;
-
- if (difference & QStyle::State_Off)
- cost <<= 1;
-
- if (difference & QStyle::State_On)
- cost <<= 1;
-
- if (difference & QStyle::State_HasFocus)
- cost <<= 1;
-
- if (difference & QStyle::State_Selected)
- cost <<= 1;
-
- if (cost < bestCost) {
- bestCost = cost;
- bestMatch = state.second;
- }
- }
- return bestMatch;
-}
-
-int QAndroidStyle::AndroidStateDrawable::extractState(const QVariantMap &value)
-{
- QStyle::State state = QStyle::State_Enabled | QStyle::State_Active;;
- for (auto it = value.cbegin(), end = value.cend(); it != end; ++it) {
- const QString &key = it.key();
- bool val = it.value().toString() == QLatin1String("true");
- if (key == QLatin1String("enabled")) {
- state.setFlag(QStyle::State_Enabled, val);
- continue;
- }
-
- if (key == QLatin1String("window_focused")) {
- state.setFlag(QStyle::State_Active, val);
- continue;
- }
-
- if (key == QLatin1String("focused")) {
- state.setFlag(QStyle::State_HasFocus, val);
- continue;
- }
-
- if (key == QLatin1String("checked")) {
- state |= val ? QStyle::State_On : QStyle::State_Off;
- continue;
- }
-
- if (key == QLatin1String("pressed")) {
- state |= val ? QStyle::State_Sunken : QStyle::State_Raised;
- continue;
- }
-
- if (key == QLatin1String("selected")) {
- state.setFlag(QStyle::State_Selected, val);
- continue;
- }
-
- if (key == QLatin1String("active")) {
- state.setFlag(QStyle::State_Active, val);
- continue;
- }
-
- if (key == QLatin1String("multiline"))
- return 0;
-
- if (key == QLatin1String("background") && val)
- return -1;
- }
- return static_cast<int>(state);
-}
-
-void QAndroidStyle::AndroidStateDrawable::setPaddingLeftToSizeWidth()
-{
- for (const StateType &type : qAsConst(m_states))
- const_cast<AndroidDrawable *>(type.second)->setPaddingLeftToSizeWidth();
-}
-
-QAndroidStyle::AndroidLayerDrawable::AndroidLayerDrawable(const QVariantMap &drawable,
- QAndroidStyle::ItemType itemType)
- : AndroidDrawable(drawable, itemType)
-{
- m_id = 0;
- m_factor = 1;
- m_orientation = Qt::Horizontal;
- const QVariantList layers = drawable.value(QLatin1String("layers")).toList();
- for (const QVariant &layer : layers) {
- QVariantMap layerMap = layer.toMap();
- AndroidDrawable *ad = fromMap(layerMap, itemType);
- if (ad) {
- LayerType l;
- l.second = ad;
- l.first = layerMap.value(QLatin1String("id")).toInt();
- m_layers << l;
- }
- }
-}
-
-QAndroidStyle::AndroidLayerDrawable::~AndroidLayerDrawable()
-{
- for (const LayerType &layer : qAsConst(m_layers))
- delete layer.second;
-}
-
-QAndroidStyle::AndroidDrawableType QAndroidStyle::AndroidLayerDrawable::type() const
-{
- return QAndroidStyle::Layer;
-}
-
-void QAndroidStyle::AndroidLayerDrawable::setFactor(int id, double factor, Qt::Orientation orientation)
-{
- m_id = id;
- m_factor = factor;
- m_orientation = orientation;
-}
-
-void QAndroidStyle::AndroidLayerDrawable::draw(QPainter *painter, const QStyleOption *opt) const
-{
- for (const LayerType &layer : m_layers) {
- if (layer.first == m_id) {
- QStyleOption copy(*opt);
- if (m_orientation == Qt::Horizontal)
- copy.rect.setWidth(copy.rect.width() * m_factor);
- else
- copy.rect.setHeight(copy.rect.height() * m_factor);
- layer.second->draw(painter, &copy);
- } else {
- layer.second->draw(painter, opt);
- }
- }
-}
-
-QAndroidStyle::AndroidDrawable *QAndroidStyle::AndroidLayerDrawable::layer(int id) const
-{
- for (const LayerType &layer : m_layers)
- if (layer.first == id)
- return layer.second;
- return 0;
-}
-
-QSize QAndroidStyle::AndroidLayerDrawable::size() const
-{
- QSize sz;
- for (const LayerType &layer : m_layers)
- sz = sz.expandedTo(layer.second->size());
- return sz;
-}
-
-QAndroidStyle::AndroidControl::AndroidControl(const QVariantMap &control,
- QAndroidStyle::ItemType itemType)
-{
- QVariantMap::const_iterator it = control.find(QLatin1String("View_background"));
- if (it != control.end())
- m_background = AndroidDrawable::fromMap(it.value().toMap(), itemType);
- else
- m_background = 0;
-
- it = control.find(QLatin1String("View_minWidth"));
- if (it != control.end())
- m_minSize.setWidth(it.value().toInt());
-
- it = control.find(QLatin1String("View_minHeight"));
- if (it != control.end())
- m_minSize.setHeight(it.value().toInt());
-
- it = control.find(QLatin1String("View_maxWidth"));
- if (it != control.end())
- m_maxSize.setWidth(it.value().toInt());
-
- it = control.find(QLatin1String("View_maxHeight"));
- if (it != control.end())
- m_maxSize.setHeight(it.value().toInt());
-}
-
-QAndroidStyle::AndroidControl::~AndroidControl()
-{
- delete m_background;
-}
-
-void QAndroidStyle::AndroidControl::drawControl(const QStyleOption *opt, QPainter *p, const QWidget * /* w */)
-{
- if (m_background) {
- m_background->draw(p, opt);
- } else {
- if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
- if ((frame->state & State_Sunken) || (frame->state & State_Raised)) {
- qDrawShadePanel(p, frame->rect, frame->palette, frame->state & State_Sunken,
- frame->lineWidth);
- } else {
- qDrawPlainRect(p, frame->rect, frame->palette.foreground().color(), frame->lineWidth);
- }
- } else {
- if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) {
- QColor bg = fropt->backgroundColor;
- QPen oldPen = p->pen();
- if (bg.isValid()) {
- int h, s, v;
- bg.getHsv(&h, &s, &v);
- if (v >= 128)
- p->setPen(Qt::black);
- else
- p->setPen(Qt::white);
- } else {
- p->setPen(opt->palette.foreground().color());
- }
- QRect focusRect = opt->rect.adjusted(1, 1, -1, -1);
- p->drawRect(focusRect.adjusted(0, 0, -1, -1)); //draw pen inclusive
- p->setPen(oldPen);
- } else {
- p->fillRect(opt->rect, opt->palette.brush(QPalette::Background));
- }
- }
- }
-}
-
-QRect QAndroidStyle::AndroidControl::subElementRect(QStyle::SubElement /* subElement */,
- const QStyleOption *option,
- const QWidget * /* widget */) const
-{
- if (const AndroidDrawable *drawable = backgroundDrawable()) {
- if (drawable->type() == State)
- drawable = static_cast<const AndroidStateDrawable *>(backgroundDrawable())->bestAndroidStateMatch(option);
-
- const QMargins &padding = drawable->padding();
-
- QRect r = option->rect.adjusted(padding.left(), padding.top(),
- -padding.right(), -padding.bottom());
-
- if (r.width() < m_minSize.width())
- r.setWidth(m_minSize.width());
-
- if (r.height() < m_minSize.height())
- r.setHeight(m_minSize.height());
-
- return visualRect(option->direction, option->rect, r);
- }
- return option->rect;
-}
-
-QRect QAndroidStyle::AndroidControl::subControlRect(const QStyleOptionComplex *option,
- QStyle::SubControl /*sc*/,
- const QWidget *widget) const
-{
- return subElementRect(QStyle::SE_CustomBase, option, widget);
-}
-
-QSize QAndroidStyle::AndroidControl::sizeFromContents(const QStyleOption *opt,
- const QSize &contentsSize,
- const QWidget * /* w */) const
-{
- QSize sz;
- if (const AndroidDrawable *drawable = backgroundDrawable()) {
-
- if (drawable->type() == State)
- drawable = static_cast<const AndroidStateDrawable*>(backgroundDrawable())->bestAndroidStateMatch(opt);
- const QMargins &padding = drawable->padding();
- sz.setWidth(padding.left() + padding.right());
- sz.setHeight(padding.top() + padding.bottom());
- if (sz.isEmpty())
- sz = drawable->size();
- }
- sz += contentsSize;
- if (contentsSize.height() < opt->fontMetrics.height())
- sz.setHeight(sz.height() + (opt->fontMetrics.height() - contentsSize.height()));
- if (sz.height() < m_minSize.height())
- sz.setHeight(m_minSize.height());
- if (sz.width() < m_minSize.width())
- sz.setWidth(m_minSize.width());
- return sz;
-}
-
-QMargins QAndroidStyle::AndroidControl::padding()
-{
- if (const AndroidDrawable *drawable = m_background) {
- if (drawable->type() == State)
- drawable = static_cast<const AndroidStateDrawable *>(m_background)->bestAndroidStateMatch(0);
- return drawable->padding();
- }
- return QMargins();
-}
-
-QSize QAndroidStyle::AndroidControl::size(const QStyleOption *option)
-{
- if (const AndroidDrawable *drawable = backgroundDrawable()) {
- if (drawable->type() == State)
- drawable = static_cast<const AndroidStateDrawable *>(backgroundDrawable())->bestAndroidStateMatch(option);
- return drawable->size();
- }
- return QSize();
-}
-
-const QAndroidStyle::AndroidDrawable *QAndroidStyle::AndroidControl::backgroundDrawable() const
-{
- return m_background;
-}
-
-QAndroidStyle::AndroidCompoundButtonControl::AndroidCompoundButtonControl(const QVariantMap &control,
- ItemType itemType)
- : AndroidControl(control, itemType)
-{
- QVariantMap::const_iterator it = control.find(QLatin1String("CompoundButton_button"));
- if (it != control.end()) {
- m_button = AndroidDrawable::fromMap(it.value().toMap(), itemType);
- const_cast<AndroidDrawable *>(m_button)->setPaddingLeftToSizeWidth();
- } else {
- m_button = 0;
- }
-}
-
-QAndroidStyle::AndroidCompoundButtonControl::~AndroidCompoundButtonControl()
-{
- delete m_button;
-}
-
-void QAndroidStyle::AndroidCompoundButtonControl::drawControl(const QStyleOption *opt,
- QPainter *p,
- const QWidget *w)
-{
- AndroidControl::drawControl(opt, p, w);
- if (m_button)
- m_button->draw(p, opt);
-}
-
-QMargins QAndroidStyle::AndroidCompoundButtonControl::padding()
-{
- if (m_button)
- return m_button->padding();
- return AndroidControl::padding();
-}
-
-QSize QAndroidStyle::AndroidCompoundButtonControl::size(const QStyleOption *option)
-{
- if (m_button) {
- if (m_button->type() == State)
- return static_cast<const AndroidStateDrawable *>(m_button)->bestAndroidStateMatch(option)->size();
- return m_button->size();
- }
- return AndroidControl::size(option);
-}
-
-const QAndroidStyle::AndroidDrawable * QAndroidStyle::AndroidCompoundButtonControl::backgroundDrawable() const
-{
- return m_background ? m_background : m_button;
-}
-
-QAndroidStyle::AndroidProgressBarControl::AndroidProgressBarControl(const QVariantMap &control,
- ItemType itemType)
- : AndroidControl(control, itemType)
-{
- QVariantMap::const_iterator it = control.find(QLatin1String("ProgressBar_indeterminateDrawable"));
- if (it != control.end())
- m_indeterminateDrawable = AndroidDrawable::fromMap(it.value().toMap(), itemType);
- else
- m_indeterminateDrawable = 0;
-
- it = control.find(QLatin1String("ProgressBar_progressDrawable"));
- if (it != control.end())
- m_progressDrawable = AndroidDrawable::fromMap(it.value().toMap(), itemType);
- else
- m_progressDrawable = 0;
-
- it = control.find(QLatin1String("ProgressBar_progress_id"));
- if (it != control.end())
- m_progressId = it.value().toInt();
-
- it = control.find(QLatin1String("ProgressBar_secondaryProgress_id"));
- if (it != control.end())
- m_secondaryProgress_id = it.value().toInt();
-
- it = control.find(QLatin1String("ProgressBar_minWidth"));
- if (it != control.end())
- m_minSize.setWidth(it.value().toInt());
-
- it = control.find(QLatin1String("ProgressBar_minHeight"));
- if (it != control.end())
- m_minSize.setHeight(it.value().toInt());
-
- it = control.find(QLatin1String("ProgressBar_maxWidth"));
- if (it != control.end())
- m_maxSize.setWidth(it.value().toInt());
-
- it = control.find(QLatin1String("ProgressBar_maxHeight"));
- if (it != control.end())
- m_maxSize.setHeight(it.value().toInt());
-}
-
-QAndroidStyle::AndroidProgressBarControl::~AndroidProgressBarControl()
-{
- delete m_progressDrawable;
- delete m_indeterminateDrawable;
-}
-
-void QAndroidStyle::AndroidProgressBarControl::drawControl(const QStyleOption *option, QPainter *p, const QWidget * /* w */)
-{
- if (!m_progressDrawable)
- return;
-
- if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
- if (m_progressDrawable->type() == QAndroidStyle::Layer) {
- const double fraction = double(qint64(pb->progress) - pb->minimum) / (qint64(pb->maximum) - pb->minimum);
- QAndroidStyle::AndroidDrawable *clipDrawable = static_cast<QAndroidStyle::AndroidLayerDrawable *>(m_progressDrawable)->layer(m_progressId);
- if (clipDrawable->type() == QAndroidStyle::Clip)
- static_cast<AndroidClipDrawable *>(clipDrawable)->setFactor(fraction, pb->orientation);
- else
- static_cast<AndroidLayerDrawable *>(m_progressDrawable)->setFactor(m_progressId, fraction, pb->orientation);
- }
- m_progressDrawable->draw(p, option);
- }
-}
-
-QRect QAndroidStyle::AndroidProgressBarControl::subElementRect(QStyle::SubElement subElement,
- const QStyleOption *option,
- const QWidget *widget) const
-{
- if (const QStyleOptionProgressBar *progressBarOption =
- qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
- const bool horizontal = progressBarOption->orientation == Qt::Vertical;
- if (!m_background)
- return option->rect;
-
- QMargins padding = m_background->padding();
- QRect p(padding.left(), padding.top(), padding.right() - padding.left(), padding.bottom() - padding.top());
- padding = m_indeterminateDrawable->padding();
- p |= QRect(padding.left(), padding.top(), padding.right() - padding.left(), padding.bottom() - padding.top());
- padding = m_progressDrawable->padding();
- p |= QRect(padding.left(), padding.top(), padding.right() - padding.left(), padding.bottom() - padding.top());
- QRect r = option->rect.adjusted(p.left(), p.top(), -p.right(), -p.bottom());
-
- if (horizontal) {
- if (r.height()<m_minSize.height())
- r.setHeight(m_minSize.height());
-
- if (r.height()>m_maxSize.height())
- r.setHeight(m_maxSize.height());
- } else {
- if (r.width()<m_minSize.width())
- r.setWidth(m_minSize.width());
-
- if (r.width()>m_maxSize.width())
- r.setWidth(m_maxSize.width());
- }
- return visualRect(option->direction, option->rect, r);
- }
- return AndroidControl::subElementRect(subElement, option, widget);
-}
-
-QSize QAndroidStyle::AndroidProgressBarControl::sizeFromContents(const QStyleOption *opt,
- const QSize &contentsSize,
- const QWidget * /* w */) const
-{
- QSize sz(contentsSize);
- if (sz.height() < m_minSize.height())
- sz.setHeight(m_minSize.height());
- if (sz.width() < m_minSize.width())
- sz.setWidth(m_minSize.width());
-
- if (const QStyleOptionProgressBar *progressBarOption =
- qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
- if (progressBarOption->orientation == Qt::Vertical) {
- if (sz.height() > m_maxSize.height())
- sz.setHeight(m_maxSize.height());
- } else {
- if (sz.width() > m_maxSize.width())
- sz.setWidth(m_maxSize.width());
- }
- }
- return contentsSize;
-}
-
-QAndroidStyle::AndroidSeekBarControl::AndroidSeekBarControl(const QVariantMap &control,
- ItemType itemType)
- : AndroidProgressBarControl(control, itemType)
-{
- QVariantMap::const_iterator it = control.find(QLatin1String("SeekBar_thumb"));
- if (it != control.end())
- m_seekBarThumb = AndroidDrawable::fromMap(it.value().toMap(), itemType);
- else
- m_seekBarThumb = 0;
-}
-
-QAndroidStyle::AndroidSeekBarControl::~AndroidSeekBarControl()
-{
- delete m_seekBarThumb;
-}
-
-void QAndroidStyle::AndroidSeekBarControl::drawControl(const QStyleOption *option,
- QPainter *p,
- const QWidget * /* w */)
-{
- if (!m_seekBarThumb || !m_progressDrawable)
- return;
-
- if (const QStyleOptionSlider *styleOption =
- qstyleoption_cast<const QStyleOptionSlider *>(option)) {
- double factor = double(styleOption->sliderPosition - styleOption->minimum)
- / double(styleOption->maximum - styleOption->minimum);
-
- // Android does not have a vertical slider. To support the vertical orientation, we rotate
- // the painter and pretend that we are horizontal.
- if (styleOption->orientation == Qt::Vertical)
- factor = 1 - factor;
-
- if (m_progressDrawable->type() == QAndroidStyle::Layer) {
- QAndroidStyle::AndroidDrawable *clipDrawable = static_cast<QAndroidStyle::AndroidLayerDrawable *>(m_progressDrawable)->layer(m_progressId);
- if (clipDrawable->type() == QAndroidStyle::Clip)
- static_cast<QAndroidStyle::AndroidClipDrawable *>(clipDrawable)->setFactor(factor, Qt::Horizontal);
- else
- static_cast<QAndroidStyle::AndroidLayerDrawable *>(m_progressDrawable)->setFactor(m_progressId, factor, Qt::Horizontal);
- }
- const AndroidDrawable *drawable = m_seekBarThumb;
- if (drawable->type() == State)
- drawable = static_cast<const QAndroidStyle::AndroidStateDrawable *>(m_seekBarThumb)->bestAndroidStateMatch(option);
- QStyleOption copy(*option);
-
- p->save();
-
- if (styleOption->orientation == Qt::Vertical) {
- // rotate the painter, and transform the rectangle to match
- p->rotate(90);
- copy.rect = QRect(copy.rect.y(), copy.rect.x() - copy.rect.width(), copy.rect.height(), copy.rect.width());
- }
-
- copy.rect.setHeight(m_progressDrawable->size().height());
- copy.rect.setWidth(copy.rect.width() - drawable->size().width());
- const int yTranslate = abs(drawable->size().height() - copy.rect.height()) / 2;
- copy.rect.translate(drawable->size().width() / 2, yTranslate);
- m_progressDrawable->draw(p, &copy);
- int pos = copy.rect.width() * factor - drawable->size().width() / 2;
- copy.rect.translate(pos, -yTranslate);
- copy.rect.setSize(drawable->size());
- m_seekBarThumb->draw(p, &copy);
-
- p->restore();
- }
-}
-
-QSize QAndroidStyle::AndroidSeekBarControl::sizeFromContents(const QStyleOption *opt,
- const QSize &contentsSize,
- const QWidget *w) const
-{
- QSize sz = AndroidProgressBarControl::sizeFromContents(opt, contentsSize, w);
- if (!m_seekBarThumb)
- return sz;
- const AndroidDrawable *drawable = m_seekBarThumb;
- if (drawable->type() == State)
- drawable = static_cast<const QAndroidStyle::AndroidStateDrawable *>(m_seekBarThumb)->bestAndroidStateMatch(opt);
- return sz.expandedTo(drawable->size());
-}
-
-QRect QAndroidStyle::AndroidSeekBarControl::subControlRect(const QStyleOptionComplex *option,
- SubControl sc,
- const QWidget * /* widget */) const
-{
- const QStyleOptionSlider *styleOption =
- qstyleoption_cast<const QStyleOptionSlider *>(option);
-
- if (m_seekBarThumb && sc == SC_SliderHandle && styleOption) {
- const AndroidDrawable *drawable = m_seekBarThumb;
- if (drawable->type() == State)
- drawable = static_cast<const QAndroidStyle::AndroidStateDrawable *>(m_seekBarThumb)->bestAndroidStateMatch(option);
-
- QRect r(option->rect);
- double factor = double(styleOption->sliderPosition - styleOption->minimum)
- / (styleOption->maximum - styleOption->minimum);
- if (styleOption->orientation == Qt::Vertical) {
- int pos = option->rect.height() * (1 - factor) - double(drawable->size().height() / 2);
- r.setY(r.y() + pos);
- } else {
- int pos = option->rect.width() * factor - double(drawable->size().width() / 2);
- r.setX(r.x() + pos);
- }
- r.setSize(drawable->size());
- return r;
- }
- return option->rect;
-}
-
-QAndroidStyle::AndroidSpinnerControl::AndroidSpinnerControl(const QVariantMap &control,
- QAndroidStyle::ItemType itemType)
- : AndroidControl(control, itemType)
-{}
-
-QRect QAndroidStyle::AndroidSpinnerControl::subControlRect(const QStyleOptionComplex *option,
- SubControl sc,
- const QWidget *widget) const
-{
- if (sc == QStyle::SC_ComboBoxListBoxPopup)
- return option->rect;
- if (sc == QStyle::SC_ComboBoxArrow) {
- const QRect editField = subControlRect(option, QStyle::SC_ComboBoxEditField, widget);
- return QRect(editField.topRight(), QSize(option->rect.width() - editField.width(), option->rect.height()));
- }
- return AndroidControl::subControlRect(option, sc, widget);
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_CONFIG(style_android) || defined(QT_PLUGIN)
diff --git a/src/widgets/styles/qandroidstyle_p.h b/src/widgets/styles/qandroidstyle_p.h
deleted file mode 100644
index caff0afada..0000000000
--- a/src/widgets/styles/qandroidstyle_p.h
+++ /dev/null
@@ -1,395 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 BogDan Vatra <bogdan@kde.org>
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QANDROIDSTYLE_P_H
-#define QANDROIDSTYLE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of qstylefactory.cpp. This header may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtWidgets/private/qtwidgetsglobal_p.h>
-#include <QtCore/QList>
-#include <QtCore/QMargins>
-#include <QtCore/QHash>
-#include <QtCore/QVariantMap>
-#include "qfusionstyle_p.h"
-
-QT_BEGIN_NAMESPACE
-
-#if QT_CONFIG(style_android)
-
-class Q_WIDGETS_EXPORT QAndroidStyle : public QFusionStyle
-{
- Q_OBJECT
-
-public:
- enum ItemType
- {
- QC_UnknownType = -1,
- QC_View,
- QC_GroupBox,
- QC_Button,
- QC_Checkbox,
- QC_RadioButton,
- QC_Slider,
- QC_Switch,
- QC_EditText,
- QC_Combobox,
- QC_BusyIndicator,
- QC_ProgressBar,
- QC_Tab,
- QC_TabButton,
- QC_RatingIndicator,
- QC_SearchBox,
- QC_CustomControl=0xf00,
- QC_ControlMask=0xfff
- };
-
- struct Android9PatchChunk
- {
- QVector<int> xDivs;
- QVector<int> yDivs;
- QVector<int> colors;
- };
-
- struct AndroidItemStateInfo
- {
- AndroidItemStateInfo():state(0){}
- int state;
- QByteArray filePath;
- QByteArray hashKey;
- Android9PatchChunk chunkData;
- QSize size;
- QMargins padding;
- };
-
- enum AndroidDrawableType
- {
- Color,
- Image,
- Clip,
- NinePatch,
- Gradient,
- State,
- Layer
- };
-
- class AndroidDrawable
- {
- public:
- AndroidDrawable(const QVariantMap &drawable, ItemType itemType);
- virtual ~AndroidDrawable();
- virtual void initPadding(const QVariantMap &drawable);
- virtual AndroidDrawableType type() const = 0;
- virtual void draw(QPainter *painter,const QStyleOption *opt) const = 0;
- const QMargins &padding() const;
- virtual QSize size() const;
- static AndroidDrawable *fromMap(const QVariantMap &drawable, ItemType itemType);
- static QMargins extractMargins(const QVariantMap &value);
- virtual void setPaddingLeftToSizeWidth();
- protected:
- ItemType m_itemType;
- QMargins m_padding;
- };
-
- class AndroidColorDrawable: public AndroidDrawable
- {
- public:
- AndroidColorDrawable(const QVariantMap &drawable, ItemType itemType);
- virtual AndroidDrawableType type() const;
- virtual void draw(QPainter *painter,const QStyleOption *opt) const;
-
- protected:
- QColor m_color;
- };
-
- class AndroidImageDrawable: public AndroidDrawable
- {
- public:
- AndroidImageDrawable(const QVariantMap &drawable, ItemType itemType);
- virtual AndroidDrawableType type() const;
- virtual void draw(QPainter *painter,const QStyleOption *opt) const;
- virtual QSize size() const;
-
- protected:
- QString m_filePath;
- mutable QString m_hashKey;
- QSize m_size;
- };
-
- class Android9PatchDrawable: public AndroidImageDrawable
- {
- public:
- Android9PatchDrawable(const QVariantMap &drawable, ItemType itemType);
- virtual AndroidDrawableType type() const;
- virtual void draw(QPainter *painter, const QStyleOption *opt) const;
- private:
- static int calculateStretch(int boundsLimit, int startingPoint,
- int srcSpace, int numStrechyPixelsRemaining,
- int numFixedPixelsRemaining);
- void extractIntArray(const QVariantList &values, QVector<int> &array);
- private:
- Android9PatchChunk m_chunkData;
- };
-
- class AndroidGradientDrawable: public AndroidDrawable
- {
- public:
- enum GradientOrientation
- {
- TOP_BOTTOM,
- TR_BL,
- RIGHT_LEFT,
- BR_TL,
- BOTTOM_TOP,
- BL_TR,
- LEFT_RIGHT,
- TL_BR
- };
-
- public:
- AndroidGradientDrawable(const QVariantMap &drawable, ItemType itemType);
- virtual AndroidDrawableType type() const;
- virtual void draw(QPainter *painter, const QStyleOption *opt) const;
- QSize size() const;
- private:
- mutable QLinearGradient m_gradient;
- GradientOrientation m_orientation;
- int m_radius;
- };
-
- class AndroidClipDrawable: public AndroidDrawable
- {
- public:
- AndroidClipDrawable(const QVariantMap &drawable, ItemType itemType);
- ~AndroidClipDrawable();
- virtual AndroidDrawableType type() const;
- virtual void setFactor(double factor, Qt::Orientation orientation);
- virtual void draw(QPainter *painter, const QStyleOption *opt) const;
-
- private:
- double m_factor;
- Qt::Orientation m_orientation;
- const AndroidDrawable *m_drawable;
- };
-
- class AndroidStateDrawable: public AndroidDrawable
- {
- public:
- AndroidStateDrawable(const QVariantMap &drawable, ItemType itemType);
- ~AndroidStateDrawable();
- virtual AndroidDrawableType type() const;
- virtual void draw(QPainter *painter, const QStyleOption *opt) const;
- inline const AndroidDrawable *bestAndroidStateMatch(const QStyleOption *opt) const;
- static int extractState(const QVariantMap &value);
- virtual void setPaddingLeftToSizeWidth();
- QSize sizeImage(const QStyleOption *opt) const;
- private:
- typedef QPair<int, const AndroidDrawable *> StateType;
- QList<StateType> m_states;
- };
-
- class AndroidLayerDrawable: public AndroidDrawable
- {
- public:
- AndroidLayerDrawable(const QVariantMap &drawable, QAndroidStyle::ItemType itemType);
- ~AndroidLayerDrawable();
- virtual AndroidDrawableType type() const;
- virtual void setFactor(int id, double factor, Qt::Orientation orientation);
- virtual void draw(QPainter *painter, const QStyleOption *opt) const;
- AndroidDrawable *layer(int id) const;
- QSize size() const;
- private:
- typedef QPair<int, AndroidDrawable *> LayerType;
- QList<LayerType> m_layers;
- int m_id;
- double m_factor;
- Qt::Orientation m_orientation;
- };
-
- class AndroidControl
- {
- public:
- AndroidControl(const QVariantMap &control, ItemType itemType);
- virtual ~AndroidControl();
- virtual void drawControl(const QStyleOption *opt, QPainter *p, const QWidget *w);
- virtual QRect subElementRect(SubElement subElement,
- const QStyleOption *option,
- const QWidget *widget = 0) const;
- virtual QRect subControlRect(const QStyleOptionComplex *option,
- SubControl sc,
- const QWidget *widget = 0) const;
- virtual QSize sizeFromContents(const QStyleOption *opt,
- const QSize &contentsSize,
- const QWidget *w) const;
- virtual QMargins padding();
- virtual QSize size(const QStyleOption *option);
- protected:
- virtual const AndroidDrawable * backgroundDrawable() const;
- const AndroidDrawable *m_background;
- QSize m_minSize;
- QSize m_maxSize;
- };
-
- class AndroidCompoundButtonControl : public AndroidControl
- {
- public:
- AndroidCompoundButtonControl(const QVariantMap &control, ItemType itemType);
- virtual ~AndroidCompoundButtonControl();
- virtual void drawControl(const QStyleOption *opt, QPainter *p, const QWidget *w);
- virtual QMargins padding();
- virtual QSize size(const QStyleOption *option);
- protected:
- virtual const AndroidDrawable * backgroundDrawable() const;
- const AndroidDrawable *m_button;
- };
-
- class AndroidProgressBarControl : public AndroidControl
- {
- public:
- AndroidProgressBarControl(const QVariantMap &control, ItemType itemType);
- virtual ~AndroidProgressBarControl();
- virtual void drawControl(const QStyleOption *option, QPainter *p, const QWidget *w);
- virtual QRect subElementRect(SubElement subElement,
- const QStyleOption *option,
- const QWidget *widget = 0) const;
-
- QSize sizeFromContents(const QStyleOption *opt,
- const QSize &contentsSize,
- const QWidget *w) const;
- protected:
- AndroidDrawable *m_progressDrawable;
- AndroidDrawable *m_indeterminateDrawable;
- int m_secondaryProgress_id;
- int m_progressId;
- };
-
- class AndroidSeekBarControl : public AndroidProgressBarControl
- {
- public:
- AndroidSeekBarControl(const QVariantMap &control, ItemType itemType);
- virtual ~AndroidSeekBarControl();
- virtual void drawControl(const QStyleOption *option, QPainter *p, const QWidget *w);
- QSize sizeFromContents(const QStyleOption *opt,
- const QSize &contentsSize, const QWidget *w) const;
- QRect subControlRect(const QStyleOptionComplex *option, SubControl sc,
- const QWidget *widget = 0) const;
- private:
- AndroidDrawable *m_seekBarThumb;
- };
-
- class AndroidSpinnerControl : public AndroidControl
- {
- public:
- AndroidSpinnerControl(const QVariantMap &control, ItemType itemType);
- virtual ~AndroidSpinnerControl(){}
- virtual QRect subControlRect(const QStyleOptionComplex *option,
- SubControl sc,
- const QWidget *widget = 0) const;
- };
-
- typedef QList<AndroidItemStateInfo *> AndroidItemStateInfoList;
-
-public:
- QAndroidStyle();
- ~QAndroidStyle();
-
- virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const;
-
- virtual void drawControl(QStyle::ControlElement element, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const;
-
- virtual QRect subElementRect(SubElement subElement, const QStyleOption *option,
- const QWidget *widget = 0) const;
- virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
- const QWidget *widget = 0) const;
- virtual SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
- const QPoint &pt, const QWidget *widget = 0) const;
- virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
- SubControl sc, const QWidget *widget = 0) const;
-
- virtual int pixelMetric(PixelMetric metric, const QStyleOption *option = 0,
- const QWidget *widget = 0) const;
-
- virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
- const QSize &contentsSize, const QWidget *w = 0) const;
-
- virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt = 0,
- const QWidget *widget = 0) const;
-
- virtual QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
- const QStyleOption *opt) const;
-
- int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0,
- QStyleHintReturn *returnData = 0) const;
-
- virtual QPalette standardPalette() const;
- void polish(QWidget *widget);
- void unpolish(QWidget *widget);
-
-private:
- Q_DISABLE_COPY(QAndroidStyle)
- static ItemType qtControl(QStyle::ComplexControl control);
- static ItemType qtControl(QStyle::ContentsType contentsType);
- static ItemType qtControl(QStyle::ControlElement controlElement);
- static ItemType qtControl(QStyle::PrimitiveElement primitiveElement);
- static ItemType qtControl(QStyle::SubElement subElement);
- static ItemType qtControl(const QString &android);
-
-private:
- typedef QHash<int, AndroidControl *> AndroidControlsHash;
- AndroidControlsHash m_androidControlsHash;
- QPalette m_standardPalette;
- AndroidCompoundButtonControl *checkBoxControl;
-};
-
-#endif // style_android
-
-QT_END_NAMESPACE
-
-#endif // QANDROIDSTYLE_P_H
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 4a6a7bce4b..557277b9e0 100644
--- a/src/widgets/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
@@ -743,8 +743,9 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
% QLatin1String(metaObject()->className()), opt, QSize(size, size))
% HexString<uint>(pe);
if (!QPixmapCache::find(pixmapName, pixmap)) {
- int border = size/5;
- int sqsize = 2*(size/2);
+ qreal pixelRatio = p->device()->devicePixelRatioF();
+ int border = qRound(pixelRatio*(size/5));
+ int sqsize = qRound(pixelRatio*(2*(size/2)));
QImage image(sqsize, sqsize, QImage::Format_ARGB32_Premultiplied);
image.fill(0);
QPainter imagePainter(&image);
@@ -796,6 +797,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
imagePainter.drawPolygon(a);
imagePainter.end();
pixmap = QPixmap::fromImage(image);
+ pixmap.setDevicePixelRatio(pixelRatio);
QPixmapCache::insert(pixmapName, pixmap);
}
int xOffset = r.x() + (r.width() - size)/2;
@@ -889,6 +891,13 @@ QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItem *option, int
break;
}
+ if (wrapText) {
+ if (option->features & QStyleOptionViewItem::HasCheckIndicator)
+ bounds.setWidth(bounds.width() - proxyStyle->pixelMetric(QStyle::PM_IndicatorWidth) - 2 * textMargin);
+ if (option->features & QStyleOptionViewItem::HasDecoration)
+ bounds.setWidth(bounds.width() - option->decorationSize.width() - 2 * textMargin);
+ }
+
const int lineWidth = bounds.width();
const QSizeF size = viewItemTextLayout(textLayout, lineWidth);
return QSize(qCeil(size.width()) + 2 * textMargin, qCeil(size.height()));
@@ -994,11 +1003,14 @@ void QCommonStylePrivate::viewItemLayout(const QStyleOptionViewItem *opt, QRect
const bool hasCheck = checkRect->isValid();
const bool hasPixmap = pixmapRect->isValid();
const bool hasText = textRect->isValid();
- const int textMargin = hasText ? proxyStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, opt, widget) + 1 : 0;
- const int pixmapMargin = hasPixmap ? proxyStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, opt, widget) + 1 : 0;
- const int checkMargin = hasCheck ? proxyStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, opt, widget) + 1 : 0;
- int x = opt->rect.left();
- int y = opt->rect.top();
+ const bool hasMargin = (hasText | hasPixmap | hasCheck);
+ const int frameHMargin = hasMargin ?
+ proxyStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, opt, widget) + 1 : 0;
+ const int textMargin = hasText ? frameHMargin : 0;
+ const int pixmapMargin = hasPixmap ? frameHMargin : 0;
+ const int checkMargin = hasCheck ? frameHMargin : 0;
+ const int x = opt->rect.left();
+ const int y = opt->rect.top();
int w, h;
if (textRect->height() == 0 && (!hasPixmap || !sizehint)) {
@@ -1571,10 +1583,11 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
aligned.width() * pixmap.devicePixelRatio(),
pixmap.height() * pixmap.devicePixelRatio());
+ const int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, opt, widget);
if (header->direction == Qt::LeftToRight)
- rect.setLeft(rect.left() + pixw + 2);
+ rect.setLeft(rect.left() + pixw + margin);
else
- rect.setRight(rect.right() - pixw - 2);
+ rect.setRight(rect.right() - pixw - margin);
}
if (header->state & QStyle::State_On) {
QFont fnt = p->font();
@@ -2499,7 +2512,7 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
const bool vertical = pb->orientation == Qt::Vertical;
if (!vertical) {
if (pb->textVisible)
- textw = qMax(pb->fontMetrics.width(pb->text), pb->fontMetrics.width(QLatin1String("100%"))) + 6;
+ textw = qMax(pb->fontMetrics.horizontalAdvance(pb->text), pb->fontMetrics.horizontalAdvance(QLatin1String("100%"))) + 6;
}
if ((pb->textAlignment & Qt::AlignCenter) == 0) {
@@ -3411,6 +3424,7 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
QRect ir = toolbutton->rect;
QStyleOptionToolButton newBtn = *toolbutton;
newBtn.rect = QRect(ir.right() + 5 - mbi, ir.y() + ir.height() - mbi + 4, mbi - 6, mbi - 6);
+ newBtn.rect = visualRect(toolbutton->direction, button, newBtn.rect);
proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget);
}
}
@@ -4154,14 +4168,10 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex
#if QT_CONFIG(combobox)
case CC_ComboBox:
if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
- int x = cb->rect.x(),
- y = cb->rect.y(),
- wi = cb->rect.width(),
- he = cb->rect.height();
- int xpos = x;
- int margin = cb->frame ? 3 : 0;
- int bmarg = cb->frame ? 2 : 0;
- xpos += wi - bmarg - 16;
+ const int x = cb->rect.x(), y = cb->rect.y(), wi = cb->rect.width(), he = cb->rect.height();
+ const int margin = cb->frame ? qRound(QStyleHelper::dpiScaled(3)) : 0;
+ const int bmarg = cb->frame ? qRound(QStyleHelper::dpiScaled(2)) : 0;
+ const int xpos = x + wi - bmarg - qRound(QStyleHelper::dpiScaled(16));
switch (sc) {
@@ -4169,10 +4179,10 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex
ret = cb->rect;
break;
case SC_ComboBoxArrow:
- ret.setRect(xpos, y + bmarg, 16, he - 2*bmarg);
+ ret.setRect(xpos, y + bmarg, qRound(QStyleHelper::dpiScaled(16)), he - 2*bmarg);
break;
case SC_ComboBoxEditField:
- ret.setRect(x + margin, y + margin, wi - 2 * margin - 16, he - 2 * margin);
+ ret.setRect(x + margin, y + margin, wi - 2 * margin - qRound(QStyleHelper::dpiScaled(16)), he - 2 * margin);
break;
case SC_ComboBoxListBoxPopup:
ret = cb->rect;
@@ -5264,6 +5274,8 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget
break;
#endif
case SH_Widget_Animate:
+ // TODO Qt6: move this code in the SH_Widget_Animation_Duration case
+ // and replace false with 0 and true with 200.
#if QT_CONFIG(treeview)
if (qobject_cast<const QTreeView*>(widget)) {
ret = false;
@@ -5281,6 +5293,18 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget
ret = QAbstractItemView::ScrollPerItem;
break;
#endif
+ case SH_TitleBar_ShowToolTipsOnButtons:
+ ret = true;
+ break;
+ case SH_Widget_Animation_Duration:
+ ret = styleHint(SH_Widget_Animate, opt, widget, hret) ? 200 : 0;
+ break;
+ case SH_ComboBox_AllowWheelScrolling:
+ ret = true;
+ break;
+ case SH_SpinBox_ButtonsInsideFrame:
+ ret = true;
+ break;
default:
ret = 0;
break;
@@ -5687,6 +5711,22 @@ QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *opti
return QPixmap();
}
+#if QT_CONFIG(imageformat_png)
+static inline QString iconResourcePrefix() { return QStringLiteral(":/qt-project.org/styles/commonstyle/images/"); }
+static inline QString iconPngSuffix() { return QStringLiteral(".png"); }
+
+static void addIconFiles(const QString &prefix, const int sizes[], size_t count, QIcon &icon)
+{
+ for (size_t i = 0; i < count; ++i) {
+ const int size = sizes[i];
+ icon.addFile(prefix + QString::number(size) + iconPngSuffix(), QSize(size, size));
+ }
+}
+
+static const int dockTitleIconSizes[] = {10, 16, 20, 32, 48, 64};
+
+#endif // imageformat_png
+
/*!
\internal
*/
@@ -6193,12 +6233,20 @@ QIcon QCommonStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption
case SP_MediaVolumeMuted:
icon.addFile(QLatin1String(":/qt-project.org/styles/commonstyle/images/media-volume-muted-16.png"), QSize(16, 16));
break;
+ case SP_TitleBarCloseButton:
+ addIconFiles(iconResourcePrefix() + QStringLiteral("closedock-"),
+ dockTitleIconSizes, sizeof(dockTitleIconSizes)/sizeof(dockTitleIconSizes[0]), icon);
+ break;
case SP_TitleBarMenuButton:
# ifndef QT_NO_IMAGEFORMAT_XPM
icon.addPixmap(titleBarMenuCachedPixmapFromXPM());
# endif
icon.addFile(QLatin1String(":/qt-project.org/qmessagebox/images/qtlogo-64.png"));
break;
+ case SP_TitleBarNormalButton:
+ addIconFiles(iconResourcePrefix() + QStringLiteral("normalizedockup-"),
+ dockTitleIconSizes, sizeof(dockTitleIconSizes)/sizeof(dockTitleIconSizes[0]), icon);
+ break;
#endif // QT_NO_IMAGEFORMAT_PNG
default:
icon.addPixmap(proxy()->standardPixmap(standardIcon, option, widget));
@@ -6243,7 +6291,7 @@ QPixmap QCommonStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &p
// High intensity colors needs dark shifting in the color table, while
// low intensity colors needs light shifting. This is to increase the
- // percieved contrast.
+ // perceived contrast.
if ((red - factor > green && red - factor > blue)
|| (green - factor > red && green - factor > blue)
|| (blue - factor > red && blue - factor > green))
diff --git a/src/widgets/styles/qcommonstyle.h b/src/widgets/styles/qcommonstyle.h
index ed880a150f..f39915295e 100644
--- a/src/widgets/styles/qcommonstyle.h
+++ b/src/widgets/styles/qcommonstyle.h
@@ -56,40 +56,40 @@ public:
~QCommonStyle();
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
- const QWidget *w = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ const QWidget *w = nullptr) const override;
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
- const QWidget *w = Q_NULLPTR) const Q_DECL_OVERRIDE;
- QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ const QWidget *w = nullptr) const override;
+ QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = nullptr) const override;
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
- const QWidget *w = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ const QWidget *w = nullptr) const override;
SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
- const QPoint &pt, const QWidget *w = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ const QPoint &pt, const QWidget *w = nullptr) const override;
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc,
- const QWidget *w = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ const QWidget *w = nullptr) const override;
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
- const QSize &contentsSize, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ const QSize &contentsSize, const QWidget *widget = nullptr) const override;
- int pixelMetric(PixelMetric m, const QStyleOption *opt = Q_NULLPTR, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ int pixelMetric(PixelMetric m, const QStyleOption *opt = nullptr, const QWidget *widget = nullptr) const override;
- int styleHint(StyleHint sh, const QStyleOption *opt = Q_NULLPTR, const QWidget *w = Q_NULLPTR,
- QStyleHintReturn *shret = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ int styleHint(StyleHint sh, const QStyleOption *opt = nullptr, const QWidget *w = nullptr,
+ QStyleHintReturn *shret = nullptr) const override;
- QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *opt = Q_NULLPTR,
- const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
- QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *opt = Q_NULLPTR,
- const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *opt = nullptr,
+ const QWidget *widget = nullptr) const override;
+ QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *opt = nullptr,
+ const QWidget *widget = nullptr) const override;
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
- const QStyleOption *opt) const Q_DECL_OVERRIDE;
+ const QStyleOption *opt) const override;
int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
- Qt::Orientation orientation, const QStyleOption *option = Q_NULLPTR,
- const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
-
- void polish(QPalette &) Q_DECL_OVERRIDE;
- void polish(QApplication *app) Q_DECL_OVERRIDE;
- void polish(QWidget *widget) Q_DECL_OVERRIDE;
- void unpolish(QWidget *widget) Q_DECL_OVERRIDE;
- void unpolish(QApplication *application) Q_DECL_OVERRIDE;
+ Qt::Orientation orientation, const QStyleOption *option = nullptr,
+ const QWidget *widget = nullptr) const override;
+
+ void polish(QPalette &) override;
+ void polish(QApplication *app) override;
+ void polish(QWidget *widget) override;
+ void unpolish(QWidget *widget) override;
+ void unpolish(QApplication *application) override;
protected:
QCommonStyle(QCommonStylePrivate &dd);
diff --git a/src/widgets/styles/qcommonstyle_p.h b/src/widgets/styles/qcommonstyle_p.h
index 9fb731239a..93db75ac2d 100644
--- a/src/widgets/styles/qcommonstyle_p.h
+++ b/src/widgets/styles/qcommonstyle_p.h
@@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE
class QStringList;
// Private class
-class QCommonStylePrivate : public QStylePrivate
+class Q_WIDGETS_EXPORT QCommonStylePrivate : public QStylePrivate
{
Q_DECLARE_PUBLIC(QCommonStyle)
public:
diff --git a/src/widgets/styles/qdrawutil.h b/src/widgets/styles/qdrawutil.h
index d5582f2c90..346029e1b4 100644
--- a/src/widgets/styles/qdrawutil.h
+++ b/src/widgets/styles/qdrawutil.h
@@ -70,42 +70,42 @@ Q_WIDGETS_EXPORT void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint
Q_WIDGETS_EXPORT void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
const QPalette &pal, bool sunken = false,
int lineWidth = 1, int midLineWidth = 0,
- const QBrush *fill = Q_NULLPTR);
+ const QBrush *fill = nullptr);
Q_WIDGETS_EXPORT void qDrawShadeRect(QPainter *p, const QRect &r,
const QPalette &pal, bool sunken = false,
int lineWidth = 1, int midLineWidth = 0,
- const QBrush *fill = Q_NULLPTR);
+ const QBrush *fill = nullptr);
Q_WIDGETS_EXPORT void qDrawShadePanel(QPainter *p, int x, int y, int w, int h,
const QPalette &pal, bool sunken = false,
- int lineWidth = 1, const QBrush *fill = Q_NULLPTR);
+ int lineWidth = 1, const QBrush *fill = nullptr);
Q_WIDGETS_EXPORT void qDrawShadePanel(QPainter *p, const QRect &r,
const QPalette &pal, bool sunken = false,
- int lineWidth = 1, const QBrush *fill = Q_NULLPTR);
+ int lineWidth = 1, const QBrush *fill = nullptr);
Q_WIDGETS_EXPORT void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
const QPalette &pal, bool sunken = false,
- const QBrush *fill = Q_NULLPTR);
+ const QBrush *fill = nullptr);
Q_WIDGETS_EXPORT void qDrawWinButton(QPainter *p, const QRect &r,
const QPalette &pal, bool sunken = false,
- const QBrush *fill = Q_NULLPTR);
+ const QBrush *fill = nullptr);
Q_WIDGETS_EXPORT void qDrawWinPanel(QPainter *p, int x, int y, int w, int h,
const QPalette &pal, bool sunken = false,
- const QBrush *fill = Q_NULLPTR);
+ const QBrush *fill = nullptr);
Q_WIDGETS_EXPORT void qDrawWinPanel(QPainter *p, const QRect &r,
const QPalette &pal, bool sunken = false,
- const QBrush *fill = Q_NULLPTR);
+ const QBrush *fill = nullptr);
Q_WIDGETS_EXPORT void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &,
- int lineWidth = 1, const QBrush *fill = Q_NULLPTR);
+ int lineWidth = 1, const QBrush *fill = nullptr);
Q_WIDGETS_EXPORT void qDrawPlainRect(QPainter *p, const QRect &r, const QColor &,
- int lineWidth = 1, const QBrush *fill = Q_NULLPTR);
+ int lineWidth = 1, const QBrush *fill = nullptr);
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index e6ad0fc898..554c45d570 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -208,55 +208,6 @@ static QColor mergedColors(const QColor &colorA, const QColor &colorB, int facto
return tmp;
}
-static QPixmap colorizedImage(const QString &fileName, const QColor &color, int rotation = 0) {
-
- QString pixmapName = QLatin1String("$qt_ia-") % fileName % HexString<uint>(color.rgba()) % QString::number(rotation);
- QPixmap pixmap;
- if (!QPixmapCache::find(pixmapName, pixmap)) {
- QImage image(fileName);
-
- if (image.format() != QImage::Format_ARGB32_Premultiplied)
- image = image.convertToFormat( QImage::Format_ARGB32_Premultiplied);
-
- int width = image.width();
- int height = image.height();
- int source = color.rgba();
-
- unsigned char sourceRed = qRed(source);
- unsigned char sourceGreen = qGreen(source);
- unsigned char sourceBlue = qBlue(source);
-
- for (int y = 0; y < height; ++y)
- {
- QRgb *data = (QRgb*) image.scanLine(y);
- for (int x = 0 ; x < width ; x++) {
- QRgb col = data[x];
- unsigned int colorDiff = (qBlue(col) - qRed(col));
- unsigned char gray = qGreen(col);
- unsigned char red = gray + qt_div_255(sourceRed * colorDiff);
- unsigned char green = gray + qt_div_255(sourceGreen * colorDiff);
- unsigned char blue = gray + qt_div_255(sourceBlue * colorDiff);
- unsigned char alpha = qt_div_255(qAlpha(col) * qAlpha(source));
- data[x] = qRgba(std::min(alpha, red),
- std::min(alpha, green),
- std::min(alpha, blue),
- alpha);
- }
- }
- if (rotation != 0) {
- QTransform transform;
- transform.translate(-image.width()/2, -image.height()/2);
- transform.rotate(rotation);
- transform.translate(image.width()/2, image.height()/2);
- image = image.transformed(transform);
- }
-
- pixmap = QPixmap::fromImage(image);
- QPixmapCache::insert(pixmapName, pixmap);
- }
- return pixmap;
-}
-
// The default button and handle gradient
static QLinearGradient qt_fusion_gradient(const QRect &rect, const QBrush &baseColor, Direction direction = TopDown)
{
@@ -294,6 +245,59 @@ static QLinearGradient qt_fusion_gradient(const QRect &rect, const QBrush &baseC
return gradient;
}
+static void qt_fusion_draw_arrow(Qt::ArrowType type, QPainter *painter, const QStyleOption *option, const QRect &rect, const QColor &color)
+{
+ const int arrowWidth = QStyleHelper::dpiScaled(14);
+ const int arrowHeight = QStyleHelper::dpiScaled(8);
+
+ const int arrowMax = qMin(arrowHeight, arrowWidth);
+ const int rectMax = qMin(rect.height(), rect.width());
+ const int size = qMin(arrowMax, rectMax);
+
+ QPixmap cachePixmap;
+ QString cacheKey = QStyleHelper::uniqueName(QLatin1String("fusion-arrow"), option, rect.size())
+ % HexString<uint>(type)
+ % HexString<uint>(color.rgba());
+ if (!QPixmapCache::find(cacheKey, cachePixmap)) {
+ cachePixmap = styleCachePixmap(rect.size());
+ cachePixmap.fill(Qt::transparent);
+ QPainter cachePainter(&cachePixmap);
+
+ QRectF arrowRect;
+ arrowRect.setWidth(size);
+ arrowRect.setHeight(arrowHeight * size / arrowWidth);
+ if (type == Qt::LeftArrow || type == Qt::RightArrow)
+ arrowRect = arrowRect.transposed();
+ arrowRect.moveTo((rect.width() - arrowRect.width()) / 2.0,
+ (rect.height() - arrowRect.height()) / 2.0);
+
+ QPolygonF triangle;
+ triangle.reserve(3);
+ switch (type) {
+ case Qt::DownArrow:
+ triangle << arrowRect.topLeft() << arrowRect.topRight() << QPointF(arrowRect.center().x(), arrowRect.bottom());
+ break;
+ case Qt::RightArrow:
+ triangle << arrowRect.topLeft() << arrowRect.bottomLeft() << QPointF(arrowRect.right(), arrowRect.center().y());
+ break;
+ case Qt::LeftArrow:
+ triangle << arrowRect.topRight() << arrowRect.bottomRight() << QPointF(arrowRect.left(), arrowRect.center().y());
+ break;
+ default:
+ triangle << arrowRect.bottomLeft() << arrowRect.bottomRight() << QPointF(arrowRect.center().x(), arrowRect.top());
+ break;
+ }
+
+ cachePainter.setPen(Qt::NoPen);
+ cachePainter.setBrush(color);
+ cachePainter.setRenderHint(QPainter::Antialiasing);
+ cachePainter.drawPolygon(triangle);
+
+ QPixmapCache::insert(cacheKey, cachePixmap);
+ }
+
+ painter->drawPixmap(rect, cachePixmap);
+}
static void qt_fusion_draw_mdibutton(QPainter *painter, const QStyleOptionTitleBar *option, const QRect &tmp, bool hover, bool sunken)
{
@@ -533,43 +537,22 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem,
if (option->rect.width() <= 1 || option->rect.height() <= 1)
break;
QColor arrowColor = option->palette.foreground().color();
- QPixmap arrow;
- int rotation = 0;
+ arrowColor.setAlpha(160);
+ Qt::ArrowType arrow = Qt::UpArrow;
switch (elem) {
case PE_IndicatorArrowDown:
- rotation = 180;
+ arrow = Qt::DownArrow;
break;
case PE_IndicatorArrowRight:
- rotation = 90;
+ arrow = Qt::RightArrow;
break;
case PE_IndicatorArrowLeft:
- rotation = -90;
+ arrow = Qt::LeftArrow;
break;
default:
break;
}
- arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor, rotation);
- if (arrow.isNull())
- break;
-
- QRect rect = option->rect;
- QRect arrowRect;
- int imageMax = qMin(arrow.height(), arrow.width());
- int rectMax = qMin(rect.height(), rect.width());
- int size = qMin(imageMax, rectMax);
-
- arrowRect.setWidth(size);
- arrowRect.setHeight(size);
- if (arrow.width() > arrow.height())
- arrowRect.setHeight(arrow.height() * size / arrow.width());
- else
- arrowRect.setWidth(arrow.width() * size / arrow.height());
-
- arrowRect.moveTopLeft(rect.center() - arrowRect.center());
- painter->save();
- painter->setRenderHint(QPainter::SmoothPixmapTransform);
- painter->drawPixmap(arrowRect, arrow);
- painter->restore();
+ qt_fusion_draw_arrow(arrow, painter, option, option->rect, arrowColor);
}
break;
case PE_IndicatorViewItemCheck:
@@ -583,29 +566,23 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem,
case PE_IndicatorHeaderArrow:
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
QRect r = header->rect;
- QPixmap arrow;
QColor arrowColor = header->palette.foreground().color();
- QPoint offset = QPoint(0, -1);
+ arrowColor.setAlpha(180);
+ QPoint offset = QPoint(0, -2);
#if defined(Q_OS_LINUX)
if (header->sortIndicator & QStyleOptionHeader::SortUp) {
- arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor);
+ qt_fusion_draw_arrow(Qt::UpArrow, painter, option, r.translated(offset), arrowColor);
} else if (header->sortIndicator & QStyleOptionHeader::SortDown) {
- arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor, 180);
+ qt_fusion_draw_arrow(Qt::DownArrow, painter, option, r.translated(offset), arrowColor);
}
#else
if (header->sortIndicator & QStyleOptionHeader::SortUp) {
- arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor, 180);
+ qt_fusion_draw_arrow(Qt::DownArrow, painter, option, r.translated(offset), arrowColor);
} else if (header->sortIndicator & QStyleOptionHeader::SortDown) {
- arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor);
+ qt_fusion_draw_arrow(Qt::UpArrow, painter, option, r.translated(offset), arrowColor);
}
#endif
-
- if (!arrow.isNull()) {
- r.setSize(QSize(arrow.width()/2, arrow.height()/2));
- r.moveCenter(header->rect.center());
- painter->drawPixmap(r.translated(offset), arrow);
- }
}
break;
case PE_IndicatorButtonDropDown:
@@ -1553,17 +1530,18 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
QColor highlight = option->palette.highlight().color();
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
int w = 0;
+ const int margin = QStyleHelper::dpiScaled(5);
if (!menuItem->text.isEmpty()) {
painter->setFont(menuItem->font);
- proxy()->drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter,
+ proxy()->drawItemText(painter, menuItem->rect.adjusted(margin, 0, -margin, 0), Qt::AlignLeft | Qt::AlignVCenter,
menuItem->palette, menuItem->state & State_Enabled, menuItem->text,
QPalette::Text);
- w = menuItem->fontMetrics.width(menuItem->text) + 5;
+ w = menuItem->fontMetrics.horizontalAdvance(menuItem->text) + margin;
}
painter->setPen(shadow.lighter(106));
bool reverse = menuItem->direction == Qt::RightToLeft;
- painter->drawLine(menuItem->rect.left() + 5 + (reverse ? 0 : w), menuItem->rect.center().y(),
- menuItem->rect.right() - 5 - (reverse ? w : 0), menuItem->rect.center().y());
+ painter->drawLine(menuItem->rect.left() + margin + (reverse ? 0 : w), menuItem->rect.center().y(),
+ menuItem->rect.right() - margin - (reverse ? w : 0), menuItem->rect.center().y());
painter->restore();
break;
}
@@ -2055,7 +2033,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
QRect r = rect.adjusted(0, 1, 0, -1);
QPainter cachePainter(&cache);
QColor arrowColor = spinBox->palette.foreground().color();
- arrowColor.setAlpha(220);
+ arrowColor.setAlpha(160);
bool isEnabled = (spinBox->state & State_Enabled);
bool hover = isEnabled && (spinBox->state & State_MouseOver);
@@ -2166,23 +2144,10 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
} else if (spinBox->buttonSymbols == QAbstractSpinBox::UpDownArrows){
// arrows
- painter->setRenderHint(QPainter::SmoothPixmapTransform);
-
- QPixmap upArrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"),
- (spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled) ? arrowColor : disabledColor);
-
- QRectF upArrowRect = QRectF(upRect.center().x() - upArrow.width() / 4.0 + 1.0,
- upRect.center().y() - upArrow.height() / 4.0 + 1.0,
- upArrow.width() / 2.0, upArrow.height() / 2.0);
-
- cachePainter.drawPixmap(upArrowRect, upArrow, QRectF(QPointF(0.0, 0.0), upArrow.size()));
-
- QPixmap downArrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"),
- (spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled) ? arrowColor : disabledColor, 180);
- QRectF downArrowRect = QRectF(downRect.center().x() - downArrow.width() / 4.0 + 1.0,
- downRect.center().y() - downArrow.height() / 4.0 + 1.0,
- downArrow.width() / 2.0, downArrow.height() / 2.0);
- cachePainter.drawPixmap(downArrowRect, downArrow, QRectF(QPointF(0.0, 0.0), downArrow.size()));
+ qt_fusion_draw_arrow(Qt::UpArrow, &cachePainter, option, upRect.adjusted(0, 0, 0, 1),
+ (spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled) ? arrowColor : disabledColor);
+ qt_fusion_draw_arrow(Qt::DownArrow, &cachePainter, option, downRect,
+ (spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled) ? arrowColor : disabledColor);
}
cachePainter.end();
@@ -2419,8 +2384,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
bool hover = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_MouseOver);
bool sunken = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_Sunken);
qt_fusion_draw_mdibutton(painter, titleBar, shadeButtonRect, hover, sunken);
- QPixmap arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), textColor);
- painter->drawPixmap(shadeButtonRect.adjusted(5, 7, -5, -7), arrow);
+ qt_fusion_draw_arrow(Qt::UpArrow, painter, option, shadeButtonRect.adjusted(5, 7, -5, -7), textColor);
}
}
@@ -2431,8 +2395,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
bool hover = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_MouseOver);
bool sunken = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_Sunken);
qt_fusion_draw_mdibutton(painter, titleBar, unshadeButtonRect, hover, sunken);
- QPixmap arrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), textColor, 180);
- painter->drawPixmap(unshadeButtonRect.adjusted(5, 7, -5, -7), arrow);
+ qt_fusion_draw_arrow(Qt::DownArrow, painter, option, unshadeButtonRect.adjusted(5, 7, -5, -7), textColor);
}
}
@@ -2562,7 +2525,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
alphaOutline.setAlpha(180);
QColor arrowColor = option->palette.foreground().color();
- arrowColor.setAlpha(220);
+ arrowColor.setAlpha(160);
const QColor bgColor = QStyleHelper::backgroundColor(option->palette, widget);
const bool isDarkBg = bgColor.red() < 128 && bgColor.green() < 128 && bgColor.blue() < 128;
@@ -2706,20 +2669,16 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
painter->drawLine(pixmapRect.bottomLeft(), pixmapRect.bottomRight());
}
+ QRect upRect = scrollBarSubLine.adjusted(horizontal ? 0 : 1, horizontal ? 1 : 0, horizontal ? -2 : -1, horizontal ? -1 : -2);
painter->setBrush(Qt::NoBrush);
painter->setPen(d->innerContrastLine());
- painter->drawRect(scrollBarSubLine.adjusted(horizontal ? 0 : 1, horizontal ? 1 : 0 , horizontal ? -2 : -1, horizontal ? -1 : -2));
+ painter->drawRect(upRect);
// Arrows
- int rotation = 0;
+ Qt::ArrowType arrowType = Qt::UpArrow;
if (option->state & State_Horizontal)
- rotation = option->direction == Qt::LeftToRight ? -90 : 90;
- QRect upRect = scrollBarSubLine.translated(horizontal ? -2 : -1, 0);
- QPixmap arrowPixmap = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor, rotation);
- painter->drawPixmap(QRectF(upRect.center().x() - arrowPixmap.width() / 4.0 + 2.0,
- upRect.center().y() - arrowPixmap.height() / 4.0 + 1.0,
- arrowPixmap.width() / 2.0, arrowPixmap.height() / 2.0),
- arrowPixmap, QRectF(QPoint(0.0, 0.0), arrowPixmap.size()));
+ arrowType = option->direction == Qt::LeftToRight ? Qt::LeftArrow : Qt::RightArrow;
+ qt_fusion_draw_arrow(arrowType, painter, option, upRect, arrowColor);
}
// The AddLine (down/right) button
@@ -2747,19 +2706,15 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
painter->drawLine(pixmapRect.topLeft(), pixmapRect.topRight());
}
+ QRect downRect = scrollBarAddLine.adjusted(1, 1, -1, -1);
painter->setPen(d->innerContrastLine());
painter->setBrush(Qt::NoBrush);
- painter->drawRect(scrollBarAddLine.adjusted(1, 1, -1, -1));
+ painter->drawRect(downRect);
- int rotation = 180;
+ Qt::ArrowType arrowType = Qt::DownArrow;
if (option->state & State_Horizontal)
- rotation = option->direction == Qt::LeftToRight ? 90 : -90;
- QRect downRect = scrollBarAddLine.translated(-1, 1);
- QPixmap arrowPixmap = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor, rotation);
- painter->drawPixmap(QRectF(downRect.center().x() - arrowPixmap.width() / 4.0 + 2.0,
- downRect.center().y() - arrowPixmap.height() / 4.0,
- arrowPixmap.width() / 2.0, arrowPixmap.height() / 2.0),
- arrowPixmap, QRectF(QPoint(0.0, 0.0), arrowPixmap.size()));
+ arrowType = option->direction == Qt::LeftToRight ? Qt::RightArrow : Qt::LeftArrow;
+ qt_fusion_draw_arrow(arrowType, painter, option, downRect, arrowColor);
}
}
@@ -2780,6 +2735,8 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
pixmapName += QLatin1String("-editable");
if (isEnabled)
pixmapName += QLatin1String("-enabled");
+ if (!comboBox->frame)
+ pixmapName += QLatin1String("-frameless");
if (!QPixmapCache::find(pixmapName, cache)) {
cache = styleCachePixmap(comboBox->rect.size());
@@ -2805,7 +2762,8 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
buttonOption.state &= ~State_MouseOver;
}
- proxy()->drawPrimitive(PE_FrameLineEdit, &buttonOption, &cachePainter, widget);
+ if (comboBox->frame)
+ proxy()->drawPrimitive(PE_FrameLineEdit, &buttonOption, &cachePainter, widget);
// Draw button clipped
cachePainter.save();
@@ -2849,12 +2807,8 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption
if (comboBox->subControls & SC_ComboBoxArrow) {
// Draw the up/down arrow
QColor arrowColor = option->palette.buttonText().color();
- arrowColor.setAlpha(220);
- QPixmap downArrow = colorizedImage(QLatin1String(":/qt-project.org/styles/commonstyle/images/fusion_arrow.png"), arrowColor, 180);
- cachePainter.drawPixmap(QRectF(downArrowRect.center().x() - downArrow.width() / 4.0 + 1.0,
- downArrowRect.center().y() - downArrow.height() / 4.0 + 1.0,
- downArrow.width() / 2.0, downArrow.height() / 2.0),
- downArrow, QRectF(QPointF(0.0, 0.0), downArrow.size()));
+ arrowColor.setAlpha(160);
+ qt_fusion_draw_arrow(Qt::DownArrow, &cachePainter, option, downArrowRect, arrowColor);
}
cachePainter.end();
QPixmapCache::insert(pixmapName, cache);
@@ -3258,17 +3212,17 @@ QSize QFusionStyle::sizeFromContents(ContentsType type, const QStyleOption *opti
if (menuItem->text.contains(QLatin1Char('\t')))
w += tabSpacing;
else if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu)
- w += 2 * QFusionStylePrivate::menuArrowHMargin;
+ w += 2 * QStyleHelper::dpiScaled(QFusionStylePrivate::menuArrowHMargin);
else if (menuItem->menuItemType == QStyleOptionMenuItem::DefaultItem) {
QFontMetrics fm(menuItem->font);
QFont fontBold = menuItem->font;
fontBold.setBold(true);
QFontMetrics fmBold(fontBold);
- w += fmBold.width(menuItem->text) - fm.width(menuItem->text);
+ w += fmBold.width(menuItem->text) - fm.horizontalAdvance(menuItem->text);
}
- int checkcol = qMax<int>(maxpmw, QFusionStylePrivate::menuCheckMarkWidth); // Windows always shows a check column
+ const int checkcol = qMax<int>(maxpmw, QStyleHelper::dpiScaled(QFusionStylePrivate::menuCheckMarkWidth)); // Windows always shows a check column
w += checkcol;
- w += int(QFusionStylePrivate::menuRightBorder) + 10;
+ w += QStyleHelper::dpiScaled(int(QFusionStylePrivate::menuRightBorder) + 10);
newSize.setWidth(w);
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
if (!menuItem->text.isEmpty()) {
@@ -3282,8 +3236,8 @@ QSize QFusionStyle::sizeFromContents(ContentsType type, const QStyleOption *opti
}
#endif
}
- newSize.setWidth(newSize.width() + 12);
- newSize.setWidth(qMax(newSize.width(), 120));
+ newSize.setWidth(newSize.width() + QStyleHelper::dpiScaled(12));
+ newSize.setWidth(qMax<int>(newSize.width(), QStyleHelper::dpiScaled(120)));
}
break;
case CT_SizeGrip:
@@ -3546,8 +3500,8 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom
switch (subControl) {
case SC_ComboBoxArrow:
rect = visualRect(option->direction, option->rect, rect);
- rect.setRect(rect.right() - 18, rect.top() - 2,
- 19, rect.height() + 4);
+ rect.setRect(rect.right() - QStyleHelper::dpiScaled(18), rect.top() - 2,
+ QStyleHelper::dpiScaled(19), rect.height() + 4);
rect = visualRect(option->direction, option->rect, rect);
break;
case SC_ComboBoxEditField: {
@@ -3816,6 +3770,19 @@ QRect QFusionStyle::subElementRect(SubElement sr, const QStyleOption *opt, const
QIcon QFusionStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *option,
const QWidget *widget) const
{
+#if QT_CONFIG(imageformat_xpm)
+ switch (standardIcon) {
+ case SP_TitleBarNormalButton:
+ return QIcon(QPixmap(dock_widget_restore_xpm));
+ case SP_TitleBarMinButton:
+ return QIcon(QPixmap(workspace_minimize));
+ case SP_TitleBarCloseButton:
+ case SP_DockWidgetCloseButton:
+ return QIcon(QPixmap(dock_widget_close_xpm));
+ default:
+ break;
+ }
+#endif // imageformat_xpm
return QCommonStyle::standardIcon(standardIcon, option, widget);
}
diff --git a/src/widgets/styles/qfusionstyle_p.h b/src/widgets/styles/qfusionstyle_p.h
index aac27e51ab..e67e792727 100644
--- a/src/widgets/styles/qfusionstyle_p.h
+++ b/src/widgets/styles/qfusionstyle_p.h
@@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE
#if QT_CONFIG(style_fusion)
class QFusionStylePrivate;
-class QFusionStyle : public QCommonStyle
+class Q_WIDGETS_EXPORT QFusionStyle : public QCommonStyle
{
Q_OBJECT
Q_DECLARE_PRIVATE(QFusionStyle)
@@ -69,41 +69,41 @@ public:
QFusionStyle();
~QFusionStyle();
- QPalette standardPalette () const Q_DECL_OVERRIDE;
+ QPalette standardPalette () const override;
void drawPrimitive(PrimitiveElement elem,
const QStyleOption *option,
- QPainter *painter, const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ QPainter *painter, const QWidget *widget = 0) const override;
void drawControl(ControlElement ce, const QStyleOption *option, QPainter *painter,
- const QWidget *widget) const Q_DECL_OVERRIDE;
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ const QWidget *widget) const override;
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const override;
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
- QPainter *painter, const QWidget *widget) const Q_DECL_OVERRIDE;
- QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ QPainter *painter, const QWidget *widget) const override;
+ QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const override;
QSize sizeFromContents(ContentsType type, const QStyleOption *option,
- const QSize &size, const QWidget *widget) const Q_DECL_OVERRIDE;
+ const QSize &size, const QWidget *widget) const override;
SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
- const QPoint &pt, const QWidget *w = 0) const Q_DECL_OVERRIDE;
+ const QPoint &pt, const QWidget *w = 0) const override;
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
- SubControl sc, const QWidget *widget) const Q_DECL_OVERRIDE;
+ SubControl sc, const QWidget *widget) const override;
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
- const QStyleOption *opt) const Q_DECL_OVERRIDE;
+ const QStyleOption *opt) const override;
int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0,
- QStyleHintReturn *returnData = 0) const Q_DECL_OVERRIDE;
- QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const Q_DECL_OVERRIDE;
+ QStyleHintReturn *returnData = 0) const override;
+ QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const override;
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0,
- const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ const QWidget *widget = 0) const override;
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
- const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ const QWidget *widget = 0) const override;
void drawItemPixmap(QPainter *painter, const QRect &rect,
- int alignment, const QPixmap &pixmap) const Q_DECL_OVERRIDE;
+ int alignment, const QPixmap &pixmap) const override;
void drawItemText(QPainter *painter, const QRect &rect,
int flags, const QPalette &pal, bool enabled,
- const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const Q_DECL_OVERRIDE;
- void polish(QWidget *widget) Q_DECL_OVERRIDE;
- void polish(QApplication *app) Q_DECL_OVERRIDE;
- void polish(QPalette &pal) Q_DECL_OVERRIDE;
- void unpolish(QWidget *widget) Q_DECL_OVERRIDE;
- void unpolish(QApplication *app) Q_DECL_OVERRIDE;
+ const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const override;
+ void polish(QWidget *widget) override;
+ void polish(QApplication *app) override;
+ void polish(QPalette &pal) override;
+ void unpolish(QWidget *widget) override;
+ void unpolish(QApplication *app) override;
protected:
QFusionStyle(QFusionStylePrivate &dd);
diff --git a/src/widgets/styles/qmacstyle.qdoc b/src/widgets/styles/qmacstyle.qdoc
deleted file mode 100644
index a77843a4dd..0000000000
--- a/src/widgets/styles/qmacstyle.qdoc
+++ /dev/null
@@ -1,207 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-/*!
- \class QMacStyle
- \brief The QMacStyle class provides a \macos style using the Apple Appearance Manager.
-
- \ingroup appearance
- \inmodule QtWidgets
- \internal
-
- This class is implemented as a wrapper to the HITheme
- APIs, allowing applications to be styled according to the current
- theme in use on \macos. This is done by having primitives
- in QStyle implemented in terms of what \macos would normally theme.
-
- \warning This style is only available on \macos because it relies on the
- HITheme APIs.
-
- There are additional issues that should be taken
- into consideration to make an application compatible with the
- \l{Apple Human Interface Guidelines}{Apple Human Interface Guidelines}. Some of these issues are outlined
- below.
-
- \list
-
- \li Layout - The restrictions on window layout are such that some
- aspects of layout that are style-dependent cannot be achieved
- using QLayout. Changes are being considered (and feedback would be
- appreciated) to make layouts QStyle-able. Some of the restrictions
- involve horizontal and vertical widget alignment and widget size
- (covered below).
-
- \li Widget size - \macos allows widgets to have specific fixed sizes. Qt
- does not fully implement this behavior so as to maintain cross-platform
- compatibility. As a result some widgets sizes may be inappropriate (and
- subsequently not rendered correctly by the HITheme APIs).The
- QWidget::sizeHint() will return the appropriate size for many
- managed widgets (widgets enumerated in \l QStyle::ContentsType).
-
- \li Effects - QMacStyle uses HITheme for performing most of the drawing, but
- also uses emulation in a few cases where HITheme does not provide the
- required functionality (for example, tab bars on Panther, the toolbar
- separator, etc). We tried to make the emulation as close to the original as
- possible. Please report any issues you see in effects or non-standard
- widgets.
-
- \endlist
-
- There are other issues that need to be considered in the feel of
- your application (including the general color scheme to match the
- Aqua colors). The Guidelines mentioned above will remain current
- with new advances and design suggestions for \macos.
-
- Note that the functions provided by QMacStyle are
- reimplementations of QStyle functions; see QStyle for their
- documentation.
-
- \image qmacstyle.png
- \sa QWindowsXPStyle, QWindowsStyle, QFusionStyle
-*/
-
-
-/*!
- \enum QMacStyle::WidgetSizePolicy
-
- \value SizeSmall
- \value SizeLarge
- \value SizeMini
- \value SizeDefault
-*/
-
-/*! \fn QMacStyle::QMacStyle()
- Constructs a QMacStyle object.
-*/
-
-/*! \fn QMacStyle::~QMacStyle()
- Destructs a QMacStyle object.
-*/
-
-/*! \fn void QMacStyle::polish(QPalette &pal)
- \reimp
-*/
-
-/*! \fn void QMacStyle::polish(QApplication *)
- \reimp
-*/
-
-/*! \fn void QMacStyle::unpolish(QApplication *)
- \reimp
-*/
-
-/*! \fn void QMacStyle::polish(QWidget* w)
- \reimp
-*/
-
-/*! \fn void QMacStyle::unpolish(QWidget* w)
- \reimp
-*/
-
-/*! \fn int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QWidget *widget) const
- \reimp
-*/
-
-/*! \fn QPalette QMacStyle::standardPalette() const
- \reimp
-*/
-
-/*! \fn int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w, QStyleHintReturn *hret) const
- \reimp
-*/
-
-/*! \fn QPixmap QMacStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const
- \reimp
-*/
-
-/*! \fn QPixmap QMacStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget) const
- \reimp
-*/
-
-/*! \fn void QMacStyle::setWidgetSizePolicy(const QWidget *widget, WidgetSizePolicy policy)
-
- \obsolete
-
- Call QWidget::setAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize,
- or Qt::WA_MacNormalSize instead.
-*/
-
-/*! \fn QMacStyle::WidgetSizePolicy QMacStyle::widgetSizePolicy(const QWidget *widget, const QStyleOption *opt = 0)
- \obsolete
-
- Call QWidget::testAttribute() with Qt::WA_MacMiniSize, Qt::WA_MacSmallSize,
- or Qt::WA_MacNormalSize instead.
-*/
-
-/*! \fn void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const
-
- \reimp
-*/
-
-/*! \fn void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter *p, const QWidget *w) const
-
- \reimp
-*/
-
-/*! \fn QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *widget) const
-
- \reimp
-*/
-
-/*! \fn void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *widget) const
- \reimp
-*/
-
-/*! \fn QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *widget) const
- \reimp
-*/
-
-/*! \fn QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const
- \reimp
-*/
-
-/*! \fn QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &csz, const QWidget *widget) const
- \reimp
-*/
-
-/*! \fn void QMacStyle::drawItemText(QPainter *p, const QRect &r, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole) const
- \reimp
-*/
-
-/*! \fn bool QMacStyle::event(QEvent *e)
- \reimp
-*/
-
-/*! \fn QIcon QMacStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *opt, const QWidget *widget) const
- \reimp
-*/
-
-/*! \fn int QMacStyle::layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option, const QWidget *widget) const
- \reimp
-*/
-
diff --git a/src/widgets/styles/qmacstyle_mac_p.h b/src/widgets/styles/qmacstyle_mac_p.h
deleted file mode 100644
index 7296539356..0000000000
--- a/src/widgets/styles/qmacstyle_mac_p.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMACSTYLE_MAC_P_H
-#define QMACSTYLE_MAC_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtWidgets/private/qtwidgetsglobal_p.h>
-#include <QtWidgets/qcommonstyle.h>
-
-QT_BEGIN_NAMESPACE
-
-
-#if QT_CONFIG(style_mac)
-
-class QPalette;
-
-class QPushButton;
-class QStyleOptionButton;
-class QMacStylePrivate;
-class QMacStyle : public QCommonStyle
-{
- Q_OBJECT
-public:
- QMacStyle();
- virtual ~QMacStyle();
-
- void polish(QWidget *w);
- void unpolish(QWidget *w);
-
- void polish(QApplication*);
- void unpolish(QApplication*);
-
- void polish(QPalette &pal);
-
- void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const;
- void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const;
- QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const;
- void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
- const QWidget *w = 0) const;
- SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
- const QPoint &pt, const QWidget *w = 0) const;
- QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc,
- const QWidget *w = 0) const;
- QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
- const QSize &contentsSize, const QWidget *w = 0) const;
-
- int pixelMetric(PixelMetric pm, const QStyleOption *opt = 0, const QWidget *widget = 0) const;
-
- QPalette standardPalette() const;
-
- virtual int styleHint(StyleHint sh, const QStyleOption *opt = 0, const QWidget *w = 0,
- QStyleHintReturn *shret = 0) const;
-
- enum WidgetSizePolicy { SizeSmall, SizeLarge, SizeMini, SizeDefault
- };
-
- static void setWidgetSizePolicy(const QWidget *w, WidgetSizePolicy policy);
- static WidgetSizePolicy widgetSizePolicy(const QWidget *w, const QStyleOption *opt = 0);
-
- QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *opt,
- const QWidget *widget = 0) const;
-
- QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
- const QStyleOption *opt) const;
-
- virtual void drawItemText(QPainter *p, const QRect &r, int flags, const QPalette &pal,
- bool enabled, const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const;
-
- bool event(QEvent *e);
-
- QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *opt = 0,
- const QWidget *widget = 0) const;
- int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
- Qt::Orientation orientation, const QStyleOption *option = 0,
- const QWidget *widget = 0) const;
-
-private:
- Q_DISABLE_COPY(QMacStyle)
- Q_DECLARE_PRIVATE(QMacStyle)
-
-#if QT_CONFIG(pushbutton)
- friend bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option);
-#endif
-};
-
-#endif
-
-QT_END_NAMESPACE
-
-#endif // QMACSTYLE_MAC_P_H
diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h
deleted file mode 100644
index 228abf950a..0000000000
--- a/src/widgets/styles/qmacstyle_mac_p_p.h
+++ /dev/null
@@ -1,292 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#ifndef QMACSTYLE_MAC_P_P_H
-#define QMACSTYLE_MAC_P_P_H
-
-#include <Carbon/Carbon.h>
-#undef check
-
-#include <QtWidgets/private/qtwidgetsglobal_p.h>
-#include "qmacstyle_mac_p.h"
-#include "qcommonstyle_p.h"
-#include <private/qapplication_p.h>
-#if QT_CONFIG(combobox)
-#include <private/qcombobox_p.h>
-#endif
-#include <private/qpainter_p.h>
-#include <private/qstylehelper_p.h>
-#include <qapplication.h>
-#include <qbitmap.h>
-#if QT_CONFIG(checkbox)
-#include <qcheckbox.h>
-#endif
-#include <qcombobox.h>
-#if QT_CONFIG(dialogbuttonbox)
-#include <qdialogbuttonbox.h>
-#endif
-#if QT_CONFIG(dockwidget)
-#include <qdockwidget.h>
-#endif
-#include <qevent.h>
-#include <qfocusframe.h>
-#include <qformlayout.h>
-#if QT_CONFIG(groupbox)
-#include <qgroupbox.h>
-#endif
-#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>
-#include <qpointer.h>
-#if QT_CONFIG(progressbar)
-#include <qprogressbar.h>
-#endif
-#if QT_CONFIG(pushbutton)
-#include <qpushbutton.h>
-#endif
-#include <qradiobutton.h>
-#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
-#include <qstyleoption.h>
-#include <qtextedit.h>
-#include <qtextstream.h>
-#include <qtoolbar.h>
-#if QT_CONFIG(toolbutton)
-#include <qtoolbutton.h>
-#endif
-#if QT_CONFIG(treeview)
-#include <qtreeview.h>
-#endif
-#if QT_CONFIG(tableview)
-#include <qtableview.h>
-#endif
-#include <qdebug.h>
-#if QT_CONFIG(datetimeedit)
-#include <qdatetimeedit.h>
-#endif
-#include <qmath.h>
-#include <qpair.h>
-#include <qvector.h>
-#include <QtWidgets/qgraphicsproxywidget.h>
-#include <QtWidgets/qgraphicsview.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.
-//
-
-Q_FORWARD_DECLARE_OBJC_CLASS(NSView);
-Q_FORWARD_DECLARE_OBJC_CLASS(NSScroller);
-
-QT_BEGIN_NAMESPACE
-
-/*
- AHIG:
- Apple Human Interface Guidelines
- http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/
-
- Builder:
- Apple Interface Builder v. 3.1.1
-*/
-
-// this works as long as we have at most 16 different control types
-#define CT1(c) CT2(c, c)
-#define CT2(c1, c2) ((uint(c1) << 16) | uint(c2))
-
-enum QAquaWidgetSize { QAquaSizeLarge = 0, QAquaSizeSmall = 1, QAquaSizeMini = 2,
- QAquaSizeUnknown = -1 };
-
-enum QCocoaWidgetKind {
- QCocoaArrowButton, // Disclosure triangle, like in QTreeView
- QCocoaCheckBox,
- QCocoaComboBox, // Editable QComboBox
- QCocoaPopupButton, // Non-editable QComboBox
- QCocoaPullDownButton, // QPushButton with menu
- QCocoaPushButton,
- QCocoaRadioButton,
- QCocoaHorizontalSlider,
- QCocoaVerticalSlider
-};
-
-typedef QPair<QCocoaWidgetKind, QAquaWidgetSize> QCocoaWidget;
-
-typedef void (^QCocoaDrawRectBlock)(NSRect, CGContextRef);
-
-#define SIZE(large, small, mini) \
- (controlSize == QAquaSizeLarge ? (large) : controlSize == QAquaSizeSmall ? (small) : (mini))
-
-// same as return SIZE(...) but optimized
-#define return_SIZE(large, small, mini) \
- do { \
- static const int sizes[] = { (large), (small), (mini) }; \
- return sizes[controlSize]; \
- } while (false)
-
-#if QT_CONFIG(pushbutton)
-bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option);
-#endif
-
-class QMacStylePrivate : public QCommonStylePrivate
-{
- Q_DECLARE_PUBLIC(QMacStyle)
-public:
- QMacStylePrivate();
- ~QMacStylePrivate();
-
- // Ideally these wouldn't exist, but since they already exist we need some accessors.
- static const int PushButtonLeftOffset;
- static const int PushButtonTopOffset;
- static const int PushButtonRightOffset;
- static const int PushButtonBottomOffset;
- static const int MiniButtonH;
- static const int SmallButtonH;
- static const int BevelButtonW;
- static const int BevelButtonH;
- static const int PushButtonContentPadding;
-
- enum Animates { AquaPushButton, AquaProgressBar, AquaListViewItemOpen, AquaScrollBar };
- static ThemeDrawState getDrawState(QStyle::State flags);
- QAquaWidgetSize aquaSizeConstrain(const QStyleOption *option, const QWidget *widg,
- QStyle::ContentsType ct = QStyle::CT_CustomBase,
- QSize szHint=QSize(-1, -1), QSize *insz = 0) const;
- QAquaWidgetSize effectiveAquaSizeConstrain(const QStyleOption *option, const QWidget *widg,
- QStyle::ContentsType ct = QStyle::CT_CustomBase,
- QSize szHint=QSize(-1, -1), QSize *insz = 0) const;
- void getSliderInfo(QStyle::ComplexControl cc, const QStyleOptionSlider *slider,
- HIThemeTrackDrawInfo *tdi, const QWidget *needToRemoveMe) const;
- inline int animateSpeed(Animates) const { return 33; }
-
- // Utility functions
- void drawColorlessButton(const HIRect &macRect, HIThemeButtonDrawInfo *bdi,
- QPainter *p, const QStyleOption *opt) const;
-
- QSize pushButtonSizeFromContents(const QStyleOptionButton *btn) const;
-
- HIRect pushButtonContentBounds(const QStyleOptionButton *btn,
- const HIThemeButtonDrawInfo *bdi) const;
-
- void initComboboxBdi(const QStyleOptionComboBox *combo, HIThemeButtonDrawInfo *bdi,
- const QWidget *widget, const ThemeDrawState &tds) const;
-
- static HIRect comboboxInnerBounds(const HIRect &outerBounds, int buttonKind);
-
- static QRect comboboxEditBounds(const QRect &outerBounds, const HIThemeButtonDrawInfo &bdi);
-
- static void drawCombobox(const HIRect &outerBounds, const HIThemeButtonDrawInfo &bdi, QPainter *p);
- static void drawTableHeader(const HIRect &outerBounds, bool drawTopBorder, bool drawLeftBorder,
- const HIThemeButtonDrawInfo &bdi, QPainter *p);
- bool contentFitsInPushButton(const QStyleOptionButton *btn, HIThemeButtonDrawInfo *bdi,
- ThemeButtonKind buttonKindToCheck) const;
- void initHIThemePushButton(const QStyleOptionButton *btn, const QWidget *widget,
- const ThemeDrawState tds,
- HIThemeButtonDrawInfo *bdi) const;
- QPixmap generateBackgroundPattern() const;
-
- void setAutoDefaultButton(QObject *button) const;
-
- NSView *cocoaControl(QCocoaWidget widget) const;
-
- void drawNSViewInRect(QCocoaWidget widget, NSView *view, const QRect &rect, QPainter *p, bool isQWidget = true, QCocoaDrawRectBlock drawRectBlock = nil) const;
- void resolveCurrentNSView(QWindow *window);
-
- void drawFocusRing(QPainter *p, const QRect &targetRect, int hMargin, int vMargin, qreal radius = 0) const;
-
-#if QT_CONFIG(tabbar)
- void tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *iconRect) const;
-#endif
-
-public:
- mutable QPointer<QObject> pressedButton;
- mutable QPointer<QObject> defaultButton;
- mutable QPointer<QObject> autoDefaultButton;
- static QVector<QPointer<QObject> > scrollBars;
-
- struct ButtonState {
- int frame;
- enum { ButtonDark, ButtonLight } dir;
- } buttonState;
- mutable QPointer<QFocusFrame> focusWidget;
- CFAbsoluteTime defaultButtonStart;
- bool mouseDown;
- void* receiver;
- NSScroller *horizontalScroller;
- NSScroller *verticalScroller;
- void *indicatorBranchButtonCell;
- NSView *backingStoreNSView;
- QHash<QCocoaWidget, NSView *> cocoaControls;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMACSTYLE_MAC_P_P_H
diff --git a/src/widgets/styles/qpixmapstyle_p.h b/src/widgets/styles/qpixmapstyle_p.h
index 618d6d2f50..590434d95e 100644
--- a/src/widgets/styles/qpixmapstyle_p.h
+++ b/src/widgets/styles/qpixmapstyle_p.h
@@ -136,34 +136,34 @@ public:
QPixmapStyle();
~QPixmapStyle();
- void polish(QApplication *application) Q_DECL_OVERRIDE;
- void polish(QPalette &palette) Q_DECL_OVERRIDE;
- void polish(QWidget *widget) Q_DECL_OVERRIDE;
- void unpolish(QApplication *application) Q_DECL_OVERRIDE;
- void unpolish(QWidget *widget) Q_DECL_OVERRIDE;
+ void polish(QApplication *application) override;
+ void polish(QPalette &palette) override;
+ void polish(QWidget *widget) override;
+ void unpolish(QApplication *application) override;
+ void unpolish(QWidget *widget) override;
void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
- QPainter *painter, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ QPainter *painter, const QWidget *widget = nullptr) const override;
void drawControl(ControlElement element, const QStyleOption *option,
- QPainter *painter, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ QPainter *painter, const QWidget *widget = nullptr) const override;
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *option,
- QPainter *painter, const QWidget *widget=0) const Q_DECL_OVERRIDE;
+ QPainter *painter, const QWidget *widget=0) const override;
QSize sizeFromContents(ContentsType type, const QStyleOption *option,
- const QSize &contentsSize, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ const QSize &contentsSize, const QWidget *widget = nullptr) const override;
QRect subElementRect(SubElement element, const QStyleOption *option,
- const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ const QWidget *widget = nullptr) const override;
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *option,
- SubControl sc, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ SubControl sc, const QWidget *widget = nullptr) const override;
- int pixelMetric(PixelMetric metric, const QStyleOption *option = Q_NULLPTR,
- const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr,
+ const QWidget *widget = nullptr) const override;
int styleHint(StyleHint hint, const QStyleOption *option,
- const QWidget *widget, QStyleHintReturn *returnData) const Q_DECL_OVERRIDE;
+ const QWidget *widget, QStyleHintReturn *returnData) const override;
SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option,
- const QPoint &pos, const QWidget *widget) const Q_DECL_OVERRIDE;
+ const QPoint &pos, const QWidget *widget) const override;
- bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE;
+ bool eventFilter(QObject *watched, QEvent *event) override;
void addDescriptor(ControlDescriptor control, const QString &fileName,
QMargins margins = QMargins(),
diff --git a/src/widgets/styles/qproxystyle.h b/src/widgets/styles/qproxystyle.h
index 20a0f12868..c26d9abf59 100644
--- a/src/widgets/styles/qproxystyle.h
+++ b/src/widgets/styles/qproxystyle.h
@@ -54,47 +54,47 @@ class Q_WIDGETS_EXPORT QProxyStyle : public QCommonStyle
Q_OBJECT
public:
- QProxyStyle(QStyle *style = Q_NULLPTR);
+ QProxyStyle(QStyle *style = nullptr);
QProxyStyle(const QString &key);
~QProxyStyle();
QStyle *baseStyle() const;
void setBaseStyle(QStyle *style);
- void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
- void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
- void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const override;
+ void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = nullptr) const override;
+ void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = nullptr) const override;
void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled,
- const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const Q_DECL_OVERRIDE;
- virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const Q_DECL_OVERRIDE;
+ const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const override;
+ virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const override;
- QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const Q_DECL_OVERRIDE;
+ QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const override;
- QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const Q_DECL_OVERRIDE;
- QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const Q_DECL_OVERRIDE;
- QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const Q_DECL_OVERRIDE;
- QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const Q_DECL_OVERRIDE;
+ QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const override;
+ QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const override;
+ QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const override;
+ QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const override;
- SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
- int styleHint(StyleHint hint, const QStyleOption *option = Q_NULLPTR, const QWidget *widget = Q_NULLPTR, QStyleHintReturn *returnData = Q_NULLPTR) const Q_DECL_OVERRIDE;
- int pixelMetric(PixelMetric metric, const QStyleOption *option = Q_NULLPTR, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget = nullptr) const override;
+ int styleHint(StyleHint hint, const QStyleOption *option = nullptr, const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const override;
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override;
int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
- Qt::Orientation orientation, const QStyleOption *option = Q_NULLPTR, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
+ Qt::Orientation orientation, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override;
- QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = Q_NULLPTR, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
- QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = Q_NULLPTR) const Q_DECL_OVERRIDE;
- QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const Q_DECL_OVERRIDE;
- QPalette standardPalette() const Q_DECL_OVERRIDE;
+ QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override;
+ QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = nullptr) const override;
+ QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const override;
+ QPalette standardPalette() const override;
- void polish(QWidget *widget) Q_DECL_OVERRIDE;
- void polish(QPalette &pal) Q_DECL_OVERRIDE;
- void polish(QApplication *app) Q_DECL_OVERRIDE;
+ void polish(QWidget *widget) override;
+ void polish(QPalette &pal) override;
+ void polish(QApplication *app) override;
- void unpolish(QWidget *widget) Q_DECL_OVERRIDE;
- void unpolish(QApplication *app) Q_DECL_OVERRIDE;
+ void unpolish(QWidget *widget) override;
+ void unpolish(QApplication *app) override;
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
private:
Q_DISABLE_COPY(QProxyStyle)
diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp
index 01d972af65..73a6554f1a 100644
--- a/src/widgets/styles/qstyle.cpp
+++ b/src/widgets/styles/qstyle.cpp
@@ -765,8 +765,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
*/
/*!
- \fn void QStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, \
- QPainter *painter, const QWidget *widget) const
+ \fn void QStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
Draws the given primitive \a element with the provided \a painter using the style
options specified by \a option.
@@ -1592,8 +1591,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
*/
/*!
- \fn QSize QStyle::sizeFromContents(ContentsType type, const QStyleOption *option, \
- const QSize &contentsSize, const QWidget *widget) const
+ \fn QSize QStyle::sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const
Returns the size of the element described by the specified
\a option and \a type, based on the provided \a contentsSize.
@@ -1840,9 +1838,8 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
\value SH_UnderlineShortcut Whether shortcuts are underlined.
- \value SH_SpellCheckUnderlineStyle A
- QTextCharFormat::UnderlineStyle value that specifies the way
- misspelled words should be underlined.
+ \value SH_SpellCheckUnderlineStyle Obsolete. Use SpellCheckUnderlineStyle
+ hint in QPlatformTheme instead.
\value SH_SpinBox_AnimateButton Animate a click when up or down is
pressed in a spin box.
@@ -1972,9 +1969,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
a tooltip is shown (notice: shown, not hidden). When a new wake isn't needed, a user-requested tooltip
will be shown nearly instantly.
- \value SH_Widget_Animate Determines if the widget should show animations or not, for example
- a transition between checked and unchecked statuses in a checkbox.
- This enum value has been introduced in Qt 5.2.
+ \value SH_Widget_Animate Deprecated. Use \l{SH_Widget_Animation_Duration} instead.
\value SH_Splitter_OpaqueResize Determines if resizing is opaque
This enum value has been introduced in Qt 5.2
@@ -1987,12 +1982,30 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
by the style. Can be overridden with QAbstractItemView::setVerticalScrollMode() and
QAbstractItemView::setHorizontalScrollMode(). This enum value has been introduced in Qt 5.7.
+ \value SH_TitleBar_ShowToolTipsOnButtons
+ Determines if tool tips are shown on window title bar buttons.
+ The Mac style, for example, sets this to false.
+ This enum value has been introduced in Qt 5.10.
+
+ \value SH_Widget_Animation_Duration
+ Determines how much an animation should last (in ms).
+ A value equal to zero means that the animations will be disabled.
+ This enum value has been introduced in Qt 5.10.
+
+ \value SH_ComboBox_AllowWheelScrolling
+ Determines if the mouse wheel can be used to scroll inside a QComboBox.
+ This is on by default in all styles except the Mac style.
+ This enum value has been introduced in Qt 5.10.
+
+ \value SH_SpinBox_ButtonsInsideFrame
+ Determnines if the spin box buttons are inside the line edit frame.
+ This enum value has been introduced in Qt 5.11.
+
\sa styleHint()
*/
/*!
- \fn int QStyle::styleHint(StyleHint hint, const QStyleOption *option, \
- const QWidget *widget, QStyleHintReturn *returnData) const
+ \fn int QStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const
Returns an integer representing the specified style \a hint for
the given \a widget described by the provided style \a option.
@@ -2104,8 +2117,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
*/
/*!
- \fn QPixmap QStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option, \
- const QWidget *widget) const
+ \fn QPixmap QStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option, const QWidget *widget) const
\obsolete
Returns a pixmap for the given \a standardPixmap.
@@ -2286,8 +2298,8 @@ int QStyle::sliderValueFromPosition(int min, int max, int pos, int span, bool up
Returns the style's standard palette.
Note that on systems that support system colors, the style's
- standard palette is not used. In particular, the Windows XP,
- Vista, and Mac styles do not use the standard palette, but make
+ standard palette is not used. In particular, the Windows
+ Vista and Mac styles do not use the standard palette, but make
use of native theme engines. With these styles, you should not set
the palette with QApplication::setPalette().
diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h
index ce33dbed62..cef569d514 100644
--- a/src/widgets/styles/qstyle.h
+++ b/src/widgets/styles/qstyle.h
@@ -202,7 +202,7 @@ public:
Q_ENUM(PrimitiveElement)
virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
- const QWidget *w = Q_NULLPTR) const = 0;
+ const QWidget *w = nullptr) const = 0;
enum ControlElement {
CE_PushButton,
CE_PushButtonBevel,
@@ -273,7 +273,7 @@ public:
Q_ENUM(ControlElement)
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
- const QWidget *w = Q_NULLPTR) const = 0;
+ const QWidget *w = nullptr) const = 0;
enum SubElement {
SE_PushButtonContents,
@@ -362,7 +362,7 @@ public:
Q_ENUM(SubElement)
virtual QRect subElementRect(SubElement subElement, const QStyleOption *option,
- const QWidget *widget = Q_NULLPTR) const = 0;
+ const QWidget *widget = nullptr) const = 0;
enum ComplexControl {
@@ -441,11 +441,11 @@ public:
virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
- const QWidget *widget = Q_NULLPTR) const = 0;
+ const QWidget *widget = nullptr) const = 0;
virtual SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
- const QPoint &pt, const QWidget *widget = Q_NULLPTR) const = 0;
+ const QPoint &pt, const QWidget *widget = nullptr) const = 0;
virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
- SubControl sc, const QWidget *widget = Q_NULLPTR) const = 0;
+ SubControl sc, const QWidget *widget = nullptr) const = 0;
enum PixelMetric {
PM_ButtonMargin,
@@ -579,8 +579,8 @@ public:
};
Q_ENUM(PixelMetric)
- virtual int pixelMetric(PixelMetric metric, const QStyleOption *option = Q_NULLPTR,
- const QWidget *widget = Q_NULLPTR) const = 0;
+ virtual int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr,
+ const QWidget *widget = nullptr) const = 0;
enum ContentsType {
CT_PushButton,
@@ -612,7 +612,7 @@ public:
Q_ENUM(ContentsType)
virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
- const QSize &contentsSize, const QWidget *w = Q_NULLPTR) const = 0;
+ const QSize &contentsSize, const QWidget *w = nullptr) const = 0;
enum RequestSoftwareInputPanel {
RSIP_OnMouseClickAndAlreadyFocused,
@@ -737,14 +737,18 @@ public:
SH_Menu_SubMenuResetWhenReenteringParent,
SH_Menu_SubMenuDontStartSloppyOnLeave,
SH_ItemView_ScrollMode,
+ SH_TitleBar_ShowToolTipsOnButtons,
+ SH_Widget_Animation_Duration,
+ SH_ComboBox_AllowWheelScrolling,
+ SH_SpinBox_ButtonsInsideFrame,
// Add new style hint values here
SH_CustomBase = 0xf0000000
};
Q_ENUM(StyleHint)
- virtual int styleHint(StyleHint stylehint, const QStyleOption *opt = Q_NULLPTR,
- const QWidget *widget = Q_NULLPTR, QStyleHintReturn* returnData = Q_NULLPTR) const = 0;
+ virtual int styleHint(StyleHint stylehint, const QStyleOption *opt = nullptr,
+ const QWidget *widget = nullptr, QStyleHintReturn* returnData = nullptr) const = 0;
enum StandardPixmap {
SP_TitleBarMenuButton,
@@ -823,11 +827,11 @@ public:
};
Q_ENUM(StandardPixmap)
- virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt = Q_NULLPTR,
- const QWidget *widget = Q_NULLPTR) const = 0;
+ virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt = nullptr,
+ const QWidget *widget = nullptr) const = 0;
- virtual QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = Q_NULLPTR,
- const QWidget *widget = Q_NULLPTR) const = 0;
+ virtual QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = nullptr,
+ const QWidget *widget = nullptr) const = 0;
virtual QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
const QStyleOption *opt) const = 0;
@@ -846,10 +850,10 @@ public:
virtual int layoutSpacing(QSizePolicy::ControlType control1,
QSizePolicy::ControlType control2, Qt::Orientation orientation,
- const QStyleOption *option = Q_NULLPTR, const QWidget *widget = Q_NULLPTR) const = 0;
+ const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const = 0;
int combinedLayoutSpacing(QSizePolicy::ControlTypes controls1,
QSizePolicy::ControlTypes controls2, Qt::Orientation orientation,
- QStyleOption *option = Q_NULLPTR, QWidget *widget = Q_NULLPTR) const;
+ QStyleOption *option = nullptr, QWidget *widget = nullptr) const;
const QStyle * proxy() const;
diff --git a/src/widgets/styles/qstyle.qrc b/src/widgets/styles/qstyle.qrc
index d8c73dd6fa..2dc3207e6d 100644
--- a/src/widgets/styles/qstyle.qrc
+++ b/src/widgets/styles/qstyle.qrc
@@ -128,13 +128,24 @@
<file>images/media-volume-16.png</file>
<file>images/media-volume-muted-16.png</file>
<file>images/fusion_groupbox.png</file>
- <file>images/fusion_arrow.png</file>
+ <file>images/closedock-10.png</file>
+ <file>images/closedock-16.png</file>
+ <file>images/closedock-20.png</file>
+ <file>images/closedock-32.png</file>
+ <file>images/closedock-48.png</file>
+ <file>images/closedock-64.png</file>
+ <file>images/normalizedockup-10.png</file>
+ <file>images/normalizedockup-16.png</file>
+ <file>images/normalizedockup-20.png</file>
+ <file>images/normalizedockup-32.png</file>
+ <file>images/normalizedockup-48.png</file>
+ <file>images/normalizedockup-64.png</file>
</qresource>
<qresource prefix="/qt-project.org/styles/macstyle">
- <file>images/closedock-16.png</file>
- <file>images/closedock-down-16.png</file>
- <file>images/dockdock-16.png</file>
- <file>images/dockdock-down-16.png</file>
+ <file alias="images/closedock-16.png">images/closedock-macstyle-16.png</file>
+ <file alias="images/closedock-down-16.png">images/closedock-down-macstyle-16.png</file>
+ <file alias="images/dockdock-16.png">images/dockdock-macstyle-16.png</file>
+ <file alias="images/dockdock-down-16.png">images/dockdock-down-macstyle-16.png</file>
<file>images/toolbar-ext.png</file>
<file>images/toolbar-ext@2x.png</file>
</qresource>
diff --git a/src/widgets/styles/qstyleanimation_p.h b/src/widgets/styles/qstyleanimation_p.h
index 3b10eeea27..a2ad4a91da 100644
--- a/src/widgets/styles/qstyleanimation_p.h
+++ b/src/widgets/styles/qstyleanimation_p.h
@@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE
// We mean it.
//
-class QStyleAnimation : public QAbstractAnimation
+class Q_WIDGETS_EXPORT QStyleAnimation : public QAbstractAnimation
{
Q_OBJECT
@@ -70,7 +70,7 @@ public:
QObject *target() const;
- int duration() const Q_DECL_OVERRIDE;
+ int duration() const override;
void setDuration(int duration);
int delay() const;
@@ -83,7 +83,8 @@ public:
DefaultFps,
SixtyFps,
ThirtyFps,
- TwentyFps
+ TwentyFps,
+ FifteenFps
};
FrameRate frameRate() const;
@@ -96,7 +97,7 @@ public Q_SLOTS:
protected:
virtual bool isUpdateNeeded() const;
- virtual void updateCurrentTime(int time) Q_DECL_OVERRIDE;
+ virtual void updateCurrentTime(int time) override;
private:
int _delay;
@@ -106,7 +107,7 @@ private:
int _skip;
};
-class QProgressStyleAnimation : public QStyleAnimation
+class Q_WIDGETS_EXPORT QProgressStyleAnimation : public QStyleAnimation
{
Q_OBJECT
@@ -120,14 +121,14 @@ public:
void setSpeed(int speed);
protected:
- bool isUpdateNeeded() const Q_DECL_OVERRIDE;
+ bool isUpdateNeeded() const override;
private:
int _speed;
mutable int _step;
};
-class QNumberStyleAnimation : public QStyleAnimation
+class Q_WIDGETS_EXPORT QNumberStyleAnimation : public QStyleAnimation
{
Q_OBJECT
@@ -143,7 +144,7 @@ public:
qreal currentValue() const;
protected:
- bool isUpdateNeeded() const Q_DECL_OVERRIDE;
+ bool isUpdateNeeded() const override;
private:
qreal _start;
@@ -151,7 +152,7 @@ private:
mutable qreal _prev;
};
-class QBlendStyleAnimation : public QStyleAnimation
+class Q_WIDGETS_EXPORT QBlendStyleAnimation : public QStyleAnimation
{
Q_OBJECT
@@ -169,7 +170,7 @@ public:
QImage currentImage() const;
protected:
- virtual void updateCurrentTime(int time) Q_DECL_OVERRIDE;
+ virtual void updateCurrentTime(int time) override;
private:
Type _type;
@@ -178,7 +179,7 @@ private:
QImage _current;
};
-class QScrollbarStyleAnimation : public QNumberStyleAnimation
+class Q_WIDGETS_EXPORT QScrollbarStyleAnimation : public QNumberStyleAnimation
{
Q_OBJECT
@@ -193,7 +194,7 @@ public:
void setActive(bool active);
private slots:
- void updateCurrentTime(int time) Q_DECL_OVERRIDE;
+ void updateCurrentTime(int time) override;
private:
Mode _mode;
diff --git a/src/widgets/styles/qstylefactory.cpp b/src/widgets/styles/qstylefactory.cpp
index 8dc603f8e6..c959994d2c 100644
--- a/src/widgets/styles/qstylefactory.cpp
+++ b/src/widgets/styles/qstylefactory.cpp
@@ -46,19 +46,6 @@
#include "qwindowsstyle_p.h"
#if QT_CONFIG(style_fusion)
#include "qfusionstyle_p.h"
-#if QT_CONFIG(style_android)
-#include "qandroidstyle_p.h"
-#endif
-#endif
-#if QT_CONFIG(style_windowsxp)
-#include "qwindowsxpstyle_p.h"
-#endif
-#if QT_CONFIG(style_windowsvista)
-#include "qwindowsvistastyle_p.h"
-#endif
-
-#if QT_CONFIG(style_mac)
-# include "qmacstyle_mac_p.h"
#endif
QT_BEGIN_NAMESPACE
@@ -81,7 +68,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
The valid keys can be retrieved using the keys()
function. Typically they include "windows" and "fusion".
- Depending on the platform, "windowsxp", "windowsvista"
+ Depending on the platform, "windowsvista"
and "macintosh" may be available.
Note that keys are case insensitive.
@@ -108,35 +95,11 @@ QStyle *QStyleFactory::create(const QString& key)
ret = new QWindowsStyle;
else
#endif
-#if QT_CONFIG(style_windowsxp)
- if (style == QLatin1String("windowsxp"))
- ret = new QWindowsXPStyle;
- else
-#endif
-#if QT_CONFIG(style_windowsvista)
- if (style == QLatin1String("windowsvista"))
- ret = new QWindowsVistaStyle;
- else
-#endif
#if QT_CONFIG(style_fusion)
if (style == QLatin1String("fusion"))
ret = new QFusionStyle;
else
#endif
-#if QT_CONFIG(style_android)
- if (style == QLatin1String("android"))
- ret = new QAndroidStyle;
- else
-#endif
-#if QT_CONFIG(style_mac)
- if (style.startsWith(QLatin1String("macintosh"))) {
- ret = new QMacStyle;
-# if 0 // Used to be included in Qt4 for Q_WS_MAC
- if (style == QLatin1String("macintosh"))
- style += QLatin1String(" (aqua)");
-# endif
- } else
-#endif
{ } // Keep these here - they make the #ifdefery above work
if (!ret)
ret = qLoadPlugin<QStyle, QStylePlugin>(loader(), style);
@@ -164,32 +127,10 @@ QStringList QStyleFactory::keys()
if (!list.contains(QLatin1String("Windows")))
list << QLatin1String("Windows");
#endif
-#if QT_CONFIG(style_windowsxp)
- if (!list.contains(QLatin1String("WindowsXP")) &&
- (QSysInfo::WindowsVersion >= QSysInfo::WV_XP && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)))
- list << QLatin1String("WindowsXP");
-#endif
-#if QT_CONFIG(style_windowsvista)
- if (!list.contains(QLatin1String("WindowsVista")) &&
- (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)))
- list << QLatin1String("WindowsVista");
-#endif
-#if QT_CONFIG(style_android)
- if (!list.contains(QLatin1String("Android")))
- list << QLatin1String("Android");
-#endif
#if QT_CONFIG(style_fusion)
if (!list.contains(QLatin1String("Fusion")))
list << QLatin1String("Fusion");
#endif
-#if QT_CONFIG(style_mac)
- QString mstyle = QLatin1String("Macintosh");
-# if 0 // Used to be included in Qt4 for Q_WS_MAC
- mstyle += QLatin1String(" (aqua)");
-# endif
- if (!list.contains(mstyle))
- list << mstyle;
-#endif
return list;
}
diff --git a/src/widgets/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp
index 141b731b65..373699a7aa 100644
--- a/src/widgets/styles/qstylehelper.cpp
+++ b/src/widgets/styles/qstylehelper.cpp
@@ -51,8 +51,6 @@
#include "qstylehelper_p.h"
#include <qstringbuilder.h>
-#include <qdatastream.h>
-#include <qcryptographichash.h>
QT_BEGIN_NAMESPACE
@@ -66,6 +64,7 @@ QString uniqueName(const QString &key, const QStyleOption *option, const QSize &
QString tmp = key % HexString<uint>(option->state)
% HexString<uint>(option->direction)
% HexString<uint>(complexOption ? uint(complexOption->activeSubControls) : 0u)
+ % HexString<quint64>(option->palette.cacheKey())
% HexString<uint>(size.width())
% HexString<uint>(size.height());
@@ -77,24 +76,6 @@ QString uniqueName(const QString &key, const QStyleOption *option, const QSize &
}
#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
- // palettes when using QPalette::cacheKey()
- if (option->palette != QGuiApplication::palette()) {
- tmp.append(QLatin1Char('P'));
-#ifndef QT_NO_DATASTREAM
- QByteArray key;
- key.reserve(5120); // Observed 5040B for a serialized palette on 64bit
- {
- QDataStream str(&key, QIODevice::WriteOnly);
- str << option->palette;
- }
- const QByteArray sha1 = QCryptographicHash::hash(key, QCryptographicHash::Sha1).toHex();
- tmp.append(QString::fromLatin1(sha1));
-#else // QT_NO_DATASTREAM
- tmp.append(QString::number(option->palette.cacheKey(), 16));
-#endif // !QT_NO_DATASTREAM
- }
return tmp;
}
@@ -430,5 +411,34 @@ QWindow *styleObjectWindow(QObject *so)
return 0;
}
+void setWidgetSizePolicy(const QWidget *widget, WidgetSizePolicy policy)
+{
+ QWidget *wadget = const_cast<QWidget *>(widget);
+ wadget->setAttribute(Qt::WA_MacNormalSize, policy == SizeLarge);
+ wadget->setAttribute(Qt::WA_MacSmallSize, policy == SizeSmall);
+ wadget->setAttribute(Qt::WA_MacMiniSize, policy == SizeMini);
+}
+
+WidgetSizePolicy widgetSizePolicy(const QWidget *widget, const QStyleOption *opt)
+{
+ while (widget) {
+ if (widget->testAttribute(Qt::WA_MacMiniSize)) {
+ return SizeMini;
+ } else if (widget->testAttribute(Qt::WA_MacSmallSize)) {
+ return SizeSmall;
+ } else if (widget->testAttribute(Qt::WA_MacNormalSize)) {
+ return SizeLarge;
+ }
+ widget = widget->parentWidget();
+ }
+
+ if (opt && opt->state & QStyle::State_Mini)
+ return SizeMini;
+ else if (opt && opt->state & QStyle::State_Small)
+ return SizeSmall;
+
+ return SizeDefault;
+}
+
}
QT_END_NAMESPACE
diff --git a/src/widgets/styles/qstylehelper_p.h b/src/widgets/styles/qstylehelper_p.h
index 17b6d9ab4f..bd263cea7b 100644
--- a/src/widgets/styles/qstylehelper_p.h
+++ b/src/widgets/styles/qstylehelper_p.h
@@ -62,31 +62,40 @@
QT_BEGIN_NAMESPACE
+class QColor;
+class QObject;
class QPainter;
+class QPalette;
class QPixmap;
class QStyleOptionSlider;
class QStyleOption;
+class QWidget;
class QWindow;
namespace QStyleHelper
{
QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size);
- qreal dpiScaled(qreal value);
+ Q_WIDGETS_EXPORT qreal dpiScaled(qreal value);
#if QT_CONFIG(dial)
qreal angle(const QPointF &p1, const QPointF &p2);
QPolygonF calcLines(const QStyleOptionSlider *dial);
int calcBigLineSize(int radius);
- void drawDial(const QStyleOptionSlider *dial, QPainter *painter);
+ Q_WIDGETS_EXPORT void drawDial(const QStyleOptionSlider *dial, QPainter *painter);
#endif //QT_CONFIG(dial)
- void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rect,
+ Q_WIDGETS_EXPORT void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rect,
int left = 0, int top = 0, int right = 0,
int bottom = 0);
#ifndef QT_NO_ACCESSIBILITY
- bool isInstanceOf(QObject *obj, QAccessible::Role role);
- bool hasAncestor(QObject *obj, QAccessible::Role role);
+ Q_WIDGETS_EXPORT bool isInstanceOf(QObject *obj, QAccessible::Role role);
+ Q_WIDGETS_EXPORT bool hasAncestor(QObject *obj, QAccessible::Role role);
#endif
- QColor backgroundColor(const QPalette &pal, const QWidget* widget = 0);
- QWindow *styleObjectWindow(QObject *so);
+ Q_WIDGETS_EXPORT QColor backgroundColor(const QPalette &pal, const QWidget* widget = 0);
+ Q_WIDGETS_EXPORT QWindow *styleObjectWindow(QObject *so);
+
+ enum WidgetSizePolicy { SizeLarge = 0, SizeSmall = 1, SizeMini = 2, SizeDefault = -1 };
+
+ void setWidgetSizePolicy(const QWidget *w, WidgetSizePolicy policy);
+ Q_WIDGETS_EXPORT WidgetSizePolicy widgetSizePolicy(const QWidget *w, const QStyleOption *opt = 0);
}
diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp
index 3e73abc62c..3666bce205 100644
--- a/src/widgets/styles/qstyleoption.cpp
+++ b/src/widgets/styles/qstyleoption.cpp
@@ -38,11 +38,9 @@
****************************************************************************/
#include <QtWidgets/private/qtwidgetsglobal_p.h>
+#include "private/qstylehelper_p.h"
#include "qstyleoption.h"
#include "qapplication.h"
-#if QT_CONFIG(style_mac)
-# include "qmacstyle_mac_p.h"
-#endif
#include <qdebug.h>
#include <QtCore/qmath.h>
@@ -205,18 +203,16 @@ void QStyleOption::init(const QWidget *widget)
if (!(state & QStyle::State_Active) && !qt_mac_can_clickThrough(widget))
state &= ~QStyle::State_Enabled;
#endif
-#if QT_CONFIG(style_mac)
- switch (QMacStyle::widgetSizePolicy(widget)) {
- case QMacStyle::SizeSmall:
+ switch (QStyleHelper::widgetSizePolicy(widget)) {
+ case QStyleHelper::SizeSmall:
state |= QStyle::State_Small;
break;
- case QMacStyle::SizeMini:
+ case QStyleHelper::SizeMini:
state |= QStyle::State_Mini;
break;
default:
;
}
-#endif
#ifdef QT_KEYPAD_NAVIGATION
if (widget->hasEditFocus())
state |= QStyle::State_HasEditFocus;
@@ -3269,7 +3265,7 @@ QStyleOptionViewItem::QStyleOptionViewItem(int version)
#endif // QT_CONFIG(itemviews)
/*!
- \fn T qstyleoption_cast<T>(const QStyleOption *option)
+ \fn template <typename T> T qstyleoption_cast<T>(const QStyleOption *option)
\relates QStyleOption
Returns a T or 0 depending on the \l{QStyleOption::type}{type} and
@@ -3283,7 +3279,7 @@ QStyleOptionViewItem::QStyleOptionViewItem(int version)
*/
/*!
- \fn T qstyleoption_cast<T>(QStyleOption *option)
+ \fn template <typename T> T qstyleoption_cast<T>(QStyleOption *option)
\overload
\relates QStyleOption
@@ -4005,7 +4001,7 @@ QStyleHintReturnVariant::~QStyleHintReturnVariant()
*/
/*!
- \fn T qstyleoption_cast<T>(const QStyleHintReturn *hint)
+ \fn template <typename T> T qstyleoption_cast<T>(const QStyleHintReturn *hint)
\relates QStyleHintReturn
Returns a T or 0 depending on the \l{QStyleHintReturn::type}{type}
@@ -4019,7 +4015,7 @@ QStyleHintReturnVariant::~QStyleHintReturnVariant()
*/
/*!
- \fn T qstyleoption_cast<T>(QStyleHintReturn *hint)
+ \fn template <typename T> T qstyleoption_cast<T>(QStyleHintReturn *hint)
\overload
\relates QStyleHintReturn
diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h
index f703c56917..2880917510 100644
--- a/src/widgets/styles/qstyleoption.h
+++ b/src/widgets/styles/qstyleoption.h
@@ -682,7 +682,7 @@ T qstyleoption_cast(const QStyleOption *opt)
|| (int(Opt::Type) == QStyleOption::SO_Complex
&& opt->type > QStyleOption::SO_Complex)))
return static_cast<T>(opt);
- return Q_NULLPTR;
+ return nullptr;
}
template <typename T>
@@ -694,7 +694,7 @@ T qstyleoption_cast(QStyleOption *opt)
|| (int(Opt::Type) == QStyleOption::SO_Complex
&& opt->type > QStyleOption::SO_Complex)))
return static_cast<T>(opt);
- return Q_NULLPTR;
+ return nullptr;
}
// -------------------------- QStyleHintReturn -------------------------------
@@ -743,7 +743,7 @@ T qstyleoption_cast(const QStyleHintReturn *hint)
if (hint && hint->version <= Opt::Version &&
(hint->type == Opt::Type || int(Opt::Type) == QStyleHintReturn::SH_Default))
return static_cast<T>(hint);
- return Q_NULLPTR;
+ return nullptr;
}
template <typename T>
@@ -753,7 +753,7 @@ T qstyleoption_cast(QStyleHintReturn *hint)
if (hint && hint->version <= Opt::Version &&
(hint->type == Opt::Type || int(Opt::Type) == QStyleHintReturn::SH_Default))
return static_cast<T>(hint);
- return Q_NULLPTR;
+ return nullptr;
}
#if !defined(QT_NO_DEBUG_STREAM)
diff --git a/src/widgets/styles/qstylepainter.h b/src/widgets/styles/qstylepainter.h
index 191360727e..b5e7956cb1 100644
--- a/src/widgets/styles/qstylepainter.h
+++ b/src/widgets/styles/qstylepainter.h
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE
class QStylePainter : public QPainter
{
public:
- inline QStylePainter() : QPainter(), widget(Q_NULLPTR), wstyle(Q_NULLPTR) {}
+ inline QStylePainter() : QPainter(), widget(nullptr), wstyle(nullptr) {}
inline explicit QStylePainter(QWidget *w) { begin(w, w); }
inline QStylePainter(QPaintDevice *pd, QWidget *w) { begin(pd, w); }
inline bool begin(QWidget *w) { return begin(w, w); }
diff --git a/src/widgets/styles/qstyleplugin.h b/src/widgets/styles/qstyleplugin.h
index d44f57d208..e9a26f9127 100644
--- a/src/widgets/styles/qstyleplugin.h
+++ b/src/widgets/styles/qstyleplugin.h
@@ -55,7 +55,7 @@ class Q_WIDGETS_EXPORT QStylePlugin : public QObject
{
Q_OBJECT
public:
- explicit QStylePlugin(QObject *parent = Q_NULLPTR);
+ explicit QStylePlugin(QObject *parent = nullptr);
~QStylePlugin();
virtual QStyle *create(const QString &key) = 0;
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index f70313d49e..e12aeb900b 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -710,10 +710,12 @@ static const char knownStyleHints[][45] = {
"titlebar-minimize-icon",
"titlebar-normal-icon",
"titlebar-shade-icon",
+ "titlebar-show-tooltips-on-buttons",
"titlebar-unshade-icon",
"toolbutton-popup-delay",
"trash-icon",
- "uparrow-icon"
+ "uparrow-icon",
+ "widget-animation-duration"
};
static const int numKnownStyleHints = sizeof(knownStyleHints)/sizeof(knownStyleHints[0]);
@@ -831,7 +833,7 @@ QHash<QStyle::SubControl, QRect> QStyleSheetStyle::titleBarLayout(const QWidget
continue;
}
if (info.element == PseudoElement_TitleBar) {
- info.width = tb->fontMetrics.width(tb->text) + 6;
+ info.width = tb->fontMetrics.horizontalAdvance(tb->text) + 6;
subRule.geo = new QStyleSheetGeometryData(info.width, tb->fontMetrics.height(), -1, -1, -1, -1);
} else {
subRule = renderRule(w, tb, info.element);
@@ -1461,7 +1463,7 @@ class QStyleSheetStyleSelector : public StyleSelector
public:
QStyleSheetStyleSelector() { }
- QStringList nodeNames(NodePtr node) const Q_DECL_OVERRIDE
+ QStringList nodeNames(NodePtr node) const override
{
if (isNullNode(node))
return QStringList();
@@ -1477,7 +1479,7 @@ public:
} while (metaObject != 0);
return result;
}
- QString attribute(NodePtr node, const QString& name) const Q_DECL_OVERRIDE
+ QString attribute(NodePtr node, const QString& name) const override
{
if (isNullNode(node))
return QString();
@@ -1514,7 +1516,7 @@ public:
cache[name] = valueStr;
return valueStr;
}
- bool nodeNameEquals(NodePtr node, const QString& nodeName) const Q_DECL_OVERRIDE
+ bool nodeNameEquals(NodePtr node, const QString& nodeName) const override
{
if (isNullNode(node))
return false;
@@ -1537,19 +1539,19 @@ public:
} while (metaObject != 0);
return false;
}
- bool hasAttributes(NodePtr) const Q_DECL_OVERRIDE
+ bool hasAttributes(NodePtr) const override
{ return true; }
- QStringList nodeIds(NodePtr node) const Q_DECL_OVERRIDE
+ QStringList nodeIds(NodePtr node) const override
{ return isNullNode(node) ? QStringList() : QStringList(OBJECT_PTR(node)->objectName()); }
- bool isNullNode(NodePtr node) const Q_DECL_OVERRIDE
+ bool isNullNode(NodePtr node) const override
{ return node.ptr == 0; }
- NodePtr parentNode(NodePtr node) const Q_DECL_OVERRIDE
+ NodePtr parentNode(NodePtr node) const override
{ NodePtr n; n.ptr = isNullNode(node) ? 0 : parentObject(OBJECT_PTR(node)); return n; }
- NodePtr previousSiblingNode(NodePtr) const Q_DECL_OVERRIDE
+ NodePtr previousSiblingNode(NodePtr) const override
{ NodePtr n; n.ptr = 0; return n; }
- NodePtr duplicateNode(NodePtr node) const Q_DECL_OVERRIDE
+ NodePtr duplicateNode(NodePtr node) const override
{ return node; }
- void freeNode(NodePtr) const Q_DECL_OVERRIDE
+ void freeNode(NodePtr) const override
{ }
private:
@@ -2690,24 +2692,19 @@ void QStyleSheetStyle::unsetStyleSheetFont(QWidget *w) const
static void updateObjects(const QList<const QObject *>& objects)
{
if (!styleSheetCaches->styleRulesCache.isEmpty() || !styleSheetCaches->hasStyleRuleCache.isEmpty() || !styleSheetCaches->renderRulesCache.isEmpty()) {
- for (int i = 0; i < objects.size(); ++i) {
- const QObject *object = objects.at(i);
+ for (const QObject *object : objects) {
styleSheetCaches->styleRulesCache.remove(object);
styleSheetCaches->hasStyleRuleCache.remove(object);
styleSheetCaches->renderRulesCache.remove(object);
}
}
- QWidgetList widgets;
- foreach (const QObject *object, objects) {
- if (QWidget *w = qobject_cast<QWidget*>(const_cast<QObject*>(object)))
- widgets << w;
- }
-
QEvent event(QEvent::StyleChange);
- foreach (QWidget *widget, widgets) {
- widget->style()->polish(widget);
- QApplication::sendEvent(widget, &event);
+ for (const QObject *object : objects) {
+ if (auto widget = qobject_cast<QWidget*>(const_cast<QObject*>(object))) {
+ widget->style()->polish(widget);
+ QApplication::sendEvent(widget, &event);
+ }
}
}
@@ -4262,7 +4259,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
switch (pe) {
case PE_FrameStatusBar: {
- QRenderRule subRule = renderRule(w ? w->parentWidget() : Q_NULLPTR, opt, PseudoElement_Item);
+ QRenderRule subRule = renderRule(w ? w->parentWidget() : nullptr, opt, PseudoElement_Item);
if (subRule.hasDrawable()) {
subRule.drawRule(p, opt->rect);
return;
@@ -4620,7 +4617,7 @@ QStyle::SubControl QStyleSheetStyle::hitTestComplexControl(ComplexControl cc, co
if (!rule.hasDrawable() && !rule.hasBox())
break;
}
- // intentionally falls through
+ Q_FALLTHROUGH();
case CC_SpinBox:
case CC_GroupBox:
case CC_ComboBox:
@@ -5348,6 +5345,8 @@ int QStyleSheetStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWi
}
case SH_ItemView_ArrowKeysNavigateIntoChildren: s = QLatin1String("arrow-keys-navigate-into-children"); break;
case SH_ItemView_PaintAlternatingRowColorsForEmptyArea: s = QLatin1String("paint-alternating-row-colors-for-empty-area"); break;
+ case SH_TitleBar_ShowToolTipsOnButtons: s = QLatin1String("titlebar-show-tooltips-on-buttons"); break;
+ case SH_Widget_Animation_Duration: s = QLatin1String("widget-animation-duration"); break;
default: break;
}
if (!s.isEmpty() && rule.hasStyleHint(s)) {
@@ -5483,7 +5482,7 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp
groupBox.rect = rule.borderRect(opt->rect);
return baseStyle()->subControlRect(cc, &groupBox, sc, w);
}
- int tw = opt->fontMetrics.width(gb->text);
+ int tw = opt->fontMetrics.horizontalAdvance(gb->text);
int th = opt->fontMetrics.height();
int spacing = pixelMetric(QStyle::PM_CheckBoxLabelSpacing, opt, w);
int iw = pixelMetric(QStyle::PM_IndicatorWidth, opt, w);
@@ -5784,7 +5783,7 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
if (!qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
return subElementRect(SE_CheckBoxIndicator, opt, w);
}
- // intentionally falls through
+ Q_FALLTHROUGH();
case SE_ItemViewItemText:
case SE_ItemViewItemDecoration:
case SE_ItemViewItemFocusRect:
@@ -5844,15 +5843,15 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
#if QT_CONFIG(tabbar)
case SE_TabWidgetLeftCorner:
pe = PseudoElement_TabWidgetLeftCorner;
- // intentionally falls through
+ Q_FALLTHROUGH();
case SE_TabWidgetRightCorner:
if (pe == PseudoElement_None)
pe = PseudoElement_TabWidgetRightCorner;
- // intentionally falls through
+ Q_FALLTHROUGH();
case SE_TabWidgetTabBar:
if (pe == PseudoElement_None)
pe = PseudoElement_TabWidgetTabBar;
- // intentionally falls through
+ Q_FALLTHROUGH();
case SE_TabWidgetTabPane:
case SE_TabWidgetTabContents:
if (pe == PseudoElement_None)
diff --git a/src/widgets/styles/qstylesheetstyle_default.cpp b/src/widgets/styles/qstylesheetstyle_default.cpp
index 168251b0f3..1cb1adb2db 100644
--- a/src/widgets/styles/qstylesheetstyle_default.cpp
+++ b/src/widgets/styles/qstylesheetstyle_default.cpp
@@ -78,7 +78,7 @@ using namespace QCss;
bSelector.pseudos << pseudo
// This is attributes. The third parameter is AttributeSelector::*
-// Ex. QComboBox[style="QWindowsXPStyle"]
+// Ex. QComboBox[style="QWindowsVistaStyle"]
// ^ ^
#define ADD_ATTRIBUTE_SELECTOR(x, y, z) \
@@ -155,7 +155,7 @@ StyleSheet QStyleSheetStyle::getDefaultStyleSheet() const
// pixmap based style doesn't support any features
bool styleIsPixmapBased = baseStyle()->inherits("QMacStyle")
- || baseStyle()->inherits("QWindowsXPStyle");
+ || baseStyle()->inherits("QWindowsVistaStyle");
/*QLineEdit {
diff --git a/src/widgets/styles/qstylesheetstyle_p.h b/src/widgets/styles/qstylesheetstyle_p.h
index 2d302305bd..042abf5c22 100644
--- a/src/widgets/styles/qstylesheetstyle_p.h
+++ b/src/widgets/styles/qstylesheetstyle_p.h
@@ -82,48 +82,48 @@ public:
~QStyleSheetStyle();
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
- const QWidget *w = 0) const Q_DECL_OVERRIDE;
+ const QWidget *w = 0) const override;
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const Q_DECL_OVERRIDE;
- void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const Q_DECL_OVERRIDE;
+ const QWidget *w = 0) const override;
+ void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const override;
void drawItemText(QPainter *painter, const QRect& rect, int alignment, const QPalette &pal,
- bool enabled, const QString& text, QPalette::ColorRole textRole = QPalette::NoRole) const Q_DECL_OVERRIDE;
+ bool enabled, const QString& text, QPalette::ColorRole textRole = QPalette::NoRole) const override;
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const Q_DECL_OVERRIDE;
+ const QWidget *w = 0) const override;
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
- const QStyleOption *option) const Q_DECL_OVERRIDE;
+ const QStyleOption *option) const override;
SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
- const QPoint &pt, const QWidget *w = 0) const Q_DECL_OVERRIDE;
- QRect itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pixmap) const Q_DECL_OVERRIDE;
+ const QPoint &pt, const QWidget *w = 0) const override;
+ QRect itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pixmap) const override;
QRect itemTextRect(const QFontMetrics &metrics, const QRect &rect, int alignment, bool enabled,
- const QString &text) const Q_DECL_OVERRIDE;
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const Q_DECL_OVERRIDE;
- void polish(QWidget *widget) Q_DECL_OVERRIDE;
- void polish(QApplication *app) Q_DECL_OVERRIDE;
- void polish(QPalette &pal) Q_DECL_OVERRIDE;
+ const QString &text) const override;
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const override;
+ void polish(QWidget *widget) override;
+ void polish(QApplication *app) override;
+ void polish(QPalette &pal) override;
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
- const QSize &contentsSize, const QWidget *widget = 0) const Q_DECL_OVERRIDE;
- QPalette standardPalette() const Q_DECL_OVERRIDE;
+ const QSize &contentsSize, const QWidget *widget = 0) const override;
+ QPalette standardPalette() const override;
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *opt = 0,
- const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ const QWidget *widget = 0) const override;
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option = 0,
- const QWidget *w = 0 ) const Q_DECL_OVERRIDE;
+ const QWidget *w = 0 ) const override;
int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
Qt::Orientation orientation, const QStyleOption *option = 0,
- const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ const QWidget *widget = 0) const override;
int styleHint(StyleHint sh, const QStyleOption *opt = 0, const QWidget *w = 0,
- QStyleHintReturn *shret = 0) const Q_DECL_OVERRIDE;
- QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ QStyleHintReturn *shret = 0) const override;
+ QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const override;
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc,
- const QWidget *w = 0) const Q_DECL_OVERRIDE;
+ const QWidget *w = 0) const override;
// These functions are called from QApplication/QWidget. Be careful.
QStyle *baseStyle() const;
void repolish(QWidget *widget);
void repolish(QApplication *app);
- void unpolish(QWidget *widget) Q_DECL_OVERRIDE;
- void unpolish(QApplication *app) Q_DECL_OVERRIDE;
+ void unpolish(QWidget *widget) override;
+ void unpolish(QApplication *app) override;
QStyle *base;
void ref() { ++refcount; }
@@ -136,7 +136,7 @@ public:
bool styleSheetPalette(const QWidget* w, const QStyleOption* opt, QPalette* pal);
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
private:
int refcount;
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp
index 657166fc8d..89011350ec 100644
--- a/src/widgets/styles/qwindowsstyle.cpp
+++ b/src/widgets/styles/qwindowsstyle.cpp
@@ -380,7 +380,7 @@ int QWindowsStylePrivate::fixedPixelMetric(QStyle::PixelMetric pm)
static QWindow *windowOf(const QWidget *w)
{
- QWindow *result = Q_NULLPTR;
+ QWindow *result = nullptr;
if (w) {
result = w->windowHandle();
if (!result) {
@@ -798,9 +798,10 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
break;
case PE_FrameDefaultButton: {
QPen oldPen = p->pen();
- p->setPen(opt->palette.shadow().color());
- QRect rect = opt->rect;
- rect.adjust(0, 0, -1, -1);
+ p->setPen(QPen(opt->palette.shadow().color(), 0));
+ QRectF rect = opt->rect;
+ rect.adjust(QStyleHelper::dpiScaled(0.5), QStyleHelper::dpiScaled(0.5),
+ QStyleHelper::dpiScaled(-1.5), QStyleHelper::dpiScaled(-1.5));
p->drawRect(rect);
p->setPen(oldPen);
break;
@@ -843,22 +844,16 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
}
#endif // QT_CONFIG(itemviews)
if (!(opt->state & State_Off)) {
- QLineF lines[7];
- int i, xx, yy;
- xx = opt->rect.x() + 3;
- yy = opt->rect.y() + 5;
- for (i = 0; i < 3; ++i) {
- lines[i] = QLineF(xx, yy, xx, yy + 2);
- ++xx;
- ++yy;
- }
- yy -= 2;
- for (i = 3; i < 7; ++i) {
- lines[i] = QLineF(xx, yy, xx, yy + 2);
- ++xx;
- --yy;
- }
- p->drawLines(lines, 7);
+ QPointF points[6];
+ points[0] = { opt->rect.x() + QStyleHelper::dpiScaled(3.5), opt->rect.y() + QStyleHelper::dpiScaled(5.5) };
+ points[1] = { points[0].x(), points[0].y() + QStyleHelper::dpiScaled(2) };
+ points[2] = { points[1].x() + QStyleHelper::dpiScaled(2), points[1].y() + QStyleHelper::dpiScaled(2) };
+ points[3] = { points[2].x() + QStyleHelper::dpiScaled(4), points[2].y() - QStyleHelper::dpiScaled(4) };
+ points[4] = { points[3].x(), points[3].y() - QStyleHelper::dpiScaled(2) };
+ points[5] = { points[4].x() - QStyleHelper::dpiScaled(4), points[4].y() + QStyleHelper::dpiScaled(4) };
+ p->setPen(QPen(opt->palette.text().color(), 0));
+ p->setBrush(opt->palette.text().color());
+ p->drawPolygon(points, 6);
}
if (doRestore)
p->restore();
@@ -890,86 +885,57 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
break;
case PE_IndicatorRadioButton:
{
-#define PTSARRLEN(x) sizeof(x)/(sizeof(QPoint))
- static const QPoint pts1[] = { // dark lines
- QPoint(1, 9), QPoint(1, 8), QPoint(0, 7), QPoint(0, 4), QPoint(1, 3), QPoint(1, 2),
- QPoint(2, 1), QPoint(3, 1), QPoint(4, 0), QPoint(7, 0), QPoint(8, 1), QPoint(9, 1)
- };
- static const QPoint pts2[] = { // black lines
- QPoint(2, 8), QPoint(1, 7), QPoint(1, 4), QPoint(2, 3), QPoint(2, 2), QPoint(3, 2),
- QPoint(4, 1), QPoint(7, 1), QPoint(8, 2), QPoint(9, 2)
- };
- static const QPoint pts3[] = { // background lines
- QPoint(2, 9), QPoint(3, 9), QPoint(4, 10), QPoint(7, 10), QPoint(8, 9), QPoint(9, 9),
- QPoint(9, 8), QPoint(10, 7), QPoint(10, 4), QPoint(9, 3)
- };
- static const QPoint pts4[] = { // white lines
- QPoint(2, 10), QPoint(3, 10), QPoint(4, 11), QPoint(7, 11), QPoint(8, 10),
- QPoint(9, 10), QPoint(10, 9), QPoint(10, 8), QPoint(11, 7), QPoint(11, 4),
- QPoint(10, 3), QPoint(10, 2)
- };
- static const QPoint pts5[] = { // inner fill
- QPoint(4, 2), QPoint(7, 2), QPoint(9, 4), QPoint(9, 7), QPoint(7, 9), QPoint(4, 9),
- QPoint(2, 7), QPoint(2, 4)
- };
-
- // make sure the indicator is square
- QRect ir = opt->rect;
-
- if (opt->rect.width() < opt->rect.height()) {
- ir.setTop(opt->rect.top() + (opt->rect.height() - opt->rect.width()) / 2);
- ir.setHeight(opt->rect.width());
- } else if (opt->rect.height() < opt->rect.width()) {
- ir.setLeft(opt->rect.left() + (opt->rect.width() - opt->rect.height()) / 2);
- ir.setWidth(opt->rect.height());
- }
-
+ QRect r = opt->rect;
p->save();
- p->setRenderHint(QPainter::Qt4CompatiblePainting);
- bool down = opt->state & State_Sunken;
- bool enabled = opt->state & State_Enabled;
- bool on = opt->state & State_On;
- QPolygon a;
-
- //center when rect is larger than indicator size
- int xOffset = 0;
- int yOffset = 0;
- int indicatorWidth = proxy()->pixelMetric(PM_ExclusiveIndicatorWidth);
- int indicatorHeight = proxy()->pixelMetric(PM_ExclusiveIndicatorHeight);
- if (ir.width() > indicatorWidth)
- xOffset += (ir.width() - indicatorWidth)/2;
- if (ir.height() > indicatorHeight)
- yOffset += (ir.height() - indicatorHeight)/2;
- p->translate(xOffset, yOffset);
-
- p->translate(ir.x(), ir.y());
-
+ p->setRenderHint(QPainter::Antialiasing, true);
+
+ QPointF circleCenter = r.center() + QPoint(1, 1);
+ qreal radius = (r.width() + (r.width() + 1) % 2) / 2.0 - 1;
+
+ QPainterPath path1;
+ path1.addEllipse(circleCenter, radius, radius);
+ radius *= 0.85;
+ QPainterPath path2;
+ path2.addEllipse(circleCenter, radius, radius);
+ radius *= 0.85;
+ QPainterPath path3;
+ path3.addEllipse(circleCenter, radius, radius);
+ radius *= 0.5;
+ QPainterPath path4;
+ path4.addEllipse(circleCenter, radius, radius);
+
+ QPolygon topLeftPol, bottomRightPol;
+ topLeftPol.setPoints(3, r.x(), r.y(), r.x(), r.y() + r.height(), r.x() + r.width(), r.y());
+ bottomRightPol.setPoints(3, r.x(), r.y() + r.height(), r.x() + r.width(), r.y() + r.height(), r.x() + r.width(), r.y());
+
+ p->setClipRegion(QRegion(topLeftPol));
p->setPen(opt->palette.dark().color());
- p->drawPolyline(pts1, PTSARRLEN(pts1));
-
+ p->setBrush(opt->palette.dark().color());
+ p->drawPath(path1);
p->setPen(opt->palette.shadow().color());
- p->drawPolyline(pts2, PTSARRLEN(pts2));
+ p->setBrush(opt->palette.shadow().color());
+ p->drawPath(path2);
+ p->setClipRegion(QRegion(bottomRightPol));
+ p->setPen(opt->palette.light().color());
+ p->setBrush(opt->palette.light().color());
+ p->drawPath(path1);
p->setPen(opt->palette.midlight().color());
- p->drawPolyline(pts3, PTSARRLEN(pts3));
+ p->setBrush(opt->palette.midlight().color());
+ p->drawPath(path2);
- p->setPen(opt->palette.light().color());
- p->drawPolyline(pts4, PTSARRLEN(pts4));
+ QColor fillColor = ((opt->state & State_Sunken) || !(opt->state & State_Enabled)) ?
+ opt->palette.button().color() : opt->palette.base().color();
- QColor fillColor = (down || !enabled)
- ? opt->palette.button().color()
- : opt->palette.base().color();
+ p->setClipping(false);
p->setPen(fillColor);
- p->setBrush(fillColor) ;
- p->drawPolygon(pts5, PTSARRLEN(pts5));
+ p->setBrush(fillColor);
+ p->drawPath(path3);
- p->translate(-ir.x(), -ir.y()); // restore translate
-
- if (on) {
- p->setPen(Qt::NoPen);
+ if (opt->state & State_On) {
+ p->setPen(opt->palette.text().color());
p->setBrush(opt->palette.text());
- p->drawRect(ir.x() + 5, ir.y() + 4, 2, 4);
- p->drawRect(ir.x() + 4, ir.y() + 5, 4, 2);
+ p->drawPath(path4);
}
p->restore();
break;
@@ -2388,7 +2354,7 @@ QSize QWindowsStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
QFont fontBold = mi->font;
fontBold.setBold(true);
QFontMetrics fmBold(fontBold);
- w += fmBold.width(mi->text) - fm.width(mi->text);
+ w += fmBold.horizontalAdvance(mi->text) - fm.horizontalAdvance(mi->text);
}
int checkcol = qMax<int>(maxpmw, QWindowsStylePrivate::windowsCheckMarkWidth); // Windows always shows a check column
diff --git a/src/widgets/styles/qwindowsstyle_p.h b/src/widgets/styles/qwindowsstyle_p.h
index a1d65610ff..7993b9f1c6 100644
--- a/src/widgets/styles/qwindowsstyle_p.h
+++ b/src/widgets/styles/qwindowsstyle_p.h
@@ -61,44 +61,44 @@ QT_BEGIN_NAMESPACE
class QWindowsStylePrivate;
-class QWindowsStyle : public QCommonStyle
+class Q_WIDGETS_EXPORT QWindowsStyle : public QCommonStyle
{
Q_OBJECT
public:
QWindowsStyle();
~QWindowsStyle();
- void polish(QApplication*) Q_DECL_OVERRIDE;
- void unpolish(QApplication*) Q_DECL_OVERRIDE;
+ void polish(QApplication*) override;
+ void unpolish(QApplication*) override;
- void polish(QWidget*) Q_DECL_OVERRIDE;
- void unpolish(QWidget*) Q_DECL_OVERRIDE;
+ void polish(QWidget*) override;
+ void unpolish(QWidget*) override;
- void polish(QPalette &) Q_DECL_OVERRIDE;
+ void polish(QPalette &) override;
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const Q_DECL_OVERRIDE;
+ const QWidget *w = 0) const override;
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const Q_DECL_OVERRIDE;
- QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ const QWidget *w = 0) const override;
+ QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const override;
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
- const QWidget *w = 0) const Q_DECL_OVERRIDE;
+ const QWidget *w = 0) const override;
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
- const QSize &contentsSize, const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ const QSize &contentsSize, const QWidget *widget = 0) const override;
- int pixelMetric(PixelMetric pm, const QStyleOption *option = 0, const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ int pixelMetric(PixelMetric pm, const QStyleOption *option = 0, const QWidget *widget = 0) const override;
int styleHint(StyleHint hint, const QStyleOption *opt = 0, const QWidget *widget = 0,
- QStyleHintReturn *returnData = 0) const Q_DECL_OVERRIDE;
+ QStyleHintReturn *returnData = 0) const override;
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
- const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ const QWidget *widget = 0) const override;
QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0,
- const QWidget *widget = 0) const Q_DECL_OVERRIDE;
+ const QWidget *widget = 0) const override;
protected:
- bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE;
+ bool eventFilter(QObject *o, QEvent *e) override;
QWindowsStyle(QWindowsStylePrivate &dd);
private:
diff --git a/src/widgets/styles/qwindowsstyle_p_p.h b/src/widgets/styles/qwindowsstyle_p_p.h
index 5023fd1042..67fa6a2f86 100644
--- a/src/widgets/styles/qwindowsstyle_p_p.h
+++ b/src/widgets/styles/qwindowsstyle_p_p.h
@@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE
class QTime;
-class QWindowsStylePrivate : public QCommonStylePrivate
+class Q_WIDGETS_EXPORT QWindowsStylePrivate : public QCommonStylePrivate
{
Q_DECLARE_PUBLIC(QWindowsStyle)
public:
@@ -73,7 +73,7 @@ public:
static int fixedPixelMetric(QStyle::PixelMetric pm);
static qreal devicePixelRatio(const QWidget *widget = 0)
{ return widget ? widget->devicePixelRatioF() : QWindowsStylePrivate::appDevicePixelRatio(); }
- static qreal nativeMetricScaleFactor(const QWidget *widget = Q_NULLPTR);
+ static qreal nativeMetricScaleFactor(const QWidget *widget = nullptr);
bool hasSeenAlt(const QWidget *widget) const;
bool altDown() const { return alt_down; }
diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp
deleted file mode 100644
index 906c3ed7c3..0000000000
--- a/src/widgets/styles/qwindowsvistastyle.cpp
+++ /dev/null
@@ -1,2492 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwindowsvistastyle_p.h"
-#include "qwindowsvistastyle_p_p.h"
-#include <qoperatingsystemversion.h>
-#include <qscreen.h>
-#include <qwindow.h>
-#include <private/qstyleanimation_p.h>
-#include <private/qstylehelper_p.h>
-#include <private/qapplication_p.h>
-#include <qpa/qplatformnativeinterface.h>
-
-#if QT_CONFIG(style_windowsvista) || defined(QT_PLUGIN)
-
-QT_BEGIN_NAMESPACE
-
-static const int windowsItemFrame = 2; // menu item frame width
-static const int windowsItemHMargin = 3; // menu item hor text margin
-static const int windowsItemVMargin = 4; // menu item ver text margin
-static const int windowsArrowHMargin = 6; // arrow horizontal margin
-static const int windowsRightBorder = 15; // right border on windows
-
-#ifndef TMT_CONTENTMARGINS
-# define TMT_CONTENTMARGINS 3602
-#endif
-#ifndef TMT_SIZINGMARGINS
-# define TMT_SIZINGMARGINS 3601
-#endif
-#ifndef LISS_NORMAL
-# define LISS_NORMAL 1
-# define LISS_HOT 2
-# define LISS_SELECTED 3
-# define LISS_DISABLED 4
-# define LISS_SELECTEDNOTFOCUS 5
-# define LISS_HOTSELECTED 6
-#endif
-#ifndef BP_COMMANDLINK
-# define BP_COMMANDLINK 6
-# define BP_COMMANDLINKGLYPH 7
-# define CMDLGS_NORMAL 1
-# define CMDLGS_HOT 2
-# define CMDLGS_PRESSED 3
-# define CMDLGS_DISABLED 4
-#endif
-
-/* \internal
- Checks if we should use Vista style , or if we should
- fall back to Windows style.
-*/
-bool QWindowsVistaStylePrivate::useVista()
-{
- return (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
- && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based))
- && QWindowsVistaStylePrivate::useXP();
-}
-
-/* \internal
- Checks and returns the style object
-*/
-inline QObject *styleObject(const QStyleOption *option) {
- return option ? option->styleObject : 0;
-}
-
-/* \internal
- Checks if we can animate on a style option
-*/
-bool canAnimate(const QStyleOption *option) {
- return option
- && option->styleObject
- && !option->styleObject->property("_q_no_animation").toBool();
-}
-
-static inline QImage createAnimationBuffer(const QStyleOption *option, const QWidget *widget)
-{
- const int devicePixelRatio = widget ? widget->devicePixelRatio() : 1;
- QImage result(option->rect.size() * devicePixelRatio, QImage::Format_ARGB32_Premultiplied);
- result.setDevicePixelRatio(devicePixelRatio);
- result.fill(0);
- return result;
-}
-
-/* \internal
- Used by animations to clone a styleoption and shift its offset
-*/
-QStyleOption *clonedAnimationStyleOption(const QStyleOption*option) {
- QStyleOption *styleOption = 0;
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option))
- styleOption = new QStyleOptionSlider(*slider);
- else if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox*>(option))
- styleOption = new QStyleOptionSpinBox(*spinbox);
- else if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox*>(option))
- styleOption = new QStyleOptionGroupBox(*groupBox);
- else if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox*>(option))
- styleOption = new QStyleOptionComboBox(*combo);
- else if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton*>(option))
- styleOption = new QStyleOptionButton(*button);
- else
- styleOption = new QStyleOption(*option);
- styleOption->rect = QRect(QPoint(0,0), option->rect.size());
- return styleOption;
-}
-
-/* \internal
- Used by animations to delete cloned styleoption
-*/
-void deleteClonedAnimationStyleOption(const QStyleOption *option)
-{
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option))
- delete slider;
- else if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox*>(option))
- delete spinbox;
- else if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox*>(option))
- delete groupBox;
- else if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox*>(option))
- delete combo;
- else if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton*>(option))
- delete button;
- else
- delete option;
-}
-
-/*!
- \class QWindowsVistaStyle
- \brief The QWindowsVistaStyle class provides a look and feel suitable for applications on Microsoft Windows Vista.
- \since 4.3
- \ingroup appearance
- \inmodule QtWidgets
- \internal
-
- \warning This style is only available on the Windows Vista platform
- because it makes use of Windows Vista's style engine.
-
- \sa QMacStyle, QWindowsXPStyle, QFusionStyle
-*/
-
-/*!
- Constructs a QWindowsVistaStyle object.
-*/
-QWindowsVistaStyle::QWindowsVistaStyle()
- : QWindowsXPStyle(*new QWindowsVistaStylePrivate)
-{
-}
-
-/*!
- Destructor.
-*/
-QWindowsVistaStyle::~QWindowsVistaStyle()
-{
-}
-
-//convert Qt state flags to uxtheme button states
-static int buttonStateId(int flags, int partId)
-{
- int stateId = 0;
- if (partId == BP_RADIOBUTTON || partId == BP_CHECKBOX) {
- if (!(flags & QStyle::State_Enabled))
- stateId = RBS_UNCHECKEDDISABLED;
- else if (flags & QStyle::State_Sunken)
- stateId = RBS_UNCHECKEDPRESSED;
- else if (flags & QStyle::State_MouseOver)
- stateId = RBS_UNCHECKEDHOT;
- else
- stateId = RBS_UNCHECKEDNORMAL;
-
- if (flags & QStyle::State_On)
- stateId += RBS_CHECKEDNORMAL-1;
-
- } else if (partId == BP_PUSHBUTTON) {
- if (!(flags & QStyle::State_Enabled))
- stateId = PBS_DISABLED;
- else if (flags & (QStyle::State_Sunken | QStyle::State_On))
- stateId = PBS_PRESSED;
- else if (flags & QStyle::State_MouseOver)
- stateId = PBS_HOT;
- else
- stateId = PBS_NORMAL;
- } else {
- Q_ASSERT(1);
- }
- return stateId;
-}
-
-bool QWindowsVistaAnimation::isUpdateNeeded() const
-{
- return QWindowsVistaStylePrivate::useVista();
-}
-
-void QWindowsVistaAnimation::paint(QPainter *painter, const QStyleOption *option)
-{
- painter->drawImage(option->rect, currentImage());
-}
-
-static inline bool supportsStateTransition(QStyle::PrimitiveElement element,
- const QStyleOption *option,
- const QWidget *widget)
-{
- bool result = false;
- switch (element) {
- case QStyle::PE_IndicatorRadioButton:
- case QStyle::PE_IndicatorCheckBox:
- result = true;
- break;
- // QTBUG-40634, do not animate when color is set in palette for PE_PanelLineEdit.
- case QStyle::PE_FrameLineEdit:
- result = !QWindowsXPStylePrivate::isLineEditBaseColorSet(option, widget);
- break;
- default:
- break;
- }
- return result;
-}
-
-/*!
- \internal
-
- Animations are used for some state transitions on specific widgets.
-
- Only one running animation can exist for a widget at any specific
- time. Animations can be added through
- QWindowsVistaStylePrivate::startAnimation(Animation *) and any
- existing animation on a widget can be retrieved with
- QWindowsVistaStylePrivate::widgetAnimation(Widget *).
-
- Once an animation has been started,
- QWindowsVistaStylePrivate::timerEvent(QTimerEvent *) will
- continuously call update() on the widget until it is stopped,
- meaning that drawPrimitive will be called many times until the
- transition has completed. During this time, the result will be
- retrieved by the Animation::paint(...) function and not by the style
- itself.
-
- To determine if a transition should occur, the style needs to know
- the previous state of the widget as well as the current one. This is
- solved by updating dynamic properties on the widget every time the
- function is called.
-
- Transitions interrupting existing transitions should always be
- smooth, so whenever a hover-transition is started on a pulsating
- button, it uses the current frame of the pulse-animation as the
- starting image for the hover transition.
-
- */
-
-void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
- QPainter *painter, const QWidget *widget) const
-{
- QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func());
-
- int state = option->state;
- if (!QWindowsVistaStylePrivate::useVista()) {
- QWindowsStyle::drawPrimitive(element, option, painter, widget);
- return;
- }
-
- if ((option->state & State_Enabled) && d->transitionsEnabled() && canAnimate(option)) {
- {
- QRect oldRect;
- QRect newRect;
-
- if (supportsStateTransition(element, option, widget)) {
- // Retrieve and update the dynamic properties tracking
- // the previous state of the widget:
- QObject *styleObject = option->styleObject;
- styleObject->setProperty("_q_no_animation", true);
-
- int oldState = styleObject->property("_q_stylestate").toInt();
- oldRect = styleObject->property("_q_stylerect").toRect();
- newRect = option->rect;
- styleObject->setProperty("_q_stylestate", (int)option->state);
- styleObject->setProperty("_q_stylerect", option->rect);
-
- bool doTransition = oldState &&
- ((state & State_Sunken) != (oldState & State_Sunken) ||
- (state & State_On) != (oldState & State_On) ||
- (state & State_MouseOver) != (oldState & State_MouseOver));
-
- if (oldRect != newRect ||
- (state & State_Enabled) != (oldState & State_Enabled) ||
- (state & State_Active) != (oldState & State_Active))
- d->stopAnimation(styleObject);
-
- if (option->state & State_ReadOnly && element == PE_FrameLineEdit) // Do not animate read only line edits
- doTransition = false;
-
- if (doTransition) {
- QStyleOption *styleOption = clonedAnimationStyleOption(option);
- styleOption->state = (QStyle::State)oldState;
-
- QWindowsVistaAnimation *anim = qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject));
- QWindowsVistaTransition *t = new QWindowsVistaTransition(styleObject);
-
- // We create separate images for the initial and final transition states and store them in the
- // Transition object.
- QImage startImage = createAnimationBuffer(option, widget);
- QPainter startPainter(&startImage);
-
- QImage endImage = createAnimationBuffer(option, widget);
- QPainter endPainter(&endImage);
-
- // If we have a running animation on the widget already, we will use that to paint the initial
- // state of the new transition, this ensures a smooth transition from a current animation such as a
- // pulsating default button into the intended target state.
- if (!anim)
- proxy()->drawPrimitive(element, styleOption, &startPainter, widget);
- else
- anim->paint(&startPainter, styleOption);
-
- t->setStartImage(startImage);
-
- // The end state of the transition is simply the result we would have painted
- // if the style was not animated.
- styleOption->styleObject = 0;
- styleOption->state = option->state;
- proxy()->drawPrimitive(element, styleOption, &endPainter, widget);
-
-
- t->setEndImage(endImage);
-
- HTHEME theme;
- int partId;
- DWORD duration;
- int fromState = 0;
- int toState = 0;
-
- //translate state flags to UXTHEME states :
- if (element == PE_FrameLineEdit) {
- theme = OpenThemeData(0, L"Edit");
- partId = EP_EDITBORDER_NOSCROLL;
-
- if (oldState & State_MouseOver)
- fromState = ETS_HOT;
- else if (oldState & State_HasFocus)
- fromState = ETS_FOCUSED;
- else
- fromState = ETS_NORMAL;
-
- if (state & State_MouseOver)
- toState = ETS_HOT;
- else if (state & State_HasFocus)
- toState = ETS_FOCUSED;
- else
- toState = ETS_NORMAL;
-
- } else {
- theme = OpenThemeData(0, L"Button");
- if (element == PE_IndicatorRadioButton)
- partId = BP_RADIOBUTTON;
- else if (element == PE_IndicatorCheckBox)
- partId = BP_CHECKBOX;
- else
- partId = BP_PUSHBUTTON;
-
- fromState = buttonStateId(oldState, partId);
- toState = buttonStateId(option->state, partId);
- }
-
- // Retrieve the transition time between the states from the system.
- if (theme
- && SUCCEEDED(GetThemeTransitionDuration(theme, partId, fromState, toState,
- TMT_TRANSITIONDURATIONS, &duration))) {
- t->setDuration(duration);
- }
- t->setStartTime(QTime::currentTime());
-
- deleteClonedAnimationStyleOption(styleOption);
- d->startAnimation(t);
- }
- styleObject->setProperty("_q_no_animation", false);
- }
-
- } // End of animation part
- }
-
- QRect rect = option->rect;
-
- switch (element) {
- case PE_IndicatorHeaderArrow:
- if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
- int stateId = HSAS_SORTEDDOWN;
- if (header->sortIndicator & QStyleOptionHeader::SortDown)
- stateId = HSAS_SORTEDUP; //note that the uxtheme sort down indicator is the inverse of ours
- XPThemeData theme(widget, painter,
- QWindowsXPStylePrivate::HeaderTheme,
- HP_HEADERSORTARROW, stateId, option->rect);
- d->drawBackground(theme);
- }
- break;
-
- case PE_IndicatorBranch:
- {
- XPThemeData theme(widget, painter, QWindowsXPStylePrivate::VistaTreeViewTheme);
- static int decoration_size = 0;
- if (!decoration_size && theme.isValid()) {
- XPThemeData themeSize = theme;
- themeSize.partId = TVP_HOTGLYPH;
- themeSize.stateId = GLPS_OPENED;
- const QSizeF size = themeSize.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget);
- decoration_size = qRound(qMax(size.width(), size.height()));
- }
- int mid_h = option->rect.x() + option->rect.width() / 2;
- int mid_v = option->rect.y() + option->rect.height() / 2;
- int bef_h = mid_h;
- int bef_v = mid_v;
- int aft_h = mid_h;
- int aft_v = mid_v;
- if (option->state & State_Children) {
- int delta = decoration_size / 2;
- theme.rect = QRect(bef_h - delta, bef_v - delta, decoration_size, decoration_size);
- theme.partId = option->state & State_MouseOver ? TVP_HOTGLYPH : TVP_GLYPH;
- theme.stateId = option->state & QStyle::State_Open ? GLPS_OPENED : GLPS_CLOSED;
- if (option->direction == Qt::RightToLeft)
- theme.mirrorHorizontally = true;
- d->drawBackground(theme);
- bef_h -= delta + 2;
- bef_v -= delta + 2;
- aft_h += delta - 2;
- aft_v += delta - 2;
- }
-#if 0
- QBrush brush(option->palette.dark().color(), Qt::Dense4Pattern);
- if (option->state & State_Item) {
- if (option->direction == Qt::RightToLeft)
- painter->fillRect(option->rect.left(), mid_v, bef_h - option->rect.left(), 1, brush);
- else
- painter->fillRect(aft_h, mid_v, option->rect.right() - aft_h + 1, 1, brush);
- }
- if (option->state & State_Sibling && option->rect.bottom() > aft_v)
- painter->fillRect(mid_h, aft_v, 1, option->rect.bottom() - aft_v + 1, brush);
- if (option->state & (State_Open | State_Children | State_Item | State_Sibling) && (bef_v > option->rect.y()))
- painter->fillRect(mid_h, option->rect.y(), 1, bef_v - option->rect.y(), brush);
-#endif
- }
- break;
-
- case PE_PanelButtonBevel:
- case PE_IndicatorCheckBox:
- case PE_IndicatorRadioButton:
- {
- if (QWindowsVistaAnimation *a =
- qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject(option)))){
- a->paint(painter, option);
- } else {
- QWindowsXPStyle::drawPrimitive(element, option, painter, widget);
- }
- }
- break;
-
- case PE_FrameMenu:
- {
- int stateId = option->state & State_Active ? MB_ACTIVE : MB_INACTIVE;
- XPThemeData theme(widget, painter,
- QWindowsXPStylePrivate::MenuTheme,
- MENU_POPUPBORDERS, stateId, option->rect);
- d->drawBackground(theme);
- }
- break;
- case PE_Frame: {
-#ifndef QT_NO_ACCESSIBILITY
- if (QStyleHelper::isInstanceOf(option->styleObject, QAccessible::EditableText)
- || QStyleHelper::isInstanceOf(option->styleObject, QAccessible::StaticText) ||
-#else
- if (
-#endif
- (widget && widget->inherits("QTextEdit"))) {
- painter->save();
- int stateId = ETS_NORMAL;
- if (!(state & State_Enabled))
- stateId = ETS_DISABLED;
- else if (state & State_ReadOnly)
- stateId = ETS_READONLY;
- else if (state & State_HasFocus)
- stateId = ETS_SELECTED;
- XPThemeData theme(widget, painter,
- QWindowsXPStylePrivate::EditTheme,
- EP_EDITBORDER_HVSCROLL, stateId, option->rect);
- // Since EP_EDITBORDER_HVSCROLL does not us borderfill, theme.noContent cannot be used for clipping
- int borderSize = 1;
- GetThemeInt(theme.handle(), theme.partId, theme.stateId, TMT_BORDERSIZE, &borderSize);
- QRegion clipRegion = option->rect;
- QRegion content = option->rect.adjusted(borderSize, borderSize, -borderSize, -borderSize);
- clipRegion ^= content;
- painter->setClipRegion(clipRegion);
- d->drawBackground(theme);
- painter->restore();
- } else {
- QWindowsXPStyle::drawPrimitive(element, option, painter, widget);
- }
- }
- break;
-
- case PE_PanelLineEdit:
- if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
- bool isEnabled = option->state & State_Enabled;
- if (QWindowsXPStylePrivate::isLineEditBaseColorSet(option, widget)) {
- painter->fillRect(panel->rect, panel->palette.brush(QPalette::Base));
- } else {
- int partId = EP_BACKGROUND;
- int stateId = EBS_NORMAL;
- if (!isEnabled)
- stateId = EBS_DISABLED;
- else if (state & State_ReadOnly)
- stateId = EBS_READONLY;
- else if (state & State_MouseOver)
- stateId = EBS_HOT;
-
- XPThemeData theme(0, painter, QWindowsXPStylePrivate::EditTheme,
- partId, stateId, rect);
- if (!theme.isValid()) {
- QWindowsStyle::drawPrimitive(element, option, painter, widget);
- return;
- }
- int bgType;
- GetThemeEnumValue(theme.handle(), partId, stateId, TMT_BGTYPE, &bgType);
- if( bgType == BT_IMAGEFILE ) {
- d->drawBackground(theme);
- } else {
- QBrush fillColor = option->palette.brush(QPalette::Base);
- if (!isEnabled) {
- PROPERTYORIGIN origin = PO_NOTFOUND;
- GetThemePropertyOrigin(theme.handle(), theme.partId, theme.stateId, TMT_FILLCOLOR, &origin);
- // Use only if the fill property comes from our part
- if ((origin == PO_PART || origin == PO_STATE)) {
- COLORREF bgRef;
- GetThemeColor(theme.handle(), partId, stateId, TMT_FILLCOLOR, &bgRef);
- fillColor = QBrush(qRgb(GetRValue(bgRef), GetGValue(bgRef), GetBValue(bgRef)));
- }
- }
- painter->fillRect(option->rect, fillColor);
- }
- }
- if (panel->lineWidth > 0)
- proxy()->drawPrimitive(PE_FrameLineEdit, panel, painter, widget);
- return;
- }
- break;
-
- case PE_FrameLineEdit:
- if (QWindowsVistaAnimation *anim = qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject(option)))) {
- anim->paint(painter, option);
- } else {
- QPainter *p = painter;
- if (QWindowsXPStylePrivate::isItemViewDelegateLineEdit(widget)) {
- // we try to check if this lineedit is a delegate on a QAbstractItemView-derived class.
- QPen oldPen = p->pen();
- // Inner white border
- p->setPen(QPen(option->palette.base().color(), 1));
- p->drawRect(option->rect.adjusted(1, 1, -2, -2));
- // Outer dark border
- p->setPen(QPen(option->palette.shadow().color(), 1));
- p->drawRect(option->rect.adjusted(0, 0, -1, -1));
- p->setPen(oldPen);
- return;
- } else {
- int stateId = ETS_NORMAL;
- if (!(state & State_Enabled))
- stateId = ETS_DISABLED;
- else if (state & State_ReadOnly)
- stateId = ETS_READONLY;
- else if (state & State_MouseOver)
- stateId = ETS_HOT;
- else if (state & State_HasFocus)
- stateId = ETS_SELECTED;
- XPThemeData theme(widget, painter,
- QWindowsXPStylePrivate::EditTheme,
- EP_EDITBORDER_NOSCROLL, stateId, option->rect);
- theme.noContent = true;
- painter->save();
- QRegion clipRegion = option->rect;
- clipRegion -= option->rect.adjusted(2, 2, -2, -2);
- painter->setClipRegion(clipRegion);
- d->drawBackground(theme);
- painter->restore();
- }
- }
- break;
-
- case PE_IndicatorToolBarHandle:
- {
- XPThemeData theme;
- QRect rect;
- if (option->state & State_Horizontal) {
- theme = XPThemeData(widget, painter,
- QWindowsXPStylePrivate::RebarTheme,
- RP_GRIPPER, ETS_NORMAL, option->rect.adjusted(0, 1, -2, -2));
- rect = option->rect.adjusted(0, 1, 0, -2);
- rect.setWidth(4);
- } else {
- theme = XPThemeData(widget, painter, QWindowsXPStylePrivate::RebarTheme,
- RP_GRIPPERVERT, ETS_NORMAL, option->rect.adjusted(0, 1, -2, -2));
- rect = option->rect.adjusted(1, 0, -1, 0);
- rect.setHeight(4);
- }
- theme.rect = rect;
- d->drawBackground(theme);
- }
- break;
-
- case PE_IndicatorToolBarSeparator:
- {
- QPen pen = painter->pen();
- int margin = 3;
- painter->setPen(option->palette.background().color().darker(114));
- if (option->state & State_Horizontal) {
- int x1 = option->rect.center().x();
- painter->drawLine(QPoint(x1, option->rect.top() + margin), QPoint(x1, option->rect.bottom() - margin));
- } else {
- int y1 = option->rect.center().y();
- painter->drawLine(QPoint(option->rect.left() + margin, y1), QPoint(option->rect.right() - margin, y1));
- }
- painter->setPen(pen);
- }
- break;
-
- case PE_PanelTipLabel: {
- XPThemeData theme(widget, painter,
- QWindowsXPStylePrivate::ToolTipTheme,
- TTP_STANDARD, TTSS_NORMAL, option->rect);
- d->drawBackground(theme);
- break;
- }
-
- case PE_PanelItemViewItem:
- {
- const QStyleOptionViewItem *vopt;
- bool newStyle = true;
- QAbstractItemView::SelectionBehavior selectionBehavior = QAbstractItemView::SelectRows;
- QAbstractItemView::SelectionMode selectionMode = QAbstractItemView::NoSelection;
- if (const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(widget)) {
- newStyle = !qobject_cast<const QTableView*>(view);
- selectionBehavior = view->selectionBehavior();
- selectionMode = view->selectionMode();
-#ifndef QT_NO_ACCESSIBILITY
- } else if (!widget) {
- newStyle = !QStyleHelper::hasAncestor(option->styleObject, QAccessible::MenuItem) ;
-#endif
- }
-
- if (newStyle && (vopt = qstyleoption_cast<const QStyleOptionViewItem *>(option))) {
- bool selected = vopt->state & QStyle::State_Selected;
- const bool hover = selectionMode != QAbstractItemView::NoSelection && (vopt->state & QStyle::State_MouseOver);
- bool active = vopt->state & QStyle::State_Active;
-
- if (vopt->features & QStyleOptionViewItem::Alternate)
- painter->fillRect(vopt->rect, vopt->palette.alternateBase());
-
- QPalette::ColorGroup cg = vopt->state & QStyle::State_Enabled
- ? QPalette::Normal : QPalette::Disabled;
- if (cg == QPalette::Normal && !(vopt->state & QStyle::State_Active))
- cg = QPalette::Inactive;
-
- QRect itemRect = subElementRect(QStyle::SE_ItemViewItemFocusRect, option, widget).adjusted(-1, 0, 1, 0);
- itemRect.setTop(vopt->rect.top());
- itemRect.setBottom(vopt->rect.bottom());
-
- QSize sectionSize = itemRect.size();
- if (vopt->showDecorationSelected)
- sectionSize = vopt->rect.size();
-
- if (selectionBehavior == QAbstractItemView::SelectRows)
- sectionSize.setWidth(vopt->rect.width());
- QPixmap pixmap;
-
- if (vopt->backgroundBrush.style() != Qt::NoBrush) {
- const QPointF oldBrushOrigin = painter->brushOrigin();
- painter->setBrushOrigin(vopt->rect.topLeft());
- painter->fillRect(vopt->rect, vopt->backgroundBrush);
- painter->setBrushOrigin(oldBrushOrigin);
- }
-
- if (hover || selected) {
- if (sectionSize.width() > 0 && sectionSize.height() > 0) {
- QString key = QString::fromLatin1("qvdelegate-%1-%2-%3-%4-%5").arg(sectionSize.width())
- .arg(sectionSize.height()).arg(selected).arg(active).arg(hover);
- if (!QPixmapCache::find(key, pixmap)) {
- pixmap = QPixmap(sectionSize);
- pixmap.fill(Qt::transparent);
-
- int state;
- if (selected && hover)
- state = LISS_HOTSELECTED;
- else if (selected && !active)
- state = LISS_SELECTEDNOTFOCUS;
- else if (selected)
- state = LISS_SELECTED;
- else
- state = LISS_HOT;
-
- QPainter pixmapPainter(&pixmap);
- XPThemeData theme(widget, &pixmapPainter,
- QWindowsXPStylePrivate::VistaTreeViewTheme,
- LVP_LISTITEM, state, QRect(0, 0, sectionSize.width(), sectionSize.height()));
- if (theme.isValid()) {
- d->drawBackground(theme);
- } else {
- QWindowsXPStyle::drawPrimitive(PE_PanelItemViewItem, option, painter, widget);
- break;;
- }
- QPixmapCache::insert(key, pixmap);
- }
- }
-
- if (vopt->showDecorationSelected) {
- const int frame = 2; //Assumes a 2 pixel pixmap border
- QRect srcRect = QRect(0, 0, sectionSize.width(), sectionSize.height());
- QRect pixmapRect = vopt->rect;
- bool reverse = vopt->direction == Qt::RightToLeft;
- bool leftSection = vopt->viewItemPosition == QStyleOptionViewItem::Beginning;
- bool rightSection = vopt->viewItemPosition == QStyleOptionViewItem::End;
- if (vopt->viewItemPosition == QStyleOptionViewItem::OnlyOne
- || vopt->viewItemPosition == QStyleOptionViewItem::Invalid)
- painter->drawPixmap(pixmapRect.topLeft(), pixmap);
- else if (reverse ? rightSection : leftSection){
- painter->drawPixmap(QRect(pixmapRect.topLeft(),
- QSize(frame, pixmapRect.height())), pixmap,
- QRect(QPoint(0, 0), QSize(frame, pixmapRect.height())));
- painter->drawPixmap(pixmapRect.adjusted(frame, 0, 0, 0),
- pixmap, srcRect.adjusted(frame, 0, -frame, 0));
- } else if (reverse ? leftSection : rightSection) {
- painter->drawPixmap(QRect(pixmapRect.topRight() - QPoint(frame - 1, 0),
- QSize(frame, pixmapRect.height())), pixmap,
- QRect(QPoint(pixmapRect.width() - frame, 0),
- QSize(frame, pixmapRect.height())));
- painter->drawPixmap(pixmapRect.adjusted(0, 0, -frame, 0),
- pixmap, srcRect.adjusted(frame, 0, -frame, 0));
- } else if (vopt->viewItemPosition == QStyleOptionViewItem::Middle)
- painter->drawPixmap(pixmapRect, pixmap,
- srcRect.adjusted(frame, 0, -frame, 0));
- } else {
- if (vopt->text.isEmpty() && vopt->icon.isNull())
- break;
- painter->drawPixmap(itemRect.topLeft(), pixmap);
- }
- }
- } else {
- QWindowsXPStyle::drawPrimitive(element, option, painter, widget);
- }
- break;
- }
- case PE_Widget:
- {
-#if QT_CONFIG(dialogbuttonbox)
- const QDialogButtonBox *buttonBox = 0;
-
- if (qobject_cast<const QMessageBox *> (widget))
- buttonBox = widget->findChild<const QDialogButtonBox *>(QLatin1String("qt_msgbox_buttonbox"));
-#if QT_CONFIG(inputdialog)
- else if (qobject_cast<const QInputDialog *> (widget))
- buttonBox = widget->findChild<const QDialogButtonBox *>(QLatin1String("qt_inputdlg_buttonbox"));
-#endif // QT_CONFIG(inputdialog)
-
- if (buttonBox) {
- //draw white panel part
- XPThemeData theme(widget, painter,
- QWindowsXPStylePrivate::TaskDialogTheme,
- TDLG_PRIMARYPANEL, 0, option->rect);
- QRect toprect = option->rect;
- toprect.setBottom(buttonBox->geometry().top());
- theme.rect = toprect;
- d->drawBackground(theme);
-
- //draw bottom panel part
- QRect buttonRect = option->rect;
- buttonRect.setTop(buttonBox->geometry().top());
- theme.rect = buttonRect;
- theme.partId = TDLG_SECONDARYPANEL;
- d->drawBackground(theme);
- }
-#endif
- }
- break;
- default:
- QWindowsXPStyle::drawPrimitive(element, option, painter, widget);
- break;
- }
-}
-
-
-/*!
- \internal
-
- see drawPrimitive for comments on the animation support
- */
-void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption *option,
- QPainter *painter, const QWidget *widget) const
-{
- QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func());
-
- if (!QWindowsVistaStylePrivate::useVista()) {
- QWindowsStyle::drawControl(element, option, painter, widget);
- return;
- }
-
- bool selected = option->state & State_Selected;
- bool pressed = option->state & State_Sunken;
- bool disabled = !(option->state & State_Enabled);
-
- int state = option->state;
- int themeNumber = -1;
-
- QRect rect(option->rect);
- State flags = option->state;
- int partId = 0;
- int stateId = 0;
-
- if (d->transitionsEnabled() && canAnimate(option))
- {
- if (element == CE_PushButtonBevel) {
- QRect oldRect;
- QRect newRect;
-
- QObject *styleObject = option->styleObject;
-
- int oldState = styleObject->property("_q_stylestate").toInt();
- oldRect = styleObject->property("_q_stylerect").toRect();
- newRect = option->rect;
- styleObject->setProperty("_q_stylestate", (int)option->state);
- styleObject->setProperty("_q_stylerect", option->rect);
-
- bool wasDefault = false;
- bool isDefault = false;
- if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- wasDefault = styleObject->property("_q_isdefault").toBool();
- isDefault = button->features & QStyleOptionButton::DefaultButton;
- styleObject->setProperty("_q_isdefault", isDefault);
- }
-
- bool doTransition = ((state & State_Sunken) != (oldState & State_Sunken) ||
- (state & State_On) != (oldState & State_On) ||
- (state & State_MouseOver) != (oldState & State_MouseOver));
-
- if (oldRect != newRect || (wasDefault && !isDefault)) {
- doTransition = false;
- d->stopAnimation(styleObject);
- }
-
- if (doTransition) {
- styleObject->setProperty("_q_no_animation", true);
-
- QWindowsVistaTransition *t = new QWindowsVistaTransition(styleObject);
- QWindowsVistaAnimation *anim = qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject));
- QStyleOption *styleOption = clonedAnimationStyleOption(option);
- styleOption->state = (QStyle::State)oldState;
-
- QImage startImage = createAnimationBuffer(option, widget);
- QPainter startPainter(&startImage);
-
- // Use current state of existing animation if already one is running
- if (!anim) {
- proxy()->drawControl(element, styleOption, &startPainter, widget);
- } else {
- anim->paint(&startPainter, styleOption);
- d->stopAnimation(styleObject);
- }
-
- t->setStartImage(startImage);
- QImage endImage = createAnimationBuffer(option, widget);
- QPainter endPainter(&endImage);
- styleOption->state = option->state;
- proxy()->drawControl(element, styleOption, &endPainter, widget);
- t->setEndImage(endImage);
-
-
- DWORD duration = 0;
- const HTHEME theme = OpenThemeData(0, L"Button");
-
- int fromState = buttonStateId(oldState, BP_PUSHBUTTON);
- int toState = buttonStateId(option->state, BP_PUSHBUTTON);
- if (GetThemeTransitionDuration(theme, BP_PUSHBUTTON, fromState, toState, TMT_TRANSITIONDURATIONS, &duration) == S_OK)
- t->setDuration(duration);
- else
- t->setDuration(0);
- t->setStartTime(QTime::currentTime());
- styleObject->setProperty("_q_no_animation", false);
-
- deleteClonedAnimationStyleOption(styleOption);
- d->startAnimation(t);
- }
-
- QWindowsVistaAnimation *anim = qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject));
- if (anim) {
- anim->paint(painter, option);
- return;
- }
-
- }
- }
- switch (element) {
- case CE_PushButtonBevel:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option))
- {
- themeNumber = QWindowsXPStylePrivate::ButtonTheme;
- partId = BP_PUSHBUTTON;
- if (btn->features & QStyleOptionButton::CommandLinkButton)
- partId = BP_COMMANDLINK;
- bool justFlat = (btn->features & QStyleOptionButton::Flat) && !(flags & (State_On|State_Sunken));
- if (!(flags & State_Enabled) && !(btn->features & QStyleOptionButton::Flat))
- stateId = PBS_DISABLED;
- else if (justFlat)
- ;
- else if (flags & (State_Sunken | State_On))
- stateId = PBS_PRESSED;
- else if (flags & State_MouseOver)
- stateId = PBS_HOT;
- else if (btn->features & QStyleOptionButton::DefaultButton && (state & State_Active))
- stateId = PBS_DEFAULTED;
- else
- stateId = PBS_NORMAL;
-
- if (!justFlat) {
-
- if (d->transitionsEnabled() && (btn->features & QStyleOptionButton::DefaultButton) &&
- !(state & (State_Sunken | State_On)) && !(state & State_MouseOver) &&
- (state & State_Enabled) && (state & State_Active))
- {
- QWindowsVistaAnimation *anim = qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject(option)));
-
- if (!anim) {
- QImage startImage = createAnimationBuffer(option, widget);
- QImage alternateImage = createAnimationBuffer(option, widget);
-
- QWindowsVistaPulse *pulse = new QWindowsVistaPulse(styleObject(option));
-
- QPainter startPainter(&startImage);
- stateId = PBS_DEFAULTED;
- XPThemeData theme(widget, &startPainter, themeNumber, partId, stateId, rect);
- d->drawBackground(theme);
-
- QPainter alternatePainter(&alternateImage);
- theme.stateId = PBS_DEFAULTED_ANIMATING;
- theme.painter = &alternatePainter;
- d->drawBackground(theme);
- pulse->setStartImage(startImage);
- pulse->setEndImage(alternateImage);
- pulse->setStartTime(QTime::currentTime());
- pulse->setDuration(2000);
- d->startAnimation(pulse);
- anim = pulse;
- }
-
- if (anim)
- anim->paint(painter, option);
- else {
- XPThemeData theme(widget, painter, themeNumber, partId, stateId, rect);
- d->drawBackground(theme);
- }
- }
- else {
- XPThemeData theme(widget, painter, themeNumber, partId, stateId, rect);
- d->drawBackground(theme);
- }
- }
-
- if (btn->features & QStyleOptionButton::HasMenu) {
- int mbiw = 0, mbih = 0;
- XPThemeData theme(widget, 0, QWindowsXPStylePrivate::ToolBarTheme,
- TP_DROPDOWNBUTTON);
- if (theme.isValid()) {
- const QSizeF size = theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget);
- if (!size.isEmpty()) {
- mbiw = qRound(size.width());
- mbih = qRound(size.height());
- }
- }
- QRect ir = subElementRect(SE_PushButtonContents, option, 0);
- QStyleOptionButton newBtn = *btn;
- newBtn.rect = QStyle::visualRect(option->direction, option->rect,
- QRect(ir.right() - mbiw - 2,
- option->rect.top() + (option->rect.height()/2) - (mbih/2),
- mbiw + 1, mbih + 1));
- proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget);
- }
- return;
- }
- break;
-
- case CE_ProgressBarContents:
- if (const QStyleOptionProgressBar *bar
- = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
- bool isIndeterminate = (bar->minimum == 0 && bar->maximum == 0);
- const bool vertical = bar->orientation == Qt::Vertical;
- const bool inverted = bar->invertedAppearance;
-
- if (isIndeterminate || (bar->progress > 0 && (bar->progress < bar->maximum) && d->transitionsEnabled())) {
- if (!d->animation(styleObject(option)))
- d->startAnimation(new QProgressStyleAnimation(d->animationFps, styleObject(option)));
- } else {
- d->stopAnimation(styleObject(option));
- }
-
- XPThemeData theme(widget, painter,
- QWindowsXPStylePrivate::ProgressTheme,
- vertical ? PP_FILLVERT : PP_FILL);
- theme.rect = option->rect;
- bool reverse = (bar->direction == Qt::LeftToRight && inverted) || (bar->direction == Qt::RightToLeft && !inverted);
- QTime current = QTime::currentTime();
-
- if (isIndeterminate) {
- if (QProgressStyleAnimation *a = qobject_cast<QProgressStyleAnimation *>(d->animation(styleObject(option)))) {
- int glowSize = 120;
- int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width());
- int animOffset = a->startTime().msecsTo(current) / 4;
- if (animOffset > animationWidth)
- a->setStartTime(QTime::currentTime());
- painter->save();
- painter->setClipRect(theme.rect);
- QRect animRect;
- QSize pixmapSize(14, 14);
- if (vertical) {
- animRect = QRect(theme.rect.left(),
- inverted ? rect.top() - glowSize + animOffset :
- rect.bottom() + glowSize - animOffset,
- rect.width(), glowSize);
- pixmapSize.setHeight(animRect.height());
- } else {
- animRect = QRect(rect.left() - glowSize + animOffset,
- rect.top(), glowSize, rect.height());
- animRect = QStyle::visualRect(reverse ? Qt::RightToLeft : Qt::LeftToRight,
- option->rect, animRect);
- pixmapSize.setWidth(animRect.width());
- }
- QString name = QString::fromLatin1("qiprogress-%1-%2").arg(pixmapSize.width()).arg(pixmapSize.height());
- QPixmap pixmap;
- if (!QPixmapCache::find(name, pixmap)) {
- QImage image(pixmapSize, QImage::Format_ARGB32);
- image.fill(Qt::transparent);
- QPainter imagePainter(&image);
- theme.painter = &imagePainter;
- theme.partId = vertical ? PP_FILLVERT : PP_FILL;
- theme.rect = QRect(QPoint(0,0), animRect.size());
- QLinearGradient alphaGradient(0, 0, vertical ? 0 : image.width(),
- vertical ? image.height() : 0);
- alphaGradient.setColorAt(0, QColor(0, 0, 0, 0));
- alphaGradient.setColorAt(0.5, QColor(0, 0, 0, 220));
- alphaGradient.setColorAt(1, QColor(0, 0, 0, 0));
- imagePainter.fillRect(image.rect(), alphaGradient);
- imagePainter.setCompositionMode(QPainter::CompositionMode_SourceIn);
- d->drawBackground(theme);
- imagePainter.end();
- pixmap = QPixmap::fromImage(image);
- QPixmapCache::insert(name, pixmap);
- }
- painter->drawPixmap(animRect, pixmap);
- painter->restore();
- }
- }
- else {
- qint64 progress = qMax<qint64>(bar->progress, bar->minimum); // workaround for bug in QProgressBar
-
- if (vertical) {
- int maxHeight = option->rect.height();
- int minHeight = 0;
- double vc6_workaround = ((progress - qint64(bar->minimum)) / qMax(double(1.0), double(qint64(bar->maximum) - qint64(bar->minimum))) * maxHeight);
- int height = isIndeterminate ? maxHeight: qMax(int(vc6_workaround), minHeight);
- theme.rect.setHeight(height);
- if (!inverted)
- theme.rect.moveTop(rect.height() - theme.rect.height());
- } else {
- int maxWidth = option->rect.width();
- int minWidth = 0;
- double vc6_workaround = ((progress - qint64(bar->minimum)) / qMax(double(1.0), double(qint64(bar->maximum) - qint64(bar->minimum))) * maxWidth);
- int width = isIndeterminate ? maxWidth : qMax(int(vc6_workaround), minWidth);
- theme.rect.setWidth(width);
- theme.rect = QStyle::visualRect(reverse ? Qt::RightToLeft : Qt::LeftToRight,
- option->rect, theme.rect);
- }
- d->drawBackground(theme);
-
- if (QProgressStyleAnimation *a = qobject_cast<QProgressStyleAnimation *>(d->animation(styleObject(option)))) {
- int glowSize = 140;
- int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width());
- int animOffset = a->startTime().msecsTo(current) / 4;
- theme.partId = vertical ? PP_MOVEOVERLAYVERT : PP_MOVEOVERLAY;
- if (animOffset > animationWidth) {
- if (bar->progress < bar->maximum)
- a->setStartTime(QTime::currentTime());
- else
- d->stopAnimation(styleObject(option)); //we stop the glow motion only after it has
- //moved out of view
- }
- painter->save();
- painter->setClipRect(theme.rect);
- if (vertical) {
- theme.rect = QRect(theme.rect.left(),
- inverted ? rect.top() - glowSize + animOffset :
- rect.bottom() + glowSize - animOffset,
- rect.width(), glowSize);
- } else {
- theme.rect = QRect(rect.left() - glowSize + animOffset,rect.top(), glowSize, rect.height());
- theme.rect = QStyle::visualRect(reverse ? Qt::RightToLeft : Qt::LeftToRight, option->rect, theme.rect);
- }
- d->drawBackground(theme);
- painter->restore();
- }
- }
- }
- break;
-
- case CE_MenuBarItem:
- {
-
- if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option))
- {
- if (mbi->menuItemType == QStyleOptionMenuItem::DefaultItem)
- break;
-
- QPalette::ColorRole textRole = disabled ? QPalette::Text : QPalette::ButtonText;
- QPixmap pix = mbi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), QIcon::Normal);
-
- uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
- if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget))
- alignment |= Qt::TextHideMnemonic;
-
- if (widget && mbi->palette.color(QPalette::Window) != Qt::transparent) { // Not needed for QtQuick Controls
- //The rect adjustment is a workaround for the menu not really filling its background.
- XPThemeData theme(widget, painter,
- QWindowsXPStylePrivate::MenuTheme,
- MENU_BARBACKGROUND, 0, option->rect.adjusted(-1, 0, 2, 1));
- d->drawBackground(theme);
- }
-
- int stateId = MBI_NORMAL;
- if (disabled)
- stateId = MBI_DISABLED;
- else if (pressed)
- stateId = MBI_PUSHED;
- else if (selected)
- stateId = MBI_HOT;
-
- XPThemeData theme2(widget, painter,
- QWindowsXPStylePrivate::MenuTheme,
- MENU_BARITEM, stateId, option->rect);
- d->drawBackground(theme2);
-
- if (!pix.isNull())
- drawItemPixmap(painter, mbi->rect, alignment, pix);
- else
- drawItemText(painter, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled, mbi->text, textRole);
- }
- }
- break;
-#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
- const qreal factor = QWindowsXPStylePrivate::nativeMetricScaleFactor(widget);
- int checkcol = qRound(qreal(25) * factor);
- const int gutterWidth = qRound(qreal(3) * factor);
- {
- XPThemeData theme(widget, 0, QWindowsXPStylePrivate::MenuTheme,
- MENU_POPUPCHECKBACKGROUND, MBI_HOT);
- XPThemeData themeSize = theme;
- themeSize.partId = MENU_POPUPCHECK;
- themeSize.stateId = 0;
- const QSizeF size = themeSize.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget);
- const QMarginsF margins = themeSize.margins() * QWindowsStylePrivate::nativeMetricScaleFactor(widget);
- checkcol = qMax(menuitem->maxIconWidth, qRound(gutterWidth + size.width() + margins.left() + margins.right()));
- }
- QRect rect = option->rect;
-
- //draw vertical menu line
- if (option->direction == Qt::LeftToRight)
- checkcol += rect.x();
- QPoint p1 = QStyle::visualPos(option->direction, menuitem->rect, QPoint(checkcol, rect.top()));
- QPoint p2 = QStyle::visualPos(option->direction, menuitem->rect, QPoint(checkcol, rect.bottom()));
- QRect gutterRect(p1.x(), p1.y(), gutterWidth, p2.y() - p1.y() + 1);
- XPThemeData theme2(widget, painter, QWindowsXPStylePrivate::MenuTheme,
- MENU_POPUPGUTTER, stateId, gutterRect);
- d->drawBackground(theme2);
-
- int x, y, w, h;
- menuitem->rect.getRect(&x, &y, &w, &h);
- int tab = menuitem->tabWidth;
- bool dis = !(menuitem->state & State_Enabled);
- bool checked = menuitem->checkType != QStyleOptionMenuItem::NotCheckable
- ? menuitem->checked : false;
- bool act = menuitem->state & State_Selected;
-
- if (menuitem->menuItemType == QStyleOptionMenuItem::Separator) {
- int yoff = y-2 + h / 2;
- const int separatorSize = qRound(qreal(6) * QWindowsStylePrivate::nativeMetricScaleFactor(widget));
- QPoint p1 = QPoint(x + checkcol, yoff);
- QPoint p2 = QPoint(x + w + separatorSize, yoff);
- stateId = MBI_HOT;
- QRect subRect(p1.x() + (gutterWidth - menuitem->rect.x()), p1.y(),
- p2.x() - p1.x(), separatorSize);
- subRect = QStyle::visualRect(option->direction, option->rect, subRect );
- XPThemeData theme2(widget, painter,
- QWindowsXPStylePrivate::MenuTheme,
- MENU_POPUPSEPARATOR, stateId, subRect);
- d->drawBackground(theme2);
- return;
- }
-
- QRect vCheckRect = visualRect(option->direction, menuitem->rect, QRect(menuitem->rect.x(),
- menuitem->rect.y(), checkcol - (gutterWidth + menuitem->rect.x()), menuitem->rect.height()));
-
- if (act) {
- stateId = dis ? MBI_DISABLED : MBI_HOT;
- XPThemeData theme2(widget, painter,
- QWindowsXPStylePrivate::MenuTheme,
- MENU_POPUPITEM, stateId, option->rect);
- d->drawBackground(theme2);
- }
-
- if (checked) {
- XPThemeData theme(widget, painter,
- QWindowsXPStylePrivate::MenuTheme,
- MENU_POPUPCHECKBACKGROUND,
- menuitem->icon.isNull() ? MBI_HOT : MBI_PUSHED, vCheckRect);
- XPThemeData themeSize = theme;
- themeSize.partId = MENU_POPUPCHECK;
- themeSize.stateId = 0;
- const QSizeF size = themeSize.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget);
- const QMarginsF margins = themeSize.margins() * QWindowsStylePrivate::nativeMetricScaleFactor(widget);
- QRect checkRect(0, 0, qRound(size.width() + margins.left() + margins.right()),
- qRound(size.height() + margins.bottom() + margins.top()));
- checkRect.moveCenter(vCheckRect.center());
- theme.rect = checkRect;
-
- d->drawBackground(theme);
-
- if (menuitem->icon.isNull()) {
- checkRect = QRect(QPoint(0, 0), size.toSize());
- checkRect.moveCenter(theme.rect.center());
- theme.rect = checkRect;
-
- theme.partId = MENU_POPUPCHECK;
- bool bullet = menuitem->checkType & QStyleOptionMenuItem::Exclusive;
- if (dis)
- theme.stateId = bullet ? MC_BULLETDISABLED: MC_CHECKMARKDISABLED;
- else
- theme.stateId = bullet ? MC_BULLETNORMAL: MC_CHECKMARKNORMAL;
- d->drawBackground(theme);
- }
- }
-
- if (!menuitem->icon.isNull()) {
- QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
- if (act && !dis)
- mode = QIcon::Active;
- QPixmap pixmap;
- if (checked)
- pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On);
- else
- pixmap = menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode);
- const int pixw = pixmap.width() / pixmap.devicePixelRatio();
- const int pixh = pixmap.height() / pixmap.devicePixelRatio();
- QRect pmr(0, 0, pixw, pixh);
- pmr.moveCenter(vCheckRect.center());
- painter->setPen(menuitem->palette.text().color());
- painter->drawPixmap(pmr.topLeft(), pixmap);
- }
-
- painter->setPen(menuitem->palette.buttonText().color());
-
- const QColor textColor = menuitem->palette.text().color();
- if (dis)
- painter->setPen(textColor);
-
- int xm = windowsItemFrame + checkcol + windowsItemHMargin + (gutterWidth - menuitem->rect.x()) - 1;
- int xpos = menuitem->rect.x() + xm;
- QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
- QRect vTextRect = visualRect(option->direction, menuitem->rect, textRect);
- QString s = menuitem->text;
- if (!s.isEmpty()) { // draw text
- painter->save();
- int t = s.indexOf(QLatin1Char('\t'));
- int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
- if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
- text_flags |= Qt::TextHideMnemonic;
- text_flags |= Qt::AlignLeft;
- if (t >= 0) {
- QRect vShortcutRect = visualRect(option->direction, menuitem->rect,
- QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom())));
- painter->drawText(vShortcutRect, text_flags, s.mid(t + 1));
- s = s.left(t);
- }
- QFont font = menuitem->font;
- if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
- font.setBold(true);
- painter->setFont(font);
- painter->setPen(textColor);
- painter->drawText(vTextRect, text_flags, s.left(t));
- painter->restore();
- }
- if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
- int dim = (h - 2 * windowsItemFrame) / 2;
- PrimitiveElement arrow;
- arrow = (option->direction == Qt::RightToLeft) ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
- xpos = x + w - windowsArrowHMargin - windowsItemFrame - dim;
- QRect vSubMenuRect = visualRect(option->direction, menuitem->rect, QRect(xpos, y + h / 2 - dim / 2, dim, dim));
- QStyleOptionMenuItem newMI = *menuitem;
- newMI.rect = vSubMenuRect;
- newMI.state = dis ? State_None : State_Enabled;
- proxy()->drawPrimitive(arrow, &newMI, painter, widget);
- }
- }
- break;
-#endif // QT_CONFIG(menu)
- case CE_HeaderSection:
- if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
- partId = HP_HEADERITEM;
- if (flags & State_Sunken)
- stateId = HIS_PRESSED;
- else if (flags & State_MouseOver)
- stateId = HIS_HOT;
- else
- stateId = HIS_NORMAL;
-
- if (header->sortIndicator != QStyleOptionHeader::None)
- stateId += 3;
-
- XPThemeData theme(widget, painter,
- QWindowsXPStylePrivate::HeaderTheme,
- partId, stateId, option->rect);
- d->drawBackground(theme);
- }
- break;
- case CE_MenuBarEmptyArea:
- {
- stateId = MBI_NORMAL;
- if (!(state & State_Enabled))
- stateId = MBI_DISABLED;
- XPThemeData theme(widget, painter,
- QWindowsXPStylePrivate::MenuTheme,
- MENU_BARBACKGROUND, stateId, option->rect);
- d->drawBackground(theme);
- }
- break;
- case CE_ToolBar:
- if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
- QPalette pal = option->palette;
- pal.setColor(QPalette::Dark, option->palette.background().color().darker(130));
- QStyleOptionToolBar copyOpt = *toolbar;
- copyOpt.palette = pal;
- QWindowsStyle::drawControl(element, &copyOpt, painter, widget);
- }
- break;
- case CE_DockWidgetTitle:
- if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) {
- const QDockWidget *dockWidget = qobject_cast<const QDockWidget *>(widget);
- QRect rect = option->rect;
- if (dockWidget && dockWidget->isFloating()) {
- QWindowsXPStyle::drawControl(element, option, painter, widget);
- break; //otherwise fall through
- }
-
- const bool verticalTitleBar = dwOpt->verticalTitleBar;
-
- if (verticalTitleBar) {
- rect = rect.transposed();
-
- painter->translate(rect.left() - 1, rect.top() + rect.width());
- painter->rotate(-90);
- painter->translate(-rect.left() + 1, -rect.top());
- }
-
- painter->setBrush(option->palette.background().color().darker(110));
- painter->setPen(option->palette.background().color().darker(130));
- painter->drawRect(rect.adjusted(0, 1, -1, -3));
-
- int buttonMargin = 4;
- int mw = proxy()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, dwOpt, widget);
- int fw = proxy()->pixelMetric(PM_DockWidgetFrameWidth, dwOpt, widget);
- const QDockWidget *dw = qobject_cast<const QDockWidget *>(widget);
- bool isFloating = dw != 0 && dw->isFloating();
-
- QRect r = option->rect.adjusted(0, 2, -1, -3);
- QRect titleRect = r;
-
- if (dwOpt->closable) {
- QSize sz = proxy()->standardIcon(QStyle::SP_TitleBarCloseButton, dwOpt, widget).actualSize(QSize(10, 10));
- titleRect.adjust(0, 0, -sz.width() - mw - buttonMargin, 0);
- }
-
- if (dwOpt->floatable) {
- QSize sz = proxy()->standardIcon(QStyle::SP_TitleBarMaxButton, dwOpt, widget).actualSize(QSize(10, 10));
- titleRect.adjust(0, 0, -sz.width() - mw - buttonMargin, 0);
- }
-
- if (isFloating) {
- titleRect.adjust(0, -fw, 0, 0);
- if (widget != 0 && widget->windowIcon().cacheKey() != QApplication::windowIcon().cacheKey())
- titleRect.adjust(titleRect.height() + mw, 0, 0, 0);
- } else {
- titleRect.adjust(mw, 0, 0, 0);
- if (!dwOpt->floatable && !dwOpt->closable)
- titleRect.adjust(0, 0, -mw, 0);
- }
- if (!verticalTitleBar)
- titleRect = visualRect(dwOpt->direction, r, titleRect);
-
- if (!dwOpt->title.isEmpty()) {
- QString titleText = painter->fontMetrics().elidedText(dwOpt->title, Qt::ElideRight,
- verticalTitleBar ? titleRect.height() : titleRect.width());
- const int indent = 4;
- drawItemText(painter, rect.adjusted(indent + 1, 1, -indent - 1, -1),
- Qt::AlignLeft | Qt::AlignVCenter, dwOpt->palette,
- dwOpt->state & State_Enabled, titleText,
- QPalette::WindowText);
- }
- }
- break;
-#if QT_CONFIG(itemviews)
- case CE_ItemViewItem:
- {
- const QStyleOptionViewItem *vopt;
-
- const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(widget);
- bool newStyle = true;
-
- if (qobject_cast<const QTableView*>(widget))
- newStyle = false;
-
- if (newStyle && view && (vopt = qstyleoption_cast<const QStyleOptionViewItem *>(option))) {
- /*
- // We cannot currently get the correct selection color for "explorer style" views
- COLORREF cref = 0;
- XPThemeData theme(d->treeViewHelper(), 0, QLatin1String("LISTVIEW"), 0, 0);
- unsigned int res = GetThemeColor(theme.handle(), LVP_LISTITEM, LISS_SELECTED, TMT_TEXTCOLOR, &cref);
- QColor textColor(GetRValue(cref), GetGValue(cref), GetBValue(cref));
- */
- QPalette palette = vopt->palette;
- palette.setColor(QPalette::All, QPalette::HighlightedText, palette.color(QPalette::Active, QPalette::Text));
- // Note that setting a saturated color here results in ugly XOR colors in the focus rect
- palette.setColor(QPalette::All, QPalette::Highlight, palette.base().color().darker(108));
- QStyleOptionViewItem adjustedOption = *vopt;
- adjustedOption.palette = palette;
- // We hide the focusrect in singleselection as it is not required
- if ((view->selectionMode() == QAbstractItemView::SingleSelection)
- && !(vopt->state & State_KeyboardFocusChange))
- adjustedOption.state &= ~State_HasFocus;
- QWindowsXPStyle::drawControl(element, &adjustedOption, painter, widget);
- } else {
- QWindowsXPStyle::drawControl(element, option, painter, widget);
- }
- break;
- }
-#endif // QT_CONFIG(itemviews)
-#if QT_CONFIG(combobox)
- case CE_ComboBoxLabel:
- QCommonStyle::drawControl(element, option, painter, widget);
- break;
-#endif // QT_CONFIG(combobox)
- default:
- QWindowsXPStyle::drawControl(element, option, painter, widget);
- break;
- }
-}
-
-/*!
- \internal
-
- see drawPrimitive for comments on the animation support
-
- */
-void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
- QPainter *painter, const QWidget *widget) const
-{
- QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func());
- if (!QWindowsVistaStylePrivate::useVista()) {
- QWindowsStyle::drawComplexControl(control, option, painter, widget);
- return;
- }
-
- State state = option->state;
- SubControls sub = option->subControls;
- QRect r = option->rect;
-
- int partId = 0;
- int stateId = 0;
-
- State flags = option->state;
- if (widget && widget->testAttribute(Qt::WA_UnderMouse) && widget->isActiveWindow())
- flags |= State_MouseOver;
-
- if (d->transitionsEnabled() && canAnimate(option))
- {
-
- if (control == CC_ScrollBar || control == CC_SpinBox ) {
-
- QObject *styleObject = option->styleObject; // Can be widget or qquickitem
-
- int oldState = styleObject->property("_q_stylestate").toInt();
- int oldActiveControls = styleObject->property("_q_stylecontrols").toInt();
-
- QRect oldRect = styleObject->property("_q_stylerect").toRect();
- styleObject->setProperty("_q_stylestate", (int)option->state);
- styleObject->setProperty("_q_stylecontrols", (int)option->activeSubControls);
- styleObject->setProperty("_q_stylerect", option->rect);
-
- bool doTransition = ((state & State_Sunken) != (oldState & State_Sunken) ||
- (state & State_On) != (oldState & State_On) ||
- (state & State_MouseOver) != (oldState & State_MouseOver) ||
- oldActiveControls != int(option->activeSubControls));
-
- if (qstyleoption_cast<const QStyleOptionSlider *>(option)) {
- QRect oldSliderPos = styleObject->property("_q_stylesliderpos").toRect();
- QRect currentPos = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
- styleObject->setProperty("_q_stylesliderpos", currentPos);
- if (oldSliderPos != currentPos) {
- doTransition = false;
- d->stopAnimation(styleObject);
- }
- } else if (control == CC_SpinBox) {
- //spinboxes have a transition when focus changes
- if (!doTransition)
- doTransition = (state & State_HasFocus) != (oldState & State_HasFocus);
- }
-
- if (oldRect != option->rect) {
- doTransition = false;
- d->stopAnimation(styleObject);
- }
-
- if (doTransition) {
- QImage startImage = createAnimationBuffer(option, widget);
- QPainter startPainter(&startImage);
-
- QImage endImage = createAnimationBuffer(option, widget);
- QPainter endPainter(&endImage);
-
- QWindowsVistaAnimation *anim = qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject));
- QWindowsVistaTransition *t = new QWindowsVistaTransition(styleObject);
-
- // Draw the image that ends the animation by using the current styleoption
- QStyleOptionComplex *styleOption = qstyleoption_cast<QStyleOptionComplex*>(clonedAnimationStyleOption(option));
-
- styleObject->setProperty("_q_no_animation", true);
-
- // Draw transition source
- if (!anim) {
- styleOption->state = (QStyle::State)oldState;
- styleOption->activeSubControls = (QStyle::SubControl)oldActiveControls;
- proxy()->drawComplexControl(control, styleOption, &startPainter, widget);
- } else {
- anim->paint(&startPainter, option);
- }
- t->setStartImage(startImage);
-
- // Draw transition target
- styleOption->state = option->state;
- styleOption->activeSubControls = option->activeSubControls;
- proxy()->drawComplexControl(control, styleOption, &endPainter, widget);
-
- styleObject->setProperty("_q_no_animation", false);
-
- t->setEndImage(endImage);
- t->setStartTime(QTime::currentTime());
-
- if (option->state & State_MouseOver || option->state & State_Sunken)
- t->setDuration(150);
- else
- t->setDuration(500);
-
- deleteClonedAnimationStyleOption(styleOption);
- d->startAnimation(t);
- }
- if (QWindowsVistaAnimation *anim = qobject_cast<QWindowsVistaAnimation *>(d->animation(styleObject))) {
- anim->paint(painter, option);
- return;
- }
- }
- }
-
- switch (control) {
- case CC_ComboBox:
- if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option))
- {
- if (cmb->editable) {
- if (sub & SC_ComboBoxEditField) {
- partId = EP_EDITBORDER_NOSCROLL;
- if (!(flags & State_Enabled))
- stateId = ETS_DISABLED;
- else if (flags & State_MouseOver)
- stateId = ETS_HOT;
- else if (flags & State_HasFocus)
- stateId = ETS_FOCUSED;
- else
- stateId = ETS_NORMAL;
-
- XPThemeData theme(widget, painter,
- QWindowsXPStylePrivate::EditTheme,
- partId, stateId, r);
-
- d->drawBackground(theme);
- }
- if (sub & SC_ComboBoxArrow) {
- QRect subRect = proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxArrow, widget);
- XPThemeData theme(widget, painter, QWindowsXPStylePrivate::ComboboxTheme);
- theme.rect = subRect;
- partId = option->direction == Qt::RightToLeft ? CP_DROPDOWNBUTTONLEFT : CP_DROPDOWNBUTTONRIGHT;
-
- if (!(cmb->state & State_Enabled))
- stateId = CBXS_DISABLED;
- else if (cmb->state & State_Sunken || cmb->state & State_On)
- stateId = CBXS_PRESSED;
- else if (cmb->state & State_MouseOver && option->activeSubControls & SC_ComboBoxArrow)
- stateId = CBXS_HOT;
- else
- stateId = CBXS_NORMAL;
-
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
-
- } else {
- if (sub & SC_ComboBoxFrame) {
- QStyleOptionButton btn;
- btn.QStyleOption::operator=(*option);
- btn.rect = option->rect.adjusted(-1, -1, 1, 1);
- if (sub & SC_ComboBoxArrow)
- btn.features = QStyleOptionButton::HasMenu;
- proxy()->drawControl(QStyle::CE_PushButton, &btn, painter, widget);
- }
- }
- }
- break;
- case CC_ScrollBar:
- if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(option))
- {
- XPThemeData theme(widget, painter, QWindowsXPStylePrivate::ScrollBarTheme);
- bool maxedOut = (scrollbar->maximum == scrollbar->minimum);
- if (maxedOut)
- flags &= ~State_Enabled;
-
- bool isHorz = flags & State_Horizontal;
- bool isRTL = option->direction == Qt::RightToLeft;
- if (sub & SC_ScrollBarAddLine) {
- theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddLine, widget);
- partId = SBP_ARROWBTN;
- if (!(flags & State_Enabled))
- stateId = (isHorz ? (isRTL ? ABS_LEFTDISABLED : ABS_RIGHTDISABLED) : ABS_DOWNDISABLED);
- else if (scrollbar->activeSubControls & SC_ScrollBarAddLine && (scrollbar->state & State_Sunken))
- stateId = (isHorz ? (isRTL ? ABS_LEFTPRESSED : ABS_RIGHTPRESSED) : ABS_DOWNPRESSED);
- else if (scrollbar->activeSubControls & SC_ScrollBarAddLine && (scrollbar->state & State_MouseOver))
- stateId = (isHorz ? (isRTL ? ABS_LEFTHOT : ABS_RIGHTHOT) : ABS_DOWNHOT);
- else if (scrollbar->state & State_MouseOver)
- stateId = (isHorz ? (isRTL ? ABS_LEFTHOVER : ABS_RIGHTHOVER) : ABS_DOWNHOVER);
- else
- stateId = (isHorz ? (isRTL ? ABS_LEFTNORMAL : ABS_RIGHTNORMAL) : ABS_DOWNNORMAL);
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
- if (sub & SC_ScrollBarSubLine) {
- theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubLine, widget);
- partId = SBP_ARROWBTN;
- if (!(flags & State_Enabled))
- stateId = (isHorz ? (isRTL ? ABS_RIGHTDISABLED : ABS_LEFTDISABLED) : ABS_UPDISABLED);
- else if (scrollbar->activeSubControls & SC_ScrollBarSubLine && (scrollbar->state & State_Sunken))
- stateId = (isHorz ? (isRTL ? ABS_RIGHTPRESSED : ABS_LEFTPRESSED) : ABS_UPPRESSED);
- else if (scrollbar->activeSubControls & SC_ScrollBarSubLine && (scrollbar->state & State_MouseOver))
- stateId = (isHorz ? (isRTL ? ABS_RIGHTHOT : ABS_LEFTHOT) : ABS_UPHOT);
- else if (scrollbar->state & State_MouseOver)
- stateId = (isHorz ? (isRTL ? ABS_RIGHTHOVER : ABS_LEFTHOVER) : ABS_UPHOVER);
- else
- stateId = (isHorz ? (isRTL ? ABS_RIGHTNORMAL : ABS_LEFTNORMAL) : ABS_UPNORMAL);
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
- if (maxedOut) {
- theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
- theme.rect = theme.rect.united(proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget));
- theme.rect = theme.rect.united(proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget));
- partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
- stateId = SCRBS_DISABLED;
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- } else {
- if (sub & SC_ScrollBarSubPage) {
- theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget);
- partId = flags & State_Horizontal ? SBP_UPPERTRACKHORZ : SBP_UPPERTRACKVERT;
- if (!(flags & State_Enabled))
- stateId = SCRBS_DISABLED;
- else if (scrollbar->activeSubControls & SC_ScrollBarSubPage && (scrollbar->state & State_Sunken))
- stateId = SCRBS_PRESSED;
- else if (scrollbar->activeSubControls & SC_ScrollBarSubPage && (scrollbar->state & State_MouseOver))
- stateId = SCRBS_HOT;
- else
- stateId = SCRBS_NORMAL;
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
- if (sub & SC_ScrollBarAddPage) {
- theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget);
- partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
- if (!(flags & State_Enabled))
- stateId = SCRBS_DISABLED;
- else if (scrollbar->activeSubControls & SC_ScrollBarAddPage && (scrollbar->state & State_Sunken))
- stateId = SCRBS_PRESSED;
- else if (scrollbar->activeSubControls & SC_ScrollBarAddPage && (scrollbar->state & State_MouseOver))
- stateId = SCRBS_HOT;
- else
- stateId = SCRBS_NORMAL;
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
- if (sub & SC_ScrollBarSlider) {
- theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
- if (!(flags & State_Enabled))
- stateId = SCRBS_DISABLED;
- else if (scrollbar->activeSubControls & SC_ScrollBarSlider && (scrollbar->state & State_Sunken))
- stateId = SCRBS_PRESSED;
- else if (scrollbar->activeSubControls & SC_ScrollBarSlider && (scrollbar->state & State_MouseOver))
- stateId = SCRBS_HOT;
- else if (option->state & State_MouseOver)
- stateId = SCRBS_HOVER;
- else
- stateId = SCRBS_NORMAL;
-
- // Draw handle
- theme.partId = flags & State_Horizontal ? SBP_THUMBBTNHORZ : SBP_THUMBBTNVERT;
- theme.stateId = stateId;
- d->drawBackground(theme);
-
- if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows8) {
- const QRect gripperBounds = QWindowsXPStylePrivate::scrollBarGripperBounds(flags, widget, &theme);
- // Draw gripper if there is enough space
- if (!gripperBounds.isEmpty() && flags & State_Enabled) {
- painter->save();
- XPThemeData grippBackground = theme;
- grippBackground.partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
- theme.rect = gripperBounds;
- painter->setClipRegion(d->region(theme));// Only change inside the region of the gripper
- d->drawBackground(grippBackground);// The gutter is the grippers background
- d->drawBackground(theme); // Transparent gripper ontop of background
- painter->restore();
- }
- }
- }
- }
- }
- break;
-#if QT_CONFIG(spinbox)
- case CC_SpinBox:
- if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(option))
- {
- XPThemeData theme(widget, painter, QWindowsXPStylePrivate::SpinTheme);
- if (sb->frame && (sub & SC_SpinBoxFrame)) {
- partId = EP_EDITBORDER_NOSCROLL;
- if (!(flags & State_Enabled))
- stateId = ETS_DISABLED;
- else if (flags & State_MouseOver)
- stateId = ETS_HOT;
- else if (flags & State_HasFocus)
- stateId = ETS_SELECTED;
- else
- stateId = ETS_NORMAL;
-
- XPThemeData ftheme(widget, painter,
- QWindowsXPStylePrivate::EditTheme,
- partId, stateId, r);
- // The spinbox in Windows QStyle is drawn with frameless QLineEdit inside it
- // That however breaks with QtQuickControls where this results in transparent
- // spinbox background, so if there's no "widget" passed (QtQuickControls case),
- // let ftheme.noContent be false, which fixes the spinbox rendering in QQC
- ftheme.noContent = (widget != NULL);
- d->drawBackground(ftheme);
- }
- if (sub & SC_SpinBoxUp) {
- theme.rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget).adjusted(0, 0, 0, 1);
- partId = SPNP_UP;
- if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled) || !(flags & State_Enabled))
- stateId = UPS_DISABLED;
- else if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken))
- stateId = UPS_PRESSED;
- else if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_MouseOver))
- stateId = UPS_HOT;
- else
- stateId = UPS_NORMAL;
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
- if (sub & SC_SpinBoxDown) {
- theme.rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);
- partId = SPNP_DOWN;
- if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled) || !(flags & State_Enabled))
- stateId = DNS_DISABLED;
- else if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken))
- stateId = DNS_PRESSED;
- else if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_MouseOver))
- stateId = DNS_HOT;
- else
- stateId = DNS_NORMAL;
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
- }
- break;
-#endif // QT_CONFIG(spinbox)
- default:
- QWindowsXPStyle::drawComplexControl(control, option, painter, widget);
- break;
- }
-}
-
-/*!
- \internal
- */
-QSize QWindowsVistaStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
- const QSize &size, const QWidget *widget) const
-{
- if (!QWindowsVistaStylePrivate::useVista())
- return QWindowsStyle::sizeFromContents(type, option, size, widget);
-
- QSize sz(size);
- switch (type) {
- case CT_MenuItem:
- sz = QWindowsXPStyle::sizeFromContents(type, option, size, widget);
- int minimumHeight;
- {
- XPThemeData theme(widget, 0,
- QWindowsXPStylePrivate::MenuTheme,
- MENU_POPUPCHECKBACKGROUND, MBI_HOT);
- XPThemeData themeSize = theme;
- themeSize.partId = MENU_POPUPCHECK;
- themeSize.stateId = 0;
- const QSizeF size = themeSize.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget);
- const QMarginsF margins = themeSize.margins() * QWindowsStylePrivate::nativeMetricScaleFactor(widget);
- minimumHeight = qMax(qRound(size.height() + margins.bottom() + margins.top()), sz.height());
- sz.rwidth() += qRound(size.width() + margins.left() + margins.right());
- }
-
- if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
- if (menuitem->menuItemType != QStyleOptionMenuItem::Separator)
- sz.setHeight(minimumHeight);
- }
- return sz;
-#if QT_CONFIG(menubar)
- case CT_MenuBarItem:
- if (!sz.isEmpty())
- sz += QSize(windowsItemHMargin * 5 + 1, 5);
- return sz;
-#endif
- case CT_ItemViewItem:
- sz = QWindowsXPStyle::sizeFromContents(type, option, size, widget);
- sz.rheight() += 2;
- return sz;
- case CT_SpinBox:
- {
- //Spinbox adds frame twice
- sz = QWindowsStyle::sizeFromContents(type, option, size, widget);
- int border = proxy()->pixelMetric(PM_SpinBoxFrameWidth, option, widget);
- sz -= QSize(2*border, 2*border);
- }
- return sz;
- case CT_HeaderSection:
- {
- // When there is a sort indicator it adds to the width but it is shown
- // above the text natively and not on the side
- if (QStyleOptionHeader *hdr = qstyleoption_cast<QStyleOptionHeader *>(const_cast<QStyleOption *>(option))) {
- QStyleOptionHeader::SortIndicator sortInd = hdr->sortIndicator;
- hdr->sortIndicator = QStyleOptionHeader::None;
- sz = QWindowsXPStyle::sizeFromContents(type, hdr, size, widget);
- hdr->sortIndicator = sortInd;
- return sz;
- }
- break;
- }
- default:
- break;
- }
- return QWindowsXPStyle::sizeFromContents(type, option, size, widget);
-}
-
-/*!
- \internal
- */
-QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
-{
- if (!QWindowsVistaStylePrivate::useVista())
- return QWindowsStyle::subElementRect(element, option, widget);
-
- QRect rect = QWindowsXPStyle::subElementRect(element, option, widget);
- switch (element) {
-
- case SE_PushButtonContents:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- MARGINS borderSize;
- const HTHEME theme = OpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"Button");
- if (theme) {
- int stateId = PBS_NORMAL;
- if (!(option->state & State_Enabled))
- stateId = PBS_DISABLED;
- else if (option->state & State_Sunken)
- stateId = PBS_PRESSED;
- else if (option->state & State_MouseOver)
- stateId = PBS_HOT;
- else if (btn->features & QStyleOptionButton::DefaultButton)
- stateId = PBS_DEFAULTED;
-
- int border = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget);
- rect = option->rect.adjusted(border, border, -border, -border);
-
- if (SUCCEEDED(GetThemeMargins(theme, NULL, BP_PUSHBUTTON, stateId, TMT_CONTENTMARGINS, NULL, &borderSize))) {
- rect.adjust(borderSize.cxLeftWidth, borderSize.cyTopHeight,
- -borderSize.cxRightWidth, -borderSize.cyBottomHeight);
- rect = visualRect(option->direction, option->rect, rect);
- }
- }
- }
- break;
-
- case SE_HeaderArrow:
- {
- QRect r = rect;
- int h = option->rect.height();
- int w = option->rect.width();
- int x = option->rect.x();
- int y = option->rect.y();
- int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, option, widget);
-
- XPThemeData theme(widget, 0,
- QWindowsXPStylePrivate::HeaderTheme,
- HP_HEADERSORTARROW, HSAS_SORTEDDOWN, option->rect);
-
- int arrowWidth = 13;
- int arrowHeight = 5;
- if (theme.isValid()) {
- const QSizeF size = theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget);
- if (!size.isEmpty()) {
- arrowWidth = qRound(size.width());
- arrowHeight = qRound(size.height());
- }
- }
- if (option->state & State_Horizontal) {
- r.setRect(x + w/2 - arrowWidth/2, y , arrowWidth, arrowHeight);
- } else {
- int vert_size = w / 2;
- r.setRect(x + 5, y + h - margin * 2 - vert_size,
- w - margin * 2 - 5, vert_size);
- }
- rect = visualRect(option->direction, option->rect, r);
- }
- break;
-
- case SE_HeaderLabel:
- {
- int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, option, widget);
- QRect r = option->rect;
- r.setRect(option->rect.x() + margin, option->rect.y() + margin,
- option->rect.width() - margin * 2, option->rect.height() - margin * 2);
- if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
- // Subtract width needed for arrow, if there is one
- if (header->sortIndicator != QStyleOptionHeader::None) {
- if (!(option->state & State_Horizontal)) //horizontal arrows are positioned on top
- r.setHeight(r.height() - (option->rect.width() / 2) - (margin * 2));
- }
- }
- rect = visualRect(option->direction, option->rect, r);
- }
- break;
- case SE_ProgressBarContents:
- rect = QCommonStyle::subElementRect(SE_ProgressBarGroove, option, widget);
- break;
- case SE_ItemViewItemDecoration:
- if (qstyleoption_cast<const QStyleOptionViewItem *>(option))
- rect.adjust(-2, 0, 2, 0);
- break;
- case SE_ItemViewItemFocusRect:
- if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(option)) {
- QRect textRect = subElementRect(QStyle::SE_ItemViewItemText, option, widget);
- QRect displayRect = subElementRect(QStyle::SE_ItemViewItemDecoration, option, widget);
- if (!vopt->icon.isNull())
- rect = textRect.united(displayRect);
- else
- rect = textRect;
- rect = rect.adjusted(1, 0, -1, 0);
- }
- break;
- default:
- break;
- }
- return rect;
-}
-
-
-/*
- This function is used by subControlRect to check if a button
- should be drawn for the given subControl given a set of window flags.
-*/
-static bool buttonVisible(const QStyle::SubControl sc, const QStyleOptionTitleBar *tb){
-
- bool isMinimized = tb->titleBarState & Qt::WindowMinimized;
- bool isMaximized = tb->titleBarState & Qt::WindowMaximized;
- const uint flags = tb->titleBarFlags;
- bool retVal = false;
- switch (sc) {
- case QStyle::SC_TitleBarContextHelpButton:
- if (flags & Qt::WindowContextHelpButtonHint)
- retVal = true;
- break;
- case QStyle::SC_TitleBarMinButton:
- if (!isMinimized && (flags & Qt::WindowMinimizeButtonHint))
- retVal = true;
- break;
- case QStyle::SC_TitleBarNormalButton:
- if (isMinimized && (flags & Qt::WindowMinimizeButtonHint))
- retVal = true;
- else if (isMaximized && (flags & Qt::WindowMaximizeButtonHint))
- retVal = true;
- break;
- case QStyle::SC_TitleBarMaxButton:
- if (!isMaximized && (flags & Qt::WindowMaximizeButtonHint))
- retVal = true;
- break;
- case QStyle::SC_TitleBarShadeButton:
- if (!isMinimized && flags & Qt::WindowShadeButtonHint)
- retVal = true;
- break;
- case QStyle::SC_TitleBarUnshadeButton:
- if (isMinimized && flags & Qt::WindowShadeButtonHint)
- retVal = true;
- break;
- case QStyle::SC_TitleBarCloseButton:
- if (flags & Qt::WindowSystemMenuHint)
- retVal = true;
- break;
- case QStyle::SC_TitleBarSysMenu:
- if (flags & Qt::WindowSystemMenuHint)
- retVal = true;
- break;
- default :
- retVal = true;
- }
- return retVal;
-}
-
-
-/*! \internal */
-int QWindowsVistaStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget,
- QStyleHintReturn *returnData) const
-{
- QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate*>(d_func());
- int ret = 0;
- switch (hint) {
- case SH_MessageBox_CenterButtons:
- ret = false;
- break;
- case SH_ToolTip_Mask:
- if (option) {
- if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(returnData)) {
- ret = true;
- XPThemeData themeData(widget, 0,
- QWindowsXPStylePrivate::ToolTipTheme,
- TTP_STANDARD, TTSS_NORMAL, option->rect);
- mask->region = d->region(themeData);
- }
- }
- break;
- case SH_Table_GridLineColor:
- if (option)
- ret = option->palette.color(QPalette::Base).darker(118).rgb();
- else
- ret = -1;
- break;
- case SH_Header_ArrowAlignment:
- ret = Qt::AlignTop | Qt::AlignHCenter;
- break;
- default:
- ret = QWindowsXPStyle::styleHint(hint, option, widget, returnData);
- break;
- }
- return ret;
-}
-
-
-/*!
- \internal
- */
-QRect QWindowsVistaStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option,
- SubControl subControl, const QWidget *widget) const
-{
- if (!QWindowsVistaStylePrivate::useVista())
- return QWindowsStyle::subControlRect(control, option, subControl, widget);
-
- QRect rect = QWindowsXPStyle::subControlRect(control, option, subControl, widget);
- switch (control) {
-#if QT_CONFIG(combobox)
- case CC_ComboBox:
- if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
- int x = cb->rect.x(),
- y = cb->rect.y(),
- wi = cb->rect.width(),
- he = cb->rect.height();
- int xpos = x;
- int margin = cb->frame ? 3 : 0;
- int bmarg = cb->frame ? 2 : 0;
- int arrowButtonWidth = bmarg + 16;
- xpos += wi - arrowButtonWidth;
-
- switch (subControl) {
- case SC_ComboBoxFrame:
- rect = cb->rect;
- break;
- case SC_ComboBoxArrow:
- rect.setRect(xpos, y , arrowButtonWidth, he);
- break;
- case SC_ComboBoxEditField:
- rect.setRect(x + margin, y + margin, wi - 2 * margin - 16, he - 2 * margin);
- break;
- case SC_ComboBoxListBoxPopup:
- rect = cb->rect;
- break;
- default:
- break;
- }
- rect = visualRect(cb->direction, cb->rect, rect);
- return rect;
- }
- break;
-#endif // QT_CONFIG(combobox)
- case CC_TitleBar:
- if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) {
- if (!buttonVisible(subControl, tb))
- return rect;
- const bool isToolTitle = false;
- const int height = tb->rect.height();
- const int width = tb->rect.width();
- const int buttonWidth =
- qRound(qreal(GetSystemMetrics(SM_CXSIZE)) * QWindowsStylePrivate::nativeMetricScaleFactor(widget)
- - QStyleHelper::dpiScaled(4));
-
- const int frameWidth = proxy()->pixelMetric(PM_MdiSubWindowFrameWidth, option, widget);
- const bool sysmenuHint = (tb->titleBarFlags & Qt::WindowSystemMenuHint) != 0;
- const bool minimizeHint = (tb->titleBarFlags & Qt::WindowMinimizeButtonHint) != 0;
- const bool maximizeHint = (tb->titleBarFlags & Qt::WindowMaximizeButtonHint) != 0;
- const bool contextHint = (tb->titleBarFlags & Qt::WindowContextHelpButtonHint) != 0;
- const bool shadeHint = (tb->titleBarFlags & Qt::WindowShadeButtonHint) != 0;
-
- switch (subControl) {
- case SC_TitleBarLabel:
- rect = QRect(frameWidth, 0, width - (buttonWidth + frameWidth + 10), height);
- if (isToolTitle) {
- if (sysmenuHint) {
- rect.adjust(0, 0, -buttonWidth - 3, 0);
- }
- if (minimizeHint || maximizeHint)
- rect.adjust(0, 0, -buttonWidth - 2, 0);
- } else {
- if (sysmenuHint) {
- const int leftOffset = height - 8;
- rect.adjust(leftOffset, 0, 0, 4);
- }
- if (minimizeHint)
- rect.adjust(0, 0, -buttonWidth - 2, 0);
- if (maximizeHint)
- rect.adjust(0, 0, -buttonWidth - 2, 0);
- if (contextHint)
- rect.adjust(0, 0, -buttonWidth - 2, 0);
- if (shadeHint)
- rect.adjust(0, 0, -buttonWidth - 2, 0);
- }
- rect.translate(0, 2);
- rect = visualRect(option->direction, option->rect, rect);
- break;
- case SC_TitleBarSysMenu:
- {
- const int controlTop = 6;
- const int controlHeight = height - controlTop - 3;
- int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
- QSize iconSize = tb->icon.actualSize(QSize(iconExtent, iconExtent));
- if (tb->icon.isNull())
- iconSize = QSize(controlHeight, controlHeight);
- int hPad = (controlHeight - iconSize.height())/2;
- int vPad = (controlHeight - iconSize.width())/2;
- rect = QRect(frameWidth + hPad, controlTop + vPad, iconSize.width(), iconSize.height());
- rect.translate(0, 3);
- rect = visualRect(option->direction, option->rect, rect);
- }
- break;
- default:
- break;
- }
- }
- break;
- default:
- break;
- }
- return rect;
-}
-
-/*!
- \internal
- */
-QStyle::SubControl QWindowsVistaStyle::hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option,
- const QPoint &pos, const QWidget *widget) const
-{
- if (!QWindowsVistaStylePrivate::useVista()) {
- return QWindowsStyle::hitTestComplexControl(control, option, pos, widget);
- }
- return QWindowsXPStyle::hitTestComplexControl(control, option, pos, widget);
-}
-
-int QWindowsVistaStylePrivate::fixedPixelMetric(QStyle::PixelMetric pm)
-{
- switch (pm) {
- case QStyle::PM_DockWidgetTitleBarButtonMargin:
- return 5;
- case QStyle::PM_ScrollBarSliderMin:
- return 18;
- case QStyle::PM_MenuHMargin:
- case QStyle::PM_MenuVMargin:
- return 0;
- case QStyle::PM_MenuPanelWidth:
- return 3;
- default:
- break;
- }
- return QWindowsVistaStylePrivate::InvalidMetric;
-}
-
-/*!
- \internal
- */
-int QWindowsVistaStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const
-{
- if (!QWindowsVistaStylePrivate::useVista())
- return QWindowsStyle::pixelMetric(metric, option, widget);
-
- int ret = QWindowsVistaStylePrivate::fixedPixelMetric(metric);
- if (ret != QWindowsStylePrivate::InvalidMetric)
- return int(QStyleHelper::dpiScaled(ret));
-
- return QWindowsXPStyle::pixelMetric(metric, option, widget);
-}
-
-/*!
- \internal
- */
-QPalette QWindowsVistaStyle::standardPalette() const
-{
- return QWindowsXPStyle::standardPalette();
-}
-
-/*!
- \internal
- */
-void QWindowsVistaStyle::polish(QApplication *app)
-{
- QWindowsXPStyle::polish(app);
-}
-
-/*!
- \internal
- */
-void QWindowsVistaStyle::polish(QWidget *widget)
-{
- QWindowsXPStyle::polish(widget);
-#if QT_CONFIG(lineedit)
- if (qobject_cast<QLineEdit*>(widget))
- widget->setAttribute(Qt::WA_Hover);
- else
-#endif // QT_CONFIG(lineedit)
- if (qobject_cast<QGroupBox*>(widget))
- widget->setAttribute(Qt::WA_Hover);
- else if (qobject_cast<QCommandLinkButton*>(widget)) {
- QFont buttonFont = widget->font();
- buttonFont.setFamily(QLatin1String("Segoe UI"));
- widget->setFont(buttonFont);
- }
- else if (widget->inherits("QTipLabel")){
- //note that since tooltips are not reused
- //we do not have to care about unpolishing
- widget->setContentsMargins(3, 0, 4, 0);
- COLORREF bgRef;
- HTHEME theme = OpenThemeData(widget ? QWindowsVistaStylePrivate::winId(widget) : 0, L"TOOLTIP");
- if (theme && SUCCEEDED(GetThemeColor(theme, TTP_STANDARD, TTSS_NORMAL, TMT_TEXTCOLOR, &bgRef))) {
- QColor textColor = QColor::fromRgb(bgRef);
- QPalette pal;
- pal.setColor(QPalette::All, QPalette::ToolTipText, textColor);
- widget->setPalette(pal);
- }
- } else if (qobject_cast<QMessageBox *> (widget)) {
- widget->setAttribute(Qt::WA_StyledBackground);
-#if QT_CONFIG(dialogbuttonbox)
- QDialogButtonBox *buttonBox = widget->findChild<QDialogButtonBox *>(QLatin1String("qt_msgbox_buttonbox"));
- if (buttonBox)
- buttonBox->setContentsMargins(0, 9, 0, 0);
-#endif
- }
-#if QT_CONFIG(inputdialog)
- else if (qobject_cast<QInputDialog *> (widget)) {
- widget->setAttribute(Qt::WA_StyledBackground);
-#if QT_CONFIG(dialogbuttonbox)
- QDialogButtonBox *buttonBox = widget->findChild<QDialogButtonBox *>(QLatin1String("qt_inputdlg_buttonbox"));
- if (buttonBox)
- buttonBox->setContentsMargins(0, 9, 0, 0);
-#endif
- }
-#endif // QT_CONFIG(inputdialog)
- else if (QTreeView *tree = qobject_cast<QTreeView *> (widget)) {
- tree->viewport()->setAttribute(Qt::WA_Hover);
- }
- else if (QListView *list = qobject_cast<QListView *> (widget)) {
- list->viewport()->setAttribute(Qt::WA_Hover);
- }
-}
-
-/*!
- \internal
- */
-void QWindowsVistaStyle::unpolish(QWidget *widget)
-{
- QWindowsXPStyle::unpolish(widget);
-
- QWindowsVistaStylePrivate *d = d_func();
-
- d->stopAnimation(widget);
-
-#if QT_CONFIG(lineedit)
- if (qobject_cast<QLineEdit*>(widget))
- widget->setAttribute(Qt::WA_Hover, false);
- else
-#endif // QT_CONFIG(lineedit)
- if (qobject_cast<QGroupBox*>(widget))
- widget->setAttribute(Qt::WA_Hover, false);
- else if (qobject_cast<QMessageBox *> (widget)) {
- widget->setAttribute(Qt::WA_StyledBackground, false);
-#if QT_CONFIG(dialogbuttonbox)
- QDialogButtonBox *buttonBox = widget->findChild<QDialogButtonBox *>(QLatin1String("qt_msgbox_buttonbox"));
- if (buttonBox)
- buttonBox->setContentsMargins(0, 0, 0, 0);
-#endif
- }
-#if QT_CONFIG(inputdialog)
- else if (qobject_cast<QInputDialog *> (widget)) {
- widget->setAttribute(Qt::WA_StyledBackground, false);
-#if QT_CONFIG(dialogbuttonbox)
- QDialogButtonBox *buttonBox = widget->findChild<QDialogButtonBox *>(QLatin1String("qt_inputdlg_buttonbox"));
- if (buttonBox)
- buttonBox->setContentsMargins(0, 0, 0, 0);
-#endif
- }
-#endif // QT_CONFIG(inputdialog)
- else if (QTreeView *tree = qobject_cast<QTreeView *> (widget)) {
- tree->viewport()->setAttribute(Qt::WA_Hover, false);
- } else if (qobject_cast<QCommandLinkButton*>(widget)) {
- QFont font = QApplication::font("QCommandLinkButton");
- QFont widgetFont = widget->font();
- widgetFont.setFamily(font.family()); //Only family set by polish
- widget->setFont(widgetFont);
- }
-}
-
-
-/*!
- \internal
- */
-void QWindowsVistaStyle::unpolish(QApplication *app)
-{
- QWindowsXPStyle::unpolish(app);
-}
-
-/*!
- \internal
- */
-void QWindowsVistaStyle::polish(QPalette &pal)
-{
- QWindowsStyle::polish(pal);
- pal.setBrush(QPalette::AlternateBase, pal.base().color().darker(104));
-}
-
-/*!
- \internal
- */
-QPixmap QWindowsVistaStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option,
- const QWidget *widget) const
-{
- if (!QWindowsVistaStylePrivate::useVista()) {
- return QWindowsStyle::standardPixmap(standardPixmap, option, widget);
- }
- return QWindowsXPStyle::standardPixmap(standardPixmap, option, widget);
-}
-
-QWindowsVistaStylePrivate::QWindowsVistaStylePrivate() :
- QWindowsXPStylePrivate()
-{
-}
-
-bool QWindowsVistaStylePrivate::transitionsEnabled() const
-{
- BOOL animEnabled = false;
- if (SystemParametersInfo(SPI_GETCLIENTAREAANIMATION, 0, &animEnabled, 0))
- {
- if (animEnabled)
- return true;
- }
- return false;
-}
-
-/*!
-\reimp
-*/
-QIcon QWindowsVistaStyle::standardIcon(StandardPixmap standardIcon,
- const QStyleOption *option,
- const QWidget *widget) const
-{
- if (!QWindowsVistaStylePrivate::useVista()) {
- return QWindowsStyle::standardIcon(standardIcon, option, widget);
- }
-
- QWindowsVistaStylePrivate *d = const_cast<QWindowsVistaStylePrivate *>(d_func());
- switch(standardIcon) {
- case SP_CommandLink:
- {
- XPThemeData theme(0, 0,
- QWindowsXPStylePrivate::ButtonTheme,
- BP_COMMANDLINKGLYPH, CMDLGS_NORMAL);
- if (theme.isValid()) {
- const QSize size = (theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize();
- QIcon linkGlyph;
- QPixmap pm(size);
- pm.fill(Qt::transparent);
- QPainter p(&pm);
- theme.painter = &p;
- theme.rect = QRect(QPoint(0, 0), size);
- d->drawBackground(theme);
- linkGlyph.addPixmap(pm, QIcon::Normal, QIcon::Off); // Normal
- pm.fill(Qt::transparent);
-
- theme.stateId = CMDLGS_PRESSED;
- d->drawBackground(theme);
- linkGlyph.addPixmap(pm, QIcon::Normal, QIcon::On); // Pressed
- pm.fill(Qt::transparent);
-
- theme.stateId = CMDLGS_HOT;
- d->drawBackground(theme);
- linkGlyph.addPixmap(pm, QIcon::Active, QIcon::Off); // Hover
- pm.fill(Qt::transparent);
-
- theme.stateId = CMDLGS_DISABLED;
- d->drawBackground(theme);
- linkGlyph.addPixmap(pm, QIcon::Disabled, QIcon::Off); // Disabled
- return linkGlyph;
- }
- }
- break;
- default:
- break;
- }
- return QWindowsXPStyle::standardIcon(standardIcon, option, widget);
-}
-
-QT_END_NAMESPACE
-
-#endif //QT_NO_WINDOWSVISTA
diff --git a/src/widgets/styles/qwindowsvistastyle_p.h b/src/widgets/styles/qwindowsvistastyle_p.h
deleted file mode 100644
index 8fbd1dc380..0000000000
--- a/src/widgets/styles/qwindowsvistastyle_p.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSVISTASTYLE_P_H
-#define QWINDOWSVISTASTYLE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtWidgets/private/qtwidgetsglobal_p.h>
-#include <private/qwindowsxpstyle_p.h>
-
-QT_BEGIN_NAMESPACE
-
-
-#if QT_CONFIG(style_windowsvista)
-
-class QWindowsVistaStylePrivate;
-class QWindowsVistaStyle : public QWindowsXPStyle
-{
- Q_OBJECT
-public:
- QWindowsVistaStyle();
- ~QWindowsVistaStyle();
-
- void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
- QPainter *painter, const QWidget *widget = 0) const;
- void drawControl(ControlElement element, const QStyleOption *option,
- QPainter *painter, const QWidget *widget) const;
- void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
- QPainter *painter, const QWidget *widget) const;
- QSize sizeFromContents(ContentsType type, const QStyleOption *option,
- const QSize &size, const QWidget *widget) const;
-
- QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const;
- QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
- SubControl sc, const QWidget *widget) const;
-
- SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option,
- const QPoint &pos, const QWidget *widget = 0) const;
-
- QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0,
- const QWidget *widget = 0) const;
- QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
- const QWidget *widget = 0) const;
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
- int styleHint(StyleHint hint, const QStyleOption *opt = 0, const QWidget *widget = 0,
- QStyleHintReturn *returnData = 0) const;
-
- void polish(QWidget *widget);
- void unpolish(QWidget *widget);
- void polish(QPalette &pal);
- void polish(QApplication *app);
- void unpolish(QApplication *app);
- QPalette standardPalette() const;
-
-private:
- Q_DISABLE_COPY(QWindowsVistaStyle)
- Q_DECLARE_PRIVATE(QWindowsVistaStyle)
- friend class QStyleFactory;
-};
-#endif // style_windowsvista
-
-QT_END_NAMESPACE
-
-#endif // QWINDOWSVISTASTYLE_P_H
diff --git a/src/widgets/styles/qwindowsvistastyle_p_p.h b/src/widgets/styles/qwindowsvistastyle_p_p.h
deleted file mode 100644
index 6e22f97cf4..0000000000
--- a/src/widgets/styles/qwindowsvistastyle_p_p.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSVISTASTYLE_P_P_H
-#define QWINDOWSVISTASTYLE_P_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
-// file may change from version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtWidgets/private/qtwidgetsglobal_p.h>
-#include "qwindowsvistastyle_p.h"
-
-#if QT_CONFIG(style_windowsvista)
-#include <private/qwindowsxpstyle_p_p.h>
-#include <private/qstyleanimation_p.h>
-#include <private/qpaintengine_raster_p.h>
-#include <qpaintengine.h>
-#include <qwidget.h>
-#include <qapplication.h>
-#include <qpixmapcache.h>
-#include <qstyleoption.h>
-#if QT_CONFIG(pushbutton)
-#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>
-#endif
-#if QT_CONFIG(scrollbar)
-#include <qscrollbar.h>
-#endif
-#if QT_CONFIG(progressbar)
-#include <qprogressbar.h>
-#endif
-#if QT_CONFIG(dockwidget)
-#include <qdockwidget.h>
-#endif
-#if QT_CONFIG(listview)
-#include <qlistview.h>
-#endif
-#if QT_CONFIG(treeview)
-#include <qtreeview.h>
-#endif
-#include <qtextedit.h>
-#include <qmessagebox.h>
-#if QT_CONFIG(dialogbuttonbox)
-#include <qdialogbuttonbox.h>
-#endif
-#include <qinputdialog.h>
-#if QT_CONFIG(tableview)
-#include <qtableview.h>
-#endif
-#include <qdatetime.h>
-#include <qcommandlinkbutton.h>
-
-QT_BEGIN_NAMESPACE
-
-#if !defined(SCHEMA_VERIFY_VSSYM32)
-#define TMT_ANIMATIONDURATION 5006
-#define TMT_TRANSITIONDURATIONS 6000
-#define EP_EDITBORDER_NOSCROLL 6
-#define EP_EDITBORDER_HVSCROLL 9
-#define EP_BACKGROUND 3
-#define EBS_NORMAL 1
-#define EBS_HOT 2
-#define EBS_DISABLED 3
-#define EBS_READONLY 5
-#define PBS_DEFAULTED_ANIMATING 6
-#define MBI_NORMAL 1
-#define MBI_HOT 2
-#define MBI_PUSHED 3
-#define MBI_DISABLED 4
-#define MB_ACTIVE 1
-#define MB_INACTIVE 2
-#define PP_FILL 5
-#define PP_FILLVERT 6
-#define PP_MOVEOVERLAY 8
-#define PP_MOVEOVERLAYVERT 10
-#define MENU_BARBACKGROUND 7
-#define MENU_BARITEM 8
-#define MENU_POPUPCHECK 11
-#define MENU_POPUPCHECKBACKGROUND 12
-#define MENU_POPUPGUTTER 13
-#define MENU_POPUPITEM 14
-#define MENU_POPUPBORDERS 10
-#define MENU_POPUPSEPARATOR 15
-#define MC_CHECKMARKNORMAL 1
-#define MC_CHECKMARKDISABLED 2
-#define MC_BULLETNORMAL 3
-#define MC_BULLETDISABLED 4
-#define ABS_UPHOVER 17
-#define ABS_DOWNHOVER 18
-#define ABS_LEFTHOVER 19
-#define ABS_RIGHTHOVER 20
-#define CP_DROPDOWNBUTTONRIGHT 6
-#define CP_DROPDOWNBUTTONLEFT 7
-#define SCRBS_HOVER 5
-#define TVP_HOTGLYPH 4
-#define SPI_GETCLIENTAREAANIMATION 0x1042
-#define TDLG_PRIMARYPANEL 1
-#define TDLG_SECONDARYPANEL 8
-#endif
-
-class QWindowsVistaAnimation : public QBlendStyleAnimation
-{
- Q_OBJECT
-public:
- QWindowsVistaAnimation(Type type, QObject *target) : QBlendStyleAnimation(type, target) { }
-
- virtual bool isUpdateNeeded() const;
- void paint(QPainter *painter, const QStyleOption *option);
-};
-
-
-// Handles state transition animations
-class QWindowsVistaTransition : public QWindowsVistaAnimation
-{
- Q_OBJECT
-public:
- QWindowsVistaTransition(QObject *target) : QWindowsVistaAnimation(Transition, target) {}
-};
-
-
-// Handles pulse animations (default buttons)
-class QWindowsVistaPulse: public QWindowsVistaAnimation
-{
- Q_OBJECT
-public:
- QWindowsVistaPulse(QObject *target) : QWindowsVistaAnimation(Pulse, target) {}
-};
-
-
-class QWindowsVistaStylePrivate : public QWindowsXPStylePrivate
-{
- Q_DECLARE_PUBLIC(QWindowsVistaStyle)
-
-public:
- QWindowsVistaStylePrivate();
-
- static int fixedPixelMetric(QStyle::PixelMetric pm);
- static inline bool useVista();
- bool transitionsEnabled() const;
-};
-
-QT_END_NAMESPACE
-
-#endif // style_windowsvista
-
-#endif // QWINDOWSVISTASTYLE_P_P_H
diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp
deleted file mode 100644
index 8656ca6c09..0000000000
--- a/src/widgets/styles/qwindowsxpstyle.cpp
+++ /dev/null
@@ -1,4240 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "qwindowsxpstyle_p.h"
-#include "qwindowsxpstyle_p_p.h"
-
-#if QT_CONFIG(style_windowsxp) || defined(QT_PLUGIN)
-
-#include <private/qobject_p.h>
-#include <private/qpaintengine_raster_p.h>
-#include <private/qapplication_p.h>
-#include <qpa/qplatformnativeinterface.h>
-#include <private/qstylehelper_p.h>
-#include <private/qwidget_p.h>
-#include <qpainter.h>
-#include <qpaintengine.h>
-#include <qwidget.h>
-#include <qbackingstore.h>
-#include <qapplication.h>
-#include <qpixmapcache.h>
-#include <private/qapplication_p.h>
-#include <qpa/qplatformnativeinterface.h>
-
-#include <qdesktopwidget.h>
-#if QT_CONFIG(toolbutton)
-#include <qtoolbutton.h>
-#endif
-#if QT_CONFIG(tabbar)
-#include <qtabbar.h>
-#endif
-#if QT_CONFIG(combobox)
-#include <qcombobox.h>
-#endif
-#if QT_CONFIG(scrollbar)
-#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
-#include <qtoolbar.h>
-#include <qlabel.h>
-#include <qvarlengtharray.h>
-#include <qdebug.h>
-
-#include <algorithm>
-
-QT_BEGIN_NAMESPACE
-
-// General const values
-static const int windowsItemFrame = 2; // menu item frame width
-static const int windowsItemHMargin = 3; // menu item hor text margin
-static const int windowsItemVMargin = 0; // menu item ver text margin
-static const int windowsArrowHMargin = 6; // arrow horizontal margin
-static const int windowsRightBorder = 12; // right border on windows
-
-// External function calls
-extern Q_WIDGETS_EXPORT HDC qt_win_display_dc();
-extern QRegion qt_region_from_HRGN(HRGN rgn);
-
-// Theme names matching the QWindowsXPStylePrivate::Theme enumeration.
-static const wchar_t *themeNames[QWindowsXPStylePrivate::NThemes] =
-{
- L"BUTTON", L"COMBOBOX", L"EDIT", L"HEADER", L"LISTVIEW",
- L"MENU", L"PROGRESS", L"REBAR", L"SCROLLBAR", L"SPIN",
- L"TAB", L"TASKDIALOG", L"TOOLBAR", L"TOOLTIP", L"TRACKBAR",
- L"TREEVIEW", L"WINDOW", L"STATUS", L"TREEVIEW"
-};
-
-static inline QBackingStore *backingStoreForWidget(const QWidget *widget)
-{
- if (QBackingStore *backingStore = widget->backingStore())
- return backingStore;
- if (const QWidget *topLevel = widget->nativeParentWidget())
- if (QBackingStore *topLevelBackingStore = topLevel->backingStore())
- return topLevelBackingStore;
- return 0;
-}
-
-static inline HDC hdcForWidgetBackingStore(const QWidget *widget)
-{
- if (QBackingStore *backingStore = backingStoreForWidget(widget)) {
- QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
- return static_cast<HDC>(nativeInterface->nativeResourceForBackingStore(QByteArrayLiteral("getDC"), backingStore));
- }
- return 0;
-}
-
-// Theme data helper ------------------------------------------------------------------------------
-/* \internal
- Returns \c true if the themedata is valid for use.
-*/
-bool XPThemeData::isValid()
-{
- return QWindowsXPStylePrivate::useXP() && theme >= 0 && handle();
-}
-
-
-/* \internal
- Returns the theme engine handle to the specific class.
- If the handle hasn't been opened before, it opens the data, and
- adds it to a static map, for caching.
-*/
-HTHEME XPThemeData::handle()
-{
- if (!QWindowsXPStylePrivate::useXP())
- return 0;
-
- if (!htheme)
- htheme = QWindowsXPStylePrivate::createTheme(theme, QWindowsXPStylePrivate::winId(widget));
- return htheme;
-}
-
-/* \internal
- Converts a QRect to the native RECT structure.
-*/
-RECT XPThemeData::toRECT(const QRect &qr)
-{
- RECT r;
- r.left = qr.x();
- r.right = qr.x() + qr.width();
- r.top = qr.y();
- r.bottom = qr.y() + qr.height();
- return r;
-}
-
-/* \internal
- Returns the native region of a part, if the part is considered
- transparent. The region is scaled to the parts size (rect).
-*/
-HRGN XPThemeData::mask(QWidget *widget)
-{
- if (!IsThemeBackgroundPartiallyTransparent(handle(), partId, stateId))
- return 0;
-
- HRGN hrgn;
- HDC dc = 0;
- if (widget)
- dc = hdcForWidgetBackingStore(widget);
- RECT nativeRect = toRECT(rect);
- GetThemeBackgroundRegion(handle(), dc, partId, stateId, &nativeRect, &hrgn);
- return hrgn;
-}
-
-// QWindowsXPStylePrivate -------------------------------------------------------------------------
-// Static initializations
-QPixmap *QWindowsXPStylePrivate::tabbody = 0;
-HWND QWindowsXPStylePrivate::m_vistaTreeViewHelper = 0;
-HTHEME QWindowsXPStylePrivate::m_themes[NThemes];
-bool QWindowsXPStylePrivate::use_xp = false;
-QBasicAtomicInt QWindowsXPStylePrivate::ref = Q_BASIC_ATOMIC_INITIALIZER(-1); // -1 based refcounting
-
-static void qt_add_rect(HRGN &winRegion, QRect r)
-{
- HRGN rgn = CreateRectRgn(r.left(), r.top(), r.x() + r.width(), r.y() + r.height());
- if (rgn) {
- HRGN dest = CreateRectRgn(0,0,0,0);
- int result = CombineRgn(dest, winRegion, rgn, RGN_OR);
- if (result) {
- DeleteObject(winRegion);
- winRegion = dest;
- }
- DeleteObject(rgn);
- }
-}
-
-static HRGN qt_hrgn_from_qregion(const QRegion &region)
-{
- HRGN hRegion = CreateRectRgn(0,0,0,0);
- if (region.rectCount() == 1) {
- qt_add_rect(hRegion, region.boundingRect());
- return hRegion;
- }
- for (const QRect &rect : region)
- qt_add_rect(hRegion, rect);
- return hRegion;
-}
-
-/* \internal
- Checks if the theme engine can/should be used, or if we should
- fall back to Windows style.
-*/
-bool QWindowsXPStylePrivate::useXP(bool update)
-{
- if (!update)
- return use_xp;
- return use_xp = IsThemeActive() && (IsAppThemed() || !QApplication::instance());
-}
-
-/* \internal
- Handles refcounting, and queries the theme engine for usage.
-*/
-void QWindowsXPStylePrivate::init(bool force)
-{
- if (ref.ref() && !force)
- return;
- if (!force) // -1 based atomic refcounting
- ref.ref();
-
- useXP(true);
- std::fill(m_themes, m_themes + NThemes, HTHEME(0));
-}
-
-/* \internal
- Cleans up all static data.
-*/
-void QWindowsXPStylePrivate::cleanup(bool force)
-{
- if(bufferBitmap) {
- if (bufferDC && nullBitmap)
- SelectObject(bufferDC, nullBitmap);
- DeleteObject(bufferBitmap);
- bufferBitmap = 0;
- }
-
- if(bufferDC)
- DeleteDC(bufferDC);
- bufferDC = 0;
-
- if (ref.deref() && !force)
- return;
- if (!force) // -1 based atomic refcounting
- ref.deref();
-
- use_xp = false;
- cleanupHandleMap();
- delete tabbody;
- tabbody = 0;
-}
-
-/* In order to obtain the correct VistaTreeViewTheme (arrows for PE_IndicatorBranch),
- * we need to set the windows "explorer" theme explicitly on a native
- * window and open the "TREEVIEW" theme handle passing its window handle
- * in order to get Vista-style item view themes (particulary drawBackground()
- * for selected items needs this).
- * We invoke a service of the native Windows interface to create
- * a non-visible window handle, open the theme on it and insert it into
- * the cache so that it is found by XPThemeData::handle() first.
- */
-
-static inline HWND createTreeViewHelperWindow()
-{
- if (QPlatformNativeInterface *ni = QGuiApplication::platformNativeInterface()) {
- void *hwnd = 0;
- void *wndProc = reinterpret_cast<void *>(DefWindowProc);
- if (QMetaObject::invokeMethod(ni, "createMessageWindow", Qt::DirectConnection,
- Q_RETURN_ARG(void *, hwnd),
- Q_ARG(QString, QStringLiteral("QTreeViewThemeHelperWindowClass")),
- Q_ARG(QString, QStringLiteral("QTreeViewThemeHelperWindow")),
- Q_ARG(void *, wndProc)) && hwnd) {
- return reinterpret_cast<HWND>(hwnd);
- }
- }
- return 0;
-}
-
-bool QWindowsXPStylePrivate::initVistaTreeViewTheming()
-{
- if (m_vistaTreeViewHelper)
- return true;
-
- m_vistaTreeViewHelper = createTreeViewHelperWindow();
- if (!m_vistaTreeViewHelper) {
- qWarning("Unable to create the treeview helper window.");
- return false;
- }
- if (FAILED(SetWindowTheme(m_vistaTreeViewHelper, L"explorer", NULL))) {
- qErrnoWarning("SetWindowTheme() failed.");
- cleanupVistaTreeViewTheming();
- return false;
- }
- return true;
-}
-
-void QWindowsXPStylePrivate::cleanupVistaTreeViewTheming()
-{
- if (m_vistaTreeViewHelper) {
- DestroyWindow(m_vistaTreeViewHelper);
- m_vistaTreeViewHelper = 0;
- }
-}
-
-/* \internal
- Closes all open theme data handles to ensure that we don't leak
- resources, and that we don't refere to old handles when for
- example the user changes the theme style.
-*/
-void QWindowsXPStylePrivate::cleanupHandleMap()
-{
- for (int i = 0; i < NThemes; ++i)
- if (m_themes[i]) {
- CloseThemeData(m_themes[i]);
- m_themes[i] = 0;
- }
- QWindowsXPStylePrivate::cleanupVistaTreeViewTheming();
-}
-
-HTHEME QWindowsXPStylePrivate::createTheme(int theme, HWND hwnd)
-{
- if (Q_UNLIKELY(theme < 0 || theme >= NThemes || !hwnd)) {
- qWarning("Invalid parameters #%d, %p", theme, hwnd);
- return 0;
- }
- if (!m_themes[theme]) {
- const wchar_t *name = themeNames[theme];
- if (theme == VistaTreeViewTheme && QWindowsXPStylePrivate::initVistaTreeViewTheming())
- hwnd = QWindowsXPStylePrivate::m_vistaTreeViewHelper;
- m_themes[theme] = OpenThemeData(hwnd, name);
- if (Q_UNLIKELY(!m_themes[theme]))
- qErrnoWarning("OpenThemeData() failed for theme %d (%s).",
- theme, qPrintable(themeName(theme)));
- }
- return m_themes[theme];
-}
-
-QString QWindowsXPStylePrivate::themeName(int theme)
-{
- return theme >= 0 && theme < NThemes ?
- QString::fromWCharArray(themeNames[theme]) :
- QString();
-}
-
-bool QWindowsXPStylePrivate::isItemViewDelegateLineEdit(const QWidget *widget)
-{
- if (!widget)
- return false;
- const QWidget *parent1 = widget->parentWidget();
- // Exlude dialogs or other toplevels parented on item views.
- if (!parent1 || parent1->isWindow())
- return false;
- const QWidget *parent2 = parent1->parentWidget();
- return parent2 && widget->inherits("QLineEdit")
- && parent2->inherits("QAbstractItemView");
-}
-
-// Returns whether base color is set for this widget
-bool QWindowsXPStylePrivate::isLineEditBaseColorSet(const QStyleOption *option, const QWidget *widget)
-{
- uint resolveMask = option->palette.resolve();
- if (widget) {
- // 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.
-#if QT_CONFIG(spinbox)
- if (const QAbstractSpinBox *spinbox = qobject_cast<QAbstractSpinBox*>(widget->parentWidget()))
- resolveMask |= spinbox->palette().resolve();
-#endif // QT_CONFIG(spinbox)
- }
- return (resolveMask & (1 << QPalette::Base)) != 0;
-}
-
-/*! \internal
- This function will always return a valid window handle, and might
- create a limbo widget to do so.
- We often need a window handle to for example open theme data, so
- this function ensures that we get one.
-*/
-HWND QWindowsXPStylePrivate::winId(const QWidget *widget)
-{
- if (widget)
- if (const HWND hwnd = QApplicationPrivate::getHWNDForWidget(const_cast<QWidget *>(widget)))
- return hwnd;
-
- // Find top level with native window (there might be dialogs that do not have one).
- const auto topLevels = QApplication::topLevelWidgets();
- for (const QWidget *toplevel : topLevels) {
- if (toplevel->windowHandle() && toplevel->windowHandle()->handle())
- if (const HWND topLevelHwnd = QApplicationPrivate::getHWNDForWidget(toplevel))
- return topLevelHwnd;
- }
-
- return GetDesktopWindow();
-}
-
-/*! \internal
- Returns the pointer to a tab widgets body pixmap, scaled to the
- height of the screen. This way the theme engine doesn't need to
- scale the body for every time we ask for it. (Speed optimization)
-*/
-const QPixmap *QWindowsXPStylePrivate::tabBody(QWidget *widget)
-{
- if (!tabbody) {
- XPThemeData theme(0, 0, QWindowsXPStylePrivate::TabTheme, TABP_BODY);
- const QSize size = (theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize();
-
- tabbody = new QPixmap(size.width(), QApplication::desktop()->screenGeometry().height());
- QPainter painter(tabbody);
- theme.rect = QRect(QPoint(0, 0), size);
- drawBackground(theme);
- // We fill with the last line of the themedata, that
- // way we don't get a tiled pixmap inside big tabs
- QPixmap temp(size.width(), 1);
- painter.drawPixmap(0, 0, temp, 0, size.height() - 1, -1, -1);
- painter.drawTiledPixmap(0, size.height(), size.width(), tabbody->height() - size.height(), temp);
- }
- return tabbody;
-}
-
-/*! \internal
- Returns a native buffer (DIB section) of at least the size of
- ( \a x , \a y ). The buffer has a 32 bit depth, to not lose
- the alpha values on proper alpha-pixmaps.
-*/
-HBITMAP QWindowsXPStylePrivate::buffer(int w, int h)
-{
- // If we already have a HBITMAP which is of adequate size, just return that
- if (bufferBitmap) {
- if (bufferW >= w && bufferH >= h)
- return bufferBitmap;
- // Not big enough, discard the old one
- if (bufferDC && nullBitmap)
- SelectObject(bufferDC, nullBitmap);
- DeleteObject(bufferBitmap);
- bufferBitmap = 0;
- }
-
- w = qMax(bufferW, w);
- h = qMax(bufferH, h);
-
- if (!bufferDC) {
- HDC displayDC = GetDC(0);
- bufferDC = CreateCompatibleDC(displayDC);
- ReleaseDC(0, displayDC);
- }
-
- // Define the header
- BITMAPINFO bmi;
- memset(&bmi, 0, sizeof(bmi));
- bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bmi.bmiHeader.biWidth = w;
- bmi.bmiHeader.biHeight = -h;
- bmi.bmiHeader.biPlanes = 1;
- bmi.bmiHeader.biBitCount = 32;
- bmi.bmiHeader.biCompression = BI_RGB;
-
- // Create the pixmap
- bufferPixels = 0;
- bufferBitmap = CreateDIBSection(bufferDC, &bmi, DIB_RGB_COLORS, (void **) &bufferPixels, 0, 0);
- GdiFlush();
- nullBitmap = (HBITMAP)SelectObject(bufferDC, bufferBitmap);
-
- if (Q_UNLIKELY(!bufferBitmap)) {
- qErrnoWarning("QWindowsXPStylePrivate::buffer(%dx%d), CreateDIBSection() failed.", w, h);
- bufferW = 0;
- bufferH = 0;
- return 0;
- }
- if (Q_UNLIKELY(!bufferPixels)) {
- qErrnoWarning("QWindowsXPStylePrivate::buffer(%dx%d), CreateDIBSection() did not allocate pixel data.", w, h);
- bufferW = 0;
- bufferH = 0;
- return 0;
- }
- bufferW = w;
- bufferH = h;
-#ifdef DEBUG_XP_STYLE
- qDebug("Creating new dib section (%d, %d)", w, h);
-#endif
- return bufferBitmap;
-}
-
-/*! \internal
- Returns \c true if the part contains any transparency at all. This does
- not indicate what kind of transparency we're dealing with. It can be
- - Alpha transparency
- - Masked transparency
-*/
-bool QWindowsXPStylePrivate::isTransparent(XPThemeData &themeData)
-{
- return IsThemeBackgroundPartiallyTransparent(themeData.handle(), themeData.partId,
- themeData.stateId);
-}
-
-
-/*! \internal
- Returns a QRegion of the region of the part
-*/
-QRegion QWindowsXPStylePrivate::region(XPThemeData &themeData)
-{
- HRGN hRgn = 0;
- RECT rect = themeData.toRECT(themeData.rect);
- if (!SUCCEEDED(GetThemeBackgroundRegion(themeData.handle(), bufferHDC(), themeData.partId,
- themeData.stateId, &rect, &hRgn))) {
- return QRegion();
- }
-
- HRGN dest = CreateRectRgn(0, 0, 0, 0);
- const bool success = CombineRgn(dest, hRgn, 0, RGN_COPY) != ERROR;
-
- QRegion region;
-
- if (success) {
- int numBytes = GetRegionData(dest, 0, 0);
- if (numBytes == 0)
- return QRegion();
-
- char *buf = new char[numBytes];
- if (buf == 0)
- return QRegion();
-
- RGNDATA *rd = reinterpret_cast<RGNDATA*>(buf);
- if (GetRegionData(dest, numBytes, rd) == 0) {
- delete [] buf;
- return QRegion();
- }
-
- RECT *r = reinterpret_cast<RECT*>(rd->Buffer);
- for (uint i = 0; i < rd->rdh.nCount; ++i) {
- QRect rect;
- rect.setCoords(r->left, r->top, r->right - 1, r->bottom - 1);
- ++r;
- region |= rect;
- }
-
- delete [] buf;
- }
-
- DeleteObject(hRgn);
- DeleteObject(dest);
-
- return region;
-}
-
-/*! \internal
- Sets the parts region on a window.
-*/
-void QWindowsXPStylePrivate::setTransparency(QWidget *widget, XPThemeData &themeData)
-{
- HRGN hrgn = themeData.mask(widget);
- if (hrgn && widget)
- SetWindowRgn(winId(widget), hrgn, true);
-}
-
-/*! \internal
- Returns \c true if the native doublebuffer contains pixels with
- varying alpha value.
-*/
-bool QWindowsXPStylePrivate::hasAlphaChannel(const QRect &rect)
-{
- const int startX = rect.left();
- const int startY = rect.top();
- const int w = rect.width();
- const int h = rect.height();
-
- int firstAlpha = -1;
- for (int y = startY; y < h/2; ++y) {
- DWORD *buffer = (DWORD*)bufferPixels + (y * bufferW);
- for (int x = startX; x < w; ++x, ++buffer) {
- int alpha = (*buffer) >> 24;
- if (firstAlpha == -1)
- firstAlpha = alpha;
- else if (alpha != firstAlpha)
- return true;
- }
- }
- return false;
-}
-
-/*! \internal
- When the theme engine paints both a true alpha pixmap and a glyph
- into our buffer, the glyph might not contain a proper alpha value.
- The rule of thumb for premultiplied pixmaps is that the color
- values of a pixel can never be higher than the alpha values, so
- we use this to our advantage here, and fix all instances where
- this occures.
-*/
-bool QWindowsXPStylePrivate::fixAlphaChannel(const QRect &rect)
-{
- const int startX = rect.left();
- const int startY = rect.top();
- const int w = rect.width();
- const int h = rect.height();
- bool hasFixedAlphaValue = false;
-
- for (int y = startY; y < h; ++y) {
- DWORD *buffer = (DWORD*)bufferPixels + (y * bufferW);
- for (int x = startX; x < w; ++x, ++buffer) {
- uint pixel = *buffer;
- int alpha = qAlpha(pixel);
- if (qRed(pixel) > alpha || qGreen(pixel) > alpha || qBlue(pixel) > alpha) {
- *buffer |= 0xff000000;
- hasFixedAlphaValue = true;
- }
- }
- }
- return hasFixedAlphaValue;
-}
-
-/*! \internal
- Swaps the alpha values on certain pixels:
- 0xFF?????? -> 0x00??????
- 0x00?????? -> 0xFF??????
- Used to determin the mask of a non-alpha transparent pixmap in
- the native doublebuffer, and swap the alphas so we may paint
- the image as a Premultiplied QImage with drawImage(), and obtain
- the mask transparency.
-*/
-bool QWindowsXPStylePrivate::swapAlphaChannel(const QRect &rect, bool allPixels)
-{
- const int startX = rect.left();
- const int startY = rect.top();
- const int w = rect.width();
- const int h = rect.height();
- bool valueChange = false;
-
- // Flip the alphas, so that 255-alpha pixels are 0, and 0-alpha are 255.
- for (int y = startY; y < h; ++y) {
- DWORD *buffer = (DWORD*)bufferPixels + (y * bufferW);
- for (int x = startX; x < w; ++x, ++buffer) {
- if (allPixels) {
- *buffer |= 0xFF000000;
- continue;
- }
- unsigned int alphaValue = (*buffer) & 0xFF000000;
- if (alphaValue == 0xFF000000) {
- *buffer = 0;
- valueChange = true;
- } else if (alphaValue == 0) {
- *buffer |= 0xFF000000;
- valueChange = true;
- }
- }
- }
- return valueChange;
-}
-
-enum TransformType { SimpleTransform, HighDpiScalingTransform, ComplexTransform };
-
-static inline TransformType transformType(const QTransform &transform, qreal devicePixelRatio)
-{
- if (transform.type() <= QTransform::TxTranslate)
- return SimpleTransform;
- if (transform.type() > QTransform::TxScale)
- return ComplexTransform;
- return qFuzzyCompare(transform.m11(), devicePixelRatio)
- && qFuzzyCompare(transform.m22(), devicePixelRatio)
- ? HighDpiScalingTransform : ComplexTransform;
-}
-
-/*! \internal
- Main theme drawing function.
- Determines the correct lowlevel drawing method depending on several
- factors.
- Use drawBackgroundThruNativeBuffer() if:
- - Painter does not have an HDC
- - Theme part is flipped (mirrored horizontally)
- else use drawBackgroundDirectly().
- \note drawBackgroundThruNativeBuffer() can return false for large
- sizes due to buffer()/CreateDIBSection() failing.
-*/
-bool QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData)
-{
- if (themeData.rect.isEmpty())
- return true;
-
- QPainter *painter = themeData.painter;
- Q_ASSERT_X(painter != 0, "QWindowsXPStylePrivate::drawBackground()", "Trying to draw a theme part without a painter");
- if (!painter || !painter->isActive())
- return false;
-
- painter->save();
-
- // Access paintDevice via engine since the painter may
- // return the clip device which can still be a widget device in case of grabWidget().
-
- bool translucentToplevel = false;
- const QPaintDevice *paintDevice = painter->device();
- const qreal aditionalDevicePixelRatio = themeData.widget ? themeData.widget->devicePixelRatioF() : qreal(1);
- if (paintDevice->devType() == QInternal::Widget) {
- const QWidget *window = static_cast<const QWidget *>(paintDevice)->window();
- translucentToplevel = window->testAttribute(Qt::WA_TranslucentBackground);
- }
-
- const TransformType tt = transformType(painter->deviceTransform(), aditionalDevicePixelRatio);
-
- bool canDrawDirectly = false;
- if (themeData.widget && painter->opacity() == 1.0 && !themeData.rotate
- && tt != ComplexTransform && !themeData.mirrorVertically
- && !translucentToplevel) {
- // Draw on backing store DC only for real widgets or backing store images.
- const QPaintDevice *enginePaintDevice = painter->paintEngine()->paintDevice();
- switch (enginePaintDevice->devType()) {
- case QInternal::Widget:
- canDrawDirectly = true;
- break;
- case QInternal::Image:
- // Ensure the backing store has received as resize and is initialized.
- if (QBackingStore *bs = backingStoreForWidget(themeData.widget))
- if (bs->size().isValid() && bs->paintDevice() == enginePaintDevice)
- canDrawDirectly = true;
- }
- }
-
- const HDC dc = canDrawDirectly ? hdcForWidgetBackingStore(themeData.widget) : HDC(0);
- const bool result = dc
- ? drawBackgroundDirectly(dc, themeData, aditionalDevicePixelRatio)
- : drawBackgroundThruNativeBuffer(themeData, aditionalDevicePixelRatio);
- painter->restore();
- return result;
-}
-
-static inline QRectF scaleRect(const QRectF &r, qreal factor)
-{
- return r.isValid() && factor > 1
- ? QRectF(r.topLeft() * factor, r.size() * factor)
- : r;
-}
-
-static QRegion scaleRegion(const QRegion &region, qreal factor)
-{
- if (region.isEmpty() || qFuzzyCompare(factor, qreal(1)))
- return region;
- if (region.rectCount() == 1)
- return QRegion(scaleRect(QRectF(region.boundingRect()), factor).toRect());
- QRegion result;
- foreach (const QRect &rect, region.rects())
- result += QRectF(QPointF(rect.topLeft()) * factor, QSizeF(rect.size() * factor)).toRect();
- return result;
-}
-
-/*! \internal
- This function draws the theme parts directly to the paintengines HDC.
- Do not use this if you need to perform other transformations on the
- resulting data.
-*/
-bool QWindowsXPStylePrivate::drawBackgroundDirectly(HDC dc, XPThemeData &themeData, qreal additionalDevicePixelRatio)
-{
- QPainter *painter = themeData.painter;
-
- const QPointF redirectionDelta(painter->deviceMatrix().dx(), painter->deviceMatrix().dy());
- const QRect area = scaleRect(QRectF(themeData.rect), additionalDevicePixelRatio).translated(redirectionDelta).toRect();
-
- QRegion sysRgn = painter->paintEngine()->systemClip();
- if (sysRgn.isEmpty())
- sysRgn = area;
- else
- sysRgn &= area;
- if (painter->hasClipping())
- sysRgn &= scaleRegion(painter->clipRegion(), additionalDevicePixelRatio).translated(redirectionDelta.toPoint());
- HRGN hrgn = qt_hrgn_from_qregion(sysRgn);
- SelectClipRgn(dc, hrgn);
-
-#ifdef DEBUG_XP_STYLE
- printf("---[ DIRECT PAINTING ]------------------> Name(%-10s) Part(%d) State(%d)\n",
- qPrintable(themeData.name), themeData.partId, themeData.stateId);
- showProperties(themeData);
-#endif
-
- RECT drawRECT = themeData.toRECT(area);
- DTBGOPTS drawOptions;
- memset(&drawOptions, 0, sizeof(drawOptions));
- drawOptions.dwSize = sizeof(drawOptions);
- drawOptions.rcClip = themeData.toRECT(sysRgn.boundingRect());
- drawOptions.dwFlags = DTBG_CLIPRECT
- | (themeData.noBorder ? DTBG_OMITBORDER : 0)
- | (themeData.noContent ? DTBG_OMITCONTENT : 0)
- | (themeData.mirrorHorizontally ? DTBG_MIRRORDC : 0);
-
- const HRESULT result = DrawThemeBackgroundEx(themeData.handle(), dc, themeData.partId, themeData.stateId, &(drawRECT), &drawOptions);
- SelectClipRgn(dc, 0);
- DeleteObject(hrgn);
- return SUCCEEDED(result);
-}
-
-/*! \internal
- This function uses a secondary Native doublebuffer for painting parts.
- It should only be used when the painteengine doesn't provide a proper
- HDC for direct painting (e.g. when doing a grabWidget(), painting to
- other pixmaps etc), or when special transformations are needed (e.g.
- flips (horizonal mirroring only, vertical are handled by the theme
- engine).
-*/
-bool QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(XPThemeData &themeData,
- qreal additionalDevicePixelRatio)
-{
- QPainter *painter = themeData.painter;
- QRectF rectF = scaleRect(QRectF(themeData.rect), additionalDevicePixelRatio);
-
- if ((themeData.rotate + 90) % 180 == 0) { // Catch 90,270,etc.. degree flips.
- rectF = QRectF(0, 0, rectF.height(), rectF.width());
- }
- rectF.moveTo(0, 0);
- QRect rect = rectF.toRect();
- int partId = themeData.partId;
- int stateId = themeData.stateId;
- int w = rect.width();
- int h = rect.height();
-
- // Values initialized later, either from cached values, or from function calls
- AlphaChannelType alphaType = UnknownAlpha;
- bool stateHasData = true; // We assume so;
- bool hasAlpha = false;
- bool partIsTransparent;
- bool potentialInvalidAlpha;
-
- QString pixmapCacheKey = QStringLiteral("$qt_xp_");
- pixmapCacheKey.append(themeName(themeData.theme));
- pixmapCacheKey.append(QLatin1Char('p'));
- pixmapCacheKey.append(QString::number(partId));
- pixmapCacheKey.append(QLatin1Char('s'));
- pixmapCacheKey.append(QString::number(stateId));
- pixmapCacheKey.append(QLatin1Char('s'));
- pixmapCacheKey.append(themeData.noBorder ? QLatin1Char('0') : QLatin1Char('1'));
- pixmapCacheKey.append(QLatin1Char('b'));
- pixmapCacheKey.append(themeData.noContent ? QLatin1Char('0') : QLatin1Char('1'));
- pixmapCacheKey.append(QString::number(w));
- pixmapCacheKey.append(QLatin1Char('w'));
- pixmapCacheKey.append(QString::number(h));
- pixmapCacheKey.append(QLatin1Char('h'));
- pixmapCacheKey.append(QString::number(additionalDevicePixelRatio));
- pixmapCacheKey.append(QLatin1Char('d'));
-
- QPixmap cachedPixmap;
- ThemeMapKey key(themeData);
- ThemeMapData data = alphaCache.value(key);
-
- bool haveCachedPixmap = false;
- bool isCached = data.dataValid;
- if (isCached) {
- partIsTransparent = data.partIsTransparent;
- hasAlpha = data.hasAlphaChannel;
- alphaType = data.alphaType;
- potentialInvalidAlpha = data.hadInvalidAlpha;
-
- haveCachedPixmap = QPixmapCache::find(pixmapCacheKey, cachedPixmap);
-
-#ifdef DEBUG_XP_STYLE
- char buf[25];
- ::sprintf(buf, "+ Pixmap(%3d, %3d) ]", w, h);
- printf("---[ CACHED %s--------> Name(%-10s) Part(%d) State(%d)\n",
- haveCachedPixmap ? buf : "]-------------------",
- qPrintable(themeData.name), themeData.partId, themeData.stateId);
-#endif
- } else {
- // Not cached, so get values from Theme Engine
- BOOL tmt_borderonly = false;
- COLORREF tmt_transparentcolor = 0x0;
- PROPERTYORIGIN proporigin = PO_NOTFOUND;
- GetThemeBool(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERONLY, &tmt_borderonly);
- GetThemeColor(themeData.handle(), themeData.partId, themeData.stateId, TMT_TRANSPARENTCOLOR, &tmt_transparentcolor);
- GetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, TMT_CAPTIONMARGINS, &proporigin);
-
- partIsTransparent = isTransparent(themeData);
-
- potentialInvalidAlpha = false;
- GetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, TMT_GLYPHTYPE, &proporigin);
- if (proporigin == PO_PART || proporigin == PO_STATE) {
- int tmt_glyphtype = GT_NONE;
- GetThemeEnumValue(themeData.handle(), themeData.partId, themeData.stateId, TMT_GLYPHTYPE, &tmt_glyphtype);
- potentialInvalidAlpha = partIsTransparent && tmt_glyphtype == GT_IMAGEGLYPH;
- }
-
-#ifdef DEBUG_XP_STYLE
- printf("---[ NOT CACHED ]-----------------------> Name(%-10s) Part(%d) State(%d)\n",
- qPrintable(themeData.name), themeData.partId, themeData.stateId);
- printf("-->partIsTransparen = %d\n", partIsTransparent);
- printf("-->potentialInvalidAlpha = %d\n", potentialInvalidAlpha);
- showProperties(themeData);
-#endif
- }
- bool wasAlphaSwapped = false;
- bool wasAlphaFixed = false;
-
- // OLD PSDK Workaround ------------------------------------------------------------------------
- // See if we need extra clipping for the older PSDK, which does
- // not have a DrawThemeBackgroundEx function for DTGB_OMITBORDER
- // and DTGB_OMITCONTENT
- bool addBorderContentClipping = false;
- QRegion extraClip;
- QRect area = rect;
- if (themeData.noBorder || themeData.noContent) {
- extraClip = area;
- // We are running on a system where the uxtheme.dll does not have
- // the DrawThemeBackgroundEx function, so we need to clip away
- // borders or contents manually.
-
- int borderSize = 0;
- PROPERTYORIGIN origin = PO_NOTFOUND;
- GetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERSIZE, &origin);
- GetThemeInt(themeData.handle(), themeData.partId, themeData.stateId, TMT_BORDERSIZE, &borderSize);
-
- // Clip away border region
- if ((origin == PO_CLASS || origin == PO_PART || origin == PO_STATE) && borderSize > 0) {
- if (themeData.noBorder) {
- extraClip &= area;
- area = area.adjusted(-borderSize, -borderSize, borderSize, borderSize);
- }
-
- // Clip away content region
- if (themeData.noContent) {
- QRegion content = area.adjusted(borderSize, borderSize, -borderSize, -borderSize);
- extraClip ^= content;
- }
- }
- addBorderContentClipping = (themeData.noBorder | themeData.noContent);
- }
-
- QImage img;
- if (!haveCachedPixmap) { // If the pixmap is not cached, generate it! -------------------------
- if (!buffer(w, h)) // Ensure a buffer of at least (w, h) in size
- return false;
- HDC dc = bufferHDC();
-
- // Clear the buffer
- if (alphaType != NoAlpha) {
- // Consider have separate "memset" function for small chunks for more speedup
- memset(bufferPixels, 0x00, bufferW * h * 4);
- }
-
- // Difference between area and rect
- int dx = area.x() - rect.x();
- int dy = area.y() - rect.y();
-
- // Adjust so painting rect starts from Origo
- rect.moveTo(0,0);
- area.moveTo(dx,dy);
- DTBGOPTS drawOptions;
- drawOptions.dwSize = sizeof(drawOptions);
- drawOptions.rcClip = themeData.toRECT(rect);
- drawOptions.dwFlags = DTBG_CLIPRECT
- | (themeData.noBorder ? DTBG_OMITBORDER : 0)
- | (themeData.noContent ? DTBG_OMITCONTENT : 0);
-
- // Drawing the part into the backing store
- RECT wRect(themeData.toRECT(area));
- DrawThemeBackgroundEx(themeData.handle(), dc, themeData.partId, themeData.stateId, &wRect, &drawOptions);
-
- // If not cached, analyze the buffer data to figure
- // out alpha type, and if it contains data
- if (!isCached) {
- // SHORTCUT: If the part's state has no data, cache it for NOOP later
- if (!stateHasData) {
- memset(&data, 0, sizeof(data));
- data.dataValid = true;
- alphaCache.insert(key, data);
- return true;
- }
- hasAlpha = hasAlphaChannel(rect);
- if (!hasAlpha && partIsTransparent)
- potentialInvalidAlpha = true;
-#if defined(DEBUG_XP_STYLE) && 1
- dumpNativeDIB(w, h);
-#endif
- }
-
- // Fix alpha values, if needed
- if (potentialInvalidAlpha)
- wasAlphaFixed = fixAlphaChannel(rect);
-
- QImage::Format format;
- if ((partIsTransparent && !wasAlphaSwapped) || (!partIsTransparent && hasAlpha)) {
- format = QImage::Format_ARGB32_Premultiplied;
- alphaType = RealAlpha;
- } else if (wasAlphaSwapped) {
- format = QImage::Format_ARGB32_Premultiplied;
- alphaType = MaskAlpha;
- } else {
- format = QImage::Format_RGB32;
- // The image data we got from the theme engine does not have any transparency,
- // thus the alpha channel is set to 0.
- // However, Format_RGB32 requires the alpha part to be set to 0xff, thus
- // we must flip it from 0x00 to 0xff
- swapAlphaChannel(rect, true);
- alphaType = NoAlpha;
- }
-#if defined(DEBUG_XP_STYLE) && 1
- printf("Image format is: %s\n", alphaType == RealAlpha ? "Real Alpha" : alphaType == MaskAlpha ? "Masked Alpha" : "No Alpha");
-#endif
- img = QImage(bufferPixels, bufferW, bufferH, format);
- img.setDevicePixelRatio(additionalDevicePixelRatio);
- }
-
- // Blitting backing store
- bool useRegion = partIsTransparent && !hasAlpha && !wasAlphaSwapped;
-
- QRegion newRegion;
- QRegion oldRegion;
- if (useRegion) {
- newRegion = region(themeData);
- oldRegion = painter->clipRegion();
- painter->setClipRegion(newRegion);
-#if defined(DEBUG_XP_STYLE) && 0
- printf("Using region:\n");
- for (const QRect &r : newRegion)
- printf(" (%d, %d, %d, %d)\n", r.x(), r.y(), r.right(), r.bottom());
-#endif
- }
-
- if (addBorderContentClipping)
- painter->setClipRegion(extraClip, Qt::IntersectClip);
-
- if (!themeData.mirrorHorizontally && !themeData.mirrorVertically && !themeData.rotate) {
- if (!haveCachedPixmap)
- painter->drawImage(themeData.rect, img, rect);
- else
- painter->drawPixmap(themeData.rect, cachedPixmap);
- } else {
- // This is _slow_!
- // Make a copy containing only the necessary data, and mirror
- // on all wanted axes. Then draw the copy.
- // If cached, the normal pixmap is cached, instead of caching
- // all possible orientations for each part and state.
- QImage imgCopy;
- if (!haveCachedPixmap)
- imgCopy = img.copy(rect);
- else
- imgCopy = cachedPixmap.toImage();
-
- if (themeData.rotate) {
- QMatrix rotMatrix;
- rotMatrix.rotate(themeData.rotate);
- imgCopy = imgCopy.transformed(rotMatrix);
- }
- if (themeData.mirrorHorizontally || themeData.mirrorVertically) {
- imgCopy = imgCopy.mirrored(themeData.mirrorHorizontally, themeData.mirrorVertically);
- }
- painter->drawImage(themeData.rect,
- imgCopy);
- }
-
- if (useRegion || addBorderContentClipping) {
- if (oldRegion.isEmpty())
- painter->setClipping(false);
- else
- painter->setClipRegion(oldRegion);
- }
-
- // Cache the pixmap to avoid expensive swapAlphaChannel() calls
- if (!haveCachedPixmap && w && h) {
- QPixmap pix = QPixmap::fromImage(img).copy(rect);
- QPixmapCache::insert(pixmapCacheKey, pix);
-#ifdef DEBUG_XP_STYLE
- printf("+++Adding pixmap to cache, size(%d, %d), wasAlphaSwapped(%d), wasAlphaFixed(%d), name(%s)\n",
- w, h, wasAlphaSwapped, wasAlphaFixed, qPrintable(pixmapCacheKey));
-#endif
- }
-
- // Add to theme part cache
- if (!isCached) {
- memset(&data, 0, sizeof(data));
- data.dataValid = true;
- data.partIsTransparent = partIsTransparent;
- data.alphaType = alphaType;
- data.hasAlphaChannel = hasAlpha;
- data.wasAlphaSwapped = wasAlphaSwapped;
- data.hadInvalidAlpha = wasAlphaFixed;
- alphaCache.insert(key, data);
- }
- return true;
-}
-
-
-// ------------------------------------------------------------------------------------------------
-
-/*!
- \class QWindowsXPStyle
- \brief The QWindowsXPStyle class provides a Microsoft Windows XP-like look and feel.
-
- \ingroup appearance
- \inmodule QtWidgets
- \internal
-
- \warning This style is only available on the Windows XP platform
- because it makes use of Windows XP's style engine.
-
- Most of the functions are documented in the base classes
- QWindowsStyle, QCommonStyle, and QStyle, but the
- QWindowsXPStyle overloads of drawComplexControl(), drawControl(),
- drawControlMask(), drawPrimitive(), proxy()->subControlRect(), and
- sizeFromContents(), are documented here.
-
- \image qwindowsxpstyle.png
- \sa QMacStyle, QWindowsStyle, QFusionStyle
-*/
-
-/*!
- Constructs a QWindowsStyle
-*/
-QWindowsXPStyle::QWindowsXPStyle()
- : QWindowsStyle(*new QWindowsXPStylePrivate)
-{
-}
-
-/*!
- Destroys the style.
-*/
-QWindowsXPStyle::~QWindowsXPStyle()
-{
-}
-
-/*! \reimp */
-void QWindowsXPStyle::unpolish(QApplication *app)
-{
- QWindowsStyle::unpolish(app);
-}
-
-/*! \reimp */
-void QWindowsXPStyle::polish(QApplication *app)
-{
- QWindowsStyle::polish(app);
- if (!QWindowsXPStylePrivate::useXP())
- return;
-}
-
-/*! \reimp */
-void QWindowsXPStyle::polish(QWidget *widget)
-{
- QWindowsStyle::polish(widget);
- if (!QWindowsXPStylePrivate::useXP())
- return;
-
- if (false
-#if QT_CONFIG(abstractbutton)
- || qobject_cast<QAbstractButton*>(widget)
-#endif
- || qobject_cast<QToolButton*>(widget)
- || qobject_cast<QTabBar*>(widget)
-#if QT_CONFIG(combobox)
- || qobject_cast<QComboBox*>(widget)
-#endif // QT_CONFIG(combobox)
- || qobject_cast<QScrollBar*>(widget)
- || qobject_cast<QSlider*>(widget)
- || qobject_cast<QHeaderView*>(widget)
-#if QT_CONFIG(spinbox)
- || qobject_cast<QAbstractSpinBox*>(widget)
- || qobject_cast<QSpinBox*>(widget)
-#endif // QT_CONFIG(spinbox)
- ) {
- widget->setAttribute(Qt::WA_Hover);
- }
-
-#if QT_CONFIG(rubberband)
- if (qobject_cast<QRubberBand*>(widget)) {
- widget->setWindowOpacity(0.6);
- }
-#endif
- if (qobject_cast<QStackedWidget*>(widget) &&
- qobject_cast<QTabWidget*>(widget->parent()))
- widget->parentWidget()->setAttribute(Qt::WA_ContentsPropagated);
-
- Q_D(QWindowsXPStyle);
- if (!d->hasInitColors) {
- // Get text color for group box labels
- COLORREF cref;
- XPThemeData theme(widget, 0, QWindowsXPStylePrivate::ButtonTheme, 0, 0);
- GetThemeColor(theme.handle(), BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR, &cref);
- d->groupBoxTextColor = qRgb(GetRValue(cref), GetGValue(cref), GetBValue(cref));
- GetThemeColor(theme.handle(), BP_GROUPBOX, GBS_DISABLED, TMT_TEXTCOLOR, &cref);
- d->groupBoxTextColorDisabled = qRgb(GetRValue(cref), GetGValue(cref), GetBValue(cref));
- // Where does this color come from?
- //GetThemeColor(theme.handle(), TKP_TICS, TSS_NORMAL, TMT_COLOR, &cref);
- d->sliderTickColor = qRgb(165, 162, 148);
- d->hasInitColors = true;
- }
-}
-
-/*! \reimp */
-void QWindowsXPStyle::polish(QPalette &pal)
-{
- QWindowsStyle::polish(pal);
- pal.setBrush(QPalette::AlternateBase, pal.base().color().darker(110));
-}
-
-/*! \reimp */
-void QWindowsXPStyle::unpolish(QWidget *widget)
-{
-#if QT_CONFIG(rubberband)
- if (qobject_cast<QRubberBand*>(widget)) {
- widget->setWindowOpacity(1.0);
- }
-#endif
- Q_D(QWindowsXPStyle);
- // Unpolish of widgets is the first thing that
- // happens when a theme changes, or the theme
- // engine is turned off. So we detect it here.
- bool oldState = QWindowsXPStylePrivate::useXP();
- bool newState = QWindowsXPStylePrivate::useXP(true);
- if ((oldState != newState) && newState) {
- d->cleanup(true);
- d->init(true);
- } else {
- // Cleanup handle map, if just changing style,
- // or turning it on. In both cases the values
- // already in the map might be old (other style).
- d->cleanupHandleMap();
- }
- if (false
-#if QT_CONFIG(abstractbutton)
- || qobject_cast<QAbstractButton*>(widget)
-#endif
- || qobject_cast<QToolButton*>(widget)
- || qobject_cast<QTabBar*>(widget)
-#if QT_CONFIG(combobox)
- || qobject_cast<QComboBox*>(widget)
-#endif // QT_CONFIG(combobox)
- || qobject_cast<QScrollBar*>(widget)
- || qobject_cast<QSlider*>(widget)
- || qobject_cast<QHeaderView*>(widget)
-#if QT_CONFIG(spinbox)
- || qobject_cast<QAbstractSpinBox*>(widget)
- || qobject_cast<QSpinBox*>(widget)
-#endif // QT_CONFIG(spinbox)
- ) {
- widget->setAttribute(Qt::WA_Hover, false);
- }
- QWindowsStyle::unpolish(widget);
-}
-
-/*! \reimp */
-QRect QWindowsXPStyle::subElementRect(SubElement sr, const QStyleOption *option, const QWidget *widget) const
-{
- if (!QWindowsXPStylePrivate::useXP()) {
- return QWindowsStyle::subElementRect(sr, option, widget);
- }
-
- QRect rect(option->rect);
- switch(sr) {
- case SE_DockWidgetCloseButton:
- case SE_DockWidgetFloatButton:
- rect = QWindowsStyle::subElementRect(sr, option, widget);
- return rect.translated(0, 1);
- break;
- case SE_TabWidgetTabContents:
- if (qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option))
- {
- rect = QWindowsStyle::subElementRect(sr, option, widget);
- if (sr == SE_TabWidgetTabContents) {
- if (const QTabWidget *tabWidget = qobject_cast<const QTabWidget *>(widget)) {
- if (tabWidget->documentMode())
- break;
- }
-
- rect.adjust(0, 0, -2, -2);
- }
- }
- break;
- case SE_TabWidgetTabBar: {
- rect = QWindowsStyle::subElementRect(sr, option, widget);
- const QStyleOptionTabWidgetFrame *twfOption =
- qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option);
- if (twfOption && twfOption->direction == Qt::RightToLeft
- && (twfOption->shape == QTabBar::RoundedNorth
- || twfOption->shape == QTabBar::RoundedSouth))
- {
- QStyleOptionTab otherOption;
- otherOption.shape = (twfOption->shape == QTabBar::RoundedNorth
- ? QTabBar::RoundedEast : QTabBar::RoundedSouth);
- int overlap = proxy()->pixelMetric(PM_TabBarBaseOverlap, &otherOption, widget);
- int borderThickness = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget);
- rect.adjust(-overlap + borderThickness, 0, -overlap + borderThickness, 0);
- }
- break;}
-
- case SE_PushButtonContents:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- MARGINS borderSize;
- if (widget) {
- XPThemeData buttontheme(widget, 0, QWindowsXPStylePrivate::ButtonTheme);
- HTHEME theme = buttontheme.handle();
- if (theme) {
- int stateId;
- if (!(option->state & State_Enabled))
- stateId = PBS_DISABLED;
- else if (option->state & State_Sunken)
- stateId = PBS_PRESSED;
- else if (option->state & State_MouseOver)
- stateId = PBS_HOT;
- else if (btn->features & QStyleOptionButton::DefaultButton)
- stateId = PBS_DEFAULTED;
- else
- stateId = PBS_NORMAL;
-
- int border = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget);
- rect = option->rect.adjusted(border, border, -border, -border);
-
- if (SUCCEEDED(GetThemeMargins(theme, NULL, BP_PUSHBUTTON, stateId, TMT_CONTENTMARGINS, NULL, &borderSize))) {
- rect.adjust(borderSize.cxLeftWidth, borderSize.cyTopHeight,
- -borderSize.cxRightWidth, -borderSize.cyBottomHeight);
- rect = visualRect(option->direction, option->rect, rect);
- }
- }
- }
- }
- break;
- case SE_ProgressBarContents:
- rect = QCommonStyle::subElementRect(SE_ProgressBarGroove, option, widget);
- if (option->state & QStyle::State_Horizontal)
- rect.adjust(4, 3, -4, -3);
- else
- rect.adjust(3, 2, -3, -2);
- break;
- default:
- rect = QWindowsStyle::subElementRect(sr, option, widget);
- }
- return rect;
-}
-
-/*!
- \reimp
-*/
-void QWindowsXPStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *option, QPainter *p,
- const QWidget *widget) const
-{
- QWindowsXPStylePrivate *d = const_cast<QWindowsXPStylePrivate*>(d_func());
-
- if (!QWindowsXPStylePrivate::useXP()) {
- QWindowsStyle::drawPrimitive(pe, option, p, widget);
- return;
- }
-
- int themeNumber = -1;
- int partId = 0;
- int stateId = 0;
- QRect rect = option->rect;
- State flags = option->state;
- bool hMirrored = false;
- bool vMirrored = false;
- bool noBorder = false;
- bool noContent = false;
- int rotate = 0;
-
- switch (pe) {
- case PE_FrameTabBarBase:
- if (const QStyleOptionTabBarBase *tbb
- = qstyleoption_cast<const QStyleOptionTabBarBase *>(option)) {
- p->save();
- switch (tbb->shape) {
- case QTabBar::RoundedNorth:
- p->setPen(QPen(tbb->palette.dark(), 0));
- p->drawLine(tbb->rect.topLeft(), tbb->rect.topRight());
- break;
- case QTabBar::RoundedWest:
- p->setPen(QPen(tbb->palette.dark(), 0));
- p->drawLine(tbb->rect.left(), tbb->rect.top(), tbb->rect.left(), tbb->rect.bottom());
- break;
- case QTabBar::RoundedSouth:
- p->setPen(QPen(tbb->palette.dark(), 0));
- p->drawLine(tbb->rect.left(), tbb->rect.top(),
- tbb->rect.right(), tbb->rect.top());
- break;
- case QTabBar::RoundedEast:
- p->setPen(QPen(tbb->palette.dark(), 0));
- p->drawLine(tbb->rect.topLeft(), tbb->rect.bottomLeft());
- break;
- case QTabBar::TriangularNorth:
- case QTabBar::TriangularEast:
- case QTabBar::TriangularWest:
- case QTabBar::TriangularSouth:
- p->restore();
- QWindowsStyle::drawPrimitive(pe, option, p, widget);
- return;
- }
- p->restore();
- }
- return;
- case PE_PanelButtonBevel:
- themeNumber = QWindowsXPStylePrivate::ButtonTheme;
- partId = BP_PUSHBUTTON;
- if (!(flags & State_Enabled))
- stateId = PBS_DISABLED;
- else if ((flags & State_Sunken) || (flags & State_On))
- stateId = PBS_PRESSED;
- else if (flags & State_MouseOver)
- stateId = PBS_HOT;
- //else if (flags & State_ButtonDefault)
- // stateId = PBS_DEFAULTED;
- else
- stateId = PBS_NORMAL;
- break;
-
- case PE_PanelButtonTool:
- if (widget && widget->inherits("QDockWidgetTitleButton")) {
- if (const QWidget *dw = widget->parentWidget())
- if (dw->isWindow())
- return;
- }
- themeNumber = QWindowsXPStylePrivate::ToolBarTheme;
- partId = TP_BUTTON;
- if (!(flags & State_Enabled))
- stateId = TS_DISABLED;
- else if (flags & State_Sunken)
- stateId = TS_PRESSED;
- else if (flags & State_MouseOver)
- stateId = flags & State_On ? TS_HOTCHECKED : TS_HOT;
- else if (flags & State_On)
- stateId = TS_CHECKED;
- else if (!(flags & State_AutoRaise))
- stateId = TS_HOT;
- else
- stateId = TS_NORMAL;
- break;
-
- case PE_IndicatorButtonDropDown:
- themeNumber = QWindowsXPStylePrivate::ToolBarTheme;
- partId = TP_SPLITBUTTONDROPDOWN;
- if (!(flags & State_Enabled))
- stateId = TS_DISABLED;
- else if (flags & State_Sunken)
- stateId = TS_PRESSED;
- else if (flags & State_MouseOver)
- stateId = flags & State_On ? TS_HOTCHECKED : TS_HOT;
- else if (flags & State_On)
- stateId = TS_CHECKED;
- else if (!(flags & State_AutoRaise))
- stateId = TS_HOT;
- else
- stateId = TS_NORMAL;
- if (option->direction == Qt::RightToLeft)
- hMirrored = true;
- break;
-
- case PE_IndicatorCheckBox:
- themeNumber = QWindowsXPStylePrivate::ButtonTheme;
- partId = BP_CHECKBOX;
- if (!(flags & State_Enabled))
- stateId = CBS_UNCHECKEDDISABLED;
- else if (flags & State_Sunken)
- stateId = CBS_UNCHECKEDPRESSED;
- else if (flags & State_MouseOver)
- stateId = CBS_UNCHECKEDHOT;
- else
- stateId = CBS_UNCHECKEDNORMAL;
-
- if (flags & State_On)
- stateId += CBS_CHECKEDNORMAL-1;
- else if (flags & State_NoChange)
- stateId += CBS_MIXEDNORMAL-1;
-
- break;
-
- case PE_IndicatorRadioButton:
- themeNumber = QWindowsXPStylePrivate::ButtonTheme;
- partId = BP_RADIOBUTTON;
- if (!(flags & State_Enabled))
- stateId = RBS_UNCHECKEDDISABLED;
- else if (flags & State_Sunken)
- stateId = RBS_UNCHECKEDPRESSED;
- else if (flags & State_MouseOver)
- stateId = RBS_UNCHECKEDHOT;
- else
- stateId = RBS_UNCHECKEDNORMAL;
-
- if (flags & State_On)
- stateId += RBS_CHECKEDNORMAL-1;
- break;
-
- case PE_IndicatorDockWidgetResizeHandle:
- return;
-
-case PE_Frame:
- {
- if (flags & State_Raised)
- return;
- themeNumber = QWindowsXPStylePrivate::ListViewTheme;
- partId = LVP_LISTGROUP;
- XPThemeData theme(widget, 0, themeNumber, partId, 0);
-
- if (!(flags & State_Enabled))
- stateId = ETS_DISABLED;
- else
- stateId = ETS_NORMAL;
- int fillType;
- if (GetThemeEnumValue(theme.handle(), partId, stateId, TMT_BGTYPE, &fillType) == S_OK) {
- if (fillType == BT_BORDERFILL) {
- COLORREF bcRef;
- GetThemeColor(theme.handle(), partId, stateId, TMT_BORDERCOLOR, &bcRef);
- QColor bordercolor(qRgb(GetRValue(bcRef), GetGValue(bcRef), GetBValue(bcRef)));
- QPen oldPen = p->pen();
- // int borderSize = 1;
- // GetThemeInt(theme.handle(), partId, stateId, TMT_BORDERCOLOR, &borderSize);
-
- // Inner white border
- p->setPen(QPen(option->palette.base().color(), 1));
- p->drawRect(option->rect.adjusted(1, 1, -2, -2));
- // Outer dark border
- p->setPen(QPen(bordercolor, 1));
- p->drawRect(option->rect.adjusted(0, 0, -1, -1));
- p->setPen(oldPen);
- return;
- } else if (fillType == BT_NONE) {
- return;
- }
- }
- break;
- }
- case PE_FrameLineEdit: {
- // we try to check if this lineedit is a delegate on a QAbstractItemView-derived class.
- if (QWindowsXPStylePrivate::isItemViewDelegateLineEdit(widget)) {
- QPen oldPen = p->pen();
- // Inner white border
- p->setPen(QPen(option->palette.base().color(), 1));
- p->drawRect(option->rect.adjusted(1, 1, -2, -2));
- // Outer dark border
- p->setPen(QPen(option->palette.shadow().color(), 1));
- p->drawRect(option->rect.adjusted(0, 0, -1, -1));
- p->setPen(oldPen);
- return;
- } else if (qstyleoption_cast<const QStyleOptionFrame *>(option)) {
- themeNumber = QWindowsXPStylePrivate::EditTheme;
- partId = EP_EDITTEXT;
- noContent = true;
- if (!(flags & State_Enabled))
- stateId = ETS_DISABLED;
- else
- stateId = ETS_NORMAL;
- }
- break;
- }
-
- case PE_PanelLineEdit:
- if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
- themeNumber = QWindowsXPStylePrivate::EditTheme;
- partId = EP_EDITTEXT;
- noBorder = true;
- bool isEnabled = flags & State_Enabled;
-
- stateId = isEnabled ? ETS_NORMAL : ETS_DISABLED;
-
- if (QWindowsXPStylePrivate::isLineEditBaseColorSet(option, widget)) {
- p->fillRect(panel->rect, panel->palette.brush(QPalette::Base));
- } else {
- XPThemeData theme(0, p, themeNumber, partId, stateId, rect);
- if (!theme.isValid()) {
- QWindowsStyle::drawPrimitive(pe, option, p, widget);
- return;
- }
- int bgType;
- GetThemeEnumValue(theme.handle(), partId, stateId, TMT_BGTYPE, &bgType);
- if( bgType == BT_IMAGEFILE ) {
- theme.mirrorHorizontally = hMirrored;
- theme.mirrorVertically = vMirrored;
- theme.noBorder = noBorder;
- theme.noContent = noContent;
- theme.rotate = rotate;
- d->drawBackground(theme);
- } else {
- QBrush fillColor = option->palette.brush(QPalette::Base);
-
- if (!isEnabled) {
- PROPERTYORIGIN origin = PO_NOTFOUND;
- GetThemePropertyOrigin(theme.handle(), theme.partId, theme.stateId, TMT_FILLCOLOR, &origin);
- // Use only if the fill property comes from our part
- if ((origin == PO_PART || origin == PO_STATE)) {
- COLORREF bgRef;
- GetThemeColor(theme.handle(), partId, stateId, TMT_FILLCOLOR, &bgRef);
- fillColor = QBrush(qRgb(GetRValue(bgRef), GetGValue(bgRef), GetBValue(bgRef)));
- }
- }
- p->fillRect(option->rect, fillColor);
- }
- }
-
- if (panel->lineWidth > 0)
- proxy()->drawPrimitive(PE_FrameLineEdit, panel, p, widget);
- return;
- }
- break;
-
- case PE_FrameTabWidget:
- if (const QStyleOptionTabWidgetFrame *tab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option))
- {
- themeNumber = QWindowsXPStylePrivate::TabTheme;
- partId = TABP_PANE;
-
- if (widget) {
- bool useGradient = true;
- const int maxlength = 256;
- wchar_t themeFileName[maxlength];
- wchar_t themeColor[maxlength];
- // Due to a a scaling issue with the XP Silver theme, tab gradients are not used with it
- if (GetCurrentThemeName(themeFileName, maxlength, themeColor, maxlength, NULL, 0) == S_OK) {
- wchar_t *offset = 0;
- if ((offset = wcsrchr(themeFileName, QChar(QLatin1Char('\\')).unicode())) != NULL) {
- offset++;
- if (!lstrcmp(offset, L"Luna.msstyles") && !lstrcmp(offset, L"Metallic")) {
- useGradient = false;
- }
- }
- }
- // This should work, but currently there's an error in the ::drawBackgroundDirectly()
- // code, when using the HDC directly..
- if (useGradient) {
- QStyleOptionTabWidgetFrame frameOpt = *tab;
- frameOpt.rect = widget->rect();
- QRect contentsRect = subElementRect(SE_TabWidgetTabContents, &frameOpt, widget);
- QRegion reg = option->rect;
- reg -= contentsRect;
- p->setClipRegion(reg);
- XPThemeData theme(widget, p, themeNumber, partId, stateId, rect);
- theme.mirrorHorizontally = hMirrored;
- theme.mirrorVertically = vMirrored;
- d->drawBackground(theme);
- p->setClipRect(contentsRect);
- partId = TABP_BODY;
- }
- }
- switch (tab->shape) {
- case QTabBar::RoundedNorth:
- case QTabBar::TriangularNorth:
- break;
- case QTabBar::RoundedSouth:
- case QTabBar::TriangularSouth:
- vMirrored = true;
- break;
- case QTabBar::RoundedEast:
- case QTabBar::TriangularEast:
- rotate = 90;
- break;
- case QTabBar::RoundedWest:
- case QTabBar::TriangularWest:
- rotate = 90;
- hMirrored = true;
- break;
- default:
- break;
- }
- }
- break;
-
- case PE_FrameMenu:
- p->save();
- p->setPen(option->palette.dark().color());
- p->drawRect(rect.adjusted(0, 0, -1, -1));
- p->restore();
- return;
-
- case PE_PanelMenuBar:
- break;
-
- case PE_FrameDockWidget:
- if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(option))
- {
- themeNumber = QWindowsXPStylePrivate::WindowTheme;
- if (flags & State_Active)
- stateId = FS_ACTIVE;
- else
- stateId = FS_INACTIVE;
-
- int fwidth = proxy()->pixelMetric(PM_DockWidgetFrameWidth, frm, widget);
-
- XPThemeData theme(widget, p, themeNumber, 0, stateId);
- if (!theme.isValid())
- break;
- theme.rect = QRect(frm->rect.x(), frm->rect.y(), frm->rect.x()+fwidth, frm->rect.height()-fwidth); theme.partId = WP_SMALLFRAMELEFT;
- d->drawBackground(theme);
- theme.rect = QRect(frm->rect.width()-fwidth, frm->rect.y(), fwidth, frm->rect.height()-fwidth);
- theme.partId = WP_SMALLFRAMERIGHT;
- d->drawBackground(theme);
- theme.rect = QRect(frm->rect.x(), frm->rect.bottom()-fwidth+1, frm->rect.width(), fwidth);
- theme.partId = WP_SMALLFRAMEBOTTOM;
- d->drawBackground(theme);
- return;
- }
- break;
-
- case PE_IndicatorHeaderArrow:
- {
-#if 0 // XP theme engine doesn't know about this :(
- name = QWindowsXPStylePrivate::HeaderTheme;
- partId = HP_HEADERSORTARROW;
- if (flags & State_Down)
- stateId = HSAS_SORTEDDOWN;
- else
- stateId = HSAS_SORTEDUP;
-#else
- if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
- p->save();
- p->setPen(option->palette.dark().color());
- p->translate(0, option->rect.height()/2 - 4);
- if (header->sortIndicator & QStyleOptionHeader::SortUp) { // invert logic to follow Windows style guide
- p->drawLine(option->rect.x(), option->rect.y(), option->rect.x()+8, option->rect.y());
- p->drawLine(option->rect.x()+1, option->rect.y()+1, option->rect.x()+7, option->rect.y()+1);
- p->drawLine(option->rect.x()+2, option->rect.y()+2, option->rect.x()+6, option->rect.y()+2);
- p->drawLine(option->rect.x()+3, option->rect.y()+3, option->rect.x()+5, option->rect.y()+3);
- p->drawPoint(option->rect.x()+4, option->rect.y()+4);
- } else if(header->sortIndicator & QStyleOptionHeader::SortDown) {
- p->drawLine(option->rect.x(), option->rect.y()+4, option->rect.x()+8, option->rect.y()+4);
- p->drawLine(option->rect.x()+1, option->rect.y()+3, option->rect.x()+7, option->rect.y()+3);
- p->drawLine(option->rect.x()+2, option->rect.y()+2, option->rect.x()+6, option->rect.y()+2);
- p->drawLine(option->rect.x()+3, option->rect.y()+1, option->rect.x()+5, option->rect.y()+1);
- p->drawPoint(option->rect.x()+4, option->rect.y());
- }
- p->restore();
- return;
- }
-#endif
- }
- break;
-
- case PE_FrameStatusBarItem:
- themeNumber = QWindowsXPStylePrivate::StatusTheme;
- partId = SP_PANE;
- break;
-
- case PE_FrameGroupBox:
- themeNumber = QWindowsXPStylePrivate::ButtonTheme;
- partId = BP_GROUPBOX;
- if (!(flags & State_Enabled))
- stateId = GBS_DISABLED;
- else
- stateId = GBS_NORMAL;
- if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
- if (frame->features & QStyleOptionFrame::Flat) {
- // Windows XP does not have a theme part for a flat GroupBox, paint it with the windows style
- QRect fr = frame->rect;
- QPoint p1(fr.x(), fr.y() + 1);
- QPoint p2(fr.x() + fr.width(), p1.y() + 1);
- rect = QRect(p1, p2);
- themeNumber = -1;
- }
- }
- break;
-
- case PE_IndicatorProgressChunk:
- {
- Qt::Orientation orient = Qt::Horizontal;
- bool inverted = false;
- if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
- orient = pb->orientation;
- inverted = pb->invertedAppearance;
- }
- if (orient == Qt::Horizontal) {
- partId = PP_CHUNK;
- rect = QRect(option->rect.x(), option->rect.y(), option->rect.width(), option->rect.height() );
- if (inverted && option->direction == Qt::LeftToRight)
- hMirrored = true;
- } else {
- partId = PP_CHUNKVERT;
- rect = QRect(option->rect.x(), option->rect.y(), option->rect.width(), option->rect.height());
- }
- themeNumber = QWindowsXPStylePrivate::ProgressTheme;
- stateId = 1;
- }
- break;
-
- case PE_FrameWindow:
- if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(option))
- {
- themeNumber = QWindowsXPStylePrivate::WindowTheme;
- if (flags & State_Active)
- stateId = FS_ACTIVE;
- else
- stateId = FS_INACTIVE;
-
- int fwidth = frm->lineWidth + frm->midLineWidth;
-
- XPThemeData theme(0, p, themeNumber, 0, stateId);
- if (!theme.isValid())
- break;
-
- // May fail due to too-large buffers for large widgets, fall back to Windows style.
- theme.rect = QRect(option->rect.x(), option->rect.y()+fwidth, option->rect.x()+fwidth, option->rect.height()-fwidth);
- theme.partId = WP_FRAMELEFT;
- if (!d->drawBackground(theme)) {
- QWindowsStyle::drawPrimitive(pe, option, p, widget);
- return;
- }
- theme.rect = QRect(option->rect.width()-fwidth, option->rect.y()+fwidth, fwidth, option->rect.height()-fwidth);
- theme.partId = WP_FRAMERIGHT;
- if (!d->drawBackground(theme)) {
- QWindowsStyle::drawPrimitive(pe, option, p, widget);
- return;
- }
- theme.rect = QRect(option->rect.x(), option->rect.height()-fwidth, option->rect.width(), fwidth);
- theme.partId = WP_FRAMEBOTTOM;
- if (!d->drawBackground(theme)) {
- QWindowsStyle::drawPrimitive(pe, option, p, widget);
- return;
- }
- theme.rect = QRect(option->rect.x(), option->rect.y(), option->rect.width(), option->rect.y()+fwidth);
- theme.partId = WP_CAPTION;
- if (!d->drawBackground(theme))
- QWindowsStyle::drawPrimitive(pe, option, p, widget);
- return;
- }
- break;
-
- case PE_IndicatorBranch:
- {
- static const int decoration_size = 9;
- int mid_h = option->rect.x() + option->rect.width() / 2;
- int mid_v = option->rect.y() + option->rect.height() / 2;
- int bef_h = mid_h;
- int bef_v = mid_v;
- int aft_h = mid_h;
- int aft_v = mid_v;
- QBrush brush(option->palette.dark().color(), Qt::Dense4Pattern);
- if (option->state & State_Item) {
- if (option->direction == Qt::RightToLeft)
- p->fillRect(option->rect.left(), mid_v, bef_h - option->rect.left(), 1, brush);
- else
- p->fillRect(aft_h, mid_v, option->rect.right() - aft_h + 1, 1, brush);
- }
- if (option->state & State_Sibling)
- p->fillRect(mid_h, aft_v, 1, option->rect.bottom() - aft_v + 1, brush);
- if (option->state & (State_Open | State_Children | State_Item | State_Sibling))
- p->fillRect(mid_h, option->rect.y(), 1, bef_v - option->rect.y(), brush);
- if (option->state & State_Children) {
- int delta = decoration_size / 2;
- bef_h -= delta;
- bef_v -= delta;
- aft_h += delta;
- aft_v += delta;
- XPThemeData theme(0, p, QWindowsXPStylePrivate::XpTreeViewTheme);
- theme.rect = QRect(bef_h, bef_v, decoration_size, decoration_size);
- theme.partId = TVP_GLYPH;
- theme.stateId = flags & QStyle::State_Open ? GLPS_OPENED : GLPS_CLOSED;
- d->drawBackground(theme);
- }
- }
- return;
-
- case PE_IndicatorToolBarSeparator:
- if (option->rect.height() < 3) {
- // XP style requires a few pixels for the separator
- // to be visible.
- QWindowsStyle::drawPrimitive(pe, option, p, widget);
- return;
- }
- themeNumber = QWindowsXPStylePrivate::ToolBarTheme;
- partId = TP_SEPARATOR;
-
- if (option->state & State_Horizontal)
- partId = TP_SEPARATOR;
- else
- partId = TP_SEPARATORVERT;
-
- break;
-
- case PE_IndicatorToolBarHandle:
-
- themeNumber = QWindowsXPStylePrivate::RebarTheme;
- partId = RP_GRIPPER;
- if (option->state & State_Horizontal) {
- partId = RP_GRIPPER;
- rect.adjust(0, 0, -2, 0);
- }
- else {
- partId = RP_GRIPPERVERT;
- rect.adjust(0, 0, 0, -2);
- }
- break;
-
- case PE_IndicatorItemViewItemCheck: {
- QStyleOptionButton button;
- button.QStyleOption::operator=(*option);
- button.state &= ~State_MouseOver;
- proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, p, widget);
- return;
- }
-
- default:
- break;
- }
-
- XPThemeData theme(widget, p, themeNumber, partId, stateId, rect);
- if (!theme.isValid()) {
- QWindowsStyle::drawPrimitive(pe, option, p, widget);
- return;
- }
- theme.mirrorHorizontally = hMirrored;
- theme.mirrorVertically = vMirrored;
- theme.noBorder = noBorder;
- theme.noContent = noContent;
- theme.rotate = rotate;
- d->drawBackground(theme);
-}
-
-/*!
- \reimp
-*/
-void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *p,
- const QWidget *widget) const
-{
- QWindowsXPStylePrivate *d = const_cast<QWindowsXPStylePrivate*>(d_func());
- if (!QWindowsXPStylePrivate::useXP()) {
- QWindowsStyle::drawControl(element, option, p, widget);
- return;
- }
-
- QRect rect(option->rect);
- State flags = option->state;
-
- int rotate = 0;
- bool hMirrored = false;
- bool vMirrored = false;
-
- int themeNumber = -1;
- int partId = 0;
- int stateId = 0;
- switch (element) {
- case CE_SizeGrip:
- {
- themeNumber = QWindowsXPStylePrivate::StatusTheme;
- partId = SP_GRIPPER;
- XPThemeData theme(0, p, themeNumber, partId, 0);
- QSize size = (theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize();
- size.rheight()--;
- if (const QStyleOptionSizeGrip *sg = qstyleoption_cast<const QStyleOptionSizeGrip *>(option)) {
- switch (sg->corner) {
- case Qt::BottomRightCorner:
- rect = QRect(QPoint(rect.right() - size.width(), rect.bottom() - size.height()), size);
- break;
- case Qt::BottomLeftCorner:
- rect = QRect(QPoint(rect.left() + 1, rect.bottom() - size.height()), size);
- hMirrored = true;
- break;
- case Qt::TopRightCorner:
- rect = QRect(QPoint(rect.right() - size.width(), rect.top() + 1), size);
- vMirrored = true;
- break;
- case Qt::TopLeftCorner:
- rect = QRect(rect.topLeft() + QPoint(1, 1), size);
- hMirrored = vMirrored = true;
- }
- }
- }
- break;
-
- case CE_HeaderSection:
- themeNumber = QWindowsXPStylePrivate::HeaderTheme;
- partId = HP_HEADERITEM;
- if (flags & State_Sunken)
- stateId = HIS_PRESSED;
- else if (flags & State_MouseOver)
- stateId = HIS_HOT;
- else
- stateId = HIS_NORMAL;
- break;
-
- case CE_Splitter:
- p->eraseRect(option->rect);
- return;
-
- case CE_PushButtonBevel:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option))
- {
- themeNumber = QWindowsXPStylePrivate::ButtonTheme;
- partId = BP_PUSHBUTTON;
- bool justFlat = ((btn->features & QStyleOptionButton::Flat) && !(flags & (State_On|State_Sunken)))
- || ((btn->features & QStyleOptionButton::CommandLinkButton)
- && !(flags & State_MouseOver)
- && !(btn->features & QStyleOptionButton::DefaultButton));
- if (!(flags & State_Enabled) && !(btn->features & QStyleOptionButton::Flat))
- stateId = PBS_DISABLED;
- else if (justFlat)
- ;
- else if (flags & (State_Sunken | State_On))
- stateId = PBS_PRESSED;
- else if (flags & State_MouseOver)
- stateId = PBS_HOT;
- else if (btn->features & QStyleOptionButton::DefaultButton)
- stateId = PBS_DEFAULTED;
- else
- stateId = PBS_NORMAL;
-
- if (!justFlat) {
- XPThemeData theme(widget, p, themeNumber, partId, stateId, rect);
- d->drawBackground(theme);
- }
-
- if (btn->features & QStyleOptionButton::HasMenu) {
- int mbiw = 0, mbih = 0;
- XPThemeData theme(widget, 0,
- QWindowsXPStylePrivate::ToolBarTheme,
- TP_SPLITBUTTONDROPDOWN);
- if (theme.isValid()) {
- const QSize size = (theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize();
- mbiw = size.width();
- mbih = size.height();
- }
-
- QRect ir = btn->rect;
- QStyleOptionButton newBtn = *btn;
- newBtn.rect = QRect(ir.right() - mbiw - 1, 1 + (ir.height()/2) - (mbih/2), mbiw, mbih);
- proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget);
- }
- return;
- }
- break;
- case CE_TabBarTab:
- if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option))
- {
- stateId = tab->state & State_Enabled ? TIS_NORMAL : TIS_DISABLED;
- }
- break;
-
- case CE_TabBarTabShape:
- if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option))
- {
- themeNumber = QWindowsXPStylePrivate::TabTheme;
- bool isDisabled = !(tab->state & State_Enabled);
- bool hasFocus = tab->state & State_HasFocus;
- bool isHot = tab->state & State_MouseOver;
- bool selected = tab->state & State_Selected;
- bool lastTab = tab->position == QStyleOptionTab::End;
- bool firstTab = tab->position == QStyleOptionTab::Beginning;
- bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab;
- bool leftAligned = proxy()->styleHint(SH_TabBar_Alignment, tab, widget) == Qt::AlignLeft;
- bool centerAligned = proxy()->styleHint(SH_TabBar_Alignment, tab, widget) == Qt::AlignCenter;
- int borderThickness = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget);
- int tabOverlap = proxy()->pixelMetric(PM_TabBarTabOverlap, option, widget);
-
- if (isDisabled)
- stateId = TIS_DISABLED;
- else if (selected)
- stateId = TIS_SELECTED;
- else if (hasFocus)
- stateId = TIS_FOCUSED;
- else if (isHot)
- stateId = TIS_HOT;
- else
- stateId = TIS_NORMAL;
-
- // Selecting proper part depending on position
- if (firstTab || onlyOne) {
- if (leftAligned) {
- partId = TABP_TABITEMLEFTEDGE;
- } else if (centerAligned) {
- partId = TABP_TABITEM;
- } else { // rightAligned
- partId = TABP_TABITEMRIGHTEDGE;
- }
- } else {
- partId = TABP_TABITEM;
- }
-
- if (tab->direction == Qt::RightToLeft
- && (tab->shape == QTabBar::RoundedNorth
- || tab->shape == QTabBar::RoundedSouth)) {
- bool temp = firstTab;
- firstTab = lastTab;
- lastTab = temp;
- }
- bool begin = firstTab || onlyOne;
- bool end = lastTab || onlyOne;
- switch (tab->shape) {
- case QTabBar::RoundedNorth:
- if (selected)
- rect.adjust(begin ? 0 : -tabOverlap, 0, end ? 0 : tabOverlap, borderThickness);
- else
- rect.adjust(begin? tabOverlap : 0, tabOverlap, end ? -tabOverlap : 0, 0);
- break;
- case QTabBar::RoundedSouth:
- //vMirrored = true;
- rotate = 180; // Not 100% correct, but works
- if (selected)
- rect.adjust(begin ? 0 : -tabOverlap , -borderThickness, end ? 0 : tabOverlap, 0);
- else
- rect.adjust(begin ? tabOverlap : 0, 0, end ? -tabOverlap : 0 , -tabOverlap);
- break;
- case QTabBar::RoundedEast:
- rotate = 90;
- if (selected) {
- rect.adjust(-borderThickness, begin ? 0 : -tabOverlap, 0, end ? 0 : tabOverlap);
- }else{
- rect.adjust(0, begin ? tabOverlap : 0, -tabOverlap, end ? -tabOverlap : 0);
- }
- break;
- case QTabBar::RoundedWest:
- hMirrored = true;
- rotate = 90;
- if (selected) {
- rect.adjust(0, begin ? 0 : -tabOverlap, borderThickness, end ? 0 : tabOverlap);
- }else{
- rect.adjust(tabOverlap, begin ? tabOverlap : 0, 0, end ? -tabOverlap : 0);
- }
- break;
- default:
- themeNumber = -1; // Do our own painting for triangular
- break;
- }
-
- if (!selected) {
- switch (tab->shape) {
- case QTabBar::RoundedNorth:
- rect.adjust(0,0, 0,-1);
- break;
- case QTabBar::RoundedSouth:
- rect.adjust(0,1, 0,0);
- break;
- case QTabBar::RoundedEast:
- rect.adjust( 1,0, 0,0);
- break;
- case QTabBar::RoundedWest:
- rect.adjust(0,0, -1,0);
- break;
- default:
- break;
- }
- }
- }
- break;
-
- case CE_ProgressBarGroove:
- {
- Qt::Orientation orient = Qt::Horizontal;
- if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option))
- orient = pb->orientation;
- partId = (orient == Qt::Horizontal) ? PP_BAR : PP_BARVERT;
- themeNumber = QWindowsXPStylePrivate::ProgressTheme;
- stateId = 1;
- }
- break;
-
- case CE_MenuEmptyArea:
- case CE_MenuItem:
- if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option))
- {
- int tab = menuitem->tabWidth;
- bool dis = !(menuitem->state & State_Enabled);
- bool act = menuitem->state & State_Selected;
- bool checkable = menuitem->menuHasCheckableItems;
- bool checked = checkable ? menuitem->checked : false;
-
- // windows always has a check column, regardless whether we have an icon or not
- int checkcol = qMax(menuitem->maxIconWidth, 12);
-
- int x, y, w, h;
- rect.getRect(&x, &y, &w, &h);
-
- QBrush fill = menuitem->palette.brush(act ? QPalette::Highlight : QPalette::Button);
- p->fillRect(rect, fill);
-
- if (element == CE_MenuEmptyArea)
- break;
-
- // draw separator -------------------------------------------------
- if (menuitem->menuItemType == QStyleOptionMenuItem::Separator) {
- int yoff = y-1 + h / 2;
- p->setPen(menuitem->palette.dark().color());
- p->drawLine(x, yoff, x+w, yoff);
- ++yoff;
- p->setPen(menuitem->palette.light().color());
- p->drawLine(x, yoff, x+w, yoff);
- return;
- }
-
- int xpos = x;
-
- // draw icon ------------------------------------------------------
- if (!menuitem->icon.isNull()) {
- QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
- if (act && !dis)
- mode = QIcon::Active;
- QPixmap pixmap = checked ?
- menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode, QIcon::On) :
- menuitem->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), mode);
- const int pixw = pixmap.width() / pixmap.devicePixelRatio();
- const int pixh = pixmap.height() / pixmap.devicePixelRatio();
- QRect iconRect(0, 0, pixw, pixh);
- iconRect.moveCenter(QRect(xpos, y, checkcol, h).center());
- QRect vIconRect = visualRect(option->direction, option->rect, iconRect);
- p->setPen(menuitem->palette.text().color());
- p->setBrush(Qt::NoBrush);
- if (checked)
- p->drawRect(vIconRect.adjusted(-1, -1, 0, 0));
- p->drawPixmap(vIconRect.topLeft(), pixmap);
-
- // draw checkmark -------------------------------------------------
- } else if (checked) {
- QStyleOptionMenuItem newMi = *menuitem;
- newMi.state = State_None;
- if (!dis)
- newMi.state |= State_Enabled;
- if (act)
- newMi.state |= State_On;
-
- QRect checkMarkRect = QRect(menuitem->rect.x() + windowsItemFrame,
- menuitem->rect.y() + windowsItemFrame,
- checkcol - 2 * windowsItemFrame,
- menuitem->rect.height() - 2*windowsItemFrame);
- newMi.rect = visualRect(option->direction, option->rect, checkMarkRect);
- proxy()->drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, widget);
- }
-
- QColor textColor = dis ? menuitem->palette.text().color() :
- act ? menuitem->palette.highlightedText().color() : menuitem->palette.buttonText().color();
- p->setPen(textColor);
-
- // draw text ------------------------------------------------------
- int xm = windowsItemFrame + checkcol + windowsItemHMargin;
- xpos = menuitem->rect.x() + xm;
- QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
- QRect vTextRect = visualRect(option->direction, option->rect, textRect);
- QString s = menuitem->text;
- if (!s.isEmpty()) {
- p->save();
- int t = s.indexOf(QLatin1Char('\t'));
- int text_flags = Qt::AlignVCenter|Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine | Qt::AlignLeft;
- if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
- text_flags |= Qt::TextHideMnemonic;
- // draw tab text ----------------
- if (t >= 0) {
- QRect vShortcutRect = visualRect(option->direction, option->rect, QRect(textRect.topRight(), menuitem->rect.bottomRight()));
- if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) {
- p->setPen(menuitem->palette.light().color());
- p->drawText(vShortcutRect.adjusted(1,1,1,1), text_flags, s.mid(t + 1));
- p->setPen(textColor);
- }
- p->drawText(vShortcutRect, text_flags, s.mid(t + 1));
- s = s.left(t);
- }
- QFont font = menuitem->font;
- if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
- font.setBold(true);
- p->setFont(font);
- if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) {
- p->setPen(menuitem->palette.light().color());
- p->drawText(vTextRect.adjusted(1,1,1,1), text_flags, s.left(t));
- p->setPen(textColor);
- }
- p->drawText(vTextRect, text_flags, s);
- p->restore();
- }
-
- // draw sub menu arrow --------------------------------------------
- if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) {
- int dim = (h - 2) / 2;
- PrimitiveElement arrow;
- arrow = (option->direction == Qt::RightToLeft) ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
- xpos = x + w - windowsArrowHMargin - windowsItemFrame - dim;
- QRect vSubMenuRect = visualRect(option->direction, option->rect, QRect(xpos, y + h / 2 - dim / 2, dim, dim));
- QStyleOptionMenuItem newMI = *menuitem;
- newMI.rect = vSubMenuRect;
- newMI.state = dis ? State_None : State_Enabled;
- if (act)
- newMI.palette.setColor(QPalette::ButtonText, newMI.palette.highlightedText().color());
- proxy()->drawPrimitive(arrow, &newMI, p, widget);
- }
- }
- return;
-
- case CE_MenuBarItem:
- if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option))
- {
- if (mbi->menuItemType == QStyleOptionMenuItem::DefaultItem)
- break;
-
- bool act = mbi->state & State_Selected;
- bool dis = !(mbi->state & State_Enabled);
-
- QBrush fill = mbi->palette.brush(act ? QPalette::Highlight : QPalette::Button);
- QPalette::ColorRole textRole = dis ? QPalette::Text:
- act ? QPalette::HighlightedText : QPalette::ButtonText;
- QPixmap pix = mbi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize, option, widget), QIcon::Normal);
-
- uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
- if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget))
- alignment |= Qt::TextHideMnemonic;
-
- p->fillRect(rect, fill);
- if (!pix.isNull())
- drawItemPixmap(p, mbi->rect, alignment, pix);
- else
- drawItemText(p, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled, mbi->text, textRole);
- }
- return;
-#if QT_CONFIG(dockwidget)
- case CE_DockWidgetTitle:
- if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option))
- {
- int buttonMargin = 4;
- int mw = proxy()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, dwOpt, widget);
- int fw = proxy()->pixelMetric(PM_DockWidgetFrameWidth, dwOpt, widget);
- bool isFloating = widget && widget->isWindow();
- bool isActive = dwOpt->state & State_Active;
-
- const bool verticalTitleBar = dwOpt->verticalTitleBar;
-
- if (verticalTitleBar) {
- rect = rect.transposed();
-
- p->translate(rect.left() - 1, rect.top() + rect.width());
- p->rotate(-90);
- p->translate(-rect.left() + 1, -rect.top());
- }
- QRect r = rect.adjusted(0, 2, -1, -3);
- QRect titleRect = r;
-
- if (dwOpt->closable) {
- QSize sz = proxy()->standardIcon(QStyle::SP_TitleBarCloseButton, dwOpt, widget).actualSize(QSize(10, 10));
- titleRect.adjust(0, 0, -sz.width() - mw - buttonMargin, 0);
- }
-
- if (dwOpt->floatable) {
- QSize sz = proxy()->standardIcon(QStyle::SP_TitleBarMaxButton, dwOpt, widget).actualSize(QSize(10, 10));
- titleRect.adjust(0, 0, -sz.width() - mw - buttonMargin, 0);
- }
-
- if (isFloating) {
- titleRect.adjust(0, -fw, 0, 0);
- if (widget != 0 && widget->windowIcon().cacheKey() != QApplication::windowIcon().cacheKey())
- titleRect.adjust(titleRect.height() + mw, 0, 0, 0);
- } else {
- titleRect.adjust(mw, 0, 0, 0);
- if (!dwOpt->floatable && !dwOpt->closable)
- titleRect.adjust(0, 0, -mw, 0);
- }
-
- if (!verticalTitleBar)
- titleRect = visualRect(dwOpt->direction, r, titleRect);
-
- if (!isFloating) {
- QPen oldPen = p->pen();
- QString titleText = p->fontMetrics().elidedText(dwOpt->title, Qt::ElideRight, titleRect.width());
- p->setPen(dwOpt->palette.color(QPalette::Dark));
- p->drawRect(r);
-
- if (!titleText.isEmpty()) {
- drawItemText(p, titleRect,
- Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, dwOpt->palette,
- dwOpt->state & State_Enabled, titleText,
- QPalette::WindowText);
- }
-
- p->setPen(oldPen);
- } else {
- themeNumber = QWindowsXPStylePrivate::WindowTheme;
- if (isActive)
- stateId = CS_ACTIVE;
- else
- stateId = CS_INACTIVE;
-
- int titleHeight = rect.height() - 2;
- rect = rect.adjusted(-fw, -fw, fw, 0);
-
- XPThemeData theme(widget, p, themeNumber, 0, stateId);
- if (!theme.isValid())
- break;
-
- // Draw small type title bar
- theme.rect = rect;
- theme.partId = WP_SMALLCAPTION;
- d->drawBackground(theme);
-
- // Figure out maximal button space on title bar
-
- QIcon ico = widget->windowIcon();
- bool hasIcon = (ico.cacheKey() != QApplication::windowIcon().cacheKey());
- if (hasIcon) {
- QPixmap pxIco = ico.pixmap(titleHeight);
- if (!verticalTitleBar && dwOpt->direction == Qt::RightToLeft)
- p->drawPixmap(rect.width() - titleHeight - pxIco.width(), rect.bottom() - titleHeight - 2, pxIco);
- else
- p->drawPixmap(fw, rect.bottom() - titleHeight - 2, pxIco);
- }
- if (!dwOpt->title.isEmpty()) {
- QPen oldPen = p->pen();
- QFont oldFont = p->font();
- QFont titleFont = oldFont;
- titleFont.setBold(true);
- p->setFont(titleFont);
- QString titleText
- = p->fontMetrics().elidedText(dwOpt->title, Qt::ElideRight, titleRect.width());
-
- int result = TST_NONE;
- GetThemeEnumValue(theme.handle(), WP_SMALLCAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWTYPE, &result);
- if (result != TST_NONE) {
- COLORREF textShadowRef;
- GetThemeColor(theme.handle(), WP_SMALLCAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWCOLOR, &textShadowRef);
- QColor textShadow = qRgb(GetRValue(textShadowRef), GetGValue(textShadowRef), GetBValue(textShadowRef));
- p->setPen(textShadow);
- drawItemText(p, titleRect.adjusted(1, 1, 1, 1),
- Qt::AlignLeft | Qt::AlignBottom, dwOpt->palette,
- dwOpt->state & State_Enabled, titleText);
- }
-
- COLORREF captionText = GetSysColor(isActive ? COLOR_CAPTIONTEXT : COLOR_INACTIVECAPTIONTEXT);
- QColor textColor = qRgb(GetRValue(captionText), GetGValue(captionText), GetBValue(captionText));
- p->setPen(textColor);
- drawItemText(p, titleRect,
- Qt::AlignLeft | Qt::AlignBottom, dwOpt->palette,
- dwOpt->state & State_Enabled, titleText);
- p->setFont(oldFont);
- p->setPen(oldPen);
- }
-
- }
-
- return;
- }
- break;
-#endif // QT_CONFIG(dockwidget)
-#if QT_CONFIG(rubberband)
- case CE_RubberBand:
- if (qstyleoption_cast<const QStyleOptionRubberBand *>(option)) {
- QColor highlight = option->palette.color(QPalette::Active, QPalette::Highlight);
- p->save();
- p->setPen(highlight.darker(120));
- QColor dimHighlight(qMin(highlight.red()/2 + 110, 255),
- qMin(highlight.green()/2 + 110, 255),
- qMin(highlight.blue()/2 + 110, 255),
- (widget && widget->isTopLevel())? 255 : 127);
- p->setBrush(dimHighlight);
- p->drawRect(option->rect.adjusted(0, 0, -1, -1));
- p->restore();
- return;
- }
- break;
-#endif // QT_CONFIG(rubberband)
- case CE_HeaderEmptyArea:
- if (option->state & State_Horizontal)
- {
- themeNumber = QWindowsXPStylePrivate::HeaderTheme;
- stateId = HIS_NORMAL;
- }
- else {
- QWindowsStyle::drawControl(CE_HeaderEmptyArea, option, p, widget);
- return;
- }
- break;
- default:
- break;
- }
-
- XPThemeData theme(widget, p, themeNumber, partId, stateId, rect);
- if (!theme.isValid()) {
- QWindowsStyle::drawControl(element, option, p, widget);
- return;
- }
-
- theme.rotate = rotate;
- theme.mirrorHorizontally = hMirrored;
- theme.mirrorVertically = vMirrored;
- d->drawBackground(theme);
-}
-
-QRect QWindowsXPStylePrivate::scrollBarGripperBounds(QStyle::State flags, const QWidget *widget, XPThemeData *theme)
-{
- const bool horizontal = flags & QStyle::State_Horizontal;
- const qreal factor = QWindowsStylePrivate::nativeMetricScaleFactor(widget);
- const QMargins contentsMargin =
- (theme->margins(theme->rect, TMT_SIZINGMARGINS) * factor).toMargins();
- theme->partId = horizontal ? SBP_GRIPPERHORZ : SBP_GRIPPERVERT;
- const QSize size = (theme->size() * factor).toSize();
-
- const int hSpace = theme->rect.width() - size.width();
- const int vSpace = theme->rect.height() - size.height();
- const bool sufficientSpace = (horizontal && hSpace > (contentsMargin.left() + contentsMargin.right()))
- || vSpace > contentsMargin.top() + contentsMargin.bottom();
- return sufficientSpace ? QRect(theme->rect.topLeft() + QPoint(hSpace, vSpace) / 2, size) : QRect();
-}
-
-/*!
- \reimp
-*/
-void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *option,
- QPainter *p, const QWidget *widget) const
-{
- QWindowsXPStylePrivate *d = const_cast<QWindowsXPStylePrivate*>(d_func());
-
- if (!QWindowsXPStylePrivate::useXP()) {
- QWindowsStyle::drawComplexControl(cc, option, p, widget);
- return;
- }
-
- State flags = option->state;
- SubControls sub = option->subControls;
- QRect r = option->rect;
-
- int partId = 0;
- int stateId = 0;
- if (widget && widget->testAttribute(Qt::WA_UnderMouse) && widget->isActiveWindow())
- flags |= State_MouseOver;
-
- switch (cc) {
-#if QT_CONFIG(spinbox)
- case CC_SpinBox:
- if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(option))
- {
- XPThemeData theme(widget, p, QWindowsXPStylePrivate::SpinTheme);
-
- if (sb->frame && (sub & SC_SpinBoxFrame)) {
- partId = EP_EDITTEXT;
- if (!(flags & State_Enabled))
- stateId = ETS_DISABLED;
- else if (flags & State_HasFocus)
- stateId = ETS_FOCUSED;
- else
- stateId = ETS_NORMAL;
-
- XPThemeData ftheme(widget, p, QWindowsXPStylePrivate::EditTheme,
- partId, stateId, r);
- ftheme.noContent = true;
- d->drawBackground(ftheme);
- }
- if (sub & SC_SpinBoxUp) {
- theme.rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget);
- partId = SPNP_UP;
- if (!(sb->stepEnabled & QAbstractSpinBox::StepUpEnabled) || !(flags & State_Enabled))
- stateId = UPS_DISABLED;
- else if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_Sunken))
- stateId = UPS_PRESSED;
- else if (sb->activeSubControls == SC_SpinBoxUp && (sb->state & State_MouseOver))
- stateId = UPS_HOT;
- else
- stateId = UPS_NORMAL;
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
- if (sub & SC_SpinBoxDown) {
- theme.rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);
- partId = SPNP_DOWN;
- if (!(sb->stepEnabled & QAbstractSpinBox::StepDownEnabled) || !(flags & State_Enabled))
- stateId = DNS_DISABLED;
- else if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_Sunken))
- stateId = DNS_PRESSED;
- else if (sb->activeSubControls == SC_SpinBoxDown && (sb->state & State_MouseOver))
- stateId = DNS_HOT;
- else
- stateId = DNS_NORMAL;
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
- }
- break;
-#endif // QT_CONFIG(spinbox)
-#if QT_CONFIG(combobox)
- case CC_ComboBox:
- if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option))
- {
- if (sub & SC_ComboBoxEditField) {
- if (cmb->frame) {
- partId = EP_EDITTEXT;
- if (!(flags & State_Enabled))
- stateId = ETS_DISABLED;
- else if (flags & State_HasFocus)
- stateId = ETS_FOCUSED;
- else
- stateId = ETS_NORMAL;
- XPThemeData theme(widget, p, QWindowsXPStylePrivate::EditTheme, partId, stateId, r);
- d->drawBackground(theme);
- } else {
- QBrush editBrush = cmb->palette.brush(QPalette::Base);
- p->fillRect(option->rect, editBrush);
- }
- if (!cmb->editable) {
- QRect re = proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxEditField, widget);
- if (option->state & State_HasFocus) {
- p->fillRect(re, option->palette.highlight());
- p->setPen(option->palette.highlightedText().color());
- p->setBackground(option->palette.highlight());
- } else {
- p->fillRect(re, option->palette.base());
- p->setPen(option->palette.text().color());
- p->setBackground(option->palette.base());
- }
- }
- }
-
- if (sub & SC_ComboBoxArrow) {
- XPThemeData theme(widget, p, QWindowsXPStylePrivate::ComboboxTheme);
- theme.rect = proxy()->subControlRect(CC_ComboBox, option, SC_ComboBoxArrow, widget);
- partId = CP_DROPDOWNBUTTON;
- if (!(flags & State_Enabled))
- stateId = CBXS_DISABLED;
- else if (cmb->activeSubControls == SC_ComboBoxArrow && (cmb->state & State_Sunken))
- stateId = CBXS_PRESSED;
- else if (cmb->activeSubControls == SC_ComboBoxArrow && (cmb->state & State_MouseOver))
- stateId = CBXS_HOT;
- else
- stateId = CBXS_NORMAL;
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
- }
- break;
-#endif // QT_CONFIG(combobox)
- case CC_ScrollBar:
- if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(option))
- {
- XPThemeData theme(widget, p, QWindowsXPStylePrivate::ScrollBarTheme);
- bool maxedOut = (scrollbar->maximum == scrollbar->minimum);
- if (maxedOut)
- flags &= ~State_Enabled;
-
- bool isHorz = flags & State_Horizontal;
- bool isRTL = option->direction == Qt::RightToLeft;
- if (sub & SC_ScrollBarAddLine) {
- theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddLine, widget);
- partId = SBP_ARROWBTN;
- if (!(flags & State_Enabled))
- stateId = (isHorz ? (isRTL ? ABS_LEFTDISABLED : ABS_RIGHTDISABLED) : ABS_DOWNDISABLED);
- else if (scrollbar->activeSubControls & SC_ScrollBarAddLine && (scrollbar->state & State_Sunken))
- stateId = (isHorz ? (isRTL ? ABS_LEFTPRESSED : ABS_RIGHTPRESSED) : ABS_DOWNPRESSED);
- else if (scrollbar->activeSubControls & SC_ScrollBarAddLine && (scrollbar->state & State_MouseOver))
- stateId = (isHorz ? (isRTL ? ABS_LEFTHOT : ABS_RIGHTHOT) : ABS_DOWNHOT);
- else
- stateId = (isHorz ? (isRTL ? ABS_LEFTNORMAL : ABS_RIGHTNORMAL) : ABS_DOWNNORMAL);
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
- if (sub & SC_ScrollBarSubLine) {
- theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubLine, widget);
- partId = SBP_ARROWBTN;
- if (!(flags & State_Enabled))
- stateId = (isHorz ? (isRTL ? ABS_RIGHTDISABLED : ABS_LEFTDISABLED) : ABS_UPDISABLED);
- else if (scrollbar->activeSubControls & SC_ScrollBarSubLine && (scrollbar->state & State_Sunken))
- stateId = (isHorz ? (isRTL ? ABS_RIGHTPRESSED : ABS_LEFTPRESSED) : ABS_UPPRESSED);
- else if (scrollbar->activeSubControls & SC_ScrollBarSubLine && (scrollbar->state & State_MouseOver))
- stateId = (isHorz ? (isRTL ? ABS_RIGHTHOT : ABS_LEFTHOT) : ABS_UPHOT);
- else
- stateId = (isHorz ? (isRTL ? ABS_RIGHTNORMAL : ABS_LEFTNORMAL) : ABS_UPNORMAL);
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
- if (maxedOut) {
- theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
- theme.rect = theme.rect.united(proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget));
- theme.rect = theme.rect.united(proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget));
- partId = scrollbar->orientation == Qt::Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
- stateId = SCRBS_DISABLED;
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- } else {
- if (sub & SC_ScrollBarSubPage) {
- theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubPage, widget);
- partId = flags & State_Horizontal ? SBP_UPPERTRACKHORZ : SBP_UPPERTRACKVERT;
- if (!(flags & State_Enabled))
- stateId = SCRBS_DISABLED;
- else if (scrollbar->activeSubControls & SC_ScrollBarSubPage && (scrollbar->state & State_Sunken))
- stateId = SCRBS_PRESSED;
- else if (scrollbar->activeSubControls & SC_ScrollBarSubPage && (scrollbar->state & State_MouseOver))
- stateId = SCRBS_HOT;
- else
- stateId = SCRBS_NORMAL;
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
- if (sub & SC_ScrollBarAddPage) {
- theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddPage, widget);
- partId = flags & State_Horizontal ? SBP_LOWERTRACKHORZ : SBP_LOWERTRACKVERT;
- if (!(flags & State_Enabled))
- stateId = SCRBS_DISABLED;
- else if (scrollbar->activeSubControls & SC_ScrollBarAddPage && (scrollbar->state & State_Sunken))
- stateId = SCRBS_PRESSED;
- else if (scrollbar->activeSubControls & SC_ScrollBarAddPage && (scrollbar->state & State_MouseOver))
- stateId = SCRBS_HOT;
- else
- stateId = SCRBS_NORMAL;
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
- if (sub & SC_ScrollBarSlider) {
- theme.rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
- if (!(flags & State_Enabled))
- stateId = SCRBS_DISABLED;
- else if (scrollbar->activeSubControls & SC_ScrollBarSlider && (scrollbar->state & State_Sunken))
- stateId = SCRBS_PRESSED;
- else if (scrollbar->activeSubControls & SC_ScrollBarSlider && (scrollbar->state & State_MouseOver))
- stateId = SCRBS_HOT;
- else
- stateId = SCRBS_NORMAL;
-
- // Draw handle
- theme.partId = flags & State_Horizontal ? SBP_THUMBBTNHORZ : SBP_THUMBBTNVERT;
- theme.stateId = stateId;
- d->drawBackground(theme);
-
- const QRect gripperBounds = QWindowsXPStylePrivate::scrollBarGripperBounds(flags, widget, &theme);
- // Draw gripper if there is enough space
- if (!gripperBounds.isEmpty()) {
- p->save();
- theme.rect = gripperBounds;
- p->setClipRegion(d->region(theme));// Only change inside the region of the gripper
- d->drawBackground(theme); // Transparent gripper ontop of background
- p->restore();
- }
- }
- }
- }
- break;
-
-#if QT_CONFIG(slider)
- case CC_Slider:
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option))
- {
- XPThemeData theme(widget, p, QWindowsXPStylePrivate::TrackBarTheme);
- QRect slrect = slider->rect;
- QRegion tickreg = slrect;
- if (sub & SC_SliderGroove) {
- theme.rect = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget);
- if (slider->orientation == Qt::Horizontal) {
- partId = TKP_TRACK;
- stateId = TRS_NORMAL;
- theme.rect = QRect(slrect.left(), theme.rect.center().y() - 2, slrect.width(), 4);
- } else {
- partId = TKP_TRACKVERT;
- stateId = TRVS_NORMAL;
- theme.rect = QRect(theme.rect.center().x() - 2, slrect.top(), 4, slrect.height());
- }
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- tickreg -= theme.rect;
- }
- if (sub & SC_SliderTickmarks) {
- int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget);
- int ticks = slider->tickPosition;
- int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget);
- int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
- int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget);
- int interval = slider->tickInterval;
- if (interval <= 0) {
- interval = slider->singleStep;
- if (QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, interval,
- available)
- - QStyle::sliderPositionFromValue(slider->minimum, slider->maximum,
- 0, available) < 3)
- interval = slider->pageStep;
- }
- if (!interval)
- interval = 1;
- int fudge = len / 2;
- int pos;
- int bothOffset = (ticks & QSlider::TicksAbove && ticks & QSlider::TicksBelow) ? 1 : 0;
- p->setPen(d->sliderTickColor);
- QVarLengthArray<QLine, 32> lines;
- int v = slider->minimum;
- while (v <= slider->maximum + 1) {
- if (v == slider->maximum + 1 && interval == 1)
- break;
- const int v_ = qMin(v, slider->maximum);
- int tickLength = (v_ == slider->minimum || v_ >= slider->maximum) ? 4 : 3;
- pos = QStyle::sliderPositionFromValue(slider->minimum, slider->maximum,
- v_, available) + fudge;
- if (slider->orientation == Qt::Horizontal) {
- if (ticks & QSlider::TicksAbove)
- lines.append(QLine(pos, tickOffset - 1 - bothOffset,
- pos, tickOffset - 1 - bothOffset - tickLength));
-
- if (ticks & QSlider::TicksBelow)
- lines.append(QLine(pos, tickOffset + thickness + bothOffset,
- pos, tickOffset + thickness + bothOffset + tickLength));
- } else {
- if (ticks & QSlider::TicksAbove)
- lines.append(QLine(tickOffset - 1 - bothOffset, pos,
- tickOffset - 1 - bothOffset - tickLength, pos));
-
- if (ticks & QSlider::TicksBelow)
- lines.append(QLine(tickOffset + thickness + bothOffset, pos,
- tickOffset + thickness + bothOffset + tickLength, pos));
- }
- // in the case where maximum is max int
- int nextInterval = v + interval;
- if (nextInterval < v)
- break;
- v = nextInterval;
- }
- if (lines.size() > 0) {
- p->save();
- p->translate(slrect.topLeft());
- p->drawLines(lines.constData(), lines.size());
- p->restore();
- }
- }
- if (sub & SC_SliderHandle) {
- theme.rect = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget);
- if (slider->orientation == Qt::Horizontal) {
- if (slider->tickPosition == QSlider::TicksAbove)
- partId = TKP_THUMBTOP;
- else if (slider->tickPosition == QSlider::TicksBelow)
- partId = TKP_THUMBBOTTOM;
- else
- partId = TKP_THUMB;
-
- if (!(slider->state & State_Enabled))
- stateId = TUS_DISABLED;
- else if (slider->activeSubControls & SC_SliderHandle && (slider->state & State_Sunken))
- stateId = TUS_PRESSED;
- else if (slider->activeSubControls & SC_SliderHandle && (slider->state & State_MouseOver))
- stateId = TUS_HOT;
- else if (flags & State_HasFocus)
- stateId = TUS_FOCUSED;
- else
- stateId = TUS_NORMAL;
- } else {
- if (slider->tickPosition == QSlider::TicksLeft)
- partId = TKP_THUMBLEFT;
- else if (slider->tickPosition == QSlider::TicksRight)
- partId = TKP_THUMBRIGHT;
- else
- partId = TKP_THUMBVERT;
-
- if (!(slider->state & State_Enabled))
- stateId = TUVS_DISABLED;
- else if (slider->activeSubControls & SC_SliderHandle && (slider->state & State_Sunken))
- stateId = TUVS_PRESSED;
- else if (slider->activeSubControls & SC_SliderHandle && (slider->state & State_MouseOver))
- stateId = TUVS_HOT;
- else if (flags & State_HasFocus)
- stateId = TUVS_FOCUSED;
- else
- stateId = TUVS_NORMAL;
- }
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
- if (slider->state & State_HasFocus) {
- QStyleOptionFocusRect fropt;
- fropt.QStyleOption::operator=(*slider);
- fropt.rect = subElementRect(SE_SliderFocusRect, slider, widget);
- proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
- }
- }
- break;
-#endif
-#if QT_CONFIG(toolbutton)
- case CC_ToolButton:
- if (const QStyleOptionToolButton *toolbutton
- = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
- QRect button, menuarea;
- button = proxy()->subControlRect(cc, toolbutton, SC_ToolButton, widget);
- menuarea = proxy()->subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget);
-
- State bflags = toolbutton->state & ~State_Sunken;
- State mflags = bflags;
- bool autoRaise = flags & State_AutoRaise;
- if (autoRaise) {
- if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) {
- bflags &= ~State_Raised;
- }
- }
-
- if (toolbutton->state & State_Sunken) {
- if (toolbutton->activeSubControls & SC_ToolButton) {
- bflags |= State_Sunken;
- mflags |= State_MouseOver | State_Sunken;
- } else if (toolbutton->activeSubControls & SC_ToolButtonMenu) {
- mflags |= State_Sunken;
- bflags |= State_MouseOver;
- }
- }
-
- QStyleOption tool = *toolbutton;
- if (toolbutton->subControls & SC_ToolButton) {
- if (flags & (State_Sunken | State_On | State_Raised) || !autoRaise) {
- if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup && autoRaise) {
- XPThemeData theme(widget, p, QWindowsXPStylePrivate::ToolBarTheme);
- theme.partId = TP_SPLITBUTTON;
- theme.rect = button;
- if (!(bflags & State_Enabled))
- stateId = TS_DISABLED;
- else if (bflags & State_Sunken)
- stateId = TS_PRESSED;
- else if (bflags & State_MouseOver || !(flags & State_AutoRaise))
- stateId = flags & State_On ? TS_HOTCHECKED : TS_HOT;
- else if (bflags & State_On)
- stateId = TS_CHECKED;
- else
- stateId = TS_NORMAL;
- if (option->direction == Qt::RightToLeft)
- theme.mirrorHorizontally = true;
- theme.stateId = stateId;
- d->drawBackground(theme);
- } else {
- tool.rect = option->rect;
- tool.state = bflags;
- if (autoRaise) // for tool bars
- proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
- else
- proxy()->drawPrimitive(PE_PanelButtonBevel, &tool, p, widget);
- }
- }
- }
-
- if (toolbutton->state & State_HasFocus) {
- QStyleOptionFocusRect fr;
- fr.QStyleOption::operator=(*toolbutton);
- fr.rect.adjust(3, 3, -3, -3);
- if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup)
- fr.rect.adjust(0, 0, -proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator,
- toolbutton, widget), 0);
- proxy()->drawPrimitive(PE_FrameFocusRect, &fr, p, widget);
- }
- QStyleOptionToolButton label = *toolbutton;
- label.state = bflags;
- int fw = 2;
- if (!autoRaise)
- label.state &= ~State_Sunken;
- label.rect = button.adjusted(fw, fw, -fw, -fw);
- proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget);
-
- if (toolbutton->subControls & SC_ToolButtonMenu) {
- tool.rect = menuarea;
- tool.state = mflags;
- if (autoRaise) {
- proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget);
- } else {
- tool.state = mflags;
- menuarea.adjust(-2, 0, 0, 0);
- // Draw menu button
- if ((bflags & State_Sunken) != (mflags & State_Sunken)){
- p->save();
- p->setClipRect(menuarea);
- tool.rect = option->rect;
- proxy()->drawPrimitive(PE_PanelButtonBevel, &tool, p, 0);
- p->restore();
- }
- // Draw arrow
- p->save();
- p->setPen(option->palette.dark().color());
- p->drawLine(menuarea.left(), menuarea.top() + 3,
- menuarea.left(), menuarea.bottom() - 3);
- p->setPen(option->palette.light().color());
- p->drawLine(menuarea.left() - 1, menuarea.top() + 3,
- menuarea.left() - 1, menuarea.bottom() - 3);
-
- tool.rect = menuarea.adjusted(2, 3, -2, -1);
- proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, p, widget);
- p->restore();
- }
- } else if (toolbutton->features & QStyleOptionToolButton::HasMenu) {
- int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton, widget);
- QRect ir = toolbutton->rect;
- QStyleOptionToolButton newBtn = *toolbutton;
- newBtn.rect = QRect(ir.right() + 4 - mbi, ir.height() - mbi + 4, mbi - 5, mbi - 5);
- proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget);
- }
- }
- break;
-#endif // QT_CONFIG(toolbutton)
-
- case CC_TitleBar:
- {
- if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(option))
- {
- bool isActive = tb->titleBarState & QStyle::State_Active;
- XPThemeData theme(widget, p, QWindowsXPStylePrivate::WindowTheme);
- if (sub & SC_TitleBarLabel) {
-
- partId = (tb->titleBarState & Qt::WindowMinimized) ? WP_MINCAPTION : WP_CAPTION;
- theme.rect = option->rect;
- if (widget && !widget->isEnabled())
- stateId = CS_DISABLED;
- else if (isActive)
- stateId = CS_ACTIVE;
- else
- stateId = CS_INACTIVE;
-
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
-
- QRect ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarLabel, widget);
-
- int result = TST_NONE;
- GetThemeEnumValue(theme.handle(), WP_CAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWTYPE, &result);
- if (result != TST_NONE) {
- COLORREF textShadowRef;
- GetThemeColor(theme.handle(), WP_CAPTION, isActive ? CS_ACTIVE : CS_INACTIVE, TMT_TEXTSHADOWCOLOR, &textShadowRef);
- QColor textShadow = qRgb(GetRValue(textShadowRef), GetGValue(textShadowRef), GetBValue(textShadowRef));
- p->setPen(textShadow);
- p->drawText(ir.x() + 3, ir.y() + 2, ir.width() - 1, ir.height(),
- Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, tb->text);
- }
- COLORREF captionText = GetSysColor(isActive ? COLOR_CAPTIONTEXT : COLOR_INACTIVECAPTIONTEXT);
- QColor textColor = qRgb(GetRValue(captionText), GetGValue(captionText), GetBValue(captionText));
- p->setPen(textColor);
- p->drawText(ir.x() + 2, ir.y() + 1, ir.width() - 2, ir.height(),
- Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, tb->text);
- }
- if (sub & SC_TitleBarSysMenu && tb->titleBarFlags & Qt::WindowSystemMenuHint) {
- theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarSysMenu, widget);
- partId = WP_SYSBUTTON;
- if ((widget && !widget->isEnabled()) || !isActive)
- stateId = SBS_DISABLED;
- else if (option->activeSubControls == SC_TitleBarSysMenu && (option->state & State_Sunken))
- stateId = SBS_PUSHED;
- else if (option->activeSubControls == SC_TitleBarSysMenu && (option->state & State_MouseOver))
- stateId = SBS_HOT;
- else
- stateId = SBS_NORMAL;
- if (!tb->icon.isNull()) {
- tb->icon.paint(p, theme.rect);
- } else {
- theme.partId = partId;
- theme.stateId = stateId;
- if (theme.size().isEmpty()) {
- int iconSize = proxy()->pixelMetric(PM_SmallIconSize, tb, widget);
- QPixmap pm = proxy()->standardIcon(SP_TitleBarMenuButton, tb, widget).pixmap(iconSize, iconSize);
- p->save();
- drawItemPixmap(p, theme.rect, Qt::AlignCenter, pm);
- p->restore();
- } else {
- d->drawBackground(theme);
- }
- }
- }
-
- if (sub & SC_TitleBarMinButton && tb->titleBarFlags & Qt::WindowMinimizeButtonHint
- && !(tb->titleBarState & Qt::WindowMinimized)) {
- theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarMinButton, widget);
- partId = WP_MINBUTTON;
- if (widget && !widget->isEnabled())
- stateId = MINBS_DISABLED;
- else if (option->activeSubControls == SC_TitleBarMinButton && (option->state & State_Sunken))
- stateId = MINBS_PUSHED;
- else if (option->activeSubControls == SC_TitleBarMinButton && (option->state & State_MouseOver))
- stateId = MINBS_HOT;
- else if (!isActive)
- stateId = MINBS_INACTIVE;
- else
- stateId = MINBS_NORMAL;
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
- if (sub & SC_TitleBarMaxButton && tb->titleBarFlags & Qt::WindowMaximizeButtonHint
- && !(tb->titleBarState & Qt::WindowMaximized)) {
- theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarMaxButton, widget);
- partId = WP_MAXBUTTON;
- if (widget && !widget->isEnabled())
- stateId = MAXBS_DISABLED;
- else if (option->activeSubControls == SC_TitleBarMaxButton && (option->state & State_Sunken))
- stateId = MAXBS_PUSHED;
- else if (option->activeSubControls == SC_TitleBarMaxButton && (option->state & State_MouseOver))
- stateId = MAXBS_HOT;
- else if (!isActive)
- stateId = MAXBS_INACTIVE;
- else
- stateId = MAXBS_NORMAL;
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
- if (sub & SC_TitleBarContextHelpButton
- && tb->titleBarFlags & Qt::WindowContextHelpButtonHint) {
- theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarContextHelpButton, widget);
- partId = WP_HELPBUTTON;
- if (widget && !widget->isEnabled())
- stateId = MINBS_DISABLED;
- else if (option->activeSubControls == SC_TitleBarContextHelpButton && (option->state & State_Sunken))
- stateId = MINBS_PUSHED;
- else if (option->activeSubControls == SC_TitleBarContextHelpButton && (option->state & State_MouseOver))
- stateId = MINBS_HOT;
- else if (!isActive)
- stateId = MINBS_INACTIVE;
- else
- stateId = MINBS_NORMAL;
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
- bool drawNormalButton = (sub & SC_TitleBarNormalButton)
- && (((tb->titleBarFlags & Qt::WindowMinimizeButtonHint)
- && (tb->titleBarState & Qt::WindowMinimized))
- || ((tb->titleBarFlags & Qt::WindowMaximizeButtonHint)
- && (tb->titleBarState & Qt::WindowMaximized)));
- if (drawNormalButton) {
- theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarNormalButton, widget);
- partId = WP_RESTOREBUTTON;
- if (widget && !widget->isEnabled())
- stateId = RBS_DISABLED;
- else if (option->activeSubControls == SC_TitleBarNormalButton && (option->state & State_Sunken))
- stateId = RBS_PUSHED;
- else if (option->activeSubControls == SC_TitleBarNormalButton && (option->state & State_MouseOver))
- stateId = RBS_HOT;
- else if (!isActive)
- stateId = RBS_INACTIVE;
- else
- stateId = RBS_NORMAL;
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
- if (sub & SC_TitleBarShadeButton && tb->titleBarFlags & Qt::WindowShadeButtonHint
- && !(tb->titleBarState & Qt::WindowMinimized)) {
- theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarShadeButton, widget);
- partId = WP_MINBUTTON;
- if (widget && !widget->isEnabled())
- stateId = MINBS_DISABLED;
- else if (option->activeSubControls == SC_TitleBarShadeButton && (option->state & State_Sunken))
- stateId = MINBS_PUSHED;
- else if (option->activeSubControls == SC_TitleBarShadeButton && (option->state & State_MouseOver))
- stateId = MINBS_HOT;
- else if (!isActive)
- stateId = MINBS_INACTIVE;
- else
- stateId = MINBS_NORMAL;
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
- if (sub & SC_TitleBarUnshadeButton && tb->titleBarFlags & Qt::WindowShadeButtonHint
- && tb->titleBarState & Qt::WindowMinimized) {
- theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarUnshadeButton, widget);
- partId = WP_RESTOREBUTTON;
- if (widget && !widget->isEnabled())
- stateId = RBS_DISABLED;
- else if (option->activeSubControls == SC_TitleBarUnshadeButton && (option->state & State_Sunken))
- stateId = RBS_PUSHED;
- else if (option->activeSubControls == SC_TitleBarUnshadeButton && (option->state & State_MouseOver))
- stateId = RBS_HOT;
- else if (!isActive)
- stateId = RBS_INACTIVE;
- else
- stateId = RBS_NORMAL;
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
- if (sub & SC_TitleBarCloseButton && tb->titleBarFlags & Qt::WindowSystemMenuHint) {
- theme.rect = proxy()->subControlRect(CC_TitleBar, option, SC_TitleBarCloseButton, widget);
- //partId = titlebar->testWFlags(Qt::WA_WState_Tool) ? WP_SMALLCLOSEBUTTON : WP_CLOSEBUTTON;
- partId = WP_CLOSEBUTTON;
- if (widget && !widget->isEnabled())
- stateId = CBS_DISABLED;
- else if (option->activeSubControls == SC_TitleBarCloseButton && (option->state & State_Sunken))
- stateId = CBS_PUSHED;
- else if (option->activeSubControls == SC_TitleBarCloseButton && (option->state & State_MouseOver))
- stateId = CBS_HOT;
- else if (!isActive)
- stateId = CBS_INACTIVE;
- else
- stateId = CBS_NORMAL;
- theme.partId = partId;
- theme.stateId = stateId;
- d->drawBackground(theme);
- }
- }
- }
- break;
-
-#if QT_CONFIG(mdiarea)
- case CC_MdiControls:
- {
- QRect buttonRect;
- XPThemeData theme(widget, p, QWindowsXPStylePrivate::WindowTheme, WP_MDICLOSEBUTTON, CBS_NORMAL);
-
- if (option->subControls & SC_MdiCloseButton) {
- buttonRect = proxy()->subControlRect(CC_MdiControls, option, SC_MdiCloseButton, widget);
- if (theme.isValid()) {
- theme.partId = WP_MDICLOSEBUTTON;
- theme.rect = buttonRect;
- if (!(flags & State_Enabled))
- theme.stateId = CBS_INACTIVE;
- else if (flags & State_Sunken && (option->activeSubControls & SC_MdiCloseButton))
- theme.stateId = CBS_PUSHED;
- else if (flags & State_MouseOver && (option->activeSubControls & SC_MdiCloseButton))
- theme.stateId = CBS_HOT;
- else
- theme.stateId = CBS_NORMAL;
- d->drawBackground(theme);
- }
- }
- if (option->subControls & SC_MdiNormalButton) {
- buttonRect = proxy()->subControlRect(CC_MdiControls, option, SC_MdiNormalButton, widget);
- if (theme.isValid()) {
- theme.partId = WP_MDIRESTOREBUTTON;
- theme.rect = buttonRect;
- if (!(flags & State_Enabled))
- theme.stateId = CBS_INACTIVE;
- else if (flags & State_Sunken && (option->activeSubControls & SC_MdiNormalButton))
- theme.stateId = CBS_PUSHED;
- else if (flags & State_MouseOver && (option->activeSubControls & SC_MdiNormalButton))
- theme.stateId = CBS_HOT;
- else
- theme.stateId = CBS_NORMAL;
- d->drawBackground(theme);
- }
- }
- if (option->subControls & QStyle::SC_MdiMinButton) {
- buttonRect = proxy()->subControlRect(CC_MdiControls, option, SC_MdiMinButton, widget);
- if (theme.isValid()) {
- theme.partId = WP_MDIMINBUTTON;
- theme.rect = buttonRect;
- if (!(flags & State_Enabled))
- theme.stateId = CBS_INACTIVE;
- else if (flags & State_Sunken && (option->activeSubControls & SC_MdiMinButton))
- theme.stateId = CBS_PUSHED;
- else if (flags & State_MouseOver && (option->activeSubControls & SC_MdiMinButton))
- theme.stateId = CBS_HOT;
- else
- theme.stateId = CBS_NORMAL;
- d->drawBackground(theme);
- }
- }
- }
- break;
-#endif // QT_CONFIG(mdiarea)
-#if QT_CONFIG(dial)
- case CC_Dial:
- if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option))
- QStyleHelper::drawDial(dial, p);
- break;
-#endif // QT_CONFIG(dial)
- default:
- QWindowsStyle::drawComplexControl(cc, option, p, widget);
- break;
- }
-}
-
-static inline Qt::Orientation progressBarOrientation(const QStyleOption *option = 0)
-{
- if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option))
- return pb->orientation;
- return Qt::Horizontal;
-}
-
-int QWindowsXPStylePrivate::pixelMetricFromSystemDp(QStyle::PixelMetric pm, const QStyleOption *option, const QWidget *widget)
-{
- switch (pm) {
- case QStyle::PM_IndicatorWidth:
- return XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::ButtonTheme, BP_CHECKBOX, CBS_UNCHECKEDNORMAL).width();
- case QStyle::PM_IndicatorHeight:
- return XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::ButtonTheme, BP_CHECKBOX, CBS_UNCHECKEDNORMAL).height();
- case QStyle::PM_ExclusiveIndicatorWidth:
- return XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::ButtonTheme, BP_RADIOBUTTON, RBS_UNCHECKEDNORMAL).width();
- case QStyle::PM_ExclusiveIndicatorHeight:
- return XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::ButtonTheme, BP_RADIOBUTTON, RBS_UNCHECKEDNORMAL).height();
- case QStyle::PM_ProgressBarChunkWidth:
- return progressBarOrientation(option) == Qt::Horizontal
- ? XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::ProgressTheme, PP_CHUNK).width()
- : XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::ProgressTheme, PP_CHUNKVERT).height();
- case QStyle::PM_SliderThickness:
- return XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::TrackBarTheme, TKP_THUMB).height();
- case QStyle::PM_TitleBarHeight:
- return widget && (widget->windowType() == Qt::Tool)
- ? GetSystemMetrics(SM_CYSMCAPTION) + GetSystemMetrics(SM_CXSIZEFRAME)
- : GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CXSIZEFRAME);
- case QStyle::PM_MdiSubWindowFrameWidth:
- return XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::WindowTheme, WP_FRAMELEFT, FS_ACTIVE).width();
- case QStyle::PM_DockWidgetFrameWidth:
- return XPThemeData::themeSize(widget, 0, QWindowsXPStylePrivate::WindowTheme, WP_SMALLFRAMERIGHT, FS_ACTIVE).width();
- default:
- break;
- }
- return QWindowsXPStylePrivate::InvalidMetric;
-}
-
-/*! \reimp */
-int QWindowsXPStyle::pixelMetric(PixelMetric pm, const QStyleOption *option, const QWidget *widget) const
-{
- if (!QWindowsXPStylePrivate::useXP())
- return QWindowsStyle::pixelMetric(pm, option, widget);
-
- int res = QWindowsXPStylePrivate::pixelMetricFromSystemDp(pm, option, widget);
- if (res != QWindowsStylePrivate::InvalidMetric)
- return qRound(qreal(res) * QWindowsStylePrivate::nativeMetricScaleFactor(widget));
-
- res = 0;
- switch (pm) {
- case PM_MenuBarPanelWidth:
- case PM_ButtonDefaultIndicator:
- res = 0;
- break;
-
- case PM_DefaultFrameWidth:
- res = qobject_cast<const QListView*>(widget) ? 2 : 1;
- break;
- case PM_MenuPanelWidth:
- case PM_SpinBoxFrameWidth:
- res = 1;
- break;
-
- case PM_TabBarTabOverlap:
- case PM_MenuHMargin:
- case PM_MenuVMargin:
- res = 2;
- break;
-
- case PM_TabBarBaseOverlap:
- if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
- switch (tab->shape) {
- case QTabBar::RoundedNorth:
- case QTabBar::TriangularNorth:
- case QTabBar::RoundedWest:
- case QTabBar::TriangularWest:
- res = 1;
- break;
- case QTabBar::RoundedSouth:
- case QTabBar::TriangularSouth:
- res = 2;
- break;
- case QTabBar::RoundedEast:
- case QTabBar::TriangularEast:
- res = 3;
- break;
- }
- }
- break;
-
- case PM_SplitterWidth:
- res = qMax(int(QStyleHelper::dpiScaled(5.)), QApplication::globalStrut().width());
- break;
-
- case PM_MdiSubWindowMinimizedWidth:
- res = 160;
- break;
-
-#ifndef QT_NO_TOOLBAR
- case PM_ToolBarHandleExtent:
- res = int(QStyleHelper::dpiScaled(8.));
- break;
-
-#endif // QT_NO_TOOLBAR
- case PM_DockWidgetSeparatorExtent:
- case PM_DockWidgetTitleMargin:
- res = int(QStyleHelper::dpiScaled(4.));
- break;
-
- case PM_ButtonShiftHorizontal:
- case PM_ButtonShiftVertical:
- res = qstyleoption_cast<const QStyleOptionToolButton *>(option) ? 1 : 0;
- break;
-
- default:
- res = QWindowsStyle::pixelMetric(pm, option, widget);
- }
-
- return res;
-}
-
-/*
- This function is used by subControlRect to check if a button
- should be drawn for the given subControl given a set of window flags.
-*/
-static bool buttonVisible(const QStyle::SubControl sc, const QStyleOptionTitleBar *tb){
-
- bool isMinimized = tb->titleBarState & Qt::WindowMinimized;
- bool isMaximized = tb->titleBarState & Qt::WindowMaximized;
- const uint flags = tb->titleBarFlags;
- bool retVal = false;
- switch (sc) {
- case QStyle::SC_TitleBarContextHelpButton:
- if (flags & Qt::WindowContextHelpButtonHint)
- retVal = true;
- break;
- case QStyle::SC_TitleBarMinButton:
- if (!isMinimized && (flags & Qt::WindowMinimizeButtonHint))
- retVal = true;
- break;
- case QStyle::SC_TitleBarNormalButton:
- if (isMinimized && (flags & Qt::WindowMinimizeButtonHint))
- retVal = true;
- else if (isMaximized && (flags & Qt::WindowMaximizeButtonHint))
- retVal = true;
- break;
- case QStyle::SC_TitleBarMaxButton:
- if (!isMaximized && (flags & Qt::WindowMaximizeButtonHint))
- retVal = true;
- break;
- case QStyle::SC_TitleBarShadeButton:
- if (!isMinimized && flags & Qt::WindowShadeButtonHint)
- retVal = true;
- break;
- case QStyle::SC_TitleBarUnshadeButton:
- if (isMinimized && flags & Qt::WindowShadeButtonHint)
- retVal = true;
- break;
- case QStyle::SC_TitleBarCloseButton:
- if (flags & Qt::WindowSystemMenuHint)
- retVal = true;
- break;
- case QStyle::SC_TitleBarSysMenu:
- if (flags & Qt::WindowSystemMenuHint)
- retVal = true;
- break;
- default :
- retVal = true;
- }
- return retVal;
-}
-
-/*!
- \reimp
-*/
-QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *option,
- SubControl subControl, const QWidget *widget) const
-{
- if (!QWindowsXPStylePrivate::useXP())
- return QWindowsStyle::subControlRect(cc, option, subControl, widget);
-
- QRect rect;
-
- switch (cc) {
- case CC_TitleBar:
- if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) {
- if (!buttonVisible(subControl, tb))
- return rect;
- const bool isToolTitle = false;
- const int height = tb->rect.height();
- const int width = tb->rect.width();
- const int buttonMargin = int(QStyleHelper::dpiScaled(4));
- const qreal factor = QWindowsStylePrivate::nativeMetricScaleFactor(widget);
- int buttonHeight = qRound(qreal(GetSystemMetrics(SM_CYSIZE)) * factor)
- - buttonMargin;
- int buttonWidth = qRound(qreal(GetSystemMetrics(SM_CXSIZE)) * factor)
- - buttonMargin;
- const int delta = buttonWidth + 2;
- int controlTop = option->rect.bottom() - buttonHeight - 2;
- const int frameWidth = proxy()->pixelMetric(PM_MdiSubWindowFrameWidth, option, widget);
- const bool sysmenuHint = (tb->titleBarFlags & Qt::WindowSystemMenuHint) != 0;
- const bool minimizeHint = (tb->titleBarFlags & Qt::WindowMinimizeButtonHint) != 0;
- const bool maximizeHint = (tb->titleBarFlags & Qt::WindowMaximizeButtonHint) != 0;
- const bool contextHint = (tb->titleBarFlags & Qt::WindowContextHelpButtonHint) != 0;
- const bool shadeHint = (tb->titleBarFlags & Qt::WindowShadeButtonHint) != 0;
- bool isMinimized = tb->titleBarState & Qt::WindowMinimized;
- bool isMaximized = tb->titleBarState & Qt::WindowMaximized;
- int offset = 0;
-
- switch (subControl) {
- case SC_TitleBarLabel:
- rect = QRect(frameWidth, 0, width - (buttonWidth + frameWidth + 10), height);
- if (isToolTitle) {
- if (sysmenuHint) {
- rect.adjust(0, 0, -buttonWidth - 3, 0);
- }
- if (minimizeHint || maximizeHint)
- rect.adjust(0, 0, -buttonWidth - 2, 0);
- } else {
- if (sysmenuHint) {
- const int leftOffset = height - 8;
- rect.adjust(leftOffset, 0, 0, 0);
- }
- if (minimizeHint)
- rect.adjust(0, 0, -buttonWidth - 2, 0);
- if (maximizeHint)
- rect.adjust(0, 0, -buttonWidth - 2, 0);
- if (contextHint)
- rect.adjust(0, 0, -buttonWidth - 2, 0);
- if (shadeHint)
- rect.adjust(0, 0, -buttonWidth - 2, 0);
- }
- break;
-
- case SC_TitleBarContextHelpButton:
- if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint)
- offset += delta;
- Q_FALLTHROUGH();
- case SC_TitleBarMinButton:
- if (!isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
- offset += delta;
- else if (subControl == SC_TitleBarMinButton)
- break;
- Q_FALLTHROUGH();
- case SC_TitleBarNormalButton:
- if (isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
- offset += delta;
- else if (isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
- offset += delta;
- else if (subControl == SC_TitleBarNormalButton)
- break;
- Q_FALLTHROUGH();
- case SC_TitleBarMaxButton:
- if (!isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
- offset += delta;
- else if (subControl == SC_TitleBarMaxButton)
- break;
- Q_FALLTHROUGH();
- case SC_TitleBarShadeButton:
- if (!isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
- offset += delta;
- else if (subControl == SC_TitleBarShadeButton)
- break;
- Q_FALLTHROUGH();
- case SC_TitleBarUnshadeButton:
- if (isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
- offset += delta;
- else if (subControl == SC_TitleBarUnshadeButton)
- break;
- Q_FALLTHROUGH();
- case SC_TitleBarCloseButton:
- if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
- offset += delta;
- else if (subControl == SC_TitleBarCloseButton)
- break;
-
- rect.setRect(width - offset - controlTop + 1, controlTop,
- buttonWidth, buttonHeight);
- break;
-
- case SC_TitleBarSysMenu:
- {
- const int controlTop = 6;
- const int controlHeight = height - controlTop - 3;
- const int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
- QSize iconSize = tb->icon.actualSize(QSize(iconExtent, iconExtent));
- if (tb->icon.isNull())
- iconSize = QSize(controlHeight, controlHeight);
- int hPad = (controlHeight - iconSize.height())/2;
- int vPad = (controlHeight - iconSize.width())/2;
- rect = QRect(frameWidth + hPad, controlTop + vPad, iconSize.width(), iconSize.height());
- }
- break;
- default:
- break;
- }
- }
- break;
-
- case CC_ComboBox:
- if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
- int x = cmb->rect.x(), y = cmb->rect.y(), wi = cmb->rect.width(), he = cmb->rect.height();
- int xpos = x;
- xpos += wi - 1 - 16;
-
- switch (subControl) {
- case SC_ComboBoxFrame:
- rect = cmb->rect;
- break;
-
- case SC_ComboBoxArrow:
- rect = QRect(xpos, y+1, 16, he-2);
- break;
-
- case SC_ComboBoxEditField:
- rect = QRect(x+2, y+2, wi-3-16, he-4);
- break;
-
- case SC_ComboBoxListBoxPopup:
- rect = cmb->rect;
- break;
-
- default:
- break;
- }
- }
- break;
-#if QT_CONFIG(mdiarea)
- case CC_MdiControls:
- {
- int numSubControls = 0;
- if (option->subControls & SC_MdiCloseButton)
- ++numSubControls;
- if (option->subControls & SC_MdiMinButton)
- ++numSubControls;
- if (option->subControls & SC_MdiNormalButton)
- ++numSubControls;
- if (numSubControls == 0)
- break;
-
- int buttonWidth = option->rect.width() / numSubControls;
- int offset = 0;
- switch (subControl) {
- case SC_MdiCloseButton:
- // Only one sub control, no offset needed.
- if (numSubControls == 1)
- break;
- offset += buttonWidth;
- Q_FALLTHROUGH();
- case SC_MdiNormalButton:
- // No offset needed if
- // 1) There's only one sub control
- // 2) We have a close button and a normal button (offset already added in SC_MdiClose)
- if (numSubControls == 1 || (numSubControls == 2 && !(option->subControls & SC_MdiMinButton)))
- break;
- if (option->subControls & SC_MdiNormalButton)
- offset += buttonWidth;
- break;
- default:
- break;
- }
- rect = QRect(offset, 0, buttonWidth, option->rect.height());
- break;
- }
-#endif // QT_CONFIG(mdiarea)
-
- default:
- rect = visualRect(option->direction, option->rect,
- QWindowsStyle::subControlRect(cc, option, subControl, widget));
- break;
- }
- return visualRect(option->direction, option->rect, rect);
-}
-
-/*!
- \reimp
-*/
-QSize QWindowsXPStyle::sizeFromContents(ContentsType ct, const QStyleOption *option,
- const QSize &contentsSize, const QWidget *widget) const
-{
- if (!QWindowsXPStylePrivate::useXP())
- return QWindowsStyle::sizeFromContents(ct, option, contentsSize, widget);
-
- QSize sz(contentsSize);
- switch (ct) {
- case CT_LineEdit:
- case CT_ComboBox:
- {
- XPThemeData buttontheme(widget, 0, QWindowsXPStylePrivate::ButtonTheme, BP_PUSHBUTTON, PBS_NORMAL);
- if (buttontheme.isValid()) {
- const qreal factor = QWindowsXPStylePrivate::nativeMetricScaleFactor(widget);
- const QMarginsF borderSize = buttontheme.margins() * factor;
- if (!borderSize.isNull()) {
- const qreal margin = qreal(2) * factor;
- sz.rwidth() += qRound(borderSize.left() + borderSize.right() - margin);
- sz.rheight() += int(borderSize.bottom() + borderSize.top() - margin
- + qreal(1) / factor - 1);
- }
- const int textMargins = 2*(proxy()->pixelMetric(PM_FocusFrameHMargin) + 1);
- sz += QSize(qMax(pixelMetric(QStyle::PM_ScrollBarExtent, option, widget)
- + textMargins, 23), 0); //arrow button
- }
- }
- break;
- case CT_SpinBox:
- {
- //Spinbox adds frame twice
- sz = QWindowsStyle::sizeFromContents(ct, option, contentsSize, widget);
- int border = proxy()->pixelMetric(PM_SpinBoxFrameWidth, option, widget);
- sz -= QSize(2*border, 2*border);
- }
- break;
- case CT_TabWidget:
- sz += QSize(6, 6);
- break;
- case CT_Menu:
- sz += QSize(1, 0);
- break;
-#if QT_CONFIG(menubar)
- case CT_MenuBarItem:
- if (!sz.isEmpty())
- sz += QSize(windowsItemHMargin * 5 + 1, 6);
- break;
-#endif
- case CT_MenuItem:
- if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(option))
- {
- if (menuitem->menuItemType != QStyleOptionMenuItem::Separator) {
- sz = QWindowsStyle::sizeFromContents(ct, option, sz, widget);
- sz.setHeight(sz.height() - 2);
- return sz;
- }
- }
- sz = QWindowsStyle::sizeFromContents(ct, option, sz, widget);
- break;
-
- case CT_MdiControls:
- if (const QStyleOptionComplex *styleOpt = qstyleoption_cast<const QStyleOptionComplex *>(option)) {
- int width = 0;
- if (styleOpt->subControls & SC_MdiMinButton)
- width += 17 + 1;
- if (styleOpt->subControls & SC_MdiNormalButton)
- width += 17 + 1;
- if (styleOpt->subControls & SC_MdiCloseButton)
- width += 17 + 1;
- sz = QSize(width, 19);
- } else {
- sz = QSize(54, 19);
- }
- break;
-
- default:
- sz = QWindowsStyle::sizeFromContents(ct, option, sz, widget);
- break;
- }
-
- return sz;
-}
-
-
-/*! \reimp */
-int QWindowsXPStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget,
- QStyleHintReturn *returnData) const
-{
- QWindowsXPStylePrivate *d = const_cast<QWindowsXPStylePrivate*>(d_func());
- if (!QWindowsXPStylePrivate::useXP())
- return QWindowsStyle::styleHint(hint, option, widget, returnData);
-
- int res = 0;
- switch (hint) {
-
- case SH_EtchDisabledText:
- res = (qobject_cast<const QLabel*>(widget) != 0);
- break;
-
- case SH_SpinControls_DisableOnBounds:
- res = 0;
- break;
-
- case SH_TitleBar_AutoRaise:
- case SH_TitleBar_NoBorder:
- res = 1;
- break;
-
- case SH_GroupBox_TextLabelColor:
- if (!widget || (widget && widget->isEnabled()))
- res = d->groupBoxTextColor;
- else
- res = d->groupBoxTextColorDisabled;
- break;
-
- case SH_Table_GridLineColor:
- res = 0xC0C0C0;
- break;
-
- case SH_WindowFrame_Mask:
- {
- res = 1;
- QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask *>(returnData);
- const QStyleOptionTitleBar *titlebar = qstyleoption_cast<const QStyleOptionTitleBar *>(option);
- if (mask && titlebar) {
- // Note certain themes will not return the whole window frame but only the titlebar part when
- // queried This function needs to return the entire window mask, hence we will only fetch the mask for the
- // titlebar itself and add the remaining part of the window rect at the bottom.
- int tbHeight = proxy()->pixelMetric(PM_TitleBarHeight, option, widget);
- QRect titleBarRect = option->rect;
- titleBarRect.setHeight(tbHeight);
- XPThemeData themeData;
- if (titlebar->titleBarState & Qt::WindowMinimized) {
- themeData = XPThemeData(widget, 0,
- QWindowsXPStylePrivate::WindowTheme,
- WP_MINCAPTION, CS_ACTIVE, titleBarRect);
- } else
- themeData = XPThemeData(widget, 0,
- QWindowsXPStylePrivate::WindowTheme,
- WP_CAPTION, CS_ACTIVE, titleBarRect);
- mask->region = d->region(themeData) +
- QRect(0, tbHeight, option->rect.width(), option->rect.height() - tbHeight);
- }
- }
- break;
-#if QT_CONFIG(rubberband)
- case SH_RubberBand_Mask:
- if (qstyleoption_cast<const QStyleOptionRubberBand *>(option))
- res = 0;
- break;
-#endif // QT_CONFIG(rubberband)
-
- case SH_ItemView_DrawDelegateFrame:
- res = 1;
- break;
-
- default:
- res =QWindowsStyle::styleHint(hint, option, widget, returnData);
- }
-
- return res;
-}
-
-/*! \reimp */
-QPalette QWindowsXPStyle::standardPalette() const
-{
- if (QWindowsXPStylePrivate::useXP() && QApplicationPrivate::sys_pal)
- return *QApplicationPrivate::sys_pal;
- else
- return QWindowsStyle::standardPalette();
-}
-
-/*!
- \reimp
-*/
-QPixmap QWindowsXPStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option,
- const QWidget *widget) const
-{
- if (!QWindowsXPStylePrivate::useXP())
- return QWindowsStyle::standardPixmap(standardPixmap, option, widget);
-
- switch(standardPixmap) {
- case SP_TitleBarMaxButton:
- case SP_TitleBarCloseButton:
- if (qstyleoption_cast<const QStyleOptionDockWidget *>(option))
- {
- if (widget && widget->isWindow()) {
- XPThemeData theme(widget, 0, QWindowsXPStylePrivate::WindowTheme, WP_SMALLCLOSEBUTTON, CBS_NORMAL);
- if (theme.isValid()) {
- const QSize size = (theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize();
- return QIcon(QWindowsStyle::standardPixmap(standardPixmap, option, widget)).pixmap(size);
- }
- }
- }
- break;
- default:
- break;
- }
- return QWindowsStyle::standardPixmap(standardPixmap, option, widget);
-}
-
-/*!
- \reimp
-*/
-QIcon QWindowsXPStyle::standardIcon(StandardPixmap standardIcon,
- const QStyleOption *option,
- const QWidget *widget) const
-{
- if (!QWindowsXPStylePrivate::useXP()) {
- return QWindowsStyle::standardIcon(standardIcon, option, widget);
- }
-
- QWindowsXPStylePrivate *d = const_cast<QWindowsXPStylePrivate*>(d_func());
- switch(standardIcon) {
- case SP_TitleBarMaxButton:
- if (qstyleoption_cast<const QStyleOptionDockWidget *>(option))
- {
- if (d->dockFloat.isNull()) {
- XPThemeData themeSize(0, 0, QWindowsXPStylePrivate::WindowTheme,
- WP_SMALLCLOSEBUTTON, CBS_NORMAL);
- XPThemeData theme(0, 0, QWindowsXPStylePrivate::WindowTheme,
- WP_MAXBUTTON, MAXBS_NORMAL);
- if (theme.isValid()) {
- const QSize size = (themeSize.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize();
- QPixmap pm(size);
- pm.fill(Qt::transparent);
- QPainter p(&pm);
- theme.painter = &p;
- theme.rect = QRect(QPoint(0, 0), size);
- d->drawBackground(theme);
- d->dockFloat.addPixmap(pm, QIcon::Normal, QIcon::Off); // Normal
- pm.fill(Qt::transparent);
- theme.stateId = MAXBS_PUSHED;
- d->drawBackground(theme);
- d->dockFloat.addPixmap(pm, QIcon::Normal, QIcon::On); // Pressed
- pm.fill(Qt::transparent);
- theme.stateId = MAXBS_HOT;
- d->drawBackground(theme);
- d->dockFloat.addPixmap(pm, QIcon::Active, QIcon::Off); // Hover
- pm.fill(Qt::transparent);
- theme.stateId = MAXBS_INACTIVE;
- d->drawBackground(theme);
- d->dockFloat.addPixmap(pm, QIcon::Disabled, QIcon::Off); // Disabled
- }
- }
- if (widget && widget->isWindow())
- return d->dockFloat;
-
- }
- break;
- case SP_TitleBarCloseButton:
- if (qstyleoption_cast<const QStyleOptionDockWidget *>(option))
- {
- if (d->dockClose.isNull()) {
- XPThemeData theme(0, 0, QWindowsXPStylePrivate::WindowTheme,
- WP_SMALLCLOSEBUTTON, CBS_NORMAL);
- if (theme.isValid()) {
- const QSize size = (theme.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize();
- QPixmap pm(size);
- pm.fill(Qt::transparent);
- QPainter p(&pm);
- theme.painter = &p;
- theme.partId = WP_CLOSEBUTTON; // ####
- theme.rect = QRect(QPoint(0, 0), size);
- d->drawBackground(theme);
- d->dockClose.addPixmap(pm, QIcon::Normal, QIcon::Off); // Normal
- pm.fill(Qt::transparent);
- theme.stateId = CBS_PUSHED;
- d->drawBackground(theme);
- d->dockClose.addPixmap(pm, QIcon::Normal, QIcon::On); // Pressed
- pm.fill(Qt::transparent);
- theme.stateId = CBS_HOT;
- d->drawBackground(theme);
- d->dockClose.addPixmap(pm, QIcon::Active, QIcon::Off); // Hover
- pm.fill(Qt::transparent);
- theme.stateId = CBS_INACTIVE;
- d->drawBackground(theme);
- d->dockClose.addPixmap(pm, QIcon::Disabled, QIcon::Off); // Disabled
- }
- }
- if (widget && widget->isWindow())
- return d->dockClose;
- }
- break;
- case SP_TitleBarNormalButton:
- if (qstyleoption_cast<const QStyleOptionDockWidget *>(option))
- {
- if (d->dockFloat.isNull()) {
- XPThemeData themeSize(0, 0, QWindowsXPStylePrivate::WindowTheme,
- WP_SMALLCLOSEBUTTON, CBS_NORMAL);
- XPThemeData theme(0, 0, QWindowsXPStylePrivate::WindowTheme,
- WP_RESTOREBUTTON, RBS_NORMAL);
- if (theme.isValid()) {
- const QSize size = (themeSize.size() * QWindowsStylePrivate::nativeMetricScaleFactor(widget)).toSize();
- QPixmap pm(size);
- pm.fill(Qt::transparent);
- QPainter p(&pm);
- theme.painter = &p;
- theme.rect = QRect(QPoint(0, 0), size);
- d->drawBackground(theme);
- d->dockFloat.addPixmap(pm, QIcon::Normal, QIcon::Off); // Normal
- pm.fill(Qt::transparent);
- theme.stateId = RBS_PUSHED;
- d->drawBackground(theme);
- d->dockFloat.addPixmap(pm, QIcon::Normal, QIcon::On); // Pressed
- pm.fill(Qt::transparent);
- theme.stateId = RBS_HOT;
- d->drawBackground(theme);
- d->dockFloat.addPixmap(pm, QIcon::Active, QIcon::Off); // Hover
- pm.fill(Qt::transparent);
- theme.stateId = RBS_INACTIVE;
- d->drawBackground(theme);
- d->dockFloat.addPixmap(pm, QIcon::Disabled, QIcon::Off); // Disabled
- }
- }
- if (widget && widget->isWindow())
- return d->dockFloat;
-
- }
- break;
- default:
- break;
- }
-
- return QWindowsStyle::standardIcon(standardIcon, option, widget);
-}
-
-/*!
- \internal
-
- Constructs a QWindowsXPStyle object.
-*/
-QWindowsXPStyle::QWindowsXPStyle(QWindowsXPStylePrivate &dd) : QWindowsStyle(dd)
-{
-}
-
-
-// Debugging code ---------------------------------------------------------------------[ START ]---
-// The code for this point on is not compiled by default, but only used as assisting
-// debugging code when you uncomment the DEBUG_XP_STYLE define at the top of the file.
-
-#ifdef DEBUG_XP_STYLE
-// The schema file expects these to be defined by the user.
-#define TMT_ENUMDEF 8
-#define TMT_ENUMVAL TEXT('A')
-#define TMT_ENUM TEXT('B')
-#define SCHEMA_STRINGS // For 2nd pass on schema file
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <tmschema.h>
-QT_END_INCLUDE_NAMESPACE
-
-// A property's value, type and name combo
-struct PropPair {
- int propValue;
- int propType;
- LPCWSTR propName;
-};
-
-// Operator for sorting of PropPairs
-bool operator<(PropPair a, PropPair b) {
- return wcscmp(a.propName, b.propName) < 0;
-}
-
-// Our list of all possible properties
-static QList<PropPair> all_props;
-
-
-/*! \internal
- Dumps a portion of the full native DIB section double buffer.
- The DIB section double buffer is only used when doing special
- transformations to the theme part, or when the real double
- buffer in the paintengine does not have an HDC we may use
- directly.
- Since we cannot rely on the pixel data we get from Microsoft
- when drawing into the DIB section, we use this function to
- see the actual data we got, and can determin the appropriate
- action.
-*/
-void QWindowsXPStylePrivate::dumpNativeDIB(int w, int h)
-{
- if (w && h) {
- static int pCount = 0;
- DWORD *bufPix = (DWORD*)bufferPixels;
-
- char *bufferDump = new char[bufferH * bufferW * 16];
- char *bufferPos = bufferDump;
-
- memset(bufferDump, 0, sizeof(bufferDump));
- bufferPos += sprintf(bufferPos, "const int pixelBufferW%d = %d;\n", pCount, w);
- bufferPos += sprintf(bufferPos, "const int pixelBufferH%d = %d;\n", pCount, h);
- bufferPos += sprintf(bufferPos, "const unsigned DWORD pixelBuffer%d[] = {", pCount);
- for (int iy = 0; iy < h; ++iy) {
- bufferPos += sprintf(bufferPos, "\n ");
- bufPix = (DWORD*)(bufferPixels + (iy * bufferW * 4));
- for (int ix = 0; ix < w; ++ix) {
- bufferPos += sprintf(bufferPos, "0x%08x, ", *bufPix);
- ++bufPix;
- }
- }
- bufferPos += sprintf(bufferPos, "\n};\n\n");
- printf(bufferDump);
-
- delete[] bufferDump;
- ++pCount;
- }
-}
-
-/*! \internal
- Shows the value of a given property for a part.
-*/
-static void showProperty(XPThemeData &themeData, const PropPair &prop)
-{
- PROPERTYORIGIN origin = PO_NOTFOUND;
- GetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &origin);
- const char *originStr;
- switch(origin) {
- case PO_STATE:
- originStr = "State ";
- break;
- case PO_PART:
- originStr = "Part ";
- break;
- case PO_CLASS:
- originStr = "Class ";
- break;
- case PO_GLOBAL:
- originStr = "Globl ";
- break;
- case PO_NOTFOUND:
- default:
- originStr = "Unkwn ";
- break;
- }
-
- switch(prop.propType) {
- case TMT_STRING:
- {
- wchar_t buffer[512];
- GetThemeString(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, buffer, 512);
- printf(" (%sString) %-20S: %S\n", originStr, prop.propName, buffer);
- }
- break;
- case TMT_ENUM:
- {
- int result = -1;
- GetThemeEnumValue(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
- printf(" (%sEnum) %-20S: %d\n", originStr, prop.propName, result);
- }
- break;
- case TMT_INT:
- {
- int result = -1;
- GetThemeInt(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
- printf(" (%sint) %-20S: %d\n", originStr, prop.propName, result);
- }
- break;
- case TMT_BOOL:
- {
- BOOL result = false;
- GetThemeBool(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
- printf(" (%sbool) %-20S: %d\n", originStr, prop.propName, result);
- }
- break;
- case TMT_COLOR:
- {
- COLORREF result = 0;
- GetThemeColor(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
- printf(" (%scolor) %-20S: 0x%08X\n", originStr, prop.propName, result);
- }
- break;
- case TMT_MARGINS:
- {
- MARGINS result;
- memset(&result, 0, sizeof(result));
- GetThemeMargins(themeData.handle(), 0, themeData.partId, themeData.stateId, prop.propValue, 0, &result);
- printf(" (%smargins) %-20S: (%d, %d, %d, %d)\n", originStr,
- prop.propName, result.cxLeftWidth, result.cyTopHeight, result.cxRightWidth, result.cyBottomHeight);
- }
- break;
- case TMT_FILENAME:
- {
- wchar_t buffer[512];
- GetThemeFilename(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, buffer, 512);
- printf(" (%sfilename)%-20S: %S\n", originStr, prop.propName, buffer);
- }
- break;
- case TMT_SIZE:
- {
- SIZE result1;
- SIZE result2;
- SIZE result3;
- memset(&result1, 0, sizeof(result1));
- memset(&result2, 0, sizeof(result2));
- memset(&result3, 0, sizeof(result3));
- GetThemePartSize(themeData.handle(), 0, themeData.partId, themeData.stateId, 0, TS_MIN, &result1);
- GetThemePartSize(themeData.handle(), 0, themeData.partId, themeData.stateId, 0, TS_TRUE, &result2);
- GetThemePartSize(themeData.handle(), 0, themeData.partId, themeData.stateId, 0, TS_DRAW, &result3);
- printf(" (%ssize) %-20S: Min (%d, %d), True(%d, %d), Draw(%d, %d)\n", originStr, prop.propName,
- result1.cx, result1.cy, result2.cx, result2.cy, result3.cx, result3.cy);
- }
- break;
- case TMT_POSITION:
- {
- POINT result;
- memset(&result, 0, sizeof(result));
- GetThemePosition(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
- printf(" (%sPosition)%-20S: (%d, %d)\n", originStr, prop.propName, result.x, result.y);
- }
- break;
- case TMT_RECT:
- {
- RECT result;
- memset(&result, 0, sizeof(result));
- GetThemeRect(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
- printf(" (%sRect) %-20S: (%d, %d, %d, %d)\n", originStr, prop.propName, result.left, result.top, result.right, result.bottom);
- }
- break;
- case TMT_FONT:
- {
- LOGFONT result;
- memset(&result, 0, sizeof(result));
- GetThemeFont(themeData.handle(), 0, themeData.partId, themeData.stateId, prop.propValue, &result);
- printf(" (%sFont) %-20S: %S height(%d) width(%d) weight(%d)\n", originStr, prop.propName,
- result.lfFaceName, result.lfHeight, result.lfWidth, result.lfWeight);
- }
- break;
- case TMT_INTLIST:
- {
- INTLIST result;
- memset(&result, 0, sizeof(result));
- GetThemeIntList(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &result);
- printf(" (%sInt list)%-20S: { ", originStr, prop.propName);
- for (int i = 0; i < result.iValueCount; ++i)
- printf("%d ", result.iValues[i]);
- printf("}\n");
- }
- break;
- default:
- printf(" %s%S : Unknown property type (%d)!\n", originStr, prop.propName, prop.propType);
- }
-}
-
-/*! \internal
- Dump all valid properties for a part.
- If it's the first time this function is called, then the name,
- enum value and documentation of all properties are shown, as
- well as all global properties.
-*/
-void QWindowsXPStylePrivate::showProperties(XPThemeData &themeData)
-{
- if (!all_props.count()) {
- const TMSCHEMAINFO *infoTable = GetSchemaInfo();
- for (int i = 0; i < infoTable->iPropCount; ++i) {
- int propType = infoTable->pPropTable[i].bPrimVal;
- int propValue = infoTable->pPropTable[i].sEnumVal;
- LPCWSTR propName = infoTable->pPropTable[i].pszName;
-
- switch(propType) {
- case TMT_ENUMDEF:
- case TMT_ENUMVAL:
- continue;
- default:
- if (propType != propValue) {
- PropPair prop;
- prop.propValue = propValue;
- prop.propName = propName;
- prop.propType = propType;
- all_props.append(prop);
- }
- }
- }
- std::sort(all_props.begin(), all_props.end());
-
- {// List all properties
- printf("part properties count = %d:\n", all_props.count());
- printf(" Enum Property Name Description\n");
- printf("-----------------------------------------------------------\n");
- wchar_t themeName[256];
- pGetCurrentThemeName(themeName, 256, 0, 0, 0, 0);
- for (int j = 0; j < all_props.count(); ++j) {
- PropPair prop = all_props.at(j);
- wchar_t buf[500];
- GetThemeDocumentationProperty(themeName, prop.propName, buf, 500);
- printf("%3d: (%4d) %-20S %S\n", j, prop.propValue, prop.propName, buf);
- }
- }
-
- {// Show Global values
- printf("Global Properties:\n");
- for (int j = 0; j < all_props.count(); ++j) {
- PropPair prop = all_props.at(j);
- PROPERTYORIGIN origin = PO_NOTFOUND;
- GetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &origin);
- if (origin == PO_GLOBAL) {
- showProperty(themeData, prop);
- }
- }
- }
- }
-
- for (int j = 0; j < all_props.count(); ++j) {
- PropPair prop = all_props.at(j);
- PROPERTYORIGIN origin = PO_NOTFOUND;
- GetThemePropertyOrigin(themeData.handle(), themeData.partId, themeData.stateId, prop.propValue, &origin);
- if (origin != PO_NOTFOUND)
- {
- showProperty(themeData, prop);
- }
- }
-}
-#endif
-// Debugging code -----------------------------------------------------------------------[ END ]---
-
-
-QT_END_NAMESPACE
-
-#endif //QT_NO_WINDOWSXP
diff --git a/src/widgets/styles/qwindowsxpstyle_p.h b/src/widgets/styles/qwindowsxpstyle_p.h
deleted file mode 100644
index 62e3af927c..0000000000
--- a/src/widgets/styles/qwindowsxpstyle_p.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSXPSTYLE_P_H
-#define QWINDOWSXPSTYLE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtWidgets/private/qtwidgetsglobal_p.h>
-#include <private/qwindowsstyle_p.h>
-
-QT_BEGIN_NAMESPACE
-
-
-#if QT_CONFIG(style_windowsxp)
-
-class QWindowsXPStylePrivate;
-class QWindowsXPStyle : public QWindowsStyle
-{
- Q_OBJECT
-public:
- QWindowsXPStyle();
- QWindowsXPStyle(QWindowsXPStylePrivate &dd);
- ~QWindowsXPStyle();
-
- void unpolish(QApplication*);
- void polish(QApplication*);
- void polish(QWidget*);
- void polish(QPalette&);
- void unpolish(QWidget*);
-
- void drawPrimitive(PrimitiveElement pe, const QStyleOption *option, QPainter *p,
- const QWidget *widget = 0) const;
- void drawControl(ControlElement element, const QStyleOption *option, QPainter *p,
- const QWidget *wwidget = 0) const;
- QRect subElementRect(SubElement r, const QStyleOption *option, const QWidget *widget = 0) const;
- QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *option, SubControl sc,
- const QWidget *widget = 0) const;
- void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *option, QPainter *p,
- const QWidget *widget = 0) const;
- QSize sizeFromContents(ContentsType ct, const QStyleOption *option, const QSize &contentsSize,
- const QWidget *widget = 0) const;
- int pixelMetric(PixelMetric pm, const QStyleOption *option = 0,
- const QWidget *widget = 0) const;
- int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0,
- QStyleHintReturn *returnData = 0) const;
-
- QPalette standardPalette() const;
- QPixmap standardPixmap(StandardPixmap standardIcon, const QStyleOption *option,
- const QWidget *widget = 0) const;
- QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0,
- const QWidget *widget = 0) const;
-
-private:
- Q_DISABLE_COPY(QWindowsXPStyle)
- Q_DECLARE_PRIVATE(QWindowsXPStyle)
- friend class QStyleFactory;
-};
-
-#endif // style_windowsxp
-
-QT_END_NAMESPACE
-
-#endif // QWINDOWSXPSTYLE_P_H
diff --git a/src/widgets/styles/qwindowsxpstyle_p_p.h b/src/widgets/styles/qwindowsxpstyle_p_p.h
deleted file mode 100644
index fb5210cb07..0000000000
--- a/src/widgets/styles/qwindowsxpstyle_p_p.h
+++ /dev/null
@@ -1,345 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSXPSTYLE_P_P_H
-#define QWINDOWSXPSTYLE_P_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
-// file may change from version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtWidgets/private/qtwidgetsglobal_p.h>
-#include "qwindowsxpstyle_p.h"
-#include "qwindowsstyle_p_p.h"
-#include <qmap.h>
-#include <qt_windows.h>
-
-#include <uxtheme.h>
-#include <vssym32.h>
-
-#include <limits.h>
-
-QT_BEGIN_NAMESPACE
-
-// TMT_TEXTSHADOWCOLOR is wrongly defined in mingw
-#if TMT_TEXTSHADOWCOLOR != 3818
-#undef TMT_TEXTSHADOWCOLOR
-#define TMT_TEXTSHADOWCOLOR 3818
-#endif
-#ifndef TST_NONE
-# define TST_NONE 0
-#endif
-
-// These defines are missing from the tmschema, but still exist as
-// states for their parts
-#ifndef MINBS_INACTIVE
-#define MINBS_INACTIVE 5
-#endif
-#ifndef MAXBS_INACTIVE
-#define MAXBS_INACTIVE 5
-#endif
-#ifndef RBS_INACTIVE
-#define RBS_INACTIVE 5
-#endif
-#ifndef HBS_INACTIVE
-#define HBS_INACTIVE 5
-#endif
-#ifndef CBS_INACTIVE
-#define CBS_INACTIVE 5
-#endif
-
-// Uncomment define below to build debug assisting code, and output
-// #define DEBUG_XP_STYLE
-
-#if QT_CONFIG(style_windowsxp)
-
-// Declarations -----------------------------------------------------------------------------------
-class XPThemeData
-{
-public:
- explicit XPThemeData(const QWidget *w = 0, QPainter *p = 0, int themeIn = -1,
- int part = 0, int state = 0, const QRect &r = QRect())
- : widget(w), painter(p), theme(themeIn), htheme(0), partId(part), stateId(state),
- mirrorHorizontally(false), mirrorVertically(false), noBorder(false),
- noContent(false), rotate(0), rect(r)
- {}
-
- HRGN mask(QWidget *widget);
- HTHEME handle();
-
- static RECT toRECT(const QRect &qr);
- bool isValid();
-
- QSizeF size();
- QMarginsF margins(const QRect &rect, int propId = TMT_CONTENTMARGINS);
- QMarginsF margins(int propId = TMT_CONTENTMARGINS);
-
- static QSizeF themeSize(const QWidget *w = 0, QPainter *p = 0, int themeIn = -1, int part = 0, int state = 0);
- static QMarginsF themeMargins(const QRect &rect, const QWidget *w = 0, QPainter *p = 0, int themeIn = -1,
- int part = 0, int state = 0, int propId = TMT_CONTENTMARGINS);
- static QMarginsF themeMargins(const QWidget *w = 0, QPainter *p = 0, int themeIn = -1,
- int part = 0, int state = 0, int propId = TMT_CONTENTMARGINS);
-
- const QWidget *widget;
- QPainter *painter;
-
- int theme;
- HTHEME htheme;
- int partId;
- int stateId;
-
- uint mirrorHorizontally : 1;
- uint mirrorVertically : 1;
- uint noBorder : 1;
- uint noContent : 1;
- uint rotate;
- QRect rect;
-};
-
-struct ThemeMapKey {
- int theme;
- int partId;
- int stateId;
- bool noBorder;
- bool noContent;
-
- ThemeMapKey() : partId(-1), stateId(-1) {}
- ThemeMapKey(const XPThemeData &data)
- : theme(data.theme), partId(data.partId), stateId(data.stateId),
- noBorder(data.noBorder), noContent(data.noContent) {}
-
-};
-
-inline uint qHash(const ThemeMapKey &key)
-{ return key.theme ^ key.partId ^ key.stateId; }
-
-inline bool operator==(const ThemeMapKey &k1, const ThemeMapKey &k2)
-{
- return k1.theme == k2.theme
- && k1.partId == k2.partId
- && k1.stateId == k2.stateId;
-}
-
-enum AlphaChannelType {
- UnknownAlpha = -1, // Alpha of part & state not yet known
- NoAlpha, // Totally opaque, no need to touch alpha (RGB)
- MaskAlpha, // Alpha channel must be fixed (ARGB)
- RealAlpha // Proper alpha values from Windows (ARGB_Premultiplied)
-};
-
-struct ThemeMapData {
- AlphaChannelType alphaType; // Which type of alpha on part & state
-
- bool dataValid : 1; // Only used to detect if hash value is ok
- bool partIsTransparent : 1;
- bool hasAlphaChannel : 1; // True = part & state has real Alpha
- bool wasAlphaSwapped : 1; // True = alpha channel needs to be swapped
- bool hadInvalidAlpha : 1; // True = alpha channel contained invalid alpha values
-
- ThemeMapData() : dataValid(false), partIsTransparent(false),
- hasAlphaChannel(false), wasAlphaSwapped(false), hadInvalidAlpha(false) {}
-};
-
-class QWindowsXPStylePrivate : public QWindowsStylePrivate
-{
- Q_DECLARE_PUBLIC(QWindowsXPStyle)
-public:
- enum Theme {
- ButtonTheme,
- ComboboxTheme,
- EditTheme,
- HeaderTheme,
- ListViewTheme,
- MenuTheme,
- ProgressTheme,
- RebarTheme,
- ScrollBarTheme,
- SpinTheme,
- TabTheme,
- TaskDialogTheme,
- ToolBarTheme,
- ToolTipTheme,
- TrackBarTheme,
- XpTreeViewTheme, // '+'/'-' shape treeview indicators (XP)
- WindowTheme,
- StatusTheme,
- VistaTreeViewTheme, // arrow shape treeview indicators (Vista) obtained from "explorer" theme.
- NThemes
- };
-
- QWindowsXPStylePrivate()
- : QWindowsStylePrivate(), hasInitColors(false), bufferDC(0), bufferBitmap(0), nullBitmap(0),
- bufferPixels(0), bufferW(0), bufferH(0)
- { init(); }
-
- ~QWindowsXPStylePrivate()
- { cleanup(); }
-
- static int pixelMetricFromSystemDp(QStyle::PixelMetric pm, const QStyleOption *option = 0, const QWidget *widget = 0);
- static int fixedPixelMetric(QStyle::PixelMetric pm, const QStyleOption *option = 0, const QWidget *widget = 0);
-
- static HWND winId(const QWidget *widget);
-
- void init(bool force = false);
- void cleanup(bool force = false);
- void cleanupHandleMap();
- const QPixmap *tabBody(QWidget *widget);
-
- HBITMAP buffer(int w = 0, int h = 0);
- HDC bufferHDC()
- { return bufferDC;}
-
- static bool useXP(bool update = false);
- static QRect scrollBarGripperBounds(QStyle::State flags, const QWidget *widget, XPThemeData *theme);
-
- bool isTransparent(XPThemeData &themeData);
- QRegion region(XPThemeData &themeData);
-
- void setTransparency(QWidget *widget, XPThemeData &themeData);
- bool drawBackground(XPThemeData &themeData);
- bool drawBackgroundThruNativeBuffer(XPThemeData &themeData, qreal aditionalDevicePixelRatio);
- bool drawBackgroundDirectly(HDC dc, XPThemeData &themeData, qreal aditionalDevicePixelRatio);
-
- bool hasAlphaChannel(const QRect &rect);
- bool fixAlphaChannel(const QRect &rect);
- bool swapAlphaChannel(const QRect &rect, bool allPixels = false);
-
- QRgb groupBoxTextColor;
- QRgb groupBoxTextColorDisabled;
- QRgb sliderTickColor;
- bool hasInitColors;
-
- static HTHEME createTheme(int theme, HWND hwnd);
- static QString themeName(int theme);
- static inline bool hasTheme(int theme) { return theme >= 0 && theme < NThemes && m_themes[theme]; }
- static bool isItemViewDelegateLineEdit(const QWidget *widget);
- static bool isLineEditBaseColorSet(const QStyleOption *option, const QWidget *widget);
-
- QIcon dockFloat, dockClose;
-
-private:
-#ifdef DEBUG_XP_STYLE
- void dumpNativeDIB(int w, int h);
- void showProperties(XPThemeData &themeData);
-#endif
-
- static bool initVistaTreeViewTheming();
- static void cleanupVistaTreeViewTheming();
-
- static QBasicAtomicInt ref;
- static bool use_xp;
- static QPixmap *tabbody;
-
- QHash<ThemeMapKey, ThemeMapData> alphaCache;
- HDC bufferDC;
- HBITMAP bufferBitmap;
- HBITMAP nullBitmap;
- uchar *bufferPixels;
- int bufferW, bufferH;
-
- static HWND m_vistaTreeViewHelper;
- static HTHEME m_themes[NThemes];
-};
-
-inline QSizeF XPThemeData::size()
-{
- QSizeF result(0, 0);
- if (isValid()) {
- SIZE size;
- if (SUCCEEDED(GetThemePartSize(handle(), 0, partId, stateId, 0, TS_TRUE, &size)))
- result = QSize(size.cx, size.cy);
- }
- return result;
-}
-
-inline QMarginsF XPThemeData::margins(const QRect &qRect, int propId)
-{
- QMarginsF result(0, 0, 0 ,0);
- if (isValid()) {
- MARGINS margins;
- RECT rect = XPThemeData::toRECT(qRect);
- if (SUCCEEDED(GetThemeMargins(handle(), 0, partId, stateId, propId, &rect, &margins)))
- result = QMargins(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight);
- }
- return result;
-}
-
-inline QMarginsF XPThemeData::margins(int propId)
-{
- QMarginsF result(0, 0, 0 ,0);
- if (isValid()) {
- MARGINS margins;
- if (SUCCEEDED(GetThemeMargins(handle(), 0, partId, stateId, propId, NULL, &margins)))
- result = QMargins(margins.cxLeftWidth, margins.cyTopHeight, margins.cxRightWidth, margins.cyBottomHeight);
- }
- return result;
-}
-
-inline QSizeF XPThemeData::themeSize(const QWidget *w, QPainter *p, int themeIn, int part, int state)
-{
- XPThemeData theme(w, p, themeIn, part, state);
- return theme.size();
-}
-
-inline QMarginsF XPThemeData::themeMargins(const QRect &rect, const QWidget *w, QPainter *p, int themeIn,
- int part, int state, int propId)
-{
- XPThemeData theme(w, p, themeIn, part, state);
- return theme.margins(rect, propId);
-}
-
-inline QMarginsF XPThemeData::themeMargins(const QWidget *w, QPainter *p, int themeIn,
- int part, int state, int propId)
-{
- XPThemeData theme(w, p, themeIn, part, state);
- return theme.margins(propId);
-}
-
-#endif // style_windows
-
-QT_END_NAMESPACE
-
-#endif //QWINDOWSXPSTYLE_P_P_H
diff --git a/src/widgets/styles/styles.pri b/src/widgets/styles/styles.pri
index 481123f0d4..0c0f8b7bc7 100644
--- a/src/widgets/styles/styles.pri
+++ b/src/widgets/styles/styles.pri
@@ -37,24 +37,6 @@ RESOURCES += styles/qstyle.qrc
include($$OUT_PWD/qtwidgets-config.pri)
-qtConfig(style-mac) {
- HEADERS += \
- styles/qmacstyle_mac_p.h \
- styles/qmacstyle_mac_p_p.h
- OBJECTIVE_SOURCES += styles/qmacstyle_mac.mm
- LIBS_PRIVATE += -framework Carbon
-}
-
-qtConfig(style-windowsvista) {
- HEADERS += styles/qwindowsvistastyle_p.h styles/qwindowsvistastyle_p_p.h
- SOURCES += styles/qwindowsvistastyle.cpp
-}
-
-qtConfig(style-windowsxp) {
- HEADERS += styles/qwindowsxpstyle_p.h styles/qwindowsxpstyle_p_p.h
- SOURCES += styles/qwindowsxpstyle.cpp
-}
-
qtConfig(style-windows) {
HEADERS += styles/qwindowsstyle_p.h styles/qwindowsstyle_p_p.h
SOURCES += styles/qwindowsstyle.cpp
@@ -64,8 +46,3 @@ qtConfig(style-fusion) {
HEADERS += styles/qfusionstyle_p.h styles/qfusionstyle_p_p.h
SOURCES += styles/qfusionstyle.cpp
}
-
-qtConfig(style-android) {
- HEADERS += styles/qandroidstyle_p.h
- SOURCES += styles/qandroidstyle.cpp
-}
diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp
index 3a287c5fa4..d444fe6053 100644
--- a/src/widgets/util/qcompleter.cpp
+++ b/src/widgets/util/qcompleter.cpp
@@ -158,6 +158,7 @@
#include "QtWidgets/qapplication.h"
#include "QtGui/qevent.h"
#include "QtWidgets/qdesktopwidget.h"
+#include <private/qdesktopwidget_p.h>
#if QT_CONFIG(lineedit)
#include "QtWidgets/qlineedit.h"
#endif
@@ -496,18 +497,25 @@ QMatchData QCompletionEngine::filterHistory()
}
// Returns a match hint from the cache by chopping the search string
-bool QCompletionEngine::matchHint(QString part, const QModelIndex& parent, QMatchData *hint)
+bool QCompletionEngine::matchHint(const QString &part, const QModelIndex &parent, QMatchData *hint) const
{
- if (c->cs == Qt::CaseInsensitive)
- part = std::move(part).toLower();
+ if (part.isEmpty())
+ return false; // early out to avoid cache[parent] lookup costs
- const CacheItem& map = cache[parent];
+ const auto cit = cache.find(parent);
+ if (cit == cache.end())
+ return false;
+
+ const CacheItem& map = *cit;
+ const auto mapEnd = map.end();
+
+ QString key = c->cs == Qt::CaseInsensitive ? part.toLower() : part;
- QString key = part;
while (!key.isEmpty()) {
key.chop(1);
- if (map.contains(key)) {
- *hint = map[key];
+ const auto it = map.find(key);
+ if (it != mapEnd) {
+ *hint = *it;
return true;
}
}
@@ -515,15 +523,25 @@ bool QCompletionEngine::matchHint(QString part, const QModelIndex& parent, QMatc
return false;
}
-bool QCompletionEngine::lookupCache(QString part, const QModelIndex& parent, QMatchData *m)
+bool QCompletionEngine::lookupCache(const QString &part, const QModelIndex &parent, QMatchData *m) const
{
- if (c->cs == Qt::CaseInsensitive)
- part = std::move(part).toLower();
- const CacheItem& map = cache[parent];
- if (!map.contains(part))
- return false;
- *m = map[part];
- return true;
+ if (part.isEmpty())
+ return false; // early out to avoid cache[parent] lookup costs
+
+ const auto cit = cache.find(parent);
+ if (cit == cache.end())
+ return false;
+
+ const CacheItem& map = *cit;
+
+ const QString key = c->cs == Qt::CaseInsensitive ? part.toLower() : part;
+
+ const auto it = map.find(key);
+ if (it == map.end())
+ return false;
+
+ *m = it.value();
+ return true;
}
// When the cache size exceeds 1MB, it clears out about 1/2 of the cache.
@@ -905,7 +923,7 @@ void QCompleterPrivate::_q_autoResizePopup()
void QCompleterPrivate::showPopup(const QRect& rect)
{
- const QRect screen = QApplication::desktop()->availableGeometry(widget);
+ const QRect screen = QDesktopWidgetPrivate::availableGeometry(widget);
Qt::LayoutDirection dir = widget->layoutDirection();
QPoint pos;
int rh, w;
diff --git a/src/widgets/util/qcompleter.h b/src/widgets/util/qcompleter.h
index 1a2c2440f5..de79302e15 100644
--- a/src/widgets/util/qcompleter.h
+++ b/src/widgets/util/qcompleter.h
@@ -82,10 +82,10 @@ public:
CaseInsensitivelySortedModel
};
- QCompleter(QObject *parent = Q_NULLPTR);
- QCompleter(QAbstractItemModel *model, QObject *parent = Q_NULLPTR);
+ QCompleter(QObject *parent = nullptr);
+ QCompleter(QAbstractItemModel *model, QObject *parent = nullptr);
#ifndef QT_NO_STRINGLISTMODEL
- QCompleter(const QStringList& completions, QObject *parent = Q_NULLPTR);
+ QCompleter(const QStringList& completions, QObject *parent = nullptr);
#endif
~QCompleter();
@@ -142,8 +142,8 @@ public:
virtual QStringList splitPath(const QString &path) const;
protected:
- bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE;
- bool event(QEvent *) Q_DECL_OVERRIDE;
+ bool eventFilter(QObject *o, QEvent *e) override;
+ bool event(QEvent *) override;
Q_SIGNALS:
void activated(const QString &text);
diff --git a/src/widgets/util/qcompleter_p.h b/src/widgets/util/qcompleter_p.h
index 5b89f9d8b5..765363744b 100644
--- a/src/widgets/util/qcompleter_p.h
+++ b/src/widgets/util/qcompleter_p.h
@@ -153,10 +153,10 @@ public:
void filter(const QStringList &parts);
QMatchData filterHistory();
- bool matchHint(QString, const QModelIndex&, QMatchData*);
+ bool matchHint(const QString &part, const QModelIndex &parent, QMatchData *m) const;
void saveInCache(QString, const QModelIndex&, const QMatchData&);
- bool lookupCache(QString part, const QModelIndex& parent, QMatchData *m);
+ bool lookupCache(const QString &part, const QModelIndex &parent, QMatchData *m) const;
virtual void filterOnDemand(int) { }
virtual QMatchData filter(const QString&, const QModelIndex&, int) = 0;
@@ -177,7 +177,7 @@ class QSortedModelEngine : public QCompletionEngine
{
public:
QSortedModelEngine(QCompleterPrivate *c) : QCompletionEngine(c) { }
- QMatchData filter(const QString&, const QModelIndex&, int) Q_DECL_OVERRIDE;
+ QMatchData filter(const QString&, const QModelIndex&, int) override;
QIndexMapper indexHint(QString, const QModelIndex&, Qt::SortOrder);
Qt::SortOrder sortOrder(const QModelIndex&) const;
};
@@ -187,8 +187,8 @@ class QUnsortedModelEngine : public QCompletionEngine
public:
QUnsortedModelEngine(QCompleterPrivate *c) : QCompletionEngine(c) { }
- void filterOnDemand(int) Q_DECL_OVERRIDE;
- QMatchData filter(const QString&, const QModelIndex&, int) Q_DECL_OVERRIDE;
+ void filterOnDemand(int) override;
+ QMatchData filter(const QString&, const QModelIndex&, int) override;
private:
int buildIndices(const QString& str, const QModelIndex& parent, int n,
const QIndexMapper& iv, QMatchData* m);
@@ -199,7 +199,7 @@ class QCompleterItemDelegate : public QItemDelegate
public:
QCompleterItemDelegate(QAbstractItemView *view)
: QItemDelegate(view), view(view) { }
- void paint(QPainter *p, const QStyleOptionViewItem& opt, const QModelIndex& idx) const Q_DECL_OVERRIDE {
+ void paint(QPainter *p, const QStyleOptionViewItem& opt, const QModelIndex& idx) const override {
QStyleOptionViewItem optCopy = opt;
optCopy.showDecorationSelected = true;
if (view->currentIndex() == idx)
@@ -228,16 +228,16 @@ public:
bool setCurrentRow(int row);
QModelIndex currentIndex(bool) const;
- QModelIndex index(int row, int column, const QModelIndex & = QModelIndex()) const Q_DECL_OVERRIDE;
- int rowCount(const QModelIndex &index = QModelIndex()) const Q_DECL_OVERRIDE;
- int columnCount(const QModelIndex &index = QModelIndex()) const Q_DECL_OVERRIDE;
- bool hasChildren(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
- QModelIndex parent(const QModelIndex & = QModelIndex()) const Q_DECL_OVERRIDE { return QModelIndex(); }
- QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
+ QModelIndex index(int row, int column, const QModelIndex & = QModelIndex()) const override;
+ int rowCount(const QModelIndex &index = QModelIndex()) const override;
+ int columnCount(const QModelIndex &index = QModelIndex()) const override;
+ bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
+ QModelIndex parent(const QModelIndex & = QModelIndex()) const override { return QModelIndex(); }
+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
- void setSourceModel(QAbstractItemModel *sourceModel) Q_DECL_OVERRIDE;
- QModelIndex mapToSource(const QModelIndex& proxyIndex) const Q_DECL_OVERRIDE;
- QModelIndex mapFromSource(const QModelIndex& sourceIndex) const Q_DECL_OVERRIDE;
+ void setSourceModel(QAbstractItemModel *sourceModel) override;
+ QModelIndex mapToSource(const QModelIndex& proxyIndex) const override;
+ QModelIndex mapFromSource(const QModelIndex& sourceIndex) const override;
QCompleterPrivate *c;
QScopedPointer<QCompletionEngine> engine;
diff --git a/src/widgets/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp
index 549b130c9d..b59fe0d504 100644
--- a/src/widgets/util/qflickgesture.cpp
+++ b/src/widgets/util/qflickgesture.cpp
@@ -256,7 +256,7 @@ public:
}
protected:
- void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE
+ void timerEvent(QTimerEvent *e) override
{
if (e->timerId() == pressDelayTimer) {
if (pressDelayEvent && mouseTarget) {
diff --git a/src/widgets/util/qscroller.cpp b/src/widgets/util/qscroller.cpp
index d8ac686fb9..903a141e49 100644
--- a/src/widgets/util/qscroller.cpp
+++ b/src/widgets/util/qscroller.cpp
@@ -58,6 +58,7 @@
#include <QGraphicsView>
#endif
#include <QDesktopWidget>
+#include <private/qdesktopwidget_p.h>
#include <QVector2D>
#include <QtCore/qmath.h>
#include <QtGui/qevent.h>
@@ -198,7 +199,7 @@ public:
: QAbstractAnimation(_d), d(_d), ignoreUpdate(false), skip(0)
{ }
- int duration() const Q_DECL_OVERRIDE
+ int duration() const override
{
return -1;
}
@@ -214,7 +215,7 @@ public:
}
protected:
- void updateCurrentTime(int /*currentTime*/) Q_DECL_OVERRIDE
+ void updateCurrentTime(int /*currentTime*/) override
{
if (!ignoreUpdate) {
if (++skip >= d->frameRateSkip()) {
@@ -280,10 +281,9 @@ private:
*/
typedef QMap<QObject *, QScroller *> ScrollerHash;
-typedef QSet<QScroller *> ScrollerSet;
Q_GLOBAL_STATIC(ScrollerHash, qt_allScrollers)
-Q_GLOBAL_STATIC(ScrollerSet, qt_activeScrollers)
+Q_GLOBAL_STATIC(QList<QScroller *>, qt_activeScrollers)
/*!
Returns \c true if a QScroller object was already created for \a target; \c false otherwise.
@@ -334,7 +334,7 @@ const QScroller *QScroller::scroller(const QObject *target)
*/
QList<QScroller *> QScroller::activeScrollers()
{
- return qt_activeScrollers()->toList();
+ return *qt_activeScrollers();
}
/*!
@@ -348,7 +348,7 @@ QObject *QScroller::target() const
}
/*!
- \fn QScroller::scrollerPropertiesChanged(const QScrollerProperties &newProperties);
+ \fn void QScroller::scrollerPropertiesChanged(const QScrollerProperties &newProperties);
QScroller emits this signal whenever its scroller properties change.
\a newProperties are the new scroller properties.
@@ -511,14 +511,14 @@ QScroller::~QScroller()
d->recognizer = 0;
#endif
qt_allScrollers()->remove(d->target);
- qt_activeScrollers()->remove(this);
+ qt_activeScrollers()->removeOne(this);
delete d_ptr;
}
/*!
- \fn QScroller::stateChanged(QScroller::State newState);
+ \fn void QScroller::stateChanged(QScroller::State newState);
QScroller emits this signal whenever the state changes. \a newState is the new State.
@@ -1013,40 +1013,6 @@ bool QScroller::handleInput(Input input, const QPointF &position, qint64 timesta
return false;
}
-#if 1 // Used to be excluded in Qt4 for Q_WS_MAC
-// the Mac version is implemented in qscroller_mac.mm
-
-QPointF QScrollerPrivate::realDpi(int screen) const
-{
-# if 0 /* Used to be included in Qt4 for Q_WS_X11 */ && !defined(QT_NO_XRANDR)
- if (X11 && X11->use_xrandr && X11->ptrXRRSizes && X11->ptrXRRRootToScreen) {
- int nsizes = 0;
- // QDesktopWidget is based on Xinerama screens, which do not always
- // correspond to RandR screens: NVidia's TwinView e.g. will show up
- // as 2 screens in QDesktopWidget, but libXRandR will only see 1 screen.
- // (although with the combined size of the Xinerama screens).
- // Additionally, libXrandr will simply crash when calling XRRSizes
- // for (the non-existent) screen 1 in this scenario.
- Window root = RootWindow(X11->display, screen == -1 ? X11->defaultScreen : screen);
- int randrscreen = (root != XNone) ? X11->ptrXRRRootToScreen(X11->display, root) : -1;
-
- XRRScreenSize *sizes = X11->ptrXRRSizes(X11->display, randrscreen == -1 ? 0 : randrscreen, &nsizes);
- if (nsizes > 0 && sizes && sizes->width && sizes->height && sizes->mwidth && sizes->mheight) {
- qScrollerDebug() << "XRandR DPI:" << QPointF(qreal(25.4) * qreal(sizes->width) / qreal(sizes->mwidth),
- qreal(25.4) * qreal(sizes->height) / qreal(sizes->mheight));
- return QPointF(qreal(25.4) * qreal(sizes->width) / qreal(sizes->mwidth),
- qreal(25.4) * qreal(sizes->height) / qreal(sizes->mheight));
- }
- }
-# endif
-
- QWidget *w = QApplication::desktop()->screen(screen);
- return QPointF(w->physicalDpiX(), w->physicalDpiY());
-}
-
-#endif
-
-
/*! \internal
Returns the resolution of the used screen.
*/
@@ -1071,8 +1037,8 @@ void QScrollerPrivate::setDpi(const QPointF &dpi)
*/
void QScrollerPrivate::setDpiFromWidget(QWidget *widget)
{
- QDesktopWidget *dw = QApplication::desktop();
- setDpi(realDpi(widget ? dw->screenNumber(widget) : dw->primaryScreen()));
+ const QScreen *screen = QGuiApplication::screens().at(QApplication::desktop()->screenNumber(widget));
+ setDpi(QPointF(screen->physicalDotsPerInchX(), screen->physicalDotsPerInchY()));
}
/*! \internal
@@ -1767,9 +1733,9 @@ void QScrollerPrivate::setState(QScroller::State newstate)
firstScroll = true;
}
if (state == QScroller::Dragging || state == QScroller::Scrolling)
- qt_activeScrollers()->insert(q);
+ qt_activeScrollers()->push_back(q);
else
- qt_activeScrollers()->remove(q);
+ qt_activeScrollers()->removeOne(q);
emit q->stateChanged(state);
}
diff --git a/src/widgets/util/qscroller_p.h b/src/widgets/util/qscroller_p.h
index 4557e7cc33..5e0c359514 100644
--- a/src/widgets/util/qscroller_p.h
+++ b/src/widgets/util/qscroller_p.h
@@ -119,7 +119,6 @@ public:
bool prepareScrolling(const QPointF &position);
void handleDrag(const QPointF &position, qint64 timestamp);
- QPointF realDpi(int screen) const;
QPointF dpi() const;
void setDpi(const QPointF &dpi);
void setDpiFromWidget(QWidget *widget);
diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp
index 884bed2e68..86c824afdb 100644
--- a/src/widgets/util/qsystemtrayicon.cpp
+++ b/src/widgets/util/qsystemtrayicon.cpp
@@ -61,8 +61,12 @@
#include "qgridlayout.h"
#include "qapplication.h"
#include "qdesktopwidget.h"
+#include <private/qdesktopwidget_p.h>
#include "qbitmap.h"
+#include <private/qhighdpiscaling_p.h>
+#include <qpa/qplatformscreen.h>
+
QT_BEGIN_NAMESPACE
static QIcon messageIcon2qIcon(QSystemTrayIcon::MessageIcon icon)
@@ -196,8 +200,23 @@ QSystemTrayIcon::~QSystemTrayIcon()
void QSystemTrayIcon::setContextMenu(QMenu *menu)
{
Q_D(QSystemTrayIcon);
+ QMenu *oldMenu = d->menu.data();
d->menu = menu;
d->updateMenu_sys();
+ if (oldMenu != menu && d->qpa_sys) {
+ // Show the QMenu-based menu for QPA plugins that do not provide native menus
+ if (oldMenu && !oldMenu->platformMenu())
+ QObject::disconnect(d->qpa_sys, &QPlatformSystemTrayIcon::contextMenuRequested, menu, nullptr);
+ if (menu && !menu->platformMenu()) {
+ QObject::connect(d->qpa_sys, &QPlatformSystemTrayIcon::contextMenuRequested,
+ menu,
+ [menu](QPoint globalNativePos, const QPlatformScreen *platformScreen)
+ {
+ QScreen *screen = platformScreen ? platformScreen->screen() : nullptr;
+ menu->popup(QHighDpi::fromNativePixels(globalNativePos, screen), nullptr);
+ });
+ }
+ }
}
/*!
@@ -323,7 +342,9 @@ bool QSystemTrayIcon::event(QEvent *e)
\value Unknown Unknown reason
\value Context The context menu for the system tray entry was requested
- \value DoubleClick The system tray entry was double clicked
+ \value DoubleClick The system tray entry was double clicked. \note On macOS, a
+ double click will only be emitted if no context menu is set, since the menu
+ opens on mouse press
\value Trigger The system tray entry was clicked
\value MiddleClick The system tray entry was clicked with the middle mouse button
@@ -348,7 +369,7 @@ bool QSystemTrayIcon::event(QEvent *e)
Currently this signal is not sent on \macos.
- \note We follow Microsoft Windows XP/Vista behavior, so the
+ \note We follow Microsoft Windows behavior, so the
signal is also emitted when the user clicks on a tray icon with
a balloon message displayed.
@@ -512,7 +533,7 @@ QBalloonTip::QBalloonTip(const QIcon &icon, const QString &title,
msgLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
// smart size for the message label
- int limit = QApplication::desktop()->availableGeometry(msgLabel).size().width() / 3;
+ int limit = QDesktopWidgetPrivate::availableGeometry(msgLabel).size().width() / 3;
if (msgLabel->sizeHint().width() > limit) {
msgLabel->setWordWrap(true);
if (msgLabel->sizeHint().width() > limit) {
@@ -579,7 +600,7 @@ void QBalloonTip::resizeEvent(QResizeEvent *ev)
void QBalloonTip::balloon(const QPoint& pos, int msecs, bool showArrow)
{
this->showArrow = showArrow;
- QRect scr = QApplication::desktop()->screenGeometry(pos);
+ QRect scr = QDesktopWidgetPrivate::screenGeometry(pos);
QSize sh = sizeHint();
const int border = 1;
const int ah = 18, ao = 18, aw = 18, rc = 7;
diff --git a/src/widgets/util/qsystemtrayicon.h b/src/widgets/util/qsystemtrayicon.h
index 81f396ed83..e4652b742c 100644
--- a/src/widgets/util/qsystemtrayicon.h
+++ b/src/widgets/util/qsystemtrayicon.h
@@ -66,8 +66,8 @@ class Q_WIDGETS_EXPORT QSystemTrayIcon : public QObject
Q_PROPERTY(bool visible READ isVisible WRITE setVisible DESIGNABLE false)
public:
- QSystemTrayIcon(QObject *parent = Q_NULLPTR);
- QSystemTrayIcon(const QIcon &icon, QObject *parent = Q_NULLPTR);
+ QSystemTrayIcon(QObject *parent = nullptr);
+ QSystemTrayIcon(const QIcon &icon, QObject *parent = nullptr);
~QSystemTrayIcon();
enum ActivationReason {
@@ -110,7 +110,7 @@ Q_SIGNALS:
void messageClicked();
protected:
- bool event(QEvent *event) Q_DECL_OVERRIDE;
+ bool event(QEvent *event) override;
private:
Q_DISABLE_COPY(QSystemTrayIcon)
diff --git a/src/widgets/util/qsystemtrayicon_p.h b/src/widgets/util/qsystemtrayicon_p.h
index 318edbd1e3..5bdf020a47 100644
--- a/src/widgets/util/qsystemtrayicon_p.h
+++ b/src/widgets/util/qsystemtrayicon_p.h
@@ -127,10 +127,10 @@ private:
void balloon(const QPoint&, int, bool);
protected:
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent *) override;
+ void resizeEvent(QResizeEvent *) override;
+ void mousePressEvent(QMouseEvent *e) override;
+ void timerEvent(QTimerEvent *e) override;
private:
QSystemTrayIcon *trayIcon;
diff --git a/src/widgets/util/qsystemtrayicon_win.cpp b/src/widgets/util/qsystemtrayicon_win.cpp
deleted file mode 100644
index 57d46912e0..0000000000
--- a/src/widgets/util/qsystemtrayicon_win.cpp
+++ /dev/null
@@ -1,599 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qsystemtrayicon_p.h"
-#ifndef QT_NO_SYSTEMTRAYICON
-
-#if defined(_WIN32_IE) && _WIN32_IE < 0x0600
-# undef _WIN32_IE
-#endif
-#if !defined(_WIN32_IE)
-# define _WIN32_IE 0x0600 //required for NOTIFYICONDATA_V2_SIZE
-#endif
-
-#include <private/qsystemlibrary_p.h>
-#include <private/qguiapplication_p.h>
-#include <private/qhighdpiscaling_p.h>
-#include <qpa/qplatformnativeinterface.h>
-#include <qpa/qplatformscreen.h>
-#include <QSettings>
-#include <QDebug>
-#include <QHash>
-
-#include <qt_windows.h>
-#include <commctrl.h>
-#include <windowsx.h>
-
-QT_BEGIN_NAMESPACE
-
-static const UINT q_uNOTIFYICONID = 0;
-
-static uint MYWM_TASKBARCREATED = 0;
-#define MYWM_NOTIFYICON (WM_APP+101)
-
-struct Q_NOTIFYICONIDENTIFIER {
- DWORD cbSize;
- HWND hWnd;
- UINT uID;
- GUID guidItem;
-};
-
-#ifndef NIN_KEYSELECT
-# define NIN_KEYSELECT (WM_USER + 1)
-#endif
-
-#ifdef Q_CC_MINGW
-# define NIN_SELECT (WM_USER + 0)
-# define NIN_BALLOONTIMEOUT (WM_USER + 4)
-# define NIN_BALLOONUSERCLICK (WM_USER + 5)
-# define NIF_SHOWTIP 0x00000080
-# define NIIF_LARGE_ICON 0x00000020
-# define NOTIFYICON_VERSION_4 4
-#endif
-
-#define Q_MSGFLT_ALLOW 1
-
-Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &);
-
-typedef HRESULT (WINAPI *PtrShell_NotifyIconGetRect)(const Q_NOTIFYICONIDENTIFIER* identifier, RECT* iconLocation);
-typedef BOOL (WINAPI *PtrChangeWindowMessageFilter)(UINT message, DWORD dwFlag);
-typedef BOOL (WINAPI *PtrChangeWindowMessageFilterEx)(HWND hWnd, UINT message, DWORD action, void* pChangeFilterStruct);
-
-// Copy QString data to a limited wchar_t array including \0.
-static inline void qStringToLimitedWCharArray(QString in, wchar_t *target, int maxLength)
-{
- const int length = qMin(maxLength - 1, in.size());
- if (length < in.size())
- in.truncate(length);
- in.toWCharArray(target);
- target[length] = wchar_t(0);
-}
-
-class QSystemTrayIconSys
-{
-public:
- QSystemTrayIconSys(HWND hwnd, QSystemTrayIcon *object);
- ~QSystemTrayIconSys();
- bool trayMessage(DWORD msg);
- void setIconContents(NOTIFYICONDATA &data);
- bool showMessage(const QString &title, const QString &message, const QIcon &icon, uint uSecs);
- QRect findIconGeometry(UINT iconId);
- HICON createIcon();
- bool winEvent(MSG *m, long *result);
-
-private:
- const HWND m_hwnd;
- HICON hIcon;
- QPoint globalPos;
- QSystemTrayIcon *q;
- uint notifyIconSize;
- int version;
- bool ignoreNextMouseRelease;
-};
-
-static bool allowsMessages()
-{
-#ifndef QT_NO_SETTINGS
- const QString key = QStringLiteral("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced");
- const QSettings settings(key, QSettings::NativeFormat);
- return settings.value(QStringLiteral("EnableBalloonTips"), true).toBool();
-#else
- return false;
-#endif
-}
-
-typedef QHash<HWND, QSystemTrayIconSys *> HandleTrayIconHash;
-
-Q_GLOBAL_STATIC(HandleTrayIconHash, handleTrayIconHash)
-
-extern "C" LRESULT QT_WIN_CALLBACK qWindowsTrayconWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
- if (message == MYWM_TASKBARCREATED || message == MYWM_NOTIFYICON) {
- if (QSystemTrayIconSys *trayIcon = handleTrayIconHash()->value(hwnd)) {
- MSG msg;
- msg.hwnd = hwnd; // re-create MSG structure
- msg.message = message; // time and pt fields ignored
- msg.wParam = wParam;
- msg.lParam = lParam;
- msg.pt.x = GET_X_LPARAM(lParam);
- msg.pt.y = GET_Y_LPARAM(lParam);
- long result = 0;
- if (trayIcon->winEvent(&msg, &result))
- return result;
- }
- }
- return DefWindowProc(hwnd, message, wParam, lParam);
-}
-
-// Invoke a service of the native Windows interface to create
-// a non-visible toplevel window to receive tray messages.
-// Note: Message windows (HWND_MESSAGE) are not sufficient, they
-// will not receive the "TaskbarCreated" message.
-static inline HWND createTrayIconMessageWindow()
-{
- QPlatformNativeInterface *ni = QGuiApplication::platformNativeInterface();
- if (!ni)
- return 0;
- // Register window class in the platform plugin.
- QString className;
- void *wndProc = reinterpret_cast<void *>(qWindowsTrayconWndProc);
- if (!QMetaObject::invokeMethod(ni, "registerWindowClass", Qt::DirectConnection,
- Q_RETURN_ARG(QString, className),
- Q_ARG(QString, QStringLiteral("QTrayIconMessageWindowClass")),
- Q_ARG(void *, wndProc))) {
- return 0;
- }
- const wchar_t windowName[] = L"QTrayIconMessageWindow";
- return CreateWindowEx(0, (wchar_t*)className.utf16(),
- windowName, WS_OVERLAPPED,
- CW_USEDEFAULT, CW_USEDEFAULT,
- CW_USEDEFAULT, CW_USEDEFAULT,
- NULL, NULL, (HINSTANCE)GetModuleHandle(0), NULL);
-}
-
-QSystemTrayIconSys::QSystemTrayIconSys(HWND hwnd, QSystemTrayIcon *object)
- : m_hwnd(hwnd), hIcon(0), q(object)
- , notifyIconSize(sizeof(NOTIFYICONDATA)), version(NOTIFYICON_VERSION_4)
- , ignoreNextMouseRelease(false)
-
-{
- handleTrayIconHash()->insert(m_hwnd, this);
-
- if (QSysInfo::windowsVersion() < QSysInfo::WV_VISTA) {
- notifyIconSize = NOTIFYICONDATA_V2_SIZE;
- version = NOTIFYICON_VERSION;
- }
-
- // For restoring the tray icon after explorer crashes
- if (!MYWM_TASKBARCREATED) {
- MYWM_TASKBARCREATED = RegisterWindowMessage(L"TaskbarCreated");
- }
-
- // Allow the WM_TASKBARCREATED message through the UIPI filter on Windows 7 and higher
- static PtrChangeWindowMessageFilterEx pChangeWindowMessageFilterEx =
- (PtrChangeWindowMessageFilterEx)QSystemLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilterEx");
-
- if (pChangeWindowMessageFilterEx) {
- // Call the safer ChangeWindowMessageFilterEx API if available (Windows 7 onwards)
- pChangeWindowMessageFilterEx(m_hwnd, MYWM_TASKBARCREATED, Q_MSGFLT_ALLOW, 0);
- } else {
- // Call the deprecated ChangeWindowMessageFilter API otherwise (Vista onwards)
- // May 2016: Still resolved at runtime since the definition is not present in MinGW 4.9.
- // TODO: Replace by direct invocation when upgrading MinGW.
- static PtrChangeWindowMessageFilter pChangeWindowMessageFilter =
- (PtrChangeWindowMessageFilter)QSystemLibrary::resolve(QLatin1String("user32"), "ChangeWindowMessageFilter");
-
- if (pChangeWindowMessageFilter)
- pChangeWindowMessageFilter(MYWM_TASKBARCREATED, Q_MSGFLT_ALLOW);
- }
-}
-
-QSystemTrayIconSys::~QSystemTrayIconSys()
-{
- handleTrayIconHash()->remove(m_hwnd);
- if (hIcon)
- DestroyIcon(hIcon);
- DestroyWindow(m_hwnd);
-}
-
-void QSystemTrayIconSys::setIconContents(NOTIFYICONDATA &tnd)
-{
- tnd.uFlags |= NIF_MESSAGE | NIF_ICON | NIF_TIP;
- tnd.uCallbackMessage = MYWM_NOTIFYICON;
- tnd.hIcon = hIcon;
- const QString tip = q->toolTip();
- if (!tip.isNull())
- qStringToLimitedWCharArray(tip, tnd.szTip, sizeof(tnd.szTip)/sizeof(wchar_t));
-}
-
-bool QSystemTrayIconSys::showMessage(const QString &title, const QString &message, const QIcon &icon, uint uSecs)
-{
- NOTIFYICONDATA tnd;
- memset(&tnd, 0, notifyIconSize);
- qStringToLimitedWCharArray(message, tnd.szInfo, 256);
- qStringToLimitedWCharArray(title, tnd.szInfoTitle, 64);
-
- tnd.uID = q_uNOTIFYICONID;
- tnd.dwInfoFlags = NIIF_USER;
-
- HICON *phIcon = &tnd.hIcon;
- QSize size(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON));
- if (version == NOTIFYICON_VERSION_4) {
- const QSize largeIcon(GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON));
- QSize more = icon.actualSize(largeIcon);
- if (more.height() > (largeIcon.height() * 3/4) || more.width() > (largeIcon.width() * 3/4)) {
- tnd.dwInfoFlags |= NIIF_LARGE_ICON;
- size = largeIcon;
- }
- phIcon = &tnd.hBalloonIcon;
- }
- QPixmap pm = icon.pixmap(size);
- if (pm.isNull()) {
- tnd.dwInfoFlags = NIIF_INFO;
- } else {
- if (pm.size() != size) {
- qWarning("QSystemTrayIcon::showMessage: Wrong icon size (%dx%d), please add standard one: %dx%d",
- pm.size().width(), pm.size().height(), size.width(), size.height());
- pm = pm.scaled(size, Qt::IgnoreAspectRatio);
- }
- *phIcon = qt_pixmapToWinHICON(pm);
- }
- tnd.cbSize = notifyIconSize;
- tnd.uVersion = version;
- tnd.hWnd = m_hwnd;
- tnd.uTimeout = uSecs;
- tnd.uFlags = NIF_INFO | NIF_SHOWTIP;
-
- return Shell_NotifyIcon(NIM_MODIFY, &tnd);
-}
-
-bool QSystemTrayIconSys::trayMessage(DWORD msg)
-{
- NOTIFYICONDATA tnd;
- memset(&tnd, 0, notifyIconSize);
-
- tnd.uID = q_uNOTIFYICONID;
- tnd.cbSize = notifyIconSize;
- tnd.hWnd = m_hwnd;
- tnd.uFlags = NIF_SHOWTIP;
- tnd.uVersion = version;
-
- if (msg == NIM_ADD || msg == NIM_MODIFY) {
- setIconContents(tnd);
- }
-
- bool success = Shell_NotifyIcon(msg, &tnd);
-
- if (msg == NIM_ADD)
- return success && Shell_NotifyIcon(NIM_SETVERSION, &tnd);
- else
- return success;
-}
-
-HICON QSystemTrayIconSys::createIcon()
-{
- const HICON oldIcon = hIcon;
- hIcon = 0;
- const QIcon icon = q->icon();
- if (icon.isNull())
- return oldIcon;
- // When merging this to 5.10, change at src/plugins/platforms/windows/qwindowssystemtrayicon.cpp:351.
- const QSize requestedSize = QSize(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON));
- const QSize size = icon.actualSize(requestedSize);
- const QPixmap pm = icon.pixmap(size);
- if (pm.isNull())
- return oldIcon;
- hIcon = qt_pixmapToWinHICON(pm);
- return oldIcon;
-}
-
-bool QSystemTrayIconSys::winEvent( MSG *m, long *result )
-{
- *result = 0;
- switch(m->message) {
- case MYWM_NOTIFYICON:
- {
- int message = 0;
- QPoint gpos;
-
- if (version == NOTIFYICON_VERSION_4) {
- Q_ASSERT(q_uNOTIFYICONID == HIWORD(m->lParam));
- message = LOWORD(m->lParam);
- gpos = QPoint(GET_X_LPARAM(m->wParam), GET_Y_LPARAM(m->wParam));
- // Drop this chunk when merging to 5.10; code has been moved to Windows QPA.
- if (const QScreen *primaryScreen = QGuiApplication::primaryScreen()) {
- if (const QPlatformScreen *screen = primaryScreen->handle()->screenForPosition(gpos)) {
- gpos = QHighDpi::fromNative(gpos, QHighDpiScaling::factor(screen),
- screen->geometry().topLeft());
- }
- }
- } else {
- Q_ASSERT(q_uNOTIFYICONID == m->wParam);
- message = m->lParam;
- gpos = QCursor::pos();
- }
-
- switch (message) {
- case NIN_SELECT:
- case NIN_KEYSELECT:
- if (ignoreNextMouseRelease)
- ignoreNextMouseRelease = false;
- else
- emit q->activated(QSystemTrayIcon::Trigger);
- break;
-
- case WM_LBUTTONDBLCLK:
- ignoreNextMouseRelease = true; // Since DBLCLICK Generates a second mouse
- // release we must ignore it
- emit q->activated(QSystemTrayIcon::DoubleClick);
- break;
-
- case WM_CONTEXTMENU:
- if (q->contextMenu()) {
- q->contextMenu()->popup(gpos);
- q->contextMenu()->activateWindow();
- }
- emit q->activated(QSystemTrayIcon::Context);
- break;
-
- case NIN_BALLOONUSERCLICK:
- emit q->messageClicked();
- break;
-
- case WM_MBUTTONUP:
- emit q->activated(QSystemTrayIcon::MiddleClick);
- break;
-
- default:
- break;
- }
- break;
- }
- default:
- if (m->message == MYWM_TASKBARCREATED) // self-registered message id.
- trayMessage(NIM_ADD);
- break;
- }
- return false;
-}
-
-QSystemTrayIconPrivate::QSystemTrayIconPrivate()
- : sys(0),
- visible(false)
-{
-}
-
-QSystemTrayIconPrivate::~QSystemTrayIconPrivate()
-{
-}
-
-void QSystemTrayIconPrivate::install_sys()
-{
- Q_Q(QSystemTrayIcon);
- if (!sys) {
- if (const HWND hwnd = createTrayIconMessageWindow()) {
- sys = new QSystemTrayIconSys(hwnd, q);
- sys->createIcon();
- sys->trayMessage(NIM_ADD);
- } else {
- qWarning("The platform plugin failed to create a message window.");
- }
- }
-}
-
-/*
-* This function tries to determine the icon geometry from the tray
-*
-* If it fails an invalid rect is returned.
-*/
-
-QRect QSystemTrayIconSys::findIconGeometry(UINT iconId)
-{
- struct AppData
- {
- HWND hwnd;
- UINT uID;
- };
-
- // Windows 7 onwards.
- static PtrShell_NotifyIconGetRect Shell_NotifyIconGetRect =
- (PtrShell_NotifyIconGetRect)QSystemLibrary::resolve(QLatin1String("shell32"),
- "Shell_NotifyIconGetRect");
-
- if (Shell_NotifyIconGetRect) {
- Q_NOTIFYICONIDENTIFIER nid;
- memset(&nid, 0, sizeof(nid));
- nid.cbSize = sizeof(nid);
- nid.hWnd = m_hwnd;
- nid.uID = iconId;
-
- RECT rect;
- HRESULT hr = Shell_NotifyIconGetRect(&nid, &rect);
- if (SUCCEEDED(hr)) {
- return QRect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
- }
- }
-
- QRect ret;
-
- TBBUTTON buttonData;
- DWORD processID = 0;
- HWND trayHandle = FindWindow(L"Shell_TrayWnd", NULL);
-
- //find the toolbar used in the notification area
- if (trayHandle) {
- trayHandle = FindWindowEx(trayHandle, NULL, L"TrayNotifyWnd", NULL);
- if (trayHandle) {
- HWND hwnd = FindWindowEx(trayHandle, NULL, L"SysPager", NULL);
- if (hwnd) {
- hwnd = FindWindowEx(hwnd, NULL, L"ToolbarWindow32", NULL);
- if (hwnd)
- trayHandle = hwnd;
- }
- }
- }
-
- if (!trayHandle)
- return ret;
-
- GetWindowThreadProcessId(trayHandle, &processID);
- if (processID <= 0)
- return ret;
-
- HANDLE trayProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ, 0, processID);
- if (!trayProcess)
- return ret;
-
- int buttonCount = SendMessage(trayHandle, TB_BUTTONCOUNT, 0, 0);
- LPVOID data = VirtualAllocEx(trayProcess, NULL, sizeof(TBBUTTON), MEM_COMMIT, PAGE_READWRITE);
-
- if ( buttonCount < 1 || !data ) {
- CloseHandle(trayProcess);
- return ret;
- }
-
- //search for our icon among all toolbar buttons
- for (int toolbarButton = 0; toolbarButton < buttonCount; ++toolbarButton ) {
- SIZE_T numBytes = 0;
- AppData appData = { 0, 0 };
- SendMessage(trayHandle, TB_GETBUTTON, toolbarButton , (LPARAM)data);
-
- if (!ReadProcessMemory(trayProcess, data, &buttonData, sizeof(TBBUTTON), &numBytes))
- continue;
-
- if (!ReadProcessMemory(trayProcess, (LPVOID) buttonData.dwData, &appData, sizeof(AppData), &numBytes))
- continue;
-
- bool isHidden = buttonData.fsState & TBSTATE_HIDDEN;
-
- if (m_hwnd == appData.hwnd && appData.uID == iconId && !isHidden) {
- SendMessage(trayHandle, TB_GETITEMRECT, toolbarButton , (LPARAM)data);
- RECT iconRect = {0, 0, 0, 0};
- if(ReadProcessMemory(trayProcess, data, &iconRect, sizeof(RECT), &numBytes)) {
- MapWindowPoints(trayHandle, NULL, (LPPOINT)&iconRect, 2);
- QRect geometry(iconRect.left + 1, iconRect.top + 1,
- iconRect.right - iconRect.left - 2,
- iconRect.bottom - iconRect.top - 2);
- if (geometry.isValid())
- ret = geometry;
- break;
- }
- }
- }
- VirtualFreeEx(trayProcess, data, 0, MEM_RELEASE);
- CloseHandle(trayProcess);
- return ret;
-}
-
-void QSystemTrayIconPrivate::showMessage_sys(const QString &title,
- const QString &messageIn,
- const QIcon &icon,
- QSystemTrayIcon::MessageIcon,
- int timeOut)
-{
- if (!sys || !allowsMessages())
- return;
-
- // 10 sec default
- const uint uSecs = timeOut < 0 ? uint(10000) : uint(timeOut);
- // For empty messages, ensures that they show when only title is set
- QString message = messageIn;
- if (message.isEmpty() && !title.isEmpty())
- message.append(QLatin1Char(' '));
-
- sys->showMessage(title, message, icon, uSecs);
-}
-
-QRect QSystemTrayIconPrivate::geometry_sys() const
-{
- if (!sys)
- return QRect();
-
- return sys->findIconGeometry(q_uNOTIFYICONID);
-}
-
-void QSystemTrayIconPrivate::remove_sys()
-{
- if (!sys)
- return;
-
- sys->trayMessage(NIM_DELETE);
- delete sys;
- sys = 0;
-}
-
-void QSystemTrayIconPrivate::updateIcon_sys()
-{
- if (!sys)
- return;
-
- const HICON hIconToDestroy = sys->createIcon();
- sys->trayMessage(NIM_MODIFY);
-
- if (hIconToDestroy)
- DestroyIcon(hIconToDestroy);
-}
-
-void QSystemTrayIconPrivate::updateMenu_sys()
-{
-#if QT_CONFIG(menu)
-#endif
-}
-
-void QSystemTrayIconPrivate::updateToolTip_sys()
-{
- if (!sys)
- return;
-
- sys->trayMessage(NIM_MODIFY);
-}
-
-bool QSystemTrayIconPrivate::isSystemTrayAvailable_sys()
-{
- return true;
-}
-
-bool QSystemTrayIconPrivate::supportsMessages_sys()
-{
- return allowsMessages();
-}
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp
index cd593d8d98..df93e15f80 100644
--- a/src/widgets/util/qsystemtrayicon_x11.cpp
+++ b/src/widgets/util/qsystemtrayicon_x11.cpp
@@ -87,12 +87,12 @@ public:
QRect globalGeometry() const;
protected:
- virtual void mousePressEvent(QMouseEvent *ev) Q_DECL_OVERRIDE;
- virtual void mouseDoubleClickEvent(QMouseEvent *ev) Q_DECL_OVERRIDE;
- virtual bool event(QEvent *) Q_DECL_OVERRIDE;
- virtual void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
- virtual void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
- virtual void moveEvent(QMoveEvent *) Q_DECL_OVERRIDE;
+ virtual void mousePressEvent(QMouseEvent *ev) override;
+ virtual void mouseDoubleClickEvent(QMouseEvent *ev) override;
+ virtual bool event(QEvent *) override;
+ virtual void paintEvent(QPaintEvent *) override;
+ virtual void resizeEvent(QResizeEvent *) override;
+ virtual void moveEvent(QMoveEvent *) override;
private slots:
void systemTrayWindowChanged(QScreen *screen);
diff --git a/src/widgets/util/qundogroup.h b/src/widgets/util/qundogroup.h
index dba79ea706..1845f7e057 100644
--- a/src/widgets/util/qundogroup.h
+++ b/src/widgets/util/qundogroup.h
@@ -58,7 +58,7 @@ class Q_WIDGETS_EXPORT QUndoGroup : public QObject
Q_DECLARE_PRIVATE(QUndoGroup)
public:
- explicit QUndoGroup(QObject *parent = Q_NULLPTR);
+ explicit QUndoGroup(QObject *parent = nullptr);
~QUndoGroup();
void addStack(QUndoStack *stack);
diff --git a/src/widgets/util/qundostack.h b/src/widgets/util/qundostack.h
index 7ab90b507a..4be24eadab 100644
--- a/src/widgets/util/qundostack.h
+++ b/src/widgets/util/qundostack.h
@@ -57,8 +57,8 @@ class Q_WIDGETS_EXPORT QUndoCommand
QUndoCommandPrivate *d;
public:
- explicit QUndoCommand(QUndoCommand *parent = Q_NULLPTR);
- explicit QUndoCommand(const QString &text, QUndoCommand *parent = Q_NULLPTR);
+ explicit QUndoCommand(QUndoCommand *parent = nullptr);
+ explicit QUndoCommand(const QString &text, QUndoCommand *parent = nullptr);
virtual ~QUndoCommand();
virtual void undo();
@@ -92,7 +92,7 @@ class Q_WIDGETS_EXPORT QUndoStack : public QObject
Q_PROPERTY(int undoLimit READ undoLimit WRITE setUndoLimit)
public:
- explicit QUndoStack(QObject *parent = Q_NULLPTR);
+ explicit QUndoStack(QObject *parent = nullptr);
~QUndoStack();
void clear();
diff --git a/src/widgets/util/qundoview.cpp b/src/widgets/util/qundoview.cpp
index b56aa42aed..31f6c0dff2 100644
--- a/src/widgets/util/qundoview.cpp
+++ b/src/widgets/util/qundoview.cpp
@@ -59,11 +59,11 @@ public:
QUndoStack *stack() const;
virtual QModelIndex index(int row, int column,
- const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
- virtual QModelIndex parent(const QModelIndex &child) const Q_DECL_OVERRIDE;
- virtual int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
- virtual int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
- virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
+ const QModelIndex &parent = QModelIndex()) const override;
+ virtual QModelIndex parent(const QModelIndex &child) const override;
+ virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ virtual int columnCount(const QModelIndex &parent = QModelIndex()) const override;
+ virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QModelIndex selectedIndex() const;
QItemSelectionModel *selectionModel() const;
diff --git a/src/widgets/util/qundoview.h b/src/widgets/util/qundoview.h
index 0bfcdd0c18..403f05d2e4 100644
--- a/src/widgets/util/qundoview.h
+++ b/src/widgets/util/qundoview.h
@@ -62,10 +62,10 @@ class Q_WIDGETS_EXPORT QUndoView : public QListView
Q_PROPERTY(QIcon cleanIcon READ cleanIcon WRITE setCleanIcon)
public:
- explicit QUndoView(QWidget *parent = Q_NULLPTR);
- explicit QUndoView(QUndoStack *stack, QWidget *parent = Q_NULLPTR);
+ explicit QUndoView(QWidget *parent = nullptr);
+ explicit QUndoView(QUndoStack *stack, QWidget *parent = nullptr);
#if QT_CONFIG(undogroup)
- explicit QUndoView(QUndoGroup *group, QWidget *parent = Q_NULLPTR);
+ explicit QUndoView(QUndoGroup *group, QWidget *parent = nullptr);
#endif
~QUndoView();
diff --git a/src/widgets/util/util.pri b/src/widgets/util/util.pri
index 0b654bbadd..a3bd8897f1 100644
--- a/src/widgets/util/util.pri
+++ b/src/widgets/util/util.pri
@@ -49,9 +49,7 @@ qtConfig(undoview) {
SOURCES += util/qundoview.cpp
}
-win32:!winrt {
- SOURCES += util/qsystemtrayicon_win.cpp
-} else: qtConfig(xcb) {
+qtConfig(xcb) {
SOURCES += util/qsystemtrayicon_x11.cpp
} else {
SOURCES += util/qsystemtrayicon_qpa.cpp
diff --git a/src/widgets/widgets.pro b/src/widgets/widgets.pro
index 22bdf08408..27d7fe9874 100644
--- a/src/widgets/widgets.pro
+++ b/src/widgets/widgets.pro
@@ -5,7 +5,6 @@ MODULE_CONFIG = uic
CONFIG += $$MODULE_CONFIG
DEFINES += QT_NO_USING_NAMESPACE
win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x65000000
-irix-cc*:QMAKE_CXXFLAGS += -no_prelink -ptused
QMAKE_DOCS = $$PWD/doc/qtwidgets.qdocconf
diff --git a/src/widgets/widgets/qabstractbutton.h b/src/widgets/widgets/qabstractbutton.h
index 01dbf4e92d..e8dee142f2 100644
--- a/src/widgets/widgets/qabstractbutton.h
+++ b/src/widgets/widgets/qabstractbutton.h
@@ -72,7 +72,7 @@ class Q_WIDGETS_EXPORT QAbstractButton : public QWidget
Q_PROPERTY(bool down READ isDown WRITE setDown DESIGNABLE false)
public:
- explicit QAbstractButton(QWidget *parent = Q_NULLPTR);
+ explicit QAbstractButton(QWidget *parent = nullptr);
~QAbstractButton();
void setText(const QString &text);
@@ -126,25 +126,25 @@ Q_SIGNALS:
void toggled(bool checked);
protected:
- void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE = 0;
+ void paintEvent(QPaintEvent *e) override = 0;
virtual bool hitButton(const QPoint &pos) const;
virtual void checkStateSet();
virtual void nextCheckState();
- bool event(QEvent *e) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
- void keyReleaseEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- void focusInEvent(QFocusEvent *e) Q_DECL_OVERRIDE;
- void focusOutEvent(QFocusEvent *e) Q_DECL_OVERRIDE;
- void changeEvent(QEvent *e) Q_DECL_OVERRIDE;
- void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
+ void keyPressEvent(QKeyEvent *e) override;
+ void keyReleaseEvent(QKeyEvent *e) override;
+ void mousePressEvent(QMouseEvent *e) override;
+ void mouseReleaseEvent(QMouseEvent *e) override;
+ void mouseMoveEvent(QMouseEvent *e) override;
+ void focusInEvent(QFocusEvent *e) override;
+ void focusOutEvent(QFocusEvent *e) override;
+ void changeEvent(QEvent *e) override;
+ void timerEvent(QTimerEvent *e) override;
protected:
- QAbstractButton(QAbstractButtonPrivate &dd, QWidget* parent = Q_NULLPTR);
+ QAbstractButton(QAbstractButtonPrivate &dd, QWidget* parent = nullptr);
private:
Q_DECLARE_PRIVATE(QAbstractButton)
diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp
index c6d66bafd4..917cddce6f 100644
--- a/src/widgets/widgets/qabstractscrollarea.cpp
+++ b/src/widgets/widgets/qabstractscrollarea.cpp
@@ -1163,7 +1163,7 @@ bool QAbstractScrollArea::event(QEvent *e)
case QEvent::ApplicationLayoutDirectionChange:
case QEvent::LayoutRequest:
d->layoutChildren();
- // fall through
+ Q_FALLTHROUGH();
default:
return QFrame::event(e);
}
diff --git a/src/widgets/widgets/qabstractscrollarea.h b/src/widgets/widgets/qabstractscrollarea.h
index cee8481e6f..8a17036fb2 100644
--- a/src/widgets/widgets/qabstractscrollarea.h
+++ b/src/widgets/widgets/qabstractscrollarea.h
@@ -61,7 +61,7 @@ class Q_WIDGETS_EXPORT QAbstractScrollArea : public QFrame
Q_PROPERTY(SizeAdjustPolicy sizeAdjustPolicy READ sizeAdjustPolicy WRITE setSizeAdjustPolicy)
public:
- explicit QAbstractScrollArea(QWidget *parent = Q_NULLPTR);
+ explicit QAbstractScrollArea(QWidget *parent = nullptr);
~QAbstractScrollArea();
enum SizeAdjustPolicy {
@@ -91,9 +91,9 @@ public:
void setViewport(QWidget *widget);
QSize maximumViewportSize() const;
- QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ QSize minimumSizeHint() const override;
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
virtual void setupViewport(QWidget *viewport);
@@ -101,35 +101,35 @@ public:
void setSizeAdjustPolicy(SizeAdjustPolicy policy);
protected:
- QAbstractScrollArea(QAbstractScrollAreaPrivate &dd, QWidget *parent = Q_NULLPTR);
+ QAbstractScrollArea(QAbstractScrollAreaPrivate &dd, QWidget *parent = nullptr);
void setViewportMargins(int left, int top, int right, int bottom);
void setViewportMargins(const QMargins &margins);
QMargins viewportMargins() const;
- bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE;
- bool event(QEvent *) Q_DECL_OVERRIDE;
+ bool eventFilter(QObject *, QEvent *) override;
+ bool event(QEvent *) override;
virtual bool viewportEvent(QEvent *);
- void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void mouseDoubleClickEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
+ void resizeEvent(QResizeEvent *) override;
+ void paintEvent(QPaintEvent *) override;
+ void mousePressEvent(QMouseEvent *) override;
+ void mouseReleaseEvent(QMouseEvent *) override;
+ void mouseDoubleClickEvent(QMouseEvent *) override;
+ void mouseMoveEvent(QMouseEvent *) override;
#if QT_CONFIG(wheelevent)
- void wheelEvent(QWheelEvent *) Q_DECL_OVERRIDE;
+ void wheelEvent(QWheelEvent *) override;
#endif
#ifndef QT_NO_CONTEXTMENU
- void contextMenuEvent(QContextMenuEvent *) Q_DECL_OVERRIDE;
+ void contextMenuEvent(QContextMenuEvent *) override;
#endif
#ifndef QT_NO_DRAGANDDROP
- void dragEnterEvent(QDragEnterEvent *) Q_DECL_OVERRIDE;
- void dragMoveEvent(QDragMoveEvent *) Q_DECL_OVERRIDE;
- void dragLeaveEvent(QDragLeaveEvent *) Q_DECL_OVERRIDE;
- void dropEvent(QDropEvent *) Q_DECL_OVERRIDE;
+ void dragEnterEvent(QDragEnterEvent *) override;
+ void dragMoveEvent(QDragMoveEvent *) override;
+ void dragLeaveEvent(QDragLeaveEvent *) override;
+ void dropEvent(QDropEvent *) override;
#endif
- void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE;
+ void keyPressEvent(QKeyEvent *) override;
virtual void scrollContentsBy(int dx, int dy);
diff --git a/src/widgets/widgets/qabstractscrollarea_p.h b/src/widgets/widgets/qabstractscrollarea_p.h
index 49f97bcb61..732a2ab40d 100644
--- a/src/widgets/widgets/qabstractscrollarea_p.h
+++ b/src/widgets/widgets/qabstractscrollarea_p.h
@@ -125,7 +125,7 @@ class QAbstractScrollAreaFilter : public QObject
public:
QAbstractScrollAreaFilter(QAbstractScrollAreaPrivate *p) : d(p)
{ setObjectName(QLatin1String("qt_abstractscrollarea_filter")); }
- bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE
+ bool eventFilter(QObject *o, QEvent *e) override
{ return (o == d->viewport ? d->viewportEvent(e) : false); }
private:
QAbstractScrollAreaPrivate *d;
diff --git a/src/widgets/widgets/qabstractslider.h b/src/widgets/widgets/qabstractslider.h
index d26d6a879c..7791d30d10 100644
--- a/src/widgets/widgets/qabstractslider.h
+++ b/src/widgets/widgets/qabstractslider.h
@@ -67,7 +67,7 @@ class Q_WIDGETS_EXPORT QAbstractSlider : public QWidget
Q_PROPERTY(bool sliderDown READ isSliderDown WRITE setSliderDown DESIGNABLE false)
public:
- explicit QAbstractSlider(QWidget *parent = Q_NULLPTR);
+ explicit QAbstractSlider(QWidget *parent = nullptr);
~QAbstractSlider();
Qt::Orientation orientation() const;
@@ -131,7 +131,7 @@ Q_SIGNALS:
void actionTriggered(int action);
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
void setRepeatAction(SliderAction action, int thresholdTime = 500, int repeatTime = 50);
SliderAction repeatAction() const;
@@ -144,16 +144,16 @@ protected:
};
virtual void sliderChange(SliderChange change);
- void keyPressEvent(QKeyEvent *ev) Q_DECL_OVERRIDE;
- void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE;
+ void keyPressEvent(QKeyEvent *ev) override;
+ void timerEvent(QTimerEvent *) override;
#if QT_CONFIG(wheelevent)
- void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE;
+ void wheelEvent(QWheelEvent *e) override;
#endif
- void changeEvent(QEvent *e) Q_DECL_OVERRIDE;
+ void changeEvent(QEvent *e) override;
protected:
- QAbstractSlider(QAbstractSliderPrivate &dd, QWidget *parent = Q_NULLPTR);
+ QAbstractSlider(QAbstractSliderPrivate &dd, QWidget *parent = nullptr);
private:
Q_DISABLE_COPY(QAbstractSlider)
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp
index 3427579d1f..7ca47e9f0f 100644
--- a/src/widgets/widgets/qabstractspinbox.cpp
+++ b/src/widgets/widgets/qabstractspinbox.cpp
@@ -678,15 +678,20 @@ void QAbstractSpinBox::setLineEdit(QLineEdit *lineEdit)
Q_ASSERT(lineEdit);
return;
}
+
+ if (lineEdit == d->edit)
+ return;
+
delete d->edit;
d->edit = lineEdit;
+ setProperty("_q_spinbox_lineedit", QVariant::fromValue<QWidget *>(d->edit));
if (!d->edit->validator())
d->edit->setValidator(d->validator);
if (d->edit->parent() != this)
d->edit->setParent(this);
- d->edit->setFrame(false);
+ d->edit->setFrame(!style()->styleHint(QStyle::SH_SpinBox_ButtonsInsideFrame, nullptr, this));
d->edit->setFocusProxy(this);
d->edit->setAcceptDrops(false);
@@ -818,6 +823,8 @@ void QAbstractSpinBox::changeEvent(QEvent *event)
d->spinClickTimerInterval = style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatRate, 0, this);
d->spinClickThresholdTimerInterval =
style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatThreshold, 0, this);
+ if (d->edit)
+ d->edit->setFrame(!style()->styleHint(QStyle::SH_SpinBox_ButtonsInsideFrame, nullptr, this));
d->reset();
d->updateEditFieldGeometry();
break;
@@ -870,15 +877,15 @@ QSize QAbstractSpinBox::sizeHint() const
s = d->textFromValue(d->minimum);
s.truncate(18);
s += fixedContent;
- w = qMax(w, fm.width(s));
+ w = qMax(w, fm.horizontalAdvance(s));
s = d->textFromValue(d->maximum);
s.truncate(18);
s += fixedContent;
- w = qMax(w, fm.width(s));
+ w = qMax(w, fm.horizontalAdvance(s));
if (d->specialValueText.size()) {
s = d->specialValueText;
- w = qMax(w, fm.width(s));
+ w = qMax(w, fm.horizontalAdvance(s));
}
w += 2; // cursor blinking space
@@ -911,15 +918,15 @@ QSize QAbstractSpinBox::minimumSizeHint() const
s = d->textFromValue(d->minimum);
s.truncate(18);
s += fixedContent;
- w = qMax(w, fm.width(s));
+ w = qMax(w, fm.horizontalAdvance(s));
s = d->textFromValue(d->maximum);
s.truncate(18);
s += fixedContent;
- w = qMax(w, fm.width(s));
+ w = qMax(w, fm.horizontalAdvance(s));
if (d->specialValueText.size()) {
s = d->specialValueText;
- w = qMax(w, fm.width(s));
+ w = qMax(w, fm.horizontalAdvance(s));
}
w += 2; // cursor blinking space
@@ -1644,7 +1651,9 @@ void QAbstractSpinBox::initStyleOption(QStyleOptionSpinBox *option) const
option->initFrom(this);
option->activeSubControls = QStyle::SC_None;
option->buttonSymbols = d->buttonSymbols;
- option->subControls = QStyle::SC_SpinBoxFrame | QStyle::SC_SpinBoxEditField;
+ option->subControls = QStyle::SC_SpinBoxEditField;
+ if (!style()->styleHint(QStyle::SH_SpinBox_ButtonsInsideFrame, nullptr, this))
+ option->subControls |= QStyle::SC_SpinBoxFrame;
if (d->buttonSymbols != QAbstractSpinBox::NoButtons) {
option->subControls |= QStyle::SC_SpinBoxUp | QStyle::SC_SpinBoxDown;
if (d->buttonState & Up) {
diff --git a/src/widgets/widgets/qabstractspinbox.h b/src/widgets/widgets/qabstractspinbox.h
index 88735baf1c..83bf83d779 100644
--- a/src/widgets/widgets/qabstractspinbox.h
+++ b/src/widgets/widgets/qabstractspinbox.h
@@ -70,7 +70,7 @@ class Q_WIDGETS_EXPORT QAbstractSpinBox : public QWidget
Q_PROPERTY(bool keyboardTracking READ keyboardTracking WRITE setKeyboardTracking)
Q_PROPERTY(bool showGroupSeparator READ isGroupSeparatorShown WRITE setGroupSeparatorShown)
public:
- explicit QAbstractSpinBox(QWidget *parent = Q_NULLPTR);
+ explicit QAbstractSpinBox(QWidget *parent = nullptr);
~QAbstractSpinBox();
enum StepEnabledFlag { StepNone = 0x00, StepUpEnabled = 0x01,
@@ -162,7 +162,7 @@ protected:
Q_SIGNALS:
void editingFinished();
protected:
- QAbstractSpinBox(QAbstractSpinBoxPrivate &dd, QWidget *parent = Q_NULLPTR);
+ QAbstractSpinBox(QAbstractSpinBoxPrivate &dd, QWidget *parent = nullptr);
private:
Q_PRIVATE_SLOT(d_func(), void _q_editorTextChanged(const QString &))
diff --git a/src/widgets/widgets/qbuttongroup.h b/src/widgets/widgets/qbuttongroup.h
index 1b4f2377ae..fec94ccb3e 100644
--- a/src/widgets/widgets/qbuttongroup.h
+++ b/src/widgets/widgets/qbuttongroup.h
@@ -57,7 +57,7 @@ class Q_WIDGETS_EXPORT QButtonGroup : public QObject
Q_PROPERTY(bool exclusive READ exclusive WRITE setExclusive)
public:
- explicit QButtonGroup(QObject *parent = Q_NULLPTR);
+ explicit QButtonGroup(QObject *parent = nullptr);
~QButtonGroup();
void setExclusive(bool);
diff --git a/src/widgets/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp
index 94911d1cb1..059fb21295 100644
--- a/src/widgets/widgets/qcalendarwidget.cpp
+++ b/src/widgets/widgets/qcalendarwidget.cpp
@@ -115,11 +115,11 @@ class QCalendarDayValidator : public QCalendarDateSectionValidator
public:
QCalendarDayValidator();
- virtual Section handleKey(int key) Q_DECL_OVERRIDE;
- virtual QDate applyToDate(const QDate &date) const Q_DECL_OVERRIDE;
- virtual void setDate(const QDate &date) Q_DECL_OVERRIDE;
- virtual QString text() const Q_DECL_OVERRIDE;
- virtual QString text(const QDate &date, int repeat) const Q_DECL_OVERRIDE;
+ virtual Section handleKey(int key) override;
+ virtual QDate applyToDate(const QDate &date) const override;
+ virtual void setDate(const QDate &date) override;
+ virtual QString text() const override;
+ virtual QString text(const QDate &date, int repeat) const override;
private:
int m_pos;
int m_day;
@@ -223,11 +223,11 @@ class QCalendarMonthValidator : public QCalendarDateSectionValidator
public:
QCalendarMonthValidator();
- virtual Section handleKey(int key) Q_DECL_OVERRIDE;
- virtual QDate applyToDate(const QDate &date) const Q_DECL_OVERRIDE;
- virtual void setDate(const QDate &date) Q_DECL_OVERRIDE;
- virtual QString text() const Q_DECL_OVERRIDE;
- virtual QString text(const QDate &date, int repeat) const Q_DECL_OVERRIDE;
+ virtual Section handleKey(int key) override;
+ virtual QDate applyToDate(const QDate &date) const override;
+ virtual void setDate(const QDate &date) override;
+ virtual QString text() const override;
+ virtual QString text(const QDate &date, int repeat) const override;
private:
int m_pos;
int m_month;
@@ -333,11 +333,11 @@ class QCalendarYearValidator : public QCalendarDateSectionValidator
public:
QCalendarYearValidator();
- virtual Section handleKey(int key) Q_DECL_OVERRIDE;
- virtual QDate applyToDate(const QDate &date) const Q_DECL_OVERRIDE;
- virtual void setDate(const QDate &date) Q_DECL_OVERRIDE;
- virtual QString text() const Q_DECL_OVERRIDE;
- virtual QString text(const QDate &date, int repeat) const Q_DECL_OVERRIDE;
+ virtual Section handleKey(int key) override;
+ virtual QDate applyToDate(const QDate &date) const override;
+ virtual void setDate(const QDate &date) override;
+ virtual QString text() const override;
+ virtual QString text(const QDate &date, int repeat) const override;
private:
int pow10(int n);
int m_pos;
@@ -654,8 +654,8 @@ public:
void setDate(const QDate &date);
- bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE;
- void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE;
+ bool eventFilter(QObject *o, QEvent *e) override;
+ void timerEvent(QTimerEvent *e) override;
signals:
void dateChanged(const QDate &date);
@@ -861,32 +861,32 @@ class QCalendarModel : public QAbstractTableModel
public:
QCalendarModel(QObject *parent = 0);
- int rowCount(const QModelIndex &) const Q_DECL_OVERRIDE
+ int rowCount(const QModelIndex &) const override
{ return RowCount + m_firstRow; }
- int columnCount(const QModelIndex &) const Q_DECL_OVERRIDE
+ int columnCount(const QModelIndex &) const override
{ return ColumnCount + m_firstColumn; }
- QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
- Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE;
+ QVariant data(const QModelIndex &index, int role) const override;
+ Qt::ItemFlags flags(const QModelIndex &index) const override;
- bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE
+ bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override
{
beginInsertRows(parent, row, row + count - 1);
endInsertRows();
return true;
}
- bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE
+ bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override
{
beginInsertColumns(parent, column, column + count - 1);
endInsertColumns();
return true;
}
- bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE
+ bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override
{
beginRemoveRows(parent, row, row + count - 1);
endRemoveRows();
return true;
}
- bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) Q_DECL_OVERRIDE
+ bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex()) override
{
beginRemoveColumns(parent, column, column + count - 1);
endRemoveColumns();
@@ -947,7 +947,7 @@ public:
void internalUpdate() { updateGeometries(); }
void setReadOnly(bool enable);
- virtual void keyboardSearch(const QString & search) Q_DECL_OVERRIDE { Q_UNUSED(search) }
+ virtual void keyboardSearch(const QString & search) override { Q_UNUSED(search) }
signals:
void showDate(const QDate &date);
@@ -955,16 +955,16 @@ signals:
void clicked(const QDate &date);
void editingFinished();
protected:
- QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) Q_DECL_OVERRIDE;
- void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+ QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
+ void mouseDoubleClickEvent(QMouseEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
#if QT_CONFIG(wheelevent)
- void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
+ void wheelEvent(QWheelEvent *event) override;
#endif
- void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
- bool event(QEvent *event) Q_DECL_OVERRIDE;
+ void keyPressEvent(QKeyEvent *event) override;
+ bool event(QEvent *event) override;
QDate handleMouseEvent(QMouseEvent *event);
public:
@@ -982,13 +982,13 @@ QCalendarModel::QCalendarModel(QObject *parent)
m_firstRow(1),
m_date(QDate::currentDate()),
m_minimumDate(QDate::fromJulianDay(1)),
- m_maximumDate(7999, 12, 31),
+ m_maximumDate(9999, 12, 31),
m_shownYear(m_date.year()),
m_shownMonth(m_date.month()),
m_firstDay(QLocale().firstDayOfWeek()),
m_horizontalHeaderFormat(QCalendarWidget::ShortDayNames),
m_weekNumbersShown(true),
- m_view(Q_NULLPTR)
+ m_view(nullptr)
{
}
@@ -1563,7 +1563,7 @@ public:
: QItemDelegate(parent), calendarWidgetPrivate(w)
{ }
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option,
- const QModelIndex &index) const Q_DECL_OVERRIDE;
+ const QModelIndex &index) const override;
void paintCell(QPainter *painter, const QRect &rect, const QDate &date) const;
private:
@@ -1579,7 +1579,7 @@ public:
: QToolButton(parent)
{ }
protected:
- void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE
+ void paintEvent(QPaintEvent *e) override
{
Q_UNUSED(e)
@@ -1607,7 +1607,7 @@ class QPrevNextCalButton : public QToolButton
public:
QPrevNextCalButton(QWidget *parent) : QToolButton(parent) {}
protected:
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE {
+ void paintEvent(QPaintEvent *) override {
QStylePainter painter(this);
QStyleOptionToolButton opt;
initStyleOption(&opt);
@@ -2196,7 +2196,7 @@ QSize QCalendarWidget::minimumSizeHint() const
} else {
for (int i = 1; i <= 7; i++) {
QFontMetrics fm(d->m_model->formatForCell(0, i).font());
- w = qMax(w, fm.width(d->m_model->dayName(d->m_model->dayOfWeekForColumn(i))) + marginH);
+ w = qMax(w, fm.horizontalAdvance(d->m_model->dayName(d->m_model->dayOfWeekForColumn(i))) + marginH);
h = qMax(h, fm.height());
}
}
@@ -2207,14 +2207,14 @@ QSize QCalendarWidget::minimumSizeHint() const
for (int i = 1; i <= 6; i++) {
QFontMetrics fm(d->m_model->formatForCell(i, 0).font());
for (int j = 1; j < end; j++)
- w = qMax(w, fm.width(QString::number(j)) + marginH);
+ w = qMax(w, fm.horizontalAdvance(QString::number(j)) + marginH);
h = qMax(h, fm.height());
}
}
QFontMetrics fm(d->m_model->formatForCell(1, 1).font());
for (int i = 1; i <= end; i++) {
- w = qMax(w, fm.width(QString::number(i)) + marginH);
+ w = qMax(w, fm.horizontalAdvance(QString::number(i)) + marginH);
h = qMax(h, fm.height());
}
diff --git a/src/widgets/widgets/qcalendarwidget.h b/src/widgets/widgets/qcalendarwidget.h
index 29e2ff698b..44ba340289 100644
--- a/src/widgets/widgets/qcalendarwidget.h
+++ b/src/widgets/widgets/qcalendarwidget.h
@@ -89,11 +89,11 @@ public:
};
Q_ENUM(SelectionMode)
- explicit QCalendarWidget(QWidget *parent = Q_NULLPTR);
+ explicit QCalendarWidget(QWidget *parent = nullptr);
~QCalendarWidget();
- virtual QSize sizeHint() const Q_DECL_OVERRIDE;
- virtual QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ virtual QSize sizeHint() const override;
+ virtual QSize minimumSizeHint() const override;
QDate selectedDate() const;
@@ -138,11 +138,11 @@ public:
void setDateEditAcceptDelay(int delay);
protected:
- bool event(QEvent *event) Q_DECL_OVERRIDE;
- bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent * event) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent * event) Q_DECL_OVERRIDE;
+ bool event(QEvent *event) override;
+ bool eventFilter(QObject *watched, QEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+ void resizeEvent(QResizeEvent * event) override;
+ void keyPressEvent(QKeyEvent * event) override;
virtual void paintCell(QPainter *painter, const QRect &rect, const QDate &date) const;
void updateCell(const QDate &date);
diff --git a/src/widgets/widgets/qcheckbox.cpp b/src/widgets/widgets/qcheckbox.cpp
index 9b49916774..81bfd3af35 100644
--- a/src/widgets/widgets/qcheckbox.cpp
+++ b/src/widgets/widgets/qcheckbox.cpp
@@ -45,6 +45,9 @@
#include "qstyle.h"
#include "qstyleoption.h"
#include "qevent.h"
+#ifndef QT_NO_ACCESSIBILITY
+#include "qaccessible.h"
+#endif
#include "private/qabstractbutton_p.h"
@@ -144,6 +147,7 @@ void QCheckBoxPrivate::init()
q->setCheckable(true);
q->setMouseTracking(true);
q->setForegroundRole(QPalette::WindowText);
+ q->setAttribute(Qt::WA_MacShowFocusRect);
setLayoutItemMargins(QStyle::SE_CheckBoxLayoutItem);
}
@@ -243,6 +247,9 @@ Qt::CheckState QCheckBox::checkState() const
void QCheckBox::setCheckState(Qt::CheckState state)
{
Q_D(QCheckBox);
+#ifndef QT_NO_ACCESSIBILITY
+ bool noChange = d->noChange;
+#endif
if (state == Qt::PartiallyChecked) {
d->tristate = true;
d->noChange = true;
@@ -257,6 +264,15 @@ void QCheckBox::setCheckState(Qt::CheckState state)
d->publishedState = state;
emit stateChanged(state);
}
+
+#ifndef QT_NO_ACCESSIBILITY
+ if (noChange != d->noChange) {
+ QAccessible::State s;
+ s.checkStateMixed = true;
+ QAccessibleStateChangeEvent event(this, s);
+ QAccessible::updateAccessibility(&event);
+ }
+#endif
}
diff --git a/src/widgets/widgets/qcheckbox.h b/src/widgets/widgets/qcheckbox.h
index 8543c4c86f..80cb22b82e 100644
--- a/src/widgets/widgets/qcheckbox.h
+++ b/src/widgets/widgets/qcheckbox.h
@@ -58,12 +58,12 @@ class Q_WIDGETS_EXPORT QCheckBox : public QAbstractButton
Q_PROPERTY(bool tristate READ isTristate WRITE setTristate)
public:
- explicit QCheckBox(QWidget *parent = Q_NULLPTR);
- explicit QCheckBox(const QString &text, QWidget *parent = Q_NULLPTR);
+ explicit QCheckBox(QWidget *parent = nullptr);
+ explicit QCheckBox(const QString &text, QWidget *parent = nullptr);
~QCheckBox();
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ QSize minimumSizeHint() const override;
void setTristate(bool y = true);
bool isTristate() const;
@@ -75,12 +75,12 @@ Q_SIGNALS:
void stateChanged(int);
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
- bool hitButton(const QPoint &pos) const Q_DECL_OVERRIDE;
- void checkStateSet() Q_DECL_OVERRIDE;
- void nextCheckState() Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
+ bool hitButton(const QPoint &pos) const override;
+ void checkStateSet() override;
+ void nextCheckState() override;
+ void paintEvent(QPaintEvent *) override;
+ void mouseMoveEvent(QMouseEvent *) override;
void initStyleOption(QStyleOptionButton *option) const;
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index 7ab3565a00..e70d096e04 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -45,6 +45,7 @@
#include <qlineedit.h>
#include <qapplication.h>
#include <qdesktopwidget.h>
+#include <private/qdesktopwidget_p.h>
#include <qlistview.h>
#if QT_CONFIG(tableview)
#include <qtableview.h>
@@ -74,11 +75,6 @@
#include <private/qlineedit_p.h>
#include <private/qcompleter_p.h>
#include <qdebug.h>
-#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && QT_CONFIG(effetcts) && QT_CONFIG(style_mac)
-#include <private/qcore_mac_p.h>
-#include <private/qmacstyle_mac_p.h>
-#include <private/qt_cocoa_helpers_mac_p.h>
-#endif
#if QT_CONFIG(effects)
# include <private/qeffects_p.h>
#endif
@@ -204,7 +200,21 @@ void QComboBoxPrivate::_q_completerActivated(const QModelIndex &index)
if (index.isValid() && q->completer()) {
QAbstractProxyModel *proxy = qobject_cast<QAbstractProxyModel *>(q->completer()->completionModel());
if (proxy) {
- q->setCurrentIndex(proxy->mapToSource(index).row());
+ const QModelIndex &completerIndex = proxy->mapToSource(index);
+ int row = -1;
+ if (completerIndex.model() == model) {
+ row = completerIndex.row();
+ } else {
+ // if QCompleter uses a proxy model to host widget's one - map again
+ QAbstractProxyModel *completerProxy = qobject_cast<QAbstractProxyModel *>(q->completer()->model());
+ if (completerProxy && completerProxy->sourceModel() == model) {
+ row = completerProxy->mapToSource(completerIndex).row();
+ } else {
+ QString match = q->completer()->model()->data(completerIndex).toString();
+ row = q->findText(match, matchFlags());
+ }
+ }
+ q->setCurrentIndex(row);
emitActivated(currentIndex);
}
}
@@ -257,8 +267,8 @@ QRect QComboBoxPrivate::popupGeometry(int screen) const
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
useFullScreenForPopupMenu = theme->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool();
return useFullScreenForPopupMenu ?
- QApplication::desktop()->screenGeometry(screen) :
- QApplication::desktop()->availableGeometry(screen);
+ QDesktopWidgetPrivate::screenGeometry(screen) :
+ QDesktopWidgetPrivate::availableGeometry(screen);
}
bool QComboBoxPrivate::updateHoverControl(const QPoint &pos)
@@ -303,7 +313,7 @@ int QComboBoxPrivate::computeWidthHint() const
const QFontMetrics &fontMetrics = q->fontMetrics();
for (int i = 0; i < count; ++i) {
- const int textWidth = fontMetrics.width(q->itemText(i));
+ const int textWidth = fontMetrics.horizontalAdvance(q->itemText(i));
if (q->itemIcon(i).isNull())
width = (qMax(width, textWidth));
else
@@ -332,7 +342,7 @@ QSize QComboBoxPrivate::recomputeSizeHint(QSize &sh) const
case QComboBox::AdjustToContents:
case QComboBox::AdjustToContentsOnFirstShow:
if (count == 0) {
- sh.rwidth() = 7 * fm.width(QLatin1Char('x'));
+ sh.rwidth() = 7 * fm.horizontalAdvance(QLatin1Char('x'));
} else {
for (int i = 0; i < count; ++i) {
if (!q->itemIcon(i).isNull()) {
@@ -355,7 +365,7 @@ QSize QComboBoxPrivate::recomputeSizeHint(QSize &sh) const
hasIcon = !q->itemIcon(i).isNull();
}
if (minimumContentsLength > 0)
- sh.setWidth(qMax(sh.width(), minimumContentsLength * fm.width(QLatin1Char('X')) + (hasIcon ? iconSize.width() + 4 : 0)));
+ sh.setWidth(qMax(sh.width(), minimumContentsLength * fm.horizontalAdvance(QLatin1Char('X')) + (hasIcon ? iconSize.width() + 4 : 0)));
// height
@@ -419,6 +429,20 @@ void QComboBoxPrivateContainer::resizeEvent(QResizeEvent *e)
QFrame::resizeEvent(e);
}
+void QComboBoxPrivateContainer::paintEvent(QPaintEvent *e)
+{
+ QStyleOptionComboBox cbOpt = comboStyleOption();
+ if (combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &cbOpt, combo)
+ && mask().isEmpty()) {
+ QStyleOption opt;
+ opt.initFrom(this);
+ QPainter p(this);
+ style()->drawPrimitive(QStyle::PE_PanelMenu, &opt, &p, this);
+ }
+
+ QFrame::paintEvent(e);
+}
+
void QComboBoxPrivateContainer::leaveEvent(QEvent *)
{
// On Mac using the Mac style we want to clear the selection
@@ -488,6 +512,14 @@ void QComboBoxPrivateContainer::scrollItemView(int action)
#endif
}
+void QComboBoxPrivateContainer::hideScrollers()
+{
+ if (top)
+ top->hide();
+ if (bottom)
+ bottom->hide();
+}
+
/*
Hides or shows the scrollers when we emulate a popupmenu
*/
@@ -2614,7 +2646,7 @@ void QComboBox::showPopup()
QComboBoxPrivateContainer* container = d->viewContainer();
QRect listRect(style->subControlRect(QStyle::CC_ComboBox, &opt,
QStyle::SC_ComboBoxListBoxPopup, this));
- QRect screen = d->popupGeometry(QApplication::desktop()->screenNumber(this));
+ QRect screen = d->popupGeometry(QDesktopWidgetPrivate::screenNumber(this));
QPoint below = mapToGlobal(listRect.bottomLeft());
int belowHeight = screen.bottom() - below.y();
@@ -2749,6 +2781,11 @@ void QComboBox::showPopup()
if (needHorizontalScrollBar) {
listRect.adjust(0, 0, 0, sb->height());
}
+
+ // Hide the scrollers here, so that the listrect gets the full height of the container
+ // If the scrollers are truly needed, the later call to container->updateScrollers()
+ // will make them visible again.
+ container->hideScrollers();
container->setGeometry(listRect);
#ifndef Q_OS_MAC
@@ -3180,7 +3217,7 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
case Qt::Key_Up:
if (e->modifiers() & Qt::ControlModifier)
break; // pass to line edit for auto completion
- // fall through
+ Q_FALLTHROUGH();
case Qt::Key_PageUp:
#ifdef QT_KEYPAD_NAVIGATION
if (QApplication::keypadNavigationEnabled())
@@ -3268,7 +3305,7 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
switch (move) {
case MoveFirst:
newIndex = -1;
- // fall through
+ Q_FALLTHROUGH();
case MoveDown:
newIndex++;
while (newIndex < rowCount && !(d->model->index(newIndex, d->modelColumn, d->root).flags() & Qt::ItemIsEnabled))
@@ -3276,7 +3313,7 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
break;
case MoveLast:
newIndex = rowCount;
- // fall through
+ Q_FALLTHROUGH();
case MoveUp:
newIndex--;
while ((newIndex >= 0) && !(d->model->flags(d->model->index(newIndex,d->modelColumn,d->root)) & Qt::ItemIsEnabled))
@@ -3315,11 +3352,11 @@ void QComboBox::keyReleaseEvent(QKeyEvent *e)
#if QT_CONFIG(wheelevent)
void QComboBox::wheelEvent(QWheelEvent *e)
{
-#ifdef Q_OS_DARWIN
- Q_UNUSED(e);
-#else
Q_D(QComboBox);
- if (!d->viewContainer()->isVisible()) {
+ QStyleOptionComboBox opt;
+ initStyleOption(&opt);
+ if (style()->styleHint(QStyle::SH_ComboBox_AllowWheelScrolling, &opt, this) &&
+ !d->viewContainer()->isVisible()) {
const int rowCount = count();
int newIndex = currentIndex();
@@ -3339,7 +3376,6 @@ void QComboBox::wheelEvent(QWheelEvent *e)
}
e->accept();
}
-#endif
}
#endif
diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h
index 59f2a425a0..671c883584 100644
--- a/src/widgets/widgets/qcombobox.h
+++ b/src/widgets/widgets/qcombobox.h
@@ -82,7 +82,7 @@ class Q_WIDGETS_EXPORT QComboBox : public QWidget
Q_PROPERTY(int modelColumn READ modelColumn WRITE setModelColumn)
public:
- explicit QComboBox(QWidget *parent = Q_NULLPTR);
+ explicit QComboBox(QWidget *parent = nullptr);
~QComboBox();
int maxVisibleItems() const;
@@ -196,14 +196,14 @@ public:
QAbstractItemView *view() const;
void setView(QAbstractItemView *itemView);
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ QSize minimumSizeHint() const override;
virtual void showPopup();
virtual void hidePopup();
- bool event(QEvent *event) Q_DECL_OVERRIDE;
- QVariant inputMethodQuery(Qt::InputMethodQuery) const Q_DECL_OVERRIDE;
+ bool event(QEvent *event) override;
+ QVariant inputMethodQuery(Qt::InputMethodQuery) const override;
Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, const QVariant &argument) const;
public Q_SLOTS:
@@ -224,24 +224,24 @@ Q_SIGNALS:
void currentTextChanged(const QString &);
protected:
- void focusInEvent(QFocusEvent *e) Q_DECL_OVERRIDE;
- void focusOutEvent(QFocusEvent *e) Q_DECL_OVERRIDE;
- void changeEvent(QEvent *e) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
- void showEvent(QShowEvent *e) Q_DECL_OVERRIDE;
- void hideEvent(QHideEvent *e) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
- void keyReleaseEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
+ void focusInEvent(QFocusEvent *e) override;
+ void focusOutEvent(QFocusEvent *e) override;
+ void changeEvent(QEvent *e) override;
+ void resizeEvent(QResizeEvent *e) override;
+ void paintEvent(QPaintEvent *e) override;
+ void showEvent(QShowEvent *e) override;
+ void hideEvent(QHideEvent *e) override;
+ void mousePressEvent(QMouseEvent *e) override;
+ void mouseReleaseEvent(QMouseEvent *e) override;
+ void keyPressEvent(QKeyEvent *e) override;
+ void keyReleaseEvent(QKeyEvent *e) override;
#if QT_CONFIG(wheelevent)
- void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE;
+ void wheelEvent(QWheelEvent *e) override;
#endif
#ifndef QT_NO_CONTEXTMENU
- void contextMenuEvent(QContextMenuEvent *e) Q_DECL_OVERRIDE;
+ void contextMenuEvent(QContextMenuEvent *e) override;
#endif // QT_NO_CONTEXTMENU
- void inputMethodEvent(QInputMethodEvent *) Q_DECL_OVERRIDE;
+ void inputMethodEvent(QInputMethodEvent *) override;
void initStyleOption(QStyleOptionComboBox *option) const;
diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h
index 249610825a..3f75a357e4 100644
--- a/src/widgets/widgets/qcombobox_p.h
+++ b/src/widgets/widgets/qcombobox_p.h
@@ -215,7 +215,7 @@ private:
bool fast;
};
-class Q_AUTOTEST_EXPORT QComboBoxPrivateContainer : public QFrame
+class Q_WIDGETS_EXPORT QComboBoxPrivateContainer : public QFrame
{
Q_OBJECT
@@ -234,6 +234,7 @@ public:
public Q_SLOTS:
void scrollItemView(int action);
+ void hideScrollers();
void updateScrollers();
void viewDestroyed();
@@ -247,6 +248,7 @@ protected:
void timerEvent(QTimerEvent *timerEvent) override;
void leaveEvent(QEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
+ void paintEvent(QPaintEvent *e) override;
QStyleOptionComboBox comboStyleOption() const;
Q_SIGNALS:
diff --git a/src/widgets/widgets/qcommandlinkbutton.cpp b/src/widgets/widgets/qcommandlinkbutton.cpp
index b6ec2a8d31..68dfefb3b7 100644
--- a/src/widgets/widgets/qcommandlinkbutton.cpp
+++ b/src/widgets/widgets/qcommandlinkbutton.cpp
@@ -318,7 +318,7 @@ QSize QCommandLinkButton::sizeHint() const
QSize size = QPushButton::sizeHint();
QFontMetrics fm(d->titleFont());
- int textWidth = qMax(fm.width(text()), 135);
+ int textWidth = qMax(fm.horizontalAdvance(text()), 135);
int buttonWidth = textWidth + d->textOffset() + d->rightMargin();
int heightWithoutDescription = d->descriptionOffset() + d->bottomMargin();
diff --git a/src/widgets/widgets/qcommandlinkbutton.h b/src/widgets/widgets/qcommandlinkbutton.h
index d8215a256e..2d01d63df8 100644
--- a/src/widgets/widgets/qcommandlinkbutton.h
+++ b/src/widgets/widgets/qcommandlinkbutton.h
@@ -58,20 +58,20 @@ class Q_WIDGETS_EXPORT QCommandLinkButton: public QPushButton
Q_PROPERTY(bool flat READ isFlat WRITE setFlat DESIGNABLE false)
public:
- explicit QCommandLinkButton(QWidget *parent = Q_NULLPTR);
- explicit QCommandLinkButton(const QString &text, QWidget *parent = Q_NULLPTR);
- explicit QCommandLinkButton(const QString &text, const QString &description, QWidget *parent = Q_NULLPTR);
+ explicit QCommandLinkButton(QWidget *parent = nullptr);
+ explicit QCommandLinkButton(const QString &text, QWidget *parent = nullptr);
+ explicit QCommandLinkButton(const QString &text, const QString &description, QWidget *parent = nullptr);
~QCommandLinkButton();
QString description() const;
void setDescription(const QString &description);
protected:
- QSize sizeHint() const Q_DECL_OVERRIDE;
- int heightForWidth(int) const Q_DECL_OVERRIDE;
- QSize minimumSizeHint() const Q_DECL_OVERRIDE;
- bool event(QEvent *e) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ int heightForWidth(int) const override;
+ QSize minimumSizeHint() const override;
+ bool event(QEvent *e) override;
+ void paintEvent(QPaintEvent *) override;
private:
Q_DISABLE_COPY(QCommandLinkButton)
diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp
index 053b184226..fca81bec48 100644
--- a/src/widgets/widgets/qdatetimeedit.cpp
+++ b/src/widgets/widgets/qdatetimeedit.cpp
@@ -42,6 +42,7 @@
#include <qapplication.h>
#include <qdatetimeedit.h>
#include <qdesktopwidget.h>
+#include <private/qdesktopwidget_p.h>
#include <qdebug.h>
#include <qevent.h>
#include <qlineedit.h>
@@ -362,7 +363,7 @@ void QDateTimeEdit::setMinimumDateTime(const QDateTime &dt)
clearMaximumDateTime().
By default, this property contains a date that refers to 31 December,
- 7999 and a time of 23:59:59 and 999 milliseconds.
+ 9999 and a time of 23:59:59 and 999 milliseconds.
\sa minimumDateTime(), minimumTime(), maximumTime(), minimumDate(),
maximumDate(), setDateTimeRange(), setDateRange(), setTimeRange(),
@@ -465,7 +466,7 @@ void QDateTimeEdit::clearMinimumDate()
necessary to ensure that the range remains valid. If the date is
not a valid QDate object, this function does nothing.
- By default, this property contains a date that refers to December 31, 7999.
+ By default, this property contains a date that refers to December 31, 9999.
\sa minimumDate, minimumTime, maximumTime, setDateRange()
*/
@@ -965,12 +966,12 @@ QSize QDateTimeEdit::sizeHint() const
int w = 0;
QString s;
s = d->textFromValue(d->minimum) + QLatin1Char(' ');
- w = qMax<int>(w, fm.width(s));
+ w = qMax<int>(w, fm.horizontalAdvance(s));
s = d->textFromValue(d->maximum) + QLatin1Char(' ');
- w = qMax<int>(w, fm.width(s));
+ w = qMax<int>(w, fm.horizontalAdvance(s));
if (d->specialValueText.size()) {
s = d->specialValueText;
- w = qMax<int>(w, fm.width(s));
+ w = qMax<int>(w, fm.horizontalAdvance(s));
}
w += 2; // cursor blinking space
@@ -1073,7 +1074,7 @@ void QDateTimeEdit::keyPressEvent(QKeyEvent *event)
//hide cursor
d->edit->d_func()->setCursorVisible(false);
- d->edit->d_func()->control->setCursorBlinkPeriod(0);
+ d->edit->d_func()->control->setBlinkingCursorEnabled(false);
d->setSelected(0);
}
}
@@ -1094,7 +1095,7 @@ void QDateTimeEdit::keyPressEvent(QKeyEvent *event)
//hide cursor
d->edit->d_func()->setCursorVisible(false);
- d->edit->d_func()->control->setCursorBlinkPeriod(0);
+ d->edit->d_func()->control->setBlinkingCursorEnabled(false);
d->setSelected(0);
oldCurrent = 0;
}
@@ -1128,7 +1129,7 @@ void QDateTimeEdit::keyPressEvent(QKeyEvent *event)
}
#endif
}
- // else fall through
+ Q_FALLTHROUGH();
case Qt::Key_Backtab:
case Qt::Key_Tab: {
event->accept();
@@ -1921,6 +1922,7 @@ QDateTime QDateTimeEditPrivate::validateAndInterpret(QString &input, int &positi
}
StateNode tmp = parse(input, position, value.toDateTime(), fixup);
input = tmp.input;
+ position += tmp.padded;
state = QValidator::State(int(tmp.state));
if (state == QValidator::Acceptable) {
if (tmp.conflicts && conflictGuard != tmp.value) {
@@ -2515,7 +2517,7 @@ void QDateTimeEditPrivate::positionCalendarPopup()
pos = q->mapToGlobal(pos);
pos2 = q->mapToGlobal(pos2);
QSize size = monthCalendar->sizeHint();
- QRect screen = QApplication::desktop()->availableGeometry(pos);
+ QRect screen = QDesktopWidgetPrivate::availableGeometry(pos);
//handle popup falling "off screen"
if (q->layoutDirection() == Qt::RightToLeft) {
pos.setX(pos.x()-size.width());
diff --git a/src/widgets/widgets/qdatetimeedit.h b/src/widgets/widgets/qdatetimeedit.h
index b46434c1a4..b6fb35fc71 100644
--- a/src/widgets/widgets/qdatetimeedit.h
+++ b/src/widgets/widgets/qdatetimeedit.h
@@ -92,10 +92,10 @@ public:
Q_DECLARE_FLAGS(Sections, Section)
Q_FLAG(Sections)
- explicit QDateTimeEdit(QWidget *parent = Q_NULLPTR);
- explicit QDateTimeEdit(const QDateTime &dt, QWidget *parent = Q_NULLPTR);
- explicit QDateTimeEdit(const QDate &d, QWidget *parent = Q_NULLPTR);
- explicit QDateTimeEdit(const QTime &t, QWidget *parent = Q_NULLPTR);
+ explicit QDateTimeEdit(QWidget *parent = nullptr);
+ explicit QDateTimeEdit(const QDateTime &dt, QWidget *parent = nullptr);
+ explicit QDateTimeEdit(const QDate &d, QWidget *parent = nullptr);
+ explicit QDateTimeEdit(const QTime &t, QWidget *parent = nullptr);
~QDateTimeEdit();
QDateTime dateTime() const;
@@ -191,7 +191,7 @@ protected:
void paintEvent(QPaintEvent *event) override;
void initStyleOption(QStyleOptionSpinBox *option) const;
- QDateTimeEdit(const QVariant &val, QVariant::Type parserType, QWidget *parent = Q_NULLPTR);
+ QDateTimeEdit(const QVariant &val, QVariant::Type parserType, QWidget *parent = nullptr);
private:
Q_DECLARE_PRIVATE(QDateTimeEdit)
Q_DISABLE_COPY(QDateTimeEdit)
@@ -204,8 +204,8 @@ class Q_WIDGETS_EXPORT QTimeEdit : public QDateTimeEdit
Q_OBJECT
Q_PROPERTY(QTime time READ time WRITE setTime NOTIFY userTimeChanged USER true)
public:
- explicit QTimeEdit(QWidget *parent = Q_NULLPTR);
- explicit QTimeEdit(const QTime &time, QWidget *parent = Q_NULLPTR);
+ explicit QTimeEdit(QWidget *parent = nullptr);
+ explicit QTimeEdit(const QTime &time, QWidget *parent = nullptr);
~QTimeEdit();
Q_SIGNALS:
@@ -217,8 +217,8 @@ class Q_WIDGETS_EXPORT QDateEdit : public QDateTimeEdit
Q_OBJECT
Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY userDateChanged USER true)
public:
- explicit QDateEdit(QWidget *parent = Q_NULLPTR);
- explicit QDateEdit(const QDate &date, QWidget *parent = Q_NULLPTR);
+ explicit QDateEdit(QWidget *parent = nullptr);
+ explicit QDateEdit(const QDate &date, QWidget *parent = nullptr);
~QDateEdit();
Q_SIGNALS:
diff --git a/src/widgets/widgets/qdatetimeedit_p.h b/src/widgets/widgets/qdatetimeedit_p.h
index 5ac5a9db6a..1ebc98dedf 100644
--- a/src/widgets/widgets/qdatetimeedit_p.h
+++ b/src/widgets/widgets/qdatetimeedit_p.h
@@ -80,25 +80,25 @@ public:
void clearSection(int index);
// Override QAbstractSpinBoxPrivate:
- void emitSignals(EmitPolicy ep, const QVariant &old) Q_DECL_OVERRIDE;
- QString textFromValue(const QVariant &f) const Q_DECL_OVERRIDE;
- QVariant valueFromText(const QString &f) const Q_DECL_OVERRIDE;
- void _q_editorCursorPositionChanged(int oldpos, int newpos) Q_DECL_OVERRIDE;
- void interpret(EmitPolicy ep) Q_DECL_OVERRIDE;
- void clearCache() const Q_DECL_OVERRIDE;
- QStyle::SubControl newHoverControl(const QPoint &pos) Q_DECL_OVERRIDE;
- void updateEditFieldGeometry() Q_DECL_OVERRIDE;
- QVariant getZeroVariant() const Q_DECL_OVERRIDE;
- void setRange(const QVariant &min, const QVariant &max) Q_DECL_OVERRIDE;
- void updateEdit() Q_DECL_OVERRIDE;
+ void emitSignals(EmitPolicy ep, const QVariant &old) override;
+ QString textFromValue(const QVariant &f) const override;
+ QVariant valueFromText(const QString &f) const override;
+ void _q_editorCursorPositionChanged(int oldpos, int newpos) override;
+ void interpret(EmitPolicy ep) override;
+ void clearCache() const override;
+ QStyle::SubControl newHoverControl(const QPoint &pos) override;
+ void updateEditFieldGeometry() override;
+ QVariant getZeroVariant() const override;
+ void setRange(const QVariant &min, const QVariant &max) override;
+ void updateEdit() override;
// Override QDateTimeParser:
- QString displayText() const Q_DECL_OVERRIDE { return edit->text(); }
- QDateTime getMinimum() const Q_DECL_OVERRIDE { return minimum.toDateTime(); }
- QDateTime getMaximum() const Q_DECL_OVERRIDE { return maximum.toDateTime(); }
- QLocale locale() const Q_DECL_OVERRIDE { return q_func()->locale(); }
- QString getAmPmText(AmPm ap, Case cs) const Q_DECL_OVERRIDE;
- int cursorPosition() const Q_DECL_OVERRIDE { return edit ? edit->cursorPosition() : -1; }
+ QString displayText() const override { return edit->text(); }
+ QDateTime getMinimum() const override { return minimum.toDateTime(); }
+ QDateTime getMaximum() const override { return maximum.toDateTime(); }
+ QLocale locale() const override { return q_func()->locale(); }
+ QString getAmPmText(AmPm ap, Case cs) const override;
+ int cursorPosition() const override { return edit ? edit->cursorPosition() : -1; }
int absoluteIndex(QDateTimeEdit::Section s, int index) const;
int absoluteIndex(const SectionNode &s) const;
diff --git a/src/widgets/widgets/qdial.cpp b/src/widgets/widgets/qdial.cpp
index c08c820127..25d57970bf 100644
--- a/src/widgets/widgets/qdial.cpp
+++ b/src/widgets/widgets/qdial.cpp
@@ -79,7 +79,7 @@ public:
int valueFromPoint(const QPoint &) const;
double angle(const QPoint &, const QPoint &) const;
void init();
- virtual int bound(int val) const Q_DECL_OVERRIDE;
+ virtual int bound(int val) const override;
};
void QDialPrivate::init()
diff --git a/src/widgets/widgets/qdial.h b/src/widgets/widgets/qdial.h
index ed753d86b0..1db1f9bb07 100644
--- a/src/widgets/widgets/qdial.h
+++ b/src/widgets/widgets/qdial.h
@@ -61,7 +61,7 @@ class Q_WIDGETS_EXPORT QDial: public QAbstractSlider
Q_PROPERTY(qreal notchTarget READ notchTarget WRITE setNotchTarget)
Q_PROPERTY(bool notchesVisible READ notchesVisible WRITE setNotchesVisible)
public:
- explicit QDial(QWidget *parent = Q_NULLPTR);
+ explicit QDial(QWidget *parent = nullptr);
~QDial();
@@ -73,23 +73,23 @@ public:
qreal notchTarget() const;
bool notchesVisible() const;
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ QSize minimumSizeHint() const override;
public Q_SLOTS:
void setNotchesVisible(bool visible);
void setWrapping(bool on);
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *re) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *pe) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
+ void resizeEvent(QResizeEvent *re) override;
+ void paintEvent(QPaintEvent *pe) override;
- void mousePressEvent(QMouseEvent *me) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *me) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *me) Q_DECL_OVERRIDE;
+ void mousePressEvent(QMouseEvent *me) override;
+ void mouseReleaseEvent(QMouseEvent *me) override;
+ void mouseMoveEvent(QMouseEvent *me) override;
- void sliderChange(SliderChange change) Q_DECL_OVERRIDE;
+ void sliderChange(SliderChange change) override;
void initStyleOption(QStyleOptionSlider *option) const;
diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp
index 90cb17da59..9f5b739230 100644
--- a/src/widgets/widgets/qdialogbuttonbox.cpp
+++ b/src/widgets/widgets/qdialogbuttonbox.cpp
@@ -579,6 +579,8 @@ QDialogButtonBox::~QDialogButtonBox()
\value MacLayout Use a policy appropriate for applications on \macos.
\value KdeLayout Use a policy appropriate for applications on KDE.
\value GnomeLayout Use a policy appropriate for applications on GNOME.
+ \value AndroidLayout Use a policy appropriate for applications on Android.
+ This enum value was added in Qt 5.10.
The button layout is specified by the \l{style()}{current style}. However,
on the X11 platform, it may be influenced by the desktop environment.
@@ -925,8 +927,8 @@ void QDialogButtonBox::changeEvent(QEvent *event)
for (StandardButtonHash::iterator it = d->standardButtonHash.begin(); it != end; ++it)
it.key()->setStyle(newStyle);
}
- // fallthrough intended
#ifdef Q_OS_MAC
+ Q_FALLTHROUGH();
case QEvent::MacSizeChange:
#endif
d->resetLayout();
diff --git a/src/widgets/widgets/qdialogbuttonbox.h b/src/widgets/widgets/qdialogbuttonbox.h
index af9e705234..a9a1a3453d 100644
--- a/src/widgets/widgets/qdialogbuttonbox.h
+++ b/src/widgets/widgets/qdialogbuttonbox.h
@@ -108,18 +108,20 @@ public:
Q_FLAG(StandardButtons)
enum ButtonLayout {
- // keep this in sync with QMessageBox::ButtonLayout and QPlatformDialogHelper::ButtonLayout
+ // keep this in sync with QPlatformDialogHelper::ButtonLayout
WinLayout,
MacLayout,
KdeLayout,
- GnomeLayout
+ GnomeLayout,
+ // MacModelessLayout,
+ AndroidLayout = GnomeLayout + 2 // ### Qt 6: reorder
};
- QDialogButtonBox(QWidget *parent = Q_NULLPTR);
- QDialogButtonBox(Qt::Orientation orientation, QWidget *parent = Q_NULLPTR);
- explicit QDialogButtonBox(StandardButtons buttons, QWidget *parent = Q_NULLPTR);
+ QDialogButtonBox(QWidget *parent = nullptr);
+ QDialogButtonBox(Qt::Orientation orientation, QWidget *parent = nullptr);
+ explicit QDialogButtonBox(StandardButtons buttons, QWidget *parent = nullptr);
QDialogButtonBox(StandardButtons buttons, Qt::Orientation orientation,
- QWidget *parent = Q_NULLPTR);
+ QWidget *parent = nullptr);
~QDialogButtonBox();
void setOrientation(Qt::Orientation orientation);
@@ -149,8 +151,8 @@ Q_SIGNALS:
void rejected();
protected:
- void changeEvent(QEvent *event) Q_DECL_OVERRIDE;
- bool event(QEvent *event) Q_DECL_OVERRIDE;
+ void changeEvent(QEvent *event) override;
+ bool event(QEvent *event) override;
private:
Q_DISABLE_COPY(QDialogButtonBox)
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index 21d1d4cb85..71726eaeee 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -45,6 +45,7 @@
#endif
#include "QtWidgets/qstyle.h"
#include "QtWidgets/qdesktopwidget.h"
+#include <private/qdesktopwidget_p.h>
#include "QtWidgets/qapplication.h"
#include "QtCore/qvariant.h"
#include "qdockarealayout_p.h"
@@ -1044,33 +1045,6 @@ QLayoutItem *QDockAreaLayoutInfo::plug(const QList<int> &path)
Q_ASSERT(item.widgetItem != 0);
Q_ASSERT(item.flags & QDockAreaLayoutItem::GapItem);
item.flags &= ~QDockAreaLayoutItem::GapItem;
-
- QRect result;
-
-#if QT_CONFIG(tabbar)
- if (tabbed) {
- } else
-#endif
- {
- int prev = this->prev(index);
- int next = this->next(index);
-
- if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {
- item.pos += *sep;
- item.size -= *sep;
- }
- if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
- item.size -= *sep;
-
- QPoint pos;
- rpick(o, pos) = item.pos;
- rperp(o, pos) = perp(o, rect.topLeft());
- QSize s;
- rpick(o, s) = item.size;
- rperp(o, s) = perp(o, rect.size());
- result = QRect(pos, s);
- }
-
return item.widgetItem;
}
@@ -1323,29 +1297,46 @@ QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(const QList<int> &path)
return item_list[index].subinfo->info(path.mid(1));
}
-QRect QDockAreaLayoutInfo::itemRect(int index) const
+QRect QDockAreaLayoutInfo::itemRect(int index, bool isGap) const
{
const QDockAreaLayoutItem &item = item_list.at(index);
if (item.skip())
return QRect();
+ if (isGap && !(item.flags & QDockAreaLayoutItem::GapItem))
+ return QRect();
+
QRect result;
#if QT_CONFIG(tabbar)
if (tabbed) {
- if (tabId(item) == currentTabId())
+ if (isGap || tabId(item) == currentTabId())
result = tabContentRect();
} else
#endif
{
- QPoint pos;
- rpick(o, pos) = item.pos;
- rperp(o, pos) = perp(o, rect.topLeft());
+ int pos = item.pos;
+ int size = item.size;
+
+ if (isGap) {
+ int prev = this->prev(index);
+ int next = this->next(index);
+ if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {
+ pos += *sep;
+ size -= *sep;
+ }
+ if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
+ size -= *sep;
+ }
+
+ QPoint p;
+ rpick(o, p) = pos;
+ rperp(o, p) = perp(o, rect.topLeft());
QSize s;
- rpick(o, s) = item.size;
+ rpick(o, s) = size;
rperp(o, s) = perp(o, rect.size());
- result = QRect(pos, s);
+ result = QRect(p, s);
}
return result;
@@ -2426,20 +2417,21 @@ QList<int> QDockAreaLayout::indexOf(QWidget *dockWidget) const
return QList<int>();
}
-QList<int> QDockAreaLayout::gapIndex(const QPoint &pos) const
+QList<int> QDockAreaLayout::gapIndex(const QPoint &pos, bool disallowTabs) const
{
QMainWindow::DockOptions opts = mainWindow->dockOptions();
bool nestingEnabled = opts & QMainWindow::AllowNestedDocks;
QDockAreaLayoutInfo::TabMode tabMode = QDockAreaLayoutInfo::NoTabs;
#if QT_CONFIG(tabbar)
- if (opts & QMainWindow::AllowTabbedDocks
- || opts & QMainWindow::VerticalTabs)
- tabMode = QDockAreaLayoutInfo::AllowTabs;
- if (opts & QMainWindow::ForceTabbedDocks)
- tabMode = QDockAreaLayoutInfo::ForceTabs;
+ if (!disallowTabs) {
+ if (opts & QMainWindow::AllowTabbedDocks || opts & QMainWindow::VerticalTabs)
+ tabMode = QDockAreaLayoutInfo::AllowTabs;
+ if (opts & QMainWindow::ForceTabbedDocks)
+ tabMode = QDockAreaLayoutInfo::ForceTabs;
- if (tabMode == QDockAreaLayoutInfo::ForceTabs)
- nestingEnabled = false;
+ if (tabMode == QDockAreaLayoutInfo::ForceTabs)
+ nestingEnabled = false;
+ }
#endif
@@ -3052,11 +3044,10 @@ QSize QDockAreaLayout::minimumSize() const
QRect QDockAreaLayout::constrainedRect(QRect rect, QWidget* widget)
{
QRect desktop;
- QDesktopWidget *desktopW = QApplication::desktop();
- if (desktopW->isVirtualDesktop())
- desktop = desktopW->screenGeometry(rect.topLeft());
+ if (QDesktopWidgetPrivate::isVirtualDesktop())
+ desktop = QDesktopWidgetPrivate::screenGeometry(rect.topLeft());
else
- desktop = desktopW->screenGeometry(widget);
+ desktop = QDesktopWidgetPrivate::screenGeometry(widget);
if (desktop.isValid()) {
rect.setWidth(qMin(rect.width(), desktop.width()));
@@ -3311,6 +3302,19 @@ int QDockAreaLayout::separatorMove(const QList<int> &separator, const QPoint &or
return delta;
}
+int QDockAreaLayoutInfo::separatorMove(const QList<int> &separator, const QPoint &origin,
+ const QPoint &dest)
+{
+ int delta = 0;
+ int index = separator.last();
+ QDockAreaLayoutInfo *info = this->info(separator);
+ delta = pick(info->o, dest - origin);
+ if (delta != 0)
+ delta = info->separatorMove(index, delta);
+ info->apply(false);
+ return delta;
+}
+
#if QT_CONFIG(tabbar)
// Sets the correct positions for the separator widgets
// Allocates new sepearator widgets with getSeparatorWidget
@@ -3420,47 +3424,10 @@ QRect QDockAreaLayout::gapRect(const QList<int> &path) const
const QDockAreaLayoutInfo *info = this->info(path);
if (info == 0)
return QRect();
- const QList<QDockAreaLayoutItem> &item_list = info->item_list;
- Qt::Orientation o = info->o;
int index = path.last();
- if (index < 0 || index >= item_list.count())
- return QRect();
- const QDockAreaLayoutItem &item = item_list.at(index);
- if (!(item.flags & QDockAreaLayoutItem::GapItem))
+ if (index < 0 || index >= info->item_list.count())
return QRect();
-
- QRect result;
-
-#if QT_CONFIG(tabbar)
- if (info->tabbed) {
- result = info->tabContentRect();
- } else
-#endif
- {
- int pos = item.pos;
- int size = item.size;
-
- int prev = info->prev(index);
- int next = info->next(index);
-
- if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {
- pos += sep;
- size -= sep;
- }
- if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
- size -= sep;
-
- QPoint p;
- rpick(o, p) = pos;
- rperp(o, p) = perp(o, info->rect.topLeft());
- QSize s;
- rpick(o, s) = size;
- rperp(o, s) = perp(o, info->rect.size());
-
- result = QRect(p, s);
- }
-
- return result;
+ return info->itemRect(index, true);
}
void QDockAreaLayout::keepSize(QDockWidget *w)
diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h
index 82244c192e..49bd157179 100644
--- a/src/widgets/widgets/qdockarealayout_p.h
+++ b/src/widgets/widgets/qdockarealayout_p.h
@@ -160,7 +160,7 @@ public:
void fitItems();
bool expansive(Qt::Orientation o) const;
int changeSize(int index, int size, bool below);
- QRect itemRect(int index) const;
+ QRect itemRect(int index, bool isGap = false) const;
QRect itemRect(const QList<int> &path) const;
QRect separatorRect(int index) const;
QRect separatorRect(const QList<int> &path) const;
@@ -182,6 +182,7 @@ public:
const QPoint &mouse) const;
QRegion separatorRegion() const;
int separatorMove(int index, int delta);
+ int separatorMove(const QList<int> &separator, const QPoint &origin, const QPoint &dest);
QLayoutItem *itemAt(int *x, int index) const;
QLayoutItem *takeAt(int *x, int index);
@@ -246,7 +247,7 @@ public:
QList<int> indexOfPlaceHolder(const QString &objectName) const;
QList<int> indexOf(QWidget *dockWidget) const;
- QList<int> gapIndex(const QPoint &pos) const;
+ QList<int> gapIndex(const QPoint &pos, bool disallowTabs) const;
QList<int> findSeparator(const QPoint &pos) const;
QDockAreaLayoutItem &item(const QList<int> &path);
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index 8d7d2a82d5..e17c2c1f4c 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -53,14 +53,10 @@
#include <qdebug.h>
#include <private/qwidgetresizehandler_p.h>
+#include <private/qstylesheetstyle_p.h>
#include "qdockwidget_p.h"
#include "qmainwindowlayout_p.h"
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
-#include <private/qapplication_p.h>
-#include <private/qt_mac_p.h>
-#include <private/qmacstyle_mac_p.h>
-#endif
QT_BEGIN_NAMESPACE
@@ -78,7 +74,7 @@ static inline QMainWindowLayout *qt_mainwindow_layout_from_dock(const QDockWidge
return qt_mainwindow_layout(window);
p = p->parentWidget();
}
- return Q_NULLPTR;
+ return nullptr;
}
static inline bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature)
@@ -125,15 +121,22 @@ class QDockWidgetTitleButton : public QAbstractButton
public:
QDockWidgetTitleButton(QDockWidget *dockWidget);
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSizeHint() const Q_DECL_OVERRIDE
+ QSize sizeHint() const override;
+ QSize minimumSizeHint() const override
{ return sizeHint(); }
- void enterEvent(QEvent *event) Q_DECL_OVERRIDE;
- void leaveEvent(QEvent *event) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
-};
+ void enterEvent(QEvent *event) override;
+ void leaveEvent(QEvent *event) override;
+ void paintEvent(QPaintEvent *event) override;
+protected:
+ bool event(QEvent *event) override;
+
+private:
+ QSize dockButtonIconSize() const;
+
+ mutable int m_iconSize = -1;
+};
QDockWidgetTitleButton::QDockWidgetTitleButton(QDockWidget *dockWidget)
: QAbstractButton(dockWidget)
@@ -141,14 +144,49 @@ QDockWidgetTitleButton::QDockWidgetTitleButton(QDockWidget *dockWidget)
setFocusPolicy(Qt::NoFocus);
}
+bool QDockWidgetTitleButton::event(QEvent *event)
+{
+ switch (event->type()) {
+ case QEvent::StyleChange:
+ case QEvent::ScreenChangeInternal:
+ m_iconSize = -1;
+ break;
+ default:
+ break;
+ }
+ return QAbstractButton::event(event);
+}
+
+static inline bool isWindowsStyle(const QStyle *style)
+{
+ // Note: QStyleSheetStyle inherits QWindowsStyle
+ const QStyle *effectiveStyle = style->inherits("QStyleSheetStyle")
+ ? static_cast<const QStyleSheetStyle *>(style)->baseStyle()
+ : style;
+ return effectiveStyle->inherits("QWindowsStyle");
+}
+
+QSize QDockWidgetTitleButton::dockButtonIconSize() const
+{
+ if (m_iconSize < 0) {
+ m_iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, this);
+ // Dock Widget title buttons on Windows where historically limited to size 10
+ // (from small icon size 16) since only a 10x10 XPM was provided.
+ // Adding larger pixmaps to the icons thus caused the icons to grow; limit
+ // this to qpiScaled(10) here.
+ if (isWindowsStyle(style()))
+ m_iconSize = qMin((10 * logicalDpiX()) / 96, m_iconSize);
+ }
+ return QSize(m_iconSize, m_iconSize);
+}
+
QSize QDockWidgetTitleButton::sizeHint() const
{
ensurePolished();
int size = 2*style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin, 0, this);
if (!icon().isNull()) {
- int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this);
- QSize sz = icon().actualSize(QSize(iconSize, iconSize));
+ const QSize sz = icon().actualSize(dockButtonIconSize());
size += qMax(sz.width(), sz.height());
}
@@ -191,8 +229,7 @@ void QDockWidgetTitleButton::paintEvent(QPaintEvent *)
opt.activeSubControls = 0;
opt.features = QStyleOptionToolButton::None;
opt.arrowType = Qt::NoArrow;
- int size = style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this);
- opt.iconSize = QSize(size, size);
+ opt.iconSize = dockButtonIconSize();
style()->drawComplexControl(QStyle::CC_ToolButton, &opt, &p, this);
}
@@ -217,10 +254,9 @@ QDockWidgetLayout::~QDockWidgetLayout()
bool QDockWidgetLayout::nativeWindowDeco() const
{
bool floating = parentWidget()->isWindow();
- if (!floating) {
- if (auto groupWindow = qobject_cast<const QDockWidgetGroupWindow*>(parentWidget()->parentWidget()))
- return groupWindow->hasNativeDecos();
- }
+ if (auto groupWindow =
+ qobject_cast<const QDockWidgetGroupWindow *>(parentWidget()->parentWidget()))
+ floating = floating || groupWindow->tabLayoutInfo();
return nativeWindowDeco(floating);
}
@@ -617,6 +653,8 @@ void QDockWidgetPrivate::init()
QObject::connect(button, SIGNAL(clicked()), q, SLOT(close()));
layout->setWidgetForRole(QDockWidgetLayout::CloseButton, button);
+ font = QApplication::font("QDockWidgetTitle");
+
#ifndef QT_NO_ACTION
toggleViewAction = new QAction(q);
toggleViewAction->setCheckable(true);
@@ -649,6 +687,7 @@ void QDockWidget::initStyleOption(QStyleOptionDockWidget *option) const
// If we are in a floating tab, init from the parent because the attributes and the geometry
// of the title bar should be taken from the floating window.
option->initFrom(floatingTab && !isFloating() ? parentWidget() : this);
+ option->fontMetrics = QFontMetrics(d->font);
option->rect = dwlayout->titleArea();
option->title = d->fixedWindowTitle;
option->closable = hasFeature(this, QDockWidget::DockWidgetClosable);
@@ -1442,9 +1481,10 @@ void QDockWidget::paintEvent(QPaintEvent *event)
}
// Title must be painted after the frame, since the areas overlap, and
- // the title may wish to extend out to all sides (eg. XP style)
+ // the title may wish to extend out to all sides (eg. Vista style)
QStyleOptionDockWidget titleOpt;
initStyleOption(&titleOpt);
+ p.setFont(d_func()->font);
p.drawControl(QStyle::CE_DockWidgetTitle, titleOpt);
}
}
diff --git a/src/widgets/widgets/qdockwidget.h b/src/widgets/widgets/qdockwidget.h
index b53fa19a03..b53a991dae 100644
--- a/src/widgets/widgets/qdockwidget.h
+++ b/src/widgets/widgets/qdockwidget.h
@@ -63,9 +63,9 @@ class Q_WIDGETS_EXPORT QDockWidget : public QWidget
Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle DESIGNABLE true)
public:
- explicit QDockWidget(const QString &title, QWidget *parent = Q_NULLPTR,
+ explicit QDockWidget(const QString &title, QWidget *parent = nullptr,
Qt::WindowFlags flags = Qt::WindowFlags());
- explicit QDockWidget(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
+ explicit QDockWidget(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
~QDockWidget();
QWidget *widget() const;
@@ -113,10 +113,10 @@ Q_SIGNALS:
void dockLocationChanged(Qt::DockWidgetArea area);
protected:
- void changeEvent(QEvent *event) Q_DECL_OVERRIDE;
- void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
- bool event(QEvent *event) Q_DECL_OVERRIDE;
+ void changeEvent(QEvent *event) override;
+ void closeEvent(QCloseEvent *event) override;
+ void paintEvent(QPaintEvent *event) override;
+ bool event(QEvent *event) override;
void initStyleOption(QStyleOptionDockWidget *option) const;
private:
diff --git a/src/widgets/widgets/qdockwidget_p.h b/src/widgets/widgets/qdockwidget_p.h
index 2c16176c37..766e4ed161 100644
--- a/src/widgets/widgets/qdockwidget_p.h
+++ b/src/widgets/widgets/qdockwidget_p.h
@@ -99,6 +99,8 @@ public:
QDockWidget::DockWidgetFeatures features;
Qt::DockWidgetAreas allowedAreas;
+ QFont font;
+
#ifndef QT_NO_ACTION
QAction *toggleViewAction;
#endif
@@ -135,18 +137,18 @@ class Q_WIDGETS_EXPORT QDockWidgetLayout : public QLayout
public:
QDockWidgetLayout(QWidget *parent = 0);
~QDockWidgetLayout();
- void addItem(QLayoutItem *item) Q_DECL_OVERRIDE;
- QLayoutItem *itemAt(int index) const Q_DECL_OVERRIDE;
- QLayoutItem *takeAt(int index) Q_DECL_OVERRIDE;
- int count() const Q_DECL_OVERRIDE;
+ void addItem(QLayoutItem *item) override;
+ QLayoutItem *itemAt(int index) const override;
+ QLayoutItem *takeAt(int index) override;
+ int count() const override;
- QSize maximumSize() const Q_DECL_OVERRIDE;
- QSize minimumSize() const Q_DECL_OVERRIDE;
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ QSize maximumSize() const override;
+ QSize minimumSize() const override;
+ QSize sizeHint() const override;
QSize sizeFromContent(const QSize &content, bool floating) const;
- void setGeometry(const QRect &r) Q_DECL_OVERRIDE;
+ void setGeometry(const QRect &r) override;
enum Role { Content, CloseButton, FloatButton, TitleBar, RoleCount };
QWidget *widgetForRole(Role r) const;
@@ -178,9 +180,9 @@ class QDockWidgetItem : public QWidgetItem
{
public:
QDockWidgetItem(QDockWidget *dockWidget);
- QSize minimumSize() const Q_DECL_OVERRIDE;
- QSize maximumSize() const Q_DECL_OVERRIDE;
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ QSize minimumSize() const override;
+ QSize maximumSize() const override;
+ QSize sizeHint() const override;
private:
inline QLayoutItem *dockWidgetChildItem() const;
diff --git a/src/widgets/widgets/qeffects.cpp b/src/widgets/widgets/qeffects.cpp
index 437cee93df..bcc8d7815d 100644
--- a/src/widgets/widgets/qeffects.cpp
+++ b/src/widgets/widgets/qeffects.cpp
@@ -50,6 +50,8 @@
#include "qelapsedtimer.h"
#include "qdebug.h"
+#include <private/qdesktopwidget_p.h>
+
QT_BEGIN_NAMESPACE
/*
@@ -69,10 +71,10 @@ public:
void run(int time);
protected:
- void paintEvent(QPaintEvent* e) Q_DECL_OVERRIDE;
- void closeEvent(QCloseEvent*) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent* e) override;
+ void closeEvent(QCloseEvent*) override;
void alphaBlend();
- bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE;
+ bool eventFilter(QObject *, QEvent *) override;
protected slots:
void render();
@@ -96,9 +98,12 @@ static QAlphaWidget* q_blend = 0;
/*
Constructs a QAlphaWidget.
*/
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED // QDesktopWidget::screen()
QAlphaWidget::QAlphaWidget(QWidget* w, Qt::WindowFlags f)
- : QWidget(QApplication::desktop()->screen(QApplication::desktop()->screenNumber(w)), f)
+ : QWidget(QApplication::desktop()->screen(QDesktopWidgetPrivate::screenNumber(w)), f)
{
+QT_WARNING_POP
#ifndef Q_OS_WIN
setEnabled(false);
#endif
@@ -346,8 +351,8 @@ public:
void run(int time);
protected:
- void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE;
- void closeEvent(QCloseEvent*) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent*) override;
+ void closeEvent(QCloseEvent*) override;
private slots:
void scroll();
diff --git a/src/widgets/widgets/qfocusframe.h b/src/widgets/widgets/qfocusframe.h
index a1fc6d345d..73d5b42bd8 100644
--- a/src/widgets/widgets/qfocusframe.h
+++ b/src/widgets/widgets/qfocusframe.h
@@ -53,17 +53,17 @@ class Q_WIDGETS_EXPORT QFocusFrame : public QWidget
{
Q_OBJECT
public:
- QFocusFrame(QWidget *parent = Q_NULLPTR);
+ QFocusFrame(QWidget *parent = nullptr);
~QFocusFrame();
void setWidget(QWidget *widget);
QWidget *widget() const;
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
- bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
+ bool eventFilter(QObject *, QEvent *) override;
+ void paintEvent(QPaintEvent *) override;
void initStyleOption(QStyleOption *option) const;
private:
diff --git a/src/widgets/widgets/qfontcombobox.cpp b/src/widgets/widgets/qfontcombobox.cpp
index f206d01999..957a464b71 100644
--- a/src/widgets/widgets/qfontcombobox.cpp
+++ b/src/widgets/widgets/qfontcombobox.cpp
@@ -47,6 +47,7 @@
#include <qapplication.h>
#include <private/qcombobox_p.h>
#include <QDesktopWidget>
+#include <private/qdesktopwidget_p.h>
#include <qdebug.h>
QT_BEGIN_NAMESPACE
@@ -188,10 +189,10 @@ public:
// painting
void paint(QPainter *painter,
const QStyleOptionViewItem &option,
- const QModelIndex &index) const Q_DECL_OVERRIDE;
+ const QModelIndex &index) const override;
QSize sizeHint(const QStyleOptionViewItem &option,
- const QModelIndex &index) const Q_DECL_OVERRIDE;
+ const QModelIndex &index) const override;
const QIcon truetype;
const QIcon bitmap;
@@ -262,7 +263,7 @@ void QFontFamilyDelegate::paint(QPainter *painter,
system = writingSystem;
if (system != QFontDatabase::Any) {
- int w = painter->fontMetrics().width(text + QLatin1String(" "));
+ int w = painter->fontMetrics().horizontalAdvance(text + QLatin1String(" "));
painter->setFont(font2);
QString sample = QFontDatabase().writingSystemSample(system);
if (option.direction == Qt::RightToLeft)
@@ -286,7 +287,7 @@ QSize QFontFamilyDelegate::sizeHint(const QStyleOptionViewItem &option,
// font.setFamily(text);
font.setPointSize(QFontInfo(font).pointSize() * 3/2);
QFontMetrics fontMetrics(font);
- return QSize(fontMetrics.width(text), fontMetrics.height());
+ return QSize(fontMetrics.horizontalAdvance(text), fontMetrics.height());
}
@@ -523,7 +524,7 @@ void QFontComboBox::setCurrentFont(const QFont &font)
}
/*!
- \fn QFontComboBox::currentFontChanged(const QFont &font)
+ \fn void QFontComboBox::currentFontChanged(const QFont &font)
This signal is emitted whenever the current font changes, with
the new \a font.
@@ -540,7 +541,7 @@ bool QFontComboBox::event(QEvent *e)
QListView *lview = qobject_cast<QListView*>(view());
if (lview) {
lview->window()->setFixedWidth(qMin(width() * 5 / 3,
- QApplication::desktop()->availableGeometry(lview).width()));
+ QDesktopWidgetPrivate::availableGeometry(lview).width()));
}
}
return QComboBox::event(e);
@@ -553,7 +554,7 @@ QSize QFontComboBox::sizeHint() const
{
QSize sz = QComboBox::sizeHint();
QFontMetrics fm(font());
- sz.setWidth(fm.width(QLatin1Char('m'))*14);
+ sz.setWidth(fm.horizontalAdvance(QLatin1Char('m'))*14);
return sz;
}
diff --git a/src/widgets/widgets/qfontcombobox.h b/src/widgets/widgets/qfontcombobox.h
index 1e4555ce2d..6c1871dd2d 100644
--- a/src/widgets/widgets/qfontcombobox.h
+++ b/src/widgets/widgets/qfontcombobox.h
@@ -58,7 +58,7 @@ class Q_WIDGETS_EXPORT QFontComboBox : public QComboBox
Q_PROPERTY(QFont currentFont READ currentFont WRITE setCurrentFont NOTIFY currentFontChanged)
public:
- explicit QFontComboBox(QWidget *parent = Q_NULLPTR);
+ explicit QFontComboBox(QWidget *parent = nullptr);
~QFontComboBox();
void setWritingSystem(QFontDatabase::WritingSystem);
@@ -78,7 +78,7 @@ public:
FontFilters fontFilters() const;
QFont currentFont() const;
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
public Q_SLOTS:
void setCurrentFont(const QFont &f);
@@ -87,7 +87,7 @@ Q_SIGNALS:
void currentFontChanged(const QFont &f);
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
private:
Q_DISABLE_COPY(QFontComboBox)
diff --git a/src/widgets/widgets/qframe.h b/src/widgets/widgets/qframe.h
index 986915a28f..595dfa929d 100644
--- a/src/widgets/widgets/qframe.h
+++ b/src/widgets/widgets/qframe.h
@@ -61,7 +61,7 @@ class Q_WIDGETS_EXPORT QFrame : public QWidget
Q_PROPERTY(QRect frameRect READ frameRect WRITE setFrameRect DESIGNABLE false)
public:
- explicit QFrame(QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
+ explicit QFrame(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
~QFrame();
int frameStyle() const;
@@ -69,7 +69,7 @@ public:
int frameWidth() const;
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
enum Shape {
NoFrame = 0, // no frame
@@ -108,14 +108,14 @@ public:
void setFrameRect(const QRect &);
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
- void changeEvent(QEvent *) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
+ void paintEvent(QPaintEvent *) override;
+ void changeEvent(QEvent *) override;
void drawFrame(QPainter *);
protected:
- QFrame(QFramePrivate &dd, QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
+ QFrame(QFramePrivate &dd, QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
void initStyleOption(QStyleOptionFrame *option) const;
private:
diff --git a/src/widgets/widgets/qgroupbox.cpp b/src/widgets/widgets/qgroupbox.cpp
index 611f3f88db..69eac1ebf7 100644
--- a/src/widgets/widgets/qgroupbox.cpp
+++ b/src/widgets/widgets/qgroupbox.cpp
@@ -484,7 +484,7 @@ QSize QGroupBox::minimumSizeHint() const
QFontMetrics metrics(fontMetrics());
- int baseWidth = metrics.width(d->title) + metrics.width(QLatin1Char(' '));
+ int baseWidth = metrics.horizontalAdvance(d->title) + metrics.horizontalAdvance(QLatin1Char(' '));
int baseHeight = metrics.height();
if (d->checkable) {
baseWidth += style()->pixelMetric(QStyle::PM_IndicatorWidth);
diff --git a/src/widgets/widgets/qgroupbox.h b/src/widgets/widgets/qgroupbox.h
index 668dc03f3d..deaeba4656 100644
--- a/src/widgets/widgets/qgroupbox.h
+++ b/src/widgets/widgets/qgroupbox.h
@@ -59,8 +59,8 @@ class Q_WIDGETS_EXPORT QGroupBox : public QWidget
Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable)
Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled USER true)
public:
- explicit QGroupBox(QWidget *parent = Q_NULLPTR);
- explicit QGroupBox(const QString &title, QWidget *parent = Q_NULLPTR);
+ explicit QGroupBox(QWidget *parent = nullptr);
+ explicit QGroupBox(const QString &title, QWidget *parent = nullptr);
~QGroupBox();
QString title() const;
@@ -69,7 +69,7 @@ public:
Qt::Alignment alignment() const;
void setAlignment(int alignment);
- QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ QSize minimumSizeHint() const override;
bool isFlat() const;
void setFlat(bool flat);
@@ -85,15 +85,15 @@ Q_SIGNALS:
void toggled(bool);
protected:
- bool event(QEvent *event) Q_DECL_OVERRIDE;
- void childEvent(QChildEvent *event) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
- void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
- void changeEvent(QEvent *event) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+ bool event(QEvent *event) override;
+ void childEvent(QChildEvent *event) override;
+ void resizeEvent(QResizeEvent *event) override;
+ void paintEvent(QPaintEvent *event) override;
+ void focusInEvent(QFocusEvent *event) override;
+ void changeEvent(QEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
void initStyleOption(QStyleOptionGroupBox *option) const;
diff --git a/src/widgets/widgets/qkeysequenceedit.h b/src/widgets/widgets/qkeysequenceedit.h
index d5b4b199cd..85d76f14a3 100644
--- a/src/widgets/widgets/qkeysequenceedit.h
+++ b/src/widgets/widgets/qkeysequenceedit.h
@@ -55,8 +55,8 @@ class Q_WIDGETS_EXPORT QKeySequenceEdit : public QWidget
Q_PROPERTY(QKeySequence keySequence READ keySequence WRITE setKeySequence NOTIFY keySequenceChanged USER true)
public:
- explicit QKeySequenceEdit(QWidget *parent = Q_NULLPTR);
- explicit QKeySequenceEdit(const QKeySequence &keySequence, QWidget *parent = Q_NULLPTR);
+ explicit QKeySequenceEdit(QWidget *parent = nullptr);
+ explicit QKeySequenceEdit(const QKeySequence &keySequence, QWidget *parent = nullptr);
~QKeySequenceEdit();
QKeySequence keySequence() const;
@@ -72,10 +72,10 @@ Q_SIGNALS:
protected:
QKeySequenceEdit(QKeySequenceEditPrivate &d, QWidget *parent, Qt::WindowFlags f);
- bool event(QEvent *) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE;
- void keyReleaseEvent(QKeyEvent *) Q_DECL_OVERRIDE;
- void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE;
+ bool event(QEvent *) override;
+ void keyPressEvent(QKeyEvent *) override;
+ void keyReleaseEvent(QKeyEvent *) override;
+ void timerEvent(QTimerEvent *) override;
private:
Q_DISABLE_COPY(QKeySequenceEdit)
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp
index e3225800cc..ee4825d3e5 100644
--- a/src/widgets/widgets/qlabel.cpp
+++ b/src/widgets/widgets/qlabel.cpp
@@ -66,16 +66,16 @@ QLabelPrivate::QLabelPrivate()
sh(),
msh(),
text(),
- pixmap(Q_NULLPTR),
- scaledpixmap(Q_NULLPTR),
- cachedimage(Q_NULLPTR),
+ pixmap(nullptr),
+ scaledpixmap(nullptr),
+ cachedimage(nullptr),
#ifndef QT_NO_PICTURE
- picture(Q_NULLPTR),
+ picture(nullptr),
#endif
#if QT_CONFIG(movie)
movie(),
#endif
- control(Q_NULLPTR),
+ control(nullptr),
shortcutCursor(),
#ifndef QT_NO_CURSOR
cursor(),
@@ -583,7 +583,7 @@ QSize QLabelPrivate::sizeForWidth(int w) const
int m = indent;
if (m < 0 && q->frameWidth()) // no indent, but we do have a frame
- m = fm.width(QLatin1Char('x')) - margin*2;
+ m = fm.horizontalAdvance(QLatin1Char('x')) - margin*2;
if (m > 0) {
if ((align & Qt::AlignLeft) || (align & Qt::AlignRight))
hextra += m;
@@ -1440,7 +1440,7 @@ QRect QLabelPrivate::documentRect() const
: q->layoutDirection(), QFlag(this->align));
int m = indent;
if (m < 0 && q->frameWidth()) // no indent, but we do have a frame
- m = q->fontMetrics().width(QLatin1Char('x')) / 2 - margin;
+ m = q->fontMetrics().horizontalAdvance(QLatin1Char('x')) / 2 - margin;
if (m > 0) {
if (align & Qt::AlignLeft)
cr.setLeft(cr.left() + m);
diff --git a/src/widgets/widgets/qlabel.h b/src/widgets/widgets/qlabel.h
index 469254a145..e1cc333a1c 100644
--- a/src/widgets/widgets/qlabel.h
+++ b/src/widgets/widgets/qlabel.h
@@ -67,8 +67,8 @@ class Q_WIDGETS_EXPORT QLabel : public QFrame
Q_PROPERTY(QString selectedText READ selectedText)
public:
- explicit QLabel(QWidget *parent=Q_NULLPTR, Qt::WindowFlags f=Qt::WindowFlags());
- explicit QLabel(const QString &text, QWidget *parent=Q_NULLPTR, Qt::WindowFlags f=Qt::WindowFlags());
+ explicit QLabel(QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags());
+ explicit QLabel(const QString &text, QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags());
~QLabel();
QString text() const;
@@ -97,13 +97,13 @@ public:
bool hasScaledContents() const;
void setScaledContents(bool);
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ QSize minimumSizeHint() const override;
#ifndef QT_NO_SHORTCUT
void setBuddy(QWidget *);
QWidget *buddy() const;
#endif
- int heightForWidth(int) const Q_DECL_OVERRIDE;
+ int heightForWidth(int) const override;
bool openExternalLinks() const;
void setOpenExternalLinks(bool open);
@@ -134,19 +134,19 @@ Q_SIGNALS:
void linkHovered(const QString& link);
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *ev) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
- void changeEvent(QEvent *) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *ev) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *ev) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *ev) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
+ void keyPressEvent(QKeyEvent *ev) override;
+ void paintEvent(QPaintEvent *) override;
+ void changeEvent(QEvent *) override;
+ void mousePressEvent(QMouseEvent *ev) override;
+ void mouseMoveEvent(QMouseEvent *ev) override;
+ void mouseReleaseEvent(QMouseEvent *ev) override;
#ifndef QT_NO_CONTEXTMENU
- void contextMenuEvent(QContextMenuEvent *ev) Q_DECL_OVERRIDE;
+ void contextMenuEvent(QContextMenuEvent *ev) override;
#endif // QT_NO_CONTEXTMENU
- void focusInEvent(QFocusEvent *ev) Q_DECL_OVERRIDE;
- void focusOutEvent(QFocusEvent *ev) Q_DECL_OVERRIDE;
- bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE;
+ void focusInEvent(QFocusEvent *ev) override;
+ void focusOutEvent(QFocusEvent *ev) override;
+ bool focusNextPrevChild(bool next) override;
private:
diff --git a/src/widgets/widgets/qlcdnumber.h b/src/widgets/widgets/qlcdnumber.h
index 28fd530e6e..644c39eaf3 100644
--- a/src/widgets/widgets/qlcdnumber.h
+++ b/src/widgets/widgets/qlcdnumber.h
@@ -59,8 +59,8 @@ class Q_WIDGETS_EXPORT QLCDNumber : public QFrame // LCD number widget
Q_PROPERTY(int intValue READ intValue WRITE display)
public:
- explicit QLCDNumber(QWidget* parent = Q_NULLPTR);
- explicit QLCDNumber(uint numDigits, QWidget* parent = Q_NULLPTR);
+ explicit QLCDNumber(QWidget* parent = nullptr);
+ explicit QLCDNumber(uint numDigits, QWidget* parent = nullptr);
~QLCDNumber();
enum Mode {
@@ -88,7 +88,7 @@ public:
double value() const;
int intValue() const;
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
public Q_SLOTS:
void display(const QString &str);
@@ -104,8 +104,8 @@ Q_SIGNALS:
void overflow();
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
+ void paintEvent(QPaintEvent *) override;
public:
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index 13b204e825..e3b348f0ef 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -80,7 +80,10 @@
#include "private/qapplication_p.h"
#include "private/qshortcutmap_p.h"
#include "qkeysequence.h"
-#define ACCEL_KEY(k) (!qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? \
+#define ACCEL_KEY(k) ((qApp->testAttribute(Qt::AA_DontShowIconsInMenus) \
+ ? false \
+ : qApp->styleHints()->showShortcutsInContextMenus()) \
+ && !qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? \
QLatin1Char('\t') + QKeySequence(k).toString(QKeySequence::NativeText) : QString())
#else
#define ACCEL_KEY(k) QString()
@@ -93,10 +96,6 @@
QT_BEGIN_NAMESPACE
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
-extern void qt_mac_secure_keyboard(bool); //qapplication_mac.cpp
-#endif
-
/*!
Initialize \a option with the values from this QLineEdit. This method
is useful for subclasses when they need a QStyleOptionFrame, but don't want
@@ -232,10 +231,10 @@ void QLineEdit::initStyleOption(QStyleOptionFrame *option) const
*/
/*!
- \fn void QLineEdit::cursorPositionChanged(int old, int new)
+ \fn void QLineEdit::cursorPositionChanged(int oldPos, int newPos)
This signal is emitted whenever the cursor moves. The previous
- position is given by \a old, and the new position by \a new.
+ position is given by \a oldPos, and the new position by \a newPos.
\sa setCursorPosition(), cursorPosition()
*/
@@ -578,10 +577,6 @@ void QLineEdit::setEchoMode(EchoMode mode)
setInputMethodHints(imHints);
d->control->setEchoMode(mode);
update();
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
- if (hasFocus())
- qt_mac_secure_keyboard(mode == Password || mode == NoEcho);
-#endif
}
@@ -687,7 +682,7 @@ QSize QLineEdit::sizeHint() const
int h = qMax(fm.height(), 14) + 2*d->verticalMargin
+ d->topTextMargin + d->bottomTextMargin
+ d->topmargin + d->bottommargin;
- int w = fm.width(QLatin1Char('x')) * 17 + 2*d->horizontalMargin
+ int w = fm.horizontalAdvance(QLatin1Char('x')) * 17 + 2*d->horizontalMargin
+ d->effectiveLeftTextMargin() + d->effectiveRightTextMargin()
+ d->leftmargin + d->rightmargin; // "some"
QStyleOptionFrame opt;
@@ -964,6 +959,8 @@ QString QLineEdit::selectedText() const
line edit or -1 if no text is selected.
\sa selectedText()
+ \sa selectionEnd()
+ \sa selectionLength()
*/
int QLineEdit::selectionStart() const
@@ -972,8 +969,33 @@ int QLineEdit::selectionStart() const
return d->control->selectionStart();
}
+/*!
+ Returns the index of the character directly after the selection
+ in the line edit or -1 if no text is selected.
+ \since 5.10
+
+ \sa selectedText()
+ \sa selectionStart()
+ \sa selectionLength()
+*/
+int QLineEdit::selectionEnd() const
+{
+ Q_D(const QLineEdit);
+ return d->control->selectionEnd();
+}
+/*!
+ Returns the length of the selection.
+ \since 5.10
+ \sa selectedText()
+ \sa selectionStart()
+ \sa selectionEnd()
+*/
+int QLineEdit::selectionLength() const
+{
+ return selectionEnd() - selectionStart();
+}
/*!
Selects text from position \a start and for \a length characters.
@@ -1444,6 +1466,8 @@ bool QLineEdit::event(QEvent * e)
#endif
} else if (e->type() == QEvent::Resize) {
d->positionSideWidgets();
+ } else if (e->type() == QEvent::StyleChange) {
+ d->initMouseYThreshold();
}
#ifdef QT_KEYPAD_NAVIGATION
if (QApplication::keypadNavigationEnabled()) {
@@ -1524,7 +1548,17 @@ void QLineEdit::mouseMoveEvent(QMouseEvent * e)
const bool select = (d->imHints & Qt::ImhNoPredictiveText);
#endif
#ifndef QT_NO_IM
- if (d->control->composeMode() && select) {
+ if (d->mouseYThreshold > 0 && e->pos().y() > d->mousePressPos.y() + d->mouseYThreshold) {
+ if (layoutDirection() == Qt::RightToLeft)
+ d->control->home(select);
+ else
+ d->control->end(select);
+ } else if (d->mouseYThreshold > 0 && e->pos().y() + d->mouseYThreshold < d->mousePressPos.y()) {
+ if (layoutDirection() == Qt::RightToLeft)
+ d->control->end(select);
+ else
+ d->control->home(select);
+ } else if (d->control->composeMode() && select) {
int startPos = d->xToPos(d->mousePressPos.x());
int currentPos = d->xToPos(e->pos().x());
if (startPos != currentPos)
@@ -1563,7 +1597,7 @@ void QLineEdit::mouseReleaseEvent(QMouseEvent* e)
d->control->copy(QClipboard::Selection);
} else if (!d->control->isReadOnly() && e->button() == Qt::MidButton) {
deselect();
- insert(QApplication::clipboard()->text(QClipboard::Selection));
+ d->control->paste(QClipboard::Selection);
}
}
#endif
@@ -1818,10 +1852,6 @@ void QLineEdit::focusInEvent(QFocusEvent *e)
if((!hasSelectedText() && d->control->preeditAreaText().isEmpty())
|| style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, this))
d->setCursorVisible(true);
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
- if (d->control->echoMode() == Password || d->control->echoMode() == NoEcho)
- qt_mac_secure_keyboard(true);
-#endif
#ifdef QT_KEYPAD_NAVIGATION
d->control->setCancelText(d->control->text());
}
@@ -1866,10 +1896,6 @@ void QLineEdit::focusOutEvent(QFocusEvent *e)
if (hasAcceptableInput() || d->control->fixup())
emit editingFinished();
}
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
- if (d->control->echoMode() == Password || d->control->echoMode() == NoEcho)
- qt_mac_secure_keyboard(false);
-#endif
#ifdef QT_KEYPAD_NAVIGATION
d->control->setCancelText(QString());
#endif
diff --git a/src/widgets/widgets/qlineedit.h b/src/widgets/widgets/qlineedit.h
index 08dd6f3b83..099bf4bb18 100644
--- a/src/widgets/widgets/qlineedit.h
+++ b/src/widgets/widgets/qlineedit.h
@@ -90,8 +90,8 @@ public:
};
Q_ENUM(ActionPosition)
- explicit QLineEdit(QWidget *parent = Q_NULLPTR);
- explicit QLineEdit(const QString &, QWidget *parent = Q_NULLPTR);
+ explicit QLineEdit(QWidget *parent = nullptr);
+ explicit QLineEdit(const QString &, QWidget *parent = nullptr);
~QLineEdit();
QString text() const;
@@ -128,8 +128,8 @@ public:
QCompleter *completer() const;
#endif
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ QSize minimumSizeHint() const override;
int cursorPosition() const;
void setCursorPosition(int);
@@ -154,6 +154,8 @@ public:
bool hasSelectedText() const;
QString selectedText() const;
int selectionStart() const;
+ int selectionEnd() const;
+ int selectionLength() const;
bool isUndoAvailable() const;
bool isRedoAvailable() const;
@@ -207,31 +209,31 @@ Q_SIGNALS:
void selectionChanged();
protected:
- void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void mouseDoubleClickEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE;
- void focusInEvent(QFocusEvent *) Q_DECL_OVERRIDE;
- void focusOutEvent(QFocusEvent *) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
+ void mousePressEvent(QMouseEvent *) override;
+ void mouseMoveEvent(QMouseEvent *) override;
+ void mouseReleaseEvent(QMouseEvent *) override;
+ void mouseDoubleClickEvent(QMouseEvent *) override;
+ void keyPressEvent(QKeyEvent *) override;
+ void focusInEvent(QFocusEvent *) override;
+ void focusOutEvent(QFocusEvent *) override;
+ void paintEvent(QPaintEvent *) override;
#ifndef QT_NO_DRAGANDDROP
- void dragEnterEvent(QDragEnterEvent *) Q_DECL_OVERRIDE;
- void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE;
- void dragLeaveEvent(QDragLeaveEvent *e) Q_DECL_OVERRIDE;
- void dropEvent(QDropEvent *) Q_DECL_OVERRIDE;
+ void dragEnterEvent(QDragEnterEvent *) override;
+ void dragMoveEvent(QDragMoveEvent *e) override;
+ void dragLeaveEvent(QDragLeaveEvent *e) override;
+ void dropEvent(QDropEvent *) override;
#endif
- void changeEvent(QEvent *) Q_DECL_OVERRIDE;
+ void changeEvent(QEvent *) override;
#ifndef QT_NO_CONTEXTMENU
- void contextMenuEvent(QContextMenuEvent *) Q_DECL_OVERRIDE;
+ void contextMenuEvent(QContextMenuEvent *) override;
#endif
- void inputMethodEvent(QInputMethodEvent *) Q_DECL_OVERRIDE;
+ void inputMethodEvent(QInputMethodEvent *) override;
void initStyleOption(QStyleOptionFrame *option) const;
public:
- QVariant inputMethodQuery(Qt::InputMethodQuery) const Q_DECL_OVERRIDE;
+ QVariant inputMethodQuery(Qt::InputMethodQuery) const override;
Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery property, QVariant argument) const;
- bool event(QEvent *) Q_DECL_OVERRIDE;
+ bool event(QEvent *) override;
protected:
QRect cursorRect() const;
diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp
index 5b352f5554..6a8af53c97 100644
--- a/src/widgets/widgets/qlineedit_p.cpp
+++ b/src/widgets/widgets/qlineedit_p.cpp
@@ -56,6 +56,7 @@
#endif
#include <qpainter.h>
#include <qpropertyanimation.h>
+#include <qstylehints.h>
#include <qvalidator.h>
QT_BEGIN_NAMESPACE
@@ -232,6 +233,13 @@ void QLineEditPrivate::init(const QString& txt)
q->setAcceptDrops(true);
q->setAttribute(Qt::WA_MacShowFocusRect);
+
+ initMouseYThreshold();
+}
+
+void QLineEditPrivate::initMouseYThreshold()
+{
+ mouseYThreshold = QGuiApplication::styleHints()->mouseQuickSelectionThreshold();
}
QRect QLineEditPrivate::adjustedContentsRect() const
@@ -330,13 +338,13 @@ QLineEditIconButton::QLineEditIconButton(QWidget *parent)
QLineEditPrivate *QLineEditIconButton::lineEditPrivate() const
{
QLineEdit *le = qobject_cast<QLineEdit *>(parentWidget());
- return le ? static_cast<QLineEditPrivate *>(qt_widget_private(le)) : Q_NULLPTR;
+ return le ? static_cast<QLineEditPrivate *>(qt_widget_private(le)) : nullptr;
}
void QLineEditIconButton::paintEvent(QPaintEvent *)
{
QPainter painter(this);
- QWindow *window = Q_NULLPTR;
+ QWindow *window = nullptr;
if (const QWidget *nativeParent = nativeParentWidget())
window = nativeParent->windowHandle();
// Note isDown should really use the active state but in most styles
diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h
index 77a91880df..39f670b0b0 100644
--- a/src/widgets/widgets/qlineedit_p.h
+++ b/src/widgets/widgets/qlineedit_p.h
@@ -94,8 +94,8 @@ public:
#endif
protected:
- void actionEvent(QActionEvent *e) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
+ void actionEvent(QActionEvent *e) override;
+ void paintEvent(QPaintEvent *event) override;
private slots:
void updateCursor();
@@ -141,7 +141,7 @@ public:
dragEnabled(0), clickCausedFocus(0), hscroll(0), vscroll(0),
alignment(Qt::AlignLeading | Qt::AlignVCenter),
leftTextMargin(0), topTextMargin(0), rightTextMargin(0), bottomTextMargin(0),
- lastTextSize(0)
+ lastTextSize(0), mouseYThreshold(0)
{
}
@@ -155,6 +155,7 @@ public:
QPointer<QAction> selectAllAction;
#endif
void init(const QString&);
+ void initMouseYThreshold();
QRect adjustedControlRect(const QRect &) const;
@@ -253,6 +254,7 @@ private:
SideWidgetEntryList leadingSideWidgets;
SideWidgetEntryList trailingSideWidgets;
int lastTextSize;
+ int mouseYThreshold;
};
Q_DECLARE_TYPEINFO(QLineEditPrivate::SideWidgetEntry, Q_PRIMITIVE_TYPE);
Q_DECLARE_TYPEINFO(QLineEditPrivate::SideWidgetLocation, Q_PRIMITIVE_TYPE);
diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.h b/src/widgets/widgets/qmaccocoaviewcontainer_mac.h
index d926ef8569..0de3989167 100644
--- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.h
+++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.h
@@ -52,7 +52,7 @@ class Q_WIDGETS_EXPORT QMacCocoaViewContainer : public QWidget
{
Q_OBJECT
public:
- QMacCocoaViewContainer(NSView *cocoaViewToWrap, QWidget *parent = Q_NULLPTR);
+ QMacCocoaViewContainer(NSView *cocoaViewToWrap, QWidget *parent = nullptr);
virtual ~QMacCocoaViewContainer();
void setCocoaView(NSView *view);
diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
index 610df2125b..98ee90deb7 100644
--- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
+++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
@@ -108,11 +108,9 @@ QMacCocoaViewContainerPrivate::~QMacCocoaViewContainerPrivate()
}
/*!
- \fn QMacCocoaViewContainer::QMacCocoaViewContainer(NSView *cocoaViewToWrap, QWidget *parent)
-
- Create a new QMacCocoaViewContainer using the NSView pointer in \a
- cocoaViewToWrap with parent, \a parent. QMacCocoaViewContainer will
- retain \a cocoaViewToWrap.
+ Create a new QMacCocoaViewContainer using the NSView pointer in
+ the \a view with parent, \a parent. QMacCocoaViewContainer will
+ retain the \a view.
*/
QMacCocoaViewContainer::QMacCocoaViewContainer(NSView *view, QWidget *parent)
diff --git a/src/widgets/widgets/qmacnativewidget_mac.h b/src/widgets/widgets/qmacnativewidget_mac.h
index a8faffd6be..6fd90516ac 100644
--- a/src/widgets/widgets/qmacnativewidget_mac.h
+++ b/src/widgets/widgets/qmacnativewidget_mac.h
@@ -51,7 +51,7 @@ class Q_WIDGETS_EXPORT QMacNativeWidget : public QWidget
{
Q_OBJECT
public:
- QMacNativeWidget(NSView *parentView = Q_NULLPTR);
+ QMacNativeWidget(NSView *parentView = nullptr);
~QMacNativeWidget();
QSize sizeHint() const override;
diff --git a/src/widgets/widgets/qmacnativewidget_mac.mm b/src/widgets/widgets/qmacnativewidget_mac.mm
index 9ad8aa1305..874ca84b61 100644
--- a/src/widgets/widgets/qmacnativewidget_mac.mm
+++ b/src/widgets/widgets/qmacnativewidget_mac.mm
@@ -145,8 +145,7 @@ QSize QMacNativeWidget::sizeHint() const
return QWidget::sizeHint();
}
-/*! \fn NSView *QMacNativeWidget::nativeView() const
-
+/*!
Returns the native view backing the QMacNativeWidget.
*/
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index ced7ec38ea..bf0a88e7fb 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -66,13 +66,6 @@
#ifdef Q_OS_OSX
#include <qpa/qplatformnativeinterface.h>
#endif
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
-#include <private/qt_mac_p.h>
-#include <private/qt_cocoa_helpers_mac_p.h>
-QT_BEGIN_NAMESPACE
-extern OSWindowRef qt_mac_window_for(const QWidget *); // qwidget_mac.cpp
-QT_END_NAMESPACE
-#endif
QT_BEGIN_NAMESPACE
@@ -85,13 +78,6 @@ public:
#ifdef Q_OS_OSX
, useUnifiedToolBar(false)
#endif
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
- , useHIToolBar(false)
- , activateUnifiedToolbarAfterFullScreen(false)
-#endif
-#if QT_CONFIG(dockwidget) && !defined(QT_NO_CURSOR)
- , hasOldCursor(false) , cursorAdjusted(false)
-#endif
{ }
QMainWindowLayout *layout;
QSize iconSize;
@@ -100,22 +86,7 @@ public:
#ifdef Q_OS_OSX
bool useUnifiedToolBar;
#endif
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
- bool useHIToolBar;
- bool activateUnifiedToolbarAfterFullScreen;
-#endif
void init();
- QList<int> hoverSeparator;
- QPoint hoverPos;
-
-#if QT_CONFIG(dockwidget) && !defined(QT_NO_CURSOR)
- QCursor separatorCursor(const QList<int> &path) const;
- void adjustCursor(const QPoint &pos);
- QCursor oldCursor;
- QCursor adjustedCursor;
- uint hasOldCursor : 1;
- uint cursorAdjusted : 1;
-#endif
static inline QMainWindowLayout *mainWindowLayout(const QMainWindow *mainWindow)
{
@@ -811,11 +782,7 @@ void QMainWindow::addToolBar(Qt::ToolBarArea area, QToolBar *toolbar)
#endif
}
- if (!d->layout->usesHIToolBar(toolbar)) {
- d->layout->removeWidget(toolbar);
- } else {
- d->layout->removeToolBar(toolbar);
- }
+ d->layout->removeToolBar(toolbar);
toolbar->d_func()->_q_updateIconSize(d->iconSize);
toolbar->d_func()->_q_updateToolButtonStyle(d->toolButtonStyle);
@@ -984,7 +951,9 @@ void QMainWindow::setDockNestingEnabled(bool enabled)
}
#if 0
-/*! \property QMainWindow::verticalTabsEnabled
+// If added back in, add the '!' to the qdoc comment marker as well.
+/*
+ \property QMainWindow::verticalTabsEnabled
\brief whether left and right dock areas use vertical tabs
\since 4.2
@@ -1117,21 +1086,6 @@ void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget
}
d_func()->layout->removeWidget(dockwidget); // in case it was already in here
addDockWidget(area, dockwidget, orientation);
-
-#if 0 // Used to be included in Qt4 for Q_WS_MAC //drawer support
- QMacAutoReleasePool pool;
- extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp
- if (qt_mac_is_macdrawer(dockwidget)) {
- extern bool qt_mac_set_drawer_preferred_edge(QWidget *, Qt::DockWidgetArea); //qwidget_mac.cpp
- window()->createWinId();
- dockwidget->window()->createWinId();
- qt_mac_set_drawer_preferred_edge(dockwidget, area);
- if (dockwidget->isVisible()) {
- dockwidget->hide();
- dockwidget->show();
- }
- }
-#endif
}
/*!
@@ -1350,153 +1304,14 @@ bool QMainWindow::restoreState(const QByteArray &state, int version)
return restored;
}
-#if QT_CONFIG(dockwidget) && !defined(QT_NO_CURSOR)
-QCursor QMainWindowPrivate::separatorCursor(const QList<int> &path) const
-{
- QDockAreaLayoutInfo *info = layout->layoutState.dockAreaLayout.info(path);
- Q_ASSERT(info != 0);
- if (path.size() == 1) { // is this the "top-level" separator which separates a dock area
- // from the central widget?
- switch (path.first()) {
- case QInternal::LeftDock:
- case QInternal::RightDock:
- return Qt::SplitHCursor;
- case QInternal::TopDock:
- case QInternal::BottomDock:
- return Qt::SplitVCursor;
- default:
- break;
- }
- }
-
- // no, it's a splitter inside a dock area, separating two dock widgets
-
- return info->o == Qt::Horizontal
- ? Qt::SplitHCursor : Qt::SplitVCursor;
-}
-
-void QMainWindowPrivate::adjustCursor(const QPoint &pos)
-{
- Q_Q(QMainWindow);
-
- hoverPos = pos;
-
- if (pos == QPoint(0, 0)) {
- if (!hoverSeparator.isEmpty())
- q->update(layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator));
- hoverSeparator.clear();
-
- if (cursorAdjusted) {
- cursorAdjusted = false;
- if (hasOldCursor)
- q->setCursor(oldCursor);
- else
- q->unsetCursor();
- }
- } else if (layout->movingSeparator.isEmpty()) { // Don't change cursor when moving separator
- QList<int> pathToSeparator
- = layout->layoutState.dockAreaLayout.findSeparator(pos);
-
- if (pathToSeparator != hoverSeparator) {
- if (!hoverSeparator.isEmpty())
- q->update(layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator));
-
- hoverSeparator = pathToSeparator;
-
- if (hoverSeparator.isEmpty()) {
- if (cursorAdjusted) {
- cursorAdjusted = false;
- if (hasOldCursor)
- q->setCursor(oldCursor);
- else
- q->unsetCursor();
- }
- } else {
- q->update(layout->layoutState.dockAreaLayout.separatorRect(hoverSeparator));
- if (!cursorAdjusted) {
- oldCursor = q->cursor();
- hasOldCursor = q->testAttribute(Qt::WA_SetCursor);
- }
- adjustedCursor = separatorCursor(hoverSeparator);
- q->setCursor(adjustedCursor);
- cursorAdjusted = true;
- }
- }
- }
-}
-#endif
-
/*! \reimp */
bool QMainWindow::event(QEvent *event)
{
Q_D(QMainWindow);
+ if (d->layout && d->layout->windowEvent(event))
+ return true;
switch (event->type()) {
-#if QT_CONFIG(dockwidget)
- case QEvent::Paint: {
- QPainter p(this);
- QRegion r = static_cast<QPaintEvent*>(event)->region();
- d->layout->layoutState.dockAreaLayout.paintSeparators(&p, this, r, d->hoverPos);
- break;
- }
-
-#ifndef QT_NO_CURSOR
- case QEvent::HoverMove: {
- d->adjustCursor(static_cast<QHoverEvent*>(event)->pos());
- break;
- }
-
- // We don't want QWidget to call update() on the entire QMainWindow
- // on HoverEnter and HoverLeave, hence accept the event (return true).
- case QEvent::HoverEnter:
- return true;
- case QEvent::HoverLeave:
- d->adjustCursor(QPoint(0, 0));
- return true;
- case QEvent::ShortcutOverride: // when a menu pops up
- d->adjustCursor(QPoint(0, 0));
- break;
-#endif // QT_NO_CURSOR
-
- case QEvent::MouseButtonPress: {
- QMouseEvent *e = static_cast<QMouseEvent*>(event);
- if (e->button() == Qt::LeftButton && d->layout->startSeparatorMove(e->pos())) {
- // The click was on a separator, eat this event
- e->accept();
- return true;
- }
- break;
- }
-
- case QEvent::MouseMove: {
- QMouseEvent *e = static_cast<QMouseEvent*>(event);
-
-#ifndef QT_NO_CURSOR
- d->adjustCursor(e->pos());
-#endif
- if (e->buttons() & Qt::LeftButton) {
- if (d->layout->separatorMove(e->pos())) {
- // We're moving a separator, eat this event
- e->accept();
- return true;
- }
- }
-
- break;
- }
-
- case QEvent::MouseButtonRelease: {
- QMouseEvent *e = static_cast<QMouseEvent*>(event);
- if (d->layout->endSeparatorMove(e->pos())) {
- // We've released a separator, eat this event
- e->accept();
- return true;
- }
- break;
- }
-
-#endif
-
#ifndef QT_NO_TOOLBAR
case QEvent::ToolBarChange: {
d->layout->toggleToolBarsVisible();
@@ -1522,40 +1337,6 @@ bool QMainWindow::event(QEvent *event)
if (!d->explicitIconSize)
setIconSize(QSize());
break;
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
- case QEvent::Show:
- if (unifiedTitleAndToolBarOnMac())
- d->layout->syncUnifiedToolbarVisibility();
- d->layout->blockVisiblityCheck = false;
- break;
- case QEvent::WindowStateChange:
- {
- if (isHidden()) {
- // We are coming out of a minimize, leave things as is.
- d->layout->blockVisiblityCheck = true;
- }
- // We need to update the HIToolbar status when we go out of or into fullscreen.
- QWindowStateChangeEvent *wce = static_cast<QWindowStateChangeEvent *>(event);
- if ((windowState() & Qt::WindowFullScreen) || (wce->oldState() & Qt::WindowFullScreen)) {
- d->layout->updateHIToolBarStatus();
- }
- }
- break;
-#endif
-#if QT_CONFIG(dockwidget) && !defined(QT_NO_CURSOR)
- case QEvent::CursorChange:
- // CursorChange events are triggered as mouse moves to new widgets even
- // if the cursor doesn't actually change, so do not change oldCursor if
- // the "changed" cursor has same shape as adjusted cursor.
- if (d->cursorAdjusted && d->adjustedCursor.shape() != cursor().shape()) {
- d->oldCursor = cursor();
- d->hasOldCursor = testAttribute(Qt::WA_SetCursor);
-
- // Ensure our adjusted cursor stays visible
- setCursor(d->adjustedCursor);
- }
- break;
-#endif
default:
break;
}
@@ -1595,33 +1376,6 @@ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set)
(reinterpret_cast<SetContentBorderEnabledFunction>(function))(window()->windowHandle(), set);
update();
}
-#endif
-
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
- Q_D(QMainWindow);
- if (!isWindow() || d->useHIToolBar == set || QSysInfo::MacintoshVersion < QSysInfo::MV_10_3)
- return;
-
- d->useHIToolBar = set;
- createWinId(); // We need the hiview for down below.
-
- // Activate the unified toolbar with the raster engine.
- if (windowSurface() && set) {
- d->layout->unifiedSurface = new QUnifiedToolbarSurface(this);
- }
-
- d->layout->updateHIToolBarStatus();
-
- // Deactivate the unified toolbar with the raster engine.
- if (windowSurface() && !set) {
- if (d->layout->unifiedSurface) {
- delete d->layout->unifiedSurface;
- d->layout->unifiedSurface = 0;
- }
- }
-
- // Enabling the unified toolbar clears the opaque size grip setting, update it.
- d->macUpdateOpaqueSizeGrip();
#else
Q_UNUSED(set)
#endif
@@ -1632,9 +1386,6 @@ bool QMainWindow::unifiedTitleAndToolBarOnMac() const
#ifdef Q_OS_OSX
return d_func()->useUnifiedToolBar;
#endif
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
- return d_func()->useHIToolBar && !testAttribute(Qt::WA_MacBrushedMetal) && !(windowFlags() & Qt::FramelessWindowHint);
-#endif
return false;
}
diff --git a/src/widgets/widgets/qmainwindow.h b/src/widgets/widgets/qmainwindow.h
index 50d840cf61..069683d4ac 100644
--- a/src/widgets/widgets/qmainwindow.h
+++ b/src/widgets/widgets/qmainwindow.h
@@ -91,7 +91,7 @@ public:
Q_DECLARE_FLAGS(DockOptions, DockOption)
Q_FLAG(DockOptions)
- explicit QMainWindow(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
+ explicit QMainWindow(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
~QMainWindow();
QSize iconSize() const;
@@ -203,9 +203,9 @@ Q_SIGNALS:
protected:
#ifndef QT_NO_CONTEXTMENU
- void contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE;
+ void contextMenuEvent(QContextMenuEvent *event) override;
#endif
- bool event(QEvent *event) Q_DECL_OVERRIDE;
+ bool event(QEvent *event) override;
private:
Q_DECLARE_PRIVATE(QMainWindow)
diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index 91c012d8d8..9b38da340c 100644
--- a/src/widgets/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
@@ -77,10 +77,6 @@
#include <private/qapplication_p.h>
#include <private/qlayoutengine_p.h>
#include <private/qwidgetresizehandler_p.h>
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
-# include <private/qcore_mac_p.h>
-# include <private/qt_cocoa_helpers_mac_p.h>
-#endif
QT_BEGIN_NAMESPACE
@@ -184,13 +180,17 @@ QDebug operator<<(QDebug debug, const QMainWindowLayout *layout)
/******************************************************************************
** QDockWidgetGroupWindow
*/
-// QDockWidgetGroupWindow is the floating window containing the tabbed dockwidgets in case several
-// dockwidgets are dragged together (QMainWindow::GroupedDragging feature).
+// QDockWidgetGroupWindow is the floating window containing several QDockWidgets floating together.
+// (QMainWindow::GroupedDragging feature)
// QDockWidgetGroupLayout is the layout of that window and use a QDockAreaLayoutInfo to layout
-// the tabs inside it.
+// the QDockWidgets inside it.
+// If there is only one QDockWidgets, or all QDockWidgets are tabbed together, it is equivalent
+// of a floating QDockWidget (the title of the QDockWidget is the title of the window). But if there
+// are nested QDockWidget, an additional title bar is there.
#if QT_CONFIG(dockwidget)
-class QDockWidgetGroupLayout : public QLayout {
- QDockAreaLayoutInfo info;
+class QDockWidgetGroupLayout : public QLayout,
+ public QMainWindowLayoutSeparatorHelper<QDockWidgetGroupLayout>
+{
QWidgetResizeHandler *resizer;
public:
QDockWidgetGroupLayout(QDockWidgetGroupWindow* parent) : QLayout(parent) {
@@ -199,40 +199,51 @@ public:
resizer->setMovingEnabled(false);
}
~QDockWidgetGroupLayout() {
- info.deleteAllLayoutItems();
+ layoutState.deleteAllLayoutItems();
}
- void addItem(QLayoutItem*) Q_DECL_OVERRIDE { Q_UNREACHABLE(); }
- int count() const Q_DECL_OVERRIDE { return 0; }
- QLayoutItem* itemAt(int index) const Q_DECL_OVERRIDE
+ void addItem(QLayoutItem*) override { Q_UNREACHABLE(); }
+ int count() const override { return 0; }
+ QLayoutItem* itemAt(int index) const override
{
int x = 0;
- return info.itemAt(&x, index);
+ return layoutState.itemAt(&x, index);
}
- QLayoutItem* takeAt(int index) Q_DECL_OVERRIDE
+ QLayoutItem* takeAt(int index) override
{
int x = 0;
- return info.takeAt(&x, index);
+ QLayoutItem *ret = layoutState.takeAt(&x, index);
+ if (savedState.rect.isValid() && ret->widget()) {
+ // we need to remove the item also from the saved state to prevent crash
+ QList<int> path = savedState.indexOf(ret->widget());
+ if (!path.isEmpty())
+ savedState.remove(path);
+ // Also, the item may be contained several times as a gap item.
+ path = layoutState.indexOf(ret->widget());
+ if (!path.isEmpty())
+ layoutState.remove(path);
+ }
+ return ret;
}
- QSize sizeHint() const Q_DECL_OVERRIDE
+ QSize sizeHint() const override
{
int fw = frameWidth();
- return info.sizeHint() + QSize(fw, fw);
+ return layoutState.sizeHint() + QSize(fw, fw);
}
- QSize minimumSize() const Q_DECL_OVERRIDE
+ QSize minimumSize() const override
{
int fw = frameWidth();
- return info.minimumSize() + QSize(fw, fw);
+ return layoutState.minimumSize() + QSize(fw, fw);
}
- QSize maximumSize() const Q_DECL_OVERRIDE
+ QSize maximumSize() const override
{
int fw = frameWidth();
- return info.maximumSize() + QSize(fw, fw);
+ return layoutState.maximumSize() + QSize(fw, fw);
}
- void setGeometry(const QRect&r) Q_DECL_OVERRIDE
+ void setGeometry(const QRect&r) override
{
groupWindow()->destroyOrHideIfEmpty();
- QDockAreaLayoutInfo *li = layoutInfo();
+ QDockAreaLayoutInfo *li = dockAreaLayoutInfo();
if (li->isEmpty())
return;
int fw = frameWidth();
@@ -242,12 +253,12 @@ public:
li->rect = r.adjusted(fw, fw, -fw, -fw);
li->fitItems();
li->apply(false);
+ if (savedState.rect.isValid())
+ savedState.rect = li->rect;
resizer->setActive(QWidgetResizeHandler::Resize, !nativeWindowDeco());
}
- QDockAreaLayoutInfo *layoutInfo() {
- return &info;
- }
+ QDockAreaLayoutInfo *dockAreaLayoutInfo() { return &layoutState; }
bool nativeWindowDeco() const
{
@@ -264,14 +275,21 @@ public:
{
return static_cast<QDockWidgetGroupWindow *>(parent());
}
+
+ QDockAreaLayoutInfo layoutState;
+ QDockAreaLayoutInfo savedState;
};
bool QDockWidgetGroupWindow::event(QEvent *e)
{
+ auto lay = static_cast<QDockWidgetGroupLayout *>(layout());
+ if (lay && lay->windowEvent(e))
+ return true;
+
switch (e->type()) {
case QEvent::Close:
// Forward the close to the QDockWidget just as if its close button was pressed
- if (QDockWidget *dw = topDockWidget()) {
+ if (QDockWidget *dw = activeTabbedDockWidget()) {
e->ignore();
dw->close();
adjustFlags();
@@ -279,7 +297,7 @@ bool QDockWidgetGroupWindow::event(QEvent *e)
return true;
case QEvent::Move:
// Let QDockWidgetPrivate::moseEvent handle the dragging
- if (QDockWidget *dw = topDockWidget())
+ if (QDockWidget *dw = activeTabbedDockWidget())
static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(dw))->moveEvent(static_cast<QMoveEvent*>(e));
return true;
case QEvent::NonClientAreaMouseMove:
@@ -287,7 +305,7 @@ bool QDockWidgetGroupWindow::event(QEvent *e)
case QEvent::NonClientAreaMouseButtonRelease:
case QEvent::NonClientAreaMouseButtonDblClick:
// Let the QDockWidgetPrivate of the currently visible dock widget handle the drag and drop
- if (QDockWidget *dw = topDockWidget())
+ if (QDockWidget *dw = activeTabbedDockWidget())
static_cast<QDockWidgetPrivate *>(QObjectPrivate::get(dw))->nonClientAreaMouseEvent(static_cast<QMouseEvent*>(e));
return true;
case QEvent::ChildAdded:
@@ -319,17 +337,49 @@ void QDockWidgetGroupWindow::paintEvent(QPaintEvent *)
QDockAreaLayoutInfo *QDockWidgetGroupWindow::layoutInfo() const
{
- return static_cast<QDockWidgetGroupLayout*>(layout())->layoutInfo();
+ return static_cast<QDockWidgetGroupLayout *>(layout())->dockAreaLayoutInfo();
+}
+
+/*! \internal
+ If this is a floating tab bar returns the currently the QDockWidgetGroupWindow that contains
+ tab, otherwise, return nullptr;
+ \note: if there is only one QDockWidget, it's still considered as a floating tab
+ */
+const QDockAreaLayoutInfo *QDockWidgetGroupWindow::tabLayoutInfo() const
+{
+ const QDockAreaLayoutInfo *info = layoutInfo();
+ while (info && !info->tabbed) {
+ // There should be only one tabbed subinfo otherwise we are not a floating tab but a real
+ // window
+ const QDockAreaLayoutInfo *next = nullptr;
+ bool isSingle = false;
+ for (const auto &item : info->item_list) {
+ if (item.skip() || (item.flags & QDockAreaLayoutItem::GapItem))
+ continue;
+ if (next || isSingle) // Two visible things
+ return nullptr;
+ if (item.subinfo)
+ next = item.subinfo;
+ else if (item.widgetItem)
+ isSingle = true;
+ }
+ if (isSingle)
+ return info;
+ info = next;
+ }
+ return info;
}
/*! \internal
- Returns the currently active QDockWidget.
+ If this is a floating tab bar returns the currently active QDockWidget, otherwise nullptr
*/
-QDockWidget *QDockWidgetGroupWindow::topDockWidget() const
+QDockWidget *QDockWidgetGroupWindow::activeTabbedDockWidget() const
{
- QDockAreaLayoutInfo *info = layoutInfo();
- QDockWidget *dw = 0;
+ QDockWidget *dw = nullptr;
#if QT_CONFIG(tabbar)
+ const QDockAreaLayoutInfo *info = tabLayoutInfo();
+ if (!info)
+ return nullptr;
if (info->tabBar && info->tabBar->currentIndex() >= 0) {
int i = info->tabIndexToListIndex(info->tabBar->currentIndex());
if (i >= 0) {
@@ -338,7 +388,6 @@ QDockWidget *QDockWidgetGroupWindow::topDockWidget() const
dw = qobject_cast<QDockWidget *>(item.widgetItem->widget());
}
}
-#endif
if (!dw) {
for (int i = 0; !dw && i < info->item_list.count(); ++i) {
const QDockAreaLayoutItem &item = info->item_list.at(i);
@@ -349,6 +398,7 @@ QDockWidget *QDockWidgetGroupWindow::topDockWidget() const
dw = qobject_cast<QDockWidget *>(item.widgetItem->widget());
}
}
+#endif
return dw;
}
@@ -395,18 +445,18 @@ void QDockWidgetGroupWindow::destroyOrHideIfEmpty()
}
/*! \internal
- Sets the flags of this window in accordence to the capabilities of the dock widgets
+ Sets the flags of this window in accordance to the capabilities of the dock widgets
*/
void QDockWidgetGroupWindow::adjustFlags()
{
- QDockWidget *top = topDockWidget();
- if (!top)
- return;
- const bool nativeDeco = static_cast<QDockWidgetGroupLayout *>(layout())->nativeWindowDeco();
-
Qt::WindowFlags oldFlags = windowFlags();
Qt::WindowFlags flags = oldFlags;
- if (nativeDeco) {
+
+ QDockWidget *top = activeTabbedDockWidget();
+ if (!top) { // nested tabs, show window decoration
+ flags =
+ ((oldFlags & ~Qt::FramelessWindowHint) | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
+ } else if (static_cast<QDockWidgetGroupLayout *>(layout())->nativeWindowDeco()) {
flags |= Qt::CustomizeWindowHint | Qt::WindowTitleHint;
flags.setFlag(Qt::WindowCloseButtonHint, top->features() & QDockWidget::DockWidgetClosable);
flags &= ~Qt::FramelessWindowHint;
@@ -439,21 +489,99 @@ void QDockWidgetGroupWindow::adjustFlags()
show(); // setWindowFlags hides the window
}
- setWindowTitle(top->windowTitle());
- setWindowIcon(top->windowIcon());
+ QWidget *titleBarOf = top ? top : parentWidget();
+ setWindowTitle(titleBarOf->windowTitle());
+ setWindowIcon(titleBarOf->windowIcon());
}
bool QDockWidgetGroupWindow::hasNativeDecos() const
{
+ QDockWidget *dw = activeTabbedDockWidget();
+ if (!dw) // We have a group of nested QDockWidgets (not just floating tabs)
+ return true;
+
if (!QDockWidgetLayout::wmSupportsNativeWindowDeco())
return false;
- if (QDockWidget *dw = topDockWidget())
- return dw->titleBarWidget() == nullptr;
+ return dw->titleBarWidget() == nullptr;
+}
+/*
+ The given widget is hovered over this floating group.
+ This function will save the state and create a gap in the actual state.
+ currentGapRect and currentGapPos will be set.
+ One must call restore() or apply() after this function.
+ Returns true if there was any change in the currentGapPos
+ */
+bool QDockWidgetGroupWindow::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
+{
+ QDockAreaLayoutInfo &savedState = static_cast<QDockWidgetGroupLayout *>(layout())->savedState;
+ if (savedState.isEmpty())
+ savedState = *layoutInfo();
+
+ QMainWindow::DockOptions opts = static_cast<QMainWindow *>(parentWidget())->dockOptions();
+ bool nestingEnabled =
+ (opts & QMainWindow::AllowNestedDocks) && !(opts & QMainWindow::ForceTabbedDocks);
+ QDockAreaLayoutInfo::TabMode tabMode =
+ nestingEnabled ? QDockAreaLayoutInfo::AllowTabs : QDockAreaLayoutInfo::ForceTabs;
+ if (auto group = qobject_cast<QDockWidgetGroupWindow *>(widgetItem->widget())) {
+ if (!group->tabLayoutInfo())
+ tabMode = QDockAreaLayoutInfo::NoTabs;
+ }
+
+ QDockAreaLayoutInfo newState = savedState;
+ if (newState.tabbed) {
+ // insertion into a top-level tab
+ newState.item_list = { QDockAreaLayoutItem(new QDockAreaLayoutInfo(newState)) };
+ newState.item_list.first().size = pick(savedState.o, savedState.rect.size());
+ newState.tabbed = false;
+ newState.tabBar = nullptr;
+ }
+
+ auto newGapPos = newState.gapIndex(mousePos, nestingEnabled, tabMode);
+ Q_ASSERT(!newGapPos.isEmpty());
+ if (newGapPos == currentGapPos)
+ return false; // gap is already there
+ currentGapPos = newGapPos;
+ newState.insertGap(currentGapPos, widgetItem);
+ newState.fitItems();
+ currentGapRect = newState.info(currentGapPos)->itemRect(currentGapPos.last(), true);
+ *layoutInfo() = std::move(newState);
+ layoutInfo()->apply(opts & QMainWindow::AnimatedDocks);
return true;
}
+/*
+ Remove the gap that was created by hover()
+ */
+void QDockWidgetGroupWindow::restore()
+{
+ QDockAreaLayoutInfo &savedState = static_cast<QDockWidgetGroupLayout *>(layout())->savedState;
+ if (!savedState.isEmpty()) {
+ *layoutInfo() = savedState;
+ savedState = QDockAreaLayoutInfo();
+ }
+ currentGapRect = QRect();
+ currentGapPos.clear();
+ adjustFlags();
+ layoutInfo()->fitItems();
+ layoutInfo()->apply(static_cast<QMainWindow *>(parentWidget())->dockOptions()
+ & QMainWindow::AnimatedDocks);
+}
+
+/*
+ Apply the state that was created by hover
+ */
+void QDockWidgetGroupWindow::apply()
+{
+ static_cast<QDockWidgetGroupLayout *>(layout())->savedState.clear();
+ currentGapRect = QRect();
+ layoutInfo()->plug(currentGapPos);
+ currentGapPos.clear();
+ adjustFlags();
+ layoutInfo()->apply(false);
+}
+
#endif
/******************************************************************************
@@ -707,7 +835,14 @@ QList<int> QMainWindowLayoutState::gapIndex(QWidget *widget,
// is it a dock widget?
if (qobject_cast<QDockWidget *>(widget) != 0
|| qobject_cast<QDockWidgetGroupWindow *>(widget)) {
- result = dockAreaLayout.gapIndex(pos);
+ bool disallowTabs = false;
+#if QT_CONFIG(tabbar)
+ if (auto *group = qobject_cast<QDockWidgetGroupWindow *>(widget)) {
+ if (!group->tabLayoutInfo()) // Disallow to drop nested docks as a tab
+ disallowTabs = true;
+ }
+#endif
+ result = dockAreaLayout.gapIndex(pos, disallowTabs);
if (!result.isEmpty())
result.prepend(1);
return result;
@@ -1190,14 +1325,7 @@ void QMainWindowLayout::removeToolBar(QToolBar *toolbar)
QObject::disconnect(parentWidget(), SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)),
toolbar, SLOT(_q_updateToolButtonStyle(Qt::ToolButtonStyle)));
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
- if (usesHIToolBar(toolbar)) {
- removeFromMacToolbar(toolbar);
- } else
-#endif
- {
- removeWidget(toolbar);
- }
+ removeWidget(toolbar);
}
}
@@ -1209,25 +1337,17 @@ void QMainWindowLayout::addToolBar(Qt::ToolBarArea area,
bool)
{
validateToolBarArea(area);
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
- if ((area == Qt::TopToolBarArea)
- && layoutState.mainWindow->unifiedTitleAndToolBarOnMac()) {
- insertIntoMacToolbar(0, toolbar);
- } else
-#endif
- {
- //let's add the toolbar to the layout
- addChildWidget(toolbar);
- QLayoutItem * item = layoutState.toolBarAreaLayout.addToolBar(toDockPos(area), toolbar);
- if (savedState.isValid() && item) {
- // copy the toolbar also in the saved state
- savedState.toolBarAreaLayout.insertItem(toDockPos(area), item);
- }
- invalidate();
-
- //this ensures that the toolbar has the right window flags (not floating any more)
- toolbar->d_func()->updateWindowFlags(false /*floating*/);
+ // let's add the toolbar to the layout
+ addChildWidget(toolbar);
+ QLayoutItem *item = layoutState.toolBarAreaLayout.addToolBar(toDockPos(area), toolbar);
+ if (savedState.isValid() && item) {
+ // copy the toolbar also in the saved state
+ savedState.toolBarAreaLayout.insertItem(toDockPos(area), item);
}
+ invalidate();
+
+ // this ensures that the toolbar has the right window flags (not floating any more)
+ toolbar->d_func()->updateWindowFlags(false /*floating*/);
}
/*!
@@ -1235,27 +1355,20 @@ void QMainWindowLayout::addToolBar(Qt::ToolBarArea area,
*/
void QMainWindowLayout::insertToolBar(QToolBar *before, QToolBar *toolbar)
{
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
- if (usesHIToolBar(before)) {
- insertIntoMacToolbar(before, toolbar);
- } else
-#endif
- {
- addChildWidget(toolbar);
- QLayoutItem * item = layoutState.toolBarAreaLayout.insertToolBar(before, toolbar);
- if (savedState.isValid() && item) {
- // copy the toolbar also in the saved state
- savedState.toolBarAreaLayout.insertItem(before, item);
+ addChildWidget(toolbar);
+ QLayoutItem *item = layoutState.toolBarAreaLayout.insertToolBar(before, toolbar);
+ if (savedState.isValid() && item) {
+ // copy the toolbar also in the saved state
+ savedState.toolBarAreaLayout.insertItem(before, item);
+ }
+ if (!currentGapPos.isEmpty() && currentGapPos.constFirst() == 0) {
+ currentGapPos = layoutState.toolBarAreaLayout.currentGapIndex();
+ if (!currentGapPos.isEmpty()) {
+ currentGapPos.prepend(0);
+ currentGapRect = layoutState.itemRect(currentGapPos);
}
- if (!currentGapPos.isEmpty() && currentGapPos.constFirst() == 0) {
- currentGapPos = layoutState.toolBarAreaLayout.currentGapIndex();
- if (!currentGapPos.isEmpty()) {
- currentGapPos.prepend(0);
- currentGapRect = layoutState.itemRect(currentGapPos);
- }
- }
- invalidate();
}
+ invalidate();
}
Qt::ToolBarArea QMainWindowLayout::toolBarArea(QToolBar *toolbar) const
@@ -1268,12 +1381,6 @@ Qt::ToolBarArea QMainWindowLayout::toolBarArea(QToolBar *toolbar) const
case QInternal::BottomDock: return Qt::BottomToolBarArea;
default: break;
}
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
- if (pos == QInternal::DockCount) {
- if (qtoolbarsInUnifiedToolbarList.contains(toolbar))
- return Qt::TopToolBarArea;
- }
-#endif
return Qt::NoToolBarArea;
}
@@ -1290,70 +1397,15 @@ void QMainWindowLayout::getStyleOptionInfo(QStyleOptionToolBar *option, QToolBar
void QMainWindowLayout::toggleToolBarsVisible()
{
- bool updateNonUnifiedParts = true;
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
- if (layoutState.mainWindow->unifiedTitleAndToolBarOnMac()) {
- // If we hit this case, someone has pressed the "toolbar button" which will
- // toggle the unified toolbar visibility, because that's what the user wants.
- // We might be in a situation where someone has hidden all the toolbars
- // beforehand (maybe in construction), but now they've hit this button and
- // and are expecting the items to show. What do we do?
- // 1) Check the visibility of all the toolbars, if one is visible, do nothing, this
- // preserves what people would expect (these toolbars were visible when I clicked last time).
- // 2) If NONE are visible, then show them all. Again, this preserves the user expectation
- // of, "I want to see the toolbars." The user may get more toolbars than expected, but this
- // is better seeing nothing.
- // Don't worry about any of this if we are going invisible. This does mean we may get
- // into issues when switching into and out of fullscreen mode, but this is probably minor.
- // If we ever need to do hiding, that would have to be taken care of after the unified toolbar
- // has finished hiding.
- // People can of course handle the QEvent::ToolBarChange event themselves and do
- // WHATEVER they want if they don't like what we are doing (though the unified toolbar
- // will fire regardless).
-
- // Check if we REALLY need to update the geometry below. If we only have items in the
- // unified toolbar, all the docks will be empty, so there's very little point
- // in doing the geometry as Apple will do it (we also avoid flicker in Cocoa as well).
- // FWIW, layoutState.toolBarAreaLayout.visible and the state of the unified toolbar
- // visibility can get out of sync. I really don't think it's a big issue. It is kept
- // to a minimum because we only change the visibility if we absolutely must.
- // update the "non unified parts."
- updateNonUnifiedParts = !layoutState.toolBarAreaLayout.isEmpty();
-
- // We get this function before the unified toolbar does its thing.
- // So, the value will be opposite of what we expect.
- bool goingVisible = !macWindowToolbarIsVisible(qt_mac_window_for(layoutState.mainWindow));
- if (goingVisible) {
- const int ToolBarCount = qtoolbarsInUnifiedToolbarList.size();
- bool needAllVisible = true;
- for (int i = 0; i < ToolBarCount; ++i) {
- if (!qtoolbarsInUnifiedToolbarList.at(i)->isHidden()) {
- needAllVisible = false;
- break;
- }
- }
- if (needAllVisible) {
- QBoolBlocker blocker(blockVisiblityCheck); // Disable the visibilty check because
- // the toggle has already happened.
- for (int i = 0; i < ToolBarCount; ++i)
- qtoolbarsInUnifiedToolbarList.at(i)->setVisible(true);
- }
- }
- if (!updateNonUnifiedParts)
- layoutState.toolBarAreaLayout.visible = goingVisible;
- }
-#endif
- if (updateNonUnifiedParts) {
- layoutState.toolBarAreaLayout.visible = !layoutState.toolBarAreaLayout.visible;
- if (!layoutState.mainWindow->isMaximized()) {
- QPoint topLeft = parentWidget()->geometry().topLeft();
- QRect r = parentWidget()->geometry();
- r = layoutState.toolBarAreaLayout.rectHint(r);
- r.moveTo(topLeft);
- parentWidget()->setGeometry(r);
- } else {
- update();
- }
+ layoutState.toolBarAreaLayout.visible = !layoutState.toolBarAreaLayout.visible;
+ if (!layoutState.mainWindow->isMaximized()) {
+ QPoint topLeft = parentWidget()->geometry().topLeft();
+ QRect r = parentWidget()->geometry();
+ r = layoutState.toolBarAreaLayout.rectHint(r);
+ r.moveTo(topLeft);
+ parentWidget()->setGeometry(r);
+ } else {
+ update();
}
}
@@ -1606,9 +1658,9 @@ class QMainWindowTabBar : public QTabBar
public:
QMainWindowTabBar(QMainWindow *parent);
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent*) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent*) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
+ void mouseReleaseEvent(QMouseEvent*) override;
+ void mouseMoveEvent(QMouseEvent*) override;
};
@@ -1783,39 +1835,6 @@ void QMainWindowLayout::tabMoved(int from, int to)
}
#endif // QT_CONFIG(tabbar)
-bool QMainWindowLayout::startSeparatorMove(const QPoint &pos)
-{
- movingSeparator = layoutState.dockAreaLayout.findSeparator(pos);
-
- if (movingSeparator.isEmpty())
- return false;
-
- layoutState.dockAreaLayout.fallbackToSizeHints = false;
-
- savedState = layoutState;
- movingSeparatorPos = movingSeparatorOrigin = pos;
-
- return true;
-}
-
-bool QMainWindowLayout::separatorMove(const QPoint &pos)
-{
- if (movingSeparator.isEmpty())
- return false;
- movingSeparatorPos = pos;
- separatorMoveTimer.start(0, this);
- return true;
-}
-
-bool QMainWindowLayout::endSeparatorMove(const QPoint&)
-{
- if (movingSeparator.isEmpty())
- return false;
- movingSeparator.clear();
- savedState.clear();
- return true;
-}
-
void QMainWindowLayout::raise(QDockWidget *widget)
{
#if QT_CONFIG(tabbar)
@@ -1940,14 +1959,6 @@ QSize QMainWindowLayout::minimumSize() const
const QSize sbMin = statusbar ? statusbar->minimumSize() : QSize(0, 0);
minSize = QSize(qMax(sbMin.width(), minSize.width()),
sbMin.height() + minSize.height());
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
- const QSize storedSize = minSize;
- int minWidth = 0;
- foreach (QToolBar *toolbar, qtoolbarsInUnifiedToolbarList) {
- minWidth += toolbar->sizeHint().width() + 20;
- }
- minSize = QSize(qMax(minWidth, storedSize.width()), storedSize.height());
-#endif
}
return minSize;
}
@@ -1959,12 +1970,16 @@ void QMainWindowLayout::invalidate()
}
#if QT_CONFIG(dockwidget)
-void QMainWindowLayout::setCurrentHoveredFloat(QWidget *w)
+void QMainWindowLayout::setCurrentHoveredFloat(QDockWidgetGroupWindow *w)
{
if (currentHoveredFloat != w) {
if (currentHoveredFloat) {
disconnect(currentHoveredFloat.data(), &QObject::destroyed,
this, &QMainWindowLayout::updateGapIndicator);
+ if (currentHoveredFloat)
+ currentHoveredFloat->restore();
+ } else if (w) {
+ restore(true);
}
currentHoveredFloat = w;
@@ -2035,52 +2050,30 @@ void QMainWindowLayout::revert(QLayoutItem *widgetItem)
bool QMainWindowLayout::plug(QLayoutItem *widgetItem)
{
-#if QT_CONFIG(dockwidget)
+#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) && QT_CONFIG(tabbar)
if (currentHoveredFloat) {
QWidget *widget = widgetItem->widget();
QList<int> previousPath = layoutState.indexOf(widget);
if (!previousPath.isEmpty())
layoutState.remove(previousPath);
+ previousPath = currentHoveredFloat->layoutInfo()->indexOf(widget);
// Let's remove the widget from any possible group window
foreach (QDockWidgetGroupWindow *dwgw,
parent()->findChildren<QDockWidgetGroupWindow*>(QString(), Qt::FindDirectChildrenOnly)) {
+ if (dwgw == currentHoveredFloat)
+ continue;
QList<int> path = dwgw->layoutInfo()->indexOf(widget);
if (!path.isEmpty())
dwgw->layoutInfo()->remove(path);
}
currentGapRect = QRect();
-#if QT_CONFIG(tabwidget)
- if (QDockWidget *dropTo = qobject_cast<QDockWidget*>(currentHoveredFloat)) {
- //dropping to a normal widget, we mutate it in a QDockWidgetGroupWindow with two tabs
- QDockWidgetGroupWindow *floatingTabs = createTabbedDockWindow();
- floatingTabs->setGeometry(dropTo->geometry());
- QDockAreaLayoutInfo *info = floatingTabs->layoutInfo();
- *info = QDockAreaLayoutInfo(&layoutState.dockAreaLayout.sep, QInternal::LeftDock,
- Qt::Horizontal, QTabBar::RoundedSouth,
- static_cast<QMainWindow*>(parentWidget()));
- info->tabbed = true;
- QLayout *parentLayout = currentHoveredFloat->parentWidget()->layout();
- info->item_list.append(QDockAreaLayoutItem(parentLayout->takeAt(parentLayout->indexOf(currentHoveredFloat))));
-
- dropTo->setParent(floatingTabs);
- dropTo->show();
- dropTo->d_func()->plug(QRect());
- setCurrentHoveredFloat(floatingTabs);
- }
-#endif // QT_CONFIG(tabwidget)
-#if QT_CONFIG(tabbar)
- QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(currentHoveredFloat);
- Q_ASSERT(dwgw);
- Q_ASSERT(dwgw->layoutInfo()->tabbed); // because floating group should always be tabbed
- previousPath = dwgw->layoutInfo()->indexOf(widget);
+ currentHoveredFloat->apply();
if (!previousPath.isEmpty())
- dwgw->layoutInfo()->remove(previousPath);
- dwgw->layoutInfo()->tab(0, widgetItem);
- QRect globalRect = dwgw->layoutInfo()->tabContentRect();
- globalRect.moveTopLeft(dwgw->mapToGlobal(globalRect.topLeft()));
+ currentHoveredFloat->layoutInfo()->remove(previousPath);
+ QRect globalRect = currentHoveredFloat->currentGapRect;
+ globalRect.moveTopLeft(currentHoveredFloat->mapToGlobal(globalRect.topLeft()));
pluggingWidget = widget;
widgetAnimator.animate(widget, globalRect, dockOptions & QMainWindow::AnimatedDocks);
-#endif // QT_CONFIG(tabbar)
return true;
}
#endif
@@ -2149,57 +2142,55 @@ void QMainWindowLayout::animationFinished(QWidget *widget)
if (widget == pluggingWidget) {
#if QT_CONFIG(dockwidget)
+#if QT_CONFIG(tabbar)
if (QDockWidgetGroupWindow *dwgw = qobject_cast<QDockWidgetGroupWindow *>(widget)) {
// When the animated widget was a QDockWidgetGroupWindow, it means each of the
// embedded QDockWidget needs to be plugged back into the QMainWindow layout.
savedState.clear();
- QDockAreaLayoutInfo* info = dwgw->layoutInfo();
- QDockAreaLayoutInfo* parentInfo;
- QList<int> path;
-
- if (QDockWidgetGroupWindow *dropTo = qobject_cast<QDockWidgetGroupWindow *>(currentHoveredFloat)) {
- parentInfo = dropTo->layoutInfo();
-#if QT_CONFIG(tabbar)
- Q_ASSERT(parentInfo->tabbed);
-#endif
- path = parentInfo->indexOf(widget);
- Q_ASSERT(path.size() == 1);
+ QDockAreaLayoutInfo *srcInfo = dwgw->layoutInfo();
+ const QDockAreaLayoutInfo *srcTabInfo = dwgw->tabLayoutInfo();
+ QDockAreaLayoutInfo *dstParentInfo;
+ QList<int> dstPath;
+
+ if (currentHoveredFloat) {
+ dstPath = currentHoveredFloat->layoutInfo()->indexOf(widget);
+ Q_ASSERT(dstPath.size() >= 1);
+ dstParentInfo = currentHoveredFloat->layoutInfo()->info(dstPath);
} else {
- path = layoutState.dockAreaLayout.indexOf(widget);
- Q_ASSERT(path.size() >= 2);
- parentInfo = layoutState.dockAreaLayout.info(path);
- Q_ASSERT(parentInfo);
+ dstPath = layoutState.dockAreaLayout.indexOf(widget);
+ Q_ASSERT(dstPath.size() >= 2);
+ dstParentInfo = layoutState.dockAreaLayout.info(dstPath);
}
-#if QT_CONFIG(tabbar)
- if (parentInfo->tabbed) {
+ Q_ASSERT(dstParentInfo);
+ int idx = dstPath.constLast();
+ Q_ASSERT(dstParentInfo->item_list[idx].widgetItem->widget() == dwgw);
+ if (dstParentInfo->tabbed && srcTabInfo) {
// merge the two tab widgets
- int idx = path.constLast();
- Q_ASSERT(parentInfo->item_list[idx].widgetItem->widget() == dwgw);
- delete parentInfo->item_list[idx].widgetItem;
- parentInfo->item_list.removeAt(idx);
- std::copy(info->item_list.cbegin(), info->item_list.cend(),
- std::inserter(parentInfo->item_list, parentInfo->item_list.begin() + idx));
- quintptr currentId = info->currentTabId();
- *info = QDockAreaLayoutInfo();
- parentInfo->reparentWidgets(currentHoveredFloat ? currentHoveredFloat.data() : parentWidget());
- parentInfo->updateTabBar();
- parentInfo->setCurrentTabId(currentId);
- } else
-#endif // QT_CONFIG(tabbar)
- {
- QDockAreaLayoutItem &item = layoutState.dockAreaLayout.item(path);
+ delete dstParentInfo->item_list[idx].widgetItem;
+ dstParentInfo->item_list.removeAt(idx);
+ std::copy(srcTabInfo->item_list.cbegin(), srcTabInfo->item_list.cend(),
+ std::inserter(dstParentInfo->item_list,
+ dstParentInfo->item_list.begin() + idx));
+ quintptr currentId = srcTabInfo->currentTabId();
+ *srcInfo = QDockAreaLayoutInfo();
+ dstParentInfo->reparentWidgets(currentHoveredFloat ? currentHoveredFloat.data()
+ : parentWidget());
+ dstParentInfo->updateTabBar();
+ dstParentInfo->setCurrentTabId(currentId);
+ } else {
+ QDockAreaLayoutItem &item = dstParentInfo->item_list[idx];
Q_ASSERT(item.widgetItem->widget() == dwgw);
delete item.widgetItem;
item.widgetItem = 0;
- item.subinfo = new QDockAreaLayoutInfo(qMove(*info));
- *info = QDockAreaLayoutInfo();
-#if QT_CONFIG(tabbar)
- item.subinfo->reparentWidgets(parentWidget());
- item.subinfo->setTabBarShape(parentInfo->tabBarShape);
-#endif
+ item.subinfo = new QDockAreaLayoutInfo(std::move(*srcInfo));
+ *srcInfo = QDockAreaLayoutInfo();
+ item.subinfo->reparentWidgets(currentHoveredFloat ? currentHoveredFloat.data()
+ : parentWidget());
+ item.subinfo->setTabBarShape(dstParentInfo->tabBarShape);
}
dwgw->destroyOrHideIfEmpty();
}
+#endif
if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget)) {
dw->setParent(currentHoveredFloat ? currentHoveredFloat.data() : parentWidget());
@@ -2279,9 +2270,6 @@ QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLay
#endif // QT_CONFIG(dockwidget)
, widgetAnimator(this)
, pluggingWidget(0)
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
- , blockVisiblityCheck(false)
-#endif
{
if (parentLayout)
setParent(parentLayout);
@@ -2306,10 +2294,6 @@ QMainWindowLayout::~QMainWindowLayout()
layoutState.deleteAllLayoutItems();
layoutState.deleteCentralWidgetItem();
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
- cleanUpMacToolbarItems();
-#endif
-
delete statusbar;
}
@@ -2362,6 +2346,36 @@ void QMainWindowLayout::setCentralWidget(QWidget *widget)
invalidate();
}
+#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget)
+/*! \internal
+ This helper function is called by QMainWindowLayout::unplug if QMainWindow::GroupedDragging is
+ set and we are dragging the title bar of a non-floating QDockWidget.
+ If one should unplug the whole group, do so and return true, otherwise return false.
+ \a item is pointing to the QLayoutItem that holds the QDockWidget, but will be updated to the
+ QLayoutItem that holds the new QDockWidgetGroupWindow if the group is unplugged.
+*/
+static bool unplugGroup(QMainWindowLayout *layout, QLayoutItem **item,
+ QDockAreaLayoutItem &parentItem)
+{
+ if (!parentItem.subinfo || !parentItem.subinfo->tabbed)
+ return false;
+
+ // The QDockWidget is part of a group of tab and we need to unplug them all.
+
+ QDockWidgetGroupWindow *floatingTabs = layout->createTabbedDockWindow();
+ QDockAreaLayoutInfo *info = floatingTabs->layoutInfo();
+ *info = std::move(*parentItem.subinfo);
+ delete parentItem.subinfo;
+ parentItem.subinfo = nullptr;
+ floatingTabs->setGeometry(info->rect.translated(layout->parentWidget()->pos()));
+ floatingTabs->show();
+ floatingTabs->raise();
+ *item = new QDockWidgetGroupWindowItem(floatingTabs);
+ parentItem.widgetItem = *item;
+ return true;
+}
+#endif
+
/*! \internal
Unplug \a widget (QDockWidget or QToolBar) from it's parent container.
@@ -2375,19 +2389,31 @@ void QMainWindowLayout::setCentralWidget(QWidget *widget)
QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group)
{
#if QT_CONFIG(dockwidget) && QT_CONFIG(tabbar)
- if (!widget->isWindow() && qobject_cast<const QDockWidgetGroupWindow *>(widget->parentWidget())) {
- if (group) {
+ auto *groupWindow = qobject_cast<const QDockWidgetGroupWindow *>(widget->parentWidget());
+ if (!widget->isWindow() && groupWindow) {
+ if (group && groupWindow->tabLayoutInfo()) {
// We are just dragging a floating window as it, not need to do anything, we just have to
// look up the corresponding QWidgetItem* if it exists
- QList<int> tabbedWindowPath = layoutState.indexOf(widget->parentWidget());
- return tabbedWindowPath.isEmpty() ? 0 : layoutState.item(tabbedWindowPath);
+ if (QDockAreaLayoutInfo *info = dockInfo(widget->parentWidget())) {
+ QList<int> groupWindowPath = info->indexOf(widget->parentWidget());
+ return groupWindowPath.isEmpty() ? nullptr : info->item(groupWindowPath).widgetItem;
+ }
+ return nullptr;
+ }
+ QList<int> path = groupWindow->layoutInfo()->indexOf(widget);
+ QLayoutItem *item = groupWindow->layoutInfo()->item(path).widgetItem;
+ if (group && path.size() > 1
+ && unplugGroup(this, &item,
+ groupWindow->layoutInfo()->item(path.mid(0, path.size() - 1)))) {
+ return item;
} else {
// We are unplugging a dock widget from a floating window.
- if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget)) {
- dw->d_func()->unplug(widget->geometry());
- int index = widget->parentWidget()->layout()->indexOf(widget);
- return widget->parentWidget()->layout()->itemAt(index);
- }
+ QDockWidget *dw = qobject_cast<QDockWidget *>(widget);
+ Q_ASSERT(dw); // cannot be a QDockWidgetGroupWindow because it's not floating.
+ dw->d_func()->unplug(widget->geometry());
+ groupWindow->layoutInfo()->fitItems();
+ groupWindow->layoutInfo()->apply(dockOptions & QMainWindow::AnimatedDocks);
+ return item;
}
}
#endif
@@ -2405,30 +2431,15 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group)
#if QT_CONFIG(dockwidget)
if (QDockWidget *dw = qobject_cast<QDockWidget*>(widget)) {
Q_ASSERT(path.constFirst() == 1);
- bool actualGroup = false;
#if QT_CONFIG(tabwidget)
- if (group && (dockOptions & QMainWindow::GroupedDragging) && path.size() > 3) {
- QDockAreaLayoutItem &parentItem = layoutState.dockAreaLayout.item(path.mid(1, path.size() - 2));
- if (parentItem.subinfo && parentItem.subinfo->tabbed) {
- // The QDockWidget is part of a group of tab and we need to unplug them all.
- actualGroup = true;
- path.removeLast();
-
- QDockWidgetGroupWindow* floatingTabs = createTabbedDockWindow();
- QDockAreaLayoutInfo* info = floatingTabs->layoutInfo();
- *info = qMove(*parentItem.subinfo);
- delete parentItem.subinfo;
- parentItem.subinfo = 0;
- floatingTabs->setGeometry(info->rect.translated(parentWidget()->pos()));
- floatingTabs->show();
- floatingTabs->raise();
- item = new QDockWidgetGroupWindowItem(floatingTabs);
- parentItem.widgetItem = item;
- savedState = layoutState;
- }
- }
+ if (group && (dockOptions & QMainWindow::GroupedDragging) && path.size() > 3
+ && unplugGroup(this, &item,
+ layoutState.dockAreaLayout.item(path.mid(1, path.size() - 2)))) {
+ path.removeLast();
+ savedState = layoutState;
+ } else
#endif // QT_CONFIG(tabwidget)
- if (!actualGroup) {
+ {
dw->d_func()->unplug(r);
}
}
@@ -2457,11 +2468,11 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group)
void QMainWindowLayout::updateGapIndicator()
{
#if QT_CONFIG(rubberband)
- if ((!widgetAnimator.animating() && !currentGapPos.isEmpty())
+ if (!widgetAnimator.animating() && (!currentGapPos.isEmpty()
#if QT_CONFIG(dockwidget)
- || currentHoveredFloat
+ || currentHoveredFloat
#endif
- ) {
+ )) {
QWidget *expectedParent =
#if QT_CONFIG(dockwidget)
currentHoveredFloat ? currentHoveredFloat.data() :
@@ -2474,11 +2485,13 @@ void QMainWindowLayout::updateGapIndicator()
} else if (gapIndicator->parent() != expectedParent) {
gapIndicator->setParent(expectedParent);
}
- gapIndicator->setGeometry(
+
#if QT_CONFIG(dockwidget)
- currentHoveredFloat ? currentHoveredFloat->rect() :
+ if (currentHoveredFloat)
+ gapIndicator->setGeometry(currentHoveredFloat->currentGapRect);
+ else
#endif
- currentGapRect);
+ gapIndicator->setGeometry(currentGapRect);
gapIndicator->show();
gapIndicator->raise();
} else if (gapIndicator) {
@@ -2527,12 +2540,36 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
if (!w->geometry().contains(mousePos))
continue;
- setCurrentHoveredFloat(w);
- restore(true);
+ if (auto dropTo = qobject_cast<QDockWidget *>(w)) {
+ // dropping to a normal widget, we mutate it in a QDockWidgetGroupWindow with two
+ // tabs
+ QDockWidgetGroupWindow *floatingTabs = createTabbedDockWindow(); // FIXME
+ floatingTabs->setGeometry(dropTo->geometry());
+ QDockAreaLayoutInfo *info = floatingTabs->layoutInfo();
+ *info = QDockAreaLayoutInfo(&layoutState.dockAreaLayout.sep, QInternal::LeftDock,
+ Qt::Horizontal, QTabBar::RoundedSouth,
+ static_cast<QMainWindow *>(parentWidget()));
+ info->tabbed = true;
+ QLayout *parentLayout = dropTo->parentWidget()->layout();
+ info->item_list.append(
+ QDockAreaLayoutItem(parentLayout->takeAt(parentLayout->indexOf(dropTo))));
+
+ dropTo->setParent(floatingTabs);
+ dropTo->show();
+ dropTo->d_func()->plug(QRect());
+ w = floatingTabs;
+ }
+ Q_ASSERT(qobject_cast<QDockWidgetGroupWindow *>(w));
+ auto group = static_cast<QDockWidgetGroupWindow *>(w);
+ if (group->hover(widgetItem, group->mapFromGlobal(mousePos))) {
+ setCurrentHoveredFloat(group);
+ applyState(layoutState); // update the tabbars
+ }
return;
}
}
setCurrentHoveredFloat(nullptr);
+ layoutState.dockAreaLayout.fallbackToSizeHints = false;
#endif // QT_CONFIG(dockwidget)
QPoint pos = parentWidget()->mapFromGlobal(mousePos);
@@ -2595,7 +2632,7 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos)
#if QT_CONFIG(dockwidget)
parentWidget()->update(layoutState.dockAreaLayout.separatorRegion());
#endif
- layoutState = newState;
+ layoutState = std::move(newState);
applyState(layoutState);
updateGapIndicator();
@@ -2684,45 +2721,6 @@ bool QMainWindowLayout::restoreState(QDataStream &stream)
return true;
}
-
-// Returns if this toolbar *should* be using HIToolbar. Won't work for all in between cases
-// for example, you have a toolbar in the top area and then you suddenly turn on
-// HIToolbar.
-bool QMainWindowLayout::usesHIToolBar(QToolBar *toolbar) const
-{
-#if 1 // Used to be excluded in Qt4 for Q_WS_MAC
- Q_UNUSED(toolbar);
- return false;
-#else
- return qtoolbarsInUnifiedToolbarList.contains(toolbar)
- || ((toolBarArea(toolbar) == Qt::TopToolBarArea)
- && layoutState.mainWindow->unifiedTitleAndToolBarOnMac());
-#endif
-}
-
-void QMainWindowLayout::timerEvent(QTimerEvent *e)
-{
-#if QT_CONFIG(dockwidget)
- if (e->timerId() == separatorMoveTimer.timerId()) {
- //let's move the separators
- separatorMoveTimer.stop();
- if (movingSeparator.isEmpty())
- return;
- if (movingSeparatorOrigin == movingSeparatorPos)
- return;
-
- //when moving the separator, we need to update the previous position
- parentWidget()->update(layoutState.dockAreaLayout.separatorRegion());
-
- layoutState = savedState;
- layoutState.dockAreaLayout.separatorMove(movingSeparator, movingSeparatorOrigin,
- movingSeparatorPos);
- movingSeparatorPos = movingSeparatorOrigin;
- }
-#endif
- QLayout::timerEvent(e);
-}
-
QT_END_NAMESPACE
#include "moc_qmainwindowlayout_p.cpp"
diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h
index 615035d2fe..168d4444b9 100644
--- a/src/widgets/widgets/qmainwindowlayout_p.h
+++ b/src/widgets/widgets/qmainwindowlayout_p.h
@@ -57,6 +57,8 @@
#include "QtWidgets/qlayout.h"
#if QT_CONFIG(tabbar)
#include "QtWidgets/qtabbar.h"
+#include "QtGui/qpainter.h"
+#include "QtGui/qevent.h"
#endif
#include "QtCore/qvector.h"
#include "QtCore/qset.h"
@@ -76,6 +78,251 @@ QT_BEGIN_NAMESPACE
class QToolBar;
class QRubberBand;
+template <typename Layout> // Make use of the "Curiously recurring template pattern"
+class QMainWindowLayoutSeparatorHelper
+{
+ Layout *layout() { return static_cast<Layout *>(this); }
+ const Layout *layout() const { return static_cast<const Layout *>(this); }
+ QWidget *window() { return layout()->parentWidget(); }
+
+public:
+ QList<int> hoverSeparator;
+ QPoint hoverPos;
+
+#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR)
+ QCursor separatorCursor(const QList<int> &path);
+ void adjustCursor(const QPoint &pos);
+ QCursor oldCursor;
+ QCursor adjustedCursor;
+ bool hasOldCursor = false;
+ bool cursorAdjusted = false;
+
+ QList<int> movingSeparator;
+ QPoint movingSeparatorOrigin, movingSeparatorPos;
+ QBasicTimer separatorMoveTimer;
+
+ bool startSeparatorMove(const QPoint &pos);
+ bool separatorMove(const QPoint &pos);
+ bool endSeparatorMove(const QPoint &pos);
+
+#endif
+
+ bool windowEvent(QEvent *e);
+};
+
+#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR)
+template <typename Layout>
+QCursor QMainWindowLayoutSeparatorHelper<Layout>::separatorCursor(const QList<int> &path)
+{
+ const QDockAreaLayoutInfo *info = layout()->dockAreaLayoutInfo()->info(path);
+ Q_ASSERT(info != 0);
+ if (path.size() == 1) { // is this the "top-level" separator which separates a dock area
+ // from the central widget?
+ switch (path.first()) {
+ case QInternal::LeftDock:
+ case QInternal::RightDock:
+ return Qt::SplitHCursor;
+ case QInternal::TopDock:
+ case QInternal::BottomDock:
+ return Qt::SplitVCursor;
+ default:
+ break;
+ }
+ }
+
+ // no, it's a splitter inside a dock area, separating two dock widgets
+
+ return info->o == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor;
+}
+
+template <typename Layout>
+void QMainWindowLayoutSeparatorHelper<Layout>::adjustCursor(const QPoint &pos)
+{
+ QWidget *w = layout()->window();
+ hoverPos = pos;
+
+ if (pos == QPoint(0, 0)) {
+ if (!hoverSeparator.isEmpty())
+ w->update(layout()->dockAreaLayoutInfo()->separatorRect(hoverSeparator));
+ hoverSeparator.clear();
+
+ if (cursorAdjusted) {
+ cursorAdjusted = false;
+ if (hasOldCursor)
+ w->setCursor(oldCursor);
+ else
+ w->unsetCursor();
+ }
+ } else if (movingSeparator.isEmpty()) { // Don't change cursor when moving separator
+ QList<int> pathToSeparator = layout()->dockAreaLayoutInfo()->findSeparator(pos);
+
+ if (pathToSeparator != hoverSeparator) {
+ if (!hoverSeparator.isEmpty())
+ w->update(layout()->dockAreaLayoutInfo()->separatorRect(hoverSeparator));
+
+ hoverSeparator = pathToSeparator;
+
+ if (hoverSeparator.isEmpty()) {
+ if (cursorAdjusted) {
+ cursorAdjusted = false;
+ if (hasOldCursor)
+ w->setCursor(oldCursor);
+ else
+ w->unsetCursor();
+ }
+ } else {
+ w->update(layout()->dockAreaLayoutInfo()->separatorRect(hoverSeparator));
+ if (!cursorAdjusted) {
+ oldCursor = w->cursor();
+ hasOldCursor = w->testAttribute(Qt::WA_SetCursor);
+ }
+ adjustedCursor = separatorCursor(hoverSeparator);
+ w->setCursor(adjustedCursor);
+ cursorAdjusted = true;
+ }
+ }
+ }
+}
+
+template <typename Layout>
+bool QMainWindowLayoutSeparatorHelper<Layout>::windowEvent(QEvent *event)
+{
+ QWidget *w = window();
+ switch (event->type()) {
+ case QEvent::Paint: {
+ QPainter p(w);
+ QRegion r = static_cast<QPaintEvent *>(event)->region();
+ layout()->dockAreaLayoutInfo()->paintSeparators(&p, w, r, hoverPos);
+ break;
+ }
+
+#ifndef QT_NO_CURSOR
+ case QEvent::HoverMove: {
+ adjustCursor(static_cast<QHoverEvent *>(event)->pos());
+ break;
+ }
+
+ // We don't want QWidget to call update() on the entire QMainWindow
+ // on HoverEnter and HoverLeave, hence accept the event (return true).
+ case QEvent::HoverEnter:
+ return true;
+ case QEvent::HoverLeave:
+ adjustCursor(QPoint(0, 0));
+ return true;
+ case QEvent::ShortcutOverride: // when a menu pops up
+ adjustCursor(QPoint(0, 0));
+ break;
+#endif // QT_NO_CURSOR
+
+ case QEvent::MouseButtonPress: {
+ QMouseEvent *e = static_cast<QMouseEvent *>(event);
+ if (e->button() == Qt::LeftButton && startSeparatorMove(e->pos())) {
+ // The click was on a separator, eat this event
+ e->accept();
+ return true;
+ }
+ break;
+ }
+
+ case QEvent::MouseMove: {
+ QMouseEvent *e = static_cast<QMouseEvent *>(event);
+
+#ifndef QT_NO_CURSOR
+ adjustCursor(e->pos());
+#endif
+ if (e->buttons() & Qt::LeftButton) {
+ if (separatorMove(e->pos())) {
+ // We're moving a separator, eat this event
+ e->accept();
+ return true;
+ }
+ }
+
+ break;
+ }
+
+ case QEvent::MouseButtonRelease: {
+ QMouseEvent *e = static_cast<QMouseEvent *>(event);
+ if (endSeparatorMove(e->pos())) {
+ // We've released a separator, eat this event
+ e->accept();
+ return true;
+ }
+ break;
+ }
+
+#if !defined(QT_NO_CURSOR)
+ case QEvent::CursorChange:
+ // CursorChange events are triggered as mouse moves to new widgets even
+ // if the cursor doesn't actually change, so do not change oldCursor if
+ // the "changed" cursor has same shape as adjusted cursor.
+ if (cursorAdjusted && adjustedCursor.shape() != w->cursor().shape()) {
+ oldCursor = w->cursor();
+ hasOldCursor = w->testAttribute(Qt::WA_SetCursor);
+
+ // Ensure our adjusted cursor stays visible
+ w->setCursor(adjustedCursor);
+ }
+ break;
+#endif
+ case QEvent::Timer:
+ if (static_cast<QTimerEvent *>(event)->timerId() == separatorMoveTimer.timerId()) {
+ // let's move the separators
+ separatorMoveTimer.stop();
+ if (movingSeparator.isEmpty())
+ return true;
+ if (movingSeparatorOrigin == movingSeparatorPos)
+ return true;
+
+ // when moving the separator, we need to update the previous position
+ window()->update(layout()->dockAreaLayoutInfo()->separatorRegion());
+
+ layout()->layoutState = layout()->savedState;
+ layout()->dockAreaLayoutInfo()->separatorMove(movingSeparator, movingSeparatorOrigin,
+ movingSeparatorPos);
+ movingSeparatorPos = movingSeparatorOrigin;
+ return true;
+ }
+ break;
+ default:
+ break;
+ }
+ return false;
+}
+
+template <typename Layout>
+bool QMainWindowLayoutSeparatorHelper<Layout>::startSeparatorMove(const QPoint &pos)
+{
+ movingSeparator = layout()->dockAreaLayoutInfo()->findSeparator(pos);
+
+ if (movingSeparator.isEmpty())
+ return false;
+
+ layout()->savedState = layout()->layoutState;
+ movingSeparatorPos = movingSeparatorOrigin = pos;
+
+ return true;
+}
+template <typename Layout>
+bool QMainWindowLayoutSeparatorHelper<Layout>::separatorMove(const QPoint &pos)
+{
+ if (movingSeparator.isEmpty())
+ return false;
+ movingSeparatorPos = pos;
+ separatorMoveTimer.start(0, window());
+ return true;
+}
+template <typename Layout>
+bool QMainWindowLayoutSeparatorHelper<Layout>::endSeparatorMove(const QPoint &)
+{
+ if (movingSeparator.isEmpty())
+ return false;
+ movingSeparator.clear();
+ layout()->savedState.clear();
+ return true;
+}
+#endif
+
#if QT_CONFIG(dockwidget)
class QDockWidgetGroupWindow : public QWidget
{
@@ -84,14 +331,22 @@ public:
explicit QDockWidgetGroupWindow(QWidget* parent = 0, Qt::WindowFlags f = 0)
: QWidget(parent, f) {}
QDockAreaLayoutInfo *layoutInfo() const;
- QDockWidget *topDockWidget() const;
+ const QDockAreaLayoutInfo *tabLayoutInfo() const;
+ QDockWidget *activeTabbedDockWidget() const;
void destroyOrHideIfEmpty();
void adjustFlags();
bool hasNativeDecos() const;
+ bool hover(QLayoutItem *widgetItem, const QPoint &mousePos);
+ void restore();
+ void apply();
+
+ QRect currentGapRect;
+ QList<int> currentGapPos;
+
protected:
- bool event(QEvent *) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE;
+ bool event(QEvent *) override;
+ void paintEvent(QPaintEvent*) override;
private:
QSize m_removedFrameSize;
@@ -103,9 +358,9 @@ class QDockWidgetGroupWindowItem : public QWidgetItem
{
public:
explicit QDockWidgetGroupWindowItem(QDockWidgetGroupWindow *parent) : QWidgetItem(parent) {}
- QSize minimumSize() const Q_DECL_OVERRIDE { return lay()->minimumSize(); }
- QSize maximumSize() const Q_DECL_OVERRIDE { return lay()->maximumSize(); }
- QSize sizeHint() const Q_DECL_OVERRIDE { return lay()->sizeHint(); }
+ QSize minimumSize() const override { return lay()->minimumSize(); }
+ QSize maximumSize() const override { return lay()->maximumSize(); }
+ QSize sizeHint() const override { return lay()->sizeHint(); }
private:
QLayout *lay() const { return const_cast<QDockWidgetGroupWindowItem *>(this)->widget()->layout(); }
@@ -172,7 +427,9 @@ public:
bool restoreState(QDataStream &stream, const QMainWindowLayoutState &oldState);
};
-class Q_AUTOTEST_EXPORT QMainWindowLayout : public QLayout
+class Q_AUTOTEST_EXPORT QMainWindowLayout
+ : public QLayout,
+ public QMainWindowLayoutSeparatorHelper<QMainWindowLayout>
{
Q_OBJECT
@@ -184,9 +441,6 @@ public:
QMainWindow::DockOptions dockOptions;
void setDockOptions(QMainWindow::DockOptions opts);
- bool usesHIToolBar(QToolBar *toolbar) const;
-
- void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE;
// status bar
@@ -265,15 +519,7 @@ public:
#endif // QT_CONFIG(tabwidget)
#endif // QT_CONFIG(tabbar)
- // separators
-
- QList<int> movingSeparator;
- QPoint movingSeparatorOrigin, movingSeparatorPos;
- QBasicTimer separatorMoveTimer;
-
- bool startSeparatorMove(const QPoint &pos);
- bool separatorMove(const QPoint &pos);
- bool endSeparatorMove(const QPoint &pos);
+ QDockAreaLayout *dockAreaLayoutInfo() { return &layoutState.dockAreaLayout; }
void keepSize(QDockWidget *w);
#endif // QT_CONFIG(dockwidget)
@@ -287,17 +533,17 @@ public:
// QLayout interface
- void addItem(QLayoutItem *item) Q_DECL_OVERRIDE;
- void setGeometry(const QRect &r) Q_DECL_OVERRIDE;
- QLayoutItem *itemAt(int index) const Q_DECL_OVERRIDE;
- QLayoutItem *takeAt(int index) Q_DECL_OVERRIDE;
- int count() const Q_DECL_OVERRIDE;
+ void addItem(QLayoutItem *item) override;
+ void setGeometry(const QRect &r) override;
+ QLayoutItem *itemAt(int index) const override;
+ QLayoutItem *takeAt(int index) override;
+ int count() const override;
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSize() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ QSize minimumSize() const override;
mutable QSize szHint;
mutable QSize minSize;
- void invalidate() Q_DECL_OVERRIDE;
+ void invalidate() override;
// animations
@@ -309,8 +555,8 @@ public:
QPointer<QRubberBand> gapIndicator;
#endif
#if QT_CONFIG(dockwidget)
- QPointer<QWidget> currentHoveredFloat; // set when dragging over a floating dock widget
- void setCurrentHoveredFloat(QWidget *w);
+ QPointer<QDockWidgetGroupWindow> currentHoveredFloat; // set when dragging over a floating dock widget
+ void setCurrentHoveredFloat(QDockWidgetGroupWindow *w);
#endif
void hover(QLayoutItem *widgetItem, const QPoint &mousePos);
@@ -320,7 +566,6 @@ public:
void paintDropIndicator(QPainter *p, QWidget *widget, const QRegion &clip);
void applyState(QMainWindowLayoutState &newState, bool animate = true);
void restore(bool keepSavedState = false);
- void updateHIToolBarStatus();
void animationFinished(QWidget *widget);
private Q_SLOTS:
@@ -335,40 +580,6 @@ private:
#if QT_CONFIG(tabbar)
void updateTabBarShapes();
#endif
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
- static OSStatus qtmacToolbarDelegate(EventHandlerCallRef, EventRef , void *);
- static OSStatus qtoolbarInHIToolbarHandler(EventHandlerCallRef inCallRef, EventRef event,
- void *data);
- static void qtMacHIToolbarRegisterQToolBarInHIToolborItemClass();
- static HIToolbarItemRef CreateToolbarItemForIdentifier(CFStringRef identifier, CFTypeRef data);
- static HIToolbarItemRef createQToolBarInHIToolbarItem(QToolBar *toolbar,
- QMainWindowLayout *layout);
-public:
- struct ToolBarSaveState {
- ToolBarSaveState() : movable(false) { }
- ToolBarSaveState(bool newMovable, const QSize &newMax)
- : movable(newMovable), maximumSize(newMax) { }
- bool movable;
- QSize maximumSize;
- };
- QList<QToolBar *> qtoolbarsInUnifiedToolbarList;
- QList<void *> toolbarItemsCopy;
- QHash<void *, QToolBar *> unifiedToolbarHash;
- QHash<QToolBar *, ToolBarSaveState> toolbarSaveState;
- QHash<QString, QToolBar *> cocoaItemIDToToolbarHash;
- void insertIntoMacToolbar(QToolBar *before, QToolBar *after);
- void removeFromMacToolbar(QToolBar *toolbar);
- void cleanUpMacToolbarItems();
- void fixSizeInUnifiedToolbar(QToolBar *tb) const;
- bool useHIToolBar;
- bool activateUnifiedToolbarAfterFullScreen;
- void syncUnifiedToolbarVisibility();
- bool blockVisiblityCheck;
-
- QUnifiedToolbarSurface *unifiedSurface;
- void updateUnifiedToolbarOffset();
-
-#endif
};
#if QT_CONFIG(dockwidget) && !defined(QT_NO_DEBUG_STREAM)
diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp
index c90d915f4c..45c01dec80 100644
--- a/src/widgets/widgets/qmdiarea.cpp
+++ b/src/widgets/widgets/qmdiarea.cpp
@@ -100,7 +100,7 @@
*/
/*!
- \fn QMdiArea::subWindowActivated(QMdiSubWindow *window)
+ \fn void QMdiArea::subWindowActivated(QMdiSubWindow *window)
QMdiArea emits this signal after \a window has been activated. When \a
window is 0, QMdiArea has just deactivated its last active window, and
@@ -158,9 +158,6 @@
#include <QApplication>
#include <QStyle>
-#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && QT_CONFIG(style_mac)
-#include <private/qmacstyle_mac_p.h>
-#endif
#include <QChildEvent>
#include <QResizeEvent>
#include <QScrollBar>
@@ -169,6 +166,7 @@
#include <QFontMetrics>
#include <QStyleOption>
#include <QDesktopWidget>
+#include <private/qdesktopwidget_p.h>
#include <QDebug>
#include <qmath.h>
#if QT_CONFIG(menu)
@@ -572,9 +570,9 @@ public:
QMdiAreaTabBar(QWidget *parent) : QTabBar(parent) {}
protected:
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
+ void mousePressEvent(QMouseEvent *event) override;
#ifndef QT_NO_CONTEXTMENU
- void contextMenuEvent(QContextMenuEvent *event) Q_DECL_OVERRIDE;
+ void contextMenuEvent(QContextMenuEvent *event) override;
#endif
private:
@@ -1750,7 +1748,7 @@ QSize QMdiArea::sizeHint() const
}
const int scaleFactor = 3 * (nestedCount + 1);
- QSize desktopSize = QApplication::desktop()->size();
+ QSize desktopSize = QDesktopWidgetPrivate::size();
QSize size(desktopSize.width() * 2 / scaleFactor, desktopSize.height() * 2 / scaleFactor);
for (QMdiSubWindow *child : d_func()->childWindows) {
if (!sanityCheck(child, "QMdiArea::sizeHint"))
@@ -2640,7 +2638,7 @@ bool QMdiArea::eventFilter(QObject *object, QEvent *event)
d->tabBar->setTabEnabled(tabIndex, true);
}
#endif // QT_CONFIG(tabbar)
- // fall through
+ Q_FALLTHROUGH();
case QEvent::Hide:
d->isSubWindowsTiled = false;
break;
diff --git a/src/widgets/widgets/qmdiarea.h b/src/widgets/widgets/qmdiarea.h
index 05deb9e21f..35edde9eb8 100644
--- a/src/widgets/widgets/qmdiarea.h
+++ b/src/widgets/widgets/qmdiarea.h
@@ -87,11 +87,11 @@ public:
};
Q_ENUM(ViewMode)
- QMdiArea(QWidget *parent = Q_NULLPTR);
+ QMdiArea(QWidget *parent = nullptr);
~QMdiArea();
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ QSize minimumSizeHint() const override;
QMdiSubWindow *currentSubWindow() const;
QMdiSubWindow *activeSubWindow() const;
@@ -143,18 +143,18 @@ public Q_SLOTS:
void activatePreviousSubWindow();
protected Q_SLOTS:
- void setupViewport(QWidget *viewport) Q_DECL_OVERRIDE;
+ void setupViewport(QWidget *viewport) override;
protected:
- bool event(QEvent *event) Q_DECL_OVERRIDE;
- bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *paintEvent) Q_DECL_OVERRIDE;
- void childEvent(QChildEvent *childEvent) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *resizeEvent) Q_DECL_OVERRIDE;
- void timerEvent(QTimerEvent *timerEvent) Q_DECL_OVERRIDE;
- void showEvent(QShowEvent *showEvent) Q_DECL_OVERRIDE;
- bool viewportEvent(QEvent *event) Q_DECL_OVERRIDE;
- void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE;
+ bool event(QEvent *event) override;
+ bool eventFilter(QObject *object, QEvent *event) override;
+ void paintEvent(QPaintEvent *paintEvent) override;
+ void childEvent(QChildEvent *childEvent) override;
+ void resizeEvent(QResizeEvent *resizeEvent) override;
+ void timerEvent(QTimerEvent *timerEvent) override;
+ void showEvent(QShowEvent *showEvent) override;
+ bool viewportEvent(QEvent *event) override;
+ void scrollContentsBy(int dx, int dy) override;
private:
Q_DISABLE_COPY(QMdiArea)
diff --git a/src/widgets/widgets/qmdiarea_p.h b/src/widgets/widgets/qmdiarea_p.h
index 4740993af7..fd00118ec6 100644
--- a/src/widgets/widgets/qmdiarea_p.h
+++ b/src/widgets/widgets/qmdiarea_p.h
@@ -88,8 +88,8 @@ class RegularTiler : public Rearranger
// Rearranges widgets according to a regular tiling pattern
// covering the entire domain.
// Both positions and sizes may change.
- void rearrange(QList<QWidget *> &widgets, const QRect &domain) const Q_DECL_OVERRIDE;
- Type type() const Q_DECL_OVERRIDE { return Rearranger::RegularTiler; }
+ void rearrange(QList<QWidget *> &widgets, const QRect &domain) const override;
+ Type type() const override { return Rearranger::RegularTiler; }
};
class SimpleCascader : public Rearranger
@@ -97,8 +97,8 @@ class SimpleCascader : public Rearranger
// Rearranges widgets according to a simple, regular cascading pattern.
// Widgets are resized to minimumSize.
// Both positions and sizes may change.
- void rearrange(QList<QWidget *> &widgets, const QRect &domain) const Q_DECL_OVERRIDE;
- Type type() const Q_DECL_OVERRIDE { return Rearranger::SimpleCascader; }
+ void rearrange(QList<QWidget *> &widgets, const QRect &domain) const override;
+ Type type() const override { return Rearranger::SimpleCascader; }
};
class IconTiler : public Rearranger
@@ -106,8 +106,8 @@ class IconTiler : public Rearranger
// Rearranges icons (assumed to be the same size) according to a regular
// tiling pattern filling up the domain from the bottom.
// Only positions may change.
- void rearrange(QList<QWidget *> &widgets, const QRect &domain) const Q_DECL_OVERRIDE;
- Type type() const Q_DECL_OVERRIDE { return Rearranger::IconTiler; }
+ void rearrange(QList<QWidget *> &widgets, const QRect &domain) const override;
+ Type type() const override { return Rearranger::IconTiler; }
};
class Placer
@@ -122,7 +122,7 @@ public:
class MinOverlapPlacer : public Placer
{
- QPoint place(const QSize &size, const QVector<QRect> &rects, const QRect &domain) const Q_DECL_OVERRIDE;
+ QPoint place(const QSize &size, const QVector<QRect> &rects, const QRect &domain) const override;
static int accumulatedOverlap(const QRect &source, const QVector<QRect> &rects);
static QRect findMinOverlapRect(const QVector<QRect> &source, const QVector<QRect> &rects);
static QVector<QRect> getCandidatePlacements(const QSize &size, const QVector<QRect> &rects, const QRect &domain);
@@ -206,7 +206,7 @@ public:
bool lastWindowAboutToBeDestroyed() const;
void setChildActivationEnabled(bool enable = true, bool onlyNextActivationEvent = false) const;
QRect resizeToMinimumTileSize(const QSize &minSubWindowSize, int subWindowCount);
- void scrollBarPolicyChanged(Qt::Orientation, Qt::ScrollBarPolicy) Q_DECL_OVERRIDE; // reimp
+ void scrollBarPolicyChanged(Qt::Orientation, Qt::ScrollBarPolicy) override; // reimp
QMdiSubWindow *nextVisibleSubWindow(int increaseFactor, QMdiArea::WindowOrder,
int removed = -1, int fromIndex = -1) const;
void highlightNextSubWindow(int increaseFactor);
diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp
index 2e6c82f95a..794674c427 100644
--- a/src/widgets/widgets/qmdisubwindow.cpp
+++ b/src/widgets/widgets/qmdisubwindow.cpp
@@ -160,9 +160,6 @@
#endif
#include <QScrollBar>
#include <QDebug>
-#if QT_CONFIG(style_mac)
-#include <private/qmacstyle_mac_p.h>
-#endif
#include <QMdiArea>
#include <QScopedValueRollback>
#include <QAction>
@@ -200,6 +197,11 @@ static const Qt::WindowFlags CustomizeWindowFlags =
static const int BoundaryMargin = 5;
+static inline bool isMacStyle(QStyle *style)
+{
+ return style->inherits("QMacStyle");
+}
+
static inline int getMoveDeltaComponent(uint cflags, uint moveFlag, uint resizeFlag,
int delta, int maxDelta, int minDelta)
{
@@ -301,11 +303,8 @@ static void showToolTip(QHelpEvent *helpEvent, QWidget *widget, const QStyleOpti
Q_ASSERT(helpEvent->type() == QEvent::ToolTip);
Q_ASSERT(widget);
-#if QT_CONFIG(style_mac)
- // Native Mac windows don't show tool tip.
- if (qobject_cast<QMacStyle *>(widget->style()))
+ if (widget->style()->styleHint(QStyle::SH_TitleBar_ShowToolTipsOnButtons, &opt, widget))
return;
-#endif
// Convert CC_MdiControls to CC_TitleBar. Sub controls of different complex
// controls cannot be in the same switch as they might have the same value.
@@ -374,18 +373,18 @@ class ControlLabel : public QWidget
public:
ControlLabel(QMdiSubWindow *subWindow, QWidget *parent = 0);
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
signals:
void _q_clicked();
void _q_doubleClicked();
protected:
- bool event(QEvent *event) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *paintEvent) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE;
- void mouseDoubleClickEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE;
+ bool event(QEvent *event) override;
+ void paintEvent(QPaintEvent *paintEvent) override;
+ void mousePressEvent(QMouseEvent *mouseEvent) override;
+ void mouseDoubleClickEvent(QMouseEvent *mouseEvent) override;
+ void mouseReleaseEvent(QMouseEvent *mouseEvent) override;
private:
QPixmap label;
@@ -505,7 +504,7 @@ class ControllerWidget : public QWidget
Q_OBJECT
public:
ControllerWidget(QMdiSubWindow *subWindow, QWidget *parent = 0);
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
void setControlVisible(QMdiSubWindowPrivate::WindowStateAction action, bool visible);
inline bool hasVisibleControls() const
{
@@ -520,12 +519,12 @@ signals:
void _q_close();
protected:
- void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
- void leaveEvent(QEvent *event) Q_DECL_OVERRIDE;
- bool event(QEvent *event) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent *event) override;
+ void mousePressEvent(QMouseEvent *event) override;
+ void mouseReleaseEvent(QMouseEvent *event) override;
+ void mouseMoveEvent(QMouseEvent *event) override;
+ void leaveEvent(QEvent *event) override;
+ bool event(QEvent *event) override;
private:
QStyle::SubControl activeControl;
@@ -1082,10 +1081,8 @@ void QMdiSubWindowPrivate::updateCursor()
{
#ifndef QT_NO_CURSOR
Q_Q(QMdiSubWindow);
-#if QT_CONFIG(style_mac)
- if (qobject_cast<QMacStyle *>(q->style()))
+ if (isMacStyle(q->style()))
return;
-#endif
if (currentOperation == None) {
q->unsetCursor();
@@ -1510,15 +1507,14 @@ void QMdiSubWindowPrivate::processClickedSubControl()
q->showNormal();
break;
case QStyle::SC_TitleBarMinButton:
-#if QT_CONFIG(style_mac)
- if (qobject_cast<QMacStyle *>(q->style())) {
+ if (isMacStyle(q->style())) {
if (q->isMinimized())
q->showNormal();
else
q->showMinimized();
break;
}
-#endif
+
q->showMinimized();
break;
case QStyle::SC_TitleBarNormalButton:
@@ -1527,15 +1523,14 @@ void QMdiSubWindowPrivate::processClickedSubControl()
q->showNormal();
break;
case QStyle::SC_TitleBarMaxButton:
-#if QT_CONFIG(style_mac)
- if (qobject_cast<QMacStyle *>(q->style())) {
+ if (isMacStyle(q->style())) {
if (q->isMaximized())
q->showNormal();
else
q->showMaximized();
break;
}
-#endif
+
q->showMaximized();
break;
case QStyle::SC_TitleBarCloseButton:
@@ -1574,10 +1569,8 @@ QRegion QMdiSubWindowPrivate::getRegion(Operation operation) const
}
QRegion region;
-#if QT_CONFIG(style_mac)
- if (qobject_cast<QMacStyle *>(q->style()))
+ if (isMacStyle(q->style()))
return region;
-#endif
switch (operation) {
case TopResize:
@@ -1781,10 +1774,6 @@ bool QMdiSubWindowPrivate::drawTitleBarWhenMaximized() const
if (isChildOfTabbedQMdiArea(q))
return false;
-#if QT_CONFIG(style_mac)
- Q_UNUSED(isChildOfQMdiSubWindow);
- return true;
-#else
if (q->style()->styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, 0, q))
return true;
#if !QT_CONFIG(menubar) || !QT_CONFIG(mainwindow)
@@ -1798,7 +1787,6 @@ bool QMdiSubWindowPrivate::drawTitleBarWhenMaximized() const
return isChildOfQMdiSubWindow(q);
#endif
-#endif
}
#if QT_CONFIG(menubar)
@@ -1998,6 +1986,13 @@ void QMdiSubWindowPrivate::updateActions()
for (int i = 0; i < NumWindowStateActions; ++i)
setVisible(WindowStateAction(i), false);
+#ifdef Q_OS_MACOS
+ if (q_func()->style()->inherits("QMacStyle"))
+ for (int i = 0; i < NumWindowStateActions; ++i)
+ if (QAction *action = actions[i])
+ action->setIconVisibleInMenu(false);
+#endif
+
if (windowFlags & Qt::FramelessWindowHint)
return;
@@ -2197,10 +2192,8 @@ void QMdiSubWindowPrivate::setSizeGrip(QSizeGrip *newSizeGrip)
return;
newSizeGrip->setFixedSize(newSizeGrip->sizeHint());
bool putSizeGripInLayout = layout ? true : false;
-#if QT_CONFIG(style_mac)
- if (qobject_cast<QMacStyle *>(q->style()))
+ if (isMacStyle(q->style()))
putSizeGripInLayout = false;
-#endif
if (putSizeGripInLayout) {
layout->addWidget(newSizeGrip);
layout->setAlignment(newSizeGrip, Qt::AlignBottom | Qt::AlignRight);
@@ -2849,8 +2842,8 @@ bool QMdiSubWindow::event(QEvent *event)
d->isMaximizeMode = false;
d->isWidgetHiddenByUs = false;
if (!parent()) {
-#if QT_CONFIG(sizegrip) && QT_CONFIG(style_mac)
- if (qobject_cast<QMacStyle *>(style()))
+#if QT_CONFIG(sizegrip)
+ if (isMacStyle(style()))
delete d->sizeGrip;
#endif
setOption(RubberBandResize, false);
@@ -2944,8 +2937,8 @@ void QMdiSubWindow::showEvent(QShowEvent *showEvent)
return;
}
-#if QT_CONFIG(sizegrip) && QT_CONFIG(style_mac)
- if (qobject_cast<QMacStyle *>(style()) && !d->sizeGrip
+#if QT_CONFIG(sizegrip)
+ if (isMacStyle(style()) && !d->sizeGrip
&& !(windowFlags() & Qt::FramelessWindowHint)) {
d->setSizeGrip(new QSizeGrip(this));
Q_ASSERT(d->sizeGrip);
@@ -3339,10 +3332,10 @@ void QMdiSubWindow::mouseMoveEvent(QMouseEvent *mouseEvent)
hoverRegion += style()->subControlRect(QStyle::CC_TitleBar, &options,
d->hoveredSubControl, this);
}
-#if QT_CONFIG(style_mac)
- if (qobject_cast<QMacStyle *>(style()) && !hoverRegion.isEmpty())
+
+ if (isMacStyle(style()) && !hoverRegion.isEmpty())
hoverRegion += QRegion(0, 0, width(), d->titleBarHeight(options));
-#endif
+
if (!hoverRegion.isEmpty())
update(hoverRegion);
}
@@ -3549,10 +3542,8 @@ QSize QMdiSubWindow::minimumSizeHint() const
int sizeGripHeight = 0;
if (d->sizeGrip && d->sizeGrip->isVisibleTo(const_cast<QMdiSubWindow *>(this)))
sizeGripHeight = d->sizeGrip->height();
-#if QT_CONFIG(style_mac)
- else if (parent() && qobject_cast<QMacStyle *>(style()) && !d->sizeGrip)
+ else if (parent() && isMacStyle(style()) && !d->sizeGrip)
sizeGripHeight = style()->pixelMetric(QStyle::PM_SizeGripSize, 0, this);
-#endif
minHeight = qMax(minHeight, decorationHeight + sizeGripHeight);
#endif
diff --git a/src/widgets/widgets/qmdisubwindow.h b/src/widgets/widgets/qmdisubwindow.h
index adaafa352a..302522e1c3 100644
--- a/src/widgets/widgets/qmdisubwindow.h
+++ b/src/widgets/widgets/qmdisubwindow.h
@@ -66,11 +66,11 @@ public:
};
Q_DECLARE_FLAGS(SubWindowOptions, SubWindowOption)
- QMdiSubWindow(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
+ QMdiSubWindow(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
~QMdiSubWindow();
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ QSize minimumSizeHint() const override;
void setWidget(QWidget *widget);
QWidget *widget() const;
@@ -107,28 +107,28 @@ public Q_SLOTS:
void showShaded();
protected:
- bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
- bool event(QEvent *event) Q_DECL_OVERRIDE;
- void showEvent(QShowEvent *showEvent) Q_DECL_OVERRIDE;
- void hideEvent(QHideEvent *hideEvent) Q_DECL_OVERRIDE;
- void changeEvent(QEvent *changeEvent) Q_DECL_OVERRIDE;
- void closeEvent(QCloseEvent *closeEvent) Q_DECL_OVERRIDE;
- void leaveEvent(QEvent *leaveEvent) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *resizeEvent) Q_DECL_OVERRIDE;
- void timerEvent(QTimerEvent *timerEvent) Q_DECL_OVERRIDE;
- void moveEvent(QMoveEvent *moveEvent) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *paintEvent) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE;
- void mouseDoubleClickEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *keyEvent) Q_DECL_OVERRIDE;
+ bool eventFilter(QObject *object, QEvent *event) override;
+ bool event(QEvent *event) override;
+ void showEvent(QShowEvent *showEvent) override;
+ void hideEvent(QHideEvent *hideEvent) override;
+ void changeEvent(QEvent *changeEvent) override;
+ void closeEvent(QCloseEvent *closeEvent) override;
+ void leaveEvent(QEvent *leaveEvent) override;
+ void resizeEvent(QResizeEvent *resizeEvent) override;
+ void timerEvent(QTimerEvent *timerEvent) override;
+ void moveEvent(QMoveEvent *moveEvent) override;
+ void paintEvent(QPaintEvent *paintEvent) override;
+ void mousePressEvent(QMouseEvent *mouseEvent) override;
+ void mouseDoubleClickEvent(QMouseEvent *mouseEvent) override;
+ void mouseReleaseEvent(QMouseEvent *mouseEvent) override;
+ void mouseMoveEvent(QMouseEvent *mouseEvent) override;
+ void keyPressEvent(QKeyEvent *keyEvent) override;
#ifndef QT_NO_CONTEXTMENU
- void contextMenuEvent(QContextMenuEvent *contextMenuEvent) Q_DECL_OVERRIDE;
+ void contextMenuEvent(QContextMenuEvent *contextMenuEvent) override;
#endif
- void focusInEvent(QFocusEvent *focusInEvent) Q_DECL_OVERRIDE;
- void focusOutEvent(QFocusEvent *focusOutEvent) Q_DECL_OVERRIDE;
- void childEvent(QChildEvent *childEvent) Q_DECL_OVERRIDE;
+ void focusInEvent(QFocusEvent *focusInEvent) override;
+ void focusOutEvent(QFocusEvent *focusOutEvent) override;
+ void childEvent(QChildEvent *childEvent) override;
private:
Q_DISABLE_COPY(QMdiSubWindow)
diff --git a/src/widgets/widgets/qmdisubwindow_p.h b/src/widgets/widgets/qmdisubwindow_p.h
index d03aca168b..719984c8d4 100644
--- a/src/widgets/widgets/qmdisubwindow_p.h
+++ b/src/widgets/widgets/qmdisubwindow_p.h
@@ -271,7 +271,7 @@ public:
void setFocusWidget();
bool restoreFocus();
void storeFocusWidget();
- void setWindowFlags(Qt::WindowFlags windowFlags) Q_DECL_OVERRIDE;
+ void setWindowFlags(Qt::WindowFlags windowFlags) override;
void setVisible(WindowStateAction, bool visible = true);
#ifndef QT_NO_ACTION
void setEnabled(WindowStateAction, bool enable = true);
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index cf306e63bd..024f9a75a1 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -77,6 +77,7 @@
#include <private/qaction_p.h>
#include <private/qguiapplication_p.h>
#include <qpa/qplatformtheme.h>
+#include <private/qdesktopwidget_p.h>
QT_BEGIN_NAMESPACE
@@ -102,7 +103,7 @@ class QTornOffMenu : public QMenu
Q_Q(QTornOffMenu);
QSize size = menuSize;
const QPoint p = (!initialized) ? causedMenu->pos() : q->pos();
- QRect screen = popupGeometry(QApplication::desktop()->screenNumber(p));
+ QRect screen = popupGeometry(QDesktopWidgetPrivate::screenNumber(p));
const int desktopFrame = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q);
const int titleBarHeight = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, 0, q);
if (scroll && (size.height() > screen.height() - titleBarHeight || size.width() > screen.width())) {
@@ -115,7 +116,7 @@ class QTornOffMenu : public QMenu
q->setFixedSize(size);
}
- QVector<QPointer<QWidget> > calcCausedStack() const Q_DECL_OVERRIDE { return causedStack; }
+ QVector<QPointer<QWidget> > calcCausedStack() const override { return causedStack; }
QPointer<QMenu> causedMenu;
QVector<QPointer<QWidget> > causedStack;
bool initialized;
@@ -161,7 +162,7 @@ public:
} else if (act->type() == QEvent::ActionRemoved)
removeAction(act->action());
}
- void actionEvent(QActionEvent *e) Q_DECL_OVERRIDE
+ void actionEvent(QActionEvent *e) override
{
Q_D(QTornOffMenu);
QMenu::actionEvent(e);
@@ -233,59 +234,101 @@ void QMenuPrivate::setPlatformMenu(QPlatformMenu *menu)
}
}
-// forward declare function
-static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem *item, QPlatformMenu *itemsMenu);
-
void QMenuPrivate::syncPlatformMenu()
{
Q_Q(QMenu);
if (platformMenu.isNull())
return;
- QPlatformMenuItem *beforeItem = Q_NULLPTR;
+ QPlatformMenuItem *beforeItem = nullptr;
const QList<QAction*> actions = q->actions();
for (QList<QAction*>::const_reverse_iterator it = actions.rbegin(), end = actions.rend(); it != end; ++it) {
- QPlatformMenuItem *menuItem = platformMenu->createMenuItem();
- QAction *action = *it;
- menuItem->setTag(reinterpret_cast<quintptr>(action));
- QObject::connect(menuItem, SIGNAL(activated()), action, SLOT(trigger()), Qt::QueuedConnection);
- QObject::connect(menuItem, SIGNAL(hovered()), action, SIGNAL(hovered()), Qt::QueuedConnection);
- copyActionToPlatformItem(action, menuItem, platformMenu.data());
- platformMenu->insertMenuItem(menuItem, beforeItem);
+ QPlatformMenuItem *menuItem = insertActionInPlatformMenu(*it, beforeItem);
beforeItem = menuItem;
}
platformMenu->syncSeparatorsCollapsible(collapsibleSeparators);
platformMenu->setEnabled(q->isEnabled());
}
+void QMenuPrivate::copyActionToPlatformItem(const QAction *action, QPlatformMenuItem *item)
+{
+ item->setText(action->text());
+ item->setIsSeparator(action->isSeparator());
+ if (action->isIconVisibleInMenu()) {
+ item->setIcon(action->icon());
+ if (QWidget *w = action->parentWidget()) {
+ QStyleOption opt;
+ opt.init(w);
+ item->setIconSize(w->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, w));
+ } else {
+ QStyleOption opt;
+ item->setIconSize(qApp->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, 0));
+ }
+ } else {
+ item->setIcon(QIcon());
+ }
+ item->setVisible(action->isVisible());
+#if QT_CONFIG(shortcut)
+ item->setShortcut(action->shortcut());
+#endif
+ item->setCheckable(action->isCheckable());
+ item->setChecked(action->isChecked());
+ item->setHasExclusiveGroup(action->actionGroup() && action->actionGroup()->isExclusive());
+ item->setFont(action->font());
+ item->setRole((QPlatformMenuItem::MenuRole) action->menuRole());
+ item->setEnabled(action->isEnabled());
+
+ if (action->menu()) {
+ if (!action->menu()->platformMenu())
+ action->menu()->setPlatformMenu(platformMenu->createSubMenu());
+ item->setMenu(action->menu()->platformMenu());
+ } else {
+ item->setMenu(0);
+ }
+}
+
+QPlatformMenuItem * QMenuPrivate::insertActionInPlatformMenu(const QAction *action, QPlatformMenuItem *beforeItem)
+{
+ QPlatformMenuItem *menuItem = platformMenu->createMenuItem();
+ Q_ASSERT(menuItem);
+
+ menuItem->setTag(reinterpret_cast<quintptr>(action));
+ QObject::connect(menuItem, &QPlatformMenuItem::activated, action, &QAction::trigger, Qt::QueuedConnection);
+ QObject::connect(menuItem, &QPlatformMenuItem::hovered, action, &QAction::hovered, Qt::QueuedConnection);
+ copyActionToPlatformItem(action, menuItem);
+ platformMenu->insertMenuItem(menuItem, beforeItem);
+
+ return menuItem;
+}
+
int QMenuPrivate::scrollerHeight() const
{
Q_Q(const QMenu);
return qMax(QApplication::globalStrut().height(), q->style()->pixelMetric(QStyle::PM_MenuScrollerHeight, 0, q));
}
-//Windows and KDE allows menus to cover the taskbar, while GNOME and Mac don't
+//Windows and KDE allow menus to cover the taskbar, while GNOME and Mac don't
QRect QMenuPrivate::popupGeometry() const
{
Q_Q(const QMenu);
if (!tornoff && // Torn-off menus are different
QGuiApplicationPrivate::platformTheme() &&
QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) {
- return QApplication::desktop()->screenGeometry(q);
+ return QDesktopWidgetPrivate::screenGeometry(q);
} else {
- return QApplication::desktop()->availableGeometry(q);
+ return QDesktopWidgetPrivate::availableGeometry(q);
}
}
-//Windows and KDE allows menus to cover the taskbar, while GNOME and Mac don't
+//Windows and KDE allow menus to cover the taskbar, while GNOME and Mac don't
QRect QMenuPrivate::popupGeometry(int screen) const
{
if (!tornoff && // Torn-off menus are different
QGuiApplicationPrivate::platformTheme() &&
QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) {
- return QApplication::desktop()->screenGeometry(screen);
+ return QDesktopWidgetPrivate::screenGeometry(screen);
} else {
- return QApplication::desktop()->availableGeometry(screen);
+ return QDesktopWidgetPrivate::availableGeometry(screen);
}
}
@@ -304,6 +347,11 @@ QVector<QPointer<QWidget> > QMenuPrivate::calcCausedStack() const
return ret;
}
+bool QMenuPrivate::isContextMenu() const
+{
+ return qobject_cast<const QMenuBar *>(topCausedWidget()) == nullptr;
+}
+
void QMenuPrivate::updateActionRects() const
{
updateActionRects(popupGeometry());
@@ -358,6 +406,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
//calculate size
QFontMetrics qfm = q->fontMetrics();
bool previousWasSeparator = true; // this is true to allow removing the leading separators
+ const bool contextMenu = isContextMenu();
for(int i = 0; i <= lastVisibleAction; i++) {
QAction *action = actions.at(i);
const bool isSection = action->isSeparator() && (!action->text().isEmpty() || !action->icon().isNull());
@@ -386,13 +435,13 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
QString s = action->text();
int t = s.indexOf(QLatin1Char('\t'));
if (t != -1) {
- tabWidth = qMax(int(tabWidth), qfm.width(s.mid(t+1)));
+ tabWidth = qMax(int(tabWidth), qfm.horizontalAdvance(s.mid(t+1)));
s = s.left(t);
#ifndef QT_NO_SHORTCUT
- } else {
+ } else if (action->isShortcutVisibleInContextMenu() || !contextMenu) {
QKeySequence seq = action->shortcut();
if (!seq.isEmpty())
- tabWidth = qMax(int(tabWidth), qfm.width(seq.toString(QKeySequence::NativeText)));
+ tabWidth = qMax(int(tabWidth), qfm.horizontalAdvance(seq.toString(QKeySequence::NativeText)));
#endif
}
sz.setWidth(fm.boundingRect(QRect(), Qt::TextSingleLine | Qt::TextShowMnemonic, s).width());
@@ -616,7 +665,7 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason
if (action
&& (action->isSeparator()
|| (!action->isEnabled() && !q->style()->styleHint(QStyle::SH_Menu_AllowActiveAndDisabled, 0, q))))
- action = Q_NULLPTR;
+ action = nullptr;
// Reselect the currently active action in case mouse moved over other menu items when
// moving from sub menu action to sub menu (QTBUG-20094).
@@ -690,13 +739,13 @@ void QMenuSloppyState::reset()
m_use_reset_action = true;
m_uni_dir_discarded_count = 0;
m_time.stop();
- m_reset_action = Q_NULLPTR;
- m_origin_action = Q_NULLPTR;
+ m_reset_action = nullptr;
+ m_origin_action = nullptr;
m_action_rect = QRect();
m_previous_point = QPointF();
if (m_sub_menu) {
- QMenuPrivate::get(m_sub_menu)->sloppyState.m_parent = Q_NULLPTR;
- m_sub_menu = Q_NULLPTR;
+ QMenuPrivate::get(m_sub_menu)->sloppyState.m_parent = nullptr;
+ m_sub_menu = nullptr;
}
}
void QMenuSloppyState::enter()
@@ -805,7 +854,7 @@ void QMenuSloppyState::timeout()
if (m_use_reset_action)
menu_priv->setCurrentAction(m_reset_action, 0);
} else {
- menu_priv->setCurrentAction(Q_NULLPTR, 0);
+ menu_priv->setCurrentAction(nullptr, 0);
}
}
@@ -854,8 +903,7 @@ void QMenuPrivate::adjustMenuScreen(const QPoint &p)
// The (item) size calculations depend on the menu screen,
// so a wrong screen would often cause wrong sizes (on high DPI)
const QScreen *currentScreen = q->windowHandle() ? q->windowHandle()->screen() : nullptr;
- const int screenNumberForPoint = QApplication::desktop()->screenNumber(p);
- QScreen *actualScreen = QGuiApplication::screens().at(screenNumberForPoint);
+ QScreen *actualScreen = QGuiApplication::screenAt(p);
if (actualScreen && currentScreen != actualScreen) {
if (!q->windowHandle()) // Try to create a window handle if not created.
createWinId();
@@ -1536,7 +1584,8 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action)
option->icon = action->icon();
QString textAndAccel = action->text();
#ifndef QT_NO_SHORTCUT
- if (textAndAccel.indexOf(QLatin1Char('\t')) == -1) {
+ if ((action->isShortcutVisibleInContextMenu() || !d->isContextMenu())
+ && textAndAccel.indexOf(QLatin1Char('\t')) == -1) {
QKeySequence seq = action->shortcut();
if (!seq.isEmpty())
textAndAccel += QLatin1Char('\t') + seq.toString(QKeySequence::NativeText);
@@ -1753,7 +1802,7 @@ QAction *QMenu::addAction(const QString &text, const QObject *receiver, const ch
return action;
}
-/*!\fn QAction *QMenu::addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0)
+/*!\fn template<typename PointerToMemberFunction> QAction *QMenu::addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0)
\since 5.6
@@ -1768,7 +1817,7 @@ QAction *QMenu::addAction(const QString &text, const QObject *receiver, const ch
QMenu takes ownership of the returned QAction.
*/
-/*!\fn QAction *QMenu::addAction(const QString &text, Functor functor, const QKeySequence &shortcut = 0)
+/*!\fn template<typename Functor> QAction *QMenu::addAction(const QString &text, Functor functor, const QKeySequence &shortcut = 0)
\since 5.6
@@ -1783,7 +1832,7 @@ QAction *QMenu::addAction(const QString &text, const QObject *receiver, const ch
QMenu takes ownership of the returned QAction.
*/
-/*!\fn QAction *QMenu::addAction(const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut = 0)
+/*!\fn template<typename Functor> QAction *QMenu::addAction(const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut)
\since 5.6
@@ -1800,7 +1849,7 @@ QAction *QMenu::addAction(const QString &text, const QObject *receiver, const ch
QMenu takes ownership of the returned QAction.
*/
-/*!\fn QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0)
+/*!\fn template<typename PointerToMemberFunction> QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method, const QKeySequence &shortcut = 0)
\since 5.6
@@ -1815,7 +1864,7 @@ QAction *QMenu::addAction(const QString &text, const QObject *receiver, const ch
QMenu takes ownership of the returned QAction.
*/
-/*!\fn QAction *QMenu::addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut = 0)
+/*!\fn template<typename Functor> QAction *QMenu::addAction(const QIcon &icon, const QString &text, Functor functor, const QKeySequence &shortcut = 0)
\since 5.6
@@ -1830,7 +1879,7 @@ QAction *QMenu::addAction(const QString &text, const QObject *receiver, const ch
QMenu takes ownership of the returned QAction.
*/
-/*!\fn QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut = 0)
+/*!\fn template<typename Functor> QAction *QMenu::addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor, const QKeySequence &shortcut)
\since 5.6
@@ -2176,7 +2225,7 @@ void QMenu::hideTearOffMenu()
// should consider the torn-off menu deleted.
// This way showTearOffMenu() will not try to
// reuse the dying torn-off menu.
- d->tornPopup = Q_NULLPTR;
+ d->tornPopup = nullptr;
}
}
@@ -2330,6 +2379,12 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
d->updateLayoutDirection();
d->adjustMenuScreen(p);
+ const bool contextMenu = d->isContextMenu();
+ if (d->lastContextMenu != contextMenu) {
+ d->itemsDirty = true;
+ d->lastContextMenu = contextMenu;
+ }
+
#if QT_CONFIG(menubar)
// if this menu is part of a chain attached to a QMenuBar, set the
// _NET_WM_WINDOW_TYPE_DROPDOWN_MENU X11 window type
@@ -2347,7 +2402,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
screen = d->popupGeometry();
else
#endif
- screen = d->popupGeometry(QApplication::desktop()->screenNumber(p));
+ screen = d->popupGeometry(QDesktopWidgetPrivate::screenNumber(p));
d->updateActionRects(screen);
QPoint pos;
@@ -2447,8 +2502,6 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
pos.setY(qMin(mouse.y() - (size.height() + desktopFrame), screen.bottom()-desktopFrame-size.height()+1));
else
pos.setY(qMax(p.y() - (size.height() + desktopFrame), screen.bottom()-desktopFrame-size.height()+1));
- } else if (pos.y() < screen.top() + desktopFrame) {
- pos.setY(screen.top() + desktopFrame);
}
if (pos.y() < screen.top() + desktopFrame)
@@ -2680,7 +2733,8 @@ void QMenu::hideEvent(QHideEvent *)
if (QMenuBar *mb = qobject_cast<QMenuBar*>(d->causedPopup.widget))
mb->d_func()->setCurrentAction(0);
#endif
- d->mouseDown = 0;
+ if (d->mouseDown == this)
+ d->mouseDown = 0;
d->hasHadMouse = false;
if (d->activeMenu)
d->hideMenu(d->activeMenu);
@@ -3469,43 +3523,6 @@ QMenu::timerEvent(QTimerEvent *e)
}
}
-static void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem *item, QPlatformMenu *itemsMenu)
-{
- item->setText(action->text());
- item->setIsSeparator(action->isSeparator());
- if (action->isIconVisibleInMenu()) {
- item->setIcon(action->icon());
- if (QWidget *w = action->parentWidget()) {
- QStyleOption opt;
- opt.init(w);
- item->setIconSize(w->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, w));
- } else {
- QStyleOption opt;
- item->setIconSize(qApp->style()->pixelMetric(QStyle::PM_SmallIconSize, &opt, 0));
- }
- } else {
- item->setIcon(QIcon());
- }
- item->setVisible(action->isVisible());
-#ifndef QT_NO_SHORTCUT
- item->setShortcut(action->shortcut());
-#endif
- item->setCheckable(action->isCheckable());
- item->setChecked(action->isChecked());
- item->setHasExclusiveGroup(action->actionGroup() && action->actionGroup()->isExclusive());
- item->setFont(action->font());
- item->setRole((QPlatformMenuItem::MenuRole) action->menuRole());
- item->setEnabled(action->isEnabled());
-
- if (action->menu()) {
- if (!action->menu()->platformMenu())
- action->menu()->setPlatformMenu(itemsMenu->createSubMenu());
- item->setMenu(action->menu()->platformMenu());
- } else {
- item->setMenu(0);
- }
-}
-
/*!
\reimp
*/
@@ -3517,9 +3534,13 @@ void QMenu::actionEvent(QActionEvent *e)
if (d->tornPopup)
d->tornPopup->syncWithMenu(this, e);
if (e->type() == QEvent::ActionAdded) {
- if(!d->tornoff) {
- connect(e->action(), SIGNAL(triggered()), this, SLOT(_q_actionTriggered()));
- connect(e->action(), SIGNAL(hovered()), this, SLOT(_q_actionHovered()));
+
+ if (!d->tornoff
+ && !qobject_cast<QMenuBar*>(e->action()->parent())) {
+ // Only connect if the action was not directly added by QMenuBar::addAction(const QString &text)
+ // to avoid the signal being emitted twice
+ connect(e->action(), SIGNAL(triggered()), this, SLOT(_q_actionTriggered()), Qt::UniqueConnection);
+ connect(e->action(), SIGNAL(hovered()), this, SLOT(_q_actionHovered()), Qt::UniqueConnection);
}
if (QWidgetAction *wa = qobject_cast<QWidgetAction *>(e->action())) {
QWidget *widget = wa->requestWidget(this);
@@ -3559,15 +3580,10 @@ void QMenu::actionEvent(QActionEvent *e)
if (!d->platformMenu.isNull()) {
if (e->type() == QEvent::ActionAdded) {
- QPlatformMenuItem *menuItem = d->platformMenu->createMenuItem();
- menuItem->setTag(reinterpret_cast<quintptr>(e->action()));
- QObject::connect(menuItem, SIGNAL(activated()), e->action(), SLOT(trigger()));
- QObject::connect(menuItem, SIGNAL(hovered()), e->action(), SIGNAL(hovered()));
- copyActionToPlatformItem(e->action(), menuItem, d->platformMenu);
QPlatformMenuItem *beforeItem = e->before()
? d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->before()))
: nullptr;
- d->platformMenu->insertMenuItem(menuItem, beforeItem);
+ d->insertActionInPlatformMenu(e->action(), beforeItem);
} else if (e->type() == QEvent::ActionRemoved) {
QPlatformMenuItem *menuItem = d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->action()));
d->platformMenu->removeMenuItem(menuItem);
@@ -3575,7 +3591,7 @@ void QMenu::actionEvent(QActionEvent *e)
} else if (e->type() == QEvent::ActionChanged) {
QPlatformMenuItem *menuItem = d->platformMenu->menuItemForTag(reinterpret_cast<quintptr>(e->action()));
if (menuItem) {
- copyActionToPlatformItem(e->action(), menuItem, d->platformMenu);
+ d->copyActionToPlatformItem(e->action(), menuItem);
d->platformMenu->syncMenuItem(menuItem);
}
}
@@ -3617,7 +3633,7 @@ void QMenu::internalDelayedPopup()
screen = d->popupGeometry();
else
#endif
- screen = d->popupGeometry(QApplication::desktop()->screenNumber(pos()));
+ screen = d->popupGeometry(QDesktopWidgetPrivate::screenNumber(pos()));
int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this);
const QRect actionRect(d->actionRect(d->currentAction));
diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h
index 0b5ed579cd..86d927e919 100644
--- a/src/widgets/widgets/qmenu.h
+++ b/src/widgets/widgets/qmenu.h
@@ -71,8 +71,8 @@ private:
Q_PROPERTY(bool toolTipsVisible READ toolTipsVisible WRITE setToolTipsVisible)
public:
- explicit QMenu(QWidget *parent = Q_NULLPTR);
- explicit QMenu(const QString &title, QWidget *parent = Q_NULLPTR);
+ explicit QMenu(QWidget *parent = nullptr);
+ explicit QMenu(const QString &title, QWidget *parent = nullptr);
~QMenu();
using QWidget::addAction;
@@ -107,7 +107,7 @@ public:
#else
result->setShortcut(shortcut);
#endif
- connect(result, &QAction::triggered, object, slot);
+ connect(result, &QAction::triggered, object, std::move(slot));
return result;
}
// addAction(QString): Connect to a functor or function pointer (without context)
@@ -120,7 +120,7 @@ public:
#else
result->setShortcut(shortcut);
#endif
- connect(result, &QAction::triggered, slot);
+ connect(result, &QAction::triggered, std::move(slot));
return result;
}
// addAction(QIcon, QString): Connect to a QObject slot / functor or function pointer (with context)
@@ -135,7 +135,7 @@ public:
#else
result->setShortcut(shortcut);
#endif
- connect(result, &QAction::triggered, object, slot);
+ connect(result, &QAction::triggered, object, std::move(slot));
return result;
}
// addAction(QIcon, QString): Connect to a functor or function pointer (without context)
@@ -148,7 +148,7 @@ public:
#else
result->setShortcut(shortcut);
#endif
- connect(result, &QAction::triggered, slot);
+ connect(result, &QAction::triggered, std::move(slot));
return result;
}
#endif // !Q_QDOC
@@ -184,17 +184,17 @@ public:
void setActiveAction(QAction *act);
QAction *activeAction() const;
- void popup(const QPoint &pos, QAction *at = Q_NULLPTR);
+ void popup(const QPoint &pos, QAction *at = nullptr);
QAction *exec();
- QAction *exec(const QPoint &pos, QAction *at = Q_NULLPTR);
+ QAction *exec(const QPoint &pos, QAction *at = nullptr);
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
- static QAction *exec(const QList<QAction *> &actions, const QPoint &pos, QAction *at = Q_NULLPTR, QWidget *parent = Q_NULLPTR);
+ static QAction *exec(const QList<QAction *> &actions, const QPoint &pos, QAction *at = nullptr, QWidget *parent = nullptr);
#else
- static QAction *exec(QList<QAction*> actions, const QPoint &pos, QAction *at = Q_NULLPTR, QWidget *parent = Q_NULLPTR);
+ static QAction *exec(QList<QAction*> actions, const QPoint &pos, QAction *at = nullptr, QWidget *parent = nullptr);
#endif
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
QRect actionGeometry(QAction *) const;
QAction *actionAt(const QPoint &) const;
@@ -231,22 +231,22 @@ Q_SIGNALS:
protected:
int columnCount() const;
- void changeEvent(QEvent *) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
+ void changeEvent(QEvent *) override;
+ void keyPressEvent(QKeyEvent *) override;
+ void mouseReleaseEvent(QMouseEvent *) override;
+ void mousePressEvent(QMouseEvent *) override;
+ void mouseMoveEvent(QMouseEvent *) override;
#if QT_CONFIG(wheelevent)
- void wheelEvent(QWheelEvent *) Q_DECL_OVERRIDE;
+ void wheelEvent(QWheelEvent *) override;
#endif
- void enterEvent(QEvent *) Q_DECL_OVERRIDE;
- void leaveEvent(QEvent *) Q_DECL_OVERRIDE;
- void hideEvent(QHideEvent *) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
- void actionEvent(QActionEvent *) Q_DECL_OVERRIDE;
- void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE;
- bool event(QEvent *) Q_DECL_OVERRIDE;
- bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE;
+ void enterEvent(QEvent *) override;
+ void leaveEvent(QEvent *) override;
+ void hideEvent(QHideEvent *) override;
+ void paintEvent(QPaintEvent *) override;
+ void actionEvent(QActionEvent *) override;
+ void timerEvent(QTimerEvent *) override;
+ bool event(QEvent *) override;
+ bool focusNextPrevChild(bool next) override;
void initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const;
private Q_SLOTS:
@@ -259,7 +259,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_platformMenuAboutToShow())
protected:
- QMenu(QMenuPrivate &dd, QWidget* parent = Q_NULLPTR);
+ QMenu(QMenuPrivate &dd, QWidget* parent = nullptr);
private:
Q_DISABLE_COPY(QMenu)
diff --git a/src/widgets/widgets/qmenu_mac.mm b/src/widgets/widgets/qmenu_mac.mm
index 7d932c670f..0d680fb4dc 100644
--- a/src/widgets/widgets/qmenu_mac.mm
+++ b/src/widgets/widgets/qmenu_mac.mm
@@ -135,6 +135,11 @@ void QMenuPrivate::moveWidgetToPlatformItem(QWidget *widget, QPlatformMenuItem*
containerWindow->setFlags(wf | Qt::SubWindow);
[(NSView *)widget->winId() setAutoresizingMask:NSViewWidthSizable];
+ if (QPlatformNativeInterface::NativeResourceForIntegrationFunction function = resolvePlatformFunction("setEmbeddedInForeignView")) {
+ typedef void (*SetEmbeddedInForeignViewFunction)(QPlatformWindow *window, bool embedded);
+ reinterpret_cast<SetEmbeddedInForeignViewFunction>(function)(containerWindow->handle(), true);
+ }
+
item->setNativeContents((WId)containerView);
container->show();
}
diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h
index 64d22087e3..b6afb05e3a 100644
--- a/src/widgets/widgets/qmenu_p.h
+++ b/src/widgets/widgets/qmenu_p.h
@@ -177,7 +177,7 @@ public:
QSetValueOnDestroy<QPointF> setPreviousPoint(m_previous_point, mousePos);
if (resetAction && resetAction->isSeparator()) {
- m_reset_action = Q_NULLPTR;
+ m_reset_action = nullptr;
m_use_reset_action = true;
} else if (m_reset_action != resetAction) {
if (m_use_reset_action && resetAction) {
@@ -272,6 +272,7 @@ public:
QMenuPrivate() :
itemsDirty(false),
hasCheckableItems(false),
+ lastContextMenu(false),
collapsibleSeparators(true),
toolTipsVisible(false),
delayedPopupGuard(false),
@@ -294,6 +295,9 @@ public:
QPlatformMenu *createPlatformMenu();
void setPlatformMenu(QPlatformMenu *menu);
void syncPlatformMenu();
+ void copyActionToPlatformItem(const QAction *action, QPlatformMenuItem *item);
+ QPlatformMenuItem *insertActionInPlatformMenu(const QAction *action, QPlatformMenuItem *beforeItem);
+
#ifdef Q_OS_OSX
void moveWidgetToPlatformItem(QWidget *w, QPlatformMenuItem* item);
#endif
@@ -301,6 +305,8 @@ public:
static QMenuPrivate *get(QMenu *m) { return m->d_func(); }
int scrollerHeight() const;
+ bool isContextMenu() const;
+
//item calculations
QRect actionRect(QAction *) const;
@@ -436,8 +442,8 @@ public:
public:
enum Type { ScrollUp, ScrollDown };
ScrollerTearOffItem(Type type, QMenuPrivate *mPrivate,
- QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
- void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
+ QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
+ void paintEvent(QPaintEvent *e) override;
void updateScrollerRects(const QRect &rect);
private:
@@ -462,6 +468,7 @@ public:
mutable bool itemsDirty : 1;
mutable bool hasCheckableItems : 1;
+ bool lastContextMenu : 1;
bool collapsibleSeparators : 1;
bool toolTipsVisible : 1;
bool delayedPopupGuard : 1;
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index 6dfbb7c8a1..b0a75288e8 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -62,6 +62,7 @@
#include <qpa/qplatformtheme.h>
#include "private/qguiapplication_p.h"
#include "qpa/qplatformintegration.h"
+#include <private/qdesktopwidget_p.h>
#include "qmenu_p.h"
#include "qmenubar_p.h"
@@ -74,8 +75,8 @@ class QMenuBarExtension : public QToolButton
public:
explicit QMenuBarExtension(QWidget *parent);
- QSize sizeHint() const Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ void paintEvent(QPaintEvent *) override;
};
QMenuBarExtension::QMenuBarExtension(QWidget *parent)
@@ -321,7 +322,7 @@ void QMenuBarPrivate::popupAction(QAction *action, bool activateFirst)
QSize popup_size = activeMenu->sizeHint();
//we put the popup menu on the screen containing the bottom-center of the action rect
- QRect screenRect = QApplication::desktop()->screenGeometry(pos + QPoint(adjustedActionRect.width() / 2, 0));
+ QRect screenRect = QDesktopWidgetPrivate::screenGeometry(pos + QPoint(adjustedActionRect.width() / 2, 0));
pos = QPoint(qMax(pos.x(), screenRect.x()), qMax(pos.y(), screenRect.y()));
const bool fitUp = (q->mapToGlobal(adjustedActionRect.topLeft()).y() >= popup_size.height());
@@ -780,6 +781,40 @@ QAction *QMenuBar::addAction(const QString &text, const QObject *receiver, const
}
/*!
+ \fn template<typename Obj, typename PointerToMemberFunctionOrFunctor> QAction *QMenuBar::addAction(const QString &text, const Obj *receiver, PointerToMemberFunctionOrFunctor method)
+
+ \since 5.11
+
+ \overload
+
+ This convenience function creates a new action with the given \a
+ text. The action's triggered() signal is connected to the
+ \a method of the \a receiver. The function adds the newly created
+ action to the menu's list of actions and returns it.
+
+ QMenuBar takes ownership of the returned QAction.
+
+ \sa QWidget::addAction(), QWidget::actions()
+*/
+
+/*!
+ \fn template<typename Functor> QAction *QMenuBar::addAction(const QString &text, Functor functor)
+
+ \since 5.11
+
+ \overload
+
+ This convenience function creates a new action with the given \a
+ text. The action's triggered() signal is connected to the
+ \a functor. The function adds the newly created
+ action to the menu's list of actions and returns it.
+
+ QMenuBar takes ownership of the returned QAction.
+
+ \sa QWidget::addAction(), QWidget::actions()
+*/
+
+/*!
Appends a new QMenu with \a title to the menu bar. The menu bar
takes ownership of the menu. Returns the new menu.
@@ -1045,6 +1080,10 @@ void QMenuBar::mouseReleaseEvent(QMouseEvent *e)
d->mouseDown = false;
QAction *action = d->actionAt(e->pos());
+
+ // do noting if the action is hidden
+ if (!d->isVisible(action))
+ return;
if((d->closePopupMode && action == d->currentAction) || !action || !action->menu()) {
//we set the current action before activating
//so that we let the leave event set the current back to 0
@@ -1330,7 +1369,7 @@ void QMenuBarPrivate::handleReparent()
//Note: if parent is reparented, then window may change even if parent doesn't.
// We need to install an avent filter on each parent up to the parent that is
// also a window (for shortcuts)
- QWidget *newWindow = newParent ? newParent->window() : Q_NULLPTR;
+ QWidget *newWindow = newParent ? newParent->window() : nullptr;
QVector<QPointer<QWidget> > newParents;
// Remove event filters on ex-parents, keep them on still-parents
@@ -1505,7 +1544,7 @@ bool QMenuBar::eventFilter(QObject *object, QEvent *event)
d->setKeyboardMode(!d->keyboardState);
}
}
- // fall through
+ Q_FALLTHROUGH();
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::MouseMove:
@@ -1573,7 +1612,7 @@ QSize QMenuBar::minimumSizeHint() const
int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);
int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this);
if(as_gui_menubar) {
- int w = parentWidget() ? parentWidget()->width() : QApplication::desktop()->width();
+ int w = parentWidget() ? parentWidget()->width() : QDesktopWidgetPrivate::width();
d->calcActionRects(w - (2 * fw), 0);
for (int i = 0; ret.isNull() && i < d->actions.count(); ++i)
ret = d->actionRects.at(i).size();
@@ -1625,7 +1664,7 @@ QSize QMenuBar::sizeHint() const
int fw = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, this);
int spaceBelowMenuBar = style()->styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, 0, this);
if(as_gui_menubar) {
- const int w = parentWidget() ? parentWidget()->width() : QApplication::desktop()->width();
+ const int w = parentWidget() ? parentWidget()->width() : QDesktopWidgetPrivate::width();
d->calcActionRects(w - (2 * fw), 0);
for (int i = 0; i < d->actionRects.count(); ++i) {
const QRect &actionRect = d->actionRects.at(i);
@@ -1709,7 +1748,7 @@ void QMenuBarPrivate::_q_internalShortcutActivated(int id)
QAction *act = actions.at(id);
if (act && act->menu()) {
if (QPlatformMenu *platformMenu = act->menu()->platformMenu()) {
- platformMenu->showPopup(q->windowHandle(), actionRects.at(id), Q_NULLPTR);
+ platformMenu->showPopup(q->windowHandle(), actionRects.at(id), nullptr);
return;
}
}
diff --git a/src/widgets/widgets/qmenubar.h b/src/widgets/widgets/qmenubar.h
index be70f4ea48..2f071e7e3b 100644
--- a/src/widgets/widgets/qmenubar.h
+++ b/src/widgets/widgets/qmenubar.h
@@ -60,13 +60,39 @@ class Q_WIDGETS_EXPORT QMenuBar : public QWidget
Q_PROPERTY(bool nativeMenuBar READ isNativeMenuBar WRITE setNativeMenuBar)
public:
- explicit QMenuBar(QWidget *parent = Q_NULLPTR);
+ explicit QMenuBar(QWidget *parent = nullptr);
~QMenuBar();
using QWidget::addAction;
QAction *addAction(const QString &text);
QAction *addAction(const QString &text, const QObject *receiver, const char* member);
+#ifdef Q_QDOC
+ template<typename Obj, typename PointerToMemberFunctionOrFunctor>
+ QAction *addAction(const QString &text, const Obj *receiver, PointerToMemberFunctionOrFunctor method);
+ template<typename Functor>
+ QAction *addAction(const QString &text, Functor functor);
+#else
+ // addAction(QString): Connect to a QObject slot / functor or function pointer (with context)
+ template<typename Obj, typename Func1>
+ inline typename std::enable_if<!std::is_same<const char*, Func1>::value
+ && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type
+ addAction(const QString &text, const Obj *object, Func1 slot)
+ {
+ QAction *result = addAction(text);
+ connect(result, &QAction::triggered, object, std::move(slot));
+ return result;
+ }
+ // addAction(QString): Connect to a functor or function pointer (without context)
+ template <typename Func1>
+ inline QAction *addAction(const QString &text, Func1 slot)
+ {
+ QAction *result = addAction(text);
+ connect(result, &QAction::triggered, std::move(slot));
+ return result;
+ }
+#endif // !Q_QDOC
+
QAction *addMenu(QMenu *menu);
QMenu *addMenu(const QString &title);
QMenu *addMenu(const QIcon &icon, const QString &title);
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index 6b51388990..e66b702ffd 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -364,7 +364,7 @@ void QPlainTextDocumentLayout::layoutBlock(const QTextBlock &block)
int extraMargin = 0;
if (option.flags() & QTextOption::AddSpaceForLineAndParagraphSeparators) {
QFontMetrics fm(block.charFormat().font());
- extraMargin += fm.width(QChar(0x21B5));
+ extraMargin += fm.horizontalAdvance(QChar(0x21B5));
}
tl->beginLayout();
qreal availableWidth = d->width;
@@ -747,7 +747,8 @@ QPlainTextEditPrivate::QPlainTextEditPrivate()
tabChangesFocus(false),
lineWrap(QPlainTextEdit::WidgetWidth),
wordWrap(QTextOption::WrapAtWordBoundaryOrAnywhere),
- clickCausedFocus(0),topLine(0),topLineFracture(0),
+ clickCausedFocus(0), placeholderVisible(1),
+ topLine(0), topLineFracture(0),
pageUpDownLastCursorYIsValid(false)
{
showCursorOnInitialShow = true;
@@ -784,6 +785,7 @@ void QPlainTextEditPrivate::init(const QString &txt)
QObject::connect(control, SIGNAL(selectionChanged()), q, SIGNAL(selectionChanged()));
QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SLOT(_q_cursorPositionChanged()));
+ QObject::connect(control, SIGNAL(textChanged()), q, SLOT(_q_textChanged()));
QObject::connect(control, SIGNAL(textChanged()), q, SLOT(updateMicroFocus()));
// set a null page size initially to avoid any relayouting until the textedit
@@ -816,6 +818,24 @@ void QPlainTextEditPrivate::init(const QString &txt)
#endif
}
+void QPlainTextEditPrivate::_q_textChanged()
+{
+ Q_Q(QPlainTextEdit);
+
+ // We normally only repaint the part of view that contains text in the
+ // document that has changed (in _q_repaintContents). But the placeholder
+ // text is not a part of the document, but is drawn on separately. So whenever
+ // we either show or hide the placeholder text, we issue a full update.
+ bool placeholderCurrentyVisible = placeholderVisible;
+
+ placeholderVisible = !placeholderText.isEmpty()
+ && q->document()->isEmpty()
+ && q->firstVisibleBlock().layout()->preeditAreaText().isEmpty();
+
+ if (placeholderCurrentyVisible != placeholderVisible)
+ viewport->update();
+}
+
void QPlainTextEditPrivate::_q_repaintContents(const QRectF &contentsRect)
{
Q_Q(QPlainTextEdit);
@@ -1881,6 +1901,7 @@ static void fillBackground(QPainter *p, const QRectF &rect, QBrush brush, const
*/
void QPlainTextEdit::paintEvent(QPaintEvent *e)
{
+ Q_D(QPlainTextEdit);
QPainter painter(viewport());
Q_ASSERT(qobject_cast<QPlainTextDocumentLayout*>(document()->documentLayout()));
@@ -1903,6 +1924,15 @@ void QPlainTextEdit::paintEvent(QPaintEvent *e)
er.setRight(qMin(er.right(), maxX));
painter.setClipRect(er);
+ if (d->placeholderVisible) {
+ QColor col = d->control->palette().text().color();
+ col.setAlpha(128);
+ painter.setPen(col);
+ painter.setClipRect(e->rect());
+ const int margin = int(document()->documentMargin());
+ QRectF textRect = viewportRect.adjusted(margin, margin, 0, 0);
+ painter.drawText(textRect, Qt::AlignTop | Qt::TextWordWrap, placeholderText());
+ }
QAbstractTextDocumentLayout::PaintContext context = getPaintContext();
@@ -1977,17 +2007,8 @@ void QPlainTextEdit::paintEvent(QPaintEvent *e)
}
}
+ layout->draw(&painter, offset, selections, er);
- if (!placeholderText().isEmpty() && document()->isEmpty() && layout->preeditAreaText().isEmpty()) {
- Q_D(QPlainTextEdit);
- QColor col = d->control->palette().text().color();
- col.setAlpha(128);
- painter.setPen(col);
- const int margin = int(document()->documentMargin());
- painter.drawText(r.adjusted(margin, 0, 0, 0), Qt::AlignTop | Qt::TextWordWrap, placeholderText());
- } else {
- layout->draw(&painter, offset, selections, er);
- }
if ((drawCursor && !drawCursorAsBlock)
|| (editable && context.cursorPosition < -1
&& !layout->preeditAreaText().isEmpty())) {
@@ -2453,29 +2474,51 @@ void QPlainTextEdit::setOverwriteMode(bool overwrite)
d->control->setOverwriteMode(overwrite);
}
+#if QT_DEPRECATED_SINCE(5, 10)
/*!
\property QPlainTextEdit::tabStopWidth
\brief the tab stop width in pixels
+ \deprecated in Qt 5.10. Use tabStopDistance instead.
By default, this property contains a value of 80.
*/
int QPlainTextEdit::tabStopWidth() const
{
- Q_D(const QPlainTextEdit);
- return qRound(d->control->document()->defaultTextOption().tabStop());
+ return qRound(tabStopDistance());
}
void QPlainTextEdit::setTabStopWidth(int width)
{
+ setTabStopDistance(width);
+}
+#endif
+
+/*!
+ \property QPlainTextEdit::tabStopDistance
+ \brief the tab stop distance in pixels
+ \since 5.10
+
+ By default, this property contains a value of 80.
+*/
+
+qreal QPlainTextEdit::tabStopDistance() const
+{
+ Q_D(const QPlainTextEdit);
+ return d->control->document()->defaultTextOption().tabStopDistance();
+}
+
+void QPlainTextEdit::setTabStopDistance(qreal distance)
+{
Q_D(QPlainTextEdit);
QTextOption opt = d->control->document()->defaultTextOption();
- if (opt.tabStop() == width || width < 0)
+ if (opt.tabStopDistance() == distance || distance < 0)
return;
- opt.setTabStop(width);
+ opt.setTabStopDistance(distance);
d->control->document()->setDefaultTextOption(opt);
}
+
/*!
\property QPlainTextEdit::cursorWidth
diff --git a/src/widgets/widgets/qplaintextedit.h b/src/widgets/widgets/qplaintextedit.h
index 29d610a129..34ec96715e 100644
--- a/src/widgets/widgets/qplaintextedit.h
+++ b/src/widgets/widgets/qplaintextedit.h
@@ -73,7 +73,10 @@ class Q_WIDGETS_EXPORT QPlainTextEdit : public QAbstractScrollArea
Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
Q_PROPERTY(QString plainText READ toPlainText WRITE setPlainText NOTIFY textChanged USER true)
Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode)
+#if QT_DEPRECATED_SINCE(5, 10)
Q_PROPERTY(int tabStopWidth READ tabStopWidth WRITE setTabStopWidth)
+#endif
+ Q_PROPERTY(qreal tabStopDistance READ tabStopDistance WRITE setTabStopDistance)
Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
Q_PROPERTY(int blockCount READ blockCount)
@@ -88,8 +91,8 @@ public:
};
Q_ENUM(LineWrapMode)
- explicit QPlainTextEdit(QWidget *parent = Q_NULLPTR);
- explicit QPlainTextEdit(const QString &text, QWidget *parent = Q_NULLPTR);
+ explicit QPlainTextEdit(QWidget *parent = nullptr);
+ explicit QPlainTextEdit(const QString &text, QWidget *parent = nullptr);
virtual ~QPlainTextEdit();
void setDocument(QTextDocument *document);
@@ -167,8 +170,13 @@ public:
bool overwriteMode() const;
void setOverwriteMode(bool overwrite);
- int tabStopWidth() const;
- void setTabStopWidth(int width);
+#if QT_DEPRECATED_SINCE(5, 10)
+ QT_DEPRECATED int tabStopWidth() const;
+ QT_DEPRECATED void setTabStopWidth(int width);
+#endif
+
+ qreal tabStopDistance() const;
+ void setTabStopDistance(qreal distance);
int cursorWidth() const;
void setCursorWidth(int width);
@@ -183,7 +191,7 @@ public:
void print(QPagedPaintDevice *printer) const;
int blockCount() const;
- QVariant inputMethodQuery(Qt::InputMethodQuery property) const Q_DECL_OVERRIDE;
+ QVariant inputMethodQuery(Qt::InputMethodQuery property) const override;
Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const;
public Q_SLOTS:
@@ -225,43 +233,43 @@ Q_SIGNALS:
void modificationChanged(bool);
protected:
- virtual bool event(QEvent *e) Q_DECL_OVERRIDE;
- virtual void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE;
- virtual void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
- virtual void keyReleaseEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
- virtual void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
- virtual void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
- virtual void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- virtual void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- virtual void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- virtual void mouseDoubleClickEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- virtual bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE;
+ virtual bool event(QEvent *e) override;
+ virtual void timerEvent(QTimerEvent *e) override;
+ virtual void keyPressEvent(QKeyEvent *e) override;
+ virtual void keyReleaseEvent(QKeyEvent *e) override;
+ virtual void resizeEvent(QResizeEvent *e) override;
+ virtual void paintEvent(QPaintEvent *e) override;
+ virtual void mousePressEvent(QMouseEvent *e) override;
+ virtual void mouseMoveEvent(QMouseEvent *e) override;
+ virtual void mouseReleaseEvent(QMouseEvent *e) override;
+ virtual void mouseDoubleClickEvent(QMouseEvent *e) override;
+ virtual bool focusNextPrevChild(bool next) override;
#ifndef QT_NO_CONTEXTMENU
- virtual void contextMenuEvent(QContextMenuEvent *e) Q_DECL_OVERRIDE;
+ virtual void contextMenuEvent(QContextMenuEvent *e) override;
#endif
#ifndef QT_NO_DRAGANDDROP
- virtual void dragEnterEvent(QDragEnterEvent *e) Q_DECL_OVERRIDE;
- virtual void dragLeaveEvent(QDragLeaveEvent *e) Q_DECL_OVERRIDE;
- virtual void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE;
- virtual void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE;
+ virtual void dragEnterEvent(QDragEnterEvent *e) override;
+ virtual void dragLeaveEvent(QDragLeaveEvent *e) override;
+ virtual void dragMoveEvent(QDragMoveEvent *e) override;
+ virtual void dropEvent(QDropEvent *e) override;
#endif
- virtual void focusInEvent(QFocusEvent *e) Q_DECL_OVERRIDE;
- virtual void focusOutEvent(QFocusEvent *e) Q_DECL_OVERRIDE;
- virtual void showEvent(QShowEvent *) Q_DECL_OVERRIDE;
- virtual void changeEvent(QEvent *e) Q_DECL_OVERRIDE;
+ virtual void focusInEvent(QFocusEvent *e) override;
+ virtual void focusOutEvent(QFocusEvent *e) override;
+ virtual void showEvent(QShowEvent *) override;
+ virtual void changeEvent(QEvent *e) override;
#if QT_CONFIG(wheelevent)
- virtual void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE;
+ virtual void wheelEvent(QWheelEvent *e) override;
#endif
virtual QMimeData *createMimeDataFromSelection() const;
virtual bool canInsertFromMimeData(const QMimeData *source) const;
virtual void insertFromMimeData(const QMimeData *source);
- virtual void inputMethodEvent(QInputMethodEvent *) Q_DECL_OVERRIDE;
+ virtual void inputMethodEvent(QInputMethodEvent *) override;
QPlainTextEdit(QPlainTextEditPrivate &dd, QWidget *parent);
- virtual void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE;
+ virtual void scrollContentsBy(int dx, int dy) override;
virtual void doSetTextCursor(const QTextCursor &cursor);
QTextBlock firstVisibleBlock() const;
@@ -275,6 +283,7 @@ protected:
private:
Q_DISABLE_COPY(QPlainTextEdit)
Q_PRIVATE_SLOT(d_func(), void _q_repaintContents(const QRectF &r))
+ Q_PRIVATE_SLOT(d_func(), void _q_textChanged())
Q_PRIVATE_SLOT(d_func(), void _q_adjustScrollbars())
Q_PRIVATE_SLOT(d_func(), void _q_verticalScrollbarActionTriggered(int))
Q_PRIVATE_SLOT(d_func(), void _q_cursorPositionChanged())
@@ -294,14 +303,14 @@ public:
QPlainTextDocumentLayout(QTextDocument *document);
~QPlainTextDocumentLayout();
- void draw(QPainter *, const PaintContext &) Q_DECL_OVERRIDE;
- int hitTest(const QPointF &, Qt::HitTestAccuracy ) const Q_DECL_OVERRIDE;
+ void draw(QPainter *, const PaintContext &) override;
+ int hitTest(const QPointF &, Qt::HitTestAccuracy ) const override;
- int pageCount() const Q_DECL_OVERRIDE;
- QSizeF documentSize() const Q_DECL_OVERRIDE;
+ int pageCount() const override;
+ QSizeF documentSize() const override;
- QRectF frameBoundingRect(QTextFrame *) const Q_DECL_OVERRIDE;
- QRectF blockBoundingRect(const QTextBlock &block) const Q_DECL_OVERRIDE;
+ QRectF frameBoundingRect(QTextFrame *) const override;
+ QRectF blockBoundingRect(const QTextBlock &block) const override;
void ensureBlockLayout(const QTextBlock &block) const;
@@ -311,7 +320,7 @@ public:
void requestUpdate();
protected:
- void documentChanged(int from, int /*charsRemoved*/, int charsAdded) Q_DECL_OVERRIDE;
+ void documentChanged(int from, int /*charsRemoved*/, int charsAdded) override;
private:
diff --git a/src/widgets/widgets/qplaintextedit_p.h b/src/widgets/widgets/qplaintextedit_p.h
index 3d6e7781ed..534f0d4681 100644
--- a/src/widgets/widgets/qplaintextedit_p.h
+++ b/src/widgets/widgets/qplaintextedit_p.h
@@ -84,19 +84,19 @@ public:
QPlainTextEditControl(QPlainTextEdit *parent);
- QMimeData *createMimeDataFromSelection() const Q_DECL_OVERRIDE;
- bool canInsertFromMimeData(const QMimeData *source) const Q_DECL_OVERRIDE;
- void insertFromMimeData(const QMimeData *source) Q_DECL_OVERRIDE;
- int hitTest(const QPointF &point, Qt::HitTestAccuracy = Qt::FuzzyHit) const Q_DECL_OVERRIDE;
- QRectF blockBoundingRect(const QTextBlock &block) const Q_DECL_OVERRIDE;
- QString anchorAt(const QPointF &pos) const Q_DECL_OVERRIDE;
+ QMimeData *createMimeDataFromSelection() const override;
+ bool canInsertFromMimeData(const QMimeData *source) const override;
+ void insertFromMimeData(const QMimeData *source) override;
+ int hitTest(const QPointF &point, Qt::HitTestAccuracy = Qt::FuzzyHit) const override;
+ QRectF blockBoundingRect(const QTextBlock &block) const override;
+ QString anchorAt(const QPointF &pos) const override;
inline QRectF cursorRect(const QTextCursor &cursor) const {
QRectF r = QWidgetTextControl::cursorRect(cursor);
r.setLeft(qMax(r.left(), (qreal) 0.));
return r;
}
inline QRectF cursorRect() { return cursorRect(textCursor()); }
- void ensureCursorVisible() Q_DECL_OVERRIDE {
+ void ensureCursorVisible() override {
textEdit->ensureCursorVisible();
emit microFocusChanged();
}
@@ -106,7 +106,7 @@ public:
int topBlock;
QTextBlock firstVisibleBlock() const;
- QVariant loadResource(int type, const QUrl &name) Q_DECL_OVERRIDE {
+ QVariant loadResource(int type, const QUrl &name) override {
return textEdit->loadResource(type, name);
}
@@ -121,6 +121,7 @@ public:
void init(const QString &txt = QString());
void _q_repaintContents(const QRectF &contentsRect);
+ void _q_textChanged();
inline QPoint mapToContents(const QPoint &point) const
{ return QPoint(point.x() + horizontalOffset(), point.y() + verticalOffset()); }
@@ -157,6 +158,7 @@ public:
uint centerOnScroll : 1;
uint inDrag : 1;
uint clickCausedFocus : 1;
+ uint placeholderVisible : 1;
int topLine;
qreal topLineFracture; // for non-int sized fonts
diff --git a/src/widgets/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp
index c408a87339..56253b8e44 100644
--- a/src/widgets/widgets/qprogressbar.cpp
+++ b/src/widgets/widgets/qprogressbar.cpp
@@ -213,7 +213,7 @@ bool QProgressBarPrivate::repaintRequired() const
Note that whether or not the text is drawn is dependent on the style.
Currently CleanLooks and Plastique draw the text. Mac, Windows
- and WindowsXP style do not.
+ and WindowsVista style do not.
\sa textDirection
*/
@@ -421,7 +421,7 @@ QSize QProgressBar::sizeHint() const
QStyleOptionProgressBar opt;
initStyleOption(&opt);
int cw = style()->pixelMetric(QStyle::PM_ProgressBarChunkWidth, &opt, this);
- QSize size = QSize(qMax(9, cw) * 7 + fm.width(QLatin1Char('0')) * 4, fm.height() + 8);
+ QSize size = QSize(qMax(9, cw) * 7 + fm.horizontalAdvance(QLatin1Char('0')) * 4, fm.height() + 8);
if (opt.orientation == Qt::Vertical)
size = size.transposed();
return style()->sizeFromContents(QStyle::CT_ProgressBar, &opt, size, this);
diff --git a/src/widgets/widgets/qprogressbar.h b/src/widgets/widgets/qprogressbar.h
index e0f5e9084b..ec9686068c 100644
--- a/src/widgets/widgets/qprogressbar.h
+++ b/src/widgets/widgets/qprogressbar.h
@@ -68,7 +68,7 @@ public:
enum Direction { TopToBottom, BottomToTop };
Q_ENUM(Direction)
- explicit QProgressBar(QWidget *parent = Q_NULLPTR);
+ explicit QProgressBar(QWidget *parent = nullptr);
~QProgressBar();
int minimum() const;
@@ -83,8 +83,8 @@ public:
Qt::Alignment alignment() const;
void setAlignment(Qt::Alignment alignment);
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ QSize minimumSizeHint() const override;
Qt::Orientation orientation() const;
@@ -109,8 +109,8 @@ Q_SIGNALS:
void valueChanged(int value);
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
+ void paintEvent(QPaintEvent *) override;
void initStyleOption(QStyleOptionProgressBar *option) const;
private:
diff --git a/src/widgets/widgets/qpushbutton.cpp b/src/widgets/widgets/qpushbutton.cpp
index 90b1e7ef29..afb17f533b 100644
--- a/src/widgets/widgets/qpushbutton.cpp
+++ b/src/widgets/widgets/qpushbutton.cpp
@@ -40,6 +40,7 @@
#include "qapplication.h"
#include "qbitmap.h"
#include "qdesktopwidget.h"
+#include <private/qdesktopwidget_p.h>
#if QT_CONFIG(dialog)
#include <private/qdialog_p.h>
#endif
@@ -58,10 +59,6 @@
#if QT_CONFIG(dialogbuttonbox)
#include "qdialogbuttonbox.h"
#endif
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
-#include "private/qmacstyle_mac_p.h"
-#include "private/qmacstyle_mac_p_p.h"
-#endif
#ifndef QT_NO_ACCESSIBILITY
#include "qaccessible.h"
@@ -83,7 +80,7 @@ QT_BEGIN_NAMESPACE
\ingroup basicwidgets
\inmodule QtWidgets
- \image windows-pushbutton.jpg
+ \image windows-pushbutton.png
The push button, or command button, is perhaps the most commonly
used widget in any graphical user interface. Push (click) a button
@@ -464,7 +461,7 @@ void QPushButton::keyPressEvent(QKeyEvent *e)
click();
break;
}
- // fall through
+ Q_FALLTHROUGH();
default:
QAbstractButton::keyPressEvent(e);
}
@@ -613,7 +610,7 @@ QPoint QPushButtonPrivate::adjustedMenuPosition()
QPoint globalPos = q->mapToGlobal(rect.topLeft());
int x = globalPos.x();
int y = globalPos.y();
- const QRect availableGeometry = QApplication::desktop()->availableGeometry(q);
+ const QRect availableGeometry = QDesktopWidgetPrivate::availableGeometry(q);
if (horizontal) {
if (globalPos.y() + rect.height() + menuSize.height() <= availableGeometry.bottom()) {
y += rect.height();
diff --git a/src/widgets/widgets/qpushbutton.h b/src/widgets/widgets/qpushbutton.h
index c005f320cc..b02ba63d07 100644
--- a/src/widgets/widgets/qpushbutton.h
+++ b/src/widgets/widgets/qpushbutton.h
@@ -61,13 +61,13 @@ class Q_WIDGETS_EXPORT QPushButton : public QAbstractButton
Q_PROPERTY(bool flat READ isFlat WRITE setFlat)
public:
- explicit QPushButton(QWidget *parent = Q_NULLPTR);
- explicit QPushButton(const QString &text, QWidget *parent = Q_NULLPTR);
- QPushButton(const QIcon& icon, const QString &text, QWidget *parent = Q_NULLPTR);
+ explicit QPushButton(QWidget *parent = nullptr);
+ explicit QPushButton(const QString &text, QWidget *parent = nullptr);
+ QPushButton(const QIcon& icon, const QString &text, QWidget *parent = nullptr);
~QPushButton();
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ QSize minimumSizeHint() const override;
bool autoDefault() const;
void setAutoDefault(bool);
@@ -88,13 +88,13 @@ public Q_SLOTS:
#endif
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE;
- void focusInEvent(QFocusEvent *) Q_DECL_OVERRIDE;
- void focusOutEvent(QFocusEvent *) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
+ void paintEvent(QPaintEvent *) override;
+ void keyPressEvent(QKeyEvent *) override;
+ void focusInEvent(QFocusEvent *) override;
+ void focusOutEvent(QFocusEvent *) override;
void initStyleOption(QStyleOptionButton *option) const;
- QPushButton(QPushButtonPrivate &dd, QWidget* parent = Q_NULLPTR);
+ QPushButton(QPushButtonPrivate &dd, QWidget* parent = nullptr);
public:
diff --git a/src/widgets/widgets/qradiobutton.cpp b/src/widgets/widgets/qradiobutton.cpp
index dfba32d3e8..fd8922ed28 100644
--- a/src/widgets/widgets/qradiobutton.cpp
+++ b/src/widgets/widgets/qradiobutton.cpp
@@ -72,6 +72,7 @@ void QRadioButtonPrivate::init()
q->setAutoExclusive(true);
q->setMouseTracking(true);
q->setForegroundRole(QPalette::WindowText);
+ q->setAttribute(Qt::WA_MacShowFocusRect);
setLayoutItemMargins(QStyle::SE_RadioButtonLayoutItem);
}
diff --git a/src/widgets/widgets/qradiobutton.h b/src/widgets/widgets/qradiobutton.h
index 137ae01380..c6b5ddce84 100644
--- a/src/widgets/widgets/qradiobutton.h
+++ b/src/widgets/widgets/qradiobutton.h
@@ -56,18 +56,18 @@ class Q_WIDGETS_EXPORT QRadioButton : public QAbstractButton
Q_OBJECT
public:
- explicit QRadioButton(QWidget *parent = Q_NULLPTR);
- explicit QRadioButton(const QString &text, QWidget *parent = Q_NULLPTR);
+ explicit QRadioButton(QWidget *parent = nullptr);
+ explicit QRadioButton(const QString &text, QWidget *parent = nullptr);
~QRadioButton();
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ QSize minimumSizeHint() const override;
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
- bool hitButton(const QPoint &) const Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
+ bool hitButton(const QPoint &) const override;
+ void paintEvent(QPaintEvent *) override;
+ void mouseMoveEvent(QMouseEvent *) override;
void initStyleOption(QStyleOptionButton *button) const;
diff --git a/src/widgets/widgets/qrubberband.h b/src/widgets/widgets/qrubberband.h
index a05eb0d543..c683c24a18 100644
--- a/src/widgets/widgets/qrubberband.h
+++ b/src/widgets/widgets/qrubberband.h
@@ -56,7 +56,7 @@ class Q_WIDGETS_EXPORT QRubberBand : public QWidget
public:
enum Shape { Line, Rectangle };
- explicit QRubberBand(Shape, QWidget * = Q_NULLPTR);
+ explicit QRubberBand(Shape, QWidget * = nullptr);
~QRubberBand();
Shape shape() const;
@@ -73,12 +73,12 @@ public:
{ resize(s.width(), s.height()); }
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
- void changeEvent(QEvent *) Q_DECL_OVERRIDE;
- void showEvent(QShowEvent *) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
- void moveEvent(QMoveEvent *) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
+ void paintEvent(QPaintEvent *) override;
+ void changeEvent(QEvent *) override;
+ void showEvent(QShowEvent *) override;
+ void resizeEvent(QResizeEvent *) override;
+ void moveEvent(QMoveEvent *) override;
void initStyleOption(QStyleOptionRubberBand *option) const;
private:
diff --git a/src/widgets/widgets/qscrollarea.h b/src/widgets/widgets/qscrollarea.h
index d38bced2f2..6d252821c5 100644
--- a/src/widgets/widgets/qscrollarea.h
+++ b/src/widgets/widgets/qscrollarea.h
@@ -56,7 +56,7 @@ class Q_WIDGETS_EXPORT QScrollArea : public QAbstractScrollArea
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
public:
- explicit QScrollArea(QWidget *parent = Q_NULLPTR);
+ explicit QScrollArea(QWidget *parent = nullptr);
~QScrollArea();
QWidget *widget() const;
@@ -66,9 +66,9 @@ public:
bool widgetResizable() const;
void setWidgetResizable(bool resizable);
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
- bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE;
+ bool focusNextPrevChild(bool next) override;
Qt::Alignment alignment() const;
void setAlignment(Qt::Alignment);
@@ -77,13 +77,13 @@ public:
void ensureWidgetVisible(QWidget *childWidget, int xmargin = 50, int ymargin = 50);
protected:
- QScrollArea(QScrollAreaPrivate &dd, QWidget *parent = Q_NULLPTR);
- bool event(QEvent *) Q_DECL_OVERRIDE;
- bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
- void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE;
+ QScrollArea(QScrollAreaPrivate &dd, QWidget *parent = nullptr);
+ bool event(QEvent *) override;
+ bool eventFilter(QObject *, QEvent *) override;
+ void resizeEvent(QResizeEvent *) override;
+ void scrollContentsBy(int dx, int dy) override;
- QSize viewportSizeHint() const Q_DECL_OVERRIDE;
+ QSize viewportSizeHint() const override;
private:
Q_DECLARE_PRIVATE(QScrollArea)
diff --git a/src/widgets/widgets/qscrollbar.h b/src/widgets/widgets/qscrollbar.h
index 22b9bfcddb..171195fd24 100644
--- a/src/widgets/widgets/qscrollbar.h
+++ b/src/widgets/widgets/qscrollbar.h
@@ -56,25 +56,25 @@ class Q_WIDGETS_EXPORT QScrollBar : public QAbstractSlider
{
Q_OBJECT
public:
- explicit QScrollBar(QWidget *parent = Q_NULLPTR);
- explicit QScrollBar(Qt::Orientation, QWidget *parent = Q_NULLPTR);
+ explicit QScrollBar(QWidget *parent = nullptr);
+ explicit QScrollBar(Qt::Orientation, QWidget *parent = nullptr);
~QScrollBar();
- QSize sizeHint() const Q_DECL_OVERRIDE;
- bool event(QEvent *event) Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ bool event(QEvent *event) override;
protected:
#if QT_CONFIG(wheelevent)
- void wheelEvent(QWheelEvent *) Q_DECL_OVERRIDE;
+ void wheelEvent(QWheelEvent *) override;
#endif
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void hideEvent(QHideEvent*) Q_DECL_OVERRIDE;
- void sliderChange(SliderChange change) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent *) override;
+ void mousePressEvent(QMouseEvent *) override;
+ void mouseReleaseEvent(QMouseEvent *) override;
+ void mouseMoveEvent(QMouseEvent *) override;
+ void hideEvent(QHideEvent*) override;
+ void sliderChange(SliderChange change) override;
#ifndef QT_NO_CONTEXTMENU
- void contextMenuEvent(QContextMenuEvent *) Q_DECL_OVERRIDE;
+ void contextMenuEvent(QContextMenuEvent *) override;
#endif
void initStyleOption(QStyleOptionSlider *option) const;
diff --git a/src/widgets/widgets/qsizegrip.cpp b/src/widgets/widgets/qsizegrip.cpp
index 1e1d847751..dc5a7158dd 100644
--- a/src/widgets/widgets/qsizegrip.cpp
+++ b/src/widgets/widgets/qsizegrip.cpp
@@ -55,6 +55,7 @@
#endif
#include <private/qwidget_p.h>
+#include <private/qdesktopwidget_p.h>
#include <QtWidgets/qabstractscrollarea.h>
QT_BEGIN_NAMESPACE
@@ -312,7 +313,7 @@ void QSizeGrip::mousePressEvent(QMouseEvent * e)
bool hasVerticalSizeConstraint = true;
bool hasHorizontalSizeConstraint = true;
if (tlw->isWindow())
- availableGeometry = QApplication::desktop()->availableGeometry(tlw);
+ availableGeometry = QDesktopWidgetPrivate::availableGeometry(tlw);
else {
const QWidget *tlwParent = tlw->parentWidget();
// Check if tlw is inside QAbstractScrollArea/QScrollArea.
diff --git a/src/widgets/widgets/qsizegrip.h b/src/widgets/widgets/qsizegrip.h
index 6ad2405339..5285ffdfb8 100644
--- a/src/widgets/widgets/qsizegrip.h
+++ b/src/widgets/widgets/qsizegrip.h
@@ -55,19 +55,19 @@ public:
explicit QSizeGrip(QWidget *parent);
~QSizeGrip();
- QSize sizeHint() const Q_DECL_OVERRIDE;
- void setVisible(bool) Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ void setVisible(bool) override;
protected:
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *mouseEvent) Q_DECL_OVERRIDE;
- void moveEvent(QMoveEvent *moveEvent) Q_DECL_OVERRIDE;
- void showEvent(QShowEvent *showEvent) Q_DECL_OVERRIDE;
- void hideEvent(QHideEvent *hideEvent) Q_DECL_OVERRIDE;
- bool eventFilter(QObject *, QEvent *) Q_DECL_OVERRIDE;
- bool event(QEvent *) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent *) override;
+ void mousePressEvent(QMouseEvent *) override;
+ void mouseMoveEvent(QMouseEvent *) override;
+ void mouseReleaseEvent(QMouseEvent *mouseEvent) override;
+ void moveEvent(QMoveEvent *moveEvent) override;
+ void showEvent(QShowEvent *showEvent) override;
+ void hideEvent(QHideEvent *hideEvent) override;
+ bool eventFilter(QObject *, QEvent *) override;
+ bool event(QEvent *) override;
public:
diff --git a/src/widgets/widgets/qslider.h b/src/widgets/widgets/qslider.h
index 642e836af7..f74f9c8576 100644
--- a/src/widgets/widgets/qslider.h
+++ b/src/widgets/widgets/qslider.h
@@ -68,13 +68,13 @@ public:
};
Q_ENUM(TickPosition)
- explicit QSlider(QWidget *parent = Q_NULLPTR);
- explicit QSlider(Qt::Orientation orientation, QWidget *parent = Q_NULLPTR);
+ explicit QSlider(QWidget *parent = nullptr);
+ explicit QSlider(Qt::Orientation orientation, QWidget *parent = nullptr);
~QSlider();
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ QSize minimumSizeHint() const override;
void setTickPosition(TickPosition position);
TickPosition tickPosition() const;
@@ -82,13 +82,13 @@ public:
void setTickInterval(int ti);
int tickInterval() const;
- bool event(QEvent *event) Q_DECL_OVERRIDE;
+ bool event(QEvent *event) override;
protected:
- void paintEvent(QPaintEvent *ev) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *ev) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *ev) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *ev) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent *ev) override;
+ void mousePressEvent(QMouseEvent *ev) override;
+ void mouseReleaseEvent(QMouseEvent *ev) override;
+ void mouseMoveEvent(QMouseEvent *ev) override;
void initStyleOption(QStyleOptionSlider *option) const;
diff --git a/src/widgets/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp
index b62a7768ce..561215ec85 100644
--- a/src/widgets/widgets/qspinbox.cpp
+++ b/src/widgets/widgets/qspinbox.cpp
@@ -61,10 +61,10 @@ class QSpinBoxPrivate : public QAbstractSpinBoxPrivate
Q_DECLARE_PUBLIC(QSpinBox)
public:
QSpinBoxPrivate();
- void emitSignals(EmitPolicy ep, const QVariant &) Q_DECL_OVERRIDE;
+ void emitSignals(EmitPolicy ep, const QVariant &) override;
- virtual QVariant valueFromText(const QString &n) const Q_DECL_OVERRIDE;
- virtual QString textFromValue(const QVariant &n) const Q_DECL_OVERRIDE;
+ virtual QVariant valueFromText(const QString &n) const override;
+ virtual QString textFromValue(const QVariant &n) const override;
QVariant validateAndInterpret(QString &input, int &pos,
QValidator::State &state) const;
@@ -82,10 +82,10 @@ class QDoubleSpinBoxPrivate : public QAbstractSpinBoxPrivate
Q_DECLARE_PUBLIC(QDoubleSpinBox)
public:
QDoubleSpinBoxPrivate();
- void emitSignals(EmitPolicy ep, const QVariant &) Q_DECL_OVERRIDE;
+ void emitSignals(EmitPolicy ep, const QVariant &) override;
- virtual QVariant valueFromText(const QString &n) const Q_DECL_OVERRIDE;
- virtual QString textFromValue(const QVariant &n) const Q_DECL_OVERRIDE;
+ virtual QVariant valueFromText(const QString &n) const override;
+ virtual QString textFromValue(const QVariant &n) const override;
QVariant validateAndInterpret(QString &input, int &pos,
QValidator::State &state) const;
double round(double input) const;
diff --git a/src/widgets/widgets/qspinbox.h b/src/widgets/widgets/qspinbox.h
index b61e665413..73489c9a68 100644
--- a/src/widgets/widgets/qspinbox.h
+++ b/src/widgets/widgets/qspinbox.h
@@ -62,7 +62,7 @@ class Q_WIDGETS_EXPORT QSpinBox : public QAbstractSpinBox
Q_PROPERTY(int displayIntegerBase READ displayIntegerBase WRITE setDisplayIntegerBase)
public:
- explicit QSpinBox(QWidget *parent = Q_NULLPTR);
+ explicit QSpinBox(QWidget *parent = nullptr);
~QSpinBox();
int value() const;
@@ -123,7 +123,7 @@ class Q_WIDGETS_EXPORT QDoubleSpinBox : public QAbstractSpinBox
Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep)
Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged USER true)
public:
- explicit QDoubleSpinBox(QWidget *parent = Q_NULLPTR);
+ explicit QDoubleSpinBox(QWidget *parent = nullptr);
~QDoubleSpinBox();
double value() const;
diff --git a/src/widgets/widgets/qsplashscreen.cpp b/src/widgets/widgets/qsplashscreen.cpp
index fb92d5de0d..468fc272b5 100644
--- a/src/widgets/widgets/qsplashscreen.cpp
+++ b/src/widgets/widgets/qsplashscreen.cpp
@@ -41,6 +41,7 @@
#include "qapplication.h"
#include "qdesktopwidget.h"
+#include <private/qdesktopwidget_p.h>
#include "qpainter.h"
#include "qpixmap.h"
#include "qtextdocument.h"
@@ -140,7 +141,7 @@ QSplashScreen::QSplashScreen(const QPixmap &pixmap, Qt::WindowFlags f)
one. In that case pass the proper desktop() as the \a parent.
*/
QSplashScreen::QSplashScreen(QWidget *parent, const QPixmap &pixmap, Qt::WindowFlags f)
- : QWidget(*new QSplashScreenPrivate, parent, Qt::SplashScreen | f)
+ : QWidget(*new QSplashScreenPrivate, parent, Qt::SplashScreen | Qt::FramelessWindowHint | f)
{
d_func()->pixmap = pixmap;
setPixmap(d_func()->pixmap); // Does an implicit repaint
@@ -282,7 +283,7 @@ void QSplashScreen::setPixmap(const QPixmap &pixmap)
QRect r(QPoint(), d->pixmap.size() / d->pixmap.devicePixelRatio());
resize(r.size());
- move(QApplication::desktop()->screenGeometry().center() - r.center());
+ move(QDesktopWidgetPrivate::screenGeometry().center() - r.center());
if (isVisible())
repaint();
}
diff --git a/src/widgets/widgets/qsplashscreen.h b/src/widgets/widgets/qsplashscreen.h
index 1971b8bacf..8bdf4e7749 100644
--- a/src/widgets/widgets/qsplashscreen.h
+++ b/src/widgets/widgets/qsplashscreen.h
@@ -73,9 +73,9 @@ Q_SIGNALS:
void messageChanged(const QString &message);
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
virtual void drawContents(QPainter *painter);
- void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
+ void mousePressEvent(QMouseEvent *) override;
private:
Q_DISABLE_COPY(QSplashScreen)
diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp
index 5f49623941..8e4c846402 100644
--- a/src/widgets/widgets/qsplitter.cpp
+++ b/src/widgets/widgets/qsplitter.cpp
@@ -1372,7 +1372,7 @@ bool QSplitter::event(QEvent *e)
if (!d->firstShow)
break;
d->firstShow = false;
- // fall through
+ Q_FALLTHROUGH();
case QEvent::HideToParent:
case QEvent::ShowToParent:
case QEvent::LayoutRequest:
diff --git a/src/widgets/widgets/qsplitter.h b/src/widgets/widgets/qsplitter.h
index bc4d7bca39..16fac48d1c 100644
--- a/src/widgets/widgets/qsplitter.h
+++ b/src/widgets/widgets/qsplitter.h
@@ -64,8 +64,8 @@ class Q_WIDGETS_EXPORT QSplitter : public QFrame
Q_PROPERTY(bool childrenCollapsible READ childrenCollapsible WRITE setChildrenCollapsible)
public:
- explicit QSplitter(QWidget* parent = Q_NULLPTR);
- explicit QSplitter(Qt::Orientation, QWidget* parent = Q_NULLPTR);
+ explicit QSplitter(QWidget* parent = nullptr);
+ explicit QSplitter(Qt::Orientation, QWidget* parent = nullptr);
~QSplitter();
void addWidget(QWidget *widget);
@@ -84,8 +84,8 @@ public:
bool opaqueResize() const;
void refresh();
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ QSize minimumSizeHint() const override;
QList<int> sizes() const;
void setSizes(const QList<int> &list);
@@ -111,12 +111,12 @@ Q_SIGNALS:
protected:
virtual QSplitterHandle *createHandle();
- void childEvent(QChildEvent *) Q_DECL_OVERRIDE;
+ void childEvent(QChildEvent *) override;
- bool event(QEvent *) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
+ bool event(QEvent *) override;
+ void resizeEvent(QResizeEvent *) override;
- void changeEvent(QEvent *) Q_DECL_OVERRIDE;
+ void changeEvent(QEvent *) override;
void moveSplitter(int pos, int index);
void setRubberBand(int position);
int closestLegalPosition(int, int);
@@ -145,15 +145,15 @@ public:
bool opaqueResize() const;
QSplitter *splitter() const;
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
protected:
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
- void mouseMoveEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
- bool event(QEvent *) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent *) override;
+ void mouseMoveEvent(QMouseEvent *) override;
+ void mousePressEvent(QMouseEvent *) override;
+ void mouseReleaseEvent(QMouseEvent *) override;
+ void resizeEvent(QResizeEvent *) override;
+ bool event(QEvent *) override;
void moveSplitter(int p);
int closestLegalPosition(int p);
diff --git a/src/widgets/widgets/qstackedwidget.cpp b/src/widgets/widgets/qstackedwidget.cpp
index 9d92855a40..2217dab870 100644
--- a/src/widgets/widgets/qstackedwidget.cpp
+++ b/src/widgets/widgets/qstackedwidget.cpp
@@ -101,7 +101,7 @@ public:
widget is removed from the stacked widget, the currentChanged()
and widgetRemoved() signals are emitted respectively.
- \sa QStackedLayout, QTabWidget, {Config Dialog Example}
+ \sa QStackedLayout, QTabWidget
*/
/*!
diff --git a/src/widgets/widgets/qstackedwidget.h b/src/widgets/widgets/qstackedwidget.h
index 29df145b70..5508f905d4 100644
--- a/src/widgets/widgets/qstackedwidget.h
+++ b/src/widgets/widgets/qstackedwidget.h
@@ -56,7 +56,7 @@ class Q_WIDGETS_EXPORT QStackedWidget : public QFrame
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
Q_PROPERTY(int count READ count)
public:
- explicit QStackedWidget(QWidget *parent = Q_NULLPTR);
+ explicit QStackedWidget(QWidget *parent = nullptr);
~QStackedWidget();
int addWidget(QWidget *w);
@@ -79,7 +79,7 @@ Q_SIGNALS:
void widgetRemoved(int index);
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
private:
Q_DISABLE_COPY(QStackedWidget)
diff --git a/src/widgets/widgets/qstatusbar.cpp b/src/widgets/widgets/qstatusbar.cpp
index 4635b73a81..fb551158bf 100644
--- a/src/widgets/widgets/qstatusbar.cpp
+++ b/src/widgets/widgets/qstatusbar.cpp
@@ -601,7 +601,7 @@ QString QStatusBar::currentMessage() const
}
/*!
- \fn QStatusBar::messageChanged(const QString &message)
+ \fn void QStatusBar::messageChanged(const QString &message)
This signal is emitted whenever the temporary status message
changes. The new temporary message is passed in the \a message
diff --git a/src/widgets/widgets/qstatusbar.h b/src/widgets/widgets/qstatusbar.h
index 9ac637931c..2492e8487f 100644
--- a/src/widgets/widgets/qstatusbar.h
+++ b/src/widgets/widgets/qstatusbar.h
@@ -56,7 +56,7 @@ class Q_WIDGETS_EXPORT QStatusBar: public QWidget
Q_PROPERTY(bool sizeGripEnabled READ isSizeGripEnabled WRITE setSizeGripEnabled)
public:
- explicit QStatusBar(QWidget *parent = Q_NULLPTR);
+ explicit QStatusBar(QWidget *parent = nullptr);
virtual ~QStatusBar();
void addWidget(QWidget *widget, int stretch = 0);
@@ -79,14 +79,14 @@ Q_SIGNALS:
void messageChanged(const QString &text);
protected:
- void showEvent(QShowEvent *) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
+ void showEvent(QShowEvent *) override;
+ void paintEvent(QPaintEvent *) override;
+ void resizeEvent(QResizeEvent *) override;
// ### Qt 6: consider making reformat() and hideOrShow() private
void reformat();
void hideOrShow();
- bool event(QEvent *) Q_DECL_OVERRIDE;
+ bool event(QEvent *) override;
private:
Q_DISABLE_COPY(QStatusBar)
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index adaafc7d21..258e018151 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -1034,7 +1034,7 @@ void QTabBar::removeTab(int index)
newIndex--;
if (d->validIndex(newIndex))
break;
- // else fallthrough
+ Q_FALLTHROUGH();
case SelectRightTab:
newIndex = index;
if (newIndex >= d->tabList.size())
@@ -2221,7 +2221,7 @@ void QTabBar::changeEvent(QEvent *event)
d->elideMode = Qt::TextElideMode(style()->styleHint(QStyle::SH_TabBar_ElideMode, 0, this));
if (!d->useScrollButtonsSetByUser)
d->useScrollButtons = !style()->styleHint(QStyle::SH_TabBar_PreferNoArrows, 0, this);
- // fallthrough
+ Q_FALLTHROUGH();
case QEvent::FontChange:
d->textSizes.clear();
d->refresh();
diff --git a/src/widgets/widgets/qtabbar.h b/src/widgets/widgets/qtabbar.h
index ebcd1094ef..fc619355f0 100644
--- a/src/widgets/widgets/qtabbar.h
+++ b/src/widgets/widgets/qtabbar.h
@@ -71,7 +71,7 @@ class Q_WIDGETS_EXPORT QTabBar: public QWidget
Q_PROPERTY(bool changeCurrentOnDrag READ changeCurrentOnDrag WRITE setChangeCurrentOnDrag)
public:
- explicit QTabBar(QWidget *parent = Q_NULLPTR);
+ explicit QTabBar(QWidget *parent = nullptr);
~QTabBar();
enum Shape { RoundedNorth, RoundedSouth, RoundedWest, RoundedEast,
@@ -136,8 +136,8 @@ public:
int currentIndex() const;
int count() const;
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ QSize minimumSizeHint() const override;
void setDrawBase(bool drawTheBase);
bool drawBase() const;
@@ -194,20 +194,20 @@ protected:
virtual void tabRemoved(int index);
virtual void tabLayoutChange();
- bool event(QEvent *) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
- void showEvent(QShowEvent *) Q_DECL_OVERRIDE;
- void hideEvent(QHideEvent *) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
- void mousePressEvent (QMouseEvent *) Q_DECL_OVERRIDE;
- void mouseMoveEvent (QMouseEvent *) Q_DECL_OVERRIDE;
- void mouseReleaseEvent (QMouseEvent *) Q_DECL_OVERRIDE;
+ bool event(QEvent *) override;
+ void resizeEvent(QResizeEvent *) override;
+ void showEvent(QShowEvent *) override;
+ void hideEvent(QHideEvent *) override;
+ void paintEvent(QPaintEvent *) override;
+ void mousePressEvent (QMouseEvent *) override;
+ void mouseMoveEvent (QMouseEvent *) override;
+ void mouseReleaseEvent (QMouseEvent *) override;
#if QT_CONFIG(wheelevent)
- void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
+ void wheelEvent(QWheelEvent *event) override;
#endif
- void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE;
- void changeEvent(QEvent *) Q_DECL_OVERRIDE;
- void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE;
+ void keyPressEvent(QKeyEvent *) override;
+ void changeEvent(QEvent *) override;
+ void timerEvent(QTimerEvent *event) override;
void initStyleOption(QStyleOptionTab *option, int tabIndex) const;
#ifndef QT_NO_ACCESSIBILITY
diff --git a/src/widgets/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h
index 52e139c707..1092878f2c 100644
--- a/src/widgets/widgets/qtabbar_p.h
+++ b/src/widgets/widgets/qtabbar_p.h
@@ -71,17 +71,17 @@ QT_BEGIN_NAMESPACE
class QMovableTabWidget : public QWidget
{
public:
- explicit QMovableTabWidget(QWidget *parent = Q_NULLPTR);
+ explicit QMovableTabWidget(QWidget *parent = nullptr);
void setPixmap(const QPixmap &pixmap);
protected:
- void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent *e) override;
private:
QPixmap m_pixmap;
};
-class QTabBarPrivate : public QWidgetPrivate
+class Q_WIDGETS_EXPORT QTabBarPrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QTabBar)
public:
@@ -142,9 +142,9 @@ public:
TabBarAnimation(Tab *t, QTabBarPrivate *_priv) : tab(t), priv(_priv)
{ setEasingCurve(QEasingCurve::InOutQuad); }
- void updateCurrentValue(const QVariant &current) Q_DECL_OVERRIDE;
+ void updateCurrentValue(const QVariant &current) override;
- void updateState(State, State newState) Q_DECL_OVERRIDE;
+ void updateState(State, State newState) override;
private:
//these are needed for the callbacks
Tab *tab;
@@ -180,7 +180,7 @@ public:
int indexAtPos(const QPoint &p) const;
- inline bool isAnimated() const { Q_Q(const QTabBar); return q->style()->styleHint(QStyle::SH_Widget_Animate, 0, q); }
+ inline bool isAnimated() const { Q_Q(const QTabBar); return q->style()->styleHint(QStyle::SH_Widget_Animation_Duration, 0, q) > 0; }
inline bool validIndex(int index) const { return index >= 0 && index < tabList.count(); }
void setCurrentNextEnabledIndex(int offset);
@@ -278,12 +278,12 @@ class CloseButton : public QAbstractButton
public:
explicit CloseButton(QWidget *parent = 0);
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSizeHint() const Q_DECL_OVERRIDE
+ QSize sizeHint() const override;
+ QSize minimumSizeHint() const override
{ return sizeHint(); }
- void enterEvent(QEvent *event) Q_DECL_OVERRIDE;
- void leaveEvent(QEvent *event) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
+ void enterEvent(QEvent *event) override;
+ void leaveEvent(QEvent *event) override;
+ void paintEvent(QPaintEvent *event) override;
};
QT_END_NAMESPACE
diff --git a/src/widgets/widgets/qtabwidget.cpp b/src/widgets/widgets/qtabwidget.cpp
index dc866a38cf..60a924510a 100644
--- a/src/widgets/widgets/qtabwidget.cpp
+++ b/src/widgets/widgets/qtabwidget.cpp
@@ -44,6 +44,7 @@
#include "qapplication.h"
#include "qbitmap.h"
#include "qdesktopwidget.h"
+#include <private/qdesktopwidget_p.h>
#include "qevent.h"
#include "qlayout.h"
#include "qstackedwidget.h"
@@ -844,7 +845,7 @@ QSize QTabWidget::sizeHint() const
if(usesScrollButtons())
t = t.boundedTo(QSize(200,200));
else
- t = t.boundedTo(QApplication::desktop()->size());
+ t = t.boundedTo(QDesktopWidgetPrivate::size());
QSize sz = basicSize(d->pos == North || d->pos == South, lc, rc, s, t);
@@ -912,7 +913,7 @@ int QTabWidget::heightForWidth(int width) const
if(usesScrollButtons())
t = t.boundedTo(QSize(200,200));
else
- t = t.boundedTo(QApplication::desktop()->size());
+ t = t.boundedTo(QDesktopWidgetPrivate::size());
const bool tabIsHorizontal = (d->pos == North || d->pos == South);
const int contentsWidth = width - padding.width();
diff --git a/src/widgets/widgets/qtabwidget.h b/src/widgets/widgets/qtabwidget.h
index b80fdba1fb..f55e71488b 100644
--- a/src/widgets/widgets/qtabwidget.h
+++ b/src/widgets/widgets/qtabwidget.h
@@ -68,7 +68,7 @@ class Q_WIDGETS_EXPORT QTabWidget : public QWidget
Q_PROPERTY(bool tabBarAutoHide READ tabBarAutoHide WRITE setTabBarAutoHide)
public:
- explicit QTabWidget(QWidget *parent = Q_NULLPTR);
+ explicit QTabWidget(QWidget *parent = nullptr);
~QTabWidget();
int addTab(QWidget *widget, const QString &);
@@ -120,10 +120,10 @@ public:
TabShape tabShape() const;
void setTabShape(TabShape s);
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSizeHint() const Q_DECL_OVERRIDE;
- int heightForWidth(int width) const Q_DECL_OVERRIDE;
- bool hasHeightForWidth() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ QSize minimumSizeHint() const override;
+ int heightForWidth(int width) const override;
+ bool hasHeightForWidth() const override;
void setCornerWidget(QWidget * w, Qt::Corner corner = Qt::TopRightCorner);
QWidget * cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const;
@@ -161,13 +161,13 @@ protected:
virtual void tabInserted(int index);
virtual void tabRemoved(int index);
- void showEvent(QShowEvent *) Q_DECL_OVERRIDE;
- void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE;
- void keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
+ void showEvent(QShowEvent *) override;
+ void resizeEvent(QResizeEvent *) override;
+ void keyPressEvent(QKeyEvent *) override;
+ void paintEvent(QPaintEvent *) override;
void setTabBar(QTabBar *);
- void changeEvent(QEvent *) Q_DECL_OVERRIDE;
- bool event(QEvent *) Q_DECL_OVERRIDE;
+ void changeEvent(QEvent *) override;
+ bool event(QEvent *) override;
void initStyleOption(QStyleOptionTabWidgetFrame *option) const;
diff --git a/src/widgets/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp
index 0797120960..fa4dd14c92 100644
--- a/src/widgets/widgets/qtextbrowser.cpp
+++ b/src/widgets/widgets/qtextbrowser.cpp
@@ -135,7 +135,7 @@ public:
void setSource(const QUrl &url);
// re-imlemented from QTextEditPrivate
- virtual QUrl resolveUrl(const QUrl &url) const Q_DECL_OVERRIDE;
+ virtual QUrl resolveUrl(const QUrl &url) const override;
inline QUrl resolveUrl(const QString &url) const
{ return resolveUrl(QUrl(url)); }
diff --git a/src/widgets/widgets/qtextbrowser.h b/src/widgets/widgets/qtextbrowser.h
index f36c86bc86..ea81256f50 100644
--- a/src/widgets/widgets/qtextbrowser.h
+++ b/src/widgets/widgets/qtextbrowser.h
@@ -63,7 +63,7 @@ class Q_WIDGETS_EXPORT QTextBrowser : public QTextEdit
Q_PROPERTY(bool openLinks READ openLinks WRITE setOpenLinks)
public:
- explicit QTextBrowser(QWidget* parent = Q_NULLPTR);
+ explicit QTextBrowser(QWidget* parent = nullptr);
virtual ~QTextBrowser();
QUrl source() const;
@@ -71,7 +71,7 @@ public:
QStringList searchPaths() const;
void setSearchPaths(const QStringList &paths);
- virtual QVariant loadResource(int type, const QUrl &name) Q_DECL_OVERRIDE;
+ virtual QVariant loadResource(int type, const QUrl &name) override;
bool isBackwardAvailable() const;
bool isForwardAvailable() const;
@@ -104,14 +104,14 @@ Q_SIGNALS:
void anchorClicked(const QUrl &);
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
- virtual void keyPressEvent(QKeyEvent *ev) Q_DECL_OVERRIDE;
- virtual void mouseMoveEvent(QMouseEvent *ev) Q_DECL_OVERRIDE;
- virtual void mousePressEvent(QMouseEvent *ev) Q_DECL_OVERRIDE;
- virtual void mouseReleaseEvent(QMouseEvent *ev) Q_DECL_OVERRIDE;
- virtual void focusOutEvent(QFocusEvent *ev) Q_DECL_OVERRIDE;
- virtual bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE;
- virtual void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
+ virtual void keyPressEvent(QKeyEvent *ev) override;
+ virtual void mouseMoveEvent(QMouseEvent *ev) override;
+ virtual void mousePressEvent(QMouseEvent *ev) override;
+ virtual void mouseReleaseEvent(QMouseEvent *ev) override;
+ virtual void focusOutEvent(QFocusEvent *ev) override;
+ virtual bool focusNextPrevChild(bool next) override;
+ virtual void paintEvent(QPaintEvent *e) override;
private:
Q_DISABLE_COPY(QTextBrowser)
diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp
index 374267f9f2..95c85dc4fe 100644
--- a/src/widgets/widgets/qtextedit.cpp
+++ b/src/widgets/widgets/qtextedit.cpp
@@ -84,19 +84,19 @@ class QTextEditControl : public QWidgetTextControl
public:
inline QTextEditControl(QObject *parent) : QWidgetTextControl(parent) {}
- virtual QMimeData *createMimeDataFromSelection() const Q_DECL_OVERRIDE {
+ virtual QMimeData *createMimeDataFromSelection() const override {
QTextEdit *ed = qobject_cast<QTextEdit *>(parent());
if (!ed)
return QWidgetTextControl::createMimeDataFromSelection();
return ed->createMimeDataFromSelection();
}
- virtual bool canInsertFromMimeData(const QMimeData *source) const Q_DECL_OVERRIDE {
+ virtual bool canInsertFromMimeData(const QMimeData *source) const override {
QTextEdit *ed = qobject_cast<QTextEdit *>(parent());
if (!ed)
return QWidgetTextControl::canInsertFromMimeData(source);
return ed->canInsertFromMimeData(source);
}
- virtual void insertFromMimeData(const QMimeData *source) Q_DECL_OVERRIDE {
+ virtual void insertFromMimeData(const QMimeData *source) override {
QTextEdit *ed = qobject_cast<QTextEdit *>(parent());
if (!ed)
QWidgetTextControl::insertFromMimeData(source);
@@ -1955,27 +1955,48 @@ void QTextEdit::setOverwriteMode(bool overwrite)
d->control->setOverwriteMode(overwrite);
}
+#if QT_DEPRECATED_SINCE(5, 10)
/*!
\property QTextEdit::tabStopWidth
\brief the tab stop width in pixels
\since 4.1
+ \deprecated in Qt 5.10. Use tabStopDistance instead.
By default, this property contains a value of 80 pixels.
*/
int QTextEdit::tabStopWidth() const
{
- Q_D(const QTextEdit);
- return qRound(d->control->document()->defaultTextOption().tabStop());
+ return qRound(tabStopDistance());
}
void QTextEdit::setTabStopWidth(int width)
{
+ setTabStopDistance(width);
+}
+#endif
+
+/*!
+ \property QTextEdit::tabStopDistance
+ \brief the tab stop distance in pixels
+ \since 5.10
+
+ By default, this property contains a value of 80 pixels.
+*/
+
+qreal QTextEdit::tabStopDistance() const
+{
+ Q_D(const QTextEdit);
+ return d->control->document()->defaultTextOption().tabStopDistance();
+}
+
+void QTextEdit::setTabStopDistance(qreal distance)
+{
Q_D(QTextEdit);
QTextOption opt = d->control->document()->defaultTextOption();
- if (opt.tabStop() == width || width < 0)
+ if (opt.tabStopDistance() == distance || distance < 0)
return;
- opt.setTabStop(width);
+ opt.setTabStopDistance(distance);
d->control->document()->setDefaultTextOption(opt);
}
diff --git a/src/widgets/widgets/qtextedit.h b/src/widgets/widgets/qtextedit.h
index ff52fde2ed..9e0913160d 100644
--- a/src/widgets/widgets/qtextedit.h
+++ b/src/widgets/widgets/qtextedit.h
@@ -75,7 +75,10 @@ class Q_WIDGETS_EXPORT QTextEdit : public QAbstractScrollArea
#endif
Q_PROPERTY(QString plainText READ toPlainText WRITE setPlainText DESIGNABLE false)
Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode)
+#if QT_DEPRECATED_SINCE(5, 10)
Q_PROPERTY(int tabStopWidth READ tabStopWidth WRITE setTabStopWidth)
+#endif
+ Q_PROPERTY(qreal tabStopDistance READ tabStopDistance WRITE setTabStopDistance)
Q_PROPERTY(bool acceptRichText READ acceptRichText WRITE setAcceptRichText)
Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
@@ -99,8 +102,8 @@ public:
Q_DECLARE_FLAGS(AutoFormatting, AutoFormattingFlag)
Q_FLAG(AutoFormatting)
- explicit QTextEdit(QWidget *parent = Q_NULLPTR);
- explicit QTextEdit(const QString &text, QWidget *parent = Q_NULLPTR);
+ explicit QTextEdit(QWidget *parent = nullptr);
+ explicit QTextEdit(const QString &text, QWidget *parent = nullptr);
virtual ~QTextEdit();
void setDocument(QTextDocument *document);
@@ -185,8 +188,13 @@ public:
bool overwriteMode() const;
void setOverwriteMode(bool overwrite);
- int tabStopWidth() const;
- void setTabStopWidth(int width);
+#if QT_DEPRECATED_SINCE(5, 10)
+ QT_DEPRECATED int tabStopWidth() const;
+ QT_DEPRECATED void setTabStopWidth(int width);
+#endif
+
+ qreal tabStopDistance() const;
+ void setTabStopDistance(qreal distance);
int cursorWidth() const;
void setCursorWidth(int width);
@@ -208,7 +216,7 @@ public:
void print(QPagedPaintDevice *printer) const;
- QVariant inputMethodQuery(Qt::InputMethodQuery property) const Q_DECL_OVERRIDE;
+ QVariant inputMethodQuery(Qt::InputMethodQuery property) const override;
Q_INVOKABLE QVariant inputMethodQuery(Qt::InputMethodQuery query, QVariant argument) const;
public Q_SLOTS:
@@ -262,43 +270,43 @@ Q_SIGNALS:
void cursorPositionChanged();
protected:
- virtual bool event(QEvent *e) Q_DECL_OVERRIDE;
- virtual void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE;
- virtual void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
- virtual void keyReleaseEvent(QKeyEvent *e) Q_DECL_OVERRIDE;
- virtual void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
- virtual void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
- virtual void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- virtual void mouseMoveEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- virtual void mouseReleaseEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- virtual void mouseDoubleClickEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
- virtual bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE;
+ virtual bool event(QEvent *e) override;
+ virtual void timerEvent(QTimerEvent *e) override;
+ virtual void keyPressEvent(QKeyEvent *e) override;
+ virtual void keyReleaseEvent(QKeyEvent *e) override;
+ virtual void resizeEvent(QResizeEvent *e) override;
+ virtual void paintEvent(QPaintEvent *e) override;
+ virtual void mousePressEvent(QMouseEvent *e) override;
+ virtual void mouseMoveEvent(QMouseEvent *e) override;
+ virtual void mouseReleaseEvent(QMouseEvent *e) override;
+ virtual void mouseDoubleClickEvent(QMouseEvent *e) override;
+ virtual bool focusNextPrevChild(bool next) override;
#ifndef QT_NO_CONTEXTMENU
- virtual void contextMenuEvent(QContextMenuEvent *e) Q_DECL_OVERRIDE;
+ virtual void contextMenuEvent(QContextMenuEvent *e) override;
#endif
#ifndef QT_NO_DRAGANDDROP
- virtual void dragEnterEvent(QDragEnterEvent *e) Q_DECL_OVERRIDE;
- virtual void dragLeaveEvent(QDragLeaveEvent *e) Q_DECL_OVERRIDE;
- virtual void dragMoveEvent(QDragMoveEvent *e) Q_DECL_OVERRIDE;
- virtual void dropEvent(QDropEvent *e) Q_DECL_OVERRIDE;
+ virtual void dragEnterEvent(QDragEnterEvent *e) override;
+ virtual void dragLeaveEvent(QDragLeaveEvent *e) override;
+ virtual void dragMoveEvent(QDragMoveEvent *e) override;
+ virtual void dropEvent(QDropEvent *e) override;
#endif
- virtual void focusInEvent(QFocusEvent *e) Q_DECL_OVERRIDE;
- virtual void focusOutEvent(QFocusEvent *e) Q_DECL_OVERRIDE;
- virtual void showEvent(QShowEvent *) Q_DECL_OVERRIDE;
- virtual void changeEvent(QEvent *e) Q_DECL_OVERRIDE;
+ virtual void focusInEvent(QFocusEvent *e) override;
+ virtual void focusOutEvent(QFocusEvent *e) override;
+ virtual void showEvent(QShowEvent *) override;
+ virtual void changeEvent(QEvent *e) override;
#if QT_CONFIG(wheelevent)
- virtual void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE;
+ virtual void wheelEvent(QWheelEvent *e) override;
#endif
virtual QMimeData *createMimeDataFromSelection() const;
virtual bool canInsertFromMimeData(const QMimeData *source) const;
virtual void insertFromMimeData(const QMimeData *source);
- virtual void inputMethodEvent(QInputMethodEvent *) Q_DECL_OVERRIDE;
+ virtual void inputMethodEvent(QInputMethodEvent *) override;
QTextEdit(QTextEditPrivate &dd, QWidget *parent);
- virtual void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE;
+ virtual void scrollContentsBy(int dx, int dy) override;
virtual void doSetTextCursor(const QTextCursor &cursor);
void zoomInF(float range);
diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp
index 243fb6d555..7b6a2a329f 100644
--- a/src/widgets/widgets/qtoolbar.cpp
+++ b/src/widgets/widgets/qtoolbar.cpp
@@ -92,7 +92,6 @@ void QToolBarPrivate::init()
q->setBackgroundRole(QPalette::Button);
q->setAttribute(Qt::WA_Hover);
q->setAttribute(Qt::WA_X11NetWmWindowTypeToolBar);
- q->setProperty("_q_platform_MacUseNSWindow", QVariant(true));
QStyle *style = q->style();
int e = style->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q);
@@ -804,7 +803,7 @@ QAction *QToolBar::addAction(const QIcon &icon, const QString &text,
return action;
}
-/*!\fn QAction *QToolBar::addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method)
+/*!\fn template<typename PointerToMemberFunction> QAction *QToolBar::addAction(const QString &text, const QObject *receiver, PointerToMemberFunction method)
\since 5.6
@@ -816,7 +815,7 @@ QAction *QToolBar::addAction(const QIcon &icon, const QString &text,
\a method of the \a receiver.
*/
-/*!\fn QAction *QToolBar::addAction(const QString &text, Functor functor)
+/*!\fn template<typename Functor> QAction *QToolBar::addAction(const QString &text, Functor functor)
\since 5.6
@@ -828,7 +827,7 @@ QAction *QToolBar::addAction(const QIcon &icon, const QString &text,
\a functor.
*/
-/*!\fn QAction *QToolBar::addAction(const QString &text, const QObject *context, Functor functor)
+/*!\fn template<typename Functor> QAction *QToolBar::addAction(const QString &text, const QObject *context, Functor functor)
\since 5.6
@@ -842,7 +841,7 @@ QAction *QToolBar::addAction(const QIcon &icon, const QString &text,
If \a context is destroyed, the functor will not be called.
*/
-/*!\fn QAction *QToolBar::addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method)
+/*!\fn template<typename PointerToMemberFunction> QAction *QToolBar::addAction(const QIcon &icon, const QString &text, const QObject *receiver, PointerToMemberFunction method)
\since 5.6
@@ -854,7 +853,7 @@ QAction *QToolBar::addAction(const QIcon &icon, const QString &text,
\a method of the \a receiver.
*/
-/*!\fn QAction *QToolBar::addAction(const QIcon &icon, const QString &text, Functor functor)
+/*!\fn template<typename Functor> QAction *QToolBar::addAction(const QIcon &icon, const QString &text, Functor functor)
\since 5.6
@@ -866,7 +865,7 @@ QAction *QToolBar::addAction(const QIcon &icon, const QString &text,
\a functor.
*/
-/*!\fn QAction *QToolBar::addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor)
+/*!\fn template<typename Functor> QAction *QToolBar::addAction(const QIcon &icon, const QString &text, const QObject *context, Functor functor)
\since 5.6
diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h
index e0f2d9b073..0253541a2e 100644
--- a/src/widgets/widgets/qtoolbar.h
+++ b/src/widgets/widgets/qtoolbar.h
@@ -76,8 +76,8 @@ class Q_WIDGETS_EXPORT QToolBar : public QWidget
Q_PROPERTY(bool floatable READ isFloatable WRITE setFloatable)
public:
- explicit QToolBar(const QString &title, QWidget *parent = Q_NULLPTR);
- explicit QToolBar(QWidget *parent = Q_NULLPTR);
+ explicit QToolBar(const QString &title, QWidget *parent = nullptr);
+ explicit QToolBar(QWidget *parent = nullptr);
~QToolBar();
void setMovable(bool movable);
@@ -121,7 +121,7 @@ public:
addAction(const QString &text, const Obj *object, Func1 slot)
{
QAction *result = addAction(text);
- connect(result, &QAction::triggered, object, slot);
+ connect(result, &QAction::triggered, object, std::move(slot));
return result;
}
// addAction(QString): Connect to a functor or function pointer (without context)
@@ -139,7 +139,7 @@ public:
addAction(const QIcon &actionIcon, const QString &text, const Obj *object, Func1 slot)
{
QAction *result = addAction(actionIcon, text);
- connect(result, &QAction::triggered, object, slot);
+ connect(result, &QAction::triggered, object, std::move(slot));
return result;
}
// addAction(QIcon, QString): Connect to a functor or function pointer (without context)
@@ -188,10 +188,10 @@ Q_SIGNALS:
void visibilityChanged(bool visible);
protected:
- void actionEvent(QActionEvent *event) Q_DECL_OVERRIDE;
- void changeEvent(QEvent *event) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
- bool event(QEvent *event) Q_DECL_OVERRIDE;
+ void actionEvent(QActionEvent *event) override;
+ void changeEvent(QEvent *event) override;
+ void paintEvent(QPaintEvent *event) override;
+ bool event(QEvent *event) override;
void initStyleOption(QStyleOptionToolBar *option) const;
diff --git a/src/widgets/widgets/qtoolbarextension_p.h b/src/widgets/widgets/qtoolbarextension_p.h
index b6223107c4..a388f1e40f 100644
--- a/src/widgets/widgets/qtoolbarextension_p.h
+++ b/src/widgets/widgets/qtoolbarextension_p.h
@@ -64,8 +64,8 @@ class Q_AUTOTEST_EXPORT QToolBarExtension : public QToolButton
public:
explicit QToolBarExtension(QWidget *parent);
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent *) override;
+ QSize sizeHint() const override;
public Q_SLOTS:
void setOrientation(Qt::Orientation o);
diff --git a/src/widgets/widgets/qtoolbarlayout_p.h b/src/widgets/widgets/qtoolbarlayout_p.h
index 9a81c4e50e..8c60164439 100644
--- a/src/widgets/widgets/qtoolbarlayout_p.h
+++ b/src/widgets/widgets/qtoolbarlayout_p.h
@@ -68,7 +68,7 @@ class QToolBarItem : public QWidgetItem
{
public:
QToolBarItem(QWidget *widget);
- bool isEmpty() const Q_DECL_OVERRIDE;
+ bool isEmpty() const override;
QAction *action;
bool customWidget;
@@ -82,22 +82,22 @@ public:
QToolBarLayout(QWidget *parent = 0);
~QToolBarLayout();
- void addItem(QLayoutItem *item) Q_DECL_OVERRIDE;
- QLayoutItem *itemAt(int index) const Q_DECL_OVERRIDE;
- QLayoutItem *takeAt(int index) Q_DECL_OVERRIDE;
- int count() const Q_DECL_OVERRIDE;
+ void addItem(QLayoutItem *item) override;
+ QLayoutItem *itemAt(int index) const override;
+ QLayoutItem *takeAt(int index) override;
+ int count() const override;
- bool isEmpty() const Q_DECL_OVERRIDE;
- void invalidate() Q_DECL_OVERRIDE;
- Qt::Orientations expandingDirections() const Q_DECL_OVERRIDE;
+ bool isEmpty() const override;
+ void invalidate() override;
+ Qt::Orientations expandingDirections() const override;
- void setGeometry(const QRect &r) Q_DECL_OVERRIDE;
- QSize minimumSize() const Q_DECL_OVERRIDE;
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ void setGeometry(const QRect &r) override;
+ QSize minimumSize() const override;
+ QSize sizeHint() const override;
void insertAction(int index, QAction *action);
int indexOf(QAction *action) const;
- int indexOf(QWidget *widget) const Q_DECL_OVERRIDE { return QLayout::indexOf(widget); }
+ int indexOf(QWidget *widget) const override { return QLayout::indexOf(widget); }
bool layoutActions(const QSize &size);
QSize expandedSize(const QSize &size) const;
diff --git a/src/widgets/widgets/qtoolbarseparator_p.h b/src/widgets/widgets/qtoolbarseparator_p.h
index 8c9cf9f46a..d52b4fa6ae 100644
--- a/src/widgets/widgets/qtoolbarseparator_p.h
+++ b/src/widgets/widgets/qtoolbarseparator_p.h
@@ -71,9 +71,9 @@ public:
Qt::Orientation orientation() const;
- QSize sizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent *) override;
void initStyleOption(QStyleOption *option) const;
public Q_SLOTS:
diff --git a/src/widgets/widgets/qtoolbox.cpp b/src/widgets/widgets/qtoolbox.cpp
index fdcd07eb06..46ade0277c 100644
--- a/src/widgets/widgets/qtoolbox.cpp
+++ b/src/widgets/widgets/qtoolbox.cpp
@@ -69,12 +69,12 @@ public:
inline void setSelected(bool b) { selected = b; update(); }
inline void setIndex(int newIndex) { indexInPage = newIndex; }
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ QSize minimumSizeHint() const override;
protected:
void initStyleOption(QStyleOptionToolBox *opt) const;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
+ void paintEvent(QPaintEvent *) override;
private:
bool selected;
diff --git a/src/widgets/widgets/qtoolbox.h b/src/widgets/widgets/qtoolbox.h
index 321507ba07..2796631b94 100644
--- a/src/widgets/widgets/qtoolbox.h
+++ b/src/widgets/widgets/qtoolbox.h
@@ -57,7 +57,7 @@ class Q_WIDGETS_EXPORT QToolBox : public QFrame
Q_PROPERTY(int count READ count)
public:
- explicit QToolBox(QWidget *parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
+ explicit QToolBox(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
~QToolBox();
int addItem(QWidget *widget, const QString &text);
@@ -95,11 +95,11 @@ Q_SIGNALS:
void currentChanged(int index);
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
virtual void itemInserted(int index);
virtual void itemRemoved(int index);
- void showEvent(QShowEvent *e) Q_DECL_OVERRIDE;
- void changeEvent(QEvent *) Q_DECL_OVERRIDE;
+ void showEvent(QShowEvent *e) override;
+ void changeEvent(QEvent *) override;
private:
diff --git a/src/widgets/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp
index 58f1a296b2..c2bf13a3e9 100644
--- a/src/widgets/widgets/qtoolbutton.cpp
+++ b/src/widgets/widgets/qtoolbutton.cpp
@@ -41,6 +41,7 @@
#include <qapplication.h>
#include <qdesktopwidget.h>
+#include <private/qdesktopwidget_p.h>
#include <qdrawutil.h>
#include <qevent.h>
#include <qicon.h>
@@ -347,7 +348,7 @@ QSize QToolButton::sizeHint() const
if (opt.toolButtonStyle != Qt::ToolButtonIconOnly) {
QSize textSize = fm.size(Qt::TextShowMnemonic, text());
- textSize.setWidth(textSize.width() + fm.width(QLatin1Char(' '))*2);
+ textSize.setWidth(textSize.width() + fm.horizontalAdvance(QLatin1Char(' '))*2);
if (opt.toolButtonStyle == Qt::ToolButtonTextUnderIcon) {
h += 4 + textSize.height();
if (textSize.width() > w)
@@ -749,7 +750,7 @@ void QToolButtonPrivate::popupTimerDone()
#endif
QPoint p;
const QRect rect = q->rect(); // Find screen via point in case of QGraphicsProxyWidget.
- QRect screen = QApplication::desktop()->availableGeometry(q->mapToGlobal(rect.center()));
+ QRect screen = QDesktopWidgetPrivate::availableGeometry(q->mapToGlobal(rect.center()));
QSize sh = ((QToolButton*)(QMenu*)actualMenu)->receivers(SIGNAL(aboutToShow()))? QSize() : actualMenu->sizeHint();
if (horizontal) {
if (q->isRightToLeft()) {
diff --git a/src/widgets/widgets/qtoolbutton.h b/src/widgets/widgets/qtoolbutton.h
index dd9964cb94..52bd2d5f7a 100644
--- a/src/widgets/widgets/qtoolbutton.h
+++ b/src/widgets/widgets/qtoolbutton.h
@@ -71,11 +71,11 @@ public:
};
Q_ENUM(ToolButtonPopupMode)
- explicit QToolButton(QWidget *parent = Q_NULLPTR);
+ explicit QToolButton(QWidget *parent = nullptr);
~QToolButton();
- QSize sizeHint() const Q_DECL_OVERRIDE;
- QSize minimumSizeHint() const Q_DECL_OVERRIDE;
+ QSize sizeHint() const override;
+ QSize minimumSizeHint() const override;
Qt::ToolButtonStyle toolButtonStyle() const;
@@ -106,19 +106,19 @@ Q_SIGNALS:
void triggered(QAction *);
protected:
- bool event(QEvent *e) Q_DECL_OVERRIDE;
- void mousePressEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void mouseReleaseEvent(QMouseEvent *) Q_DECL_OVERRIDE;
- void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
- void actionEvent(QActionEvent *) Q_DECL_OVERRIDE;
-
- void enterEvent(QEvent *) Q_DECL_OVERRIDE;
- void leaveEvent(QEvent *) Q_DECL_OVERRIDE;
- void timerEvent(QTimerEvent *) Q_DECL_OVERRIDE;
- void changeEvent(QEvent *) Q_DECL_OVERRIDE;
-
- bool hitButton(const QPoint &pos) const Q_DECL_OVERRIDE;
- void nextCheckState() Q_DECL_OVERRIDE;
+ bool event(QEvent *e) override;
+ void mousePressEvent(QMouseEvent *) override;
+ void mouseReleaseEvent(QMouseEvent *) override;
+ void paintEvent(QPaintEvent *) override;
+ void actionEvent(QActionEvent *) override;
+
+ void enterEvent(QEvent *) override;
+ void leaveEvent(QEvent *) override;
+ void timerEvent(QTimerEvent *) override;
+ void changeEvent(QEvent *) override;
+
+ bool hitButton(const QPoint &pos) const override;
+ void nextCheckState() override;
void initStyleOption(QStyleOptionToolButton *option) const;
private:
diff --git a/src/widgets/widgets/qwidgetanimator.cpp b/src/widgets/widgets/qwidgetanimator.cpp
index fdf2b5d321..b6828a14ef 100644
--- a/src/widgets/widgets/qwidgetanimator.cpp
+++ b/src/widgets/widgets/qwidgetanimator.cpp
@@ -93,13 +93,13 @@ void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, boo
#ifndef QT_NO_ANIMATION
//If the QStyle has animations, animate
- if (widget->style()->styleHint(QStyle::SH_Widget_Animate, 0, widget)) {
+ if (const int animationDuration = widget->style()->styleHint(QStyle::SH_Widget_Animation_Duration, 0, widget)) {
AnimationMap::const_iterator it = m_animation_map.constFind(widget);
if (it != m_animation_map.constEnd() && (*it)->endValue().toRect() == final_geometry)
return;
QPropertyAnimation *anim = new QPropertyAnimation(widget, "geometry", widget);
- anim->setDuration(animate ? 200 : 0);
+ anim->setDuration(animate ? animationDuration : 0);
anim->setEasingCurve(QEasingCurve::InOutQuad);
anim->setEndValue(final_geometry);
m_animation_map[widget] = anim;
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index 4f4a6f70b5..623ca5b0a1 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -44,7 +44,9 @@
#endif
#include "qclipboard.h"
#include <private/qguiapplication_p.h>
+#if QT_CONFIG(completer)
#include <private/qcompleter_p.h>
+#endif
#include <qpa/qplatformtheme.h>
#include <qstylehints.h>
#ifndef QT_NO_ACCESSIBILITY
@@ -1177,9 +1179,9 @@ bool QWidgetLineControl::hasAcceptableInput(const QString &str) const
that blanks will be used, false that previous input is used.
Calling this when no inputMask is set is undefined.
*/
-QString QWidgetLineControl::maskString(uint pos, const QString &str, bool clear) const
+QString QWidgetLineControl::maskString(int pos, const QString &str, bool clear) const
{
- if (pos >= (uint)m_maxLength)
+ if (pos >= m_maxLength)
return QString::fromLatin1("");
QString fill;
@@ -1252,13 +1254,13 @@ QString QWidgetLineControl::maskString(uint pos, const QString &str, bool clear)
Returns a "cleared" string with only separators and blank chars.
Calling this when no inputMask is set is undefined.
*/
-QString QWidgetLineControl::clearString(uint pos, uint len) const
+QString QWidgetLineControl::clearString(int pos, int len) const
{
- if (pos >= (uint)m_maxLength)
+ if (pos >= m_maxLength)
return QString();
QString s;
- int end = qMin((uint)m_maxLength, pos + len);
+ int end = qMin(m_maxLength, pos + len);
for (int i = pos; i < end; ++i)
if (m_maskData[i].separator)
s += m_maskData[i].maskChar;
diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h
index 16c9cc71eb..ca70e2c02f 100644
--- a/src/widgets/widgets/qwidgetlinecontrol_p.h
+++ b/src/widgets/widgets/qwidgetlinecontrol_p.h
@@ -500,8 +500,8 @@ private:
void parseInputMask(const QString &maskFields);
bool isValidInput(QChar key, QChar mask) const;
bool hasAcceptableInput(const QString &text) const;
- QString maskString(uint pos, const QString &str, bool clear = false) const;
- QString clearString(uint pos, uint len) const;
+ QString maskString(int pos, const QString &str, bool clear = false) const;
+ QString clearString(int pos, int len) const;
QString stripString(const QString &str) const;
int findInMask(int pos, bool forward, bool findSeparator, QChar searchChar = QChar()) const;
@@ -550,7 +550,7 @@ Q_SIGNALS:
void editFocusChange(bool);
#endif
protected:
- virtual void timerEvent(QTimerEvent *event) Q_DECL_OVERRIDE;
+ virtual void timerEvent(QTimerEvent *event) override;
private Q_SLOTS:
void _q_deleteSelected();
diff --git a/src/widgets/widgets/qwidgetresizehandler.cpp b/src/widgets/widgets/qwidgetresizehandler.cpp
index 8a1f26dbc2..45010d1768 100644
--- a/src/widgets/widgets/qwidgetresizehandler.cpp
+++ b/src/widgets/widgets/qwidgetresizehandler.cpp
@@ -42,6 +42,7 @@
#include "qframe.h"
#include "qapplication.h"
#include "qdesktopwidget.h"
+#include <private/qdesktopwidget_p.h>
#include "qcursor.h"
#if QT_CONFIG(sizegrip)
#include "qsizegrip.h"
@@ -261,7 +262,7 @@ void QWidgetResizeHandler::mouseMoveEvent(QMouseEvent *e)
// Workaround for window managers which refuse to move a tool window partially offscreen.
if (QGuiApplication::platformName() == QLatin1String("xcb")) {
- const QRect desktop = QApplication::desktop()->availableGeometry(widget);
+ const QRect desktop = QDesktopWidgetPrivate::availableGeometry(widget);
pp.rx() = qMax(pp.x(), desktop.left());
pp.ry() = qMax(pp.y(), desktop.top());
p.rx() = qMin(p.x(), desktop.right());
@@ -382,7 +383,7 @@ void QWidgetResizeHandler::keyPressEvent(QKeyEvent * e)
switch (e->key()) {
case Qt::Key_Left:
pos.rx() -= delta;
- if (pos.x() <= QApplication::desktop()->geometry().left()) {
+ if (pos.x() <= QDesktopWidgetPrivate::geometry().left()) {
if (mode == TopLeft || mode == BottomLeft) {
moveOffset.rx() += delta;
invertedMoveOffset.rx() += delta;
@@ -407,7 +408,7 @@ void QWidgetResizeHandler::keyPressEvent(QKeyEvent * e)
break;
case Qt::Key_Right:
pos.rx() += delta;
- if (pos.x() >= QApplication::desktop()->geometry().right()) {
+ if (pos.x() >= QDesktopWidgetPrivate::geometry().right()) {
if (mode == TopRight || mode == BottomRight) {
moveOffset.rx() += delta;
invertedMoveOffset.rx() += delta;
@@ -432,7 +433,7 @@ void QWidgetResizeHandler::keyPressEvent(QKeyEvent * e)
break;
case Qt::Key_Up:
pos.ry() -= delta;
- if (pos.y() <= QApplication::desktop()->geometry().top()) {
+ if (pos.y() <= QDesktopWidgetPrivate::geometry().top()) {
if (mode == TopLeft || mode == TopRight) {
moveOffset.ry() += delta;
invertedMoveOffset.ry() += delta;
@@ -457,7 +458,7 @@ void QWidgetResizeHandler::keyPressEvent(QKeyEvent * e)
break;
case Qt::Key_Down:
pos.ry() += delta;
- if (pos.y() >= QApplication::desktop()->geometry().bottom()) {
+ if (pos.y() >= QDesktopWidgetPrivate::geometry().bottom()) {
if (mode == BottomLeft || mode == BottomRight) {
moveOffset.ry() += delta;
invertedMoveOffset.ry() += delta;
diff --git a/src/widgets/widgets/qwidgetresizehandler_p.h b/src/widgets/widgets/qwidgetresizehandler_p.h
index 669cb6f256..b87bbd6229 100644
--- a/src/widgets/widgets/qwidgetresizehandler_p.h
+++ b/src/widgets/widgets/qwidgetresizehandler_p.h
@@ -95,7 +95,7 @@ Q_SIGNALS:
void activate();
protected:
- bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE;
+ bool eventFilter(QObject *o, QEvent *e) override;
void mouseMoveEvent(QMouseEvent *e);
void keyPressEvent(QKeyEvent *e);
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index da6dcfbe8b..93158dcdba 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -93,7 +93,10 @@
#include "private/qapplication_p.h"
#include "private/qshortcutmap_p.h"
#include <qkeysequence.h>
-#define ACCEL_KEY(k) (!qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? \
+#define ACCEL_KEY(k) ((qApp->testAttribute(Qt::AA_DontShowIconsInMenus) \
+ ? false \
+ : qApp->styleHints()->showShortcutsInContextMenus()) \
+ && !qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? \
QLatin1Char('\t') + QKeySequence(k).toString(QKeySequence::NativeText) : QString())
#else
@@ -1411,7 +1414,7 @@ QRectF QWidgetTextControlPrivate::rectForPosition(int position) const
if (relativePos < line.textLength() - line.textStart())
w = line.cursorToX(relativePos + 1) - x;
else
- w = QFontMetrics(block.layout()->font()).width(QLatin1Char(' ')); // in sync with QTextLine::draw()
+ w = QFontMetrics(block.layout()->font()).horizontalAdvance(QLatin1Char(' ')); // in sync with QTextLine::draw()
}
r = QRectF(layoutPos.x() + x, layoutPos.y() + line.y(),
cursorWidth + w, line.height());
@@ -1424,10 +1427,6 @@ QRectF QWidgetTextControlPrivate::rectForPosition(int position) const
namespace {
struct QTextFrameComparator {
-#if defined(Q_CC_MSVC) && _MSC_VER < 1600
-//The STL implementation of MSVC 2008 requires the definition
- bool operator()(QTextFrame *frame1, QTextFrame *frame2) { return frame1->firstPosition() < frame2->firstPosition(); }
-#endif
bool operator()(QTextFrame *frame, int position) { return frame->firstPosition() < position; }
bool operator()(int position, QTextFrame *frame) { return position < frame->firstPosition(); }
};
@@ -1884,8 +1883,6 @@ void QWidgetTextControlPrivate::contextMenuEvent(const QPoint &screenPos, const
Q_UNUSED(contextWidget);
#else
Q_Q(QWidgetTextControl);
- if (!hasFocus)
- return;
QMenu *menu = q->createStandardContextMenu(docPos, contextWidget);
if (!menu)
return;
diff --git a/src/widgets/widgets/qwidgettextcontrol_p.h b/src/widgets/widgets/qwidgettextcontrol_p.h
index 11ff63c5e4..4b2acbd934 100644
--- a/src/widgets/widgets/qwidgettextcontrol_p.h
+++ b/src/widgets/widgets/qwidgettextcontrol_p.h
@@ -258,9 +258,9 @@ public:
bool findNextPrevAnchor(const QTextCursor& from, bool next, QTextCursor& newAnchor);
protected:
- virtual void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE;
+ virtual void timerEvent(QTimerEvent *e) override;
- virtual bool event(QEvent *e) Q_DECL_OVERRIDE;
+ virtual bool event(QEvent *e) override;
private:
Q_DISABLE_COPY(QWidgetTextControl)
@@ -296,9 +296,9 @@ class QTextEditMimeData : public QMimeData
public:
inline QTextEditMimeData(const QTextDocumentFragment &aFragment) : fragment(aFragment) {}
- virtual QStringList formats() const Q_DECL_OVERRIDE;
+ virtual QStringList formats() const override;
protected:
- virtual QVariant retrieveData(const QString &mimeType, QVariant::Type type) const Q_DECL_OVERRIDE;
+ virtual QVariant retrieveData(const QString &mimeType, QVariant::Type type) const override;
private:
void setup() const;