aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-02-09 03:02:20 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-02-09 03:02:21 +0100
commit7b48bda18f836671cda6d47d6570fc522a4361ec (patch)
treeba0093c597b5581aa6fc86964c3d95d7fe9bfe36 /src
parent3afec43b69991753416380d88e22b5382b8b0832 (diff)
parent4e5601ac1c7aec6aba9ba09fe7adb7a0462da2f0 (diff)
Merge remote-tracking branch 'origin/5.12' into 5.13
Diffstat (limited to 'src')
-rw-r--r--src/imports/controls/qtquickcontrols2plugin.cpp8
-rw-r--r--src/quicktemplates2/qquickabstractbutton.cpp3
-rw-r--r--src/quicktemplates2/qquickcontrol.cpp5
-rw-r--r--src/quicktemplates2/qquickcontrol_p.h1
-rw-r--r--src/quicktemplates2/qquickmenu.cpp31
-rw-r--r--src/quicktemplates2/qquickmenu_p_p.h2
-rw-r--r--src/quicktemplates2/qquickpopup.cpp18
-rw-r--r--src/quicktemplates2/qquickpopupitem.cpp13
-rw-r--r--src/quicktemplates2/qquickpopupitem_p_p.h1
9 files changed, 68 insertions, 14 deletions
diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp
index 133be0d1..89d956bd 100644
--- a/src/imports/controls/qtquickcontrols2plugin.cpp
+++ b/src/imports/controls/qtquickcontrols2plugin.cpp
@@ -308,7 +308,15 @@ QQuickTheme *QtQuickControls2Plugin::createTheme(const QString &name)
QSharedPointer<QSettings> settings = QQuickStylePrivate::settings(name);
if (settings) {
p->defaultFont.reset(QQuickStylePrivate::readFont(settings));
+ // Set the default font as the System scope, because that's what
+ // QQuickControlPrivate::parentFont() uses as its fallback if no
+ // parent item has a font explicitly set. QQuickControlPrivate::parentFont()
+ // is used as the starting point for font inheritance/resolution.
+ // The same goes for palettes below.
+ theme->setFont(QQuickTheme::System, *p->defaultFont);
+
p->defaultPalette.reset(QQuickStylePrivate::readPalette(settings));
+ theme->setPalette(QQuickTheme::System, *p->defaultPalette);
}
#endif
QQuickThemePrivate::instance.reset(theme);
diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp
index 9157b4f9..3b41f34c 100644
--- a/src/quicktemplates2/qquickabstractbutton.cpp
+++ b/src/quicktemplates2/qquickabstractbutton.cpp
@@ -324,9 +324,10 @@ void QQuickAbstractButtonPrivate::click()
void QQuickAbstractButtonPrivate::trigger()
{
Q_Q(QQuickAbstractButton);
+ const bool wasEnabled = effectiveEnable;
if (action && action->isEnabled())
QQuickActionPrivate::get(action)->trigger(q, false);
- else if (effectiveEnable)
+ if (wasEnabled && (!action || !action->isEnabled()))
emit q->clicked();
}
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp
index 1fa70662..a61df3ca 100644
--- a/src/quicktemplates2/qquickcontrol.cpp
+++ b/src/quicktemplates2/qquickcontrol.cpp
@@ -943,6 +943,7 @@ void QQuickControl::itemChange(QQuickItem::ItemChange change, const QQuickItem::
switch (change) {
case ItemEnabledHasChanged:
emit paletteChanged();
+ enabledChange();
break;
case ItemVisibleHasChanged:
#if QT_CONFIG(quicktemplates2_hover)
@@ -2184,6 +2185,10 @@ void QQuickControl::geometryChanged(const QRectF &newGeometry, const QRectF &old
emit availableHeightChanged();
}
+void QQuickControl::enabledChange()
+{
+}
+
void QQuickControl::fontChange(const QFont &newFont, const QFont &oldFont)
{
Q_UNUSED(newFont);
diff --git a/src/quicktemplates2/qquickcontrol_p.h b/src/quicktemplates2/qquickcontrol_p.h
index a38e34f9..3fe20f3b 100644
--- a/src/quicktemplates2/qquickcontrol_p.h
+++ b/src/quicktemplates2/qquickcontrol_p.h
@@ -278,6 +278,7 @@ protected:
virtual void localeChange(const QLocale &newLocale, const QLocale &oldLocale);
virtual void paletteChange(const QPalette &newPalette, const QPalette &oldPalette);
virtual void insetChange(const QMarginsF &newInset, const QMarginsF &oldInset);
+ virtual void enabledChange();
#if QT_CONFIG(accessibility)
virtual QAccessible::Role accessibleRole() const;
diff --git a/src/quicktemplates2/qquickmenu.cpp b/src/quicktemplates2/qquickmenu.cpp
index f52405c9..f91d15a5 100644
--- a/src/quicktemplates2/qquickmenu.cpp
+++ b/src/quicktemplates2/qquickmenu.cpp
@@ -468,10 +468,12 @@ void QQuickMenuPrivate::onItemTriggered()
if (!item)
return;
- if (QQuickMenu *subMenu = item->subMenu())
- subMenu->popup(subMenu->itemAt(0));
- else
+ if (QQuickMenu *subMenu = item->subMenu()) {
+ auto subMenuPrivate = QQuickMenuPrivate::get(subMenu);
+ subMenu->popup(subMenuPrivate->firstEnabledMenuItem());
+ } else {
q->dismiss();
+ }
}
void QQuickMenuPrivate::onItemActiveFocusChanged()
@@ -600,7 +602,7 @@ bool QQuickMenuPrivate::activateNextItem()
int count = contentModel->count();
while (++index < count) {
QQuickItem *item = itemAt(index);
- if (!item || !item->activeFocusOnTab())
+ if (!item || !item->activeFocusOnTab() || !item->isEnabled())
continue;
setCurrentIndex(index, Qt::TabFocusReason);
return true;
@@ -613,7 +615,7 @@ bool QQuickMenuPrivate::activatePreviousItem()
int index = currentIndex;
while (--index >= 0) {
QQuickItem *item = itemAt(index);
- if (!item || !item->activeFocusOnTab())
+ if (!item || !item->activeFocusOnTab() || !item->isEnabled())
continue;
setCurrentIndex(index, Qt::BacktabFocusReason);
return true;
@@ -621,6 +623,22 @@ bool QQuickMenuPrivate::activatePreviousItem()
return false;
}
+QQuickMenuItem *QQuickMenuPrivate::firstEnabledMenuItem() const
+{
+ for (int i = 0; i < contentModel->count(); ++i) {
+ QQuickItem *item = itemAt(i);
+ if (!item || !item->isEnabled())
+ continue;
+
+ QQuickMenuItem *menuItem = qobject_cast<QQuickMenuItem *>(item);
+ if (!menuItem)
+ continue;
+
+ return menuItem;
+ }
+ return nullptr;
+}
+
void QQuickMenuPrivate::contentData_append(QQmlListProperty<QObject> *prop, QObject *obj)
{
QQuickMenu *q = qobject_cast<QQuickMenu *>(prop->object);
@@ -1419,7 +1437,8 @@ void QQuickMenu::keyPressEvent(QKeyEvent *event)
}
} else {
if (QQuickMenu *subMenu = d->currentSubMenu()) {
- subMenu->popup(subMenu->itemAt(0));
+ auto subMenuPrivate = QQuickMenuPrivate::get(subMenu);
+ subMenu->popup(subMenuPrivate->firstEnabledMenuItem());
event->accept();
}
}
diff --git a/src/quicktemplates2/qquickmenu_p_p.h b/src/quicktemplates2/qquickmenu_p_p.h
index 6146b960..ec48c919 100644
--- a/src/quicktemplates2/qquickmenu_p_p.h
+++ b/src/quicktemplates2/qquickmenu_p_p.h
@@ -115,6 +115,8 @@ public:
bool activateNextItem();
bool activatePreviousItem();
+ QQuickMenuItem *firstEnabledMenuItem() const;
+
static void contentData_append(QQmlListProperty<QObject> *prop, QObject *obj);
static int contentData_count(QQmlListProperty<QObject> *prop);
static QObject *contentData_at(QQmlListProperty<QObject> *prop, int index);
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index e542e7e8..72e4f042 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -263,7 +263,6 @@ void QQuickPopupPrivate::init()
popupItem = new QQuickPopupItem(q);
popupItem->setVisible(false);
q->setParentItem(qobject_cast<QQuickItem *>(parent));
- QObject::connect(popupItem, &QQuickItem::enabledChanged, q, &QQuickPopup::enabledChanged);
QObject::connect(popupItem, &QQuickControl::paddingChanged, q, &QQuickPopup::paddingChanged);
QObject::connect(popupItem, &QQuickControl::backgroundChanged, q, &QQuickPopup::backgroundChanged);
QObject::connect(popupItem, &QQuickControl::contentItemChanged, q, &QQuickPopup::contentItemChanged);
@@ -1666,8 +1665,7 @@ void QQuickPopup::setBackground(QQuickItem *background)
The content item is the visual implementation of the popup. When the
popup is made visible, the content item is automatically reparented to
- the \l {ApplicationWindow::overlay}{overlay item} of its application
- window.
+ the \l {Overlay::overlay}{overlay item}.
\note The content item is automatically resized to fit within the
\l padding of the popup.
@@ -1807,14 +1805,20 @@ bool QQuickPopup::hasActiveFocus() const
This property holds whether the popup is modal.
Modal popups often have a distinctive background dimming effect defined
- in \l {ApplicationWindow::overlay}{overlay.modal}, and do not allow press
- or release events through to items beneath them.
+ in \l {Overlay::modal}{Overlay.modal}, and do not allow press
+ or release events through to items beneath them. For example, if the user
+ accidentally clicks outside of a popup, any item beneath that popup at
+ the location of the click will not receive the event.
On desktop platforms, it is common for modal popups to be closed only when
the escape key is pressed. To achieve this behavior, set
- \l closePolicy to \c Popup.CloseOnEscape.
+ \l closePolicy to \c Popup.CloseOnEscape. By default, \c closePolicy
+ is set to \c {Popup.CloseOnEscape | Popup.CloseOnPressOutside}, which
+ means that clicking outside of a modal popup will close it.
The default value is \c false.
+
+ \sa dim
*/
bool QQuickPopup::isModal() const
{
@@ -1846,7 +1850,7 @@ void QQuickPopup::setModal(bool modal)
Unless explicitly set, this property follows the value of \l modal. To
return to the default value, set this property to \c undefined.
- \sa modal
+ \sa modal, {Overlay::modeless}{Overlay.modeless}
*/
bool QQuickPopup::dim() const
{
diff --git a/src/quicktemplates2/qquickpopupitem.cpp b/src/quicktemplates2/qquickpopupitem.cpp
index cf2fec41..16d8c4f6 100644
--- a/src/quicktemplates2/qquickpopupitem.cpp
+++ b/src/quicktemplates2/qquickpopupitem.cpp
@@ -366,6 +366,19 @@ void QQuickPopupItem::paletteChange(const QPalette &newPalette, const QPalette &
d->popup->paletteChange(newPalette, oldPalette);
}
+void QQuickPopupItem::enabledChange()
+{
+ Q_D(QQuickPopupItem);
+ // Just having QQuickPopup connect our QQuickItem::enabledChanged() signal
+ // to its enabledChanged() signal is enough for the enabled property to work,
+ // but we must also ensure that its paletteChanged() signal is emitted
+ // so that bindings to palette are re-evaluated, because QQuickControl::palette()
+ // returns a different palette depending on whether or not the control is enabled.
+ // To save a connection, we also emit enabledChanged here.
+ emit d->popup->enabledChanged();
+ emit d->popup->paletteChanged();
+}
+
QFont QQuickPopupItem::defaultFont() const
{
Q_D(const QQuickPopupItem);
diff --git a/src/quicktemplates2/qquickpopupitem_p_p.h b/src/quicktemplates2/qquickpopupitem_p_p.h
index a15aeb17..a12e43e0 100644
--- a/src/quicktemplates2/qquickpopupitem_p_p.h
+++ b/src/quicktemplates2/qquickpopupitem_p_p.h
@@ -95,6 +95,7 @@ protected:
void itemChange(ItemChange change, const ItemChangeData &data) override;
void paddingChange(const QMarginsF &newPadding, const QMarginsF &oldPadding) override;
void paletteChange(const QPalette &newPalette, const QPalette &oldPalette) override;
+ void enabledChange() override;
QFont defaultFont() const override;
QPalette defaultPalette() const override;