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
title: i18n("WiVRn dashboard")
Settings {
id: config
}
ConnectUsbDialog {
id: select_usb_device
}
@@ -51,11 +47,6 @@ Kirigami.ApplicationWindow {
Connections {
target: WivrnServer
function onCapSysNiceChanged(value) {
if (WivrnServer.serverStatus != WivrnServer.Stopped)
restart_capsysnice.visible = true;
}
function onServerStatusChanged(value) {
var started = value == WivrnServer.Started;
@@ -79,10 +70,6 @@ Kirigami.ApplicationWindow {
switch_pairing.checked = WivrnServer.pairingEnabled;
}
function onJsonConfigurationChanged() {
config.load(WivrnServer);
}
function onServerError(info) {
console.log(info.where);
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 {
@@ -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.")
type: Kirigami.MessageType.Warning
showCloseButton: true
visible: WivrnServer.openVRCompat.length == 0 && config.openvr == ""
visible: WivrnServer.openVRCompat.length == 0 && Settings.openvr == ""
}
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 {
id: message_failed_to_start
Layout.fillWidth: true
+7 -11
View File
@@ -38,10 +38,6 @@ ColumnLayout {
id: apps
}
Settings {
id: config
}
Connections {
target: WivrnServer
function onJsonConfigurationChanged() {
@@ -88,7 +84,7 @@ ColumnLayout {
if (select_game.json_loaded || WivrnServer.serverStatus != WivrnServer.Started || WivrnServer.jsonConfiguration == "")
return;
config.load(WivrnServer);
Settings.load(WivrnServer);
var found = false;
var custom_idx = -1;
@@ -96,7 +92,7 @@ ColumnLayout {
var app = apps.get(i);
if (app.is_custom)
custom_idx = i;
else if (app.command == config.application) {
else if (app.command == Settings.application) {
app_combobox.currentIndex = i;
found = true;
break;
@@ -104,7 +100,7 @@ ColumnLayout {
}
if (!found) {
app_text.text = config.application;
app_text.text = Settings.application;
app_combobox.currentIndex = custom_idx;
}
@@ -119,10 +115,10 @@ ColumnLayout {
else
new_application = apps.get(app_combobox.currentIndex).command;
config.load(WivrnServer);
if (config.application != new_application) {
config.application = new_application;
config.save(WivrnServer);
Settings.load(WivrnServer);
if (Settings.application != new_application) {
Settings.application = new_application;
Settings.save(WivrnServer);
}
}
}
+38 -42
View File
@@ -17,10 +17,6 @@ Kirigami.ScrollablePage {
property bool allowUpdates: false // ignore onXXX events until document is loaded
Settings {
id: config
}
ColumnLayout {
id: column
anchors.fill: parent
@@ -29,7 +25,7 @@ Kirigami.ScrollablePage {
Controls.CheckBox {
id: manual_foveation
checked: config.scale != -1
checked: Settings.scale != -1
Layout.row: 0
Layout.column: 0
text: i18nc("automatic foveation setup", "Manual foveation")
@@ -100,25 +96,25 @@ Kirigami.ScrollablePage {
return Number.fromLocaleString(text);
}
onValueModified: config.bitrate = value
onValueModified: Settings.bitrate = value
}
Kirigami.InlineMessage {
Layout.fillWidth: true
text: i18n("The current encoder configuration is not supported")
type: Kirigami.MessageType.Information
visible: !config.simpleConfig
visible: !Settings.simpleConfig
actions: [
Kirigami.Action {
text: i18n("Reset")
onTriggered: config.encoder = Settings.EncoderAuto
onTriggered: Settings.encoder = Settings.EncoderAuto
}
]
}
RowLayout {
Kirigami.FormData.label: i18n("Encoder:")
enabled: config.simpleConfig
enabled: Settings.simpleConfig
Controls.ComboBox {
id: encoder_combo
model: [
@@ -143,12 +139,12 @@ Kirigami.ScrollablePage {
encoder: Settings.X264
}
]
onCurrentIndexChanged: if (settings.allowUpdates) {config.encoder = model[currentIndex].encoder}
onCurrentIndexChanged: if (settings.allowUpdates) {Settings.encoder = model[currentIndex].encoder}
textRole: "label"
Connections {
target: config
target: Settings
function onEncoderChanged() {
var encoder = config.encoder;
var encoder = Settings.encoder;
var i = encoder_combo.model.findIndex( item => item.encoder == encoder)
if (i > -1)
encoder_combo.currentIndex = i
@@ -164,7 +160,7 @@ Kirigami.ScrollablePage {
Kirigami.FormData.label: i18n("Codec:")
Controls.ComboBox {
id: codec_combo
enabled: config.simpleConfig && config.encoder != Settings.EncoderAuto
enabled: Settings.simpleConfig && Settings.encoder != Settings.EncoderAuto
model: [
{
label: i18nc("automatic codec setup", "Auto"),
@@ -183,7 +179,7 @@ Kirigami.ScrollablePage {
codec: Settings.Av1
}
]
onCurrentIndexChanged: if (settings.allowUpdates) {config.codec = model[currentIndex].codec}
onCurrentIndexChanged: if (settings.allowUpdates) {Settings.codec = model[currentIndex].codec}
textRole: "label"
delegate: Controls.ItemDelegate {
@@ -193,12 +189,12 @@ Kirigami.ScrollablePage {
width: codec_combo.width
text: i18n(label)
highlighted: ListView.isCurrentItem
enabled: config.allowedCodecs.includes(codec)
enabled: Settings.allowedCodecs.includes(codec)
}
Connections {
target: config
target: Settings
function onCodecChanged() {
var codec = config.codec;
var codec = Settings.codec;
var i = codec_combo.model.findIndex( item => item.codec == codec)
if (i > -1)
codec_combo.currentIndex = i
@@ -206,10 +202,10 @@ Kirigami.ScrollablePage {
}
}
Controls.CheckBox {
enabled: config.can10bit
enabled: Settings.can10bit
text: i18n("10 bits")
checked: config.tenbit
onCheckedChanged: config.tenbit = checked
checked: Settings.tenbit
onCheckedChanged: Settings.tenbit = checked
}
Kirigami.ContextualHelpButton {
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")
}
RowLayout {
visible: config.hid_forwarding_supported
visible: Settings.hid_forwarding_supported
Controls.CheckBox {
id: hid_forwarding
text: i18n("Forward keyboard & mouse from headset")
@@ -243,10 +239,10 @@ Kirigami.ScrollablePage {
Controls.CheckBox {
id: debug_gui
text: i18n("Enable debug window")
visible: config.debug_gui_supported
visible: Settings.debug_gui_supported
}
RowLayout {
visible: config.steamvr_lh_supported
visible: Settings.steamvr_lh_supported
Controls.CheckBox {
id: steamvr_lh
text: i18n("Enable SteamVR tracked devices support")
@@ -327,14 +323,14 @@ Kirigami.ScrollablePage {
function load() {
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;
return;
}
}
for(let i=0 ; i < openvr_libs.count; i++) {
if (openvr_libs.get(i).is_custom) {
openvr_text.text = config.openvr
openvr_text.text = Settings.openvr
openvr_combobox.currentIndex = i;
return;
}
@@ -343,7 +339,7 @@ Kirigami.ScrollablePage {
}
Controls.TextField {
id: openvr_text
placeholderText: i18n("Library path, excluding bin/linux64/vrclient.so")
placeholderText: i18n("Library path, excluding bin/linux64/vrclient.so")
visible: !!openvr_combobox.model.get(openvr_combobox.currentIndex)?.is_custom
Layout.fillWidth: true
}
@@ -362,12 +358,12 @@ Kirigami.ScrollablePage {
onAccepted: {
settings.save();
config.save(WivrnServer);
Settings.save(WivrnServer);
applicationWindow().pageStack.pop();
}
onReset: {
config.restore_defaults();
Settings.restore_defaults();
settings.load();
}
onRejected: applicationWindow().pageStack.pop()
@@ -375,21 +371,21 @@ Kirigami.ScrollablePage {
Component.onCompleted: {
openvr_libs.init()
config.load(WivrnServer);
Settings.load(WivrnServer);
// If bitrate was manually set higher, keep the limit
bitrate.to = Math.max(bitrate.to, config.bitrate)
bitrate.value = config.bitrate
bitrate.to = Math.max(bitrate.to, Settings.bitrate)
bitrate.value = Settings.bitrate
settings.allowUpdates = true;
settings.load();
}
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)
if (openvr.is_custom) {
config.openvr = openvr_text.text;
Settings.openvr = openvr_text.text;
} else {
config.openvr = openvr.value
Settings.openvr = openvr.value
}
DashboardSettings.adb_custom = adb_custom.checked;
DashboardSettings.adb_location = adb_location.text;
@@ -397,21 +393,21 @@ Kirigami.ScrollablePage {
DashboardSettings.show_system_checks = show_system_checks.checked;
config.debugGui = debug_gui.checked;
config.steamVrLh = steamvr_lh.checked;
config.hidForwarding = hid_forwarding.checked;
Settings.debugGui = debug_gui.checked;
Settings.steamVrLh = steamvr_lh.checked;
Settings.hidForwarding = hid_forwarding.checked;
}
function load() {
if (config.scale > 0) {
scale_slider.value = Math.round(100 - config.scale * 100);
if (Settings.scale > 0) {
scale_slider.value = Math.round(100 - Settings.scale * 100);
} else {
scale_slider.value = 50;
}
debug_gui.checked = config.debugGui;
steamvr_lh.checked = config.steamVrLh;
hid_forwarding.checked = config.hidForwarding;
debug_gui.checked = Settings.debugGui;
steamvr_lh.checked = Settings.steamVrLh;
hid_forwarding.checked = Settings.hidForwarding;
openvr_combobox.load()
+3
View File
@@ -131,6 +131,7 @@ void Settings::load(const wivrn_server * server)
{
auto conf = server->jsonConfiguration();
m_jsonSettings = nlohmann::json::parse(conf.toUtf8());
m_originalSettings = m_jsonSettings;
if (not m_jsonSettings.is_object())
m_jsonSettings = nlohmann::json::object();
emitAllChanged();
@@ -513,6 +514,8 @@ bool Settings::can10bit() const
void Settings::save(wivrn_server * server)
{
server->setJsonConfiguration(QString::fromStdString(m_jsonSettings.dump(2)));
if (m_jsonSettings != m_originalSettings)
settingsChanged();
}
void Settings::restore_defaults()
+6 -1
View File
@@ -38,7 +38,8 @@ class wivrn_server;
class Settings : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_NAMED_ELEMENT(Settings)
QML_SINGLETON
public:
enum encoder_name
{
@@ -95,6 +96,7 @@ public:
SETTER_GETTER_NOTIFY(QString, openvr)
private:
nlohmann::json m_jsonSettings = nlohmann::json::object();
nlohmann::json m_originalSettings;
void emitAllChanged();
public:
@@ -117,6 +119,9 @@ public:
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 & codec_from_id(video_codec id);
Q_SIGNALS:
void settingsChanged();
};
#undef SETTER_GETTER_NOTIFY
+8
View File
@@ -280,6 +280,9 @@ void wivrn_server::on_server_dbus_unregistered()
if (isHeadsetConnected())
headsetConnectedChanged(m_headsetConnected = false);
if (isSessionRunning())
sessionRunningChanged(m_sessionRunning = false);
if (isPairingEnabled())
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());
}
if (changed_properties.contains("SessionRunning"))
{
sessionRunningChanged(m_sessionRunning = changed_properties["SessionRunning"].toBool());
}
if (changed_properties.contains("JsonConfiguration"))
{
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(bool capSysNice READ capSysNice NOTIFY capSysNiceChanged)
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 serverLogs READ serverLogs NOTIFY serverLogsChanged)
Q_INVOKABLE void start_server();
@@ -232,6 +233,11 @@ public:
return m_headsetConnected;
}
bool isSessionRunning() const
{
return m_sessionRunning;
}
QString jsonConfiguration() const
{
return m_jsonConfiguration;
@@ -351,6 +357,7 @@ private:
Status m_serverStatus{Status::Stopped};
bool m_capSysNice{};
bool m_headsetConnected{};
bool m_sessionRunning{};
QString m_jsonConfiguration{};
QString m_pin{};
@@ -376,6 +383,7 @@ Q_SIGNALS:
void serverStatusChanged(Status);
void capSysNiceChanged(bool);
void headsetConnectedChanged(bool);
void sessionRunningChanged(bool);
void jsonConfigurationChanged(QString);
void needMonadoVulkanLayerChanged(bool);
void pinChanged(QString);
+1
View File
@@ -42,6 +42,7 @@
<method name="DisablePairing"/>
<property name="HeadsetConnected" type="b" access="read"/>
<property name="SessionRunning" type="b" access="read"/>
<property name="SteamCommand" type="s" access="read"/>
<property name="JsonConfiguration" type="s" 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_kill_watch == 0);
wivrn_server_set_session_running(dbus_server, true);
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");
g_source_remove(server_watch);
if (server_kill_watch)