EffectComposer: Add copy button for the uniform id in editor

Task-number: QDS-14124
Change-Id: If73f0ba40b672c1761c54765c8415fb498873b2a
Reviewed-by: Shrief Gabr <shrief.gabr@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Ali Kianian
2024-11-17 11:49:44 +02:00
parent 3c8c2eba13
commit f6593cac58
5 changed files with 46 additions and 0 deletions

View File

@@ -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

View File

@@ -179,6 +179,7 @@ QHash<int, QByteArray> 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 {};
}

View File

@@ -30,6 +30,7 @@ public:
enum Role {
ValueRole = Qt::UserRole + 1,
ValueTypeRole,
CanCopyRole,
};
explicit EffectComposerUniformsTableModel(

View File

@@ -23,6 +23,7 @@
#include <qmljseditor/qmljseditordocument.h>
#include <QApplication>
#include <QClipboard>
#include <QPlainTextEdit>
#include <QSettings>
#include <QSplitter>
@@ -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;

View File

@@ -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();