File indexing completed on 2024-05-19 04:47:22
0001 #include <QApplication> 0002 #include <QQmlApplicationEngine> 0003 #include <QCommandLineParser> 0004 #include <QQmlContext> 0005 #include <QIcon> 0006 0007 #include <MauiKit3/Core/mauiapp.h> 0008 0009 #include <KI18n/KLocalizedString> 0010 0011 #include "models/historymodel.h" 0012 #include "models/bookmarksmodel.h" 0013 0014 #include "controllers/surf.h" 0015 #include "controllers/fierywebprofile.h" 0016 #include "controllers/downloadsmanager.h" 0017 0018 #include "../fiery_version.h" 0019 0020 #include <QtWebEngine/QtWebEngine> 0021 0022 #define FIERY_URI "org.maui.fiery" 0023 0024 int main(int argc, char *argv[]) 0025 { 0026 QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 0027 QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true); 0028 0029 QApplication app(argc, argv); 0030 QtWebEngine::initialize(); 0031 0032 app.setOrganizationName("Maui"); 0033 app.setWindowIcon(QIcon(":/fiery.svg")); 0034 0035 KLocalizedString::setApplicationDomain("fiery"); 0036 KAboutData about(QStringLiteral("fiery"), 0037 QStringLiteral("Fiery"), 0038 FIERY_VERSION_STRING, 0039 i18n("Browse and organize the web."), 0040 KAboutLicense::LGPL_V3, 0041 APP_COPYRIGHT_NOTICE, 0042 QString(GIT_BRANCH) + "/" + QString(GIT_COMMIT_HASH)); 0043 0044 about.addAuthor(QStringLiteral("Camilo Higuita"), i18n("Developer"), QStringLiteral("milo.h@aol.com")); 0045 about.setHomepage("https://mauikit.org"); 0046 about.setProductName("maui/fiery"); 0047 about.setBugAddress("https://invent.kde.org/maui/fiery/-/issues"); 0048 about.setOrganizationDomain(FIERY_URI); 0049 about.setProgramLogo(app.windowIcon()); 0050 0051 KAboutData::setApplicationData(about); 0052 MauiApp::instance()->setIconName("qrc:/fiery.png"); 0053 0054 QCommandLineParser parser; 0055 0056 about.setupCommandLine(&parser); 0057 parser.process(app); 0058 0059 about.processCommandLine(&parser); 0060 0061 QQmlApplicationEngine engine; 0062 const QUrl url(QStringLiteral("qrc:/main.qml")); 0063 QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, 0064 &app, [url](QObject *obj, const QUrl &objUrl) 0065 { 0066 if (!obj && url == objUrl) 0067 QCoreApplication::exit(-1); 0068 0069 // if(!args.isEmpty()) 0070 // Sol::getInstance()->requestUrls(args); 0071 0072 }, Qt::QueuedConnection); 0073 0074 0075 engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); 0076 0077 qmlRegisterType<surf>(FIERY_URI, 1, 0, "Surf"); 0078 0079 qmlRegisterSingletonInstance<DownloadsManager>(FIERY_URI, 1, 0, "DownloadsManager", &DownloadsManager::instance()); 0080 0081 qmlRegisterType<FieryWebProfile>(FIERY_URI, 1, 0, "FieryWebProfile"); 0082 qmlRegisterSingletonType<HistoryModel>(FIERY_URI, 1, 0, "History", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * { 0083 Q_UNUSED(scriptEngine) 0084 Q_UNUSED(engine) 0085 0086 // engine->setObjectOwnership(platform, QQmlEngine::CppOwnership); 0087 return new HistoryModel; 0088 }); 0089 0090 0091 qmlRegisterSingletonType<BookMarksModel>(FIERY_URI, 1, 0, "Bookmarks", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject * { 0092 Q_UNUSED(scriptEngine) 0093 Q_UNUSED(engine) 0094 0095 // engine->setObjectOwnership(platform, QQmlEngine::CppOwnership); 0096 return new BookMarksModel; 0097 }); 0098 0099 engine.load(url); 0100 0101 return app.exec(); 0102 }