Save/load settings for the new tool

This commit is contained in:
Vadim Kuznetsov 2022-09-25 15:36:16 +03:00
parent b72649f552
commit 6f6f7f0b90
2 changed files with 69 additions and 1 deletions

View File

@ -24,12 +24,64 @@
#include <QApplication>
#include "qucspowercombiningtool.h"
struct tQucsSettings QucsSettings;
// #########################################################################
// Loads the settings file and stores the settings.
bool loadSettings()
{
QSettings settings("qucs","qucs_s");
settings.beginGroup("QucsPowercombining");
if(settings.contains("x"))QucsSettings.x=settings.value("x").toInt();
if(settings.contains("y"))QucsSettings.y=settings.value("y").toInt();
settings.endGroup();
if(settings.contains("Language"))QucsSettings.Language=settings.value("Language").toString();
if(settings.contains("DefaultSimulator"))
QucsSettings.DefaultSimulator = settings.value("DefaultSimulator").toInt();
else QucsSettings.DefaultSimulator = spicecompat::simNotSpecified;
return true;
}
// #########################################################################
// Saves the settings in the settings file.
bool saveApplSettings(QucsPowerCombiningTool *qucs)
{
QSettings settings ("qucs","qucs_s");
settings.beginGroup("QucsPowercombining");
settings.setValue("x", qucs->x());
settings.setValue("y", qucs->y());
settings.endGroup();
return true;
}
int main(int argc, char *argv[])
{
// apply default settings
QucsSettings.x = 200;
QucsSettings.y = 100;
QApplication app(argc, argv);
loadSettings();
QTranslator tor( 0 );
QString lang = QucsSettings.Language;
if(lang.isEmpty())
lang = QString(QLocale::system().name());
tor.load( QString("qucs_") + lang, QucsSettings.LangDir);
app.installTranslator( &tor );
QucsPowerCombiningTool *PowerCombiningTool = new QucsPowerCombiningTool();
PowerCombiningTool->raise();
PowerCombiningTool->resize(350, 350);
PowerCombiningTool->move(QucsSettings.x, QucsSettings.y);
PowerCombiningTool->show();
return app.exec();
int result = app.exec();
saveApplSettings(PowerCombiningTool);
return result;
}

View File

@ -27,6 +27,22 @@
#include <QtSvg>
#include <QDebug>
#include <QDesktopWidget>
namespace spicecompat {
enum Simulator {simNgspice = 0, simXyceSer = 1, simXycePar = 2, simSpiceOpus = 3, simQucsator = 4, simNotSpecified=10};
}
struct tQucsSettings {
int x, y; // position of main window
QFont font;
QString LangDir;
QString Language;
int DefaultSimulator;
};
extern struct tQucsSettings QucsSettings;
struct tSubstrate {
double er;
double height;