2013-05-03 18:04:51 +00:00
|
|
|
/* qt-gui.cpp */
|
|
|
|
/* Qt UI implementation */
|
2011-09-20 19:40:34 +00:00
|
|
|
#include "dive.h"
|
|
|
|
#include "display.h"
|
2013-04-07 22:20:43 +00:00
|
|
|
#include "qt-ui/mainwindow.h"
|
2013-05-23 06:24:33 +00:00
|
|
|
#include "helpers.h"
|
2011-09-20 19:40:34 +00:00
|
|
|
|
2013-05-03 18:04:51 +00:00
|
|
|
#include <QApplication>
|
2013-05-10 16:24:06 +00:00
|
|
|
#include <QDesktopWidget>
|
2013-07-13 12:42:26 +00:00
|
|
|
#include <QNetworkProxy>
|
2013-10-09 05:25:02 +00:00
|
|
|
#include <QLibraryInfo>
|
2015-05-27 12:36:39 +00:00
|
|
|
|
2013-04-07 22:20:43 +00:00
|
|
|
|
2015-06-16 13:52:06 +00:00
|
|
|
#include "qt-gui.h"
|
2013-04-02 16:49:17 +00:00
|
|
|
|
2015-06-04 10:36:36 +00:00
|
|
|
#ifdef SUBSURFACE_MOBILE
|
2015-06-05 04:46:24 +00:00
|
|
|
#include <QQuickWindow>
|
|
|
|
#include <QQmlApplicationEngine>
|
2015-06-04 10:36:36 +00:00
|
|
|
#include "qt-mobile/qmlmanager.h"
|
|
|
|
#endif
|
|
|
|
|
2015-06-16 13:52:06 +00:00
|
|
|
static MainWindow *window = NULL;
|
2013-04-25 22:28:31 +00:00
|
|
|
|
2015-06-16 13:52:06 +00:00
|
|
|
void init_ui()
|
2014-03-19 16:23:43 +00:00
|
|
|
{
|
2015-06-16 13:52:06 +00:00
|
|
|
init_qt_late();
|
2013-10-10 19:26:03 +00:00
|
|
|
|
2013-09-18 15:27:24 +00:00
|
|
|
window = new MainWindow();
|
2013-09-09 08:59:03 +00:00
|
|
|
if (existing_filename && existing_filename[0] != '\0')
|
|
|
|
window->setTitle(MWTF_FILENAME);
|
|
|
|
else
|
|
|
|
window->setTitle(MWTF_DEFAULT);
|
2011-09-20 19:40:34 +00:00
|
|
|
}
|
|
|
|
|
2015-06-16 13:52:06 +00:00
|
|
|
void run_ui()
|
2011-09-20 19:40:34 +00:00
|
|
|
{
|
2015-05-27 12:36:39 +00:00
|
|
|
#ifdef SUBSURFACE_MOBILE
|
2015-06-03 14:19:01 +00:00
|
|
|
window->hide();
|
2015-06-04 10:36:36 +00:00
|
|
|
qmlRegisterType<QMLManager>("org.subsurfacedivelog.mobile", 1, 0, "QMLManager");
|
2015-05-27 12:36:39 +00:00
|
|
|
QQmlApplicationEngine engine;
|
|
|
|
engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml")));
|
|
|
|
QObject *mainWindow = engine.rootObjects().value(0);
|
|
|
|
QQuickWindow *qml_window = qobject_cast<QQuickWindow *>(mainWindow);
|
|
|
|
qml_window->show();
|
|
|
|
#else
|
2014-03-11 21:11:34 +00:00
|
|
|
window->show();
|
2015-05-27 12:36:39 +00:00
|
|
|
#endif
|
2015-06-16 13:52:06 +00:00
|
|
|
qApp->exec();
|
2011-09-20 19:40:34 +00:00
|
|
|
}
|
|
|
|
|
2015-06-16 13:52:06 +00:00
|
|
|
void exit_ui()
|
2012-05-02 17:03:48 +00:00
|
|
|
{
|
2013-09-18 15:27:24 +00:00
|
|
|
delete window;
|
2015-06-16 13:52:06 +00:00
|
|
|
delete qApp;
|
2014-05-12 17:58:15 +00:00
|
|
|
free((void *)existing_filename);
|
2014-12-18 18:47:00 +00:00
|
|
|
free((void *)default_dive_computer_vendor);
|
|
|
|
free((void *)default_dive_computer_product);
|
2014-05-12 17:58:15 +00:00
|
|
|
free((void *)default_dive_computer_device);
|
2012-05-02 17:03:48 +00:00
|
|
|
}
|
|
|
|
|
2013-05-10 16:24:06 +00:00
|
|
|
double get_screen_dpi()
|
|
|
|
{
|
2015-06-16 13:52:06 +00:00
|
|
|
QDesktopWidget *mydesk = qApp->desktop();
|
2013-05-10 16:24:06 +00:00
|
|
|
return mydesk->physicalDpiX();
|
|
|
|
}
|
2013-05-23 06:24:33 +00:00
|
|
|
|
2013-05-30 21:26:08 +00:00
|
|
|
|