48
52
#include <windows.h>
55
static bool showDebug = false;
52
58
static void ipeDebugImpl(const char *msg)
54
60
OutputDebugStringA(msg);
57
static void ipeDebugImpl(const char *)
63
static void ipeDebugImpl(const char *msg)
66
fprintf(stderr, "%s\n", msg);
63
70
// used from appui.cpp
64
71
void StartManual(QString url)
66
//HelpWindow *manual = HelpWindow::Static(url);
69
74
ShellExecute(0, "open", url.local8Bit(), 0, 0, 0);
75
#elif defined(IPE_KDE)
76
KApplication::kApplication()->invokeBrowser(url);
71
78
QString browser = IpePreferences::Static()->iBrowser;
72
79
QString s = browser + " " + url;
84
int saveKeys(int argc, char **argv, const char *fname)
86
QApplication a(argc, argv);
87
AppUi *appui = new AppUi;
88
appui->SaveKeys(QString::fromLocal8Bit(fname));
94
static const KCmdLineOptions options[] = {
95
{ "debug", "Display debug information on stderr.", 0 },
96
{ "sheet <stylesheet>", "Add style sheet to all newly created documents.",
98
{ "!geom <WxH+X+Y>", "Set geometry of main window.", 0 },
99
{ "+[file]", "Load document from file.", 0 },
100
KCmdLineLastOption // End of options.
77
105
static void usage()
79
fprintf(stderr, "Usage:\n ipe [ Qt options ] [-geom wxh+x+y] [-sheet stylesheet][ filename ]\n");
108
"Usage:\n ipe [ Qt options ] [-debug] [-geom wxh+x+y] "
109
"[-sheet stylesheet][ filename ]\n");
83
115
// The main function just starts the QApplication
84
116
int main(int argc, char *argv[])
97
129
// set ipeDebug handler
98
130
ipeDebugHandler = ipeDebugImpl;
132
if (argc == 3 && !qstrcmp(argv[1], "-savekeys"))
133
return saveKeys(argc, argv, argv[2]);
137
KCmdLineArgs::init(argc, argv, "ipe", "Ipe",
138
"Ipe drawing editor", IPE_VERSION);
139
KCmdLineArgs::addCmdLineOptions(options);
140
KApplication::addCmdLineOptions();
100
145
if (argc >= 2 && (!qstrcmp(argv[1], "-help") ||
101
146
!qstrcmp(argv[1], "--help")))
104
149
QApplication a( argc, argv );
106
153
// must create QApplication before first call to IpePreferences::Static.
107
154
IpePreferences *prefs = IpePreferences::Static();
109
156
QApplication::setFont(prefs->iFont, true);
111
158
QString lang = IpePreferences::Static()->iLanguage;
112
IPEDBG << "Current locale is " << QTextCodec::locale() << "\n";
113
IPEDBG << "Current directory is " << QDir::current().path() << "\n";
159
ipeDebug("Current locale is '%s'", QTextCodec::locale());
160
ipeDebug("Current directory is '%s'", QDir::current().path().latin1());
115
162
QTranslator qt(0);
116
163
QTranslator qt1(0);
117
if (lang != QString::null) {
164
if (!lang.isNull()) {
118
165
if (qt.load("ipe-" + lang, prefs->iLangDir))
119
166
a.installTranslator(&qt);
120
167
if (qt1.load("keys-" + lang, prefs->iLangDir))
124
171
QTranslator qt2(0);
125
172
if (qt2.load(prefs->iKeysFileName)) {
126
IPEDBG << "Loaded personal key definitions\n";
173
qDebug("Loaded personal key definitions from '%s'",
174
prefs->iKeysFileName.latin1());
127
175
a.installTranslator(&qt2);
131
178
bool geom = false;
184
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
186
QCString sheet = args->getOption("sheet");
187
if (!sheet.isEmpty())
188
prefs->iStyleSheet2 = sheet.data();
190
QCString geoms = args->getOption("geom");
191
if (!geoms.isEmpty() &&
192
sscanf(geoms.data(), "%dx%d+%d+%d", &w, &h, &x, &y) == 4) {
194
ipeDebug("Geometry: %dx%d at (%d,%d)", w, h, x, y);
198
if (args->count() > 0)
201
args->clear(); // Free up some memory.
133
206
if (a.argc() >= i+2 && !qstrcmp(a.argv()[i], "-geom")) {
134
207
if (sscanf(a.argv()[i+1], "%dx%d+%d+%d", &w, &h, &x, &y) == 4)
136
IPEDBG << "Geometry: " << w << " x " << h
137
<< " at (" << x << "," << y << ")\n";
209
ipeDebug("Geometry: %dx%d at (%d,%d)", w, h, x, y);
140
212
if (a.argc() >= i+2 && !qstrcmp(a.argv()[i], "-sheet")) {
141
213
prefs->iStyleSheet2 = a.argv()[i+1];
145
if (a.argc() > i + 1)
216
if (a.argc() >= i+1 && !qstrcmp(a.argv()[i], "-debug")) {
220
if (a.argc() == i + 1) {
222
} else if (a.argc() > i + 1)
148
227
AppUi *appui = new AppUi;
150
if (a.argc() != i+1 || !appui->Load(a.argv()[i]))
229
if (load.isEmpty() || !appui->Load(load))
153
232
if (prefs->iMaximize) {