summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2009-04-24 14:03:55 (GMT)
committeraxis <qt-info@nokia.com>2009-04-27 07:09:01 (GMT)
commite74c8dc65e2feffb9a55d00aee5ca634fba41df8 (patch)
tree3a131f9235fb6a455793178d8313655e4fd0036e /src/gui
parent8f427b2b914d5b575a4a7c0ed65d2fb8f45acc76 (diff)
parent211bea9838bcc2acd7f54b65468fe1be2d81b1e0 (diff)
downloadQt-e74c8dc65e2feffb9a55d00aee5ca634fba41df8.zip
Qt-e74c8dc65e2feffb9a55d00aee5ca634fba41df8.tar.gz
Qt-e74c8dc65e2feffb9a55d00aee5ca634fba41df8.tar.bz2
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt
Configure.exe recompiled with MSVC6. Conflicts: configure.exe examples/network/network.pro src/gui/dialogs/qfiledialog_p.h src/gui/dialogs/qfilesystemmodel_p.h src/gui/kernel/qapplication.cpp tests/auto/_Categories/qmake.txt tests/auto/qfile/test/test.pro tests/auto/qfile/tst_qfile.cpp tests/auto/qlibrary/tst_qlibrary.cpp tests/auto/qline/tst_qline.cpp tests/auto/qstyle/tst_qstyle.cpp tests/auto/qtextstream/tst_qtextstream.cpp tests/auto/qtranslator/qtranslator.pro tests/auto/qwaitcondition/tst_qwaitcondition.cpp translations/qt_ja_JP.ts
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/accessible/qaccessible_mac.mm122
-rw-r--r--src/gui/accessible/qaccessiblewidget.cpp13
-rw-r--r--src/gui/dialogs/qcolordialog.cpp8
-rw-r--r--src/gui/dialogs/qfiledialog.cpp71
-rw-r--r--src/gui/dialogs/qfiledialog_mac.mm2
-rw-r--r--src/gui/dialogs/qfiledialog_p.h39
-rw-r--r--src/gui/dialogs/qfileinfogatherer.cpp20
-rw-r--r--src/gui/dialogs/qfileinfogatherer_p.h1
-rw-r--r--src/gui/dialogs/qfilesystemmodel.cpp23
-rw-r--r--src/gui/dialogs/qfilesystemmodel.h2
-rw-r--r--src/gui/dialogs/qfilesystemmodel_p.h24
-rw-r--r--src/gui/dialogs/qfontdialog_mac.mm8
-rw-r--r--src/gui/dialogs/qinputdialog.cpp181
-rw-r--r--src/gui/dialogs/qmessagebox.cpp84
-rw-r--r--src/gui/dialogs/qprintdialog_unix.cpp4
-rw-r--r--src/gui/dialogs/qsidebar.cpp25
-rw-r--r--src/gui/dialogs/qsidebar_p.h13
-rw-r--r--src/gui/embedded/qscreentransformed_qws.cpp4
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp561
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h61
-rw-r--r--src/gui/graphicsview/qgraphicslayoutitem.cpp45
-rw-r--r--src/gui/graphicsview/qgraphicsproxywidget.cpp8
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp394
-rw-r--r--src/gui/graphicsview/qgraphicsscene_p.h4
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp274
-rw-r--r--src/gui/graphicsview/qgraphicsview_p.h7
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp60
-rw-r--r--src/gui/graphicsview/qgraphicswidget_p.cpp2
-rw-r--r--src/gui/graphicsview/qgraphicswidget_p.h4
-rw-r--r--src/gui/image/qimage.cpp26
-rw-r--r--src/gui/image/qnativeimage.cpp4
-rw-r--r--src/gui/image/qpaintengine_pic.cpp21
-rw-r--r--src/gui/image/qpaintengine_pic_p.h2
-rw-r--r--src/gui/image/qpicture.cpp16
-rw-r--r--src/gui/image/qpicture_p.h1
-rw-r--r--src/gui/image/qpixmap.cpp18
-rw-r--r--src/gui/image/qpixmap_mac.cpp2
-rw-r--r--src/gui/image/qpixmap_x11.cpp8
-rw-r--r--src/gui/image/qpixmapcache.cpp6
-rw-r--r--src/gui/image/qpixmapdata_p.h1
-rw-r--r--src/gui/inputmethod/qwininputcontext_win.cpp10
-rw-r--r--src/gui/inputmethod/qximinputcontext_p.h1
-rw-r--r--src/gui/inputmethod/qximinputcontext_x11.cpp13
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp3
-rw-r--r--src/gui/itemviews/qheaderview.cpp31
-rw-r--r--src/gui/itemviews/qheaderview_p.h3
-rw-r--r--src/gui/itemviews/qsortfilterproxymodel.cpp25
-rw-r--r--src/gui/itemviews/qtreeview.cpp2
-rw-r--r--src/gui/kernel/qapplication.cpp1908
-rw-r--r--src/gui/kernel/qapplication_x11.cpp58
-rw-r--r--src/gui/kernel/qcocoaapplication_mac.mm22
-rw-r--r--src/gui/kernel/qcocoaapplicationdelegate_mac.mm46
-rw-r--r--src/gui/kernel/qcocoaapplicationdelegate_mac_p.h1
-rw-r--r--src/gui/kernel/qcocoamenuloader_mac.mm22
-rw-r--r--src/gui/kernel/qcocoapanel_mac.mm107
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm136
-rw-r--r--src/gui/kernel/qcocoawindow_mac.mm49
-rw-r--r--src/gui/kernel/qcocoawindowdelegate_mac.mm22
-rw-r--r--src/gui/kernel/qcursor.h2
-rw-r--r--src/gui/kernel/qcursor_mac.mm16
-rw-r--r--src/gui/kernel/qevent.cpp2
-rw-r--r--src/gui/kernel/qmacdefines_mac.h2
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm17
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac_p.h1
-rw-r--r--src/gui/kernel/qt_mac.cpp47
-rw-r--r--src/gui/kernel/qt_mac_p.h3
-rw-r--r--src/gui/kernel/qwidget.cpp111
-rw-r--r--src/gui/kernel/qwidget_mac.mm149
-rw-r--r--src/gui/kernel/qwidget_p.h3
-rw-r--r--src/gui/kernel/qwidget_x11.cpp7
-rw-r--r--src/gui/kernel/qx11embed_x11.cpp7
-rw-r--r--src/gui/painting/qblendfunctions.cpp159
-rw-r--r--src/gui/painting/qdrawhelper.cpp92
-rw-r--r--src/gui/painting/qmemrotate.cpp1
-rw-r--r--src/gui/painting/qmemrotate_p.h1
-rw-r--r--src/gui/painting/qpaintengine_alpha.cpp12
-rw-r--r--src/gui/painting/qpaintengine_alpha_p.h1
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp152
-rw-r--r--src/gui/painting/qpaintengine_raster_p.h2
-rw-r--r--src/gui/painting/qpaintengine_x11.cpp19
-rw-r--r--src/gui/painting/qpainter.cpp25
-rw-r--r--src/gui/painting/qpainterpath.cpp23
-rw-r--r--src/gui/painting/qpainterpath.h2
-rw-r--r--src/gui/painting/qpainterpath_p.h11
-rw-r--r--src/gui/painting/qpdf.cpp5
-rw-r--r--src/gui/painting/qprintengine_mac.mm66
-rw-r--r--src/gui/painting/qprintengine_mac_p.h1
-rw-r--r--src/gui/painting/qprintengine_win.cpp4
-rw-r--r--src/gui/painting/qprinter.cpp6
-rw-r--r--src/gui/painting/qregion.cpp24
-rw-r--r--src/gui/painting/qtransform.cpp93
-rw-r--r--src/gui/painting/qtransform.h8
-rw-r--r--src/gui/painting/qwindowsurface.cpp7
-rw-r--r--src/gui/styles/gtksymbols.cpp67
-rw-r--r--src/gui/styles/gtksymbols_p.h11
-rw-r--r--src/gui/styles/qcommonstyle.cpp73
-rw-r--r--src/gui/styles/qgtkstyle.cpp135
-rw-r--r--src/gui/styles/qmacstyle_mac.mm19
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp43
-rw-r--r--src/gui/styles/qwindowsmobilestyle.cpp3
-rw-r--r--src/gui/styles/qwindowsvistastyle.cpp23
-rw-r--r--src/gui/styles/qwindowsvistastyle_p.h1
-rw-r--r--src/gui/styles/qwindowsxpstyle.cpp4
-rw-r--r--src/gui/text/qfontdatabase_win.cpp12
-rw-r--r--src/gui/text/qfontengine_ft.cpp2
-rw-r--r--src/gui/text/qfontengine_mac.mm31
-rw-r--r--src/gui/text/qfontengine_p.h2
-rw-r--r--src/gui/text/qtextdocument.h1
-rw-r--r--src/gui/text/qtextdocument_p.cpp1
-rw-r--r--src/gui/text/qtextlist.cpp7
-rw-r--r--src/gui/text/qtextobject.cpp8
-rw-r--r--src/gui/text/qtextobject_p.h15
-rw-r--r--src/gui/text/qtexttable.cpp2
-rw-r--r--src/gui/text/qtexttable_p.h2
-rw-r--r--src/gui/util/qcompleter.cpp11
-rw-r--r--src/gui/util/qdesktopservices.cpp5
-rw-r--r--src/gui/widgets/qabstractbutton.cpp9
-rw-r--r--src/gui/widgets/qabstractbutton.h3
-rw-r--r--src/gui/widgets/qcocoamenu_mac.mm45
-rw-r--r--src/gui/widgets/qcombobox.cpp26
-rw-r--r--src/gui/widgets/qcombobox_p.h2
-rw-r--r--src/gui/widgets/qdialogbuttonbox.cpp3
-rw-r--r--src/gui/widgets/qdockarealayout.cpp2
-rw-r--r--src/gui/widgets/qdockwidget.cpp12
-rw-r--r--src/gui/widgets/qmaccocoaviewcontainer_mac.mm22
-rw-r--r--src/gui/widgets/qmacnativewidget_mac.mm22
-rw-r--r--src/gui/widgets/qmainwindow.cpp2
-rw-r--r--src/gui/widgets/qmainwindowlayout.cpp3
-rw-r--r--src/gui/widgets/qmainwindowlayout_mac.mm44
-rw-r--r--src/gui/widgets/qmenu.cpp4
-rw-r--r--src/gui/widgets/qtabbar.cpp96
-rw-r--r--src/gui/widgets/qtabbar_p.h33
-rw-r--r--src/gui/widgets/qtextedit.cpp8
-rw-r--r--src/gui/widgets/qtoolbar.cpp11
134 files changed, 3900 insertions, 2634 deletions
diff --git a/src/gui/accessible/qaccessible_mac.mm b/src/gui/accessible/qaccessible_mac.mm
index b6412c2..68efb8f 100644
--- a/src/gui/accessible/qaccessible_mac.mm
+++ b/src/gui/accessible/qaccessible_mac.mm
@@ -72,55 +72,36 @@ typedef NSString * const QAXRoleType;
#define QAXApplicationRole NSAccessibilityApplicationRole
#define QAXButtonRole NSAccessibilityButtonRole
#define QAXCancelAction NSAccessibilityCancelAction
-#define QAXCancelAction NSAccessibilityCancelAction
#define QAXCheckBoxRole NSAccessibilityCheckBoxRole
#define QAXChildrenAttribute NSAccessibilityChildrenAttribute
-#define QAXChildrenAttribute NSAccessibilityChildrenAttribute
-#define QAXChildrenAttribute NSAccessibilityChildrenAttribute
#define QAXCloseButtonAttribute NSAccessibilityCloseButtonAttribute
#define QAXCloseButtonAttribute NSAccessibilityCloseButtonAttribute
#define QAXColumnRole NSAccessibilityColumnRole
#define QAXConfirmAction NSAccessibilityConfirmAction
-#define QAXConfirmAction NSAccessibilityConfirmAction
#define QAXContentsAttribute NSAccessibilityContentsAttribute
-#define QAXContentsAttribute NSAccessibilityContentsAttribute
-#define QAXDecrementAction NSAccessibilityDecrementAction
#define QAXDecrementAction NSAccessibilityDecrementAction
#define QAXDecrementArrowSubrole NSAccessibilityDecrementArrowSubrole
#define QAXDecrementPageSubrole NSAccessibilityDecrementPageSubrole
#define QAXDescriptionAttribute NSAccessibilityDescriptionAttribute
-#define QAXDescriptionAttribute NSAccessibilityDescriptionAttribute
-#define QAXDescriptionAttribute NSAccessibilityDescriptionAttribute
-#define QAXDescriptionAttribute NSAccessibilityDescriptionAttribute
-#define QAXEnabledAttribute NSAccessibilityEnabledAttribute
#define QAXEnabledAttribute NSAccessibilityEnabledAttribute
#define QAXExpandedAttribute NSAccessibilityExpandedAttribute
#define QAXFocusedAttribute NSAccessibilityFocusedAttribute
-#define QAXFocusedAttribute NSAccessibilityFocusedAttribute
-#define QAXFocusedAttribute NSAccessibilityFocusedAttribute
#define QAXFocusedUIElementChangedNotification NSAccessibilityFocusedUIElementChangedNotification
#define QAXFocusedWindowChangedNotification NSAccessibilityFocusedWindowChangedNotification
#define QAXGroupRole NSAccessibilityGroupRole
#define QAXGrowAreaAttribute NSAccessibilityGrowAreaAttribute
-#define QAXGrowAreaAttribute NSAccessibilityGrowAreaAttribute
#define QAXGrowAreaRole NSAccessibilityGrowAreaRole
#define QAXHelpAttribute NSAccessibilityHelpAttribute
-#define QAXHelpAttribute NSAccessibilityHelpAttribute
-#define QAXHelpAttribute NSAccessibilityHelpAttribute
#define QAXHorizontalOrientationValue NSAccessibilityHorizontalOrientationValue
#define QAXHorizontalScrollBarAttribute NSAccessibilityHorizontalScrollBarAttribute
-#define QAXHorizontalScrollBarAttribute NSAccessibilityHorizontalScrollBarAttribute
-#define QAXIncrementAction NSAccessibilityIncrementAction
#define QAXIncrementAction NSAccessibilityIncrementAction
#define QAXIncrementArrowSubrole NSAccessibilityIncrementArrowSubrole
#define QAXIncrementPageSubrole NSAccessibilityIncrementPageSubrole
#define QAXIncrementorRole NSAccessibilityIncrementorRole
#define QAXLinkedUIElementsAttribute NSAccessibilityLinkedUIElementsAttribute
-#define QAXLinkedUIElementsAttribute NSAccessibilityLinkedUIElementsAttribute
#define QAXListRole NSAccessibilityListRole
#define QAXMainAttribute NSAccessibilityMainAttribute
#define QAXMaxValueAttribute NSAccessibilityMaxValueAttribute
-#define QAXMaxValueAttribute NSAccessibilityMaxValueAttribute
#define QAXMenuBarRole NSAccessibilityMenuBarRole
#define QAXMenuButtonRole NSAccessibilityMenuButtonRole
#define QAXMenuClosedNotification NSAccessibilityMenuClosedNotification
@@ -128,151 +109,90 @@ typedef NSString * const QAXRoleType;
#define QAXMenuOpenedNotification NSAccessibilityMenuOpenedNotification
#define QAXMenuRole NSAccessibilityMenuRole
#define QAXMinValueAttribute NSAccessibilityMinValueAttribute
-#define QAXMinValueAttribute NSAccessibilityMinValueAttribute
#define QAXMinimizeButtonAttribute NSAccessibilityMinimizeButtonAttribute
-#define QAXMinimizeButtonAttribute NSAccessibilityMinimizeButtonAttribute
-#define QAXMinimizedAttribute NSAccessibilityMinimizedAttribute
#define QAXMinimizedAttribute NSAccessibilityMinimizedAttribute
#define QAXNextContentsAttribute NSAccessibilityNextContentsAttribute
-#define QAXNextContentsAttribute NSAccessibilityNextContentsAttribute
-#define QAXOrientationAttribute NSAccessibilityOrientationAttribute
-#define QAXOrientationAttribute NSAccessibilityOrientationAttribute
#define QAXOrientationAttribute NSAccessibilityOrientationAttribute
#define QAXParentAttribute NSAccessibilityParentAttribute
#define QAXPickAction NSAccessibilityPickAction
-#define QAXPickAction NSAccessibilityPickAction
#define QAXPopUpButtonRole NSAccessibilityPopUpButtonRole
#define QAXPositionAttribute NSAccessibilityPositionAttribute
-#define QAXPositionAttribute NSAccessibilityPositionAttribute
-#define QAXPressAction NSAccessibilityPressAction
#define QAXPressAction NSAccessibilityPressAction
#define QAXPreviousContentsAttribute NSAccessibilityPreviousContentsAttribute
-#define QAXPreviousContentsAttribute NSAccessibilityPreviousContentsAttribute
-#define QAXPreviousContentsAttribute NSAccessibilityPreviousContentsAttribute
#define QAXProgressIndicatorRole NSAccessibilityProgressIndicatorRole
#define QAXRadioButtonRole NSAccessibilityRadioButtonRole
#define QAXRoleAttribute NSAccessibilityRoleAttribute
-#define QAXRoleAttribute NSAccessibilityRoleAttribute
#define QAXRoleDescriptionAttribute NSAccessibilityRoleDescriptionAttribute
#define QAXRowRole NSAccessibilityRowRole
#define QAXRowsAttribute NSAccessibilityRowsAttribute
-#define QAXRowsAttribute NSAccessibilityRowsAttribute
-#define QAXScrollAreaRole NSAccessibilityScrollAreaRole
-#define QAXScrollAreaRole NSAccessibilityScrollAreaRole
#define QAXScrollAreaRole NSAccessibilityScrollAreaRole
#define QAXScrollBarRole NSAccessibilityScrollBarRole
#define QAXSelectedAttribute NSAccessibilitySelectedAttribute
#define QAXSelectedChildrenAttribute NSAccessibilitySelectedChildrenAttribute
#define QAXSelectedRowsAttribute NSAccessibilitySelectedRowsAttribute
-#define QAXSelectedRowsAttribute NSAccessibilitySelectedRowsAttribute
-#define QAXSizeAttribute NSAccessibilitySizeAttribute
#define QAXSizeAttribute NSAccessibilitySizeAttribute
#define QAXSliderRole NSAccessibilitySliderRole
#define QAXSplitGroupRole NSAccessibilitySplitGroupRole
#define QAXSplitterRole NSAccessibilitySplitterRole
-#define QAXSplitterRole NSAccessibilitySplitterRole
-#define QAXSplitterRole NSAccessibilitySplitterRole
-#define QAXSplittersAttribute NSAccessibilitySplittersAttribute
#define QAXSplittersAttribute NSAccessibilitySplittersAttribute
#define QAXStaticTextRole NSAccessibilityStaticTextRole
-#define QAXStaticTextRole NSAccessibilityStaticTextRole
-#define QAXSubroleAttribute NSAccessibilitySubroleAttribute
#define QAXSubroleAttribute NSAccessibilitySubroleAttribute
#define QAXSubroleAttribute NSAccessibilitySubroleAttribute
#define QAXTabGroupRole NSAccessibilityTabGroupRole
-#define QAXTabGroupRole NSAccessibilityTabGroupRole
#define QAXTableRole NSAccessibilityTableRole
#define QAXTabsAttribute NSAccessibilityTabsAttribute
-#define QAXTabsAttribute NSAccessibilityTabsAttribute
#define QAXTextFieldRole NSAccessibilityTextFieldRole
-#define QAXTextFieldRole NSAccessibilityTextFieldRole
-#define QAXTitleAttribute NSAccessibilityTitleAttribute
-#define QAXTitleAttribute NSAccessibilityTitleAttribute
#define QAXTitleAttribute NSAccessibilityTitleAttribute
-#define QAXTitleAttribute NSAccessibilityTitleAttribute
-#define QAXTitleUIElementAttribute NSAccessibilityTitleUIElementAttribute
#define QAXTitleUIElementAttribute NSAccessibilityTitleUIElementAttribute
#define QAXToolbarButtonAttribute NSAccessibilityToolbarButtonAttribute
-#define QAXToolbarButtonAttribute NSAccessibilityToolbarButtonAttribute
#define QAXToolbarRole NSAccessibilityToolbarRole
#define QAXTopLevelUIElementAttribute NSAccessibilityTopLevelUIElementAttribute
-#define QAXTopLevelUIElementAttribute NSAccessibilityTopLevelUIElementAttribute
-#define QAXTopLevelUIElementAttribute NSAccessibilityTopLevelUIElementAttribute
-#define QAXUnknownRole NSAccessibilityUnknownRole
#define QAXUnknownRole NSAccessibilityUnknownRole
#define QAXValueAttribute NSAccessibilityValueAttribute
-#define QAXValueAttribute NSAccessibilityValueAttribute
-#define QAXValueAttribute NSAccessibilityValueAttribute
-#define QAXValueAttribute NSAccessibilityValueAttribute
#define QAXValueChangedNotification NSAccessibilityValueChangedNotification
#define QAXValueIndicatorRole NSAccessibilityValueIndicatorRole
#define QAXVerticalOrientationValue NSAccessibilityVerticalOrientationValue
#define QAXVerticalScrollBarAttribute NSAccessibilityVerticalScrollBarAttribute
-#define QAXVerticalScrollBarAttribute NSAccessibilityVerticalScrollBarAttribute
#define QAXVisibleRowsAttribute NSAccessibilityVisibleRowsAttribute
-#define QAXVisibleRowsAttribute NSAccessibilityVisibleRowsAttribute
-#define QAXWindowAttribute NSAccessibilityWindowAttribute
-#define QAXWindowAttribute NSAccessibilityWindowAttribute
#define QAXWindowAttribute NSAccessibilityWindowAttribute
#define QAXWindowCreatedNotification NSAccessibilityWindowCreatedNotification
#define QAXWindowMovedNotification NSAccessibilityWindowMovedNotification
#define QAXWindowRole NSAccessibilityWindowRole
#define QAXZoomButtonAttribute NSAccessibilityZoomButtonAttribute
-#define QAXZoomButtonAttribute NSAccessibilityZoomButtonAttribute
#else
typedef CFStringRef const QAXRoleType;
#define QAXApplicationRole kAXApplicationRole
#define QAXButtonRole kAXButtonRole
#define QAXCancelAction kAXCancelAction
-#define QAXCancelAction kAXCancelAction
#define QAXCheckBoxRole kAXCheckBoxRole
#define QAXChildrenAttribute kAXChildrenAttribute
-#define QAXChildrenAttribute kAXChildrenAttribute
-#define QAXChildrenAttribute kAXChildrenAttribute
-#define QAXCloseButtonAttribute kAXCloseButtonAttribute
#define QAXCloseButtonAttribute kAXCloseButtonAttribute
#define QAXColumnRole kAXColumnRole
#define QAXConfirmAction kAXConfirmAction
-#define QAXConfirmAction kAXConfirmAction
#define QAXContentsAttribute kAXContentsAttribute
-#define QAXContentsAttribute kAXContentsAttribute
-#define QAXDecrementAction kAXDecrementAction
#define QAXDecrementAction kAXDecrementAction
#define QAXDecrementArrowSubrole kAXDecrementArrowSubrole
#define QAXDecrementPageSubrole kAXDecrementPageSubrole
#define QAXDescriptionAttribute kAXDescriptionAttribute
-#define QAXDescriptionAttribute kAXDescriptionAttribute
-#define QAXDescriptionAttribute kAXDescriptionAttribute
-#define QAXDescriptionAttribute kAXDescriptionAttribute
-#define QAXEnabledAttribute kAXEnabledAttribute
#define QAXEnabledAttribute kAXEnabledAttribute
#define QAXExpandedAttribute kAXExpandedAttribute
#define QAXFocusedAttribute kAXFocusedAttribute
-#define QAXFocusedAttribute kAXFocusedAttribute
-#define QAXFocusedAttribute kAXFocusedAttribute
#define QAXFocusedUIElementChangedNotification kAXFocusedUIElementChangedNotification
#define QAXFocusedWindowChangedNotification kAXFocusedWindowChangedNotification
#define QAXGroupRole kAXGroupRole
#define QAXGrowAreaAttribute kAXGrowAreaAttribute
-#define QAXGrowAreaAttribute kAXGrowAreaAttribute
#define QAXGrowAreaRole kAXGrowAreaRole
#define QAXHelpAttribute kAXHelpAttribute
-#define QAXHelpAttribute kAXHelpAttribute
-#define QAXHelpAttribute kAXHelpAttribute
#define QAXHorizontalOrientationValue kAXHorizontalOrientationValue
#define QAXHorizontalScrollBarAttribute kAXHorizontalScrollBarAttribute
-#define QAXHorizontalScrollBarAttribute kAXHorizontalScrollBarAttribute
-#define QAXIncrementAction kAXIncrementAction
#define QAXIncrementAction kAXIncrementAction
#define QAXIncrementArrowSubrole kAXIncrementArrowSubrole
#define QAXIncrementPageSubrole kAXIncrementPageSubrole
#define QAXIncrementorRole kAXIncrementorRole
#define QAXLinkedUIElementsAttribute kAXLinkedUIElementsAttribute
-#define QAXLinkedUIElementsAttribute kAXLinkedUIElementsAttribute
#define QAXListRole kAXListRole
#define QAXMainAttribute kAXMainAttribute
#define QAXMaxValueAttribute kAXMaxValueAttribute
-#define QAXMaxValueAttribute kAXMaxValueAttribute
#define QAXMenuBarRole kAXMenuBarRole
#define QAXMenuButtonRole kAXMenuButtonRole
#define QAXMenuClosedNotification kAXMenuClosedNotification
@@ -280,97 +200,55 @@ typedef CFStringRef const QAXRoleType;
#define QAXMenuOpenedNotification kAXMenuOpenedNotification
#define QAXMenuRole kAXMenuRole
#define QAXMinValueAttribute kAXMinValueAttribute
-#define QAXMinValueAttribute kAXMinValueAttribute
#define QAXMinimizeButtonAttribute kAXMinimizeButtonAttribute
-#define QAXMinimizeButtonAttribute kAXMinimizeButtonAttribute
-#define QAXMinimizedAttribute kAXMinimizedAttribute
#define QAXMinimizedAttribute kAXMinimizedAttribute
#define QAXNextContentsAttribute kAXNextContentsAttribute
-#define QAXNextContentsAttribute kAXNextContentsAttribute
-#define QAXOrientationAttribute kAXOrientationAttribute
-#define QAXOrientationAttribute kAXOrientationAttribute
#define QAXOrientationAttribute kAXOrientationAttribute
#define QAXParentAttribute kAXParentAttribute
#define QAXPickAction kAXPickAction
-#define QAXPickAction kAXPickAction
#define QAXPopUpButtonRole kAXPopUpButtonRole
#define QAXPositionAttribute kAXPositionAttribute
-#define QAXPositionAttribute kAXPositionAttribute
-#define QAXPressAction kAXPressAction
#define QAXPressAction kAXPressAction
#define QAXPreviousContentsAttribute kAXPreviousContentsAttribute
-#define QAXPreviousContentsAttribute kAXPreviousContentsAttribute
-#define QAXPreviousContentsAttribute kAXPreviousContentsAttribute
#define QAXProgressIndicatorRole kAXProgressIndicatorRole
#define QAXRadioButtonRole kAXRadioButtonRole
#define QAXRoleAttribute kAXRoleAttribute
-#define QAXRoleAttribute kAXRoleAttribute
#define QAXRoleDescriptionAttribute kAXRoleDescriptionAttribute
#define QAXRowRole kAXRowRole
#define QAXRowsAttribute kAXRowsAttribute
-#define QAXRowsAttribute kAXRowsAttribute
-#define QAXScrollAreaRole kAXScrollAreaRole
-#define QAXScrollAreaRole kAXScrollAreaRole
#define QAXScrollAreaRole kAXScrollAreaRole
#define QAXScrollBarRole kAXScrollBarRole
#define QAXSelectedAttribute kAXSelectedAttribute
#define QAXSelectedChildrenAttribute kAXSelectedChildrenAttribute
#define QAXSelectedRowsAttribute kAXSelectedRowsAttribute
-#define QAXSelectedRowsAttribute kAXSelectedRowsAttribute
-#define QAXSizeAttribute kAXSizeAttribute
#define QAXSizeAttribute kAXSizeAttribute
#define QAXSliderRole kAXSliderRole
#define QAXSplitGroupRole kAXSplitGroupRole
#define QAXSplitterRole kAXSplitterRole
-#define QAXSplitterRole kAXSplitterRole
-#define QAXSplitterRole kAXSplitterRole
-#define QAXSplittersAttribute kAXSplittersAttribute
#define QAXSplittersAttribute kAXSplittersAttribute
#define QAXStaticTextRole kAXStaticTextRole
-#define QAXStaticTextRole kAXStaticTextRole
-#define QAXSubroleAttribute kAXSubroleAttribute
#define QAXSubroleAttribute kAXSubroleAttribute
-#define QAXSubroleAttribute kAXSubroleAttribute
-#define QAXTabGroupRole kAXTabGroupRole
#define QAXTabGroupRole kAXTabGroupRole
#define QAXTableRole kAXTableRole
#define QAXTabsAttribute kAXTabsAttribute
-#define QAXTabsAttribute kAXTabsAttribute
-#define QAXTextFieldRole kAXTextFieldRole
#define QAXTextFieldRole kAXTextFieldRole
#define QAXTitleAttribute kAXTitleAttribute
-#define QAXTitleAttribute kAXTitleAttribute
-#define QAXTitleAttribute kAXTitleAttribute
-#define QAXTitleAttribute kAXTitleAttribute
#define QAXTitleUIElementAttribute kAXTitleUIElementAttribute
-#define QAXTitleUIElementAttribute kAXTitleUIElementAttribute
-#define QAXToolbarButtonAttribute kAXToolbarButtonAttribute
#define QAXToolbarButtonAttribute kAXToolbarButtonAttribute
#define QAXToolbarRole kAXToolbarRole
#define QAXTopLevelUIElementAttribute kAXTopLevelUIElementAttribute
-#define QAXTopLevelUIElementAttribute kAXTopLevelUIElementAttribute
-#define QAXTopLevelUIElementAttribute kAXTopLevelUIElementAttribute
#define QAXUnknownRole kAXUnknownRole
-#define QAXUnknownRole kAXUnknownRole
-#define QAXValueAttribute kAXValueAttribute
-#define QAXValueAttribute kAXValueAttribute
-#define QAXValueAttribute kAXValueAttribute
#define QAXValueAttribute kAXValueAttribute
#define QAXValueChangedNotification kAXValueChangedNotification
#define QAXValueIndicatorRole kAXValueIndicatorRole
#define QAXVerticalOrientationValue kAXVerticalOrientationValue
#define QAXVerticalScrollBarAttribute kAXVerticalScrollBarAttribute
-#define QAXVerticalScrollBarAttribute kAXVerticalScrollBarAttribute
-#define QAXVisibleRowsAttribute kAXVisibleRowsAttribute
#define QAXVisibleRowsAttribute kAXVisibleRowsAttribute
#define QAXWindowAttribute kAXWindowAttribute
-#define QAXWindowAttribute kAXWindowAttribute
-#define QAXWindowAttribute kAXWindowAttribute
#define QAXWindowCreatedNotification kAXWindowCreatedNotification
#define QAXWindowMovedNotification kAXWindowMovedNotification
#define QAXWindowRole kAXWindowRole
#define QAXZoomButtonAttribute kAXZoomButtonAttribute
-#define QAXZoomButtonAttribute kAXZoomButtonAttribute
#endif
diff --git a/src/gui/accessible/qaccessiblewidget.cpp b/src/gui/accessible/qaccessiblewidget.cpp
index 4b2b2ab..753ac57 100644
--- a/src/gui/accessible/qaccessiblewidget.cpp
+++ b/src/gui/accessible/qaccessiblewidget.cpp
@@ -131,9 +131,16 @@ QString Q_GUI_EXPORT qt_accHotKey(const QString &text)
int fa = 0;
QChar ac;
while ((fa = text.indexOf(QLatin1Char('&'), fa)) != -1) {
- if (fa == text.length() - 1 || text.at(fa+1) != QLatin1Char('&')) {
- ac = text.at(fa+1);
- break;
+ ++fa;
+ if (fa < text.length()) {
+ // ignore "&&"
+ if (text.at(fa) == QLatin1Char('&')) {
+ ++fa;
+ continue;
+ } else {
+ ac = text.at(fa);
+ break;
+ }
}
}
if (ac.isNull())
diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp
index b744dca..3aa04f6 100644
--- a/src/gui/dialogs/qcolordialog.cpp
+++ b/src/gui/dialogs/qcolordialog.cpp
@@ -1523,10 +1523,10 @@ static const Qt::WindowFlags DefaultWindowFlags =
If you require a modeless dialog, use the QColorDialog constructor.
\endomit
- The static getColor() function shows the dialog, and allows the
- user to specify a color. The getRgba() function does the same, but
- also allows the user to specify a color with an alpha channel
- (transparency) value.
+ The static getColor() function shows the dialog, and allows the user to
+ specify a color. This function can also be used to let users choose a
+ color with a level of transparency: pass the ShowAlphaChannel option as
+ an additional argument.
The user can store customCount() different custom colors. The
custom colors are shared by all color dialogs, and remembered
diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp
index 9bcb666..7056575 100644
--- a/src/gui/dialogs/qfiledialog.cpp
+++ b/src/gui/dialogs/qfiledialog.cpp
@@ -696,7 +696,10 @@ void QFileDialog::setVisible(bool visible)
*/
void QFileDialogPrivate::_q_goToUrl(const QUrl &url)
{
- QModelIndex idx = model->index(url.toLocalFile());
+ //The shortcut in the side bar may have a parent that is not fetched yet (e.g. an hidden file)
+ //so we force the fetching
+ QFileSystemModelPrivate::QFileSystemNode *node = model->d_func()->node(url.toLocalFile(), true);
+ QModelIndex idx = model->d_func()->index(node);
_q_enterDirectory(idx);
}
@@ -960,25 +963,29 @@ void QFileDialog::setNameFilters(const QStringList &filters)
{
Q_D(QFileDialog);
d->defaultFileTypes = (filters == QStringList(QFileDialog::tr("All Files (*)")));
- d->nameFilters = filters;
+ QStringList cleanedFilters;
+ for (int i = 0; i < filters.count(); ++i) {
+ cleanedFilters << filters[i].simplified();
+ }
+ d->nameFilters = cleanedFilters;
if (d->nativeDialogInUse){
- d->setNameFilters_sys(filters);
+ d->setNameFilters_sys(cleanedFilters);
return;
}
d->qFileDialogUi->fileTypeCombo->clear();
- if (filters.isEmpty())
+ if (cleanedFilters.isEmpty())
return;
if (testOption(HideNameFilterDetails)) {
QStringList strippedFilters;
- for (int i = 0; i < filters.count(); ++i) {
- strippedFilters.append(filters[i].mid(0, filters[i].indexOf(QLatin1String(" ("))));
+ for (int i = 0; i < cleanedFilters.count(); ++i) {
+ strippedFilters.append(cleanedFilters[i].mid(0, cleanedFilters[i].indexOf(QLatin1String(" ("))));
}
d->qFileDialogUi->fileTypeCombo->addItems(strippedFilters);
} else {
- d->qFileDialogUi->fileTypeCombo->addItems(filters);
+ d->qFileDialogUi->fileTypeCombo->addItems(cleanedFilters);
}
d->_q_useNameFilter(0);
}
@@ -1436,6 +1443,8 @@ void QFileDialog::setIconProvider(QFileIconProvider *provider)
{
Q_D(QFileDialog);
d->model->setIconProvider(provider);
+ //It forces the refresh of all entries in the side bar, then we can get new icons
+ d->qFileDialogUi->sidebar->setUrls(d->qFileDialogUi->sidebar->urls());
}
/*!
@@ -1592,7 +1601,12 @@ QString QFileDialog::getOpenFileName(QWidget *parent,
args.parent = parent;
args.caption = caption;
args.directory = QFileDialogPrivate::workingDirectory(dir);
- args.selection = QFileDialogPrivate::initialSelection(dir);
+ //If workingDirectory returned a different path than the initial one,
+ //it means that the initial path was invalid. There is no point to try select a file
+ if (args.directory != QFileInfo(dir).path())
+ args.selection = QString();
+ else
+ args.selection = QFileDialogPrivate::initialSelection(dir);
args.filter = filter;
args.mode = ExistingFile;
args.options = options;
@@ -1677,7 +1691,12 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent,
args.parent = parent;
args.caption = caption;
args.directory = QFileDialogPrivate::workingDirectory(dir);
- args.selection = QFileDialogPrivate::initialSelection(dir);
+ //If workingDirectory returned a different path than the initial one,
+ //it means that the initial path was invalid. There is no point to try select a file
+ if (args.directory != QFileInfo(dir).path())
+ args.selection = QString();
+ else
+ args.selection = QFileDialogPrivate::initialSelection(dir);
args.filter = filter;
args.mode = ExistingFiles;
args.options = options;
@@ -1763,7 +1782,12 @@ QString QFileDialog::getSaveFileName(QWidget *parent,
args.parent = parent;
args.caption = caption;
args.directory = QFileDialogPrivate::workingDirectory(dir);
- args.selection = QFileDialogPrivate::initialSelection(dir);
+ //If workingDirectory returned a different path than the initial one,
+ //it means that the initial path was invalid. There is no point to try select a file
+ if (args.directory != QFileInfo(dir).path())
+ args.selection = QString();
+ else
+ args.selection = QFileDialogPrivate::initialSelection(dir);
args.filter = filter;
args.mode = AnyFile;
args.options = options;
@@ -2127,6 +2151,7 @@ void QFileDialogPrivate::createWidgets()
#ifndef QT_NO_COMPLETER
completer = new QFSCompletor(model, q);
qFileDialogUi->fileNameEdit->setCompleter(completer);
+ completer->sourceModel = model;
QObject::connect(qFileDialogUi->fileNameEdit, SIGNAL(textChanged(QString)),
q, SLOT(_q_autoCompleteFileName(QString)));
#endif // QT_NO_COMPLETER
@@ -2249,12 +2274,21 @@ void QFileDialog::setProxyModel(QAbstractProxyModel *proxyModel)
proxyModel->setSourceModel(d->model);
d->qFileDialogUi->listView->setModel(d->proxyModel);
d->qFileDialogUi->treeView->setModel(d->proxyModel);
+#ifndef QT_NO_COMPLETER
+ d->completer->setModel(d->proxyModel);
+ d->completer->proxyModel = d->proxyModel;
+#endif
connect(d->proxyModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
this, SLOT(_q_rowsInserted(const QModelIndex &)));
} else {
d->proxyModel = 0;
d->qFileDialogUi->listView->setModel(d->model);
d->qFileDialogUi->treeView->setModel(d->model);
+#ifndef QT_NO_COMPLETER
+ d->completer->setModel(d->model);
+ d->completer->sourceModel = d->model;
+ d->completer->proxyModel = 0;
+#endif
connect(d->model, SIGNAL(rowsInserted(const QModelIndex &, int, int)),
this, SLOT(_q_rowsInserted(const QModelIndex &)));
}
@@ -2767,8 +2801,9 @@ void QFileDialogPrivate::_q_enterDirectory(const QModelIndex &index)
{
Q_Q(QFileDialog);
// My Computer or a directory
- QString path = index.data(QFileSystemModel::FilePathRole).toString();
- if (path.isEmpty() || model->isDir(index)) {
+ QModelIndex sourceIndex = mapToSource(index);
+ QString path = sourceIndex.data(QFileSystemModel::FilePathRole).toString();
+ if (path.isEmpty() || model->isDir(sourceIndex)) {
q->setDirectory(path);
emit q->directoryEntered(path);
if (fileMode == QFileDialog::Directory
@@ -3142,7 +3177,11 @@ void QFileDialogLineEdit::keyPressEvent(QKeyEvent *e)
QString QFSCompletor::pathFromIndex(const QModelIndex &index) const
{
- const QFileSystemModel *dirModel = static_cast<const QFileSystemModel *>(model());
+ const QFileSystemModel *dirModel;
+ if (proxyModel)
+ dirModel = qobject_cast<const QFileSystemModel *>(proxyModel->sourceModel());
+ else
+ dirModel = sourceModel;
QString currentLocation = dirModel->rootPath();
QString path = index.data(QFileSystemModel::FilePathRole).toString();
if (!currentLocation.isEmpty() && path.startsWith(currentLocation)) {
@@ -3195,7 +3234,11 @@ QStringList QFSCompletor::splitPath(const QString &path) const
bool startsFromRoot = path[0] == sep[0];
#endif
if (parts.count() == 1 || (parts.count() > 1 && !startsFromRoot)) {
- const QFileSystemModel *dirModel = static_cast<const QFileSystemModel *>(model());
+ const QFileSystemModel *dirModel;
+ if (proxyModel)
+ dirModel = qobject_cast<const QFileSystemModel *>(proxyModel->sourceModel());
+ else
+ dirModel = sourceModel;
QString currentLocation = QDir::toNativeSeparators(dirModel->rootPath());
if (currentLocation.contains(sep) && path != currentLocation) {
QStringList currentLocationList = splitPath(currentLocation);
diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/gui/dialogs/qfiledialog_mac.mm
index 4c13d01..90af9fc 100644
--- a/src/gui/dialogs/qfiledialog_mac.mm
+++ b/src/gui/dialogs/qfiledialog_mac.mm
@@ -278,7 +278,7 @@ QT_USE_NAMESPACE
{
Q_UNUSED(sender);
QString qtFileName = QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString)(filename);
- QFileInfo info(qtFileName);
+ QFileInfo info(qtFileName.normalized(QT_PREPEND_NAMESPACE(QString::NormalizationForm_C)));
QString path = info.absolutePath();
if (path != *mLastFilterCheckPath){
*mLastFilterCheckPath = path;
diff --git a/src/gui/dialogs/qfiledialog_p.h b/src/gui/dialogs/qfiledialog_p.h
index ef282ae..bbd4af3 100644
--- a/src/gui/dialogs/qfiledialog_p.h
+++ b/src/gui/dialogs/qfiledialog_p.h
@@ -91,6 +91,26 @@ class QCompleter;
class QHBoxLayout;
class Ui_QFileDialog;
+#ifndef QT_NO_COMPLETER
+/*!
+ QCompleter that can deal with QFileSystemModel
+ */
+class QFSCompletor : public QCompleter {
+public:
+ QFSCompletor(QAbstractItemModel *model, QObject *parent = 0) : QCompleter(model, parent), proxyModel(0), sourceModel(0)
+ {
+#ifdef Q_OS_WIN || defined(Q_OS_SYMBIAN)
+ setCaseSensitivity(Qt::CaseInsensitive);
+#endif
+ }
+ QString pathFromIndex(const QModelIndex &index) const;
+ QStringList splitPath(const QString& path) const;
+
+ QAbstractProxyModel *proxyModel;
+ QFileSystemModel *sourceModel;
+};
+#endif // QT_NO_COMPLETER
+
struct QFileDialogArgs
{
QFileDialogArgs() : parent(0), mode(QFileDialog::AnyFile) {}
@@ -255,7 +275,7 @@ public:
// data
QStringList watching;
QFileSystemModel *model;
- QCompleter *completer;
+ QFSCompletor *completer;
QFileDialog::FileMode fileMode;
QFileDialog::AcceptMode acceptMode;
@@ -434,23 +454,6 @@ inline QString QFileDialogPrivate::rootPath() const {
inline QString QFileDialogPrivate::selectedNameFilter_sys() const { return QString(); }
#endif
-#ifndef QT_NO_COMPLETER
-/*!
- QCompleter that can deal with QFileSystemModel
- */
-class QFSCompletor : public QCompleter {
-public:
- QFSCompletor(QAbstractItemModel *model, QObject *parent = 0) : QCompleter(model, parent)
- {
-#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
- setCaseSensitivity(Qt::CaseInsensitive);
-#endif
- }
- QString pathFromIndex(const QModelIndex &index) const;
- QStringList splitPath(const QString& path) const;
-};
-#endif // QT_NO_COMPLETER
-
QT_END_NAMESPACE
#endif // QT_NO_FILEDIALOG
diff --git a/src/gui/dialogs/qfileinfogatherer.cpp b/src/gui/dialogs/qfileinfogatherer.cpp
index 7b849f7..a2abe54 100644
--- a/src/gui/dialogs/qfileinfogatherer.cpp
+++ b/src/gui/dialogs/qfileinfogatherer.cpp
@@ -168,6 +168,20 @@ void QFileInfoGatherer::clear()
}
/*
+ Remove a \a path from the watcher
+
+ \sa listed()
+*/
+void QFileInfoGatherer::removePath(const QString &path)
+{
+#ifndef QT_NO_FILESYSTEMWATCHER
+ mutex.lock();
+ watcher->removePath(path);
+ mutex.unlock();
+#endif
+}
+
+/*
List all files in \a directoryPath
\sa listed()
@@ -288,15 +302,9 @@ QString QFileInfoGatherer::translateDriveName(const QFileInfo &drive) const
void QFileInfoGatherer::getFileInfos(const QString &path, const QStringList &files)
{
#ifndef QT_NO_FILESYSTEMWATCHER
- //### We test here if the path still exist before adding it in the watcher
- //### because sometime the file is deleted just before enter here so QStringList files is not up to date
- //### It is not a proper fix, perhaps in 4.6 we should have a better way to avoid that
- //### to ensure the gatherer have fresh information
- QFileInfo info(path);
if (files.isEmpty()
&& !watcher->directories().contains(path)
&& !path.isEmpty()
- && info.exists()
&& !path.startsWith(QLatin1String("//")) /*don't watch UNC path*/) {
watcher->addPath(path);
}
diff --git a/src/gui/dialogs/qfileinfogatherer_p.h b/src/gui/dialogs/qfileinfogatherer_p.h
index eac0d46..60b9d5f 100644
--- a/src/gui/dialogs/qfileinfogatherer_p.h
+++ b/src/gui/dialogs/qfileinfogatherer_p.h
@@ -161,6 +161,7 @@ public:
~QFileInfoGatherer();
void clear();
+ void removePath(const QString &path);
QExtendedInformation getInfo(const QFileInfo &info) const;
public Q_SLOTS:
diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp
index 8b68411..b202629 100644
--- a/src/gui/dialogs/qfilesystemmodel.cpp
+++ b/src/gui/dialogs/qfilesystemmodel.cpp
@@ -166,6 +166,8 @@ bool QFileSystemModel::remove(const QModelIndex &aindex) const
{
//### TODO optim
QString path = filePath(aindex);
+ QFileSystemModelPrivate * d = const_cast<QFileSystemModelPrivate*>(d_func());
+ d->fileInfoGatherer.removePath(path);
QDirIterator it(path,
QDir::AllDirs | QDir:: Files | QDir::NoDotAndDotDot,
QDirIterator::Subdirectories);
@@ -375,7 +377,7 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS
if (!info.exists())
return rootNode;
QFileSystemModelPrivate *p = const_cast<QFileSystemModelPrivate*>(this);
- p->addNode(rootNode, host);
+ p->addNode(rootNode, host,info);
p->addVisibleFiles(rootNode, QStringList(host));
}
r = rootNode->visibleLocation(host);
@@ -407,6 +409,7 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS
#endif
QFileSystemModelPrivate::QFileSystemNode *parent = node(index);
+
for (int i = 0; i < pathElements.count(); ++i) {
QString element = pathElements.at(i);
#ifdef Q_OS_WIN
@@ -435,7 +438,7 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS
if (!info.exists())
return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
QFileSystemModelPrivate *p = const_cast<QFileSystemModelPrivate*>(this);
- node = p->addNode(parent, element);
+ node = p->addNode(parent, element,info);
#ifndef QT_NO_FILESYSTEMWATCHER
node->populate(fileInfoGatherer.getInfo(info));
#endif
@@ -855,7 +858,7 @@ bool QFileSystemModel::setData(const QModelIndex &idx, const QVariant &value, in
QFileSystemModelPrivate::QFileSystemNode *parentNode = indexNode->parent;
int visibleLocation = parentNode->visibleLocation(parentNode->children.value(indexNode->fileName)->fileName);
- d->addNode(parentNode, newName);
+ d->addNode(parentNode, newName,indexNode->info->fileInfo());
parentNode->visibleChildren.removeAt(visibleLocation);
QFileSystemModelPrivate::QFileSystemNode * oldValue = parentNode->children.value(oldName);
parentNode->children[newName] = oldValue;
@@ -1294,7 +1297,7 @@ QModelIndex QFileSystemModel::mkdir(const QModelIndex &parent, const QString &na
if (!dir.mkdir(name))
return QModelIndex();
QFileSystemModelPrivate::QFileSystemNode *parentNode = d->node(parent);
- d->addNode(parentNode, name);
+ d->addNode(parentNode, name, QFileInfo());
Q_ASSERT(parentNode->children.contains(name));
QFileSystemModelPrivate::QFileSystemNode *node = parentNode->children[name];
node->populate(d->fileInfoGatherer.getInfo(QFileInfo(dir.absolutePath() + QDir::separator() + name)));
@@ -1439,7 +1442,10 @@ void QFileSystemModel::setFilter(QDir::Filters filters)
}
/*!
- Returns the filter specification for the directory model.
+ Returns the filter specified for the directory model.
+
+ If a filter has not been set, the default filter is QDir::AllEntries |
+ QDir::NoDotAndDotDot | QDir::AllDirs.
\sa QDir::Filters
*/
@@ -1626,10 +1632,13 @@ void QFileSystemModelPrivate::_q_directoryChanged(const QString &directory, cons
*WARNING* this will change the count of children
*/
-QFileSystemModelPrivate::QFileSystemNode* QFileSystemModelPrivate::addNode(QFileSystemNode *parentNode, const QString &fileName)
+QFileSystemModelPrivate::QFileSystemNode* QFileSystemModelPrivate::addNode(QFileSystemNode *parentNode, const QString &fileName, const QFileInfo& info)
{
// In the common case, itemLocation == count() so check there first
QFileSystemModelPrivate::QFileSystemNode *node = new QFileSystemModelPrivate::QFileSystemNode(fileName, parentNode);
+#ifndef QT_NO_FILESYSTEMWATCHER
+ node->populate(info);
+#endif
parentNode->children.insert(fileName, node);
return node;
}
@@ -1747,7 +1756,7 @@ void QFileSystemModelPrivate::_q_fileSystemChanged(const QString &path, const QL
QExtendedInformation info = fileInfoGatherer.getInfo(updates.at(i).second);
bool previouslyHere = parentNode->children.contains(fileName);
if (!previouslyHere) {
- addNode(parentNode, fileName);
+ addNode(parentNode, fileName, info.fileInfo());
}
QFileSystemModelPrivate::QFileSystemNode * node = parentNode->children.value(fileName);
bool isCaseSensitive = parentNode->caseSensitive();
diff --git a/src/gui/dialogs/qfilesystemmodel.h b/src/gui/dialogs/qfilesystemmodel.h
index 52ecaf9..995268b 100644
--- a/src/gui/dialogs/qfilesystemmodel.h
+++ b/src/gui/dialogs/qfilesystemmodel.h
@@ -158,6 +158,8 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_performDelayedSort())
Q_PRIVATE_SLOT(d_func(), void _q_fileSystemChanged(const QString &path, const QList<QPair<QString, QFileInfo> > &))
Q_PRIVATE_SLOT(d_func(), void _q_resolvedName(const QString &fileName, const QString &resolvedName))
+
+ friend class QFileDialogPrivate;
};
inline bool QFileSystemModel::rmdir(const QModelIndex &aindex) const
diff --git a/src/gui/dialogs/qfilesystemmodel_p.h b/src/gui/dialogs/qfilesystemmodel_p.h
index f98a977..0a1265a 100644
--- a/src/gui/dialogs/qfilesystemmodel_p.h
+++ b/src/gui/dialogs/qfilesystemmodel_p.h
@@ -163,7 +163,11 @@ public:
info->icon = iconProvider->icon(QFileInfo(path));
QHash<QString, QFileSystemNode *>::const_iterator iterator;
for(iterator = children.constBegin() ; iterator != children.constEnd() ; ++iterator) {
- iterator.value()->updateIcon(iconProvider, path + QLatin1Char('/') + iterator.value()->fileName);
+ //On windows the root (My computer) has no path so we don't want to add a / for nothing (e.g. /C:/)
+ if (!path.isEmpty())
+ iterator.value()->updateIcon(iconProvider, path + QLatin1Char('/') + iterator.value()->fileName);
+ else
+ iterator.value()->updateIcon(iconProvider, iterator.value()->fileName);
}
}
@@ -172,17 +176,11 @@ public:
info->displayType = iconProvider->type(QFileInfo(path));
QHash<QString, QFileSystemNode *>::const_iterator iterator;
for(iterator = children.constBegin() ; iterator != children.constEnd() ; ++iterator) {
-#if defined(Q_OS_SYMBIAN)
- // Symbian can't handle paths in form of "/C:/foo/bar", so do not prepend the initial '/'
- QString newPath;
- if (path.isEmpty())
- newPath = iterator.value()->fileName;
+ //On windows the root (My computer) has no path so we don't want to add a / for nothing (e.g. /C:/)
+ if (!path.isEmpty())
+ iterator.value()->retranslateStrings(iconProvider, path + QLatin1Char('/') + iterator.value()->fileName);
else
- newPath = path + QLatin1Char('/') + iterator.value()->fileName;
- iterator.value()->retranslateStrings(iconProvider, newPath);
-#else
- iterator.value()->retranslateStrings(iconProvider, path + QLatin1Char('/') + iterator.value()->fileName);
-#endif
+ iterator.value()->retranslateStrings(iconProvider, iterator.value()->fileName);
}
}
@@ -192,7 +190,7 @@ public:
QList<QString> visibleChildren;
QFileSystemNode *parent;
- private:
+
QExtendedInformation *info;
};
@@ -226,7 +224,7 @@ public:
bool filtersAcceptsNode(const QFileSystemNode *node) const;
bool passNameFilters(const QFileSystemNode *node) const;
void removeNode(QFileSystemNode *parentNode, const QString &name);
- QFileSystemNode* addNode(QFileSystemNode *parentNode, const QString &fileName);
+ QFileSystemNode* addNode(QFileSystemNode *parentNode, const QString &fileName, const QFileInfo &info);
void addVisibleFiles(QFileSystemNode *parentNode, const QStringList &newFiles);
void removeVisibleFile(QFileSystemNode *parentNode, int visibleLocation);
void sortChildren(int column, const QModelIndex &parent);
diff --git a/src/gui/dialogs/qfontdialog_mac.mm b/src/gui/dialogs/qfontdialog_mac.mm
index d6ddfa3..42be3be 100644
--- a/src/gui/dialogs/qfontdialog_mac.mm
+++ b/src/gui/dialogs/qfontdialog_mac.mm
@@ -190,7 +190,7 @@ const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWin
newFont.setStrikeOut(mQtFont->strikeOut());
}
- [self setQtFont:newFont];
+ [self setQtFont:newFont];
if (mPriv)
mPriv->updateSampleFont(*mQtFont);
}
@@ -357,8 +357,8 @@ const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWin
- (void)setQtFont:(const QFont &)newFont
{
- delete mQtFont;
- mQtFont = new QFont(newFont);
+ delete mQtFont;
+ mQtFont = new QFont(newFont);
}
- (QFont)qtFont
@@ -404,6 +404,7 @@ const int StyleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWin
}
[mFontPanel setDelegate:nil];
[[NSFontManager sharedFontManager] setDelegate:nil];
+ [[NSFontManager sharedFontManager] setTarget:nil];
}
@end
@@ -527,6 +528,7 @@ void *QFontDialogPrivate::openCocoaFontPanel(const QFont &initial,
extraHeight:dialogExtraHeight];
[ourPanel setDelegate:delegate];
[[NSFontManager sharedFontManager] setDelegate:delegate];
+ [[NSFontManager sharedFontManager] setTarget:delegate];
setFont(delegate, initial);
// hack to get correct initial layout
diff --git a/src/gui/dialogs/qinputdialog.cpp b/src/gui/dialogs/qinputdialog.cpp
index b63c8ee..78d99e3 100644
--- a/src/gui/dialogs/qinputdialog.cpp
+++ b/src/gui/dialogs/qinputdialog.cpp
@@ -424,26 +424,27 @@ void QInputDialogPrivate::_q_currentRowChanged(const QModelIndex &newIndex,
/*!
\class QInputDialog
- \brief The QInputDialog class provides a simple convenience dialog to get a single value from the user.
+ \brief The QInputDialog class provides a simple convenience dialog to get a
+ single value from the user.
\ingroup dialogs
\mainclass
- The input value can be a string, a number or an item from a list. A
- label must be set to tell the user what they should enter.
+ The input value can be a string, a number or an item from a list. A label
+ must be set to tell the user what they should enter.
- Four static convenience functions are provided:
- getText(), getInt(), getDouble(), and getItem(). All the
- functions can be used in a similar way, for example:
+ Four static convenience functions are provided: getText(), getInt(),
+ getDouble(), and getItem(). All the functions can be used in a similar way,
+ for example:
\snippet examples/dialogs/standarddialogs/dialog.cpp 3
- The \c ok variable is set to true if the user clicks \gui OK;
- otherwise it is set to false.
+ The \c ok variable is set to true if the user clicks \gui OK; otherwise it
+ is set to false.
\img inputdialogs.png Input Dialogs
- The \l{dialogs/standarddialogs}{Standard Dialogs} example shows
- how to use QInputDialog as well as other built-in Qt dialogs.
+ The \l{dialogs/standarddialogs}{Standard Dialogs} example shows how to use
+ QInputDialog as well as other built-in Qt dialogs.
\sa QMessageBox, {Standard Dialogs Example}
*/
@@ -452,11 +453,13 @@ void QInputDialogPrivate::_q_currentRowChanged(const QModelIndex &newIndex,
\enum QInputDialog::InputMode
\since 4.5
- This enum describes the different modes of input that can be selected for the dialog.
+ This enum describes the different modes of input that can be selected for
+ the dialog.
\value TextInput Used to input text strings.
\value IntInput Used to input integers.
- \value DoubleInput Used to input floating point numbers with double precision accuracy.
+ \value DoubleInput Used to input floating point numbers with double
+ precision accuracy.
\sa inputMode
*/
@@ -487,7 +490,8 @@ QInputDialog::~QInputDialog()
\brief the mode used for input
- This property help determines which widget is used for entering input into the dialog.
+ This property help determines which widget is used for entering input into
+ the dialog.
*/
void QInputDialog::setInputMode(InputMode mode)
{
@@ -1104,15 +1108,18 @@ void QInputDialog::done(int result)
}
/*!
- Static convenience function to get a string 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 text is the default text which is
- placed in the line edit. The \a mode is the echo mode the line
- edit will use. If \a ok is nonnull \e *\a ok will be set to true
- if the user pressed \gui OK and to false if the user pressed
- \gui Cancel. The dialog's parent is \a parent. The dialog will be
- modal and uses the specified widget \a flags.
+ Static convenience function to get a string 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 text is the default text which is placed in the line edit.
+ \a mode is the echo mode the line edit will use.
+
+ If \a ok is nonnull \e *\a ok will be set to true if the user pressed
+ \gui OK and to false if the user pressed \gui Cancel. The dialog's parent
+ is \a parent. The dialog will be modal and uses the specified widget
+ \a flags.
This function returns the text which has been entered in the line
edit. It will not return an empty string.
@@ -1121,11 +1128,11 @@ void QInputDialog::done(int result)
\snippet examples/dialogs/standarddialogs/dialog.cpp 3
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QInputDialog constructors.
+ \warning Do not delete \a parent during the execution of the dialog. If you
+ want to do this, you should create the dialog yourself using one of the
+ QInputDialog constructors.
- \sa getInteger(), getDouble(), getItem()
+ \sa getInt(), getDouble(), getItem()
*/
QString QInputDialog::getText(QWidget *parent, const QString &title, const QString &label,
@@ -1149,30 +1156,32 @@ QString QInputDialog::getText(QWidget *parent, const QString &title, const QStri
}
/*!
- Static convenience function to get an integer input 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
- integer which the spinbox will be set to. \a min and \a
- max are the minimum and maximum values the user may choose,
- and \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 \gui OK and to false if the user pressed \gui Cancel. The
- dialog's parent is \a parent. The dialog will be modal and uses
- the widget \a flags.
-
- On success, this function returns the integer which has been
- entered by the user; on failure, it returns the initial \a value.
+ \since 4.5
+
+ Static convenience function to get an integer input 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 integer which the spinbox will be set to.
+ \a min and \a max are the minimum and maximum values the user may choose.
+ \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 \gui OK
+ and to false if the user pressed \gui Cancel. The dialog's parent is
+ \a parent. The dialog will be modal and uses the widget \a flags.
+
+ On success, this function returns the integer which has been entered by the
+ user; on failure, it returns the initial \a value.
Use this static function like this:
\snippet examples/dialogs/standarddialogs/dialog.cpp 0
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QInputDialog constructors.
+ \warning Do not delete \a parent during the execution of the dialog. If you
+ want to do this, you should create the dialog yourself using one of the
+ QInputDialog constructors.
\sa getText(), getDouble(), getItem()
*/
@@ -1198,32 +1207,32 @@ int QInputDialog::getInt(QWidget *parent, const QString &title, const QString &l
}
/*!
- 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, and \a decimals is the maximum number of decimal
- places the number may have.
-
- If \a ok is nonnull, *\a ok will be set to true if the user
- pressed \gui OK and to false if the user pressed \gui 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.
+ 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.
+
+ If \a ok is nonnull, *\a ok will be set to true if the user pressed \gui OK
+ and to false if the user pressed \gui 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 examples/dialogs/standarddialogs/dialog.cpp 1
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QInputDialog constructors.
+ \warning Do not delete \a parent during the execution of the dialog. If you
+ want to do this, you should create the dialog yourself using one of the
+ QInputDialog constructors.
- \sa getText(), getInteger(), getItem()
+ \sa getText(), getInt(), getItem()
*/
double QInputDialog::getDouble(QWidget *parent, const QString &title, const QString &label,
@@ -1248,32 +1257,34 @@ double QInputDialog::getDouble(QWidget *parent, const QString &title, const QStr
}
/*!
- Static convenience function to let the user select an item from a
- string list. \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 items is the
- string list which is inserted into the combobox, and \a current is the number
- of the item which should be the current item. If \a editable is true
- the user can enter their own text; if \a editable is false the user
- may only select one of the existing items.
-
- If \a ok is nonnull \e *\a ok will be set to true if the user
- pressed \gui OK and to false if the user pressed \gui Cancel. The
- dialog's parent is \a parent. The dialog will be modal and uses
- the widget \a flags.
-
- This function returns the text of the current item, or if \a
- editable is true, the current text of the combobox.
+ Static convenience function to let the user select an item from a string
+ list.
+
+ \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 items is the string list which is inserted into the combobox.
+ \a current is the number of the item which should be the current item.
+
+ If \a editable is true the user can enter their own text; otherwise the
+ user may only select one of the existing items.
+
+ If \a ok is nonnull \e *\a ok will be set to true if the user pressed
+ \gui OK and to false if the user pressed \gui Cancel. The dialog's parent
+ is \a parent. The dialog will be modal and uses the widget \a flags.
+
+ This function returns the text of the current item, or if \a editable is
+ true, the current text of the combobox.
Use this static function like this:
\snippet examples/dialogs/standarddialogs/dialog.cpp 2
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QInputDialog constructors.
+ \warning Do not delete \a parent during the execution of the dialog. If you
+ want to do this, you should create the dialog yourself using one of the
+ QInputDialog constructors.
- \sa getText(), getInteger(), getDouble()
+ \sa getText(), getInt(), getDouble()
*/
QString QInputDialog::getItem(QWidget *parent, const QString &title, const QString &label,
diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp
index 34f123e..9702fd1 100644
--- a/src/gui/dialogs/qmessagebox.cpp
+++ b/src/gui/dialogs/qmessagebox.cpp
@@ -532,11 +532,11 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button)
\section2 Severity Levels and the Icon and Pixmap Properties
- QMessageBox supports four predefined message severity levels, or
- message types, which really only differ in the predefined icon
- they each show. Specify one of the four predefined message types
- by setting the \l{QMessageBox::icon} {icon} property to one of the
- \l{QMessageBox::Icon} {predefined Icons}. The following rules are
+ QMessageBox supports four predefined message severity levels, or message
+ types, which really only differ in the predefined icon they each show.
+ Specify one of the four predefined message types by setting the
+ \l{QMessageBox::icon}{icon} property to one of the
+ \l{QMessageBox::Icon}{predefined icons}. The following rules are
guidelines:
\table
@@ -558,17 +558,17 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button)
\o For reporting critical errors.
\endtable
- The default value is \l{QMessageBox::NoIcon} {No Icon}. The
- message boxes are otherwise the same for all cases. When using a
- standard icon, use the one recommended in the table, or use the
- one recommended by the style guidelines for your platform. If none
- of the standard icons is right for your message box, you can use a
- custom icon by setting the \l{QMessageBox::iconPixmap} {icon
- pixmap} property instead of setting the \l{QMessageBox::icon}
- {icon} property.
+ \l{QMessageBox::Icon}{Predefined icons} are not defined by QMessageBox, but
+ provided by the style. The default value is \l{QMessageBox::NoIcon}
+ {No Icon}. The message boxes are otherwise the same for all cases. When
+ using a standard icon, use the one recommended in the table, or use the
+ one recommended by the style guidelines for your platform. If none of the
+ standard icons is right for your message box, you can use a custom icon by
+ setting the \l{QMessageBox::iconPixmap}{icon pixmap} property instead of
+ setting the \l{QMessageBox::icon}{icon} property.
- In summary, to set an icon, use \e{either} setIcon() for one of
- the standard icons, \e{or} setIconPixmap() for a custom icon.
+ In summary, to set an icon, use \e{either} setIcon() for one of the
+ standard icons, \e{or} setIconPixmap() for a custom icon.
\section1 The Static Functions API
@@ -1680,7 +1680,7 @@ void QMessageBox::aboutQt(QWidget *parent, const QString &title)
{
#ifdef Q_WS_MAC
static QPointer<QMessageBox> oldMsgBox;
-
+
if (oldMsgBox) {
oldMsgBox->show();
oldMsgBox->raise();
@@ -1692,29 +1692,35 @@ void QMessageBox::aboutQt(QWidget *parent, const QString &title)
QString translatedTextAboutQt;
translatedTextAboutQt = QMessageBox::tr(
"<h3>About Qt</h3>"
- "%1<p>Qt is a C++ toolkit for cross-platform "
- "application development.</p>"
- "<p>Qt provides single-source "
- "portability across MS&nbsp;Windows, Mac&nbsp;OS&nbsp;X, "
- "Linux, and all major commercial Unix variants. Qt is also"
- " available for embedded devices as Qt for Embedded Linux"
- " and Qt for Windows CE.</p>"
- "<p>Qt is a Nokia product. See "
- "<a href=\"http://qtsoftware.com/qt/\">qtsoftware.com/qt/</a> for more information.</p>"
- )
-#if QT_EDITION != QT_EDITION_OPENSOURCE
- .arg(QMessageBox::tr("<p>This program uses Qt version %1.</p>"))
-#else
- .arg(QMessageBox::tr("<p>This program uses Qt Open Source Edition version %1.</p>"
- "<p>Qt Open Source Edition is intended for the development "
- "of Open Source applications. You need a commercial Qt "
- "license for development of proprietary (closed source) "
- "applications.</p>"
- "<p>Please see <a href=\"http://qtsoftware.com/company/model/\">qtsoftware.com/company/model/</a> "
- "for an overview of Qt licensing.</p>"))
-#endif
-
- .arg(QLatin1String(QT_VERSION_STR));
+ "<p>This program uses Qt version %1.</p>"
+ "<p>Qt is a C++ toolkit for cross-platform application "
+ "development.</p>"
+ "<p>Qt provides single-source portability across MS&nbsp;Windows, "
+ "Mac&nbsp;OS&nbsp;X, Linux, and all major commercial Unix variants. "
+ "Qt is also available for embedded devices as Qt for Embedded Linux "
+ "and Qt for Windows CE.</p>"
+ "<p>Qt is available under three different licensing options designed "
+ "to accommodate the needs of our various users.</p>"
+ "Qt licensed under our commercial license agreement is appropriate "
+ "for development of proprietary/commercial software where you do not "
+ "want to share any source code with third parties or otherwise cannot "
+ "comply with the terms of the GNU LGPL version 2.1 or GNU GPL version "
+ "3.0.</p>"
+ "<p>Qt licensed under the GNU LGPL version 2.1 is appropriate for the "
+ "development of Qt applications (proprietary or open source) provided "
+ "you can comply with the terms and conditions of the GNU LGPL version "
+ "2.1.</p>"
+ "<p>Qt licensed under the GNU General Public License version 3.0 is "
+ "appropriate for the development of Qt applications where you wish to "
+ "use such applications in combination with software subject to the "
+ "terms of the GNU GPL version 3.0 or where you are otherwise willing "
+ "to comply with the terms of the GNU GPL version 3.0.</p>"
+ "<p>Please see <a href=\"http://www.qtsoftware.com/products/licensing\">www.qtsoftware.com/products/licensing</a> "
+ "for an overview of Qt licensing.</p>"
+ "<p>Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).</p>"
+ "<p>Qt is a Nokia product. See <a href=\"http://www.qtsoftware.com/qt/\">www.qtsoftware.com/qt</a> "
+ "for more information.</p>"
+ ).arg(QLatin1String(QT_VERSION_STR));
QMessageBox *msgBox = new QMessageBox(parent);
msgBox->setAttribute(Qt::WA_DeleteOnClose);
diff --git a/src/gui/dialogs/qprintdialog_unix.cpp b/src/gui/dialogs/qprintdialog_unix.cpp
index 76c22d0..87a4e65 100644
--- a/src/gui/dialogs/qprintdialog_unix.cpp
+++ b/src/gui/dialogs/qprintdialog_unix.cpp
@@ -727,7 +727,9 @@ void QUnixPrintWidgetPrivate::updateWidget()
widget.printers->removeItem(widget.printers->count()-1); // remove separator
filePrintersAdded = false;
}
- if (printer && filePrintersAdded && printer->printerName().isEmpty()) {
+ if (printer && filePrintersAdded && (printer->outputFormat() != QPrinter::NativeFormat
+ || printer->printerName().isEmpty()))
+ {
if (printer->outputFormat() == QPrinter::PdfFormat)
widget.printers->setCurrentIndex(widget.printers->count() - 2);
else if (printer->outputFormat() == QPrinter::PostScriptFormat)
diff --git a/src/gui/dialogs/qsidebar.cpp b/src/gui/dialogs/qsidebar.cpp
index 1bd2b7d..26108d7 100644
--- a/src/gui/dialogs/qsidebar.cpp
+++ b/src/gui/dialogs/qsidebar.cpp
@@ -55,6 +55,18 @@
QT_BEGIN_NAMESPACE
+void QSideBarDelegate::initStyleOption(QStyleOptionViewItem *option,
+ const QModelIndex &index) const
+{
+ QStyledItemDelegate::initStyleOption(option,index);
+ QVariant value = index.data(QUrlModel::EnabledRole);
+ if (value.isValid()) {
+ //If the bookmark/entry is not enabled then we paint it in gray
+ if (!qvariant_cast<bool>(value))
+ option->state &= ~QStyle::State_Enabled;
+ }
+}
+
/*!
QUrlModel lets you have indexes from a QFileSystemModel to a list. When QFileSystemModel
changes them QUrlModel will automatically update.
@@ -88,9 +100,6 @@ Qt::ItemFlags QUrlModel::flags(const QModelIndex &index) const
if (index.data(Qt::DecorationRole).isNull())
flags &= ~Qt::ItemIsEnabled;
- if (invalidUrls.contains(index.data(UrlRole).toUrl()))
- flags &= ~Qt::ItemIsEnabled;
-
return flags;
}
@@ -193,6 +202,11 @@ void QUrlModel::setUrl(const QModelIndex &index, const QUrl &url, const QModelIn
newName = QFileInfo(url.toLocalFile()).fileName();
if (!invalidUrls.contains(url))
invalidUrls.append(url);
+ //The bookmark is invalid then we set to false the EnabledRole
+ setData(index, false, EnabledRole);
+ } else {
+ //The bookmark is valid then we set to true the EnabledRole
+ setData(index, true, EnabledRole);
}
// Make sure that we have at least 32x32 images
@@ -234,7 +248,11 @@ void QUrlModel::addUrls(const QList<QUrl> &list, int row, bool move)
if (!url.isValid() || url.scheme() != QLatin1String("file"))
continue;
for (int j = 0; move && j < rowCount(); ++j) {
+#if defined(Q_OS_WIN)
+ if (index(j, 0).data(UrlRole).toUrl().toLocalFile().toLower() == url.toLocalFile().toLower()) {
+#else
if (index(j, 0).data(UrlRole) == url) {
+#endif
removeRow(j);
if (j <= row)
row--;
@@ -356,6 +374,7 @@ void QSidebar::init(QFileSystemModel *model, const QList<QUrl> &newUrls)
urlModel = new QUrlModel(this);
urlModel->setFileSystemModel(model);
setModel(urlModel);
+ setItemDelegate(new QSideBarDelegate(this));
connect(selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)),
this, SLOT(clicked(const QModelIndex &)));
diff --git a/src/gui/dialogs/qsidebar_p.h b/src/gui/dialogs/qsidebar_p.h
index ecbbb37..56fd6d4 100644
--- a/src/gui/dialogs/qsidebar_p.h
+++ b/src/gui/dialogs/qsidebar_p.h
@@ -55,6 +55,7 @@
#include <qlistwidget.h>
#include <qstandarditemmodel.h>
+#include <qstyleditemdelegate.h>
#include <qurl.h>
#ifndef QT_NO_FILEDIALOG
@@ -62,13 +63,23 @@
QT_BEGIN_NAMESPACE
class QFileSystemModel;
+
+class QSideBarDelegate : public QStyledItemDelegate
+{
+ public:
+ QSideBarDelegate(QWidget *parent = 0) : QStyledItemDelegate(parent) {}
+ void initStyleOption(QStyleOptionViewItem *option,
+ const QModelIndex &index) const;
+};
+
class Q_AUTOTEST_EXPORT QUrlModel : public QStandardItemModel
{
Q_OBJECT
public:
enum Roles {
- UrlRole = Qt::UserRole + 1
+ UrlRole = Qt::UserRole + 1,
+ EnabledRole = Qt::UserRole + 2
};
QUrlModel(QObject *parent = 0);
diff --git a/src/gui/embedded/qscreentransformed_qws.cpp b/src/gui/embedded/qscreentransformed_qws.cpp
index f988789..46ac1d1 100644
--- a/src/gui/embedded/qscreentransformed_qws.cpp
+++ b/src/gui/embedded/qscreentransformed_qws.cpp
@@ -410,7 +410,9 @@ void QTransformedScreen::blit(const QImage &image, const QPoint &topLeft,
#endif
#ifdef QT_QWS_DEPTH_8
case 8:
- if (image.depth() == 16)
+ if (image.format() == QImage::Format_RGB444)
+ SET_BLIT_FUNC(quint8, qrgb444, trans, func);
+ else if (image.depth() == 16)
SET_BLIT_FUNC(quint8, quint16, trans, func);
else
SET_BLIT_FUNC(quint8, quint32, trans, func);
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 7b885df..3e8d38f 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -528,25 +528,22 @@ QT_BEGIN_NAMESPACE
// QRectF::intersects() returns false always if either the source or target
// rectangle's width or height are 0. This works around that problem.
-static QRectF _q_adjustedRect(const QRectF &rect)
-{
- static const qreal p = (qreal)0.00001;
- QRectF r = rect;
- if (!r.width())
- r.adjust(-p, 0, p, 0);
- if (!r.height())
- r.adjust(0, -p, 0, p);
- return r;
+static inline void _q_adjustRect(QRectF *rect)
+{
+ Q_ASSERT(rect);
+ if (!rect->width())
+ rect->adjust(-0.00001, 0, 0.00001, 0);
+ if (!rect->height())
+ rect->adjust(0, -0.00001, 0, 0.00001);
}
-static QRect _q_adjustedRect(const QRect &rect)
+static inline void _q_adjustRect(QRect *rect)
{
- QRect r = rect;
- if (!r.width())
- r.adjust(0, 0, 1, 0);
- if (!r.height())
- r.adjust(0, 0, 0, 1);
- return r;
+ Q_ASSERT(rect);
+ if (!rect->width())
+ rect->adjust(0, 0, 1, 0);
+ if (!rect->height())
+ rect->adjust(0, 0, 0, 1);
}
/*
@@ -631,6 +628,7 @@ void QGraphicsItemPrivate::updateAncestorFlag(QGraphicsItem::GraphicsItemFlag ch
case QGraphicsItem::ItemClipsChildrenToShape:
flag = AncestorClipsChildren;
enabled = flags & QGraphicsItem::ItemClipsChildrenToShape;
+ invalidateCachedClipPathRecursively(/*childrenOnly=*/true);
break;
case QGraphicsItem::ItemIgnoresTransformations:
flag = AncestorIgnoresTransformations;
@@ -1023,9 +1021,8 @@ void QGraphicsItem::setParentItem(QGraphicsItem *parent)
}
if (parent == d_ptr->parent)
return;
- QVariant variant;
- qVariantSetValue<QGraphicsItem *>(variant, parent);
- parent = qVariantValue<QGraphicsItem *>(itemChange(ItemParentChange, variant));
+ const QVariant newParentVariant(itemChange(ItemParentChange, qVariantFromValue<QGraphicsItem *>(parent)));
+ parent = qVariantValue<QGraphicsItem *>(newParentVariant);
if (parent == d_ptr->parent)
return;
@@ -1040,11 +1037,11 @@ void QGraphicsItem::setParentItem(QGraphicsItem *parent)
// We anticipate geometry changes
prepareGeometryChange();
+ const QVariant thisPointerVariant(qVariantFromValue<QGraphicsItem *>(this));
if (d_ptr->parent) {
// Remove from current parent
qt_graphicsitem_removeChild(this, &d_ptr->parent->d_func()->children);
- qVariantSetValue<QGraphicsItem *>(variant, this);
- d_ptr->parent->itemChange(ItemChildRemovedChange, variant);
+ d_ptr->parent->itemChange(ItemChildRemovedChange, thisPointerVariant);
}
if ((d_ptr->parent = parent)) {
@@ -1059,10 +1056,9 @@ void QGraphicsItem::setParentItem(QGraphicsItem *parent)
}
d_ptr->parent->d_func()->children << this;
- qVariantSetValue<QGraphicsItem *>(variant, this);
- d_ptr->parent->itemChange(ItemChildAddedChange, variant);
+ d_ptr->parent->itemChange(ItemChildAddedChange, thisPointerVariant);
if (!implicitUpdate)
- d_ptr->updateHelper();
+ d_ptr->updateHelper(QRectF(), false, true);
// Inherit ancestor flags from the new parent.
d_ptr->updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-1));
@@ -1091,7 +1087,7 @@ void QGraphicsItem::setParentItem(QGraphicsItem *parent)
if (!d_ptr->enabled && !d_ptr->explicitlyDisabled)
d_ptr->setEnabledHelper(true, /* explicit = */ false);
- d_ptr->updateHelper();
+ d_ptr->updateHelper(QRectF(), false, true);
}
if (d_ptr->scene) {
@@ -1101,10 +1097,7 @@ void QGraphicsItem::setParentItem(QGraphicsItem *parent)
}
// Resolve opacity.
- if (QGraphicsItem *p = d_ptr->parent)
- d_ptr->resolveEffectiveOpacity(p->effectiveOpacity());
- else
- d_ptr->resolveEffectiveOpacity(1.0);
+ d_ptr->updateEffectiveOpacity();
// Resolve depth.
d_ptr->resolveDepth(parent ? parent->d_ptr->depth : -1);
@@ -1113,7 +1106,7 @@ void QGraphicsItem::setParentItem(QGraphicsItem *parent)
d_ptr->invalidateSceneTransformCache();
// Deliver post-change notification
- itemChange(QGraphicsItem::ItemParentHasChanged, qVariantFromValue<QGraphicsItem *>(parent));
+ itemChange(QGraphicsItem::ItemParentHasChanged, newParentVariant);
}
/*!
@@ -1235,7 +1228,7 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags)
int geomChangeFlagsMask = (ItemClipsChildrenToShape | ItemClipsToShape | ItemIgnoresTransformations);
bool fullUpdate = (flags & geomChangeFlagsMask) != (d_ptr->flags & geomChangeFlagsMask);
if (fullUpdate)
- d_ptr->fullUpdateHelper();
+ d_ptr->fullUpdateHelper(false, true);
// Keep the old flags to compare the diff.
GraphicsItemFlags oldFlags = this->flags();
@@ -1245,12 +1238,8 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags)
// Reresolve effective opacity if the opacity flags change.
static const quint32 opacityFlagsMask = ItemIgnoresParentOpacity | ItemDoesntPropagateOpacityToChildren;
- if ((flags & opacityFlagsMask) != (oldFlags & opacityFlagsMask)) {
- if (QGraphicsItem *p = d_ptr->parent)
- d_ptr->resolveEffectiveOpacity(p->effectiveOpacity());
- else
- d_ptr->resolveEffectiveOpacity(1.0);
- }
+ if ((flags & opacityFlagsMask) != (oldFlags & opacityFlagsMask))
+ d_ptr->updateEffectiveOpacity();
if (!(d_ptr->flags & ItemIsFocusable) && hasFocus()) {
// Clear focus on the item if it has focus when the focusable flag
@@ -1270,6 +1259,9 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags)
d_ptr->updateAncestorFlag(ItemClipsChildrenToShape);
}
+ if ((flags & ItemClipsToShape) != (oldFlags & ItemClipsToShape))
+ d_ptr->invalidateCachedClipPath();
+
if ((flags & ItemIgnoresTransformations) != (oldFlags & ItemIgnoresTransformations)) {
// Item children clipping changes. Propagate the ancestor flag to
// all children.
@@ -1277,7 +1269,7 @@ void QGraphicsItem::setFlags(GraphicsItemFlags flags)
}
// ### Why updateHelper?
- d_ptr->updateHelper();
+ d_ptr->updateHelper(QRectF(), false, true);
// Notify change.
itemChange(ItemFlagsHaveChanged, quint32(flags));
@@ -1375,9 +1367,9 @@ QString QGraphicsItem::toolTip() const
*/
void QGraphicsItem::setToolTip(const QString &toolTip)
{
- QString newCursor = itemChange(ItemToolTipChange, toolTip).toString();
- d_ptr->setExtra(QGraphicsItemPrivate::ExtraToolTip, toolTip);
- itemChange(ItemToolTipHasChanged, toolTip);
+ const QVariant toolTipVariant(itemChange(ItemToolTipChange, toolTip));
+ d_ptr->setExtra(QGraphicsItemPrivate::ExtraToolTip, toolTipVariant.toString());
+ itemChange(ItemToolTipHasChanged, toolTipVariant);
}
#endif // QT_NO_TOOLTIP
@@ -1419,9 +1411,8 @@ QCursor QGraphicsItem::cursor() const
*/
void QGraphicsItem::setCursor(const QCursor &cursor)
{
- QCursor newCursor = qVariantValue<QCursor>(itemChange(ItemCursorChange,
- qVariantFromValue<QCursor>(cursor)));
- d_ptr->setExtra(QGraphicsItemPrivate::ExtraCursor, newCursor);
+ const QVariant cursorVariant(itemChange(ItemCursorChange, qVariantFromValue<QCursor>(cursor)));
+ d_ptr->setExtra(QGraphicsItemPrivate::ExtraCursor, qVariantValue<QCursor>(cursorVariant));
d_ptr->hasCursor = 1;
if (d_ptr->scene) {
foreach (QGraphicsView *view, d_ptr->scene->views()) {
@@ -1438,7 +1429,7 @@ void QGraphicsItem::setCursor(const QCursor &cursor)
}
}
}
- itemChange(ItemCursorHasChanged, qVariantFromValue<QCursor>(newCursor));
+ itemChange(ItemCursorHasChanged, cursorVariant);
}
/*!
@@ -1532,7 +1523,9 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo
return;
// Modify the property.
- newVisible = q_ptr->itemChange(QGraphicsItem::ItemVisibleChange, quint32(newVisible)).toBool();
+ const QVariant newVisibleVariant(q_ptr->itemChange(QGraphicsItem::ItemVisibleChange,
+ quint32(newVisible)));
+ newVisible = newVisibleVariant.toBool();
if (visible == quint32(newVisible))
return;
visible = newVisible;
@@ -1579,9 +1572,10 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo
}
// Update children with explicitly = false.
+ const bool updateChildren = update && !(flags & QGraphicsItem::ItemClipsChildrenToShape);
foreach (QGraphicsItem *child, children) {
if (!newVisible || !child->d_ptr->explicitlyHidden)
- child->d_ptr->setVisibleHelper(newVisible, false);
+ child->d_ptr->setVisibleHelper(newVisible, false, updateChildren);
}
// Enable subfocus
@@ -1593,7 +1587,7 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo
}
// Deliver post-change notification.
- q_ptr->itemChange(QGraphicsItem::ItemVisibleHasChanged, quint32(visible));
+ q_ptr->itemChange(QGraphicsItem::ItemVisibleHasChanged, newVisibleVariant);
}
/*!
@@ -1699,7 +1693,9 @@ void QGraphicsItemPrivate::setEnabledHelper(bool newEnabled, bool explicitly, bo
}
// Modify the property.
- enabled = q_ptr->itemChange(QGraphicsItem::ItemEnabledChange, quint32(newEnabled)).toBool();
+ const QVariant newEnabledVariant(q_ptr->itemChange(QGraphicsItem::ItemEnabledChange,
+ quint32(newEnabled)));
+ enabled = newEnabledVariant.toBool();
// Schedule redraw.
if (update)
@@ -1711,7 +1707,7 @@ void QGraphicsItemPrivate::setEnabledHelper(bool newEnabled, bool explicitly, bo
}
// Deliver post-change notification.
- q_ptr->itemChange(QGraphicsItem::ItemEnabledHasChanged, quint32(enabled));
+ q_ptr->itemChange(QGraphicsItem::ItemEnabledHasChanged, newEnabledVariant);
}
/*!
@@ -1798,7 +1794,8 @@ void QGraphicsItem::setSelected(bool selected)
selected = false;
if (d_ptr->selected == selected)
return;
- bool newSelected = itemChange(ItemSelectedChange, quint32(selected)).toBool();
+ const QVariant newSelectedVariant(itemChange(ItemSelectedChange, quint32(selected)));
+ bool newSelected = newSelectedVariant.toBool();
if (d_ptr->selected == newSelected)
return;
d_ptr->selected = newSelected;
@@ -1818,7 +1815,7 @@ void QGraphicsItem::setSelected(bool selected)
}
// Deliver post-change notification.
- itemChange(QGraphicsItem::ItemSelectedHasChanged, quint32(d_ptr->selected));
+ itemChange(QGraphicsItem::ItemSelectedHasChanged, newSelectedVariant);
}
/*!
@@ -1862,6 +1859,9 @@ qreal QGraphicsItem::opacity() const
*/
qreal QGraphicsItem::effectiveOpacity() const
{
+ if (!d_ptr->hasEffectiveOpacity)
+ return qreal(1.0);
+
QVariant effectiveOpacity = d_ptr->extra(QGraphicsItemPrivate::ExtraEffectiveOpacity);
return effectiveOpacity.isNull() ? qreal(1.0) : qreal(effectiveOpacity.toDouble());
}
@@ -1891,7 +1891,8 @@ qreal QGraphicsItem::effectiveOpacity() const
void QGraphicsItem::setOpacity(qreal opacity)
{
// Notify change.
- qreal newOpacity = itemChange(ItemOpacityChange, double(opacity)).toDouble();
+ const QVariant newOpacityVariant(itemChange(ItemOpacityChange, double(opacity)));
+ qreal newOpacity = newOpacityVariant.toDouble();
// Normalize.
newOpacity = qBound<qreal>(0.0, newOpacity, 1.0);
@@ -2349,19 +2350,22 @@ QPointF QGraphicsItem::scenePos() const
the item is also updated; otherwise it is not updated before and after the
change.
*/
-void QGraphicsItemPrivate::setPosHelper(const QPointF &pos, bool update)
+void QGraphicsItemPrivate::setPosHelper(const QPointF &pos)
{
Q_Q(QGraphicsItem);
if (this->pos == pos)
return;
// Notify the item that the position is changing.
- QPointF newPos = q->itemChange(QGraphicsItem::ItemPositionChange, pos).toPointF();
+ const QVariant newPosVariant(q->itemChange(QGraphicsItem::ItemPositionChange, pos));
+ QPointF newPos = newPosVariant.toPointF();
if (newPos == this->pos)
return;
// Update and repositition.
- if (scene && update) {
+ inSetPosHelper = 1;
+ updateCachedClipPathFromSetPosHelper(newPos);
+ if (scene) {
fullUpdateHelper(true);
q->prepareGeometryChange();
}
@@ -2369,7 +2373,8 @@ void QGraphicsItemPrivate::setPosHelper(const QPointF &pos, bool update)
invalidateSceneTransformCache();
// Send post-notification.
- q->itemChange(QGraphicsItem::ItemPositionHasChanged, newPos);
+ q->itemChange(QGraphicsItem::ItemPositionHasChanged, newPosVariant);
+ inSetPosHelper = 0;
}
/*!
@@ -2384,7 +2389,7 @@ void QGraphicsItemPrivate::setPosHelper(const QPointF &pos, bool update)
*/
void QGraphicsItem::setPos(const QPointF &pos)
{
- d_ptr->setPosHelper(pos, /* update = */ true);
+ d_ptr->setPosHelper(pos);
}
/*!
@@ -2511,10 +2516,10 @@ QTransform QGraphicsItem::sceneTransform() const
QTransform m;
if (d_ptr->hasTransform) {
m = transform();
- m *= QTransform::fromTranslate(d_ptr->pos.x(), d_ptr->pos.y());
- } else {
- // ### ? QTransform::fromTranslate(d_ptr->pos.x(), d_ptr->pos.y())
- m.translate(d_ptr->pos.x(), d_ptr->pos.y());
+ if (!d_ptr->pos.isNull())
+ m *= QTransform::fromTranslate(d_ptr->pos.x(), d_ptr->pos.y());
+ } else if (!d_ptr->pos.isNull()) {
+ m = QTransform::fromTranslate(d_ptr->pos.x(), d_ptr->pos.y());
}
// Combine with parent and add to cache.
@@ -2639,6 +2644,8 @@ QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) co
if (ok)
*ok = true;
const QPointF &itemPos = d_ptr->pos;
+ if (itemPos.isNull())
+ return d_ptr->hasTransform ? transform() : QTransform();
if (d_ptr->hasTransform)
return transform() * QTransform::fromTranslate(itemPos.x(), itemPos.y());
return QTransform::fromTranslate(itemPos.x(), itemPos.y());
@@ -2649,7 +2656,8 @@ QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) co
const QPointF &otherPos = other->d_ptr->pos;
if (other->d_ptr->hasTransform) {
QTransform otherToParent = other->transform();
- otherToParent *= QTransform::fromTranslate(otherPos.x(), otherPos.y());
+ if (!otherPos.isNull())
+ otherToParent *= QTransform::fromTranslate(otherPos.x(), otherPos.y());
return otherToParent.inverted(ok);
} else {
if (ok)
@@ -2674,11 +2682,11 @@ QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) co
QTransform itemToParent = QTransform::fromTranslate(itemPos.x(), itemPos.y());
if (hasTr)
- itemToParent = transform() * itemToParent;
+ itemToParent = itemPos.isNull() ? transform() : transform() * itemToParent;
QTransform otherToParent = QTransform::fromTranslate(otherPos.x(), otherPos.y());
if (otherHasTr)
- otherToParent = other->transform() * otherToParent;
+ otherToParent = otherPos.isNull() ? other->transform() : other->transform() * otherToParent;
return itemToParent * otherToParent.inverted(ok);
}
@@ -2718,7 +2726,8 @@ QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) co
const QGraphicsItemPrivate *pd = p->d_ptr;
if (pd->hasTransform)
x *= p->transform();
- x *= QTransform::fromTranslate(pd->pos.x(), pd->pos.y());
+ if (!pd->pos.isNull())
+ x *= QTransform::fromTranslate(pd->pos.x(), pd->pos.y());
} while ((p = p->d_ptr->parent) && p != root);
if (parentOfOther)
return x.inverted(ok);
@@ -2750,21 +2759,23 @@ void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine)
return;
// Notify the item that the matrix is changing.
- QVariant variant;
- qVariantSetValue<QMatrix>(variant, newTransform.toAffine());
- newTransform = QTransform(qVariantValue<QMatrix>(itemChange(ItemMatrixChange, variant)));
+ QVariant newTransformVariant(itemChange(ItemMatrixChange,
+ qVariantFromValue<QMatrix>(newTransform.toAffine())));
+ newTransform = QTransform(qVariantValue<QMatrix>(newTransformVariant));
if (oldTransform == newTransform)
return;
// Update and set the new transformation.
- d_ptr->fullUpdateHelper(true);
+ d_ptr->fullUpdateHelper(true, true);
prepareGeometryChange();
d_ptr->hasTransform = !newTransform.isIdentity();
d_ptr->setExtra(QGraphicsItemPrivate::ExtraTransform, newTransform);
d_ptr->invalidateSceneTransformCache();
// Send post-notification.
- itemChange(ItemTransformHasChanged, newTransform);
+ // NB! We have to change the value from QMatrix to QTransform.
+ qVariantSetValue<QTransform>(newTransformVariant, newTransform);
+ itemChange(ItemTransformHasChanged, newTransformVariant);
}
/*!
@@ -2796,21 +2807,21 @@ void QGraphicsItem::setTransform(const QTransform &matrix, bool combine)
return;
// Notify the item that the transformation matrix is changing.
- QVariant variant;
- qVariantSetValue<QTransform>(variant, newTransform);
- newTransform = qVariantValue<QTransform>(itemChange(ItemTransformChange, variant));
+ const QVariant newTransformVariant(itemChange(ItemTransformChange,
+ qVariantFromValue<QTransform>(newTransform)));
+ newTransform = qVariantValue<QTransform>(newTransformVariant);
if (oldTransform == newTransform)
return;
// Update and set the new transformation.
- d_ptr->fullUpdateHelper(true);
+ d_ptr->fullUpdateHelper(true, true);
prepareGeometryChange();
d_ptr->hasTransform = !newTransform.isIdentity();
d_ptr->setExtra(QGraphicsItemPrivate::ExtraTransform, newTransform);
d_ptr->invalidateSceneTransformCache();
// Send post-notification.
- itemChange(ItemTransformHasChanged, newTransform);
+ itemChange(ItemTransformHasChanged, newTransformVariant);
}
/*!
@@ -2958,7 +2969,8 @@ qreal QGraphicsItem::zValue() const
*/
void QGraphicsItem::setZValue(qreal z)
{
- qreal newZ = qreal(itemChange(ItemZValueChange, double(z)).toDouble());
+ const QVariant newZVariant(itemChange(ItemZValueChange, double(z)));
+ qreal newZ = qreal(newZVariant.toDouble());
if (newZ == d_ptr->z)
return;
d_ptr->z = z;
@@ -2970,7 +2982,7 @@ void QGraphicsItem::setZValue(qreal z)
d_ptr->scene->d_func()->invalidateSortCache();
}
- itemChange(ItemZValueHasChanged, double(newZ));
+ itemChange(ItemZValueHasChanged, newZVariant);
}
/*!
@@ -2995,7 +3007,9 @@ QRectF QGraphicsItem::childrenBoundingRect() const
QRectF childRect;
foreach (QGraphicsItem *child, children()) {
QPointF childPos = child->pos();
- QTransform matrix = child->transform() * QTransform::fromTranslate(childPos.x(), childPos.y());
+ QTransform matrix = child->transform();
+ if (!childPos.isNull())
+ matrix *= QTransform::fromTranslate(childPos.x(), childPos.y());
childRect |= matrix.mapRect(child->boundingRect() | child->childrenBoundingRect());
}
return childRect;
@@ -3127,57 +3141,79 @@ bool QGraphicsItem::isClipped() const
QPainterPath QGraphicsItem::clipPath() const
{
Q_D(const QGraphicsItem);
- QPainterPath clip;
- if (!isClipped())
- return clip;
+ if (!d->dirtyClipPath)
+ return d->emptyClipPath ? QPainterPath() : d->cachedClipPath;
+ if (!isClipped()) {
+ d_ptr->setCachedClipPath(QPainterPath());
+ return d->cachedClipPath;
+ }
+
+ const QRectF thisBoundingRect(boundingRect());
+ if (thisBoundingRect.isEmpty()) {
+ if (d_ptr->flags & ItemClipsChildrenToShape)
+ d_ptr->setEmptyCachedClipPathRecursively();
+ else
+ d_ptr->setEmptyCachedClipPath();
+ return QPainterPath();
+ }
+
+ QPainterPath clip;
// Start with the item's bounding rect.
- clip.addRect(boundingRect());
+ clip.addRect(thisBoundingRect);
- bool clipAway = false;
if (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) {
- // Make list of parents up to the farthest ancestor that clips its
- // children to its shape.
- QVarLengthArray<const QGraphicsItem *, 32> clippingAncestors;
- const QGraphicsItem *parent = parentItem();
- const QGraphicsItem *clipOwner = 0;
- do {
+ const QGraphicsItem *parent = this;
+ const QGraphicsItem *lastParent = this;
+
+ // Intersect any in-between clips starting at the top and moving downwards.
+ bool foundValidClipPath = false;
+ while ((parent = parent->d_ptr->parent)) {
if (parent->d_ptr->flags & ItemClipsChildrenToShape) {
- clippingAncestors.append(parent);
- clipOwner = parent;
- }
- } while ((parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) && (parent = parent->parentItem()));
+ // Map clip to the current parent and intersect with its shape/clipPath
+ clip = lastParent->itemTransform(parent).map(clip);
+ if ((foundValidClipPath = !parent->d_ptr->dirtyClipPath && parent->isClipped())) {
+ if (parent->d_ptr->emptyClipPath) {
+ if (d_ptr->flags & ItemClipsChildrenToShape)
+ d_ptr->setEmptyCachedClipPathRecursively();
+ else
+ d_ptr->setEmptyCachedClipPath();
+ return QPainterPath();
+ }
+ clip = clip.intersected(parent->d_ptr->cachedClipPath);
+ if (!(parent->d_ptr->flags & ItemClipsToShape))
+ clip = clip.intersected(parent->shape());
+ } else {
+ clip = clip.intersected(parent->shape());
+ }
- // Start with the topmost clip.
- QPainterPath parentClip = clipOwner->shape();
+ if (clip.isEmpty()) {
+ if (d_ptr->flags & ItemClipsChildrenToShape)
+ d_ptr->setEmptyCachedClipPathRecursively();
+ else
+ d_ptr->setEmptyCachedClipPath();
+ return clip;
+ }
+ lastParent = parent;
+ }
- // Intersect any in-between clips starting at the bottom and moving
- // upwards.
- for (int i = clippingAncestors.size() - 2; i >= 0; --i) {
- const QGraphicsItem *item = clippingAncestors[i];
- // ### what if itemtransform fails
- if (clipOwner)
- parentClip = clipOwner->itemTransform(item).map(parentClip);
- parentClip = parentClip.intersected(item->shape());
- if (parentClip.isEmpty()) {
- clip = parentClip;
- clipAway = true;
+ if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)
+ || foundValidClipPath) {
break;
}
- clipOwner = item;
}
- if (!clipAway) {
+ if (lastParent != this) {
+ // Map clip back to the item's transform.
// ### what if itemtransform fails
- clip = clip.intersected(clipOwner->itemTransform(this).map(parentClip));
- if (clip.isEmpty())
- clipAway = true;
+ clip = lastParent->itemTransform(this).map(clip);
}
}
- if (!clipAway && d->flags & ItemClipsToShape)
+ if (d->flags & ItemClipsToShape)
clip = clip.intersected(shape());
+ d_ptr->setCachedClipPath(clip);
return clip;
}
@@ -3266,8 +3302,10 @@ bool QGraphicsItem::collidesWithPath(const QPainterPath &path, Qt::ItemSelection
return false;
}
- QRectF rectA = _q_adjustedRect(boundingRect());
- QRectF rectB = _q_adjustedRect(path.controlPointRect());
+ QRectF rectA(boundingRect());
+ _q_adjustRect(&rectA);
+ QRectF rectB(path.controlPointRect());
+ _q_adjustRect(&rectB);
if (!rectA.intersects(rectB)) {
// This we can determine efficiently. If the two rects neither
// intersect nor contain eachother, then the two items do not collide.
@@ -3276,12 +3314,11 @@ bool QGraphicsItem::collidesWithPath(const QPainterPath &path, Qt::ItemSelection
// For further testing, we need this item's shape or bounding rect.
QPainterPath thisShape;
- if (mode == Qt::IntersectsItemShape || mode == Qt::ContainsItemShape) {
+ if (mode == Qt::IntersectsItemShape || mode == Qt::ContainsItemShape)
thisShape = (isClipped() && !d_ptr->localCollisionHack) ? clipPath() : shape();
- } else {
- thisShape.addPolygon(_q_adjustedRect(boundingRect()));
- thisShape.closeSubpath();
- }
+ else
+ thisShape.addRect(rectA);
+
if (thisShape == QPainterPath()) {
// Empty shape? No collision.
return false;
@@ -3451,7 +3488,8 @@ QRegion QGraphicsItem::boundingRegion(const QTransform &itemToDeviceTransform) c
// into the bitmap, converts the result to a QRegion and scales the region
// back to device space with inverse granularity.
qreal granularity = boundingRegionGranularity();
- QRect deviceRect = _q_adjustedRect(itemToDeviceTransform.mapRect(boundingRect()).toRect());
+ QRect deviceRect = itemToDeviceTransform.mapRect(boundingRect()).toRect();
+ _q_adjustRect(&deviceRect);
if (granularity == 0.0)
return QRegion(deviceRect);
@@ -3581,6 +3619,24 @@ void QGraphicsItem::setBoundingRegionGranularity(qreal granularity)
/*!
\internal
+ Returns true if we can discard an update request; otherwise false.
+*/
+bool QGraphicsItemPrivate::discardUpdateRequest(bool ignoreClipping,
+ bool ignoreVisibleBit,
+ bool ignoreDirtyBit) const
+{
+ // No scene, or if the scene is updating everything, means we have nothing
+ // to do. The only exception is if the scene tracks the growing scene rect.
+ return (!visible && !ignoreVisibleBit)
+ || (dirty && !ignoreDirtyBit)
+ || !scene
+ || (scene->d_func()->updateAll && scene->d_func()->hasSceneRect)
+ || (!ignoreClipping && (childrenClippedToShape() && isClippedAway()))
+ || (childrenCombineOpacity() && isFullyTransparent());
+}
+
+/*!
+ \internal
Asks the scene to mark this item's scene rect as dirty, requesting a
redraw. This does not invalidate any cache.
@@ -3589,19 +3645,16 @@ void QGraphicsItem::setBoundingRegionGranularity(qreal granularity)
only case where the item's background should be marked as dirty even when
the item isn't visible.
*/
-void QGraphicsItemPrivate::updateHelper(const QRectF &rect, bool force)
+void QGraphicsItemPrivate::updateHelper(const QRectF &rect, bool force, bool maybeDirtyClipPath)
{
// No scene, or if the scene is updating everything, means we have nothing
// to do. The only exception is if the scene tracks the growing scene rect.
- if (dirty)
+ if (discardUpdateRequest(/*ignoreClipping=*/maybeDirtyClipPath, /*ignoreVisibleBit=*/force))
return;
- if (!scene || (scene && scene->d_func()->updateAll && scene->d_func()->hasSceneRect))
- return;
- if (scene && (visible || force)) {
- if (rect.isNull())
- dirty = 1;
- scene->itemUpdated(q_ptr, rect);
- }
+
+ if (rect.isNull())
+ dirty = 1;
+ scene->itemUpdated(q_ptr, rect);
}
/*!
@@ -3609,21 +3662,25 @@ void QGraphicsItemPrivate::updateHelper(const QRectF &rect, bool force)
Propagates updates to \a item and all its children.
*/
-void QGraphicsItemPrivate::fullUpdateHelper(bool childrenOnly)
+void QGraphicsItemPrivate::fullUpdateHelper(bool childrenOnly, bool maybeDirtyClipPath)
{
- // No scene, or if the scene is updating everything, means we have nothing
- // to do. The only exception is if the scene tracks the growing scene rect.
- if (!scene || (scene && scene->d_func()->updateAll && scene->d_func()->hasSceneRect))
- return;
- if (!childrenOnly && !dirty)
- updateHelper();
- if (children.isEmpty() || dirtyChildren)
+ if (discardUpdateRequest(/*ignoreClipping=*/maybeDirtyClipPath,
+ /*ignoreVisibleBit=*/false,
+ /*ignoreDirtyBit=*/true)) {
return;
- if (flags & QGraphicsItem::ItemClipsChildrenToShape) {
- // ### mark all children dirty?
+ }
+
+ if (!childrenOnly && !dirty) {
+ // Effectively the same as updateHelper(QRectF(), false, maybeDirtyClipPath).
+ dirty = 1;
+ scene->itemUpdated(q_ptr, QRectF());
+ }
+
+ if (dirtyChildren || childrenClippedToShape()) {
// Unnecessary to update children as well.
return;
}
+
if (ancestorFlags & AncestorClipsChildren) {
Q_Q(QGraphicsItem);
// Check if we can avoid updating all children.
@@ -3646,10 +3703,36 @@ void QGraphicsItemPrivate::fullUpdateHelper(bool childrenOnly)
}
}
foreach (QGraphicsItem *child, children)
- child->d_ptr->fullUpdateHelper();
+ child->d_ptr->fullUpdateHelper(false, maybeDirtyClipPath);
dirtyChildren = 1;
}
+static inline bool qt_allChildrenCombineOpacity(QGraphicsItem *parent)
+{
+ Q_ASSERT(parent);
+ if (parent->flags() & QGraphicsItem::ItemDoesntPropagateOpacityToChildren)
+ return false;
+
+ const QList<QGraphicsItem *> children(parent->childItems());
+ for (int i = 0; i < children.size(); ++i) {
+ if (children.at(i)->flags() & QGraphicsItem::ItemIgnoresParentOpacity)
+ return false;
+ }
+ return true;
+}
+
+void QGraphicsItemPrivate::updateEffectiveOpacity()
+{
+ Q_Q(QGraphicsItem);
+ if (parent) {
+ resolveEffectiveOpacity(parent->effectiveOpacity());
+ parent->d_ptr->allChildrenCombineOpacity = qt_allChildrenCombineOpacity(parent);
+ } else {
+ resolveEffectiveOpacity(1.0);
+ }
+ allChildrenCombineOpacity = qt_allChildrenCombineOpacity(q);
+}
+
/*!
\internal
@@ -3674,7 +3757,14 @@ void QGraphicsItemPrivate::resolveEffectiveOpacity(qreal parentEffectiveOpacity)
}
// Set this item's resolved opacity.
- setExtra(ExtraEffectiveOpacity, myEffectiveOpacity);
+ if (qFuzzyCompare(myEffectiveOpacity, qreal(1.0))) {
+ // Opaque, unset effective opacity.
+ hasEffectiveOpacity = 0;
+ unsetExtra(ExtraEffectiveOpacity);
+ } else {
+ hasEffectiveOpacity = 1;
+ setExtra(ExtraEffectiveOpacity, myEffectiveOpacity);
+ }
// Resolve children always.
for (int i = 0; i < children.size(); ++i)
@@ -3727,6 +3817,109 @@ void QGraphicsItemPrivate::removeExtraItemCache()
unsetExtra(ExtraCacheData);
}
+void QGraphicsItemPrivate::setEmptyCachedClipPathRecursively(const QRectF &emptyIfOutsideThisRect)
+{
+ setEmptyCachedClipPath();
+
+ const bool checkRect = !emptyIfOutsideThisRect.isNull()
+ && !(flags & QGraphicsItem::ItemClipsChildrenToShape);
+ for (int i = 0; i < children.size(); ++i) {
+ if (!checkRect) {
+ children.at(i)->d_ptr->setEmptyCachedClipPathRecursively();
+ continue;
+ }
+
+ QGraphicsItem *child = children.at(i);
+ const QRectF rect = child->mapRectFromParent(emptyIfOutsideThisRect);
+ if (rect.intersects(child->boundingRect()))
+ child->d_ptr->invalidateCachedClipPathRecursively(false, rect);
+ else
+ child->d_ptr->setEmptyCachedClipPathRecursively(rect);
+ }
+}
+
+void QGraphicsItemPrivate::invalidateCachedClipPathRecursively(bool childrenOnly, const QRectF &emptyIfOutsideThisRect)
+{
+ if (!childrenOnly)
+ invalidateCachedClipPath();
+
+ const bool checkRect = !emptyIfOutsideThisRect.isNull();
+ for (int i = 0; i < children.size(); ++i) {
+ if (!checkRect) {
+ children.at(i)->d_ptr->invalidateCachedClipPathRecursively(false);
+ continue;
+ }
+
+ QGraphicsItem *child = children.at(i);
+ const QRectF rect = child->mapRectFromParent(emptyIfOutsideThisRect);
+ if (rect.intersects(child->boundingRect()))
+ child->d_ptr->invalidateCachedClipPathRecursively(false, rect);
+ else
+ child->d_ptr->setEmptyCachedClipPathRecursively(rect);
+ }
+}
+
+void QGraphicsItemPrivate::updateCachedClipPathFromSetPosHelper(const QPointF &newPos)
+{
+ Q_ASSERT(inSetPosHelper);
+
+ if (!(ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren))
+ return; // Not clipped by any ancestor.
+
+ // Find closest clip ancestor and transform.
+ Q_Q(QGraphicsItem);
+ QTransform thisToParentTransform = hasTransform
+ ? q->transform() * QTransform::fromTranslate(newPos.x(), newPos.y())
+ : QTransform::fromTranslate(newPos.x(), newPos.y());
+ QGraphicsItem *clipParent = parent;
+ while (clipParent && !(clipParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape)) {
+ if (clipParent->d_ptr->hasTransform)
+ thisToParentTransform *= clipParent->transform();
+ if (!clipParent->d_ptr->pos.isNull()) {
+ thisToParentTransform *= QTransform::fromTranslate(clipParent->d_ptr->pos.x(),
+ clipParent->d_ptr->pos.y());
+ }
+ clipParent = clipParent->d_ptr->parent;
+ }
+
+ // thisToParentTransform is now the same as q->itemTransform(clipParent), except
+ // that the new position (which is not yet set on the item) is taken into account.
+ Q_ASSERT(clipParent);
+ Q_ASSERT(clipParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape);
+
+ // From here everything is calculated in clip parent's coordinates.
+ const QRectF parentBoundingRect(clipParent->boundingRect());
+ const QRectF thisBoundingRect(thisToParentTransform.mapRect(q->boundingRect()));
+
+ if (!parentBoundingRect.intersects(thisBoundingRect)) {
+ // Item is moved outside the clip parent's bounding rect,
+ // i.e. it is fully clipped and the clip path is empty.
+ if (flags & QGraphicsItem::ItemClipsChildrenToShape)
+ setEmptyCachedClipPathRecursively();
+ else
+ setEmptyCachedClipPathRecursively(thisToParentTransform.inverted().mapRect(parentBoundingRect));
+ return;
+ }
+
+ const QPainterPath parentClip(clipParent->isClipped() ? clipParent->clipPath() : clipParent->shape());
+ if (parentClip.contains(thisBoundingRect))
+ return; // Item is inside the clip parent's shape. No update required.
+
+ const QRectF parentClipRect(parentClip.controlPointRect());
+ if (!parentClipRect.intersects(thisBoundingRect)) {
+ // Item is moved outside the clip parent's shape,
+ // i.e. it is fully clipped and the clip path is empty.
+ if (flags & QGraphicsItem::ItemClipsChildrenToShape)
+ setEmptyCachedClipPathRecursively();
+ else
+ setEmptyCachedClipPathRecursively(thisToParentTransform.inverted().mapRect(parentClipRect));
+ } else {
+ // Item is partially inside the clip parent's shape,
+ // i.e. the cached clip path must be invalidated.
+ invalidateCachedClipPathRecursively(false, thisToParentTransform.inverted().mapRect(parentClipRect));
+ }
+}
+
/*!
\internal
@@ -3757,20 +3950,35 @@ bool QGraphicsItemPrivate::isProxyWidget() const
*/
void QGraphicsItem::update(const QRectF &rect)
{
- if (d_ptr->dirty)
+ if (rect.isEmpty() && !rect.isNull())
return;
- if (d_ptr->scene && isVisible()) {
- if (CacheMode(d_ptr->cacheMode) != NoCache) {
- QGraphicsItemCache *cache = d_ptr->extraItemCache();
- if (rect.isNull()) {
- cache->allExposed = true;
- cache->exposed.clear();
- } else {
- cache->exposed.append(rect);
- }
+
+ if (CacheMode(d_ptr->cacheMode) != NoCache) {
+ QGraphicsItemCache *cache = d_ptr->extraItemCache();
+ if (d_ptr->discardUpdateRequest(/* ignoreVisibleBit = */ false,
+ /* ignoreClipping = */ false,
+ /* ignoreDirtyBit = */ true)) {
+ return;
+ }
+
+ // Invalidate cache.
+ if (rect.isNull()) {
+ cache->allExposed = true;
+ cache->exposed.clear();
+ } else {
+ cache->exposed.append(rect);
}
- d_ptr->updateHelper(rect);
+ // Only invalidate cache; item is already dirty.
+ if (d_ptr->dirty)
+ return;
+ } else if (d_ptr->discardUpdateRequest()) {
+ return;
}
+
+ // Effectively the same as updateHelper(rect);
+ if (rect.isNull())
+ d_ptr->dirty = 1;
+ d_ptr->scene->itemUpdated(this, rect);
}
@@ -4027,9 +4235,9 @@ QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QRectF &rect
*/
QPolygonF QGraphicsItem::mapToParent(const QRectF &rect) const
{
- if (!d_ptr->hasTransform)
- return QPolygonF(rect.translated(d_ptr->pos));
- return transform().map(rect.translated(d_ptr->pos));
+ QPolygonF p = !d_ptr->hasTransform ? rect : transform().map(rect);
+ p.translate(d_ptr->pos);
+ return p;
}
/*!
@@ -4096,8 +4304,8 @@ QRectF QGraphicsItem::mapRectToItem(const QGraphicsItem *item, const QRectF &rec
*/
QRectF QGraphicsItem::mapRectToParent(const QRectF &rect) const
{
- QRectF r = rect.translated(d_ptr->pos.x(), d_ptr->pos.y());
- return !d_ptr->hasTransform ? r : transform().mapRect(r);
+ QRectF r = !d_ptr->hasTransform ? rect : transform().mapRect(rect);
+ return r.translated(d_ptr->pos);
}
/*!
@@ -4228,9 +4436,9 @@ QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPolygonF &p
*/
QPolygonF QGraphicsItem::mapToParent(const QPolygonF &polygon) const
{
- QPolygonF p = polygon;
+ QPolygonF p = !d_ptr->hasTransform ? polygon : transform().map(polygon);
p.translate(d_ptr->pos);
- return d_ptr->hasTransform ? transform().map(p) : p;
+ return p;
}
/*!
@@ -4272,7 +4480,10 @@ QPainterPath QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPainterP
*/
QPainterPath QGraphicsItem::mapToParent(const QPainterPath &path) const
{
- return d_ptr->parent ? itemTransform(d_ptr->parent).map(path) : mapToScene(path);
+ QTransform x = QTransform::fromTranslate(d_ptr->pos.x(), d_ptr->pos.y());
+ if (d_ptr->hasTransform)
+ x = transform() * x;
+ return x.map(path);
}
/*!
@@ -5502,11 +5713,18 @@ void QGraphicsItem::removeFromIndex()
void QGraphicsItem::prepareGeometryChange()
{
if (d_ptr->scene) {
- d_ptr->updateHelper();
-
+ d_ptr->updateHelper(QRectF(), false, /*maybeDirtyClipPath=*/!d_ptr->inSetPosHelper);
QGraphicsScenePrivate *scenePrivate = d_ptr->scene->d_func();
scenePrivate->removeFromIndex(this);
}
+
+ if (d_ptr->inSetPosHelper)
+ return;
+
+ if (d_ptr->flags & ItemClipsChildrenToShape)
+ d_ptr->invalidateCachedClipPathRecursively();
+ else
+ d_ptr->invalidateCachedClipPath();
}
/*!
@@ -8090,6 +8308,8 @@ void QGraphicsTextItem::setTabChangesFocus(bool b)
Returns true if the \gui Tab key will cause the widget to change focus;
otherwise, false is returned.
+ By default, this behavior is disabled, and this function will return false.
+
\sa setTabChangesFocus()
*/
bool QGraphicsTextItem::tabChangesFocus() const
@@ -8281,6 +8501,7 @@ void QGraphicsSimpleTextItem::setText(const QString &text)
return;
d->text = text;
d->updateBoundingRect();
+ update();
}
/*!
@@ -8542,13 +8763,17 @@ void QGraphicsItemGroup::addToGroup(QGraphicsItem *item)
QTransform oldSceneMatrix = item->sceneTransform();
item->setPos(mapFromItem(item, 0, 0));
item->setParentItem(this);
- item->setTransform(oldSceneMatrix
- * sceneTransform().inverted()
- * QTransform::fromTranslate(-item->x(), -item->y()));
+ QTransform newItemTransform(oldSceneMatrix);
+ newItemTransform *= sceneTransform().inverted();
+ if (!item->pos().isNull())
+ newItemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
+ item->setTransform(newItemTransform);
item->d_func()->setIsMemberOfGroup(true);
prepareGeometryChange();
- d->itemsBoundingRect |= (item->transform() * QTransform::fromTranslate(item->x(), item->y()))
- .mapRect(item->boundingRect() | item->childrenBoundingRect());
+ QTransform itemTransform(item->transform());
+ if (!item->pos().isNull())
+ itemTransform *= QTransform::fromTranslate(item->x(), item->y());
+ d->itemsBoundingRect |= itemTransform.mapRect(item->boundingRect() | item->childrenBoundingRect());
update();
}
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index 07f6958..a5871a7 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -133,10 +133,15 @@ public:
hasBoundingRegionGranularity(0),
flags(0),
hasOpacity(0),
+ hasEffectiveOpacity(0),
isWidget(0),
dirty(0),
dirtyChildren(0),
localCollisionHack(0),
+ dirtyClipPath(1),
+ emptyClipPath(0),
+ inSetPosHelper(0),
+ allChildrenCombineOpacity(1),
globalStackingOrder(-1),
sceneTransformIndex(-1),
q_ptr(0)
@@ -157,11 +162,15 @@ public:
virtual QVariant inputMethodQueryHelper(Qt::InputMethodQuery query) const;
static bool movableAncestorIsSelected(const QGraphicsItem *item);
- void setPosHelper(const QPointF &pos, bool update);
+ void setPosHelper(const QPointF &pos);
void setVisibleHelper(bool newVisible, bool explicitly, bool update = true);
void setEnabledHelper(bool newEnabled, bool explicitly, bool update = true);
- void updateHelper(const QRectF &rect = QRectF(), bool force = false);
- void fullUpdateHelper(bool childrenOnly = false);
+ bool discardUpdateRequest(bool ignoreClipping = false,
+ bool ignoreVisibleBit = false,
+ bool ignoreDirtyBit = false) const;
+ void updateHelper(const QRectF &rect = QRectF(), bool force = false, bool maybeDirtyClipPath = false);
+ void fullUpdateHelper(bool childrenOnly = false, bool maybeDirtyClipPath = false);
+ void updateEffectiveOpacity();
void resolveEffectiveOpacity(qreal effectiveParentOpacity);
void resolveDepth(int parentDepth);
void invalidateSceneTransformCache();
@@ -233,6 +242,47 @@ public:
QGraphicsItemCache *extraItemCache() const;
void removeExtraItemCache();
+ inline void setCachedClipPath(const QPainterPath &path)
+ {
+ cachedClipPath = path;
+ dirtyClipPath = 0;
+ emptyClipPath = 0;
+ }
+
+ inline void setEmptyCachedClipPath()
+ {
+ emptyClipPath = 1;
+ dirtyClipPath = 0;
+ }
+
+ void setEmptyCachedClipPathRecursively(const QRectF &emptyIfOutsideThisRect = QRectF());
+
+ inline void invalidateCachedClipPath()
+ { /*static int count = 0 ;qWarning("%i", ++count);*/ dirtyClipPath = 1; emptyClipPath = 0; }
+
+ void invalidateCachedClipPathRecursively(bool childrenOnly = false, const QRectF &emptyIfOutsideThisRect = QRectF());
+ void updateCachedClipPathFromSetPosHelper(const QPointF &newPos);
+
+ inline bool isFullyTransparent() const
+ { return hasEffectiveOpacity && qFuzzyCompare(q_func()->effectiveOpacity() + 1, qreal(1.0)); }
+
+ inline bool childrenCombineOpacity() const
+ { return allChildrenCombineOpacity || children.isEmpty(); }
+
+ inline bool isClippedAway() const
+ { return !dirtyClipPath && q_func()->isClipped() && (emptyClipPath || cachedClipPath.isEmpty()); }
+
+ inline bool childrenClippedToShape() const
+ { return (flags & QGraphicsItem::ItemClipsChildrenToShape) || children.isEmpty(); }
+
+ inline bool isInvisible() const
+ {
+ return !visible
+ || (childrenClippedToShape() && isClippedAway())
+ || (childrenCombineOpacity() && isFullyTransparent());
+ }
+
+ QPainterPath cachedClipPath;
QPointF pos;
qreal z;
QGraphicsScene *scene;
@@ -262,10 +312,15 @@ public:
// New 32 bytes
quint32 hasOpacity : 1;
+ quint32 hasEffectiveOpacity : 1;
quint32 isWidget : 1;
quint32 dirty : 1;
quint32 dirtyChildren : 1;
quint32 localCollisionHack : 1;
+ quint32 dirtyClipPath : 1;
+ quint32 emptyClipPath : 1;
+ quint32 inSetPosHelper : 1;
+ quint32 allChildrenCombineOpacity : 1;
// Optional stacking order
int globalStackingOrder;
diff --git a/src/gui/graphicsview/qgraphicslayoutitem.cpp b/src/gui/graphicsview/qgraphicslayoutitem.cpp
index 0ea7692..eaa97ff 100644
--- a/src/gui/graphicsview/qgraphicslayoutitem.cpp
+++ b/src/gui/graphicsview/qgraphicslayoutitem.cpp
@@ -117,7 +117,7 @@ QGraphicsLayoutItemPrivate::QGraphicsLayoutItemPrivate(QGraphicsLayoutItem *par,
*/
void QGraphicsLayoutItemPrivate::init()
{
- sizeHintCacheDirty = true;
+ sizeHintCacheDirty = true;
sizePolicy = QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
}
@@ -175,12 +175,12 @@ QSizeF *QGraphicsLayoutItemPrivate::effectiveSizeHints(const QSizeF &constraint)
Returns the parent item of this layout, or 0 if this layout is
not installed on any widget.
-
+
If this is the item that the layout is installed on, it will return "itself".
If the layout is a sub-layout, this function returns the parent
widget of the parent layout.
-
+
Note that it will traverse up the layout item hierarchy instead of just calling
QGraphicsItem::parentItem(). This is on purpose.
@@ -233,7 +233,7 @@ QGraphicsItem *QGraphicsLayoutItemPrivate::parentItem() const
position. Calling setGeometry() will always resize and reposition the item
immediately. Normally, this function is called by QGraphicsLayout after
the layout has been activated, but it can also be called by the item's user
- at any time.
+ at any time.
The sizeHint() function returns the item' minimum, preferred and maximum
size hints. You can override these properties by calling setMinimumSize(),
@@ -360,7 +360,7 @@ void QGraphicsLayoutItem::setSizePolicy(QSizePolicy::Policy hPolicy,
}
/*!
- Returns the current size policy.
+ Returns the current size policy.
\sa setSizePolicy(), QWidget::sizePolicy()
*/
@@ -626,14 +626,15 @@ void QGraphicsLayoutItem::setMaximumHeight(qreal height)
*/
/*!
- \fn virtual void QGraphicsLayoutItem::setGeometry(const QRectF &rect) = 0
+ \fn virtual void QGraphicsLayoutItem::setGeometry(const QRectF &rect)
- This pure virtual function sets the geometry of the QGraphicsLayoutItem to
+ This virtual function sets the geometry of the QGraphicsLayoutItem to
\a rect, which is in parent coordinates (e.g., the top-left corner of \a rect
is equivalent to the item's position in parent coordinates).
- Reimplement this function in a subclass of QGraphicsLayoutItem to enable
- your item to receive geometry updates.
+ You must reimplement this function in a subclass of QGraphicsLayoutItem to
+ receive geometry updates. The layout will call this function when it does a
+ rearrangement.
If \a rect is outside of the bounds of minimumSize and maximumSize, it
will be adjusted to its closest size so that it is within the legal
@@ -744,7 +745,7 @@ QSizeF QGraphicsLayoutItem::effectiveSizeHint(Qt::SizeHint which, const QSizeF &
\sa effectiveSizeHint()
*/
void QGraphicsLayoutItem::updateGeometry()
-{
+{
Q_D(QGraphicsLayoutItem);
d->sizeHintCacheDirty = true;
}
@@ -768,7 +769,7 @@ QGraphicsLayoutItem *QGraphicsLayoutItem::parentLayoutItem() const
\sa parentLayoutItem()
*/
void QGraphicsLayoutItem::setParentLayoutItem(QGraphicsLayoutItem *parent)
-{
+{
d_func()->parent = parent;
}
@@ -789,12 +790,12 @@ bool QGraphicsLayoutItem::isLayout() const
If its true, then the layout will delete it. If its false, then it is
assumed that another object has the ownership of it, and the layout won't
delete this item.
-
- If the item inherits both QGraphicsItem and QGraphicsLayoutItem (such
- as QGraphicsWidget does) the item is really part of two ownership
+
+ If the item inherits both QGraphicsItem and QGraphicsLayoutItem (such
+ as QGraphicsWidget does) the item is really part of two ownership
hierarchies. This property informs what the layout should do with its
child items when it is destructed. In the case of QGraphicsWidget, it
- is preferred that when the layout is deleted it won't delete its children
+ is preferred that when the layout is deleted it won't delete its children
(since they are also part of the graphics item hierarchy).
By default this value is initialized to false in QGraphicsLayoutItem,
@@ -822,9 +823,9 @@ void QGraphicsLayoutItem::setOwnedByLayout(bool ownership)
/*!
* Returns the QGraphicsItem that this layout item represents.
- * For QGraphicsWidget it will return itself. For custom items it can return an
- * aggregated value.
- *
+ * For QGraphicsWidget it will return itself. For custom items it can return an
+ * aggregated value.
+ *
* \sa setGraphicsItem()
*/
QGraphicsItem *QGraphicsLayoutItem::graphicsItem() const
@@ -836,10 +837,10 @@ QGraphicsItem *QGraphicsLayoutItem::graphicsItem() const
* If the QGraphicsLayoutItem represents a QGraphicsItem, and it wants to take
* advantage of the automatic reparenting capabilities of QGraphicsLayout it
* should set this value.
- * Note that if you delete \a item and not delete the layout item, you are
- * responsible of calling setGraphicsItem(0) in order to avoid having a
+ * Note that if you delete \a item and not delete the layout item, you are
+ * responsible of calling setGraphicsItem(0) in order to avoid having a
* dangling pointer.
- *
+ *
* \sa graphicsItem()
*/
void QGraphicsLayoutItem::setGraphicsItem(QGraphicsItem *item)
@@ -848,5 +849,5 @@ void QGraphicsLayoutItem::setGraphicsItem(QGraphicsItem *item)
}
QT_END_NAMESPACE
-
+
#endif //QT_NO_GRAPHICSVIEW
diff --git a/src/gui/graphicsview/qgraphicsproxywidget.cpp b/src/gui/graphicsview/qgraphicsproxywidget.cpp
index 1d2721b..e660879 100644
--- a/src/gui/graphicsview/qgraphicsproxywidget.cpp
+++ b/src/gui/graphicsview/qgraphicsproxywidget.cpp
@@ -177,6 +177,10 @@ QT_BEGIN_NAMESPACE
while the widget is embedded. In this state, the widget may differ slightly
in behavior from when it is not embedded.
+ \warning This class is provided for convenience when bridging
+ QWidgets and QGraphicsItems, it should not be used for
+ high-performance scenarios.
+
\sa QGraphicsScene::addWidget(), QGraphicsWidget
*/
@@ -1033,7 +1037,7 @@ void QGraphicsProxyWidget::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
if (receiver != d->dragDropWidget) {
// Try to enter before we leave
QDragEnterEvent dragEnter(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
- dragEnter.setDropAction(event->proposedAction());
+ dragEnter.setDropAction(event->proposedAction());
QApplication::sendEvent(receiver, &dragEnter);
event->setAccepted(dragEnter.isAccepted());
event->setDropAction(dragEnter.dropAction());
@@ -1431,7 +1435,7 @@ int QGraphicsProxyWidget::type() const
Creates a proxy widget for the given \a child of the widget
contained in this proxy.
-
+
This function makes it possible to aquire proxies for
non top-level widgets. For instance, you can embed a dialog,
and then transform only one of its widgets.
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 1f78a18..13f70e5 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -292,15 +292,21 @@ static inline bool QRectF_intersects(const QRectF &s, const QRectF &r)
// QRectF::intersects() returns false always if either the source or target
// rectangle's width or height are 0. This works around that problem.
-static QRectF _q_adjustedRect(const QRectF &rect)
+static inline void _q_adjustRect(QRectF *rect)
{
- static const qreal p = (qreal)0.00001;
- QRectF r = rect;
- if (!r.width())
- r.adjust(-p, 0, p, 0);
- if (!r.height())
- r.adjust(0, -p, 0, p);
- return r;
+ Q_ASSERT(rect);
+ if (!rect->width())
+ rect->adjust(-0.00001, 0, 0.00001, 0);
+ if (!rect->height())
+ rect->adjust(0, -0.00001, 0, 0.00001);
+}
+
+static inline QRectF adjustedItemBoundingRect(const QGraphicsItem *item)
+{
+ Q_ASSERT(item);
+ QRectF boundingRect(item->boundingRect());
+ _q_adjustRect(&boundingRect);
+ return boundingRect;
}
static void _q_hoverFromMouseEvent(QGraphicsSceneHoverEvent *hover, const QGraphicsSceneMouseEvent *mouseEvent)
@@ -632,10 +638,11 @@ void QGraphicsScenePrivate::_q_updateLater()
*/
void QGraphicsScenePrivate::_q_polishItems()
{
+ const QVariant booleanTrueVariant(true);
foreach (QGraphicsItem *item, unpolishedItems) {
if (!item->d_ptr->explicitlyHidden) {
- item->itemChange(QGraphicsItem::ItemVisibleChange, true);
- item->itemChange(QGraphicsItem::ItemVisibleHasChanged, true);
+ item->itemChange(QGraphicsItem::ItemVisibleChange, booleanTrueVariant);
+ item->itemChange(QGraphicsItem::ItemVisibleHasChanged, booleanTrueVariant);
}
if (item->isWidget()) {
QEvent event(QEvent::Polish);
@@ -690,13 +697,6 @@ void QGraphicsScenePrivate::_q_removeItemLater(QGraphicsItem *item)
{
Q_Q(QGraphicsScene);
- if (QGraphicsItem *parent = item->d_func()->parent) {
- QVariant variant;
- qVariantSetValue<QGraphicsItem *>(variant, item);
- parent->itemChange(QGraphicsItem::ItemChildRemovedChange, variant);
- parent->d_func()->children.removeAll(item);
- }
-
// Clear focus on the item to remove any reference in the focusWidget
// chain.
item->clearFocus();
@@ -740,6 +740,15 @@ void QGraphicsScenePrivate::_q_removeItemLater(QGraphicsItem *item)
unpolishedItems.removeAll(item);
dirtyItems.removeAll(item);
+ //We remove all references of item from the sceneEventFilter arrays
+ QMultiMap<QGraphicsItem*, QGraphicsItem*>::iterator iterator = sceneEventFilters.begin();
+ while (iterator != sceneEventFilters.end()) {
+ if (iterator.value() == item || iterator.key() == item)
+ iterator = sceneEventFilters.erase(iterator);
+ else
+ ++iterator;
+ }
+
// Remove from scene transform cache
int transformIndex = item->d_func()->sceneTransformIndex;
if (transformIndex != -1) {
@@ -1358,6 +1367,48 @@ QGraphicsWidget *QGraphicsScenePrivate::windowForItem(const QGraphicsItem *item)
return 0;
}
+
+QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QPointF &pos) const
+{
+ QList<QGraphicsItem *> items;
+
+ // The index returns a rough estimate of what items are inside the rect.
+ // Refine it by iterating through all returned items.
+ QRectF adjustedRect = QRectF(pos, QSize(1,1));
+ foreach (QGraphicsItem *item, estimateItemsInRect(adjustedRect)) {
+ // Find the item's scene transform in a clever way.
+ QTransform x = item->sceneTransform();
+ bool keep = false;
+
+ // ### _q_adjustedRect is only needed because QRectF::intersects,
+ // QRectF::contains and QTransform::map() and friends don't work with
+ // flat rectangles.
+ const QRectF br(adjustedItemBoundingRect(item));
+ // Rect intersects/contains item's shape
+ if (QRectF_intersects(adjustedRect, x.mapRect(br))) {
+ bool ok;
+ QTransform xinv = x.inverted(&ok);
+ if (ok) {
+ if (item->contains(xinv.map(pos))) {
+ items << item;
+ keep = true;
+ }
+ }
+ }
+
+ if (keep && (item->flags() & QGraphicsItem::ItemClipsChildrenToShape)) {
+ // Recurse into children that clip children.
+ bool ok;
+ QTransform xinv = x.inverted(&ok);
+ if (ok)
+ childItems_helper(&items, item, xinv.map(pos));
+ }
+ }
+
+ sortItems(&items, Qt::AscendingOrder, sortCacheEnabled);
+ return items;
+}
+
QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QRectF &rect,
Qt::ItemSelectionMode mode,
Qt::SortOrder order) const
@@ -1368,7 +1419,8 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QRectF &rect,
// The index returns a rough estimate of what items are inside the rect.
// Refine it by iterating through all returned items.
- QRectF adjustedRect = _q_adjustedRect(rect);
+ QRectF adjustedRect(rect);
+ _q_adjustRect(&adjustedRect);
foreach (QGraphicsItem *item, estimateItemsInRect(adjustedRect)) {
// Find the item's scene transform in a clever way.
QTransform x = item->sceneTransform();
@@ -1377,7 +1429,7 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QRectF &rect,
// ### _q_adjustedRect is only needed because QRectF::intersects,
// QRectF::contains and QTransform::map() and friends don't work with
// flat rectangles.
- QRectF br = _q_adjustedRect(item->boundingRect());
+ const QRectF br(adjustedItemBoundingRect(item));
if (mode >= Qt::ContainsItemBoundingRect) {
// Rect intersects/contains item's bounding rect
QRectF mbr = x.mapRect(br);
@@ -1392,7 +1444,7 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QRectF &rect,
bool ok;
QTransform xinv = x.inverted(&ok);
if (ok) {
- if (path == QPainterPath())
+ if (path.isEmpty())
path.addRect(rect);
if (itemCollidesWithPath(item, xinv.map(path), mode)) {
items << item;
@@ -1429,7 +1481,8 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QPolygonF &poly
{
QList<QGraphicsItem *> items;
- QRectF polyRect = _q_adjustedRect(polygon.boundingRect());
+ QRectF polyRect(polygon.boundingRect());
+ _q_adjustRect(&polyRect);
QPainterPath path;
// The index returns a rough estimate of what items are inside the rect.
@@ -1442,7 +1495,7 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QPolygonF &poly
// ### _q_adjustedRect is only needed because QRectF::intersects,
// QRectF::contains and QTransform::map() and friends don't work with
// flat rectangles.
- QRectF br = _q_adjustedRect(item->boundingRect());
+ const QRectF br(adjustedItemBoundingRect(item));
if (mode >= Qt::ContainsItemBoundingRect) {
// Polygon contains/intersects item's bounding rect
if (path == QPainterPath())
@@ -1487,21 +1540,47 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QPainterPath &p
Qt::SortOrder order) const
{
QList<QGraphicsItem *> items;
+ QRectF pathRect(path.controlPointRect());
+ _q_adjustRect(&pathRect);
+
// The index returns a rough estimate of what items are inside the rect.
// Refine it by iterating through all returned items.
- foreach (QGraphicsItem *item, estimateItemsInRect(_q_adjustedRect(path.controlPointRect()))) {
+ foreach (QGraphicsItem *item, estimateItemsInRect(pathRect)) {
// Find the item's scene transform in a clever way.
QTransform x = item->sceneTransform();
- bool ok;
- QTransform xinv = x.inverted(&ok);
- if (ok) {
- QPainterPath mappedPath = xinv.map(path);
- if (itemCollidesWithPath(item, mappedPath, mode)) {
+ bool keep = false;
+
+ // ### _q_adjustedRect is only needed because QRectF::intersects,
+ // QRectF::contains and QTransform::map() and friends don't work with
+ // flat rectangles.
+ const QRectF br(adjustedItemBoundingRect(item));
+ if (mode >= Qt::ContainsItemBoundingRect) {
+ // Path contains/intersects item's bounding rect
+ if ((mode == Qt::IntersectsItemBoundingRect && path.intersects(x.mapRect(br)))
+ || (mode == Qt::ContainsItemBoundingRect && path.contains(x.mapRect(br)))) {
items << item;
- if (item->flags() & QGraphicsItem::ItemClipsChildrenToShape)
- childItems_helper(&items, item, mappedPath, mode);
+ keep = true;
+ }
+ } else {
+ // Path contains/intersects item's shape
+ if (QRectF_intersects(pathRect, x.mapRect(br))) {
+ bool ok;
+ QTransform xinv = x.inverted(&ok);
+ if (ok) {
+ if (itemCollidesWithPath(item, xinv.map(path), mode)) {
+ items << item;
+ keep = true;
+ }
+ }
}
}
+
+ if (keep && (item->flags() & QGraphicsItem::ItemClipsChildrenToShape)) {
+ bool ok;
+ QTransform xinv = x.inverted(&ok);
+ if (ok)
+ childItems_helper(&items, item, xinv.map(path), mode);
+ }
}
if (order != Qt::SortOrder(-1))
@@ -1511,13 +1590,13 @@ QList<QGraphicsItem *> QGraphicsScenePrivate::items_helper(const QPainterPath &p
void QGraphicsScenePrivate::childItems_helper(QList<QGraphicsItem *> *items,
const QGraphicsItem *parent,
- const QRectF &rect,
- Qt::ItemSelectionMode mode) const
+ const QPointF &pos) const
{
- QPainterPath path;
bool parentClip = (parent->flags() & QGraphicsItem::ItemClipsChildrenToShape);
- QRectF r = !parentClip ? _q_adjustedRect(rect) : _q_adjustedRect(rect).intersected(_q_adjustedRect(parent->boundingRect()));
- if (r.isEmpty())
+ if (parentClip && parent->d_ptr->isClippedAway())
+ return;
+ // ### is this needed?
+ if (parentClip && !parent->boundingRect().contains(pos))
return;
QList<QGraphicsItem *> &children = parent->d_ptr->children;
@@ -1527,31 +1606,73 @@ void QGraphicsScenePrivate::childItems_helper(QList<QGraphicsItem *> *items,
continue;
// Skip invisible items and all their children.
- if (!item->d_ptr->visible || qFuzzyCompare(item->effectiveOpacity(), qreal(0.0)))
+ if (item->d_ptr->isInvisible())
continue;
- // ### _q_adjustedRect is only needed because QRectF::intersects,
- // QRectF::contains and QTransform::map() and friends don't work with
- // flat rectangles.
- QRectF br = _q_adjustedRect(item->boundingRect());
- QRectF mbr = item->mapRectToParent(br);
bool keep = false;
- if (mode >= Qt::ContainsItemBoundingRect) {
- // Rect intersects/contains item's bounding rect
- if ((mode == Qt::IntersectsItemBoundingRect && QRectF_intersects(rect, mbr))
- || (mode == Qt::ContainsItemBoundingRect && rect != mbr && rect.contains(br))) {
+ if (!item->d_ptr->isClippedAway()) {
+ if (item->contains(item->mapFromParent(pos))) {
items->append(item);
keep = true;
}
- } else {
- // Rect intersects/contains item's shape
- if (QRectF_intersects(rect, mbr)) {
- if (path == QPainterPath())
- path.addRect(rect);
- if (itemCollidesWithPath(item, item->mapFromParent(path), mode)) {
+ }
+
+ if ((keep || !(item->flags() & QGraphicsItem::ItemClipsChildrenToShape)) && !item->d_ptr->children.isEmpty())
+ // Recurse into children.
+ childItems_helper(items, item, item->mapFromParent(pos));
+ }
+}
+
+
+void QGraphicsScenePrivate::childItems_helper(QList<QGraphicsItem *> *items,
+ const QGraphicsItem *parent,
+ const QRectF &rect,
+ Qt::ItemSelectionMode mode) const
+{
+ bool parentClip = (parent->flags() & QGraphicsItem::ItemClipsChildrenToShape);
+ if (parentClip && parent->d_ptr->isClippedAway())
+ return;
+ QRectF adjustedRect(rect);
+ _q_adjustRect(&adjustedRect);
+ QRectF r = !parentClip ? adjustedRect : adjustedRect.intersected(adjustedItemBoundingRect(parent));
+ if (r.isEmpty())
+ return;
+
+ QPainterPath path;
+ QList<QGraphicsItem *> &children = parent->d_ptr->children;
+ for (int i = 0; i < children.size(); ++i) {
+ QGraphicsItem *item = children.at(i);
+ if (item->d_ptr->hasTransform && !item->transform().isInvertible())
+ continue;
+
+ // Skip invisible items and all their children.
+ if (item->d_ptr->isInvisible())
+ continue;
+
+ bool keep = false;
+ if (!item->d_ptr->isClippedAway()) {
+ // ### _q_adjustedRect is only needed because QRectF::intersects,
+ // QRectF::contains and QTransform::map() and friends don't work with
+ // flat rectangles.
+ const QRectF br(adjustedItemBoundingRect(item));
+ QRectF mbr = item->mapRectToParent(br);
+ if (mode >= Qt::ContainsItemBoundingRect) {
+ // Rect intersects/contains item's bounding rect
+ if ((mode == Qt::IntersectsItemBoundingRect && QRectF_intersects(rect, mbr))
+ || (mode == Qt::ContainsItemBoundingRect && rect != mbr && rect.contains(br))) {
items->append(item);
keep = true;
}
+ } else {
+ // Rect intersects/contains item's shape
+ if (QRectF_intersects(rect, mbr)) {
+ if (path == QPainterPath())
+ path.addRect(rect);
+ if (itemCollidesWithPath(item, item->mapFromParent(path), mode)) {
+ items->append(item);
+ keep = true;
+ }
+ }
}
}
@@ -1568,18 +1689,22 @@ void QGraphicsScenePrivate::childItems_helper(QList<QGraphicsItem *> *items,
}
}
+
void QGraphicsScenePrivate::childItems_helper(QList<QGraphicsItem *> *items,
const QGraphicsItem *parent,
const QPolygonF &polygon,
Qt::ItemSelectionMode mode) const
{
- QPainterPath path;
bool parentClip = (parent->flags() & QGraphicsItem::ItemClipsChildrenToShape);
- QRectF polyRect = _q_adjustedRect(polygon.boundingRect());
- QRectF r = !parentClip ? polyRect : polyRect.intersected(_q_adjustedRect(parent->boundingRect()));
+ if (parentClip && parent->d_ptr->isClippedAway())
+ return;
+ QRectF polyRect(polygon.boundingRect());
+ _q_adjustRect(&polyRect);
+ QRectF r = !parentClip ? polyRect : polyRect.intersected(adjustedItemBoundingRect(parent));
if (r.isEmpty())
return;
+ QPainterPath path;
QList<QGraphicsItem *> &children = parent->d_ptr->children;
for (int i = 0; i < children.size(); ++i) {
QGraphicsItem *item = children.at(i);
@@ -1587,32 +1712,34 @@ void QGraphicsScenePrivate::childItems_helper(QList<QGraphicsItem *> *items,
continue;
// Skip invisible items.
- if (!item->d_ptr->visible || qFuzzyCompare(item->effectiveOpacity() + 1, qreal(1.0)))
+ if (item->d_ptr->isInvisible())
continue;
- // ### _q_adjustedRect is only needed because QRectF::intersects,
- // QRectF::contains and QTransform::map() and friends don't work with
- // flat rectangles.
- QRectF br = _q_adjustedRect(item->boundingRect());
bool keep = false;
- if (mode >= Qt::ContainsItemBoundingRect) {
- // Polygon contains/intersects item's bounding rect
- if (path == QPainterPath())
- path.addPolygon(polygon);
- if ((mode == Qt::IntersectsItemBoundingRect && path.intersects(item->mapRectToParent(br)))
- || (mode == Qt::ContainsItemBoundingRect && path.contains(item->mapRectToParent(br)))) {
- items->append(item);
- keep = true;
- }
- } else {
- // Polygon contains/intersects item's shape
- if (QRectF_intersects(polyRect, item->mapRectToParent(br))) {
+ if (!item->d_ptr->isClippedAway()) {
+ // ### _q_adjustedRect is only needed because QRectF::intersects,
+ // QRectF::contains and QTransform::map() and friends don't work with
+ // flat rectangles.
+ const QRectF br(adjustedItemBoundingRect(item));
+ if (mode >= Qt::ContainsItemBoundingRect) {
+ // Polygon contains/intersects item's bounding rect
if (path == QPainterPath())
path.addPolygon(polygon);
- if (itemCollidesWithPath(item, item->mapFromParent(path), mode)) {
+ if ((mode == Qt::IntersectsItemBoundingRect && path.intersects(item->mapRectToParent(br)))
+ || (mode == Qt::ContainsItemBoundingRect && path.contains(item->mapRectToParent(br)))) {
items->append(item);
keep = true;
}
+ } else {
+ // Polygon contains/intersects item's shape
+ if (QRectF_intersects(polyRect, item->mapRectToParent(br))) {
+ if (path == QPainterPath())
+ path.addPolygon(polygon);
+ if (itemCollidesWithPath(item, item->mapFromParent(path), mode)) {
+ items->append(item);
+ keep = true;
+ }
+ }
}
}
@@ -1629,30 +1756,52 @@ void QGraphicsScenePrivate::childItems_helper(QList<QGraphicsItem *> *items,
Qt::ItemSelectionMode mode) const
{
bool parentClip = (parent->flags() & QGraphicsItem::ItemClipsChildrenToShape);
- QPainterPath intersectedPath = !parentClip ? path : path.intersected(parent->shape());
- if (intersectedPath.isEmpty())
+ if (parentClip && parent->d_ptr->isClippedAway())
+ return;
+ QRectF pathRect(path.boundingRect());
+ _q_adjustRect(&pathRect);
+ QRectF r = !parentClip ? pathRect : pathRect.intersected(adjustedItemBoundingRect(parent));
+ if (r.isEmpty())
return;
QList<QGraphicsItem *> &children = parent->d_ptr->children;
for (int i = 0; i < children.size(); ++i) {
QGraphicsItem *item = children.at(i);
+ if (item->d_ptr->hasTransform && !item->transform().isInvertible())
+ continue;
// Skip invisible items.
- if (!item->d_ptr->visible || qFuzzyCompare(item->effectiveOpacity(), qreal(0.0)))
+ if (item->d_ptr->isInvisible())
continue;
- QTransform x = item->sceneTransform();
-
- bool ok;
- QTransform xinv = x.inverted(&ok);
- if (ok) {
- QPainterPath mappedPath = xinv.map(path);
- if (itemCollidesWithPath(item, mappedPath, mode)) {
- items->append(item);
- if (!item->d_ptr->children.isEmpty())
- childItems_helper(items, item, mappedPath, mode);
+ bool keep = false;
+ if (!item->d_ptr->isClippedAway()) {
+ // ### _q_adjustedRect is only needed because QRectF::intersects,
+ // QRectF::contains and QTransform::map() and friends don't work with
+ // flat rectangles.
+ const QRectF br(adjustedItemBoundingRect(item));
+ if (mode >= Qt::ContainsItemBoundingRect) {
+ // Polygon contains/intersects item's bounding rect
+ if ((mode == Qt::IntersectsItemBoundingRect && path.intersects(item->mapRectToParent(br)))
+ || (mode == Qt::ContainsItemBoundingRect && path.contains(item->mapRectToParent(br)))) {
+ items->append(item);
+ keep = true;
+ }
+ } else {
+ // Path contains/intersects item's shape
+ if (QRectF_intersects(pathRect, item->mapRectToParent(br))) {
+ if (itemCollidesWithPath(item, item->mapFromParent(path), mode)) {
+ items->append(item);
+ keep = true;
+ }
+ }
}
}
+
+ if ((keep || !(item->flags() & QGraphicsItem::ItemClipsChildrenToShape)) && !item->d_ptr->children.isEmpty()) {
+ // Recurse into children that clip children.
+ childItems_helper(items, item, item->mapFromParent(path), mode);
+ }
}
}
@@ -2326,17 +2475,8 @@ QList<QGraphicsItem *> QGraphicsScene::items() const
*/
QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos) const
{
- QList<QGraphicsItem *> itemsAtPoint;
-
- // Find all items within a 1x1 rect area starting at pos. This can be
- // inefficient for scenes that use small coordinates (like unity
- // coordinates), or for detailed graphs. ### The index should support
- // fetching items at a pos to avoid this limitation.
- foreach (QGraphicsItem *item, items(QRectF(pos, QSizeF(1, 1)), Qt::IntersectsItemBoundingRect)) {
- if (item->contains(item->mapFromScene(pos)))
- itemsAtPoint << item;
- }
- return itemsAtPoint;
+ Q_D(const QGraphicsScene);
+ return d->items_helper(pos);
}
@@ -2723,8 +2863,9 @@ void QGraphicsScene::addItem(QGraphicsItem *item)
// Notify the item that its scene is changing, and allow the item to
// react.
- QGraphicsScene *targetScene = qVariantValue<QGraphicsScene *>(item->itemChange(QGraphicsItem::ItemSceneChange,
- qVariantFromValue<QGraphicsScene *>(this)));
+ const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange,
+ qVariantFromValue<QGraphicsScene *>(this)));
+ QGraphicsScene *targetScene = qVariantValue<QGraphicsScene *>(newSceneVariant);
if (targetScene != this) {
if (targetScene && item->scene() != targetScene)
targetScene->addItem(item);
@@ -2818,7 +2959,7 @@ void QGraphicsScene::addItem(QGraphicsItem *item)
emit selectionChanged();
// Deliver post-change notification
- item->itemChange(QGraphicsItem::ItemSceneHasChanged, qVariantFromValue<QGraphicsScene *>(this));
+ item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant);
}
/*!
@@ -3082,8 +3223,9 @@ void QGraphicsScene::removeItem(QGraphicsItem *item)
// Notify the item that it's scene is changing to 0, allowing the item to
// react.
- QGraphicsScene *targetScene = qVariantValue<QGraphicsScene *>(item->itemChange(QGraphicsItem::ItemSceneChange,
- qVariantFromValue<QGraphicsScene *>(0)));
+ const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange,
+ qVariantFromValue<QGraphicsScene *>(0)));
+ QGraphicsScene *targetScene = qVariantValue<QGraphicsScene *>(newSceneVariant);
if (targetScene != 0 && targetScene != this) {
targetScene->addItem(item);
return;
@@ -3154,6 +3296,16 @@ void QGraphicsScene::removeItem(QGraphicsItem *item)
d->unpolishedItems.removeAll(item);
d->dirtyItems.removeAll(item);
+ //We remove all references of item from the sceneEventFilter arrays
+ QMultiMap<QGraphicsItem*, QGraphicsItem*>::iterator iterator = d->sceneEventFilters.begin();
+ while (iterator != d->sceneEventFilters.end()) {
+ if (iterator.value() == item || iterator.key() == item)
+ iterator = d->sceneEventFilters.erase(iterator);
+ else
+ ++iterator;
+ }
+
+
//Ensure dirty flag have the correct default value so the next time it will be added it will receive updates
item->d_func()->dirty = 0;
item->d_func()->dirtyChildren = 0;
@@ -3181,7 +3333,7 @@ void QGraphicsScene::removeItem(QGraphicsItem *item)
emit selectionChanged();
// Deliver post-change notification
- item->itemChange(QGraphicsItem::ItemSceneHasChanged, qVariantFromValue<QGraphicsScene *>(0));
+ item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant);
}
/*!
@@ -3455,7 +3607,7 @@ QVariant QGraphicsScene::inputMethodQuery(Qt::InputMethodQuery query) const
void QGraphicsScene::update(const QRectF &rect)
{
Q_D(QGraphicsScene);
- if (d->updateAll)
+ if (d->updateAll || (rect.isEmpty() && !rect.isNull()))
return;
// Check if anyone's connected; if not, we can send updates directly to
@@ -4564,7 +4716,9 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
// Item's (local) bounding rect
QRectF brect = item->boundingRect();
- if (_q_adjustedRect(brect).isEmpty())
+ QRectF adjustedBrect(brect);
+ _q_adjustRect(&adjustedBrect);
+ if (adjustedBrect.isEmpty())
return;
// Fetch the off-screen transparent buffer and exposed area info.
@@ -4595,16 +4749,17 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
if (cacheMode == QGraphicsItem::ItemCoordinateCache) {
QSize pixmapSize;
bool fixedCacheSize = false;
+ QRectF brectAligned = brect.toAlignedRect();
if ((fixedCacheSize = itemCache->fixedSize.isValid())) {
pixmapSize = itemCache->fixedSize;
} else {
- pixmapSize = brect.toAlignedRect().size();
+ pixmapSize = brectAligned.size().toSize();
}
// Create or recreate the pixmap.
int adjust = itemCache->fixedSize.isValid() ? 0 : 2;
QSize adjustSize(adjust*2, adjust*2);
- QRectF br = brect.adjusted(-adjust, -adjust, adjust, adjust);
+ QRectF br = brectAligned.adjusted(-adjust, -adjust, adjust, adjust);
if (pix.isNull() || (!fixedCacheSize && (pixmapSize + adjustSize) != pix.size())) {
pix = QPixmap(pixmapSize + adjustSize);
itemCache->exposed.clear();
@@ -4614,9 +4769,11 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
// Redraw any newly exposed areas.
if (itemCache->allExposed || !itemCache->exposed.isEmpty()) {
// Fit the item's bounding rect into the pixmap's coordinates.
- const QPointF scale(pixmapSize.width() / brect.width(), pixmapSize.height() / brect.height());
QTransform itemToPixmap;
- itemToPixmap.scale(scale.x(), scale.y());
+ if (fixedCacheSize) {
+ const QPointF scale(pixmapSize.width() / brect.width(), pixmapSize.height() / brect.height());
+ itemToPixmap.scale(scale.x(), scale.y());
+ }
itemToPixmap.translate(-br.x(), -br.y());
// Generate the item's exposedRect and map its list of expose
@@ -4769,8 +4926,9 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte
if (itemCache->allExposed || !itemCache->exposed.isEmpty() || !scrollExposure.isEmpty()) {
// Construct an item-to-pixmap transform.
QPointF p = deviceRect.topLeft();
- QTransform itemToPixmap = QTransform::fromTranslate(-p.x(), -p.y());
- itemToPixmap = painter->worldTransform() * itemToPixmap;
+ QTransform itemToPixmap = painter->worldTransform();
+ if (!p.isNull())
+ itemToPixmap *= QTransform::fromTranslate(-p.x(), -p.y());
// Map the item's logical expose to pixmap coordinates.
QRegion pixmapExposed = scrollExposure;
@@ -5104,9 +5262,12 @@ void QGraphicsScene::itemUpdated(QGraphicsItem *item, const QRectF &rect)
update(item->sceneBoundingRect());
} else {
// ### Remove _q_adjustedRects().
- QRectF boundingRect = _q_adjustedRect(item->boundingRect());
- if (!rect.isNull())
- boundingRect &= _q_adjustedRect(rect);
+ QRectF boundingRect(adjustedItemBoundingRect(item));
+ if (!rect.isNull()) {
+ QRectF adjustedRect(rect);
+ _q_adjustRect(&adjustedRect);
+ boundingRect &= adjustedRect;
+ }
// Update each view directly.
for (int i = 0; i < d->views.size(); ++i)
@@ -5118,6 +5279,9 @@ void QGraphicsScene::itemUpdated(QGraphicsItem *item, const QRectF &rect)
d->resetDirtyItemsLater();
}
+ if (!item->isVisible())
+ return; // Hiding an item won't effect the largestUntransformableItem/sceneRect.
+
// Update d->largestUntransformableItem by mapping this item's bounding
// rect back to the topmost untransformable item's untransformed
// coordinate system (which sort of equals the 1:1 coordinate system of an
@@ -5133,7 +5297,9 @@ void QGraphicsScene::itemUpdated(QGraphicsItem *item, const QRectF &rect)
// defined scene rect.
if (!d->hasSceneRect) {
QRectF oldGrowingItemsBoundingRect = d->growingItemsBoundingRect;
- d->growingItemsBoundingRect |= _q_adjustedRect(item->sceneBoundingRect());
+ QRectF adjustedItemSceneBoundingRect(item->sceneBoundingRect());
+ _q_adjustRect(&adjustedItemSceneBoundingRect);
+ d->growingItemsBoundingRect |= adjustedItemSceneBoundingRect;
if (d->growingItemsBoundingRect != oldGrowingItemsBoundingRect)
emit sceneRectChanged(d->growingItemsBoundingRect);
}
diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h
index 9c165d1..befbbd8 100644
--- a/src/gui/graphicsview/qgraphicsscene_p.h
+++ b/src/gui/graphicsview/qgraphicsscene_p.h
@@ -197,6 +197,7 @@ public:
void mousePressEventHandler(QGraphicsSceneMouseEvent *mouseEvent);
QGraphicsWidget *windowForItem(const QGraphicsItem *item) const;
+ QList<QGraphicsItem *> items_helper(const QPointF &pos) const;
QList<QGraphicsItem *> items_helper(const QRectF &rect,
Qt::ItemSelectionMode mode,
Qt::SortOrder order) const;
@@ -208,6 +209,9 @@ public:
Qt::SortOrder order) const;
void childItems_helper(QList<QGraphicsItem *> *items,
const QGraphicsItem *parent,
+ const QPointF &pos) const;
+ void childItems_helper(QList<QGraphicsItem *> *items,
+ const QGraphicsItem *parent,
const QRectF &rect,
Qt::ItemSelectionMode mode) const;
void childItems_helper(QList<QGraphicsItem *> *items,
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
index 2f7f57a..b5a1bdf 100644
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ b/src/gui/graphicsview/qgraphicsview.cpp
@@ -790,6 +790,19 @@ QRegion QGraphicsViewPrivate::mapToViewRegion(const QGraphicsItem *item, const Q
return item->boundingRegion(itv) & itv.mapRect(rect).toAlignedRect();
}
+// QRectF::intersects() returns false always if either the source or target
+// rectangle's width or height are 0. This works around that problem.
+static inline QRectF adjustedItemBoundingRect(const QGraphicsItem *item)
+{
+ Q_ASSERT(item);
+ QRectF boundingRect(item->boundingRect());
+ if (!boundingRect.width())
+ boundingRect.adjust(-0.00001, 0, 0.00001, 0);
+ if (!boundingRect.height())
+ boundingRect.adjust(0, -0.00001, 0, 0.00001);
+ return boundingRect;
+}
+
/*!
\internal
*/
@@ -801,38 +814,37 @@ void QGraphicsViewPrivate::itemUpdated(QGraphicsItem *item, const QRectF &rect)
updateLater();
QRectF updateRect = rect;
- if (item->isClipped()) {
+ if ((item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape) || item->d_ptr->children.isEmpty()) {
+ updateRect &= adjustedItemBoundingRect(item);
+ if (updateRect.isEmpty())
+ return;
+ }
+
+ QGraphicsItem *clipItem = item;
+ if (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) {
// Minimize unnecessary redraw.
- QGraphicsItem *p = item;
- while ((p = p->d_ptr->parent)) {
- if (p->flags() & QGraphicsItem::ItemClipsChildrenToShape) {
- updateRect &= p->itemTransform(item).mapRect(p->boundingRect());
- if (updateRect.isNull())
+ QGraphicsItem *parent = item;
+ while ((parent = parent->d_ptr->parent)) {
+ if (parent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape) {
+ // Map update rect to the current parent and itersect with its bounding rect.
+ updateRect = clipItem->itemTransform(parent).mapRect(updateRect)
+ & adjustedItemBoundingRect(parent);
+ if (updateRect.isEmpty())
return;
+ clipItem = parent;
}
- if (!(p->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren))
+ if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren))
break;
}
-
- if (updateRect.isNull())
- return;
}
- // Map the rect to view coordinates.
- QRect vr = viewport->rect();
-
- if (!item->d_ptr->hasBoundingRegionGranularity) {
- QRect r = mapToViewRect(item, updateRect) & vr;
- if (r.isNull())
- return;
- this->updateRect(r);
- } else {
- QRegion r = mapToViewRegion(item, updateRect) & vr;
- if (r.isEmpty())
- return;
- updateRegion(r);
- }
+ // Map update rect from clipItem coordinates to view coordinates.
+ Q_ASSERT(clipItem);
+ if (!item->d_ptr->hasBoundingRegionGranularity)
+ this->updateRect(mapToViewRect(clipItem, updateRect) & viewport->rect());
+ else
+ updateRegion(mapToViewRegion(clipItem, updateRect) & viewport->rect());
}
void QGraphicsViewPrivate::updateLater()
@@ -855,16 +867,19 @@ void QGraphicsViewPrivate::_q_updateLaterSlot()
const QList<QGraphicsItem *> &dirtyItems = scene->d_func()->dirtyItems;
for (int i = 0; i < dirtyItems.size(); ++i) {
const QGraphicsItem *item = dirtyItems.at(i);
+ if (item->d_ptr->discardUpdateRequest(/*ignoreClipping=*/false,
+ /*ignoreVisibleBit=*/false,
+ /*ignoreDirtyBit=*/true)) {
+ continue;
+ }
QTransform x = item->sceneTransform() * viewTransform;
- QRect viewRect = x.mapRect(item->boundingRect()).toAlignedRect() & vr;
- if (!viewRect.isNull())
- updateRect(viewRect);
+ updateRect(x.mapRect(item->boundingRect()).toAlignedRect() & vr);
}
dirtyRectCount += dirtyRects.size();
bool noUpdate = !fullUpdatePending && viewportUpdateMode == QGraphicsView::FullViewportUpdate;
- if ((dirtyRectCount > 0 || !dirtyBoundingRect.isNull()) && !fullUpdatePending && !noUpdate) {
+ if ((dirtyRectCount > 0 || !dirtyBoundingRect.isEmpty()) && !fullUpdatePending && !noUpdate) {
if (viewportUpdateMode == QGraphicsView::BoundingRectViewportUpdate
|| (viewportUpdateMode == QGraphicsView::SmartViewportUpdate
&& dirtyRectCount >= QGRAPHICSVIEW_REGION_RECT_THRESHOLD)) {
@@ -921,6 +936,9 @@ void QGraphicsViewPrivate::updateAll()
void QGraphicsViewPrivate::updateRegion(const QRegion &r)
{
+ if (r.isEmpty())
+ return;
+
Q_Q(QGraphicsView);
// Rect intersects viewport - update everything?
@@ -969,6 +987,9 @@ void QGraphicsViewPrivate::updateRegion(const QRegion &r)
void QGraphicsViewPrivate::updateRect(const QRect &r)
{
+ if (r.isEmpty())
+ return;
+
Q_Q(QGraphicsView);
// Rect intersects viewport - update everything?
@@ -1025,103 +1046,71 @@ void QGraphicsViewPrivate::freeStyleOptionsArray(QStyleOptionGraphicsItem *array
extern QPainterPath qt_regionToPath(const QRegion &region);
-QList<QGraphicsItem *> QGraphicsViewPrivate::findItems(const QRegion &exposedRegion,
- const QTransform &worldTransform,
- bool *allItems) const
+/*!
+ ### Adjustments in findItems: mapToScene(QRect) forces us to adjust the
+ input rectangle by (0, 0, 1, 1), because it uses QRect::bottomRight()
+ (etc) when mapping the rectangle to a polygon (which is _wrong_). In
+ addition, as QGraphicsItem::boundingRect() is defined in logical space,
+ but the default pen for QPainter is cosmetic with a width of 0, QPainter
+ is at risk of painting 1 pixel outside the bounding rect. Therefore we
+ must search for items with an adjustment of (-1, -1, 1, 1).
+*/
+QList<QGraphicsItem *> QGraphicsViewPrivate::findItems(const QRegion &exposedRegion, bool *allItems) const
{
Q_Q(const QGraphicsView);
- QList<QGraphicsItem *> itemList;
- QSet<QGraphicsItem *> tmp;
- bool simpleTransform = worldTransform.type() <= QTransform::TxScale;
-
- QPainterPath path = qt_regionToPath(exposedRegion);
- *allItems = path.contains(q->mapFromScene(scene->d_func()->growingItemsBoundingRect).boundingRect());
- QList<QRectF> exposedRects;
- QList<QPolygonF> exposedPolys;
-
- // Transform the exposed viewport rects to scene rects or polygons
- foreach (const QRect &rect, exposedRegion.rects()) {
- QPolygonF exposedPoly = q->mapToScene(rect.adjusted(-1, -1, 1, 1));
- QRectF exposedRect = exposedPoly.boundingRect();
- if (!simpleTransform)
- exposedPolys << exposedPoly;
- exposedRects << exposedRect;
- }
-
- // Find which items need to be drawn.
- if (*allItems) {
+
+ // Step 1) If all items are contained within the expose region, then
+ // return a list of all visible items.
+ const QRectF exposedRegionSceneBounds = q->mapToScene(exposedRegion.boundingRect().adjusted(-1, -1, 2, 2))
+ .boundingRect();
+ if (exposedRegionSceneBounds.contains(scene->d_func()->growingItemsBoundingRect)) {
+ Q_ASSERT(allItems);
+ *allItems = true;
+
// All items are guaranteed within the exposed region, don't bother using the index.
- foreach (QGraphicsItem *item, scene->items()) {
+ QList<QGraphicsItem *> itemList(scene->items());
+ int i = 0;
+ while (i < itemList.size()) {
// But we only want to include items that are visible
- if (item->isVisible())
- itemList << item;
- }
- } else if (simpleTransform) {
- // Simple rect lookups will do.
- if (exposedRects.size() > 1) {
- foreach (const QRectF &rect, exposedRects) {
- foreach (QGraphicsItem *item, scene->d_func()->items_helper(rect, Qt::IntersectsItemBoundingRect, Qt::SortOrder(-1) /* don't sort */)) {
- if (!tmp.contains(item)) {
- tmp << item;
- itemList << item;
- }
- }
- }
- } else {
- itemList += scene->d_func()->items_helper(exposedRects[0], Qt::IntersectsItemBoundingRect, Qt::SortOrder(-1) /* don't sort */);
- }
- } else {
- // Polygon lookup is necessary.
- if (exposedRects.size() > 1) {
- foreach (const QPolygonF &poly, exposedPolys) {
- foreach (QGraphicsItem *item, scene->d_func()->items_helper(poly, Qt::IntersectsItemBoundingRect, Qt::SortOrder(-1) /* don't sort */)) {
- if (!tmp.contains(item)) {
- tmp << item;
- itemList << item;
- }
- }
- }
- } else {
- itemList += scene->d_func()->items_helper(exposedPolys[0], Qt::IntersectsItemBoundingRect, Qt::SortOrder(-1) /* don't sort */);
+ if (!itemList.at(i)->isVisible())
+ itemList.removeAt(i);
+ else
+ ++i;
}
+
+ // Sort the items.
+ QGraphicsScenePrivate::sortItems(&itemList, Qt::DescendingOrder, scene->d_func()->sortCacheEnabled);
+ return itemList;
}
- // Check for items that ignore inherited transformations, and add them if
- // necessary.
- QRectF untr = scene->d_func()->largestUntransformableItem;
- if (!*allItems && !untr.isNull()) {
- // Map the largest untransformable item subtree boundingrect from view
- // to scene coordinates, and use this to expand all exposed rects in
- // search for untransformable items.
- QRectF ltri = matrix.inverted().mapRect(untr);
- ltri.adjust(-untr.width(), -untr.height(), untr.width(), untr.height());
-
- foreach (const QRect &rect, exposedRegion.rects()) {
- QRectF exposed = q->mapToScene(rect.adjusted(-1, -1, 1, 1)).boundingRect();
- exposed.adjust(-ltri.width(), -ltri.height(), ltri.width(), ltri.height());
-
- foreach (QGraphicsItem *item, scene->d_func()->estimateItemsInRect(exposed)) {
- if (item->d_ptr->itemIsUntransformable()) {
- if (!tmp.contains(item)) {
- QPainterPath rectPath;
- rectPath.addRect(rect);
- QPainterPath path = item->deviceTransform(q->viewportTransform()).inverted().map(rectPath);
- if (item->collidesWithPath(path, Qt::IntersectsItemBoundingRect)) {
- itemList << item;
- tmp << item;
- }
- }
- }
- }
- }
+ // Step 2) If the expose region is a simple rect and the view is only
+ // translated or scaled, search for items using
+ // QGraphicsScene::items(QRectF).
+ bool simpleRectLookup = (scene->d_func()->largestUntransformableItem.isNull()
+ && exposedRegion.numRects() == 1 && matrix.type() <= QTransform::TxScale);
+ if (simpleRectLookup) {
+ return scene->d_func()->items_helper(exposedRegionSceneBounds,
+ Qt::IntersectsItemBoundingRect,
+ Qt::DescendingOrder);
}
- tmp.clear();
- // Sort the items.
- QGraphicsScenePrivate::sortItems(&itemList, Qt::DescendingOrder,
- scene->d_func()->sortCacheEnabled);
+ // If the region is complex or the view has a complex transform, adjust
+ // the expose region, convert it to a path, and then search for items
+ // using QGraphicsScene::items(QPainterPath);
+ QRegion adjustedRegion;
+ foreach (const QRect &r, exposedRegion.rects())
+ adjustedRegion += r.adjusted(-1, -1, 1, 1);
+
+ const QPainterPath exposedPath(qt_regionToPath(adjustedRegion));
+ if (scene->d_func()->largestUntransformableItem.isNull()) {
+ const QPainterPath exposedScenePath(q->mapToScene(exposedPath));
+ return scene->d_func()->items_helper(exposedScenePath,
+ Qt::IntersectsItemBoundingRect,
+ Qt::DescendingOrder);
+ }
- return itemList;
+ // NB! Path must be in viewport coordinates.
+ return itemsInArea(exposedPath, Qt::IntersectsItemBoundingRect, Qt::DescendingOrder);
}
void QGraphicsViewPrivate::generateStyleOptions(const QList<QGraphicsItem *> &itemList,
@@ -2224,7 +2213,8 @@ QList<QGraphicsItem *> QGraphicsView::items() const
certainly room for improvement.
*/
QList<QGraphicsItem *> QGraphicsViewPrivate::itemsInArea(const QPainterPath &path,
- Qt::ItemSelectionMode mode) const
+ Qt::ItemSelectionMode mode,
+ Qt::SortOrder order) const
{
Q_Q(const QGraphicsView);
@@ -2274,8 +2264,8 @@ QList<QGraphicsItem *> QGraphicsViewPrivate::itemsInArea(const QPainterPath &pat
}
// ### Insertion sort would be faster.
- QGraphicsScenePrivate::sortItems(&result, Qt::AscendingOrder,
- scene->d_func()->sortCacheEnabled);
+ if (order != Qt::SortOrder(-1))
+ QGraphicsScenePrivate::sortItems(&result, order, scene->d_func()->sortCacheEnabled);
return result;
}
@@ -3280,7 +3270,7 @@ void QGraphicsView::mouseMoveEvent(QMouseEvent *event)
}
// Update old rubberband
- if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate && !d->rubberBandRect.isNull()) {
+ if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate && !d->rubberBandRect.isEmpty()) {
if (d->viewportUpdateMode != FullViewportUpdate)
viewport()->update(d->rubberBandRegion(viewport(), d->rubberBandRect));
else
@@ -3462,7 +3452,7 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
QPainter painter(viewport());
QTransform original = painter.worldTransform();
#ifndef QT_NO_RUBBERBAND
- if (d->rubberBanding && !d->rubberBandRect.isNull())
+ if (d->rubberBanding && !d->rubberBandRect.isEmpty())
painter.save();
#endif
// Set up render hints
@@ -3481,7 +3471,7 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
// Find all exposed items
bool allItems = false;
- QList<QGraphicsItem *> itemList = d->findItems(exposedRegion, viewTransform, &allItems);
+ QList<QGraphicsItem *> itemList = d->findItems(exposedRegion, &allItems);
#ifdef QGRAPHICSVIEW_DEBUG
int exposedTime = stopWatch.elapsed();
@@ -3557,7 +3547,7 @@ void QGraphicsView::paintEvent(QPaintEvent *event)
#ifndef QT_NO_RUBBERBAND
// Rubberband
- if (d->rubberBanding && !d->rubberBandRect.isNull()) {
+ if (d->rubberBanding && !d->rubberBandRect.isEmpty()) {
painter.restore();
QStyleOptionRubberBand option;
option.initFrom(viewport());
@@ -3631,30 +3621,30 @@ void QGraphicsView::scrollContentsBy(int dx, int dy)
if (isRightToLeft())
dx = -dx;
- if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate
- && d->viewportUpdateMode != QGraphicsView::FullViewportUpdate) {
- for (int i = 0; i < d->dirtyRects.size(); ++i)
- d->dirtyRects[i].translate(dx, dy);
- for (int i = 0; i < d->dirtyRegions.size(); ++i)
- d->dirtyRegions[i].translate(dx, dy);
- }
-
+ if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate) {
+ if (d->viewportUpdateMode != QGraphicsView::FullViewportUpdate) {
+ for (int i = 0; i < d->dirtyRects.size(); ++i)
+ d->dirtyRects[i].translate(dx, dy);
+ for (int i = 0; i < d->dirtyRegions.size(); ++i)
+ d->dirtyRegions[i].translate(dx, dy);
+ if (d->accelerateScrolling) {
#ifndef QT_NO_RUBBERBAND
- // Update old rubberband
- if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate && !d->rubberBandRect.isNull()) {
- if (d->viewportUpdateMode != FullViewportUpdate)
- viewport()->update(d->rubberBandRegion(viewport(), d->rubberBandRect));
- else
- viewport()->update();
- }
+ // Update new and old rubberband regions
+ if (!d->rubberBandRect.isEmpty()) {
+ QRegion rubberBandRegion(d->rubberBandRegion(viewport(), d->rubberBandRect));
+ rubberBandRegion += rubberBandRegion.translated(-dx, -dy);
+ viewport()->update(rubberBandRegion);
+ }
#endif
-
- if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate){
- if (d->accelerateScrolling && d->viewportUpdateMode != FullViewportUpdate)
- viewport()->scroll(dx, dy);
- else
+ viewport()->scroll(dx, dy);
+ } else {
+ viewport()->update();
+ }
+ } else {
viewport()->update();
+ }
}
+
d->updateLastCenterPoint();
if ((d->cacheMode & CacheBackground)
diff --git a/src/gui/graphicsview/qgraphicsview_p.h b/src/gui/graphicsview/qgraphicsview_p.h
index 2109673..a76279e 100644
--- a/src/gui/graphicsview/qgraphicsview_p.h
+++ b/src/gui/graphicsview/qgraphicsview_p.h
@@ -85,7 +85,8 @@ public:
qint64 verticalScroll() const;
QList<QGraphicsItem *> itemsInArea(const QPainterPath &path,
- Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const;
+ Qt::ItemSelectionMode mode = Qt::IntersectsItemShape,
+ Qt::SortOrder = Qt::AscendingOrder) const;
QPointF mousePressItemPoint;
QPointF mousePressScenePoint;
@@ -172,9 +173,7 @@ public:
void updateRegion(const QRegion &region);
bool updateSceneSlotReimplementedChecked;
- QList<QGraphicsItem *> findItems(const QRegion &exposedRegion,
- const QTransform &worldTransform,
- bool *allItems) const;
+ QList<QGraphicsItem *> findItems(const QRegion &exposedRegion, bool *allItems) const;
void generateStyleOptions(const QList<QGraphicsItem *> &itemList,
QGraphicsItem **itemArray,
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index 5cc18f9..7f02fb9 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -366,32 +366,33 @@ void QGraphicsWidget::resize(const QSizeF &size)
void QGraphicsWidget::setGeometry(const QRectF &rect)
{
QGraphicsWidgetPrivate *wd = QGraphicsWidget::d_func();
- const QGraphicsLayoutItemPrivate *d = QGraphicsLayoutItem::d_ptr;
- setAttribute(Qt::WA_Resized);
- QRectF newGeom = rect;
- newGeom.setSize(rect.size().expandedTo(effectiveSizeHint(Qt::MinimumSize))
- .boundedTo(effectiveSizeHint(Qt::MaximumSize)));
- if (newGeom == d->geom)
- return;
-
- // Update and prepare to change the geometry (remove from index).
- if (wd->scene) {
- if (rect.topLeft() != d->geom.topLeft())
- wd->fullUpdateHelper(true);
- else
- update();
- }
- prepareGeometryChange();
-
- // setPos triggers ItemPositionChange, which can adjust position
+ QGraphicsLayoutItemPrivate *d = QGraphicsLayoutItem::d_ptr;
+ QRectF newGeom;
QPointF oldPos = d->geom.topLeft();
- wd->inSetGeometry = 1;
- wd->setPosHelper(newGeom.topLeft(), /* update = */ false);
- wd->inSetGeometry = 0;
- newGeom.moveTopLeft(pos());
-
- if (newGeom == d->geom)
- return;
+ if (!wd->inSetPos) {
+ setAttribute(Qt::WA_Resized);
+ newGeom = rect;
+ newGeom.setSize(rect.size().expandedTo(effectiveSizeHint(Qt::MinimumSize))
+ .boundedTo(effectiveSizeHint(Qt::MaximumSize)));
+ if (newGeom == d->geom)
+ return;
+
+ // setPos triggers ItemPositionChange, which can adjust position
+ wd->inSetGeometry = 1;
+ wd->setPosHelper(newGeom.topLeft());
+ wd->inSetGeometry = 0;
+ newGeom.moveTopLeft(pos());
+
+ if (newGeom == d->geom)
+ return;
+
+ // Update and prepare to change the geometry (remove from index) if the size has changed.
+ if (wd->scene) {
+ if (rect.topLeft() == d->geom.topLeft()) {
+ prepareGeometryChange();
+ }
+ }
+ }
// Update the layout item geometry
bool moved = oldPos != pos();
@@ -401,6 +402,11 @@ void QGraphicsWidget::setGeometry(const QRectF &rect)
event.setOldPos(oldPos);
event.setNewPos(pos());
QApplication::sendEvent(this, &event);
+ if (wd->inSetPos) {
+ //set the new pos
+ d->geom.moveTopLeft(pos());
+ return;
+ }
}
QSizeF oldSize = size();
QGraphicsLayoutItem::setGeometry(newGeom);
@@ -1016,9 +1022,11 @@ QVariant QGraphicsWidget::itemChange(GraphicsItemChange change, const QVariant &
break;
case ItemPositionHasChanged:
if (!d->inSetGeometry) {
+ d->inSetPos = 1;
// Ensure setGeometry is called (avoid recursion when setPos is
// called from within setGeometry).
setGeometry(QRectF(pos(), size()));
+ d->inSetPos = 0 ;
}
break;
case ItemParentChange: {
@@ -1269,6 +1277,8 @@ bool QGraphicsWidget::event(QEvent *event)
break;
case QEvent::Polish:
polishEvent();
+ d->polished = true;
+ d->updateFont(d->font);
break;
case QEvent::WindowActivate:
case QEvent::WindowDeactivate:
diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp
index 641409d..789f8da 100644
--- a/src/gui/graphicsview/qgraphicswidget_p.cpp
+++ b/src/gui/graphicsview/qgraphicswidget_p.cpp
@@ -274,6 +274,8 @@ void QGraphicsWidgetPrivate::updateFont(const QFont &font)
}
}
+ if (!polished)
+ return;
// Notify change.
QEvent event(QEvent::FontChange);
QApplication::sendEvent(q, &event);
diff --git a/src/gui/graphicsview/qgraphicswidget_p.h b/src/gui/graphicsview/qgraphicswidget_p.h
index afa6812..53eaa31 100644
--- a/src/gui/graphicsview/qgraphicswidget_p.h
+++ b/src/gui/graphicsview/qgraphicswidget_p.h
@@ -85,6 +85,8 @@ public:
inheritedPaletteResolveMask(0),
inheritedFontResolveMask(0),
inSetGeometry(0),
+ polished(0),
+ inSetPos(0),
focusPolicy(Qt::NoFocus),
focusNext(0),
focusPrev(0),
@@ -193,6 +195,8 @@ public:
}
quint32 attributes : 10;
quint32 inSetGeometry : 1;
+ quint32 polished: 1;
+ quint32 inSetPos : 1;
// Focus
Qt::FocusPolicy focusPolicy;
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 558d574..c7a20db 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -3607,6 +3607,9 @@ int QImage::pixelIndex(int x, int y) const
If the \a position is not valid, the results are undefined.
+ \warning This function is expensive when used for massive pixel
+ manipulations.
+
\sa setPixel(), valid(), {QImage#Pixel Manipulation}{Pixel
Manipulation}
*/
@@ -4937,10 +4940,12 @@ int QImage::dotsPerMeterY() const
meter, to \a x.
Together with dotsPerMeterY(), this number defines the intended
- scale and aspect ratio of the image.
+ scale and aspect ratio of the image, and determines the scale
+ at which QPainter will draw graphics on the image. It does not
+ change the scale or aspect ratio of the image when it is rendered
+ on other paint devices.
- \sa dotsPerMeterX(), {QImage#Image Information}{Image
- Information}
+ \sa dotsPerMeterX(), {QImage#Image Information}{Image Information}
*/
void QImage::setDotsPerMeterX(int x)
{
@@ -4957,10 +4962,12 @@ void QImage::setDotsPerMeterX(int x)
to \a y.
Together with dotsPerMeterX(), this number defines the intended
- scale and aspect ratio of the image.
+ scale and aspect ratio of the image, and determines the scale
+ at which QPainter will draw graphics on the image. It does not
+ change the scale or aspect ratio of the image when it is rendered
+ on other paint devices.
- \sa dotsPerMeterY(), {QImage#Image Information}{Image
- Information}
+ \sa dotsPerMeterY(), {QImage#Image Information}{Image Information}
*/
void QImage::setDotsPerMeterY(int y)
{
@@ -5577,6 +5584,8 @@ bool QImage::isDetached() const
Use one of the composition mods in QPainter::CompositionMode instead.
+ \warning This function is expensive.
+
\sa alphaChannel(), {QImage#Image Transformations}{Image
Transformations}, {QImage#Image Formats}{Image Formats}
*/
@@ -5659,6 +5668,11 @@ void QImage::setAlphaChannel(const QImage &alphaChannel)
\l{QPixmap::}{alphaChannel()}, which works in the same way as
this function on QPixmaps.
+ Most usecases for this function can be replaced with QPainter and
+ using composition modes.
+
+ \warning This is an expensive function.
+
\sa setAlphaChannel(), hasAlphaChannel(),
{QPixmap#Pixmap Information}{Pixmap},
{QImage#Image Transformations}{Image Transformations}
diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp
index 6b74323..33e565c 100644
--- a/src/gui/image/qnativeimage.cpp
+++ b/src/gui/image/qnativeimage.cpp
@@ -100,7 +100,9 @@ QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool is
bmi.blueMask = 0;
}
- hdc = CreateCompatibleDC(qt_win_display_dc());
+ HDC display_dc = GetDC(0);
+ hdc = CreateCompatibleDC(display_dc);
+ ReleaseDC(0, display_dc);
Q_ASSERT(hdc);
uchar *bits = 0;
diff --git a/src/gui/image/qpaintengine_pic.cpp b/src/gui/image/qpaintengine_pic.cpp
index cba9827..a130a1a 100644
--- a/src/gui/image/qpaintengine_pic.cpp
+++ b/src/gui/image/qpaintengine_pic.cpp
@@ -346,7 +346,7 @@ void QPicturePaintEngine::writeCmdLength(int pos, const QRectF &r, bool corr)
if (corr) { // widen bounding rect
int w2 = painter()->pen().width() / 2;
br.setCoords(br.left() - w2, br.top() - w2,
- br.right() + w2, br.bottom() + w2);
+ br.right() + w2, br.bottom() + w2);
}
br = painter()->transform().mapRect(br);
if (painter()->hasClipping()) {
@@ -458,6 +458,25 @@ void QPicturePaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap
writeCmdLength(pos, r, false);
}
+void QPicturePaintEngine::drawImage(const QRectF &r, const QImage &image, const QRectF &sr,
+ Qt::ImageConversionFlags flags)
+{
+ Q_D(QPicturePaintEngine);
+#ifdef QT_PICTURE_DEBUG
+ qDebug() << " -> drawImage():" << r << sr;
+#endif
+ int pos;
+ SERIALIZE_CMD(QPicturePrivate::PdcDrawImage);
+ if (d->pic_d->in_memory_only) {
+ int index = d->pic_d->image_list.size();
+ d->pic_d->image_list.append(image);
+ d->s << r << index << sr << (quint32) flags;
+ } else {
+ d->s << r << image << sr << (quint32) flags;
+ }
+ writeCmdLength(pos, r, false);
+}
+
extern int qt_defaultDpi();
void QPicturePaintEngine::drawTextItem(const QPointF &p , const QTextItem &ti)
diff --git a/src/gui/image/qpaintengine_pic_p.h b/src/gui/image/qpaintengine_pic_p.h
index 3ae0845..745d057 100644
--- a/src/gui/image/qpaintengine_pic_p.h
+++ b/src/gui/image/qpaintengine_pic_p.h
@@ -100,6 +100,8 @@ public:
void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
+ void drawImage(const QRectF &r, const QImage &image, const QRectF &sr,
+ Qt::ImageConversionFlags flags = Qt::AutoColor);
void drawTextItem(const QPointF &p, const QTextItem &ti);
Type type() const { return Picture; }
diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp
index d5d7cb0..92023e0 100644
--- a/src/gui/image/qpicture.cpp
+++ b/src/gui/image/qpicture.cpp
@@ -759,13 +759,21 @@ bool QPicture::exec(QPainter *painter, QDataStream &s, int nrecords)
QImage image;
if (d->formatMajor < 4) {
s >> p >> image;
- painter->drawPixmap(p, QPixmap::fromImage(image));
+ painter->drawImage(p, image);
} else if (d->formatMajor <= 5){
s >> ir >> image;
- painter->drawPixmap(ir, QPixmap::fromImage(image), QRect(0, 0, ir.width(), ir.height()));
+ painter->drawImage(ir, image, QRect(0, 0, ir.width(), ir.height()));
} else {
- s >> r >> image;
- painter->drawPixmap(r, QPixmap::fromImage(image), QRectF(0, 0, r.width(), r.height()));
+ QRectF sr;
+ if (d->in_memory_only) {
+ int index;
+ s >> r >> index >> sr >> ul;
+ Q_ASSERT(index < d->image_list.size());
+ image = d->image_list.at(index);
+ } else {
+ s >> r >> image >> sr >> ul;
+ }
+ painter->drawImage(r, image, sr, Qt::ImageConversionFlags(ul));
}
}
break;
diff --git a/src/gui/image/qpicture_p.h b/src/gui/image/qpicture_p.h
index 1da7f07..a3fd34f 100644
--- a/src/gui/image/qpicture_p.h
+++ b/src/gui/image/qpicture_p.h
@@ -158,6 +158,7 @@ public:
QRect override_rect;
QPaintEngine *paintEngine;
bool in_memory_only;
+ QList<QImage> image_list;
QList<QPixmap> pixmap_list;
QList<QBrush> brush_list;
QList<QPen> pen_list;
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index a16f8ee..82be1b9 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -678,7 +678,7 @@ void QPixmap::resize_helper(const QSize &s)
pixels black. The effect of this function is undefined when the pixmap is
being painted on.
- This is potentially an expensive operation.
+ \warning This is potentially an expensive operation.
\sa mask(), {QPixmap#Pixmap Transformations}{Pixmap Transformations},
QBitmap
@@ -1384,6 +1384,12 @@ void QPixmap::deref()
If the given \a size is empty, this function returns a null
pixmap.
+
+ In some cases it can be more beneficial to draw the pixmap to a
+ painter with a scale set rather than scaling the pixmap. This is
+ the case when the painter is for instance based on OpenGL or when
+ the scale factor changes rapidly.
+
\sa isNull(), {QPixmap#Pixmap Transformations}{Pixmap
Transformations}
@@ -1755,6 +1761,10 @@ int QPixmap::metric(PaintDeviceMetric metric) const
The effect of this function is undefined when the pixmap is being
painted on.
+ \warning This is potentially an expensive operation. Most usecases
+ for this function are covered by QPainter and compositionModes
+ which will normally execute faster.
+
\sa alphaChannel(), {QPixmap#Pixmap Transformations}{Pixmap
Transformations}
*/
@@ -1797,6 +1807,9 @@ void QPixmap::setAlphaChannel(const QPixmap &alphaChannel)
\image alphachannelimage.png The pixmap and channelImage QPixmaps
+ \warning This is an expensive operation. The alpha channel of the
+ pixmap is extracted dynamically from the pixeldata.
+
\sa setAlphaChannel(), {QPixmap#Pixmap Information}{Pixmap
Information}
*/
@@ -1818,7 +1831,8 @@ QPaintEngine *QPixmap::paintEngine() const
Extracts a bitmap mask from the pixmap's alphachannel.
- This is potentially an expensive operation.
+ \warning This is potentially an expensive operation. The mask of
+ the pixmap is extracted dynamically from the pixeldata.
\sa setMask(), {QPixmap#Pixmap Information}{Pixmap Information}
*/
diff --git a/src/gui/image/qpixmap_mac.cpp b/src/gui/image/qpixmap_mac.cpp
index bfc605b..26d9618 100644
--- a/src/gui/image/qpixmap_mac.cpp
+++ b/src/gui/image/qpixmap_mac.cpp
@@ -303,7 +303,7 @@ void QMacPixmapData::fromImage(const QImage &img,
else
one_bit = one_bit >> (x % 8);
if ((one_bit & 0x01))
- *(drow+x) = 0x00000000;
+ *(drow+x) = 0xFF000000;
else
*(drow+x) = 0xFFFFFFFF;
}
diff --git a/src/gui/image/qpixmap_x11.cpp b/src/gui/image/qpixmap_x11.cpp
index d758221..38916c7 100644
--- a/src/gui/image/qpixmap_x11.cpp
+++ b/src/gui/image/qpixmap_x11.cpp
@@ -1288,6 +1288,12 @@ void QX11PixmapData::setMask(const QBitmap &newmask)
0, 0, 0, 0, 0, 0, w, h);
release();
*this = newData;
+ // the new QX11PixmapData object isn't referenced yet, so
+ // ref it
+ ref.ref();
+
+ // the below is to make sure the QX11PixmapData destructor
+ // doesn't delete our newly created render picture
newData.hd = 0;
newData.x11_mask = 0;
newData.picture = 0;
@@ -1431,7 +1437,7 @@ QImage QX11PixmapData::toImage() const
// we may have to swap the byte order
if ((QSysInfo::ByteOrder == QSysInfo::LittleEndian && xi->byte_order == MSBFirst)
- || (QSysInfo::ByteOrder == QSysInfo::BigEndian))
+ || (QSysInfo::ByteOrder == QSysInfo::BigEndian && xi->byte_order == LSBFirst))
{
for (int i=0; i < image.height(); i++) {
uint *p = (uint*)image.scanLine(i);
diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp
index 99a222c..4f1f0f0 100644
--- a/src/gui/image/qpixmapcache.cpp
+++ b/src/gui/image/qpixmapcache.cpp
@@ -277,7 +277,8 @@ bool QPixmapCache::insert(const QString &key, const QPixmap &pm)
/*!
Returns the cache limit (in kilobytes).
- The default cache limit is 2048 KB for Embedded, 10240 KB for Desktops.
+ The default cache limit is 2048 KB for Embedded, 10240 KB for
+ Desktops.
\sa setCacheLimit()
*/
@@ -290,7 +291,8 @@ int QPixmapCache::cacheLimit()
/*!
Sets the cache limit to \a n kilobytes.
- The default setting is 1024 kilobytes.
+ The default setting is 2048 KB for Embedded, 10240 KB for
+ Desktops.
\sa cacheLimit()
*/
diff --git a/src/gui/image/qpixmapdata_p.h b/src/gui/image/qpixmapdata_p.h
index 2e4da40..7296426 100644
--- a/src/gui/image/qpixmapdata_p.h
+++ b/src/gui/image/qpixmapdata_p.h
@@ -109,6 +109,7 @@ protected:
private:
friend class QPixmap;
friend class QGLContextPrivate;
+ friend class QX11PixmapData;
QAtomicInt ref;
int detach_no;
diff --git a/src/gui/inputmethod/qwininputcontext_win.cpp b/src/gui/inputmethod/qwininputcontext_win.cpp
index 720f0b8..e3e8aa4 100644
--- a/src/gui/inputmethod/qwininputcontext_win.cpp
+++ b/src/gui/inputmethod/qwininputcontext_win.cpp
@@ -57,15 +57,17 @@
#ifdef Q_IME_DEBUG
#include "qdebug.h"
-#endif
-
-QT_BEGIN_NAMESPACE
+#endif
-extern bool qt_sendSpontaneousEvent(QObject*, QEvent*);
#if defined(Q_OS_WINCE)
extern void qt_wince_show_SIP(bool show); // defined in qguifunctions_wince.cpp
#endif
+QT_BEGIN_NAMESPACE
+
+extern bool qt_sendSpontaneousEvent(QObject*, QEvent*);
+
+
DEFINE_GUID(IID_IActiveIMMApp,
0x08c0e040, 0x62d1, 0x11d1, 0x93, 0x26, 0x0, 0x60, 0xb0, 0x67, 0xb8, 0x6e);
diff --git a/src/gui/inputmethod/qximinputcontext_p.h b/src/gui/inputmethod/qximinputcontext_p.h
index ca2103b..3773122 100644
--- a/src/gui/inputmethod/qximinputcontext_p.h
+++ b/src/gui/inputmethod/qximinputcontext_p.h
@@ -98,6 +98,7 @@ public:
QString text;
QBitArray selectedChars;
bool composing;
+ bool preeditEmpty;
void clear();
};
diff --git a/src/gui/inputmethod/qximinputcontext_x11.cpp b/src/gui/inputmethod/qximinputcontext_x11.cpp
index 48a96b1..c320fb4 100644
--- a/src/gui/inputmethod/qximinputcontext_x11.cpp
+++ b/src/gui/inputmethod/qximinputcontext_x11.cpp
@@ -264,6 +264,7 @@ extern "C" {
qic->standardFormat(QInputContext::PreeditFormat));
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursor, sellen ? 0 : 1, QVariant());
QInputMethodEvent e(data->text, attrs);
+ data->preeditEmpty = data->text.isEmpty();
qic->sendEvent(e);
return 0;
@@ -286,6 +287,7 @@ void QXIMInputContext::ICData::clear()
text = QString();
selectedChars.clear();
composing = false;
+ preeditEmpty = true;
}
QXIMInputContext::ICData *QXIMInputContext::icData() const
@@ -435,7 +437,8 @@ void QXIMInputContext::create_xim()
// reinitialize input context after the input method
// server (like SCIM) has been launched without
// requiring the user to manually switch focus.
- if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled))
+ if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled)
+ && focusWidget->testAttribute(Qt::WA_WState_Created))
setFocusWidget(focusWidget);
}
// following code fragment is not required for immodule
@@ -537,9 +540,12 @@ void QXIMInputContext::reset()
if (mb) {
e.setCommitString(QString::fromLocal8Bit(mb));
XFree(mb);
+ data->preeditEmpty = false; // force sending an event
+ }
+ if (!data->preeditEmpty) {
+ sendEvent(e);
+ update();
}
- sendEvent(e);
- update();
}
data->clear();
}
@@ -686,6 +692,7 @@ QXIMInputContext::ICData *QXIMInputContext::createICData(QWidget *w)
{
ICData *data = new ICData;
data->widget = w;
+ data->preeditEmpty = true;
XVaNestedList preedit_attr = 0;
XIMCallback startcallback, drawcallback, donecallback;
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp
index 942c176..6c2d109 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/gui/itemviews/qabstractitemview.cpp
@@ -1400,6 +1400,9 @@ bool QAbstractItemView::event(QEvent *event)
case QEvent::FocusOut:
d->checkPersistentEditorFocus();
break;
+ case QEvent::FontChange:
+ d->doDelayedItemsLayout(); // the size of the items will change
+ break;
default:
break;
}
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp
index 27c2c54..d373163 100644
--- a/src/gui/itemviews/qheaderview.cpp
+++ b/src/gui/itemviews/qheaderview.cpp
@@ -1388,8 +1388,7 @@ int QHeaderView::defaultSectionSize() const
void QHeaderView::setDefaultSectionSize(int size)
{
Q_D(QHeaderView);
- d->defaultSectionSize = size;
- d->forceInitializing = true;
+ d->setDefaultSectionSize(size);
}
/*!
@@ -1894,9 +1893,6 @@ void QHeaderView::initializeSections()
//make sure we update the hidden sections
if (newCount < oldCount)
d->updateHiddenSections(0, newCount-1);
- } else if (d->forceInitializing) {
- initializeSections(0, newCount - 1);
- d->forceInitializing = false;
}
}
@@ -1952,7 +1948,7 @@ void QHeaderView::initializeSections(int start, int end)
if (!d->sectionHidden.isEmpty())
d->sectionHidden.resize(d->sectionCount);
- if (d->sectionCount > oldCount || d->forceInitializing)
+ if (d->sectionCount > oldCount)
d->createSectionSpan(start, end, (end - start + 1) * d->defaultSectionSize, d->globalResizeMode);
//Q_ASSERT(d->headerLength() == d->length);
@@ -3364,6 +3360,29 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize)
viewport->update();
}
+void QHeaderViewPrivate::setDefaultSectionSize(int size)
+{
+ Q_Q(QHeaderView);
+ defaultSectionSize = size;
+ int currentVisualIndex = 0;
+ for (int i = 0; i < sectionSpans.count(); ++i) {
+ QHeaderViewPrivate::SectionSpan &span = sectionSpans[i];
+ if (span.size > 0) {
+ //we resize it if it is not hidden (ie size > 0)
+ const int newSize = span.count * size;
+ if (newSize != span.size) {
+ length += newSize - span.size; //the whole length is changed
+ const int oldSectionSize = span.sectionSize();
+ span.size = span.count * size;
+ for (int i = currentVisualIndex; i < currentVisualIndex + span.count; ++i) {
+ emit q->sectionResized(logicalIndex(i), oldSectionSize, size);
+ }
+ }
+ }
+ currentVisualIndex += span.count;
+ }
+}
+
void QHeaderViewPrivate::resizeSectionSpan(int visualIndex, int oldSize, int newSize)
{
Q_Q(QHeaderView);
diff --git a/src/gui/itemviews/qheaderview_p.h b/src/gui/itemviews/qheaderview_p.h
index fbba69a..2889f08 100644
--- a/src/gui/itemviews/qheaderview_p.h
+++ b/src/gui/itemviews/qheaderview_p.h
@@ -90,7 +90,6 @@ public:
highlightSelected(false),
stretchLastSection(false),
cascadingResizing(false),
- forceInitializing(false),
stretchSections(0),
contentsSections(0),
minimumSectionSize(-1),
@@ -275,7 +274,6 @@ public:
bool highlightSelected;
bool stretchLastSection;
bool cascadingResizing;
- bool forceInitializing;
int stretchSections;
int contentsSections;
int defaultSectionSize;
@@ -310,6 +308,7 @@ public:
void createSectionSpan(int start, int end, int size, QHeaderView::ResizeMode mode);
void removeSectionsFromSpans(int start, int end);
void resizeSectionSpan(int visualIndex, int oldSize, int newSize);
+ void setDefaultSectionSize(int size);
inline int headerSectionCount() const { // for debugging
int count = 0;
diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp
index b3993c7..91431c4 100644
--- a/src/gui/itemviews/qsortfilterproxymodel.cpp
+++ b/src/gui/itemviews/qsortfilterproxymodel.cpp
@@ -1032,9 +1032,21 @@ void QSortFilterProxyModelPrivate::_q_sourceDataChanged(const QModelIndex &sourc
}
}
- if (!source_rows_remove.isEmpty())
+ if (!source_rows_remove.isEmpty()) {
remove_source_items(m->proxy_rows, m->source_rows,
source_rows_remove, source_parent, Qt::Vertical);
+ QSet<int> source_rows_remove_set = source_rows_remove.toList().toSet();
+ QVector<QModelIndex>::iterator it = m->mapped_children.begin();
+ while (it != m->mapped_children.end()) {
+ const QModelIndex source_child_index = *it;
+ if (source_rows_remove_set.contains(source_child_index.row())) {
+ it = m->mapped_children.erase(it);
+ remove_from_mapping(source_child_index);
+ } else {
+ ++it;
+ }
+ }
+ }
if (!source_rows_resort.isEmpty()) {
// Re-sort the rows
@@ -1103,6 +1115,8 @@ void QSortFilterProxyModelPrivate::_q_sourceReset()
// All internal structures are deleted in clear()
q->reset();
update_source_sort_column();
+ if (dynamic_sortfilter)
+ sort();
}
void QSortFilterProxyModelPrivate::_q_sourceLayoutAboutToBeChanged()
@@ -1495,6 +1509,7 @@ void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
d->clear_mapping();
reset();
+ d->update_source_sort_column();
}
/*!
@@ -1566,6 +1581,10 @@ bool QSortFilterProxyModel::hasChildren(const QModelIndex &parent) const
return false;
if (!d->model->hasChildren(source_parent))
return false;
+
+ if (d->model->canFetchMore(source_parent))
+ return true; //we assume we might have children that can be fetched
+
QSortFilterProxyModelPrivate::Mapping *m = d->create_mapping(source_parent).value();
return m->source_rows.count() != 0 && m->source_columns.count() != 0;
}
@@ -1893,7 +1912,7 @@ QSize QSortFilterProxyModel::span(const QModelIndex &index) const
void QSortFilterProxyModel::sort(int column, Qt::SortOrder order)
{
Q_D(QSortFilterProxyModel);
- if (d->proxy_sort_column == column && d->sort_order == order)
+ if (d->dynamic_sortfilter && d->proxy_sort_column == column && d->sort_order == order)
return;
d->sort_order = order;
d->proxy_sort_column = column;
@@ -2107,6 +2126,8 @@ void QSortFilterProxyModel::setDynamicSortFilter(bool enable)
{
Q_D(QSortFilterProxyModel);
d->dynamic_sortfilter = enable;
+ if (enable)
+ d->sort();
}
/*!
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index 2aa0c57..62c1277 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -2019,6 +2019,7 @@ int QTreeView::verticalOffset() const
// If we are scrolling per item and have non-uniform row heights,
// finding the vertical offset in pixels is going to be relatively slow.
// ### find a faster way to do this
+ d->executePostedLayout();
int offset = 0;
for (int i = 0; i < d->viewItems.count(); ++i) {
if (i == verticalScrollBar()->value())
@@ -3507,6 +3508,7 @@ void QTreeViewPrivate::updateScrollBars()
int QTreeViewPrivate::itemDecorationAt(const QPoint &pos) const
{
+ const_cast<QTreeView *>(q_func())->executeDelayedItemsLayout();
int x = pos.x();
int column = header->logicalIndexAt(x);
if (column != 0)
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 403a58b..d65a352 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -172,189 +172,174 @@ QApplicationPrivate::~QApplicationPrivate()
}
/*!
- \class QApplication
- \brief The QApplication class manages the GUI application's control
- flow and main settings.
-
- \ingroup application
- \mainclass
-
- It contains the main event loop, where all events from the window
- system and other sources are processed and dispatched. It also
- handles the application's initialization and finalization, and
- provides session management. It also handles most system-wide and
- application-wide settings.
-
- For any GUI application that uses Qt, there is precisely one
- QApplication object, no matter whether the application has 0, 1, 2
- or more windows at any time. For non-GUI Qt applications, use
- QCoreApplication instead, which doesn't depend on the \l QtGui
- library.
-
- The QApplication object is accessible through the instance()
- function which return a pointer equivalent to the global qApp
- pointer.
-
- QApplication's main areas of responsibility are:
- \list
-
- \o It initializes the application with the user's desktop settings
- such as palette(), font() and doubleClickInterval(). It keeps track
- of these properties in case the user changes the desktop globally, for
- example through some kind of control panel.
-
- \o It performs event handling, meaning that it receives events
- from the underlying window system and dispatches them to the relevant
- widgets. By using sendEvent() and postEvent() you can send your own
- events to widgets.
-
- \o It parses common command line arguments and sets its internal
- state accordingly. See the \link QApplication::QApplication()
- constructor documentation\endlink below for more details about this.
-
- \o It defines the application's look and feel, which is
- encapsulated in a QStyle object. This can be changed at runtime
- with setStyle().
-
- \o It specifies how the application is to allocate colors.
- See setColorSpec() for details.
-
- \o It provides localization of strings that are visible to the user
- via translate().
-
- \o It provides some magical objects like the desktop() and the
- clipboard().
-
- \o It knows about the application's windows. You can ask which
- widget is at a certain position using widgetAt(), get a list of
- topLevelWidgets() and closeAllWindows(), etc.
-
- \o It manages the application's mouse cursor handling,
- see setOverrideCursor()
-
- \o On the X window system, it provides functions to flush and sync
- the communication stream, see flushX() and syncX().
-
- \o It provides support for sophisticated \link
- session.html session management \endlink. This makes it possible
- for applications to terminate gracefully when the user logs out, to
- cancel a shutdown process if termination isn't possible and even to
- preserve the entire application's state for a future session. See
- isSessionRestored(), sessionId() and commitData() and saveState()
- for details.
-
- \endlist
-
- Since the QApplication object does so much initialization, it
- \e{must} be created before any other objects related to the user
- interface are created.
-
- Since it also deals with common command line arguments, it is
- usually a good idea to create it \e before any interpretation or
- modification of \c argv is done in the application itself.
-
- \table
- \header \o{2,1} Groups of functions
- \row
- \o System settings
- \o
- desktopSettingsAware(),
- setDesktopSettingsAware(),
- cursorFlashTime(),
- setCursorFlashTime(),
- doubleClickInterval(),
- setDoubleClickInterval(),
- setKeyboardInputInterval(),
- wheelScrollLines(),
- setWheelScrollLines(),
- palette(),
- setPalette(),
- font(),
- setFont(),
- fontMetrics().
-
- \row
- \o Event handling
- \o
- exec(),
- processEvents(),
- exit(),
- quit().
- sendEvent(),
- postEvent(),
- sendPostedEvents(),
- removePostedEvents(),
- hasPendingEvents(),
- notify(),
- macEventFilter(),
- qwsEventFilter(),
- x11EventFilter(),
- x11ProcessEvent(),
- winEventFilter().
-
- \row
- \o GUI Styles
- \o
- style(),
- setStyle().
-
- \row
- \o Color usage
- \o
- colorSpec(),
- setColorSpec(),
- qwsSetCustomColors().
-
- \row
- \o Text handling
- \o
- installTranslator(),
- removeTranslator()
- translate().
-
- \row
- \o Widgets
- \o
- allWidgets(),
- topLevelWidgets(),
- desktop(),
- activePopupWidget(),
- activeModalWidget(),
- clipboard(),
- focusWidget(),
- winFocus(),
- activeWindow(),
- widgetAt().
-
- \row
- \o Advanced cursor handling
- \o
- overrideCursor(),
- setOverrideCursor(),
- restoreOverrideCursor().
-
- \row
- \o X Window System synchronization
- \o
- flushX(),
- syncX().
-
- \row
- \o Session management
- \o
- isSessionRestored(),
- sessionId(),
- commitData(),
- saveState().
-
- \row
- \o Miscellaneous
- \o
- closeAllWindows(),
- startingUp(),
- closingDown(),
- type().
- \endtable
+ \class QApplication
+ \brief The QApplication class manages the GUI application's control
+ flow and main settings.
+
+ \ingroup application
+ \mainclass
+
+ QApplication contains the main event loop, where all events from the window
+ system and other sources are processed and dispatched. It also handles the
+ application's initialization and finalization, and provides session
+ management. In addition, it handles most system-wide and application-wide
+ settings.
+
+ For any GUI application using Qt, there is precisely one QApplication
+ object, no matter whether the application has 0, 1, 2 or more windows at
+ any given time. For non-GUI Qt applications, use QCoreApplication instead,
+ as it does not depend on the \l QtGui library.
+
+ The QApplication object is accessible through the instance() function that
+ returns a pointer equivalent to the global qApp pointer.
+
+ QApplication's main areas of responsibility are:
+ \list
+ \o It initializes the application with the user's desktop settings
+ such as palette(), font() and doubleClickInterval(). It keeps
+ track of these properties in case the user changes the desktop
+ globally, for example through some kind of control panel.
+
+ \o It performs event handling, meaning that it receives events
+ from the underlying window system and dispatches them to the
+ relevant widgets. By using sendEvent() and postEvent() you can
+ send your own events to widgets.
+
+ \o It parses common command line arguments and sets its internal
+ state accordingly. See the \l{QApplication::QApplication()}
+ {constructor documentation} below for more details.
+
+ \o It defines the application's look and feel, which is
+ encapsulated in a QStyle object. This can be changed at runtime
+ with setStyle().
+
+ \o It specifies how the application is to allocate colors. See
+ setColorSpec() for details.
+
+ \o It provides localization of strings that are visible to the
+ user via translate().
+
+ \o It provides some magical objects like the desktop() and the
+ clipboard().
+
+ \o It knows about the application's windows. You can ask which
+ widget is at a certain position using widgetAt(), get a list of
+ topLevelWidgets() and closeAllWindows(), etc.
+
+ \o It manages the application's mouse cursor handling, see
+ setOverrideCursor()
+
+ \o On the X window system, it provides functions to flush and sync
+ the communication stream, see flushX() and syncX().
+
+ \o It provides support for sophisticated \l{Session Management}
+ {session management}. This makes it possible for applications
+ to terminate gracefully when the user logs out, to cancel a
+ shutdown process if termination isn't possible and even to
+ preserve the entire application's state for a future session.
+ See isSessionRestored(), sessionId() and commitData() and
+ saveState() for details.
+ \endlist
+
+ The QApplication object does so much initialization. Hence, it \e{must} be
+ created before any other objects related to the user interface are created.
+ Since QApplication also deals with common command line arguments, it is
+ usually a good idea to create it \e before any interpretation or
+ modification of \c argv is done in the application itself.
+
+ \table
+ \header
+ \o{2,1} Groups of functions
+
+ \row
+ \o System settings
+ \o desktopSettingsAware(),
+ setDesktopSettingsAware(),
+ cursorFlashTime(),
+ setCursorFlashTime(),
+ doubleClickInterval(),
+ setDoubleClickInterval(),
+ setKeyboardInputInterval(),
+ wheelScrollLines(),
+ setWheelScrollLines(),
+ palette(),
+ setPalette(),
+ font(),
+ setFont(),
+ fontMetrics().
+
+ \row
+ \o Event handling
+ \o exec(),
+ processEvents(),
+ exit(),
+ quit().
+ sendEvent(),
+ postEvent(),
+ sendPostedEvents(),
+ removePostedEvents(),
+ hasPendingEvents(),
+ notify(),
+ macEventFilter(),
+ qwsEventFilter(),
+ x11EventFilter(),
+ x11ProcessEvent(),
+ winEventFilter().
+
+ \row
+ \o GUI Styles
+ \o style(),
+ setStyle().
+
+ \row
+ \o Color usage
+ \o colorSpec(),
+ setColorSpec(),
+ qwsSetCustomColors().
+
+ \row
+ \o Text handling
+ \o installTranslator(),
+ removeTranslator()
+ translate().
+
+ \row
+ \o Widgets
+ \o allWidgets(),
+ topLevelWidgets(),
+ desktop(),
+ activePopupWidget(),
+ activeModalWidget(),
+ clipboard(),
+ focusWidget(),
+ activeWindow(),
+ widgetAt().
+
+ \row
+ \o Advanced cursor handling
+ \o overrideCursor(),
+ setOverrideCursor(),
+ restoreOverrideCursor().
+
+ \row
+ \o X Window System synchronization
+ \o flushX(),
+ syncX().
+
+ \row
+ \o Session management
+ \o isSessionRestored(),
+ sessionId(),
+ commitData(),
+ saveState().
+
+ \row
+ \o Miscellaneous
+ \o closeAllWindows(),
+ startingUp(),
+ closingDown(),
+ type().
+ \endtable
\sa QCoreApplication, QAbstractEventDispatcher, QEventLoop, QSettings
*/
@@ -385,6 +370,7 @@ QApplicationPrivate::~QApplicationPrivate()
Returns the top-level widget at the given \a point; returns 0 if
there is no such widget.
*/
+
/*!
\fn QWidget *QApplication::topLevelAt(int x, int y)
@@ -396,8 +382,8 @@ QApplicationPrivate::~QApplicationPrivate()
/*
- The qt_init() and qt_cleanup() functions are implemented in the
- qapplication_xyz.cpp file.
+ The qt_init() and qt_cleanup() functions are implemented in the
+ qapplication_xyz.cpp file.
*/
void qt_init(QApplicationPrivate *priv, int type
@@ -592,99 +578,100 @@ void QApplicationPrivate::process_cmdline()
}
/*!
- Initializes the window system and constructs an application object
- with \a argc command line arguments in \a argv.
-
- \warning The data referred to by \a argc and \a argv must stay valid
- for the entire lifetime of the QApplication object. In addition,
- \a argc must be greater than zero and \a argv must contain at least
- one valid character string.
-
- The global \c qApp pointer refers to this application object. Only
- one application object should be created.
-
- This application object must be constructed before any \link
- QPaintDevice paint devices\endlink (including widgets, pixmaps, bitmaps
- etc.).
-
- Note that \a argc and \a argv might be changed. Qt removes command
- line arguments that it recognizes.
-
- Qt debugging options (not available if Qt was compiled without the
- QT_DEBUG flag defined):
- \list
- \o -nograb, tells Qt that it must never grab the mouse or the keyboard.
- \o -dograb (only under X11), running under a debugger can cause
- an implicit -nograb, use -dograb to override.
- \o -sync (only under X11), switches to synchronous mode for
- debugging.
- \endlist
-
- See \link debug.html Debugging Techniques \endlink for a more
- detailed explanation.
-
- All Qt programs automatically support the following command line options:
- \list
- \o -style= \e style, sets the application GUI style. Possible values
- are \c motif, \c windows, and \c platinum. If you compiled Qt
- with additional styles or have additional styles as plugins these
- will be available to the \c -style command line option.
- \o -style \e style, is the same as listed above.
- \o -stylesheet= \e stylesheet, sets the application \l styleSheet. The value
- must be a path to a file that contains the Style Sheet. Note that relative URLs
- in the Style Sheet file are relative to the Style Sheet file's path.
- \o -stylesheet \e stylesheet, is the same as listed above.
- \o -session= \e session, restores the application from an earlier
- \link session.html session \endlink.
- \o -session \e session, is the same as listed above.
- \o -widgetcount, prints debug message at the end about number of widgets left
- undestroyed and maximum number of widgets existed at the same time
- \o -reverse, sets the application's layout direction to Qt::RightToLeft
- \o -graphicssystem, sets the backend to be used for on-screen
- widgets and QPixmaps. Available options are \c{raster} and \c{opengl}.
-
- \endlist
-
- The Windows version of Qt also support one additional command line
- option, if Direct3D support has been compiled into Qt:
- \list
- \o -direct3d will make the Direct3D paint engine the default widget
- paint engine in Qt. \bold {This functionality is experimental.}
- \endlist
-
- The X11 version of Qt also supports some traditional X11
- command line options:
- \list
- \o -display \e display, sets the X display (default is $DISPLAY).
- \o -geometry \e geometry, sets the client geometry of the
- first window that is shown.
- \o -fn or \c -font \e font, defines the application font. The
- font should be specified using an X logical font description.
- \o -bg or \c -background \e color, sets the default background color
- and an application palette (light and dark shades are calculated).
- \o -fg or \c -foreground \e color, sets the default foreground color.
- \o -btn or \c -button \e color, sets the default button color.
- \o -name \e name, sets the application name.
- \o -title \e title, sets the application title.
- \o -visual \c TrueColor, forces the application to use a TrueColor visual
- on an 8-bit display.
- \o -ncols \e count, limits the number of colors allocated in the
- color cube on an 8-bit display, if the application is using the
- QApplication::ManyColor color specification. If \e count is
- 216 then a 6x6x6 color cube is used (i.e. 6 levels of red, 6 of green,
- and 6 of blue); for other values, a cube
- approximately proportional to a 2x3x1 cube is used.
- \o -cmap, causes the application to install a private color map
- on an 8-bit display.
- \o -im, sets the input method server (equivalent to setting the XMODIFIERS
- environment variable)
- \o -inputstyle, defines how the input is inserted into the given widget. E.g.,
- \c onTheSpot makes the input appear directly in the widget, while
- \c overTheSpot makes the input appear in a box floating over the
- widget and is not inserted until the editing is done.
- \endlist
-
- \sa arguments()
+ Initializes the window system and constructs an application object with
+ \a argc command line arguments in \a argv.
+
+ \warning The data referred to by \a argc and \a argv must stay valid for
+ the entire lifetime of the QApplication object. In addition, \a argc must
+ be greater than zero and \a argv must contain at least one valid character
+ string.
+
+ The global \c qApp pointer refers to this application object. Only one
+ application object should be created.
+
+ This application object must be constructed before any \l{QPaintDevice}
+ {paint devices} (including widgets, pixmaps, bitmaps etc.).
+
+ \note \a argc and \a argv might be changed as Qt removes command line
+ arguments that it recognizes.
+
+ Qt debugging options (not available if Qt was compiled without the QT_DEBUG
+ flag defined):
+ \list
+ \o -nograb, tells Qt that it must never grab the mouse or the
+ keyboard.
+ \o -dograb (only under X11), running under a debugger can cause an
+ implicit -nograb, use -dograb to override.
+ \o -sync (only under X11), switches to synchronous mode for
+ debugging.
+ \endlist
+
+ See \l{Debugging Techniques} for a more detailed explanation.
+
+ All Qt programs automatically support the following command line options:
+ \list
+ \o -style= \e style, sets the application GUI style. Possible values
+ are \c motif, \c windows, and \c platinum. If you compiled Qt with
+ additional styles or have additional styles as plugins these will
+ be available to the \c -style command line option.
+ \o -style \e style, is the same as listed above.
+ \o -stylesheet= \e stylesheet, sets the application \l styleSheet. The
+ value must be a path to a file that contains the Style Sheet.
+ \note Relative URLs in the Style Sheet file are relative to the
+ Style Sheet file's path.
+ \o -stylesheet \e stylesheet, is the same as listed above.
+ \o -session= \e session, restores the application from an earlier
+ \l{Session Management}{session}.
+ \o -session \e session, is the same as listed above.
+ \o -widgetcount, prints debug message at the end about number of
+ widgets left undestroyed and maximum number of widgets existed at
+ the same time
+ \o -reverse, sets the application's layout direction to
+ Qt::RightToLeft
+ \o -graphicssystem, sets the backend to be used for on-screen widgets
+ and QPixmaps. Available options are \c{raster} and \c{opengl}.
+ \endlist
+
+ The Windows version of Qt supports an additional command line option, if
+ Direct3D support has been compiled into Qt:
+ \list
+ \o -direct3d will make the Direct3D paint engine the default widget
+ paint engine in Qt. \bold {This functionality is experimental.}
+ \endlist
+
+ The X11 version of Qt supports some traditional X11 command line options:
+ \list
+ \o -display \e display, sets the X display (default is $DISPLAY).
+ \o -geometry \e geometry, sets the client geometry of the first window
+ that is shown.
+ \o -fn or \c -font \e font, defines the application font. The font
+ should be specified using an X logical font description.
+ \o -bg or \c -background \e color, sets the default background color
+ and an application palette (light and dark shades are calculated).
+ \o -fg or \c -foreground \e color, sets the default foreground color.
+ \o -btn or \c -button \e color, sets the default button color.
+ \o -name \e name, sets the application name.
+ \o -title \e title, sets the application title.
+ \o -visual \c TrueColor, forces the application to use a TrueColor
+ visual on an 8-bit display.
+ \o -ncols \e count, limits the number of colors allocated in the color
+ cube on an 8-bit display, if the application is using the
+ QApplication::ManyColor color specification. If \e count is 216
+ then a 6x6x6 color cube is used (i.e. 6 levels of red, 6 of green,
+ and 6 of blue); for other values, a cube approximately proportional
+ to a 2x3x1 cube is used.
+ \o -cmap, causes the application to install a private color map on an
+ 8-bit display.
+ \o -im, sets the input method server (equivalent to setting the
+ XMODIFIERS environment variable)
+ \o -inputstyle, defines how the input is inserted into the given
+ widget, e.g., \c onTheSpot makes the input appear directly in the
+ widget, while \c overTheSpot makes the input appear in a box
+ floating over the widget and is not inserted until the editing is
+ done.
+ \endlist
+
+ \sa arguments()
*/
QApplication::QApplication(int &argc, char **argv)
@@ -697,26 +684,26 @@ QApplication::QApplication(int &argc, char **argv, int _internal)
/*!
- Constructs an application object with \a argc command line arguments
- in \a argv. If \a GUIenabled is true, a GUI application is
- constructed, otherwise a non-GUI (console) application is created.
+ Constructs an application object with \a argc command line arguments in
+ \a argv. If \a GUIenabled is true, a GUI application is constructed,
+ otherwise a non-GUI (console) application is created.
- \warning The data referred to by \a argc and \a argv must stay valid
- for the entire lifetime of the QApplication object. In addition,
- \a argc must be greater than zero and \a argv must contain at least
- one valid character string.
+ \warning The data referred to by \a argc and \a argv must stay valid for
+ the entire lifetime of the QApplication object. In addition, \a argc must
+ be greater than zero and \a argv must contain at least one valid character
+ string.
- Set \a GUIenabled to false for programs without a graphical user
- interface that should be able to run without a window system.
+ Set \a GUIenabled to false for programs without a graphical user interface
+ that should be able to run without a window system.
- On X11, the window system is initialized if \a GUIenabled is true.
- If \a GUIenabled is false, the application does not connect to the
- X server. On Windows and Macintosh, currently the window system is
- always initialized, regardless of the value of GUIenabled. This may
- change in future versions of Qt.
+ On X11, the window system is initialized if \a GUIenabled is true. If
+ \a GUIenabled is false, the application does not connect to the X server.
+ On Windows and Macintosh, currently the window system is always
+ initialized, regardless of the value of GUIenabled. This may change in
+ future versions of Qt.
- The following example shows how to create an application that
- uses a graphical interface when available.
+ The following example shows how to create an application that uses a
+ graphical interface when available.
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 0
*/
@@ -732,17 +719,17 @@ QApplication::QApplication(int &argc, char **argv, bool GUIenabled , int _intern
/*!
- Constructs an application object with \a argc command line arguments
- in \a argv.
+ Constructs an application object with \a argc command line arguments in
+ \a argv.
- \warning The data referred to by \a argc and \a argv must stay valid
- for the entire lifetime of the QApplication object. In addition,
- \a argc must be greater than zero and \a argv must contain at least
- one valid character string.
+ \warning The data referred to by \a argc and \a argv must stay valid for
+ the entire lifetime of the QApplication object. In addition, \a argc must
+ be greater than zero and \a argv must contain at least one valid character
+ string.
- With Qt for Embedded Linux, passing QApplication::GuiServer for \a type
- makes this application the server (equivalent to running with the
- \c -qws option).
+ With Qt for Embedded Linux, passing QApplication::GuiServer for \a type
+ makes this application the server (equivalent to running with the
+ \c -qws option).
*/
QApplication::QApplication(int &argc, char **argv, Type type)
: QCoreApplication(*new QApplicationPrivate(argc, argv, type))
@@ -790,16 +777,16 @@ static int aargc = 1;
static char *aargv[] = { (char*)"unknown", 0 };
/*!
- \fn QApplication::QApplication(Display* display, Qt::HANDLE visual, Qt::HANDLE colormap)
+ \fn QApplication::QApplication(Display* display, Qt::HANDLE visual, Qt::HANDLE colormap)
- Create an application, given an already open display \a display. If \a
- visual and \a colormap are non-zero, the application will use those as
- the default Visual and Colormap contexts.
+ Creates an application, given an already open display \a display. If
+ \a visual and \a colormap are non-zero, the application will use those
+ values as the default Visual and Colormap contexts.
- \warning Qt only supports TrueColor visuals at depths higher than 8
- bits-per-pixel.
+ \warning Qt only supports TrueColor visuals at depths higher than 8
+ bits-per-pixel.
- This is available only on X11.
+ This function is only available on X11.
*/
QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap)
: QCoreApplication(*new QApplicationPrivate(aargc, aargv, GuiClient))
@@ -821,19 +808,18 @@ QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap,
}
/*!
- \fn QApplication::QApplication(Display *display, int &argc, char **argv,
- Qt::HANDLE visual, Qt::HANDLE colormap)
-
- Create an application, given an already open \a display and using \a
- argc command line arguments in \a argv. If \a visual and \a colormap
- are non-zero, the application will use those as the default Visual
- and Colormap contexts.
+ \fn QApplication::QApplication(Display *display, int &argc, char **argv,
+ Qt::HANDLE visual, Qt::HANDLE colormap)
- \warning Qt only supports TrueColor visuals at depths higher than 8
- bits-per-pixel.
+ Creates an application, given an already open \a display and using \a argc
+ command line arguments in \a argv. If \a visual and \a colormap are
+ non-zero, the application will use those values as the default Visual
+ and Colormap contexts.
- This is available only on X11.
+ \warning Qt only supports TrueColor visuals at depths higher than 8
+ bits-per-pixel.
+ This function is only available on X11.
*/
QApplication::QApplication(Display *dpy, int &argc, char **argv,
Qt::HANDLE visual, Qt::HANDLE colormap)
@@ -858,12 +844,13 @@ QApplication::QApplication(Display *dpy, int &argc, char **argv,
#endif // Q_WS_X11
+extern void qInitDrawhelperAsm();
/*!
+ \fn void QApplicationPrivate::initialize()
+
Initializes the QApplication object, called from the constructors.
*/
-extern void qInitDrawhelperAsm();
-
void QApplicationPrivate::initialize()
{
QWidgetPrivate::mapper = new QWidgetMapper;
@@ -935,19 +922,18 @@ QApplication::Type QApplication::type()
*****************************************************************************/
/*!
- Returns the active popup widget.
+ Returns the active popup widget.
- A popup widget is a special top-level widget that sets the \c
- Qt::WType_Popup widget flag, e.g. the QMenu widget. When the
- application opens a popup widget, all events are sent to the popup.
- Normal widgets and modal widgets cannot be accessed before the popup
- widget is closed.
+ A popup widget is a special top-level widget that sets the \c
+ Qt::WType_Popup widget flag, e.g. the QMenu widget. When the application
+ opens a popup widget, all events are sent to the popup. Normal widgets and
+ modal widgets cannot be accessed before the popup widget is closed.
- Only other popup widgets may be opened when a popup widget is shown.
- The popup widgets are organized in a stack. This function returns
- the active popup widget at the top of the stack.
+ Only other popup widgets may be opened when a popup widget is shown. The
+ popup widgets are organized in a stack. This function returns the active
+ popup widget at the top of the stack.
- \sa activeModalWidget(), topLevelWidgets()
+ \sa activeModalWidget(), topLevelWidgets()
*/
QWidget *QApplication::activePopupWidget()
@@ -958,17 +944,17 @@ QWidget *QApplication::activePopupWidget()
/*!
- Returns the active modal widget.
+ Returns the active modal widget.
- A modal widget is a special top-level widget which is a subclass of
- QDialog that specifies the modal parameter of the constructor as
- true. A modal widget must be closed before the user can continue
- with other parts of the program.
+ A modal widget is a special top-level widget which is a subclass of QDialog
+ that specifies the modal parameter of the constructor as true. A modal
+ widget must be closed before the user can continue with other parts of the
+ program.
- Modal widgets are organized in a stack. This function returns
- the active modal widget at the top of the stack.
+ Modal widgets are organized in a stack. This function returns the active
+ modal widget at the top of the stack.
- \sa activePopupWidget(), topLevelWidgets()
+ \sa activePopupWidget(), topLevelWidgets()
*/
QWidget *QApplication::activeModalWidget()
@@ -977,8 +963,8 @@ QWidget *QApplication::activeModalWidget()
}
/*!
- Cleans up any window system resources that were allocated by this
- application. Sets the global variable \c qApp to 0.
+ Cleans up any window system resources that were allocated by this
+ application. Sets the global variable \c qApp to 0.
*/
QApplication::~QApplication()
@@ -1104,8 +1090,8 @@ QApplication::~QApplication()
/*!
\fn QWidget *QApplication::widgetAt(const QPoint &point)
- Returns the widget at global screen position \a point, or 0 if there
- is no Qt widget there.
+ Returns the widget at global screen position \a point, or 0 if there is no
+ Qt widget there.
This function can be slow.
@@ -1153,8 +1139,8 @@ QWidget *QApplication::widgetAt(const QPoint &p)
\overload
- Returns the widget at global screen position (\a x, \a y), or 0
- if there is no Qt widget there.
+ Returns the widget at global screen position (\a x, \a y), or 0 if there is
+ no Qt widget there.
*/
/*!
@@ -1223,16 +1209,17 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis
\since 4.4
\brief defines a threshold for auto maximizing widgets
- The auto maximize threshold is only available
- as part of Qt for Windows CE.
+ The auto maximize threshold is only available as part of Qt for Windows CE.
This property defines a threshold for the size of a window as a percentage
- of the screen size. If the minimum size hint of a window exceeds the threshold,
- calling show() will then cause the window to be maximized automatically.
+ of the screen size. If the minimum size hint of a window exceeds the
+ threshold, calling show() will then cause the window to be maximized
+ automatically.
- Setting the threshold to be 100 or greater means that it will cause it to always
- be maximized. Setting it to be 50 means that the widget is maximized if the vertical
- minimum size hint is at least 50% of the vertical screen size.
+ Setting the threshold to be 100 or greater means that it will cause it to
+ always be maximized. Setting it to be 50 means that the widget is maximized
+ if the vertical minimum size hint is at least 50% of the vertical screen
+ size.
If -1 is specified then this will disable the feature.
@@ -1245,12 +1232,11 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis
\since 4.5
\brief toggles automatic SIP (software input panel) visibility
- The auto SIP property is only available
- as part of Qt for Windows CE.
+ The auto SIP property is only available as part of Qt for Windows CE.
Set this property to true to automatically display the SIP when entering
- widgets that accept keyboard input. This only affects widgets that have the
- attribute WA_InputMethodEnabled set.
+ widgets that accept keyboard input. This property only affects widgets with
+ the WA_InputMethodEnabled attribute set.
*/
#ifdef Q_OS_WINCE
@@ -1302,9 +1288,9 @@ void QApplication::setStyleSheet(const QString& styleSheet)
#endif // QT_NO_STYLE_STYLESHEET
/*!
- Returns the application's style object.
+ Returns the application's style object.
- \sa setStyle(), QStyle
+ \sa setStyle(), QStyle
*/
QStyle *QApplication::style()
{
@@ -1389,22 +1375,21 @@ QStyle *QApplication::style()
}
/*!
- Sets the application's GUI style to \a style. Ownership of the style
- object is transferred to QApplication, so QApplication will delete
- the style object on application exit or when a new style is set and
- the old style is still the parent of the application object.
+ Sets the application's GUI style to \a style. Ownership of the style object
+ is transferred to QApplication, so QApplication will delete the style
+ object on application exit or when a new style is set and the old style is
+ still the parent of the application object.
Example usage:
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 1
- When switching application styles, the color palette is set back to
- the initial colors or the system defaults. This is necessary since
- certain styles have to adapt the color palette to be fully
- style-guide compliant.
+ When switching application styles, the color palette is set back to the
+ initial colors or the system defaults. This is necessary since certain
+ styles have to adapt the color palette to be fully style-guide compliant.
- Note that setting the style before a palette has been set
- (i.e. before creating QApplication) will cause the application to
- use QStyle::standardPalette() for the palette.
+ Setting the style before a palette has been se, i.e., before creating
+ QApplication, will cause the application to use QStyle::standardPalette()
+ for the palette.
\warning Qt style sheets are currently not supported for custom QStyle
subclasses. We plan to address this in some future release.
@@ -1507,20 +1492,20 @@ void QApplication::setStyle(QStyle *style)
}
/*!
- \overload
+ \overload
- Requests a QStyle object for \a style from the QStyleFactory.
+ Requests a QStyle object for \a style from the QStyleFactory.
- The string must be one of the QStyleFactory::keys(), typically one
- of "windows", "motif", "cde", "plastique", "windowsxp", or
- "macintosh". Style names are case insensitive.
+ The string must be one of the QStyleFactory::keys(), typically one of
+ "windows", "motif", "cde", "plastique", "windowsxp", or "macintosh". Style
+ names are case insensitive.
- Returns 0 if an unknown \a style is passed, otherwise the QStyle object
- returned is set as the application's GUI style.
+ Returns 0 if an unknown \a style is passed, otherwise the QStyle object
+ returned is set as the application's GUI style.
- \warning To ensure that the application's style is set correctly, it is
- best to call this function before the QApplication constructor, if
- possible.
+ \warning To ensure that the application's style is set correctly, it is
+ best to call this function before the QApplication constructor, if
+ possible.
*/
QStyle* QApplication::setStyle(const QString& style)
{
@@ -1533,20 +1518,19 @@ QStyle* QApplication::setStyle(const QString& style)
}
/*!
- \since 4.5
+ \since 4.5
- Sets the default graphics backend to \a system, which will be used
- for on-screen widgets and QPixmaps. The available systems are
- \c{"native"}, \c{"raster"} and \c{"opengl"}.
+ Sets the default graphics backend to \a system, which will be used for
+ on-screen widgets and QPixmaps. The available systems are \c{"native"},
+ \c{"raster"} and \c{"opengl"}.
- Note that this function call overrides both the application
- commandline \c{-graphicssystem} switch and the configure
- \c{-graphicssystem} switch.
+ This function call overrides both the application commandline
+ \c{-graphicssystem} switch and the configure \c{-graphicssystem} switch.
- \warning This function must be called before the QApplication
- constructor is called.
+ \warning This function must be called before the QApplication constructor
+ is called.
- The \c{"opengl"} option is currently considered experimental.
+ \note The \c{"opengl"} option is currently experimental.
*/
void QApplication::setGraphicsSystem(const QString &system)
@@ -1555,9 +1539,10 @@ void QApplication::setGraphicsSystem(const QString &system)
}
/*!
- Returns the color specification.
- \sa QApplication::setColorSpec()
- */
+ Returns the color specification.
+
+ \sa QApplication::setColorSpec()
+*/
int QApplication::colorSpec()
{
@@ -1565,54 +1550,54 @@ int QApplication::colorSpec()
}
/*!
- Sets the color specification for the application to \a spec.
-
- The color specification controls how the application allocates colors
- when run on a display with a limited amount of colors, e.g. 8 bit / 256
- color displays.
-
- The color specification must be set before you create the QApplication
- object.
-
- The options are:
- \list
- \o QApplication::NormalColor.
- This is the default color allocation strategy. Use this option if
- your application uses buttons, menus, texts and pixmaps with few
- colors. With this option, the application uses system global
- colors. This works fine for most applications under X11, but on
- Windows machines it may cause dithering of non-standard colors.
- \o QApplication::CustomColor.
- Use this option if your application needs a small number of custom
- colors. On X11, this option is the same as NormalColor. On Windows, Qt
- creates a Windows palette, and allocates colors to it on demand.
- \o QApplication::ManyColor.
- Use this option if your application is very color hungry
- (e.g. it requires thousands of colors).
- Under X11 the effect is:
+ Sets the color specification for the application to \a spec.
+
+ The color specification controls how the application allocates colors when
+ run on a display with a limited amount of colors, e.g. 8 bit / 256 color
+ displays.
+
+ The color specification must be set before you create the QApplication
+ object.
+
+ The options are:
\list
- \o For 256-color displays which have at best a 256 color true
- color visual, the default visual is used, and colors are
- allocated from a color cube. The color cube is the 6x6x6 (216
- color) "Web palette" (the red, green, and blue components
- always have one of the following values: 0x00, 0x33, 0x66,
- 0x99, 0xCC, or 0xFF), but the number of colors can be changed
- by the \e -ncols option. The user can force the application to
- use the true color visual with the \link
- QApplication::QApplication() -visual \endlink option.
- \o For 256-color displays which have a true color visual with more
- than 256 colors, use that visual. Silicon Graphics X servers
- have this feature, for example. They provide an 8 bit visual
- by default but can deliver true color when asked.
+ \o QApplication::NormalColor. This is the default color allocation
+ strategy. Use this option if your application uses buttons, menus,
+ texts and pixmaps with few colors. With this option, the
+ application uses system global colors. This works fine for most
+ applications under X11, but on Windows machines it may cause
+ dithering of non-standard colors.
+ \o QApplication::CustomColor. Use this option if your application
+ needs a small number of custom colors. On X11, this option is the
+ same as NormalColor. On Windows, Qt creates a Windows palette, and
+ allocates colors to it on demand.
+ \o QApplication::ManyColor. Use this option if your application is
+ very color hungry, e.g., it requires thousands of colors. \br
+ Under X11 the effect is:
+ \list
+ \o For 256-color displays which have at best a 256 color true
+ color visual, the default visual is used, and colors are
+ allocated from a color cube. The color cube is the 6x6x6
+ (216 color) "Web palette" (the red, green, and blue
+ components always have one of the following values: 0x00,
+ 0x33, 0x66, 0x99, 0xCC, or 0xFF), but the number of colors
+ can be changed by the \e -ncols option. The user can force
+ the application to use the true color visual with the
+ \l{QApplication::QApplication()}{-visual} option.
+ \o For 256-color displays which have a true color visual with
+ more than 256 colors, use that visual. Silicon Graphics X
+ servers this feature, for example. They provide an 8 bit
+ visual by default but can deliver true color when asked.
+ \endlist
+ On Windows, Qt creates a Windows palette, and fills it with a color
+ cube.
\endlist
- On Windows, Qt creates a Windows palette, and fills it with a color cube.
- \endlist
- Be aware that the CustomColor and ManyColor choices may lead to colormap
- flashing: The foreground application gets (most) of the available
- colors, while the background windows will look less attractive.
+ Be aware that the CustomColor and ManyColor choices may lead to colormap
+ flashing: The foreground application gets (most) of the available colors,
+ while the background windows will look less attractive.
- Example:
+ Example:
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 2
@@ -1632,10 +1617,9 @@ void QApplication::setColorSpec(int spec)
\brief the minimum size that any GUI element that the user can interact
with should have
- For example, no button should be resized to be smaller than the
- global strut size. The strut size should be considered when
- reimplementing GUI controls that may be used on touch-screens or
- similar I/O devices.
+ For example, no button should be resized to be smaller than the global
+ strut size. The strut size should be considered when reimplementing GUI
+ controls that may be used on touch-screens or similar I/O devices.
Example:
@@ -1669,12 +1653,11 @@ QPalette QApplication::palette()
\fn QPalette QApplication::palette(const QWidget* widget)
\overload
- If a \a widget is passed, the default palette for the
- widget's class is returned. This may or may not be the application
- palette. In most cases there isn't a special palette for certain
- types of widgets, but one notable exception is the popup menu
- under Windows, if the user has defined a special background color
- for menus in the display settings.
+ If a \a widget is passed, the default palette for the widget's class is
+ returned. This may or may not be the application palette. In most cases
+ there is no special palette for certain types of widgets, but one notable
+ exception is the popup menu under Windows, if the user has defined a
+ special background color for menus in the display settings.
\sa setPalette(), QWidget::palette()
*/
@@ -1768,26 +1751,26 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char*
}
/*!
- Changes the default application palette to \a palette.
+ Changes the default application palette to \a palette.
- If \a className is passed, the change applies only to widgets that
- inherit \a className (as reported by QObject::inherits()). If
- \a className is left 0, the change affects all widgets, thus overriding
- any previously set class specific palettes.
+ If \a className is passed, the change applies only to widgets that inherit
+ \a className (as reported by QObject::inherits()). If \a className is left
+ 0, the change affects all widgets, thus overriding any previously set class
+ specific palettes.
- The palette may be changed according to the current GUI style in
- QStyle::polish().
+ The palette may be changed according to the current GUI style in
+ QStyle::polish().
- \warning Do not use this function in conjunction with \l{Qt Style Sheets}.
- When using style sheets, the palette of a widget can be customized using the "color",
- "background-color", "selection-color", "selection-background-color" and
- "alternate-background-color".
+ \warning Do not use this function in conjunction with \l{Qt Style Sheets}.
+ When using style sheets, the palette of a widget can be customized using
+ the "color", "background-color", "selection-color",
+ "selection-background-color" and "alternate-background-color".
- Note that 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 Mac OS X styles.
+ \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 Mac OS X styles.
- \sa QWidget::setPalette(), palette(), QStyle::polish()
+ \sa QWidget::setPalette(), palette(), QStyle::polish()
*/
void QApplication::setPalette(const QPalette &palette, const char* className)
@@ -1892,15 +1875,15 @@ QFont QApplication::font(const char *className)
/*!
- Changes the default application font to \a font. If \a className
- is passed, the change applies only to classes that inherit \a
- className (as reported by QObject::inherits()).
+ Changes the default application font to \a font. If \a className is passed,
+ the change applies only to classes that inherit \a className (as reported
+ by QObject::inherits()).
- On application start-up, the default font depends on the window
- system. It can vary depending on both the window system version and
- the locale. This function lets you override the default font; but
- overriding may be a bad idea because, for example, some locales need
- extra large fonts to support their special characters.
+ On application start-up, the default font depends on the window system. It
+ can vary depending on both the window system version and the locale. This
+ function lets you override the default font; but overriding may be a bad
+ idea because, for example, some locales need extra large fonts to support
+ their special characters.
\warning Do not use this function in conjunction with \l{Qt Style Sheets}.
The font of an application can be customized using the "font" style sheet
@@ -2002,11 +1985,10 @@ void QApplication::setWindowIcon(const QIcon &icon)
}
/*!
- Returns a list of the top-level widgets (windows) in the
- application.
+ Returns a list of the top-level widgets (windows) in the application.
- Note that some of the top-level widgets may be hidden, for
- example a tooltip if no tooltip is currently shown.
+ \note Some of the top-level widgets may be hidden, for example a tooltip if
+ no tooltip is currently shown.
Example:
@@ -2032,7 +2014,7 @@ QWidgetList QApplication::topLevelWidgets()
The list is empty (QList::isEmpty()) if there are no widgets.
- Note that some of the widgets may be hidden.
+ \note Some of the widgets may be hidden.
Example:
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 5
@@ -2051,10 +2033,10 @@ QWidgetList QApplication::allWidgets()
}
/*!
- Returns the application widget that has the keyboard input focus, or
- 0 if no widget in this application has the focus.
+ Returns the application widget that has the keyboard input focus, or 0 if
+ no widget in this application has the focus.
- \sa QWidget::setFocus(), QWidget::hasFocus(), activeWindow(), focusChanged()
+ \sa QWidget::setFocus(), QWidget::hasFocus(), activeWindow(), focusChanged()
*/
QWidget *QApplication::focusWidget()
@@ -2088,9 +2070,13 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason)
QWidget *prev = focus_widget;
focus_widget = focus;
- if (prev && reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason &&
- prev->testAttribute(Qt::WA_InputMethodEnabled)) {
- QInputContext *qic = prev->inputContext();
+ if (prev && ((reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason
+ && prev->testAttribute(Qt::WA_InputMethodEnabled))
+ // Do reset the input context, in case the new focus widget won't accept keyboard input
+ // or it is not created fully yet.
+ || (focus_widget && (!focus_widget->testAttribute(Qt::WA_InputMethodEnabled)
+ || !focus_widget->testAttribute(Qt::WA_WState_Created))))) {
+ QInputContext *qic = prev->inputContext();
if(qic) {
qic->reset();
qic->setFocusWidget(0);
@@ -2128,19 +2114,19 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason)
if (that)
QApplication::sendEvent(that->style(), &in);
}
+ emit qApp->focusChanged(prev, focus_widget);
}
- emit qApp->focusChanged(prev, focus_widget);
}
}
/*!
- Returns the application top-level window that has the keyboard input
- focus, or 0 if no application window has the focus. Note that
- there might be an activeWindow() even if there is no focusWidget(),
- for example if no widget in that window accepts key events.
+ Returns the application top-level window that has the keyboard input focus,
+ or 0 if no application window has the focus. There might be an
+ activeWindow() even if there is no focusWidget(), for example if no widget
+ in that window accepts key events.
- \sa QWidget::setFocus(), QWidget::hasFocus(), focusWidget()
+ \sa QWidget::setFocus(), QWidget::hasFocus(), focusWidget()
*/
QWidget *QApplication::activeWindow()
@@ -2149,9 +2135,9 @@ QWidget *QApplication::activeWindow()
}
/*!
- Returns display (screen) font metrics for the application font.
+ Returns display (screen) font metrics for the application font.
- \sa font(), setFont(), QWidget::fontMetrics(), QPainter::fontMetrics()
+ \sa font(), setFont(), QWidget::fontMetrics(), QPainter::fontMetrics()
*/
QFontMetrics QApplication::fontMetrics()
@@ -2163,19 +2149,20 @@ QFontMetrics QApplication::fontMetrics()
/*!
Closes all top-level windows.
- This function is particularly useful for applications with many
- top-level windows. It could, for example, be connected to a
- \gui{Exit} entry in the \gui{File} menu:
+ This function is particularly useful for applications with many top-level
+ windows. It could, for example, be connected to a \gui{Exit} entry in the
+ \gui{File} menu:
\snippet examples/mainwindows/mdi/mainwindow.cpp 0
- The windows are closed in random order, until one window does not
- accept the close event. The application quits when the last window
- was successfully closed; this can be turned off by setting \l
- quitOnLastWindowClosed to false.
+ The windows are closed in random order, until one window does not accept
+ the close event. The application quits when the last window was
+ successfully closed; this can be turned off by setting
+ \l quitOnLastWindowClosed to false.
- \sa quitOnLastWindowClosed, lastWindowClosed() QWidget::close(), QWidget::closeEvent(), lastWindowClosed(),
- quit(), topLevelWidgets(), QWidget::isWindow()
+ \sa quitOnLastWindowClosed, lastWindowClosed(), QWidget::close(),
+ QWidget::closeEvent(), lastWindowClosed(), quit(), topLevelWidgets(),
+ QWidget::isWindow()
*/
void QApplication::closeAllWindows()
{
@@ -2198,11 +2185,11 @@ void QApplication::closeAllWindows()
}
/*!
- Displays a simple message box about Qt. The message includes the
- version number of Qt being used by the application.
+ Displays a simple message box about Qt. The message includes the version
+ number of Qt being used by the application.
- This is useful for inclusion in the \gui Help menu of an application,
- as shown in the \l{mainwindows/menus}{Menus} example.
+ This is useful for inclusion in the \gui Help menu of an application, as
+ shown in the \l{mainwindows/menus}{Menus} example.
This function is a convenience slot for QMessageBox::aboutQt().
*/
@@ -2223,22 +2210,20 @@ void QApplication::aboutQt()
/*!
\fn void QApplication::lastWindowClosed()
- This signal is emitted from QApplication::exec() when the last
- visible primary window (i.e. window with no parent) with the
- Qt::WA_QuitOnClose attribute set is closed.
+ This signal is emitted from QApplication::exec() when the last visible
+ primary window (i.e. window with no parent) with the Qt::WA_QuitOnClose
+ attribute set is closed.
By default,
\list
+ \o this attribute is set for all widgets except transient windows such
+ as splash screens, tool windows, and popup menus
- \i this attribute is set for all widgets except transient windows
- such as splash screens, tool windows, and popup menus
-
- \i QApplication implicitly quits when this signal is emitted.
-
+ \o QApplication implicitly quits when this signal is emitted.
\endlist
- This feature be turned off by setting \l quitOnLastWindowClosed to
+ This feature can be turned off by setting \l quitOnLastWindowClosed to
false.
\sa QWidget::close()
@@ -2248,15 +2233,15 @@ void QApplication::aboutQt()
\since 4.1
\fn void QApplication::focusChanged(QWidget *old, QWidget *now)
- This signal is emitted when the widget that has keyboard focus
- changed from \a old to \a now, i.e. because the user pressed the
- tab-key, clicked into a widget or changed the active window. Note
- that both \a old and \a now can be the null-pointer.
+ This signal is emitted when the widget that has keyboard focus changed from
+ \a old to \a now, i.e., because the user pressed the tab-key, clicked into
+ a widget or changed the active window. Both \a old and \a now can be the
+ null-pointer.
- The signal is emitted after both widget have been notified about
- the change through QFocusEvent.
+ The signal is emitted after both widget have been notified about the change
+ through QFocusEvent.
- \sa QWidget::setFocus() QWidget::clearFocus() Qt::FocusReason
+ \sa QWidget::setFocus(), QWidget::clearFocus(), Qt::FocusReason
*/
/*!
@@ -2265,10 +2250,10 @@ void QApplication::aboutQt()
This signal is emitted when application fonts are loaded or removed.
- \sa QFontDatabase::addApplicationFont()
- \sa QFontDatabase::addApplicationFontFromData()
- \sa QFontDatabase::removeAllApplicationFonts()
- \sa QFontDatabase::removeApplicationFont()
+ \sa QFontDatabase::addApplicationFont(),
+ QFontDatabase::addApplicationFontFromData(),
+ QFontDatabase::removeAllApplicationFonts(),
+ QFontDatabase::removeApplicationFont()
*/
#ifndef QT_NO_TRANSLATION
@@ -2365,18 +2350,17 @@ void QApplication::syncX() {} // do nothing
\fn void QApplication::setActiveWindow(QWidget* active)
Sets the active window to the \a active widget in response to a system
- event. The function is called from the platform specific event
- handlers.
+ event. The function is called from the platform specific event handlers.
- \warning This function does \e not set the keyboard focus to the
- active widget. Call QWidget::activateWindow() instead.
+ \warning This function does \e not set the keyboard focus to the active
+ widget. Call QWidget::activateWindow() instead.
- It sets the activeWindow() and focusWidget() attributes and sends
- proper \l{QEvent::WindowActivate}{WindowActivate}/\l{QEvent::WindowDeactivate}{WindowDeactivate}
- and \l{QEvent::FocusIn}{FocusIn}/\l{QEvent::FocusOut}{FocusOut} events
- to all appropriate widgets. The window will then be painted in
- active state (e.g. cursors in line edits will blink), and it will
- have tool tips enabled.
+ It sets the activeWindow() and focusWidget() attributes and sends proper
+ \l{QEvent::WindowActivate}{WindowActivate}/\l{QEvent::WindowDeactivate}
+ {WindowDeactivate} and \l{QEvent::FocusIn}{FocusIn}/\l{QEvent::FocusOut}
+ {FocusOut} events to all appropriate widgets. The window will then be
+ painted in active state (e.g. cursors in line edits will blink), and it
+ will have tool tips enabled.
\sa activeWindow(), QWidget::activateWindow()
*/
@@ -2475,7 +2459,9 @@ void QApplication::setActiveWindow(QWidget* act)
} else {
// If the focus widget is not in the activate_window, clear the focus
w = QApplicationPrivate::focus_widget;
- if (w && !QApplicationPrivate::active_window->isAncestorOf(w))
+ if (!w && QApplicationPrivate::active_window->focusPolicy() != Qt::NoFocus)
+ QApplicationPrivate::setFocusWidget(QApplicationPrivate::active_window, Qt::ActiveWindowFocusReason);
+ else if (!QApplicationPrivate::active_window->isAncestorOf(w))
QApplicationPrivate::setFocusWidget(0, Qt::ActiveWindowFocusReason);
}
}
@@ -2520,11 +2506,11 @@ QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool
}
/*!
- \fn void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave)
- \internal
+ \fn void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave)
+ \internal
- Creates the proper Enter/Leave event when widget \a enter is entered
- and widget \a leave is left.
+ Creates the proper Enter/Leave event when widget \a enter is entered and
+ widget \a leave is left.
*/
#if defined(Q_WS_WIN)
extern void qt_win_set_cursor(QWidget *, bool);
@@ -3041,11 +3027,11 @@ void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget)
/*!
Returns the desktop widget (also called the root window).
- Note that the desktop may be composed of multiple screens, so it would be
- incorrect, for example, to attempt to \e center some widget in the
- desktop's geometry. QDesktopWidget has various functions for obtaining
- useful geometries upon the desktop, such as QDesktopWidget::screenGeometry()
- and QDesktopWidget::availableGeometry().
+ The desktop may be composed of multiple screens, so it would be incorrect,
+ for example, to attempt to \e center some widget in the desktop's geometry.
+ QDesktopWidget has various functions for obtaining useful geometries upon
+ the desktop, such as QDesktopWidget::screenGeometry() and
+ QDesktopWidget::availableGeometry().
On X11, it is also possible to draw on the desktop.
*/
@@ -3060,10 +3046,10 @@ QDesktopWidget *QApplication::desktop()
#ifndef QT_NO_CLIPBOARD
/*!
- Returns a pointer to the application global clipboard.
+ Returns a pointer to the application global clipboard.
- \note The QApplication object should already be constructed before
- accessing the clipboard.
+ \note The QApplication object should already be constructed before
+ accessing the clipboard.
*/
QClipboard *QApplication::clipboard()
{
@@ -3079,11 +3065,11 @@ QClipboard *QApplication::clipboard()
#endif // QT_NO_CLIPBOARD
/*!
- Sets whether Qt should use the system's standard colors, fonts,
- etc., to \a on. By default, this is true.
+ Sets whether Qt should use the system's standard colors, fonts, etc., to
+ \a on. By default, this is true.
- This function must be called before creating the QApplication
- object, like this:
+ This function must be called before creating the QApplication object, like
+ this:
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 6
@@ -3095,8 +3081,8 @@ void QApplication::setDesktopSettingsAware(bool on)
}
/*!
- Returns true if Qt is set to use the system's standard colors,
- fonts, etc.; otherwise returns false. The default is true.
+ Returns true if Qt is set to use the system's standard colors, fonts, etc.;
+ otherwise returns false. The default is true.
\sa setDesktopSettingsAware()
*/
@@ -3106,17 +3092,17 @@ bool QApplication::desktopSettingsAware()
}
/*!
- Returns the current state of the modifier keys on the keyboard. The
- current state is updated sychronously as the event queue is emptied
- of events that will spontaneously change the keyboard state
- (QEvent::KeyPress and QEvent::KeyRelease events).
+ Returns the current state of the modifier keys on the keyboard. The current
+ state is updated sychronously as the event queue is emptied of events that
+ will spontaneously change the keyboard state (QEvent::KeyPress and
+ QEvent::KeyRelease events).
- It should be noted this may not reflect the actual keys held on the
- input device at the time of calling but rather the modifiers as
- last reported in one of the above events. If no keys are being held
- Qt::NoModifier is returned.
+ It should be noted this may not reflect the actual keys held on the input
+ device at the time of calling but rather the modifiers as last reported in
+ one of the above events. If no keys are being held Qt::NoModifier is
+ returned.
- \sa mouseButtons()
+ \sa mouseButtons()
*/
Qt::KeyboardModifiers QApplication::keyboardModifiers()
@@ -3125,17 +3111,17 @@ Qt::KeyboardModifiers QApplication::keyboardModifiers()
}
/*!
- Returns the current state of the buttons on the mouse. The current
- state is updated syncronously as the event queue is emptied of
- events that will spontaneously change the mouse state
- (QEvent::MouseButtonPress and QEvent::MouseButtonRelease events).
+ Returns the current state of the buttons on the mouse. The current state is
+ updated syncronously as the event queue is emptied of events that will
+ spontaneously change the mouse state (QEvent::MouseButtonPress and
+ QEvent::MouseButtonRelease events).
- It should be noted this may not reflect the actual buttons held on
- theinput device at the time of calling but rather the mouse buttons
- as last reported in one of the above events. If no mouse buttons are
- being held Qt::NoButton is returned.
+ It should be noted this may not reflect the actual buttons held on the
+ input device at the time of calling but rather the mouse buttons as last
+ reported in one of the above events. If no mouse buttons are being held
+ Qt::NoButton is returned.
- \sa keyboardModifiers()
+ \sa keyboardModifiers()
*/
Qt::MouseButtons QApplication::mouseButtons()
@@ -3144,43 +3130,40 @@ Qt::MouseButtons QApplication::mouseButtons()
}
/*!
- \fn bool QApplication::isSessionRestored() const
+ \fn bool QApplication::isSessionRestored() const
- Returns true if the application has been restored from an earlier
- \link session.html session\endlink; otherwise returns false.
+ Returns true if the application has been restored from an earlier
+ \l{Session Management}{session}; otherwise returns false.
- \sa sessionId(), commitData(), saveState()
+ \sa sessionId(), commitData(), saveState()
*/
/*!
- \fn QString QApplication::sessionId() const
+ \fn QString QApplication::sessionId() const
- Returns the current \link session.html session's\endlink identifier.
+ Returns the current \l{Session Management}{session's} identifier.
- If the application has been restored from an earlier session, this
- identifier is the same as it was in that previous session.
+ If the application has been restored from an earlier session, this
+ identifier is the same as it was in that previous session. The session
+ identifier is guaranteed to be unique both for different applications
+ and for different instances of the same application.
- The session identifier is guaranteed to be unique both for different
- applications and for different instances of the same application.
-
- \sa isSessionRestored(), sessionKey(), commitData(), saveState()
- */
+ \sa isSessionRestored(), sessionKey(), commitData(), saveState()
+*/
/*!
- \fn QString QApplication::sessionKey() const
+ \fn QString QApplication::sessionKey() const
- Returns the session key in the current \link session.html
- session\endlink.
+ Returns the session key in the current \l{Session Management}{session}.
- If the application has been restored from an earlier session, this
- key is the same as it was when the previous session ended.
+ If the application has been restored from an earlier session, this key is
+ the same as it was when the previous session ended.
- The session key changes with every call of commitData() or
- saveState().
+ The session key changes with every call of commitData() or saveState().
- \sa isSessionRestored(), sessionId(), commitData(), saveState()
- */
+ \sa isSessionRestored(), sessionId(), commitData(), saveState()
+*/
#ifndef QT_NO_SESSIONMANAGER
bool QApplication::isSessionRestored() const
{
@@ -3203,59 +3186,57 @@ QString QApplication::sessionKey() const
-
-
/*!
- \since 4.2
- \fn void QApplication::commitDataRequest(QSessionManager &manager)
+ \since 4.2
+ \fn void QApplication::commitDataRequest(QSessionManager &manager)
- This signal deals with \link session.html session
- management\endlink. It is emitted when the QSessionManager wants the
- application to commit all its data.
+ This signal deals with \l{Session Management}{session management}. It is
+ emitted when the QSessionManager wants the application to commit all its
+ data.
- Usually this means saving all open files, after getting
- permission from the user. Furthermore you may want to provide a means
- by which the user can cancel the shutdown.
+ Usually this means saving all open files, after getting permission from
+ the user. Furthermore you may want to provide a means by which the user
+ can cancel the shutdown.
- Note that you should not exit the application when called.
- Instead, the session manager may or may not do this afterwards,
- depending on the context.
+ You should not exit the application within this signal. Instead,
+ the session manager may or may not do this afterwards, depending on the
+ context.
- \warning Within this signal, no user interaction is possible, \e
- unless you ask the \a manager for explicit permission. See
- QSessionManager::allowsInteraction() and
- QSessionManager::allowsErrorInteraction() for details and example
- usage.
+ \warning Within this signal, no user interaction is possible, \e
+ unless you ask the \a manager for explicit permission. See
+ QSessionManager::allowsInteraction() and
+ QSessionManager::allowsErrorInteraction() for details and example
+ usage.
- Note: You should use Qt::DirectConnection when connecting to this signal.
+ \note You should use Qt::DirectConnection when connecting to this signal.
- \sa isSessionRestored(), sessionId(), saveState(), {Session Management}
+ \sa isSessionRestored(), sessionId(), saveState(), {Session Management}
*/
/*!
- This function deals with \link session.html session
- management\endlink. It is invoked when the QSessionManager wants the
- application to commit all its data.
+ This function deals with \l{Session Management}{session management}. It is
+ invoked when the QSessionManager wants the application to commit all its
+ data.
- Usually this means saving all open files, after getting
- permission from the user. Furthermore you may want to provide a means
- by which the user can cancel the shutdown.
+ Usually this means saving all open files, after getting permission from the
+ user. Furthermore you may want to provide a means by which the user can
+ cancel the shutdown.
- Note that you should not exit the application within this function.
- Instead, the session manager may or may not do this afterwards,
- depending on the context.
+ You should not exit the application within this function. Instead, the
+ session manager may or may not do this afterwards, depending on the
+ context.
- \warning Within this function, no user interaction is possible, \e
- unless you ask the \a manager for explicit permission. See
- QSessionManager::allowsInteraction() and
- QSessionManager::allowsErrorInteraction() for details and example
- usage.
+ \warning Within this function, no user interaction is possible, \e
+ unless you ask the \a manager for explicit permission. See
+ QSessionManager::allowsInteraction() and
+ QSessionManager::allowsErrorInteraction() for details and example
+ usage.
- The default implementation requests interaction and sends a close
- event to all visible top-level widgets. If any event was
- rejected, the shutdown is canceled.
+ The default implementation requests interaction and sends a close event to
+ all visible top-level widgets. If any event was rejected, the shutdown is
+ canceled.
- \sa isSessionRestored(), sessionId(), saveState(), {Session Management}
+ \sa isSessionRestored(), sessionId(), saveState(), {Session Management}
*/
#ifndef QT_NO_SESSIONMANAGER
void QApplication::commitData(QSessionManager& manager )
@@ -3281,58 +3262,54 @@ void QApplication::commitData(QSessionManager& manager )
}
/*!
- \since 4.2
- \fn void QApplication::saveStateRequest(QSessionManager &manager)
+ \since 4.2
+ \fn void QApplication::saveStateRequest(QSessionManager &manager)
- This signal deals with \link session.html session
- management\endlink. It is invoked when the
- \link QSessionManager session manager \endlink wants the application
- to preserve its state for a future session.
+ This signal deals with \l{Session Management}{session management}. It is
+ invoked when the \l{QSessionManager}{session manager} wants the application
+ to preserve its state for a future session.
- For example, a text editor would create a temporary file that
- includes the current contents of its edit buffers, the location of
- the cursor and other aspects of the current editing session.
+ For example, a text editor would create a temporary file that includes the
+ current contents of its edit buffers, the location of the cursor and other
+ aspects of the current editing session.
- Note that you should never exit the application within this
- signal. Instead, the session manager may or may not do this
- afterwards, depending on the context. Futhermore, most session
- managers will very likely request a saved state immediately after
- the application has been started. This permits the session manager
- to learn about the application's restart policy.
+ You should never exit the application within this signal. Instead, the
+ session manager may or may not do this afterwards, depending on the
+ context. Futhermore, most session managers will very likely request a saved
+ state immediately after the application has been started. This permits the
+ session manager to learn about the application's restart policy.
- \warning Within this function, no user interaction is possible, \e
- unless you ask the \a manager for explicit permission. See
- QSessionManager::allowsInteraction() and
- QSessionManager::allowsErrorInteraction() for details.
+ \warning Within this function, no user interaction is possible, \e
+ unless you ask the \a manager for explicit permission. See
+ QSessionManager::allowsInteraction() and
+ QSessionManager::allowsErrorInteraction() for details.
- Note:: You should use Qt::DirectConnection when connecting to this signal.
+ \note You should use Qt::DirectConnection when connecting to this signal.
- \sa isSessionRestored(), sessionId(), commitData(), {Session Management}
+ \sa isSessionRestored(), sessionId(), commitData(), {Session Management}
*/
/*!
- This function deals with \link session.html session
- management\endlink. It is invoked when the
- \link QSessionManager session manager \endlink wants the application
- to preserve its state for a future session.
+ This function deals with \l{Session Management}{session management}. It is
+ invoked when the \l{QSessionManager}{session manager} wants the application
+ to preserve its state for a future session.
- For example, a text editor would create a temporary file that
- includes the current contents of its edit buffers, the location of
- the cursor and other aspects of the current editing session.
+ For example, a text editor would create a temporary file that includes the
+ current contents of its edit buffers, the location of the cursor and other
+ aspects of the current editing session.
- Note that you should never exit the application within this
- function. Instead, the session manager may or may not do this
- afterwards, depending on the context. Futhermore, most session
- managers will very likely request a saved state immediately after
- the application has been started. This permits the session manager
- to learn about the application's restart policy.
+ You should never exit the application within this function. Instead, the
+ session manager may or may not do this afterwards, depending on the
+ context. Futhermore, most session managers will very likely request a saved
+ state immediately after the application has been started. This permits the
+ session manager to learn about the application's restart policy.
- \warning Within this function, no user interaction is possible, \e
- unless you ask the \a manager for explicit permission. See
- QSessionManager::allowsInteraction() and
- QSessionManager::allowsErrorInteraction() for details.
+ \warning Within this function, no user interaction is possible, \e
+ unless you ask the \a manager for explicit permission. See
+ QSessionManager::allowsInteraction() and
+ QSessionManager::allowsErrorInteraction() for details.
- \sa isSessionRestored(), sessionId(), commitData(), {Session Management}
+ \sa isSessionRestored(), sessionId(), commitData(), {Session Management}
*/
void QApplication::saveState(QSessionManager &manager)
@@ -3356,13 +3333,12 @@ void QApplication::setStartDragTime(int ms)
\brief the time in milliseconds that a mouse button must be held down
before a drag and drop operation will begin
- If you support drag and drop in your application, and want to start a
- drag and drop operation after the user has held down a mouse button for
- a certain amount of time, you should use this property's value as the
- delay.
+ If you support drag and drop in your application, and want to start a drag
+ and drop operation after the user has held down a mouse button for a
+ certain amount of time, you should use this property's value as the delay.
- Qt also uses this delay internally, e.g. in QTextEdit and QLineEdit,
- for starting a drag.
+ Qt also uses this delay internally, e.g. in QTextEdit and QLineEdit, for
+ starting a drag.
The default value is 500 ms.
@@ -3375,9 +3351,9 @@ int QApplication::startDragTime()
}
/*
- Sets the distance after which a drag should start to \a l pixels.
+ Sets the distance after which a drag should start to \a l pixels.
- \sa startDragDistance()
+ \sa startDragDistance()
*/
void QApplication::setStartDragDistance(int l)
@@ -3388,15 +3364,14 @@ void QApplication::setStartDragDistance(int l)
/*!
\property QApplication::startDragDistance
- If you support drag and drop in your application, and want to start a
- drag and drop operation after the user has moved the cursor a certain
- distance with a button held down, you should use this property's value
- as the minimum distance required.
+ If you support drag and drop in your application, and want to start a drag
+ and drop operation after the user has moved the cursor a certain distance
+ with a button held down, you should use this property's value as the
+ minimum distance required.
- For example, if the mouse position of the click is stored in \c
- startPos and the current position (e.g. in the mouse move event) is
- \c currentPos, you can find out if a drag should be started with code
- like this:
+ For example, if the mouse position of the click is stored in \c startPos
+ and the current position (e.g. in the mouse move event) is \c currentPos,
+ you can find out if a drag should be started with code like this:
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 7
@@ -3442,14 +3417,14 @@ int QApplication::startDragDistance()
\sa layoutDirection(), isRightToLeft()
*/
-/*! \property QApplication::layoutDirection
-
- \brief the default layout direction for this application
+/*!
+ \property QApplication::layoutDirection
+ \brief the default layout direction for this application
- On system start-up, the default layout direction depends on the
- application's language.
+ On system start-up, the default layout direction depends on the
+ application's language.
- \sa QWidget::layoutDirection, isLeftToRight(), isRightToLeft()
+ \sa QWidget::layoutDirection, isLeftToRight(), isRightToLeft()
*/
void QApplication::setLayoutDirection(Qt::LayoutDirection direction)
@@ -3473,11 +3448,12 @@ Qt::LayoutDirection QApplication::layoutDirection()
}
-/*! \obsolete
+/*!
+ \obsolete
- Strips out vertical alignment flags and transforms an
- alignment \a align of Qt::AlignLeft into Qt::AlignLeft or
- Qt::AlignRight according to the language used.
+ Strips out vertical alignment flags and transforms an alignment \a align
+ of Qt::AlignLeft into Qt::AlignLeft or Qt::AlignRight according to the
+ language used.
*/
#ifdef QT3_SUPPORT
@@ -3493,8 +3469,8 @@ Qt::Alignment QApplication::horizontalAlignment(Qt::Alignment align)
Returns the active application override cursor.
- This function returns 0 if no application cursor has been defined
- (i.e. the internal cursor stack is empty).
+ This function returns 0 if no application cursor has been defined (i.e. the
+ internal cursor stack is empty).
\sa setOverrideCursor(), restoreOverrideCursor()
*/
@@ -3507,9 +3483,10 @@ QCursor *QApplication::overrideCursor()
/*!
Changes the currently active application override cursor to \a cursor.
- This function has no effect if setOverrideCursor() wasn't called.
+ This function has no effect if setOverrideCursor() was not called.
- \sa setOverrideCursor() overrideCursor() restoreOverrideCursor() QWidget::setCursor()
+ \sa setOverrideCursor(), overrideCursor(), restoreOverrideCursor(),
+ QWidget::setCursor()
*/
void QApplication::changeOverrideCursor(const QCursor &cursor)
{
@@ -3523,8 +3500,8 @@ void QApplication::changeOverrideCursor(const QCursor &cursor)
/*!
\fn void QApplication::setOverrideCursor(const QCursor &cursor, bool replace)
- Use changeOverrideCursor(\a cursor) (if \a replace is true)
- or setOverrideCursor(\a cursor) (if \a replace is false).
+ Use changeOverrideCursor(\a cursor) (if \a replace is true) or
+ setOverrideCursor(\a cursor) (if \a replace is false).
*/
/*!
@@ -3532,29 +3509,26 @@ void QApplication::changeOverrideCursor(const QCursor &cursor)
the value that was set to exit() (which is 0 if exit() is called via
quit()).
- It is necessary to call this function to start event handling. The
- main event loop receives events from the window system and
- dispatches these to the application widgets.
-
- Generally speaking, no user interaction can take place before
- calling exec(). As a special case, modal widgets like QMessageBox
- can be used before calling exec(), because modal widgets call
- exec() to start a local event loop.
+ It is necessary to call this function to start event handling. The main
+ event loop receives events from the window system and dispatches these to
+ the application widgets.
+
+ Generally, no user interaction can take place before calling exec(). As a
+ special case, modal widgets like QMessageBox can be used before calling
+ exec(), because modal widgets call exec() to start a local event loop.
- To make your application perform idle processing, i.e. executing a
- special function whenever there are no pending events, use a
- QTimer with 0 timeout. More advanced idle processing schemes can
- be achieved using processEvents().
+ To make your application perform idle processing, i.e., executing a special
+ function whenever there are no pending events, use a QTimer with 0 timeout.
+ More advanced idle processing schemes can be achieved using processEvents().
We recommend that you connect clean-up code to the
- \l{QCoreApplication::}{aboutToQuit()} signal, instead of putting it in
- your application's \c{main()} function because on some platforms the
- QApplication::exec() call may not return. For example, on Windows
- when the user logs off, the system terminates the process after Qt
- closes all top-level windows. Hence, there is no guarantee that the
- application will have time to exit its event loop and execute code at
- the end of the \c{main()} function after the QApplication::exec()
- call.
+ \l{QCoreApplication::}{aboutToQuit()} signal, instead of putting it in your
+ application's \c{main()} function because on some platforms the
+ QApplication::exec() call may not return. For example, on Windows when the
+ user logs off, the system terminates the process after Qt closes all
+ top-level windows. Hence, there is no guarantee that the application will
+ have time to exit its event loop and execute code at the end of the
+ \c{main()} function after the QApplication::exec() call.
\sa quitOnLastWindowClosed, quit(), exit(), processEvents(),
QCoreApplication::exec()
@@ -4109,101 +4083,98 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
/*!
- \class QSessionManager
- \brief The QSessionManager class provides access to the session manager.
-
- \ingroup application
- \ingroup environment
-
- A session manager in a desktop environment (in which Qt GUI
- applications live) keeps track of a session, which is a group of
- running applications, each of which has a particular state. The
- state of an application contains (most notably) the documents the
- application has open and the position and size of its windows.
-
- The session manager is used to save the session, e.g. when the
- machine is shut down, and to restore a session, e.g. when the
- machine is started up. We recommend that you use QSettings to save
- an individual application's settings, e.g. window positions,
- recently used files, etc. When the application is restarted by the
- session manager, you can restore the settings.
-
- QSessionManager provides an interface between the application
- and the session manager so that the program can work well with the
- session manager. In Qt, session management requests for action are
- handled by the two virtual functions QApplication::commitData()
- and QApplication::saveState(). Both provide a reference to a
- session manager object as argument, to allow the application to
- communicate with the session manager. The session manager can only
- be accessed through these functions.
-
- No user interaction is possible \e unless the application gets
- explicit permission from the session manager. You ask for permission
- by calling allowsInteraction() or, if it's really urgent,
- allowsErrorInteraction(). Qt does not enforce this, but the session
- manager may.
-
- You can try to abort the shutdown process by calling cancel(). The
- default commitData() function does this if some top-level window
- rejected its closeEvent().
-
- For sophisticated session managers provided on Unix/X11, QSessionManager
- offers further possibilities to fine-tune an application's session
- management behavior: setRestartCommand(), setDiscardCommand(),
- setRestartHint(), setProperty(), requestPhase2(). See the respective
- function descriptions for further details.
-
- \sa QApplication, {Session Management}
+ \class QSessionManager
+ \brief The QSessionManager class provides access to the session manager.
+
+ \ingroup application
+ \ingroup environment
+
+ A session manager in a desktop environment (in which Qt GUI applications
+ live) keeps track of a session, which is a group of running applications,
+ each of which has a particular state. The state of an application contains
+ (most notably) the documents the application has open and the position and
+ size of its windows.
+
+ The session manager is used to save the session, e.g., when the machine is
+ shut down, and to restore a session, e.g., when the machine is started up.
+ We recommend that you use QSettings to save an application's settings,
+ for example, window positions, recently used files, etc. When the
+ application is restarted by the session manager, you can restore the
+ settings.
+
+ QSessionManager provides an interface between the application and the
+ session manager so that the program can work well with the session manager.
+ In Qt, session management requests for action are handled by the two
+ virtual functions QApplication::commitData() and QApplication::saveState().
+ Both provide a reference to a session manager object as argument, to allow
+ the application to communicate with the session manager. The session
+ manager can only be accessed through these functions.
+
+ No user interaction is possible \e unless the application gets explicit
+ permission from the session manager. You ask for permission by calling
+ allowsInteraction() or, if it is really urgent, allowsErrorInteraction().
+ Qt does not enforce this, but the session manager may.
+
+ You can try to abort the shutdown process by calling cancel(). The default
+ commitData() function does this if some top-level window rejected its
+ closeEvent().
+
+ For sophisticated session managers provided on Unix/X11, QSessionManager
+ offers further possibilities to fine-tune an application's session
+ management behavior: setRestartCommand(), setDiscardCommand(),
+ setRestartHint(), setProperty(), requestPhase2(). See the respective
+ function descriptions for further details.
+
+ \sa QApplication, {Session Management}
*/
/*! \enum QSessionManager::RestartHint
- This enum type defines the circumstances under which this
- application wants to be restarted by the session manager. The
- current values are
+ This enum type defines the circumstances under which this application wants
+ to be restarted by the session manager. The current values are:
- \value RestartIfRunning if the application is still running when
- the session is shut down, it wants to be restarted at the start of
- the next session.
+ \value RestartIfRunning If the application is still running when the
+ session is shut down, it wants to be restarted
+ at the start of the next session.
- \value RestartAnyway the application wants to be started at the
- start of the next session, no matter what. (This is useful for
- utilities that run just after startup and then quit.)
+ \value RestartAnyway The application wants to be started at the
+ start of the next session, no matter what.
+ (This is useful for utilities that run just
+ after startup and then quit.)
- \value RestartImmediately the application wants to be started
- immediately whenever it is not running.
+ \value RestartImmediately The application wants to be started immediately
+ whenever it is not running.
- \value RestartNever the application does not want to be restarted
- automatically.
+ \value RestartNever The application does not want to be restarted
+ automatically.
- The default hint is \c RestartIfRunning.
+ The default hint is \c RestartIfRunning.
*/
/*!
- \fn QString QSessionManager::sessionId() const
+ \fn QString QSessionManager::sessionId() const
- Returns the identifier of the current session.
+ Returns the identifier of the current session.
- If the application has been restored from an earlier session, this
- identifier is the same as it was in that earlier session.
+ If the application has been restored from an earlier session, this
+ identifier is the same as it was in the earlier session.
- \sa sessionKey(), QApplication::sessionId()
- */
+ \sa sessionKey(), QApplication::sessionId()
+*/
/*!
- \fn QString QSessionManager::sessionKey() const
+ \fn QString QSessionManager::sessionKey() const
- Returns the session key in the current session.
+ Returns the session key in the current session.
- If the application has been restored from an earlier session, this
- key is the same as it was when the previous session ended.
+ If the application has been restored from an earlier session, this key is
+ the same as it was when the previous session ended.
- The session key changes with every call of commitData() or
- saveState().
+ The session key changes with every call of commitData() or saveState().
- \sa sessionId(), QApplication::sessionKey()
- */
+ \sa sessionId(), QApplication::sessionKey()
+*/
/*!
\fn void* QSessionManager::handle() const
@@ -4212,120 +4183,116 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
*/
/*!
- \fn bool QSessionManager::allowsInteraction()
+ \fn bool QSessionManager::allowsInteraction()
- Asks the session manager for permission to interact with the
- user. Returns true if interaction is permitted; otherwise
- returns false.
+ Asks the session manager for permission to interact with the user. Returns
+ true if interaction is permitted; otherwise returns false.
- The rationale behind this mechanism is to make it possible to
- synchronize user interaction during a shutdown. Advanced session
- managers may ask all applications simultaneously to commit their
- data, resulting in a much faster shutdown.
+ The rationale behind this mechanism is to make it possible to synchronize
+ user interaction during a shutdown. Advanced session managers may ask all
+ applications simultaneously to commit their data, resulting in a much
+ faster shutdown.
- When the interaction is completed we strongly recommend releasing the
- user interaction semaphore with a call to release(). This way, other
- applications may get the chance to interact with the user while your
- application is still busy saving data. (The semaphore is implicitly
- released when the application exits.)
+ When the interaction is completed we strongly recommend releasing the user
+ interaction semaphore with a call to release(). This way, other
+ applications may get the chance to interact with the user while your
+ application is still busy saving data. (The semaphore is implicitly
+ released when the application exits.)
- If the user decides to cancel the shutdown process during the
- interaction phase, you must tell the session manager that this has
- happened by calling cancel().
+ If the user decides to cancel the shutdown process during the interaction
+ phase, you must tell the session manager that this has happened by calling
+ cancel().
- Here's an example of how an application's QApplication::commitData()
- might be implemented:
+ Here's an example of how an application's QApplication::commitData() might
+ be implemented:
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 8
+ \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 8
- If an error occurred within the application while saving its data,
- you may want to try allowsErrorInteraction() instead.
+ If an error occurred within the application while saving its data, you may
+ want to try allowsErrorInteraction() instead.
- \sa QApplication::commitData(), release(), cancel()
+ \sa QApplication::commitData(), release(), cancel()
*/
/*!
- \fn bool QSessionManager::allowsErrorInteraction()
+ \fn bool QSessionManager::allowsErrorInteraction()
- Returns true if error interaction is permitted; otherwise returns false.
+ Returns true if error interaction is permitted; otherwise returns false.
- This is similar to allowsInteraction(), but also enables the application
- to tell the user about any errors that occur. Session managers
- may give error interaction requests higher priority, which means that it
- is more likely that an error interaction is permitted. However, you are
- still not guaranteed that the session manager will allow interaction.
+ This is similar to allowsInteraction(), but also enables the application to
+ tell the user about any errors that occur. Session managers may give error
+ interaction requests higher priority, which means that it is more likely
+ that an error interaction is permitted. However, you are still not
+ guaranteed that the session manager will allow interaction.
- \sa allowsInteraction(), release(), cancel()
+ \sa allowsInteraction(), release(), cancel()
*/
/*!
- \fn void QSessionManager::release()
+ \fn void QSessionManager::release()
- Releases the session manager's interaction semaphore after an
- interaction phase.
+ Releases the session manager's interaction semaphore after an interaction
+ phase.
- \sa allowsInteraction(), allowsErrorInteraction()
+ \sa allowsInteraction(), allowsErrorInteraction()
*/
/*!
- \fn void QSessionManager::cancel()
-
- Tells the session manager to cancel the shutdown process. Applications
- should not call this function without first asking the user.
+ \fn void QSessionManager::cancel()
- \sa allowsInteraction(), allowsErrorInteraction()
+ Tells the session manager to cancel the shutdown process. Applications
+ should not call this function without asking the user first.
+ \sa allowsInteraction(), allowsErrorInteraction()
*/
/*!
- \fn void QSessionManager::setRestartHint(RestartHint hint)
+ \fn void QSessionManager::setRestartHint(RestartHint hint)
- Sets the application's restart hint to \a hint. On application
- startup the hint is set to \c RestartIfRunning.
+ Sets the application's restart hint to \a hint. On application startup, the
+ hint is set to \c RestartIfRunning.
- Note that these flags are only hints, a session manager may or may
- not respect them.
+ \note These flags are only hints, a session manager may or may not respect
+ them.
- We recommend setting the restart hint in QApplication::saveState()
- because most session managers perform a checkpoint shortly after an
- application's startup.
+ We recommend setting the restart hint in QApplication::saveState() because
+ most session managers perform a checkpoint shortly after an application's
+ startup.
- \sa restartHint()
+ \sa restartHint()
*/
/*!
- \fn QSessionManager::RestartHint QSessionManager::restartHint() const
+ \fn QSessionManager::RestartHint QSessionManager::restartHint() const
- Returns the application's current restart hint. The default is
- \c RestartIfRunning.
+ Returns the application's current restart hint. The default is
+ \c RestartIfRunning.
- \sa setRestartHint()
+ \sa setRestartHint()
*/
/*!
- \fn void QSessionManager::setRestartCommand(const QStringList& command)
+ \fn void QSessionManager::setRestartCommand(const QStringList& command)
- If the session manager is capable of restoring sessions it will
- execute \a command in order to restore the application. The command
- defaults to
+ If the session manager is capable of restoring sessions it will execute
+ \a command in order to restore the application. The command defaults to
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 9
- The \c -session option is mandatory; otherwise QApplication cannot
- tell whether it has been restored or what the current session
- identifier is. See QApplication::isSessionRestored() and
- QApplication::sessionId() for details.
+ The \c -session option is mandatory; otherwise QApplication cannot tell
+ whether it has been restored or what the current session identifier is.
+ See QApplication::isSessionRestored() and QApplication::sessionId() for
+ details.
- If your application is very simple, it may be possible to store the
- entire application state in additional command line options. This
- is usually a very bad idea because command lines are often limited
- to a few hundred bytes. Instead, use QSettings, or temporary files
- or a database for this purpose. By marking the data with the unique
- sessionId(), you will be able to restore the application in a future
- session.
+ If your application is very simple, it may be possible to store the entire
+ application state in additional command line options. This is usually a
+ very bad idea because command lines are often limited to a few hundred
+ bytes. Instead, use QSettings, temporary files, or a database for this
+ purpose. By marking the data with the unique sessionId(), you will be able
+ to restore the application in a future session.
- \sa restartCommand(), setDiscardCommand(), setRestartHint()
+ \sa restartCommand(), setDiscardCommand(), setRestartHint()
*/
/*!
@@ -4333,8 +4300,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
Returns the currently set restart command.
- To iterate over the list, you can use the \l foreach
- pseudo-keyword:
+ To iterate over the list, you can use the \l foreach pseudo-keyword:
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 10
@@ -4342,11 +4308,11 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
*/
/*!
- \fn void QSessionManager::setDiscardCommand(const QStringList& list)
+ \fn void QSessionManager::setDiscardCommand(const QStringList& list)
- Sets the discard command to the given \a list.
+ Sets the discard command to the given \a list.
- \sa discardCommand(), setRestartCommand()
+ \sa discardCommand(), setRestartCommand()
*/
@@ -4355,8 +4321,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
Returns the currently set discard command.
- To iterate over the list, you can use the \l foreach
- pseudo-keyword:
+ To iterate over the list, you can use the \l foreach pseudo-keyword:
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 11
@@ -4364,53 +4329,51 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
*/
/*!
- \fn void QSessionManager::setManagerProperty(const QString &name, const QString &value)
- \overload
+ \fn void QSessionManager::setManagerProperty(const QString &name, const QString &value)
+ \overload
- Low-level write access to the application's identification and state
- records are kept in the session manager.
+ Low-level write access to the application's identification and state
+ records are kept in the session manager.
- The property called \a name has its value set to the string \a value.
+ The property called \a name has its value set to the string \a value.
*/
/*!
- \fn void QSessionManager::setManagerProperty(const QString& name,
- const QStringList& value)
+ \fn void QSessionManager::setManagerProperty(const QString& name,
+ const QStringList& value)
- Low-level write access to the application's identification and state
- record are kept in the session manager.
+ Low-level write access to the application's identification and state record
+ are kept in the session manager.
- The property called \a name has its value set to the string list \a value.
+ The property called \a name has its value set to the string list \a value.
*/
/*!
- \fn bool QSessionManager::isPhase2() const
+ \fn bool QSessionManager::isPhase2() const
- Returns true if the session manager is currently performing a second
- session management phase; otherwise returns false.
+ Returns true if the session manager is currently performing a second
+ session management phase; otherwise returns false.
- \sa requestPhase2()
+ \sa requestPhase2()
*/
/*!
- \fn void QSessionManager::requestPhase2()
+ \fn void QSessionManager::requestPhase2()
- Requests a second session management phase for the application. The
- application may then return immediately from the
- QApplication::commitData() or QApplication::saveState() function,
- and they will be called again once most or all other applications have
- finished their session management.
+ Requests a second session management phase for the application. The
+ application may then return immediately from the QApplication::commitData()
+ or QApplication::saveState() function, and they will be called again once
+ most or all other applications have finished their session management.
- The two phases are useful for applications such as the X11 window manager
- that need to store information about another application's windows
- and therefore have to wait until these applications have completed their
- respective session management tasks.
+ The two phases are useful for applications such as the X11 window manager
+ that need to store information about another application's windows and
+ therefore have to wait until these applications have completed their
+ respective session management tasks.
- Note that if another application has requested a second phase it
- may get called before, simultaneously with, or after your
- application's second phase.
+ \note If another application has requested a second phase it may get called
+ before, simultaneously with, or after your application's second phase.
- \sa isPhase2()
+ \sa isPhase2()
*/
/*****************************************************************************
@@ -4603,15 +4566,14 @@ void QSessionManager::requestPhase2()
/*!
\fn bool QApplication::hasGlobalMouseTracking()
- This feature does not exist anymore. This function
- always returns true in Qt 4.
+ This feature does not exist anymore. This function always returns true
+ in Qt 4.
*/
/*!
\fn void QApplication::setGlobalMouseTracking(bool dummy)
- This function does nothing in Qt 4. The \a dummy parameter
- is ignored.
+ This function does nothing in Qt 4. The \a dummy parameter is ignored.
*/
/*!
@@ -4649,15 +4611,14 @@ void QSessionManager::requestPhase2()
/*!
\fn const QColor &QApplication::winStyleHighlightColor()
- Use qApp->palette().color(QPalette::Active, QPalette::Highlight)
- instead.
+ Use qApp->palette().color(QPalette::Active, QPalette::Highlight) instead.
*/
/*!
\fn QWidget *QApplication::widgetAt(int x, int y, bool child)
- Use the two-argument widgetAt() overload to get the child widget.
- To get the top-level widget do this:
+ Use the two-argument widgetAt() overload to get the child widget. To get
+ the top-level widget do this:
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 12
*/
@@ -4665,8 +4626,8 @@ void QSessionManager::requestPhase2()
/*!
\fn QWidget *QApplication::widgetAt(const QPoint &point, bool child)
- Use the single-argument widgetAt() overload to get the child widget.
- To get the top-level widget do this:
+ Use the single-argument widgetAt() overload to get the child widget. To get
+ the top-level widget do this:
\snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 13
*/
@@ -4738,10 +4699,9 @@ void QApplicationPrivate::emitLastWindowClosed()
Sets whether Qt should use focus navigation suitable for use with a
minimal keypad.
- If \a enable is true, Qt::Key_Up and Qt::Key_Down are used to
- change focus.
+ If \a enable is true, Qt::Key_Up and Qt::Key_Down are used to change focus.
- This feature is only available in Qt for Embedded Linux.
+ This feature is available in Qt for Embedded Linux only.
\sa keypadNavigationEnabled()
*/
@@ -4754,7 +4714,8 @@ void QApplication::setKeypadNavigationEnabled(bool enable)
Returns true if Qt is set to use keypad navigation; otherwise returns
false. The default is false.
- This feature is only available in Qt for Embedded Linux.
+ This feature is available in Qt for Embedded Linux only.
+
\sa setKeypadNavigationEnabled()
*/
bool QApplication::keypadNavigationEnabled()
@@ -4777,12 +4738,12 @@ bool QApplication::keypadNavigationEnabled()
On Mac OS X, this works more at the application level and will cause the
application icon to bounce in the dock.
- On Windows this causes the window's taskbar entry to flash for a time. If \a
- msec is zero, the flashing will stop and the taskbar entry will turn a
+ On Windows this causes the window's taskbar entry to flash for a time. If
+ \a msec is zero, the flashing will stop and the taskbar entry will turn a
different color (currently orange).
- On X11, this will cause the window to be marked as "demands attention",
- the window must not be hidden (i.e. not have hide() called on it, but be
+ On X11, this will cause the window to be marked as "demands attention", the
+ window must not be hidden (i.e. not have hide() called on it, but be
visible in some sort of way) in order for this to work.
*/
@@ -4790,18 +4751,16 @@ bool QApplication::keypadNavigationEnabled()
\property QApplication::cursorFlashTime
\brief the text cursor's flash (blink) time in milliseconds
- The flash time is the time required to display, invert and
- restore the caret display. Usually the text cursor is displayed
- for half the cursor flash time, then hidden for the same amount
- of time, but this may vary.
+ The flash time is the time required to display, invert and restore the
+ caret display. Usually the text cursor is displayed for half the cursor
+ flash time, then hidden for the same amount of time, but this may vary.
- The default value on X11 is 1000 milliseconds. On Windows, the
- control panel value is used. Widgets should not cache this value
- since it may be changed at any time by the user changing the
- global desktop settings.
+ The default value on X11 is 1000 milliseconds. On Windows, the control
+ panel value is used. Widgets should not cache this value since it may be
+ changed at any time by the user changing the global desktop settings.
- Note that on Microsoft Windows, setting this property sets the
- cursor flash time for all applications.
+ \note On Microsoft Windows, setting this property sets the cursor flash
+ time for all applications.
*/
/*!
@@ -4809,8 +4768,8 @@ bool QApplication::keypadNavigationEnabled()
\brief the time limit in milliseconds that distinguishes a double click from two
consecutive mouse clicks
- The default value on X11 is 400 milliseconds. On Windows and Mac
- OS X, the operating system's value is used.
+ The default value on X11 is 400 milliseconds. On Windows and Mac OS X, the
+ operating system's value is used.
On Microsoft Windows and Symbian, calling this function sets the
double click interval for all applications.
@@ -4831,15 +4790,13 @@ bool QApplication::keypadNavigationEnabled()
\brief the number of lines to scroll a widget, when the
mouse wheel is rotated.
- If the value exceeds the widget's number of visible lines, the
- widget should interpret the scroll operation as a single \e{page
- up} or \e{page down}. If the widget is an \l{QAbstractItemView}
- {item view class}, then the result of scrolling one \e line
- depends on the setting of the widget's
- \l{QAbstractItemView::verticalScrollMode()} {scroll mode}. Scroll
- one \e line can mean \l{QAbstractItemView::ScrollPerItem} {scroll
- one item} or \l{QAbstractItemView::ScrollPerPixel} {scroll one
- pixel}.
+ If the value exceeds the widget's number of visible lines, the widget
+ should interpret the scroll operation as a single \e{page up} or
+ \e{page down}. If the widget is an \l{QAbstractItemView}{item view class},
+ then the result of scrolling one \e line depends on the setting of the
+ widget's \l{QAbstractItemView::verticalScrollMode()}{scroll mode}. Scroll
+ one \e line can mean \l{QAbstractItemView::ScrollPerItem}{scroll one item}
+ or \l{QAbstractItemView::ScrollPerPixel}{scroll one pixel}.
By default, this property has a value of 3.
*/
@@ -4847,11 +4804,11 @@ bool QApplication::keypadNavigationEnabled()
/*!
\fn void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable)
- Enables the UI effect \a effect if \a enable is true, otherwise
- the effect will not be used.
+ Enables the UI effect \a effect if \a enable is true, otherwise the effect
+ will not be used.
- Note: All effects are disabled on screens running at less than
- 16-bit color depth.
+ \note All effects are disabled on screens running at less than 16-bit color
+ depth.
\sa isEffectEnabled(), Qt::UIEffect, setDesktopSettingsAware()
*/
@@ -4861,11 +4818,11 @@ bool QApplication::keypadNavigationEnabled()
Returns true if \a effect is enabled; otherwise returns false.
- By default, Qt will try to use the desktop settings. Call
- setDesktopSettingsAware(false) to prevent this.
+ By default, Qt will try to use the desktop settings. To prevent this, call
+ setDesktopSettingsAware(false).
- Note: All effects are disabled on screens running at less than
- 16-bit color depth.
+ \note All effects are disabled on screens running at less than 16-bit color
+ depth.
\sa setEffectEnabled(), Qt::UIEffect
*/
@@ -4873,8 +4830,7 @@ bool QApplication::keypadNavigationEnabled()
/*!
\fn QWidget *QApplication::mainWidget()
- Returns the main application widget, or 0 if there is no main
- widget.
+ Returns the main application widget, or 0 if there is no main widget.
*/
/*!
@@ -4882,19 +4838,17 @@ bool QApplication::keypadNavigationEnabled()
Sets the application's main widget to \a mainWidget.
- In most respects the main widget is like any other widget, except
- that if it is closed, the application exits. Note that
- QApplication does \e not take ownership of the \a mainWidget, so
- if you create your main widget on the heap you must delete it
- yourself.
+ In most respects the main widget is like any other widget, except that if
+ it is closed, the application exits. QApplication does \e not take
+ ownership of the \a mainWidget, so if you create your main widget on the
+ heap you must delete it yourself.
- You need not have a main widget; connecting lastWindowClosed() to
- quit() is an alternative.
+ You need not have a main widget; connecting lastWindowClosed() to quit()
+ is an alternative.
- For X11, this function also resizes and moves the main widget
- according to the \e -geometry command-line option, so you should
- set the default geometry (using \l QWidget::setGeometry()) before
- calling setMainWidget().
+ For X11, this function also resizes and moves the main widget according
+ to the \e -geometry command-line option, so you should set the default
+ geometry (using \l QWidget::setGeometry()) before calling setMainWidget().
\sa mainWidget(), exec(), quit()
*/
@@ -4902,8 +4856,8 @@ bool QApplication::keypadNavigationEnabled()
/*!
\fn void QApplication::beep()
- Sounds the bell, using the default volume and sound. The function
- is \e not available in Qt for Embedded Linux.
+ Sounds the bell, using the default volume and sound. The function is \e not
+ available in Qt for Embedded Linux.
*/
/*!
@@ -4911,26 +4865,25 @@ bool QApplication::keypadNavigationEnabled()
Sets the application override cursor to \a cursor.
- Application override cursors are intended for showing the user
- that the application is in a special state, for example during an
- operation that might take some time.
+ Application override cursors are intended for showing the user that the
+ application is in a special state, for example during an operation that
+ might take some time.
- This cursor will be displayed in all the application's widgets
- until restoreOverrideCursor() or another setOverrideCursor() is
- called.
+ This cursor will be displayed in all the application's widgets until
+ restoreOverrideCursor() or another setOverrideCursor() is called.
- Application cursors are stored on an internal stack.
- setOverrideCursor() pushes the cursor onto the stack, and
- restoreOverrideCursor() pops the active cursor off the
- stack. changeOverrideCursor() changes the curently active
- application override cursor. Every setOverrideCursor() must
+ Application cursors are stored on an internal stack. setOverrideCursor()
+ pushes the cursor onto the stack, and restoreOverrideCursor() pops the
+ active cursor off the stack. changeOverrideCursor() changes the curently
+ active application override cursor. Every setOverrideCursor() must
eventually be followed by a corresponding restoreOverrideCursor(),
otherwise the stack will never be emptied.
Example:
\snippet doc/src/snippets/code/src_gui_kernel_qapplication_x11.cpp 0
- \sa overrideCursor() restoreOverrideCursor() changeOverrideCursor() QWidget::setCursor()
+ \sa overrideCursor(), restoreOverrideCursor(), changeOverrideCursor(),
+ QWidget::setCursor()
*/
/*!
@@ -4939,9 +4892,8 @@ bool QApplication::keypadNavigationEnabled()
Undoes the last setOverrideCursor().
If setOverrideCursor() has been called twice, calling
- restoreOverrideCursor() will activate the first cursor set.
- Calling this function a second time restores the original widgets'
- cursors.
+ restoreOverrideCursor() will activate the first cursor set. Calling this
+ function a second time restores the original widgets' cursors.
\sa setOverrideCursor(), overrideCursor()
*/
@@ -4951,9 +4903,9 @@ bool QApplication::keypadNavigationEnabled()
\relates QApplication
A global pointer referring to the unique application object. It is
- equivalent to the pointer returned by the
- QCoreApplication::instance() function except that, in GUI applications,
- it is a pointer to a QApplication instance.
+ equivalent to the pointer returned by the QCoreApplication::instance()
+ function except that, in GUI applications, it is a pointer to a
+ QApplication instance.
Only one application object can be created.
@@ -4965,8 +4917,8 @@ bool QApplication::keypadNavigationEnabled()
// ************************************************************************
/*!
- This function replaces the QInputContext instance used by the
- application with \a inputContext.
+ This function replaces the QInputContext instance used by the application
+ with \a inputContext.
\sa inputContext()
*/
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 1df442f..f1fb001 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -398,7 +398,7 @@ extern bool qt_xdnd_dragging;
// gui or non-gui from qapplication.cpp
extern bool qt_is_gui_used;
-/*!
+/*!
\internal
Try to resolve a \a symbol from \a library with the version specified
by \a vernum.
@@ -829,11 +829,14 @@ bool QApplicationPrivate::x11_apply_settings()
QColor(strlist[i]));
}
- if (groupCount == QPalette::NColorGroups)
- QApplicationPrivate::setSystemPalette(pal);
+ // ### Fix properly for 4.6
+ if (!(QApplicationPrivate::app_style && QApplicationPrivate::app_style->inherits("QGtkStyle"))) {
+ if (groupCount == QPalette::NColorGroups)
+ QApplicationPrivate::setSystemPalette(pal);
+ }
int kdeSessionVersion = QString::fromLocal8Bit(qgetenv("KDE_SESSION_VERSION")).toInt();
-
+
if (!appFont) {
QFont font(QApplication::font());
QString fontDescription;
@@ -887,11 +890,15 @@ bool QApplicationPrivate::x11_apply_settings()
}
}
+ static QString currentStyleName = stylename;
if (QCoreApplication::startingUp()) {
if (!stylename.isEmpty() && !QApplicationPrivate::styleOverride)
QApplicationPrivate::styleOverride = new QString(stylename);
} else {
- QApplication::setStyle(stylename);
+ if (currentStyleName != stylename) {
+ currentStyleName = stylename;
+ QApplication::setStyle(stylename);
+ }
}
int num =
@@ -1355,8 +1362,10 @@ static void qt_set_x11_resources(const char* font = 0, const char* fg = 0,
pal.setColor(QPalette::Disabled, QPalette::Highlight, Qt::darkBlue);
}
- QApplicationPrivate::setSystemPalette(pal);
-
+ // QGtkStyle sets it's own system palette
+ if (!(QApplicationPrivate::app_style && QApplicationPrivate::app_style->inherits("QGtkStyle"))) {
+ QApplicationPrivate::setSystemPalette(pal);
+ }
QColor::setAllowX11ColorNames(allowX11ColorNames);
}
@@ -1939,11 +1948,17 @@ void qt_init(QApplicationPrivate *priv, int,
{
QString displayName = QLatin1String(XDisplayName(NULL));
- // apparently MITSHM only works for local displays, so do a quick check here
- // to determine whether the display is local or not (not 100 % accurate)
+ // MITSHM only works for local displays, so do a quick check here
+ // to determine whether the display is local or not (not 100 % accurate).
+ // BGR server layouts are not supported either, since it requires the raster
+ // engine to work on a QImage with BGR layout.
bool local = displayName.isEmpty() || displayName.lastIndexOf(QLatin1Char(':')) == 0;
- if (local && (qgetenv("QT_X11_NO_MITSHM").toInt() == 0))
- X11->use_mitshm = mitshm_pixmaps;
+ if (local && (qgetenv("QT_X11_NO_MITSHM").toInt() == 0)) {
+ Visual *defaultVisual = DefaultVisual(X11->display, DefaultScreen(X11->display));
+ X11->use_mitshm = mitshm_pixmaps && (defaultVisual->red_mask == 0xff0000
+ && defaultVisual->green_mask == 0xff00
+ && defaultVisual->blue_mask == 0xff);
+ }
}
#endif // QT_NO_MITSHM
@@ -3351,15 +3366,24 @@ int QApplication::x11ProcessEvent(XEvent* event)
// update the size for desktop widget
int scr = X11->ptrXRRRootToScreen(X11->display, event->xany.window);
- QWidget *w = desktop()->screen(scr);
+ QDesktopWidget *desktop = QApplication::desktop();
+ QWidget *w = desktop->screen(scr);
QSize oldSize(w->size());
w->data->crect.setWidth(DisplayWidth(X11->display, scr));
w->data->crect.setHeight(DisplayHeight(X11->display, scr));
- if (w->size() != oldSize) {
- QResizeEvent e(w->size(), oldSize);
- QApplication::sendEvent(w, &e);
- emit desktop()->resized(scr);
- }
+ QVarLengthArray<QRect> oldSizes(desktop->numScreens());
+ for (int i = 0; i < desktop->numScreens(); ++i)
+ oldSizes[i] = desktop->screenGeometry(i);
+ QResizeEvent e(w->size(), oldSize);
+ QApplication::sendEvent(w, &e);
+ for (int i = 0; i < qMin(oldSizes.count(), desktop->numScreens()); ++i) {
+ if (oldSizes[i] != desktop->screenGeometry(i))
+ emit desktop->resized(i);
+ }
+ for (int i = oldSizes.count(); i < desktop->numScreens(); ++i)
+ emit desktop->resized(i); // added
+ for (int i = desktop->numScreens(); i < oldSizes.count(); ++i)
+ emit desktop->resized(i); // removed
}
#endif // QT_NO_XRANDR
diff --git a/src/gui/kernel/qcocoaapplication_mac.mm b/src/gui/kernel/qcocoaapplication_mac.mm
index f95f004f..a3cc2c1 100644
--- a/src/gui/kernel/qcocoaapplication_mac.mm
+++ b/src/gui/kernel/qcocoaapplication_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
/****************************************************************************
**
diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
index 650ebbd..6571068 100644
--- a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
+++ b/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
/****************************************************************************
**
@@ -107,6 +107,8 @@ static void cleanupCocoaApplicationDelegate()
- (id)init
{
self = [super init];
+ if (self)
+ inLaunch = true;
return self;
}
@@ -198,12 +200,26 @@ static void cleanupCocoaApplicationDelegate()
return reply;
}
+- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
+{
+ Q_UNUSED(aNotification);
+ inLaunch = false;
+}
+
- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames
{
- unsigned int ix;
- for( ix = 0; ix < [filenames count]; ix++) {
- NSString *fileName = [filenames objectAtIndex:ix];
- qApp->postEvent(qApp, new QFileOpenEvent(QCFString::toQString((CFStringRef)fileName)));
+ for (NSString *fileName in filenames) {
+ QString qtFileName = qt_mac_NSStringToQString(fileName);
+ if (inLaunch) {
+ // We need to be careful because Cocoa will be nice enough to take
+ // command line arguments and send them to us as events. Given the history
+ // of Qt Applications, this will result in behavior people don't want, as
+ // they might be doing the opening themselves with the command line parsing.
+ if (qApp->arguments().contains(qtFileName))
+ continue;
+ }
+ QFileOpenEvent foe(qtFileName);
+ qt_sendSpontaneousEvent(qAppInstance(), &foe);
}
if (reflectionDelegate &&
diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac_p.h b/src/gui/kernel/qcocoaapplicationdelegate_mac_p.h
index c5336f1..fca2a15 100644
--- a/src/gui/kernel/qcocoaapplicationdelegate_mac_p.h
+++ b/src/gui/kernel/qcocoaapplicationdelegate_mac_p.h
@@ -107,6 +107,7 @@ QT_FORWARD_DECLARE_CLASS(QApplicationPrivate);
NSMenu *dockMenu;
QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *qtMenuLoader;
id <NSApplicationDelegate> reflectionDelegate;
+ bool inLaunch;
}
+ (QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate)*)sharedDelegate;
- (void)setDockMenu:(NSMenu *)newMenu;
diff --git a/src/gui/kernel/qcocoamenuloader_mac.mm b/src/gui/kernel/qcocoamenuloader_mac.mm
index 7ecb765..e836286 100644
--- a/src/gui/kernel/qcocoamenuloader_mac.mm
+++ b/src/gui/kernel/qcocoamenuloader_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
#include "qmacdefines_mac.h"
#ifdef QT_MAC_USE_COCOA
diff --git a/src/gui/kernel/qcocoapanel_mac.mm b/src/gui/kernel/qcocoapanel_mac.mm
index 6aeee34..c69826f 100644
--- a/src/gui/kernel/qcocoapanel_mac.mm
+++ b/src/gui/kernel/qcocoapanel_mac.mm
@@ -43,10 +43,16 @@
#ifdef QT_MAC_USE_COCOA
#import <private/qt_cocoa_helpers_mac_p.h>
#import <private/qcocoawindow_mac_p.h>
+#import <private/qcocoawindowdelegate_mac_p.h>
+#import <private/qcocoaview_mac_p.h>
#import <private/qcocoawindowcustomthemeframe_mac_p.h>
#include <QtGui/QWidget>
+QT_FORWARD_DECLARE_CLASS(QWidget);
+QT_BEGIN_NAMESPACE
+extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm
+QT_END_NAMESPACE
QT_USE_NAMESPACE
@implementation QT_MANGLE_NAMESPACE(QCocoaPanel)
@@ -60,18 +66,115 @@ QT_USE_NAMESPACE
return !(isPopup || isToolTip);
}
+/***********************************************************************
+ BEGIN Copy and Paste between QCocoaWindow and QCocoaPanel
+ This is a bit unfortunate, but thanks to the dynamic dispatch we
+ have to duplicate this code or resort to really silly forwarding methods
+**************************************************************************/
+
+/*
+ The methods keyDown, keyUp, and flagsChanged... These really shouldn't ever
+ get hit. We automatically say we can be first responder if we are a window.
+ So, the handling should get handled by the view. This is here more as a
+ last resort (i.e., this is code that can potentially be removed).
+ */
+
+- (void)keyDown:(NSEvent *)theEvent
+{
+ bool keyOK = qt_dispatchKeyEvent(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]);
+ if (!keyOK)
+ [super keyDown:theEvent];
+}
+
+- (void)keyUp:(NSEvent *)theEvent
+{
+ bool keyOK = qt_dispatchKeyEvent(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]);
+ if (!keyOK)
+ [super keyUp:theEvent];
+}
+
+- (void)flagsChanged:(NSEvent *)theEvent
+{
+ qt_dispatchModifiersChanged(theEvent, [self QT_MANGLE_NAMESPACE(qt_qwidget)]);
+ [super flagsChanged:theEvent];
+}
+
+
+- (void)tabletProximity:(NSEvent *)tabletEvent
+{
+ qt_dispatchTabletProximityEvent(tabletEvent);
+}
+
- (void)sendEvent:(NSEvent *)event
{
[self retain];
- [super sendEvent:event];
+
+ QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self];
+ QT_MANGLE_NAMESPACE(QCocoaView) *view = static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(qt_mac_nativeview_for(widget));
+ Qt::MouseButton mouseButton = cocoaButton2QtButton([event buttonNumber]);
+
+ // sometimes need to redirect mouse events to the popup.
+ QWidget *popup = qAppInstance()->activePopupWidget();
+ if (popup && popup != widget) {
+ switch([event type])
+ {
+ case NSLeftMouseDown:
+ qt_mac_handleMouseEvent(view, event, QEvent::MouseButtonPress, mouseButton);
+ // Don't call super here. This prevents us from getting the mouseUp event,
+ // which we need to send even if the mouseDown event was not accepted.
+ // (this is standard Qt behavior.)
+ break;
+ case NSRightMouseDown:
+ case NSOtherMouseDown:
+ if (!qt_mac_handleMouseEvent(view, event, QEvent::MouseButtonPress, mouseButton))
+ [super sendEvent:event];
+ break;
+ case NSLeftMouseUp:
+ case NSRightMouseUp:
+ case NSOtherMouseUp:
+ if (!qt_mac_handleMouseEvent(view, event, QEvent::MouseButtonRelease, mouseButton))
+ [super sendEvent:event];
+ break;
+ case NSMouseMoved:
+ qt_mac_handleMouseEvent(view, event, QEvent::MouseMove, Qt::NoButton);
+ break;
+ case NSLeftMouseDragged:
+ case NSRightMouseDragged:
+ case NSOtherMouseDragged:
+ [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]->view = view;
+ [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]->theEvent = event;
+ if (!qt_mac_handleMouseEvent(view, event, QEvent::MouseMove, mouseButton))
+ [super sendEvent:event];
+ break;
+ default:
+ [super sendEvent:event];
+ break;
+ }
+ } else {
+ [super sendEvent:event];
+ }
qt_mac_dispatchNCMouseMessage(self, event, [self QT_MANGLE_NAMESPACE(qt_qwidget)], leftButtonIsRightButton);
+
+
[self release];
}
+- (BOOL)makeFirstResponder:(NSResponder *)responder
+{
+ // For some reason Cocoa wants to flip the first responder
+ // when Qt doesn't want to, sorry, but "No" :-)
+ if (responder == nil && qApp->focusWidget())
+ return NO;
+ return [super makeFirstResponder:responder];
+}
+
+/***********************************************************************
+ END Copy and Paste between QCocoaWindow and QCocoaPanel
+***********************************************************************/
+ (Class)frameViewClassForStyleMask:(NSUInteger)styleMask
{
if (styleMask & QtMacCustomizeWindow)
- return [QCocoaWindowCustomThemeFrame class];
+ return [QT_MANGLE_NAMESPACE(QCocoaWindowCustomThemeFrame) class];
return [super frameViewClassForStyleMask:styleMask];
}
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 19367d1..fae4821 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -181,6 +181,7 @@ QT_FORWARD_DECLARE_CLASS(QAbstractScrollAreaPrivate)
QT_FORWARD_DECLARE_CLASS(QPaintEvent)
QT_FORWARD_DECLARE_CLASS(QPainter)
QT_FORWARD_DECLARE_CLASS(QHoverEvent)
+QT_FORWARD_DECLARE_CLASS(QCursor)
QT_USE_NAMESPACE
extern "C" {
extern NSString *NSTextInputReplacementRangeAttributeName;
@@ -236,6 +237,34 @@ extern "C" {
}
}
+- (void)resetCursorRects
+{
+ QWidget *cursorWidget = qwidget;
+
+ if (cursorWidget->testAttribute(Qt::WA_TransparentForMouseEvents))
+ cursorWidget = QApplication::widgetAt(qwidget->mapToGlobal(qwidget->rect().center()));
+
+ if (cursorWidget == 0)
+ return;
+
+ if (!cursorWidget->testAttribute(Qt::WA_SetCursor)) {
+ [super resetCursorRects];
+ return;
+ }
+
+ QRegion mask = qt_widget_private(cursorWidget)->extra->mask;
+ NSCursor *nscursor = static_cast<NSCursor *>(nsCursorForQCursor(cursorWidget->cursor()));
+ if (mask.isEmpty()) {
+ [self addCursorRect:[qt_mac_nativeview_for(cursorWidget) visibleRect] cursor:nscursor];
+ } else {
+ const QVector<QRect> &rects = mask.rects();
+ for (int i = 0; i < rects.size(); ++i) {
+ const QRect &rect = rects.at(i);
+ [self addCursorRect:NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height()) cursor:nscursor];
+ }
+ }
+}
+
- (void)removeDropData
{
if (dropData) {
@@ -263,9 +292,18 @@ extern "C" {
QPoint posDrag(localPoint.x, localPoint.y);
NSDragOperation nsActions = [sender draggingSourceOperationMask];
Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations(nsActions);
+ QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) = nsActions;
+ Qt::KeyboardModifiers modifiers = Qt::NoModifier;
+ if ([sender draggingSource] != nil) {
+ // modifier flags might have changed, update it here since we don't send any input events.
+ QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[NSApp currentEvent] modifierFlags]);
+ modifiers = QApplication::keyboardModifiers();
+ } else {
+ // when the source is from another application the above technique will not work.
+ modifiers = qt_cocoaDragOperation2QtModifiers(nsActions);
+ }
// send the drag enter event to the widget.
- QDragEnterEvent qDEEvent(posDrag, qtAllowed, mimeData,
- QApplication::mouseButtons(), QApplication::keyboardModifiers());
+ QDragEnterEvent qDEEvent(posDrag, qtAllowed, mimeData, QApplication::mouseButtons(), modifiers);
QApplication::sendEvent(qwidget, &qDEEvent);
if (!qDEEvent.isAccepted()) {
// widget is not interested in this drag, so ignore this drop data.
@@ -273,24 +311,23 @@ extern "C" {
return NSDragOperationNone;
} else {
// send a drag move event immediately after a drag enter event (as per documentation).
- QDragMoveEvent qDMEvent(posDrag, qtAllowed, mimeData,
- QApplication::mouseButtons(), QApplication::keyboardModifiers());
+ QDragMoveEvent qDMEvent(posDrag, qtAllowed, mimeData, QApplication::mouseButtons(), modifiers);
qDMEvent.setDropAction(qDEEvent.dropAction());
qDMEvent.accept(); // accept by default, since enter event was accepted.
QApplication::sendEvent(qwidget, &qDMEvent);
if (!qDMEvent.isAccepted() || qDMEvent.dropAction() == Qt::IgnoreAction) {
// since we accepted the drag enter event, the widget expects
// future drage move events.
- // ### check if we need to treat this like the drag enter event.
+ // ### check if we need to treat this like the drag enter event.
nsActions = QT_PREPEND_NAMESPACE(qt_mac_mapDropAction)(qDEEvent.dropAction());
} else {
nsActions = QT_PREPEND_NAMESPACE(qt_mac_mapDropAction)(qDMEvent.dropAction());
- }
+ }
QT_PREPEND_NAMESPACE(qt_mac_copy_answer_rect)(qDMEvent);
- return nsActions;
+ return nsActions;
}
}
-
+
- (NSDragOperation)draggingUpdated:(id < NSDraggingInfo >)sender
{
// drag enter event was rejected, so ignore the move event.
@@ -300,17 +337,27 @@ extern "C" {
NSPoint windowPoint = [sender draggingLocation];
NSPoint globalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:windowPoint];
NSPoint localPoint = [self convertPoint:windowPoint fromView:nil];
+ NSDragOperation nsActions = [sender draggingSourceOperationMask];
QPoint posDrag(localPoint.x, localPoint.y);
- if (qt_mac_mouse_inside_answer_rect(posDrag))
+ if (qt_mac_mouse_inside_answer_rect(posDrag)
+ && QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) == nsActions)
return QT_PREPEND_NAMESPACE(qt_mac_mapDropActions)(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastAction));
// send drag move event to the widget
- NSDragOperation nsActions = [sender draggingSourceOperationMask];
+ QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec.lastOperation) = nsActions;
Qt::DropActions qtAllowed = QT_PREPEND_NAMESPACE(qt_mac_mapNSDragOperations)(nsActions);
+ Qt::KeyboardModifiers modifiers = Qt::NoModifier;
+ if ([sender draggingSource] != nil) {
+ // modifier flags might have changed, update it here since we don't send any input events.
+ QApplicationPrivate::modifier_buttons = qt_cocoaModifiers2QtModifiers([[NSApp currentEvent] modifierFlags]);
+ modifiers = QApplication::keyboardModifiers();
+ } else {
+ // when the source is from another application the above technique will not work.
+ modifiers = qt_cocoaDragOperation2QtModifiers(nsActions);
+ }
QMimeData *mimeData = dropData;
if (QDragManager::self()->source())
mimeData = QDragManager::self()->dragPrivate()->data;
- QDragMoveEvent qDMEvent(posDrag, qtAllowed, mimeData,
- QApplication::mouseButtons(), QApplication::keyboardModifiers());
+ QDragMoveEvent qDMEvent(posDrag, qtAllowed, mimeData, QApplication::mouseButtons(), modifiers);
qDMEvent.setDropAction(QT_PREPEND_NAMESPACE(qt_mac_dnd_answer_rec).lastAction);
qDMEvent.accept();
QApplication::sendEvent(qwidget, &qDMEvent);
@@ -339,12 +386,12 @@ extern "C" {
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
[self addDropData:sender];
-
+
NSPoint windowPoint = [sender draggingLocation];
NSPoint globalPoint = [[sender draggingDestinationWindow] convertBaseToScreen:windowPoint];
NSPoint localPoint = [self convertPoint:windowPoint fromView:nil];
QPoint posDrop(localPoint.x, localPoint.y);
-
+
NSDragOperation nsActions = [sender draggingSourceOperationMask];
Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations(nsActions);
QMimeData *mimeData = dropData;
@@ -356,6 +403,8 @@ extern "C" {
if (QDragManager::self()->object)
QDragManager::self()->dragPrivate()->target = qwidget;
QApplication::sendEvent(qwidget, &de);
+ if (QDragManager::self()->object)
+ QDragManager::self()->dragPrivate()->executed_action = de.dropAction();
if (!de.isAccepted())
return NO;
else
@@ -386,10 +435,9 @@ extern "C" {
- (void) setFrameSize:(NSSize)newSize
{
[super setFrameSize:newSize];
-
+
// A change in size has required the view to be invalidated.
- if ([self inLiveResize])
- {
+ if ([self inLiveResize]) {
NSRect rects[4];
NSInteger count;
[self getRectsExposedDuringLiveResize:rects count:&count];
@@ -397,9 +445,7 @@ extern "C" {
{
[self setNeedsDisplayInRect:rects[count]];
}
- }
- else
- {
+ } else {
[self setNeedsDisplay:YES];
}
}
@@ -534,7 +580,7 @@ extern "C" {
if (!qAppInstance()->activeModalWidget() || QApplicationPrivate::tryModalHelper(qwidget, 0)) {
QApplication::sendEvent(qwidget, &enterEvent);
qt_mouseover = qwidget;
-
+
// Update cursor and dispatch hover events.
qt_mac_update_cursor_at_global_pos(flipPoint(globalPoint).toPoint());
if (qwidget->testAttribute(Qt::WA_Hover) &&
@@ -589,7 +635,7 @@ extern "C" {
[viewsToLookAt addObject:qt_mac_nativeview_for(parentWidget)];
parentWidget = parentWidget->parentWidget();
}
-
+
// Now walk through the subviews of each view and determine which subview should
// get the event. We look through all the subviews at a given level with
// the assumption that the last item to be found the candidate has a higher z-order.
@@ -599,7 +645,7 @@ extern "C" {
for (NSView *lookView in viewsToLookAt) {
NSPoint tmpPoint = [lookView convertPoint:windowPoint fromView:nil];
for (NSView *view in [lookView subviews]) {
- if (view == mouseView)
+ if (view == mouseView || [view isHidden])
continue;
NSRect frameRect = [view frame];
if (NSMouseInRect(tmpPoint, [view frame], [view isFlipped]))
@@ -618,7 +664,7 @@ extern "C" {
NSPoint tmpPoint = [viewForDescent convertPoint:windowPoint fromView:nil];
// Apply same rule as above wrt z-order.
for (NSView *view in [viewForDescent subviews]) {
- if (NSMouseInRect(tmpPoint, [view frame], [view isFlipped]))
+ if (![view isHidden] && NSMouseInRect(tmpPoint, [view frame], [view isFlipped]))
lowerView = view;
}
if (!lowerView) // Low as we can be at this point.
@@ -725,7 +771,7 @@ extern "C" {
if (currentIManager && [currentIManager wantsToHandleMouseEvents]) {
[currentIManager handleMouseEvent:theEvent];
}
-
+
NSPoint windowPoint = [theEvent locationInWindow];
NSPoint globalPoint = [[theEvent window] convertBaseToScreen:windowPoint];
NSPoint localPoint = [self convertPoint:windowPoint fromView:nil];
@@ -734,7 +780,7 @@ extern "C" {
Qt::MouseButton buttons = cocoaButton2QtButton([theEvent buttonNumber]);
bool wheelOK = false;
Qt::KeyboardModifiers keyMods = qt_cocoaModifiers2QtModifiers([theEvent modifierFlags]);
-
+
// Mouse wheel deltas seem to tick in at increments of 0.1. Qt widgets
// expect the delta to be a multiple of 120.
const int ScrollFactor = 10 * 120;
@@ -756,7 +802,7 @@ extern "C" {
wheelOK = qwe2.isAccepted();
}
}
-
+
if (deltaY) {
QWheelEvent qwe(qlocal, qglobal, deltaY, buttons, keyMods, Qt::Vertical);
qt_sendSpontaneousEvent(qwidget, &qwe);
@@ -769,7 +815,7 @@ extern "C" {
wheelOK = qwe2.isAccepted();
}
}
-
+
if (deltaZ) {
// Qt doesn't explicitly support wheels with a Z component. In a misguided attempt to
// try to be ahead of the pack, I'm adding this extra value.
@@ -858,6 +904,11 @@ extern "C" {
Q_UNUSED(anImage);
Q_UNUSED(aPoint);
qMacDnDParams()->performedAction = operation;
+ if (QDragManager::self()->object
+ && QDragManager::self()->dragPrivate()->executed_action != Qt::ActionMask) {
+ qMacDnDParams()->performedAction =
+ qt_mac_mapDropAction(QDragManager::self()->dragPrivate()->executed_action);
+ }
}
- (QWidget *)qt_qwidget
@@ -913,6 +964,27 @@ extern "C" {
}
}
+- (void)viewWillMoveToWindow:(NSWindow *)window
+{
+ if (qwidget->windowFlags() & Qt::MSWindowsOwnDC
+ && (window != [self window])) { // OpenGL Widget
+ // Create a stupid ClearDrawable Event
+ QEvent event(QEvent::MacGLClearDrawable);
+ qApp->sendEvent(qwidget, &event);
+ }
+}
+
+- (void)viewDidMoveToWindow
+{
+ if (qwidget->windowFlags() & Qt::MSWindowsOwnDC && [self window]) {
+ // call update paint event
+ qwidgetprivate->needWindowChange = true;
+ QEvent event(QEvent::MacGLWindowChange);
+ qApp->sendEvent(qwidget, &event);
+ }
+}
+
+
// NSTextInput Protocol implementation
- (void) insertText:(id)aString
@@ -1150,13 +1222,13 @@ Qt::DropAction QDragManager::drag(QDrag *o)
so we just bail early to prevent it */
if(!(GetCurrentEventButtonState() & kEventMouseButtonPrimary))
return Qt::IgnoreAction;
-
+
if(object) {
dragPrivate()->source->removeEventFilter(this);
cancel();
beingCancelled = false;
}
-
+
object = o;
dragPrivate()->target = 0;
@@ -1168,7 +1240,7 @@ Qt::DropAction QDragManager::drag(QDrag *o)
QMacPasteboard dragBoard((CFStringRef) NSDragPboard, QMacPasteboardMime::MIME_DND);
dragPrivate()->data->setData(QLatin1String("application/x-qt-mime-type-name"), QByteArray());
dragBoard.setMimeData(dragPrivate()->data);
-
+
// create the image
QPoint hotspot;
QPixmap pix = dragPrivate()->pixmap;
@@ -1214,6 +1286,7 @@ Qt::DropAction QDragManager::drag(QDrag *o)
NSSize mouseOffset = {0.0, 0.0};
NSPasteboard *pboard = [NSPasteboard pasteboardWithName:NSDragPboard];
NSPoint windowPoint = [dndParams->theEvent locationInWindow];
+ dragPrivate()->executed_action = Qt::ActionMask;
// do the drag
[dndParams->view retain];
[dndParams->view dragImage:image
@@ -1225,6 +1298,7 @@ Qt::DropAction QDragManager::drag(QDrag *o)
slideBack:YES];
[dndParams->view release];
[image release];
+ dragPrivate()->executed_action = Qt::IgnoreAction;
object = 0;
Qt::DropAction performedAction(qt_mac_mapNSDragOperation(dndParams->performedAction));
// do post drag processing, if required.
diff --git a/src/gui/kernel/qcocoawindow_mac.mm b/src/gui/kernel/qcocoawindow_mac.mm
index 6b30444..89f481f 100644
--- a/src/gui/kernel/qcocoawindow_mac.mm
+++ b/src/gui/kernel/qcocoawindow_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
#include "qmacdefines_mac.h"
#ifdef QT_MAC_USE_COCOA
@@ -53,9 +53,10 @@
#include <QtGui/QWidget>
QT_FORWARD_DECLARE_CLASS(QWidget);
-QT_USE_NAMESPACE
-
+QT_BEGIN_NAMESPACE
extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm
+QT_END_NAMESPACE
+QT_USE_NAMESPACE
@implementation NSWindow (QT_MANGLE_NAMESPACE(QWidgetIntegration))
@@ -86,6 +87,12 @@ extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.
return YES;
}
+/***********************************************************************
+ BEGIN Copy and Paste between QCocoaWindow and QCocoaPanel
+ This is a bit unfortunate, but thanks to the dynamic dispatch we
+ have to duplicate this code or resort to really silly forwarding methods
+**************************************************************************/
+
/*
The methods keyDown, keyUp, and flagsChanged... These really shouldn't ever
get hit. We automatically say we can be first responder if we are a window.
@@ -124,7 +131,7 @@ extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.
[self retain];
QWidget *widget = [[QT_MANGLE_NAMESPACE(QCocoaWindowDelegate) sharedDelegate] qt_qwidgetForWindow:self];
- QCocoaView *view = static_cast<QCocoaView *>(qt_mac_nativeview_for(widget));
+ QT_MANGLE_NAMESPACE(QCocoaView) *view = static_cast<QT_MANGLE_NAMESPACE(QCocoaView) *>(qt_mac_nativeview_for(widget));
Qt::MouseButton mouseButton = cocoaButton2QtButton([event buttonNumber]);
// sometimes need to redirect mouse events to the popup.
@@ -173,6 +180,20 @@ extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.
[self release];
}
+
+- (BOOL)makeFirstResponder:(NSResponder *)responder
+{
+ // For some reason Cocoa wants to flip the first responder
+ // when Qt doesn't want to, sorry, but "No" :-)
+ if (responder == nil && qApp->focusWidget())
+ return NO;
+ return [super makeFirstResponder:responder];
+}
+
+/***********************************************************************
+ END Copy and Paste between QCocoaWindow and QCocoaPanel
+***********************************************************************/
+
+ (Class)frameViewClassForStyleMask:(NSUInteger)styleMask
{
if (styleMask & QtMacCustomizeWindow)
diff --git a/src/gui/kernel/qcocoawindowdelegate_mac.mm b/src/gui/kernel/qcocoawindowdelegate_mac.mm
index 8480179..03b2fce 100644
--- a/src/gui/kernel/qcocoawindowdelegate_mac.mm
+++ b/src/gui/kernel/qcocoawindowdelegate_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
#import "private/qcocoawindowdelegate_mac_p.h"
#ifdef QT_MAC_USE_COCOA
diff --git a/src/gui/kernel/qcursor.h b/src/gui/kernel/qcursor.h
index 15b4597..ad1860d 100644
--- a/src/gui/kernel/qcursor.h
+++ b/src/gui/kernel/qcursor.h
@@ -77,6 +77,7 @@ class QBitmap;
class QPixmap;
#if defined(Q_WS_MAC)
+void *nsCursorForQCursor(const QCursor &c);
void qt_mac_set_cursor(const QCursor *c, const QPoint &p);
#endif
@@ -128,6 +129,7 @@ public:
private:
QCursorData *d;
#if defined(Q_WS_MAC)
+ friend void *nsCursorForQCursor(const QCursor &c);
friend void qt_mac_set_cursor(const QCursor *c, const QPoint &p);
#endif
};
diff --git a/src/gui/kernel/qcursor_mac.mm b/src/gui/kernel/qcursor_mac.mm
index d632eb79..ae98f2e 100644
--- a/src/gui/kernel/qcursor_mac.mm
+++ b/src/gui/kernel/qcursor_mac.mm
@@ -95,9 +95,19 @@ protected:
}
};
+void *nsCursorForQCursor(const QCursor &c)
+{
+ c.d->update();
+ return [[static_cast<NSCursor *>(c.d->curs.cp.nscursor) retain] autorelease];
+}
+
static QCursorData *currentCursor = 0; //current cursor
void qt_mac_set_cursor(const QCursor *c, const QPoint &)
{
+#ifdef QT_MAC_USE_COCOA
+ Q_UNUSED(c);
+ return;
+#else
if (!c) {
currentCursor = 0;
return;
@@ -128,10 +138,15 @@ void qt_mac_set_cursor(const QCursor *c, const QPoint &)
}
}
currentCursor = c->d;
+#endif
}
void qt_mac_update_cursor_at_global_pos(const QPoint &globalPos)
{
+#ifdef QT_MAC_USE_COCOA
+ Q_UNUSED(globalPos);
+ return;
+#else
QCursor cursor(Qt::ArrowCursor);
if (QApplication::overrideCursor()) {
cursor = *QApplication::overrideCursor();
@@ -144,6 +159,7 @@ void qt_mac_update_cursor_at_global_pos(const QPoint &globalPos)
}
}
qt_mac_set_cursor(&cursor, globalPos);
+#endif
}
void qt_mac_update_cursor()
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 3f1df5e..8c7e47d 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -1656,7 +1656,7 @@ Qt::ButtonState QContextMenuEvent::state() const
The variant contains a QLocale object specifying the language of a
certain part of the preedit string. There should be at most one
language set for every part of the preedit string. If several are
- specified for any character in the string the behaviour is undefined.
+ specified for any character in the string the behavior is undefined.
\value Ruby
The ruby text for a part of the preedit string. There should be at
diff --git a/src/gui/kernel/qmacdefines_mac.h b/src/gui/kernel/qmacdefines_mac.h
index 97ec544..035b8c5 100644
--- a/src/gui/kernel/qmacdefines_mac.h
+++ b/src/gui/kernel/qmacdefines_mac.h
@@ -105,7 +105,7 @@ Yes, it is an informative comment ;-)
# undef qDebug
#endif
-#if __LP64__
+#ifdef __LP64__
typedef signed int OSStatus;
#else
typedef signed long OSStatus;
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index 9c381b4..f000292 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -515,6 +515,18 @@ Qt::KeyboardModifiers qt_cocoaModifiers2QtModifiers(ulong modifierFlags)
return qtMods;
}
+Qt::KeyboardModifiers qt_cocoaDragOperation2QtModifiers(uint dragOperations)
+{
+ Qt::KeyboardModifiers qtMods =Qt::NoModifier;
+ if (dragOperations & NSDragOperationLink)
+ qtMods |= Qt::MetaModifier;
+ if (dragOperations & NSDragOperationGeneric)
+ qtMods |= Qt::ControlModifier;
+ if (dragOperations & NSDragOperationCopy)
+ qtMods |= Qt::AltModifier;
+ return qtMods;
+}
+
static inline QEvent::Type cocoaEvent2QtEvent(NSUInteger eventType)
{
// Handle the trivial cases that can be determined from the type.
@@ -555,12 +567,15 @@ bool qt_dispatchKeyEventWithCocoa(void * /*NSEvent * */ keyEvent, QWidget *widge
int keyLength = [keyChars length];
if (keyLength == 0)
return false; // Dead Key, nothing to do!
+ bool ignoreText = false;
Qt::Key qtKey = Qt::Key_unknown;
if (keyLength == 1) {
QChar ch([keyChars characterAtIndex:0]);
if (ch.isLower())
ch = ch.toUpper();
qtKey = cocoaKey2QtKey(ch);
+ // Do not set the text for Function-Key Unicodes characters (0xF700–0xF8FF).
+ ignoreText = (ch.unicode() >= 0xF700 && ch.unicode() <= 0xF8FF);
}
Qt::KeyboardModifiers keyMods = qt_cocoaModifiers2QtModifiers([event modifierFlags]);
QString text;
@@ -568,7 +583,7 @@ bool qt_dispatchKeyEventWithCocoa(void * /*NSEvent * */ keyEvent, QWidget *widge
// To quote from the Carbon port: This is actually wrong--but it is the best that
// can be done for now because of the Control/Meta mapping issues
// (we always get text on the Mac)
- if (!(keyMods & (Qt::ControlModifier | Qt::MetaModifier)))
+ if (!ignoreText && !(keyMods & (Qt::ControlModifier | Qt::MetaModifier)))
text = QCFString::toQString(reinterpret_cast<CFStringRef>(keyChars));
UInt32 macScanCode = 1;
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac_p.h b/src/gui/kernel/qt_cocoa_helpers_mac_p.h
index ef55aa4..63a301c 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac_p.h
+++ b/src/gui/kernel/qt_cocoa_helpers_mac_p.h
@@ -141,6 +141,7 @@ inline QApplication *qAppInstance() { return static_cast<QApplication *>(QCoreAp
struct ::TabletProximityRec;
void qt_dispatchTabletProximityEvent(const ::TabletProximityRec &proxRec);
Qt::KeyboardModifiers qt_cocoaModifiers2QtModifiers(ulong modifierFlags);
+Qt::KeyboardModifiers qt_cocoaDragOperation2QtModifiers(uint dragOperations);
inline int flipYCoordinate(int y)
{
return QApplication::desktop()->screenGeometry(0).height() - y;
diff --git a/src/gui/kernel/qt_mac.cpp b/src/gui/kernel/qt_mac.cpp
index b462b13..44e10a8 100644
--- a/src/gui/kernel/qt_mac.cpp
+++ b/src/gui/kernel/qt_mac.cpp
@@ -93,6 +93,8 @@ static QColor qcolorFromCGColor(CGColorRef cgcolor)
pc.setRgbF(components[0], components[1], components[2], components[3]);
} else if (model == kCGColorSpaceModelCMYK) {
pc.setCmykF(components[0], components[1], components[2], components[3]);
+ } else if (model == kCGColorSpaceModelMonochrome) {
+ pc.setRgbF(components[0], components[0], components[0], components[1]);
} else {
// Colorspace we can't deal with.
qWarning("Qt: qcolorFromCGColor: cannot convert from colorspace model: %d", model);
@@ -129,16 +131,47 @@ QColor qcolorForTheme(ThemeBrush brush)
QColor qcolorForThemeTextColor(ThemeTextColor themeColor)
{
-#ifndef QT_MAC_USE_COCOA
+#ifdef Q_OS_MAC32
RGBColor c;
GetThemeTextColor(themeColor, 32, true, &c);
- return QColor(c.red / 265, c.green / 256, c.blue / 256);
+ QColor color = QColor(c.red / 265, c.green / 256, c.blue / 256);
+ return color;
#else
- QNativeImage nativeImage(16,16, QNativeImage::systemFormat());
- CGRect cgrect = CGRectMake(0, 0, 16, 16);
- HIThemeSetTextFill(themeColor, 0, nativeImage.cg, kHIThemeOrientationNormal);
- CGContextFillRect(nativeImage.cg, cgrect);
- return QColor(nativeImage.image.pixel(0 , 0));
+ // There is no equivalent to GetThemeTextColor in 64-bit and it was rather bad that
+ // I didn't file a request to implement this for Snow Leopard. So, in the meantime
+ // I've encoded the values from the GetThemeTextColor. This is not exactly ideal
+ // as if someone really wants to mess with themeing, these colors will be wrong.
+ // It also means that we need to make sure the values for differences between
+ // OS releases (and it will be likely that we are a step behind.)
+ switch (themeColor) {
+ case kThemeTextColorAlertActive:
+ case kThemeTextColorTabFrontActive:
+ case kThemeTextColorBevelButtonActive:
+ case kThemeTextColorListView:
+ case kThemeTextColorPlacardActive:
+ case kThemeTextColorPopupButtonActive:
+ case kThemeTextColorPopupLabelActive:
+ case kThemeTextColorPushButtonActive:
+ return Qt::black;
+ case kThemeTextColorAlertInactive:
+ case kThemeTextColorDialogInactive:
+ case kThemeTextColorPlacardInactive:
+ return QColor(67, 69, 69, 255);
+ case kThemeTextColorPopupButtonInactive:
+ case kThemeTextColorPopupLabelInactive:
+ case kThemeTextColorPushButtonInactive:
+ case kThemeTextColorTabFrontInactive:
+ case kThemeTextColorBevelButtonInactive:
+ return QColor(123, 127, 127, 255);
+ default: {
+ QNativeImage nativeImage(16,16, QNativeImage::systemFormat());
+ CGRect cgrect = CGRectMake(0, 0, 16, 16);
+ HIThemeSetTextFill(themeColor, 0, nativeImage.cg, kHIThemeOrientationNormal);
+ CGContextFillRect(nativeImage.cg, cgrect);
+ QColor color = nativeImage.image.pixel(0,0);
+ return QColor(nativeImage.image.pixel(0 , 0));
+ }
+ }
#endif
}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qt_mac_p.h b/src/gui/kernel/qt_mac_p.h
index 3aec23f..ca995dc 100644
--- a/src/gui/kernel/qt_mac_p.h
+++ b/src/gui/kernel/qt_mac_p.h
@@ -233,6 +233,7 @@ extern QPaintDevice *qt_mac_safe_pdev; //qapplication_mac.cpp
extern OSWindowRef qt_mac_window_for(const QWidget*); //qwidget_mac.mm
extern OSViewRef qt_mac_nativeview_for(const QWidget *); //qwidget_mac.mm
+extern QPoint qt_mac_nativeMapFromParent(const QWidget *child, const QPoint &pt); //qwidget_mac.mm
#ifdef check
# undef check
@@ -249,11 +250,13 @@ struct QMacDndAnswerRecord {
Qt::KeyboardModifiers modifiers;
Qt::MouseButtons buttons;
Qt::DropAction lastAction;
+ unsigned int lastOperation;
void clear() {
rect = QRect();
modifiers = Qt::NoModifier;
buttons = Qt::NoButton;
lastAction = Qt::IgnoreAction;
+ lastOperation = 0;
}
};
extern QMacDndAnswerRecord qt_mac_dnd_answer_rec;
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 731ac6f..7eaebbb 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -66,6 +66,7 @@
#ifdef Q_WS_MAC
# include "qt_mac_p.h"
# include "qt_cocoa_helpers_mac_p.h"
+# include "qmainwindow.h"
#endif
#if defined(Q_WS_QWS)
# include "qwsdisplay_qws.h"
@@ -168,6 +169,7 @@ static inline bool bypassGraphicsProxyWidget(QWidget *p)
#endif
extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); // qapplication.cpp
+extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp
QWidgetPrivate::QWidgetPrivate(int version) :
QObjectPrivate(version), extra(0), focus_child(0)
@@ -238,28 +240,6 @@ QWindowSurface *QWidgetPrivate::createDefaultWindowSurface()
/*!
\internal
- This is an internal function, you should never call this.
-
- This function is called to focus associated input context. The
- code intends to eliminate duplicate focus for the context even if
- the context is shared between widgets
-
- \sa QInputContext::setFocus()
- */
-void QWidgetPrivate::focusInputContext()
-{
-#ifndef QT_NO_IM
- Q_Q(QWidget);
- QInputContext *qic = q->inputContext();
- if (qic) {
- if(qic->focusWidget() != q)
- qic->setFocusWidget(q);
- }
-#endif // QT_NO_IM
-}
-
-/*!
- \internal
*/
void QWidgetPrivate::scrollChildren(int dx, int dy)
{
@@ -333,20 +313,24 @@ void QWidget::setInputContext(QInputContext *context)
/*!
+ \obsolete
+
This function can be called on the widget that currently has focus
to reset the input method operating on it.
- \sa QInputContext, QInputContext::reset()
+ This function is providing for convenience, instead you should use
+ \l{QInputContext::}{reset()} on the input context that was
+ returned by inputContext().
+
+ \sa QInputContext, inputContext(), QInputContext::reset()
*/
void QWidget::resetInputContext()
{
if (!hasFocus())
return;
#ifndef QT_NO_IM
- if (!d_func()->ic)
- return;
QInputContext *qic = this->inputContext();
- if( qic )
+ if(qic)
qic->reset();
#endif // QT_NO_IM
}
@@ -1405,7 +1389,13 @@ int QWidgetPrivate::maxInstances = 0; // Maximum number of widget instances
void QWidgetPrivate::setWinId(WId id) // set widget identifier
{
Q_Q(QWidget);
- if (mapper && data.winid) {
+ // the user might create a widget with Qt::Desktop window
+ // attribute (or create another QDesktopWidget instance), which
+ // will have the same windowid (the root window id) as the
+ // qt_desktopWidget. We should not add the second desktop widget
+ // to the mapper.
+ bool userDesktopWidget = qt_desktopWidget != 0 && qt_desktopWidget != q && q->windowType() == Qt::Desktop;
+ if (mapper && data.winid && !userDesktopWidget) {
mapper->remove(data.winid);
uncreatedWidgets->insert(q);
}
@@ -1414,7 +1404,7 @@ void QWidgetPrivate::setWinId(WId id) // set widget identifier
#if defined(Q_WS_X11)
hd = id; // X11: hd == ident
#endif
- if (mapper && id) {
+ if (mapper && id && !userDesktopWidget) {
mapper->insert(data.winid, q);
uncreatedWidgets->remove(q);
}
@@ -2257,9 +2247,10 @@ WId QWidget::effectiveWinId() const
The style sheet contains a textual description of customizations to the
widget's style, as described in the \l{Qt Style Sheets} document.
- \note Qt style sheets are currently not supported for QMacStyle
- (the default style on Mac OS X). We plan to address this in some future
- release.
+ Since Qt 4.5, Qt style sheets fully supports Mac OS X.
+
+ \warning Qt style sheets are currently not supported for custom QStyle
+ subclasses. We plan to address this in some future release.
\sa setStyle(), QApplication::styleSheet, {Qt Style Sheets}
*/
@@ -8990,17 +8981,36 @@ QWidget *QWidget::childAt(const QPoint &p) const
QWidget *QWidgetPrivate::childAt_helper(const QPoint &p, bool ignoreChildrenInDestructor) const
{
Q_Q(const QWidget);
- if (!q->rect().contains(p))
+#ifdef Q_WS_MAC
+ bool includeFrame = q->isWindow() && qobject_cast<const QMainWindow *>(q)
+ && static_cast<const QMainWindow *>(q)->unifiedTitleAndToolBarOnMac();
+#endif
+
+ if (
+#ifdef Q_WS_MAC
+ !includeFrame &&
+#endif
+ !q->rect().contains(p))
return 0;
+
for (int i = children.size(); i > 0 ;) {
--i;
QWidget *w = qobject_cast<QWidget *>(children.at(i));
- if (w && !w->isWindow() && !w->isHidden() && w->geometry().contains(p)) {
+ if (w && !w->isWindow() && !w->isHidden()
+ && (w->geometry().contains(p)
+#ifdef Q_WS_MAC
+ || (includeFrame && w->geometry().contains(qt_mac_nativeMapFromParent(w, p)))
+#endif
+ )) {
if (ignoreChildrenInDestructor && w->data->in_destructor)
continue;
if (w->testAttribute(Qt::WA_TransparentForMouseEvents))
continue;
QPoint childPoint = w->mapFromParent(p);
+#ifdef Q_WS_MAC
+ if (includeFrame && !w->geometry().contains(p))
+ childPoint = qt_mac_nativeMapFromParent(w, p);
+#endif
if (QWidget *t = w->d_func()->childAt_helper(childPoint, ignoreChildrenInDestructor))
return t;
// if WMouseNoMask is set the widget mask is ignored, if
@@ -9441,11 +9451,13 @@ void QWidget::repaint(const QRect &rect)
if (!isVisible() || !updatesEnabled() || rect.isEmpty())
return;
- QTLWExtra *tlwExtra = !d->paintOnScreen() ? window()->d_func()->maybeTopData() : 0;
- if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
- tlwExtra->inRepaint = true;
- tlwExtra->backingStore->markDirty(rect, this, true);
- tlwExtra->inRepaint = false;
+ if (hasBackingStoreSupport()) {
+ QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
+ if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
+ tlwExtra->inRepaint = true;
+ tlwExtra->backingStore->markDirty(rect, this, true);
+ tlwExtra->inRepaint = false;
+ }
} else {
d->repaint_sys(rect);
}
@@ -9468,11 +9480,13 @@ void QWidget::repaint(const QRegion &rgn)
if (!isVisible() || !updatesEnabled() || rgn.isEmpty())
return;
- QTLWExtra *tlwExtra = !d->paintOnScreen() ? window()->d_func()->maybeTopData() : 0;
- if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
- tlwExtra->inRepaint = true;
- tlwExtra->backingStore->markDirty(rgn, this, true);
- tlwExtra->inRepaint = false;
+ if (hasBackingStoreSupport()) {
+ QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
+ if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
+ tlwExtra->inRepaint = true;
+ tlwExtra->backingStore->markDirty(rgn, this, true);
+ tlwExtra->inRepaint = false;
+ }
} else {
d->repaint_sys(rgn);
}
@@ -9799,12 +9813,21 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
}
break;
#endif
- case Qt::WA_NativeWindow:
+ case Qt::WA_NativeWindow: {
+ QInputContext *ic = 0;
+ if (on && !internalWinId() && testAttribute(Qt::WA_InputMethodEnabled) && hasFocus()) {
+ ic = d->inputContext();
+ ic->reset();
+ ic->setFocusWidget(0);
+ }
if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget())
parentWidget()->d_func()->enforceNativeChildren();
if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created))
d->createWinId();
+ if (ic)
+ ic->setFocusWidget(this);
break;
+ }
case Qt::WA_PaintOnScreen:
d->updateIsOpaque();
#if defined(Q_WS_WIN) || defined(Q_WS_X11)
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index f599b7c..a00f969 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -295,9 +295,7 @@ bool qt_mac_is_macsheet(const QWidget *w)
Qt::WindowModality modality = w->windowModality();
if (modality == Qt::ApplicationModal)
return false;
- if (modality == Qt::WindowModal || w->windowType() == Qt::Sheet)
- return true;
- return false;
+ return w->parentWidget() && (modality == Qt::WindowModal || w->windowType() == Qt::Sheet);
}
bool qt_mac_is_macdrawer(const QWidget *w)
@@ -467,7 +465,18 @@ Q_GUI_EXPORT OSWindowRef qt_mac_window_for(const QWidget *w)
if (hiview){
OSWindowRef window = qt_mac_window_for(hiview);
if (!window && qt_isGenuineQWidget(hiview)) {
- w->window()->d_func()->createWindow_sys();
+ QWidget *myWindow = w->window();
+ // This is a workaround for NSToolbar. When a widget is hidden
+ // by clicking the toolbar button, Cocoa reparents the widgets
+ // to another window (but Qt doesn't know about it).
+ // When we start showing them, it reparents back,
+ // but at this point it's window is nil, but the window it's being brought
+ // into (the Qt one) is for sure created.
+ // This stops the hierarchy moving under our feet.
+ if (myWindow != w && qt_mac_window_for(qt_mac_nativeview_for(myWindow)))
+ return qt_mac_window_for(qt_mac_nativeview_for(myWindow));
+
+ myWindow->d_func()->createWindow_sys();
// Reget the hiview since the "create window could potentially move the view (I guess).
hiview = qt_mac_nativeview_for(w);
window = qt_mac_window_for(hiview);
@@ -2174,7 +2183,10 @@ void QWidgetPrivate::finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ voidWin
if ((popup || type == Qt::Tool || type == Qt::ToolTip) && !q->isModal()) {
[windowRef setHidesOnDeactivate:YES];
[windowRef setHasShadow:YES];
+ } else {
+ [windowRef setHidesOnDeactivate:NO];
}
+
Q_UNUSED(parentWidget);
Q_UNUSED(dialog);
@@ -2514,6 +2526,8 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
}
updateIsOpaque();
+ if (q->hasFocus())
+ setFocus_sys();
if (!topLevel && initializeWindow)
setWSGeometry();
@@ -2844,12 +2858,26 @@ void QWidgetPrivate::updateSystemBackground()
void QWidgetPrivate::setCursor_sys(const QCursor &)
{
+#ifndef QT_MAC_USE_COCOA
qt_mac_update_cursor();
+#else
+ Q_Q(QWidget);
+ if (q->testAttribute(Qt::WA_WState_Created)) {
+ [qt_mac_window_for(q) invalidateCursorRectsForView:qt_mac_nativeview_for(q)];
+ }
+#endif
}
void QWidgetPrivate::unsetCursor_sys()
{
+#ifndef QT_MAC_USE_COCOA
qt_mac_update_cursor();
+#else
+ Q_Q(QWidget);
+ if (q->testAttribute(Qt::WA_WState_Created)) {
+ [qt_mac_window_for(q) invalidateCursorRectsForView:qt_mac_nativeview_for(q)];
+ }
+#endif
}
void QWidgetPrivate::setWindowTitle_sys(const QString &caption)
@@ -3274,6 +3302,20 @@ void QWidgetPrivate::show_sys()
qt_event_request_window_change(q);
}
+
+QPoint qt_mac_nativeMapFromParent(const QWidget *child, const QPoint &pt)
+{
+#ifndef QT_MAC_USE_COCOA
+ CGPoint nativePoint = CGPointMake(pt.x(), pt.y());
+ HIViewConvertPoint(&nativePoint, qt_mac_nativeview_for(child->parentWidget()),
+ qt_mac_nativeview_for(child));
+#else
+ NSPoint nativePoint = [qt_mac_nativeview_for(child) convertPoint:NSMakePoint(pt.x(), pt.y()) fromView:qt_mac_nativeview_for(child->parentWidget())];
+#endif
+ return QPoint(nativePoint.x, nativePoint.y);
+}
+
+
void QWidgetPrivate::hide_sys()
{
Q_Q(QWidget);
@@ -3959,6 +4001,33 @@ void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
}
}
+void QWidgetPrivate::applyMaxAndMinSizeConstraints(int &w, int &h)
+{
+ if (QWExtra *extra = extraData()) {
+ w = qMin(w, extra->maxw);
+ h = qMin(h, extra->maxh);
+ w = qMax(w, extra->minw);
+ h = qMax(h, extra->minh);
+
+ // Deal with size increment
+ if (QTLWExtra *top = topData()) {
+ if(top->incw) {
+ w = w/top->incw;
+ w *= top->incw;
+ }
+ if(top->inch) {
+ h = h/top->inch;
+ h *= top->inch;
+ }
+ }
+ }
+
+ if (isRealWindow()) {
+ w = qMax(0, w);
+ h = qMax(0, h);
+ }
+}
+
void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
{
Q_Q(QWidget);
@@ -3969,7 +4038,9 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
QMacCocoaAutoReleasePool pool;
bool realWindow = isRealWindow();
+
if (realWindow && !(w == 0 && h == 0) && !q->testAttribute(Qt::WA_DontShowOnScreen)) {
+ applyMaxAndMinSizeConstraints(w, h);
topData()->isSetGeometry = 1;
topData()->isMove = isMove;
#ifndef QT_MAC_USE_COCOA
@@ -3995,10 +4066,26 @@ void QWidgetPrivate::setGeometry_sys_helper(int x, int y, int w, int h, bool isM
{
Q_Q(QWidget);
bool realWindow = isRealWindow();
- if(QWExtra *extra = extraData()) { // any size restrictions?
- if(realWindow) {
+
+ QPoint oldp = q->pos();
+ QSize olds = q->size();
+ const bool isResize = (olds != QSize(w, h));
+
+ if (!realWindow && !isResize && QPoint(x, y) == oldp)
+ return;
+
+ if (isResize)
+ data.window_state = data.window_state & ~Qt::WindowMaximized;
+
+ const bool visible = q->isVisible();
+ data.crect = QRect(x, y, w, h);
+
+ if (realWindow) {
+ if (QWExtra *extra = extraData()) {
+ applyMaxAndMinSizeConstraints(w, h);
qt_mac_update_sizer(q);
- if(q->windowFlags() & Qt::WindowMaximizeButtonHint) {
+
+ if (q->windowFlags() & Qt::WindowMaximizeButtonHint) {
#ifndef QT_MAC_USE_COCOA
OSWindowRef window = qt_mac_window_for(q);
if(extra->maxw && extra->maxh && extra->maxw == extra->minw
@@ -4009,43 +4096,8 @@ void QWidgetPrivate::setGeometry_sys_helper(int x, int y, int w, int h, bool isM
}
#endif
}
- }
- w = qMin(w,extra->maxw);
- h = qMin(h,extra->maxh);
- w = qMax(w,extra->minw);
- h = qMax(h,extra->minh);
-
- // Deal with size increment
- if(QTLWExtra *top = topData()) {
- if(top->incw) {
- w = w/top->incw;
- w *= top->incw;
- }
- if(top->inch) {
- h = h/top->inch;
- h *= top->inch;
- }
- }
- }
-
- if (realWindow) {
- w = qMax(0, w);
- h = qMax(0, h);
- }
-
- QPoint oldp = q->pos();
- QSize olds = q->size();
- const bool isResize = (olds != QSize(w, h));
- if(!realWindow && !isResize && QPoint(x, y) == oldp)
- return;
- if(isResize && q->isMaximized())
- data.window_state = data.window_state & ~Qt::WindowMaximized;
- const bool visible = q->isVisible();
- data.crect = QRect(x, y, w, h);
-
- if(realWindow) {
- if(QWExtra *extra = extraData()) { //set constraints
+ // Update max and min constraints:
const float max_f(20000);
#ifndef QT_MAC_USE_COCOA
#define SF(x) ((x > max_f) ? max_f : x)
@@ -4581,12 +4633,15 @@ void QWidgetPrivate::setModal_sys()
OSWindowRef windowRef = qt_mac_window_for(q);
#ifdef QT_MAC_USE_COCOA
- bool windowIsSheet = [windowRef styleMask] & NSDocModalWindowMask;
+ bool alreadySheet = [windowRef styleMask] & NSDocModalWindowMask;
- if (q->windowModality() == Qt::WindowModal){
+ if (windowParent && q->windowModality() == Qt::WindowModal){
// Window should be window-modal, which implies a sheet.
- if (!windowIsSheet)
+ if (!alreadySheet) {
+ // NB: the following call will call setModal_sys recursivly:
recreateMacWindow();
+ windowRef = qt_mac_window_for(q);
+ }
if ([windowRef isKindOfClass:[NSPanel class]]){
// If the primary window of the sheet parent is a child of a modal dialog,
// the sheet parent should not be modally shaddowed.
@@ -4599,7 +4654,7 @@ void QWidgetPrivate::setModal_sys()
}
} else {
// Window shold not be window-modal, and as such, not a sheet.
- if (windowIsSheet){
+ if (alreadySheet){
// NB: the following call will call setModal_sys recursivly:
recreateMacWindow();
windowRef = qt_mac_window_for(q);
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
index 362571f..ec64b6e 100644
--- a/src/gui/kernel/qwidget_p.h
+++ b/src/gui/kernel/qwidget_p.h
@@ -267,6 +267,7 @@ public:
void macUpdateIsOpaque();
void setEnabled_helper_sys(bool enable);
bool isRealWindow() const;
+ void applyMaxAndMinSizeConstraints(int &w, int &h);
#endif
void raise_sys();
@@ -364,8 +365,6 @@ public:
void setWindowIcon_sys(bool forceReset = false);
void setWindowOpacity_sys(qreal opacity);
- void focusInputContext();
-
void adjustQuitOnCloseAttribute();
#if defined(Q_WS_X11)
diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp
index a12b50c..76734d4 100644
--- a/src/gui/kernel/qwidget_x11.cpp
+++ b/src/gui/kernel/qwidget_x11.cpp
@@ -898,7 +898,7 @@ void QWidgetPrivate::x11UpdateIsOpaque()
bool visible = q->isVisible();
if (visible)
q->hide();
- q->setParent(q->parentWidget(), q->windowFlags() & ~Qt::WindowType_Mask);
+ q->setParent(q->parentWidget(), q->windowFlags());
q->move(pos);
if (visible)
q->show();
@@ -1516,7 +1516,6 @@ void QWidget::activateWindow()
X11->userTime = X11->time;
qt_net_update_user_time(tlw, X11->userTime);
XSetInputFocus(X11->display, tlw->internalWinId(), XRevertToParent, X11->time);
- d->focusInputContext();
}
}
@@ -1751,8 +1750,8 @@ void QWidgetPrivate::show_sys()
mwmhints.functions &= ~MWM_FUNC_RESIZE;
}
- mwmhints.flags |= MWM_HINTS_DECORATIONS;
if (mwmhints.decorations == MWM_DECOR_ALL) {
+ mwmhints.flags |= MWM_HINTS_DECORATIONS;
mwmhints.decorations = (MWM_DECOR_BORDER
| MWM_DECOR_TITLE
| MWM_DECOR_MENU);
@@ -1761,10 +1760,12 @@ void QWidgetPrivate::show_sys()
}
if (q->windowFlags() & Qt::WindowMinimizeButtonHint) {
+ mwmhints.flags |= MWM_HINTS_DECORATIONS;
mwmhints.decorations |= MWM_DECOR_MINIMIZE;
mwmhints.functions |= MWM_FUNC_MINIMIZE;
}
if (q->windowFlags() & Qt::WindowMaximizeButtonHint) {
+ mwmhints.flags |= MWM_HINTS_DECORATIONS;
mwmhints.decorations |= MWM_DECOR_MAXIMIZE;
mwmhints.functions |= MWM_FUNC_MAXIMIZE;
}
diff --git a/src/gui/kernel/qx11embed_x11.cpp b/src/gui/kernel/qx11embed_x11.cpp
index e49c4d6..6329135 100644
--- a/src/gui/kernel/qx11embed_x11.cpp
+++ b/src/gui/kernel/qx11embed_x11.cpp
@@ -481,7 +481,7 @@ QX11EmbedWidget::QX11EmbedWidget(QWidget *parent)
| ExposureMask | StructureNotifyMask
| SubstructureNotifyMask | PropertyChangeMask);
- unsigned int data[] = {XEMBED_VERSION, XEMBED_MAPPED};
+ long data[] = {XEMBED_VERSION, XEMBED_MAPPED};
XChangeProperty(x11Info().display(), internalWinId(), ATOM(_XEMBED_INFO),
ATOM(_XEMBED_INFO), 32, PropModeReplace,
(unsigned char*) data, 2);
@@ -1571,7 +1571,7 @@ void QX11EmbedContainer::showEvent(QShowEvent *)
{
Q_D(QX11EmbedContainer);
if (d->client) {
- unsigned int data[] = {XEMBED_VERSION, XEMBED_MAPPED};
+ long data[] = {XEMBED_VERSION, XEMBED_MAPPED};
XChangeProperty(x11Info().display(), d->client, ATOM(_XEMBED_INFO), ATOM(_XEMBED_INFO), 32,
PropModeReplace, (unsigned char *) data, 2);
}
@@ -1587,8 +1587,7 @@ void QX11EmbedContainer::hideEvent(QHideEvent *)
{
Q_D(QX11EmbedContainer);
if (d->client) {
- unsigned int data[] = {XEMBED_VERSION, XEMBED_MAPPED};
-
+ long data[] = {XEMBED_VERSION, XEMBED_MAPPED};
XChangeProperty(x11Info().display(), d->client, ATOM(_XEMBED_INFO), ATOM(_XEMBED_INFO), 32,
PropModeReplace, (unsigned char *) data, 2);
}
diff --git a/src/gui/painting/qblendfunctions.cpp b/src/gui/painting/qblendfunctions.cpp
index d2f4ab7..dd7b016 100644
--- a/src/gui/painting/qblendfunctions.cpp
+++ b/src/gui/painting/qblendfunctions.cpp
@@ -44,19 +44,6 @@
QT_BEGIN_NAMESPACE
-
-// This ifdef is made with the best of intention. GCC fails to
-// optimzie the code properly so the bytemul approach is the fastest
-// it gets. Both on ARM and on MSVC the code is optimized to be better
-// than the bytemul approach... On the other hand... This code is
-// almost never run on i386 so it may be downright silly to have this
-// piece of code here...
-#if defined (Q_CC_GNU) && (defined (QT_ARCH_I386) || defined (QT_ARCH_X86_64))
-# define QT_BLEND_USE_BYTEMUL
-#endif
-
-// #define QT_DEBUG_DRAW
-
static const qreal aliasedCoordinateDelta = 0.5 - 0.015625;
struct SourceOnlyAlpha
@@ -286,7 +273,7 @@ static void qt_blend_rgb16_on_rgb16(uchar *dst, int dbpl,
int const_alpha)
{
#ifdef QT_DEBUG_DRAW
- printf("qt_blend_argb16_on_rgb16: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
+ printf("qt_blend_rgb16_on_rgb16: dst=(%p, %d), src=(%p, %d), dim=(%d, %d) alpha=%d\n",
dst, dbpl, src, sbpl, w, h, const_alpha);
#endif
@@ -347,11 +334,6 @@ template <typename T> void qt_blend_argb24_on_rgb16(uchar *destPixels, int dbpl,
if (alpha == 255) {
*dst = spix;
} else if (alpha != 0) {
-#ifdef QT_BLEND_USE_BYTEMUL
- // truncate green channel to avoid overflow
- *dst = (alphaFunc.bytemul(spix) & 0xffdf)
- + (quint16) qrgb565(*dst).byte_mul(qrgb565::ialpha(alpha));
-#else
quint16 dpix = *dst;
quint32 sia = 255 - alpha;
@@ -363,12 +345,11 @@ template <typename T> void qt_blend_argb24_on_rgb16(uchar *destPixels, int dbpl,
quint32 siag = dg * sia;
quint32 siab = db * sia;
- quint32 rr = ((siar + (siar>>8) + (0x80 << 11)) >> 8) & 0xf800;
- quint32 rg = ((siag + (siag>>8) + (0x80 << 5)) >> 8) & 0x07e0;
- quint32 rb = ((siab + (siab>>8) + (0x80 >> 3)) >> 8);
+ quint32 rr = ((siar + (siar>>8) + (0x80 << 8)) >> 8) & 0xf800;
+ quint32 rg = ((siag + (siag>>8) + (0x80 << 3)) >> 8) & 0x07e0;
+ quint32 rb = ((siab + (siab>>8) + (0x80 >> 3)) >> 8) & 0x001f;
*dst = alphaFunc.bytemul(spix) + rr + rg + rb;
-#endif
}
++dst;
@@ -435,111 +416,45 @@ static void qt_blend_argb32_on_rgb16(uchar *destPixels, int dbpl,
}
quint16 *dst = (quint16 *) destPixels;
- int dstExtraStride = dbpl / 2 - w;
-
- const quint32 *src = (const quint32 *) srcPixels;
- int srcExtraStride = sbpl / 4 - w;
+ quint32 *src = (quint32 *) srcPixels;
for (int y=0; y<h; ++y) {
- int length = w;
- const int dstAlign = ((quintptr)dst) & 0x3;
- if (dstAlign) {
- const quint8 alpha = qAlpha(*src);
- if (alpha) {
- quint16 s = convert_argb32_to_rgb16(*src);
- if (alpha < 255)
- s += BYTE_MUL_RGB16(*dst, 255 - alpha);
- *dst = s;
- }
- ++dst;
- ++src;
- --length;
- }
+ for (int x=0; x<w; ++x) {
- const int length32 = length >> 1;
- const int srcAlign = ((quintptr)src) & 0x3;
- if (length32) {
- if (srcAlign) {
- for (int i = 0; i < length32; ++i) {
- quint32 *dest32 = reinterpret_cast<quint32*>(dst);
- const quint8 a1 = qAlpha(src[0]);
- const quint8 a2 = qAlpha(src[1]);
- quint32 s;
-
- if (!a1 && !a2) {
- src += 2;
- dst +=2;
- continue;
- }
-
- s = convert_argb32_to_rgb16(src[0])
- | (convert_argb32_to_rgb16(src[1]) << 16);
-
- if (a1 == a2) {
- if (a1 < 255) {
- const quint8 sa = ((255 - a1)+1) >> 3;
- s += BYTE_MUL_RGB16_32(*dest32, sa);
- }
- } else {
- if (a1 < 255)
- s += BYTE_MUL_RGB16(dst[0], 255 - a1);
- if (a2 < 255)
- s += BYTE_MUL_RGB16(dst[1], 255 - a2) << 16;
- }
-
- *dest32 = s;
- src += 2;
- dst += 2;
- }
- } else {
- for (int i = 0; i < length32; ++i) {
- quint32 *dest32 = reinterpret_cast<quint32*>(dst);
- const quint8 a1 = qAlpha(src[0]);
- const quint8 a2 = qAlpha(src[1]);
- quint32 s;
-
- if (!a1 && !a2) {
- src += 2;
- dst +=2;
- continue;
- }
-
- const quint64 *src64 =
- reinterpret_cast<const quint64*>(src);
- s = qConvertRgb32To16x2(*src64);
-
- if (a1 == a2) {
- if (a1 < 255) {
- const quint8 sa = ((255 - a1)+1) >> 3;
- s += BYTE_MUL_RGB16_32(*dest32, sa);
- }
- } else {
- if (a1 < 255)
- s += BYTE_MUL_RGB16(dst[0], 255 - a1);
- if (a2 < 255)
- s += BYTE_MUL_RGB16(dst[1], 255 - a2) << 16;
- }
-
- *dest32 = s;
- src += 2;
- dst += 2;
- }
- }
- }
- const int tail = length & 0x1;
- if (tail) {
- const quint8 alpha = qAlpha(*src);
- if (alpha) {
- quint16 s = convert_argb32_to_rgb16(*src);
- if (alpha < 255)
- s += BYTE_MUL_RGB16(*dst, 255 - alpha);
- *dst = s;
+ quint32 spix = src[x];
+ quint32 alpha = spix >> 24;
+
+ if (alpha == 255) {
+ dst[x] = convert_argb32_to_rgb16(spix);
+ } else if (alpha != 0) {
+ quint32 dpix = dst[x];
+
+ quint32 sia = 255 - alpha;
+
+ quint32 sr = (spix >> 8) & 0xf800;
+ quint32 sg = (spix >> 5) & 0x07e0;
+ quint32 sb = (spix >> 3) & 0x001f;
+
+ quint32 dr = (dpix & 0x0000f800);
+ quint32 dg = (dpix & 0x000007e0);
+ quint32 db = (dpix & 0x0000001f);
+
+ quint32 siar = dr * sia;
+ quint32 siag = dg * sia;
+ quint32 siab = db * sia;
+
+ quint32 rr = sr + ((siar + (siar>>8) + (0x80 << 8)) >> 8);
+ quint32 rg = sg + ((siag + (siag>>8) + (0x80 << 3)) >> 8);
+ quint32 rb = sb + ((siab + (siab>>8) + (0x80 >> 3)) >> 8);
+
+ dst[x] = (rr & 0xf800)
+ | (rg & 0x07e0)
+ | (rb);
}
}
- dst += dstExtraStride;
- src += srcExtraStride;
+ dst = (quint16 *) (((uchar *) dst) + dbpl);
+ src = (quint32 *) (((uchar *) src) + sbpl);
}
-
}
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index efdc778..c11837a 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -370,7 +370,7 @@ Q_STATIC_TEMPLATE_FUNCTION void QT_FASTCALL destStore(QRasterBuffer *rasterBuffe
Q_TEMPLATE_FIX(DST))
{
DST *dest = reinterpret_cast<DST*>(rasterBuffer->scanLine(y)) + x;
- const quint32 *src = reinterpret_cast<const quint32*>(buffer);
+ const quint32p *src = reinterpret_cast<const quint32p*>(buffer);
while (length--)
*dest++ = DST(*src++);
}
@@ -4763,7 +4763,7 @@ void QT_FASTCALL blendUntransformed(int count, const QSpan *spans, void *userDat
static void blend_untransformed_rgb888(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_24)
+#if defined(QT_QWS_DEPTH_24)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_RGB888)
@@ -4777,7 +4777,7 @@ static void blend_untransformed_rgb888(int count, const QSpan *spans,
static void blend_untransformed_argb6666(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_18)
+#if defined(QT_QWS_DEPTH_18)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
@@ -4793,7 +4793,7 @@ static void blend_untransformed_argb6666(int count, const QSpan *spans,
static void blend_untransformed_rgb666(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_18)
+#if defined(QT_QWS_DEPTH_18)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
@@ -4809,7 +4809,7 @@ static void blend_untransformed_rgb666(int count, const QSpan *spans,
static void blend_untransformed_argb8565(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
+#if defined(QT_QWS_DEPTH_16)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
@@ -4825,7 +4825,7 @@ static void blend_untransformed_argb8565(int count, const QSpan *spans,
static void blend_untransformed_rgb565(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
+#if defined(QT_QWS_DEPTH_16)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
@@ -4841,7 +4841,7 @@ static void blend_untransformed_rgb565(int count, const QSpan *spans,
static void blend_untransformed_argb8555(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_15)
+#if defined(QT_QWS_DEPTH_15)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
@@ -4857,7 +4857,7 @@ static void blend_untransformed_argb8555(int count, const QSpan *spans,
static void blend_untransformed_rgb555(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_15)
+#if defined(QT_QWS_DEPTH_15)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
@@ -4873,7 +4873,7 @@ static void blend_untransformed_rgb555(int count, const QSpan *spans,
static void blend_untransformed_argb4444(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_12)
+#if defined(QT_QWS_DEPTH_12)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
@@ -4889,7 +4889,7 @@ static void blend_untransformed_argb4444(int count, const QSpan *spans,
static void blend_untransformed_rgb444(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_12)
+#if defined(QT_QWS_DEPTH_12)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
@@ -5084,7 +5084,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTiled(int count, const QSpan *spans, void *
static void blend_tiled_rgb888(int count, const QSpan *spans, void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_24)
+#if defined(QT_QWS_DEPTH_24)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_RGB888)
@@ -5097,7 +5097,7 @@ static void blend_tiled_rgb888(int count, const QSpan *spans, void *userData)
static void blend_tiled_argb6666(int count, const QSpan *spans, void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_18)
+#if defined(QT_QWS_DEPTH_18)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
@@ -5112,7 +5112,7 @@ static void blend_tiled_argb6666(int count, const QSpan *spans, void *userData)
static void blend_tiled_rgb666(int count, const QSpan *spans, void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_18)
+#if defined(QT_QWS_DEPTH_18)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
@@ -5127,7 +5127,7 @@ static void blend_tiled_rgb666(int count, const QSpan *spans, void *userData)
static void blend_tiled_argb8565(int count, const QSpan *spans, void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
+#if defined(QT_QWS_DEPTH_16)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
@@ -5142,7 +5142,7 @@ static void blend_tiled_argb8565(int count, const QSpan *spans, void *userData)
static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
+#if defined(QT_QWS_DEPTH_16)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
@@ -5157,7 +5157,7 @@ static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData)
static void blend_tiled_argb8555(int count, const QSpan *spans, void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_15)
+#if defined(QT_QWS_DEPTH_15)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
@@ -5172,7 +5172,7 @@ static void blend_tiled_argb8555(int count, const QSpan *spans, void *userData)
static void blend_tiled_rgb555(int count, const QSpan *spans, void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_15)
+#if defined(QT_QWS_DEPTH_15)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
@@ -5187,7 +5187,7 @@ static void blend_tiled_rgb555(int count, const QSpan *spans, void *userData)
static void blend_tiled_argb4444(int count, const QSpan *spans, void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_12)
+#if defined(QT_QWS_DEPTH_12)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
@@ -5202,7 +5202,7 @@ static void blend_tiled_argb4444(int count, const QSpan *spans, void *userData)
static void blend_tiled_rgb444(int count, const QSpan *spans, void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_12)
+#if defined(QT_QWS_DEPTH_12)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
@@ -5599,7 +5599,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformedBilinear(int count, const QSpan
static void blend_transformed_bilinear_rgb888(int count, const QSpan *spans, void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_24)
+#if defined(QT_QWS_DEPTH_24)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_RGB888)
@@ -5612,7 +5612,7 @@ static void blend_transformed_bilinear_rgb888(int count, const QSpan *spans, voi
static void blend_transformed_bilinear_argb6666(int count, const QSpan *spans, void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_18)
+#if defined(QT_QWS_DEPTH_18)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
@@ -5627,7 +5627,7 @@ static void blend_transformed_bilinear_argb6666(int count, const QSpan *spans, v
static void blend_transformed_bilinear_rgb666(int count, const QSpan *spans, void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_18)
+#if defined(QT_QWS_DEPTH_18)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
@@ -5642,7 +5642,7 @@ static void blend_transformed_bilinear_rgb666(int count, const QSpan *spans, voi
static void blend_transformed_bilinear_argb8565(int count, const QSpan *spans, void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
+#if defined(QT_QWS_DEPTH_16)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
@@ -5658,7 +5658,7 @@ static void blend_transformed_bilinear_argb8565(int count, const QSpan *spans, v
static void blend_transformed_bilinear_rgb565(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
+#if defined(QT_QWS_DEPTH_16)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_RGB16)
@@ -5673,7 +5673,7 @@ static void blend_transformed_bilinear_rgb565(int count, const QSpan *spans,
static void blend_transformed_bilinear_argb8555(int count, const QSpan *spans, void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_15)
+#if defined(QT_QWS_DEPTH_15)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
@@ -5688,7 +5688,7 @@ static void blend_transformed_bilinear_argb8555(int count, const QSpan *spans, v
static void blend_transformed_bilinear_rgb555(int count, const QSpan *spans, void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_15)
+#if defined(QT_QWS_DEPTH_15)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
@@ -5703,7 +5703,7 @@ static void blend_transformed_bilinear_rgb555(int count, const QSpan *spans, voi
static void blend_transformed_bilinear_argb4444(int count, const QSpan *spans, void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_12)
+#if defined(QT_QWS_DEPTH_12)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
@@ -5718,7 +5718,7 @@ static void blend_transformed_bilinear_argb4444(int count, const QSpan *spans, v
static void blend_transformed_bilinear_rgb444(int count, const QSpan *spans, void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_12)
+#if defined(QT_QWS_DEPTH_12)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
@@ -6195,7 +6195,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformed(int count, const QSpan *spans,
static void blend_transformed_rgb888(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_24)
+#if defined(QT_QWS_DEPTH_24)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_RGB888)
@@ -6209,7 +6209,7 @@ static void blend_transformed_rgb888(int count, const QSpan *spans,
static void blend_transformed_argb6666(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_18)
+#if defined(QT_QWS_DEPTH_18)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
@@ -6225,7 +6225,7 @@ static void blend_transformed_argb6666(int count, const QSpan *spans,
static void blend_transformed_rgb666(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_18)
+#if defined(QT_QWS_DEPTH_18)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
@@ -6241,7 +6241,7 @@ static void blend_transformed_rgb666(int count, const QSpan *spans,
static void blend_transformed_argb8565(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
+#if defined(QT_QWS_DEPTH_16)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
@@ -6257,7 +6257,7 @@ static void blend_transformed_argb8565(int count, const QSpan *spans,
static void blend_transformed_rgb565(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
+#if defined(QT_QWS_DEPTH_16)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
@@ -6273,7 +6273,7 @@ static void blend_transformed_rgb565(int count, const QSpan *spans,
static void blend_transformed_argb8555(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_15)
+#if defined(QT_QWS_DEPTH_15)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
@@ -6289,7 +6289,7 @@ static void blend_transformed_argb8555(int count, const QSpan *spans,
static void blend_transformed_rgb555(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_15)
+#if defined(QT_QWS_DEPTH_15)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
@@ -6305,7 +6305,7 @@ static void blend_transformed_rgb555(int count, const QSpan *spans,
static void blend_transformed_argb4444(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_12)
+#if defined(QT_QWS_DEPTH_12)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
@@ -6321,7 +6321,7 @@ static void blend_transformed_argb4444(int count, const QSpan *spans,
static void blend_transformed_rgb444(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_12)
+#if defined(QT_QWS_DEPTH_12)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
@@ -6619,7 +6619,7 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformedTiled(int count, const QSpan *sp
static void blend_transformed_tiled_rgb888(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_24)
+#if defined(QT_QWS_DEPTH_24)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_RGB888)
@@ -6633,7 +6633,7 @@ static void blend_transformed_tiled_rgb888(int count, const QSpan *spans,
static void blend_transformed_tiled_argb6666(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_18)
+#if defined(QT_QWS_DEPTH_18)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
@@ -6649,7 +6649,7 @@ static void blend_transformed_tiled_argb6666(int count, const QSpan *spans,
static void blend_transformed_tiled_rgb666(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_18)
+#if defined(QT_QWS_DEPTH_18)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
@@ -6665,7 +6665,7 @@ static void blend_transformed_tiled_rgb666(int count, const QSpan *spans,
static void blend_transformed_tiled_argb8565(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
+#if defined(QT_QWS_DEPTH_16)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
@@ -6681,7 +6681,7 @@ static void blend_transformed_tiled_argb8565(int count, const QSpan *spans,
static void blend_transformed_tiled_rgb565(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
+#if defined(QT_QWS_DEPTH_16)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
@@ -6697,7 +6697,7 @@ static void blend_transformed_tiled_rgb565(int count, const QSpan *spans,
static void blend_transformed_tiled_argb8555(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_15)
+#if defined(QT_QWS_DEPTH_15)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
@@ -6713,7 +6713,7 @@ static void blend_transformed_tiled_argb8555(int count, const QSpan *spans,
static void blend_transformed_tiled_rgb555(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_15)
+#if defined(QT_QWS_DEPTH_15)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
@@ -6729,7 +6729,7 @@ static void blend_transformed_tiled_rgb555(int count, const QSpan *spans,
static void blend_transformed_tiled_argb4444(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_12)
+#if defined(QT_QWS_DEPTH_12)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
@@ -6745,7 +6745,7 @@ static void blend_transformed_tiled_argb4444(int count, const QSpan *spans,
static void blend_transformed_tiled_rgb444(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_12)
+#if defined(QT_QWS_DEPTH_12)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
diff --git a/src/gui/painting/qmemrotate.cpp b/src/gui/painting/qmemrotate.cpp
index 7ad0e42..4058143 100644
--- a/src/gui/painting/qmemrotate.cpp
+++ b/src/gui/painting/qmemrotate.cpp
@@ -537,6 +537,7 @@ QT_IMPL_MEMROTATE(quint32, quint24)
QT_IMPL_MEMROTATE(quint32, quint18)
QT_IMPL_MEMROTATE(quint32, quint8)
QT_IMPL_MEMROTATE(quint16, quint8)
+QT_IMPL_MEMROTATE(qrgb444, quint8)
QT_IMPL_MEMROTATE(quint8, quint8)
#ifdef QT_QWS_DEPTH_GENERIC
QT_IMPL_MEMROTATE(quint32, qrgb_generic16)
diff --git a/src/gui/painting/qmemrotate_p.h b/src/gui/painting/qmemrotate_p.h
index bd6006b..c1eb93e 100644
--- a/src/gui/painting/qmemrotate_p.h
+++ b/src/gui/painting/qmemrotate_p.h
@@ -90,6 +90,7 @@ QT_DECL_MEMROTATE(quint32, quint24);
QT_DECL_MEMROTATE(quint32, quint18);
QT_DECL_MEMROTATE(quint32, quint8);
QT_DECL_MEMROTATE(quint16, quint8);
+QT_DECL_MEMROTATE(qrgb444, quint8);
QT_DECL_MEMROTATE(quint8, quint8);
#ifdef QT_QWS_DEPTH_GENERIC
QT_DECL_MEMROTATE(quint32, qrgb_generic16);
diff --git a/src/gui/painting/qpaintengine_alpha.cpp b/src/gui/painting/qpaintengine_alpha.cpp
index e38f6a4..74cbebe 100644
--- a/src/gui/painting/qpaintengine_alpha.cpp
+++ b/src/gui/painting/qpaintengine_alpha.cpp
@@ -80,6 +80,7 @@ bool QAlphaPaintEngine::begin(QPaintDevice *pdev)
d->m_advancedPen = false;
d->m_advancedBrush = false;
d->m_complexTransform = false;
+ d->m_emulateProjectiveTransforms = false;
// clear alpha region
d->m_alphargn = QRegion();
@@ -116,6 +117,9 @@ void QAlphaPaintEngine::updateState(const QPaintEngineState &state)
if (flags & QPaintEngine::DirtyTransform) {
d->m_transform = state.transform();
d->m_complexTransform = (d->m_transform.type() > QTransform::TxScale);
+ d->m_emulateProjectiveTransforms = !(d->m_savedcaps & QPaintEngine::PerspectiveTransform)
+ && !(d->m_savedcaps & QPaintEngine::AlphaBlend)
+ && (d->m_transform.type() >= QTransform::TxProject);
}
if (flags & QPaintEngine::DirtyPen) {
d->m_pen = state.pen();
@@ -163,7 +167,9 @@ void QAlphaPaintEngine::drawPath(const QPainterPath &path)
if (d->m_pass == 0) {
d->m_continueCall = false;
- if (d->m_hasalpha || d->m_advancedPen || d->m_advancedBrush) {
+ if (d->m_hasalpha || d->m_advancedPen || d->m_advancedBrush
+ || d->m_emulateProjectiveTransforms)
+ {
d->addAlphaRect(tr);
}
if (d->m_picengine)
@@ -187,7 +193,9 @@ void QAlphaPaintEngine::drawPolygon(const QPointF *points, int pointCount, Polyg
if (d->m_pass == 0) {
d->m_continueCall = false;
- if (d->m_hasalpha || d->m_advancedPen || d->m_advancedBrush) {
+ if (d->m_hasalpha || d->m_advancedPen || d->m_advancedBrush
+ || d->m_emulateProjectiveTransforms)
+ {
d->addAlphaRect(tr);
}
diff --git a/src/gui/painting/qpaintengine_alpha_p.h b/src/gui/painting/qpaintengine_alpha_p.h
index f510c73..f7d7a34 100644
--- a/src/gui/painting/qpaintengine_alpha_p.h
+++ b/src/gui/painting/qpaintengine_alpha_p.h
@@ -113,6 +113,7 @@ public:
bool m_advancedPen;
bool m_advancedBrush;
bool m_complexTransform;
+ bool m_emulateProjectiveTransforms;
bool m_continueCall;
QTransform m_transform;
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index c3addd8..19b2574 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -1142,6 +1142,33 @@ void QRasterPaintEnginePrivate::updateMatrixData(QSpanData *spanData, const QBru
}
}
+// #define QT_CLIPPING_RATIOS
+
+#ifdef QT_CLIPPING_RATIOS
+int rectClips;
+int regionClips;
+int totalClips;
+
+static void checkClipRatios(QRasterPaintEnginePrivate *d)
+{
+ if (d->clip()->hasRectClip)
+ rectClips++;
+ if (d->clip()->hasRegionClip)
+ regionClips++;
+ totalClips++;
+
+ if ((totalClips % 5000) == 0) {
+ printf("Clipping ratio: rectangular=%f%%, region=%f%%, complex=%f%%\n",
+ rectClips * 100.0 / (qreal) totalClips,
+ regionClips * 100.0 / (qreal) totalClips,
+ (totalClips - rectClips - regionClips) * 100.0 / (qreal) totalClips);
+ totalClips = 0;
+ rectClips = 0;
+ regionClips = 0;
+ }
+
+}
+#endif
/*!
\internal
@@ -1243,6 +1270,10 @@ void QRasterPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op)
d->solid_color_filler.clip = d->clip();
d->solid_color_filler.adjustSpanMethods();
+
+#ifdef QT_CLIPPING_RATIOS
+ checkClipRatios(d);
+#endif
}
@@ -1317,6 +1348,11 @@ void QRasterPaintEngine::clip(const QRect &rect, Qt::ClipOperation op)
d->solid_color_filler.clip = d->clip();
d->solid_color_filler.adjustSpanMethods();
+
+
+#ifdef QT_CLIPPING_RATIOS
+ checkClipRatios(d);
+#endif
}
/*!
@@ -1531,7 +1567,7 @@ void QRasterPaintEngine::drawRects(const QRectF *rects, int rectCount)
d->initializeRasterizer(&s->brushData);
for (int i = 0; i < rectCount; ++i) {
const QRectF &rect = rects[i].normalized();
- if (rects[i].isEmpty())
+ if (rect.isEmpty())
continue;
const QPointF a = s->matrix.map((rect.topLeft() + rect.bottomLeft()) * 0.5f);
const QPointF b = s->matrix.map((rect.topRight() + rect.bottomRight()) * 0.5f);
@@ -2357,11 +2393,6 @@ void QRasterPaintEngine::strokePolygonCosmetic(const QPoint *points, int pointCo
}
}
-#define IMAGE_FROM_PIXMAP(pixmap) \
- pixmap.data->classId() == QPixmapData::RasterClass \
- ? ((QRasterPixmapData *) pixmap.data)->image \
- : pixmap.toImage()
-
/*!
\internal
*/
@@ -2370,16 +2401,33 @@ void QRasterPaintEngine::drawPixmap(const QPointF &pos, const QPixmap &pixmap)
#ifdef QT_DEBUG_DRAW
qDebug() << " - QRasterPaintEngine::drawPixmap(), pos=" << pos << " pixmap=" << pixmap.size() << "depth=" << pixmap.depth();
#endif
- if (pixmap.depth() == 1) {
- Q_D(QRasterPaintEngine);
- QRasterPaintEngineState *s = state();
- if (s->matrix.type() <= QTransform::TxTranslate) {
- drawBitmap(pos + QPointF(s->matrix.dx(), s->matrix.dy()), pixmap, &s->penData);
+
+ if (pixmap.data->classId() == QPixmapData::RasterClass) {
+ const QImage &image = ((QRasterPixmapData *) pixmap.data)->image;
+ if (image.depth() == 1) {
+ Q_D(QRasterPaintEngine);
+ QRasterPaintEngineState *s = state();
+ if (s->matrix.type() <= QTransform::TxTranslate) {
+ drawBitmap(pos + QPointF(s->matrix.dx(), s->matrix.dy()), image, &s->penData);
+ } else {
+ drawImage(pos, d->rasterBuffer->colorizeBitmap(image, s->pen.color()));
+ }
} else {
- drawImage(pos, d->rasterBuffer->colorizeBitmap(IMAGE_FROM_PIXMAP(pixmap), s->pen.color()));
+ QRasterPaintEngine::drawImage(pos, image);
}
} else {
- QRasterPaintEngine::drawImage(pos, IMAGE_FROM_PIXMAP(pixmap));
+ const QImage image = pixmap.toImage();
+ if (pixmap.depth() == 1) {
+ Q_D(QRasterPaintEngine);
+ QRasterPaintEngineState *s = state();
+ if (s->matrix.type() <= QTransform::TxTranslate) {
+ drawBitmap(pos + QPointF(s->matrix.dx(), s->matrix.dy()), image, &s->penData);
+ } else {
+ drawImage(pos, d->rasterBuffer->colorizeBitmap(image, s->pen.color()));
+ }
+ } else {
+ QRasterPaintEngine::drawImage(pos, image);
+ }
}
}
@@ -2392,22 +2440,40 @@ void QRasterPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap, cons
qDebug() << " - QRasterPaintEngine::drawPixmap(), r=" << r << " sr=" << sr << " pixmap=" << pixmap.size() << "depth=" << pixmap.depth();
#endif
- Q_D(QRasterPaintEngine);
- QRasterPaintEngineState *s = state();
-
- if (pixmap.depth() == 1) {
- if (s->matrix.type() <= QTransform::TxTranslate
- && r.size() == sr.size()
- && r.size() == pixmap.size()) {
- ensurePen();
- drawBitmap(r.topLeft() + QPointF(s->matrix.dx(), s->matrix.dy()), pixmap, &s->penData);
- return;
+ if (pixmap.data->classId() == QPixmapData::RasterClass) {
+ const QImage &image = ((QRasterPixmapData *) pixmap.data)->image;
+ if (image.depth() == 1) {
+ Q_D(QRasterPaintEngine);
+ QRasterPaintEngineState *s = state();
+ if (s->matrix.type() <= QTransform::TxTranslate
+ && r.size() == sr.size()
+ && r.size() == pixmap.size()) {
+ ensurePen();
+ drawBitmap(r.topLeft() + QPointF(s->matrix.dx(), s->matrix.dy()), image, &s->penData);
+ return;
+ } else {
+ drawImage(r, d->rasterBuffer->colorizeBitmap(image, s->pen.color()), sr);
+ }
} else {
- drawImage(r, d->rasterBuffer->colorizeBitmap(IMAGE_FROM_PIXMAP(pixmap),
- s->pen.color()), sr);
+ drawImage(r, image, sr);
}
} else {
- drawImage(r, IMAGE_FROM_PIXMAP(pixmap), sr);
+ const QImage image = pixmap.toImage();
+ if (image.depth() == 1) {
+ Q_D(QRasterPaintEngine);
+ QRasterPaintEngineState *s = state();
+ if (s->matrix.type() <= QTransform::TxTranslate
+ && r.size() == sr.size()
+ && r.size() == pixmap.size()) {
+ ensurePen();
+ drawBitmap(r.topLeft() + QPointF(s->matrix.dx(), s->matrix.dy()), image, &s->penData);
+ return;
+ } else {
+ drawImage(r, d->rasterBuffer->colorizeBitmap(image, s->pen.color()), sr);
+ }
+ } else {
+ drawImage(r, image, sr);
+ }
}
}
@@ -2616,10 +2682,15 @@ void QRasterPaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap,
QRasterPaintEngineState *s = state();
QImage image;
- if (pixmap.depth() == 1)
- image = d->rasterBuffer->colorizeBitmap(IMAGE_FROM_PIXMAP(pixmap), s->pen.color());
- else
- image = IMAGE_FROM_PIXMAP(pixmap);
+
+ if (pixmap.data->classId() == QPixmapData::RasterClass) {
+ image = ((QRasterPixmapData *) pixmap.data)->image;
+ } else {
+ image = pixmap.toImage();
+ }
+
+ if (image.depth() == 1)
+ image = d->rasterBuffer->colorizeBitmap(image, s->pen.color());
if (s->matrix.type() > QTransform::TxTranslate) {
QTransform copy = s->matrix;
@@ -3652,14 +3723,13 @@ void QRasterPaintEngine::drawBufferSpan(const uint *buffer, int bufsize,
}
#endif // Q_WS_QWS
-void QRasterPaintEngine::drawBitmap(const QPointF &pos, const QPixmap &pm, QSpanData *fg)
+void QRasterPaintEngine::drawBitmap(const QPointF &pos, const QImage &image, QSpanData *fg)
{
Q_ASSERT(fg);
if (!fg->blend)
return;
Q_D(QRasterPaintEngine);
- const QImage image = IMAGE_FROM_PIXMAP(pm);
Q_ASSERT(image.depth() == 1);
const int spanCount = 256;
@@ -3667,8 +3737,8 @@ void QRasterPaintEngine::drawBitmap(const QPointF &pos, const QPixmap &pm, QSpan
int n = 0;
// Boundaries
- int w = pm.width();
- int h = pm.height();
+ int w = image.width();
+ int h = image.height();
int ymax = qMin(qRound(pos.y() + h), d->rasterBuffer->height());
int ymin = qMax(qRound(pos.y()), 0);
int xmax = qMin(qRound(pos.x() + w), d->rasterBuffer->width());
@@ -4343,6 +4413,9 @@ void QClipData::fixup()
*/
void QClipData::setClipRect(const QRect &rect)
{
+ if (rect == clipRect)
+ return;
+
// qDebug() << "setClipRect" << clipSpanHeight << count << allocated << rect;
hasRectClip = true;
clipRect = rect;
@@ -4352,6 +4425,11 @@ void QClipData::setClipRect(const QRect &rect)
ymin = qMin(rect.y(), clipSpanHeight);
ymax = qMin(rect.y() + rect.height(), clipSpanHeight);
+ if (m_spans) {
+ delete m_spans;
+ m_spans = 0;
+ }
+
// qDebug() << xmin << xmax << ymin << ymax;
}
@@ -4375,6 +4453,12 @@ void QClipData::setClipRegion(const QRegion &region)
ymin = rect.y();
ymax = rect.y() + rect.height();
}
+
+ if (m_spans) {
+ delete m_spans;
+ m_spans = 0;
+ }
+
}
/*!
diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h
index 0f8060a..26a2b3f 100644
--- a/src/gui/painting/qpaintengine_raster_p.h
+++ b/src/gui/painting/qpaintengine_raster_p.h
@@ -256,7 +256,7 @@ private:
void init();
void fillRect(const QRectF &rect, QSpanData *data);
- void drawBitmap(const QPointF &pos, const QPixmap &image, QSpanData *fill);
+ void drawBitmap(const QPointF &pos, const QImage &image, QSpanData *fill);
void drawCachedGlyphs(const QPointF &p, const QTextItemInt &ti);
diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp
index e9f1bb3..39ce59f 100644
--- a/src/gui/painting/qpaintengine_x11.cpp
+++ b/src/gui/painting/qpaintengine_x11.cpp
@@ -62,6 +62,7 @@
#include <private/qpaintengine_x11_p.h>
#include <private/qfontengine_x11_p.h>
#include <private/qwidget_p.h>
+#include <private/qpainterpath_p.h>
#include "qpen.h"
#include "qcolor.h"
@@ -1479,14 +1480,10 @@ void QX11PaintEngine::drawEllipse(const QRect &rect)
return;
}
d->setupAdaptedOrigin(rect.topLeft());
- if (d->has_brush) { // draw filled ellipse
- if (!d->has_pen) {
- XFillArc(d->dpy, d->hd, d->gc_brush, x, y, w-1, h-1, 0, 360*64);
+ if (d->has_brush) { // draw filled ellipse
+ XFillArc(d->dpy, d->hd, d->gc_brush, x, y, w, h, 0, 360*64);
+ if (!d->has_pen) // make smoother outline
XDrawArc(d->dpy, d->hd, d->gc_brush, x, y, w-1, h-1, 0, 360*64);
- return;
- } else{
- XFillArc(d->dpy, d->hd, d->gc_brush, x, y, w, h, 0, 360*64);
- }
}
if (d->has_pen) // draw outline
XDrawArc(d->dpy, d->hd, d->gc, x, y, w, h, 0, 360*64);
@@ -1760,9 +1757,14 @@ void QX11PaintEngine::drawPath(const QPainterPath &path)
QPainterPath stroke;
qreal width = d->cpen.widthF();
QPolygonF poly;
+ QRectF deviceRect(0, 0, d->pdev->width(), d->pdev->height());
// necessary to get aliased alphablended primitives to be drawn correctly
if (d->cpen.isCosmetic() || d->has_scaling_xform) {
- stroker.setWidth(width == 0 ? 1 : width * d->xform_scale);
+ if (d->cpen.isCosmetic())
+ stroker.setWidth(width == 0 ? 1 : width);
+ else
+ stroker.setWidth(width * d->xform_scale);
+ stroker.d_ptr->stroker.setClipRect(deviceRect);
stroke = stroker.createStroke(path * d->matrix);
if (stroke.isEmpty())
return;
@@ -1770,6 +1772,7 @@ void QX11PaintEngine::drawPath(const QPainterPath &path)
d->fillPath(stroke, QX11PaintEnginePrivate::PenGC, false);
} else {
stroker.setWidth(width);
+ stroker.d_ptr->stroker.setClipRect(d->matrix.inverted().mapRect(deviceRect));
stroke = stroker.createStroke(path);
if (stroke.isEmpty())
return;
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index e2d9b32..65d87fa 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -1293,7 +1293,7 @@ void QPainterPrivate::updateState(QPainterState *newState)
destination.
Note that composition transformation operates pixelwise. For that
- reason, there is a difference between using the grahic primitive
+ reason, there is a difference between using the graphic primitive
itself and its bounding rectangle: The bounding rect contains
pixels with alpha == 0 (i.e the pixels surrounding the
primitive). These pixels will overwrite the other image's pixels,
@@ -1465,8 +1465,8 @@ bool QPainter::isActive() const
/*!
Initializes the painters pen, background and font to the same as
- the given \a widget. Call this function after begin() while the
- painter is active.
+ the given \a widget. This function is called automatically when the
+ painter is opened on a QWidget.
\sa begin(), {QPainter#Settings}{Settings}
*/
@@ -1484,7 +1484,9 @@ void QPainter::initFrom(const QWidget *widget)
d->state->bgBrush = pal.brush(widget->backgroundRole());
d->state->deviceFont = QFont(widget->font(), const_cast<QWidget*> (widget));
d->state->font = d->state->deviceFont;
- if (d->engine) {
+ if (d->extended) {
+ d->extended->penChanged();
+ } else if (d->engine) {
d->engine->setDirty(QPaintEngine::DirtyPen);
d->engine->setDirty(QPaintEngine::DirtyBrush);
d->engine->setDirty(QPaintEngine::DirtyFont);
@@ -2371,6 +2373,11 @@ void QPainter::setClipping(bool enable)
Returns the currently set clip region. Note that the clip region
is given in logical coordinates.
+ \warning QPainter does not store the combined clip explicitly as
+ this is handled by the underlying QPaintEngine, so the path is
+ recreated on demand and transformed to the current logical
+ coordinate system. This is potentially an expensive operation.
+
\sa setClipRegion(), clipPath(), setClipping()
*/
@@ -2486,6 +2493,11 @@ extern QPainterPath qt_regionToPath(const QRegion &region);
Returns the currently clip as a path. Note that the clip path is
given in logical coordinates.
+ \warning QPainter does not store the combined clip explicitly as
+ this is handled by the underlying QPaintEngine, so the path is
+ recreated on demand and transformed to the current logical
+ coordinate system. This is potentially an expensive operation.
+
\sa setClipPath(), clipRegion(), setClipping()
*/
QPainterPath QPainter::clipPath() const
@@ -5155,7 +5167,7 @@ void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm)
Q_D(QPainter);
- if (!d->engine || pm.isNull())
+ if (!d->engine)
return;
#ifndef QT_NO_DEBUG
@@ -5173,6 +5185,9 @@ void QPainter::drawPixmap(const QPointF &p, const QPixmap &pm)
int w = pm.width();
int h = pm.height();
+ if (w <= 0)
+ return;
+
// Emulate opaque background for bitmaps
if (d->state->bgMode == Qt::OpaqueMode && pm.isQBitmap()) {
fillRect(QRectF(x, y, w, h), d->state->bgBrush.color());
diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp
index bb07f81..e1f5eea 100644
--- a/src/gui/painting/qpainterpath.cpp
+++ b/src/gui/painting/qpainterpath.cpp
@@ -1725,7 +1725,7 @@ static void qt_painterpath_isect_curve(const QBezier &bezier, const QPointF &pt,
*/
bool QPainterPath::contains(const QPointF &pt) const
{
- if (isEmpty())
+ if (isEmpty() || !controlPointRect().contains(pt))
return false;
QPainterPathData *d = d_func();
@@ -2387,21 +2387,13 @@ void qt_path_stroke_cubic_to(qfixed c1x, qfixed c1y,
\sa QPen, QBrush
*/
-class QPainterPathStrokerPrivate
+QPainterPathStrokerPrivate::QPainterPathStrokerPrivate()
+ : dashOffset(0)
{
-public:
- QPainterPathStrokerPrivate()
- : dashOffset(0)
- {
- stroker.setMoveToHook(qt_path_stroke_move_to);
- stroker.setLineToHook(qt_path_stroke_line_to);
- stroker.setCubicToHook(qt_path_stroke_cubic_to);
- }
-
- QStroker stroker;
- QVector<qfixed> dashPattern;
- qreal dashOffset;
-};
+ stroker.setMoveToHook(qt_path_stroke_move_to);
+ stroker.setLineToHook(qt_path_stroke_line_to);
+ stroker.setCubicToHook(qt_path_stroke_cubic_to);
+}
/*!
Creates a new stroker.
@@ -2445,6 +2437,7 @@ QPainterPath QPainterPathStroker::createStroke(const QPainterPath &path) const
QDashStroker dashStroker(&d->stroker);
dashStroker.setDashPattern(d->dashPattern);
dashStroker.setDashOffset(d->dashOffset);
+ dashStroker.setClipRect(d->stroker.clipRect());
dashStroker.strokePath(path, &stroke, QTransform());
}
stroke.setFillRule(Qt::WindingFill);
diff --git a/src/gui/painting/qpainterpath.h b/src/gui/painting/qpainterpath.h
index 88fb19d..6cd2af8 100644
--- a/src/gui/painting/qpainterpath.h
+++ b/src/gui/painting/qpainterpath.h
@@ -277,6 +277,8 @@ public:
QPainterPath createStroke(const QPainterPath &path) const;
private:
+ friend class QX11PaintEngine;
+
QPainterPathStrokerPrivate *d_ptr;
};
diff --git a/src/gui/painting/qpainterpath_p.h b/src/gui/painting/qpainterpath_p.h
index 93f9704..29c48df 100644
--- a/src/gui/painting/qpainterpath_p.h
+++ b/src/gui/painting/qpainterpath_p.h
@@ -61,9 +61,20 @@
#include <qdebug.h>
#include <private/qvectorpath_p.h>
+#include <private/qstroker_p.h>
QT_BEGIN_NAMESPACE
+class QPainterPathStrokerPrivate
+{
+public:
+ QPainterPathStrokerPrivate();
+
+ QStroker stroker;
+ QVector<qfixed> dashPattern;
+ qreal dashOffset;
+};
+
class QPolygonF;
class QVectorPathConverter;
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp
index b010209..55006f6 100644
--- a/src/gui/painting/qpdf.cpp
+++ b/src/gui/painting/qpdf.cpp
@@ -1106,6 +1106,11 @@ void QPdfBaseEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
if (!d->hasPen || (d->clipEnabled && d->allClipped))
return;
+ if (d->stroker.matrix.type() >= QTransform::TxProject) {
+ QPaintEngine::drawTextItem(p, textItem);
+ return;
+ }
+
*d->currentPage << "q\n";
if(!d->simplePen)
*d->currentPage << QPdf::generateMatrix(d->stroker.matrix);
diff --git a/src/gui/painting/qprintengine_mac.mm b/src/gui/painting/qprintengine_mac.mm
index 7a77e47..b1216b7 100644
--- a/src/gui/painting/qprintengine_mac.mm
+++ b/src/gui/painting/qprintengine_mac.mm
@@ -62,6 +62,10 @@ bool QMacPrintEngine::begin(QPaintDevice *dev)
{
Q_D(QMacPrintEngine);
+ Q_ASSERT(dev && dev->devType() == QInternal::Printer);
+ if (!static_cast<QPrinter *>(dev)->isValid())
+ return false;
+
if (d->state == QPrinter::Idle && !d->isPrintSessionInitialized()) // Need to reinitialize
d->initialize();
@@ -121,24 +125,8 @@ bool QMacPrintEngine::end()
if(d->paintEngine->type() == QPaintEngine::CoreGraphics)
static_cast<QCoreGraphicsPaintEngine*>(d->paintEngine)->d_func()->hd = 0;
d->paintEngine->end();
- if (d->state != QPrinter::Idle) {
-#ifndef QT_MAC_USE_COCOA
- if (d->shouldSuppressStatus()) {
- PMSessionEndPageNoDialog(d->session);
- PMSessionEndDocumentNoDialog(d->session);
- } else {
- PMSessionEndPage(d->session);
- PMSessionEndDocument(d->session);
- }
- PMRelease(d->session);
-#else
- PMSessionEndPageNoDialog(d->session);
- PMSessionEndDocumentNoDialog(d->session);
- [d->printInfo release];
-#endif
- d->printInfo = 0;
- d->session = 0;
- }
+ if (d->state != QPrinter::Idle)
+ d->releaseSession();
d->state = QPrinter::Idle;
return true;
}
@@ -509,6 +497,26 @@ void QMacPrintEnginePrivate::initialize()
}
}
+void QMacPrintEnginePrivate::releaseSession()
+{
+#ifndef QT_MAC_USE_COCOA
+ if (shouldSuppressStatus()) {
+ PMSessionEndPageNoDialog(session);
+ PMSessionEndDocumentNoDialog(session);
+ } else {
+ PMSessionEndPage(session);
+ PMSessionEndDocument(session);
+ }
+ PMRelease(session);
+#else
+ PMSessionEndPageNoDialog(session);
+ PMSessionEndDocumentNoDialog(session);
+ [printInfo release];
+#endif
+ printInfo = 0;
+ session = 0;
+}
+
bool QMacPrintEnginePrivate::newPage_helper()
{
Q_Q(QMacPrintEngine);
@@ -737,6 +745,7 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
d->setPaperSize(QPrinter::PaperSize(value.toInt()));
break;
case PPK_PrinterName: {
+ bool printerNameSet = false;
OSStatus status = noErr;
QCFType<CFArrayRef> printerList;
status = PMServerCreatePrinterList(kPMServerLocal, &printerList);
@@ -747,12 +756,18 @@ void QMacPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va
QString name = QCFString::toQString(PMPrinterGetName(printer));
if (name == value.toString()) {
status = PMSessionSetCurrentPMPrinter(d->session, printer);
+ printerNameSet = true;
break;
}
}
}
if (status != noErr)
qWarning("QMacPrintEngine::setPrinterName: Error setting printer: %ld", long(status));
+ if (!printerNameSet) {
+ qWarning("QMacPrintEngine::setPrinterName: Failed to set printer named '%s'.", qPrintable(value.toString()));
+ d->releaseSession();
+ d->state = QPrinter::Idle;
+ }
break; }
case PPK_SuppressSystemPrintStatus:
d->suppressStatus = value.toBool();
@@ -876,17 +891,12 @@ QVariant QMacPrintEngine::property(PrintEnginePropertyKey key) const
ret = r;
break; }
case PPK_PrinterName: {
- CFIndex currIndex;
- PMPrinter unused;
- QCFType<CFArrayRef> printerList;
- OSStatus status = PMSessionCreatePrinterList(d->session, &printerList, &currIndex, &unused);
+ PMPrinter printer;
+ OSStatus status = PMSessionGetCurrentPrinter(d->session, &printer);
if (status != noErr)
- qWarning("QMacPrintEngine::printerName: Problem getting list of printers: %ld", long(status));
- if (currIndex != -1 && printerList && currIndex < CFArrayGetCount(printerList)) {
- const CFStringRef name = static_cast<CFStringRef>(CFArrayGetValueAtIndex(printerList, currIndex));
- if (name)
- ret = QCFString::toQString(name);
- }
+ qWarning("QMacPrintEngine::printerName: Failed getting current PMPrinter: %ld", long(status));
+ if (printer)
+ ret = QCFString::toQString(PMPrinterGetName(printer));
break; }
case PPK_Resolution: {
ret = d->resolution.hRes;
diff --git a/src/gui/painting/qprintengine_mac_p.h b/src/gui/painting/qprintengine_mac_p.h
index 5e18845..bc917e7 100644
--- a/src/gui/painting/qprintengine_mac_p.h
+++ b/src/gui/painting/qprintengine_mac_p.h
@@ -143,6 +143,7 @@ public:
hasCustomPaperSize(false), hasCustomPageMargins(false) {}
~QMacPrintEnginePrivate();
void initialize();
+ void releaseSession();
bool newPage_helper();
void setPaperSize(QPrinter::PaperSize ps);
QPrinter::PaperSize paperSize() const;
diff --git a/src/gui/painting/qprintengine_win.cpp b/src/gui/painting/qprintengine_win.cpp
index d48b525..7601beb 100644
--- a/src/gui/painting/qprintengine_win.cpp
+++ b/src/gui/painting/qprintengine_win.cpp
@@ -369,7 +369,7 @@ void QWin32PrintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem
QRgb brushColor = state->pen().brush().color().rgb();
bool fallBack = state->pen().brush().style() != Qt::SolidPattern
|| qAlpha(brushColor) != 0xff
- || QT_WA_INLINE(false, d->txop >= QTransform::TxScale)
+ || QT_WA_INLINE(d->txop >= QTransform::TxProject, d->txop >= QTransform::TxScale)
|| ti.fontEngine->type() != QFontEngine::Win;
@@ -1532,7 +1532,7 @@ QVariant QWin32PrintEngine::property(PrintEnginePropertyKey key) const
value = rect;
} else {
value = QTransform(1/d->stretch_x, 0, 0, 1/d->stretch_y, 0, 0)
- .mapRect(d->fullPage ? d->devPaperRect : d->devPageRect);
+ .mapRect(d->fullPage ? d->devPhysicalPageRect : d->devPageRect);
}
break;
diff --git a/src/gui/painting/qprinter.cpp b/src/gui/painting/qprinter.cpp
index 413f4a1..4f3e71c 100644
--- a/src/gui/painting/qprinter.cpp
+++ b/src/gui/painting/qprinter.cpp
@@ -284,6 +284,10 @@ void QPrinterPrivate::addToManualSetList(QPrintEngine::PrintEnginePropertyKey ke
to send PostScript or PDF output to the printer. As an alternative,
the printProgram() function can be used to specify the command or utility
to use instead of the system default.
+
+ Note that setting parameters like paper size and resolution on an
+ invalid printer is undefined. You can use QPrinter::isValid() to
+ verify this before changing any parameters.
QPrinter supports a number of parameters, most of which can be
changed by the end user through a \l{QPrintDialog}{print dialog}. In
@@ -849,7 +853,7 @@ void QPrinter::setPrinterName(const QString &name)
Returns true if the printer currently selected is a valid printer
in the system, or a pure PDF/PostScript printer; otherwise returns false.
- To detect other failures check the output of QPainter::begin() or QPainter::nextPage().
+ To detect other failures check the output of QPainter::begin() or QPrinter::newPage().
\snippet doc/src/snippets/printing-qprinter/errors.cpp 0
diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp
index f728f9d..c88af7c 100644
--- a/src/gui/painting/qregion.cpp
+++ b/src/gui/painting/qregion.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qregion.h"
+#include "qpainterpath.h"
#include "qpolygon.h"
#include "qbuffer.h"
#include "qdatastream.h"
@@ -49,7 +50,6 @@
#include <qdebug.h>
#if defined(Q_OS_UNIX) || defined(Q_OS_WINCE)
-#include "qpainterpath.h"
#include "qimage.h"
#include "qbitmap.h"
#include <stdlib.h>
@@ -65,9 +65,17 @@ QT_BEGIN_NAMESPACE
\ingroup shared
QRegion is used with QPainter::setClipRegion() to limit the paint
- area to what needs to be painted. There is also a
- QWidget::repaint() function that takes a QRegion parameter.
- QRegion is the best tool for reducing flicker.
+ area to what needs to be painted. There is also a QWidget::repaint()
+ function that takes a QRegion parameter. QRegion is the best tool for
+ minimizing the amount of screen area to be updated by a repaint.
+
+ This class is not suitable for constructing shapes for rendering, especially
+ as outlines. Use QPainterPath to create paths and shapes for use with
+ QPainter.
+
+ QRegion is an \l{implicitly shared} class.
+
+ \section1 Creating and Using Regions
A region can be created from a rectangle, an ellipse, a polygon or
a bitmap. Complex regions may be created by combining simple
@@ -84,8 +92,6 @@ QT_BEGIN_NAMESPACE
Example of using complex regions:
\snippet doc/src/snippets/code/src_gui_painting_qregion.cpp 0
- QRegion is an \l{implicitly shared} class.
-
\warning Due to window system limitations, the whole coordinate space for a
region is limited to the points between -32767 and 32767 on Windows
95/98/ME. You can circumvent this limitation by using a QPainterPath.
@@ -93,7 +99,7 @@ QT_BEGIN_NAMESPACE
\section1 Additional License Information
On Embedded Linux, Windows CE and X11 platforms, parts of this class rely on
- code obtained under the following license:
+ code obtained under the following licenses:
\legalese
Copyright (c) 1987 X Consortium
@@ -120,9 +126,7 @@ QT_BEGIN_NAMESPACE
in this Software without prior written authorization from the X Consortium.
\endlegalese
- \raw HTML
- <hr />
- \endraw
+ \br
\legalese
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp
index da8c428..af27fd5 100644
--- a/src/gui/painting/qtransform.cpp
+++ b/src/gui/painting/qtransform.cpp
@@ -168,10 +168,10 @@ QT_BEGIN_NAMESPACE
\image qtransform-representation.png
- A QTransform object contains a 3 x 3 matrix. The \c dx and \c dy
- elements specify horizontal and vertical translation. The \c m11
- and \c m22 elements specify horizontal and vertical scaling. The
- \c m21 and \c m12 elements specify horizontal and vertical \e shearing.
+ A QTransform object contains a 3 x 3 matrix. The \c m31 (\c dx) and
+ \c m32 (\c dy) elements specify horizontal and vertical translation.
+ The \c m11 and \c m22 elements specify horizontal and vertical scaling.
+ The \c m21 and \c m12 elements specify horizontal and vertical \e shearing.
And finally, the \c m13 and \c m23 elements specify horizontal and vertical
projection, with \c m33 as an additional projection factor.
@@ -246,8 +246,10 @@ QTransform::QTransform()
}
/*!
- Constructs a matrix with the elements, \a h11, \a h12, \a h13,
- \a h21, \a h22, \a h23, \a h31, \a h32, \a h33.
+ \fn QTransform::QTransform(qreal m11, qreal m12, qreal m13, qreal m21, qreal m22, qreal m23, qreal m31, qreal m32, qreal m33)
+
+ Constructs a matrix with the elements, \a m11, \a m12, \a m13,
+ \a m21, \a m22, \a m23, \a m31, \a m32, \a m33.
\sa setMatrix()
*/
@@ -263,8 +265,9 @@ QTransform::QTransform(qreal h11, qreal h12, qreal h13,
}
/*!
- Constructs a matrix with the elements, \a h11, \a h12, \a h21, \a
- h22, \a dx and \a dy.
+ \fn QTransform::QTransform(qreal m11, qreal m12, qreal m21, qreal m22, qreal dx, qreal dy)
+
+ Constructs a matrix with the elements, \a m11, \a m12, \a m21, \a m22, \a dx and \a dy.
\sa setMatrix()
*/
@@ -396,6 +399,9 @@ QTransform QTransform::inverted(bool *invertible) const
*/
QTransform & QTransform::translate(qreal dx, qreal dy)
{
+ if (dx == 0 && dy == 0)
+ return *this;
+
switch(type()) {
case TxNone:
affine._dx = dx;
@@ -432,7 +438,10 @@ QTransform & QTransform::translate(qreal dx, qreal dy)
QTransform QTransform::fromTranslate(qreal dx, qreal dy)
{
QTransform transform(1, 0, 0, 1, dx, dy);
- transform.m_dirty = TxTranslate;
+ if (dx == 0 && dy == 0)
+ transform.m_dirty = TxNone;
+ else
+ transform.m_dirty = TxTranslate;
return transform;
}
@@ -444,6 +453,9 @@ QTransform QTransform::fromTranslate(qreal dx, qreal dy)
*/
QTransform & QTransform::scale(qreal sx, qreal sy)
{
+ if (sx == 1 && sy == 1)
+ return *this;
+
switch(type()) {
case TxNone:
case TxTranslate:
@@ -478,7 +490,10 @@ QTransform & QTransform::scale(qreal sx, qreal sy)
QTransform QTransform::fromScale(qreal sx, qreal sy)
{
QTransform transform(sx, 0, 0, sy, 0, 0);
- transform.m_dirty = TxScale;
+ if (sx == 1 && sy == 1)
+ transform.m_dirty = TxNone;
+ else
+ transform.m_dirty = TxScale;
return transform;
}
@@ -541,6 +556,9 @@ const qreal inv_dist_to_plane = 1. / 1024.;
*/
QTransform & QTransform::rotate(qreal a, Qt::Axis axis)
{
+ if (a == 0)
+ return *this;
+
qreal sina = 0;
qreal cosa = 0;
if (a == 90. || a == -270.)
@@ -712,7 +730,15 @@ bool QTransform::operator!=(const QTransform &o) const
*/
QTransform & QTransform::operator*=(const QTransform &o)
{
- TransformationType t = qMax(type(), o.type());
+ const TransformationType otherType = o.type();
+ if (otherType == TxNone)
+ return *this;
+
+ const TransformationType thisType = type();
+ if (thisType == TxNone)
+ return operator=(o);
+
+ TransformationType t = qMax(thisType, otherType);
switch(t) {
case TxNone:
break;
@@ -1219,7 +1245,8 @@ static QPolygonF mapProjective(const QTransform &transform, const QPolygonF &pol
*/
QPolygonF QTransform::map(const QPolygonF &a) const
{
- if (type() >= QTransform::TxProject)
+ TransformationType t = type();
+ if (t >= QTransform::TxProject)
return mapProjective(*this, a);
int size = a.size();
@@ -1228,7 +1255,6 @@ QPolygonF QTransform::map(const QPolygonF &a) const
const QPointF *da = a.constData();
QPointF *dp = p.data();
- TransformationType t = type();
for(i = 0; i < size; ++i) {
MAP(da[i].xp, da[i].yp, dp[i].xp, dp[i].yp);
}
@@ -1246,7 +1272,8 @@ QPolygonF QTransform::map(const QPolygonF &a) const
*/
QPolygon QTransform::map(const QPolygon &a) const
{
- if (type() >= QTransform::TxProject)
+ TransformationType t = type();
+ if (t >= QTransform::TxProject)
return mapProjective(*this, QPolygonF(a)).toPolygon();
int size = a.size();
@@ -1255,7 +1282,6 @@ QPolygon QTransform::map(const QPolygon &a) const
const QPoint *da = a.constData();
QPoint *dp = p.data();
- TransformationType t = type();
for(i = 0; i < size; ++i) {
qreal nx = 0, ny = 0;
MAP(da[i].xp, da[i].yp, nx, ny);
@@ -1689,13 +1715,12 @@ QRect QTransform::mapRect(const QRect &rect) const
return QRect(x, y, w, h);
} else if (t < TxProject) {
// see mapToPolygon for explanations of the algorithm.
- qreal x0 = 0, y0 = 0;
- qreal x, y;
- MAP(rect.left(), rect.top(), x0, y0);
- qreal xmin = x0;
- qreal ymin = y0;
- qreal xmax = x0;
- qreal ymax = y0;
+ qreal x = 0, y = 0;
+ MAP(rect.left(), rect.top(), x, y);
+ qreal xmin = x;
+ qreal ymin = y;
+ qreal xmax = x;
+ qreal ymax = y;
MAP(rect.right() + 1, rect.top(), x, y);
xmin = qMin(xmin, x);
ymin = qMin(ymin, y);
@@ -1756,13 +1781,12 @@ QRectF QTransform::mapRect(const QRectF &rect) const
}
return QRectF(x, y, w, h);
} else if (t < TxProject) {
- qreal x0 = 0, y0 = 0;
- qreal x, y;
- MAP(rect.x(), rect.y(), x0, y0);
- qreal xmin = x0;
- qreal ymin = y0;
- qreal xmax = x0;
- qreal ymax = y0;
+ qreal x = 0, y = 0;
+ MAP(rect.x(), rect.y(), x, y);
+ qreal xmin = x;
+ qreal ymin = y;
+ qreal xmax = x;
+ qreal ymax = y;
MAP(rect.x() + rect.width(), rect.y(), x, y);
xmin = qMin(xmin, x);
ymin = qMin(ymin, y);
@@ -1856,7 +1880,7 @@ const QMatrix &QTransform::toAffine() const
QTransform::TransformationType QTransform::type() const
{
if (m_dirty >= m_type) {
- if (m_dirty > TxShear && (!qFuzzyCompare(m_13 + 1, 1) || !qFuzzyCompare(m_23 + 1, 1)))
+ if (m_dirty > TxShear && (!qFuzzyCompare(m_13 + 1, 1) || !qFuzzyCompare(m_23 + 1, 1) || !qFuzzyCompare(m_33, 1)))
m_type = TxProject;
else if (m_dirty > TxScale && (!qFuzzyCompare(affine._m12 + 1, 1) || !qFuzzyCompare(affine._m21 + 1, 1))) {
const qreal dot = affine._m11 * affine._m12 + affine._m21 * affine._m22;
@@ -1864,7 +1888,7 @@ QTransform::TransformationType QTransform::type() const
m_type = TxRotate;
else
m_type = TxShear;
- } else if (m_dirty > TxTranslate && (!qFuzzyCompare(affine._m11, 1) || !qFuzzyCompare(affine._m22, 1) || !qFuzzyCompare(m_33, 1)))
+ } else if (m_dirty > TxTranslate && (!qFuzzyCompare(affine._m11, 1) || !qFuzzyCompare(affine._m22, 1)))
m_type = TxScale;
else if (m_dirty > TxNone && (!qFuzzyCompare(affine._dx + 1, 1) || !qFuzzyCompare(affine._dy + 1, 1)))
m_type = TxTranslate;
@@ -2058,10 +2082,11 @@ QTransform::operator QVariant() const
Q_GUI_EXPORT
bool qt_scaleForTransform(const QTransform &transform, qreal *scale)
{
- if (transform.type() <= QTransform::TxTranslate) {
+ const QTransform::TransformationType type = transform.type();
+ if (type <= QTransform::TxTranslate) {
*scale = 1;
return true;
- } else if (transform.type() == QTransform::TxScale) {
+ } else if (type == QTransform::TxScale) {
const qreal xScale = qAbs(transform.m11());
const qreal yScale = qAbs(transform.m22());
*scale = qMax(xScale, yScale);
@@ -2073,7 +2098,7 @@ bool qt_scaleForTransform(const QTransform &transform, qreal *scale)
const qreal yScale = transform.m12() * transform.m12()
+ transform.m22() * transform.m22();
*scale = qSqrt(qMax(xScale, yScale));
- return transform.type() == QTransform::TxRotate && qFuzzyCompare(xScale, yScale);
+ return type == QTransform::TxRotate && qFuzzyCompare(xScale, yScale);
}
QT_END_NAMESPACE
diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h
index de7ebcd..c76409b 100644
--- a/src/gui/painting/qtransform.h
+++ b/src/gui/painting/qtransform.h
@@ -257,6 +257,8 @@ inline qreal QTransform::dy() const
inline QTransform &QTransform::operator*=(qreal num)
{
+ if (num == 1.)
+ return *this;
affine._m11 *= num;
affine._m12 *= num;
m_13 *= num;
@@ -271,11 +273,15 @@ inline QTransform &QTransform::operator*=(qreal num)
}
inline QTransform &QTransform::operator/=(qreal div)
{
+ if (div == 0)
+ return *this;
div = 1/div;
return operator*=(div);
}
inline QTransform &QTransform::operator+=(qreal num)
{
+ if (num == 0)
+ return *this;
affine._m11 += num;
affine._m12 += num;
m_13 += num;
@@ -290,6 +296,8 @@ inline QTransform &QTransform::operator+=(qreal num)
}
inline QTransform &QTransform::operator-=(qreal num)
{
+ if (num == 0)
+ return *this;
affine._m11 -= num;
affine._m12 -= num;
m_13 -= num;
diff --git a/src/gui/painting/qwindowsurface.cpp b/src/gui/painting/qwindowsurface.cpp
index bcb0380..d941a24 100644
--- a/src/gui/painting/qwindowsurface.cpp
+++ b/src/gui/painting/qwindowsurface.cpp
@@ -310,10 +310,13 @@ void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset)
int lineskip = img.bytesPerLine();
int depth = img.depth() >> 3;
-
- const QRect r = rect & QRect(0, 0, img.width(), img.height());
+ const QRect imageRect(0, 0, img.width(), img.height());
+ const QRect r = rect & imageRect & imageRect.translated(-offset);
const QPoint p = rect.topLeft() + offset;
+ if (r.isEmpty())
+ return;
+
const uchar *src;
uchar *dest;
diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp
index 3fbf233..0842ec7 100644
--- a/src/gui/styles/gtksymbols.cpp
+++ b/src/gui/styles/gtksymbols.cpp
@@ -75,6 +75,7 @@
QT_BEGIN_NAMESPACE
static bool displayDepth = -1;
+Q_GLOBAL_STATIC(QGtkStyleUpdateScheduler, styleScheduler)
typedef QHash<QString, GtkWidget*> WidgetMap;
Q_GLOBAL_STATIC(WidgetMap, gtkWidgetMap)
@@ -486,11 +487,11 @@ static void init_gtk_menu()
}
// Updates window/windowtext palette based on the indicated gtk widget
-static void ensureWidgetPalette(QWidget* widget, const QString &gtkWidgetName)
+static QPalette gtkWidgetPalette(const QString &gtkWidgetName)
{
GtkWidget *gtkWidget = QGtk::gtkWidget(gtkWidgetName);
Q_ASSERT(gtkWidget);
- QPalette pal = widget->palette();
+ QPalette pal = QApplication::palette();
GdkColor gdkBg = gtkWidget->style->bg[GTK_STATE_NORMAL];
GdkColor gdkText = gtkWidget->style->fg[GTK_STATE_NORMAL];
GdkColor gdkDisabledText = gtkWidget->style->fg[GTK_STATE_INSENSITIVE];
@@ -503,8 +504,7 @@ static void ensureWidgetPalette(QWidget* widget, const QString &gtkWidgetName)
pal.setBrush(QPalette::Disabled, QPalette::WindowText, disabledTextColor);
pal.setBrush(QPalette::All, QPalette::ButtonText, textColor);
pal.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledTextColor);
- widget->setPalette(pal);
- widget->setAttribute(Qt::WA_SetPalette, false);
+ return pal;
}
bool QGtk::isKDE4Session()
@@ -515,44 +515,47 @@ bool QGtk::isKDE4Session()
return (version == 4);
}
-// Maps a Gtk widget palettes to a Qt widget
-void QGtk::applyGtkSystemPalette(QWidget *widget)
+void QGtk::applyCustomPaletteHash()
{
- // Do not apply if the widget has a custom palette;
- if (widget->testAttribute(Qt::WA_SetPalette))
- return;
+ QPalette menuPal = gtkWidgetPalette(QLS("GtkMenu"));
+ GdkColor gdkBg = QGtk::gtkWidget(QLS("GtkMenu"))->style->bg[GTK_STATE_NORMAL];
+ QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
+ menuPal.setBrush(QPalette::Base, bgColor);
+ menuPal.setBrush(QPalette::Window, bgColor);
+ qApp->setPalette(menuPal, "QMenu");
- QPalette pal;
- if (QStatusBar *statusbar = qobject_cast<QStatusBar*> (widget))
- ensureWidgetPalette(statusbar, QLS("GtkStatusbar"));
- else if (QMenuBar *menubar = qobject_cast<QMenuBar*> (widget))
- ensureWidgetPalette(menubar, QLS("GtkMenuBar"));
- else if (QToolBar *toolbar = qobject_cast<QToolBar*> (widget))
- ensureWidgetPalette(toolbar, QLS("GtkToolbar"));
- else if (QMenu *menubar = qobject_cast<QMenu*> (widget)) {
- // This really applies to the combo box rendering since
- // QComboBox copies the palette from a QMenu
- QPalette pal = widget->palette();
- GdkColor gdkBg = QGtk::gtkWidget(QLS("GtkMenu"))->style->bg[GTK_STATE_NORMAL];
- QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
- pal.setBrush(QPalette::Base, bgColor);
- menubar->setPalette(pal);
- }
- widget->setAttribute(Qt::WA_SetPalette, false);
+ QPalette toolbarPal = gtkWidgetPalette(QLS("GtkToolbar"));
+ qApp->setPalette(toolbarPal, "QToolBar");
+
+ QPalette menuBarPal = gtkWidgetPalette(QLS("GtkMenuBar"));
+ qApp->setPalette(menuBarPal, "QMenuBar");
}
static void gtkStyleSetCallback(GtkWidget*, GtkStyle*, void*)
{
+ // We have to let this function return and complete the event
+ // loop to ensure that all gtk widgets have been styled before
+ // updating
+ QMetaObject::invokeMethod(styleScheduler(), "updateTheme", Qt::QueuedConnection);
+}
+
+void QGtkStyleUpdateScheduler::updateTheme()
+{
static QString oldTheme(QLS("qt_not_set"));
QPixmapCache::clear();
- qApp->setFont(QGtk::getThemeFont());
- QGtk::initGtkWidgets();
if (oldTheme != getThemeName()) {
oldTheme = getThemeName();
- QApplicationPrivate::setSystemPalette(qApp->style()->standardPalette());
+ qApp->setFont(QGtk::getThemeFont());
+ QPalette newPalette = qApp->style()->standardPalette();
+ QApplicationPrivate::setSystemPalette(newPalette);
+ QApplication::setPalette(newPalette);
+ QGtk::initGtkWidgets();
+ QGtk::applyCustomPaletteHash();
QList<QWidget*> widgets = QApplication::allWidgets();
+ // Notify all widgets that size metrics might have changed
foreach (QWidget *widget, widgets) {
- QGtk::applyGtkSystemPalette(widget);
+ QEvent e(QEvent::StyleChange);
+ QApplication::sendEvent(widget, &e);
}
}
}
@@ -743,9 +746,9 @@ static void setupGtkFileChooser(GtkWidget* gtkFileChooser, QWidget *parent,
foreach (const QString &rawfilter, filters) {
GtkFileFilter *gtkFilter = QGtk::gtk_file_filter_new ();
QString name = rawfilter.left(rawfilter.indexOf(QLatin1Char('(')));
- QGtk::gtk_file_filter_set_name(gtkFilter, qPrintable(name));
-
QStringList extensions = extract_filter(rawfilter);
+ QGtk::gtk_file_filter_set_name(gtkFilter, qPrintable(name.isEmpty() ? extensions.join(QLS(", ")) : name));
+
foreach (const QString &fileExtension, extensions) {
QGtk::gtk_file_filter_add_pattern (gtkFilter, qPrintable(fileExtension));
}
diff --git a/src/gui/styles/gtksymbols_p.h b/src/gui/styles/gtksymbols_p.h
index 0cea542..74c5dc3 100644
--- a/src/gui/styles/gtksymbols_p.h
+++ b/src/gui/styles/gtksymbols_p.h
@@ -204,7 +204,7 @@ public:
static void cleanup_gtk_widgets();
static void initGtkWidgets();
static bool isKDE4Session();
- static void applyGtkSystemPalette(QWidget* widget);
+ static void applyCustomPaletteHash();
static QFont getThemeFont();
static bool isThemeAvailable() { return gtkStyle() != 0; }
@@ -329,6 +329,15 @@ public:
static Ptr_gconf_client_get_string gconf_client_get_string;
};
+// Helper to ensure that we have polished all our gtk widgets
+// before updating our own palettes
+class QGtkStyleUpdateScheduler : public QObject
+{
+ Q_OBJECT
+public slots:
+ void updateTheme();
+};
+
QT_END_NAMESPACE
#endif // !QT_NO_STYLE_GTK
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index 3cae08a..819965b 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -1779,7 +1779,46 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
case CE_TabBarTab:
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
drawControl(CE_TabBarTabShape, tab, p, widget);
- drawControl(CE_TabBarTabLabel, tab, p, widget);
+
+ QStyleOptionTabV3 tabV3(*tab);
+ QRect labelRect = tabV3.rect;
+ QSize &left= tabV3.leftButtonSize;
+ QSize &right = tabV3.rightButtonSize;
+ const int spacing = 6 + 2;
+
+ // left widget
+ if (!left.isEmpty()) {
+ if (tabV3.shape == QTabBar::RoundedEast || tabV3.shape == QTabBar::TriangularEast )
+ labelRect.setTop(labelRect.top() + spacing + left.height());
+ else if (tabV3.shape == QTabBar::RoundedWest|| tabV3.shape == QTabBar::TriangularWest)
+ labelRect.setBottom(labelRect.bottom() - spacing - left.height());
+ else
+ labelRect.setLeft(labelRect.left() + spacing + left.width());
+ }
+
+ // right widget
+ if (!right.isEmpty()) {
+ if (tabV3.shape == QTabBar::RoundedEast || tabV3.shape == QTabBar::TriangularEast )
+ labelRect.setBottom(labelRect.bottom() - spacing - right.height());
+ else if (tabV3.shape == QTabBar::RoundedWest|| tabV3.shape == QTabBar::TriangularWest)
+ labelRect.setTop(labelRect.top() + spacing + right.height());
+ else
+ labelRect.setRight(labelRect.right() - spacing - right.width());
+ }
+
+ tabV3.rect = visualRect(opt->direction, opt->rect, labelRect);
+ drawControl(CE_TabBarTabLabel, &tabV3, p, widget);
+ if (tabV3.state & State_HasFocus) {
+ const int OFFSET = 1 + pixelMetric(PM_DefaultFrameWidth);
+ int x1, x2;
+ x1 = tab->rect.left();
+ x2 = tab->rect.right() - 1;
+ QStyleOptionFocusRect fropt;
+ fropt.QStyleOption::operator=(*tab);
+ fropt.rect.setRect(x1 + 1 + OFFSET, tab->rect.y() + OFFSET,
+ x2 - x1 - 2*OFFSET, tab->rect.height() - 2*OFFSET);
+ drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
+ }
}
break;
case CE_TabBarTabShape:
@@ -1981,12 +2020,8 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
(tabV2.state & State_Enabled) ? QIcon::Normal
: QIcon::Disabled);
- int offset = 4;
+ int offset = 6;
int left = opt->rect.left();
- if (tabV2.leftButtonSize.isEmpty())
- offset += 2;
- else
- left += tabV2.leftButtonSize.width() + (6 + 2) + 2;
QRect iconRect = QRect(left + offset, tr.center().y() - tabIcon.height() / 2,
tabIconSize.width(), tabIconSize.height());
if (!verticalTabs)
@@ -1997,20 +2032,6 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
drawItemText(p, tr, alignment, tab->palette, tab->state & State_Enabled, tab->text, QPalette::WindowText);
if (verticalTabs)
p->restore();
-
- if (tabV2.state & State_HasFocus) {
- const int OFFSET = 1 + pixelMetric(PM_DefaultFrameWidth);
-
- int x1, x2;
- x1 = tabV2.rect.left();
- x2 = tabV2.rect.right() - 1;
-
- QStyleOptionFocusRect fropt;
- fropt.QStyleOption::operator=(*tab);
- fropt.rect.setRect(x1 + 1 + OFFSET, tabV2.rect.y() + OFFSET,
- x2 - x1 - 2*OFFSET, tabV2.rect.height() - 2*OFFSET);
- drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
- }
}
break;
#endif // QT_NO_TABBAR
@@ -2858,12 +2879,6 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
tr.setRight(tr.right() - horizontalShift);
}
- // left widget
- if (!tabV2.leftButtonSize.isEmpty()) {
- tr.setLeft(tr.left() + 6 + 2 +
- (verticalTabs ? tabV2.leftButtonSize.height() : tabV2.leftButtonSize.width()));
- }
-
// icon
if (!tabV2.icon.isNull()) {
QSize iconSize = tabV2.iconSize;
@@ -2885,12 +2900,6 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
tr.setLeft(tr.left() + tabIconSize.width() + offset + 2);
}
- // right widget
- if (!tabV2.rightButtonSize.isEmpty()) {
- tr.setRight(tr.right() - 6 - 2 -
- (verticalTabs ? tabV2.rightButtonSize.height() : tabV2.rightButtonSize.width()));
- }
-
if (!verticalTabs)
tr = visualRect(opt->direction, opt->rect, tr);
r = tr;
diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp
index 103e97f..ca71da2 100644
--- a/src/gui/styles/qgtkstyle.cpp
+++ b/src/gui/styles/qgtkstyle.cpp
@@ -38,7 +38,6 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
#include "qgtkstyle.h"
#if !defined(QT_NO_STYLE_GTK)
@@ -138,6 +137,30 @@ static const char * const dock_widget_restore_xpm[] =
};
+class QGtkStyleFilter : public QObject
+{
+public:
+ QGtkStyleFilter() {
+ qApp->installEventFilter(this);
+ }
+
+private:
+ bool eventFilter(QObject *obj, QEvent *e);
+};
+
+bool QGtkStyleFilter::eventFilter(QObject *obj, QEvent *e)
+{
+ if (e->type() == QEvent::ApplicationPaletteChange) {
+ // Only do this the first time since this will also
+ // generate applicationPaletteChange events
+ extern QHash<QByteArray, QPalette> *qt_app_palettes_hash(); //qapplication.cpp
+ if (!qt_app_palettes_hash() || qt_app_palettes_hash()->isEmpty()) {
+ QGtk::applyCustomPaletteHash();
+ }
+ }
+ return QObject::eventFilter(obj, e);
+}
+
class QGtkStylePrivate : public QCleanlooksStylePrivate
{
Q_DECLARE_PUBLIC(QGtkStyle)
@@ -145,6 +168,7 @@ public:
QGtkStylePrivate()
: QCleanlooksStylePrivate()
{}
+ QGtkStyleFilter filter;
};
static const int groupBoxBottomMargin = 2; // space below the groupbox
@@ -217,6 +241,7 @@ static QString uniqueName(const QString &key, const QStyleOption *option, const
Constructs a QGtkStyle object.
*/
QGtkStyle::QGtkStyle()
+ : QCleanlooksStyle(*new QGtkStylePrivate)
{
QGtk::initGtkWidgets();
}
@@ -313,7 +338,7 @@ void QGtkStyle::polish(QPalette &palette)
if (!QGtk::isThemeAvailable())
QCleanlooksStyle::polish(palette);
else
- palette = standardPalette();
+ palette = palette.resolve(standardPalette());
}
/*!
@@ -328,6 +353,7 @@ void QGtkStyle::polish(QApplication *app)
if (app->desktopSettingsAware() && QGtk::isThemeAvailable()) {
QApplicationPrivate::setSystemPalette(standardPalette());
QApplicationPrivate::setSystemFont(QGtk::getThemeFont());
+ QGtk::applyCustomPaletteHash();
if (!QGtk::isKDE4Session()) {
qt_filedialog_open_filename_hook = &QGtk::openFilename;
qt_filedialog_save_filename_hook = &QGtk::saveFilename;
@@ -357,12 +383,12 @@ void QGtkStyle::unpolish(QApplication *app)
/*!
\reimp
*/
+
void QGtkStyle::polish(QWidget *widget)
{
QCleanlooksStyle::polish(widget);
if (!QGtk::isThemeAvailable())
return;
-
if (qobject_cast<QAbstractButton*>(widget)
|| qobject_cast<QToolButton*>(widget)
|| qobject_cast<QComboBox*>(widget)
@@ -375,8 +401,6 @@ void QGtkStyle::polish(QWidget *widget)
widget->setAttribute(Qt::WA_Hover);
else if (QTreeView *tree = qobject_cast<QTreeView *> (widget))
tree->viewport()->setAttribute(Qt::WA_Hover);
-
- QGtk::applyGtkSystemPalette(widget);
}
/*!
@@ -399,6 +423,17 @@ int QGtkStyle::pixelMetric(PixelMetric metric,
return QCleanlooksStyle::pixelMetric(metric, option, widget);
switch (metric) {
+ case PM_DefaultFrameWidth:
+ if (qobject_cast<const QFrame*>(widget)) {
+ if (GtkStyle *style =
+ QGtk::gtk_rc_get_style_by_paths(QGtk::gtk_settings_get_default(),
+ "*.GtkScrolledWindow",
+ "*.GtkScrolledWindow",
+ Q_GTK_TYPE_WINDOW))
+ return qMax(style->xthickness, style->ythickness);
+ }
+ return 2;
+
case PM_MenuButtonIndicator:
return 20;
@@ -635,6 +670,66 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
QGtkPainter gtkPainter(painter);
switch (element) {
+ case PE_Frame: {
+ if (widget && widget->inherits("QComboBoxPrivateContainer")){
+ QStyleOption copy = *option;
+ copy.state |= State_Raised;
+ drawPrimitive(PE_PanelMenu, &copy, painter, widget);
+ break;
+ }
+ // Drawing the entire itemview frame is very expensive, especially on the native X11 engine
+ // Instead we cheat a bit and draw a border image without the center part, hence only scaling
+ // thin rectangular images
+ const int pmSize = 64;
+ const int border = pixelMetric(PM_DefaultFrameWidth, option, widget);
+ const QString pmKey = QString(QLS("windowframe %0")).arg(option->state);
+
+ QPixmap pixmap;
+ QPixmapCache::find(pmKey, pixmap);
+ QRect pmRect(QPoint(0,0), QSize(pmSize, pmSize));
+
+ // Only draw through style once
+ if (pixmap.isNull()) {
+ pixmap = QPixmap(pmSize, pmSize);
+ pixmap.fill(Qt::transparent);
+ QPainter pmPainter(&pixmap);
+ QGtkPainter gtkFramePainter(&pmPainter);
+ gtkFramePainter.setUsePixmapCache(false); // Don't cache twice
+
+ GtkShadowType shadow_type = GTK_SHADOW_NONE;
+ if (option->state & State_Sunken)
+ shadow_type = GTK_SHADOW_IN;
+ else if (option->state & State_Raised)
+ shadow_type = GTK_SHADOW_OUT;
+
+ GtkStyle *style = QGtk::gtk_rc_get_style_by_paths(QGtk::gtk_settings_get_default(),
+ "*.GtkScrolledWindow", "*.GtkScrolledWindow", Q_GTK_TYPE_WINDOW);
+ if (style)
+ gtkFramePainter.paintShadow(QGtk::gtkWidget(QLS("GtkFrame")), "viewport", pmRect,
+ option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
+ shadow_type, style);
+ QPixmapCache::insert(pmKey, pixmap);
+ }
+
+ QRect rect = option->rect;
+ const int rw = rect.width() - border;
+ const int rh = rect.height() - border;
+ const int pw = pmRect.width() - border;
+ const int ph = pmRect.height() - border;
+
+ // Sidelines
+ painter->drawPixmap(rect.adjusted(border, 0, -border, -rh), pixmap, pmRect.adjusted(border, 0, -border,-ph));
+ painter->drawPixmap(rect.adjusted(border, rh, -border, 0), pixmap, pmRect.adjusted(border, ph,-border,0));
+ painter->drawPixmap(rect.adjusted(0, border, -rw, -border), pixmap, pmRect.adjusted(0, border, -pw, -border));
+ painter->drawPixmap(rect.adjusted(rw, border, 0, -border), pixmap, pmRect.adjusted(pw, border, 0, -border));
+
+ // Corners
+ painter->drawPixmap(rect.adjusted(0, 0, -rw, -rh), pixmap, pmRect.adjusted(0, 0, -pw,-ph));
+ painter->drawPixmap(rect.adjusted(rw, 0, 0, -rh), pixmap, pmRect.adjusted(pw, 0, 0,-ph));
+ painter->drawPixmap(rect.adjusted(0, rh, -rw, 0), pixmap, pmRect.adjusted(0, ph, -pw,0));
+ painter->drawPixmap(rect.adjusted(rw, rh, 0, 0), pixmap, pmRect.adjusted(pw, ph, 0,0));
+ }
+ break;
case PE_PanelTipLabel: {
GtkWidget *gtkWindow = QGtk::gtkWidget(QLS("GtkWindow")); // The Murrine Engine currently assumes a widget is passed
@@ -856,14 +951,15 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
"interior-focus", &interior_focus,
"focus-line-width", &focus_line_width, NULL);
+ // See https://bugzilla.mozilla.org/show_bug.cgi?id=405421 for info about this hack
+ g_object_set_data(G_OBJECT(gtkEntry), "transparent-bg-hint", GINT_TO_POINTER(TRUE));
+
if (!interior_focus && option->state & State_HasFocus)
rect.adjust(focus_line_width, focus_line_width, -focus_line_width, -focus_line_width);
-
gtkPainter.paintShadow(gtkEntry, "entry", rect, option->state & State_Enabled ?
GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
GTK_SHADOW_IN, gtkEntry->style,
option->state & State_HasFocus ? QLS("focus") : QString());
-
if (!interior_focus && option->state & State_HasFocus)
gtkPainter.paintShadow(gtkEntry, "entry", option->rect, option->state & State_Enabled ?
GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
@@ -882,7 +978,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
if (widget && widget->testAttribute(Qt::WA_SetPalette) &&
resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
- painter->fillRect(textRect, option->palette.base().color());
+ painter->fillRect(textRect, option->palette.base());
else
gtkPainter.paintFlatBox( gtkEntry, "entry_bg", textRect,
option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, gtkEntry->style);
@@ -2412,6 +2508,10 @@ void QGtkStyle::drawControl(ControlElement element,
if (selected) {
QRect rect = option->rect.adjusted(0, 0, -1, -1);
+#ifndef QT_NO_COMBOBOX
+ if (qobject_cast<const QComboBox*>(widget))
+ rect = option->rect;
+#endif
gtkPainter.paintBox( gtkMenuItem, "menuitem", rect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style);
}
@@ -2528,16 +2628,24 @@ void QGtkStyle::drawControl(ControlElement element,
opt.rect = vCheckRect;
drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget);
}
-
painter->drawPixmap(pmr.topLeft(), pixmap);
}
GdkColor gdkText = gtkMenuItem->style->fg[GTK_STATE_NORMAL];
GdkColor gdkDText = gtkMenuItem->style->fg[GTK_STATE_INSENSITIVE];
GdkColor gdkHText = gtkMenuItem->style->fg[GTK_STATE_PRELIGHT];
+ uint resolve_mask = option->palette.resolve();
QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
QColor disabledTextColor = QColor(gdkDText.red>>8, gdkDText.green>>8, gdkDText.blue>>8);
+ if (resolve_mask & (1 << QPalette::ButtonText)) {
+ textColor = option->palette.buttonText().color();
+ disabledTextColor = option->palette.brush(QPalette::Disabled, QPalette::ButtonText).color();
+ }
+
QColor highlightedTextColor = QColor(gdkHText.red>>8, gdkHText.green>>8, gdkHText.blue>>8);
+ if (resolve_mask & (1 << QPalette::HighlightedText)) {
+ highlightedTextColor = option->palette.highlightedText().color();
+ }
if (selected)
painter->setPen(highlightedTextColor);
@@ -2653,10 +2761,13 @@ void QGtkStyle::drawControl(ControlElement element,
if (tab->state & State_Selected)
state = GTK_STATE_NORMAL;
- bool first = tab->position == QStyleOptionTab::Beginning || tab->position == QStyleOptionTab::OnlyOneTab;
- bool last = tab->position == QStyleOptionTab::End || tab->position == QStyleOptionTab::OnlyOneTab;
bool selected = (tab->state & State_Selected);
- if (option->direction == Qt::RightToLeft) {
+ bool first = false, last = false;
+ if (widget) {
+ // This is most accurate and avoids resizing tabs while moving
+ first = tab->rect.left() == widget->rect().left();
+ last = tab->rect.right() == widget->rect().right();
+ } else if (option->direction == Qt::RightToLeft) {
bool tmp = first;
first = last;
last = tmp;
diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm
index a3f5cfe..398e11d 100644
--- a/src/gui/styles/qmacstyle_mac.mm
+++ b/src/gui/styles/qmacstyle_mac.mm
@@ -2189,7 +2189,7 @@ void QMacStyle::polish(QWidget* w)
}
if (qobject_cast<QMenu*>(w) || qobject_cast<QComboBoxPrivateContainer *>(w)) {
- w->setWindowOpacity(0.94);
+ w->setWindowOpacity(QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5 ? 0.985 : 0.94);
if (!w->testAttribute(Qt::WA_SetPalette)) {
QPixmap px(64, 64);
HIThemeMenuDrawInfo mtinfo;
@@ -3854,13 +3854,16 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter
}
break;
case CE_TabBarTabShape:
- if (const QStyleOptionTabV3 *tabOpt = qstyleoption_cast<const QStyleOptionTabV3 *>(opt)) {
- if (tabOpt->documentMode) {
- p->save();
- QRect tabRect = tabOpt->rect;
- drawTabShape(p, tabOpt);
- p->restore();
- return;
+ if (const QStyleOptionTab *tabOpt = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
+
+ if (const QStyleOptionTabV3 *tabOptV3 = qstyleoption_cast<const QStyleOptionTabV3 *>(opt)) {
+ if (tabOptV3->documentMode) {
+ p->save();
+ QRect tabRect = tabOptV3->rect;
+ drawTabShape(p, tabOptV3);
+ p->restore();
+ return;
+ }
}
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index 2558409..49ac57a 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -1514,20 +1514,11 @@ void QRenderRule::configurePalette(QPalette *p, QPalette::ColorRole fr, QPalette
void QRenderRule::configurePalette(QPalette *p, QPalette::ColorGroup cg, const QWidget *w, bool embedded)
{
-#ifdef QT_NO_COMBOBOX
- const bool isReadOnlyCombo = false;
-#else
- const bool isReadOnlyCombo = qobject_cast<const QComboBox *>(w) != 0;
-#endif
-
if (bg && bg->brush.style() != Qt::NoBrush) {
- if (isReadOnlyCombo) {
- p->setBrush(cg, QPalette::Base, bg->brush); // for windows, windowxp
- p->setBrush(cg, QPalette::Button, bg->brush); // for plastique
- } else {
- p->setBrush(cg, w->backgroundRole(), bg->brush);
- //p->setBrush(cg, QPalette::Window, bg->brush);
- }
+ p->setBrush(cg, QPalette::Base, bg->brush); // for windows, windowxp
+ p->setBrush(cg, QPalette::Button, bg->brush); // for plastique
+ p->setBrush(cg, w->backgroundRole(), bg->brush);
+ p->setBrush(cg, QPalette::Window, bg->brush);
}
if (embedded) {
@@ -1542,12 +1533,9 @@ void QRenderRule::configurePalette(QPalette *p, QPalette::ColorGroup cg, const Q
return;
if (pal->foreground.style() != Qt::NoBrush) {
- if (isReadOnlyCombo) {
- p->setBrush(cg, QPalette::ButtonText, pal->foreground);
- } else {
- p->setBrush(cg, w->foregroundRole(), pal->foreground);
- p->setBrush(cg, QPalette::WindowText, pal->foreground);
- }
+ p->setBrush(cg, QPalette::ButtonText, pal->foreground);
+ p->setBrush(cg, w->foregroundRole(), pal->foreground);
+ p->setBrush(cg, QPalette::WindowText, pal->foreground);
p->setBrush(cg, QPalette::Text, pal->foreground);
}
if (pal->selectionBackground.style() != Qt::NoBrush)
@@ -2916,6 +2904,10 @@ void QStyleSheetStyle::polish(QWidget *w)
if (ew->autoFillBackground()) {
ew->setAutoFillBackground(false);
autoFillDisabledWidgets->insert(w);
+ if (ew != w) { //eg. viewport of a scrollarea
+ //(in order to draw the background anyway in case we don't.)
+ ew->setAttribute(Qt::WA_StyledBackground, true);
+ }
}
if (!rule.hasBackground() || rule.background()->isTransparent() || rule.hasBox()
|| (!rule.hasNativeBorder() && !rule.border()->isOpaque()))
@@ -4345,8 +4337,16 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
return;
case PE_Widget:
- if (!rule.hasBackground())
+ if (!rule.hasBackground()) {
+ QWidget *container = containerWidget(w);
+ if (autoFillDisabledWidgets->contains(container)
+ && (container == w || !renderRule(container, opt).hasBackground())) {
+ //we do not have a background, but we disabled the autofillbackground anyway. so fill the background now.
+ // (this may happen if we have rules like :focus)
+ p->fillRect(opt->rect, opt->palette.brush(w->backgroundRole()));
+ }
break;
+ }
#ifndef QT_NO_SCROLLAREA
if (const QAbstractScrollArea *sa = qobject_cast<const QAbstractScrollArea *>(w)) {
@@ -4840,7 +4840,8 @@ int QStyleSheetStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const
if (subRule.hasContentsSize())
return subRule.size().height();
else if (subRule.hasBox() || subRule.hasBorder()) {
- return subRule.size(QSize(0, opt->fontMetrics.lineSpacing())).height();
+ QFontMetrics fm = opt ? opt->fontMetrics : w->fontMetrics();
+ return subRule.size(QSize(0, fm.lineSpacing())).height();
}
break;
}
diff --git a/src/gui/styles/qwindowsmobilestyle.cpp b/src/gui/styles/qwindowsmobilestyle.cpp
index c52c700..1c03b9e 100644
--- a/src/gui/styles/qwindowsmobilestyle.cpp
+++ b/src/gui/styles/qwindowsmobilestyle.cpp
@@ -3401,6 +3401,9 @@ int QWindowsMobileStyle::styleHint(StyleHint hint, const QStyleOption *opt, cons
case SH_ScrollBar_ContextMenu:
ret = false;
break;
+ case SH_MenuBar_AltKeyNavigation:
+ ret = false;
+ break;
default:
ret = QWindowsStyle::styleHint(hint, opt, widget, returnData);
break;
diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp
index 4c3060d..013ca1e 100644
--- a/src/gui/styles/qwindowsvistastyle.cpp
+++ b/src/gui/styles/qwindowsvistastyle.cpp
@@ -801,12 +801,20 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
if (vopt->viewItemPosition == QStyleOptionViewItemV4::OnlyOne
|| vopt->viewItemPosition == QStyleOptionViewItemV4::Invalid)
painter->drawPixmap(pixmapRect.topLeft(), pixmap);
- else if (reverse ? rightSection : leftSection)
- painter->drawPixmap(pixmapRect, pixmap, srcRect.adjusted(0, 0, -frame, 0));
- else if (reverse ? leftSection : rightSection)
- painter->drawPixmap(pixmapRect, pixmap,
- srcRect.adjusted(frame, 0, 0, 0));
- else if (vopt->viewItemPosition == QStyleOptionViewItemV4::Middle)
+ 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 == QStyleOptionViewItemV4::Middle)
painter->drawPixmap(pixmapRect, pixmap,
srcRect.adjusted(frame, 0, -frame, 0));
} else {
@@ -2388,6 +2396,9 @@ void QWindowsVistaStyle::polish(QWidget *widget)
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);
+ }
}
/*!
diff --git a/src/gui/styles/qwindowsvistastyle_p.h b/src/gui/styles/qwindowsvistastyle_p.h
index 877bc50..cef2b71 100644
--- a/src/gui/styles/qwindowsvistastyle_p.h
+++ b/src/gui/styles/qwindowsvistastyle_p.h
@@ -76,6 +76,7 @@
#include <qscrollbar.h>
#include <qprogressbar.h>
#include <qdockwidget.h>
+#include <qlistview.h>
#include <qtreeview.h>
#include <qtextedit.h>
#include <qmessagebox.h>
diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp
index 9d735a7..2f4254e 100644
--- a/src/gui/styles/qwindowsxpstyle.cpp
+++ b/src/gui/styles/qwindowsxpstyle.cpp
@@ -607,7 +607,7 @@ void QWindowsXPStylePrivate::drawBackground(XPThemeData &themeData)
QPainter *painter = themeData.painter;
Q_ASSERT_X(painter != 0, "QWindowsXPStylePrivate::drawBackground()", "Trying to draw a theme part without a painter");
- if (!painter)
+ if (!painter || !painter->isActive())
return;
painter->save();
@@ -2834,7 +2834,7 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
bflags |= State_MouseOver;
}
}
-
+
QStyleOption tool(0);
tool.palette = toolbutton->palette;
if (toolbutton->subControls & SC_ToolButton) {
diff --git a/src/gui/text/qfontdatabase_win.cpp b/src/gui/text/qfontdatabase_win.cpp
index c9f5586..780ae28 100644
--- a/src/gui/text/qfontdatabase_win.cpp
+++ b/src/gui/text/qfontdatabase_win.cpp
@@ -699,6 +699,7 @@ QFontEngine *loadEngine(int script, const QFontPrivate *fp, const QFontDef &requ
}
bool stockFont = false;
+ bool preferClearTypeAA = false;
HFONT hfont = 0;
@@ -799,10 +800,12 @@ QFontEngine *loadEngine(int script, const QFontPrivate *fp, const QFontDef &requ
#endif
if (request.styleStrategy & QFont::PreferAntialias) {
- if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP)
+ if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP) {
qual = 5; // == CLEARTYPE_QUALITY;
- else
+ preferClearTypeAA = true;
+ } else {
qual = ANTIALIASED_QUALITY;
+ }
} else if (request.styleStrategy & QFont::NoAntialias) {
qual = NONANTIALIASED_QUALITY;
}
@@ -884,6 +887,9 @@ QFontEngine *loadEngine(int script, const QFontPrivate *fp, const QFontDef &requ
}
QFontEngineWin *few = new QFontEngineWin(font_name, hfont, stockFont, lf);
+ if (preferClearTypeAA)
+ few->glyphFormat = QFontEngineGlyphCache::Raster_RGBMask;
+
// Also check for OpenType tables when using complex scripts
// ### TODO: This only works for scripts that require OpenType. More generally
// for scripts that do not require OpenType we should just look at the list of
@@ -1134,7 +1140,7 @@ static void getFamiliesAndSignatures(const QByteArray &fontData, QFontDatabasePr
signature.fsUsb[1] = qFromBigEndian<quint32>(table + 46);
signature.fsUsb[2] = qFromBigEndian<quint32>(table + 50);
signature.fsUsb[3] = qFromBigEndian<quint32>(table + 54);
-
+
signature.fsCsb[0] = qFromBigEndian<quint32>(table + 78);
signature.fsCsb[1] = qFromBigEndian<quint32>(table + 82);
}
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 45a25a4..cb0b436 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -1051,7 +1051,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, Glyph
Q_ASSERT(antialias);
uchar *convoluted = new uchar[bitmap.rows*bitmap.pitch];
bool useLegacyLcdFilter = false;
-#if defined(FT_LCD_FILTER_H)
+#if defined(FC_LCD_FILTER) && defined(FT_LCD_FILTER_H)
useLegacyLcdFilter = (lcdFilterType == FT_LCD_FILTER_LEGACY);
#endif
uchar *buffer = bitmap.buffer;
diff --git a/src/gui/text/qfontengine_mac.mm b/src/gui/text/qfontengine_mac.mm
index 40d145a..425cab2 100644
--- a/src/gui/text/qfontengine_mac.mm
+++ b/src/gui/text/qfontengine_mac.mm
@@ -120,7 +120,7 @@ OSStatus QMacFontPath::closePath(void *data)
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
-QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const ATSFontFamilyRef &, const ATSFontRef &atsFontRef, const QFontDef &fontDef, bool)
+QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const ATSFontFamilyRef &, const ATSFontRef &atsFontRef, const QFontDef &fontDef, bool kerning)
: QFontEngineMulti(0)
{
this->fontDef = fontDef;
@@ -149,11 +149,15 @@ QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const ATSFontFamilyRef &, con
CFRetain(ctfont);
}
- const void *keys[] = { NSFontAttributeName };
- const void *values[] = { ctfont };
- attributeDict = CFDictionaryCreate(0, keys, values, 1,
+ attributeDict = CFDictionaryCreateMutable(0, 2,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
+ CFDictionaryAddValue(attributeDict, NSFontAttributeName, ctfont);
+ if (!kerning) {
+ float zero = 0.0;
+ QCFType<CFNumberRef> noKern = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &zero);
+ CFDictionaryAddValue(attributeDict, kCTKernAttributeName, &noKern);
+ }
QCoreTextFontEngine *fe = new QCoreTextFontEngine(ctfont, fontDef, this);
fe->ref.ref();
@@ -277,10 +281,11 @@ bool QCoreTextFontEngineMulti::stringToCMap(const QChar *str, int len, QGlyphLay
outAdvances_x[idx] = QFixed::fromReal(tmpPoints[i + 1].x - tmpPoints[i].x);
outAdvances_y[idx] = QFixed::fromReal(tmpPoints[i + 1].y - tmpPoints[i].y);
}
- double runWidth = ceil(CTRunGetTypographicBounds(run, range, 0, 0, 0));
- runWidth += tmpPoints[0].x;
+ CGSize lastGlyphAdvance;
+ CTFontGetAdvancesForGlyphs(runFont, kCTFontHorizontalOrientation, tmpGlyphs + glyphCount - 1, &lastGlyphAdvance, 1);
+
outGlyphs[rtl ? 0 : (glyphCount - 1)] = tmpGlyphs[glyphCount - 1] | fontIndex;
- outAdvances_x[rtl ? 0 : (glyphCount - 1)] = QFixed::fromReal(runWidth - tmpPoints[glyphCount - 1].x);
+ outAdvances_x[rtl ? 0 : (glyphCount - 1)] = QFixed::fromReal(lastGlyphAdvance.width).ceil();
}
outGlyphs += glyphCount;
outAttributes += glyphCount;
@@ -365,26 +370,26 @@ glyph_metrics_t QCoreTextFontEngine::boundingBox(glyph_t glyph)
ret.y = -QFixed::fromReal(rect.origin.y) - ret.height;
CGSize advances[1];
CTFontGetAdvancesForGlyphs(ctfont, kCTFontHorizontalOrientation, &g, advances, 1);
- ret.xoff = QFixed::fromReal(advances[0].width);
- ret.yoff = QFixed::fromReal(advances[0].height);
+ ret.xoff = QFixed::fromReal(advances[0].width).ceil();
+ ret.yoff = QFixed::fromReal(advances[0].height).ceil();
return ret;
}
QFixed QCoreTextFontEngine::ascent() const
{
- return QFixed::fromReal(CTFontGetAscent(ctfont));
+ return QFixed::fromReal(CTFontGetAscent(ctfont)).ceil();
}
QFixed QCoreTextFontEngine::descent() const
{
- return QFixed::fromReal(CTFontGetDescent(ctfont));
+ return QFixed::fromReal(CTFontGetDescent(ctfont)).ceil();
}
QFixed QCoreTextFontEngine::leading() const
{
- return QFixed::fromReal(CTFontGetLeading(ctfont));
+ return QFixed::fromReal(CTFontGetLeading(ctfont)).ceil();
}
QFixed QCoreTextFontEngine::xHeight() const
{
- return QFixed::fromReal(CTFontGetXHeight(ctfont));
+ return QFixed::fromReal(CTFontGetXHeight(ctfont)).ceil();
}
QFixed QCoreTextFontEngine::averageCharWidth() const
{
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index 22a1994..7382b39 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -487,7 +487,7 @@ private:
uint fontIndexForFont(CTFontRef id) const;
CTFontRef ctfont;
- mutable QCFType<CFDictionaryRef> attributeDict;
+ mutable QCFType<CFMutableDictionaryRef> attributeDict;
friend class QFontDialogPrivate;
};
diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h
index c337783..9c3d6c2 100644
--- a/src/gui/text/qtextdocument.h
+++ b/src/gui/text/qtextdocument.h
@@ -287,6 +287,7 @@ public:
private:
Q_DISABLE_COPY(QTextDocument)
Q_DECLARE_PRIVATE(QTextDocument)
+ friend class QTextObjectPrivate;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QTextDocument::FindFlags)
diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp
index 320ecbf..05ddf47 100644
--- a/src/gui/text/qtextdocument_p.cpp
+++ b/src/gui/text/qtextdocument_p.cpp
@@ -1484,7 +1484,6 @@ QTextObject *QTextDocumentPrivate::createObject(const QTextFormat &f, int object
QTextObject *obj = document()->createObject(f);
if (obj) {
- obj->d_func()->pieceTable = this;
obj->d_func()->objectIndex = objectIndex == -1 ? formats.createObjectIndex(f) : objectIndex;
objects[obj->d_func()->objectIndex] = obj;
}
diff --git a/src/gui/text/qtextlist.cpp b/src/gui/text/qtextlist.cpp
index e305027..d1a3361 100644
--- a/src/gui/text/qtextlist.cpp
+++ b/src/gui/text/qtextlist.cpp
@@ -50,6 +50,11 @@ QT_BEGIN_NAMESPACE
class QTextListPrivate : public QTextBlockGroupPrivate
{
+public:
+ QTextListPrivate(QTextDocument *doc)
+ : QTextBlockGroupPrivate(doc)
+ {
+ }
};
/*!
@@ -111,7 +116,7 @@ class QTextListPrivate : public QTextBlockGroupPrivate
/*! \internal
*/
QTextList::QTextList(QTextDocument *doc)
- : QTextBlockGroup(*new QTextListPrivate, doc)
+ : QTextBlockGroup(*new QTextListPrivate(doc), doc)
{
}
diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp
index 1645a21..3f4c8e5 100644
--- a/src/gui/text/qtextobject.cpp
+++ b/src/gui/text/qtextobject.cpp
@@ -88,7 +88,7 @@ QT_BEGIN_NAMESPACE
from QTextDocument::createObject().
*/
QTextObject::QTextObject(QTextDocument *doc)
- : QObject(*new QTextObjectPrivate, doc)
+ : QObject(*new QTextObjectPrivate(doc), doc)
{
}
@@ -98,7 +98,7 @@ QTextObject::QTextObject(QTextDocument *doc)
\internal
*/
QTextObject::QTextObject(QTextObjectPrivate &p, QTextDocument *doc)
- :QObject(p, doc)
+ : QObject(p, doc)
{
}
@@ -221,7 +221,7 @@ void QTextBlockGroupPrivate::markBlocksDirty()
QTextDocument::createObject().
*/
QTextBlockGroup::QTextBlockGroup(QTextDocument *doc)
- : QTextObject(*new QTextBlockGroupPrivate, doc)
+ : QTextObject(*new QTextBlockGroupPrivate(doc), doc)
{
}
@@ -410,7 +410,7 @@ QTextFrameLayoutData::~QTextFrameLayoutData()
Creates a new empty frame for the text \a document.
*/
QTextFrame::QTextFrame(QTextDocument *doc)
- : QTextObject(*new QTextFramePrivate, doc)
+ : QTextObject(*new QTextFramePrivate(doc), doc)
{
Q_D(QTextFrame);
d->fragment_start = 0;
diff --git a/src/gui/text/qtextobject_p.h b/src/gui/text/qtextobject_p.h
index b00a16a..dd05eb4 100644
--- a/src/gui/text/qtextobject_p.h
+++ b/src/gui/text/qtextobject_p.h
@@ -55,6 +55,7 @@
#include "QtGui/qtextobject.h"
#include "private/qobject_p.h"
+#include "QtGui/qtextdocument.h"
QT_BEGIN_NAMESPACE
@@ -64,6 +65,10 @@ class QTextObjectPrivate : public QObjectPrivate
{
Q_DECLARE_PUBLIC(QTextObject)
public:
+ QTextObjectPrivate(QTextDocument *doc)
+ : pieceTable(doc->d_func()), objectIndex(-1)
+ {
+ }
QTextDocumentPrivate *pieceTable;
int objectIndex;
};
@@ -72,7 +77,10 @@ class QTextBlockGroupPrivate : public QTextObjectPrivate
{
Q_DECLARE_PUBLIC(QTextBlockGroup)
public:
-
+ QTextBlockGroupPrivate(QTextDocument *doc)
+ : QTextObjectPrivate(doc)
+ {
+ }
typedef QList<QTextBlock> BlockList;
BlockList blocks;
void markBlocksDirty();
@@ -85,7 +93,10 @@ class QTextFramePrivate : public QTextObjectPrivate
friend class QTextDocumentPrivate;
Q_DECLARE_PUBLIC(QTextFrame)
public:
-
+ QTextFramePrivate(QTextDocument *doc)
+ : QTextObjectPrivate(doc)
+ {
+ }
virtual void fragmentAdded(const QChar &type, uint fragment);
virtual void fragmentRemoved(const QChar &type, uint fragment);
void remove_me();
diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp
index 375bb09..ba1c04f 100644
--- a/src/gui/text/qtexttable.cpp
+++ b/src/gui/text/qtexttable.cpp
@@ -553,7 +553,7 @@ void QTextTablePrivate::update() const
/*! \internal
*/
QTextTable::QTextTable(QTextDocument *doc)
- : QTextFrame(*new QTextTablePrivate, doc)
+ : QTextFrame(*new QTextTablePrivate(doc), doc)
{
}
diff --git a/src/gui/text/qtexttable_p.h b/src/gui/text/qtexttable_p.h
index 1ba3a3f..f2b45b6 100644
--- a/src/gui/text/qtexttable_p.h
+++ b/src/gui/text/qtexttable_p.h
@@ -62,7 +62,7 @@ class QTextTablePrivate : public QTextFramePrivate
{
Q_DECLARE_PUBLIC(QTextTable)
public:
- QTextTablePrivate() : grid(0), nRows(0), dirty(true), blockFragmentUpdates(false) {}
+ QTextTablePrivate(QTextDocument *document) : QTextFramePrivate(document), grid(0), nRows(0), dirty(true), blockFragmentUpdates(false) {}
~QTextTablePrivate();
static QTextTable *createTable(QTextDocumentPrivate *, int pos, int rows, int cols, const QTextTableFormat &tableFormat);
diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp
index 998098c..e6bc80a 100644
--- a/src/gui/util/qcompleter.cpp
+++ b/src/gui/util/qcompleter.cpp
@@ -824,9 +824,9 @@ void QCompleterPrivate::_q_complete(QModelIndex index, bool highlighted)
Q_Q(QCompleter);
QString completion;
- if (!index.isValid())
+ if (!index.isValid() || (index.row() >= proxy->engine->matchCount())) {
completion = prefix;
- else {
+ } else {
QModelIndex si = proxy->mapToSource(index);
si = si.sibling(si.row(), column); // for clicked()
completion = q->pathFromIndex(si);
@@ -1079,7 +1079,14 @@ void QCompleter::setPopup(QAbstractItemView *popup)
popup->setModel(d->proxy);
popup->hide();
popup->setParent(0, Qt::Popup);
+
+ Qt::FocusPolicy origPolicy = Qt::NoFocus;
+ if (d->widget)
+ origPolicy = d->widget->focusPolicy();
popup->setFocusPolicy(Qt::NoFocus);
+ if (d->widget)
+ d->widget->setFocusPolicy(origPolicy);
+
popup->setFocusProxy(d->widget);
popup->installEventFilter(this);
popup->setItemDelegate(new QCompleterItemDelegate(popup));
diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp
index d7e77de..b84b63f 100644
--- a/src/gui/util/qdesktopservices.cpp
+++ b/src/gui/util/qdesktopservices.cpp
@@ -159,6 +159,11 @@ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
If the URL is a reference to a local file (i.e., the URL scheme is "file") then
it will be opened with a suitable application instead of a Web browser.
+ The following example opens a file on the Windows file system residing on a path
+ that contains spaces:
+
+ \snippet doc/src/snippets/code/src_gui_util_qdesktopservices.cpp 2
+
If a \c mailto URL is specified, the user's e-mail client will be used to open a
composer window containing the options specified in the URL, similar to the way
\c mailto links are handled by a Web browser.
diff --git a/src/gui/widgets/qabstractbutton.cpp b/src/gui/widgets/qabstractbutton.cpp
index 330a7f8..61ed0ea 100644
--- a/src/gui/widgets/qabstractbutton.cpp
+++ b/src/gui/widgets/qabstractbutton.cpp
@@ -1248,15 +1248,6 @@ void QAbstractButton::timerEvent(QTimerEvent *e)
}
}
-#if defined(Q_OS_WINCE) && !defined(QT_NO_CONTEXTMENU)
-/*! \reimp */
-void QAbstractButton::contextMenuEvent(QContextMenuEvent *e)
-{
- e->ignore();
- setDown(false);
-}
-#endif
-
/*! \reimp */
void QAbstractButton::focusInEvent(QFocusEvent *e)
{
diff --git a/src/gui/widgets/qabstractbutton.h b/src/gui/widgets/qabstractbutton.h
index 6503a56..f0cbb05 100644
--- a/src/gui/widgets/qabstractbutton.h
+++ b/src/gui/widgets/qabstractbutton.h
@@ -143,9 +143,6 @@ protected:
void focusOutEvent(QFocusEvent *e);
void changeEvent(QEvent *e);
void timerEvent(QTimerEvent *e);
-#ifdef Q_OS_WINCE
- void contextMenuEvent(QContextMenuEvent *e);
-#endif
#ifdef QT3_SUPPORT
public:
diff --git a/src/gui/widgets/qcocoamenu_mac.mm b/src/gui/widgets/qcocoamenu_mac.mm
index c5977e4..6434289 100644
--- a/src/gui/widgets/qcocoamenu_mac.mm
+++ b/src/gui/widgets/qcocoamenu_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
#include "qmacdefines_mac.h"
#include "qapplication.h"
@@ -55,6 +55,16 @@
QT_FORWARD_DECLARE_CLASS(QAction)
QT_FORWARD_DECLARE_CLASS(QWidget)
QT_FORWARD_DECLARE_CLASS(QApplication)
+QT_FORWARD_DECLARE_CLASS(QCoreApplication)
+QT_FORWARD_DECLARE_CLASS(QApplicationPrivate)
+QT_FORWARD_DECLARE_CLASS(QKeyEvent)
+QT_FORWARD_DECLARE_CLASS(QEvent)
+
+QT_BEGIN_NAMESPACE
+extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); //qapplication.cpp
+QT_END_NAMESPACE
+
+QT_USE_NAMESPACE
@implementation QT_MANGLE_NAMESPACE(QCocoaMenu)
@@ -130,8 +140,9 @@ QT_FORWARD_DECLARE_CLASS(QApplication)
// If it does, then we will first send the key sequence to the QWidget that has focus
// since (in Qt's eyes) it needs to a chance at the key event first. If the widget
// accepts the key event, we then return YES, but set the target and action to be nil,
- // which means that the action should not be triggered. In every other case we return
- // NO, which means that Cocoa can do as it pleases (i.e., fire the menu action).
+ // which means that the action should not be triggered, and instead dispatch the event ourselves.
+ // In every other case we return NO, which means that Cocoa can do as it pleases
+ // (i.e., fire the menu action).
NSMenuItem *whichItem;
if ([self hasShortcut:menu
forKey:[event characters]
@@ -154,9 +165,11 @@ QT_FORWARD_DECLARE_CLASS(QApplication)
accel_ev.ignore();
qt_sendSpontaneousEvent(widget, &accel_ev);
if (accel_ev.isAccepted()) {
- *target = nil;
- *action = nil;
- return YES;
+ if (qt_dispatchKeyEvent(event, widget)) {
+ *target = nil;
+ *action = nil;
+ return YES;
+ }
}
}
}
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index 8c8e231..e9884bb 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -61,6 +61,7 @@
#endif
#include <private/qcombobox_p.h>
#include <private/qabstractitemmodel_p.h>
+#include <private/qabstractscrollarea_p.h>
#include <qdebug.h>
#ifdef Q_WS_X11
@@ -108,7 +109,7 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt
const QModelIndex &index) const
{
QStyleOptionMenuItem menuOption;
- menuOption.palette = QComboBoxPrivate::viewContainerPalette(mCombo).resolve(QApplication::palette("QMenu"));
+ menuOption.palette = option.palette.resolve(QApplication::palette("QMenu"));
menuOption.state = QStyle::State_None;
if (mCombo->window()->isActiveWindow())
menuOption.state = QStyle::State_Active;
@@ -2274,7 +2275,6 @@ void QComboBox::showPopup()
bool boundToScreen = !window()->testAttribute(Qt::WA_DontShowOnScreen);
const bool usePopup = style->styleHint(QStyle::SH_ComboBox_Popup, &opt, this);
-
{
int listHeight = 0;
int count = 0;
@@ -2306,11 +2306,23 @@ void QComboBox::showPopup()
listRect.setHeight(listHeight);
}
- // add the frame size to the height. (+the spacing for the top and the bottom item)
- int marginTop, marginBottom;
- view()->getContentsMargins(0, &marginTop, 0, &marginBottom);
- listRect.setHeight(listRect.height() + 2*container->spacing()
- + marginTop + marginBottom);
+ {
+ // add the spacing for the grid on the top and the bottom;
+ int heightMargin = 2*container->spacing();
+
+ // add the frame of the container
+ int marginTop, marginBottom;
+ container->getContentsMargins(0, &marginTop, 0, &marginBottom);
+ heightMargin += marginTop + marginBottom;
+
+ //add the frame of the view
+ view()->getContentsMargins(0, &marginTop, 0, &marginBottom);
+ marginTop += static_cast<QAbstractScrollAreaPrivate *>(QObjectPrivate::get(view()))->top;
+ marginBottom += static_cast<QAbstractScrollAreaPrivate *>(QObjectPrivate::get(view()))->bottom;
+ heightMargin += marginTop + marginBottom;
+
+ listRect.setHeight(listRect.height() + heightMargin);
+ }
// Add space for margin at top and bottom if the style wants it.
if (usePopup)
diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h
index f1203dc..c39a231 100644
--- a/src/gui/widgets/qcombobox_p.h
+++ b/src/gui/widgets/qcombobox_p.h
@@ -265,7 +265,7 @@ protected:
const QStyleOptionViewItem &option,
const QModelIndex &index) const {
QStyleOptionMenuItem opt = getStyleOption(option, index);
- painter->eraseRect(option.rect);
+ painter->fillRect(option.rect, opt.palette.background());
mCombo->style()->drawControl(QStyle::CE_MenuItem, &opt, painter, mCombo);
}
QSize sizeHint(const QStyleOptionViewItem &option,
diff --git a/src/gui/widgets/qdialogbuttonbox.cpp b/src/gui/widgets/qdialogbuttonbox.cpp
index 246da95..4a95292 100644
--- a/src/gui/widgets/qdialogbuttonbox.cpp
+++ b/src/gui/widgets/qdialogbuttonbox.cpp
@@ -752,7 +752,8 @@ QDialogButtonBox::~QDialogButtonBox()
\value KdeLayout Use a policy appropriate for applications on KDE.
\value GnomeLayout Use a policy appropriate for applications on GNOME.
- The button layout is specified by the \l{style()}{current style}.
+ The button layout is specified by the \l{style()}{current style}. However,
+ on the X11 platform, it may be influenced by the desktop environment.
*/
/*!
diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp
index 9261c63..4f0ec1e 100644
--- a/src/gui/widgets/qdockarealayout.cpp
+++ b/src/gui/widgets/qdockarealayout.cpp
@@ -579,7 +579,7 @@ void QDockAreaLayoutInfo::fitItems()
QLayoutStruct &ls = layout_struct_list[j++];
ls.init();
ls.empty = false;
- if (gap || (item.flags & QDockAreaLayoutItem::KeepSize)) {
+ if (item.flags & QDockAreaLayoutItem::KeepSize) {
ls.minimumSize = ls.maximumSize = ls.sizeHint = item.size;
ls.expansive = false;
ls.stretch = 0;
diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp
index 865b19c..a5be5f8 100644
--- a/src/gui/widgets/qdockwidget.cpp
+++ b/src/gui/widgets/qdockwidget.cpp
@@ -406,10 +406,14 @@ int QDockWidgetLayout::minimumTitleWidth() const
QSize closeSize(0, 0);
QSize floatSize(0, 0);
- if (QLayoutItem *item = item_list[CloseButton])
- closeSize = item->sizeHint();
- if (QLayoutItem *item = item_list[FloatButton])
- floatSize = item->sizeHint();
+ if (hasFeature(q, QDockWidget::DockWidgetClosable)) {
+ if (QLayoutItem *item = item_list[CloseButton])
+ closeSize = item->widget()->sizeHint();
+ }
+ if (hasFeature(q, QDockWidget::DockWidgetFloatable)) {
+ if (QLayoutItem *item = item_list[FloatButton])
+ floatSize = item->widget()->sizeHint();
+ }
int titleHeight = this->titleHeight();
diff --git a/src/gui/widgets/qmaccocoaviewcontainer_mac.mm b/src/gui/widgets/qmaccocoaviewcontainer_mac.mm
index 710af6a..380e983 100644
--- a/src/gui/widgets/qmaccocoaviewcontainer_mac.mm
+++ b/src/gui/widgets/qmaccocoaviewcontainer_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
#import <Cocoa/Cocoa.h>
#include <private/qwidget_p.h>
diff --git a/src/gui/widgets/qmacnativewidget_mac.mm b/src/gui/widgets/qmacnativewidget_mac.mm
index 1bc0430..0f4edf9 100644
--- a/src/gui/widgets/qmacnativewidget_mac.mm
+++ b/src/gui/widgets/qmacnativewidget_mac.mm
@@ -1,11 +1,11 @@
/****************************************************************************
- **
- ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
- **
- ** This file is part of the QtGui module of the Qt Toolkit.
- **
- ** $QT_BEGIN_LICENSE:LGPL$
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
@@ -36,11 +36,11 @@
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
** $QT_END_LICENSE$
- **
- ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
- ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- **
- ****************************************************************************/
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
#import <Cocoa/Cocoa.h>
#import <private/qcocoaview_mac_p.h>
diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp
index 46d6471..2abc9e8 100644
--- a/src/gui/widgets/qmainwindow.cpp
+++ b/src/gui/widgets/qmainwindow.cpp
@@ -481,7 +481,7 @@ void QMainWindow::setMenuBar(QMenuBar *menuBar)
oldMenuBar->deleteLater();
}
#ifdef Q_OS_WINCE
- if (menuBar->size().height() > 0)
+ if (menuBar && menuBar->size().height() > 0)
#endif
d->layout->setMenuBar(menuBar);
}
diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp
index 768446e..eade633 100644
--- a/src/gui/widgets/qmainwindowlayout.cpp
+++ b/src/gui/widgets/qmainwindowlayout.cpp
@@ -1542,8 +1542,8 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem)
if (!previousPath.isEmpty())
layoutState.remove(previousPath);
+ pluggingWidget = widget;
if (dockOptions & QMainWindow::AnimatedDocks) {
- pluggingWidget = widget;
QRect globalRect = currentGapRect;
globalRect.moveTopLeft(parentWidget()->mapToGlobal(globalRect.topLeft()));
#ifndef QT_NO_DOCKWIDGET
@@ -1575,6 +1575,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem)
#endif
currentGapPos.clear();
updateGapIndicator();
+ pluggingWidget = 0;
}
return true;
diff --git a/src/gui/widgets/qmainwindowlayout_mac.mm b/src/gui/widgets/qmainwindowlayout_mac.mm
index 950f758..c807afb 100644
--- a/src/gui/widgets/qmainwindowlayout_mac.mm
+++ b/src/gui/widgets/qmainwindowlayout_mac.mm
@@ -1,3 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+****************************************************************************/
+
#include <private/qmainwindowlayout_p.h>
#include <qtoolbar.h>
#include <private/qtoolbarlayout_p.h>
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index b64a614..6be0f19 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -2916,8 +2916,8 @@ void QMenu::internalDelayedPopup()
int subMenuOffset = style()->pixelMetric(QStyle::PM_SubMenuOverlap, 0, this);
const QRect actionRect(d->actionRect(d->currentAction));
const QSize menuSize(d->activeMenu->sizeHint());
- const QPoint rightPos(mapToGlobal(QPoint(rect().right() + subMenuOffset + 1, actionRect.top())));
- const QPoint leftPos(mapToGlobal(QPoint(rect().left() - subMenuOffset - menuSize.width(), actionRect.top())));
+ const QPoint rightPos(mapToGlobal(QPoint(actionRect.right() + subMenuOffset + 1, actionRect.top())));
+ const QPoint leftPos(mapToGlobal(QPoint(actionRect.left() - subMenuOffset - menuSize.width(), actionRect.top())));
QPoint pos(rightPos);
QMenu *caused = qobject_cast<QMenu*>(d->activeMenu->d_func()->causedPopup.widget);
diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp
index 7d970ad..b562b1f 100644
--- a/src/gui/widgets/qtabbar.cpp
+++ b/src/gui/widgets/qtabbar.cpp
@@ -131,7 +131,7 @@ void QTabBar::initStyleOption(QStyleOptionTab *option, int tabIndex) const
option->state &= ~QStyle::State_Enabled;
if (isActiveWindow())
option->state |= QStyle::State_Active;
- if (option->rect == d->hoverRect)
+ if (!d->dragInProgress && option->rect == d->hoverRect)
option->state |= QStyle::State_MouseOver;
option->shape = d->shape;
option->text = tab.text;
@@ -454,9 +454,6 @@ void QTabBarPrivate::layoutTabs()
maxExtent = maxWidth;
}
- if (pressedIndex != -1 && movable)
- grabCache(0, tabList.count(), true);
-
Q_ASSERT(tabChainIndex == tabChain.count() - 1); // add an assert just to make sure.
// Mirror our front item.
tabChain[tabChainIndex].init();
@@ -1170,13 +1167,13 @@ void QTabBar::setCurrentIndex(int index)
d->currentIndex = index;
update();
d->makeVisible(index);
+ d->tabList[index].lastTab = oldIndex;
+ d->layoutWidgets(oldIndex);
+ d->layoutWidgets(index);
#ifdef QT3_SUPPORT
emit selected(index);
#endif
emit currentChanged(index);
- d->tabList[index].lastTab = oldIndex;
- d->layoutWidgets(oldIndex);
- d->layoutWidgets(index);
}
}
@@ -1484,6 +1481,8 @@ void QTabBar::paintEvent(QPaintEvent *)
bool vertical = verticalTabs(d->shape);
QStyleOptionTab cutTab;
selected = d->currentIndex;
+ if (d->dragInProgress)
+ selected = d->pressedIndex;
for (int i = 0; i < d->tabList.count(); ++i)
optTabBase.tabBarRect |= tabRect(i);
@@ -1522,11 +1521,7 @@ void QTabBar::paintEvent(QPaintEvent *)
if (i == selected)
continue;
- if (!d->tabList[i].animatingCache.isNull() && d->paintWithOffsets) {
- p.drawPixmap(tab.rect, d->tabList[i].animatingCache);
- } else {
- p.drawControl(QStyle::CE_TabBarTab, tab);
- }
+ p.drawControl(QStyle::CE_TabBarTab, tab);
}
// Draw the selected tab last to get it "on top"
@@ -1539,7 +1534,11 @@ void QTabBar::paintEvent(QPaintEvent *)
else
tab.rect.moveLeft(tab.rect.x() + d->tabList[selected].dragOffset);
}
- p.drawControl(QStyle::CE_TabBarTab, tab);
+ if (!d->dragInProgress)
+ p.drawControl(QStyle::CE_TabBarTab, tab);
+ else
+ d->movingTab->setGeometry(tab.rect);
+
}
// Only draw the tear indicator if necessary. Most of the time we don't need too.
@@ -1680,6 +1679,7 @@ void QTabBarPrivate::_q_moveTab(int offset)
if (!validIndex(index))
return;
tabList[index].dragOffset = offset;
+ layoutTab(index); // Make buttons follow tab
q->update();
}
}
@@ -1727,8 +1727,7 @@ void QTabBar::mouseMoveEvent(QMouseEvent *event)
if (!d->dragInProgress && d->pressedIndex != -1) {
if ((event->pos() - d->dragStartPosition).manhattanLength() > QApplication::startDragDistance()) {
d->dragInProgress = true;
- if (d->animations.isEmpty())
- d->grabCache(0, d->tabList.count(), false);
+ d->setupMovableTab();
}
}
@@ -1773,7 +1772,6 @@ void QTabBar::mouseMoveEvent(QMouseEvent *event)
if (dragDistance > needsToBeOver)
d->slide(i + offset, d->pressedIndex);
}
-
}
// Buttons needs to follow the dragged tab
d->layoutTab(d->pressedIndex);
@@ -1801,32 +1799,41 @@ void QTabBarPrivate::_q_moveTabFinished()
}
}
-void QTabBarPrivate::grabCache(int start, int end, bool unhide)
+void QTabBarPrivate::setupMovableTab()
{
Q_Q(QTabBar);
- paintWithOffsets = false;
- bool showButtonsAgain = rightB->isVisible();
- rightB->hide();
- leftB->hide();
-
- QWidget *topLevel = q->window();
- QPoint topLevelOffset(q->mapTo(topLevel, QPoint()));
- for (int i = start; i < end; ++i) {
- QRect tabRect = q->tabRect(i);
- tabRect.translate(topLevelOffset);
- if (unhide) {
- tabList[i].unHideWidgets();
- layoutWidgets(i);
- }
- tabList[i].animatingCache = QPixmap::grabWidget(topLevel, tabRect);
- if (i != pressedIndex)
- tabList[i].hideWidgets();
- }
- if (showButtonsAgain) {
- rightB->show();
- leftB->show();
- }
- paintWithOffsets = true;
+ if (!movingTab)
+ movingTab = new QWidget(q);
+
+ QRect grabRect = q->tabRect(pressedIndex);
+
+ QPixmap grabImage(grabRect.size());
+ grabImage.fill(Qt::transparent);
+ QStylePainter p(&grabImage, q);
+
+ QStyleOptionTabV3 tab;
+ q->initStyleOption(&tab, pressedIndex);
+ tab.rect.moveTopLeft(QPoint(0, 0));
+ p.drawControl(QStyle::CE_TabBarTab, tab);
+ p.end();
+
+ QPalette pal;
+ pal.setBrush(QPalette::All, QPalette::Window, grabImage);
+ movingTab->setPalette(pal);
+ movingTab->setGeometry(grabRect);
+ movingTab->setAutoFillBackground(true);
+ movingTab->raise();
+
+ // Re-arrange widget order to avoid overlaps
+ if (tabList[pressedIndex].leftWidget)
+ tabList[pressedIndex].leftWidget->raise();
+ if (tabList[pressedIndex].rightWidget)
+ tabList[pressedIndex].rightWidget->raise();
+ if (leftB)
+ leftB->raise();
+ if (rightB)
+ rightB->raise();
+ movingTab->setVisible(true);
}
void QTabBarPrivate::_q_moveTabFinished(int index)
@@ -1834,10 +1841,9 @@ void QTabBarPrivate::_q_moveTabFinished(int index)
Q_Q(QTabBar);
bool cleanup = (pressedIndex == index) || (pressedIndex == -1) || !validIndex(index);
if (animations.isEmpty() && cleanup) {
+ movingTab->setVisible(false); // We might not get a mouse release
for (int i = 0; i < tabList.count(); ++i) {
tabList[i].dragOffset = 0;
- tabList[i].unHideWidgets();
- tabList[i].animatingCache = QPixmap();
}
if (pressedIndex != -1 && movable) {
pressedIndex = -1;
@@ -1881,6 +1887,7 @@ void QTabBar::mouseReleaseEvent(QMouseEvent *event)
d->_q_moveTabFinished(d->pressedIndex);
}
d->dragInProgress = false;
+ d->movingTab->setVisible(false);
d->dragStartPosition = QPoint();
}
@@ -2203,19 +2210,16 @@ void QTabBar::setTabButton(int index, ButtonPosition position, QWidget *widget)
widget->setParent(this);
// make sure our left and right widgets stay on top
widget->lower();
+ widget->show();
}
if (position == LeftSide) {
if (d->tabList[index].leftWidget)
d->tabList[index].leftWidget->hide();
d->tabList[index].leftWidget = widget;
- if(!d->tabList[index].hidLeft && widget)
- widget->show();
} else {
if (d->tabList[index].rightWidget)
d->tabList[index].rightWidget->hide();
d->tabList[index].rightWidget = widget;
- if(!d->tabList[index].hidRight && widget)
- widget->show();
}
d->layoutTabs();
update();
diff --git a/src/gui/widgets/qtabbar_p.h b/src/gui/widgets/qtabbar_p.h
index a117aa3..cb1a15b 100644
--- a/src/gui/widgets/qtabbar_p.h
+++ b/src/gui/widgets/qtabbar_p.h
@@ -70,7 +70,6 @@
QT_BEGIN_NAMESPACE
-
class QTabBarPrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QTabBar)
@@ -78,7 +77,7 @@ public:
QTabBarPrivate()
:currentIndex(-1), pressedIndex(-1),
shape(QTabBar::RoundedNorth),
- layoutDirty(false), drawBase(true), scrollOffset(0), expanding(true), closeButtonOnTabs(false), selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false), dragInProgress(false), documentMode(false) {}
+ layoutDirty(false), drawBase(true), scrollOffset(0), expanding(true), closeButtonOnTabs(false), selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false), dragInProgress(false), documentMode(false), movingTab(0) {}
int currentIndex;
int pressedIndex;
@@ -98,8 +97,6 @@ public:
, lastTab(-1)
, timeLine(0)
, dragOffset(0)
- , hidLeft(false)
- , hidRight(false)
{}
bool enabled;
int shortcutId;
@@ -123,9 +120,6 @@ public:
QTimeLine *timeLine;
int dragOffset;
- QPixmap animatingCache;
- bool hidLeft;
- bool hidRight;
void makeTimeLine(QWidget *q) {
if (timeLine)
@@ -135,27 +129,6 @@ public:
q->connect(timeLine, SIGNAL(finished()), q, SLOT(_q_moveTabFinished()));
}
- void hideWidgets() {
- if (!hidRight && rightWidget) {
- hidRight = rightWidget->isVisible();
- rightWidget->hide();
- }
-
- if (!hidLeft && leftWidget) {
- hidLeft = leftWidget->isVisible();
- leftWidget->hide();
- }
- }
-
- void unHideWidgets() {
- if (leftWidget && hidLeft)
- leftWidget->show();
- hidLeft = false;
- if (rightWidget && hidRight)
- rightWidget->show();
- hidRight = false;
- }
-
};
QList<Tab> tabList;
QHash<QTimeLine*, int> animations;
@@ -184,12 +157,12 @@ public:
void _q_moveTabFinished(int offset);
QRect hoverRect;
- void grabCache(int start, int end, bool unhide);
void refresh();
void layoutTabs();
void layoutWidgets(int index = -1);
void layoutTab(int index);
void updateMacBorderMetrics();
+ void setupMovableTab();
void makeVisible(int index);
QSize iconSize;
@@ -206,6 +179,8 @@ public:
bool dragInProgress;
bool documentMode;
+ QWidget *movingTab;
+
// shared by tabwidget and qtabbar
static void initStyleBaseOption(QStyleOptionTabBarBaseV2 *optTabBase, QTabBar *tabbar, QSize size)
{
diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp
index b239e32..1c4df93 100644
--- a/src/gui/widgets/qtextedit.cpp
+++ b/src/gui/widgets/qtextedit.cpp
@@ -1478,7 +1478,13 @@ void QTextEditPrivate::paint(QPainter *p, QPaintEvent *e)
layout->setViewport(QRect());
}
-/*! \reimp
+/*! \fn void QTextEdit::paintEvent(QPaintEvent *event)
+
+This event handler can be reimplemented in a subclass to receive paint events passed in \a event.
+It is usually unnecessary to reimplement this function in a subclass of QTextEdit.
+
+\warning The underlying text document must not be modified from within a reimplementation
+of this function.
*/
void QTextEdit::paintEvent(QPaintEvent *e)
{
diff --git a/src/gui/widgets/qtoolbar.cpp b/src/gui/widgets/qtoolbar.cpp
index 85d6ea2..1babb6d 100644
--- a/src/gui/widgets/qtoolbar.cpp
+++ b/src/gui/widgets/qtoolbar.cpp
@@ -1153,6 +1153,17 @@ bool QToolBar::event(QEvent *event)
if (d->mouseMoveEvent(static_cast<QMouseEvent*>(event)))
return true;
break;
+#ifdef Q_OS_WINCE
+ case QEvent::ContextMenu:
+ {
+ QContextMenuEvent* contextMenuEvent = static_cast<QContextMenuEvent*>(event);
+ QWidget* child = childAt(contextMenuEvent->pos());
+ QAbstractButton* button = qobject_cast<QAbstractButton*>(child);
+ if (button)
+ button->setDown(false);
+ }
+ break;
+#endif
case QEvent::Leave:
if (d->state != 0 && d->state->dragging) {
#ifdef Q_OS_WIN