mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-12-01 20:37:18 -06:00
Keep showing saved projector display while it is disconnected
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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 = "";
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user