Selaa lähdekoodia

UI: Fix transform shortcuts for audio only sources

The edit, copy, paste and reset transform shortcuts would still work
for audio only sources, even though the menu was hidden for these.
cg2121 2 vuotta sitten
vanhempi
sitoutus
c33fa8bfa2
2 muutettua tiedostoa jossa 17 lisäystä ja 0 poistoa
  1. 15 0
      UI/window-basic-main.cpp
  2. 2 0
      UI/window-basic-main.hpp

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

@@ -3311,9 +3311,24 @@ void OBSBasic::SourceToolBarActionsSetEnabled()
 	RefreshToolBarStyling(ui->sourcesToolbar);
 }
 
+void OBSBasic::UpdateTransformShortcuts()
+{
+	OBSSource source = obs_sceneitem_get_source(GetCurrentSceneItem());
+	uint32_t flags = obs_source_get_output_flags(source);
+	bool audioOnly = (flags & OBS_SOURCE_VIDEO) == 0;
+
+	ui->actionEditTransform->setEnabled(!audioOnly);
+	ui->actionCopyTransform->setEnabled(!audioOnly);
+	ui->actionPasteTransform->setEnabled(audioOnly ? false
+						       : hasCopiedTransform);
+
+	ui->actionResetTransform->setEnabled(!audioOnly);
+}
+
 void OBSBasic::UpdateContextBar(bool force)
 {
 	SourceToolBarActionsSetEnabled();
+	UpdateTransformShortcuts();
 
 	if (!ui->contextContainer->isVisible() && !force)
 		return;

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

@@ -662,6 +662,8 @@ private:
 
 	bool restartingVCam = false;
 
+	void UpdateTransformShortcuts();
+
 public slots:
 	void DeferSaveBegin();
 	void DeferSaveEnd();