Support getting text data from dbus in PlatformData

This commit is contained in:
Anton Thomasson 2023-02-19 21:14:09 +01:00
parent 29c5bbf62b
commit d473d23d55

View file

@ -12,11 +12,21 @@ DBusAdaptor::~DBusAdaptor()
{
}
void DBusAdaptor::Open(const QStringList &uris, const QVariantMap &)
void DBusAdaptor::Open(const QStringList& uris, const QVariantMap& platformData)
{
if (!uris.isEmpty()) {
qDebug() << platformData;
if (!uris.isEmpty() && uris[0] != "") {
QMetaObject::invokeMethod(_view->rootObject(), "openFile", Q_ARG(QVariant, uris.at(0)));
}
else if(platformData.contains("data"))
{
QTemporaryFile tmpfile(QDir::tempPath() + "/" + (platformData.contains("name") ? platformData["name"].toString() : "seaprint"));
tmpfile.setAutoRemove(false);
tmpfile.open();
tmpfile.write(platformData["data"].toString().toUtf8());
tmpfile.close();
QMetaObject::invokeMethod(_view->rootObject(), "openFile", Q_ARG(QVariant, tmpfile.fileName()));
}
QMetaObject::invokeMethod(_view->rootObject(), "activate");
}