QElectroTech  0.70
exportproperties.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 "exportproperties.h"
19 
20 #include <QStandardPaths>
21 
31  destination_directory(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)),
32  format("PNG"),
33  draw_grid(false),
34  draw_border(true),
35  draw_titleblock(true),
36  draw_terminals(false),
37  draw_colored_conductors(true),
38  exported_area(QET::BorderArea)
39 {
40 }
41 
46 }
47 
53 void ExportProperties::toSettings(QSettings &settings, const QString &prefix) const {
54  settings.setValue(prefix + "path", QDir::toNativeSeparators(destination_directory.absolutePath()));
55  settings.setValue(prefix + "format", format);
56  settings.setValue(prefix + "drawgrid", draw_grid);
57  settings.setValue(prefix + "drawborder", draw_border);
58  settings.setValue(prefix + "drawtitleblock", draw_titleblock);
59  settings.setValue(prefix + "drawterminals", draw_terminals);
60  settings.setValue(prefix + "drawcoloredconductors", draw_colored_conductors);
61  settings.setValue(prefix + "area", QET::diagramAreaToString(exported_area));
62 }
63 
69 void ExportProperties::fromSettings(QSettings &settings, const QString &prefix) {
70  QString desktop_path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
71  destination_directory.setPath(settings.value(prefix + "path", desktop_path).toString());
72  if (!destination_directory.exists()) destination_directory.setPath(desktop_path);
73 
74  format = settings.value(prefix + "format").toString();
75 
76  draw_grid = settings.value(prefix + "drawgrid", false).toBool();
77  draw_border = settings.value(prefix + "drawborder", true ).toBool();
78  draw_titleblock = settings.value(prefix + "drawtitleblock", true ).toBool();
79  draw_terminals = settings.value(prefix + "drawterminals", false).toBool();
80  draw_colored_conductors = settings.value(prefix + "drawcoloredconductors", true ).toBool();
81 
82  exported_area = QET::diagramAreaFromString(settings.value(prefix + "area", "border").toString());
83 }
84 
90 {
91  QSettings settings;
92 
93  ExportProperties def;
94  def.fromSettings(settings, "export/default");
95 
96  return(def);
97 }
98 
104 {
105  QSettings settings;
106 
107  ExportProperties def;
108  def.fromSettings(settings, "print/default");
109 
110  return(def);
111 }
QString format
Image format of generated files.
QET::DiagramArea diagramAreaFromString(const QString &)
Definition: qet.cpp:488
virtual ~ExportProperties()
bool draw_border
Whether to render the border (along with rows/columns headers)
Definition: qet.h:28
void toSettings(QSettings &, const QString &=QString()) const
QString diagramAreaToString(const QET::DiagramArea &)
Definition: qet.cpp:478
void fromSettings(QSettings &, const QString &=QString())
bool draw_colored_conductors
Whether to render conductors colors.
QDir destination_directory
Target directory for generated files.
static ExportProperties defaultExportProperties()
ExportProperties::defaultProperties.
static ExportProperties defaultPrintProperties()
ExportProperties::defaultPrintProperties.
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.
Export the diagram along with its border and title block.
Definition: qet.h:138
bool draw_terminals
Whether to render terminals.