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.
This commit is contained in:
cg2121 2022-12-11 22:50:56 -06:00 committed by Jim
parent 148122f5aa
commit 26725fa2d5
2 changed files with 22 additions and 7 deletions

View file

@ -3089,10 +3089,26 @@ void OBSBasic::UpdateContextBarDeferred(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->actionSourceProperties->setEnabled(enable);
ui->actionSourceUp->setEnabled(enable);
ui->actionSourceDown->setEnabled(enable);
@ -3101,14 +3117,13 @@ void OBSBasic::SourceToolBarActionsSetEnabled(bool enable)
void OBSBasic::UpdateContextBar(bool force)
{
OBSSceneItem item = GetCurrentSceneItem();
bool enable = item != nullptr;
SourceToolBarActionsSetEnabled(enable);
SourceToolBarActionsSetEnabled();
if (!ui->contextContainer->isVisible() && !force)
return;
OBSSceneItem item = GetCurrentSceneItem();
if (item) {
obs_source_t *source = obs_sceneitem_get_source(item);

View file

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