aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-02-06 10:05:15 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2017-02-06 11:32:17 +0000
commitedf92fed9017a594fde8c6c6f634bb1386a6bdd3 (patch)
tree292eb86e3d3bdf7e3f078dc21196310949c775b5
parentdd773d99d2e7ce94e2cef503e80caafc079b1acd (diff)
Add "hover support" configure feature
./configure -no-feature-quicktemplates2-hover [...] Qt Quick Templates 2: Hover support .......................... no Change-Id: I0509a1a9ac3ffe2cbfe4f2016ce0345708860b84 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--.gitignore4
-rw-r--r--configure.json5
-rw-r--r--src/quicktemplates2/configure.json20
-rw-r--r--src/quicktemplates2/qquickcontrol.cpp36
-rw-r--r--src/quicktemplates2/qquickcontrol_p.h4
-rw-r--r--src/quicktemplates2/qquickcontrol_p_p.h6
-rw-r--r--src/quicktemplates2/qquickoverlay.cpp2
-rw-r--r--src/quicktemplates2/qquickpopupitem.cpp2
-rw-r--r--src/quicktemplates2/qquickscrollbar.cpp9
-rw-r--r--src/quicktemplates2/qquickscrollbar_p.h2
-rw-r--r--src/quicktemplates2/qquicktextarea.cpp32
-rw-r--r--src/quicktemplates2/qquicktextarea_p.h2
-rw-r--r--src/quicktemplates2/qquicktextarea_p_p.h4
-rw-r--r--src/quicktemplates2/qquicktextfield.cpp31
-rw-r--r--src/quicktemplates2/qquicktextfield_p.h2
-rw-r--r--src/quicktemplates2/qquicktextfield_p_p.h4
-rw-r--r--src/quicktemplates2/qtquicktemplates2global_p.h1
17 files changed, 160 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index dac53591..5de4c876 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,10 @@
/mkspecs
/doc
+/src/quicktemplates2/qtquicktemplates2-config.h
+/src/quicktemplates2/qtquicktemplates2-config.pri
+/src/quicktemplates2/qtquicktemplates2-config_p.h
+
/examples/quickcontrols2/chattutorial/chapter1-settingup/chapter1-settingup
/examples/quickcontrols2/chattutorial/chapter2-lists/chapter2-lists
/examples/quickcontrols2/chattutorial/chapter3-navigation/chapter3-navigation
diff --git a/configure.json b/configure.json
new file mode 100644
index 00000000..5378d2d7
--- /dev/null
+++ b/configure.json
@@ -0,0 +1,5 @@
+{
+ "subconfigs": [
+ "src/quicktemplates2"
+ ]
+}
diff --git a/src/quicktemplates2/configure.json b/src/quicktemplates2/configure.json
new file mode 100644
index 00000000..c262b035
--- /dev/null
+++ b/src/quicktemplates2/configure.json
@@ -0,0 +1,20 @@
+{
+ "module": "quicktemplates2",
+
+ "features": {
+ "quicktemplates2-hover": {
+ "label": "Hover support",
+ "purpose": "Support hover effects",
+ "output": [ "privateFeature" ]
+ }
+ },
+
+ "summary": [
+ {
+ "section": "Qt Quick Templates 2",
+ "entries": [
+ "quicktemplates2-hover"
+ ]
+ }
+ ]
+}
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp
index 2f327e34..57191b71 100644
--- a/src/quicktemplates2/qquickcontrol.cpp
+++ b/src/quicktemplates2/qquickcontrol.cpp
@@ -114,9 +114,11 @@ QQuickControlPrivate::QQuickControlPrivate()
hasRightPadding(false),
hasBottomPadding(false),
hasLocale(false),
- hovered(false),
wheelEnabled(false),
+#if QT_CONFIG(quicktemplates2_hover)
+ hovered(false),
explicitHoverEnabled(false),
+#endif
padding(0),
topPadding(0),
leftPadding(0),
@@ -376,6 +378,7 @@ void QQuickControlPrivate::updateFontRecur(QQuickItem *item, const QFont &f)
}
}
+#if QT_CONFIG(quicktemplates2_hover)
void QQuickControlPrivate::updateHoverEnabled(bool enabled, bool xplicit)
{
Q_Q(QQuickControl);
@@ -431,6 +434,7 @@ bool QQuickControlPrivate::calcHoverEnabled(const QQuickItem *item)
return QGuiApplication::styleHints()->useHoverEffects();
}
+#endif
QString QQuickControl::accessibleName() const
{
@@ -492,16 +496,20 @@ void QQuickControl::itemChange(QQuickItem::ItemChange change, const QQuickItem::
QQuickItem::itemChange(change, value);
switch (change) {
case ItemVisibleHasChanged:
+#if QT_CONFIG(quicktemplates2_hover)
if (!value.boolValue)
setHovered(false);
+#endif
break;
case ItemParentHasChanged:
if (value.item) {
d->resolveFont();
if (!d->hasLocale)
d->updateLocale(QQuickControlPrivate::calcLocale(d->parentItem), false); // explicit=false
+#if QT_CONFIG(quicktemplates2_hover)
if (!d->explicitHoverEnabled)
d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false
+#endif
}
break;
case ItemActiveFocusHasChanged:
@@ -1005,12 +1013,17 @@ bool QQuickControl::hasVisualFocus() const
*/
bool QQuickControl::isHovered() const
{
+#if QT_CONFIG(quicktemplates2_hover)
Q_D(const QQuickControl);
return d->hovered;
+#else
+ return false;
+#endif
}
void QQuickControl::setHovered(bool hovered)
{
+#if QT_CONFIG(quicktemplates2_hover)
Q_D(QQuickControl);
if (hovered == d->hovered)
return;
@@ -1018,6 +1031,9 @@ void QQuickControl::setHovered(bool hovered)
d->hovered = hovered;
emit hoveredChanged();
hoverChange();
+#else
+ Q_UNUSED(hovered);
+#endif
}
/*!
@@ -1037,27 +1053,37 @@ void QQuickControl::setHovered(bool hovered)
*/
bool QQuickControl::isHoverEnabled() const
{
+#if QT_CONFIG(quicktemplates2_hover)
Q_D(const QQuickControl);
return d->hoverEnabled;
+#else
+ return false;
+#endif
}
void QQuickControl::setHoverEnabled(bool enabled)
{
+#if QT_CONFIG(quicktemplates2_hover)
Q_D(QQuickControl);
if (d->explicitHoverEnabled && enabled == d->hoverEnabled)
return;
d->updateHoverEnabled(enabled, true); // explicit=true
+#else
+ Q_UNUSED(enabled)
+#endif
}
void QQuickControl::resetHoverEnabled()
{
+#if QT_CONFIG(quicktemplates2_hover)
Q_D(QQuickControl);
if (!d->explicitHoverEnabled)
return;
d->explicitHoverEnabled = false;
d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false
+#endif
}
/*!
@@ -1197,8 +1223,10 @@ void QQuickControl::componentComplete()
d->resizeContent();
if (!d->hasLocale)
d->locale = QQuickControlPrivate::calcLocale(d->parentItem);
+#if QT_CONFIG(quicktemplates2_hover)
if (!d->explicitHoverEnabled)
setAcceptHoverEvents(QQuickControlPrivate::calcHoverEnabled(d->parentItem));
+#endif
#ifndef QT_NO_ACCESSIBILITY
if (!d->accessibleAttached && QAccessible::isActive())
accessibilityActiveChanged(true);
@@ -1227,6 +1255,7 @@ void QQuickControl::focusOutEvent(QFocusEvent *event)
setFocusReason(event->reason());
}
+#if QT_CONFIG(quicktemplates2_hover)
void QQuickControl::hoverEnterEvent(QHoverEvent *event)
{
Q_D(QQuickControl);
@@ -1247,6 +1276,7 @@ void QQuickControl::hoverLeaveEvent(QHoverEvent *event)
setHovered(false);
event->setAccepted(d->hoverEnabled);
}
+#endif
void QQuickControl::mousePressEvent(QMouseEvent *event)
{
@@ -1259,8 +1289,10 @@ void QQuickControl::mousePressEvent(QMouseEvent *event)
void QQuickControl::mouseMoveEvent(QMouseEvent *event)
{
+#if QT_CONFIG(quicktemplates2_hover)
Q_D(QQuickControl);
setHovered(d->hoverEnabled && contains(event->pos()));
+#endif
event->accept();
}
@@ -1302,9 +1334,11 @@ void QQuickControl::fontChange(const QFont &newFont, const QFont &oldFont)
Q_UNUSED(oldFont);
}
+#if QT_CONFIG(quicktemplates2_hover)
void QQuickControl::hoverChange()
{
}
+#endif
void QQuickControl::mirrorChange()
{
diff --git a/src/quicktemplates2/qquickcontrol_p.h b/src/quicktemplates2/qquickcontrol_p.h
index 525dd303..bd45a4dd 100644
--- a/src/quicktemplates2/qquickcontrol_p.h
+++ b/src/quicktemplates2/qquickcontrol_p.h
@@ -176,9 +176,11 @@ protected:
void focusInEvent(QFocusEvent *event) override;
void focusOutEvent(QFocusEvent *event) override;
+#if QT_CONFIG(quicktemplates2_hover)
void hoverEnterEvent(QHoverEvent *event) override;
void hoverMoveEvent(QHoverEvent *event) override;
void hoverLeaveEvent(QHoverEvent *event) override;
+#endif
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
@@ -189,7 +191,9 @@ protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
virtual void fontChange(const QFont &newFont, const QFont &oldFont);
+#if QT_CONFIG(quicktemplates2_hover)
virtual void hoverChange();
+#endif
virtual void mirrorChange();
virtual void spacingChange(qreal newSpacing, qreal oldSpacing);
virtual void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding);
diff --git a/src/quicktemplates2/qquickcontrol_p_p.h b/src/quicktemplates2/qquickcontrol_p_p.h
index 2cecfc84..029bb1e9 100644
--- a/src/quicktemplates2/qquickcontrol_p_p.h
+++ b/src/quicktemplates2/qquickcontrol_p_p.h
@@ -111,9 +111,11 @@ public:
static void updateLocaleRecur(QQuickItem *item, const QLocale &l);
static QLocale calcLocale(const QQuickItem *item);
+#if QT_CONFIG(quicktemplates2_hover)
void updateHoverEnabled(bool enabled, bool xplicit);
static void updateHoverEnabledRecur(QQuickItem *item, bool enabled);
static bool calcHoverEnabled(const QQuickItem *item);
+#endif
void deleteDelegate(QObject *object);
@@ -133,9 +135,11 @@ public:
bool hasRightPadding;
bool hasBottomPadding;
bool hasLocale;
- bool hovered;
bool wheelEnabled;
+#if QT_CONFIG(quicktemplates2_hover)
+ bool hovered;
bool explicitHoverEnabled;
+#endif
qreal padding;
qreal topPadding;
qreal leftPadding;
diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp
index 72506543..e3910509 100644
--- a/src/quicktemplates2/qquickoverlay.cpp
+++ b/src/quicktemplates2/qquickoverlay.cpp
@@ -97,10 +97,12 @@ static QQuickItem *createDimmer(QQmlComponent *component, QQuickPopup *popup, QQ
item->setZ(popup->z());
if (popup->isModal()) {
item->setAcceptedMouseButtons(Qt::AllButtons);
+#if QT_CONFIG(quicktemplates2_hover)
// TODO: switch to QStyleHints::useHoverEffects in Qt 5.8
item->setAcceptHoverEvents(true);
// item->setAcceptHoverEvents(QGuiApplication::styleHints()->useHoverEffects());
// connect(QGuiApplication::styleHints(), &QStyleHints::useHoverEffectsChanged, item, &QQuickItem::setAcceptHoverEvents);
+#endif
}
if (component)
component->completeCreate();
diff --git a/src/quicktemplates2/qquickpopupitem.cpp b/src/quicktemplates2/qquickpopupitem.cpp
index 60a4a6ee..37d755cb 100644
--- a/src/quicktemplates2/qquickpopupitem.cpp
+++ b/src/quicktemplates2/qquickpopupitem.cpp
@@ -106,10 +106,12 @@ QQuickPopupItem::QQuickPopupItem(QQuickPopup *popup)
setFlag(ItemIsFocusScope);
setAcceptedMouseButtons(Qt::AllButtons);
+#if QT_CONFIG(quicktemplates2_hover)
// TODO: switch to QStyleHints::useHoverEffects in Qt 5.8
setHoverEnabled(true);
// setAcceptHoverEvents(QGuiApplication::styleHints()->useHoverEffects());
// connect(QGuiApplication::styleHints(), &QStyleHints::useHoverEffectsChanged, this, &QQuickItem::setAcceptHoverEvents);
+#endif
}
void QQuickPopupItem::grabShortcut()
diff --git a/src/quicktemplates2/qquickscrollbar.cpp b/src/quicktemplates2/qquickscrollbar.cpp
index 1ad14e9d..bfdc45d4 100644
--- a/src/quicktemplates2/qquickscrollbar.cpp
+++ b/src/quicktemplates2/qquickscrollbar.cpp
@@ -205,7 +205,12 @@ void QQuickScrollBarPrivate::setInteractive(bool enabled)
void QQuickScrollBarPrivate::updateActive()
{
Q_Q(QQuickScrollBar);
- q->setActive(moving || (interactive && (pressed || hovered)));
+#if QT_CONFIG(quicktemplates2_hover)
+ bool hover = hovered;
+#else
+ bool hover = false;
+#endif
+ q->setActive(moving || (interactive && (pressed || hover)));
}
void QQuickScrollBarPrivate::resizeContent()
@@ -599,11 +604,13 @@ void QQuickScrollBar::mouseUngrabEvent()
d->handleUngrab();
}
+#if QT_CONFIG(quicktemplates2_hover)
void QQuickScrollBar::hoverChange()
{
Q_D(QQuickScrollBar);
d->updateActive();
}
+#endif
#ifndef QT_NO_ACCESSIBILITY
void QQuickScrollBar::accessibilityActiveChanged(bool active)
diff --git a/src/quicktemplates2/qquickscrollbar_p.h b/src/quicktemplates2/qquickscrollbar_p.h
index 868cb5d8..eef7d2ff 100644
--- a/src/quicktemplates2/qquickscrollbar_p.h
+++ b/src/quicktemplates2/qquickscrollbar_p.h
@@ -135,7 +135,9 @@ protected:
void mouseReleaseEvent(QMouseEvent *event) override;
void mouseUngrabEvent() override;
+#if QT_CONFIG(quicktemplates2_hover)
void hoverChange() override;
+#endif
#ifndef QT_NO_ACCESSIBILITY
void accessibilityActiveChanged(bool active) override;
diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp
index 573521cf..380ea978 100644
--- a/src/quicktemplates2/qquicktextarea.cpp
+++ b/src/quicktemplates2/qquicktextarea.cpp
@@ -131,8 +131,11 @@ QT_BEGIN_NAMESPACE
*/
QQuickTextAreaPrivate::QQuickTextAreaPrivate()
- : hovered(false),
+ : QQuickTextEditPrivate(),
+#if QT_CONFIG(quicktemplates2_hover)
+ hovered(false),
explicitHoverEnabled(false),
+#endif
background(nullptr),
focusReason(Qt::OtherFocusReason),
accessibleAttached(nullptr),
@@ -201,6 +204,7 @@ void QQuickTextAreaPrivate::inheritFont(const QFont &f)
emit q->fontChanged();
}
+#if QT_CONFIG(quicktemplates2_hover)
void QQuickTextAreaPrivate::updateHoverEnabled(bool enabled, bool xplicit)
{
Q_Q(QQuickTextArea);
@@ -215,6 +219,7 @@ void QQuickTextAreaPrivate::updateHoverEnabled(bool enabled, bool xplicit)
emit q->hoverEnabledChanged();
}
}
+#endif
void QQuickTextAreaPrivate::attachFlickable(QQuickFlickable *item)
{
@@ -518,18 +523,26 @@ void QQuickTextArea::setFocusReason(Qt::FocusReason reason)
*/
bool QQuickTextArea::isHovered() const
{
+#if QT_CONFIG(quicktemplates2_hover)
Q_D(const QQuickTextArea);
return d->hovered;
+#else
+ return false;
+#endif
}
void QQuickTextArea::setHovered(bool hovered)
{
+#if QT_CONFIG(quicktemplates2_hover)
Q_D(QQuickTextArea);
if (hovered == d->hovered)
return;
d->hovered = hovered;
emit hoveredChanged();
+#else
+ Q_UNUSED(hovered);
+#endif
}
/*!
@@ -542,27 +555,37 @@ void QQuickTextArea::setHovered(bool hovered)
*/
bool QQuickTextArea::isHoverEnabled() const
{
+#if QT_CONFIG(quicktemplates2_hover)
Q_D(const QQuickTextArea);
return d->hoverEnabled;
+#else
+ return false;
+#endif
}
void QQuickTextArea::setHoverEnabled(bool enabled)
{
+#if QT_CONFIG(quicktemplates2_hover)
Q_D(QQuickTextArea);
if (d->explicitHoverEnabled && enabled == d->hoverEnabled)
return;
d->updateHoverEnabled(enabled, true); // explicit=true
+#else
+ Q_UNUSED(enabled);
+#endif
}
void QQuickTextArea::resetHoverEnabled()
{
+#if QT_CONFIG(quicktemplates2_hover)
Q_D(QQuickTextArea);
if (!d->explicitHoverEnabled)
return;
d->explicitHoverEnabled = false;
d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false
+#endif
}
bool QQuickTextArea::contains(const QPointF &point) const
@@ -584,8 +607,10 @@ void QQuickTextArea::componentComplete()
{
Q_D(QQuickTextArea);
QQuickTextEdit::componentComplete();
+#if QT_CONFIG(quicktemplates2_hover)
if (!d->explicitHoverEnabled)
setAcceptHoverEvents(QQuickControlPrivate::calcHoverEnabled(d->parentItem));
+#endif
#ifndef QT_NO_ACCESSIBILITY
if (!d->accessibleAttached && QAccessible::isActive())
d->accessibilityActiveChanged(true);
@@ -601,9 +626,10 @@ void QQuickTextArea::itemChange(QQuickItem::ItemChange change, const QQuickItem:
QQuickTextEdit::itemChange(change, value);
if (change == ItemParentHasChanged && value.item) {
d->resolveFont();
+#if QT_CONFIG(quicktemplates2_hover)
if (!d->explicitHoverEnabled)
d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false
-
+#endif
QQuickFlickable *flickable = qobject_cast<QQuickFlickable *>(value.item->parentItem());
if (flickable) {
QQuickScrollView *scrollView = qobject_cast<QQuickScrollView *>(flickable->parentItem());
@@ -660,6 +686,7 @@ void QQuickTextArea::focusOutEvent(QFocusEvent *event)
setFocusReason(event->reason());
}
+#if QT_CONFIG(quicktemplates2_hover)
void QQuickTextArea::hoverEnterEvent(QHoverEvent *event)
{
Q_D(QQuickTextArea);
@@ -675,6 +702,7 @@ void QQuickTextArea::hoverLeaveEvent(QHoverEvent *event)
setHovered(false);
event->setAccepted(d->hoverEnabled);
}
+#endif
void QQuickTextArea::mousePressEvent(QMouseEvent *event)
{
diff --git a/src/quicktemplates2/qquicktextarea_p.h b/src/quicktemplates2/qquicktextarea_p.h
index 99440c32..af7c1d13 100644
--- a/src/quicktemplates2/qquicktextarea_p.h
+++ b/src/quicktemplates2/qquicktextarea_p.h
@@ -119,8 +119,10 @@ protected:
void focusInEvent(QFocusEvent *event) override;
void focusOutEvent(QFocusEvent *event) override;
+#if QT_CONFIG(quicktemplates2_hover)
void hoverEnterEvent(QHoverEvent *event) override;
void hoverLeaveEvent(QHoverEvent *event) override;
+#endif
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
diff --git a/src/quicktemplates2/qquicktextarea_p_p.h b/src/quicktemplates2/qquicktextarea_p_p.h
index 06ba3eb5..60995080 100644
--- a/src/quicktemplates2/qquicktextarea_p_p.h
+++ b/src/quicktemplates2/qquicktextarea_p_p.h
@@ -83,7 +83,9 @@ public:
void resolveFont();
void inheritFont(const QFont &f);
+#if QT_CONFIG(quicktemplates2_hover)
void updateHoverEnabled(bool h, bool e);
+#endif
void attachFlickable(QQuickFlickable *flickable);
void detachFlickable();
@@ -108,8 +110,10 @@ public:
void deleteDelegate(QObject *object);
+#if QT_CONFIG(quicktemplates2_hover)
bool hovered;
bool explicitHoverEnabled;
+#endif
QFont font;
QQuickItem *background;
QString placeholder;
diff --git a/src/quicktemplates2/qquicktextfield.cpp b/src/quicktemplates2/qquicktextfield.cpp
index ace17210..36c284f0 100644
--- a/src/quicktemplates2/qquicktextfield.cpp
+++ b/src/quicktemplates2/qquicktextfield.cpp
@@ -112,8 +112,11 @@ QT_BEGIN_NAMESPACE
*/
QQuickTextFieldPrivate::QQuickTextFieldPrivate()
- : hovered(false),
+ : QQuickTextInputPrivate(),
+#if QT_CONFIG(quicktemplates2_hover)
+ hovered(false),
explicitHoverEnabled(false),
+#endif
background(nullptr),
focusReason(Qt::OtherFocusReason),
accessibleAttached(nullptr)
@@ -175,6 +178,7 @@ void QQuickTextFieldPrivate::inheritFont(const QFont &f)
emit q->fontChanged();
}
+#if QT_CONFIG(quicktemplates2_hover)
void QQuickTextFieldPrivate::updateHoverEnabled(bool enabled, bool xplicit)
{
Q_Q(QQuickTextField);
@@ -189,6 +193,7 @@ void QQuickTextFieldPrivate::updateHoverEnabled(bool enabled, bool xplicit)
emit q->hoverEnabledChanged();
}
}
+#endif
qreal QQuickTextFieldPrivate::getImplicitWidth() const
{
@@ -391,18 +396,26 @@ void QQuickTextField::setFocusReason(Qt::FocusReason reason)
*/
bool QQuickTextField::isHovered() const
{
+#if QT_CONFIG(quicktemplates2_hover)
Q_D(const QQuickTextField);
return d->hovered;
+#else
+ return false;
+#endif
}
void QQuickTextField::setHovered(bool hovered)
{
+#if QT_CONFIG(quicktemplates2_hover)
Q_D(QQuickTextField);
if (hovered == d->hovered)
return;
d->hovered = hovered;
emit hoveredChanged();
+#else
+ Q_UNUSED(hovered);
+#endif
}
/*!
@@ -415,27 +428,37 @@ void QQuickTextField::setHovered(bool hovered)
*/
bool QQuickTextField::isHoverEnabled() const
{
+#if QT_CONFIG(quicktemplates2_hover)
Q_D(const QQuickTextField);
return d->hoverEnabled;
+#else
+ return false;
+#endif
}
void QQuickTextField::setHoverEnabled(bool enabled)
{
+#if QT_CONFIG(quicktemplates2_hover)
Q_D(QQuickTextField);
if (d->explicitHoverEnabled && enabled == d->hoverEnabled)
return;
d->updateHoverEnabled(enabled, true); // explicit=true
+#else
+ Q_UNUSED(enabled);
+#endif
}
void QQuickTextField::resetHoverEnabled()
{
+#if QT_CONFIG(quicktemplates2_hover)
Q_D(QQuickTextField);
if (!d->explicitHoverEnabled)
return;
d->explicitHoverEnabled = false;
d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false
+#endif
}
void QQuickTextField::classBegin()
@@ -449,8 +472,10 @@ void QQuickTextField::componentComplete()
{
Q_D(QQuickTextField);
QQuickTextInput::componentComplete();
+#if QT_CONFIG(quicktemplates2_hover)
if (!d->explicitHoverEnabled)
setAcceptHoverEvents(QQuickControlPrivate::calcHoverEnabled(d->parentItem));
+#endif
#ifndef QT_NO_ACCESSIBILITY
if (!d->accessibleAttached && QAccessible::isActive())
d->accessibilityActiveChanged(true);
@@ -466,8 +491,10 @@ void QQuickTextField::itemChange(QQuickItem::ItemChange change, const QQuickItem
QQuickTextInput::itemChange(change, value);
if (change == ItemParentHasChanged && value.item) {
d->resolveFont();
+#if QT_CONFIG(quicktemplates2_hover)
if (!d->explicitHoverEnabled)
d->updateHoverEnabled(QQuickControlPrivate::calcHoverEnabled(d->parentItem), false); // explicit=false
+#endif
}
}
@@ -506,6 +533,7 @@ void QQuickTextField::focusOutEvent(QFocusEvent *event)
setFocusReason(event->reason());
}
+#if QT_CONFIG(quicktemplates2_hover)
void QQuickTextField::hoverEnterEvent(QHoverEvent *event)
{
Q_D(QQuickTextField);
@@ -521,6 +549,7 @@ void QQuickTextField::hoverLeaveEvent(QHoverEvent *event)
setHovered(false);
event->setAccepted(d->hoverEnabled);
}
+#endif
void QQuickTextField::mousePressEvent(QMouseEvent *event)
{
diff --git a/src/quicktemplates2/qquicktextfield_p.h b/src/quicktemplates2/qquicktextfield_p.h
index f9637cc9..24e6ce53 100644
--- a/src/quicktemplates2/qquicktextfield_p.h
+++ b/src/quicktemplates2/qquicktextfield_p.h
@@ -114,8 +114,10 @@ protected:
void focusInEvent(QFocusEvent *event) override;
void focusOutEvent(QFocusEvent *event) override;
+#if QT_CONFIG(quicktemplates2_hover)
void hoverEnterEvent(QHoverEvent *event) override;
void hoverLeaveEvent(QHoverEvent *event) override;
+#endif
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
diff --git a/src/quicktemplates2/qquicktextfield_p_p.h b/src/quicktemplates2/qquicktextfield_p_p.h
index 4b83f29e..b35446ec 100644
--- a/src/quicktemplates2/qquicktextfield_p_p.h
+++ b/src/quicktemplates2/qquicktextfield_p_p.h
@@ -79,7 +79,9 @@ public:
void resolveFont();
void inheritFont(const QFont &f);
+#if QT_CONFIG(quicktemplates2_hover)
void updateHoverEnabled(bool h, bool e);
+#endif
qreal getImplicitWidth() const override;
qreal getImplicitHeight() const override;
@@ -97,8 +99,10 @@ public:
void deleteDelegate(QObject *object);
+#if QT_CONFIG(quicktemplates2_hover)
bool hovered;
bool explicitHoverEnabled;
+#endif
QFont font;
QQuickItem *background;
QString placeholder;
diff --git a/src/quicktemplates2/qtquicktemplates2global_p.h b/src/quicktemplates2/qtquicktemplates2global_p.h
index 322a334f..b7f54bb6 100644
--- a/src/quicktemplates2/qtquicktemplates2global_p.h
+++ b/src/quicktemplates2/qtquicktemplates2global_p.h
@@ -49,6 +49,7 @@
//
#include <QtCore/qglobal.h>
+#include <QtQuickTemplates2/private/qtquicktemplates2-config_p.h>
QT_BEGIN_NAMESPACE