summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/corelib/global/qglobal.cpp23
-rw-r--r--src/corelib/global/qglobal.h4
-rw-r--r--src/corelib/global/qhooks.cpp11
-rw-r--r--src/corelib/global/qhooks_p.h1
-rw-r--r--src/corelib/global/qnamespace.h4
-rw-r--r--src/corelib/global/qnamespace.qdoc23
-rw-r--r--src/corelib/global/qsystemdetection.h65
-rw-r--r--src/corelib/io/io.pri10
-rw-r--r--src/corelib/io/qdatastream.cpp1
-rw-r--r--src/corelib/io/qdatastream.h5
-rw-r--r--src/corelib/io/qprocess.cpp2
-rw-r--r--src/corelib/io/qprocess_unix.cpp25
-rw-r--r--src/corelib/io/qsettings.cpp26
-rw-r--r--src/corelib/io/qsettings.h5
-rw-r--r--src/corelib/io/qsettings_win.cpp120
-rw-r--r--src/corelib/io/qstandardpaths.cpp16
-rw-r--r--src/corelib/io/qstandardpaths_ios.mm133
-rw-r--r--src/corelib/io/qstandardpaths_mac.mm204
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp6
-rw-r--r--src/corelib/kernel/qcoreevent.h2
-rw-r--r--src/corelib/kernel/qmetaobjectbuilder.cpp204
-rw-r--r--src/corelib/plugin/qfactoryloader.cpp106
-rw-r--r--src/corelib/plugin/qfactoryloader_p.h21
-rw-r--r--src/corelib/plugin/qlibrary.cpp4
-rw-r--r--src/corelib/plugin/qlibrary_p.h25
-rw-r--r--src/corelib/plugin/qpluginloader.cpp15
-rw-r--r--src/corelib/plugin/qpluginloader.h15
-rw-r--r--src/corelib/tools/qbytearray.cpp46
-rw-r--r--src/corelib/tools/qbytearray.h23
-rw-r--r--src/corelib/tools/qregexp.h5
-rw-r--r--src/corelib/tools/qringbuffer.cpp89
-rw-r--r--src/corelib/tools/qringbuffer_p.h6
-rw-r--r--src/corelib/tools/qsharedpointer.cpp11
-rw-r--r--src/corelib/tools/qsharedpointer.h2
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h42
-rw-r--r--src/corelib/tools/qsimd_p.h1
-rw-r--r--src/corelib/tools/qstring.h20
-rw-r--r--src/corelib/tools/qversionnumber.h2
-rw-r--r--src/dbus/qdbusconnection.cpp4
-rw-r--r--src/dbus/qdbusconnectioninterface.cpp8
-rw-r--r--src/dbus/qdbusintegrator.cpp12
-rw-r--r--src/gui/accessible/accessible.pri6
-rw-r--r--src/gui/gui.pro2
-rw-r--r--src/gui/image/qicon.cpp50
-rw-r--r--src/gui/image/qicon.h3
-rw-r--r--src/gui/image/qiconengine.cpp17
-rw-r--r--src/gui/image/qiconengine.h3
-rw-r--r--src/gui/image/qiconloader.cpp168
-rw-r--r--src/gui/image/qiconloader_p.h5
-rw-r--r--src/gui/image/qimage.h4
-rw-r--r--src/gui/image/qpixmapcache.cpp10
-rw-r--r--src/gui/image/qpixmapcache.h1
-rw-r--r--src/gui/kernel/qevent.cpp3
-rw-r--r--src/gui/kernel/qevent.h9
-rw-r--r--src/gui/kernel/qgenericplugin.cpp4
-rw-r--r--src/gui/kernel/qgenericplugin.h5
-rw-r--r--src/gui/kernel/qguiapplication.cpp32
-rw-r--r--src/gui/kernel/qguiapplication.h4
-rw-r--r--src/gui/kernel/qguiapplication_p.h1
-rw-r--r--src/gui/kernel/qinputdevicemanager_p.h3
-rw-r--r--src/gui/kernel/qplatformintegrationfactory.cpp14
-rw-r--r--src/gui/opengl/qtriangulator_p.h11
-rw-r--r--src/gui/text/qrawfont.cpp1
-rw-r--r--src/gui/text/qtexthtmlparser.cpp3
-rw-r--r--src/gui/text/qtextimagehandler.cpp1
-rw-r--r--src/network/access/access.pri2
-rw-r--r--src/network/socket/qabstractsocket.cpp68
-rw-r--r--src/network/socket/qabstractsocket.h2
-rw-r--r--src/network/socket/qabstractsocket_p.h2
-rw-r--r--src/platformsupport/cglconvenience/cglconvenience.mm2
-rw-r--r--src/platformsupport/cglconvenience/cglconvenience.pri4
-rw-r--r--src/platformsupport/clipboard/qmacmime.mm7
-rw-r--r--src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp6
-rw-r--r--src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp1
-rw-r--r--src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm4
-rw-r--r--src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp1
-rw-r--r--src/platformsupport/input/evdevtablet/evdevtablet.pri6
-rw-r--r--src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp (renamed from src/platformsupport/input/evdevtablet/qevdevtablet.cpp)203
-rw-r--r--src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h (renamed from src/platformsupport/input/evdevtablet/qevdevtablet_p.h)19
-rw-r--r--src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp122
-rw-r--r--src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h (renamed from src/widgets/styles/qgtkglobal_p.h)54
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp1
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes.cpp2
-rw-r--r--src/plugins/generic/evdevtablet/main.cpp12
-rw-r--r--src/plugins/generic/tuiotouch/qtuiohandler.cpp1
-rw-r--r--src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp2
-rw-r--r--src/plugins/platforms/cocoa/cocoa.pro2
-rw-r--r--src/plugins/platforms/cocoa/main.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibility.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibility.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplication.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoacursor.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoadrag.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm4
-rw-r--r--src/plugins/platforms/cocoa/qcocoakeymapper.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenubar.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuloader.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoanativeinterface.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm16
-rw-r--r--src/plugins/platforms/cocoa/qmacclipboard.h2
-rw-r--r--src/plugins/platforms/cocoa/qmacdefines_mac.h2
-rw-r--r--src/plugins/platforms/cocoa/qmultitouch_mac_p.h2
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h2
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.h2
-rw-r--r--src/plugins/platforms/cocoa/qt_mac_p.h2
-rw-r--r--src/plugins/platforms/eglfs/qeglfscursor.cpp1
-rw-r--r--src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp1
-rw-r--r--src/plugins/platforms/mirclient/qmirclientglcontext.cpp10
-rw-r--r--src/plugins/platforms/windows/qwindowsdrag.cpp6
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase.cpp1
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp4
-rw-r--r--src/plugins/platforms/windows/qwindowsfontengine.cpp1
-rw-r--r--src/plugins/platforms/windows/qwindowsintegration.cpp9
-rw-r--r--src/plugins/platforms/windows/qwindowsmousehandler.cpp1
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp2
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp2
-rw-r--r--src/plugins/printsupport/cocoa/cocoa.pro2
-rw-r--r--src/printsupport/dialogs/dialogs.pri4
-rw-r--r--src/printsupport/dialogs/qpagesetupdialog_mac.mm2
-rw-r--r--src/printsupport/dialogs/qprintdialog_mac.mm2
-rw-r--r--src/tools/moc/preprocessor.cpp5
-rw-r--r--src/tools/qdoc/node.cpp41
-rw-r--r--src/tools/qdoc/qdocdatabase.cpp4
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp15
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.h1
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp6
-rw-r--r--src/widgets/doc/images/gtk-calendarwidget.pngbin16761 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-checkbox.pngbin2323 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-combobox.pngbin2730 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-dateedit.pngbin2163 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-datetimeedit.pngbin2923 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-dial.pngbin7221 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-doublespinbox.pngbin2325 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-fontcombobox.pngbin3022 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-frame.pngbin2340 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-groupbox.pngbin6650 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-horizontalscrollbar.pngbin1701 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-label.pngbin1582 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-lcdnumber.pngbin1193 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-lineedit.pngbin2528 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-listview.pngbin8493 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-progressbar.pngbin2228 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-pushbutton.pngbin2153 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-radiobutton.pngbin3142 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-slider.pngbin1359 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-spinbox.pngbin2078 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-tableview.pngbin8364 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-tabwidget.pngbin8179 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-textedit.pngbin12641 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-timeedit.pngbin2621 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-toolbox.pngbin4240 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-toolbutton.pngbin2260 -> 0 bytes
-rw-r--r--src/widgets/doc/images/gtk-treeview.pngbin9722 -> 0 bytes
-rw-r--r--src/widgets/doc/snippets/code/doc_src_stylesheet.cpp4
-rw-r--r--src/widgets/doc/snippets/macmainwindow.mm2
-rw-r--r--src/widgets/doc/snippets/qmacnativewidget/main.mm2
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/gallery-gtk.qdoc142
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/gallery.qdoc4
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/styles.qdoc2
-rw-r--r--src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc22
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp1
-rw-r--r--src/widgets/itemviews/qfileiconprovider.cpp13
-rw-r--r--src/widgets/itemviews/qitemeditorfactory.cpp3
-rw-r--r--src/widgets/kernel/mac.pri4
-rw-r--r--src/widgets/kernel/qapplication.cpp1
-rw-r--r--src/widgets/kernel/qwidget.cpp35
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp8
-rw-r--r--src/widgets/styles/qgtk2painter.cpp699
-rw-r--r--src/widgets/styles/qgtk2painter_p.h100
-rw-r--r--src/widgets/styles/qgtkpainter.cpp76
-rw-r--r--src/widgets/styles/qgtkpainter_p.h119
-rw-r--r--src/widgets/styles/qgtkstyle.cpp4257
-rw-r--r--src/widgets/styles/qgtkstyle_p.cpp891
-rw-r--r--src/widgets/styles/qgtkstyle_p.h123
-rw-r--r--src/widgets/styles/qgtkstyle_p_p.h449
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm69
-rw-r--r--src/widgets/styles/qmacstyle_mac_p_p.h3
-rw-r--r--src/widgets/styles/qstyle.h18
-rw-r--r--src/widgets/styles/qstylefactory.cpp14
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp121
-rw-r--r--src/widgets/styles/qstylesheetstyle_default.cpp3
-rw-r--r--src/widgets/styles/qstylesheetstyle_p.h7
-rw-r--r--src/widgets/styles/styles.pri20
-rw-r--r--src/widgets/util/qflickgesture.cpp1
-rw-r--r--src/widgets/util/qscroller_mac.mm2
-rw-r--r--src/widgets/util/qsystemtrayicon_x11.cpp4
-rw-r--r--src/widgets/widgets/qcombobox.cpp2
-rw-r--r--src/widgets/widgets/qcombobox.h2
-rw-r--r--src/widgets/widgets/qgroupbox.cpp4
-rw-r--r--src/widgets/widgets/qlabel.cpp6
-rw-r--r--src/widgets/widgets/qlabel.h2
-rw-r--r--src/widgets/widgets/qmaccocoaviewcontainer_mac.mm2
-rw-r--r--src/widgets/widgets/qmacnativewidget_mac.mm2
-rw-r--r--src/widgets/widgets/qmdiarea.cpp4
-rw-r--r--src/widgets/widgets/qmdisubwindow.cpp6
-rw-r--r--src/widgets/widgets/qmenu_mac.mm2
-rw-r--r--src/widgets/widgets/qtextedit.cpp2
206 files changed, 1740 insertions, 7937 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 02220d0db2..62308aec9d 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -1185,30 +1185,35 @@ bool qSharedBuild() Q_DECL_NOTHROW
\macro Q_OS_DARWIN
\relates <QtGlobal>
- Defined on Darwin-based operating systems such as OS X and iOS,
- including any open source version(s) of Darwin.
+ Defined on Darwin-based operating systems such as OS X, iOS, watchOS, and tvOS.
*/
/*!
- \macro Q_OS_MAC
+ \macro Q_OS_OSX
\relates <QtGlobal>
- Defined on Darwin-based operating systems distributed by Apple, which
- currently includes OS X and iOS, but not the open source versions of Darwin.
+ Defined on OS X.
*/
/*!
- \macro Q_OS_OSX
+ \macro Q_OS_IOS
\relates <QtGlobal>
- Defined on OS X.
+ Defined on iOS.
*/
/*!
- \macro Q_OS_IOS
+ \macro Q_OS_WATCHOS
\relates <QtGlobal>
- Defined on iOS.
+ Defined on watchOS.
+ */
+
+/*!
+ \macro Q_OS_TVOS
+ \relates <QtGlobal>
+
+ Defined on tvOS.
*/
/*!
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 4813c2b100..d4bbbe833c 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -41,11 +41,11 @@
#include <stddef.h>
-#define QT_VERSION_STR "5.6.0"
+#define QT_VERSION_STR "5.7.0"
/*
QT_VERSION is (major << 16) + (minor << 8) + patch.
*/
-#define QT_VERSION 0x050600
+#define QT_VERSION 0x050700
/*
can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
*/
diff --git a/src/corelib/global/qhooks.cpp b/src/corelib/global/qhooks.cpp
index 382f45f592..40a7c88f13 100644
--- a/src/corelib/global/qhooks.cpp
+++ b/src/corelib/global/qhooks.cpp
@@ -37,7 +37,7 @@ QT_BEGIN_NAMESPACE
// Only add to the end, and bump version if you do.
quintptr Q_CORE_EXPORT qtHookData[] = {
- 2, // hook data version
+ 3, // hook data version
QHooks::LastHookIndex, // size of qtHookData
QT_VERSION,
@@ -52,6 +52,15 @@ quintptr Q_CORE_EXPORT qtHookData[] = {
0,
// Startup, void(*)(), called once QCoreApplication is operational
+ 0,
+
+ // TypeInformationVersion, an integral value, bumped whenever private
+ // object sizes or member offsets that are used in Qt Creator's
+ // data structure "pretty printing" change.
+ //
+ // The required sizes and offsets are tested in tests/auto/other/toolsupport.
+ // When this fails and the change was intentional, adjust the test and
+ // adjust this value here.
0
};
diff --git a/src/corelib/global/qhooks_p.h b/src/corelib/global/qhooks_p.h
index 3ff4980abe..2beb58f8a7 100644
--- a/src/corelib/global/qhooks_p.h
+++ b/src/corelib/global/qhooks_p.h
@@ -61,6 +61,7 @@ enum HookIndex {
AddQObject = 3,
RemoveQObject = 4,
Startup = 5,
+ TypeInformationVersion = 6,
LastHookIndex
};
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index de8a17fa51..056e519e56 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -482,7 +482,8 @@ public:
AA_DontShowIconsInMenus = 2,
AA_NativeWindows = 3,
AA_DontCreateNativeWidgetSiblings = 4,
- AA_MacPluginApplication = 5,
+ AA_PluginApplication = 5,
+ AA_MacPluginApplication = AA_PluginApplication, // ### Qt 6: remove me
AA_DontUseNativeMenuBar = 6,
AA_MacDontSwapCtrlAndMeta = 7,
AA_Use96Dpi = 8,
@@ -497,6 +498,7 @@ public:
AA_ShareOpenGLContexts = 18,
AA_SetPalette = 19,
AA_NoHighDpiScaling = 20,
+ AA_UseStyleSheetPropagationInWidgetStyles = 21, // ### Qt 6: remove me
// Add new attributes before this line
AA_AttributeCount
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 443eae5a11..8568dfd97c 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -120,13 +120,21 @@
widgets stay non-native unless specifically set by the
Qt::WA_NativeWindow attribute.
- \value AA_MacPluginApplication Stops the Qt mac application from doing
- specific initializations that do not necessarily make sense when using Qt
- to author a plugin. This includes avoiding loading our nib for the main
- menu and not taking possession of the native menu bar. When setting this
+ \value AA_PluginApplication Indicates that Qt is used to author a plugin. Depending
+ on the operating system, it suppresses specific initializations that do not
+ necessarily make sense in the plugin case.
+
+ For example on OS X, this includes avoiding loading our nib for the main
+ menu and not taking possession of the native menu bar. Setting this
attribute to true will also set the AA_DontUseNativeMenuBar attribute
to true. It also disables native event filters.
+ This attribute has been added in Qt 5.7. It must be set before
+ \l {QGuiApplication}{Q(Gui)Application} is constructed.
+
+ \value AA_MacPluginApplication This attribute has been deprecated.
+ Use AA_PluginApplication instead.
+
\value AA_DontUseNativeMenuBar All menubars created while this attribute is
set to true won't be used as a native menubar (e.g, the menubar at
the top of the main screen on OS X or at the bottom in Windows CE).
@@ -205,6 +213,13 @@
so this does not guarantee that QPaintDevice::devicePixelRatio() will
be equal to 1. This value has been added in Qt 5.6.
+ \value AA_UseStyleSheetPropagationInWidgetStyles By default, Qt Style Sheets
+ disable regular QWidget palette and font propagation. When this flag
+ is enabled, font and palette changes propagate as though the user had
+ manually called the corresponding QWidget methods. See
+ \l{The Style Sheet Syntax#Inheritance}{The Style Sheet Syntax - Inheritance}
+ for more details. This value has been added in Qt 5.7.
+
The following values are obsolete:
\value AA_ImmediateWidgetCreation This attribute is no longer fully
diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h
index d19784163a..f043f6c5c9 100644
--- a/src/corelib/global/qsystemdetection.h
+++ b/src/corelib/global/qsystemdetection.h
@@ -41,10 +41,11 @@
/*
The operating system, must be one of: (Q_OS_x)
- DARWIN - Any Darwin system
- MAC - OS X and iOS
+ DARWIN - Any Darwin system (OS X, iOS, watchOS, tvOS)
OSX - OS X
IOS - iOS
+ WATCHOS - watchOS
+ TVOS - tvOS
MSDOS - MS-DOS and Windows
OS2 - OS/2
OS2EMX - XFree86 on OS/2 (not PM)
@@ -87,12 +88,32 @@
*/
#if defined(__APPLE__) && (defined(__GNUC__) || defined(__xlC__) || defined(__xlc__))
-# define Q_OS_DARWIN
-# define Q_OS_BSD4
-# ifdef __LP64__
-# define Q_OS_DARWIN64
+# include <TargetConditionals.h>
+# if defined(TARGET_OS_MAC) && TARGET_OS_MAC
+# define Q_OS_DARWIN
+# define Q_OS_BSD4
+# ifdef __LP64__
+# define Q_OS_DARWIN64
+# else
+# define Q_OS_DARWIN32
+# endif
+# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
+# if defined(TARGET_OS_TV) && TARGET_OS_TV
+# define Q_OS_TVOS
+# elif defined(TARGET_OS_WATCH) && TARGET_OS_WATCH
+# define Q_OS_WATCHOS
+# else
+# // TARGET_OS_IOS is only available in newer SDKs,
+# // so assume any other iOS-based platform is iOS for now
+# define Q_OS_IOS
+# endif
+# else
+# // there is no "real" OS X define (rdar://22640089),
+# // assume any non iOS-based platform is OS X for now
+# define Q_OS_OSX
+# endif
# else
-# define Q_OS_DARWIN32
+# error "Qt has not been ported to this Apple platform - see http://www.qt.io/developers"
# endif
#elif defined(__ANDROID__) || defined(ANDROID)
# define Q_OS_ANDROID
@@ -181,28 +202,26 @@
# define Q_OS_WIN
#endif
-#if defined(Q_OS_DARWIN)
-# define Q_OS_MAC
-# if defined(Q_OS_DARWIN64)
-# define Q_OS_MAC64
-# elif defined(Q_OS_DARWIN32)
-# define Q_OS_MAC32
-# endif
-# include <TargetConditionals.h>
-# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
-# define Q_OS_IOS
-# elif defined(TARGET_OS_MAC) && TARGET_OS_MAC
-# define Q_OS_OSX
-# define Q_OS_MACX // compatibility synonym
-# endif
-#endif
-
#if defined(Q_OS_WIN)
# undef Q_OS_UNIX
#elif !defined(Q_OS_UNIX)
# define Q_OS_UNIX
#endif
+// Compatibility synonyms
+#ifdef Q_OS_DARWIN
+#define Q_OS_MAC
+#endif
+#ifdef Q_OS_DARWIN32
+#define Q_OS_MAC32
+#endif
+#ifdef Q_OS_DARWIN64
+#define Q_OS_MAC64
+#endif
+#ifdef Q_OS_OSX
+#define Q_OS_MACX
+#endif
+
#ifdef Q_OS_DARWIN
# include <Availability.h>
# include <AvailabilityMacros.h>
diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri
index b2bcbdf727..7be1e5883e 100644
--- a/src/corelib/io/io.pri
+++ b/src/corelib/io/io.pri
@@ -149,20 +149,14 @@ win32 {
}
freebsd: LIBS_PRIVATE += -lutil # qlockfile_unix.cpp requires this
mac {
+ SOURCES += io/qstorageinfo_mac.cpp
+ OBJECTIVE_SOURCES += io/qstandardpaths_mac.mm
osx {
OBJECTIVE_SOURCES += io/qfilesystemwatcher_fsevents.mm
HEADERS += io/qfilesystemwatcher_fsevents_p.h
- }
- macx {
- SOURCES += io/qstorageinfo_mac.cpp
- OBJECTIVE_SOURCES += io/qstandardpaths_mac.mm
LIBS += -framework DiskArbitration -framework IOKit
} else:ios {
- OBJECTIVE_SOURCES += io/qstandardpaths_ios.mm
- SOURCES += io/qstorageinfo_mac.cpp
LIBS += -framework MobileCoreServices
- } else {
- SOURCES += io/qstandardpaths_unix.cpp
}
} else:blackberry {
SOURCES += \
diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp
index 675178ea80..c32df4c8a6 100644
--- a/src/corelib/io/qdatastream.cpp
+++ b/src/corelib/io/qdatastream.cpp
@@ -527,6 +527,7 @@ void QDataStream::setByteOrder(ByteOrder bo)
\value Qt_5_4 Version 16 (Qt 5.4)
\value Qt_5_5 Same as Qt_5_4
\value Qt_5_6 Version 17 (Qt 5.6)
+ \value Qt_5_7 Same as Qt_5_6
\omitvalue Qt_DefaultCompiledVersion
\sa setVersion(), version()
diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h
index 5730c12907..744829c659 100644
--- a/src/corelib/io/qdatastream.h
+++ b/src/corelib/io/qdatastream.h
@@ -84,10 +84,11 @@ public:
Qt_5_4 = 16,
Qt_5_5 = Qt_5_4,
Qt_5_6 = 17,
-#if QT_VERSION >= 0x050700
+ Qt_5_7 = Qt_5_6,
+#if QT_VERSION >= 0x050800
#error Add the datastream version for this Qt version and update Qt_DefaultCompiledVersion
#endif
- Qt_DefaultCompiledVersion = Qt_5_6
+ Qt_DefaultCompiledVersion = Qt_5_7
};
enum ByteOrder {
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 8fbe96adb9..3539c75548 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -1186,7 +1186,7 @@ bool QProcessPrivate::_q_startupNotification()
}
q->setProcessState(QProcess::NotRunning);
- setErrorAndEmit(QProcess::FailedToStart);
+ setErrorAndEmit(QProcess::FailedToStart, errorString); // the error string was already set
#ifdef Q_OS_UNIX
// make sure the process manager removes this entry
waitForDeadChild();
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 63480dfc6b..a958aa4322 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -672,6 +672,7 @@ void QProcessPrivate::execChild(const char *workingDir, char **path, char **argv
qt_safe_close(childStartedPipe[0]);
// enter the working directory
+ const char *callthatfailed = "chdir: ";
if (workingDir && QT_CHDIR(workingDir) == -1) {
// failed, stop the process
goto report_errno;
@@ -683,6 +684,7 @@ void QProcessPrivate::execChild(const char *workingDir, char **path, char **argv
// execute the process
if (!envp) {
qt_safe_execvp(argv[0], argv);
+ callthatfailed = "execvp: ";
} else {
if (path) {
char **arg = path;
@@ -700,15 +702,19 @@ void QProcessPrivate::execChild(const char *workingDir, char **path, char **argv
#endif
qt_safe_execve(argv[0], argv, envp);
}
+ callthatfailed = "execve: ";
}
// notify failure
+ // we're running in the child process, so we don't need to be thread-safe;
+ // we can use strerror
report_errno:
- QString error = qt_error_string(errno);
+ const char *msg = strerror(errno);
#if defined (QPROCESS_DEBUG)
- fprintf(stderr, "QProcessPrivate::execChild() failed (%s), notifying parent process\n", qPrintable(error));
+ fprintf(stderr, "QProcessPrivate::execChild() failed (%s), notifying parent process\n", msg);
#endif
- qt_safe_write(childStartedPipe[1], error.data(), error.length() * sizeof(QChar));
+ qt_safe_write(childStartedPipe[1], callthatfailed, strlen(callthatfailed));
+ qt_safe_write(childStartedPipe[1], msg, strlen(msg));
qt_safe_close(childStartedPipe[1]);
childStartedPipe[1] = -1;
}
@@ -716,8 +722,15 @@ report_errno:
bool QProcessPrivate::processStarted()
{
- ushort buf[errorBufferMax];
- int i = qt_safe_read(childStartedPipe[0], &buf, sizeof buf);
+ char buf[errorBufferMax];
+ int i = 0;
+ int ret;
+ do {
+ ret = qt_safe_read(childStartedPipe[0], buf + i, sizeof buf - i);
+ if (ret > 0)
+ i += ret;
+ } while (ret > 0 && i < int(sizeof buf));
+
if (startupSocketNotifier) {
startupSocketNotifier->setEnabled(false);
startupSocketNotifier->deleteLater();
@@ -732,7 +745,7 @@ bool QProcessPrivate::processStarted()
// did we read an error message?
if (i > 0)
- q_func()->setErrorString(QString((const QChar *)buf, i / sizeof(QChar)));
+ q_func()->setErrorString(QString::fromLocal8Bit(buf, i));
return i <= 0;
}
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 0c44582af8..3460753fbe 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -2413,14 +2413,24 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
This enum type specifies the storage format used by QSettings.
- \value NativeFormat Store the settings using the most
- appropriate storage format for the platform.
- On Windows, this means the system registry;
- on OS X and iOS, this means the CFPreferences
- API; on Unix, this means textual
- configuration files in INI format.
- \value IniFormat Store the settings in INI files.
- \value InvalidFormat Special value returned by registerFormat().
+ \value NativeFormat Store the settings using the most
+ appropriate storage format for the platform.
+ On Windows, this means the system registry;
+ on OS X and iOS, this means the CFPreferences
+ API; on Unix, this means textual
+ configuration files in INI format.
+ \value Registry32Format Windows only: Explicitly access the 32-bit system registry
+ from a 64-bit application running on 64-bit Windows.
+ On 32-bit Windows or from a 32-bit application on 64-bit Windows,
+ this works the same as specifying NativeFormat.
+ This enum value was added in Qt 5.7.
+ \value Registry64Format Windows only: Explicitly access the 64-bit system registry
+ from a 32-bit application running on 64-bit Windows.
+ On 32-bit Windows or from a 64-bit application on 64-bit Windows,
+ this works the same as specifying NativeFormat.
+ This enum value was added in Qt 5.7.
+ \value IniFormat Store the settings in INI files.
+ \value InvalidFormat Special value returned by registerFormat().
\omitvalue CustomFormat1
\omitvalue CustomFormat2
\omitvalue CustomFormat3
diff --git a/src/corelib/io/qsettings.h b/src/corelib/io/qsettings.h
index 8f41273ffa..dd0c4a9bfb 100644
--- a/src/corelib/io/qsettings.h
+++ b/src/corelib/io/qsettings.h
@@ -79,6 +79,11 @@ public:
NativeFormat,
IniFormat,
+#ifdef Q_OS_WIN
+ Registry32Format,
+ Registry64Format,
+#endif
+
InvalidFormat = 16,
CustomFormat1,
CustomFormat2,
diff --git a/src/corelib/io/qsettings_win.cpp b/src/corelib/io/qsettings_win.cpp
index 1546219c3b..88f58422a8 100644
--- a/src/corelib/io/qsettings_win.cpp
+++ b/src/corelib/io/qsettings_win.cpp
@@ -41,6 +41,18 @@
#include "qdebug.h"
#include <qt_windows.h>
+// See "Accessing an Alternate Registry View" at:
+// http://msdn.microsoft.com/en-us/library/aa384129%28VS.85%29.aspx
+#ifndef KEY_WOW64_64KEY
+ // Access a 32-bit key from either a 32-bit or 64-bit application.
+# define KEY_WOW64_64KEY 0x0100
+#endif
+
+#ifndef KEY_WOW64_32KEY
+ // Access a 64-bit key from either a 32-bit or 64-bit application.
+# define KEY_WOW64_32KEY 0x0200
+#endif
+
QT_BEGIN_NAMESPACE
/* Keys are stored in QStrings. If the variable name starts with 'u', this is a "user"
@@ -135,12 +147,13 @@ static QString errorCodeToString(DWORD errorCode)
return result;
}
-// Open a key with the specified perms
-static HKEY openKey(HKEY parentHandle, REGSAM perms, const QString &rSubKey)
+// Open a key with the specified "perms".
+// "access" is to explicitly use the 32- or 64-bit branch.
+static HKEY openKey(HKEY parentHandle, REGSAM perms, const QString &rSubKey, REGSAM access = 0)
{
HKEY resultHandle = 0;
LONG res = RegOpenKeyEx(parentHandle, reinterpret_cast<const wchar_t *>(rSubKey.utf16()),
- 0, perms, &resultHandle);
+ 0, perms | access, &resultHandle);
if (res == ERROR_SUCCESS)
return resultHandle;
@@ -148,17 +161,18 @@ static HKEY openKey(HKEY parentHandle, REGSAM perms, const QString &rSubKey)
return 0;
}
-// Open a key with the specified perms, create it if it does not exist
-static HKEY createOrOpenKey(HKEY parentHandle, REGSAM perms, const QString &rSubKey)
+// Open a key with the specified "perms", create it if it does not exist.
+// "access" is to explicitly use the 32- or 64-bit branch.
+static HKEY createOrOpenKey(HKEY parentHandle, REGSAM perms, const QString &rSubKey, REGSAM access = 0)
{
// try to open it
- HKEY resultHandle = openKey(parentHandle, perms, rSubKey);
+ HKEY resultHandle = openKey(parentHandle, perms, rSubKey, access);
if (resultHandle != 0)
return resultHandle;
// try to create it
LONG res = RegCreateKeyEx(parentHandle, reinterpret_cast<const wchar_t *>(rSubKey.utf16()), 0, 0,
- REG_OPTION_NON_VOLATILE, perms, 0, &resultHandle, 0);
+ REG_OPTION_NON_VOLATILE, perms | access, 0, &resultHandle, 0);
if (res == ERROR_SUCCESS)
return resultHandle;
@@ -169,11 +183,12 @@ static HKEY createOrOpenKey(HKEY parentHandle, REGSAM perms, const QString &rSub
return 0;
}
-// Open or create a key in read-write mode if possible, otherwise read-only
-static HKEY createOrOpenKey(HKEY parentHandle, const QString &rSubKey, bool *readOnly)
+// Open or create a key in read-write mode if possible, otherwise read-only.
+// "access" is to explicitly use the 32- or 64-bit branch.
+static HKEY createOrOpenKey(HKEY parentHandle, const QString &rSubKey, bool *readOnly, REGSAM access = 0)
{
// try to open or create it read/write
- HKEY resultHandle = createOrOpenKey(parentHandle, registryPermissions, rSubKey);
+ HKEY resultHandle = createOrOpenKey(parentHandle, registryPermissions, rSubKey, access);
if (resultHandle != 0) {
if (readOnly != 0)
*readOnly = false;
@@ -181,7 +196,7 @@ static HKEY createOrOpenKey(HKEY parentHandle, const QString &rSubKey, bool *rea
}
// try to open or create it read/only
- resultHandle = createOrOpenKey(parentHandle, KEY_READ, rSubKey);
+ resultHandle = createOrOpenKey(parentHandle, KEY_READ, rSubKey, access);
if (resultHandle != 0) {
if (readOnly != 0)
*readOnly = true;
@@ -247,9 +262,9 @@ static QStringList childKeysOrGroups(HKEY parentHandle, QSettingsPrivate::ChildS
return result;
}
-static void allKeys(HKEY parentHandle, const QString &rSubKey, NameSet *result)
+static void allKeys(HKEY parentHandle, const QString &rSubKey, NameSet *result, REGSAM access = 0)
{
- HKEY handle = openKey(parentHandle, KEY_READ, rSubKey);
+ HKEY handle = openKey(parentHandle, KEY_READ, rSubKey, access);
if (handle == 0)
return;
@@ -270,11 +285,11 @@ static void allKeys(HKEY parentHandle, const QString &rSubKey, NameSet *result)
if (!s.isEmpty())
s += QLatin1Char('\\');
s += childGroups.at(i);
- allKeys(parentHandle, s, result);
+ allKeys(parentHandle, s, result, access);
}
}
-static void deleteChildGroups(HKEY parentHandle)
+static void deleteChildGroups(HKEY parentHandle, REGSAM access = 0)
{
QStringList childGroups = childKeysOrGroups(parentHandle, QSettingsPrivate::ChildGroups);
@@ -282,10 +297,10 @@ static void deleteChildGroups(HKEY parentHandle)
QString group = childGroups.at(i);
// delete subgroups in group
- HKEY childGroupHandle = openKey(parentHandle, registryPermissions, group);
+ HKEY childGroupHandle = openKey(parentHandle, registryPermissions, group, access);
if (childGroupHandle == 0)
continue;
- deleteChildGroups(childGroupHandle);
+ deleteChildGroups(childGroupHandle, access);
RegCloseKey(childGroupHandle);
// delete group itself
@@ -305,7 +320,7 @@ static void deleteChildGroups(HKEY parentHandle)
class RegistryKey
{
public:
- RegistryKey(HKEY parent_handle = 0, const QString &key = QString(), bool read_only = true);
+ RegistryKey(HKEY parent_handle = 0, const QString &key = QString(), bool read_only = true, REGSAM access = 0);
QString key() const;
HKEY handle() const;
HKEY parentHandle() const;
@@ -316,13 +331,15 @@ private:
mutable HKEY m_handle;
QString m_key;
mutable bool m_read_only;
+ REGSAM m_access;
};
-RegistryKey::RegistryKey(HKEY parent_handle, const QString &key, bool read_only)
+RegistryKey::RegistryKey(HKEY parent_handle, const QString &key, bool read_only, REGSAM access)
: m_parent_handle(parent_handle),
m_handle(0),
m_key(key),
- m_read_only(read_only)
+ m_read_only(read_only),
+ m_access(access)
{
}
@@ -337,9 +354,9 @@ HKEY RegistryKey::handle() const
return m_handle;
if (m_read_only)
- m_handle = openKey(m_parent_handle, KEY_READ, m_key);
+ m_handle = openKey(m_parent_handle, KEY_READ, m_key, m_access);
else
- m_handle = createOrOpenKey(m_parent_handle, m_key, &m_read_only);
+ m_handle = createOrOpenKey(m_parent_handle, m_key, &m_read_only, m_access);
return m_handle;
}
@@ -371,8 +388,8 @@ class QWinSettingsPrivate : public QSettingsPrivate
{
public:
QWinSettingsPrivate(QSettings::Scope scope, const QString &organization,
- const QString &application);
- QWinSettingsPrivate(QString rKey);
+ const QString &application, REGSAM access = 0);
+ QWinSettingsPrivate(QString rKey, REGSAM access = 0);
~QWinSettingsPrivate();
void remove(const QString &uKey);
@@ -390,11 +407,13 @@ public:
private:
RegistryKeyList regList; // list of registry locations to search for keys
bool deleteWriteHandleOnExit;
+ REGSAM access;
};
QWinSettingsPrivate::QWinSettingsPrivate(QSettings::Scope scope, const QString &organization,
- const QString &application)
- : QSettingsPrivate(QSettings::NativeFormat, scope, organization, application)
+ const QString &application, REGSAM access)
+ : QSettingsPrivate(QSettings::NativeFormat, scope, organization, application),
+ access(access)
{
deleteWriteHandleOnExit = false;
@@ -405,23 +424,24 @@ QWinSettingsPrivate::QWinSettingsPrivate(QSettings::Scope scope, const QString &
if (scope == QSettings::UserScope) {
if (!application.isEmpty())
- regList.append(RegistryKey(HKEY_CURRENT_USER, appPrefix, !regList.isEmpty()));
+ regList.append(RegistryKey(HKEY_CURRENT_USER, appPrefix, !regList.isEmpty(), access));
- regList.append(RegistryKey(HKEY_CURRENT_USER, orgPrefix, !regList.isEmpty()));
+ regList.append(RegistryKey(HKEY_CURRENT_USER, orgPrefix, !regList.isEmpty(), access));
}
if (!application.isEmpty())
- regList.append(RegistryKey(HKEY_LOCAL_MACHINE, appPrefix, !regList.isEmpty()));
+ regList.append(RegistryKey(HKEY_LOCAL_MACHINE, appPrefix, !regList.isEmpty(), access));
- regList.append(RegistryKey(HKEY_LOCAL_MACHINE, orgPrefix, !regList.isEmpty()));
+ regList.append(RegistryKey(HKEY_LOCAL_MACHINE, orgPrefix, !regList.isEmpty(), access));
}
if (regList.isEmpty())
setStatus(QSettings::AccessError);
}
-QWinSettingsPrivate::QWinSettingsPrivate(QString rPath)
- : QSettingsPrivate(QSettings::NativeFormat)
+QWinSettingsPrivate::QWinSettingsPrivate(QString rPath, REGSAM access)
+ : QSettingsPrivate(QSettings::NativeFormat),
+ access(access)
{
deleteWriteHandleOnExit = false;
@@ -460,9 +480,9 @@ QWinSettingsPrivate::QWinSettingsPrivate(QString rPath)
}
if (rPath.length() == keyLength)
- regList.append(RegistryKey(keyName, QString(), false));
+ regList.append(RegistryKey(keyName, QString(), false, access));
else if (rPath[keyLength] == QLatin1Char('\\'))
- regList.append(RegistryKey(keyName, rPath.mid(keyLength+1), false));
+ regList.append(RegistryKey(keyName, rPath.mid(keyLength+1), false, access));
}
bool QWinSettingsPrivate::readKey(HKEY parentHandle, const QString &rSubKey, QVariant *value) const
@@ -471,7 +491,7 @@ bool QWinSettingsPrivate::readKey(HKEY parentHandle, const QString &rSubKey, QVa
QString rSubkeyPath = keyPath(rSubKey);
// open a handle on the subkey
- HKEY handle = openKey(parentHandle, KEY_READ, rSubkeyPath);
+ HKEY handle = openKey(parentHandle, KEY_READ, rSubkeyPath, access);
if (handle == 0)
return false;
@@ -604,16 +624,16 @@ void QWinSettingsPrivate::remove(const QString &uKey)
// try to delete value bar in key foo
LONG res;
- HKEY handle = openKey(writeHandle(), registryPermissions, keyPath(rKey));
+ HKEY handle = openKey(writeHandle(), registryPermissions, keyPath(rKey), access);
if (handle != 0) {
res = RegDeleteValue(handle, reinterpret_cast<const wchar_t *>(keyName(rKey).utf16()));
RegCloseKey(handle);
}
// try to delete key foo/bar and all subkeys
- handle = openKey(writeHandle(), registryPermissions, rKey);
+ handle = openKey(writeHandle(), registryPermissions, rKey, access);
if (handle != 0) {
- deleteChildGroups(handle);
+ deleteChildGroups(handle, access);
if (rKey.isEmpty()) {
QStringList childKeys = childKeysOrGroups(handle, QSettingsPrivate::ChildKeys);
@@ -661,7 +681,7 @@ void QWinSettingsPrivate::set(const QString &uKey, const QVariant &value)
QString rKey = escapedKey(uKey);
- HKEY handle = createOrOpenKey(writeHandle(), registryPermissions, keyPath(rKey));
+ HKEY handle = createOrOpenKey(writeHandle(), registryPermissions, keyPath(rKey), access);
if (handle == 0) {
setStatus(QSettings::AccessError);
return;
@@ -775,13 +795,13 @@ QStringList QWinSettingsPrivate::children(const QString &uKey, ChildSpec spec) c
HKEY parent_handle = regList.at(i).handle();
if (parent_handle == 0)
continue;
- HKEY handle = openKey(parent_handle, KEY_READ, rKey);
+ HKEY handle = openKey(parent_handle, KEY_READ, rKey, access);
if (handle == 0)
continue;
if (spec == AllKeys) {
NameSet keys;
- allKeys(handle, QLatin1String(""), &keys);
+ allKeys(handle, QLatin1String(""), &keys, access);
mergeKeySets(&result, keys);
} else { // ChildGroups or ChildKeys
QStringList names = childKeysOrGroups(handle, spec);
@@ -836,20 +856,26 @@ bool QWinSettingsPrivate::isWritable() const
QSettingsPrivate *QSettingsPrivate::create(QSettings::Format format, QSettings::Scope scope,
const QString &organization, const QString &application)
{
- if (format == QSettings::NativeFormat) {
+ if (format == QSettings::NativeFormat)
return new QWinSettingsPrivate(scope, organization, application);
- } else {
+ else if (format == QSettings::Registry32Format)
+ return new QWinSettingsPrivate(scope, organization, application, KEY_WOW64_32KEY);
+ else if (format == QSettings::Registry64Format)
+ return new QWinSettingsPrivate(scope, organization, application, KEY_WOW64_64KEY);
+ else
return new QConfFileSettingsPrivate(format, scope, organization, application);
- }
}
QSettingsPrivate *QSettingsPrivate::create(const QString &fileName, QSettings::Format format)
{
- if (format == QSettings::NativeFormat) {
+ if (format == QSettings::NativeFormat)
return new QWinSettingsPrivate(fileName);
- } else {
+ else if (format == QSettings::Registry32Format)
+ return new QWinSettingsPrivate(fileName, KEY_WOW64_32KEY);
+ else if (format == QSettings::Registry64Format)
+ return new QWinSettingsPrivate(fileName, KEY_WOW64_64KEY);
+ else
return new QConfFileSettingsPrivate(fileName, format);
- }
}
QT_END_NAMESPACE
diff --git a/src/corelib/io/qstandardpaths.cpp b/src/corelib/io/qstandardpaths.cpp
index 8828e09e8f..0137e859e7 100644
--- a/src/corelib/io/qstandardpaths.cpp
+++ b/src/corelib/io/qstandardpaths.cpp
@@ -277,13 +277,13 @@ QT_BEGIN_NAMESPACE
\header \li Path type \li Android \li iOS
\row \li DesktopLocation
\li "<APPROOT>/files"
- \li "<APPROOT>/<APPDIR>" (not writable)
+ \li "<APPROOT>/Documents/Desktop"
\row \li DocumentsLocation
\li "<USER>/Documents", "<USER>/<APPNAME>/Documents"
\li "<APPROOT>/Documents"
\row \li FontsLocation
\li "/system/fonts" (not writable)
- \li "<APPROOT>/Documents/.fonts"
+ \li "<APPROOT>/Library/Fonts"
\row \li ApplicationsLocation
\li not supported (directory not readable)
\li not supported
@@ -301,7 +301,7 @@ QT_BEGIN_NAMESPACE
\li "<APPROOT>/tmp"
\row \li HomeLocation
\li "<APPROOT>/files"
- \li "<APPROOT>/<APPDIR>" (not writable)
+ \li "<APPROOT>" (not writable)
\row \li DataLocation
\li "<APPROOT>/files", "<USER>/<APPNAME>/files"
\li "<APPROOT>/Library/Application Support"
@@ -316,13 +316,13 @@ QT_BEGIN_NAMESPACE
\li not supported
\row \li ConfigLocation
\li "<APPROOT>/files/settings"
- \li "<APPROOT>/Documents"
+ \li "<APPROOT>/Library/Preferences"
\row \li GenericConfigLocation
\li "<APPROOT>/files/settings" (there is no shared settings)
- \li "<APPROOT>/Documents"
+ \li "<APPROOT>/Library/Preferences"
\row \li DownloadLocation
\li "<USER>/Downloads", "<USER>/<APPNAME>/Downloads"
- \li "<APPROOT>/Documents/Download"
+ \li "<APPROOT>/Documents/Downloads"
\row \li GenericCacheLocation
\li "<APPROOT>/cache" (there is no shared cache)
\li "<APPROOT>/Library/Caches"
@@ -331,7 +331,7 @@ QT_BEGIN_NAMESPACE
\li "<APPROOT>/Library/Application Support"
\row \li AppConfigLocation
\li "<APPROOT>/files/settings"
- \li "<APPROOT>/Documents"
+ \li "<APPROOT>/Library/Preferences/<APPNAME>"
\row \li AppLocalDataLocation
\li "<APPROOT>/files", "<USER>/<APPNAME>/files"
\li "<APPROOT>/Library/Application Support"
@@ -555,7 +555,7 @@ QString QStandardPaths::findExecutable(const QString &executableName, const QStr
an empty QString if no relevant location can be found.
*/
-#if !defined(Q_OS_OSX) && !defined(QT_BOOTSTRAPPED)
+#if !defined(Q_OS_MAC) && !defined(QT_BOOTSTRAPPED)
QString QStandardPaths::displayName(StandardLocation type)
{
switch (type) {
diff --git a/src/corelib/io/qstandardpaths_ios.mm b/src/corelib/io/qstandardpaths_ios.mm
deleted file mode 100644
index eb85e2fd23..0000000000
--- a/src/corelib/io/qstandardpaths_ios.mm
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#import <UIKit/UIKit.h>
-
-#include "qstandardpaths.h"
-
-#ifndef QT_NO_STANDARDPATHS
-
-QT_BEGIN_NAMESPACE
-
-static QString pathForDirectory(NSSearchPathDirectory directory)
-{
- return QString::fromNSString(
- [NSSearchPathForDirectoriesInDomains(directory, NSUserDomainMask, YES) lastObject]);
-}
-
-static QString bundlePath()
-{
- return QString::fromNSString([[NSBundle mainBundle] bundlePath]);
-}
-
-QString QStandardPaths::writableLocation(StandardLocation type)
-{
- QString location;
-
- switch (type) {
- case DocumentsLocation:
- location = pathForDirectory(NSDocumentDirectory);
- break;
- case FontsLocation:
- location = pathForDirectory(NSDocumentDirectory) + QLatin1String("/.fonts");
- break;
- case ApplicationsLocation:
- // NSApplicationDirectory points to a non-existing write-protected path.
- break;
- case MusicLocation:
- // NSMusicDirectory points to a non-existing write-protected path. Use sensible fallback.
- location = pathForDirectory(NSDocumentDirectory) + QLatin1String("/Music");
- break;
- case MoviesLocation:
- // NSMoviesDirectory points to a non-existing write-protected path. Use sensible fallback.
- location = pathForDirectory(NSDocumentDirectory) + QLatin1String("/Movies");
- break;
- case PicturesLocation:
- // NSPicturesDirectory points to a non-existing write-protected path. Use sensible fallback.
- location = pathForDirectory(NSDocumentDirectory) + QLatin1String("/Pictures");
- break;
- case TempLocation:
- location = QString::fromNSString(NSTemporaryDirectory());
- break;
- case DesktopLocation:
- case HomeLocation:
- location = bundlePath();
- break;
- case AppDataLocation:
- case AppLocalDataLocation:
- location = pathForDirectory(NSApplicationSupportDirectory);
- break;
- case GenericDataLocation:
- location = pathForDirectory(NSDocumentDirectory);
- break;
- case CacheLocation:
- case GenericCacheLocation:
- location = pathForDirectory(NSCachesDirectory);
- break;
- case ConfigLocation:
- case GenericConfigLocation:
- case AppConfigLocation:
- location = pathForDirectory(NSDocumentDirectory);
- break;
- case DownloadLocation:
- // NSDownloadsDirectory points to a non-existing write-protected path.
- location = pathForDirectory(NSDocumentDirectory) + QLatin1String("/Download");
- break;
- case RuntimeLocation:
- break;
- default:
- break;
- }
-
- return location;
-}
-
-QStringList QStandardPaths::standardLocations(StandardLocation type)
-{
- QStringList dirs;
-
- switch (type) {
- case PicturesLocation:
- dirs << writableLocation(PicturesLocation) << QLatin1String("assets-library://");
- break;
- default:
- dirs << writableLocation(type);
- break;
- }
-
- return dirs;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_STANDARDPATHS
diff --git a/src/corelib/io/qstandardpaths_mac.mm b/src/corelib/io/qstandardpaths_mac.mm
index d6126ce1c3..57d365e916 100644
--- a/src/corelib/io/qstandardpaths_mac.mm
+++ b/src/corelib/io/qstandardpaths_mac.mm
@@ -32,6 +32,9 @@
****************************************************************************/
#include "qstandardpaths.h"
+
+#ifndef QT_NO_STANDARDPATHS
+
#include <qdir.h>
#include <qurl.h>
#include <private/qcore_mac_p.h>
@@ -40,63 +43,47 @@
#include <qcoreapplication.h>
#endif
-#include <CoreFoundation/CoreFoundation.h>
-#include <ApplicationServices/ApplicationServices.h>
+#import <Foundation/Foundation.h>
QT_BEGIN_NAMESPACE
-/*
- Translates a QStandardPaths::StandardLocation into the mac equivalent.
-*/
-OSType translateLocation(QStandardPaths::StandardLocation type)
+static QString pathForDirectory(NSSearchPathDirectory directory,
+ NSSearchPathDomainMask mask)
+{
+ return QString::fromNSString(
+ [NSSearchPathForDirectoriesInDomains(directory, mask, YES) lastObject]);
+}
+
+static NSSearchPathDirectory searchPathDirectory(QStandardPaths::StandardLocation type)
{
switch (type) {
- case QStandardPaths::ConfigLocation:
- case QStandardPaths::GenericConfigLocation:
- case QStandardPaths::AppConfigLocation:
- return kPreferencesFolderType;
case QStandardPaths::DesktopLocation:
- return kDesktopFolderType;
+ return NSDesktopDirectory;
case QStandardPaths::DocumentsLocation:
- return kDocumentsFolderType;
- case QStandardPaths::FontsLocation:
- // There are at least two different font directories on the mac: /Library/Fonts and ~/Library/Fonts.
- // To select a specific one we have to specify a different first parameter when calling FSFindFolder.
- return kFontsFolderType;
+ return NSDocumentDirectory;
case QStandardPaths::ApplicationsLocation:
- return kApplicationsFolderType;
+ return NSApplicationDirectory;
case QStandardPaths::MusicLocation:
- return kMusicDocumentsFolderType;
+ return NSMusicDirectory;
case QStandardPaths::MoviesLocation:
- return kMovieDocumentsFolderType;
+ return NSMoviesDirectory;
case QStandardPaths::PicturesLocation:
- return kPictureDocumentsFolderType;
- case QStandardPaths::TempLocation:
- return kTemporaryFolderType;
+ return NSPicturesDirectory;
case QStandardPaths::GenericDataLocation:
case QStandardPaths::RuntimeLocation:
case QStandardPaths::AppDataLocation:
case QStandardPaths::AppLocalDataLocation:
- return kApplicationSupportFolderType;
+ return NSApplicationSupportDirectory;
case QStandardPaths::GenericCacheLocation:
case QStandardPaths::CacheLocation:
- return kCachedDataFolderType;
+ return NSCachesDirectory;
+ case QStandardPaths::DownloadLocation:
+ return NSDownloadsDirectory;
default:
- return kDesktopFolderType;
+ return (NSSearchPathDirectory)0;
}
}
-/*
- Constructs a full unicode path from a FSRef.
-*/
-static QString getFullPath(const FSRef &ref)
-{
- QByteArray ba(2048, 0);
- if (FSRefMakePath(&ref, reinterpret_cast<UInt8 *>(ba.data()), ba.size()) == noErr)
- return QString::fromUtf8(ba.constData()).normalized(QString::NormalizationForm_C);
- return QString();
-}
-
static void appendOrganizationAndApp(QString &path)
{
#ifndef QT_BOOTSTRAPPED
@@ -111,28 +98,65 @@ static void appendOrganizationAndApp(QString &path)
#endif
}
-static QString macLocation(QStandardPaths::StandardLocation type, short domain)
+static QString baseWritableLocation(QStandardPaths::StandardLocation type,
+ NSSearchPathDomainMask mask = NSUserDomainMask,
+ bool appendOrgAndApp = false)
{
- // https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/index.html
- if (type == QStandardPaths::DownloadLocation) {
- NSFileManager *fileManager = [NSFileManager defaultManager];
- NSURL *url = [fileManager URLForDirectory:NSDownloadsDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
- if (!url)
- return QString();
- return QString::fromNSString([url path]);
+ QString path;
+ const NSSearchPathDirectory dir = searchPathDirectory(type);
+ switch (type) {
+ case QStandardPaths::HomeLocation:
+ path = QDir::homePath();
+ break;
+ case QStandardPaths::TempLocation:
+ path = QDir::tempPath();
+ break;
+#ifdef Q_OS_IOS
+ // These locations point to non-existing write-protected paths. Use sensible fallbacks.
+ case QStandardPaths::MusicLocation:
+ path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Music");
+ break;
+ case QStandardPaths::MoviesLocation:
+ path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Movies");
+ break;
+ case QStandardPaths::PicturesLocation:
+ path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Pictures");
+ break;
+ case QStandardPaths::DownloadLocation:
+ path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Downloads");
+ break;
+ case QStandardPaths::DesktopLocation:
+ path = pathForDirectory(NSDocumentDirectory, mask) + QLatin1String("/Desktop");
+ break;
+ case QStandardPaths::ApplicationsLocation:
+ break;
+#endif
+ case QStandardPaths::FontsLocation:
+ path = pathForDirectory(NSLibraryDirectory, mask) + QLatin1String("/Fonts");
+ break;
+ case QStandardPaths::ConfigLocation:
+ case QStandardPaths::GenericConfigLocation:
+ case QStandardPaths::AppConfigLocation:
+ path = pathForDirectory(NSLibraryDirectory, mask) + QLatin1String("/Preferences");
+ break;
+ default:
+ path = pathForDirectory(dir, mask);
+ break;
}
- // http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
- FSRef ref;
- OSErr err = FSFindFolder(domain, translateLocation(type), false, &ref);
- if (err)
- return QString();
-
- QString path = getFullPath(ref);
+ if (appendOrgAndApp) {
+ switch (type) {
+ case QStandardPaths::AppDataLocation:
+ case QStandardPaths::AppLocalDataLocation:
+ case QStandardPaths::AppConfigLocation:
+ case QStandardPaths::CacheLocation:
+ appendOrganizationAndApp(path);
+ break;
+ default:
+ break;
+ }
+ }
- if (type == QStandardPaths::AppDataLocation || type == QStandardPaths::AppLocalDataLocation ||
- type == QStandardPaths::CacheLocation || type == QStandardPaths::AppConfigLocation)
- appendOrganizationAndApp(path);
return path;
}
@@ -167,31 +191,32 @@ QString QStandardPaths::writableLocation(StandardLocation type)
}
}
- switch (type) {
- case HomeLocation:
- return QDir::homePath();
- case TempLocation:
- return QDir::tempPath();
- case GenericDataLocation:
- case AppDataLocation:
- case AppLocalDataLocation:
- case GenericCacheLocation:
- case CacheLocation:
- case RuntimeLocation:
- return macLocation(type, kUserDomain);
- default:
- return macLocation(type, kOnAppropriateDisk);
- }
+ return baseWritableLocation(type, NSUserDomainMask, true);
}
QStringList QStandardPaths::standardLocations(StandardLocation type)
{
QStringList dirs;
- if (type == GenericDataLocation || type == AppDataLocation || type == AppLocalDataLocation || type == GenericCacheLocation || type == CacheLocation) {
- const QString path = macLocation(type, kOnAppropriateDisk);
- if (!path.isEmpty())
- dirs.append(path);
+#ifdef Q_OS_IOS
+ if (type == PicturesLocation)
+ dirs << writableLocation(PicturesLocation) << QLatin1String("assets-library://");
+#endif
+
+ if (type == GenericDataLocation || type == FontsLocation || type == ApplicationsLocation
+ || type == AppDataLocation || type == AppLocalDataLocation
+ || type == GenericCacheLocation || type == CacheLocation) {
+ QList<NSSearchPathDomainMask> masks;
+ masks << NSLocalDomainMask;
+ if (type == FontsLocation || type == GenericCacheLocation)
+ masks << NSSystemDomainMask;
+
+ for (QList<NSSearchPathDomainMask>::const_iterator it = masks.begin();
+ it != masks.end(); ++it) {
+ const QString path = baseWritableLocation(type, *it, true);
+ if (!path.isEmpty() && !dirs.contains(path))
+ dirs.append(path);
+ }
}
if (type == AppDataLocation || type == AppLocalDataLocation) {
@@ -219,28 +244,41 @@ QStringList QStandardPaths::standardLocations(StandardLocation type)
}
}
const QString localDir = writableLocation(type);
- dirs.prepend(localDir);
+ if (!localDir.isEmpty())
+ dirs.prepend(localDir);
return dirs;
}
#ifndef QT_BOOTSTRAPPED
QString QStandardPaths::displayName(StandardLocation type)
{
+ // Use "Home" instead of the user's Unix username
if (QStandardPaths::HomeLocation == type)
return QCoreApplication::translate("QStandardPaths", "Home");
- FSRef ref;
- OSErr err = FSFindFolder(kOnAppropriateDisk, translateLocation(type), false, &ref);
- if (err)
- return QString();
+ // The temporary directory returned by the old Carbon APIs is ~/Library/Caches/TemporaryItems,
+ // the display name of which ("TemporaryItems") isn't translated by the system. The standard
+ // temporary directory has no reasonable display name either, so use something more sensible.
+ if (QStandardPaths::TempLocation == type)
+ return QCoreApplication::translate("QStandardPaths", "Temporary Items");
- QCFString displayName;
- err = LSCopyDisplayNameForRef(&ref, &displayName);
- if (err)
- return QString();
+ // standardLocations() may return an empty list on some platforms
+ if (QStandardPaths::ApplicationsLocation == type)
+ return QCoreApplication::translate("QStandardPaths", "Applications");
- return static_cast<QString>(displayName);
+ if (QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
+ standardLocations(type).first().toCFString(),
+ kCFURLPOSIXPathStyle, true)) {
+ QCFString name;
+ CFURLCopyResourcePropertyForKey(url, kCFURLLocalizedNameKey, &name, NULL);
+ if (name && CFStringGetLength(name))
+ return QString::fromCFString(name);
+ }
+
+ return QFileInfo(baseWritableLocation(type)).fileName();
}
#endif
QT_END_NAMESPACE
+
+#endif // QT_NO_STANDARDPATHS
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 2719019d30..53725c7f90 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -2686,7 +2686,7 @@ void QCoreApplication::removeLibraryPath(const QString &path)
i.e. MSG or XCB event structs.
\note Native event filters will be disabled when the application the
- Qt::AA_MacPluginApplication attribute is set.
+ Qt::AA_PluginApplication attribute is set.
For maximum portability, you should always try to use QEvent
and QObject::installEventFilter() whenever possible.
@@ -2697,8 +2697,8 @@ void QCoreApplication::removeLibraryPath(const QString &path)
*/
void QCoreApplication::installNativeEventFilter(QAbstractNativeEventFilter *filterObj)
{
- if (QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) {
- qWarning("Native event filters are not applied when the Qt::AA_MacPluginApplication attribute is set");
+ if (QCoreApplication::testAttribute(Qt::AA_PluginApplication)) {
+ qWarning("Native event filters are not applied when the Qt::AA_PluginApplication attribute is set");
return;
}
diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h
index 53da4a849b..d9de828fa1 100644
--- a/src/corelib/kernel/qcoreevent.h
+++ b/src/corelib/kernel/qcoreevent.h
@@ -276,6 +276,8 @@ public:
PlatformSurface = 217, // Platform surface created or about to be destroyed
+ Pointer = 218, // QQuickPointerEvent; ### Qt 6: QPointerEvent
+
// 512 reserved for Qt Jambi's MetaCall event
// 513 reserved for Qt Jambi's DeleteOnMainThread event
diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp
index 021e137273..e346d7b44e 100644
--- a/src/corelib/kernel/qmetaobjectbuilder.cpp
+++ b/src/corelib/kernel/qmetaobjectbuilder.cpp
@@ -36,6 +36,7 @@
#include "qobject_p.h"
#include "qmetaobject_p.h"
+#include <vector>
#include <stdlib.h>
QT_BEGIN_NAMESPACE
@@ -88,7 +89,6 @@ static inline Q_DECL_UNUSED const QMetaObjectPrivate *priv(const uint* data)
class QMetaMethodBuilderPrivate
{
public:
- QMetaMethodBuilderPrivate() {} // for QVector, don't use
QMetaMethodBuilderPrivate
(QMetaMethod::MethodType _methodType,
const QByteArray& _signature,
@@ -145,7 +145,6 @@ Q_DECLARE_TYPEINFO(QMetaMethodBuilderPrivate, Q_MOVABLE_TYPE);
class QMetaPropertyBuilderPrivate
{
public:
- QMetaPropertyBuilderPrivate() {} // for QVector, don't use
QMetaPropertyBuilderPrivate
(const QByteArray& _name, const QByteArray& _type, int notifierIdx=-1,
int _revision = 0)
@@ -184,7 +183,6 @@ Q_DECLARE_TYPEINFO(QMetaPropertyBuilderPrivate, Q_MOVABLE_TYPE);
class QMetaEnumBuilderPrivate
{
public:
- QMetaEnumBuilderPrivate() {} // for QVector, don't use
QMetaEnumBuilderPrivate(const QByteArray& _name)
: name(_name), isFlag(false)
{
@@ -213,19 +211,19 @@ public:
QByteArray className;
const QMetaObject *superClass;
QMetaObjectBuilder::StaticMetacallFunction staticMetacallFunction;
- QVector<QMetaMethodBuilderPrivate> methods;
- QVector<QMetaMethodBuilderPrivate> constructors;
- QVector<QMetaPropertyBuilderPrivate> properties;
+ std::vector<QMetaMethodBuilderPrivate> methods;
+ std::vector<QMetaMethodBuilderPrivate> constructors;
+ std::vector<QMetaPropertyBuilderPrivate> properties;
QList<QByteArray> classInfoNames;
QList<QByteArray> classInfoValues;
- QVector<QMetaEnumBuilderPrivate> enumerators;
+ std::vector<QMetaEnumBuilderPrivate> enumerators;
QList<const QMetaObject *> relatedMetaObjects;
int flags;
};
bool QMetaObjectBuilderPrivate::hasRevisionedProperties() const
{
- for (int i = 0; i < properties.size(); ++i) {
+ for (size_t i = 0; i < properties.size(); ++i) {
if (properties.at(i).revision)
return true;
}
@@ -234,7 +232,7 @@ bool QMetaObjectBuilderPrivate::hasRevisionedProperties() const
bool QMetaObjectBuilderPrivate::hasRevisionedMethods() const
{
- for (int i = 0; i < methods.size(); ++i) {
+ for (size_t i = 0; i < methods.size(); ++i) {
if (methods.at(i).revision)
return true;
}
@@ -353,7 +351,7 @@ void QMetaObjectBuilder::setFlags(MetaObjectFlags flags)
*/
int QMetaObjectBuilder::methodCount() const
{
- return d->methods.size();
+ return int(d->methods.size());
}
/*!
@@ -363,7 +361,7 @@ int QMetaObjectBuilder::methodCount() const
*/
int QMetaObjectBuilder::constructorCount() const
{
- return d->constructors.size();
+ return int(d->constructors.size());
}
/*!
@@ -374,7 +372,7 @@ int QMetaObjectBuilder::constructorCount() const
*/
int QMetaObjectBuilder::propertyCount() const
{
- return d->properties.size();
+ return int(d->properties.size());
}
/*!
@@ -386,7 +384,7 @@ int QMetaObjectBuilder::propertyCount() const
*/
int QMetaObjectBuilder::enumeratorCount() const
{
- return d->enumerators.size();
+ return int(d->enumerators.size());
}
/*!
@@ -427,8 +425,8 @@ int QMetaObjectBuilder::relatedMetaObjectCount() const
*/
QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QByteArray& signature)
{
- int index = d->methods.size();
- d->methods.append(QMetaMethodBuilderPrivate(QMetaMethod::Method, signature));
+ int index = int(d->methods.size());
+ d->methods.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Method, signature));
return QMetaMethodBuilder(this, index);
}
@@ -444,8 +442,8 @@ QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QByteArray& signature)
QMetaMethodBuilder QMetaObjectBuilder::addMethod
(const QByteArray& signature, const QByteArray& returnType)
{
- int index = d->methods.size();
- d->methods.append(QMetaMethodBuilderPrivate
+ int index = int(d->methods.size());
+ d->methods.push_back(QMetaMethodBuilderPrivate
(QMetaMethod::Method, signature, returnType));
return QMetaMethodBuilder(this, index);
}
@@ -491,8 +489,8 @@ QMetaMethodBuilder QMetaObjectBuilder::addMethod(const QMetaMethod& prototype)
*/
QMetaMethodBuilder QMetaObjectBuilder::addSlot(const QByteArray& signature)
{
- int index = d->methods.size();
- d->methods.append(QMetaMethodBuilderPrivate(QMetaMethod::Slot, signature));
+ int index = int(d->methods.size());
+ d->methods.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Slot, signature));
return QMetaMethodBuilder(this, index);
}
@@ -506,8 +504,8 @@ QMetaMethodBuilder QMetaObjectBuilder::addSlot(const QByteArray& signature)
*/
QMetaMethodBuilder QMetaObjectBuilder::addSignal(const QByteArray& signature)
{
- int index = d->methods.size();
- d->methods.append(QMetaMethodBuilderPrivate
+ int index = int(d->methods.size());
+ d->methods.push_back(QMetaMethodBuilderPrivate
(QMetaMethod::Signal, signature, QByteArray("void"), QMetaMethod::Public));
return QMetaMethodBuilder(this, index);
}
@@ -523,9 +521,9 @@ QMetaMethodBuilder QMetaObjectBuilder::addSignal(const QByteArray& signature)
*/
QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QByteArray& signature)
{
- int index = d->constructors.size();
- d->constructors.append(QMetaMethodBuilderPrivate(QMetaMethod::Constructor, signature,
- /*returnType=*/QByteArray()));
+ int index = int(d->constructors.size());
+ d->constructors.push_back(QMetaMethodBuilderPrivate(QMetaMethod::Constructor, signature,
+ /*returnType=*/QByteArray()));
return QMetaMethodBuilder(this, -(index + 1));
}
@@ -564,8 +562,8 @@ QMetaMethodBuilder QMetaObjectBuilder::addConstructor(const QMetaMethod& prototy
QMetaPropertyBuilder QMetaObjectBuilder::addProperty
(const QByteArray& name, const QByteArray& type, int notifierId)
{
- int index = d->properties.size();
- d->properties.append(QMetaPropertyBuilderPrivate(name, type, notifierId));
+ int index = int(d->properties.size());
+ d->properties.push_back(QMetaPropertyBuilderPrivate(name, type, notifierId));
return QMetaPropertyBuilder(this, index);
}
@@ -615,8 +613,8 @@ QMetaPropertyBuilder QMetaObjectBuilder::addProperty(const QMetaProperty& protot
*/
QMetaEnumBuilder QMetaObjectBuilder::addEnumerator(const QByteArray& name)
{
- int index = d->enumerators.size();
- d->enumerators.append(QMetaEnumBuilderPrivate(name));
+ int index = int(d->enumerators.size());
+ d->enumerators.push_back(QMetaEnumBuilderPrivate(name));
return QMetaEnumBuilder(this, index);
}
@@ -762,7 +760,7 @@ void QMetaObjectBuilder::addMetaObject
*/
QMetaMethodBuilder QMetaObjectBuilder::method(int index) const
{
- if (index >= 0 && index < d->methods.size())
+ if (uint(index) < d->methods.size())
return QMetaMethodBuilder(this, index);
else
return QMetaMethodBuilder();
@@ -775,7 +773,7 @@ QMetaMethodBuilder QMetaObjectBuilder::method(int index) const
*/
QMetaMethodBuilder QMetaObjectBuilder::constructor(int index) const
{
- if (index >= 0 && index < d->constructors.size())
+ if (uint(index) < d->constructors.size())
return QMetaMethodBuilder(this, -(index + 1));
else
return QMetaMethodBuilder();
@@ -788,7 +786,7 @@ QMetaMethodBuilder QMetaObjectBuilder::constructor(int index) const
*/
QMetaPropertyBuilder QMetaObjectBuilder::property(int index) const
{
- if (index >= 0 && index < d->properties.size())
+ if (uint(index) < d->properties.size())
return QMetaPropertyBuilder(this, index);
else
return QMetaPropertyBuilder();
@@ -802,7 +800,7 @@ QMetaPropertyBuilder QMetaObjectBuilder::property(int index) const
*/
QMetaEnumBuilder QMetaObjectBuilder::enumerator(int index) const
{
- if (index >= 0 && index < d->enumerators.size())
+ if (uint(index) < d->enumerators.size())
return QMetaEnumBuilder(this, index);
else
return QMetaEnumBuilder();
@@ -866,9 +864,9 @@ QByteArray QMetaObjectBuilder::classInfoValue(int index) const
*/
void QMetaObjectBuilder::removeMethod(int index)
{
- if (index >= 0 && index < d->methods.size()) {
- d->methods.removeAt(index);
- for (int prop = 0; prop < d->properties.size(); ++prop) {
+ if (uint(index) < d->methods.size()) {
+ d->methods.erase(d->methods.begin() + index);
+ for (size_t prop = 0; prop < d->properties.size(); ++prop) {
// Adjust the indices of property notify signal references.
if (d->properties[prop].notifySignal == index) {
d->properties[prop].notifySignal = -1;
@@ -888,8 +886,8 @@ void QMetaObjectBuilder::removeMethod(int index)
*/
void QMetaObjectBuilder::removeConstructor(int index)
{
- if (index >= 0 && index < d->constructors.size())
- d->constructors.removeAt(index);
+ if (uint(index) < d->constructors.size())
+ d->constructors.erase(d->constructors.begin() + index);
}
/*!
@@ -900,8 +898,8 @@ void QMetaObjectBuilder::removeConstructor(int index)
*/
void QMetaObjectBuilder::removeProperty(int index)
{
- if (index >= 0 && index < d->properties.size())
- d->properties.removeAt(index);
+ if (uint(index) < d->properties.size())
+ d->properties.erase(d->properties.begin() + index);
}
/*!
@@ -913,8 +911,8 @@ void QMetaObjectBuilder::removeProperty(int index)
*/
void QMetaObjectBuilder::removeEnumerator(int index)
{
- if (index >= 0 && index < d->enumerators.size())
- d->enumerators.removeAt(index);
+ if (uint(index) < d->enumerators.size())
+ d->enumerators.erase(d->enumerators.begin() + index);
}
/*!
@@ -959,9 +957,9 @@ void QMetaObjectBuilder::removeRelatedMetaObject(int index)
int QMetaObjectBuilder::indexOfMethod(const QByteArray& signature)
{
QByteArray sig = QMetaObject::normalizedSignature(signature);
- for (int index = 0; index < d->methods.size(); ++index) {
+ for (size_t index = 0; index < d->methods.size(); ++index) {
if (sig == d->methods[index].signature)
- return index;
+ return int(index);
}
return -1;
}
@@ -975,10 +973,10 @@ int QMetaObjectBuilder::indexOfMethod(const QByteArray& signature)
int QMetaObjectBuilder::indexOfSignal(const QByteArray& signature)
{
QByteArray sig = QMetaObject::normalizedSignature(signature);
- for (int index = 0; index < d->methods.size(); ++index) {
+ for (size_t index = 0; index < d->methods.size(); ++index) {
if (sig == d->methods[index].signature &&
d->methods[index].methodType() == QMetaMethod::Signal)
- return index;
+ return int(index);
}
return -1;
}
@@ -992,10 +990,10 @@ int QMetaObjectBuilder::indexOfSignal(const QByteArray& signature)
int QMetaObjectBuilder::indexOfSlot(const QByteArray& signature)
{
QByteArray sig = QMetaObject::normalizedSignature(signature);
- for (int index = 0; index < d->methods.size(); ++index) {
+ for (size_t index = 0; index < d->methods.size(); ++index) {
if (sig == d->methods[index].signature &&
d->methods[index].methodType() == QMetaMethod::Slot)
- return index;
+ return int(index);
}
return -1;
}
@@ -1009,9 +1007,9 @@ int QMetaObjectBuilder::indexOfSlot(const QByteArray& signature)
int QMetaObjectBuilder::indexOfConstructor(const QByteArray& signature)
{
QByteArray sig = QMetaObject::normalizedSignature(signature);
- for (int index = 0; index < d->constructors.size(); ++index) {
+ for (size_t index = 0; index < d->constructors.size(); ++index) {
if (sig == d->constructors[index].signature)
- return index;
+ return int(index);
}
return -1;
}
@@ -1024,9 +1022,9 @@ int QMetaObjectBuilder::indexOfConstructor(const QByteArray& signature)
*/
int QMetaObjectBuilder::indexOfProperty(const QByteArray& name)
{
- for (int index = 0; index < d->properties.size(); ++index) {
+ for (size_t index = 0; index < d->properties.size(); ++index) {
if (name == d->properties[index].name)
- return index;
+ return int(index);
}
return -1;
}
@@ -1039,9 +1037,9 @@ int QMetaObjectBuilder::indexOfProperty(const QByteArray& name)
*/
int QMetaObjectBuilder::indexOfEnumerator(const QByteArray& name)
{
- for (int index = 0; index < d->enumerators.size(); ++index) {
+ for (size_t index = 0; index < d->enumerators.size(); ++index) {
if (name == d->enumerators[index].name)
- return index;
+ return int(index);
}
return -1;
}
@@ -1155,10 +1153,10 @@ void QMetaStringTable::writeBlob(char *out) const
// Returns the sum of all parameters (including return type) for the given
// \a methods. This is needed for calculating the size of the methods'
// parameter type/name meta-data.
-static int aggregateParameterCount(const QVector<QMetaMethodBuilderPrivate> &methods)
+static int aggregateParameterCount(const std::vector<QMetaMethodBuilderPrivate> &methods)
{
int sum = 0;
- for (int i = 0; i < methods.size(); ++i)
+ for (size_t i = 0; i < methods.size(); ++i)
sum += methods.at(i).parameterCount() + 1; // +1 for return type
return sum;
}
@@ -1200,7 +1198,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
= reinterpret_cast<QMetaObjectPrivate *>(buf + size);
int pmetaSize = size;
dataIndex = MetaObjectPrivateFieldCount;
- for (index = 0; index < d->properties.size(); ++index) {
+ for (size_t index = 0; index < d->properties.size(); ++index) {
if (d->properties[index].notifySignal != -1) {
hasNotifySignals = true;
break;
@@ -1209,8 +1207,8 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
int methodParametersDataSize =
((aggregateParameterCount(d->methods)
+ aggregateParameterCount(d->constructors)) * 2) // types and parameter names
- - d->methods.size() // return "parameters" don't have names
- - d->constructors.size(); // "this" parameters don't have names
+ - int(d->methods.size()) // return "parameters" don't have names
+ - int(d->constructors.size()); // "this" parameters don't have names
if (buf) {
Q_STATIC_ASSERT_X(QMetaObjectPrivate::OutputRevision == 7, "QMetaObjectBuilder should generate the same version as moc");
pmeta->revision = QMetaObjectPrivate::OutputRevision;
@@ -1222,48 +1220,48 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
pmeta->classInfoData = dataIndex;
dataIndex += 2 * d->classInfoNames.size();
- pmeta->methodCount = d->methods.size();
+ pmeta->methodCount = int(d->methods.size());
pmeta->methodData = dataIndex;
- dataIndex += 5 * d->methods.size();
+ dataIndex += 5 * int(d->methods.size());
if (hasRevisionedMethods)
- dataIndex += d->methods.size();
+ dataIndex += int(d->methods.size());
paramsIndex = dataIndex;
dataIndex += methodParametersDataSize;
- pmeta->propertyCount = d->properties.size();
+ pmeta->propertyCount = int(d->properties.size());
pmeta->propertyData = dataIndex;
- dataIndex += 3 * d->properties.size();
+ dataIndex += 3 * int(d->properties.size());
if (hasNotifySignals)
- dataIndex += d->properties.size();
+ dataIndex += int(d->properties.size());
if (hasRevisionedProperties)
- dataIndex += d->properties.size();
+ dataIndex += int(d->properties.size());
- pmeta->enumeratorCount = d->enumerators.size();
+ pmeta->enumeratorCount = int(d->enumerators.size());
pmeta->enumeratorData = dataIndex;
- dataIndex += 4 * d->enumerators.size();
+ dataIndex += 4 * int(d->enumerators.size());
- pmeta->constructorCount = d->constructors.size();
+ pmeta->constructorCount = int(d->constructors.size());
pmeta->constructorData = dataIndex;
- dataIndex += 5 * d->constructors.size();
+ dataIndex += 5 * int(d->constructors.size());
} else {
- dataIndex += 2 * d->classInfoNames.size();
- dataIndex += 5 * d->methods.size();
+ dataIndex += 2 * int(d->classInfoNames.size());
+ dataIndex += 5 * int(d->methods.size());
if (hasRevisionedMethods)
- dataIndex += d->methods.size();
+ dataIndex += int(d->methods.size());
paramsIndex = dataIndex;
dataIndex += methodParametersDataSize;
- dataIndex += 3 * d->properties.size();
+ dataIndex += 3 * int(d->properties.size());
if (hasNotifySignals)
- dataIndex += d->properties.size();
+ dataIndex += int(d->properties.size());
if (hasRevisionedProperties)
- dataIndex += d->properties.size();
- dataIndex += 4 * d->enumerators.size();
- dataIndex += 5 * d->constructors.size();
+ dataIndex += int(d->properties.size());
+ dataIndex += 4 * int(d->enumerators.size());
+ dataIndex += 5 * int(d->constructors.size());
}
// Allocate space for the enumerator key names and values.
enumIndex = dataIndex;
- for (index = 0; index < d->enumerators.size(); ++index) {
+ for (size_t index = 0; index < d->enumerators.size(); ++index) {
QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]);
dataIndex += 2 * enumerator->keys.size();
}
@@ -1305,7 +1303,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
// Output the methods in the class.
Q_ASSERT(!buf || dataIndex == pmeta->methodData);
- for (index = 0; index < d->methods.size(); ++index) {
+ for (size_t index = 0; index < d->methods.size(); ++index) {
QMetaMethodBuilderPrivate *method = &(d->methods[index]);
int name = strings.enter(method->name());
int argc = method->parameterCount();
@@ -1324,7 +1322,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
paramsIndex += 1 + argc * 2;
}
if (hasRevisionedMethods) {
- for (index = 0; index < d->methods.size(); ++index) {
+ for (size_t index = 0; index < d->methods.size(); ++index) {
QMetaMethodBuilderPrivate *method = &(d->methods[index]);
if (buf)
data[dataIndex] = method->revision;
@@ -1333,12 +1331,12 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
}
// Output the method parameters in the class.
- Q_ASSERT(!buf || dataIndex == pmeta->methodData + d->methods.size() * 5
- + (hasRevisionedMethods ? d->methods.size() : 0));
+ Q_ASSERT(!buf || dataIndex == pmeta->methodData + int(d->methods.size()) * 5
+ + (hasRevisionedMethods ? int(d->methods.size()) : 0));
for (int x = 0; x < 2; ++x) {
- QVector<QMetaMethodBuilderPrivate> &methods = (x == 0) ? d->methods : d->constructors;
- for (index = 0; index < methods.size(); ++index) {
- QMetaMethodBuilderPrivate *method = &(methods[index]);
+ const std::vector<QMetaMethodBuilderPrivate> &methods = (x == 0) ? d->methods : d->constructors;
+ for (size_t index = 0; index < methods.size(); ++index) {
+ const QMetaMethodBuilderPrivate *method = &(methods[index]);
QList<QByteArray> paramTypeNames = method->parameterTypes();
int paramCount = paramTypeNames.size();
for (int i = -1; i < paramCount; ++i) {
@@ -1367,7 +1365,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
// Output the properties in the class.
Q_ASSERT(!buf || dataIndex == pmeta->propertyData);
- for (index = 0; index < d->properties.size(); ++index) {
+ for (size_t index = 0; index < d->properties.size(); ++index) {
QMetaPropertyBuilderPrivate *prop = &(d->properties[index]);
int name = strings.enter(prop->name);
@@ -1390,7 +1388,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
dataIndex += 3;
}
if (hasNotifySignals) {
- for (index = 0; index < d->properties.size(); ++index) {
+ for (size_t index = 0; index < d->properties.size(); ++index) {
QMetaPropertyBuilderPrivate *prop = &(d->properties[index]);
if (buf) {
if (prop->notifySignal != -1)
@@ -1402,7 +1400,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
}
}
if (hasRevisionedProperties) {
- for (index = 0; index < d->properties.size(); ++index) {
+ for (size_t index = 0; index < d->properties.size(); ++index) {
QMetaPropertyBuilderPrivate *prop = &(d->properties[index]);
if (buf)
data[dataIndex] = prop->revision;
@@ -1412,7 +1410,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
// Output the enumerators in the class.
Q_ASSERT(!buf || dataIndex == pmeta->enumeratorData);
- for (index = 0; index < d->enumerators.size(); ++index) {
+ for (size_t index = 0; index < d->enumerators.size(); ++index) {
QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]);
int name = strings.enter(enumerator->name);
int isFlag = (int)(enumerator->isFlag);
@@ -1437,7 +1435,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf,
// Output the constructors in the class.
Q_ASSERT(!buf || dataIndex == pmeta->constructorData);
- for (index = 0; index < d->constructors.size(); ++index) {
+ for (size_t index = 0; index < d->constructors.size(); ++index) {
QMetaMethodBuilderPrivate *method = &(d->constructors[index]);
int name = strings.enter(method->name());
int argc = method->parameterCount();
@@ -1612,10 +1610,10 @@ void QMetaObjectBuilder::serialize(QDataStream& stream) const
// Write the counts for each type of class member.
stream << d->classInfoNames.size();
- stream << d->methods.size();
- stream << d->properties.size();
- stream << d->enumerators.size();
- stream << d->constructors.size();
+ stream << int(d->methods.size());
+ stream << int(d->properties.size());
+ stream << int(d->enumerators.size());
+ stream << int(d->constructors.size());
stream << d->relatedMetaObjects.size();
// Write the items of class information.
@@ -1625,7 +1623,7 @@ void QMetaObjectBuilder::serialize(QDataStream& stream) const
}
// Write the methods.
- for (index = 0; index < d->methods.size(); ++index) {
+ for (size_t index = 0; index < d->methods.size(); ++index) {
const QMetaMethodBuilderPrivate *method = &(d->methods[index]);
stream << method->signature;
stream << method->returnType;
@@ -1637,7 +1635,7 @@ void QMetaObjectBuilder::serialize(QDataStream& stream) const
}
// Write the properties.
- for (index = 0; index < d->properties.size(); ++index) {
+ for (size_t index = 0; index < d->properties.size(); ++index) {
const QMetaPropertyBuilderPrivate *property = &(d->properties[index]);
stream << property->name;
stream << property->type;
@@ -1648,7 +1646,7 @@ void QMetaObjectBuilder::serialize(QDataStream& stream) const
}
// Write the enumerators.
- for (index = 0; index < d->enumerators.size(); ++index) {
+ for (size_t index = 0; index < d->enumerators.size(); ++index) {
const QMetaEnumBuilderPrivate *enumerator = &(d->enumerators[index]);
stream << enumerator->name;
stream << enumerator->isFlag;
@@ -1657,7 +1655,7 @@ void QMetaObjectBuilder::serialize(QDataStream& stream) const
}
// Write the constructors.
- for (index = 0; index < d->constructors.size(); ++index) {
+ for (size_t index = 0; index < d->constructors.size(); ++index) {
const QMetaMethodBuilderPrivate *method = &(d->constructors[index]);
stream << method->signature;
stream << method->returnType;
@@ -1796,7 +1794,7 @@ void QMetaObjectBuilder::deserialize
stream >> property->flags;
stream >> property->notifySignal;
if (property->notifySignal < -1 ||
- property->notifySignal >= d->methods.size()) {
+ property->notifySignal >= int(d->methods.size())) {
// Notify signal method index is out of range.
stream.setStatus(QDataStream::ReadCorruptData);
return;
@@ -1875,9 +1873,9 @@ void QMetaObjectBuilder::deserialize
QMetaMethodBuilderPrivate *QMetaMethodBuilder::d_func() const
{
// Positive indices indicate methods, negative indices indicate constructors.
- if (_mobj && _index >= 0 && _index < _mobj->d->methods.size())
+ if (_mobj && _index >= 0 && _index < int(_mobj->d->methods.size()))
return &(_mobj->d->methods[_index]);
- else if (_mobj && -_index >= 1 && -_index <= _mobj->d->constructors.size())
+ else if (_mobj && -_index >= 1 && -_index <= int(_mobj->d->constructors.size()))
return &(_mobj->d->constructors[(-_index) - 1]);
else
return 0;
@@ -2116,7 +2114,7 @@ void QMetaMethodBuilder::setRevision(int revision)
QMetaPropertyBuilderPrivate *QMetaPropertyBuilder::d_func() const
{
- if (_mobj && _index >= 0 && _index < _mobj->d->properties.size())
+ if (_mobj && _index >= 0 && _index < int(_mobj->d->properties.size()))
return &(_mobj->d->properties[_index]);
else
return 0;
@@ -2588,7 +2586,7 @@ void QMetaPropertyBuilder::setRevision(int revision)
QMetaEnumBuilderPrivate *QMetaEnumBuilder::d_func() const
{
- if (_mobj && _index >= 0 && _index < _mobj->d->enumerators.size())
+ if (_mobj && _index >= 0 && _index < int(_mobj->d->enumerators.size()))
return &(_mobj->d->enumerators[_index]);
else
return 0;
diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp
index cc5aa1394a..f7545b5bcb 100644
--- a/src/corelib/plugin/qfactoryloader.cpp
+++ b/src/corelib/plugin/qfactoryloader.cpp
@@ -33,7 +33,7 @@
#include "qfactoryloader_p.h"
-#ifndef QT_NO_LIBRARY
+#ifndef QT_NO_QOBJECT
#include "qfactoryinterface.h"
#include "qmap.h"
#include <qdir.h>
@@ -50,10 +50,6 @@
QT_BEGIN_NAMESPACE
-Q_GLOBAL_STATIC(QList<QFactoryLoader *>, qt_factory_loaders)
-
-Q_GLOBAL_STATIC_WITH_ARGS(QMutex, qt_factoryloader_mutex, (QMutex::Recursive))
-
namespace {
// avoid duplicate QStringLiteral data:
@@ -69,18 +65,24 @@ class QFactoryLoaderPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QFactoryLoader)
public:
QFactoryLoaderPrivate(){}
+ QByteArray iid;
+#ifndef QT_NO_LIBRARY
~QFactoryLoaderPrivate();
mutable QMutex mutex;
- QByteArray iid;
QList<QLibraryPrivate*> libraryList;
QMap<QString,QLibraryPrivate*> keyMap;
QString suffix;
Qt::CaseSensitivity cs;
QStringList loadedPaths;
-
- void unloadPath(const QString &path);
+#endif
};
+#ifndef QT_NO_LIBRARY
+
+Q_GLOBAL_STATIC(QList<QFactoryLoader *>, qt_factory_loaders)
+
+Q_GLOBAL_STATIC_WITH_ARGS(QMutex, qt_factoryloader_mutex, (QMutex::Recursive))
+
QFactoryLoaderPrivate::~QFactoryLoaderPrivate()
{
for (int i = 0; i < libraryList.count(); ++i) {
@@ -90,25 +92,6 @@ QFactoryLoaderPrivate::~QFactoryLoaderPrivate()
}
}
-QFactoryLoader::QFactoryLoader(const char *iid,
- const QString &suffix,
- Qt::CaseSensitivity cs)
- : QObject(*new QFactoryLoaderPrivate)
-{
- moveToThread(QCoreApplicationPrivate::mainThread());
- Q_D(QFactoryLoader);
- d->iid = iid;
- d->cs = cs;
- d->suffix = suffix;
-
-
- QMutexLocker locker(qt_factoryloader_mutex());
- update();
- qt_factory_loaders()->append(this);
-}
-
-
-
void QFactoryLoader::update()
{
#ifdef QT_SHARED
@@ -229,13 +212,56 @@ QFactoryLoader::~QFactoryLoader()
qt_factory_loaders()->removeAll(this);
}
+#if defined(Q_OS_UNIX) && !defined (Q_OS_MAC)
+QLibraryPrivate *QFactoryLoader::library(const QString &key) const
+{
+ Q_D(const QFactoryLoader);
+ return d->keyMap.value(d->cs ? key : key.toLower());
+}
+#endif
+
+void QFactoryLoader::refreshAll()
+{
+ QMutexLocker locker(qt_factoryloader_mutex());
+ QList<QFactoryLoader *> *loaders = qt_factory_loaders();
+ for (QList<QFactoryLoader *>::const_iterator it = loaders->constBegin();
+ it != loaders->constEnd(); ++it) {
+ (*it)->update();
+ }
+}
+
+#endif // QT_NO_LIBRARY
+
+QFactoryLoader::QFactoryLoader(const char *iid,
+ const QString &suffix,
+ Qt::CaseSensitivity cs)
+ : QObject(*new QFactoryLoaderPrivate)
+{
+ moveToThread(QCoreApplicationPrivate::mainThread());
+ Q_D(QFactoryLoader);
+ d->iid = iid;
+#ifndef QT_NO_LIBRARY
+ d->cs = cs;
+ d->suffix = suffix;
+
+ QMutexLocker locker(qt_factoryloader_mutex());
+ update();
+ qt_factory_loaders()->append(this);
+#else
+ Q_UNUSED(suffix);
+ Q_UNUSED(cs);
+#endif
+}
+
QList<QJsonObject> QFactoryLoader::metaData() const
{
Q_D(const QFactoryLoader);
- QMutexLocker locker(&d->mutex);
QList<QJsonObject> metaData;
+#ifndef QT_NO_LIBRARY
+ QMutexLocker locker(&d->mutex);
for (int i = 0; i < d->libraryList.size(); ++i)
metaData.append(d->libraryList.at(i)->metaData);
+#endif
foreach (const QStaticPlugin &plugin, QPluginLoader::staticPlugins()) {
const QJsonObject object = plugin.metaData();
@@ -252,6 +278,7 @@ QObject *QFactoryLoader::instance(int index) const
if (index < 0)
return 0;
+#ifndef QT_NO_LIBRARY
if (index < d->libraryList.size()) {
QLibraryPrivate *library = d->libraryList.at(index);
if (library->instance || library->loadPlugin()) {
@@ -266,8 +293,9 @@ QObject *QFactoryLoader::instance(int index) const
}
return 0;
}
-
index -= d->libraryList.size();
+#endif
+
QVector<QStaticPlugin> staticPlugins = QPluginLoader::staticPlugins();
for (int i = 0; i < staticPlugins.count(); ++i) {
const QJsonObject object = staticPlugins.at(i).metaData();
@@ -282,24 +310,6 @@ QObject *QFactoryLoader::instance(int index) const
return 0;
}
-#if defined(Q_OS_UNIX) && !defined (Q_OS_MAC)
-QLibraryPrivate *QFactoryLoader::library(const QString &key) const
-{
- Q_D(const QFactoryLoader);
- return d->keyMap.value(d->cs ? key : key.toLower());
-}
-#endif
-
-void QFactoryLoader::refreshAll()
-{
- QMutexLocker locker(qt_factoryloader_mutex());
- QList<QFactoryLoader *> *loaders = qt_factory_loaders();
- for (QList<QFactoryLoader *>::const_iterator it = loaders->constBegin();
- it != loaders->constEnd(); ++it) {
- (*it)->update();
- }
-}
-
QMultiMap<int, QString> QFactoryLoader::keyMap() const
{
QMultiMap<int, QString> result;
@@ -335,4 +345,4 @@ int QFactoryLoader::indexOf(const QString &needle) const
QT_END_NAMESPACE
-#endif // QT_NO_LIBRARY
+#endif // QT_NO_QOBJECT
diff --git a/src/corelib/plugin/qfactoryloader_p.h b/src/corelib/plugin/qfactoryloader_p.h
index 1c48491b0d..ee07084180 100644
--- a/src/corelib/plugin/qfactoryloader_p.h
+++ b/src/corelib/plugin/qfactoryloader_p.h
@@ -45,17 +45,18 @@
// We mean it.
//
+#include "QtCore/qglobal.h"
+#ifndef QT_NO_QOBJECT
+
#include "QtCore/qobject.h"
#include "QtCore/qstringlist.h"
#include "QtCore/qjsonobject.h"
#include "QtCore/qmap.h"
#include "private/qlibrary_p.h"
-#ifndef QT_NO_LIBRARY
QT_BEGIN_NAMESPACE
class QFactoryLoaderPrivate;
-
class Q_CORE_EXPORT QFactoryLoader : public QObject
{
Q_OBJECT
@@ -65,21 +66,23 @@ public:
explicit QFactoryLoader(const char *iid,
const QString &suffix = QString(),
Qt::CaseSensitivity = Qt::CaseSensitive);
+
+#ifndef QT_NO_LIBRARY
~QFactoryLoader();
- QList<QJsonObject> metaData() const;
- QObject *instance(int index) const;
+ void update();
+ static void refreshAll();
#if defined(Q_OS_UNIX) && !defined (Q_OS_MAC)
QLibraryPrivate *library(const QString &key) const;
-#endif
+#endif // Q_OS_UNIX && !Q_OS_MAC
+#endif // !QT_NO_LIBRARY
QMultiMap<int, QString> keyMap() const;
int indexOf(const QString &needle) const;
- void update();
-
- static void refreshAll();
+ QList<QJsonObject> metaData() const;
+ QObject *instance(int index) const;
};
template <class PluginInterface, class FactoryInterface>
@@ -112,6 +115,6 @@ PluginInterface *qLoadPlugin1(const QFactoryLoader *loader,
QT_END_NAMESPACE
-#endif // QT_NO_LIBRARY
+#endif // QT_NO_QOBJECT
#endif // QFACTORYLOADER_P_H
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index 920e02ae5a..763f0fb1e9 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -302,7 +302,7 @@ static bool findPatternUnloaded(const QString &library, QLibraryPrivate *lib)
if (pos >= 0) {
if (hasMetaData) {
const char *data = filedata + pos;
- QJsonDocument doc = QLibraryPrivate::fromRawMetaData(data);
+ QJsonDocument doc = qJsonFromRawLibraryMetaData(data);
lib->metaData = doc.object();
if (qt_debug_component())
qWarning("Found metadata in lib %s, metadata=\n%s\n",
@@ -677,7 +677,7 @@ static bool qt_get_metadata(QtPluginQueryVerificationDataFunction pfn, QLibraryP
if (!szData)
return false;
- QJsonDocument doc = QLibraryPrivate::fromRawMetaData(szData);
+ QJsonDocument doc = qJsonFromRawLibraryMetaData(szData);
if (doc.isNull())
return false;
priv->metaData = doc.object();
diff --git a/src/corelib/plugin/qlibrary_p.h b/src/corelib/plugin/qlibrary_p.h
index ada90d7bfd..11b0cb1eb9 100644
--- a/src/corelib/plugin/qlibrary_p.h
+++ b/src/corelib/plugin/qlibrary_p.h
@@ -57,9 +57,20 @@
# include "QtCore/qt_windows.h"
#endif
+QT_BEGIN_NAMESPACE
+
+// Needed also in case of QT_NO_LIBRARY, for static plugin loading.
+inline QJsonDocument qJsonFromRawLibraryMetaData(const char *raw)
+{
+ raw += strlen("QTMETADATA ");
+ // the size of the embedded JSON object can be found 8 bytes into the data (see qjson_p.h),
+ // but doesn't include the size of the header (8 bytes)
+ QByteArray json(raw, qFromLittleEndian<uint>(*(const uint *)(raw + 8)) + 8);
+ return QJsonDocument::fromBinaryData(json);
+}
+
#ifndef QT_NO_LIBRARY
-QT_BEGIN_NAMESPACE
bool qt_debug_component();
@@ -104,14 +115,6 @@ public:
void updatePluginState();
bool isPlugin();
- static inline QJsonDocument fromRawMetaData(const char *raw) {
- raw += strlen("QTMETADATA ");
- // the size of the embedded JSON object can be found 8 bytes into the data (see qjson_p.h),
- // but doesn't include the size of the header (8 bytes)
- QByteArray json(raw, qFromLittleEndian<uint>(*(const uint *)(raw + 8)) + 8);
- return QJsonDocument::fromBinaryData(json);
- }
-
private:
explicit QLibraryPrivate(const QString &canonicalFileName, const QString &version, QLibrary::LoadHints loadHints);
~QLibraryPrivate();
@@ -132,8 +135,8 @@ private:
friend class QLibraryStore;
};
-QT_END_NAMESPACE
-
#endif // QT_NO_LIBRARY
+QT_END_NAMESPACE
+
#endif // QLIBRARY_P_H
diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp
index 24101be87b..8264a27842 100644
--- a/src/corelib/plugin/qpluginloader.cpp
+++ b/src/corelib/plugin/qpluginloader.cpp
@@ -41,10 +41,10 @@
#include "qdebug.h"
#include "qdir.h"
-#ifndef QT_NO_LIBRARY
-
QT_BEGIN_NAMESPACE
+#ifndef QT_NO_LIBRARY
+
/*!
\class QPluginLoader
\inmodule QtCore
@@ -382,9 +382,6 @@ QString QPluginLoader::errorString() const
return (!d || d->errorString.isEmpty()) ? tr("Unknown error") : d->errorString;
}
-typedef QVector<QStaticPlugin> StaticPluginList;
-Q_GLOBAL_STATIC(StaticPluginList, staticPluginList)
-
/*! \since 4.4
\property QPluginLoader::loadHints
@@ -413,6 +410,11 @@ QLibrary::LoadHints QPluginLoader::loadHints() const
return d ? d->loadHints() : QLibrary::LoadHints();
}
+#endif // QT_NO_LIBRARY
+
+typedef QVector<QStaticPlugin> StaticPluginList;
+Q_GLOBAL_STATIC(StaticPluginList, staticPluginList)
+
/*!
\relates QPluginLoader
\since 5.0
@@ -465,9 +467,8 @@ QVector<QStaticPlugin> QPluginLoader::staticPlugins()
*/
QJsonObject QStaticPlugin::metaData() const
{
- return QLibraryPrivate::fromRawMetaData(rawMetaData()).object();
+ return qJsonFromRawLibraryMetaData(rawMetaData()).object();
}
QT_END_NAMESPACE
-#endif // QT_NO_LIBRARY
diff --git a/src/corelib/plugin/qpluginloader.h b/src/corelib/plugin/qpluginloader.h
index 0ab25bbb07..5dc7d1b66c 100644
--- a/src/corelib/plugin/qpluginloader.h
+++ b/src/corelib/plugin/qpluginloader.h
@@ -37,10 +37,10 @@
#include <QtCore/qlibrary.h>
#include <QtCore/qplugin.h>
-#ifndef QT_NO_LIBRARY
-
QT_BEGIN_NAMESPACE
+#ifndef QT_NO_LIBRARY
+
class QLibraryPrivate;
class QJsonObject;
@@ -78,8 +78,17 @@ private:
Q_DISABLE_COPY(QPluginLoader)
};
-QT_END_NAMESPACE
+#else
+
+class Q_CORE_EXPORT QPluginLoader
+{
+public:
+ static QObjectList staticInstances();
+ static QVector<QStaticPlugin> staticPlugins();
+};
#endif // QT_NO_LIBRARY
+QT_END_NAMESPACE
+
#endif //QPLUGINLOADER_H
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index a9f361c205..c223c9de6c 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -1713,6 +1713,14 @@ QByteArray &QByteArray::prepend(const char *str, int len)
return *this;
}
+/*! \fn QByteArray &QByteArray::prepend(int count, char ch)
+
+ \overload
+ \since 5.7
+
+ Prepends \a count copies of character \a ch to this byte array.
+*/
+
/*!
\overload
@@ -1825,6 +1833,17 @@ QByteArray &QByteArray::append(const char *str, int len)
return *this;
}
+/*! \fn QByteArray &QByteArray::append(int count, char ch)
+
+ \overload
+ \since 5.7
+
+ Appends \a count copies of character \a ch to this byte
+ array and returns a reference to this byte array.
+
+ If \a count is negative or zero nothing is appended to the byte array.
+*/
+
/*!
\overload
@@ -1941,6 +1960,33 @@ QByteArray &QByteArray::insert(int i, char ch)
return qbytearray_insert(this, i, &ch, 1);
}
+/*! \fn QByteArray &QByteArray::insert(int i, int count, char ch)
+
+ \overload
+ \since 5.7
+
+ Inserts \a count copies of character \a ch at index position \a i in the
+ byte array.
+
+ If \a i is greater than size(), the array is first extended using resize().
+*/
+
+QByteArray &QByteArray::insert(int i, int count, char ch)
+{
+ if (i < 0 || count <= 0)
+ return *this;
+
+ int oldsize = size();
+ resize(qMax(i, oldsize) + count);
+ char *dst = d->data();
+ if (i > oldsize)
+ ::memset(dst + oldsize, 0x20, i - oldsize);
+ else if (i < oldsize)
+ ::memmove(dst + i + count, dst + i, oldsize - i);
+ ::memset(dst + i, ch, count);
+ return *this;
+}
+
/*!
Removes \a len bytes from the array, starting at index position \a
pos, and returns a reference to the array.
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index f0032227e8..6c79a603d3 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -255,21 +255,21 @@ public:
# define Q_REQUIRED_RESULT
# define Q_REQUIRED_RESULT_pushed
# endif
- QByteArray toLower() const & Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QByteArray toLower() const & Q_REQUIRED_RESULT
{ return toLower_helper(*this); }
- QByteArray toLower() && Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QByteArray toLower() && Q_REQUIRED_RESULT
{ return toLower_helper(*this); }
- QByteArray toUpper() const & Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QByteArray toUpper() const & Q_REQUIRED_RESULT
{ return toUpper_helper(*this); }
- QByteArray toUpper() && Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QByteArray toUpper() && Q_REQUIRED_RESULT
{ return toUpper_helper(*this); }
- QByteArray trimmed() const & Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QByteArray trimmed() const & Q_REQUIRED_RESULT
{ return trimmed_helper(*this); }
- QByteArray trimmed() && Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QByteArray trimmed() && Q_REQUIRED_RESULT
{ return trimmed_helper(*this); }
- QByteArray simplified() const & Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QByteArray simplified() const & Q_REQUIRED_RESULT
{ return simplified_helper(*this); }
- QByteArray simplified() && Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QByteArray simplified() && Q_REQUIRED_RESULT
{ return simplified_helper(*this); }
# ifdef Q_REQUIRED_RESULT_pushed
# pragma pop_macro("Q_REQUIRED_RESULT")
@@ -285,14 +285,17 @@ public:
QByteArray rightJustified(int width, char fill = ' ', bool truncate = false) const Q_REQUIRED_RESULT;
QByteArray &prepend(char c);
+ QByteArray &prepend(int count, char c);
QByteArray &prepend(const char *s);
QByteArray &prepend(const char *s, int len);
QByteArray &prepend(const QByteArray &a);
QByteArray &append(char c);
+ QByteArray &append(int count, char c);
QByteArray &append(const char *s);
QByteArray &append(const char *s, int len);
QByteArray &append(const QByteArray &a);
QByteArray &insert(int i, char c);
+ QByteArray &insert(int i, int count, char c);
QByteArray &insert(int i, const char *s);
QByteArray &insert(int i, const char *s, int len);
QByteArray &insert(int i, const QByteArray &a);
@@ -568,6 +571,10 @@ inline QByteArray::const_iterator QByteArray::cend() const
{ return d->data() + d->size; }
inline QByteArray::const_iterator QByteArray::constEnd() const
{ return d->data() + d->size; }
+inline QByteArray &QByteArray::append(int n, char ch)
+{ return insert(d->size, n, ch); }
+inline QByteArray &QByteArray::prepend(int n, char ch)
+{ return insert(0, n, ch); }
inline QByteArray &QByteArray::operator+=(char c)
{ return append(c); }
inline QByteArray &QByteArray::operator+=(const char *s)
diff --git a/src/corelib/tools/qregexp.h b/src/corelib/tools/qregexp.h
index f384e6c51f..9c68c194e0 100644
--- a/src/corelib/tools/qregexp.h
+++ b/src/corelib/tools/qregexp.h
@@ -68,10 +68,9 @@ public:
~QRegExp();
QRegExp &operator=(const QRegExp &rx);
#ifdef Q_COMPILER_RVALUE_REFS
- inline QRegExp &operator=(QRegExp &&other)
- { qSwap(priv,other.priv); return *this; }
+ QRegExp &operator=(QRegExp &&other) Q_DECL_NOTHROW { swap(other); return *this; }
#endif
- inline void swap(QRegExp &other) { qSwap(priv, other.priv); }
+ void swap(QRegExp &other) Q_DECL_NOTHROW { qSwap(priv, other.priv); }
bool operator==(const QRegExp &rx) const;
inline bool operator!=(const QRegExp &rx) const { return !operator==(rx); }
diff --git a/src/corelib/tools/qringbuffer.cpp b/src/corelib/tools/qringbuffer.cpp
index 85cfdaf129..e9b655c01e 100644
--- a/src/corelib/tools/qringbuffer.cpp
+++ b/src/corelib/tools/qringbuffer.cpp
@@ -65,6 +65,8 @@ const char *QRingBuffer::readPointerAtPosition(qint64 pos, qint64 &length) const
void QRingBuffer::free(qint64 bytes)
{
+ Q_ASSERT(bytes <= bufferSize);
+
while (bytes > 0) {
const qint64 blockSize = buffers.first().size() - head;
@@ -100,20 +102,25 @@ char *QRingBuffer::reserve(qint64 bytes)
if (bytes <= 0 || bytes >= MaxByteArraySize)
return 0;
- const qint64 newSize = bytes + tail;
- // if need buffer reallocation
- if (newSize > buffers.last().size()) {
- if (newSize > buffers.last().capacity() && (tail >= basicBlockSize
- || newSize >= MaxByteArraySize)) {
- // shrink this buffer to its current size
- buffers.last().resize(tail);
-
- // create a new QByteArray
- buffers.append(QByteArray());
- ++tailBuffer;
- tail = 0;
+ if (buffers.isEmpty()) {
+ buffers.append(QByteArray());
+ buffers.first().resize(qMax(basicBlockSize, int(bytes)));
+ } else {
+ const qint64 newSize = bytes + tail;
+ // if need buffer reallocation
+ if (newSize > buffers.last().size()) {
+ if (newSize > buffers.last().capacity() && (tail >= basicBlockSize
+ || newSize >= MaxByteArraySize)) {
+ // shrink this buffer to its current size
+ buffers.last().resize(tail);
+
+ // create a new QByteArray
+ buffers.append(QByteArray());
+ ++tailBuffer;
+ tail = 0;
+ }
+ buffers.last().resize(qMax(basicBlockSize, tail + int(bytes)));
}
- buffers.last().resize(qMax(basicBlockSize, tail + int(bytes)));
}
char *writePtr = buffers.last().data() + tail;
@@ -134,9 +141,13 @@ char *QRingBuffer::reserveFront(qint64 bytes)
return 0;
if (head < bytes) {
- buffers.first().remove(0, head);
- if (tailBuffer == 0)
- tail -= head;
+ if (buffers.isEmpty()) {
+ buffers.append(QByteArray());
+ } else {
+ buffers.first().remove(0, head);
+ if (tailBuffer == 0)
+ tail -= head;
+ }
head = qMax(basicBlockSize, int(bytes));
if (bufferSize == 0) {
@@ -155,6 +166,8 @@ char *QRingBuffer::reserveFront(qint64 bytes)
void QRingBuffer::chop(qint64 bytes)
{
+ Q_ASSERT(bytes <= bufferSize);
+
while (bytes > 0) {
if (tailBuffer == 0 || tail > bytes) {
// keep a single block around if it does not exceed
@@ -185,6 +198,9 @@ void QRingBuffer::chop(qint64 bytes)
void QRingBuffer::clear()
{
+ if (buffers.isEmpty())
+ return;
+
buffers.erase(buffers.begin() + 1, buffers.end());
buffers.first().clear();
@@ -193,20 +209,32 @@ void QRingBuffer::clear()
bufferSize = 0;
}
-qint64 QRingBuffer::indexOf(char c, qint64 maxLength) const
+qint64 QRingBuffer::indexOf(char c, qint64 maxLength, qint64 pos) const
{
- qint64 index = 0;
- qint64 j = head;
- for (int i = 0; index < maxLength && i < buffers.size(); ++i) {
- const char *ptr = buffers[i].constData() + j;
- j = qMin(index + (i == tailBuffer ? tail : buffers[i].size()) - j, maxLength);
-
- while (index < j) {
- if (*ptr++ == c)
- return index;
- ++index;
+ if (maxLength <= 0 || pos < 0)
+ return -1;
+
+ qint64 index = -(pos + head);
+ for (int i = 0; i < buffers.size(); ++i) {
+ const qint64 nextBlockIndex = qMin(index + (i == tailBuffer ? tail : buffers[i].size()),
+ maxLength);
+
+ if (nextBlockIndex > 0) {
+ const char *ptr = buffers[i].constData();
+ if (index < 0) {
+ ptr -= index;
+ index = 0;
+ }
+
+ const char *findPtr = reinterpret_cast<const char *>(memchr(ptr, c,
+ nextBlockIndex - index));
+ if (findPtr)
+ return qint64(findPtr - ptr) + index + pos;
+
+ if (nextBlockIndex == maxLength)
+ return -1;
}
- j = 0;
+ index = nextBlockIndex;
}
return -1;
}
@@ -288,7 +316,10 @@ qint64 QRingBuffer::peek(char *data, qint64 maxLength, qint64 pos) const
void QRingBuffer::append(const QByteArray &qba)
{
if (tail == 0) {
- buffers.last() = qba;
+ if (buffers.isEmpty())
+ buffers.append(qba);
+ else
+ buffers.last() = qba;
} else {
buffers.last().resize(tail);
buffers.append(qba);
diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h
index 68509a6a80..3a5ae1c4cc 100644
--- a/src/corelib/tools/qringbuffer_p.h
+++ b/src/corelib/tools/qringbuffer_p.h
@@ -54,9 +54,7 @@ class QRingBuffer
{
public:
explicit inline QRingBuffer(int growth = 4096) :
- head(0), tail(0), tailBuffer(0), basicBlockSize(growth), bufferSize(0) {
- buffers.append(QByteArray());
- }
+ head(0), tail(0), tailBuffer(0), basicBlockSize(growth), bufferSize(0) { }
inline qint64 nextDataBlockSize() const {
return (tailBuffer == 0 ? tail : buffers.first().size()) - head;
@@ -114,7 +112,7 @@ public:
Q_CORE_EXPORT void clear();
inline qint64 indexOf(char c) const { return indexOf(c, size()); }
- Q_CORE_EXPORT qint64 indexOf(char c, qint64 maxLength) const;
+ Q_CORE_EXPORT qint64 indexOf(char c, qint64 maxLength, qint64 pos = 0) const;
Q_CORE_EXPORT qint64 read(char *data, qint64 maxLength);
Q_CORE_EXPORT QByteArray read();
Q_CORE_EXPORT qint64 peek(char *data, qint64 maxLength, qint64 pos = 0) const;
diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp
index 86f4c6a268..4d30396cb6 100644
--- a/src/corelib/tools/qsharedpointer.cpp
+++ b/src/corelib/tools/qsharedpointer.cpp
@@ -1292,6 +1292,17 @@
compile. Use qSharedPointerConstCast to cast away the constness.
*/
+/*!
+ \fn QDebug operator<<(QDebug debug, const QSharedPointer<T> &ptr)
+ \relates QSharedPointer
+ \since 5.7
+
+ Writes the pointer tracked by \a ptr into the debug object \a debug for
+ debugging purposes.
+
+ \sa {Debugging Techniques}
+*/
+
#include <qset.h>
#include <qmutex.h>
diff --git a/src/corelib/tools/qsharedpointer.h b/src/corelib/tools/qsharedpointer.h
index 279ec36a28..56e13d500f 100644
--- a/src/corelib/tools/qsharedpointer.h
+++ b/src/corelib/tools/qsharedpointer.h
@@ -153,6 +153,8 @@ template <class X, class T> QSharedPointer<X> qSharedPointerObjectCast(const QWe
template <class X, class T> QWeakPointer<X> qWeakPointerCast(const QWeakPointer<T> &src);
+template <class T> QDebug operator<<(QDebug debug, const QSharedPointer<T> &ptr);
+
QT_END_NAMESPACE
#endif // Q_QDOC
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index 1323dd6b1c..ace6c5d093 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -55,6 +55,7 @@ QT_END_NAMESPACE
#include <new>
#include <QtCore/qatomic.h>
#include <QtCore/qobject.h> // for qobject_cast
+#include <QtCore/qdebug.h>
#if QT_DEPRECATED_SINCE(5, 5)
#include <QtCore/qhash.h>
#endif
@@ -305,7 +306,7 @@ public:
inline T &operator*() const { return *data(); }
inline T *operator->() const { return data(); }
- QSharedPointer() : value(Q_NULLPTR), d(Q_NULLPTR) { }
+ QSharedPointer() Q_DECL_NOTHROW : value(Q_NULLPTR), d(Q_NULLPTR) {}
~QSharedPointer() { deref(); }
inline explicit QSharedPointer(T *ptr) : value(ptr) // noexcept
@@ -315,22 +316,22 @@ public:
inline QSharedPointer(T *ptr, Deleter deleter) : value(ptr) // throws
{ internalConstruct(ptr, deleter); }
- inline QSharedPointer(const QSharedPointer &other) : value(other.value), d(other.d)
+ QSharedPointer(const QSharedPointer &other) Q_DECL_NOTHROW : value(other.value), d(other.d)
{ if (d) ref(); }
- inline QSharedPointer &operator=(const QSharedPointer &other)
+ QSharedPointer &operator=(const QSharedPointer &other) Q_DECL_NOTHROW
{
QSharedPointer copy(other);
swap(copy);
return *this;
}
#ifdef Q_COMPILER_RVALUE_REFS
- inline QSharedPointer(QSharedPointer &&other)
+ QSharedPointer(QSharedPointer &&other) Q_DECL_NOTHROW
: value(other.value), d(other.d)
{
other.d = Q_NULLPTR;
other.value = Q_NULLPTR;
}
- inline QSharedPointer &operator=(QSharedPointer &&other)
+ QSharedPointer &operator=(QSharedPointer &&other) Q_DECL_NOTHROW
{
QSharedPointer moved(std::move(other));
swap(moved);
@@ -596,7 +597,7 @@ public:
inline bool operator !() const { return isNull(); }
inline T *data() const { return d == Q_NULLPTR || d->strongref.load() == 0 ? Q_NULLPTR : value; }
- inline QWeakPointer() : d(Q_NULLPTR), value(Q_NULLPTR) { }
+ inline QWeakPointer() Q_DECL_NOTHROW : d(Q_NULLPTR), value(Q_NULLPTR) { }
inline ~QWeakPointer() { if (d && !d->weakref.deref()) delete d; }
#ifndef QT_NO_QOBJECT
@@ -614,15 +615,26 @@ public:
{ return *this = QWeakPointer(ptr); }
#endif
- inline QWeakPointer(const QWeakPointer &o) : d(o.d), value(o.value)
+ QWeakPointer(const QWeakPointer &other) Q_DECL_NOTHROW : d(other.d), value(other.value)
{ if (d) d->weakref.ref(); }
- inline QWeakPointer &operator=(const QWeakPointer &o)
+#ifdef Q_COMPILER_RVALUE_REFS
+ QWeakPointer(QWeakPointer &&other) Q_DECL_NOTHROW
+ : d(other.d), value(other.value)
{
- internalSet(o.d, o.value);
+ other.d = Q_NULLPTR;
+ other.value = Q_NULLPTR;
+ }
+ QWeakPointer &operator=(QWeakPointer &&other) Q_DECL_NOTHROW
+ { QWeakPointer moved(std::move(other)); swap(moved); return *this; }
+#endif
+ QWeakPointer &operator=(const QWeakPointer &other) Q_DECL_NOTHROW
+ {
+ QWeakPointer copy(other);
+ swap(copy);
return *this;
}
- inline void swap(QWeakPointer &other)
+ void swap(QWeakPointer &other) Q_DECL_NOTHROW
{
qSwap(this->d, other.d);
qSwap(this->value, other.value);
@@ -858,6 +870,16 @@ inline void qSwap(QSharedPointer<T> &p1, QSharedPointer<T> &p2)
p1.swap(p2);
}
+#ifndef QT_NO_DEBUG_STREAM
+template <class T>
+Q_INLINE_TEMPLATE QDebug operator<<(QDebug debug, const QSharedPointer<T> &ptr)
+{
+ QDebugStateSaver saver(debug);
+ debug.nospace() << "QSharedPointer(" << ptr.data() << ")";
+ return debug;
+}
+#endif
+
QT_END_NAMESPACE
namespace std {
template <class T>
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h
index 1e8b3420cf..96f5419af6 100644
--- a/src/corelib/tools/qsimd_p.h
+++ b/src/corelib/tools/qsimd_p.h
@@ -73,6 +73,7 @@
* SSE4_2 | x86 | I & C | I & C | I only |
* AVX | x86 | I & C | I & C | I & C |
* AVX2 | x86 | I & C | I & C | I only |
+ * AVX512xx | x86 | I & C | I & C | I only |
* I = intrinsics; C = code generation
*
* Code can use the following constructs to determine compiler support & status:
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 7829317d1f..47c4272389 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -386,25 +386,25 @@ public:
# define Q_REQUIRED_RESULT
# define Q_REQUIRED_RESULT_pushed
# endif
- QString toLower() const & Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QString toLower() const & Q_REQUIRED_RESULT
{ return toLower_helper(*this); }
- QString toLower() && Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QString toLower() && Q_REQUIRED_RESULT
{ return toLower_helper(*this); }
- QString toUpper() const & Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QString toUpper() const & Q_REQUIRED_RESULT
{ return toUpper_helper(*this); }
- QString toUpper() && Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QString toUpper() && Q_REQUIRED_RESULT
{ return toUpper_helper(*this); }
- QString toCaseFolded() const & Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QString toCaseFolded() const & Q_REQUIRED_RESULT
{ return toCaseFolded_helper(*this); }
- QString toCaseFolded() && Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QString toCaseFolded() && Q_REQUIRED_RESULT
{ return toCaseFolded_helper(*this); }
- QString trimmed() const & Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QString trimmed() const & Q_REQUIRED_RESULT
{ return trimmed_helper(*this); }
- QString trimmed() && Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QString trimmed() && Q_REQUIRED_RESULT
{ return trimmed_helper(*this); }
- QString simplified() const & Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QString simplified() const & Q_REQUIRED_RESULT
{ return simplified_helper(*this); }
- QString simplified() && Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QString simplified() && Q_REQUIRED_RESULT
{ return simplified_helper(*this); }
# ifdef Q_REQUIRED_RESULT_pushed
# pragma pop_macro("Q_REQUIRED_RESULT")
diff --git a/src/corelib/tools/qversionnumber.h b/src/corelib/tools/qversionnumber.h
index ebf1844f38..6a2718ca28 100644
--- a/src/corelib/tools/qversionnumber.h
+++ b/src/corelib/tools/qversionnumber.h
@@ -273,7 +273,7 @@ public:
Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber commonPrefix(const QVersionNumber &v1, const QVersionNumber &v2) Q_REQUIRED_RESULT;
Q_CORE_EXPORT QString toString() const Q_REQUIRED_RESULT;
- Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = 0) Q_REQUIRED_RESULT;
+ Q_CORE_EXPORT static Q_DECL_PURE_FUNCTION QVersionNumber fromString(const QString &string, int *suffixIndex = Q_NULLPTR) Q_REQUIRED_RESULT;
private:
#ifndef QT_NO_DATASTREAM
diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp
index e9196173ad..d0f5c06ee5 100644
--- a/src/dbus/qdbusconnection.cpp
+++ b/src/dbus/qdbusconnection.cpp
@@ -1177,8 +1177,8 @@ void QDBusConnectionPrivate::createBusService()
ref.deref(); // busService has increased the refcounting to us
// avoid cyclic refcounting
- QObject::connect(this, SIGNAL(callWithCallbackFailed(QDBusError,QDBusMessage)),
- busService, SIGNAL(callWithCallbackFailed(QDBusError,QDBusMessage)),
+ QObject::connect(this, &QDBusConnectionPrivate::callWithCallbackFailed,
+ busService, emit &QDBusConnectionInterface::callWithCallbackFailed,
Qt::QueuedConnection);
}
diff --git a/src/dbus/qdbusconnectioninterface.cpp b/src/dbus/qdbusconnectioninterface.cpp
index ff923ba282..9dc0b3f9bd 100644
--- a/src/dbus/qdbusconnectioninterface.cpp
+++ b/src/dbus/qdbusconnectioninterface.cpp
@@ -158,10 +158,10 @@ QDBusConnectionInterface::QDBusConnectionInterface(const QDBusConnection &connec
QDBusUtil::dbusPath(),
DBUS_INTERFACE_DBUS, connection, parent)
{
- connect(this, SIGNAL(NameAcquired(QString)), this, SIGNAL(serviceRegistered(QString)));
- connect(this, SIGNAL(NameLost(QString)), this, SIGNAL(serviceUnregistered(QString)));
- connect(this, SIGNAL(NameOwnerChanged(QString,QString,QString)),
- this, SIGNAL(serviceOwnerChanged(QString,QString,QString)));
+ connect(this, &QDBusConnectionInterface::NameAcquired, this, emit &QDBusConnectionInterface::serviceRegistered);
+ connect(this, &QDBusConnectionInterface::NameLost, this, emit &QDBusConnectionInterface::serviceUnregistered);
+ connect(this, &QDBusConnectionInterface::NameOwnerChanged,
+ this, emit &QDBusConnectionInterface::serviceOwnerChanged);
}
/*!
diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp
index c465706913..d3f899676b 100644
--- a/src/dbus/qdbusintegrator.cpp
+++ b/src/dbus/qdbusintegrator.cpp
@@ -208,14 +208,14 @@ static dbus_bool_t qDBusAddWatch(DBusWatch *watch, void *data)
watcher.watch = watch;
watcher.read = new QSocketNotifier(fd, QSocketNotifier::Read, d);
watcher.read->setEnabled(q_dbus_watch_get_enabled(watch));
- d->connect(watcher.read, SIGNAL(activated(int)), SLOT(socketRead(int)));
+ d->connect(watcher.read, &QSocketNotifier::activated, d, &QDBusConnectionPrivate::socketRead);
}
if (flags & DBUS_WATCH_WRITABLE) {
//qDebug("addWriteWatch %d", fd);
watcher.watch = watch;
watcher.write = new QSocketNotifier(fd, QSocketNotifier::Write, d);
watcher.write->setEnabled(q_dbus_watch_get_enabled(watch));
- d->connect(watcher.write, SIGNAL(activated(int)), SLOT(socketWrite(int)));
+ d->connect(watcher.write, &QSocketNotifier::activated, d, &QDBusConnectionPrivate::socketWrite);
}
d->watchers.insertMulti(fd, watcher);
@@ -1892,8 +1892,8 @@ QDBusMessage QDBusConnectionPrivate::sendWithReply(const QDBusMessage &message,
if (sendMode == QDBus::BlockWithGui) {
pcall->watcherHelper = new QDBusPendingCallWatcherHelper;
QEventLoop loop;
- loop.connect(pcall->watcherHelper, SIGNAL(reply(QDBusMessage)), SLOT(quit()));
- loop.connect(pcall->watcherHelper, SIGNAL(error(QDBusError,QDBusMessage)), SLOT(quit()));
+ loop.connect(pcall->watcherHelper, &QDBusPendingCallWatcherHelper::reply, &loop, &QEventLoop::quit);
+ loop.connect(pcall->watcherHelper, &QDBusPendingCallWatcherHelper::error, &loop, &QEventLoop::quit);
// enter the event loop and wait for a reply
loop.exec(QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents);
@@ -2078,7 +2078,7 @@ void QDBusConnectionPrivate::addSignalHook(const QString &key, const SignalHook
}
signalHooks.insertMulti(key, hook);
- connect(hook.obj, SIGNAL(destroyed(QObject*)), SLOT(objectDestroyed(QObject*)),
+ connect(hook.obj, &QObject::destroyed, this, &QDBusConnectionPrivate::objectDestroyed,
Qt::ConnectionType(Qt::BlockingQueuedConnection | Qt::UniqueConnection));
MatchRefCountHash::iterator mit = matchRefCounts.find(hook.matchRule);
@@ -2204,7 +2204,7 @@ QDBusConnectionPrivate::removeSignalHookNoLock(SignalHookHash::Iterator it)
void QDBusConnectionPrivate::registerObject(const ObjectTreeNode *node)
{
- connect(node->obj, SIGNAL(destroyed(QObject*)), SLOT(objectDestroyed(QObject*)),
+ connect(node->obj, &QObject::destroyed, this, &QDBusConnectionPrivate::objectDestroyed,
Qt::ConnectionType(Qt::BlockingQueuedConnection | Qt::UniqueConnection));
if (node->flags & (QDBusConnection::ExportAdaptors
diff --git a/src/gui/accessible/accessible.pri b/src/gui/accessible/accessible.pri
index 86ed4c3a71..b7f341d5b7 100644
--- a/src/gui/accessible/accessible.pri
+++ b/src/gui/accessible/accessible.pri
@@ -17,5 +17,9 @@ contains(QT_CONFIG, accessibility) {
HEADERS += accessible/qaccessiblebridge.h
SOURCES += accessible/qaccessiblebridge.cpp
- OBJECTIVE_SOURCES += accessible/qaccessiblecache_mac.mm
+ mac {
+ OBJECTIVE_SOURCES += accessible/qaccessiblecache_mac.mm
+
+ LIBS_PRIVATE += -framework Foundation
+ }
}
diff --git a/src/gui/gui.pro b/src/gui/gui.pro
index aa05d72a3d..55837bcf3b 100644
--- a/src/gui/gui.pro
+++ b/src/gui/gui.pro
@@ -33,7 +33,7 @@ testcocoon {
load(testcocoon)
}
-mac:!ios: LIBS_PRIVATE += -framework Cocoa
+osx: LIBS_PRIVATE += -framework AppKit
CONFIG += simd optimize_full
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 7a59adffb8..7ae081adfb 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -918,7 +918,7 @@ void QIcon::paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment,
*/
bool QIcon::isNull() const
{
- return !d;
+ return !d || d->engine->isNull();
}
/*!\internal
@@ -933,7 +933,12 @@ bool QIcon::isDetached() const
void QIcon::detach()
{
if (d) {
- if (d->ref.load() != 1) {
+ if (d->engine->isNull()) {
+ if (!d->ref.deref())
+ delete d;
+ d = 0;
+ return;
+ } else if (d->ref.load() != 1) {
QIconPrivate *x = new QIconPrivate;
x->engine = d->engine->clone();
if (!d->ref.deref())
@@ -957,11 +962,10 @@ void QIcon::addPixmap(const QPixmap &pixmap, Mode mode, State state)
{
if (pixmap.isNull())
return;
+ detach();
if (!d) {
d = new QIconPrivate;
d->engine = new QPixmapIconEngine;
- } else {
- detach();
}
d->engine->addPixmap(pixmap, mode, state);
}
@@ -1001,6 +1005,7 @@ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State
{
if (fileName.isEmpty())
return;
+ detach();
if (!d) {
#ifndef QT_NO_LIBRARY
QFileInfo info(fileName);
@@ -1023,8 +1028,6 @@ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State
d = new QIconPrivate;
d->engine = new QPixmapIconEngine;
}
- } else {
- detach();
}
d->engine->addFile(fileName, size, mode, state);
@@ -1140,8 +1143,7 @@ QString QIcon::themeName()
\since 4.6
Returns the QIcon corresponding to \a name in the current
- icon theme. If no such icon is found in the current theme
- \a fallback is returned instead.
+ icon theme.
The latest version of the freedesktop icon specification and naming
specification can be obtained here:
@@ -1155,19 +1157,18 @@ QString QIcon::themeName()
\snippet code/src_gui_image_qicon.cpp 3
- Or if you want to provide a guaranteed fallback for platforms that
- do not support theme icons, you can use the second argument:
-
- \snippet code/src_gui_image_qicon.cpp 4
-
\note By default, only X11 will support themed icons. In order to
use themed icons on Mac and Windows, you will have to bundle a
compliant theme in one of your themeSearchPaths() and set the
appropriate themeName().
+ \note Qt will make use of GTK's icon-theme.cache if present to speed up
+ the lookup. These caches can be generated using gtk-update-icon-cache:
+ \l{https://developer.gnome.org/gtk3/stable/gtk-update-icon-cache.html}.
+
\sa themeName(), setThemeName(), themeSearchPaths()
*/
-QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback)
+QIcon QIcon::fromTheme(const QString &name)
{
QIcon icon;
@@ -1183,7 +1184,26 @@ QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback)
qtIconCache()->insert(name, cachedIcon);
}
- if (qApp && icon.availableSizes().isEmpty())
+ return icon;
+}
+
+/*!
+ \overload
+
+ Returns the QIcon corresponding to \a name in the current
+ icon theme. If no such icon is found in the current theme
+ \a fallback is returned instead.
+
+ If you want to provide a guaranteed fallback for platforms that
+ do not support theme icons, you can use the second argument:
+
+ \snippet code/src_gui_image_qicon.cpp 4
+*/
+QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback)
+{
+ QIcon icon = fromTheme(name);
+
+ if (icon.isNull() || icon.availableSizes().isEmpty())
return fallback;
return icon;
diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h
index ccddf69101..329ae3deb3 100644
--- a/src/gui/image/qicon.h
+++ b/src/gui/image/qicon.h
@@ -105,7 +105,8 @@ public:
void setIsMask(bool isMask);
bool isMask() const;
- static QIcon fromTheme(const QString &name, const QIcon &fallback = QIcon());
+ static QIcon fromTheme(const QString &name);
+ static QIcon fromTheme(const QString &name, const QIcon &fallback);
static bool hasThemeIcon(const QString &name);
static QStringList themeSearchPaths();
diff --git a/src/gui/image/qiconengine.cpp b/src/gui/image/qiconengine.cpp
index c09933d45f..7411dbb054 100644
--- a/src/gui/image/qiconengine.cpp
+++ b/src/gui/image/qiconengine.cpp
@@ -150,6 +150,11 @@ void QIconEngine::addFile(const QString &/*fileName*/, const QSize &/*size*/, QI
icon, for example when instantiating an icon using
QIcon::fromTheme().
+ \value IsNullHook Allow to query if this engine represents a null
+ icon. The \a data argument of the virtual_hook() is a pointer to a
+ bool that can be set to true if the icon is null. This enum value
+ was added in Qt 5.7.
+
\sa virtual_hook()
*/
@@ -283,4 +288,16 @@ QString QIconEngine::iconName() const
return name;
}
+/*!
+ \since 5.7
+
+ Returns true if this icon engine represent a null QIcon.
+ */
+bool QIconEngine::isNull() const
+{
+ bool isNull = false;
+ const_cast<QIconEngine *>(this)->virtual_hook(QIconEngine::IsNullHook, &isNull);
+ return isNull;
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/image/qiconengine.h b/src/gui/image/qiconengine.h
index 9977113054..6c45cd216f 100644
--- a/src/gui/image/qiconengine.h
+++ b/src/gui/image/qiconengine.h
@@ -58,7 +58,7 @@ public:
virtual bool read(QDataStream &in);
virtual bool write(QDataStream &out) const;
- enum IconEngineHook { AvailableSizesHook = 1, IconNameHook };
+ enum IconEngineHook { AvailableSizesHook = 1, IconNameHook, IsNullHook };
struct AvailableSizesArgument
{
@@ -71,6 +71,7 @@ public:
QIcon::State state = QIcon::Off) const;
virtual QString iconName() const;
+ bool isNull() const; // ### Qt6 make virtual
virtual void virtual_hook(int id, void *data);
};
diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp
index 3ead72dfbb..ecce7f9967 100644
--- a/src/gui/image/qiconloader.cpp
+++ b/src/gui/image/qiconloader.cpp
@@ -155,6 +155,141 @@ QStringList QIconLoader::themeSearchPaths() const
return m_iconDirs;
}
+/*!
+ \class QIconCacheGtkReader
+ \internal
+ Helper class that reads and looks up into the icon-theme.cache generated with
+ gtk-update-icon-cache. If at any point we detect a corruption in the file
+ (because the offsets point at wrong locations for example), the reader
+ is marked as invalid.
+*/
+class QIconCacheGtkReader
+{
+public:
+ explicit QIconCacheGtkReader(const QString &themeDir);
+ QVector<const char *> lookup(const QString &);
+ bool isValid() const { return m_isValid; }
+private:
+ QFile m_file;
+ const unsigned char *m_data;
+ quint64 m_size;
+ bool m_isValid;
+
+ quint16 read16(uint offset)
+ {
+ if (offset > m_size - 2 || (offset & 0x1)) {
+ m_isValid = false;
+ return 0;
+ }
+ return m_data[offset+1] | m_data[offset] << 8;
+ }
+ quint32 read32(uint offset)
+ {
+ if (offset > m_size - 4 || (offset & 0x3)) {
+ m_isValid = false;
+ return 0;
+ }
+ return m_data[offset+3] | m_data[offset+2] << 8
+ | m_data[offset+1] << 16 | m_data[offset] << 24;
+ }
+};
+
+
+QIconCacheGtkReader::QIconCacheGtkReader(const QString &dirName)
+ : m_isValid(false)
+{
+ QFileInfo info(dirName + QLatin1Literal("/icon-theme.cache"));
+ if (!info.exists() || info.lastModified() < QFileInfo(dirName).lastModified())
+ return;
+ m_file.setFileName(info.absoluteFilePath());
+ if (!m_file.open(QFile::ReadOnly))
+ return;
+ m_size = m_file.size();
+ m_data = m_file.map(0, m_size);
+ if (!m_data)
+ return;
+ if (read16(0) != 1) // VERSION_MAJOR
+ return;
+
+ m_isValid = true;
+
+ // Check that all the directories are older than the cache
+ auto lastModified = info.lastModified();
+ quint32 dirListOffset = read32(8);
+ quint32 dirListLen = read32(dirListOffset);
+ for (uint i = 0; i < dirListLen; ++i) {
+ quint32 offset = read32(dirListOffset + 4 + 4 * i);
+ if (!m_isValid || offset >= m_size || lastModified < QFileInfo(dirName + QLatin1Char('/')
+ + QString::fromUtf8(reinterpret_cast<const char*>(m_data + offset))).lastModified()) {
+ m_isValid = false;
+ return;
+ }
+ }
+}
+
+static quint32 icon_name_hash(const char *p)
+{
+ quint32 h = static_cast<signed char>(*p);
+ for (p += 1; *p != '\0'; p++)
+ h = (h << 5) - h + *p;
+ return h;
+}
+
+/*! \internal
+ lookup the icon name and return the list of subdirectories in which an icon
+ with this name is present. The char* are pointers to the mapped data.
+ For example, this would return { "32x32/apps", "24x24/apps" , ... }
+ */
+QVector<const char *> QIconCacheGtkReader::lookup(const QString &name)
+{
+ QVector<const char *> ret;
+ if (!isValid())
+ return ret;
+
+ QByteArray nameUtf8 = name.toUtf8();
+ quint32 hash = icon_name_hash(nameUtf8);
+
+ quint32 hashOffset = read32(4);
+ quint32 hashBucketCount = read32(hashOffset);
+
+ if (!isValid() || hashBucketCount == 0) {
+ m_isValid = false;
+ return ret;
+ }
+
+ quint32 bucketIndex = hash % hashBucketCount;
+ quint32 bucketOffset = read32(hashOffset + 4 + bucketIndex * 4);
+ while (bucketOffset > 0 && bucketOffset <= m_size - 12) {
+ quint32 nameOff = read32(bucketOffset + 4);
+ if (nameOff < m_size && strcmp(reinterpret_cast<const char*>(m_data + nameOff), nameUtf8) == 0) {
+ quint32 dirListOffset = read32(8);
+ quint32 dirListLen = read32(dirListOffset);
+
+ quint32 listOffset = read32(bucketOffset+8);
+ quint32 listLen = read32(listOffset);
+
+ if (!m_isValid || listOffset + 4 + 8 * listLen > m_size) {
+ m_isValid = false;
+ return ret;
+ }
+
+ ret.reserve(listLen);
+ for (uint j = 0; j < listLen && m_isValid; ++j) {
+ quint32 dirIndex = read16(listOffset + 4 + 8 * j);
+ quint32 o = read32(dirListOffset + 4 + dirIndex*4);
+ if (!m_isValid || dirIndex >= dirListLen || o >= m_size) {
+ m_isValid = false;
+ return ret;
+ }
+ ret.append(reinterpret_cast<const char*>(m_data) + o);
+ }
+ return ret;
+ }
+ bucketOffset = read32(bucketOffset);
+ }
+ return ret;
+}
+
QIconTheme::QIconTheme(const QString &themeName)
: m_valid(false)
{
@@ -166,8 +301,10 @@ QIconTheme::QIconTheme(const QString &themeName)
QString themeDir = iconDir.path() + QLatin1Char('/') + themeName;
QFileInfo themeDirInfo(themeDir);
- if (themeDirInfo.isDir())
+ if (themeDirInfo.isDir()) {
m_contentDirs << themeDir;
+ m_gtkCaches << QSharedPointer<QIconCacheGtkReader>::create(themeDir);
+ }
if (!m_valid) {
themeIndex.setFileName(themeDir + QLatin1String("/index.theme"));
@@ -257,7 +394,6 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
}
const QStringList contentDirs = theme.contentDirs();
- const QVector<QIconDirInfo> subDirs = theme.keyList();
QString iconNameFallback = iconName;
@@ -268,6 +404,29 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
// Add all relevant files
for (int i = 0; i < contentDirs.size(); ++i) {
+ QVector<QIconDirInfo> subDirs = theme.keyList();
+
+ // Try to reduce the amount of subDirs by looking in the GTK+ cache in order to save
+ // a massive amount of file stat (especially if the icon is not there)
+ auto cache = theme.m_gtkCaches.at(i);
+ if (cache->isValid()) {
+ auto result = cache->lookup(iconNameFallback);
+ if (cache->isValid()) {
+ const QVector<QIconDirInfo> subDirsCopy = subDirs;
+ subDirs.clear();
+ subDirs.reserve(result.count());
+ foreach (const char *s, result) {
+ QString path = QString::fromUtf8(s);
+ auto it = std::find_if(subDirsCopy.cbegin(), subDirsCopy.cend(),
+ [&](const QIconDirInfo &info) {
+ return info.path == path; } );
+ if (it != subDirsCopy.cend()) {
+ subDirs.append(*it);
+ }
+ }
+ }
+ }
+
QString contentDir = contentDirs.at(i) + QLatin1Char('/');
for (int j = 0; j < subDirs.size() ; ++j) {
const QIconDirInfo &dirInfo = subDirs.at(j);
@@ -587,6 +746,11 @@ void QIconLoaderEngine::virtual_hook(int id, void *data)
name = m_info.iconName;
}
break;
+ case QIconEngine::IsNullHook:
+ {
+ *reinterpret_cast<bool*>(data) = m_info.entries.isEmpty();
+ }
+ break;
default:
QIconEngine::virtual_hook(id, data);
}
diff --git a/src/gui/image/qiconloader_p.h b/src/gui/image/qiconloader_p.h
index ccf0a9d438..193154e44e 100644
--- a/src/gui/image/qiconloader_p.h
+++ b/src/gui/image/qiconloader_p.h
@@ -139,6 +139,8 @@ private:
friend class QIconLoader;
};
+class QIconCacheGtkReader;
+
class QIconTheme
{
public:
@@ -148,12 +150,13 @@ public:
QVector<QIconDirInfo> keyList() { return m_keyList; }
QStringList contentDirs() { return m_contentDirs; }
bool isValid() { return m_valid; }
-
private:
QStringList m_contentDirs;
QVector<QIconDirInfo> m_keyList;
QStringList m_parents;
bool m_valid;
+public:
+ QVector<QSharedPointer<QIconCacheGtkReader>> m_gtkCaches;
};
class Q_GUI_EXPORT QIconLoader
diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h
index 888c7beb32..9d8e3efcc4 100644
--- a/src/gui/image/qimage.h
+++ b/src/gui/image/qimage.h
@@ -168,9 +168,9 @@ public:
Format format() const;
#if defined(Q_COMPILER_REF_QUALIFIERS) && !defined(QT_COMPILING_QIMAGE_COMPAT_CPP)
- QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) const & Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) const & Q_REQUIRED_RESULT
{ return convertToFormat_helper(f, flags); }
- QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) && Q_REQUIRED_RESULT
+ Q_ALWAYS_INLINE QImage convertToFormat(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor) && Q_REQUIRED_RESULT
{
if (convertToFormat_inplace(f, flags))
return std::move(*this);
diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp
index de37e0ab44..2df813367d 100644
--- a/src/gui/image/qpixmapcache.cpp
+++ b/src/gui/image/qpixmapcache.cpp
@@ -156,6 +156,16 @@ bool QPixmapCache::Key::operator ==(const Key &key) const
*/
/*!
+ Returns \c true if there is a cached pixmap associated with this key.
+ Otherwise, if pixmap was flushed, the key is no longer valid.
+ \since 5.7
+*/
+bool QPixmapCache::Key::isValid() const Q_DECL_NOTHROW
+{
+ return d && d->isValid;
+}
+
+/*!
\internal
*/
QPixmapCache::Key &QPixmapCache::Key::operator =(const Key &other)
diff --git a/src/gui/image/qpixmapcache.h b/src/gui/image/qpixmapcache.h
index 37a0588e06..ca18f299a7 100644
--- a/src/gui/image/qpixmapcache.h
+++ b/src/gui/image/qpixmapcache.h
@@ -59,6 +59,7 @@ public:
Key &operator =(const Key &other);
void swap(Key &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
+ bool isValid() const Q_DECL_NOTHROW;
private:
KeyData *d;
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 0bb21752bc..233b9ef3f7 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -37,6 +37,7 @@
#include "qpa/qplatformintegration.h"
#include "qpa/qplatformdrag.h"
#include "private/qevent_p.h"
+#include "qfile.h"
#include "qmetaobject.h"
#include "qmimedata.h"
#include "private/qdnd_p.h"
@@ -3948,9 +3949,11 @@ QDebug operator<<(QDebug dbg, const QEvent *e)
QtDebugUtils::formatQEnum(dbg, static_cast<const QApplicationStateChangeEvent *>(e)->applicationState());
dbg << ')';
break;
+# ifndef QT_NO_CONTEXTMENU
case QEvent::ContextMenu:
dbg << "QContextMenuEvent(" << static_cast<const QContextMenuEvent *>(e)->pos() << ')';
break;
+# endif // !QT_NO_CONTEXTMENU
# ifndef QT_NO_TABLETEVENT
case QEvent::TabletEnterProximity:
case QEvent::TabletLeaveProximity:
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index b90fce97e0..66e650c42d 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -35,20 +35,19 @@
#define QEVENT_H
#include <QtGui/qwindowdefs.h>
-#include <QtCore/qobject.h>
#include <QtGui/qregion.h>
#include <QtCore/qnamespace.h>
#include <QtCore/qstring.h>
#include <QtGui/qkeysequence.h>
#include <QtCore/qcoreevent.h>
#include <QtCore/qvariant.h>
-#include <QtCore/qmap.h>
+#include <QtCore/qmap.h> // ### Qt 6: Remove
#include <QtCore/qvector.h>
-#include <QtCore/qset.h>
+#include <QtCore/qset.h> // ### Qt 6: Remove
#include <QtCore/qurl.h>
-#include <QtCore/qfile.h>
+#include <QtCore/qfile.h> // ### Qt 6: Replace by <qiodevice.h> and forward declare QFile
#include <QtGui/qvector2d.h>
-#include <QtGui/qtouchdevice.h>
+#include <QtGui/qtouchdevice.h> // ### Qt 6: Replace by forward declaration
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qgenericplugin.cpp b/src/gui/kernel/qgenericplugin.cpp
index 47f3ea5811..ae423b93e3 100644
--- a/src/gui/kernel/qgenericplugin.cpp
+++ b/src/gui/kernel/qgenericplugin.cpp
@@ -33,8 +33,6 @@
#include "qgenericplugin.h"
-#ifndef QT_NO_LIBRARY
-
QT_BEGIN_NAMESPACE
/*!
@@ -90,5 +88,3 @@ QGenericPlugin::~QGenericPlugin()
*/
QT_END_NAMESPACE
-
-#endif // QT_NO_LIBRARY
diff --git a/src/gui/kernel/qgenericplugin.h b/src/gui/kernel/qgenericplugin.h
index 03c1df7fba..21ae97f045 100644
--- a/src/gui/kernel/qgenericplugin.h
+++ b/src/gui/kernel/qgenericplugin.h
@@ -39,9 +39,6 @@
QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_LIBRARY
-
#define QGenericPluginFactoryInterface_iid "org.qt-project.Qt.QGenericPluginFactoryInterface"
class Q_GUI_EXPORT QGenericPlugin : public QObject
@@ -54,8 +51,6 @@ public:
virtual QObject* create(const QString& name, const QString &spec) = 0;
};
-#endif // QT_NO_LIBRARY
-
QT_END_NAMESPACE
#endif // QGENERICPLUGIN_H
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 3f50ab8688..b717585b54 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -37,6 +37,7 @@
#include <qpa/qplatformintegrationfactory_p.h>
#include "private/qevent_p.h"
#include "qfont.h"
+#include "qtouchdevice.h"
#include <qpa/qplatformfontdatabase.h>
#include <qpa/qplatformwindow.h>
#include <qpa/qplatformnativeinterface.h>
@@ -146,6 +147,7 @@ QIcon *QGuiApplicationPrivate::app_icon = 0;
QString *QGuiApplicationPrivate::platform_name = 0;
QString *QGuiApplicationPrivate::displayName = 0;
+QString *QGuiApplicationPrivate::desktopFileName = 0;
QPalette *QGuiApplicationPrivate::app_pal = 0; // default application palette
@@ -606,6 +608,8 @@ QGuiApplication::~QGuiApplication()
QGuiApplicationPrivate::platform_name = 0;
delete QGuiApplicationPrivate::displayName;
QGuiApplicationPrivate::displayName = 0;
+ delete QGuiApplicationPrivate::desktopFileName;
+ QGuiApplicationPrivate::desktopFileName = 0;
}
QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags)
@@ -647,6 +651,34 @@ QString QGuiApplication::applicationDisplayName()
}
/*!
+ \property QGuiApplication::desktopFileName
+ \brief the base name of the desktop entry for this application
+ \since 5.7
+
+ This is the file name, without the full path, of the desktop entry
+ that represents this application according to the freedesktop desktop
+ entry specification.
+
+ This property gives a precise indication of what desktop entry represents
+ the application and it is needed by the windowing system to retrieve
+ such information without resorting to imprecise heuristics.
+
+ The latest version of the freedesktop desktop entry specification can be obtained
+ \l{http://standards.freedesktop.org/desktop-entry-spec/latest/}{here}.
+*/
+void QGuiApplication::setDesktopFileName(const QString &name)
+{
+ if (!QGuiApplicationPrivate::desktopFileName)
+ QGuiApplicationPrivate::desktopFileName = new QString;
+ *QGuiApplicationPrivate::desktopFileName = name;
+}
+
+QString QGuiApplication::desktopFileName()
+{
+ return QGuiApplicationPrivate::desktopFileName ? *QGuiApplicationPrivate::desktopFileName : QString();
+}
+
+/*!
Returns the most recently shown modal window. If no modal windows are
visible, this function returns zero.
diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h
index d995387d66..a773122d3e 100644
--- a/src/gui/kernel/qguiapplication.h
+++ b/src/gui/kernel/qguiapplication.h
@@ -67,6 +67,7 @@ class Q_GUI_EXPORT QGuiApplication : public QCoreApplication
Q_OBJECT
Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon)
Q_PROPERTY(QString applicationDisplayName READ applicationDisplayName WRITE setApplicationDisplayName)
+ Q_PROPERTY(QString desktopFileName READ desktopFileName WRITE setDesktopFileName)
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged)
Q_PROPERTY(QString platformName READ platformName STORED false)
Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed WRITE setQuitOnLastWindowClosed)
@@ -83,6 +84,9 @@ public:
static void setApplicationDisplayName(const QString &name);
static QString applicationDisplayName();
+ static void setDesktopFileName(const QString &name);
+ static QString desktopFileName();
+
static QWindowList allWindows();
static QWindowList topLevelWindows();
static QWindow *topLevelAt(const QPoint &pos);
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index 0559442049..6dc8735f86 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_p.h
@@ -183,6 +183,7 @@ public:
static QIcon *app_icon;
static QString *platform_name;
static QString *displayName;
+ static QString *desktopFileName;
QWindowList modalWindowList;
static void showModalWindow(QWindow *window);
diff --git a/src/gui/kernel/qinputdevicemanager_p.h b/src/gui/kernel/qinputdevicemanager_p.h
index d64793c23c..4c24b1bc93 100644
--- a/src/gui/kernel/qinputdevicemanager_p.h
+++ b/src/gui/kernel/qinputdevicemanager_p.h
@@ -61,7 +61,8 @@ public:
DeviceTypeUnknown,
DeviceTypePointer,
DeviceTypeKeyboard,
- DeviceTypeTouch
+ DeviceTypeTouch,
+ DeviceTypeTablet
};
QInputDeviceManager(QObject *parent = 0);
diff --git a/src/gui/kernel/qplatformintegrationfactory.cpp b/src/gui/kernel/qplatformintegrationfactory.cpp
index 5a1fb3ca83..d109ceb2f0 100644
--- a/src/gui/kernel/qplatformintegrationfactory.cpp
+++ b/src/gui/kernel/qplatformintegrationfactory.cpp
@@ -42,11 +42,13 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QPlatformIntegrationFactoryInterface_iid, QLatin1String("/platforms"), Qt::CaseInsensitive))
+
+#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
(QPlatformIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
+#endif // !QT_NO_LIBRARY
static inline QPlatformIntegration *loadIntegration(QFactoryLoader *loader, const QString &key, const QStringList &parameters, int &argc, char ** argv)
{
@@ -59,8 +61,6 @@ static inline QPlatformIntegration *loadIntegration(QFactoryLoader *loader, cons
return 0;
}
-#endif // !QT_NO_LIBRARY
-
QPlatformIntegration *QPlatformIntegrationFactory::create(const QString &platform, const QStringList &paramList, int &argc, char **argv, const QString &platformPluginPath)
{
#ifndef QT_NO_LIBRARY
@@ -70,16 +70,10 @@ QPlatformIntegration *QPlatformIntegrationFactory::create(const QString &platfor
if (QPlatformIntegration *ret = loadIntegration(directLoader(), platform, paramList, argc, argv))
return ret;
}
- if (QPlatformIntegration *ret = loadIntegration(loader(), platform, paramList, argc, argv))
- return ret;
#else
- Q_UNUSED(platform);
- Q_UNUSED(paramList);
- Q_UNUSED(argc);
- Q_UNUSED(argv);
Q_UNUSED(platformPluginPath);
#endif
- return 0;
+ return loadIntegration(loader(), platform, paramList, argc, argv);
}
/*!
diff --git a/src/gui/opengl/qtriangulator_p.h b/src/gui/opengl/qtriangulator_p.h
index 0ab3f7496c..4e13e5bdd0 100644
--- a/src/gui/opengl/qtriangulator_p.h
+++ b/src/gui/opengl/qtriangulator_p.h
@@ -88,12 +88,13 @@ public:
inline QVertexIndexVector &operator = (const QVertexIndexVector &other)
{
- if (t == UnsignedInt)
- indices32 = other.indices32;
- else
- indices16 = other.indices16;
+ if (t == UnsignedInt)
+ indices32 = other.indices32;
+ else
+ indices16 = other.indices16;
- return *this;
+ t = other.t;
+ return *this;
}
private:
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index 0fd5f510c7..0e8771b0ac 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -44,6 +44,7 @@
#include <qpa/qplatformfontdatabase.h>
#include <QtCore/qendian.h>
+#include <QtCore/qfile.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index f8f41bb53d..a09ed2c040 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -1140,6 +1140,7 @@ void QTextHtmlParserNode::setListStyle(const QVector<QCss::Value> &cssValues)
for (int i = 0; i < cssValues.count(); ++i) {
if (cssValues.at(i).type == QCss::Value::KnownIdentifier) {
switch (static_cast<QCss::KnownValue>(cssValues.at(i).variant.toInt())) {
+ case QCss::Value_None: hasOwnListStyle = true; listStyle = QTextListFormat::ListStyleUndefined; break;
case QCss::Value_Disc: hasOwnListStyle = true; listStyle = QTextListFormat::ListDisc; break;
case QCss::Value_Square: hasOwnListStyle = true; listStyle = QTextListFormat::ListSquare; break;
case QCss::Value_Circle: hasOwnListStyle = true; listStyle = QTextListFormat::ListCircle; break;
@@ -1495,6 +1496,8 @@ void QTextHtmlParser::applyAttributes(const QStringList &attributes)
node->listStyle = QTextListFormat::ListDisc;
else if (value == QLatin1String("circle"))
node->listStyle = QTextListFormat::ListCircle;
+ else if (value == QLatin1String("none"))
+ node->listStyle = QTextListFormat::ListStyleUndefined;
}
}
break;
diff --git a/src/gui/text/qtextimagehandler.cpp b/src/gui/text/qtextimagehandler.cpp
index 1ba2cb31ca..54d7fe1738 100644
--- a/src/gui/text/qtextimagehandler.cpp
+++ b/src/gui/text/qtextimagehandler.cpp
@@ -38,6 +38,7 @@
#include <qtextformat.h>
#include <qpainter.h>
#include <qdebug.h>
+#include <qfile.h>
#include <private/qtextengine_p.h>
#include <qpalette.h>
#include <qthread.h>
diff --git a/src/network/access/access.pri b/src/network/access/access.pri
index e829d52cbe..42c7c80f3b 100644
--- a/src/network/access/access.pri
+++ b/src/network/access/access.pri
@@ -78,6 +78,8 @@ ios {
OBJECTIVE_SOURCES += \
access/qnetworkreplynsurlconnectionimpl.mm
+
+ LIBS_PRIVATE += -framework Foundation
}
include($$PWD/../../3rdparty/zlib_dependency.pri)
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 8d9975dcdb..08ccff83fa 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -722,7 +722,7 @@ bool QAbstractSocketPrivate::canReadNotification()
}
}
- // only emit readyRead() when not recursing, and only if there is data available
+ // Only emit readyRead() if there is data available.
bool hasData = newBytes > 0
#ifndef QT_NO_UDPSOCKET
|| (!isBuffered && socketType != QAbstractSocket::TcpSocket && socketEngine && socketEngine->hasPendingDatagrams())
@@ -730,11 +730,8 @@ bool QAbstractSocketPrivate::canReadNotification()
|| (!isBuffered && socketType == QAbstractSocket::TcpSocket && socketEngine)
;
- if (!emittedReadyRead && hasData) {
- QScopedValueRollback<bool> r(emittedReadyRead);
- emittedReadyRead = true;
- emit q->readyRead();
- }
+ if (hasData)
+ emitReadyRead();
// If we were closed as a result of the readyRead() signal,
// return.
@@ -792,12 +789,12 @@ void QAbstractSocketPrivate::canCloseNotification()
// then occur when we read from the socket again and fail
// in canReadNotification or by the manually created
// closeNotification below.
- emit q->readyRead();
+ emitReadyRead();
QMetaObject::invokeMethod(socketEngine, "closeNotification", Qt::QueuedConnection);
}
} else if (socketType == QAbstractSocket::TcpSocket && socketEngine) {
- emit q->readyRead();
+ emitReadyRead();
}
}
@@ -817,8 +814,7 @@ bool QAbstractSocketPrivate::canWriteNotification()
#if defined (QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocketPrivate::canWriteNotification() flushing");
#endif
- qint64 tmp = writeBuffer.size();
- flush();
+ bool dataWasWritten = writeToSocket();
if (socketEngine) {
#if defined (Q_OS_WIN)
@@ -830,7 +826,7 @@ bool QAbstractSocketPrivate::canWriteNotification()
#endif
}
- return (writeBuffer.size() < tmp);
+ return dataWasWritten;
}
/*! \internal
@@ -852,21 +848,20 @@ void QAbstractSocketPrivate::connectionNotification()
/*! \internal
- Writes pending data in the write buffers to the socket. The
- function writes as much as it can without blocking.
+ Writes one pending data block in the write buffer to the socket.
It is usually invoked by canWriteNotification after one or more
calls to write().
Emits bytesWritten().
*/
-bool QAbstractSocketPrivate::flush()
+bool QAbstractSocketPrivate::writeToSocket()
{
Q_Q(QAbstractSocket);
if (!socketEngine || !socketEngine->isValid() || (writeBuffer.isEmpty()
&& socketEngine->bytesToWrite() == 0)) {
#if defined (QABSTRACTSOCKET_DEBUG)
- qDebug("QAbstractSocketPrivate::flush() nothing to do: valid ? %s, writeBuffer.isEmpty() ? %s",
+ qDebug("QAbstractSocketPrivate::writeToSocket() nothing to do: valid ? %s, writeBuffer.isEmpty() ? %s",
(socketEngine && socketEngine->isValid()) ? "yes" : "no", writeBuffer.isEmpty() ? "yes" : "no");
#endif
@@ -884,7 +879,8 @@ bool QAbstractSocketPrivate::flush()
qint64 written = socketEngine->write(ptr, nextSize);
if (written < 0) {
#if defined (QABSTRACTSOCKET_DEBUG)
- qDebug() << "QAbstractSocketPrivate::flush() write error, aborting." << socketEngine->errorString();
+ qDebug() << "QAbstractSocketPrivate::writeToSocket() write error, aborting."
+ << socketEngine->errorString();
#endif
setErrorAndEmit(socketEngine->error(), socketEngine->errorString());
// an unexpected error so close the socket.
@@ -893,7 +889,7 @@ bool QAbstractSocketPrivate::flush()
}
#if defined (QABSTRACTSOCKET_DEBUG)
- qDebug("QAbstractSocketPrivate::flush() %lld bytes written to the network",
+ qDebug("QAbstractSocketPrivate::writeToSocket() %lld bytes written to the network",
written);
#endif
@@ -914,7 +910,23 @@ bool QAbstractSocketPrivate::flush()
if (state == QAbstractSocket::ClosingState)
q->disconnectFromHost();
- return true;
+ return written > 0;
+}
+
+/*! \internal
+
+ Writes pending data in the write buffers to the socket. The function
+ writes as much as it can without blocking. If any data was written,
+ this function returns true; otherwise false is returned.
+*/
+bool QAbstractSocketPrivate::flush()
+{
+ bool dataWasWritten = false;
+
+ while (!writeBuffer.isEmpty() && writeToSocket())
+ dataWasWritten = true;
+
+ return dataWasWritten;
}
#ifndef QT_NO_NETWORKPROXY
@@ -1248,6 +1260,7 @@ void QAbstractSocketPrivate::_q_forceDisconnect()
*/
bool QAbstractSocketPrivate::readFromSocket()
{
+ Q_Q(QAbstractSocket);
// Find how many bytes we can read from the socket layer.
qint64 bytesToRead = socketEngine->bytesAvailable();
if (bytesToRead == 0) {
@@ -1276,7 +1289,7 @@ bool QAbstractSocketPrivate::readFromSocket()
buffer.chop(bytesToRead);
return true;
}
- buffer.chop(bytesToRead - (readBytes < 0 ? qint64(0) : readBytes));
+ buffer.chop(bytesToRead - ((readBytes < 0 || !q->isReadable()) ? qint64(0) : readBytes));
#if defined(QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocketPrivate::readFromSocket() got %lld bytes, buffer size = %lld",
readBytes, buffer.size());
@@ -1297,6 +1310,21 @@ bool QAbstractSocketPrivate::readFromSocket()
/*! \internal
+ Prevents from the recursive readyRead() emission.
+*/
+void QAbstractSocketPrivate::emitReadyRead()
+{
+ Q_Q(QAbstractSocket);
+ // Only emit readyRead() when not recursing.
+ if (!emittedReadyRead) {
+ QScopedValueRollback<bool> r(emittedReadyRead);
+ emittedReadyRead = true;
+ emit q->readyRead();
+ }
+}
+
+/*! \internal
+
Sets up the internal state after the connection has succeeded.
*/
void QAbstractSocketPrivate::fetchConnectionParameters()
@@ -2374,7 +2402,7 @@ bool QAbstractSocket::isSequential() const
*/
bool QAbstractSocket::atEnd() const
{
- return QIODevice::atEnd() && (!isOpen() || d_func()->buffer.isEmpty());
+ return QIODevice::atEnd();
}
/*!
diff --git a/src/network/socket/qabstractsocket.h b/src/network/socket/qabstractsocket.h
index 23f0d26cbd..f8edc74a24 100644
--- a/src/network/socket/qabstractsocket.h
+++ b/src/network/socket/qabstractsocket.h
@@ -176,7 +176,7 @@ public:
// from QIODevice
void close() Q_DECL_OVERRIDE;
bool isSequential() const Q_DECL_OVERRIDE;
- bool atEnd() const Q_DECL_OVERRIDE;
+ bool atEnd() const Q_DECL_OVERRIDE; // ### Qt6: remove me
bool flush();
// for synchronous access
diff --git a/src/network/socket/qabstractsocket_p.h b/src/network/socket/qabstractsocket_p.h
index a905625b19..ba129b48df 100644
--- a/src/network/socket/qabstractsocket_p.h
+++ b/src/network/socket/qabstractsocket_p.h
@@ -135,6 +135,8 @@ public:
void fetchConnectionParameters();
void setupSocketNotifiers();
bool readFromSocket();
+ bool writeToSocket();
+ void emitReadyRead();
void setError(QAbstractSocket::SocketError errorCode, const QString &errorString);
void setErrorAndEmit(QAbstractSocket::SocketError errorCode, const QString &errorString);
diff --git a/src/platformsupport/cglconvenience/cglconvenience.mm b/src/platformsupport/cglconvenience/cglconvenience.mm
index 6b0a91e13f..b20f324442 100644
--- a/src/platformsupport/cglconvenience/cglconvenience.mm
+++ b/src/platformsupport/cglconvenience/cglconvenience.mm
@@ -34,7 +34,7 @@
#include "cglconvenience_p.h"
#include <QtCore/qglobal.h>
#include <QtCore/private/qcore_mac_p.h>
-#include <Cocoa/Cocoa.h>
+#include <AppKit/AppKit.h>
#include <QVector>
void (*qcgl_getProcAddress(const QByteArray &procName))()
diff --git a/src/platformsupport/cglconvenience/cglconvenience.pri b/src/platformsupport/cglconvenience/cglconvenience.pri
index 0e86ddb208..1de38bbd08 100644
--- a/src/platformsupport/cglconvenience/cglconvenience.pri
+++ b/src/platformsupport/cglconvenience/cglconvenience.pri
@@ -1,4 +1,4 @@
-mac:!ios {
+osx {
INCLUDEPATH += $$PWD
HEADERS += \
@@ -7,5 +7,5 @@ mac:!ios {
OBJECTIVE_SOURCES += \
$$PWD/cglconvenience.mm
- LIBS_PRIVATE += -framework Cocoa -framework OpenGL
+ LIBS_PRIVATE += -framework AppKit -framework OpenGL
}
diff --git a/src/platformsupport/clipboard/qmacmime.mm b/src/platformsupport/clipboard/qmacmime.mm
index ffa548bf83..5fec32c650 100644
--- a/src/platformsupport/clipboard/qmacmime.mm
+++ b/src/platformsupport/clipboard/qmacmime.mm
@@ -32,10 +32,13 @@
****************************************************************************/
#include <QtCore/qsystemdetection.h>
+
+#if defined(Q_OS_OSX)
+#import <AppKit/AppKit.h>
+#endif
+
#if defined(Q_OS_IOS)
#import <UIKit/UIKit.h>
-#elif defined(Q_OS_OSX)
-#import <Cocoa/Cocoa.h>
#endif
#include "qmacmime_p.h"
diff --git a/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp b/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp
index f285e61a9f..334eb51a86 100644
--- a/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp
+++ b/src/platformsupport/devicediscovery/qdevicediscovery_udev.cpp
@@ -185,11 +185,11 @@ void QDeviceDiscoveryUDev::handleUDevNotification()
// if we cannot determine a type, walk up the device tree
if (!checkDeviceType(dev)) {
// does not increase the refcount
- dev = udev_device_get_parent_with_subsystem_devtype(dev, subsystem, 0);
- if (!dev)
+ struct udev_device *parent_dev = udev_device_get_parent_with_subsystem_devtype(dev, subsystem, 0);
+ if (!parent_dev)
goto cleanup;
- if (!checkDeviceType(dev))
+ if (!checkDeviceType(parent_dev))
goto cleanup;
}
diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
index 022bc8bec2..8e7a393613 100644
--- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
@@ -36,6 +36,7 @@
#include <QtCore/QList>
#include <QtCore/QElapsedTimer>
+#include <QtCore/QFile>
#include <qpa/qplatformnativeinterface.h>
#include <qpa/qplatformscreen.h>
diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
index 0af779097c..a87443cc85 100644
--- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
+++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
@@ -35,8 +35,8 @@
#include <sys/param.h>
-#if defined(Q_OS_MACX)
-#import <Cocoa/Cocoa.h>
+#if defined(Q_OS_OSX)
+#import <AppKit/AppKit.h>
#import <IOKit/graphics/IOGraphicsLib.h>
#elif defined(Q_OS_IOS)
#import <UIKit/UIFont.h>
diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
index 06751de0ef..d467a62abd 100644
--- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
+++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp
@@ -35,6 +35,7 @@
#include <qplatformdefs.h>
+#include <QFile>
#include <QSocketNotifier>
#include <QStringList>
#include <QCoreApplication>
diff --git a/src/platformsupport/input/evdevtablet/evdevtablet.pri b/src/platformsupport/input/evdevtablet/evdevtablet.pri
index 5ace0df61d..fb9489353c 100644
--- a/src/platformsupport/input/evdevtablet/evdevtablet.pri
+++ b/src/platformsupport/input/evdevtablet/evdevtablet.pri
@@ -1,8 +1,10 @@
HEADERS += \
- $$PWD/qevdevtablet_p.h
+ $$PWD/qevdevtablethandler_p.h \
+ $$PWD/qevdevtabletmanager_p.h
SOURCES += \
- $$PWD/qevdevtablet.cpp
+ $$PWD/qevdevtablethandler.cpp \
+ $$PWD/qevdevtabletmanager.cpp
contains(QT_CONFIG, libudev) {
LIBS_PRIVATE += $$QMAKE_LIBS_LIBUDEV
diff --git a/src/platformsupport/input/evdevtablet/qevdevtablet.cpp b/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp
index c6f952c64d..aa87340112 100644
--- a/src/platformsupport/input/evdevtablet/qevdevtablet.cpp
+++ b/src/platformsupport/input/evdevtablet/qevdevtablethandler.cpp
@@ -31,14 +31,14 @@
**
****************************************************************************/
-#include "qevdevtablet_p.h"
-#include <qpa/qwindowsysteminterface.h>
+#include "qevdevtablethandler_p.h"
+
#include <QStringList>
#include <QSocketNotifier>
#include <QGuiApplication>
#include <QLoggingCategory>
#include <QtCore/private/qcore_unix_p.h>
-#include <QtPlatformSupport/private/qdevicediscovery_p.h>
+#include <qpa/qwindowsysteminterface.h>
#include <linux/input.h>
QT_BEGIN_NAMESPACE
@@ -49,16 +49,11 @@ class QEvdevTabletData
{
public:
QEvdevTabletData(QEvdevTabletHandler *q_ptr);
- bool queryLimits();
- void testGrab();
+
void processInputEvent(input_event *ev);
- void reportProximityEnter();
- void reportProximityLeave();
void report();
QEvdevTabletHandler *q;
- QSocketNotifier *notifier;
- int fd;
int lastEventType;
QString devName;
struct {
@@ -73,57 +68,13 @@ public:
};
QEvdevTabletData::QEvdevTabletData(QEvdevTabletHandler *q_ptr)
- : q(q_ptr), notifier(0), fd(-1), lastEventType(0)
+ : q(q_ptr), lastEventType(0)
{
memset(&minValues, 0, sizeof(minValues));
memset(&maxValues, 0, sizeof(maxValues));
memset(&state, 0, sizeof(state));
}
-bool QEvdevTabletData::queryLimits()
-{
- bool ok = true;
- input_absinfo absInfo;
- memset(&absInfo, 0, sizeof(input_absinfo));
- ok &= ioctl(fd, EVIOCGABS(ABS_X), &absInfo) >= 0;
- if (ok) {
- minValues.x = absInfo.minimum;
- maxValues.x = absInfo.maximum;
- qCDebug(qLcEvdevTablet, "evdevtablet: min X: %d max X: %d", minValues.x, maxValues.x);
- }
- ok &= ioctl(fd, EVIOCGABS(ABS_Y), &absInfo) >= 0;
- if (ok) {
- minValues.y = absInfo.minimum;
- maxValues.y = absInfo.maximum;
- qCDebug(qLcEvdevTablet, "evdevtablet: min Y: %d max Y: %d", minValues.y, maxValues.y);
- }
- if (ioctl(fd, EVIOCGABS(ABS_PRESSURE), &absInfo) >= 0) {
- minValues.p = absInfo.minimum;
- maxValues.p = absInfo.maximum;
- qCDebug(qLcEvdevTablet, "evdevtablet: min pressure: %d max pressure: %d", minValues.p, maxValues.p);
- }
- if (ioctl(fd, EVIOCGABS(ABS_DISTANCE), &absInfo) >= 0) {
- minValues.d = absInfo.minimum;
- maxValues.d = absInfo.maximum;
- qCDebug(qLcEvdevTablet, "evdevtablet: min distance: %d max distance: %d", minValues.d, maxValues.d);
- }
- char name[128];
- if (ioctl(fd, EVIOCGNAME(sizeof(name) - 1), name) >= 0) {
- devName = QString::fromLocal8Bit(name);
- qCDebug(qLcEvdevTablet, "evdevtablet: device name: %s", name);
- }
- return ok;
-}
-
-void QEvdevTabletData::testGrab()
-{
- bool grabSuccess = !ioctl(fd, EVIOCGRAB, (void *) 1);
- if (grabSuccess)
- ioctl(fd, EVIOCGRAB, (void *) 0);
- else
- qWarning("evdevtablet: ERROR: The device is grabbed by another process. No events will be read.");
-}
-
void QEvdevTabletData::processInputEvent(input_event *ev)
{
if (ev->type == EV_ABS) {
@@ -167,20 +118,10 @@ void QEvdevTabletData::processInputEvent(input_event *ev)
lastEventType = ev->type;
}
-void QEvdevTabletData::reportProximityEnter()
-{
- QWindowSystemInterface::handleTabletEnterProximityEvent(QTabletEvent::Stylus, state.tool, 1);
-}
-
-void QEvdevTabletData::reportProximityLeave()
-{
- QWindowSystemInterface::handleTabletLeaveProximityEvent(QTabletEvent::Stylus, state.tool, 1);
-}
-
void QEvdevTabletData::report()
{
if (!state.lastReportTool && state.tool)
- reportProximityEnter();
+ QWindowSystemInterface::handleTabletEnterProximityEvent(QTabletEvent::Stylus, state.tool, q->deviceId());
qreal nx = (state.x - minValues.x) / qreal(maxValues.x - minValues.x);
qreal ny = (state.y - minValues.y) / qreal(maxValues.y - minValues.y);
@@ -194,16 +135,17 @@ void QEvdevTabletData::report()
pointer = state.lastReportTool;
}
- qreal pressure = (state.p - minValues.p) / qreal(maxValues.p - minValues.p);
+ int pressureRange = maxValues.p - minValues.p;
+ qreal pressure = pressureRange ? (state.p - minValues.p) / qreal(pressureRange) : qreal(1);
if (state.down || state.lastReportDown) {
QWindowSystemInterface::handleTabletEvent(0, state.down, QPointF(), globalPos,
QTabletEvent::Stylus, pointer,
- pressure, 0, 0, 0, 0, 0, 1, qGuiApp->keyboardModifiers());
+ pressure, 0, 0, 0, 0, 0, q->deviceId(), qGuiApp->keyboardModifiers());
}
if (state.lastReportTool && !state.tool)
- reportProximityLeave();
+ QWindowSystemInterface::handleTabletLeaveProximityEvent(QTabletEvent::Stylus, state.tool, q->deviceId());
state.lastReportDown = state.down;
state.lastReportTool = state.tool;
@@ -211,69 +153,104 @@ void QEvdevTabletData::report()
}
-QEvdevTabletHandler::QEvdevTabletHandler(const QString &spec, QObject *parent)
- : QObject(parent), d(0)
+QEvdevTabletHandler::QEvdevTabletHandler(const QString &device, const QString &spec, QObject *parent)
+ : QObject(parent), m_fd(-1), m_device(device), m_notifier(0), d(0)
{
+ Q_UNUSED(spec)
+
setObjectName(QLatin1String("Evdev Tablet Handler"));
- d = new QEvdevTabletData(this);
- QString dev;
- QStringList args = spec.split(QLatin1Char(':'));
- for (int i = 0; i < args.count(); ++i) {
- if (args.at(i).startsWith(QLatin1String("/dev/"))) {
- dev = args.at(i);
- break;
- }
- }
- if (dev.isEmpty()) {
- QScopedPointer<QDeviceDiscovery> deviceDiscovery(
- QDeviceDiscovery::create(QDeviceDiscovery::Device_Tablet, this));
- if (deviceDiscovery) {
- QStringList devices = deviceDiscovery->scanConnectedDevices();
- if (!devices.isEmpty())
- dev = devices.at(0);
- }
- }
- if (!dev.isEmpty()) {
- qCDebug(qLcEvdevTablet, "evdevtablet: using %s", qPrintable(dev));
- d->fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);
- if (d->fd >= 0) {
- d->testGrab();
- if (d->queryLimits()) {
- d->notifier = new QSocketNotifier(d->fd, QSocketNotifier::Read, this);
- connect(d->notifier, SIGNAL(activated(int)), this, SLOT(readData()));
- }
- } else {
- qErrnoWarning(errno, "evdevtablet: Cannot open input device");
- }
+
+ qCDebug(qLcEvdevTablet, "evdevtablet: using %s", qPrintable(device));
+
+ m_fd = QT_OPEN(device.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);
+ if (m_fd < 0) {
+ qErrnoWarning(errno, "evdevtablet: Cannot open input device %s", qPrintable(device));
+ return;
}
+
+ bool grabSuccess = !ioctl(m_fd, EVIOCGRAB, (void *) 1);
+ if (grabSuccess)
+ ioctl(m_fd, EVIOCGRAB, (void *) 0);
+ else
+ qWarning("evdevtablet: %s: The device is grabbed by another process. No events will be read.", qPrintable(device));
+
+ d = new QEvdevTabletData(this);
+ if (!queryLimits())
+ qWarning("evdevtablet: %s: Unset or invalid ABS limits. Behavior will be unspecified.", qPrintable(device));
+
+ m_notifier = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
+ connect(m_notifier, &QSocketNotifier::activated, this, &QEvdevTabletHandler::readData);
}
QEvdevTabletHandler::~QEvdevTabletHandler()
{
- delete d->notifier;
- if (d->fd >= 0)
- QT_CLOSE(d->fd);
+ if (m_fd >= 0)
+ QT_CLOSE(m_fd);
delete d;
}
+qint64 QEvdevTabletHandler::deviceId() const
+{
+ return m_fd;
+}
+
+bool QEvdevTabletHandler::queryLimits()
+{
+ bool ok = true;
+ input_absinfo absInfo;
+ memset(&absInfo, 0, sizeof(input_absinfo));
+ ok &= ioctl(m_fd, EVIOCGABS(ABS_X), &absInfo) >= 0;
+ if (ok) {
+ d->minValues.x = absInfo.minimum;
+ d->maxValues.x = absInfo.maximum;
+ qCDebug(qLcEvdevTablet, "evdevtablet: %s: min X: %d max X: %d", qPrintable(m_device),
+ d->minValues.x, d->maxValues.x);
+ }
+ ok &= ioctl(m_fd, EVIOCGABS(ABS_Y), &absInfo) >= 0;
+ if (ok) {
+ d->minValues.y = absInfo.minimum;
+ d->maxValues.y = absInfo.maximum;
+ qCDebug(qLcEvdevTablet, "evdevtablet: %s: min Y: %d max Y: %d", qPrintable(m_device),
+ d->minValues.y, d->maxValues.y);
+ }
+ if (ioctl(m_fd, EVIOCGABS(ABS_PRESSURE), &absInfo) >= 0) {
+ d->minValues.p = absInfo.minimum;
+ d->maxValues.p = absInfo.maximum;
+ qCDebug(qLcEvdevTablet, "evdevtablet: %s: min pressure: %d max pressure: %d", qPrintable(m_device),
+ d->minValues.p, d->maxValues.p);
+ }
+ if (ioctl(m_fd, EVIOCGABS(ABS_DISTANCE), &absInfo) >= 0) {
+ d->minValues.d = absInfo.minimum;
+ d->maxValues.d = absInfo.maximum;
+ qCDebug(qLcEvdevTablet, "evdevtablet: %s: min distance: %d max distance: %d", qPrintable(m_device),
+ d->minValues.d, d->maxValues.d);
+ }
+ char name[128];
+ if (ioctl(m_fd, EVIOCGNAME(sizeof(name) - 1), name) >= 0) {
+ d->devName = QString::fromLocal8Bit(name);
+ qCDebug(qLcEvdevTablet, "evdevtablet: %s: device name: %s", qPrintable(m_device), name);
+ }
+ return ok;
+}
+
void QEvdevTabletHandler::readData()
{
static input_event buffer[32];
int n = 0;
for (; ;) {
- int result = QT_READ(d->fd, reinterpret_cast<char*>(buffer) + n, sizeof(buffer) - n);
+ int result = QT_READ(m_fd, reinterpret_cast<char*>(buffer) + n, sizeof(buffer) - n);
if (!result) {
- qWarning("evdevtablet: Got EOF from input device");
+ qWarning("evdevtablet: %s: Got EOF from input device", qPrintable(m_device));
return;
} else if (result < 0) {
if (errno != EINTR && errno != EAGAIN) {
- qErrnoWarning(errno, "evdevtablet: Could not read from input device");
+ qErrnoWarning(errno, "evdevtablet: %s: Could not read from input device", qPrintable(m_device));
if (errno == ENODEV) { // device got disconnected -> stop reading
- delete d->notifier;
- d->notifier = 0;
- QT_CLOSE(d->fd);
- d->fd = -1;
+ delete m_notifier;
+ m_notifier = 0;
+ QT_CLOSE(m_fd);
+ m_fd = -1;
}
return;
}
@@ -291,8 +268,8 @@ void QEvdevTabletHandler::readData()
}
-QEvdevTabletHandlerThread::QEvdevTabletHandlerThread(const QString &spec, QObject *parent)
- : QDaemonThread(parent), m_spec(spec), m_handler(0)
+QEvdevTabletHandlerThread::QEvdevTabletHandlerThread(const QString &device, const QString &spec, QObject *parent)
+ : QDaemonThread(parent), m_device(device), m_spec(spec), m_handler(0)
{
start();
}
@@ -305,7 +282,7 @@ QEvdevTabletHandlerThread::~QEvdevTabletHandlerThread()
void QEvdevTabletHandlerThread::run()
{
- m_handler = new QEvdevTabletHandler(m_spec);
+ m_handler = new QEvdevTabletHandler(m_device, m_spec);
exec();
delete m_handler;
m_handler = 0;
diff --git a/src/platformsupport/input/evdevtablet/qevdevtablet_p.h b/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h
index f546f9a88a..4a9b2bab34 100644
--- a/src/platformsupport/input/evdevtablet/qevdevtablet_p.h
+++ b/src/platformsupport/input/evdevtablet/qevdevtablethandler_p.h
@@ -31,8 +31,8 @@
**
****************************************************************************/
-#ifndef QEVDEVTABLET_P_H
-#define QEVDEVTABLET_P_H
+#ifndef QEVDEVTABLETHANDLER_P_H
+#define QEVDEVTABLETHANDLER_P_H
//
// W A R N I N G
@@ -52,6 +52,7 @@
QT_BEGIN_NAMESPACE
+class QSocketNotifier;
class QEvdevTabletData;
class QEvdevTabletHandler : public QObject
@@ -59,29 +60,37 @@ class QEvdevTabletHandler : public QObject
Q_OBJECT
public:
- explicit QEvdevTabletHandler(const QString &spec = QString(), QObject *parent = 0);
+ explicit QEvdevTabletHandler(const QString &device, const QString &spec = QString(), QObject *parent = 0);
~QEvdevTabletHandler();
+ qint64 deviceId() const;
+
private slots:
void readData();
private:
+ bool queryLimits();
+
+ int m_fd;
+ QString m_device;
+ QSocketNotifier *m_notifier;
QEvdevTabletData *d;
};
class QEvdevTabletHandlerThread : public QDaemonThread
{
public:
- explicit QEvdevTabletHandlerThread(const QString &spec, QObject *parent = 0);
+ explicit QEvdevTabletHandlerThread(const QString &device, const QString &spec, QObject *parent = 0);
~QEvdevTabletHandlerThread();
void run() Q_DECL_OVERRIDE;
QEvdevTabletHandler *handler() { return m_handler; }
private:
+ QString m_device;
QString m_spec;
QEvdevTabletHandler *m_handler;
};
QT_END_NAMESPACE
-#endif // QEVDEVTABLET_P_H
+#endif // QEVDEVTABLETHANDLER_P_H
diff --git a/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp b/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp
new file mode 100644
index 0000000000..05fd6e655c
--- /dev/null
+++ b/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the plugins module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qevdevtabletmanager_p.h"
+#include "qevdevtablethandler_p.h"
+
+#include <QStringList>
+#include <QGuiApplication>
+#include <QLoggingCategory>
+#include <QtPlatformSupport/private/qdevicediscovery_p.h>
+#include <private/qguiapplication_p.h>
+#include <private/qinputdevicemanager_p_p.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_DECLARE_LOGGING_CATEGORY(qLcEvdevTablet)
+
+QEvdevTabletManager::QEvdevTabletManager(const QString &key, const QString &specification, QObject *parent)
+ : QObject(parent)
+{
+ Q_UNUSED(key);
+
+ if (qEnvironmentVariableIsSet("QT_QPA_EVDEV_DEBUG"))
+ const_cast<QLoggingCategory &>(qLcEvdevTablet()).setEnabled(QtDebugMsg, true);
+
+ QString spec = QString::fromLocal8Bit(qgetenv("QT_QPA_EVDEV_TABLET_PARAMETERS"));
+
+ if (spec.isEmpty())
+ spec = specification;
+
+ QStringList args = spec.split(QLatin1Char(':'));
+ QStringList devices;
+
+ foreach (const QString &arg, args) {
+ if (arg.startsWith(QLatin1String("/dev/"))) {
+ devices.append(arg);
+ args.removeAll(arg);
+ }
+ }
+
+ // build new specification without /dev/ elements
+ m_spec = args.join(QLatin1Char(':'));
+
+ foreach (const QString &device, devices)
+ addDevice(device);
+
+ // when no devices specified, use device discovery to scan and monitor
+ if (devices.isEmpty()) {
+ qCDebug(qLcEvdevTablet) << "evdevtablet: Using device discovery";
+ m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Tablet, this);
+ if (m_deviceDiscovery) {
+ QStringList devices = m_deviceDiscovery->scanConnectedDevices();
+ foreach (const QString &device, devices)
+ addDevice(device);
+ connect(m_deviceDiscovery, SIGNAL(deviceDetected(QString)), this, SLOT(addDevice(QString)));
+ connect(m_deviceDiscovery, SIGNAL(deviceRemoved(QString)), this, SLOT(removeDevice(QString)));
+ }
+ }
+}
+
+QEvdevTabletManager::~QEvdevTabletManager()
+{
+ qDeleteAll(m_activeDevices);
+}
+
+void QEvdevTabletManager::addDevice(const QString &deviceNode)
+{
+ qCDebug(qLcEvdevTablet) << "Adding device at" << deviceNode;
+ QEvdevTabletHandlerThread *handler;
+ handler = new QEvdevTabletHandlerThread(deviceNode, m_spec);
+ if (handler) {
+ m_activeDevices.insert(deviceNode, handler);
+ QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
+ QInputDeviceManager::DeviceTypeTablet, m_activeDevices.count());
+ } else {
+ qWarning("evdevtablet: Failed to open tablet device %s", qPrintable(deviceNode));
+ }
+}
+
+void QEvdevTabletManager::removeDevice(const QString &deviceNode)
+{
+ if (m_activeDevices.contains(deviceNode)) {
+ qCDebug(qLcEvdevTablet) << "Removing device at" << deviceNode;
+ QEvdevTabletHandlerThread *handler = m_activeDevices.value(deviceNode);
+ m_activeDevices.remove(deviceNode);
+ QInputDeviceManagerPrivate::get(QGuiApplicationPrivate::inputDeviceManager())->setDeviceCount(
+ QInputDeviceManager::DeviceTypeTablet, m_activeDevices.count());
+ delete handler;
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/widgets/styles/qgtkglobal_p.h b/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h
index 7d729d7fc0..893ff03fa7 100644
--- a/src/widgets/styles/qgtkglobal_p.h
+++ b/src/platformsupport/input/evdevtablet/qevdevtabletmanager_p.h
@@ -3,7 +3,7 @@
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
-** This file is part of the QtWidgets module of the Qt Toolkit.
+** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
@@ -31,8 +31,8 @@
**
****************************************************************************/
-#ifndef QGTKGLOBAL_P_H
-#define QGTKGLOBAL_P_H
+#ifndef QEVDEVTABLETMANAGER_P_H
+#define QEVDEVTABLETMANAGER_P_H
//
// W A R N I N G
@@ -45,38 +45,32 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
-#if !defined(QT_NO_STYLE_GTK)
+#include <QObject>
+#include <QHash>
+#include <QSocketNotifier>
-#undef signals // Collides with GTK symbols
-#include <gtk/gtk.h>
-
-typedef unsigned long XID;
+QT_BEGIN_NAMESPACE
-#undef GTK_OBJECT_FLAGS
-#define GTK_OBJECT_FLAGS(obj)(((GtkObject*)(obj))->flags)
+class QDeviceDiscovery;
+class QEvdevTabletHandlerThread;
-#define QLS(x) QLatin1String(x)
+class QEvdevTabletManager : public QObject
+{
+ Q_OBJECT
+public:
+ QEvdevTabletManager(const QString &key, const QString &spec, QObject *parent = 0);
+ ~QEvdevTabletManager();
-QT_BEGIN_NAMESPACE
+private slots:
+ void addDevice(const QString &deviceNode);
+ void removeDevice(const QString &deviceNode);
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
-# define QT_RED 3
-# define QT_GREEN 2
-# define QT_BLUE 1
-# define QT_ALPHA 0
-#else
-# define QT_RED 0
-# define QT_GREEN 1
-# define QT_BLUE 2
-# define QT_ALPHA 3
-#endif
-# define GTK_RED 2
-# define GTK_GREEN 1
-# define GTK_BLUE 0
-# define GTK_ALPHA 3
+private:
+ QString m_spec;
+ QDeviceDiscovery *m_deviceDiscovery;
+ QHash<QString, QEvdevTabletHandlerThread *> m_activeDevices;
+};
QT_END_NAMESPACE
-#endif // !QT_NO_STYLE_GTK
-#endif // QGTKGLOBAL_P_H
+#endif // QEVDEVTABLETMANAGER_P_H
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
index ad348cc083..dc40f728e1 100644
--- a/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
+++ b/src/platformsupport/input/evdevtouch/qevdevtouchhandler.cpp
@@ -36,6 +36,7 @@
#include <QHash>
#include <QSocketNotifier>
#include <QGuiApplication>
+#include <QTouchDevice>
#include <QLoggingCategory>
#include <QtCore/private/qcore_unix_p.h>
#include <QtGui/private/qhighdpiscaling_p.h>
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
index a369747a64..26d815d7ff 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
@@ -615,7 +615,7 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
return QVariant(QGenericUnixTheme::xdgIconThemePaths());
case QPlatformTheme::StyleNames: {
QStringList styleNames;
- styleNames << QStringLiteral("GTK+") << QStringLiteral("fusion") << QStringLiteral("windows");
+ styleNames << QStringLiteral("fusion") << QStringLiteral("windows");
return QVariant(styleNames);
}
case QPlatformTheme::KeyboardScheme:
diff --git a/src/plugins/generic/evdevtablet/main.cpp b/src/plugins/generic/evdevtablet/main.cpp
index 62524e8f33..3a9fd4f1dd 100644
--- a/src/plugins/generic/evdevtablet/main.cpp
+++ b/src/plugins/generic/evdevtablet/main.cpp
@@ -32,7 +32,7 @@
****************************************************************************/
#include <QtGui/qgenericplugin.h>
-#include <QtPlatformSupport/private/qevdevtablet_p.h>
+#include <QtPlatformSupport/private/qevdevtabletmanager_p.h>
QT_BEGIN_NAMESPACE
@@ -44,7 +44,6 @@ class QEvdevTabletPlugin : public QGenericPlugin
public:
QEvdevTabletPlugin();
- QStringList keys() const;
QObject* create(const QString &key, const QString &specification) Q_DECL_OVERRIDE;
};
@@ -52,16 +51,11 @@ QEvdevTabletPlugin::QEvdevTabletPlugin()
{
}
-QStringList QEvdevTabletPlugin::keys() const
-{
- return QStringList() << "EvdevTablet";
-}
-
-QObject *QEvdevTabletPlugin::create(const QString &key,
+QObject* QEvdevTabletPlugin::create(const QString &key,
const QString &spec)
{
if (!key.compare(QLatin1String("EvdevTablet"), Qt::CaseInsensitive))
- return new QEvdevTabletHandlerThread(spec);
+ return new QEvdevTabletManager(key, spec);
return 0;
}
diff --git a/src/plugins/generic/tuiotouch/qtuiohandler.cpp b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
index 2b42889cb1..2598bc5caf 100644
--- a/src/plugins/generic/tuiotouch/qtuiohandler.cpp
+++ b/src/plugins/generic/tuiotouch/qtuiohandler.cpp
@@ -36,6 +36,7 @@
#include <QRect>
#include <QWindow>
#include <QGuiApplication>
+#include <QTouchDevice>
#include <qpa/qwindowsysteminterface.h>
diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
index dca21245aa..f69bc5e401 100644
--- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
+++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
@@ -398,6 +398,7 @@ void QIBusPlatformInputContext::filterEventFinished(QDBusPendingCallWatcher *cal
bool retval = reply.value();
qCDebug(qtQpaInputMethods) << "filterEventFinished return" << code << sym << state << retval;
if (!retval) {
+#ifndef QT_NO_CONTEXTMENU
if (type == QEvent::KeyPress && qtcode == Qt::Key_Menu
&& window != NULL) {
const QPoint globalPos = window->screen()->handle()->cursor()->pos();
@@ -405,6 +406,7 @@ void QIBusPlatformInputContext::filterEventFinished(QDBusPendingCallWatcher *cal
QWindowSystemInterface::handleContextMenuEvent(window, false, pos,
globalPos, modifiers);
}
+#endif // QT_NO_CONTEXTMENU
QWindowSystemInterface::handleExtendedKeyEvent(window, time, type, qtcode, modifiers,
code, sym, state, string, isAutoRepeat);
diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro
index ba0e6b001a..fec1da334f 100644
--- a/src/plugins/platforms/cocoa/cocoa.pro
+++ b/src/plugins/platforms/cocoa/cocoa.pro
@@ -84,7 +84,7 @@ contains(QT_CONFIG, opengl.*) {
RESOURCES += qcocoaresources.qrc
-LIBS += -framework Cocoa -framework Carbon -framework IOKit -lcups
+LIBS += -framework AppKit -framework Carbon -framework IOKit -lcups
QT += core-private gui-private platformsupport-private
diff --git a/src/plugins/platforms/cocoa/main.mm b/src/plugins/platforms/cocoa/main.mm
index 43ff715161..4ec2b4ffc4 100644
--- a/src/plugins/platforms/cocoa/main.mm
+++ b/src/plugins/platforms/cocoa/main.mm
@@ -31,7 +31,7 @@
**
****************************************************************************/
-#include <Cocoa/Cocoa.h>
+#include <AppKit/AppKit.h>
#include <qpa/qplatformintegrationplugin.h>
#include <qpa/qplatformthemeplugin.h>
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.h b/src/plugins/platforms/cocoa/qcocoaaccessibility.h
index 228643ab26..2d1aa41a9a 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibility.h
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.h
@@ -33,7 +33,7 @@
#ifndef QCOCOAACCESIBILITY_H
#define QCOCOAACCESIBILITY_H
-#include <Cocoa/Cocoa.h>
+#include <AppKit/AppKit.h>
#include <QtGui>
#include <qpa/qplatformaccessibility.h>
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
index 4e901ba015..f83d15f48e 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm
@@ -334,6 +334,7 @@ bool hasValueAttribute(QAccessibleInterface *interface)
Q_ASSERT(interface);
const QAccessible::Role qtrole = interface->role();
if (qtrole == QAccessible::EditableText
+ || qtrole == QAccessible::StaticText
|| interface->valueInterface()
|| interface->state().checkable) {
return true;
@@ -345,6 +346,9 @@ bool hasValueAttribute(QAccessibleInterface *interface)
id getValueAttribute(QAccessibleInterface *interface)
{
const QAccessible::Role qtrole = interface->role();
+ if (qtrole == QAccessible::StaticText) {
+ return QCFString::toNSString(interface->text(QAccessible::Name));
+ }
if (qtrole == QAccessible::EditableText) {
if (QAccessibleTextInterface *textInterface = interface->textInterface()) {
// VoiceOver will read out the entire text string at once when returning
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
index 28f3b2af84..050fb7ba0a 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm
@@ -284,6 +284,8 @@ static void convertLineOffset(QAccessibleTextInterface *text, int &line, int &of
QSize qtSize = iface->rect().size();
return [NSValue valueWithSize: NSMakeSize(qtSize.width(), qtSize.height())];
} else if ([attribute isEqualToString:NSAccessibilityTitleAttribute]) {
+ if (iface->role() == QAccessible::StaticText)
+ return nil;
return QCFString::toNSString(iface->text(QAccessible::Name));
} else if ([attribute isEqualToString:NSAccessibilityDescriptionAttribute]) {
return QCFString::toNSString(iface->text(QAccessible::Description));
diff --git a/src/plugins/platforms/cocoa/qcocoaapplication.mm b/src/plugins/platforms/cocoa/qcocoaapplication.mm
index d9919f1120..7d0018a595 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplication.mm
+++ b/src/plugins/platforms/cocoa/qcocoaapplication.mm
@@ -181,7 +181,7 @@ QT_BEGIN_NAMESPACE
void qt_redirectNSApplicationSendEvent()
{
- if (QCoreApplication::testAttribute(Qt::AA_MacPluginApplication))
+ if (QCoreApplication::testAttribute(Qt::AA_PluginApplication))
// In a plugin we cannot chain sendEvent hooks: a second plugin could
// store the implementation of the first, which during the program flow
// can be unloaded.
@@ -207,7 +207,7 @@ void qt_redirectNSApplicationSendEvent()
void qt_resetNSApplicationSendEvent()
{
- if (QCoreApplication::testAttribute(Qt::AA_MacPluginApplication))
+ if (QCoreApplication::testAttribute(Qt::AA_PluginApplication))
return;
diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h
index abaaba91a5..a0eb8cc6fd 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h
+++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.h
@@ -79,7 +79,7 @@
//
-#import <Cocoa/Cocoa.h>
+#import <AppKit/AppKit.h>
#include <qglobal.h>
#include <private/qcore_mac_p.h>
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.h b/src/plugins/platforms/cocoa/qcocoabackingstore.h
index 5a199de4a5..839b536863 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.h
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.h
@@ -34,7 +34,7 @@
#ifndef QBACKINGSTORE_COCOA_H
#define QBACKINGSTORE_COCOA_H
-#include <Cocoa/Cocoa.h>
+#include <AppKit/AppKit.h>
#include "qcocoawindow.h"
#include "qnsview.h"
diff --git a/src/plugins/platforms/cocoa/qcocoacursor.h b/src/plugins/platforms/cocoa/qcocoacursor.h
index d104939f0c..58be5414f1 100644
--- a/src/plugins/platforms/cocoa/qcocoacursor.h
+++ b/src/plugins/platforms/cocoa/qcocoacursor.h
@@ -34,7 +34,7 @@
#ifndef QWINDOWSCURSOR_H
#define QWINDOWSCURSOR_H
-#include <Cocoa/Cocoa.h>
+#include <AppKit/AppKit.h>
#include <QtCore>
#include <qpa/qplatformcursor.h>
diff --git a/src/plugins/platforms/cocoa/qcocoadrag.h b/src/plugins/platforms/cocoa/qcocoadrag.h
index c1eeb34679..51de5dd5ed 100644
--- a/src/plugins/platforms/cocoa/qcocoadrag.h
+++ b/src/plugins/platforms/cocoa/qcocoadrag.h
@@ -34,7 +34,7 @@
#ifndef QCOCOADRAG_H
#define QCOCOADRAG_H
-#include <Cocoa/Cocoa.h>
+#include <AppKit/AppKit.h>
#include <QtGui>
#include <qpa/qplatformdrag.h>
#include <private/qsimpledrag_p.h>
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
index 1865624d57..117eba1b2a 100644
--- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
+++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
@@ -80,7 +80,7 @@
#include <qdebug.h>
#undef slots
-#include <Cocoa/Cocoa.h>
+#include <AppKit/AppKit.h>
#include <Carbon/Carbon.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h
index fa6db018a7..cac53b14f9 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.h
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h
@@ -40,7 +40,7 @@
#include <QtGui/QWindow>
#undef slots
-#include <Cocoa/Cocoa.h>
+#include <AppKit/AppKit.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
index 0f9b8b900d..d43c8e5ee9 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -39,7 +39,7 @@
#include <QtPlatformSupport/private/cglconvenience_p.h>
#include <QtPlatformHeaders/qcocoanativecontext.h>
-#import <Cocoa/Cocoa.h>
+#import <AppKit/AppKit.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h
index e7e21c356a..c7875af83e 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.h
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.h
@@ -34,7 +34,7 @@
#ifndef QPLATFORMINTEGRATION_COCOA_H
#define QPLATFORMINTEGRATION_COCOA_H
-#include <Cocoa/Cocoa.h>
+#include <AppKit/AppKit.h>
#include "qcocoacursor.h"
#include "qcocoawindow.h"
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index 6bec6b191d..e469ec5c74 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -317,7 +317,7 @@ QCocoaIntegration::QCocoaIntegration(const QStringList &paramList)
// ### For AA_MacPluginApplication we don't want to load the menu nib.
// Qt 4 also does not set the application delegate, so that behavior
// is matched here.
- if (!QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) {
+ if (!QCoreApplication::testAttribute(Qt::AA_PluginApplication)) {
// Set app delegate, link to the current delegate (if any)
QCocoaApplicationDelegate *newDelegate = [QCocoaApplicationDelegate sharedDelegate];
@@ -344,7 +344,7 @@ QCocoaIntegration::~QCocoaIntegration()
qt_resetNSApplicationSendEvent();
QMacAutoReleasePool pool;
- if (!QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) {
+ if (!QCoreApplication::testAttribute(Qt::AA_PluginApplication)) {
// remove the apple event handlers installed by QCocoaApplicationDelegate
QCocoaApplicationDelegate *delegate = [QCocoaApplicationDelegate sharedDelegate];
[delegate removeAppleEventHandlers];
diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.h b/src/plugins/platforms/cocoa/qcocoakeymapper.h
index 11bbdc5426..9e79d634ab 100644
--- a/src/plugins/platforms/cocoa/qcocoakeymapper.h
+++ b/src/plugins/platforms/cocoa/qcocoakeymapper.h
@@ -36,7 +36,7 @@
#include <qcocoahelpers.h>
-#include <Cocoa/Cocoa.h>
+#include <AppKit/AppKit.h>
#include <Carbon/Carbon.h>
#include <QtCore/QList>
diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm
index 7775cdbde6..af5905f846 100644
--- a/src/plugins/platforms/cocoa/qcocoamenubar.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm
@@ -31,7 +31,7 @@
**
****************************************************************************/
-#include <Cocoa/Cocoa.h>
+#include <AppKit/AppKit.h>
#include "qcocoamenubar.h"
#include "qcocoawindow.h"
diff --git a/src/plugins/platforms/cocoa/qcocoamenuloader.h b/src/plugins/platforms/cocoa/qcocoamenuloader.h
index bdc943f78a..a3eea8bc15 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuloader.h
+++ b/src/plugins/platforms/cocoa/qcocoamenuloader.h
@@ -45,7 +45,7 @@
// We mean it.
//
-#import <Cocoa/Cocoa.h>
+#import <AppKit/AppKit.h>
#include <QtCore/private/qcore_mac_p.h>
@interface QT_MANGLE_NAMESPACE(QCocoaMenuLoader) : NSResponder
diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
index 41ea1fa49c..d2d3a7d562 100644
--- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
+++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
@@ -60,7 +60,7 @@
#include <QtPlatformHeaders/qcocoawindowfunctions.h>
-#include <Cocoa/Cocoa.h>
+#include <AppKit/AppKit.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm
index 4b73d0af08..42ddce6e23 100644
--- a/src/plugins/platforms/cocoa/qcocoatheme.mm
+++ b/src/plugins/platforms/cocoa/qcocoatheme.mm
@@ -31,7 +31,7 @@
**
****************************************************************************/
-#import <Cocoa/Cocoa.h>
+#import <AppKit/AppKit.h>
#include "qcocoatheme.h"
#include "messages.h"
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index 05e6cf3c9e..e830be212a 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -34,7 +34,7 @@
#ifndef QCOCOAWINDOW_H
#define QCOCOAWINDOW_H
-#include <Cocoa/Cocoa.h>
+#include <AppKit/AppKit.h>
#include <qpa/qplatformwindow.h>
#include <QRect>
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 6f1e355790..adfef81117 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -47,7 +47,7 @@
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatformscreen.h>
-#include <Cocoa/Cocoa.h>
+#include <AppKit/AppKit.h>
#include <Carbon/Carbon.h>
#include <QDebug>
@@ -685,7 +685,16 @@ void QCocoaWindow::setVisible(bool visible)
cocoaEventDispatcherPrivate->beginModalSession(window());
m_hasModalSession = true;
} else if ([m_nsWindow canBecomeKeyWindow]) {
- [m_nsWindow makeKeyAndOrderFront:nil];
+ QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast<QCocoaEventDispatcher *>(QGuiApplication::instance()->eventDispatcher());
+ QCocoaEventDispatcherPrivate *cocoaEventDispatcherPrivate = 0;
+ if (cocoaEventDispatcher)
+ cocoaEventDispatcherPrivate = static_cast<QCocoaEventDispatcherPrivate *>(QObjectPrivate::get(cocoaEventDispatcher));
+
+ if (!(cocoaEventDispatcherPrivate && cocoaEventDispatcherPrivate->currentModalSession()))
+ [m_nsWindow makeKeyAndOrderFront:nil];
+ else
+ [m_nsWindow orderFront:nil];
+
foreach (QCocoaWindow *childWindow, m_childWindows)
childWindow->show(true);
} else {
@@ -1338,6 +1347,9 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
}
} else {
// Child windows have no NSWindow, link the NSViews instead.
+ if ([m_contentView superview])
+ [m_contentView removeFromSuperview];
+
[m_parentCocoaWindow->m_contentView addSubview : m_contentView];
QRect rect = windowGeometry();
// Prevent setting a (0,0) window size; causes opengl context
diff --git a/src/plugins/platforms/cocoa/qmacclipboard.h b/src/plugins/platforms/cocoa/qmacclipboard.h
index 0d1f195f48..8b290866c6 100644
--- a/src/plugins/platforms/cocoa/qmacclipboard.h
+++ b/src/plugins/platforms/cocoa/qmacclipboard.h
@@ -39,7 +39,7 @@
#undef slots
-#import <Cocoa/Cocoa.h>
+#import <AppKit/AppKit.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qmacdefines_mac.h b/src/plugins/platforms/cocoa/qmacdefines_mac.h
index b2773a2b9f..fd540e7c34 100644
--- a/src/plugins/platforms/cocoa/qmacdefines_mac.h
+++ b/src/plugins/platforms/cocoa/qmacdefines_mac.h
@@ -92,7 +92,7 @@ typedef signed long OSStatus;
# define old_slots slots
# undef slots
# endif
-#include <Cocoa/Cocoa.h>
+#include <AppKit/AppKit.h>
# ifdef old_slots
# undef slots
# define slots
diff --git a/src/plugins/platforms/cocoa/qmultitouch_mac_p.h b/src/plugins/platforms/cocoa/qmultitouch_mac_p.h
index e4eec41295..0af0505a47 100644
--- a/src/plugins/platforms/cocoa/qmultitouch_mac_p.h
+++ b/src/plugins/platforms/cocoa/qmultitouch_mac_p.h
@@ -47,7 +47,7 @@
#include <QtCore/qglobal.h>
-#import <Cocoa/Cocoa.h>
+#import <AppKit/AppKit.h>
#include <qpa/qwindowsysteminterface.h>
#include <qhash.h>
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h
index 028a34af1c..d7b9c3831b 100644
--- a/src/plugins/platforms/cocoa/qnsview.h
+++ b/src/plugins/platforms/cocoa/qnsview.h
@@ -34,7 +34,7 @@
#ifndef QNSVIEW_H
#define QNSVIEW_H
-#include <Cocoa/Cocoa.h>
+#include <AppKit/AppKit.h>
#include <QtCore/QPointer>
#include <QtGui/QImage>
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.h b/src/plugins/platforms/cocoa/qnswindowdelegate.h
index b8d344aa0e..794059bc68 100644
--- a/src/plugins/platforms/cocoa/qnswindowdelegate.h
+++ b/src/plugins/platforms/cocoa/qnswindowdelegate.h
@@ -34,7 +34,7 @@
#ifndef QNSWINDOWDELEGATE_H
#define QNSWINDOWDELEGATE_H
-#include <Cocoa/Cocoa.h>
+#include <AppKit/AppKit.h>
#include "qcocoawindow.h"
diff --git a/src/plugins/platforms/cocoa/qt_mac_p.h b/src/plugins/platforms/cocoa/qt_mac_p.h
index 576e0f9729..7714de9005 100644
--- a/src/plugins/platforms/cocoa/qt_mac_p.h
+++ b/src/plugins/platforms/cocoa/qt_mac_p.h
@@ -48,7 +48,7 @@
#include "qmacdefines_mac.h"
#ifdef __OBJC__
-#include <Cocoa/Cocoa.h>
+#include <AppKit/AppKit.h>
#include <objc/runtime.h>
#endif
diff --git a/src/plugins/platforms/eglfs/qeglfscursor.cpp b/src/plugins/platforms/eglfs/qeglfscursor.cpp
index eea130a754..bfb69d3e8f 100644
--- a/src/plugins/platforms/eglfs/qeglfscursor.cpp
+++ b/src/plugins/platforms/eglfs/qeglfscursor.cpp
@@ -38,6 +38,7 @@
#include <qpa/qwindowsysteminterface.h>
#include <QtGui/QOpenGLContext>
#include <QtGui/QOpenGLShaderProgram>
+#include <QtCore/QFile>
#include <QtCore/QJsonDocument>
#include <QtCore/QJsonArray>
#include <QtCore/QJsonObject>
diff --git a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
index 91708c0a47..45f66db75d 100644
--- a/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
+++ b/src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp
@@ -34,6 +34,7 @@
#include "qlinuxfbscreen.h"
#include <QtPlatformSupport/private/qfbcursor_p.h>
#include <QtPlatformSupport/private/qfbwindow_p.h>
+#include <QtCore/QFile>
#include <QtCore/QRegularExpression>
#include <QtGui/QPainter>
diff --git a/src/plugins/platforms/mirclient/qmirclientglcontext.cpp b/src/plugins/platforms/mirclient/qmirclientglcontext.cpp
index bfba5051e5..bbd7f5ee75 100644
--- a/src/plugins/platforms/mirclient/qmirclientglcontext.cpp
+++ b/src/plugins/platforms/mirclient/qmirclientglcontext.cpp
@@ -39,6 +39,7 @@
#include "qmirclientwindow.h"
#include "qmirclientlogging.h"
#include <QtPlatformSupport/private/qeglconvenience_p.h>
+#include <QtGui/private/qopenglcontext_p.h>
#if !defined(QT_NO_DEBUG)
static void printOpenGLESConfig() {
@@ -103,6 +104,15 @@ bool QMirClientOpenGLContext::makeCurrent(QPlatformSurface* surface)
ASSERT(eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, mEglContext) == EGL_TRUE);
printOpenGLESConfig();
#endif
+
+ // When running on the emulator, shaders will be compiled using a thin wrapper around the desktop drivers.
+ // These wrappers might not support the precision qualifiers, so set the workaround flag to true.
+ const char *rendererString = reinterpret_cast<const char *>(glGetString(GL_RENDERER));
+ if (rendererString != 0 && qstrncmp(rendererString, "Android Emulator", 16) == 0) {
+ QOpenGLContextPrivate *ctx_d = QOpenGLContextPrivate::get(context());
+ ctx_d->workaround_missingPrecisionQualifiers = true;
+ }
+
return true;
}
diff --git a/src/plugins/platforms/windows/qwindowsdrag.cpp b/src/plugins/platforms/windows/qwindowsdrag.cpp
index d24cba3c68..955f5792a9 100644
--- a/src/plugins/platforms/windows/qwindowsdrag.cpp
+++ b/src/plugins/platforms/windows/qwindowsdrag.cpp
@@ -239,8 +239,6 @@ private:
};
typedef QMap<Qt::DropAction, CursorEntry> ActionCursorMap;
- typedef ActionCursorMap::Iterator ActionCursorMapIt;
- typedef ActionCursorMap::ConstIterator ActionCursorMapConstIt;
const Mode m_mode;
QWindowsDrag *m_drag;
@@ -318,7 +316,7 @@ void QWindowsOleDropSource::createCursors()
if (cursorPixmap.isNull())
cursorPixmap = m_drag->defaultCursor(action);
const qint64 cacheKey = cursorPixmap.cacheKey();
- const ActionCursorMapIt it = m_cursors.find(action);
+ const auto it = m_cursors.find(action);
if (it != m_cursors.end() && it.value().cacheKey == cacheKey)
continue;
if (cursorPixmap.isNull()) {
@@ -447,7 +445,7 @@ QWindowsOleDropSource::GiveFeedback(DWORD dwEffect)
m_drag->updateAction(action);
const qint64 currentCacheKey = m_drag->currentDrag()->dragCursor(action).cacheKey();
- ActionCursorMapConstIt it = m_cursors.constFind(action);
+ auto it = m_cursors.constFind(action);
// If a custom drag cursor is set, check its cache key to detect changes.
if (it == m_cursors.constEnd() || (currentCacheKey && currentCacheKey != it.value().cacheKey)) {
createCursors();
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
index 3b27964b0e..eb8262262f 100644
--- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
@@ -43,6 +43,7 @@
#include <QtCore/qmath.h>
#include <QtCore/QDebug>
+#include <QtCore/QFile>
#include <QtCore/QtEndian>
#include <QtCore/QThreadStorage>
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp
index 795554698c..d827607bc5 100644
--- a/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontdatabase_ft.cpp
@@ -145,10 +145,8 @@ static FontKeys &fontKeys()
static const FontKey *findFontKey(const QString &name, int *indexIn = Q_NULLPTR)
{
- typedef FontKeys::ConstIterator ConstIt;
-
const FontKeys &keys = fontKeys();
- for (ConstIt it = keys.constBegin(), cend = keys.constEnd(); it != cend; ++it) {
+ for (auto it = keys.constBegin(), cend = keys.constEnd(); it != cend; ++it) {
const int index = it->fontNames.indexOf(name);
if (index >= 0) {
if (indexIn)
diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp
index 3685197430..ca3e2527e9 100644
--- a/src/plugins/platforms/windows/qwindowsfontengine.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp
@@ -54,6 +54,7 @@
#include <QtGui/private/qpaintengine_raster_p.h>
#include <QtCore/QtEndian>
+#include <QtCore/QFile>
#include <QtCore/qmath.h>
#include <QtCore/QThreadStorage>
#include <QtCore/private/qsystemlibrary_p.h>
diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp
index bbb1f68a52..7322af95d1 100644
--- a/src/plugins/platforms/windows/qwindowsintegration.cpp
+++ b/src/plugins/platforms/windows/qwindowsintegration.cpp
@@ -62,6 +62,7 @@
#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER)
# include "qwindowssessionmanager.h"
#endif
+#include <QtGui/qtouchdevice.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/private/qhighdpiscaling_p.h>
#include <QtGui/qpa/qplatforminputcontextfactory_p.h>
@@ -220,11 +221,13 @@ QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList &paramL
if (tabletAbsoluteRange >= 0)
m_context.setTabletAbsoluteRange(tabletAbsoluteRange);
if (!dpiAwarenessSet) { // Set only once in case of repeated instantiations of QGuiApplication.
- m_context.setProcessDpiAwareness(dpiAwareness);
+ if (!QCoreApplication::testAttribute(Qt::AA_PluginApplication)) {
+ m_context.setProcessDpiAwareness(dpiAwareness);
+ qCDebug(lcQpaWindows)
+ << __FUNCTION__ << "DpiAwareness=" << dpiAwareness;
+ }
dpiAwarenessSet = true;
}
- qCDebug(lcQpaWindows)
- << __FUNCTION__ << "DpiAwareness=" << dpiAwareness;
QTouchDevice *touchDevice = m_context.touchDevice();
if (touchDevice) {
diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
index 90cb6fe195..bd801edc4f 100644
--- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp
+++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp
@@ -41,6 +41,7 @@
#include <qpa/qwindowsysteminterface.h>
#include <QtGui/QGuiApplication>
#include <QtGui/QScreen>
+#include <QtGui/QTouchDevice>
#include <QtGui/QWindow>
#include <QtGui/QCursor>
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
index 2e088d3ca5..0bfefc962e 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
@@ -1511,11 +1511,13 @@ void QXcbKeyboard::handleKeyEvent(xcb_window_t sourceWindow, QEvent::Type type,
QWindow *window = targetWindow->window();
if (!filtered) {
+#ifndef QT_NO_CONTEXTMENU
if (type == QEvent::KeyPress && qtcode == Qt::Key_Menu) {
const QPoint globalPos = window->screen()->handle()->cursor()->pos();
const QPoint pos = window->mapFromGlobal(globalPos);
QWindowSystemInterface::handleContextMenuEvent(window, false, pos, globalPos, modifiers);
}
+#endif // QT_NO_CONTEXTMENU
QWindowSystemInterface::handleExtendedKeyEvent(window, time, type, qtcode, modifiers,
code, sym, state, string, isAutoRepeat);
}
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index 64645b92f6..da4db5edcb 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -113,8 +113,6 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDe
updateRefreshRate(crtc->mode);
free(crtc);
}
- } else {
- updateGeometry(output ? output->timestamp : 0);
}
if (m_geometry.isEmpty()) {
diff --git a/src/plugins/printsupport/cocoa/cocoa.pro b/src/plugins/printsupport/cocoa/cocoa.pro
index a3b9e2dfcf..c993b42574 100644
--- a/src/plugins/printsupport/cocoa/cocoa.pro
+++ b/src/plugins/printsupport/cocoa/cocoa.pro
@@ -5,7 +5,7 @@ PLUGIN_CLASS_NAME = QCocoaPrinterSupportPlugin
load(qt_plugin)
QT += gui-private printsupport-private
-LIBS += -framework Cocoa
+LIBS += -framework AppKit
SOURCES += main.cpp
diff --git a/src/printsupport/dialogs/dialogs.pri b/src/printsupport/dialogs/dialogs.pri
index bb07167f68..7b520a05de 100644
--- a/src/printsupport/dialogs/dialogs.pri
+++ b/src/printsupport/dialogs/dialogs.pri
@@ -8,10 +8,10 @@ HEADERS += \
dialogs/qprintdialog.h \
dialogs/qprintpreviewdialog.h
-mac:!ios {
+osx {
OBJECTIVE_SOURCES += dialogs/qpagesetupdialog_mac.mm \
dialogs/qprintdialog_mac.mm
- LIBS_PRIVATE += -framework Cocoa
+ LIBS_PRIVATE += -framework AppKit
}
win32 {
diff --git a/src/printsupport/dialogs/qpagesetupdialog_mac.mm b/src/printsupport/dialogs/qpagesetupdialog_mac.mm
index b86de31883..3147ccb58e 100644
--- a/src/printsupport/dialogs/qpagesetupdialog_mac.mm
+++ b/src/printsupport/dialogs/qpagesetupdialog_mac.mm
@@ -32,7 +32,7 @@
****************************************************************************/
-#include <Cocoa/Cocoa.h>
+#include <AppKit/AppKit.h>
#include "qpagesetupdialog.h"
diff --git a/src/printsupport/dialogs/qprintdialog_mac.mm b/src/printsupport/dialogs/qprintdialog_mac.mm
index 030526954d..e7948c2a37 100644
--- a/src/printsupport/dialogs/qprintdialog_mac.mm
+++ b/src/printsupport/dialogs/qprintdialog_mac.mm
@@ -31,7 +31,7 @@
**
****************************************************************************/
-#include <Cocoa/Cocoa.h>
+#include <AppKit/AppKit.h>
#include "qprintdialog.h"
#include "qabstractprintdialog_p.h"
diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp
index d036c40f35..0a80c0242b 100644
--- a/src/tools/moc/preprocessor.cpp
+++ b/src/tools/moc/preprocessor.cpp
@@ -154,6 +154,11 @@ bool Preprocessor::skipBranch()
Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocessor::TokenizeMode mode)
{
Symbols symbols;
+ // Preallocate some space to speed up the code below.
+ // The magic divisor value was found by calculating the average ratio between
+ // input size and the final size of symbols.
+ // This yielded a value of 16.x when compiling Qt Base.
+ symbols.reserve(input.size() / 16);
const char *begin = input.constData();
const char *data = begin;
while (*data) {
diff --git a/src/tools/qdoc/node.cpp b/src/tools/qdoc/node.cpp
index c1cf076f47..9740f984f5 100644
--- a/src/tools/qdoc/node.cpp
+++ b/src/tools/qdoc/node.cpp
@@ -847,7 +847,7 @@ FunctionNode *Aggregate::findFunctionNode(const QString& name, const QString& pa
FunctionNode* fn = pfn;
if (fn) {
const QVector<Parameter>* funcParams = &(fn->parameters());
- if (params.isEmpty() && funcParams->isEmpty())
+ if (params.isEmpty() && funcParams->isEmpty() && !fn->isInternal())
return fn;
bool isQPrivateSignal = false; // Not used in the search
QVector<Parameter> testParams;
@@ -859,7 +859,7 @@ FunctionNode *Aggregate::findFunctionNode(const QString& name, const QString& pa
int i = -1;
while (fn) {
if (testParams.size() == funcParams->size()) {
- if (testParams.isEmpty())
+ if (testParams.isEmpty() && !fn->isInternal())
return fn;
bool different = false;
for (int j=0; j<testParams.size(); j++) {
@@ -868,7 +868,7 @@ FunctionNode *Aggregate::findFunctionNode(const QString& name, const QString& pa
break;
}
}
- if (!different)
+ if (!different && !fn->isInternal())
return fn;
}
if (++i < funcs.size()) {
@@ -878,19 +878,30 @@ FunctionNode *Aggregate::findFunctionNode(const QString& name, const QString& pa
else
fn = 0;
}
- if (!fn && !testParams.empty())
- return 0;
+ /*
+ Most \l commands that link to functions don't include
+ the parameter declarations in the function signature,
+ so if the \l is meant to go to a function that does
+ have parameters, the algorithm above won't find it.
+ Therefore we must return the pointer to the function
+ in the primary function map in the cases where the
+ parameters should have been specified in the \l command.
+ But if the primary function is marked internal, search
+ the secondary list to find one that is not marked internal.
+ */
+ if (!fn) {
+ if (!testParams.empty())
+ return 0;
+ if (pfn && !pfn->isInternal())
+ return pfn;
+ foreach (Node* n, funcs) {
+ fn = static_cast<FunctionNode*>(n);
+ if (!fn->isInternal())
+ return fn;
+ }
+ }
}
- /*
- Most \l commands that link to functions don't include
- the parameter declarations in the function signature,
- so if the \l is meant to go to a function that does
- have parameters, the algorithm above won't find it.
- Therefore we must return the pointer to the function
- in the primary function map in the cases where the
- parameters should have been specified in the \l command.
- */
- return (fn ? fn : pfn);
+ return fn;
}
/*!
diff --git a/src/tools/qdoc/qdocdatabase.cpp b/src/tools/qdoc/qdocdatabase.cpp
index 28373bd3b5..d48804d566 100644
--- a/src/tools/qdoc/qdocdatabase.cpp
+++ b/src/tools/qdoc/qdocdatabase.cpp
@@ -1676,8 +1676,6 @@ const Node* QDocDatabase::findNodeForAtom(const Atom* a, const Node* relative, Q
Atom* atom = const_cast<Atom*>(a);
QStringList targetPath = atom->string().split(QLatin1Char('#'));
QString first = targetPath.first().trimmed();
- if (Generator::debugging())
- qDebug() << " first:" << first;
Tree* domain = 0;
Node::Genus genus = Node::DontCare;
@@ -1721,8 +1719,6 @@ const Node* QDocDatabase::findNodeForAtom(const Atom* a, const Node* relative, Q
node = findNodeByNameAndType(QStringList(first), Node::Document);
else if (first.endsWith(QChar(')'))) {
node = findFunctionNode(first, relative, genus);
- if (Generator::debugging())
- qDebug() << " node:" << node;
}
if (!node)
return findNodeForTarget(targetPath, relative, genus, ref);
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index 556e927cbf..00f466e227 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -251,6 +251,21 @@ QModelIndex QFileSystemModel::index(int row, int column, const QModelIndex &pare
}
/*!
+ \reimp
+*/
+QModelIndex QFileSystemModel::sibling(int row, int column, const QModelIndex &idx) const
+{
+ if (row == idx.row() && column < QFileSystemModelPrivate::NumColumns) {
+ // cheap sibling operation: just adjust the column:
+ return createIndex(row, column, idx.internalPointer());
+ } else {
+ // for anything else: call the default implementation
+ // (this could probably be optimized, too):
+ return QAbstractItemModel::sibling(row, column, idx);
+ }
+}
+
+/*!
\overload
Returns the model item index for the given \a path and \a column.
diff --git a/src/widgets/dialogs/qfilesystemmodel.h b/src/widgets/dialogs/qfilesystemmodel.h
index f749c97bcb..cef85a0c8c 100644
--- a/src/widgets/dialogs/qfilesystemmodel.h
+++ b/src/widgets/dialogs/qfilesystemmodel.h
@@ -75,6 +75,7 @@ public:
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
QModelIndex index(const QString &path, int column = 0) const;
QModelIndex parent(const QModelIndex &child) const Q_DECL_OVERRIDE;
+ QModelIndex sibling(int row, int column, const QModelIndex &idx) const Q_DECL_OVERRIDE;
bool hasChildren(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
bool canFetchMore(const QModelIndex &parent) const Q_DECL_OVERRIDE;
void fetchMore(const QModelIndex &parent) Q_DECL_OVERRIDE;
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index 8a48100ea7..4ad235051c 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -89,16 +89,14 @@ public:
{
public:
TextEdit(QWidget *parent=0) : QTextEdit(parent) { }
+#ifndef QT_NO_CONTEXTMENU
void contextMenuEvent(QContextMenuEvent * e) Q_DECL_OVERRIDE
{
-#ifndef QT_NO_CONTEXTMENU
QMenu *menu = createStandardContextMenu();
menu->setAttribute(Qt::WA_DeleteOnClose);
menu->popup(e->globalPos());
-#else
- Q_UNUSED(e);
-#endif
}
+#endif // QT_NO_CONTEXTMENU
};
QMessageBoxDetailsText(QWidget *parent=0)
diff --git a/src/widgets/doc/images/gtk-calendarwidget.png b/src/widgets/doc/images/gtk-calendarwidget.png
deleted file mode 100644
index 568cd1a5da..0000000000
--- a/src/widgets/doc/images/gtk-calendarwidget.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-checkbox.png b/src/widgets/doc/images/gtk-checkbox.png
deleted file mode 100644
index 1fd5fc77bf..0000000000
--- a/src/widgets/doc/images/gtk-checkbox.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-combobox.png b/src/widgets/doc/images/gtk-combobox.png
deleted file mode 100644
index 3b4544df13..0000000000
--- a/src/widgets/doc/images/gtk-combobox.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-dateedit.png b/src/widgets/doc/images/gtk-dateedit.png
deleted file mode 100644
index 25229f0b3b..0000000000
--- a/src/widgets/doc/images/gtk-dateedit.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-datetimeedit.png b/src/widgets/doc/images/gtk-datetimeedit.png
deleted file mode 100644
index 0c934a4d0d..0000000000
--- a/src/widgets/doc/images/gtk-datetimeedit.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-dial.png b/src/widgets/doc/images/gtk-dial.png
deleted file mode 100644
index 18e14b3650..0000000000
--- a/src/widgets/doc/images/gtk-dial.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-doublespinbox.png b/src/widgets/doc/images/gtk-doublespinbox.png
deleted file mode 100644
index 3a69043c0b..0000000000
--- a/src/widgets/doc/images/gtk-doublespinbox.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-fontcombobox.png b/src/widgets/doc/images/gtk-fontcombobox.png
deleted file mode 100644
index 4cb1bc1343..0000000000
--- a/src/widgets/doc/images/gtk-fontcombobox.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-frame.png b/src/widgets/doc/images/gtk-frame.png
deleted file mode 100644
index c1bf52f6a6..0000000000
--- a/src/widgets/doc/images/gtk-frame.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-groupbox.png b/src/widgets/doc/images/gtk-groupbox.png
deleted file mode 100644
index 6d217c89f9..0000000000
--- a/src/widgets/doc/images/gtk-groupbox.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-horizontalscrollbar.png b/src/widgets/doc/images/gtk-horizontalscrollbar.png
deleted file mode 100644
index 2887730c13..0000000000
--- a/src/widgets/doc/images/gtk-horizontalscrollbar.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-label.png b/src/widgets/doc/images/gtk-label.png
deleted file mode 100644
index 006d0133d8..0000000000
--- a/src/widgets/doc/images/gtk-label.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-lcdnumber.png b/src/widgets/doc/images/gtk-lcdnumber.png
deleted file mode 100644
index 142d298ffc..0000000000
--- a/src/widgets/doc/images/gtk-lcdnumber.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-lineedit.png b/src/widgets/doc/images/gtk-lineedit.png
deleted file mode 100644
index 8fb513c39f..0000000000
--- a/src/widgets/doc/images/gtk-lineedit.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-listview.png b/src/widgets/doc/images/gtk-listview.png
deleted file mode 100644
index d32f8e8aee..0000000000
--- a/src/widgets/doc/images/gtk-listview.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-progressbar.png b/src/widgets/doc/images/gtk-progressbar.png
deleted file mode 100644
index 6162484bf3..0000000000
--- a/src/widgets/doc/images/gtk-progressbar.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-pushbutton.png b/src/widgets/doc/images/gtk-pushbutton.png
deleted file mode 100644
index f4f4d7c1e4..0000000000
--- a/src/widgets/doc/images/gtk-pushbutton.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-radiobutton.png b/src/widgets/doc/images/gtk-radiobutton.png
deleted file mode 100644
index b3620fa054..0000000000
--- a/src/widgets/doc/images/gtk-radiobutton.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-slider.png b/src/widgets/doc/images/gtk-slider.png
deleted file mode 100644
index 3d8e0ee89e..0000000000
--- a/src/widgets/doc/images/gtk-slider.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-spinbox.png b/src/widgets/doc/images/gtk-spinbox.png
deleted file mode 100644
index a39eb3aa93..0000000000
--- a/src/widgets/doc/images/gtk-spinbox.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-tableview.png b/src/widgets/doc/images/gtk-tableview.png
deleted file mode 100644
index a025193188..0000000000
--- a/src/widgets/doc/images/gtk-tableview.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-tabwidget.png b/src/widgets/doc/images/gtk-tabwidget.png
deleted file mode 100644
index 089c76dad2..0000000000
--- a/src/widgets/doc/images/gtk-tabwidget.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-textedit.png b/src/widgets/doc/images/gtk-textedit.png
deleted file mode 100644
index e4b91c01c9..0000000000
--- a/src/widgets/doc/images/gtk-textedit.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-timeedit.png b/src/widgets/doc/images/gtk-timeedit.png
deleted file mode 100644
index acf6730a86..0000000000
--- a/src/widgets/doc/images/gtk-timeedit.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-toolbox.png b/src/widgets/doc/images/gtk-toolbox.png
deleted file mode 100644
index 25e6137699..0000000000
--- a/src/widgets/doc/images/gtk-toolbox.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-toolbutton.png b/src/widgets/doc/images/gtk-toolbutton.png
deleted file mode 100644
index f0eb86efc5..0000000000
--- a/src/widgets/doc/images/gtk-toolbutton.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/images/gtk-treeview.png b/src/widgets/doc/images/gtk-treeview.png
deleted file mode 100644
index 7b4e3044be..0000000000
--- a/src/widgets/doc/images/gtk-treeview.png
+++ /dev/null
Binary files differ
diff --git a/src/widgets/doc/snippets/code/doc_src_stylesheet.cpp b/src/widgets/doc/snippets/code/doc_src_stylesheet.cpp
index a937498fe5..01f4c528a2 100644
--- a/src/widgets/doc/snippets/code/doc_src_stylesheet.cpp
+++ b/src/widgets/doc/snippets/code/doc_src_stylesheet.cpp
@@ -138,3 +138,7 @@ emailEdit->setProperty("mandatoryField", true);
QSpinBox *ageSpinBox = new QSpinBox(this);
ageSpinBox->setProperty("mandatoryField", true);
//! [95]
+
+//! [96]
+qApp->setAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles, true);
+//! [97]
diff --git a/src/widgets/doc/snippets/macmainwindow.mm b/src/widgets/doc/snippets/macmainwindow.mm
index d0d74631ab..17aff45fa0 100644
--- a/src/widgets/doc/snippets/macmainwindow.mm
+++ b/src/widgets/doc/snippets/macmainwindow.mm
@@ -31,7 +31,7 @@
**
****************************************************************************/
#include "macmainwindow.h"
-#import <Cocoa/Cocoa.h>
+#import <AppKit/AppKit.h>
#include <QtGui>
diff --git a/src/widgets/doc/snippets/qmacnativewidget/main.mm b/src/widgets/doc/snippets/qmacnativewidget/main.mm
index e541aac1f8..38701917c0 100644
--- a/src/widgets/doc/snippets/qmacnativewidget/main.mm
+++ b/src/widgets/doc/snippets/qmacnativewidget/main.mm
@@ -40,7 +40,7 @@
#include <QtGui/QtGui>
#include <QtGui/qmacnativewidget_mac.h>
-#import <Cocoa/Cocoa.h>
+#import <AppKit/AppKit.h>
int main(int argc, char **argv)
{
diff --git a/src/widgets/doc/src/widgets-and-layouts/gallery-gtk.qdoc b/src/widgets/doc/src/widgets-and-layouts/gallery-gtk.qdoc
deleted file mode 100644
index 5c3ae8cb97..0000000000
--- a/src/widgets/doc/src/widgets-and-layouts/gallery-gtk.qdoc
+++ /dev/null
@@ -1,142 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: http://www.gnu.org/copyleft/fdl.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \page gallery-gtk.html
-
- \title GTK Style Widget Gallery
- \ingroup gallery
-
- This page shows some of the widgets available in Qt
- when configured to use the "gtk" style. This style is
- only available on desktop environments with GTK runtime
- support. This style provides native look'n'feel by
- integrating to the GTK platform theme. Thus, the final
- appearance varies depending on the active GTK theme.
-
-\section2 Buttons
-
-\table 100%
-\row
-\li \image gtk-pushbutton.png
- \caption The QPushButton widget provides a command button.
-\li \image gtk-toolbutton.png
- \caption The QToolButton class provides a quick-access button to commands
- or options, usually used inside a QToolBar.
-\endtable
-
-\table 100%
-\row
-\li \image gtk-checkbox.png
- \caption The QCheckBox widget provides a checkbox with a text label.
-\li \image gtk-radiobutton.png
- \caption The QRadioButton widget provides a radio button with a text or pixmap label.
-\endtable
-
-\section2 Containers
-
-\table 100%
-\row
-\li \image gtk-groupbox.png
- The QGroupBox widget provides a group box frame with a title.
-\li \image gtk-tabwidget.png
- The QTabWidget class provides a stack of tabbed widgets.
-\li \image gtk-frame.png
- The QFrame widget provides a simple decorated container for other widgets.
-\li \image gtk-toolbox.png
- The QToolBox class provides a column of tabbed widget items.
-\endtable
-
-\section2 Item Views
-
-\table 100%
-\row
-\li \image gtk-listview.png
- The QListView class provides a default model/view implementation of a list/icon view. The QListWidget class provides a classic item-based list/icon view.
-\li \image gtk-treeview.png
- The QTreeView class provides a default model/view implementation of a tree view. The QTreeWidget class provides a classic item-based tree view.
-\li \image gtk-tableview.png
- The QTableView class provides a default model/view implementation of a table view. The QTableWidget class provides a classic item-based table view.\li
-\li
-\endtable
-
-\section2 Display Widgets
-
-\table 100%
-\row
-\li \image gtk-progressbar.png
- The QProgressBar widget provides a horizontal progress bar.
-\li \image gtk-label.png
- The QLabel widget provides a text or image display.
-\li \image gtk-lcdnumber.png
- The QLCDNumber widget displays a number with LCD-like digits.
-\endtable
-
-\section2 Input Widgets
-
-\table 100%
-\row
-\li \image gtk-lineedit.png
- The QLineEdit widget is a one-line text editor.
-\li \image gtk-dateedit.png
- The QDateEdit class provides a widget for editing dates.
-\li \image gtk-timeedit.png
- The QTimeEdit class provides a widget for editing times.
-\li \image gtk-datetimeedit.png
- The QDateTimeEdit class provides a widget for editing dates and times.
-\endtable
-
-\table 100%
-\row
-\li \image gtk-slider.png
- The QSlider widget provides a vertical or horizontal slider.
-\li \image gtk-combobox.png
- The QComboBox widget is a combined button and pop-up list.
-\li \image gtk-spinbox.png
- The QSpinBox class provides a spin box widget.
-\endtable
-
-\table 100%
-\row
-\li \image gtk-fontcombobox.png
- The QFontComboBox widget is a specialized combobox that enables fonts to be selected from a pop-up list containing previews of available fonts.
-\li \image gtk-doublespinbox.png
- The QDoubleSpinBox class provides a spin box widget that allows double precision floating point numbers to be entered.
-\li \image gtk-horizontalscrollbar.png
- The QScrollBar widget provides a vertical or horizontal scroll bar. Here, we show a scroll bar with horizontal orientation.
-\endtable
-
-\table 100%
-\row
-\li \image gtk-dial.png
- The QDial class provides a rounded range control (like a speedometer or potentiometer).
-\li \image gtk-textedit.png
- The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
-\li \image gtk-calendarwidget.png
- The QCalendarWidget class provides a monthly calendar widget that can be used to select dates.
-\endtable
-*/
diff --git a/src/widgets/doc/src/widgets-and-layouts/gallery.qdoc b/src/widgets/doc/src/widgets-and-layouts/gallery.qdoc
index cc6446b8a5..c32eceb558 100644
--- a/src/widgets/doc/src/widgets-and-layouts/gallery.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/gallery.qdoc
@@ -54,10 +54,6 @@
\caption \l{Macintosh Style Widget Gallery}
The Macintosh style is provided by QMacStyle.
- \li \image gtk-tabwidget.png GTK Style Widget Gallery
- \caption \l{GTK Style Widget Gallery}
-
- The GTK style is provided by QGtkStyle.
\li \image fusion-tabwidget.png Fusion Style Widget Gallery
\caption \l{Fusion Style Widget Gallery}
diff --git a/src/widgets/doc/src/widgets-and-layouts/styles.qdoc b/src/widgets/doc/src/widgets-and-layouts/styles.qdoc
index 0a5a079969..74a5ce3189 100644
--- a/src/widgets/doc/src/widgets-and-layouts/styles.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/styles.qdoc
@@ -38,7 +38,7 @@
native widgets.
Qt comes with a selection of built-in styles. Some styles are only
- available on specific platforms (such as the Mac, GTK+ and Windows
+ available on specific platforms (such as the Mac and Windows
Vista styles). Custom styles are made available as plugins or by
creating an instance of a specific style class with
QStyleFactory::create() and setting it with QApplication::setStyle().
diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
index 0547c4f64a..8f0f0f32c7 100644
--- a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
+++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc
@@ -492,9 +492,9 @@
\section1 Inheritance
In classic CSS, when font and color of an item is not explicitly set,
- it gets automatically inherited from the parent. When using Qt Style Sheets,
- a widget does \b{not} automatically inherit its font and color setting
- from its parent widget.
+ it gets automatically inherited from the parent. By default, when using
+ Qt Style Sheets, a widget does \b{not} automatically inherit its font
+ and color setting from its parent widget.
For example, consider a QPushButton inside a QGroupBox:
@@ -507,9 +507,23 @@
\snippet code/doc_src_stylesheet.cpp 25
- In contrast, setting a font and propagate using QWidget::setFont() and
+ In contrast, setting a font and palette using QWidget::setFont() and
QWidget::setPalette() propagates to child widgets.
+ If you would prefer that the font and palette propagate to child widgets,
+ you can set the Qt::AA_UseStyleSheetPropagationInWidgetStyles flag, like
+ this:
+
+ Usage:
+ \snippet code/doc_src_stylesheet.cpp 96
+
+ When the widget-style font and palette propagation is enabled, font and
+ palette changes made through Qt Style Sheets will behave as though the
+ user had manually called the corresponding QWidget::setPalette() and
+ QWidget::setFont() methods on all of the QWidgets targeted by the style
+ sheet. If this would have caused propagation in C++, it will cause
+ propagation in style sheets and visa versa.
+
\section1 Widgets Inside C++ Namespaces
The Type Selector can be used to style widgets of a particular type. For
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index ad58aeb488..df810064c7 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -232,6 +232,7 @@
#include <QtGui/qpainter.h>
#include <QtGui/qpixmapcache.h>
#include <QtGui/qpolygon.h>
+#include <QtGui/qtouchdevice.h>
#include <QtWidgets/qstyleoption.h>
#include <QtWidgets/qtooltip.h>
#include <QtGui/qtransform.h>
diff --git a/src/widgets/itemviews/qfileiconprovider.cpp b/src/widgets/itemviews/qfileiconprovider.cpp
index f43bcd5d5a..18b9755477 100644
--- a/src/widgets/itemviews/qfileiconprovider.cpp
+++ b/src/widgets/itemviews/qfileiconprovider.cpp
@@ -52,10 +52,6 @@
# endif
#endif
-#if defined(Q_OS_UNIX) && !defined(QT_NO_STYLE_GTK)
-# include <private/qgtkstyle_p_p.h>
-#endif
-
QT_BEGIN_NAMESPACE
static bool isCacheable(const QFileInfo &fi);
@@ -358,15 +354,6 @@ QIcon QFileIconProvider::icon(const QFileInfo &info) const
{
Q_D(const QFileIconProvider);
-#if defined(Q_OS_UNIX) && !defined(QT_NO_STYLE_GTK)
- const QByteArray desktopEnvironment = QGuiApplicationPrivate::platformIntegration()->services()->desktopEnvironment();
- if (desktopEnvironment != QByteArrayLiteral("KDE")) {
- QIcon gtkIcon = QGtkStylePrivate::getFilesystemIcon(info);
- if (!gtkIcon.isNull())
- return gtkIcon;
- }
-#endif
-
QIcon retIcon = d->getIcon(info);
if (!retIcon.isNull())
return retIcon;
diff --git a/src/widgets/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp
index e966c83fe7..701e7ab79b 100644
--- a/src/widgets/itemviews/qitemeditorfactory.cpp
+++ b/src/widgets/itemviews/qitemeditorfactory.cpp
@@ -47,6 +47,7 @@
#include <qapplication.h>
#include <qdebug.h>
+#include <algorithm>
QT_BEGIN_NAMESPACE
@@ -202,7 +203,7 @@ void QItemEditorFactory::registerEditor(int userType, QItemEditorCreatorBase *cr
QItemEditorCreatorBase *oldCreator = it.value();
Q_ASSERT(oldCreator);
creatorMap.erase(it);
- if (!creatorMap.values().contains(oldCreator))
+ if (std::find(creatorMap.cbegin(), creatorMap.cend(), oldCreator) == creatorMap.cend())
delete oldCreator; // if it is no more in use we can delete it
}
diff --git a/src/widgets/kernel/mac.pri b/src/widgets/kernel/mac.pri
index 4c507ae80e..129fdebe1b 100644
--- a/src/widgets/kernel/mac.pri
+++ b/src/widgets/kernel/mac.pri
@@ -1,4 +1,4 @@
-!x11:mac:!ios {
- LIBS_PRIVATE += -framework Carbon -framework Cocoa -lz
+!x11:osx {
+ LIBS_PRIVATE += -framework Carbon -framework AppKit -lz
*-mwerks:INCLUDEPATH += compat
}
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 148ed61424..7b51028e6e 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -65,6 +65,7 @@
#include <QtGui/qstylehints.h>
#include <QtGui/qinputmethod.h>
#include <QtGui/private/qwindow_p.h>
+#include <QtGui/qtouchdevice.h>
#include <qpa/qplatformtheme.h>
#ifndef QT_NO_WHATSTHIS
#include <QtWidgets/QWhatsThis>
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index a006246454..a4335e1f2d 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -1957,11 +1957,14 @@ void QWidgetPrivate::propagatePaletteChange()
}
int mask = data.pal.resolve() | inheritedPaletteResolveMask;
+ const bool useStyleSheetPropagationInWidgetStyles =
+ QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles);
+
QEvent pc(QEvent::PaletteChange);
QApplication::sendEvent(q, &pc);
for (int i = 0; i < children.size(); ++i) {
QWidget *w = qobject_cast<QWidget*>(children.at(i));
- if (w && !w->testAttribute(Qt::WA_StyleSheet)
+ if (w && (!w->testAttribute(Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles)
&& (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))) {
QWidgetPrivate *wd = w->d_func();
wd->inheritedPaletteResolveMask = mask;
@@ -4546,15 +4549,19 @@ void QWidget::setPalette(const QPalette &palette)
QPalette QWidgetPrivate::naturalWidgetPalette(uint inheritedMask) const
{
Q_Q(const QWidget);
+
+ const bool useStyleSheetPropagationInWidgetStyles =
+ QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles);
+
QPalette naturalPalette = QApplication::palette(q);
- if (!q->testAttribute(Qt::WA_StyleSheet)
+ if ((!q->testAttribute(Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles)
&& (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation)
#ifndef QT_NO_GRAPHICSVIEW
|| (extra && extra->proxyWidget)
#endif //QT_NO_GRAPHICSVIEW
)) {
if (QWidget *p = q->parentWidget()) {
- if (!p->testAttribute(Qt::WA_StyleSheet)) {
+ if (!p->testAttribute(Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles) {
if (!naturalPalette.isCopyOf(QApplication::palette())) {
QPalette inheritedPalette = p->palette();
inheritedPalette.resolve(inheritedMask);
@@ -4690,15 +4697,19 @@ void QWidget::setFont(const QFont &font)
QFont QWidgetPrivate::naturalWidgetFont(uint inheritedMask) const
{
Q_Q(const QWidget);
+
+ const bool useStyleSheetPropagationInWidgetStyles =
+ QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles);
+
QFont naturalFont = QApplication::font(q);
- if (!q->testAttribute(Qt::WA_StyleSheet)
+ if ((!q->testAttribute(Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles)
&& (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation)
#ifndef QT_NO_GRAPHICSVIEW
|| (extra && extra->proxyWidget)
#endif //QT_NO_GRAPHICSVIEW
)) {
if (QWidget *p = q->parentWidget()) {
- if (!p->testAttribute(Qt::WA_StyleSheet)) {
+ if (!p->testAttribute(Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles) {
if (!naturalFont.isCopyOf(QApplication::font())) {
QFont inheritedFont = p->font();
inheritedFont.resolve(inheritedMask);
@@ -4750,6 +4761,8 @@ void QWidgetPrivate::updateFont(const QFont &font)
#ifndef QT_NO_STYLE_STYLESHEET
const QStyleSheetStyle* cssStyle;
cssStyle = extra ? qobject_cast<const QStyleSheetStyle*>(extra->style) : 0;
+ const bool useStyleSheetPropagationInWidgetStyles =
+ QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles);
#endif
data.fnt = QFont(font, q);
@@ -4774,7 +4787,7 @@ void QWidgetPrivate::updateFont(const QFont &font)
if (w) {
if (0) {
#ifndef QT_NO_STYLE_STYLESHEET
- } else if (w->testAttribute(Qt::WA_StyleSheet)) {
+ } else if (!useStyleSheetPropagationInWidgetStyles && w->testAttribute(Qt::WA_StyleSheet)) {
// Style sheets follow a different font propagation scheme.
if (cssStyle)
cssStyle->updateStyleSheetFont(w);
@@ -4789,7 +4802,7 @@ void QWidgetPrivate::updateFont(const QFont &font)
}
#ifndef QT_NO_STYLE_STYLESHEET
- if (cssStyle) {
+ if (!useStyleSheetPropagationInWidgetStyles && cssStyle) {
cssStyle->updateStyleSheetFont(q);
}
#endif
@@ -5143,9 +5156,9 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset,
d->render(target, targetOffset, toBePainted, renderFlags);
// Restore system clip, viewport and transform.
- enginePriv->systemClip = oldSystemClip;
enginePriv->setSystemViewport(oldSystemViewport);
enginePriv->setSystemTransform(oldTransform);
+ enginePriv->systemClip = oldSystemClip;
// Restore shared painter.
d->setSharedPainter(oldPainter);
@@ -10449,7 +10462,11 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
d->reparentFocusWidgets(oldtlw);
setAttribute(Qt::WA_Resized, resized);
- if (!testAttribute(Qt::WA_StyleSheet)
+
+ const bool useStyleSheetPropagationInWidgetStyles =
+ QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles);
+
+ if (!useStyleSheetPropagationInWidgetStyles && !testAttribute(Qt::WA_StyleSheet)
&& (!parent || !parent->testAttribute(Qt::WA_StyleSheet))) {
d->resolveFont();
d->resolvePalette();
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index a194993328..e3c40ef95e 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -283,7 +283,7 @@ bool QWidgetWindow::event(QEvent *event)
case QEvent::ContextMenu:
handleContextMenuEvent(static_cast<QContextMenuEvent *>(event));
return true;
-#endif
+#endif // QT_NO_CONTEXTMENU
// Handing show events to widgets (see below) here would cause them to be triggered twice
case QEvent::Show:
@@ -510,8 +510,12 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
popupEvent = popupChild;
QContextMenuEvent e(QContextMenuEvent::Mouse, mapped, event->globalPos(), event->modifiers());
QApplication::sendSpontaneousEvent(popupEvent, &e);
-#endif
}
+#else
+ Q_UNUSED(contextMenuTrigger)
+ Q_UNUSED(oldOpenPopupCount)
+ }
+#endif
if (releaseAfter) {
qt_button_down = 0;
diff --git a/src/widgets/styles/qgtk2painter.cpp b/src/widgets/styles/qgtk2painter.cpp
deleted file mode 100644
index ea8afbc93c..0000000000
--- a/src/widgets/styles/qgtk2painter.cpp
+++ /dev/null
@@ -1,699 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgtk2painter_p.h"
-
-#include <QtCore/qglobal.h>
-#if !defined(QT_NO_STYLE_GTK)
-
-// This class is primarily a wrapper around the gtk painter functions
-// and takes care of converting all such calls into cached Qt pixmaps.
-
-#include <private/qgtkstyle_p_p.h>
-#include <private/qhexstring_p.h>
-#include <QtWidgets/QWidget>
-#include <QtGui/QPixmapCache>
-#include <QtCore/QLibrary>
-
-QT_BEGIN_NAMESPACE
-
-typedef GdkPixbuf* (*Ptr_gdk_pixbuf_get_from_drawable) (GdkPixbuf *, GdkDrawable *, GdkColormap *, int, int, int, int, int, int);
-typedef GdkPixmap* (*Ptr_gdk_pixmap_new) (GdkDrawable *, gint, gint, gint);
-typedef void (*Ptr_gdk_draw_rectangle) (GdkDrawable *, GdkGC *, gboolean, gint, gint, gint, gint);
-typedef void (*Ptr_gdk_drawable_unref)(GdkDrawable *);
-
-typedef void (*Ptr_gtk_paint_check) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_box) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_box_gap) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint , gint, GtkPositionType, gint, gint);
-typedef void (*Ptr_gtk_paint_resize_grip) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, GdkWindowEdge, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_focus) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_shadow) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_slider) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint, GtkOrientation);
-typedef void (*Ptr_gtk_paint_expander) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , GtkExpanderStyle );
-typedef void (*Ptr_gtk_paint_handle) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint, GtkOrientation);
-typedef void (*Ptr_gtk_paint_arrow) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, GtkArrowType, gboolean, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_option) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_flat_box) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_extension) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint, gint, GtkPositionType);
-typedef void (*Ptr_gtk_paint_hline) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint y);
-typedef void (*Ptr_gtk_paint_vline) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint);
-
-namespace QGtk2PainterPrivate {
- static Ptr_gdk_pixmap_new gdk_pixmap_new = 0;
- static Ptr_gdk_pixbuf_get_from_drawable gdk_pixbuf_get_from_drawable = 0;
- static Ptr_gdk_draw_rectangle gdk_draw_rectangle = 0;
- static Ptr_gdk_drawable_unref gdk_drawable_unref = 0;
-
- static Ptr_gtk_paint_check gtk_paint_check = 0;
- static Ptr_gtk_paint_box gtk_paint_box = 0;
- static Ptr_gtk_paint_box_gap gtk_paint_box_gap = 0;
- static Ptr_gtk_paint_flat_box gtk_paint_flat_box = 0;
- static Ptr_gtk_paint_option gtk_paint_option = 0;
- static Ptr_gtk_paint_extension gtk_paint_extension = 0;
- static Ptr_gtk_paint_slider gtk_paint_slider = 0;
- static Ptr_gtk_paint_shadow gtk_paint_shadow = 0;
- static Ptr_gtk_paint_resize_grip gtk_paint_resize_grip = 0;
- static Ptr_gtk_paint_focus gtk_paint_focus = 0;
- static Ptr_gtk_paint_arrow gtk_paint_arrow = 0;
- static Ptr_gtk_paint_handle gtk_paint_handle = 0;
- static Ptr_gtk_paint_expander gtk_paint_expander = 0;
- static Ptr_gtk_paint_vline gtk_paint_vline = 0;
- static Ptr_gtk_paint_hline gtk_paint_hline = 0;
-}
-
-static void initGtk()
-{
-#ifndef QT_NO_LIBRARY
- static bool initialized = false;
- if (!initialized) {
- // enforce the "0" suffix, so we'll open libgtk-x11-2.0.so.0
- QLibrary libgtk(QLS("gtk-x11-2.0"), 0, 0);
-
- QGtk2PainterPrivate::gdk_pixmap_new = (Ptr_gdk_pixmap_new)libgtk.resolve("gdk_pixmap_new");
- QGtk2PainterPrivate::gdk_pixbuf_get_from_drawable = (Ptr_gdk_pixbuf_get_from_drawable)libgtk.resolve("gdk_pixbuf_get_from_drawable");
- QGtk2PainterPrivate::gdk_draw_rectangle = (Ptr_gdk_draw_rectangle)libgtk.resolve("gdk_draw_rectangle");
- QGtk2PainterPrivate::gdk_drawable_unref = (Ptr_gdk_drawable_unref)libgtk.resolve("gdk_drawable_unref");
-
- QGtk2PainterPrivate::gtk_paint_check = (Ptr_gtk_paint_check)libgtk.resolve("gtk_paint_check");
- QGtk2PainterPrivate::gtk_paint_box = (Ptr_gtk_paint_box)libgtk.resolve("gtk_paint_box");
- QGtk2PainterPrivate::gtk_paint_flat_box = (Ptr_gtk_paint_flat_box)libgtk.resolve("gtk_paint_flat_box");
- QGtk2PainterPrivate::gtk_paint_check = (Ptr_gtk_paint_check)libgtk.resolve("gtk_paint_check");
- QGtk2PainterPrivate::gtk_paint_box = (Ptr_gtk_paint_box)libgtk.resolve("gtk_paint_box");
- QGtk2PainterPrivate::gtk_paint_resize_grip = (Ptr_gtk_paint_resize_grip)libgtk.resolve("gtk_paint_resize_grip");
- QGtk2PainterPrivate::gtk_paint_focus = (Ptr_gtk_paint_focus)libgtk.resolve("gtk_paint_focus");
- QGtk2PainterPrivate::gtk_paint_shadow = (Ptr_gtk_paint_shadow)libgtk.resolve("gtk_paint_shadow");
- QGtk2PainterPrivate::gtk_paint_slider = (Ptr_gtk_paint_slider)libgtk.resolve("gtk_paint_slider");
- QGtk2PainterPrivate::gtk_paint_expander = (Ptr_gtk_paint_expander)libgtk.resolve("gtk_paint_expander");
- QGtk2PainterPrivate::gtk_paint_handle = (Ptr_gtk_paint_handle)libgtk.resolve("gtk_paint_handle");
- QGtk2PainterPrivate::gtk_paint_option = (Ptr_gtk_paint_option)libgtk.resolve("gtk_paint_option");
- QGtk2PainterPrivate::gtk_paint_arrow = (Ptr_gtk_paint_arrow)libgtk.resolve("gtk_paint_arrow");
- QGtk2PainterPrivate::gtk_paint_box_gap = (Ptr_gtk_paint_box_gap)libgtk.resolve("gtk_paint_box_gap");
- QGtk2PainterPrivate::gtk_paint_extension = (Ptr_gtk_paint_extension)libgtk.resolve("gtk_paint_extension");
- QGtk2PainterPrivate::gtk_paint_hline = (Ptr_gtk_paint_hline)libgtk.resolve("gtk_paint_hline");
- QGtk2PainterPrivate::gtk_paint_vline = (Ptr_gtk_paint_vline)libgtk.resolve("gtk_paint_vline");
-
- initialized = true;
- }
-#endif // !QT_NO_LIBRARY
-}
-
-// To recover alpha we apply the gtk painting function two times to
-// white, and black window backgrounds. This can be used to
-// recover the premultiplied alpha channel
-QPixmap QGtk2Painter::renderTheme(uchar *bdata, uchar *wdata, const QRect &rect) const
-{
- const int bytecount = rect.width() * rect.height() * 4;
- for (int index = 0; index < bytecount ; index += 4) {
- uchar val = bdata[index + GTK_BLUE];
- if (m_alpha) {
- int alphaval = qMax(bdata[index + GTK_BLUE] - wdata[index + GTK_BLUE],
- bdata[index + GTK_GREEN] - wdata[index + GTK_GREEN]);
- alphaval = qMax(alphaval, bdata[index + GTK_RED] - wdata[index + GTK_RED]) + 255;
- bdata[index + QT_ALPHA] = alphaval;
- }
- bdata[index + QT_RED] = bdata[index + GTK_RED];
- bdata[index + QT_GREEN] = bdata[index + GTK_GREEN];
- bdata[index + QT_BLUE] = val;
- }
- QImage converted((const uchar*)bdata, rect.width(), rect.height(), m_alpha ?
- QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32);
-
- if (m_hflipped || m_vflipped) {
- return QPixmap::fromImage(converted.mirrored(m_hflipped, m_vflipped));
- } else {
- // on raster graphicssystem we need to do a copy here, because
- // we intend to deallocate the qimage bits shortly after...
- return QPixmap::fromImage(converted.copy());
- }
-}
-
-// This macro is responsible for painting any GtkStyle painting function onto a QPixmap
-#define DRAW_TO_CACHE(draw_func) \
- if (rect.width() > QWIDGETSIZE_MAX || rect.height() > QWIDGETSIZE_MAX) \
- return; \
- QRect pixmapRect(0, 0, rect.width(), rect.height()); \
- { \
- GdkPixmap *pixmap = QGtk2PainterPrivate::gdk_pixmap_new((GdkDrawable*)(m_window->window), \
- rect.width(), rect.height(), -1); \
- if (!pixmap) \
- return; \
- style = QGtkStylePrivate::gtk_style_attach (style, m_window->window); \
- QGtk2PainterPrivate::gdk_draw_rectangle(pixmap, m_alpha ? style->black_gc : *style->bg_gc, \
- true, 0, 0, rect.width(), rect.height()); \
- draw_func; \
- GdkPixbuf *imgb = QGtkStylePrivate::gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, \
- rect.width(), rect.height()); \
- if (!imgb) \
- return; \
- imgb = QGtk2PainterPrivate::gdk_pixbuf_get_from_drawable(imgb, pixmap, NULL, 0, 0, 0, 0, \
- rect.width(), rect.height()); \
- uchar* bdata = (uchar*)QGtkStylePrivate::gdk_pixbuf_get_pixels(imgb); \
- if (m_alpha) { \
- QGtk2PainterPrivate::gdk_draw_rectangle(pixmap, style->white_gc, true, 0, 0, \
- rect.width(), rect.height()); \
- draw_func; \
- GdkPixbuf *imgw = QGtkStylePrivate::gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, \
- rect.width(), rect.height()); \
- if (!imgw) \
- return; \
- imgw = QGtk2PainterPrivate::gdk_pixbuf_get_from_drawable(imgw, pixmap, NULL, 0, 0, 0, 0,\
- rect.width(), rect.height()); \
- uchar* wdata = (uchar*)QGtkStylePrivate::gdk_pixbuf_get_pixels(imgw); \
- cache = renderTheme(bdata, wdata, rect); \
- QGtkStylePrivate::gdk_pixbuf_unref(imgw); \
- } else { \
- cache = renderTheme(bdata, 0, rect); \
- } \
- QGtk2PainterPrivate::gdk_drawable_unref(pixmap); \
- QGtkStylePrivate::gdk_pixbuf_unref(imgb); \
- }
-
-QGtk2Painter::QGtk2Painter() : QGtkPainter(), m_window(QGtkStylePrivate::gtkWidget("GtkWindow"))
-{
- initGtk();
-}
-
-// Note currently painted without alpha for performance reasons
-void QGtk2Painter::paintBoxGap(GtkWidget *gtkWidget, const gchar* part,
- const QRect &paintRect, GtkStateType state,
- GtkShadowType shadow, GtkPositionType gap_side,
- gint x, gint width,
- GtkStyle *style)
-{
- if (!paintRect.isValid())
- return;
-
- QPixmap cache;
- QRect rect = paintRect;
-
- // To avoid exhausting cache on large tabframes we cheat a bit by
- // tiling the center part.
-
- const int maxHeight = 256;
- const int border = 16;
- if (rect.height() > maxHeight && (gap_side == GTK_POS_TOP || gap_side == GTK_POS_BOTTOM))
- rect.setHeight(2 * border + 1);
-
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget)
- % HexString<uchar>(gap_side)
- % HexString<gint>(width)
- % HexString<gint>(x);
-
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_box_gap (style,
- pixmap,
- state,
- shadow,
- NULL,
- gtkWidget,
- (const gchar*)part,
- 0, 0,
- rect.width(),
- rect.height(),
- gap_side,
- x,
- width));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
- if (rect.size() != paintRect.size()) {
- // We assume we can stretch the middle tab part
- // Note: the side effect of this is that pinstripe patterns will get fuzzy
- const QSize size = cache.size();
- // top part
- m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top(),
- paintRect.width(), border), cache,
- QRect(0, 0, size.width(), border));
-
- // tiled center part
- QPixmap tilePart(cache.width(), 1);
- QPainter scanLinePainter(&tilePart);
- scanLinePainter.drawPixmap(QRect(0, 0, tilePart.width(), tilePart.height()), cache, QRect(0, border, size.width(), 1));
- scanLinePainter.end();
- m_painter->drawTiledPixmap(QRect(paintRect.left(), paintRect.top() + border,
- paintRect.width(), paintRect.height() - 2*border), tilePart);
-
- // bottom part
- m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top() + paintRect.height() - border,
- paintRect.width(), border), cache,
- QRect(0, size.height() - border, size.width(), border));
- } else
- m_painter->drawPixmap(paintRect.topLeft(), cache);
-}
-
-void QGtk2Painter::paintBox(GtkWidget *gtkWidget, const gchar* part,
- const QRect &paintRect, GtkStateType state,
- GtkShadowType shadow, GtkStyle *style,
- const QString &pmKey)
-{
- if (!paintRect.isValid())
- return;
-
- QPixmap cache;
- QRect rect = paintRect;
-
- // To avoid exhausting cache on large tabframes we cheat a bit by
- // tiling the center part.
-
- const int maxHeight = 256;
- const int maxArea = 256*512;
- const int border = 32;
- if (rect.height() > maxHeight && (rect.width()*rect.height() > maxArea))
- rect.setHeight(2 * border + 1);
-
- QString pixmapName = uniqueName(QLS(part), state, shadow,
- rect.size(), gtkWidget) % pmKey;
-
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_box (style,
- pixmap,
- state,
- shadow,
- NULL,
- gtkWidget,
- part,
- 0, 0,
- rect.width(),
- rect.height()));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
- if (rect.size() != paintRect.size()) {
- // We assume we can stretch the middle tab part
- // Note: the side effect of this is that pinstripe patterns will get fuzzy
- const QSize size = cache.size();
- // top part
- m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top(),
- paintRect.width(), border), cache,
- QRect(0, 0, size.width(), border));
-
- // tiled center part
- QPixmap tilePart(cache.width(), 1);
- QPainter scanLinePainter(&tilePart);
- scanLinePainter.drawPixmap(QRect(0, 0, tilePart.width(), tilePart.height()), cache, QRect(0, border, size.width(), 1));
- scanLinePainter.end();
- m_painter->drawTiledPixmap(QRect(paintRect.left(), paintRect.top() + border,
- paintRect.width(), paintRect.height() - 2*border), tilePart);
-
- // bottom part
- m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top() + paintRect.height() - border,
- paintRect.width(), border), cache,
- QRect(0, size.height() - border, size.width(), border));
- } else
- m_painter->drawPixmap(paintRect.topLeft(), cache);
-}
-
-void QGtk2Painter::paintHline(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state,
- GtkStyle *style, int x1, int x2, int y,
- const QString &pmKey)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
- % HexString<int>(x1)
- % HexString<int>(x2)
- % HexString<int>(y)
- % pmKey;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_hline (style,
- pixmap,
- state,
- NULL,
- gtkWidget,
- part,
- x1, x2, y));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-void QGtk2Painter::paintVline(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state,
- GtkStyle *style, int y1, int y2, int x,
- const QString &pmKey)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
- % HexString<int>(y1)
- % HexString<int>(y2)
- % HexString<int>(x)
- % pmKey;
-
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_vline (style,
- pixmap,
- state,
- NULL,
- gtkWidget,
- part,
- y1, y2,
- x));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-
-void QGtk2Painter::paintExpander(GtkWidget *gtkWidget,
- const gchar* part, const QRect &rect,
- GtkStateType state, GtkExpanderStyle expander_state,
- GtkStyle *style, const QString &pmKey)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
- % HexString<uchar>(expander_state)
- % pmKey;
-
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_expander (style, pixmap,
- state, NULL,
- gtkWidget, part,
- rect.width()/2,
- rect.height()/2,
- expander_state));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-void QGtk2Painter::paintFocus(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state,
- GtkStyle *style, const QString &pmKey)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget) % pmKey;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_focus (style, pixmap, state, NULL,
- gtkWidget,
- part,
- 0, 0,
- rect.width(),
- rect.height()));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-
-void QGtk2Painter::paintResizeGrip(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state,
- GtkShadowType shadow, GdkWindowEdge edge,
- GtkStyle *style, const QString &pmKey)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) % pmKey;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_resize_grip (style, pixmap, state,
- NULL, gtkWidget,
- part, edge, 0, 0,
- rect.width(),
- rect.height()));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-
-void QGtk2Painter::paintArrow(GtkWidget *gtkWidget, const gchar* part,
- const QRect &arrowrect, GtkArrowType arrow_type,
- GtkStateType state, GtkShadowType shadow,
- gboolean fill, GtkStyle *style, const QString &pmKey)
-{
- QRect rect = m_cliprect.isValid() ? m_cliprect : arrowrect;
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size())
- % HexString<uchar>(arrow_type)
- % pmKey;
-
- GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
- int xOffset = m_cliprect.isValid() ? arrowrect.x() - m_cliprect.x() : 0;
- int yOffset = m_cliprect.isValid() ? arrowrect.y() - m_cliprect.y() : 0;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_arrow (style, pixmap, state, shadow,
- &gtkCliprect,
- gtkWidget,
- part,
- arrow_type, fill,
- xOffset, yOffset,
- arrowrect.width(),
- arrowrect.height()))
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-
-void QGtk2Painter::paintHandle(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
- GtkStateType state, GtkShadowType shadow,
- GtkOrientation orientation, GtkStyle *style)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size())
- % HexString<uchar>(orientation);
-
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_handle (style,
- pixmap,
- state,
- shadow,
- NULL,
- gtkWidget,
- part, 0, 0,
- rect.width(),
- rect.height(),
- orientation));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-
-void QGtk2Painter::paintSlider(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
- GtkStateType state, GtkShadowType shadow,
- GtkStyle *style, GtkOrientation orientation,
- const QString &pmKey)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) % pmKey;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_slider (style,
- pixmap,
- state,
- shadow,
- NULL,
- gtkWidget,
- part,
- 0, 0,
- rect.width(),
- rect.height(),
- orientation));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-
-void QGtk2Painter::paintShadow(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state,
- GtkShadowType shadow, GtkStyle *style,
- const QString &pmKey)
-
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_shadow(style, pixmap, state, shadow, NULL,
- gtkWidget, part, 0, 0, rect.width(), rect.height()));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-void QGtk2Painter::paintFlatBox(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state,
- GtkShadowType shadow, GtkStyle *style,
- const QString &pmKey)
-{
- if (!rect.isValid())
- return;
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_flat_box (style,
- pixmap,
- state,
- shadow,
- NULL,
- gtkWidget,
- part, 0, 0,
- rect.width(),
- rect.height()));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-void QGtk2Painter::paintExtention(GtkWidget *gtkWidget,
- const gchar *part, const QRect &rect,
- GtkStateType state, GtkShadowType shadow,
- GtkPositionType gap_pos, GtkStyle *style)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget)
- % HexString<uchar>(gap_pos);
-
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_extension (style, pixmap, state, shadow,
- NULL, gtkWidget,
- (const gchar*)part, 0, 0,
- rect.width(),
- rect.height(),
- gap_pos));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-void QGtk2Painter::paintOption(GtkWidget *gtkWidget, const QRect &radiorect,
- GtkStateType state, GtkShadowType shadow,
- GtkStyle *style, const QString &detail)
-
-{
- QRect rect = m_cliprect.isValid() ? m_cliprect : radiorect;
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(detail, state, shadow, rect.size());
- GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
- int xOffset = m_cliprect.isValid() ? radiorect.x() - m_cliprect.x() : 0;
- int yOffset = m_cliprect.isValid() ? radiorect.y() - m_cliprect.y() : 0;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_option(style, pixmap,
- state, shadow,
- &gtkCliprect,
- gtkWidget,
- detail.toLatin1(),
- xOffset, yOffset,
- radiorect.width(),
- radiorect.height()));
-
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-void QGtk2Painter::paintCheckbox(GtkWidget *gtkWidget, const QRect &checkrect,
- GtkStateType state, GtkShadowType shadow,
- GtkStyle *style, const QString &detail)
-
-{
- QRect rect = m_cliprect.isValid() ? m_cliprect : checkrect;
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(detail, state, shadow, rect.size());
- GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
- int xOffset = m_cliprect.isValid() ? checkrect.x() - m_cliprect.x() : 0;
- int yOffset = m_cliprect.isValid() ? checkrect.y() - m_cliprect.y() : 0;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk2PainterPrivate::gtk_paint_check (style,
- pixmap,
- state,
- shadow,
- &gtkCliprect,
- gtkWidget,
- detail.toLatin1(),
- xOffset, yOffset,
- checkrect.width(),
- checkrect.height()));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-QT_END_NAMESPACE
-
-#endif //!defined(QT_NO_STYLE_GTK)
diff --git a/src/widgets/styles/qgtk2painter_p.h b/src/widgets/styles/qgtk2painter_p.h
deleted file mode 100644
index 1e489b5bf9..0000000000
--- a/src/widgets/styles/qgtk2painter_p.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGTK2PAINTER_P_H
-#define QGTK2PAINTER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qglobal.h>
-#if !defined(QT_NO_STYLE_GTK)
-
-#include <private/qgtkpainter_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGtk2Painter : public QGtkPainter
-{
-public:
- QGtk2Painter();
-
- void paintBoxGap(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
- GtkStateType state, GtkShadowType shadow, GtkPositionType gap_side, gint x,
- gint width, GtkStyle *style) Q_DECL_OVERRIDE;
- void paintBox(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style,
- const QString &pmKey = QString()) Q_DECL_OVERRIDE;
- void paintHline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
- int x1, int x2, int y, const QString &pmKey = QString()) Q_DECL_OVERRIDE;
- void paintVline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
- int y1, int y2, int x, const QString &pmKey = QString()) Q_DECL_OVERRIDE;
- void paintExpander(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state,
- GtkExpanderStyle expander_state, GtkStyle *style, const QString &pmKey = QString()) Q_DECL_OVERRIDE;
- void paintFocus(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
- const QString &pmKey = QString()) Q_DECL_OVERRIDE;
- void paintResizeGrip(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
- GdkWindowEdge edge, GtkStyle *style, const QString &pmKey = QString()) Q_DECL_OVERRIDE;
- void paintArrow(GtkWidget *gtkWidget, const gchar* part, const QRect &arrowrect, GtkArrowType arrow_type, GtkStateType state, GtkShadowType shadow,
- gboolean fill, GtkStyle *style, const QString &pmKey = QString()) Q_DECL_OVERRIDE;
- void paintHandle(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
- GtkStateType state, GtkShadowType shadow, GtkOrientation orientation, GtkStyle *style) Q_DECL_OVERRIDE;
- void paintSlider(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
- GtkStyle *style, GtkOrientation orientation, const QString &pmKey = QString()) Q_DECL_OVERRIDE;
- void paintShadow(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
- GtkStyle *style, const QString &pmKey = QString()) Q_DECL_OVERRIDE;
- void paintFlatBox(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString & = QString()) Q_DECL_OVERRIDE;
- void paintExtention(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
- GtkPositionType gap_pos, GtkStyle *style) Q_DECL_OVERRIDE;
- void paintOption(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail) Q_DECL_OVERRIDE;
- void paintCheckbox(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail) Q_DECL_OVERRIDE;
-
-private:
- QPixmap renderTheme(uchar *bdata, uchar *wdata, const QRect &rect) const;
-
- GtkWidget *m_window;
-};
-
-QT_END_NAMESPACE
-
-#endif //!defined(QT_NO_STYLE_QGTK)
-
-#endif // QGTK2PAINTER_P_H
diff --git a/src/widgets/styles/qgtkpainter.cpp b/src/widgets/styles/qgtkpainter.cpp
deleted file mode 100644
index e86fee079e..0000000000
--- a/src/widgets/styles/qgtkpainter.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgtkpainter_p.h"
-
-#if !defined(QT_NO_STYLE_GTK)
-
-#include <private/qhexstring_p.h>
-
-QT_BEGIN_NAMESPACE
-
-QGtkPainter::QGtkPainter()
-{
- reset(0);
-}
-
-QGtkPainter::~QGtkPainter()
-{
-}
-
-void QGtkPainter::reset(QPainter *painter)
-{
- m_painter = painter;
- m_alpha = true;
- m_hflipped = false;
- m_vflipped = false;
- m_usePixmapCache = true;
- m_cliprect = QRect();
-}
-
-QString QGtkPainter::uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow,
- const QSize &size, GtkWidget *widget)
-{
- // Note the widget arg should ideally use the widget path, though would compromise performance
- QString tmp = key
- % HexString<uint>(state)
- % HexString<uint>(shadow)
- % HexString<uint>(size.width())
- % HexString<uint>(size.height())
- % HexString<quint64>(quint64(widget));
- return tmp;
-}
-
-QT_END_NAMESPACE
-
-#endif //!defined(QT_NO_STYLE_GTK)
diff --git a/src/widgets/styles/qgtkpainter_p.h b/src/widgets/styles/qgtkpainter_p.h
deleted file mode 100644
index bfe97ccaef..0000000000
--- a/src/widgets/styles/qgtkpainter_p.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGTKPAINTER_H
-#define QGTKPAINTER_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qglobal.h>
-#if !defined(QT_NO_STYLE_GTK)
-
-#include <private/qgtkglobal_p.h>
-#include <QtCore/qsize.h>
-#include <QtCore/qrect.h>
-#include <QtCore/qpoint.h>
-#include <QtGui/qpixmap.h>
-#include <QtGui/qpainter.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGtkPainter
-{
-public:
- QGtkPainter();
- virtual ~QGtkPainter();
-
- void reset(QPainter *painter = 0);
-
- void setAlphaSupport(bool value) { m_alpha = value; }
- void setClipRect(const QRect &rect) { m_cliprect = rect; }
- void setFlipHorizontal(bool value) { m_hflipped = value; }
- void setFlipVertical(bool value) { m_vflipped = value; }
- void setUsePixmapCache(bool value) { m_usePixmapCache = value; }
-
- virtual void paintBoxGap(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
- GtkStateType state, GtkShadowType shadow, GtkPositionType gap_side, gint x,
- gint width, GtkStyle *style) = 0;
- virtual void paintBox(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style,
- const QString &pmKey = QString()) = 0;
- virtual void paintHline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
- int x1, int x2, int y, const QString &pmKey = QString()) = 0;
- virtual void paintVline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
- int y1, int y2, int x, const QString &pmKey = QString()) = 0;
- virtual void paintExpander(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state,
- GtkExpanderStyle expander_state, GtkStyle *style, const QString &pmKey = QString()) = 0;
- virtual void paintFocus(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
- const QString &pmKey = QString()) = 0;
- virtual void paintResizeGrip(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
- GdkWindowEdge edge, GtkStyle *style, const QString &pmKey = QString()) = 0;
- virtual void paintArrow(GtkWidget *gtkWidget, const gchar* part, const QRect &arrowrect, GtkArrowType arrow_type, GtkStateType state, GtkShadowType shadow,
- gboolean fill, GtkStyle *style, const QString &pmKey = QString()) = 0;
- virtual void paintHandle(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
- GtkStateType state, GtkShadowType shadow, GtkOrientation orientation, GtkStyle *style) = 0;
- virtual void paintSlider(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
- GtkStyle *style, GtkOrientation orientation, const QString &pmKey = QString()) = 0;
- virtual void paintShadow(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
- GtkStyle *style, const QString &pmKey = QString()) = 0;
- virtual void paintFlatBox(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString & = QString()) = 0;
- virtual void paintExtention(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
- GtkPositionType gap_pos, GtkStyle *style) = 0;
- virtual void paintOption(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail) = 0;
- virtual void paintCheckbox(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail) = 0;
-
-protected:
- static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow, const QSize &size, GtkWidget *widget = 0);
-
- QPainter *m_painter;
- bool m_alpha;
- bool m_hflipped;
- bool m_vflipped;
- bool m_usePixmapCache;
- QRect m_cliprect;
-};
-
-QT_END_NAMESPACE
-
-#endif //!defined(QT_NO_STYLE_QGTK)
-
-#endif // QGTKPAINTER_H
diff --git a/src/widgets/styles/qgtkstyle.cpp b/src/widgets/styles/qgtkstyle.cpp
deleted file mode 100644
index 7ed0dce91d..0000000000
--- a/src/widgets/styles/qgtkstyle.cpp
+++ /dev/null
@@ -1,4257 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "qgtkstyle_p.h"
-
-#if !defined(QT_NO_STYLE_GTK)
-
-#include <private/qapplication_p.h>
-#include <QtCore/QLibrary>
-#include <QtCore/QSettings>
-#include <QtWidgets/QDialogButtonBox>
-#include <QtWidgets/QStatusBar>
-#include <QtWidgets/QLineEdit>
-#include <QtWidgets/QWidget>
-#include <QtWidgets/QListView>
-#include <QtWidgets/QApplication>
-#include <QtWidgets/QStyleOption>
-#include <QtWidgets/QPushButton>
-#include <QtGui/QPainter>
-#include <QtWidgets/QMainWindow>
-#include <QtWidgets/QToolBar>
-#include <QtWidgets/QHeaderView>
-#include <QtWidgets/QMenuBar>
-#include <QtWidgets/QComboBox>
-#include <QtWidgets/QSpinBox>
-#include <QtWidgets/QScrollBar>
-#include <QtWidgets/QAbstractButton>
-#include <QtWidgets/QToolButton>
-#include <QtWidgets/QGroupBox>
-#include <QtWidgets/QRadioButton>
-#include <QtWidgets/QCheckBox>
-#include <QtWidgets/QTreeView>
-#include <QtWidgets/QStyledItemDelegate>
-#include <QtWidgets/QWizard>
-
-#include <qpixmapcache.h>
-#include <private/qstyleanimation_p.h>
-#undef signals // Collides with GTK stymbols
-#include <private/qgtkpainter_p.h>
-#include <private/qstylehelper_p.h>
-#include <private/qgtkstyle_p_p.h>
-
-QT_BEGIN_NAMESPACE
-
-static GtkStateType qt_gtk_state(const QStyleOption *option)
-{
- GtkStateType state = GTK_STATE_NORMAL;
- if (!(option->state & QStyle::State_Enabled))
- state = GTK_STATE_INSENSITIVE;
- else if (option->state & QStyle::State_MouseOver)
- state = GTK_STATE_PRELIGHT;
-
- return state;
-}
-
-static QPixmap qt_gtk_get_icon(const char* iconName, GtkIconSize size = GTK_ICON_SIZE_BUTTON)
-{
- GtkStyle *style = QGtkStylePrivate::gtkStyle();
- GtkIconSet* iconSet = QGtkStylePrivate::gtk_icon_factory_lookup_default (iconName);
- GdkPixbuf* icon = QGtkStylePrivate::gtk_icon_set_render_icon(iconSet,
- style,
- GTK_TEXT_DIR_LTR,
- GTK_STATE_NORMAL,
- size,
- NULL,
- "button");
- uchar* data = (uchar*)QGtkStylePrivate::gdk_pixbuf_get_pixels(icon);
- int width = QGtkStylePrivate::gdk_pixbuf_get_width(icon);
- int height = QGtkStylePrivate::gdk_pixbuf_get_height(icon);
- QImage converted(width, height, QImage::Format_ARGB32);
- uchar* tdata = (uchar*)converted.bits();
-
- for ( int index = 0 ; index < height * width*4 ; index +=4 ) {
- //int index = y * rowstride + x;
- tdata[index + QT_RED] = data[index + GTK_RED];
- tdata[index + QT_GREEN] = data[index + GTK_GREEN];
- tdata[index + QT_BLUE] = data[index + GTK_BLUE];
- tdata[index + QT_ALPHA] = data[index + GTK_ALPHA];
- }
-
- QGtkStylePrivate::gdk_pixbuf_unref(icon);
-
- // should we free iconset?
- return QPixmap::fromImage(converted);
-}
-
-static void qt_gtk_draw_mdibutton(QPainter *painter, const QStyleOptionTitleBar *option, const QRect &tmp, bool hover, bool sunken)
-{
- QColor dark;
- dark.setHsv(option->palette.button().color().hue(),
- qMin(255, (int)(option->palette.button().color().saturation()*1.9)),
- qMin(255, (int)(option->palette.button().color().value()*0.7)));
-
- QColor highlight = option->palette.highlight().color();
-
- bool active = (option->titleBarState & QStyle::State_Active);
- QColor titleBarHighlight(255, 255, 255, 60);
-
- if (sunken)
- painter->fillRect(tmp.adjusted(1, 1, -1, -1), option->palette.highlight().color().darker(120));
- else if (hover)
- painter->fillRect(tmp.adjusted(1, 1, -1, -1), QColor(255, 255, 255, 20));
-
- QColor mdiButtonGradientStartColor;
- QColor mdiButtonGradientStopColor;
-
- mdiButtonGradientStartColor = QColor(0, 0, 0, 40);
- mdiButtonGradientStopColor = QColor(255, 255, 255, 60);
-
- if (sunken)
- titleBarHighlight = highlight.darker(130);
-
- QLinearGradient gradient(tmp.center().x(), tmp.top(), tmp.center().x(), tmp.bottom());
- gradient.setColorAt(0, mdiButtonGradientStartColor);
- gradient.setColorAt(1, mdiButtonGradientStopColor);
- QColor mdiButtonBorderColor(active ? option->palette.highlight().color().darker(180): dark.darker(110));
-
- painter->setPen(QPen(mdiButtonBorderColor, 1));
- const QLine lines[4] = {
- QLine(tmp.left() + 2, tmp.top(), tmp.right() - 2, tmp.top()),
- QLine(tmp.left() + 2, tmp.bottom(), tmp.right() - 2, tmp.bottom()),
- QLine(tmp.left(), tmp.top() + 2, tmp.left(), tmp.bottom() - 2),
- QLine(tmp.right(), tmp.top() + 2, tmp.right(), tmp.bottom() - 2)
- };
- painter->drawLines(lines, 4);
- const QPoint points[4] = {
- QPoint(tmp.left() + 1, tmp.top() + 1),
- QPoint(tmp.right() - 1, tmp.top() + 1),
- QPoint(tmp.left() + 1, tmp.bottom() - 1),
- QPoint(tmp.right() - 1, tmp.bottom() - 1)
- };
- painter->drawPoints(points, 4);
-
- painter->setPen(titleBarHighlight);
- painter->drawLine(tmp.left() + 2, tmp.top() + 1, tmp.right() - 2, tmp.top() + 1);
- painter->drawLine(tmp.left() + 1, tmp.top() + 2, tmp.left() + 1, tmp.bottom() - 2);
-
- painter->setPen(QPen(gradient, 1));
- painter->drawLine(tmp.right() + 1, tmp.top() + 2, tmp.right() + 1, tmp.bottom() - 2);
- painter->drawPoint(tmp.right() , tmp.top() + 1);
-
- painter->drawLine(tmp.left() + 2, tmp.bottom() + 1, tmp.right() - 2, tmp.bottom() + 1);
- painter->drawPoint(tmp.left() + 1, tmp.bottom());
- painter->drawPoint(tmp.right() - 1, tmp.bottom());
- painter->drawPoint(tmp.right() , tmp.bottom() - 1);
-}
-
-static const char * const dock_widget_close_xpm[] =
- {
- "11 13 5 1",
- " c None",
- ". c #D5CFCB",
- "+ c #6C6A67",
- "@ c #6C6A67",
- "$ c #B5B0AC",
- " ",
- " @@@@@@@@@ ",
- "@+ +@",
- "@ +@ @+ @",
- "@ @@@ @@@ @",
- "@ @@@@@ @",
- "@ @@@ @",
- "@ @@@@@ @",
- "@ @@@ @@@ @",
- "@ +@ @+ @",
- "@+ +@",
- " @@@@@@@@@ ",
- " "
- };
-
-static const char * const dock_widget_restore_xpm[] =
- {
- "11 13 5 1",
- " c None",
- ". c #D5CFCB",
- "+ c #6C6A67",
- "@ c #6C6A67",
- "# c #6C6A67",
- " ",
- " @@@@@@@@@ ",
- "@+ +@",
- "@ #@@@# @",
- "@ @ @ @",
- "@ #@@@# @ @",
- "@ @ @ @ @",
- "@ @ @@@ @",
- "@ @ @ @",
- "@ #@@@@ @",
- "@+ +@",
- " @@@@@@@@@ ",
- " "
- };
-
-static const char * const qt_titlebar_context_help[] = {
- "10 10 3 1",
- " c None",
- "# c #000000",
- "+ c #444444",
- " +####+ ",
- " ### ### ",
- " ## ## ",
- " +##+ ",
- " +## ",
- " ## ",
- " ## ",
- " ",
- " ## ",
- " ## "};
-
-static const char * const qt_scrollbar_button_arrow_up[] = {
- "7 4 2 1",
- " c None",
- "* c #BFBFBF",
- " * ",
- " *** ",
- " ***** ",
- "*******"};
-
-static const char * const qt_scrollbar_button_arrow_down[] = {
- "7 4 2 1",
- " c None",
- "* c #BFBFBF",
- "*******",
- " ***** ",
- " *** ",
- " * "};
-
-static const int groupBoxBottomMargin = 2; // space below the groupbox
-static const int groupBoxTitleMargin = 6; // space between contents and title
-static const int groupBoxTopMargin = 2;
-
-/*!
- Returns the configuration string for \a value.
- Returns \a fallback if \a value is not found.
- */
-QString QGtkStyle::getGConfString(const QString &value, const QString &fallback)
-{
- return QGtkStylePrivate::getGConfString(value, fallback);
-}
-
-/*!
- Returns the configuration boolean for \a key.
- Returns \a fallback if \a key is not found.
- */
-bool QGtkStyle::getGConfBool(const QString &key, bool fallback)
-{
- return QGtkStylePrivate::getGConfBool(key, fallback);
-}
-
-static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50)
-{
- const int maxFactor = 100;
- QColor tmp = colorA;
- tmp.setRed((tmp.red() * factor) / maxFactor + (colorB.red() * (maxFactor - factor)) / maxFactor);
- tmp.setGreen((tmp.green() * factor) / maxFactor + (colorB.green() * (maxFactor - factor)) / maxFactor);
- tmp.setBlue((tmp.blue() * factor) / maxFactor + (colorB.blue() * (maxFactor - factor)) / maxFactor);
- return tmp;
-}
-
-static GdkColor fromQColor(const QColor &color)
-{
- GdkColor retval;
- retval.pixel = 0;
- retval.red = color.red() * 255;
- retval.green = color.green() * 255;
- retval.blue = color.blue() * 255;
- return retval;
-}
-
-/*!
- \class QGtkStyle
- \brief The QGtkStyle class provides a widget style rendered by GTK+
- \since 4.5
-
- \internal
- \inmodule QtWidgets
-
- The QGtkStyle style provides a look and feel that integrates well
- into GTK-based desktop environments such as the XFCe and GNOME.
-
- It does this by making use of the GTK+ theme engine, ensuring
- that Qt applications look and feel native on these platforms.
-
- Note: The style requires GTK+ version 2.18 or later.
- The Qt3-based "Qt" GTK+ theme engine will not work with QGtkStyle.
-
- \sa QWindowsXPStyle, QMacStyle, QWindowsStyle, QFusionStyle
-*/
-
-/*!
- Constructs a QGtkStyle object.
-*/
-QGtkStyle::QGtkStyle()
- : QCommonStyle(*new QGtkStylePrivate)
-{
- Q_D(QGtkStyle);
- d->init();
-}
-
-/*!
- \internal
-
- Constructs a QGtkStyle object.
-*/
-QGtkStyle::QGtkStyle(QGtkStylePrivate &dd)
- : QCommonStyle(dd)
-{
- Q_D(QGtkStyle);
- d->init();
-}
-
-
-/*!
- Destroys the QGtkStyle object.
-*/
-QGtkStyle::~QGtkStyle()
-{
-}
-
-/*!
- \reimp
-*/
-QPalette QGtkStyle::standardPalette() const
-{
- Q_D(const QGtkStyle);
-
- QPalette palette = QCommonStyle::standardPalette();
- if (d->isThemeAvailable()) {
- GtkStyle *style = d->gtkStyle();
- GtkWidget *gtkButton = d->gtkWidget("GtkButton");
- GtkWidget *gtkEntry = d->getTextColorWidget();
- GdkColor gdkBg, gdkBase, gdkText, gdkForeground, gdkSbg, gdkSfg, gdkaSbg, gdkaSfg;
- QColor bg, base, text, fg, highlight, highlightText, inactiveHighlight, inactiveHighlightedTExt;
- gdkBg = style->bg[GTK_STATE_NORMAL];
- gdkForeground = d->gtk_widget_get_style(gtkButton)->fg[GTK_STATE_NORMAL];
-
- // Our base and selected color is primarily used for text
- // so we assume a gtkEntry will have the most correct value
- GtkStyle *gtkEntryStyle = d->gtk_widget_get_style(gtkEntry);
- gdkBase = gtkEntryStyle->base[GTK_STATE_NORMAL];
- gdkText = gtkEntryStyle->text[GTK_STATE_NORMAL];
- gdkSbg = gtkEntryStyle->base[GTK_STATE_SELECTED];
- gdkSfg = gtkEntryStyle->text[GTK_STATE_SELECTED];
-
- // The ACTIVE base color is really used for inactive windows
- gdkaSbg = gtkEntryStyle->base[GTK_STATE_ACTIVE];
- gdkaSfg = gtkEntryStyle->text[GTK_STATE_ACTIVE];
-
- bg = QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
- text = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
- fg = QColor(gdkForeground.red>>8, gdkForeground.green>>8, gdkForeground.blue>>8);
- base = QColor(gdkBase.red>>8, gdkBase.green>>8, gdkBase.blue>>8);
- highlight = QColor(gdkSbg.red>>8, gdkSbg.green>>8, gdkSbg.blue>>8);
- highlightText = QColor(gdkSfg.red>>8, gdkSfg.green>>8, gdkSfg.blue>>8);
- inactiveHighlight = QColor(gdkaSbg.red>>8, gdkaSbg.green>>8, gdkaSbg.blue>>8);
- inactiveHighlightedTExt = QColor(gdkaSfg.red>>8, gdkaSfg.green>>8, gdkaSfg.blue>>8);
-
- palette.setColor(QPalette::HighlightedText, highlightText);
-
-
- palette.setColor(QPalette::Light, bg.lighter(125));
- palette.setColor(QPalette::Shadow, bg.darker(130));
- palette.setColor(QPalette::Dark, bg.darker(120));
- palette.setColor(QPalette::Text, text);
- palette.setColor(QPalette::WindowText, fg);
- palette.setColor(QPalette::ButtonText, fg);
- palette.setColor(QPalette::Base, base);
-
- QColor alternateRowColor = palette.base().color().lighter(93); // ref gtkstyle.c draw_flat_box
- GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView");
- GdkColor *gtkAltBase = NULL;
- d->gtk_widget_style_get(gtkTreeView, "odd-row-color", &gtkAltBase, NULL);
- if (gtkAltBase) {
- alternateRowColor = QColor(gtkAltBase->red>>8, gtkAltBase->green>>8, gtkAltBase->blue>>8);
- d->gdk_color_free(gtkAltBase);
- }
- palette.setColor(QPalette::AlternateBase, alternateRowColor);
-
- palette.setColor(QPalette::Window, bg);
- palette.setColor(QPalette::Button, bg);
- palette.setColor(QPalette::Background, bg);
- QColor disabled((fg.red() + bg.red()) / 2,
- (fg.green() + bg.green())/ 2,
- (fg.blue() + bg.blue()) / 2);
- palette.setColor(QPalette::Disabled, QPalette::Text, disabled);
- palette.setColor(QPalette::Disabled, QPalette::WindowText, disabled);
- palette.setColor(QPalette::Disabled, QPalette::Foreground, disabled);
- palette.setColor(QPalette::Disabled, QPalette::ButtonText, disabled);
- palette.setColor(QPalette::Highlight, highlight);
- // calculate disabled colors by removing saturation
- highlight.setHsv(highlight.hue(), 0, highlight.value(), highlight.alpha());
- highlightText.setHsv(highlightText.hue(), 0, highlightText.value(), highlightText.alpha());
- palette.setColor(QPalette::Disabled, QPalette::Highlight, highlight);
- palette.setColor(QPalette::Disabled, QPalette::HighlightedText, highlightText);
-
- palette.setColor(QPalette::Inactive, QPalette::HighlightedText, inactiveHighlightedTExt);
- palette.setColor(QPalette::Inactive, QPalette::Highlight, inactiveHighlight);
-
- style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(), "gtk-tooltips", "GtkWindow",
- d->gtk_window_get_type());
- if (style) {
- gdkText = style->fg[GTK_STATE_NORMAL];
- text = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
- palette.setColor(QPalette::ToolTipText, text);
- }
- }
- return palette;
-}
-
-/*!
- \reimp
-*/
-void QGtkStyle::polish(QPalette &palette)
-{
- Q_D(QGtkStyle);
-
- if (!d->isThemeAvailable())
- QCommonStyle::polish(palette);
- else
- palette = palette.resolve(standardPalette());
-}
-
-/*!
- \reimp
-*/
-void QGtkStyle::polish(QApplication *app)
-{
- Q_D(QGtkStyle);
-
- QCommonStyle::polish(app);
- // Custom fonts and palettes with QtConfig are intentionally
- // not supported as these should be entirely determined by
- // current Gtk settings
- if (app->desktopSettingsAware() && d->isThemeAvailable()) {
- QApplicationPrivate::setSystemPalette(standardPalette());
- QApplicationPrivate::setSystemFont(d->getThemeFont());
- d->applyCustomPaletteHash();
- if (!d->isKDE4Session())
- qApp->installEventFilter(&d->filter);
- }
-}
-
-/*!
- \reimp
-*/
-void QGtkStyle::unpolish(QApplication *app)
-{
- Q_D(QGtkStyle);
-
- QCommonStyle::unpolish(app);
- QPixmapCache::clear();
-
- if (app->desktopSettingsAware() && d->isThemeAvailable() && !d->isKDE4Session())
- qApp->removeEventFilter(&d->filter);
-}
-
-/*!
- \reimp
-*/
-
-void QGtkStyle::polish(QWidget *widget)
-{
- Q_D(QGtkStyle);
-
- QCommonStyle::polish(widget);
- if (!d->isThemeAvailable())
- return;
- if (qobject_cast<QAbstractButton*>(widget)
- || qobject_cast<QToolButton*>(widget)
- || qobject_cast<QComboBox*>(widget)
- || qobject_cast<QGroupBox*>(widget)
- || qobject_cast<QScrollBar*>(widget)
- || qobject_cast<QSlider*>(widget)
- || qobject_cast<QAbstractSpinBox*>(widget)
- || qobject_cast<QSpinBox*>(widget)
- || qobject_cast<QHeaderView*>(widget))
- widget->setAttribute(Qt::WA_Hover);
-#ifndef QT_NO_TREEVIEW
- else if (QTreeView *tree = qobject_cast<QTreeView *> (widget))
- tree->viewport()->setAttribute(Qt::WA_Hover);
-#endif
-}
-
-/*!
- \reimp
-*/
-void QGtkStyle::unpolish(QWidget *widget)
-{
- QCommonStyle::unpolish(widget);
-}
-
-/*!
- \reimp
-*/
-int QGtkStyle::pixelMetric(PixelMetric metric,
- const QStyleOption *option,
- const QWidget *widget) const
-{
- Q_D(const QGtkStyle);
-
- if (!d->isThemeAvailable())
- return QCommonStyle::pixelMetric(metric, option, widget);
-
- switch (metric) {
- case PM_DefaultFrameWidth:
- if (qobject_cast<const QFrame*>(widget)) {
- if (GtkStyle *style =
- d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(),
- "*.GtkScrolledWindow",
- "*.GtkScrolledWindow",
- d->gtk_window_get_type()))
- return qMax(style->xthickness, style->ythickness);
- }
- return 2;
-
- case PM_MenuButtonIndicator:
- return 20;
-
- case PM_TabBarBaseOverlap:
- return 1;
-
- case PM_ToolBarSeparatorExtent:
- return 11;
-
- case PM_ToolBarFrameWidth:
- return 1;
-
- case PM_ToolBarItemSpacing:
- return 0;
-
- case PM_ButtonShiftHorizontal: {
- GtkWidget *gtkButton = d->gtkWidget("GtkButton");
- guint horizontal_shift;
- d->gtk_widget_style_get(gtkButton, "child-displacement-x", &horizontal_shift, NULL);
- return horizontal_shift;
- }
-
- case PM_ButtonShiftVertical: {
- GtkWidget *gtkButton = d->gtkWidget("GtkButton");
- guint vertical_shift;
- d->gtk_widget_style_get(gtkButton, "child-displacement-y", &vertical_shift, NULL);
- return vertical_shift;
- }
-
- case PM_MenuBarPanelWidth:
- return 0;
-
- case PM_MenuPanelWidth: {
- GtkWidget *gtkMenu = d->gtkWidget("GtkMenu");
- guint horizontal_padding = 0;
- // horizontal-padding is used by Maemo to get thicker borders
- if (!d->gtk_check_version(2, 10, 0))
- d->gtk_widget_style_get(gtkMenu, "horizontal-padding", &horizontal_padding, NULL);
- int padding = qMax<int>(d->gtk_widget_get_style(gtkMenu)->xthickness, horizontal_padding);
- return padding;
- }
-
- case PM_ButtonIconSize: {
- int retVal = 24;
- GtkSettings *settings = d->gtk_settings_get_default();
- gchararray icon_sizes;
- g_object_get(settings, "gtk-icon-sizes", &icon_sizes, NULL);
- QStringList values = QString(QLS(icon_sizes)).split(QLatin1Char(':'));
- g_free(icon_sizes);
- QChar splitChar(QLatin1Char(','));
- foreach (const QString &value, values) {
- if (value.startsWith(QLS("gtk-button="))) {
- QString iconSize = value.right(value.size() - 11);
-
- if (iconSize.contains(splitChar))
- retVal = iconSize.split(splitChar)[0].toInt();
- break;
- }
- }
- return retVal;
- }
-
- case PM_MenuVMargin:
-
- case PM_MenuHMargin:
- return 0;
-
- case PM_DockWidgetTitleMargin:
- return 0;
-
- case PM_DockWidgetTitleBarButtonMargin:
- return 5;
-
- case PM_TabBarTabVSpace:
- return 12;
-
- case PM_TabBarTabHSpace:
- return 14;
-
- case PM_TabBarTabShiftVertical:
- return 2;
-
- case PM_ToolBarHandleExtent:
- return 9;
-
- case PM_SplitterWidth:
- return 6;
-
- case PM_SliderThickness:
- case PM_SliderControlThickness: {
- GtkWidget *gtkScale = d->gtkWidget("GtkHScale");
- gint val;
- d->gtk_widget_style_get(gtkScale, "slider-width", &val, NULL);
- if (metric == PM_SliderControlThickness)
- return val + 2*d->gtk_widget_get_style(gtkScale)->ythickness;
- return val;
- }
-
- case PM_ScrollBarExtent: {
- gint sliderLength;
- gint trough_border;
- GtkWidget *hScrollbar = d->gtkWidget("GtkHScrollbar");
- d->gtk_widget_style_get(hScrollbar,
- "trough-border", &trough_border,
- "slider-width", &sliderLength,
- NULL);
- return sliderLength + trough_border*2;
- }
-
- case PM_ScrollBarSliderMin:
- return 34;
-
- case PM_SliderLength:
- gint val;
- d->gtk_widget_style_get(d->gtkWidget("GtkHScale"), "slider-length", &val, NULL);
- return val;
-
- case PM_ExclusiveIndicatorWidth:
- case PM_ExclusiveIndicatorHeight:
- case PM_IndicatorWidth:
- case PM_IndicatorHeight: {
- GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton");
- gint size, spacing;
- d->gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, "indicator-size", &size, NULL);
- return size + 2 * spacing;
- }
-
- case PM_MenuBarVMargin: {
- GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
- return qMax(0, d->gtk_widget_get_style(gtkMenubar)->ythickness);
- }
- case PM_ScrollView_ScrollBarSpacing:
- {
- gint spacing = 3;
- GtkWidget *gtkScrollWindow = d->gtkWidget("GtkScrolledWindow");
- Q_ASSERT(gtkScrollWindow);
- d->gtk_widget_style_get(gtkScrollWindow, "scrollbar-spacing", &spacing, NULL);
- return spacing;
- }
- case PM_SubMenuOverlap: {
- gint offset = 0;
- GtkWidget *gtkMenu = d->gtkWidget("GtkMenu");
- d->gtk_widget_style_get(gtkMenu, "horizontal-offset", &offset, NULL);
- return offset;
- }
- case PM_ToolTipLabelFrameWidth:
- return 2;
- case PM_ButtonDefaultIndicator:
- return 0;
- case PM_ListViewIconSize:
- return 24;
- case PM_DialogButtonsSeparator:
- return 6;
- case PM_TitleBarHeight:
- return 24;
- case PM_SpinBoxFrameWidth:
- return 3;
- case PM_MenuBarItemSpacing:
- return 6;
- case PM_MenuBarHMargin:
- return 0;
- case PM_ToolBarItemMargin:
- return 1;
- case PM_SmallIconSize:
- return 16;
- case PM_MaximumDragDistance:
- return -1;
- case PM_TabCloseIndicatorWidth:
- case PM_TabCloseIndicatorHeight:
- return 20;
- default:
- return QCommonStyle::pixelMetric(metric, option, widget);
- }
-}
-
-/*!
- \reimp
-*/
-int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget,
-
- QStyleHintReturn *returnData = 0) const
-{
- Q_D(const QGtkStyle);
-
- if (!d->isThemeAvailable())
- return QCommonStyle::styleHint(hint, option, widget, returnData);
-
- switch (hint) {
- case SH_ItemView_ChangeHighlightOnFocus:
- return true;
- case SH_ScrollBar_MiddleClickAbsolutePosition:
- return true;
- case SH_Menu_AllowActiveAndDisabled:
- return false;
- case SH_MainWindow_SpaceBelowMenuBar:
- return false;
- case SH_MenuBar_MouseTracking:
- return true;
- case SH_Menu_MouseTracking:
- return true;
- case SH_TitleBar_AutoRaise:
- return true;
- case SH_TitleBar_NoBorder:
- return true;
- case SH_ItemView_ShowDecorationSelected:
- return true;
- case SH_Table_GridLineColor:
- if (option)
- return option->palette.background().color().darker(120).rgb();
- break;
- case SH_WindowFrame_Mask:
- if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask *>(returnData)) {
- //left rounded corner
- mask->region = option->rect;
- mask->region -= QRect(option->rect.left(), option->rect.top(), 5, 1);
- mask->region -= QRect(option->rect.left(), option->rect.top() + 1, 3, 1);
- mask->region -= QRect(option->rect.left(), option->rect.top() + 2, 2, 1);
- mask->region -= QRect(option->rect.left(), option->rect.top() + 3, 1, 2);
-
- //right rounded corner
- mask->region -= QRect(option->rect.right() - 4, option->rect.top(), 5, 1);
- mask->region -= QRect(option->rect.right() - 2, option->rect.top() + 1, 3, 1);
- mask->region -= QRect(option->rect.right() - 1, option->rect.top() + 2, 2, 1);
- mask->region -= QRect(option->rect.right() , option->rect.top() + 3, 1, 2);
- }
- return QCommonStyle::styleHint(hint, option, widget, returnData);
- case SH_MessageBox_TextInteractionFlags:
- return Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse;
- case SH_MessageBox_CenterButtons:
- return false;
-#ifndef QT_NO_WIZARD
- case SH_WizardStyle:
- return QWizard::ClassicStyle;
-#endif
- case SH_ItemView_ArrowKeysNavigateIntoChildren:
- return false;
- case SH_DialogButtonLayout: {
- int ret = QDialogButtonBox::GnomeLayout;
- gboolean alternateOrder = 0;
- GtkSettings *settings = d->gtk_settings_get_default();
- g_object_get(settings, "gtk-alternative-button-order", &alternateOrder, NULL);
-
- if (alternateOrder)
- ret = QDialogButtonBox::WinLayout;
-
- return ret;
- }
- break;
-
- case SH_ToolButtonStyle:
- {
- if (d->isKDE4Session())
- return QCommonStyle::styleHint(hint, option, widget, returnData);
- GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar");
- GtkToolbarStyle toolbar_style = GTK_TOOLBAR_ICONS;
- g_object_get(gtkToolbar, "toolbar-style", &toolbar_style, NULL);
- switch (toolbar_style) {
- case GTK_TOOLBAR_TEXT:
- return Qt::ToolButtonTextOnly;
- case GTK_TOOLBAR_BOTH:
- return Qt::ToolButtonTextUnderIcon;
- case GTK_TOOLBAR_BOTH_HORIZ:
- return Qt::ToolButtonTextBesideIcon;
- case GTK_TOOLBAR_ICONS:
- default:
- return Qt::ToolButtonIconOnly;
- }
- }
- break;
- case SH_SpinControls_DisableOnBounds:
- return int(true);
-
- case SH_DitherDisabledText:
- return int(false);
-
- case SH_ComboBox_Popup: {
- GtkWidget *gtkComboBox = d->gtkWidget("GtkComboBox");
- gboolean appears_as_list;
- d->gtk_widget_style_get((GtkWidget*)gtkComboBox, "appears-as-list", &appears_as_list, NULL);
- return appears_as_list ? 0 : 1;
- }
-
- case SH_MenuBar_AltKeyNavigation:
- return int(false);
-
- case SH_EtchDisabledText:
- return int(false);
-
- case SH_Menu_SubMenuPopupDelay: {
- gint delay = 225;
- GtkSettings *settings = d->gtk_settings_get_default();
- g_object_get(settings, "gtk-menu-popup-delay", &delay, NULL);
- return delay;
- }
-
- case SH_ScrollView_FrameOnlyAroundContents: {
- gboolean scrollbars_within_bevel = false;
- if (widget && widget->isWindow())
- scrollbars_within_bevel = true;
- else if (!d->gtk_check_version(2, 12, 0)) {
- GtkWidget *gtkScrollWindow = d->gtkWidget("GtkScrolledWindow");
- d->gtk_widget_style_get(gtkScrollWindow, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL);
- }
- return !scrollbars_within_bevel;
- }
-
- case SH_DialogButtonBox_ButtonsHaveIcons: {
- static bool buttonsHaveIcons = d->getGConfBool(QLS("/desktop/gnome/interface/buttons_have_icons"));
- return buttonsHaveIcons;
- }
-
- case SH_UnderlineShortcut: {
- gboolean underlineShortcut = true;
- if (!d->gtk_check_version(2, 12, 0)) {
- GtkSettings *settings = d->gtk_settings_get_default();
- g_object_get(settings, "gtk-enable-mnemonics", &underlineShortcut, NULL);
- }
- return underlineShortcut;
- }
-
- default:
- break;
- }
- return QCommonStyle::styleHint(hint, option, widget, returnData);
-}
-
-/*!
- \reimp
-*/
-void QGtkStyle::drawPrimitive(PrimitiveElement element,
- const QStyleOption *option,
- QPainter *painter,
- const QWidget *widget) const
-{
- Q_D(const QGtkStyle);
-
- if (!d->isThemeAvailable()) {
- QCommonStyle::drawPrimitive(element, option, painter, widget);
- return;
- }
-
- GtkStyle* style = d->gtkStyle();
- QGtkPainter* gtkPainter = d->gtkPainter(painter);
-
- switch (element) {
- case PE_Frame: {
- if (widget && widget->inherits("QComboBoxPrivateContainer")){
- QStyleOption copy = *option;
- copy.state |= State_Raised;
- proxy()->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 = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget);
- const QString pmKey = QLatin1String("windowframe") % HexString<uint>(option->state);
-
- QPixmap pixmap;
- QRect pmRect(QPoint(0,0), QSize(pmSize, pmSize));
-
- // Only draw through style once
- if (!QPixmapCache::find(pmKey, pixmap)) {
- pixmap = QPixmap(pmSize, pmSize);
- pixmap.fill(Qt::transparent);
- QPainter pmPainter(&pixmap);
- gtkPainter->reset(&pmPainter);
- gtkPainter->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 = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(),
- "*.GtkScrolledWindow", "*.GtkScrolledWindow", d->gtk_window_get_type());
- if (style)
- gtkPainter->paintShadow(d->gtkWidget("GtkFrame"), "viewport", pmRect,
- option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
- shadow_type, style);
- QPixmapCache::insert(pmKey, pixmap);
- gtkPainter->reset(painter);
- }
-
- 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_FrameWindow:
- painter->save();
- {
- QRect rect= option->rect;
- painter->setPen(QPen(option->palette.dark().color().darker(150), 0));
- painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
- painter->setPen(QPen(option->palette.light(), 0));
- painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1),
- QPoint(rect.left() + 1, rect.bottom() - 1));
- painter->setPen(QPen(option->palette.background().color().darker(120), 0));
- painter->drawLine(QPoint(rect.left() + 1, rect.bottom() - 1),
- QPoint(rect.right() - 2, rect.bottom() - 1));
- painter->drawLine(QPoint(rect.right() - 1, rect.top() + 1),
- QPoint(rect.right() - 1, rect.bottom() - 1));
- }
- painter->restore();
- break;
-
- case PE_PanelTipLabel: {
- GtkWidget *gtkWindow = d->gtkWidget("GtkWindow"); // The Murrine Engine currently assumes a widget is passed
- style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(), "gtk-tooltips", "GtkWindow",
- d->gtk_window_get_type());
- gtkPainter->paintFlatBox(gtkWindow, "tooltip", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, style);
- }
- break;
-
- case PE_PanelStatusBar: {
- if (widget && widget->testAttribute(Qt::WA_SetPalette) &&
- option->palette.resolve() & (1 << QPalette::Window)) {
- // Respect custom palette
- painter->fillRect(option->rect, option->palette.window());
- break;
- }
- GtkShadowType shadow_type;
- GtkWidget *gtkStatusbarFrame = d->gtkWidget("GtkStatusbar.GtkFrame");
- d->gtk_widget_style_get(d->gtk_widget_get_parent(gtkStatusbarFrame), "shadow-type", &shadow_type, NULL);
- gtkPainter->paintShadow(gtkStatusbarFrame, "frame", option->rect, GTK_STATE_NORMAL,
- shadow_type, d->gtk_widget_get_style(gtkStatusbarFrame));
- }
- break;
-
- case PE_IndicatorHeaderArrow:
- if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
- GtkWidget *gtkTreeHeader = d->gtkWidget("GtkTreeView.GtkButton");
- GtkStateType state = qt_gtk_state(option);
- style = d->gtk_widget_get_style(gtkTreeHeader);
- GtkArrowType type = GTK_ARROW_UP;
- // This sorting indicator inversion is intentional, and follows the GNOME HIG.
- // See http://library.gnome.org/devel/hig-book/stable/controls-lists.html.en#controls-lists-sortable
- if (header->sortIndicator & QStyleOptionHeader::SortUp)
- type = GTK_ARROW_UP;
- else if (header->sortIndicator & QStyleOptionHeader::SortDown)
- type = GTK_ARROW_DOWN;
-
- gtkPainter->paintArrow(gtkTreeHeader, "button", option->rect.adjusted(1, 1, -1, -1), type, state,
- GTK_SHADOW_NONE, false, style);
- }
- break;
-
- case PE_FrameDefaultButton: // fall through
- case PE_FrameFocusRect: {
- QRect frameRect = option->rect.adjusted(1, 1, -2, -2); // ### this mess should move to subcontrolrect
- if (qobject_cast<const QAbstractItemView*>(widget)) {
- // Don't draw anything
- } else if (qobject_cast<const QTabBar*>(widget)) {
- GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook");
- style = d->gtk_widget_get_style(gtkNotebook);
- gtkPainter->paintFocus(gtkNotebook, "tab", frameRect.adjusted(-1, 1, 1, 1), GTK_STATE_ACTIVE, style);
- } else {
- GtkWidget *gtkRadioButton = d->gtkWidget("GtkRadioButton");
- gtkPainter->paintFocus(gtkRadioButton, "radiobutton", frameRect, GTK_STATE_ACTIVE, style);
- }
- }
- break;
-
- case PE_IndicatorBranch:
- if (option->state & State_Children) {
- QRect rect = option->rect;
- rect = QRect(0, 0, 12, 12);
- rect.moveCenter(option->rect.center());
- rect.translate(2, 0);
- GtkExpanderStyle openState = GTK_EXPANDER_EXPANDED;
- GtkExpanderStyle closedState = GTK_EXPANDER_COLLAPSED;
- GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView");
-
- GtkStateType state = GTK_STATE_NORMAL;
- if (!(option->state & State_Enabled))
- state = GTK_STATE_INSENSITIVE;
- else if (option->state & State_MouseOver)
- state = GTK_STATE_PRELIGHT;
-
- gtkPainter->paintExpander(gtkTreeView, "treeview", rect, state,
- option->state & State_Open ? openState : closedState , d->gtk_widget_get_style(gtkTreeView));
- }
- break;
-
- case PE_PanelItemViewRow:
- // This primitive is only used to draw selection behind selected expander arrows.
- // We try not to decorate the tree branch background unless you inherit from StyledItemDelegate
- // The reason for this is that a lot of code that relies on custom item delegates will look odd having
- // a gradient on the branch but a flat shaded color on the item itself.
- QCommonStyle::drawPrimitive(element, option, painter, widget);
- if (!(option->state & State_Selected)) {
- break;
- } else {
- if (const QAbstractItemView *view = qobject_cast<const QAbstractItemView*>(widget)) {
- if (!qobject_cast<QStyledItemDelegate*>(view->itemDelegate()))
- break;
- }
- } // fall through
-
- case PE_PanelItemViewItem:
- if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(option)) {
- uint resolve_mask = vopt->palette.resolve();
- if (vopt->backgroundBrush.style() != Qt::NoBrush
- || (resolve_mask & (1 << QPalette::Base)))
- {
- QPointF oldBO = painter->brushOrigin();
- painter->setBrushOrigin(vopt->rect.topLeft());
- painter->fillRect(vopt->rect, vopt->backgroundBrush);
- painter->setBrushOrigin(oldBO);
- if (!(option->state & State_Selected))
- break;
- }
- if (GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView")) {
- const char *detail = "cell_even_ruled";
- if (vopt && vopt->features & QStyleOptionViewItem::Alternate)
- detail = "cell_odd_ruled";
- bool isActive = option->state & State_Active;
- QString key;
- if (isActive ) {
- // Required for active/non-active window appearance
- key = QLS("a");
- QGtkStylePrivate::gtkWidgetSetFocus(gtkTreeView, true);
- }
- bool isEnabled = (widget ? widget->isEnabled() : (vopt->state & QStyle::State_Enabled));
- gtkPainter->paintFlatBox(gtkTreeView, detail, option->rect,
- option->state & State_Selected ? GTK_STATE_SELECTED :
- isEnabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
- GTK_SHADOW_OUT, d->gtk_widget_get_style(gtkTreeView), key);
- if (isActive )
- QGtkStylePrivate::gtkWidgetSetFocus(gtkTreeView, false);
- }
- }
- break;
- case PE_IndicatorToolBarSeparator:
- {
- const int margin = 6;
- GtkWidget *gtkSeparator = d->gtkWidget("GtkToolbar.GtkSeparatorToolItem");
- if (option->state & State_Horizontal) {
- const int offset = option->rect.width()/2;
- QRect rect = option->rect.adjusted(offset, margin, 0, -margin);
- painter->setPen(QPen(option->palette.background().color().darker(110)));
- gtkPainter->paintVline(gtkSeparator, "vseparator",
- rect, GTK_STATE_NORMAL, d->gtk_widget_get_style(gtkSeparator),
- 0, rect.height(), 0);
- } else { //Draw vertical separator
- const int offset = option->rect.height()/2;
- QRect rect = option->rect.adjusted(margin, offset, -margin, 0);
- painter->setPen(QPen(option->palette.background().color().darker(110)));
- gtkPainter->paintHline(gtkSeparator, "hseparator",
- rect, GTK_STATE_NORMAL, d->gtk_widget_get_style(gtkSeparator),
- 0, rect.width(), 0);
- }
- }
- break;
-
- case PE_IndicatorToolBarHandle: {
- GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar");
- GtkShadowType shadow_type;
- d->gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL);
- //Note when the toolbar is horizontal, the handle is vertical
- painter->setClipRect(option->rect);
- gtkPainter->paintHandle(gtkToolbar, "toolbar", option->rect.adjusted(-1, -1 ,0 ,1),
- GTK_STATE_NORMAL, shadow_type, !(option->state & State_Horizontal) ?
- GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, d->gtk_widget_get_style(gtkToolbar));
- }
- break;
-
- case PE_IndicatorArrowUp:
- case PE_IndicatorArrowDown:
- case PE_IndicatorArrowLeft:
- case PE_IndicatorArrowRight: {
-
-
- GtkArrowType type = GTK_ARROW_UP;
-
- switch (element) {
-
- case PE_IndicatorArrowDown:
- type = GTK_ARROW_DOWN;
- break;
-
- case PE_IndicatorArrowLeft:
- type = GTK_ARROW_LEFT;
- break;
-
- case PE_IndicatorArrowRight:
- type = GTK_ARROW_RIGHT;
- break;
-
- default:
- break;
- }
- int size = qMin(option->rect.height(), option->rect.width());
- int border = (size > 9) ? (size/4) : 0; //Allow small arrows to have exact dimensions
- int bsx = 0, bsy = 0;
- if (option->state & State_Sunken) {
- bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal);
- bsy = proxy()->pixelMetric(PM_ButtonShiftVertical);
- }
- QRect arrowRect = option->rect.adjusted(border + bsx, border + bsy, -border + bsx, -border + bsy);
- GtkShadowType shadow = option->state & State_Sunken ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
- GtkStateType state = qt_gtk_state(option);
-
- QColor arrowColor = option->palette.buttonText().color();
- GtkWidget *gtkArrow = d->gtkWidget("GtkArrow");
- GdkColor color = fromQColor(arrowColor);
- d->gtk_widget_modify_fg (gtkArrow, state, &color);
- gtkPainter->paintArrow(gtkArrow, "button", arrowRect,
- type, state, shadow, false, d->gtk_widget_get_style(gtkArrow),
- QString::number(arrowColor.rgba(), 16));
- // Passing NULL will revert the color change
- d->gtk_widget_modify_fg (gtkArrow, state, NULL);
- }
- break;
-
- case PE_FrameGroupBox:
- // Do nothing here, the GNOME groupboxes are flat
- break;
-
- case PE_PanelMenu: {
- GtkWidget *gtkMenu = d->gtkWidget("GtkMenu");
- gtkPainter->setAlphaSupport(false); // Note, alpha disabled for performance reasons
- gtkPainter->paintBox(gtkMenu, "menu", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, d->gtk_widget_get_style(gtkMenu), QString());
- }
- break;
-
- case PE_FrameMenu:
- //This is actually done by PE_Widget due to a clipping issue
- //Otherwise Menu items will not be able to span the entire menu width
-
- // This is only used by floating tool bars
- if (qobject_cast<const QToolBar *>(widget)) {
- GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
- gtkPainter->paintBox(gtkMenubar, "toolbar", option->rect,
- GTK_STATE_NORMAL, GTK_SHADOW_OUT, style);
- gtkPainter->paintBox(gtkMenubar, "menu", option->rect,
- GTK_STATE_NORMAL, GTK_SHADOW_OUT, style);
- }
- break;
-
- case PE_FrameLineEdit: {
- GtkWidget *gtkEntry = d->gtkWidget("GtkEntry");
-
-
- gboolean interior_focus;
- gint focus_line_width;
- QRect rect = option->rect;
- d->gtk_widget_style_get(gtkEntry,
- "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);
-
- if (option->state & State_HasFocus)
- QGtkStylePrivate::gtkWidgetSetFocus(gtkEntry, true);
- gtkPainter->paintShadow(gtkEntry, "entry", rect, option->state & State_Enabled ?
- GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
- GTK_SHADOW_IN, d->gtk_widget_get_style(gtkEntry),
- 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,
- GTK_SHADOW_IN, d->gtk_widget_get_style(gtkEntry), QLS("GtkEntryShadowIn"));
-
- if (option->state & State_HasFocus)
- QGtkStylePrivate::gtkWidgetSetFocus(gtkEntry, false);
- }
- break;
-
- case PE_PanelLineEdit:
- if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
- GtkWidget *gtkEntry = d->gtkWidget("GtkEntry");
- if (panel->lineWidth > 0)
- proxy()->drawPrimitive(PE_FrameLineEdit, option, painter, widget);
- uint resolve_mask = option->palette.resolve();
- GtkStyle *gtkEntryStyle = d->gtk_widget_get_style(gtkEntry);
- QRect textRect = option->rect.adjusted(gtkEntryStyle->xthickness, gtkEntryStyle->ythickness,
- -gtkEntryStyle->xthickness, -gtkEntryStyle->ythickness);
-
- if (widget && widget->testAttribute(Qt::WA_SetPalette) &&
- resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
- 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, gtkEntryStyle);
- }
- break;
-
- case PE_FrameTabWidget:
- if (const QStyleOptionTabWidgetFrame *frame = qstyleoption_cast<const QStyleOptionTabWidgetFrame*>(option)) {
- GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook");
- style = d->gtk_widget_get_style(gtkNotebook);
- gtkPainter->setAlphaSupport(false);
- GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = GTK_STATE_NORMAL; // Only state supported by gtknotebook
- bool reverse = (option->direction == Qt::RightToLeft);
- QGtkStylePrivate::gtk_widget_set_direction(gtkNotebook, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
- if (const QStyleOptionTabWidgetFrameV2 *tabframe = qstyleoption_cast<const QStyleOptionTabWidgetFrameV2*>(option)) {
- GtkPositionType frameType = GTK_POS_TOP;
- QTabBar::Shape shape = frame->shape;
- int gapStart = 0;
- int gapSize = 0;
- if (shape == QTabBar::RoundedNorth || shape == QTabBar::RoundedSouth) {
- frameType = (shape == QTabBar::RoundedNorth) ? GTK_POS_TOP : GTK_POS_BOTTOM;
- gapStart = tabframe->selectedTabRect.left();
- gapSize = tabframe->selectedTabRect.width();
- } else {
- frameType = (shape == QTabBar::RoundedWest) ? GTK_POS_LEFT : GTK_POS_RIGHT;
- gapStart = tabframe->selectedTabRect.y();
- gapSize = tabframe->selectedTabRect.height();
- }
- gtkPainter->paintBoxGap(gtkNotebook, "notebook", option->rect, state, shadow, frameType,
- gapStart, gapSize, style);
- break; // done
- }
-
- // Note this is only the fallback option
- gtkPainter->paintBox(gtkNotebook, "notebook", option->rect, state, shadow, style);
- }
- break;
-
- case PE_PanelButtonCommand:
- case PE_PanelButtonTool: {
- bool isDefault = false;
- bool isTool = (element == PE_PanelButtonTool);
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton*>(option))
- isDefault = btn->features & QStyleOptionButton::DefaultButton;
-
- // don't draw a frame for tool buttons that have the autoRaise flag and are not enabled or on
- if (isTool && !(option->state & State_Enabled || option->state & State_On) && (option->state & State_AutoRaise))
- break;
- // don't draw a frame for dock widget buttons, unless we are hovering
- if (widget && widget->inherits("QDockWidgetTitleButton") && !(option->state & State_MouseOver))
- break;
-
- GtkStateType state = qt_gtk_state(option);
- if (option->state & State_On || option->state & State_Sunken)
- state = GTK_STATE_ACTIVE;
- GtkWidget *gtkButton = isTool ? d->gtkWidget("GtkToolButton.GtkButton") : d->gtkWidget("GtkButton");
- gint focusWidth, focusPad;
- gboolean interiorFocus = false;
- d->gtk_widget_style_get (gtkButton,
- "focus-line-width", &focusWidth,
- "focus-padding", &focusPad,
- "interior-focus", &interiorFocus, NULL);
-
- style = d->gtk_widget_get_style(gtkButton);
-
- QRect buttonRect = option->rect;
-
- QString key;
- if (isDefault) {
- key += QLS("def");
- QGtkStylePrivate::gtk_widget_set_can_default(gtkButton, true);
- QGtkStylePrivate::gtk_window_set_default((GtkWindow*)QGtkStylePrivate::gtk_widget_get_toplevel(gtkButton), gtkButton);
- gtkPainter->paintBox(gtkButton, "buttondefault", buttonRect, state, GTK_SHADOW_IN,
- style, isDefault ? QLS("d") : QString());
- }
-
- bool hasFocus = option->state & State_HasFocus;
-
- if (hasFocus) {
- key += QLS("def");
- QGtkStylePrivate::gtkWidgetSetFocus(gtkButton, true);
- }
-
- if (!interiorFocus)
- buttonRect = buttonRect.adjusted(focusWidth, focusWidth, -focusWidth, -focusWidth);
-
- GtkShadowType shadow = (option->state & State_Sunken || option->state & State_On ) ?
- GTK_SHADOW_IN : GTK_SHADOW_OUT;
-
- gtkPainter->paintBox(gtkButton, "button", buttonRect, state, shadow,
- style, key);
- if (isDefault)
- QGtkStylePrivate::gtk_window_set_default((GtkWindow*)QGtkStylePrivate::gtk_widget_get_toplevel(gtkButton), 0);
- if (hasFocus)
- QGtkStylePrivate::gtkWidgetSetFocus(gtkButton, false);
- }
- break;
-
- case PE_IndicatorRadioButton: {
- GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = qt_gtk_state(option);
-
- if (option->state & State_Sunken)
- state = GTK_STATE_ACTIVE;
-
- if (option->state & State_NoChange)
- shadow = GTK_SHADOW_ETCHED_IN;
- else if (option->state & State_On)
- shadow = GTK_SHADOW_IN;
- else
- shadow = GTK_SHADOW_OUT;
-
- GtkWidget *gtkRadioButton = d->gtkWidget("GtkRadioButton");
- gint spacing;
- d->gtk_widget_style_get(gtkRadioButton, "indicator-spacing", &spacing, NULL);
- QRect buttonRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing);
- gtkPainter->setClipRect(option->rect);
- // ### Note: Ubuntulooks breaks when the proper widget is passed
- // Murrine engine requires a widget not to get RGBA check - warnings
- GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton");
- QString key(QLS("radiobutton"));
- if (option->state & State_HasFocus) { // Themes such as Nodoka check this flag
- key += QLatin1Char('f');
- QGtkStylePrivate::gtkWidgetSetFocus(gtkCheckButton, true);
- }
- gtkPainter->paintOption(gtkCheckButton , buttonRect, state, shadow, d->gtk_widget_get_style(gtkRadioButton), key);
- if (option->state & State_HasFocus)
- QGtkStylePrivate::gtkWidgetSetFocus(gtkCheckButton, false);
- }
- break;
-
- case PE_IndicatorCheckBox: {
- GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = qt_gtk_state(option);
-
- if (option->state & State_Sunken)
- state = GTK_STATE_ACTIVE;
-
- if (option->state & State_NoChange)
- shadow = GTK_SHADOW_ETCHED_IN;
- else if (option->state & State_On)
- shadow = GTK_SHADOW_IN;
- else
- shadow = GTK_SHADOW_OUT;
-
- int spacing;
-
- GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton");
- QString key(QLS("checkbutton"));
- if (option->state & State_HasFocus) { // Themes such as Nodoka checks this flag
- key += QLatin1Char('f');
- QGtkStylePrivate::gtkWidgetSetFocus(gtkCheckButton, true);
- }
-
- // Some styles such as aero-clone assume they can paint in the spacing area
- gtkPainter->setClipRect(option->rect);
-
- d->gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, NULL);
-
- QRect checkRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing);
-
- gtkPainter->paintCheckbox(gtkCheckButton, checkRect, state, shadow, d->gtk_widget_get_style(gtkCheckButton),
- key);
- if (option->state & State_HasFocus)
- QGtkStylePrivate::gtkWidgetSetFocus(gtkCheckButton, false);
-
- }
- break;
-
-#ifndef QT_NO_TABBAR
-
- case PE_FrameTabBarBase:
- if (const QStyleOptionTabBarBase *tbb
- = qstyleoption_cast<const QStyleOptionTabBarBase *>(option)) {
- QRect tabRect = tbb->rect;
- painter->save();
- painter->setPen(QPen(option->palette.dark().color().dark(110), 0));
- switch (tbb->shape) {
-
- case QTabBar::RoundedNorth:
- painter->drawLine(tabRect.topLeft(), tabRect.topRight());
- break;
-
- case QTabBar::RoundedWest:
- painter->drawLine(tabRect.left(), tabRect.top(), tabRect.left(), tabRect.bottom());
- break;
-
- case QTabBar::RoundedSouth:
- painter->drawLine(tbb->rect.left(), tbb->rect.bottom(),
- tabRect.right(), tabRect.bottom());
- break;
-
- case QTabBar::RoundedEast:
- painter->drawLine(tabRect.topRight(), tabRect.bottomRight());
- break;
-
- case QTabBar::TriangularNorth:
- case QTabBar::TriangularEast:
- case QTabBar::TriangularWest:
- case QTabBar::TriangularSouth:
- painter->restore();
- QCommonStyle::drawPrimitive(element, option, painter, widget);
- return;
- }
-
- painter->restore();
- }
- return;
-
-#endif // QT_NO_TABBAR
-
- case PE_Widget:
- break;
-
- default:
- QCommonStyle::drawPrimitive(element, option, painter, widget);
- }
-}
-
-/*!
- \reimp
-*/
-void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
-
- QPainter *painter, const QWidget *widget) const
-{
- Q_D(const QGtkStyle);
-
- if (!d->isThemeAvailable()) {
- QCommonStyle::drawComplexControl(control, option, painter, widget);
- return;
- }
-
- GtkStyle* style = d->gtkStyle();
- QGtkPainter* gtkPainter = d->gtkPainter(painter);
- QColor button = option->palette.button().color();
- QColor dark;
- QColor grooveColor;
- QColor darkOutline;
- dark.setHsv(button.hue(),
- qMin(255, (int)(button.saturation()*1.9)),
- qMin(255, (int)(button.value()*0.7)));
- grooveColor.setHsv(button.hue(),
- qMin(255, (int)(button.saturation()*2.6)),
- qMin(255, (int)(button.value()*0.9)));
- darkOutline.setHsv(button.hue(),
- qMin(255, (int)(button.saturation()*3.0)),
- qMin(255, (int)(button.value()*0.6)));
-
- QColor alphaCornerColor;
-
- if (widget)
- alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), darkOutline);
- else
- alphaCornerColor = mergedColors(option->palette.background().color(), darkOutline);
-
- switch (control) {
-
- case CC_TitleBar:
- painter->save();
- if (const QStyleOptionTitleBar *titleBar = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) {
- // Since this is drawn by metacity and not Gtk we
- // have to do custom drawing
-
- GdkColor gdkBg = style->bg[GTK_STATE_SELECTED];
- QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
-
- const int buttonMargin = 5;
- bool active = (titleBar->titleBarState & State_Active);
- QRect fullRect = titleBar->rect;
- QPalette palette = option->palette;
- QColor highlight = bgColor;
-
- QColor titleBarFrameBorder(active ? highlight.darker(180): dark.darker(110));
- QColor titleBarHighlight(active ? highlight.lighter(120): palette.background().color().lighter(120));
- QColor textColor(active ? 0xffffff : 0xff000000);
- QColor textAlphaColor(active ? 0xffffff : 0xff000000 );
-
- {
- // Fill title bar gradient
- QColor titlebarColor = QColor(active ? highlight: palette.background().color());
- QLinearGradient gradient(option->rect.center().x(), option->rect.top(),
- option->rect.center().x(), option->rect.bottom());
-
- gradient.setColorAt(0, titlebarColor.lighter(114));
- gradient.setColorAt(0.5, titlebarColor.lighter(102));
- gradient.setColorAt(0.51, titlebarColor.darker(104));
- gradient.setColorAt(1, titlebarColor);
- painter->fillRect(option->rect.adjusted(1, 1, -1, 0), gradient);
-
- // Frame and rounded corners
- painter->setPen(titleBarFrameBorder);
-
- // top outline
- painter->drawLine(fullRect.left() + 5, fullRect.top(), fullRect.right() - 5, fullRect.top());
- painter->drawLine(fullRect.left(), fullRect.top() + 4, fullRect.left(), fullRect.bottom());
- const QPoint points[5] = {
- QPoint(fullRect.left() + 4, fullRect.top() + 1),
- QPoint(fullRect.left() + 3, fullRect.top() + 1),
- QPoint(fullRect.left() + 2, fullRect.top() + 2),
- QPoint(fullRect.left() + 1, fullRect.top() + 3),
- QPoint(fullRect.left() + 1, fullRect.top() + 4)
- };
- painter->drawPoints(points, 5);
-
- painter->drawLine(fullRect.right(), fullRect.top() + 4, fullRect.right(), fullRect.bottom());
- const QPoint points2[5] = {
- QPoint(fullRect.right() - 3, fullRect.top() + 1),
- QPoint(fullRect.right() - 4, fullRect.top() + 1),
- QPoint(fullRect.right() - 2, fullRect.top() + 2),
- QPoint(fullRect.right() - 1, fullRect.top() + 3),
- QPoint(fullRect.right() - 1, fullRect.top() + 4)
- };
- painter->drawPoints(points2, 5);
-
- // draw bottomline
- painter->drawLine(fullRect.right(), fullRect.bottom(), fullRect.left(), fullRect.bottom());
-
- // top highlight
- painter->setPen(titleBarHighlight);
- painter->drawLine(fullRect.left() + 6, fullRect.top() + 1, fullRect.right() - 6, fullRect.top() + 1);
- }
- // draw title
- QRect textRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget);
- QFont font = painter->font();
- font.setBold(true);
- painter->setFont(font);
- painter->setPen(active? (titleBar->palette.text().color().lighter(120)) :
- titleBar->palette.text().color() );
- // Note workspace also does elliding but it does not use the correct font
- QString title = QFontMetrics(font).elidedText(titleBar->text, Qt::ElideRight, textRect.width() - 14);
- painter->drawText(textRect.adjusted(1, 1, 1, 1), title, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter));
- painter->setPen(Qt::white);
- if (active)
- painter->drawText(textRect, title, QTextOption(Qt::AlignHCenter | Qt::AlignVCenter));
- // min button
- if ((titleBar->subControls & SC_TitleBarMinButton) && (titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) &&
- !(titleBar->titleBarState& Qt::WindowMinimized)) {
- QRect minButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget);
- if (minButtonRect.isValid()) {
- bool hover = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_MouseOver);
- bool sunken = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_Sunken);
- qt_gtk_draw_mdibutton(painter, titleBar, minButtonRect, hover, sunken);
- QRect minButtonIconRect = minButtonRect.adjusted(buttonMargin ,buttonMargin , -buttonMargin, -buttonMargin);
- painter->setPen(textColor);
- painter->drawLine(minButtonIconRect.center().x() - 2, minButtonIconRect.center().y() + 3,
- minButtonIconRect.center().x() + 3, minButtonIconRect.center().y() + 3);
- painter->drawLine(minButtonIconRect.center().x() - 2, minButtonIconRect.center().y() + 4,
- minButtonIconRect.center().x() + 3, minButtonIconRect.center().y() + 4);
- painter->setPen(textAlphaColor);
- painter->drawLine(minButtonIconRect.center().x() - 3, minButtonIconRect.center().y() + 3,
- minButtonIconRect.center().x() - 3, minButtonIconRect.center().y() + 4);
- painter->drawLine(minButtonIconRect.center().x() + 4, minButtonIconRect.center().y() + 3,
- minButtonIconRect.center().x() + 4, minButtonIconRect.center().y() + 4);
- }
- }
- // max button
- if ((titleBar->subControls & SC_TitleBarMaxButton) && (titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) &&
- !(titleBar->titleBarState & Qt::WindowMaximized)) {
- QRect maxButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget);
- if (maxButtonRect.isValid()) {
- bool hover = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_MouseOver);
- bool sunken = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_Sunken);
- qt_gtk_draw_mdibutton(painter, titleBar, maxButtonRect, hover, sunken);
-
- QRect maxButtonIconRect = maxButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin);
-
- painter->setPen(textColor);
- painter->drawRect(maxButtonIconRect.adjusted(0, 0, -1, -1));
- painter->drawLine(maxButtonIconRect.left() + 1, maxButtonIconRect.top() + 1,
- maxButtonIconRect.right() - 1, maxButtonIconRect.top() + 1);
- painter->setPen(textAlphaColor);
- const QPoint points[4] = {
- maxButtonIconRect.topLeft(),
- maxButtonIconRect.topRight(),
- maxButtonIconRect.bottomLeft(),
- maxButtonIconRect.bottomRight()
- };
- painter->drawPoints(points, 4);
- }
- }
-
- // close button
- if ((titleBar->subControls & SC_TitleBarCloseButton) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) {
- QRect closeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget);
- if (closeButtonRect.isValid()) {
- bool hover = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_MouseOver);
- bool sunken = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_Sunken);
- qt_gtk_draw_mdibutton(painter, titleBar, closeButtonRect, hover, sunken);
- QRect closeIconRect = closeButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin);
- painter->setPen(textAlphaColor);
- const QLine lines[4] = {
- QLine(closeIconRect.left() + 1, closeIconRect.top(),
- closeIconRect.right(), closeIconRect.bottom() - 1),
- QLine(closeIconRect.left(), closeIconRect.top() + 1,
- closeIconRect.right() - 1, closeIconRect.bottom()),
- QLine(closeIconRect.right() - 1, closeIconRect.top(),
- closeIconRect.left(), closeIconRect.bottom() - 1),
- QLine(closeIconRect.right(), closeIconRect.top() + 1,
- closeIconRect.left() + 1, closeIconRect.bottom())
- };
- painter->drawLines(lines, 4);
- const QPoint points[4] = {
- closeIconRect.topLeft(),
- closeIconRect.topRight(),
- closeIconRect.bottomLeft(),
- closeIconRect.bottomRight()
- };
- painter->drawPoints(points, 4);
-
- painter->setPen(textColor);
- painter->drawLine(closeIconRect.left() + 1, closeIconRect.top() + 1,
- closeIconRect.right() - 1, closeIconRect.bottom() - 1);
- painter->drawLine(closeIconRect.left() + 1, closeIconRect.bottom() - 1,
- closeIconRect.right() - 1, closeIconRect.top() + 1);
- }
- }
-
- // normalize button
- if ((titleBar->subControls & SC_TitleBarNormalButton) &&
- (((titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) &&
- (titleBar->titleBarState & Qt::WindowMinimized)) ||
- ((titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) &&
- (titleBar->titleBarState & Qt::WindowMaximized)))) {
- QRect normalButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget);
- if (normalButtonRect.isValid()) {
-
- bool hover = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_MouseOver);
- bool sunken = (titleBar->activeSubControls & SC_TitleBarNormalButton) && (titleBar->state & State_Sunken);
- QRect normalButtonIconRect = normalButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin);
- qt_gtk_draw_mdibutton(painter, titleBar, normalButtonRect, hover, sunken);
-
- QRect frontWindowRect = normalButtonIconRect.adjusted(0, 3, -3, 0);
- painter->setPen(textColor);
- painter->drawRect(frontWindowRect.adjusted(0, 0, -1, -1));
- painter->drawLine(frontWindowRect.left() + 1, frontWindowRect.top() + 1,
- frontWindowRect.right() - 1, frontWindowRect.top() + 1);
- painter->setPen(textAlphaColor);
- const QPoint points[4] = {
- frontWindowRect.topLeft(),
- frontWindowRect.topRight(),
- frontWindowRect.bottomLeft(),
- frontWindowRect.bottomRight()
- };
- painter->drawPoints(points, 4);
-
- QRect backWindowRect = normalButtonIconRect.adjusted(3, 0, 0, -3);
- QRegion clipRegion = backWindowRect;
- clipRegion -= frontWindowRect;
- painter->save();
- painter->setClipRegion(clipRegion);
- painter->setPen(textColor);
- painter->drawRect(backWindowRect.adjusted(0, 0, -1, -1));
- painter->drawLine(backWindowRect.left() + 1, backWindowRect.top() + 1,
- backWindowRect.right() - 1, backWindowRect.top() + 1);
- painter->setPen(textAlphaColor);
- const QPoint points2[4] = {
- backWindowRect.topLeft(),
- backWindowRect.topRight(),
- backWindowRect.bottomLeft(),
- backWindowRect.bottomRight()
- };
- painter->drawPoints(points2, 4);
- painter->restore();
- }
- }
-
- // context help button
- if (titleBar->subControls & SC_TitleBarContextHelpButton
- && (titleBar->titleBarFlags & Qt::WindowContextHelpButtonHint)) {
- QRect contextHelpButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget);
- if (contextHelpButtonRect.isValid()) {
- bool hover = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_MouseOver);
- bool sunken = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_Sunken);
- qt_gtk_draw_mdibutton(painter, titleBar, contextHelpButtonRect, hover, sunken);
-
- QColor blend;
- QImage image(qt_titlebar_context_help);
- QColor alpha = textColor;
- alpha.setAlpha(128);
- image.setColor(1, textColor.rgba());
- image.setColor(2, alpha.rgba());
- painter->setRenderHint(QPainter::SmoothPixmapTransform);
- painter->drawImage(contextHelpButtonRect.adjusted(4, 4, -4, -4), image);
- }
- }
-
- // shade button
- if (titleBar->subControls & SC_TitleBarShadeButton && (titleBar->titleBarFlags & Qt::WindowShadeButtonHint)) {
- QRect shadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget);
- if (shadeButtonRect.isValid()) {
- bool hover = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_MouseOver);
- bool sunken = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_Sunken);
- qt_gtk_draw_mdibutton(painter, titleBar, shadeButtonRect, hover, sunken);
- QImage image(qt_scrollbar_button_arrow_up);
- image.setColor(1, textColor.rgba());
- painter->drawImage(shadeButtonRect.adjusted(5, 7, -5, -7), image);
- }
- }
-
- // unshade button
- if (titleBar->subControls & SC_TitleBarUnshadeButton && (titleBar->titleBarFlags & Qt::WindowShadeButtonHint)) {
- QRect unshadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget);
- if (unshadeButtonRect.isValid()) {
- bool hover = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_MouseOver);
- bool sunken = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_Sunken);
- qt_gtk_draw_mdibutton(painter, titleBar, unshadeButtonRect, hover, sunken);
- QImage image(qt_scrollbar_button_arrow_down);
- image.setColor(1, textColor.rgba());
- painter->drawImage(unshadeButtonRect.adjusted(5, 7, -5, -7), image);
- }
- }
-
- if ((titleBar->subControls & SC_TitleBarSysMenu) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) {
- QRect iconRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget);
- if (iconRect.isValid()) {
- if (!titleBar->icon.isNull()) {
- titleBar->icon.paint(painter, iconRect);
- } else {
- QStyleOption tool(0);
- tool.palette = titleBar->palette;
- QPixmap pm = proxy()->standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(16, 16);
- tool.rect = iconRect;
- painter->save();
- proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm);
- painter->restore();
- }
- }
- }
- }
- painter->restore();
- break;
-
-#ifndef QT_NO_GROUPBOX
-
- case CC_GroupBox:
- painter->save();
-
- if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
- QRect textRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget);
- QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxCheckBox, widget);
- // Draw title
-
- if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {
- // Draw prelight background
- GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton");
-
- if (option->state & State_MouseOver) {
- QRect bgRect = textRect | checkBoxRect;
- gtkPainter->paintFlatBox(gtkCheckButton, "checkbutton", bgRect.adjusted(0, 0, 0, -2),
- GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, d->gtk_widget_get_style(gtkCheckButton));
- }
-
- if (!groupBox->text.isEmpty()) {
- int alignment = int(groupBox->textAlignment);
- if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, option, widget))
- alignment |= Qt::TextHideMnemonic;
- QColor textColor = groupBox->textColor; // Note: custom textColor is currently ignored
- int labelState = GTK_STATE_INSENSITIVE;
-
- if (option->state & State_Enabled)
- labelState = (option->state & State_MouseOver) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
-
- GdkColor gdkText = d->gtk_widget_get_style(gtkCheckButton)->fg[labelState];
- textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
- painter->setPen(textColor);
- QFont font = painter->font();
- font.setBold(true);
- painter->setFont(font);
- painter->drawText(textRect, Qt::TextShowMnemonic | Qt::AlignLeft| alignment, groupBox->text);
-
- if (option->state & State_HasFocus)
- gtkPainter->paintFocus(gtkCheckButton, "checkbutton", textRect.adjusted(-4, -1, 0, -3), GTK_STATE_ACTIVE, style);
- }
- }
-
- if (groupBox->subControls & SC_GroupBoxCheckBox) {
- QStyleOptionButton box;
- box.QStyleOption::operator=(*groupBox);
- box.rect = checkBoxRect;
- proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget);
- }
- }
-
- painter->restore();
- break;
-#endif // QT_NO_GROUPBOX
-
-#ifndef QT_NO_COMBOBOX
-
- case CC_ComboBox:
- // See: http://live.gnome.org/GnomeArt/Tutorials/GtkThemes/GtkComboBox
- // and http://live.gnome.org/GnomeArt/Tutorials/GtkThemes/GtkComboBoxEntry
- if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
- bool sunken = comboBox->state & State_On; // play dead, if combobox has no items
- BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("cb-%0-%1").arg(sunken).arg(comboBox->editable));
- gtkPainter->reset(p);
- gtkPainter->setUsePixmapCache(false); // cached externally
-
- bool isEnabled = (comboBox->state & State_Enabled);
- bool focus = isEnabled && (comboBox->state & State_HasFocus);
- GtkStateType state = qt_gtk_state(option);
- int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, comboBox, widget);
- QStyleOptionComboBox comboBoxCopy = *comboBox;
- comboBoxCopy.rect = option->rect;
-
- bool reverse = (option->direction == Qt::RightToLeft);
- QRect rect = option->rect;
- QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy,
- SC_ComboBoxArrow, widget);
-
- GtkShadowType shadow = (option->state & State_Sunken || option->state & State_On ) ?
- GTK_SHADOW_IN : GTK_SHADOW_OUT;
- const QHashableLatin1Literal comboBoxPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry") : QHashableLatin1Literal("GtkComboBox");
-
- // We use the gtk widget to position arrows and separators for us
- GtkWidget *gtkCombo = d->gtkWidget(comboBoxPath);
- GtkAllocation geometry = {0, 0, option->rect.width(), option->rect.height()};
- d->gtk_widget_set_direction(gtkCombo, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
- d->gtk_widget_size_allocate(gtkCombo, &geometry);
-
- QHashableLatin1Literal buttonPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton")
- : QHashableLatin1Literal("GtkComboBox.GtkToggleButton");
- GtkWidget *gtkToggleButton = d->gtkWidget(buttonPath);
- d->gtk_widget_set_direction(gtkToggleButton, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
- if (gtkToggleButton && (appears_as_list || comboBox->editable)) {
- if (focus)
- QGtkStylePrivate::gtkWidgetSetFocus(gtkToggleButton, true);
- // Draw the combo box as a line edit with a button next to it
- if (comboBox->editable || appears_as_list) {
- GtkStateType frameState = (state == GTK_STATE_PRELIGHT) ? GTK_STATE_NORMAL : state;
- QHashableLatin1Literal entryPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkEntry") : QHashableLatin1Literal("GtkComboBox.GtkFrame");
- GtkWidget *gtkEntry = d->gtkWidget(entryPath);
- d->gtk_widget_set_direction(gtkEntry, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
- QRect frameRect = option->rect;
-
- if (reverse)
- frameRect.setLeft(arrowButtonRect.right());
- else
- frameRect.setRight(arrowButtonRect.left());
-
- // Fill the line edit background
- // We could have used flat_box with "entry_bg" but that is probably not worth the overhead
- uint resolve_mask = option->palette.resolve();
- GtkStyle *gtkEntryStyle = d->gtk_widget_get_style(gtkEntry);
- QRect contentRect = frameRect.adjusted(gtkEntryStyle->xthickness, gtkEntryStyle->ythickness,
- -gtkEntryStyle->xthickness, -gtkEntryStyle->ythickness);
- // Required for inner blue highlight with clearlooks
- if (focus)
- QGtkStylePrivate::gtkWidgetSetFocus(gtkEntry, true);
-
- if (widget && widget->testAttribute(Qt::WA_SetPalette) &&
- resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
- p->fillRect(contentRect, option->palette.base().color());
- else {
- gtkPainter->paintFlatBox(gtkEntry, "entry_bg", contentRect,
- option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
- GTK_SHADOW_NONE, gtkEntryStyle, entryPath.toString() + QString::number(focus));
- }
-
- gtkPainter->paintShadow(gtkEntry, comboBox->editable ? "entry" : "frame", frameRect, frameState,
- GTK_SHADOW_IN, gtkEntryStyle, entryPath.toString() +
- QString::number(focus) + QString::number(comboBox->editable) +
- QString::number(option->direction));
- if (focus)
- QGtkStylePrivate::gtkWidgetSetFocus(gtkEntry, false);
- }
-
- GtkStateType buttonState = GTK_STATE_NORMAL;
-
- if (!(option->state & State_Enabled))
- buttonState = GTK_STATE_INSENSITIVE;
- else if (option->state & State_Sunken || option->state & State_On)
- buttonState = GTK_STATE_ACTIVE;
- else if (option->state & State_MouseOver && comboBox->activeSubControls & SC_ComboBoxArrow)
- buttonState = GTK_STATE_PRELIGHT;
-
- Q_ASSERT(gtkToggleButton);
- gtkPainter->paintBox(gtkToggleButton, "button", arrowButtonRect, buttonState,
- shadow, d->gtk_widget_get_style(gtkToggleButton), buttonPath.toString() +
- QString::number(focus) + QString::number(option->direction));
- if (focus)
- QGtkStylePrivate::gtkWidgetSetFocus(gtkToggleButton, false);
- } else {
- // Draw combo box as a button
- QRect buttonRect = option->rect;
- GtkStyle *gtkToggleButtonStyle = d->gtk_widget_get_style(gtkToggleButton);
-
- if (focus) // Clearlooks actually check the widget for the default state
- QGtkStylePrivate::gtkWidgetSetFocus(gtkToggleButton, true);
- gtkPainter->paintBox(gtkToggleButton, "button",
- buttonRect, state,
- shadow, gtkToggleButtonStyle,
- buttonPath.toString() + QString::number(focus));
- if (focus)
- QGtkStylePrivate::gtkWidgetSetFocus(gtkToggleButton, false);
-
-
- // Draw the separator between label and arrows
- QHashableLatin1Literal vSeparatorPath = comboBox->editable
- ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkHBox.GtkVSeparator")
- : QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkHBox.GtkVSeparator");
-
- if (GtkWidget *gtkVSeparator = d->gtkWidget(vSeparatorPath)) {
- GtkAllocation allocation;
- d->gtk_widget_get_allocation(gtkVSeparator, &allocation);
- QRect vLineRect(allocation.x, allocation.y, allocation.width, allocation.height);
-
- gtkPainter->paintVline(gtkVSeparator, "vseparator",
- vLineRect, state, d->gtk_widget_get_style(gtkVSeparator),
- 0, vLineRect.height(), 0, vSeparatorPath.toString());
-
-
- gint interiorFocus = true;
- d->gtk_widget_style_get(gtkToggleButton, "interior-focus", &interiorFocus, NULL);
- int xt = interiorFocus ? gtkToggleButtonStyle->xthickness : 0;
- int yt = interiorFocus ? gtkToggleButtonStyle->ythickness : 0;
- if (focus && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget)))
- gtkPainter->paintFocus(gtkToggleButton, "button",
- option->rect.adjusted(xt, yt, -xt, -yt),
- option->state & State_Sunken ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL,
- gtkToggleButtonStyle);
- }
- }
-
- if (comboBox->subControls & SC_ComboBoxArrow) {
- if (!isEnabled)
- state = GTK_STATE_INSENSITIVE;
- else if (sunken)
- state = GTK_STATE_ACTIVE;
- else if (option->state & State_MouseOver)
- state = GTK_STATE_PRELIGHT;
- else
- state = GTK_STATE_NORMAL;
-
- QHashableLatin1Literal arrowPath("");
- if (comboBox->editable) {
- if (appears_as_list)
- arrowPath = QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkArrow");
- else
- arrowPath = QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkHBox.GtkArrow");
- } else {
- if (appears_as_list)
- arrowPath = QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkArrow");
- else
- arrowPath = QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkHBox.GtkArrow");
- }
-
- GtkWidget *gtkArrow = d->gtkWidget(arrowPath);
- gfloat scale = 0.7;
- gint minSize = 15;
- QRect arrowWidgetRect;
-
- if (gtkArrow && !d->gtk_check_version(2, 12, 0)) {
- d->gtk_widget_style_get(gtkArrow, "arrow-scaling", &scale, NULL);
- d->gtk_widget_style_get(gtkCombo, "arrow-size", &minSize, NULL);
- }
- if (gtkArrow) {
- GtkAllocation allocation;
- d->gtk_widget_get_allocation(gtkArrow, &allocation);
- arrowWidgetRect = QRect(allocation.x, allocation.y, allocation.width, allocation.height);
- style = d->gtk_widget_get_style(gtkArrow);
- }
-
- // Note that for some reason the arrow-size is not properly respected with Hildon
- // Hence we enforce the minimum "arrow-size" ourselves
- int arrowSize = qMax(qMin(rect.height() - d->gtk_widget_get_style(gtkCombo)->ythickness * 2, minSize),
- qMin(arrowWidgetRect.width(), arrowWidgetRect.height()));
- QRect arrowRect(0, 0, static_cast<int>(arrowSize * scale), static_cast<int>(arrowSize * scale));
-
- arrowRect.moveCenter(arrowWidgetRect.center());
-
- if (sunken) {
- int xoff, yoff;
- const QHashableLatin1Literal toggleButtonPath = comboBox->editable
- ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton")
- : QHashableLatin1Literal("GtkComboBox.GtkToggleButton");
-
- GtkWidget *gtkButton = d->gtkWidget(toggleButtonPath);
- d->gtk_widget_style_get(gtkButton, "child-displacement-x", &xoff, NULL);
- d->gtk_widget_style_get(gtkButton, "child-displacement-y", &yoff, NULL);
- arrowRect = arrowRect.adjusted(xoff, yoff, xoff, yoff);
- }
-
- // Some styles such as Nimbus paint outside the arrowRect
- // hence we have provide the whole widget as the cliprect
- if (gtkArrow) {
- gtkPainter->setClipRect(option->rect);
- gtkPainter->paintArrow(gtkArrow, "arrow", arrowRect,
- GTK_ARROW_DOWN, state, GTK_SHADOW_NONE, true,
- style, arrowPath.toString() + QString::number(option->direction));
- }
- }
- END_STYLE_PIXMAPCACHE;
- }
- break;
-#endif // QT_NO_COMBOBOX
-#ifndef QT_NO_TOOLBUTTON
-
- case CC_ToolButton:
- if (const QStyleOptionToolButton *toolbutton
- = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
- QRect button, menuarea;
- button = proxy()->subControlRect(control, toolbutton, SC_ToolButton, widget);
- menuarea = proxy()->subControlRect(control, toolbutton, SC_ToolButtonMenu, widget);
- State bflags = toolbutton->state & ~(State_Sunken | State_MouseOver);
-
- if (bflags & State_AutoRaise)
- if (!(bflags & State_MouseOver))
- bflags &= ~State_Raised;
-
- State mflags = bflags;
-
- if (toolbutton->state & State_Sunken) {
- if (toolbutton->activeSubControls & SC_ToolButton)
- bflags |= State_Sunken;
- if (toolbutton->activeSubControls & SC_ToolButtonMenu)
- mflags |= State_Sunken;
- } else if (toolbutton->state & State_MouseOver) {
- if (toolbutton->activeSubControls & SC_ToolButton)
- bflags |= State_MouseOver;
- if (toolbutton->activeSubControls & SC_ToolButtonMenu)
- mflags |= State_MouseOver;
- }
-
- QStyleOption tool(0);
-
- tool.palette = toolbutton->palette;
-
- if (toolbutton->subControls & SC_ToolButton) {
- if (bflags & (State_Sunken | State_On | State_Raised | State_MouseOver)) {
- tool.rect = button;
- tool.state = bflags;
- proxy()->drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
- }
- }
-
- bool drawMenuArrow = toolbutton->features & QStyleOptionToolButton::HasMenu &&
- !(toolbutton->features & QStyleOptionToolButton::MenuButtonPopup);
- int popupArrowSize = drawMenuArrow ? 7 : 0;
-
- if (toolbutton->state & State_HasFocus) {
- QStyleOptionFocusRect fr;
- fr.QStyleOption::operator=(*toolbutton);
- fr.rect = proxy()->subControlRect(CC_ToolButton, toolbutton, SC_ToolButton, widget);
- fr.rect.adjust(1, 1, -1, -1);
- proxy()->drawPrimitive(PE_FrameFocusRect, &fr, painter, widget);
- }
-
- QStyleOptionToolButton label = *toolbutton;
- label.state = bflags;
- GtkWidget *gtkButton = d->gtkWidget("GtkToolButton.GtkButton");
- QPalette pal = toolbutton->palette;
- if (option->state & State_Enabled &&
- option->state & State_MouseOver && !(widget && widget->testAttribute(Qt::WA_SetPalette))) {
- GdkColor gdkText = d->gtk_widget_get_style(gtkButton)->fg[GTK_STATE_PRELIGHT];
- QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
- pal.setBrush(QPalette::All, QPalette::ButtonText, textColor);
- label.palette = pal;
- }
- label.rect = button.adjusted(style->xthickness, style->ythickness,
- -style->xthickness - popupArrowSize, -style->ythickness);
- proxy()->drawControl(CE_ToolButtonLabel, &label, painter, widget);
-
- if (toolbutton->subControls & SC_ToolButtonMenu) {
- tool.rect = menuarea;
- tool.state = mflags;
- if ((mflags & State_Enabled && (mflags & (State_Sunken | State_Raised | State_MouseOver))) || !(mflags & State_AutoRaise))
- proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, painter, widget);
-
- proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget);
-
- } else if (drawMenuArrow) {
- QRect ir = toolbutton->rect;
- QStyleOptionToolButton newBtn = *toolbutton;
- newBtn.rect = QRect(ir.right() - popupArrowSize - style->xthickness - 3, ir.height()/2 - 1, popupArrowSize, popupArrowSize);
- proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget);
- }
- }
- break;
-
-#endif // QT_NO_TOOLBUTTON
-#ifndef QT_NO_SCROLLBAR
-
- case CC_ScrollBar:
- if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
- GtkWidget *gtkHScrollBar = d->gtkWidget("GtkHScrollbar");
- GtkWidget *gtkVScrollBar = d->gtkWidget("GtkVScrollbar");
-
- // Fill background in case the scrollbar is partially transparent
- painter->fillRect(option->rect, option->palette.background());
-
- QRect rect = scrollBar->rect;
- QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget);
- QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget);
- QRect scrollBarSlider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget);
- QRect grooveRect = proxy()->subControlRect(control, scrollBar, SC_ScrollBarGroove, widget);
- bool horizontal = scrollBar->orientation == Qt::Horizontal;
- GtkWidget * scrollbarWidget = horizontal ? gtkHScrollBar : gtkVScrollBar;
- style = d->gtk_widget_get_style(scrollbarWidget);
- gboolean trough_under_steppers = true;
- gboolean trough_side_details = false;
- gboolean activate_slider = false;
- gboolean stepper_size = 14;
- gint trough_border = 1;
- if (!d->gtk_check_version(2, 10, 0)) {
- d->gtk_widget_style_get((GtkWidget*)(scrollbarWidget),
- "trough-border", &trough_border,
- "trough-side-details", &trough_side_details,
- "trough-under-steppers", &trough_under_steppers,
- "activate-slider", &activate_slider,
- "stepper-size", &stepper_size, NULL);
- }
- if (trough_under_steppers) {
- scrollBarAddLine.adjust(trough_border, trough_border, -trough_border, -trough_border);
- scrollBarSubLine.adjust(trough_border, trough_border, -trough_border, -trough_border);
- scrollBarSlider.adjust(horizontal ? -trough_border : 0, horizontal ? 0 : -trough_border,
- horizontal ? trough_border : 0, horizontal ? 0 : trough_border);
- }
-
- // Some styles check the position of scrollbars in order to determine
- // if lines should be painted when the scrollbar is in max or min positions.
- int maximum = 2;
- int fakePos = 0;
- bool reverse = (option->direction == Qt::RightToLeft);
- if (scrollBar->minimum == scrollBar->maximum)
- maximum = 0;
- if (scrollBar->sliderPosition == scrollBar->maximum)
- fakePos = maximum;
- else if (scrollBar->sliderPosition > scrollBar->minimum)
- fakePos = maximum - 1;
-
-
- GtkRange *range = (GtkRange*)(horizontal ? gtkHScrollBar : gtkVScrollBar);
- GtkAdjustment *adjustment = 0;
-
- if (d->gtk_adjustment_configure)
- adjustment = d->gtk_range_get_adjustment(range);
- if (adjustment) {
- d->gtk_adjustment_configure(adjustment, fakePos, 0, maximum, 0, 0, 0);
- } else {
- adjustment = (GtkAdjustment*)d->gtk_adjustment_new(fakePos, 0, maximum, 0, 0, 0);
- d->gtk_range_set_adjustment(range, adjustment);
- }
-
- if (scrollBar->subControls & SC_ScrollBarGroove) {
- GtkStateType state = GTK_STATE_ACTIVE;
-
- if (!(option->state & State_Enabled))
- state = GTK_STATE_INSENSITIVE;
-
- if (trough_under_steppers)
- grooveRect = option->rect;
-
- gtkPainter->paintBox(scrollbarWidget, "trough", grooveRect, state, GTK_SHADOW_IN, style);
- }
-
- //paint slider
- if (scrollBar->subControls & SC_ScrollBarSlider) {
- GtkStateType state = GTK_STATE_NORMAL;
-
- if (!(option->state & State_Enabled))
- state = GTK_STATE_INSENSITIVE;
- else if (activate_slider &&
- option->state & State_Sunken && (scrollBar->activeSubControls & SC_ScrollBarSlider))
- state = GTK_STATE_ACTIVE;
- else if (option->state & State_MouseOver && (scrollBar->activeSubControls & SC_ScrollBarSlider))
- state = GTK_STATE_PRELIGHT;
-
- GtkShadowType shadow = GTK_SHADOW_OUT;
-
- if (trough_under_steppers) {
- if (!horizontal)
- scrollBarSlider.adjust(trough_border, 0, -trough_border, 0);
- else
- scrollBarSlider.adjust(0, trough_border, 0, -trough_border);
- }
-
- gtkPainter->paintSlider(scrollbarWidget, "slider", scrollBarSlider, state, shadow, style,
- horizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, QString(QLS("%0%1")).arg(fakePos).arg(maximum));
- }
-
- if (scrollBar->subControls & SC_ScrollBarAddLine) {
- GtkAllocation vAllocation;
- vAllocation.y = scrollBarAddLine.top();
- vAllocation.height = scrollBarAddLine.height() - rect.height() + 6;
- d->gtk_widget_set_allocation(gtkVScrollBar, &vAllocation);
-
- GtkAllocation hAllocation;
- hAllocation.x = scrollBarAddLine.right();
- hAllocation.width = scrollBarAddLine.width() - rect.width();
- d->gtk_widget_set_allocation(gtkHScrollBar, &hAllocation);
-
- GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = GTK_STATE_NORMAL;
-
- if (!(option->state & State_Enabled) || (fakePos == maximum))
- state = GTK_STATE_INSENSITIVE;
- else if (option->state & State_Sunken && (scrollBar->activeSubControls & SC_ScrollBarAddLine)) {
- state = GTK_STATE_ACTIVE;
- shadow = GTK_SHADOW_IN;
-
- } else if (option->state & State_MouseOver && (scrollBar->activeSubControls & SC_ScrollBarAddLine))
- state = GTK_STATE_PRELIGHT;
-
- gtkPainter->paintBox(scrollbarWidget,
- horizontal ? "hscrollbar" : "vscrollbar", scrollBarAddLine,
- state, shadow, style, QLS("add"));
-
- gtkPainter->paintArrow(scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarAddLine.adjusted(4, 4, -4, -4),
- horizontal ? (reverse ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT) :
- GTK_ARROW_DOWN, state, GTK_SHADOW_NONE, false, style);
- }
-
- if (scrollBar->subControls & SC_ScrollBarSubLine) {
- GtkAllocation vAllocation;
- vAllocation.y = 0;
- vAllocation.height = scrollBarSubLine.height();
- d->gtk_widget_set_allocation(gtkVScrollBar, &vAllocation);
-
- GtkAllocation hAllocation;
- hAllocation.x = 0;
- hAllocation.width = scrollBarSubLine.width();
- d->gtk_widget_set_allocation(gtkHScrollBar, &hAllocation);
-
- GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = GTK_STATE_NORMAL;
-
- if (!(option->state & State_Enabled) || (fakePos == 0))
- state = GTK_STATE_INSENSITIVE;
- else if (option->state & State_Sunken && (scrollBar->activeSubControls & SC_ScrollBarSubLine)) {
- shadow = GTK_SHADOW_IN;
- state = GTK_STATE_ACTIVE;
-
- } else if (option->state & State_MouseOver && (scrollBar->activeSubControls & SC_ScrollBarSubLine))
- state = GTK_STATE_PRELIGHT;
-
- gtkPainter->paintBox(scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarSubLine,
- state, shadow, style, QLS("sub"));
-
- gtkPainter->paintArrow(scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarSubLine.adjusted(4, 4, -4, -4),
- horizontal ? (reverse ? GTK_ARROW_RIGHT : GTK_ARROW_LEFT) :
- GTK_ARROW_UP, state, GTK_SHADOW_NONE, false, style);
- }
- }
- break;
-
-#endif //QT_NO_SCROLLBAR
-#ifndef QT_NO_SPINBOX
-
- case CC_SpinBox:
- if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
-
- GtkWidget *gtkSpinButton = spinBox->buttonSymbols == QAbstractSpinBox::NoButtons
- ? d->gtkWidget("GtkEntry")
- : d->gtkWidget("GtkSpinButton");
- bool isEnabled = (spinBox->state & State_Enabled);
- bool hover = isEnabled && (spinBox->state & State_MouseOver);
- bool sunken = (spinBox->state & State_Sunken);
- bool upIsActive = (spinBox->activeSubControls == SC_SpinBoxUp);
- bool downIsActive = (spinBox->activeSubControls == SC_SpinBoxDown);
- bool reverse = (spinBox->direction == Qt::RightToLeft);
-
- QRect editArea = option->rect;
- QRect editRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxEditField, widget);
- QRect upRect, downRect, buttonRect;
- if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) {
- upRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget);
- downRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);
-
- //### Move this to subControlRect
- upRect.setTop(option->rect.top());
-
- if (reverse)
- upRect.setLeft(option->rect.left());
- else
- upRect.setRight(option->rect.right());
-
- downRect.setBottom(option->rect.bottom());
-
- if (reverse)
- downRect.setLeft(option->rect.left());
- else
- downRect.setRight(option->rect.right());
-
- buttonRect = upRect | downRect;
-
- if (reverse)
- editArea.setLeft(upRect.right());
- else
- editArea.setRight(upRect.left());
- }
- if (spinBox->frame) {
- GtkStateType state = qt_gtk_state(option);
-
- if (!(option->state & State_Enabled))
- state = GTK_STATE_INSENSITIVE;
- else if (option->state & State_HasFocus)
- state = GTK_STATE_NORMAL;
- else if (state == GTK_STATE_PRELIGHT)
- state = GTK_STATE_NORMAL;
-
- style = d->gtk_widget_get_style(gtkSpinButton);
-
-
- QString key;
-
- if (option->state & State_HasFocus) {
- key += QLatin1Char('f');
- QGtkStylePrivate::gtkWidgetSetFocus(gtkSpinButton, true);
- }
-
- uint resolve_mask = option->palette.resolve();
-
- if (resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
- painter->fillRect(editRect, option->palette.base().color());
- else
- gtkPainter->paintFlatBox(gtkSpinButton, "entry_bg", editArea.adjusted(style->xthickness, style->ythickness,
- -style->xthickness, -style->ythickness),
- option->state & State_Enabled ?
- GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, style, key);
-
- gtkPainter->paintShadow(gtkSpinButton, "entry", editArea, state, GTK_SHADOW_IN, d->gtk_widget_get_style(gtkSpinButton), key);
- if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) {
- gtkPainter->paintBox(gtkSpinButton, "spinbutton", buttonRect, state, GTK_SHADOW_IN, style, key);
-
- upRect.setSize(downRect.size());
- if (!(option->state & State_Enabled))
- gtkPainter->paintBox(gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key);
- else if (upIsActive && sunken)
- gtkPainter->paintBox(gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key);
- else if (upIsActive && hover)
- gtkPainter->paintBox(gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key);
- else
- gtkPainter->paintBox(gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key);
-
- if (!(option->state & State_Enabled))
- gtkPainter->paintBox(gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key);
- else if (downIsActive && sunken)
- gtkPainter->paintBox(gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key);
- else if (downIsActive && hover)
- gtkPainter->paintBox(gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key);
- else
- gtkPainter->paintBox(gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key);
-
- if (option->state & State_HasFocus)
- QGtkStylePrivate::gtkWidgetSetFocus(gtkSpinButton, false);
- }
- }
-
- if (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) {
- int centerX = upRect.center().x();
- int centerY = upRect.center().y();
- // plus/minus
-
- if (spinBox->activeSubControls == SC_SpinBoxUp && sunken) {
- painter->drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY);
- painter->drawLine(1 + centerX, 1 + centerY - 2, 1 + centerX, 1 + centerY + 2);
-
- } else {
- painter->drawLine(centerX - 2, centerY, centerX + 2, centerY);
- painter->drawLine(centerX, centerY - 2, centerX, centerY + 2);
- }
- centerX = downRect.center().x();
- centerY = downRect.center().y();
-
- if (spinBox->activeSubControls == SC_SpinBoxDown && sunken) {
- painter->drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY);
- } else {
- painter->drawLine(centerX - 2, centerY, centerX + 2, centerY);
- }
-
- } else if (spinBox->buttonSymbols == QAbstractSpinBox::UpDownArrows) {
- int size = d->getSpinboxArrowSize();
- int w = size / 2 - 1;
- w -= w % 2 - 1; // force odd
- int h = (w + 1)/2;
- QRect arrowRect(0, 0, w, h);
- arrowRect.moveCenter(upRect.center());
- // arrows
- GtkStateType state = GTK_STATE_NORMAL;
-
- if (!(option->state & State_Enabled) || !(spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled))
- state = GTK_STATE_INSENSITIVE;
-
- gtkPainter->paintArrow(gtkSpinButton, "spinbutton", arrowRect, GTK_ARROW_UP, state,
- GTK_SHADOW_NONE, false, style);
-
- arrowRect.moveCenter(downRect.center());
-
- if (!(option->state & State_Enabled) || !(spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled))
- state = GTK_STATE_INSENSITIVE;
-
- gtkPainter->paintArrow(gtkSpinButton, "spinbutton", arrowRect, GTK_ARROW_DOWN, state,
- GTK_SHADOW_NONE, false, style);
- }
- }
- break;
-
-#endif // QT_NO_SPINBOX
-
-#ifndef QT_NO_SLIDER
-
- case CC_Slider:
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
- GtkWidget *hScaleWidget = d->gtkWidget("GtkHScale");
- GtkWidget *vScaleWidget = d->gtkWidget("GtkVScale");
-
- QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget);
- QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget);
-
- bool horizontal = slider->orientation == Qt::Horizontal;
- bool ticksAbove = slider->tickPosition & QSlider::TicksAbove;
- bool ticksBelow = slider->tickPosition & QSlider::TicksBelow;
-
- QBrush oldBrush = painter->brush();
- QPen oldPen = painter->pen();
-
- QColor shadowAlpha(Qt::black);
- shadowAlpha.setAlpha(10);
- QColor highlightAlpha(Qt::white);
- highlightAlpha.setAlpha(80);
-
- QGtkStylePrivate::gtk_widget_set_direction(hScaleWidget, slider->upsideDown ?
- GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
- GtkWidget *scaleWidget = horizontal ? hScaleWidget : vScaleWidget;
- style = d->gtk_widget_get_style(scaleWidget);
-
- if ((option->subControls & SC_SliderGroove) && groove.isValid()) {
-
- GtkRange *range = (GtkRange*)scaleWidget;
- GtkAdjustment *adjustment = 0;
- if (d->gtk_adjustment_configure)
- adjustment = d->gtk_range_get_adjustment(range);
- if (adjustment) {
- d->gtk_adjustment_configure(adjustment,
- slider->sliderPosition,
- slider->minimum,
- slider->maximum,
- slider->singleStep,
- slider->singleStep,
- slider->pageStep);
- } else {
- adjustment = (GtkAdjustment*)d->gtk_adjustment_new(slider->sliderPosition,
- slider->minimum,
- slider->maximum,
- slider->singleStep,
- slider->singleStep,
- slider->pageStep);
- d->gtk_range_set_adjustment(range, adjustment);
- }
-
- int outerSize;
- d->gtk_range_set_inverted(range, !horizontal);
- d->gtk_widget_style_get(scaleWidget, "trough-border", &outerSize, NULL);
- outerSize++;
-
- GtkStateType state = qt_gtk_state(option);
- int focusFrameMargin = 2;
- QRect grooveRect = option->rect.adjusted(focusFrameMargin, outerSize + focusFrameMargin,
- -focusFrameMargin, -outerSize - focusFrameMargin);
-
- gboolean trough_side_details = false; // Indicates if the upper or lower scale background differs
- if (!d->gtk_check_version(2, 10, 0))
- d->gtk_widget_style_get((GtkWidget*)(scaleWidget), "trough-side-details", &trough_side_details, NULL);
-
- if (!trough_side_details) {
- gtkPainter->paintBox(scaleWidget, "trough", grooveRect, state,
- GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
- } else {
- QRect upperGroove = grooveRect;
- QRect lowerGroove = grooveRect;
-
- if (horizontal) {
- if (slider->upsideDown) {
- lowerGroove.setLeft(handle.center().x());
- upperGroove.setRight(handle.center().x());
- } else {
- upperGroove.setLeft(handle.center().x());
- lowerGroove.setRight(handle.center().x());
- }
- } else {
- if (!slider->upsideDown) {
- lowerGroove.setBottom(handle.center().y());
- upperGroove.setTop(handle.center().y());
- } else {
- upperGroove.setBottom(handle.center().y());
- lowerGroove.setTop(handle.center().y());
- }
- }
-
- gtkPainter->paintBox(scaleWidget, "trough-upper", upperGroove, state,
- GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
- gtkPainter->paintBox(scaleWidget, "trough-lower", lowerGroove, state,
- GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
- }
- }
-
- if (option->subControls & SC_SliderTickmarks) {
- painter->setPen(darkOutline);
- int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
- int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget);
- int interval = slider->tickInterval;
-
- if (interval <= 0) {
- interval = slider->singleStep;
-
- if (QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, interval,
- available)
- - QStyle::sliderPositionFromValue(slider->minimum, slider->maximum,
- 0, available) < 3)
- interval = slider->pageStep;
- }
-
- if (interval <= 0)
- interval = 1;
-
- int v = slider->minimum;
- int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
- while (v <= slider->maximum + 1) {
- if (v == slider->maximum + 1 && interval == 1)
- break;
- const int v_ = qMin(v, slider->maximum);
- int pos = sliderPositionFromValue(slider->minimum, slider->maximum,
- v_, (horizontal
- ? slider->rect.width()
- : slider->rect.height()) - len,
- slider->upsideDown) + len / 2;
- int extra = 2 - ((v_ == slider->minimum || v_ == slider->maximum) ? 1 : 0);
- if (horizontal) {
- if (ticksAbove)
- painter->drawLine(pos, slider->rect.top() + extra,
- pos, slider->rect.top() + tickSize);
- if (ticksBelow)
- painter->drawLine(pos, slider->rect.bottom() - extra,
- pos, slider->rect.bottom() - tickSize);
-
- } else {
- if (ticksAbove)
- painter->drawLine(slider->rect.left() + extra, pos,
- slider->rect.left() + tickSize, pos);
- if (ticksBelow)
- painter->drawLine(slider->rect.right() - extra, pos,
- slider->rect.right() - tickSize, pos);
- }
-
- // In the case where maximum is max int
- int nextInterval = v + interval;
- if (nextInterval < v)
- break;
- v = nextInterval;
- }
- }
-
- // Draw slider handle
- if (option->subControls & SC_SliderHandle) {
- GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = GTK_STATE_NORMAL;
-
- if (!(option->state & State_Enabled))
- state = GTK_STATE_INSENSITIVE;
- else if (option->state & State_MouseOver && option->activeSubControls & SC_SliderHandle)
- state = GTK_STATE_PRELIGHT;
-
- bool horizontal = option->state & State_Horizontal;
-
- if (slider->state & State_HasFocus) {
- QStyleOptionFocusRect fropt;
- fropt.QStyleOption::operator=(*slider);
- fropt.rect = slider->rect.adjusted(-1, -1 ,1, 1);
-
- if (horizontal) {
- fropt.rect.setTop(handle.top() - 3);
- fropt.rect.setBottom(handle.bottom() + 4);
-
- } else {
- fropt.rect.setLeft(handle.left() - 3);
- fropt.rect.setRight(handle.right() + 3);
- }
- proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
- }
- gtkPainter->paintSlider(scaleWidget, horizontal ? "hscale" : "vscale", handle, state, shadow, style,
- horizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
- }
- painter->setBrush(oldBrush);
- painter->setPen(oldPen);
- }
- break;
- case CC_Dial:
- if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option))
- QStyleHelper::drawDial(dial, painter);
- break;
-
-#endif // QT_NO_SLIDER
-
- default:
- QCommonStyle::drawComplexControl(control, option, painter, widget);
-
- break;
- }
-}
-
-
-/*!
- \reimp
-*/
-void QGtkStyle::drawControl(ControlElement element,
- const QStyleOption *option,
- QPainter *painter,
- const QWidget *widget) const
-{
- Q_D(const QGtkStyle);
-
- if (!d->isThemeAvailable()) {
- QCommonStyle::drawControl(element, option, painter, widget);
- return;
- }
-
- GtkStyle* style = d->gtkStyle();
- QGtkPainter* gtkPainter = d->gtkPainter(painter);
-
- switch (element) {
- case CE_ProgressBarLabel:
- if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
- GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar");
- if (!gtkProgressBar)
- return;
-
- QRect leftRect;
- QRect rect = bar->rect;
- GtkStyle *gtkProgressBarStyle = d->gtk_widget_get_style(gtkProgressBar);
- GdkColor gdkText = gtkProgressBarStyle->fg[GTK_STATE_NORMAL];
- QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
- gdkText = gtkProgressBarStyle->fg[GTK_STATE_PRELIGHT];
- QColor alternateTextColor= QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
-
- painter->save();
- bool vertical = false, inverted = false;
- if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
- vertical = (bar2->orientation == Qt::Vertical);
- inverted = bar2->invertedAppearance;
- }
- if (vertical)
- rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
- const int progressIndicatorPos = (bar->progress - qreal(bar->minimum)) * rect.width() /
- qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum);
- if (progressIndicatorPos >= 0 && progressIndicatorPos <= rect.width())
- leftRect = QRect(rect.left(), rect.top(), progressIndicatorPos, rect.height());
- if (vertical)
- leftRect.translate(rect.width() - progressIndicatorPos, 0);
-
- bool flip = (!vertical && (((bar->direction == Qt::RightToLeft) && !inverted) ||
- ((bar->direction == Qt::LeftToRight) && inverted)));
-
- QRegion rightRect = rect;
- rightRect = rightRect.subtracted(leftRect);
- painter->setClipRegion(rightRect);
- painter->setPen(flip ? alternateTextColor : textColor);
- painter->drawText(rect, bar->text, QTextOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter));
- if (!leftRect.isNull()) {
- painter->setPen(flip ? textColor : alternateTextColor);
- painter->setClipRect(leftRect);
- painter->drawText(rect, bar->text, QTextOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter));
- }
- painter->restore();
- }
- break;
- case CE_PushButtonLabel:
- if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- QRect ir = button->rect;
- uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic;
- QPoint buttonShift;
-
- if (option->state & State_Sunken)
- buttonShift = QPoint(pixelMetric(PM_ButtonShiftHorizontal, option, widget),
- proxy()->pixelMetric(PM_ButtonShiftVertical, option, widget));
-
- if (proxy()->styleHint(SH_UnderlineShortcut, button, widget))
- tf |= Qt::TextShowMnemonic;
- else
- tf |= Qt::TextHideMnemonic;
-
- if (!button->icon.isNull()) {
- //Center both icon and text
- QPoint point;
-
- QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled;
- if (mode == QIcon::Normal && button->state & State_HasFocus)
- mode = QIcon::Active;
-
- QIcon::State state = QIcon::Off;
-
- if (button->state & State_On)
- state = QIcon::On;
-
- QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state);
- int w = pixmap.width();
- int h = pixmap.height();
-
- if (!button->text.isEmpty())
- w += button->fontMetrics.boundingRect(option->rect, tf, button->text).width() + 4;
-
- point = QPoint(ir.x() + ir.width() / 2 - w / 2,
- ir.y() + ir.height() / 2 - h / 2);
-
- if (button->direction == Qt::RightToLeft)
- point.rx() += pixmap.width();
-
- painter->drawPixmap(visualPos(button->direction, button->rect, point + buttonShift), pixmap);
-
- if (button->direction == Qt::RightToLeft)
- ir.translate(-point.x() - 2, 0);
- else
- ir.translate(point.x() + pixmap.width() + 2, 0);
-
- // left-align text if there is
- if (!button->text.isEmpty())
- tf |= Qt::AlignLeft;
-
- } else {
- tf |= Qt::AlignHCenter;
- }
-
- ir.translate(buttonShift);
-
- if (button->features & QStyleOptionButton::HasMenu)
- ir = ir.adjusted(0, 0, -pixelMetric(PM_MenuButtonIndicator, button, widget), 0);
-
- GtkWidget *gtkButton = d->gtkWidget("GtkButton");
- QPalette pal = button->palette;
- int labelState = GTK_STATE_INSENSITIVE;
- if (option->state & State_Enabled)
- labelState = (option->state & State_MouseOver && !(option->state & State_Sunken)) ?
- GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
-
- GdkColor gdkText = d->gtk_widget_get_style(gtkButton)->fg[labelState];
- QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
- pal.setBrush(QPalette::ButtonText, textColor);
- proxy()->drawItemText(painter, ir, tf, pal, (button->state & State_Enabled),
- button->text, QPalette::ButtonText);
- }
- break;
-
- case CE_RadioButton: // Fall through
- case CE_CheckBox:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- bool isRadio = (element == CE_RadioButton);
-
- // Draw prelight background
- GtkWidget *gtkRadioButton = d->gtkWidget("GtkRadioButton");
-
- if (option->state & State_MouseOver) {
- gtkPainter->paintFlatBox(gtkRadioButton, "checkbutton", option->rect,
- GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, d->gtk_widget_get_style(gtkRadioButton));
- }
-
- QStyleOptionButton subopt = *btn;
- subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator
- : SE_CheckBoxIndicator, btn, widget);
- proxy()->drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox,
- &subopt, painter, widget);
- subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents
- : SE_CheckBoxContents, btn, widget);
- // Get label text color
- QPalette pal = subopt.palette;
- int labelState = GTK_STATE_INSENSITIVE;
- if (option->state & State_Enabled)
- labelState = (option->state & State_MouseOver) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
-
- GdkColor gdkText = d->gtk_widget_get_style(gtkRadioButton)->fg[labelState];
- QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
- pal.setBrush(QPalette::WindowText, textColor);
- subopt.palette = pal;
- proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, painter, widget);
-
- if (btn->state & State_HasFocus) {
- QStyleOptionFocusRect fropt;
- fropt.QStyleOption::operator=(*btn);
- fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect
- : SE_CheckBoxFocusRect, btn, widget);
- proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
- }
- }
- break;
-
-#ifndef QT_NO_COMBOBOX
-
- case CE_ComboBoxLabel:
- if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
- QRect editRect = proxy()->subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget);
- bool appearsAsList = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, cb, widget);
- painter->save();
- painter->setClipRect(editRect);
-
- if (!cb->currentIcon.isNull()) {
- QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal
- : QIcon::Disabled;
- QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode);
- QRect iconRect(editRect);
- iconRect.setWidth(cb->iconSize.width() + 4);
-
- iconRect = alignedRect(cb->direction,
- Qt::AlignLeft | Qt::AlignVCenter,
- iconRect.size(), editRect);
-
- if (cb->editable)
- painter->fillRect(iconRect, option->palette.brush(QPalette::Base));
-
- proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap);
-
- if (cb->direction == Qt::RightToLeft)
- editRect.translate(-4 - cb->iconSize.width(), 0);
- else
- editRect.translate(cb->iconSize.width() + 4, 0);
- }
-
- if (!cb->currentText.isEmpty() && !cb->editable) {
- GtkWidget *gtkCombo = d->gtkWidget("GtkComboBox");
- QPalette pal = cb->palette;
- int labelState = GTK_STATE_INSENSITIVE;
-
- if (option->state & State_Enabled)
- labelState = (option->state & State_MouseOver && !appearsAsList) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
-
- GdkColor gdkText = d->gtk_widget_get_style(gtkCombo)->fg[labelState];
-
- QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
-
- pal.setBrush(QPalette::ButtonText, textColor);
-
- proxy()->drawItemText(painter, editRect.adjusted(1, 0, -1, 0),
- visualAlignment(cb->direction, Qt::AlignLeft | Qt::AlignVCenter),
- pal, cb->state & State_Enabled, cb->currentText, QPalette::ButtonText);
- }
-
- painter->restore();
- }
- break;
-
-#endif // QT_NO_COMBOBOX
-
- case CE_DockWidgetTitle:
- painter->save();
- if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) {
- const QStyleOptionDockWidgetV2 *v2
- = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(dwOpt);
- bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
-
- QRect rect = dwOpt->rect;
- QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, option, widget).adjusted(-2, 0, -2, 0);
- QRect r = rect.adjusted(0, 0, -1, -1);
- if (verticalTitleBar)
- r.adjust(0, 0, 0, -1);
-
- if (verticalTitleBar) {
- QRect r = rect;
- r.setSize(r.size().transposed());
-
- titleRect = QRect(r.left() + rect.bottom()
- - titleRect.bottom(),
- r.top() + titleRect.left() - rect.left(),
- titleRect.height(), titleRect.width());
-
- painter->translate(r.left(), r.top() + r.width());
- painter->rotate(-90);
- painter->translate(-r.left(), -r.top());
-
- rect = r;
- }
-
- if (!dwOpt->title.isEmpty()) {
- QString titleText
- = painter->fontMetrics().elidedText(dwOpt->title,
- Qt::ElideRight, titleRect.width());
- proxy()->drawItemText(painter,
- titleRect,
- Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, dwOpt->palette,
- dwOpt->state & State_Enabled, titleText,
- QPalette::WindowText);
- }
- }
- painter->restore();
- break;
-
-
-
- case CE_HeaderSection:
- painter->save();
-
- // Draws the header in tables.
- if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
- Q_UNUSED(header);
- GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView");
- // Get the middle column
- GtkTreeViewColumn *column = d->gtk_tree_view_get_column((GtkTreeView*)gtkTreeView, 1);
- Q_ASSERT(column);
-
- GtkWidget *gtkTreeHeader = column->button;
- GtkStateType state = qt_gtk_state(option);
- GtkShadowType shadow = GTK_SHADOW_OUT;
-
- if (option->state & State_Sunken)
- shadow = GTK_SHADOW_IN;
-
- gtkPainter->paintBox(gtkTreeHeader, "button", option->rect.adjusted(-1, 0, 0, 0), state, shadow, d->gtk_widget_get_style(gtkTreeHeader));
- }
-
- painter->restore();
- break;
-
-#ifndef QT_NO_SIZEGRIP
-
- case CE_SizeGrip: {
- GtkWidget *gtkStatusbar = d->gtkWidget("GtkStatusbar.GtkFrame");
- GtkStyle *gtkStatusbarStyle = d->gtk_widget_get_style(gtkStatusbar);
- QRect gripRect = option->rect.adjusted(0, 0, -gtkStatusbarStyle->xthickness, -gtkStatusbarStyle->ythickness);
- gtkPainter->paintResizeGrip(gtkStatusbar, "statusbar", gripRect, GTK_STATE_NORMAL,
- GTK_SHADOW_OUT, option->direction == Qt::RightToLeft ?
- GDK_WINDOW_EDGE_SOUTH_WEST : GDK_WINDOW_EDGE_SOUTH_EAST,
- gtkStatusbarStyle);
- }
- break;
-
-#endif // QT_NO_SIZEGRIP
-
- case CE_MenuBarEmptyArea: {
- GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
- GdkColor gdkBg = d->gtk_widget_get_style(gtkMenubar)->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency
- painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8));
- if (widget) { // See CE_MenuBarItem
- QRect menuBarRect = widget->rect();
- QPixmap pixmap(menuBarRect.size());
- pixmap.fill(Qt::transparent);
- QPainter pmPainter(&pixmap);
- gtkPainter->reset(&pmPainter);
- GtkShadowType shadow_type;
- d->gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL);
- gtkPainter->paintBox(gtkMenubar, "menubar", menuBarRect,
- GTK_STATE_NORMAL, shadow_type, d->gtk_widget_get_style(gtkMenubar));
- pmPainter.end();
- painter->drawPixmap(option->rect, pixmap, option->rect);
- gtkPainter->reset(painter);
- }
- }
- break;
-
- case CE_MenuBarItem:
- painter->save();
-
- if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
- GtkWidget *gtkMenubarItem = d->gtkWidget("GtkMenuBar.GtkMenuItem");
- GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
-
- style = d->gtk_widget_get_style(gtkMenubarItem);
-
- if (widget) {
- // Since Qt does not currently allow filling the entire background
- // we use a hack for this by making a complete menubar each time and
- // paint with the correct offset inside it. Pixmap caching should resolve
- // most of the performance penalty.
- QRect menuBarRect = widget->rect();
- QPixmap pixmap(menuBarRect.size());
- pixmap.fill(Qt::transparent);
- QPainter pmPainter(&pixmap);
- gtkPainter->reset(&pmPainter);
- GtkShadowType shadow_type;
- d->gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL);
- GdkColor gdkBg = d->gtk_widget_get_style(gtkMenubar)->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency
- painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8));
- gtkPainter->paintBox(gtkMenubar, "menubar", menuBarRect,
- GTK_STATE_NORMAL, shadow_type, d->gtk_widget_get_style(gtkMenubar));
- pmPainter.end();
- painter->drawPixmap(option->rect, pixmap, option->rect);
- gtkPainter->reset(painter);
- }
-
- QStyleOptionMenuItem item = *mbi;
- bool act = mbi->state & State_Selected && mbi->state & State_Sunken;
- bool dis = !(mbi->state & State_Enabled);
- item.rect = mbi->rect;
- GdkColor gdkText = style->fg[dis ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL];
- GdkColor gdkHText = style->fg[GTK_STATE_PRELIGHT];
- QColor normalTextColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
- QColor highlightedTextColor = QColor(gdkHText.red>>8, gdkHText.green>>8, gdkHText.blue>>8);
- item.palette.setBrush(QPalette::HighlightedText, highlightedTextColor);
- item.palette.setBrush(QPalette::Text, normalTextColor);
- item.palette.setBrush(QPalette::ButtonText, normalTextColor);
- QCommonStyle::drawControl(element, &item, painter, widget);
-
- if (act) {
- GtkShadowType shadowType = GTK_SHADOW_NONE;
- d->gtk_widget_style_get (gtkMenubarItem, "selected-shadow-type", &shadowType, NULL);
- gtkPainter->paintBox(gtkMenubarItem, "menuitem", option->rect.adjusted(0, 0, 0, 3),
- GTK_STATE_PRELIGHT, shadowType, style);
- //draw text
- QPalette::ColorRole textRole = dis ? QPalette::Text : QPalette::HighlightedText;
- uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
-
- if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget))
- alignment |= Qt::TextHideMnemonic;
-
- proxy()->drawItemText(painter, item.rect, alignment, item.palette, mbi->state & State_Enabled, mbi->text, textRole);
- }
- }
- painter->restore();
- break;
-
- case CE_Splitter: {
- GtkWidget *gtkWindow = d->gtkWidget("GtkWindow"); // The Murrine Engine currently assumes a widget is passed
- gtkPainter->paintHandle(gtkWindow, "splitter", option->rect, qt_gtk_state(option), GTK_SHADOW_NONE,
- !(option->state & State_Horizontal) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL,
- style);
- }
- break;
-
-#ifndef QT_NO_TOOLBAR
-
- case CE_ToolBar:
- if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
- // Reserve the beveled appearance only for mainwindow toolbars
- if (!(widget && qobject_cast<const QMainWindow*> (widget->parentWidget())))
- break;
-
- QRect rect = option->rect;
- // There is a 1 pixel gap between toolbar lines in some styles (i.e Human)
- if (toolbar->positionWithinLine != QStyleOptionToolBar::End)
- rect.adjust(0, 0, 1, 0);
-
- GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar");
- GtkShadowType shadow_type = GTK_SHADOW_NONE;
- d->gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL);
- gtkPainter->paintBox(gtkToolbar, "toolbar", rect,
- GTK_STATE_NORMAL, shadow_type, d->gtk_widget_get_style(gtkToolbar));
- }
- break;
-
-#endif // QT_NO_TOOLBAR
-
- case CE_MenuItem:
- painter->save();
-
- // Draws one item in a popup menu.
- if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
- const int windowsItemHMargin = 3; // menu item hor text margin
- const int windowsItemVMargin = 26; // menu item ver text margin
- GtkWidget *gtkMenuItem = menuItem->checked ? d->gtkWidget("GtkMenu.GtkCheckMenuItem") :
- d->gtkWidget("GtkMenu.GtkMenuItem");
-
- style = d->gtk_widget_get_style(gtkMenuItem);
- QColor shadow = option->palette.dark().color();
-
- if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
- GtkWidget *gtkMenuSeparator = d->gtkWidget("GtkMenu.GtkSeparatorMenuItem");
- painter->setPen(shadow.lighter(106));
- gboolean wide_separators = 0;
- gint separator_height = 0;
- guint horizontal_padding = 3;
- QRect separatorRect = option->rect;
- if (!d->gtk_check_version(2, 10, 0)) {
- d->gtk_widget_style_get(gtkMenuSeparator,
- "wide-separators", &wide_separators,
- "separator-height", &separator_height,
- "horizontal-padding", &horizontal_padding,
- NULL);
- }
- GtkStyle *gtkMenuSeparatorStyle = d->gtk_widget_get_style(gtkMenuSeparator);
- separatorRect.setHeight(option->rect.height() - 2 * gtkMenuSeparatorStyle->ythickness);
- separatorRect.setWidth(option->rect.width() - 2 * (horizontal_padding + gtkMenuSeparatorStyle->xthickness));
- separatorRect.moveCenter(option->rect.center());
- if (wide_separators)
- gtkPainter->paintBox(gtkMenuSeparator, "hseparator",
- separatorRect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, gtkMenuSeparatorStyle);
- else
- gtkPainter->paintHline(gtkMenuSeparator, "hseparator",
- separatorRect, GTK_STATE_NORMAL, gtkMenuSeparatorStyle,
- 0, option->rect.right() - 1, 1);
- painter->restore();
- break;
- }
-
- bool selected = menuItem->state & State_Selected && menuItem->state & State_Enabled;
-
- if (selected) {
- QRect rect = option->rect;
-#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);
- }
-
- bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable;
- bool checked = menuItem->checked;
- bool enabled = menuItem->state & State_Enabled;
- bool ignoreCheckMark = false;
-
- gint checkSize;
- d->gtk_widget_style_get(d->gtkWidget("GtkMenu.GtkCheckMenuItem"), "indicator-size", &checkSize, NULL);
-
- int checkcol = qMax(menuItem->maxIconWidth, qMax(20, checkSize));
-
-#ifndef QT_NO_COMBOBOX
-
- if (qobject_cast<const QComboBox*>(widget) ||
- (option->styleObject && option->styleObject->property("_q_isComboBoxPopupItem").toBool()))
- ignoreCheckMark = true; // Ignore the checkmarks provided by the QComboMenuDelegate
-
-#endif
- if (!ignoreCheckMark) {
- // Check
- QRect checkRect(option->rect.left() + 7, option->rect.center().y() - checkSize/2 + 1, checkSize, checkSize);
- checkRect = visualRect(menuItem->direction, menuItem->rect, checkRect);
-
- if (checkable && menuItem->icon.isNull()) {
- // Some themes such as aero-clone draw slightly outside the paint rect
- int spacing = 1; // ### Consider using gtkCheckBox : "indicator-spacing" instead
-
- if (menuItem->checkType & QStyleOptionMenuItem::Exclusive) {
- // Radio button
- GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = qt_gtk_state(option);
-
- if (selected)
- state = GTK_STATE_PRELIGHT;
- if (checked)
- shadow = GTK_SHADOW_IN;
-
- gtkPainter->setClipRect(checkRect.adjusted(-spacing, -spacing, spacing, spacing));
- gtkPainter->paintOption(gtkMenuItem, checkRect.translated(-spacing, -spacing), state, shadow,
- style, QLS("option"));
- gtkPainter->setClipRect(QRect());
-
- } else {
- // Check box
- if (menuItem->icon.isNull()) {
- GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = qt_gtk_state(option);
-
- if (selected)
- state = GTK_STATE_PRELIGHT;
- if (checked)
- shadow = GTK_SHADOW_IN;
-
- gtkPainter->setClipRect(checkRect.adjusted(-spacing, -spacing, -spacing, -spacing));
- gtkPainter->paintCheckbox(gtkMenuItem, checkRect.translated(-spacing, -spacing), state, shadow,
- style, QLS("check"));
- gtkPainter->setClipRect(QRect());
- }
- }
- }
-
- } else {
- // Ignore checkmark
- if (menuItem->icon.isNull())
- checkcol = 0;
- else
- checkcol = menuItem->maxIconWidth;
- }
-
- bool dis = !(menuItem->state & State_Enabled);
- bool act = menuItem->state & State_Selected;
- const QStyleOption *opt = option;
- const QStyleOptionMenuItem *menuitem = menuItem;
- QPainter *p = painter;
- QRect vCheckRect = visualRect(opt->direction, menuitem->rect,
- QRect(menuitem->rect.x() + 3, menuitem->rect.y(),
- checkcol, menuitem->rect.height()));
-
- if (!menuItem->icon.isNull()) {
- QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
-
- if (act && !dis)
- mode = QIcon::Active;
-
- QPixmap pixmap;
- int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize, option, widget);
- QSize iconSize(smallIconSize, smallIconSize);
-
-#ifndef QT_NO_COMBOBOX
- if (const QComboBox *combo = qobject_cast<const QComboBox*>(widget))
- iconSize = combo->iconSize();
-
-#endif // QT_NO_COMBOBOX
- if (checked)
- pixmap = menuItem->icon.pixmap(iconSize, mode, QIcon::On);
- else
- pixmap = menuItem->icon.pixmap(iconSize, mode);
-
- const int pixw = pixmap.width() / pixmap.devicePixelRatio();
- const int pixh = pixmap.height() / pixmap.devicePixelRatio();
- QRect pmr(0, 0, pixw, pixh);
- pmr.moveCenter(vCheckRect.center() - QPoint(0, 1));
- painter->setPen(menuItem->palette.text().color());
- if (!ignoreCheckMark && checkable && checked) {
- QStyleOption opt = *option;
-
- if (act) {
- QColor activeColor = mergedColors(option->palette.background().color(),
- option->palette.highlight().color());
- opt.palette.setBrush(QPalette::Button, activeColor);
- }
- opt.state |= State_Sunken;
- opt.rect = vCheckRect;
- proxy()->drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget);
- }
- painter->drawPixmap(pmr.topLeft(), pixmap);
- }
-
- GdkColor gdkText = style->fg[GTK_STATE_NORMAL];
- GdkColor gdkDText = style->fg[GTK_STATE_INSENSITIVE];
- GdkColor gdkHText = 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);
- else
- painter->setPen(textColor);
-
- int x, y, w, h;
- menuitem->rect.getRect(&x, &y, &w, &h);
- int tab = menuitem->tabWidth;
- int xm = QGtkStylePrivate::menuItemFrame + checkcol + windowsItemHMargin;
- int xpos = menuitem->rect.x() + xm + 1;
- QRect textRect(xpos, y + windowsItemVMargin, w - xm - QGtkStylePrivate::menuRightBorder - tab + 1, h - 2 * windowsItemVMargin);
- QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
- QString s = menuitem->text;
-
- if (!s.isEmpty()) { // Draw text
- p->save();
- int t = s.indexOf(QLatin1Char('\t'));
- int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
-
- if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
- text_flags |= Qt::TextHideMnemonic;
-
- // Draw shortcut right aligned
- text_flags |= Qt::AlignRight;
-
- if (t >= 0) {
- int rightMargin = 12; // Hardcode for now
- QRect vShortcutRect = visualRect(opt->direction, menuitem->rect,
- QRect(textRect.topRight(), QPoint(menuitem->rect.right() - rightMargin, textRect.bottom())));
-
- if (dis)
- p->setPen(disabledTextColor);
- p->drawText(vShortcutRect, text_flags , s.mid(t + 1));
- s = s.left(t);
- }
-
- text_flags &= ~Qt::AlignRight;
- text_flags |= Qt::AlignLeft;
- QFont font = menuitem->font;
- if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
- font.setBold(true);
- p->setFont(font);
-
- if (dis)
- p->setPen(disabledTextColor);
- p->drawText(vTextRect, text_flags, s.left(t));
- p->restore();
- }
-
- // Arrow
- if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
-
- QFontMetrics fm(menuitem->font);
- int arrow_size = fm.ascent() + fm.descent() - 2 * style->ythickness;
- gfloat arrow_scaling = 0.8;
- int extra = 0;
- if (!d->gtk_check_version(2, 16, 0)) {
- // "arrow-scaling" is actually hardcoded and fails on hardy (see gtk+-2.12/gtkmenuitem.c)
- // though the current documentation states otherwise
- d->gtk_widget_style_get(gtkMenuItem, "arrow-scaling", &arrow_scaling, NULL);
- // in versions < 2.16 ythickness was previously subtracted from the arrow_size
- extra = 2 * style->ythickness;
- }
-
- int horizontal_padding;
- d->gtk_widget_style_get(gtkMenuItem, "horizontal-padding", &horizontal_padding, NULL);
-
- const int dim = static_cast<int>(arrow_size * arrow_scaling) + extra;
- int xpos = menuItem->rect.left() + menuItem->rect.width() - horizontal_padding - dim;
- QRect vSubMenuRect = visualRect(option->direction, menuItem->rect,
- QRect(xpos, menuItem->rect.top() +
- menuItem->rect.height() / 2 - dim / 2, dim, dim));
- GtkStateType state = enabled ? (act ? GTK_STATE_PRELIGHT: GTK_STATE_NORMAL) : GTK_STATE_INSENSITIVE;
- GtkShadowType shadowType = (state == GTK_STATE_PRELIGHT) ? GTK_SHADOW_OUT : GTK_SHADOW_IN;
- gtkPainter->paintArrow(gtkMenuItem, "menuitem", vSubMenuRect, option->direction == Qt::RightToLeft ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT, state,
- shadowType, false, style);
- }
- }
- painter->restore();
- break;
-
- case CE_PushButton:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- GtkWidget *gtkButton = d->gtkWidget("GtkButton");
- proxy()->drawControl(CE_PushButtonBevel, btn, painter, widget);
- QStyleOptionButton subopt = *btn;
- subopt.rect = subElementRect(SE_PushButtonContents, btn, widget);
- gint interiorFocus = true;
- d->gtk_widget_style_get(gtkButton, "interior-focus", &interiorFocus, NULL);
- GtkStyle *gtkButtonStyle = d->gtk_widget_get_style(gtkButton);
- int xt = interiorFocus ? gtkButtonStyle->xthickness : 0;
- int yt = interiorFocus ? gtkButtonStyle->ythickness : 0;
-
- if (btn->features & QStyleOptionButton::Flat && btn->state & State_HasFocus)
- // The normal button focus rect does not work well for flat buttons in Clearlooks
- proxy()->drawPrimitive(PE_FrameFocusRect, option, painter, widget);
- else if (btn->state & State_HasFocus)
- gtkPainter->paintFocus(gtkButton, "button",
- option->rect.adjusted(xt, yt, -xt, -yt),
- btn->state & State_Sunken ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL,
- gtkButtonStyle);
-
- proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
- }
- break;
-
-#ifndef QT_NO_TABBAR
-
- case CE_TabBarTabShape:
- if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
- GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook");
- style = d->gtk_widget_get_style(gtkNotebook);
-
- QRect rect = option->rect;
- GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = GTK_STATE_ACTIVE;
- if (tab->state & State_Selected)
- state = GTK_STATE_NORMAL;
-
- bool selected = (tab->state & State_Selected);
- 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;
- }
- int topIndent = 3;
- int bottomIndent = 1;
- int tabOverlap = 1;
- painter->save();
-
- switch (tab->shape) {
- case QTabBar::RoundedNorth:
- if (!selected)
- rect.adjust(first ? 0 : -tabOverlap, topIndent, last ? 0 : tabOverlap, -bottomIndent);
- gtkPainter->paintExtention(gtkNotebook, "tab", rect,
- state, shadow, GTK_POS_BOTTOM, style);
- break;
-
- case QTabBar::RoundedSouth:
- if (!selected)
- rect.adjust(first ? 0 : -tabOverlap, 0, last ? 0 : tabOverlap, -topIndent);
- gtkPainter->paintExtention(gtkNotebook, "tab", rect.adjusted(0, 1, 0, 0),
- state, shadow, GTK_POS_TOP, style);
- break;
-
- case QTabBar::RoundedWest:
- if (!selected)
- rect.adjust(topIndent, 0, -bottomIndent, 0);
- gtkPainter->paintExtention(gtkNotebook, "tab", rect, state, shadow, GTK_POS_RIGHT, style);
- break;
-
- case QTabBar::RoundedEast:
- if (!selected)
- rect.adjust(bottomIndent, 0, -topIndent, 0);
- gtkPainter->paintExtention(gtkNotebook, "tab", rect, state, shadow, GTK_POS_LEFT, style);
- break;
-
- default:
- QCommonStyle::drawControl(element, option, painter, widget);
- break;
- }
-
- painter->restore();
- }
-
- break;
-
-#endif //QT_NO_TABBAR
-
- case CE_ProgressBarGroove:
- if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
- Q_UNUSED(bar);
- GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar");
- GtkStateType state = qt_gtk_state(option);
- gtkPainter->paintBox(gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, d->gtk_widget_get_style(gtkProgressBar));
- }
-
- break;
-
- case CE_ProgressBarContents:
- if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
- GtkStateType state = option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE;
- GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar");
- style = d->gtk_widget_get_style(gtkProgressBar);
- gtkPainter->paintBox(gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, style);
- int xt = style->xthickness;
- int yt = style->ythickness;
- QRect rect = bar->rect.adjusted(xt, yt, -xt, -yt);
- bool vertical = false;
- bool inverted = false;
- bool indeterminate = (bar->minimum == 0 && bar->maximum == 0);
- // Get extra style options if version 2
-
- if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
- vertical = (bar2->orientation == Qt::Vertical);
- inverted = bar2->invertedAppearance;
- }
-
- // If the orientation is vertical, we use a transform to rotate
- // the progress bar 90 degrees clockwise. This way we can use the
- // same rendering code for both orientations.
- if (vertical) {
- rect.translate(xt, -yt * 2);
- rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // Flip width and height
- QTransform m = QTransform::fromTranslate(rect.height(), 0);
- m.rotate(90.0);
- painter->setTransform(m);
- }
-
- int maxWidth = rect.width();
- int minWidth = 4;
-
- qint64 progress = (qint64)qMax(bar->progress, bar->minimum); // Workaround for bug in QProgressBar
- double vc6_workaround = ((progress - qint64(bar->minimum)) / double(qint64(bar->maximum) - qint64(bar->minimum))) * maxWidth;
- int progressBarWidth = (int(vc6_workaround) > minWidth ) ? int(vc6_workaround) : minWidth;
- int width = indeterminate ? maxWidth : progressBarWidth;
- bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical;
-
- if (inverted)
- reverse = !reverse;
-
- int maximum = 2;
- int fakePos = 0;
- if (bar->minimum == bar->maximum)
- maximum = 0;
- if (bar->progress == bar->maximum)
- fakePos = maximum;
- else if (bar->progress > bar->minimum)
- fakePos = maximum - 1;
-
- QRect progressBar;
-
- if (!indeterminate) {
- if (!reverse)
- progressBar.setRect(rect.left(), rect.top(), width, rect.height());
- else
- progressBar.setRect(rect.right() - width, rect.top(), width, rect.height());
-#ifndef QT_NO_ANIMATION
- d->stopAnimation(option->styleObject);
-#endif
- } else {
- Q_D(const QGtkStyle);
- int slideWidth = ((rect.width() - 4) * 2) / 3;
- int step = 0;
-#ifndef QT_NO_ANIMATION
- if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(option->styleObject)))
- step = animation->progressStep(slideWidth);
- else
- d->startAnimation(new QProgressStyleAnimation(d->animationFps, option->styleObject));
-#endif
- progressBar.setRect(rect.left() + step, rect.top(), slideWidth / 2, rect.height());
- }
-
- QString key = QString(QLS("%0")).arg(fakePos);
- if (inverted) {
- key += QLatin1String("inv");
- gtkPainter->setFlipHorizontal(true);
- }
- gtkPainter->paintBox(gtkProgressBar, "bar", progressBar, GTK_STATE_SELECTED, GTK_SHADOW_OUT, style, key);
- }
-
- break;
-
- default:
- QCommonStyle::drawControl(element, option, painter, widget);
- }
-}
-
-/*!
- \reimp
-*/
-QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option,
- SubControl subControl, const QWidget *widget) const
-{
- Q_D(const QGtkStyle);
-
- QRect rect = QCommonStyle::subControlRect(control, option, subControl, widget);
- if (!d->isThemeAvailable())
- return QCommonStyle::subControlRect(control, option, subControl, widget);
-
- switch (control) {
- case CC_ScrollBar:
- break;
- case CC_Slider:
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
- int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
- switch (subControl) {
- case SC_SliderHandle: {
- if (slider->orientation == Qt::Horizontal) {
- rect.setHeight(proxy()->pixelMetric(PM_SliderThickness));
- rect.setWidth(proxy()->pixelMetric(PM_SliderLength));
- int centerY = slider->rect.center().y() - rect.height() / 2;
- if (slider->tickPosition & QSlider::TicksAbove)
- centerY += tickSize;
- if (slider->tickPosition & QSlider::TicksBelow)
- centerY -= tickSize;
- rect.moveTop(centerY);
- } else {
- rect.setWidth(proxy()->pixelMetric(PM_SliderThickness));
- rect.setHeight(proxy()->pixelMetric(PM_SliderLength));
- int centerX = slider->rect.center().x() - rect.width() / 2;
- if (slider->tickPosition & QSlider::TicksAbove)
- centerX += tickSize;
- if (slider->tickPosition & QSlider::TicksBelow)
- centerX -= tickSize;
- rect.moveLeft(centerX);
- }
- }
- break;
- case SC_SliderGroove: {
- QPoint grooveCenter = slider->rect.center();
- if (slider->orientation == Qt::Horizontal) {
- rect.setHeight(7);
- if (slider->tickPosition & QSlider::TicksAbove)
- grooveCenter.ry() += tickSize;
- if (slider->tickPosition & QSlider::TicksBelow)
- grooveCenter.ry() -= tickSize;
- } else {
- rect.setWidth(7);
- if (slider->tickPosition & QSlider::TicksAbove)
- grooveCenter.rx() += tickSize;
- if (slider->tickPosition & QSlider::TicksBelow)
- grooveCenter.rx() -= tickSize;
- }
- rect.moveCenter(grooveCenter);
- break;
- }
- default:
- break;
- }
- }
- break;
-
-#ifndef QT_NO_GROUPBOX
-
- case CC_GroupBox:
- if (const QStyleOptionGroupBox * groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
- rect = option->rect.adjusted(0, groupBoxTopMargin, 0, -groupBoxBottomMargin);
- int topMargin = 0;
- int topHeight = 0;
- topHeight = 10;
- QRect frameRect = rect;
- frameRect.setTop(topMargin);
-
- if (subControl == SC_GroupBoxFrame)
- return rect;
- else if (subControl == SC_GroupBoxContents) {
- int margin = 0;
- int leftMarginExtension = 8;
- return frameRect.adjusted(leftMarginExtension + margin, margin + topHeight + groupBoxTitleMargin, -margin, -margin);
- }
-
- QFontMetrics fontMetrics = option->fontMetrics;
- if (qobject_cast<const QGroupBox *>(widget)) {
- //Prepare metrics for a bold font
- QFont font = widget->font();
- font.setBold(true);
- fontMetrics = QFontMetrics(font);
-#ifndef QT_NO_ACCESSIBILITY
- } else if (QStyleHelper::isInstanceOf(groupBox->styleObject, QAccessible::Grouping)) {
- QVariant var = groupBox->styleObject->property("font");
- if (var.isValid() && var.canConvert<QFont>()) {
- QFont font = var.value<QFont>();
- font.setBold(true);
- fontMetrics = QFontMetrics(font);
- }
-#endif // QT_NO_ACCESSIBILITY
- }
-
- QSize textRect = fontMetrics.boundingRect(groupBox->text).size() + QSize(4, 4);
- int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget);
- int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, option, widget);
-
- if (subControl == SC_GroupBoxCheckBox) {
- rect.setWidth(indicatorWidth);
- rect.setHeight(indicatorHeight);
- rect.moveTop((textRect.height() - indicatorHeight) / 2);
-
- } else if (subControl == SC_GroupBoxLabel) {
- if (groupBox->subControls & SC_GroupBoxCheckBox)
- rect.adjust(indicatorWidth + 4, 0, 0, 0);
- rect.setSize(textRect);
- }
- rect = visualRect(option->direction, option->rect, rect);
- }
-
- return rect;
-
-#endif
-#ifndef QT_NO_SPINBOX
-
- case CC_SpinBox:
- if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
- GtkWidget *gtkSpinButton = d->gtkWidget("GtkSpinButton");
- int center = spinbox->rect.height() / 2;
- GtkStyle *gtkSpinButtonStyle = d->gtk_widget_get_style(gtkSpinButton);
- int xt = spinbox->frame ? gtkSpinButtonStyle->xthickness : 0;
- int yt = spinbox->frame ? gtkSpinButtonStyle->ythickness : 0;
- int y = yt;
-
- QSize bs;
- bs.setHeight(qMax(8, spinbox->rect.height()/2 - y));
- bs.setWidth(d->getSpinboxArrowSize());
- int x, lx, rx;
- x = spinbox->rect.width() - y - bs.width() + 2;
- lx = xt;
- rx = x - xt;
-
- switch (subControl) {
-
- case SC_SpinBoxUp:
- if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
- return QRect();
- rect = QRect(x, xt, bs.width(), center - yt);
- break;
-
- case SC_SpinBoxDown:
- if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
- return QRect();
- rect = QRect(x, center, bs.width(), spinbox->rect.bottom() - center - yt + 1);
- break;
-
- case SC_SpinBoxEditField:
- if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
- rect = QRect(lx, yt, spinbox->rect.width() - 2*xt, spinbox->rect.height() - 2*yt);
- else
- rect = QRect(lx, yt, rx - qMax(xt - 1, 0), spinbox->rect.height() - 2*yt);
- break;
-
- case SC_SpinBoxFrame:
- rect = spinbox->rect;
-
- default:
- break;
- }
-
- rect = visualRect(spinbox->direction, spinbox->rect, rect);
- }
-
- break;
-
-#endif // Qt_NO_SPINBOX
-#ifndef QT_NO_COMBOBOX
-
- case CC_TitleBar:
- if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) {
- SubControl sc = subControl;
- QRect &ret = rect;
- const int indent = 3;
- const int controlTopMargin = 3;
- const int controlBottomMargin = 3;
- const int controlWidthMargin = 2;
- const int controlHeight = tb->rect.height() - controlTopMargin - controlBottomMargin ;
- const int delta = controlHeight + controlWidthMargin;
- int offset = 0;
-
- bool isMinimized = tb->titleBarState & Qt::WindowMinimized;
- bool isMaximized = tb->titleBarState & Qt::WindowMaximized;
-
- switch (sc) {
- case SC_TitleBarLabel:
- if (tb->titleBarFlags & (Qt::WindowTitleHint | Qt::WindowSystemMenuHint)) {
- ret = tb->rect;
- if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
- ret.adjust(delta, 0, -delta, 0);
- if (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)
- ret.adjust(0, 0, -delta, 0);
- if (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)
- ret.adjust(0, 0, -delta, 0);
- if (tb->titleBarFlags & Qt::WindowShadeButtonHint)
- ret.adjust(0, 0, -delta, 0);
- if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint)
- ret.adjust(0, 0, -delta, 0);
- }
- break;
- case SC_TitleBarContextHelpButton:
- if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint)
- offset += delta;
- case SC_TitleBarMinButton:
- if (!isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
- offset += delta;
- else if (sc == SC_TitleBarMinButton)
- break;
- case SC_TitleBarNormalButton:
- if (isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
- offset += delta;
- else if (isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
- offset += delta;
- else if (sc == SC_TitleBarNormalButton)
- break;
- case SC_TitleBarMaxButton:
- if (!isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
- offset += delta;
- else if (sc == SC_TitleBarMaxButton)
- break;
- case SC_TitleBarShadeButton:
- if (!isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
- offset += delta;
- else if (sc == SC_TitleBarShadeButton)
- break;
- case SC_TitleBarUnshadeButton:
- if (isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint))
- offset += delta;
- else if (sc == SC_TitleBarUnshadeButton)
- break;
- case SC_TitleBarCloseButton:
- if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
- offset += delta;
- else if (sc == SC_TitleBarCloseButton)
- break;
- ret.setRect(tb->rect.right() - indent - offset, tb->rect.top() + controlTopMargin,
- controlHeight, controlHeight);
- break;
- case SC_TitleBarSysMenu:
- if (tb->titleBarFlags & Qt::WindowSystemMenuHint) {
- ret.setRect(tb->rect.left() + controlWidthMargin + indent, tb->rect.top() + controlTopMargin,
- controlHeight, controlHeight);
- }
- break;
- default:
- break;
- }
- ret = visualRect(tb->direction, tb->rect, ret);
- }
- break;
- case CC_ComboBox:
- if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
- // We employ the gtk widget to position arrows and separators for us
- GtkWidget *gtkCombo = box->editable ? d->gtkWidget("GtkComboBoxEntry")
- : d->gtkWidget("GtkComboBox");
- d->gtk_widget_set_direction(gtkCombo, (option->direction == Qt::RightToLeft) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
- GtkAllocation geometry = {0, 0, qMax(0, option->rect.width()), qMax(0, option->rect.height())};
- d->gtk_widget_size_allocate(gtkCombo, &geometry);
- int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, option, widget);
- QHashableLatin1Literal arrowPath("GtkComboBoxEntry.GtkToggleButton");
- if (!box->editable) {
- if (appears_as_list)
- arrowPath = "GtkComboBox.GtkToggleButton";
- else
- arrowPath = "GtkComboBox.GtkToggleButton.GtkHBox.GtkArrow";
- }
-
- GtkWidget *arrowWidget = d->gtkWidget(arrowPath);
- if (!arrowWidget)
- return QCommonStyle::subControlRect(control, option, subControl, widget);
-
- GtkAllocation allocation;
- d->gtk_widget_get_allocation(arrowWidget, &allocation);
- QRect buttonRect(option->rect.left() + allocation.x,
- option->rect.top() + allocation.y,
- allocation.width, allocation.height);
-
- switch (subControl) {
-
- case SC_ComboBoxArrow: // Note: this indicates the arrowbutton for editable combos
- rect = buttonRect;
- break;
-
- case SC_ComboBoxEditField: {
- rect = visualRect(option->direction, option->rect, rect);
- int xMargin = box->editable ? 1 : 4, yMargin = 2;
- GtkStyle *gtkComboStyle = d->gtk_widget_get_style(gtkCombo);
- rect.setRect(option->rect.left() + gtkComboStyle->xthickness + xMargin,
- option->rect.top() + gtkComboStyle->ythickness + yMargin,
- option->rect.width() - buttonRect.width() - 2*(gtkComboStyle->xthickness + xMargin),
- option->rect.height() - 2*(gtkComboStyle->ythickness + yMargin));
- rect = visualRect(option->direction, option->rect, rect);
- break;
- }
-
- default:
- break;
- }
- }
-
- break;
-#endif // QT_NO_COMBOBOX
-
- default:
- break;
- }
-
- return rect;
-}
-
-/*!
- \reimp
-*/
-QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
- const QSize &size, const QWidget *widget) const
-{
- Q_D(const QGtkStyle);
-
- QSize newSize = QCommonStyle::sizeFromContents(type, option, size, widget);
- if (!d->isThemeAvailable())
- return newSize;
-
- switch (type) {
- case CT_GroupBox:
- // Since we use a bold font we have to recalculate base width
- if (const QGroupBox *gb = qobject_cast<const QGroupBox*>(widget)) {
- QFont font = gb->font();
- font.setBold(true);
- QFontMetrics metrics(font);
- int baseWidth = metrics.width(gb->title()) + metrics.width(QLatin1Char(' '));
- if (gb->isCheckable()) {
- baseWidth += proxy()->pixelMetric(QStyle::PM_IndicatorWidth, option, widget);
- baseWidth += proxy()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing, option, widget);
- }
- newSize.setWidth(qMax(baseWidth, newSize.width()));
- }
- newSize += QSize(4, 1 + groupBoxBottomMargin + groupBoxTopMargin + groupBoxTitleMargin); // Add some space below the groupbox
- break;
- case CT_ToolButton:
- if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
- GtkWidget *gtkButton = d->gtkWidget("GtkToolButton.GtkButton");
- GtkStyle *gtkButtonStyle = d->gtk_widget_get_style(gtkButton);
- newSize = size + QSize(2 * gtkButtonStyle->xthickness, 2 + 2 * gtkButtonStyle->ythickness);
- if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) {
- QSize minSize(0, 25);
- if (toolbutton->toolButtonStyle != Qt::ToolButtonTextOnly)
- minSize = toolbutton->iconSize + QSize(12, 12);
- newSize = newSize.expandedTo(minSize);
- }
-
- if (toolbutton->features & QStyleOptionToolButton::HasMenu)
- newSize += QSize(6, 0);
- }
- break;
- case CT_SpinBox:
- // QSpinBox does some nasty things that depends on CT_LineEdit
- newSize = newSize + QSize(0, -d->gtk_widget_get_style(d->gtkWidget("GtkSpinButton"))->ythickness * 2);
- break;
- case CT_RadioButton:
- case CT_CheckBox:
- newSize += QSize(0, 1);
- break;
- case CT_PushButton:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- if (!btn->icon.isNull() && btn->iconSize.height() > 16)
- newSize -= QSize(0, 2); // From cleanlooksstyle
- newSize += QSize(0, 1);
- GtkWidget *gtkButton = d->gtkWidget("GtkButton");
- gint focusPadding, focusWidth;
- d->gtk_widget_style_get(gtkButton, "focus-padding", &focusPadding, NULL);
- d->gtk_widget_style_get(gtkButton, "focus-line-width", &focusWidth, NULL);
- newSize = size;
- GtkStyle *gtkButtonStyle = d->gtk_widget_get_style(gtkButton);
- newSize += QSize(2*gtkButtonStyle->xthickness + 4, 2*gtkButtonStyle->ythickness);
- newSize += QSize(2*(focusWidth + focusPadding + 2), 2*(focusWidth + focusPadding));
-
- GtkWidget *gtkButtonBox = d->gtkWidget("GtkHButtonBox");
- gint minWidth = 85, minHeight = 0;
- d->gtk_widget_style_get(gtkButtonBox, "child-min-width", &minWidth,
- "child-min-height", &minHeight, NULL);
- if (!btn->text.isEmpty() && newSize.width() < minWidth)
- newSize.setWidth(minWidth);
- if (newSize.height() < minHeight)
- newSize.setHeight(minHeight);
- }
- break;
- case CT_Slider: {
- GtkWidget *gtkSlider = d->gtkWidget("GtkHScale");
- GtkStyle *gtkSliderStyle = d->gtk_widget_get_style(gtkSlider);
- newSize = size + QSize(2*gtkSliderStyle->xthickness, 2*gtkSliderStyle->ythickness); }
- break;
- case CT_LineEdit: {
- GtkWidget *gtkEntry = d->gtkWidget("GtkEntry");
- GtkStyle *gtkEntryStyle = d->gtk_widget_get_style(gtkEntry);
- newSize = size + QSize(2*gtkEntryStyle->xthickness, 2 + 2*gtkEntryStyle->ythickness); }
- break;
- case CT_ItemViewItem:
- newSize += QSize(0, 2);
- break;
- case CT_ComboBox:
- if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
- GtkWidget *gtkCombo = d->gtkWidget("GtkComboBox");
- QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, combo, SC_ComboBoxArrow, widget);
- GtkStyle *gtkComboStyle = d->gtk_widget_get_style(gtkCombo);
- newSize = size + QSize(12 + arrowButtonRect.width() + 2*gtkComboStyle->xthickness, 4 + 2*gtkComboStyle->ythickness);
-
- if (!(widget && qobject_cast<QToolBar *>(widget->parentWidget())))
- newSize += QSize(0, 2);
- }
- break;
- case CT_TabBarTab:
- if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
- if (!tab->icon.isNull())
- newSize += QSize(6, 0);
- }
- newSize += QSize(1, 1);
- break;
- case CT_MenuBarItem:
- newSize += QSize(QGtkStylePrivate::menuItemHMargin * 4, QGtkStylePrivate::menuItemVMargin * 2 + 2);
- break;
- case CT_SizeGrip:
- newSize += QSize(4, 4);
- break;
- case CT_MdiControls:
- if (const QStyleOptionComplex *styleOpt = qstyleoption_cast<const QStyleOptionComplex *>(option)) {
- int width = 0;
- if (styleOpt->subControls & SC_MdiMinButton)
- width += 19 + 1;
- if (styleOpt->subControls & SC_MdiNormalButton)
- width += 19 + 1;
- if (styleOpt->subControls & SC_MdiCloseButton)
- width += 19 + 1;
- newSize = QSize(width, 19);
- } else {
- newSize = QSize(60, 19);
- }
- break;
- case CT_MenuItem:
- if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
- int w = newSize.width();
- int maxpmw = menuItem->maxIconWidth;
- int tabSpacing = 20;
- if (menuItem->text.contains(QLatin1Char('\t')))
- w += tabSpacing;
- else if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu)
- w += 2 * QGtkStylePrivate::menuArrowHMargin;
- else if (menuItem->menuItemType == QStyleOptionMenuItem::DefaultItem) {
- // adjust the font and add the difference in size.
- // it would be better if the font could be adjusted in the initStyleOption qmenu func!!
- QFontMetrics fm(menuItem->font);
- QFont fontBold = menuItem->font;
- fontBold.setBold(true);
- QFontMetrics fmBold(fontBold);
- w += fmBold.width(menuItem->text) - fm.width(menuItem->text);
- }
-
- int checkcol = qMax<int>(maxpmw, QGtkStylePrivate::menuCheckMarkWidth); // Windows always shows a check column
- w += checkcol;
- w += int(QGtkStylePrivate::menuRightBorder) + 10;
-
- newSize.setWidth(w);
-
- int textMargin = 8;
- if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
- GtkWidget *gtkMenuSeparator = d->gtkWidget("GtkMenu.GtkSeparatorMenuItem");
- GtkRequisition sizeReq = {0, 0};
- d->gtk_widget_size_request(gtkMenuSeparator, &sizeReq);
- newSize = QSize(newSize.width(), sizeReq.height);
- break;
- }
-
- GtkWidget *gtkMenuItem = d->gtkWidget("GtkMenu.GtkCheckMenuItem");
- GtkStyle* style = d->gtk_widget_get_style(gtkMenuItem);
-
- // Note we get the perfect height for the default font since we
- // set a fake text label on the gtkMenuItem
- // But if custom fonts are used on the widget we need a minimum size
- GtkRequisition sizeReq = {0, 0};
- d->gtk_widget_size_request(gtkMenuItem, &sizeReq);
- newSize.setHeight(qMax(newSize.height() - 4, sizeReq.height));
- newSize += QSize(textMargin + style->xthickness - 1, 0);
-
- gint checkSize;
- d->gtk_widget_style_get(gtkMenuItem, "indicator-size", &checkSize, NULL);
- newSize.setWidth(newSize.width() + qMax(0, checkSize - 20));
- }
- break;
- default:
- break;
- }
-
- return newSize;
-}
-
-
-/*! \reimp */
-QPixmap QGtkStyle::standardPixmap(StandardPixmap sp, const QStyleOption *option,
- const QWidget *widget) const
-{
- Q_D(const QGtkStyle);
-
- if (!d->isThemeAvailable())
- return QCommonStyle::standardPixmap(sp, option, widget);
-
- QPixmap pixmap;
- switch (sp) {
-
- case SP_TitleBarNormalButton: {
- QImage restoreButton(dock_widget_restore_xpm);
- QColor alphaCorner = restoreButton.color(2);
- alphaCorner.setAlpha(80);
- restoreButton.setColor(2, alphaCorner.rgba());
- alphaCorner.setAlpha(180);
- restoreButton.setColor(4, alphaCorner.rgba());
- return QPixmap::fromImage(restoreButton);
- }
- break;
-
- case SP_TitleBarCloseButton: // Fall through
- case SP_DockWidgetCloseButton: {
-
- QImage closeButton(dock_widget_close_xpm);
- QColor alphaCorner = closeButton.color(2);
- alphaCorner.setAlpha(80);
- closeButton.setColor(2, alphaCorner.rgba());
- return QPixmap::fromImage(closeButton);
- }
- break;
-
- case SP_DialogDiscardButton:
- return qt_gtk_get_icon(GTK_STOCK_DELETE);
- case SP_DialogOkButton:
- return qt_gtk_get_icon(GTK_STOCK_OK);
- case SP_DialogCancelButton:
- return qt_gtk_get_icon(GTK_STOCK_CANCEL);
- case SP_DialogYesButton:
- return qt_gtk_get_icon(GTK_STOCK_YES);
- case SP_DialogNoButton:
- return qt_gtk_get_icon(GTK_STOCK_NO);
- case SP_DialogOpenButton:
- return qt_gtk_get_icon(GTK_STOCK_OPEN);
- case SP_DialogCloseButton:
- return qt_gtk_get_icon(GTK_STOCK_CLOSE);
- case SP_DialogApplyButton:
- return qt_gtk_get_icon(GTK_STOCK_APPLY);
- case SP_DialogSaveButton:
- return qt_gtk_get_icon(GTK_STOCK_SAVE);
- case SP_MessageBoxWarning:
- return qt_gtk_get_icon(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
- case SP_MessageBoxQuestion:
- return qt_gtk_get_icon(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
- case SP_MessageBoxInformation:
- return qt_gtk_get_icon(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
- case SP_MessageBoxCritical:
- return qt_gtk_get_icon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
- default:
- return QCommonStyle::standardPixmap(sp, option, widget);
- }
- return pixmap;
-}
-
-/*!
- \reimp
-*/
-QIcon QGtkStyle::standardIcon(StandardPixmap standardIcon,
- const QStyleOption *option,
- const QWidget *widget) const
-{
- Q_D(const QGtkStyle);
-
- if (!d->isThemeAvailable())
- return QCommonStyle::standardIcon(standardIcon, option, widget);
- switch (standardIcon) {
- case SP_DialogDiscardButton:
- return qt_gtk_get_icon(GTK_STOCK_DELETE);
- case SP_DialogOkButton:
- return qt_gtk_get_icon(GTK_STOCK_OK);
- case SP_DialogCancelButton:
- return qt_gtk_get_icon(GTK_STOCK_CANCEL);
- case SP_DialogYesButton:
- return qt_gtk_get_icon(GTK_STOCK_YES);
- case SP_DialogNoButton:
- return qt_gtk_get_icon(GTK_STOCK_NO);
- case SP_DialogOpenButton:
- return qt_gtk_get_icon(GTK_STOCK_OPEN);
- case SP_DialogCloseButton:
- return qt_gtk_get_icon(GTK_STOCK_CLOSE);
- case SP_DialogApplyButton:
- return qt_gtk_get_icon(GTK_STOCK_APPLY);
- case SP_DialogSaveButton:
- return qt_gtk_get_icon(GTK_STOCK_SAVE);
- case SP_MessageBoxWarning:
- return qt_gtk_get_icon(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
- case SP_MessageBoxQuestion:
- return qt_gtk_get_icon(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
- case SP_MessageBoxInformation:
- return qt_gtk_get_icon(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
- case SP_MessageBoxCritical:
- return qt_gtk_get_icon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
- default:
- return QCommonStyle::standardIcon(standardIcon, option, widget);
- }
-}
-
-
-/*! \reimp */
-QRect QGtkStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
-{
- Q_D(const QGtkStyle);
-
- QRect r = QCommonStyle::subElementRect(element, option, widget);
- if (!d->isThemeAvailable())
- return r;
-
- switch (element) {
- case SE_PushButtonFocusRect:
- r.adjust(0, 1, 0, -1);
- break;
- case SE_DockWidgetTitleBarText: {
- const QStyleOptionDockWidgetV2 *v2
- = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(option);
- bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
- if (verticalTitleBar) {
- r.adjust(0, 0, 0, -4);
- } else {
- if (option->direction == Qt::LeftToRight)
- r.adjust(4, 0, 0, 0);
- else
- r.adjust(0, 0, -4, 0);
- }
-
- break;
- }
- case SE_ProgressBarLabel:
- case SE_ProgressBarContents:
- case SE_ProgressBarGroove:
- return option->rect;
- case SE_PushButtonContents:
- if (!d->gtk_check_version(2, 10, 0)) {
- GtkWidget *gtkButton = d->gtkWidget("GtkButton");
- GtkBorder *border = 0;
- d->gtk_widget_style_get(gtkButton, "inner-border", &border, NULL);
- if (border) {
- r = option->rect.adjusted(border->left, border->top, -border->right, -border->bottom);
- d->gtk_border_free(border);
- } else {
- r = option->rect.adjusted(1, 1, -1, -1);
- }
- r = visualRect(option->direction, option->rect, r);
- }
- break;
- default:
- break;
- }
-
- return r;
-}
-
-/*!
- \reimp
-*/
-QRect QGtkStyle::itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const
-{
- return QCommonStyle::itemPixmapRect(r, flags, pixmap);
-}
-
-/*!
- \reimp
-*/
-void QGtkStyle::drawItemPixmap(QPainter *painter, const QRect &rect,
- int alignment, const QPixmap &pixmap) const
-{
- QCommonStyle::drawItemPixmap(painter, rect, alignment, pixmap);
-}
-
-/*!
- \reimp
-*/
-QStyle::SubControl QGtkStyle::hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
- const QPoint &pt, const QWidget *w) const
-{
- return QCommonStyle::hitTestComplexControl(cc, opt, pt, w);
-}
-
-/*!
- \reimp
-*/
-QPixmap QGtkStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
- const QStyleOption *opt) const
-{
- return QCommonStyle::generatedIconPixmap(iconMode, pixmap, opt);
-}
-
-/*!
- \reimp
-*/
-void QGtkStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal,
- bool enabled, const QString& text, QPalette::ColorRole textRole) const
-{
- return QCommonStyle::drawItemText(painter, rect, alignment, pal, enabled, text, textRole);
-}
-
-QT_END_NAMESPACE
-
-#endif //!defined(QT_NO_STYLE_QGTK)
diff --git a/src/widgets/styles/qgtkstyle_p.cpp b/src/widgets/styles/qgtkstyle_p.cpp
deleted file mode 100644
index 00682c1c0f..0000000000
--- a/src/widgets/styles/qgtkstyle_p.cpp
+++ /dev/null
@@ -1,891 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgtkstyle_p_p.h"
-
-// This file is responsible for resolving all GTK functions we use
-// dynamically. This is done to avoid link-time dependancy on GTK
-// as well as crashes occurring due to usage of the GTK_QT engines
-//
-// Additionally we create a map of common GTK widgets that we can pass
-// to the GTK theme engine as many engines resort to querying the
-// actual widget pointers for details that are not covered by the
-// state flags
-
-#include <QtCore/qglobal.h>
-#if !defined(QT_NO_STYLE_GTK)
-
-#include <QtCore/QEvent>
-#include <QtCore/QFile>
-#include <QtCore/QStringList>
-#include <QtCore/QTextStream>
-#include <QtCore/QHash>
-#include <QtCore/QUrl>
-#include <QtCore/QLibrary>
-#include <QtCore/QDebug>
-
-#include <private/qgtk2painter_p.h>
-#include <private/qapplication_p.h>
-#include <private/qiconloader_p.h>
-#include <qpa/qplatformfontdatabase.h>
-
-#include <QtWidgets/QMenu>
-#include <QtWidgets/QStyle>
-#include <QtWidgets/QApplication>
-#include <QtGui/QPixmapCache>
-#include <QtWidgets/QStatusBar>
-#include <QtWidgets/QMenuBar>
-#include <QtWidgets/QToolBar>
-#include <QtWidgets/QToolButton>
-
-#ifndef Q_OS_MAC
-// X11 Includes:
-
-// the following is necessary to work around breakage in many versions
-// of XFree86's Xlib.h still in use
-// ### which versions?
-#if defined(_XLIB_H_) // crude hack, but...
-#error "cannot include <X11/Xlib.h> before this file"
-#endif
-#define XRegisterIMInstantiateCallback qt_XRegisterIMInstantiateCallback
-#define XUnregisterIMInstantiateCallback qt_XUnregisterIMInstantiateCallback
-#define XSetIMValues qt_XSetIMValues
-#include <X11/Xlib.h>
-#undef XRegisterIMInstantiateCallback
-#undef XUnregisterIMInstantiateCallback
-#undef XSetIMValues
-#endif
-
-QT_BEGIN_NAMESPACE
-
-Q_GLOBAL_STATIC(QGtkStyleUpdateScheduler, styleScheduler)
-
-Ptr_gtk_container_forall QGtkStylePrivate::gtk_container_forall = 0;
-Ptr_gtk_init QGtkStylePrivate::gtk_init = 0;
-Ptr_gtk_style_attach QGtkStylePrivate::gtk_style_attach = 0;
-Ptr_gtk_window_new QGtkStylePrivate::gtk_window_new = 0;
-Ptr_gtk_widget_destroy QGtkStylePrivate::gtk_widget_destroy = 0;
-Ptr_gtk_widget_realize QGtkStylePrivate::gtk_widget_realize = 0;
-Ptr_gtk_widget_set_default_direction QGtkStylePrivate::gtk_widget_set_default_direction = 0;
-Ptr_gtk_widget_modify_color QGtkStylePrivate::gtk_widget_modify_fg = 0;
-Ptr_gtk_widget_modify_color QGtkStylePrivate::gtk_widget_modify_bg = 0;
-Ptr_gtk_arrow_new QGtkStylePrivate::gtk_arrow_new = 0;
-Ptr_gtk_menu_item_new_with_label QGtkStylePrivate::gtk_menu_item_new_with_label = 0;
-Ptr_gtk_check_menu_item_new_with_label QGtkStylePrivate::gtk_check_menu_item_new_with_label = 0;
-Ptr_gtk_menu_bar_new QGtkStylePrivate::gtk_menu_bar_new = 0;
-Ptr_gtk_menu_new QGtkStylePrivate::gtk_menu_new = 0;
-Ptr_gtk_button_new QGtkStylePrivate::gtk_button_new = 0;
-Ptr_gtk_tool_button_new QGtkStylePrivate::gtk_tool_button_new = 0;
-Ptr_gtk_hbutton_box_new QGtkStylePrivate::gtk_hbutton_box_new = 0;
-Ptr_gtk_check_button_new QGtkStylePrivate::gtk_check_button_new = 0;
-Ptr_gtk_radio_button_new QGtkStylePrivate::gtk_radio_button_new = 0;
-Ptr_gtk_spin_button_new QGtkStylePrivate::gtk_spin_button_new = 0;
-Ptr_gtk_frame_new QGtkStylePrivate::gtk_frame_new = 0;
-Ptr_gtk_expander_new QGtkStylePrivate::gtk_expander_new = 0;
-Ptr_gtk_statusbar_new QGtkStylePrivate::gtk_statusbar_new = 0;
-Ptr_gtk_entry_new QGtkStylePrivate::gtk_entry_new = 0;
-Ptr_gtk_hscale_new QGtkStylePrivate::gtk_hscale_new = 0;
-Ptr_gtk_vscale_new QGtkStylePrivate::gtk_vscale_new = 0;
-Ptr_gtk_hscrollbar_new QGtkStylePrivate::gtk_hscrollbar_new = 0;
-Ptr_gtk_vscrollbar_new QGtkStylePrivate::gtk_vscrollbar_new = 0;
-Ptr_gtk_scrolled_window_new QGtkStylePrivate::gtk_scrolled_window_new = 0;
-Ptr_gtk_notebook_new QGtkStylePrivate::gtk_notebook_new = 0;
-Ptr_gtk_toolbar_new QGtkStylePrivate::gtk_toolbar_new = 0;
-Ptr_gtk_toolbar_insert QGtkStylePrivate::gtk_toolbar_insert = 0;
-Ptr_gtk_separator_tool_item_new QGtkStylePrivate::gtk_separator_tool_item_new = 0;
-Ptr_gtk_tree_view_new QGtkStylePrivate::gtk_tree_view_new = 0;
-Ptr_gtk_combo_box_new QGtkStylePrivate::gtk_combo_box_new = 0;
-Ptr_gtk_combo_box_entry_new QGtkStylePrivate::gtk_combo_box_entry_new = 0;
-Ptr_gtk_progress_bar_new QGtkStylePrivate::gtk_progress_bar_new = 0;
-Ptr_gtk_container_add QGtkStylePrivate::gtk_container_add = 0;
-Ptr_gtk_menu_shell_append QGtkStylePrivate::gtk_menu_shell_append = 0;
-Ptr_gtk_range_get_adjustment QGtkStylePrivate::gtk_range_get_adjustment = 0;
-Ptr_gtk_range_set_adjustment QGtkStylePrivate::gtk_range_set_adjustment = 0;
-Ptr_gtk_range_set_inverted QGtkStylePrivate::gtk_range_set_inverted = 0;
-Ptr_gtk_icon_factory_lookup_default QGtkStylePrivate::gtk_icon_factory_lookup_default = 0;
-Ptr_gtk_icon_theme_get_default QGtkStylePrivate::gtk_icon_theme_get_default = 0;
-Ptr_gtk_widget_get_style QGtkStylePrivate::gtk_widget_get_style = 0;
-Ptr_gtk_widget_style_get QGtkStylePrivate::gtk_widget_style_get = 0;
-Ptr_gtk_icon_set_render_icon QGtkStylePrivate::gtk_icon_set_render_icon = 0;
-Ptr_gtk_fixed_new QGtkStylePrivate::gtk_fixed_new = 0;
-Ptr_gtk_tree_view_column_new QGtkStylePrivate::gtk_tree_view_column_new = 0;
-Ptr_gtk_tree_view_get_column QGtkStylePrivate::gtk_tree_view_get_column = 0;
-Ptr_gtk_tree_view_append_column QGtkStylePrivate::gtk_tree_view_append_column = 0;
-Ptr_gtk_adjustment_configure QGtkStylePrivate::gtk_adjustment_configure = 0;
-Ptr_gtk_adjustment_new QGtkStylePrivate::gtk_adjustment_new = 0;
-Ptr_gtk_menu_item_set_submenu QGtkStylePrivate::gtk_menu_item_set_submenu = 0;
-Ptr_gtk_settings_get_default QGtkStylePrivate::gtk_settings_get_default = 0;
-Ptr_gtk_separator_menu_item_new QGtkStylePrivate::gtk_separator_menu_item_new = 0;
-Ptr_gtk_widget_size_allocate QGtkStylePrivate::gtk_widget_size_allocate = 0;
-Ptr_gtk_widget_size_request QGtkStylePrivate::gtk_widget_size_request = 0;
-Ptr_gtk_widget_set_direction QGtkStylePrivate::gtk_widget_set_direction = 0;
-Ptr_gtk_widget_path QGtkStylePrivate::gtk_widget_path = 0;
-Ptr_gtk_container_get_type QGtkStylePrivate::gtk_container_get_type = 0;
-Ptr_gtk_window_get_type QGtkStylePrivate::gtk_window_get_type = 0;
-Ptr_gtk_widget_get_type QGtkStylePrivate::gtk_widget_get_type = 0;
-Ptr_gtk_widget_get_parent QGtkStylePrivate::gtk_widget_get_parent = 0;
-Ptr_gtk_widget_is_toplevel QGtkStylePrivate::gtk_widget_is_toplevel = 0;
-Ptr_gtk_widget_get_toplevel QGtkStylePrivate::gtk_widget_get_toplevel = 0;
-Ptr_gtk_rc_get_style_by_paths QGtkStylePrivate::gtk_rc_get_style_by_paths = 0;
-Ptr_gtk_check_version QGtkStylePrivate::gtk_check_version = 0;
-Ptr_gtk_border_free QGtkStylePrivate::gtk_border_free = 0;
-Ptr_gtk_widget_get_allocation QGtkStylePrivate::gtk_widget_get_allocation = 0;
-Ptr_gtk_widget_set_allocation QGtkStylePrivate::gtk_widget_set_allocation = 0;
-Ptr_gtk_widget_set_can_default QGtkStylePrivate::gtk_widget_set_can_default = 0;
-Ptr_gtk_window_set_default QGtkStylePrivate::gtk_window_set_default = 0;
-
-Ptr_gdk_event_new QGtkStylePrivate::gdk_event_new = 0;
-Ptr_gdk_event_free QGtkStylePrivate::gdk_event_free = 0;
-Ptr_gtk_widget_send_focus_change QGtkStylePrivate::gtk_widget_send_focus_change = 0;
-
-Ptr_pango_font_description_get_size QGtkStylePrivate::pango_font_description_get_size = 0;
-Ptr_pango_font_description_get_weight QGtkStylePrivate::pango_font_description_get_weight = 0;
-Ptr_pango_font_description_get_family QGtkStylePrivate::pango_font_description_get_family = 0;
-Ptr_pango_font_description_get_style QGtkStylePrivate::pango_font_description_get_style = 0;
-
-Ptr_gdk_pixbuf_get_pixels QGtkStylePrivate::gdk_pixbuf_get_pixels = 0;
-Ptr_gdk_pixbuf_get_width QGtkStylePrivate::gdk_pixbuf_get_width = 0;
-Ptr_gdk_pixbuf_get_height QGtkStylePrivate::gdk_pixbuf_get_height = 0;
-Ptr_gdk_pixbuf_new QGtkStylePrivate::gdk_pixbuf_new = 0;
-Ptr_gdk_pixbuf_unref QGtkStylePrivate::gdk_pixbuf_unref = 0;
-Ptr_gdk_color_free QGtkStylePrivate::gdk_color_free = 0;
-Ptr_gdk_x11_window_set_user_time QGtkStylePrivate::gdk_x11_window_set_user_time = 0;
-Ptr_gdk_x11_drawable_get_xid QGtkStylePrivate::gdk_x11_drawable_get_xid = 0;
-Ptr_gdk_x11_drawable_get_xdisplay QGtkStylePrivate::gdk_x11_drawable_get_xdisplay = 0;
-
-Ptr_gconf_client_get_default QGtkStylePrivate::gconf_client_get_default = 0;
-Ptr_gconf_client_get_string QGtkStylePrivate::gconf_client_get_string = 0;
-Ptr_gconf_client_get_bool QGtkStylePrivate::gconf_client_get_bool = 0;
-
-Ptr_gnome_icon_lookup_sync QGtkStylePrivate::gnome_icon_lookup_sync = 0;
-Ptr_gnome_vfs_init QGtkStylePrivate::gnome_vfs_init = 0;
-
-#ifndef Q_OS_MAC
-typedef int (*x11ErrorHandler)(Display*, XErrorEvent*);
-#endif
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QGtkStylePrivate*);
-
-QT_BEGIN_NAMESPACE
-
-static void gtkStyleSetCallback(GtkWidget*)
-{
- qRegisterMetaType<QGtkStylePrivate *>();
-
- // 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);
-}
-
-static void update_toolbar_style(GtkWidget *gtkToolBar, GParamSpec *, gpointer)
-{
- GtkToolbarStyle toolbar_style = GTK_TOOLBAR_ICONS;
- g_object_get(gtkToolBar, "toolbar-style", &toolbar_style, NULL);
- QWidgetList widgets = QApplication::allWidgets();
- for (int i = 0; i < widgets.size(); ++i) {
- QWidget *widget = widgets.at(i);
- if (qobject_cast<QToolButton*>(widget)) {
- QEvent event(QEvent::StyleChange);
- QApplication::sendEvent(widget, &event);
- }
- }
-}
-
-static QHashableLatin1Literal classPath(GtkWidget *widget)
-{
- char *class_path;
- QGtkStylePrivate::gtk_widget_path (widget, NULL, &class_path, NULL);
-
- char *copy = class_path;
- if (strncmp(copy, "GtkWindow.", 10) == 0)
- copy += 10;
- if (strncmp(copy, "GtkFixed.", 9) == 0)
- copy += 9;
-
- copy = strdup(copy);
-
- g_free(class_path);
-
- return QHashableLatin1Literal::fromData(copy);
-}
-
-
-
-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
- if (!qt_app_palettes_hash() || qt_app_palettes_hash()->isEmpty()) {
- stylePrivate->applyCustomPaletteHash();
- }
- }
- return QObject::eventFilter(obj, e);
-}
-
-QList<QGtkStylePrivate *> QGtkStylePrivate::instances;
-QGtkStylePrivate::WidgetMap *QGtkStylePrivate::widgetMap = 0;
-
-QGtkStylePrivate::QGtkStylePrivate()
- : QCommonStylePrivate()
- , filter(this)
-{
- instances.append(this);
- animationFps = 60;
-}
-
-QGtkStylePrivate::~QGtkStylePrivate()
-{
- instances.removeOne(this);
-}
-
-void QGtkStylePrivate::init()
-{
- resolveGtk();
- initGtkWidgets();
-}
-
-QGtkPainter* QGtkStylePrivate::gtkPainter(QPainter *painter)
-{
- // TODO: choose between gtk2 and gtk3
- static QGtk2Painter instance;
- instance.reset(painter);
- return &instance;
-}
-
-GtkWidget* QGtkStylePrivate::gtkWidget(const QHashableLatin1Literal &path)
-{
- GtkWidget *widget = gtkWidgetMap()->value(path);
- if (!widget) {
- // Theme might have rearranged widget internals
- widget = gtkWidgetMap()->value(path);
- }
- return widget;
-}
-
-GtkStyle* QGtkStylePrivate::gtkStyle(const QHashableLatin1Literal &path)
-{
- if (GtkWidget *w = gtkWidgetMap()->value(path))
- return QGtkStylePrivate::gtk_widget_get_style(w);
- return 0;
-}
-
-void QGtkStylePrivate::gtkWidgetSetFocus(GtkWidget *widget, bool focus)
-{
- if (QGtkStylePrivate::gtk_widget_send_focus_change) {
- GdkEvent *event = QGtkStylePrivate::gdk_event_new(GDK_FOCUS_CHANGE);
- event->focus_change.type = GDK_FOCUS_CHANGE;
- event->focus_change.in = focus;
- QGtkStylePrivate::gtk_widget_send_focus_change(widget, event);
- QGtkStylePrivate::gdk_event_free(event);
- } else {
-#if defined(GTK_WIDGET_SET_FLAGS) && defined(GTK_WIDGET_UNSET_FLAGS)
- if (focus)
- GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS);
- else
- GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS);
-#endif
- }
-}
-
-/*! \internal
- * Get references to gtk functions after we dynamically load the library.
- */
-void QGtkStylePrivate::resolveGtk() const
-{
-#ifndef QT_NO_LIBRARY
- // enforce the "0" suffix, so we'll open libgtk-x11-2.0.so.0
- QLibrary libgtk(QLS("gtk-x11-2.0"), 0, 0);
-
- gtk_init = (Ptr_gtk_init)libgtk.resolve("gtk_init");
- gtk_window_new = (Ptr_gtk_window_new)libgtk.resolve("gtk_window_new");
- gtk_style_attach = (Ptr_gtk_style_attach)libgtk.resolve("gtk_style_attach");
- gtk_widget_destroy = (Ptr_gtk_widget_destroy)libgtk.resolve("gtk_widget_destroy");
- gtk_widget_realize = (Ptr_gtk_widget_realize)libgtk.resolve("gtk_widget_realize");
-
- gdk_pixbuf_get_pixels = (Ptr_gdk_pixbuf_get_pixels)libgtk.resolve("gdk_pixbuf_get_pixels");
- gdk_pixbuf_get_width = (Ptr_gdk_pixbuf_get_width)libgtk.resolve("gdk_pixbuf_get_width");
- gdk_pixbuf_get_height = (Ptr_gdk_pixbuf_get_height)libgtk.resolve("gdk_pixbuf_get_height");
- gdk_pixbuf_new = (Ptr_gdk_pixbuf_new)libgtk.resolve("gdk_pixbuf_new");
- gdk_pixbuf_unref = (Ptr_gdk_pixbuf_unref)libgtk.resolve("gdk_pixbuf_unref");
- gdk_color_free = (Ptr_gdk_color_free)libgtk.resolve("gdk_color_free");
- gdk_x11_window_set_user_time = (Ptr_gdk_x11_window_set_user_time)libgtk.resolve("gdk_x11_window_set_user_time");
- gdk_x11_drawable_get_xid = (Ptr_gdk_x11_drawable_get_xid)libgtk.resolve("gdk_x11_drawable_get_xid");
- gdk_x11_drawable_get_xdisplay = (Ptr_gdk_x11_drawable_get_xdisplay)libgtk.resolve("gdk_x11_drawable_get_xdisplay");
-
- gtk_widget_set_default_direction = (Ptr_gtk_widget_set_default_direction)libgtk.resolve("gtk_widget_set_default_direction");
- gtk_widget_modify_fg = (Ptr_gtk_widget_modify_color)libgtk.resolve("gtk_widget_modify_fg");
- gtk_widget_modify_bg = (Ptr_gtk_widget_modify_color)libgtk.resolve("gtk_widget_modify_bg");
- gtk_arrow_new = (Ptr_gtk_arrow_new)libgtk.resolve("gtk_arrow_new");
- gtk_menu_item_new_with_label = (Ptr_gtk_menu_item_new_with_label)libgtk.resolve("gtk_menu_item_new_with_label");
- gtk_check_menu_item_new_with_label = (Ptr_gtk_check_menu_item_new_with_label)libgtk.resolve("gtk_check_menu_item_new_with_label");
- gtk_menu_bar_new = (Ptr_gtk_menu_bar_new)libgtk.resolve("gtk_menu_bar_new");
- gtk_menu_new = (Ptr_gtk_menu_new)libgtk.resolve("gtk_menu_new");
- gtk_toolbar_new = (Ptr_gtk_toolbar_new)libgtk.resolve("gtk_toolbar_new");
- gtk_separator_tool_item_new = (Ptr_gtk_separator_tool_item_new)libgtk.resolve("gtk_separator_tool_item_new");
- gtk_toolbar_insert = (Ptr_gtk_toolbar_insert)libgtk.resolve("gtk_toolbar_insert");
- gtk_button_new = (Ptr_gtk_button_new)libgtk.resolve("gtk_button_new");
- gtk_tool_button_new = (Ptr_gtk_tool_button_new)libgtk.resolve("gtk_tool_button_new");
- gtk_hbutton_box_new = (Ptr_gtk_hbutton_box_new)libgtk.resolve("gtk_hbutton_box_new");
- gtk_check_button_new = (Ptr_gtk_check_button_new)libgtk.resolve("gtk_check_button_new");
- gtk_radio_button_new = (Ptr_gtk_radio_button_new)libgtk.resolve("gtk_radio_button_new");
- gtk_notebook_new = (Ptr_gtk_notebook_new)libgtk.resolve("gtk_notebook_new");
- gtk_progress_bar_new = (Ptr_gtk_progress_bar_new)libgtk.resolve("gtk_progress_bar_new");
- gtk_spin_button_new = (Ptr_gtk_spin_button_new)libgtk.resolve("gtk_spin_button_new");
- gtk_hscale_new = (Ptr_gtk_hscale_new)libgtk.resolve("gtk_hscale_new");
- gtk_vscale_new = (Ptr_gtk_vscale_new)libgtk.resolve("gtk_vscale_new");
- gtk_hscrollbar_new = (Ptr_gtk_hscrollbar_new)libgtk.resolve("gtk_hscrollbar_new");
- gtk_vscrollbar_new = (Ptr_gtk_vscrollbar_new)libgtk.resolve("gtk_vscrollbar_new");
- gtk_scrolled_window_new = (Ptr_gtk_scrolled_window_new)libgtk.resolve("gtk_scrolled_window_new");
- gtk_menu_shell_append = (Ptr_gtk_menu_shell_append)libgtk.resolve("gtk_menu_shell_append");
- gtk_entry_new = (Ptr_gtk_entry_new)libgtk.resolve("gtk_entry_new");
- gtk_tree_view_new = (Ptr_gtk_tree_view_new)libgtk.resolve("gtk_tree_view_new");
- gtk_combo_box_new = (Ptr_gtk_combo_box_new)libgtk.resolve("gtk_combo_box_new");
- gtk_combo_box_entry_new = (Ptr_gtk_combo_box_entry_new)libgtk.resolve("gtk_combo_box_entry_new");
- gtk_range_get_adjustment = (Ptr_gtk_range_get_adjustment)libgtk.resolve("gtk_range_get_adjustment");
- gtk_range_set_adjustment = (Ptr_gtk_range_set_adjustment)libgtk.resolve("gtk_range_set_adjustment");
- gtk_range_set_inverted = (Ptr_gtk_range_set_inverted)libgtk.resolve("gtk_range_set_inverted");
- gtk_container_add = (Ptr_gtk_container_add)libgtk.resolve("gtk_container_add");
- gtk_icon_factory_lookup_default = (Ptr_gtk_icon_factory_lookup_default)libgtk.resolve("gtk_icon_factory_lookup_default");
- gtk_icon_theme_get_default = (Ptr_gtk_icon_theme_get_default)libgtk.resolve("gtk_icon_theme_get_default");
- gtk_widget_get_style = (Ptr_gtk_widget_get_style)libgtk.resolve("gtk_widget_get_style");
- gtk_widget_style_get = (Ptr_gtk_widget_style_get)libgtk.resolve("gtk_widget_style_get");
- gtk_icon_set_render_icon = (Ptr_gtk_icon_set_render_icon)libgtk.resolve("gtk_icon_set_render_icon");
- gtk_fixed_new = (Ptr_gtk_fixed_new)libgtk.resolve("gtk_fixed_new");
- gtk_tree_view_column_new = (Ptr_gtk_tree_view_column_new)libgtk.resolve("gtk_tree_view_column_new");
- gtk_tree_view_append_column= (Ptr_gtk_tree_view_append_column )libgtk.resolve("gtk_tree_view_append_column");
- gtk_tree_view_get_column = (Ptr_gtk_tree_view_get_column )libgtk.resolve("gtk_tree_view_get_column");
- gtk_adjustment_configure = (Ptr_gtk_adjustment_configure)libgtk.resolve("gtk_adjustment_configure");
- gtk_adjustment_new = (Ptr_gtk_adjustment_new)libgtk.resolve("gtk_adjustment_new");
- gtk_menu_item_set_submenu = (Ptr_gtk_menu_item_set_submenu)libgtk.resolve("gtk_menu_item_set_submenu");
- gtk_settings_get_default = (Ptr_gtk_settings_get_default)libgtk.resolve("gtk_settings_get_default");
- gtk_separator_menu_item_new = (Ptr_gtk_separator_menu_item_new)libgtk.resolve("gtk_separator_menu_item_new");
- gtk_frame_new = (Ptr_gtk_frame_new)libgtk.resolve("gtk_frame_new");
- gtk_expander_new = (Ptr_gtk_expander_new)libgtk.resolve("gtk_expander_new");
- gtk_statusbar_new = (Ptr_gtk_statusbar_new)libgtk.resolve("gtk_statusbar_new");
- gtk_container_forall = (Ptr_gtk_container_forall)libgtk.resolve("gtk_container_forall");
- gtk_widget_size_allocate =(Ptr_gtk_widget_size_allocate)libgtk.resolve("gtk_widget_size_allocate");
- gtk_widget_size_request =(Ptr_gtk_widget_size_request)libgtk.resolve("gtk_widget_size_request");
- gtk_widget_set_direction =(Ptr_gtk_widget_set_direction)libgtk.resolve("gtk_widget_set_direction");
- gtk_widget_path =(Ptr_gtk_widget_path)libgtk.resolve("gtk_widget_path");
- gtk_container_get_type =(Ptr_gtk_container_get_type)libgtk.resolve("gtk_container_get_type");
- gtk_window_get_type =(Ptr_gtk_window_get_type)libgtk.resolve("gtk_window_get_type");
- gtk_widget_get_type =(Ptr_gtk_widget_get_type)libgtk.resolve("gtk_widget_get_type");
- gtk_widget_get_parent =(Ptr_gtk_widget_get_parent)libgtk.resolve("gtk_widget_get_parent");
- gtk_widget_is_toplevel =(Ptr_gtk_widget_is_toplevel)libgtk.resolve("gtk_widget_is_toplevel");
- gtk_widget_get_toplevel =(Ptr_gtk_widget_get_toplevel)libgtk.resolve("gtk_widget_get_toplevel");
-
- gtk_rc_get_style_by_paths =(Ptr_gtk_rc_get_style_by_paths)libgtk.resolve("gtk_rc_get_style_by_paths");
- gtk_check_version =(Ptr_gtk_check_version)libgtk.resolve("gtk_check_version");
- gtk_border_free =(Ptr_gtk_border_free)libgtk.resolve("gtk_border_free");
- gtk_widget_get_allocation = (Ptr_gtk_widget_get_allocation)libgtk.resolve("gtk_widget_get_allocation");
- gtk_widget_set_allocation = (Ptr_gtk_widget_set_allocation)libgtk.resolve("gtk_widget_set_allocation");
-
- gtk_widget_set_can_default = (Ptr_gtk_widget_set_can_default)libgtk.resolve("gtk_widget_set_can_default");
- gtk_window_set_default = (Ptr_gtk_window_set_default)libgtk.resolve("gtk_window_set_default");
-
- gdk_event_new = (Ptr_gdk_event_new)libgtk.resolve("gdk_event_new");
- gdk_event_free = (Ptr_gdk_event_free)libgtk.resolve("gdk_event_free");
- gtk_widget_send_focus_change = (Ptr_gtk_widget_send_focus_change)libgtk.resolve("gtk_widget_send_focus_change");
-
- pango_font_description_get_size = (Ptr_pango_font_description_get_size)libgtk.resolve("pango_font_description_get_size");
- pango_font_description_get_weight = (Ptr_pango_font_description_get_weight)libgtk.resolve("pango_font_description_get_weight");
- pango_font_description_get_family = (Ptr_pango_font_description_get_family)libgtk.resolve("pango_font_description_get_family");
- pango_font_description_get_style = (Ptr_pango_font_description_get_style)libgtk.resolve("pango_font_description_get_style");
-
- gnome_icon_lookup_sync = (Ptr_gnome_icon_lookup_sync)QLibrary::resolve(QLS("gnomeui-2"), 0, "gnome_icon_lookup_sync");
- gnome_vfs_init= (Ptr_gnome_vfs_init)QLibrary::resolve(QLS("gnomevfs-2"), 0, "gnome_vfs_init");
-#endif // !QT_NO_LIBRARY
-}
-
-/* \internal
- * Initializes a number of gtk menu widgets.
- * The widgets are cached.
- */
-void QGtkStylePrivate::initGtkMenu() const
-{
- // Create menubar
- GtkWidget *gtkMenuBar = QGtkStylePrivate::gtk_menu_bar_new();
- setupGtkWidget(gtkMenuBar);
-
- GtkWidget *gtkMenuBarItem = QGtkStylePrivate::gtk_menu_item_new_with_label("X");
- gtk_menu_shell_append((GtkMenuShell*)(gtkMenuBar), gtkMenuBarItem);
- gtk_widget_realize(gtkMenuBarItem);
-
- // Create menu
- GtkWidget *gtkMenu = QGtkStylePrivate::gtk_menu_new();
- gtk_menu_item_set_submenu((GtkMenuItem*)(gtkMenuBarItem), gtkMenu);
- gtk_widget_realize(gtkMenu);
-
- GtkWidget *gtkMenuItem = QGtkStylePrivate::gtk_menu_item_new_with_label("X");
- gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkMenuItem);
- gtk_widget_realize(gtkMenuItem);
-
- GtkWidget *gtkCheckMenuItem = QGtkStylePrivate::gtk_check_menu_item_new_with_label("X");
- gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkCheckMenuItem);
- gtk_widget_realize(gtkCheckMenuItem);
-
- GtkWidget *gtkMenuSeparator = QGtkStylePrivate::gtk_separator_menu_item_new();
- gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkMenuSeparator);
-
- addAllSubWidgets(gtkMenuBar);
- addAllSubWidgets(gtkMenu);
-}
-
-
-void QGtkStylePrivate::initGtkTreeview() const
-{
- GtkWidget *gtkTreeView = gtk_tree_view_new();
- gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, gtk_tree_view_column_new());
- gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, gtk_tree_view_column_new());
- gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, gtk_tree_view_column_new());
- addWidget(gtkTreeView);
-}
-
-
-/* \internal
- * Initializes a number of gtk widgets that we can later on use to determine some of our styles.
- * The widgets are cached.
- */
-void QGtkStylePrivate::initGtkWidgets() const
-{
- // From gtkmain.c
- uid_t ruid = getuid ();
- uid_t rgid = getgid ();
- uid_t euid = geteuid ();
- uid_t egid = getegid ();
- if (ruid != euid || rgid != egid) {
- qWarning("\nThis process is currently running setuid or setgid.\nGTK+ does not allow this "
- "therefore Qt cannot use the GTK+ integration.\nTry launching your app using \'gksudo\', "
- "\'kdesudo\' or a similar tool.\n\n"
- "See http://www.gtk.org/setuid.html for more information.\n");
- return;
- }
-
- if (QGtkStylePrivate::gtk_init) {
-#ifndef Q_OS_MAC
- // Gtk will set the Qt error handler so we have to reset it afterwards
- x11ErrorHandler qt_x_errhandler = XSetErrorHandler(0);
-#endif
- QGtkStylePrivate::gtk_init (NULL, NULL);
-#ifndef Q_OS_MAC
- XSetErrorHandler(qt_x_errhandler);
-#endif
-
- // make a window
- GtkWidget* gtkWindow = QGtkStylePrivate::gtk_window_new(GTK_WINDOW_POPUP);
- QGtkStylePrivate::gtk_widget_realize(gtkWindow);
- QHashableLatin1Literal widgetPath = QHashableLatin1Literal::fromData(strdup("GtkWindow"));
- removeWidgetFromMap(widgetPath);
- gtkWidgetMap()->insert(widgetPath, gtkWindow);
-
-
- // Make all other widgets. respect the text direction
- if (qApp->layoutDirection() == Qt::RightToLeft)
- QGtkStylePrivate::gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL);
-
- if (!gtkWidgetMap()->contains("GtkButton")) {
- GtkWidget *gtkButton = QGtkStylePrivate::gtk_button_new();
- addWidget(gtkButton);
- g_signal_connect(gtkButton, "style-set", G_CALLBACK(gtkStyleSetCallback), 0);
- addWidget(QGtkStylePrivate::gtk_tool_button_new(NULL, "Qt"));
- addWidget(QGtkStylePrivate::gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE));
- addWidget(QGtkStylePrivate::gtk_hbutton_box_new());
- addWidget(QGtkStylePrivate::gtk_check_button_new());
- addWidget(QGtkStylePrivate::gtk_radio_button_new(NULL));
- addWidget(QGtkStylePrivate::gtk_combo_box_new());
- addWidget(QGtkStylePrivate::gtk_combo_box_entry_new());
- GtkWidget *entry = QGtkStylePrivate::gtk_entry_new();
- // gtk-im-context-none is supported in gtk+ since 2.19.5
- // and also exists in gtk3
- // http://git.gnome.org/browse/gtk+/tree/gtk/gtkimmulticontext.c?id=2.19.5#n33
- // reason that we don't use gtk-im-context-simple here is,
- // gtk-im-context-none has less overhead, and 2.19.5 is
- // relatively old. and even for older gtk+, it will fallback
- // to gtk-im-context-simple if gtk-im-context-none doesn't
- // exists.
- g_object_set(entry, "im-module", "gtk-im-context-none", NULL);
- addWidget(entry);
- addWidget(QGtkStylePrivate::gtk_frame_new(NULL));
- addWidget(QGtkStylePrivate::gtk_expander_new(""));
- addWidget(QGtkStylePrivate::gtk_statusbar_new());
- addWidget(QGtkStylePrivate::gtk_hscale_new((QGtkStylePrivate::gtk_adjustment_new(1, 0, 1, 0, 0, 0))));
- addWidget(QGtkStylePrivate::gtk_hscrollbar_new(NULL));
- addWidget(QGtkStylePrivate::gtk_scrolled_window_new(NULL, NULL));
-
- initGtkMenu();
- addWidget(QGtkStylePrivate::gtk_notebook_new());
- addWidget(QGtkStylePrivate::gtk_progress_bar_new());
- addWidget(QGtkStylePrivate::gtk_spin_button_new((QGtkStylePrivate::gtk_adjustment_new(1, 0, 1, 0, 0, 0)), 0.1, 3));
- GtkWidget *toolbar = gtk_toolbar_new();
- g_signal_connect (toolbar, "notify::toolbar-style", G_CALLBACK (update_toolbar_style), toolbar);
- gtk_toolbar_insert((GtkToolbar*)toolbar, gtk_separator_tool_item_new(), -1);
- addWidget(toolbar);
- initGtkTreeview();
- addWidget(gtk_vscale_new((QGtkStylePrivate::gtk_adjustment_new(1, 0, 1, 0, 0, 0))));
- addWidget(gtk_vscrollbar_new(NULL));
- }
- else // Rebuild map
- {
- // When styles change subwidgets can get rearranged
- // as with the combo box. We need to update the widget map
- // to reflect this;
- QHash<QHashableLatin1Literal, GtkWidget*> oldMap = *gtkWidgetMap();
- gtkWidgetMap()->clear();
- QHashIterator<QHashableLatin1Literal, GtkWidget*> it(oldMap);
- while (it.hasNext()) {
- it.next();
- if (!strchr(it.key().data(), '.')) {
- addAllSubWidgets(it.value());
- }
- free(const_cast<char *>(it.key().data()));
- }
- }
- } else {
- qWarning("QGtkStyle could not resolve GTK. Make sure you have installed the proper libraries.");
- }
-}
-
-/*! \internal
- * destroys all previously buffered widgets.
- */
-void QGtkStylePrivate::cleanupGtkWidgets()
-{
- if (!widgetMap)
- return;
- if (widgetMap->contains("GtkWindow")) // Gtk will destroy all children
- gtk_widget_destroy(widgetMap->value("GtkWindow"));
- for (QHash<QHashableLatin1Literal, GtkWidget *>::const_iterator it = widgetMap->constBegin();
- it != widgetMap->constEnd(); ++it)
- free(const_cast<char *>(it.key().data()));
-}
-
-static bool resolveGConf()
-{
-#ifndef QT_NO_LIBRARY
- if (!QGtkStylePrivate::gconf_client_get_default) {
- QGtkStylePrivate::gconf_client_get_default = (Ptr_gconf_client_get_default)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_default");
- QGtkStylePrivate::gconf_client_get_string = (Ptr_gconf_client_get_string)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_string");
- QGtkStylePrivate::gconf_client_get_bool = (Ptr_gconf_client_get_bool)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_bool");
- }
-#endif // !QT_NO_LIBRARY
- return (QGtkStylePrivate::gconf_client_get_default !=0);
-}
-
-QString QGtkStylePrivate::getGConfString(const QString &value, const QString &fallback)
-{
- QString retVal = fallback;
- if (resolveGConf()) {
-#if !defined(GLIB_VERSION_2_36)
- g_type_init();
-#endif
- GConfClient* client = gconf_client_get_default();
- GError *err = 0;
- char *str = gconf_client_get_string(client, qPrintable(value), &err);
- if (!err) {
- retVal = QString::fromUtf8(str);
- g_free(str);
- }
- g_object_unref(client);
- if (err)
- g_error_free (err);
- }
- return retVal;
-}
-
-bool QGtkStylePrivate::getGConfBool(const QString &key, bool fallback)
-{
- bool retVal = fallback;
- if (resolveGConf()) {
-#if !defined(GLIB_VERSION_2_36)
- g_type_init();
-#endif
- GConfClient* client = gconf_client_get_default();
- GError *err = 0;
- bool result = gconf_client_get_bool(client, qPrintable(key), &err);
- g_object_unref(client);
- if (!err)
- retVal = result;
- else
- g_error_free (err);
- }
- return retVal;
-}
-
-QString QGtkStylePrivate::getThemeName()
-{
- QString themeName;
- // Read the theme name from GtkSettings
- GtkSettings *settings = QGtkStylePrivate::gtk_settings_get_default();
- gchararray value;
- g_object_get(settings, "gtk-theme-name", &value, NULL);
- themeName = QString::fromUtf8(value);
- g_free(value);
- return themeName;
-}
-
-// Get size of the arrow controls in a GtkSpinButton
-int QGtkStylePrivate::getSpinboxArrowSize() const
-{
- const int MIN_ARROW_WIDTH = 6;
- GtkWidget *spinButton = gtkWidget("GtkSpinButton");
- GtkStyle *style = QGtkStylePrivate::gtk_widget_get_style(spinButton);
- gint size = pango_font_description_get_size (style->font_desc);
- gint arrow_size;
- arrow_size = qMax(PANGO_PIXELS (size), MIN_ARROW_WIDTH) + style->xthickness;
- arrow_size += arrow_size%2 + 1;
- return arrow_size;
-}
-
-
-bool QGtkStylePrivate::isKDE4Session()
-{
- static int version = -1;
- if (version == -1)
- version = qgetenv("KDE_SESSION_VERSION").toInt();
- return (version == 4);
-}
-
-void QGtkStylePrivate::applyCustomPaletteHash()
-{
- QPalette menuPal = gtkWidgetPalette("GtkMenu");
- GdkColor gdkBg = QGtkStylePrivate::gtk_widget_get_style(gtkWidget("GtkMenu"))->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 toolbarPal = gtkWidgetPalette("GtkToolbar");
- qApp->setPalette(toolbarPal, "QToolBar");
-
- QPalette menuBarPal = gtkWidgetPalette("GtkMenuBar");
- qApp->setPalette(menuBarPal, "QMenuBar");
-}
-
-/*! \internal
- * Returns the gtk Widget that should be used to determine text foreground and background colors.
-*/
-GtkWidget* QGtkStylePrivate::getTextColorWidget() const
-{
- return gtkWidget("GtkEntry");
-}
-
-void QGtkStylePrivate::setupGtkWidget(GtkWidget* widget)
-{
- if (Q_GTK_IS_WIDGET(widget)) {
- GtkWidget *protoLayout = gtkWidgetMap()->value("GtkContainer");
- if (!protoLayout) {
- protoLayout = QGtkStylePrivate::gtk_fixed_new();
- QGtkStylePrivate::gtk_container_add((GtkContainer*)(gtkWidgetMap()->value("GtkWindow")), protoLayout);
- QHashableLatin1Literal widgetPath = QHashableLatin1Literal::fromData(strdup("GtkContainer"));
- gtkWidgetMap()->insert(widgetPath, protoLayout);
- }
- Q_ASSERT(protoLayout);
-
- if (!QGtkStylePrivate::gtk_widget_get_parent(widget) && !QGtkStylePrivate::gtk_widget_is_toplevel(widget))
- QGtkStylePrivate::gtk_container_add((GtkContainer*)(protoLayout), widget);
- QGtkStylePrivate::gtk_widget_realize(widget);
- }
-}
-
-void QGtkStylePrivate::removeWidgetFromMap(const QHashableLatin1Literal &path)
-{
- WidgetMap *map = gtkWidgetMap();
- WidgetMap::iterator it = map->find(path);
- if (it != map->end()) {
- char* keyData = const_cast<char *>(it.key().data());
- map->erase(it);
- free(keyData);
- }
-}
-
-void QGtkStylePrivate::addWidgetToMap(GtkWidget *widget)
-{
- if (Q_GTK_IS_WIDGET(widget)) {
- gtk_widget_realize(widget);
- QHashableLatin1Literal widgetPath = classPath(widget);
-
- removeWidgetFromMap(widgetPath);
- gtkWidgetMap()->insert(widgetPath, widget);
-#ifdef DUMP_GTK_WIDGET_TREE
- qWarning("Inserted Gtk Widget: %s", widgetPath.data());
-#endif
- }
- }
-
-void QGtkStylePrivate::addAllSubWidgets(GtkWidget *widget, gpointer v)
-{
- Q_UNUSED(v);
- addWidgetToMap(widget);
- if (G_TYPE_CHECK_INSTANCE_TYPE ((widget), gtk_container_get_type()))
- gtk_container_forall((GtkContainer*)widget, addAllSubWidgets, NULL);
-}
-
-// Updates window/windowtext palette based on the indicated gtk widget
-QPalette QGtkStylePrivate::gtkWidgetPalette(const QHashableLatin1Literal &gtkWidgetName) const
-{
- GtkWidget *gtkWidget = QGtkStylePrivate::gtkWidget(gtkWidgetName);
- Q_ASSERT(gtkWidget);
- QPalette pal = QApplication::palette();
- GdkColor gdkBg = gtk_widget_get_style(gtkWidget)->bg[GTK_STATE_NORMAL];
- GdkColor gdkText = gtk_widget_get_style(gtkWidget)->fg[GTK_STATE_NORMAL];
- GdkColor gdkDisabledText = gtk_widget_get_style(gtkWidget)->fg[GTK_STATE_INSENSITIVE];
- QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
- QColor textColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
- QColor disabledTextColor(gdkDisabledText.red>>8, gdkDisabledText.green>>8, gdkDisabledText.blue>>8);
- pal.setBrush(QPalette::Window, bgColor);
- pal.setBrush(QPalette::Button, bgColor);
- pal.setBrush(QPalette::All, QPalette::WindowText, textColor);
- pal.setBrush(QPalette::Disabled, QPalette::WindowText, disabledTextColor);
- pal.setBrush(QPalette::All, QPalette::ButtonText, textColor);
- pal.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledTextColor);
- return pal;
-}
-
-
-void QGtkStyleUpdateScheduler::updateTheme()
-{
- static QString oldTheme(QLS("qt_not_set"));
- QPixmapCache::clear();
-
- QFont font = QGtkStylePrivate::getThemeFont();
- if (QApplication::font() != font)
- qApp->setFont(font);
-
- if (oldTheme != QGtkStylePrivate::getThemeName()) {
- oldTheme = QGtkStylePrivate::getThemeName();
- QPalette newPalette = qApp->style()->standardPalette();
- QApplicationPrivate::setSystemPalette(newPalette);
- QApplication::setPalette(newPalette);
- if (!QGtkStylePrivate::instances.isEmpty()) {
- QGtkStylePrivate::instances.last()->initGtkWidgets();
- QGtkStylePrivate::instances.last()->applyCustomPaletteHash();
- }
- QList<QWidget*> widgets = QApplication::allWidgets();
- // Notify all widgets that size metrics might have changed
- foreach (QWidget *widget, widgets) {
- QEvent e(QEvent::StyleChange);
- QApplication::sendEvent(widget, &e);
- }
- }
- QIconLoader::instance()->updateSystemTheme();
-}
-
-void QGtkStylePrivate::addWidget(GtkWidget *widget)
-{
- if (widget) {
- setupGtkWidget(widget);
- addAllSubWidgets(widget);
- }
-}
-
-
-// Fetch the application font from the pango font description
-// contained in the theme.
-QFont QGtkStylePrivate::getThemeFont()
-{
- QFont font;
- GtkStyle *style = gtkStyle();
- if (style && qApp->desktopSettingsAware())
- {
- PangoFontDescription *gtk_font = style->font_desc;
- font.setPointSizeF((float)(pango_font_description_get_size(gtk_font))/PANGO_SCALE);
-
- QString family = QString::fromLatin1(pango_font_description_get_family(gtk_font));
- if (!family.isEmpty())
- font.setFamily(family);
-
- const int weight = pango_font_description_get_weight(gtk_font);
- font.setWeight(QPlatformFontDatabase::weightFromInteger(weight));
-
- PangoStyle fontstyle = pango_font_description_get_style(gtk_font);
- if (fontstyle == PANGO_STYLE_ITALIC)
- font.setStyle(QFont::StyleItalic);
- else if (fontstyle == PANGO_STYLE_OBLIQUE)
- font.setStyle(QFont::StyleOblique);
- else
- font.setStyle(QFont::StyleNormal);
- }
- return font;
-}
-
-QIcon QGtkStylePrivate::getFilesystemIcon(const QFileInfo &info)
-{
- QIcon icon;
- if (isThemeAvailable() && gnome_vfs_init && gnome_icon_lookup_sync) {
- gnome_vfs_init();
- GtkIconTheme *theme = gtk_icon_theme_get_default();
- QByteArray fileurl = QUrl::fromLocalFile(info.absoluteFilePath()).toEncoded();
- char * icon_name = gnome_icon_lookup_sync(theme,
- NULL,
- fileurl.data(),
- NULL,
- GNOME_ICON_LOOKUP_FLAGS_NONE,
- NULL);
- QString iconName = QString::fromUtf8(icon_name);
- g_free(icon_name);
- if (iconName.startsWith(QLatin1Char('/')))
- return QIcon(iconName);
- return QIcon::fromTheme(iconName);
- }
- return icon;
-}
-
-bool operator==(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2)
-{
- return l1.size() == l2.size() || qstrcmp(l1.data(), l2.data()) == 0;
-}
-
-// copied from qHash.cpp
-uint qHash(const QHashableLatin1Literal &key)
-{
- int n = key.size();
- const uchar *p = reinterpret_cast<const uchar *>(key.data());
- uint h = 0;
- uint g;
-
- while (n--) {
- h = (h << 4) + *p++;
- if ((g = (h & 0xf0000000)) != 0)
- h ^= g >> 23;
- h &= ~g;
- }
- return h;
-}
-
-QT_END_NAMESPACE
-
-#endif // !defined(QT_NO_STYLE_GTK)
diff --git a/src/widgets/styles/qgtkstyle_p.h b/src/widgets/styles/qgtkstyle_p.h
deleted file mode 100644
index 3dcd7bf6ef..0000000000
--- a/src/widgets/styles/qgtkstyle_p.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGTKSTYLE_P_H
-#define QGTKSTYLE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <private/qwindowsstyle_p.h>
-#include <QtGui/QPalette>
-#include <QtGui/QFont>
-#include <QtWidgets/QFileDialog>
-
-QT_BEGIN_NAMESPACE
-
-
-#if !defined(QT_NO_STYLE_GTK)
-
-class QPainterPath;
-class QGtkStylePrivate;
-
-class QGtkStyle : public QCommonStyle
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QGtkStyle)
-
-public:
- QGtkStyle();
- QGtkStyle(QGtkStylePrivate &dd);
-
- ~QGtkStyle();
-
- QPalette standardPalette() const Q_DECL_OVERRIDE;
-
- void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
- QPainter *painter, const QWidget *widget) const Q_DECL_OVERRIDE;
- void drawControl(ControlElement control, const QStyleOption *option,
- QPainter *painter, const QWidget *widget) const Q_DECL_OVERRIDE;
- void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
- QPainter *painter, const QWidget *widget) const Q_DECL_OVERRIDE;
- void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
- const QPixmap &pixmap) const Q_DECL_OVERRIDE;
- void drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal,
- bool enabled, const QString& text, QPalette::ColorRole textRole) const Q_DECL_OVERRIDE;
-
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0,
- const QWidget *widget = 0) const Q_DECL_OVERRIDE;
- int styleHint(StyleHint hint, const QStyleOption *option,
- const QWidget *widget, QStyleHintReturn *returnData) const Q_DECL_OVERRIDE;
-
- QStyle::SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
- const QPoint &pt, const QWidget *w) const Q_DECL_OVERRIDE;
-
- QRect subControlRect(ComplexControl control, const QStyleOptionComplex *option,
- SubControl subControl, const QWidget *widget) const Q_DECL_OVERRIDE;
- QRect subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *w) const Q_DECL_OVERRIDE;
- QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const Q_DECL_OVERRIDE;
-
-
- QSize sizeFromContents(ContentsType type, const QStyleOption *option,
- const QSize &size, const QWidget *widget) const Q_DECL_OVERRIDE;
- QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0,
- const QWidget *widget = 0) const Q_DECL_OVERRIDE;
- QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *option,
- const QWidget *widget) const Q_DECL_OVERRIDE;
- QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
- const QStyleOption *opt) const Q_DECL_OVERRIDE;
-
- void polish(QWidget *widget) Q_DECL_OVERRIDE;
- void polish(QApplication *app) Q_DECL_OVERRIDE;
- void polish(QPalette &palette) Q_DECL_OVERRIDE;
-
- void unpolish(QWidget *widget) Q_DECL_OVERRIDE;
- void unpolish(QApplication *app) Q_DECL_OVERRIDE;
-
- static bool getGConfBool(const QString &key, bool fallback = 0);
- static QString getGConfString(const QString &key, const QString &fallback = QString());
-};
-
-#endif //!defined(QT_NO_STYLE_QGTK)
-
-QT_END_NAMESPACE
-
-#endif //QGTKSTYLE_P_H
diff --git a/src/widgets/styles/qgtkstyle_p_p.h b/src/widgets/styles/qgtkstyle_p_p.h
deleted file mode 100644
index 4cb03ed833..0000000000
--- a/src/widgets/styles/qgtkstyle_p_p.h
+++ /dev/null
@@ -1,449 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGTKSTYLE_P_P_H
-#define QGTKSTYLE_P_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qglobal.h>
-#if !defined(QT_NO_STYLE_GTK)
-
-#include <QtCore/qstring.h>
-#include <QtCore/qstringbuilder.h>
-#include <QtCore/qcoreapplication.h>
-
-#include <QtWidgets/QFileDialog>
-
-#include <private/qgtkstyle_p.h>
-#include <private/qcommonstyle_p.h>
-#include <private/qgtkglobal_p.h>
-
-#define Q_GTK_IS_WIDGET(widget) widget && G_TYPE_CHECK_INSTANCE_TYPE ((widget), QGtkStylePrivate::gtk_widget_get_type())
-
-QT_BEGIN_NAMESPACE
-
-class QHashableLatin1Literal
-{
-public:
- int size() const { return m_size; }
- const char *data() const { return m_data; }
-
-#ifdef __SUNPRO_CC
- QHashableLatin1Literal(const char* str)
- : m_size(strlen(str)), m_data(str) {}
-#else
- template <int N>
- QHashableLatin1Literal(const char (&str)[N])
- : m_size(N - 1), m_data(str) {}
-#endif
-
- QHashableLatin1Literal(const QHashableLatin1Literal &other)
- : m_size(other.m_size), m_data(other.m_data)
- {}
-
- QHashableLatin1Literal &operator=(const QHashableLatin1Literal &other)
- {
- if (this == &other)
- return *this;
- *const_cast<int *>(&m_size) = other.m_size;
- *const_cast<char **>(&m_data) = const_cast<char *>(other.m_data);
- return *this;
- }
-
- QString toString() const { return QString::fromLatin1(m_data, m_size); }
-
- static QHashableLatin1Literal fromData(const char *str)
- {
- return QHashableLatin1Literal(str, qstrlen(str));
- }
-
-private:
- QHashableLatin1Literal(const char *str, int length)
- : m_size(length), m_data(str)
- {}
-
- const int m_size;
- const char *m_data;
-};
-
-bool operator==(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2);
-inline bool operator!=(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2) { return !operator==(l1, l2); }
-uint qHash(const QHashableLatin1Literal &key);
-
-QT_END_NAMESPACE
-
-class GConf;
-class GConfClient;
-typedef struct _XDisplay Display;
-
-typedef GConfClient* (*Ptr_gconf_client_get_default)();
-typedef char* (*Ptr_gconf_client_get_string)(GConfClient*, const char*, GError **);
-typedef bool (*Ptr_gconf_client_get_bool)(GConfClient*, const char*, GError **);
-
-typedef void (*Ptr_gtk_init)(int *, char ***);
-typedef GtkWidget* (*Ptr_gtk_window_new) (GtkWindowType);
-typedef GtkStyle* (*Ptr_gtk_style_attach)(GtkStyle *, GdkWindow *);
-typedef void (*Ptr_gtk_widget_destroy) (GtkWidget *);
-typedef void (*Ptr_gtk_widget_realize) (GtkWidget *);
-typedef void (*Ptr_gtk_widget_set_default_direction) (GtkTextDirection);
-typedef void (*Ptr_gtk_widget_modify_color)(GtkWidget *widget, GtkStateType state, const GdkColor *color);
-typedef GtkWidget* (*Ptr_gtk_arrow_new)(GtkArrowType, GtkShadowType);
-typedef GtkWidget* (*Ptr_gtk_menu_item_new_with_label)(const gchar *);
-typedef GtkWidget* (*Ptr_gtk_separator_menu_item_new)(void);
-typedef GtkWidget* (*Ptr_gtk_check_menu_item_new_with_label)(const gchar *);
-typedef GtkWidget* (*Ptr_gtk_menu_bar_new)(void);
-typedef GtkWidget* (*Ptr_gtk_menu_new)(void);
-typedef GtkWidget* (*Ptr_gtk_combo_box_new)(void);
-typedef GtkWidget* (*Ptr_gtk_combo_box_entry_new)(void);
-typedef GtkWidget* (*Ptr_gtk_toolbar_new)(void);
-typedef GtkWidget* (*Ptr_gtk_spin_button_new)(GtkAdjustment*, double, int);
-typedef GtkWidget* (*Ptr_gtk_button_new)(void);
-typedef GtkWidget* (*Ptr_gtk_tool_button_new)(GtkWidget *, const gchar *);
-typedef GtkWidget* (*Ptr_gtk_hbutton_box_new)(void);
-typedef GtkWidget* (*Ptr_gtk_check_button_new)(void);
-typedef GtkWidget* (*Ptr_gtk_radio_button_new)(GSList *);
-typedef GtkWidget* (*Ptr_gtk_notebook_new)(void);
-typedef GtkWidget* (*Ptr_gtk_progress_bar_new)(void);
-typedef GtkWidget* (*Ptr_gtk_hscale_new)(GtkAdjustment*);
-typedef GtkWidget* (*Ptr_gtk_vscale_new)(GtkAdjustment*);
-typedef GtkWidget* (*Ptr_gtk_hscrollbar_new)(GtkAdjustment*);
-typedef GtkWidget* (*Ptr_gtk_vscrollbar_new)(GtkAdjustment*);
-typedef GtkWidget* (*Ptr_gtk_scrolled_window_new)(GtkAdjustment*, GtkAdjustment*);
-typedef gchar* (*Ptr_gtk_check_version)(guint, guint, guint);
-typedef GtkToolItem* (*Ptr_gtk_separator_tool_item_new) (void);
-typedef GtkWidget* (*Ptr_gtk_entry_new)(void);
-typedef GtkWidget* (*Ptr_gtk_tree_view_new)(void);
-typedef GtkTreeViewColumn* (*Ptr_gtk_tree_view_get_column)(GtkTreeView *, gint);
-typedef GtkWidget* (*Ptr_gtk_frame_new)(const gchar *);
-typedef GtkWidget* (*Ptr_gtk_expander_new)(const gchar*);
-typedef GtkWidget* (*Ptr_gtk_statusbar_new)(void);
-typedef GtkSettings* (*Ptr_gtk_settings_get_default)(void);
-typedef GtkAdjustment* (*Ptr_gtk_range_get_adjustment)(GtkRange *);
-typedef void (*Ptr_gtk_range_set_adjustment)(GtkRange *, GtkAdjustment *);
-typedef void (*Ptr_gtk_range_set_inverted)(GtkRange*, bool);
-typedef void (*Ptr_gtk_container_add)(GtkContainer *container, GtkWidget *widget);
-typedef GtkIconSet* (*Ptr_gtk_icon_factory_lookup_default) (const gchar*);
-typedef GtkIconTheme* (*Ptr_gtk_icon_theme_get_default) (void);
-typedef GtkStyle* (*Ptr_gtk_widget_get_style)(GtkWidget *);
-typedef void (*Ptr_gtk_widget_style_get)(GtkWidget *, const gchar *first_property_name, ...);
-typedef GtkTreeViewColumn* (*Ptr_gtk_tree_view_column_new)(void);
-typedef GtkWidget* (*Ptr_gtk_fixed_new)(void);
-typedef GdkPixbuf* (*Ptr_gtk_icon_set_render_icon)(GtkIconSet *, GtkStyle *, GtkTextDirection, GtkStateType, GtkIconSize, GtkWidget *,const char *);
-typedef void (*Ptr_gtk_tree_view_append_column) (GtkTreeView*, GtkTreeViewColumn*);
-typedef void (*Ptr_gtk_adjustment_configure) (GtkAdjustment *, double, double, double, double, double, double);
-typedef GtkAdjustment* (*Ptr_gtk_adjustment_new) (double, double, double, double, double, double);
-typedef void (*Ptr_gtk_menu_item_set_submenu) (GtkMenuItem *, GtkWidget *);
-typedef void (*Ptr_gtk_container_forall) (GtkContainer *, GtkCallback, gpointer);
-typedef void (*Ptr_gtk_widget_size_allocate) (GtkWidget *, GtkAllocation*);
-typedef void (*Ptr_gtk_widget_size_request) (GtkWidget *widget, GtkRequisition *requisition);
-typedef void (*Ptr_gtk_widget_set_direction) (GtkWidget *, GtkTextDirection);
-typedef void (*Ptr_gtk_widget_path) (GtkWidget *, guint *, gchar **, gchar**);
-
-typedef void (*Ptr_gtk_toolbar_insert) (GtkToolbar *toolbar, GtkToolItem *item, int pos);
-typedef void (*Ptr_gtk_menu_shell_append)(GtkMenuShell *, GtkWidget *);
-typedef GType (*Ptr_gtk_container_get_type) (void);
-typedef GType (*Ptr_gtk_window_get_type) (void);
-typedef GType (*Ptr_gtk_widget_get_type) (void);
-typedef GtkWidget* (*Ptr_gtk_widget_get_parent) (GtkWidget *);
-typedef gboolean (*Ptr_gtk_widget_is_toplevel) (GtkWidget *);
-typedef GtkWidget* (*Ptr_gtk_widget_get_toplevel) (GtkWidget *);
-typedef GtkStyle* (*Ptr_gtk_rc_get_style_by_paths) (GtkSettings *, const char *, const char *, GType);
-typedef gint (*Ptr_pango_font_description_get_size) (const PangoFontDescription *);
-typedef PangoWeight (*Ptr_pango_font_description_get_weight) (const PangoFontDescription *);
-typedef const char* (*Ptr_pango_font_description_get_family) (const PangoFontDescription *);
-typedef PangoStyle (*Ptr_pango_font_description_get_style) (const PangoFontDescription *desc);
-typedef void (*Ptr_gtk_border_free)(GtkBorder *);
-typedef void (*Ptr_gtk_widget_get_allocation) (GtkWidget*, GtkAllocation*);
-typedef void (*Ptr_gtk_widget_set_allocation) (GtkWidget*, const GtkAllocation*);
-
-typedef void (*Ptr_gtk_widget_set_can_default) (GtkWidget*, gboolean);
-typedef void (*Ptr_gtk_window_set_default) (GtkWindow*, GtkWidget*);
-
-typedef GdkEvent* (*Ptr_gdk_event_new) (GdkEventType);
-typedef void (*Ptr_gdk_event_free) (GdkEvent*);
-typedef void (*Ptr_gtk_widget_send_focus_change) (GtkWidget*, GdkEvent*);
-
-typedef guchar* (*Ptr_gdk_pixbuf_get_pixels) (const GdkPixbuf *pixbuf);
-typedef int (*Ptr_gdk_pixbuf_get_width) (const GdkPixbuf *pixbuf);
-typedef void (*Ptr_gdk_color_free) (const GdkColor *);
-typedef int (*Ptr_gdk_pixbuf_get_height) (const GdkPixbuf *pixbuf);
-typedef GdkPixbuf* (*Ptr_gdk_pixbuf_new) (GdkColorspace colorspace, gboolean has_alpha,
- int bits_per_sample, int width, int height);
-typedef void (*Ptr_gdk_pixbuf_unref)(GdkPixbuf *);
-typedef void (*Ptr_gdk_x11_window_set_user_time) (GdkWindow *window, guint32);
-typedef XID (*Ptr_gdk_x11_drawable_get_xid) (GdkDrawable *);
-typedef Display* (*Ptr_gdk_x11_drawable_get_xdisplay) ( GdkDrawable *);
-
-
-QT_BEGIN_NAMESPACE
-
-class QGtkPainter;
-class QGtkStylePrivate;
-
-class QGtkStyleFilter : public QObject
-{
-public:
- QGtkStyleFilter(QGtkStylePrivate* sp)
- : stylePrivate(sp)
- {}
-private:
- QGtkStylePrivate* stylePrivate;
- bool eventFilter(QObject *obj, QEvent *e) Q_DECL_OVERRIDE;
-};
-
-typedef enum {
- GNOME_ICON_LOOKUP_FLAGS_NONE = 0,
- GNOME_ICON_LOOKUP_FLAGS_EMBEDDING_TEXT = 1<<0,
- GNOME_ICON_LOOKUP_FLAGS_SHOW_SMALL_IMAGES_AS_THEMSELVES = 1<<1,
- GNOME_ICON_LOOKUP_FLAGS_ALLOW_SVG_AS_THEMSELVES = 1<<2
-} GnomeIconLookupFlags;
-
-typedef enum {
- GNOME_ICON_LOOKUP_RESULT_FLAGS_NONE = 0,
- GNOME_ICON_LOOKUP_RESULT_FLAGS_THUMBNAIL = 1<<0
-} GnomeIconLookupResultFlags;
-
-struct GnomeThumbnailFactory;
-typedef gboolean (*Ptr_gnome_vfs_init) (void);
-typedef char* (*Ptr_gnome_icon_lookup_sync) (
- GtkIconTheme *icon_theme,
- GnomeThumbnailFactory *,
- const char *file_uri,
- const char *custom_icon,
- GnomeIconLookupFlags flags,
- GnomeIconLookupResultFlags *result);
-
-class QGtkStylePrivate : public QCommonStylePrivate
-{
- Q_DECLARE_PUBLIC(QGtkStyle)
-public:
- QGtkStylePrivate();
- ~QGtkStylePrivate();
-
- QGtkStyleFilter filter;
-
- static QGtkPainter* gtkPainter(QPainter *painter = 0);
- static GtkWidget* gtkWidget(const QHashableLatin1Literal &path);
- static GtkStyle* gtkStyle(const QHashableLatin1Literal &path = QHashableLatin1Literal("GtkWindow"));
- static void gtkWidgetSetFocus(GtkWidget *widget, bool focus);
-
- virtual void resolveGtk() const;
- virtual void initGtkMenu() const;
- virtual void initGtkTreeview() const;
- virtual void initGtkWidgets() const;
-
- static void cleanupGtkWidgets();
-
- static bool isKDE4Session();
- void applyCustomPaletteHash();
- static QFont getThemeFont();
- static bool isThemeAvailable() { return gtkStyle() != 0; }
-
- static bool getGConfBool(const QString &key, bool fallback = 0);
- static QString getGConfString(const QString &key, const QString &fallback = QString());
-
- static QString getThemeName();
- virtual int getSpinboxArrowSize() const;
-
- static QIcon getFilesystemIcon(const QFileInfo &);
-
- static Ptr_gtk_container_forall gtk_container_forall;
- static Ptr_gtk_init gtk_init;
- static Ptr_gtk_style_attach gtk_style_attach;
- static Ptr_gtk_window_new gtk_window_new;
- static Ptr_gtk_widget_destroy gtk_widget_destroy;
- static Ptr_gtk_widget_realize gtk_widget_realize;
- static Ptr_gtk_widget_set_default_direction gtk_widget_set_default_direction;
- static Ptr_gtk_widget_modify_color gtk_widget_modify_fg;
- static Ptr_gtk_widget_modify_color gtk_widget_modify_bg;
- static Ptr_gtk_menu_item_new_with_label gtk_menu_item_new_with_label;
- static Ptr_gtk_arrow_new gtk_arrow_new;
- static Ptr_gtk_check_menu_item_new_with_label gtk_check_menu_item_new_with_label;
- static Ptr_gtk_menu_bar_new gtk_menu_bar_new;
- static Ptr_gtk_menu_new gtk_menu_new;
- static Ptr_gtk_expander_new gtk_expander_new;
- static Ptr_gtk_button_new gtk_button_new;
- static Ptr_gtk_tool_button_new gtk_tool_button_new;
- static Ptr_gtk_hbutton_box_new gtk_hbutton_box_new;
- static Ptr_gtk_check_button_new gtk_check_button_new;
- static Ptr_gtk_radio_button_new gtk_radio_button_new;
- static Ptr_gtk_spin_button_new gtk_spin_button_new;
- static Ptr_gtk_separator_tool_item_new gtk_separator_tool_item_new;
- static Ptr_gtk_toolbar_insert gtk_toolbar_insert;
- static Ptr_gtk_frame_new gtk_frame_new;
- static Ptr_gtk_statusbar_new gtk_statusbar_new;
- static Ptr_gtk_entry_new gtk_entry_new;
- static Ptr_gtk_hscale_new gtk_hscale_new;
- static Ptr_gtk_vscale_new gtk_vscale_new;
- static Ptr_gtk_hscrollbar_new gtk_hscrollbar_new;
- static Ptr_gtk_vscrollbar_new gtk_vscrollbar_new;
- static Ptr_gtk_scrolled_window_new gtk_scrolled_window_new;
- static Ptr_gtk_notebook_new gtk_notebook_new;
- static Ptr_gtk_toolbar_new gtk_toolbar_new;
- static Ptr_gtk_tree_view_new gtk_tree_view_new;
- static Ptr_gtk_tree_view_get_column gtk_tree_view_get_column;
- static Ptr_gtk_combo_box_new gtk_combo_box_new;
- static Ptr_gtk_combo_box_entry_new gtk_combo_box_entry_new;
- static Ptr_gtk_progress_bar_new gtk_progress_bar_new;
- static Ptr_gtk_container_add gtk_container_add;
- static Ptr_gtk_menu_shell_append gtk_menu_shell_append;
- static Ptr_gtk_range_get_adjustment gtk_range_get_adjustment;
- static Ptr_gtk_range_set_adjustment gtk_range_set_adjustment;
- static Ptr_gtk_range_set_inverted gtk_range_set_inverted;
- static Ptr_gtk_icon_factory_lookup_default gtk_icon_factory_lookup_default;
- static Ptr_gtk_icon_theme_get_default gtk_icon_theme_get_default;
- static Ptr_gtk_widget_get_style gtk_widget_get_style;
- static Ptr_gtk_widget_style_get gtk_widget_style_get;
- static Ptr_gtk_icon_set_render_icon gtk_icon_set_render_icon;
- static Ptr_gtk_fixed_new gtk_fixed_new;
- static Ptr_gtk_tree_view_column_new gtk_tree_view_column_new;
- static Ptr_gtk_tree_view_append_column gtk_tree_view_append_column;
- static Ptr_gtk_adjustment_configure gtk_adjustment_configure;
- static Ptr_gtk_adjustment_new gtk_adjustment_new;
- static Ptr_gtk_menu_item_set_submenu gtk_menu_item_set_submenu;
- static Ptr_gtk_settings_get_default gtk_settings_get_default;
- static Ptr_gtk_separator_menu_item_new gtk_separator_menu_item_new;
- static Ptr_gtk_widget_size_allocate gtk_widget_size_allocate;
- static Ptr_gtk_widget_size_request gtk_widget_size_request;
- static Ptr_gtk_widget_set_direction gtk_widget_set_direction;
- static Ptr_gtk_widget_path gtk_widget_path;
- static Ptr_gtk_container_get_type gtk_container_get_type;
- static Ptr_gtk_window_get_type gtk_window_get_type;
- static Ptr_gtk_widget_get_type gtk_widget_get_type;
- static Ptr_gtk_widget_get_parent gtk_widget_get_parent;
- static Ptr_gtk_widget_is_toplevel gtk_widget_is_toplevel;
- static Ptr_gtk_widget_get_toplevel gtk_widget_get_toplevel;
- static Ptr_gtk_rc_get_style_by_paths gtk_rc_get_style_by_paths;
- static Ptr_gtk_check_version gtk_check_version;
- static Ptr_gtk_border_free gtk_border_free;
- static Ptr_gtk_widget_get_allocation gtk_widget_get_allocation;
- static Ptr_gtk_widget_set_allocation gtk_widget_set_allocation;
- static Ptr_gtk_widget_set_can_default gtk_widget_set_can_default;
- static Ptr_gtk_window_set_default gtk_window_set_default;
-
- static Ptr_gdk_event_new gdk_event_new;
- static Ptr_gdk_event_free gdk_event_free;
- static Ptr_gtk_widget_send_focus_change gtk_widget_send_focus_change;
-
- static Ptr_pango_font_description_get_size pango_font_description_get_size;
- static Ptr_pango_font_description_get_weight pango_font_description_get_weight;
- static Ptr_pango_font_description_get_family pango_font_description_get_family;
- static Ptr_pango_font_description_get_style pango_font_description_get_style;
-
- static Ptr_gdk_pixbuf_get_pixels gdk_pixbuf_get_pixels;
- static Ptr_gdk_pixbuf_get_width gdk_pixbuf_get_width;
- static Ptr_gdk_pixbuf_get_height gdk_pixbuf_get_height;
- static Ptr_gdk_pixbuf_new gdk_pixbuf_new;
- static Ptr_gdk_pixbuf_unref gdk_pixbuf_unref;
- static Ptr_gdk_color_free gdk_color_free;
- static Ptr_gdk_x11_window_set_user_time gdk_x11_window_set_user_time;
- static Ptr_gdk_x11_drawable_get_xid gdk_x11_drawable_get_xid;
- static Ptr_gdk_x11_drawable_get_xdisplay gdk_x11_drawable_get_xdisplay;
-
- static Ptr_gconf_client_get_default gconf_client_get_default;
- static Ptr_gconf_client_get_string gconf_client_get_string;
- static Ptr_gconf_client_get_bool gconf_client_get_bool;
-
- static Ptr_gnome_icon_lookup_sync gnome_icon_lookup_sync;
- static Ptr_gnome_vfs_init gnome_vfs_init;
-
- virtual QPalette gtkWidgetPalette(const QHashableLatin1Literal &gtkWidgetName) const;
-
-protected:
- typedef QHash<QHashableLatin1Literal, GtkWidget*> WidgetMap;
-
- static inline void destroyWidgetMap()
- {
- cleanupGtkWidgets();
- delete widgetMap;
- widgetMap = 0;
- }
-
- static inline WidgetMap *gtkWidgetMap()
- {
- if (!widgetMap) {
- widgetMap = new WidgetMap();
- qAddPostRoutine(destroyWidgetMap);
- }
- return widgetMap;
- }
-
- static QStringList extract_filter(const QString &rawFilter);
-
- virtual GtkWidget* getTextColorWidget() const;
- static void setupGtkWidget(GtkWidget* widget);
- static void addWidgetToMap(GtkWidget* widget);
- static void addAllSubWidgets(GtkWidget *widget, gpointer v = 0);
- static void addWidget(GtkWidget *widget);
- static void removeWidgetFromMap(const QHashableLatin1Literal &path);
-
- virtual void init();
-
- enum {
- menuItemFrame = 2, // menu item frame width
- menuItemHMargin = 3, // menu item hor text margin
- menuArrowHMargin = 6, // menu arrow horizontal margin
- menuItemVMargin = 2, // menu item ver text margin
- menuRightBorder = 15, // right border on menus
- menuCheckMarkWidth = 12 // checkmarks width on menus
- };
-
-private:
- static QList<QGtkStylePrivate *> instances;
- static WidgetMap *widgetMap;
- friend class QGtkStyleUpdateScheduler;
-};
-
-// 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
-#endif // QGTKSTYLE_P_P_H
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index e8da137654..b5e3596de9 100644
--- a/src/widgets/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
@@ -36,7 +36,7 @@
.../doc/src/qstyles.qdoc.
*/
-#include <Cocoa/Cocoa.h>
+#include <AppKit/AppKit.h>
#include "qmacstyle_mac_p.h"
#include "qmacstyle_mac_p_p.h"
@@ -1105,6 +1105,17 @@ static void qt_drawFocusRingOnPath(CGContextRef cg, NSBezierPath *focusRingPath)
CGContextRestoreGState(cg);
}
+QAquaWidgetSize QMacStylePrivate::effectiveAquaSizeConstrain(const QStyleOption *option,
+ const QWidget *widg,
+ QStyle::ContentsType ct,
+ QSize szHint, QSize *insz) const
+{
+ QAquaWidgetSize sz = aquaSizeConstrain(option, widg, ct, szHint, insz);
+ if (sz == QAquaSizeUnknown)
+ return QAquaSizeLarge;
+ return sz;
+}
+
QAquaWidgetSize QMacStylePrivate::aquaSizeConstrain(const QStyleOption *option, const QWidget *widg,
QStyle::ContentsType ct, QSize szHint, QSize *insz) const
{
@@ -2470,32 +2481,9 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
ret = 0;
break;
case PM_TitleBarHeight:
- if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
- HIThemeWindowDrawInfo wdi;
- wdi.version = qt_mac_hitheme_version;
- wdi.state = kThemeStateActive;
- wdi.windowType = QtWinType;
- if (tb->titleBarState)
- wdi.attributes = kThemeWindowHasFullZoom | kThemeWindowHasCloseBox
- | kThemeWindowHasCollapseBox;
- else if (tb->titleBarFlags & Qt::WindowSystemMenuHint)
- wdi.attributes = kThemeWindowHasCloseBox;
- else
- wdi.attributes = 0;
- wdi.titleHeight = tb->rect.height();
- wdi.titleWidth = tb->rect.width();
- QCFType<HIShapeRef> region;
- HIRect hirect = qt_hirectForQRect(tb->rect);
- if (hirect.size.width <= 0)
- hirect.size.width = 100;
- if (hirect.size.height <= 0)
- hirect.size.height = 30;
-
- HIThemeGetWindowShape(&hirect, &wdi, kWindowTitleBarRgn, &region);
- HIRect rect;
- ptrHIShapeGetBounds(region, &rect);
- ret = int(rect.size.height);
- }
+ // Always use NSTitledWindowMask since we never need any other type of window here
+ ret = int([NSWindow frameRectForContentRect:NSZeroRect
+ styleMask:NSTitledWindowMask].size.height);
break;
case PM_TabBarTabVSpace:
ret = 4;
@@ -2525,29 +2513,10 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
}
break;
case PM_ScrollBarExtent: {
- if ([NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay) {
- switch (d->aquaSizeConstrain(opt, widget)) {
- case QAquaSizeUnknown:
- case QAquaSizeLarge:
- ret = QSysInfo::macVersion() >= QSysInfo::MV_10_8 ? 16 : 9;
- break;
- case QAquaSizeMini:
- case QAquaSizeSmall:
- ret = QSysInfo::macVersion() >= QSysInfo::MV_10_8 ? 14 : 7;
- break;
- }
- break;
- }
- switch (d->aquaSizeConstrain(opt, widget)) {
- case QAquaSizeUnknown:
- case QAquaSizeLarge:
- GetThemeMetric(kThemeMetricScrollBarWidth, &ret);
- break;
- case QAquaSizeMini:
- case QAquaSizeSmall:
- GetThemeMetric(kThemeMetricSmallScrollBarWidth, &ret);
- break;
- }
+ const QAquaWidgetSize size = d->effectiveAquaSizeConstrain(opt, widget);
+ ret = static_cast<SInt32>([NSScroller
+ scrollerWidthForControlSize:static_cast<NSControlSize>(size)
+ scrollerStyle:[NSScroller preferredScrollerStyle]]);
break; }
case PM_IndicatorHeight: {
switch (d->aquaSizeConstrain(opt, widget)) {
diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h
index 33818568ec..8e138ea887 100644
--- a/src/widgets/styles/qmacstyle_mac_p_p.h
+++ b/src/widgets/styles/qmacstyle_mac_p_p.h
@@ -172,6 +172,9 @@ public:
QAquaWidgetSize aquaSizeConstrain(const QStyleOption *option, const QWidget *widg,
QStyle::ContentsType ct = QStyle::CT_CustomBase,
QSize szHint=QSize(-1, -1), QSize *insz = 0) const;
+ QAquaWidgetSize effectiveAquaSizeConstrain(const QStyleOption *option, const QWidget *widg,
+ QStyle::ContentsType ct = QStyle::CT_CustomBase,
+ QSize szHint=QSize(-1, -1), QSize *insz = 0) const;
void getSliderInfo(QStyle::ComplexControl cc, const QStyleOptionSlider *slider,
HIThemeTrackDrawInfo *tdi, const QWidget *needToRemoveMe) const;
inline int animateSpeed(Animates) const { return 33; }
diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h
index 1e9d15c993..43addb5eb7 100644
--- a/src/widgets/styles/qstyle.h
+++ b/src/widgets/styles/qstyle.h
@@ -134,7 +134,7 @@ public:
PE_FrameGroupBox,
PE_FrameLineEdit,
PE_FrameMenu,
- PE_FrameStatusBar, // obsolete
+ PE_FrameStatusBar, // ### Qt 6: remove
PE_FrameStatusBarItem = PE_FrameStatusBar,
PE_FrameTabWidget,
PE_FrameWindow,
@@ -155,7 +155,7 @@ public:
PE_IndicatorArrowUp,
PE_IndicatorBranch,
PE_IndicatorButtonDropDown,
- PE_IndicatorViewItemCheck,
+ PE_IndicatorViewItemCheck, // ### Qt 6: remove
PE_IndicatorItemViewItemCheck = PE_IndicatorViewItemCheck,
PE_IndicatorCheckBox,
PE_IndicatorDockWidgetResizeHandle,
@@ -298,7 +298,7 @@ public:
SE_TabWidgetLeftCorner,
SE_TabWidgetRightCorner,
- SE_ViewItemCheckIndicator,
+ SE_ViewItemCheckIndicator, // ### Qt 6: remove
SE_ItemViewItemCheckIndicator = SE_ViewItemCheckIndicator,
SE_TabBarTearIndicator,
@@ -491,9 +491,9 @@ public:
PM_DialogButtonsButtonHeight,
PM_MdiSubWindowFrameWidth,
- PM_MDIFrameWidth = PM_MdiSubWindowFrameWidth, //obsolete
+ PM_MDIFrameWidth = PM_MdiSubWindowFrameWidth, // ### Qt 6: remove
PM_MdiSubWindowMinimizedWidth,
- PM_MDIMinimizedWidth = PM_MdiSubWindowMinimizedWidth, //obsolete
+ PM_MDIMinimizedWidth = PM_MdiSubWindowMinimizedWidth, // ### Qt 6: remove
PM_HeaderMargin,
PM_HeaderMarkSize,
@@ -511,9 +511,9 @@ public:
PM_SpinBoxSliderHeight,
- PM_DefaultTopLevelMargin,
- PM_DefaultChildMargin,
- PM_DefaultLayoutSpacing,
+ PM_DefaultTopLevelMargin, // ### Qt 6: remove
+ PM_DefaultChildMargin, // ### Qt 6: remove
+ PM_DefaultLayoutSpacing, // ### Qt 6: remove
PM_ToolBarIconSize,
PM_ListViewIconSize,
@@ -631,7 +631,7 @@ public:
SH_ComboBox_Popup,
SH_TitleBar_NoBorder,
SH_Slider_StopMouseOverSlider,
- SH_ScrollBar_StopMouseOverSlider = SH_Slider_StopMouseOverSlider, // obsolete
+ SH_ScrollBar_StopMouseOverSlider = SH_Slider_StopMouseOverSlider, // ### Qt 6: remove
SH_BlinkCursorWhenTextSelected,
SH_RichText_FullWidthSelection,
SH_Menu_Scrollable,
diff --git a/src/widgets/styles/qstylefactory.cpp b/src/widgets/styles/qstylefactory.cpp
index 520e303d93..f651521cbd 100644
--- a/src/widgets/styles/qstylefactory.cpp
+++ b/src/widgets/styles/qstylefactory.cpp
@@ -44,9 +44,6 @@
#include "qandroidstyle_p.h"
#endif
#endif
-#ifndef QT_NO_STYLE_GTK
-#include "qgtkstyle_p.h"
-#endif
#ifndef QT_NO_STYLE_WINDOWSXP
#include "qwindowsxpstyle_p.h"
#endif
@@ -86,7 +83,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
The valid keys can be retrieved using the keys()
function. Typically they include "windows" and "fusion".
- Depending on the platform, "windowsxp", "windowsvista", "gtk"
+ Depending on the platform, "windowsxp", "windowsvista"
and "macintosh" may be available.
Note that keys are case insensitive.
@@ -143,11 +140,6 @@ QStyle *QStyleFactory::create(const QString& key)
ret = new QAndroidStyle;
else
#endif
-#ifndef QT_NO_STYLE_GTK
- if (style == QLatin1String("gtk") || style == QLatin1String("gtk+"))
- ret = new QGtkStyle;
- else
-#endif
#ifndef QT_NO_STYLE_MAC
if (style.startsWith(QLatin1String("macintosh"))) {
ret = new QMacStyle;
@@ -210,10 +202,6 @@ QStringList QStyleFactory::keys()
if (!list.contains(QLatin1String("Android")))
list << QLatin1String("Android");
#endif
-#ifndef QT_NO_STYLE_GTK
- if (!list.contains(QLatin1String("GTK+")))
- list << QLatin1String("GTK+");
-#endif
#ifndef QT_NO_STYLE_FUSION
if (!list.contains(QLatin1String("Fusion")))
list << QLatin1String("Fusion");
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 380b2b3939..c9440efc8c 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -2556,7 +2556,13 @@ void QStyleSheetStyle::setPalette(QWidget *w)
{ PseudoClass_Enabled, QPalette::Inactive }
};
- QPalette p = w->palette();
+ const bool useStyleSheetPropagationInWidgetStyles =
+ QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles);
+
+ QPalette p;
+ if (!useStyleSheetPropagationInWidgetStyles)
+ p = w->palette();
+
QWidget *ew = embeddedWidget(w);
for (int i = 0; i < 3; i++) {
@@ -2573,32 +2579,84 @@ void QStyleSheetStyle::setPalette(QWidget *w)
rule.configurePalette(&p, map[i].group, ew, ew != w);
}
- styleSheetCaches->customPaletteWidgets.insert(w, w->palette());
- w->setPalette(p);
- if (ew != w)
- ew->setPalette(p);
+ if (!useStyleSheetPropagationInWidgetStyles || p.resolve() != 0) {
+ QPalette wp = w->palette();
+ styleSheetCaches->customPaletteWidgets.insert(w, qMakePair(wp, p.resolve()));
+
+ if (useStyleSheetPropagationInWidgetStyles) {
+ p = p.resolve(wp);
+ p.resolve(p.resolve() | wp.resolve());
+ }
+
+ w->setPalette(p);
+ if (ew != w)
+ ew->setPalette(p);
+ }
}
void QStyleSheetStyle::unsetPalette(QWidget *w)
{
+ const bool useStyleSheetPropagationInWidgetStyles =
+ QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles);
+
if (styleSheetCaches->customPaletteWidgets.contains(w)) {
- QPalette p = styleSheetCaches->customPaletteWidgets.value(w);
- w->setPalette(p);
+ QPair<QPalette, uint> p = styleSheetCaches->customPaletteWidgets.value(w);
+ styleSheetCaches->customPaletteWidgets.remove(w);
+
+ QPalette original = p.first;
+
+ if (useStyleSheetPropagationInWidgetStyles) {
+ original.resolve(original.resolve() & p.second);
+
+ QPalette wp = w->palette();
+ wp.resolve(wp.resolve() & ~p.second);
+ wp.resolve(original);
+ wp.resolve(wp.resolve() | original.resolve());
+ original = wp;
+ }
+
+ w->setPalette(original);
QWidget *ew = embeddedWidget(w);
if (ew != w)
- ew->setPalette(p);
- styleSheetCaches->customPaletteWidgets.remove(w);
+ ew->setPalette(original);
}
- QVariant oldFont = w->property("_q_styleSheetWidgetFont");
- if (oldFont.isValid()) {
- w->setFont(qvariant_cast<QFont>(oldFont));
+
+ if (useStyleSheetPropagationInWidgetStyles) {
+ unsetStyleSheetFont(w);
+ QWidget *ew = embeddedWidget(w);
+ if (ew != w)
+ unsetStyleSheetFont(ew);
+ } else {
+ QVariant oldFont = w->property("_q_styleSheetWidgetFont");
+ if (oldFont.isValid()) {
+ w->setFont(qvariant_cast<QFont>(oldFont));
+ }
}
+
if (styleSheetCaches->autoFillDisabledWidgets.contains(w)) {
embeddedWidget(w)->setAutoFillBackground(true);
styleSheetCaches->autoFillDisabledWidgets.remove(w);
}
}
+void QStyleSheetStyle::unsetStyleSheetFont(QWidget *w) const
+{
+ if (styleSheetCaches->customFontWidgets.contains(w)) {
+ QPair<QFont, uint> f = styleSheetCaches->customFontWidgets.value(w);
+ styleSheetCaches->customFontWidgets.remove(w);
+
+ QFont original = f.first;
+ original.resolve(original.resolve() & f.second);
+
+ QFont font = w->font();
+ font.resolve(font.resolve() & ~f.second);
+ font.resolve(original);
+ font.resolve(font.resolve() | original.resolve());
+
+ w->setFont(font);
+ }
+}
+
static void updateObjects(const QList<const QObject *>& objects)
{
if (!styleSheetCaches->styleRulesCache.isEmpty() || !styleSheetCaches->hasStyleRuleCache.isEmpty() || !styleSheetCaches->renderRulesCache.isEmpty()) {
@@ -2658,6 +2716,7 @@ void QStyleSheetStyleCaches::objectDestroyed(QObject *o)
hasStyleRuleCache.remove(o);
renderRulesCache.remove(o);
customPaletteWidgets.remove((const QWidget *)o);
+ customFontWidgets.remove(static_cast<QWidget *>(o));
styleSheetCache.remove(o);
autoFillDisabledWidgets.remove((const QWidget *)o);
}
@@ -5846,24 +5905,42 @@ void QStyleSheetStyle::updateStyleSheetFont(QWidget* w) const
// we should never override it.
if (w->objectName() == QLatin1String("qt_fontDialog_sampleEdit"))
return;
+
QWidget *container = containerWidget(w);
QRenderRule rule = renderRule(container, PseudoElement_None,
PseudoClass_Active | PseudoClass_Enabled | extendedPseudoClass(container));
- QFont font = rule.font.resolve(w->font());
- if ((!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))
- && isNaturalChild(w) && qobject_cast<QWidget *>(w->parent())) {
+ const bool useStyleSheetPropagationInWidgetStyles =
+ QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles);
- font = font.resolve(static_cast<QWidget *>(w->parent())->font());
- }
+ if (useStyleSheetPropagationInWidgetStyles) {
+ unsetStyleSheetFont(w);
- if (w->data->fnt == font)
- return;
+ if (rule.font.resolve()) {
+ QFont wf = w->font();
+ styleSheetCaches->customFontWidgets.insert(w, qMakePair(wf, rule.font.resolve()));
+
+ QFont font = rule.font.resolve(wf);
+ font.resolve(wf.resolve() | rule.font.resolve());
+ w->setFont(font);
+ }
+ } else {
+ QFont font = rule.font.resolve(w->font());
- w->data->fnt = font;
+ if ((!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))
+ && isNaturalChild(w) && qobject_cast<QWidget *>(w->parent())) {
- QEvent e(QEvent::FontChange);
- QApplication::sendEvent(w, &e);
+ font = font.resolve(static_cast<QWidget *>(w->parent())->font());
+ }
+
+ if (w->data->fnt == font)
+ return;
+
+ w->data->fnt = font;
+
+ QEvent e(QEvent::FontChange);
+ QApplication::sendEvent(w, &e);
+ }
}
void QStyleSheetStyle::saveWidgetFont(QWidget* w, const QFont& font) const
diff --git a/src/widgets/styles/qstylesheetstyle_default.cpp b/src/widgets/styles/qstylesheetstyle_default.cpp
index c3d00f1883..a444be006d 100644
--- a/src/widgets/styles/qstylesheetstyle_default.cpp
+++ b/src/widgets/styles/qstylesheetstyle_default.cpp
@@ -149,8 +149,7 @@ StyleSheet QStyleSheetStyle::getDefaultStyleSheet() const
// pixmap based style doesn't support any features
bool styleIsPixmapBased = baseStyle()->inherits("QMacStyle")
- || baseStyle()->inherits("QWindowsXPStyle")
- || baseStyle()->inherits("QGtkStyle");
+ || baseStyle()->inherits("QWindowsXPStyle");
/*QLineEdit {
diff --git a/src/widgets/styles/qstylesheetstyle_p.h b/src/widgets/styles/qstylesheetstyle_p.h
index 9cd8cb889d..dd2a25aed3 100644
--- a/src/widgets/styles/qstylesheetstyle_p.h
+++ b/src/widgets/styles/qstylesheetstyle_p.h
@@ -42,6 +42,7 @@
#include "QtCore/qhash.h"
#include "QtGui/qevent.h"
#include "QtCore/qvector.h"
+#include "QtCore/qset.h"
#include "QtWidgets/qapplication.h"
#include "private/qcssparser_p.h"
#include "QtGui/qbrush.h"
@@ -149,6 +150,7 @@ private:
void unsetPalette(QWidget *);
void setProperties(QWidget *);
void setGeometry(QWidget *);
+ void unsetStyleSheetFont(QWidget *) const;
QVector<QCss::StyleRule> styleRules(const QObject *obj) const;
bool hasStyleRule(const QObject *obj, int part) const;
@@ -178,9 +180,12 @@ public:
QHash<const QObject *, QHash<int, bool> > hasStyleRuleCache;
typedef QHash<int, QHash<quint64, QRenderRule> > QRenderRules;
QHash<const QObject *, QRenderRules> renderRulesCache;
- QHash<const QWidget *, QPalette> customPaletteWidgets; // widgets whose palette we tampered
QHash<const void *, QCss::StyleSheet> styleSheetCache; // parsed style sheets
QSet<const QWidget *> autoFillDisabledWidgets;
+ // widgets whose palettes and fonts we have tampered. stored value pair is
+ // QPair<old widget value, resolve mask of stylesheet value>
+ QHash<const QWidget *, QPair<QPalette, uint> > customPaletteWidgets;
+ QHash<const QWidget *, QPair<QFont, uint> > customFontWidgets;
};
diff --git a/src/widgets/styles/styles.pri b/src/widgets/styles/styles.pri
index 3707090c4c..968429dc1e 100644
--- a/src/widgets/styles/styles.pri
+++ b/src/widgets/styles/styles.pri
@@ -42,13 +42,6 @@ contains( styles, all ) {
!macx:styles -= mac
-contains(QT_CONFIG, gtkstyle) {
- QMAKE_CXXFLAGS += $$QT_CFLAGS_QGTKSTYLE
- LIBS_PRIVATE += $$QT_LIBS_QGTKSTYLE
- styles += gtk
- CONFIG += x11
-}
-
contains( styles, mac ) {
HEADERS += \
styles/qmacstyle_mac_p.h \
@@ -90,19 +83,6 @@ contains( styles, windows ) {
DEFINES += QT_NO_STYLE_WINDOWS
}
-contains( styles, gtk ) {
- HEADERS += styles/qgtkglobal_p.h
- HEADERS += styles/qgtkstyle_p.h
- HEADERS += styles/qgtkpainter_p.h
- HEADERS += styles/qgtk2painter_p.h
- HEADERS += styles/qgtkstyle_p_p.h
- SOURCES += styles/qgtkstyle.cpp
- SOURCES += styles/qgtkpainter.cpp
- SOURCES += styles/qgtk2painter.cpp
- SOURCES += styles/qgtkstyle_p.cpp
-} else {
- DEFINES += QT_NO_STYLE_GTK
-}
contains( styles, fusion ) {
HEADERS += styles/qfusionstyle_p.h
HEADERS += styles/qfusionstyle_p_p.h
diff --git a/src/widgets/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp
index 8eadc42625..4648278910 100644
--- a/src/widgets/util/qflickgesture.cpp
+++ b/src/widgets/util/qflickgesture.cpp
@@ -40,6 +40,7 @@
#include "qgraphicssceneevent.h"
#include "qgraphicsview.h"
#include "qscroller.h"
+#include <QtGui/qtouchdevice.h>
#include "private/qapplication_p.h"
#include "private/qevent_p.h"
#include "private/qflickgesture_p.h"
diff --git a/src/widgets/util/qscroller_mac.mm b/src/widgets/util/qscroller_mac.mm
index 07de07de52..51485973b8 100644
--- a/src/widgets/util/qscroller_mac.mm
+++ b/src/widgets/util/qscroller_mac.mm
@@ -35,7 +35,7 @@
#ifdef Q_DEAD_CODE_FROM_QT4_MAC
-#import <Cocoa/Cocoa.h>
+#import <AppKit/AppKit.h>
#include "qscroller_p.h"
diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp
index 9a69db1bc8..e50b0bd12c 100644
--- a/src/widgets/util/qsystemtrayicon_x11.cpp
+++ b/src/widgets/util/qsystemtrayicon_x11.cpp
@@ -170,7 +170,9 @@ void QSystemTrayIconSys::mousePressEvent(QMouseEvent *ev)
#ifndef QT_NO_CONTEXTMENU
if (ev->button() == Qt::RightButton && q->contextMenu())
q->contextMenu()->popup(globalPos);
-#endif
+#else
+ Q_UNUSED(globalPos)
+#endif // QT_NO_CONTEXTMENU
if (QBalloonTip::isBalloonVisible()) {
emit q->messageClicked();
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index aab28bf18a..2a1742b652 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -1770,7 +1770,9 @@ void QComboBox::setLineEdit(QLineEdit *edit)
delete d->lineEdit;
d->lineEdit = edit;
+#ifndef QT_NO_IM
qt_widget_private(d->lineEdit)->inheritsInputMethodHints = 1;
+#endif
if (d->lineEdit->parent() != this)
d->lineEdit->setParent(this);
connect(d->lineEdit, SIGNAL(returnPressed()), this, SLOT(_q_returnPressed()));
diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h
index 3182a0a3aa..45b601788f 100644
--- a/src/widgets/widgets/qcombobox.h
+++ b/src/widgets/widgets/qcombobox.h
@@ -229,7 +229,9 @@ protected:
#ifndef QT_NO_WHEELEVENT
void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE;
#endif
+#ifndef QT_NO_CONTEXTMENU
void contextMenuEvent(QContextMenuEvent *e) Q_DECL_OVERRIDE;
+#endif // QT_NO_CONTEXTMENU
void inputMethodEvent(QInputMethodEvent *) Q_DECL_OVERRIDE;
void initStyleOption(QStyleOptionComboBox *option) const;
diff --git a/src/widgets/widgets/qgroupbox.cpp b/src/widgets/widgets/qgroupbox.cpp
index 0ff5dc8753..f1ebf91ad7 100644
--- a/src/widgets/widgets/qgroupbox.cpp
+++ b/src/widgets/widgets/qgroupbox.cpp
@@ -707,6 +707,8 @@ void QGroupBox::mousePressEvent(QMouseEvent *event)
if (d->checkable && (d->pressedControl & (QStyle::SC_GroupBoxCheckBox | QStyle::SC_GroupBoxLabel))) {
d->overCheckBox = true;
update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+ } else {
+ event->ignore();
}
}
@@ -723,6 +725,8 @@ void QGroupBox::mouseMoveEvent(QMouseEvent *event)
if (d->checkable && (d->pressedControl == QStyle::SC_GroupBoxCheckBox || d->pressedControl == QStyle::SC_GroupBoxLabel)
&& (d->overCheckBox != oldOverCheckBox))
update(style()->subControlRect(QStyle::CC_GroupBox, &box, QStyle::SC_GroupBoxCheckBox, this));
+
+ event->ignore();
}
/*! \reimp */
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp
index 55e277026c..eeabd5db38 100644
--- a/src/widgets/widgets/qlabel.cpp
+++ b/src/widgets/widgets/qlabel.cpp
@@ -882,13 +882,11 @@ void QLabel::mouseReleaseEvent(QMouseEvent *ev)
d->sendControlEvent(ev);
}
+#ifndef QT_NO_CONTEXTMENU
/*!\reimp
*/
void QLabel::contextMenuEvent(QContextMenuEvent *ev)
{
-#ifdef QT_NO_CONTEXTMENU
- Q_UNUSED(ev);
-#else
Q_D(QLabel);
if (!d->isTextLabel) {
ev->ignore();
@@ -902,8 +900,8 @@ void QLabel::contextMenuEvent(QContextMenuEvent *ev)
ev->accept();
menu->setAttribute(Qt::WA_DeleteOnClose);
menu->popup(ev->globalPos());
-#endif
}
+#endif // QT_NO_CONTEXTMENU
/*!
\reimp
diff --git a/src/widgets/widgets/qlabel.h b/src/widgets/widgets/qlabel.h
index 1a3a68db60..6b6e15e0a8 100644
--- a/src/widgets/widgets/qlabel.h
+++ b/src/widgets/widgets/qlabel.h
@@ -132,7 +132,9 @@ protected:
void mousePressEvent(QMouseEvent *ev) Q_DECL_OVERRIDE;
void mouseMoveEvent(QMouseEvent *ev) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent *ev) Q_DECL_OVERRIDE;
+#ifndef QT_NO_CONTEXTMENU
void contextMenuEvent(QContextMenuEvent *ev) Q_DECL_OVERRIDE;
+#endif // QT_NO_CONTEXTMENU
void focusInEvent(QFocusEvent *ev) Q_DECL_OVERRIDE;
void focusOutEvent(QFocusEvent *ev) Q_DECL_OVERRIDE;
bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE;
diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
index a384e41d1b..7dad6604b9 100644
--- a/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
+++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
@@ -31,7 +31,7 @@
**
****************************************************************************/
-#import <Cocoa/Cocoa.h>
+#import <AppKit/AppKit.h>
#include "qmaccocoaviewcontainer_mac.h"
#include <QtCore/QDebug>
diff --git a/src/widgets/widgets/qmacnativewidget_mac.mm b/src/widgets/widgets/qmacnativewidget_mac.mm
index 46a43c4110..f855777837 100644
--- a/src/widgets/widgets/qmacnativewidget_mac.mm
+++ b/src/widgets/widgets/qmacnativewidget_mac.mm
@@ -31,7 +31,7 @@
**
****************************************************************************/
-#import <Cocoa/Cocoa.h>
+#import <AppKit/AppKit.h>
#include "qmacnativewidget_mac.h"
#include <QtCore/qdebug.h>
diff --git a/src/widgets/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp
index e683c48ad3..1864b42a80 100644
--- a/src/widgets/widgets/qmdiarea.cpp
+++ b/src/widgets/widgets/qmdiarea.cpp
@@ -380,7 +380,7 @@ void IconTiler::rearrange(QList<QWidget *> &widgets, const QRect &domain) const
return;
const int n = widgets.size();
- const int width = widgets.at(0)->width();
+ const int width = qMax(widgets.at(0)->width(), 1);
const int height = widgets.at(0)->height();
const int ncols = qMax(domain.width() / width, 1);
const int nrows = n / ncols + ((n % ncols) ? 1 : 0);
@@ -938,7 +938,7 @@ void QMdiAreaPrivate::rearrange(Rearranger *rearranger)
if (!sanityCheck(child, "QMdiArea::rearrange") || !child->isVisible())
continue;
if (rearranger->type() == Rearranger::IconTiler) {
- if (child->isMinimized() && !child->isShaded() && !(child->windowFlags() & Qt::FramelessWindowHint))
+ if (child->isMinimized() && !child->isShaded())
widgets.append(child);
} else {
if (child->isMinimized() && !child->isShaded())
diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp
index c3b31ea5a4..3f4d0ec453 100644
--- a/src/widgets/widgets/qmdisubwindow.cpp
+++ b/src/widgets/widgets/qmdisubwindow.cpp
@@ -1000,7 +1000,9 @@ void QMdiSubWindowPrivate::removeBaseWidget()
q->setWindowModified(false);
}
lastChildWindowTitle.clear();
- baseWidget->setParent(0);
+ // QTBUG-47993: parent widget can be reset before this call
+ if (baseWidget->parentWidget() == q)
+ baseWidget->setParent(0);
baseWidget = 0;
isWidgetHiddenByUs = false;
}
@@ -2653,7 +2655,7 @@ void QMdiSubWindow::showShaded()
resize(d->internalMinimumSize);
// Hide the internal widget if not already hidden by the user.
- if (d->baseWidget && !d->baseWidget->isHidden()) {
+ if (d->baseWidget && !d->baseWidget->isHidden() && !(windowFlags() & Qt::FramelessWindowHint)) {
d->baseWidget->hide();
d->isWidgetHiddenByUs = true;
}
diff --git a/src/widgets/widgets/qmenu_mac.mm b/src/widgets/widgets/qmenu_mac.mm
index a42879fc73..e30eda130b 100644
--- a/src/widgets/widgets/qmenu_mac.mm
+++ b/src/widgets/widgets/qmenu_mac.mm
@@ -32,7 +32,7 @@
****************************************************************************/
#import <Foundation/Foundation.h>
-#import <Cocoa/Cocoa.h>
+#import <AppKit/AppKit.h>
#include "qmenu.h"
#include "qmenubar.h"
diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp
index 7439005b92..ba6db2971a 100644
--- a/src/widgets/widgets/qtextedit.cpp
+++ b/src/widgets/widgets/qtextedit.cpp
@@ -1060,6 +1060,8 @@ bool QTextEdit::event(QEvent *e)
|| e->type() == QEvent::ToolTip) {
d->sendControlEvent(e);
}
+#else
+ Q_UNUSED(d)
#endif // QT_NO_CONTEXTMENU
#ifdef QT_KEYPAD_NAVIGATION
if (e->type() == QEvent::EnterEditFocus || e->type() == QEvent::LeaveEditFocus) {