got rid of duplicates in list

This commit is contained in:
Jared Bruni
2020-01-10 20:46:18 -08:00
parent cde17e9efe
commit 24729b7de5
3 changed files with 40 additions and 4 deletions

View File

@@ -170,6 +170,7 @@ void AC_MainWindow::createControls() {
std::sort(fnames.begin(), fnames.end()); std::sort(fnames.begin(), fnames.end());
/*
for(unsigned long i = 0; i < fnames.size(); ++i) { for(unsigned long i = 0; i < fnames.size(); ++i) {
filters->addItem(fnames[i].c_str()); filters->addItem(fnames[i].c_str());
} }
@@ -183,7 +184,7 @@ void AC_MainWindow::createControls() {
for(unsigned int i = 0; i < plugins.plugin_list.size(); ++i) { for(unsigned int i = 0; i < plugins.plugin_list.size(); ++i) {
std::string name = "plugin " + plugins.plugin_list[i]->name(); std::string name = "plugin " + plugins.plugin_list[i]->name();
filters->addItem(name.c_str()); filters->addItem(name.c_str());
} }*/
connect(filters, SIGNAL(currentIndexChanged(int)), this, SLOT(comboFilterChanged(int))); connect(filters, SIGNAL(currentIndexChanged(int)), this, SLOT(comboFilterChanged(int)));
connect(menu_cat, SIGNAL(currentIndexChanged(int)), this, SLOT(menuFilterChanged(int))); connect(menu_cat, SIGNAL(currentIndexChanged(int)), this, SLOT(menuFilterChanged(int)));
@@ -529,7 +530,21 @@ void AC_MainWindow::createMenu() {
select_random_filter = new QAction(tr("Set Random Filter"), this); select_random_filter = new QAction(tr("Set Random Filter"), this);
connect(select_random_filter, SIGNAL(triggered()), this, SLOT(setRandomFilterValue())); connect(select_random_filter, SIGNAL(triggered()), this, SLOT(setRandomFilterValue()));
select_random_filter->setShortcut(tr("Space")); select_random_filter->setShortcut(tr("Space"));
controls_menu->addAction(select_random_filter); controls_menu->addAction(select_random_filter);
select_next_filter = new QAction(tr("Next Filter"), this);
connect(select_next_filter, SIGNAL(triggered()), this, SLOT(next_filter()));
select_next_filter->setShortcut(tr("Ctrl+I"));
controls_menu->addAction(select_next_filter);
select_prev_filter = new QAction(tr("Prev Filter"), this);
connect(select_prev_filter, SIGNAL(triggered()), this, SLOT(prev_filter()));
select_prev_filter->setShortcut(tr("Ctrl+O"));
controls_menu->addAction(select_prev_filter);
} }
@@ -1401,9 +1416,14 @@ void AC_MainWindow::menuFilterChanged(int index) {
loading = true; loading = true;
std::string menu_n = menuNames[index]; std::string menu_n = menuNames[index];
filters->clear(); filters->clear();
auto v = ac::filter_menu_map[menu_n].menu_list; std::vector<std::string> *v = ac::filter_menu_map[menu_n].menu_list;
auto end = v->end();
for(auto it = v->begin(); it != end; ++it) {
end = std::remove(it + 1, end, *it);
}
for(auto in = v->begin(); in != v->end(); ++in) { for(auto in = v->begin(); in != v->end(); ++in) {
filters->addItem(in->c_str()); filters->addItem(in->c_str());
} }
filters->setCurrentIndex(0); filters->setCurrentIndex(0);
loading = false; loading = false;
@@ -1694,3 +1714,16 @@ void AC_MainWindow::setCustomCycle_Menu() {
bool chk = cycle_custom->isChecked(); bool chk = cycle_custom->isChecked();
playback->setCustomCycle(chk); playback->setCustomCycle(chk);
} }
void AC_MainWindow::next_filter() {
int count = filters->count();
int index = filters->currentIndex();
if(index < count) {
++index;
filters->setCurrentIndex(index);
}
}
void AC_MainWindow::prev_filter() {
}

View File

@@ -60,6 +60,7 @@ public:
QAction *show_options_window; QAction *show_options_window;
QAction *show_control_window; QAction *show_control_window;
QAction *select_random_filter; QAction *select_random_filter;
QAction *select_next_filter, *select_prev_filter;
QAction *cycle_custom; QAction *cycle_custom;
double speed_actions[7]; double speed_actions[7];
QRadioButton *filter_single, *filter_custom; QRadioButton *filter_single, *filter_custom;
@@ -130,6 +131,8 @@ public slots:
void showPrefWindow(); void showPrefWindow();
void setRandomFilterValue(); void setRandomFilterValue();
void setCustomCycle_Menu(); void setCustomCycle_Menu();
void next_filter();
void prev_filter();
private: private:
void createControls(); void createControls();
void createMenu(); void createMenu();

View File

@@ -356,7 +356,7 @@ void Playback::run() {
if(_custom_cycle_index > static_cast<int>(cur.size()-1)) if(_custom_cycle_index > static_cast<int>(cur.size()-1))
_custom_cycle_index = 0; _custom_cycle_index = 0;
if(_custom_cycle_index >= 0 && _custom_cycle_index < cur.size()) { if(_custom_cycle_index >= 0 && _custom_cycle_index < static_cast<int>(cur.size())) {
drawFilter(frame, cur[_custom_cycle_index]); drawFilter(frame, cur[_custom_cycle_index]);
msleep(duration/2); msleep(duration/2);
} }