[Libreoffice-commits] core.git: vcl/inc vcl/qt5
Jan-Marek Glogowski (via logerrit)
logerrit at kemper.freedesktop.org
Mon Mar 2 12:02:58 UTC 2020
vcl/inc/qt5/Qt5Frame.hxx | 2
vcl/inc/qt5/Qt5Graphics.hxx | 2
vcl/inc/qt5/Qt5Graphics_Controls.hxx | 22 ++++
vcl/qt5/Qt5Frame.cxx | 19 ---
vcl/qt5/Qt5Graphics.cxx | 1
vcl/qt5/Qt5Graphics_Controls.cxx | 174 ++++++++++++++++-------------------
6 files changed, 107 insertions(+), 113 deletions(-)
New commits:
commit 7c6c9951d3be0af11099f78462f7dfc8772df963
Author: Jan-Marek Glogowski <jan-marek.glogowski at extern.cib.de>
AuthorDate: Sat Feb 29 12:43:32 2020 +0100
Commit: Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Mon Mar 2 13:02:24 2020 +0100
Qt5 some refactoring for HiDPI merge
This is a preparatory patch for merging the initial fix for
tdf#127687, the Qt5 HiDPI scaling support, and generally to make
the style handling code a little bit more readable.
It includes:
* Moving all lcl_ Qt5Graphics_Controls functions into the class as
private functions without lcl_ prefix.
* Add three additional helpers - pixelMetric, sizeFromContents and
subControlRect - to cut down boilerplate QApplication::style()->
prefixes for the style calls everywhere.
* Drop the superfluous Qt5Frame::TriggerPaintEvent functions.
* Drop the single, broken maGeometry.nTopDecoration filling.
* Split some very long lines of nested call code by using some
intermediate variables.
* Move a Qt5Data include from hxx into cpp
Change-Id: Iae1bfafd14c4163447f3d55e2307f0f617e68a0e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89751
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>
diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index b5eea5b15b1e..5a88221565a3 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -132,8 +132,6 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : public QObject, public SalFrame
bool isMaximized() const;
void SetWindowStateImpl(Qt::WindowStates eState);
- void TriggerPaintEvent();
- void TriggerPaintEvent(QRect aRect);
void fixICCCMwindowGroup();
public:
diff --git a/vcl/inc/qt5/Qt5Graphics.hxx b/vcl/inc/qt5/Qt5Graphics.hxx
index a17421b2f65d..c36d22267fd2 100644
--- a/vcl/inc/qt5/Qt5Graphics.hxx
+++ b/vcl/inc/qt5/Qt5Graphics.hxx
@@ -27,8 +27,6 @@
#include <QtGui/QPainterPath>
#include <QtGui/QRegion>
-#include "Qt5Data.hxx"
-
class PhysicalFontCollection;
class QImage;
class QPushButton;
diff --git a/vcl/inc/qt5/Qt5Graphics_Controls.hxx b/vcl/inc/qt5/Qt5Graphics_Controls.hxx
index da1af4dc066b..f70804cea844 100644
--- a/vcl/inc/qt5/Qt5Graphics_Controls.hxx
+++ b/vcl/inc/qt5/Qt5Graphics_Controls.hxx
@@ -28,6 +28,8 @@
#include <QtGui/QPainter>
#include <QtGui/QRegion>
#include <QtWidgets/QPushButton>
+#include <QtWidgets/QStyle>
+#include <QtWidgets/QStyleOption>
class Qt5Graphics_Controls final : public vcl::WidgetDrawInterface
{
@@ -51,6 +53,26 @@ public:
const ImplControlValue& aValue, const OUString& aCaption,
tools::Rectangle& rNativeBoundingRegion,
tools::Rectangle& rNativeContentRegion) override;
+
+private:
+ static int pixelMetric(QStyle::PixelMetric metric, const QStyleOption* option = nullptr);
+ static QSize sizeFromContents(QStyle::ContentsType type, const QStyleOption* option,
+ const QSize& contentsSize);
+ static QRect subControlRect(QStyle::ComplexControl control, const QStyleOptionComplex* option,
+ QStyle::SubControl subControl);
+
+ static void draw(QStyle::ControlElement element, QStyleOption* option, QImage* image,
+ QStyle::State const state = QStyle::State_None, QRect rect = QRect());
+ static void draw(QStyle::PrimitiveElement element, QStyleOption* option, QImage* image,
+ QStyle::State const state = QStyle::State_None, QRect rect = QRect());
+ static void draw(QStyle::ComplexControl element, QStyleOptionComplex* option, QImage* image,
+ QStyle::State const state = QStyle::State_None);
+ static void drawFrame(QStyle::PrimitiveElement element, QImage* image,
+ QStyle::State const& state, bool bClip = true,
+ QStyle::PixelMetric eLineMetric = QStyle::PM_DefaultFrameWidth);
+
+ static void fillQStyleOptionTab(const ImplControlValue& value, QStyleOptionTab& sot);
+ static void fullQStyleOptionTabWidgetFrame(QStyleOptionTabWidgetFrame& option);
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 2f6738485fb0..8f1594240f46 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -287,19 +287,6 @@ void Qt5Frame::Damage(sal_Int32 nExtentsX, sal_Int32 nExtentsY, sal_Int32 nExten
m_pQWidget->update(nExtentsX, nExtentsY, nExtentsWidth, nExtentsHeight);
}
-void Qt5Frame::TriggerPaintEvent()
-{
- QSize aSize(m_pQWidget->size());
- SalPaintEvent aPaintEvt(0, 0, aSize.width(), aSize.height(), true);
- CallCallback(SalEvent::Paint, &aPaintEvt);
-}
-
-void Qt5Frame::TriggerPaintEvent(QRect aRect)
-{
- SalPaintEvent aPaintEvt(aRect.x(), aRect.y(), aRect.width(), aRect.height(), true);
- CallCallback(SalEvent::Paint, &aPaintEvt);
-}
-
void Qt5Frame::InitQt5SvpGraphics(Qt5SvpGraphics* pQt5SvpGraphics)
{
int width = 640;
@@ -684,12 +671,6 @@ bool Qt5Frame::GetWindowState(SalFrameState* pState)
pState->mnY = rect.y();
pState->mnWidth = rect.width();
pState->mnHeight = rect.height();
- // the menubar is drawn natively, adjust for that
- if (maGeometry.nTopDecoration)
- {
- pState->mnY += maGeometry.nTopDecoration;
- pState->mnHeight -= maGeometry.nTopDecoration;
- }
pState->mnMask |= WindowStateMask::X | WindowStateMask::Y | WindowStateMask::Width
| WindowStateMask::Height;
}
diff --git a/vcl/qt5/Qt5Graphics.cxx b/vcl/qt5/Qt5Graphics.cxx
index 60054700596e..e9d57d2d86af 100644
--- a/vcl/qt5/Qt5Graphics.cxx
+++ b/vcl/qt5/Qt5Graphics.cxx
@@ -19,6 +19,7 @@
#include <Qt5Graphics.hxx>
+#include <Qt5Data.hxx>
#include <Qt5Font.hxx>
#include <Qt5Frame.hxx>
#include <Qt5Graphics_Controls.hxx>
diff --git a/vcl/qt5/Qt5Graphics_Controls.cxx b/vcl/qt5/Qt5Graphics_Controls.cxx
index ff8537764bd9..a6d8e6fa23e5 100644
--- a/vcl/qt5/Qt5Graphics_Controls.cxx
+++ b/vcl/qt5/Qt5Graphics_Controls.cxx
@@ -21,8 +21,6 @@
#include <QtGui/QPainter>
#include <QtWidgets/QApplication>
-#include <QtWidgets/QStyle>
-#include <QtWidgets/QStyleOption>
#include <QtWidgets/QFrame>
#include <QtWidgets/QLabel>
@@ -116,10 +114,27 @@ bool Qt5Graphics_Controls::isNativeControlSupported(ControlType type, ControlPar
return false;
}
-namespace
+inline int Qt5Graphics_Controls::pixelMetric(QStyle::PixelMetric metric, const QStyleOption* option)
{
-void draw(QStyle::ControlElement element, QStyleOption* option, QImage* image,
- QStyle::State const state = QStyle::State_None, QRect rect = QRect())
+ return QApplication::style()->pixelMetric(metric, option);
+}
+
+inline QSize Qt5Graphics_Controls::sizeFromContents(QStyle::ContentsType type,
+ const QStyleOption* option,
+ const QSize& contentsSize)
+{
+ return QApplication::style()->sizeFromContents(type, option, contentsSize);
+}
+
+inline QRect Qt5Graphics_Controls::subControlRect(QStyle::ComplexControl control,
+ const QStyleOptionComplex* option,
+ QStyle::SubControl subControl)
+{
+ return QApplication::style()->subControlRect(control, option, subControl);
+}
+
+void Qt5Graphics_Controls::draw(QStyle::ControlElement element, QStyleOption* option, QImage* image,
+ QStyle::State const state, QRect rect)
{
option->state |= state;
option->rect = !rect.isNull() ? rect : image->rect();
@@ -128,8 +143,8 @@ void draw(QStyle::ControlElement element, QStyleOption* option, QImage* image,
QApplication::style()->drawControl(element, option, &painter);
}
-void draw(QStyle::PrimitiveElement element, QStyleOption* option, QImage* image,
- QStyle::State const state = QStyle::State_None, QRect rect = QRect())
+void Qt5Graphics_Controls::draw(QStyle::PrimitiveElement element, QStyleOption* option,
+ QImage* image, QStyle::State const state, QRect rect)
{
option->state |= state;
option->rect = !rect.isNull() ? rect : image->rect();
@@ -138,8 +153,8 @@ void draw(QStyle::PrimitiveElement element, QStyleOption* option, QImage* image,
QApplication::style()->drawPrimitive(element, option, &painter);
}
-void draw(QStyle::ComplexControl element, QStyleOptionComplex* option, QImage* image,
- QStyle::State const state = QStyle::State_None)
+void Qt5Graphics_Controls::draw(QStyle::ComplexControl element, QStyleOptionComplex* option,
+ QImage* image, QStyle::State const state)
{
option->state |= state;
option->rect = image->rect();
@@ -148,11 +163,11 @@ void draw(QStyle::ComplexControl element, QStyleOptionComplex* option, QImage* i
QApplication::style()->drawComplexControl(element, option, &painter);
}
-void lcl_drawFrame(QStyle::PrimitiveElement element, QImage* image, QStyle::State const& state,
- bool bClip = true,
- QStyle::PixelMetric eLineMetric = QStyle::PM_DefaultFrameWidth)
+void Qt5Graphics_Controls::drawFrame(QStyle::PrimitiveElement element, QImage* image,
+ QStyle::State const& state, bool bClip,
+ QStyle::PixelMetric eLineMetric)
{
- const int fw = QApplication::style()->pixelMetric(eLineMetric);
+ const int fw = pixelMetric(eLineMetric);
QStyleOptionFrame option;
option.frameShape = QFrame::StyledPanel;
option.state = QStyle::State_Sunken | state;
@@ -167,7 +182,7 @@ void lcl_drawFrame(QStyle::PrimitiveElement element, QImage* image, QStyle::Stat
QApplication::style()->drawPrimitive(element, &option, &painter);
}
-void lcl_fillQStyleOptionTab(const ImplControlValue& value, QStyleOptionTab& sot)
+void Qt5Graphics_Controls::fillQStyleOptionTab(const ImplControlValue& value, QStyleOptionTab& sot)
{
const TabitemValue& rValue = static_cast<const TabitemValue&>(value);
if (rValue.isFirst())
@@ -178,16 +193,15 @@ void lcl_fillQStyleOptionTab(const ImplControlValue& value, QStyleOptionTab& sot
sot.position = QStyleOptionTab::Middle;
}
-void lcl_fullQStyleOptionTabWidgetFrame(QStyleOptionTabWidgetFrame& option)
+void Qt5Graphics_Controls::fullQStyleOptionTabWidgetFrame(QStyleOptionTabWidgetFrame& option)
{
option.state = QStyle::State_Enabled;
option.rightCornerWidgetSize = QSize(0, 0);
option.leftCornerWidgetSize = QSize(0, 0);
- option.lineWidth = QApplication::style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
+ option.lineWidth = pixelMetric(QStyle::PM_DefaultFrameWidth);
option.midLineWidth = 0;
option.shape = QTabBar::RoundedNorth;
}
-}
bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part,
const tools::Rectangle& rControlRegion,
@@ -310,8 +324,7 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part,
// with at least Plastique style, so clip only to the separator itself
// (QSize( 2, 2 ) is hardcoded in Qt)
option.rect = m_image->rect();
- QSize size = QApplication::style()->sizeFromContents(QStyle::CT_MenuItem, &option,
- QSize(2, 2));
+ QSize size = sizeFromContents(QStyle::CT_MenuItem, &option, QSize(2, 2));
QRect rect = m_image->rect();
QPoint center = rect.center();
rect.setHeight(size.height());
@@ -321,7 +334,7 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part,
QPainter painter(m_image.get());
// don't paint over popup frame border (like the hack above, but here it can be simpler)
- const int fw = QApplication::style()->pixelMetric(QStyle::PM_MenuPanelWidth);
+ const int fw = pixelMetric(QStyle::PM_MenuPanelWidth);
painter.setClipRect(rect.adjusted(fw, 0, -fw, 0));
QApplication::style()->drawControl(QStyle::CE_MenuItem, &option, &painter);
}
@@ -342,7 +355,7 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part,
QRect rect(menuItemRect.topLeft() - widgetRect.topLeft(),
widgetRect.size().expandedTo(menuItemRect.size()));
// checkboxes are always displayed next to images in menus, so are never centered
- const int focus_size = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin);
+ const int focus_size = pixelMetric(QStyle::PM_FocusFrameHMargin);
rect.moveTo(-focus_size, rect.y());
draw(QStyle::CE_MenuItem, &option, m_image.get(),
vclStateValue2StateFlag(nControlState & ~ControlState::PRESSED, value), rect);
@@ -382,7 +395,7 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part,
&& (part == ControlPart::ThumbVert || part == ControlPart::ThumbHorz))
{
// reduce paint area only to the handle area
- const int handleExtend = QApplication::style()->pixelMetric(QStyle::PM_ToolBarHandleExtent);
+ const int handleExtend = pixelMetric(QStyle::PM_ToolBarHandleExtent);
QStyleOption option;
QRect aRect = m_image->rect();
if (part == ControlPart::ThumbVert)
@@ -397,8 +410,8 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part,
}
else if (type == ControlType::Editbox || type == ControlType::MultilineEditbox)
{
- lcl_drawFrame(QStyle::PE_FrameLineEdit, m_image.get(),
- vclStateValue2StateFlag(nControlState, value), false);
+ drawFrame(QStyle::PE_FrameLineEdit, m_image.get(),
+ vclStateValue2StateFlag(nControlState, value), false);
}
else if (type == ControlType::Combobox)
{
@@ -414,9 +427,9 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part,
switch (part)
{
case ControlPart::ListboxWindow:
- lcl_drawFrame(QStyle::PE_Frame, m_image.get(),
- vclStateValue2StateFlag(nControlState, value), true,
- QStyle::PM_ComboBoxFrameWidth);
+ drawFrame(QStyle::PE_Frame, m_image.get(),
+ vclStateValue2StateFlag(nControlState, value), true,
+ QStyle::PM_ComboBoxFrameWidth);
break;
case ControlPart::SubEdit:
draw(QStyle::CE_ComboBoxLabel, &option, m_image.get(),
@@ -568,8 +581,7 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part,
}
else if (type == ControlType::Frame)
{
- lcl_drawFrame(QStyle::PE_Frame, m_image.get(),
- vclStateValue2StateFlag(nControlState, value));
+ drawFrame(QStyle::PE_Frame, m_image.get(), vclStateValue2StateFlag(nControlState, value));
}
else if (type == ControlType::WindowBackground)
{
@@ -617,7 +629,7 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part,
else if (type == ControlType::TabItem && part == ControlPart::Entire)
{
QStyleOptionTab sot;
- lcl_fillQStyleOptionTab(value, sot);
+ fillQStyleOptionTab(value, sot);
draw(QStyle::CE_TabBarTabShape, &sot, m_image.get(),
vclStateValue2StateFlag(nControlState, value));
}
@@ -628,11 +640,10 @@ bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part,
// get the overlap size for the tabs, so they will overlap the frame
QStyleOptionTab tabOverlap;
tabOverlap.shape = QTabBar::RoundedNorth;
- TabPaneValue::m_nOverlap
- = QApplication::style()->pixelMetric(QStyle::PM_TabBarBaseOverlap, &tabOverlap);
+ TabPaneValue::m_nOverlap = pixelMetric(QStyle::PM_TabBarBaseOverlap, &tabOverlap);
QStyleOptionTabWidgetFrame option;
- lcl_fullQStyleOptionTabWidgetFrame(option);
+ fullQStyleOptionTabWidgetFrame(option);
option.tabBarRect = toQRect(rValue.m_aTabHeaderRect);
option.selectedTabRect
= rValue.m_aSelectedTabRect.IsEmpty() ? QRect() : toQRect(rValue.m_aSelectedTabRect);
@@ -673,8 +684,7 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart
if (controlState & ControlState::DEFAULT)
{
- int size = QApplication::style()->pixelMetric(QStyle::PM_ButtonDefaultIndicator,
- &styleOption);
+ int size = pixelMetric(QStyle::PM_ButtonDefaultIndicator, &styleOption);
boundingRect.adjust(-size, -size, size, size);
retVal = true;
}
@@ -686,9 +696,8 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart
QStyleOptionFrame fo;
fo.frameShape = QFrame::StyledPanel;
fo.state = QStyle::State_Sunken;
- fo.lineWidth = QApplication::style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
- QSize aMinSize = QApplication::style()->sizeFromContents(QStyle::CT_LineEdit, &fo,
- contentRect.size());
+ fo.lineWidth = pixelMetric(QStyle::PM_DefaultFrameWidth);
+ QSize aMinSize = sizeFromContents(QStyle::CT_LineEdit, &fo, contentRect.size());
if (aMinSize.height() > boundingRect.height())
{
int nHeight = (aMinSize.height() - boundingRect.height()) / 2;
@@ -709,21 +718,15 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart
{
styleOption.state = vclStateValue2StateFlag(controlState, val);
- contentRect.setWidth(
- QApplication::style()->pixelMetric(QStyle::PM_IndicatorWidth, &styleOption));
- contentRect.setHeight(
- QApplication::style()->pixelMetric(QStyle::PM_IndicatorHeight, &styleOption));
+ int nWidth = pixelMetric(QStyle::PM_IndicatorWidth, &styleOption);
+ int nHeight = pixelMetric(QStyle::PM_IndicatorHeight, &styleOption);
+ contentRect.setSize({ nWidth, nHeight });
- contentRect.adjust(0, 0,
- 2
- * QApplication::style()->pixelMetric(
- QStyle::PM_FocusFrameHMargin, &styleOption),
- 2
- * QApplication::style()->pixelMetric(
- QStyle::PM_FocusFrameVMargin, &styleOption));
+ int nHMargin = pixelMetric(QStyle::PM_FocusFrameHMargin, &styleOption);
+ int nVMargin = pixelMetric(QStyle::PM_FocusFrameVMargin, &styleOption);
+ contentRect.adjust(0, 0, 2 * nHMargin, 2 * nVMargin);
boundingRect = contentRect;
-
retVal = true;
}
break;
@@ -743,8 +746,7 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart
// assume contents is a text line
int nHeight = QApplication::fontMetrics().height();
QSize aContentSize(contentRect.width(), nHeight);
- QSize aMinSize = QApplication::style()->sizeFromContents(QStyle::CT_ComboBox,
- &cbo, aContentSize);
+ QSize aMinSize = sizeFromContents(QStyle::CT_ComboBox, &cbo, aContentSize);
if (aMinSize.height() > contentRect.height())
contentRect.adjust(0, 0, 0, aMinSize.height() - contentRect.height());
boundingRect = contentRect;
@@ -752,15 +754,15 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart
break;
}
case ControlPart::ButtonDown:
- contentRect = QApplication::style()->subControlRect(QStyle::CC_ComboBox, &cbo,
- QStyle::SC_ComboBoxArrow);
+ contentRect
+ = subControlRect(QStyle::CC_ComboBox, &cbo, QStyle::SC_ComboBoxArrow);
contentRect.translate(boundingRect.left(), boundingRect.top());
retVal = true;
break;
case ControlPart::SubEdit:
{
- contentRect = QApplication::style()->subControlRect(
- QStyle::CC_ComboBox, &cbo, QStyle::SC_ComboBoxEditField);
+ contentRect
+ = subControlRect(QStyle::CC_ComboBox, &cbo, QStyle::SC_ComboBoxEditField);
contentRect.translate(boundingRect.left(), boundingRect.top());
retVal = true;
break;
@@ -784,8 +786,7 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart
{
int nHeight = QApplication::fontMetrics().height();
QSize aContentSize(contentRect.width(), nHeight);
- QSize aMinSize = QApplication::style()->sizeFromContents(QStyle::CT_SpinBox,
- &sbo, aContentSize);
+ QSize aMinSize = sizeFromContents(QStyle::CT_SpinBox, &sbo, aContentSize);
if (aMinSize.height() > contentRect.height())
contentRect.adjust(0, 0, 0, aMinSize.height() - contentRect.height());
boundingRect = contentRect;
@@ -793,24 +794,22 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart
break;
}
case ControlPart::ButtonUp:
- contentRect = QApplication::style()->subControlRect(QStyle::CC_SpinBox, &sbo,
- QStyle::SC_SpinBoxUp);
+ contentRect = subControlRect(QStyle::CC_SpinBox, &sbo, QStyle::SC_SpinBoxUp);
contentRect.translate(boundingRect.left(), boundingRect.top());
retVal = true;
boundingRect = QRect();
break;
case ControlPart::ButtonDown:
- contentRect = QApplication::style()->subControlRect(QStyle::CC_SpinBox, &sbo,
- QStyle::SC_SpinBoxDown);
+ contentRect = subControlRect(QStyle::CC_SpinBox, &sbo, QStyle::SC_SpinBoxDown);
retVal = true;
contentRect.translate(boundingRect.left(), boundingRect.top());
boundingRect = QRect();
break;
case ControlPart::SubEdit:
- contentRect = QApplication::style()->subControlRect(
- QStyle::CC_SpinBox, &sbo, QStyle::SC_SpinBoxEditField);
+ contentRect
+ = subControlRect(QStyle::CC_SpinBox, &sbo, QStyle::SC_SpinBoxEditField);
retVal = true;
contentRect.translate(boundingRect.left(), boundingRect.top());
break;
@@ -825,13 +824,13 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart
switch (part)
{
case ControlPart::MenuItemCheckMark:
- h = QApplication::style()->pixelMetric(QStyle::PM_IndicatorHeight);
- w = QApplication::style()->pixelMetric(QStyle::PM_IndicatorWidth);
+ h = pixelMetric(QStyle::PM_IndicatorHeight);
+ w = pixelMetric(QStyle::PM_IndicatorWidth);
retVal = true;
break;
case ControlPart::MenuItemRadioMark:
- h = QApplication::style()->pixelMetric(QStyle::PM_ExclusiveIndicatorHeight);
- w = QApplication::style()->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth);
+ h = pixelMetric(QStyle::PM_ExclusiveIndicatorHeight);
+ w = pixelMetric(QStyle::PM_ExclusiveIndicatorWidth);
retVal = true;
break;
default:
@@ -851,8 +850,7 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart
auto nStyle = static_cast<DrawFrameFlags>(val.getNumericVal() & 0xFFF0);
if (nStyle & DrawFrameFlags::NoDraw)
{
- const int nFrameWidth
- = QApplication::style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
+ const int nFrameWidth = pixelMetric(QStyle::PM_DefaultFrameWidth);
contentRect.adjust(nFrameWidth, nFrameWidth, -nFrameWidth, -nFrameWidth);
}
retVal = true;
@@ -861,14 +859,12 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart
}
case ControlType::Radiobutton:
{
- const int h = QApplication::style()->pixelMetric(QStyle::PM_ExclusiveIndicatorHeight);
- const int w = QApplication::style()->pixelMetric(QStyle::PM_ExclusiveIndicatorWidth);
+ const int h = pixelMetric(QStyle::PM_ExclusiveIndicatorHeight);
+ const int w = pixelMetric(QStyle::PM_ExclusiveIndicatorWidth);
contentRect = QRect(boundingRect.left(), boundingRect.top(), w, h);
- contentRect.adjust(
- 0, 0,
- 2 * QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin, &styleOption),
- 2 * QApplication::style()->pixelMetric(QStyle::PM_FocusFrameVMargin, &styleOption));
+ contentRect.adjust(0, 0, 2 * pixelMetric(QStyle::PM_FocusFrameHMargin, &styleOption),
+ 2 * pixelMetric(QStyle::PM_FocusFrameVMargin, &styleOption));
boundingRect = contentRect;
retVal = true;
@@ -876,7 +872,7 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart
}
case ControlType::Slider:
{
- const int w = QApplication::style()->pixelMetric(QStyle::PM_SliderLength);
+ const int w = pixelMetric(QStyle::PM_SliderLength);
if (part == ControlPart::ThumbHorz)
{
contentRect
@@ -895,7 +891,7 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart
}
case ControlType::Toolbar:
{
- const int nWorH = QApplication::style()->pixelMetric(QStyle::PM_ToolBarHandleExtent);
+ const int nWorH = pixelMetric(QStyle::PM_ToolBarHandleExtent);
if (part == ControlPart::ThumbHorz)
{
contentRect
@@ -934,13 +930,12 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart
// widget and screen coordinates the same. QStyle functions should use screen
// coordinates but at least QPlastiqueStyle::subControlRect() is buggy
// and sometimes uses widget coordinates.
- QRect rect = contentRect;
- rect.moveTo(0, 0);
- option.rect = rect;
- rect = QApplication::style()->subControlRect(QStyle::CC_ScrollBar, &option,
- QStyle::SC_ScrollBarGroove);
- rect.translate(contentRect.topLeft()); // reverse the workaround above
- contentRect = boundingRect = rect;
+ option.rect = QRect({ 0, 0 }, contentRect.size());
+ contentRect
+ = subControlRect(QStyle::CC_ScrollBar, &option, QStyle::SC_ScrollBarGroove);
+ contentRect.translate(contentRect.topLeft()); // reverse the workaround above
+
+ boundingRect = contentRect;
retVal = true;
}
break;
@@ -948,9 +943,8 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart
case ControlType::TabItem:
{
QStyleOptionTab sot;
- lcl_fillQStyleOptionTab(val, sot);
- QSize aMinSize = QApplication::style()->sizeFromContents(QStyle::CT_TabBarTab, &sot,
- contentRect.size());
+ fillQStyleOptionTab(val, sot);
+ QSize aMinSize = sizeFromContents(QStyle::CT_TabBarTab, &sot, contentRect.size());
contentRect.setSize(aMinSize);
boundingRect = contentRect;
retVal = true;
@@ -960,8 +954,8 @@ bool Qt5Graphics_Controls::getNativeControlRegion(ControlType type, ControlPart
{
const TabPaneValue& rValue = static_cast<const TabPaneValue&>(val);
QStyleOptionTabWidgetFrame sotwf;
- lcl_fullQStyleOptionTabWidgetFrame(sotwf);
- QSize aMinSize = QApplication::style()->sizeFromContents(
+ fullQStyleOptionTabWidgetFrame(sotwf);
+ QSize aMinSize = sizeFromContents(
QStyle::CT_TabWidget, &sotwf,
QSize(std::max(rValue.m_aTabHeaderRect.GetWidth(), controlRegion.GetWidth()),
rValue.m_aTabHeaderRect.GetHeight() + controlRegion.GetHeight()));
More information about the Libreoffice-commits
mailing list