annotate src/services/services.cc @ 101:c537996cf67b

*: multitude of config changes 1. theme is now configurable from the settings menu (but you have to restart for it to apply) 2. config is now stored in an INI file, with no method of conversion from json (this repo is private-ish anyway)
author Paper <mrpapersonic@gmail.com>
date Fri, 03 Nov 2023 14:06:02 -0400
parents 9b2b41f83a5e
children 80f49f623d30
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15
cde8f67a7c7d *: update, megacommit :)
Paper <mrpapersonic@gmail.com>
parents: 10
diff changeset
1 #include "services/services.h"
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
2 #include "core/session.h"
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 52
diff changeset
3 #include "gui/dialog/settings.h"
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
4 #include "services/anilist.h"
47
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
5 #include <QMessageBox>
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
6
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
7 namespace Services {
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
8
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
9 void Synchronize() {
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
10 switch (session.config.service) {
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
11 case Anime::Services::ANILIST: AniList::GetAnimeList(); break;
47
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
12 default: {
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
13 QMessageBox msg;
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
14 msg.setInformativeText("It seems you haven't yet selected a service to use.");
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
15 msg.setText("Would you like to select one now?");
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
16 msg.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
17 msg.setDefaultButton(QMessageBox::Yes);
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
18 int ret = msg.exec();
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
19 if (ret == QMessageBox::Yes) {
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
20 SettingsDialog dialog;
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
21 dialog.exec();
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
22 }
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
23 break;
d8eb763e6661 information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents: 44
diff changeset
24 }
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
25 }
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
26 }
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
27
52
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
28 void UpdateAnimeEntry(int id) {
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
29 switch (session.config.service) {
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
30 case Anime::Services::ANILIST: AniList::UpdateAnimeEntry(id); break;
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
31 default: break;
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
32 }
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
33 }
0c4138de2ea7 anime list: we are finally read-write
Paper <mrpapersonic@gmail.com>
parents: 47
diff changeset
34
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
35 bool Authorize() {
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
36 switch (session.config.service) {
63
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 52
diff changeset
37 case Anime::Services::ANILIST: return AniList::AuthorizeUser();
3d2decf093bb *: fix many clang warnings
Paper <mrpapersonic@gmail.com>
parents: 52
diff changeset
38 default: return true;
10
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
39 }
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
40 }
Paper <mrpapersonic@gmail.com>
parents: 9
diff changeset
41
44
619cbd6e69f9 filesystem: fix CreateDirectories function
Paper <mrpapersonic@gmail.com>
parents: 15
diff changeset
42 }; // namespace Services