[license] Add should-be-expanded display option to license entries

- In code, add the necessary bool
 - document meaning in the config file
 - actually expand the full text if the entry is local and set to expanding-
   by-default. This implementation is a bit lazy since it just pretends
   to click on the toggle button.
 - While here, reduce scope for UB by initializing POD members
This commit is contained in:
Adriaan de Groot 2019-11-28 13:31:16 +01:00
parent c870fca787
commit 1de6062233
4 changed files with 17 additions and 2 deletions

View File

@ -72,6 +72,7 @@ LicenseEntry::LicenseEntry( const QVariantMap& conf )
m_url = QUrl( conf[ "url" ].toString() );
m_required = CalamaresUtils::getBool( conf, "required", false );
m_expand = CalamaresUtils::getBool( conf, "expand", false );
bool ok = false;
QString typeString = conf.value( "type", "software" ).toString();

View File

@ -56,13 +56,15 @@ struct LicenseEntry
bool isValid() const { return !m_id.isEmpty(); }
bool isRequired() const { return m_required; }
bool isLocal() const;
bool expandByDefault() const { return m_expand; }
QString m_id;
QString m_prettyName;
QString m_prettyVendor;
Type m_type;
Type m_type = Type::Software;
QUrl m_url;
bool m_required;
bool m_required = false;
bool m_expand = false;
};
class LicensePage : public QWidget

View File

@ -98,6 +98,13 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent )
vLayout->addWidget( m_fullText );
setLayout( vLayout );
if ( m_entry.expandByDefault() )
{
// Since we started in a collapsed state, toggle it to expand.
// This can only be done once the full text has been added.
expandClicked();
}
}
else
{

View File

@ -14,6 +14,10 @@
# to the URL is provided, which opens in the default web browser. A local
# URL (i.e. file:///) assumes that the contents are HTML or plain text, and
# displays the license in-line. YAML: string, mandatory.
# - expand A boolean value only relevant for **local** URLs. If true,
# the license text is displayed in "expanded" form by
# default, rather than requiring the user to first open it up.
# YAML: boolean, optional, default is false.
entries:
- id: nvidia
name: Nvidia
@ -43,3 +47,4 @@ entries:
type: software
required: true
url: file:../LICENSE
expand: true