GUI Milestone 6

This commit is contained in:
Joey Yakimowich-Payne 2026-01-30 06:38:58 -07:00
commit 0e67c19902
4 changed files with 211 additions and 26 deletions

View file

@ -5,9 +5,12 @@
#include <QtNodes/ConnectionStyle>
#include <QtNodes/GraphicsView>
#include <QDateTime>
#include <QDir>
#include <QInputDialog>
#include <QMenu>
#include <QMessageBox>
#include <QPixmap>
#include <QStandardPaths>
#include <QTimer>
#include <QVBoxLayout>
@ -62,13 +65,26 @@ GraphEditorWidget::GraphEditorWidget(warppipe::Client *client,
m_model->autoArrange();
}
if (m_model->allNodeIds().size() > 0) {
m_graphReady = true;
Q_EMIT graphReady();
}
m_refreshTimer = new QTimer(this);
connect(m_refreshTimer, &QTimer::timeout, this,
&GraphEditorWidget::onRefreshTimer);
m_refreshTimer->start(500);
}
void GraphEditorWidget::onRefreshTimer() { m_model->refreshFromClient(); }
void GraphEditorWidget::onRefreshTimer() {
m_model->refreshFromClient();
if (!m_graphReady && m_model->allNodeIds().size() > 0) {
m_graphReady = true;
Q_EMIT graphReady();
captureDebugScreenshot("initial_load");
}
}
void GraphEditorWidget::scheduleSaveLayout() {
if (!m_saveTimer->isActive()) {
@ -89,6 +105,55 @@ int GraphEditorWidget::linkCount() const {
return count / 2;
}
void GraphEditorWidget::setDebugScreenshotDir(const QString &dir) {
m_debugScreenshotDir = dir;
QDir d(dir);
if (!d.exists()) {
d.mkpath(".");
}
connect(m_model, &QtNodes::AbstractGraphModel::nodeCreated, this, [this]() {
captureDebugScreenshot("node_added");
});
connect(m_model, &QtNodes::AbstractGraphModel::nodeDeleted, this, [this]() {
captureDebugScreenshot("node_removed");
});
connect(m_model, &QtNodes::AbstractGraphModel::connectionCreated, this,
[this]() { captureDebugScreenshot("connection_added"); });
connect(m_model, &QtNodes::AbstractGraphModel::connectionDeleted, this,
[this]() { captureDebugScreenshot("connection_removed"); });
connect(m_model, &QtNodes::AbstractGraphModel::nodeUpdated, this, [this]() {
captureDebugScreenshot("node_updated");
});
if (m_graphReady) {
QTimer::singleShot(200, this, [this]() {
captureDebugScreenshot("initial_load");
});
}
}
void GraphEditorWidget::captureDebugScreenshot(const QString &event) {
if (m_debugScreenshotDir.isEmpty()) {
return;
}
QWidget *win = window();
if (!win) {
return;
}
QPixmap pixmap = win->grab();
if (pixmap.isNull()) {
return;
}
QString timestamp =
QDateTime::currentDateTime().toString("yyyyMMdd_HHmmss");
QString filename = QString("warppipe_%1_%2.png").arg(timestamp, event);
pixmap.save(m_debugScreenshotDir + "/" + filename);
}
void GraphEditorWidget::onContextMenuRequested(const QPoint &pos) {
QPointF scenePos = m_view->mapToScene(pos);