Mercurial > trustbridge
annotate ui/administrator.cpp @ 1065:5cf648c233d2
Note that quoted quotes are unhandled instead of FIXME
We do not plan to fix that. Not supporting those is acceptable.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 10 Sep 2014 11:52:55 +0200 |
parents | f638eb1f3b0f |
children | 1e429faf7c84 |
rev | line source |
---|---|
404 | 1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU GPL (v>=2) | |
5 * and comes with ABSOLUTELY NO WARRANTY! | |
6 * See LICENSE.txt for details. | |
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 |
1059
f638eb1f3b0f
(issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
876
diff
changeset
|
43 bool g_debug = false; |
f638eb1f3b0f
(issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
876
diff
changeset
|
44 QtMessageHandler g_default_msg_handler = NULL; |
f638eb1f3b0f
(issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
876
diff
changeset
|
45 |
f638eb1f3b0f
(issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
876
diff
changeset
|
46 void noDebugOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) |
f638eb1f3b0f
(issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
876
diff
changeset
|
47 { |
f638eb1f3b0f
(issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
876
diff
changeset
|
48 if (type == QtDebugMsg) { |
f638eb1f3b0f
(issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
876
diff
changeset
|
49 return; |
f638eb1f3b0f
(issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
876
diff
changeset
|
50 } |
f638eb1f3b0f
(issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
876
diff
changeset
|
51 |
f638eb1f3b0f
(issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
876
diff
changeset
|
52 if (g_default_msg_handler) { |
f638eb1f3b0f
(issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
876
diff
changeset
|
53 (*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
|
54 } |
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 |
333
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
57 int main(int argc, char **argv) |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
58 { |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
59 QApplication app (argc, argv); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
60 |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
61 QStringList arguments = QApplication::arguments(); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
62 |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
63 QApplication::setOrganizationName(QString::fromLatin1(ORGANIZATION)); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
64 QApplication::setApplicationName(QString::fromLatin1(APPNAME)); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
65 QApplication::setApplicationVersion(QString::fromLatin1(VERSION)); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
66 QSettings::setDefaultFormat(QSettings::IniFormat); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
67 |
829
294d76174102
(issue5) Add --version to trustbridge and trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
520
diff
changeset
|
68 if (QApplication::arguments().contains("--version")) { |
294d76174102
(issue5) Add --version to trustbridge and trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
520
diff
changeset
|
69 printf (APPNAME " Version: %s \n", |
294d76174102
(issue5) Add --version to trustbridge and trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
520
diff
changeset
|
70 QApplication::applicationVersion().toLocal8Bit().constData()); |
294d76174102
(issue5) Add --version to trustbridge and trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
520
diff
changeset
|
71 printf (COPYRIGHT); |
294d76174102
(issue5) Add --version to trustbridge and trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
520
diff
changeset
|
72 return 0; |
294d76174102
(issue5) Add --version to trustbridge and trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
520
diff
changeset
|
73 } |
294d76174102
(issue5) Add --version to trustbridge and trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
520
diff
changeset
|
74 |
1059
f638eb1f3b0f
(issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
876
diff
changeset
|
75 if (arguments.contains("--debug")) { |
f638eb1f3b0f
(issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
876
diff
changeset
|
76 g_debug = true; |
f638eb1f3b0f
(issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
876
diff
changeset
|
77 } else { |
f638eb1f3b0f
(issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
876
diff
changeset
|
78 g_debug = false; |
f638eb1f3b0f
(issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
876
diff
changeset
|
79 g_default_msg_handler = qInstallMessageHandler(noDebugOutput); |
f638eb1f3b0f
(issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
876
diff
changeset
|
80 } |
f638eb1f3b0f
(issue46) Add debug option for trustbridge-admin
Andre Heinecke <andre.heinecke@intevation.de>
parents:
876
diff
changeset
|
81 |
420
16b6d5686835
Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents:
409
diff
changeset
|
82 QTranslator translator; |
16b6d5686835
Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents:
409
diff
changeset
|
83 if (QLocale::system().name() == "C") { |
16b6d5686835
Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents:
409
diff
changeset
|
84 /* 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
|
85 translator.load(":/l10n/administrator_de_DE"); |
16b6d5686835
Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents:
409
diff
changeset
|
86 } else { |
16b6d5686835
Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents:
409
diff
changeset
|
87 translator.load(":/l10n/administrator_" + QLocale::system().name()); |
16b6d5686835
Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents:
409
diff
changeset
|
88 qDebug() << "Loading translations for: " << "administrator_" + |
16b6d5686835
Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents:
409
diff
changeset
|
89 QLocale::system().name(); |
16b6d5686835
Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents:
409
diff
changeset
|
90 } |
16b6d5686835
Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents:
409
diff
changeset
|
91 app.installTranslator(&translator); |
16b6d5686835
Switch to resource based loading of translations
Andre Heinecke <aheinecke@intevation.de>
parents:
409
diff
changeset
|
92 |
832
170b13ea05ee
(Issue10) Force encoding to be latin-1 during installer creation.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
829
diff
changeset
|
93 /* 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
|
94 * 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
|
95 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
|
96 |
876
0051cb07da28
Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
832
diff
changeset
|
97 /* Install static fonts */ |
0051cb07da28
Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
832
diff
changeset
|
98 |
0051cb07da28
Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
832
diff
changeset
|
99 /* 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
|
100 * 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
|
101 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
|
102 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
|
103 if (fontId != -1) |
0051cb07da28
Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
832
diff
changeset
|
104 { |
0051cb07da28
Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
832
diff
changeset
|
105 QFont font("DejaVuSans"); |
0051cb07da28
Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
832
diff
changeset
|
106 font.setPointSize(9); |
0051cb07da28
Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
832
diff
changeset
|
107 app.setFont(font); |
0051cb07da28
Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
832
diff
changeset
|
108 } |
0051cb07da28
Reduce libraries, document i386 build and statically link fonts.
Andre Heinecke <andre.heinecke@intevation.de>
parents:
832
diff
changeset
|
109 |
333
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
110 AdministratorWindow adminWin; |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
111 adminWin.show(); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
112 |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
113 return app.exec(); |
de94c4ec22b1
Renamed management to administrator application.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
114 } |