Mercurial > minori
diff 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 |
line wrap: on
line diff
--- a/src/gui/dialog/settings/services.cc Sun Nov 05 17:44:49 2023 -0500 +++ b/src/gui/dialog/settings/services.cc Sun Nov 05 23:31:49 2023 -0500 @@ -15,27 +15,37 @@ QWidget* result = new QWidget(this); result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); - QGroupBox* sync_group_box = new QGroupBox(tr("Synchronization"), result); - sync_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); + QVBoxLayout* full_layout = new QVBoxLayout(result); - QLabel* sync_combo_box_label = new QLabel(tr("Active service and metadata provider:"), sync_group_box); + { + QGroupBox* sync_group_box = new QGroupBox(tr("Synchronization"), result); + sync_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); - QComboBox* sync_combo_box = new QComboBox(sync_group_box); - sync_combo_box->addItem(tr("AniList")); - connect(sync_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, - [this](int index) { service = static_cast<Anime::Services>(index + 1); }); - sync_combo_box->setCurrentIndex(static_cast<int>(service) - 1); + QVBoxLayout* sync_layout = new QVBoxLayout(sync_group_box); + + { + QLabel* sync_combo_box_label = new QLabel(tr("Active service and metadata provider:"), sync_group_box); + sync_layout->addWidget(sync_combo_box_label); + } - QLabel* sync_note_label = - new QLabel(tr("Note: Minori is unable to synchronize multiple services at the same time."), sync_group_box); + { + QComboBox* sync_combo_box = new QComboBox(sync_group_box); + sync_combo_box->addItem(tr("AniList")); + connect(sync_combo_box, QOverload<int>::of(&QComboBox::currentIndexChanged), this, + [this](int index) { service = static_cast<Anime::Services>(index + 1); }); + sync_combo_box->setCurrentIndex(static_cast<int>(service) - 1); + sync_layout->addWidget(sync_combo_box); + } - QVBoxLayout* sync_layout = new QVBoxLayout(sync_group_box); - sync_layout->addWidget(sync_combo_box_label); - sync_layout->addWidget(sync_combo_box); - sync_layout->addWidget(sync_note_label); + { + QLabel* sync_note_label = + new QLabel(tr("Note: Minori is unable to synchronize multiple services at the same time."), sync_group_box); + sync_layout->addWidget(sync_note_label); + } - QVBoxLayout* full_layout = new QVBoxLayout(result); - full_layout->addWidget(sync_group_box); + full_layout->addWidget(sync_group_box); + } + full_layout->setSpacing(10); full_layout->addStretch(); @@ -46,51 +56,69 @@ QWidget* result = new QWidget(this); result->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); - QGroupBox* group_box = new QGroupBox(tr("Account"), result); - group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); + QVBoxLayout* full_layout = new QVBoxLayout(result); - /* this is outdated! usernames are retrieved through a request to AniList now. - although that's a bit... erm... cancerous, maybe this method IS useful. IDK */ - QLabel* username_entry_label = new QLabel(tr("Username: (not your email address)"), group_box); + { + /* Account */ + QGroupBox* group_box = new QGroupBox(tr("Account"), result); + group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); + + QVBoxLayout* layout = new QVBoxLayout(group_box); - QWidget* auth_widget = new QWidget(group_box); - QLineEdit* username_entry = new QLineEdit(username, auth_widget); - connect(username_entry, &QLineEdit::editingFinished, this, - [this, username_entry] { username = username_entry->text(); }); + { + QLabel* username_entry_label = new QLabel(tr("Username: (not your email address)"), group_box); + layout->addWidget(username_entry_label); + } - QPushButton* auth_button = new QPushButton(auth_widget); - connect(auth_button, &QPushButton::clicked, this, [] { Services::AniList::AuthorizeUser(); }); - auth_button->setText(session.config.anilist.auth_token.empty() ? tr("Authorize...") : tr("Re-authorize...")); + { + /* Authorization */ + QWidget* auth_widget = new QWidget(group_box); + QHBoxLayout* auth_layout = new QHBoxLayout(auth_widget); - QHBoxLayout* auth_layout = new QHBoxLayout(auth_widget); - auth_layout->addWidget(username_entry); - auth_layout->addWidget(auth_button); + { + /* Username: this literally never gets used btw */ + QLineEdit* username_entry = new QLineEdit(username, auth_widget); + connect(username_entry, &QLineEdit::editingFinished, this, + [this, username_entry] { username = username_entry->text(); }); + auth_layout->addWidget(username_entry); + } + + { + /* The actual auth button */ + QPushButton* auth_button = new QPushButton(auth_widget); + connect(auth_button, &QPushButton::clicked, this, [] { Services::AniList::AuthorizeUser(); }); + auth_button->setText(session.config.anilist.auth_token.empty() ? tr("Authorize...") : tr("Re-authorize...")); + auth_layout->addWidget(auth_button); + } - QLabel* note_label = new QLabel(tr("<a href=\"http://anilist.co/\">Create a new AniList account</a>"), group_box); - note_label->setTextFormat(Qt::RichText); - note_label->setTextInteractionFlags(Qt::TextBrowserInteraction); - note_label->setOpenExternalLinks(true); + layout->addWidget(auth_widget); + } - QVBoxLayout* layout = new QVBoxLayout(group_box); - layout->addWidget(username_entry_label); - layout->addWidget(auth_widget); - layout->addWidget(note_label); + { + /* Note on creating new accounts... */ + QLabel* note_label = new QLabel(tr("<a href=\"http://anilist.co/\">Create a new AniList account</a>"), group_box); + note_label->setTextFormat(Qt::RichText); + note_label->setTextInteractionFlags(Qt::TextBrowserInteraction); + note_label->setOpenExternalLinks(true); + layout->addWidget(note_label); + } + + full_layout->addWidget(group_box); + } - QVBoxLayout* full_layout = new QVBoxLayout(result); - full_layout->addWidget(group_box); full_layout->setSpacing(10); full_layout->addStretch(); return result; } void SettingsPageServices::SaveInfo() { - // session.config.anilist.username = - Strings::ToUtf8String(username); + // see services/anilist.cc for why this is commented out + // session.config.anilist.username = Strings::ToUtf8String(username); session.config.service = service; } SettingsPageServices::SettingsPageServices(QWidget* parent) : SettingsPage(parent, tr("Services")) { - username = QString::fromUtf8(session.config.anilist.username.c_str()); + // username = QString::fromUtf8(session.config.anilist.username.c_str()); service = session.config.service; AddTab(CreateMainPage(), tr("Main")); AddTab(CreateAniListPage(), tr("AniList"));