[qet] [727] Premiere application du patch de Sebastien Gouezel : il est possible de specifier les parametres d' export par defaut au niveau de l'application. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
- To: qet@xxxxxxxxxxxxxxxxxxx
- Subject: [qet] [727] Premiere application du patch de Sebastien Gouezel : il est possible de specifier les parametres d' export par defaut au niveau de l'application.
- From: subversion@xxxxxxxxxxxxx
- Date: Sun, 09 Aug 2009 14:51:02 +0200
Revision: 727
Author: xavier
Date: 2009-08-09 14:51:02 +0200 (Sun, 09 Aug 2009)
Log Message:
-----------
Premiere application du patch de Sebastien Gouezel : il est possible de specifier les parametres d'export par defaut au niveau de l'application.
Modified Paths:
--------------
trunk/qelectrotech.qrc
trunk/sources/configdialog.cpp
trunk/sources/configpages.cpp
trunk/sources/configpages.h
trunk/sources/exportdialog.cpp
trunk/sources/exportdialog.h
trunk/sources/qet.cpp
trunk/sources/qet.h
trunk/sources/qetdiagrameditor.cpp
trunk/sources/qetdiagrameditor.h
trunk/sources/qeticons.cpp
Added Paths:
-----------
trunk/ico/128x128/document-export.png
trunk/sources/exportproperties.cpp
trunk/sources/exportproperties.h
trunk/sources/exportpropertieswidget.cpp
trunk/sources/exportpropertieswidget.h
Added: trunk/ico/128x128/document-export.png
===================================================================
(Binary files differ)
Property changes on: trunk/ico/128x128/document-export.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/qelectrotech.qrc
===================================================================
--- trunk/qelectrotech.qrc 2009-08-04 16:19:17 UTC (rev 726)
+++ trunk/qelectrotech.qrc 2009-08-09 12:51:02 UTC (rev 727)
@@ -2,6 +2,7 @@
<qresource>
<file>ico/128x128/diagram.png</file>
<file>ico/128x128/settings.png</file>
+ <file>ico/128x128/document-export.png</file>
<file>ico/16x16/add_col.png</file>
<file>ico/16x16/add_row.png</file>
<file>ico/16x16/application-exit.png</file>
Modified: trunk/sources/configdialog.cpp
===================================================================
--- trunk/sources/configdialog.cpp 2009-08-04 16:19:17 UTC (rev 726)
+++ trunk/sources/configdialog.cpp 2009-08-09 12:51:02 UTC (rev 727)
@@ -39,6 +39,7 @@
pages_widget = new QStackedWidget();
addPage(new GeneralConfigurationPage());
addPage(new NewDiagramPage());
+ addPage(new ExportConfigPage());
buildPagesList();
// boutons
Modified: trunk/sources/configpages.cpp
===================================================================
--- trunk/sources/configpages.cpp 2009-08-04 16:19:17 UTC (rev 726)
+++ trunk/sources/configpages.cpp 2009-08-09 12:51:02 UTC (rev 727)
@@ -23,6 +23,7 @@
#include "qetdiagrameditor.h"
#include "borderinset.h"
#include "qeticons.h"
+#include "exportpropertieswidget.h"
/**
Constructeur
@@ -189,3 +190,50 @@
QString GeneralConfigurationPage::title() const {
return(tr("G\351n\351ral", "configuration page title"));
}
+
+
+/**
+ Constructeur
+ @param parent QWidget parent
+*/
+ExportConfigPage::ExportConfigPage(QWidget *parent) : ConfigPage(parent) {
+ // epw contient les options d'export
+ epw = new ExportPropertiesWidget(QETDiagramEditor::defaultExportProperties());
+
+ // layout vertical contenant le titre, une ligne horizontale et epw
+ QVBoxLayout *vlayout1 = new QVBoxLayout();
+
+ QLabel *title = new QLabel(this -> title());
+ vlayout1 -> addWidget(title);
+
+ QFrame *horiz_line = new QFrame();
+ horiz_line -> setFrameShape(QFrame::HLine);
+ vlayout1 -> addWidget(horiz_line);
+ vlayout1 -> addWidget(epw);
+
+ // activation du layout
+ setLayout(vlayout1);
+}
+
+/// Destructeur
+ExportConfigPage::~ExportConfigPage() {
+}
+
+/**
+ Applique la configuration de cette page
+*/
+void ExportConfigPage::applyConf() {
+ QSettings &settings = QETApp::settings();
+ epw -> exportProperties().toSettings(settings, "export/default");
+}
+
+/// @return l'icone de cette page
+QIcon ExportConfigPage::icon() const {
+ return(QET::Icons::DocumentExport);
+}
+
+/// @return le titre de cette page
+QString ExportConfigPage::title() const {
+ return(tr("Export", "configuration page title"));
+}
+
Modified: trunk/sources/configpages.h
===================================================================
--- trunk/sources/configpages.h 2009-08-04 16:19:17 UTC (rev 726)
+++ trunk/sources/configpages.h 2009-08-09 12:51:02 UTC (rev 727)
@@ -21,6 +21,7 @@
class BorderPropertiesWidget;
class ConductorPropertiesWidget;
class InsetPropertiesWidget;
+class ExportPropertiesWidget;
/**
Cette classe abstraite contient les methodes que toutes les pages de
configuration doivent implementer.
@@ -99,4 +100,27 @@
QGroupBox *elements_management_;
QCheckBox *integrate_elements_;
};
+
+/**
+ Cette classe represente la page de configuration du dialogue d'exportation
+*/
+class ExportConfigPage : public ConfigPage {
+ Q_OBJECT
+ // constructeurs, destructeur
+ public:
+ ExportConfigPage(QWidget * = 0);
+ virtual ~ExportConfigPage();
+ private:
+ ExportConfigPage(const ExportConfigPage &);
+
+ // methodes
+ public:
+ void applyConf();
+ QString title() const;
+ QIcon icon() const;
+
+ // attributs
+ public:
+ ExportPropertiesWidget *epw;
+};
#endif
Modified: trunk/sources/exportdialog.cpp
===================================================================
--- trunk/sources/exportdialog.cpp 2009-08-04 16:19:17 UTC (rev 726)
+++ trunk/sources/exportdialog.cpp 2009-08-09 12:51:02 UTC (rev 727)
@@ -19,6 +19,8 @@
#include <QSvgGenerator>
#include <QtXml>
#include "qeticons.h"
+#include "exportpropertieswidget.h"
+#include "qetdiagrameditor.h"
/**
Constructeur
@@ -28,13 +30,24 @@
ExportDialog::ExportDialog(QETProject *project, QWidget *parent) : QDialog(parent) {
if (!project) return;
- // recupere le schema a exporter, sa taille et ses proportions
+ // recupere le projet a exporter
project_ = project;
+ // recupere les parametres d'export definis dans la configuration de l'application
+ ExportProperties default_export_properties = QETDiagramEditor::defaultExportProperties();
+
+ // on utilise le repertoire du projet a exporter si possible
+ if (!project_ -> filePath().isEmpty()) {
+ default_export_properties.destination_directory = project_ -> currentDir();
+ }
+
// la taille minimale du dialogue est fixee
setMinimumSize(800, 390);
resize(minimumSize());
setWindowTitle(tr("Exporter les sch\351mas du projet", "window title"));
+
+ // options d'export, dans le widget epw
+ epw = new ExportPropertiesWidget(default_export_properties);
// le dialogue comporte deux boutons
buttons = new QDialogButtonBox(this);
@@ -47,15 +60,17 @@
QVBoxLayout *layout = new QVBoxLayout(this);
layout -> addWidget(new QLabel(tr("Choisissez les sch\351mas que vous d\351sirez exporter ainsi que leurs dimensions :")));
layout -> addWidget(initDiagramsListPart(), 1);
- layout -> addWidget(leftPart());
+ layout -> addWidget(epw);
layout -> addWidget(buttons);
- slot_changeFilesExtension(true);
// connexions signaux/slots
- connect(button_browse, SIGNAL(released()), this, SLOT(slot_chooseADirectory()));
- connect(format, SIGNAL(currentIndexChanged(int)), this, SLOT(slot_changeFilesExtension()));
- connect(buttons, SIGNAL(accepted()), this, SLOT(slot_export()));
- connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
+ connect(epw, SIGNAL(formatChanged()), this, SLOT(slot_changeFilesExtension()));
+ connect(epw, SIGNAL(exportedAreaChanged()), this, SLOT(slot_changeUseBorder()));
+ connect(buttons, SIGNAL(accepted()), this, SLOT(slot_export()));
+ connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
+
+ // ajustement des extensions des fichiers
+ slot_changeFilesExtension(true);
}
/**
@@ -65,7 +80,7 @@
}
/**
- @return lenombre de schemas coches (donc a exporter)
+ @return le nombre de schemas coches (donc a exporter)
*/
int ExportDialog::diagramsToExportCount() const {
int checked_diagrams_count = 0;
@@ -76,47 +91,6 @@
}
/**
- Met en place la partie du dialogue dans lequel l'utilisateur entre les
- options souhaitees de l'image.
- @return La QGroupBox permettant de regler les options de l'image
-*/
-QGroupBox *ExportDialog::setupOptionsGroupBox() {
- QGroupBox *groupbox_options = new QGroupBox(tr("Options"), this);
- QGridLayout *optionshlayout = new QGridLayout(groupbox_options);
-
- // Choix de la zone du schema a exporter
- QButtonGroup *exported_content_choices = new QButtonGroup(groupbox_options);
- export_border = new QRadioButton(tr("Exporter le cadre"), groupbox_options);
- optionshlayout -> addWidget(export_border, 0, 0);
- exported_content_choices -> addButton(export_border);
- export_elements = new QRadioButton(tr("Exporter les \351l\351ments"), groupbox_options);
- optionshlayout -> addWidget(export_elements, 0, 1);
- exported_content_choices -> addButton(export_elements);
- export_border -> setChecked(true);
- connect(exported_content_choices, SIGNAL(buttonClicked(QAbstractButton *)), this, SLOT(slot_changeUseBorder()));
-
- // dessiner la grille
- draw_grid = new QCheckBox(tr("Dessiner la grille"), groupbox_options);
- optionshlayout -> addWidget(draw_grid, 1, 1);
-
- // dessiner le cadre
- draw_border = new QCheckBox(tr("Dessiner le cadre"), groupbox_options);
- optionshlayout -> addWidget(draw_border, 1, 0);
- draw_border -> setChecked(true);
-
- // dessiner le cartouche
- draw_inset = new QCheckBox(tr("Dessiner le cartouche"), groupbox_options);
- optionshlayout -> addWidget(draw_inset, 2, 0);
- draw_inset -> setChecked(true);
-
- // dessiner les bornes
- draw_terminals = new QCheckBox(tr("Dessiner les bornes"), groupbox_options);
- optionshlayout -> addWidget(draw_terminals, 2, 1);
-
- return(groupbox_options);
-}
-
-/**
Met en place la liste des schemas
@return Le widget representant la liste des schemas
*/
@@ -178,60 +152,6 @@
}
/**
- Met en place la partie gauche du dialogue
- @return Le widget representant la moitie gauche du dialogue
-*/
-QWidget *ExportDialog::leftPart() {
- QWidget *retour = new QWidget();
-
- // la partie gauche du dialogue est un empilement vertical d'elements
- QVBoxLayout *vboxLayout = new QVBoxLayout(retour);
-
- /* le dialogue comprend une ligne permettant d'indiquer un chemin de dossier (hboxLayout) */
- QHBoxLayout *hboxLayout = new QHBoxLayout();
- QLabel *dirpath_label = new QLabel(tr("Dossier cible :"), this);
- dirpath = new QLineEdit(this);
- dirpath -> setText(QDir::toNativeSeparators(project_ -> currentDir()));
- QCompleter *completer = new QCompleter(this);
- completer -> setModel(new QDirModel(completer));
- dirpath -> setCompleter(completer);
- button_browse = new QPushButton(tr("Parcourir"), this);
- hboxLayout -> addWidget(dirpath_label);
- hboxLayout -> addWidget(dirpath);
- hboxLayout -> addWidget(button_browse);
- hboxLayout -> addStretch();
-
- vboxLayout -> addLayout(hboxLayout);
-
- /* une ligne permettant de choisir le format (hboxLayout1) */
- QHBoxLayout *hboxLayout1 = new QHBoxLayout();
- hboxLayout1 -> addWidget(new QLabel(tr("Format :"), this));
- hboxLayout1 -> addWidget(format = new QComboBox(this));
- format -> addItem(tr("PNG (*.png)"), "PNG");
- format -> addItem(tr("JPEG (*.jpg)"), "JPG");
- format -> addItem(tr("Bitmap (*.bmp)"), "BMP");
- format -> addItem(tr("SVG (*.svg)"), "SVG");
- hboxLayout1 -> addStretch();
-
- vboxLayout -> addLayout(hboxLayout1);
-
- /* un cadre permettant de specifier les options de l'image finale */
- vboxLayout -> addWidget(setupOptionsGroupBox());
- vboxLayout -> addStretch();
-
- // ordre des input selectionnes avec la touche tab
-
- setTabOrder(dirpath, button_browse);
- setTabOrder(button_browse, format);
- setTabOrder(format, export_border);
- setTabOrder(export_border, draw_border);
- setTabOrder(draw_border, draw_grid);
- setTabOrder(draw_grid, draw_inset);
- setTabOrder(draw_inset, draw_terminals);
- return(retour);
-}
-
-/**
@param diagram Un schema
@return le rapport largeur / hauteur du schema
*/
@@ -251,7 +171,7 @@
bool state_useBorder = diagram -> useBorder();
// applique le useBorder adequat et calcule le ratio
- diagram -> setUseBorder(export_border -> isChecked());
+ diagram -> setUseBorder(epw -> exportProperties().exported_area == QET::BorderArea);
QSize diagram_size = diagram -> imageSize();
// restaure le parametre useBorder du schema
@@ -352,20 +272,6 @@
}
/**
- Slot demandant a l'utilisateur de choisir un dossier
-*/
-void ExportDialog::slot_chooseADirectory() {
- QString user_dir = QFileDialog::getExistingDirectory(
- this,
- tr("Exporter dans le dossier", "dialog title"),
- dirpath -> text()
- );
- if (!user_dir.isEmpty()) {
- dirpath -> setText(user_dir);
- }
-}
-
-/**
Genere l'image a exporter
@param diagram Schema a exporter en SVG
@param width Largeur de l'export
@@ -410,11 +316,13 @@
state_drawTerm = diagram -> drawTerminals();
state_useBorder = diagram -> useBorder();
- diagram -> setUseBorder(export_border -> isChecked());
- diagram -> setDrawTerminals(draw_terminals -> isChecked());
- diagram -> setDisplayGrid(draw_grid -> isChecked());
- diagram -> border_and_inset.displayBorder(draw_border -> isChecked());
- diagram -> border_and_inset.displayInset(draw_inset -> isChecked());
+ ExportProperties export_properties = epw -> exportProperties();
+
+ diagram -> setUseBorder (export_properties.exported_area == QET::BorderArea);
+ diagram -> setDrawTerminals (export_properties.draw_terminals);
+ diagram -> setDisplayGrid (export_properties.draw_grid);
+ diagram -> border_and_inset.displayBorder(export_properties.draw_border);
+ diagram -> border_and_inset.displayInset (export_properties.draw_inset);
} else {
// restaure les parametres relatifs au schema
diagram -> border_and_inset.displayBorder(state_drawBorder);
@@ -480,7 +388,7 @@
this,
tr("Noms des fichiers cibles", "message box title"),
tr(
- "Vous devez entrer un nom de fichier distinct pour chaque "
+ "Vous devez entrer un nom de fichier non vide et unique pour chaque "
"sch\351ma \340 exporter.",
"message box content"
)
@@ -489,8 +397,9 @@
}
// verification #2 : un chemin vers un dossier doit avoir ete specifie
- QDir target_dir_path(dirpath -> text());
- if (dirpath -> text().isEmpty() || !target_dir_path.exists()) {
+
+ QDir target_dir_path(epw -> exportProperties().destination_directory);
+ if (!target_dir_path.exists()) {
QMessageBox::warning(
this,
tr("Dossier non sp\351cifi\351", "message box title"),
@@ -515,15 +424,17 @@
de l'exporter
*/
void ExportDialog::exportDiagram(ExportDiagramLine *diagram_line) {
+ ExportProperties export_properties(epw -> exportProperties());
+
// recupere le format a utiliser (acronyme et extension)
- QString format_acronym = format -> itemData(format -> currentIndex()).toString();
+ QString format_acronym = export_properties.format;
QString format_extension = "." + format_acronym.toLower();
// determine le nom de fichier a utiliser
QString diagram_path = diagram_line -> file_name -> text();
// determine le chemin du fichier du fichier
- QDir target_dir_path(dirpath -> text());
+ QDir target_dir_path(export_properties.destination_directory);
diagram_path = target_dir_path.absoluteFilePath(diagram_path);
// recupere des informations sur le fichier specifie
@@ -572,7 +483,7 @@
/**
Slot appele lorsque l'utilisateur change la zone du schema qui doit etre
- exportee. Il faut alors ajuster les dimensons des schemas.
+ exportee. Il faut alors ajuster les dimensions des schemas.
*/
void ExportDialog::slot_changeUseBorder() {
// parcourt les schemas a exporter
@@ -587,8 +498,10 @@
}
/**
- Ce slot active ou desactive le bouton "Exporter" en fonction du nombre de
- schemas coches.
+ Ce slot est appele quand un schema a ete coche ou decoche.
+ Il active ou desactive le bouton "Exporter" en fonction du nombre de
+ schemas coches, et il garde au plus un schema coche si on exporte vers
+ le presse-papier.
*/
void ExportDialog::slot_checkDiagramsCount() {
QPushButton *export_button = buttons -> button(QDialogButtonBox::Save);
@@ -602,7 +515,7 @@
*/
void ExportDialog::slot_changeFilesExtension(bool force_extension) {
// recupere le format a utiliser (acronyme et extension)
- QString format_acronym = format -> itemData(format -> currentIndex()).toString();
+ QString format_acronym = epw -> exportProperties().format;
QString format_extension = "." + format_acronym.toLower();
// parcourt les schemas a exporter
Modified: trunk/sources/exportdialog.h
===================================================================
--- trunk/sources/exportdialog.h 2009-08-04 16:19:17 UTC (rev 726)
+++ trunk/sources/exportdialog.h 2009-08-09 12:51:02 UTC (rev 727)
@@ -21,6 +21,7 @@
#include "diagram.h"
#include "qetproject.h"
class QSvgGenerator;
+class ExportPropertiesWidget;
/**
Cette classe represente le dialogue permettant d'exporter un schema
sous forme d'image selon les desirs de l'utilisateur
@@ -64,15 +65,7 @@
QHash<int, ExportDialog::ExportDiagramLine *> diagram_lines_;
// elements graphiques
QGridLayout *diagrams_list_layout_;
- QLineEdit *dirpath;
- QPushButton *button_browse;
- QComboBox *format;
- QCheckBox *draw_grid;
- QCheckBox *draw_border;
- QCheckBox *draw_inset;
- QCheckBox *draw_terminals;
- QRadioButton *export_elements;
- QRadioButton *export_border;
+ ExportPropertiesWidget *epw;
QDialogButtonBox *buttons;
// mappers
QSignalMapper *preview_mapper_;
@@ -87,8 +80,6 @@
// methodes
private:
QWidget *initDiagramsListPart();
- QWidget *leftPart();
- QGroupBox *setupOptionsGroupBox();
void saveReloadDiagramParameters(Diagram *, bool = true);
void generateSvg(Diagram *, int, int, bool, QFile &);
QImage generateImage(Diagram *, int, int, bool);
@@ -101,7 +92,6 @@
void slot_correctHeight(int);
void slot_keepRatioChanged(int);
void slot_resetSize(int);
- void slot_chooseADirectory();
void slot_export();
void slot_changeUseBorder();
void slot_checkDiagramsCount();
Added: trunk/sources/exportproperties.cpp
===================================================================
--- trunk/sources/exportproperties.cpp (rev 0)
+++ trunk/sources/exportproperties.cpp 2009-08-09 12:51:02 UTC (rev 727)
@@ -0,0 +1,79 @@
+/*
+ Copyright 2006-2009 Xavier Guerrin
+ This file is part of QElectroTech.
+
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "exportproperties.h"
+#include <QDesktopServices>
+
+/**
+ Constructeur par defaut :
+ * le repertoire de destination est le Bureau de l'utilisateur
+ * le format d'export est PNG
+ * la grille et les bornes ne doivent pas etre dessinees
+ * la bordure et le cartouche doivent etre dessines
+ * la zone exportee est le schema avec son cadre et son cartouche
+*/
+ExportProperties::ExportProperties() :
+ destination_directory(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)),
+ format("PNG"),
+ draw_grid(false),
+ draw_border(true),
+ draw_inset(true),
+ draw_terminals(false),
+ exported_area(QET::BorderArea)
+{
+}
+
+/**
+ Destructeur
+*/
+ExportProperties::~ExportProperties() {
+}
+
+/**
+ Exporte les options dans une configuration.
+ @param settings Parametres a ecrire
+ @param prefix prefixe a ajouter devant les noms des parametres
+*/
+void ExportProperties::toSettings(QSettings &settings, const QString &prefix) const {
+ settings.setValue(prefix + "path", QDir::toNativeSeparators(destination_directory.absolutePath()));
+ settings.setValue(prefix + "format", format);
+ settings.setValue(prefix + "drawgrid", draw_grid);
+ settings.setValue(prefix + "drawborder", draw_border);
+ settings.setValue(prefix + "drawinset", draw_inset);
+ settings.setValue(prefix + "drawterminals", draw_terminals);
+ settings.setValue(prefix + "area", QET::diagramAreaToString(exported_area));
+}
+
+/**
+ Lit les options depuis une configuration.
+ @param settings Parametres a lire
+ @param prefix prefixe a ajouter devant les noms des parametres
+*/
+void ExportProperties::fromSettings(QSettings &settings, const QString &prefix) {
+ QString desktop_path = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation);
+ destination_directory.setPath(settings.value(prefix + "path", desktop_path).toString());
+ if (!destination_directory.exists()) destination_directory.setPath(desktop_path);
+
+ format = settings.value(prefix + "format").toString();
+
+ draw_grid = settings.value(prefix + "drawgrid", false).toBool();
+ draw_border = settings.value(prefix + "drawborder", true ).toBool();
+ draw_inset = settings.value(prefix + "drawinset", true ).toBool();
+ draw_terminals = settings.value(prefix + "drawterminals", false).toBool();
+
+ exported_area = QET::diagramAreaFromString(settings.value(prefix + "area", "border").toString());
+}
Added: trunk/sources/exportproperties.h
===================================================================
--- trunk/sources/exportproperties.h (rev 0)
+++ trunk/sources/exportproperties.h 2009-08-09 12:51:02 UTC (rev 727)
@@ -0,0 +1,48 @@
+/*
+ Copyright 2006-2009 Xavier Guerrin
+ This file is part of QElectroTech.
+
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef EXPORT_PROPERTIES_H
+#define EXPORT_PROPERTIES_H
+#include <QtCore>
+#include "qet.h"
+
+/**
+ Cette classe represente les differentes options utilisees pour exporter un
+ schema sous forme d'image, ou encore pour l'imprimer.
+*/
+class ExportProperties {
+ // constructeur, destructeur
+ public:
+ ExportProperties();
+ virtual ~ExportProperties();
+
+ // methodes
+ public:
+ void toSettings (QSettings &, const QString & = QString()) const;
+ void fromSettings(QSettings &, const QString & = QString());
+
+ // attributs
+ public:
+ QDir destination_directory; ///< Quel est le repertoire de destination du ou des fichiers generes ?
+ QString format; ///< Quel format d'image faut-il utiliser ?
+ bool draw_grid; ///< Faut-il dessiner la grille ?
+ bool draw_border; ///< Faut-il dessiner le cadre ?
+ bool draw_inset; ///< Faut-il dessiner le cartouche ?
+ bool draw_terminals; ///< Faut-il dessiner les bornes ?
+ QET::DiagramArea exported_area; ///< Zone du schema a exporter
+};
+#endif
Added: trunk/sources/exportpropertieswidget.cpp
===================================================================
--- trunk/sources/exportpropertieswidget.cpp (rev 0)
+++ trunk/sources/exportpropertieswidget.cpp 2009-08-09 12:51:02 UTC (rev 727)
@@ -0,0 +1,180 @@
+/*
+ Copyright 2006-2009 Xavier Guerrin
+ This file is part of QElectroTech.
+
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "exportpropertieswidget.h"
+
+/**
+ Constructeur
+ @param parent QWidget parent
+*/
+ExportPropertiesWidget::ExportPropertiesWidget(QWidget *parent) : QWidget(parent) {
+ build();
+ setExportProperties(ExportProperties());
+}
+
+/**
+ Constructeur
+ @param export_properties Parametres d'export a afficher / editer
+ @param parent QWidget parent
+*/
+ExportPropertiesWidget::ExportPropertiesWidget(const ExportProperties &export_properties, QWidget *parent) : QWidget(parent) {
+ build();
+ setExportProperties(export_properties);
+}
+
+/// Destructeur
+ExportPropertiesWidget::~ExportPropertiesWidget() {
+}
+
+/**
+ @return les parametres d'export definis via le widget
+*/
+ExportProperties ExportPropertiesWidget::exportProperties() const {
+ ExportProperties export_properties;
+
+ export_properties.destination_directory = QDir(dirpath -> text());
+ export_properties.format = format -> itemData(format -> currentIndex()).toString();
+ export_properties.draw_grid = draw_grid -> isChecked();
+ export_properties.draw_border = draw_border -> isChecked();
+ export_properties.draw_inset = draw_inset -> isChecked();
+ export_properties.draw_terminals = draw_terminals -> isChecked();
+ export_properties.exported_area = export_border -> isChecked() ? QET::BorderArea : QET::ElementsArea;
+
+ return(export_properties);
+}
+
+/**
+ @param export_properties les parametres d'export a afficher / editer via le widget
+*/
+void ExportPropertiesWidget::setExportProperties(const ExportProperties &export_properties) {
+ dirpath -> setText(QDir::toNativeSeparators(export_properties.destination_directory.absolutePath()));
+
+ int index = format -> findData(export_properties.format);
+ if (index == -1) index = 0;
+ format -> setCurrentIndex(index);
+
+ draw_grid -> setChecked(export_properties.draw_grid);
+ draw_border -> setChecked(export_properties.draw_border);
+ draw_inset -> setChecked(export_properties.draw_inset);
+ draw_terminals -> setChecked(export_properties.draw_terminals);
+
+ if (export_properties.exported_area == QET::BorderArea) {
+ export_border -> setChecked(true);
+ } else {
+ export_elements -> setChecked(true);
+ }
+}
+
+/**
+ Slot demandant a l'utilisateur de choisir un dossier
+*/
+void ExportPropertiesWidget::slot_chooseADirectory() {
+ QString user_dir = QFileDialog::getExistingDirectory(
+ this,
+ tr("Exporter dans le dossier", "dialog title"),
+ dirpath -> text()
+ );
+ if (!user_dir.isEmpty()) {
+ dirpath -> setText(QDir::toNativeSeparators(user_dir));
+ }
+}
+
+/**
+ Cette methode construit le widget en lui-meme
+*/
+void ExportPropertiesWidget::build() {
+ // le dialogue est un empilement vertical d'elements
+ QVBoxLayout *vboxLayout = new QVBoxLayout();
+
+ /* le dialogue comprend une ligne permettant d'indiquer un chemin de dossier (hboxLayout) */
+ QHBoxLayout *hboxLayout = new QHBoxLayout();
+ QLabel *dirpath_label = new QLabel(tr("Dossier cible :"), this);
+ dirpath = new QLineEdit(this);
+ QCompleter *completer = new QCompleter(this);
+ completer -> setModel(new QDirModel(completer));
+ dirpath -> setCompleter(completer);
+ button_browse = new QPushButton(tr("Parcourir"), this);
+ hboxLayout -> addWidget(dirpath_label);
+ hboxLayout -> addWidget(dirpath);
+ hboxLayout -> addWidget(button_browse);
+ hboxLayout -> addStretch();
+
+ vboxLayout -> addLayout(hboxLayout);
+
+ /* une ligne permettant de choisir le format (hboxLayout1) */
+ QHBoxLayout *hboxLayout1 = new QHBoxLayout();
+ hboxLayout1 -> addWidget(new QLabel(tr("Format :"), this));
+ hboxLayout1 -> addWidget(format = new QComboBox(this));
+ format -> addItem(tr("PNG (*.png)"), "PNG");
+ format -> addItem(tr("JPEG (*.jpg)"), "JPG");
+ format -> addItem(tr("Bitmap (*.bmp)"), "BMP");
+ format -> addItem(tr("SVG (*.svg)"), "SVG");
+ hboxLayout1 -> addStretch();
+
+ vboxLayout -> addLayout(hboxLayout1);
+
+
+ /* un cadre permettant de specifier les options de l'image finale */
+ QGroupBox *groupbox_options = new QGroupBox(tr("Options"));
+ QGridLayout *optionshlayout = new QGridLayout(groupbox_options);
+
+ // Choix de la zone du schema a exporter
+ exported_content_choices = new QButtonGroup(groupbox_options);
+ export_border = new QRadioButton(tr("Exporter le cadre"), groupbox_options);
+ optionshlayout -> addWidget(export_border, 0, 0);
+ exported_content_choices -> addButton(export_border);
+ export_elements = new QRadioButton(tr("Exporter les \351l\351ments"), groupbox_options);
+ optionshlayout -> addWidget(export_elements, 0, 1);
+ exported_content_choices -> addButton(export_elements);
+
+ // dessiner la grille
+ draw_grid = new QCheckBox(tr("Dessiner la grille"), groupbox_options);
+ optionshlayout -> addWidget(draw_grid, 1, 1);
+
+ // dessiner le cadre
+ draw_border = new QCheckBox(tr("Dessiner le cadre"), groupbox_options);
+ optionshlayout -> addWidget(draw_border, 1, 0);
+
+ // dessiner le cartouche
+ draw_inset = new QCheckBox(tr("Dessiner le cartouche"), groupbox_options);
+ optionshlayout -> addWidget(draw_inset, 2, 0);
+
+ // dessiner les bornes
+ draw_terminals = new QCheckBox(tr("Dessiner les bornes"), groupbox_options);
+ optionshlayout -> addWidget(draw_terminals, 2, 1);
+
+ vboxLayout -> addWidget(groupbox_options);
+ vboxLayout -> addStretch();
+
+ setLayout(vboxLayout);
+
+ // ordre des input selectionnes avec la touche tab
+ setTabOrder(dirpath, button_browse);
+ setTabOrder(button_browse, format);
+ setTabOrder(format, export_border);
+ setTabOrder(export_border, draw_border);
+ setTabOrder(draw_border, draw_grid);
+ setTabOrder(draw_grid, draw_inset);
+ setTabOrder(draw_inset, draw_terminals);
+
+ // connexion du bouton permettant le choix du repertoire
+ connect(button_browse, SIGNAL(released()), this, SLOT(slot_chooseADirectory()));
+
+ // emission de signaux lors du changement de format et lors du changement de zone exportee
+ connect(format, SIGNAL(currentIndexChanged(int)), this, SIGNAL(formatChanged()));
+ connect(exported_content_choices, SIGNAL(buttonClicked(QAbstractButton *)), this, SIGNAL(exportedAreaChanged()));
+}
Added: trunk/sources/exportpropertieswidget.h
===================================================================
--- trunk/sources/exportpropertieswidget.h (rev 0)
+++ trunk/sources/exportpropertieswidget.h 2009-08-09 12:51:02 UTC (rev 727)
@@ -0,0 +1,66 @@
+/*
+ Copyright 2006-2009 Xavier Guerrin
+ This file is part of QElectroTech.
+
+ QElectroTech is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ QElectroTech is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef EXPORT_PROPERTIES_WIDGET_H
+#define EXPORT_PROPERTIES_WIDGET_H
+#include <QtGui>
+#include "exportproperties.h"
+
+/**
+ Ce widget permet d'editer les differentes options utilisees
+ pour exporter un projet.
+*/
+class ExportPropertiesWidget : public QWidget {
+ Q_OBJECT
+ // constructeurs, destructeur
+ public:
+ ExportPropertiesWidget(QWidget * = 0);
+ ExportPropertiesWidget(const ExportProperties &, QWidget * = 0);
+ virtual ~ExportPropertiesWidget();
+ private:
+ ExportPropertiesWidget(const ExportPropertiesWidget &);
+
+ // methodes
+ public:
+ void setExportProperties(const ExportProperties &);
+ ExportProperties exportProperties() const;
+
+ public slots:
+ void slot_chooseADirectory();
+
+ signals:
+ void formatChanged();
+ void exportedAreaChanged();
+
+ // methodes privees
+ private:
+ void build();
+
+ // attributs
+ private:
+ QLineEdit *dirpath;
+ QPushButton *button_browse;
+ QComboBox *format;
+ QCheckBox *draw_grid;
+ QCheckBox *draw_border;
+ QCheckBox *draw_inset;
+ QCheckBox *draw_terminals;
+ QRadioButton *export_border;
+ QRadioButton *export_elements;
+ QButtonGroup *exported_content_choices;
+};
+#endif
Modified: trunk/sources/qet.cpp
===================================================================
--- trunk/sources/qet.cpp 2009-08-04 16:19:17 UTC (rev 726)
+++ trunk/sources/qet.cpp 2009-08-09 12:51:02 UTC (rev 727)
@@ -395,6 +395,25 @@
}
/**
+ @param diagram_area un type de zone de schema
+ @return une chaine representant le type de zone de schema
+*/
+QString QET::diagramAreaToString(const QET::DiagramArea &diagram_area) {
+ if (diagram_area == ElementsArea) return("elements");
+ else return("border");
+}
+
+/**
+ @param string une chaine representant un type de zone de schema
+ @return le type de zone de schema correspondant ; si la chaine est invalide,
+ QET::ElementsArea est retourne.
+*/
+QET::DiagramArea QET::diagramAreaFromString(const QString &string) {
+ if (!string.compare("border", Qt::CaseInsensitive)) return(QET::BorderArea);
+ else return(QET::ElementsArea);
+}
+
+/**
@param ptr pointeur quelconque
@return une representation hexadecimale de l'adresse du pointeur
*/
Modified: trunk/sources/qet.h
===================================================================
--- trunk/sources/qet.h 2009-08-04 16:19:17 UTC (rev 726)
+++ trunk/sources/qet.h 2009-08-09 12:51:02 UTC (rev 727)
@@ -89,6 +89,14 @@
Rename ///< il faut renommer la cible
};
+ /**
+ Cet enum represente la zone d'un schema a exporter / imprimer
+ */
+ enum DiagramArea {
+ BorderArea, ///< Exporte le schema avec son cadre et son cartouche
+ ElementsArea ///< Exporte le contenu du schema sans le cadre et le cartouche
+ };
+
QET::Orientation nextOrientation(QET::Orientation);
QET::Orientation previousOrientation(QET::Orientation);
QET::Orientation orientationFromString(const QString &);
@@ -110,6 +118,8 @@
QStringList splitWithSpaces(const QString &);
QString endTypeToString(const QET::EndType &);
QET::EndType endTypeFromString(const QString &);
+ QString diagramAreaToString(const QET::DiagramArea &);
+ QET::DiagramArea diagramAreaFromString(const QString &);
QString pointerString(void *);
}
#endif
Modified: trunk/sources/qetdiagrameditor.cpp
===================================================================
--- trunk/sources/qetdiagrameditor.cpp 2009-08-04 16:19:17 UTC (rev 726)
+++ trunk/sources/qetdiagrameditor.cpp 2009-08-09 12:51:02 UTC (rev 727)
@@ -1757,3 +1757,17 @@
return(def);
}
+
+/**
+ @return Les parametres d'export par defaut pour un schema
+*/
+ExportProperties QETDiagramEditor::defaultExportProperties() {
+ // accede a la configuration de l'application
+ QSettings &settings = QETApp::settings();
+
+ ExportProperties def;
+ // lit les caracteristiques des conducteurs par defaut dans la configuration
+ def.fromSettings(settings, "export/default");
+
+ return(def);
+}
Modified: trunk/sources/qetdiagrameditor.h
===================================================================
--- trunk/sources/qetdiagrameditor.h 2009-08-04 16:19:17 UTC (rev 726)
+++ trunk/sources/qetdiagrameditor.h 2009-08-09 12:51:02 UTC (rev 727)
@@ -21,6 +21,7 @@
#include "borderproperties.h"
#include "conductorproperties.h"
#include "insetproperties.h"
+#include "exportproperties.h"
class QETProject;
class ProjectView;
class Diagram;
@@ -55,9 +56,10 @@
QList<DiagramView *> projectViews() const;
QList<QString> editedFiles() const;
ProjectView *viewForFile(const QString &) const;
- static InsetProperties defaultInsetProperties();
- static BorderProperties defaultBorderProperties();
+ static InsetProperties defaultInsetProperties();
+ static BorderProperties defaultBorderProperties();
static ConductorProperties defaultConductorProperties();
+ static ExportProperties defaultExportProperties();
protected:
void actions();
Modified: trunk/sources/qeticons.cpp
===================================================================
--- trunk/sources/qeticons.cpp 2009-08-04 16:19:17 UTC (rev 726)
+++ trunk/sources/qeticons.cpp 2009-08-09 12:51:02 UTC (rev 727)
@@ -176,6 +176,7 @@
DocumentClose .addFile(":/ico/22x22/document-close.png");
DocumentExport .addFile(":/ico/16x16/document-export.png");
DocumentExport .addFile(":/ico/22x22/document-export.png");
+ DocumentExport .addFile(":/ico/128x128/document-export.png");
DocumentImport .addFile(":/ico/16x16/document-import.png");
DocumentImport .addFile(":/ico/22x22/document-import.png");
DocumentNew .addFile(":/ico/16x16/document-new.png");