1
/****************************************************************************
3
** This file is part of the LibreCAD project, a 2D CAD program
5
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
6
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
9
** This file may be distributed and/or modified under the terms of the
10
** GNU General Public License version 2 as published by the Free Software
11
** Foundation and appearing in the file gpl-2.0.txt included in the
12
** packaging of this file.
14
** This program is distributed in the hope that it will be useful,
15
** but WITHOUT ANY WARRANTY; without even the implied warranty of
16
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
** GNU General Public License for more details.
19
** You should have received a copy of the GNU General Public License
20
** along with this program; if not, write to the Free Software
21
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
** This copyright notice MUST APPEAR in all copies of the script!
25
**********************************************************************/
26
#include "qg_insertoptions.h"
28
#include "rs_actioninterface.h"
29
#include "rs_actionblocksinsert.h"
30
#include "rs_settings.h"
33
* Constructs a QG_InsertOptions as a child of 'parent', with the
34
* name 'name' and widget flags set to 'f'.
36
QG_InsertOptions::QG_InsertOptions(QWidget* parent, Qt::WindowFlags fl)
44
* Destroys the object and frees any allocated resources
46
QG_InsertOptions::~QG_InsertOptions()
49
// no need to delete child widgets, Qt does it all for us
53
* Sets the strings of the subwidgets using the current
56
void QG_InsertOptions::languageChange()
61
void QG_InsertOptions::destroy() {
62
RS_SETTINGS->beginGroup("/Insert");
63
RS_SETTINGS->writeEntry("/InsertAngle", leAngle->text());
64
RS_SETTINGS->writeEntry("/InsertFactor", leFactor->text());
65
RS_SETTINGS->writeEntry("/InsertColumns", sbColumns->text());
66
RS_SETTINGS->writeEntry("/InsertRows", sbRows->text());
67
RS_SETTINGS->writeEntry("/InsertColumnSpacing", leColumnSpacing->text());
68
RS_SETTINGS->writeEntry("/InsertRowSpacing", leRowSpacing->text());
69
RS_SETTINGS->endGroup();
72
void QG_InsertOptions::setAction(RS_ActionInterface* a, bool update) {
73
if (a!=NULL && a->rtti()==RS2::ActionBlocksInsert) {
74
action = (RS_ActionBlocksInsert*)a;
80
QString sColumnSpacing;
83
sAngle = QString("%1").arg(RS_Math::rad2deg(action->getAngle()));
84
sFactor = QString("%1").arg(action->getFactor());
85
sColumns = QString("%1").arg(action->getColumns());
86
sRows = QString("%1").arg(action->getRows());
87
sColumnSpacing = QString("%1").arg(action->getColumnSpacing());
88
sRowSpacing = QString("%1").arg(action->getRowSpacing());
90
RS_SETTINGS->beginGroup("/Insert");
91
sAngle = RS_SETTINGS->readEntry("/InsertAngle", "0.0");
92
sFactor = RS_SETTINGS->readEntry("/InsertFactor", "1.0");
93
sColumns = RS_SETTINGS->readEntry("/InsertColumns", "1");
94
sRows = RS_SETTINGS->readEntry("/InsertRows", "1");
95
sColumnSpacing = RS_SETTINGS->readEntry("/InsertColumnSpacing", "1.0");
96
sRowSpacing = RS_SETTINGS->readEntry("/InsertRowSpacing", "1.0");
97
RS_SETTINGS->endGroup();
99
leAngle->setText(sAngle);
100
leFactor->setText(sFactor);
101
sbColumns->setValue(sColumns.toInt());
102
sbRows->setValue(sRows.toInt());
103
leColumnSpacing->setText(sColumnSpacing);
104
leRowSpacing->setText(sRowSpacing);
106
RS_DEBUG->print(RS_Debug::D_ERROR,
107
"QG_InsertOptions::setAction: wrong action type");
112
void QG_InsertOptions::updateData() {
114
action->setAngle(RS_Math::deg2rad(RS_Math::eval(leAngle->text())));
115
action->setFactor(RS_Math::eval(leFactor->text()));
116
action->setColumns(sbColumns->value());
117
action->setRows(sbRows->value());
118
action->setColumnSpacing(RS_Math::eval(leColumnSpacing->text()));
119
action->setRowSpacing(RS_Math::eval(leRowSpacing->text()));