diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2009-08-25 11:33:15 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2009-08-25 11:34:13 (GMT) |
commit | f384dd306c022aa70015133be3a7b4d4c8bb1121 (patch) | |
tree | 704187f228bb2f7dbc76c9d72ae51e65388cc853 /src/gui/widgets | |
parent | f8acf3b9a9398eabef98be7007fd6766574a788a (diff) | |
download | Qt-f384dd306c022aa70015133be3a7b4d4c8bb1121.zip Qt-f384dd306c022aa70015133be3a7b4d4c8bb1121.tar.gz Qt-f384dd306c022aa70015133be3a7b4d4c8bb1121.tar.bz2 |
Make sure we use layoutDirection from the widget and not always the app
Task-number: 259331
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/qcommandlinkbutton.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/qdatetimeedit.cpp | 1 | ||||
-rw-r--r-- | src/gui/widgets/qdatetimeedit_p.h | 1 | ||||
-rw-r--r-- | src/gui/widgets/qmainwindowlayout.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/qmenu.cpp | 6 | ||||
-rw-r--r-- | src/gui/widgets/qmenubar.cpp | 8 | ||||
-rw-r--r-- | src/gui/widgets/qtoolbar.cpp | 8 | ||||
-rw-r--r-- | src/gui/widgets/qtoolbarextension.cpp | 6 |
8 files changed, 19 insertions, 17 deletions
diff --git a/src/gui/widgets/qcommandlinkbutton.cpp b/src/gui/widgets/qcommandlinkbutton.cpp index 206221f..fd69f55 100644 --- a/src/gui/widgets/qcommandlinkbutton.cpp +++ b/src/gui/widgets/qcommandlinkbutton.cpp @@ -205,7 +205,9 @@ void QCommandLinkButtonPrivate::init() q->setSizePolicy(policy); q->setIconSize(QSize(20, 20)); - q->setIcon(q->style()->standardIcon(QStyle::SP_CommandLink)); + QStyleOptionButton opt; + q->initStyleOption(&opt); + q->setIcon(q->style()->standardIcon(QStyle::SP_CommandLink, &opt)); } // Calculates the height of the description text based on widget width diff --git a/src/gui/widgets/qdatetimeedit.cpp b/src/gui/widgets/qdatetimeedit.cpp index 5a9c7e1..d1ebdf4 100644 --- a/src/gui/widgets/qdatetimeedit.cpp +++ b/src/gui/widgets/qdatetimeedit.cpp @@ -1643,7 +1643,6 @@ QDateTimeEditPrivate::QDateTimeEditPrivate() cachedDay = -1; currentSectionIndex = FirstSectionIndex; - layoutDirection = QApplication::layoutDirection(); first.type = FirstSection; last.type = LastSection; none.type = NoSection; diff --git a/src/gui/widgets/qdatetimeedit_p.h b/src/gui/widgets/qdatetimeedit_p.h index 7b29e51..33c09c0 100644 --- a/src/gui/widgets/qdatetimeedit_p.h +++ b/src/gui/widgets/qdatetimeedit_p.h @@ -132,7 +132,6 @@ public: mutable bool cacheGuard; QString defaultDateFormat, defaultTimeFormat, defaultDateTimeFormat, unreversedFormat; - Qt::LayoutDirection layoutDirection; mutable QVariant conflictGuard; bool hasHadFocus, formatExplicitlySet, calendarPopup; QStyle::StateFlag arrowState; diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp index 529a225..0ea9b56 100644 --- a/src/gui/widgets/qmainwindowlayout.cpp +++ b/src/gui/widgets/qmainwindowlayout.cpp @@ -1463,7 +1463,7 @@ void QMainWindowLayout::setGeometry(const QRect &_r) QSize(r.width(), statusbar->heightForWidth(r.width())) .expandedTo(statusbar->minimumSize())); sbr.moveBottom(r.bottom()); - QRect vr = QStyle::visualRect(QApplication::layoutDirection(), _r, sbr); + QRect vr = QStyle::visualRect(parentWidget()->layoutDirection(), _r, sbr); statusbar->setGeometry(vr); r.setBottom(sbr.top() - 1); } diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 92d1271..f0f425f 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -1832,7 +1832,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) if (adjustToDesktop) { //handle popup falling "off screen" - if (QApplication::layoutDirection() == Qt::RightToLeft) { + if (isRightToLeft()) { if(snapToMouse) //position flowing left from the mouse pos.setX(mouse.x()-size.width()); @@ -1870,9 +1870,9 @@ void QMenu::popup(const QPoint &p, QAction *atAction) } setGeometry(QRect(pos, size)); #ifndef QT_NO_EFFECTS - int hGuess = QApplication::layoutDirection() == Qt::RightToLeft ? QEffects::LeftScroll : QEffects::RightScroll; + int hGuess = isRightToLeft() ? QEffects::LeftScroll : QEffects::RightScroll; int vGuess = QEffects::DownScroll; - if (QApplication::layoutDirection() == Qt::RightToLeft) { + if (isRightToLeft()) { if ((snapToMouse && (pos.x() + size.width()/2 > mouse.x())) || (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width()/2 > d->causedPopup.widget->x())) hGuess = QEffects::RightScroll; diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index 0967f71..6633f2a 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -132,7 +132,7 @@ QRect QMenuBarPrivate::menuRect(bool extVisible) const result.adjust(hmargin, 0, -hmargin, 0); if (extVisible) { - if (q->layoutDirection() == Qt::RightToLeft) + if (q->isRightToLeft()) result.setLeft(result.left() + extension->sizeHint().width()); else result.setWidth(result.width() - extension->sizeHint().width()); @@ -140,7 +140,7 @@ QRect QMenuBarPrivate::menuRect(bool extVisible) const if (leftWidget && leftWidget->isVisible()) { QSize sz = leftWidget->sizeHint(); - if (q->layoutDirection() == Qt::RightToLeft) + if (q->isRightToLeft()) result.setRight(result.right() - sz.width()); else result.setLeft(result.left() + sz.width()); @@ -148,7 +148,7 @@ QRect QMenuBarPrivate::menuRect(bool extVisible) const if (rightWidget && rightWidget->isVisible()) { QSize sz = rightWidget->sizeHint(); - if (q->layoutDirection() == Qt::RightToLeft) + if (q->isRightToLeft()) result.setLeft(result.left() + sz.width()); else result.setRight(result.right() - sz.width()); @@ -245,7 +245,7 @@ void QMenuBarPrivate::updateGeometries() pop->addActions(hiddenActions); int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q); - int x = q->layoutDirection() == Qt::RightToLeft + int x = q->isRightToLeft() ? menuRect.left() - extension->sizeHint().width() + 1 : menuRect.right(); extension->setGeometry(x, vmargin, extension->sizeHint().width(), menuRect.height() - vmargin*2); diff --git a/src/gui/widgets/qtoolbar.cpp b/src/gui/widgets/qtoolbar.cpp index ef0847b..bf44ea1 100644 --- a/src/gui/widgets/qtoolbar.cpp +++ b/src/gui/widgets/qtoolbar.cpp @@ -205,7 +205,7 @@ void QToolBarPrivate::initDrag(const QPoint &pos) state->moving = false; state->widgetItem = 0; - if (q->layoutDirection() == Qt::RightToLeft) + if (q->isRightToLeft()) state->pressPos = QPoint(q->width() - state->pressPos.x(), state->pressPos.y()); } @@ -359,7 +359,7 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event) QPoint pos = event->globalPos(); // if we are right-to-left, we move so as to keep the right edge the same distance // from the mouse - if (q->layoutDirection() == Qt::LeftToRight) + if (q->isLeftToRight()) pos -= state->pressPos; else pos += QPoint(state->pressPos.x() - q->width(), -state->pressPos.y()); @@ -369,14 +369,14 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event) } else if (state->moving) { const QPoint rtl(q->width() - state->pressPos.x(), state->pressPos.y()); //for RTL - const QPoint globalPressPos = q->mapToGlobal(q->layoutDirection() == Qt::RightToLeft ? rtl : state->pressPos); + const QPoint globalPressPos = q->mapToGlobal(q->isRightToLeft() ? rtl : state->pressPos); int pos = 0; QPoint delta = event->globalPos() - globalPressPos; if (orientation == Qt::Vertical) { pos = q->y() + delta.y(); } else { - if (q->layoutDirection() == Qt::RightToLeft) { + if (q->isRightToLeft()) { pos = win->width() - q->width() - q->x() - delta.x(); } else { pos = q->x() + delta.x(); diff --git a/src/gui/widgets/qtoolbarextension.cpp b/src/gui/widgets/qtoolbarextension.cpp index 1f1186c..6a70326 100644 --- a/src/gui/widgets/qtoolbarextension.cpp +++ b/src/gui/widgets/qtoolbarextension.cpp @@ -61,10 +61,12 @@ QToolBarExtension::QToolBarExtension(QWidget *parent) void QToolBarExtension::setOrientation(Qt::Orientation o) { + QStyleOption opt; + opt.init(this); if (o == Qt::Horizontal) { - setIcon(style()->standardIcon(QStyle::SP_ToolBarHorizontalExtensionButton)); + setIcon(style()->standardIcon(QStyle::SP_ToolBarHorizontalExtensionButton, &opt)); } else { - setIcon(style()->standardIcon(QStyle::SP_ToolBarVerticalExtensionButton)); + setIcon(style()->standardIcon(QStyle::SP_ToolBarVerticalExtensionButton, &opt)); } } |