Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qcommonstyle_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QCOMMONSTYLE_P_H
5#define QCOMMONSTYLE_P_H
6
7#include <QtWidgets/private/qtwidgetsglobal_p.h>
8#include "qhash.h"
9#include "qcommonstyle.h"
10#include "qstyle_p.h"
11#if QT_CONFIG(animation)
12#include "qstyleanimation_p.h"
13#endif
14#include "qstyleoption.h"
15
17
18//
19// W A R N I N G
20// -------------
21//
22// This file is not part of the Qt API. It exists for the convenience
23// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
24// file may change from version to version without notice, or even be removed.
25//
26// We mean it.
27//
28
29class QTextOption;
30
31// Private class
32class Q_WIDGETS_EXPORT QCommonStylePrivate : public QStylePrivate
33{
34 Q_DECLARE_PUBLIC(QCommonStyle)
35public:
37#if QT_CONFIG(itemviews)
38 cachedOption(nullptr),
39#endif
40 animationFps(30)
41 { }
42
44 {
45#if QT_CONFIG(animation)
46 qDeleteAll(animations);
47#endif
48#if QT_CONFIG(itemviews)
49 delete cachedOption;
50#endif
51 }
52
53 QString calculateElidedText(const QString &text, const QTextOption &textOption,
54 const QFont &font, const QRect &textRect, const Qt::Alignment valign,
55 Qt::TextElideMode textElideMode, int flags,
56 bool lastVisibleLineShouldBeElided, QPointF *paintStartPosition) const;
57#if QT_CONFIG(itemviews)
58 void viewItemDrawText(QPainter *p, const QStyleOptionViewItem *option, const QRect &rect) const;
59 void viewItemLayout(const QStyleOptionViewItem *opt, QRect *checkRect,
60 QRect *pixmapRect, QRect *textRect, bool sizehint) const;
61 QSize viewItemSize(const QStyleOptionViewItem *option, int role) const;
62
63 mutable QRect decorationRect, displayRect, checkRect;
64 mutable QStyleOptionViewItem *cachedOption;
65 bool isViewItemCached(const QStyleOptionViewItem &option) const {
66 return cachedOption && (option.widget == cachedOption->widget
67 && option.index == cachedOption->index
68 && option.state == cachedOption->state
69 && option.rect == cachedOption->rect
70 && option.text == cachedOption->text
71 && option.direction == cachedOption->direction
72 && option.displayAlignment == cachedOption->displayAlignment
73 && option.decorationAlignment == cachedOption->decorationAlignment
74 && option.decorationPosition == cachedOption->decorationPosition
75 && option.decorationSize == cachedOption->decorationSize
76 && option.features == cachedOption->features
77 && option.icon.isNull() == cachedOption->icon.isNull()
78 && option.font == cachedOption->font
79 && option.viewItemPosition == cachedOption->viewItemPosition
80 && option.showDecorationSelected == cachedOption->showDecorationSelected);
81 }
82#endif
83#if QT_CONFIG(toolbutton)
84 QString toolButtonElideText(const QStyleOptionToolButton *toolbutton,
85 const QRect &textRect, int flags) const;
86#endif
87
89#if QT_CONFIG(tabbar)
90 virtual void tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *pixmapRect) const;
91#endif
92
94#if QT_CONFIG(animation)
96 void startAnimation(QStyleAnimation *animation) const;
97 void stopAnimation(const QObject *target) const;
98 void removeAnimation(const QObject *target) const;
99#endif
100
101 QIcon iconFromWindowsTheme(QCommonStyle::StandardPixmap standardIcon,
102 const QStyleOption *option,
103 const QWidget *widget) const;
104 QIcon iconFromMacTheme(QCommonStyle::StandardPixmap standardIcon,
105 const QStyleOption *option,
106 const QWidget *widget) const;
107 QIcon iconFromApplicationTheme(QCommonStyle::StandardPixmap standardIcon,
108 const QStyleOption *option,
109 const QWidget *widget) const;
110 QIcon iconFromResourceTheme(QCommonStyle::StandardPixmap standardIcon,
111 const QStyleOption *option,
112 const QWidget *widget) const;
113 static bool inline rtl(const QStyleOption *option) {
114 return (option && option->direction == Qt::RightToLeft) ||
116 }
117#if QT_CONFIG(animation)
118private:
119 mutable QHash<const QObject*, QStyleAnimation*> animations;
120#endif // animation
121};
122
124
125#endif //QCOMMONSTYLE_P_H
static bool rtl(const QStyleOption *option)
The QCommonStyle class encapsulates the common Look and Feel of a GUI.
\reentrant
Definition qfont.h:22
static bool isRightToLeft()
Returns true if the application's layout direction is Qt::RightToLeft; otherwise returns false.
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
\inmodule QtCore
Definition qobject.h:103
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
\inmodule QtCore\reentrant
Definition qpoint.h:217
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\variable QStyleOptionDockWidget::title
The QStyleOption class stores the parameters used by QStyle functions.
StandardPixmap
This enum describes the available standard pixmaps.
Definition qstyle.h:716
\reentrant
Definition qtextoption.h:18
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
QOpenGLWidget * widget
[1]
QString text
qDeleteAll(list.begin(), list.end())
rect
[4]
QStyleOptionButton opt
QRect textRect
Combined button and popup list for selecting options.
@ RightToLeft
TextElideMode
Definition qnamespace.h:188
GLenum target
GLbitfield flags
GLfloat GLfloat p
[1]
GLuint GLenum option
static void stopAnimation(QObject *object)
#define QT_CONFIG(feature)
if(qFloatDistance(a, b)<(1<< 7))
[0]
QObject::connect nullptr
QPropertyAnimation animation
[0]