# HG changeset patch # User Paper # Date 1699469400 18000 # Node ID 4eae379cb1ff0a78d76799ed34212f2bbaddb78e # Parent 39521c47c7a3fd460fab631c023fbf588ecedd0e settings: add a very early recognition tab for configuring players and extensions diff -r 39521c47c7a3 -r 4eae379cb1ff CMakeLists.txt --- a/CMakeLists.txt Tue Nov 07 23:40:54 2023 -0500 +++ b/CMakeLists.txt Wed Nov 08 13:50:00 2023 -0500 @@ -92,6 +92,7 @@ src/gui/dialog/settings/application.cc src/gui/dialog/settings/services.cc src/gui/dialog/settings/torrents.cc + src/gui/dialog/settings/recognition.cc # Translate src/gui/translate/anime.cc diff -r 39521c47c7a3 -r 4eae379cb1ff include/gui/dialog/settings.h --- a/include/gui/dialog/settings.h Tue Nov 07 23:40:54 2023 -0500 +++ b/include/gui/dialog/settings.h Wed Nov 08 13:50:00 2023 -0500 @@ -71,6 +71,18 @@ decltype(session.config.torrents.feed_link) feed_link; }; +class SettingsPageRecognition final : public SettingsPage { + Q_OBJECT + + public: + SettingsPageRecognition(QWidget* parent = nullptr); + void SaveInfo() override; + + private: + QWidget* CreatePlayersWidget(); + decltype(session.recognition.players) players; +}; + class SettingsDialog final : public QDialog { Q_OBJECT diff -r 39521c47c7a3 -r 4eae379cb1ff rc/icons.qrc --- a/rc/icons.qrc Tue Nov 07 23:40:54 2023 -0500 +++ b/rc/icons.qrc Wed Nov 08 13:50:00 2023 -0500 @@ -12,6 +12,7 @@ icons/16x16/gear.png icons/16x16/magnifier.png icons/16x16/navigation-270-button.png + icons/16x16/plus-button.png icons/24x24/application-export.png icons/24x24/application-sidebar-list.png icons/24x24/arrow-circle-double-135.png diff -r 39521c47c7a3 -r 4eae379cb1ff rc/icons/16x16/plus-button.png Binary file rc/icons/16x16/plus-button.png has changed diff -r 39521c47c7a3 -r 4eae379cb1ff src/gui/dialog/settings.cc --- a/src/gui/dialog/settings.cc Tue Nov 07 23:40:54 2023 -0500 +++ b/src/gui/dialog/settings.cc Wed Nov 08 13:50:00 2023 -0500 @@ -90,7 +90,7 @@ sidebar->setCurrentItem(sidebar->AddItem(tr("Services"), SideBar::CreateIcon(":/icons/24x24/globe.png"))); // sidebar->AddItem(tr("Library"), SideBar::CreateIcon(":/icons/24x24/inbox-film.png")); sidebar->AddItem(tr("Application"), SideBar::CreateIcon(":/icons/24x24/application-sidebar-list.png")); - // sidebar->AddItem(tr("Recognition"), SideBar::CreateIcon(":/icons/24x24/question.png")); + sidebar->AddItem(tr("Recognition"), SideBar::CreateIcon(":/icons/24x24/question.png")); // sidebar->AddItem(tr("Sharing"), SideBar::CreateIcon(":/icons/24x24/megaphone.png")); sidebar->AddItem(tr("Torrents"), SideBar::CreateIcon(":/icons/24x24/feed.png")); // sidebar->AddItem(tr("Advanced"), SideBar::CreateIcon(":/icons/24x24/gear.png")); @@ -110,6 +110,7 @@ stacked = new QStackedWidget(widget); stacked->addWidget(new SettingsPageServices(stacked)); stacked->addWidget(new SettingsPageApplication(stacked)); + stacked->addWidget(new SettingsPageRecognition(stacked)); stacked->addWidget(new SettingsPageTorrents(stacked)); stacked->setCurrentIndex(0); diff -r 39521c47c7a3 -r 4eae379cb1ff src/gui/dialog/settings/recognition.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/gui/dialog/settings/recognition.cc Wed Nov 08 13:50:00 2023 -0500 @@ -0,0 +1,70 @@ +#include "core/session.h" +#include "core/strings.h" +#include "gui/dialog/settings.h" +#include "track/types.h" +#include +#include +#include +#include +#include +#include +#include + +Q_DECLARE_METATYPE(Track::Types::MediaPlayer); + +QWidget* SettingsPageRecognition::CreatePlayersWidget() { + QWidget* result = new QWidget(this); + result->setAutoFillBackground(true); + result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); + + QVBoxLayout* full_layout = new QVBoxLayout(result); + + { + /* URLs */ + QGroupBox* group = new QGroupBox(tr("URLs"), result); + group->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); + + QVBoxLayout* group_layout = new QVBoxLayout(group); + + { + /* Feed link */ + QWidget* widget = new QWidget(group); + QVBoxLayout* widget_layout = new QVBoxLayout(widget); + + { + QLabel* label = new QLabel(tr("Allowed media players:"), widget); + widget_layout->addWidget(label); + } + + { + QListWidget* listwidget = new QListWidget(widget); + for (const auto& player : session.recognition.players) { + QListWidgetItem* item = new QListWidgetItem(listwidget); + item->setCheckState(player.GetEnabled() ? Qt::Checked : Qt::Unchecked); + item->setText(Strings::ToQString(player.GetName() + " (" + player.GetExecutable() + ")")); + { + QVariant v(QVariant::fromValue(player)); + item->setData(Qt::UserRole, v); + } + } + widget_layout->addWidget(listwidget); + } + + group_layout->addWidget(widget); + } + + full_layout->addWidget(group); + } + + full_layout->setSpacing(10); + full_layout->addStretch(); + + return result; +} + +void SettingsPageRecognition::SaveInfo() { +} + +SettingsPageRecognition::SettingsPageRecognition(QWidget* parent) : SettingsPage(parent, tr("Recognition")) { + AddTab(CreatePlayersWidget(), tr("Players")); +} diff -r 39521c47c7a3 -r 4eae379cb1ff src/gui/dialog/settings/torrents.cc --- a/src/gui/dialog/settings/torrents.cc Tue Nov 07 23:40:54 2023 -0500 +++ b/src/gui/dialog/settings/torrents.cc Wed Nov 08 13:50:00 2023 -0500 @@ -56,7 +56,7 @@ session.config.torrents.feed_link = feed_link; } -SettingsPageTorrents::SettingsPageTorrents(QWidget* parent) : SettingsPage(parent, tr("Application")) { +SettingsPageTorrents::SettingsPageTorrents(QWidget* parent) : SettingsPage(parent, tr("Torrents")) { feed_link = session.config.torrents.feed_link; AddTab(CreateGeneralWidget(), tr("General")); }