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 02b2b09bf..34d130258 100644 Binary files a/lang/qet_en.qm and b/lang/qet_en.qm differ 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();