diff --git a/sources/qetapp.cpp b/sources/qetapp.cpp index 3659dcd63..1ecc0a71f 100644 --- a/sources/qetapp.cpp +++ b/sources/qetapp.cpp @@ -68,17 +68,17 @@ QETApp *QETApp::m_qetapp = nullptr; /** - * @brief QETApp::QETApp - */ + @brief QETApp::QETApp +*/ QETApp::QETApp() : m_splash_screen(nullptr), non_interactive_execution_(false) { m_qetapp = this; parseArguments(); - if (non_interactive_execution_) { - std::exit(EXIT_SUCCESS); - } + if (non_interactive_execution_) { + std::exit(EXIT_SUCCESS); + } initConfiguration(); initLanguage(); QET::Icons::initIcons(); @@ -109,16 +109,16 @@ QETApp::QETApp() : } buildSystemTrayMenu(); - if (m_splash_screen) { - m_splash_screen -> hide(); - } + if (m_splash_screen) { + m_splash_screen -> hide(); + } checkBackupFiles(); } /** - * @brief QETApp::~QETApp - */ + @brief QETApp::~QETApp +*/ QETApp::~QETApp() { m_elements_recent_files->save(); @@ -138,8 +138,11 @@ QETApp::~QETApp() ElementPictureFactory::dropInstance(); } + /** - @return l'instance de la QETApp + @brief QETApp::instance + \~ @return the instance of the QETApp + \~French l'instance de la QETApp */ QETApp *QETApp::instance() { @@ -147,8 +150,12 @@ QETApp *QETApp::instance() } /** - Change le langage utilise par l'application. - @param desired_language langage voulu + @brief QETApp::setLanguage + Change the language used by the application. + \~French Change le langage utilise par l'application. + \~ @param desired_language : + wanted language + \~French langage voulu */ void QETApp::setLanguage(const QString &desired_language) { QString languages_path = languagesPath(); @@ -178,10 +185,10 @@ void QETApp::setLanguage(const QString &desired_language) { } /** - * @brief QETApp::langFromSetting - * @return the langage found in setting file - * if nothing was found return the system local. - */ + @brief QETApp::langFromSetting + @return the langage found in setting file + if nothing was found return the system local. +*/ QString QETApp::langFromSetting() { QSettings settings; @@ -197,30 +204,42 @@ void QETApp::switchLayout(Qt::LayoutDirection direction) { } /** - Gere les evenements relatifs au QSystemTrayIcon - @param reason un entier representant l'evenement survenu sur le systray + @brief QETApp::systray + Manages QSystemTrayIcon related events + \~French Gere les evenements relatifs au QSystemTrayIcon + \~ @param reason : + reason an integer representing the event on the systray + \~French reason un entier representant l'evenement survenu sur le systray */ void QETApp::systray(QSystemTrayIcon::ActivationReason reason) { if (!QSystemTrayIcon::isSystemTrayAvailable()) return; switch(reason) { case QSystemTrayIcon::Context: + // menu display // affichage du menu buildSystemTrayMenu(); m_qsti -> contextMenu() -> show(); break; case QSystemTrayIcon::DoubleClick: case QSystemTrayIcon::Trigger: + // reduce or restore the application // reduction ou restauration de l'application fetchWindowStats(diagramEditors(), elementEditors(), titleBlockTemplateEditors()); if (every_editor_reduced) restoreEveryEditor(); else reduceEveryEditor(); break; case QSystemTrayIcon::Unknown: - default: // ne rien faire + default: + // do nothing + // ne rien faire break; } } -/// Reduit toutes les fenetres de l'application dans le systray +/** + @brief QETApp::reduceEveryEditor + Minimizes all application windows in the systray + \~French Reduit toutes les fenetres de l'application dans le systray +*/ void QETApp::reduceEveryEditor() { reduceDiagramEditors(); reduceElementEditors(); @@ -228,7 +247,11 @@ void QETApp::reduceEveryEditor() { every_editor_reduced = true; } -/// Restaure toutes les fenetres de l'application dans le systray +/** + @brief QETApp::restoreEveryEditor + Restores all application windows in the systray + \~French Restaure toutes les fenetres de l'application dans le systray +*/ void QETApp::restoreEveryEditor() { restoreDiagramEditors(); restoreElementEditors(); @@ -236,47 +259,79 @@ void QETApp::restoreEveryEditor() { every_editor_reduced = false; } -/// Reduit tous les editeurs de schemas dans le systray +/** + @brief QETApp::reduceDiagramEditors + Minimize all schema editors in the systray + \~French Reduit tous les editeurs de schemas dans le systray + */ void QETApp::reduceDiagramEditors() { setMainWindowsVisible(false); } -/// Restaure tous les editeurs de schemas dans le systray +/** + @brief QETApp::restoreDiagramEditors + Restore all schema editors in the systray + \~French Restaure tous les editeurs de schemas dans le systray +*/ void QETApp::restoreDiagramEditors() { setMainWindowsVisible(true); } -/// Reduit tous les editeurs d'element dans le systray + +/** + @brief QETApp::reduceElementEditors + Minimize all element editors in systray + \~French Reduit tous les editeurs d'element dans le systray +*/ void QETApp::reduceElementEditors() { setMainWindowsVisible(false); } -/// Restaure tous les editeurs d'element dans le systray +/** + @brief QETApp::restoreElementEditors + Restore all element editors in the systray + \~French Restaure tous les editeurs d'element dans le systray + */ void QETApp::restoreElementEditors() { setMainWindowsVisible(true); } -/// Reduce all known template editors +/** + @brief QETApp::reduceTitleBlockTemplateEditors + Reduce all known template editors +*/ void QETApp::reduceTitleBlockTemplateEditors() { setMainWindowsVisible(false); } -/// Restore all known template editors +/** + @brief QETApp::restoreTitleBlockTemplateEditors + Restore all known template editors +*/ void QETApp::restoreTitleBlockTemplateEditors() { setMainWindowsVisible(true); } -/// lance un nouvel editeur de schemas +/** + @brief QETApp::newDiagramEditor + launches a new schema editor + \~French lance un nouvel editeur de schemas +*/ void QETApp::newDiagramEditor() { new QETDiagramEditor(); } -/// lance un nouvel editeur d'element +/** + @brief QETApp::newElementEditor + launches a new element editor + \~French lance un nouvel editeur d'element +*/ void QETApp::newElementEditor() { new QETElementEditor(); } /** + @brief QETApp::collectionCache @return the collection cache provided by the application itself. */ ElementsCollectionCache *QETApp::collectionCache() { @@ -284,9 +339,9 @@ ElementsCollectionCache *QETApp::collectionCache() { } /** - * @brief QETApp::elementInfoKeys - * @return all available key for describe an element - */ + @brief QETApp::elementInfoKeys + @return all available key for describe an element +*/ QStringList QETApp::elementInfoKeys() { QStringList info_list; @@ -315,12 +370,12 @@ QStringList QETApp::elementInfoKeys() } /** - * @brief ElementsProperties::translatedInfo - * Return the translated information key given by @info - * If @info don't match, return an empty string - * @param info the key to be translated - * @return - */ + @brief ElementsProperties::translatedInfo + Return the translated information key given by @info + If @info don't match, return an empty string + @param info the key to be translated + @return +*/ QString QETApp::elementTranslatedInfoKey(const QString &info) { if (info == "formula") return tr("Formule du label"); @@ -349,11 +404,12 @@ QString QETApp::elementTranslatedInfoKey(const QString &info) } /** - * @brief QETApp::elementInfoToVar - * @param info - * @return var in form %{my-var} corresponding to the info, if there is not available var for the given info - * the returned var is %{void} - */ + @brief QETApp::elementInfoToVar + @param info + @return var in form %{my-var} corresponding to the info, + if there is not available var for the given info + the returned var is %{void} +*/ QString QETApp::elementInfoToVar(const QString &info) { if (info == "formula") return QString("%{formula}"); @@ -380,9 +436,9 @@ QString QETApp::elementInfoToVar(const QString &info) } /** - * @brief QETApp::conductorInfoKeys - * @return the conductor information keys - */ + @brief QETApp::conductorInfoKeys + @return the conductor information keys +*/ QStringList QETApp::conductorInfoKeys() { QStringList keys; @@ -397,11 +453,11 @@ QStringList QETApp::conductorInfoKeys() } /** - * @brief QETApp::conductorTranslatedInfoKey - * @param key - * @return the translated information key given by @key - * If @key don't match, return an empty string - */ + @brief QETApp::conductorTranslatedInfoKey + @param key + @return the translated information key given by @key + If @key don't match, return an empty string +*/ QString QETApp::conductorTranslatedInfoKey(const QString &key) { if (key == "formula") return tr("Formule du texte"); @@ -414,9 +470,9 @@ QString QETApp::conductorTranslatedInfoKey(const QString &key) } /** - * @brief QETApp::diagramInfoKeys - * @return the diagram default default information keys - */ + @brief QETApp::diagramInfoKeys + @return the diagram default default information keys +*/ QStringList QETApp::diagramInfoKeys() { QStringList list; @@ -434,11 +490,11 @@ QStringList QETApp::diagramInfoKeys() } /** - * @brief QETApp::diagramTranslatedInfoKey - * @param key - * @return the translated information key given by @key - * If @key don't match, return an empty string - */ + @brief QETApp::diagramTranslatedInfoKey + @param key + @return the translated information key given by @key + If @key don't match, return an empty string +*/ QString QETApp::diagramTranslatedInfoKey(const QString &key) { if (key == "title") return tr("Titre"); @@ -454,8 +510,9 @@ QString QETApp::diagramTranslatedInfoKey(const QString &key) } /** - @return the common title block templates collection, i.e. the one provided - by QElecrotTech + @brief QETApp::commonTitleBlockTemplatesCollection + @return the common title block templates collection, + i.e. the one provided by QElecrotTech */ TitleBlockTemplatesFilesCollection *QETApp::commonTitleBlockTemplatesCollection() { if (!m_common_tbt_collection) { @@ -468,8 +525,9 @@ TitleBlockTemplatesFilesCollection *QETApp::commonTitleBlockTemplatesCollection( } /** - @return the custom title block templates collection, i.e. the one managed - by the end user + @brief QETApp::customTitleBlockTemplatesCollection + @return the custom title block templates collection, + i.e. the one managed by the end user */ TitleBlockTemplatesFilesCollection *QETApp::customTitleBlockTemplatesCollection() { if (!m_custom_tbt_collection) { @@ -482,6 +540,7 @@ TitleBlockTemplatesFilesCollection *QETApp::customTitleBlockTemplatesCollection( } /** + @brief QETApp::availableTitleBlockTemplatesCollections @return the list of all available title block tempaltes collections, beginning with the common and custom ones, plus the projects-embedded ones. */ @@ -499,8 +558,10 @@ QList QETApp::availableTitleBlockTemplatesColle } /** + @brief QETApp::titleBlockTemplatesCollection @param protocol Protocol string - @return the templates collection matching the provided protocol, or 0 if none could be found + @return the templates collection matching the provided protocol, + or 0 if none could be found */ TitleBlockTemplatesCollection *QETApp::titleBlockTemplatesCollection(const QString &protocol) { if (protocol == QETAPP_COMMON_TBT_PROTOCOL) { @@ -517,9 +578,9 @@ TitleBlockTemplatesCollection *QETApp::titleBlockTemplatesCollection(const QStri } /** - * @brief QETApp::commonElementsDir - * @return the dir path of the common elements collection. - */ + @brief QETApp::commonElementsDir + @return the dir path of the common elements collection. +*/ QString QETApp::commonElementsDir() { if (m_user_common_elements_dir.isEmpty()) @@ -561,9 +622,9 @@ QString QETApp::commonElementsDir() } /** - * @brief QETApp::customElementsDir - * @return the dir path of user elements collection ened by a "/" separator - */ + @brief QETApp::customElementsDir + @return the dir path of user elements collection ened by a "/" separator +*/ QString QETApp::customElementsDir() { if (m_user_custom_elements_dir.isEmpty()) @@ -594,10 +655,10 @@ QString QETApp::customElementsDir() } /** - * @brief QETApp::commonElementsDirN - * like QString QETApp::commonElementsDir but without "/" at the end - * @return - */ + @brief QETApp::commonElementsDirN + like QString QETApp::commonElementsDir but without "/" at the end + @return QString path +*/ QString QETApp::commonElementsDirN() { QString path = commonElementsDir(); @@ -606,10 +667,10 @@ QString QETApp::commonElementsDirN() } /** - * @brief QETApp::customElementsDirN - * like QString QETApp::customElementsDir but without "/" at the end - * @return - */ + @brief QETApp::customElementsDirN + like QString QETApp::customElementsDir but without "/" at the end + @return QString path +*/ QString QETApp::customElementsDirN() { QString path = customElementsDir(); @@ -618,10 +679,10 @@ QString QETApp::customElementsDirN() } /** - * @brief QETApp::resetUserElementsDir - * Reset the path of the user common and custom elements dir. - * Use this function when the user path (common and/or custom) change. - */ + @brief QETApp::resetUserElementsDir + Reset the path of the user common and custom elements dir. + Use this function when the user path (common and/or custom) change. +*/ void QETApp::resetUserElementsDir() { m_user_common_elements_dir.clear(); @@ -630,6 +691,7 @@ void QETApp::resetUserElementsDir() } /** + @brief QETApp::commonTitleBlockTemplatesDir @return the path of the directory containing the common title block templates collection. */ @@ -642,7 +704,8 @@ QString QETApp::commonTitleBlockTemplatesDir() { return(QCoreApplication::applicationDirPath() + "/titleblocks/"); #else #ifndef QET_COMMON_COLLECTION_PATH_RELATIVE_TO_BINARY_PATH - // the compile-time option represents a usual path (be it absolute or relative) + // the compile-time option represents a usual path + // (be it absolute or relative) return(QUOTE(QET_COMMON_TBT_PATH)); #else // the compile-time option represents a path relative to the directory that contains the executable binary @@ -652,6 +715,7 @@ QString QETApp::commonTitleBlockTemplatesDir() { } /** + @brief QETApp::customTitleBlockTemplatesDir @return the path of the directory containing the custom title block templates collection. */ @@ -681,12 +745,24 @@ QString QETApp::customTitleBlockTemplatesDir() { } /** - Renvoie le dossier de configuration de QET, c-a-d le chemin du dossier dans - lequel QET lira les informations de configuration et de personnalisation - propres a l'utilisateur courant. Ce dossier est generalement - C:\\Documents And Settings\\utilisateur\\Application Data\\qet sous Windows et - ~/.qet sous les systemes type UNIX. - @return Le chemin du dossier de configuration de QElectroTech + @brief QETApp::configDir + Return the QET configuration folder, i.e. the path to the folder in + which QET will read configuration and customization information + specific to the current user. This file is generally + C:\\Documents And Settings\\user\\Application Data\ qet + on Windows and + ~/.qet + under UNIX-like systems. + \~French Renvoie le dossier de configuration de QET, + c-a-d le chemin du dossier dans lequel QET lira les informations + de configuration et de personnalisation propres a l'utilisateur courant. + Ce dossier est generalement + C:\\Documents And Settings\\utilisateur\\Application Data\\qet + sous Windows et + ~/.qet + sous les systemes type UNIX. + \~ @return The path of the QElectroTech configuration folder + \~French Le chemin du dossier de configuration de QElectroTech */ QString QETApp::configDir() { #ifdef QET_ALLOW_OVERRIDE_CD_OPTION @@ -710,11 +786,20 @@ QString QETApp::configDir() { } /** - Permet de connaitre le chemin absolu du fichier *.elmt correspondant a un - chemin symbolique (du type custom://outils_pervers/sado_maso/contact_bizarre) - @param sym_path Chaine de caracteres representant le chemin absolu du fichier - @return Une chaine de caracteres vide en cas d'erreur ou le chemin absolu du - fichier *.elmt. + @brief QETApp::realPath + Allows you to know the absolute path of the * .elmt file + corresponding to a symbolic path + (of the type custom: // tools_pervers / sado_maso / contact_bizarre) + \~French Permet de connaitre le chemin absolu du fichier *.elmt + correspondant a un chemin symbolique + (du type custom://outils_pervers/sado_maso/contact_bizarre) + \~ @param sym_path + Character string representing the absolute path of the file + \~French Chaine de caracteres representant le chemin absolu du fichier + \~ @return An empty string in case of error or the absolute path + of the * .elmt file. + \~French Une chaine de caracteres vide en cas d'erreur ou + le chemin absolu du fichier *.elmt. */ QString QETApp::realPath(const QString &sym_path) { QString directory; @@ -730,18 +815,30 @@ QString QETApp::realPath(const QString &sym_path) { return(directory + QDir::toNativeSeparators(sym_path.right(sym_path.length() - 9))); } + /** - Construit le chemin symbolique (du type custom://outils_pervers/sado_maso/ - contact_bizarre) correspondant a un fichier. - @param real_path Chaine de caracteres representant le chemin symbolique du fichier - @return Une chaine de caracteres vide en cas d'erreur ou le chemin + @brief QETApp::symbolicPath + Build the symbolic path + (of the type custom: // tools_pervers / sado_maso / contact_bizarre) + corresponding to a file. + \~French Construit le chemin symbolique + (du type custom://outils_pervers/sado_maso/ contact_bizarre) + correspondant a un fichier. + \~ @param real_path : + Character string representing the symbolic path of the file + \~French Chaine de caracteres representant le chemin symbolique du fichier + \~ @return An empty string in case of error + or the path symbolic designating the element. + \~French Une chaine de caracteres vide en cas d'erreur ou le chemin symbolique designant l'element. -*/ + */ QString QETApp::symbolicPath(const QString &real_path) { + // get the common and custom folders // recupere les dossier common et custom QString commond = commonElementsDir(); QString customd = customElementsDir(); QString chemin; + // analyzes the file path passed in parameter // analyse le chemin de fichier passe en parametre if (real_path.startsWith(commond)) { chemin = "common://" + real_path.right(real_path.length() - commond.length()); @@ -752,9 +849,10 @@ QString QETApp::symbolicPath(const QString &real_path) { } /** + @brief QETApp::handledFileExtensions @return the list of file extensions QElectroTech is able to open and supposed to handle. Note they are provided with no leading point. -*/ + */ QStringList QETApp::handledFileExtensions() { static QStringList ext; if (!ext.count()) { @@ -766,7 +864,8 @@ QStringList QETApp::handledFileExtensions() { } /** - @param an URLs list + @brief QETApp::handledFiles + @param urls : URLs list @return the list of filepaths QElectroTech is able to open. */ QStringList QETApp::handledFiles(const QList &urls) { @@ -784,11 +883,17 @@ QStringList QETApp::handledFiles(const QList &urls) { } /** - @param filepath Un chemin de fichier - Note : si filepath est une chaine vide, cette methode retourne 0. - @return le QETDiagramEditor editant le fichier filepath, ou 0 si ce fichier - n'est pas edite par l'application. -*/ + @brief QETApp::diagramEditorForFile + \~French + \~ @param filepath : A file path + \~French Un chemin de fichier + \~ @note if filepath is an empty string, this method returns 0. + \~French si filepath est une chaine vide, cette methode retourne 0. + \~ @return the QETDiagramEditor editing the filepath file, + or 0 if this file is not edited by the application. + \~French le QETDiagramEditor editant le fichier filepath, + ou 0 si ce fichier n'est pas edite par l'application. + */ QETDiagramEditor *QETApp::diagramEditorForFile(const QString &filepath) { if (filepath.isEmpty()) return(nullptr); @@ -803,11 +908,12 @@ QETDiagramEditor *QETApp::diagramEditorForFile(const QString &filepath) { } /** - * @brief QETApp::diagramEditorAncestorOf - * @param child - * @return the parent QETDiagramEditor (or grandparent and so on to any level) of the given child. - * If not return nullptr; - */ + @brief QETApp::diagramEditorAncestorOf + @param child + @return the parent QETDiagramEditor + (or grandparent and so on to any level) of the given child. + If not return nullptr; +*/ QETDiagramEditor *QETApp::diagramEditorAncestorOf (const QWidget *child) { foreach (QETDiagramEditor *qde, QETApp::diagramEditors()) { @@ -821,8 +927,12 @@ QETDiagramEditor *QETApp::diagramEditorAncestorOf (const QWidget *child) #ifdef QET_ALLOW_OVERRIDE_CED_OPTION /** - Redefinit le chemin du dossier des elements communs - @param new_ced Nouveau chemin du dossier des elements communs + @brief QETApp::overrideCommonElementsDir + Redefines the path of the common elements folder + \~French Redefinit le chemin du dossier des elements communs + \~ @param new_ced : + New path of the common elements folder + \~French Nouveau chemin du dossier des elements communs */ void QETApp::overrideCommonElementsDir(const QString &new_ced) { QFileInfo new_ced_info(new_ced); @@ -835,8 +945,10 @@ void QETApp::overrideCommonElementsDir(const QString &new_ced) { #ifdef QET_ALLOW_OVERRIDE_CTBTD_OPTION /** + @brief QETApp::overrideCommonTitleBlockTemplatesDir Define the path of the directory containing the common title block tempaltes collection. + @param new_ctbtd */ void QETApp::overrideCommonTitleBlockTemplatesDir(const QString &new_ctbtd) { QFileInfo new_ctbtd_info(new_ctbtd); @@ -849,8 +961,12 @@ void QETApp::overrideCommonTitleBlockTemplatesDir(const QString &new_ctbtd) { #ifdef QET_ALLOW_OVERRIDE_CD_OPTION /** - Redefinit le chemin du dossier de configuration - @param new_cd Nouveau chemin du dossier de configuration + @brief QETApp::overrideConfigDir + Redefines the path of the configuration folder + \~French Redefinit le chemin du dossier de configuration + \~ @param new_cd : + New path to configuration folder + \~French Nouveau chemin du dossier de configuration */ void QETApp::overrideConfigDir(const QString &new_cd) { QFileInfo new_cd_info(new_cd); @@ -862,8 +978,12 @@ void QETApp::overrideConfigDir(const QString &new_cd) { #endif /** - Redefinit le chemin du dossier contenant les fichiers de langue - @param new_ld Nouveau chemin du dossier contenant les fichiers de langue + @brief QETApp::overrideLangDir + Redefines the path of the folder containing the language files + \~French Redefinit le chemin du dossier contenant les fichiers de langue + \~ @param new_ld : + New path of the folder containing the language files + \~French Nouveau chemin du dossier contenant les fichiers de langue */ void QETApp::overrideLangDir(const QString &new_ld) { QFileInfo new_ld_info(new_ld); @@ -874,8 +994,10 @@ void QETApp::overrideLangDir(const QString &new_ld) { } /** - @return Le chemin du dossier contenant les fichiers de langue -*/ + @brief QETApp::languagesPath + @return The path of the folder containing the language files + \~French Le chemin du dossier contenant les fichiers de langue + */ QString QETApp::languagesPath() { if (!lang_dir.isEmpty()) { return(lang_dir); @@ -885,7 +1007,11 @@ QString QETApp::languagesPath() { return(QCoreApplication::applicationDirPath() + "/lang/"); #else #ifndef QET_LANG_PATH_RELATIVE_TO_BINARY_PATH - // l'option de compilation represente un chemin absolu ou relatif classique + /* the compilation option represents + * a classic absolute or relative path + * l'option de compilation represente + * un chemin absolu ou relatif classique + */ return(QUOTE(QET_LANG_PATH)); #else // l'option de compilation represente un chemin relatif au dossier contenant le binaire executable @@ -896,10 +1022,15 @@ QString QETApp::languagesPath() { } /** - Ferme tous les editeurs - @return true si l'utilisateur a accepte toutes les fermetures, false sinon + @brief QETApp::closeEveryEditor + Close all editors + \~French Ferme tous les editeurs + \~ @return true if the user has accepted all closures, false otherwise + \~French true si l'utilisateur a accepte toutes les fermetures, + false sinon */ bool QETApp::closeEveryEditor() { + // make sure all windows are visible before leaving // s'assure que toutes les fenetres soient visibles avant de quitter restoreEveryEditor(); foreach(QETProject *project, registered_projects_) { @@ -916,17 +1047,17 @@ bool QETApp::closeEveryEditor() { } /** - * @brief QETApp::diagramTextsFont - * The font to use - * By default the font is "sans Serif" and size 9. - * @param size : the size of font - * @return the font to use - */ + @brief QETApp::diagramTextsFont + The font to use + By default the font is "sans Serif" and size 9. + @param size : the size of font + @return the font to use +*/ QFont QETApp::diagramTextsFont(qreal size) { QSettings settings; - //Font to use + //Font to use QString diagram_texts_family = settings.value("diagramfont", "Sans Serif").toString(); qreal diagram_texts_size = settings.value("diagramsize", 9.0).toDouble(); @@ -941,16 +1072,16 @@ QFont QETApp::diagramTextsFont(qreal size) return(diagram_texts_font); } /** - * @brief QETApp::diagramTextsItemFont - * the font for to use in independent text item - * @param size of font - * @return - */ + @brief QETApp::diagramTextsItemFont + the font for to use in independent text item + @param size of font + @return +*/ QFont QETApp::diagramTextsItemFont(qreal size) { QSettings settings; - //Font to use + //Font to use QString diagram_texts_item_family = settings.value("diagramitemfont", "Sans Serif").toString(); qreal diagram_texts_item_size = settings.value("diagramitemsize", 9.0).toDouble(); qreal diagram_texts_item_weight = settings.value("diagramitemweight").toDouble(); @@ -969,15 +1100,15 @@ QFont QETApp::diagramTextsItemFont(qreal size) return(diagram_texts_item_font); } /** - * @brief QETApp::dynamicTextsFont - * the defaukt font of dynamic element text item - * @param size - * @return - */ + @brief QETApp::dynamicTextsFont + the default font of dynamic element text item + @param size + @return dynamic text font with PointSizeF(size) +*/ QFont QETApp::dynamicTextsItemFont(qreal size) { QSettings settings; - //Font to use + //Font to use QFont font_ = diagramTextsItemFont(); if (settings.contains("diagrameditor/dynamic_text_font")) { font_.fromString(settings.value("diagrameditor/dynamic_text_font").toString()); @@ -991,15 +1122,15 @@ QFont QETApp::diagramTextsItemFont(qreal size) /** - * @brief QETApp::indiTextsItemFont - * The default font to use for independent text item - * @param size - * @return - */ + @brief QETApp::indiTextsItemFont + The default font to use for independent text item + @param size + @return independent text font with PointSizeF(size) +*/ QFont QETApp::indiTextsItemFont(qreal size) { QSettings settings; - //Font to use + //Font to use QFont font_ = diagramTextsItemFont(); if (settings.contains("diagrameditor/independent_text_font")) { font_.fromString(settings.value("diagrameditor/independent_text_font").toString()); @@ -1010,22 +1141,26 @@ QFont QETApp::indiTextsItemFont(qreal size) return(font_); } - /** - @return les editeurs de schemas + @brief QETApp::diagramEditors + @return schema editors + \~French les editeurs de schemas */ QList QETApp::diagramEditors() { return(QETApp::instance() -> detectWindows()); } /** - @return les editeurs d'elements + @brief QETApp::elementEditors + @return element editors + \~French les editeurs d'elements */ QList QETApp::elementEditors() { return(QETApp::instance() -> detectWindows()); } /** + @brief QETApp::titleBlockTemplateEditors @return the title block template editors */ QList QETApp::titleBlockTemplateEditors() { @@ -1033,6 +1168,7 @@ QList QETApp::titleBlockTemplateEditors() { } /** + @brief QETApp::titleBlockTemplateEditors @param project Opened project object. @return the list of title block template editors which are currently editing a template embedded within \a project. @@ -1052,14 +1188,19 @@ QList QETApp::titleBlockTemplateEditors(QETProjec } /** - Instancie un QTextOrientationSpinBoxWidget et configure : + @brief QETApp::createTextOrientationSpinBoxWidget + Instantiates a QTextOrientationSpinBoxWidget and configures: + * his font + * his strings + \~French Instancie un QTextOrientationSpinBoxWidget et configure : * sa police de caracteres * ses chaines de caracteres - A noter que la suppression du widget ainsi alloue est a la charge de - l'appelant. - @return un QTextOrientationSpinBoxWidget adapte pour une utilisation - "directe" dans QET. - @see QTextOrientationSpinBoxWidget + \~ @note that the deletion of the widget thus allocated is the + responsibility of the caller. + \~French que la suppression du widget ainsi alloue est a la charge + de l'appelant. + \~ @return + \~ @see QTextOrientationSpinBoxWidget */ QTextOrientationSpinBoxWidget *QETApp::createTextOrientationSpinBoxWidget() { QTextOrientationSpinBoxWidget *widget = new QTextOrientationSpinBoxWidget(); @@ -1075,6 +1216,7 @@ QTextOrientationSpinBoxWidget *QETApp::createTextOrientationSpinBoxWidget() { } /** + @brief QETApp::defaultTitleBlockTemplate @return the default titleblock template for diagrams */ TitleBlockTemplate *QETApp::defaultTitleBlockTemplate() { @@ -1087,21 +1229,27 @@ TitleBlockTemplate *QETApp::defaultTitleBlockTemplate() { return(default_titleblock_template_); } - /** - @param project un projet - @return les editeurs d'elements editant un element appartenant au projet - project + @brief QETApp::elementEditors + @param project : a project + \~French un projet + \~ @return element editors editing + an element belonging to the QETProject project + \~French les editeurs d'elements editant un element appartenant + au projet project */ QList QETApp::elementEditors(QETProject *project) { QList editors; if (!project) return(editors); + // for each element editor ... // pour chaque editeur d'element... foreach(QETElementEditor *elmt_editor, elementEditors()) { + // we retrieve the location of the element it edits // on recupere l'emplacement de l'element qu'il edite ElementsLocation elmt_editor_loc(elmt_editor -> location()); + // the editor may edit an unsaved item or a file // il se peut que l'editeur edite un element non enregistre ou un fichier if (elmt_editor_loc.isNull()) continue; @@ -1112,11 +1260,13 @@ QList QETApp::elementEditors(QETProject *project) { return(editors); } + /** - * @brief QETApp::receiveMessage - * @param instanceId - * @param message - */ + @brief QETApp::receiveMessage + openFiles from message + @param instanceId Q_UNUSED + @param message +*/ void QETApp::receiveMessage(int instanceId, QByteArray message) { Q_UNUSED(instanceId); @@ -1157,23 +1307,32 @@ template void QETApp::setMainWindowsVisible(bool visible) { } /** - @return La liste des fichiers recents pour les projets + @brief QETApp::projectsRecentFiles + @return The list of recent files for projects + \~French La liste des fichiers recents pour les projets */ RecentFiles *QETApp::projectsRecentFiles() { return(m_projects_recent_files); } /** - @return La liste des fichiers recents pour les elements + @brief QETApp::elementsRecentFiles + @return The list of recent files for the elements + \~French La liste des fichiers recents pour les elements */ RecentFiles *QETApp::elementsRecentFiles() { return(m_elements_recent_files); } /** - Affiche ou cache une fenetre (editeurs de schemas / editeurs d'elements) - @param window fenetre a afficher / cacher - @param visible true pour affiche la fenetre, false sinon + @brief QETApp::setMainWindowVisible + Show or hide a window (schema editors / element editors) + \~French Affiche ou cache une fenetre + (editeurs de schemas / editeurs d'elements) + \~ @param window : window to show / hide + \~French fenetre a afficher / cacher + \~ @param visible : true to display the window, false otherwise + \~French true pour affiche la fenetre, false sinon */ void QETApp::setMainWindowVisible(QMainWindow *window, bool visible) { if (window -> isVisible() == visible) return; @@ -1195,9 +1354,13 @@ void QETApp::setMainWindowVisible(QMainWindow *window, bool visible) { } /** - Affiche une fenetre (editeurs de schemas / editeurs d'elements) si - celle-ci est cachee ou la cache si elle est affichee. - @param window fenetre a afficher / cacher + @brief QETApp::invertMainWindowVisibility + Display a window (schema editors / element editors) + if this is hidden or hides it if it is displayed. + \~French Affiche une fenetre (editeurs de schemas / editeurs d'elements) + si celle-ci est cachee ou la cache si elle est affichee. + \~ @param window : window to show / hide + \~French fenetre a afficher / cacher */ void QETApp::invertMainWindowVisibility(QWidget *window) { if (QMainWindow *w = qobject_cast(window)) setMainWindowVisible(w, !w -> isVisible()); @@ -1220,10 +1383,14 @@ if defined(Q_OS_WIN) style = QLatin1String("Windows"); // default styles for Windows #endif - /** - Change la palette de l'application - @param use true pour utiliser les couleurs du systeme, false pour utiliser celles du theme en cours + @brief QETApp::useSystemPalette + Change the application palette + \~French Change la palette de l'application + \~ @param use : + true to use the system colors, false to use those of the current theme + \~French true pour utiliser les couleurs du systeme, + false pour utiliser celles du theme en cours */ void QETApp::useSystemPalette(bool use) { if (use) { @@ -1243,23 +1410,35 @@ void QETApp::useSystemPalette(bool use) { } /** - Demande la fermeture de toutes les fenetres ; si l'utilisateur les accepte, - l'application quitte + @brief QETApp::quitQET + Request the closing of all windows; + if the user accepts them, the application quits + \~French Demande la fermeture de toutes les fenetres ; + si l'utilisateur les accepte, l'application quitte */ void QETApp::quitQET() { +#pragma message("@TODO Segmentation fault when closing program before loading elements is finished") if (closeEveryEditor()) { qApp->quit(); } } /** - Verifie s'il reste des fenetres (cachees ou non) et quitte s'il n'en reste - plus. + @brief QETApp::checkRemainingWindows + Check if there are any windows (hidden or not) + and exit if there are no more. + \~French Verifie s'il reste des fenetres (cachees ou non) + et quitte s'il n'en reste plus. */ void QETApp::checkRemainingWindows() { - /* petite bidouille : le slot se rappelle apres 500 ms d'attente - afin de compenser le fait que certaines fenetres peuvent encore - paraitre vivantes alors qu'elles viennent d'etre fermees + /* little hack: + * the slot remembers after 500 ms of waiting in order to compensate + * for the fact that some windows can still appear alive when they + * have just been closed + * petite bidouille : + * le slot se rappelle apres 500 ms d'attente afin de compenser + * le fait que certaines fenetres peuvent encore paraitre vivantes + * alors qu'elles viennent d'etre fermees */ static bool sleep = true; if (sleep) { @@ -1273,9 +1452,13 @@ void QETApp::checkRemainingWindows() { } /** - Ouvre les fichiers passes en arguments - @param args Objet contenant des arguments ; les fichiers - @see openProjectFiles openElementFiles + @brief QETApp::openFiles + Open files passed as arguments + \~French Ouvre les fichiers passes en arguments + \~ @param args : + Object containing arguments; the files + \~French Objet contenant des arguments ; les fichiers + \~ @see openProjectFiles openElementFiles */ void QETApp::openFiles(const QETArguments &args) { openProjectFiles(args.projectFiles()); @@ -1284,19 +1467,28 @@ void QETApp::openFiles(const QETArguments &args) { } /** - Ouvre une liste de fichiers. - Les fichiers sont ouverts dans le premier editeur de schemas visible venu. - Sinon, le premier editeur de schemas existant venu devient visible et est - utilise. S'il n'y a aucun editeur de schemas ouvert, un nouveau est cree et - utilise. - @param files_list Fichiers a ouvrir + @brief QETApp::openProjectFiles + Opens a list of files. + Files are opened in the first visible schematic editor. + Otherwise, the first existing schema editor becomes visible and is uses. + If there is no schematic editor open, a new one is created and uses. + \~French Ouvre une liste de fichiers. + Les fichiers sont ouverts dans le premier editeur de schemas visible + venu. Sinon, le premier editeur de schemas existant venu devient + visible et est utilise. S'il n'y a aucun editeur de schemas ouvert, + un nouveau est cree et utilise. + \~ @param files_list : + Files to open + \~French Fichiers a ouvrir */ void QETApp::openProjectFiles(const QStringList &files_list) { if (files_list.isEmpty()) return; + // list of open schema editors // liste des editeurs de schema ouverts QList diagrams_editors = diagramEditors(); + // if there are open diagram editors, we look for those that are visible // s'il y a des editeur de schemas ouvert, on cherche ceux qui sont visibles if (diagrams_editors.count()) { QList visible_diagrams_editors; @@ -1304,6 +1496,7 @@ void QETApp::openProjectFiles(const QStringList &files_list) { if (de -> isVisible()) visible_diagrams_editors << de; } + // we choose either the first visible or the very first // on choisit soit le premier visible soit le premier tout court QETDiagramEditor *de_open; if (visible_diagrams_editors.count()) { @@ -1313,41 +1506,52 @@ void QETApp::openProjectFiles(const QStringList &files_list) { de_open -> setVisible(true); } + // opens the files in the editor thus chosen // ouvre les fichiers dans l'editeur ainsi choisi foreach(QString file, files_list) { de_open -> openAndAddProject(file); } } else { + // create a new editor that will open the files // cree un nouvel editeur qui ouvrira les fichiers new QETDiagramEditor(files_list); } } /** - Ouvre les fichiers elements passes en parametre. Si un element est deja - ouvert, la fenetre qui l'edite est activee. - @param files_list Fichiers a ouvrir + @brief QETApp::openElementFiles + Open the elements files passed in parameter. + If an element is already open, the window which edits it is activated. + \~French Ouvre les fichiers elements passes en parametre. + Si un element est deja ouvert, la fenetre qui l'edite est activee. + \~ @param files_list : Files to open + \~French Fichiers a ouvrir */ void QETApp::openElementFiles(const QStringList &files_list) { if (files_list.isEmpty()) return; + // avoid as much as possible duplicates in the list provided // evite autant que possible les doublons dans la liste fournie QSet files_set; foreach(QString file, files_list) { QString canonical_filepath = QFileInfo(file).canonicalFilePath(); if (!canonical_filepath.isEmpty()) files_set << canonical_filepath; } + // at this stage, all the files in the Set exist and are a priori different // a ce stade, tous les fichiers dans le Set existent et sont a priori differents if (files_set.isEmpty()) return; + // list of open item editors // liste des editeurs d'element ouverts QList element_editors = elementEditors(); + // we process the files one after the other ... // on traite les fichiers a la queue leu leu... foreach(QString element_file, files_set) { bool already_opened_in_existing_element_editor = false; foreach(QETElementEditor *element_editor, element_editors) { if (element_editor -> isEditing(element_file)) { + // this file is already open in an editor // ce fichier est deja ouvert dans un editeur already_opened_in_existing_element_editor = true; element_editor -> setVisible(true); @@ -1357,6 +1561,7 @@ void QETApp::openElementFiles(const QStringList &files_list) { } } if (!already_opened_in_existing_element_editor) { + // this file is not open in any editor // ce fichier n'est ouvert dans aucun editeur QETElementEditor *element_editor = new QETElementEditor(); element_editor -> fromFile(element_file); @@ -1365,21 +1570,28 @@ void QETApp::openElementFiles(const QStringList &files_list) { } /** - Ouvre les elements dont l'emplacement est passe en parametre. Si un element - est deja ouvert, la fentre qui l'edite est activee. - @param locations_list Emplacements a ouvrir + @brief QETApp::openElementLocations + Open the elements whose location is passed in parameter. If an element + is already open, the window which is edited is active. + \~French Ouvre les elements dont l'emplacement est passe en parametre. + Si un element est deja ouvert, la fentre qui l'edite est activee. + \~ @param locations_list : Locations to open + \~French Emplacements a ouvrir */ void QETApp::openElementLocations(const QList &locations_list) { if (locations_list.isEmpty()) return; + // list of open item editors // liste des editeurs d'element ouverts QList element_editors = elementEditors(); + // we treat the sites in a single file ... // on traite les emplacements a la queue leu leu... foreach(ElementsLocation element_location, locations_list) { bool already_opened_in_existing_element_editor = false; foreach(QETElementEditor *element_editor, element_editors) { if (element_editor -> isEditing(element_location)) { + // this location is already open in an editor // cet emplacement est deja ouvert dans un editeur already_opened_in_existing_element_editor = true; element_editor -> setVisible(true); @@ -1389,6 +1601,7 @@ void QETApp::openElementLocations(const QList &locations_list) } } if (!already_opened_in_existing_element_editor) { + // this location is not open in any editor // cet emplacement n'est ouvert dans aucun editeur QETElementEditor *element_editor = new QETElementEditor(); element_editor -> fromLocation(element_location); @@ -1397,11 +1610,12 @@ void QETApp::openElementLocations(const QList &locations_list) } /** + @brief QETApp::openTitleBlockTemplate Launch a new title block template editor to edit the given template @param location location of the title block template to be edited - @param duplicate if true, the template is opened for duplication, which means - the user will be prompter for a new template name. + @param duplicate if true, the template is opened for duplication, + which means the user will be prompter for a new template name. @see QETTitleBlockTemplateEditor::setOpenForDuplication() */ void QETApp::openTitleBlockTemplate(const TitleBlockTemplateLocation &location, bool duplicate) { @@ -1412,6 +1626,7 @@ void QETApp::openTitleBlockTemplate(const TitleBlockTemplateLocation &location, } /** + @brief QETApp::openTitleBlockTemplate Launch a new title block template editor to edit the given template @param filepath Path of the .titleblock file to be opened */ @@ -1422,8 +1637,10 @@ void QETApp::openTitleBlockTemplate(const QString &filepath) { } /** - Open provided title block template files. If a title block template is already - opened, the adequate window is activated. + @brief QETApp::openTitleBlockTemplateFiles + Open provided title block template files. + If a title block template is already opened, + the adequate window is activated. @param files_list Files to be opened */ void QETApp::openTitleBlockTemplateFiles(const QStringList &files_list) { @@ -1461,13 +1678,18 @@ void QETApp::openTitleBlockTemplateFiles(const QStringList &files_list) { } /** - Permet a l'utilisateur de configurer QET en lancant un dialogue approprie. - @see ConfigDialog + @brief QETApp::configureQET + Allows the user to configure QET by launching an appropriate dialog. + \~French Permet a l'utilisateur de configurer QET + en lancant un dialogue approprie. + \~ @see ConfigDialog */ void QETApp::configureQET() { + // determine the parent widget to use for the dialog // determine le widget parent a utiliser pour le dialogue QWidget *parent_widget = qApp->activeWindow(); + // create dialogue // cree le dialogue ConfigDialog cd; cd.setWindowTitle(tr("Configurer QElectroTech", "window title")); @@ -1477,21 +1699,22 @@ void QETApp::configureQET() { cd.addPage(new ExportConfigPage()); cd.addPage(new PrintConfigPage()); - + // associates the dialog with a possible parent widget // associe le dialogue a un eventuel widget parent if (parent_widget) { cd.setParent(parent_widget, cd.windowFlags()); } + // display the dialog then avoid linking it to any parent widget // affiche le dialogue puis evite de le lier a un quelconque widget parent cd.exec(); cd.setParent(nullptr, cd.windowFlags()); } /** - * @brief QETApp::aboutQET - * Open the dialog about qet. - */ + @brief QETApp::aboutQET + Open the dialog about qet. +*/ void QETApp::aboutQET() { AboutQETDialog aqd(qApp->activeWindow()); @@ -1502,8 +1725,13 @@ void QETApp::aboutQET() } /** - @param window fenetre dont il faut trouver les barres d'outils et dock flottants - @return les barres d'outils et dock flottants de la fenetre + @brief QETApp::floatingToolbarsAndDocksForMainWindow + \~French + \~ @param window : + window where you have to find the toolbars and floating dock + \~French fenetre dont il faut trouver les barres d'outils et dock flottants + \~ @return the window's toolbars and floating dock + \~French les barres d'outils et dock flottants de la fenetre */ QList QETApp::floatingToolbarsAndDocksForMainWindow(QMainWindow *window) const { QList widgets; @@ -1516,7 +1744,20 @@ QList QETApp::floatingToolbarsAndDocksForMainWindow(QMainWindow *wind return(widgets); } + /** + @brief QETApp::parseArguments + Parse the following arguments: + * --common-elements-dir= + * --config-dir + * --help + * --version + * -v + * --license + The other arguments are normally file paths. + If they exist, they are just stored in the arguments_files_ attribute. + Otherwise, they are stored in the arguments_options_ attribute. + \~French Parse les arguments suivants : * --common-elements-dir= * --config-dir @@ -1529,12 +1770,15 @@ QList QETApp::floatingToolbarsAndDocksForMainWindow(QMainWindow *wind Sinon, ils sont memorises dans l'attribut arguments_options_. */ void QETApp::parseArguments() { + // get the arguments // recupere les arguments QList arguments_list(qApp->arguments()); + // remove the first argument: this is the binary file // enleve le premier argument : il s'agit du fichier binaire arguments_list.takeFirst(); + // analyze the arguments // analyse les arguments qet_arguments_ = QETArguments(arguments_list); @@ -1573,8 +1817,11 @@ void QETApp::parseArguments() { } /** - Initialise le splash screen si et seulement si l'execution est interactive. - Autrement, l'attribut splash_screen_ vaut 0. + @brief QETApp::initSplashScreen + Initializes the splash screen if and only if the execution is + interactive. Otherwise, the splash_screen_ attribute is 0. + \~French Initialise le splash screen si et seulement si l'execution est + interactive. Autrement, l'attribut splash_screen_ vaut 0. */ void QETApp::initSplashScreen() { if (non_interactive_execution_) return; @@ -1584,9 +1831,15 @@ void QETApp::initSplashScreen() { } /** - Change le texte du splash screen et prend en compte les evenements. - Si l'application s'execute de facon non interactive, cette methode ne fait - rien. + @brief QETApp::setSplashScreenStep + Changes the text of the splash screen and takes events into account. + If the application is running non-interactively, + this method does nothing. + \~French Change le texte du splash screen et prend en compte les + evenements. Si l'application s'execute de facon non interactive, + cette methode ne fait rien. + \~ @param message : the text of the splash screen + \~French */ void QETApp::setSplashScreenStep(const QString &message) { if (!m_splash_screen) return; @@ -1597,16 +1850,18 @@ void QETApp::setSplashScreenStep(const QString &message) { } /** - Determine et applique le langage a utiliser pour l'application + @brief QETApp::initLanguage + Determine and apply the language to use for the application + \~French Determine et applique le langage a utiliser pour l'application */ void QETApp::initLanguage() { setLanguage(langFromSetting()); } /** - * @brief QETApp::initStyle - * Setup the gui style - */ + @brief QETApp::initStyle + Setup the gui style +*/ void QETApp::initStyle() { initial_palette_ = qApp->palette(); @@ -1616,6 +1871,13 @@ void QETApp::initStyle() { } /** + @brief QETApp::initConfiguration + Reads and takes into account the configuration of the application. + This method will create, if necessary: + * the configuration folder + * the folder of the personal collection + * the directory for custom title blocks + \~French Lit et prend en compte la configuration de l'application. Cette methode creera, si necessaire : * le dossier de configuration @@ -1623,6 +1885,7 @@ void QETApp::initStyle() { * the directory for custom title blocks */ void QETApp::initConfiguration() { + // create configuration files if necessary // cree les dossiers de configuration si necessaire QDir config_dir(QETApp::configDir()); if (!config_dir.exists()) config_dir.mkpath(QETApp::configDir()); @@ -1633,8 +1896,16 @@ void QETApp::initConfiguration() { QDir custom_tbt_dir(QETApp::customTitleBlockTemplatesDir()); if (!custom_tbt_dir.exists()) custom_tbt_dir.mkpath(QETApp::customTitleBlockTemplatesDir()); - // fichiers recents - // note : les icones doivent etre initialisees avant ces instructions (qui creent des menus en interne) + /* recent files + * note: + * icons must be initialized before these instructions + * (which create menus internally) + * + * fichiers recents + * note : + * les icones doivent etre initialisees avant ces instructions + * (qui creent des menus en interne) + */ m_projects_recent_files = new RecentFiles("projects"); m_projects_recent_files -> setIconForFiles(QET::Icons::ProjectFile); m_elements_recent_files = new RecentFiles("elements"); @@ -1642,10 +1913,13 @@ void QETApp::initConfiguration() { } /** - Construit l'icone dans le systray et son menu + @brief QETApp::initSystemTray + Build the icon in the systray and its menu + \~French Construit l'icone dans le systray et son menu */ void QETApp::initSystemTray() { setSplashScreenStep(tr("Chargement... icône du systray", "splash screen caption")); + // initialization of the icon menus in the systray // initialisation des menus de l'icone dans le systray menu_systray = new QMenu(tr("QElectroTech", "systray menu title")); @@ -1677,6 +1951,7 @@ void QETApp::initSystemTray() { connect(new_diagram, SIGNAL(triggered()), this, SLOT(newDiagramEditor())); connect(new_element, SIGNAL(triggered()), this, SLOT(newElementEditor())); + // initialization of the systray icon // initialisation de l'icone du systray m_qsti = new QSystemTrayIcon(QET::Icons::QETLogo, this); m_qsti -> setToolTip(tr("QElectroTech", "systray icon tooltip")); @@ -1705,10 +1980,11 @@ template void QETApp::addWindowsListToMenu(QMenu *menu, const QList clear(); + // get editors // recupere les editeurs QList diagrams = diagramEditors(); QList elements = elementEditors(); QList tbtemplates = titleBlockTemplateEditors(); fetchWindowStats(diagrams, elements, tbtemplates); + // add reduce / restore button to menu // ajoute le bouton reduire / restaurer au menu menu_systray -> addAction(every_editor_reduced ? restore_appli : reduce_appli); + // add schema editors in a submenu // ajoute les editeurs de schemas dans un sous-menu QMenu *diagrams_submenu = menu_systray -> addMenu(tr("Éditeurs de schémas")); diagrams_submenu -> addAction(reduce_diagrams); @@ -1756,6 +2040,7 @@ void QETApp::buildSystemTrayMenu() { restore_diagrams -> setEnabled(!diagrams.isEmpty() && !every_diagram_visible); addWindowsListToMenu(diagrams_submenu, diagrams); + // add item editors to the menu // ajoute les editeurs d'elements au menu QMenu *elements_submenu = menu_systray -> addMenu(tr("Éditeurs d'élément")); elements_submenu -> addAction(reduce_elements); @@ -1766,6 +2051,7 @@ void QETApp::buildSystemTrayMenu() { elements_submenu -> addSeparator(); addWindowsListToMenu(elements_submenu, elements); + // add title block template editors in a submenu // add title block template editors in a submenu QMenu *tbtemplates_submenu = menu_systray -> addMenu(tr("Éditeurs de cartouche", "systray menu entry")); tbtemplates_submenu -> addAction(reduce_templates); @@ -1774,16 +2060,17 @@ void QETApp::buildSystemTrayMenu() { restore_templates -> setEnabled(!tbtemplates.isEmpty() && !every_template_visible); addWindowsListToMenu(tbtemplates_submenu, tbtemplates); + // add the exit button to the menu // ajoute le bouton quitter au menu menu_systray -> addSeparator(); menu_systray -> addAction(quitter_qet); } /** - * @brief QETApp::checkBackupFiles - * Check for backup files. - * If backup was found, open a dialog and ask user what to do. - */ + @brief QETApp::checkBackupFiles + Check for backup files. + If backup was found, open a dialog and ask user what to do. +*/ void QETApp::checkBackupFiles() { QList stale_files = KAutoSaveFile::allStaleFiles(); @@ -1794,7 +2081,10 @@ void QETApp::checkBackupFiles() { for (QETProject *project : registeredProjects().values()) { - //We must to adjust with the flag QUrl::StripTrailingSlash to compar a path formated like the path returned by KAutoSaveFile + /* We must to adjust with the flag + * QUrl::StripTrailingSlash to compar a path formated + * like the path returned by KAutoSaveFile + */ const QString path = QUrl::fromLocalFile(project->filePath()).adjusted(QUrl::RemoveScheme | QUrl::StripTrailingSlash).path(); if (kasf->managedFile() == path) { stale_files.removeOne(kasf); @@ -1824,10 +2114,10 @@ void QETApp::checkBackupFiles() #endif } - //Open backup file + //Open backup file if (QET::QetMessageBox::question(nullptr, tr("Fichier de restauration"), text, QMessageBox::Ok|QMessageBox::Cancel) == QMessageBox::Ok) { - //If there is opened editors, we find those who are visible + //If there is opened editors, we find those who are visible if (diagramEditors().count()) { diagramEditors().first()->setVisible(true); @@ -1841,7 +2131,7 @@ void QETApp::checkBackupFiles() } else //Clear backup file { - //Remove the stale files + //Remove the stale files for (KAutoSaveFile *stale : stale_files) { stale->open(QIODevice::ReadWrite); @@ -1850,18 +2140,27 @@ void QETApp::checkBackupFiles() } } -/// Met a jour les booleens concernant l'etat des fenetres +/** + @brief QETApp::fetchWindowStats + Updates the booleans concerning the state of the windows + \~French Met a jour les booleens concernant l'etat des fenetres + \~ @param diagrams : QList + \~ @param elements : QList + \~ @param tbtemplates : QList + */ void QETApp::fetchWindowStats( const QList &diagrams, const QList &elements, const QList &tbtemplates ) { + // count the number of visible diagrams // compte le nombre de schemas visibles int visible_diagrams = 0; foreach(QMainWindow *w, diagrams) if (w -> isVisible()) ++ visible_diagrams; every_diagram_reduced = !visible_diagrams; every_diagram_visible = visible_diagrams == diagrams.count(); + // count the number of visible elements // compte le nombre de schemas visibles int visible_elements = 0; foreach(QMainWindow *w, elements) if (w -> isVisible()) ++ visible_elements; @@ -1876,6 +2175,7 @@ void QETApp::fetchWindowStats( every_template_reduced = !visible_templates; every_template_visible = visible_templates == tbtemplates.count(); + // determines if all elements are reduced // determine si tous les elements sont reduits every_editor_reduced = every_element_reduced && every_diagram_reduced; } @@ -1899,7 +2199,9 @@ bool QETApp::eventFiltrer(QObject *object, QEvent *e) { #endif /** - Affiche l'aide et l'usage sur la sortie standard + @brief QETApp::printHelp + Display help and usage on standard output + \~French Affiche l'aide et l'usage sur la sortie standard */ void QETApp::printHelp() { QString help( @@ -1924,62 +2226,89 @@ void QETApp::printHelp() { } /** - Affiche la version sur la sortie standard + @brief QETApp::printVersion + Print version to standard output + \~French Affiche la version sur la sortie standard */ void QETApp::printVersion() { std::cout << qPrintable(QET::displayedVersion) << std::endl; } /** - Affiche la licence sur la sortie standard + @brief QETApp::printLicense + Display license on standard output + \~French Affiche la licence sur la sortie standard */ void QETApp::printLicense() { std::cout << qPrintable(QET::license()) << std::endl; } /** - @return la liste des projets avec leurs ids associes + @brief QETApp::registeredProjects + @return the list of projects with their associated ids + \~French la liste des projets avec leurs ids associes */ QMap QETApp::registeredProjects() { return(registered_projects_); } /** - @param project Projet a enregistrer aupres de l'application - @return true si le projet a pu etre enregistre, false sinon + @brief QETApp::registerProject + \~ @param project : + Project to register with the application + \~French Projet a enregistrer aupres de l'application + \~ @return true if the project could be saved, false otherwise + Failure to save a project usually means that it is already saved. + \~French true si le projet a pu etre enregistre, false sinon L'echec de l'enregistrement d'un projet signifie generalement qu'il est deja enregistre. */ bool QETApp::registerProject(QETProject *project) { + // the project must seem valid // le projet doit sembler valide if (!project) return(false); + // if the project is already saved, returns false // si le projet est deja enregistre, renvoie false if (projectId(project) != -1) return(false); + // save the project // enregistre le projet registered_projects_.insert(next_project_id ++, project); return(true); } /** - Annule l'enregistrement du projet project - @param project Projet dont il faut annuler l'enregistrement - @return true si l'annulation a reussi, false sinon - L'echec de cette methode signifie generalement que le projet n'etait pas enregistre. + @brief QETApp::unregisterProject + Cancel the recording of the project project + \~French Annule l'enregistrement du projet project + \~ @param project : + Project to be unregistered + \~French Projet dont il faut annuler l'enregistrement + \~ @return true if the cancellation was successful, false otherwise + The failure of this method usually means that the project was not saved. + \~French true si l'annulation a reussi, false sinon L'echec de cette + methode signifie generalement que le projet n'etait pas enregistre. */ bool QETApp::unregisterProject(QETProject *project) { int project_id = projectId(project); + // if the project is not saved, returns false // si le projet n'est pas enregistre, renvoie false if (project_id == -1) return(false); + // cancels the registration of the project // annule l'enregistrement du projet return(registered_projects_.remove(project_id) == 1); } /** - @param id Id du projet voulu - @return le projet correspond a l'id passe en parametre + @brief QETApp::project + \~French + \~ @param id : + Id of the desired project + \~French Id du projet voulu + \~ @return the project corresponds to the id passed in parameter + \~French le projet correspond a l'id passe en parametre */ QETProject *QETApp::project(const uint &id) { if (registered_projects_.contains(id)) { @@ -1990,8 +2319,13 @@ QETProject *QETApp::project(const uint &id) { } /** - @param project Projet dont on souhaite recuperer l'id - @return l'id du projet en parametre si celui-ci est enregistre, -1 sinon + @brief QETApp::projectId + \~French + \~ @param project : + Project whose id we want to retrieve + \~French Projet dont on souhaite recuperer l'id + \~ @return the project id as a parameter if it is saved, -1 otherwise + \~French l'id du projet en parametre si celui-ci est enregistre, -1 sinon */ int QETApp::projectId(const QETProject *project) { foreach(int id, registered_projects_.keys()) { diff --git a/sources/qetapp.h b/sources/qetapp.h index f324ac6d9..ba1788d0f 100644 --- a/sources/qetapp.h +++ b/sources/qetapp.h @@ -48,6 +48,7 @@ class QTextOrientationSpinBoxWidget; class RecentFiles; /** + @brief The QETApp class This class represents the QElectroTech application. */ class QETApp : public QObject @@ -112,26 +113,44 @@ class QETApp : public QObject public: static void overrideCommonElementsDir(const QString &); private: - static QString common_elements_dir; ///< Directory containing the common elements collection + /** + @brief common_elements_dir + Directory containing the common elements collection + */ + static QString common_elements_dir; #endif #ifdef QET_ALLOW_OVERRIDE_CTBTD_OPTION public: static void overrideCommonTitleBlockTemplatesDir(const QString &); private: - static QString common_tbt_dir_; ///< Directory containing the common title block templates collection + /** + @brief common_tbt_dir_ + Directory containing + the common title block templates collection + */ + static QString common_tbt_dir_; #endif #ifdef QET_ALLOW_OVERRIDE_CD_OPTION public: static void overrideConfigDir(const QString &); private: - static QString config_dir; ///< Directory containing the user configuration and the custom elements collection + /** + @brief config_dir + Directory containing the user configuration + and the custom elements collection + */ + static QString config_dir; #endif public: static void overrideLangDir(const QString &); - static QString lang_dir; ///< Directory containing localization files. + /** + @brief lang_dir + Directory containing localization files. + */ + static QString lang_dir; static QFont diagramTextsFont(qreal = -1.0); static QFont diagramTextsItemFont(qreal = -1.0); static QFont dynamicTextsItemFont(qreal = -1.0); @@ -181,9 +200,14 @@ class QETApp : public QObject bool every_template_reduced; bool every_template_visible; QSignalMapper signal_map; - QETArguments qet_arguments_; ///< Comand-line arguments parser - bool non_interactive_execution_; ///< Whether the application will end without any user interaction - QPalette initial_palette_; ///< System color palette + QETArguments qet_arguments_; ///< Comand-line arguments parser + /** + @brief non_interactive_execution_ + Whether the application will end + without any user interaction + */ + bool non_interactive_execution_; + QPalette initial_palette_; ///< System color palette static TitleBlockTemplatesFilesCollection *m_common_tbt_collection; static TitleBlockTemplatesFilesCollection *m_custom_tbt_collection;