From 5c1260fe0c6895368a42814c73332e590709730e Mon Sep 17 00:00:00 2001 From: xavierqet Date: Sun, 28 Oct 2007 01:32:57 +0000 Subject: [PATCH] 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 --- gnugpl.txt => LICENSE | 0 aboutqet.cpp | 22 +-- lang/qet_en.qm | Bin 49301 -> 50482 bytes lang/qet_en.ts | 337 +++++++++++++++++++++++------------------- qelectrotech.qrc | 1 + qet.cpp | 24 +++ qet.h | 1 + qetapp.cpp | 60 ++++++-- qetapp.h | 3 + 9 files changed, 266 insertions(+), 182 deletions(-) rename gnugpl.txt => LICENSE (100%) diff --git a/gnugpl.txt b/LICENSE similarity index 100% rename from gnugpl.txt rename to LICENSE diff --git a/aboutqet.cpp b/aboutqet.cpp index d3ef33fc3..231999f36 100644 --- a/aboutqet.cpp +++ b/aboutqet.cpp @@ -107,29 +107,9 @@ QWidget *AboutQET::ongletLicence() const { // label QLabel *titre_licence = new QLabel(tr("Ce programme est sous licence GNU/GPL.")); - // Recuperation du texte de la GNU/GPL dans un fichier externe - QFile *fichier_gpl = new QFile("./gnugpl.txt"); - QString txt_gpl; - // verifie que le fichier existe - if (!fichier_gpl -> exists()) { - txt_gpl = QString(tr("Le fichier texte contenant la licence GNU/GPL est introuvable - bon bah de toute fa\347on, vous la connaissez par coeur non ?")); - } else { - // ouvre le fichier en mode texte et en lecture seule - if (!fichier_gpl -> open(QIODevice::ReadOnly | QIODevice::Text)) { - txt_gpl = QString(tr("Le fichier texte contenant la licence GNU/GPL existe mais n'a pas pu \352tre ouvert - bon bah de toute fa\347on, vous la connaissez par coeur non ?")); - } else { - // charge le contenu du fichier dans une QString - QTextStream in(fichier_gpl); - txt_gpl = QString(""); - while (!in.atEnd()) txt_gpl += in.readLine()+"\n"; - // ferme le fichier - fichier_gpl -> close(); - } - } - // texte de la GNU/GPL dans une zone de texte scrollable non editable QTextEdit *texte_licence = new QTextEdit(); - texte_licence -> setPlainText(txt_gpl); + texte_licence -> setPlainText(QET::license()); texte_licence -> setReadOnly(true); // le tout dans une disposition verticale diff --git a/lang/qet_en.qm b/lang/qet_en.qm index 02b2b09bfaed72dd9529cd3f065ba67fd353a2cd..34d1302582c5a0bdd067ec8dd62da00f18f6692a 100644 GIT binary patch delta 4525 zcma*p30M?Ywg>RjOI3AOZ^p1h)R|UeP$MWR;;5)7Xbd6z;e= zz2~;B&ynpel$E$hj_h*vliG9WLY|eVr;0A^7!Gsk(gh#5hrYKq5k22mB5BNmHziE- z10t7v_z-?6;ZiL`t}jWnCs)9CBt8{Y@S$XK|2QJIF_I8V8myN@3@IRTe_0ZF?m75| zB(bg?9&l=Z!Bw(U)kyS$RkE~eK5UbiuMZ&dSSHD;t0U^|A=#9lLDZ*@WcQEh@Ra04 z(M+PgF_H&!5wP!nOP;jm68*_b>XP39H%dKT*AxA@pLEiS3D7K!s9Hj#FPBDbae-H* zbNQ`A{am`WQ$MTJko^T7G)oKaZzJj-EZwZZ!2P#KD{3&a0S4*T!ANXCi?nHr2hoeU z(j(7bhhIsLJ})JDX{u<6^w=&3+E=8fZV{1ZPw6*5`NA2}r{N`Vue8(kBGI57P6zjq zjp+TzPBgew7EqN!G(;+U#ioXfMVn+ZKWZa-StE<=*9iuWg_LeXr?+jT@BDQkaRN1a(WHxM)9 zDm?fX{2V?a@?#^!Q{1(F701Z9Ix~LKo9(ek#$#_n2N;g5NR&I}(T{4QB?;+zadNOlZ~x z+}vTp2D%aj1c`1D?PMa~8cQ@ejEQu-3D+>jF=_BHV`>-)A3B}l$(WjbiKe_RTFThI zzKQlpCPPRt(3L67oD6q64I01{E3pDW_D#%Me|#|Y6{aj1=YHybreZP%nA*-%Dxz-Qy?ZKW*$2lxX@KVuzZ12{~L^C*cSRsmLMhH9H9mO`|1UuYM z@F_cDP##f;A3L!XGY(lR+RTRB-G=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XXc^wYoCg>Dk6%WFV?0vz%237=lHsKd4C|@ zbY|l3C-1-+;-^Dcus+Ku&cFVaN`9e&D8^FNrT;QGS!Fv2ry;h3YIqA)5W7wlbkl|? zPLy<0ZR9XvT!d=V3Y0poK$Vk@H(dN$)&A-?@GsTDEX4Iin*Q7dipgYm}*{a$RdhGT3ZK|t6IMD{V>Qx&@=&pKm)fhLZ{@sB+-DoShRxOM0 zLwrl!<`H@$v8~#HZ-Rc3+trS}S`q)E9+r89$Y7@Sjz@xq7wS1P@!(AX>VSC6yJ^2V zJ`2Zs)4%FMeYGdi=AG(;26Xf0izc^ll5Xltr*nw5M5!-l9)h<`CUsEXJBZVeG)?`; z-<~MBr(}q_ImaCF3CR|9^K*Zqlp*Tom#9F>Qgw@Q0V#XbAMe$}>uUYyL8_&O{~4L3 z`fEBrjD{r|yCcXjZHT6~V;HM~l+{R_Ru+d_+hpXQrX?8){PO=R9^qVN4Qxpv+# zO;f4B=ik?8E}Y*-v?En>#WDt-)6~5~&txby5BRfiyyp2`oQ8}HP17DEp3$OtAE_kD ztkpChM=$K0sQI)N-`iO%`HyxmTTQe}@1`A|6oNsec4RWTe0Pv`UMVWEyIi}p8V}6s zu3fP>03OwbB~B&Eo}pb?I~Epcqg0oOa;&t8HJCUjQJdWD0lcj(d3l&$8?=94!~*yJrF|6RjOO3xZW`>{pncRjooL?`?FZuxxgB+k91qC# z(sg7S;R{{&8v}{*_Deq2Ii5kH`2%z=ukhgfA9b$BufY!{_s`Ld$iRI2t8`-`uGph8J$}l{eoJd(QSnOW|AkT*=^q>(<~4SD#cb>2X8#v< j9g;t>;&fadQ}KPm4q1h@A>Wy4lYZQ#W5vibubKY=f`(F3 diff --git a/lang/qet_en.ts b/lang/qet_en.ts index dca39cdbb..86eb8b6f6 100644 --- a/lang/qet_en.ts +++ b/lang/qet_en.ts @@ -1,6 +1,5 @@ - AboutQET @@ -38,16 +37,6 @@ Idée originale Original concept - - - Le fichier texte contenant la licence GNU/GPL est introuvable - bon bah de toute façon, vous la connaissez par coeur non ? - The text file containing the GNU/GPL license could not be found - however, you know it by heart, don't you ? - - - - Le fichier texte contenant la licence GNU/GPL existe mais n'a pas pu être ouvert - bon bah de toute façon, vous la connaissez par coeur non ? - The text file containing the GNU/GPL license exists but could not be opened - however, you know it by heart, don't you ? - Programmation @@ -1093,475 +1082,513 @@ Please check rights of the directory QETApp - + QElectroTech QElectroTech - + &Quitter &Quit - + &Masquer &Hide - + &Restaurer &Show - + &Masquer tous les éditeurs de schéma &Hide diagram editors - + &Restaurer tous les éditeurs de schéma &Show diagram editors - + &Masquer tous les éditeurs d'élément &Hide element editors - + &Restaurer tous les éditeurs d'élément &Show element editors - + &Nouvel éditeur de schéma &New diagram editor - + &Nouvel éditeur d'élément &New element editor - + Ferme l'application QElectroTech Closes QElectroTech - + Réduire QElectroTech dans le systray Reduces QElectroTech into the systray - + Restaurer QElectroTech Restore QElectroTech - + Éditeurs de schémas Diagram editors - + Éditeurs d'élément Element editors + + + Usage : + Usage: + + + + QElectroTech, une application de réalisation de schémas électriques. + +Options disponibles : + --help Afficher l'aide sur les options + -v, --version Afficher la version + --license Afficher la licence + + QElectroTech, an application to design electric diagrams. + +Available options: + --help Display this help + -v, --version Display the version + --license Display the license + + + + + [options] [fichier]... + + + [options] [file]... + + + + + + --common-elements-dir=DIR Definir le dossier de la collection d'elements + + --common-elements-dir=DIR Define the elements collection directory + + QETDiagramEditor - + Active la fenêtre Activates the window - + Active la fenêtre précédente Activates the previous window - + Active la fenêtre suivante Activates the next window - + Adapte la taille du schéma afin qu'il soit entièrement visible Changes the size of the plan so that it fits in the view - + Afficha&ge Displ&ay - + Affiche des informations sur la bibliothèque Qt Displays informations about Qt library - + Affiche des informations sur QElectroTech Displays informations about QElectroTech - + Affiche ou non le panel d'appareils Displays or not the elements panel - + Affiche QElectroTech en mode fenêtré Displays QElectroTech in windowed mode - + Affiche QElectroTech en mode plein écran Displays QELectroTech in full screen mode - + Afficher Display - + Agrandir le schéma Expand the diagram - + Agrandit le schéma Expand the diagram - + Agrandit le schéma en hauteur Expand the diagram's height - + &Aide &Help - + Ajouter une colonne Add a column - + Ajoute une colonne au schéma Add a column to the diagram - + Aligne les fenêtres réduites Arranges all iconized windows at the bottom of the workspace - + Annule l'action précédente Undoes the previous action - + À &propos de QElectroTech A&bout QElectroTech - + À propos de &Qt About &Qt - + Arranger les fenêtres réduites Arranges iconized windows - + &Cascade &Cascade - + Ce fichier n'est pas un document XML valide. This file is not a valid XML Document. - + Ce fichier n'existe pas. This file does not exist. - + C&oller &Paste - + &Configuration &Settings - + &Configurer QElectroTech &Configure QElectroTech - + Copie les éléments sélectionnés dans le presse-papier Copies selected elements - + Cop&ier &Copy - + Co&uper Cu&t - + Crée un nouveau schéma Opens a new diagram - + Ctrl+0 - + Ctrl+9 - + Ctrl+I - + Ctrl+Q - + Ctrl+R Ctrl+R - + Ctrl+Shift+A - + Ctrl+Shift+F Ctrl+Shift+F - + Ctrl+Shift+I - + Ctrl+Shift+X - + Désélectionne les éléments sélectionnés et sélectionne les éléments non sélectionnés Deselects selected elements and select non-selected elements - + Désélectionner tout Select none - + Désélectionne tous les éléments du schéma Deselect all elements on the plan - + Dispose les fenêtres en cascade Arranges windows in a cascade pattern - + Dispose les fenêtres en mosaïque Arranges windows in a tile pattern - + Édite les informations affichées par le cartouche Edit informations displayed by the inset - + &Édition &Edit - + Enlève les éléments sélectionnés du schéma Removes selected elements from the plan - + Enlever une colonne Remove a column - + Enlève une colonne au schéma Remove a column from the diagram - + Enregistre le schéma courant Saves the current plan - + Enregistre le schéma courant avec un autre nom de fichier Saves the current plan as another filename - + &Enregistrer &Save - + Enregistrer sous Save as - + Erreur Error - + Exporte le schéma courant dans un autre format Exports the curent plan to another format - + E&xporter &Export - + Fenêtre précédente Previous Window - + Fe&nêtres Wi&ndows - + Fenêtre suivante Next Window - + Ferme l'application QElectroTech Closes QElectroTech - + Ferme le schéma courant Closes the current plan - + &Fermer &Close - + &Fichier &File - + &Importer &Import - + Importe un schéma dans le schéma courant Imports a plan into the current plan - + Impossible de lire ce fichier. Could not read file. - + Imprime le schéma courant Prints the current plan - + Imprimer Print - + Inverser la sélection Invert selection - + Mode Selection Selection Mode - + Mode Visualisation View Mode - + &Mosaïque &Tile - + &Nouveau &New - + Outils Tools - + Ouvre un schéma existant Open an existing diagram - + &Ouvrir &Open - + Ouvrir un fichier Open a file @@ -1571,42 +1598,42 @@ Please check rights of the directory Elements Panel - + Pas de zoom Reset zoom - + Passer en &mode plein écran F&ullScreen Mode - + Permet de régler différents paramètres de QElectroTech Allows to specify various parameters for QElectroTech - + Permet de sélectionner les éléments Allows to select elements - + Permet de visualiser le schéma sans pouvoir le modifier Allows to view the plan without modifying it - + Pivote les éléments sélectionnés Rotates selected elements - + Pivoter Rotate - + Place les éléments du presse-papier sur le schéma Pastes elements from the clipboard into the plan @@ -1616,182 +1643,182 @@ Please check rights of the directory QElectroTech - + &Quitter &Quit - + Restaure l'action annulée Restores the undone action - + Restaure le zoom par défaut Restores default zoom level - + Rétrécir le schéma Shrink the diagram - + Rétrécit le schéma Shrinks the plan - + Rétrécit le schéma en hauteur Shrink the diagram's height - + Schémas QElectroTech (*.qet);;Fichiers XML (*.xml);;Tous les fichiers (*) QElectroTech Diagrams (*.qet);;XML Files (*.xml);;All files (*) - + Sélectionne tous les éléments du schéma Selects all elements on the plan - + Sortir du &mode plein écran Exit F&ullScreen Screen Mode - + Supprimer Delete - + Tout sélectionner Select All - + Transfère les éléments sélectionnés dans le presse-papier Puts selected elements into the clipboard - + Une erreur s'est produite lors de l'ouverture du fichier. An error occured while opening the file. - + Zoom adapté Fit in view - + Zoom arrière Zoom Out - + Zoom avant Zoom In - + Annuler Undo - + Refaire Redo - + Propriétés du conducteur Conductor properties - + Édite les propriétés du conducteur sélectionné Edit the selected conductor properties - + Réinitialiser les conducteurs Reset conductors - + Suppr Del - + Ctrl+J Ctrl+J - + Ctrl+K Ctrl+K - + Propriétés du schéma Diagram Properties - + Ctrl+L Ctrl+L - + Recalcule les chemins des conducteurs sans tenir compte des modifications Reset the conductors path ignoring the user changes - + Affiche ou non la barre d'outils principale Display or hide the main toolbar - + Affiche ou non la barre d'outils Affichage Display or hide the Display toolbar - + Affiche ou non la barre d'outils Schéma Display or hide the Diagram toolbar - + Affichage Display - + Schéma Diagram - + Conducteurs par défaut Default conductors - + Ctrl+D Ctrl+D - + Spécifie les propriétés par défaut des conducteurs Specify the conductors default properties - + Ajouter un champ de texte Add a textfield @@ -2357,7 +2384,7 @@ Please check rights of the directory Add a textfield - + , , @@ -2366,6 +2393,16 @@ Please check rights of the directory champs de texte textfields + + + Le fichier texte contenant la licence GNU/GPL est introuvable - bon bah de toute façon, vous la connaissez par coeur non ? + The text file containing the GNU/GPL license could not be found - however, you know it by heart, don't you ? + + + + Le fichier texte contenant la licence GNU/GPL existe mais n'a pas pu être ouvert - bon bah de toute façon, vous la connaissez par coeur non ? + The text file containing the GNU/GPL license exists but could not be opened - however, you know it by heart, don't you ? + StyleEditor diff --git a/qelectrotech.qrc b/qelectrotech.qrc index 1c6c15cc3..475a3e82f 100644 --- a/qelectrotech.qrc +++ b/qelectrotech.qrc @@ -1,5 +1,6 @@ + LICENSE ico/qet.png ico/qet-16.png ico/qelectrotech.png diff --git a/qet.cpp b/qet.cpp index 2f5a58b28..cd627df5a 100644 --- a/qet.cpp +++ b/qet.cpp @@ -175,3 +175,27 @@ QList QET::findInDomElement(const QDomElement &e, const QString &pa } return(return_list); } + +/// @return le texte de la licence de QElectroTech (GNU/GPL) +QString QET::license() { + // Recuperation du texte de la GNU/GPL dans un fichier integre a l'application + QFile *file_license = new QFile(":/LICENSE"); + QString txt_license; + // verifie que le fichier existe + if (!file_license -> exists()) { + txt_license = QString(QObject::tr("Le fichier texte contenant la licence GNU/GPL est introuvable - bon bah de toute fa\347on, vous la connaissez par coeur non ?")); + } else { + // ouvre le fichier en mode texte et en lecture seule + if (!file_license -> open(QIODevice::ReadOnly | QIODevice::Text)) { + txt_license = QString(QObject::tr("Le fichier texte contenant la licence GNU/GPL existe mais n'a pas pu \352tre ouvert - bon bah de toute fa\347on, vous la connaissez par coeur non ?")); + } else { + // charge le contenu du fichier dans une QString + QTextStream in(file_license); + txt_license = QString(""); + while (!in.atEnd()) txt_license += in.readLine()+"\n"; + // ferme le fichier + file_license -> close(); + } + } + return(txt_license); +}; diff --git a/qet.h b/qet.h index 6956924dd..5c06af8f6 100644 --- a/qet.h +++ b/qet.h @@ -9,6 +9,7 @@ namespace QET { /// version de QElectroTech const QString version = "0.1"; + QString license(); /// Orientation (utilise pour les bornes mais aussi pour les elements) enum Orientation {North, East, South, West}; /// Types de segment de conducteurs diff --git a/qetapp.cpp b/qetapp.cpp index a33445e0e..6e178af70 100644 --- a/qetapp.cpp +++ b/qetapp.cpp @@ -1,6 +1,7 @@ #include "qetapp.h" #include "qetdiagrameditor.h" #include "qetelementeditor.h" +#include #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; +} diff --git a/qetapp.h b/qetapp.h index e41b14fea..af0541cc5 100644 --- a/qetapp.h +++ b/qetapp.h @@ -22,6 +22,9 @@ class QETApp : public QApplication { // methodes public: void setLanguage(const QString &); + static void printHelp(); + static void printVersion(); + static void printLicense(); static QString commonElementsDir(); static QString customElementsDir();