QElectroTech  0.70
exportpropertieswidget.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 The QElectroTech Team
3  This file is part of QElectroTech.
4 
5  QElectroTech is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 2 of the License, or
8  (at your option) any later version.
9 
10  QElectroTech is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #include "exportpropertieswidget.h"
19 
24 ExportPropertiesWidget::ExportPropertiesWidget(QWidget *parent) : QWidget(parent) {
25  setMinimumWidth(680);
26  setMinimumHeight(720);
27  build();
29 }
30 
36 ExportPropertiesWidget::ExportPropertiesWidget(const ExportProperties &export_properties, QWidget *parent) : QWidget(parent) {
37  build();
38  setExportProperties(export_properties);
39 }
40 
43 }
44 
49  ExportProperties export_properties;
50 
51  export_properties.destination_directory = QDir(dirpath -> text());
52  export_properties.format = format -> itemData(format -> currentIndex()).toString();
53  export_properties.draw_grid = draw_grid -> isChecked();
54  export_properties.draw_border = draw_border -> isChecked();
55  export_properties.draw_titleblock = draw_titleblock -> isChecked();
56  export_properties.draw_terminals = draw_terminals -> isChecked();
57  export_properties.draw_colored_conductors = draw_colored_conductors -> isChecked();
58  export_properties.exported_area = export_border -> isChecked() ? QET::BorderArea : QET::ElementsArea;
59 
60  return(export_properties);
61 }
62 
67  dirpath -> setText(QDir::toNativeSeparators(export_properties.destination_directory.absolutePath()));
68 
69  int index = format -> findData(export_properties.format);
70  if (index == -1) index = 0;
71  format -> setCurrentIndex(index);
72 
73  draw_grid -> setChecked(export_properties.draw_grid);
74  draw_border -> setChecked(export_properties.draw_border);
75  draw_titleblock -> setChecked(export_properties.draw_titleblock);
76  draw_terminals -> setChecked(export_properties.draw_terminals);
77  draw_colored_conductors -> setChecked(export_properties.draw_colored_conductors);
78 
79  if (export_properties.exported_area == QET::BorderArea) {
80  export_border -> setChecked(true);
81  } else {
82  export_elements -> setChecked(true);
83  }
84 }
85 
93  dirpath_label -> setVisible(!mode);
94  dirpath -> setVisible(!mode);
95  button_browse -> setVisible(!mode);
96  format_label -> setVisible(!mode);
97  format -> setVisible(!mode);
98  export_border -> setVisible(!mode);
99  export_elements -> setVisible(!mode);
100 }
101 
106  QString user_dir = QFileDialog::getExistingDirectory(
107  this,
108  tr("Exporter dans le dossier", "dialog title"),
109  dirpath -> text()
110  );
111  if (!user_dir.isEmpty()) {
112  dirpath -> setText(QDir::toNativeSeparators(user_dir));
113  }
114 }
115 
120  // le dialogue est un empilement vertical d'elements
121  QVBoxLayout *vboxLayout = new QVBoxLayout();
122  vboxLayout -> setContentsMargins(0, 0, 0, 0);
123 
124  /* le dialogue comprend une ligne permettant d'indiquer un chemin de dossier (hboxLayout) */
125  QHBoxLayout *hboxLayout = new QHBoxLayout();
126  dirpath_label = new QLabel(tr("Dossier cible :"), this);
127  dirpath = new QLineEdit(this);
128  QCompleter *completer = new QCompleter(this);
129  completer -> setModel(new QDirModel(completer));
130  dirpath -> setCompleter(completer);
131  button_browse = new QPushButton(tr("Parcourir"), this);
132  hboxLayout -> addWidget(dirpath_label);
133  hboxLayout -> addWidget(dirpath);
134  hboxLayout -> addWidget(button_browse);
135  hboxLayout -> addStretch();
136 
137  vboxLayout -> addLayout(hboxLayout);
138 
139  /* une ligne permettant de choisir le format (hboxLayout1) */
140  QHBoxLayout *hboxLayout1 = new QHBoxLayout();
141  format_label = new QLabel(tr("Format :"), this);
142  hboxLayout1 -> addWidget(format_label);
143  hboxLayout1 -> addWidget(format = new QComboBox(this));
144  format -> addItem(tr("PNG (*.png)"), "PNG");
145  format -> addItem(tr("JPEG (*.jpg)"), "JPG");
146  format -> addItem(tr("Bitmap (*.bmp)"), "BMP");
147  format -> addItem(tr("SVG (*.svg)"), "SVG");
148  format -> addItem(tr("DXF (*.dxf)"), "DXF");
149  hboxLayout1 -> addStretch();
150 
151  vboxLayout -> addLayout(hboxLayout1);
152 
153  /* un cadre permettant de specifier les options de l'image finale */
154  QGroupBox *groupbox_options = new QGroupBox(tr("Options de rendu", "groupbox title"));
155  QGridLayout *optionshlayout = new QGridLayout(groupbox_options);
156 
157  // Choix de la zone du schema a exporter
158  exported_content_choices = new QButtonGroup(groupbox_options);
159  export_border = new QRadioButton(tr("Exporter entièrement le folio"), groupbox_options);
160  optionshlayout -> addWidget(export_border, 0, 0);
162  export_elements = new QRadioButton(tr("Exporter seulement les éléments"), groupbox_options);
163  optionshlayout -> addWidget(export_elements, 0, 1);
165 
166  // dessiner la grille
167  draw_grid = new QCheckBox(tr("Dessiner la grille"), groupbox_options);
168  optionshlayout -> addWidget(draw_grid, 1, 1);
169 
170  // dessiner le cadre
171  draw_border = new QCheckBox(tr("Dessiner le cadre"), groupbox_options);
172  optionshlayout -> addWidget(draw_border, 1, 0);
173 
174  // dessiner le cartouche
175  draw_titleblock = new QCheckBox(tr("Dessiner le cartouche"), groupbox_options);
176  optionshlayout -> addWidget(draw_titleblock, 2, 0);
177 
178  // dessiner les bornes
179  draw_terminals = new QCheckBox(tr("Dessiner les bornes"), groupbox_options);
180  optionshlayout -> addWidget(draw_terminals, 2, 1);
181 
182  // conserver les couleurs des conducteurs
183  draw_colored_conductors = new QCheckBox(tr("Conserver les couleurs des conducteurs"), groupbox_options);
184  optionshlayout -> addWidget(draw_colored_conductors, 3, 0);
185 
186  vboxLayout -> addWidget(groupbox_options);
187 
188  setLayout(vboxLayout);
189 
190  // ordre des input selectionnes avec la touche tab
191  setTabOrder(dirpath, button_browse);
192  setTabOrder(button_browse, format);
193  setTabOrder(format, export_border);
194  setTabOrder(export_border, draw_border);
195  setTabOrder(draw_border, draw_grid);
196  setTabOrder(draw_grid, draw_titleblock);
197  setTabOrder(draw_titleblock, draw_terminals);
199 
200  // connexion du bouton permettant le choix du repertoire
201  connect(button_browse, SIGNAL(released()), this, SLOT(slot_chooseADirectory()));
202 
203  // emission de signaux lors du changement de format et lors du changement de zone exportee
204  connect(format, SIGNAL(currentIndexChanged(int)), this, SIGNAL(formatChanged()));
205  connect(exported_content_choices, SIGNAL(buttonClicked(QAbstractButton *)), this, SIGNAL(exportedAreaChanged()));
206  connect(draw_grid, SIGNAL(stateChanged(int)), this, SIGNAL(optionChanged()));
207  connect(draw_border, SIGNAL(stateChanged(int)), this, SIGNAL(optionChanged()));
208  connect(draw_titleblock, SIGNAL(stateChanged(int)), this, SIGNAL(optionChanged()));
209  connect(draw_terminals, SIGNAL(stateChanged(int)), this, SIGNAL(optionChanged()));
210  connect(draw_colored_conductors, SIGNAL(stateChanged(int)), this, SIGNAL(optionChanged()));
211 }
QString format
Image format of generated files.
void setExportProperties(const ExportProperties &)
bool draw_border
Whether to render the border (along with rows/columns headers)
QButtonGroup * exported_content_choices
~ExportPropertiesWidget() override
Destructeur.
bool draw_colored_conductors
Whether to render conductors colors.
Export the content of the diagram only.
Definition: qet.h:139
QDir destination_directory
Target directory for generated files.
QIcon tr
Definition: qeticons.cpp:204
bool draw_titleblock
Whether to render the title block.
bool draw_grid
Whether to render the diagram grid.
QET::DiagramArea exported_area
Area of diagrams to be rendered.
ExportProperties exportProperties() const
Export the diagram along with its border and title block.
Definition: qet.h:138
ExportPropertiesWidget(QWidget *=nullptr)
bool draw_terminals
Whether to render terminals.