Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F23020463
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
3 KB
Subscribers
None
View Options
diff --git a/examples/qml/CMakeLists.txt b/examples/qml/CMakeLists.txt
index 8a2ca7d..38199ae 100644
--- a/examples/qml/CMakeLists.txt
+++ b/examples/qml/CMakeLists.txt
@@ -1,23 +1,28 @@
# SPDX-FileCopyrightText: 2023 Carl Schwan <carl.schwan@gnupg.com>
# SPDX-License-Identifier: BSD-3-Clause
find_package(Qt6Qml ${QT_REQUIRED_VERSION} CONFIG REQUIRED)
find_package(Qt6Quick ${QT_REQUIRED_VERSION} CONFIG REQUIRED)
find_package(KPim6Mbox ${KPIM_MBOX_VERSION} CONFIG REQUIRED)
add_executable(mimetreeparser-qml
main.cpp
messagehandler.cpp
messagehandler.h
resources.qrc
)
target_link_libraries(mimetreeparser-qml PUBLIC
Qt::Quick
Qt::Widgets
Qt::Qml
Qt::Gui
KF6::I18n
KPim6::MimeTreeParserCore
KPim6::Mbox
Gpgmepp
)
+if(TARGET KF6::I18nQml)
+target_link_libraries(mimetreeparser-qml PUBLIC
+ KF6::I18nQml
+)
+endif()
diff --git a/examples/qml/main.cpp b/examples/qml/main.cpp
index 610ca4f..63fefc8 100644
--- a/examples/qml/main.cpp
+++ b/examples/qml/main.cpp
@@ -1,55 +1,62 @@
// SPDX-FileCopyrightText: 2023 Carl Schwan <carl.schwan@gnupg.com>
// SPDX-License-Identifier: LGPL-2.0-or-later
#include <KLocalizedContext>
#include <KLocalizedString>
#include <QApplication>
#include <QCommandLineParser>
#include <QDebug>
#include <QDir>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QQuickWindow>
#include "messagehandler.h"
#include <KLocalizedContext>
#include <MimeTreeParserCore/FileOpener>
#include <MimeTreeParserCore/MessageParser>
+#if KI18N_VERSION >= QT_VERSION_CHECK(6, 8, 0)
+#include <KLocalizedQmlContext>
+#endif
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QCommandLineParser parser;
parser.setApplicationDescription(i18n("View mbox file"));
parser.addPositionalArgument(QStringLiteral("file"), i18n("mbox file"));
QQmlApplicationEngine engine;
+#if KI18N_VERSION < QT_VERSION_CHECK(6, 8, 0)
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
+#else
+ engine.rootContext()->setContextObject(new KLocalizedQmlContext(&engine));
+#endif
QObject::connect(&engine, &QQmlApplicationEngine::quit, &app, &QCoreApplication::quit);
constexpr auto uri = "org.kde.mimetreeparser";
qmlRegisterType<MessageParser>(uri, 1, 0, "MessageParser");
qmlRegisterType<MessageHandler>(uri, 1, 0, "MessageHandler");
engine.load(QUrl(QStringLiteral("qrc:/content/main.qml")));
const auto rootObjects = engine.rootObjects();
if (rootObjects.isEmpty()) {
qWarning() << "Impossible to load main.qml. Please verify installation";
return -1;
}
parser.process(app);
const QStringList args = parser.positionalArguments();
if (!args.isEmpty()) {
for (auto obj : rootObjects) {
auto view = qobject_cast<QQuickWindow *>(obj);
auto messageHandler = view->findChild<MessageHandler *>(QStringLiteral("MessageHandler"));
const auto file = QUrl::fromUserInput(args.at(args.count() - 1), QDir::currentPath());
messageHandler->open(file);
}
}
return QCoreApplication::exec();
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, May 12, 6:18 PM (12 h, 53 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
d1/d8/773a7c1db089d0b35d101cd77c93
Attached To
rMTP MIME Tree Parser
Event Timeline
Log In to Comment