Mercurial > minori
changeset 82:8b65c417c225
*: fix old stuff, make video players and extensions constants
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Mon, 23 Oct 2023 13:37:42 -0400 |
parents | 9b2b41f83a5e |
children | d02fdf1d6708 |
files | CMakeLists.txt include/gui/widgets/anime_info.h include/track/constants.h src/gui/pages/now_playing.cc src/gui/widgets/anime_info.cc src/gui/window.cc src/track/constants.cc src/track/media.cc |
diffstat | 8 files changed, 56 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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 <QWidget> +#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<TextWidgets::OneLineSection> _title = nullptr;
--- /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 <string> +#include <vector> + +extern const std::vector<std::string> media_extensions; +extern const std::vector<std::string> media_players; + +#endif // __track__constants_h
--- 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 <QLabel> @@ -7,10 +8,11 @@ #include <QVBoxLayout> #include <QWidget> -/* 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); } }
--- 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"
--- 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) {
--- /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<std::string> media_extensions = { + "avi", + "asf", + "mp4", + "mkv", + "wmv" +}; + +const std::vector<std::string> 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 +};
--- 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 <QDebug> #include <string> +#include <unordered_map> #include <vector> -#include <unordered_map> -#include <QDebug> namespace Track { namespace Media { @@ -15,13 +16,16 @@ /* getting all open files */ std::vector<int> pids = Animia::get_all_pids(); for (int i : pids) { - if (Animia::get_process_name(i) == "vlc") { - std::vector<std::string> 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<std::string> 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<std::string, std::string> 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<std::string, std::string> ret;