diff options
Diffstat (limited to 'src')
20 files changed, 187 insertions, 104 deletions
diff --git a/src/qml/CMakeLists.txt b/src/qml/CMakeLists.txt index 068cf9e1fd..2d327caf77 100644 --- a/src/qml/CMakeLists.txt +++ b/src/qml/CMakeLists.txt @@ -139,7 +139,7 @@ qt_internal_add_qml_module(Qml inlinecomponentutils_p.h jsapi/qjsengine.cpp jsapi/qjsengine.h jsapi/qjsengine_p.h jsapi/qjslist.cpp jsapi/qjslist.h - jsapi/qjsmanagedvalue.cpp jsapi/qjsmanagedvalue.h + jsapi/qjsmanagedvalue.cpp jsapi/qjsmanagedvalue.h jsapi/qjsmanagedvalue_p.h jsapi/qjsprimitivevalue.cpp jsapi/qjsprimitivevalue.h jsapi/qjsvalue.cpp jsapi/qjsvalue.h jsapi/qjsvalue_p.h jsapi/qjsvalueiterator.cpp jsapi/qjsvalueiterator.h jsapi/qjsvalueiterator_p.h diff --git a/src/qml/jsapi/qjsmanagedvalue.h b/src/qml/jsapi/qjsmanagedvalue.h index a6f67b0cc0..24117a2e89 100644 --- a/src/qml/jsapi/qjsmanagedvalue.h +++ b/src/qml/jsapi/qjsmanagedvalue.h @@ -120,6 +120,7 @@ public: private: friend class QJSValue; friend class QJSEngine; + friend class QJSManagedValuePrivate; QJSManagedValue(QV4::ExecutionEngine *engine); QV4::Value *d = nullptr; diff --git a/src/qml/jsapi/qjsmanagedvalue_p.h b/src/qml/jsapi/qjsmanagedvalue_p.h new file mode 100644 index 0000000000..f949561dfc --- /dev/null +++ b/src/qml/jsapi/qjsmanagedvalue_p.h @@ -0,0 +1,32 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QJSMANAGEDVALUE_P_H +#define QJSMANAGEDVALUE_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 "qjsmanagedvalue.h" + +QT_BEGIN_NAMESPACE + +// ### Qt 7: Use this for proper PIMPL +class QJSManagedValuePrivate +{ +public: + static QV4::Value *member(const QJSManagedValue *jsmv) { return jsmv->d; } + static QV4::Value **memberPtr(QJSManagedValue *jsmv) { return &jsmv->d; } +}; + +QT_END_NAMESPACE + +#endif // QJSMANAGEDVALUE_P_H diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index ecb9e8053b..c53968300d 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -4,6 +4,7 @@ #include "qv4qobjectwrapper_p.h" #include <private/qjsvalue_p.h> +#include <private/qjsmanagedvalue_p.h> #include <private/qqmlbinding_p.h> #include <private/qqmlbuiltinfunctions_p.h> @@ -1636,6 +1637,7 @@ private: QString, QList<QObject *>, QJSValue, + QJSManagedValue, QJsonArray, QJsonObject, QJsonValue>]; @@ -1649,6 +1651,7 @@ private: QVariant *qvariantPtr; QList<QObject *> *qlistPtr; QJSValue *qjsValuePtr; + QJSManagedValue *qjsManagedValuePtr; QJsonArray *jsonArrayPtr; QJsonObject *jsonObjectPtr; QJsonValue *jsonValuePtr; @@ -2303,6 +2306,11 @@ void CallArgument::cleanup() break; } + if (type == qMetaTypeId<QJSManagedValue>()) { + qjsManagedValuePtr->~QJSManagedValue(); + break; + } + if (type == qMetaTypeId<QList<QObject *> >()) { qlistPtr->~QList<QObject *>(); break; @@ -2383,6 +2391,11 @@ void CallArgument::initAsType(QMetaType metaType) break; } + if (metaType == QMetaType::fromType<QJSManagedValue>()) { + qjsManagedValuePtr = new (&allocData) QJSManagedValue(); + break; + } + if (metaType == QMetaType::fromType<QList<QObject *>>()) { qlistPtr = new (&allocData) QList<QObject *>(); break; @@ -2499,6 +2512,15 @@ bool CallArgument::fromValue(QMetaType metaType, ExecutionEngine *engine, const return true; } + if (type == qMetaTypeId<QJSManagedValue>()) { + Scope scope(engine); + ScopedValue v(scope, value); + qjsManagedValuePtr = new (&allocData) QJSManagedValue; + // This points to a JS heap object that cannot be immutable. const_cast-ing is fine here. + *QJSManagedValuePrivate::memberPtr(qjsManagedValuePtr) = const_cast<Value *>(&value); + return true; + } + if (type == qMetaTypeId<QList<QObject*> >()) { qlistPtr = new (&allocData) QList<QObject *>(); Scope scope(engine); @@ -2645,6 +2667,9 @@ ReturnedValue CallArgument::toValue(ExecutionEngine *engine) return QJSValuePrivate::asReturnedValue(qjsValuePtr); } + if (type == qMetaTypeId<QJSManagedValue>()) + return QJSManagedValuePrivate::member(qjsManagedValuePtr)->asReturnedValue(); + if (type == qMetaTypeId<QList<QObject *> >()) { // XXX Can this be made more by using Array as a prototype and implementing // directly against QList<QObject*>? diff --git a/src/qml/qml/qqmlbuiltinfunctions.cpp b/src/qml/qml/qqmlbuiltinfunctions.cpp index a5cdafc273..30e9dddaa5 100644 --- a/src/qml/qml/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/qqmlbuiltinfunctions.cpp @@ -1865,99 +1865,72 @@ void QtObject::callLater(QQmlV4FunctionPtr args) \qmlmethod Qt::enumStringToValue(enumType, keyName) Returns the numeric value of key \a keyName in enum \a enumType. If the - enum could not be found or if the key is not an entry of the enum, - \c undefined is returned instead. + enum could not be found, a \c TypeError is thrown. If the key is not an + entry of the enum, a \c ReferenceError is thrown. */ -QVariant QtObject::enumStringToValue(QJSValue enumType, QJSValue string) +double QtObject::enumStringToValue(const QJSManagedValue &enumType, const QString &string) { - if (!enumType.isObject() || !string.isString()) - return QVariant(); - - const auto *enumWrapper = QJSValuePrivate::takeManagedValue(&enumType)->as<QQmlEnumWrapper>(); - if (!enumWrapper) - return QVariant(); - - bool ok = false; - QQmlType type = enumWrapper->d()->type(); - int enumIndex = enumWrapper->d()->enumIndex; - QString keyString = string.toString(); - auto *typeLoader = m_engine->typeLoader(); - int value = enumWrapper->d()->scoped - ? type.scopedEnumValue(typeLoader, enumIndex, keyString, &ok) - : type.unscopedEnumValue(typeLoader, enumIndex, keyString, &ok); - - if (ok) - return value; - - return QVariant(); + return retrieveFromEnum<double>( + enumType, + [&](const QQmlType &type, QQmlTypeLoader *typeLoader, int enumIndex, bool *ok) { + return type.scopedEnumValue(typeLoader, enumIndex, string, ok); + }, [&](const QQmlType &type, QQmlTypeLoader *typeLoader, int enumIndex, bool *ok) { + return type.unscopedEnumValue(typeLoader, enumIndex, string, ok); + }, m_engine); } /*! - \qmlmethod Qt::enumValueToString(enumType, keyNumericValue) + \qmlmethod Qt::enumValueToString(enumType, keyValue) Returns the string representation of a key of enum \a enumType that has the - value \a keyNumericValue. If the enum could not be found or if the value - does not match any key of the enum, \c undefined is returned instead. + value \a keyValue. If the enum could not be found, a \c TypeError is + thrown. If the value does not match any key of the enum, a + \c ReferenceError is thrown. - \note If multiple keys match the value of \a keyNumericValue, which of the + \note If multiple keys match the value of \a keyValue, which of the matching keys will be returned is unspecified. Use enumValueToStrings in that case. */ -QVariant QtObject::enumValueToString(QJSValue enumType, QJSValue value) +QString QtObject::enumValueToString(const QJSManagedValue &enumType, double value) { - if (!enumType.isObject() || !value.isNumber()) - return QVariant(); - - const auto *enumWrapper = QJSValuePrivate::takeManagedValue(&enumType)->as<QQmlEnumWrapper>(); - if (!enumWrapper) - return QVariant(); - - bool ok = false; - QQmlType type = enumWrapper->d()->type(); - int enumIndex = enumWrapper->d()->enumIndex; - int keyValue = value.toInt(); - auto *typeLoader = m_engine->typeLoader(); - QString key = enumWrapper->d()->scoped - ? type.scopedEnumKey(typeLoader, enumIndex, keyValue, &ok) - : type.unscopedEnumKey(typeLoader, enumIndex, keyValue, &ok); - - if (ok) - return key; + // Undefined -> double = NaN + if (std::isnan(value)) { + m_engine->throwReferenceError("Invalid second argument, entry"_L1); + return {}; + } - return QVariant(); + return retrieveFromEnum<QString>( + enumType, + [&](const QQmlType &type, QQmlTypeLoader *typeLoader, int enumIndex, bool *ok) { + return type.scopedEnumKey(typeLoader, enumIndex, QtPrivate::qSaturateRound(value), ok); + }, [&](const QQmlType &type, QQmlTypeLoader *typeLoader, int enumIndex, bool *ok) { + return type.unscopedEnumKey(typeLoader, enumIndex, QtPrivate::qSaturateRound(value), ok); + }, m_engine); } /*! - \qmlmethod Qt::enumValueToStrings(enumType, keyNumericValue) + \qmlmethod Qt::enumValueToStrings(enumType, keyValue) Returns a list of the string representation of all the keys of enum - \a enumType that have the value \a keyNumericValue. If the enum could not - be found, undefined is retured instead. If no key matches the provided - value, the returned list is empty. + \a enumType that have the value \a keyValue. If the enum could not be + found, a \c TypeError is thrown. If no key in the enum has value + \a keyValue, a \c ReferenceError is thrown. */ -QVariant QtObject::enumValueToStrings(QJSValue enumType, QJSValue value) +QStringList QtObject::enumValueToStrings(const QJSManagedValue &enumType, double value) { - if (!enumType.isObject() || !value.isNumber()) - return QVariant(); - - const auto *enumWrapper = QJSValuePrivate::takeManagedValue(&enumType)->as<QQmlEnumWrapper>(); - if (!enumWrapper) - return QVariant(); - - bool ok = false; - QQmlType type = enumWrapper->d()->type(); - int enumIndex = enumWrapper->d()->enumIndex; - int keyValue = value.toInt(); - auto *typeLoader = m_engine->typeLoader(); - Scope scope(m_engine); - QStringList keys = enumWrapper->d()->scoped - ? type.scopedEnumKeys(typeLoader, enumIndex, keyValue, &ok) - : type.unscopedEnumKeys(typeLoader, enumIndex, keyValue, &ok); - - if (ok) - return keys; + // Undefined -> double = NaN + if (std::isnan(value)) { + m_engine->throwReferenceError("Invalid second argument, entry"_L1); + return {}; + } - return QVariant(); + return retrieveFromEnum<QStringList>( + enumType, + [&](const QQmlType &type, QQmlTypeLoader *typeLoader, int enumIndex, bool *ok) { + return type.scopedEnumKeys(typeLoader, enumIndex, QtPrivate::qSaturateRound(value), ok); + }, [&](const QQmlType &type, QQmlTypeLoader *typeLoader, int enumIndex, bool *ok) { + return type.unscopedEnumKeys(typeLoader, enumIndex, QtPrivate::qSaturateRound(value), ok); + }, m_engine); } QQmlPlatform *QtObject::platform() diff --git a/src/qml/qml/qqmlbuiltinfunctions_p.h b/src/qml/qml/qqmlbuiltinfunctions_p.h index e50d99f86a..364f910494 100644 --- a/src/qml/qml/qqmlbuiltinfunctions_p.h +++ b/src/qml/qml/qqmlbuiltinfunctions_p.h @@ -16,8 +16,12 @@ // #include <private/qjsengine_p.h> +#include <private/qjsvalue_p.h> +#include <private/qjsmanagedvalue_p.h> +#include <private/qqmlengine_p.h> #include <private/qqmlglobal_p.h> #include <private/qqmlplatform_p.h> +#include <private/qqmltypewrapper_p.h> #include <private/qv4functionobject_p.h> #include <QtCore/qnamespace.h> @@ -31,6 +35,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_DECLARE_LOGGING_CATEGORY(lcQml); Q_DECLARE_LOGGING_CATEGORY(lcJs); @@ -164,9 +170,9 @@ public: Q_INVOKABLE QJSValue binding(const QJSValue &function) const; Q_INVOKABLE void callLater(QQmlV4FunctionPtr args); - Q_INVOKABLE QVariant enumStringToValue(QJSValue enumType, QJSValue value); - Q_INVOKABLE QVariant enumValueToString(QJSValue enumType, QJSValue value); - Q_INVOKABLE QVariant enumValueToStrings(QJSValue enumType, QJSValue value); + Q_INVOKABLE double enumStringToValue(const QJSManagedValue &enumType, const QString &string); + Q_INVOKABLE QString enumValueToString(const QJSManagedValue &enumType, double value); + Q_INVOKABLE QStringList enumValueToStrings(const QJSManagedValue &enumType, double value); #if QT_CONFIG(translation) QString uiLanguage() const; @@ -197,6 +203,39 @@ private: }; Contexts getContexts() const; + template<typename Ret, typename HandleScoped, typename HandleUnscoped> + Ret retrieveFromEnum(const QJSManagedValue &enumType, HandleScoped &&handleScoped, + HandleUnscoped &&handleUnscoped, QV4::ExecutionEngine *engine) + { + Q_ASSERT(engine); + + // It's fine to hold a bare pointer to the internals of a QJSManagedValue + // The managed value keeps a QV4::PersistentValue after all. + QV4::Value *internal = QJSManagedValuePrivate::member(&enumType); + Q_ASSERT(internal); + + QV4::Heap::QQmlEnumWrapper *enumWrapper = nullptr; + if (QV4::QQmlEnumWrapper *wrapper = internal->as<QV4::QQmlEnumWrapper>()) { + enumWrapper = wrapper->d(); + } else { + engine->throwTypeError("Invalid first argument, expected enum"_L1); + return Ret(); + } + + bool ok; + const QQmlType type = enumWrapper->type(); + const int enumIndex = enumWrapper->enumIndex; + auto *typeLoader = m_engine->typeLoader(); + const auto value = enumWrapper->scoped + ? handleScoped(type, typeLoader, enumIndex, &ok) + : handleUnscoped(type, typeLoader, enumIndex, &ok); + + if (!ok) + engine->throwReferenceError("Invalid second argument, entry"_L1); + + return value; + } + QQmlPlatform *m_platform = nullptr; QQmlApplication *m_application = nullptr; diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 6ba59fad9e..80ac9c6afe 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -78,8 +78,17 @@ V4_DEFINE_EXTENSION(QQmlComponentExtension, componentExtension); \code QQmlEngine *engine = new QQmlEngine; QQmlComponent component(engine, QUrl::fromLocalFile("main.qml")); + if (component.isError()) { + qWarning() << "Failed to load main.qml:" << component.errors(); + return 1; + } QObject *myObject = component.create(); + if (component.isError()) { + qWarning() << "Failed to create instance of main.qml:" << component.errors(); + return 1; + } + QQuickItem *item = qobject_cast<QQuickItem*>(myObject); int width = item->width(); // width = 200 \endcode diff --git a/src/qmlcompiler/qqmljstyperesolver.cpp b/src/qmlcompiler/qqmljstyperesolver.cpp index 41ededaa91..2fcf7884a5 100644 --- a/src/qmlcompiler/qqmljstyperesolver.cpp +++ b/src/qmlcompiler/qqmljstyperesolver.cpp @@ -1521,6 +1521,12 @@ bool QQmlJSTypeResolver::canPrimitivelyConvertFromTo( return true; } + // it is possible to assing a singlar object to a list property if it could be stored in the list + if (to->accessSemantics() == QQmlJSScope::AccessSemantics::Sequence + && from->accessSemantics() == QQmlJSScope::AccessSemantics::Reference + && from->inherits(to->valueType())) + return true; + if (to == m_stringType && from->accessSemantics() == QQmlJSScope::AccessSemantics::Sequence) return canConvertFromTo(from->valueType(), m_stringType); diff --git a/src/quick/platform/android/jar/src/org/qtproject/qt/android/QtQuickView.java b/src/quick/platform/android/jar/src/org/qtproject/qt/android/QtQuickView.java index 32eae95913..78cd7beea8 100644 --- a/src/quick/platform/android/jar/src/org/qtproject/qt/android/QtQuickView.java +++ b/src/quick/platform/android/jar/src/org/qtproject/qt/android/QtQuickView.java @@ -330,9 +330,10 @@ public class QtQuickView extends QtView { { m_statusChangeListener = listener; - if (m_hasQueuedStatus) + if (m_hasQueuedStatus) { sendStatusChanged(m_lastStatus); m_hasQueuedStatus = false; + } } private void handleStatusChange(int status) diff --git a/src/quickcontrols/fluentwinui3/SearchField.qml b/src/quickcontrols/fluentwinui3/SearchField.qml index e17264ada2..553cce3d8b 100644 --- a/src/quickcontrols/fluentwinui3/SearchField.qml +++ b/src/quickcontrols/fluentwinui3/SearchField.qml @@ -52,7 +52,7 @@ T.SearchField { palette.text: control.palette.text palette.highlightedText: control.palette.highlightedText font.weight: control.currentIndex === index ? Font.DemiBold : Font.Normal - highlighted: control.currentIndex === index + highlighted: control.highlightedIndex === index hoverEnabled: control.hoverEnabled required property var model @@ -183,7 +183,7 @@ T.SearchField { clip: true implicitHeight: contentHeight model: control.delegateModel - currentIndex: control.currentIndex + currentIndex: control.highlightedIndex highlightMoveDuration: 0 } diff --git a/src/quickcontrols/fusion/SearchField.qml b/src/quickcontrols/fusion/SearchField.qml index c09d3f0f06..c07a0129ef 100644 --- a/src/quickcontrols/fusion/SearchField.qml +++ b/src/quickcontrols/fusion/SearchField.qml @@ -30,7 +30,7 @@ T.SearchField { width: ListView.view.width text: model[control.textRole] font.weight: control.currentIndex === index ? Font.DemiBold : Font.Normal - highlighted: control.currentIndex === index + highlighted: control.highlightedIndex === index hoverEnabled: control.hoverEnabled required property var model @@ -127,7 +127,7 @@ T.SearchField { clip: true implicitHeight: contentHeight model: control.delegateModel - currentIndex: control.currentIndex + currentIndex: control.highlightedIndex highlightMoveDuration: 0 T.ScrollIndicator.vertical: ScrollIndicator { } diff --git a/src/quickcontrols/material/SearchField.qml b/src/quickcontrols/material/SearchField.qml index 40e5f307f0..3a6cbfb45f 100644 --- a/src/quickcontrols/material/SearchField.qml +++ b/src/quickcontrols/material/SearchField.qml @@ -27,7 +27,7 @@ T.SearchField { width: ListView.view.width text: model[control.textRole] font.weight: control.currentIndex === index ? Font.DemiBold : Font.Normal - highlighted: control.currentIndex === index + highlighted: control.highlightedIndex === index hoverEnabled: control.hoverEnabled Material.foreground: control.currentIndex === index ? ListView.view.contentItem.Material.accent : ListView.view.contentItem.Material.foreground @@ -106,7 +106,7 @@ T.SearchField { clip: true implicitHeight: contentHeight model: control.delegateModel - currentIndex: control.currentIndex + currentIndex: control.highlightedIndex highlightMoveDuration: 0 T.ScrollIndicator.vertical: ScrollIndicator { } diff --git a/src/quickdialogs/quickdialogsquickimpl/qml/+Fusion/FileDialog.qml b/src/quickdialogs/quickdialogsquickimpl/qml/+Fusion/FileDialog.qml index ced997c838..bee06c47ae 100644 --- a/src/quickdialogs/quickdialogsquickimpl/qml/+Fusion/FileDialog.qml +++ b/src/quickdialogs/quickdialogsquickimpl/qml/+Fusion/FileDialog.qml @@ -38,10 +38,10 @@ FileDialogImpl { dim: true modal: true title: qsTr("Overwrite file?") + width: contentItem.implicitWidth + leftPadding + rightPadding contentItem: Label { text: qsTr("“%1” already exists.\nDo you want to replace it?").arg(control.fileName) - wrapMode: Text.WordWrap } footer: DialogButtonBox { diff --git a/src/quickdialogs/quickdialogsquickimpl/qml/+Fusion/SideBar.qml b/src/quickdialogs/quickdialogsquickimpl/qml/+Fusion/SideBar.qml index 21e55fe53e..237be7847c 100644 --- a/src/quickdialogs/quickdialogsquickimpl/qml/+Fusion/SideBar.qml +++ b/src/quickdialogs/quickdialogsquickimpl/qml/+Fusion/SideBar.qml @@ -47,7 +47,6 @@ DialogsQuickImpl.SideBar { required property int index required property string folderName - required icon } separatorDelegate: Item { @@ -65,7 +64,7 @@ DialogsQuickImpl.SideBar { addFavoriteDelegate: Button { id: addFavoriteDelegateRoot - text: "Add Favorite" + text: qsTr("Add Favorite") flat: true width: control.width contentItem: IconLabel { diff --git a/src/quickdialogs/quickdialogsquickimpl/qml/+Imagine/SideBar.qml b/src/quickdialogs/quickdialogsquickimpl/qml/+Imagine/SideBar.qml index ee9ad1e256..f0fd1b5610 100644 --- a/src/quickdialogs/quickdialogsquickimpl/qml/+Imagine/SideBar.qml +++ b/src/quickdialogs/quickdialogsquickimpl/qml/+Imagine/SideBar.qml @@ -41,7 +41,6 @@ DialogsQuickImpl.SideBar { required property int index required property string folderName - required icon } separatorDelegate: Item { @@ -59,7 +58,7 @@ DialogsQuickImpl.SideBar { addFavoriteDelegate: Button { id: addFavoriteDelegateRoot - text: "Add Favorite" + text: qsTr("Add Favorite") flat: true width: control.width contentItem: IconLabel { diff --git a/src/quickdialogs/quickdialogsquickimpl/qml/+Material/FileDialog.qml b/src/quickdialogs/quickdialogsquickimpl/qml/+Material/FileDialog.qml index db3a76a91b..02ad9f03de 100644 --- a/src/quickdialogs/quickdialogsquickimpl/qml/+Material/FileDialog.qml +++ b/src/quickdialogs/quickdialogsquickimpl/qml/+Material/FileDialog.qml @@ -40,6 +40,7 @@ FileDialogImpl { modal: true title: qsTr("Overwrite file?") clip: true + width: contentItem.implicitWidth + leftPadding + rightPadding contentItem: Label { text: qsTr("“%1” already exists.\nDo you want to replace it?").arg(control.fileName) diff --git a/src/quickdialogs/quickdialogsquickimpl/qml/+Material/SideBar.qml b/src/quickdialogs/quickdialogsquickimpl/qml/+Material/SideBar.qml index 77952c8e31..8b25c975da 100644 --- a/src/quickdialogs/quickdialogsquickimpl/qml/+Material/SideBar.qml +++ b/src/quickdialogs/quickdialogsquickimpl/qml/+Material/SideBar.qml @@ -43,7 +43,6 @@ DialogsQuickImpl.SideBar { required property int index required property string folderName - required icon } separatorDelegate: Item { @@ -61,7 +60,7 @@ DialogsQuickImpl.SideBar { addFavoriteDelegate: Button { id: addFavoriteDelegateRoot - text: "Add Favorite" + text: qsTr("Add Favorite") flat: true width: control.width contentItem: IconLabel { diff --git a/src/quickdialogs/quickdialogsquickimpl/qml/+Universal/FileDialog.qml b/src/quickdialogs/quickdialogsquickimpl/qml/+Universal/FileDialog.qml index 3b644ae4fd..aedf3e1852 100644 --- a/src/quickdialogs/quickdialogsquickimpl/qml/+Universal/FileDialog.qml +++ b/src/quickdialogs/quickdialogsquickimpl/qml/+Universal/FileDialog.qml @@ -38,10 +38,10 @@ FileDialogImpl { dim: true modal: true title: qsTr("Overwrite file?") + width: contentItem.implicitWidth + leftPadding + rightPadding contentItem: Label { text: qsTr("“%1” already exists.\nDo you want to replace it?").arg(control.fileName) - wrapMode: Text.WordWrap } footer: DialogButtonBox { diff --git a/src/quickdialogs/quickdialogsquickimpl/qml/+Universal/SideBar.qml b/src/quickdialogs/quickdialogsquickimpl/qml/+Universal/SideBar.qml index 0331c103da..e620ee994b 100644 --- a/src/quickdialogs/quickdialogsquickimpl/qml/+Universal/SideBar.qml +++ b/src/quickdialogs/quickdialogsquickimpl/qml/+Universal/SideBar.qml @@ -44,7 +44,6 @@ DialogsQuickImpl.SideBar { required property int index required property string folderName - required icon } separatorDelegate: Item { @@ -62,7 +61,7 @@ DialogsQuickImpl.SideBar { addFavoriteDelegate: Button { id: addFavoriteDelegateRoot - text: "Add Favorite" + text: qsTr("Add Favorite") flat: true width: control.width contentItem: IconLabel { diff --git a/src/quickdialogs/quickdialogsquickimpl/qquicksidebar.cpp b/src/quickdialogs/quickdialogsquickimpl/qquicksidebar.cpp index 6232beba53..a6310a3a37 100644 --- a/src/quickdialogs/quickdialogsquickimpl/qquicksidebar.cpp +++ b/src/quickdialogs/quickdialogsquickimpl/qquicksidebar.cpp @@ -26,7 +26,7 @@ using namespace Qt::Literals::StringLiterals; -static QList<QStandardPaths::StandardLocation> s_defaultPaths = { +static std::initializer_list<QStandardPaths::StandardLocation> s_defaultPaths = { QStandardPaths::HomeLocation, QStandardPaths::DesktopLocation, QStandardPaths::DownloadLocation, QStandardPaths::DocumentsLocation, QStandardPaths::MusicLocation, QStandardPaths::PicturesLocation, @@ -357,28 +357,28 @@ void QQuickSideBar::componentComplete() QUrl QQuickSideBarPrivate::folderIconSource() const { - return QUrl("../images/sidebar-folder.png"_L1); + return QUrl("qrc:/qt-project.org/imports/QtQuick/Dialogs/quickimpl/images/sidebar-folder.png"_L1); } QUrl QQuickSideBarPrivate::folderIconSource(QStandardPaths::StandardLocation stdLocation) const { switch (stdLocation) { case QStandardPaths::DesktopLocation: - return QUrl("../images/sidebar-desktop.png"_L1); + return QUrl("qrc:/qt-project.org/imports/QtQuick/Dialogs/quickimpl/images/sidebar-desktop.png"_L1); case QStandardPaths::DocumentsLocation: - return QUrl("../images/sidebar-documents.png"_L1); + return QUrl("qrc:/qt-project.org/imports/QtQuick/Dialogs/quickimpl/images/sidebar-documents.png"_L1); case QStandardPaths::MusicLocation: - return QUrl("../images/sidebar-music.png"_L1); + return QUrl("qrc:/qt-project.org/imports/QtQuick/Dialogs/quickimpl/images/sidebar-music.png"_L1); case QStandardPaths::MoviesLocation: - return QUrl("../images/sidebar-video.png"_L1); + return QUrl("qrc:/qt-project.org/imports/QtQuick/Dialogs/quickimpl/images/sidebar-video.png"_L1); case QStandardPaths::PicturesLocation: - return QUrl("../images/sidebar-photo.png"_L1); + return QUrl("qrc:/qt-project.org/imports/QtQuick/Dialogs/quickimpl/images/sidebar-photo.png"_L1); case QStandardPaths::HomeLocation: - return QUrl("../images/sidebar-home.png"_L1); + return QUrl("qrc:/qt-project.org/imports/QtQuick/Dialogs/quickimpl/images/sidebar-home.png"_L1); case QStandardPaths::DownloadLocation: - return QUrl("../images/sidebar-downloads.png"_L1); + return QUrl("qrc:/qt-project.org/imports/QtQuick/Dialogs/quickimpl/images/sidebar-downloads.png"_L1); default: - return QUrl("../images/sidebar-folder.png"_L1); + return QUrl("qrc:/qt-project.org/imports/QtQuick/Dialogs/quickimpl/images/sidebar-folder.png"_L1); } } @@ -479,7 +479,7 @@ void QQuickSideBarPrivate::setAddFavoriteDelegateHovered(bool hovered) QUrl QQuickSideBarPrivate::addFavoriteIconUrl() const { - return QUrl("../images/sidebar-plus.png"_L1); + return QUrl("qrc:/qt-project.org/imports/QtQuick/Dialogs/quickimpl/images/sidebar-plus.png"_L1); } void QQuickSideBarPrivate::initContextMenu() |