Add ProfileSelectionWidget

Refreshes list of profiles when widget becomes visible to support widget
caching.
This commit is contained in:
WarmUpTill
2025-05-22 21:38:07 +02:00
committed by WarmUpTill
parent 1c94a1ab44
commit 5e3ab19940
6 changed files with 50 additions and 45 deletions

View File

@@ -1,6 +1,5 @@
#include "macro-action-profile.hpp"
#include "layout-helpers.hpp"
#include "profile-helpers.hpp"
#include <obs-frontend-api.h>
@@ -55,20 +54,16 @@ std::shared_ptr<MacroAction> MacroActionProfile::Copy() const
MacroActionProfileEdit::MacroActionProfileEdit(
QWidget *parent, std::shared_ptr<MacroActionProfile> entryData)
: QWidget(parent)
: QWidget(parent),
_profiles(new ProfileSelectionWidget(this))
{
_profiles = new QComboBox();
PopulateProfileSelection(_profiles);
QWidget::connect(_profiles, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(ProfileChanged(const QString &)));
QHBoxLayout *mainLayout = new QHBoxLayout;
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
{"{{profiles}}", _profiles},
};
auto layout = new QHBoxLayout;
PlaceWidgets(obs_module_text("AdvSceneSwitcher.action.profile.entry"),
mainLayout, widgetPlaceholders);
setLayout(mainLayout);
layout, {{"{{profiles}}", _profiles}});
setLayout(layout);
_entryData = entryData;
UpdateEntryData();
@@ -86,11 +81,7 @@ void MacroActionProfileEdit::UpdateEntryData()
void MacroActionProfileEdit::ProfileChanged(const QString &text)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_profile = text.toStdString();
emit HeaderInfoChanged(
QString::fromStdString(_entryData->GetShortDesc()));