summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorJens Bache-Wiig <jbache@trolltech.com>2009-11-18 16:08:37 +0100
committerJens Bache-Wiig <jbache@trolltech.com>2009-11-18 16:24:05 +0100
commit5d4f58843bb1c8590986aa710dbea30525578a5f (patch)
tree6ac71cccfa21c961076dae6c2501631bce222a86 /src/gui
parentd173dabf3e441bf4a16237df1a90e256ae525596 (diff)
Fix multiple regressions in QGtkStyle caused by freetype fixes
Qt 4.6 reports smaller sizes for all fonts which means a lot of the size adjustments QGtkStyle does were now off. I have adjusted most of them including some fixes to menu items themselves. Note that the changes were introduced with this change: 04d18b38c38c5ff623b30366ea08d56128b9b7d0 We now also adapt to GNOME 2.16 style submenu arrow sizes. Combo boxes, line edits, spin boxes and push buttons should finally have a uniform height. Task-number: QTBUG-5753 Reviewed-by: thorbjorn
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/styles/qcleanlooksstyle.cpp1
-rw-r--r--src/gui/styles/qgtkstyle.cpp32
2 files changed, 20 insertions, 13 deletions
diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp
index 973e6823fe..b08847d718 100644
--- a/src/gui/styles/qcleanlooksstyle.cpp
+++ b/src/gui/styles/qcleanlooksstyle.cpp
@@ -3817,6 +3817,7 @@ QSize QCleanlooksStyle::sizeFromContents(ContentsType type, const QStyleOption *
newSize.setWidth(80);
if (!btn->icon.isNull() && btn->iconSize.height() > 16)
newSize -= QSize(0, 2);
+ newSize += QSize(0, 1);
}
if (const QPushButton *button = qobject_cast<const QPushButton *>(widget)) {
if (qobject_cast<const QDialogButtonBox *>(button->parentWidget())) {
diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp
index 58aa3b862e..5566cc6a1e 100644
--- a/src/gui/styles/qgtkstyle.cpp
+++ b/src/gui/styles/qgtkstyle.cpp
@@ -2521,7 +2521,7 @@ void QGtkStyle::drawControl(ControlElement element,
bool selected = menuItem->state & State_Selected && menuItem->state & State_Enabled;
if (selected) {
- QRect rect = option->rect.adjusted(0, 0, -1, -1);
+ QRect rect = option->rect.adjusted(0, 0, 0, -1);
#ifndef QT_NO_COMBOBOX
if (qobject_cast<const QComboBox*>(widget))
rect = option->rect;
@@ -2628,7 +2628,7 @@ void QGtkStyle::drawControl(ControlElement element,
int pixw = pixmap.width();
int pixh = pixmap.height();
QRect pmr(0, 0, pixw, pixh);
- pmr.moveCenter(vCheckRect.center());
+ pmr.moveCenter(vCheckRect.center() - QPoint(0, 1));
painter->setPen(menuItem->palette.text().color());
if (!ignoreCheckMark && checkable && checked) {
QStyleOption opt = *option;
@@ -2670,8 +2670,8 @@ void QGtkStyle::drawControl(ControlElement element,
menuitem->rect.getRect(&x, &y, &w, &h);
int tab = menuitem->tabWidth;
int xm = windowsItemFrame + checkcol + windowsItemHMargin;
- int xpos = menuitem->rect.x() + xm;
- QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
+ int xpos = menuitem->rect.x() + xm + 1;
+ QRect textRect(xpos, y + windowsItemVMargin - 1, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
QString s = menuitem->text;
@@ -2718,13 +2718,19 @@ void QGtkStyle::drawControl(ControlElement element,
QFontMetrics fm(menuitem->font);
int arrow_size = fm.ascent() + fm.descent() - 2 * gtkMenuItem->style->ythickness;
gfloat arrow_scaling = 0.8;
+ int extra = 0;
+ if (!d->gtk_check_version(2, 16, 0)) {
+ // "arrow-scaling" is actually hardcoded and fails on hardy (see gtk+-2.12/gtkmenuitem.c)
+ // though the current documentation states otherwise
+ d->gtk_widget_style_get(gtkMenuItem, "arrow-scaling", &arrow_scaling, NULL);
+ // in versions < 2.16 ythickness was previously subtracted from the arrow_size
+ extra = 2 * gtkMenuItem->style->ythickness;
+ }
- // "arrow-scaling" is actually hardcoded and fails on hardy (see gtk+-2.12/gtkmenuitem.c)
- // though the current documentation states otherwise
int horizontal_padding;
d->gtk_widget_style_get(gtkMenuItem, "horizontal-padding", &horizontal_padding, NULL);
- const int dim = static_cast<int>(arrow_size * arrow_scaling);
+ const int dim = static_cast<int>(arrow_size * arrow_scaling) + extra;
int xpos = menuItem->rect.left() + menuItem->rect.width() - horizontal_padding - dim;
QRect vSubMenuRect = visualRect(option->direction, menuItem->rect,
QRect(xpos, menuItem->rect.top() +
@@ -3123,7 +3129,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
case CT_ToolButton:
if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
GtkWidget *gtkButton = d->gtkWidget(QLS("GtkToolButton.GtkButton"));
- newSize = size + QSize(2 * gtkButton->style->xthickness, 1 + 2 * gtkButton->style->ythickness);
+ newSize = size + QSize(2 * gtkButton->style->xthickness, 2 + 2 * gtkButton->style->ythickness);
if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) {
QSize minSize(0, 25);
if (toolbutton->toolButtonStyle != Qt::ToolButtonTextOnly)
@@ -3155,7 +3161,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
GtkWidget *gtkMenuItem = d->gtkWidget(QLS("GtkMenu.GtkMenuItem"));
GtkStyle* style = gtkMenuItem->style;
- newSize += QSize(textMargin + style->xthickness - 2, style->ythickness - 4);
+ newSize += QSize(textMargin + style->xthickness - 1, style->ythickness - 3);
// Cleanlooks assumes a check column of 20 pixels so we need to
// expand it a bit
@@ -3175,7 +3181,7 @@ 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, -d->gtkWidget(QLS("GtkSpinButton"))->style->ythickness * 2 + 2);
+ newSize = size + QSize(0, -d->gtkWidget(QLS("GtkSpinButton"))->style->ythickness * 2);
break;
case CT_PushButton:
@@ -3208,7 +3214,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
case CT_LineEdit: {
GtkWidget *gtkEntry = d->gtkWidget(QLS("GtkEntry"));
- newSize = size + QSize(2*gtkEntry->style->xthickness, 2*gtkEntry->style->ythickness);
+ newSize = size + QSize(2*gtkEntry->style->xthickness, 2 + 2*gtkEntry->style->ythickness);
}
break;
@@ -3223,7 +3229,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
newSize = size + QSize(12 + arrowButtonRect.width() + 2*gtkCombo->style->xthickness, 4 + 2*gtkCombo->style->ythickness);
if (!(widget && qobject_cast<QToolBar *>(widget->parentWidget())))
- newSize += QSize(0, 3);
+ newSize += QSize(0, 2);
}
break;
@@ -3236,7 +3242,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
if (!tab->icon.isNull())
newSize += QSize(6, 0);
}
- newSize += QSize(1, 0);
+ newSize += QSize(1, 1);
break;
default: