#include #include #include #include #include #include #include "accountlistmodel.h" #include "controller.h" #include "emojimodel.h" #include "imageprovider.h" #include "messageeventmodel.h" #include "room.h" #include "roomlistmodel.h" #include "spectralroom.h" #include "spectraluser.h" #include "userlistmodel.h" #include "csapi/joining.h" #include "csapi/leaving.h" #include "qqmlsortfilterproxymodel.h" using namespace QMatrixClient; int main(int argc, char *argv[]) { #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()); } #endif QCoreApplication::setAttribute(Qt::AA_UseOpenGLES); QNetworkProxyFactory::setUseSystemConfiguration(true); QApplication app(argc, argv); app.setOrganizationName("ENCOM"); app.setOrganizationDomain("encom.eu.org"); app.setApplicationName("Spectral"); app.setWindowIcon(QIcon(":/assets/img/icon.png")); qmlRegisterType("SortFilterProxyModel", 0, 2, "SortFilterProxyModel"); qmlRegisterType("Spectral", 0, 1, "Controller"); qmlRegisterType("Spectral", 0, 1, "AccountListModel"); qmlRegisterType("Spectral", 0, 1, "RoomListModel"); qmlRegisterType("Spectral", 0, 1, "UserListModel"); qmlRegisterType("Spectral", 0, 1, "MessageEventModel"); qmlRegisterType("Spectral", 0, 1, "EmojiModel"); qmlRegisterUncreatableType("Spectral", 0, 1, "RoomMessageEvent", "ENUM"); qmlRegisterUncreatableType("Spectral", 0, 1, "RoomType", "ENUM"); qRegisterMetaType("User*"); qRegisterMetaType("Room*"); qRegisterMetaType("MessageEventType"); qRegisterMetaType("SpectralRoom*"); qRegisterMetaType("SpectralUser*"); #if defined(BUNDLE_FONT) QFontDatabase::addApplicationFont(":/assets/font/roboto.ttf"); QFontDatabase::addApplicationFont(":/assets/font/twemoji.ttf"); #endif QQmlApplicationEngine engine; engine.addImportPath("qrc:/imports"); ImageProvider *m_provider = new ImageProvider(); engine.rootContext()->setContextProperty("imageProvider", m_provider); engine.addImageProvider(QLatin1String("mxc"), m_provider); engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); if (engine.rootObjects().isEmpty()) return -1; return app.exec(); }