Restore fullscreen projector display selection

Instead of discarding the monitor selection now only no longer perform
the action while the monitor setup is changed.
This commit is contained in:
WarmUpTill 2024-06-16 19:08:23 +02:00 committed by WarmUpTill
parent c1e23f9c7a
commit d77101b6aa
2 changed files with 21 additions and 40 deletions

View File

@ -60,8 +60,13 @@ bool MacroActionProjector::PerformAction()
}
if (_fullscreen && _monitor == -1) {
blog(LOG_INFO, "refusing to open fullscreen projector"
" with invalid display selection");
blog(LOG_INFO, "refusing to open fullscreen projector "
"with invalid display selection");
return true;
}
if (_fullscreen && MonitorSetupChanged()) {
blog(LOG_INFO, "refusing to open fullscreen projector - "
"monitor setup seems to have changed!");
return true;
}
@ -109,13 +114,6 @@ bool MacroActionProjector::Load(obs_data_t *obj)
_fullscreen = obs_data_get_bool(obj, "fullscreen");
_scene.Load(obj);
_source.Load(obj);
if (MonitorSetupChanged()) {
blog(LOG_INFO, "monitor setup seems to have changed! "
"resetting projector action monitor selection!");
_monitor = -1;
}
return true;
}
@ -149,10 +147,13 @@ void MacroActionProjector::SetMonitor(int idx)
int MacroActionProjector::GetMonitor() const
{
if (MonitorSetupChanged()) {
return -1;
}
return _monitor;
}
bool MacroActionProjector::MonitorSetupChanged()
bool MacroActionProjector::MonitorSetupChanged() const
{
if (_monitorName.empty()) {
return false;
@ -248,41 +249,25 @@ void MacroActionProjectorEdit::UpdateEntryData()
void MacroActionProjectorEdit::SceneChanged(const SceneSelection &s)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_scene = s;
}
void MacroActionProjectorEdit::SourceChanged(const SourceSelection &source)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_source = source;
}
void MacroActionProjectorEdit::MonitorChanged(int value)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->SetMonitor(value);
}
void MacroActionProjectorEdit::WindowTypeChanged(int)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_fullscreen =
_windowTypes->currentText() ==
obs_module_text("AdvSceneSwitcher.action.projector.fullscreen");
@ -291,11 +276,7 @@ void MacroActionProjectorEdit::WindowTypeChanged(int)
void MacroActionProjectorEdit::TypeChanged(int value)
{
if (_loading || !_entryData) {
return;
}
auto lock = LockContext();
GUARD_LOADING_AND_LOCK();
_entryData->_type = static_cast<MacroActionProjector::Type>(value);
SetWidgetVisibility();
}

View File

@ -33,7 +33,7 @@ public:
bool _fullscreen = true;
private:
bool MonitorSetupChanged();
bool MonitorSetupChanged() const;
int _monitor = -1;
// Only used to detect display setup changes
@ -66,17 +66,17 @@ private slots:
void SourceChanged(const SourceSelection &);
void MonitorChanged(int value);
protected:
private:
void SetWidgetVisibility();
QComboBox *_windowTypes;
QComboBox *_types;
SceneSelectionWidget *_scenes;
SourceSelectionWidget *_sources;
QHBoxLayout *_monitorSelection;
QComboBox *_monitors;
std::shared_ptr<MacroActionProjector> _entryData;
private:
void SetWidgetVisibility();
std::shared_ptr<MacroActionProjector> _entryData;
bool _loading = true;
};