GUI M8d
This commit is contained in:
parent
e649dea9c1
commit
a07f94c93d
10 changed files with 718 additions and 25 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#include "WarpGraphModel.h"
|
||||
#include "VolumeWidgets.h"
|
||||
|
||||
#include <QColor>
|
||||
#include <QDir>
|
||||
|
|
@ -178,6 +179,12 @@ QVariant WarpGraphModel::nodeData(QtNodes::NodeId nodeId,
|
|||
WarpNodeType type = classifyNode(data.info);
|
||||
return styleForNode(type, ghost);
|
||||
}
|
||||
case QtNodes::NodeRole::Widget: {
|
||||
auto wIt = m_volumeWidgets.find(nodeId);
|
||||
if (wIt != m_volumeWidgets.end())
|
||||
return QVariant::fromValue(wIt->second);
|
||||
return QVariant::fromValue(static_cast<QWidget *>(nullptr));
|
||||
}
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
|
@ -290,6 +297,12 @@ bool WarpGraphModel::deleteNode(QtNodes::NodeId const nodeId) {
|
|||
m_nodes.erase(nodeId);
|
||||
m_positions.erase(nodeId);
|
||||
m_sizes.erase(nodeId);
|
||||
m_volumeStates.erase(nodeId);
|
||||
auto vwIt = m_volumeWidgets.find(nodeId);
|
||||
if (vwIt != m_volumeWidgets.end()) {
|
||||
delete vwIt->second;
|
||||
m_volumeWidgets.erase(vwIt);
|
||||
}
|
||||
Q_EMIT nodeDeleted(nodeId);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -457,6 +470,10 @@ void WarpGraphModel::refreshFromClient() {
|
|||
}
|
||||
}
|
||||
|
||||
auto *volumeWidget = new NodeVolumeWidget();
|
||||
m_volumeWidgets[qtId] = volumeWidget;
|
||||
m_volumeStates[qtId] = {};
|
||||
|
||||
Q_EMIT nodeCreated(qtId);
|
||||
}
|
||||
|
||||
|
|
@ -713,6 +730,45 @@ WarpGraphModel::classifyNode(const warppipe::NodeInfo &info) {
|
|||
return WarpNodeType::kUnknown;
|
||||
}
|
||||
|
||||
void WarpGraphModel::setNodeVolumeState(QtNodes::NodeId nodeId,
|
||||
const NodeVolumeState &state) {
|
||||
if (!nodeExists(nodeId))
|
||||
return;
|
||||
|
||||
NodeVolumeState previous = m_volumeStates[nodeId];
|
||||
m_volumeStates[nodeId] = state;
|
||||
|
||||
if (m_client) {
|
||||
auto it = m_nodes.find(nodeId);
|
||||
if (it != m_nodes.end() && it->second.info.id.value != 0) {
|
||||
#ifdef WARPPIPE_TESTING
|
||||
m_client->Test_SetNodeVolume(it->second.info.id, state.volume, state.mute);
|
||||
#else
|
||||
m_client->SetNodeVolume(it->second.info.id, state.volume, state.mute);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
auto wIt = m_volumeWidgets.find(nodeId);
|
||||
if (wIt != m_volumeWidgets.end()) {
|
||||
auto *w = qobject_cast<NodeVolumeWidget *>(wIt->second);
|
||||
if (w) {
|
||||
w->setVolume(static_cast<int>(state.volume * 100.0f));
|
||||
w->setMuted(state.mute);
|
||||
}
|
||||
}
|
||||
|
||||
Q_EMIT nodeVolumeChanged(nodeId, previous, state);
|
||||
}
|
||||
|
||||
WarpGraphModel::NodeVolumeState
|
||||
WarpGraphModel::nodeVolumeState(QtNodes::NodeId nodeId) const {
|
||||
auto it = m_volumeStates.find(nodeId);
|
||||
if (it != m_volumeStates.end())
|
||||
return it->second;
|
||||
return {};
|
||||
}
|
||||
|
||||
void WarpGraphModel::saveLayout(const QString &path) const {
|
||||
ViewState vs{};
|
||||
saveLayout(path, vs);
|
||||
|
|
@ -938,6 +994,10 @@ bool WarpGraphModel::loadLayout(const QString &path) {
|
|||
? m_positions.at(qtId)
|
||||
: QPointF(0, 0);
|
||||
|
||||
auto *volumeWidget = new NodeVolumeWidget();
|
||||
m_volumeWidgets[qtId] = volumeWidget;
|
||||
m_volumeStates[qtId] = {};
|
||||
|
||||
Q_EMIT nodeCreated(qtId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue