mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-20 16:25:43 -05:00
Add ProfileSelectionWidget
Refreshes list of profiles when widget becomes visible to support widget caching.
This commit is contained in:
@@ -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()));
|
||||
|
||||
Reference in New Issue
Block a user