Add image saving to SVG format

This allows to create images independent from screen resolution
Replaced copy-pasted screenshot code with the single implementation
This commit is contained in:
alexey.lysiuk 2025-11-12 15:14:37 +02:00
parent bbd1bce0b8
commit 56dbec82d4
14 changed files with 96 additions and 62 deletions

View file

@ -9,6 +9,7 @@
#include "preferences.h"
#include "appwindow.h"
#include "ui_XYPlotConstantLineEditDialog.h"
#include "screenshot.h"
#include <QGridLayout>
#include <cmath>
@ -349,17 +350,7 @@ void TraceXYPlot::updateContextMenu()
auto image = new QAction("Save image...", contextmenu);
contextmenu->addAction(image);
connect(image, &QAction::triggered, [=]() {
auto filename = QFileDialog::getSaveFileName(nullptr, "Save plot image", Preferences::getInstance().UISettings.Paths.image, "PNG image files (*.png)", nullptr, Preferences::QFileDialogOptions());
if(filename.isEmpty()) {
// aborted selection
return;
}
Preferences::getInstance().UISettings.Paths.image = QFileInfo(filename).path();
if(filename.endsWith(".png")) {
filename.chop(4);
}
filename += ".png";
grab().save(filename);
SaveScreenshot(this);
});
auto createMarker = contextmenu->addAction("Add marker here");