Get host path for selected application
This commit is contained in:
@@ -55,7 +55,7 @@ ColumnLayout {
|
|||||||
Dialogs.FileDialog {
|
Dialogs.FileDialog {
|
||||||
id: app_browse
|
id: app_browse
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
app_text.text = new URL(selectedFile).pathname;
|
app_text.text = WivrnServer.host_path(new URL(selectedFile).pathname);
|
||||||
select_game.save();
|
select_game.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "wivrn_server.h"
|
#include "wivrn_server.h"
|
||||||
#include "gui_config.h"
|
#include "gui_config.h"
|
||||||
#include "magic_enum.hpp"
|
#include "magic_enum.hpp"
|
||||||
|
#include "utils/flatpak.h"
|
||||||
#include "wivrn_server_dbus.h"
|
#include "wivrn_server_dbus.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
@@ -554,6 +555,27 @@ QString wivrn_server::hostname()
|
|||||||
return _hostname;
|
return _hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString wivrn_server::host_path(QString path)
|
||||||
|
{
|
||||||
|
if (not wivrn::is_flatpak())
|
||||||
|
return path;
|
||||||
|
|
||||||
|
QDBusInterface docs("org.freedesktop.portal.Documents", "/org/freedesktop/portal/documents", "org.freedesktop.portal.Documents", QDBusConnection::sessionBus());
|
||||||
|
if (not docs.isValid())
|
||||||
|
return path;
|
||||||
|
|
||||||
|
QString id = QFileInfo(path).dir().dirName();
|
||||||
|
[[maybe_unused]] static auto r = qDBusRegisterMetaType<QMap<QString, QByteArray>>();
|
||||||
|
QDBusReply<QMap<QString, QByteArray>> res = docs.call("GetHostPaths", QStringList(id));
|
||||||
|
if ((not res.isValid()) or res.value().empty())
|
||||||
|
return path;
|
||||||
|
|
||||||
|
path = res.value().first();
|
||||||
|
if (path.endsWith('\0'))
|
||||||
|
path.chop(1);
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
void wivrn_server::disconnect_headset()
|
void wivrn_server::disconnect_headset()
|
||||||
{
|
{
|
||||||
if (server_interface)
|
if (server_interface)
|
||||||
|
|||||||
@@ -167,6 +167,9 @@ public:
|
|||||||
// hostnamed
|
// hostnamed
|
||||||
Q_PROPERTY(QString hostname READ hostname CONSTANT)
|
Q_PROPERTY(QString hostname READ hostname CONSTANT)
|
||||||
|
|
||||||
|
// flatpak API
|
||||||
|
Q_INVOKABLE QString host_path(QString path);
|
||||||
|
|
||||||
Status serverStatus() const
|
Status serverStatus() const
|
||||||
{
|
{
|
||||||
return m_serverStatus;
|
return m_serverStatus;
|
||||||
|
|||||||
Reference in New Issue
Block a user