Rework settings GUI

Only allow simple encoder configuration in GUI, now with 10-bit encoding
checkbox.
This commit is contained in:
Patrick Nicolas
2025-10-29 23:59:18 +01:00
parent 3c91e4eca8
commit 16076a05c8
7 changed files with 521 additions and 1489 deletions
+49 -95
View File
@@ -26,114 +26,63 @@
#include <nlohmann/json.hpp>
#include <qqmlintegration.h>
#define SETTER_GETTER_NOTIFY(type, prop_name) \
private: \
type m_##prop_name; \
\
public: \
const type & prop_name() const \
{ \
return m_##prop_name; \
} \
void set_##prop_name(const type & value) \
{ \
m_##prop_name = value; \
prop_name##Changed(value); \
} \
Q_SIGNALS: \
void prop_name##Changed(const type &);
#define SETTER_GETTER_NOTIFY(type, prop_name) \
public: \
type prop_name() const; \
void set_##prop_name(const type & value); \
Q_SIGNALS: \
void prop_name##Changed();
class wivrn_server;
struct encoder
{
enum class video_codec
{
h264,
h265,
av1,
};
enum class encoder_name
{
nvenc,
vaapi,
x264,
vulkan
};
std::optional<encoder_name> name;
double width;
double height;
double offset_x;
double offset_y;
std::optional<int> group;
std::optional<video_codec> codec;
std::map<std::string, std::string> options;
std::optional<std::string> device;
double top() const
{
return offset_y;
}
void set_top(double value)
{
height = bottom() - value;
offset_y = value;
}
double bottom() const
{
return offset_y + height;
}
void set_bottom(double value)
{
height = value - top();
}
double left() const
{
return offset_x;
}
void set_left(double value)
{
width = right() - value;
offset_x = value;
}
double right() const
{
return offset_x + width;
}
void set_right(double value)
{
width = value - left();
}
};
class Settings : public QObject
{
Q_OBJECT
QML_ELEMENT
public:
enum encoder_name
{
EncoderAuto,
Nvenc,
Vaapi,
X264,
Vulkan,
};
Q_ENUM(encoder_name)
Q_PROPERTY(bool manualEncoders READ manualEncoders WRITE set_manualEncoders NOTIFY manualEncodersChanged)
Q_PROPERTY(std::vector<encoder> encoders READ encoders WRITE set_encoders NOTIFY encodersChanged)
Q_PROPERTY(encoder encoderPassthrough READ encoderPassthrough WRITE set_encoderPassthrough NOTIFY encoderPassthroughChanged)
enum video_codec
{
CodecAuto,
H264,
H265,
Av1,
};
Q_ENUM(video_codec)
Q_PROPERTY(bool simpleConfig READ simpleConfig NOTIFY simpleConfigChanged)
Q_PROPERTY(encoder_name encoder READ encoder WRITE set_encoder NOTIFY encoderChanged)
Q_PROPERTY(video_codec codec READ codec WRITE set_codec NOTIFY codecChanged)
Q_PROPERTY(QList<video_codec> allowedCodecs READ allowedCodecs NOTIFY encoderChanged)
Q_PROPERTY(bool can10bit READ can10bit NOTIFY codecChanged)
Q_PROPERTY(bool tenbit READ tenbit WRITE set_tenbit NOTIFY tenbitChanged)
Q_PROPERTY(int bitrate READ bitrate WRITE set_bitrate NOTIFY bitrateChanged)
Q_PROPERTY(float scale READ scale WRITE set_scale NOTIFY scaleChanged)
Q_PROPERTY(bool tcpOnly READ tcpOnly WRITE set_tcpOnly NOTIFY tcpOnlyChanged)
Q_PROPERTY(QString application READ application WRITE set_application NOTIFY applicationChanged)
Q_PROPERTY(QString openvr READ openvr WRITE set_openvr NOTIFY openvrChanged)
Q_PROPERTY(bool debugGui READ debugGui WRITE set_debugGui NOTIFY debugGuiChanged)
Q_PROPERTY(bool steamVrLh READ steamVrLh WRITE set_steamVrLh NOTIFY steamVrLhChanged)
Q_PROPERTY(bool tcpOnly READ tcpOnly WRITE set_tcpOnly NOTIFY tcpOnlyChanged)
Q_PROPERTY(QString openvr READ openvr WRITE set_openvr NOTIFY openvrChanged)
Q_PROPERTY(bool flatpak READ flatpak CONSTANT)
Q_PROPERTY(bool debug_gui_supported READ debug_gui CONSTANT)
Q_PROPERTY(bool steamvr_lh_supported READ steamvr_lh CONSTANT)
SETTER_GETTER_NOTIFY(bool, manualEncoders)
SETTER_GETTER_NOTIFY(std::vector<encoder>, encoders)
SETTER_GETTER_NOTIFY(encoder, encoderPassthrough)
SETTER_GETTER_NOTIFY(bool, simpleConfig)
SETTER_GETTER_NOTIFY(encoder_name, encoder)
SETTER_GETTER_NOTIFY(video_codec, codec)
SETTER_GETTER_NOTIFY(bool, tenbit)
SETTER_GETTER_NOTIFY(int, bitrate)
SETTER_GETTER_NOTIFY(float, scale)
SETTER_GETTER_NOTIFY(QString, application)
@@ -141,6 +90,9 @@ class Settings : public QObject
SETTER_GETTER_NOTIFY(bool, steamVrLh)
SETTER_GETTER_NOTIFY(bool, tcpOnly)
SETTER_GETTER_NOTIFY(QString, openvr)
private:
nlohmann::json m_jsonSettings = nlohmann::json::object();
void emitAllChanged();
public:
Settings(QObject * parent = nullptr) :
@@ -149,16 +101,18 @@ public:
Q_INVOKABLE void load(const wivrn_server * server);
Q_INVOKABLE void save(wivrn_server * server);
Q_INVOKABLE void restore_defaults();
Q_INVOKABLE void set_encoder_preset(QJSValue preset);
QList<video_codec> allowedCodecs() const;
bool can10bit() const;
bool flatpak() const;
bool debug_gui() const;
bool steamvr_lh() const;
static std::optional<encoder::encoder_name> encoder_id_from_string(std::string_view s);
static std::optional<encoder::video_codec> codec_id_from_string(std::string_view s);
static const std::string & encoder_from_id(std::optional<encoder::encoder_name> id);
static const std::string & codec_from_id(std::optional<encoder::video_codec> id);
static encoder_name encoder_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 & codec_from_id(video_codec id);
};
#undef SETTER_GETTER_NOTIFY