QElectroTech  0.70
configpages.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 "configpages.h"
19 #include "borderpropertieswidget.h"
22 #include "bordertitleblock.h"
23 #include "qeticons.h"
24 #include "exportpropertieswidget.h"
27 #include "qetproject.h"
28 #include "reportproperties.h"
29 #include "qetapp.h"
30 #include <QFontDialog>
31 #include <QFont>
32 #include <QSizePolicy>
33 #include <utility>
34 
43  ConfigPage (parent),
44  ppd_ (ppd),
45  m_project (project)
46 {
47  //By default we set the global default properties
48 
49  // dimensions by default for diagram
51  // default titleblock properties
52  QList <TitleBlockTemplatesCollection *> c;
56  // default conductor properties
59  // default propertie of report label
61  // default properties of xref
63 
64  //If there is a project, we edit his properties
65  if (m_project) {
66  bpw -> setProperties (m_project -> defaultBorderProperties());
67  m_cpw -> setProperties (m_project -> defaultConductorProperties());
68  ipw -> setProperties (m_project -> defaultTitleBlockProperties());
69  rpw -> setReportProperties (m_project -> defaultReportProperties());
70  xrefpw -> setProperties (m_project -> defaultXRefProperties());
71  }
72 
73  connect(ipw,SIGNAL(openAutoNumFolioEditor(QString)),this,SLOT(changeToAutoFolioTab()));
74 
75  // main tab widget
76  QTabWidget *tab_widget = new QTabWidget(this);
77  QWidget *diagram_widget = new QWidget();
78  QVBoxLayout *diagram_layout = new QVBoxLayout(diagram_widget);
79 
80  diagram_layout -> addWidget(bpw);
81  diagram_layout -> addWidget(ipw);
82  tab_widget->setMinimumSize(800, 650);
83 
84  tab_widget -> addTab (diagram_widget, tr("Folio"));
85  tab_widget -> addTab (m_cpw, tr("Conducteur"));
86  tab_widget -> addTab (rpw, tr("Reports de folio"));
87  tab_widget -> addTab (xrefpw, tr("Références croisées"));
88 
89  QVBoxLayout *vlayout1 = new QVBoxLayout();
90  vlayout1->addWidget(tab_widget);
91 
92  setLayout(vlayout1);
93 }
94 
99  disconnect(ipw,SIGNAL(openAutoNumFolioEditor(QString)),this,SLOT(changeToAutoFolioTab()));
100 }
101 
109  if (m_project) { //If project we save to the project
110  if (m_project -> isReadOnly()) return;
111  bool modified_project = false;
112 
113  BorderProperties new_border_prop = bpw -> properties();
114  if (m_project -> defaultBorderProperties() != new_border_prop) {
115  m_project -> setDefaultBorderProperties(bpw -> properties());
116  modified_project = true;
117  }
118 
119  TitleBlockProperties new_tbt_prop = ipw -> properties();
120  if (m_project -> defaultTitleBlockProperties() != new_tbt_prop) {
121  m_project -> setDefaultTitleBlockProperties(ipw -> properties());
122  modified_project = true;
123  }
124 
125  ConductorProperties new_conductor_prop = m_cpw -> properties();
126  if (m_project -> defaultConductorProperties() != new_conductor_prop) {
127  m_project -> setDefaultConductorProperties(m_cpw -> properties());
128  modified_project = true;
129  }
130 
131  QString new_report_prop = rpw -> ReportProperties();
132  if (m_project -> defaultReportProperties() != new_report_prop) {
133  m_project -> setDefaultReportProperties(new_report_prop);
134  modified_project = true;
135  }
136 
137  QHash<QString, XRefProperties> new_xref_properties = xrefpw -> properties();
138  if (m_project -> defaultXRefProperties() != new_xref_properties) {
139  m_project -> setDefaultXRefProperties(new_xref_properties);
140  modified_project = true;
141  }
142 
143  if (modified_project) {
144  m_project -> setModified(modified_project);
145  }
146 
147  } else { //Else we save to the default value
148  QSettings settings;
149 
150  // dimensions des nouveaux schemas
151  bpw -> properties().toSettings(settings, "diagrameditor/default");
152 
153  // proprietes du cartouche
154  ipw-> properties().toSettings(settings, "diagrameditor/default");
155 
156  // proprietes par defaut des conducteurs
157  m_cpw -> properties().toSettings(settings, "diagrameditor/defaultconductor");
158 
159  // default report propertie
160  rpw->toSettings(settings, "diagrameditor/defaultreport");
161 
162  // default xref properties
163  QHash <QString, XRefProperties> hash_xrp = xrefpw -> properties();
164  foreach (QString key, hash_xrp.keys()) {
165  XRefProperties xrp = hash_xrp[key];
166  QString str("diagrameditor/defaultxref");
167  xrp.toSettings(settings, str += key);
168  }
169  }
170 
171 }
172 
177 QIcon NewDiagramPage::icon() const {
178  if (m_project) return(QET::Icons::NewDiagram);
179  return(QET::Icons::Projects);
180 }
181 
186 QString NewDiagramPage::title() const {
187  if (m_project) return(tr("Nouveau folio", "configuration page title"));
188  return(tr("Nouveau projet", "configuration page title"));
189 }
190 
196  if (m_project){
198  ppd_->changeToFolio();
199  ppd_->exec();
200  }
201 }
202 
207 void NewDiagramPage::setFolioAutonum(QString autoNum){
208  TitleBlockProperties tbptemp = ipw->propertiesAutoNum(std::move(autoNum));
209  ipw->setProperties(tbptemp);
210  applyConf();
211 }
212 
218  savedTbp = ipw->properties();
219 }
220 
227  applyConf();
228 }
229 
234 ExportConfigPage::ExportConfigPage(QWidget *parent) : ConfigPage(parent) {
235  // epw contient les options d'export
237 
238  // layout vertical contenant le titre, une ligne horizontale et epw
239  QVBoxLayout *vlayout1 = new QVBoxLayout();
240 
241  QLabel *title = new QLabel(this -> title());
242  vlayout1 -> addWidget(title);
243 
244  QFrame *horiz_line = new QFrame();
245  horiz_line -> setFrameShape(QFrame::HLine);
246  vlayout1 -> addWidget(horiz_line);
247  vlayout1 -> addWidget(epw);
248  vlayout1 -> addStretch();
249 
250  // activation du layout
251  setLayout(vlayout1);
252 }
253 
256 }
257 
262 {
263  QSettings settings;
264  epw -> exportProperties().toSettings(settings, "export/default");
265 }
266 
268 QIcon ExportConfigPage::icon() const {
270 }
271 
273 QString ExportConfigPage::title() const {
274  return(tr("Export", "configuration page title"));
275 }
276 
281 PrintConfigPage::PrintConfigPage(QWidget *parent) : ConfigPage(parent) {
282  // epw contient les options d'export
284  epw -> setPrintingMode(true);
285 
286  // layout vertical contenant le titre, une ligne horizontale et epw
287  QVBoxLayout *vlayout1 = new QVBoxLayout();
288 
289  QLabel *title = new QLabel(this -> title());
290  vlayout1 -> addWidget(title);
291 
292  QFrame *horiz_line = new QFrame();
293  horiz_line -> setFrameShape(QFrame::HLine);
294  vlayout1 -> addWidget(horiz_line);
295  vlayout1 -> addWidget(epw);
296  vlayout1 -> addStretch();
297 
298  // activation du layout
299  setLayout(vlayout1);
300 }
301 
304 }
305 
311 {
312  QString prefix = "print/default";
313 
314  QSettings settings;
315  epw -> exportProperties().toSettings(settings, prefix);
316 
317  // annule l'enregistrement de certaines proprietes non pertinentes
318  settings.remove(prefix + "path");
319  settings.remove(prefix + "format");
320  settings.remove(prefix + "area");
321 }
322 
324 QIcon PrintConfigPage::icon() const {
325  return(QET::Icons::Printer);
326 }
327 
329 QString PrintConfigPage::title() const {
330  return(tr("Impression", "configuration page title"));
331 }
332 
static TitleBlockTemplatesFilesCollection * commonTitleBlockTemplatesCollection()
Definition: qetapp.cpp:448
~ExportConfigPage() override
Destructeur.
static ConductorProperties defaultProperties()
ConductorProperties::defaultProperties.
void setProperties(const TitleBlockProperties &properties)
TitleBlockPropertiesWidget::setProperties.
The ProjectPropertiesDialog class this class builds a dialog to edit whole properties of a project...
ExportPropertiesWidget * epw
Definition: configpages.h:115
The BorderPropertiesWidget class this widget edit the properties of a border.
The XRefProperties class this class store properties used by XrefItem.
QString title() const override
NewDiagramPage::title.
The XRefPropertiesWidget class This class provide a widget to edit the XRefProperties.
TitleBlockProperties savedTbp
Used to save current TBP and retrieve later.
Definition: configpages.h:68
QIcon Projects
Definition: qeticons.cpp:146
ProjectPropertiesDialog * ppd_
Definition: configpages.h:61
QIcon Printer
Definition: qeticons.cpp:139
BorderPropertiesWidget * bpw
Widget to edit default diagram dimensions.
Definition: configpages.h:63
QString title() const override
QString title() const override
TitleBlockPropertiesWidget * ipw
Widget to edit default title block properties.
Definition: configpages.h:64
static QHash< QString, XRefProperties > defaultProperties()
XRefProperties::defaultProperties.
QIcon icon() const override
NewDiagramPage::icon.
static TitleBlockTemplatesFilesCollection * customTitleBlockTemplatesCollection()
Definition: qetapp.cpp:462
void exec()
ProjectPropertiesDialog::exec execute this dialog.
TitleBlockProperties propertiesAutoNum(QString autoNum) const
TitleBlockPropertiesWidget::properties.
ExportPropertiesWidget * epw
Definition: configpages.h:92
void changeToAutoFolioTab()
NewDiagramPage::changeToAutoFolioTab Set the current tab to Autonum.
TitleBlockProperties properties() const
TitleBlockPropertiesWidget::properties.
QIcon DocumentExport
Definition: qeticons.cpp:50
QIcon NewDiagram
Definition: qeticons.cpp:121
void loadSavedTbp()
NewDiagramPage::loadSavedTbp Retrieve saved auto folio num.
static ExportProperties defaultExportProperties()
ExportProperties::defaultProperties.
void setFolioAutonum(QString)
NewDiagramPage::setFolioAutonum Set temporary TBP to use in auto folio num.
QIcon tr
Definition: qeticons.cpp:204
~PrintConfigPage() override
Destructeur.
QETProject * m_project
Project to edit propertie.
Definition: configpages.h:62
void toSettings(QSettings &settings, const QString=QString()) const override
XRefProperties::toSettings Save to settings.
void applyConf() override
PrintConfigPage::applyConf Apply the config of this page.
static ExportProperties defaultPrintProperties()
ExportProperties::defaultPrintProperties.
static BorderProperties defaultProperties()
BorderProperties::defaultProperties.
ExportConfigPage(QWidget *=nullptr)
PrintConfigPage(QWidget *=nullptr)
XRefPropertiesWidget * xrefpw
Widget to edit default xref properties.
Definition: configpages.h:67
ConductorPropertiesWidget * m_cpw
Widget to edit default conductor properties.
Definition: configpages.h:65
ReportPropertieWidget * rpw
Widget to edit default report label.
Definition: configpages.h:66
~NewDiagramPage() override
NewDiagramPage::~NewDiagramPage.
Definition: configpages.cpp:98
void applyConf() override
NewDiagramPage::applyConf Apply conf for this page. If there is a project, save in the project...
void setHiddenAvailableAutonum(const bool &hide)
ConductorPropertiesWidget::setHiddenAvailableAutonum Hide the label, combo box and push button of ava...
void setCurrentPage(ProjectPropertiesDialog::Page)
ProjectPropertiesDialog::setCurrentPage Change the current displayed page by p.
void toSettings(QSettings &settings, const QString &prefix)
void applyConf() override
void saveCurrentTbp()
NewDiagramPage::saveCurrentTbp Save current TBP to retrieve after auto folio num. ...
QIcon icon() const override
TitleBlockTemplatesProjectCollection * embeddedTitleBlockTemplatesCollection()
Definition: qetproject.cpp:236
QIcon icon() const override
static QString defaultProperties()
ReportProperties::defaultProperties.
static TitleBlockProperties defaultProperties()
TitleBlockProperties::defaultProperties Return the default properties stored in the setting file...
void changeToFolio()
ProjectPropertiesDialog::changeToFolio Change the current displayed tab to folio tab.
NewDiagramPage(QETProject *project=nullptr, QWidget *=nullptr, ProjectPropertiesDialog *teste=nullptr)
NewDiagramPage::NewDiagramPage Default constructor.
Definition: configpages.cpp:42