Fix perf issues and some visual bugs
This commit is contained in:
parent
00e997a204
commit
d389161f4a
5 changed files with 300 additions and 11 deletions
|
|
@ -29,6 +29,8 @@ WarpGraphModel::WarpGraphModel(warppipe::Client *client, QObject *parent)
|
|||
if (parent) {
|
||||
setParent(parent);
|
||||
}
|
||||
connect(this, &WarpGraphModel::nodeUpdated, this,
|
||||
[this](QtNodes::NodeId nodeId) { m_styleCache.erase(nodeId); });
|
||||
}
|
||||
|
||||
QtNodes::NodeId WarpGraphModel::newNodeId() { return m_nextNodeId++; }
|
||||
|
|
@ -195,9 +197,14 @@ QVariant WarpGraphModel::nodeData(QtNodes::NodeId nodeId,
|
|||
case QtNodes::NodeRole::Type:
|
||||
return QString("PipeWire");
|
||||
case QtNodes::NodeRole::Style: {
|
||||
auto cacheIt = m_styleCache.find(nodeId);
|
||||
if (cacheIt != m_styleCache.end())
|
||||
return cacheIt->second;
|
||||
bool ghost = m_ghostNodes.find(nodeId) != m_ghostNodes.end();
|
||||
WarpNodeType type = classifyNode(data.info);
|
||||
return styleForNode(type, ghost);
|
||||
QVariant result = styleForNode(type, ghost);
|
||||
m_styleCache[nodeId] = result;
|
||||
return result;
|
||||
}
|
||||
case QtNodes::NodeRole::Widget: {
|
||||
auto wIt = m_volumeWidgets.find(nodeId);
|
||||
|
|
@ -321,6 +328,7 @@ bool WarpGraphModel::deleteNode(QtNodes::NodeId const nodeId) {
|
|||
m_positions.erase(nodeId);
|
||||
m_sizes.erase(nodeId);
|
||||
m_volumeStates.erase(nodeId);
|
||||
m_styleCache.erase(nodeId);
|
||||
auto vwIt = m_volumeWidgets.find(nodeId);
|
||||
if (vwIt != m_volumeWidgets.end()) {
|
||||
delete vwIt->second;
|
||||
|
|
@ -593,7 +601,8 @@ void WarpGraphModel::refreshFromClient() {
|
|||
|
||||
if (outIsGhost || inIsGhost) {
|
||||
m_ghostConnections.insert(connId);
|
||||
} else {
|
||||
}
|
||||
{
|
||||
auto connIt = m_connections.find(connId);
|
||||
if (connIt != m_connections.end()) {
|
||||
m_connections.erase(connIt);
|
||||
|
|
@ -643,10 +652,8 @@ void WarpGraphModel::refreshFromClient() {
|
|||
}
|
||||
|
||||
QtNodes::ConnectionId connId{outQtId, outIdx, inQtId, inIdx};
|
||||
if (m_connections.find(connId) == m_connections.end()) {
|
||||
m_connections.insert(connId);
|
||||
if (m_ghostConnections.find(connId) == m_ghostConnections.end()) {
|
||||
m_ghostConnections.insert(connId);
|
||||
Q_EMIT connectionCreated(connId);
|
||||
}
|
||||
it = m_pendingGhostConnections.erase(it);
|
||||
}
|
||||
|
|
@ -969,6 +976,12 @@ void WarpGraphModel::saveLayout(const QString &path,
|
|||
viewObj["splitter_sidebar"] = viewState.splitterSidebar;
|
||||
}
|
||||
viewObj["connection_style"] = viewState.connectionStyle;
|
||||
if (viewState.zoomSensitivity > 0.0)
|
||||
viewObj["zoom_sensitivity"] = viewState.zoomSensitivity;
|
||||
if (viewState.zoomMin > 0.0)
|
||||
viewObj["zoom_min"] = viewState.zoomMin;
|
||||
if (viewState.zoomMax > 0.0)
|
||||
viewObj["zoom_max"] = viewState.zoomMax;
|
||||
root["view"] = viewObj;
|
||||
}
|
||||
|
||||
|
|
@ -1029,6 +1042,9 @@ bool WarpGraphModel::loadLayout(const QString &path) {
|
|||
m_savedViewState.splitterGraph = viewObj["splitter_graph"].toInt(0);
|
||||
m_savedViewState.splitterSidebar = viewObj["splitter_sidebar"].toInt(0);
|
||||
m_savedViewState.connectionStyle = viewObj["connection_style"].toInt(0);
|
||||
m_savedViewState.zoomSensitivity = viewObj["zoom_sensitivity"].toDouble(0.0);
|
||||
m_savedViewState.zoomMin = viewObj["zoom_min"].toDouble(0.0);
|
||||
m_savedViewState.zoomMax = viewObj["zoom_max"].toDouble(0.0);
|
||||
m_savedViewState.valid = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue