1 // libraryinsertoptions.cpp
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 06/10/2010 Created this file. :-)
15 #include "libraryinsertoptions.h"
17 #include "actionlibraryinsert.h"
20 LibraryInsertOptions::LibraryInsertOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
21 QWidget(parent, flags),
22 lAngle(new QLabel(tr("Angle:"))),
23 leAngle(new QLineEdit(this)),
24 lFactor(new QLabel(tr("Factor:"))),
25 leFactor(new QLineEdit(this))
27 QHBoxLayout * layout = new QHBoxLayout(this);
28 layout->setContentsMargins(0, 0, 0, 0);
30 leAngle->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
31 leFactor->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
33 layout->addWidget(lAngle);
34 layout->addWidget(leAngle);
35 layout->addWidget(lFactor);
36 layout->addWidget(leFactor);
38 connect(leAngle, SIGNAL(textChanged(QString)), this, SLOT(updateData()));
39 connect(leFactor, SIGNAL(textChanged(QString)), this, SLOT(updateData()));
41 // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
42 // nothing will show up on the screen. :-)
44 parent->addWidget(this);
47 LibraryInsertOptions::~LibraryInsertOptions()
49 settings.beginGroup("LibraryInsert");
50 settings.setValue("LibraryInsertAngle", leAngle->text());
51 settings.setValue("LibraryInsertFactor", leFactor->text());
55 void LibraryInsertOptions::setAction(ActionInterface * a, bool update)
57 if (a != NULL && a->rtti() == RS2::ActionLibraryInsert)
59 action = (ActionLibraryInsert *)a;
66 sAngle = QString("%1").arg(RS_Math::rad2deg(action->getAngle()));
67 sFactor = QString("%1").arg(action->getFactor());
71 settings.beginGroup("LibraryInsert");
72 sAngle = settings.value("LibraryInsertAngle", "0.0").toString();
73 sFactor = settings.value("LibraryInsertFactor", "1.0").toString();
77 leAngle->setText(sAngle);
78 leFactor->setText(sFactor);
82 RS_DEBUG->print(RS_Debug::D_ERROR, "LibraryInsertOptions::setAction: wrong action type");
87 void LibraryInsertOptions::updateData()
91 action->setAngle(RS_Math::deg2rad(RS_Math::eval(leAngle->text())));
92 action->setFactor(RS_Math::eval(leFactor->text()));