Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bc77da0749 | |||
| 1286782422 | |||
| 91712d4f3b | |||
| a163c7d62d | |||
| 3db91dec6a | |||
| 62d997063b | |||
| c7e1783e30 | |||
| bb1212c974 | |||
| 983b9cb68a | |||
| d24d23902c | |||
| efe4b4da71 | |||
| 010ac14221 | |||
|
fcdcc25738
|
|||
|
367995710b
|
@@ -162,7 +162,6 @@ set(LIST_SKIPPED_MODULES "")
|
||||
calamares_add_module_subdirectory( modules/basestrap LIST_SKIPPED_MODULES )
|
||||
calamares_add_module_subdirectory( modules/services-artix LIST_SKIPPED_MODULES )
|
||||
calamares_add_module_subdirectory( modules/postcfg LIST_SKIPPED_MODULES )
|
||||
calamares_add_module_subdirectory( modules/packagechooser LIST_SKIPPED_MODULES )
|
||||
|
||||
message(STATUS "Calamares extensions ${CALAMARES_EXTENSIONS_VERSION} for Calamares version ${Calamares_VERSION}")
|
||||
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
# === This file is part of Calamares - <https://calamares.io> ===
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
#
|
||||
find_package(${qtname} COMPONENTS Core Gui Widgets REQUIRED)
|
||||
set(_extra_libraries "")
|
||||
set(_extra_src "")
|
||||
|
||||
### OPTIONAL AppData XML support in PackageModel
|
||||
#
|
||||
#
|
||||
option(BUILD_APPDATA "Support appdata: items in PackageChooser (requires QtXml)" OFF)
|
||||
if(BUILD_APPDATA)
|
||||
find_package(${qtname} REQUIRED COMPONENTS Xml)
|
||||
if(TARGET ${qtname}::Xml)
|
||||
add_definitions(-DHAVE_APPDATA)
|
||||
list(APPEND _extra_libraries ${qtname}::Xml)
|
||||
list(APPEND _extra_src ItemAppData.cpp)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
### OPTIONAL AppStream support in PackageModel
|
||||
#
|
||||
#
|
||||
include(AppStreamHelper)
|
||||
|
||||
calamares_add_plugin(packagechooser
|
||||
TYPE viewmodule
|
||||
EXPORT_MACRO PLUGINDLLEXPORT_PRO
|
||||
SOURCES
|
||||
Config.cpp
|
||||
PackageChooserPage.cpp
|
||||
PackageChooserViewStep.cpp
|
||||
PackageModel.cpp
|
||||
${_extra_src}
|
||||
RESOURCES
|
||||
packagechooser.qrc
|
||||
UI
|
||||
page_package.ui
|
||||
LINK_PRIVATE_LIBRARIES
|
||||
${_extra_libraries}
|
||||
SHARED_LIB
|
||||
)
|
||||
|
||||
if(AppStreamQt_FOUND)
|
||||
target_link_libraries(calamares_viewmodule_packagechooser PRIVATE calamares::appstreamqt)
|
||||
target_sources(calamares_viewmodule_packagechooser PRIVATE ItemAppStream.cpp)
|
||||
endif()
|
||||
|
||||
# calamares_add_test(
|
||||
# packagechoosertest
|
||||
# GUI
|
||||
# SOURCES Tests.cpp
|
||||
# LIBRARIES calamares_viewmodule_packagechooser ${_extra_libraries}
|
||||
# )
|
||||
@@ -1,360 +0,0 @@
|
||||
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2021 Adriaan de Groot <groot@kde.org>
|
||||
* SPDX-FileCopyrightText: 2021 Anke Boersma <demm@kaosx.us>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#ifdef HAVE_APPDATA
|
||||
#include "ItemAppData.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_APPSTREAM_VERSION
|
||||
#include "ItemAppStream.h"
|
||||
#include <memory>
|
||||
#endif
|
||||
|
||||
#include "GlobalStorage.h"
|
||||
#include "JobQueue.h"
|
||||
#include "compat/Variant.h"
|
||||
#include "packages/Globals.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Variant.h"
|
||||
|
||||
/** @brief This removes any values from @p groups that match @p source
|
||||
*
|
||||
* This is used to remove duplicates from the netinstallAdd structure
|
||||
* It iterates over @p groups and for each map in the list, if the
|
||||
* "source" element matches @p source, it is removed from the returned
|
||||
* list.
|
||||
*/
|
||||
static QVariantList
|
||||
pruneNetinstallAdd( const QString& source, const QVariant& groups )
|
||||
{
|
||||
QVariantList newGroupList;
|
||||
const QVariantList groupList = groups.toList();
|
||||
for ( const QVariant& group : groupList )
|
||||
{
|
||||
QVariantMap groupMap = group.toMap();
|
||||
if ( groupMap.value( "source", "" ).toString() != source )
|
||||
{
|
||||
newGroupList.append( groupMap );
|
||||
}
|
||||
}
|
||||
return newGroupList;
|
||||
}
|
||||
|
||||
const NamedEnumTable< PackageChooserMode >&
|
||||
packageChooserModeNames()
|
||||
{
|
||||
static const NamedEnumTable< PackageChooserMode > names {
|
||||
{ "optional", PackageChooserMode::Optional },
|
||||
{ "required", PackageChooserMode::Required },
|
||||
{ "optionalmultiple", PackageChooserMode::OptionalMultiple },
|
||||
{ "requiredmultiple", PackageChooserMode::RequiredMultiple },
|
||||
// and a bunch of aliases
|
||||
{ "zero-or-one", PackageChooserMode::Optional },
|
||||
{ "radio", PackageChooserMode::Required },
|
||||
{ "one", PackageChooserMode::Required },
|
||||
{ "set", PackageChooserMode::OptionalMultiple },
|
||||
{ "zero-or-more", PackageChooserMode::OptionalMultiple },
|
||||
{ "multiple", PackageChooserMode::RequiredMultiple },
|
||||
{ "one-or-more", PackageChooserMode::RequiredMultiple }
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
const NamedEnumTable< PackageChooserMethod >&
|
||||
PackageChooserMethodNames()
|
||||
{
|
||||
static const NamedEnumTable< PackageChooserMethod > names {
|
||||
{ "legacy", PackageChooserMethod::Legacy },
|
||||
{ "custom", PackageChooserMethod::Legacy },
|
||||
{ "contextualprocess", PackageChooserMethod::Legacy },
|
||||
{ "packages", PackageChooserMethod::Packages },
|
||||
{ "netinstall-add", PackageChooserMethod::NetAdd },
|
||||
{ "netinstall-select", PackageChooserMethod::NetSelect },
|
||||
};
|
||||
return names;
|
||||
}
|
||||
|
||||
Config::Config( QObject* parent )
|
||||
: Calamares::ModuleSystem::Config( parent )
|
||||
, m_model( new PackageListModel( this ) )
|
||||
, m_mode( PackageChooserMode::Required )
|
||||
{
|
||||
}
|
||||
|
||||
Config::~Config() {}
|
||||
|
||||
const PackageItem&
|
||||
Config::introductionPackage() const
|
||||
{
|
||||
for ( int i = 0; i < m_model->packageCount(); ++i )
|
||||
{
|
||||
const auto& package = m_model->packageData( i );
|
||||
if ( package.isNonePackage() )
|
||||
{
|
||||
return package;
|
||||
}
|
||||
}
|
||||
|
||||
static PackageItem* defaultIntroduction = nullptr;
|
||||
if ( !defaultIntroduction )
|
||||
{
|
||||
const auto name = QT_TR_NOOP( "Package Selection" );
|
||||
const auto description
|
||||
= QT_TR_NOOP( "Please pick a product from the list. The selected product will be installed." );
|
||||
defaultIntroduction = new PackageItem( QString(), name, description );
|
||||
defaultIntroduction->screenshot = QPixmap( QStringLiteral( ":/images/no-selection.png" ) );
|
||||
defaultIntroduction->name = Calamares::Locale::TranslatedString( name, metaObject()->className() );
|
||||
defaultIntroduction->description
|
||||
= Calamares::Locale::TranslatedString( description, metaObject()->className() );
|
||||
}
|
||||
return *defaultIntroduction;
|
||||
}
|
||||
|
||||
static inline QString
|
||||
make_gs_key( const Calamares::ModuleSystem::InstanceKey& key )
|
||||
{
|
||||
return QStringLiteral( "packagechooser_" ) + key.id();
|
||||
}
|
||||
|
||||
void
|
||||
Config::updateGlobalStorage( const QStringList& selected ) const
|
||||
{
|
||||
if ( m_packageChoice.has_value() )
|
||||
{
|
||||
cWarning() << "Inconsistent package choices -- both model and single-selection QML";
|
||||
}
|
||||
if ( m_method == PackageChooserMethod::Legacy )
|
||||
{
|
||||
QString value = selected.join( ',' );
|
||||
Calamares::JobQueue::instance()->globalStorage()->insert( make_gs_key( m_defaultId ), value );
|
||||
cDebug() << m_defaultId << "selected" << value;
|
||||
}
|
||||
else if ( m_method == PackageChooserMethod::Packages )
|
||||
{
|
||||
QStringList packageNames = m_model->getInstallPackagesForNames( selected );
|
||||
cDebug() << m_defaultId << "packages to install" << packageNames;
|
||||
Calamares::Packages::setGSPackageAdditions(
|
||||
Calamares::JobQueue::instance()->globalStorage(), m_defaultId, packageNames );
|
||||
}
|
||||
else if ( m_method == PackageChooserMethod::NetAdd )
|
||||
{
|
||||
QVariantList netinstallDataList = m_model->getNetinstallDataForNames( selected );
|
||||
if ( netinstallDataList.isEmpty() )
|
||||
{
|
||||
cWarning() << "No netinstall information found for " << selected;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If an earlier packagechooser instance added this data to global storage, combine them
|
||||
auto* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||
if ( gs->contains( "netinstallAdd" ) )
|
||||
{
|
||||
netinstallDataList
|
||||
+= pruneNetinstallAdd( QStringLiteral( "packageChooser" ), gs->value( "netinstallAdd" ) );
|
||||
}
|
||||
gs->insert( "netinstallAdd", netinstallDataList );
|
||||
}
|
||||
}
|
||||
else if ( m_method == PackageChooserMethod::NetSelect )
|
||||
{
|
||||
cDebug() << m_defaultId << "groups to select in netinstall" << selected;
|
||||
QStringList newSelected = selected;
|
||||
auto* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||
|
||||
// If an earlier packagechooser instance added this data to global storage, combine them
|
||||
if ( gs->contains( "netinstallSelect" ) )
|
||||
{
|
||||
auto selectedOrig = gs->value( "netinstallSelect" );
|
||||
if ( selectedOrig.canConvert< QStringList >() )
|
||||
{
|
||||
newSelected += selectedOrig.toStringList();
|
||||
}
|
||||
else
|
||||
{
|
||||
cWarning() << "Invalid NetinstallSelect data in global storage. Earlier selections purged";
|
||||
}
|
||||
gs->remove( "netinstallSelect" );
|
||||
}
|
||||
gs->insert( "netinstallSelect", newSelected );
|
||||
}
|
||||
else
|
||||
{
|
||||
cWarning() << "Unknown packagechooser method" << smash( m_method );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Config::updateGlobalStorage() const
|
||||
{
|
||||
if ( m_model->packageCount() > 0 )
|
||||
{
|
||||
cWarning() << "Inconsistent package choices -- both model and single-selection QML";
|
||||
}
|
||||
if ( m_method == PackageChooserMethod::Legacy )
|
||||
{
|
||||
auto* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||
if ( m_packageChoice.has_value() )
|
||||
{
|
||||
gs->insert( make_gs_key( m_defaultId ), m_packageChoice.value() );
|
||||
}
|
||||
else
|
||||
{
|
||||
gs->remove( make_gs_key( m_defaultId ) );
|
||||
}
|
||||
}
|
||||
else if ( m_method == PackageChooserMethod::Packages )
|
||||
{
|
||||
cWarning() << "Unsupported single-selection packagechooser method 'Packages'";
|
||||
}
|
||||
else
|
||||
{
|
||||
cWarning() << "Unknown packagechooser method" << smash( m_method );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Config::setPackageChoice( const QString& packageChoice )
|
||||
{
|
||||
if ( packageChoice.isEmpty() )
|
||||
{
|
||||
m_packageChoice.reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_packageChoice = packageChoice;
|
||||
}
|
||||
emit packageChoiceChanged( m_packageChoice.value_or( QString() ) );
|
||||
}
|
||||
|
||||
QString
|
||||
Config::prettyName() const
|
||||
{
|
||||
return m_stepName ? m_stepName->get() : tr( "Packages" );
|
||||
}
|
||||
|
||||
QString
|
||||
Config::prettyStatus() const
|
||||
{
|
||||
return tr( "Install option: <strong>%1</strong>" ).arg( m_packageChoice.value_or( tr( "None" ) ) );
|
||||
}
|
||||
|
||||
static void
|
||||
fillModel( PackageListModel* model, const QVariantList& items )
|
||||
{
|
||||
if ( items.isEmpty() )
|
||||
{
|
||||
cWarning() << "No *items* for PackageChooser module.";
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef HAVE_APPSTREAM_VERSION
|
||||
std::unique_ptr< AppStream::Pool > pool;
|
||||
bool poolOk = false;
|
||||
#endif
|
||||
|
||||
cDebug() << "Loading PackageChooser model items from config";
|
||||
int item_index = 0;
|
||||
for ( const auto& item_it : items )
|
||||
{
|
||||
++item_index;
|
||||
QVariantMap item_map = item_it.toMap();
|
||||
if ( item_map.isEmpty() )
|
||||
{
|
||||
cWarning() << "PackageChooser entry" << item_index << "is not valid.";
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( item_map.contains( "appdata" ) )
|
||||
{
|
||||
#ifdef HAVE_XML
|
||||
model->addPackage( fromAppData( item_map ) );
|
||||
#else
|
||||
cWarning() << "Loading AppData XML is not supported.";
|
||||
#endif
|
||||
}
|
||||
else if ( item_map.contains( "appstream" ) )
|
||||
{
|
||||
#ifdef HAVE_APPSTREAM_VERSION
|
||||
if ( !pool )
|
||||
{
|
||||
pool = std::make_unique< AppStream::Pool >();
|
||||
pool->setLocale( QStringLiteral( "ALL" ) );
|
||||
poolOk = pool->load();
|
||||
}
|
||||
if ( pool && poolOk )
|
||||
{
|
||||
model->addPackage( fromAppStream( *pool, item_map ) );
|
||||
}
|
||||
#else
|
||||
cWarning() << "Loading AppStream data is not supported.";
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
model->addPackage( PackageItem( item_map ) );
|
||||
}
|
||||
}
|
||||
cDebug() << Logger::SubEntry << "Loaded PackageChooser with" << model->packageCount() << "entries.";
|
||||
}
|
||||
|
||||
void
|
||||
Config::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
{
|
||||
m_mode = packageChooserModeNames().find( Calamares::getString( configurationMap, "mode" ),
|
||||
PackageChooserMode::Required );
|
||||
m_method = PackageChooserMethodNames().find( Calamares::getString( configurationMap, "method" ),
|
||||
PackageChooserMethod::Legacy );
|
||||
|
||||
if ( m_method == PackageChooserMethod::Legacy )
|
||||
{
|
||||
cDebug() << "Using module ID" << m_defaultId;
|
||||
}
|
||||
|
||||
if ( configurationMap.contains( "items" ) )
|
||||
{
|
||||
fillModel( m_model, configurationMap.value( "items" ).toList() );
|
||||
|
||||
QString default_item_id = Calamares::getString( configurationMap, "default" );
|
||||
if ( !default_item_id.isEmpty() )
|
||||
{
|
||||
for ( int item_n = 0; item_n < m_model->packageCount(); ++item_n )
|
||||
{
|
||||
QModelIndex item_idx = m_model->index( item_n, 0 );
|
||||
QVariant item_id = m_model->data( item_idx, PackageListModel::IdRole );
|
||||
|
||||
if ( item_id.toString() == default_item_id )
|
||||
{
|
||||
m_defaultModelIndex = item_idx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setPackageChoice( Calamares::getString( configurationMap, "packageChoice" ) );
|
||||
if ( m_method != PackageChooserMethod::Legacy )
|
||||
{
|
||||
cWarning() << "Single-selection QML module must use 'Legacy' method.";
|
||||
}
|
||||
}
|
||||
|
||||
bool labels_ok = false;
|
||||
auto labels = Calamares::getSubMap( configurationMap, "labels", labels_ok );
|
||||
if ( labels_ok )
|
||||
{
|
||||
if ( labels.contains( "step" ) )
|
||||
{
|
||||
m_stepName = new Calamares::Locale::TranslatedString( labels, "step" );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2021 Adriaan de Groot <groot@kde.org>
|
||||
* SPDX-FileCopyrightText: 2021 Anke Boersma <demm@kaosx.us>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PACKAGECHOOSER_CONFIG_H
|
||||
#define PACKAGECHOOSER_CONFIG_H
|
||||
|
||||
#include "PackageModel.h"
|
||||
|
||||
#include "modulesystem/Config.h"
|
||||
#include "modulesystem/InstanceKey.h"
|
||||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
enum class PackageChooserMode
|
||||
{
|
||||
Optional, // zero or one
|
||||
Required, // exactly one
|
||||
OptionalMultiple, // zero or more
|
||||
RequiredMultiple // one or more
|
||||
};
|
||||
|
||||
const NamedEnumTable< PackageChooserMode >& packageChooserModeNames();
|
||||
|
||||
enum class PackageChooserMethod
|
||||
{
|
||||
Legacy, // use contextualprocess or other custom
|
||||
Packages, // use the packages module
|
||||
NetAdd, // adds packages to the netinstall module
|
||||
NetSelect, // makes selections in the netinstall module
|
||||
};
|
||||
|
||||
const NamedEnumTable< PackageChooserMethod >& PackageChooserMethodNames();
|
||||
|
||||
class Config : public Calamares::ModuleSystem::Config
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
/** @brief This is the single-select package-choice
|
||||
*
|
||||
* For (QML) modules that support only a single selection and
|
||||
* just want to do things in a straightforward pick-this-one
|
||||
* way, the packageChoice property is a (the) way to go.
|
||||
*
|
||||
* Writing to this property means that any other form of package-
|
||||
* choice or selection is ignored.
|
||||
*/
|
||||
Q_PROPERTY( QString packageChoice READ packageChoice WRITE setPackageChoice NOTIFY packageChoiceChanged )
|
||||
Q_PROPERTY( QString prettyStatus READ prettyStatus NOTIFY prettyStatusChanged FINAL )
|
||||
|
||||
public:
|
||||
Config( QObject* parent = nullptr );
|
||||
~Config() override;
|
||||
|
||||
/** @brief Sets the default Id for this Config
|
||||
*
|
||||
* The default Id is the (owning) module identifier for the config,
|
||||
* and it is used when the Id read from the config file is empty.
|
||||
* The **usual** configuration when using method *packages* is
|
||||
* to rely on the default Id.
|
||||
*/
|
||||
void setDefaultId( const Calamares::ModuleSystem::InstanceKey& defaultId ) { m_defaultId = defaultId; }
|
||||
void setConfigurationMap( const QVariantMap& ) override;
|
||||
|
||||
PackageChooserMode mode() const { return m_mode; }
|
||||
PackageListModel* model() const { return m_model; }
|
||||
QModelIndex defaultSelectionIndex() const { return m_defaultModelIndex; }
|
||||
|
||||
/** @brief Returns an "introductory package" which describes packagechooser
|
||||
*
|
||||
* If the model contains a "none" package, returns that one on
|
||||
* the assumption that it is one to describe the whole; otherwise
|
||||
* returns a totally generic description.
|
||||
*/
|
||||
const PackageItem& introductionPackage() const;
|
||||
|
||||
/** @brief Write selection to global storage
|
||||
*
|
||||
* Updates the GS keys for this packagechooser, marking all
|
||||
* (and only) the packages in @p selected as selected.
|
||||
*/
|
||||
void updateGlobalStorage( const QStringList& selected ) const;
|
||||
/** @brief Write selection to global storage
|
||||
*
|
||||
* Updates the GS keys for this packagechooser, marking **only**
|
||||
* the package choice as selected. This assumes that the single-
|
||||
* selection QML code is in use.
|
||||
*/
|
||||
void updateGlobalStorage() const;
|
||||
|
||||
QString packageChoice() const { return m_packageChoice.value_or( QString() ); }
|
||||
void setPackageChoice( const QString& packageChoice );
|
||||
|
||||
QString prettyName() const;
|
||||
QString prettyStatus() const;
|
||||
|
||||
signals:
|
||||
void packageChoiceChanged( QString packageChoice );
|
||||
void prettyStatusChanged();
|
||||
|
||||
private:
|
||||
PackageListModel* m_model = nullptr;
|
||||
QModelIndex m_defaultModelIndex;
|
||||
|
||||
/// Selection mode for this module
|
||||
PackageChooserMode m_mode = PackageChooserMode::Optional;
|
||||
/// How this module stores to GS
|
||||
PackageChooserMethod m_method = PackageChooserMethod::Legacy;
|
||||
/// Value to use for id if none is set in the config file
|
||||
Calamares::ModuleSystem::InstanceKey m_defaultId;
|
||||
/** @brief QML selection (for single-selection approaches)
|
||||
*
|
||||
* If there is no value, then there has been no selection.
|
||||
* Reading the property will return an empty QString.
|
||||
*/
|
||||
std::optional< QString > m_packageChoice;
|
||||
Calamares::Locale::TranslatedString* m_stepName; // As it appears in the sidebar
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,225 +0,0 @@
|
||||
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @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"
|
||||
|
||||
#include <QDomDocument>
|
||||
#include <QDomNodeList>
|
||||
#include <QFile>
|
||||
|
||||
/** @brief try to load the given @p fileName XML document
|
||||
*
|
||||
* Returns a QDomDocument, which will be valid iff the file can
|
||||
* be read and contains valid XML data.
|
||||
*/
|
||||
static inline QDomDocument
|
||||
loadAppData( const QString& fileName )
|
||||
{
|
||||
QFile file( fileName );
|
||||
if ( !file.open( QIODevice::ReadOnly ) )
|
||||
{
|
||||
return QDomDocument();
|
||||
}
|
||||
QDomDocument doc( "AppData" );
|
||||
if ( !doc.setContent( &file ) )
|
||||
{
|
||||
file.close();
|
||||
return QDomDocument();
|
||||
}
|
||||
file.close();
|
||||
return doc;
|
||||
}
|
||||
|
||||
/** @brief gets the text of child element @p tagName
|
||||
*/
|
||||
static inline QString
|
||||
getChildText( const QDomNode& n, const QString& tagName )
|
||||
{
|
||||
QDomElement e = n.firstChildElement( tagName );
|
||||
return e.isNull() ? QString() : e.text();
|
||||
}
|
||||
|
||||
/** @brief Gets a suitable screenshot path
|
||||
*
|
||||
* The <screenshots> element contains zero or more <screenshot>
|
||||
* elements, which can have a *type* associated with them.
|
||||
* Scan the screenshot elements, return the <image> path
|
||||
* for the one labeled with type=default or, if there is no
|
||||
* default, the first element.
|
||||
*/
|
||||
static inline QString
|
||||
getScreenshotPath( const QDomNode& n )
|
||||
{
|
||||
QDomElement shotsNode = n.firstChildElement( "screenshots" );
|
||||
if ( shotsNode.isNull() )
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
const QDomNodeList shotList = shotsNode.childNodes();
|
||||
int firstScreenshot = -1; // Use which screenshot node?
|
||||
for ( int i = 0; i < shotList.count(); ++i )
|
||||
{
|
||||
if ( !shotList.at( i ).isElement() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
QDomElement e = shotList.at( i ).toElement();
|
||||
if ( e.tagName() != "screenshot" )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// If none has the "type=default" attribute, use the first one
|
||||
if ( firstScreenshot < 0 )
|
||||
{
|
||||
firstScreenshot = i;
|
||||
}
|
||||
// But type=default takes precedence.
|
||||
if ( e.hasAttribute( "type" ) && e.attribute( "type" ) == "default" )
|
||||
{
|
||||
firstScreenshot = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( firstScreenshot >= 0 )
|
||||
{
|
||||
return shotList.at( firstScreenshot ).firstChildElement( "image" ).text();
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
/** @brief Returns language of the given element @p e
|
||||
*
|
||||
* Transforms the attribute value for xml:lang to something
|
||||
* suitable for TranslatedString (e.g. [lang]).
|
||||
*/
|
||||
static inline QString
|
||||
getLanguage( const QDomElement& e )
|
||||
{
|
||||
QString language = e.attribute( "xml:lang" );
|
||||
if ( !language.isEmpty() )
|
||||
{
|
||||
language.replace( '-', '_' );
|
||||
language.prepend( '[' );
|
||||
language.append( ']' );
|
||||
}
|
||||
return language;
|
||||
}
|
||||
|
||||
/** @brief Scan the list of @p children for @p tagname elements and add them to the map
|
||||
*
|
||||
* Uses @p mapname instead of @p tagname for the entries in map @p m
|
||||
* to allow renaming from XML to map keys (in particular for
|
||||
* TranslatedString). Also transforms xml:lang attributes to suitable
|
||||
* key-decorations on @p mapname.
|
||||
*/
|
||||
static inline void
|
||||
fillMap( QVariantMap& m, const QDomNodeList& children, const QString& tagname, const QString& mapname )
|
||||
{
|
||||
for ( int i = 0; i < children.count(); ++i )
|
||||
{
|
||||
if ( !children.at( i ).isElement() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
QDomElement e = children.at( i ).toElement();
|
||||
if ( e.tagName() != tagname )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
m[ mapname + getLanguage( e ) ] = e.text();
|
||||
}
|
||||
}
|
||||
|
||||
/** @brief gets the <name> and <description> elements
|
||||
*
|
||||
* Builds up a map of the <name> elements (which may have a *lang*
|
||||
* attribute to indicate translations and paragraphs of the
|
||||
* <description> element (also with lang). Uses the <summary>
|
||||
* elements to supplement the description if no description
|
||||
* is available for a given language.
|
||||
*
|
||||
* Returns a map with keys suitable for use by TranslatedString.
|
||||
*/
|
||||
static inline QVariantMap
|
||||
getNameAndSummary( const QDomNode& n )
|
||||
{
|
||||
QVariantMap m;
|
||||
|
||||
const QDomNodeList children = n.childNodes();
|
||||
fillMap( m, children, "name", "name" );
|
||||
fillMap( m, children, "summary", "description" );
|
||||
|
||||
const QDomElement description = n.firstChildElement( "description" );
|
||||
if ( !description.isNull() )
|
||||
{
|
||||
fillMap( m, description.childNodes(), "p", "description" );
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
PackageItem
|
||||
fromAppData( const QVariantMap& item_map )
|
||||
{
|
||||
QString fileName = Calamares::getString( item_map, "appdata" );
|
||||
if ( fileName.isEmpty() )
|
||||
{
|
||||
cWarning() << "Can't load AppData without a suitable key.";
|
||||
return PackageItem();
|
||||
}
|
||||
cDebug() << "Loading AppData XML from" << fileName;
|
||||
|
||||
QDomDocument doc = loadAppData( fileName );
|
||||
if ( doc.isNull() )
|
||||
{
|
||||
return PackageItem();
|
||||
}
|
||||
|
||||
QDomElement componentNode = doc.documentElement();
|
||||
if ( !componentNode.isNull() && componentNode.tagName() == "component" )
|
||||
{
|
||||
// An "id" entry in the Calamares config overrides ID in the AppData
|
||||
QString id = Calamares::getString( item_map, "id" );
|
||||
if ( id.isEmpty() )
|
||||
{
|
||||
id = getChildText( componentNode, "id" );
|
||||
}
|
||||
if ( id.isEmpty() )
|
||||
{
|
||||
return PackageItem();
|
||||
}
|
||||
|
||||
// A "screenshot" entry in the Calamares config overrides AppData
|
||||
QString screenshotPath = Calamares::getString( item_map, "screenshot" );
|
||||
if ( screenshotPath.isEmpty() )
|
||||
{
|
||||
screenshotPath = getScreenshotPath( componentNode );
|
||||
}
|
||||
|
||||
QVariantMap map = getNameAndSummary( componentNode );
|
||||
map.insert( "id", id );
|
||||
map.insert( "screenshot", screenshotPath );
|
||||
|
||||
return PackageItem( map );
|
||||
}
|
||||
|
||||
return PackageItem();
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ITEMAPPDATA_H
|
||||
#define ITEMAPPDATA_H
|
||||
|
||||
#include "PackageModel.h"
|
||||
|
||||
/** @brief Loads an AppData XML file and returns a PackageItem
|
||||
*
|
||||
* The @p map must have a key *appdata*. That is used as the
|
||||
* primary source of information, but keys *id* and *screenshotPath*
|
||||
* may be used to override parts of the AppData -- 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 XML support in libcalamares, if not present will
|
||||
* return invalid PackageItems.
|
||||
*/
|
||||
PackageItem fromAppData( const QVariantMap& map );
|
||||
|
||||
#endif
|
||||
@@ -1,165 +0,0 @@
|
||||
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
|
||||
/** @brief Loading items from AppStream database.
|
||||
*
|
||||
* Only used if AppStreamQt is found, implements PackageItem::fromAppStream().
|
||||
*/
|
||||
#include "ItemAppStream.h"
|
||||
|
||||
#include "locale/TranslationsModel.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Variant.h"
|
||||
|
||||
/// @brief Return number of pixels in a size, for < ordering purposes
|
||||
static inline quint64
|
||||
sizeOrder( const QSize& size )
|
||||
{
|
||||
return static_cast<quint64>(size.width()) * static_cast<quint64>(size.height());
|
||||
}
|
||||
|
||||
/// @brief Sets a screenshot in @p map from @p screenshot, if a usable one is found
|
||||
static void
|
||||
setScreenshot( QVariantMap& map, const AppStream::Screenshot& screenshot )
|
||||
{
|
||||
if ( screenshot.images().count() < 1 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Pick the smallest
|
||||
QUrl url;
|
||||
quint64 size = sizeOrder( screenshot.images().first().size() );
|
||||
for ( const auto& img : screenshot.images() )
|
||||
{
|
||||
if ( sizeOrder( img.size() ) <= size )
|
||||
{
|
||||
url = img.url();
|
||||
}
|
||||
}
|
||||
|
||||
if ( url.isValid() )
|
||||
{
|
||||
map.insert( "screenshot", url.toString() );
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Interpret an AppStream Component
|
||||
static PackageItem
|
||||
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( "," ) );
|
||||
|
||||
// Assume that the pool has loaded "ALL" locales, but it might be set
|
||||
// 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.
|
||||
setActiveLocale( QStringLiteral( "en_US" ) );
|
||||
QString en_name = component.name();
|
||||
QString en_description = component.description();
|
||||
map.insert( "name", en_name );
|
||||
map.insert( "description", en_description );
|
||||
|
||||
for ( const QString& locale : Calamares::Locale::availableTranslations()->localeIds() )
|
||||
{
|
||||
setActiveLocale( locale );
|
||||
QString name = component.name();
|
||||
if ( name != en_name )
|
||||
{
|
||||
map.insert( QStringLiteral( "name[%1]" ).arg( locale ), name );
|
||||
}
|
||||
QString description = component.description();
|
||||
if ( description != en_description )
|
||||
{
|
||||
map.insert( QStringLiteral( "description[%1]" ).arg( locale ), description );
|
||||
}
|
||||
}
|
||||
|
||||
#if HAVE_APPSTREAM_VERSION == 0
|
||||
auto screenshots = component.screenshots();
|
||||
#else
|
||||
auto screenshots = component.screenshotsAll();
|
||||
#endif
|
||||
if ( screenshots.count() > 0 )
|
||||
{
|
||||
bool done = false;
|
||||
for ( const auto& s : screenshots )
|
||||
{
|
||||
if ( s.isDefault() )
|
||||
{
|
||||
setScreenshot( map, s );
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !done )
|
||||
{
|
||||
setScreenshot( map, screenshots.first() );
|
||||
}
|
||||
}
|
||||
|
||||
return PackageItem( map );
|
||||
}
|
||||
|
||||
PackageItem
|
||||
fromAppStream( AppStream::Pool& pool, const QVariantMap& item_map )
|
||||
{
|
||||
QString appstreamId = Calamares::getString( item_map, "appstream" );
|
||||
if ( appstreamId.isEmpty() )
|
||||
{
|
||||
cWarning() << "Can't load AppStream without a suitable appstreamId.";
|
||||
return PackageItem();
|
||||
}
|
||||
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;
|
||||
return PackageItem();
|
||||
}
|
||||
if ( itemList.count() > 1 )
|
||||
{
|
||||
cDebug() << "Multiple AppStream data for" << appstreamId << "using first.";
|
||||
}
|
||||
|
||||
auto r = fromComponent( pool, itemList.first() );
|
||||
if ( r.isValid() )
|
||||
{
|
||||
QString id = Calamares::getString( item_map, "id" );
|
||||
QString screenshotPath = Calamares::getString( item_map, "screenshot" );
|
||||
if ( !id.isEmpty() )
|
||||
{
|
||||
r.id = id;
|
||||
}
|
||||
if ( !screenshotPath.isEmpty() )
|
||||
{
|
||||
r.screenshot = screenshotPath;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ITEMAPPSTREAM_H
|
||||
#define ITEMAPPSTREAM_H
|
||||
|
||||
#include "PackageModel.h"
|
||||
|
||||
/*
|
||||
* This weird include mechanism is because an #include line is allowed
|
||||
* to consist of preprocessor-tokens, which are expanded, and then
|
||||
* the #include is *re*processed. But if it starts with < or ", then
|
||||
* preprocessor tokens are not expanded. So we build up a #include <>
|
||||
* style line with a suitable path -- if we are given a value for
|
||||
* HAVE_APPSTREAM_HEADERS, that is the directory that the AppStreamQt
|
||||
* headers live in.
|
||||
*/
|
||||
#define CALAMARES_LT <
|
||||
#define CALAMARES_GT >
|
||||
|
||||
#ifndef HAVE_APPSTREAM_HEADERS
|
||||
#define HAVE_APPSTREAM_HEADERS AppStreamQt
|
||||
#endif
|
||||
|
||||
#include CALAMARES_LT HAVE_APPSTREAM_HEADERS/pool.h CALAMARES_GT
|
||||
#include CALAMARES_LT HAVE_APPSTREAM_HEADERS/image.h CALAMARES_GT
|
||||
#include CALAMARES_LT HAVE_APPSTREAM_HEADERS/screenshot.h CALAMARES_GT
|
||||
|
||||
#undef CALAMARES_LT
|
||||
#undef CALAMARES_GT
|
||||
|
||||
/** @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.
|
||||
*/
|
||||
PackageItem fromAppStream( AppStream::Pool& pool, const QVariantMap& map );
|
||||
|
||||
#endif
|
||||
@@ -1,145 +0,0 @@
|
||||
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "PackageChooserPage.h"
|
||||
|
||||
#include "ui_page_package.h"
|
||||
|
||||
#include "utils/Gui.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Retranslator.h"
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
PackageChooserPage::PackageChooserPage( PackageChooserMode mode, QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, ui( new Ui::PackageChooserPage )
|
||||
, m_introduction( QString(),
|
||||
QString(),
|
||||
tr( "Package Selection" ),
|
||||
tr( "Please pick a product from the list. The selected product will be installed." ) )
|
||||
{
|
||||
m_introduction.screenshot = QPixmap( QStringLiteral( ":/images/no-selection.png" ) );
|
||||
|
||||
ui->setupUi( this );
|
||||
CALAMARES_RETRANSLATE( updateLabels(); );
|
||||
|
||||
switch ( mode )
|
||||
{
|
||||
case PackageChooserMode::Optional:
|
||||
[[fallthrough]];
|
||||
case PackageChooserMode::Required:
|
||||
ui->products->setSelectionMode( QAbstractItemView::SingleSelection );
|
||||
break;
|
||||
case PackageChooserMode::OptionalMultiple:
|
||||
[[fallthrough]];
|
||||
case PackageChooserMode::RequiredMultiple:
|
||||
ui->products->setSelectionMode( QAbstractItemView::ExtendedSelection );
|
||||
}
|
||||
|
||||
ui->products->setMinimumWidth( 10 * Calamares::defaultFontHeight() );
|
||||
}
|
||||
|
||||
void
|
||||
PackageChooserPage::currentChanged( const QModelIndex& index )
|
||||
{
|
||||
if ( !index.isValid() || !ui->products->selectionModel()->hasSelection() )
|
||||
{
|
||||
ui->productName->setText( m_introduction.name.get() );
|
||||
ui->productScreenshot->setPixmap( m_introduction.screenshot );
|
||||
ui->productDescription->setText( m_introduction.description.get() );
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto* model = ui->products->model();
|
||||
|
||||
ui->productName->setText( model->data( index, PackageListModel::NameRole ).toString() );
|
||||
ui->productDescription->setText( model->data( index, PackageListModel::DescriptionRole ).toString() );
|
||||
|
||||
QPixmap currentScreenshot = model->data( index, PackageListModel::ScreenshotRole ).value< QPixmap >();
|
||||
if ( currentScreenshot.isNull() )
|
||||
{
|
||||
ui->productScreenshot->setPixmap( m_introduction.screenshot );
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->productScreenshot->setPixmap( currentScreenshot );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PackageChooserPage::updateLabels()
|
||||
{
|
||||
if ( ui && ui->products && ui->products->selectionModel() )
|
||||
{
|
||||
currentChanged( ui->products->selectionModel()->currentIndex() );
|
||||
}
|
||||
else
|
||||
{
|
||||
currentChanged( QModelIndex() );
|
||||
}
|
||||
emit selectionChanged();
|
||||
}
|
||||
|
||||
void
|
||||
PackageChooserPage::setModel( QAbstractItemModel* model )
|
||||
{
|
||||
ui->products->setModel( model );
|
||||
currentChanged( QModelIndex() );
|
||||
connect( ui->products->selectionModel(),
|
||||
&QItemSelectionModel::selectionChanged,
|
||||
this,
|
||||
&PackageChooserPage::updateLabels );
|
||||
}
|
||||
|
||||
void
|
||||
PackageChooserPage::setSelection( const QModelIndex& index )
|
||||
{
|
||||
if ( index.isValid() )
|
||||
{
|
||||
ui->products->selectionModel()->select( index, QItemSelectionModel::Select );
|
||||
}
|
||||
currentChanged( index );
|
||||
}
|
||||
|
||||
bool
|
||||
PackageChooserPage::hasSelection() const
|
||||
{
|
||||
return ui && ui->products && ui->products->selectionModel() && ui->products->selectionModel()->hasSelection();
|
||||
}
|
||||
|
||||
QStringList
|
||||
PackageChooserPage::selectedPackageIds() const
|
||||
{
|
||||
if ( !( ui && ui->products && ui->products->selectionModel() ) )
|
||||
{
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
const auto* model = ui->products->model();
|
||||
QStringList ids;
|
||||
for ( const auto& index : ui->products->selectionModel()->selectedIndexes() )
|
||||
{
|
||||
QString pid = model->data( index, PackageListModel::IdRole ).toString();
|
||||
if ( !pid.isEmpty() )
|
||||
{
|
||||
ids.append( pid );
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
void
|
||||
PackageChooserPage::setIntroduction( const PackageItem& item )
|
||||
{
|
||||
m_introduction.name = item.name;
|
||||
m_introduction.description = item.description;
|
||||
m_introduction.screenshot = item.screenshot;
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PACKAGECHOOSERPAGE_H
|
||||
#define PACKAGECHOOSERPAGE_H
|
||||
|
||||
#include "Config.h"
|
||||
#include "PackageModel.h"
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class PackageChooserPage;
|
||||
} // namespace Ui
|
||||
|
||||
class PackageChooserPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PackageChooserPage( PackageChooserMode mode, QWidget* parent = nullptr );
|
||||
|
||||
/// @brief Sets the data model for the listview
|
||||
void setModel( QAbstractItemModel* model );
|
||||
|
||||
/// @brief Sets the introductory (no-package-selected) texts
|
||||
void setIntroduction( const PackageItem& item );
|
||||
/// @brief Selects a listview item
|
||||
void setSelection( const QModelIndex& index );
|
||||
/// @brief Is anything selected?
|
||||
bool hasSelection() const;
|
||||
/** @brief Get the list of selected ids
|
||||
*
|
||||
* This list may be empty (if none is selected).
|
||||
*/
|
||||
QStringList selectedPackageIds() const;
|
||||
|
||||
public slots:
|
||||
void currentChanged( const QModelIndex& index );
|
||||
void updateLabels();
|
||||
|
||||
signals:
|
||||
void selectionChanged();
|
||||
|
||||
private:
|
||||
Ui::PackageChooserPage* ui;
|
||||
PackageItem m_introduction;
|
||||
};
|
||||
|
||||
#endif // PACKAGECHOOSERPAGE_H
|
||||
@@ -1,158 +0,0 @@
|
||||
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "PackageChooserViewStep.h"
|
||||
|
||||
#include "Config.h"
|
||||
#include "PackageChooserPage.h"
|
||||
#include "PackageModel.h"
|
||||
|
||||
#include "GlobalStorage.h"
|
||||
#include "JobQueue.h"
|
||||
#include "locale/TranslatableConfiguration.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/System.h"
|
||||
#include "utils/Variant.h"
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QVariantMap>
|
||||
|
||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( PackageChooserViewStepFactory, registerPlugin< PackageChooserViewStep >(); )
|
||||
|
||||
PackageChooserViewStep::PackageChooserViewStep( QObject* parent )
|
||||
: Calamares::ViewStep( parent )
|
||||
, m_config( new Config( this ) )
|
||||
, m_widget( nullptr )
|
||||
{
|
||||
emit nextStatusChanged( false );
|
||||
}
|
||||
|
||||
|
||||
PackageChooserViewStep::~PackageChooserViewStep()
|
||||
{
|
||||
if ( m_widget && m_widget->parent() == nullptr )
|
||||
{
|
||||
m_widget->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
PackageChooserViewStep::prettyName() const
|
||||
{
|
||||
return m_config->prettyName();
|
||||
}
|
||||
|
||||
|
||||
QWidget*
|
||||
PackageChooserViewStep::widget()
|
||||
{
|
||||
if ( !m_widget )
|
||||
{
|
||||
m_widget = new PackageChooserPage( m_config->mode(), nullptr );
|
||||
connect( m_widget,
|
||||
&PackageChooserPage::selectionChanged,
|
||||
[ = ]() { emit nextStatusChanged( this->isNextEnabled() ); } );
|
||||
hookupModel();
|
||||
}
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PackageChooserViewStep::isNextEnabled() const
|
||||
{
|
||||
if ( !m_widget )
|
||||
{
|
||||
// No way to have changed anything
|
||||
return true;
|
||||
}
|
||||
|
||||
switch ( m_config->mode() )
|
||||
{
|
||||
case PackageChooserMode::Optional:
|
||||
case PackageChooserMode::OptionalMultiple:
|
||||
// zero or one OR zero or more
|
||||
return true;
|
||||
case PackageChooserMode::Required:
|
||||
case PackageChooserMode::RequiredMultiple:
|
||||
// exactly one OR one or more
|
||||
return m_widget->hasSelection();
|
||||
}
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PackageChooserViewStep::isBackEnabled() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PackageChooserViewStep::isAtBeginning() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PackageChooserViewStep::isAtEnd() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
PackageChooserViewStep::onActivate()
|
||||
{
|
||||
if ( !m_widget->hasSelection() )
|
||||
{
|
||||
m_widget->setSelection( m_config->defaultSelectionIndex() );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PackageChooserViewStep::onLeave()
|
||||
{
|
||||
m_config->updateGlobalStorage( m_widget->selectedPackageIds() );
|
||||
}
|
||||
|
||||
Calamares::JobList
|
||||
PackageChooserViewStep::jobs() const
|
||||
{
|
||||
Calamares::JobList l;
|
||||
return l;
|
||||
}
|
||||
|
||||
void
|
||||
PackageChooserViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
{
|
||||
m_config->setDefaultId( moduleInstanceKey() );
|
||||
m_config->setConfigurationMap( configurationMap );
|
||||
|
||||
if ( m_widget )
|
||||
{
|
||||
hookupModel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PackageChooserViewStep::hookupModel()
|
||||
{
|
||||
if ( !m_config->model() || !m_widget )
|
||||
{
|
||||
cError() << "Can't hook up model until widget and model both exist.";
|
||||
return;
|
||||
}
|
||||
|
||||
m_widget->setModel( m_config->model() );
|
||||
m_widget->setIntroduction( m_config->introductionPackage() );
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PACKAGECHOOSERVIEWSTEP_H
|
||||
#define PACKAGECHOOSERVIEWSTEP_H
|
||||
|
||||
#include "DllMacro.h"
|
||||
#include "locale/TranslatableConfiguration.h"
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
|
||||
#include <QVariantMap>
|
||||
|
||||
class Config;
|
||||
class PackageChooserPage;
|
||||
|
||||
class PLUGINDLLEXPORT PackageChooserViewStep : public Calamares::ViewStep
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PackageChooserViewStep( QObject* parent = nullptr );
|
||||
~PackageChooserViewStep() override;
|
||||
|
||||
QString prettyName() const override;
|
||||
|
||||
QWidget* widget() override;
|
||||
|
||||
bool isNextEnabled() const override;
|
||||
bool isBackEnabled() const override;
|
||||
|
||||
bool isAtBeginning() const override;
|
||||
bool isAtEnd() const override;
|
||||
|
||||
void onActivate() override;
|
||||
void onLeave() override;
|
||||
|
||||
Calamares::JobList jobs() const override;
|
||||
|
||||
void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
||||
|
||||
private:
|
||||
void hookupModel();
|
||||
|
||||
Config* m_config;
|
||||
PackageChooserPage* m_widget;
|
||||
};
|
||||
|
||||
CALAMARES_PLUGIN_FACTORY_DECLARATION( PackageChooserViewStepFactory )
|
||||
|
||||
#endif // PACKAGECHOOSERVIEWSTEP_H
|
||||
@@ -1,196 +0,0 @@
|
||||
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "PackageModel.h"
|
||||
|
||||
#include "Branding.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Variant.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
/** @brief A wrapper for Calamares::getSubMap that excludes the success param
|
||||
*/
|
||||
static QVariantMap
|
||||
getSubMap( const QVariantMap& map, const QString& key )
|
||||
{
|
||||
bool success;
|
||||
|
||||
return Calamares::getSubMap( map, key, success );
|
||||
}
|
||||
|
||||
static QPixmap
|
||||
loadScreenshot( const QString& path )
|
||||
{
|
||||
if ( QFileInfo::exists( path ) )
|
||||
{
|
||||
return QPixmap( path );
|
||||
}
|
||||
|
||||
const auto* branding = Calamares::Branding::instance();
|
||||
if ( !branding )
|
||||
{
|
||||
return QPixmap();
|
||||
}
|
||||
return QPixmap( branding->componentDirectory() + QStringLiteral( "/" ) + path );
|
||||
}
|
||||
|
||||
PackageItem::PackageItem() {}
|
||||
|
||||
PackageItem::PackageItem( const QString& a_id, const QString& a_name, const QString& a_description )
|
||||
: id( a_id )
|
||||
, name( a_name )
|
||||
, description( a_description )
|
||||
{
|
||||
}
|
||||
|
||||
PackageItem::PackageItem( const QString& a_id,
|
||||
const QString& a_name,
|
||||
const QString& a_description,
|
||||
const QString& screenshotPath )
|
||||
: id( a_id )
|
||||
, name( a_name )
|
||||
, description( a_description )
|
||||
, screenshot( screenshotPath )
|
||||
{
|
||||
}
|
||||
|
||||
PackageItem::PackageItem( const QVariantMap& item_map )
|
||||
: id( Calamares::getString( item_map, "id" ) )
|
||||
, name( Calamares::Locale::TranslatedString( item_map, "name" ) )
|
||||
, description( Calamares::Locale::TranslatedString( item_map, "description" ) )
|
||||
, screenshot( loadScreenshot( Calamares::getString( item_map, "screenshot" ) ) )
|
||||
, packageNames( Calamares::getStringList( item_map, "packages" ) )
|
||||
, netinstallData( getSubMap( item_map, "netinstall" ) )
|
||||
{
|
||||
if ( name.isEmpty() && id.isEmpty() )
|
||||
{
|
||||
name = QObject::tr( "No product" );
|
||||
}
|
||||
else if ( name.isEmpty() )
|
||||
{
|
||||
cWarning() << "PackageChooser item" << id << "has an empty name.";
|
||||
}
|
||||
if ( description.isEmpty() )
|
||||
{
|
||||
description = QObject::tr( "No description provided." );
|
||||
}
|
||||
}
|
||||
|
||||
PackageListModel::PackageListModel( QObject* parent )
|
||||
: QAbstractListModel( parent )
|
||||
{
|
||||
}
|
||||
|
||||
PackageListModel::PackageListModel( PackageList&& items, QObject* parent )
|
||||
: QAbstractListModel( parent )
|
||||
, m_packages( std::move( items ) )
|
||||
{
|
||||
}
|
||||
|
||||
PackageListModel::~PackageListModel() {}
|
||||
|
||||
void
|
||||
PackageListModel::addPackage( PackageItem&& p )
|
||||
{
|
||||
// Only add valid packages
|
||||
if ( p.isValid() )
|
||||
{
|
||||
int c = m_packages.count();
|
||||
beginInsertRows( QModelIndex(), c, c );
|
||||
m_packages.append( p );
|
||||
endInsertRows();
|
||||
}
|
||||
}
|
||||
|
||||
QStringList
|
||||
PackageListModel::getInstallPackagesForName( const QString& id ) const
|
||||
{
|
||||
for ( const auto& p : qAsConst( m_packages ) )
|
||||
{
|
||||
if ( p.id == id )
|
||||
{
|
||||
return p.packageNames;
|
||||
}
|
||||
}
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
QStringList
|
||||
PackageListModel::getInstallPackagesForNames( const QStringList& ids ) const
|
||||
{
|
||||
QStringList l;
|
||||
for ( const auto& p : qAsConst( m_packages ) )
|
||||
{
|
||||
if ( ids.contains( p.id ) )
|
||||
{
|
||||
l.append( p.packageNames );
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
QVariantList
|
||||
PackageListModel::getNetinstallDataForNames( const QStringList& ids ) const
|
||||
{
|
||||
QVariantList l;
|
||||
for ( auto& p : m_packages )
|
||||
{
|
||||
if ( ids.contains( p.id ) )
|
||||
{
|
||||
if ( !p.netinstallData.isEmpty() )
|
||||
{
|
||||
QVariantMap newData = p.netinstallData;
|
||||
newData[ "source" ] = QStringLiteral( "packageChooser" );
|
||||
l.append( newData );
|
||||
}
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
int
|
||||
PackageListModel::rowCount( const QModelIndex& index ) const
|
||||
{
|
||||
// For lists, valid indexes have zero children; only the root index has them
|
||||
return index.isValid() ? 0 : m_packages.count();
|
||||
}
|
||||
|
||||
QVariant
|
||||
PackageListModel::data( const QModelIndex& index, int role ) const
|
||||
{
|
||||
if ( !index.isValid() )
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
int row = index.row();
|
||||
if ( row >= m_packages.count() || row < 0 )
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if ( role == Qt::DisplayRole /* Also PackageNameRole */ )
|
||||
{
|
||||
return m_packages[ row ].name.get();
|
||||
}
|
||||
else if ( role == DescriptionRole )
|
||||
{
|
||||
return m_packages[ row ].description.get();
|
||||
}
|
||||
else if ( role == ScreenshotRole )
|
||||
{
|
||||
return m_packages[ row ].screenshot;
|
||||
}
|
||||
else if ( role == IdRole )
|
||||
{
|
||||
return m_packages[ row ].id;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PACKAGEMODEL_H
|
||||
#define PACKAGEMODEL_H
|
||||
|
||||
#include "locale/TranslatableConfiguration.h"
|
||||
#include "utils/NamedEnum.h"
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QObject>
|
||||
#include <QPixmap>
|
||||
#include <QVector>
|
||||
|
||||
|
||||
struct PackageItem
|
||||
{
|
||||
QString id;
|
||||
Calamares::Locale::TranslatedString name;
|
||||
Calamares::Locale::TranslatedString description;
|
||||
QPixmap screenshot;
|
||||
QStringList packageNames;
|
||||
QVariantMap netinstallData;
|
||||
|
||||
/// @brief Create blank PackageItem
|
||||
PackageItem();
|
||||
/** @brief Creates a PackageItem from given strings
|
||||
*
|
||||
* This constructor sets all the text members,
|
||||
* but leaves the screenshot blank. Set that separately.
|
||||
*/
|
||||
PackageItem( const QString& id, const QString& name, const QString& description );
|
||||
|
||||
/** @brief Creates a PackageItem from given strings.
|
||||
*
|
||||
* Set all the text members and load the screenshot from the given
|
||||
* @p screenshotPath, which may be a QRC path (:/path/in/qrc) or
|
||||
* a filesystem path, whatever QPixmap understands.
|
||||
*/
|
||||
PackageItem( const QString& id, const QString& name, const QString& description, const QString& screenshotPath );
|
||||
|
||||
/** @brief Creates a PackageItem from a QVariantMap
|
||||
*
|
||||
* This is intended for use when loading PackageItems from a
|
||||
* configuration map. It will look up the various keys in the map
|
||||
* and handle translation strings as well.
|
||||
*
|
||||
* The following keys are used:
|
||||
* - *id*: the identifier for this item; if it is the empty string
|
||||
* then this is the special "no-package".
|
||||
* - *name* (and *name[lang]*): for the name and its translations
|
||||
* - *description* (and *description[lang]*)
|
||||
* - *screenshot*: a path to a screenshot for this package
|
||||
* - *packages*: a list of package names
|
||||
*/
|
||||
PackageItem( const QVariantMap& map );
|
||||
|
||||
/** @brief Is this item valid?
|
||||
*
|
||||
* A valid item has an untranslated name available.
|
||||
*/
|
||||
bool isValid() const { return !name.isEmpty(); }
|
||||
|
||||
/** @brief Is this a (the) No-Package package?
|
||||
*
|
||||
* There should be at most one No-Package item in a collection
|
||||
* of PackageItems. That one will be used to describe a
|
||||
* "no package" situation.
|
||||
*/
|
||||
bool isNonePackage() const { return id.isEmpty(); }
|
||||
};
|
||||
|
||||
using PackageList = QVector< PackageItem >;
|
||||
|
||||
class PackageListModel : public QAbstractListModel
|
||||
{
|
||||
public:
|
||||
PackageListModel( PackageList&& items, QObject* parent );
|
||||
PackageListModel( QObject* parent );
|
||||
~PackageListModel() override;
|
||||
|
||||
/** @brief Add a package @p to the model
|
||||
*
|
||||
* Only valid packages are added -- that is, they must have a name.
|
||||
*/
|
||||
void addPackage( PackageItem&& p );
|
||||
|
||||
int rowCount( const QModelIndex& index ) const override;
|
||||
QVariant data( const QModelIndex& index, int role ) const override;
|
||||
|
||||
/// @brief Direct (non-abstract) access to package data
|
||||
const PackageItem& packageData( int r ) const { return m_packages[ r ]; }
|
||||
/// @brief Direct (non-abstract) count of package data
|
||||
int packageCount() const { return m_packages.count(); }
|
||||
|
||||
/** @brief Does a name lookup (based on id) and returns the packages member
|
||||
*
|
||||
* If there is a package with the given @p id, returns its packages
|
||||
* (e.g. the names of underlying packages to install for it); returns
|
||||
* an empty list if the id is not found.
|
||||
*/
|
||||
QStringList getInstallPackagesForName( const QString& id ) const;
|
||||
/** @brief Name-lookup all the @p ids and returns the packages members
|
||||
*
|
||||
* Concatenates installPackagesForName() for each id in @p ids.
|
||||
*/
|
||||
QStringList getInstallPackagesForNames( const QStringList& ids ) const;
|
||||
|
||||
/** @brief Does a name lookup (based on id) and returns the netinstall data
|
||||
*
|
||||
* If there is a package with an id in @p ids, returns their netinstall data
|
||||
*
|
||||
* returns a list of netinstall data or an emply list if none is found
|
||||
*/
|
||||
QVariantList getNetinstallDataForNames( const QStringList& ids ) const;
|
||||
|
||||
enum Roles : int
|
||||
{
|
||||
NameRole = Qt::DisplayRole,
|
||||
DescriptionRole = Qt::UserRole,
|
||||
ScreenshotRole,
|
||||
IdRole
|
||||
};
|
||||
|
||||
private:
|
||||
PackageList m_packages;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,84 +0,0 @@
|
||||
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Tests.h"
|
||||
|
||||
#ifdef HAVE_APPDATA
|
||||
#include "ItemAppData.h"
|
||||
#endif
|
||||
#ifdef HAVE_APPSTREAM_VERSION
|
||||
#include "ItemAppStream.h"
|
||||
#endif
|
||||
#include "PackageModel.h"
|
||||
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
QTEST_GUILESS_MAIN( PackageChooserTests )
|
||||
|
||||
PackageChooserTests::PackageChooserTests() {}
|
||||
|
||||
PackageChooserTests::~PackageChooserTests() {}
|
||||
|
||||
void
|
||||
PackageChooserTests::initTestCase()
|
||||
{
|
||||
Logger::setupLogLevel( Logger::LOGDEBUG );
|
||||
}
|
||||
|
||||
void
|
||||
PackageChooserTests::testBogus()
|
||||
{
|
||||
QVERIFY( true );
|
||||
}
|
||||
|
||||
void
|
||||
PackageChooserTests::testAppData()
|
||||
{
|
||||
// Path from the build-dir and from the running-the-test varies,
|
||||
// for in-source build, for build/, and for tests-in-build/,
|
||||
// so look in multiple places.
|
||||
QString appdataName( "io.calamares.calamares.appdata.xml" );
|
||||
for ( const auto& prefix : QStringList { "", "../", "../../../", "../../../../" } )
|
||||
{
|
||||
if ( QFile::exists( prefix + appdataName ) )
|
||||
{
|
||||
appdataName = prefix + appdataName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
QVERIFY( QFile::exists( appdataName ) );
|
||||
|
||||
QVariantMap m;
|
||||
m.insert( "appdata", appdataName );
|
||||
|
||||
#ifdef HAVE_XML
|
||||
PackageItem p1 = fromAppData( m );
|
||||
QVERIFY( p1.isValid() );
|
||||
QCOMPARE( p1.id, QStringLiteral( "io.calamares.calamares.desktop" ) );
|
||||
QCOMPARE( p1.name.get(), QStringLiteral( "Calamares" ) );
|
||||
// The <description> entry has precedence
|
||||
QCOMPARE( p1.description.get(), QStringLiteral( "Calamares is an installer program for Linux distributions." ) );
|
||||
// .. but en_GB doesn't have an entry in description, so uses <summary>
|
||||
QCOMPARE( p1.description.get( QLocale( "en_GB" ) ), QStringLiteral( "Calamares Linux Installer" ) );
|
||||
QCOMPARE( p1.description.get( QLocale( "nl" ) ),
|
||||
QStringLiteral( "Calamares is een installatieprogramma voor Linux distributies." ) );
|
||||
QVERIFY( p1.screenshot.isNull() );
|
||||
|
||||
m.insert( "id", "calamares" );
|
||||
m.insert( "screenshot", ":/images/calamares.png" );
|
||||
PackageItem p2 = fromAppData( m );
|
||||
QVERIFY( p2.isValid() );
|
||||
QCOMPARE( p2.id, QStringLiteral( "calamares" ) );
|
||||
QCOMPARE( p2.description.get( QLocale( "nl" ) ),
|
||||
QStringLiteral( "Calamares is een installatieprogramma voor Linux distributies." ) );
|
||||
QVERIFY( !p2.screenshot.isNull() );
|
||||
#endif
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
/* === This file is part of Calamares - <https://calamares.io> ===
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
* Calamares is Free Software: see the License-Identifier above.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PACKAGECHOOSERTESTS_H
|
||||
#define PACKAGECHOOSERTESTS_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class PackageChooserTests : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PackageChooserTests();
|
||||
~PackageChooserTests() override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
void testBogus();
|
||||
void testAppData();
|
||||
};
|
||||
|
||||
#endif
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 8.1 KiB |
@@ -1,2 +0,0 @@
|
||||
SPDX-FileCopyrightText: 2014 Teo Mrnjavac <teo@kde.org>
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB |
@@ -1,2 +0,0 @@
|
||||
SPDX-FileCopyrightText: 2014 Uri Herrera <uri_herrera@nitrux.in> and others
|
||||
SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.7 KiB |
@@ -1,2 +0,0 @@
|
||||
SPDX-FileCopyrightText: 2014 Uri Herrera <uri_herrera@nitrux.in> and others
|
||||
SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
@@ -1,172 +0,0 @@
|
||||
# SPDX-FileCopyrightText: no
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
#
|
||||
# Configuration for the low-density software chooser
|
||||
---
|
||||
# Software selection mode, to set whether the software packages
|
||||
# can be chosen singly, or multiply.
|
||||
#
|
||||
# Possible modes are "optional", "required" (for zero-or-one or exactly-one)
|
||||
# or "optionalmultiple", "requiredmultiple" (for zero-or-more
|
||||
# or one-or-more).
|
||||
mode: required
|
||||
|
||||
# Software installation method:
|
||||
#
|
||||
# - "legacy" or "custom" or "contextualprocess"
|
||||
# When set to "legacy", writes a GlobalStorage value for the choice that
|
||||
# has been made. The key is *packagechooser_<id>*. The module's
|
||||
# instance name is used; see the *instances* section of `settings.conf`.
|
||||
# If there is just one packagechooser module, and no special instance is set,
|
||||
# resulting GS key is probably *packagechooser_packagechooser*.
|
||||
#
|
||||
# The GS value is a comma-separated list of the IDs of the selected
|
||||
# packages, or an empty string if none is selected.
|
||||
#
|
||||
# With "legacy" installation, you should have a contextualprocess or similar
|
||||
# module somewhere in the `exec` phase to process the GlobalStorage key
|
||||
# and actually **do** something for the packages.
|
||||
#
|
||||
# - "packages"
|
||||
# When set to "packages", writes GlobalStorage values suitable for
|
||||
# consumption by the *packages* module (which should appear later
|
||||
# in the `exec` section. These package settings will then be handed
|
||||
# off to whatever package manager is configured there.
|
||||
#
|
||||
# - "netinstall-select"
|
||||
# When this is set, the id(s) selected are passed to the netinstall module.
|
||||
# Any id that matches a group name in that module is set to checked
|
||||
#
|
||||
# - "netinstall-add"
|
||||
# With this method, the packagechooser module is used to add groups to the
|
||||
# netinstall module. For this to have any effect. You must set netinstall,
|
||||
# which is described below.
|
||||
#
|
||||
# There is no need to put this module in the `exec` section. There
|
||||
# are no jobs that this module provides. You should put **other**
|
||||
# modules, either *contextualprocess* or *packages* or some custom
|
||||
# module, in the `exec` section to do the actual work.
|
||||
method: legacy
|
||||
|
||||
|
||||
# Human-visible strings in this module. These are all optional.
|
||||
# The following translated keys are used:
|
||||
# - *step*, used in the overall progress view (left-hand pane)
|
||||
#
|
||||
# Each key can have a [locale] added to it, which is used as
|
||||
# the translated string for that locale. For the strings
|
||||
# associated with the "no-selection" item, see *items*, below
|
||||
# with the explicit item-*id* "".
|
||||
#
|
||||
labels:
|
||||
step: "Packages"
|
||||
step[nl]: "Pakketten"
|
||||
|
||||
# (Optional) item-*id* of pre-selected list-view item.
|
||||
# Pre-selects one of the items below.
|
||||
# default: kde
|
||||
|
||||
# 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, 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
|
||||
# setting the value of *packagechooser_<module-id>*. The following field
|
||||
# is mandatory:
|
||||
#
|
||||
# - *id*
|
||||
# ID for the product. The ID "" is special, and is used for
|
||||
# "no package selected". Only include this if the mode allows
|
||||
# selecting none. The name and description given for the "no package
|
||||
# selected" item are displayed when the module starts.
|
||||
#
|
||||
# Each item must adhere to one of three "styles" of item. Which styles
|
||||
# are supported depends on compile-time dependencies of Calamares.
|
||||
# Both AppData and AppStream may **optionally** be available.
|
||||
#
|
||||
# # Generic Items #
|
||||
#
|
||||
# These items are always supported. They require the most configuration
|
||||
# **in this file** and duplicate information that may be available elsewhere
|
||||
# (e.g. in AppData or AppStream), but do not require any additional
|
||||
# dependencies. These items have the following **mandatory** fields:
|
||||
#
|
||||
# - *name*
|
||||
# Human-readable name of the product. To provide translations,
|
||||
# add a *[lang]* decoration as part of the key name, e.g. `name[nl]`
|
||||
# for Dutch. The list of usable languages can be found in
|
||||
# `CMakeLists.txt` or as part of the debug output of Calamares.
|
||||
# - *description*
|
||||
# Human-readable description. These can be translated as well.
|
||||
# - *screenshot*
|
||||
# Path to a single screenshot of the product. May be a filesystem
|
||||
# path or a QRC path, e.g. ":/images/no-selection.png". If the path
|
||||
# is not found (e.g. is a non-existent absolute path, or is a relative
|
||||
# path that does not exist in the current working directory) then
|
||||
# an additional attempt is made to load the image from the **branding**
|
||||
# directory.
|
||||
#
|
||||
# The following fields are **optional** for an item:
|
||||
#
|
||||
# - *packages* :
|
||||
# List of package names for the product. If using the *method*
|
||||
# "packages", consider this item mandatory (because otherwise
|
||||
# selecting the item would install no packages).
|
||||
#
|
||||
# - *netinstall* :
|
||||
# The data in this field should follow the format of a group
|
||||
# from the netinstall module documented in
|
||||
# src/modules/netinstall/netinstall.conf. This is only used
|
||||
# when method is set to "netinstall-add"
|
||||
#
|
||||
# # AppData Items #
|
||||
#
|
||||
# For data provided by AppData XML: the item has an *appdata*
|
||||
# key which points to an AppData XML file in the local filesystem.
|
||||
# This file is parsed to provide the id (from AppData id), name
|
||||
# (from AppData name), description (from AppData description paragraphs
|
||||
# or the summary entries), and a screenshot (the default screenshot
|
||||
# from AppData). No package is set (but that is unused anyway).
|
||||
#
|
||||
# AppData may contain IDs that are not useful inside Calamares,
|
||||
# and the screenshot URL may be remote -- a remote URL will not
|
||||
# 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.
|
||||
#
|
||||
# # AppStream Items #
|
||||
#
|
||||
# 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: ""
|
||||
# packages: [] # This item installs no packages
|
||||
name: "No Desktop"
|
||||
name[nl]: "Geen desktop"
|
||||
description: "Please pick a desktop environment from the list. If you don't want to install a desktop, that's fine, your system will start up in text-only mode and you can install a desktop environment later."
|
||||
description[nl]: "Kies eventueel een desktop-omgeving uit deze lijst. Als u geen desktop-omgeving wenst te gebruiken, kies er dan geen. In dat geval start het systeem straks op in tekst-modus en kunt u later alsnog een desktop-omgeving installeren."
|
||||
screenshot: ":/images/no-selection.png"
|
||||
- id: kde
|
||||
packages: [ kde-frameworks, kde-plasma, kde-gear ]
|
||||
name: Plasma Desktop
|
||||
description: "KDE Plasma Desktop, simple by default, a clean work area for real-world usage which intends to stay out of your way. Plasma is powerful when needed, enabling the user to create the workflow that makes them more effective to complete their tasks."
|
||||
screenshot: ":/images/kde.png"
|
||||
- id: gnome
|
||||
packages: [ gnome-all ]
|
||||
name: GNOME
|
||||
description: GNU Networked Object Modeling Environment Desktop
|
||||
screenshot: ":/images/gnome.png"
|
||||
- id: calamares
|
||||
appdata: ../io.calamares.calamares.appdata.xml
|
||||
screenshot: ":/images/calamares.png"
|
||||
- id: kate
|
||||
appstream: org.kde.kwrite.desktop
|
||||
@@ -1,5 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>images/if.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -1,104 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<author>
|
||||
SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
</author>
|
||||
<class>PackageChooserPage</class>
|
||||
<widget class="QWidget" name="PackageChooserPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>500</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,4">
|
||||
<item>
|
||||
<widget class="QListView" name="products">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,30,1">
|
||||
<item>
|
||||
<widget class="QLabel" name="productName">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Product Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="FixedAspectRatioLabel" name="productScreenshot">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="productDescription">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Long Product Description</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>FixedAspectRatioLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>widgets/FixedAspectRatioLabel.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -27,54 +27,191 @@ import libcalamares
|
||||
from libcalamares.utils import target_env_call
|
||||
|
||||
|
||||
class ConfigController:
|
||||
"""Configuration controller
|
||||
import gettext
|
||||
_ = gettext.translation("calamares-python",
|
||||
localedir=libcalamares.utils.gettext_path(),
|
||||
languages=libcalamares.utils.gettext_languages(),
|
||||
fallback=True).gettext
|
||||
|
||||
|
||||
def pretty_name():
|
||||
return _("Configure user services")
|
||||
|
||||
|
||||
def terminate(proc):
|
||||
"""Send SIGKILL to the given proccess
|
||||
"""
|
||||
target_env_call(['killall', '-9', proc])
|
||||
|
||||
def sedFile(pattern, file):
|
||||
"""Sed the given file with the given pattern
|
||||
"""
|
||||
target_env_call(["sed", "-e", pattern, "-i", file])
|
||||
|
||||
def configure(initsys):
|
||||
"""Configure the services
|
||||
"""
|
||||
if initsys == "openrc":
|
||||
exp = 's|^.*keymap=.*|keymap="{}"|'.format(
|
||||
libcalamares.globalstorage.value("keyboardLayout")
|
||||
)
|
||||
sedFile(exp, "/etc/conf.d/keymaps")
|
||||
|
||||
def fix_btrfs_boot(root):
|
||||
if exists(join(root, "usr/bin/dd")):
|
||||
|
||||
ec = target_env_call(["sh", "-c", 'mkdir -p /tmp/vmlinuz-hack && mv /boot/vmlinuz-* /tmp/vmlinuz-hack/ && find /tmp/vmlinuz-hack/ -maxdepth 1 -type f -exec sh -c \'dd if="$1" of="/boot/$(basename "$1")"\' sh {} \;'])
|
||||
|
||||
if ec != 0:
|
||||
libcalamares.utils.warning(
|
||||
"dd {} call in chroot returned error code {}".format("/boot", ec)
|
||||
)
|
||||
|
||||
if exists(join(root, "boot/intel-ucode.img")):
|
||||
ec = target_env_call(["sh", "-c", 'mkdir -p /tmp/intel-hack && mv /boot/intel-ucode.img /tmp/intel-hack/ && find /tmp/intel-hack/ -maxdepth 1 -type f -exec sh -c \'dd if="$1" of="/boot/$(basename "$1")"\' sh {} \;'])
|
||||
|
||||
if ec != 0:
|
||||
libcalamares.utils.warning(
|
||||
"dd {} call in chroot returned error code {}".format("/boot", ec)
|
||||
)
|
||||
|
||||
if exists(join(root, "boot/amd-ucode.img")):
|
||||
ec = target_env_call(["sh", "-c", 'mkdir -p /tmp/amd-hack && mv /boot/amd-ucode.img /tmp/amd-hack/ && find /tmp/amd-hack/ -maxdepth 1 -type f -exec sh -c \'dd if="$1" of="/boot/$(basename "$1")"\' sh {} \;'])
|
||||
|
||||
if ec != 0:
|
||||
libcalamares.utils.warning(
|
||||
"dd {} call in chroot returned error code {}".format("/boot", ec)
|
||||
)
|
||||
|
||||
|
||||
def manage_services(services, initsys, root):
|
||||
"""
|
||||
For each entry in @p services, run "<command> <action> <name>",
|
||||
where each service is a mapping of service name, action, and a flag.
|
||||
|
||||
Returns a failure message, or None if this was successful.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.root = libcalamares.globalstorage.value("rootMountPoint")
|
||||
username = libcalamares.globalstorage.value("username")
|
||||
|
||||
def terminate(self, proc):
|
||||
"""Send SIGKILL to the given proccess
|
||||
"""
|
||||
target_env_call(['killall', '-9', proc])
|
||||
userhome = "/home/" + username
|
||||
|
||||
def sedFile(self, pattern, file):
|
||||
"""Sed the given file with the given pattern
|
||||
"""
|
||||
target_env_call(["sed", "-e", pattern, "-i", file])
|
||||
owner = username + ":" + username
|
||||
|
||||
def configure(self):
|
||||
"""Configure the services
|
||||
"""
|
||||
if exists(join(self.root, "/etc/conf.d/keymaps")):
|
||||
exp = 's|^.*keymap=.*|keymap="{}"|'.format(
|
||||
libcalamares.globalstorage.value("keyboardLayout")
|
||||
if initsys == "openrc":
|
||||
|
||||
dir_path = userhome + "/.config/rc/runlevels/default"
|
||||
|
||||
ec = target_env_call(["mkdir", "-p", dir_path])
|
||||
|
||||
if ec != 0:
|
||||
libcalamares.utils.warning(
|
||||
"create dir {} call in chroot returned error code {}".format(dir_path, ec)
|
||||
)
|
||||
self.sedFile(exp, "/etc/conf.d/keymaps")
|
||||
|
||||
if exists(join(self.root, "/etc/conf.d/xdm")):
|
||||
for dm in libcalamares.globalstorage.value("displayManagers"):
|
||||
exp = 's|^.*DISPLAYMANAGER=.*|DISPLAYMANAGER="{}"|'.format(dm)
|
||||
self.sedFile(exp, "/etc/conf.d/xdm")
|
||||
elif initsys == "dinit":
|
||||
|
||||
dir_path = userhome + "/.config/dinit.d/boot.d"
|
||||
|
||||
ec = target_env_call(["mkdir", "-p", dir_path])
|
||||
|
||||
if ec != 0:
|
||||
libcalamares.utils.warning(
|
||||
"create dir {} call in chroot returned error code {}".format(dir_path, ec)
|
||||
)
|
||||
|
||||
for sv in services:
|
||||
if isinstance(sv, str):
|
||||
name = sv
|
||||
action = "enable"
|
||||
else:
|
||||
if "name" not in sv:
|
||||
libcalamares.utils.error("The key 'name' is missing from the mapping {_sv!s}. Continuing to the next service.".format(_sv=str(sv)))
|
||||
continue
|
||||
name = sv["name"]
|
||||
action = sv.get("action", "enable")
|
||||
|
||||
if initsys == "openrc":
|
||||
|
||||
svhome = userhome + "/.config/rc"
|
||||
|
||||
src = "/etc/user/init.d/" + name
|
||||
urlvl = svhome + "/runlevels/default/"
|
||||
dest = urlvl + name
|
||||
|
||||
if action == "enable":
|
||||
|
||||
if exists(join(root, src)):
|
||||
|
||||
ec = target_env_call(["ln", "-s", src, dest])
|
||||
|
||||
if ec != 0:
|
||||
libcalamares.utils.warning(
|
||||
"service {} call in chroot returned error code {}".format(action, ec)
|
||||
)
|
||||
|
||||
|
||||
def run(self):
|
||||
"""Run the controller
|
||||
ec = target_env_call(["chown", "-R", owner, svhome ])
|
||||
|
||||
Workaround for pacman-key bug
|
||||
FS#45351 https://bugs.archlinux.org/task/45351
|
||||
We have to kill gpg-agent because if it stays
|
||||
around we can't reliably unmount
|
||||
the target partition.
|
||||
"""
|
||||
self.configure()
|
||||
self.terminate('gpg-agent')
|
||||
if ec != 0:
|
||||
libcalamares.utils.warning(
|
||||
"chown {} call in chroot returned error code {}".format(svhome, ec)
|
||||
)
|
||||
|
||||
elif initsys == "dinit":
|
||||
|
||||
svhome = userhome + "/.config/dinit.d"
|
||||
|
||||
src = "/etc/dinit.d/user/" + name
|
||||
ubdir = svhome + "/boot.d/"
|
||||
dest = ubdir + name
|
||||
|
||||
if action == "enable":
|
||||
|
||||
if exists(join(root, src)):
|
||||
|
||||
ec = target_env_call(["ln", "-s", src, dest])
|
||||
|
||||
if ec != 0:
|
||||
libcalamares.utils.warning(
|
||||
"service {} call in chroot returned error code {}".format(action, ec)
|
||||
)
|
||||
|
||||
ec = target_env_call(["chown", "-R", owner, svhome])
|
||||
|
||||
if ec != 0:
|
||||
libcalamares.utils.warning(
|
||||
"chown {} call in chroot returned error code {}".format(svhome, ec)
|
||||
)
|
||||
|
||||
|
||||
def run():
|
||||
""" Misc postinstall configurations """
|
||||
"""
|
||||
Misc postinstall configurations
|
||||
"""
|
||||
|
||||
config = ConfigController()
|
||||
install_root = libcalamares.globalstorage.value("rootMountPoint")
|
||||
|
||||
return config.run()
|
||||
initsys = libcalamares.job.configuration["initsys"]
|
||||
|
||||
userservices = libcalamares.job.configuration.get("user-services", [])
|
||||
|
||||
partitions = libcalamares.globalstorage.value("partitions")
|
||||
|
||||
configure(initsys)
|
||||
|
||||
has_btrfs = False
|
||||
|
||||
for partition in partitions:
|
||||
if partition["fs"] == "btrfs":
|
||||
has_btrfs = True
|
||||
|
||||
if has_btrfs:
|
||||
fix_btrfs_boot(install_root)
|
||||
|
||||
# terminate('gpg-agent')
|
||||
|
||||
r = manage_services(userservices, initsys, install_root)
|
||||
|
||||
if r is not None:
|
||||
return r
|
||||
|
||||
@@ -4,4 +4,4 @@ type: "job"
|
||||
name: "postcfg"
|
||||
interface: "python"
|
||||
script: "main.py" #assumed relative to the current directory
|
||||
noconfig: true
|
||||
noconfig: false
|
||||
|
||||
11
modules/postcfg/postcfg.conf
Normal file
11
modules/postcfg/postcfg.conf
Normal file
@@ -0,0 +1,11 @@
|
||||
---
|
||||
initsys: openrc
|
||||
user-services:
|
||||
- name: dbus
|
||||
action: enable
|
||||
- name: pipewire
|
||||
action: enable
|
||||
- name: pipewire-pulse
|
||||
action: enable
|
||||
- name: wireplumber
|
||||
action: enable
|
||||
@@ -10,10 +10,10 @@ fi
|
||||
title=${title:-"Switcher"}
|
||||
text=${text:-"Select:"}
|
||||
if [[ -z "${configs[*]}" ]]; then
|
||||
configs=(online offline)
|
||||
configs=(offline online)
|
||||
fi
|
||||
|
||||
select=$(kdialog --title "${title}" --combobox "${text}" "${configs[@]}" --default "${configs[0]}")
|
||||
select=$(kdialog --title "${title}" --combobox "${text}" "${configs[@]}" --default "${configs[0]}") || exit 1
|
||||
|
||||
pkexec ln -snf /etc/calamares-"$select" /etc/calamares
|
||||
pkexec calamares "$@"
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
|
||||
title="Switcher"
|
||||
|
||||
text="Select calamares<br>configuration:"
|
||||
text="Select calamares configuration:<br><br>Online is experimental, go with offline.<br>"
|
||||
|
||||
configs=(online offline)
|
||||
configs=(offline online)
|
||||
|
||||
Reference in New Issue
Block a user