mirror of
https://github.com/ra3xdh/qucs_s
synced 2025-03-28 21:13:26 +00:00
Save/load settings for the new tool
This commit is contained in:
parent
b72649f552
commit
6f6f7f0b90
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user