Extract 7z loading to it's own function

This will unify 7z loading in all scenarios and it also fixes the search path in Linux, now the apps will always try to load 7z.so from LIBDIR/yacreader/7z.so, if it fails they'll try 7zip/7z.so
This commit is contained in:
Luis Ángel San Martín
2024-09-15 15:50:09 +02:00
parent bb36368ad2
commit 63fcde8035
5 changed files with 26 additions and 24 deletions

View File

@ -1,6 +1,8 @@
#include "yacreader_global.h"
#include <QModelIndex>
#include <QLibrary>
#include <QCoreApplication>
using namespace YACReader;
@ -119,3 +121,17 @@ void YACReader::iterate(const QModelIndex &index,
for (int i = 0; i < rows; ++i)
iterate(model->index(i, 0, index), model, iteration);
}
QLibrary *YACReader::load7zLibrary()
{
#if defined Q_OS_UNIX && !defined Q_OS_MACOS
auto yacreader7zPath = QString(LIBDIR) + "/yacreader/7z.so";
if (QLibrary::isLibrary(yacreader7zPath)) {
return new QLibrary(yacreader7zPath);
} else {
return new QLibrary(QString(LIBDIR) + "/7zip/7z.so");
}
#else
return new QLibrary(QCoreApplication::applicationDirPath() + "/utils/7z");
#endif
}

View File

@ -6,6 +6,8 @@
#include <QMetaType>
#include <QAbstractItemModel>
class QLibrary;
#define VERSION "9.15.0"
// Used to check if the database needs to be updated, the version is stored in the database.
@ -100,6 +102,7 @@ QDataStream &operator>>(QDataStream &stream, OpenComicSource &source);
QString getSettingsPath();
QString colorToName(LabelColors colors);
QString labelColorToRGBString(LabelColors color);
QLibrary *load7zLibrary();
void iterate(const QModelIndex &index,
const QAbstractItemModel *model,