annotate src/main.cpp @ 13:06c9b37d1e1b

Fix static windows build of qtxtcsvmodel copy
author Andre Heinecke <andre.heinecke@intevation.de>
date Tue, 14 Apr 2015 13:43:43 +0200
parents e3c8f61e45a9
children 64a51a42c01f
rev   line source
0
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2014 by Intevation GmbH
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
2 *
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
3 * This file is Free Software under the GNU GPL (v>=2)
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
4 * and comes with ABSOLUTELY NO WARRANTY!
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
5 * See LICENSE.txt for details.
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
6 */
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
7
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
8 /** @file Main entry point for the application.
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
9 *
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
10 * This file is the wrapper around the qt application.
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
11 * Does command line parsing and preparation of the QApplication.
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
12 */
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
13 #include "constants.h"
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
14
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
15 #include "mainwindow.h"
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
16
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
17 #include "strhelp.h"
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
18 #include "util.h"
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
19
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
20 #include <QApplication>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
21 #include <QCommandLineParser>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
22 #include <QtPlugin>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
23 #include <QDebug>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
24 #include <QTranslator>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
25 #include <QSettings>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
26 #include <QFontDatabase>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
27 #include <QSplashScreen>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
28 #include <QTimer>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
29
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
30 #ifdef Q_OS_WIN
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
31
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
32 #include <windows.h>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
33 #include <shlobj.h>
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
34
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
35 Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
36 #else
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
37 /* this is only necessary if we build statically for GNU/Linux */
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
38 // Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
39 #endif
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
40
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
41 #ifdef IS_TAG_BUILD
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
42 bool g_debug = false;
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
43 #else
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
44 bool g_debug = true;
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
45 #endif
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
46
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
47 QtMessageHandler g_default_msg_handler = NULL;
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
48
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
49 void filterDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
50 {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
51 if (!g_debug && type == QtDebugMsg) {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
52 return;
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
53 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
54
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
55 if (g_default_msg_handler) {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
56 (*g_default_msg_handler)(type, context, msg);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
57 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
58 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
59
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
60 int realMain(int argc, char **argv);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
61
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
62 #if defined(WIN32) && defined(UNICODE)
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
63
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
64 /** @brief Unicode entry point.
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
65 *
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
66 * Converts arguments to UTF-8 and executes the real
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
67 * entry point realMain.
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
68 */
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
69 int wmain(int argc, wchar_t **argv, wchar_t **envp)
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
70 {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
71 char **utf8args = NULL;
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
72
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
73 utf8args = (char**) xmalloc0 ((argc + 1) * sizeof(char*));
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
74
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
75 for (int i = 0; i < argc; i++) {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
76 utf8args[i] = wchar_to_utf8(argv[i], wcslen(argv[i]));
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
77 if (utf8args[i] == NULL) {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
78 printf ("Fatal: could not convert arguments to UTF-8.\n");
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
79 exit(-1);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
80 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
81 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
82 int ret = realMain(argc, utf8args);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
83 strv_free(utf8args);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
84
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
85 return ret;
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
86 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
87 #else
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
88 int main(int argc, char **argv)
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
89 {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
90 return realMain(argc, argv);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
91 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
92 #endif
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
93
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
94 /** @brief The real entry point to the application.
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
95 *
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
96 * @param [in] argc the count of the arguments.
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
97 * @param [in] argv On GNU/Linux this function expects argv to be in the
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
98 * native system encoding. On Windows the arguments
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
99 * shall be UTF-8
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
100 *
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
101 * @returns 0 on success an error code otherwise. */
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
102 int realMain(int argc, char **argv)
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
103 {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
104 /* QApplication setup */
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
105 QApplication app (argc, argv);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
106 QApplication::setQuitOnLastWindowClosed(true);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
107 QApplication::setOrganizationName(QString::fromLatin1(ORGANIZATION));
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
108 QApplication::setApplicationName(QString::fromLatin1(APPNAME));
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
109 QApplication::setApplicationVersion(QString::fromLatin1(VERSION));
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
110 QSettings::setDefaultFormat(QSettings::IniFormat);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
111
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
112 /* Setup translations */
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
113 QTranslator translator;
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
114 if (QLocale::system().name() == "C") {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
115 /* Useful for testing / development as the primary target is german */
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
116 translator.load(":/l10n/main_de_DE");
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
117 } else {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
118 translator.load(":/l10n/main_" + QLocale::system().name());
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
119 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
120 app.installTranslator(&translator);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
121
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
122 /* Install static fonts */
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
123
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
124 /* The putenv here works around a bug in qt (#29192). Qt thinks it is a fatal
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
125 * error if the font directory does not exist. Will be fixed in Qt 5.4 */
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
126 char * inst_dir = get_install_dir();
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
127 if (inst_dir) {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
128 qputenv("QT_QPA_FONTDIR", inst_dir);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
129 xfree(inst_dir);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
130 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
131 int fontId = QFontDatabase::addApplicationFont(":/fonts/DejaVuSans.ttf");
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
132 if (fontId != -1)
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
133 {
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
134 QFont font("DejaVuSans");
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
135 font.setPointSize(9);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
136 app.setFont(font);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
137 }
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
138
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
139 /* Parse the command line */
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
140 QCommandLineParser parser;
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
141 parser.setApplicationDescription(QObject::tr(DESCRIPTION) + "\n" +
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
142 QObject::tr(COPYRIGHT));
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
143 parser.addHelpOption();
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
144
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
145 parser.addPositionalArgument("folder", QCoreApplication::translate("main", "The folder containing the data to replay."));
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
146 QCommandLineOption debugOpt(QStringList() << "debug",
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
147 QCoreApplication::translate("main", "Print debug output."));
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
148 parser.addOption(debugOpt);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
149
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
150 parser.process(app);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
151
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
152 #ifdef IS_TAG_BUILD
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
153 g_debug = parser.isSet(debugOpt);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
154 #else
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
155 g_debug = true;
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
156 #endif
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
157 g_default_msg_handler = qInstallMessageHandler(filterDebugOutput);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
158
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
159
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
160 /* Initialize the main window */
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
161 MainWindow mainWin;
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
162
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
163 const QStringList args = parser.positionalArguments();
9
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
164 if (args.size() > 1) {
0
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
165 parser.showHelp(1);
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
166 }
9
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
167 if (args.size() == 1) {
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
168 mainWin.setFolder(args.first());
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
169 } else {
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
170 mainWin.showWithFolderSelect();
e3c8f61e45a9 Implement folderselection dialogs
Andre Heinecke <andre.heinecke@intevation.de>
parents: 0
diff changeset
171 }
0
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
172
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
173 return app.exec(); /* Go event loop */
147b08bc7d64 Initial commit of a basic Application framework.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
174 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)