|
Packit Bot |
052d53 |
/*************************************************************************
|
|
Packit Bot |
052d53 |
* Copyright (C) 2014 by Hugo Pereira Da Costa <hugo.pereira@free.fr> *
|
|
Packit Bot |
052d53 |
* Copyright (C) 2014-2018 Martin Bříza <m@rtinbriza.cz> *
|
|
Packit Bot |
052d53 |
* Copyright (C) 2019 Jan Grulich <jgrulich@redhat.com> *
|
|
Packit Bot |
052d53 |
* *
|
|
Packit Bot |
052d53 |
* This program is free software; you can redistribute it and/or modify *
|
|
Packit Bot |
052d53 |
* it under the terms of the GNU General Public License as published by *
|
|
Packit Bot |
052d53 |
* the Free Software Foundation; either version 2 of the License, or *
|
|
Packit Bot |
052d53 |
* (at your option) any later version. *
|
|
Packit Bot |
052d53 |
* *
|
|
Packit Bot |
052d53 |
* This program is distributed in the hope that it will be useful, *
|
|
Packit Bot |
052d53 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
Packit Bot |
052d53 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
Packit Bot |
052d53 |
* GNU General Public License for more details. *
|
|
Packit Bot |
052d53 |
* *
|
|
Packit Bot |
052d53 |
* You should have received a copy of the GNU General Public License *
|
|
Packit Bot |
052d53 |
* along with this program; if not, write to the *
|
|
Packit Bot |
052d53 |
* Free Software Foundation, Inc., *
|
|
Packit Bot |
052d53 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
|
|
Packit Bot |
052d53 |
*************************************************************************/
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
#ifndef ADWAITA_STYLE_H
|
|
Packit Bot |
052d53 |
#define ADWAITA_STYLE_H
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
#include "adwaita.h"
|
|
Packit Bot |
052d53 |
#include "config-adwaita.h"
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
#include <QAbstractItemView>
|
|
Packit Bot |
052d53 |
#include <QAbstractScrollArea>
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
#include <QCommonStyle>
|
|
Packit Bot |
052d53 |
#include <QDockWidget>
|
|
Packit Bot |
052d53 |
#include <QHash>
|
|
Packit Bot |
052d53 |
#include <QIcon>
|
|
Packit Bot |
052d53 |
#include <QMdiSubWindow>
|
|
Packit Bot |
052d53 |
#include <QStyleOption>
|
|
Packit Bot |
052d53 |
#include <QWidget>
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
#include <QCommandLinkButton>
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
namespace AdwaitaPrivate
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
class TabBarData;
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
namespace Adwaita
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
class Animations;
|
|
Packit Bot |
052d53 |
class Helper;
|
|
Packit Bot |
052d53 |
class Mnemonics;
|
|
Packit Bot |
052d53 |
class SplitterFactory;
|
|
Packit Bot |
052d53 |
class WidgetExplorer;
|
|
Packit Bot |
052d53 |
class WindowManager;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* convenience typedef for base class
|
|
Packit Bot |
052d53 |
using ParentStyleClass = QCommonStyle;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* base class for adwaita style
|
|
Packit Bot |
052d53 |
/** it is responsible to draw all the primitives to be displayed on screen, on request from Qt paint engine */
|
|
Packit Bot |
052d53 |
class Style : public ParentStyleClass
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
Q_OBJECT
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
/* this tells kde applications that custom style elements are supported, using the kstyle mechanism */
|
|
Packit Bot |
052d53 |
Q_CLASSINFO("X-KDE-CustomElements", "true")
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
public:
|
|
Packit Bot |
052d53 |
//* constructor
|
|
Packit Bot |
052d53 |
explicit Style(bool dark);
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* destructor
|
|
Packit Bot |
052d53 |
virtual ~Style(void);
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* needed to avoid warnings at compilation time
|
|
Packit Bot |
052d53 |
using ParentStyleClass::polish;
|
|
Packit Bot |
052d53 |
using ParentStyleClass::unpolish;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* widget polishing
|
|
Packit Bot |
052d53 |
virtual void polish(QWidget *widget);
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* widget unpolishing
|
|
Packit Bot |
052d53 |
virtual void unpolish(QWidget *widget);
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* palette polishing
|
|
Packit Bot |
052d53 |
virtual void polish(QPalette &palette);
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
virtual QPalette standardPalette() const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* polish scrollarea
|
|
Packit Bot |
052d53 |
void polishScrollArea(QAbstractScrollArea *scrollArea);
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* pixel metrics
|
|
Packit Bot |
052d53 |
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* style hints
|
|
Packit Bot |
052d53 |
virtual int styleHint(StyleHint hint, const QStyleOption *option = nullptr, const QWidget *widget = nullptr, QStyleHintReturn *returnData = nullptr) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* returns rect corresponding to one widget's subelement
|
|
Packit Bot |
052d53 |
virtual QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* returns rect corresponding to one widget's subcontrol
|
|
Packit Bot |
052d53 |
virtual QRect subControlRect(ComplexControl element, const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* returns size matching contents
|
|
Packit Bot |
052d53 |
QSize sizeFromContents(ContentsType element, const QStyleOption *option, const QSize &size, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* returns which subcontrol given QPoint corresponds to
|
|
Packit Bot |
052d53 |
SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option , const QPoint &point, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* primitives
|
|
Packit Bot |
052d53 |
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* controls
|
|
Packit Bot |
052d53 |
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* complex controls
|
|
Packit Bot |
052d53 |
void drawComplexControl(ComplexControl element, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* generic text rendering
|
|
Packit Bot |
052d53 |
virtual void drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &palette, bool enabled,
|
|
Packit Bot |
052d53 |
const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//*@name event filters
|
|
Packit Bot |
052d53 |
//@{
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
virtual bool eventFilter(QObject *object, QEvent *event);
|
|
Packit Bot |
052d53 |
bool eventFilterScrollArea(QWidget *widget, QEvent *event);
|
|
Packit Bot |
052d53 |
bool eventFilterComboBoxContainer(QWidget *widget, QEvent *event);
|
|
Packit Bot |
052d53 |
bool eventFilterDockWidget(QDockWidget *dockWidget, QEvent *event);
|
|
Packit Bot |
052d53 |
bool eventFilterMdiSubWindow(QMdiSubWindow *subWindow, QEvent *event);
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
bool eventFilterCommandLinkButton(QCommandLinkButton *button, QEvent *event);
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* install event filter to object, in a unique way
|
|
Packit Bot |
052d53 |
void addEventFilter(QObject *object)
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
object->removeEventFilter(this);
|
|
Packit Bot |
052d53 |
object->installEventFilter(this);
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//@}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
protected Q_SLOTS:
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* update configuration
|
|
Packit Bot |
052d53 |
void configurationChanged(void);
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* standard icons
|
|
Packit Bot |
052d53 |
virtual QIcon standardIconImplementation(StandardPixmap standardPixmap, const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
protected:
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* standard icons
|
|
Packit Bot |
052d53 |
virtual QIcon standardIcon(StandardPixmap pixmap, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
return standardIconImplementation(pixmap, option, widget);
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* load configuration
|
|
Packit Bot |
052d53 |
void loadConfiguration();
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//*@name subelementRect specialized functions
|
|
Packit Bot |
052d53 |
//@{
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* default implementation. Does not change anything
|
|
Packit Bot |
052d53 |
QRect defaultSubElementRect(const QStyleOption *option, const QWidget *widget) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
return option->rect;
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
QRect pushButtonContentsRect(const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect pushButtonFocusRect(const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect checkBoxContentsRect(const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect checkBoxIndicatorRect(const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect checkBoxFocusRect(const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect lineEditContentsRect(const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect progressBarGrooveRect(const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect progressBarContentsRect(const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect progressBarLabelRect(const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect headerArrowRect(const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect headerLabelRect(const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect sliderFocusRect(const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect tabBarTabLeftButtonRect(const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect tabBarTabRightButtonRect(const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect tabWidgetTabBarRect(const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect tabWidgetTabContentsRect(const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect tabWidgetTabPaneRect(const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect tabWidgetCornerRect(SubElement element, const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect toolBoxTabContentsRect(const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect genericLayoutItemRect(const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//@}option
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//*@name subcontrol Rect specialized functions
|
|
Packit Bot |
052d53 |
//@{
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
QRect groupBoxSubControlRect(const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect toolButtonSubControlRect(const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect comboBoxSubControlRect(const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect spinBoxSubControlRect(const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect scrollBarInternalSubControlRect(const QStyleOptionComplex *option, SubControl subControl) const;
|
|
Packit Bot |
052d53 |
QRect scrollBarSubControlRect(const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect dialSubControlRect(const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QRect sliderSubControlRect(const QStyleOptionComplex *option, SubControl subControl, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//@}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//*@name sizeFromContents
|
|
Packit Bot |
052d53 |
//@{
|
|
Packit Bot |
052d53 |
QSize defaultSizeFromContents(const QStyleOption *option, const QSize &size, const QWidget *widget) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
return size;
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
QSize checkBoxSizeFromContents(const QStyleOption *option, const QSize &size, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QSize lineEditSizeFromContents(const QStyleOption *option, const QSize &size, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QSize comboBoxSizeFromContents(const QStyleOption *option, const QSize &size, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QSize spinBoxSizeFromContents(const QStyleOption *option, const QSize &size, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QSize sliderSizeFromContents(const QStyleOption *option, const QSize &size, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QSize pushButtonSizeFromContents(const QStyleOption *option, const QSize &size, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QSize toolButtonSizeFromContents(const QStyleOption *option, const QSize &size, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QSize menuBarItemSizeFromContents(const QStyleOption *option, const QSize &size, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QSize menuItemSizeFromContents(const QStyleOption *option, const QSize &size, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QSize progressBarSizeFromContents(const QStyleOption *option, const QSize &size, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QSize tabWidgetSizeFromContents(const QStyleOption *option, const QSize &size, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QSize tabBarTabSizeFromContents(const QStyleOption *option, const QSize &size, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QSize headerSectionSizeFromContents(const QStyleOption *option, const QSize &size, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
QSize itemViewItemSizeFromContents(const QStyleOption *option, const QSize &size, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//@}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//*@name primitives specialized functions
|
|
Packit Bot |
052d53 |
//@{
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
bool emptyPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
return true;
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
bool drawFramePrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawFrameLineEditPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawFrameFocusRectPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawFrameMenuPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawFrameGroupBoxPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawFrameTabWidgetPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawFrameTabBarBasePrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawFrameWindowPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
bool drawIndicatorArrowUpPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
return drawIndicatorArrowPrimitive(ArrowUp, option, painter, widget);
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
bool drawIndicatorArrowDownPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
return drawIndicatorArrowPrimitive(ArrowDown, option, painter, widget);
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
bool drawIndicatorArrowLeftPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
return drawIndicatorArrowPrimitive(ArrowLeft, option, painter, widget);
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
bool drawIndicatorArrowRightPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
return drawIndicatorArrowPrimitive(ArrowRight, option, painter, widget);
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
bool drawIndicatorArrowPrimitive(ArrowOrientation orientation, const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawIndicatorHeaderArrowPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawPanelButtonCommandPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawPanelButtonToolPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawTabBarPanelButtonToolPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawPanelScrollAreaCornerPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawPanelMenuPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawPanelTipLabelPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawPanelItemViewRowPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawPanelItemViewItemPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawIndicatorCheckBoxPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawIndicatorRadioButtonPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawIndicatorButtonDropDownPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawIndicatorTabClosePrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawIndicatorTabTearPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawIndicatorToolBarHandlePrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawIndicatorToolBarSeparatorPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawIndicatorBranchPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//@}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//*@name controls specialized functions
|
|
Packit Bot |
052d53 |
//@{
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
bool emptyControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
return true;
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
virtual bool drawPushButtonLabelControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawToolButtonLabelControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawCheckBoxLabelControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawComboBoxLabelControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawItemViewItemControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawMenuBarEmptyArea(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawMenuBarItemControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawMenuItemControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawProgressBarControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawProgressBarContentsControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawProgressBarGrooveControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawProgressBarLabelControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawScrollBarSliderControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawScrollBarAddLineControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawScrollBarSubLineControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawShapedFrameControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawRubberBandControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawHeaderSectionControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawHeaderLabelControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawHeaderEmptyAreaControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawTabBarTabLabelControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawTabBarTabShapeControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawToolBoxTabLabelControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawToolBoxTabShapeControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
virtual bool drawDockWidgetTitleControl(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//*@}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//*@name complex ontrols specialized functions
|
|
Packit Bot |
052d53 |
//@{
|
|
Packit Bot |
052d53 |
bool drawGroupBoxComplexControl(const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawToolButtonComplexControl(const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawComboBoxComplexControl(const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawSpinBoxComplexControl(const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawSliderComplexControl(const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawDialComplexControl(const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawScrollBarComplexControl(const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
bool drawTitleBarComplexControl(const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
//@}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//!*@name various utilty functions
|
|
Packit Bot |
052d53 |
//@{
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* spinbox arrows
|
|
Packit Bot |
052d53 |
void renderSpinBoxArrow(const SubControl &subControl, const QStyleOptionSpinBox *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* menu title
|
|
Packit Bot |
052d53 |
void renderMenuTitle(const QStyleOptionToolButton *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* return dial angle based on option and value
|
|
Packit Bot |
052d53 |
qreal dialAngle(const QStyleOptionSlider *sliderOption, int value) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* returns relevant scrollbar parent
|
|
Packit Bot |
052d53 |
/** needed to detect parent focus */
|
|
Packit Bot |
052d53 |
const QWidget *scrollBarParent(const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* returns true if given scrollbar arrow is animated
|
|
Packit Bot |
052d53 |
QColor scrollBarArrowColor(const QStyleOptionSlider *option, const SubControl &control, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* scrollbar buttons
|
|
Packit Bot |
052d53 |
enum ScrollBarButtonType {
|
|
Packit Bot |
052d53 |
NoButton,
|
|
Packit Bot |
052d53 |
SingleButton,
|
|
Packit Bot |
052d53 |
DoubleButton
|
|
Packit Bot |
052d53 |
};
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* returns height for scrollbar buttons depending of button types
|
|
Packit Bot |
052d53 |
int scrollBarButtonHeight(const ScrollBarButtonType &type) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
switch (type) {
|
|
Packit Bot |
052d53 |
case NoButton:
|
|
Packit Bot |
052d53 |
return Metrics::ScrollBar_NoButtonHeight;
|
|
Packit Bot |
052d53 |
case SingleButton:
|
|
Packit Bot |
052d53 |
return Metrics::ScrollBar_SingleButtonHeight;
|
|
Packit Bot |
052d53 |
case DoubleButton:
|
|
Packit Bot |
052d53 |
return Metrics::ScrollBar_DoubleButtonHeight;
|
|
Packit Bot |
052d53 |
default:
|
|
Packit Bot |
052d53 |
return 0;
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//@}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* translucent background
|
|
Packit Bot |
052d53 |
void setTranslucentBackground(QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
/**
|
|
Packit Bot |
052d53 |
separator can have a title and an icon
|
|
Packit Bot |
052d53 |
in that case they are rendered as sunken flat toolbuttons
|
|
Packit Bot |
052d53 |
return toolbutton option that matches named separator menu items
|
|
Packit Bot |
052d53 |
*/
|
|
Packit Bot |
052d53 |
QStyleOptionToolButton separatorMenuItemOption(const QStyleOptionMenuItem *menuItemOption, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* create toolbar extension icon
|
|
Packit Bot |
052d53 |
QIcon toolBarExtensionIcon(StandardPixmap, const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* create title bar button icon
|
|
Packit Bot |
052d53 |
QIcon titleBarButtonIcon(StandardPixmap, const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* returns item view parent if any
|
|
Packit Bot |
052d53 |
/** needed to have correct color on focused checkboxes and radiobuttons */
|
|
Packit Bot |
052d53 |
const QAbstractItemView *itemViewParent(const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* returns true if a given widget is a selected item in a focused list
|
|
Packit Bot |
052d53 |
/**
|
|
Packit Bot |
052d53 |
This is necessary to have the correct colors used for e.g. checkboxes and radiobuttons in lists
|
|
Packit Bot |
052d53 |
@param widget The widget to be checked
|
|
Packit Bot |
052d53 |
@param position Used to find the relevant QModelIndex
|
|
Packit Bot |
052d53 |
*/
|
|
Packit Bot |
052d53 |
bool isSelectedItem(const QWidget *widget, const QPoint &localPosition) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* return true if option corresponds to QtQuick control
|
|
Packit Bot |
052d53 |
bool isQtQuickControl(const QStyleOption *option, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//@}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* adjust rect based on provided margins
|
|
Packit Bot |
052d53 |
QRect insideMargin(const QRect &r, int margin) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
return insideMargin(r, margin, margin);
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* adjust rect based on provided margins
|
|
Packit Bot |
052d53 |
QRect insideMargin(const QRect &r, int marginWidth, int marginHeight) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
return r.adjusted(marginWidth, marginHeight, -marginWidth, -marginHeight);
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* expand size based on margins
|
|
Packit Bot |
052d53 |
QSize expandSize(const QSize &size, int margin) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
return expandSize(size, margin, margin);
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* expand size based on margins
|
|
Packit Bot |
052d53 |
QSize expandSize(const QSize &size, int marginWidth, int marginHeight) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
return size + 2 * QSize(marginWidth, marginHeight);
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* returns true for vertical tabs
|
|
Packit Bot |
052d53 |
bool isVerticalTab(const QStyleOptionTab *option) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
return isVerticalTab(option->shape);
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
bool isVerticalTab(const QTabBar::Shape &shape) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
return shape == QTabBar::RoundedEast
|
|
Packit Bot |
052d53 |
|| shape == QTabBar::RoundedWest
|
|
Packit Bot |
052d53 |
|| shape == QTabBar::TriangularEast
|
|
Packit Bot |
052d53 |
|| shape == QTabBar::TriangularWest;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* right to left alignment handling
|
|
Packit Bot |
052d53 |
using ParentStyleClass::visualRect;
|
|
Packit Bot |
052d53 |
QRect visualRect(const QStyleOption *opt, const QRect &subRect) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
return ParentStyleClass::visualRect(opt->direction, opt->rect, subRect);
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* centering
|
|
Packit Bot |
052d53 |
QRect centerRect(const QRect &rect, const QSize &size) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
return centerRect(rect, size.width(), size.height());
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
QRect centerRect(const QRect &rect, int width, int height) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
return QRect(rect.left() + (rect.width() - width) / 2, rect.top() + (rect.height() - height) / 2, width, height);
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
/*
|
|
Packit Bot |
052d53 |
Checks whether the point is before the bound rect for bound of given orientation.
|
|
Packit Bot |
052d53 |
This is needed to implement custom number of buttons in scrollbars,
|
|
Packit Bot |
052d53 |
as well as proper mouse-hover
|
|
Packit Bot |
052d53 |
*/
|
|
Packit Bot |
052d53 |
inline bool preceeds(const QPoint &point, const QRect &bound, const QStyleOption *option) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* return which arrow button is hit by point for scrollbar double buttons
|
|
Packit Bot |
052d53 |
inline QStyle::SubControl scrollBarHitTest(const QRect &rect, const QPoint &point, const QStyleOption *option) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//! return true if one of the widget's parent inherits requested type
|
|
Packit Bot |
052d53 |
inline bool hasParent(const QWidget *widget, const char *className) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* return true if one of the widget's parent inherits requested type
|
|
Packit Bot |
052d53 |
template<typename T> bool hasParent(const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* return true if icons should be shown in menus
|
|
Packit Bot |
052d53 |
bool showIconsInMenuItems(void) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* return true if icons should be shown on buttons
|
|
Packit Bot |
052d53 |
bool showIconsOnPushButtons(void) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* return true if passed widget is a menu title (KMenu::addTitle)
|
|
Packit Bot |
052d53 |
bool isMenuTitle(const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* return true if passed widget is a menu title (KMenu::addTitle)
|
|
Packit Bot |
052d53 |
bool hasAlteredBackground(const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
private:
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//*@name scrollbar button types (for addLine and subLine )
|
|
Packit Bot |
052d53 |
//@{
|
|
Packit Bot |
052d53 |
ScrollBarButtonType _addLineButtons;
|
|
Packit Bot |
052d53 |
ScrollBarButtonType _subLineButtons;
|
|
Packit Bot |
052d53 |
//@}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* helper
|
|
Packit Bot |
052d53 |
Helper *_helper;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* animations
|
|
Packit Bot |
052d53 |
Animations *_animations;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* keyboard accelerators
|
|
Packit Bot |
052d53 |
Mnemonics *_mnemonics;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* window manager
|
|
Packit Bot |
052d53 |
WindowManager *_windowManager;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* splitter Factory, to extend splitters hit area
|
|
Packit Bot |
052d53 |
SplitterFactory *_splitterFactory;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* widget explorer
|
|
Packit Bot |
052d53 |
WidgetExplorer *_widgetExplorer;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* tabbar data
|
|
Packit Bot |
052d53 |
AdwaitaPrivate::TabBarData *_tabBarData;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* icon hash
|
|
Packit Bot |
052d53 |
using IconCache = QHash<StandardPixmap, QIcon>;
|
|
Packit Bot |
052d53 |
IconCache _iconCache;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* pointer to primitive specialized function
|
|
Packit Bot |
052d53 |
using StylePrimitive = bool(Style::*)(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
StylePrimitive _frameFocusPrimitive = nullptr;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* pointer to control specialized function
|
|
Packit Bot |
052d53 |
using StyleControl = bool (Style::*)(const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* pointer to control specialized function
|
|
Packit Bot |
052d53 |
using StyleComplexControl = bool (Style::*)(const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//*@name custom elements
|
|
Packit Bot |
052d53 |
//@{
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//* use Argb Drag and Drop Window
|
|
Packit Bot |
052d53 |
QStyle::StyleHint SH_ArgbDndWindow;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//! styled painting for KCapacityBar
|
|
Packit Bot |
052d53 |
QStyle::ControlElement CE_CapacityBar;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
bool _dark { false };
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
bool _isGNOME { false };
|
|
Packit Bot |
052d53 |
bool _isKDE { false };
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//@}
|
|
Packit Bot |
052d53 |
};
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//_________________________________________________________________________
|
|
Packit Bot |
052d53 |
bool Style::preceeds(const QPoint &point, const QRect &bound, const QStyleOption *option) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
if (option->state & QStyle::State_Horizontal) {
|
|
Packit Bot |
052d53 |
if (option->direction == Qt::LeftToRight)
|
|
Packit Bot |
052d53 |
return point.x() < bound.right();
|
|
Packit Bot |
052d53 |
else
|
|
Packit Bot |
052d53 |
return point.x() > bound.x();
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
} else
|
|
Packit Bot |
052d53 |
return point.y() < bound.y();
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//_________________________________________________________________________
|
|
Packit Bot |
052d53 |
QStyle::SubControl Style::scrollBarHitTest(const QRect &rect, const QPoint &point, const QStyleOption *option) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
if (option->state & QStyle::State_Horizontal) {
|
|
Packit Bot |
052d53 |
if (option->direction == Qt::LeftToRight)
|
|
Packit Bot |
052d53 |
return point.x() < rect.center().x() ? QStyle::SC_ScrollBarSubLine : QStyle::SC_ScrollBarAddLine;
|
|
Packit Bot |
052d53 |
else
|
|
Packit Bot |
052d53 |
return point.x() > rect.center().x() ? QStyle::SC_ScrollBarSubLine : QStyle::SC_ScrollBarAddLine;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
} else
|
|
Packit Bot |
052d53 |
return point.y() < rect.center().y() ? QStyle::SC_ScrollBarSubLine : QStyle::SC_ScrollBarAddLine;
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//_________________________________________________________________________
|
|
Packit Bot |
052d53 |
bool Style::hasParent(const QWidget *widget, const char *className) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
if (!widget)
|
|
Packit Bot |
052d53 |
return false;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
while ((widget = widget->parentWidget())) {
|
|
Packit Bot |
052d53 |
if (widget->inherits(className))
|
|
Packit Bot |
052d53 |
return true;
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
return false;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
//_________________________________________________________________________
|
|
Packit Bot |
052d53 |
template< typename T > bool Style::hasParent(const QWidget *widget) const
|
|
Packit Bot |
052d53 |
{
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
if (!widget)
|
|
Packit Bot |
052d53 |
return false;
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
while ((widget = widget->parentWidget())) {
|
|
Packit Bot |
052d53 |
if (qobject_cast<const T *>(widget))
|
|
Packit Bot |
052d53 |
return true;
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
return false;
|
|
Packit Bot |
052d53 |
}
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
} // namespace Adwaita
|
|
Packit Bot |
052d53 |
|
|
Packit Bot |
052d53 |
#endif // ADWAITA_STYLE_H
|
|
Packit Bot |
052d53 |
|