File indexing completed on 2024-04-28 05:26:27
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "breeze.h" 0010 #include "breezehelper.h" 0011 #include "breezemetrics.h" 0012 #include "config-breeze.h" 0013 0014 #if BREEZE_HAVE_KSTYLE 0015 #include <KStyle> 0016 #endif 0017 0018 #include <QAbstractItemView> 0019 #include <QAbstractScrollArea> 0020 0021 #include <QCommandLinkButton> 0022 #include <QCommonStyle> 0023 #include <QDockWidget> 0024 #include <QFocusFrame> 0025 #include <QHash> 0026 #include <QIcon> 0027 #include <QMdiSubWindow> 0028 #include <QStyleOption> 0029 #include <QWidget> 0030 0031 #include <functional> 0032 0033 class QDialogButtonBox; 0034 0035 namespace BreezePrivate 0036 { 0037 class TabBarData; 0038 } 0039 0040 namespace Breeze 0041 { 0042 class Animations; 0043 class FrameShadowFactory; 0044 class Helper; 0045 class MdiWindowShadowFactory; 0046 class Mnemonics; 0047 class ShadowHelper; 0048 class SplitterFactory; 0049 class WidgetExplorer; 0050 class WindowManager; 0051 class BlurHelper; 0052 class ToolsAreaManager; 0053 0054 //* convenience typedef for base class 0055 #if !BREEZE_HAVE_KSTYLE 0056 using ParentStyleClass = QCommonStyle; 0057 #else 0058 using ParentStyleClass = KStyle; 0059 #endif 0060 0061 //* base class for breeze style 0062 /** it is responsible to draw all the primitives to be displayed on screen, on request from Qt paint engine */ 0063 class Style : public ParentStyleClass 0064 { 0065 Q_OBJECT 0066 0067 /* this tells kde applications that custom style elements are supported, using the kstyle mechanism */ 0068 Q_CLASSINFO("X-KDE-CustomElements", "true") 0069 0070 public: 0071 //* constructor 0072 explicit Style(); 0073 0074 //* destructor 0075 ~Style() override; 0076 0077 //* needed to avoid warnings at compilation time 0078 using ParentStyleClass::polish; 0079 using ParentStyleClass::unpolish; 0080 0081 //* widget polishing 0082 void polish(QWidget *) override; 0083 0084 //* widget unpolishing 0085 void unpolish(QWidget *) override; 0086 0087 //* application polishing 0088 void polish(QApplication *) override; 0089 0090 //* application unpolishing 0091 void unpolish(QApplication *) override; 0092 0093 //* polish scrollarea 0094 void polishScrollArea(QAbstractScrollArea *); 0095 0096 //* pixel metrics 0097 int pixelMetric(PixelMetric, const QStyleOption * = nullptr, const QWidget * = nullptr) const override; 0098 0099 //* style hints 0100 int styleHint(StyleHint, const QStyleOption * = nullptr, const QWidget * = nullptr, QStyleHintReturn * = nullptr) const override; 0101 0102 //* returns rect corresponding to one widget's subelement 0103 QRect subElementRect(SubElement, const QStyleOption *, const QWidget *) const override; 0104 0105 //* returns rect corresponding to one widget's subcontrol 0106 QRect subControlRect(ComplexControl, const QStyleOptionComplex *, SubControl, const QWidget *) const override; 0107 0108 //* returns size matching contents 0109 QSize sizeFromContents(ContentsType, const QStyleOption *, const QSize &, const QWidget *) const override; 0110 0111 //* returns which subcontrol given QPoint corresponds to 0112 SubControl hitTestComplexControl(ComplexControl, const QStyleOptionComplex *, const QPoint &, const QWidget *) const override; 0113 0114 //* primitives 0115 void drawPrimitive(PrimitiveElement, const QStyleOption *, QPainter *, const QWidget *) const override; 0116 0117 //* controls 0118 void drawControl(ControlElement, const QStyleOption *, QPainter *, const QWidget *) const override; 0119 0120 //* complex controls 0121 void drawComplexControl(ComplexControl, const QStyleOptionComplex *, QPainter *, const QWidget *) const override; 0122 0123 //* generic text rendering 0124 void drawItemText(QPainter *, const QRect &, int alignment, const QPalette &, bool enabled, const QString &, QPalette::ColorRole = QPalette::NoRole) 0125 const override; 0126 0127 bool event(QEvent *) override; 0128 0129 //*@name event filters 0130 //@{ 0131 0132 bool eventFilter(QObject *, QEvent *) override; 0133 bool eventFilterScrollArea(QWidget *, QEvent *); 0134 bool eventFilterComboBoxContainer(QWidget *, QEvent *); 0135 bool eventFilterDockWidget(QDockWidget *, QEvent *); 0136 bool eventFilterMdiSubWindow(QMdiSubWindow *, QEvent *); 0137 bool eventFilterCommandLinkButton(QCommandLinkButton *, QEvent *); 0138 bool eventFilterDialogButtonBox(QDialogButtonBox *, QEvent *); 0139 0140 //* install event filter to object, in a unique way 0141 void addEventFilter(QObject *object) 0142 { 0143 object->removeEventFilter(this); 0144 object->installEventFilter(this); 0145 } 0146 0147 //@} 0148 0149 protected Q_SLOTS: 0150 0151 //* update configuration 0152 void configurationChanged(); 0153 0154 //* global configuration changed 0155 void globalConfigurationChanged(int type, int arg); 0156 void loadGlobalAnimationSettings(); 0157 0158 //* standard icons 0159 QIcon standardIconImplementation(StandardPixmap, const QStyleOption *, const QWidget *) const; 0160 0161 protected: 0162 //* standard icons 0163 QIcon standardIcon(StandardPixmap pixmap, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override 0164 { 0165 return standardIconImplementation(pixmap, option, widget); 0166 } 0167 0168 private: 0169 //* load configuration 0170 void loadConfiguration(); 0171 0172 bool isTabletMode() const; 0173 0174 //*@name subelementRect specialized functions 0175 //@{ 0176 0177 QRect pushButtonContentsRect(const QStyleOption *, const QWidget *) const; 0178 QRect checkBoxContentsRect(const QStyleOption *, const QWidget *) const; 0179 QRect lineEditContentsRect(const QStyleOption *, const QWidget *) const; 0180 QRect progressBarGrooveRect(const QStyleOption *, const QWidget *) const; 0181 QRect progressBarContentsRect(const QStyleOption *, const QWidget *) const; 0182 QRect progressBarLabelRect(const QStyleOption *, const QWidget *) const; 0183 QRect frameContentsRect(const QStyleOption *, const QWidget *) const; 0184 QRect headerArrowRect(const QStyleOption *, const QWidget *) const; 0185 QRect headerLabelRect(const QStyleOption *, const QWidget *) const; 0186 QRect tabBarTabLeftButtonRect(const QStyleOption *, const QWidget *) const; 0187 QRect tabBarTabRightButtonRect(const QStyleOption *, const QWidget *) const; 0188 QRect tabWidgetTabBarRect(const QStyleOption *, const QWidget *) const; 0189 QRect tabWidgetTabContentsRect(const QStyleOption *, const QWidget *) const; 0190 QRect tabWidgetTabPaneRect(const QStyleOption *, const QWidget *) const; 0191 QRect tabWidgetCornerRect(SubElement, const QStyleOption *, const QWidget *widget) const; 0192 QRect toolBoxTabContentsRect(const QStyleOption *, const QWidget *) const; 0193 QRect genericLayoutItemRect(const QStyleOption *, const QWidget *) const; 0194 0195 //@} 0196 0197 //*@name subcontrol Rect specialized functions 0198 //@{ 0199 0200 QRect groupBoxSubControlRect(const QStyleOptionComplex *, SubControl, const QWidget *) const; 0201 QRect toolButtonSubControlRect(const QStyleOptionComplex *, SubControl, const QWidget *) const; 0202 QRect comboBoxSubControlRect(const QStyleOptionComplex *, SubControl, const QWidget *) const; 0203 QRect spinBoxSubControlRect(const QStyleOptionComplex *, SubControl, const QWidget *) const; 0204 QRect scrollBarInternalSubControlRect(const QStyleOptionComplex *, SubControl) const; 0205 QRect scrollBarSubControlRect(const QStyleOptionComplex *, SubControl, const QWidget *) const; 0206 QRect dialSubControlRect(const QStyleOptionComplex *, SubControl, const QWidget *) const; 0207 QRect sliderSubControlRect(const QStyleOptionComplex *, SubControl, const QWidget *) const; 0208 0209 //@} 0210 0211 //*@name sizeFromContents 0212 //@{ 0213 QSize defaultSizeFromContents(const QStyleOption *, const QSize &size, const QWidget *) const 0214 { 0215 return size; 0216 } 0217 0218 QSize checkBoxSizeFromContents(const QStyleOption *, const QSize &, const QWidget *) const; 0219 QSize lineEditSizeFromContents(const QStyleOption *, const QSize &, const QWidget *) const; 0220 QSize comboBoxSizeFromContents(const QStyleOption *, const QSize &, const QWidget *) const; 0221 QSize spinBoxSizeFromContents(const QStyleOption *, const QSize &, const QWidget *) const; 0222 QSize sliderSizeFromContents(const QStyleOption *, const QSize &, const QWidget *) const; 0223 QSize pushButtonSizeFromContents(const QStyleOption *, const QSize &, const QWidget *) const; 0224 QSize toolButtonSizeFromContents(const QStyleOption *, const QSize &, const QWidget *) const; 0225 QSize menuBarItemSizeFromContents(const QStyleOption *, const QSize &, const QWidget *) const; 0226 QSize menuItemSizeFromContents(const QStyleOption *, const QSize &, const QWidget *) const; 0227 QSize progressBarSizeFromContents(const QStyleOption *, const QSize &, const QWidget *) const; 0228 QSize tabWidgetSizeFromContents(const QStyleOption *, const QSize &, const QWidget *) const; 0229 QSize tabBarTabSizeFromContents(const QStyleOption *, const QSize &, const QWidget *) const; 0230 QSize headerSectionSizeFromContents(const QStyleOption *, const QSize &, const QWidget *) const; 0231 QSize itemViewItemSizeFromContents(const QStyleOption *, const QSize &, const QWidget *) const; 0232 0233 //@} 0234 0235 //*@name primitives specialized functions 0236 //@{ 0237 0238 bool emptyPrimitive(const QStyleOption *, QPainter *, const QWidget *) const 0239 { 0240 return true; 0241 } 0242 0243 bool drawFramePrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0244 bool drawFrameLineEditPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0245 bool drawFrameFocusRectPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0246 bool drawFrameMenuPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0247 bool drawFrameGroupBoxPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0248 bool drawFrameTabWidgetPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0249 bool drawFrameTabBarBasePrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0250 bool drawFrameWindowPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0251 0252 bool drawIndicatorArrowUpPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const 0253 { 0254 return drawIndicatorArrowPrimitive(ArrowUp, option, painter, widget); 0255 } 0256 0257 bool drawIndicatorArrowDownPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const 0258 { 0259 return drawIndicatorArrowPrimitive(ArrowDown, option, painter, widget); 0260 } 0261 0262 bool drawIndicatorArrowLeftPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const 0263 { 0264 return drawIndicatorArrowPrimitive(ArrowLeft, option, painter, widget); 0265 } 0266 0267 bool drawIndicatorArrowRightPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const 0268 { 0269 return drawIndicatorArrowPrimitive(ArrowRight, option, painter, widget); 0270 } 0271 0272 bool drawIndicatorArrowPrimitive(ArrowOrientation, const QStyleOption *, QPainter *, const QWidget *) const; 0273 bool drawIndicatorHeaderArrowPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0274 bool drawPanelButtonCommandPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0275 bool drawPanelButtonToolPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0276 bool drawTabBarPanelButtonToolPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0277 bool drawPanelScrollAreaCornerPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0278 bool drawPanelMenuPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0279 bool drawPanelTipLabelPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0280 bool drawPanelItemViewItemPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0281 bool drawIndicatorCheckBoxPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0282 bool drawIndicatorRadioButtonPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0283 bool drawIndicatorButtonDropDownPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0284 bool drawIndicatorTabClosePrimitive(const QStyleOption *, QPainter *painter, const QWidget *widget) const; 0285 bool drawIndicatorTabTearPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0286 bool drawIndicatorToolBarHandlePrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0287 bool drawIndicatorToolBarSeparatorPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0288 bool drawIndicatorBranchPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0289 bool drawDockWidgetResizeHandlePrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0290 bool drawPanelStatusBarPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0291 bool drawWidgetPrimitive(const QStyleOption *, QPainter *, const QWidget *) const; 0292 0293 //@} 0294 0295 //*@name controls specialized functions 0296 //@{ 0297 0298 bool emptyControl(const QStyleOption *, QPainter *, const QWidget *) const 0299 { 0300 return true; 0301 } 0302 0303 bool drawPushButtonLabelControl(const QStyleOption *, QPainter *, const QWidget *) const; 0304 bool drawToolButtonLabelControl(const QStyleOption *, QPainter *, const QWidget *) const; 0305 bool drawCheckBoxLabelControl(const QStyleOption *, QPainter *, const QWidget *) const; 0306 bool drawComboBoxLabelControl(const QStyleOption *, QPainter *, const QWidget *) const; 0307 bool drawMenuBarItemControl(const QStyleOption *, QPainter *, const QWidget *) const; 0308 bool drawMenuItemControl(const QStyleOption *, QPainter *, const QWidget *) const; 0309 bool drawProgressBarControl(const QStyleOption *, QPainter *, const QWidget *) const; 0310 bool drawProgressBarContentsControl(const QStyleOption *, QPainter *, const QWidget *) const; 0311 bool drawProgressBarGrooveControl(const QStyleOption *, QPainter *, const QWidget *) const; 0312 bool drawProgressBarLabelControl(const QStyleOption *, QPainter *, const QWidget *) const; 0313 bool drawScrollBarSliderControl(const QStyleOption *, QPainter *, const QWidget *) const; 0314 bool drawScrollBarAddLineControl(const QStyleOption *, QPainter *, const QWidget *) const; 0315 bool drawScrollBarSubLineControl(const QStyleOption *, QPainter *, const QWidget *) const; 0316 bool drawShapedFrameControl(const QStyleOption *, QPainter *, const QWidget *) const; 0317 bool drawFocusFrame(const QStyleOption *, QPainter *, const QWidget *) const; 0318 bool drawRubberBandControl(const QStyleOption *, QPainter *, const QWidget *) const; 0319 bool drawHeaderSectionControl(const QStyleOption *, QPainter *, const QWidget *) const; 0320 bool drawHeaderEmptyAreaControl(const QStyleOption *, QPainter *, const QWidget *) const; 0321 bool drawTabBarTabLabelControl(const QStyleOption *, QPainter *, const QWidget *) const; 0322 bool drawTabBarTabShapeControl(const QStyleOption *, QPainter *, const QWidget *) const; 0323 bool drawToolBoxTabLabelControl(const QStyleOption *, QPainter *, const QWidget *) const; 0324 bool drawToolBoxTabShapeControl(const QStyleOption *, QPainter *, const QWidget *) const; 0325 bool drawDockWidgetTitleControl(const QStyleOption *, QPainter *, const QWidget *) const; 0326 bool drawSplitterControl(const QStyleOption *, QPainter *, const QWidget *) const; 0327 0328 //*@} 0329 0330 //*@name complex ontrols specialized functions 0331 //@{ 0332 bool drawGroupBoxComplexControl(const QStyleOptionComplex *, QPainter *, const QWidget *) const; 0333 bool drawToolButtonComplexControl(const QStyleOptionComplex *, QPainter *, const QWidget *) const; 0334 bool drawComboBoxComplexControl(const QStyleOptionComplex *, QPainter *, const QWidget *) const; 0335 bool drawSpinBoxComplexControl(const QStyleOptionComplex *, QPainter *, const QWidget *) const; 0336 bool drawSliderComplexControl(const QStyleOptionComplex *, QPainter *, const QWidget *) const; 0337 bool drawDialComplexControl(const QStyleOptionComplex *, QPainter *, const QWidget *) const; 0338 bool drawScrollBarComplexControl(const QStyleOptionComplex *, QPainter *, const QWidget *) const; 0339 bool drawTitleBarComplexControl(const QStyleOptionComplex *, QPainter *, const QWidget *) const; 0340 //@} 0341 0342 //!*@name various utility functions 0343 //@{ 0344 0345 //* spinbox arrows 0346 void renderSpinBoxArrow(const SubControl &, const QStyleOptionSpinBox *, QPainter *, const QWidget *) const; 0347 0348 //* return dial angle based on option and value 0349 qreal dialAngle(const QStyleOptionSlider *, int) const; 0350 0351 //* returns relevant scrollbar parent 0352 /** needed to detect parent focus */ 0353 const QWidget *scrollBarParent(const QWidget *) const; 0354 0355 //* returns true if given scrollbar arrow is animated 0356 QColor scrollBarArrowColor(const QStyleOptionSlider *, const SubControl &, const QWidget *) const; 0357 0358 //* scrollbar buttons 0359 enum ScrollBarButtonType { 0360 NoButton, 0361 SingleButton, 0362 DoubleButton, 0363 }; 0364 0365 //* returns height for scrollbar buttons depending of button types 0366 int scrollBarButtonHeight(const ScrollBarButtonType &type) const 0367 { 0368 switch (type) { 0369 case NoButton: 0370 return Metrics::ScrollBar_NoButtonHeight; 0371 case SingleButton: 0372 return Metrics::ScrollBar_SingleButtonHeight; 0373 case DoubleButton: 0374 return Metrics::ScrollBar_DoubleButtonHeight; 0375 default: 0376 return 0; 0377 } 0378 } 0379 0380 //@} 0381 0382 //* translucent background 0383 void setTranslucentBackground(QWidget *) const; 0384 0385 //* create toolbar extension icon 0386 QIcon toolBarExtensionIcon(StandardPixmap, const QStyleOption *, const QWidget *) const; 0387 0388 //* create title bar button icon 0389 QIcon titleBarButtonIcon(StandardPixmap, const QStyleOption *, const QWidget *) const; 0390 0391 //* return true if option corresponds to QtQuick control 0392 bool isQtQuickControl(const QStyleOption *, const QWidget *) const; 0393 0394 //@} 0395 0396 //* adjust rect based on provided margins 0397 QRect insideMargin(const QRect &r, int margin) const 0398 { 0399 return insideMargin(r, margin, margin); 0400 } 0401 0402 //* adjust rect based on provided margins 0403 QRect insideMargin(const QRect &r, int marginWidth, int marginHeight) const 0404 { 0405 return r.adjusted(marginWidth, marginHeight, -marginWidth, -marginHeight); 0406 } 0407 0408 //* expand size based on margins 0409 QSize expandSize(const QSize &size, int margin) const 0410 { 0411 return expandSize(size, margin, margin); 0412 } 0413 0414 //* expand size based on margins 0415 QSize expandSize(const QSize &size, int marginWidth, int marginHeight) const 0416 { 0417 return size + 2 * QSize(marginWidth, marginHeight); 0418 } 0419 0420 //* returns true for vertical tabs 0421 bool isVerticalTab(const QStyleOptionTab *option) const 0422 { 0423 return isVerticalTab(option->shape); 0424 } 0425 0426 bool isVerticalTab(const QTabBar::Shape &shape) const 0427 { 0428 return shape == QTabBar::RoundedEast || shape == QTabBar::RoundedWest || shape == QTabBar::TriangularEast || shape == QTabBar::TriangularWest; 0429 } 0430 0431 //* right to left alignment handling 0432 using ParentStyleClass::visualRect; 0433 QRect visualRect(const QStyleOption *opt, const QRect &subRect) const 0434 { 0435 return ParentStyleClass::visualRect(opt->direction, opt->rect, subRect); 0436 } 0437 0438 //* centering 0439 QRect centerRect(const QRect &rect, const QSize &size) const 0440 { 0441 return centerRect(rect, size.width(), size.height()); 0442 } 0443 0444 QRect centerRect(const QRect &rect, int width, int height) const 0445 { 0446 return QRect(rect.left() + (rect.width() - width) / 2, rect.top() + (rect.height() - height) / 2, width, height); 0447 } 0448 0449 static int sliderTickMarksLength(); 0450 0451 static QRect sliderRectWithoutTickMarks(const QStyleOptionSlider *option); 0452 0453 /* 0454 Checks whether the point is before the bound rect for bound of given orientation. 0455 This is needed to implement custom number of buttons in scrollbars, 0456 as well as proper mouse-hover 0457 */ 0458 inline bool preceeds(const QPoint &, const QRect &, const QStyleOption *) const; 0459 0460 //* return which arrow button is hit by point for scrollbar double buttons 0461 inline QStyle::SubControl scrollBarHitTest(const QRect &, const QPoint &, const QStyleOption *) const; 0462 0463 //! return true if one of the widget's parent inherits requested type 0464 inline bool hasParent(const QWidget *, const char *) const; 0465 0466 //* return true if icons should be shown in menus 0467 bool showIconsInMenuItems() const; 0468 0469 //* return true if icons should be shown on buttons 0470 bool showIconsOnPushButtons() const; 0471 0472 //* return true if passed widget is a menu title (KMenu::addTitle) 0473 bool hasAlteredBackground(const QWidget *) const; 0474 0475 /* 0476 * return true if the widget should be highlighted with neutral color 0477 * if widget is null, check for the styleObject in option 0478 * return false if the widget has the mouse hover or is focused. 0479 */ 0480 bool hasHighlightNeutral(const QObject *widget, const QStyleOption *option, bool mouseOver = false, bool focus = false) const; 0481 0482 //*@name scrollbar button types (for addLine and subLine ) 0483 //@{ 0484 ScrollBarButtonType _addLineButtons = SingleButton; 0485 ScrollBarButtonType _subLineButtons = SingleButton; 0486 //@} 0487 0488 //* focus frame 0489 QPointer<QFocusFrame> _focusFrame = nullptr; 0490 0491 //* helper 0492 Helper *_helper = nullptr; 0493 0494 //* shadow helper 0495 ShadowHelper *_shadowHelper = nullptr; 0496 0497 //* animations 0498 Animations *_animations = nullptr; 0499 0500 //* keyboard accelerators 0501 Mnemonics *_mnemonics = nullptr; 0502 0503 //* blur helper 0504 BlurHelper *_blurHelper = nullptr; 0505 0506 //* window manager 0507 WindowManager *_windowManager = nullptr; 0508 0509 //* frame shadows 0510 FrameShadowFactory *_frameShadowFactory = nullptr; 0511 0512 //* mdi window shadows 0513 MdiWindowShadowFactory *_mdiWindowShadowFactory = nullptr; 0514 0515 //* splitter Factory, to extend splitters hit area 0516 SplitterFactory *_splitterFactory = nullptr; 0517 0518 //* signal manager for the tools area 0519 ToolsAreaManager *_toolsAreaManager = nullptr; 0520 0521 //* widget explorer 0522 WidgetExplorer *_widgetExplorer = nullptr; 0523 0524 //* tabbar data 0525 BreezePrivate::TabBarData *_tabBarData = nullptr; 0526 0527 //* icon hash 0528 using IconCache = QHash<StandardPixmap, QIcon>; 0529 IconCache _iconCache; 0530 0531 //* pointer to primitive specialized function 0532 using StylePrimitive = std::function<bool(const Style &, const QStyleOption *, QPainter *, const QWidget *)>; 0533 StylePrimitive _frameFocusPrimitive; 0534 0535 //* pointer to control specialized function 0536 using StyleControl = std::function<bool(const Style &, const QStyleOption *, QPainter *, const QWidget *)>; 0537 0538 //* pointer to control specialized function 0539 using StyleComplexControl = std::function<bool(const Style &, const QStyleOptionComplex *, QPainter *, const QWidget *)>; 0540 0541 //*@name custom elements 0542 //@{ 0543 0544 //* use Argb Drag and Drop Window 0545 QStyle::StyleHint SH_ArgbDndWindow; 0546 0547 //! styled painting for KCapacityBar 0548 QStyle::ControlElement CE_CapacityBar; 0549 0550 //@} 0551 }; 0552 0553 //_________________________________________________________________________ 0554 bool Style::preceeds(const QPoint &point, const QRect &bound, const QStyleOption *option) const 0555 { 0556 if (option->state & QStyle::State_Horizontal) { 0557 if (option->direction == Qt::LeftToRight) { 0558 return point.x() < bound.right(); 0559 } else { 0560 return point.x() > bound.x(); 0561 } 0562 0563 } else { 0564 return point.y() < bound.y(); 0565 } 0566 } 0567 0568 //_________________________________________________________________________ 0569 QStyle::SubControl Style::scrollBarHitTest(const QRect &rect, const QPoint &point, const QStyleOption *option) const 0570 { 0571 if (option->state & QStyle::State_Horizontal) { 0572 if (option->direction == Qt::LeftToRight) { 0573 return point.x() < rect.center().x() ? QStyle::SC_ScrollBarSubLine : QStyle::SC_ScrollBarAddLine; 0574 } else { 0575 return point.x() > rect.center().x() ? QStyle::SC_ScrollBarSubLine : QStyle::SC_ScrollBarAddLine; 0576 } 0577 0578 } else { 0579 return point.y() < rect.center().y() ? QStyle::SC_ScrollBarSubLine : QStyle::SC_ScrollBarAddLine; 0580 } 0581 } 0582 0583 //_________________________________________________________________________ 0584 bool Style::hasParent(const QWidget *widget, const char *className) const 0585 { 0586 if (!widget) { 0587 return false; 0588 } 0589 0590 while ((widget = widget->parentWidget())) { 0591 if (widget->inherits(className)) { 0592 return true; 0593 } 0594 } 0595 0596 return false; 0597 } 0598 }