未验证 提交 e338b44a 编写于 作者: J Jim 提交者: GitHub

Merge pull request #2305 from cg2121/aspect-ratios

UI: Display aspect ratios in video settings
...@@ -92,6 +92,7 @@ Calculating="Calculating..." ...@@ -92,6 +92,7 @@ Calculating="Calculating..."
Fullscreen="Fullscreen" Fullscreen="Fullscreen"
Windowed="Windowed" Windowed="Windowed"
Percent="Percent" Percent="Percent"
AspectRatio="Aspect Ratio <b>%1:%2</b>"
# warning if program already open # warning if program already open
AlreadyRunning.Title="OBS is already running" AlreadyRunning.Title="OBS is already running"
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>981</width> <width>981</width>
<height>748</height> <height>726</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item alignment="Qt::AlignLeft"> <item>
<widget class="QListWidget" name="listWidget"> <widget class="QListWidget" name="listWidget">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding"> <sizepolicy hsizetype="Minimum" vsizetype="Expanding">
...@@ -151,8 +151,8 @@ ...@@ -151,8 +151,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>803</width> <width>806</width>
<height>977</height> <height>1254</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_19"> <layout class="QVBoxLayout" name="verticalLayout_19">
...@@ -1206,8 +1206,8 @@ ...@@ -1206,8 +1206,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>601</width> <width>813</width>
<height>631</height> <height>761</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_21"> <layout class="QVBoxLayout" name="verticalLayout_21">
...@@ -2345,8 +2345,8 @@ ...@@ -2345,8 +2345,8 @@
<rect> <rect>
<x>9</x> <x>9</x>
<y>0</y> <y>0</y>
<width>221</width> <width>236</width>
<height>21</height> <height>25</height>
</rect> </rect>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_24"> <layout class="QHBoxLayout" name="horizontalLayout_24">
...@@ -3715,8 +3715,8 @@ ...@@ -3715,8 +3715,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>555</width> <width>767</width>
<height>469</height> <height>582</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_50"> <layout class="QVBoxLayout" name="verticalLayout_50">
...@@ -4200,22 +4200,42 @@ ...@@ -4200,22 +4200,42 @@
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QComboBox" name="baseResolution"> <layout class="QHBoxLayout" name="horizontalLayout_29">
<property name="editable"> <property name="spacing">
<bool>true</bool> <number>6</number>
</property>
<property name="currentText">
<string notr="true"/>
</property>
<property name="duplicatesEnabled">
<bool>false</bool>
</property>
<property name="frame">
<bool>true</bool>
</property> </property>
</widget> <item>
<widget class="QComboBox" name="baseResolution">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
<property name="currentText">
<string notr="true"/>
</property>
<property name="duplicatesEnabled">
<bool>false</bool>
</property>
<property name="frame">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="baseAspect">
<property name="text">
<string>AspectRatio</string>
</property>
</widget>
</item>
</layout>
</item> </item>
<item row="1" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_10"> <widget class="QLabel" name="label_10">
<property name="text"> <property name="text">
<string>Basic.Settings.Video.ScaledResolution</string> <string>Basic.Settings.Video.ScaledResolution</string>
...@@ -4225,17 +4245,7 @@ ...@@ -4225,17 +4245,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="5" column="0">
<widget class="QComboBox" name="outputResolution">
<property name="editable">
<bool>true</bool>
</property>
<property name="currentText">
<string notr="true"/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_11"> <widget class="QLabel" name="label_11">
<property name="text"> <property name="text">
<string>Basic.Settings.Video.DownscaleFilter</string> <string>Basic.Settings.Video.DownscaleFilter</string>
...@@ -4245,14 +4255,14 @@ ...@@ -4245,14 +4255,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="5" column="1">
<widget class="QComboBox" name="downscaleFilter"> <widget class="QComboBox" name="downscaleFilter">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="6" column="0">
<widget class="QComboBox" name="fpsType"> <widget class="QComboBox" name="fpsType">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
...@@ -4283,7 +4293,7 @@ ...@@ -4283,7 +4293,7 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="6" column="1">
<widget class="QStackedWidget" name="fpsTypes"> <widget class="QStackedWidget" name="fpsTypes">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>1</number>
...@@ -4454,7 +4464,7 @@ ...@@ -4454,7 +4464,7 @@
</widget> </widget>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="7" column="1">
<widget class="QLabel" name="videoMsg"> <widget class="QLabel" name="videoMsg">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
...@@ -4473,6 +4483,36 @@ ...@@ -4473,6 +4483,36 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_28">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QComboBox" name="outputResolution">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
<property name="currentText">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="scaledAspect">
<property name="text">
<string>AspectRatio</string>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QScrollArea" name="hotkeyPage"> <widget class="QScrollArea" name="hotkeyPage">
...@@ -4531,8 +4571,8 @@ ...@@ -4531,8 +4571,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>803</width> <width>791</width>
<height>781</height> <height>970</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_23"> <layout class="QVBoxLayout" name="verticalLayout_23">
...@@ -5485,8 +5525,6 @@ ...@@ -5485,8 +5525,6 @@
<tabstop>peakMeterType</tabstop> <tabstop>peakMeterType</tabstop>
<tabstop>monitoringDevice</tabstop> <tabstop>monitoringDevice</tabstop>
<tabstop>disableAudioDucking</tabstop> <tabstop>disableAudioDucking</tabstop>
<tabstop>baseResolution</tabstop>
<tabstop>outputResolution</tabstop>
<tabstop>downscaleFilter</tabstop> <tabstop>downscaleFilter</tabstop>
<tabstop>fpsType</tabstop> <tabstop>fpsType</tabstop>
<tabstop>fpsCommon</tabstop> <tabstop>fpsCommon</tabstop>
......
...@@ -760,6 +760,8 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent) ...@@ -760,6 +760,8 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
UpdateAutomaticReplayBufferCheckboxes(); UpdateAutomaticReplayBufferCheckboxes();
on_baseResolution_editTextChanged(ui->baseResolution->currentText());
App()->DisableHotkeys(); App()->DisableHotkeys();
} }
...@@ -1315,10 +1317,13 @@ void OBSBasicSettings::ResetDownscales(uint32_t cx, uint32_t cy) ...@@ -1315,10 +1317,13 @@ void OBSBasicSettings::ResetDownscales(uint32_t cx, uint32_t cy)
float outputAspect = float(out_cx) / float(out_cy); float outputAspect = float(out_cx) / float(out_cy);
bool closeAspect = close_float(baseAspect, outputAspect, 0.01f); bool closeAspect = close_float(baseAspect, outputAspect, 0.01f);
if (closeAspect) if (closeAspect) {
ui->outputResolution->lineEdit()->setText(oldOutputRes); ui->outputResolution->lineEdit()->setText(oldOutputRes);
else on_outputResolution_editTextChanged(oldOutputRes);
} else {
ui->outputResolution->lineEdit()->setText(bestScale.c_str()); ui->outputResolution->lineEdit()->setText(bestScale.c_str());
on_outputResolution_editTextChanged(bestScale.c_str());
}
ui->outputResolution->blockSignals(false); ui->outputResolution->blockSignals(false);
...@@ -3745,6 +3750,25 @@ static bool ValidResolutions(Ui::OBSBasicSettings *ui) ...@@ -3745,6 +3750,25 @@ static bool ValidResolutions(Ui::OBSBasicSettings *ui)
return true; return true;
} }
static int gcd(int a, int b)
{
return b == 0 ? a : gcd(b, a % b);
}
static std::tuple<int, int> aspect_ratio(int cx, int cy)
{
int common = gcd(cx, cy);
int newCX = cx / common;
int newCY = cy / common;
if (newCX == 8 && newCY == 5) {
newCX = 16;
newCY = 10;
}
return std::make_tuple(newCX, newCY);
}
void OBSBasicSettings::RecalcOutputResPixels(const char *resText) void OBSBasicSettings::RecalcOutputResPixels(const char *resText)
{ {
uint32_t newCX; uint32_t newCX;
...@@ -3754,6 +3778,13 @@ void OBSBasicSettings::RecalcOutputResPixels(const char *resText) ...@@ -3754,6 +3778,13 @@ void OBSBasicSettings::RecalcOutputResPixels(const char *resText)
if (newCX && newCY) { if (newCX && newCY) {
outputCX = newCX; outputCX = newCX;
outputCY = newCY; outputCY = newCY;
std::tuple<int, int> aspect = aspect_ratio(outputCX, outputCY);
ui->scaledAspect->setText(
QTStr("AspectRatio")
.arg(QString::number(std::get<0>(aspect)),
QString::number(std::get<1>(aspect))));
} }
} }
...@@ -3785,6 +3816,14 @@ void OBSBasicSettings::on_baseResolution_editTextChanged(const QString &text) ...@@ -3785,6 +3816,14 @@ void OBSBasicSettings::on_baseResolution_editTextChanged(const QString &text)
uint32_t cx, cy; uint32_t cx, cy;
ConvertResText(QT_TO_UTF8(baseResolution), cx, cy); ConvertResText(QT_TO_UTF8(baseResolution), cx, cy);
std::tuple<int, int> aspect = aspect_ratio(cx, cy);
ui->baseAspect->setText(
QTStr("AspectRatio")
.arg(QString::number(std::get<0>(aspect)),
QString::number(std::get<1>(aspect))));
ResetDownscales(cx, cy); ResetDownscales(cx, cy);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册