Mercurial > minori
comparison src/gui/dialog/settings/recognition.cc @ 119:4eae379cb1ff
settings: add a very early recognition tab for configuring players and extensions
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Wed, 08 Nov 2023 13:50:00 -0500 |
parents | |
children | 275da698697d |
comparison
equal
deleted
inserted
replaced
118:39521c47c7a3 | 119:4eae379cb1ff |
---|---|
1 #include "core/session.h" | |
2 #include "core/strings.h" | |
3 #include "gui/dialog/settings.h" | |
4 #include "track/types.h" | |
5 #include <QListWidget> | |
6 #include <QListWidgetItem> | |
7 #include <QGroupBox> | |
8 #include <QLabel> | |
9 #include <QSizePolicy> | |
10 #include <QVBoxLayout> | |
11 #include <algorithm> | |
12 | |
13 Q_DECLARE_METATYPE(Track::Types::MediaPlayer); | |
14 | |
15 QWidget* SettingsPageRecognition::CreatePlayersWidget() { | |
16 QWidget* result = new QWidget(this); | |
17 result->setAutoFillBackground(true); | |
18 result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); | |
19 | |
20 QVBoxLayout* full_layout = new QVBoxLayout(result); | |
21 | |
22 { | |
23 /* URLs */ | |
24 QGroupBox* group = new QGroupBox(tr("URLs"), result); | |
25 group->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); | |
26 | |
27 QVBoxLayout* group_layout = new QVBoxLayout(group); | |
28 | |
29 { | |
30 /* Feed link */ | |
31 QWidget* widget = new QWidget(group); | |
32 QVBoxLayout* widget_layout = new QVBoxLayout(widget); | |
33 | |
34 { | |
35 QLabel* label = new QLabel(tr("Allowed media players:"), widget); | |
36 widget_layout->addWidget(label); | |
37 } | |
38 | |
39 { | |
40 QListWidget* listwidget = new QListWidget(widget); | |
41 for (const auto& player : session.recognition.players) { | |
42 QListWidgetItem* item = new QListWidgetItem(listwidget); | |
43 item->setCheckState(player.GetEnabled() ? Qt::Checked : Qt::Unchecked); | |
44 item->setText(Strings::ToQString(player.GetName() + " (" + player.GetExecutable() + ")")); | |
45 { | |
46 QVariant v(QVariant::fromValue(player)); | |
47 item->setData(Qt::UserRole, v); | |
48 } | |
49 } | |
50 widget_layout->addWidget(listwidget); | |
51 } | |
52 | |
53 group_layout->addWidget(widget); | |
54 } | |
55 | |
56 full_layout->addWidget(group); | |
57 } | |
58 | |
59 full_layout->setSpacing(10); | |
60 full_layout->addStretch(); | |
61 | |
62 return result; | |
63 } | |
64 | |
65 void SettingsPageRecognition::SaveInfo() { | |
66 } | |
67 | |
68 SettingsPageRecognition::SettingsPageRecognition(QWidget* parent) : SettingsPage(parent, tr("Recognition")) { | |
69 AddTab(CreatePlayersWidget(), tr("Players")); | |
70 } |