From 6fb86196716a088d008fd6469ecb466af1ea901b Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Wed, 28 Aug 2024 09:48:02 +0200 Subject: [PATCH] Clear outdated highlight triggers when enabling macro segment highlights --- lib/macro/macro-tab.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/macro/macro-tab.cpp b/lib/macro/macro-tab.cpp index f29b0eae..90a16ea7 100644 --- a/lib/macro/macro-tab.cpp +++ b/lib/macro/macro-tab.cpp @@ -762,6 +762,16 @@ void AdvSceneSwitcher::HighlightOnChange() } } +static void resetSegmentHighlights(MacroSegmentList *list) +{ + MacroSegmentEdit *widget = nullptr; + for (int i = 0; (widget = list->WidgetAt(i)); i++) { + if (widget && widget->Data()) { + (void)widget->Data()->GetHighlightAndReset(); + } + } +} + void AdvSceneSwitcher::on_macroSettings_clicked() { GlobalMacroSettings prop = GetGlobalMacroSettings(); @@ -770,8 +780,20 @@ void AdvSceneSwitcher::on_macroSettings_clicked() if (!accepted) { return; } + GetGlobalMacroSettings() = prop; emit HighlightMacrosChanged(prop._highlightExecuted); + + // Reset highlights to avoid all macro segments being highlighted, which + // would have been highlighted at least once since the moment the + // highlighting was disabled + if (prop._highlightConditions) { + resetSegmentHighlights(ui->conditionsList); + } + if (prop._highlightActions) { + resetSegmentHighlights(ui->actionsList); + resetSegmentHighlights(ui->elseActionsList); + } } static void moveControlsToSplitter(QSplitter *splitter, int idx,