annotate ui/administrator.cpp @ 1255:2a1aa9df8f11

(issue133) Improve API documentation
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 25 Sep 2014 17:58:12 +0200
parents 1e429faf7c84
children 12ed0b72e9f5
rev   line source
404
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 333
diff changeset
1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 333
diff changeset
2 * Software engineering by Intevation GmbH
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 333
diff changeset
3 *
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 333
diff changeset
4 * This file is Free Software under the GNU GPL (v>=2)
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 333
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY!
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 333
diff changeset
6 * See LICENSE.txt for details.
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 333
diff changeset
7 */
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
8 #include "administratorwindow.h"
876
0051cb07da28 Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 832
diff changeset
9 #include "util.h"
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
10
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11 #include <QApplication>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12 #include <QtPlugin>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13 #include <QMessageBox>
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14 #include <QSettings>
420
16b6d5686835 Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents: 409
diff changeset
15 #include <QTranslator>
16b6d5686835 Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents: 409
diff changeset
16 #include <QDebug>
832
170b13ea05ee (Issue10) Force encoding to be latin-1 during installer creation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 829
diff changeset
17 #include <QTextCodec>
876
0051cb07da28 Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 832
diff changeset
18 #include <QFontDatabase>
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
20 #ifndef VERSION
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
21 #define VERSION "0.0.1"
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
22 #endif
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
23
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
24 #ifndef APPNAME
520
09077eca0b0d Rename administrator to trustbridge-admin
Andre Heinecke <aheinecke@intevation.de>
parents: 431
diff changeset
25 #define APPNAME "trustbridge-admin"
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
26 #endif
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
27
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
28 #ifndef ORGANIZATION
409
09bb19e5e369 Remove m13 mentions and change test certificate to intevation.de
Andre Heinecke <aheinecke@intevation.de>
parents: 404
diff changeset
29 #define ORGANIZATION "BSI"
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
30 #endif
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
31
829
294d76174102 (issue5) Add --version to trustbridge and trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 520
diff changeset
32 #define COPYRIGHT "Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik \n" \
294d76174102 (issue5) Add --version to trustbridge and trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 520
diff changeset
33 "Software engineering by Intevation GmbH \n\n" \
294d76174102 (issue5) Add --version to trustbridge and trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 520
diff changeset
34 "This file is Free Software under the GNU GPL (v>=2)\n" \
294d76174102 (issue5) Add --version to trustbridge and trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 520
diff changeset
35 "and comes with ABSOLUTELY NO WARRANTY!\n"
294d76174102 (issue5) Add --version to trustbridge and trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 520
diff changeset
36
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
37 #ifdef Q_OS_WIN
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
38 Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
39 #else
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
40 Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
41 #endif
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42
1072
1e429faf7c84 (issue46) Default to debug output on if RELEASE_BUILD is not defined
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1059
diff changeset
43 #ifdef DO_RELEASE_BUILD
1059
f638eb1f3b0f (issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 876
diff changeset
44 bool g_debug = false;
1072
1e429faf7c84 (issue46) Default to debug output on if RELEASE_BUILD is not defined
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1059
diff changeset
45 #else
1e429faf7c84 (issue46) Default to debug output on if RELEASE_BUILD is not defined
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1059
diff changeset
46 bool g_debug = true;
1e429faf7c84 (issue46) Default to debug output on if RELEASE_BUILD is not defined
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1059
diff changeset
47 #endif
1e429faf7c84 (issue46) Default to debug output on if RELEASE_BUILD is not defined
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1059
diff changeset
48
1059
f638eb1f3b0f (issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 876
diff changeset
49 QtMessageHandler g_default_msg_handler = NULL;
f638eb1f3b0f (issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 876
diff changeset
50
1072
1e429faf7c84 (issue46) Default to debug output on if RELEASE_BUILD is not defined
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1059
diff changeset
51 void filterDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
1059
f638eb1f3b0f (issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 876
diff changeset
52 {
1072
1e429faf7c84 (issue46) Default to debug output on if RELEASE_BUILD is not defined
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1059
diff changeset
53 if (!g_debug && type == QtDebugMsg) {
1059
f638eb1f3b0f (issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 876
diff changeset
54 return;
f638eb1f3b0f (issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 876
diff changeset
55 }
f638eb1f3b0f (issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 876
diff changeset
56
f638eb1f3b0f (issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 876
diff changeset
57 if (g_default_msg_handler) {
f638eb1f3b0f (issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 876
diff changeset
58 (*g_default_msg_handler)(type, context, msg);
f638eb1f3b0f (issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 876
diff changeset
59 }
f638eb1f3b0f (issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 876
diff changeset
60 }
f638eb1f3b0f (issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 876
diff changeset
61
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
62 int main(int argc, char **argv)
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
63 {
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
64 QApplication app (argc, argv);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
65
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
66 QStringList arguments = QApplication::arguments();
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
67
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
68 QApplication::setOrganizationName(QString::fromLatin1(ORGANIZATION));
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
69 QApplication::setApplicationName(QString::fromLatin1(APPNAME));
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
70 QApplication::setApplicationVersion(QString::fromLatin1(VERSION));
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
71 QSettings::setDefaultFormat(QSettings::IniFormat);
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
72
829
294d76174102 (issue5) Add --version to trustbridge and trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 520
diff changeset
73 if (QApplication::arguments().contains("--version")) {
294d76174102 (issue5) Add --version to trustbridge and trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 520
diff changeset
74 printf (APPNAME " Version: %s \n",
294d76174102 (issue5) Add --version to trustbridge and trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 520
diff changeset
75 QApplication::applicationVersion().toLocal8Bit().constData());
294d76174102 (issue5) Add --version to trustbridge and trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 520
diff changeset
76 printf (COPYRIGHT);
294d76174102 (issue5) Add --version to trustbridge and trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 520
diff changeset
77 return 0;
294d76174102 (issue5) Add --version to trustbridge and trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 520
diff changeset
78 }
294d76174102 (issue5) Add --version to trustbridge and trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 520
diff changeset
79
1059
f638eb1f3b0f (issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 876
diff changeset
80 if (arguments.contains("--debug")) {
f638eb1f3b0f (issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 876
diff changeset
81 g_debug = true;
f638eb1f3b0f (issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 876
diff changeset
82 }
1072
1e429faf7c84 (issue46) Default to debug output on if RELEASE_BUILD is not defined
Andre Heinecke <andre.heinecke@intevation.de>
parents: 1059
diff changeset
83 g_default_msg_handler = qInstallMessageHandler(filterDebugOutput);
1059
f638eb1f3b0f (issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents: 876
diff changeset
84
420
16b6d5686835 Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents: 409
diff changeset
85 QTranslator translator;
16b6d5686835 Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents: 409
diff changeset
86 if (QLocale::system().name() == "C") {
16b6d5686835 Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents: 409
diff changeset
87 /* Useful for testing / development as the primary target is german */
16b6d5686835 Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents: 409
diff changeset
88 translator.load(":/l10n/administrator_de_DE");
16b6d5686835 Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents: 409
diff changeset
89 } else {
16b6d5686835 Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents: 409
diff changeset
90 translator.load(":/l10n/administrator_" + QLocale::system().name());
16b6d5686835 Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents: 409
diff changeset
91 qDebug() << "Loading translations for: " << "administrator_" +
16b6d5686835 Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents: 409
diff changeset
92 QLocale::system().name();
16b6d5686835 Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents: 409
diff changeset
93 }
16b6d5686835 Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents: 409
diff changeset
94 app.installTranslator(&translator);
16b6d5686835 Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents: 409
diff changeset
95
832
170b13ea05ee (Issue10) Force encoding to be latin-1 during installer creation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 829
diff changeset
96 /* Out of process calls need to be encoded in latin-1 so that they
170b13ea05ee (Issue10) Force encoding to be latin-1 during installer creation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 829
diff changeset
97 * look decent on western europe's windows */
170b13ea05ee (Issue10) Force encoding to be latin-1 during installer creation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 829
diff changeset
98 QTextCodec::setCodecForLocale(QTextCodec::codecForName ("ISO-8859-1"));
170b13ea05ee (Issue10) Force encoding to be latin-1 during installer creation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 829
diff changeset
99
876
0051cb07da28 Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 832
diff changeset
100 /* Install static fonts */
0051cb07da28 Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 832
diff changeset
101
0051cb07da28 Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 832
diff changeset
102 /* The putenv here works around a bug in qt. Qt thinks it is a fatal
0051cb07da28 Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 832
diff changeset
103 * error if the font directory does not exist. */
0051cb07da28 Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 832
diff changeset
104 qputenv("QT_QPA_FONTDIR", get_install_dir());
0051cb07da28 Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 832
diff changeset
105 int fontId = QFontDatabase::addApplicationFont(":/fonts/DejaVuSans.ttf");
0051cb07da28 Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 832
diff changeset
106 if (fontId != -1)
0051cb07da28 Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 832
diff changeset
107 {
0051cb07da28 Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 832
diff changeset
108 QFont font("DejaVuSans");
0051cb07da28 Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 832
diff changeset
109 font.setPointSize(9);
0051cb07da28 Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 832
diff changeset
110 app.setFont(font);
0051cb07da28 Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 832
diff changeset
111 }
0051cb07da28 Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 832
diff changeset
112
333
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
113 AdministratorWindow adminWin;
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
114 adminWin.show();
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
115
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
116 return app.exec();
de94c4ec22b1 Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
117 }

http://wald.intevation.org/projects/trustbridge/