diff --git a/Gems/AudioSystem/Code/Include/Editor/IAudioSystemEditor.h b/Gems/AudioSystem/Code/Include/Editor/IAudioSystemEditor.h index 5a9c773a32..b4dcf1df12 100644 --- a/Gems/AudioSystem/Code/Include/Editor/IAudioSystemEditor.h +++ b/Gems/AudioSystem/Code/Include/Editor/IAudioSystemEditor.h @@ -16,6 +16,8 @@ #include +class QWidget; + namespace AudioControls { class IAudioSystemEditor; @@ -150,6 +152,12 @@ namespace AudioControls //! Informs the plugin that the ACE has saved the data in case it needs to do any clean up. virtual void DataSaved() = 0; + + //! Creates a widget for modifying connection properties. + //! The widget must have a "PropertiesChanged()" signal. + //! The widget ownership transferred to the caller. + virtual QWidget* CreateConnectionPropertiesWidget([[maybe_unused]] const TConnectionPtr connection, + [[maybe_unused]] EACEControlType atlControlType) { return nullptr; } }; } // namespace AudioControls diff --git a/Gems/AudioSystem/Code/Source/Editor/ConnectionsWidget.ui b/Gems/AudioSystem/Code/Source/Editor/ConnectionsWidget.ui index 120df694bc..b536ea541a 100644 --- a/Gems/AudioSystem/Code/Source/Editor/ConnectionsWidget.ui +++ b/Gems/AudioSystem/Code/Source/Editor/ConnectionsWidget.ui @@ -16,18 +16,6 @@ 0 - - - 0 - 450 - - - - - 16777215 - 450 - - Inspector Panel @@ -104,7 +92,7 @@ QFrame::Plain - + 0 diff --git a/Gems/AudioSystem/Code/Source/Editor/QConnectionsWidget.cpp b/Gems/AudioSystem/Code/Source/Editor/QConnectionsWidget.cpp index ce7a49ae1e..d827f657b8 100644 --- a/Gems/AudioSystem/Code/Source/Editor/QConnectionsWidget.cpp +++ b/Gems/AudioSystem/Code/Source/Editor/QConnectionsWidget.cpp @@ -37,6 +37,7 @@ namespace AudioControls m_connectionList->installEventFilter(this); connect(m_connectionList, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(ShowConnectionContextMenu(const QPoint&))); + connect(m_connectionList, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedConnectionChanged())); } //-------------------------------------------------------------------------------------------// @@ -100,6 +101,57 @@ namespace AudioControls contextMenu.exec(m_connectionList->mapToGlobal(pos)); } + //-------------------------------------------------------------------------------------------// + void QConnectionsWidget::SelectedConnectionChanged() + { + TConnectionPtr connection; + EACEControlType controlType = AudioControls::eACET_NUM_TYPES; + if (m_control) + { + QList selected = m_connectionList->selectedItems(); + if (selected.length() == 1) + { + QListWidgetItem* currentItem = selected[0]; + if (currentItem) + { + const CID externalId = currentItem->data(eMDR_ID).toInt(); + connection = m_control->GetConnection(externalId); + controlType = m_control->GetType(); + } + } + } + + if (m_connectionPropertiesWidget) + { + delete m_connectionPropertiesWidget; + m_connectionPropertiesWidget = nullptr; + } + + if (connection && connection->HasProperties()) + { + if (IAudioSystemEditor* audioSystemImpl = CAudioControlsEditorPlugin::GetAudioSystemEditorImpl()) + { + m_connectionPropertiesWidget = audioSystemImpl->CreateConnectionPropertiesWidget(connection, controlType); + if (m_connectionPropertiesWidget) + { + m_connectionPropertiesWidget->setParent(m_connectionPropertiesFrame); + m_connectionPropertiesLayout->addWidget(m_connectionPropertiesWidget); + + bool widgetHasChangedSignal = m_connectionPropertiesWidget->metaObject()->indexOfSignal("PropertiesChanged()") != -1; + AZ_Error( + "Audio", widgetHasChangedSignal, + "The widget created by IAudioSystemEditor::CreateConnectionPropertiesWidget() must have a \"PropertiesChanged()\" " + "signal."); + + if (widgetHasChangedSignal) + { + connect(m_connectionPropertiesWidget, SIGNAL(PropertiesChanged()), this, SLOT(CurrentConnectionModified())); + } + } + } + } + } + //-------------------------------------------------------------------------------------------// void QConnectionsWidget::MakeConnectionTo(IAudioSystemControl* middlewareControl) { diff --git a/Gems/AudioSystem/Code/Source/Editor/QConnectionsWidget.h b/Gems/AudioSystem/Code/Source/Editor/QConnectionsWidget.h index 2adb7c592d..d1181d74c2 100644 --- a/Gems/AudioSystem/Code/Source/Editor/QConnectionsWidget.h +++ b/Gems/AudioSystem/Code/Source/Editor/QConnectionsWidget.h @@ -40,6 +40,7 @@ namespace AudioControls void ShowConnectionContextMenu(const QPoint& pos); void CurrentConnectionModified(); void RemoveSelectedConnection(); + void SelectedConnectionChanged(); private: bool eventFilter(QObject* object, QEvent* event) override; @@ -50,6 +51,8 @@ namespace AudioControls CATLControl* m_control; QColor m_notFoundColor; QColor m_localizedColor; + + QWidget* m_connectionPropertiesWidget = nullptr; }; } // namespace AudioControls