version 2.20

icon change
EDockWidget improvements
EMainWindow small refactoring
Graphic now remember last loaded graphics style and restore it on setGraphicsCount
This commit is contained in:
2023-08-23 16:33:43 +03:00
parent ca6bcd4944
commit b77648aae9
12 changed files with 319 additions and 182 deletions

View File

@@ -1252,24 +1252,31 @@ void Graphic::setCurrentGraphic(int arg) {
}
void Graphic::setGraphicsCount(int arg, bool update) {
if (arg < 0) return;
while (graphics.size() < arg) {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
graphics.append(
GraphicType(tr("y(x)"),
QColor::fromHsv((graphics.size() * 55) % 360, 255, 255 - QRandomGenerator::global()->generate() % 115)));
# define _G_QRAND_ QRandomGenerator::global()->generate()
#else
graphics.append(GraphicType(tr("y(x)"), QColor::fromHsv((graphics.size() * 55) % 360, 255, 255 - qrand() % 115)));
# define _G_QRAND_ qrand()
#endif
void Graphic::setGraphicsCount(int count, bool update) {
if (count < 0) return;
while (graphics.size() < count) {
GraphicType gt(tr("y(x)"));
if (loaded_configs.size() > graphics.size())
gt = loaded_configs[graphics.size()];
else
gt.pen.setColor(QColor::fromHsv((graphics.size() * 55) % 360, 255, 255 - _G_QRAND_ % 115));
graphics.append(gt);
}
while (graphics.size() > arg) {
while (graphics.size() > count) {
delete graphics.back().pb;
graphics.pop_back();
}
if (update) updateLegend();
}
#undef _G_QRAND_
void Graphic::removeGraphic(int arg, bool update) {
if (arg < 0 || arg >= graphics.size()) return;
@@ -2309,6 +2316,10 @@ void Graphic::on_graphic_buttonConfigure_clicked() {
setGridEnabled(conf->ui->groupGrid->isChecked());
updateLegend();
repaintCanvas();
for (int i = 0; i < qMin<int>(graphics.size(), loaded_configs.size()); ++i) {
loaded_configs[i] = graphics[i];
loaded_configs[i].removeData();
}
}
@@ -2702,6 +2713,9 @@ void Graphic::load(QByteArray ba) {
setLegendVisible(a);
} break;
}
loaded_configs = graphics;
for (auto & i: loaded_configs)
i.removeData();
if (has_opengl != isOGL) setOpenGL(has_opengl);
updateLegend();
repaintCanvas(true);