Ver Fonte

Revert "UI: Remove "Resize output (source size)" menu"

This reverts commit 829e906ac2b15d822173009cde5c90b5ec6c04c1.
derrod há 3 anos atrás
pai
commit
e8dc70d0ee
3 ficheiros alterados com 53 adições e 0 exclusões
  1. 5 0
      UI/data/locale/en-US.ini
  2. 46 0
      UI/window-basic-main.cpp
  3. 2 0
      UI/window-basic-main.hpp

+ 5 - 0
UI/data/locale/en-US.ini

@@ -1285,6 +1285,11 @@ AddUrl.Title="Add Source via URL"
 AddUrl.Text="You have dragged a URL into OBS. This will automatically add the link as a source. Continue?"
 AddUrl.Text.Url="URL: %1"
 
+# Dynamic output size
+ResizeOutputSizeOfSource="Resize output (source size)"
+ResizeOutputSizeOfSource.Text="The base and output resolutions will be resized to the size of the current source."
+ResizeOutputSizeOfSource.Continue="Do you want to continue?"
+
 PreviewTransition="Preview Transition"
 
 # Import Dialog

+ 46 - 0
UI/window-basic-main.cpp

@@ -5642,6 +5642,18 @@ void OBSBasic::CreateSourcePopupMenu(int idx, bool preview)
 			popup.addSeparator();
 		}
 
+		QAction *resizeOutput =
+			popup.addAction(QTStr("ResizeOutputSizeOfSource"), this,
+					SLOT(ResizeOutputSizeOfSource()));
+
+		int width = obs_source_get_width(source);
+		int height = obs_source_get_height(source);
+
+		resizeOutput->setEnabled(!obs_video_active());
+
+		if (width < 8 || height < 8)
+			resizeOutput->setEnabled(false);
+
 		scaleFilteringMenu = new QMenu(QTStr("ScaleFiltering"));
 		popup.addMenu(
 			AddScaleFilteringMenu(scaleFilteringMenu, sceneItem));
@@ -9725,6 +9737,40 @@ void OBSBasic::on_actionShowAbout_triggered()
 	about->setAttribute(Qt::WA_DeleteOnClose, true);
 }
 
+void OBSBasic::ResizeOutputSizeOfSource()
+{
+	if (obs_video_active())
+		return;
+
+	QMessageBox resize_output(this);
+	resize_output.setText(QTStr("ResizeOutputSizeOfSource.Text") + "\n\n" +
+			      QTStr("ResizeOutputSizeOfSource.Continue"));
+	QAbstractButton *Yes =
+		resize_output.addButton(QTStr("Yes"), QMessageBox::YesRole);
+	resize_output.addButton(QTStr("No"), QMessageBox::NoRole);
+	resize_output.setIcon(QMessageBox::Warning);
+	resize_output.setWindowTitle(QTStr("ResizeOutputSizeOfSource"));
+	resize_output.exec();
+
+	if (resize_output.clickedButton() != Yes)
+		return;
+
+	OBSSource source = obs_sceneitem_get_source(GetCurrentSceneItem());
+
+	int width = obs_source_get_width(source);
+	int height = obs_source_get_height(source);
+
+	config_set_uint(basicConfig, "Video", "BaseCX", width);
+	config_set_uint(basicConfig, "Video", "BaseCY", height);
+	config_set_uint(basicConfig, "Video", "OutputCX", width);
+	config_set_uint(basicConfig, "Video", "OutputCY", height);
+
+	ResetVideo();
+	ResetOutputs();
+	config_save_safe(basicConfig, "tmp", nullptr);
+	on_actionFitToScreen_triggered();
+}
+
 QAction *OBSBasic::AddDockWidget(QDockWidget *dock)
 {
 	QAction *action = ui->menuDocks->addAction(dock->windowTitle());

+ 2 - 0
UI/window-basic-main.hpp

@@ -1174,6 +1174,8 @@ private slots:
 
 	void StackedMixerAreaContextMenuRequested();
 
+	void ResizeOutputSizeOfSource();
+
 public slots:
 	void on_actionResetTransform_triggered();