2023-06-29 15:06:11 +03:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
|
|
|
|
|
|
|
|
#include "effectmakerwidget.h"
|
|
|
|
|
|
|
|
|
|
#include "effectmakermodel.h"
|
2023-08-11 12:53:28 +03:00
|
|
|
#include "effectmakernodesmodel.h"
|
2023-06-29 15:06:11 +03:00
|
|
|
#include "effectmakerview.h"
|
|
|
|
|
#include "qmldesignerconstants.h"
|
|
|
|
|
#include "qmldesignerplugin.h"
|
|
|
|
|
#include "theme.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
|
|
|
|
|
#include <studioquickwidget.h>
|
|
|
|
|
|
|
|
|
|
#include <utils/algorithm.h>
|
|
|
|
|
#include <utils/environment.h>
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
#include <QQmlEngine>
|
|
|
|
|
|
|
|
|
|
namespace QmlDesigner {
|
|
|
|
|
|
|
|
|
|
static QString propertyEditorResourcesPath()
|
|
|
|
|
{
|
|
|
|
|
#ifdef SHARE_QML_PATH
|
|
|
|
|
if (Utils::qtcEnvironmentVariableIsSet("LOAD_QML_FROM_SOURCE"))
|
|
|
|
|
return QLatin1String(SHARE_QML_PATH) + "/propertyEditorQmlSources";
|
|
|
|
|
#endif
|
|
|
|
|
return Core::ICore::resourcePath("qmldesigner/propertyEditorQmlSources").toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EffectMakerWidget::EffectMakerWidget(EffectMakerView *view)
|
|
|
|
|
: m_effectMakerModel{new EffectMakerModel(this)}
|
2023-08-11 12:53:28 +03:00
|
|
|
, m_effectMakerNodesModel{new EffectMakerNodesModel(this)}
|
2023-06-29 15:06:11 +03:00
|
|
|
, m_effectMakerView(view)
|
2023-08-09 18:15:56 +03:00
|
|
|
, m_quickWidget{new StudioQuickWidget(this)}
|
2023-06-29 15:06:11 +03:00
|
|
|
{
|
|
|
|
|
setWindowTitle(tr("Effect Maker", "Title of effect maker widget"));
|
|
|
|
|
setMinimumWidth(250);
|
|
|
|
|
|
2023-08-09 18:15:56 +03:00
|
|
|
m_quickWidget->quickWidget()->installEventFilter(this);
|
2023-06-29 15:06:11 +03:00
|
|
|
|
|
|
|
|
// create the inner widget
|
2023-08-09 18:15:56 +03:00
|
|
|
m_quickWidget->quickWidget()->setObjectName(Constants::OBJECT_NAME_EFFECT_MAKER);
|
|
|
|
|
m_quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
|
|
|
|
Theme::setupTheme(m_quickWidget->engine());
|
|
|
|
|
m_quickWidget->engine()->addImportPath(propertyEditorResourcesPath() + "/imports");
|
|
|
|
|
m_quickWidget->setClearColor(Theme::getColor(Theme::Color::QmlDesigner_BackgroundColorDarkAlternate));
|
2023-06-29 15:06:11 +03:00
|
|
|
|
|
|
|
|
auto layout = new QHBoxLayout(this);
|
|
|
|
|
layout->setContentsMargins({});
|
|
|
|
|
layout->setSpacing(0);
|
2023-08-09 18:15:56 +03:00
|
|
|
layout->addWidget(m_quickWidget.data());
|
2023-06-29 15:06:11 +03:00
|
|
|
|
|
|
|
|
setStyleSheet(Theme::replaceCssColors(
|
|
|
|
|
QString::fromUtf8(Utils::FileReader::fetchQrc(":/qmldesigner/stylesheet.css"))));
|
|
|
|
|
|
|
|
|
|
QmlDesignerPlugin::trackWidgetFocusTime(this, Constants::EVENT_EFFECTMAKER_TIME);
|
|
|
|
|
|
2023-08-09 18:15:56 +03:00
|
|
|
auto map = m_quickWidget->registerPropertyMap("EffectMakerBackend");
|
2023-08-11 12:53:28 +03:00
|
|
|
map->setProperties({{"effectMakerNodesModel", QVariant::fromValue(m_effectMakerNodesModel.data())},
|
|
|
|
|
{"effectMakerModel", QVariant::fromValue(m_effectMakerModel.data())},
|
2023-06-29 15:06:11 +03:00
|
|
|
{"rootView", QVariant::fromValue(this)}});
|
|
|
|
|
|
|
|
|
|
// init the first load of the QML UI elements
|
|
|
|
|
reloadQmlSource();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool EffectMakerWidget::eventFilter(QObject *obj, QEvent *event)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(obj)
|
|
|
|
|
Q_UNUSED(event)
|
|
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EffectMakerWidget::contextHelp(const Core::IContext::HelpCallback &callback) const
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(callback)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StudioQuickWidget *EffectMakerWidget::quickWidget() const
|
|
|
|
|
{
|
2023-08-09 18:15:56 +03:00
|
|
|
return m_quickWidget.data();
|
2023-06-29 15:06:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QPointer<EffectMakerModel> EffectMakerWidget::effectMakerModel() const
|
|
|
|
|
{
|
|
|
|
|
return m_effectMakerModel;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 12:53:28 +03:00
|
|
|
QPointer<EffectMakerNodesModel> EffectMakerWidget::effectMakerNodesModel() const
|
|
|
|
|
{
|
|
|
|
|
return m_effectMakerNodesModel;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-29 15:06:11 +03:00
|
|
|
void EffectMakerWidget::focusSection(int section)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(section)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString EffectMakerWidget::qmlSourcesPath()
|
|
|
|
|
{
|
|
|
|
|
#ifdef SHARE_QML_PATH
|
|
|
|
|
if (Utils::qtcEnvironmentVariableIsSet("LOAD_QML_FROM_SOURCE"))
|
|
|
|
|
return QLatin1String(SHARE_QML_PATH) + "/effectMakerQmlSources";
|
|
|
|
|
#endif
|
|
|
|
|
return Core::ICore::resourcePath("qmldesigner/effectMakerQmlSources").toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EffectMakerWidget::reloadQmlSource()
|
|
|
|
|
{
|
|
|
|
|
const QString effectMakerQmlPath = qmlSourcesPath() + "/EffectMaker.qml";
|
|
|
|
|
QTC_ASSERT(QFileInfo::exists(effectMakerQmlPath), return);
|
2023-08-09 18:15:56 +03:00
|
|
|
m_quickWidget->setSource(QUrl::fromLocalFile(effectMakerQmlPath));
|
2023-06-29 15:06:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace QmlDesigner
|