aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/effectcomposer/effectshaderscodeeditor.cpp
diff options
context:
space:
mode:
authorAli Kianian <ali.kianian@qt.io>2024-11-17 07:36:01 +0200
committerAli Kianian <ali.kianian@qt.io>2024-11-19 12:59:14 +0000
commite75d9001e5c16cb044ddb229bbb858e02d4028ef (patch)
tree675e7ffbc4233c3c2639ddfea516007e4a96c6d8 /src/plugins/effectcomposer/effectshaderscodeeditor.cpp
parent92bd7a1f0105c087dccb8bbb05b43bfe3816d574 (diff)
EffectComposer: Move live update button to Qml header
Task-number: QDS-14123 Change-Id: I54d3bb7e916a5bf5f9b4e5b9db17692eed28aaaf Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/plugins/effectcomposer/effectshaderscodeeditor.cpp')
-rw-r--r--src/plugins/effectcomposer/effectshaderscodeeditor.cpp47
1 files changed, 1 insertions, 46 deletions
diff --git a/src/plugins/effectcomposer/effectshaderscodeeditor.cpp b/src/plugins/effectcomposer/effectshaderscodeeditor.cpp
index fce41f27c4a..35f11879fcd 100644
--- a/src/plugins/effectcomposer/effectshaderscodeeditor.cpp
+++ b/src/plugins/effectcomposer/effectshaderscodeeditor.cpp
@@ -14,8 +14,6 @@
#include <coreplugin/icore.h>
-#include <componentcore/designeractionmanager.h>
-#include <componentcore/designericons.h>
#include <componentcore/theme.h>
#include <qmldesigner/qmldesignerplugin.h>
@@ -29,22 +27,14 @@
#include <QSettings>
#include <QSplitter>
#include <QTabWidget>
-#include <QToolBar>
#include <QVBoxLayout>
namespace {
-using IconId = QmlDesigner::DesignerIcons::IconId;
-
inline constexpr char EFFECTCOMPOSER_LIVE_UPDATE_KEY[] = "EffectComposer/CodeEditor/LiveUpdate";
inline constexpr char OBJECT_NAME_EFFECTCOMPOSER_SHADER_HEADER[]
= "QQuickWidgetEffectComposerCodeEditorHeader";
-QIcon toolbarIcon(IconId iconId)
-{
- return QmlDesigner::DesignerActionManager::instance().toolbarIcon(iconId);
-};
-
QString propertyEditorResourcesPath()
{
#ifdef SHARE_QML_PATH
@@ -222,7 +212,6 @@ void EffectShadersCodeEditor::setupUIComponents()
tabWidget->addTab(m_vertexEditor, tr("Vertex Shader"));
verticalLayout->setContentsMargins(0, 0, 0, 0);
- verticalLayout->addWidget(createToolbar());
verticalLayout->addWidget(splitter);
splitter->addWidget(m_headerWidget.get());
splitter->addWidget(tabWidget);
@@ -275,41 +264,6 @@ void EffectShadersCodeEditor::readAndApplyLiveUpdateSettings()
setLiveUpdate(liveUpdateStatus);
}
-QToolBar *EffectShadersCodeEditor::createToolbar()
-{
- using QmlDesigner::Theme;
-
- QToolBar *toolbar = new QToolBar(this);
-
- toolbar->setFixedHeight(Theme::toolbarSize());
- toolbar->setFloatable(false);
- toolbar->setContentsMargins(0, 0, 0, 0);
-
- toolbar->setStyleSheet(Theme::replaceCssColors(
- QString::fromUtf8(Utils::FileReader::fetchQrc(":/qmldesigner/stylesheet.css"))));
-
- QAction *liveUpdateButton
- = toolbar->addAction(toolbarIcon(IconId::LiveUpdateIcon), tr("Live Update"));
- liveUpdateButton->setCheckable(true);
- connect(liveUpdateButton, &QAction::toggled, this, &EffectShadersCodeEditor::setLiveUpdate);
-
- QAction *applyAction = toolbar->addAction(toolbarIcon(IconId::SyncIcon), tr("Apply"));
- connect(applyAction, &QAction::triggered, this, &EffectShadersCodeEditor::rebakeRequested);
-
- auto syncLive = [liveUpdateButton, applyAction](bool liveState) {
- liveUpdateButton->setChecked(liveState);
- applyAction->setDisabled(liveState);
- };
-
- connect(this, &EffectShadersCodeEditor::liveUpdateChanged, this, syncLive);
- syncLive(liveUpdate());
-
- toolbar->addAction(liveUpdateButton);
- toolbar->addAction(applyAction);
-
- return toolbar;
-}
-
void EffectShadersCodeEditor::createHeader()
{
m_headerWidget = new StudioQuickWidget(this);
@@ -320,6 +274,7 @@ void EffectShadersCodeEditor::createHeader()
m_headerWidget->engine()->addImportPath(EffectUtils::nodesSourcesPath() + "/common");
m_headerWidget->setClearColor(QmlDesigner::Theme::getColor(
QmlDesigner::Theme::Color::QmlDesigner_BackgroundColorDarkAlternate));
+ m_headerWidget->rootContext()->setContextProperty("shaderEditor", QVariant::fromValue(this));
}
void EffectShadersCodeEditor::reloadQml()