mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-24 19:05:46 -05:00
[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
3 changed files with 40 additions and 0 deletions
|
@ -44,6 +44,8 @@ handle_args( CalamaresApplication& a )
|
|||
"Verbose output for debugging purposes (0-8).", "level" );
|
||||
QCommandLineOption configOption( QStringList{ "c", "config"},
|
||||
"Configuration directory to use, for testing purposes.", "config" );
|
||||
QCommandLineOption xdgOption( QStringList{"X", "xdg-config"},
|
||||
"Use XDG_{CONFIG,DATA}_DIRS as well." );
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription( "Distribution-independent installer framework" );
|
||||
|
@ -53,6 +55,7 @@ handle_args( CalamaresApplication& a )
|
|||
parser.addOption( debugOption );
|
||||
parser.addOption( debugLevelOption );
|
||||
parser.addOption( configOption );
|
||||
parser.addOption( xdgOption );
|
||||
|
||||
parser.process( a );
|
||||
|
||||
|
@ -72,6 +75,8 @@ handle_args( CalamaresApplication& a )
|
|||
}
|
||||
if ( parser.isSet( configOption ) )
|
||||
CalamaresUtils::setAppDataDir( QDir( parser.value( configOption ) ) );
|
||||
if ( parser.isSet( xdgOption ) )
|
||||
CalamaresUtils::setXdgDirs();
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -49,6 +49,9 @@ static QTranslator* s_brandingTranslator = nullptr;
|
|||
static QTranslator* s_translator = nullptr;
|
||||
static QString s_translatorLocaleName;
|
||||
|
||||
static bool s_haveExtraDirs = false;
|
||||
static QStringList s_extraConfigDirs;
|
||||
static QStringList s_extraDataDirs;
|
||||
|
||||
static bool
|
||||
isWritableDir( const QDir& dir )
|
||||
|
@ -94,6 +97,31 @@ setAppDataDir( const QDir& dir )
|
|||
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
|
||||
isAppDataDirOverridden()
|
||||
|
|
|
@ -79,6 +79,13 @@ namespace CalamaresUtils
|
|||
|
||||
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
|
||||
* alternative forms and digraphs.
|
||||
|
|
Loading…
Add table
Reference in a new issue