annotate src/main.cpp @ 92:7204024777b4

Add info plist template for file extension
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 06 Oct 2016 17:05:14 +0200
parents 82d38421fdf3
children
rev   line source
3
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2016 by ETH Zürich
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
3 *
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=2)
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY!
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
6 * See LICENSE.txt for details.
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
7 */
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
8
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
9 /** @file Main entry point for the application.
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
10 *
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
11 * This file is the wrapper around the qt application.
23
927794e3cc52 Add HTML output and some pdf support
Andre Heinecke <andre.heinecke@intevation.de>
parents: 15
diff changeset
12 * Does command line parsing and preparation of the QApplication.
3
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
13 */
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
14 #include "constants.h"
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
15
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
16 #include "strhelp.h"
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
17 #include "converter.h"
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
18 #include "cconvert_options.h"
50
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
19 #include "mainwindow.h"
3
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
20
23
927794e3cc52 Add HTML output and some pdf support
Andre Heinecke <andre.heinecke@intevation.de>
parents: 15
diff changeset
21 #include <QApplication>
3
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
22 #include <QCommandLineParser>
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
23 #include <QtPlugin>
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
24 #include <QDebug>
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
25 #include <QTranslator>
52
263880612637 Set input file and handle windows encoding correctly.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 50
diff changeset
26 #include <QTextCodec>
3
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
27 #include <QSettings>
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
28 #include <QTimer>
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
29
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
30 #ifdef Q_OS_WIN
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
31
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
32 #include <windows.h>
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
33 #include <shlobj.h>
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
34
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
35 Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
36 #elif defined(Q_OS_MAC)
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
37 Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin)
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
38 #else
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
39 /* this is only necessary if we build statically for GNU/Linux */
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
40 // Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
41 #endif
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
42
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
43 bool g_debug = false;
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
44
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
45 QtMessageHandler g_default_msg_handler = NULL;
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
46
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
47 void filterDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
48 {
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
49 if (!g_debug && type == QtDebugMsg) {
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
50 return;
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
51 }
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
52
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
53 if (g_default_msg_handler) {
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
54 (*g_default_msg_handler)(type, context, msg);
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
55 }
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
56 }
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
57
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
58 int realMain(int argc, char **argv);
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
59
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
60 #if defined(WIN32) && defined(UNICODE)
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
61
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
62 /** @brief Unicode entry point.
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
63 *
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
64 * Converts arguments to UTF-8 and executes the real
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
65 * entry point realMain.
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
66 */
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
67 int wmain(int argc, wchar_t **argv, wchar_t **envp)
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
68 {
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
69 char **utf8args = NULL;
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
70
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
71 utf8args = (char**) xmalloc0 ((argc + 1) * sizeof(char*));
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
72
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
73 for (int i = 0; i < argc; i++) {
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
74 utf8args[i] = wchar_to_utf8(argv[i], wcslen(argv[i]));
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
75 if (utf8args[i] == NULL) {
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
76 printf ("Fatal: could not convert arguments to UTF-8.\n");
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
77 exit(-1);
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
78 }
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
79 }
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
80 int ret = realMain(argc, utf8args);
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
81 strv_free(utf8args);
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
82
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
83 return ret;
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
84 }
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
85 #else
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
86 int main(int argc, char **argv)
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
87 {
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
88 return realMain(argc, argv);
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
89 }
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
90 #endif
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
91
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
92 /** @brief The real entry point to the application.
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
93 *
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
94 * @param [in] argc the count of the arguments.
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
95 * @param [in] argv On GNU/Linux this function expects argv to be in the
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
96 * native system encoding. On Windows the arguments
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
97 * shall be UTF-8
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
98 *
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
99 * @returns 0 on success an error code otherwise. */
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
100 int realMain(int argc, char **argv)
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
101 {
23
927794e3cc52 Add HTML output and some pdf support
Andre Heinecke <andre.heinecke@intevation.de>
parents: 15
diff changeset
102 /* QApplication setup */
927794e3cc52 Add HTML output and some pdf support
Andre Heinecke <andre.heinecke@intevation.de>
parents: 15
diff changeset
103 QApplication app (argc, argv);
927794e3cc52 Add HTML output and some pdf support
Andre Heinecke <andre.heinecke@intevation.de>
parents: 15
diff changeset
104 QApplication::setOrganizationName(QStringLiteral(APPNAME));
927794e3cc52 Add HTML output and some pdf support
Andre Heinecke <andre.heinecke@intevation.de>
parents: 15
diff changeset
105 QApplication::setApplicationName(QStringLiteral(APPNAME));
927794e3cc52 Add HTML output and some pdf support
Andre Heinecke <andre.heinecke@intevation.de>
parents: 15
diff changeset
106 QApplication::setApplicationVersion(QStringLiteral(VERSION));
52
263880612637 Set input file and handle windows encoding correctly.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 50
diff changeset
107 QSettings::setDefaultFormat(QSettings::IniFormat);
3
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
108
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
109 /* Setup translations */
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
110 QTranslator translator;
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
111 if (QLocale::system().name() == "C") {
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
112 /* Useful for testing / development as the primary target is german */
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
113 translator.load(":/l10n/main_de_DE");
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
114 } else {
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
115 translator.load(":/l10n/main_" + QLocale::system().name());
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
116 }
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
117 app.installTranslator(&translator);
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
118
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
119 /* Parse the command line */
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
120 QCommandLineParser parser;
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
121 cconvert_options(parser);
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
122
52
263880612637 Set input file and handle windows encoding correctly.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 50
diff changeset
123 #ifdef Q_OS_WIN
263880612637 Set input file and handle windows encoding correctly.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 50
diff changeset
124 auto oldCodec = QTextCodec::codecForLocale();
263880612637 Set input file and handle windows encoding correctly.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 50
diff changeset
125 QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
263880612637 Set input file and handle windows encoding correctly.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 50
diff changeset
126 #endif
3
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
127 parser.process(app);
52
263880612637 Set input file and handle windows encoding correctly.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 50
diff changeset
128 #ifdef Q_OS_WIN
263880612637 Set input file and handle windows encoding correctly.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 50
diff changeset
129 QTextCodec::setCodecForLocale(oldCodec);
263880612637 Set input file and handle windows encoding correctly.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 50
diff changeset
130 #endif
3
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
131
4
5c256892042c Always silence debug output by default
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
132 g_debug = parser.isSet("debug");
3
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
133 g_default_msg_handler = qInstallMessageHandler(filterDebugOutput);
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
134
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
135
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
136 const QStringList args = parser.positionalArguments();
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
137 if (args.size() > 1) {
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
138 parser.showHelp(1);
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
139 }
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
140
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
141 QString infile;
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
142 if (args.size()) {
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
143 infile = args.first();
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
144 }
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
145
50
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
146 MainWindow *mainWin = Q_NULLPTR;
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
147 const QStringList outputs = parser.values("output");
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
148 const QString title = parser.value("title");
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
149 if (outputs.isEmpty() || title.isEmpty()) {
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
150 mainWin = new MainWindow();
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
151 mainWin->setTitle(title);
60
82d38421fdf3 Fix file name defaults and xlsx extension
Andre Heinecke <andre.heinecke@intevation.de>
parents: 52
diff changeset
152 if (!infile.isEmpty()) {
82d38421fdf3 Fix file name defaults and xlsx extension
Andre Heinecke <andre.heinecke@intevation.de>
parents: 52
diff changeset
153 mainWin->setInputFile(infile);
82d38421fdf3 Fix file name defaults and xlsx extension
Andre Heinecke <andre.heinecke@intevation.de>
parents: 52
diff changeset
154 }
50
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
155 mainWin->show();
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
156 app.exec();
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
157 delete mainWin;
3
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
158 } else {
50
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
159 Converter conv(infile, parser.values("output"),
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
160 parser.value("title"));
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
161
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
162 conv.start();
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
163 conv.wait();
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
164 const QStringList errors = conv.errors();
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
165 if (!errors.isEmpty()) {
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
166 Q_FOREACH (const QString err, errors) {
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
167 qCritical() << err;
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
168 }
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
169 return 1;
3
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
170 }
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
171 }
50
36ee5dd46fd3 Add GUI
Andre Heinecke <andre.heinecke@intevation.de>
parents: 38
diff changeset
172 return 0;
3
8b4c49c92451 Add initial implementation that handles choices
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
173 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)