diff --git a/share/qtcreator/qmldesigner/effectComposerQmlSources/CodeEditorHeader.qml b/share/qtcreator/qmldesigner/effectComposerQmlSources/CodeEditorHeader.qml index 6ebcf731204..9a50c761299 100644 --- a/share/qtcreator/qmldesigner/effectComposerQmlSources/CodeEditorHeader.qml +++ b/share/qtcreator/qmldesigner/effectComposerQmlSources/CodeEditorHeader.qml @@ -9,7 +9,7 @@ import StudioTheme as StudioTheme Rectangle { id: root - property var rootView: shaderEditor + property var rootEditor: shaderEditor color: StudioTheme.Values.themeToolbarBackground @@ -52,8 +52,8 @@ Rectangle { text: qsTr("Live Update") actionIndicatorVisible: false style: StudioTheme.Values.viewBarControlStyle - checked: root.rootView ? root.rootView.liveUpdate : false - onToggled: root.rootView.liveUpdate = checked + checked: root.rootEditor ? root.rootEditor.liveUpdate : false + onToggled: root.rootEditor.liveUpdate = checked Layout.alignment: Qt.AlignVCenter } } diff --git a/share/qtcreator/qmldesigner/effectComposerQmlSources/CodeEditorUniformsView.qml b/share/qtcreator/qmldesigner/effectComposerQmlSources/CodeEditorUniformsView.qml index f7319a3cd8c..decb076094a 100644 --- a/share/qtcreator/qmldesigner/effectComposerQmlSources/CodeEditorUniformsView.qml +++ b/share/qtcreator/qmldesigner/effectComposerQmlSources/CodeEditorUniformsView.qml @@ -99,24 +99,28 @@ ColumnLayout { sourceComponent: MouseArea { id: hoverArea - width: 15 + width: buttonsRow.implicitWidth hoverEnabled: true enabled: true Row { + id: buttonsRow + anchors.fill: parent + spacing: StudioTheme.Values.controlGap visible: hoverArea.containsMouse - StudioControls.AbstractButton { - width: iconSize - height: iconSize - anchors.verticalCenter: parent.verticalCenter - buttonIcon: StudioTheme.Constants.copy_small - backgroundVisible: false - onClicked: rootView.copyText(dataScope.display) + CellButton { + buttonIcon: StudioTheme.Constants.assignTo_medium + onClicked: rootEditor.insertTextToCursorPosition(dataScope.display) + tooltip: qsTr("Insert into the editor cursor position.") } - // ToDo: Add a button for placing the value to the editor + CellButton { + buttonIcon: StudioTheme.Constants.copy_small + onClicked: rootEditor.copyText(dataScope.display) + tooltip: qsTr("Copy uniform name to clipboard.") + } } } } @@ -182,4 +186,22 @@ ColumnLayout { color: StudioTheme.Values.themeStateSeparator } } + + component CellButton: StudioControls.AbstractButton { + id: cellBtn + + property alias tooltip: cellBtnTooltip.text + + width: iconSize + height: iconSize + anchors.verticalCenter: parent.verticalCenter + buttonIcon: StudioTheme.Constants.assignTo_medium + backgroundVisible: false + + StudioControls.ToolTip { + id: cellBtnTooltip + + visible: cellBtn.hovered && text !== "" + } + } } diff --git a/src/plugins/effectcomposer/effectshaderscodeeditor.cpp b/src/plugins/effectcomposer/effectshaderscodeeditor.cpp index f18cd15c3c7..a229d9e6d25 100644 --- a/src/plugins/effectcomposer/effectshaderscodeeditor.cpp +++ b/src/plugins/effectcomposer/effectshaderscodeeditor.cpp @@ -184,6 +184,16 @@ void EffectShadersCodeEditor::copyText(const QString &text) qApp->clipboard()->setText(text); } +void EffectShadersCodeEditor::insertTextToCursorPosition(const QString &text) +{ + auto editor = currentEditor(); + if (!editor) + return; + + editor->textCursor().insertText(text); + editor->setFocus(); +} + EffectShadersCodeEditor *EffectShadersCodeEditor::instance() { static EffectShadersCodeEditor *editorInstance = new EffectShadersCodeEditor( @@ -310,4 +320,18 @@ void EffectShadersCodeEditor::selectNonEmptyShader(ShaderEditorData *data) widgetToSelect->setFocus(); } +EffectCodeEditorWidget *EffectShadersCodeEditor::currentEditor() const +{ + QWidget *currentTab = m_tabWidget->currentWidget(); + if (!m_currentEditorData || !currentTab) + return nullptr; + + if (currentTab == m_currentEditorData->fragmentEditor.get()) + return m_currentEditorData->fragmentEditor.get(); + if (currentTab == m_currentEditorData->vertexEditor.get()) + return m_currentEditorData->vertexEditor.get(); + + return nullptr; +} + } // namespace EffectComposer diff --git a/src/plugins/effectcomposer/effectshaderscodeeditor.h b/src/plugins/effectcomposer/effectshaderscodeeditor.h index af7f1d472b7..218ab58046b 100644 --- a/src/plugins/effectcomposer/effectshaderscodeeditor.h +++ b/src/plugins/effectcomposer/effectshaderscodeeditor.h @@ -65,6 +65,7 @@ public: EffectComposerUniformsModel *uniforms); Q_INVOKABLE void copyText(const QString &text); + Q_INVOKABLE void insertTextToCursorPosition(const QString &text); static EffectShadersCodeEditor *instance(); @@ -89,6 +90,8 @@ private: void setUniformsModel(EffectComposerUniformsTableModel *uniforms); void selectNonEmptyShader(ShaderEditorData *data); + EffectCodeEditorWidget *currentEditor() const; + QSettings *m_settings = nullptr; QPointer m_headerWidget; QPointer m_tabWidget;