Keep showing saved projector display while it is disconnected

This commit is contained in:
WarmUpTill
2026-11-25 09:40:51 +01:00
committed by WarmUpTill
parent 1bb386ea3b
commit 3745410c37
4 changed files with 30 additions and 3 deletions

View File

@@ -303,7 +303,12 @@ void MacroActionProjectorEdit::UpdateEntryData()
_types->setCurrentIndex(static_cast<int>(_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();

View File

@@ -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 = "";

View File

@@ -3,6 +3,7 @@
#include <QGuiApplication>
#include <QScreen>
#include <QStandardItemModel>
#include <QString>
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<QStandardItemModel *>(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);
}

View File

@@ -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