From 5967c83b0386db4d1e04c18e1cdc392b5a237c2b Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Sat, 29 Apr 2023 22:39:42 +0200 Subject: [PATCH] Remove switch-priority.cpp --- CMakeLists.txt | 1 - src/legacy/switch-priority.cpp | 83 ---------------------------------- src/utils/priority-helper.cpp | 78 ++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 84 deletions(-) delete mode 100644 src/legacy/switch-priority.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e0a3f1d..6e51f813 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,7 +73,6 @@ target_sources( src/legacy/switch-network.hpp src/legacy/switch-pause.cpp src/legacy/switch-pause.hpp - src/legacy/switch-priority.cpp src/legacy/switch-random.cpp src/legacy/switch-random.hpp src/legacy/switch-screen-region.cpp diff --git a/src/legacy/switch-priority.cpp b/src/legacy/switch-priority.cpp deleted file mode 100644 index 65cdb17d..00000000 --- a/src/legacy/switch-priority.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include "advanced-scene-switcher.hpp" -#include "switcher-data.hpp" - -#include - -namespace advss { - -void AdvSceneSwitcher::on_threadPriority_currentTextChanged(const QString &text) -{ - if (loading || ui->threadPriority->count() != - (int)switcher->threadPriorities.size()) - return; - - std::lock_guard lock(switcher->m); - - for (auto p : switcher->threadPriorities) { - if (p.name == text.toUtf8().constData()) { - switcher->threadPriority = p.value; - break; - } - } -} - -void AdvSceneSwitcher::on_priorityUp_clicked() -{ - int currentIndex = ui->priorityList->currentRow(); - if (currentIndex != -1 && currentIndex != 0) { - ui->priorityList->insertItem( - currentIndex - 1, - ui->priorityList->takeItem(currentIndex)); - ui->priorityList->setCurrentRow(currentIndex - 1); - std::lock_guard lock(switcher->m); - - iter_swap(switcher->functionNamesByPriority.begin() + - currentIndex, - switcher->functionNamesByPriority.begin() + - currentIndex - 1); - } - ui->macroPriorityWarning->setVisible( - switcher->functionNamesByPriority[0] != macro_func); -} - -void AdvSceneSwitcher::on_priorityDown_clicked() -{ - int currentIndex = ui->priorityList->currentRow(); - if (currentIndex != -1 && - currentIndex != ui->priorityList->count() - 1) { - ui->priorityList->insertItem( - currentIndex + 1, - ui->priorityList->takeItem(currentIndex)); - ui->priorityList->setCurrentRow(currentIndex + 1); - std::lock_guard lock(switcher->m); - - iter_swap(switcher->functionNamesByPriority.begin() + - currentIndex, - switcher->functionNamesByPriority.begin() + - currentIndex + 1); - } - ui->macroPriorityWarning->setVisible( - switcher->functionNamesByPriority[0] != macro_func); -} - -bool SwitcherData::PrioFuncsValid() -{ - auto fNBPCopy = functionNamesByPriority; - - std::sort(fNBPCopy.begin(), fNBPCopy.end()); - auto it = std::unique(fNBPCopy.begin(), fNBPCopy.end()); - bool wasUnique = (it == fNBPCopy.end()); - - if (!wasUnique) { - return false; - } - - for (int p : functionNamesByPriority) { - if (p < 0 || p > 10) { - return false; - } - } - return true; -} - -} // namespace advss diff --git a/src/utils/priority-helper.cpp b/src/utils/priority-helper.cpp index e943cb9a..3ff3430a 100644 --- a/src/utils/priority-helper.cpp +++ b/src/utils/priority-helper.cpp @@ -1,4 +1,6 @@ #include "priority-helper.hpp" +#include "switcher-data.hpp" +#include "advanced-scene-switcher.hpp" #include "scene-group.hpp" #include "scene-trigger.hpp" #include "switch-audio.hpp" @@ -17,6 +19,7 @@ #include "switch-network.hpp" #include "macro.hpp" +#include #include namespace advss { @@ -78,4 +81,79 @@ std::vector GetThreadPrioMapping() }; } +bool SwitcherData::PrioFuncsValid() +{ + auto fNBPCopy = functionNamesByPriority; + + std::sort(fNBPCopy.begin(), fNBPCopy.end()); + auto it = std::unique(fNBPCopy.begin(), fNBPCopy.end()); + bool wasUnique = (it == fNBPCopy.end()); + + if (!wasUnique) { + return false; + } + + for (int p : functionNamesByPriority) { + if (p < 0 || p > 10) { + return false; + } + } + return true; +} + +void AdvSceneSwitcher::on_threadPriority_currentTextChanged(const QString &text) +{ + if (loading || ui->threadPriority->count() != + (int)switcher->threadPriorities.size()) + return; + + std::lock_guard lock(switcher->m); + + for (auto p : switcher->threadPriorities) { + if (p.name == text.toUtf8().constData()) { + switcher->threadPriority = p.value; + break; + } + } +} + +void AdvSceneSwitcher::on_priorityUp_clicked() +{ + int currentIndex = ui->priorityList->currentRow(); + if (currentIndex != -1 && currentIndex != 0) { + ui->priorityList->insertItem( + currentIndex - 1, + ui->priorityList->takeItem(currentIndex)); + ui->priorityList->setCurrentRow(currentIndex - 1); + std::lock_guard lock(switcher->m); + + iter_swap(switcher->functionNamesByPriority.begin() + + currentIndex, + switcher->functionNamesByPriority.begin() + + currentIndex - 1); + } + ui->macroPriorityWarning->setVisible( + switcher->functionNamesByPriority[0] != macro_func); +} + +void AdvSceneSwitcher::on_priorityDown_clicked() +{ + int currentIndex = ui->priorityList->currentRow(); + if (currentIndex != -1 && + currentIndex != ui->priorityList->count() - 1) { + ui->priorityList->insertItem( + currentIndex + 1, + ui->priorityList->takeItem(currentIndex)); + ui->priorityList->setCurrentRow(currentIndex + 1); + std::lock_guard lock(switcher->m); + + iter_swap(switcher->functionNamesByPriority.begin() + + currentIndex, + switcher->functionNamesByPriority.begin() + + currentIndex + 1); + } + ui->macroPriorityWarning->setVisible( + switcher->functionNamesByPriority[0] != macro_func); +} + } // namespace advss