diff options
author | vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f> | 2019-02-11 16:40:49 +0000 |
---|---|---|
committer | vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f> | 2019-02-11 16:40:49 +0000 |
commit | a35f10674c463febaa32147eeb641032616669fc (patch) | |
tree | fb727ee3bc8a2d7af47b30e6835f07c555c36b2b /src/VBox/Frontends | |
parent | 7a24f6e1b84d9e5d841acb87937c055a8fe21f79 (diff) | |
download | VirtualBox-svn-a35f10674c463febaa32147eeb641032616669fc.tar.gz |
FE/Qt: bugref:9373: macOS: No buttons for UIGraphicsScrollBar on macOS, it's not a part of style there.
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@77268 cfe28804-0f27-0410-a406-dd0f0b0b656f
Diffstat (limited to 'src/VBox/Frontends')
-rw-r--r-- | src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsScrollBar.cpp | 62 |
1 files changed, 50 insertions, 12 deletions
diff --git a/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsScrollBar.cpp b/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsScrollBar.cpp index ec586040ee0..94290c86e6e 100644 --- a/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsScrollBar.cpp +++ b/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsScrollBar.cpp @@ -389,8 +389,13 @@ void UIGraphicsScrollBar::sltTokenMoved(const QPointF &pos) case Qt::Horizontal: { /* We have to calculate the X coord of the token, leaving Y untouched: */ +#ifdef VBOX_WS_MAC + const int iMin = 0; + const int iMax = size().width() - m_iExtent; +#else const int iMin = m_iExtent; const int iMax = size().width() - 2 * m_iExtent; +#endif int iX = pos.x() - m_iExtent / 2; iX = qMax(iX, iMin); iX = qMin(iX, iMax); @@ -401,8 +406,13 @@ void UIGraphicsScrollBar::sltTokenMoved(const QPointF &pos) case Qt::Vertical: { /* We have to calculate the Y coord of the token, leaving X untouched: */ +#ifdef VBOX_WS_MAC + const int iMin = 0; + const int iMax = size().height() - m_iExtent; +#else const int iMin = m_iExtent; const int iMax = size().height() - 2 * m_iExtent; +#endif int iY = pos.y() - m_iExtent / 2; iY = qMax(iY, iMin); iY = qMin(iY, iMax); @@ -420,30 +430,42 @@ void UIGraphicsScrollBar::sltTokenMoved(const QPointF &pos) void UIGraphicsScrollBar::sltStateLeftDefault() { - m_pButton1->hide(); - m_pButton2->hide(); - m_pToken->hide(); + if (m_pButton1) + m_pButton1->hide(); + if (m_pButton2) + m_pButton2->hide(); + if (m_pToken) + m_pToken->hide(); } void UIGraphicsScrollBar::sltStateLeftHovered() { - m_pButton1->hide(); - m_pButton2->hide(); - m_pToken->hide(); + if (m_pButton1) + m_pButton1->hide(); + if (m_pButton2) + m_pButton2->hide(); + if (m_pToken) + m_pToken->hide(); } void UIGraphicsScrollBar::sltStateEnteredDefault() { - m_pButton1->hide(); - m_pButton2->hide(); - m_pToken->hide(); + if (m_pButton1) + m_pButton1->hide(); + if (m_pButton2) + m_pButton2->hide(); + if (m_pToken) + m_pToken->hide(); } void UIGraphicsScrollBar::sltStateEnteredHovered() { - m_pButton1->show(); - m_pButton2->show(); - m_pToken->show(); + if (m_pButton1) + m_pButton1->show(); + if (m_pButton2) + m_pButton2->show(); + if (m_pToken) + m_pToken->show(); } void UIGraphicsScrollBar::prepare() @@ -468,6 +490,7 @@ void UIGraphicsScrollBar::prepareWidgets() void UIGraphicsScrollBar::prepareButtons() { +#ifndef VBOX_WS_MAC /* Create buttons depending on orientation: */ switch (m_enmOrientation) { @@ -503,6 +526,7 @@ void UIGraphicsScrollBar::prepareButtons() connect(m_pButton2, &UIGraphicsButton::sigButtonClicked, this, &UIGraphicsScrollBar::sltButton2Clicked); } +#endif } void UIGraphicsScrollBar::prepareToken() @@ -590,8 +614,10 @@ void UIGraphicsScrollBar::updateExtent() { /* Make sure extent value is not smaller than the button size: */ m_iExtent = QApplication::style()->pixelMetric(QStyle::PM_ScrollBarExtent); +#ifndef VBOX_WS_MAC m_iExtent = qMax(m_iExtent, (int)m_pButton1->minimumSizeHint().width()); m_iExtent = qMax(m_iExtent, (int)m_pButton2->minimumSizeHint().width()); +#endif updateGeometry(); } @@ -603,6 +629,7 @@ void UIGraphicsScrollBar::layoutWidgets() void UIGraphicsScrollBar::layoutButtons() { +#ifndef VBOX_WS_MAC // WORKAROUND: // We are calculating proper button shift delta, because // button size can be smaller than scroll-bar extent value. @@ -616,6 +643,7 @@ void UIGraphicsScrollBar::layoutButtons() if (m_iExtent > m_pButton2->minimumSizeHint().width()) iDelta2 = (m_iExtent - m_pButton2->minimumSizeHint().width() + 1) / 2; m_pButton2->setPos(size().width() - m_iExtent + iDelta2, size().height() - m_iExtent + iDelta2); +#endif } void UIGraphicsScrollBar::layoutToken() @@ -637,8 +665,13 @@ QPoint UIGraphicsScrollBar::actualTokenPosition() const case Qt::Horizontal: { /* We have to adjust the X coord of the token, leaving Y unchanged: */ +#ifdef VBOX_WS_MAC + const int iMin = 0; + const int iMax = size().width() - m_iExtent; +#else const int iMin = m_iExtent; const int iMax = size().width() - 2 * m_iExtent; +#endif int iX = dRatio * (iMax - iMin) + iMin; position = QPoint(iX, 0); break; @@ -646,8 +679,13 @@ QPoint UIGraphicsScrollBar::actualTokenPosition() const case Qt::Vertical: { /* We have to adjust the Y coord of the token, leaving X unchanged: */ +#ifdef VBOX_WS_MAC + const int iMin = 0; + const int iMax = size().height() - m_iExtent; +#else const int iMin = m_iExtent; const int iMax = size().height() - 2 * m_iExtent; +#endif int iY = dRatio * (iMax - iMin) + iMin; position = QPoint(0, iY); break; |