Fusion & GTK styles need to check direction from style option not qapp
An RTL menu containing a menu item which opens a submenu was showing the wrong arrow if the application's direction was not also RTL. So now the test for QTBUG-30595 can be simplified: no need to set the application direction, and therefore less chance of failure. Change-Id: Id140656206c6fefea3649289477dc54c77e2dd5e Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>bb10
parent
4c7881396e
commit
acfccd0483
|
|
@ -1681,7 +1681,7 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio
|
|||
if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
|
||||
int dim = (menuItem->rect.height() - 4) / 2;
|
||||
PrimitiveElement arrow;
|
||||
arrow = QApplication::isRightToLeft() ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
|
||||
arrow = option->direction == Qt::RightToLeft ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
|
||||
int xpos = menuItem->rect.left() + menuItem->rect.width() - 3 - dim;
|
||||
QRect vSubMenuRect = visualRect(option->direction, menuItem->rect,
|
||||
QRect(xpos, menuItem->rect.top() + menuItem->rect.height() / 2 - dim / 2, dim, dim));
|
||||
|
|
|
|||
|
|
@ -2985,7 +2985,7 @@ void QGtkStyle::drawControl(ControlElement element,
|
|||
GtkStyle *gtkStatusbarStyle = d->gtk_widget_get_style(gtkStatusbar);
|
||||
QRect gripRect = option->rect.adjusted(0, 0, -gtkStatusbarStyle->xthickness, -gtkStatusbarStyle->ythickness);
|
||||
gtkPainter->paintResizeGrip(gtkStatusbar, "statusbar", gripRect, GTK_STATE_NORMAL,
|
||||
GTK_SHADOW_OUT, QApplication::isRightToLeft() ?
|
||||
GTK_SHADOW_OUT, option->direction == Qt::RightToLeft ?
|
||||
GDK_WINDOW_EDGE_SOUTH_WEST : GDK_WINDOW_EDGE_SOUTH_EAST,
|
||||
gtkStatusbarStyle);
|
||||
}
|
||||
|
|
@ -3366,7 +3366,7 @@ void QGtkStyle::drawControl(ControlElement element,
|
|||
menuItem->rect.height() / 2 - dim / 2, dim, dim));
|
||||
GtkStateType state = enabled ? (act ? GTK_STATE_PRELIGHT: GTK_STATE_NORMAL) : GTK_STATE_INSENSITIVE;
|
||||
GtkShadowType shadowType = (state == GTK_STATE_PRELIGHT) ? GTK_SHADOW_OUT : GTK_SHADOW_IN;
|
||||
gtkPainter->paintArrow(gtkMenuItem, "menuitem", vSubMenuRect, QApplication::isRightToLeft() ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT, state,
|
||||
gtkPainter->paintArrow(gtkMenuItem, "menuitem", vSubMenuRect, option->direction == Qt::RightToLeft ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT, state,
|
||||
shadowType, false, style);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -897,29 +897,10 @@ void tst_QMenu::QTBUG7411_submenus_activate()
|
|||
QTRY_VERIFY(sub1.isVisible());
|
||||
}
|
||||
|
||||
class LayoutDirectionSaver
|
||||
{
|
||||
Q_DISABLE_COPY(LayoutDirectionSaver)
|
||||
public:
|
||||
explicit LayoutDirectionSaver(Qt::LayoutDirection direction)
|
||||
: m_oldDirection(qApp->layoutDirection())
|
||||
{
|
||||
qApp->setLayoutDirection(direction);
|
||||
}
|
||||
|
||||
~LayoutDirectionSaver()
|
||||
{
|
||||
qApp->setLayoutDirection(m_oldDirection);
|
||||
}
|
||||
|
||||
private:
|
||||
const Qt::LayoutDirection m_oldDirection;
|
||||
};
|
||||
|
||||
void tst_QMenu::QTBUG30595_rtl_submenu()
|
||||
{
|
||||
LayoutDirectionSaver directionSaver(Qt::RightToLeft);
|
||||
QMenu menu("Test Menu");
|
||||
menu.setLayoutDirection(Qt::RightToLeft);
|
||||
QMenu sub("&sub");
|
||||
sub.addAction("bar");
|
||||
sub.setTitle("&sub");
|
||||
|
|
|
|||
Loading…
Reference in New Issue