From 7b71cbb7ae80494b28b4167d57061d5bfe24cf55 Mon Sep 17 00:00:00 2001 From: xavierqet Date: Thu, 4 Oct 2007 20:34:29 +0000 Subject: [PATCH] * Option Compile-Time pour definir le chemin du dossier des fichiers de traduction : QET_LANG_PATH * Option Compile-Time pour definir le chemin du dossier des elements communs : QET_COMMON_COLLECTION_PATH * Option Run-Time pour definir le chemin de la collection principale : --common-elements-dir=/path/to/elements/ * Option Compile-Time pour autoriser ou non l'utilisation de l'option Run-Time precedente : QET_ALLOW_OVERRIDE_CED_OPTION Les options Compile-Time sont a definir dans le fichier .pro git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@158 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- qelectrotech.pro | 21 ++++++++++++++------- qetapp.cpp | 41 +++++++++++++++++++++++++++++++++++++++-- qetapp.h | 9 +++++++-- 3 files changed, 60 insertions(+), 11 deletions(-) diff --git a/qelectrotech.pro b/qelectrotech.pro index 1cc89ad22..5902f6a47 100644 --- a/qelectrotech.pro +++ b/qelectrotech.pro @@ -3,7 +3,6 @@ ###################################################################### TEMPLATE = app -TARGET = DEPENDPATH += . editor lang INCLUDEPATH += . editor @@ -64,10 +63,10 @@ HEADERS += aboutqet.h \ editor/terminaleditor.h \ editor/texteditor.h \ editor/textfieldeditor.h \ - diagramcommands.h \ - diagramtextitem.h \ - insetproperties.h \ - conductorproperties.h + diagramcommands.h \ + diagramtextitem.h \ + insetproperties.h \ + conductorproperties.h SOURCES += aboutqet.cpp \ borderinset.cpp \ conductor.cpp \ @@ -125,10 +124,18 @@ SOURCES += aboutqet.cpp \ editor/texteditor.cpp \ editor/textfieldeditor.cpp \ diagramcommands.cpp \ - diagramtextitem.cpp \ - conductorproperties.cpp + diagramtextitem.cpp \ + conductorproperties.cpp RESOURCES += qelectrotech.qrc TRANSLATIONS += lang/qet_en.ts lang/qt_fr.ts RC_FILE = ico/windows_icon/application_icon/qelectrotech.rc QT += xml CONFIG += debug_and_release +CONFIG(debug, debug|release) { + TARGET = qelectrotech +} else { + TARGET = qelectrotech.release +} +;DEFINES += QET_LANG_PATH='\\"/path/to/qelectrotech/lang/\\"' +;DEFINES += QET_COMMON_COLLECTION_PATH='\\"/path/to/qelectrotech/elements/\\"' +DEFINES += QET_ALLOW_OVERRIDE_CED_OPTION diff --git a/qetapp.cpp b/qetapp.cpp index 2fb7c52eb..fd4c58cf2 100644 --- a/qetapp.cpp +++ b/qetapp.cpp @@ -2,6 +2,8 @@ #include "qetdiagrameditor.h" #include "qetelementeditor.h" +QString QETApp::common_elements_dir = QString(); + /** Constructeur @param argc Nombre d'arguments passes a l'application @@ -58,6 +60,17 @@ QETApp::QETApp(int &argc, char **argv) : QApplication(argc, argv) { connect(this, SIGNAL(lastWindowClosed()), this, SLOT(checkRemainingWindows())); } + // parse les arguments + foreach(QString argument, arguments()) { +#ifdef QET_ALLOW_OVERRIDE_CED_OPTION + QString ced_arg("--common-elements-dir="); + if (argument.startsWith(ced_arg)) { + QString ced_value = argument.right(argument.length() - ced_arg.length()); + overrideCommonElementsDir(ced_value); + } +#endif + } + // Creation et affichage d'un editeur de schema QStringList files; foreach(QString argument, arguments()) { @@ -165,7 +178,14 @@ void QETApp::newElementEditor() { @return Le chemin du dossier des elements communs */ QString QETApp::commonElementsDir() { +#ifdef QET_ALLOW_OVERRIDE_CED_OPTION + if (common_elements_dir != QString()) return(common_elements_dir); +#endif +#ifdef QET_COMMON_COLLECTION_PATH + return(QET_COMMON_COLLECTION_PATH); +#else return(QDir::current().path() + "/elements/"); +#endif } /** @@ -201,7 +221,7 @@ QString QETApp::configDir() { @return Une chaine de caracteres vide en cas d'erreur ou le chemin absolu du fichier *.elmt. */ -QString QETApp::realPath(QString &sym_path) { +QString QETApp::realPath(const QString &sym_path) { QString directory; if (sym_path.startsWith("common://")) { directory = commonElementsDir(); @@ -218,7 +238,7 @@ QString QETApp::realPath(QString &sym_path) { @return Une chaine de caracteres vide en cas d'erreur ou le chemin symbolique designant l'element. */ -QString QETApp::symbolicPath(QString &real_path) { +QString QETApp::symbolicPath(const QString &real_path) { // recupere les dossier common et custom QString commond = commonElementsDir(); QString customd = customElementsDir(); @@ -232,11 +252,28 @@ QString QETApp::symbolicPath(QString &real_path) { return(chemin); } +#ifdef QET_ALLOW_OVERRIDE_CED_OPTION +/** + Redefinit le chemin du dossier des elements communs. +*/ +void QETApp::overrideCommonElementsDir(const QString &new_ced) { + QFileInfo new_ced_info(new_ced); + if (new_ced_info.isDir()) { + common_elements_dir = new_ced_info.absoluteFilePath(); + if (!common_elements_dir.endsWith("/")) common_elements_dir += "/"; + } +} +#endif + /** @return Le chemin du dossier contenant les fichiers de langue */ QString QETApp::languagesPath() { +#ifndef QET_LANG_PATH return(QDir::current().path() + "/lang/"); +#else + return(QET_LANG_PATH); +#endif } /** diff --git a/qetapp.h b/qetapp.h index 90b71c6b0..145479c55 100644 --- a/qetapp.h +++ b/qetapp.h @@ -27,8 +27,13 @@ class QETApp : public QApplication { static QString customElementsDir(); static QString configDir(); static QString languagesPath(); - static QString realPath(QString &); - static QString symbolicPath(QString &); + static QString realPath(const QString &); + static QString symbolicPath(const QString &); +#ifdef QET_ALLOW_OVERRIDE_CED_OPTION + static void overrideCommonElementsDir(const QString &); + private: + static QString common_elements_dir; +#endif // attributs private: