File indexing completed on 2024-09-08 04:54:28
0001 // SPDX-FileCopyrightText: 2010 Omat Holding B.V. <info@omat.nl> 0002 // SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org> 0003 // SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org> 0004 // SPDX-License-Identifier: LGPL-2.0-or-later 0005 0006 #include <QApplication> 0007 #include <QQmlApplicationEngine> 0008 #include <QtQml> 0009 #include <QUrl> 0010 #include <QDebug> 0011 #include <QIcon> 0012 0013 #include <KLocalizedContext> 0014 #include <KLocalizedString> 0015 #include <KDescendantsProxyModel> 0016 #include <MessageComposer/Composer> 0017 #include <MessageComposer/AttachmentModel> 0018 #include <MessageComposer/TextPart> 0019 #include <MessageComposer/InfoPart> 0020 0021 #include "raven.h" 0022 #include "mailmanager.h" 0023 #include "abouttype.h" 0024 #include "mailmodel.h" 0025 #include "contactimageprovider.h" 0026 #include "mime/htmlutils.h" 0027 #include "mime/messageparser.h" 0028 #include "accounts/mailaccounts.h" 0029 #include "accounts/newaccount.h" 0030 0031 #include <Akonadi/Item> 0032 #include <Akonadi/CollectionFilterProxyModel> 0033 0034 Q_DECL_EXPORT int main(int argc, char *argv[]) 0035 { 0036 QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 0037 QGuiApplication::setAttribute(Qt::AA_ShareOpenGLContexts); 0038 QApplication app(argc, argv); 0039 KLocalizedString::setApplicationDomain("raven"); 0040 0041 KAboutData aboutData(QStringLiteral("raven"), 0042 i18n("Raven"), 0043 QStringLiteral("0.1"), 0044 i18n("A mail client"), 0045 KAboutLicense::GPL, 0046 i18n("© 2022 Plasma Development Team")); 0047 aboutData.setBugAddress("https://bugs.kde.org/describecomponents.cgi?product=kweather"); 0048 aboutData.addAuthor(i18n("Devin Lin"), QString(), QStringLiteral("devin@kde.org"), QStringLiteral("https://espi.dev")); 0049 KAboutData::setApplicationData(aboutData); 0050 0051 QQmlApplicationEngine engine; 0052 0053 // configure types 0054 qmlRegisterSingletonType<MailManager>("org.kde.raven", 1, 0, "MailManager", [](QQmlEngine *engine, QJSEngine *scriptEngine) { 0055 Q_UNUSED(engine) 0056 Q_UNUSED(scriptEngine) 0057 return new MailManager; 0058 }); 0059 0060 qmlRegisterSingletonType<HtmlUtils::HtmlUtils>("org.kde.raven", 1, 0, "HtmlUtils", [](QQmlEngine *engine, QJSEngine *scriptEngine) { 0061 Q_UNUSED(engine) 0062 Q_UNUSED(scriptEngine) 0063 return new HtmlUtils::HtmlUtils; 0064 }); 0065 0066 qmlRegisterSingletonType<MailAccounts>("org.kde.raven", 1, 0, "MailAccounts", [](QQmlEngine *engine, QJSEngine *scriptEngine) { return new MailAccounts; }); 0067 0068 qmlRegisterType<NewAccount>("org.kde.raven", 1, 0, "NewAccount"); 0069 qmlRegisterType<MessageParser>("org.kde.raven", 1, 0, "MessageParser"); 0070 0071 qRegisterMetaType<MailModel *>("MailModel*"); 0072 qRegisterMetaType<Akonadi::CollectionFilterProxyModel *>("Akonadi::CollectionFilterProxyModel *"); 0073 qRegisterMetaType<Akonadi::Item::Id>("Akonadi::Item::Id"); 0074 qRegisterMetaType<KDescendantsProxyModel*>("KDescendantsProxyModel*"); 0075 0076 qmlRegisterSingletonInstance("org.kde.raven", 1, 0, "AboutType", &AboutType::instance()); 0077 qmlRegisterSingletonInstance<Raven>("org.kde.raven", 1, 0, "Raven", raven); 0078 0079 engine.addImageProvider(QLatin1String("contact"), new ContactImageProvider); 0080 0081 engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); 0082 engine.load(QUrl(QStringLiteral("qrc:///main.qml"))); 0083 0084 // required for X11 0085 app.setWindowIcon(QIcon::fromTheme(QStringLiteral("org.kde.raven"))); 0086 0087 if (engine.rootObjects().isEmpty()) { 0088 return -1; 0089 } 0090 0091 return app.exec(); 0092 }