summaryrefslogtreecommitdiffstats
path: root/src/gui/styles
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/styles')
-rw-r--r--src/gui/styles/gtksymbols.cpp1008
-rw-r--r--src/gui/styles/qcleanlooksstyle.cpp2
-rw-r--r--src/gui/styles/qcommonstyle.cpp5
-rw-r--r--src/gui/styles/qcommonstyle_p.h19
-rw-r--r--src/gui/styles/qgtkpainter.cpp72
-rw-r--r--src/gui/styles/qgtkpainter_p.h2
-rw-r--r--src/gui/styles/qgtkstyle.cpp483
-rw-r--r--src/gui/styles/qgtkstyle.h8
-rw-r--r--src/gui/styles/qgtkstyle_p.cpp1069
-rw-r--r--src/gui/styles/qgtkstyle_p.h (renamed from src/gui/styles/gtksymbols_p.h)106
-rw-r--r--src/gui/styles/qplastiquestyle.cpp3
-rw-r--r--src/gui/styles/qs60style.cpp360
-rw-r--r--src/gui/styles/qs60style_p.h6
-rw-r--r--src/gui/styles/qs60style_s60.cpp75
-rw-r--r--src/gui/styles/qs60style_simulated.cpp6
-rw-r--r--src/gui/styles/qwindowsstyle.cpp3
-rw-r--r--src/gui/styles/qwindowsvistastyle.cpp50
-rw-r--r--src/gui/styles/qwindowsvistastyle_p.h24
-rw-r--r--src/gui/styles/qwindowsxpstyle.cpp4
-rw-r--r--src/gui/styles/styles.pri4
20 files changed, 1755 insertions, 1554 deletions
diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp
deleted file mode 100644
index 32fde62..0000000
--- a/src/gui/styles/gtksymbols.cpp
+++ /dev/null
@@ -1,1008 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "gtksymbols_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 <private/qapplication_p.h>
-#include <private/qiconloader_p.h>
-
-#include <QtGui/QMenu>
-#include <QtGui/QStyle>
-#include <QtGui/QApplication>
-#include <QtGui/QPixmapCache>
-#include <QtGui/QStatusBar>
-#include <QtGui/QMenuBar>
-#include <QtGui/QToolBar>
-#include <QtGui/QToolButton>
-#include <QtGui/QX11Info>
-
-#include <X11/Xlib.h>
-
-QT_BEGIN_NAMESPACE
-
-static bool displayDepth = -1;
-Q_GLOBAL_STATIC(QGtkStyleUpdateScheduler, styleScheduler)
-
-typedef QHash<QString, GtkWidget*> WidgetMap;
-Q_GLOBAL_STATIC(WidgetMap, gtkWidgetMap)
-
-Ptr_gtk_container_forall QGtk::gtk_container_forall = 0;
-Ptr_gtk_init QGtk::gtk_init = 0;
-Ptr_gtk_style_attach QGtk::gtk_style_attach = 0;
-Ptr_gtk_window_new QGtk::gtk_window_new = 0;
-Ptr_gtk_widget_destroy QGtk::gtk_widget_destroy = 0;
-Ptr_gtk_widget_realize QGtk::gtk_widget_realize = 0;
-Ptr_gtk_widget_set_default_direction QGtk::gtk_widget_set_default_direction = 0;
-Ptr_gtk_widget_modify_color QGtk::gtk_widget_modify_fg = 0;
-Ptr_gtk_widget_modify_color QGtk::gtk_widget_modify_bg = 0;
-Ptr_gtk_arrow_new QGtk::gtk_arrow_new = 0;
-Ptr_gtk_menu_item_new QGtk::gtk_menu_item_new = 0;
-Ptr_gtk_check_menu_item_new QGtk::gtk_check_menu_item_new = 0;
-Ptr_gtk_menu_bar_new QGtk::gtk_menu_bar_new = 0;
-Ptr_gtk_menu_new QGtk::gtk_menu_new = 0;
-Ptr_gtk_button_new QGtk::gtk_button_new = 0;
-Ptr_gtk_tool_button_new QGtk::gtk_tool_button_new = 0;
-Ptr_gtk_hbutton_box_new QGtk::gtk_hbutton_box_new = 0;
-Ptr_gtk_check_button_new QGtk::gtk_check_button_new = 0;
-Ptr_gtk_radio_button_new QGtk::gtk_radio_button_new = 0;
-Ptr_gtk_spin_button_new QGtk::gtk_spin_button_new = 0;
-Ptr_gtk_frame_new QGtk::gtk_frame_new = 0;
-Ptr_gtk_expander_new QGtk::gtk_expander_new = 0;
-Ptr_gtk_statusbar_new QGtk::gtk_statusbar_new = 0;
-Ptr_gtk_entry_new QGtk::gtk_entry_new = 0;
-Ptr_gtk_hscale_new QGtk::gtk_hscale_new = 0;
-Ptr_gtk_vscale_new QGtk::gtk_vscale_new = 0;
-Ptr_gtk_hscrollbar_new QGtk::gtk_hscrollbar_new = 0;
-Ptr_gtk_vscrollbar_new QGtk::gtk_vscrollbar_new = 0;
-Ptr_gtk_scrolled_window_new QGtk::gtk_scrolled_window_new = 0;
-Ptr_gtk_notebook_new QGtk::gtk_notebook_new = 0;
-Ptr_gtk_toolbar_new QGtk::gtk_toolbar_new = 0;
-Ptr_gtk_toolbar_insert QGtk::gtk_toolbar_insert = 0;
-Ptr_gtk_separator_tool_item_new QGtk::gtk_separator_tool_item_new = 0;
-Ptr_gtk_tree_view_new QGtk::gtk_tree_view_new = 0;
-Ptr_gtk_combo_box_new QGtk::gtk_combo_box_new = 0;
-Ptr_gtk_combo_box_entry_new QGtk::gtk_combo_box_entry_new = 0;
-Ptr_gtk_progress_bar_new QGtk::gtk_progress_bar_new = 0;
-Ptr_gtk_container_add QGtk::gtk_container_add = 0;
-Ptr_gtk_menu_shell_append QGtk::gtk_menu_shell_append = 0;
-Ptr_gtk_progress_set_adjustment QGtk::gtk_progress_set_adjustment = 0;
-Ptr_gtk_range_set_adjustment QGtk::gtk_range_set_adjustment = 0;
-Ptr_gtk_range_set_inverted QGtk::gtk_range_set_inverted = 0;
-Ptr_gtk_icon_factory_lookup_default QGtk::gtk_icon_factory_lookup_default = 0;
-Ptr_gtk_icon_theme_get_default QGtk::gtk_icon_theme_get_default = 0;
-Ptr_gtk_widget_style_get QGtk::gtk_widget_style_get = 0;
-Ptr_gtk_icon_set_render_icon QGtk::gtk_icon_set_render_icon = 0;
-Ptr_gtk_fixed_new QGtk::gtk_fixed_new = 0;
-Ptr_gtk_tree_view_column_new QGtk::gtk_tree_view_column_new = 0;
-Ptr_gtk_tree_view_get_column QGtk::gtk_tree_view_get_column = 0;
-Ptr_gtk_tree_view_append_column QGtk::gtk_tree_view_append_column = 0;
-Ptr_gtk_paint_check QGtk::gtk_paint_check = 0;
-Ptr_gtk_paint_box QGtk::gtk_paint_box = 0;
-Ptr_gtk_paint_box_gap QGtk::gtk_paint_box_gap = 0;
-Ptr_gtk_paint_flat_box QGtk::gtk_paint_flat_box = 0;
-Ptr_gtk_paint_option QGtk::gtk_paint_option = 0;
-Ptr_gtk_paint_extension QGtk::gtk_paint_extension = 0;
-Ptr_gtk_paint_slider QGtk::gtk_paint_slider = 0;
-Ptr_gtk_paint_shadow QGtk::gtk_paint_shadow = 0;
-Ptr_gtk_paint_resize_grip QGtk::gtk_paint_resize_grip = 0;
-Ptr_gtk_paint_focus QGtk::gtk_paint_focus = 0;
-Ptr_gtk_paint_arrow QGtk::gtk_paint_arrow = 0;
-Ptr_gtk_paint_handle QGtk::gtk_paint_handle = 0;
-Ptr_gtk_paint_expander QGtk::gtk_paint_expander = 0;
-Ptr_gtk_adjustment_new QGtk::gtk_adjustment_new = 0;
-Ptr_gtk_paint_hline QGtk::gtk_paint_hline = 0;
-Ptr_gtk_paint_vline QGtk::gtk_paint_vline = 0;
-Ptr_gtk_menu_item_set_submenu QGtk::gtk_menu_item_set_submenu = 0;
-Ptr_gtk_settings_get_default QGtk::gtk_settings_get_default = 0;
-Ptr_gtk_separator_menu_item_new QGtk::gtk_separator_menu_item_new = 0;
-Ptr_gtk_widget_size_allocate QGtk::gtk_widget_size_allocate = 0;
-Ptr_gtk_widget_set_direction QGtk::gtk_widget_set_direction = 0;
-Ptr_gtk_widget_path QGtk::gtk_widget_path = 0;
-Ptr_gtk_container_get_type QGtk::gtk_container_get_type = 0;
-Ptr_gtk_window_get_type QGtk::gtk_window_get_type = 0;
-Ptr_gtk_widget_get_type QGtk::gtk_widget_get_type = 0;
-Ptr_gtk_rc_get_style_by_paths QGtk::gtk_rc_get_style_by_paths = 0;
-Ptr_gtk_check_version QGtk::gtk_check_version = 0;
-
-Ptr_pango_font_description_get_size QGtk::pango_font_description_get_size = 0;
-Ptr_pango_font_description_get_weight QGtk::pango_font_description_get_weight = 0;
-Ptr_pango_font_description_get_family QGtk::pango_font_description_get_family = 0;
-Ptr_pango_font_description_get_style QGtk::pango_font_description_get_style = 0;
-
-Ptr_gtk_file_filter_new QGtk::gtk_file_filter_new = 0;
-Ptr_gtk_file_filter_set_name QGtk::gtk_file_filter_set_name = 0;
-Ptr_gtk_file_filter_add_pattern QGtk::gtk_file_filter_add_pattern = 0;
-Ptr_gtk_file_chooser_add_filter QGtk::gtk_file_chooser_add_filter = 0;
-Ptr_gtk_file_chooser_set_filter QGtk::gtk_file_chooser_set_filter = 0;
-Ptr_gtk_file_chooser_get_filter QGtk::gtk_file_chooser_get_filter = 0;
-Ptr_gtk_file_chooser_dialog_new QGtk::gtk_file_chooser_dialog_new = 0;
-Ptr_gtk_file_chooser_set_current_folder QGtk::gtk_file_chooser_set_current_folder = 0;
-Ptr_gtk_file_chooser_get_filename QGtk::gtk_file_chooser_get_filename = 0;
-Ptr_gtk_file_chooser_get_filenames QGtk::gtk_file_chooser_get_filenames = 0;
-Ptr_gtk_file_chooser_set_current_name QGtk::gtk_file_chooser_set_current_name = 0;
-Ptr_gtk_dialog_run QGtk::gtk_dialog_run = 0;
-Ptr_gtk_file_chooser_set_filename QGtk::gtk_file_chooser_set_filename = 0;
-
-Ptr_gdk_pixbuf_get_pixels QGtk::gdk_pixbuf_get_pixels = 0;
-Ptr_gdk_pixbuf_get_width QGtk::gdk_pixbuf_get_width = 0;
-Ptr_gdk_pixbuf_get_height QGtk::gdk_pixbuf_get_height = 0;
-Ptr_gdk_pixmap_new QGtk::gdk_pixmap_new = 0;
-Ptr_gdk_pixbuf_new QGtk::gdk_pixbuf_new = 0;
-Ptr_gdk_pixbuf_get_from_drawable QGtk::gdk_pixbuf_get_from_drawable = 0;
-Ptr_gdk_draw_rectangle QGtk::gdk_draw_rectangle = 0;
-Ptr_gdk_pixbuf_unref QGtk::gdk_pixbuf_unref = 0;
-Ptr_gdk_drawable_unref QGtk::gdk_drawable_unref = 0;
-Ptr_gdk_drawable_get_depth QGtk::gdk_drawable_get_depth = 0;
-Ptr_gdk_color_free QGtk::gdk_color_free = 0;
-Ptr_gdk_x11_window_set_user_time QGtk::gdk_x11_window_set_user_time = 0;
-Ptr_gdk_x11_drawable_get_xid QGtk::gdk_x11_drawable_get_xid = 0;
-Ptr_gdk_x11_drawable_get_xdisplay QGtk::gdk_x11_drawable_get_xdisplay = 0;
-
-Ptr_gconf_client_get_default QGtk::gconf_client_get_default = 0;
-Ptr_gconf_client_get_string QGtk::gconf_client_get_string = 0;
-Ptr_gconf_client_get_bool QGtk::gconf_client_get_bool = 0;
-
-Ptr_gnome_icon_lookup_sync QGtk::gnome_icon_lookup_sync = 0;
-Ptr_gnome_vfs_init QGtk::gnome_vfs_init = 0;
-
-static QString classPath(GtkWidget *widget)
-{
- char* class_path;
- QGtk::gtk_widget_path (widget, NULL, &class_path, NULL);
- QString path = QLS(class_path);
- g_free(class_path);
-
- // Remove the prefixes
- path.remove(QLS("GtkWindow."));
- path.remove(QLS("GtkFixed."));
- return path;
-}
-
-static void resolveGtk()
-{
- // enforce the "0" suffix, so we'll open libgtk-x11-2.0.so.0
- QLibrary libgtk(QLS("gtk-x11-2.0"), 0, 0);
- QGtk::gtk_init = (Ptr_gtk_init)libgtk.resolve("gtk_init");
- QGtk::gtk_window_new = (Ptr_gtk_window_new)libgtk.resolve("gtk_window_new");
- QGtk::gtk_style_attach = (Ptr_gtk_style_attach)libgtk.resolve("gtk_style_attach");
- QGtk::gtk_widget_destroy = (Ptr_gtk_widget_destroy)libgtk.resolve("gtk_widget_destroy");
- QGtk::gtk_widget_realize = (Ptr_gtk_widget_realize)libgtk.resolve("gtk_widget_realize");
-
- QGtk::gtk_file_chooser_set_current_folder = (Ptr_gtk_file_chooser_set_current_folder)libgtk.resolve("gtk_file_chooser_set_current_folder");
- QGtk::gtk_file_filter_new = (Ptr_gtk_file_filter_new)libgtk.resolve("gtk_file_filter_new");
- QGtk::gtk_file_filter_set_name = (Ptr_gtk_file_filter_set_name)libgtk.resolve("gtk_file_filter_set_name");
- QGtk::gtk_file_filter_add_pattern = (Ptr_gtk_file_filter_add_pattern)libgtk.resolve("gtk_file_filter_add_pattern");
- QGtk::gtk_file_chooser_add_filter = (Ptr_gtk_file_chooser_add_filter)libgtk.resolve("gtk_file_chooser_add_filter");
- QGtk::gtk_file_chooser_set_filter = (Ptr_gtk_file_chooser_set_filter)libgtk.resolve("gtk_file_chooser_set_filter");
- QGtk::gtk_file_chooser_get_filter = (Ptr_gtk_file_chooser_get_filter)libgtk.resolve("gtk_file_chooser_get_filter");
- QGtk::gtk_file_chooser_dialog_new = (Ptr_gtk_file_chooser_dialog_new)libgtk.resolve("gtk_file_chooser_dialog_new");
- QGtk::gtk_file_chooser_set_current_folder = (Ptr_gtk_file_chooser_set_current_folder)libgtk.resolve("gtk_file_chooser_set_current_folder");
- QGtk::gtk_file_chooser_get_filename = (Ptr_gtk_file_chooser_get_filename)libgtk.resolve("gtk_file_chooser_get_filename");
- QGtk::gtk_file_chooser_get_filenames = (Ptr_gtk_file_chooser_get_filenames)libgtk.resolve("gtk_file_chooser_get_filenames");
- QGtk::gtk_file_chooser_set_current_name = (Ptr_gtk_file_chooser_set_current_name)libgtk.resolve("gtk_file_chooser_set_current_name");
- QGtk::gtk_dialog_run = (Ptr_gtk_dialog_run)libgtk.resolve("gtk_dialog_run");
- QGtk::gtk_file_chooser_set_filename = (Ptr_gtk_file_chooser_set_filename)libgtk.resolve("gtk_file_chooser_set_filename");
-
- QGtk::gdk_pixbuf_get_pixels = (Ptr_gdk_pixbuf_get_pixels)libgtk.resolve("gdk_pixbuf_get_pixels");
- QGtk::gdk_pixbuf_get_width = (Ptr_gdk_pixbuf_get_width)libgtk.resolve("gdk_pixbuf_get_width");
- QGtk::gdk_pixbuf_get_height = (Ptr_gdk_pixbuf_get_height)libgtk.resolve("gdk_pixbuf_get_height");
- QGtk::gdk_pixmap_new = (Ptr_gdk_pixmap_new)libgtk.resolve("gdk_pixmap_new");
- QGtk::gdk_pixbuf_new = (Ptr_gdk_pixbuf_new)libgtk.resolve("gdk_pixbuf_new");
- QGtk::gdk_pixbuf_get_from_drawable = (Ptr_gdk_pixbuf_get_from_drawable)libgtk.resolve("gdk_pixbuf_get_from_drawable");
- QGtk::gdk_draw_rectangle = (Ptr_gdk_draw_rectangle)libgtk.resolve("gdk_draw_rectangle");
- QGtk::gdk_pixbuf_unref = (Ptr_gdk_pixbuf_unref)libgtk.resolve("gdk_pixbuf_unref");
- QGtk::gdk_drawable_unref = (Ptr_gdk_drawable_unref)libgtk.resolve("gdk_drawable_unref");
- QGtk::gdk_drawable_get_depth = (Ptr_gdk_drawable_get_depth)libgtk.resolve("gdk_drawable_get_depth");
- QGtk::gdk_color_free = (Ptr_gdk_color_free)libgtk.resolve("gdk_color_free");
- QGtk::gdk_x11_window_set_user_time = (Ptr_gdk_x11_window_set_user_time)libgtk.resolve("gdk_x11_window_set_user_time");
- QGtk::gdk_x11_drawable_get_xid = (Ptr_gdk_x11_drawable_get_xid)libgtk.resolve("gdk_x11_drawable_get_xid");
- QGtk::gdk_x11_drawable_get_xdisplay = (Ptr_gdk_x11_drawable_get_xdisplay)libgtk.resolve("gdk_x11_drawable_get_xdisplay");
-
- QGtk::gtk_widget_set_default_direction = (Ptr_gtk_widget_set_default_direction)libgtk.resolve("gtk_widget_set_default_direction");
- QGtk::gtk_widget_modify_fg = (Ptr_gtk_widget_modify_color)libgtk.resolve("gtk_widget_modify_fg");
- QGtk::gtk_widget_modify_bg = (Ptr_gtk_widget_modify_color)libgtk.resolve("gtk_widget_modify_bg");
- QGtk::gtk_arrow_new = (Ptr_gtk_arrow_new)libgtk.resolve("gtk_arrow_new");
- QGtk::gtk_menu_item_new = (Ptr_gtk_menu_item_new)libgtk.resolve("gtk_menu_item_new");
- QGtk::gtk_check_menu_item_new = (Ptr_gtk_check_menu_item_new)libgtk.resolve("gtk_check_menu_item_new");
- QGtk::gtk_menu_bar_new = (Ptr_gtk_menu_bar_new)libgtk.resolve("gtk_menu_bar_new");
- QGtk::gtk_menu_new = (Ptr_gtk_menu_new)libgtk.resolve("gtk_menu_new");
- QGtk::gtk_toolbar_new = (Ptr_gtk_toolbar_new)libgtk.resolve("gtk_toolbar_new");
- QGtk::gtk_separator_tool_item_new = (Ptr_gtk_separator_tool_item_new)libgtk.resolve("gtk_separator_tool_item_new");
- QGtk::gtk_toolbar_insert = (Ptr_gtk_toolbar_insert)libgtk.resolve("gtk_toolbar_insert");
- QGtk::gtk_button_new = (Ptr_gtk_button_new)libgtk.resolve("gtk_button_new");
- QGtk::gtk_tool_button_new = (Ptr_gtk_tool_button_new)libgtk.resolve("gtk_tool_button_new");
- QGtk::gtk_hbutton_box_new = (Ptr_gtk_hbutton_box_new)libgtk.resolve("gtk_hbutton_box_new");
- QGtk::gtk_check_button_new = (Ptr_gtk_check_button_new)libgtk.resolve("gtk_check_button_new");
- QGtk::gtk_radio_button_new = (Ptr_gtk_radio_button_new)libgtk.resolve("gtk_radio_button_new");
- QGtk::gtk_notebook_new = (Ptr_gtk_notebook_new)libgtk.resolve("gtk_notebook_new");
- QGtk::gtk_progress_bar_new = (Ptr_gtk_progress_bar_new)libgtk.resolve("gtk_progress_bar_new");
- QGtk::gtk_spin_button_new = (Ptr_gtk_spin_button_new)libgtk.resolve("gtk_spin_button_new");
- QGtk::gtk_hscale_new = (Ptr_gtk_hscale_new)libgtk.resolve("gtk_hscale_new");
- QGtk::gtk_vscale_new = (Ptr_gtk_vscale_new)libgtk.resolve("gtk_vscale_new");
- QGtk::gtk_hscrollbar_new = (Ptr_gtk_hscrollbar_new)libgtk.resolve("gtk_hscrollbar_new");
- QGtk::gtk_vscrollbar_new = (Ptr_gtk_vscrollbar_new)libgtk.resolve("gtk_vscrollbar_new");
- QGtk::gtk_scrolled_window_new = (Ptr_gtk_scrolled_window_new)libgtk.resolve("gtk_scrolled_window_new");
- QGtk::gtk_menu_shell_append = (Ptr_gtk_menu_shell_append)libgtk.resolve("gtk_menu_shell_append");
- QGtk::gtk_entry_new = (Ptr_gtk_entry_new)libgtk.resolve("gtk_entry_new");
- QGtk::gtk_tree_view_new = (Ptr_gtk_tree_view_new)libgtk.resolve("gtk_tree_view_new");
- QGtk::gtk_combo_box_new = (Ptr_gtk_combo_box_new)libgtk.resolve("gtk_combo_box_new");
- QGtk::gtk_progress_set_adjustment = (Ptr_gtk_progress_set_adjustment)libgtk.resolve("gtk_progress_set_adjustment");
- QGtk::gtk_range_set_adjustment = (Ptr_gtk_range_set_adjustment)libgtk.resolve("gtk_range_set_adjustment");
- QGtk::gtk_range_set_inverted = (Ptr_gtk_range_set_inverted)libgtk.resolve("gtk_range_set_inverted");
- QGtk::gtk_container_add = (Ptr_gtk_container_add)libgtk.resolve("gtk_container_add");
- QGtk::gtk_icon_factory_lookup_default = (Ptr_gtk_icon_factory_lookup_default)libgtk.resolve("gtk_icon_factory_lookup_default");
- QGtk::gtk_icon_theme_get_default = (Ptr_gtk_icon_theme_get_default)libgtk.resolve("gtk_icon_theme_get_default");
- QGtk::gtk_widget_style_get = (Ptr_gtk_widget_style_get)libgtk.resolve("gtk_widget_style_get");
- QGtk::gtk_icon_set_render_icon = (Ptr_gtk_icon_set_render_icon)libgtk.resolve("gtk_icon_set_render_icon");
- QGtk::gtk_fixed_new = (Ptr_gtk_fixed_new)libgtk.resolve("gtk_fixed_new");
- QGtk::gtk_tree_view_column_new = (Ptr_gtk_tree_view_column_new)libgtk.resolve("gtk_tree_view_column_new");
- QGtk::gtk_tree_view_append_column= (Ptr_gtk_tree_view_append_column )libgtk.resolve("gtk_tree_view_append_column");
- QGtk::gtk_tree_view_get_column = (Ptr_gtk_tree_view_get_column )libgtk.resolve("gtk_tree_view_get_column");
- QGtk::gtk_paint_check = (Ptr_gtk_paint_check)libgtk.resolve("gtk_paint_check");
- QGtk::gtk_paint_box = (Ptr_gtk_paint_box)libgtk.resolve("gtk_paint_box");
- QGtk::gtk_paint_flat_box = (Ptr_gtk_paint_flat_box)libgtk.resolve("gtk_paint_flat_box");
- QGtk::gtk_paint_check = (Ptr_gtk_paint_check)libgtk.resolve("gtk_paint_check");
- QGtk::gtk_paint_box = (Ptr_gtk_paint_box)libgtk.resolve("gtk_paint_box");
- QGtk::gtk_paint_resize_grip = (Ptr_gtk_paint_resize_grip)libgtk.resolve("gtk_paint_resize_grip");
- QGtk::gtk_paint_focus = (Ptr_gtk_paint_focus)libgtk.resolve("gtk_paint_focus");
- QGtk::gtk_paint_shadow = (Ptr_gtk_paint_shadow)libgtk.resolve("gtk_paint_shadow");
- QGtk::gtk_paint_slider = (Ptr_gtk_paint_slider)libgtk.resolve("gtk_paint_slider");
- QGtk::gtk_paint_expander = (Ptr_gtk_paint_expander)libgtk.resolve("gtk_paint_expander");
- QGtk::gtk_paint_handle = (Ptr_gtk_paint_handle)libgtk.resolve("gtk_paint_handle");
- QGtk::gtk_paint_option = (Ptr_gtk_paint_option)libgtk.resolve("gtk_paint_option");
- QGtk::gtk_paint_arrow = (Ptr_gtk_paint_arrow)libgtk.resolve("gtk_paint_arrow");
- QGtk::gtk_paint_box_gap = (Ptr_gtk_paint_box_gap)libgtk.resolve("gtk_paint_box_gap");
- QGtk::gtk_paint_extension = (Ptr_gtk_paint_extension)libgtk.resolve("gtk_paint_extension");
- QGtk::gtk_paint_hline = (Ptr_gtk_paint_hline)libgtk.resolve("gtk_paint_hline");
- QGtk::gtk_paint_vline = (Ptr_gtk_paint_vline)libgtk.resolve("gtk_paint_vline");
- QGtk::gtk_adjustment_new = (Ptr_gtk_adjustment_new)libgtk.resolve("gtk_adjustment_new");
- QGtk::gtk_menu_item_set_submenu = (Ptr_gtk_menu_item_set_submenu)libgtk.resolve("gtk_menu_item_set_submenu");
- QGtk::gtk_settings_get_default = (Ptr_gtk_settings_get_default)libgtk.resolve("gtk_settings_get_default");
- QGtk::gtk_separator_menu_item_new = (Ptr_gtk_separator_menu_item_new)libgtk.resolve("gtk_separator_menu_item_new");
- QGtk::gtk_frame_new = (Ptr_gtk_frame_new)libgtk.resolve("gtk_frame_new");
- QGtk::gtk_expander_new = (Ptr_gtk_expander_new)libgtk.resolve("gtk_expander_new");
- QGtk::gtk_statusbar_new = (Ptr_gtk_statusbar_new)libgtk.resolve("gtk_statusbar_new");
- QGtk::gtk_combo_box_entry_new = (Ptr_gtk_combo_box_entry_new)libgtk.resolve("gtk_combo_box_entry_new");
- QGtk::gtk_container_forall = (Ptr_gtk_container_forall)libgtk.resolve("gtk_container_forall");
- QGtk::gtk_widget_size_allocate =(Ptr_gtk_widget_size_allocate)libgtk.resolve("gtk_widget_size_allocate");
- QGtk::gtk_widget_set_direction =(Ptr_gtk_widget_set_direction)libgtk.resolve("gtk_widget_set_direction");
- QGtk::gtk_widget_path =(Ptr_gtk_widget_path)libgtk.resolve("gtk_widget_path");
- QGtk::gtk_container_get_type =(Ptr_gtk_container_get_type)libgtk.resolve("gtk_container_get_type");
- QGtk::gtk_window_get_type =(Ptr_gtk_window_get_type)libgtk.resolve("gtk_window_get_type");
- QGtk::gtk_widget_get_type =(Ptr_gtk_widget_get_type)libgtk.resolve("gtk_widget_get_type");
- QGtk::gtk_rc_get_style_by_paths =(Ptr_gtk_rc_get_style_by_paths)libgtk.resolve("gtk_rc_get_style_by_paths");
- QGtk::gtk_check_version =(Ptr_gtk_check_version)libgtk.resolve("gtk_check_version");
- QGtk::pango_font_description_get_size = (Ptr_pango_font_description_get_size)libgtk.resolve("pango_font_description_get_size");
- QGtk::pango_font_description_get_weight = (Ptr_pango_font_description_get_weight)libgtk.resolve("pango_font_description_get_weight");
- QGtk::pango_font_description_get_family = (Ptr_pango_font_description_get_family)libgtk.resolve("pango_font_description_get_family");
- QGtk::pango_font_description_get_style = (Ptr_pango_font_description_get_style)libgtk.resolve("pango_font_description_get_style");
-
- QGtk::gnome_icon_lookup_sync = (Ptr_gnome_icon_lookup_sync)QLibrary::resolve( QLS("gnomeui-2"), 0, "gnome_icon_lookup_sync");
- QGtk::gnome_vfs_init= (Ptr_gnome_vfs_init)QLibrary::resolve( QLS("gnomevfs-2"), 0, "gnome_vfs_init");
-}
-
-void QGtk::cleanup_gtk_widgets()
-{
- if (gtkWidgetMap()->contains(QLS("GtkWindow"))) // Gtk will destroy all children
- QGtk::gtk_widget_destroy(gtkWidgetMap()->value(QLS("GtkWindow")));
-}
-
-static bool resolveGConf()
-{
- if (!QGtk::gconf_client_get_default) {
- QGtk::gconf_client_get_default = (Ptr_gconf_client_get_default)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_default");
- QGtk::gconf_client_get_string = (Ptr_gconf_client_get_string)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_string");
- QGtk::gconf_client_get_bool = (Ptr_gconf_client_get_bool)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_bool");
- }
- return (QGtk::gconf_client_get_default !=0);
-}
-
-typedef int (*x11ErrorHandler)(Display*, XErrorEvent*);
-
-QString QGtk::getGConfString(const QString &value, const QString &fallback)
-{
- QString retVal = fallback;
- if (resolveGConf()) {
- g_type_init();
- GConfClient* client = QGtk::gconf_client_get_default();
- GError *err = 0;
- char *str = QGtk::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 QGtk::getGConfBool(const QString &key, bool fallback)
-{
- bool retVal = fallback;
- if (resolveGConf()) {
- g_type_init();
- GConfClient* client = QGtk::gconf_client_get_default();
- GError *err = 0;
- bool result = QGtk::gconf_client_get_bool(client, qPrintable(key), &err);
- g_object_unref(client);
- if (!err)
- retVal = result;
- else
- g_error_free (err);
- }
- return retVal;
-}
-
-static QString getThemeName()
-{
- QString themeName;
- // We try to parse the gtkrc file first
- // primarily to avoid resolving Gtk functions if
- // the KDE 3 "Qt" style is currently in use
- QString rcPaths = QString::fromLocal8Bit(qgetenv("GTK2_RC_FILES"));
- if (!rcPaths.isEmpty()) {
- QStringList paths = rcPaths.split(QLS(":"));
- foreach (const QString &rcPath, paths) {
- if (!rcPath.isEmpty()) {
- QFile rcFile(rcPath);
- if (rcFile.exists() && rcFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
- QTextStream in(&rcFile);
- while(!in.atEnd()) {
- QString line = in.readLine();
- if (line.contains(QLS("gtk-theme-name"))) {
- line = line.right(line.length() - line.indexOf(QLatin1Char('=')) - 1);
- line.remove(QLatin1Char('\"'));
- line = line.trimmed();
- themeName = line;
- break;
- }
- }
- }
- }
- if (!themeName.isEmpty())
- break;
- }
- }
-
- // Fall back to gconf
- if (themeName.isEmpty() && resolveGConf())
- themeName = QGtk::getGConfString(QLS("/desktop/gnome/interface/gtk_theme"));
-
- return themeName;
-}
-
-static void init_gtk_window()
-{
- static QString themeName;
- if (!gtkWidgetMap()->contains(QLS("GtkWindow")) && themeName.isEmpty()) {
- themeName = getThemeName();
-
- if (themeName.isEmpty()) {
- qWarning("QGtkStyle was unable to detect the current GTK+ theme.");
- return;
- } else if (themeName == QLS("Qt") || themeName == QLS("Qt4")) {
- // Due to namespace conflicts with Qt3 and obvious recursion with Qt4,
- // we cannot support the GTK_Qt Gtk engine
- qWarning("QGtkStyle cannot be used together with the GTK_Qt engine.");
- return;
- }
-
- resolveGtk();
-
- if (QGtk::gtk_init) {
- // Gtk will set the Qt error handler so we have to reset it afterwards
- x11ErrorHandler qt_x_errhandler = XSetErrorHandler(0);
- QGtk::gtk_init (NULL, NULL);
- XSetErrorHandler(qt_x_errhandler);
-
- GtkWidget* gtkWindow = QGtk::gtk_window_new(GTK_WINDOW_POPUP);
- QGtk::gtk_widget_realize(gtkWindow);
- if (displayDepth == -1)
- displayDepth = QGtk::gdk_drawable_get_depth(gtkWindow->window);
- gtkWidgetMap()->insert(QLS("GtkWindow"), gtkWindow);
- } else {
- qWarning("QGtkStyle could not resolve GTK. Make sure you have installed the proper libraries.");
- }
- }
-}
-
-static void setup_gtk_widget(GtkWidget* widget)
-{
- if (Q_GTK_IS_WIDGET(widget)) {
- static GtkWidget* protoLayout = 0;
- if (!protoLayout) {
- protoLayout = QGtk::gtk_fixed_new();
- QGtk::gtk_container_add((GtkContainer*)(gtkWidgetMap()->value(QLS("GtkWindow"))), protoLayout);
- }
- Q_ASSERT(protoLayout);
-
- QGtk::gtk_container_add((GtkContainer*)(protoLayout), widget);
- QGtk::gtk_widget_realize(widget);
- }
-}
-
-static void add_widget_to_map(GtkWidget *widget)
-{
- if (Q_GTK_IS_WIDGET(widget)) {
- QGtk::gtk_widget_realize(widget);
- gtkWidgetMap()->insert(classPath(widget), widget);
- }
- }
-
-static void add_all_sub_widgets(GtkWidget *widget, gpointer v = 0)
-{
- Q_UNUSED(v);
- add_widget_to_map(widget);
- if (GTK_CHECK_TYPE ((widget), Q_GTK_TYPE_CONTAINER))
- QGtk::gtk_container_forall((GtkContainer*)widget, add_all_sub_widgets, NULL);
-}
-
-static void init_gtk_menu()
-{
- // Create menubar
- GtkWidget *gtkMenuBar = QGtk::gtk_menu_bar_new();
- setup_gtk_widget(gtkMenuBar);
-
- GtkWidget *gtkMenuBarItem = QGtk::gtk_menu_item_new();
- QGtk::gtk_menu_shell_append((GtkMenuShell*)(gtkMenuBar), gtkMenuBarItem);
- QGtk::gtk_widget_realize(gtkMenuBarItem);
-
- // Create menu
- GtkWidget *gtkMenu = QGtk::gtk_menu_new();
- QGtk::gtk_menu_item_set_submenu((GtkMenuItem*)(gtkMenuBarItem), gtkMenu);
- QGtk::gtk_widget_realize(gtkMenu);
-
- GtkWidget *gtkMenuItem = QGtk::gtk_menu_item_new();
- QGtk::gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkMenuItem);
- QGtk::gtk_widget_realize(gtkMenuItem);
-
- GtkWidget *gtkCheckMenuItem = QGtk::gtk_check_menu_item_new();
- QGtk::gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkCheckMenuItem);
- QGtk::gtk_widget_realize(gtkCheckMenuItem);
-
- GtkWidget *gtkMenuSeparator = QGtk::gtk_separator_menu_item_new();
- QGtk::gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkMenuSeparator);
-
- add_all_sub_widgets(gtkMenuBar);
- add_all_sub_widgets(gtkMenu);
-}
-
-// Updates window/windowtext palette based on the indicated gtk widget
-static QPalette gtkWidgetPalette(const QString &gtkWidgetName)
-{
- GtkWidget *gtkWidget = QGtk::gtkWidget(gtkWidgetName);
- Q_ASSERT(gtkWidget);
- QPalette pal = QApplication::palette();
- GdkColor gdkBg = gtkWidget->style->bg[GTK_STATE_NORMAL];
- GdkColor gdkText = gtkWidget->style->fg[GTK_STATE_NORMAL];
- GdkColor gdkDisabledText = gtkWidget->style->fg[GTK_STATE_INSENSITIVE];
- 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;
-}
-
-bool QGtk::isKDE4Session()
-{
- static int version = -1;
- if (version == -1)
- version = qgetenv("KDE_SESSION_VERSION").toInt();
- return (version == 4);
-}
-
-void QGtk::applyCustomPaletteHash()
-{
- QPalette menuPal = gtkWidgetPalette(QLS("GtkMenu"));
- GdkColor gdkBg = QGtk::gtkWidget(QLS("GtkMenu"))->style->bg[GTK_STATE_NORMAL];
- QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
- menuPal.setBrush(QPalette::Base, bgColor);
- menuPal.setBrush(QPalette::Window, bgColor);
- qApp->setPalette(menuPal, "QMenu");
-
- QPalette toolbarPal = gtkWidgetPalette(QLS("GtkToolbar"));
- qApp->setPalette(toolbarPal, "QToolBar");
-
- QPalette menuBarPal = gtkWidgetPalette(QLS("GtkMenuBar"));
- qApp->setPalette(menuBarPal, "QMenuBar");
-}
-
-static void gtkStyleSetCallback(GtkWidget*, GtkStyle*, void*)
-{
- // We have to let this function return and complete the event
- // loop to ensure that all gtk widgets have been styled before
- // updating
- QMetaObject::invokeMethod(styleScheduler(), "updateTheme", Qt::QueuedConnection);
-}
-
-void QGtkStyleUpdateScheduler::updateTheme()
-{
- static QString oldTheme(QLS("qt_not_set"));
- QPixmapCache::clear();
-
- QFont font = QGtk::getThemeFont();
- if (QApplication::font() != font)
- qApp->setFont(font);
-
- if (oldTheme != getThemeName()) {
- oldTheme = getThemeName();
- QPalette newPalette = qApp->style()->standardPalette();
- QApplicationPrivate::setSystemPalette(newPalette);
- QApplication::setPalette(newPalette);
- QGtk::initGtkWidgets();
- QGtk::applyCustomPaletteHash();
- QList<QWidget*> widgets = QApplication::allWidgets();
- // Notify all widgets that size metrics might have changed
- foreach (QWidget *widget, widgets) {
- QEvent e(QEvent::StyleChange);
- QApplication::sendEvent(widget, &e);
- }
- }
- QIconLoader::instance()->updateSystemTheme();
-}
-
-static void add_widget(GtkWidget *widget)
-{
- if (widget) {
- setup_gtk_widget(widget);
- add_all_sub_widgets(widget);
- }
-}
-
-static void init_gtk_treeview()
-{
- GtkWidget *gtkTreeView = QGtk::gtk_tree_view_new();
- QGtk::gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, QGtk::gtk_tree_view_column_new());
- QGtk::gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, QGtk::gtk_tree_view_column_new());
- QGtk::gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, QGtk::gtk_tree_view_column_new());
- add_widget(gtkTreeView);
-}
-
-
-// Fetch the application font from the pango font description
-// contained in the theme.
-QFont QGtk::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);
-
- int weight = pango_font_description_get_weight(gtk_font);
- if (weight >= PANGO_WEIGHT_HEAVY)
- font.setWeight(QFont::Black);
- else if (weight >= PANGO_WEIGHT_BOLD)
- font.setWeight(QFont::Bold);
- else if (weight >= PANGO_WEIGHT_SEMIBOLD)
- font.setWeight(QFont::DemiBold);
- else if (weight >= PANGO_WEIGHT_NORMAL)
- font.setWeight(QFont::Normal);
- else
- font.setWeight(QFont::Light);
-
- 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;
-}
-
-GtkWidget* QGtk::gtkWidget(const QString &path)
-{
- GtkWidget *widget = gtkWidgetMap()->value(path);
- if (!widget) {
- // Theme might have rearranged widget internals
- widget = gtkWidgetMap()->value(path);
- }
- return widget;
-}
-
-GtkStyle* QGtk::gtkStyle(const QString &path)
-{
- if (gtkWidgetMap()->contains(path))
- return gtkWidgetMap()->value(path)->style;
- return 0;
-}
-
-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);
- }
- }
-}
-
-void QGtk::initGtkWidgets()
-{
- // 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;
- }
-
- init_gtk_window();
-
- if (QGtk::gtk_init) {
-
- // Make all widgets respect the text direction
- if (qApp->layoutDirection() == Qt::RightToLeft)
- QGtk::gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL);
-
- if (!gtkWidgetMap()->contains(QLS("GtkButton"))) {
- GtkWidget *gtkButton = QGtk::gtk_button_new();
- add_widget(gtkButton);
- g_signal_connect(gtkButton, "style-set", G_CALLBACK(gtkStyleSetCallback), NULL);
- add_widget(QGtk::gtk_tool_button_new(NULL, NULL));
- add_widget(QGtk::gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE));
- add_widget(QGtk::gtk_hbutton_box_new());
- add_widget(QGtk::gtk_check_button_new());
- add_widget(QGtk::gtk_radio_button_new(NULL));
- add_widget(QGtk::gtk_combo_box_new());
- add_widget(QGtk::gtk_combo_box_entry_new());
- add_widget(QGtk::gtk_entry_new());
- add_widget(QGtk::gtk_frame_new(NULL));
- add_widget(QGtk::gtk_expander_new(""));
- add_widget(QGtk::gtk_statusbar_new());
- add_widget(QGtk::gtk_hscale_new((GtkAdjustment*)(QGtk::gtk_adjustment_new(1, 0, 1, 0, 0, 0))));
- add_widget(QGtk::gtk_hscrollbar_new(NULL));
- add_widget(QGtk::gtk_scrolled_window_new(NULL, NULL));
- init_gtk_menu();
- add_widget(QGtk::gtk_notebook_new());
- add_widget(QGtk::gtk_progress_bar_new());
- add_widget(QGtk::gtk_spin_button_new((GtkAdjustment*)
- (QGtk::gtk_adjustment_new(1, 0, 1, 0, 0, 0)), 0.1, 3));
- GtkWidget *toolbar = QGtk::gtk_toolbar_new();
- g_signal_connect (toolbar, "notify::toolbar-style", G_CALLBACK (update_toolbar_style), toolbar);
- QGtk::gtk_toolbar_insert((GtkToolbar*)toolbar, QGtk::gtk_separator_tool_item_new(), -1);
- add_widget(toolbar);
- init_gtk_treeview();
- add_widget(QGtk::gtk_vscale_new((GtkAdjustment*)(QGtk::gtk_adjustment_new(1, 0, 1, 0, 0, 0))));
- add_widget(QGtk::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<QString, GtkWidget*> oldMap = *gtkWidgetMap();
- gtkWidgetMap()->clear();
- QHashIterator<QString, GtkWidget*> it(oldMap);
- while (it.hasNext()) {
- it.next();
- if (!it.key().contains(QLatin1Char('.'))) {
- add_all_sub_widgets(it.value());
- }
- }
- }
- }
-}
-
-// ----------- Native file dialogs -----------
-
-// Extract filter list from expressions of type: foo (*.a *.b *.c)"
-static QStringList extract_filter(const QString &rawFilter)
-{
- QString result = rawFilter;
- QRegExp r(QString::fromLatin1("^([^()]*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$"));
- int index = r.indexIn(result);
- if (index >= 0)
- result = r.cap(2);
- return result.split(QLatin1Char(' '));
-}
-
-extern QStringList qt_make_filter_list(const QString &filter);
-
-static void setupGtkFileChooser(GtkWidget* gtkFileChooser, QWidget *parent,
- const QString &dir, const QString &filter, QString *selectedFilter,
- QFileDialog::Options options, bool isSaveDialog = false,
- QMap<GtkFileFilter *, QString> *filterMap = 0)
-{
- g_object_set(gtkFileChooser, "do-overwrite-confirmation", gboolean(!(options & QFileDialog::DontConfirmOverwrite)), NULL);
- g_object_set(gtkFileChooser, "local_only", gboolean(true), NULL);
- if (!filter.isEmpty()) {
- QStringList filters = qt_make_filter_list(filter);
- foreach (const QString &rawfilter, filters) {
- GtkFileFilter *gtkFilter = QGtk::gtk_file_filter_new ();
- QString name = rawfilter.left(rawfilter.indexOf(QLatin1Char('(')));
- QStringList extensions = extract_filter(rawfilter);
- QGtk::gtk_file_filter_set_name(gtkFilter, qPrintable(name.isEmpty() ? extensions.join(QLS(", ")) : name));
-
- foreach (const QString &fileExtension, extensions) {
- // Note Gtk file dialogs are by default case sensitive
- // and only supports basic glob syntax so we
- // rewrite .xyz to .[xX][yY][zZ]
- QString caseInsensitive;
- for (int i = 0 ; i < fileExtension.length() ; ++i) {
- QChar ch = fileExtension.at(i);
- if (ch.isLetter()) {
- caseInsensitive.append(
- QLatin1Char('[') +
- ch.toLower() +
- ch.toUpper() +
- QLatin1Char(']'));
- } else {
- caseInsensitive.append(ch);
- }
- }
- QGtk::gtk_file_filter_add_pattern (gtkFilter, qPrintable(caseInsensitive));
-
- }
- if (filterMap)
- filterMap->insert(gtkFilter, rawfilter);
- QGtk::gtk_file_chooser_add_filter((GtkFileChooser*)gtkFileChooser, gtkFilter);
- if (selectedFilter && (rawfilter == *selectedFilter))
- QGtk::gtk_file_chooser_set_filter((GtkFileChooser*)gtkFileChooser, gtkFilter);
- }
- }
-
- // Using the currently active window is not entirely correct, however
- // it gives more sensible behavior for applications that do not provide a
- // parent
- QWidget *modalFor = parent ? parent->window() : qApp->activeWindow();
- if (modalFor) {
- QGtk::gtk_widget_realize(gtkFileChooser); // Creates X window
- XSetTransientForHint(QGtk::gdk_x11_drawable_get_xdisplay(gtkFileChooser->window),
- QGtk::gdk_x11_drawable_get_xid(gtkFileChooser->window),
- modalFor->winId());
- QGtk::gdk_x11_window_set_user_time (gtkFileChooser->window, QX11Info::appUserTime());
-
- }
-
- QFileInfo fileinfo(dir);
- if (dir.isEmpty())
- fileinfo.setFile(QDir::currentPath());
- fileinfo.makeAbsolute();
- if (fileinfo.isDir()) {
- QGtk::gtk_file_chooser_set_current_folder((GtkFileChooser*)gtkFileChooser, qPrintable(dir));
- } else if (isSaveDialog) {
- QGtk::gtk_file_chooser_set_current_folder((GtkFileChooser*)gtkFileChooser, qPrintable(fileinfo.absolutePath()));
- QGtk::gtk_file_chooser_set_current_name((GtkFileChooser*)gtkFileChooser, qPrintable(fileinfo.fileName()));
- } else {
- QGtk::gtk_file_chooser_set_filename((GtkFileChooser*)gtkFileChooser, qPrintable(dir));
- }
-}
-
-QString QGtk::openFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
- QString *selectedFilter, QFileDialog::Options options)
-{
- QMap<GtkFileFilter *, QString> filterMap;
- GtkWidget *gtkFileChooser = QGtk::gtk_file_chooser_dialog_new (qPrintable(caption),
- NULL,
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL);
-
- setupGtkFileChooser(gtkFileChooser, parent, dir, filter, selectedFilter, options, false, &filterMap);
-
- QWidget modal_widget;
- modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
- modal_widget.setParent(parent, Qt::Window);
- QApplicationPrivate::enterModal(&modal_widget);
-
- QString filename;
- if (QGtk::gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
- char *gtk_filename = QGtk::gtk_file_chooser_get_filename ((GtkFileChooser*)gtkFileChooser);
- filename = QString::fromUtf8(gtk_filename);
- g_free (gtk_filename);
- if (selectedFilter) {
- GtkFileFilter *gtkFilter = QGtk::gtk_file_chooser_get_filter ((GtkFileChooser*)gtkFileChooser);
- *selectedFilter = filterMap.value(gtkFilter);
- }
- }
-
- QApplicationPrivate::leaveModal(&modal_widget);
- gtk_widget_destroy (gtkFileChooser);
- return filename;
-}
-
-
-QString QGtk::openDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options)
-{
- QMap<GtkFileFilter *, QString> filterMap;
- GtkWidget *gtkFileChooser = QGtk::gtk_file_chooser_dialog_new (qPrintable(caption),
- NULL,
- GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL);
-
- setupGtkFileChooser(gtkFileChooser, parent, dir, QString(), 0, options);
- QWidget modal_widget;
- modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
- modal_widget.setParent(parent, Qt::Window);
- QApplicationPrivate::enterModal(&modal_widget);
-
- QString filename;
- if (QGtk::gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
- char *gtk_filename = QGtk::gtk_file_chooser_get_filename ((GtkFileChooser*)gtkFileChooser);
- filename = QString::fromUtf8(gtk_filename);
- g_free (gtk_filename);
- }
-
- QApplicationPrivate::leaveModal(&modal_widget);
- gtk_widget_destroy (gtkFileChooser);
- return filename;
-}
-
-QStringList QGtk::openFilenames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
- QString *selectedFilter, QFileDialog::Options options)
-{
- QStringList filenames;
- QMap<GtkFileFilter *, QString> filterMap;
- GtkWidget *gtkFileChooser = QGtk::gtk_file_chooser_dialog_new (qPrintable(caption),
- NULL,
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL);
-
- setupGtkFileChooser(gtkFileChooser, parent, dir, filter, selectedFilter, options, false, &filterMap);
- g_object_set(gtkFileChooser, "select-multiple", gboolean(true), NULL);
-
- QWidget modal_widget;
- modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
- modal_widget.setParent(parent, Qt::Window);
- QApplicationPrivate::enterModal(&modal_widget);
-
- if (gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
- GSList *gtk_file_names = QGtk::gtk_file_chooser_get_filenames((GtkFileChooser*)gtkFileChooser);
- for (GSList *iterator = gtk_file_names ; iterator; iterator = iterator->next)
- filenames << QString::fromUtf8((const char*)iterator->data);
- g_slist_free(gtk_file_names);
- if (selectedFilter) {
- GtkFileFilter *gtkFilter = QGtk::gtk_file_chooser_get_filter ((GtkFileChooser*)gtkFileChooser);
- *selectedFilter = filterMap.value(gtkFilter);
- }
- }
-
- QApplicationPrivate::leaveModal(&modal_widget);
- gtk_widget_destroy (gtkFileChooser);
- return filenames;
-}
-
-QString QGtk::saveFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
- QString *selectedFilter, QFileDialog::Options options)
-{
- QMap<GtkFileFilter *, QString> filterMap;
- GtkWidget *gtkFileChooser = QGtk::gtk_file_chooser_dialog_new (qPrintable(caption),
- NULL,
- GTK_FILE_CHOOSER_ACTION_SAVE,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
- NULL);
- setupGtkFileChooser(gtkFileChooser, parent, dir, filter, selectedFilter, options, true, &filterMap);
-
- QWidget modal_widget;
- modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
- modal_widget.setParent(parent, Qt::Window);
- QApplicationPrivate::enterModal(&modal_widget);
-
- QString filename;
- if (QGtk::gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
- char *gtk_filename = QGtk::gtk_file_chooser_get_filename ((GtkFileChooser*)gtkFileChooser);
- filename = QString::fromUtf8(gtk_filename);
- g_free (gtk_filename);
- if (selectedFilter) {
- GtkFileFilter *gtkFilter = QGtk::gtk_file_chooser_get_filter ((GtkFileChooser*)gtkFileChooser);
- *selectedFilter = filterMap.value(gtkFilter);
- }
- }
-
- QApplicationPrivate::leaveModal(&modal_widget);
- gtk_widget_destroy (gtkFileChooser);
- return filename;
-}
-
-QIcon QGtk::getFilesystemIcon(const QFileInfo &info)
-{
- QIcon icon;
- if (QGtk::gnome_vfs_init && QGtk::gnome_icon_lookup_sync) {
- QGtk::gnome_vfs_init();
- GtkIconTheme *theme = QGtk::gtk_icon_theme_get_default();
- QByteArray fileurl = QUrl::fromLocalFile(info.absoluteFilePath()).toEncoded();
- char * icon_name = QGtk::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;
-}
-
-QT_END_NAMESPACE
-
-#endif // !defined(QT_NO_STYLE_GTK)
diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp
index fc12cfe..973e682 100644
--- a/src/gui/styles/qcleanlooksstyle.cpp
+++ b/src/gui/styles/qcleanlooksstyle.cpp
@@ -3825,6 +3825,7 @@ QSize QCleanlooksStyle::sizeFromContents(ContentsType type, const QStyleOption *
}
}
break;
+#ifndef QT_NO_GROUPBOX
case CT_GroupBox:
// Since we use a bold font we have to recalculate base width
if (const QGroupBox *gb = qobject_cast<const QGroupBox*>(widget)) {
@@ -3840,6 +3841,7 @@ QSize QCleanlooksStyle::sizeFromContents(ContentsType type, const QStyleOption *
}
newSize += QSize(0, 1);
break;
+#endif //QT_NO_GROUPBOX
case CT_RadioButton:
case CT_CheckBox:
newSize += QSize(0, 1);
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index 84e046f..4c9541b 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -4661,7 +4661,7 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid
case PM_ToolBarIconSize:
ret = qt_guiPlatformPlugin()->platformHint(QGuiPlatformPlugin::PH_ToolBarIconSize);
if (!ret)
- ret = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
+ ret = int(QStyleHelper::dpiScaled(24.));
break;
case PM_TabBarIconSize:
@@ -5169,13 +5169,12 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget
QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *option,
const QWidget *widget) const
{
+ const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QApplication::isRightToLeft());
#ifdef QT_NO_IMAGEFORMAT_PNG
- Q_UNUSED(option);
Q_UNUSED(widget);
Q_UNUSED(sp);
#else
QPixmap pixmap;
- const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QApplication::isRightToLeft());
if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) {
switch (sp) {
diff --git a/src/gui/styles/qcommonstyle_p.h b/src/gui/styles/qcommonstyle_p.h
index a905601..6122f81 100644
--- a/src/gui/styles/qcommonstyle_p.h
+++ b/src/gui/styles/qcommonstyle_p.h
@@ -62,25 +62,6 @@ QT_BEGIN_NAMESPACE
class QStringList;
-#ifdef Q_WS_X11
-class QIconTheme
-{
-public:
- QIconTheme(QHash <int, QString> dirList, QStringList parents) :
- _dirList(dirList), _parents(parents), _valid(true){ }
- QIconTheme() : _valid(false){ }
-
- QHash <int, QString> dirList() {return _dirList;}
- QStringList parents() {return _parents;}
- bool isValid() {return _valid;}
-
-private:
- QHash <int, QString> _dirList;
- QStringList _parents;
- bool _valid;
-};
-#endif
-
// Private class
class QCommonStylePrivate : public QStylePrivate
{
diff --git a/src/gui/styles/qgtkpainter.cpp b/src/gui/styles/qgtkpainter.cpp
index 05c5804..aaa029a 100644
--- a/src/gui/styles/qgtkpainter.cpp
+++ b/src/gui/styles/qgtkpainter.cpp
@@ -108,41 +108,41 @@ QPixmap QGtkPainter::renderTheme(uchar *bdata, uchar *wdata, const QRect &rect)
return; \
QRect pixmapRect(0, 0, rect.width(), rect.height()); \
{ \
- GdkPixmap *pixmap = QGtk::gdk_pixmap_new((GdkDrawable*)(m_window->window), \
+ GdkPixmap *pixmap = QGtkStylePrivate::gdk_pixmap_new((GdkDrawable*)(m_window->window), \
rect.width(), rect.height(), -1); \
if (!pixmap) \
return; \
- style = QGtk::gtk_style_attach (style, m_window->window); \
- QGtk::gdk_draw_rectangle(pixmap, m_alpha ? style->black_gc : *style->bg_gc, true, \
+ style = QGtkStylePrivate::gtk_style_attach (style, m_window->window); \
+ QGtkStylePrivate::gdk_draw_rectangle(pixmap, m_alpha ? style->black_gc : *style->bg_gc, true, \
0, 0, rect.width(), rect.height()); \
draw_func; \
- GdkPixbuf *imgb = QGtk::gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, rect.width(), rect.height());\
+ GdkPixbuf *imgb = QGtkStylePrivate::gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, rect.width(), rect.height());\
if (!imgb) \
return; \
- imgb = QGtk::gdk_pixbuf_get_from_drawable(imgb, pixmap, NULL, 0, 0, 0, 0, \
+ imgb = QGtkStylePrivate::gdk_pixbuf_get_from_drawable(imgb, pixmap, NULL, 0, 0, 0, 0, \
rect.width(), rect.height()); \
- uchar* bdata = (uchar*)QGtk::gdk_pixbuf_get_pixels(imgb); \
+ uchar* bdata = (uchar*)QGtkStylePrivate::gdk_pixbuf_get_pixels(imgb); \
if (m_alpha) { \
- QGtk::gdk_draw_rectangle(pixmap, style->white_gc, true, 0, 0, rect.width(), rect.height()); \
+ QGtkStylePrivate::gdk_draw_rectangle(pixmap, style->white_gc, true, 0, 0, rect.width(), rect.height()); \
draw_func; \
- GdkPixbuf *imgw = QGtk::gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, rect. \
+ GdkPixbuf *imgw = QGtkStylePrivate::gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, rect. \
width(), rect.height()); \
if (!imgw) \
return; \
- imgw = QGtk::gdk_pixbuf_get_from_drawable(imgw, pixmap, NULL, 0, 0, 0, 0, \
+ imgw = QGtkStylePrivate::gdk_pixbuf_get_from_drawable(imgw, pixmap, NULL, 0, 0, 0, 0, \
rect.width(), rect.height()); \
- uchar* wdata = (uchar*)QGtk::gdk_pixbuf_get_pixels(imgw); \
+ uchar* wdata = (uchar*)QGtkStylePrivate::gdk_pixbuf_get_pixels(imgw); \
cache = renderTheme(bdata, wdata, rect); \
- QGtk::gdk_pixbuf_unref(imgw); \
+ QGtkStylePrivate::gdk_pixbuf_unref(imgw); \
} else { \
cache = renderTheme(bdata, 0, rect); \
} \
- QGtk::gdk_drawable_unref(pixmap); \
- QGtk::gdk_pixbuf_unref(imgb); \
+ QGtkStylePrivate::gdk_drawable_unref(pixmap); \
+ QGtkStylePrivate::gdk_pixbuf_unref(imgb); \
}
QGtkPainter::QGtkPainter(QPainter *_painter)
- : m_window(QGtk::gtkWidget(QLatin1String("GtkWindow")))
+ : m_window(QGtkStylePrivate::gtkWidget(QLatin1String("GtkWindow")))
, m_painter(_painter)
, m_alpha(true)
, m_hflipped(false)
@@ -185,18 +185,18 @@ GtkStyle* QGtkPainter::getStyle(GtkWidget *gtkWidget)
QPixmap QGtkPainter::getIcon(const char* iconName, GtkIconSize size)
{
- GtkStyle *style = QGtk::gtkStyle();
- GtkIconSet* iconSet = QGtk::gtk_icon_factory_lookup_default (iconName);
- GdkPixbuf* icon = QGtk::gtk_icon_set_render_icon(iconSet,
+ 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*)QGtk::gdk_pixbuf_get_pixels(icon);
- int width = QGtk::gdk_pixbuf_get_width(icon);
- int height = QGtk::gdk_pixbuf_get_height(icon);
+ 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();
@@ -208,7 +208,7 @@ QPixmap QGtkPainter::getIcon(const char* iconName, GtkIconSize size)
tdata[index + QT_ALPHA] = data[index + GTK_ALPHA];
}
- QGtk::gdk_pixbuf_unref(icon);
+ QGtkStylePrivate::gdk_pixbuf_unref(icon);
// should we free iconset?
return QPixmap::fromImage(converted);
@@ -240,7 +240,7 @@ void QGtkPainter::paintBoxGap(GtkWidget *gtkWidget, const gchar* part,
QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) + gapExtras;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk::gtk_paint_box_gap (style,
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_box_gap (style,
pixmap,
state,
shadow,
@@ -305,7 +305,7 @@ void QGtkPainter::paintBox(GtkWidget *gtkWidget, const gchar* part,
rect.size(), gtkWidget) + pmKey;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk::gtk_paint_box (style,
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_box (style,
pixmap,
state,
shadow,
@@ -356,7 +356,7 @@ void QGtkPainter::paintHline(GtkWidget *gtkWidget, const gchar* part,
QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
+ hLineExtras + pmKey;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk::gtk_paint_hline (style,
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_hline (style,
pixmap,
state,
NULL,
@@ -383,7 +383,7 @@ void QGtkPainter::paintVline(GtkWidget *gtkWidget, const gchar* part,
QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(),
gtkWidget) + vLineExtras +pmKey;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk::gtk_paint_vline (style,
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_vline (style,
pixmap,
state,
NULL,
@@ -410,7 +410,7 @@ void QGtkPainter::paintExpander(GtkWidget *gtkWidget,
QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(),
gtkWidget) + QString::number(expander_state) + pmKey;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk::gtk_paint_expander (style, pixmap,
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_expander (style, pixmap,
state, NULL,
gtkWidget, part,
rect.width()/2,
@@ -433,7 +433,7 @@ void QGtkPainter::paintFocus(GtkWidget *gtkWidget, const gchar* part,
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(QGtk::gtk_paint_focus (style, pixmap, state, NULL,
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_focus (style, pixmap, state, NULL,
gtkWidget,
part,
0, 0,
@@ -458,7 +458,7 @@ void QGtkPainter::paintResizeGrip(GtkWidget *gtkWidget, const gchar* part,
QPixmap cache;
QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) + pmKey;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk::gtk_paint_resize_grip (style, pixmap, state,
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_resize_grip (style, pixmap, state,
NULL, gtkWidget,
part, edge, 0, 0,
rect.width(),
@@ -488,7 +488,7 @@ void QGtkPainter::paintArrow(GtkWidget *gtkWidget, const gchar* part,
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(QGtk::gtk_paint_arrow (style, pixmap, state, shadow,
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_arrow (style, pixmap, state, shadow,
&gtkCliprect,
gtkWidget,
part,
@@ -515,7 +515,7 @@ void QGtkPainter::paintHandle(GtkWidget *gtkWidget, const gchar* part, const QRe
QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size())
+ QString::number(orientation);
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk::gtk_paint_handle (style,
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_handle (style,
pixmap,
state,
shadow,
@@ -543,7 +543,7 @@ void QGtkPainter::paintSlider(GtkWidget *gtkWidget, const gchar* part, const QRe
QPixmap cache;
QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) + pmKey;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk::gtk_paint_slider (style,
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_slider (style,
pixmap,
state,
shadow,
@@ -574,7 +574,7 @@ void QGtkPainter::paintShadow(GtkWidget *gtkWidget, const gchar* part,
QPixmap cache;
QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) + pmKey;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk::gtk_paint_shadow(style, pixmap, state, shadow, NULL,
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_shadow(style, pixmap, state, shadow, NULL,
gtkWidget, part, 0, 0, rect.width(), rect.height()));
if (m_usePixmapCache)
QPixmapCache::insert(pixmapName, cache);
@@ -593,7 +593,7 @@ void QGtkPainter::paintFlatBox(GtkWidget *gtkWidget, const gchar* part,
QPixmap cache;
QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) + pmKey;
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk::gtk_paint_flat_box (style,
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_flat_box (style,
pixmap,
state,
shadow,
@@ -622,7 +622,7 @@ void QGtkPainter::paintExtention(GtkWidget *gtkWidget,
pixmapName += QString::number(gap_pos);
if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtk::gtk_paint_extension (style, pixmap, state, shadow,
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_extension (style, pixmap, state, shadow,
NULL, gtkWidget,
(gchar*)part, 0, 0,
rect.width(),
@@ -651,7 +651,7 @@ void QGtkPainter::paintOption(GtkWidget *gtkWidget, const QRect &radiorect,
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(QGtk::gtk_paint_option(style, pixmap,
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_option(style, pixmap,
state, shadow,
&gtkCliprect,
gtkWidget,
@@ -683,7 +683,7 @@ void QGtkPainter::paintCheckbox(GtkWidget *gtkWidget, const QRect &checkrect,
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(QGtk::gtk_paint_check (style,
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_check (style,
pixmap,
state,
shadow,
diff --git a/src/gui/styles/qgtkpainter_p.h b/src/gui/styles/qgtkpainter_p.h
index 0e8ffe2..cbc96c0 100644
--- a/src/gui/styles/qgtkpainter_p.h
+++ b/src/gui/styles/qgtkpainter_p.h
@@ -56,11 +56,11 @@
#include <QtCore/qglobal.h>
#if !defined(QT_NO_STYLE_GTK)
-#include "gtksymbols_p.h"
#include <QtGui/QCleanlooksStyle>
#include <QtGui/QPainter>
#include <QtGui/QPalette>
#include <QtGui/QFont>
+#include <private/qgtkstyle_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp
index a7c291b..1c78a47 100644
--- a/src/gui/styles/qgtkstyle.cpp
+++ b/src/gui/styles/qgtkstyle.cpp
@@ -69,28 +69,14 @@
#include <QtGui/QTreeView>
#include <qpixmapcache.h>
#undef signals // Collides with GTK stymbols
-#include "qgtkpainter_p.h"
-#include "qstylehelper_p.h"
-
+#include <private/qgtkpainter_p.h>
+#include <private/qstylehelper_p.h>
+#include <private/qgtkstyle_p.h>
#include <private/qcleanlooksstyle_p.h>
QT_BEGIN_NAMESPACE
-typedef QStringList (*_qt_filedialog_open_filenames_hook)(QWidget * parent, const QString &caption, const QString &dir,
- const QString &filter, QString *selectedFilter, QFileDialog::Options options);
-typedef QString (*_qt_filedialog_open_filename_hook) (QWidget * parent, const QString &caption, const QString &dir,
- const QString &filter, QString *selectedFilter, QFileDialog::Options options);
-typedef QString (*_qt_filedialog_save_filename_hook) (QWidget * parent, const QString &caption, const QString &dir,
- const QString &filter, QString *selectedFilter, QFileDialog::Options options);
-typedef QString (*_qt_filedialog_existing_directory_hook)(QWidget *parent, const QString &caption, const QString &dir,
- QFileDialog::Options options);
-
-extern Q_GUI_EXPORT _qt_filedialog_open_filename_hook qt_filedialog_open_filename_hook;
-extern Q_GUI_EXPORT _qt_filedialog_open_filenames_hook qt_filedialog_open_filenames_hook;
-extern Q_GUI_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook;
-extern Q_GUI_EXPORT _qt_filedialog_existing_directory_hook qt_filedialog_existing_directory_hook;
-
static const char * const dock_widget_close_xpm[] =
{
"11 13 5 1",
@@ -137,57 +123,18 @@ static const char * const dock_widget_restore_xpm[] =
" "
};
-
-class QGtkStyleFilter : public QObject
-{
-public:
- QGtkStyleFilter() {}
-private:
- bool eventFilter(QObject *obj, QEvent *e);
-};
-
-bool QGtkStyleFilter::eventFilter(QObject *obj, QEvent *e)
-{
- if (e->type() == QEvent::ApplicationPaletteChange) {
- // Only do this the first time since this will also
- // generate applicationPaletteChange events
- if (!qt_app_palettes_hash() || qt_app_palettes_hash()->isEmpty()) {
- QGtk::applyCustomPaletteHash();
- }
- }
- return QObject::eventFilter(obj, e);
-}
-
-class QGtkStylePrivate : public QCleanlooksStylePrivate
-{
- Q_DECLARE_PUBLIC(QGtkStyle)
-public:
- QGtkStylePrivate()
- : QCleanlooksStylePrivate()
- {
- QGtk::initGtkWidgets();
- if (QGtk::isThemeAvailable())
- qApp->installEventFilter(&filter);
-
- }
- QGtkStyleFilter filter;
-};
-
static const int groupBoxBottomMargin = 2; // space below the groupbox
static const int groupBoxTitleMargin = 6; // space between contents and title
static const int groupBoxTopMargin = 2;
-// Get size of the arrow controls in a GtkSpinButton
-static int spinboxArrowSize()
+QString QGtkStyle::getGConfString(const QString &value, const QString &fallback)
+{
+ return QGtkStylePrivate::getGConfString(value, fallback);
+}
+
+bool QGtkStyle::getGConfBool(const QString &key, bool fallback)
{
- const int MIN_ARROW_WIDTH = 6;
- GtkWidget *spinButton = QGtk::gtkWidget(QLS("GtkSpinButton"));
- GtkStyle *style = spinButton->style;
- gint size = QGtk::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;
+ return QGtkStylePrivate::getGConfBool(key, fallback);
}
static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50)
@@ -233,9 +180,24 @@ static GdkColor fromQColor(const QColor &color)
QGtkStyle::QGtkStyle()
: QCleanlooksStyle(*new QGtkStylePrivate)
{
+ Q_D(QGtkStyle);
+ d->init();
}
/*!
+ \internal
+
+ Constructs a QGtkStyle object.
+*/
+QGtkStyle::QGtkStyle(QGtkStylePrivate &dd)
+ : QCleanlooksStyle(dd)
+{
+ Q_D(QGtkStyle);
+ d->init();
+}
+
+
+/*!
Destroys the QGtkStyle object.
*/
QGtkStyle::~QGtkStyle()
@@ -247,11 +209,13 @@ QGtkStyle::~QGtkStyle()
*/
QPalette QGtkStyle::standardPalette() const
{
+ Q_D(const QGtkStyle);
+
QPalette palette = QCleanlooksStyle::standardPalette();
- if (QGtk::isThemeAvailable()) {
- GtkStyle *style = QGtk::gtkStyle();
- GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));
- GtkWidget *gtkEntry = QGtk::gtkWidget(QLS("GtkEntry"));
+ if (d->isThemeAvailable()) {
+ GtkStyle *style = d->gtkStyle();
+ GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
+ GtkWidget *gtkEntry = d->getTextColorWidget();
GdkColor gdkBg, gdkBase, gdkText, gdkForeground, gdkSbg, gdkSfg;
QColor bg, base, text, fg, highlight, highlightText;
@@ -281,12 +245,12 @@ QPalette QGtkStyle::standardPalette() const
palette.setColor(QPalette::Base, base);
QColor alternateRowColor = palette.base().color().lighter(93); // ref gtkstyle.c draw_flat_box
- GtkWidget *gtkTreeView = QGtk::gtkWidget(QLS("GtkTreeView"));
+ GtkWidget *gtkTreeView = d->gtkWidget(QLS("GtkTreeView"));
GdkColor *gtkAltBase = NULL;
- QGtk::gtk_widget_style_get(gtkTreeView, "odd-row-color", &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);
- QGtk::gdk_color_free(gtkAltBase);
+ d->gdk_color_free(gtkAltBase);
}
palette.setColor(QPalette::AlternateBase, alternateRowColor);
@@ -306,7 +270,8 @@ QPalette QGtkStyle::standardPalette() const
highlightText.setHsv(highlightText.hue(), 0, highlightText.value(), highlightText.alpha());
palette.setColor(QPalette::Disabled, QPalette::Highlight, highlight);
palette.setColor(QPalette::Disabled, QPalette::HighlightedText, highlightText);
- style = QGtk::gtk_rc_get_style_by_paths(QGtk::gtk_settings_get_default(), "gtk-tooltips", "GtkWindow", Q_GTK_TYPE_WINDOW);
+ 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);
@@ -321,10 +286,12 @@ QPalette QGtkStyle::standardPalette() const
*/
void QGtkStyle::polish(QPalette &palette)
{
+ Q_D(QGtkStyle);
+
// QCleanlooksStyle will alter the palette, hence we do
// not want to polish the palette unless we are using it as
// the fallback
- if (!QGtk::isThemeAvailable())
+ if (!d->isThemeAvailable())
QCleanlooksStyle::polish(palette);
else
palette = palette.resolve(standardPalette());
@@ -335,19 +302,21 @@ void QGtkStyle::polish(QPalette &palette)
*/
void QGtkStyle::polish(QApplication *app)
{
+ Q_D(QGtkStyle);
+
QCleanlooksStyle::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() && QGtk::isThemeAvailable()) {
+ if (app->desktopSettingsAware() && d->isThemeAvailable()) {
QApplicationPrivate::setSystemPalette(standardPalette());
- QApplicationPrivate::setSystemFont(QGtk::getThemeFont());
- QGtk::applyCustomPaletteHash();
- if (!QGtk::isKDE4Session()) {
- qt_filedialog_open_filename_hook = &QGtk::openFilename;
- qt_filedialog_save_filename_hook = &QGtk::saveFilename;
- qt_filedialog_open_filenames_hook = &QGtk::openFilenames;
- qt_filedialog_existing_directory_hook = &QGtk::openDirectory;
+ QApplicationPrivate::setSystemFont(d->getThemeFont());
+ d->applyCustomPaletteHash();
+ if (!d->isKDE4Session()) {
+ qt_filedialog_open_filename_hook = &QGtkStylePrivate::openFilename;
+ qt_filedialog_save_filename_hook = &QGtkStylePrivate::saveFilename;
+ qt_filedialog_open_filenames_hook = &QGtkStylePrivate::openFilenames;
+ qt_filedialog_existing_directory_hook = &QGtkStylePrivate::openDirectory;
}
}
}
@@ -357,11 +326,13 @@ void QGtkStyle::polish(QApplication *app)
*/
void QGtkStyle::unpolish(QApplication *app)
{
+ Q_D(QGtkStyle);
+
QCleanlooksStyle::unpolish(app);
QPixmapCache::clear();
- if (app->desktopSettingsAware() && QGtk::isThemeAvailable()
- && !QGtk::isKDE4Session()) {
+ if (app->desktopSettingsAware() && d->isThemeAvailable()
+ && !d->isKDE4Session()) {
qt_filedialog_open_filename_hook = 0;
qt_filedialog_save_filename_hook = 0;
qt_filedialog_open_filenames_hook = 0;
@@ -375,8 +346,10 @@ void QGtkStyle::unpolish(QApplication *app)
void QGtkStyle::polish(QWidget *widget)
{
+ Q_D(QGtkStyle);
+
QCleanlooksStyle::polish(widget);
- if (!QGtk::isThemeAvailable())
+ if (!d->isThemeAvailable())
return;
if (qobject_cast<QAbstractButton*>(widget)
|| qobject_cast<QToolButton*>(widget)
@@ -404,21 +377,22 @@ void QGtkStyle::unpolish(QWidget *widget)
\reimp
*/
int QGtkStyle::pixelMetric(PixelMetric metric,
-
const QStyleOption *option,
const QWidget *widget) const
{
- if (!QGtk::isThemeAvailable())
+ Q_D(const QGtkStyle);
+
+ if (!d->isThemeAvailable())
return QCleanlooksStyle::pixelMetric(metric, option, widget);
switch (metric) {
case PM_DefaultFrameWidth:
if (qobject_cast<const QFrame*>(widget)) {
if (GtkStyle *style =
- QGtk::gtk_rc_get_style_by_paths(QGtk::gtk_settings_get_default(),
+ d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(),
"*.GtkScrolledWindow",
"*.GtkScrolledWindow",
- Q_GTK_TYPE_WINDOW))
+ d->gtk_window_get_type()))
return qMax(style->xthickness, style->ythickness);
}
return 2;
@@ -439,16 +413,16 @@ int QGtkStyle::pixelMetric(PixelMetric metric,
return 0;
case PM_ButtonShiftHorizontal: {
- GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));
+ GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
guint horizontal_shift;
- QGtk::gtk_widget_style_get(gtkButton, "child-displacement-x", &horizontal_shift, NULL);
+ d->gtk_widget_style_get(gtkButton, "child-displacement-x", &horizontal_shift, NULL);
return horizontal_shift;
}
case PM_ButtonShiftVertical: {
- GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));
+ GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
guint vertical_shift;
- QGtk::gtk_widget_style_get(gtkButton, "child-displacement-y", &vertical_shift, NULL);
+ d->gtk_widget_style_get(gtkButton, "child-displacement-y", &vertical_shift, NULL);
return vertical_shift;
}
@@ -456,18 +430,18 @@ int QGtkStyle::pixelMetric(PixelMetric metric,
return 0;
case PM_MenuPanelWidth: {
- GtkWidget *gtkMenu = QGtk::gtkWidget(QLS("GtkMenu"));
+ GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu"));
guint horizontal_padding = 0;
// horizontal-padding is used by Maemo to get thicker borders
- if (!QGtk::gtk_check_version(2, 10, 0))
- QGtk::gtk_widget_style_get(gtkMenu, "horizontal-padding", &horizontal_padding, NULL);
+ if (!d->gtk_check_version(2, 10, 0))
+ d->gtk_widget_style_get(gtkMenu, "horizontal-padding", &horizontal_padding, NULL);
int padding = qMax<int>(gtkMenu->style->xthickness, horizontal_padding);
return padding;
}
case PM_ButtonIconSize: {
int retVal = 24;
- GtkSettings *settings = QGtk::gtk_settings_get_default();
+ 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(':'));
@@ -513,9 +487,9 @@ int QGtkStyle::pixelMetric(PixelMetric metric,
case PM_SliderThickness:
case PM_SliderControlThickness: {
- GtkWidget *gtkScale = QGtk::gtkWidget(QLS("GtkHScale"));
+ GtkWidget *gtkScale = d->gtkWidget(QLS("GtkHScale"));
gint val;
- QGtk::gtk_widget_style_get(gtkScale, "slider-width", &val, NULL);
+ d->gtk_widget_style_get(gtkScale, "slider-width", &val, NULL);
if (metric == PM_SliderControlThickness)
return val + 2*gtkScale->style->ythickness;
return val;
@@ -524,8 +498,8 @@ int QGtkStyle::pixelMetric(PixelMetric metric,
case PM_ScrollBarExtent: {
gint sliderLength;
gint trough_border;
- GtkWidget *hScrollbar = QGtk::gtkWidget(QLS("GtkHScrollbar"));
- QGtk::gtk_widget_style_get(hScrollbar,
+ GtkWidget *hScrollbar = d->gtkWidget(QLS("GtkHScrollbar"));
+ d->gtk_widget_style_get(hScrollbar,
"trough-border", &trough_border,
"slider-width", &sliderLength,
NULL);
@@ -537,35 +511,35 @@ int QGtkStyle::pixelMetric(PixelMetric metric,
case PM_SliderLength:
gint val;
- QGtk::gtk_widget_style_get(QGtk::gtkWidget(QLS("GtkHScale")), "slider-length", &val, NULL);
+ d->gtk_widget_style_get(d->gtkWidget(QLS("GtkHScale")), "slider-length", &val, NULL);
return val;
case PM_ExclusiveIndicatorWidth:
case PM_ExclusiveIndicatorHeight:
case PM_IndicatorWidth:
case PM_IndicatorHeight: {
- GtkWidget *gtkCheckButton = QGtk::gtkWidget(QLS("GtkCheckButton"));
+ GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton"));
gint size, spacing;
- QGtk::gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, "indicator-size", &size, NULL);
+ d->gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, "indicator-size", &size, NULL);
return size + 2 * spacing;
}
case PM_MenuBarVMargin: {
- GtkWidget *gtkMenubar = QGtk::gtkWidget(QLS("GtkMenuBar"));
+ GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar"));
return qMax(0, gtkMenubar->style->ythickness);
}
case PM_ScrollView_ScrollBarSpacing:
{
gint spacing = 3;
- GtkWidget *gtkScrollWindow = QGtk::gtkWidget(QLS("GtkScrolledWindow"));
+ GtkWidget *gtkScrollWindow = d->gtkWidget(QLS("GtkScrolledWindow"));
Q_ASSERT(gtkScrollWindow);
- QGtk::gtk_widget_style_get(gtkScrollWindow, "scrollbar-spacing", &spacing, NULL);
+ d->gtk_widget_style_get(gtkScrollWindow, "scrollbar-spacing", &spacing, NULL);
return spacing;
}
case PM_SubMenuOverlap: {
gint offset = 0;
- GtkWidget *gtkMenu = QGtk::gtkWidget(QLS("GtkMenu"));
- QGtk::gtk_widget_style_get(gtkMenu, "horizontal-offset", &offset, NULL);
+ GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu"));
+ d->gtk_widget_style_get(gtkMenu, "horizontal-offset", &offset, NULL);
return offset;
}
default:
@@ -580,7 +554,9 @@ int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidg
QStyleHintReturn *returnData = 0) const
{
- if (!QGtk::isThemeAvailable())
+ Q_D(const QGtkStyle);
+
+ if (!d->isThemeAvailable())
return QCleanlooksStyle::styleHint(hint, option, widget, returnData);
switch (hint) {
@@ -588,7 +564,7 @@ int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidg
case SH_DialogButtonLayout: {
int ret = QDialogButtonBox::GnomeLayout;
gboolean alternateOrder = 0;
- GtkSettings *settings = QGtk::gtk_settings_get_default();
+ GtkSettings *settings = d->gtk_settings_get_default();
g_object_get(settings, "gtk-alternative-button-order", &alternateOrder, NULL);
if (alternateOrder)
@@ -601,9 +577,9 @@ int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidg
case SH_ToolButtonStyle:
{
- if (QGtk::isKDE4Session())
+ if (d->isKDE4Session())
return QCleanlooksStyle::styleHint(hint, option, widget, returnData);
- GtkWidget *gtkToolbar = QGtk::gtkWidget(QLS("GtkToolbar"));
+ GtkWidget *gtkToolbar = d->gtkWidget(QLS("GtkToolbar"));
GtkToolbarStyle toolbar_style = GTK_TOOLBAR_ICONS;
g_object_get(gtkToolbar, "toolbar-style", &toolbar_style, NULL);
switch (toolbar_style) {
@@ -626,9 +602,9 @@ int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidg
return int(false);
case SH_ComboBox_Popup: {
- GtkWidget *gtkComboBox = QGtk::gtkWidget(QLS("GtkComboBox"));
+ GtkWidget *gtkComboBox = d->gtkWidget(QLS("GtkComboBox"));
gboolean appears_as_list;
- QGtk::gtk_widget_style_get((GtkWidget*)gtkComboBox, "appears-as-list", &appears_as_list, NULL);
+ d->gtk_widget_style_get((GtkWidget*)gtkComboBox, "appears-as-list", &appears_as_list, NULL);
return appears_as_list ? 0 : 1;
}
@@ -640,7 +616,7 @@ int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidg
case SH_Menu_SubMenuPopupDelay: {
gint delay = 225;
- GtkSettings *settings = QGtk::gtk_settings_get_default();
+ GtkSettings *settings = d->gtk_settings_get_default();
g_object_get(settings, "gtk-menu-popup-delay", &delay, NULL);
return delay;
}
@@ -649,15 +625,15 @@ int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidg
gboolean scrollbars_within_bevel = false;
if (widget && widget->isWindow())
scrollbars_within_bevel = true;
- else if (!QGtk::gtk_check_version(2, 12, 0)) {
- GtkWidget *gtkScrollWindow = QGtk::gtkWidget(QLS("GtkScrolledWindow"));
- QGtk::gtk_widget_style_get(gtkScrollWindow, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL);
+ else if (!d->gtk_check_version(2, 12, 0)) {
+ GtkWidget *gtkScrollWindow = d->gtkWidget(QLS("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 = QGtk::getGConfBool(QLS("/desktop/gnome/interface/buttons_have_icons"));
+ static bool buttonsHaveIcons = d->getGConfBool(QLS("/desktop/gnome/interface/buttons_have_icons"));
return buttonsHaveIcons;
}
@@ -670,17 +646,18 @@ int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidg
\reimp
*/
void QGtkStyle::drawPrimitive(PrimitiveElement element,
-
const QStyleOption *option,
QPainter *painter,
const QWidget *widget) const
{
- if (!QGtk::isThemeAvailable()) {
+ Q_D(const QGtkStyle);
+
+ if (!d->isThemeAvailable()) {
QCleanlooksStyle::drawPrimitive(element, option, painter, widget);
return;
}
- GtkStyle* style = QGtk::gtkStyle();
+ GtkStyle* style = d->gtkStyle();
QGtkPainter gtkPainter(painter);
switch (element) {
@@ -715,10 +692,10 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
else if (option->state & State_Raised)
shadow_type = GTK_SHADOW_OUT;
- GtkStyle *style = QGtk::gtk_rc_get_style_by_paths(QGtk::gtk_settings_get_default(),
- "*.GtkScrolledWindow", "*.GtkScrolledWindow", Q_GTK_TYPE_WINDOW);
+ GtkStyle *style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(),
+ "*.GtkScrolledWindow", "*.GtkScrolledWindow", d->gtk_window_get_type());
if (style)
- gtkFramePainter.paintShadow(QGtk::gtkWidget(QLS("GtkFrame")), "viewport", pmRect,
+ gtkFramePainter.paintShadow(d->gtkWidget(QLS("GtkFrame")), "viewport", pmRect,
option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
shadow_type, style);
QPixmapCache::insert(pmKey, pixmap);
@@ -745,8 +722,9 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
break;
case PE_PanelTipLabel: {
- GtkWidget *gtkWindow = QGtk::gtkWidget(QLS("GtkWindow")); // The Murrine Engine currently assumes a widget is passed
- style = QGtk::gtk_rc_get_style_by_paths(QGtk::gtk_settings_get_default(), "gtk-tooltips", "GtkWindow", Q_GTK_TYPE_WINDOW);
+ GtkWidget *gtkWindow = d->gtkWidget(QLS("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;
@@ -759,8 +737,8 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
break;
}
GtkShadowType shadow_type;
- GtkWidget *gtkStatusbarFrame = QGtk::gtkWidget(QLS("GtkStatusbar.GtkFrame"));
- QGtk::gtk_widget_style_get(gtkStatusbarFrame->parent, "shadow-type", &shadow_type, NULL);
+ GtkWidget *gtkStatusbarFrame = d->gtkWidget(QLS("GtkStatusbar.GtkFrame"));
+ d->gtk_widget_style_get(gtkStatusbarFrame->parent, "shadow-type", &shadow_type, NULL);
gtkPainter.paintShadow(gtkStatusbarFrame, "frame", option->rect, GTK_STATE_NORMAL,
shadow_type, gtkStatusbarFrame->style);
}
@@ -768,7 +746,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
case PE_IndicatorHeaderArrow:
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
- GtkWidget *gtkTreeHeader = QGtk::gtkWidget(QLS("GtkTreeView.GtkButton"));
+ GtkWidget *gtkTreeHeader = d->gtkWidget(QLS("GtkTreeView.GtkButton"));
GtkStateType state = gtkPainter.gtkState(option);
style = gtkTreeHeader->style;
GtkArrowType type = GTK_ARROW_UP;
@@ -806,7 +784,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
rect.translate(2, 0);
GtkExpanderStyle openState = GTK_EXPANDER_EXPANDED;
GtkExpanderStyle closedState = GTK_EXPANDER_COLLAPSED;
- GtkWidget *gtkTreeView = QGtk::gtkWidget(QLS("GtkTreeView"));
+ GtkWidget *gtkTreeView = d->gtkWidget(QLS("GtkTreeView"));
GtkStateType state = GTK_STATE_NORMAL;
if (!(option->state & State_Enabled))
@@ -842,7 +820,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
case PE_IndicatorToolBarSeparator:
{
const int margin = 6;
- GtkWidget *gtkSeparator = QGtk::gtkWidget(QLS("GtkToolbar.GtkSeparatorToolItem"));
+ GtkWidget *gtkSeparator = d->gtkWidget(QLS("GtkToolbar.GtkSeparatorToolItem"));
if (option->state & State_Horizontal) {
const int offset = option->rect.width()/2;
QRect rect = option->rect.adjusted(offset, margin, 0, -margin);
@@ -862,9 +840,9 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
break;
case PE_IndicatorToolBarHandle: {
- GtkWidget *gtkToolbar = QGtk::gtkWidget(QLS("GtkToolbar"));
+ GtkWidget *gtkToolbar = d->gtkWidget(QLS("GtkToolbar"));
GtkShadowType shadow_type;
- QGtk::gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL);
+ 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),
@@ -910,14 +888,14 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
GtkStateType state = gtkPainter.gtkState(option);
QColor arrowColor = option->palette.buttonText().color();
- GtkWidget *gtkArrow = QGtk::gtkWidget(QLS("GtkArrow"));
+ GtkWidget *gtkArrow = d->gtkWidget(QLS("GtkArrow"));
GdkColor color = fromQColor(arrowColor);
- QGtk::gtk_widget_modify_fg (gtkArrow, state, &color);
+ d->gtk_widget_modify_fg (gtkArrow, state, &color);
gtkPainter.paintArrow(gtkArrow, "button", arrowRect,
type, state, shadow, FALSE, gtkArrow->style,
QString::number(arrowColor.rgba(), 16));
// Passing NULL will revert the color change
- QGtk::gtk_widget_modify_fg (gtkArrow, state, NULL);
+ d->gtk_widget_modify_fg (gtkArrow, state, NULL);
}
break;
@@ -926,7 +904,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
break;
case PE_PanelMenu: {
- GtkWidget *gtkMenu = QGtk::gtkWidget(QLS("GtkMenu"));
+ GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu"));
gtkPainter.setAlphaSupport(false); // Note, alpha disabled for performance reasons
gtkPainter.paintBox(gtkMenu, "menu", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, gtkMenu->style, QString());
}
@@ -938,7 +916,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
// This is only used by floating tool bars
if (qobject_cast<const QToolBar *>(widget)) {
- GtkWidget *gtkMenubar = QGtk::gtkWidget(QLS("GtkMenuBar"));
+ GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar"));
gtkPainter.paintBox( gtkMenubar, "toolbar", option->rect,
GTK_STATE_NORMAL, GTK_SHADOW_OUT, style);
gtkPainter.paintBox( gtkMenubar, "menu", option->rect,
@@ -947,13 +925,13 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
break;
case PE_FrameLineEdit: {
- GtkWidget *gtkEntry = QGtk::gtkWidget(QLS("GtkEntry"));
+ GtkWidget *gtkEntry = d->gtkWidget(QLS("GtkEntry"));
gboolean interior_focus;
gint focus_line_width;
QRect rect = option->rect;
- QGtk::gtk_widget_style_get(gtkEntry,
+ d->gtk_widget_style_get(gtkEntry,
"interior-focus", &interior_focus,
"focus-line-width", &focus_line_width, NULL);
@@ -981,7 +959,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
case PE_PanelLineEdit:
if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
- GtkWidget *gtkEntry = QGtk::gtkWidget(QLS("GtkEntry"));
+ GtkWidget *gtkEntry = d->gtkWidget(QLS("GtkEntry"));
if (panel->lineWidth > 0)
proxy()->drawPrimitive(PE_FrameLineEdit, option, painter, widget);
uint resolve_mask = option->palette.resolve();
@@ -999,13 +977,13 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
case PE_FrameTabWidget:
if (const QStyleOptionTabWidgetFrame *frame = qstyleoption_cast<const QStyleOptionTabWidgetFrame*>(option)) {
- GtkWidget *gtkNotebook = QGtk::gtkWidget(QLS("GtkNotebook"));
+ GtkWidget *gtkNotebook = d->gtkWidget(QLS("GtkNotebook"));
style = gtkPainter.getStyle(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);
- QGtk::gtk_widget_set_direction(gtkNotebook, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
+ 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;
@@ -1047,10 +1025,10 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
GtkStateType state = gtkPainter.gtkState(option);
if (option->state & State_On || option->state & State_Sunken)
state = GTK_STATE_ACTIVE;
- GtkWidget *gtkButton = QGtk::gtkWidget(isTool ? QLS("GtkToolButton.GtkButton") : QLS("GtkButton"));
+ GtkWidget *gtkButton = d->gtkWidget(isTool ? QLS("GtkToolButton.GtkButton") : QLS("GtkButton"));
gint focusWidth, focusPad;
gboolean interiorFocus = false;
- QGtk::gtk_widget_style_get (gtkButton,
+ d->gtk_widget_style_get (gtkButton,
"focus-line-width", &focusWidth,
"focus-padding", &focusPad,
"interior-focus", &interiorFocus, NULL);
@@ -1103,14 +1081,14 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
else
shadow = GTK_SHADOW_OUT;
- GtkWidget *gtkRadioButton = QGtk::gtkWidget(QLS("GtkRadioButton"));
+ GtkWidget *gtkRadioButton = d->gtkWidget(QLS("GtkRadioButton"));
gint spacing;
- QGtk::gtk_widget_style_get(gtkRadioButton, "indicator-spacing", &spacing, NULL);
+ 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 = QGtk::gtkWidget(QLS("GtkCheckButton"));
+ GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton"));
gtkPainter.paintOption(gtkCheckButton , buttonRect, state, shadow, gtkRadioButton->style, QLS("radiobutton"));
}
@@ -1132,12 +1110,12 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element,
int spacing;
- GtkWidget *gtkCheckButton = QGtk::gtkWidget(QLS("GtkCheckButton"));
+ GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton"));
// Some styles such as aero-clone assume they can paint in the spacing area
gtkPainter.setClipRect(option->rect);
- QGtk::gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, NULL);
+ d->gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, NULL);
QRect checkRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing);
@@ -1204,12 +1182,14 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
QPainter *painter, const QWidget *widget) const
{
- if (!QGtk::isThemeAvailable()) {
+ Q_D(const QGtkStyle);
+
+ if (!d->isThemeAvailable()) {
QCleanlooksStyle::drawComplexControl(control, option, painter, widget);
return;
}
- GtkStyle* style = QGtk::gtkStyle();
+ GtkStyle* style = d->gtkStyle();
QGtkPainter gtkPainter(painter);
QColor button = option->palette.button().color();
QColor dark;
@@ -1264,7 +1244,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {
// Draw prelight background
- GtkWidget *gtkCheckButton = QGtk::gtkWidget(QLS("GtkCheckButton"));
+ GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton"));
if (option->state & State_MouseOver) {
QRect bgRect = textRect | checkBoxRect;
@@ -1340,14 +1320,14 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
QString comboBoxPath = QLS(comboBox->editable ? "GtkComboBoxEntry" : "GtkComboBox");
// We use the gtk widget to position arrows and separators for us
- GtkWidget *gtkCombo = QGtk::gtkWidget(comboBoxPath);
+ GtkWidget *gtkCombo = d->gtkWidget(comboBoxPath);
GtkAllocation geometry = {0, 0, option->rect.width(), option->rect.height()};
- QGtk::gtk_widget_set_direction(gtkCombo, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
- QGtk::gtk_widget_size_allocate(gtkCombo, &geometry);
+ d->gtk_widget_set_direction(gtkCombo, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
+ d->gtk_widget_size_allocate(gtkCombo, &geometry);
QString buttonPath = comboBoxPath + QLS(".GtkToggleButton");
- GtkWidget *gtkToggleButton = QGtk::gtkWidget(buttonPath);
- QGtk::gtk_widget_set_direction(gtkToggleButton, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
+ 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)
GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
@@ -1355,8 +1335,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
if (comboBox->editable || appears_as_list) {
GtkStateType frameState = (state == GTK_STATE_PRELIGHT) ? GTK_STATE_NORMAL : state;
QString entryPath = QLS(comboBox->editable ? "GtkComboBoxEntry.GtkEntry" : "GtkComboBox.GtkFrame");
- GtkWidget *gtkEntry = QGtk::gtkWidget(entryPath);
- QGtk::gtk_widget_set_direction(gtkEntry, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
+ 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)
@@ -1425,7 +1405,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
// Draw the separator between label and arrows
QString vSeparatorPath = buttonPath + QLS(".GtkHBox.GtkVSeparator");
- if (GtkWidget *gtkVSeparator = QGtk::gtkWidget(vSeparatorPath)) {
+ if (GtkWidget *gtkVSeparator = d->gtkWidget(vSeparatorPath)) {
QRect vLineRect(gtkVSeparator->allocation.x,
gtkVSeparator->allocation.y,
gtkVSeparator->allocation.width,
@@ -1437,7 +1417,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
gint interiorFocus = true;
- QGtk::gtk_widget_style_get(gtkToggleButton, "interior-focus", &interiorFocus, NULL);
+ d->gtk_widget_style_get(gtkToggleButton, "interior-focus", &interiorFocus, NULL);
int xt = interiorFocus ? gtkToggleButton->style->xthickness : 0;
int yt = interiorFocus ? gtkToggleButton->style->ythickness : 0;
if (focus && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget)))
@@ -1461,14 +1441,14 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
QString arrowPath = comboBoxPath + QLS(appears_as_list ? ".GtkToggleButton.GtkArrow"
: ".GtkToggleButton.GtkHBox.GtkArrow");
- GtkWidget *gtkArrow = QGtk::gtkWidget(arrowPath);
+ GtkWidget *gtkArrow = d->gtkWidget(arrowPath);
gfloat scale = 0.7;
gint minSize = 15;
QRect arrowWidgetRect;
- if (gtkArrow && !QGtk::gtk_check_version(2, 12, 0)) {
- QGtk::gtk_widget_style_get(gtkArrow, "arrow-scaling", &scale, NULL);
- QGtk::gtk_widget_style_get(gtkCombo, "arrow-size", &minSize, NULL);
+ 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) {
arrowWidgetRect = QRect(gtkArrow->allocation.x, gtkArrow->allocation.y,
@@ -1486,9 +1466,9 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
if (sunken) {
int xoff, yoff;
- GtkWidget *gtkButton = QGtk::gtkWidget(comboBoxPath + QLS(".GtkToggleButton"));
- QGtk::gtk_widget_style_get(gtkButton, "child-displacement-x", &xoff, NULL);
- QGtk::gtk_widget_style_get(gtkButton, "child-displacement-y", &yoff, NULL);
+ GtkWidget *gtkButton = d->gtkWidget(comboBoxPath + QLS(".GtkToggleButton"));
+ 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);
}
@@ -1559,7 +1539,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
QStyleOptionToolButton label = *toolbutton;
label.state = bflags;
- GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkToolButton.GtkButton"));
+ GtkWidget *gtkButton = d->gtkWidget(QLS("GtkToolButton.GtkButton"));
QPalette pal = toolbutton->palette;
if (option->state & State_Enabled &&
option->state & State_MouseOver && !(widget && widget->testAttribute(Qt::WA_SetPalette))) {
@@ -1594,8 +1574,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
case CC_ScrollBar:
if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
- GtkWidget *gtkHScrollBar = QGtk::gtkWidget(QLS("GtkHScrollbar"));
- GtkWidget *gtkVScrollBar = QGtk::gtkWidget(QLS("GtkVScrollbar"));
+ GtkWidget *gtkHScrollBar = d->gtkWidget(QLS("GtkHScrollbar"));
+ GtkWidget *gtkVScrollBar = d->gtkWidget(QLS("GtkVScrollbar"));
// Fill background in case the scrollbar is partially transparent
painter->fillRect(option->rect, option->palette.background());
@@ -1612,8 +1592,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
gboolean trough_side_details = false;
gboolean stepper_size = 14;
gint trough_border = 1;
- if (!QGtk::gtk_check_version(2, 10, 0)) {
- QGtk::gtk_widget_style_get((GtkWidget*)(scrollbarWidget),
+ 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,
@@ -1637,12 +1617,12 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
fakePos = maximum;
else if (scrollBar->sliderPosition > scrollBar->minimum)
fakePos = maximum - 1;
- GtkObject *adjustment = QGtk::gtk_adjustment_new(fakePos, 0, maximum, 0, 0, 0);
+ GtkObject *adjustment = d->gtk_adjustment_new(fakePos, 0, maximum, 0, 0, 0);
if (horizontal)
- QGtk::gtk_range_set_adjustment((GtkRange*)(gtkHScrollBar), (GtkAdjustment*)(adjustment));
+ d->gtk_range_set_adjustment((GtkRange*)(gtkHScrollBar), (GtkAdjustment*)(adjustment));
else
- QGtk::gtk_range_set_adjustment((GtkRange*)(gtkVScrollBar), (GtkAdjustment*)(adjustment));
+ d->gtk_range_set_adjustment((GtkRange*)(gtkVScrollBar), (GtkAdjustment*)(adjustment));
if (scrollBar->subControls & SC_ScrollBarGroove) {
GtkStateType state = GTK_STATE_ACTIVE;
@@ -1739,7 +1719,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
case CC_SpinBox:
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
- GtkWidget *gtkSpinButton = QGtk::gtkWidget(QLS("GtkSpinButton"));
+ GtkWidget *gtkSpinButton = d->gtkWidget(QLS("GtkSpinButton"));
bool isEnabled = (spinBox->state & State_Enabled);
bool hover = isEnabled && (spinBox->state & State_MouseOver);
bool sunken = (spinBox->state & State_Sunken);
@@ -1854,7 +1834,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
}
} else {
- int size = spinboxArrowSize();
+ int size = d->getSpinboxArrowSize();
int w = size / 2 - 1;
w -= w % 2 - 1; // force odd
int h = (w + 1)/2;
@@ -1886,8 +1866,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
case CC_Slider:
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
- GtkWidget *hScaleWidget = QGtk::gtkWidget(QLS("GtkHScale"));
- GtkWidget *vScaleWidget = QGtk::gtkWidget(QLS("GtkVScale"));
+ GtkWidget *hScaleWidget = d->gtkWidget(QLS("GtkHScale"));
+ GtkWidget *vScaleWidget = d->gtkWidget(QLS("GtkVScale"));
QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget);
QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget);
@@ -1911,16 +1891,16 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
style = scaleWidget->style;
if ((option->subControls & SC_SliderGroove) && groove.isValid()) {
- GtkObject *adjustment = QGtk::gtk_adjustment_new(slider->sliderPosition,
+ GtkObject *adjustment = d->gtk_adjustment_new(slider->sliderPosition,
slider->minimum,
slider->maximum,
slider->singleStep,
slider->singleStep,
slider->pageStep);
int outerSize;
- QGtk::gtk_range_set_adjustment ((GtkRange*)(scaleWidget), (GtkAdjustment*)(adjustment));
- QGtk::gtk_range_set_inverted((GtkRange*)(scaleWidget), !horizontal);
- QGtk::gtk_widget_style_get(scaleWidget, "trough-border", &outerSize, NULL);
+ d->gtk_range_set_adjustment ((GtkRange*)(scaleWidget), (GtkAdjustment*)(adjustment));
+ d->gtk_range_set_inverted((GtkRange*)(scaleWidget), !horizontal);
+ d->gtk_widget_style_get(scaleWidget, "trough-border", &outerSize, NULL);
outerSize++;
GtkStateType state = gtkPainter.gtkState(option);
@@ -1928,12 +1908,9 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom
QRect grooveRect = option->rect.adjusted(focusFrameMargin, outerSize + focusFrameMargin,
-focusFrameMargin, -outerSize - focusFrameMargin);
- gtkPainter.paintBox( scaleWidget, "trough", grooveRect, state,
- GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
-
gboolean trough_side_details = false; // Indicates if the upper or lower scale background differs
- if (!QGtk::gtk_check_version(2, 10, 0))
- QGtk::gtk_widget_style_get((GtkWidget*)(scaleWidget), "trough-side-details", &trough_side_details, NULL);
+ 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,
@@ -2067,18 +2044,20 @@ void QGtkStyle::drawControl(ControlElement element,
QPainter *painter,
const QWidget *widget) const
{
- if (!QGtk::isThemeAvailable()) {
+ Q_D(const QGtkStyle);
+
+ if (!d->isThemeAvailable()) {
QCleanlooksStyle::drawControl(element, option, painter, widget);
return;
}
- GtkStyle* style = QGtk::gtkStyle();
+ GtkStyle* style = d->gtkStyle();
QGtkPainter gtkPainter(painter);
switch (element) {
case CE_ProgressBarLabel:
if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
- GtkWidget *gtkProgressBar = QGtk::gtkWidget(QLS("GtkProgressBar"));
+ GtkWidget *gtkProgressBar = d->gtkWidget(QLS("GtkProgressBar"));
if (!gtkProgressBar)
return;
@@ -2181,7 +2160,7 @@ void QGtkStyle::drawControl(ControlElement element,
if (button->features & QStyleOptionButton::HasMenu)
ir = ir.adjusted(0, 0, -pixelMetric(PM_MenuButtonIndicator, button, widget), 0);
- GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));
+ GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
QPalette pal = button->palette;
int labelState = GTK_STATE_INSENSITIVE;
if (option->state & State_Enabled)
@@ -2202,7 +2181,7 @@ void QGtkStyle::drawControl(ControlElement element,
bool isRadio = (element == CE_RadioButton);
// Draw prelight background
- GtkWidget *gtkRadioButton = QGtk::gtkWidget(QLS("GtkRadioButton"));
+ GtkWidget *gtkRadioButton = d->gtkWidget(QLS("GtkRadioButton"));
if (option->state & State_MouseOver) {
gtkPainter.paintFlatBox(gtkRadioButton, "checkbutton", option->rect,
@@ -2270,7 +2249,7 @@ void QGtkStyle::drawControl(ControlElement element,
}
if (!cb->currentText.isEmpty() && !cb->editable) {
- GtkWidget *gtkCombo = QGtk::gtkWidget(QLS("GtkComboBox"));
+ GtkWidget *gtkCombo = d->gtkWidget(QLS("GtkComboBox"));
QPalette pal = cb->palette;
int labelState = GTK_STATE_INSENSITIVE;
@@ -2347,9 +2326,9 @@ void QGtkStyle::drawControl(ControlElement element,
// Draws the header in tables.
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
Q_UNUSED(header);
- GtkWidget *gtkTreeView = QGtk::gtkWidget(QLS("GtkTreeView"));
+ GtkWidget *gtkTreeView = d->gtkWidget(QLS("GtkTreeView"));
// Get the middle column
- GtkTreeViewColumn *column = QGtk::gtk_tree_view_get_column((GtkTreeView*)gtkTreeView, 1);
+ GtkTreeViewColumn *column = d->gtk_tree_view_get_column((GtkTreeView*)gtkTreeView, 1);
Q_ASSERT(column);
GtkWidget *gtkTreeHeader = column->button;
@@ -2368,7 +2347,7 @@ void QGtkStyle::drawControl(ControlElement element,
#ifndef QT_NO_SIZEGRIP
case CE_SizeGrip: {
- GtkWidget *gtkStatusbar = QGtk::gtkWidget(QLS("GtkStatusbar.GtkFrame"));
+ GtkWidget *gtkStatusbar = d->gtkWidget(QLS("GtkStatusbar.GtkFrame"));
QRect gripRect = option->rect.adjusted(0, 0, -gtkStatusbar->style->xthickness, -gtkStatusbar->style->ythickness);
gtkPainter.paintResizeGrip( gtkStatusbar, "statusbar", gripRect, GTK_STATE_NORMAL,
GTK_SHADOW_OUT, QApplication::isRightToLeft() ?
@@ -2380,7 +2359,7 @@ void QGtkStyle::drawControl(ControlElement element,
#endif // QT_NO_SIZEGRIP
case CE_MenuBarEmptyArea: {
- GtkWidget *gtkMenubar = QGtk::gtkWidget(QLS("GtkMenuBar"));
+ GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar"));
GdkColor gdkBg = gtkMenubar->style->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
@@ -2390,7 +2369,7 @@ void QGtkStyle::drawControl(ControlElement element,
QPainter pmPainter(&pixmap);
QGtkPainter gtkMenuBarPainter(&pmPainter);
GtkShadowType shadow_type;
- QGtk::gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL);
+ d->gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL);
gtkMenuBarPainter.paintBox( gtkMenubar, "menubar", menuBarRect,
GTK_STATE_NORMAL, shadow_type, gtkMenubar->style);
pmPainter.end();
@@ -2403,8 +2382,8 @@ void QGtkStyle::drawControl(ControlElement element,
painter->save();
if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
- GtkWidget *gtkMenubarItem = QGtk::gtkWidget(QLS("GtkMenuBar.GtkMenuItem"));
- GtkWidget *gtkMenubar = QGtk::gtkWidget(QLS("GtkMenuBar"));
+ GtkWidget *gtkMenubarItem = d->gtkWidget(QLS("GtkMenuBar.GtkMenuItem"));
+ GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar"));
style = gtkMenubarItem->style;
@@ -2419,7 +2398,7 @@ void QGtkStyle::drawControl(ControlElement element,
QPainter pmPainter(&pixmap);
QGtkPainter menubarPainter(&pmPainter);
GtkShadowType shadow_type;
- QGtk::gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL);
+ d->gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL);
GdkColor gdkBg = gtkMenubar->style->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency
painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8));
menubarPainter.paintBox(gtkMenubar, "menubar", menuBarRect,
@@ -2443,7 +2422,7 @@ void QGtkStyle::drawControl(ControlElement element,
if (act) {
GtkShadowType shadowType = GTK_SHADOW_NONE;
- QGtk::gtk_widget_style_get (gtkMenubarItem, "selected-shadow-type", &shadowType, NULL);
+ 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, gtkMenubarItem->style);
//draw text
@@ -2460,7 +2439,7 @@ void QGtkStyle::drawControl(ControlElement element,
break;
case CE_Splitter: {
- GtkWidget *gtkWindow = QGtk::gtkWidget(QLS("GtkWindow")); // The Murrine Engine currently assumes a widget is passed
+ GtkWidget *gtkWindow = d->gtkWidget(QLS("GtkWindow")); // The Murrine Engine currently assumes a widget is passed
gtkPainter.paintHandle(gtkWindow, "splitter", option->rect, gtkPainter.gtkState(option), GTK_SHADOW_NONE,
!(option->state & State_Horizontal) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL,
style);
@@ -2480,9 +2459,9 @@ void QGtkStyle::drawControl(ControlElement element,
if (toolbar->positionWithinLine != QStyleOptionToolBar::End)
rect.adjust(0, 0, 1, 0);
- GtkWidget *gtkToolbar = QGtk::gtkWidget(QLS("GtkToolbar"));
+ GtkWidget *gtkToolbar = d->gtkWidget(QLS("GtkToolbar"));
GtkShadowType shadow_type = GTK_SHADOW_NONE;
- QGtk::gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL);
+ d->gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL);
gtkPainter.paintBox( gtkToolbar, "toolbar", rect,
GTK_STATE_NORMAL, shadow_type, gtkToolbar->style);
}
@@ -2499,22 +2478,22 @@ void QGtkStyle::drawControl(ControlElement element,
const int windowsItemHMargin = 3; // menu item hor text margin
const int windowsItemVMargin = 26; // menu item ver text margin
const int windowsRightBorder = 15; // right border on windows
- GtkWidget *gtkMenu = QGtk::gtkWidget(QLS("GtkMenu"));
- GtkWidget *gtkMenuItem = menuItem->checked ? QGtk::gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")) :
- QGtk::gtkWidget(QLS("GtkMenu.GtkMenuItem"));
+ GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu"));
+ GtkWidget *gtkMenuItem = menuItem->checked ? d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")) :
+ d->gtkWidget(QLS("GtkMenu.GtkMenuItem"));
style = gtkPainter.getStyle(gtkMenuItem);
QColor borderColor = option->palette.background().color().darker(160);
QColor shadow = option->palette.dark().color();
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
- GtkWidget *gtkMenuSeparator = QGtk::gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem"));
+ GtkWidget *gtkMenuSeparator = d->gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem"));
painter->setPen(shadow.lighter(106));
gboolean wide_separators = 0;
gint separator_height = 0;
guint horizontal_padding = 3;
- if (!QGtk::gtk_check_version(2, 10, 0)) {
- QGtk::gtk_widget_style_get(gtkMenuSeparator,
+ 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,
@@ -2548,7 +2527,7 @@ void QGtkStyle::drawControl(ControlElement element,
bool ignoreCheckMark = false;
gint checkSize;
- QGtk::gtk_widget_style_get(QGtk::gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")), "indicator-size", &checkSize, NULL);
+ d->gtk_widget_style_get(d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")), "indicator-size", &checkSize, NULL);
int checkcol = qMax(menuItem->maxIconWidth, qMax(20, checkSize));
@@ -2735,7 +2714,7 @@ void QGtkStyle::drawControl(ControlElement element,
// "arrow-scaling" is actually hardcoded and fails on hardy (see gtk+-2.12/gtkmenuitem.c)
// though the current documentation states otherwise
int horizontal_padding;
- QGtk::gtk_widget_style_get(gtkMenuItem, "horizontal-padding", &horizontal_padding, NULL);
+ d->gtk_widget_style_get(gtkMenuItem, "horizontal-padding", &horizontal_padding, NULL);
const int dim = static_cast<int>(arrow_size * arrow_scaling);
int xpos = menuItem->rect.left() + menuItem->rect.width() - horizontal_padding - dim;
@@ -2753,12 +2732,12 @@ void QGtkStyle::drawControl(ControlElement element,
case CE_PushButton:
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));
+ GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
proxy()->drawControl(CE_PushButtonBevel, btn, painter, widget);
QStyleOptionButton subopt = *btn;
subopt.rect = subElementRect(SE_PushButtonContents, btn, widget);
gint interiorFocus = true;
- QGtk::gtk_widget_style_get(gtkButton, "interior-focus", &interiorFocus, NULL);
+ d->gtk_widget_style_get(gtkButton, "interior-focus", &interiorFocus, NULL);
int xt = interiorFocus ? gtkButton->style->xthickness : 0;
int yt = interiorFocus ? gtkButton->style->ythickness : 0;
@@ -2779,7 +2758,7 @@ void QGtkStyle::drawControl(ControlElement element,
case CE_TabBarTabShape:
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
- GtkWidget *gtkNotebook = QGtk::gtkWidget(QLS("GtkNotebook"));
+ GtkWidget *gtkNotebook = d->gtkWidget(QLS("GtkNotebook"));
style = gtkPainter.getStyle(gtkNotebook);
QRect rect = option->rect;
@@ -2846,7 +2825,7 @@ void QGtkStyle::drawControl(ControlElement element,
case CE_ProgressBarGroove:
if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
Q_UNUSED(bar);
- GtkWidget *gtkProgressBar = QGtk::gtkWidget(QLS("GtkProgressBar"));
+ GtkWidget *gtkProgressBar = d->gtkWidget(QLS("GtkProgressBar"));
GtkStateType state = gtkPainter.gtkState(option);
gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, gtkProgressBar->style);
}
@@ -2856,7 +2835,7 @@ void QGtkStyle::drawControl(ControlElement element,
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 = QGtk::gtkWidget(QLS("GtkProgressBar"));
+ GtkWidget *gtkProgressBar = d->gtkWidget(QLS("GtkProgressBar"));
style = gtkProgressBar->style;
gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, style);
int xt = style->xthickness;
@@ -2904,8 +2883,8 @@ void QGtkStyle::drawControl(ControlElement element,
else if (bar->progress > bar->minimum)
fakePos = maximum - 1;
- GtkObject *adjustment = QGtk::gtk_adjustment_new(fakePos, 0, maximum, 0, 0, 0);
- QGtk::gtk_progress_set_adjustment((GtkProgress*)(gtkProgressBar), (GtkAdjustment*)(adjustment));
+ GtkObject *adjustment = d->gtk_adjustment_new(fakePos, 0, maximum, 0, 0, 0);
+ d->gtk_progress_set_adjustment((GtkProgress*)(gtkProgressBar), (GtkAdjustment*)(adjustment));
QRect progressBar;
@@ -2945,8 +2924,10 @@ void QGtkStyle::drawControl(ControlElement element,
QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option,
SubControl subControl, const QWidget *widget) const
{
+ Q_D(const QGtkStyle);
+
QRect rect = QWindowsStyle::subControlRect(control, option, subControl, widget);
- if (!QGtk::isThemeAvailable())
+ if (!d->isThemeAvailable())
return QCleanlooksStyle::subControlRect(control, option, subControl, widget);
switch (control) {
@@ -3012,7 +2993,7 @@ QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComple
case CC_SpinBox:
if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
- GtkWidget *gtkSpinButton = QGtk::gtkWidget(QLS("GtkSpinButton"));
+ GtkWidget *gtkSpinButton = d->gtkWidget(QLS("GtkSpinButton"));
int center = spinbox->rect.height() / 2;
int xt = spinbox->frame ? gtkSpinButton->style->xthickness : 0;
int yt = spinbox->frame ? gtkSpinButton->style->ythickness : 0;
@@ -3020,7 +3001,7 @@ QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComple
QSize bs;
bs.setHeight(qMax(8, spinbox->rect.height()/2 - y));
- bs.setWidth(spinboxArrowSize());
+ bs.setWidth(d->getSpinboxArrowSize());
int x, lx, rx;
x = spinbox->rect.width() - y - bs.width() + 2;
lx = xt;
@@ -3066,17 +3047,17 @@ QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComple
if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
// We employ the gtk widget to position arrows and separators for us
QString comboBoxPath = box->editable ? QLS("GtkComboBoxEntry") : QLS("GtkComboBox");
- GtkWidget *gtkCombo = QGtk::gtkWidget(comboBoxPath);
- QGtk::gtk_widget_set_direction(gtkCombo, (option->direction == Qt::RightToLeft) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
+ GtkWidget *gtkCombo = d->gtkWidget(comboBoxPath);
+ 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())};
- QGtk::gtk_widget_size_allocate(gtkCombo, &geometry);
+ d->gtk_widget_size_allocate(gtkCombo, &geometry);
int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, option, widget);
QString arrowPath = comboBoxPath + QLS(".GtkToggleButton");
if (!box->editable && !appears_as_list)
arrowPath += QLS(".GtkHBox.GtkArrow");
- GtkWidget *arrowWidget = QGtk::gtkWidget(arrowPath);
+ GtkWidget *arrowWidget = d->gtkWidget(arrowPath);
if (!arrowWidget)
return QCleanlooksStyle::subControlRect(control, option, subControl, widget);
@@ -3121,19 +3102,19 @@ QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComple
\reimp
*/
QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
-
const QSize &size, const QWidget *widget) const
{
+ Q_D(const QGtkStyle);
QSize newSize = QCleanlooksStyle::sizeFromContents(type, option, size, widget);
- if (!QGtk::isThemeAvailable())
+ if (!d->isThemeAvailable())
return newSize;
switch (type) {
case CT_ToolButton:
if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
- GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkToolButton.GtkButton"));
+ GtkWidget *gtkButton = d->gtkWidget(QLS("GtkToolButton.GtkButton"));
newSize = size + QSize(2 * gtkButton->style->xthickness, 1 + 2 * gtkButton->style->ythickness);
if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) {
QSize minSize(0, 25);
@@ -3141,7 +3122,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
minSize = toolbutton->iconSize + QSize(12, 12);
newSize = newSize.expandedTo(minSize);
}
-
+
if (toolbutton->features & QStyleOptionToolButton::HasMenu)
newSize += QSize(6, 0);
}
@@ -3152,10 +3133,10 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
int textMargin = 8;
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
- GtkWidget *gtkMenuSeparator = QGtk::gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem"));
+ GtkWidget *gtkMenuSeparator = d->gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem"));
gboolean wide_separators;
gint separator_height;
- QGtk::gtk_widget_style_get(gtkMenuSeparator,
+ d->gtk_widget_style_get(gtkMenuSeparator,
"wide-separators", &wide_separators,
"separator-height", &separator_height,
NULL);
@@ -3164,14 +3145,14 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
break;
}
- GtkWidget *gtkMenuItem = QGtk::gtkWidget(QLS("GtkMenu.GtkMenuItem"));
+ GtkWidget *gtkMenuItem = d->gtkWidget(QLS("GtkMenu.GtkMenuItem"));
GtkStyle* style = gtkMenuItem->style;
newSize += QSize(textMargin + style->xthickness - 2, style->ythickness - 4);
// Cleanlooks assumes a check column of 20 pixels so we need to
// expand it a bit
gint checkSize;
- QGtk::gtk_widget_style_get(QGtk::gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")), "indicator-size", &checkSize, NULL);
+ d->gtk_widget_style_get(d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")), "indicator-size", &checkSize, NULL);
newSize.setHeight(qMax(newSize.height(), checkSize + 2));
newSize.setWidth(newSize.width() + qMax(0, checkSize - 20));
}
@@ -3186,22 +3167,22 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
case CT_SpinBox:
// QSpinBox does some nasty things that depends on CT_LineEdit
- newSize = size + QSize(0, -QGtk::gtkWidget(QLS("GtkSpinButton"))->style->ythickness * 2 + 2);
+ newSize = size + QSize(0, -d->gtkWidget(QLS("GtkSpinButton"))->style->ythickness * 2 + 2);
break;
case CT_PushButton:
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton"));
+ GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton"));
gint focusPadding, focusWidth;
- QGtk::gtk_widget_style_get(gtkButton, "focus-padding", &focusPadding, NULL);
- QGtk::gtk_widget_style_get(gtkButton, "focus-line-width", &focusWidth, NULL);
+ d->gtk_widget_style_get(gtkButton, "focus-padding", &focusPadding, NULL);
+ d->gtk_widget_style_get(gtkButton, "focus-line-width", &focusWidth, NULL);
newSize = size;
newSize += QSize(2*gtkButton->style->xthickness + 4, 2*gtkButton->style->ythickness);
newSize += QSize(2*(focusWidth + focusPadding + 2), 2*(focusWidth + focusPadding));
- GtkWidget *gtkButtonBox = QGtk::gtkWidget(QLS("GtkHButtonBox"));
+ GtkWidget *gtkButtonBox = d->gtkWidget(QLS("GtkHButtonBox"));
gint minWidth = 85, minHeight = 0;
- QGtk::gtk_widget_style_get(gtkButtonBox, "child-min-width", &minWidth,
+ 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);
@@ -3212,7 +3193,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
break;
case CT_Slider: {
- GtkWidget *gtkSlider = QGtk::gtkWidget(QLS("GtkHScale"));
+ GtkWidget *gtkSlider = d->gtkWidget(QLS("GtkHScale"));
newSize = size + QSize(2*gtkSlider->style->xthickness, 2*gtkSlider->style->ythickness);
}
break;
@@ -3222,7 +3203,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
break;
case CT_LineEdit: {
- GtkWidget *gtkEntry = QGtk::gtkWidget(QLS("GtkEntry"));
+ GtkWidget *gtkEntry = d->gtkWidget(QLS("GtkEntry"));
newSize = size + QSize(2*gtkEntry->style->xthickness, 2*gtkEntry->style->ythickness);
}
break;
@@ -3233,7 +3214,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
case CT_ComboBox:
if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
- GtkWidget *gtkCombo = QGtk::gtkWidget(QLS("GtkComboBox"));
+ GtkWidget *gtkCombo = d->gtkWidget(QLS("GtkComboBox"));
QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, combo, SC_ComboBoxArrow, widget);
newSize = size + QSize(12 + arrowButtonRect.width() + 2*gtkCombo->style->xthickness, 4 + 2*gtkCombo->style->ythickness);
@@ -3266,7 +3247,9 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
QPixmap QGtkStyle::standardPixmap(StandardPixmap sp, const QStyleOption *option,
const QWidget *widget) const
{
- if (!QGtk::isThemeAvailable())
+ Q_D(const QGtkStyle);
+
+ if (!d->isThemeAvailable())
return QCleanlooksStyle::standardPixmap(sp, option, widget);
QPixmap pixmap;
@@ -3333,7 +3316,9 @@ QIcon QGtkStyle::standardIconImplementation(StandardPixmap standardIcon,
const QStyleOption *option,
const QWidget *widget) const
{
- if (!QGtk::isThemeAvailable())
+ Q_D(const QGtkStyle);
+
+ if (!d->isThemeAvailable())
return QCleanlooksStyle::standardIconImplementation(standardIcon, option, widget);
switch (standardIcon) {
case SP_DialogDiscardButton:
diff --git a/src/gui/styles/qgtkstyle.h b/src/gui/styles/qgtkstyle.h
index 20c2b52..5c3bad1 100644
--- a/src/gui/styles/qgtkstyle.h
+++ b/src/gui/styles/qgtkstyle.h
@@ -45,6 +45,7 @@
#include <QtGui/QCleanlooksStyle>
#include <QtGui/QPalette>
#include <QtGui/QFont>
+#include <QtGui/QFileDialog>
QT_BEGIN_HEADER
@@ -64,6 +65,8 @@ class Q_GUI_EXPORT QGtkStyle : public QCleanlooksStyle
public:
QGtkStyle();
+ QGtkStyle(QGtkStylePrivate &dd);
+
~QGtkStyle();
QPalette standardPalette() const;
@@ -107,12 +110,15 @@ public:
void unpolish(QWidget *widget);
void unpolish(QApplication *app);
+ static bool getGConfBool(const QString &key, bool fallback = 0);
+ static QString getGConfString(const QString &key, const QString &fallback = QString());
+
+
protected Q_SLOTS:
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
const QWidget *widget = 0) const;
};
-
#endif //!defined(QT_NO_STYLE_QGTK)
QT_END_NAMESPACE
diff --git a/src/gui/styles/qgtkstyle_p.cpp b/src/gui/styles/qgtkstyle_p.cpp
new file mode 100644
index 0000000..7119a4f
--- /dev/null
+++ b/src/gui/styles/qgtkstyle_p.cpp
@@ -0,0 +1,1069 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgtkstyle_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 <private/qapplication_p.h>
+#include <private/qiconloader_p.h>
+
+#include <QtGui/QMenu>
+#include <QtGui/QStyle>
+#include <QtGui/QApplication>
+#include <QtGui/QPixmapCache>
+#include <QtGui/QStatusBar>
+#include <QtGui/QMenuBar>
+#include <QtGui/QToolBar>
+#include <QtGui/QToolButton>
+#include <QtGui/QX11Info>
+
+#include <private/qt_x11_p.h>
+
+QT_BEGIN_NAMESPACE
+
+static bool displayDepth = -1;
+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 QGtkStylePrivate::gtk_menu_item_new = 0;
+Ptr_gtk_check_menu_item_new QGtkStylePrivate::gtk_check_menu_item_new = 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_progress_set_adjustment QGtkStylePrivate::gtk_progress_set_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_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_paint_check QGtkStylePrivate::gtk_paint_check = 0;
+Ptr_gtk_paint_box QGtkStylePrivate::gtk_paint_box = 0;
+Ptr_gtk_paint_box_gap QGtkStylePrivate::gtk_paint_box_gap = 0;
+Ptr_gtk_paint_flat_box QGtkStylePrivate::gtk_paint_flat_box = 0;
+Ptr_gtk_paint_option QGtkStylePrivate::gtk_paint_option = 0;
+Ptr_gtk_paint_extension QGtkStylePrivate::gtk_paint_extension = 0;
+Ptr_gtk_paint_slider QGtkStylePrivate::gtk_paint_slider = 0;
+Ptr_gtk_paint_shadow QGtkStylePrivate::gtk_paint_shadow = 0;
+Ptr_gtk_paint_resize_grip QGtkStylePrivate::gtk_paint_resize_grip = 0;
+Ptr_gtk_paint_focus QGtkStylePrivate::gtk_paint_focus = 0;
+Ptr_gtk_paint_arrow QGtkStylePrivate::gtk_paint_arrow = 0;
+Ptr_gtk_paint_handle QGtkStylePrivate::gtk_paint_handle = 0;
+Ptr_gtk_paint_expander QGtkStylePrivate::gtk_paint_expander = 0;
+Ptr_gtk_adjustment_new QGtkStylePrivate::gtk_adjustment_new = 0;
+Ptr_gtk_paint_hline QGtkStylePrivate::gtk_paint_hline = 0;
+Ptr_gtk_paint_vline QGtkStylePrivate::gtk_paint_vline = 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_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_rc_get_style_by_paths QGtkStylePrivate::gtk_rc_get_style_by_paths = 0;
+Ptr_gtk_check_version QGtkStylePrivate::gtk_check_version = 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_gtk_file_filter_new QGtkStylePrivate::gtk_file_filter_new = 0;
+Ptr_gtk_file_filter_set_name QGtkStylePrivate::gtk_file_filter_set_name = 0;
+Ptr_gtk_file_filter_add_pattern QGtkStylePrivate::gtk_file_filter_add_pattern = 0;
+Ptr_gtk_file_chooser_add_filter QGtkStylePrivate::gtk_file_chooser_add_filter = 0;
+Ptr_gtk_file_chooser_set_filter QGtkStylePrivate::gtk_file_chooser_set_filter = 0;
+Ptr_gtk_file_chooser_get_filter QGtkStylePrivate::gtk_file_chooser_get_filter = 0;
+Ptr_gtk_file_chooser_dialog_new QGtkStylePrivate::gtk_file_chooser_dialog_new = 0;
+Ptr_gtk_file_chooser_set_current_folder QGtkStylePrivate::gtk_file_chooser_set_current_folder = 0;
+Ptr_gtk_file_chooser_get_filename QGtkStylePrivate::gtk_file_chooser_get_filename = 0;
+Ptr_gtk_file_chooser_get_filenames QGtkStylePrivate::gtk_file_chooser_get_filenames = 0;
+Ptr_gtk_file_chooser_set_current_name QGtkStylePrivate::gtk_file_chooser_set_current_name = 0;
+Ptr_gtk_dialog_run QGtkStylePrivate::gtk_dialog_run = 0;
+Ptr_gtk_file_chooser_set_filename QGtkStylePrivate::gtk_file_chooser_set_filename = 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_pixmap_new QGtkStylePrivate::gdk_pixmap_new = 0;
+Ptr_gdk_pixbuf_new QGtkStylePrivate::gdk_pixbuf_new = 0;
+Ptr_gdk_pixbuf_get_from_drawable QGtkStylePrivate::gdk_pixbuf_get_from_drawable = 0;
+Ptr_gdk_draw_rectangle QGtkStylePrivate::gdk_draw_rectangle = 0;
+Ptr_gdk_pixbuf_unref QGtkStylePrivate::gdk_pixbuf_unref = 0;
+Ptr_gdk_drawable_unref QGtkStylePrivate::gdk_drawable_unref = 0;
+Ptr_gdk_drawable_get_depth QGtkStylePrivate::gdk_drawable_get_depth = 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;
+
+typedef int (*x11ErrorHandler)(Display*, XErrorEvent*);
+
+static void gtkStyleSetCallback(GtkWidget*, QGtkStylePrivate* stylePrivate)
+{
+ // 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, Q_ARG(QGtkStylePrivate*, stylePrivate));
+}
+
+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 QString classPath(GtkWidget *widget)
+{
+ char* class_path;
+ QGtkStylePrivate::gtk_widget_path (widget, NULL, &class_path, NULL);
+ QString path = QLS(class_path);
+ g_free(class_path);
+
+ // Remove the prefixes
+ path.remove(QLS("GtkWindow."));
+ path.remove(QLS("GtkFixed."));
+ return path;
+}
+
+
+
+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);
+}
+
+QGtkStylePrivate::QGtkStylePrivate()
+ : QCleanlooksStylePrivate()
+ , filter(this)
+{
+}
+
+void QGtkStylePrivate::init()
+{
+ resolveGtk();
+ initGtkWidgets();
+ if (isThemeAvailable())
+ qApp->installEventFilter(&filter);
+}
+
+GtkWidget* QGtkStylePrivate::gtkWidget(const QString &path)
+{
+ GtkWidget *widget = gtkWidgetMap()->value(path);
+ if (!widget) {
+ // Theme might have rearranged widget internals
+ widget = gtkWidgetMap()->value(path);
+ }
+ return widget;
+}
+
+GtkStyle* QGtkStylePrivate::gtkStyle(const QString &path)
+{
+ if (gtkWidgetMap()->contains(path))
+ return gtkWidgetMap()->value(path)->style;
+ return 0;
+}
+
+/*! \internal
+ * Get references to gtk functions after we dynamically load the library.
+ */
+void QGtkStylePrivate::resolveGtk()
+{
+ // 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");
+
+ gtk_file_chooser_set_current_folder = (Ptr_gtk_file_chooser_set_current_folder)libgtk.resolve("gtk_file_chooser_set_current_folder");
+ gtk_file_filter_new = (Ptr_gtk_file_filter_new)libgtk.resolve("gtk_file_filter_new");
+ gtk_file_filter_set_name = (Ptr_gtk_file_filter_set_name)libgtk.resolve("gtk_file_filter_set_name");
+ gtk_file_filter_add_pattern = (Ptr_gtk_file_filter_add_pattern)libgtk.resolve("gtk_file_filter_add_pattern");
+ gtk_file_chooser_add_filter = (Ptr_gtk_file_chooser_add_filter)libgtk.resolve("gtk_file_chooser_add_filter");
+ gtk_file_chooser_set_filter = (Ptr_gtk_file_chooser_set_filter)libgtk.resolve("gtk_file_chooser_set_filter");
+ gtk_file_chooser_get_filter = (Ptr_gtk_file_chooser_get_filter)libgtk.resolve("gtk_file_chooser_get_filter");
+ gtk_file_chooser_dialog_new = (Ptr_gtk_file_chooser_dialog_new)libgtk.resolve("gtk_file_chooser_dialog_new");
+ gtk_file_chooser_set_current_folder = (Ptr_gtk_file_chooser_set_current_folder)libgtk.resolve("gtk_file_chooser_set_current_folder");
+ gtk_file_chooser_get_filename = (Ptr_gtk_file_chooser_get_filename)libgtk.resolve("gtk_file_chooser_get_filename");
+ gtk_file_chooser_get_filenames = (Ptr_gtk_file_chooser_get_filenames)libgtk.resolve("gtk_file_chooser_get_filenames");
+ gtk_file_chooser_set_current_name = (Ptr_gtk_file_chooser_set_current_name)libgtk.resolve("gtk_file_chooser_set_current_name");
+ gtk_dialog_run = (Ptr_gtk_dialog_run)libgtk.resolve("gtk_dialog_run");
+ gtk_file_chooser_set_filename = (Ptr_gtk_file_chooser_set_filename)libgtk.resolve("gtk_file_chooser_set_filename");
+
+ 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_pixmap_new = (Ptr_gdk_pixmap_new)libgtk.resolve("gdk_pixmap_new");
+ gdk_pixbuf_new = (Ptr_gdk_pixbuf_new)libgtk.resolve("gdk_pixbuf_new");
+ gdk_pixbuf_get_from_drawable = (Ptr_gdk_pixbuf_get_from_drawable)libgtk.resolve("gdk_pixbuf_get_from_drawable");
+ gdk_draw_rectangle = (Ptr_gdk_draw_rectangle)libgtk.resolve("gdk_draw_rectangle");
+ gdk_pixbuf_unref = (Ptr_gdk_pixbuf_unref)libgtk.resolve("gdk_pixbuf_unref");
+ gdk_drawable_unref = (Ptr_gdk_drawable_unref)libgtk.resolve("gdk_drawable_unref");
+ gdk_drawable_get_depth = (Ptr_gdk_drawable_get_depth)libgtk.resolve("gdk_drawable_get_depth");
+ 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 = (Ptr_gtk_menu_item_new)libgtk.resolve("gtk_menu_item_new");
+ gtk_check_menu_item_new = (Ptr_gtk_check_menu_item_new)libgtk.resolve("gtk_check_menu_item_new");
+ 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_progress_set_adjustment = (Ptr_gtk_progress_set_adjustment)libgtk.resolve("gtk_progress_set_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_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_paint_check = (Ptr_gtk_paint_check)libgtk.resolve("gtk_paint_check");
+ gtk_paint_box = (Ptr_gtk_paint_box)libgtk.resolve("gtk_paint_box");
+ gtk_paint_flat_box = (Ptr_gtk_paint_flat_box)libgtk.resolve("gtk_paint_flat_box");
+ gtk_paint_check = (Ptr_gtk_paint_check)libgtk.resolve("gtk_paint_check");
+ gtk_paint_box = (Ptr_gtk_paint_box)libgtk.resolve("gtk_paint_box");
+ gtk_paint_resize_grip = (Ptr_gtk_paint_resize_grip)libgtk.resolve("gtk_paint_resize_grip");
+ gtk_paint_focus = (Ptr_gtk_paint_focus)libgtk.resolve("gtk_paint_focus");
+ gtk_paint_shadow = (Ptr_gtk_paint_shadow)libgtk.resolve("gtk_paint_shadow");
+ gtk_paint_slider = (Ptr_gtk_paint_slider)libgtk.resolve("gtk_paint_slider");
+ gtk_paint_expander = (Ptr_gtk_paint_expander)libgtk.resolve("gtk_paint_expander");
+ gtk_paint_handle = (Ptr_gtk_paint_handle)libgtk.resolve("gtk_paint_handle");
+ gtk_paint_option = (Ptr_gtk_paint_option)libgtk.resolve("gtk_paint_option");
+ gtk_paint_arrow = (Ptr_gtk_paint_arrow)libgtk.resolve("gtk_paint_arrow");
+ gtk_paint_box_gap = (Ptr_gtk_paint_box_gap)libgtk.resolve("gtk_paint_box_gap");
+ gtk_paint_extension = (Ptr_gtk_paint_extension)libgtk.resolve("gtk_paint_extension");
+ gtk_paint_hline = (Ptr_gtk_paint_hline)libgtk.resolve("gtk_paint_hline");
+ gtk_paint_vline = (Ptr_gtk_paint_vline)libgtk.resolve("gtk_paint_vline");
+ 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_combo_box_entry_new = (Ptr_gtk_combo_box_entry_new)libgtk.resolve("gtk_combo_box_entry_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_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_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");
+ 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");
+}
+
+/* \internal
+ * Initializes a number of gtk menu widgets.
+ * The widgets are cached.
+ */
+void QGtkStylePrivate::initGtkMenu()
+{
+ // Create menubar
+ GtkWidget *gtkMenuBar = QGtkStylePrivate::gtk_menu_bar_new();
+ setupGtkWidget(gtkMenuBar);
+
+ GtkWidget *gtkMenuBarItem = QGtkStylePrivate::gtk_menu_item_new();
+ 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();
+ gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkMenuItem);
+ gtk_widget_realize(gtkMenuItem);
+
+ GtkWidget *gtkCheckMenuItem = QGtkStylePrivate::gtk_check_menu_item_new();
+ 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()
+{
+ 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()
+{
+ // 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;
+ }
+
+ static QString themeName;
+ if (!gtkWidgetMap()->contains(QLS("GtkWindow")) && themeName.isEmpty()) {
+ themeName = getThemeName();
+
+ if (themeName.isEmpty()) {
+ qWarning("QGtkStyle was unable to detect the current GTK+ theme.");
+ return;
+ } else if (themeName == QLS("Qt") || themeName == QLS("Qt4")) {
+ // Due to namespace conflicts with Qt3 and obvious recursion with Qt4,
+ // we cannot support the GTK_Qt Gtk engine
+ qWarning("QGtkStyle cannot be used together with the GTK_Qt engine.");
+ return;
+ }
+ }
+
+ if (QGtkStylePrivate::gtk_init) {
+ // Gtk will set the Qt error handler so we have to reset it afterwards
+ x11ErrorHandler qt_x_errhandler = XSetErrorHandler(0);
+ QGtkStylePrivate::gtk_init (NULL, NULL);
+ XSetErrorHandler(qt_x_errhandler);
+
+ // make a window
+ GtkWidget* gtkWindow = QGtkStylePrivate::gtk_window_new(GTK_WINDOW_POPUP);
+ QGtkStylePrivate::gtk_widget_realize(gtkWindow);
+ if (displayDepth == -1)
+ displayDepth = QGtkStylePrivate::gdk_drawable_get_depth(gtkWindow->window);
+ gtkWidgetMap()->insert(QLS("GtkWindow"), 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(QLS("GtkButton"))) {
+ GtkWidget *gtkButton = QGtkStylePrivate::gtk_button_new();
+ addWidget(gtkButton);
+ g_signal_connect(gtkButton, "style-set", G_CALLBACK(gtkStyleSetCallback), this);
+ addWidget(QGtkStylePrivate::gtk_tool_button_new(NULL, NULL));
+ 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());
+ addWidget(QGtkStylePrivate::gtk_entry_new());
+ addWidget(QGtkStylePrivate::gtk_frame_new(NULL));
+ addWidget(QGtkStylePrivate::gtk_expander_new(""));
+ addWidget(QGtkStylePrivate::gtk_statusbar_new());
+ addWidget(QGtkStylePrivate::gtk_hscale_new((GtkAdjustment*)(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((GtkAdjustment*)
+ (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((GtkAdjustment*)(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<QString, GtkWidget*> oldMap = *gtkWidgetMap();
+ gtkWidgetMap()->clear();
+ QHashIterator<QString, GtkWidget*> it(oldMap);
+ while (it.hasNext()) {
+ it.next();
+ if (!it.key().contains(QLatin1Char('.'))) {
+ addAllSubWidgets(it.value());
+ }
+ }
+ }
+ } 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 (gtkWidgetMap()->contains(QLS("GtkWindow"))) // Gtk will destroy all children
+ gtk_widget_destroy(gtkWidgetMap()->value(QLS("GtkWindow")));
+}
+
+static bool resolveGConf()
+{
+ 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");
+ }
+ return (QGtkStylePrivate::gconf_client_get_default !=0);
+}
+
+QString QGtkStylePrivate::getGConfString(const QString &value, const QString &fallback)
+{
+ QString retVal = fallback;
+ if (resolveGConf()) {
+ g_type_init();
+ 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()) {
+ g_type_init();
+ 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() const
+{
+ QString themeName;
+ // We try to parse the gtkrc file first
+ // primarily to avoid resolving Gtk functions if
+ // the KDE 3 "Qt" style is currently in use
+ QString rcPaths = QString::fromLocal8Bit(qgetenv("GTK2_RC_FILES"));
+ if (!rcPaths.isEmpty()) {
+ QStringList paths = rcPaths.split(QLS(":"));
+ foreach (const QString &rcPath, paths) {
+ if (!rcPath.isEmpty()) {
+ QFile rcFile(rcPath);
+ if (rcFile.exists() && rcFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ QTextStream in(&rcFile);
+ while(!in.atEnd()) {
+ QString line = in.readLine();
+ if (line.contains(QLS("gtk-theme-name"))) {
+ line = line.right(line.length() - line.indexOf(QLatin1Char('=')) - 1);
+ line.remove(QLatin1Char('\"'));
+ line = line.trimmed();
+ themeName = line;
+ break;
+ }
+ }
+ }
+ }
+ if (!themeName.isEmpty())
+ break;
+ }
+ }
+
+ // Fall back to gconf
+ if (themeName.isEmpty() && resolveGConf())
+ themeName = getGConfString(QLS("/desktop/gnome/interface/gtk_theme"));
+
+ return themeName;
+}
+
+// Get size of the arrow controls in a GtkSpinButton
+int QGtkStylePrivate::getSpinboxArrowSize() const
+{
+ const int MIN_ARROW_WIDTH = 6;
+ GtkWidget *spinButton = gtkWidget(QLS("GtkSpinButton"));
+ GtkStyle *style = spinButton->style;
+ 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(QLS("GtkMenu"));
+ GdkColor gdkBg = gtkWidget(QLS("GtkMenu"))->style->bg[GTK_STATE_NORMAL];
+ QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
+ menuPal.setBrush(QPalette::Base, bgColor);
+ menuPal.setBrush(QPalette::Window, bgColor);
+ qApp->setPalette(menuPal, "QMenu");
+
+ QPalette toolbarPal = gtkWidgetPalette(QLS("GtkToolbar"));
+ qApp->setPalette(toolbarPal, "QToolBar");
+
+ QPalette menuBarPal = gtkWidgetPalette(QLS("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(QLS("GtkEntry"));
+}
+
+void QGtkStylePrivate::setupGtkWidget(GtkWidget* widget)
+{
+ if (Q_GTK_IS_WIDGET(widget)) {
+ static GtkWidget* protoLayout = 0;
+ if (!protoLayout) {
+ protoLayout = QGtkStylePrivate::gtk_fixed_new();
+ QGtkStylePrivate::gtk_container_add((GtkContainer*)(gtkWidgetMap()->value(QLS("GtkWindow"))), protoLayout);
+ }
+ Q_ASSERT(protoLayout);
+
+ if (!widget->parent && !GTK_WIDGET_TOPLEVEL(widget))
+ QGtkStylePrivate::gtk_container_add((GtkContainer*)(protoLayout), widget);
+ QGtkStylePrivate::gtk_widget_realize(widget);
+ }
+}
+
+void QGtkStylePrivate::addWidgetToMap(GtkWidget *widget)
+{
+ if (Q_GTK_IS_WIDGET(widget)) {
+ gtk_widget_realize(widget);
+ gtkWidgetMap()->insert(classPath(widget), widget);
+ }
+ }
+
+void QGtkStylePrivate::addAllSubWidgets(GtkWidget *widget, gpointer v)
+{
+ Q_UNUSED(v);
+ addWidgetToMap(widget);
+ if (GTK_CHECK_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 QString &gtkWidgetName)
+{
+ GtkWidget *gtkWidget = QGtkStylePrivate::gtkWidget(gtkWidgetName);
+ Q_ASSERT(gtkWidget);
+ QPalette pal = QApplication::palette();
+ GdkColor gdkBg = gtkWidget->style->bg[GTK_STATE_NORMAL];
+ GdkColor gdkText = gtkWidget->style->fg[GTK_STATE_NORMAL];
+ GdkColor gdkDisabledText = gtkWidget->style->fg[GTK_STATE_INSENSITIVE];
+ 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( QGtkStylePrivate* stylePrivate )
+{
+ static QString oldTheme(QLS("qt_not_set"));
+ QPixmapCache::clear();
+
+ QFont font = QGtkStylePrivate::getThemeFont();
+ if (QApplication::font() != font)
+ qApp->setFont(font);
+
+ if (oldTheme != stylePrivate->getThemeName()) {
+ oldTheme = stylePrivate->getThemeName();
+ QPalette newPalette = qApp->style()->standardPalette();
+ QApplicationPrivate::setSystemPalette(newPalette);
+ QApplication::setPalette(newPalette);
+ stylePrivate->initGtkWidgets();
+ stylePrivate->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);
+
+ int weight = pango_font_description_get_weight(gtk_font);
+ if (weight >= PANGO_WEIGHT_HEAVY)
+ font.setWeight(QFont::Black);
+ else if (weight >= PANGO_WEIGHT_BOLD)
+ font.setWeight(QFont::Bold);
+ else if (weight >= PANGO_WEIGHT_SEMIBOLD)
+ font.setWeight(QFont::DemiBold);
+ else if (weight >= PANGO_WEIGHT_NORMAL)
+ font.setWeight(QFont::Normal);
+ else
+ font.setWeight(QFont::Light);
+
+ 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;
+}
+
+
+// ----------- Native file dialogs -----------
+
+// Extract filter list from expressions of type: foo (*.a *.b *.c)"
+QStringList QGtkStylePrivate::extract_filter(const QString &rawFilter)
+{
+ QString result = rawFilter;
+ QRegExp r(QString::fromLatin1("^([^()]*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$"));
+ int index = r.indexIn(result);
+ if (index >= 0)
+ result = r.cap(2);
+ return result.split(QLatin1Char(' '));
+}
+
+extern QStringList qt_make_filter_list(const QString &filter);
+
+void QGtkStylePrivate::setupGtkFileChooser(GtkWidget* gtkFileChooser, QWidget *parent,
+ const QString &dir, const QString &filter, QString *selectedFilter,
+ QFileDialog::Options options, bool isSaveDialog,
+ QMap<GtkFileFilter *, QString> *filterMap)
+{
+ g_object_set(gtkFileChooser, "do-overwrite-confirmation", gboolean(!(options & QFileDialog::DontConfirmOverwrite)), NULL);
+ g_object_set(gtkFileChooser, "local_only", gboolean(true), NULL);
+ if (!filter.isEmpty()) {
+ QStringList filters = qt_make_filter_list(filter);
+ foreach (const QString &rawfilter, filters) {
+ GtkFileFilter *gtkFilter = QGtkStylePrivate::gtk_file_filter_new ();
+ QString name = rawfilter.left(rawfilter.indexOf(QLatin1Char('(')));
+ QStringList extensions = extract_filter(rawfilter);
+ QGtkStylePrivate::gtk_file_filter_set_name(gtkFilter, qPrintable(name.isEmpty() ? extensions.join(QLS(", ")) : name));
+
+ foreach (const QString &fileExtension, extensions) {
+ // Note Gtk file dialogs are by default case sensitive
+ // and only supports basic glob syntax so we
+ // rewrite .xyz to .[xX][yY][zZ]
+ QString caseInsensitive;
+ for (int i = 0 ; i < fileExtension.length() ; ++i) {
+ QChar ch = fileExtension.at(i);
+ if (ch.isLetter()) {
+ caseInsensitive.append(
+ QLatin1Char('[') +
+ ch.toLower() +
+ ch.toUpper() +
+ QLatin1Char(']'));
+ } else {
+ caseInsensitive.append(ch);
+ }
+ }
+ QGtkStylePrivate::gtk_file_filter_add_pattern (gtkFilter, qPrintable(caseInsensitive));
+
+ }
+ if (filterMap)
+ filterMap->insert(gtkFilter, rawfilter);
+ QGtkStylePrivate::gtk_file_chooser_add_filter((GtkFileChooser*)gtkFileChooser, gtkFilter);
+ if (selectedFilter && (rawfilter == *selectedFilter))
+ QGtkStylePrivate::gtk_file_chooser_set_filter((GtkFileChooser*)gtkFileChooser, gtkFilter);
+ }
+ }
+
+ // Using the currently active window is not entirely correct, however
+ // it gives more sensible behavior for applications that do not provide a
+ // parent
+ QWidget *modalFor = parent ? parent->window() : qApp->activeWindow();
+ if (modalFor) {
+ QGtkStylePrivate::gtk_widget_realize(gtkFileChooser); // Creates X window
+ XSetTransientForHint(QGtkStylePrivate::gdk_x11_drawable_get_xdisplay(gtkFileChooser->window),
+ QGtkStylePrivate::gdk_x11_drawable_get_xid(gtkFileChooser->window),
+ modalFor->winId());
+ QGtkStylePrivate::gdk_x11_window_set_user_time (gtkFileChooser->window, QX11Info::appUserTime());
+
+ }
+
+ QFileInfo fileinfo(dir);
+ if (dir.isEmpty())
+ fileinfo.setFile(QDir::currentPath());
+ fileinfo.makeAbsolute();
+ if (fileinfo.isDir()) {
+ QGtkStylePrivate::gtk_file_chooser_set_current_folder((GtkFileChooser*)gtkFileChooser, qPrintable(dir));
+ } else if (isSaveDialog) {
+ QGtkStylePrivate::gtk_file_chooser_set_current_folder((GtkFileChooser*)gtkFileChooser, qPrintable(fileinfo.absolutePath()));
+ QGtkStylePrivate::gtk_file_chooser_set_current_name((GtkFileChooser*)gtkFileChooser, qPrintable(fileinfo.fileName()));
+ } else {
+ QGtkStylePrivate::gtk_file_chooser_set_filename((GtkFileChooser*)gtkFileChooser, qPrintable(dir));
+ }
+}
+
+QString QGtkStylePrivate::openFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
+ QString *selectedFilter, QFileDialog::Options options)
+{
+ QMap<GtkFileFilter *, QString> filterMap;
+ GtkWidget *gtkFileChooser = QGtkStylePrivate::gtk_file_chooser_dialog_new (qPrintable(caption),
+ NULL,
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ setupGtkFileChooser(gtkFileChooser, parent, dir, filter, selectedFilter, options, false, &filterMap);
+
+ QWidget modal_widget;
+ modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
+ modal_widget.setParent(parent, Qt::Window);
+ QApplicationPrivate::enterModal(&modal_widget);
+
+ QString filename;
+ if (QGtkStylePrivate::gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
+ char *gtk_filename = QGtkStylePrivate::gtk_file_chooser_get_filename ((GtkFileChooser*)gtkFileChooser);
+ filename = QString::fromUtf8(gtk_filename);
+ g_free (gtk_filename);
+ if (selectedFilter) {
+ GtkFileFilter *gtkFilter = QGtkStylePrivate::gtk_file_chooser_get_filter ((GtkFileChooser*)gtkFileChooser);
+ *selectedFilter = filterMap.value(gtkFilter);
+ }
+ }
+
+ QApplicationPrivate::leaveModal(&modal_widget);
+ gtk_widget_destroy (gtkFileChooser);
+ return filename;
+}
+
+
+QString QGtkStylePrivate::openDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options)
+{
+ QMap<GtkFileFilter *, QString> filterMap;
+ GtkWidget *gtkFileChooser = QGtkStylePrivate::gtk_file_chooser_dialog_new (qPrintable(caption),
+ NULL,
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ setupGtkFileChooser(gtkFileChooser, parent, dir, QString(), 0, options);
+ QWidget modal_widget;
+ modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
+ modal_widget.setParent(parent, Qt::Window);
+ QApplicationPrivate::enterModal(&modal_widget);
+
+ QString filename;
+ if (QGtkStylePrivate::gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
+ char *gtk_filename = QGtkStylePrivate::gtk_file_chooser_get_filename ((GtkFileChooser*)gtkFileChooser);
+ filename = QString::fromUtf8(gtk_filename);
+ g_free (gtk_filename);
+ }
+
+ QApplicationPrivate::leaveModal(&modal_widget);
+ gtk_widget_destroy (gtkFileChooser);
+ return filename;
+}
+
+QStringList QGtkStylePrivate::openFilenames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
+ QString *selectedFilter, QFileDialog::Options options)
+{
+ QStringList filenames;
+ QMap<GtkFileFilter *, QString> filterMap;
+ GtkWidget *gtkFileChooser = QGtkStylePrivate::gtk_file_chooser_dialog_new (qPrintable(caption),
+ NULL,
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ setupGtkFileChooser(gtkFileChooser, parent, dir, filter, selectedFilter, options, false, &filterMap);
+ g_object_set(gtkFileChooser, "select-multiple", gboolean(true), NULL);
+
+ QWidget modal_widget;
+ modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
+ modal_widget.setParent(parent, Qt::Window);
+ QApplicationPrivate::enterModal(&modal_widget);
+
+ if (gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
+ GSList *gtk_file_names = QGtkStylePrivate::gtk_file_chooser_get_filenames((GtkFileChooser*)gtkFileChooser);
+ for (GSList *iterator = gtk_file_names ; iterator; iterator = iterator->next)
+ filenames << QString::fromUtf8((const char*)iterator->data);
+ g_slist_free(gtk_file_names);
+ if (selectedFilter) {
+ GtkFileFilter *gtkFilter = QGtkStylePrivate::gtk_file_chooser_get_filter ((GtkFileChooser*)gtkFileChooser);
+ *selectedFilter = filterMap.value(gtkFilter);
+ }
+ }
+
+ QApplicationPrivate::leaveModal(&modal_widget);
+ gtk_widget_destroy (gtkFileChooser);
+ return filenames;
+}
+
+QString QGtkStylePrivate::saveFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
+ QString *selectedFilter, QFileDialog::Options options)
+{
+ QMap<GtkFileFilter *, QString> filterMap;
+ GtkWidget *gtkFileChooser = QGtkStylePrivate::gtk_file_chooser_dialog_new (qPrintable(caption),
+ NULL,
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
+ NULL);
+ setupGtkFileChooser(gtkFileChooser, parent, dir, filter, selectedFilter, options, true, &filterMap);
+
+ QWidget modal_widget;
+ modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
+ modal_widget.setParent(parent, Qt::Window);
+ QApplicationPrivate::enterModal(&modal_widget);
+
+ QString filename;
+ if (QGtkStylePrivate::gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
+ char *gtk_filename = QGtkStylePrivate::gtk_file_chooser_get_filename ((GtkFileChooser*)gtkFileChooser);
+ filename = QString::fromUtf8(gtk_filename);
+ g_free (gtk_filename);
+ if (selectedFilter) {
+ GtkFileFilter *gtkFilter = QGtkStylePrivate::gtk_file_chooser_get_filter ((GtkFileChooser*)gtkFileChooser);
+ *selectedFilter = filterMap.value(gtkFilter);
+ }
+ }
+
+ QApplicationPrivate::leaveModal(&modal_widget);
+ gtk_widget_destroy (gtkFileChooser);
+ return filename;
+}
+
+QIcon QGtkStylePrivate::getFilesystemIcon(const QFileInfo &info)
+{
+ QIcon icon;
+ if (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;
+}
+
+QT_END_NAMESPACE
+
+#endif // !defined(QT_NO_STYLE_GTK)
diff --git a/src/gui/styles/gtksymbols_p.h b/src/gui/styles/qgtkstyle_p.h
index 2cf21ce..fa16769 100644
--- a/src/gui/styles/gtksymbols_p.h
+++ b/src/gui/styles/qgtkstyle_p.h
@@ -39,8 +39,8 @@
**
****************************************************************************/
-#ifndef GTKSYMBOLS_H
-#define GTKSYMBOLS_H
+#ifndef QGTKSTYLE_P_H
+#define QGTKSTYLE_P_H
//
// W A R N I N G
@@ -56,19 +56,19 @@
#include <QtCore/qglobal.h>
#if !defined(QT_NO_STYLE_GTK)
+#include <QtGui/QFileDialog>
+
+#include <QtGui/QGtkStyle>
+#include <private/qcleanlooksstyle_p.h>
+
#undef signals // Collides with GTK stymbols
#include <gtk/gtk.h>
-#include <QtCore/QLibrary>
-#include <QtGui/QFont>
-#include <QtGui/QFileDialog>
+
typedef unsigned long XID;
#undef GTK_OBJECT_FLAGS
#define GTK_OBJECT_FLAGS(obj)(((GtkObject*)(obj))->flags)
-#define Q_GTK_TYPE_WIDGET QGtk::gtk_widget_get_type()
-#define Q_GTK_IS_WIDGET(widget) widget && GTK_CHECK_TYPE ((widget), Q_GTK_TYPE_WIDGET)
-#define Q_GTK_TYPE_WINDOW QGtk::gtk_window_get_type()
-#define Q_GTK_TYPE_CONTAINER QGtk::gtk_container_get_type()
+#define Q_GTK_IS_WIDGET(widget) widget && GTK_CHECK_TYPE ((widget), QGtkStylePrivate::gtk_widget_get_type())
#define QLS(x) QLatin1String(x)
@@ -198,6 +198,35 @@ typedef XID (*Ptr_gdk_x11_drawable_get_xid) (GdkDrawable *);
typedef Display* (*Ptr_gdk_x11_drawable_get_xdisplay) ( GdkDrawable *);
+QT_BEGIN_NAMESPACE
+
+typedef QStringList (*_qt_filedialog_open_filenames_hook)(QWidget * parent, const QString &caption, const QString &dir,
+ const QString &filter, QString *selectedFilter, QFileDialog::Options options);
+typedef QString (*_qt_filedialog_open_filename_hook) (QWidget * parent, const QString &caption, const QString &dir,
+ const QString &filter, QString *selectedFilter, QFileDialog::Options options);
+typedef QString (*_qt_filedialog_save_filename_hook) (QWidget * parent, const QString &caption, const QString &dir,
+ const QString &filter, QString *selectedFilter, QFileDialog::Options options);
+typedef QString (*_qt_filedialog_existing_directory_hook)(QWidget *parent, const QString &caption, const QString &dir,
+ QFileDialog::Options options);
+
+extern Q_GUI_EXPORT _qt_filedialog_open_filename_hook qt_filedialog_open_filename_hook;
+extern Q_GUI_EXPORT _qt_filedialog_open_filenames_hook qt_filedialog_open_filenames_hook;
+extern Q_GUI_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook;
+extern Q_GUI_EXPORT _qt_filedialog_existing_directory_hook qt_filedialog_existing_directory_hook;
+
+class QGtkStylePrivate;
+
+class QGtkStyleFilter : public QObject
+{
+public:
+ QGtkStyleFilter(QGtkStylePrivate* sp)
+ : stylePrivate(sp)
+ {}
+private:
+ QGtkStylePrivate* stylePrivate;
+ bool eventFilter(QObject *obj, QEvent *e);
+};
+
typedef enum {
GNOME_ICON_LOOKUP_FLAGS_NONE = 0,
GNOME_ICON_LOOKUP_FLAGS_EMBEDDING_TEXT = 1<<0,
@@ -220,21 +249,41 @@ typedef char* (*Ptr_gnome_icon_lookup_sync) (
GnomeIconLookupFlags flags,
GnomeIconLookupResultFlags *result);
-QT_BEGIN_NAMESPACE
-class QGtk
+class QGtkStylePrivate : public QCleanlooksStylePrivate
{
+ Q_DECLARE_PUBLIC(QGtkStyle)
public:
+ QGtkStylePrivate();
+
+ QGtkStyleFilter filter;
+
static GtkWidget* gtkWidget(const QString &path);
static GtkStyle* gtkStyle(const QString &path = QLatin1String("GtkWindow"));
- static void cleanup_gtk_widgets();
- static void initGtkWidgets();
+ virtual void resolveGtk();
+ virtual void initGtkMenu();
+ virtual void initGtkTreeview();
+ virtual void initGtkWidgets();
+
+ static void cleanupGtkWidgets();
+
static bool isKDE4Session();
- static void applyCustomPaletteHash();
+ 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());
+
+ virtual QString getThemeName() const;
+ virtual int getSpinboxArrowSize() const;
+
+ static void setupGtkFileChooser(GtkWidget* gtkFileChooser, QWidget *parent,
+ const QString &dir, const QString &filter, QString *selectedFilter,
+ QFileDialog::Options options, bool isSaveDialog = false,
+ QMap<GtkFileFilter *, QString> *filterMap = 0);
+
static QString openFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
QString *selectedFilter, QFileDialog::Options options);
static QString saveFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
@@ -242,8 +291,6 @@ public:
static QString openDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options);
static QStringList openFilenames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
QString *selectedFilter, QFileDialog::Options options);
- static QString getGConfString(const QString &key, const QString &fallback = QString());
- static bool getGConfBool(const QString &key, bool fallback = 0);
static QIcon getFilesystemIcon(const QFileInfo &);
static Ptr_gtk_container_forall gtk_container_forall;
@@ -364,6 +411,29 @@ public:
static Ptr_gnome_icon_lookup_sync gnome_icon_lookup_sync;
static Ptr_gnome_vfs_init gnome_vfs_init;
+
+ virtual QPalette gtkWidgetPalette(const QString &gtkWidgetName);
+
+protected:
+ typedef QHash<QString, GtkWidget*> WidgetMap;
+
+ static inline WidgetMap *gtkWidgetMap()
+ {
+ static WidgetMap *map = 0;
+ if (!map)
+ map = new WidgetMap();
+ return map;
+ }
+
+ 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);
+
+ virtual void init();
};
// Helper to ensure that we have polished all our gtk widgets
@@ -372,10 +442,10 @@ class QGtkStyleUpdateScheduler : public QObject
{
Q_OBJECT
public slots:
- void updateTheme();
+ void updateTheme( QGtkStylePrivate* stylePrivate );
};
QT_END_NAMESPACE
#endif // !QT_NO_STYLE_GTK
-#endif // GTKSYMBOLS_H
+#endif // QGTKSTYLE_P_H
diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp
index 09f5d36..f880351 100644
--- a/src/gui/styles/qplastiquestyle.cpp
+++ b/src/gui/styles/qplastiquestyle.cpp
@@ -5514,9 +5514,6 @@ int QPlastiqueStyle::pixelMetric(PixelMetric metric, const QStyleOption *option,
case PM_MenuHMargin:
ret = 0;
break;
- case PM_ToolBarIconSize:
- ret = 24;
- break;
case PM_ButtonShiftHorizontal:
case PM_ButtonShiftVertical:
ret = 1;
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index 8d59d14..350a8e6 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -66,7 +66,6 @@
#include "qtextedit.h"
#include "qtoolbar.h"
#include "qtoolbutton.h"
-#include "qtreeview.h"
#include "qfocusframe.h"
#include "private/qtoolbarextension_p.h"
@@ -91,14 +90,14 @@ static const qreal goldenRatio = 1.618;
const layoutHeader QS60StylePrivate::m_layoutHeaders[] = {
// *** generated layout data ***
-{240,320,1,14,true,"QVGA Landscape Mirrored"},
-{240,320,1,14,false,"QVGA Landscape"},
-{320,240,1,14,true,"QVGA Portrait Mirrored"},
-{320,240,1,14,false,"QVGA Portrait"},
-{360,640,1,14,true,"NHD Landscape Mirrored"},
-{360,640,1,14,false,"NHD Landscape"},
-{640,360,1,14,true,"NHD Portrait Mirrored"},
-{640,360,1,14,false,"NHD Portrait"},
+{240,320,1,15,true,"QVGA Landscape Mirrored"},
+{240,320,1,15,false,"QVGA Landscape"},
+{320,240,1,15,true,"QVGA Portrait Mirrored"},
+{320,240,1,15,false,"QVGA Portrait"},
+{360,640,1,15,true,"NHD Landscape Mirrored"},
+{360,640,1,15,false,"NHD Landscape"},
+{640,360,1,15,true,"NHD Portrait Mirrored"},
+{640,360,1,15,false,"NHD Portrait"},
{352,800,1,12,true,"E90 Landscape Mirrored"},
{352,800,1,12,false,"E90 Landscape"}
// *** End of generated data ***
@@ -108,16 +107,16 @@ const int QS60StylePrivate::m_numberOfLayouts =
const short QS60StylePrivate::data[][MAX_PIXELMETRICS] = {
// *** generated pixel metrics ***
-{5,0,-909,0,0,1,0,0,-1,8,15,22,15,15,7,198,-909,-909,-909,19,15,2,0,0,21,-909,21,-909,4,4,1,-909,-909,0,2,0,0,13,23,17,17,21,21,2,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,51,27,51,4,4,5,10,15,-909,5,58,12,5,0,7,4,4,9,4,4,-909,1,-909,-909,-909,-909,4,4,3,1},
-{5,0,-909,0,0,1,0,0,-1,8,15,22,15,15,7,198,-909,-909,-909,19,15,2,0,0,21,-909,21,-909,4,4,1,-909,-909,0,2,0,0,13,23,17,17,21,21,2,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,51,27,51,4,4,5,10,15,-909,5,58,12,5,0,4,4,7,9,4,4,-909,1,-909,-909,-909,-909,4,4,3,1},
-{5,0,-909,0,0,1,0,0,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,-909,27,-909,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,4,4,5,10,15,-909,5,58,13,5,0,7,4,4,9,4,4,-909,1,-909,-909,-909,-909,4,4,3,1},
-{5,0,-909,0,0,1,0,0,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,-909,27,-909,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,4,4,5,10,15,-909,5,58,13,5,0,4,4,7,9,4,4,-909,1,-909,-909,-909,-909,4,4,3,1},
-{7,0,-909,0,0,2,0,0,-1,20,53,28,19,19,9,258,-909,-909,-909,29,19,26,0,0,32,-909,72,-909,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,5,5,6,8,19,-909,7,74,19,7,0,8,5,5,12,5,5,-909,2,-909,-909,-909,-909,7,7,3,1},
-{7,0,-909,0,0,2,0,0,-1,20,53,28,19,19,9,258,-909,-909,-909,29,19,26,0,0,32,-909,72,-909,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,5,5,6,8,19,-909,7,74,19,7,0,5,5,8,12,5,5,-909,2,-909,-909,-909,-909,7,7,3,1},
-{7,0,-909,0,0,2,0,0,-1,20,52,28,19,19,9,258,-909,-909,-909,29,19,6,0,0,32,-909,60,-909,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,98,35,98,5,5,6,8,19,-909,7,74,22,7,0,8,5,5,12,5,5,-909,2,-909,-909,-909,-909,7,7,3,1},
-{7,0,-909,0,0,2,0,0,-1,20,52,28,19,19,9,258,-909,-909,-909,29,19,6,0,0,32,-909,60,-909,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,98,35,98,5,5,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,2,-909,-909,-909,-909,7,7,3,1},
-{7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,-909,32,-909,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,5,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,8,6,5,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1},
-{7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,-909,32,-909,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1}
+{5,0,-909,0,0,2,0,0,-1,7,12,19,13,13,6,200,-909,-909,-909,20,13,2,0,0,21,7,18,-909,3,3,1,-909,-909,0,1,0,0,12,20,15,15,18,18,1,115,18,0,-909,-909,-909,-909,0,0,16,2,-909,0,0,-909,16,-909,-909,-909,-909,32,18,55,24,55,3,3,4,9,13,-909,5,51,11,5,0,6,3,3,8,3,3,-909,2,-909,-909,-909,-909,5,5,3,1},
+{5,0,-909,0,0,2,0,0,-1,7,12,19,13,13,6,200,-909,-909,-909,20,13,2,0,0,21,7,18,-909,3,3,1,-909,-909,0,1,0,0,12,20,15,15,18,18,1,115,18,0,-909,-909,-909,-909,0,0,16,2,-909,0,0,-909,16,-909,-909,-909,-909,32,18,55,24,55,3,3,4,9,13,-909,5,51,11,5,0,3,3,6,8,3,3,-909,2,-909,-909,-909,-909,5,5,3,1},
+{5,0,-909,0,0,1,0,0,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,8,27,-909,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,4,4,5,10,15,-909,5,58,13,5,0,7,4,4,9,4,4,-909,2,-909,-909,-909,-909,6,6,3,1},
+{5,0,-909,0,0,1,0,0,-1,8,14,22,15,15,7,164,-909,-909,-909,19,15,2,0,0,21,8,27,-909,4,4,1,-909,-909,0,7,6,0,13,23,17,17,21,21,7,115,21,0,-909,-909,-909,-909,0,0,15,1,-909,0,0,-909,15,-909,-909,-909,-909,32,21,65,27,65,4,4,5,10,15,-909,5,58,13,5,0,4,4,7,9,4,4,-909,2,-909,-909,-909,-909,6,6,3,1},
+{7,0,-909,0,0,2,0,0,-1,25,69,28,19,19,9,258,-909,-909,-909,23,19,26,0,0,32,25,72,-909,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,5,5,6,8,19,-909,7,74,19,7,0,8,5,5,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1},
+{7,0,-909,0,0,2,0,0,-1,25,69,28,19,19,9,258,-909,-909,-909,23,19,26,0,0,32,25,72,-909,5,5,2,-909,-909,0,7,21,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,25,2,-909,0,0,-909,25,-909,-909,-909,-909,87,27,77,35,77,5,5,6,8,19,-909,7,74,19,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1},
+{7,0,-909,0,0,2,0,0,-1,25,68,28,19,19,9,258,-909,-909,-909,31,19,6,0,0,32,25,60,-909,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,96,35,96,5,5,6,8,19,-909,7,74,22,7,0,8,5,5,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1},
+{7,0,-909,0,0,2,0,0,-1,25,68,28,19,19,9,258,-909,-909,-909,31,19,6,0,0,32,25,60,-909,5,5,2,-909,-909,0,7,32,0,17,29,22,22,27,27,7,173,29,0,-909,-909,-909,-909,0,0,26,2,-909,0,0,-909,26,-909,-909,-909,-909,87,27,96,35,96,5,5,6,8,19,-909,7,74,22,7,0,5,5,8,12,5,5,-909,3,-909,-909,-909,-909,7,7,3,1},
+{7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,-909,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,5,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,8,6,5,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1},
+{7,0,-909,0,0,2,0,0,-1,10,20,27,18,18,9,301,-909,-909,-909,29,18,5,0,0,35,7,32,-909,5,5,2,-909,-909,0,2,8,0,16,28,21,21,26,26,2,170,26,0,-909,-909,-909,-909,0,0,21,6,-909,0,0,-909,-909,-909,-909,-909,-909,54,26,265,34,265,5,5,6,3,18,-909,7,72,19,7,0,5,6,8,11,6,5,-909,2,-909,-909,-909,-909,5,5,3,1}
// *** End of generated data ***
};
@@ -500,7 +499,7 @@ void QS60StylePrivate::setBackgroundTexture(QApplication *app) const
Q_UNUSED(app)
QPalette applicationPalette = QApplication::palette();
applicationPalette.setBrush(QPalette::Window, backgroundTexture());
- QApplication::setPalette(applicationPalette);
+ setThemePalette(app);
}
void QS60StylePrivate::deleteBackground()
@@ -526,7 +525,8 @@ void QS60StylePrivate::drawPart(QS60StyleEnums::SkinParts skinPart,
#else
true;
#endif
- const QPixmap skinPartPixMap((doCache ? cachedPart : part)(skinPart, rect.size(), flags));
+
+ const QPixmap skinPartPixMap((doCache ? cachedPart : part)(skinPart, rect.size(), painter, flags));
if (!skinPartPixMap.isNull())
painter->drawPixmap(rect.topLeft(), skinPartPixMap);
}
@@ -593,14 +593,14 @@ void QS60StylePrivate::drawRow(QS60StyleEnums::SkinParts start,
}
QPixmap QS60StylePrivate::cachedPart(QS60StyleEnums::SkinParts part,
- const QSize &size, SkinElementFlags flags)
+ const QSize &size, QPainter *painter, SkinElementFlags flags)
{
QPixmap result;
const QString cacheKey =
QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinPartFlags=%4")
.arg((int)part).arg(size.width()).arg(size.height()).arg((int)flags);
if (!QPixmapCache::find(cacheKey, result)) {
- result = QS60StylePrivate::part(part, size, flags);
+ result = QS60StylePrivate::part(part, size, painter, flags);
QPixmapCache::insert(cacheKey, result);
}
return result;
@@ -743,7 +743,7 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const
const QColor mainAreaTextColor =
s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0);
- widgetPalette.setColor(QPalette::All, QPalette::WindowText,
+ widgetPalette.setColor(QPalette::WindowText,
s60Color(QS60StyleEnums::CL_QsnLineColors, 8, 0));
QApplication::setPalette(widgetPalette, "QSlider");
// return to original palette after each widget
@@ -767,34 +767,34 @@ void QS60StylePrivate::setThemePaletteHash(QPalette *palette) const
QApplication::setPalette(widgetPalette, "QHeaderView");
widgetPalette = *palette;
- widgetPalette.setColor(QPalette::All, QPalette::ButtonText,
+ widgetPalette.setColor(QPalette::ButtonText,
s60Color(QS60StyleEnums::CL_QsnTextColors, 8, 0));
QApplication::setPalette(widgetPalette, "QMenuBar");
widgetPalette = *palette;
- widgetPalette.setColor(QPalette::Active, QPalette::WindowText,
+ widgetPalette.setColor(QPalette::WindowText,
s60Color(QS60StyleEnums::CL_QsnTextColors, 4, 0));
QApplication::setPalette(widgetPalette, "QTabBar");
widgetPalette = *palette;
- widgetPalette.setColor(QPalette::All, QPalette::Text,
+ widgetPalette.setColor(QPalette::Text,
s60Color(QS60StyleEnums::CL_QsnTextColors, 22, 0));
QApplication::setPalette(widgetPalette, "QTableView");
widgetPalette = *palette;
- widgetPalette.setColor(QPalette::All, QPalette::HighlightedText,
+ widgetPalette.setColor(QPalette::HighlightedText,
s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0));
QApplication::setPalette(widgetPalette, "QLineEdit");
widgetPalette = *palette;
- widgetPalette.setColor(QPalette::All, QPalette::Text,
+ widgetPalette.setColor(QPalette::Text,
s60Color(QS60StyleEnums::CL_QsnTextColors, 34, 0));
- widgetPalette.setColor(QPalette::All, QPalette::HighlightedText,
+ widgetPalette.setColor(QPalette::HighlightedText,
s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0));
QApplication::setPalette(widgetPalette, "QTextEdit");
widgetPalette = *palette;
- widgetPalette.setColor(QPalette::All, QPalette::HighlightedText,
+ widgetPalette.setColor(QPalette::HighlightedText,
s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0));
QApplication::setPalette(widgetPalette, "QComboBox");
widgetPalette = *palette;
@@ -994,6 +994,10 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
const State bflags = toolBtn->state;
const QRect button(subControlRect(control, toolBtn, SC_ToolButton, widget));
+ QRect menuRect = QRect();
+ if (toolBtn->subControls & SC_ToolButtonMenu)
+ menuRect = subControlRect(control, toolBtn, SC_ToolButtonMenu, widget);
+
QStyleOptionToolButton toolButton = *toolBtn;
if (sub&SC_ToolButton) {
@@ -1006,7 +1010,7 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
toolBar = qobject_cast<QToolBar *>(widget->parentWidget());
if (bflags & (State_Sunken | State_On | State_Raised)) {
- tool.rect = button;
+ tool.rect = button.unite(menuRect);
tool.state = bflags;
// todo: I'd like to move extension button next to where last button is
@@ -1061,6 +1065,12 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
} else {
drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
}
+
+ if (toolButton.subControls & SC_ToolButtonMenu) {
+ tool.rect = menuRect;
+ tool.state = bflags;
+ drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget);
+ }
}
}
@@ -1315,13 +1325,13 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
painter->setClipRect(voptAdj.rect);
const bool isSelected = (vopt->state & QStyle::State_Selected);
- bool isVisible = false;
+ bool isScrollBarVisible = false;
int scrollBarWidth = 0;
QList<QScrollBar *> scrollBars = qFindChildren<QScrollBar *>(widget);
for (int i = 0; i < scrollBars.size(); ++i) {
QScrollBar *scrollBar = scrollBars.at(i);
if (scrollBar && scrollBar->orientation() == Qt::Vertical) {
- isVisible = scrollBar->isVisible();
+ isScrollBarVisible = scrollBar->isVisible();
scrollBarWidth = scrollBar->size().width();
break;
}
@@ -1329,7 +1339,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
int rightValue = widget ? widget->contentsRect().right() : 0;
- if (isVisible)
+ if (isScrollBarVisible)
rightValue -= scrollBarWidth;
if (voptAdj.rect.right() > rightValue)
@@ -1337,40 +1347,40 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
const QRect iconRect = subElementRect(SE_ItemViewItemDecoration, &voptAdj, widget);
QRect textRect = subElementRect(SE_ItemViewItemText, &voptAdj, widget);
+ const QAbstractItemView *itemView = qobject_cast<const QAbstractItemView *>(widget);
// draw themed background for table unless background brush has been defined.
if (vopt->backgroundBrush == Qt::NoBrush) {
- const QStyleOptionViewItemV4 *tableOption = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option);
- const QTableView *table = qobject_cast<const QTableView *>(widget);
- if (table && tableOption) {
- const QModelIndex index = tableOption->index;
+ if (itemView) {
+ const QModelIndex index = vopt->index;
//todo: Draw cell background only once - for the first cell.
QStyleOptionViewItemV4 voptAdj2 = voptAdj;
- const QModelIndex indexFirst = table->model()->index(0,0);
- const QModelIndex indexLast = table->model()->index(
- table->model()->rowCount()-1,table->model()->columnCount()-1);
- if (table->viewport())
- voptAdj2.rect = QRect( table->visualRect(indexFirst).topLeft(),
- table->visualRect(indexLast).bottomRight()).intersect(table->viewport()->rect());
- drawPrimitive(PE_PanelItemViewItem, &voptAdj2, painter, widget);
+ const QModelIndex indexFirst = itemView->model()->index(0,0);
+ const QModelIndex indexLast = itemView->model()->index(
+ itemView->model()->rowCount()-1,itemView->model()->columnCount()-1);
+ if (itemView->viewport())
+ voptAdj2.rect = QRect( itemView->visualRect(indexFirst).topLeft(),
+ itemView->visualRect(indexLast).bottomRight()).intersect(itemView->viewport()->rect());
+ drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget);
}
- } else { QCommonStyle::drawPrimitive(PE_PanelItemViewItem, option, painter, widget);}
+ } else { QCommonStyle::drawPrimitive(PE_PanelItemViewItem, &voptAdj, painter, widget);}
// draw the focus rect
if (isSelected) {
QRect highlightRect = option->rect.adjusted(1,1,-1,-1);
- const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(widget);
- if (view && view->selectionBehavior() != QAbstractItemView::SelectItems) {
+ QAbstractItemView::SelectionBehavior selectionBehavior =
+ itemView ? itemView->selectionBehavior() : QAbstractItemView::SelectItems;
+ if (selectionBehavior != QAbstractItemView::SelectItems) {
// set highlight rect so that it is continuous from cell to cell, yet sligthly
// smaller than cell rect
int xBeginning = 0, yBeginning = 0, xEnd = 0, yEnd = 0;
- if (view->selectionBehavior() == QAbstractItemView::SelectRows) {
+ if (selectionBehavior == QAbstractItemView::SelectRows) {
yBeginning = 1; yEnd = -1;
if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning)
xBeginning = 1;
else if (vopt->viewItemPosition == QStyleOptionViewItemV4::End)
xEnd = -1;
- } else if (view->selectionBehavior() == QAbstractItemView::SelectColumns) {
+ } else if (selectionBehavior == QAbstractItemView::SelectColumns) {
xBeginning = 1; xEnd = -1;
if (vopt->viewItemPosition == QStyleOptionViewItemV4::Beginning)
yBeginning = 1;
@@ -1379,7 +1389,9 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
}
highlightRect = option->rect.adjusted(xBeginning, yBeginning, xEnd, yEnd);
}
- QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, highlightRect, flags);
+ if (vopt->showDecorationSelected &&
+ (vopt->palette.highlight().color() == d->themePalette()->highlight().color()))
+ QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_ListHighlight, painter, highlightRect, flags);
}
// draw the icon
@@ -1388,48 +1400,44 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
voptAdj.icon.paint(painter, iconRect, voptAdj.decorationAlignment, mode, state);
// Draw selection check mark. Show check mark only in multi selection modes.
- if (const QListView *listView = (qobject_cast<const QListView *>(widget))) {
+ if (itemView) {
const bool singleSelection =
- listView &&
- (listView->selectionMode() == QAbstractItemView::SingleSelection ||
- listView->selectionMode() == QAbstractItemView::NoSelection);
+ (itemView->selectionMode() == QAbstractItemView::SingleSelection ||
+ itemView->selectionMode() == QAbstractItemView::NoSelection);
const QRect selectionRect = subElementRect(SE_ItemViewItemCheckIndicator, &voptAdj, widget);
+
+ QStyleOptionViewItemV4 checkMarkOption(voptAdj);
+ // Draw selection mark.
if (voptAdj.state & QStyle::State_Selected && !singleSelection) {
- QStyleOptionViewItemV4 option(voptAdj);
- option.rect = selectionRect;
- // Draw selection mark.
- drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &option, painter, widget);
+ checkMarkOption.rect = selectionRect;
+ drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget);
if ( textRect.right() > selectionRect.left() )
textRect.setRight(selectionRect.left());
} else if (singleSelection &&
- voptAdj.features & QStyleOptionViewItemV2::HasCheckIndicator) {
- // draw the check mark
- if (selectionRect.isValid()) {
- QStyleOptionViewItemV4 option(*vopt);
- option.rect = selectionRect;
- option.state = option.state & ~QStyle::State_HasFocus;
-
- switch (vopt->checkState) {
- case Qt::Unchecked:
- option.state |= QStyle::State_Off;
- break;
- case Qt::PartiallyChecked:
- option.state |= QStyle::State_NoChange;
- break;
- case Qt::Checked:
- option.state |= QStyle::State_On;
- break;
- }
- drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &option, painter, widget);
+ voptAdj.features & QStyleOptionViewItemV2::HasCheckIndicator &&
+ selectionRect.isValid()) {
+ checkMarkOption.rect = selectionRect;
+ checkMarkOption.state = checkMarkOption.state & ~QStyle::State_HasFocus;
+
+ switch (vopt->checkState) {
+ case Qt::Unchecked:
+ checkMarkOption.state |= QStyle::State_Off;
+ break;
+ case Qt::PartiallyChecked:
+ checkMarkOption.state |= QStyle::State_NoChange;
+ break;
+ case Qt::Checked:
+ checkMarkOption.state |= QStyle::State_On;
+ break;
}
+ drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &checkMarkOption, painter, widget);
}
}
// draw the text
if (!voptAdj.text.isEmpty()) {
- const QStyleOptionViewItemV4 *tableOption = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option);
if (isSelected) {
- if (qobject_cast<const QTableView *>(widget) && tableOption)
+ if (qobject_cast<const QTableView *>(widget))
voptAdj.palette.setColor(
QPalette::Text, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 11, 0));
else
@@ -1722,8 +1730,11 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
// direction is set to north (and south when in RightToLeft)
const QS60StylePrivate::SkinElementFlag arrowDirection = (arrowOptions.direction == Qt::LeftToRight) ?
QS60StylePrivate::SF_PointNorth : QS60StylePrivate::SF_PointSouth;
+ painter->save();
+ painter->setPen(option->palette.windowText().color());
QS60StylePrivate::drawSkinPart(QS60StyleEnums::SP_QgnIndiSubMenu, painter, arrowOptions.rect,
(flags | QS60StylePrivate::SF_ColorSkinned | arrowDirection));
+ painter->restore();
}
//draw text
@@ -1751,7 +1762,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
#endif //QT_NO_MENUBAR
case CE_HeaderSection:
- if ( const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
+ if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
painter->save();
QPen linePen = QPen(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnLineColors, 1, header));
const int penWidth = (header->orientation == Qt::Horizontal) ?
@@ -1769,6 +1780,25 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
}
}
painter->restore();
+
+ //Draw corner button as normal pushButton.
+ if (qobject_cast<const QAbstractButton *>(widget)) {
+ //Make cornerButton slightly smaller so that it is not on top of table border graphic.
+ QStyleOptionHeader subopt = *header;
+ const int borderTweak =
+ QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth)>>1;
+ if (subopt.direction == Qt::LeftToRight)
+ subopt.rect.adjust(borderTweak, borderTweak, 0, -borderTweak);
+ else
+ subopt.rect.adjust(0, borderTweak, -borderTweak, -borderTweak);
+ drawPrimitive(PE_PanelButtonBevel, &subopt, painter, widget);
+ } else if ((header->palette.brush(QPalette::Button) != Qt::transparent)) {
+ //Draw non-themed background. Background for theme is drawn in CE_ShapedFrame
+ //to get continuous theme graphic across all the header cells.
+ qDrawShadePanel(painter, header->rect, header->palette,
+ header->state & (State_Sunken | State_On), penWidth,
+ &header->palette.brush(QPalette::Button));
+ }
}
break;
case CE_HeaderEmptyArea: // no need to draw this
@@ -1830,20 +1860,33 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
break;
#endif //QT_NO_TOOLBAR
case CE_ShapedFrame:
- if (qobject_cast<const QTextEdit *>(widget)) {
- QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_Editor, painter, option->rect, flags);
+ if (const QTextEdit *textEdit = qobject_cast<const QTextEdit *>(widget)) {
+ const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option);
+ if (frame->palette.base().color()==Qt::transparent)
+ QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_Editor, painter, option->rect, flags);
+ else
+ QCommonStyle::drawControl(element, option, painter, widget);
} else if (qobject_cast<const QTableView *>(widget)) {
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableItem, painter, option->rect, flags);
} else if (const QHeaderView *header = qobject_cast<const QHeaderView *>(widget)) {
- if (header->orientation() == Qt::Horizontal) {
- QRect headerRect = option->rect;
- const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth);
- headerRect.adjust(0,frameWidth,-2*frameWidth,0);
- QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableHeaderItem, painter, headerRect, flags);
- } else {
+ //QS60style draws header background here instead of in each headersection, to get
+ //continuous graphic from section to section.
+ QS60StylePrivate::SkinElementFlags adjustableFlags = flags;
+ QRect headerRect = option->rect;
+ if (header->orientation() != Qt::Horizontal) {
//todo: update to horizontal table graphic
- QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_TableHeaderItem, painter, option->rect, flags | QS60StylePrivate::SF_PointWest);
+ adjustableFlags = (adjustableFlags | QS60StylePrivate::SF_PointWest);
+ } else {
+ const int frameWidth = QS60StylePrivate::pixelMetric(PM_DefaultFrameWidth);
+ if (option->direction == Qt::LeftToRight)
+ headerRect.adjust(-2*frameWidth, 0, 0, 0);
+ else
+ headerRect.adjust(0, 0, 2*frameWidth, 0);
}
+ if (option->palette.brush(QPalette::Button).color() == Qt::transparent)
+ QS60StylePrivate::drawSkinElement(
+ QS60StylePrivate::SE_TableHeaderItem, painter, headerRect, adjustableFlags);
+
} else if (qobject_cast<const QFrame *>(widget)) {
QCommonStyle::drawControl(element, option, painter, widget);
}
@@ -1889,6 +1932,17 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
painter->restore();
}
break;
+ case CE_Splitter:
+ if (option->state & State_Sunken && option->state & State_Enabled) {
+ painter->save();
+ painter->setOpacity(0.5);
+ painter->setBrush(d->themePalette()->light());
+ painter->setRenderHint(QPainter::Antialiasing);
+ const qreal roundRectRadius = 4 * goldenRatio;
+ painter->drawRoundedRect(option->rect, roundRectRadius, roundRectRadius);
+ painter->restore();
+ }
+ break;
default:
QCommonStyle::drawControl(element, option, painter, widget);
}
@@ -1899,6 +1953,7 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
*/
void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
{
+ Q_D(const QS60Style);
const QS60StylePrivate::SkinElementFlags flags = (option->state & State_Enabled) ? QS60StylePrivate::SF_StateEnabled : QS60StylePrivate::SF_StateDisabled;
switch (element) {
#ifndef QT_NO_LINEEDIT
@@ -1908,19 +1963,27 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
if (widget && qobject_cast<const QComboBox *>(widget->parentWidget()))
break;
#endif
- QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_FrameLineEdit,
- painter, option->rect, flags);
+ QBrush editBrush = option->palette.brush(QPalette::Base);
+ if (editBrush.color() == Qt::transparent)
+ QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_FrameLineEdit,
+ painter, option->rect, flags);
+ else
+ QCommonStyle::drawPrimitive(element, option, painter, widget);
}
break;
#endif // QT_NO_LINEEDIT
case PE_IndicatorCheckBox:
{
- const QRect indicatorRect = option->rect;
// Draw checkbox indicator as color skinned graphics.
const QS60StyleEnums::SkinParts skinPart = (option->state & QStyle::State_On) ?
QS60StyleEnums::SP_QgnIndiCheckboxOn : QS60StyleEnums::SP_QgnIndiCheckboxOff;
- QS60StylePrivate::drawSkinPart(skinPart, painter, indicatorRect,
- (flags | QS60StylePrivate::SF_ColorSkinned));
+ painter->save();
+ QColor themeColor = d->s60Color(QS60StyleEnums::CL_QsnIconColors, 13, option);
+ QColor buttonTextColor = option->palette.buttonText().color();
+ if (themeColor != buttonTextColor)
+ painter->setPen(buttonTextColor);
+ QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags | QS60StylePrivate::SF_ColorSkinned );
+ painter->restore();
}
break;
case PE_IndicatorViewItemCheck:
@@ -1960,21 +2023,33 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
const int newY = (buttonRect.bottomRight().y() - option->rect.bottomRight().y()) >> 1 ;
buttonRect.adjust(0,-newY,0,-newY);
+ painter->save();
+ QColor themeColor = d->s60Color(QS60StyleEnums::CL_QsnIconColors, 13, option);
+ QColor buttonTextColor = option->palette.buttonText().color();
+ if (themeColor != buttonTextColor)
+ painter->setPen(buttonTextColor);
+
// Draw radiobutton indicator as color skinned graphics.
QS60StyleEnums::SkinParts skinPart = (option->state & QStyle::State_On) ?
QS60StyleEnums::SP_QgnIndiRadiobuttOn : QS60StyleEnums::SP_QgnIndiRadiobuttOff;
QS60StylePrivate::drawSkinPart(skinPart, painter, buttonRect,
(flags | QS60StylePrivate::SF_ColorSkinned));
+ painter->restore();
}
break;
case PE_PanelButtonCommand:
case PE_PanelButtonTool:
case PE_PanelButtonBevel:
case PE_FrameButtonBevel: {
- const bool isPressed = option->state & QStyle::State_Sunken;
- const QS60StylePrivate::SkinElements skinElement =
- isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal;
- QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags);
+ QBrush editBrush = option->palette.brush(QPalette::Base);
+ if (editBrush.color() == Qt::transparent) {
+ const bool isPressed = option->state & QStyle::State_Sunken;
+ const QS60StylePrivate::SkinElements skinElement =
+ isPressed ? QS60StylePrivate::SE_ButtonPressed : QS60StylePrivate::SE_ButtonNormal;
+ QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags);
+ } else {
+ QCommonStyle::drawPrimitive(element, option, painter, widget);
+ }
}
break;
#ifndef QT_NO_TOOLBUTTON
@@ -2001,21 +2076,29 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
case PE_IndicatorSpinUp:
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
QStyleOptionSpinBox optionSpinBox = *spinBox;
- const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ?
- QS60StyleEnums::SP_QgnGrafScrollArrowUp :
- QS60StyleEnums::SP_QgnGrafScrollArrowDown;
- const int adjustment = qMin(optionSpinBox.rect.width(), optionSpinBox.rect.height())/6;
- optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment );
- QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect,flags);
+ if (optionSpinBox.palette.base().color()==Qt::transparent) {
+ const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ?
+ QS60StyleEnums::SP_QgnGrafScrollArrowUp :
+ QS60StyleEnums::SP_QgnGrafScrollArrowDown;
+ const int adjustment = qMin(optionSpinBox.rect.width(), optionSpinBox.rect.height())/6;
+ optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment );
+ QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect,flags);
+ } else {
+ QCommonStyle::drawPrimitive(element, &optionSpinBox, painter, widget);
+ }
}
#ifndef QT_NO_COMBOBOX
else if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
- // We want to draw down arrow here for comboboxes as well.
- const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown;
- QStyleOptionFrame comboBox = *cmb;
- const int adjustment = qMin(comboBox.rect.width(), comboBox.rect.height())/6;
- comboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment );
- QS60StylePrivate::drawSkinPart(part, painter, comboBox.rect,flags);
+ if (cmb->palette.base().color()==Qt::transparent) {
+ // We want to draw down arrow here for comboboxes as well.
+ const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown;
+ QStyleOptionFrame comboBox = *cmb;
+ const int adjustment = qMin(comboBox.rect.width(), comboBox.rect.height())/6;
+ comboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment );
+ QS60StylePrivate::drawSkinPart(part, painter, comboBox.rect,flags);
+ } else {
+ QCommonStyle::drawPrimitive(element, cmb, painter, widget);
+ }
}
#endif //QT_NO_COMBOBOX
break;
@@ -2045,8 +2128,12 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
|| qobject_cast<const QMenu *> (widget)
#endif //QT_NO_MENU
) {
- QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_OptionsMenu;
- QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags);
+ if (option->palette.base().color()==Qt::transparent) {
+ QS60StylePrivate::SkinElements skinElement = QS60StylePrivate::SE_OptionsMenu;
+ QS60StylePrivate::drawSkinElement(skinElement, painter, option->rect, flags);
+ } else {
+ QCommonStyle::drawPrimitive(element, option, painter, widget);
+ }
}
break;
case PE_FrameWindow:
@@ -2133,7 +2220,7 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
drawSkinPart = true;
}
- if ( drawSkinPart )
+ if (drawSkinPart)
QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags);
if (option->state & State_Children) {
@@ -2155,7 +2242,6 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
// todo: items are below with #ifdefs "just in case". in final version, remove all non-required cases
case PE_FrameLineEdit:
- case PE_IndicatorButtonDropDown:
case PE_IndicatorDockWidgetResizeHandle:
case PE_PanelTipLabel:
case PE_PanelScrollAreaCorner:
@@ -2190,7 +2276,7 @@ int QS60Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const
if (metricValue == KNotFound)
metricValue = QCommonStyle::pixelMetric(metric, option, widget);
- if (metric == PM_SubMenuOverlap && widget){
+ if (metric == PM_SubMenuOverlap && widget) {
const QMenu *menu = qobject_cast<const QMenu *>(widget);
if (menu && menu->activeAction() && menu->activeAction()->menu()) {
const int menuWidth = menu->activeAction()->menu()->sizeHint().width();
@@ -2217,10 +2303,19 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt,
sz += QSize(2*f->lineWidth, 4*f->lineWidth);
break;
case CT_TabBarTab:
- QSize naviPaneSize = QS60StylePrivate::naviPaneSize();
+ {
+ const QSize naviPaneSize = QS60StylePrivate::naviPaneSize();
+ sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);
+ if (naviPaneSize.height() > sz.height())
+ sz.setHeight(naviPaneSize.height());
+ }
+ break;
+ case CT_ItemViewItem:
sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget);
- if (naviPaneSize.height() > sz.height())
- sz.setHeight(naviPaneSize.height());
+ if (QS60StylePrivate::isTouchSupported())
+ //Make itemview easier to use in touch devices
+ //QCommonStyle does not adjust height with horizontal margin, it only adjusts width
+ sz.setHeight(sz.height() + 2*pixelMetric(QStyle::PM_FocusFrameVMargin));
break;
default:
sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget);
@@ -2475,6 +2570,29 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
}
}
break;
+ case CC_ToolButton:
+ if (const QStyleOptionToolButton *toolButton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
+ const int indicatorRect = pixelMetric(PM_MenuButtonIndicator, toolButton, widget) +
+ 2*pixelMetric(PM_ButtonMargin, toolButton, widget);
+ ret = toolButton->rect;
+ const bool popup = (toolButton->features &
+ (QStyleOptionToolButton::MenuButtonPopup | QStyleOptionToolButton::PopupDelay))
+ == QStyleOptionToolButton::MenuButtonPopup;
+ switch (scontrol) {
+ case SC_ToolButton:
+ if (popup)
+ ret.adjust(0, 0, -indicatorRect, 0);
+ break;
+ case SC_ToolButtonMenu:
+ if (popup)
+ ret.adjust(ret.width() - indicatorRect, ret.height() - indicatorRect, 0, 0);
+ break;
+ default:
+ break;
+ }
+ ret = visualRect(toolButton->direction, toolButton->rect, ret);
+ }
+ break;
default:
ret = QCommonStyle::subControlRect(control, option, scontrol, widget);
}
@@ -2878,7 +2996,7 @@ QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon,
return QCommonStyle::standardIconImplementation(standardIcon, option, widget);
}
const QS60StylePrivate::SkinElementFlags flags = adjustedFlags;
- const QPixmap cachedPixMap(QS60StylePrivate::cachedPart(part, iconSize.size(), flags));
+ const QPixmap cachedPixMap(QS60StylePrivate::cachedPart(part, iconSize.size(), 0, flags));
return cachedPixMap.isNull() ?
QCommonStyle::standardIconImplementation(standardIcon, option, widget) : QIcon(cachedPixMap);
}
diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h
index 8e53eee..54af757 100644
--- a/src/gui/styles/qs60style_p.h
+++ b/src/gui/styles/qs60style_p.h
@@ -372,7 +372,7 @@ public:
SF_StateEnabled = 0x0010, // Enabled = the default
SF_StateDisabled = 0x0020,
- SF_ColorSkinned = 0x0040,
+ SF_ColorSkinned = 0x0040, // pixmap is colored with foreground pen color
};
enum CacheClearReason {
@@ -472,7 +472,7 @@ private:
const QRect &rect, SkinElementFlags flags = KDefaultSkinElementFlags);
static QPixmap cachedPart(QS60StyleEnums::SkinParts part, const QSize &size,
- SkinElementFlags flags = KDefaultSkinElementFlags);
+ QPainter *painter, SkinElementFlags flags = KDefaultSkinElementFlags);
static QPixmap cachedFrame(SkinFrameElements frame, const QSize &size,
SkinElementFlags flags = KDefaultSkinElementFlags);
@@ -489,7 +489,7 @@ private:
static QSize partSize(QS60StyleEnums::SkinParts part,
SkinElementFlags flags = KDefaultSkinElementFlags);
static QPixmap part(QS60StyleEnums::SkinParts part, const QSize &size,
- SkinElementFlags flags = KDefaultSkinElementFlags);
+ QPainter *painter, SkinElementFlags flags = KDefaultSkinElementFlags);
static QFont s60Font_specific(QS60StyleEnums::FontCategories fontCategory, int pointSize);
diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp
index 9765066..0cd87bd 100644
--- a/src/gui/styles/qs60style_s60.cpp
+++ b/src/gui/styles/qs60style_s60.cpp
@@ -99,7 +99,7 @@ public:
const QSize &size, QS60StylePrivate::SkinElementFlags flags);
static QPixmap skinnedGraphics(QS60StylePrivate::SkinFrameElements frameElement, const QSize &size, QS60StylePrivate::SkinElementFlags flags);
static QPixmap colorSkinnedGraphics(const QS60StyleEnums::SkinParts &stylepart,
- const QSize &size, QS60StylePrivate::SkinElementFlags flags);
+ const QSize &size, QPainter *painter, QS60StylePrivate::SkinElementFlags flags);
static QColor colorValue(const TAknsItemID &colorGroup, int colorIndex);
static QPixmap fromFbsBitmap(CFbsBitmap *icon, CFbsBitmap *mask, QS60StylePrivate::SkinElementFlags flags, QImage::Format format);
static bool disabledPartGraphic(QS60StyleEnums::SkinParts &part);
@@ -112,14 +112,12 @@ private:
const QSize &size, QS60StylePrivate::SkinElementFlags flags);
static QPixmap createSkinnedGraphicsLX(QS60StylePrivate::SkinFrameElements frameElement, const QSize &size, QS60StylePrivate::SkinElementFlags flags);
static QPixmap colorSkinnedGraphicsLX(const QS60StyleEnums::SkinParts &stylepart,
- const QSize &size, QS60StylePrivate::SkinElementFlags flags);
+ const QSize &size, QPainter *painter, QS60StylePrivate::SkinElementFlags flags);
static void frameIdAndCenterId(QS60StylePrivate::SkinFrameElements frameElement, TAknsItemID &frameId, TAknsItemID &centerId);
static TRect innerRectFromElement(QS60StylePrivate::SkinFrameElements frameElement, const TRect &outerRect);
static void checkAndUnCompressBitmapL(CFbsBitmap*& aOriginalBitmap);
static void checkAndUnCompressBitmap(CFbsBitmap*& aOriginalBitmap);
static void unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap* aTrgBitmap, CFbsBitmap* aSrcBitmap);
- static void colorGroupAndIndex(QS60StyleEnums::SkinParts skinID,
- TAknsItemID &colorGroup, int &colorIndex);
static void fallbackInfo(const QS60StyleEnums::SkinParts &stylepart, TDes& fallbackFileName, TInt& fallbackIndex);
static bool checkSupport(const int supportedRelease);
static TAknsItemID checkAndUpdateReleaseSpecificGraphics(int part);
@@ -361,11 +359,11 @@ QPixmap QS60StyleModeSpecifics::skinnedGraphics(
}
QPixmap QS60StyleModeSpecifics::colorSkinnedGraphics(
- const QS60StyleEnums::SkinParts &stylepart,
- const QSize &size, QS60StylePrivate::SkinElementFlags flags)
+ const QS60StyleEnums::SkinParts &stylepart, const QSize &size, QPainter *painter,
+ QS60StylePrivate::SkinElementFlags flags)
{
QPixmap colorGraphics;
- TRAPD(error, QT_TRYCATCH_LEAVING(colorGraphics = colorSkinnedGraphicsLX(stylepart, size, flags)));
+ TRAPD(error, QT_TRYCATCH_LEAVING(colorGraphics = colorSkinnedGraphicsLX(stylepart, size, painter, flags)));
return error ? QPixmap() : colorGraphics;
}
@@ -525,7 +523,7 @@ void QS60StyleModeSpecifics::fallbackInfo(const QS60StyleEnums::SkinParts &style
QPixmap QS60StyleModeSpecifics::colorSkinnedGraphicsLX(
const QS60StyleEnums::SkinParts &stylepart,
- const QSize &size, QS60StylePrivate::SkinElementFlags flags)
+ const QSize &size, QPainter *painter, QS60StylePrivate::SkinElementFlags flags)
{
// this function can throw both exceptions and leaves. There are no cleanup dependencies between Qt and Symbian parts.
const int stylepartIndex = (int)stylepart;
@@ -537,8 +535,13 @@ QPixmap QS60StyleModeSpecifics::colorSkinnedGraphicsLX(
fallbackInfo(stylepart, fileNamePtr, fallbackGraphicID);
TAknsItemID colorGroup = KAknsIIDQsnIconColors;
- int colorIndex = 0;
- colorGroupAndIndex(stylepart, colorGroup, colorIndex);
+ TRgb defaultColor = KRgbBlack;
+ int colorIndex = -1; //set a bogus value to color index to ensure that painter color is used
+ //to color the icon
+ if (painter) {
+ QRgb widgetColor = painter->pen().color().rgb();
+ defaultColor = TRgb(qRed(widgetColor), qGreen(widgetColor), qBlue(widgetColor));
+ }
const bool rotatedBy90or270 =
(flags & (QS60StylePrivate::SF_PointEast | QS60StylePrivate::SF_PointWest));
@@ -550,7 +553,7 @@ QPixmap QS60StyleModeSpecifics::colorSkinnedGraphicsLX(
fallbackGraphicID == KErrNotFound?KErrNotFound:fallbackGraphicID+1; //masks are auto-generated as next in mif files
MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
AknsUtils::CreateColorIconLC(
- skinInstance, skinId, colorGroup, colorIndex, icon, iconMask, fileNamePtr, fallbackGraphicID , fallbackGraphicsMaskID, KRgbBlack);
+ skinInstance, skinId, colorGroup, colorIndex, icon, iconMask, fileNamePtr, fallbackGraphicID , fallbackGraphicsMaskID, defaultColor);
User::LeaveIfError(AknIconUtils::SetSize(icon, targetSize, EAspectRatioNotPreserved));
User::LeaveIfError(AknIconUtils::SetSize(iconMask, targetSize, EAspectRatioNotPreserved));
QPixmap result = fromFbsBitmap(icon, iconMask, flags, qt_TDisplayMode2Format(icon->DisplayMode()));
@@ -652,8 +655,8 @@ QPoint qt_s60_fill_background_offset(const QWidget *targetWidget)
}
QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsLX(
- QS60StyleEnums::SkinParts part,
- const QSize &size, QS60StylePrivate::SkinElementFlags flags)
+ QS60StyleEnums::SkinParts part, const QSize &size,
+ QS60StylePrivate::SkinElementFlags flags)
{
// this function can throw both exceptions and leaves. There are no cleanup dependencies between Qt and Symbian parts.
if (!size.isValid())
@@ -700,13 +703,13 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsLX(
CleanupStack::PushL(background);
User::LeaveIfError(background->Create(targetSize, EColor16MA));
- CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL(background);
+ CFbsBitmapDevice *dev = CFbsBitmapDevice::NewL(background);
CleanupStack::PushL(dev);
- CFbsBitGc* gc = NULL;
+ CFbsBitGc *gc = NULL;
User::LeaveIfError(dev->CreateContext(gc));
CleanupStack::PushL(gc);
- CAknsBasicBackgroundControlContext* bgContext = CAknsBasicBackgroundControlContext::NewL(
+ CAknsBasicBackgroundControlContext *bgContext = CAknsBasicBackgroundControlContext::NewL(
skinId,
targetSize,
EFalse);
@@ -1145,12 +1148,12 @@ QPixmap QS60StyleModeSpecifics::generateMissingThemeGraphic(QS60StyleEnums::Skin
}
QPixmap QS60StylePrivate::part(QS60StyleEnums::SkinParts part,
- const QSize &size, SkinElementFlags flags)
+ const QSize &size, QPainter *painter, SkinElementFlags flags)
{
QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock);
QPixmap result = (flags & SF_ColorSkinned)?
- QS60StyleModeSpecifics::colorSkinnedGraphics(part, size, flags)
+ QS60StyleModeSpecifics::colorSkinnedGraphics(part, size, painter, flags)
: QS60StyleModeSpecifics::skinnedGraphics(part, size, flags);
lock.relock();
@@ -1189,7 +1192,7 @@ QPixmap QS60StylePrivate::backgroundTexture()
{
if (!m_background) {
QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen,
- QSize(S60->screenWidthInPixels, S60->screenHeightInPixels), SkinElementFlags());
+ QSize(S60->screenWidthInPixels, S60->screenHeightInPixels), 0, SkinElementFlags());
m_background = new QPixmap(background);
}
return *m_background;
@@ -1343,26 +1346,6 @@ QSize QS60StylePrivate::screenSize()
return QSize(screenSize.iWidth, screenSize.iHeight);
}
-void QS60StyleModeSpecifics::colorGroupAndIndex(
- QS60StyleEnums::SkinParts skinID, TAknsItemID &colorGroup, int &colorIndex)
-{
- switch(skinID) {
- case QS60StyleEnums::SP_QgnIndiSubMenu:
- colorGroup = KAknsIIDQsnIconColors;
- colorIndex = EAknsCIQsnIconColorsCG1;
- break;
- case QS60StyleEnums::SP_QgnIndiRadiobuttOff:
- case QS60StyleEnums::SP_QgnIndiRadiobuttOn:
- case QS60StyleEnums::SP_QgnIndiCheckboxOff:
- case QS60StyleEnums::SP_QgnIndiCheckboxOn:
- colorGroup = KAknsIIDQsnIconColors;
- colorIndex = EAknsCIQsnIconColorsCG14;
- break;
- default:
- break;
- }
-}
-
QS60Style::QS60Style()
: QCommonStyle(*new QS60StylePrivate)
{
@@ -1399,13 +1382,13 @@ QSize QS60StylePrivate::naviPaneSize()
QSize QS60StyleModeSpecifics::naviPaneSize()
{
CAknNavigationControlContainer* naviContainer;
- if (S60->statusPane())
- naviContainer = static_cast<CAknNavigationControlContainer*>
- (S60->statusPane()->ControlL(TUid::Uid(EEikStatusPaneUidNavi)));
- if (naviContainer)
- return QSize(naviContainer->Size().iWidth, naviContainer->Size().iHeight);
- else
- return QSize(0,0);
+ if (S60->statusPane()) {
+ TRAPD(err, naviContainer = static_cast<CAknNavigationControlContainer*>
+ (S60->statusPane()->ControlL(TUid::Uid(EEikStatusPaneUidNavi))));
+ if (err==KErrNone)
+ return QSize(naviContainer->Size().iWidth, naviContainer->Size().iHeight);
+ }
+ return QSize(0,0);
}
#endif // Q_WS_S60
diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/gui/styles/qs60style_simulated.cpp
index 8a2616d..706b4e9 100644
--- a/src/gui/styles/qs60style_simulated.cpp
+++ b/src/gui/styles/qs60style_simulated.cpp
@@ -189,8 +189,10 @@ QColor QS60StylePrivate::s60Color(QS60StyleEnums::ColorLists list,
}
QPixmap QS60StylePrivate::part(QS60StyleEnums::SkinParts part, const QSize &size,
- QS60StylePrivate::SkinElementFlags flags)
+ QPainter *painter, QS60StylePrivate::SkinElementFlags flags)
{
+ Q_UNUSED(painter);
+
const QString partKey = QS60Style::partKeys().at(part);
const QPicture partPicture = QS60StyleModeSpecifics::m_partPictures.value(partKey);
QSize partSize(partPicture.boundingRect().size());
@@ -320,7 +322,7 @@ QPixmap QS60StylePrivate::backgroundTexture()
{
if (!m_background) {
const QSize size = QApplication::desktop()->screen()->size();
- QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen, size);
+ QPixmap background = part(QS60StyleEnums::SP_QsnBgScreen, size, 0);
m_background = new QPixmap(background);
}
return *m_background;
diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp
index 0f72440..5cf738e 100644
--- a/src/gui/styles/qwindowsstyle.cpp
+++ b/src/gui/styles/qwindowsstyle.cpp
@@ -454,9 +454,6 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW
ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget);
break;
- case PM_ToolBarIconSize:
- ret = int(QStyleHelper::dpiScaled(24.));
- break;
case PM_DockWidgetTitleMargin:
ret = int(QStyleHelper::dpiScaled(2.));
break;
diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp
index 974bce1..9f5440c 100644
--- a/src/gui/styles/qwindowsvistastyle.cpp
+++ b/src/gui/styles/qwindowsvistastyle.cpp
@@ -159,7 +159,7 @@ QWindowsVistaStyle::QWindowsVistaStyle()
}
//convert Qt state flags to uxtheme button states
-int buttonStateId(int flags, int partId)
+static int buttonStateId(int flags, int partId)
{
int stateId = 0;
if (partId == BP_RADIOBUTTON || partId == BP_CHECKBOX) {
@@ -190,7 +190,7 @@ int buttonStateId(int flags, int partId)
return stateId;
}
-void Animation::paint(QPainter *painter, const QStyleOption *option)
+void QWindowsVistaAnimation::paint(QPainter *painter, const QStyleOption *option)
{
Q_UNUSED(option);
Q_UNUSED(painter);
@@ -205,7 +205,7 @@ void Animation::paint(QPainter *painter, const QStyleOption *option)
+ ((1-alpha)*_secondaryImage)
*/
-void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) {
+void QWindowsVistaAnimation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) {
if (_secondaryImage.isNull() || _primaryImage.isNull())
return;
@@ -251,7 +251,7 @@ void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) {
initial and final state of the transition, depending on the time
difference between _startTime and current time.
*/
-void Transition::paint(QPainter *painter, const QStyleOption *option)
+void QWindowsVistaTransition::paint(QPainter *painter, const QStyleOption *option)
{
float alpha = 1.0;
if (_duration > 0) {
@@ -278,7 +278,7 @@ void Transition::paint(QPainter *painter, const QStyleOption *option)
secondary pulse images depending on the time difference between
_startTime and current time.
*/
-void Pulse::paint(QPainter *painter, const QStyleOption *option)
+void QWindowsVistaPulse::paint(QPainter *painter, const QStyleOption *option)
{
float alpha = 1.0;
if (_duration > 0) {
@@ -393,8 +393,8 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
startImage.fill(0);
QPainter startPainter(&startImage);
- Animation *anim = d->widgetAnimation(widget);
- Transition *t = new Transition;
+ QWindowsVistaAnimation *anim = d->widgetAnimation(widget);
+ QWindowsVistaTransition *t = new QWindowsVistaTransition;
t->setWidget(w);
// If we have a running animation on the widget already, we will use that to paint the initial
@@ -531,7 +531,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
case PE_IndicatorCheckBox:
case PE_IndicatorRadioButton:
{
- if (Animation *a = d->widgetAnimation(widget)) {
+ if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) {
a->paint(painter, option);
} else {
QWindowsXPStyle::drawPrimitive(element, option, painter, widget);
@@ -644,7 +644,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
break;
case PE_FrameLineEdit:
- if (Animation *anim = d->widgetAnimation(widget)) {
+ if (QWindowsVistaAnimation *anim = d->widgetAnimation(widget)) {
anim->paint(painter, option);
} else {
QPainter *p = painter;
@@ -929,13 +929,13 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
if (doTransition) {
QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
- Animation *anim = d->widgetAnimation(widget);
+ QWindowsVistaAnimation *anim = d->widgetAnimation(widget);
QStyleOptionButton opt = *button;
opt.state = (QStyle::State)oldState;
startImage.fill(0);
- Transition *t = new Transition;
+ QWindowsVistaTransition *t = new QWindowsVistaTransition;
t->setWidget(w);
QPainter startPainter(&startImage);
@@ -972,7 +972,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option))
{
- if (Animation *anim = d->widgetAnimation(widget)) {
+ if (QWindowsVistaAnimation *anim = d->widgetAnimation(widget)) {
anim->paint(painter, option);
} else {
name = QLatin1String("BUTTON");
@@ -999,14 +999,14 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
!(state & (State_Sunken | State_On)) && !(state & State_MouseOver) &&
(state & State_Enabled) && (state & State_Active))
{
- Animation *anim = d->widgetAnimation(widget);
+ QWindowsVistaAnimation *anim = d->widgetAnimation(widget);
if (!anim && widget) {
QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
startImage.fill(0);
QImage alternateImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
alternateImage.fill(0);
- Pulse *pulse = new Pulse;
+ QWindowsVistaPulse *pulse = new QWindowsVistaPulse;
pulse->setWidget(const_cast<QWidget*>(widget));
QPainter startPainter(&startImage);
@@ -1079,7 +1079,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
if (const QProgressBar *progressbar = qobject_cast<const QProgressBar *>(widget)) {
if (((progressbar->value() > 0 && d->transitionsEnabled()) || isIndeterminate)) {
if (!d->widgetAnimation(progressbar) && progressbar->value() < progressbar->maximum()) {
- Animation *a = new Animation;
+ QWindowsVistaAnimation *a = new QWindowsVistaAnimation;
a->setWidget(const_cast<QWidget*>(widget));
a->setStartTime(QTime::currentTime());
d->startAnimation(a);
@@ -1095,7 +1095,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
QTime current = QTime::currentTime();
if (isIndeterminate) {
- if (Animation *a = d->widgetAnimation(widget)) {
+ if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) {
int glowSize = 120;
int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width());
int animOffset = a->startTime().msecsTo(current) / 4;
@@ -1165,7 +1165,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
}
d->drawBackground(theme);
- if (Animation *a = d->widgetAnimation(widget)) {
+ if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) {
int glowSize = 140;
int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width());
int animOffset = a->startTime().msecsTo(current) / 4;
@@ -1603,8 +1603,8 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle
if (doTransition) {
QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
- Animation *anim = d->widgetAnimation(widget);
- Transition *t = new Transition;
+ QWindowsVistaAnimation *anim = d->widgetAnimation(widget);
+ QWindowsVistaTransition *t = new QWindowsVistaTransition;
t->setWidget(w);
if (!anim) {
if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox*>(option)) {
@@ -1651,7 +1651,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle
t->setDuration(500);
}
- if (Animation *anim = d->widgetAnimation(widget)) {
+ if (QWindowsVistaAnimation *anim = d->widgetAnimation(widget)) {
anim->paint(painter, option);
return;
}
@@ -2534,7 +2534,7 @@ void QWindowsVistaStylePrivate::timerEvent()
!animations[i]->running() ||
!QWindowsVistaStylePrivate::useVista())
{
- Animation *a = animations.takeAt(i);
+ QWindowsVistaAnimation *a = animations.takeAt(i);
delete a;
}
}
@@ -2547,14 +2547,14 @@ void QWindowsVistaStylePrivate::stopAnimation(const QWidget *w)
{
for (int i = animations.size() - 1 ; i >= 0 ; --i) {
if (animations[i]->widget() == w) {
- Animation *a = animations.takeAt(i);
+ QWindowsVistaAnimation *a = animations.takeAt(i);
delete a;
break;
}
}
}
-void QWindowsVistaStylePrivate::startAnimation(Animation *t)
+void QWindowsVistaStylePrivate::startAnimation(QWindowsVistaAnimation *t)
{
Q_Q(QWindowsVistaStyle);
stopAnimation(t->widget());
@@ -2576,11 +2576,11 @@ bool QWindowsVistaStylePrivate::transitionsEnabled() const
}
-Animation * QWindowsVistaStylePrivate::widgetAnimation(const QWidget *widget) const
+QWindowsVistaAnimation * QWindowsVistaStylePrivate::widgetAnimation(const QWidget *widget) const
{
if (!widget)
return 0;
- foreach (Animation *a, animations) {
+ foreach (QWindowsVistaAnimation *a, animations) {
if (a->widget() == widget)
return a;
}
diff --git a/src/gui/styles/qwindowsvistastyle_p.h b/src/gui/styles/qwindowsvistastyle_p.h
index e9bbb77..04823c1 100644
--- a/src/gui/styles/qwindowsvistastyle_p.h
+++ b/src/gui/styles/qwindowsvistastyle_p.h
@@ -136,11 +136,11 @@ QT_BEGIN_NAMESPACE
#define TDLG_SECONDARYPANEL 8
#endif
-class Animation
+class QWindowsVistaAnimation
{
public :
- Animation() : _running(true) { }
- virtual ~Animation() { }
+ QWindowsVistaAnimation() : _running(true) { }
+ virtual ~QWindowsVistaAnimation() { }
QWidget * widget() const { return _widget; }
bool running() const { return _running; }
const QTime &startTime() const { return _startTime; }
@@ -161,11 +161,11 @@ protected:
// Handles state transition animations
-class Transition : public Animation
+class QWindowsVistaTransition : public QWindowsVistaAnimation
{
public :
- Transition() : Animation() {}
- virtual ~Transition() { }
+ QWindowsVistaTransition() : QWindowsVistaAnimation() {}
+ virtual ~QWindowsVistaTransition() { }
void setDuration(int duration) { _duration = duration; }
void setStartImage(const QImage &image) { _primaryImage = image; }
void setEndImage(const QImage &image) { _secondaryImage = image; }
@@ -176,11 +176,11 @@ public :
// Handles pulse animations (default buttons)
-class Pulse: public Animation
+class QWindowsVistaPulse: public QWindowsVistaAnimation
{
public :
- Pulse() : Animation() {}
- virtual ~Pulse() { }
+ QWindowsVistaPulse() : QWindowsVistaAnimation() {}
+ virtual ~QWindowsVistaPulse() { }
void setDuration(int duration) { _duration = duration; }
void setPrimaryImage(const QImage &image) { _primaryImage = image; }
void setAlternateImage(const QImage &image) { _secondaryImage = image; }
@@ -199,15 +199,15 @@ public:
~QWindowsVistaStylePrivate();
static bool resolveSymbols();
static inline bool useVista();
- void startAnimation(Animation *);
+ void startAnimation(QWindowsVistaAnimation *);
void stopAnimation(const QWidget *);
- Animation* widgetAnimation(const QWidget *) const;
+ QWindowsVistaAnimation* widgetAnimation(const QWidget *) const;
void timerEvent();
bool transitionsEnabled() const;
QWidget *treeViewHelper();
private:
- QList <Animation*> animations;
+ QList <QWindowsVistaAnimation*> animations;
QBasicTimer animationTimer;
QWidget *m_treeViewHelper;
};
diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp
index 9fd9ce9..fe7f5d7 100644
--- a/src/gui/styles/qwindowsxpstyle.cpp
+++ b/src/gui/styles/qwindowsxpstyle.cpp
@@ -2926,10 +2926,10 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
}
// Draw arrow
p->save();
- p->setPen(option->palette.dark());
+ p->setPen(option->palette.dark().color());
p->drawLine(menuarea.left(), menuarea.top() + 3,
menuarea.left(), menuarea.bottom() - 3);
- p->setPen(option->palette.light());
+ p->setPen(option->palette.light().color());
p->drawLine(menuarea.left() - 1, menuarea.top() + 3,
menuarea.left() - 1, menuarea.bottom() - 3);
diff --git a/src/gui/styles/styles.pri b/src/gui/styles/styles.pri
index 767ade0..88a2cce 100644
--- a/src/gui/styles/styles.pri
+++ b/src/gui/styles/styles.pri
@@ -109,10 +109,10 @@ contains( styles, plastique ) {
contains( styles, gtk ) {
HEADERS += styles/qgtkstyle.h
HEADERS += styles/qgtkpainter_p.h
- HEADERS += styles/gtksymbols_p.h
+ HEADERS += styles/qgtkstyle_p.h
SOURCES += styles/qgtkstyle.cpp
SOURCES += styles/qgtkpainter.cpp
- SOURCES += styles/gtksymbols.cpp
+ SOURCES += styles/qgtkstyle_p.cpp
!contains( styles, cleanlooks ) {
styles += cleanlooks
DEFINES+= QT_STYLE_CLEANLOOKS