From 3745410c37b2d6f34d18e6cfb1df78bc47bf1591 Mon Sep 17 00:00:00 2001 From: WarmUpTill <19472752+WarmUpTill@users.noreply.github.com> Date: Wed, 25 Nov 2026 09:40:51 +0100 Subject: [PATCH] Keep showing saved projector display while it is disconnected --- plugins/base/macro-action-projector.cpp | 7 ++++++- plugins/base/macro-action-projector.hpp | 4 ++-- plugins/base/utils/monitor-helpers.cpp | 18 ++++++++++++++++++ plugins/base/utils/monitor-helpers.hpp | 4 ++++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/plugins/base/macro-action-projector.cpp b/plugins/base/macro-action-projector.cpp index 5cc6fb48..fa02be69 100644 --- a/plugins/base/macro-action-projector.cpp +++ b/plugins/base/macro-action-projector.cpp @@ -303,7 +303,12 @@ void MacroActionProjectorEdit::UpdateEntryData() _types->setCurrentIndex(static_cast(_entryData->_type)); _scenes->SetScene(_entryData->_scene); _sources->SetSource(_entryData->_source); - _monitors->setCurrentIndex(_entryData->GetMonitor()); + if (_entryData->MonitorSetupChanged()) { + _monitors->SetUnavailableMonitor( + QString::fromStdString(_entryData->GetMonitorName())); + } else { + _monitors->setCurrentIndex(_entryData->GetMonitor()); + } _projectorWindowName->setText(_entryData->_projectorWindowName); _regex->SetRegexConfig(_entryData->_regex); SetWidgetVisibility(); diff --git a/plugins/base/macro-action-projector.hpp b/plugins/base/macro-action-projector.hpp index e2483347..de82d7e0 100644 --- a/plugins/base/macro-action-projector.hpp +++ b/plugins/base/macro-action-projector.hpp @@ -21,6 +21,8 @@ public: void ResolveVariablesToFixedValues(); void SetMonitor(int); int GetMonitor() const; + std::string GetMonitorName() const { return _monitorName; } + bool MonitorSetupChanged() const; enum class Action { OPEN, @@ -44,8 +46,6 @@ public: RegexConfig _regex = RegexConfig::PartialMatchRegexConfig(true); private: - bool MonitorSetupChanged() const; - int _monitor = -1; // Only used to detect display setup changes std::string _monitorName = ""; diff --git a/plugins/base/utils/monitor-helpers.cpp b/plugins/base/utils/monitor-helpers.cpp index c1652173..67119305 100644 --- a/plugins/base/utils/monitor-helpers.cpp +++ b/plugins/base/utils/monitor-helpers.cpp @@ -3,6 +3,7 @@ #include #include +#include #include namespace advss { @@ -56,6 +57,18 @@ MonitorSelectionWidget::MonitorSelectionWidget(QWidget *parent) addItems(GetMonitorNames()); } +void MonitorSelectionWidget::SetUnavailableMonitor(const QString &name) +{ + _unavailableMonitor = name; + addItem(name); + const int idx = count() - 1; + auto itemModel = qobject_cast(model()); + if (itemModel) { + itemModel->item(idx)->setEnabled(false); + } + setCurrentIndex(idx); +} + void MonitorSelectionWidget::showEvent(QShowEvent *event) { FilterComboBox::showEvent(event); @@ -63,6 +76,11 @@ void MonitorSelectionWidget::showEvent(QShowEvent *event) const auto text = currentText(); clear(); addItems(GetMonitorNames()); + if (!text.isEmpty() && text == _unavailableMonitor && + findText(text) == -1) { + SetUnavailableMonitor(text); + return; + } setCurrentText(text); } diff --git a/plugins/base/utils/monitor-helpers.hpp b/plugins/base/utils/monitor-helpers.hpp index b0fa1743..5ec88665 100644 --- a/plugins/base/utils/monitor-helpers.hpp +++ b/plugins/base/utils/monitor-helpers.hpp @@ -10,9 +10,13 @@ class MonitorSelectionWidget : public FilterComboBox { public: MonitorSelectionWidget(QWidget *parent); + void SetUnavailableMonitor(const QString &name); protected: void showEvent(QShowEvent *event) override; + +private: + QString _unavailableMonitor; }; } // namespace advss