diff --git a/diagram.cpp b/diagram.cpp index 4f02d26b5..7383199d8 100644 --- a/diagram.cpp +++ b/diagram.cpp @@ -595,3 +595,10 @@ QSet Diagram::selectedConductors() const { } return(conductors_set); } + +/// @return true si le presse-papier semble contenir un schema +bool Diagram::clipboardMayContainDiagram() { + QString clipboard_text = QApplication::clipboard() -> text().trimmed(); + bool may_be_diagram = clipboard_text.startsWith(""); + return(may_be_diagram); +} diff --git a/diagram.h b/diagram.h index d013721d2..e041ccdfd 100644 --- a/diagram.h +++ b/diagram.h @@ -62,10 +62,13 @@ class Diagram : public QGraphicsScene { bool draw_terminals; // methodes + protected: + virtual void drawBackground(QPainter *, const QRectF &); + virtual void keyPressEvent(QKeyEvent *); + virtual void keyReleaseEvent(QKeyEvent *); + public: - void drawBackground(QPainter *, const QRectF &); - void keyPressEvent(QKeyEvent *); - void keyReleaseEvent(QKeyEvent *); + static bool clipboardMayContainDiagram(); // fonctions relatives a la pose de conducteurs void setConductor(bool); diff --git a/diagramview.cpp b/diagramview.cpp index 8586794b7..43de3f93d 100644 --- a/diagramview.cpp +++ b/diagramview.cpp @@ -826,6 +826,7 @@ void DiagramView::contextMenuEvent(QContextMenuEvent *e) { context_menu -> clear(); if (scene -> selectedItems().isEmpty()) { paste_here_pos = e -> pos(); + paste_here -> setEnabled(Diagram::clipboardMayContainDiagram()); context_menu -> addAction(paste_here); context_menu -> addSeparator(); context_menu -> addAction(qde -> infos_diagram); diff --git a/lang/qet_en.qm b/lang/qet_en.qm index 34d130258..30f686d02 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 86eb8b6f6..af84d5e63 100644 --- a/lang/qet_en.ts +++ b/lang/qet_en.ts @@ -1,5 +1,6 @@ + AboutQET @@ -226,115 +227,120 @@ DiagramView - + ? ? - + Auteur : Author : - + Date : Date : - + Enregistrer le schéma en cours ? Save the current diagram ? - + Enregistrer sous Save as - + Erreur Error - + Fichier : File : - + Folio : Folio : - + Impossible d'ecrire dans ce fichier Can't write to the file - + Schéma QElectroTech (*.qet) QElectroTech Diagram (*.qet) - + Titre : Title : - + Voulez-vous enregistrer le schéma Do you wish to save the diagram - + nouveau schéma new diagram - + Éditer les propriétés d'un conducteur Edit conductor properties - + Propriétés du schéma Diagram properties - + Dimensions du schéma Diagram size - + Colonnes : Columns : - + × × - + px px - + Hauteur : Height : - + Informations du cartouche Inset properties - + Éditer les propriétés par défaut des conducteurs Edit conductors default properties + + + Coller ici + Paste Here + ElementDeleter @@ -557,22 +563,22 @@ Please check rights of the directory ElementsPanel - + Ceci est un élément que vous pouvez insérer dans votre schéma par cliquer-déplacer This is an element you can drag'n drop onto your diagram - + Cliquer-déposez cet élément sur le schéma pour insérer un élément Drag'n drop this element to the diagram to insert a - + Collection QET QET Collection - + Collection utilisateur User Collection @@ -615,12 +621,12 @@ Please check rights of the directory Delete element - + Gestionnaire de catégories Categories manager - + Vous pouvez utiliser ce gestionnaire pour ajouter, supprimer ou modifier les catégories. Use this manager to add, delete or modify categories. @@ -1147,22 +1153,22 @@ Please check rights of the directory 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 : @@ -1179,7 +1185,7 @@ Available options: - + [options] [fichier]... @@ -1188,7 +1194,7 @@ Available options: - + --common-elements-dir=DIR Definir le dossier de la collection d'elements --common-elements-dir=DIR Define the elements collection directory @@ -1198,7 +1204,7 @@ Available options: QETDiagramEditor - + Active la fenêtre Activates the window @@ -1233,7 +1239,7 @@ Available options: Displays informations about QElectroTech - + Affiche ou non le panel d'appareils Displays or not the elements panel @@ -1313,12 +1319,12 @@ Available options: &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. @@ -1473,7 +1479,7 @@ Available options: Save as - + Erreur Error @@ -1533,7 +1539,7 @@ Available options: Imports a plan into the current plan - + Impossible de lire ce fichier. Could not read file. @@ -1573,7 +1579,7 @@ Available options: &New - + Outils Tools @@ -1588,7 +1594,7 @@ Available options: &Open - + Ouvrir un fichier Open a file @@ -1673,7 +1679,7 @@ Available options: Shrink the diagram's height - + Schémas QElectroTech (*.qet);;Fichiers XML (*.xml);;Tous les fichiers (*) QElectroTech Diagrams (*.qet);;XML Files (*.xml);;All files (*) @@ -1703,7 +1709,7 @@ Available options: Puts selected elements into the clipboard - + Une erreur s'est produite lors de l'ouverture du fichier. An error occured while opening the file. @@ -1778,27 +1784,27 @@ Available options: 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 @@ -2219,17 +2225,17 @@ Available options: terminal - + T T - + texte text - + _ _ diff --git a/qetdiagrameditor.cpp b/qetdiagrameditor.cpp index 6efe1ad9d..889a41cd2 100644 --- a/qetdiagrameditor.cpp +++ b/qetdiagrameditor.cpp @@ -777,13 +777,8 @@ void QETDiagramEditor::slot_updateModeActions() { Gere les actions ayant besoin du presse-papier */ void QETDiagramEditor::slot_updatePasteAction() { - if (!currentDiagram()) { - paste -> setEnabled(false); - } else { - QString clipboard_text = QApplication::clipboard() -> text(); - bool can_paste = clipboard_text.startsWith("\n"); - paste -> setEnabled(can_paste); - } + // pour coller, il faut un schema ouvert et un schema dans le presse-papier + paste -> setEnabled(currentDiagram() && Diagram::clipboardMayContainDiagram()); } /**