# HG changeset patch # User Paper # Date 1698082662 14400 # Node ID 8b65c417c225aa3aa5c965ba193db3cf2706eb1a # Parent 9b2b41f83a5e4057b1bead56f215d514bf619c82 *: fix old stuff, make video players and extensions constants diff -r 9b2b41f83a5e -r 8b65c417c225 CMakeLists.txt --- a/CMakeLists.txt Mon Oct 23 12:07:27 2023 -0400 +++ b/CMakeLists.txt Mon Oct 23 13:37:42 2023 -0400 @@ -99,6 +99,7 @@ src/services/anilist.cc # Tracking + src/track/constants.cc src/track/media.cc # Qt resources diff -r 9b2b41f83a5e -r 8b65c417c225 include/gui/widgets/anime_info.h --- a/include/gui/widgets/anime_info.h Mon Oct 23 12:07:27 2023 -0400 +++ b/include/gui/widgets/anime_info.h Mon Oct 23 13:37:42 2023 -0400 @@ -1,6 +1,7 @@ #ifndef __gui__widgets__anime_info_h #define __gui__widgets__anime_info_h #include +#include "gui/widgets/text.h" namespace Anime { class Anime; @@ -12,7 +13,7 @@ public: AnimeInfoWidget(QWidget* parent = nullptr); AnimeInfoWidget(const Anime::Anime& anime, QWidget* parent = nullptr); - SetAnime(const Anime::Anime& anime); + void SetAnime(const Anime::Anime& anime); private: std::shared_ptr _title = nullptr; diff -r 9b2b41f83a5e -r 8b65c417c225 include/track/constants.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/include/track/constants.h Mon Oct 23 13:37:42 2023 -0400 @@ -0,0 +1,9 @@ +#ifndef __track__constants_h +#define __track__constants_h +#include +#include + +extern const std::vector media_extensions; +extern const std::vector media_players; + +#endif // __track__constants_h diff -r 9b2b41f83a5e -r 8b65c417c225 src/gui/pages/now_playing.cc --- a/src/gui/pages/now_playing.cc Mon Oct 23 12:07:27 2023 -0400 +++ b/src/gui/pages/now_playing.cc Mon Oct 23 13:37:42 2023 -0400 @@ -1,5 +1,6 @@ #include "gui/pages/now_playing.h" #include "core/anime_db.h" +#include "core/strings.h" #include "gui/widgets/anime_info.h" #include "gui/widgets/text.h" #include @@ -7,10 +8,11 @@ #include #include -/* This is here to make it easier to switch between the - "sub-pages", i.e., not playing and playing. - - TODO: find a way to do this more efficiently */ +/* WARNING: HACKY STUFF HERE + + The Now Playing page is designed to "switch" between these two sub-pages, + using a QStackedWidget. This *could* be the best way to do this, but this + feels very very stupid and I really don't like it */ namespace NowPlayingPages { class Default : public QWidget { @@ -66,7 +68,7 @@ return; if (Anime::db.items.find(id) != Anime::db.items.end()) { const Anime::Anime& anime = Anime::db.items[_id = id]; - _title->setText(anime.GetUserPreferredTitle()); + _title->setText(Strings::ToQString(anime.GetUserPreferredTitle())); _info->SetAnime(anime); } } diff -r 9b2b41f83a5e -r 8b65c417c225 src/gui/widgets/anime_info.cc --- a/src/gui/widgets/anime_info.cc Mon Oct 23 12:07:27 2023 -0400 +++ b/src/gui/widgets/anime_info.cc Mon Oct 23 13:37:42 2023 -0400 @@ -12,11 +12,10 @@ _title.reset(new TextWidgets::OneLineSection(tr("Alternative titles"), "", this)); layout->addWidget(_title.get()); - _details.reset(new TextWidgets::LabelledSection(tr("Details"), new TextWidgets::LabelledSection( - tr("Details"), tr("Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:"), "", this), "", this)); + _details.reset(new TextWidgets::LabelledSection(tr("Details"), tr("Type:\nEpisodes:\nStatus:\nSeason:\nGenres:\nScore:"), "", this)); layout->addWidget(_details.get()); - _synopsis.reset(new TextWidgets::LabelledSection(tr("Synopsis"), "", this)); + _synopsis.reset(new TextWidgets::SelectableSection(tr("Synopsis"), "", this)); _synopsis->GetParagraph()->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); layout->addWidget(_synopsis.get()); } @@ -25,9 +24,9 @@ SetAnime(anime); } -AnimeInfoWidget::SetAnime(const Anime::Anime& anime) { +void AnimeInfoWidget::SetAnime(const Anime::Anime& anime) { /* alt titles */ - _title->GetParagraph()->SetText(Strings::ToQString(Strings::Implode(anime.GetTitleSynonyms(), ", "))); + _title->GetLine()->setText(Strings::ToQString(Strings::Implode(anime.GetTitleSynonyms(), ", "))); /* details */ QString details_data; @@ -39,10 +38,8 @@ << Strings::Implode(anime.GetGenres(), ", ").c_str() << "\n" << anime.GetAudienceScore() << "%"; _details->GetParagraph()->SetText(Strings::ToQString(Strings::Implode(anime.GetTitleSynonyms(), ", "))); - layout->addWidget(); _synopsis->GetParagraph()->SetText(Strings::ToQString(Strings::Implode(anime.GetTitleSynonyms(), ", "))); - layout->addWidget(synopsis); } #include "gui/widgets/moc_anime_info.cpp" diff -r 9b2b41f83a5e -r 8b65c417c225 src/gui/window.cc --- a/src/gui/window.cc Mon Oct 23 12:07:27 2023 -0400 +++ b/src/gui/window.cc Mon Oct 23 13:37:42 2023 -0400 @@ -266,7 +266,6 @@ dialog.exec(); }); addToolBar(toolbar); - } void MainWindow::SetActivePage(QWidget* page) { diff -r 9b2b41f83a5e -r 8b65c417c225 src/track/constants.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/track/constants.cc Mon Oct 23 13:37:42 2023 -0400 @@ -0,0 +1,19 @@ +#include "track/constants.h" + +const std::vector media_extensions = { + "avi", + "asf", + "mp4", + "mkv", + "wmv" +}; + +const std::vector media_players = { +#ifdef MACOSX + "VLC" +#elif WIN32 + "vlc.exe", "mpc-hc.exe", "mpc-hc64.exe", "wmplayer.exe" +#else // linux, unix, whatevs + "vlc", "mpv", "mpc-qt" +#endif +}; diff -r 9b2b41f83a5e -r 8b65c417c225 src/track/media.cc --- a/src/track/media.cc Mon Oct 23 12:07:27 2023 -0400 +++ b/src/track/media.cc Mon Oct 23 13:37:42 2023 -0400 @@ -1,12 +1,13 @@ #include "track/media.h" +#include "track/constants.h" #include "animia.h" #include "anitomy/anitomy.h" #include "core/filesystem.h" #include "core/strings.h" +#include #include +#include #include -#include -#include namespace Track { namespace Media { @@ -15,13 +16,16 @@ /* getting all open files */ std::vector pids = Animia::get_all_pids(); for (int i : pids) { - if (Animia::get_process_name(i) == "vlc") { - std::vector files = Animia::filter_system_files(Animia::get_open_files(i)); - for (std::string s : files) { - qDebug() << Strings::ToQString(s); - Filesystem::Path p(s); - if (p.Extension() == "mp4") - return p; + for (const std::string& player : media_players) { + if (Animia::get_process_name(i) == player) { + std::vector files = Animia::filter_system_files(Animia::get_open_files(i)); + for (const std::string& f : files) { + Filesystem::Path p(f); + for (const std::string& ext : media_extensions) { + if (p.Extension() == ext) + return p; + } + } } } } @@ -29,7 +33,7 @@ } std::unordered_map GetMapFromElements(const anitomy::Elements& elements) { - /* there are way more than this in anitomy, but we only need basic information + /* there are way more than this in anitomy, but we only need basic information I also just prefer using maps than using the ".get()" stuff which is why I'm doing this */ std::unordered_map ret;