mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-02 15:55:39 +00:00
Make StreamingPreferences accessible from QML for Settings integration
This commit is contained in:
parent
67eb09d753
commit
7023bcf504
@ -11,6 +11,7 @@
|
|||||||
#include "gui/computermodel.h"
|
#include "gui/computermodel.h"
|
||||||
#include "gui/appmodel.h"
|
#include "gui/appmodel.h"
|
||||||
#include "streaming/session.hpp"
|
#include "streaming/session.hpp"
|
||||||
|
#include "settings/streamingpreferences.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -36,6 +37,7 @@ int main(int argc, char *argv[])
|
|||||||
// Register our C++ types for QML
|
// Register our C++ types for QML
|
||||||
qmlRegisterType<ComputerModel>("ComputerModel", 1, 0, "ComputerModel");
|
qmlRegisterType<ComputerModel>("ComputerModel", 1, 0, "ComputerModel");
|
||||||
qmlRegisterType<AppModel>("AppModel", 1, 0, "AppModel");
|
qmlRegisterType<AppModel>("AppModel", 1, 0, "AppModel");
|
||||||
|
qmlRegisterType<StreamingPreferences>("StreamingPreferences", 1, 0, "StreamingPreferences");
|
||||||
qmlRegisterUncreatableType<Session>("Session", 1, 0, "Session", "Session cannot be created from QML");
|
qmlRegisterUncreatableType<Session>("Session", 1, 0, "Session", "Session cannot be created from QML");
|
||||||
qmlRegisterSingletonType<ComputerManager>("ComputerManager", 1, 0,
|
qmlRegisterSingletonType<ComputerManager>("ComputerManager", 1, 0,
|
||||||
"ComputerManager",
|
"ComputerManager",
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#define SER_MULTICONT "multicontroller"
|
#define SER_MULTICONT "multicontroller"
|
||||||
#define SER_AUDIOCFG "audiocfg"
|
#define SER_AUDIOCFG "audiocfg"
|
||||||
#define SER_VIDEOCFG "videocfg"
|
#define SER_VIDEOCFG "videocfg"
|
||||||
|
#define SER_VIDEODEC "videodec"
|
||||||
|
|
||||||
StreamingPreferences::StreamingPreferences()
|
StreamingPreferences::StreamingPreferences()
|
||||||
{
|
{
|
||||||
@ -28,13 +29,15 @@ void StreamingPreferences::reload()
|
|||||||
fps = settings.value(SER_FPS, 60).toInt();
|
fps = settings.value(SER_FPS, 60).toInt();
|
||||||
bitrateKbps = settings.value(SER_BITRATE, getDefaultBitrate(width, height, fps)).toInt();
|
bitrateKbps = settings.value(SER_BITRATE, getDefaultBitrate(width, height, fps)).toInt();
|
||||||
fullScreen = settings.value(SER_FULLSCREEN, true).toBool();
|
fullScreen = settings.value(SER_FULLSCREEN, true).toBool();
|
||||||
enableGameOptimizations = settings.value(SER_GAMEOPTS, true).toBool();
|
gameOptimizations = settings.value(SER_GAMEOPTS, true).toBool();
|
||||||
playAudioOnHost = settings.value(SER_HOSTAUDIO, false).toBool();
|
playAudioOnHost = settings.value(SER_HOSTAUDIO, false).toBool();
|
||||||
multiController = settings.value(SER_MULTICONT, true).toBool();
|
multiController = settings.value(SER_MULTICONT, true).toBool();
|
||||||
audioConfig = static_cast<AudioConfig>(settings.value(SER_AUDIOCFG,
|
audioConfig = static_cast<AudioConfig>(settings.value(SER_AUDIOCFG,
|
||||||
static_cast<int>(AudioConfig::AC_AUTO)).toInt());
|
static_cast<int>(AudioConfig::AC_AUTO)).toInt());
|
||||||
videoCodecConfig = static_cast<VideoCodecConfig>(settings.value(SER_VIDEOCFG,
|
videoCodecConfig = static_cast<VideoCodecConfig>(settings.value(SER_VIDEOCFG,
|
||||||
static_cast<int>(VideoCodecConfig::VCC_AUTO)).toInt());
|
static_cast<int>(VideoCodecConfig::VCC_AUTO)).toInt());
|
||||||
|
videoDecoderSelection = static_cast<VideoDecoderSelection>(settings.value(SER_VIDEODEC,
|
||||||
|
static_cast<int>(VideoDecoderSelection::VDS_AUTO)).toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
void StreamingPreferences::save()
|
void StreamingPreferences::save()
|
||||||
@ -46,11 +49,12 @@ void StreamingPreferences::save()
|
|||||||
settings.setValue(SER_FPS, fps);
|
settings.setValue(SER_FPS, fps);
|
||||||
settings.setValue(SER_BITRATE, bitrateKbps);
|
settings.setValue(SER_BITRATE, bitrateKbps);
|
||||||
settings.setValue(SER_FULLSCREEN, fullScreen);
|
settings.setValue(SER_FULLSCREEN, fullScreen);
|
||||||
settings.setValue(SER_GAMEOPTS, enableGameOptimizations);
|
settings.setValue(SER_GAMEOPTS, gameOptimizations);
|
||||||
settings.setValue(SER_HOSTAUDIO, playAudioOnHost);
|
settings.setValue(SER_HOSTAUDIO, playAudioOnHost);
|
||||||
settings.setValue(SER_MULTICONT, multiController);
|
settings.setValue(SER_MULTICONT, multiController);
|
||||||
settings.setValue(SER_AUDIOCFG, static_cast<int>(audioConfig));
|
settings.setValue(SER_AUDIOCFG, static_cast<int>(audioConfig));
|
||||||
settings.setValue(SER_VIDEOCFG, static_cast<int>(videoCodecConfig));
|
settings.setValue(SER_VIDEOCFG, static_cast<int>(videoCodecConfig));
|
||||||
|
settings.setValue(SER_VIDEODEC, static_cast<int>(videoDecoderSelection));
|
||||||
}
|
}
|
||||||
|
|
||||||
int StreamingPreferences::getDefaultBitrate(int width, int height, int fps)
|
int StreamingPreferences::getDefaultBitrate(int width, int height, int fps)
|
||||||
|
@ -1,14 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class StreamingPreferences
|
#include <QObject>
|
||||||
|
|
||||||
|
class StreamingPreferences : public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StreamingPreferences();
|
StreamingPreferences();
|
||||||
|
|
||||||
static int
|
Q_INVOKABLE static int
|
||||||
getDefaultBitrate(int width, int height, int fps);
|
getDefaultBitrate(int width, int height, int fps);
|
||||||
|
|
||||||
void save();
|
Q_INVOKABLE void save();
|
||||||
|
|
||||||
void reload();
|
void reload();
|
||||||
|
|
||||||
@ -18,6 +22,7 @@ public:
|
|||||||
AC_FORCE_STEREO,
|
AC_FORCE_STEREO,
|
||||||
AC_FORCE_SURROUND
|
AC_FORCE_SURROUND
|
||||||
};
|
};
|
||||||
|
Q_ENUM(AudioConfig)
|
||||||
|
|
||||||
enum VideoCodecConfig
|
enum VideoCodecConfig
|
||||||
{
|
{
|
||||||
@ -26,6 +31,27 @@ public:
|
|||||||
VCC_FORCE_HEVC,
|
VCC_FORCE_HEVC,
|
||||||
VCC_FORCE_HEVC_HDR
|
VCC_FORCE_HEVC_HDR
|
||||||
};
|
};
|
||||||
|
Q_ENUM(VideoCodecConfig)
|
||||||
|
|
||||||
|
enum VideoDecoderSelection
|
||||||
|
{
|
||||||
|
VDS_AUTO,
|
||||||
|
VDS_FORCE_HARDWARE,
|
||||||
|
VDS_FORCE_SOFTWARE
|
||||||
|
};
|
||||||
|
Q_ENUM(VideoDecoderSelection)
|
||||||
|
|
||||||
|
Q_PROPERTY(int width MEMBER width NOTIFY resolutionOrFpsChanged)
|
||||||
|
Q_PROPERTY(int height MEMBER height NOTIFY resolutionOrFpsChanged)
|
||||||
|
Q_PROPERTY(int fps MEMBER fps NOTIFY resolutionOrFpsChanged)
|
||||||
|
Q_PROPERTY(int bitrateKbps MEMBER bitrateKbps NOTIFY bitrateChanged)
|
||||||
|
Q_PROPERTY(bool fullScreen MEMBER fullScreen NOTIFY fullScreenChanged)
|
||||||
|
Q_PROPERTY(bool gameOptimizations MEMBER gameOptimizations NOTIFY gameOptimizationsChanged)
|
||||||
|
Q_PROPERTY(bool playAudioOnHost MEMBER playAudioOnHost NOTIFY playAudioOnHostChanged)
|
||||||
|
Q_PROPERTY(bool multiController MEMBER multiController NOTIFY multiControllerChanged)
|
||||||
|
Q_PROPERTY(AudioConfig audioConfig MEMBER audioConfig NOTIFY audioConfigChanged)
|
||||||
|
Q_PROPERTY(VideoCodecConfig videoCodecConfig MEMBER videoCodecConfig NOTIFY videoCodecConfigChanged)
|
||||||
|
Q_PROPERTY(VideoDecoderSelection videoDecoderSelection MEMBER videoDecoderSelection NOTIFY videoDecoderSelectionChanged)
|
||||||
|
|
||||||
// Directly accessible members for preferences
|
// Directly accessible members for preferences
|
||||||
int width;
|
int width;
|
||||||
@ -33,10 +59,22 @@ public:
|
|||||||
int fps;
|
int fps;
|
||||||
int bitrateKbps;
|
int bitrateKbps;
|
||||||
bool fullScreen;
|
bool fullScreen;
|
||||||
bool enableGameOptimizations;
|
bool gameOptimizations;
|
||||||
bool playAudioOnHost;
|
bool playAudioOnHost;
|
||||||
bool multiController;
|
bool multiController;
|
||||||
AudioConfig audioConfig;
|
AudioConfig audioConfig;
|
||||||
VideoCodecConfig videoCodecConfig;
|
VideoCodecConfig videoCodecConfig;
|
||||||
|
VideoDecoderSelection videoDecoderSelection;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void resolutionOrFpsChanged();
|
||||||
|
void bitrateChanged();
|
||||||
|
void fullScreenChanged();
|
||||||
|
void gameOptimizationsChanged();
|
||||||
|
void playAudioOnHostChanged();
|
||||||
|
void multiControllerChanged();
|
||||||
|
void audioConfigChanged();
|
||||||
|
void videoCodecConfigChanged();
|
||||||
|
void videoDecoderSelectionChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ void Session::exec()
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
http.launchApp(m_App.id, &m_StreamConfig,
|
http.launchApp(m_App.id, &m_StreamConfig,
|
||||||
prefs.enableGameOptimizations,
|
prefs.gameOptimizations,
|
||||||
prefs.playAudioOnHost,
|
prefs.playAudioOnHost,
|
||||||
inputHandler.getAttachedGamepadMask());
|
inputHandler.getAttachedGamepadMask());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user