src/{exdeath,main}: smarter versioning.

main
Síle Ekaterin Liszka 2022-08-09 20:07:42 -07:00
parent 9399655662
commit 07ab5e363b
2 changed files with 22 additions and 3 deletions

View File

@ -26,6 +26,7 @@
*/ */
#include <QApplication> #include <QApplication>
#include <QTextStream>
#include "exdeath.hh" #include "exdeath.hh"
@ -268,8 +269,20 @@ void Exdeath::initPreview(void) {
void Exdeath::initConfig(void) { void Exdeath::initConfig(void) {
QString version = QApplication::applicationVersion(); QString version = QApplication::applicationVersion();
QStringList parts = version.split(".");
if (parts.length() > 2) {
parts.removeLast();
version = parts.join(".");
}
QString cfgVersion = _cfg->value("main/version").toString();
parts = cfgVersion.split(".");
if (parts.length() > 2) {
parts.removeLast();
cfgVersion = parts.join(".");
}
// don't load config from old versions. // don't load config from old versions.
if (!version.compare(_cfg->value("main/version", version).toString())) { if (version.compare(cfgVersion) != 0) {
out << "doesn't match!\n";
return; return;
} }
QString temp = _cfg->value("rom/filename", "").toString(); QString temp = _cfg->value("rom/filename", "").toString();
@ -335,7 +348,13 @@ void Exdeath::selMode_index(int idx) {
} }
void Exdeath::btnSave_clicked(bool trigger) { void Exdeath::btnSave_clicked(bool trigger) {
_cfg->setValue("main/version", QApplication::applicationVersion()); QString version = QApplication::applicationVersion();
QStringList parts = version.split(".");
if (parts.length() > 2) {
parts.removeLast();
version = parts.join(".");
}
_cfg->setValue("main/version", version);
_cfg->setValue("rom/filename", filename); _cfg->setValue("rom/filename", filename);
_cfg->setValue("main/mode", selMode->currentIndex()); _cfg->setValue("main/mode", selMode->currentIndex());
_cfg->setValue("main/ned", selNED->currentIndex()); _cfg->setValue("main/ned", selNED->currentIndex());

View File

@ -35,7 +35,7 @@ int main(int argc, char **argv) {
QApplication::setOrganizationDomain("aerdan.org"); QApplication::setOrganizationDomain("aerdan.org");
QApplication::setApplicationName("Exdeath"); QApplication::setApplicationName("Exdeath");
QApplication::setApplicationDisplayName("Exdeath"); QApplication::setApplicationDisplayName("Exdeath");
QApplication::setApplicationVersion("0.9.0"); QApplication::setApplicationVersion("0.9.1");
QSettings *cfg = new QSettings(); QSettings *cfg = new QSettings();
Exdeath *win = new Exdeath(cfg); Exdeath *win = new Exdeath(cfg);