Browse Source

UI: Fix aspect ratio triggering settings change

Clayton Groeneveld 5 years ago
parent
commit
46db0c0823
1 changed files with 26 additions and 21 deletions
  1. 26 21
      UI/window-basic-settings.cpp

+ 26 - 21
UI/window-basic-settings.cpp

@@ -247,6 +247,25 @@ static void PopulateAACBitrates(initializer_list<QComboBox *> boxes)
 	}
 }
 
+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 RestrictResetBitrates(initializer_list<QComboBox *> boxes, int maxbitrate);
 
 void OBSBasicSettings::HookWidget(QWidget *widget, const char *signal,
@@ -760,8 +779,6 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
 
 	UpdateAutomaticReplayBufferCheckboxes();
 
-	on_baseResolution_editTextChanged(ui->baseResolution->currentText());
-
 	App()->DisableHotkeys();
 
 	channelIndex = ui->channelSetup->currentIndex();
@@ -1406,6 +1423,13 @@ void OBSBasicSettings::LoadResolutionLists()
 	ResetDownscales(cx, cy);
 
 	ui->outputResolution->lineEdit()->setText(outputResString.c_str());
+
+	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))));
 }
 
 static inline void LoadFPSCommon(OBSBasic *main, Ui::OBSBasicSettings *ui)
@@ -3753,25 +3777,6 @@ static bool ValidResolutions(Ui::OBSBasicSettings *ui)
 	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)
 {
 	uint32_t newCX;