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/editrc"));
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 ==
"EditWindow") {
55 QucsSettings.
x = Line.section(
",",0,0).toInt();
56 QucsSettings.
y = Line.section(
",",1,1).toInt();
57 QucsSettings.
dx = Line.section(
",",2,2).toInt();
58 QucsSettings.
dy = Line.section(
",",3,3).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")
88 if(qucs->x() == QucsSettings.
x)
89 if(qucs->y() == QucsSettings.
y)
90 if(qucs->width() == QucsSettings.
dx)
91 if(qucs->height() == QucsSettings.
dy)
95 QFile file(QDir::homeDirPath()+QDir::convertSeparators (
"/.qucs/editrc"));
96 if(!file.open(IO_WriteOnly)) {
97 QMessageBox::warning(0, QObject::tr(
"Warning"),
98 QObject::tr(
"Cannot save settings !"));
103 QTextStream stream(&file);
105 stream <<
"Settings file, Qucs Editor " PACKAGE_VERSION
"\n"
106 <<
"EditWindow=" << qucs->x() <<
',' << qucs->y() <<
','
107 << qucs->width() <<
',' << qucs->height() <<
'\n';
116 fprintf(stdout, QObject::tr(
"Qucs Editor Version ")+PACKAGE_VERSION+
117 QObject::tr(
"\nVery simple text editor for Qucs\n")+
118 QObject::tr(
"Copyright (C) 2004, 2005 by Michael Margraf\n")+
119 QObject::tr(
"\nUsage: qucsedit [-r] file\n")+
120 QObject::tr(
" -h display this help and exit\n")+
121 QObject::tr(
" -r open file read-only\n"));
131 int main(
int argc,
char *argv[])
134 QucsSettings.
x = 200;
135 QucsSettings.
y = 100;
136 QucsSettings.
dx = 400;
137 QucsSettings.
dy = 400;
138 QucsSettings.
font = QFont(
"Helvetica", 12);
141 char * var = getenv (
"QUCSDIR");
143 QDir QucsDir = QDir (var);
144 QString QucsDirStr = QucsDir.canonicalPath ();
146 QDir::convertSeparators (QucsDirStr +
"/share/qucs/bitmaps/");
148 QDir::convertSeparators (QucsDirStr +
"/share/qucs/lang/");
151 QucsSettings.
LangDir = LANGUAGEDIR;
156 QApplication a(argc, argv);
157 a.setFont(QucsSettings.
font);
159 QTranslator tor( 0 );
160 QString lang = QucsSettings.
Language;
162 lang = QTextCodec::locale();
163 tor.load( QString(
"qucs_") + lang, QucsSettings.
LangDir);
164 a.installTranslator( &tor );
166 bool readOnly =
false;
168 for(
int i=1;
i<argc;
i++) {
171 if(s.length() != 2) {
172 fprintf(stdout, QObject::tr(
"Too long command line argument!\n\n"));
176 switch(s.at(1).latin1()) {
177 case 'r': readOnly =
true;
182 fprintf(stderr, QObject::tr(
"Wrong command line argument!\n\n"));
187 else if(FileName.isEmpty()) FileName = s;
189 fprintf(stderr, QObject::tr(
"Only one filename allowed!\n\n"));
196 a.setMainWidget(qucs);
197 qucs->resize(QucsSettings.
dx, QucsSettings.
dy);
198 qucs->move(QucsSettings.
x, QucsSettings.
y);
200 int result = a.exec();