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