forked from qt-creator/qt-creator
EffectComposer: Add a button for inserting uniform id to code editor
Task-number: QDS-14140 Change-Id: Ic4505a25ed46aee8e58fc1a9fd1af6e47c5172d2 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -9,7 +9,7 @@ import StudioTheme as StudioTheme
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
property var rootView: shaderEditor
|
property var rootEditor: shaderEditor
|
||||||
|
|
||||||
color: StudioTheme.Values.themeToolbarBackground
|
color: StudioTheme.Values.themeToolbarBackground
|
||||||
|
|
||||||
@@ -52,8 +52,8 @@ Rectangle {
|
|||||||
text: qsTr("Live Update")
|
text: qsTr("Live Update")
|
||||||
actionIndicatorVisible: false
|
actionIndicatorVisible: false
|
||||||
style: StudioTheme.Values.viewBarControlStyle
|
style: StudioTheme.Values.viewBarControlStyle
|
||||||
checked: root.rootView ? root.rootView.liveUpdate : false
|
checked: root.rootEditor ? root.rootEditor.liveUpdate : false
|
||||||
onToggled: root.rootView.liveUpdate = checked
|
onToggled: root.rootEditor.liveUpdate = checked
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -99,24 +99,28 @@ ColumnLayout {
|
|||||||
sourceComponent: MouseArea {
|
sourceComponent: MouseArea {
|
||||||
id: hoverArea
|
id: hoverArea
|
||||||
|
|
||||||
width: 15
|
width: buttonsRow.implicitWidth
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
|
id: buttonsRow
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
spacing: StudioTheme.Values.controlGap
|
||||||
visible: hoverArea.containsMouse
|
visible: hoverArea.containsMouse
|
||||||
|
|
||||||
StudioControls.AbstractButton {
|
CellButton {
|
||||||
width: iconSize
|
buttonIcon: StudioTheme.Constants.assignTo_medium
|
||||||
height: iconSize
|
onClicked: rootEditor.insertTextToCursorPosition(dataScope.display)
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
tooltip: qsTr("Insert into the editor cursor position.")
|
||||||
buttonIcon: StudioTheme.Constants.copy_small
|
|
||||||
backgroundVisible: false
|
|
||||||
onClicked: rootView.copyText(dataScope.display)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
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 !== ""
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -184,6 +184,16 @@ void EffectShadersCodeEditor::copyText(const QString &text)
|
|||||||
qApp->clipboard()->setText(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()
|
EffectShadersCodeEditor *EffectShadersCodeEditor::instance()
|
||||||
{
|
{
|
||||||
static EffectShadersCodeEditor *editorInstance = new EffectShadersCodeEditor(
|
static EffectShadersCodeEditor *editorInstance = new EffectShadersCodeEditor(
|
||||||
@@ -310,4 +320,18 @@ void EffectShadersCodeEditor::selectNonEmptyShader(ShaderEditorData *data)
|
|||||||
widgetToSelect->setFocus();
|
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
|
} // namespace EffectComposer
|
||||||
|
@@ -65,6 +65,7 @@ public:
|
|||||||
EffectComposerUniformsModel *uniforms);
|
EffectComposerUniformsModel *uniforms);
|
||||||
|
|
||||||
Q_INVOKABLE void copyText(const QString &text);
|
Q_INVOKABLE void copyText(const QString &text);
|
||||||
|
Q_INVOKABLE void insertTextToCursorPosition(const QString &text);
|
||||||
|
|
||||||
static EffectShadersCodeEditor *instance();
|
static EffectShadersCodeEditor *instance();
|
||||||
|
|
||||||
@@ -89,6 +90,8 @@ private:
|
|||||||
void setUniformsModel(EffectComposerUniformsTableModel *uniforms);
|
void setUniformsModel(EffectComposerUniformsTableModel *uniforms);
|
||||||
void selectNonEmptyShader(ShaderEditorData *data);
|
void selectNonEmptyShader(ShaderEditorData *data);
|
||||||
|
|
||||||
|
EffectCodeEditorWidget *currentEditor() const;
|
||||||
|
|
||||||
QSettings *m_settings = nullptr;
|
QSettings *m_settings = nullptr;
|
||||||
QPointer<StudioQuickWidget> m_headerWidget;
|
QPointer<StudioQuickWidget> m_headerWidget;
|
||||||
QPointer<QTabWidget> m_tabWidget;
|
QPointer<QTabWidget> m_tabWidget;
|
||||||
|
Reference in New Issue
Block a user