From fb12660b0a097d75db2f05e2f3e7792ae84635cc Mon Sep 17 00:00:00 2001 From: Amr Essam Date: Mon, 19 Dec 2022 16:50:24 +0200 Subject: [PATCH] QmlDesigner: Enable integration of the new create effect system - Remove old New Effect item from new file dialog - Add license checker for creating effects Task-number: QDS-8675 Task-number: QDS-8676 Change-Id: I83ed2c4021c9df3896018da19fbff76be92a7431 Reviewed-by: Mahmoud Badri --- .../AssetsContextMenu.qml | 1 + .../studio_templates/files/effect/file.qep | 0 .../studio_templates/files/effect/wizard.json | 64 ------------------- .../assetslibrary/assetslibrarymodel.cpp | 9 +++ .../assetslibrary/assetslibrarymodel.h | 2 + 5 files changed, 12 insertions(+), 64 deletions(-) delete mode 100644 share/qtcreator/qmldesigner/studio_templates/files/effect/file.qep delete mode 100644 share/qtcreator/qmldesigner/studio_templates/files/effect/wizard.json diff --git a/share/qtcreator/qmldesigner/itemLibraryQmlSources/AssetsContextMenu.qml b/share/qtcreator/qmldesigner/itemLibraryQmlSources/AssetsContextMenu.qml index d3b28d77bbe..3337be90ef0 100644 --- a/share/qtcreator/qmldesigner/itemLibraryQmlSources/AssetsContextMenu.qml +++ b/share/qtcreator/qmldesigner/itemLibraryQmlSources/AssetsContextMenu.qml @@ -186,6 +186,7 @@ StudioControls.Menu { StudioControls.MenuItem { text: qsTr("New Effect") + visible: assetsModel.canCreateEffects() NewEffectDialog { id: newEffectDialog diff --git a/share/qtcreator/qmldesigner/studio_templates/files/effect/file.qep b/share/qtcreator/qmldesigner/studio_templates/files/effect/file.qep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/share/qtcreator/qmldesigner/studio_templates/files/effect/wizard.json b/share/qtcreator/qmldesigner/studio_templates/files/effect/wizard.json deleted file mode 100644 index 3dedbb5080d..00000000000 --- a/share/qtcreator/qmldesigner/studio_templates/files/effect/wizard.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "version": 1, - "supportedProjectTypes": [ ], - "id": "J.QEP", - "category": "U.QEP", - "trDescription": "Creates an Effect Maker file.", - "trDisplayName": "Effect File (Effect Maker)", - "trDisplayCategory": "Effects", - "iconText": "qep", - "platformIndependent": true, - "enabled": "%{JS: value('Features').indexOf('QmlDesigner.Wizards.Enterprise') >= 0}", - "featuresRequired": [ "QmlDesigner.Wizards.Enterprise" ], - - "options": [ - { "key": "EffectFile", "value": "%{Class}.qep" }, - { "key": "DoNotOpenFile", "value": "true" } - ], - - "pages" : - [ - { - "trDisplayName": "Define Class", - "trShortTitle": "Details", - "typeId": "Fields", - "data" : - [ - { - "name": "Class", - "trDisplayName": "Effect name:", - "mandatory": true, - "type": "LineEdit", - "data": { - "validator": "(?:[A-Z_][a-zA-Z_0-9]*|)", - "fixup": "%{JS: '%{INPUT}'.charAt(0).toUpperCase() + '%{INPUT}'.slice(1) }" - } - }, - { - "name": "TargetPath", - "type": "PathChooser", - "trDisplayName": "Path:", - "mandatory": true, - "data": - { - "kind": "existingDirectory", - "basePath": "%{InitialPath}", - "path": "%{InitialPath}" - } - } - ] - } -], - "generators" : - [ - { - "typeId": "File", - "data": - { - "source": "file.qep", - "target": "%{TargetPath}/%{EffectFile}", - "openInEditor": false - } - } - ] -} diff --git a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp index 2d51bc4734a..e52f168f73d 100644 --- a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp +++ b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp @@ -194,6 +194,15 @@ bool AssetsLibraryModel::createNewEffect(const QString &effectPath, bool openEff return created; } +bool AssetsLibraryModel::canCreateEffects() const +{ +#ifdef LICENSECHECKER + return checkLicense() == FoundLicense::enterprise; +#else + return true; +#endif +} + bool AssetsLibraryModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const { QString path = m_sourceFsModel->filePath(sourceParent); diff --git a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.h b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.h index 6567ca8338b..b6cadd4eceb 100644 --- a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.h +++ b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.h @@ -50,6 +50,8 @@ public: Q_INVOKABLE QString getUniqueEffectPath(const QString &parentFolder, const QString &effectName); Q_INVOKABLE bool createNewEffect(const QString &effectPath, bool openEffectMaker = true); + Q_INVOKABLE bool canCreateEffects() const; + int columnCount(const QModelIndex &parent = QModelIndex()) const override { int result = QSortFilterProxyModel::columnCount(parent);