Make QGtkStyle work on Qt 5.
authorMorten Johan Sorvig <morten.sorvig@nokia.com>
Tue, 24 Apr 2012 12:23:02 +0000 (14:23 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 30 Apr 2012 12:01:22 +0000 (14:01 +0200)
Mostly straightforward porting: Add configure test from Qt 4. Add X11
include to qgtkstyle_p.cpp. Use renamed QGuiApplicationPrivate::showModalWindow.

Change-Id: I83020e13ec00b49f3fe346814f881bce19a6f602
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
configure
src/widgets/styles/qgtkstyle_p.cpp
src/widgets/styles/qgtkstyle_p.h
src/widgets/styles/styles.pri

index b4b57c6..38d460f 100755 (executable)
--- a/configure
+++ b/configure
@@ -4245,6 +4245,32 @@ if [ "$CFG_GLIB" != "no" ]; then
     fi
 fi
 
+# auto-detect GTK style support
+if [ "$CFG_GLIB" = "yes" -a "$CFG_QGTKSTYLE" != "no" ]; then
+    if [ -n "$PKG_CONFIG" ]; then
+        QT_CFLAGS_QGTKSTYLE=`$PKG_CONFIG --cflags gtk+-2.0 ">=" 2.10 atk 2>/dev/null`
+        QT_LIBS_QGTKSTYLE=`$PKG_CONFIG --libs gobject-2.0 2>/dev/null`
+    fi
+    if [ -n "$QT_CFLAGS_QGTKSTYLE" ] ; then
+        CFG_QGTKSTYLE=yes
+        QT_CONFIG="$QT_CONFIG gtkstyle"
+        QMakeVar set QT_CFLAGS_QGTKSTYLE "$QT_CFLAGS_QGTKSTYLE"
+        QMakeVar set QT_LIBS_QGTKSTYLE "$QT_LIBS_QGTKSTYLE"
+    else
+        if [ "$CFG_QGTKSTYLE" = "yes" ] && [ "$CFG_CONFIGURE_EXIT_ON_ERROR" = "yes" ]; then
+            echo "Gtk theme support cannot be enabled due to functionality tests!"
+            echo " Turn on verbose messaging (-v) to $0 to see the fin  al report."
+            echo " If you believe this message is in error you may use the continue"
+            echo " switch (-continue) to $0 to continue."
+            exit 101
+        else
+            CFG_QGTKSTYLE=no
+        fi
+    fi
+elif [ "$CFG_GLIB" = "no" ]; then
+    CFG_QGTKSTYLE=no
+fi
+
 # ### Vestige
 if [ "$CFG_GLIB" = "yes" -a "$CFG_GSTREAMER" != "no" ]; then
     if [ -n "$PKG_CONFIG" ]; then
index 0402859..37edf5d 100644 (file)
 #include <QtWidgets/QToolBar>
 #include <QtWidgets/QToolButton>
 
-#include <private/qt_x11_p.h>
+// 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
 
 QT_BEGIN_NAMESPACE
 
@@ -982,7 +996,7 @@ QString QGtkStylePrivate::openFilename(QWidget *parent, const QString &caption,
     QWidget modal_widget;
     modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
     modal_widget.setParent(parent, Qt::Window);
-    QApplicationPrivate::enterModal(&modal_widget);
+    QGuiApplicationPrivate::showModalWindow(modal_widget.windowHandle());
 
     QString filename;
     if (QGtkStylePrivate::gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
@@ -995,7 +1009,7 @@ QString QGtkStylePrivate::openFilename(QWidget *parent, const QString &caption,
         }
     }
 
-    QApplicationPrivate::leaveModal(&modal_widget);
+    QApplicationPrivate::hideModalWindow(modal_widget.windowHandle());
     gtk_widget_destroy (gtkFileChooser);
     return filename;
 }
@@ -1015,7 +1029,7 @@ QString QGtkStylePrivate::openDirectory(QWidget *parent, const QString &caption,
     QWidget modal_widget;
     modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
     modal_widget.setParent(parent, Qt::Window);
-    QApplicationPrivate::enterModal(&modal_widget);
+    QGuiApplicationPrivate::showModalWindow(modal_widget.windowHandle());
 
     QString filename;
     if (QGtkStylePrivate::gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
@@ -1024,7 +1038,7 @@ QString QGtkStylePrivate::openDirectory(QWidget *parent, const QString &caption,
         g_free (gtk_filename);
     }
 
-    QApplicationPrivate::leaveModal(&modal_widget);
+    QApplicationPrivate::hideModalWindow(modal_widget.windowHandle());
     gtk_widget_destroy (gtkFileChooser);
     return filename;
 }
@@ -1047,7 +1061,7 @@ QStringList QGtkStylePrivate::openFilenames(QWidget *parent, const QString &capt
     QWidget modal_widget;
     modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
     modal_widget.setParent(parent, Qt::Window);
-    QApplicationPrivate::enterModal(&modal_widget);
+    QGuiApplicationPrivate::showModalWindow(modal_widget.windowHandle());
 
     if (gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
         GSList *gtk_file_names = QGtkStylePrivate::gtk_file_chooser_get_filenames((GtkFileChooser*)gtkFileChooser);
@@ -1060,7 +1074,7 @@ QStringList QGtkStylePrivate::openFilenames(QWidget *parent, const QString &capt
         }
     }
 
-    QApplicationPrivate::leaveModal(&modal_widget);
+    QApplicationPrivate::hideModalWindow(modal_widget.windowHandle());
     gtk_widget_destroy (gtkFileChooser);
     return filenames;
 }
@@ -1080,7 +1094,7 @@ QString QGtkStylePrivate::saveFilename(QWidget *parent, const QString &caption,
     QWidget modal_widget;
     modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
     modal_widget.setParent(parent, Qt::Window);
-    QApplicationPrivate::enterModal(&modal_widget);
+    QGuiApplicationPrivate::showModalWindow(modal_widget.windowHandle());
 
     QString filename;
     if (QGtkStylePrivate::gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
@@ -1093,7 +1107,7 @@ QString QGtkStylePrivate::saveFilename(QWidget *parent, const QString &caption,
         }
     }
 
-    QApplicationPrivate::leaveModal(&modal_widget);
+    QApplicationPrivate::hideModalWindow(modal_widget.windowHandle());
     gtk_widget_destroy (gtkFileChooser);
     return filename;
 }
index 02d659c..b095820 100644 (file)
@@ -131,6 +131,7 @@ 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 **);
index 2ae9664..91212f0 100644 (file)
@@ -39,7 +39,7 @@ contains( styles, all ) {
 
 !macx-*|ios:styles -= mac
 
-x11{
+contains(QT_CONFIG, gtkstyle) {
     QMAKE_CXXFLAGS += $$QT_CFLAGS_QGTKSTYLE
     LIBS_PRIVATE += $$QT_LIBS_QGTKSTYLE
     styles += gtk