An RTL submenu should be right-aligned
Task-number: QTBUG-30595 Change-Id: Iac54cae70b5a2ac6be5a750279fb390bb158776a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
parent
7c791171a1
commit
4c7881396e
@ -1967,8 +1967,8 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
|
||||
pos.setX(mouse.x() - size.width());
|
||||
|
||||
#ifndef QT_NO_MENUBAR
|
||||
// if in a menubar, it should be right-aligned
|
||||
if (qobject_cast<QMenuBar*>(d->causedPopup.widget))
|
||||
// if the menu is in a menubar or is a submenu, it should be right-aligned
|
||||
if (qobject_cast<QMenuBar*>(d->causedPopup.widget) || qobject_cast<QMenu*>(d->causedPopup.widget))
|
||||
pos.rx() -= size.width();
|
||||
#endif //QT_NO_MENUBAR
|
||||
|
||||
|
@ -101,6 +101,7 @@ private slots:
|
||||
void pushButtonPopulateOnAboutToShow();
|
||||
void QTBUG7907_submenus_autoselect();
|
||||
void QTBUG7411_submenus_activate();
|
||||
void QTBUG30595_rtl_submenu();
|
||||
void QTBUG20403_nested_popup_on_shortcut_trigger();
|
||||
void QTBUG_10735_crashWithDialog();
|
||||
protected slots:
|
||||
@ -896,6 +897,41 @@ 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");
|
||||
QMenu sub("&sub");
|
||||
sub.addAction("bar");
|
||||
sub.setTitle("&sub");
|
||||
menu.addMenu(&sub);
|
||||
menu.move(200, 20);
|
||||
menu.show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(&menu));
|
||||
QTest::mouseClick(&menu, Qt::LeftButton, Qt::NoModifier, QPoint(5,5) );
|
||||
QTRY_VERIFY(sub.isVisible());
|
||||
QVERIFY(sub.pos().x() < menu.pos().x());
|
||||
}
|
||||
|
||||
void tst_QMenu::QTBUG20403_nested_popup_on_shortcut_trigger()
|
||||
{
|
||||
QMenu menu("Test Menu");
|
||||
|
Loading…
Reference in New Issue
Block a user