mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-22 09:54:54 -05:00
Split into multiple files since it was impossible to maintain the code with a file for 3000+ lines. Fixed bug with scene round trip freeze (missing condition variable wait) Added option to sort switch functions by prioroty Renamed Scene Round Trip to Scene Sequence to cause less confusion
58 lines
1.5 KiB
C++
58 lines
1.5 KiB
C++
#include <algorithm>
|
|
#include "advanced-scene-switcher.hpp"
|
|
|
|
void SceneSwitcher::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);
|
|
lock_guard<mutex> lock(switcher->m);
|
|
|
|
iter_swap(switcher->functionNamesByPriority.begin() + currentIndex, switcher->functionNamesByPriority.begin() + currentIndex - 1);
|
|
}
|
|
}
|
|
|
|
void SceneSwitcher::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);
|
|
lock_guard<mutex> lock(switcher->m);
|
|
|
|
iter_swap(switcher->functionNamesByPriority.begin() + currentIndex, switcher->functionNamesByPriority.begin() + currentIndex + 1);
|
|
}
|
|
}
|
|
|
|
bool prioStrValid(string s)
|
|
{
|
|
if (s == WINDOW_TITLE_FUNC)
|
|
return true;
|
|
if (s == SCREEN_REGION_FUNC)
|
|
return true;
|
|
if (s == ROUND_TRIP_FUNC)
|
|
return true;
|
|
if (s == (IDLE_FUNC))
|
|
return true;
|
|
if (s == EXE_FUNC)
|
|
return true;
|
|
if (s == READ_FILE_FUNC)
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
|
|
bool SwitcherData::prioFuncsValid()
|
|
{
|
|
for (string f : functionNamesByPriority)
|
|
{
|
|
if (!prioStrValid(f))
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|