diff --git a/gui/include/qmlsettings.h b/gui/include/qmlsettings.h index 723684ec8..17fc09f58 100644 --- a/gui/include/qmlsettings.h +++ b/gui/include/qmlsettings.h @@ -41,6 +41,8 @@ class QmlSettings : public QObject Q_PROPERTY(QString audioOutDevice READ audioOutDevice WRITE setAudioOutDevice NOTIFY audioOutDeviceChanged) Q_PROPERTY(QString decoder READ decoder WRITE setDecoder NOTIFY decoderChanged) Q_PROPERTY(int windowType READ windowType WRITE setWindowType NOTIFY windowTypeChanged) + Q_PROPERTY(uint customResolutionWidth READ customResolutionWidth WRITE setCustomResolutionWidth NOTIFY customResolutionWidthChanged) + Q_PROPERTY(uint customResolutionHeight READ customResolutionHeight WRITE setCustomResolutionHeight NOTIFY customResolutionHeightChanged) Q_PROPERTY(int videoPreset READ videoPreset WRITE setVideoPreset NOTIFY videoPresetChanged) Q_PROPERTY(float sZoomFactor READ sZoomFactor WRITE setSZoomFactor NOTIFY sZoomFactorChanged) Q_PROPERTY(int packetLossMax READ packetLossMax WRITE setPacketLossMax NOTIFY packetLossMaxChanged) @@ -215,6 +217,12 @@ class QmlSettings : public QObject int windowType() const; void setWindowType(int type); + uint customResolutionWidth() const; + void setCustomResolutionWidth(uint width); + + uint customResolutionHeight() const; + void setCustomResolutionHeight(uint length); + float sZoomFactor() const; void setSZoomFactor(float factor); @@ -497,6 +505,8 @@ class QmlSettings : public QObject void wifiDroppedNotifChanged(); void decoderChanged(); void windowTypeChanged(); + void customResolutionWidthChanged(); + void customResolutionHeightChanged(); void sZoomFactorChanged(); void videoPresetChanged(); void autoConnectMacChanged(); diff --git a/gui/include/settings.h b/gui/include/settings.h index 6ec10551b..4b79f026d 100644 --- a/gui/include/settings.h +++ b/gui/include/settings.h @@ -67,6 +67,7 @@ enum class PlaceboPreset { enum class WindowType { SelectedResolution, + CustomResolution, Fullscreen, Zoom, Stretch @@ -291,6 +292,12 @@ class Settings : public QObject WindowType GetWindowType() const; void SetWindowType(WindowType type); + uint GetCustomResolutionWidth() const; + void SetCustomResolutionWidth(uint width); + + uint GetCustomResolutionHeight() const; + void SetCustomResolutionHeight(uint length); + PlaceboPreset GetPlaceboPreset() const; void SetPlaceboPreset(PlaceboPreset preset); diff --git a/gui/src/qml/SettingsDialog.qml b/gui/src/qml/SettingsDialog.qml index 2b7168bf5..d54032be2 100644 --- a/gui/src/qml/SettingsDialog.qml +++ b/gui/src/qml/SettingsDialog.qml @@ -286,14 +286,78 @@ DialogView { C.ComboBox { Layout.preferredWidth: 400 - model: [qsTr("Selected Resolution"), qsTr("Fullscreen"), qsTr("Zoom [adjust zoom using slider in stream menu]"), qsTr("Stretch")] + model: [qsTr("Stream Resolution"), qsTr("Custom Resolution"), qsTr("Fullscreen"), qsTr("Zoom [adjust zoom using slider in stream menu]"), qsTr("Stretch")] currentIndex: Chiaki.settings.windowType onActivated: (index) => Chiaki.settings.windowType = index; } Label { Layout.alignment: Qt.AlignRight - text: qsTr("(Selected Resolution)") + text: qsTr("(Stream Resolution)") + } + + Label { + Layout.alignment: Qt.AlignRight + text: qsTr("Custom Resolution Width") + visible: Chiaki.settings.windowType == 1 + } + + C.TextField { + id: customResolutionWidth + Layout.preferredWidth: 400 + visible: Chiaki.settings.windowType == 1 + text: Chiaki.settings.customResolutionWidth + Material.accent: text && !validate() ? Material.Red : undefined + onEditingFinished: { + if (validate()) { + Chiaki.settings.customResolutionWidth = parseInt(text); + } else { + Chiaki.settings.customResolutionWidth = 0; + text = ""; + } + } + function validate() { + var num = parseInt(text); + return num >= 0 && num <= 9999; + } + } + + Label { + Layout.alignment: Qt.AlignRight + text: qsTr("(1920)") + visible: Chiaki.settings.windowType == 1 + } + + Label { + Layout.alignment: Qt.AlignRight + text: qsTr("Custom Resolution Height") + visible: Chiaki.settings.windowType == 1 + } + + C.TextField { + id: customResolutionHeight + Layout.preferredWidth: 400 + visible: Chiaki.settings.windowType == 1 + text: Chiaki.settings.customResolutionHeight + Material.accent: text && !validate() ? Material.Red : undefined + onEditingFinished: { + if (validate()) { + Chiaki.settings.customResolutionHeight = parseInt(text); + } else { + Chiaki.settings.customResolutionHeight = 0; + text = ""; + } + } + function validate() { + var num = parseInt(text); + return num >= 0 && num <= 9999; + } + } + + Label { + Layout.alignment: Qt.AlignRight + text: qsTr("(1080)") + visible: Chiaki.settings.windowType == 1 } Label { diff --git a/gui/src/qmlbackend.cpp b/gui/src/qmlbackend.cpp index 83a846c45..b35e97ab2 100644 --- a/gui/src/qmlbackend.cpp +++ b/gui/src/qmlbackend.cpp @@ -775,7 +775,15 @@ void QmlBackend::createSession(const StreamSessionConnectInfo &connect_info) }); if (window->windowState() != Qt::WindowFullScreen) - window->resize(connect_info.video_profile.width, connect_info.video_profile.height); + { + if(settings->GetWindowType() == WindowType::CustomResolution) + { + window->resize(settings->GetCustomResolutionWidth(), settings->GetCustomResolutionHeight()); + window->setMaximumSize(QSize(settings->GetCustomResolutionWidth(), settings->GetCustomResolutionHeight())); + } + else + window->resize(connect_info.video_profile.width, connect_info.video_profile.height); + } chiaki_log_mutex.lock(); chiaki_log_ctx = session->GetChiakiLog(); @@ -1016,6 +1024,8 @@ void QmlBackend::connectToHost(int index, QString nickname) switch (settings->GetWindowType()) { case WindowType::SelectedResolution: break; + case WindowType::CustomResolution: + break; case WindowType::Fullscreen: fullscreen = true; break; diff --git a/gui/src/qmlmainwindow.cpp b/gui/src/qmlmainwindow.cpp index 7a55bf83b..dcf054faf 100644 --- a/gui/src/qmlmainwindow.cpp +++ b/gui/src/qmlmainwindow.cpp @@ -152,6 +152,8 @@ void QmlMainWindow::updateWindowType(WindowType type) switch (type) { case WindowType::SelectedResolution: break; + case WindowType::CustomResolution: + break; case WindowType::Fullscreen: showFullScreen(); break; @@ -270,8 +272,7 @@ void QmlMainWindow::show() QMetaObject::invokeMethod(QGuiApplication::instance(), &QGuiApplication::quit, Qt::QueuedConnection); return; } - - resize(1280, 720); + resize(1920, 1080); if (qEnvironmentVariable("XDG_CURRENT_DESKTOP") == "gamescope") showFullScreen(); diff --git a/gui/src/qmlsettings.cpp b/gui/src/qmlsettings.cpp index 437b4d17f..ded5f5023 100644 --- a/gui/src/qmlsettings.cpp +++ b/gui/src/qmlsettings.cpp @@ -380,6 +380,28 @@ void QmlSettings::setWindowType(int type) emit windowTypeChanged(); } +uint QmlSettings::customResolutionWidth() const +{ + return settings->GetCustomResolutionWidth(); +} + +void QmlSettings::setCustomResolutionWidth(uint width) +{ + settings->SetCustomResolutionWidth(width); + emit customResolutionWidthChanged(); +} + +uint QmlSettings::customResolutionHeight() const +{ + return settings->GetCustomResolutionHeight(); +} + +void QmlSettings::setCustomResolutionHeight(uint length) +{ + settings->SetCustomResolutionHeight(length); + emit customResolutionHeightChanged(); +} + float QmlSettings::sZoomFactor() const { return settings->GetZoomFactor(); @@ -1303,6 +1325,8 @@ void QmlSettings::refreshAllKeys() emit wifiDroppedNotifChanged(); emit decoderChanged(); emit windowTypeChanged(); + emit customResolutionWidthChanged(); + emit customResolutionHeightChanged(); emit sZoomFactorChanged(); emit videoPresetChanged(); emit autoConnectMacChanged(); diff --git a/gui/src/settings.cpp b/gui/src/settings.cpp index 56101a445..ee77b17e5 100644 --- a/gui/src/settings.cpp +++ b/gui/src/settings.cpp @@ -605,6 +605,7 @@ void Settings::SetPacketLossMax(float packet_loss_max) static const QMap window_type_values = { { WindowType::SelectedResolution, "Selected Resolution" }, + { WindowType::CustomResolution, "Custom Resolution"}, { WindowType::Fullscreen, "Fullscreen" }, { WindowType::Zoom, "Zoom" }, { WindowType::Stretch, "Stretch" } @@ -621,6 +622,26 @@ void Settings::SetWindowType(WindowType type) settings.setValue("settings/window_type", window_type_values[type]); } +uint Settings::GetCustomResolutionWidth() const +{ + return settings.value("settings/custom_resolution_width", 1920).toUInt(); +} + +void Settings::SetCustomResolutionWidth(uint width) +{ + settings.setValue("settings/custom_resolution_width", width); +} + +uint Settings::GetCustomResolutionHeight() const +{ + return settings.value("settings/custom_resolution_length", 1080).toUInt(); +} + +void Settings::SetCustomResolutionHeight(uint length) +{ + settings.setValue("settings/custom_resolution_length", length); +} + RegisteredHost Settings::GetAutoConnectHost() const { const QByteArray mac = settings.value("settings/auto_connect_mac").toByteArray();