Mercurial > minori
annotate src/gui/dialog/settings/services.cc @ 253:b3549da699a6
*: ooooh! stupid big commit!
oops
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Tue, 06 Feb 2024 16:56:32 -0500 |
| parents | ff0061e75f0f |
| children | 862d0d8619f6 |
| rev | line source |
|---|---|
| 10 | 1 #include "core/anime.h" |
| 2 #include "core/session.h" | |
|
65
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
63
diff
changeset
|
3 #include "core/strings.h" |
| 10 | 4 #include "gui/dialog/settings.h" |
| 5 #include "services/anilist.h" | |
| 6 #include <QComboBox> | |
| 7 #include <QGroupBox> | |
| 76 | 8 #include <QLabel> |
| 9 #include <QLineEdit> | |
| 10 | 10 #include <QPushButton> |
| 11 #include <QSizePolicy> | |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
65
diff
changeset
|
12 #include <QVBoxLayout> |
| 10 | 13 |
| 14 QWidget* SettingsPageServices::CreateMainPage() { | |
| 15 QWidget* result = new QWidget(this); | |
| 16 result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); | |
| 17 | |
| 108 | 18 QVBoxLayout* full_layout = new QVBoxLayout(result); |
| 10 | 19 |
| 108 | 20 { |
| 21 QGroupBox* sync_group_box = new QGroupBox(tr("Synchronization"), result); | |
| 22 sync_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); | |
| 10 | 23 |
| 108 | 24 QVBoxLayout* sync_layout = new QVBoxLayout(sync_group_box); |
| 25 | |
| 26 { | |
| 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 } | |
| 10 | 30 |
| 108 | 31 { |
| 32 QComboBox* sync_combo_box = new QComboBox(sync_group_box); | |
| 33 sync_combo_box->addItem(tr("AniList")); | |
| 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 } | |
| 10 | 39 |
| 108 | 40 { |
| 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 } | |
| 10 | 45 |
| 108 | 46 full_layout->addWidget(sync_group_box); |
| 47 } | |
| 48 | |
| 10 | 49 full_layout->setSpacing(10); |
| 50 full_layout->addStretch(); | |
|
68
2417121d894e
*: normalize usage of layouts
Paper <mrpapersonic@gmail.com>
parents:
65
diff
changeset
|
51 |
| 10 | 52 return result; |
| 53 } | |
| 54 | |
| 55 QWidget* SettingsPageServices::CreateAniListPage() { | |
| 56 QWidget* result = new QWidget(this); | |
| 57 result->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); | |
| 58 | |
| 108 | 59 QVBoxLayout* full_layout = new QVBoxLayout(result); |
| 10 | 60 |
| 108 | 61 { |
| 62 /* Account */ | |
| 63 QGroupBox* group_box = new QGroupBox(tr("Account"), result); | |
| 64 group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); | |
| 65 | |
| 66 QVBoxLayout* layout = new QVBoxLayout(group_box); | |
| 10 | 67 |
| 108 | 68 { |
| 69 /* Authorization */ | |
| 70 QWidget* auth_widget = new QWidget(group_box); | |
| 71 QHBoxLayout* auth_layout = new QHBoxLayout(auth_widget); | |
| 10 | 72 |
| 108 | 73 { |
| 74 QPushButton* auth_button = new QPushButton(auth_widget); | |
| 75 connect(auth_button, &QPushButton::clicked, this, [] { Services::AniList::AuthorizeUser(); }); | |
| 120 | 76 auth_button->setText(session.config.auth.anilist.auth_token.empty() ? tr("Authorize...") : tr("Re-authorize...")); |
| 108 | 77 auth_layout->addWidget(auth_button); |
| 78 } | |
| 10 | 79 |
| 108 | 80 layout->addWidget(auth_widget); |
| 81 } | |
| 10 | 82 |
| 108 | 83 { |
| 84 /* Note on creating new accounts... */ | |
| 85 QLabel* note_label = new QLabel(tr("<a href=\"http://anilist.co/\">Create a new AniList account</a>"), group_box); | |
| 86 note_label->setTextFormat(Qt::RichText); | |
| 87 note_label->setTextInteractionFlags(Qt::TextBrowserInteraction); | |
| 88 note_label->setOpenExternalLinks(true); | |
| 89 layout->addWidget(note_label); | |
| 90 } | |
| 91 | |
| 92 full_layout->addWidget(group_box); | |
| 93 } | |
| 10 | 94 |
| 95 full_layout->setSpacing(10); | |
| 96 full_layout->addStretch(); | |
| 97 return result; | |
| 98 } | |
| 99 | |
| 100 void SettingsPageServices::SaveInfo() { | |
| 108 | 101 // see services/anilist.cc for why this is commented out |
| 10 | 102 session.config.service = service; |
| 103 } | |
| 104 | |
| 105 SettingsPageServices::SettingsPageServices(QWidget* parent) : SettingsPage(parent, tr("Services")) { | |
| 106 service = session.config.service; | |
| 107 AddTab(CreateMainPage(), tr("Main")); | |
| 108 AddTab(CreateAniListPage(), tr("AniList")); | |
| 109 } |
