# HG changeset patch # User Paper # Date 1701965641 18000 # Node ID 975a3f0965e219268bf60fe2109c6788ac1e08fd # Parent 8548dc425697317b4428639e7cca02478e6650b1 locale: only attempt loading locales after QApplication is init'd also the general application stuff and anime list is separated in settings diff -r 8548dc425697 -r 975a3f0965e2 CMakeLists.txt --- a/CMakeLists.txt Thu Dec 07 03:17:05 2023 -0500 +++ b/CMakeLists.txt Thu Dec 07 11:14:01 2023 -0500 @@ -123,7 +123,6 @@ set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/rc/locale") -# dumb little hack to get this working on Qt5 and Qt6 if(UPDATE_TRANSLATIONS) cmake_language(CALL qt${QT_VERSION_MAJOR}_create_translation ${SRC_FILES} ${TS_FILES} OPTIONS "-I${CMAKE_CURRENT_SOURCE_DIR}/include") endif() @@ -196,6 +195,7 @@ target_compile_options(minori PRIVATE -Wall -Wpedantic -Wextra -Wsuggest-override -Wold-style-cast) if(APPLE) target_compile_definitions(minori PUBLIC MACOSX) + set_target_properties(minori PROPERTIES MACOSX_BUNDLE TRUE) elseif(WIN32) target_compile_definitions(minori PUBLIC WIN32) endif() diff -r 8548dc425697 -r 975a3f0965e2 include/core/session.h --- a/include/core/session.h Thu Dec 07 03:17:05 2023 -0500 +++ b/include/core/session.h Thu Dec 07 11:14:01 2023 -0500 @@ -16,7 +16,7 @@ Config config; private: - uint32_t requests = 0; + unsigned int requests = 0; QElapsedTimer timer; }; diff -r 8548dc425697 -r 975a3f0965e2 include/gui/dialog/settings.h --- a/include/gui/dialog/settings.h Thu Dec 07 03:17:05 2023 -0500 +++ b/include/gui/dialog/settings.h Thu Dec 07 11:14:01 2023 -0500 @@ -50,6 +50,7 @@ private: QWidget* CreateAnimeListWidget(); + QWidget* CreateGeneralWidget(); decltype(session.config.anime_list.score_format) format; Themes theme; QLocale locale; diff -r 8548dc425697 -r 975a3f0965e2 rc/locale/en_GB.ts --- a/rc/locale/en_GB.ts Thu Dec 07 03:17:05 2023 -0500 +++ b/rc/locale/en_GB.ts Thu Dec 07 11:14:01 2023 -0500 @@ -4,7 +4,7 @@ AboutWindow - + About Minori @@ -40,23 +40,28 @@ AnimeListPage - - + + Column visibility - + Reset to defaults - + Information - + + Edit + + + + Delete from list... @@ -64,57 +69,57 @@ AnimeListPageModel - + Anime title - + Progress - - Episodes - - - - - Type - - - - - Score - - - - Season + Episodes - Date started + Type - Date completed + Score - Notes + Season + Date started + + + + + Date completed + + + + + Notes + + + + Average score - + Last updated @@ -185,83 +190,83 @@ MainWindow - + Now Playing - + Anime List - - History - - - - - Statistics - - - - - Search - - - - - Seasons - - - - - Torrents - - - - &File + History + + + + + Statistics - &Library folders + Search + + + + + Seasons + Torrents + + + + + &File + + + + + &Library folders + + + + &Add new folder... - + &Scan available episodes - - + + ... - + E&xit - + &Services - + Synchronize &list Synchronise &list - + &Tools @@ -270,87 +275,87 @@ Enable &auto synchronisation - + &Settings - + &View - + &Now Playing - + &Anime List - + &History - + &Statistics - + S&earch - + Se&asons - + &Torrents - - &Help - - - - - &About Minori - - - - - About &Qt - - - + &Help + + + + + &About Minori + + + + + About &Qt + + + + &Synchronize &Synchronise - + S&ettings - + Error synchronizing with service! - + It seems you haven't yet selected a service to use. - + Would you like to select one now? @@ -358,7 +363,7 @@ NowPlayingPages::Default - + Now Playing @@ -366,184 +371,209 @@ QCoreApplication - + Currently watching - + Plan to watch - + Completed - + Dropped - + On hold - + Not in list - + TV - + TV short - + OVA - + Special - + ONA - + Music - - - + + + Unknown - + Winter - + Summer - + + 3-point + + + + + 5-point + + + + + 10-point + + + + + 10-point (Decimal) + + + + + 100-point + + + + Movie - + Fall - + Spring - + Currently airing - + Finished airing - + Not yet aired - + Cancelled - + On hiatus - + AniList - + None - + Native - + English - + Romaji + + Author: + + + - Author: + Third party components: - - Third party components: + + Special thanks: + + + + + for creating Taiga - Special thanks: + and + + + + + for creating BreezeStyleSheets, on which the dark theme in this program is based off of - for creating Taiga - - - - - and + for providing some sample code for detecting dark mode on Windows and macOS - for creating BreezeStyleSheets, on which the dark theme in this program is based off of - - - - - for providing some sample code for detecting dark mode on Windows and macOS - - - - for providing information on getting open file descriptors on macOS @@ -551,22 +581,27 @@ SettingsDialog - + Settings - + Services - + Application - + + Recognition + + + + Torrents @@ -574,117 +609,151 @@ SettingsPageApplication - + Actions - + Double click: - + View anime info - + Middle click: - + Play next episode - + + Appearance - + Title language preference: - + Romaji - + Native - + English - + + Rating system: + + + + Application theme: - + Default - + Light - + Dark - - Set application locale: - - - - + Highlight anime if next episode is available in library folders - + Display highlighted anime above others - + Progress - + Display aired episodes (estimated) - + Display available episodes in library folders - + + Application locale: + + + + Application - + + General + + + + Anime list + SettingsPageRecognition + + + Enable media player detection + + + + + Allowed media players: + + + + + Recognition + + + + + Media players + + + + SettingsPageServices @@ -757,7 +826,7 @@ - Application + Torrents @@ -769,12 +838,12 @@ StatisticsPage - + Anime list - + Anime count: Episode count: Time spent watching: @@ -784,17 +853,17 @@ - + Score distribution - + Minori - + Uptime: Requests made: @@ -803,22 +872,22 @@ TorrentsPage - + &Check new torrents - + Download &marked torrents - + &Discard all - + &Settings @@ -826,57 +895,57 @@ TorrentsPageListModel - + Anime title - + Episode - + Group - + Size - + Resolution - + Seeding - + Leeching - + Downloading - + Description - + Filename - + Release date diff -r 8548dc425697 -r 975a3f0965e2 rc/locale/es.ts --- a/rc/locale/es.ts Thu Dec 07 03:17:05 2023 -0500 +++ b/rc/locale/es.ts Thu Dec 07 11:14:01 2023 -0500 @@ -4,7 +4,7 @@ AboutWindow - + About Minori Acerca de Minori @@ -45,23 +45,28 @@ AnimeListPage - - + + Column visibility Visibilidad de la columna - + Reset to defaults Restablecer valores predeterminado - + Information Información - + + Edit + + + + Delete from list... Borrar de la lista... @@ -69,57 +74,57 @@ AnimeListPageModel - + Anime title Título del anime - + Progress Progreso - + Episodes Episodios - + Type Formato - + Score Puntuación - + Season Temporada - + Date started Fecha de inicio - + Date completed Fecha de finalización - + Notes Notas - + Average score Puntuación media - + Last updated Última actualización @@ -190,63 +195,63 @@ MainWindow - + Now Playing Jugando ahora - + Anime List Lista de anime - + History Historia - + Statistics Estadísticas - + Search Buscar - + Seasons Temporadas - + Torrents - + &File &Fichero - + &Library folders Directorios de la biblioteca (&L) - + &Add new folder... &Añadir una nueva directorios... - + &Scan available episodes E&scanear episodios disponibles - - + + ... @@ -259,17 +264,17 @@ Ver episodio aleato&rio - + E&xit Salida (&X) - + &Services &Servicios - + Synchronize &list Sincronizar &lista @@ -310,7 +315,7 @@ Ir a mi &historia - + &Tools Ins&trumentos @@ -339,47 +344,47 @@ Activar la sincronización &automática - + &Settings Configuración (&S) - + &View &Ver - + &Now Playing Jugando ahora (&N) - + &Anime List Lista de &anime - + &History &Historia - + &Statistics E&stadísticas - + S&earch Buscar (&S) - + Se&asons Tempor&adas - + &Torrents @@ -388,22 +393,22 @@ Mostrar barra lateral - + &Help Ayuda (&H) - + &About Minori &Acerca de Minori - + About &Qt Acerca de &Qt - + &Synchronize &Sincronice @@ -416,22 +421,22 @@ Marcador de posición - + S&ettings Configuración (&S) - + Error synchronizing with service! Error al sincronizar con el servicio! - + It seems you haven't yet selected a service to use. Parece que aún no has seleccionado un servicio para usar. - + Would you like to select one now? ¿Quieres seleccionar uno ahora? @@ -439,7 +444,7 @@ NowPlayingPages::Default - + Now Playing Jugando ahora @@ -447,184 +452,209 @@ QCoreApplication - + Currently watching Actualmente viendo - + Plan to watch Plan para ver - + Completed Completado - + Dropped Dejado - + On hold En espera - + Not in list No en la lista - + TV TV - + TV short Corto - + OVA OVA - + Movie Película - + Special Especial - + ONA ONA - + Music Música - - - + + + Unknown Desconocido - + Winter Invierno - + Summer Verano - + Fall Otoño - + Spring Primavera - + Currently airing En emisión - + Finished airing Emisión terminada - + Not yet aired Aún no emitido - + Cancelled Cancelado - + On hiatus En pausa - + AniList AniList - + None Ninguno - + Native Nativo - + English Inglés - + Romaji Romaji - + + 3-point + + + + + 5-point + + + + + 10-point + + + + + 10-point (Decimal) + + + + + 100-point + + + + Author: Autor: - + Third party components: Componentes de terceros: - + Special thanks: Agradecimientos especiales: - + for creating Taiga para crear Taiga - + and y - + for creating BreezeStyleSheets, on which the dark theme in this program is based off of para crear BreezeStyleSheets, en el que se basa el tema oscuro de este programa - + for providing some sample code for detecting dark mode on Windows and macOS por proporcionar algunos ejemplos de código para detectar el modo oscuro en Windows y macOS - + for providing information on getting open file descriptors on macOS para obtener información sobre descriptores de archivos abiertos en macOS @@ -632,22 +662,27 @@ SettingsDialog - + Settings Configuración - + Services Servicios - + Application Aplicación - + + Recognition + + + + Torrents @@ -655,117 +690,155 @@ SettingsPageApplication - + Actions Acciones - + Double click: Haz doble clic: - + View anime info Ver información sobre el anime - + Middle click: Clic central: - + Play next episode Ver el próximo episodio - + + Appearance Apariencia - + Title language preference: Preferencia lingüística del título - + Romaji Romaji - + Native Nativo - + English Inglés - + + Rating system: + + + + Application theme: Tema de aplicación: - + Default Predeterminado - + Light Luminoso - + Dark Oscuro - Set application locale: - Establecer la configuración regional de la aplicación: + Establecer la configuración regional de la aplicación: - + Display highlighted anime above others Mostrar el anime destacado por encima de los demás - + Highlight anime if next episode is available in library folders Resaltar el anime si el siguiente episodio está disponible en las directorios de la biblioteca - + Progress Progreso - + Display aired episodes (estimated) Mostrar episodios emitidos (estimación) - + Display available episodes in library folders Mostrar los episodios disponibles en las directorios de la biblioteca - + + Application locale: + + + + Application Aplicación - + + General + General + + + Anime list Lista de anime + SettingsPageRecognition + + + Enable media player detection + + + + + Allowed media players: + + + + + Recognition + + + + + Media players + + + + SettingsPageServices @@ -838,8 +911,12 @@ + Torrents + + + Application - Aplicación + Aplicación @@ -850,12 +927,12 @@ StatisticsPage - + Anime list Lista de anime - + Anime count: Episode count: Time spent watching: @@ -870,17 +947,17 @@ Desviación de la puntuación: - + Score distribution Distribución de la puntuación - + Minori Minori - + Uptime: Requests made: Tiempo de actividad: @@ -890,22 +967,22 @@ TorrentsPage - + &Check new torrents &Comprueba nuevos torrentes - + Download &marked torrents Descargar torrents &marcados - + &Discard all &Descartar todo - + &Settings Configuración (&S) @@ -913,57 +990,57 @@ TorrentsPageListModel - + Anime title Título del anime - + Episode Episodio - + Group Grupo - + Size Tamaño del archivo - + Resolution Resolución - + Seeding Siembra - + Leeching Sanguijuela - + Downloading Descargando - + Description Descripción - + Filename Nombre del archivo - + Release date Fecha de lanzamiento diff -r 8548dc425697 -r 975a3f0965e2 src/core/anime.cc --- a/src/core/anime.cc Thu Dec 07 03:17:05 2023 -0500 +++ b/src/core/anime.cc Thu Dec 07 11:14:01 2023 -0500 @@ -181,18 +181,19 @@ std::vector Anime::GetTitleSynonyms() const { std::vector result; -#define IN_VECTOR(v, k) (std::count(v.begin(), v.end(), k)) -#define ADD_TO_SYNONYMS(v, k) \ - if (!k.empty() && !IN_VECTOR(v, k) && k != GetUserPreferredTitle()) \ - v.push_back(k) - ADD_TO_SYNONYMS(result, info_.title.english); - ADD_TO_SYNONYMS(result, info_.title.romaji); - ADD_TO_SYNONYMS(result, info_.title.native); - for (auto& synonym : info_.synonyms) { - ADD_TO_SYNONYMS(result, synonym); - } -#undef ADD_TO_SYNONYMS -#undef IN_VECTOR + + auto add_to_synonyms = [this](std::vector& vec, std::string key) { + if (!key.empty() && !std::count(vec.begin(), vec.end(), key) && key != GetUserPreferredTitle()) + vec.push_back(key); + }; + + add_to_synonyms(result, info_.title.english); + add_to_synonyms(result, info_.title.romaji); + add_to_synonyms(result, info_.title.native); + + for (auto& synonym : info_.synonyms) + add_to_synonyms(result, synonym); + return result; } diff -r 8548dc425697 -r 975a3f0965e2 src/gui/dialog/settings/application.cc --- a/src/gui/dialog/settings/application.cc Thu Dec 07 03:17:05 2023 -0500 +++ b/src/gui/dialog/settings/application.cc Thu Dec 07 11:14:01 2023 -0500 @@ -91,49 +91,6 @@ { /* Application theme */ { - QLabel* theme_combo_box_label = new QLabel(tr("Application theme:"), appearance_group_box); - appearance_layout->addWidget(theme_combo_box_label); - } - - { - QComboBox* theme_combo_box = new QComboBox(appearance_group_box); - theme_combo_box->addItem(tr("Default")); - theme_combo_box->addItem(tr("Light")); - theme_combo_box->addItem(tr("Dark")); - connect(theme_combo_box, QOverload::of(&QComboBox::currentIndexChanged), this, - [this](int index) { theme = static_cast(index); }); - theme_combo_box->setCurrentIndex(static_cast(theme)); - appearance_layout->addWidget(theme_combo_box); - } - } - - { - /* Application locale */ - { - QLabel* locale_combo_box_label = new QLabel(tr("Application locale:"), appearance_group_box); - appearance_layout->addWidget(locale_combo_box_label); - } - - { - QComboBox* locale_combo_box = new QComboBox(appearance_group_box); - const auto& available_locales = session.config.locale.GetAvailableLocales(); - for (const auto& l : available_locales) - locale_combo_box->addItem(Strings::ToQString(Locale::GetLocaleFullName(l)), l); - - connect(locale_combo_box, QOverload::of(&QComboBox::currentIndexChanged), this, - [this, locale_combo_box](int) { locale = locale_combo_box->currentData().toLocale(); }); - - for (size_t i = 0; i < available_locales.size(); i++) - if (available_locales[i] == locale) - locale_combo_box->setCurrentIndex(i); - - appearance_layout->addWidget(locale_combo_box); - } - } - - { - /* Application theme */ - { QLabel* rating_combo_box_label = new QLabel(tr("Rating system:"), appearance_group_box); appearance_layout->addWidget(rating_combo_box_label); } @@ -214,6 +171,73 @@ return result; } +QWidget* SettingsPageApplication::CreateGeneralWidget() { + QWidget* result = new QWidget(this); + result->setAutoFillBackground(true); + result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); + + QVBoxLayout* full_layout = new QVBoxLayout(result); + + { + /* Appearance */ + QGroupBox* appearance_group_box = new QGroupBox(tr("Appearance"), result); + appearance_group_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); + + QVBoxLayout* appearance_layout = new QVBoxLayout(appearance_group_box); + + { + /* Application theme */ + { + QLabel* theme_combo_box_label = new QLabel(tr("Application theme:"), appearance_group_box); + appearance_layout->addWidget(theme_combo_box_label); + } + + { + QComboBox* theme_combo_box = new QComboBox(appearance_group_box); + theme_combo_box->addItem(tr("Default")); + theme_combo_box->addItem(tr("Light")); + theme_combo_box->addItem(tr("Dark")); + connect(theme_combo_box, QOverload::of(&QComboBox::currentIndexChanged), this, + [this](int index) { theme = static_cast(index); }); + theme_combo_box->setCurrentIndex(static_cast(theme)); + appearance_layout->addWidget(theme_combo_box); + } + } + + { + /* Application locale */ + { + QLabel* locale_combo_box_label = new QLabel(tr("Application locale:"), appearance_group_box); + appearance_layout->addWidget(locale_combo_box_label); + } + + { + QComboBox* locale_combo_box = new QComboBox(appearance_group_box); + const auto& available_locales = session.config.locale.GetAvailableLocales(); + for (const auto& l : available_locales) + locale_combo_box->addItem(Strings::ToQString(Locale::GetLocaleFullName(l)), l); + + connect(locale_combo_box, QOverload::of(&QComboBox::currentIndexChanged), this, + [this, locale_combo_box](int) { locale = locale_combo_box->currentData().toLocale(); }); + + for (size_t i = 0; i < available_locales.size(); i++) + if (available_locales[i] == locale) + locale_combo_box->setCurrentIndex(i); + + appearance_layout->addWidget(locale_combo_box); + } + } + + full_layout->addWidget(appearance_group_box); + } + + full_layout->setSpacing(10); + full_layout->addStretch(); + + return result; +} + + void SettingsPageApplication::SaveInfo() { session.config.anime_list.language = language; session.config.anime_list.highlighted_anime_above_others = highlighted_anime_above_others; @@ -233,5 +257,6 @@ highlight_anime_if_available = session.config.anime_list.highlight_anime_if_available; display_aired_episodes = session.config.anime_list.display_aired_episodes; display_available_episodes = session.config.anime_list.display_available_episodes; + AddTab(CreateGeneralWidget(), tr("General")); AddTab(CreateAnimeListWidget(), tr("Anime list")); } diff -r 8548dc425697 -r 975a3f0965e2 src/gui/locale.cc --- a/src/gui/locale.cc Thu Dec 07 03:17:05 2023 -0500 +++ b/src/gui/locale.cc Thu Dec 07 11:14:01 2023 -0500 @@ -1,10 +1,14 @@ #include "gui/locale.h" #include "core/strings.h" + #include #include #include #include #include + +#include + #include namespace Locale { @@ -18,12 +22,7 @@ Locale::Locale() { RefreshAvailableLocales(); - - /* default to en_US */ - if (!IsLocaleAvailable(QLocale())) - SetActiveLocale(QLocale("en_US")); - else /* TODO: is this needed? */ - SetActiveLocale(QLocale()); + SetActiveLocale(QLocale("en_US")); } Locale::Locale(const std::string& name) { @@ -52,9 +51,8 @@ QStringList translations = dir.entryList({"*.qm"}, QDir::Files); _available_translations.reserve(translations.size()); - for (const QString& str : translations) { + for (const QString& str : translations) _available_translations.push_back(QLocale(str.mid(0, str.lastIndexOf(".")))); - } } bool Locale::IsLocaleAvailable(const QLocale& locale) const { @@ -65,8 +63,9 @@ } bool Locale::SetActiveLocale(const QLocale& locale) { - if (!IsLocaleAvailable(locale)) + if (!IsLocaleAvailable(locale) || !qApp) return false; + if (_locale == locale) return true; /* we're... already on this locale :) */ diff -r 8548dc425697 -r 975a3f0965e2 src/gui/window.cc --- a/src/gui/window.cc Thu Dec 07 03:17:05 2023 -0500 +++ b/src/gui/window.cc Thu Dec 07 11:14:01 2023 -0500 @@ -78,6 +78,10 @@ qRegisterMetaType>(); + /* This thread will be destroyed on + * close of the program OR on the destruction + * of MainWindow + */ thread.reset(new PlayingThread(this)); QTimer* timer = new QTimer(this); diff -r 8548dc425697 -r 975a3f0965e2 src/main.cc --- a/src/main.cc Thu Dec 07 03:17:05 2023 -0500 +++ b/src/main.cc Thu Dec 07 11:14:01 2023 -0500 @@ -12,6 +12,7 @@ QApplication app(argc, argv); session.config.Load(); + session.config.locale.RefreshAvailableLocales(); Anime::db.LoadDatabaseFromDisk(); MainWindow window; diff -r 8548dc425697 -r 975a3f0965e2 src/sys/osx/dark_theme.cc --- a/src/sys/osx/dark_theme.cc Thu Dec 07 03:17:05 2023 -0500 +++ b/src/sys/osx/dark_theme.cc Thu Dec 07 11:14:01 2023 -0500 @@ -4,7 +4,6 @@ #include #include -#include #include @@ -19,10 +18,10 @@ static CFStringRef NSAppearanceNameAqua = nullptr; static CFStringRef NSAppearanceNameDarkAqua = nullptr; -static const CFStringRef kLaunchServicesBundleID = CFSTR("com.apple.AppKit"); +static const CFStringRef kAppKitBundleID = CFSTR("com.apple.AppKit"); bool RetrieveAppearanceNames() { - CFBundleRef appkit_bundle = CFBundleGetBundleWithIdentifier(kLaunchServicesBundleID); + CFBundleRef appkit_bundle = CFBundleGetBundleWithIdentifier(kAppKitBundleID); if (!appkit_bundle) return false; diff -r 8548dc425697 -r 975a3f0965e2 src/sys/osx/filesystem.cc --- a/src/sys/osx/filesystem.cc Thu Dec 07 03:17:05 2023 -0500 +++ b/src/sys/osx/filesystem.cc Thu Dec 07 11:14:01 2023 -0500 @@ -1,14 +1,18 @@ #include "sys/osx/filesystem.h" #include +#include #include +/* These constants are defined in Foundation but not + * exposed to CoreFoundation users. +*/ static constexpr unsigned long NSApplicationSupportDirectory = 14; static constexpr unsigned long NSUserDomainMask = 1; extern "C" { - CFArrayRef NSSearchPathForDirectoriesInDomains(unsigned long directory, unsigned long domainMask, int expandTilde); + CFArrayRef NSSearchPathForDirectoriesInDomains(unsigned long directory, unsigned long domainMask, BOOL expandTilde); } namespace osx { @@ -35,7 +39,7 @@ CFRelease(strings); return false; } - result.resize(result.find('\0')); + result.resize(result.find_first_of('\0')); return true; }