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
|
|
@ -4,6 +4,7 @@
|
|||
#include "SquareConnectionPainter.h"
|
||||
#include "VolumeWidgets.h"
|
||||
#include "WarpGraphModel.h"
|
||||
#include "ZoomGraphicsView.h"
|
||||
|
||||
#include <QtNodes/BasicGraphicsScene>
|
||||
#include <QtNodes/ConnectionStyle>
|
||||
|
|
@ -178,6 +179,7 @@ GraphEditorWidget::GraphEditorWidget(warppipe::Client *client,
|
|||
bool hasLayout = m_model->loadLayout(m_layoutPath);
|
||||
|
||||
m_scene = new QtNodes::BasicGraphicsScene(*m_model, this);
|
||||
m_scene->setItemIndexMethod(QGraphicsScene::BspTreeIndex);
|
||||
|
||||
QtNodes::ConnectionStyle::setConnectionStyle(
|
||||
R"({"ConnectionStyle": {
|
||||
|
|
@ -192,10 +194,12 @@ GraphEditorWidget::GraphEditorWidget(warppipe::Client *client,
|
|||
"UseDataDefinedColors": false
|
||||
}})");
|
||||
|
||||
m_view = new QtNodes::GraphicsView(m_scene);
|
||||
m_view = new ZoomGraphicsView(m_scene);
|
||||
m_view->setFocusPolicy(Qt::StrongFocus);
|
||||
m_view->viewport()->setFocusPolicy(Qt::StrongFocus);
|
||||
m_view->viewport()->installEventFilter(this);
|
||||
connect(m_view, &ZoomGraphicsView::scaleChanged, m_view,
|
||||
[this]() { m_view->updateProxyCacheMode(); });
|
||||
|
||||
m_presetDir =
|
||||
QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) +
|
||||
|
|
@ -233,6 +237,108 @@ GraphEditorWidget::GraphEditorWidget(warppipe::Client *client,
|
|||
|
||||
presetsLayout->addWidget(savePresetBtn);
|
||||
presetsLayout->addWidget(loadPresetBtn);
|
||||
|
||||
presetsLayout->addSpacing(16);
|
||||
|
||||
auto *zoomSensLabel = new QLabel(QStringLiteral("ZOOM SENSITIVITY"));
|
||||
zoomSensLabel->setStyleSheet(QStringLiteral(
|
||||
"QLabel { color: #a0a8b6; font-size: 11px; font-weight: bold;"
|
||||
" background: transparent; }"));
|
||||
presetsLayout->addWidget(zoomSensLabel);
|
||||
|
||||
m_zoomSensSlider = new QSlider(Qt::Horizontal);
|
||||
m_zoomSensSlider->setRange(5, 50);
|
||||
m_zoomSensSlider->setValue(20);
|
||||
m_zoomSensSlider->setStyleSheet(QStringLiteral(
|
||||
"QSlider::groove:horizontal {"
|
||||
" background: #1a1a1e; border-radius: 3px; height: 6px; }"
|
||||
"QSlider::handle:horizontal {"
|
||||
" background: #ecf0f6; border-radius: 5px;"
|
||||
" width: 10px; margin: -4px 0; }"
|
||||
"QSlider::sub-page:horizontal {"
|
||||
" background: #4caf50; border-radius: 3px; }"));
|
||||
|
||||
m_zoomSensValue = new QLabel(QStringLiteral("1.20x"));
|
||||
m_zoomSensValue->setStyleSheet(QStringLiteral(
|
||||
"QLabel { color: #ecf0f6; font-size: 11px; background: transparent; }"));
|
||||
m_zoomSensValue->setAlignment(Qt::AlignCenter);
|
||||
|
||||
connect(m_zoomSensSlider, &QSlider::valueChanged, this,
|
||||
[this](int value) {
|
||||
double sensitivity = 1.0 + value / 100.0;
|
||||
m_view->setZoomSensitivity(sensitivity);
|
||||
m_zoomSensValue->setText(
|
||||
QString::number(sensitivity, 'f', 2) + QStringLiteral("x"));
|
||||
scheduleSaveLayout();
|
||||
});
|
||||
|
||||
presetsLayout->addWidget(m_zoomSensSlider);
|
||||
presetsLayout->addWidget(m_zoomSensValue);
|
||||
|
||||
auto sliderStyle = m_zoomSensSlider->styleSheet();
|
||||
auto valueLabelStyle = m_zoomSensValue->styleSheet();
|
||||
|
||||
presetsLayout->addSpacing(12);
|
||||
|
||||
auto *zoomMinLabel = new QLabel(QStringLiteral("MIN ZOOM"));
|
||||
zoomMinLabel->setStyleSheet(zoomSensLabel->styleSheet());
|
||||
presetsLayout->addWidget(zoomMinLabel);
|
||||
|
||||
m_zoomMinSlider = new QSlider(Qt::Horizontal);
|
||||
m_zoomMinSlider->setRange(5, 90);
|
||||
m_zoomMinSlider->setValue(30);
|
||||
m_zoomMinSlider->setStyleSheet(sliderStyle);
|
||||
|
||||
m_zoomMinValue = new QLabel(QStringLiteral("0.30x"));
|
||||
m_zoomMinValue->setStyleSheet(valueLabelStyle);
|
||||
m_zoomMinValue->setAlignment(Qt::AlignCenter);
|
||||
|
||||
connect(m_zoomMinSlider, &QSlider::valueChanged, this,
|
||||
[this](int value) {
|
||||
double minZoom = value / 100.0;
|
||||
if (m_zoomMaxSlider->value() <= value) {
|
||||
m_zoomMaxSlider->setValue(value + 5);
|
||||
}
|
||||
m_view->setScaleRange(minZoom,
|
||||
m_zoomMaxSlider->value() / 100.0);
|
||||
m_zoomMinValue->setText(
|
||||
QString::number(minZoom, 'f', 2) + QStringLiteral("x"));
|
||||
scheduleSaveLayout();
|
||||
});
|
||||
|
||||
presetsLayout->addWidget(m_zoomMinSlider);
|
||||
presetsLayout->addWidget(m_zoomMinValue);
|
||||
|
||||
presetsLayout->addSpacing(12);
|
||||
|
||||
auto *zoomMaxLabel = new QLabel(QStringLiteral("MAX ZOOM"));
|
||||
zoomMaxLabel->setStyleSheet(zoomSensLabel->styleSheet());
|
||||
presetsLayout->addWidget(zoomMaxLabel);
|
||||
|
||||
m_zoomMaxSlider = new QSlider(Qt::Horizontal);
|
||||
m_zoomMaxSlider->setRange(10, 500);
|
||||
m_zoomMaxSlider->setValue(200);
|
||||
m_zoomMaxSlider->setStyleSheet(sliderStyle);
|
||||
|
||||
m_zoomMaxValue = new QLabel(QStringLiteral("2.00x"));
|
||||
m_zoomMaxValue->setStyleSheet(valueLabelStyle);
|
||||
m_zoomMaxValue->setAlignment(Qt::AlignCenter);
|
||||
|
||||
connect(m_zoomMaxSlider, &QSlider::valueChanged, this,
|
||||
[this](int value) {
|
||||
double maxZoom = value / 100.0;
|
||||
if (m_zoomMinSlider->value() >= value) {
|
||||
m_zoomMinSlider->setValue(value - 5);
|
||||
}
|
||||
m_view->setScaleRange(m_zoomMinSlider->value() / 100.0,
|
||||
maxZoom);
|
||||
m_zoomMaxValue->setText(
|
||||
QString::number(maxZoom, 'f', 2) + QStringLiteral("x"));
|
||||
scheduleSaveLayout();
|
||||
});
|
||||
|
||||
presetsLayout->addWidget(m_zoomMaxSlider);
|
||||
presetsLayout->addWidget(m_zoomMaxValue);
|
||||
presetsLayout->addStretch();
|
||||
|
||||
auto *metersTab = new QWidget();
|
||||
|
|
@ -504,9 +610,7 @@ void GraphEditorWidget::onRefreshTimer() {
|
|||
}
|
||||
|
||||
void GraphEditorWidget::scheduleSaveLayout() {
|
||||
if (!m_saveTimer->isActive()) {
|
||||
m_saveTimer->start();
|
||||
}
|
||||
m_saveTimer->start();
|
||||
}
|
||||
|
||||
GraphEditorWidget::~GraphEditorWidget() {
|
||||
|
|
@ -1130,6 +1234,9 @@ void GraphEditorWidget::saveLayoutWithViewState() {
|
|||
vs.splitterGraph = sizes.value(0, 1200);
|
||||
vs.splitterSidebar = sizes.value(1, 320);
|
||||
vs.connectionStyle = static_cast<int>(m_connectionStyle);
|
||||
vs.zoomSensitivity = m_view->zoomSensitivity();
|
||||
vs.zoomMin = m_zoomMinSlider->value() / 100.0;
|
||||
vs.zoomMax = m_zoomMaxSlider->value() / 100.0;
|
||||
vs.valid = true;
|
||||
m_model->saveLayout(m_layoutPath, vs);
|
||||
}
|
||||
|
|
@ -1145,6 +1252,17 @@ void GraphEditorWidget::restoreViewState() {
|
|||
if (vs.connectionStyle == static_cast<int>(ConnectionStyleType::kSquare)) {
|
||||
setConnectionStyle(ConnectionStyleType::kSquare);
|
||||
}
|
||||
if (vs.zoomSensitivity > 0.0) {
|
||||
m_view->setZoomSensitivity(vs.zoomSensitivity);
|
||||
int sliderVal = static_cast<int>((vs.zoomSensitivity - 1.0) * 100.0);
|
||||
m_zoomSensSlider->setValue(sliderVal);
|
||||
}
|
||||
if (vs.zoomMin > 0.0) {
|
||||
m_zoomMinSlider->setValue(static_cast<int>(vs.zoomMin * 100.0));
|
||||
}
|
||||
if (vs.zoomMax > 0.0) {
|
||||
m_zoomMaxSlider->setValue(static_cast<int>(vs.zoomMax * 100.0));
|
||||
}
|
||||
} else {
|
||||
m_view->zoomFitAll();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue