forked from qt-creator/qt-creator
EffectComposer: Move live update button to Qml header
Task-number: QDS-14123 Change-Id: I54d3bb7e916a5bf5f9b4e5b9db17692eed28aaaf Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
@@ -3,9 +3,14 @@
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import StudioControls as StudioControls
|
||||
import StudioTheme as StudioTheme
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
property var rootView: shaderEditor
|
||||
|
||||
color: StudioTheme.Values.themeToolbarBackground
|
||||
|
||||
ColumnLayout {
|
||||
@@ -19,10 +24,19 @@ Rectangle {
|
||||
|
||||
ColumnChooser {
|
||||
table: uniformsView.tableView
|
||||
text: "Columns"
|
||||
text: qsTr("Columns")
|
||||
style: StudioTheme.Values.viewBarControlStyle
|
||||
Layout.topMargin: StudioTheme.Values.marginTopBottom
|
||||
}
|
||||
|
||||
StudioControls.CheckBox {
|
||||
text: qsTr("Live Update")
|
||||
actionIndicatorVisible: false
|
||||
style: StudioTheme.Values.viewBarControlStyle
|
||||
Layout.topMargin: StudioTheme.Values.marginTopBottom
|
||||
checked: root.rootView ? root.rootView.liveUpdate : false
|
||||
onToggled: root.rootView.liveUpdate = checked
|
||||
}
|
||||
}
|
||||
|
||||
CodeEditorUniformsView {
|
||||
|
@@ -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()
|
||||
|
@@ -8,7 +8,6 @@
|
||||
#include <utils/uniqueobjectptr.h>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QSettings)
|
||||
QT_FORWARD_DECLARE_CLASS(QToolBar)
|
||||
|
||||
class StudioQuickWidget;
|
||||
|
||||
@@ -60,7 +59,6 @@ protected:
|
||||
private:
|
||||
void writeLiveUpdateSettings();
|
||||
void readAndApplyLiveUpdateSettings();
|
||||
QToolBar *createToolbar();
|
||||
void createHeader();
|
||||
void reloadQml();
|
||||
|
||||
|
Reference in New Issue
Block a user