diff --git a/ico/16x16/preferences-desktop-user.png b/ico/16x16/preferences-desktop-user.png new file mode 100644 index 000000000..346f21e7b Binary files /dev/null and b/ico/16x16/preferences-desktop-user.png differ diff --git a/ico/22x22/preferences-desktop-user.png b/ico/22x22/preferences-desktop-user.png new file mode 100644 index 000000000..d95b259ab Binary files /dev/null and b/ico/22x22/preferences-desktop-user.png differ diff --git a/qelectrotech.qrc b/qelectrotech.qrc index ebf6f384a..7824abad1 100644 --- a/qelectrotech.qrc +++ b/qelectrotech.qrc @@ -55,6 +55,7 @@ ico/16x16/object-rotate-right.png ico/16x16/orientations.png ico/16x16/phase.png + ico/16x16/preferences-desktop-user.png ico/16x16/project.png ico/16x16/qet.png ico/16x16/remove_col.png @@ -129,6 +130,7 @@ ico/22x22/object-unlocked.png ico/22x22/polygon.png ico/22x22/portrait.png + ico/22x22/preferences-desktop-user.png ico/22x22/raise.png ico/22x22/rectangle.png ico/22x22/restaurer.png diff --git a/sources/editor/editorcommands.cpp b/sources/editor/editorcommands.cpp index c42cce446..65618d128 100644 --- a/sources/editor/editorcommands.cpp +++ b/sources/editor/editorcommands.cpp @@ -590,3 +590,32 @@ void AllowInternalConnectionsCommand::undo() { void AllowInternalConnectionsCommand::redo() { element -> setInternalConnections(ic); } + +/** + Constructeur + @param elmt ElementScene concernee + @param old_infos Informations complementaires precedentes + @param old_infos Nouvelles informations complementaires + @param parent QUndoCommand parent +*/ +ChangeInformationsCommand::ChangeInformationsCommand(ElementScene *elmt, const QString &old_infos, const QString &new_infos, QUndoCommand *parent) : + QUndoCommand(QObject::tr("modification informations complementaires", "undo caption"), parent), + element(elmt), + old_informations_(old_infos), + new_informations_(new_infos) +{ +} + +/// Destructeur +ChangeInformationsCommand::~ChangeInformationsCommand() { +} + +/// Annule le changement d'autorisation pour les connexions internes +void ChangeInformationsCommand::undo() { + element -> setInformations(old_informations_); +} + +/// Refait le changement d'autorisation pour les connexions internes +void ChangeInformationsCommand::redo() { + element -> setInformations(new_informations_); +} diff --git a/sources/editor/editorcommands.h b/sources/editor/editorcommands.h index b9f1c45f9..9b58a7a92 100644 --- a/sources/editor/editorcommands.h +++ b/sources/editor/editorcommands.h @@ -356,4 +356,31 @@ class AllowInternalConnectionsCommand : public QUndoCommand { /// autorisation des connexions internes apres modification bool ic; }; + +/** + Cette classe represente l'action de changer les informations + complementaires d'un element. +*/ +class ChangeInformationsCommand : public QUndoCommand { + // constructeurs, destructeur + public: + ChangeInformationsCommand(ElementScene *, const QString &, const QString &, QUndoCommand * = 0); + virtual ~ChangeInformationsCommand(); + private: + ChangeInformationsCommand(const ChangeInformationsCommand &); + + // methodes + public: + virtual void undo(); + virtual void redo(); + + // attributs + private: + /// Element edite auquel il faut appliquer les modifications + ElementScene *element; + /// Informations avant modification + QString old_informations_; + /// Informations apres modification + QString new_informations_; +}; #endif diff --git a/sources/editor/elementscene.cpp b/sources/editor/elementscene.cpp index da0f1f394..3384ddaa0 100644 --- a/sources/editor/elementscene.cpp +++ b/sources/editor/elementscene.cpp @@ -559,6 +559,11 @@ const QDomDocument ElementScene::toXml(bool all_parts) const { // noms de l'element root.appendChild(_names.toXml(xml_document)); + // informations complementaires de l'element + QDomElement informations_element = xml_document.createElement("informations"); + root.appendChild(informations_element); + informations_element.appendChild(xml_document.createTextNode(informations())); + QDomElement description = xml_document.createElement("description"); // description de l'element foreach(QGraphicsItem *qgi, zItems(true)) { @@ -887,6 +892,50 @@ void ElementScene::slot_editOrientations() { } } +/** + Lance un dialogue pour editer les informations complementaires de cet + element. Concretement, ce champ libre est destine a accueillir des informations + sur l'auteur de l'element, sa licence, etc. +*/ +void ElementScene::slot_editAuthorInformations() { + + // cree un dialogue + QDialog dialog_author(element_editor); + dialog_author.setModal(true); +#ifdef Q_WS_MAC + dialog_author.setWindowFlags(Qt::Sheet); +#endif + dialog_author.setMinimumSize(400, 260); + dialog_author.setWindowTitle(tr("\311diter les informations sur l'auteur", "window title")); + QVBoxLayout *dialog_layout = new QVBoxLayout(&dialog_author); + + // ajoute un champ explicatif au dialogue + QLabel *information_label = new QLabel(tr("Vous pouvez utiliser ce champ libre pour mentionner les auteurs de l'\351l\351ment, sa licence, ou tout autre renseignement que vous jugerez utile.")); + information_label -> setAlignment(Qt::AlignJustify | Qt::AlignVCenter); + information_label -> setWordWrap(true); + dialog_layout -> addWidget(information_label); + + // ajoute un QTextEdit au dialogue + QTextEdit *text_field = new QTextEdit(); + text_field -> setAcceptRichText(false); + text_field -> setPlainText(informations()); + dialog_layout -> addWidget(text_field); + + // ajoute deux boutons au dialogue + QDialogButtonBox *dialog_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + dialog_layout -> addWidget(dialog_buttons); + connect(dialog_buttons, SIGNAL(accepted()), &dialog_author, SLOT(accept())); + connect(dialog_buttons, SIGNAL(rejected()), &dialog_author, SLOT(reject())); + + // lance le dialogue + if (dialog_author.exec() == QDialog::Accepted) { + QString new_infos = text_field -> toPlainText(); + if (new_infos != informations()) { + undoStack().push(new ChangeInformationsCommand(this, informations(), new_infos)); + } + } +} + /** Lance un dialogue pour editer les noms de cet element */ @@ -1044,7 +1093,7 @@ QRectF ElementScene::elementContentBoundingRect(const ElementContent &content) { /** Applique les informations (dimensions, hostpot, orientations, connexions - internes et noms) contenu dans un document XML. + internes, noms et informations complementaires) contenu dans un document XML. @param xml_document Document XML a analyser @param error_message pointeur vers une QString ; si error_message est different de 0, un message d'erreur sera stocke dedans si necessaire @@ -1093,6 +1142,16 @@ bool ElementScene::applyInformations(const QDomDocument &xml_document, QString * // extrait les noms de la definition XML _names.fromXml(root); + // extrait les informations complementaires + for (QDomNode node = root.firstChild() ; !node.isNull() ; node = node.nextSibling()) { + QDomElement elmt = node.toElement(); + if (elmt.isNull()) continue; + if (elmt.tagName() == "informations") { + setInformations(elmt.text()); + break; + } + } + return(true); } diff --git a/sources/editor/elementscene.h b/sources/editor/elementscene.h index 9ed1e71a0..757ad9bb2 100644 --- a/sources/editor/elementscene.h +++ b/sources/editor/elementscene.h @@ -64,6 +64,8 @@ class ElementScene : public QGraphicsScene { OrientationSet ori; /// booleen indiquant si les bornes de l'element peuvent etre reliees a des bornes de ce meme element bool internal_connections; + /// Chaine contenant les informations complementaires de l'element + QString informations_; /// Gestionnaire de QGraphicsItem QGIManager qgi_manager; /// Pile des actions annulables @@ -114,6 +116,8 @@ class ElementScene : public QGraphicsScene { void setOrientations(const OrientationSet &); bool internalConnections(); void setInternalConnections(bool); + QString informations() const; + void setInformations(const QString &); virtual int xGrid() const; virtual int yGrid() const; virtual void setGrid(int, int); @@ -175,6 +179,7 @@ class ElementScene : public QGraphicsScene { void slot_editSizeHotSpot(); void slot_editNames(); void slot_editOrientations(); + void slot_editAuthorInformations(); void slot_bringForward(); void slot_raise(); void slot_lower(); @@ -284,4 +289,18 @@ inline void ElementScene::setInternalConnections(bool ic) { internal_connections = ic; } +/** + @return les informations complementaires de cet element +*/ +inline QString ElementScene::informations() const { + return(informations_); +} + +/** + @param infos les nouvelles informations complementaires de cet element +*/ +inline void ElementScene::setInformations(const QString &infos) { + informations_ = infos; +} + #endif diff --git a/sources/editor/qetelementeditor.cpp b/sources/editor/qetelementeditor.cpp index b57f0d7d6..144257b9b 100644 --- a/sources/editor/qetelementeditor.cpp +++ b/sources/editor/qetelementeditor.cpp @@ -96,6 +96,7 @@ void QETElementEditor::setupActions() { edit_size_hs = new QAction(QET::Icons::HotSpot, tr("\311diter la taille et le point de saisie"), this); edit_names = new QAction(QET::Icons::Names, tr("\311diter les noms"), this); edit_ori = new QAction(QET::Icons::Orientations, tr("\311diter les orientations"), this); + edit_author = new QAction(QET::Icons::UserInformations, tr("\311diter les informations sur l'auteur"), this); edit_raise = new QAction(QET::Icons::Raise, tr("Rapprocher"), this); edit_lower = new QAction(QET::Icons::Lower, tr("\311loigner"), this); edit_backward = new QAction(QET::Icons::SendBackward, tr("Envoyer au fond"), this); @@ -167,6 +168,7 @@ void QETElementEditor::setupActions() { edit_names -> setShortcut(QKeySequence(tr("Ctrl+E"))); edit_size_hs -> setShortcut(QKeySequence(tr("Ctrl+R"))); edit_ori -> setShortcut(QKeySequence(tr("Ctrl+T"))); + edit_author -> setShortcut(tr("Ctrl+Y")); edit_raise -> setShortcut(QKeySequence(tr("Ctrl+Shift+Up"))); edit_lower -> setShortcut(QKeySequence(tr("Ctrl+Shift+Down"))); @@ -202,6 +204,7 @@ void QETElementEditor::setupActions() { connect(fullscreen, SIGNAL(triggered()), this, SLOT(toggleFullScreen())); connect(configure, SIGNAL(triggered()), qet_app, SLOT(configureQET())); connect(edit_ori, SIGNAL(triggered()), ce_scene, SLOT(slot_editOrientations())); + connect(edit_author, SIGNAL(triggered()), ce_scene, SLOT(slot_editAuthorInformations())); connect(edit_forward, SIGNAL(triggered()), ce_scene, SLOT(slot_bringForward())); connect(edit_raise, SIGNAL(triggered()), ce_scene, SLOT(slot_raise())); connect(edit_lower, SIGNAL(triggered()), ce_scene, SLOT(slot_lower())); @@ -368,6 +371,7 @@ void QETElementEditor::setupMenus() { edit_menu -> addAction(edit_names); edit_menu -> addAction(edit_size_hs); edit_menu -> addAction(edit_ori); + edit_menu -> addAction(edit_author); edit_menu -> addSeparator(); edit_menu -> addAction(edit_forward); edit_menu -> addAction(edit_raise); @@ -417,6 +421,7 @@ void QETElementEditor::slot_updateMenus() { edit_size_hs -> setEnabled(!read_only); edit_names -> setEnabled(!read_only); edit_ori -> setEnabled(!read_only); + edit_author -> setEnabled(!read_only); parts_list -> setEnabled(!read_only); // actions dependant de la presence de parties selectionnees diff --git a/sources/editor/qetelementeditor.h b/sources/editor/qetelementeditor.h index 9090aa9f2..01150c3a5 100644 --- a/sources/editor/qetelementeditor.h +++ b/sources/editor/qetelementeditor.h @@ -68,7 +68,7 @@ class QETElementEditor : public QMainWindow { QAction *selectall, *deselectall, *inv_select; QAction *cut, *copy, *paste, *paste_in_area, *paste_from_file, *paste_from_elmt; QAction *undo, *redo; - QAction *edit_delete, *edit_size_hs, *edit_names, *edit_ori; + QAction *edit_delete, *edit_size_hs, *edit_names, *edit_ori, *edit_author; QAction *edit_raise, *edit_lower, *edit_backward, *edit_forward; /// actions du menu affichage QAction *zoom_in, *zoom_out, *zoom_fit, *zoom_reset; diff --git a/sources/qeticons.cpp b/sources/qeticons.cpp index 79a39ffe4..568a1fd0c 100644 --- a/sources/qeticons.cpp +++ b/sources/qeticons.cpp @@ -126,6 +126,7 @@ namespace QET { QIcon South; QIcon Start; QIcon Terminal; + QIcon UserInformations; QIcon ViewFitWidth; QIcon ViewFitWindow; QIcon ViewMove; @@ -297,6 +298,8 @@ void QET::Icons::initIcons() { South .addFile(":/ico/16x16/south.png"); Start .addFile(":/ico/22x22/start.png"); Terminal .addFile(":/ico/22x22/terminal.png"); + UserInformations .addFile(":/ico/16x16/preferences-desktop-user.png"); + UserInformations .addFile(":/ico/22x22/preferences-desktop-user.png"); ViewFitWidth .addFile(":/ico/22x22/view_fit_width.png"); ViewFitWindow .addFile(":/ico/22x22/view_fit_window.png"); ViewMove .addFile(":/ico/22x22/move.png"); diff --git a/sources/qeticons.h b/sources/qeticons.h index 86fc53b1e..9768d9e87 100644 --- a/sources/qeticons.h +++ b/sources/qeticons.h @@ -136,6 +136,7 @@ namespace QET { extern QIcon South; extern QIcon Start; extern QIcon Terminal; + extern QIcon UserInformations; extern QIcon ViewFitWidth; extern QIcon ViewFitWindow; extern QIcon ViewMove;