mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-18 06:30:55 +00:00
Add option to allow PC to sleep while streaming
This commit is contained in:
@@ -312,6 +312,7 @@ void StreamCommandLineParser::parse(const QStringList &args, StreamingPreference
|
|||||||
parser.addToggleOption("background-gamepad", "background gamepad input");
|
parser.addToggleOption("background-gamepad", "background gamepad input");
|
||||||
parser.addToggleOption("reverse-scroll-direction", "inverted scroll direction");
|
parser.addToggleOption("reverse-scroll-direction", "inverted scroll direction");
|
||||||
parser.addToggleOption("swap-gamepad-buttons", "swap A/B and X/Y gamepad buttons (Nintendo-style)");
|
parser.addToggleOption("swap-gamepad-buttons", "swap A/B and X/Y gamepad buttons (Nintendo-style)");
|
||||||
|
parser.addToggleOption("keep-awake", "prevent display sleep while streaming");
|
||||||
parser.addChoiceOption("capture-system-keys", "capture system key combos", m_CaptureSysKeysModeMap.keys());
|
parser.addChoiceOption("capture-system-keys", "capture system key combos", m_CaptureSysKeysModeMap.keys());
|
||||||
parser.addChoiceOption("video-codec", "video codec", m_VideoCodecMap.keys());
|
parser.addChoiceOption("video-codec", "video codec", m_VideoCodecMap.keys());
|
||||||
parser.addChoiceOption("video-decoder", "video decoder", m_VideoDecoderMap.keys());
|
parser.addChoiceOption("video-decoder", "video decoder", m_VideoDecoderMap.keys());
|
||||||
@@ -423,6 +424,9 @@ void StreamCommandLineParser::parse(const QStringList &args, StreamingPreference
|
|||||||
// Resolve --swap-gamepad-buttons and --no-swap-gamepad-buttons options
|
// Resolve --swap-gamepad-buttons and --no-swap-gamepad-buttons options
|
||||||
preferences->swapFaceButtons = parser.getToggleOptionValue("swap-gamepad-buttons", preferences->swapFaceButtons);
|
preferences->swapFaceButtons = parser.getToggleOptionValue("swap-gamepad-buttons", preferences->swapFaceButtons);
|
||||||
|
|
||||||
|
// Resolve --keep-awake and --no-keep-awake options
|
||||||
|
preferences->keepAwake = parser.getToggleOptionValue("keep-awake", preferences->keepAwake);
|
||||||
|
|
||||||
// Resolve --capture-system-keys option
|
// Resolve --capture-system-keys option
|
||||||
if (parser.isSet("capture-system-keys")) {
|
if (parser.isSet("capture-system-keys")) {
|
||||||
preferences->captureSysKeysMode = mapValue(m_CaptureSysKeysModeMap, parser.getChoiceOptionValue("capture-system-keys"));
|
preferences->captureSysKeysMode = mapValue(m_CaptureSysKeysModeMap, parser.getChoiceOptionValue("capture-system-keys"));
|
||||||
|
|||||||
@@ -953,6 +953,23 @@ Flickable {
|
|||||||
ToolTip.visible: hovered
|
ToolTip.visible: hovered
|
||||||
ToolTip.text: qsTr("Updates your Discord status to display the name of the game you're streaming.")
|
ToolTip.text: qsTr("Updates your Discord status to display the name of the game you're streaming.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckBox {
|
||||||
|
visible: SystemProperties.hasDesktopEnvironment
|
||||||
|
id: keepAwakeCheck
|
||||||
|
width: parent.width
|
||||||
|
text: qsTr("Keep PC awake while streaming")
|
||||||
|
font.pointSize: 12
|
||||||
|
checked: StreamingPreferences.keepAwake
|
||||||
|
onCheckedChanged: {
|
||||||
|
StreamingPreferences.keepAwake = checked
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolTip.delay: 1000
|
||||||
|
ToolTip.timeout: 5000
|
||||||
|
ToolTip.visible: hovered
|
||||||
|
ToolTip.text: qsTr("Prevents the display from going to sleep while a stream is active.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
#define SER_REVERSESCROLL "reversescroll"
|
#define SER_REVERSESCROLL "reversescroll"
|
||||||
#define SER_SWAPFACEBUTTONS "swapfacebuttons"
|
#define SER_SWAPFACEBUTTONS "swapfacebuttons"
|
||||||
#define SER_CAPTURESYSKEYS "capturesyskeys"
|
#define SER_CAPTURESYSKEYS "capturesyskeys"
|
||||||
|
#define SER_KEEPAWAKE "keepawake"
|
||||||
#define SER_LANGUAGE "language"
|
#define SER_LANGUAGE "language"
|
||||||
|
|
||||||
#define CURRENT_DEFAULT_VER 1
|
#define CURRENT_DEFAULT_VER 1
|
||||||
@@ -95,6 +96,7 @@ void StreamingPreferences::reload()
|
|||||||
backgroundGamepad = settings.value(SER_BACKGROUNDGAMEPAD, false).toBool();
|
backgroundGamepad = settings.value(SER_BACKGROUNDGAMEPAD, false).toBool();
|
||||||
reverseScrollDirection = settings.value(SER_REVERSESCROLL, false).toBool();
|
reverseScrollDirection = settings.value(SER_REVERSESCROLL, false).toBool();
|
||||||
swapFaceButtons = settings.value(SER_SWAPFACEBUTTONS, false).toBool();
|
swapFaceButtons = settings.value(SER_SWAPFACEBUTTONS, false).toBool();
|
||||||
|
keepAwake = settings.value(SER_KEEPAWAKE, true).toBool();
|
||||||
captureSysKeysMode = static_cast<CaptureSysKeysMode>(settings.value(SER_CAPTURESYSKEYS,
|
captureSysKeysMode = static_cast<CaptureSysKeysMode>(settings.value(SER_CAPTURESYSKEYS,
|
||||||
static_cast<int>(CaptureSysKeysMode::CSK_OFF)).toInt());
|
static_cast<int>(CaptureSysKeysMode::CSK_OFF)).toInt());
|
||||||
audioConfig = static_cast<AudioConfig>(settings.value(SER_AUDIOCFG,
|
audioConfig = static_cast<AudioConfig>(settings.value(SER_AUDIOCFG,
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ public:
|
|||||||
Q_PROPERTY(bool backgroundGamepad MEMBER backgroundGamepad NOTIFY backgroundGamepadChanged)
|
Q_PROPERTY(bool backgroundGamepad MEMBER backgroundGamepad NOTIFY backgroundGamepadChanged)
|
||||||
Q_PROPERTY(bool reverseScrollDirection MEMBER reverseScrollDirection NOTIFY reverseScrollDirectionChanged)
|
Q_PROPERTY(bool reverseScrollDirection MEMBER reverseScrollDirection NOTIFY reverseScrollDirectionChanged)
|
||||||
Q_PROPERTY(bool swapFaceButtons MEMBER swapFaceButtons NOTIFY swapFaceButtonsChanged)
|
Q_PROPERTY(bool swapFaceButtons MEMBER swapFaceButtons NOTIFY swapFaceButtonsChanged)
|
||||||
|
Q_PROPERTY(bool keepAwake MEMBER keepAwake NOTIFY keepAwakeChanged)
|
||||||
Q_PROPERTY(CaptureSysKeysMode captureSysKeysMode MEMBER captureSysKeysMode NOTIFY captureSysKeysModeChanged)
|
Q_PROPERTY(CaptureSysKeysMode captureSysKeysMode MEMBER captureSysKeysMode NOTIFY captureSysKeysModeChanged)
|
||||||
Q_PROPERTY(Language language MEMBER language NOTIFY languageChanged);
|
Q_PROPERTY(Language language MEMBER language NOTIFY languageChanged);
|
||||||
|
|
||||||
@@ -157,6 +158,7 @@ public:
|
|||||||
bool backgroundGamepad;
|
bool backgroundGamepad;
|
||||||
bool reverseScrollDirection;
|
bool reverseScrollDirection;
|
||||||
bool swapFaceButtons;
|
bool swapFaceButtons;
|
||||||
|
bool keepAwake;
|
||||||
int packetSize;
|
int packetSize;
|
||||||
AudioConfig audioConfig;
|
AudioConfig audioConfig;
|
||||||
VideoCodecConfig videoCodecConfig;
|
VideoCodecConfig videoCodecConfig;
|
||||||
@@ -195,6 +197,7 @@ signals:
|
|||||||
void reverseScrollDirectionChanged();
|
void reverseScrollDirectionChanged();
|
||||||
void swapFaceButtonsChanged();
|
void swapFaceButtonsChanged();
|
||||||
void captureSysKeysModeChanged();
|
void captureSysKeysModeChanged();
|
||||||
|
void keepAwakeChanged();
|
||||||
void languageChanged();
|
void languageChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -1468,8 +1468,10 @@ void Session::execInternal()
|
|||||||
// on macOS.
|
// on macOS.
|
||||||
SDL_StopTextInput();
|
SDL_StopTextInput();
|
||||||
|
|
||||||
// Disable the screen saver
|
// Disable the screen saver if requested or running as embedded platform
|
||||||
SDL_DisableScreenSaver();
|
if (m_Preferences->keepAwake || !WMUtils::isRunningDesktopEnvironment()) {
|
||||||
|
SDL_DisableScreenSaver();
|
||||||
|
}
|
||||||
|
|
||||||
// Hide Qt's fake mouse cursor on EGLFS systems
|
// Hide Qt's fake mouse cursor on EGLFS systems
|
||||||
if (QGuiApplication::platformName() == "eglfs") {
|
if (QGuiApplication::platformName() == "eglfs") {
|
||||||
|
|||||||
Reference in New Issue
Block a user