mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 05:00:33 +01:00
Seconde application du patch de Sebastien Goueze : il est desormais possible d'exporter un schema vers le presse-papier depuis le dialogue d'export.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@728 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -95,17 +95,19 @@ int ExportDialog::diagramsToExportCount() const {
|
||||
@return Le widget representant la liste des schemas
|
||||
*/
|
||||
QWidget *ExportDialog::initDiagramsListPart() {
|
||||
preview_mapper_ = new QSignalMapper(this);
|
||||
width_mapper_ = new QSignalMapper(this);
|
||||
height_mapper_ = new QSignalMapper(this);
|
||||
ratio_mapper_ = new QSignalMapper(this);
|
||||
reset_mapper_ = new QSignalMapper(this);
|
||||
preview_mapper_ = new QSignalMapper(this);
|
||||
width_mapper_ = new QSignalMapper(this);
|
||||
height_mapper_ = new QSignalMapper(this);
|
||||
ratio_mapper_ = new QSignalMapper(this);
|
||||
reset_mapper_ = new QSignalMapper(this);
|
||||
clipboard_mapper_ = new QSignalMapper(this);
|
||||
|
||||
connect(preview_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_previewDiagram(int)));
|
||||
connect(width_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_correctHeight(int)));
|
||||
connect(height_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_correctWidth(int)));
|
||||
connect(ratio_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_keepRatioChanged(int)));
|
||||
connect(reset_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_resetSize(int)));
|
||||
connect(preview_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_previewDiagram(int)));
|
||||
connect(width_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_correctHeight(int)));
|
||||
connect(height_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_correctWidth(int)));
|
||||
connect(ratio_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_keepRatioChanged(int)));
|
||||
connect(reset_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_resetSize(int)));
|
||||
connect(clipboard_mapper_, SIGNAL(mapped(int)), this, SLOT(slot_exportToClipBoard(int)));
|
||||
|
||||
diagrams_list_layout_ = new QGridLayout();
|
||||
|
||||
@@ -140,6 +142,10 @@ QWidget *ExportDialog::initDiagramsListPart() {
|
||||
// mappings et signaux pour l'apercu du schema
|
||||
preview_mapper_ -> setMapping(diagram_line -> preview, line_count);
|
||||
connect(diagram_line -> preview, SIGNAL(clicked(bool)), preview_mapper_, SLOT(map()));
|
||||
|
||||
// mappings et signaux pour l'export du schema vers le presse-papier
|
||||
clipboard_mapper_ -> setMapping(diagram_line -> clipboard, line_count);
|
||||
connect(diagram_line -> clipboard, SIGNAL(clicked(bool)), clipboard_mapper_, SLOT(map()));
|
||||
}
|
||||
|
||||
QWidget *widget_diagrams_list = new QWidget();
|
||||
@@ -339,9 +345,9 @@ void ExportDialog::saveReloadDiagramParameters(Diagram *diagram, bool save) {
|
||||
@param width Largeur de l'export SVG
|
||||
@param height Hauteur de l'export SVG
|
||||
@param keep_aspect_ratio True pour conserver le ratio, false sinon
|
||||
@param file Fichier dans lequel sera enregistre le code SVG
|
||||
@param io_device Peripherique de sortie pour le code SVG (souvent : un fichier)
|
||||
*/
|
||||
void ExportDialog::generateSvg(Diagram *diagram, int width, int height, bool keep_aspect_ratio, QFile &file) {
|
||||
void ExportDialog::generateSvg(Diagram *diagram, int width, int height, bool keep_aspect_ratio, QIODevice &io_device) {
|
||||
saveReloadDiagramParameters(diagram, true);
|
||||
|
||||
// genere une QPicture a partir du schema
|
||||
@@ -356,7 +362,7 @@ void ExportDialog::generateSvg(Diagram *diagram, int width, int height, bool kee
|
||||
// "joue" la QPicture sur un QSvgGenerator
|
||||
QSvgGenerator svg_engine;
|
||||
svg_engine.setSize(QSize(width, height));
|
||||
svg_engine.setOutputDevice(&file);
|
||||
svg_engine.setOutputDevice(&io_device);
|
||||
QPainter svg_painter(&svg_engine);
|
||||
picture.play(&svg_painter);
|
||||
|
||||
@@ -433,7 +439,7 @@ void ExportDialog::exportDiagram(ExportDiagramLine *diagram_line) {
|
||||
// determine le nom de fichier a utiliser
|
||||
QString diagram_path = diagram_line -> file_name -> text();
|
||||
|
||||
// determine le chemin du fichier du fichier
|
||||
// determine le chemin du fichier
|
||||
QDir target_dir_path(export_properties.destination_directory);
|
||||
diagram_path = target_dir_path.absoluteFilePath(diagram_path);
|
||||
|
||||
@@ -543,8 +549,8 @@ void ExportDialog::slot_changeFilesExtension(bool force_extension) {
|
||||
}
|
||||
|
||||
/**
|
||||
Cette methode fait apparaitre un dialogue permettant de redimensionner et
|
||||
previsualiser un des schemas a exporter
|
||||
Cette methode fait apparaitre un dialogue permettant de previsualiser un
|
||||
des schemas a exporter
|
||||
@param diagram_id numero du schema a previsualiser
|
||||
*/
|
||||
void ExportDialog::slot_previewDiagram(int diagram_id) {
|
||||
@@ -592,6 +598,45 @@ void ExportDialog::slot_previewDiagram(int diagram_id) {
|
||||
preview_dialog.exec();
|
||||
}
|
||||
|
||||
/**
|
||||
Cette methode exporte un schema vers le presse-papier
|
||||
@param diagram_id numero du schema a previsualiser
|
||||
*/
|
||||
void ExportDialog::slot_exportToClipBoard(int diagram_id) {
|
||||
// recupere l'ExportDiagramLine concernee
|
||||
ExportDialog::ExportDiagramLine *diagram_line = diagram_lines_[diagram_id];
|
||||
if (!diagram_line) return;
|
||||
|
||||
// recupere le format a utiliser (acronyme et extension)
|
||||
QString format_acronym = epw -> exportProperties().format;
|
||||
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
|
||||
// enregistre l'image dans le fichier
|
||||
if (format_acronym == "SVG") {
|
||||
QByteArray ba;
|
||||
QBuffer buffer(&ba);
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
generateSvg(
|
||||
diagram_line -> diagram,
|
||||
diagram_line -> width -> value(),
|
||||
diagram_line -> height -> value(),
|
||||
diagram_line -> keep_ratio -> isChecked(),
|
||||
buffer
|
||||
);
|
||||
buffer.close();
|
||||
clipboard -> setText(ba);
|
||||
} else {
|
||||
QImage image = generateImage(
|
||||
diagram_line -> diagram,
|
||||
diagram_line -> width -> value(),
|
||||
diagram_line -> height -> value(),
|
||||
diagram_line -> keep_ratio -> isChecked()
|
||||
);
|
||||
clipboard -> setImage(image);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param dia Schema concerne
|
||||
@@ -641,6 +686,10 @@ ExportDialog::ExportDiagramLine::ExportDiagramLine(Diagram *dia) {
|
||||
preview = new QPushButton();
|
||||
preview -> setIcon(QET::Icons::ZoomOriginal);
|
||||
preview -> setToolTip(QObject::tr("Aper\347u"));
|
||||
|
||||
clipboard = new QPushButton();
|
||||
clipboard -> setIcon(QET::Icons::CopyFile);
|
||||
clipboard -> setToolTip(QObject::tr("Exporter vers le presse-papier"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -661,5 +710,6 @@ QBoxLayout *ExportDialog::ExportDiagramLine::sizeLayout() {
|
||||
layout -> addWidget(keep_ratio);
|
||||
layout -> addWidget(reset_size);
|
||||
layout -> addWidget(preview);
|
||||
layout -> addWidget(clipboard);
|
||||
return(layout);
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ class ExportDialog : public QDialog {
|
||||
QPushButton *keep_ratio;
|
||||
QPushButton *reset_size;
|
||||
QPushButton *preview;
|
||||
QPushButton *clipboard;
|
||||
};
|
||||
|
||||
// attributs
|
||||
@@ -73,6 +74,7 @@ class ExportDialog : public QDialog {
|
||||
QSignalMapper *height_mapper_;
|
||||
QSignalMapper *ratio_mapper_;
|
||||
QSignalMapper *reset_mapper_;
|
||||
QSignalMapper *clipboard_mapper_;
|
||||
|
||||
// elements relatifs au traitement effectue par le dialogue
|
||||
QETProject *project_;
|
||||
@@ -81,7 +83,7 @@ class ExportDialog : public QDialog {
|
||||
private:
|
||||
QWidget *initDiagramsListPart();
|
||||
void saveReloadDiagramParameters(Diagram *, bool = true);
|
||||
void generateSvg(Diagram *, int, int, bool, QFile &);
|
||||
void generateSvg(Diagram *, int, int, bool, QIODevice &);
|
||||
QImage generateImage(Diagram *, int, int, bool);
|
||||
void exportDiagram(ExportDiagramLine *);
|
||||
qreal diagramRatio(Diagram *);
|
||||
@@ -97,5 +99,6 @@ class ExportDialog : public QDialog {
|
||||
void slot_checkDiagramsCount();
|
||||
void slot_changeFilesExtension(bool = false);
|
||||
void slot_previewDiagram(int);
|
||||
void slot_exportToClipBoard(int);
|
||||
};
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user