Mercurial > trustbridge
comparison ui/main.cpp @ 876:0051cb07da28
Reduce libraries, document i386 build and statically link fonts.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Thu, 07 Aug 2014 19:12:37 +0200 |
parents | 4efd6378c001 |
children | 59fc7ececa5f |
comparison
equal
deleted
inserted
replaced
875:a43ebf716abd | 876:0051cb07da28 |
---|---|
7 */ | 7 */ |
8 #include "mainwindow.h" | 8 #include "mainwindow.h" |
9 #include "processhelp.h" | 9 #include "processhelp.h" |
10 #include "logging.h" | 10 #include "logging.h" |
11 #include "selftest.h" | 11 #include "selftest.h" |
12 #include "util.h" | |
12 #ifdef WIN32 | 13 #ifdef WIN32 |
13 #include "taskscheduler.h" | 14 #include "taskscheduler.h" |
14 #endif | 15 #endif |
15 | 16 |
16 #include <QApplication> | 17 #include <QApplication> |
20 #include <QSettings> | 21 #include <QSettings> |
21 #include <QDebug> | 22 #include <QDebug> |
22 #include <QTranslator> | 23 #include <QTranslator> |
23 | 24 |
24 #include <QStyleFactory> | 25 #include <QStyleFactory> |
26 #include <QFontDatabase> | |
25 | 27 |
26 #ifndef VERSION | 28 #ifndef VERSION |
27 #define VERSION "0.0.1" | 29 #define VERSION "0.0.1" |
28 #endif | 30 #endif |
29 | 31 |
68 QApplication::setApplicationVersion(QString::fromLatin1(VERSION)); | 70 QApplication::setApplicationVersion(QString::fromLatin1(VERSION)); |
69 QSettings::setDefaultFormat(QSettings::IniFormat); | 71 QSettings::setDefaultFormat(QSettings::IniFormat); |
70 | 72 |
71 qDebug() << "Application style is: " << app.style()->metaObject()->className(); | 73 qDebug() << "Application style is: " << app.style()->metaObject()->className(); |
72 qDebug() << "Available styles: " << QStyleFactory::keys().join(", "); | 74 qDebug() << "Available styles: " << QStyleFactory::keys().join(", "); |
75 qDebug() << "Font is: " << app.font(); | |
73 | 76 |
74 QStringList arguments = QApplication::arguments(); | 77 QStringList arguments = QApplication::arguments(); |
75 bool trayMode = arguments.contains("--tray"); | 78 bool trayMode = arguments.contains("--tray"); |
76 | 79 |
77 if (arguments.contains("--version")) { | 80 if (arguments.contains("--version")) { |
127 QFile startup_file (settings.fileName().replace(APPNAME ".ini", STARTUP_FILE_NAME)); | 130 QFile startup_file (settings.fileName().replace(APPNAME ".ini", STARTUP_FILE_NAME)); |
128 startup_file.open(QIODevice::WriteOnly); | 131 startup_file.open(QIODevice::WriteOnly); |
129 startup_file.write(QString::fromLatin1("DISPLAY=%1\n").arg(qgetenv("DISPLAY").constData()).toUtf8()); | 132 startup_file.write(QString::fromLatin1("DISPLAY=%1\n").arg(qgetenv("DISPLAY").constData()).toUtf8()); |
130 startup_file.close(); | 133 startup_file.close(); |
131 #endif | 134 #endif |
135 | |
136 /* Install static fonts */ | |
137 | |
138 /* The putenv here works around a bug in qt. Qt thinks it is a fatal | |
139 * error if the font directory does not exist. */ | |
140 qputenv("QT_QPA_FONTDIR", get_install_dir()); | |
141 int fontId = QFontDatabase::addApplicationFont(":/fonts/DejaVuSans.ttf"); | |
142 if (fontId != -1) | |
143 { | |
144 QFont font("DejaVuSans"); | |
145 font.setPointSize(9); | |
146 app.setFont(font); | |
147 } | |
148 | |
132 MainWindow mainWin(trayMode); | 149 MainWindow mainWin(trayMode); |
133 | 150 |
134 return app.exec(); | 151 return app.exec(); |
135 } | 152 } |