| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2017 The Qt Company Ltd. |
| 4 | ** Contact: http://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL3$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at http://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPLv3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or later as published by the Free |
| 28 | ** Software Foundation and appearing in the file LICENSE.GPL included in |
| 29 | ** the packaging of this file. Please review the following information to |
| 30 | ** ensure the GNU General Public License version 2.0 requirements will be |
| 31 | ** met: http://www.gnu.org/licenses/gpl-2.0.html. |
| 32 | ** |
| 33 | ** $QT_END_LICENSE$ |
| 34 | ** |
| 35 | ****************************************************************************/ |
| 36 | |
| 37 | #ifndef QQUICKCONTROL_P_H |
| 38 | #define QQUICKCONTROL_P_H |
| 39 | |
| 40 | // |
| 41 | // W A R N I N G |
| 42 | // ------------- |
| 43 | // |
| 44 | // This file is not part of the Qt API. It exists purely as an |
| 45 | // implementation detail. This header file may change from version to |
| 46 | // version without notice, or even be removed. |
| 47 | // |
| 48 | // We mean it. |
| 49 | // |
| 50 | |
| 51 | #include <QtCore/qlocale.h> |
| 52 | #include <QtGui/qpalette.h> |
| 53 | #include <QtQuick/qquickitem.h> |
| 54 | #include <QtQuickTemplates2/private/qtquicktemplates2global_p.h> |
| 55 | |
| 56 | QT_BEGIN_NAMESPACE |
| 57 | |
| 58 | class QQuickControlPrivate; |
| 59 | |
| 60 | class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickControl : public QQuickItem |
| 61 | { |
| 62 | Q_OBJECT |
| 63 | Q_PROPERTY(QFont font READ font WRITE setFont RESET resetFont NOTIFY fontChanged FINAL) |
| 64 | Q_PROPERTY(qreal availableWidth READ availableWidth NOTIFY availableWidthChanged FINAL) |
| 65 | Q_PROPERTY(qreal availableHeight READ availableHeight NOTIFY availableHeightChanged FINAL) |
| 66 | Q_PROPERTY(qreal padding READ padding WRITE setPadding RESET resetPadding NOTIFY paddingChanged FINAL) |
| 67 | Q_PROPERTY(qreal topPadding READ topPadding WRITE setTopPadding RESET resetTopPadding NOTIFY topPaddingChanged FINAL) |
| 68 | Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged FINAL) |
| 69 | Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged FINAL) |
| 70 | Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged FINAL) |
| 71 | Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing RESET resetSpacing NOTIFY spacingChanged FINAL) |
| 72 | Q_PROPERTY(QLocale locale READ locale WRITE setLocale RESET resetLocale NOTIFY localeChanged FINAL) |
| 73 | Q_PROPERTY(bool mirrored READ isMirrored NOTIFY mirroredChanged FINAL) |
| 74 | Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy NOTIFY focusPolicyChanged FINAL) |
| 75 | Q_PROPERTY(Qt::FocusReason focusReason READ focusReason WRITE setFocusReason NOTIFY focusReasonChanged FINAL) |
| 76 | Q_PROPERTY(bool visualFocus READ hasVisualFocus NOTIFY visualFocusChanged FINAL) |
| 77 | Q_PROPERTY(bool hovered READ isHovered NOTIFY hoveredChanged FINAL) |
| 78 | Q_PROPERTY(bool hoverEnabled READ isHoverEnabled WRITE setHoverEnabled RESET resetHoverEnabled NOTIFY hoverEnabledChanged FINAL) |
| 79 | Q_PROPERTY(bool wheelEnabled READ isWheelEnabled WRITE setWheelEnabled NOTIFY wheelEnabledChanged FINAL) |
| 80 | Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL) |
| 81 | Q_PROPERTY(QQuickItem *contentItem READ contentItem WRITE setContentItem NOTIFY contentItemChanged FINAL) |
| 82 | Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset RESET resetBaselineOffset NOTIFY baselineOffsetChanged FINAL) |
| 83 | // 2.3 (Qt 5.10) |
| 84 | Q_PROPERTY(QPalette palette READ palette WRITE setPalette RESET resetPalette NOTIFY paletteChanged FINAL REVISION 3) |
| 85 | // 2.5 (Qt 5.12) |
| 86 | Q_PROPERTY(qreal horizontalPadding READ horizontalPadding WRITE setHorizontalPadding RESET resetHorizontalPadding NOTIFY horizontalPaddingChanged FINAL REVISION 5) |
| 87 | Q_PROPERTY(qreal verticalPadding READ verticalPadding WRITE setVerticalPadding RESET resetVerticalPadding NOTIFY verticalPaddingChanged FINAL REVISION 5) |
| 88 | Q_PROPERTY(qreal implicitContentWidth READ implicitContentWidth NOTIFY implicitContentWidthChanged FINAL REVISION 5) |
| 89 | Q_PROPERTY(qreal implicitContentHeight READ implicitContentHeight NOTIFY implicitContentHeightChanged FINAL REVISION 5) |
| 90 | Q_PROPERTY(qreal implicitBackgroundWidth READ implicitBackgroundWidth NOTIFY implicitBackgroundWidthChanged FINAL REVISION 5) |
| 91 | Q_PROPERTY(qreal implicitBackgroundHeight READ implicitBackgroundHeight NOTIFY implicitBackgroundHeightChanged FINAL REVISION 5) |
| 92 | Q_PROPERTY(qreal topInset READ topInset WRITE setTopInset RESET resetTopInset NOTIFY topInsetChanged FINAL REVISION 5) |
| 93 | Q_PROPERTY(qreal leftInset READ leftInset WRITE setLeftInset RESET resetLeftInset NOTIFY leftInsetChanged FINAL REVISION 5) |
| 94 | Q_PROPERTY(qreal rightInset READ rightInset WRITE setRightInset RESET resetRightInset NOTIFY rightInsetChanged FINAL REVISION 5) |
| 95 | Q_PROPERTY(qreal bottomInset READ bottomInset WRITE setBottomInset RESET resetBottomInset NOTIFY bottomInsetChanged FINAL REVISION 5) |
| 96 | Q_CLASSINFO("DeferredPropertyNames" , "background,contentItem" ) |
| 97 | |
| 98 | public: |
| 99 | explicit QQuickControl(QQuickItem *parent = nullptr); |
| 100 | ~QQuickControl(); |
| 101 | |
| 102 | QFont font() const; |
| 103 | void setFont(const QFont &font); |
| 104 | void resetFont(); |
| 105 | |
| 106 | qreal availableWidth() const; |
| 107 | qreal availableHeight() const; |
| 108 | |
| 109 | qreal padding() const; |
| 110 | void setPadding(qreal padding); |
| 111 | void resetPadding(); |
| 112 | |
| 113 | qreal topPadding() const; |
| 114 | void setTopPadding(qreal padding); |
| 115 | void resetTopPadding(); |
| 116 | |
| 117 | qreal leftPadding() const; |
| 118 | void setLeftPadding(qreal padding); |
| 119 | void resetLeftPadding(); |
| 120 | |
| 121 | qreal rightPadding() const; |
| 122 | void setRightPadding(qreal padding); |
| 123 | void resetRightPadding(); |
| 124 | |
| 125 | qreal bottomPadding() const; |
| 126 | void setBottomPadding(qreal padding); |
| 127 | void resetBottomPadding(); |
| 128 | |
| 129 | qreal spacing() const; |
| 130 | void setSpacing(qreal spacing); |
| 131 | void resetSpacing(); |
| 132 | |
| 133 | QLocale locale() const; |
| 134 | void setLocale(const QLocale &locale); |
| 135 | void resetLocale(); |
| 136 | |
| 137 | bool isMirrored() const; |
| 138 | |
| 139 | Qt::FocusPolicy focusPolicy() const; |
| 140 | void setFocusPolicy(Qt::FocusPolicy policy); |
| 141 | |
| 142 | Qt::FocusReason focusReason() const; |
| 143 | void setFocusReason(Qt::FocusReason reason); |
| 144 | |
| 145 | bool hasVisualFocus() const; |
| 146 | |
| 147 | bool isHovered() const; |
| 148 | void setHovered(bool hovered); |
| 149 | |
| 150 | bool isHoverEnabled() const; |
| 151 | void setHoverEnabled(bool enabled); |
| 152 | void resetHoverEnabled(); |
| 153 | |
| 154 | bool isWheelEnabled() const; |
| 155 | void setWheelEnabled(bool enabled); |
| 156 | |
| 157 | QQuickItem *background() const; |
| 158 | void setBackground(QQuickItem *background); |
| 159 | |
| 160 | QQuickItem *contentItem() const; |
| 161 | void setContentItem(QQuickItem *item); |
| 162 | |
| 163 | qreal baselineOffset() const; |
| 164 | void setBaselineOffset(qreal offset); |
| 165 | void resetBaselineOffset(); |
| 166 | |
| 167 | // 2.3 (Qt 5.10) |
| 168 | QPalette palette() const; |
| 169 | void setPalette(const QPalette &palette); |
| 170 | void resetPalette(); |
| 171 | |
| 172 | // 2.5 (Qt 5.12) |
| 173 | qreal horizontalPadding() const; |
| 174 | void setHorizontalPadding(qreal padding); |
| 175 | void resetHorizontalPadding(); |
| 176 | |
| 177 | qreal verticalPadding() const; |
| 178 | void setVerticalPadding(qreal padding); |
| 179 | void resetVerticalPadding(); |
| 180 | |
| 181 | qreal implicitContentWidth() const; |
| 182 | qreal implicitContentHeight() const; |
| 183 | |
| 184 | qreal implicitBackgroundWidth() const; |
| 185 | qreal implicitBackgroundHeight() const; |
| 186 | |
| 187 | qreal topInset() const; |
| 188 | void setTopInset(qreal inset); |
| 189 | void resetTopInset(); |
| 190 | |
| 191 | qreal leftInset() const; |
| 192 | void setLeftInset(qreal inset); |
| 193 | void resetLeftInset(); |
| 194 | |
| 195 | qreal rightInset() const; |
| 196 | void setRightInset(qreal inset); |
| 197 | void resetRightInset(); |
| 198 | |
| 199 | qreal bottomInset() const; |
| 200 | void setBottomInset(qreal inset); |
| 201 | void resetBottomInset(); |
| 202 | |
| 203 | Q_SIGNALS: |
| 204 | void fontChanged(); |
| 205 | void availableWidthChanged(); |
| 206 | void availableHeightChanged(); |
| 207 | void paddingChanged(); |
| 208 | void topPaddingChanged(); |
| 209 | void leftPaddingChanged(); |
| 210 | void rightPaddingChanged(); |
| 211 | void bottomPaddingChanged(); |
| 212 | void spacingChanged(); |
| 213 | void localeChanged(); |
| 214 | void mirroredChanged(); |
| 215 | void focusPolicyChanged(); |
| 216 | void focusReasonChanged(); |
| 217 | void visualFocusChanged(); |
| 218 | void hoveredChanged(); |
| 219 | void hoverEnabledChanged(); |
| 220 | void wheelEnabledChanged(); |
| 221 | void backgroundChanged(); |
| 222 | void contentItemChanged(); |
| 223 | void baselineOffsetChanged(); |
| 224 | // 2.3 (Qt 5.10) |
| 225 | Q_REVISION(3) void paletteChanged(); |
| 226 | // 2.5 (Qt 5.12) |
| 227 | Q_REVISION(5) void horizontalPaddingChanged(); |
| 228 | Q_REVISION(5) void verticalPaddingChanged(); |
| 229 | Q_REVISION(5) void implicitContentWidthChanged(); |
| 230 | Q_REVISION(5) void implicitContentHeightChanged(); |
| 231 | Q_REVISION(5) void implicitBackgroundWidthChanged(); |
| 232 | Q_REVISION(5) void implicitBackgroundHeightChanged(); |
| 233 | Q_REVISION(5) void topInsetChanged(); |
| 234 | Q_REVISION(5) void leftInsetChanged(); |
| 235 | Q_REVISION(5) void rightInsetChanged(); |
| 236 | Q_REVISION(5) void bottomInsetChanged(); |
| 237 | |
| 238 | protected: |
| 239 | virtual QFont defaultFont() const; |
| 240 | virtual QPalette defaultPalette() const; |
| 241 | |
| 242 | QQuickControl(QQuickControlPrivate &dd, QQuickItem *parent); |
| 243 | |
| 244 | void classBegin() override; |
| 245 | void componentComplete() override; |
| 246 | |
| 247 | void itemChange(ItemChange change, const ItemChangeData &value) override; |
| 248 | |
| 249 | void focusInEvent(QFocusEvent *event) override; |
| 250 | void focusOutEvent(QFocusEvent *event) override; |
| 251 | #if QT_CONFIG(quicktemplates2_hover) |
| 252 | void hoverEnterEvent(QHoverEvent *event) override; |
| 253 | void hoverMoveEvent(QHoverEvent *event) override; |
| 254 | void hoverLeaveEvent(QHoverEvent *event) override; |
| 255 | #endif |
| 256 | void mousePressEvent(QMouseEvent *event) override; |
| 257 | void mouseMoveEvent(QMouseEvent *event) override; |
| 258 | void mouseReleaseEvent(QMouseEvent *event) override; |
| 259 | void mouseUngrabEvent() override; |
| 260 | #if QT_CONFIG(quicktemplates2_multitouch) |
| 261 | void touchEvent(QTouchEvent *event) override; |
| 262 | void touchUngrabEvent() override; |
| 263 | #endif |
| 264 | #if QT_CONFIG(wheelevent) |
| 265 | void wheelEvent(QWheelEvent *event) override; |
| 266 | #endif |
| 267 | |
| 268 | void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; |
| 269 | |
| 270 | virtual void fontChange(const QFont &newFont, const QFont &oldFont); |
| 271 | #if QT_CONFIG(quicktemplates2_hover) |
| 272 | virtual void hoverChange(); |
| 273 | #endif |
| 274 | virtual void mirrorChange(); |
| 275 | virtual void spacingChange(qreal newSpacing, qreal oldSpacing); |
| 276 | virtual void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding); |
| 277 | virtual void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem); |
| 278 | virtual void localeChange(const QLocale &newLocale, const QLocale &oldLocale); |
| 279 | virtual void paletteChange(const QPalette &newPalette, const QPalette &oldPalette); |
| 280 | virtual void insetChange(const QMarginsF &newInset, const QMarginsF &oldInset); |
| 281 | virtual void enabledChange(); |
| 282 | |
| 283 | #if QT_CONFIG(accessibility) |
| 284 | virtual QAccessible::Role accessibleRole() const; |
| 285 | virtual void accessibilityActiveChanged(bool active); |
| 286 | #endif |
| 287 | |
| 288 | // helper functions which avoid to check QT_CONFIG(accessibility) |
| 289 | QString accessibleName() const; |
| 290 | void maybeSetAccessibleName(const QString &name); |
| 291 | |
| 292 | QVariant accessibleProperty(const char *propertyName); |
| 293 | bool setAccessibleProperty(const char *propertyName, const QVariant &value); |
| 294 | |
| 295 | private: |
| 296 | Q_DISABLE_COPY(QQuickControl) |
| 297 | Q_DECLARE_PRIVATE(QQuickControl) |
| 298 | }; |
| 299 | |
| 300 | QT_END_NAMESPACE |
| 301 | |
| 302 | QML_DECLARE_TYPE(QQuickControl) |
| 303 | |
| 304 | #endif // QQUICKCONTROL_P_H |
| 305 | |