diff -r b72c6db6890b -r 5dc02b23752f src/gui/styles/qgtkstyle.cpp --- a/src/gui/styles/qgtkstyle.cpp Wed Jun 23 19:07:03 2010 +0300 +++ b/src/gui/styles/qgtkstyle.cpp Tue Jul 06 15:10:48 2010 +0300 @@ -222,7 +222,7 @@ QPalette palette = QCleanlooksStyle::standardPalette(); if (d->isThemeAvailable()) { GtkStyle *style = d->gtkStyle(); - GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); + GtkWidget *gtkButton = d->gtkWidget("GtkButton"); GtkWidget *gtkEntry = d->getTextColorWidget(); GdkColor gdkBg, gdkBase, gdkText, gdkForeground, gdkSbg, gdkSfg; @@ -253,7 +253,7 @@ palette.setColor(QPalette::Base, base); QColor alternateRowColor = palette.base().color().lighter(93); // ref gtkstyle.c draw_flat_box - GtkWidget *gtkTreeView = d->gtkWidget(QLS("GtkTreeView")); + GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView"); GdkColor *gtkAltBase = NULL; d->gtk_widget_style_get(gtkTreeView, "odd-row-color", >kAltBase, NULL); if (gtkAltBase) { @@ -421,14 +421,14 @@ return 0; case PM_ButtonShiftHorizontal: { - GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); + GtkWidget *gtkButton = d->gtkWidget("GtkButton"); guint horizontal_shift; d->gtk_widget_style_get(gtkButton, "child-displacement-x", &horizontal_shift, NULL); return horizontal_shift; } case PM_ButtonShiftVertical: { - GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); + GtkWidget *gtkButton = d->gtkWidget("GtkButton"); guint vertical_shift; d->gtk_widget_style_get(gtkButton, "child-displacement-y", &vertical_shift, NULL); return vertical_shift; @@ -438,7 +438,7 @@ return 0; case PM_MenuPanelWidth: { - GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu")); + GtkWidget *gtkMenu = d->gtkWidget("GtkMenu"); guint horizontal_padding = 0; // horizontal-padding is used by Maemo to get thicker borders if (!d->gtk_check_version(2, 10, 0)) @@ -495,7 +495,7 @@ case PM_SliderThickness: case PM_SliderControlThickness: { - GtkWidget *gtkScale = d->gtkWidget(QLS("GtkHScale")); + GtkWidget *gtkScale = d->gtkWidget("GtkHScale"); gint val; d->gtk_widget_style_get(gtkScale, "slider-width", &val, NULL); if (metric == PM_SliderControlThickness) @@ -506,7 +506,7 @@ case PM_ScrollBarExtent: { gint sliderLength; gint trough_border; - GtkWidget *hScrollbar = d->gtkWidget(QLS("GtkHScrollbar")); + GtkWidget *hScrollbar = d->gtkWidget("GtkHScrollbar"); d->gtk_widget_style_get(hScrollbar, "trough-border", &trough_border, "slider-width", &sliderLength, @@ -519,34 +519,34 @@ case PM_SliderLength: gint val; - d->gtk_widget_style_get(d->gtkWidget(QLS("GtkHScale")), "slider-length", &val, NULL); + d->gtk_widget_style_get(d->gtkWidget("GtkHScale"), "slider-length", &val, NULL); return val; case PM_ExclusiveIndicatorWidth: case PM_ExclusiveIndicatorHeight: case PM_IndicatorWidth: case PM_IndicatorHeight: { - GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton")); + GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton"); gint size, spacing; d->gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, "indicator-size", &size, NULL); return size + 2 * spacing; } case PM_MenuBarVMargin: { - GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar")); + GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar"); return qMax(0, gtkMenubar->style->ythickness); } case PM_ScrollView_ScrollBarSpacing: { gint spacing = 3; - GtkWidget *gtkScrollWindow = d->gtkWidget(QLS("GtkScrolledWindow")); + GtkWidget *gtkScrollWindow = d->gtkWidget("GtkScrolledWindow"); Q_ASSERT(gtkScrollWindow); d->gtk_widget_style_get(gtkScrollWindow, "scrollbar-spacing", &spacing, NULL); return spacing; } case PM_SubMenuOverlap: { gint offset = 0; - GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu")); + GtkWidget *gtkMenu = d->gtkWidget("GtkMenu"); d->gtk_widget_style_get(gtkMenu, "horizontal-offset", &offset, NULL); return offset; } @@ -587,7 +587,7 @@ { if (d->isKDE4Session()) return QCleanlooksStyle::styleHint(hint, option, widget, returnData); - GtkWidget *gtkToolbar = d->gtkWidget(QLS("GtkToolbar")); + GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar"); GtkToolbarStyle toolbar_style = GTK_TOOLBAR_ICONS; g_object_get(gtkToolbar, "toolbar-style", &toolbar_style, NULL); switch (toolbar_style) { @@ -610,7 +610,7 @@ return int(false); case SH_ComboBox_Popup: { - GtkWidget *gtkComboBox = d->gtkWidget(QLS("GtkComboBox")); + GtkWidget *gtkComboBox = d->gtkWidget("GtkComboBox"); gboolean appears_as_list; d->gtk_widget_style_get((GtkWidget*)gtkComboBox, "appears-as-list", &appears_as_list, NULL); return appears_as_list ? 0 : 1; @@ -634,7 +634,7 @@ if (widget && widget->isWindow()) scrollbars_within_bevel = true; else if (!d->gtk_check_version(2, 12, 0)) { - GtkWidget *gtkScrollWindow = d->gtkWidget(QLS("GtkScrolledWindow")); + GtkWidget *gtkScrollWindow = d->gtkWidget("GtkScrolledWindow"); d->gtk_widget_style_get(gtkScrollWindow, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL); } return !scrollbars_within_bevel; @@ -712,7 +712,7 @@ 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(d->gtkWidget(QLS("GtkFrame")), "viewport", pmRect, + gtkFramePainter.paintShadow(d->gtkWidget("GtkFrame"), "viewport", pmRect, option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, shadow_type, style); QPixmapCache::insert(pmKey, pixmap); @@ -739,7 +739,7 @@ break; case PE_PanelTipLabel: { - GtkWidget *gtkWindow = d->gtkWidget(QLS("GtkWindow")); // The Murrine Engine currently assumes a widget is passed + GtkWidget *gtkWindow = d->gtkWidget("GtkWindow"); // The Murrine Engine currently assumes a widget is passed style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(), "gtk-tooltips", "GtkWindow", d->gtk_window_get_type()); gtkPainter.paintFlatBox(gtkWindow, "tooltip", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, style); @@ -754,7 +754,7 @@ break; } GtkShadowType shadow_type; - GtkWidget *gtkStatusbarFrame = d->gtkWidget(QLS("GtkStatusbar.GtkFrame")); + GtkWidget *gtkStatusbarFrame = d->gtkWidget("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); @@ -763,12 +763,14 @@ case PE_IndicatorHeaderArrow: if (const QStyleOptionHeader *header = qstyleoption_cast(option)) { - GtkWidget *gtkTreeHeader = d->gtkWidget(QLS("GtkTreeView.GtkButton")); + GtkWidget *gtkTreeHeader = d->gtkWidget("GtkTreeView.GtkButton"); GtkStateType state = gtkPainter.gtkState(option); style = gtkTreeHeader->style; GtkArrowType type = GTK_ARROW_UP; QRect r = header->rect; QImage arrow; + // This sorting indicator inversion is intentional, and follows the GNOME HIG. + // See http://library.gnome.org/devel/hig-book/stable/controls-lists.html.en#controls-lists-sortable if (header->sortIndicator & QStyleOptionHeader::SortUp) type = GTK_ARROW_UP; else if (header->sortIndicator & QStyleOptionHeader::SortDown) @@ -801,7 +803,7 @@ rect.translate(2, 0); GtkExpanderStyle openState = GTK_EXPANDER_EXPANDED; GtkExpanderStyle closedState = GTK_EXPANDER_COLLAPSED; - GtkWidget *gtkTreeView = d->gtkWidget(QLS("GtkTreeView")); + GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView"); GtkStateType state = GTK_STATE_NORMAL; if (!(option->state & State_Enabled)) @@ -837,7 +839,7 @@ case PE_IndicatorToolBarSeparator: { const int margin = 6; - GtkWidget *gtkSeparator = d->gtkWidget(QLS("GtkToolbar.GtkSeparatorToolItem")); + GtkWidget *gtkSeparator = d->gtkWidget("GtkToolbar.GtkSeparatorToolItem"); if (option->state & State_Horizontal) { const int offset = option->rect.width()/2; QRect rect = option->rect.adjusted(offset, margin, 0, -margin); @@ -857,7 +859,7 @@ break; case PE_IndicatorToolBarHandle: { - GtkWidget *gtkToolbar = d->gtkWidget(QLS("GtkToolbar")); + GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar"); GtkShadowType shadow_type; d->gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL); //Note when the toolbar is horizontal, the handle is vertical @@ -905,7 +907,7 @@ GtkStateType state = gtkPainter.gtkState(option); QColor arrowColor = option->palette.buttonText().color(); - GtkWidget *gtkArrow = d->gtkWidget(QLS("GtkArrow")); + GtkWidget *gtkArrow = d->gtkWidget("GtkArrow"); GdkColor color = fromQColor(arrowColor); d->gtk_widget_modify_fg (gtkArrow, state, &color); gtkPainter.paintArrow(gtkArrow, "button", arrowRect, @@ -921,7 +923,7 @@ break; case PE_PanelMenu: { - GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu")); + GtkWidget *gtkMenu = d->gtkWidget("GtkMenu"); gtkPainter.setAlphaSupport(false); // Note, alpha disabled for performance reasons gtkPainter.paintBox(gtkMenu, "menu", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, gtkMenu->style, QString()); } @@ -933,7 +935,7 @@ // This is only used by floating tool bars if (qobject_cast(widget)) { - GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar")); + GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar"); gtkPainter.paintBox( gtkMenubar, "toolbar", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style); gtkPainter.paintBox( gtkMenubar, "menu", option->rect, @@ -942,7 +944,7 @@ break; case PE_FrameLineEdit: { - GtkWidget *gtkEntry = d->gtkWidget(QLS("GtkEntry")); + GtkWidget *gtkEntry = d->gtkWidget("GtkEntry"); gboolean interior_focus; @@ -976,7 +978,7 @@ case PE_PanelLineEdit: if (const QStyleOptionFrame *panel = qstyleoption_cast(option)) { - GtkWidget *gtkEntry = d->gtkWidget(QLS("GtkEntry")); + GtkWidget *gtkEntry = d->gtkWidget("GtkEntry"); if (panel->lineWidth > 0) proxy()->drawPrimitive(PE_FrameLineEdit, option, painter, widget); uint resolve_mask = option->palette.resolve(); @@ -994,7 +996,7 @@ case PE_FrameTabWidget: if (const QStyleOptionTabWidgetFrame *frame = qstyleoption_cast(option)) { - GtkWidget *gtkNotebook = d->gtkWidget(QLS("GtkNotebook")); + GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook"); style = gtkPainter.getStyle(gtkNotebook); gtkPainter.setAlphaSupport(false); GtkShadowType shadow = GTK_SHADOW_OUT; @@ -1042,7 +1044,7 @@ GtkStateType state = gtkPainter.gtkState(option); if (option->state & State_On || option->state & State_Sunken) state = GTK_STATE_ACTIVE; - GtkWidget *gtkButton = d->gtkWidget(isTool ? QLS("GtkToolButton.GtkButton") : QLS("GtkButton")); + GtkWidget *gtkButton = isTool ? d->gtkWidget("GtkToolButton.GtkButton") : d->gtkWidget("GtkButton"); gint focusWidth, focusPad; gboolean interiorFocus = false; d->gtk_widget_style_get (gtkButton, @@ -1098,14 +1100,14 @@ else shadow = GTK_SHADOW_OUT; - GtkWidget *gtkRadioButton = d->gtkWidget(QLS("GtkRadioButton")); + GtkWidget *gtkRadioButton = d->gtkWidget("GtkRadioButton"); gint spacing; d->gtk_widget_style_get(gtkRadioButton, "indicator-spacing", &spacing, NULL); QRect buttonRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing); gtkPainter.setClipRect(option->rect); // ### Note: Ubuntulooks breaks when the proper widget is passed // Murrine engine requires a widget not to get RGBA check - warnings - GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton")); + GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton"); QString key(QLS("radiobutton")); if (option->state & State_HasFocus) { // Themes such as Nodoka check this flag key += QLatin1Char('f'); @@ -1133,7 +1135,7 @@ int spacing; - GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton")); + GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton"); QString key(QLS("checkbutton")); if (option->state & State_HasFocus) { // Themes such as Nodoka checks this flag key += QLatin1Char('f'); @@ -1161,7 +1163,6 @@ if (const QStyleOptionTabBarBase *tbb = qstyleoption_cast(option)) { QRect tabRect = tbb->rect; - QRegion region(tabRect); painter->save(); painter->setPen(QPen(option->palette.dark().color().dark(110), 0)); switch (tbb->shape) { @@ -1243,8 +1244,6 @@ else alphaCornerColor = mergedColors(option->palette.background().color(), darkOutline); - QPalette palette = option->palette; - switch (control) { case CC_TitleBar: @@ -1275,7 +1274,7 @@ if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) { // Draw prelight background - GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton")); + GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton"); if (option->state & State_MouseOver) { QRect bgRect = textRect | checkBoxRect; @@ -1331,11 +1330,8 @@ bool isEnabled = (comboBox->state & State_Enabled); bool focus = isEnabled && (comboBox->state & State_HasFocus); - QColor buttonShadow = option->palette.dark().color(); GtkStateType state = gtkPainter.gtkState(option); int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, comboBox, widget); - QPixmap cache; - QString pixmapName; QStyleOptionComboBox comboBoxCopy = *comboBox; comboBoxCopy.rect = option->rect; @@ -1343,12 +1339,10 @@ QRect rect = option->rect; QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy, SC_ComboBoxArrow, widget); - QRect editRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy, - SC_ComboBoxEditField, widget); GtkShadowType shadow = (option->state & State_Sunken || option->state & State_On ) ? GTK_SHADOW_IN : GTK_SHADOW_OUT; - QString comboBoxPath = QLS(comboBox->editable ? "GtkComboBoxEntry" : "GtkComboBox"); + const QHashableLatin1Literal comboBoxPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry") : QHashableLatin1Literal("GtkComboBox"); // We use the gtk widget to position arrows and separators for us GtkWidget *gtkCombo = d->gtkWidget(comboBoxPath); @@ -1356,7 +1350,8 @@ 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"); + QHashableLatin1Literal buttonPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton") + : QHashableLatin1Literal("GtkComboBox.GtkToggleButton"); GtkWidget *gtkToggleButton = d->gtkWidget(buttonPath); d->gtk_widget_set_direction(gtkToggleButton, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); if (gtkToggleButton && (appears_as_list || comboBox->editable)) { @@ -1365,7 +1360,7 @@ // Draw the combo box as a line edit with a button next to it if (comboBox->editable || appears_as_list) { GtkStateType frameState = (state == GTK_STATE_PRELIGHT) ? GTK_STATE_NORMAL : state; - QString entryPath = QLS(comboBox->editable ? "GtkComboBoxEntry.GtkEntry" : "GtkComboBox.GtkFrame"); + QHashableLatin1Literal entryPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkEntry") : QHashableLatin1Literal("GtkComboBox.GtkFrame"); GtkWidget *gtkEntry = d->gtkWidget(entryPath); d->gtk_widget_set_direction(gtkEntry, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); QRect frameRect = option->rect; @@ -1391,11 +1386,11 @@ else { gtkCachedPainter.paintFlatBox(gtkEntry, "entry_bg", contentRect, option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, - GTK_SHADOW_NONE, gtkEntry->style, entryPath + QString::number(focus)); + GTK_SHADOW_NONE, gtkEntry->style, entryPath.toString() + QString::number(focus)); } gtkCachedPainter.paintShadow(gtkEntry, comboBox->editable ? "entry" : "frame", frameRect, frameState, - GTK_SHADOW_IN, gtkEntry->style, entryPath + + GTK_SHADOW_IN, gtkEntry->style, entryPath.toString() + QString::number(focus) + QString::number(comboBox->editable) + QString::number(option->direction)); if (focus) @@ -1411,12 +1406,9 @@ else if (option->state & State_MouseOver && comboBox->activeSubControls & SC_ComboBoxArrow) buttonState = GTK_STATE_PRELIGHT; - QRect buttonrect = QRect(gtkToggleButton->allocation.x, gtkToggleButton->allocation.y, - gtkToggleButton->allocation.width, gtkToggleButton->allocation.height); - Q_ASSERT(gtkToggleButton); gtkCachedPainter.paintBox( gtkToggleButton, "button", arrowButtonRect, buttonState, - shadow, gtkToggleButton->style, buttonPath + + shadow, gtkToggleButton->style, buttonPath.toString() + QString::number(focus) + QString::number(option->direction)); if (focus) GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS); @@ -1429,12 +1421,15 @@ gtkCachedPainter.paintBox(gtkToggleButton, "button", buttonRect, state, shadow, gtkToggleButton->style, - buttonPath + QString::number(focus)); + buttonPath.toString() + QString::number(focus)); if (focus) GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS); + // Draw the separator between label and arrows - QString vSeparatorPath = buttonPath + QLS(".GtkHBox.GtkVSeparator"); + QHashableLatin1Literal vSeparatorPath = comboBox->editable + ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkHBox.GtkVSeparator") + : QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkHBox.GtkVSeparator"); if (GtkWidget *gtkVSeparator = d->gtkWidget(vSeparatorPath)) { QRect vLineRect(gtkVSeparator->allocation.x, @@ -1444,7 +1439,7 @@ gtkCachedPainter.paintVline( gtkVSeparator, "vseparator", vLineRect, state, gtkVSeparator->style, - 0, vLineRect.height(), 0, vSeparatorPath); + 0, vLineRect.height(), 0, vSeparatorPath.toString()); gint interiorFocus = true; @@ -1469,8 +1464,18 @@ else state = GTK_STATE_NORMAL; - QString arrowPath = comboBoxPath + QLS(appears_as_list ? ".GtkToggleButton.GtkArrow" - : ".GtkToggleButton.GtkHBox.GtkArrow"); + QHashableLatin1Literal arrowPath(""); + if (comboBox->editable) { + if (appears_as_list) + arrowPath = QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkArrow"); + else + arrowPath = QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkHBox.GtkArrow"); + } else { + if (appears_as_list) + arrowPath = QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkArrow"); + else + arrowPath = QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkHBox.GtkArrow"); + } GtkWidget *gtkArrow = d->gtkWidget(arrowPath); gfloat scale = 0.7; @@ -1497,7 +1502,11 @@ if (sunken) { int xoff, yoff; - GtkWidget *gtkButton = d->gtkWidget(comboBoxPath + QLS(".GtkToggleButton")); + const QHashableLatin1Literal toggleButtonPath = comboBox->editable + ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton") + : QHashableLatin1Literal("GtkComboBox.GtkToggleButton"); + + GtkWidget *gtkButton = d->gtkWidget(toggleButtonPath); d->gtk_widget_style_get(gtkButton, "child-displacement-x", &xoff, NULL); d->gtk_widget_style_get(gtkButton, "child-displacement-y", &yoff, NULL); arrowRect = arrowRect.adjusted(xoff, yoff, xoff, yoff); @@ -1509,7 +1518,7 @@ gtkCachedPainter.setClipRect(option->rect); gtkCachedPainter.paintArrow( gtkArrow, "arrow", arrowRect, GTK_ARROW_DOWN, state, GTK_SHADOW_NONE, TRUE, - style, arrowPath + QString::number(option->direction)); + style, arrowPath.toString() + QString::number(option->direction)); } } END_STYLE_PIXMAPCACHE; @@ -1570,7 +1579,7 @@ QStyleOptionToolButton label = *toolbutton; label.state = bflags; - GtkWidget *gtkButton = d->gtkWidget(QLS("GtkToolButton.GtkButton")); + GtkWidget *gtkButton = d->gtkWidget("GtkToolButton.GtkButton"); QPalette pal = toolbutton->palette; if (option->state & State_Enabled && option->state & State_MouseOver && !(widget && widget->testAttribute(Qt::WA_SetPalette))) { @@ -1605,8 +1614,8 @@ case CC_ScrollBar: if (const QStyleOptionSlider *scrollBar = qstyleoption_cast(option)) { - GtkWidget *gtkHScrollBar = d->gtkWidget(QLS("GtkHScrollbar")); - GtkWidget *gtkVScrollBar = d->gtkWidget(QLS("GtkVScrollbar")); + GtkWidget *gtkHScrollBar = d->gtkWidget("GtkHScrollbar"); + GtkWidget *gtkVScrollBar = d->gtkWidget("GtkVScrollbar"); // Fill background in case the scrollbar is partially transparent painter->fillRect(option->rect, option->palette.background()); @@ -1621,6 +1630,7 @@ style = scrollbarWidget->style; gboolean trough_under_steppers = true; gboolean trough_side_details = false; + gboolean activate_slider = false; gboolean stepper_size = 14; gint trough_border = 1; if (!d->gtk_check_version(2, 10, 0)) { @@ -1628,6 +1638,7 @@ "trough-border", &trough_border, "trough-side-details", &trough_side_details, "trough-under-steppers", &trough_under_steppers, + "activate-slider", &activate_slider, "stepper-size", &stepper_size, NULL); } if (trough_under_steppers) { @@ -1673,6 +1684,9 @@ if (!(option->state & State_Enabled)) state = GTK_STATE_INSENSITIVE; + else if (activate_slider && + option->state & State_Sunken && (scrollBar->activeSubControls & SC_ScrollBarSlider)) + state = GTK_STATE_ACTIVE; else if (option->state & State_MouseOver && (scrollBar->activeSubControls & SC_ScrollBarSlider)) state = GTK_STATE_PRELIGHT; @@ -1751,10 +1765,9 @@ case CC_SpinBox: if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast(option)) { - GtkWidget *gtkSpinButton = d->gtkWidget( - spinBox->buttonSymbols == QAbstractSpinBox::NoButtons ? - QLS("GtkEntry") : - QLS("GtkSpinButton")); + GtkWidget *gtkSpinButton = spinBox->buttonSymbols == QAbstractSpinBox::NoButtons + ? d->gtkWidget("GtkEntry") + : d->gtkWidget("GtkSpinButton"); bool isEnabled = (spinBox->state & State_Enabled); bool hover = isEnabled && (spinBox->state & State_MouseOver); bool sunken = (spinBox->state & State_Sunken); @@ -1906,19 +1919,16 @@ case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) { - GtkWidget *hScaleWidget = d->gtkWidget(QLS("GtkHScale")); - GtkWidget *vScaleWidget = d->gtkWidget(QLS("GtkVScale")); + GtkWidget *hScaleWidget = d->gtkWidget("GtkHScale"); + GtkWidget *vScaleWidget = d->gtkWidget("GtkVScale"); QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget); - QRect ticks = proxy()->subControlRect(CC_Slider, option, SC_SliderTickmarks, widget); bool horizontal = slider->orientation == Qt::Horizontal; bool ticksAbove = slider->tickPosition & QSlider::TicksAbove; bool ticksBelow = slider->tickPosition & QSlider::TicksBelow; - QColor activeHighlight = option->palette.color(QPalette::Normal, QPalette::Highlight); - - QPixmap cache; + QBrush oldBrush = painter->brush(); QPen oldPen = painter->pen(); @@ -1927,6 +1937,8 @@ QColor highlightAlpha(Qt::white); highlightAlpha.setAlpha(80); + QGtkStylePrivate::gtk_widget_set_direction(hScaleWidget, slider->upsideDown ? + GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); GtkWidget *scaleWidget = horizontal ? hScaleWidget : vScaleWidget; style = scaleWidget->style; @@ -1960,11 +1972,21 @@ QRect lowerGroove = grooveRect; if (horizontal) { - upperGroove.setLeft(handle.center().x()); - lowerGroove.setRight(handle.center().x()); + if (slider->upsideDown) { + lowerGroove.setLeft(handle.center().x()); + upperGroove.setRight(handle.center().x()); + } else { + upperGroove.setLeft(handle.center().x()); + lowerGroove.setRight(handle.center().x()); + } } else { - upperGroove.setBottom(handle.center().y()); - lowerGroove.setTop(handle.center().y()); + if (!slider->upsideDown) { + lowerGroove.setBottom(handle.center().y()); + upperGroove.setTop(handle.center().y()); + } else { + upperGroove.setBottom(handle.center().y()); + lowerGroove.setTop(handle.center().y()); + } } gtkPainter.paintBox( scaleWidget, "trough-upper", upperGroove, state, @@ -2097,7 +2119,7 @@ switch (element) { case CE_ProgressBarLabel: if (const QStyleOptionProgressBar *bar = qstyleoption_cast(option)) { - GtkWidget *gtkProgressBar = d->gtkWidget(QLS("GtkProgressBar")); + GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar"); if (!gtkProgressBar) return; @@ -2200,7 +2222,7 @@ if (button->features & QStyleOptionButton::HasMenu) ir = ir.adjusted(0, 0, -pixelMetric(PM_MenuButtonIndicator, button, widget), 0); - GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); + GtkWidget *gtkButton = d->gtkWidget("GtkButton"); QPalette pal = button->palette; int labelState = GTK_STATE_INSENSITIVE; if (option->state & State_Enabled) @@ -2221,7 +2243,7 @@ bool isRadio = (element == CE_RadioButton); // Draw prelight background - GtkWidget *gtkRadioButton = d->gtkWidget(QLS("GtkRadioButton")); + GtkWidget *gtkRadioButton = d->gtkWidget("GtkRadioButton"); if (option->state & State_MouseOver) { gtkPainter.paintFlatBox(gtkRadioButton, "checkbutton", option->rect, @@ -2289,7 +2311,7 @@ } if (!cb->currentText.isEmpty() && !cb->editable) { - GtkWidget *gtkCombo = d->gtkWidget(QLS("GtkComboBox")); + GtkWidget *gtkCombo = d->gtkWidget("GtkComboBox"); QPalette pal = cb->palette; int labelState = GTK_STATE_INSENSITIVE; @@ -2366,7 +2388,7 @@ // Draws the header in tables. if (const QStyleOptionHeader *header = qstyleoption_cast(option)) { Q_UNUSED(header); - GtkWidget *gtkTreeView = d->gtkWidget(QLS("GtkTreeView")); + GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView"); // Get the middle column GtkTreeViewColumn *column = d->gtk_tree_view_get_column((GtkTreeView*)gtkTreeView, 1); Q_ASSERT(column); @@ -2387,7 +2409,7 @@ #ifndef QT_NO_SIZEGRIP case CE_SizeGrip: { - GtkWidget *gtkStatusbar = d->gtkWidget(QLS("GtkStatusbar.GtkFrame")); + GtkWidget *gtkStatusbar = d->gtkWidget("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() ? @@ -2399,7 +2421,7 @@ #endif // QT_NO_SIZEGRIP case CE_MenuBarEmptyArea: { - GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar")); + GtkWidget *gtkMenubar = d->gtkWidget("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 @@ -2422,8 +2444,8 @@ painter->save(); if (const QStyleOptionMenuItem *mbi = qstyleoption_cast(option)) { - GtkWidget *gtkMenubarItem = d->gtkWidget(QLS("GtkMenuBar.GtkMenuItem")); - GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar")); + GtkWidget *gtkMenubarItem = d->gtkWidget("GtkMenuBar.GtkMenuItem"); + GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar"); style = gtkMenubarItem->style; @@ -2479,7 +2501,7 @@ break; case CE_Splitter: { - GtkWidget *gtkWindow = d->gtkWidget(QLS("GtkWindow")); // The Murrine Engine currently assumes a widget is passed + GtkWidget *gtkWindow = d->gtkWidget("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); @@ -2499,7 +2521,7 @@ if (toolbar->positionWithinLine != QStyleOptionToolBar::End) rect.adjust(0, 0, 1, 0); - GtkWidget *gtkToolbar = d->gtkWidget(QLS("GtkToolbar")); + GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar"); GtkShadowType shadow_type = GTK_SHADOW_NONE; d->gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL); gtkPainter.paintBox( gtkToolbar, "toolbar", rect, @@ -2518,15 +2540,14 @@ 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 *gtkMenuItem = menuItem->checked ? d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")) : - d->gtkWidget(QLS("GtkMenu.GtkMenuItem")); + GtkWidget *gtkMenuItem = menuItem->checked ? d->gtkWidget("GtkMenu.GtkCheckMenuItem") : + d->gtkWidget("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 = d->gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem")); + GtkWidget *gtkMenuSeparator = d->gtkWidget("GtkMenu.GtkSeparatorMenuItem"); painter->setPen(shadow.lighter(106)); gboolean wide_separators = 0; gint separator_height = 0; @@ -2570,7 +2591,7 @@ bool ignoreCheckMark = false; gint checkSize; - d->gtk_widget_style_get(d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")), "indicator-size", &checkSize, NULL); + d->gtk_widget_style_get(d->gtkWidget("GtkMenu.GtkCheckMenuItem"), "indicator-size", &checkSize, NULL); int checkcol = qMax(menuItem->maxIconWidth, qMax(20, checkSize)); @@ -2747,8 +2768,6 @@ // Arrow if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow - QPoint buttonShift(pixelMetric(PM_ButtonShiftHorizontal, option, widget), - proxy()->pixelMetric(PM_ButtonShiftVertical, option, widget)); QFontMetrics fm(menuitem->font); int arrow_size = fm.ascent() + fm.descent() - 2 * gtkMenuItem->style->ythickness; @@ -2781,7 +2800,7 @@ case CE_PushButton: if (const QStyleOptionButton *btn = qstyleoption_cast(option)) { - GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); + GtkWidget *gtkButton = d->gtkWidget("GtkButton"); proxy()->drawControl(CE_PushButtonBevel, btn, painter, widget); QStyleOptionButton subopt = *btn; subopt.rect = subElementRect(SE_PushButtonContents, btn, widget); @@ -2807,7 +2826,7 @@ case CE_TabBarTabShape: if (const QStyleOptionTab *tab = qstyleoption_cast(option)) { - GtkWidget *gtkNotebook = d->gtkWidget(QLS("GtkNotebook")); + GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook"); style = gtkPainter.getStyle(gtkNotebook); QRect rect = option->rect; @@ -2874,7 +2893,7 @@ case CE_ProgressBarGroove: if (const QStyleOptionProgressBar *bar = qstyleoption_cast(option)) { Q_UNUSED(bar); - GtkWidget *gtkProgressBar = d->gtkWidget(QLS("GtkProgressBar")); + GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar"); GtkStateType state = gtkPainter.gtkState(option); gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, gtkProgressBar->style); } @@ -2884,7 +2903,7 @@ case CE_ProgressBarContents: if (const QStyleOptionProgressBar *bar = qstyleoption_cast(option)) { GtkStateType state = option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE; - GtkWidget *gtkProgressBar = d->gtkWidget(QLS("GtkProgressBar")); + GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar"); style = gtkProgressBar->style; gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, style); int xt = style->xthickness; @@ -3042,7 +3061,7 @@ case CC_SpinBox: if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast(option)) { - GtkWidget *gtkSpinButton = d->gtkWidget(QLS("GtkSpinButton")); + GtkWidget *gtkSpinButton = d->gtkWidget("GtkSpinButton"); int center = spinbox->rect.height() / 2; int xt = spinbox->frame ? gtkSpinButton->style->xthickness : 0; int yt = spinbox->frame ? gtkSpinButton->style->ythickness : 0; @@ -3095,16 +3114,19 @@ case CC_ComboBox: if (const QStyleOptionComboBox *box = qstyleoption_cast(option)) { // We employ the gtk widget to position arrows and separators for us - QString comboBoxPath = box->editable ? QLS("GtkComboBoxEntry") : QLS("GtkComboBox"); - GtkWidget *gtkCombo = d->gtkWidget(comboBoxPath); + GtkWidget *gtkCombo = box->editable ? d->gtkWidget("GtkComboBoxEntry") + : d->gtkWidget("GtkComboBox"); d->gtk_widget_set_direction(gtkCombo, (option->direction == Qt::RightToLeft) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); GtkAllocation geometry = {0, 0, qMax(0, option->rect.width()), qMax(0, option->rect.height())}; d->gtk_widget_size_allocate(gtkCombo, &geometry); int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, option, widget); - QString arrowPath = comboBoxPath + QLS(".GtkToggleButton"); - - if (!box->editable && !appears_as_list) - arrowPath += QLS(".GtkHBox.GtkArrow"); + QHashableLatin1Literal arrowPath("GtkComboBoxEntry.GtkToggleButton"); + if (!box->editable) { + if (appears_as_list) + arrowPath = "GtkComboBox.GtkToggleButton"; + else + arrowPath = "GtkComboBox.GtkToggleButton.GtkHBox.GtkArrow"; + } GtkWidget *arrowWidget = d->gtkWidget(arrowPath); if (!arrowWidget) @@ -3163,7 +3185,7 @@ case CT_ToolButton: if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast(option)) { - GtkWidget *gtkButton = d->gtkWidget(QLS("GtkToolButton.GtkButton")); + GtkWidget *gtkButton = d->gtkWidget("GtkToolButton.GtkButton"); newSize = size + QSize(2 * gtkButton->style->xthickness, 2 + 2 * gtkButton->style->ythickness); if (widget && qobject_cast(widget->parentWidget())) { QSize minSize(0, 25); @@ -3181,14 +3203,14 @@ int textMargin = 8; if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { - GtkWidget *gtkMenuSeparator = d->gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem")); + GtkWidget *gtkMenuSeparator = d->gtkWidget("GtkMenu.GtkSeparatorMenuItem"); GtkRequisition sizeReq = {0, 0}; d->gtk_widget_size_request(gtkMenuSeparator, &sizeReq); newSize = QSize(size.width(), sizeReq.height); break; } - GtkWidget *gtkMenuItem = d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")); + GtkWidget *gtkMenuItem = d->gtkWidget("GtkMenu.GtkCheckMenuItem"); GtkStyle* style = gtkMenuItem->style; // Note we get the perfect height for the default font since we @@ -3210,12 +3232,12 @@ case CT_SpinBox: // QSpinBox does some nasty things that depends on CT_LineEdit - newSize = size + QSize(0, -d->gtkWidget(QLS("GtkSpinButton"))->style->ythickness * 2); + newSize = size + QSize(0, -d->gtkWidget("GtkSpinButton")->style->ythickness * 2); break; case CT_PushButton: if (const QStyleOptionButton *btn = qstyleoption_cast(option)) { - GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); + GtkWidget *gtkButton = d->gtkWidget("GtkButton"); gint focusPadding, focusWidth; d->gtk_widget_style_get(gtkButton, "focus-padding", &focusPadding, NULL); d->gtk_widget_style_get(gtkButton, "focus-line-width", &focusWidth, NULL); @@ -3223,7 +3245,7 @@ newSize += QSize(2*gtkButton->style->xthickness + 4, 2*gtkButton->style->ythickness); newSize += QSize(2*(focusWidth + focusPadding + 2), 2*(focusWidth + focusPadding)); - GtkWidget *gtkButtonBox = d->gtkWidget(QLS("GtkHButtonBox")); + GtkWidget *gtkButtonBox = d->gtkWidget("GtkHButtonBox"); gint minWidth = 85, minHeight = 0; d->gtk_widget_style_get(gtkButtonBox, "child-min-width", &minWidth, "child-min-height", &minHeight, NULL); @@ -3236,13 +3258,13 @@ break; case CT_Slider: { - GtkWidget *gtkSlider = d->gtkWidget(QLS("GtkHScale")); + GtkWidget *gtkSlider = d->gtkWidget("GtkHScale"); newSize = size + QSize(2*gtkSlider->style->xthickness, 2*gtkSlider->style->ythickness); } break; case CT_LineEdit: { - GtkWidget *gtkEntry = d->gtkWidget(QLS("GtkEntry")); + GtkWidget *gtkEntry = d->gtkWidget("GtkEntry"); newSize = size + QSize(2*gtkEntry->style->xthickness, 2 + 2*gtkEntry->style->ythickness); } break; @@ -3253,7 +3275,7 @@ case CT_ComboBox: if (const QStyleOptionComboBox *combo = qstyleoption_cast(option)) { - GtkWidget *gtkCombo = d->gtkWidget(QLS("GtkComboBox")); + GtkWidget *gtkCombo = d->gtkWidget("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); @@ -3408,7 +3430,7 @@ return option->rect; case SE_PushButtonContents: if (!d->gtk_check_version(2, 10, 0)) { - GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); + GtkWidget *gtkButton = d->gtkWidget("GtkButton"); GtkBorder *border = 0; d->gtk_widget_style_get(gtkButton, "inner-border", &border, NULL); if (border) {