mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-01-07 14:12:33 +01:00
Ajout des options --help, -v,--version et --license
Le fichier gnugpl.txt s'appelle desormais LICENSE et est integre au binaire QET git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@196 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
60
qetapp.cpp
60
qetapp.cpp
@@ -1,6 +1,7 @@
|
||||
#include "qetapp.h"
|
||||
#include "qetdiagrameditor.h"
|
||||
#include "qetelementeditor.h"
|
||||
#include <iostream>
|
||||
#define QUOTE(x) STRINGIFY(x)
|
||||
#define STRINGIFY(x) #x
|
||||
|
||||
@@ -16,6 +17,31 @@ QETApp::QETApp(int &argc, char **argv) : QApplication(argc, argv) {
|
||||
QString system_language = QLocale::system().name().left(2);
|
||||
setLanguage(system_language);
|
||||
|
||||
// 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
|
||||
bool must_exit = false;
|
||||
if (argument == QString("--help")) {
|
||||
printHelp();
|
||||
must_exit = true;
|
||||
} else if (argument == QString("--version") || argument == QString("-v")) {
|
||||
printVersion();
|
||||
must_exit = true;
|
||||
} else if (argument == QString("--license")) {
|
||||
printLicense();
|
||||
must_exit = true;
|
||||
}
|
||||
if (must_exit) {
|
||||
std::exit(EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
// nettoyage avant de quitter l'application
|
||||
connect(this, SIGNAL(aboutToQuit()), this, SLOT(cleanup()));
|
||||
|
||||
@@ -62,17 +88,6 @@ 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()) {
|
||||
@@ -505,3 +520,26 @@ bool QETApp::event(QEvent *e) {
|
||||
return(QApplication::event(e));
|
||||
}
|
||||
}
|
||||
|
||||
void QETApp::printHelp() {
|
||||
QString help(
|
||||
tr("Usage : ") + QFileInfo(applicationFilePath()).fileName() + tr(" [options] [fichier]...\n\n") +
|
||||
tr("QElectroTech, une application de r\351alisation de sch\351mas \351lectriques.\n\n"
|
||||
"Options disponibles : \n"
|
||||
" --help Afficher l'aide sur les options\n"
|
||||
" -v, --version Afficher la version\n"
|
||||
" --license Afficher la licence\n")
|
||||
#ifdef QET_ALLOW_OVERRIDE_CED_OPTION
|
||||
+ tr(" --common-elements-dir=DIR Definir le dossier de la collection d'elements\n")
|
||||
#endif
|
||||
);
|
||||
std::cout << qPrintable(help) << std::endl;
|
||||
}
|
||||
|
||||
void QETApp::printVersion() {
|
||||
std::cout << qPrintable(QET::version) << std::endl;
|
||||
}
|
||||
|
||||
void QETApp::printLicense() {
|
||||
std::cout << qPrintable(QET::license()) << std::endl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user