DesignSystem: Generate unique collection name on creating new collection

Task-number: QDS-14670
Change-Id: I7f3609535a2d7d3005d3146bc33c118cce9163d7
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Henning Gründl <henning.gruendl@qt.io>
This commit is contained in:
Vikas Pachdha
2025-03-25 14:29:27 +01:00
committed by Thomas Hartmann
parent 097ff50d57
commit 0c6f18ac2a
4 changed files with 13 additions and 4 deletions

View File

@@ -154,6 +154,7 @@ Rectangle {
StudioControls.Dialog {
id: createCollectionDialog
property alias newCollectionName: createCollectionTextField.text;
title: qsTr("Create collection")
width: Math.min(300, root.width)
closePolicy: Popup.CloseOnEscape
@@ -172,8 +173,6 @@ Rectangle {
translationIndicatorVisible: false
width: parent.width
text: qsTr("NewCollection")
onAccepted: createCollectionDialog.accept()
onRejected: createCollectionDialog.reject()
}
@@ -318,7 +317,10 @@ Rectangle {
StudioControls.MenuItem {
text: qsTr("Create collection")
onTriggered: createCollectionDialog.open()
onTriggered: {
createCollectionDialog.newCollectionName = DesignSystemBackend.dsInterface.generateCollectionName(qsTr("NewCollection"));
createCollectionDialog.open()
}
}
}
}

View File

@@ -42,6 +42,11 @@ CollectionModel *DesignSystemInterface::model(const QString &typeName)
return nullptr;
}
QString DesignSystemInterface::generateCollectionName(const QString &hint) const
{
return m_store->uniqueCollectionName(hint);
}
void DesignSystemInterface::addCollection(const QString &name)
{
if (m_store->addCollection(name))

View File

@@ -24,6 +24,7 @@ public:
Q_INVOKABLE void loadDesignSystem();
Q_INVOKABLE CollectionModel *model(const QString &typeName);
Q_INVOKABLE QString generateCollectionName(const QString &hint) const;
Q_INVOKABLE void addCollection(const QString &name);
Q_INVOKABLE void removeCollection(const QString &name);
Q_INVOKABLE void renameCollection(const QString &oldName, const QString &newName);

View File

@@ -40,8 +40,9 @@ public:
ThemeProperty resolvedDSBinding(QStringView binding) const;
private:
QString uniqueCollectionName(const QString &hint) const;
private:
std::optional<QString> loadCollection(const QString &typeName, const Utils::FilePath &qmlFilePath);
std::optional<QString> writeQml(const DSThemeManager &mgr,
const QString &typeName,