forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/8.0' into 9.0
Conflicts: src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp src/plugins/qmldesigner/qmldesignerplugin.cpp Change-Id: I24216ae3f83cdde3493b4a6274e24a72f75820fc
This commit is contained in:
@@ -423,7 +423,7 @@ QString JsonWizard::evaluate(const QVariant &v) const
|
||||
void JsonWizard::openFiles(const JsonWizard::GeneratorFiles &files)
|
||||
{
|
||||
QString errorMessage;
|
||||
bool openedSomething = false;
|
||||
bool openedSomething = stringValue("DoNotOpenFile") == "true";
|
||||
for (const JsonWizard::GeneratorFile &f : files) {
|
||||
const Core::GeneratedFile &file = f.file;
|
||||
if (!file.filePath().exists()) {
|
||||
|
||||
@@ -64,6 +64,13 @@ bool AssetsLibraryModel::loadExpandedState(const QString &assetPath)
|
||||
return m_expandedStateHash.value(assetPath, true);
|
||||
}
|
||||
|
||||
bool AssetsLibraryModel::isEffectQmlExist(const QString &effectName)
|
||||
{
|
||||
Utils::FilePath effectsResDir = ModelNodeOperations::getEffectsDirectory();
|
||||
Utils::FilePath qmlPath = effectsResDir.resolvePath(effectName + "/" + effectName + ".qml");
|
||||
return qmlPath.exists();
|
||||
}
|
||||
|
||||
AssetsLibraryModel::DirExpandState AssetsLibraryModel::getAllExpandedState() const
|
||||
{
|
||||
const auto keys = m_expandedStateHash.keys();
|
||||
|
||||
@@ -52,6 +52,8 @@ public:
|
||||
static void saveExpandedState(bool expanded, const QString &assetPath);
|
||||
static bool loadExpandedState(const QString &assetPath);
|
||||
|
||||
static bool isEffectQmlExist(const QString &effectName);
|
||||
|
||||
enum class DirExpandState {
|
||||
SomeExpanded,
|
||||
AllExpanded,
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <utils/utilsicons.h>
|
||||
#include "utils/environment.h"
|
||||
#include "utils/filepath.h"
|
||||
#include "utils/qtcprocess.h"
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/icore.h>
|
||||
@@ -50,9 +49,6 @@
|
||||
#include <QQmlContext>
|
||||
#include <QQuickItem>
|
||||
|
||||
#include <qtsupport/baseqtversion.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
static QString propertyEditorResourcesPath()
|
||||
@@ -242,44 +238,7 @@ QSet<QString> AssetsLibraryWidget::supportedAssetSuffixes(bool complex)
|
||||
|
||||
void AssetsLibraryWidget::openEffectMaker(const QString &filePath)
|
||||
{
|
||||
const ProjectExplorer::Target *target = ProjectExplorer::ProjectTree::currentTarget();
|
||||
if (!target) {
|
||||
qWarning() << __FUNCTION__ << "No project open";
|
||||
return;
|
||||
}
|
||||
|
||||
Utils::FilePath projectPath = target->project()->projectDirectory();
|
||||
QString effectName = QFileInfo(filePath).baseName();
|
||||
QString effectResDir = "asset_imports/Effects/" + effectName;
|
||||
Utils::FilePath effectResPath = projectPath.resolvePath(effectResDir);
|
||||
if (!effectResPath.exists())
|
||||
QDir(projectPath.toString()).mkpath(effectResDir);
|
||||
|
||||
const QtSupport::QtVersion *baseQtVersion = QtSupport::QtKitAspect::qtVersion(target->kit());
|
||||
if (baseQtVersion) {
|
||||
auto effectMakerPath = baseQtVersion->binPath().pathAppended("QQEffectMaker").withExecutableSuffix();
|
||||
if (!effectMakerPath.exists()) {
|
||||
qWarning() << __FUNCTION__ << "Cannot find EffectMaker app";
|
||||
return;
|
||||
}
|
||||
|
||||
Utils::FilePath effectPath = Utils::FilePath::fromString(filePath);
|
||||
QString effectContents = QString::fromUtf8(effectPath.fileContents().value_or(QByteArray()));
|
||||
QStringList arguments;
|
||||
arguments << filePath;
|
||||
if (effectContents.isEmpty())
|
||||
arguments << "--create";
|
||||
arguments << "--exportpath" << effectResPath.toString();
|
||||
|
||||
Utils::Environment env = Utils::Environment::systemEnvironment();
|
||||
if (env.osType() == Utils::OsTypeMac)
|
||||
env.appendOrSet("QSG_RHI_BACKEND", "metal");
|
||||
|
||||
m_qqemProcess.reset(new Utils::QtcProcess);
|
||||
m_qqemProcess->setEnvironment(env);
|
||||
m_qqemProcess->setCommand({ effectMakerPath, arguments });
|
||||
m_qqemProcess->start();
|
||||
}
|
||||
ModelNodeOperations::openEffectMaker(filePath);
|
||||
}
|
||||
|
||||
void AssetsLibraryWidget::setModel(Model *model)
|
||||
|
||||
@@ -22,7 +22,6 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace Utils {
|
||||
class FileSystemWatcher;
|
||||
class QtcProcess;
|
||||
}
|
||||
|
||||
namespace QmlDesigner {
|
||||
@@ -96,8 +95,6 @@ private:
|
||||
bool m_updateRetry = false;
|
||||
QString m_filterText;
|
||||
QPoint m_dragStartPoint;
|
||||
|
||||
std::unique_ptr<Utils::QtcProcess> m_qqemProcess;
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
@@ -47,11 +47,15 @@
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
#include <projectexplorer/projecttree.h>
|
||||
#include "projectexplorer/session.h"
|
||||
#include "projectexplorer/target.h"
|
||||
|
||||
#include <qtsupport/baseqtversion.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include "utils/qtcprocess.h"
|
||||
#include <utils/smallstring.h>
|
||||
|
||||
#include <QComboBox>
|
||||
@@ -1610,6 +1614,51 @@ void updateImported3DAsset(const SelectionContext &selectionContext)
|
||||
}
|
||||
}
|
||||
|
||||
void openEffectMaker(const QString &filePath)
|
||||
{
|
||||
const ProjectExplorer::Target *target = ProjectExplorer::ProjectTree::currentTarget();
|
||||
if (!target) {
|
||||
qWarning() << __FUNCTION__ << "No project open";
|
||||
return;
|
||||
}
|
||||
|
||||
Utils::FilePath projectPath = target->project()->projectDirectory();
|
||||
QString effectName = QFileInfo(filePath).baseName();
|
||||
QString effectResDir = "asset_imports/Effects/" + effectName;
|
||||
Utils::FilePath effectResPath = projectPath.resolvePath(effectResDir);
|
||||
if (!effectResPath.exists())
|
||||
QDir(projectPath.toString()).mkpath(effectResDir);
|
||||
|
||||
const QtSupport::QtVersion *baseQtVersion = QtSupport::QtKitAspect::qtVersion(target->kit());
|
||||
if (baseQtVersion) {
|
||||
auto effectMakerPath = baseQtVersion->binPath().pathAppended("QQEffectMaker").withExecutableSuffix();
|
||||
if (!effectMakerPath.exists()) {
|
||||
qWarning() << __FUNCTION__ << "Cannot find EffectMaker app";
|
||||
return;
|
||||
}
|
||||
|
||||
Utils::FilePath effectPath = Utils::FilePath::fromString(filePath);
|
||||
QStringList arguments;
|
||||
arguments << filePath;
|
||||
if (effectPath.fileContents())
|
||||
arguments << "--create";
|
||||
arguments << "--exportpath" << effectResPath.toString();
|
||||
|
||||
Utils::Environment env = Utils::Environment::systemEnvironment();
|
||||
if (env.osType() == Utils::OsTypeMac)
|
||||
env.appendOrSet("QSG_RHI_BACKEND", "metal");
|
||||
|
||||
Utils::QtcProcess *qqemProcess = new Utils::QtcProcess();
|
||||
qqemProcess->setEnvironment(env);
|
||||
qqemProcess->setCommand({ effectMakerPath, arguments });
|
||||
qqemProcess->start();
|
||||
|
||||
QObject::connect(qqemProcess, &Utils::QtcProcess::done, [qqemProcess]() {
|
||||
qqemProcess->deleteLater();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Utils::FilePath getEffectsDirectory()
|
||||
{
|
||||
QString defaultDir = "asset_imports/Effects";
|
||||
|
||||
@@ -79,6 +79,7 @@ void openSignalDialog(const SelectionContext &selectionContext);
|
||||
void updateImported3DAsset(const SelectionContext &selectionContext);
|
||||
|
||||
QMLDESIGNERCORE_EXPORT Utils::FilePath getEffectsDirectory();
|
||||
void openEffectMaker(const QString &filePath);
|
||||
|
||||
// ModelNodePreviewImageOperations
|
||||
QVariant previewImageDataForGenericNode(const ModelNode &modelNode);
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
#include "formeditorscene.h"
|
||||
#include "formeditorview.h"
|
||||
#include "assetslibrarywidget.h"
|
||||
#include "assetslibrarymodel.h"
|
||||
#include <metainfo.h>
|
||||
#include <modelnodeoperations.h>
|
||||
#include <nodehints.h>
|
||||
#include <rewritingexception.h>
|
||||
#include "qmldesignerconstants.h"
|
||||
@@ -19,6 +21,7 @@
|
||||
#include <QMimeData>
|
||||
#include <QTimer>
|
||||
#include <QWidget>
|
||||
#include <QMessageBox>
|
||||
|
||||
static Q_LOGGING_CATEGORY(dragToolInfo, "qtc.qmldesigner.formeditor", QtWarningMsg);
|
||||
|
||||
@@ -242,9 +245,31 @@ void DragTool::dropEvent(const QList<QGraphicsItem *> &itemList, QGraphicsSceneD
|
||||
if (targetContainerFormEditorItem) {
|
||||
QmlItemNode parentQmlItemNode = targetContainerFormEditorItem->qmlItemNode();
|
||||
QString effectName = QFileInfo(effectPath).baseName();
|
||||
QmlItemNode effectNode = QmlItemNode::createQmlItemNodeForEffect(view(), parentQmlItemNode, effectName);
|
||||
|
||||
view()->setSelectedModelNodes({effectNode});
|
||||
if (!AssetsLibraryModel::isEffectQmlExist(effectName)) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("Effect " + effectName + " is empty");
|
||||
msgBox.setInformativeText("Do you want to edit " + effectName + "?");
|
||||
msgBox.setStandardButtons(QMessageBox::No |QMessageBox::Yes);
|
||||
msgBox.setDefaultButton(QMessageBox::Yes);
|
||||
msgBox.setIcon(QMessageBox::Question);
|
||||
int ret = msgBox.exec();
|
||||
switch (ret) {
|
||||
case QMessageBox::Yes:
|
||||
ModelNodeOperations::openEffectMaker(effectPath);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
QmlItemNode effectNode = QmlItemNode::
|
||||
createQmlItemNodeForEffect(view(), parentQmlItemNode, effectName);
|
||||
|
||||
view()->setSelectedModelNodes({parentQmlItemNode});
|
||||
view()->resetPuppet();
|
||||
|
||||
commitTransaction();
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#include "modelmerger.h"
|
||||
#include "rewritingexception.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <QUrl>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QFileInfo>
|
||||
@@ -159,12 +161,22 @@ QmlItemNode QmlItemNode::createQmlItemNodeFromFont(AbstractView *view,
|
||||
return newQmlItemNode;
|
||||
}
|
||||
|
||||
static bool useLayerEffect()
|
||||
{
|
||||
QSettings *settings = Core::ICore::settings();
|
||||
const QString layerEffectEntry = "QML/Designer/UseLayerEffect";
|
||||
|
||||
return settings->value(layerEffectEntry, true).toBool();
|
||||
}
|
||||
|
||||
QmlItemNode QmlItemNode::createQmlItemNodeForEffect(AbstractView *view,
|
||||
const QmlItemNode &parentNode,
|
||||
const QString &effectName)
|
||||
{
|
||||
QmlItemNode newQmlItemNode;
|
||||
|
||||
const bool layerEffect = useLayerEffect();
|
||||
|
||||
QmlDesigner::Import import = Import::createLibraryImport("Effects." + effectName, "1.0");
|
||||
try {
|
||||
if (!view->model()->hasImport(import, true, true))
|
||||
@@ -175,11 +187,17 @@ QmlItemNode QmlItemNode::createQmlItemNodeForEffect(AbstractView *view,
|
||||
|
||||
TypeName type(effectName.toUtf8());
|
||||
newQmlItemNode = QmlItemNode(view->createModelNode(type, 1, 0));
|
||||
NodeAbstractProperty parentProperty = parentNode.defaultNodeAbstractProperty();
|
||||
NodeAbstractProperty parentProperty = layerEffect
|
||||
? parentNode.nodeAbstractProperty("layer.effect")
|
||||
: parentNode.defaultNodeAbstractProperty();
|
||||
parentProperty.reparentHere(newQmlItemNode);
|
||||
|
||||
newQmlItemNode.modelNode().bindingProperty("source").setExpression("parent");
|
||||
newQmlItemNode.modelNode().bindingProperty("anchors.fill").setExpression("parent");
|
||||
if (!layerEffect) {
|
||||
newQmlItemNode.modelNode().bindingProperty("source").setExpression("parent");
|
||||
newQmlItemNode.modelNode().bindingProperty("anchors.fill").setExpression("parent");
|
||||
} else {
|
||||
parentNode.modelNode().variantProperty("layer.enabled").setValue(true);
|
||||
}
|
||||
|
||||
QTC_ASSERT(newQmlItemNode.isValid(), return QmlItemNode());
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "qmldesignerplugin.h"
|
||||
#include "coreplugin/iwizardfactory.h"
|
||||
#include "designmodecontext.h"
|
||||
#include "designmodewidget.h"
|
||||
#include "dynamiclicensecheck.h"
|
||||
@@ -39,8 +40,10 @@
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/designmode.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/featureprovider.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/iwizardfactory.h>
|
||||
#include <coreplugin/messagebox.h>
|
||||
#include <coreplugin/modemanager.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
@@ -52,19 +55,19 @@
|
||||
#include <sqlitelibraryinitializer.h>
|
||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QTimer>
|
||||
#include <QApplication>
|
||||
#include <QCoreApplication>
|
||||
#include <qplugin.h>
|
||||
#include <QDebug>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QScreen>
|
||||
#include <QTimer>
|
||||
#include <QWindow>
|
||||
#include <QApplication>
|
||||
#include <qplugin.h>
|
||||
|
||||
#include "nanotrace/nanotrace.h"
|
||||
#include <modelnodecontextmenu_helper.h>
|
||||
@@ -77,6 +80,17 @@ namespace QmlDesigner {
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class EnterpriseFeatureProvider : public Core::IFeatureProvider
|
||||
{
|
||||
public:
|
||||
QSet<Utils::Id> availableFeatures(Utils::Id id) const override
|
||||
{
|
||||
return {"QmlDesigner.Wizards.Enterprise"};
|
||||
}
|
||||
QSet<Utils::Id> availablePlatforms() const override { return {}; }
|
||||
QString displayNameForPlatform(Utils::Id id) const override { return {}; }
|
||||
};
|
||||
|
||||
QString normalizeIdentifier(const QString &string)
|
||||
{
|
||||
if (string.isEmpty())
|
||||
@@ -262,6 +276,8 @@ bool QmlDesignerPlugin::initialize(const QStringList & /*arguments*/, QString *e
|
||||
//TODO Move registering those types out of the property editor, since they are used also in the states editor
|
||||
Quick2PropertyEditorView::registerQmlTypes();
|
||||
|
||||
if (QmlDesigner::checkLicense() == QmlDesigner::FoundLicense::enterprise)
|
||||
Core::IWizardFactory::registerFeatureProvider(new EnterpriseFeatureProvider);
|
||||
Exception::setWarnAboutException(!QmlDesignerPlugin::instance()
|
||||
->settings()
|
||||
.value(DesignerSettingsKey::ENABLE_MODEL_EXCEPTION_OUTPUT)
|
||||
|
||||
Reference in New Issue
Block a user