diff options
author | Robert Griebl <rgriebl@trolltech.com> | 2009-10-27 13:50:57 (GMT) |
---|---|---|
committer | Robert Griebl <rgriebl@trolltech.com> | 2009-10-27 16:06:40 (GMT) |
commit | ea139224d49a543cbd09fff450df101720095307 (patch) | |
tree | e7ec688099c11c64c79ab0d9192f94b5969e0223 /src/gui | |
parent | 83e25326c7fb6aa2e239b220e608446f52aeff34 (diff) | |
download | Qt-ea139224d49a543cbd09fff450df101720095307.zip Qt-ea139224d49a543cbd09fff450df101720095307.tar.gz Qt-ea139224d49a543cbd09fff450df101720095307.tar.bz2 |
Fix for Gtk+ toolbuttons and sliders.
Maemo5 looks very weird without these patches.
Reviewed-By: jbache
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/styles/gtksymbols.cpp | 3 | ||||
-rw-r--r-- | src/gui/styles/gtksymbols_p.h | 2 | ||||
-rw-r--r-- | src/gui/styles/qgtkstyle.cpp | 36 |
3 files changed, 34 insertions, 7 deletions
diff --git a/src/gui/styles/gtksymbols.cpp b/src/gui/styles/gtksymbols.cpp index 6ec5796..32fde62 100644 --- a/src/gui/styles/gtksymbols.cpp +++ b/src/gui/styles/gtksymbols.cpp @@ -98,6 +98,7 @@ 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; @@ -266,6 +267,7 @@ static void resolveGtk() 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"); @@ -717,6 +719,7 @@ void QGtk::initGtkWidgets() 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()); diff --git a/src/gui/styles/gtksymbols_p.h b/src/gui/styles/gtksymbols_p.h index 313d948..2cf21ce 100644 --- a/src/gui/styles/gtksymbols_p.h +++ b/src/gui/styles/gtksymbols_p.h @@ -96,6 +96,7 @@ typedef GtkWidget* (*Ptr_gtk_combo_box_entry_new)(void); typedef GtkWidget* (*Ptr_gtk_toolbar_new)(void); typedef GtkWidget* (*Ptr_gtk_spin_button_new)(GtkAdjustment*, double, int); typedef GtkWidget* (*Ptr_gtk_button_new)(void); +typedef GtkWidget* (*Ptr_gtk_tool_button_new)(GtkWidget *, const gchar *); typedef GtkWidget* (*Ptr_gtk_hbutton_box_new)(void); typedef GtkWidget* (*Ptr_gtk_check_button_new)(void); typedef GtkWidget* (*Ptr_gtk_radio_button_new)(GSList *); @@ -261,6 +262,7 @@ public: static Ptr_gtk_menu_new gtk_menu_new; static Ptr_gtk_expander_new gtk_expander_new; static Ptr_gtk_button_new gtk_button_new; + static Ptr_gtk_tool_button_new gtk_tool_button_new; static Ptr_gtk_hbutton_box_new gtk_hbutton_box_new; static Ptr_gtk_check_button_new gtk_check_button_new; static Ptr_gtk_radio_button_new gtk_radio_button_new; diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index 414580e..d315c98 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -1035,15 +1035,24 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, } break; - case PE_PanelButtonCommand: { + case PE_PanelButtonCommand: + case PE_PanelButtonTool: { bool isDefault = false; + bool isTool = (element == PE_PanelButtonTool); if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton*>(option)) isDefault = btn->features & QStyleOptionButton::DefaultButton; + // don't draw a frame for tool buttons that have the autoRaise flag and are not enabled or on + if (isTool && !(option->state & State_Enabled || option->state & State_On) && (option->state & State_AutoRaise)) + break; + // don't draw a frame for dock widget buttons, unless we are hovering + if (widget && widget->inherits("QDockWidgetTitleButton") && !(option->state & State_MouseOver)) + break; + GtkStateType state = gtkPainter.gtkState(option); if (option->state & State_On || option->state & State_Sunken) state = GTK_STATE_ACTIVE; - GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton")); + GtkWidget *gtkButton = QGtk::gtkWidget(isTool ? QLS("GtkToolButton.GtkButton") : QLS("GtkButton")); gint focusWidth, focusPad; gboolean interiorFocus = false; QGtk::gtk_widget_style_get (gtkButton, @@ -1555,7 +1564,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom QStyleOptionToolButton label = *toolbutton; label.state = bflags; - GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton")); + GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkToolButton.GtkButton")); QPalette pal = toolbutton->palette; if (option->state & State_Enabled && option->state & State_MouseOver && !(widget && widget->testAttribute(Qt::WA_SetPalette))) { @@ -1931,13 +1940,26 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom if (!QGtk::gtk_check_version(2, 10, 0)) QGtk::gtk_widget_style_get((GtkWidget*)(scaleWidget), "trough-side-details", &trough_side_details, NULL); - if (trough_side_details && horizontal) { //### Vertical sliders look broken with this for some reason + if (!trough_side_details) { + gtkPainter.paintBox( scaleWidget, "trough", grooveRect, state, + GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition)); + } else { + QRect upperGroove = grooveRect; QRect lowerGroove = grooveRect; - lowerGroove.setRight(handle.center().x()); + + if (horizontal) { + upperGroove.setLeft(handle.center().x()); + lowerGroove.setRight(handle.center().x()); + } else { + upperGroove.setBottom(handle.center().y()); + lowerGroove.setTop(handle.center().y()); + } + + gtkPainter.paintBox( scaleWidget, "trough-upper", upperGroove, state, + GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition)); gtkPainter.paintBox( scaleWidget, "trough-lower", lowerGroove, state, GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition)); } - } if (option->subControls & SC_SliderTickmarks) { @@ -3116,7 +3138,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, case CT_ToolButton: if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { - GtkWidget *gtkButton = QGtk::gtkWidget(QLS("GtkButton")); + GtkWidget *gtkButton = QGtk::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); |