diff options
author | Jens Bache-Wiig <jbache@trolltech.com> | 2009-07-16 19:00:45 (GMT) |
---|---|---|
committer | Jens Bache-Wiig <jbache@trolltech.com> | 2009-07-16 19:12:29 (GMT) |
commit | e1c019fd7ecaa59eee39f23434dd63d5656f4ee0 (patch) | |
tree | 52e299e2d6ecc0d32247f2ee2dafbba99350c3a3 /src/gui/styles/gtksymbols.cpp | |
parent | ca2122e9eb2b0d68d4203b05128f6fc5a838f3d6 (diff) | |
download | Qt-e1c019fd7ecaa59eee39f23434dd63d5656f4ee0.zip Qt-e1c019fd7ecaa59eee39f23434dd63d5656f4ee0.tar.gz Qt-e1c019fd7ecaa59eee39f23434dd63d5656f4ee0.tar.bz2 |
Allow picking up tool button style from the system
KDE and GNOME has the concept of a default tool button style that
can be set system-wide. Qt currently allways default to IconOnly.
I have added an optional Qt::ToolButtonSystemDefault value so you
can opt-in to respect the system setting. We did not change the
default because a lot of apps will look odd when for instance
text is beside icons and the descriptive text is too long.
Task-number: 237864
Reviewed-by: ogoffart
Diffstat (limited to 'src/gui/styles/gtksymbols.cpp')
-rw-r--r-- | src/gui/styles/gtksymbols.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp index f553d27..2b32450 100644 --- a/src/gui/styles/gtksymbols.cpp +++ b/src/gui/styles/gtksymbols.cpp @@ -68,6 +68,7 @@ #include <QtGui/QStatusBar> #include <QtGui/QMenuBar> #include <QtGui/QToolBar> +#include <QtGui/QToolButton> #include <QtGui/QX11Info> #include <X11/Xlib.h> @@ -633,6 +634,20 @@ GtkStyle* QGtk::gtkStyle(const QString &path) return 0; } +static void update_toolbar_style(GtkWidget *gtkToolBar, GParamSpec *pspec, gpointer user_data) +{ + 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 @@ -679,6 +694,7 @@ void QGtk::initGtkWidgets() 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(); |