forked from qt-creator/qt-creator
QmlDesigner: Show proper warning if .qep file has no component
When dragging an empty effect, a messagebox shows with an option to open QQEM
(cherry picked from commit f4723ae885
)
Task-number: QDS-8155
Change-Id: I2afbf7ffb9cb58243f3635fe3a7aee999ab68713
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -86,6 +86,13 @@ bool AssetsLibraryModel::loadExpandedState(const QString &assetPath)
|
|||||||
return m_expandedStateHash.value(assetPath, true);
|
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
|
AssetsLibraryModel::DirExpandState AssetsLibraryModel::getAllExpandedState() const
|
||||||
{
|
{
|
||||||
const auto keys = m_expandedStateHash.keys();
|
const auto keys = m_expandedStateHash.keys();
|
||||||
|
@@ -74,6 +74,8 @@ public:
|
|||||||
static void saveExpandedState(bool expanded, const QString &assetPath);
|
static void saveExpandedState(bool expanded, const QString &assetPath);
|
||||||
static bool loadExpandedState(const QString &assetPath);
|
static bool loadExpandedState(const QString &assetPath);
|
||||||
|
|
||||||
|
static bool isEffectQmlExist(const QString &effectName);
|
||||||
|
|
||||||
enum class DirExpandState {
|
enum class DirExpandState {
|
||||||
SomeExpanded,
|
SomeExpanded,
|
||||||
AllExpanded,
|
AllExpanded,
|
||||||
|
@@ -45,7 +45,6 @@
|
|||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
#include "utils/environment.h"
|
#include "utils/environment.h"
|
||||||
#include "utils/filepath.h"
|
#include "utils/filepath.h"
|
||||||
#include "utils/qtcprocess.h"
|
|
||||||
|
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
@@ -71,9 +70,6 @@
|
|||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
|
|
||||||
#include <qtsupport/baseqtversion.h>
|
|
||||||
#include <qtsupport/qtkitinformation.h>
|
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
|
|
||||||
static QString propertyEditorResourcesPath()
|
static QString propertyEditorResourcesPath()
|
||||||
@@ -263,44 +259,7 @@ QSet<QString> AssetsLibraryWidget::supportedAssetSuffixes(bool complex)
|
|||||||
|
|
||||||
void AssetsLibraryWidget::openEffectMaker(const QString &filePath)
|
void AssetsLibraryWidget::openEffectMaker(const QString &filePath)
|
||||||
{
|
{
|
||||||
const ProjectExplorer::Target *target = ProjectExplorer::ProjectTree::currentTarget();
|
ModelNodeOperations::openEffectMaker(filePath);
|
||||||
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());
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetsLibraryWidget::setModel(Model *model)
|
void AssetsLibraryWidget::setModel(Model *model)
|
||||||
|
@@ -44,7 +44,6 @@ QT_END_NAMESPACE
|
|||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
class FileSystemWatcher;
|
class FileSystemWatcher;
|
||||||
class QtcProcess;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace QmlDesigner {
|
namespace QmlDesigner {
|
||||||
@@ -118,8 +117,6 @@ private:
|
|||||||
bool m_updateRetry = false;
|
bool m_updateRetry = false;
|
||||||
QString m_filterText;
|
QString m_filterText;
|
||||||
QPoint m_dragStartPoint;
|
QPoint m_dragStartPoint;
|
||||||
|
|
||||||
std::unique_ptr<Utils::QtcProcess> m_qqemProcess;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmlDesigner
|
} // namespace QmlDesigner
|
||||||
|
@@ -69,11 +69,15 @@
|
|||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/projectnodes.h>
|
#include <projectexplorer/projectnodes.h>
|
||||||
#include <projectexplorer/projecttree.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/algorithm.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include "utils/qtcprocess.h"
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
@@ -1617,6 +1621,52 @@ 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);
|
||||||
|
QString effectContents = QString::fromUtf8(effectPath.fileContents());
|
||||||
|
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");
|
||||||
|
|
||||||
|
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()
|
Utils::FilePath getEffectsDirectory()
|
||||||
{
|
{
|
||||||
QString defaultDir = "asset_imports/Effects";
|
QString defaultDir = "asset_imports/Effects";
|
||||||
|
@@ -101,6 +101,7 @@ void openSignalDialog(const SelectionContext &selectionContext);
|
|||||||
void updateImported3DAsset(const SelectionContext &selectionContext);
|
void updateImported3DAsset(const SelectionContext &selectionContext);
|
||||||
|
|
||||||
QMLDESIGNERCORE_EXPORT Utils::FilePath getEffectsDirectory();
|
QMLDESIGNERCORE_EXPORT Utils::FilePath getEffectsDirectory();
|
||||||
|
void openEffectMaker(const QString &filePath);
|
||||||
|
|
||||||
// ModelNodePreviewImageOperations
|
// ModelNodePreviewImageOperations
|
||||||
QVariant previewImageDataForGenericNode(const ModelNode &modelNode);
|
QVariant previewImageDataForGenericNode(const ModelNode &modelNode);
|
||||||
|
@@ -28,7 +28,9 @@
|
|||||||
#include "formeditorscene.h"
|
#include "formeditorscene.h"
|
||||||
#include "formeditorview.h"
|
#include "formeditorview.h"
|
||||||
#include "assetslibrarywidget.h"
|
#include "assetslibrarywidget.h"
|
||||||
|
#include "assetslibrarymodel.h"
|
||||||
#include <metainfo.h>
|
#include <metainfo.h>
|
||||||
|
#include <modelnodeoperations.h>
|
||||||
#include <nodehints.h>
|
#include <nodehints.h>
|
||||||
#include <rewritingexception.h>
|
#include <rewritingexception.h>
|
||||||
#include "qmldesignerconstants.h"
|
#include "qmldesignerconstants.h"
|
||||||
@@ -41,6 +43,7 @@
|
|||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
static Q_LOGGING_CATEGORY(dragToolInfo, "qtc.qmldesigner.formeditor", QtWarningMsg);
|
static Q_LOGGING_CATEGORY(dragToolInfo, "qtc.qmldesigner.formeditor", QtWarningMsg);
|
||||||
|
|
||||||
@@ -264,9 +267,31 @@ void DragTool::dropEvent(const QList<QGraphicsItem *> &itemList, QGraphicsSceneD
|
|||||||
if (targetContainerFormEditorItem) {
|
if (targetContainerFormEditorItem) {
|
||||||
QmlItemNode parentQmlItemNode = targetContainerFormEditorItem->qmlItemNode();
|
QmlItemNode parentQmlItemNode = targetContainerFormEditorItem->qmlItemNode();
|
||||||
QString effectName = QFileInfo(effectPath).baseName();
|
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();
|
view()->resetPuppet();
|
||||||
|
|
||||||
commitTransaction();
|
commitTransaction();
|
||||||
|
Reference in New Issue
Block a user