2018-11-25 23:53:04 +00:00
|
|
|
#include <QFontDatabase>
|
2018-10-21 02:17:21 +00:00
|
|
|
#include <QGuiApplication>
|
2018-02-28 09:10:42 +00:00
|
|
|
#include <QNetworkProxy>
|
2018-07-09 02:45:26 +00:00
|
|
|
#include <QQmlApplicationEngine>
|
2018-03-02 08:56:36 +00:00
|
|
|
#include <QQmlContext>
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-09-09 02:12:45 +00:00
|
|
|
#include "accountlistmodel.h"
|
2018-07-13 04:06:27 +00:00
|
|
|
#include "controller.h"
|
2018-08-17 04:55:57 +00:00
|
|
|
#include "emojimodel.h"
|
2018-07-13 04:06:27 +00:00
|
|
|
#include "imageprovider.h"
|
|
|
|
#include "messageeventmodel.h"
|
2018-07-09 02:45:26 +00:00
|
|
|
#include "room.h"
|
2018-07-17 06:14:48 +00:00
|
|
|
#include "roomlistmodel.h"
|
2018-10-01 08:07:48 +00:00
|
|
|
#include "spectralroom.h"
|
2018-10-22 13:08:24 +00:00
|
|
|
#include "spectraluser.h"
|
2018-08-26 05:17:12 +00:00
|
|
|
#include "userlistmodel.h"
|
2018-03-02 08:56:36 +00:00
|
|
|
|
2018-08-01 12:26:29 +00:00
|
|
|
#include "csapi/joining.h"
|
2018-07-30 14:42:27 +00:00
|
|
|
#include "csapi/leaving.h"
|
|
|
|
|
2018-10-18 11:53:54 +00:00
|
|
|
#include "qqmlsortfilterproxymodel.h"
|
|
|
|
|
2018-02-23 14:39:14 +00:00
|
|
|
using namespace QMatrixClient;
|
|
|
|
|
2018-07-09 02:45:26 +00:00
|
|
|
int main(int argc, char *argv[]) {
|
2018-11-18 12:08:01 +00:00
|
|
|
#if defined(Q_OS_LINUX) || defined(Q_OS_WIN) || defined(Q_OS_FREEBSD)
|
|
|
|
if (qgetenv("QT_SCALE_FACTOR").size() == 0) {
|
|
|
|
QSettings settings("ENCOM", "Spectral");
|
|
|
|
float factor = settings.value("Interface/dpi", 100).toFloat() / 100;
|
|
|
|
|
|
|
|
qDebug() << "DPI:" << factor;
|
|
|
|
|
|
|
|
if (factor != -1)
|
|
|
|
qputenv("QT_SCALE_FACTOR", QString::number(factor).toUtf8());
|
|
|
|
}
|
2018-11-17 14:39:34 +00:00
|
|
|
#endif
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-07-19 08:04:09 +00:00
|
|
|
QApplication app(argc, argv);
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-08-24 13:43:03 +00:00
|
|
|
app.setOrganizationName("ENCOM");
|
|
|
|
app.setOrganizationDomain("encom.eu.org");
|
2018-09-17 13:01:02 +00:00
|
|
|
app.setApplicationName("Spectral");
|
2018-10-19 05:11:13 +00:00
|
|
|
app.setWindowIcon(QIcon(":/assets/img/icon.png"));
|
2018-08-24 13:43:03 +00:00
|
|
|
|
2018-10-18 11:53:54 +00:00
|
|
|
qmlRegisterType<qqsfpm::QQmlSortFilterProxyModel>("SortFilterProxyModel", 0,
|
|
|
|
2, "SortFilterProxyModel");
|
2018-09-17 13:01:02 +00:00
|
|
|
qmlRegisterType<Controller>("Spectral", 0, 1, "Controller");
|
|
|
|
qmlRegisterType<AccountListModel>("Spectral", 0, 1, "AccountListModel");
|
|
|
|
qmlRegisterType<RoomListModel>("Spectral", 0, 1, "RoomListModel");
|
|
|
|
qmlRegisterType<UserListModel>("Spectral", 0, 1, "UserListModel");
|
|
|
|
qmlRegisterType<MessageEventModel>("Spectral", 0, 1, "MessageEventModel");
|
|
|
|
qmlRegisterType<EmojiModel>("Spectral", 0, 1, "EmojiModel");
|
|
|
|
qmlRegisterUncreatableType<RoomMessageEvent>("Spectral", 0, 1,
|
2018-08-17 04:55:57 +00:00
|
|
|
"RoomMessageEvent", "ENUM");
|
2018-09-17 13:01:02 +00:00
|
|
|
qmlRegisterUncreatableType<RoomType>("Spectral", 0, 1, "RoomType", "ENUM");
|
2018-10-01 08:07:48 +00:00
|
|
|
|
2018-10-13 10:54:33 +00:00
|
|
|
qRegisterMetaType<User *>("User*");
|
2018-10-19 14:02:12 +00:00
|
|
|
qRegisterMetaType<Room *>("Room*");
|
2018-10-13 10:54:33 +00:00
|
|
|
qRegisterMetaType<MessageEventType>("MessageEventType");
|
2018-10-19 14:02:12 +00:00
|
|
|
qRegisterMetaType<SpectralRoom *>("SpectralRoom*");
|
2018-11-02 07:08:01 +00:00
|
|
|
qRegisterMetaType<SpectralUser *>("SpectralUser*");
|
2018-10-13 10:54:33 +00:00
|
|
|
|
2018-11-25 23:53:04 +00:00
|
|
|
#if defined(BUNDLE_FONT)
|
|
|
|
QFontDatabase::addApplicationFont(":/assets/font/roboto.ttf");
|
|
|
|
QFontDatabase::addApplicationFont(":/assets/font/twemoji.ttf");
|
|
|
|
#endif
|
|
|
|
|
2018-07-09 02:45:26 +00:00
|
|
|
QQmlApplicationEngine engine;
|
2018-03-02 08:56:36 +00:00
|
|
|
|
2018-10-01 08:07:48 +00:00
|
|
|
engine.addImportPath("qrc:/imports");
|
2018-07-09 02:45:26 +00:00
|
|
|
ImageProvider *m_provider = new ImageProvider();
|
2018-09-07 05:50:06 +00:00
|
|
|
engine.rootContext()->setContextProperty("imageProvider", m_provider);
|
2018-07-09 02:45:26 +00:00
|
|
|
engine.addImageProvider(QLatin1String("mxc"), m_provider);
|
2018-07-07 11:06:13 +00:00
|
|
|
|
2018-07-09 02:45:26 +00:00
|
|
|
engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
|
|
|
|
if (engine.rootObjects().isEmpty()) return -1;
|
2018-02-23 14:39:14 +00:00
|
|
|
|
2018-07-09 02:45:26 +00:00
|
|
|
return app.exec();
|
2018-02-23 14:39:14 +00:00
|
|
|
}
|