mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-02-04 11:09:58 +01:00
Ajout de l'option --lang-dir pour redefinir le dossier contenant les fichiers de langue
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@378 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
|
||||
QString QETApp::common_elements_dir = QString();
|
||||
QString QETApp::config_dir = QString();
|
||||
QString QETApp::lang_dir = QString();
|
||||
QString QETApp::diagram_texts_font = QString();
|
||||
RecentFiles *QETApp::projects_recent_files_ = 0;
|
||||
RecentFiles *QETApp::elements_recent_files_ = 0;
|
||||
@@ -337,15 +338,31 @@ void QETApp::overrideConfigDir(const QString &new_cd) {
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
Redefinit le chemin du dossier contenant les fichiers de langue
|
||||
@param new_ld Nouveau chemin du dossier contenant les fichiers de langue
|
||||
*/
|
||||
void QETApp::overrideLangDir(const QString &new_ld) {
|
||||
QFileInfo new_ld_info(new_ld);
|
||||
if (new_ld_info.isDir()) {
|
||||
lang_dir = new_ld_info.absoluteFilePath();
|
||||
if (!lang_dir.endsWith("/")) lang_dir += "/";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@return Le chemin du dossier contenant les fichiers de langue
|
||||
*/
|
||||
QString QETApp::languagesPath() {
|
||||
if (!lang_dir.isEmpty()) {
|
||||
return(lang_dir);
|
||||
} else {
|
||||
#ifndef QET_LANG_PATH
|
||||
return(QDir::current().path() + "/lang/");
|
||||
#else
|
||||
return(QUOTE(QET_LANG_PATH));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -603,6 +620,10 @@ void QETApp::parseArguments() {
|
||||
}
|
||||
#endif
|
||||
|
||||
if (qet_arguments_.langDirSpecified()) {
|
||||
overrideLangDir(qet_arguments_.langDir());
|
||||
}
|
||||
|
||||
if (qet_arguments_.printLicenseRequested()) {
|
||||
printLicense();
|
||||
non_interactive_execution_ = true;
|
||||
@@ -827,6 +848,7 @@ void QETApp::printHelp() {
|
||||
#ifdef QET_ALLOW_OVERRIDE_CD_OPTION
|
||||
+ tr(" --config-dir=DIR Definir le dossier de configuration\n")
|
||||
#endif
|
||||
+ tr(" --lang-dir=DIR Definir le dossier contenant les fichiers de langue\n")
|
||||
);
|
||||
std::cout << qPrintable(help) << std::endl;
|
||||
}
|
||||
|
||||
@@ -72,6 +72,8 @@ class QETApp : public QETSingleApplication {
|
||||
static QString config_dir; ///< Dossier contenant la configuration et la collection d'elements de l'utilisateur
|
||||
#endif
|
||||
public:
|
||||
static void overrideLangDir(const QString &);
|
||||
static QString lang_dir; ///< Dossier contenant les fichiers de langue
|
||||
static QString diagramTextsFont();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -59,6 +59,7 @@ QETArguments::QETArguments(const QETArguments &qet_arguments) :
|
||||
#ifdef QET_ALLOW_OVERRIDE_CD_OPTION
|
||||
config_dir_(qet_arguments.config_dir_),
|
||||
#endif
|
||||
lang_dir_(qet_arguments.lang_dir_),
|
||||
print_help_(qet_arguments.print_help_),
|
||||
print_license_(qet_arguments.print_license_),
|
||||
print_version_(qet_arguments.print_version_)
|
||||
@@ -80,6 +81,7 @@ QETArguments &QETArguments::operator=(const QETArguments &qet_arguments) {
|
||||
#ifdef QET_ALLOW_OVERRIDE_CD_OPTION
|
||||
config_dir_ = qet_arguments.config_dir_;
|
||||
#endif
|
||||
lang_dir_ = qet_arguments.lang_dir_;
|
||||
print_help_ = qet_arguments.print_help_;
|
||||
print_license_ = qet_arguments.print_license_;
|
||||
print_version_ = qet_arguments.print_version_;
|
||||
@@ -199,7 +201,8 @@ void QETArguments::handleFileArgument(const QString &file) {
|
||||
Gere les arguments correspondant potentiellement a une option.
|
||||
Les options reconnues sont :
|
||||
* --common-elements-dir=
|
||||
* --config-dir
|
||||
* --config-dir=
|
||||
* --lang-dir=
|
||||
* --help
|
||||
* --version
|
||||
* -v
|
||||
@@ -237,6 +240,12 @@ void QETArguments::handleOptionArgument(const QString &option) {
|
||||
|
||||
#endif
|
||||
|
||||
QString ld_arg("--lang-dir=");
|
||||
if (option.startsWith(ld_arg)) {
|
||||
lang_dir_ = option.mid(ld_arg.length());
|
||||
return;
|
||||
}
|
||||
|
||||
// a ce stade, l'option est inconnue
|
||||
unknown_options_ << option;
|
||||
}
|
||||
@@ -276,6 +285,21 @@ QString QETArguments::configDir() const {
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
@return true si l'utilisateur a specifie un dossier pour les fichiers de langue
|
||||
*/
|
||||
bool QETArguments::langDirSpecified() const {
|
||||
return(!lang_dir_.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@return le dossier de langue specifie par l'utilisateur.
|
||||
Si l'utilisateur n'en a pas specifie, une chaine vide est retournee.
|
||||
*/
|
||||
QString QETArguments::langDir() const {
|
||||
return(lang_dir_);
|
||||
}
|
||||
|
||||
/**
|
||||
@return true si les arguments comportent une demande d'affichage de l'aide,
|
||||
false sinon
|
||||
|
||||
@@ -50,6 +50,8 @@ class QETArguments : public QObject {
|
||||
virtual bool configDirSpecified() const;
|
||||
virtual QString configDir() const;
|
||||
#endif
|
||||
virtual bool langDirSpecified() const;
|
||||
virtual QString langDir() const;
|
||||
virtual bool printHelpRequested() const;
|
||||
virtual bool printLicenseRequested() const;
|
||||
virtual bool printVersionRequested() const;
|
||||
@@ -74,6 +76,7 @@ class QETArguments : public QObject {
|
||||
#ifdef QET_ALLOW_OVERRIDE_CD_OPTION
|
||||
QString config_dir_;
|
||||
#endif
|
||||
QString lang_dir_;
|
||||
bool print_help_;
|
||||
bool print_license_;
|
||||
bool print_version_;
|
||||
|
||||
Reference in New Issue
Block a user