aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@theqtcompany.com>2016-04-26 15:51:50 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-04-27 16:02:50 +0000
commitd6b32468667a4890cef6061f08c353a0d0cba43e (patch)
tree270287bd5725b4de6a8edc1b2809eb4adbd51e65 /src/quicktemplates2
parent9e79b19a305960a3df7bd1c90675ba00cd972153 (diff)
Move highlighted to subclasses that actually use it
Change-Id: I70468b35b2a3a03c6e2d557a67443291697c8b42 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r--src/quicktemplates2/qquickabstractbutton.cpp28
-rw-r--r--src/quicktemplates2/qquickabstractbutton_p.h5
-rw-r--r--src/quicktemplates2/qquickabstractbutton_p_p.h1
-rw-r--r--src/quicktemplates2/qquickbutton.cpp44
-rw-r--r--src/quicktemplates2/qquickbutton_p.h11
-rw-r--r--src/quicktemplates2/qquickcheckdelegate.cpp4
-rw-r--r--src/quicktemplates2/qquickitemdelegate.cpp37
-rw-r--r--src/quicktemplates2/qquickitemdelegate_p.h15
-rw-r--r--src/quicktemplates2/qquickitemdelegate_p_p.h67
-rw-r--r--src/quicktemplates2/qquickmenuitem.cpp43
-rw-r--r--src/quicktemplates2/qquickmenuitem_p.h5
-rw-r--r--src/quicktemplates2/qquickswipedelegate.cpp4
-rw-r--r--src/quicktemplates2/qquickswitchdelegate.cpp4
-rw-r--r--src/quicktemplates2/quicktemplates2.pri1
14 files changed, 225 insertions, 44 deletions
diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp
index 9cfd9b40..68d11bae 100644
--- a/src/quicktemplates2/qquickabstractbutton.cpp
+++ b/src/quicktemplates2/qquickabstractbutton.cpp
@@ -105,7 +105,7 @@ static const int AUTO_REPEAT_INTERVAL = 100;
QQuickAbstractButtonPrivate::QQuickAbstractButtonPrivate() :
down(false), explicitDown(false), pressed(false), checked(false), checkable(false),
- highlighted(false), autoExclusive(false), autoRepeat(false), wasHeld(false),
+ autoExclusive(false), autoRepeat(false), wasHeld(false),
holdTimer(0), delayTimer(0), repeatTimer(0), repeatButton(Qt::NoButton), indicator(nullptr), group(nullptr)
{
}
@@ -374,32 +374,6 @@ void QQuickAbstractButton::setCheckable(bool checkable)
}
/*!
- \qmlproperty bool QtQuick.Controls::AbstractButton::highlighted
-
- This property holds whether the button is highlighted.
-
- A button can be highlighted in order to draw the user's attention towards
- it. It has no effect on keyboard interaction.
-
- The default value is \c false.
-*/
-bool QQuickAbstractButton::isHighlighted() const
-{
- Q_D(const QQuickAbstractButton);
- return d->highlighted;
-}
-
-void QQuickAbstractButton::setHighlighted(bool highlighted)
-{
- Q_D(QQuickAbstractButton);
- if (highlighted == d->highlighted)
- return;
-
- d->highlighted = highlighted;
- emit highlightedChanged();
-}
-
-/*!
\qmlproperty bool QtQuick.Controls::AbstractButton::autoExclusive
This property holds whether auto-exclusivity is enabled.
diff --git a/src/quicktemplates2/qquickabstractbutton_p.h b/src/quicktemplates2/qquickabstractbutton_p.h
index f23d29f3..779739de 100644
--- a/src/quicktemplates2/qquickabstractbutton_p.h
+++ b/src/quicktemplates2/qquickabstractbutton_p.h
@@ -61,7 +61,6 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickAbstractButton : public QQuickContr
Q_PROPERTY(bool down READ isDown WRITE setDown NOTIFY downChanged RESET resetDown FINAL)
Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged FINAL)
Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY checkedChanged FINAL)
- Q_PROPERTY(bool highlighted READ isHighlighted WRITE setHighlighted NOTIFY highlightedChanged FINAL)
Q_PROPERTY(bool autoExclusive READ autoExclusive WRITE setAutoExclusive NOTIFY autoExclusiveChanged FINAL)
Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL)
@@ -85,9 +84,6 @@ public:
bool isCheckable() const;
void setCheckable(bool checkable);
- bool isHighlighted() const;
- void setHighlighted(bool highlighted);
-
bool autoExclusive() const;
void setAutoExclusive(bool exclusive);
@@ -111,7 +107,6 @@ Q_SIGNALS:
void downChanged();
void pressedChanged();
void checkedChanged();
- void highlightedChanged();
void autoExclusiveChanged();
void indicatorChanged();
diff --git a/src/quicktemplates2/qquickabstractbutton_p_p.h b/src/quicktemplates2/qquickabstractbutton_p_p.h
index 7aa2c028..e690bbd0 100644
--- a/src/quicktemplates2/qquickabstractbutton_p_p.h
+++ b/src/quicktemplates2/qquickabstractbutton_p_p.h
@@ -84,7 +84,6 @@ public:
bool pressed;
bool checked;
bool checkable;
- bool highlighted;
bool autoExclusive;
bool autoRepeat;
bool wasHeld;
diff --git a/src/quicktemplates2/qquickbutton.cpp b/src/quicktemplates2/qquickbutton.cpp
index 5f702818..cb5b2963 100644
--- a/src/quicktemplates2/qquickbutton.cpp
+++ b/src/quicktemplates2/qquickbutton.cpp
@@ -90,7 +90,23 @@ QT_BEGIN_NAMESPACE
\sa {Customizing Button}, {Button Controls}
*/
-QQuickButton::QQuickButton(QQuickItem *parent) : QQuickAbstractButton(parent)
+class QQuickButtonPrivate : public QQuickAbstractButtonPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickButton)
+
+public:
+ QQuickButtonPrivate();
+
+ bool highlighted;
+};
+
+QQuickButtonPrivate::QQuickButtonPrivate() :
+ highlighted(false)
+{
+}
+
+QQuickButton::QQuickButton(QQuickItem *parent) :
+ QQuickAbstractButton(*(new QQuickButtonPrivate), parent)
{
}
@@ -124,4 +140,30 @@ QFont QQuickButton::defaultFont() const
return QQuickControlPrivate::themeFont(QPlatformTheme::PushButtonFont);
}
+/*!
+ \qmlproperty bool QtQuick.Controls::Button::highlighted
+
+ This property holds whether the button is highlighted.
+
+ A button can be highlighted in order to draw the user's attention towards
+ it. It has no effect on keyboard interaction.
+
+ The default value is \c false.
+*/
+bool QQuickButton::isHighlighted() const
+{
+ Q_D(const QQuickButton);
+ return d->highlighted;
+}
+
+void QQuickButton::setHighlighted(bool highlighted)
+{
+ Q_D(QQuickButton);
+ if (highlighted == d->highlighted)
+ return;
+
+ d->highlighted = highlighted;
+ emit highlightedChanged();
+}
+
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickbutton_p.h b/src/quicktemplates2/qquickbutton_p.h
index a98bbe78..36eb4359 100644
--- a/src/quicktemplates2/qquickbutton_p.h
+++ b/src/quicktemplates2/qquickbutton_p.h
@@ -52,24 +52,35 @@
QT_BEGIN_NAMESPACE
+class QQuickButtonPrivate;
+
class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickButton : public QQuickAbstractButton
{
Q_OBJECT
Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged FINAL)
Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat NOTIFY autoRepeatChanged FINAL)
+ Q_PROPERTY(bool highlighted READ isHighlighted WRITE setHighlighted NOTIFY highlightedChanged FINAL)
public:
explicit QQuickButton(QQuickItem *parent = nullptr);
+ bool isHighlighted() const;
+ void setHighlighted(bool highlighted);
+
Q_SIGNALS:
void checkableChanged();
void autoRepeatChanged();
+ void highlightedChanged();
protected:
void checkableChange() override;
void autoRepeatChange() override;
QFont defaultFont() const override;
+
+private:
+ Q_DISABLE_COPY(QQuickButton)
+ Q_DECLARE_PRIVATE(QQuickButton)
};
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickcheckdelegate.cpp b/src/quicktemplates2/qquickcheckdelegate.cpp
index 9d0a0cfb..f21da57c 100644
--- a/src/quicktemplates2/qquickcheckdelegate.cpp
+++ b/src/quicktemplates2/qquickcheckdelegate.cpp
@@ -35,7 +35,7 @@
****************************************************************************/
#include "qquickcheckdelegate_p.h"
-#include "qquickabstractbutton_p_p.h"
+#include "qquickitemdelegate_p_p.h"
#include <QtGui/qpa/qplatformtheme.h>
@@ -77,7 +77,7 @@ QT_BEGIN_NAMESPACE
\sa {Customizing CheckDelegate}, {Delegate Controls}
*/
-class QQuickCheckDelegatePrivate : public QQuickAbstractButtonPrivate
+class QQuickCheckDelegatePrivate : public QQuickItemDelegatePrivate
{
Q_DECLARE_PUBLIC(QQuickCheckDelegate)
diff --git a/src/quicktemplates2/qquickitemdelegate.cpp b/src/quicktemplates2/qquickitemdelegate.cpp
index b2719095..9ff068f1 100644
--- a/src/quicktemplates2/qquickitemdelegate.cpp
+++ b/src/quicktemplates2/qquickitemdelegate.cpp
@@ -35,6 +35,7 @@
****************************************************************************/
#include "qquickitemdelegate_p.h"
+#include "qquickitemdelegate_p_p.h"
#include "qquickcontrol_p_p.h"
#include <QtGui/qpa/qplatformtheme.h>
@@ -62,17 +63,49 @@ QT_BEGIN_NAMESPACE
\sa {Customizing ItemDelegate}, {Delegate Controls}
*/
-QQuickItemDelegate::QQuickItemDelegate(QQuickItem *parent) : QQuickAbstractButton(parent)
+QQuickItemDelegatePrivate::QQuickItemDelegatePrivate() :
+ highlighted(false)
+{
+}
+
+QQuickItemDelegate::QQuickItemDelegate(QQuickItem *parent) :
+ QQuickAbstractButton(*(new QQuickItemDelegatePrivate), parent)
{
setFocusPolicy(Qt::NoFocus);
}
-QQuickItemDelegate::QQuickItemDelegate(QQuickAbstractButtonPrivate &dd, QQuickItem *parent) :
+QQuickItemDelegate::QQuickItemDelegate(QQuickItemDelegatePrivate &dd, QQuickItem *parent) :
QQuickAbstractButton(dd, parent)
{
setFocusPolicy(Qt::NoFocus);
}
+/*!
+ \qmlproperty bool QtQuick.Controls::ItemDelegate::highlighted
+
+ This property holds whether the delegate is highlighted.
+
+ A delegate can be highlighted in order to draw the user's attention towards
+ it. It has no effect on keyboard interaction.
+
+ The default value is \c false.
+*/
+bool QQuickItemDelegate::isHighlighted() const
+{
+ Q_D(const QQuickItemDelegate);
+ return d->highlighted;
+}
+
+void QQuickItemDelegate::setHighlighted(bool highlighted)
+{
+ Q_D(QQuickItemDelegate);
+ if (highlighted == d->highlighted)
+ return;
+
+ d->highlighted = highlighted;
+ emit highlightedChanged();
+}
+
QFont QQuickItemDelegate::defaultFont() const
{
return QQuickControlPrivate::themeFont(QPlatformTheme::ItemViewFont);
diff --git a/src/quicktemplates2/qquickitemdelegate_p.h b/src/quicktemplates2/qquickitemdelegate_p.h
index 205407a0..429b0ca9 100644
--- a/src/quicktemplates2/qquickitemdelegate_p.h
+++ b/src/quicktemplates2/qquickitemdelegate_p.h
@@ -52,13 +52,22 @@
QT_BEGIN_NAMESPACE
+class QQuickItemDelegatePrivate;
+
class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickItemDelegate : public QQuickAbstractButton
{
Q_OBJECT
+ Q_PROPERTY(bool highlighted READ isHighlighted WRITE setHighlighted NOTIFY highlightedChanged FINAL)
public:
explicit QQuickItemDelegate(QQuickItem *parent = nullptr);
+ bool isHighlighted() const;
+ void setHighlighted(bool highlighted);
+
+Q_SIGNALS:
+ void highlightedChanged();
+
protected:
QFont defaultFont() const override;
@@ -67,7 +76,11 @@ protected:
#endif
protected:
- QQuickItemDelegate(QQuickAbstractButtonPrivate &dd, QQuickItem *parent);
+ QQuickItemDelegate(QQuickItemDelegatePrivate &dd, QQuickItem *parent);
+
+private:
+ Q_DISABLE_COPY(QQuickItemDelegate)
+ Q_DECLARE_PRIVATE(QQuickItemDelegate)
};
QT_END_NAMESPACE
diff --git a/src/quicktemplates2/qquickitemdelegate_p_p.h b/src/quicktemplates2/qquickitemdelegate_p_p.h
new file mode 100644
index 00000000..c69f3d46
--- /dev/null
+++ b/src/quicktemplates2/qquickitemdelegate_p_p.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the Qt Quick Templates 2 module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL3$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPLv3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or later as published by the Free
+** Software Foundation and appearing in the file LICENSE.GPL included in
+** the packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 2.0 requirements will be
+** met: http://www.gnu.org/licenses/gpl-2.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKITEMDELEGATE_P_P_H
+#define QQUICKITEMDELEGATE_P_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtQuickTemplates2/private/qquickabstractbutton_p_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQuickItemDelegatePrivate : public QQuickAbstractButtonPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickItemDelegate)
+
+public:
+ QQuickItemDelegatePrivate();
+
+ bool highlighted;
+};
+
+QT_END_NAMESPACE
+
+#endif // QQUICKITEMDELEGATE_P_P_H
diff --git a/src/quicktemplates2/qquickmenuitem.cpp b/src/quicktemplates2/qquickmenuitem.cpp
index d9740910..7c9ede7d 100644
--- a/src/quicktemplates2/qquickmenuitem.cpp
+++ b/src/quicktemplates2/qquickmenuitem.cpp
@@ -78,6 +78,21 @@ QT_BEGIN_NAMESPACE
\sa {Customizing MenuItem}, {Menu Controls}
*/
+class QQuickMenuItemPrivate : public QQuickAbstractButtonPrivate
+{
+ Q_DECLARE_PUBLIC(QQuickMenuItem)
+
+public:
+ QQuickMenuItemPrivate();
+
+ bool highlighted;
+};
+
+QQuickMenuItemPrivate::QQuickMenuItemPrivate() :
+ highlighted(false)
+{
+}
+
/*!
\qmlsignal void QtQuick.Controls::MenuItem::triggered()
@@ -85,7 +100,7 @@ QT_BEGIN_NAMESPACE
*/
QQuickMenuItem::QQuickMenuItem(QQuickItem *parent) :
- QQuickAbstractButton(parent)
+ QQuickAbstractButton(*(new QQuickMenuItemPrivate), parent)
{
connect(this, &QQuickAbstractButton::clicked, this, &QQuickMenuItem::triggered);
}
@@ -106,6 +121,32 @@ QFont QQuickMenuItem::defaultFont() const
return QQuickControlPrivate::themeFont(QPlatformTheme::MenuItemFont);
}
+/*!
+ \qmlproperty bool QtQuick.Controls::MenuItem::highlighted
+
+ This property holds whether the menu item is highlighted.
+
+ A menu item can be highlighted in order to draw the user's attention
+ towards it. It has no effect on keyboard interaction.
+
+ The default value is \c false.
+*/
+bool QQuickMenuItem::isHighlighted() const
+{
+ Q_D(const QQuickMenuItem);
+ return d->highlighted;
+}
+
+void QQuickMenuItem::setHighlighted(bool highlighted)
+{
+ Q_D(QQuickMenuItem);
+ if (highlighted == d->highlighted)
+ return;
+
+ d->highlighted = highlighted;
+ emit highlightedChanged();
+}
+
#ifndef QT_NO_ACCESSIBILITY
QAccessible::Role QQuickMenuItem::accessibleRole() const
{
diff --git a/src/quicktemplates2/qquickmenuitem_p.h b/src/quicktemplates2/qquickmenuitem_p.h
index b99fdef3..6c717e13 100644
--- a/src/quicktemplates2/qquickmenuitem_p.h
+++ b/src/quicktemplates2/qquickmenuitem_p.h
@@ -58,13 +58,18 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickMenuItem : public QQuickAbstractBut
{
Q_OBJECT
Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged FINAL)
+ Q_PROPERTY(bool highlighted READ isHighlighted WRITE setHighlighted NOTIFY highlightedChanged FINAL)
public:
explicit QQuickMenuItem(QQuickItem *parent = nullptr);
+ bool isHighlighted() const;
+ void setHighlighted(bool highlighted);
+
Q_SIGNALS:
void checkableChanged();
void triggered();
+ void highlightedChanged();
protected:
void checkableChange() override;
diff --git a/src/quicktemplates2/qquickswipedelegate.cpp b/src/quicktemplates2/qquickswipedelegate.cpp
index 9156d7a3..ed01ea28 100644
--- a/src/quicktemplates2/qquickswipedelegate.cpp
+++ b/src/quicktemplates2/qquickswipedelegate.cpp
@@ -36,7 +36,7 @@
#include "qquickswipedelegate_p.h"
#include "qquickcontrol_p_p.h"
-#include "qquickabstractbutton_p_p.h"
+#include "qquickitemdelegate_p_p.h"
#include "qquickvelocitycalculator_p_p.h"
#include <QtGui/qstylehints.h>
@@ -521,7 +521,7 @@ void QQuickSwipeExposure::setActive(bool active)
emit activeChanged();
}
-class QQuickSwipeDelegatePrivate : public QQuickAbstractButtonPrivate
+class QQuickSwipeDelegatePrivate : public QQuickItemDelegatePrivate
{
Q_DECLARE_PUBLIC(QQuickSwipeDelegate)
diff --git a/src/quicktemplates2/qquickswitchdelegate.cpp b/src/quicktemplates2/qquickswitchdelegate.cpp
index adaf10c3..190152b8 100644
--- a/src/quicktemplates2/qquickswitchdelegate.cpp
+++ b/src/quicktemplates2/qquickswitchdelegate.cpp
@@ -36,7 +36,7 @@
#include "qquickswitchdelegate_p.h"
-#include "qquickabstractbutton_p_p.h"
+#include "qquickitemdelegate_p_p.h"
QT_BEGIN_NAMESPACE
@@ -69,7 +69,7 @@ QT_BEGIN_NAMESPACE
\sa {Customizing SwitchDelegate}, {Delegate Controls}
*/
-class QQuickSwitchDelegatePrivate : public QQuickAbstractButtonPrivate
+class QQuickSwitchDelegatePrivate : public QQuickItemDelegatePrivate
{
Q_DECLARE_PUBLIC(QQuickSwitchDelegate)
diff --git a/src/quicktemplates2/quicktemplates2.pri b/src/quicktemplates2/quicktemplates2.pri
index e16d8b69..173112d3 100644
--- a/src/quicktemplates2/quicktemplates2.pri
+++ b/src/quicktemplates2/quicktemplates2.pri
@@ -20,6 +20,7 @@ HEADERS += \
$$PWD/qquickframe_p_p.h \
$$PWD/qquickgroupbox_p.h \
$$PWD/qquickitemdelegate_p.h \
+ $$PWD/qquickitemdelegate_p_p.h \
$$PWD/qquicklabel_p.h \
$$PWD/qquicklabel_p_p.h \
$$PWD/qquickmenu_p.h \