diff --git a/share/qtcreator/qmldesigner/effectComposerQmlSources/CodeEditorUniformsView.qml b/share/qtcreator/qmldesigner/effectComposerQmlSources/CodeEditorUniformsView.qml index 5d86c6d1ac7..f7319a3cd8c 100644 --- a/share/qtcreator/qmldesigner/effectComposerQmlSources/CodeEditorUniformsView.qml +++ b/share/qtcreator/qmldesigner/effectComposerQmlSources/CodeEditorUniformsView.qml @@ -88,6 +88,38 @@ ColumnLayout { text: labelView.text enabled: labelView.truncated } + + Loader { + active: dataScope.canCopy + + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + + sourceComponent: MouseArea { + id: hoverArea + + width: 15 + hoverEnabled: true + enabled: true + + Row { + anchors.fill: parent + 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) + } + + // ToDo: Add a button for placing the value to the editor + } + } + } } } } @@ -140,6 +172,7 @@ ColumnLayout { required property bool editing required property bool selected required property bool current + required property bool canCopy color: tableView.currentRow === row ? StudioTheme.Values.themeTableCellCurrent : StudioTheme.Values.themePanelBackground implicitWidth: StudioTheme.Values.cellWidth diff --git a/src/plugins/effectcomposer/effectcomposeruniformstablemodel.cpp b/src/plugins/effectcomposer/effectcomposeruniformstablemodel.cpp index 5189a631dfe..16c9d489196 100644 --- a/src/plugins/effectcomposer/effectcomposeruniformstablemodel.cpp +++ b/src/plugins/effectcomposer/effectcomposeruniformstablemodel.cpp @@ -179,6 +179,7 @@ QHash EffectComposerUniformsTableModel::roleNames() const {Qt::DisplayRole, "display"}, {Role::ValueRole, "value"}, {Role::ValueTypeRole, "valueType"}, + {Role::CanCopyRole, "canCopy"}, }; } @@ -206,6 +207,9 @@ QVariant EffectComposerUniformsTableModel::data(const QModelIndex &index, int ro if (role == Role::ValueTypeRole) return mapToSource(index).valueTypeString(); + if (role == Role::CanCopyRole) + return mapToSource(index).role == UniformRole::NameRole; + return {}; } diff --git a/src/plugins/effectcomposer/effectcomposeruniformstablemodel.h b/src/plugins/effectcomposer/effectcomposeruniformstablemodel.h index 68a11eaa168..52b7dd82932 100644 --- a/src/plugins/effectcomposer/effectcomposeruniformstablemodel.h +++ b/src/plugins/effectcomposer/effectcomposeruniformstablemodel.h @@ -30,6 +30,7 @@ public: enum Role { ValueRole = Qt::UserRole + 1, ValueTypeRole, + CanCopyRole, }; explicit EffectComposerUniformsTableModel( diff --git a/src/plugins/effectcomposer/effectshaderscodeeditor.cpp b/src/plugins/effectcomposer/effectshaderscodeeditor.cpp index 35f11879fcd..3f1a48033ee 100644 --- a/src/plugins/effectcomposer/effectshaderscodeeditor.cpp +++ b/src/plugins/effectcomposer/effectshaderscodeeditor.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -174,6 +175,11 @@ void EffectShadersCodeEditor::setUniformsModel(EffectComposerUniformsModel *unif } } +void EffectShadersCodeEditor::copyText(const QString &text) +{ + qApp->clipboard()->setText(text); +} + EffectCodeEditorWidget *EffectShadersCodeEditor::createJSEditor() { static EffectCodeEditorFactory f; diff --git a/src/plugins/effectcomposer/effectshaderscodeeditor.h b/src/plugins/effectcomposer/effectshaderscodeeditor.h index 69ee9a19d38..9de59010afb 100644 --- a/src/plugins/effectcomposer/effectshaderscodeeditor.h +++ b/src/plugins/effectcomposer/effectshaderscodeeditor.h @@ -41,6 +41,8 @@ public: bool isOpened() const; void setUniformsModel(EffectComposerUniformsModel *uniforms); + Q_INVOKABLE void copyText(const QString &text); + signals: void liveUpdateChanged(bool); void fragmentValueChanged();