From: mar77i Date: Mon, 22 Apr 2024 00:30:11 +0000 (+0200) Subject: compress output files, and use an extension other than .json X-Git-Url: https://git.mar77i.info/?a=commitdiff_plain;h=2e1cd064794fdc23d63fe329c6d76cd8b97bc2b0;p=bigintmandel compress output files, and use an extension other than .json --- diff --git a/bigintwidget.cpp b/bigintwidget.cpp index 30c7ff2..916c141 100644 --- a/bigintwidget.cpp +++ b/bigintwidget.cpp @@ -24,13 +24,13 @@ static inline QMenuBar *setup_menu_bar(BigintWidget *parent) { menu->addAction("&Load"), &QAction::triggered, parent, - &BigintWidget::load_json + &BigintWidget::load_data ); QObject::connect( menu->addAction("&Save"), &QAction::triggered, parent, - &BigintWidget::save_json + &BigintWidget::save_data ); menu->addSeparator(); QObject::connect( @@ -202,20 +202,20 @@ void BigintWidget::settings_widget_accepted() { update_img(); } -void BigintWidget::load_json() { +void BigintWidget::load_data() { QString file_name = QFileDialog::getOpenFileName( - this, "Load JSON", "", "JSON Documents (*.json)" + this, "Load Data", "", "BigintMandel Data (*.bim)" ); if (!file_name.isEmpty()) { - settings.load_json(file_name); + settings.load_data(file_name); update_img(); } } -void BigintWidget::save_json() { +void BigintWidget::save_data() { QString file_name = QFileDialog::getSaveFileName( - this, "Save JSON", "", "JSON Documents (*.json)" + this, "Save Data", "", "BigintMandel Data (*.bim)" ); if (!file_name.isEmpty()) - settings.save_json(file_name); + settings.save_data(file_name); } diff --git a/bigintwidget.h b/bigintwidget.h index 705be18..327c92c 100644 --- a/bigintwidget.h +++ b/bigintwidget.h @@ -43,8 +43,8 @@ public Q_SLOT: void settings_widget_accepted(); void finished_cell(int num); void finished(); - void load_json(); - void save_json(); + void load_data(); + void save_data(); }; #endif // BIGINTWIDGET_H diff --git a/mandel.cpp b/mandel.cpp index f68b5ff..cdeae91 100644 --- a/mandel.cpp +++ b/mandel.cpp @@ -108,11 +108,12 @@ void MandelSettings::zoom(const QSize size, const QPoint pos) { } void MandelSettings::finished_cell(int num, const MandelResultCell &result) { - size_t iter = result.get_iter(); cells[num].set_result(result); if (!img) return; img->setPixelColor(cells[num].get_pos(), cells[num].get_color()); + return; + (void)colors; } void MandelSettings::save_img(QString file_name) { @@ -137,7 +138,7 @@ void MandelSettings::reset(size_t max_iter, const QSize size) { setup_cells(cells, ¶ms); } -void MandelSettings::load_json(QString file_name) { +void MandelSettings::load_data(QString file_name) { QFile file(file_name); QJsonObject json; QJsonArray json_array; @@ -146,7 +147,7 @@ void MandelSettings::load_json(QString file_name) { qWarning("Couldn't open save file."); return; } - json = QJsonDocument::fromJson(file.readAll()).object(); + json = QJsonDocument::fromJson(qUncompress(file.readAll())).object(); params = MandelParams::from_json(json["params"].toObject()); json_array = json["cells"].toArray(); cells.resize(json_array.size(), MandelCell(¶ms)); @@ -156,7 +157,7 @@ void MandelSettings::load_json(QString file_name) { file.close(); } -void MandelSettings::save_json(QString file_name) { +void MandelSettings::save_data(QString file_name) { QVector::iterator i; QFile file(file_name); QJsonObject json; @@ -169,7 +170,7 @@ void MandelSettings::save_json(QString file_name) { qWarning("Couldn't open save file."); return; } - file.write(QJsonDocument(json).toJson()); + file.write(qCompress(QJsonDocument(json).toJson(), 9)); file.close(); } diff --git a/mandel.h b/mandel.h index dba45e3..8910f97 100644 --- a/mandel.h +++ b/mandel.h @@ -74,8 +74,8 @@ public: void finished_cell(int num, const MandelResultCell &cell); void save_img(QString file_name); void reset(size_t max_iter, QSize size); - void load_json(QString file_name); - void save_json(QString file_name); + void load_data(QString file_name); + void save_data(QString file_name); }; extern QVector colors;