aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-07-17 15:40:17 +0200
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-07-17 15:40:17 +0200
commit50244fc5d6f0730a447f1ac1ce19827890bc1456 (patch)
treefd937513dc616c270a1b8da23f982c2b9a7b6ac2 /src/quicktemplates2
parentbf727efa7aa9a4738ae86a2c699832129813c670 (diff)
parent49ffc6e6af83b295c67fd119b79c925879cc292e (diff)
Merge branch 'dev' into nativestyle
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r--src/quicktemplates2/configure.cmake8
-rw-r--r--src/quicktemplates2/qquickabstractbutton.cpp1
-rw-r--r--src/quicktemplates2/qquickaction.cpp1
-rw-r--r--src/quicktemplates2/qquickaction_p_p.h2
-rw-r--r--src/quicktemplates2/qquickactiongroup.cpp2
-rw-r--r--src/quicktemplates2/qquickapplicationwindow.cpp78
-rw-r--r--src/quicktemplates2/qquickapplicationwindow_p.h7
-rw-r--r--src/quicktemplates2/qquickbuttongroup.cpp2
-rw-r--r--src/quicktemplates2/qquickcombobox.cpp178
-rw-r--r--src/quicktemplates2/qquickcombobox_p.h17
-rw-r--r--src/quicktemplates2/qquickcontrol.cpp10
-rw-r--r--src/quicktemplates2/qquickdialogbuttonbox.cpp2
-rw-r--r--src/quicktemplates2/qquickdrawer.cpp2
-rw-r--r--src/quicktemplates2/qquickheaderview.cpp4
-rw-r--r--src/quicktemplates2/qquicklabel.cpp2
-rw-r--r--src/quicktemplates2/qquickmenu_p_p.h4
-rw-r--r--src/quicktemplates2/qquickoverlay.cpp18
-rw-r--r--src/quicktemplates2/qquickoverlay_p_p.h8
-rw-r--r--src/quicktemplates2/qquickpane.cpp4
-rw-r--r--src/quicktemplates2/qquickpopup.cpp14
-rw-r--r--src/quicktemplates2/qquickpopupanchors.cpp26
-rw-r--r--src/quicktemplates2/qquickpopupanchors_p.h6
-rw-r--r--src/quicktemplates2/qquickpresshandler.cpp13
-rw-r--r--src/quicktemplates2/qquickrangeslider.cpp16
-rw-r--r--src/quicktemplates2/qquickscrollbar.cpp2
-rw-r--r--src/quicktemplates2/qquickslider.cpp12
-rw-r--r--src/quicktemplates2/qquickspinbox.cpp4
-rw-r--r--src/quicktemplates2/qquicksplitview.cpp4
-rw-r--r--src/quicktemplates2/qquicksplitview_p_p.h2
-rw-r--r--src/quicktemplates2/qquickstackview.cpp13
-rw-r--r--src/quicktemplates2/qquickstackview_p.h2
-rw-r--r--src/quicktemplates2/qquickswipedelegate.cpp16
-rw-r--r--src/quicktemplates2/qquickswitch.cpp6
-rw-r--r--src/quicktemplates2/qquickswitchdelegate.cpp6
-rw-r--r--src/quicktemplates2/qquicktabbar.cpp2
-rw-r--r--src/quicktemplates2/qquicktextfield.cpp2
36 files changed, 322 insertions, 174 deletions
diff --git a/src/quicktemplates2/configure.cmake b/src/quicktemplates2/configure.cmake
index 6ccd920c..4e097569 100644
--- a/src/quicktemplates2/configure.cmake
+++ b/src/quicktemplates2/configure.cmake
@@ -14,13 +14,17 @@
#### Features
-qt_feature("quicktemplates2_hover" PRIVATE
+qt_feature("quicktemplates2-hover" PRIVATE
SECTION "Quick Templates 2"
LABEL "Hover support"
PURPOSE "Provides support for hover effects."
)
-qt_feature("quicktemplates2_multitouch" PRIVATE
+qt_feature("quicktemplates2-multitouch" PRIVATE
SECTION "Quick Templates 2"
LABEL "Multi-touch support"
PURPOSE "Provides support for multi-touch."
)
+qt_configure_add_summary_section(NAME "Qt Quick Templates 2")
+qt_configure_add_summary_entry(ARGS "quicktemplates2-hover")
+qt_configure_add_summary_entry(ARGS "quicktemplates2-multitouch")
+qt_configure_end_summary_section() # end of "Qt Quick Templates 2" section
diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp
index 8a61e570..0c481d01 100644
--- a/src/quicktemplates2/qquickabstractbutton.cpp
+++ b/src/quicktemplates2/qquickabstractbutton.cpp
@@ -748,6 +748,7 @@ void QQuickAbstractButton::setIndicator(QQuickItem *indicator)
\qmlproperty int QtQuick.Controls::AbstractButton::icon.width
\qmlproperty int QtQuick.Controls::AbstractButton::icon.height
\qmlproperty color QtQuick.Controls::AbstractButton::icon.color
+ \qmlproperty bool QtQuick.Controls::AbstractButton::icon.cache
This property group was added in QtQuick.Controls 2.3.
diff --git a/src/quicktemplates2/qquickaction.cpp b/src/quicktemplates2/qquickaction.cpp
index 0b083339..0dab3b97 100644
--- a/src/quicktemplates2/qquickaction.cpp
+++ b/src/quicktemplates2/qquickaction.cpp
@@ -387,6 +387,7 @@ void QQuickAction::setText(const QString &text)
\qmlproperty int QtQuick.Controls::Action::icon.width
\qmlproperty int QtQuick.Controls::Action::icon.height
\qmlproperty color QtQuick.Controls::Action::icon.color
+ \qmlproperty bool QtQuick.Controls::Action::icon.cache
\include qquickicon.qdocinc grouped-properties
*/
diff --git a/src/quicktemplates2/qquickaction_p_p.h b/src/quicktemplates2/qquickaction_p_p.h
index 252b0075..d9b83548 100644
--- a/src/quicktemplates2/qquickaction_p_p.h
+++ b/src/quicktemplates2/qquickaction_p_p.h
@@ -125,7 +125,7 @@ public:
QKeySequence keySequence;
QVariant vshortcut;
ShortcutEntry *defaultShortcutEntry = nullptr;
- QVector<ShortcutEntry *> shortcutEntries;
+ QList<ShortcutEntry *> shortcutEntries;
#endif
QQuickActionGroup *group = nullptr;
};
diff --git a/src/quicktemplates2/qquickactiongroup.cpp b/src/quicktemplates2/qquickactiongroup.cpp
index a78489e2..301957b6 100644
--- a/src/quicktemplates2/qquickactiongroup.cpp
+++ b/src/quicktemplates2/qquickactiongroup.cpp
@@ -156,7 +156,7 @@ public:
bool enabled = true;
bool exclusive = true;
QPointer<QQuickAction> checkedAction;
- QVector<QQuickAction*> actions;
+ QList<QQuickAction*> actions;
};
void QQuickActionGroupPrivate::clear()
diff --git a/src/quicktemplates2/qquickapplicationwindow.cpp b/src/quicktemplates2/qquickapplicationwindow.cpp
index d7ff9a26..3d39a04e 100644
--- a/src/quicktemplates2/qquickapplicationwindow.cpp
+++ b/src/quicktemplates2/qquickapplicationwindow.cpp
@@ -36,7 +36,6 @@
#include "qquickapplicationwindow_p.h"
#include "qquickcontentitem_p.h"
-#include "qquickoverlay_p.h"
#include "qquickpopup_p_p.h"
#include "qquickcontrol_p_p.h"
#include "qquicktextarea_p.h"
@@ -178,7 +177,6 @@ public:
QQuickItem *menuBar = nullptr;
QQuickItem *header = nullptr;
QQuickItem *footer = nullptr;
- QQuickOverlay *overlay = nullptr;
QFont font;
QLocale locale;
QQuickItem *activeFocusControl = nullptr;
@@ -231,9 +229,9 @@ void QQuickApplicationWindowPrivate::relayout()
void QQuickApplicationWindowPrivate::itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff)
{
- Q_UNUSED(item)
- Q_UNUSED(change)
- Q_UNUSED(diff)
+ Q_UNUSED(item);
+ Q_UNUSED(change);
+ Q_UNUSED(diff);
relayout();
}
@@ -589,57 +587,6 @@ QQuickItem *QQuickApplicationWindow::activeFocusControl() const
}
/*!
- \deprecated
- \qmlpropertygroup QtQuick.Controls::ApplicationWindow::overlay
- \qmlproperty Item QtQuick.Controls::ApplicationWindow::overlay
- \qmlproperty Component QtQuick.Controls::ApplicationWindow::overlay.modal
- \qmlproperty Component QtQuick.Controls::ApplicationWindow::overlay.modeless
-
- Use the \l Overlay attached properties and signals instead.
-
- This property holds the window overlay item. Popups are automatically
- reparented to the overlay.
-
- \table
- \header
- \li Property
- \li Description
- \row
- \li overlay.modal
- \li This property holds a component to use as a visual item that implements
- background dimming for modal popups. It is created for and stacked below
- visible modal popups.
- \row
- \li overlay.modeless
- \li This property holds a component to use as a visual item that implements
- background dimming for modeless popups. It is created for and stacked below
- visible dimming popups.
- \row
- \li overlay.pressed()
- \li This signal is emitted when the overlay is pressed by the user while
- a popup is visible.
- \row
- \li overlay.released()
- \li This signal is emitted when the overlay is released by the user while
- a modal popup is visible.
- \endtable
-
- \sa Popup::modal, Popup::dim
-*/
-QQuickOverlay *QQuickApplicationWindow::overlay() const
-{
- QQuickApplicationWindowPrivate *d = const_cast<QQuickApplicationWindowPrivate *>(d_func());
- if (!d) // being deleted
- return nullptr;
-
- if (!d->overlay) {
- d->overlay = new QQuickOverlay(QQuickWindow::contentItem());
- d->overlay->stackAfter(QQuickApplicationWindow::contentItem());
- }
- return d->overlay;
-}
-
-/*!
\qmlproperty font QtQuick.Controls::ApplicationWindow::font
This property holds the font currently set for the window.
@@ -852,7 +799,6 @@ void QQuickApplicationWindowAttachedPrivate::windowChange(QQuickWindow *wnd)
window = wnd;
emit q->windowChanged();
emit q->contentItemChanged();
- emit q->overlayChanged();
activeFocusChange();
if ((oldWindow && oldWindow->menuBar()) || (newWindow && newWindow->menuBar()))
@@ -986,24 +932,6 @@ QQuickItem *QQuickApplicationWindowAttached::footer() const
}
/*!
- \deprecated
- \qmlattachedproperty Item QtQuick.Controls::ApplicationWindow::overlay
- \readonly
-
- Use the \l Overlay::overlay attached property instead.
-
- This attached property holds the window overlay item. The property can be attached
- to any item. The value is \c null if the item is not in an ApplicationWindow.
-
- \sa {Attached ApplicationWindow Properties}
-*/
-QQuickOverlay *QQuickApplicationWindowAttached::overlay() const
-{
- Q_D(const QQuickApplicationWindowAttached);
- return QQuickOverlay::overlay(d->window);
-}
-
-/*!
\since QtQuick.Controls 2.3 (Qt 5.10)
\qmlattachedproperty Item QtQuick.Controls::ApplicationWindow::menuBar
\readonly
diff --git a/src/quicktemplates2/qquickapplicationwindow_p.h b/src/quicktemplates2/qquickapplicationwindow_p.h
index 14ef6c67..9c0292ed 100644
--- a/src/quicktemplates2/qquickapplicationwindow_p.h
+++ b/src/quicktemplates2/qquickapplicationwindow_p.h
@@ -56,7 +56,6 @@
QT_BEGIN_NAMESPACE
-class QQuickOverlay;
class QQuickApplicationWindowPrivate;
class QQuickApplicationWindowAttached;
class QQuickApplicationWindowAttachedPrivate;
@@ -70,7 +69,6 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickApplicationWindow : public QQuickWi
Q_PROPERTY(QQuickItem *activeFocusControl READ activeFocusControl NOTIFY activeFocusControlChanged FINAL)
Q_PROPERTY(QQuickItem *header READ header WRITE setHeader NOTIFY headerChanged FINAL)
Q_PROPERTY(QQuickItem *footer READ footer WRITE setFooter NOTIFY footerChanged FINAL)
- Q_PROPERTY(QQuickOverlay *overlay READ overlay CONSTANT FINAL)
Q_PROPERTY(QFont font READ font WRITE setFont RESET resetFont NOTIFY fontChanged FINAL)
Q_PROPERTY(QLocale locale READ locale WRITE setLocale RESET resetLocale NOTIFY localeChanged FINAL)
// 2.3 (Qt 5.10)
@@ -99,8 +97,6 @@ public:
QQuickItem *footer() const;
void setFooter(QQuickItem *footer);
- QQuickOverlay *overlay() const;
-
QFont font() const;
void setFont(const QFont &font);
void resetFont();
@@ -141,7 +137,6 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickApplicationWindowAttached : public
Q_PROPERTY(QQuickItem *activeFocusControl READ activeFocusControl NOTIFY activeFocusControlChanged FINAL)
Q_PROPERTY(QQuickItem *header READ header NOTIFY headerChanged FINAL)
Q_PROPERTY(QQuickItem *footer READ footer NOTIFY footerChanged FINAL)
- Q_PROPERTY(QQuickOverlay *overlay READ overlay NOTIFY overlayChanged FINAL)
Q_PROPERTY(QQuickItem *menuBar READ menuBar NOTIFY menuBarChanged FINAL) // REVISION 3
public:
@@ -152,7 +147,6 @@ public:
QQuickItem *activeFocusControl() const;
QQuickItem *header() const;
QQuickItem *footer() const;
- QQuickOverlay *overlay() const;
QQuickItem *menuBar() const;
Q_SIGNALS:
@@ -161,7 +155,6 @@ Q_SIGNALS:
void activeFocusControlChanged();
void headerChanged();
void footerChanged();
- void overlayChanged();
// 2.3 (Qt 5.10)
/*Q_REVISION(3)*/ void menuBarChanged();
diff --git a/src/quicktemplates2/qquickbuttongroup.cpp b/src/quicktemplates2/qquickbuttongroup.cpp
index 3886dce9..974cd029 100644
--- a/src/quicktemplates2/qquickbuttongroup.cpp
+++ b/src/quicktemplates2/qquickbuttongroup.cpp
@@ -170,7 +170,7 @@ public:
bool settingCheckState = false;
Qt::CheckState checkState = Qt::Unchecked;
QPointer<QQuickAbstractButton> checkedButton;
- QVector<QQuickAbstractButton*> buttons;
+ QList<QQuickAbstractButton*> buttons;
};
void QQuickButtonGroupPrivate::clear()
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp
index 85f135c7..426adbd3 100644
--- a/src/quicktemplates2/qquickcombobox.cpp
+++ b/src/quicktemplates2/qquickcombobox.cpp
@@ -54,10 +54,13 @@
#include <QtQuick/private/qquickaccessibleattached_p.h>
#include <QtQuick/private/qquickevents_p_p.h>
#include <QtQuick/private/qquicktextinput_p.h>
+#include <QtQuick/private/qquicktextinput_p_p.h>
#include <QtQuick/private/qquickitemview_p.h>
QT_BEGIN_NAMESPACE
+Q_LOGGING_CATEGORY(lcCalculateWidestTextWidth, "qt.quick.controls.combobox.calculatewidesttextwidth")
+
/*!
\qmltype ComboBox
\inherits Control
@@ -230,6 +233,7 @@ public:
void modelUpdated();
void countChanged();
+ QString effectiveTextRole() const;
void updateEditText();
void updateCurrentText();
void updateCurrentValue();
@@ -265,6 +269,10 @@ public:
void itemImplicitWidthChanged(QQuickItem *item) override;
void itemImplicitHeightChanged(QQuickItem *item) override;
+ virtual qreal getContentWidth() const override;
+ qreal calculateWidestTextWidth() const;
+ void maybeUpdateImplicitContentWidth();
+
static void hideOldPopup(QQuickPopup *popup);
QPalette defaultPalette() const override { return QQuickTheme::palette(QQuickTheme::ComboBox); }
@@ -277,8 +285,10 @@ public:
bool keyNavigating = false;
bool hasDisplayText = false;
bool hasCurrentIndex = false;
+ bool hasCalculatedWidestText = false;
int highlightedIndex = -1;
int currentIndex = -1;
+ QQuickComboBox::ImplicitContentWidthPolicy implicitContentWidthPolicy = QQuickComboBox::ContentItemImplicitWidth;
QVariant model;
QString textRole;
QString currentText;
@@ -411,8 +421,12 @@ void QQuickComboBoxPrivate::createdItem(int index, QObject *object)
void QQuickComboBoxPrivate::modelUpdated()
{
- if (!extra.isAllocated() || !extra->accepting)
+ if (componentComplete && (!extra.isAllocated() || !extra->accepting)) {
updateCurrentTextAndValue();
+
+ if (implicitContentWidthPolicy == QQuickComboBox::WidestText)
+ updateImplicitContentSize();
+ }
}
void QQuickComboBoxPrivate::countChanged()
@@ -423,6 +437,11 @@ void QQuickComboBoxPrivate::countChanged()
emit q->countChanged();
}
+QString QQuickComboBoxPrivate::effectiveTextRole() const
+{
+ return textRole.isEmpty() ? QStringLiteral("modelData") : textRole;
+}
+
void QQuickComboBoxPrivate::updateEditText()
{
Q_Q(QQuickComboBox);
@@ -780,6 +799,72 @@ void QQuickComboBoxPrivate::itemImplicitHeightChanged(QQuickItem *item)
emit q->implicitIndicatorHeightChanged();
}
+qreal QQuickComboBoxPrivate::getContentWidth() const
+{
+ if (componentComplete) {
+ switch (implicitContentWidthPolicy) {
+ case QQuickComboBox::WidestText:
+ return calculateWidestTextWidth();
+ case QQuickComboBox::WidestTextWhenCompleted:
+ if (!hasCalculatedWidestText)
+ return calculateWidestTextWidth();
+ break;
+ default:
+ break;
+ }
+ }
+
+ return QQuickControlPrivate::getContentWidth();
+}
+
+qreal QQuickComboBoxPrivate::calculateWidestTextWidth() const
+{
+ Q_Q(const QQuickComboBox);
+ if (!componentComplete)
+ return 0;
+
+ const int count = q->count();
+ if (count == 0)
+ return 0;
+
+ auto textInput = qobject_cast<QQuickTextInput*>(contentItem);
+ if (!textInput)
+ return 0;
+
+ qCDebug(lcCalculateWidestTextWidth) << "calculating widest text from" << count << "items...";
+
+ // Avoid the index check and repeated calls to effectiveTextRole()
+ // that would result from calling textAt() in a loop.
+ const QString textRole = effectiveTextRole();
+ auto textInputPrivate = QQuickTextInputPrivate::get(textInput);
+ qreal widest = 0;
+ for (int i = 0; i < count; ++i) {
+ const QString text = delegateModel->stringValue(i, textRole);
+ const qreal textImplicitWidth = textInputPrivate->calculateImplicitWidthForText(text);
+ widest = qMax(widest, textImplicitWidth);
+ }
+
+ qCDebug(lcCalculateWidestTextWidth) << "... widest text is" << widest;
+ return widest;
+}
+
+/*!
+ If the user requested it (and we haven't already done it, depending on the policy),
+ update the implicit content width to the largest text in the model.
+*/
+void QQuickComboBoxPrivate::maybeUpdateImplicitContentWidth()
+{
+ if (!componentComplete)
+ return;
+
+ if (implicitContentWidthPolicy == QQuickComboBox::ContentItemImplicitWidth
+ || (implicitContentWidthPolicy == QQuickComboBox::WidestTextWhenCompleted && hasCalculatedWidestText))
+ return;
+
+ updateImplicitContentWidth();
+ hasCalculatedWidestText = true;
+}
+
void QQuickComboBoxPrivate::hideOldPopup(QQuickPopup *popup)
{
if (!popup)
@@ -885,6 +970,8 @@ void QQuickComboBox::setModel(const QVariant& m)
d->updateCurrentTextAndValue();
}
emit modelChanged();
+
+ d->maybeUpdateImplicitContentWidth();
}
/*!
@@ -1597,6 +1684,80 @@ void QQuickComboBox::setSelectTextByMouse(bool canSelect)
d->extra.value().selectTextByMouse = canSelect;
emit selectTextByMouseChanged();
}
+
+/*!
+ \since QtQuick.Controls 6.0 (Qt 6.0)
+ \qmlproperty enumeration QtQuick.Controls::ComboBox::implicitContentWidthPolicy
+
+ This property controls how the \l implicitContentWidth of the ComboBox is
+ calculated.
+
+ When the width of a ComboBox is not large enough to display text, that text
+ is elided. Depending on which parts of the text are elided, this can make
+ selecting an item difficult for the end user. An efficient way of ensuring
+ that a ComboBox is wide enough to avoid text being elided is to set a width
+ that is known to be large enough:
+
+ \code
+ width: 300
+ implicitContentWidthPolicy: ComboBox.ContentItemImplicitWidth
+ \endcode
+
+ However, it is often not possible to know whether or not a hard-coded value
+ will be large enough, as the size of text depends on many factors, such as
+ font family, font size, translations, and so on.
+
+ implicitContentWidthPolicy provides an easy way to control how the
+ implicitContentWidth is calculated, which in turn affects the
+ \l implicitWidth of the ComboBox and ensures that text will not be elided.
+
+ The available values are:
+
+ \value ContentItemImplicitWidth
+ The implicitContentWidth will default to that of the \l contentItem.
+
+ This is the most efficient option, as no extra text layout is done.
+ \value WidestText
+ The implicitContentWidth will be set to the implicit width of the
+ the largest text for the given \l textRole every time the model
+ changes.
+
+ This option should be used with smaller models, as it can be expensive.
+ \value WidestTextWhenCompleted
+ The implicitContentWidth will be set to the implicit width of the
+ the largest text for the given \l textRole once after
+ \l {QQmlParserStatus::componentComplete()}{component completion}.
+
+ This option should be used with smaller models, as it can be expensive.
+
+ The default value is \c ContentItemImplicitWidth.
+
+ As this property only affects the \l implicitWidth of the ComboBox, setting
+ an explicit \l width can still result in eliding.
+
+ \note This feature requires the contentItem to be a type derived from
+ \l TextInput.
+
+ \note This feature requires text to be laid out, and can therefore be
+ expensive for large models or models whose contents are updated
+ frequently.
+*/
+QQuickComboBox::ImplicitContentWidthPolicy QQuickComboBox::implicitContentWidthPolicy() const
+{
+ Q_D(const QQuickComboBox);
+ return d->implicitContentWidthPolicy;
+}
+
+void QQuickComboBox::setImplicitContentWidthPolicy(QQuickComboBox::ImplicitContentWidthPolicy policy)
+{
+ Q_D(QQuickComboBox);
+ if (policy == d->implicitContentWidthPolicy)
+ return;
+
+ d->implicitContentWidthPolicy = policy;
+ d->maybeUpdateImplicitContentWidth();
+ emit implicitContentWidthPolicyChanged();
+}
/*!
\qmlmethod string QtQuick.Controls::ComboBox::textAt(int index)
@@ -1611,8 +1772,7 @@ QString QQuickComboBox::textAt(int index) const
if (!d->isValidIndex(index))
return QString();
- const QString effectiveTextRole = d->textRole.isEmpty() ? QStringLiteral("modelData") : d->textRole;
- return d->delegateModel->stringValue(index, effectiveTextRole);
+ return d->delegateModel->stringValue(index, d->effectiveTextRole());
}
/*!
@@ -1894,6 +2054,11 @@ void QQuickComboBox::componentComplete()
setCurrentIndex(0);
else
d->updateCurrentTextAndValue();
+
+ // If the widest text was already calculated in the call to
+ // QQmlDelegateModel::componentComplete() above, then we shouldn't do it here too.
+ if (!d->hasCalculatedWidestText)
+ d->maybeUpdateImplicitContentWidth();
}
}
@@ -1907,6 +2072,13 @@ void QQuickComboBox::itemChange(QQuickItem::ItemChange change, const QQuickItem:
}
}
+void QQuickComboBox::fontChange(const QFont &newFont, const QFont &oldFont)
+{
+ Q_D(QQuickComboBox);
+ QQuickControl::fontChange(newFont, oldFont);
+ d->maybeUpdateImplicitContentWidth();
+}
+
void QQuickComboBox::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
{
Q_D(QQuickComboBox);
diff --git a/src/quicktemplates2/qquickcombobox_p.h b/src/quicktemplates2/qquickcombobox_p.h
index 4874eb5d..18c1275c 100644
--- a/src/quicktemplates2/qquickcombobox_p.h
+++ b/src/quicktemplates2/qquickcombobox_p.h
@@ -94,6 +94,9 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickComboBox : public QQuickControl
Q_PROPERTY(QString valueRole READ valueRole WRITE setValueRole NOTIFY valueRoleChanged FINAL REVISION 14)
// 2.15 (Qt 5.15)
Q_PROPERTY(bool selectTextByMouse READ selectTextByMouse WRITE setSelectTextByMouse NOTIFY selectTextByMouseChanged FINAL REVISION 15)
+ // TODO: 6.0 (Qt 6.0) - QTBUG-84190
+ Q_PROPERTY(ImplicitContentWidthPolicy implicitContentWidthPolicy READ implicitContentWidthPolicy
+ WRITE setImplicitContentWidthPolicy NOTIFY implicitContentWidthPolicyChanged FINAL REVISION 15)
public:
explicit QQuickComboBox(QQuickItem *parent = nullptr);
@@ -175,6 +178,17 @@ public:
bool selectTextByMouse() const;
void setSelectTextByMouse(bool canSelect);
+ // 6.0 (Qt 6.0)
+ enum ImplicitContentWidthPolicy {
+ ContentItemImplicitWidth,
+ WidestText,
+ WidestTextWhenCompleted
+ };
+ Q_ENUM(ImplicitContentWidthPolicy)
+
+ ImplicitContentWidthPolicy implicitContentWidthPolicy() const;
+ void setImplicitContentWidthPolicy(ImplicitContentWidthPolicy policy);
+
public Q_SLOTS:
void incrementCurrentIndex();
void decrementCurrentIndex();
@@ -214,6 +228,8 @@ Q_SIGNALS:
Q_REVISION(14) void currentValueChanged();
// 2.15 (Qt 5.15)
Q_REVISION(15) void selectTextByMouseChanged();
+ // 6.0 (Qt 6.0)
+ Q_REVISION(6, 0) void implicitContentWidthPolicyChanged();
protected:
bool eventFilter(QObject *object, QEvent *event) override;
@@ -231,6 +247,7 @@ protected:
void componentComplete() override;
void itemChange(ItemChange change, const ItemChangeData &value) override;
+ void fontChange(const QFont &newFont, const QFont &oldFont) override;
void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override;
void localeChange(const QLocale &newLocale, const QLocale &oldLocale) override;
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp
index c5a5fd7a..8463c60d 100644
--- a/src/quicktemplates2/qquickcontrol.cpp
+++ b/src/quicktemplates2/qquickcontrol.cpp
@@ -1442,7 +1442,7 @@ void QQuickControl::setHoverEnabled(bool enabled)
d->updateHoverEnabled(enabled, true); // explicit=true
#else
- Q_UNUSED(enabled)
+ Q_UNUSED(enabled);
#endif
}
@@ -2154,7 +2154,7 @@ void QQuickControl::maybeSetAccessibleName(const QString &name)
accessibleAttached->setNameImplicitly(name);
}
#else
- Q_UNUSED(name)
+ Q_UNUSED(name);
#endif
}
@@ -2164,7 +2164,7 @@ QVariant QQuickControl::accessibleProperty(const char *propertyName)
if (QAccessible::isActive())
return QQuickAccessibleAttached::property(this, propertyName);
#endif
- Q_UNUSED(propertyName)
+ Q_UNUSED(propertyName);
return QVariant();
}
@@ -2174,8 +2174,8 @@ bool QQuickControl::setAccessibleProperty(const char *propertyName, const QVaria
if (QAccessible::isActive())
return QQuickAccessibleAttached::setProperty(this, propertyName, value);
#endif
- Q_UNUSED(propertyName)
- Q_UNUSED(value)
+ Q_UNUSED(propertyName);
+ Q_UNUSED(value);
return false;
}
diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp
index b9e9674b..d6ed366f 100644
--- a/src/quicktemplates2/qquickdialogbuttonbox.cpp
+++ b/src/quicktemplates2/qquickdialogbuttonbox.cpp
@@ -258,7 +258,7 @@ void QQuickDialogButtonBoxPrivate::updateLayout()
const int halign = alignment & Qt::AlignHorizontal_Mask;
const int valign = alignment & Qt::AlignVertical_Mask;
- QVector<QQuickAbstractButton *> buttons;
+ QList<QQuickAbstractButton *> buttons;
const qreal cw = (alignment & Qt::AlignHorizontal_Mask) == 0 ? q->availableWidth() : contentWidth;
const qreal itemWidth = (cw - qMax(0, count - 1) * spacing) / count;
diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp
index b6d70dd7..433346ba 100644
--- a/src/quicktemplates2/qquickdrawer.cpp
+++ b/src/quicktemplates2/qquickdrawer.cpp
@@ -416,7 +416,7 @@ bool QQuickDrawerPrivate::grabTouch(QQuickItem *item, QTouchEvent *event)
}
if (overThreshold) {
- popupItem->grabTouchPoints(QVector<int>() << touchId);
+ popupItem->grabTouchPoints(QList<int>() << touchId);
popupItem->setKeepTouchGrab(true);
offset = offsetAt(movePoint);
}
diff --git a/src/quicktemplates2/qquickheaderview.cpp b/src/quicktemplates2/qquickheaderview.cpp
index 85291bcb..8593fa0f 100644
--- a/src/quicktemplates2/qquickheaderview.cpp
+++ b/src/quicktemplates2/qquickheaderview.cpp
@@ -360,7 +360,7 @@ QModelIndex QHeaderDataProxyModel::index(int row, int column, const QModelIndex
QModelIndex QHeaderDataProxyModel::parent(const QModelIndex &child) const
{
- Q_UNUSED(child)
+ Q_UNUSED(child);
return QModelIndex();
}
@@ -401,7 +401,7 @@ bool QHeaderDataProxyModel::setData(const QModelIndex &index, const QVariant &va
bool QHeaderDataProxyModel::hasChildren(const QModelIndex &parent) const
{
- Q_UNUSED(parent)
+ Q_UNUSED(parent);
return false;
}
diff --git a/src/quicktemplates2/qquicklabel.cpp b/src/quicktemplates2/qquicklabel.cpp
index f8c1c489..144d2fe7 100644
--- a/src/quicktemplates2/qquicklabel.cpp
+++ b/src/quicktemplates2/qquicklabel.cpp
@@ -213,7 +213,7 @@ void QQuickLabelPrivate::textChanged(const QString &text)
#if QT_CONFIG(accessibility)
maybeSetAccessibleName(text);
#else
- Q_UNUSED(text)
+ Q_UNUSED(text);
#endif
}
diff --git a/src/quicktemplates2/qquickmenu_p_p.h b/src/quicktemplates2/qquickmenu_p_p.h
index 41837a15..f1a5b3f9 100644
--- a/src/quicktemplates2/qquickmenu_p_p.h
+++ b/src/quicktemplates2/qquickmenu_p_p.h
@@ -48,7 +48,7 @@
// We mean it.
//
-#include <QtCore/qvector.h>
+#include <QtCore/qlist.h>
#include <QtCore/qpointer.h>
#include <QtQuickTemplates2/private/qquickmenu_p.h>
@@ -131,7 +131,7 @@ public:
QPointer<QQuickMenu> parentMenu;
QPointer<QQuickMenuItem> currentItem;
QQuickItem *contentItem = nullptr; // TODO: cleanup
- QVector<QObject *> contentData;
+ QList<QObject *> contentData;
QQmlObjectModel *contentModel;
QQmlComponent *delegate = nullptr;
QString title;
diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp
index 6eb0d0e8..5cb1ab0b 100644
--- a/src/quicktemplates2/qquickoverlay.cpp
+++ b/src/quicktemplates2/qquickoverlay.cpp
@@ -69,11 +69,11 @@ QT_BEGIN_NAMESPACE
\sa ApplicationWindow
*/
-QVector<QQuickPopup *> QQuickOverlayPrivate::stackingOrderPopups() const
+QList<QQuickPopup *> QQuickOverlayPrivate::stackingOrderPopups() const
{
const QList<QQuickItem *> children = paintOrderChildItems();
- QVector<QQuickPopup *> popups;
+ QList<QQuickPopup *> popups;
popups.reserve(children.count());
for (auto it = children.crbegin(), end = children.crend(); it != end; ++it) {
@@ -85,9 +85,9 @@ QVector<QQuickPopup *> QQuickOverlayPrivate::stackingOrderPopups() const
return popups;
}
-QVector<QQuickDrawer *> QQuickOverlayPrivate::stackingOrderDrawers() const
+QList<QQuickDrawer *> QQuickOverlayPrivate::stackingOrderDrawers() const
{
- QVector<QQuickDrawer *> sorted(allDrawers);
+ QList<QQuickDrawer *> sorted(allDrawers);
std::sort(sorted.begin(), sorted.end(), [](const QQuickDrawer *one, const QQuickDrawer *another) {
return one->z() > another->z();
});
@@ -116,7 +116,7 @@ bool QQuickOverlayPrivate::startDrag(QEvent *event, const QPointF &pos)
}
}
- const QVector<QQuickDrawer *> drawers = stackingOrderDrawers();
+ const QList<QQuickDrawer *> drawers = stackingOrderDrawers();
for (QQuickDrawer *drawer : drawers) {
QQuickDrawerPrivate *p = QQuickDrawerPrivate::get(drawer);
if (p->startDrag(event)) {
@@ -194,7 +194,7 @@ bool QQuickOverlayPrivate::handleMouseEvent(QQuickItem *source, QMouseEvent *eve
{
switch (event->type()) {
case QEvent::MouseButtonPress:
- if (!target && startDrag(event, event->windowPos()))
+ if (!target && startDrag(event, event->scenePosition()))
return true;
return handlePress(source, event, target);
case QEvent::MouseMove:
@@ -218,7 +218,7 @@ bool QQuickOverlayPrivate::handleTouchEvent(QQuickItem *source, QTouchEvent *eve
for (const QTouchEvent::TouchPoint &point : event->touchPoints()) {
switch (point.state()) {
case Qt::TouchPointPressed:
- if (!target && startDrag(event, point.scenePos()))
+ if (!target && startDrag(event, point.scenePosition()))
handled = true;
else
handled |= handlePress(source, event, target);
@@ -368,10 +368,6 @@ QQuickOverlay *QQuickOverlay::overlay(QQuickWindow *window)
if (!window)
return nullptr;
- QQuickApplicationWindow *applicationWindow = qobject_cast<QQuickApplicationWindow *>(window);
- if (applicationWindow)
- return applicationWindow->overlay();
-
const char *name = "_q_QQuickOverlay";
QQuickOverlay *overlay = window->property(name).value<QQuickOverlay *>();
if (!overlay) {
diff --git a/src/quicktemplates2/qquickoverlay_p_p.h b/src/quicktemplates2/qquickoverlay_p_p.h
index b445f87a..ef3d9ee2 100644
--- a/src/quicktemplates2/qquickoverlay_p_p.h
+++ b/src/quicktemplates2/qquickoverlay_p_p.h
@@ -82,8 +82,8 @@ public:
void removePopup(QQuickPopup *popup);
void setMouseGrabberPopup(QQuickPopup *popup);
- QVector<QQuickPopup *> stackingOrderPopups() const;
- QVector<QQuickDrawer *> stackingOrderDrawers() const;
+ QList<QQuickPopup *> stackingOrderPopups() const;
+ QList<QQuickDrawer *> stackingOrderDrawers() const;
void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &diff) override;
@@ -91,8 +91,8 @@ public:
QQmlComponent *modal = nullptr;
QQmlComponent *modeless = nullptr;
- QVector<QQuickPopup *> allPopups;
- QVector<QQuickDrawer *> allDrawers;
+ QList<QQuickPopup *> allPopups;
+ QList<QQuickDrawer *> allDrawers;
QPointer<QQuickPopup> mouseGrabberPopup;
};
diff --git a/src/quicktemplates2/qquickpane.cpp b/src/quicktemplates2/qquickpane.cpp
index bf902b6b..ecdc27db 100644
--- a/src/quicktemplates2/qquickpane.cpp
+++ b/src/quicktemplates2/qquickpane.cpp
@@ -410,8 +410,8 @@ void QQuickPane::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem)
void QQuickPane::contentSizeChange(const QSizeF &newSize, const QSizeF &oldSize)
{
- Q_UNUSED(newSize)
- Q_UNUSED(oldSize)
+ Q_UNUSED(newSize);
+ Q_UNUSED(oldSize);
}
#if QT_CONFIG(accessibility)
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index bafa3110..1d6f125e 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -372,11 +372,11 @@ bool QQuickPopupPrivate::handleMouseEvent(QQuickItem *item, QMouseEvent *event)
{
switch (event->type()) {
case QEvent::MouseButtonPress:
- return handlePress(item, event->windowPos(), event->timestamp());
+ return handlePress(item, event->scenePosition(), event->timestamp());
case QEvent::MouseMove:
- return handleMove(item, event->windowPos(), event->timestamp());
+ return handleMove(item, event->scenePosition(), event->timestamp());
case QEvent::MouseButtonRelease:
- return handleRelease(item, event->windowPos(), event->timestamp());
+ return handleRelease(item, event->scenePosition(), event->timestamp());
default:
Q_UNREACHABLE();
return false;
@@ -392,15 +392,15 @@ bool QQuickPopupPrivate::handleTouchEvent(QQuickItem *item, QTouchEvent *event)
case QEvent::TouchEnd:
for (const QTouchEvent::TouchPoint &point : event->touchPoints()) {
if (!acceptTouch(point))
- return blockInput(item, point.pos());
+ return blockInput(item, point.position());
switch (point.state()) {
case Qt::TouchPointPressed:
- return handlePress(item, item->mapToScene(point.pos()), event->timestamp());
+ return handlePress(item, item->mapToScene(point.position()), event->timestamp());
case Qt::TouchPointMoved:
- return handleMove(item, item->mapToScene(point.pos()), event->timestamp());
+ return handleMove(item, item->mapToScene(point.position()), event->timestamp());
case Qt::TouchPointReleased:
- return handleRelease(item, item->mapToScene(point.pos()), event->timestamp());
+ return handleRelease(item, item->mapToScene(point.position()), event->timestamp());
default:
break;
}
diff --git a/src/quicktemplates2/qquickpopupanchors.cpp b/src/quicktemplates2/qquickpopupanchors.cpp
index c48ca5ff..0d286cc0 100644
--- a/src/quicktemplates2/qquickpopupanchors.cpp
+++ b/src/quicktemplates2/qquickpopupanchors.cpp
@@ -47,6 +47,15 @@ QQuickPopupAnchors::QQuickPopupAnchors(QQuickPopup *popup)
d->popup = popup;
}
+QQuickPopupAnchors::~QQuickPopupAnchors()
+{
+ Q_D(const QQuickPopupAnchors);
+ if (d->centerIn) {
+ auto centerInPrivate = QQuickItemPrivate::get(d->centerIn);
+ centerInPrivate->removeItemChangeListener(this, QQuickItemPrivate::Destroyed);
+ }
+}
+
QQuickItem *QQuickPopupAnchors::centerIn() const
{
Q_D(const QQuickPopupAnchors);
@@ -59,8 +68,20 @@ void QQuickPopupAnchors::setCenterIn(QQuickItem *item)
if (item == d->centerIn)
return;
+ if (d->centerIn) {
+ auto centerInPrivate = QQuickItemPrivate::get(d->centerIn);
+ centerInPrivate->removeItemChangeListener(this, QQuickItemPrivate::Destroyed);
+ }
+
d->centerIn = item;
+
+ if (d->centerIn) {
+ auto centerInPrivate = QQuickItemPrivate::get(d->centerIn);
+ centerInPrivate->addItemChangeListener(this, QQuickItemPrivate::Destroyed);
+ }
+
QQuickPopupPrivate::get(d->popup)->reposition();
+
emit centerInChanged();
}
@@ -69,6 +90,11 @@ void QQuickPopupAnchors::resetCenterIn()
setCenterIn(nullptr);
}
+void QQuickPopupAnchors::itemDestroyed(QQuickItem *)
+{
+ resetCenterIn();
+}
+
QT_END_NAMESPACE
#include "moc_qquickpopupanchors_p.cpp"
diff --git a/src/quicktemplates2/qquickpopupanchors_p.h b/src/quicktemplates2/qquickpopupanchors_p.h
index 531c494e..eff4e23d 100644
--- a/src/quicktemplates2/qquickpopupanchors_p.h
+++ b/src/quicktemplates2/qquickpopupanchors_p.h
@@ -50,6 +50,7 @@
#include <QtCore/qobject.h>
#include <QtQml/qqml.h>
+#include <QtQuick/private/qquickitem_p.h>
#include <QtQuickTemplates2/private/qtquicktemplates2global_p.h>
QT_BEGIN_NAMESPACE
@@ -58,13 +59,14 @@ class QQuickItem;
class QQuickPopupAnchorsPrivate;
class QQuickPopup;
-class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickPopupAnchors : public QObject
+class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickPopupAnchors : public QObject, public QQuickItemChangeListener
{
Q_OBJECT
Q_PROPERTY(QQuickItem *centerIn READ centerIn WRITE setCenterIn RESET resetCenterIn NOTIFY centerInChanged)
public:
explicit QQuickPopupAnchors(QQuickPopup *popup);
+ ~QQuickPopupAnchors();
QQuickItem *centerIn() const;
void setCenterIn(QQuickItem *item);
@@ -74,6 +76,8 @@ Q_SIGNALS:
void centerInChanged();
private:
+ void itemDestroyed(QQuickItem *item) override;
+
Q_DISABLE_COPY(QQuickPopupAnchors)
Q_DECLARE_PRIVATE(QQuickPopupAnchors)
};
diff --git a/src/quicktemplates2/qquickpresshandler.cpp b/src/quicktemplates2/qquickpresshandler.cpp
index b9018573..d9ed484b 100644
--- a/src/quicktemplates2/qquickpresshandler.cpp
+++ b/src/quicktemplates2/qquickpresshandler.cpp
@@ -49,10 +49,10 @@ QT_BEGIN_NAMESPACE
void QQuickPressHandler::mousePressEvent(QMouseEvent *event)
{
longPress = false;
- pressPos = event->localPos();
+ pressPos = event->position();
if (Qt::LeftButton == (event->buttons() & Qt::LeftButton)) {
timer.start(QGuiApplication::styleHints()->mousePressAndHoldInterval(), control);
- delayedMousePressEvent = new QMouseEvent(event->type(), event->pos(), event->button(), event->buttons(), event->modifiers());
+ delayedMousePressEvent = new QMouseEvent(event->type(), event->position().toPoint(), event->button(), event->buttons(), event->modifiers());
} else {
timer.stop();
}
@@ -60,7 +60,7 @@ void QQuickPressHandler::mousePressEvent(QMouseEvent *event)
if (isSignalConnected(control, "pressed(QQuickMouseEvent*)", pressedSignalIndex)) {
QQuickMouseEvent mev;
mev.reset(pressPos.x(), pressPos.y(), event->button(), event->buttons(),
- QGuiApplication::keyboardModifiers(), false/*isClick*/, false/*wasHeld*/);
+ event->modifiers(), false/*isClick*/, false/*wasHeld*/);
mev.setAccepted(true);
QQuickMouseEvent *mevPtr = &mev;
void *args[] = { nullptr, &mevPtr };
@@ -71,7 +71,7 @@ void QQuickPressHandler::mousePressEvent(QMouseEvent *event)
void QQuickPressHandler::mouseMoveEvent(QMouseEvent *event)
{
- if (qAbs(int(event->localPos().x() - pressPos.x())) > QGuiApplication::styleHints()->startDragDistance())
+ if (qAbs(int(event->position().x() - pressPos.x())) > QGuiApplication::styleHints()->startDragDistance())
timer.stop();
}
@@ -83,7 +83,7 @@ void QQuickPressHandler::mouseReleaseEvent(QMouseEvent *event)
if (isSignalConnected(control, "released(QQuickMouseEvent*)", releasedSignalIndex)) {
QQuickMouseEvent mev;
mev.reset(pressPos.x(), pressPos.y(), event->button(), event->buttons(),
- QGuiApplication::keyboardModifiers(), false/*isClick*/, false/*wasHeld*/);
+ event->modifiers(), false/*isClick*/, false/*wasHeld*/);
mev.setAccepted(true);
QQuickMouseEvent *mevPtr = &mev;
void *args[] = { nullptr, &mevPtr };
@@ -101,8 +101,11 @@ void QQuickPressHandler::timerEvent(QTimerEvent *)
longPress = isSignalConnected(control, "pressAndHold(QQuickMouseEvent*)", pressAndHoldSignalIndex);
if (longPress) {
QQuickMouseEvent mev;
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
mev.reset(pressPos.x(), pressPos.y(), Qt::LeftButton, Qt::LeftButton,
QGuiApplication::keyboardModifiers(), false/*isClick*/, true/*wasHeld*/);
+QT_WARNING_POP
mev.setAccepted(true);
// Use fast signal invocation since we already got its index
QQuickMouseEvent *mevPtr = &mev;
diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp
index 9ad12102..2b0f2961 100644
--- a/src/quicktemplates2/qquickrangeslider.cpp
+++ b/src/quicktemplates2/qquickrangeslider.cpp
@@ -1151,14 +1151,14 @@ void QQuickRangeSlider::hoverEnterEvent(QHoverEvent *event)
{
Q_D(QQuickRangeSlider);
QQuickControl::hoverEnterEvent(event);
- d->updateHover(event->posF());
+ d->updateHover(event->position());
}
void QQuickRangeSlider::hoverMoveEvent(QHoverEvent *event)
{
Q_D(QQuickRangeSlider);
QQuickControl::hoverMoveEvent(event);
- d->updateHover(event->posF());
+ d->updateHover(event->position());
}
void QQuickRangeSlider::hoverLeaveEvent(QHoverEvent *event)
@@ -1181,7 +1181,7 @@ void QQuickRangeSlider::mousePressEvent(QMouseEvent *event)
{
Q_D(QQuickRangeSlider);
QQuickControl::mousePressEvent(event);
- d->handleMove(event->localPos());
+ d->handleMove(event->position());
setKeepMouseGrab(true);
}
@@ -1197,20 +1197,20 @@ void QQuickRangeSlider::touchEvent(QTouchEvent *event)
switch (point.state()) {
case Qt::TouchPointPressed:
- d->handlePress(point.pos());
+ d->handlePress(point.position());
break;
case Qt::TouchPointMoved:
if (!keepTouchGrab()) {
if (d->orientation == Qt::Horizontal)
- setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.pos().x() - point.startPos().x(), Qt::XAxis, &point, qRound(d->touchDragThreshold)));
+ setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.position().x() - point.pressPosition().x(), Qt::XAxis, &point, qRound(d->touchDragThreshold)));
else
- setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.pos().y() - point.startPos().y(), Qt::YAxis, &point, qRound(d->touchDragThreshold)));
+ setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.position().y() - point.pressPosition().y(), Qt::YAxis, &point, qRound(d->touchDragThreshold)));
}
if (keepTouchGrab())
- d->handleMove(point.pos());
+ d->handleMove(point.position());
break;
case Qt::TouchPointReleased:
- d->handleRelease(point.pos());
+ d->handleRelease(point.position());
break;
default:
break;
diff --git a/src/quicktemplates2/qquickscrollbar.cpp b/src/quicktemplates2/qquickscrollbar.cpp
index 678b7942..b352224c 100644
--- a/src/quicktemplates2/qquickscrollbar.cpp
+++ b/src/quicktemplates2/qquickscrollbar.cpp
@@ -710,7 +710,7 @@ void QQuickScrollBar::mousePressEvent(QMouseEvent *event)
{
Q_D(QQuickScrollBar);
QQuickControl::mousePressEvent(event);
- d->handleMove(event->localPos());
+ d->handleMove(event->position());
}
#if QT_CONFIG(quicktemplates2_hover)
diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp
index f4a459fa..9d223f25 100644
--- a/src/quicktemplates2/qquickslider.cpp
+++ b/src/quicktemplates2/qquickslider.cpp
@@ -790,7 +790,7 @@ void QQuickSlider::mousePressEvent(QMouseEvent *event)
{
Q_D(QQuickSlider);
QQuickControl::mousePressEvent(event);
- d->handleMove(event->localPos());
+ d->handleMove(event->position());
setKeepMouseGrab(true);
}
@@ -806,20 +806,20 @@ void QQuickSlider::touchEvent(QTouchEvent *event)
switch (point.state()) {
case Qt::TouchPointPressed:
- d->handlePress(point.pos());
+ d->handlePress(point.position());
break;
case Qt::TouchPointMoved:
if (!keepTouchGrab()) {
if (d->orientation == Qt::Horizontal)
- setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.pos().x() - d->pressPoint.x(), Qt::XAxis, &point, qRound(d->touchDragThreshold)));
+ setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.position().x() - d->pressPoint.x(), Qt::XAxis, &point, qRound(d->touchDragThreshold)));
else
- setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.pos().y() - d->pressPoint.y(), Qt::YAxis, &point, qRound(d->touchDragThreshold)));
+ setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.position().y() - d->pressPoint.y(), Qt::YAxis, &point, qRound(d->touchDragThreshold)));
}
if (keepTouchGrab())
- d->handleMove(point.pos());
+ d->handleMove(point.position());
break;
case Qt::TouchPointReleased:
- d->handleRelease(point.pos());
+ d->handleRelease(point.position());
break;
default:
break;
diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp
index 687ccafd..c1541a99 100644
--- a/src/quicktemplates2/qquickspinbox.cpp
+++ b/src/quicktemplates2/qquickspinbox.cpp
@@ -891,14 +891,14 @@ void QQuickSpinBox::hoverEnterEvent(QHoverEvent *event)
{
Q_D(QQuickSpinBox);
QQuickControl::hoverEnterEvent(event);
- d->updateHover(event->posF());
+ d->updateHover(event->position());
}
void QQuickSpinBox::hoverMoveEvent(QHoverEvent *event)
{
Q_D(QQuickSpinBox);
QQuickControl::hoverMoveEvent(event);
- d->updateHover(event->posF());
+ d->updateHover(event->position());
}
void QQuickSpinBox::hoverLeaveEvent(QHoverEvent *event)
diff --git a/src/quicktemplates2/qquicksplitview.cpp b/src/quicktemplates2/qquicksplitview.cpp
index a1016792..df00f522 100644
--- a/src/quicktemplates2/qquicksplitview.cpp
+++ b/src/quicktemplates2/qquicksplitview.cpp
@@ -1389,7 +1389,7 @@ void QQuickSplitView::hoverMoveEvent(QHoverEvent *event)
Q_D(QQuickSplitView);
QQuickContainer::hoverMoveEvent(event);
- QQuickItem *hoveredItem = childAt(event->pos().x(), event->pos().y());
+ QQuickItem *hoveredItem = childAt(event->position().toPoint().x(), event->position().toPoint().y());
d->updateHoveredHandle(hoveredItem);
}
@@ -2029,7 +2029,7 @@ const QQuickSplitHandleAttachedPrivate *QQuickSplitHandleAttachedPrivate::get(co
}
QQuickSplitHandleAttached::QQuickSplitHandleAttached(QObject *parent)
- : QObject(*(new QQuickSplitViewAttachedPrivate), parent)
+ : QObject(*(new QQuickSplitHandleAttachedPrivate), parent)
{
}
diff --git a/src/quicktemplates2/qquicksplitview_p_p.h b/src/quicktemplates2/qquicksplitview_p_p.h
index 2430eac1..6123f83d 100644
--- a/src/quicktemplates2/qquicksplitview_p_p.h
+++ b/src/quicktemplates2/qquicksplitview_p_p.h
@@ -109,7 +109,7 @@ public:
Qt::Orientation m_orientation = Qt::Horizontal;
QQmlComponent *m_handle = nullptr;
- QVector<QQuickItem*> m_handleItems;
+ QList<QQuickItem*> m_handleItems;
int m_hoveredHandleIndex = -1;
int m_pressedHandleIndex = -1;
int m_nextVisibleIndexAfterPressedHandle = -1;
diff --git a/src/quicktemplates2/qquickstackview.cpp b/src/quicktemplates2/qquickstackview.cpp
index e5e2c39b..83f99843 100644
--- a/src/quicktemplates2/qquickstackview.cpp
+++ b/src/quicktemplates2/qquickstackview.cpp
@@ -498,7 +498,7 @@ QQuickItem *QQuickStackView::find(const QJSValue &callback, LoadBehavior behavio
/*!
\qmlmethod Item QtQuick.Controls::StackView::push(item, properties, operation)
- Pushes an \a item onto the stack using the specified \a operation, and
+ Pushes an \a item onto the stack using an optional \a operation, and
optionally applies a set of \a properties on the item. The item can be
an \l Item, \l Component, or a \l [QML] url. Returns the item that became
current.
@@ -545,12 +545,13 @@ QQuickItem *QQuickStackView::find(const QJSValue &callback, LoadBehavior behavio
An \a operation can be optionally specified as the last argument. Supported
operations:
- \value StackView.Transition An operation with default transitions (default).
\value StackView.Immediate An immediate operation without transitions.
\value StackView.PushTransition An operation with push transitions (since QtQuick.Controls 2.1).
\value StackView.ReplaceTransition An operation with replace transitions (since QtQuick.Controls 2.1).
\value StackView.PopTransition An operation with pop transitions (since QtQuick.Controls 2.1).
+ If no operation is provided, \c PushTransition will be used.
+
\note Items that already exist in the stack are not pushed.
\sa initialItem, {Pushing Items}
@@ -639,12 +640,13 @@ void QQuickStackView::push(QQmlV4Function *args)
An \a operation can be optionally specified as the last argument. Supported
operations:
- \value StackView.Transition An operation with default transitions (default).
\value StackView.Immediate An immediate operation without transitions.
\value StackView.PushTransition An operation with push transitions (since QtQuick.Controls 2.1).
\value StackView.ReplaceTransition An operation with replace transitions (since QtQuick.Controls 2.1).
\value StackView.PopTransition An operation with pop transitions (since QtQuick.Controls 2.1).
+ If no operation is provided, \c PopTransition will be used.
+
Examples:
\code
stackView.pop()
@@ -733,7 +735,7 @@ void QQuickStackView::pop(QQmlV4Function *args)
\qmlmethod Item QtQuick.Controls::StackView::replace(target, item, properties, operation)
Replaces one or more items on the stack with the specified \a item and
- \a operation, and optionally applies a set of \a properties on the
+ optional \a operation, and optionally applies a set of \a properties on the
item. The item can be an \l Item, \l Component, or a \l [QML] url.
Returns the item that became current.
@@ -782,12 +784,13 @@ void QQuickStackView::pop(QQmlV4Function *args)
An \a operation can be optionally specified as the last argument. Supported
operations:
- \value StackView.Transition An operation with default transitions (default).
\value StackView.Immediate An immediate operation without transitions.
\value StackView.PushTransition An operation with push transitions (since QtQuick.Controls 2.1).
\value StackView.ReplaceTransition An operation with replace transitions (since QtQuick.Controls 2.1).
\value StackView.PopTransition An operation with pop transitions (since QtQuick.Controls 2.1).
+ If no operation is provided, \c ReplaceTransition will be used.
+
The following example illustrates the use of push and pop transitions with replace().
\code
diff --git a/src/quicktemplates2/qquickstackview_p.h b/src/quicktemplates2/qquickstackview_p.h
index 9bb9c8f4..f551f027 100644
--- a/src/quicktemplates2/qquickstackview_p.h
+++ b/src/quicktemplates2/qquickstackview_p.h
@@ -124,7 +124,7 @@ public:
Q_INVOKABLE QQuickItem *find(const QJSValue &callback, LoadBehavior behavior = DontLoad);
enum Operation {
- Transition = -1, // deprecated
+ Transition = -1, // ### Deprecated in Qt 6; remove in Qt 7.
Immediate = 0,
PushTransition = 1,
ReplaceTransition = 2,
diff --git a/src/quicktemplates2/qquickswipedelegate.cpp b/src/quicktemplates2/qquickswipedelegate.cpp
index 8c8d8c6e..a28d8ecf 100644
--- a/src/quicktemplates2/qquickswipedelegate.cpp
+++ b/src/quicktemplates2/qquickswipedelegate.cpp
@@ -720,7 +720,7 @@ bool QQuickSwipeDelegatePrivate::handleMousePressEvent(QQuickItem *item, QMouseE
// The press point could be incorrect if the press happened over a child item,
// so we correct it after calling the base class' mousePressEvent(), rather
// than having to duplicate its code just so we can set the pressPoint.
- setPressPoint(item->mapToItem(q, event->pos()));
+ setPressPoint(item->mapToItem(q, event->position().toPoint()));
return true;
}
@@ -728,8 +728,8 @@ bool QQuickSwipeDelegatePrivate::handleMousePressEvent(QQuickItem *item, QMouseE
// (the control can be clicked to e.g. close the swipe). Either way, we must begin measuring
// mouse movement in case it turns into a swipe, in which case we grab the mouse.
swipePrivate->positionBeforePress = swipePrivate->position;
- swipePrivate->velocityCalculator.startMeasuring(event->pos(), event->timestamp());
- setPressPoint(item->mapToItem(q, event->pos()));
+ swipePrivate->velocityCalculator.startMeasuring(event->position().toPoint(), event->timestamp());
+ setPressPoint(item->mapToItem(q, event->position().toPoint()));
// When a delegate uses the attached properties and signals, it declares that it wants mouse events.
Attached *attached = attachedObject(item);
@@ -748,7 +748,7 @@ bool QQuickSwipeDelegatePrivate::handleMouseMoveEvent(QQuickItem *item, QMouseEv
Q_Q(QQuickSwipeDelegate);
if (holdTimer > 0) {
- if (QLineF(pressPoint, event->localPos()).length() > QGuiApplication::styleHints()->startDragDistance())
+ if (QLineF(pressPoint, event->position()).length() > QGuiApplication::styleHints()->startDragDistance())
stopPressAndHold();
}
@@ -770,7 +770,7 @@ bool QQuickSwipeDelegatePrivate::handleMouseMoveEvent(QQuickItem *item, QMouseEv
if (item == q && !pressed)
return false;
- const QPointF mappedEventPos = item->mapToItem(q, event->pos());
+ const QPointF mappedEventPos = item->mapToItem(q, event->position().toPoint());
const qreal distance = (mappedEventPos - pressPoint).x();
if (!q->keepMouseGrab()) {
// Taken from QQuickDrawerPrivate::grabMouse; see comments there.
@@ -840,7 +840,7 @@ bool QQuickSwipeDelegatePrivate::handleMouseMoveEvent(QQuickItem *item, QMouseEv
}
} else {
// The swipe wasn't initiated.
- if (event->pos().y() < 0 || event->pos().y() > height) {
+ if (event->position().toPoint().y() < 0 || event->position().toPoint().y() > height) {
// The mouse went outside the vertical bounds of the control, so
// we should no longer consider it pressed.
q->setPressed(false);
@@ -858,7 +858,7 @@ bool QQuickSwipeDelegatePrivate::handleMouseReleaseEvent(QQuickItem *item, QMous
{
Q_Q(QQuickSwipeDelegate);
QQuickSwipePrivate *swipePrivate = QQuickSwipePrivate::get(&swipe);
- swipePrivate->velocityCalculator.stopMeasuring(event->pos(), event->timestamp());
+ swipePrivate->velocityCalculator.stopMeasuring(event->position().toPoint(), event->timestamp());
const bool hadGrabbedMouse = q->keepMouseGrab();
q->setKeepMouseGrab(false);
@@ -1180,7 +1180,7 @@ void QQuickSwipeDelegate::mousePressEvent(QMouseEvent *event)
return;
swipePrivate->positionBeforePress = swipePrivate->position;
- swipePrivate->velocityCalculator.startMeasuring(event->pos(), event->timestamp());
+ swipePrivate->velocityCalculator.startMeasuring(event->position().toPoint(), event->timestamp());
}
void QQuickSwipeDelegate::mouseMoveEvent(QMouseEvent *event)
diff --git a/src/quicktemplates2/qquickswitch.cpp b/src/quicktemplates2/qquickswitch.cpp
index 08ea44da..2bba350d 100644
--- a/src/quicktemplates2/qquickswitch.cpp
+++ b/src/quicktemplates2/qquickswitch.cpp
@@ -180,7 +180,7 @@ void QQuickSwitch::mouseMoveEvent(QMouseEvent *event)
{
Q_D(QQuickSwitch);
if (!keepMouseGrab()) {
- const QPointF movePoint = event->localPos();
+ const QPointF movePoint = event->position();
if (d->canDrag(movePoint))
setKeepMouseGrab(QQuickWindowPrivate::dragOverThreshold(movePoint.x() - d->pressPoint.x(), Qt::XAxis, event));
}
@@ -195,8 +195,8 @@ void QQuickSwitch::touchEvent(QTouchEvent *event)
for (const QTouchEvent::TouchPoint &point : event->touchPoints()) {
if (point.id() != d->touchId || point.state() != Qt::TouchPointMoved)
continue;
- if (d->canDrag(point.pos()))
- setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.pos().x() - d->pressPoint.x(), Qt::XAxis, &point));
+ if (d->canDrag(point.position()))
+ setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.position().x() - d->pressPoint.x(), Qt::XAxis, &point));
}
}
QQuickAbstractButton::touchEvent(event);
diff --git a/src/quicktemplates2/qquickswitchdelegate.cpp b/src/quicktemplates2/qquickswitchdelegate.cpp
index d0e3afc8..3300e252 100644
--- a/src/quicktemplates2/qquickswitchdelegate.cpp
+++ b/src/quicktemplates2/qquickswitchdelegate.cpp
@@ -177,7 +177,7 @@ void QQuickSwitchDelegate::mouseMoveEvent(QMouseEvent *event)
{
Q_D(QQuickSwitchDelegate);
if (!keepMouseGrab()) {
- const QPointF movePoint = event->localPos();
+ const QPointF movePoint = event->position();
if (d->canDrag(movePoint))
setKeepMouseGrab(QQuickWindowPrivate::dragOverThreshold(movePoint.x() - d->pressPoint.x(), Qt::XAxis, event));
}
@@ -192,8 +192,8 @@ void QQuickSwitchDelegate::touchEvent(QTouchEvent *event)
for (const QTouchEvent::TouchPoint &point : event->touchPoints()) {
if (point.id() != d->touchId || point.state() != Qt::TouchPointMoved)
continue;
- if (d->canDrag(point.pos()))
- setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.pos().x() - d->pressPoint.x(), Qt::XAxis, &point));
+ if (d->canDrag(point.position()))
+ setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.position().x() - d->pressPoint.x(), Qt::XAxis, &point));
}
}
QQuickItemDelegate::touchEvent(event);
diff --git a/src/quicktemplates2/qquicktabbar.cpp b/src/quicktemplates2/qquicktabbar.cpp
index c90ff674..b38699df 100644
--- a/src/quicktemplates2/qquicktabbar.cpp
+++ b/src/quicktemplates2/qquicktabbar.cpp
@@ -158,7 +158,7 @@ void QQuickTabBarPrivate::updateLayout()
qreal reservedWidth = 0;
int resizableCount = 0;
- QVector<QQuickItem *> allItems;
+ QList<QQuickItem *> allItems;
allItems.reserve(count);
for (int i = 0; i < count; ++i) {
diff --git a/src/quicktemplates2/qquicktextfield.cpp b/src/quicktemplates2/qquicktextfield.cpp
index 0dcebb40..c8e61094 100644
--- a/src/quicktemplates2/qquicktextfield.cpp
+++ b/src/quicktemplates2/qquicktextfield.cpp
@@ -309,7 +309,7 @@ void QQuickTextFieldPrivate::echoModeChanged(QQuickTextField::EchoMode echoMode)
if (QQuickAccessibleAttached *accessibleAttached = QQuickControlPrivate::accessibleAttached(q_func()))
accessibleAttached->set_passwordEdit((echoMode == QQuickTextField::Password || echoMode == QQuickTextField::PasswordEchoOnEdit) ? true : false);
#else
- Q_UNUSED(echoMode)
+ Q_UNUSED(echoMode);
#endif
}