mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
add commandline-parameter "--data-dir"
This commit is contained in:
parent
e9d2c13630
commit
d971da5ac7
@ -5,7 +5,10 @@ set current_dir=%~dp0
|
||||
cd /d %current_dir%
|
||||
|
||||
rem lance QElectroTech
|
||||
rem Sans option --config-dir, la configuration de QElectroTech ainsi que la
|
||||
rem collection d'elements perso seront dans "%APPDATA%\qet"
|
||||
rem Sans option --config-dir, la configuration de QElectroTech seront dans
|
||||
rem "C:/Users/<USER>/AppData/Local/QElectroTech/QElectroTech"
|
||||
rem Sans l'option --data-dir, les données utilisateur (elements, titleblocks,
|
||||
rem log, ...) de QElectroTech sont stockées dans
|
||||
rem "C:/Users/<USER>/AppData/Roaming/QElectroTech/QElectroTech"
|
||||
set command=bin\qelectrotech.exe --common-elements-dir=elements/ --common-tbt-dir=titleblocks/ --lang-dir=lang/ -style windowsvista %*
|
||||
@start %command%
|
||||
|
@ -25,5 +25,8 @@ add_definitions(-DQET_ALLOW_OVERRIDE_CTBTD_OPTION)
|
||||
# Comment the line below to deactivate the --config-dir option
|
||||
add_definitions(-DQET_ALLOW_OVERRIDE_CD_OPTION)
|
||||
|
||||
# Comment the line below to deactivate the --data-dir option
|
||||
add_definitions(-DQET_ALLOW_OVERRIDE_DD_OPTION)
|
||||
|
||||
#comment the line below to disable the project database export
|
||||
#add_definitions(-DQET_EXPORT_PROJECT_DB) #error Todo
|
||||
|
@ -8,5 +8,5 @@ rem Met la collection QET en lecture seule
|
||||
attrib +r elements/* /S /D
|
||||
|
||||
rem lance QElectroTech
|
||||
set command=bin\qelectrotech.exe -platform windows:fontengine=freetype --common-elements-dir=elements/ --common-tbt-dir=titleblocks/ --lang-dir=lang/ --config-dir=conf/ -style plastique %*
|
||||
set command=bin\qelectrotech.exe -platform windows:fontengine=freetype --common-elements-dir=elements/ --common-tbt-dir=titleblocks/ --lang-dir=lang/ --config-dir=conf/ --data-dir=conf/ -style plastique %*
|
||||
@start %command%
|
||||
|
@ -7,6 +7,7 @@ QET_EXE=$(readlink -f "${current_dir}/../qelectrotech")
|
||||
QET_ELEMENTS_DIR=$(readlink -f "${current_dir}/../elements/")
|
||||
QET_TBT_DIR=$(readlink -f "${current_dir}/../titleblocks/")
|
||||
QET_CONFIG_DIR=""
|
||||
QET_DATA_DIR=""
|
||||
QET_LANG_DIR=$(readlink -f "${current_dir}/../lang/")
|
||||
# REDEFINE_LANG="es"
|
||||
|
||||
@ -31,6 +32,10 @@ if [ -d "${QET_CONFIG_DIR}" ]; then
|
||||
OPTIONS="${OPTIONS} --config-dir=${QET_CONFIG_DIR}"
|
||||
fi
|
||||
|
||||
if [ -d "${QET_DATA_DIR}" ]; then
|
||||
OPTIONS="${OPTIONS} --data-dir=${QET_DATA_DIR}"
|
||||
fi
|
||||
|
||||
if [ -d "${QET_LANG_DIR}" ]; then
|
||||
OPTIONS="${OPTIONS} --lang-dir=${QET_LANG_DIR}"
|
||||
fi
|
||||
|
@ -57,6 +57,9 @@ DEFINES += QET_ALLOW_OVERRIDE_CTBTD_OPTION
|
||||
# Commenter la ligne ci-dessous pour desactiver l'option --config-dir
|
||||
DEFINES += QET_ALLOW_OVERRIDE_CD_OPTION
|
||||
|
||||
# Commenter la ligne ci-dessous pour desactiver l'option --data-dir
|
||||
DEFINES += QET_ALLOW_OVERRIDE_DD_OPTION
|
||||
|
||||
#comment the line below to disable the project database export
|
||||
DEFINES += QET_EXPORT_PROJECT_DB
|
||||
|
||||
|
@ -62,6 +62,10 @@ QString QETApp::common_tbt_dir_ = QString();
|
||||
QString QETApp::config_dir = QString();
|
||||
#endif
|
||||
|
||||
#ifdef QET_ALLOW_OVERRIDE_DD_OPTION
|
||||
QString QETApp::data_dir = QString();
|
||||
#endif
|
||||
|
||||
QString QETApp::lang_dir = QString();
|
||||
TitleBlockTemplatesFilesCollection *QETApp::m_common_tbt_collection;
|
||||
TitleBlockTemplatesFilesCollection *QETApp::m_company_tbt_collection;
|
||||
@ -842,7 +846,7 @@ QString QETApp::configDir()
|
||||
if (config_dir != QString()) return(config_dir);
|
||||
#endif
|
||||
QString configdir = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
|
||||
if (configdir.endsWith('/')) {
|
||||
while (configdir.endsWith('/')) {
|
||||
configdir.remove(configdir.length()-1, 1);
|
||||
}
|
||||
return configdir;
|
||||
@ -862,8 +866,11 @@ QString QETApp::configDir()
|
||||
*/
|
||||
QString QETApp::dataDir()
|
||||
{
|
||||
#ifdef QET_ALLOW_OVERRIDE_DD_OPTION
|
||||
if (data_dir != QString()) return(data_dir);
|
||||
#endif
|
||||
QString datadir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||
if (datadir.endsWith('/')) {
|
||||
while (datadir.endsWith('/')) {
|
||||
datadir.remove(datadir.length()-1, 1);
|
||||
}
|
||||
return datadir;
|
||||
@ -882,7 +889,7 @@ QString QETApp::dataDir()
|
||||
QString QETApp::documentDir()
|
||||
{
|
||||
QString docdir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
|
||||
if (docdir.endsWith('/')) {
|
||||
while (docdir.endsWith('/')) {
|
||||
docdir.remove(docdir.length()-1, 1);
|
||||
}
|
||||
return docdir;
|
||||
@ -901,7 +908,7 @@ QString QETApp::documentDir()
|
||||
QString QETApp::pictureDir()
|
||||
{
|
||||
QString picturedir = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
|
||||
if (picturedir.endsWith('/')) {
|
||||
while (picturedir.endsWith('/')) {
|
||||
picturedir.remove(picturedir.length()-1, 1);
|
||||
}
|
||||
return picturedir;
|
||||
@ -1114,7 +1121,32 @@ void QETApp::overrideConfigDir(const QString &new_cd) {
|
||||
QFileInfo new_cd_info(new_cd);
|
||||
if (new_cd_info.isDir()) {
|
||||
config_dir = new_cd_info.absoluteFilePath();
|
||||
if (!config_dir.endsWith("/")) config_dir += "/";
|
||||
// directory entries always without trailing slash
|
||||
while (config_dir.endsWith('/')) {
|
||||
config_dir.remove(config_dir.length()-1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef QET_ALLOW_OVERRIDE_DD_OPTION
|
||||
/**
|
||||
@brief QETApp::overrideDataDir
|
||||
Redefines the path of the data folder
|
||||
\~French Redefinit le chemin du dossier de data
|
||||
\~ @param new_dd :
|
||||
New path to data folder
|
||||
\~French Nouveau chemin du dossier de data
|
||||
*/
|
||||
void QETApp::overrideDataDir(const QString &new_dd) {
|
||||
QFileInfo new_dd_info(new_dd);
|
||||
if (new_dd_info.isDir()) {
|
||||
data_dir = new_dd_info.absoluteFilePath();
|
||||
// directory entries always without trailing slash
|
||||
while (data_dir.endsWith('/')) {
|
||||
data_dir.remove(data_dir.length()-1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1944,6 +1976,7 @@ QList<QWidget *> QETApp::floatingToolbarsAndDocksForMainWindow(
|
||||
Parse the following arguments:
|
||||
- --common-elements-dir=
|
||||
- --config-dir
|
||||
- --data-dir
|
||||
- --help
|
||||
- --version
|
||||
- -v
|
||||
@ -1956,6 +1989,7 @@ QList<QWidget *> QETApp::floatingToolbarsAndDocksForMainWindow(
|
||||
Parse les arguments suivants :
|
||||
- --common-elements-dir=
|
||||
- --config-dir
|
||||
- --data-dir
|
||||
- --help
|
||||
- --version
|
||||
- -v
|
||||
@ -1995,6 +2029,11 @@ void QETApp::parseArguments()
|
||||
overrideConfigDir(qet_arguments_.configDir());
|
||||
}
|
||||
#endif
|
||||
#ifdef QET_ALLOW_OVERRIDE_DD_OPTION
|
||||
if (qet_arguments_.dataDirSpecified()) {
|
||||
overrideDataDir(qet_arguments_.dataDir());
|
||||
}
|
||||
#endif
|
||||
|
||||
if (qet_arguments_.langDirSpecified()) {
|
||||
overrideLangDir(qet_arguments_.langDir());
|
||||
@ -2496,6 +2535,9 @@ void QETApp::printHelp()
|
||||
#endif
|
||||
#ifdef QET_ALLOW_OVERRIDE_CD_OPTION
|
||||
+ tr(" --config-dir=DIR Definir le dossier de configuration\n")
|
||||
#endif
|
||||
#ifdef QET_ALLOW_OVERRIDE_DD_OPTION
|
||||
+ tr(" --data-dir=DIR Definir le dossier de data\n")
|
||||
#endif
|
||||
+ tr(" --lang-dir=DIR Definir le dossier contenant les fichiers de langue\n")
|
||||
);
|
||||
|
@ -143,6 +143,18 @@ class QETApp : public QObject
|
||||
static QString config_dir;
|
||||
#endif
|
||||
|
||||
#ifdef QET_ALLOW_OVERRIDE_DD_OPTION
|
||||
public:
|
||||
static void overrideDataDir(const QString &);
|
||||
private:
|
||||
/**
|
||||
@brief data_dir
|
||||
Directory containing the users data
|
||||
and the custom elements collection
|
||||
*/
|
||||
static QString data_dir;
|
||||
#endif
|
||||
|
||||
public:
|
||||
static void overrideLangDir(const QString &);
|
||||
/**
|
||||
|
@ -63,6 +63,9 @@ common_tbt_dir_(qet_arguments.common_tbt_dir_),
|
||||
#endif
|
||||
#ifdef QET_ALLOW_OVERRIDE_CD_OPTION
|
||||
config_dir_(qet_arguments.config_dir_),
|
||||
#endif
|
||||
#ifdef QET_ALLOW_OVERRIDE_DD_OPTION
|
||||
data_dir_(qet_arguments.data_dir_),
|
||||
#endif
|
||||
lang_dir_(qet_arguments.lang_dir_),
|
||||
print_help_(qet_arguments.print_help_),
|
||||
@ -89,6 +92,9 @@ QETArguments &QETArguments::operator=(const QETArguments &qet_arguments) {
|
||||
#endif
|
||||
#ifdef QET_ALLOW_OVERRIDE_CD_OPTION
|
||||
config_dir_ = qet_arguments.config_dir_;
|
||||
#endif
|
||||
#ifdef QET_ALLOW_OVERRIDE_DD_OPTION
|
||||
data_dir_ = qet_arguments.data_dir_;
|
||||
#endif
|
||||
lang_dir_ = qet_arguments.lang_dir_;
|
||||
print_help_ = qet_arguments.print_help_;
|
||||
@ -190,6 +196,9 @@ void QETArguments::clear()
|
||||
#ifdef QET_ALLOW_OVERRIDE_CD_OPTION
|
||||
config_dir_.clear();
|
||||
#endif
|
||||
#ifdef QET_ALLOW_OVERRIDE_DD_OPTION
|
||||
data_dir_.clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@ -239,6 +248,7 @@ void QETArguments::handleFileArgument(const QString &file) {
|
||||
* --common-elements-dir=
|
||||
* --common-tbt-dir
|
||||
* --config-dir=
|
||||
* --data-dir=
|
||||
* --lang-dir=
|
||||
* --help
|
||||
* --version
|
||||
@ -266,7 +276,6 @@ void QETArguments::handleOptionArgument(const QString &option) {
|
||||
common_elements_dir_ = option.mid(ced_arg.length());
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef QET_ALLOW_OVERRIDE_CTBTD_OPTION
|
||||
QString ctbtd_arg("--common-tbt-dir=");
|
||||
@ -281,7 +290,13 @@ void QETArguments::handleOptionArgument(const QString &option) {
|
||||
config_dir_ = option.mid(cd_arg.length());
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef QET_ALLOW_OVERRIDE_DD_OPTION
|
||||
QString dd_arg("--data-dir=");
|
||||
if (option.startsWith(dd_arg)) {
|
||||
data_dir_ = option.mid(dd_arg.length());
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
QString ld_arg("--lang-dir=");
|
||||
@ -353,6 +368,25 @@ QString QETArguments::configDir() const
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef QET_ALLOW_OVERRIDE_DD_OPTION
|
||||
/**
|
||||
@return true si l'utilisateur a specifie un dossier pour la data
|
||||
*/
|
||||
bool QETArguments::dataDirSpecified() const
|
||||
{
|
||||
return(!data_dir_.isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
@return le dossier de data specifie par l'utilisateur.
|
||||
Si l'utilisateur n'en a pas specifie, une chaine vide est retournee.
|
||||
*/
|
||||
QString QETArguments::dataDir() const
|
||||
{
|
||||
return(data_dir_);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
@return true si l'utilisateur a specifie un dossier pour les fichiers de langue
|
||||
*/
|
||||
|
@ -53,6 +53,10 @@ class QETArguments : public QObject {
|
||||
#ifdef QET_ALLOW_OVERRIDE_CD_OPTION
|
||||
virtual bool configDirSpecified() const;
|
||||
virtual QString configDir() const;
|
||||
#endif
|
||||
#ifdef QET_ALLOW_OVERRIDE_DD_OPTION
|
||||
virtual bool dataDirSpecified() const;
|
||||
virtual QString dataDir() const;
|
||||
#endif
|
||||
virtual bool langDirSpecified() const;
|
||||
virtual QString langDir() const;
|
||||
@ -83,6 +87,9 @@ class QETArguments : public QObject {
|
||||
#endif
|
||||
#ifdef QET_ALLOW_OVERRIDE_CD_OPTION
|
||||
QString config_dir_;
|
||||
#endif
|
||||
#ifdef QET_ALLOW_OVERRIDE_DD_OPTION
|
||||
QString data_dir_;
|
||||
#endif
|
||||
QString lang_dir_;
|
||||
bool print_help_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user