2009-08-09 12:51:02 +00:00
|
|
|
/*
|
2025-01-04 13:37:40 +01:00
|
|
|
Copyright 2006-2025 The QElectroTech Team
|
2009-08-09 12:51:02 +00:00
|
|
|
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"
|
2025-01-26 11:32:46 +01:00
|
|
|
#include "qetapp.h"
|
2015-03-02 20:14:56 +00:00
|
|
|
|
2009-08-09 12:51:02 +00:00
|
|
|
/**
|
|
|
|
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() :
|
2025-01-26 11:32:46 +01:00
|
|
|
destination_directory(QETApp::documentDir()),
|
2009-08-09 12:51:02 +00:00
|
|
|
format("PNG"),
|
|
|
|
draw_grid(false),
|
|
|
|
draw_border(true),
|
2010-12-20 02:45:36 +00:00
|
|
|
draw_titleblock(true),
|
2009-08-09 12:51:02 +00:00
|
|
|
draw_terminals(false),
|
2024-03-27 15:30:02 +01:00
|
|
|
draw_bg_transparent(false),
|
2009-11-22 16:12:22 +00:00
|
|
|
draw_colored_conductors(true),
|
2009-08-09 12:51:02 +00:00
|
|
|
exported_area(QET::BorderArea)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructeur
|
|
|
|
*/
|
2020-09-07 21:41:45 +02:00
|
|
|
ExportProperties::~ExportProperties()
|
|
|
|
{
|
2009-08-09 12:51:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Exporte les options dans une configuration.
|
|
|
|
@param settings Parametres a ecrire
|
|
|
|
@param prefix prefixe a ajouter devant les noms des parametres
|
|
|
|
*/
|
2020-08-18 21:46:39 +02:00
|
|
|
void ExportProperties::toSettings(QSettings &settings,
|
2020-09-07 21:41:45 +02:00
|
|
|
const QString &prefix) const
|
|
|
|
{
|
2020-08-18 21:46:39 +02:00
|
|
|
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 + "drawtitleblock",
|
|
|
|
draw_titleblock);
|
|
|
|
settings.setValue(prefix + "drawterminals",
|
|
|
|
draw_terminals);
|
2024-03-27 15:15:53 +01:00
|
|
|
settings.setValue(prefix + "drawbgtransparent",
|
|
|
|
draw_bg_transparent);
|
2020-08-18 21:46:39 +02:00
|
|
|
settings.setValue(prefix + "drawcoloredconductors",
|
|
|
|
draw_colored_conductors);
|
|
|
|
settings.setValue(prefix + "area",
|
|
|
|
QET::diagramAreaToString(exported_area));
|
2009-08-09 12:51:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Lit les options depuis une configuration.
|
|
|
|
@param settings Parametres a lire
|
|
|
|
@param prefix prefixe a ajouter devant les noms des parametres
|
|
|
|
*/
|
2020-08-18 21:46:39 +02:00
|
|
|
void ExportProperties::fromSettings(QSettings &settings,
|
|
|
|
const QString &prefix) {
|
2025-01-26 11:32:46 +01:00
|
|
|
QString export_path = QETApp::documentDir();
|
2020-08-18 21:46:39 +02:00
|
|
|
destination_directory.setPath(
|
|
|
|
settings.value(
|
|
|
|
prefix + "path",
|
2025-01-26 11:32:46 +01:00
|
|
|
export_path).toString());
|
2020-08-18 21:46:39 +02:00
|
|
|
if (!destination_directory.exists())
|
2025-01-26 11:32:46 +01:00
|
|
|
destination_directory.setPath(export_path);
|
2020-08-18 21:46:39 +02:00
|
|
|
|
2009-08-09 12:51:02 +00:00
|
|
|
format = settings.value(prefix + "format").toString();
|
2020-08-18 21:46:39 +02:00
|
|
|
|
|
|
|
draw_grid = settings.value(prefix + "drawgrid",
|
|
|
|
false).toBool();
|
|
|
|
draw_border = settings.value(prefix + "drawborder",
|
|
|
|
true ).toBool();
|
|
|
|
draw_titleblock = settings.value(prefix + "drawtitleblock",
|
|
|
|
true ).toBool();
|
|
|
|
draw_terminals = settings.value(prefix + "drawterminals",
|
|
|
|
false).toBool();
|
2024-03-27 15:15:53 +01:00
|
|
|
draw_bg_transparent = settings.value(prefix + "drawbgtransparent",
|
|
|
|
false).toBool();
|
2020-08-18 21:46:39 +02:00
|
|
|
draw_colored_conductors = settings.value(
|
|
|
|
prefix + "drawcoloredconductors",
|
|
|
|
true ).toBool();
|
|
|
|
|
|
|
|
exported_area = QET::diagramAreaFromString(
|
|
|
|
settings.value(
|
|
|
|
prefix + "area",
|
|
|
|
"border").toString());
|
2009-08-09 12:51:02 +00:00
|
|
|
}
|
2014-10-26 11:57:38 +00:00
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
@brief ExportProperties::defaultProperties
|
|
|
|
@return the default properties stored in the setting file
|
|
|
|
*/
|
2015-09-16 15:11:13 +00:00
|
|
|
ExportProperties ExportProperties::defaultExportProperties()
|
|
|
|
{
|
|
|
|
QSettings settings;
|
2014-10-26 11:57:38 +00:00
|
|
|
|
|
|
|
ExportProperties def;
|
|
|
|
def.fromSettings(settings, "export/default");
|
|
|
|
|
|
|
|
return(def);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
@brief ExportProperties::defaultPrintProperties
|
|
|
|
@return the default properties stored in the setting file
|
|
|
|
*/
|
2015-09-16 15:11:13 +00:00
|
|
|
ExportProperties ExportProperties::defaultPrintProperties()
|
|
|
|
{
|
|
|
|
QSettings settings;
|
2014-10-26 11:57:38 +00:00
|
|
|
|
|
|
|
ExportProperties def;
|
|
|
|
def.fromSettings(settings, "print/default");
|
|
|
|
|
|
|
|
return(def);
|
|
|
|
}
|