mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-27 03:29:16 +02:00
Fixed file open event handling on OS X
Installer files separation
This commit is contained in:
50
src/app.cpp
Normal file
50
src/app.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
#include <QtGlobal>
|
||||
#include <QTranslator>
|
||||
#include <QLocale>
|
||||
#include <QFileOpenEvent>
|
||||
#include "gui.h"
|
||||
#include "icons.h"
|
||||
#include "app.h"
|
||||
|
||||
|
||||
App::App(int &argc, char **argv) : QApplication(argc, argv),
|
||||
_argc(argc), _argv(argv)
|
||||
{
|
||||
_translator = new QTranslator();
|
||||
|
||||
QString locale = QLocale::system().name();
|
||||
_translator->load(QString(":/lang/gpxsee_") + locale);
|
||||
installTranslator(_translator);
|
||||
#ifdef Q_OS_MAC
|
||||
setAttribute(Qt::AA_DontShowIconsInMenus);
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
_gui = new GUI();
|
||||
}
|
||||
|
||||
App::~App()
|
||||
{
|
||||
delete _gui;
|
||||
delete _translator;
|
||||
}
|
||||
|
||||
void App::run()
|
||||
{
|
||||
_gui->setWindowIcon(QIcon(QPixmap(APP_ICON)));
|
||||
_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);
|
||||
}
|
28
src/app.h
Normal file
28
src/app.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef APP_H
|
||||
#define APP_H
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
class GUI;
|
||||
class QTranslator;
|
||||
|
||||
class App : QApplication
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
App(int &argc, char **argv);
|
||||
~App();
|
||||
void run();
|
||||
|
||||
protected:
|
||||
bool event(QEvent *event);
|
||||
|
||||
private:
|
||||
int &_argc;
|
||||
char **_argv;
|
||||
GUI *_gui;
|
||||
QTranslator *_translator;
|
||||
};
|
||||
|
||||
#endif // APP_H
|
@ -8,7 +8,7 @@
|
||||
|
||||
#define APP_NAME "GPXSee"
|
||||
#define APP_HOMEPAGE "http://tumic.wz.cz/gpxsee"
|
||||
#define APP_VERSION "2.12"
|
||||
#define APP_VERSION "2.13"
|
||||
|
||||
#define FONT_FAMILY "Arial"
|
||||
#define FONT_SIZE 12
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <QApplication>
|
||||
#include <QApplication>
|
||||
#include <QVBoxLayout>
|
||||
#include <QMenuBar>
|
||||
#include <QStatusBar>
|
||||
|
27
src/main.cpp
27
src/main.cpp
@ -1,28 +1,9 @@
|
||||
#include <QApplication>
|
||||
#include <QTranslator>
|
||||
#include <QLocale>
|
||||
#include "gui.h"
|
||||
#include "icons.h"
|
||||
|
||||
#include "app.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
App app(argc, argv);
|
||||
app.run();
|
||||
|
||||
QString locale = QLocale::system().name();
|
||||
QTranslator translator;
|
||||
translator.load(QString(":/lang/gpxsee_") + locale);
|
||||
app.installTranslator(&translator);
|
||||
#ifdef Q_OS_MAC
|
||||
app.setAttribute(Qt::AA_DontShowIconsInMenus);
|
||||
#endif // Q_OS_MAC
|
||||
|
||||
GUI gui;
|
||||
gui.setWindowIcon(QIcon(QPixmap(APP_ICON)));
|
||||
gui.show();
|
||||
|
||||
for (int i = 1; i < argc; i++)
|
||||
gui.openFile(QString::fromLocal8Bit(argv[i]));
|
||||
|
||||
return app.exec();
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user