Add message to restart server after config change

This commit is contained in:
Patrick Nicolas
2025-11-19 14:16:15 +01:00
parent 01c4f0343a
commit 7c2057ec9e
9 changed files with 115 additions and 68 deletions
+42 -14
View File
@@ -11,10 +11,6 @@ Kirigami.ApplicationWindow {
id: root id: root
title: i18n("WiVRn dashboard") title: i18n("WiVRn dashboard")
Settings {
id: config
}
ConnectUsbDialog { ConnectUsbDialog {
id: select_usb_device id: select_usb_device
} }
@@ -51,11 +47,6 @@ Kirigami.ApplicationWindow {
Connections { Connections {
target: WivrnServer target: WivrnServer
function onCapSysNiceChanged(value) {
if (WivrnServer.serverStatus != WivrnServer.Stopped)
restart_capsysnice.visible = true;
}
function onServerStatusChanged(value) { function onServerStatusChanged(value) {
var started = value == WivrnServer.Started; var started = value == WivrnServer.Started;
@@ -79,10 +70,6 @@ Kirigami.ApplicationWindow {
switch_pairing.checked = WivrnServer.pairingEnabled; switch_pairing.checked = WivrnServer.pairingEnabled;
} }
function onJsonConfigurationChanged() {
config.load(WivrnServer);
}
function onServerError(info) { function onServerError(info) {
console.log(info.where); console.log(info.where);
console.log(info.message); console.log(info.message);
@@ -184,6 +171,16 @@ Kirigami.ApplicationWindow {
} }
} }
] ]
Connections {
target: WivrnServer
function onCapSysNiceChanged(value) {
if (WivrnServer.serverStatus != WivrnServer.Stopped)
restart_capsysnice.visible = true;
}
function onServerStatusChanged(value) {
restart_capsysnice.visible = false;
}
}
} }
Kirigami.InlineMessage { Kirigami.InlineMessage {
@@ -213,7 +210,7 @@ Kirigami.ApplicationWindow {
text: i18n("No OpenVR compatibility detected, Steam games won't be able to load VR.\nInstall xrizer or OpenComposite.") text: i18n("No OpenVR compatibility detected, Steam games won't be able to load VR.\nInstall xrizer or OpenComposite.")
type: Kirigami.MessageType.Warning type: Kirigami.MessageType.Warning
showCloseButton: true showCloseButton: true
visible: WivrnServer.openVRCompat.length == 0 && config.openvr == "" visible: WivrnServer.openVRCompat.length == 0 && Settings.openvr == ""
} }
Kirigami.InlineMessage { Kirigami.InlineMessage {
@@ -238,6 +235,37 @@ Kirigami.ApplicationWindow {
] ]
} }
Kirigami.InlineMessage {
id: config_restart
Layout.fillWidth: true
text: i18n("Restart the server for configuration changes to take effect")
type: Kirigami.MessageType.Information
showCloseButton: true
visible: false
actions: [
Kirigami.Action {
text: i18nc("restart the server", "Restart now")
onTriggered: {
WivrnServer.restart_server();
config_restart.visible = false;
}
}
]
Connections {
target: Settings
function onSettingsChanged() {
if (WivrnServer.sessionRunning)
config_restart.visible = true;
}
}
Connections {
target: WivrnServer
function onServerStatusChanged(value) {
config_restart.visible = false;
}
}
}
Kirigami.InlineMessage { Kirigami.InlineMessage {
id: message_failed_to_start id: message_failed_to_start
Layout.fillWidth: true Layout.fillWidth: true
+7 -11
View File
@@ -38,10 +38,6 @@ ColumnLayout {
id: apps id: apps
} }
Settings {
id: config
}
Connections { Connections {
target: WivrnServer target: WivrnServer
function onJsonConfigurationChanged() { function onJsonConfigurationChanged() {
@@ -88,7 +84,7 @@ ColumnLayout {
if (select_game.json_loaded || WivrnServer.serverStatus != WivrnServer.Started || WivrnServer.jsonConfiguration == "") if (select_game.json_loaded || WivrnServer.serverStatus != WivrnServer.Started || WivrnServer.jsonConfiguration == "")
return; return;
config.load(WivrnServer); Settings.load(WivrnServer);
var found = false; var found = false;
var custom_idx = -1; var custom_idx = -1;
@@ -96,7 +92,7 @@ ColumnLayout {
var app = apps.get(i); var app = apps.get(i);
if (app.is_custom) if (app.is_custom)
custom_idx = i; custom_idx = i;
else if (app.command == config.application) { else if (app.command == Settings.application) {
app_combobox.currentIndex = i; app_combobox.currentIndex = i;
found = true; found = true;
break; break;
@@ -104,7 +100,7 @@ ColumnLayout {
} }
if (!found) { if (!found) {
app_text.text = config.application; app_text.text = Settings.application;
app_combobox.currentIndex = custom_idx; app_combobox.currentIndex = custom_idx;
} }
@@ -119,10 +115,10 @@ ColumnLayout {
else else
new_application = apps.get(app_combobox.currentIndex).command; new_application = apps.get(app_combobox.currentIndex).command;
config.load(WivrnServer); Settings.load(WivrnServer);
if (config.application != new_application) { if (Settings.application != new_application) {
config.application = new_application; Settings.application = new_application;
config.save(WivrnServer); Settings.save(WivrnServer);
} }
} }
} }
+37 -41
View File
@@ -17,10 +17,6 @@ Kirigami.ScrollablePage {
property bool allowUpdates: false // ignore onXXX events until document is loaded property bool allowUpdates: false // ignore onXXX events until document is loaded
Settings {
id: config
}
ColumnLayout { ColumnLayout {
id: column id: column
anchors.fill: parent anchors.fill: parent
@@ -29,7 +25,7 @@ Kirigami.ScrollablePage {
Controls.CheckBox { Controls.CheckBox {
id: manual_foveation id: manual_foveation
checked: config.scale != -1 checked: Settings.scale != -1
Layout.row: 0 Layout.row: 0
Layout.column: 0 Layout.column: 0
text: i18nc("automatic foveation setup", "Manual foveation") text: i18nc("automatic foveation setup", "Manual foveation")
@@ -100,25 +96,25 @@ Kirigami.ScrollablePage {
return Number.fromLocaleString(text); return Number.fromLocaleString(text);
} }
onValueModified: config.bitrate = value onValueModified: Settings.bitrate = value
} }
Kirigami.InlineMessage { Kirigami.InlineMessage {
Layout.fillWidth: true Layout.fillWidth: true
text: i18n("The current encoder configuration is not supported") text: i18n("The current encoder configuration is not supported")
type: Kirigami.MessageType.Information type: Kirigami.MessageType.Information
visible: !config.simpleConfig visible: !Settings.simpleConfig
actions: [ actions: [
Kirigami.Action { Kirigami.Action {
text: i18n("Reset") text: i18n("Reset")
onTriggered: config.encoder = Settings.EncoderAuto onTriggered: Settings.encoder = Settings.EncoderAuto
} }
] ]
} }
RowLayout { RowLayout {
Kirigami.FormData.label: i18n("Encoder:") Kirigami.FormData.label: i18n("Encoder:")
enabled: config.simpleConfig enabled: Settings.simpleConfig
Controls.ComboBox { Controls.ComboBox {
id: encoder_combo id: encoder_combo
model: [ model: [
@@ -143,12 +139,12 @@ Kirigami.ScrollablePage {
encoder: Settings.X264 encoder: Settings.X264
} }
] ]
onCurrentIndexChanged: if (settings.allowUpdates) {config.encoder = model[currentIndex].encoder} onCurrentIndexChanged: if (settings.allowUpdates) {Settings.encoder = model[currentIndex].encoder}
textRole: "label" textRole: "label"
Connections { Connections {
target: config target: Settings
function onEncoderChanged() { function onEncoderChanged() {
var encoder = config.encoder; var encoder = Settings.encoder;
var i = encoder_combo.model.findIndex( item => item.encoder == encoder) var i = encoder_combo.model.findIndex( item => item.encoder == encoder)
if (i > -1) if (i > -1)
encoder_combo.currentIndex = i encoder_combo.currentIndex = i
@@ -164,7 +160,7 @@ Kirigami.ScrollablePage {
Kirigami.FormData.label: i18n("Codec:") Kirigami.FormData.label: i18n("Codec:")
Controls.ComboBox { Controls.ComboBox {
id: codec_combo id: codec_combo
enabled: config.simpleConfig && config.encoder != Settings.EncoderAuto enabled: Settings.simpleConfig && Settings.encoder != Settings.EncoderAuto
model: [ model: [
{ {
label: i18nc("automatic codec setup", "Auto"), label: i18nc("automatic codec setup", "Auto"),
@@ -183,7 +179,7 @@ Kirigami.ScrollablePage {
codec: Settings.Av1 codec: Settings.Av1
} }
] ]
onCurrentIndexChanged: if (settings.allowUpdates) {config.codec = model[currentIndex].codec} onCurrentIndexChanged: if (settings.allowUpdates) {Settings.codec = model[currentIndex].codec}
textRole: "label" textRole: "label"
delegate: Controls.ItemDelegate { delegate: Controls.ItemDelegate {
@@ -193,12 +189,12 @@ Kirigami.ScrollablePage {
width: codec_combo.width width: codec_combo.width
text: i18n(label) text: i18n(label)
highlighted: ListView.isCurrentItem highlighted: ListView.isCurrentItem
enabled: config.allowedCodecs.includes(codec) enabled: Settings.allowedCodecs.includes(codec)
} }
Connections { Connections {
target: config target: Settings
function onCodecChanged() { function onCodecChanged() {
var codec = config.codec; var codec = Settings.codec;
var i = codec_combo.model.findIndex( item => item.codec == codec) var i = codec_combo.model.findIndex( item => item.codec == codec)
if (i > -1) if (i > -1)
codec_combo.currentIndex = i codec_combo.currentIndex = i
@@ -206,10 +202,10 @@ Kirigami.ScrollablePage {
} }
} }
Controls.CheckBox { Controls.CheckBox {
enabled: config.can10bit enabled: Settings.can10bit
text: i18n("10 bits") text: i18n("10 bits")
checked: config.tenbit checked: Settings.tenbit
onCheckedChanged: config.tenbit = checked onCheckedChanged: Settings.tenbit = checked
} }
Kirigami.ContextualHelpButton { Kirigami.ContextualHelpButton {
toolTipText: i18n("10-bit encoding improves image quality but is not supported by all codecs and hardware") toolTipText: i18n("10-bit encoding improves image quality but is not supported by all codecs and hardware")
@@ -231,7 +227,7 @@ Kirigami.ScrollablePage {
text: i18n("Check system configuration on start") text: i18n("Check system configuration on start")
} }
RowLayout { RowLayout {
visible: config.hid_forwarding_supported visible: Settings.hid_forwarding_supported
Controls.CheckBox { Controls.CheckBox {
id: hid_forwarding id: hid_forwarding
text: i18n("Forward keyboard & mouse from headset") text: i18n("Forward keyboard & mouse from headset")
@@ -243,10 +239,10 @@ Kirigami.ScrollablePage {
Controls.CheckBox { Controls.CheckBox {
id: debug_gui id: debug_gui
text: i18n("Enable debug window") text: i18n("Enable debug window")
visible: config.debug_gui_supported visible: Settings.debug_gui_supported
} }
RowLayout { RowLayout {
visible: config.steamvr_lh_supported visible: Settings.steamvr_lh_supported
Controls.CheckBox { Controls.CheckBox {
id: steamvr_lh id: steamvr_lh
text: i18n("Enable SteamVR tracked devices support") text: i18n("Enable SteamVR tracked devices support")
@@ -327,14 +323,14 @@ Kirigami.ScrollablePage {
function load() { function load() {
for(let i=0 ; i < openvr_libs.count; i++) { for(let i=0 ; i < openvr_libs.count; i++) {
if (openvr_libs.get(i).value == config.openvr) { if (openvr_libs.get(i).value == Settings.openvr) {
openvr_combobox.currentIndex = i; openvr_combobox.currentIndex = i;
return; return;
} }
} }
for(let i=0 ; i < openvr_libs.count; i++) { for(let i=0 ; i < openvr_libs.count; i++) {
if (openvr_libs.get(i).is_custom) { if (openvr_libs.get(i).is_custom) {
openvr_text.text = config.openvr openvr_text.text = Settings.openvr
openvr_combobox.currentIndex = i; openvr_combobox.currentIndex = i;
return; return;
} }
@@ -362,12 +358,12 @@ Kirigami.ScrollablePage {
onAccepted: { onAccepted: {
settings.save(); settings.save();
config.save(WivrnServer); Settings.save(WivrnServer);
applicationWindow().pageStack.pop(); applicationWindow().pageStack.pop();
} }
onReset: { onReset: {
config.restore_defaults(); Settings.restore_defaults();
settings.load(); settings.load();
} }
onRejected: applicationWindow().pageStack.pop() onRejected: applicationWindow().pageStack.pop()
@@ -375,21 +371,21 @@ Kirigami.ScrollablePage {
Component.onCompleted: { Component.onCompleted: {
openvr_libs.init() openvr_libs.init()
config.load(WivrnServer); Settings.load(WivrnServer);
// If bitrate was manually set higher, keep the limit // If bitrate was manually set higher, keep the limit
bitrate.to = Math.max(bitrate.to, config.bitrate) bitrate.to = Math.max(bitrate.to, Settings.bitrate)
bitrate.value = config.bitrate bitrate.value = Settings.bitrate
settings.allowUpdates = true; settings.allowUpdates = true;
settings.load(); settings.load();
} }
function save() { function save() {
config.scale = manual_foveation.checked ? 1 - scale_slider.value / 100.0 : -1; Settings.scale = manual_foveation.checked ? 1 - scale_slider.value / 100.0 : -1;
let openvr = openvr_combobox.model.get(openvr_combobox.currentIndex) let openvr = openvr_combobox.model.get(openvr_combobox.currentIndex)
if (openvr.is_custom) { if (openvr.is_custom) {
config.openvr = openvr_text.text; Settings.openvr = openvr_text.text;
} else { } else {
config.openvr = openvr.value Settings.openvr = openvr.value
} }
DashboardSettings.adb_custom = adb_custom.checked; DashboardSettings.adb_custom = adb_custom.checked;
DashboardSettings.adb_location = adb_location.text; DashboardSettings.adb_location = adb_location.text;
@@ -397,21 +393,21 @@ Kirigami.ScrollablePage {
DashboardSettings.show_system_checks = show_system_checks.checked; DashboardSettings.show_system_checks = show_system_checks.checked;
config.debugGui = debug_gui.checked; Settings.debugGui = debug_gui.checked;
config.steamVrLh = steamvr_lh.checked; Settings.steamVrLh = steamvr_lh.checked;
config.hidForwarding = hid_forwarding.checked; Settings.hidForwarding = hid_forwarding.checked;
} }
function load() { function load() {
if (config.scale > 0) { if (Settings.scale > 0) {
scale_slider.value = Math.round(100 - config.scale * 100); scale_slider.value = Math.round(100 - Settings.scale * 100);
} else { } else {
scale_slider.value = 50; scale_slider.value = 50;
} }
debug_gui.checked = config.debugGui; debug_gui.checked = Settings.debugGui;
steamvr_lh.checked = config.steamVrLh; steamvr_lh.checked = Settings.steamVrLh;
hid_forwarding.checked = config.hidForwarding; hid_forwarding.checked = Settings.hidForwarding;
openvr_combobox.load() openvr_combobox.load()
+3
View File
@@ -131,6 +131,7 @@ void Settings::load(const wivrn_server * server)
{ {
auto conf = server->jsonConfiguration(); auto conf = server->jsonConfiguration();
m_jsonSettings = nlohmann::json::parse(conf.toUtf8()); m_jsonSettings = nlohmann::json::parse(conf.toUtf8());
m_originalSettings = m_jsonSettings;
if (not m_jsonSettings.is_object()) if (not m_jsonSettings.is_object())
m_jsonSettings = nlohmann::json::object(); m_jsonSettings = nlohmann::json::object();
emitAllChanged(); emitAllChanged();
@@ -513,6 +514,8 @@ bool Settings::can10bit() const
void Settings::save(wivrn_server * server) void Settings::save(wivrn_server * server)
{ {
server->setJsonConfiguration(QString::fromStdString(m_jsonSettings.dump(2))); server->setJsonConfiguration(QString::fromStdString(m_jsonSettings.dump(2)));
if (m_jsonSettings != m_originalSettings)
settingsChanged();
} }
void Settings::restore_defaults() void Settings::restore_defaults()
+6 -1
View File
@@ -38,7 +38,8 @@ class wivrn_server;
class Settings : public QObject class Settings : public QObject
{ {
Q_OBJECT Q_OBJECT
QML_ELEMENT QML_NAMED_ELEMENT(Settings)
QML_SINGLETON
public: public:
enum encoder_name enum encoder_name
{ {
@@ -95,6 +96,7 @@ public:
SETTER_GETTER_NOTIFY(QString, openvr) SETTER_GETTER_NOTIFY(QString, openvr)
private: private:
nlohmann::json m_jsonSettings = nlohmann::json::object(); nlohmann::json m_jsonSettings = nlohmann::json::object();
nlohmann::json m_originalSettings;
void emitAllChanged(); void emitAllChanged();
public: public:
@@ -117,6 +119,9 @@ public:
static video_codec codec_id_from_string(std::string_view s); static video_codec codec_id_from_string(std::string_view s);
static const std::string & encoder_from_id(encoder_name id); static const std::string & encoder_from_id(encoder_name id);
static const std::string & codec_from_id(video_codec id); static const std::string & codec_from_id(video_codec id);
Q_SIGNALS:
void settingsChanged();
}; };
#undef SETTER_GETTER_NOTIFY #undef SETTER_GETTER_NOTIFY
+8
View File
@@ -280,6 +280,9 @@ void wivrn_server::on_server_dbus_unregistered()
if (isHeadsetConnected()) if (isHeadsetConnected())
headsetConnectedChanged(m_headsetConnected = false); headsetConnectedChanged(m_headsetConnected = false);
if (isSessionRunning())
sessionRunningChanged(m_sessionRunning = false);
if (isPairingEnabled()) if (isPairingEnabled())
pairingEnabledChanged(m_isPairingEnabled = false); pairingEnabledChanged(m_isPairingEnabled = false);
@@ -361,6 +364,11 @@ void wivrn_server::on_server_properties_changed(const QString & interface_name,
headsetConnectedChanged(m_headsetConnected = changed_properties["HeadsetConnected"].toBool()); headsetConnectedChanged(m_headsetConnected = changed_properties["HeadsetConnected"].toBool());
} }
if (changed_properties.contains("SessionRunning"))
{
sessionRunningChanged(m_sessionRunning = changed_properties["SessionRunning"].toBool());
}
if (changed_properties.contains("JsonConfiguration")) if (changed_properties.contains("JsonConfiguration"))
{ {
jsonConfigurationChanged(m_jsonConfiguration = changed_properties["JsonConfiguration"].toString()); jsonConfigurationChanged(m_jsonConfiguration = changed_properties["JsonConfiguration"].toString());
+8
View File
@@ -175,6 +175,7 @@ public:
Q_PROPERTY(Status serverStatus READ serverStatus NOTIFY serverStatusChanged) Q_PROPERTY(Status serverStatus READ serverStatus NOTIFY serverStatusChanged)
Q_PROPERTY(bool capSysNice READ capSysNice NOTIFY capSysNiceChanged) Q_PROPERTY(bool capSysNice READ capSysNice NOTIFY capSysNiceChanged)
Q_PROPERTY(bool headsetConnected READ isHeadsetConnected NOTIFY headsetConnectedChanged) Q_PROPERTY(bool headsetConnected READ isHeadsetConnected NOTIFY headsetConnectedChanged)
Q_PROPERTY(bool sessionRunning READ isSessionRunning NOTIFY sessionRunningChanged)
Q_PROPERTY(QString jsonConfiguration READ jsonConfiguration WRITE setJsonConfiguration NOTIFY jsonConfigurationChanged) Q_PROPERTY(QString jsonConfiguration READ jsonConfiguration WRITE setJsonConfiguration NOTIFY jsonConfigurationChanged)
Q_PROPERTY(QString serverLogs READ serverLogs NOTIFY serverLogsChanged) Q_PROPERTY(QString serverLogs READ serverLogs NOTIFY serverLogsChanged)
Q_INVOKABLE void start_server(); Q_INVOKABLE void start_server();
@@ -232,6 +233,11 @@ public:
return m_headsetConnected; return m_headsetConnected;
} }
bool isSessionRunning() const
{
return m_sessionRunning;
}
QString jsonConfiguration() const QString jsonConfiguration() const
{ {
return m_jsonConfiguration; return m_jsonConfiguration;
@@ -351,6 +357,7 @@ private:
Status m_serverStatus{Status::Stopped}; Status m_serverStatus{Status::Stopped};
bool m_capSysNice{}; bool m_capSysNice{};
bool m_headsetConnected{}; bool m_headsetConnected{};
bool m_sessionRunning{};
QString m_jsonConfiguration{}; QString m_jsonConfiguration{};
QString m_pin{}; QString m_pin{};
@@ -376,6 +383,7 @@ Q_SIGNALS:
void serverStatusChanged(Status); void serverStatusChanged(Status);
void capSysNiceChanged(bool); void capSysNiceChanged(bool);
void headsetConnectedChanged(bool); void headsetConnectedChanged(bool);
void sessionRunningChanged(bool);
void jsonConfigurationChanged(QString); void jsonConfigurationChanged(QString);
void needMonadoVulkanLayerChanged(bool); void needMonadoVulkanLayerChanged(bool);
void pinChanged(QString); void pinChanged(QString);
+1
View File
@@ -42,6 +42,7 @@
<method name="DisablePairing"/> <method name="DisablePairing"/>
<property name="HeadsetConnected" type="b" access="read"/> <property name="HeadsetConnected" type="b" access="read"/>
<property name="SessionRunning" type="b" access="read"/>
<property name="SteamCommand" type="s" access="read"/> <property name="SteamCommand" type="s" access="read"/>
<property name="JsonConfiguration" type="s" access="readwrite"/> <property name="JsonConfiguration" type="s" access="readwrite"/>
<property name="Bitrate" type="u" access="readwrite"/> <property name="Bitrate" type="u" access="readwrite"/>
+2
View File
@@ -276,7 +276,9 @@ void start_server(configuration config)
assert(server_watch == 0); assert(server_watch == 0);
assert(server_kill_watch == 0); assert(server_kill_watch == 0);
wivrn_server_set_session_running(dbus_server, true);
server_watch = g_child_watch_add(server_pid, [](pid_t, int status, void *) { server_watch = g_child_watch_add(server_pid, [](pid_t, int status, void *) {
wivrn_server_set_session_running(dbus_server, false);
display_child_status(status, "Server"); display_child_status(status, "Server");
g_source_remove(server_watch); g_source_remove(server_watch);
if (server_kill_watch) if (server_kill_watch)