From 6f0dc9f4c7c1405bdbfef32395d0fb091bb0c8c8 Mon Sep 17 00:00:00 2001 From: Ahmed Saidi Date: Thu, 4 Apr 2013 12:27:24 +0000 Subject: QWizard/Win: Support RTL layout in Aero style Task-number: QTBUG-30462 Change-Id: Ie6b3ba4975542a9d92611eb9a8547215e41d3c2c Reviewed-by: Konstantin Ritt Reviewed-by: Ahmed Saidi Reviewed-by: Friedemann Kleint --- src/widgets/dialogs/qwizard.cpp | 10 ++++++++++ src/widgets/dialogs/qwizard_win.cpp | 18 +++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index 72283451d7..b7a91a3d4b 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -3131,6 +3131,16 @@ bool QWizard::event(QEvent *event) d->handleAeroStyleChange(); } else if (d->isVistaThemeEnabled()) { + if (event->type() == QEvent::Resize + || event->type() == QEvent::LayoutDirectionChange) { + const int buttonLeft = (layoutDirection() == Qt::RightToLeft + ? width() - d->vistaHelper->backButton()->sizeHint().width() + : 0); + + d->vistaHelper->backButton()->move(buttonLeft, + d->vistaHelper->backButton()->y()); + } + d->vistaHelper->mouseEvent(event); } #endif diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp index 001c21da61..b57614c018 100644 --- a/src/widgets/dialogs/qwizard_win.cpp +++ b/src/widgets/dialogs/qwizard_win.cpp @@ -240,7 +240,11 @@ void QVistaBackButton::paintEvent(QPaintEvent *) else if (underMouse()) state = WIZ_NAV_BB_HOT; - pDrawThemeBackground(theme, hdc, WIZ_NAV_BACKBUTTON, state, &clipRect, &clipRect); + WIZ_NAVIGATIONPARTS buttonType = (layoutDirection() == Qt::LeftToRight + ? WIZ_NAV_BACKBUTTON + : WIZ_NAV_FORWARDBUTTON); + + pDrawThemeBackground(theme, hdc, buttonType, state, &clipRect, &clipRect); } /****************************************************************************** @@ -385,7 +389,11 @@ void QVistaHelper::drawTitleBar(QPainter *painter) glowOffset = glowSize(); } - const QRect textRectangle(titleOffset() - glowOffset, verticalCenter - textHeight / 2, textWidth, textHeight); + const int titleLeft = (wizard->layoutDirection() == Qt::LeftToRight + ? titleOffset() - glowOffset + : wizard->width() - titleOffset() - textWidth + glowOffset); + + const QRect textRectangle(titleLeft, verticalCenter - textHeight / 2, textWidth, textHeight); if (isWindow) { drawTitleText(painter, text, textRectangle, hdc); } else { @@ -397,7 +405,11 @@ void QVistaHelper::drawTitleBar(QPainter *painter) const QIcon windowIcon = wizard->windowIcon(); if (!windowIcon.isNull()) { - const QRect rect(origin.x() + leftMargin(), + const int iconLeft = (wizard->layoutDirection() == Qt::LeftToRight + ? leftMargin() + : wizard->width() - leftMargin() - iconSize()); + + const QRect rect(origin.x() + iconLeft, origin.y() + verticalCenter - iconSize() / 2, iconSize(), iconSize()); const HICON hIcon = qt_pixmapToWinHICON(windowIcon.pixmap(iconSize())); DrawIconEx(hdc, rect.left(), rect.top(), hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT); -- cgit v1.2.3