[packagechooser] Initial support for appstream items
- Use *appstream* as key in one of the items for the package- chooser to load data from the AppStream cache in the system. - Usable for some applications; for DE-selection not so much. - Currently unimplemented.
This commit is contained in:
parent
2f20ad30bf
commit
eaa0c02f8d
@ -23,6 +23,7 @@ set_package_properties(
|
||||
if ( AppStreamQt_FOUND )
|
||||
add_definitions( -DHAVE_APPSTREAM )
|
||||
list( APPEND _extra_libraries AppStreamQt )
|
||||
list( APPEND _extra_src ItemAppStream.cpp )
|
||||
endif()
|
||||
|
||||
calamares_add_plugin( packagechooser
|
||||
|
33
src/modules/packagechooser/ItemAppStream.cpp
Normal file
33
src/modules/packagechooser/ItemAppStream.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2019, Adriaan de Groot <groot@kde.org>
|
||||
*
|
||||
* Calamares is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Calamares is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @brief Loading items from AppData XML files.
|
||||
*
|
||||
* Only used if QtXML is found, implements PackageItem::fromAppData().
|
||||
*/
|
||||
#include "PackageModel.h"
|
||||
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Variant.h"
|
||||
|
||||
PackageItem
|
||||
PackageItem::fromAppStream( const QVariantMap& map )
|
||||
{
|
||||
cWarning() << "AppStream loading not implemented.";
|
||||
return PackageItem();
|
||||
}
|
@ -219,6 +219,10 @@ PackageChooserViewStep::fillModel( const QVariantList& items )
|
||||
{
|
||||
m_model->addPackage( PackageItem::fromAppData( item_map ) );
|
||||
}
|
||||
else if ( item_map.contains( "appstream" ) )
|
||||
{
|
||||
m_model->addPackage( PackageItem::fromAppStream( item_map ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_model->addPackage( PackageItem( item_map ) );
|
||||
|
@ -98,6 +98,15 @@ PackageItem::fromAppData( const QVariantMap& item_map )
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_APPSTREAM
|
||||
PackageItem
|
||||
PackageItem::fromAppStream( const QVariantMap& item_map )
|
||||
{
|
||||
cWarning() << "Loading AppStream data is not supported.";
|
||||
return PackageItem();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
PackageListModel::PackageListModel( QObject* parent )
|
||||
: QAbstractListModel( parent )
|
||||
|
@ -93,6 +93,20 @@ struct PackageItem
|
||||
* return invalid PackageItems.
|
||||
*/
|
||||
static PackageItem fromAppData( const QVariantMap& map );
|
||||
|
||||
/** @brief Loads an item from AppStream data.
|
||||
*
|
||||
* The @p map must have a key *appstream*. That is used as the
|
||||
* primary source of information from the AppStream cache, but
|
||||
* keys *id* and *screenshotPath* may be used to override parts
|
||||
* of the AppStream data -- so that the ID is under the control
|
||||
* of Calamares, and the screenshot can be forced to a local path
|
||||
* available on the installation medium.
|
||||
*
|
||||
* Requires AppStreamQt, if not present will return invalid
|
||||
* PackageItems.
|
||||
*/
|
||||
static PackageItem fromAppStream( const QVariantMap& map );
|
||||
};
|
||||
|
||||
using PackageList = QVector< PackageItem >;
|
||||
|
@ -20,14 +20,15 @@
|
||||
# or one-or-more).
|
||||
mode: required
|
||||
|
||||
# Items to display in the chooser. In general, this should be a
|
||||
# Items to display in the chooser. In general, this should be a
|
||||
# pretty short list to avoid overwhelming the UI. This is a list
|
||||
# of objects, and the items are displayed in list order.
|
||||
#
|
||||
# Either provide the data for an item in the list (using the keys
|
||||
# below), or use existing AppData XML files as a source for the data.
|
||||
# below), or use existing AppData XML files, or use AppStream cache
|
||||
# as a source for the data.
|
||||
#
|
||||
# For data provided by the list: the item has an id, which is used in
|
||||
# For data provided by the list: the item has an id, which is used in
|
||||
# setting the value of *packagechooser_<module-id>*). The following fields
|
||||
# are mandatory:
|
||||
#
|
||||
@ -60,6 +61,14 @@ mode: required
|
||||
# be loaded and the screenshot will be missing. An item with *appdata*
|
||||
# **may** specify an ID or screenshot path, as above. This will override
|
||||
# the settings from AppData.
|
||||
#
|
||||
# For data provided by AppStream cache: the item has an *appstream*
|
||||
# key which matches the AppStream identifier in the cache (e.g.
|
||||
# *org.kde.kwrite.desktop*). Data is retrieved from the AppStream
|
||||
# cache for that ID. The package name is set from the AppStream data.
|
||||
#
|
||||
# An item for AppStream may also contain an *id* and a *screenshot*
|
||||
# key which will override the data from AppStream.
|
||||
items:
|
||||
- id: ""
|
||||
package: ""
|
||||
@ -81,4 +90,5 @@ items:
|
||||
- id: calamares
|
||||
appdata: ../io.calamares.calamares.appdata.xml
|
||||
screenshot: ":/images/calamares.png"
|
||||
|
||||
- id: kate
|
||||
appstream: org.kde.kwrite.desktop
|
||||
|
Loading…
Reference in New Issue
Block a user