Mercurial > minori
diff src/gui/dialog/settings/recognition.cc @ 147:6fdf0632c003
track: use a bit of a more sane way to manage recognition
it also works with the new animia API
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Tue, 14 Nov 2023 13:19:40 -0500 |
parents | 69db40272acd |
children | e41505d24733 |
line wrap: on
line diff
--- a/src/gui/dialog/settings/recognition.cc Mon Nov 13 13:52:58 2023 -0500 +++ b/src/gui/dialog/settings/recognition.cc Tue Nov 14 13:19:40 2023 -0500 @@ -1,7 +1,7 @@ #include "core/session.h" #include "core/strings.h" #include "gui/dialog/settings.h" -#include "track/types.h" + #include <QListWidget> #include <QListWidgetItem> #include <QGroupBox> @@ -9,10 +9,9 @@ #include <QLabel> #include <QSizePolicy> #include <QVBoxLayout> + #include <algorithm> -Q_DECLARE_METATYPE(Track::Types::MediaPlayer); - QWidget* SettingsPageRecognition::CreatePlayersWidget() { QWidget* result = new QWidget(this); result->setAutoFillBackground(true); @@ -41,8 +40,8 @@ const auto& player = players[i]; { QListWidgetItem* item = new QListWidgetItem(listwidget); - item->setCheckState(player.GetEnabled() ? Qt::Checked : Qt::Unchecked); - item->setText(Strings::ToQString(player.GetName() + " (" + player.GetExecutable() + ")")); + item->setCheckState(player.first ? Qt::Checked : Qt::Unchecked); + item->setText(Strings::ToQString(player.second.name)); item->setData(Qt::UserRole, QVariant::fromValue(i)); } } @@ -50,7 +49,7 @@ if (!item) return; size_t i = item->data(Qt::UserRole).toUInt(); - players[i].SetEnabled(item->checkState()); + players[i].first = item->checkState(); }); /* this is down here because the listwidget state depends on it */ connect(checkbox, &QCheckBox::stateChanged, this, [this, listwidget](int state) { @@ -65,40 +64,6 @@ full_layout->addWidget(widget); } - { - /* Feed link */ - QWidget* widget = new QWidget(result); - QVBoxLayout* widget_layout = new QVBoxLayout(widget); - - { - QLabel* label = new QLabel(tr("Allowed file extensions:"), widget); - widget_layout->addWidget(label); - } - - { - QListWidget* listwidget = new QListWidget(widget); - for (size_t i = 0; i < extensions.size(); i++) { - const auto& extension = extensions[i]; - { - QListWidgetItem* item = new QListWidgetItem(listwidget); - item->setCheckState(extension.GetEnabled() ? Qt::Checked : Qt::Unchecked); - item->setText(Strings::ToQString("." + extension.GetExtension())); - item->setData(Qt::UserRole, QVariant::fromValue(i)); - } - } - connect(listwidget, &QListWidget::itemChanged, this, [this](QListWidgetItem* item){ - if (!item) - return; - size_t i = item->data(Qt::UserRole).toUInt(); - extensions[i].SetEnabled(item->checkState()); - }); - - widget_layout->addWidget(listwidget); - } - - full_layout->addWidget(widget); - } - full_layout->setSpacing(10); return result; @@ -106,14 +71,12 @@ void SettingsPageRecognition::SaveInfo() { session.config.recognition.detect_media_players = detect_media_players; - session.recognition.players = players; - session.recognition.extensions = extensions; + session.config.recognition.players = players; } SettingsPageRecognition::SettingsPageRecognition(QWidget* parent) : SettingsPage(parent, tr("Recognition")), - players(session.recognition.players), - extensions(session.recognition.extensions) { + players(session.config.recognition.players) { detect_media_players = session.config.recognition.detect_media_players; AddTab(CreatePlayersWidget(), tr("Media players")); }