mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-20 00:05:41 -05:00
Restructure library and plugins
The "core" macro conditions and actions have been extracted out to the "base" plugin. The library now mostly contains functionality which is required across all plugins and (e.g. definitions for macro segments). The goal is to reduce the complexity and cross-dependencies and group the source files in a better way. This should relsove the "library limit of 65535 objects exceeded" build issue occuring in some Windows build environments.
This commit is contained in:
86
plugins/base/macro-condition-profile.cpp
Normal file
86
plugins/base/macro-condition-profile.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
#include "macro-condition-profile.hpp"
|
||||
#include "profile-helpers.hpp"
|
||||
#include "utility.hpp"
|
||||
|
||||
namespace advss {
|
||||
|
||||
const std::string MacroConditionProfile::id = "profile";
|
||||
|
||||
bool MacroConditionProfile::_registered = MacroConditionFactory::Register(
|
||||
MacroConditionProfile::id,
|
||||
{MacroConditionProfile::Create, MacroConditionProfileEdit::Create,
|
||||
"AdvSceneSwitcher.condition.profile"});
|
||||
|
||||
bool MacroConditionProfile::CheckCondition()
|
||||
{
|
||||
auto currentProfile = obs_frontend_get_current_profile();
|
||||
const bool match = _profile == currentProfile;
|
||||
bfree(currentProfile);
|
||||
return match;
|
||||
}
|
||||
|
||||
bool MacroConditionProfile::Save(obs_data_t *obj) const
|
||||
{
|
||||
MacroCondition::Save(obj);
|
||||
obs_data_set_string(obj, "profile", _profile.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MacroConditionProfile::Load(obs_data_t *obj)
|
||||
{
|
||||
MacroCondition::Load(obj);
|
||||
_profile = obs_data_get_string(obj, "profile");
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string MacroConditionProfile::GetShortDesc() const
|
||||
{
|
||||
return _profile;
|
||||
}
|
||||
|
||||
MacroConditionProfileEdit::MacroConditionProfileEdit(
|
||||
QWidget *parent, std::shared_ptr<MacroConditionProfile> entryData)
|
||||
: QWidget(parent), _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},
|
||||
};
|
||||
|
||||
PlaceWidgets(
|
||||
obs_module_text("AdvSceneSwitcher.condition.profile.entry"),
|
||||
mainLayout, widgetPlaceholders);
|
||||
setLayout(mainLayout);
|
||||
|
||||
_entryData = entryData;
|
||||
UpdateEntryData();
|
||||
_loading = false;
|
||||
}
|
||||
|
||||
void MacroConditionProfileEdit::ProfileChanged(const QString &text)
|
||||
{
|
||||
if (_loading || !_entryData) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto lock = LockContext();
|
||||
_entryData->_profile = text.toStdString();
|
||||
emit HeaderInfoChanged(
|
||||
QString::fromStdString(_entryData->GetShortDesc()));
|
||||
}
|
||||
|
||||
void MacroConditionProfileEdit::UpdateEntryData()
|
||||
{
|
||||
if (!_entryData) {
|
||||
return;
|
||||
}
|
||||
|
||||
_profiles->setCurrentText(QString::fromStdString(_entryData->_profile));
|
||||
}
|
||||
|
||||
} // namespace advss
|
||||
Reference in New Issue
Block a user