comparison src/gui/dialog/settings/services.cc @ 108:2004b41d4a59

*: huge commit 1. WORKING LOCALIZATION + translation for Spanish and British English 2. idk like 2 changes for the dark theme :)
author Paper <mrpapersonic@gmail.com>
date Sun, 05 Nov 2023 23:31:49 -0500
parents 9b2b41f83a5e
children 275da698697d
comparison
equal deleted inserted replaced
107:49c8d1976869 108:2004b41d4a59
13 13
14 QWidget* SettingsPageServices::CreateMainPage() { 14 QWidget* SettingsPageServices::CreateMainPage() {
15 QWidget* result = new QWidget(this); 15 QWidget* result = new QWidget(this);
16 result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); 16 result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
17 17
18 QGroupBox* sync_group_box = new QGroupBox(tr("Synchronization"), result); 18 QVBoxLayout* full_layout = new QVBoxLayout(result);
19 sync_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
20 19
21 QLabel* sync_combo_box_label = new QLabel(tr("Active service and metadata provider:"), sync_group_box); 20 {
21 QGroupBox* sync_group_box = new QGroupBox(tr("Synchronization"), result);
22 sync_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
22 23
23 QComboBox* sync_combo_box = new QComboBox(sync_group_box); 24 QVBoxLayout* sync_layout = new QVBoxLayout(sync_group_box);
24 sync_combo_box->addItem(tr("AniList"));
25 connect(sync_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
26 [this](int index) { service = static_cast<Anime::Services>(index + 1); });
27 sync_combo_box->setCurrentIndex(static_cast<int>(service) - 1);
28 25
29 QLabel* sync_note_label = 26 {
30 new QLabel(tr("Note: Minori is unable to synchronize multiple services at the same time."), sync_group_box); 27 QLabel* sync_combo_box_label = new QLabel(tr("Active service and metadata provider:"), sync_group_box);
28 sync_layout->addWidget(sync_combo_box_label);
29 }
31 30
32 QVBoxLayout* sync_layout = new QVBoxLayout(sync_group_box); 31 {
33 sync_layout->addWidget(sync_combo_box_label); 32 QComboBox* sync_combo_box = new QComboBox(sync_group_box);
34 sync_layout->addWidget(sync_combo_box); 33 sync_combo_box->addItem(tr("AniList"));
35 sync_layout->addWidget(sync_note_label); 34 connect(sync_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
35 [this](int index) { service = static_cast<Anime::Services>(index + 1); });
36 sync_combo_box->setCurrentIndex(static_cast<int>(service) - 1);
37 sync_layout->addWidget(sync_combo_box);
38 }
36 39
37 QVBoxLayout* full_layout = new QVBoxLayout(result); 40 {
38 full_layout->addWidget(sync_group_box); 41 QLabel* sync_note_label =
42 new QLabel(tr("Note: Minori is unable to synchronize multiple services at the same time."), sync_group_box);
43 sync_layout->addWidget(sync_note_label);
44 }
45
46 full_layout->addWidget(sync_group_box);
47 }
48
39 full_layout->setSpacing(10); 49 full_layout->setSpacing(10);
40 full_layout->addStretch(); 50 full_layout->addStretch();
41 51
42 return result; 52 return result;
43 } 53 }
44 54
45 QWidget* SettingsPageServices::CreateAniListPage() { 55 QWidget* SettingsPageServices::CreateAniListPage() {
46 QWidget* result = new QWidget(this); 56 QWidget* result = new QWidget(this);
47 result->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); 57 result->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
48 58
49 QGroupBox* group_box = new QGroupBox(tr("Account"), result); 59 QVBoxLayout* full_layout = new QVBoxLayout(result);
50 group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
51 60
52 /* this is outdated! usernames are retrieved through a request to AniList now. 61 {
53 although that's a bit... erm... cancerous, maybe this method IS useful. IDK */ 62 /* Account */
54 QLabel* username_entry_label = new QLabel(tr("Username: (not your email address)"), group_box); 63 QGroupBox* group_box = new QGroupBox(tr("Account"), result);
64 group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
55 65
56 QWidget* auth_widget = new QWidget(group_box); 66 QVBoxLayout* layout = new QVBoxLayout(group_box);
57 QLineEdit* username_entry = new QLineEdit(username, auth_widget);
58 connect(username_entry, &QLineEdit::editingFinished, this,
59 [this, username_entry] { username = username_entry->text(); });
60 67
61 QPushButton* auth_button = new QPushButton(auth_widget); 68 {
62 connect(auth_button, &QPushButton::clicked, this, [] { Services::AniList::AuthorizeUser(); }); 69 QLabel* username_entry_label = new QLabel(tr("Username: (not your email address)"), group_box);
63 auth_button->setText(session.config.anilist.auth_token.empty() ? tr("Authorize...") : tr("Re-authorize...")); 70 layout->addWidget(username_entry_label);
71 }
64 72
65 QHBoxLayout* auth_layout = new QHBoxLayout(auth_widget); 73 {
66 auth_layout->addWidget(username_entry); 74 /* Authorization */
67 auth_layout->addWidget(auth_button); 75 QWidget* auth_widget = new QWidget(group_box);
76 QHBoxLayout* auth_layout = new QHBoxLayout(auth_widget);
68 77
69 QLabel* note_label = new QLabel(tr("<a href=\"http://anilist.co/\">Create a new AniList account</a>"), group_box); 78 {
70 note_label->setTextFormat(Qt::RichText); 79 /* Username: this literally never gets used btw */
71 note_label->setTextInteractionFlags(Qt::TextBrowserInteraction); 80 QLineEdit* username_entry = new QLineEdit(username, auth_widget);
72 note_label->setOpenExternalLinks(true); 81 connect(username_entry, &QLineEdit::editingFinished, this,
82 [this, username_entry] { username = username_entry->text(); });
83 auth_layout->addWidget(username_entry);
84 }
73 85
74 QVBoxLayout* layout = new QVBoxLayout(group_box); 86 {
75 layout->addWidget(username_entry_label); 87 /* The actual auth button */
76 layout->addWidget(auth_widget); 88 QPushButton* auth_button = new QPushButton(auth_widget);
77 layout->addWidget(note_label); 89 connect(auth_button, &QPushButton::clicked, this, [] { Services::AniList::AuthorizeUser(); });
90 auth_button->setText(session.config.anilist.auth_token.empty() ? tr("Authorize...") : tr("Re-authorize..."));
91 auth_layout->addWidget(auth_button);
92 }
78 93
79 QVBoxLayout* full_layout = new QVBoxLayout(result); 94 layout->addWidget(auth_widget);
80 full_layout->addWidget(group_box); 95 }
96
97 {
98 /* Note on creating new accounts... */
99 QLabel* note_label = new QLabel(tr("<a href=\"http://anilist.co/\">Create a new AniList account</a>"), group_box);
100 note_label->setTextFormat(Qt::RichText);
101 note_label->setTextInteractionFlags(Qt::TextBrowserInteraction);
102 note_label->setOpenExternalLinks(true);
103 layout->addWidget(note_label);
104 }
105
106 full_layout->addWidget(group_box);
107 }
108
81 full_layout->setSpacing(10); 109 full_layout->setSpacing(10);
82 full_layout->addStretch(); 110 full_layout->addStretch();
83 return result; 111 return result;
84 } 112 }
85 113
86 void SettingsPageServices::SaveInfo() { 114 void SettingsPageServices::SaveInfo() {
87 // session.config.anilist.username = 115 // see services/anilist.cc for why this is commented out
88 Strings::ToUtf8String(username); 116 // session.config.anilist.username = Strings::ToUtf8String(username);
89 session.config.service = service; 117 session.config.service = service;
90 } 118 }
91 119
92 SettingsPageServices::SettingsPageServices(QWidget* parent) : SettingsPage(parent, tr("Services")) { 120 SettingsPageServices::SettingsPageServices(QWidget* parent) : SettingsPage(parent, tr("Services")) {
93 username = QString::fromUtf8(session.config.anilist.username.c_str()); 121 // username = QString::fromUtf8(session.config.anilist.username.c_str());
94 service = session.config.service; 122 service = session.config.service;
95 AddTab(CreateMainPage(), tr("Main")); 123 AddTab(CreateMainPage(), tr("Main"));
96 AddTab(CreateAniListPage(), tr("AniList")); 124 AddTab(CreateAniListPage(), tr("AniList"));
97 } 125 }