Merge branch 'name-netinstall'
Extra UI options for the netinstall page (to support having multiple)
This commit is contained in:
commit
4e3ef607b1
4
CHANGES
4
CHANGES
@ -37,8 +37,8 @@ This release contains contributions from (alphabetically by first name):
|
||||
- Multiple *netinstall* modules can exist side-by-side, and they each
|
||||
control the package installation for their part of the package list.
|
||||
Previously, a netinstall module would overwrite all of the package
|
||||
configuration done by other netinstall modules.
|
||||
#1303
|
||||
configuration done by other netinstall modules. Translations can be
|
||||
provided in the configuration file, `netinstall.conf`. #1303
|
||||
|
||||
|
||||
# 3.2.18 (2020-01-28) #
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2016, Luca Giambonini <almack@chakraos.org>
|
||||
* Copyright 2016, Lisa Vitolo <shainer@chakraos.org>
|
||||
* Copyright 2017, Kyle Robbertze <krobbertze@gmail.com>
|
||||
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
|
||||
* Copyright 2017-2018, 2020, Adriaan de Groot <groot@kde.org>
|
||||
* Copyright 2017, Gabriel Craciunescu <crazy@frugalware.org>
|
||||
*
|
||||
* Calamares is free software: you can redistribute it and/or modify
|
||||
@ -34,8 +34,6 @@
|
||||
#include <QHeaderView>
|
||||
#include <QNetworkReply>
|
||||
|
||||
using CalamaresUtils::yamlToVariant;
|
||||
|
||||
NetInstallPage::NetInstallPage( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, ui( new Ui::Page_NetInst )
|
||||
@ -43,6 +41,38 @@ NetInstallPage::NetInstallPage( QWidget* parent )
|
||||
, m_groups( nullptr )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
setPageTitle( nullptr );
|
||||
CALAMARES_RETRANSLATE_SLOT( &NetInstallPage::retranslate );
|
||||
}
|
||||
|
||||
NetInstallPage::~NetInstallPage()
|
||||
{
|
||||
delete m_groups;
|
||||
delete m_reply;
|
||||
}
|
||||
|
||||
void
|
||||
NetInstallPage::setPageTitle( CalamaresUtils::Locale::TranslatedString* t )
|
||||
{
|
||||
m_title.reset( t );
|
||||
if ( !m_title )
|
||||
{
|
||||
ui->label->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->label->show();
|
||||
}
|
||||
retranslate();
|
||||
}
|
||||
|
||||
void
|
||||
NetInstallPage::retranslate()
|
||||
{
|
||||
if ( ui && m_title )
|
||||
{
|
||||
ui->label->setText( m_title->get() ); // That's get() on the TranslatedString
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
@ -58,8 +88,6 @@ NetInstallPage::readGroups( const QByteArray& yamlData )
|
||||
}
|
||||
Q_ASSERT( groups.IsSequence() );
|
||||
m_groups = new PackageModel( groups );
|
||||
CALAMARES_RETRANSLATE( m_groups->setHeaderData( 0, Qt::Horizontal, tr( "Name" ) );
|
||||
m_groups->setHeaderData( 1, Qt::Horizontal, tr( "Description" ) ); )
|
||||
return true;
|
||||
}
|
||||
catch ( YAML::Exception& e )
|
||||
@ -121,6 +149,7 @@ NetInstallPage::dataIsHere()
|
||||
return;
|
||||
}
|
||||
|
||||
retranslate(); // For changed model
|
||||
ui->groupswidget->setModel( m_groups );
|
||||
ui->groupswidget->header()->setSectionResizeMode( 0, QHeaderView::ResizeToContents );
|
||||
ui->groupswidget->header()->setSectionResizeMode( 1, QHeaderView::Stretch );
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2016, Luca Giambonini <almack@chakraos.org>
|
||||
* Copyright 2016, Lisa Vitolo <shainer@chakraos.org>
|
||||
* Copyright 2017, Kyle Robbertze <krobbertze@gmail.com>
|
||||
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
|
||||
* Copyright 2017-2018, 2020, 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
|
||||
@ -24,9 +24,13 @@
|
||||
#include "PackageModel.h"
|
||||
#include "PackageTreeItem.h"
|
||||
|
||||
#include "locale/TranslatableConfiguration.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
|
||||
#include <memory>
|
||||
|
||||
class QNetworkReply;
|
||||
|
||||
namespace Ui
|
||||
@ -39,6 +43,18 @@ class NetInstallPage : public QWidget
|
||||
Q_OBJECT
|
||||
public:
|
||||
NetInstallPage( QWidget* parent = nullptr );
|
||||
virtual ~NetInstallPage();
|
||||
|
||||
/** @brief Sets the page title
|
||||
*
|
||||
* In situations where there is more than one netinstall page,
|
||||
* or you want some explanatory title above the treeview,
|
||||
* set the page title. This page takes ownership of the
|
||||
* TranslatedString object.
|
||||
*
|
||||
* Set to nullptr to remove the title.
|
||||
*/
|
||||
void setPageTitle( CalamaresUtils::Locale::TranslatedString* );
|
||||
|
||||
void onActivate();
|
||||
|
||||
@ -63,6 +79,8 @@ public:
|
||||
public slots:
|
||||
void dataIsHere();
|
||||
|
||||
void retranslate();
|
||||
|
||||
signals:
|
||||
void checkReady( bool );
|
||||
|
||||
@ -74,6 +92,8 @@ private:
|
||||
|
||||
Ui::Page_NetInst* ui;
|
||||
|
||||
std::unique_ptr< CalamaresUtils::Locale::TranslatedString > m_title; // Above the treeview
|
||||
|
||||
QNetworkReply* m_reply;
|
||||
PackageModel* m_groups;
|
||||
bool m_required;
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Copyright 2016, Luca Giambonini <almack@chakraos.org>
|
||||
* Copyright 2016, Lisa Vitolo <shainer@chakraos.org>
|
||||
* Copyright 2017, Kyle Robbertze <krobbertze@gmail.com>
|
||||
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
|
||||
* Copyright 2017-2018, 2020, 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
|
||||
@ -34,6 +34,7 @@ NetInstallViewStep::NetInstallViewStep( QObject* parent )
|
||||
: Calamares::ViewStep( parent )
|
||||
, m_widget( new NetInstallPage() )
|
||||
, m_nextEnabled( false )
|
||||
, m_sidebarLabel( nullptr )
|
||||
{
|
||||
emit nextStatusChanged( true );
|
||||
connect( m_widget, &NetInstallPage::checkReady, this, &NetInstallViewStep::nextIsReady );
|
||||
@ -46,20 +47,14 @@ NetInstallViewStep::~NetInstallViewStep()
|
||||
{
|
||||
m_widget->deleteLater();
|
||||
}
|
||||
delete m_sidebarLabel;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
NetInstallViewStep::prettyName() const
|
||||
{
|
||||
return tr( "Package selection" );
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
NetInstallViewStep::prettyStatus() const
|
||||
{
|
||||
return m_prettyStatus;
|
||||
return m_sidebarLabel ? m_sidebarLabel->get() : tr( "Package selection" );
|
||||
}
|
||||
|
||||
|
||||
@ -128,9 +123,9 @@ NetInstallViewStep::onLeave()
|
||||
// Clear out existing operations for this module, going backwards:
|
||||
// Sometimes we remove an item, and we don't want the index to
|
||||
// fall off the end of the list.
|
||||
for ( int index = packageOperations.length() - 1; 0 <= index ; index-- )
|
||||
for ( int index = packageOperations.length() - 1; 0 <= index; index-- )
|
||||
{
|
||||
const QVariantMap op = packageOperations.at(index).toMap();
|
||||
const QVariantMap op = packageOperations.at( index ).toMap();
|
||||
if ( op.contains( "source" ) && op.value( "source" ).toString() == moduleInstanceKey().toString() )
|
||||
{
|
||||
cDebug() << Logger::SubEntry << "Removing existing operations for" << moduleInstanceKey();
|
||||
@ -178,6 +173,12 @@ NetInstallViewStep::onLeave()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NetInstallViewStep::nextIsReady( bool b )
|
||||
{
|
||||
m_nextEnabled = b;
|
||||
emit nextStatusChanged( b );
|
||||
}
|
||||
|
||||
void
|
||||
NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
@ -192,11 +193,16 @@ NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
Calamares::JobQueue::instance()->globalStorage()->insert( "groupsUrl", groupsUrl );
|
||||
m_widget->loadGroupList( groupsUrl );
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NetInstallViewStep::nextIsReady( bool b )
|
||||
{
|
||||
m_nextEnabled = b;
|
||||
emit nextStatusChanged( b );
|
||||
bool bogus = false;
|
||||
auto label = CalamaresUtils::getSubMap( configurationMap, "label", bogus );
|
||||
|
||||
if ( label.contains( "sidebar" ) )
|
||||
{
|
||||
m_sidebarLabel = new CalamaresUtils::Locale::TranslatedString( label, "sidebar" );
|
||||
}
|
||||
if ( label.contains( "title" ) )
|
||||
{
|
||||
m_widget->setPageTitle( new CalamaresUtils::Locale::TranslatedString( label, "title" ) );
|
||||
}
|
||||
}
|
||||
|
@ -20,10 +20,10 @@
|
||||
#ifndef NETINSTALLVIEWSTEP_H
|
||||
#define NETINSTALLVIEWSTEP_H
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include "DllMacro.h"
|
||||
#include "locale/TranslatableConfiguration.h"
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
@ -38,7 +38,6 @@ public:
|
||||
virtual ~NetInstallViewStep() override;
|
||||
|
||||
QString prettyName() const override;
|
||||
QString prettyStatus() const override;
|
||||
|
||||
QWidget* widget() override;
|
||||
|
||||
@ -63,8 +62,7 @@ public slots:
|
||||
private:
|
||||
NetInstallPage* m_widget;
|
||||
bool m_nextEnabled;
|
||||
QString m_prettyStatus;
|
||||
|
||||
CalamaresUtils::Locale::TranslatedString* m_sidebarLabel; // As it appears in the sidebar
|
||||
QList< Calamares::job_ptr > m_jobs;
|
||||
};
|
||||
|
||||
|
@ -21,9 +21,11 @@
|
||||
|
||||
#include "utils/Yaml.h"
|
||||
|
||||
// TODO: see headerData(), remove after 3.2.19
|
||||
#include <QCoreApplication>
|
||||
|
||||
PackageModel::PackageModel( const YAML::Node& data, QObject* parent )
|
||||
: QAbstractItemModel( parent )
|
||||
, m_columnHeadings()
|
||||
{
|
||||
m_rootItem = new PackageTreeItem();
|
||||
setupModelData( data, m_rootItem );
|
||||
@ -106,11 +108,7 @@ PackageModel::rowCount( const QModelIndex& parent ) const
|
||||
int
|
||||
PackageModel::columnCount( const QModelIndex& parent ) const
|
||||
{
|
||||
if ( parent.isValid() )
|
||||
{
|
||||
return static_cast< PackageTreeItem* >( parent.internalPointer() )->columnCount();
|
||||
}
|
||||
return m_rootItem->columnCount();
|
||||
return 2;
|
||||
}
|
||||
|
||||
QVariant
|
||||
@ -154,26 +152,6 @@ PackageModel::setData( const QModelIndex& index, const QVariant& value, int role
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
PackageModel::setHeaderData( int section, Qt::Orientation orientation, const QVariant& value, int role )
|
||||
{
|
||||
Q_UNUSED( role )
|
||||
|
||||
if ( orientation == Qt::Horizontal )
|
||||
{
|
||||
if ( m_columnHeadings.value( section ) != QVariant() )
|
||||
{
|
||||
m_columnHeadings.replace( section, value );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_columnHeadings.insert( section, value );
|
||||
}
|
||||
emit headerDataChanged( orientation, section, section );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Qt::ItemFlags
|
||||
PackageModel::flags( const QModelIndex& index ) const
|
||||
{
|
||||
@ -193,7 +171,12 @@ PackageModel::headerData( int section, Qt::Orientation orientation, int role ) c
|
||||
{
|
||||
if ( orientation == Qt::Horizontal && role == Qt::DisplayRole )
|
||||
{
|
||||
return m_columnHeadings.value( section );
|
||||
// Unusual translation call uses the existing translation from the NetInstallPage
|
||||
// class (now removed).
|
||||
//
|
||||
// TODO: after 3.2.19, change this to just tr() and push TX
|
||||
return ( section == 0 ) ? QCoreApplication::translate( "NetInstallPage", "Name" )
|
||||
: QCoreApplication::translate( "NetInstallPage", "Description" );
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -44,14 +44,15 @@ public:
|
||||
|
||||
QVariant data( const QModelIndex& index, int role ) const override;
|
||||
bool setData( const QModelIndex& index, const QVariant& value, int role = Qt::EditRole ) override;
|
||||
bool
|
||||
setHeaderData( int section, Qt::Orientation orientation, const QVariant& value, int role = Qt::EditRole ) override;
|
||||
Qt::ItemFlags flags( const QModelIndex& index ) const override;
|
||||
QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
|
||||
|
||||
QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const override;
|
||||
QModelIndex parent( const QModelIndex& index ) const override;
|
||||
|
||||
QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
|
||||
int rowCount( const QModelIndex& parent = QModelIndex() ) const override;
|
||||
int columnCount( const QModelIndex& parent = QModelIndex() ) const override;
|
||||
|
||||
PackageItemDataList getPackages() const;
|
||||
QList< PackageTreeItem* > getItemPackages( PackageTreeItem* item ) const;
|
||||
|
||||
@ -60,7 +61,6 @@ private:
|
||||
|
||||
PackageTreeItem* m_rootItem;
|
||||
QList< PackageTreeItem* > m_hiddenItems;
|
||||
QVariantList m_columnHeadings;
|
||||
};
|
||||
|
||||
#endif // PACKAGEMODEL_H
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||
*
|
||||
* Copyright (c) 2017, Kyle Robbertze <kyle@aims.ac.za>
|
||||
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
||||
* Copyright 2017, 2020, 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
|
||||
@ -105,12 +105,6 @@ PackageTreeItem::row() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
PackageTreeItem::columnCount() const
|
||||
{
|
||||
return m_columns;
|
||||
}
|
||||
|
||||
QVariant
|
||||
PackageTreeItem::data( int column ) const
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||
*
|
||||
* Copyright (c) 2017, Kyle Robbertze <kyle@aims.ac.za>
|
||||
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
||||
* Copyright 2017, 2020, 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
|
||||
@ -54,7 +54,6 @@ public:
|
||||
void appendChild( PackageTreeItem* child );
|
||||
PackageTreeItem* child( int row );
|
||||
int childCount() const;
|
||||
int columnCount() const;
|
||||
QVariant data( int column ) const override;
|
||||
int row() const;
|
||||
|
||||
@ -90,7 +89,6 @@ private:
|
||||
PackageTreeItem* m_parentItem;
|
||||
QList< PackageTreeItem* > m_childItems;
|
||||
ItemData m_data;
|
||||
const int m_columns = 2; // Name, description
|
||||
};
|
||||
|
||||
#endif // PACKAGETREEITEM_H
|
||||
|
@ -21,3 +21,17 @@
|
||||
# This only has an effect if the netinstall data cannot be retrieved,
|
||||
# or is corrupt: having "required" set, means the install cannot proceed.
|
||||
required: false
|
||||
|
||||
# To support multiple instances of this module,
|
||||
# some strings are configurable and translatable here.
|
||||
# - *sidebar* This is the name of the module in the progress-tree / sidebar
|
||||
# in Calamares.
|
||||
# - *title* This is displayed above the list of packages.
|
||||
# If no *sidebar* values are provided, defaults to "Package selection"
|
||||
# and existing translations. If no *title* values are provided, no string
|
||||
# is displayed.
|
||||
label:
|
||||
sidebar: "Package selection"
|
||||
sidebar[nl]: "Pakketkeuze"
|
||||
title: "Office Package"
|
||||
title[nl]: "Kantoorsoftware"
|
||||
|
@ -14,6 +14,16 @@
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Title of Netinstall Module</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="maximumSize">
|
||||
@ -31,7 +41,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>981</width>
|
||||
<height>434</height>
|
||||
<height>407</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
|
Loading…
Reference in New Issue
Block a user