Browse Source

UI: Disable properties button in source toolbar

If a scene or group is selected, disable the properties button in the
source toolbar. This also does a refactor of the function to enable/disable
the toolbar buttons.
cg2121 2 years ago
parent
commit
26725fa2d5
2 changed files with 22 additions and 7 deletions
  1. 21 6
      UI/window-basic-main.cpp
  2. 1 1
      UI/window-basic-main.hpp

+ 21 - 6
UI/window-basic-main.cpp

@@ -3089,10 +3089,26 @@ void OBSBasic::UpdateContextBarDeferred(bool force)
 				  Qt::QueuedConnection, Q_ARG(bool, force));
 				  Qt::QueuedConnection, Q_ARG(bool, force));
 }
 }
 
 
-void OBSBasic::SourceToolBarActionsSetEnabled(bool enable)
+void OBSBasic::SourceToolBarActionsSetEnabled()
 {
 {
+	bool enable = false;
+	bool disableProps = false;
+
+	OBSSceneItem item = GetCurrentSceneItem();
+
+	if (item) {
+		OBSSource source = obs_sceneitem_get_source(item);
+		disableProps = !obs_source_configurable(source);
+
+		enable = true;
+	}
+
+	if (disableProps)
+		ui->actionSourceProperties->setEnabled(false);
+	else
+		ui->actionSourceProperties->setEnabled(enable);
+
 	ui->actionRemoveSource->setEnabled(enable);
 	ui->actionRemoveSource->setEnabled(enable);
-	ui->actionSourceProperties->setEnabled(enable);
 	ui->actionSourceUp->setEnabled(enable);
 	ui->actionSourceUp->setEnabled(enable);
 	ui->actionSourceDown->setEnabled(enable);
 	ui->actionSourceDown->setEnabled(enable);
 
 
@@ -3101,14 +3117,13 @@ void OBSBasic::SourceToolBarActionsSetEnabled(bool enable)
 
 
 void OBSBasic::UpdateContextBar(bool force)
 void OBSBasic::UpdateContextBar(bool force)
 {
 {
-	OBSSceneItem item = GetCurrentSceneItem();
-	bool enable = item != nullptr;
-
-	SourceToolBarActionsSetEnabled(enable);
+	SourceToolBarActionsSetEnabled();
 
 
 	if (!ui->contextContainer->isVisible() && !force)
 	if (!ui->contextContainer->isVisible() && !force)
 		return;
 		return;
 
 
+	OBSSceneItem item = GetCurrentSceneItem();
+
 	if (item) {
 	if (item) {
 		obs_source_t *source = obs_sceneitem_get_source(item);
 		obs_source_t *source = obs_sceneitem_get_source(item);
 
 

+ 1 - 1
UI/window-basic-main.hpp

@@ -638,7 +638,7 @@ private:
 	bool drawSpacingHelpers = true;
 	bool drawSpacingHelpers = true;
 
 
 	float GetDevicePixelRatio();
 	float GetDevicePixelRatio();
-	void SourceToolBarActionsSetEnabled(bool enable);
+	void SourceToolBarActionsSetEnabled();
 
 
 	std::string lastScreenshot;
 	std::string lastScreenshot;
 	std::string lastReplay;
 	std::string lastReplay;