comparison src/main.cpp @ 52:263880612637

Set input file and handle windows encoding correctly.
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 19 Jul 2016 17:45:10 +0200
parents 36ee5dd46fd3
children 82d38421fdf3
comparison
equal deleted inserted replaced
51:e9cc707838d1 52:263880612637
21 #include <QApplication> 21 #include <QApplication>
22 #include <QCommandLineParser> 22 #include <QCommandLineParser>
23 #include <QtPlugin> 23 #include <QtPlugin>
24 #include <QDebug> 24 #include <QDebug>
25 #include <QTranslator> 25 #include <QTranslator>
26 #include <QTextCodec>
26 #include <QSettings> 27 #include <QSettings>
27 #include <QTimer> 28 #include <QTimer>
28 29
29 #ifdef Q_OS_WIN 30 #ifdef Q_OS_WIN
30 31
101 /* QApplication setup */ 102 /* QApplication setup */
102 QApplication app (argc, argv); 103 QApplication app (argc, argv);
103 QApplication::setOrganizationName(QStringLiteral(APPNAME)); 104 QApplication::setOrganizationName(QStringLiteral(APPNAME));
104 QApplication::setApplicationName(QStringLiteral(APPNAME)); 105 QApplication::setApplicationName(QStringLiteral(APPNAME));
105 QApplication::setApplicationVersion(QStringLiteral(VERSION)); 106 QApplication::setApplicationVersion(QStringLiteral(VERSION));
106 // QSettings::setDefaultFormat(QSettings::IniFormat); 107 QSettings::setDefaultFormat(QSettings::IniFormat);
107 108
108 /* Setup translations */ 109 /* Setup translations */
109 QTranslator translator; 110 QTranslator translator;
110 if (QLocale::system().name() == "C") { 111 if (QLocale::system().name() == "C") {
111 /* Useful for testing / development as the primary target is german */ 112 /* Useful for testing / development as the primary target is german */
117 118
118 /* Parse the command line */ 119 /* Parse the command line */
119 QCommandLineParser parser; 120 QCommandLineParser parser;
120 cconvert_options(parser); 121 cconvert_options(parser);
121 122
123 #ifdef Q_OS_WIN
124 auto oldCodec = QTextCodec::codecForLocale();
125 QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
126 #endif
122 parser.process(app); 127 parser.process(app);
128 #ifdef Q_OS_WIN
129 QTextCodec::setCodecForLocale(oldCodec);
130 #endif
123 131
124 g_debug = parser.isSet("debug"); 132 g_debug = parser.isSet("debug");
125 g_default_msg_handler = qInstallMessageHandler(filterDebugOutput); 133 g_default_msg_handler = qInstallMessageHandler(filterDebugOutput);
126 134
127 135
139 const QStringList outputs = parser.values("output"); 147 const QStringList outputs = parser.values("output");
140 const QString title = parser.value("title"); 148 const QString title = parser.value("title");
141 if (outputs.isEmpty() || title.isEmpty()) { 149 if (outputs.isEmpty() || title.isEmpty()) {
142 mainWin = new MainWindow(); 150 mainWin = new MainWindow();
143 mainWin->setTitle(title); 151 mainWin->setTitle(title);
152 mainWin->setInputFile(infile);
144 mainWin->show(); 153 mainWin->show();
145 app.exec(); 154 app.exec();
146 delete mainWin; 155 delete mainWin;
147 } else { 156 } else {
148 Converter conv(infile, parser.values("output"), 157 Converter conv(infile, parser.values("output"),
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)