commit
f55161c06a
@ -35,7 +35,7 @@ if(BUILD_APPSTREAM)
|
||||
TYPE OPTIONAL
|
||||
)
|
||||
if(AppStreamQt_FOUND)
|
||||
add_definitions(-DHAVE_APPSTREAM)
|
||||
add_definitions(-DHAVE_APPSTREAM_VERSION=${AppStreamQt_VERSION_MAJOR})
|
||||
list(APPEND _extra_libraries AppStreamQt)
|
||||
list(APPEND _extra_src ItemAppStream.cpp)
|
||||
endif()
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "ItemAppData.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_APPSTREAM
|
||||
#ifdef HAVE_APPSTREAM_VERSION
|
||||
#include "ItemAppStream.h"
|
||||
#include <AppStreamQt/pool.h>
|
||||
#include <memory>
|
||||
@ -257,7 +257,7 @@ fillModel( PackageListModel* model, const QVariantList& items )
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef HAVE_APPSTREAM
|
||||
#ifdef HAVE_APPSTREAM_VERSION
|
||||
std::unique_ptr< AppStream::Pool > pool;
|
||||
bool poolOk = false;
|
||||
#endif
|
||||
@ -284,7 +284,7 @@ fillModel( PackageListModel* model, const QVariantList& items )
|
||||
}
|
||||
else if ( item_map.contains( "appstream" ) )
|
||||
{
|
||||
#ifdef HAVE_APPSTREAM
|
||||
#ifdef HAVE_APPSTREAM_VERSION
|
||||
if ( !pool )
|
||||
{
|
||||
pool = std::make_unique< AppStream::Pool >();
|
||||
|
@ -56,8 +56,20 @@ setScreenshot( QVariantMap& map, const AppStream::Screenshot& screenshot )
|
||||
|
||||
/// @brief Interpret an AppStream Component
|
||||
static PackageItem
|
||||
fromComponent( AppStream::Component& component )
|
||||
fromComponent( AppStream::Pool& pool, AppStream::Component& component )
|
||||
{
|
||||
#if HAVE_APPSTREAM_VERSION == 0
|
||||
auto setActiveLocale = [&component](const QString & locale)
|
||||
{
|
||||
component.setActiveLocale( locale );
|
||||
};
|
||||
#else
|
||||
auto setActiveLocale = [&pool](const QString & locale)
|
||||
{
|
||||
pool.setLocale( locale );
|
||||
};
|
||||
#endif
|
||||
|
||||
QVariantMap map;
|
||||
map.insert( "id", component.id() );
|
||||
map.insert( "package", component.packageNames().join( "," ) );
|
||||
@ -66,7 +78,7 @@ fromComponent( AppStream::Component& component )
|
||||
// to any of them; get the en_US locale as "untranslated" and then
|
||||
// loop over Calamares locales (since there is no way to query for
|
||||
// available locales in the Component) to see if there's anything else.
|
||||
component.setActiveLocale( QStringLiteral( "en_US" ) );
|
||||
setActiveLocale( QStringLiteral( "en_US" ) );
|
||||
QString en_name = component.name();
|
||||
QString en_description = component.description();
|
||||
map.insert( "name", en_name );
|
||||
@ -74,7 +86,7 @@ fromComponent( AppStream::Component& component )
|
||||
|
||||
for ( const QString& locale : Calamares::Locale::availableTranslations()->localeIds() )
|
||||
{
|
||||
component.setActiveLocale( locale );
|
||||
setActiveLocale( locale );
|
||||
QString name = component.name();
|
||||
if ( name != en_name )
|
||||
{
|
||||
@ -87,7 +99,11 @@ fromComponent( AppStream::Component& component )
|
||||
}
|
||||
}
|
||||
|
||||
#if HAVE_APPSTREAM_VERSION == 0
|
||||
auto screenshots = component.screenshots();
|
||||
#else
|
||||
auto screenshots = component.screenshotsAll();
|
||||
#endif
|
||||
if ( screenshots.count() > 0 )
|
||||
{
|
||||
bool done = false;
|
||||
@ -120,7 +136,11 @@ fromAppStream( AppStream::Pool& pool, const QVariantMap& item_map )
|
||||
}
|
||||
cDebug() << "Loading AppStream data for" << appstreamId;
|
||||
|
||||
#if HAVE_APPSTREAM_VERSION == 0
|
||||
auto itemList = pool.componentsById( appstreamId );
|
||||
#else
|
||||
auto itemList = pool.componentsById( appstreamId ).toList();
|
||||
#endif
|
||||
if ( itemList.count() < 1 )
|
||||
{
|
||||
cWarning() << "No AppStream data for" << appstreamId;
|
||||
@ -131,7 +151,7 @@ fromAppStream( AppStream::Pool& pool, const QVariantMap& item_map )
|
||||
cDebug() << "Multiple AppStream data for" << appstreamId << "using first.";
|
||||
}
|
||||
|
||||
auto r = fromComponent( itemList.first() );
|
||||
auto r = fromComponent( pool, itemList.first() );
|
||||
if ( r.isValid() )
|
||||
{
|
||||
QString id = Calamares::getString( item_map, "id" );
|
||||
|
@ -12,7 +12,7 @@
|
||||
#ifdef HAVE_APPDATA
|
||||
#include "ItemAppData.h"
|
||||
#endif
|
||||
#ifdef HAVE_APPSTREAM
|
||||
#ifdef HAVE_APPSTREAM_VERSION
|
||||
#include "ItemAppStream.h"
|
||||
#endif
|
||||
#include "PackageModel.h"
|
||||
|
@ -46,7 +46,7 @@ if(BUILD_APPSTREAM)
|
||||
TYPE OPTIONAL
|
||||
)
|
||||
if(AppStreamQt_FOUND)
|
||||
add_definitions(-DHAVE_APPSTREAM)
|
||||
add_definitions(-DHAVE_APPSTREAM_VERSION=${AppStreamQt_VERSION_MAJOR})
|
||||
list(APPEND _extra_libraries AppStreamQt)
|
||||
list(APPEND _extra_src ${_packagechooser}/ItemAppStream.cpp)
|
||||
endif()
|
||||
|
Loading…
Reference in New Issue
Block a user