24 #include <qapplication.h>
26 #include <qtextcodec.h>
27 #include <qtranslator.h>
29 #include <qtextstream.h>
30 #include <qmessagebox.h>
45 QFile file(QDir::homeDirPath()+QDir::convertSeparators (
"/.qucs/transrc"));
46 if(!file.open(IO_ReadOnly))
49 QTextStream stream(&file);
50 QString
Line, Setting;
51 while(!stream.atEnd()) {
52 Line = stream.readLine();
53 Setting = Line.section(
'=',0,0);
54 Line = Line.section(
'=',1,1);
55 if(Setting ==
"Mode") {
56 QucsSettings.
Mode = Line.simplifyWhiteSpace();
58 else if(Setting ==
"Frequency") {
59 Line = Line.simplifyWhiteSpace();
62 else if(Setting ==
"Length") {
63 Line = Line.simplifyWhiteSpace();
66 else if(Setting ==
"Resistance") {
67 Line = Line.simplifyWhiteSpace();
70 else if(Setting ==
"Angle") {
71 Line = Line.simplifyWhiteSpace();
74 else if(Setting ==
"TransWindow") {
75 QucsSettings.
x = Line.section(
",",0,0).toInt();
76 QucsSettings.
y = Line.section(
",",1,1).toInt();
77 QucsSettings.
dx = Line.section(
",",2,2).toInt();
78 QucsSettings.
dy = Line.section(
",",3,3).toInt();
85 file.setName(QDir::homeDirPath()+QDir::convertSeparators (
"/.qucs/qucsrc"));
86 if(!file.open(IO_ReadOnly))
89 QTextStream stream(&file);
90 QString
Line, Setting;
91 while(!stream.atEnd()) {
92 Line = stream.readLine();
93 Setting = Line.section(
'=',0,0);
94 Line = Line.section(
'=',1,1).stripWhiteSpace();
96 QucsSettings.
font.fromString(Line);
97 else if(Setting ==
"Language")
108 QFile file(QDir::homeDirPath()+QDir::convertSeparators (
"/.qucs/transrc"));
109 if(!file.open(IO_WriteOnly)) {
110 QMessageBox::warning(0, QObject::tr(
"Warning"),
111 QObject::tr(
"Cannot save settings !"));
116 QTextStream stream(&file);
118 stream <<
"Settings file, QucsTranscalc " PACKAGE_VERSION
"\n"
119 <<
"Mode=" << qucs->
getMode() <<
"\n"
124 <<
"TransWindow=" << qucs->x() <<
',' << qucs->y() <<
','
125 << qucs->width() <<
',' << qucs->height() <<
'\n';
138 int main(
int argc,
char *argv[])
141 QucsSettings.
x = 100;
143 QucsSettings.
dx = 540;
144 QucsSettings.
dy = 400;
145 QucsSettings.
font = QFont(
"Helvetica", 12);
152 char * var = getenv (
"QUCSDIR");
154 QDir QucsDir = QDir (var);
155 QString QucsDirStr = QucsDir.canonicalPath ();
157 QDir::convertSeparators (QucsDirStr +
"/share/qucs/bitmaps/");
159 QDir::convertSeparators (QucsDirStr +
"/share/qucs/lang/");
162 QucsSettings.
LangDir = LANGUAGEDIR;
164 QucsWorkDir.setPath (QDir::homeDirPath()+QDir::convertSeparators (
"/.qucs"));
167 QApplication a(argc, argv);
168 a.setFont(QucsSettings.
font);
170 QTranslator tor( 0 );
171 QString lang = QucsSettings.
Language;
173 lang = QTextCodec::locale();
174 tor.load( QString(
"qucs_") + lang, QucsSettings.
LangDir);
175 a.installTranslator( &tor );
178 a.setMainWidget(qucs);
179 qucs->resize(QucsSettings.
dx, QucsSettings.
dy);
180 qucs->move(QucsSettings.
x, QucsSettings.
y);
183 qucs->
loadFile(QDir::homeDirPath()+
"/.qucs/transrc");
189 QString
File = argv[1];
193 int result = a.exec();