From 25ef804ae71159c900a7372ac39f6adf6e86c4b4 Mon Sep 17 00:00:00 2001 From: lambdcalculus Date: Mon, 24 Jun 2024 16:15:21 -0300 Subject: [PATCH 1/2] remove unnecessary plugin loaders imageformats plugins are loaded automatically, we just need to check if they were actually loaded --- src/main.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 955b1ff..bad49ad 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,8 +8,8 @@ #include #include +#include #include -#include #include #include @@ -28,7 +28,6 @@ int main(int argc, char *argv[]) } #endif - AOApplication::addLibraryPath(AOApplication::applicationDirPath() + "/lib"); QResource::registerResource(main_app.get_asset("themes/" + Options::getInstance().theme() + ".rcc")); QFont main_font = main_app.font(); @@ -46,16 +45,14 @@ int main(int argc, char *argv[]) fontDatabase.addApplicationFont(it.next()); } - QPluginLoader apngPlugin("qapng"); - if (!apngPlugin.load()) + if (!QImageReader::supportedImageFormats().contains("apng")) { - qCritical() << "QApng plugin could not be loaded"; + qCritical() << "QApng plugin could not be loaded. Errors may occur when loading .apng files."; } - QPluginLoader webpPlugin("qwebp"); - if (!webpPlugin.load()) + if (!QImageReader::supportedImageFormats().contains("webp")) { - qCritical() << "QWebp plugin could not be loaded"; + qCritical() << "QWebP plugin could not be loaded. Errors may occur when loading .webp files."; } QString p_language = Options::getInstance().language(); From 061b7a796a20c3f92c720d9e0b30c5ff1edcf744 Mon Sep 17 00:00:00 2001 From: lambdcalculus Date: Mon, 24 Jun 2024 20:18:56 -0300 Subject: [PATCH 2/2] improve image formats check iterate over important formats, and add a message box --- src/main.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index bad49ad..65e5849 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -45,14 +45,19 @@ int main(int argc, char *argv[]) fontDatabase.addApplicationFont(it.next()); } - if (!QImageReader::supportedImageFormats().contains("apng")) + QStringList missing_formats{"webp", "apng", "gif"}; + for (const QByteArray &i_format : QImageReader::supportedImageFormats()) { - qCritical() << "QApng plugin could not be loaded. Errors may occur when loading .apng files."; + missing_formats.removeAll(i_format.toLower()); } - if (!QImageReader::supportedImageFormats().contains("webp")) + if (!missing_formats.empty()) { - qCritical() << "QWebP plugin could not be loaded. Errors may occur when loading .webp files."; + call_error(QString("Missing the following image formats: %1." + "
Please make sure the client is installed correctly." + "
If you are on Linux, you may need to install your distribution's image formats package, " + "as detailed in the project's README.") + .arg(missing_formats.join(", "))); } QString p_language = Options::getInstance().language();