[libcalamaresui] Drop 'name' parameter in QmlViewStep

- The name is just the module identifier, and now we
  search for *m@i* and also *m* from that identifier,
  the name becomes much less important -- and it
  can be set from the config key *qmlFilename* as well.
This commit is contained in:
Adriaan de Groot 2020-03-11 15:57:08 +01:00
parent 8f1ab99190
commit 862b05221d
4 changed files with 12 additions and 15 deletions

View File

@ -101,9 +101,8 @@ registerCalamaresModels()
namespace Calamares namespace Calamares
{ {
QmlViewStep::QmlViewStep( const QString& name, QObject* parent ) QmlViewStep::QmlViewStep( QObject* parent )
: ViewStep( parent ) : ViewStep( parent )
, m_name( name )
, m_widget( new QWidget ) , m_widget( new QWidget )
, m_spinner( new WaitingWidget( tr( "Loading ..." ) ) ) , m_spinner( new WaitingWidget( tr( "Loading ..." ) ) )
, m_qmlWidget( new QQuickWidget ) , m_qmlWidget( new QQuickWidget )
@ -126,7 +125,7 @@ QString
QmlViewStep::prettyName() const QmlViewStep::prettyName() const
{ {
// TODO: query the QML itself // TODO: query the QML itself
return tr( "QML Step <i>%1</i>." ).arg( m_name ); return tr( "QML Step <i>%1</i>." ).arg( moduleInstanceKey().module() );
} }
@ -251,14 +250,14 @@ QmlViewStep::showQml()
* is badly configured). * is badly configured).
*/ */
QString QString
searchQmlFile( QmlViewStep::QmlSearch method, const QString& configuredName, const QString& moduleName, const Calamares::ModuleSystem::InstanceKey& i ) searchQmlFile( QmlViewStep::QmlSearch method, const QString& configuredName, const Calamares::ModuleSystem::InstanceKey& i )
{ {
using QmlSearch = Calamares::QmlViewStep::QmlSearch; using QmlSearch = Calamares::QmlViewStep::QmlSearch;
QString bPath( QStringLiteral( "%1/%2.qml" ) ); QString bPath( QStringLiteral( "%1/%2.qml" ) );
QString qrPath( QStringLiteral( ":/%1.qml" ) ); QString qrPath( QStringLiteral( ":/%1.qml" ) );
cDebug() << "Looking for QML for" << moduleName; cDebug() << "Looking for QML for" << i.toString();
QStringList candidates; QStringList candidates;
if ( configuredName.startsWith( '/' ) ) if ( configuredName.startsWith( '/' ) )
{ {
@ -269,14 +268,12 @@ searchQmlFile( QmlViewStep::QmlSearch method, const QString& configuredName, con
QString brandDir = Calamares::Branding::instance()->componentDirectory(); QString brandDir = Calamares::Branding::instance()->componentDirectory();
candidates << ( configuredName.isEmpty() ? QString() candidates << ( configuredName.isEmpty() ? QString()
: bPath.arg( brandDir, configuredName ) ) : bPath.arg( brandDir, configuredName ) )
<< ( moduleName.isEmpty() ? QString() : bPath.arg( brandDir, moduleName ) )
<< bPath.arg( brandDir, i.toString() ) << bPath.arg( brandDir, i.toString() )
<< bPath.arg( brandDir, i.module() ); << bPath.arg( brandDir, i.module() );
} }
if ( ( method == QmlSearch::Both ) || ( method == QmlSearch::QrcOnly ) ) if ( ( method == QmlSearch::Both ) || ( method == QmlSearch::QrcOnly ) )
{ {
candidates << ( configuredName.isEmpty() ? QString() : qrPath.arg( configuredName ) ) candidates << ( configuredName.isEmpty() ? QString() : qrPath.arg( configuredName ) )
<< ( moduleName.isEmpty() ? QString() : qrPath.arg( moduleName ) )
<< qrPath.arg( i.toString() ) << qrPath.arg( i.toString() )
<< qrPath.arg( i.module() ); << qrPath.arg( i.module() );
} }
@ -315,7 +312,7 @@ QmlViewStep::setConfigurationMap( const QVariantMap& configurationMap )
QString qmlFile = CalamaresUtils::getString( configurationMap, "qmlFilename" ); QString qmlFile = CalamaresUtils::getString( configurationMap, "qmlFilename" );
if ( !m_qmlComponent ) if ( !m_qmlComponent )
{ {
m_qmlFileName = searchQmlFile( m_searchMethod, qmlFile, m_name, moduleInstanceKey() ); m_qmlFileName = searchQmlFile( m_searchMethod, qmlFile, moduleInstanceKey() );
QObject* config = this->getConfig(); QObject* config = this->getConfig();
if ( config ) if ( config )

View File

@ -49,12 +49,12 @@ public:
/** @brief Creates a QML view step /** @brief Creates a QML view step
* *
* The name should not have an extension or schema or anything; * The search behavior for the actial QML depends on a QmlSearch value.
* just the plain name, which will be searched as "/<name>.qml" in * This is set through common configuration key *qmlSearch*.
* QRC files, or "<name>.qml" in suitable branding paths. * The filename used comes from the module identifier, or can be
* The search behavior depends on a QmlSearch value. * set in the configuration file through *qmlFilename*.
*/ */
QmlViewStep( const QString& name, QObject* parent = nullptr ); QmlViewStep( QObject* parent = nullptr );
virtual ~QmlViewStep() override; virtual ~QmlViewStep() override;
virtual QString prettyName() const override; virtual QString prettyName() const override;

View File

@ -22,7 +22,7 @@
#include <QVariant> #include <QVariant>
NotesQmlViewStep::NotesQmlViewStep( QObject* parent ) NotesQmlViewStep::NotesQmlViewStep( QObject* parent )
: Calamares::QmlViewStep( "notesqml", parent ) : Calamares::QmlViewStep( parent )
{ {
} }

View File

@ -40,7 +40,7 @@
CALAMARES_PLUGIN_FACTORY_DEFINITION( WelcomeQmlViewStepFactory, registerPlugin< WelcomeQmlViewStep >(); ) CALAMARES_PLUGIN_FACTORY_DEFINITION( WelcomeQmlViewStepFactory, registerPlugin< WelcomeQmlViewStep >(); )
WelcomeQmlViewStep::WelcomeQmlViewStep( QObject* parent ) WelcomeQmlViewStep::WelcomeQmlViewStep( QObject* parent )
: Calamares::QmlViewStep("welcomeq", parent ) : Calamares::QmlViewStep(parent )
, m_config( new Config( ) ) // the qml singleton takes ownership and deletes it , m_config( new Config( ) ) // the qml singleton takes ownership and deletes it
// , m_nextEnabled( false ) // , m_nextEnabled( false )
, m_requirementsChecker( new GeneralRequirements( this ) ) , m_requirementsChecker( new GeneralRequirements( this ) )