[AudioSystem] Allow audio engines to provide widgets for modifying connection properties. (#6303)
Signed-off-by: Maxim Ivanov <imginimg@gmail.com>
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
#include <ACETypes.h>
|
||||
|
||||
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
|
||||
|
||||
@@ -16,18 +16,6 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>450</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>450</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Inspector Panel</string>
|
||||
</property>
|
||||
@@ -104,7 +92,7 @@
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QVBoxLayout" name="m_connectionPropertiesLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
|
||||
@@ -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<QListWidgetItem*> 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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user