[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.
main
Adriaan de Groot 5 years ago
parent 8f1ab99190
commit 862b05221d

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

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

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

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

Loading…
Cancel
Save