removed some unused shit
[jrugr.git] / src / main.cpp
blob9ea5fb55976877c5c022d6b37746a9421392b000
1 ////////////////////////////////////////
2 // Copyright : GPL //
3 ////////////////////////////////////////
4 #include "jrugrdefs.h"
5 #include "jrugr.h"
6 #include "xkeyboard.h"
9 static void fixTextCodec () {
10 QTextCodec *kc;
11 #ifdef WIN32
12 kc = QTextCodec::codecForName("windows-1251");
13 if (!kc) return;
14 QTextCodec::setCodecForCStrings(kc);
15 QTextCodec::setCodecForLocale(kc);
16 #else
17 const char *ll = getenv("LANG");
18 if (!ll || !ll[0]) ll = getenv("LC_CTYPE");
19 if (ll && ll[0] && (strcasestr(ll, "utf-8") || strcasestr(ll, "utf8"))) return;
20 kc = QTextCodec::codecForName("koi8-r");
21 if (!kc) return;
22 QTextCodec::setCodecForCStrings(kc);
23 QTextCodec::setCodecForLocale(kc);
24 #endif
28 #ifdef DEBUG_OUTPUT
29 static bool debugOutput = true;
30 #else
31 static bool debugOutput = false;
32 #endif
34 static void myMessageOutput (QtMsgType type, const char *msg) {
35 if (debugOutput) {
36 switch (type) {
37 case QtDebugMsg: fprintf(stderr, "Debug: %s\n", msg); break;
38 case QtWarningMsg: fprintf(stderr, "Warning: %s\n", msg); break;
39 case QtCriticalMsg: fprintf(stderr, "Critical: %s\n", msg); break;
40 case QtFatalMsg: fprintf(stderr, "Fatal: %s\n", msg); abort();
42 } else {
43 if (type == QtFatalMsg) { fprintf(stderr, "Fatal: %s\n", msg); abort(); }
48 static void setDebugOutput (int argc, char *argv[]) {
49 qInstallMsgHandler(myMessageOutput);
51 for (int f = 1; f < argc; ++f) {
52 if (strcmp(argv[f], "-goobers") == 0) {
53 debugOutput = 1;
54 for (int c = f; c < argc; ++c) argv[c] = argv[c+1];
55 argv[--argc] = NULL;
56 --f;
62 int main (int argc, char *argv[]) {
63 setDebugOutput(argc, argv);
65 Jrugr a(argc, argv);
67 fixTextCodec();
69 QTranslator translator;
70 qDebug() << "Locale:" << QLocale::system().name();
71 QString lang = "jrugr_" + QLocale::system().name().split("_")[0];
72 qDebug()<<"Language:"<<lang;
76 QStringList l;
77 XKeyboard *k = new XKeyboard();
79 l.clear(); k->groupNames(l); qDebug() << l;
80 l.clear(); k->symbolNames(l); qDebug() << l;
81 delete k;
85 #if 0
86 QString langPath(JRUGR_TRANSLATION_PATH);
87 qDebug()<<"Language path (trying):"<<langPath;
88 if (!QFile::exists(langPath+"/"+lang+".qm")) langPath = QCoreApplication::applicationDirPath() + "/language/";
89 qDebug()<<"Language path (fallback):"<<langPath;
90 translator.load(lang, langPath);
91 a.installTranslator(&translator);
92 #else
93 QString langPath(QCoreApplication::applicationDirPath() + "/language/");
94 translator.load(lang, langPath);
95 a.installTranslator(&translator);
96 #endif
98 a.setStartup();
99 return a.exec();