mirror of
https://github.com/parchlinux/calamares.git
synced 2025-07-03 04:15:37 -04:00
[calamares] Refactor searching for QML dir
- Split collecting the search paths into separate function - Don't fall back on the current directory
This commit is contained in:
parent
f118fd73bc
commit
3329f2ea55
1 changed files with 40 additions and 45 deletions
|
@ -133,60 +133,55 @@ CalamaresApplication::mainWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static QStringList
|
||||||
|
qmlDirCandidates( bool assumeBuilddir )
|
||||||
|
{
|
||||||
|
static const char QML[] = "qml";
|
||||||
|
|
||||||
|
QStringList qmlDirs;
|
||||||
|
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||||
|
qmlDirs << CalamaresUtils::appDataDir().absoluteFilePath( QML );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( assumeBuilddir )
|
||||||
|
qmlDirs << QDir::current().absoluteFilePath( "src/qml" ); // In build-dir
|
||||||
|
qmlDirs << CalamaresUtils::appDataDir().absoluteFilePath( QML );
|
||||||
|
}
|
||||||
|
|
||||||
|
return qmlDirs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CalamaresApplication::initQmlPath()
|
CalamaresApplication::initQmlPath()
|
||||||
{
|
{
|
||||||
QDir importPath;
|
QDir importPath; // Right now, current-dir
|
||||||
|
QStringList qmlDirCandidatesByPriority = qmlDirCandidates( isDebug() );
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
QString subpath( "qml" );
|
foreach ( const QString& path, qmlDirCandidatesByPriority )
|
||||||
|
|
||||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
|
||||||
{
|
{
|
||||||
importPath = QDir( CalamaresUtils::appDataDir()
|
QDir dir( path );
|
||||||
.absoluteFilePath( subpath ) );
|
if ( dir.exists() && dir.isReadable() )
|
||||||
if ( !importPath.exists() || !importPath.isReadable() )
|
|
||||||
{
|
{
|
||||||
cError() << "FATAL: explicitly configured application data directory"
|
importPath = dir;
|
||||||
<< CalamaresUtils::appDataDir().absolutePath()
|
found = true;
|
||||||
<< "does not contain a valid QML modules directory at"
|
break;
|
||||||
<< importPath.absolutePath()
|
|
||||||
<< "\nCowardly refusing to continue startup without the QML directory.";
|
|
||||||
::exit( EXIT_FAILURE );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QStringList qmlDirCandidatesByPriority;
|
|
||||||
if ( isDebug() )
|
|
||||||
{
|
|
||||||
qmlDirCandidatesByPriority.append(
|
|
||||||
QDir::current().absoluteFilePath(
|
|
||||||
QString( "src/%1" )
|
|
||||||
.arg( subpath ) ) );
|
|
||||||
}
|
|
||||||
qmlDirCandidatesByPriority.append( CalamaresUtils::appDataDir()
|
|
||||||
.absoluteFilePath( subpath ) );
|
|
||||||
|
|
||||||
foreach ( const QString& path, qmlDirCandidatesByPriority )
|
|
||||||
{
|
|
||||||
QDir dir( path );
|
|
||||||
if ( dir.exists() && dir.isReadable() )
|
|
||||||
{
|
|
||||||
importPath = dir;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !importPath.exists() || !importPath.isReadable() )
|
|
||||||
{
|
|
||||||
cError() << "FATAL: none of the expected QML paths ("
|
|
||||||
<< qmlDirCandidatesByPriority.join( ", " )
|
|
||||||
<< ") exist."
|
|
||||||
<< "\nCowardly refusing to continue startup without the QML directory.";
|
|
||||||
::exit( EXIT_FAILURE );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !found || !importPath.exists() || !importPath.isReadable() )
|
||||||
|
{
|
||||||
|
cError() << "Cowardly refusing to continue startup without a QML directory."
|
||||||
|
<< Logger::DebugList( qmlDirCandidatesByPriority );
|
||||||
|
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||||
|
cError() << "FATAL: explicitly configured application data directory is missing qml/";
|
||||||
|
else
|
||||||
|
cError() << "FATAL: none of the expected QML paths exist.";
|
||||||
|
::exit( EXIT_FAILURE );
|
||||||
|
}
|
||||||
|
|
||||||
|
cDebug() << "Using Calamares QML directory" << importPath.absolutePath();
|
||||||
CalamaresUtils::setQmlModulesDir( importPath );
|
CalamaresUtils::setQmlModulesDir( importPath );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue