2016-04-29 21:13:38 +02:00
|
|
|
#include <QtGlobal>
|
|
|
|
#include <QTranslator>
|
|
|
|
#include <QLocale>
|
|
|
|
#include <QFileOpenEvent>
|
2016-09-22 20:57:58 +02:00
|
|
|
#include <QNetworkProxyFactory>
|
2017-05-31 23:37:02 +02:00
|
|
|
#include <QLibraryInfo>
|
2016-12-20 00:11:30 +01:00
|
|
|
#include "opengl.h"
|
2016-04-29 21:13:38 +02:00
|
|
|
#include "gui.h"
|
2017-03-18 01:30:31 +01:00
|
|
|
#include "onlinemap.h"
|
|
|
|
#include "downloader.h"
|
2016-04-29 21:13:38 +02:00
|
|
|
#include "app.h"
|
|
|
|
|
|
|
|
|
|
|
|
App::App(int &argc, char **argv) : QApplication(argc, argv),
|
|
|
|
_argc(argc), _argv(argv)
|
|
|
|
{
|
2017-05-31 23:37:02 +02:00
|
|
|
QTranslator *gpxsee = new QTranslator(this);
|
2016-04-29 21:13:38 +02:00
|
|
|
QString locale = QLocale::system().name();
|
2017-05-31 23:37:02 +02:00
|
|
|
gpxsee->load(QString(":/lang/gpxsee_") + locale);
|
|
|
|
installTranslator(gpxsee);
|
|
|
|
|
|
|
|
QTranslator *qt = new QTranslator(this);
|
2017-06-18 16:06:59 +02:00
|
|
|
qt->load(QLocale::system(), "qt", "_", QLibraryInfo::location(
|
|
|
|
QLibraryInfo::TranslationsPath));
|
2017-05-31 23:37:02 +02:00
|
|
|
installTranslator(qt);
|
|
|
|
|
2016-04-29 21:13:38 +02:00
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
setAttribute(Qt::AA_DontShowIconsInMenus);
|
|
|
|
#endif // Q_OS_MAC
|
|
|
|
|
2016-09-22 20:57:58 +02:00
|
|
|
QNetworkProxyFactory::setUseSystemConfiguration(true);
|
2017-03-18 01:30:31 +01:00
|
|
|
OnlineMap::setDownloader(new Downloader(this));
|
2016-12-20 00:11:30 +01:00
|
|
|
OPENGL_SET_SAMPLES(4);
|
2016-12-06 01:48:26 +01:00
|
|
|
|
2016-04-29 21:13:38 +02:00
|
|
|
_gui = new GUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
App::~App()
|
|
|
|
{
|
|
|
|
delete _gui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void App::run()
|
|
|
|
{
|
|
|
|
_gui->show();
|
|
|
|
|
|
|
|
for (int i = 1; i < _argc; i++)
|
|
|
|
_gui->openFile(QString::fromLocal8Bit(_argv[i]));
|
|
|
|
|
|
|
|
exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool App::event(QEvent *event)
|
|
|
|
{
|
|
|
|
if (event->type() == QEvent::FileOpen) {
|
|
|
|
QFileOpenEvent *e = static_cast<QFileOpenEvent *>(event);
|
|
|
|
return _gui->openFile(e->file());
|
|
|
|
}
|
|
|
|
|
|
|
|
return QApplication::event(event);
|
|
|
|
}
|