QWizard/Win: Support RTL layout in Aero style

Task-number: QTBUG-30462
Change-Id: Ie6b3ba4975542a9d92611eb9a8547215e41d3c2c
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Ahmed Saidi <justroftest@gmail.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
Ahmed Saidi 2013-04-04 12:27:24 +00:00 committed by The Qt Project
parent 47a9f80dc1
commit 6f0dc9f4c7
2 changed files with 25 additions and 3 deletions

View File

@ -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

View File

@ -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);