[calamares] Add option to obey XDG dirs
- Prep-work for #941 - This does nothing, yet, just sets the stage for using XDG_CONFIG_DIRS and XDG_DATA_DIRS as well as the regular directories.
This commit is contained in:
parent
4a2ca8bb77
commit
c489320af5
@ -44,6 +44,8 @@ handle_args( CalamaresApplication& a )
|
|||||||
"Verbose output for debugging purposes (0-8).", "level" );
|
"Verbose output for debugging purposes (0-8).", "level" );
|
||||||
QCommandLineOption configOption( QStringList{ "c", "config"},
|
QCommandLineOption configOption( QStringList{ "c", "config"},
|
||||||
"Configuration directory to use, for testing purposes.", "config" );
|
"Configuration directory to use, for testing purposes.", "config" );
|
||||||
|
QCommandLineOption xdgOption( QStringList{"X", "xdg-config"},
|
||||||
|
"Use XDG_{CONFIG,DATA}_DIRS as well." );
|
||||||
|
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
parser.setApplicationDescription( "Distribution-independent installer framework" );
|
parser.setApplicationDescription( "Distribution-independent installer framework" );
|
||||||
@ -53,6 +55,7 @@ handle_args( CalamaresApplication& a )
|
|||||||
parser.addOption( debugOption );
|
parser.addOption( debugOption );
|
||||||
parser.addOption( debugLevelOption );
|
parser.addOption( debugLevelOption );
|
||||||
parser.addOption( configOption );
|
parser.addOption( configOption );
|
||||||
|
parser.addOption( xdgOption );
|
||||||
|
|
||||||
parser.process( a );
|
parser.process( a );
|
||||||
|
|
||||||
@ -72,6 +75,8 @@ handle_args( CalamaresApplication& a )
|
|||||||
}
|
}
|
||||||
if ( parser.isSet( configOption ) )
|
if ( parser.isSet( configOption ) )
|
||||||
CalamaresUtils::setAppDataDir( QDir( parser.value( configOption ) ) );
|
CalamaresUtils::setAppDataDir( QDir( parser.value( configOption ) ) );
|
||||||
|
if ( parser.isSet( xdgOption ) )
|
||||||
|
CalamaresUtils::setXdgDirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -49,6 +49,9 @@ static QTranslator* s_brandingTranslator = nullptr;
|
|||||||
static QTranslator* s_translator = nullptr;
|
static QTranslator* s_translator = nullptr;
|
||||||
static QString s_translatorLocaleName;
|
static QString s_translatorLocaleName;
|
||||||
|
|
||||||
|
static bool s_haveExtraDirs = false;
|
||||||
|
static QStringList s_extraConfigDirs;
|
||||||
|
static QStringList s_extraDataDirs;
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
isWritableDir( const QDir& dir )
|
isWritableDir( const QDir& dir )
|
||||||
@ -94,6 +97,31 @@ setAppDataDir( const QDir& dir )
|
|||||||
s_isAppDataDirOverridden = true;
|
s_isAppDataDirOverridden = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setXdgDirs()
|
||||||
|
{
|
||||||
|
s_haveExtraDirs = true;
|
||||||
|
s_extraConfigDirs.append( QString( qgetenv( "XDG_CONFIG_DIRS" ) ).split(':') );
|
||||||
|
s_extraDataDirs.append( QString( qgetenv( "XDG_DATA_DIRS" ) ).split(':') );
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList
|
||||||
|
extraConfigDirs()
|
||||||
|
{
|
||||||
|
if ( s_haveExtraDirs )
|
||||||
|
return s_extraConfigDirs;
|
||||||
|
return QStringList();
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList
|
||||||
|
extraDataDirs()
|
||||||
|
{
|
||||||
|
if ( s_haveExtraDirs )
|
||||||
|
return s_extraDataDirs;
|
||||||
|
return QStringList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isAppDataDirOverridden()
|
isAppDataDirOverridden()
|
||||||
|
@ -79,6 +79,13 @@ namespace CalamaresUtils
|
|||||||
|
|
||||||
DLLEXPORT void setQmlModulesDir( const QDir& dir );
|
DLLEXPORT void setQmlModulesDir( const QDir& dir );
|
||||||
|
|
||||||
|
/** @brief Setup extra config and data dirs from the XDG variables.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
DLLEXPORT void setXdgDirs();
|
||||||
|
DLLEXPORT QStringList extraConfigDirs();
|
||||||
|
DLLEXPORT QStringList extraDataDirs();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief removeDiacritics replaces letters with diacritics and ligatures with
|
* @brief removeDiacritics replaces letters with diacritics and ligatures with
|
||||||
* alternative forms and digraphs.
|
* alternative forms and digraphs.
|
||||||
|
Loading…
Reference in New Issue
Block a user