24 #include <qapplication.h>
26 #include <qtextcodec.h>
27 #include <qtranslator.h>
29 #include <qtextstream.h>
30 #include <qmessagebox.h>
44 QFile file(QDir::homeDirPath()+QDir::convertSeparators (
"/.qucs/librc"));
45 if(!file.open(IO_ReadOnly))
48 QTextStream stream(&file);
49 QString
Line, Setting;
50 while(!stream.atEnd()) {
51 Line = stream.readLine();
52 Setting = Line.section(
'=',0,0);
53 Line = Line.section(
'=',1,1);
54 if(Setting ==
"Position") {
55 QucsSettings.
x = Line.section(
",",0,0).toInt();
56 QucsSettings.
y = Line.section(
",",1,1).toInt(); }
57 else if(Setting ==
"Size") {
58 QucsSettings.
dx = Line.section(
",",0,0).toInt();
59 QucsSettings.
dy = Line.section(
",",1,1).toInt(); }
64 file.setName(QDir::homeDirPath()+QDir::convertSeparators (
"/.qucs/qucsrc"));
65 if(!file.open(IO_ReadOnly))
68 QTextStream stream(&file);
69 QString
Line, Setting;
70 while(!stream.atEnd()) {
71 Line = stream.readLine();
72 Setting = Line.section(
'=',0,0);
73 Line = Line.section(
'=',1,1).stripWhiteSpace();
75 QucsSettings.
font.fromString(Line);
76 else if(Setting ==
"Language")
87 QFile file(QDir::homeDirPath()+QDir::convertSeparators (
"/.qucs/librc"));
88 if(!file.open(IO_WriteOnly)) {
89 QMessageBox::warning(0, QObject::tr(
"Warning"),
90 QObject::tr(
"Cannot save settings !"));
95 QTextStream stream(&file);
97 stream <<
"Settings file, QucsLib " PACKAGE_VERSION
"\n"
98 <<
"Position=" << qucs->x() <<
"," << qucs->y() <<
"\n"
99 <<
"Size=" << qucs->width() <<
"," << qucs->height() <<
"\n";
111 int main(
int argc,
char *argv[])
114 QucsSettings.
x = 100;
116 QucsSettings.
dx = 600;
117 QucsSettings.
dy = 350;
118 QucsSettings.
font = QFont(
"Helvetica", 12);
121 char * var = getenv (
"QUCSDIR");
123 QDir QucsDir = QDir (var);
124 QString QucsDirStr = QucsDir.canonicalPath ();
126 QDir::convertSeparators (QucsDirStr +
"/share/qucs/bitmaps/");
128 QDir::convertSeparators (QucsDirStr +
"/share/qucs/lang/");
130 QDir::convertSeparators (QucsDirStr +
"/share/qucs/library/");
133 QucsSettings.
LangDir = LANGUAGEDIR;
134 QucsSettings.
LibDir = LIBRARYDIR;
136 UserLibDir.setPath (QDir::homeDirPath()+QDir::convertSeparators (
"/.qucs/user_lib"));
139 QApplication a(argc, argv);
140 a.setFont(QucsSettings.
font);
142 QTranslator tor( 0 );
143 QString lang = QucsSettings.
Language;
145 lang = QTextCodec::locale();
146 tor.load( QString(
"qucs_") + lang, QucsSettings.
LangDir);
147 a.installTranslator( &tor );
150 a.setMainWidget(qucs);
151 qucs->resize(QucsSettings.
dx, QucsSettings.
dy);
152 qucs->move(QucsSettings.
x, QucsSettings.
y);
155 int result = a.exec();