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 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
10 // JLH = James L. Hammons <jlhamm@acm.org>
13 // --- ---------- -----------------------------------------------------------
14 // JLH 06/10/2010 Created this file. :-)
17 #include "libraryinsertoptions.h"
19 #include "actionlibraryinsert.h"
22 LibraryInsertOptions::LibraryInsertOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
23 QWidget(parent, flags),
24 lAngle(new QLabel(tr("Angle:"))),
25 leAngle(new QLineEdit(this)),
26 lFactor(new QLabel(tr("Factor:"))),
27 leFactor(new QLineEdit(this))
29 QHBoxLayout * layout = new QHBoxLayout(this);
30 layout->setContentsMargins(0, 0, 0, 0);
32 leAngle->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
33 leFactor->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
35 layout->addWidget(lAngle);
36 layout->addWidget(leAngle);
37 layout->addWidget(lFactor);
38 layout->addWidget(leFactor);
40 connect(leAngle, SIGNAL(textChanged(QString)), this, SLOT(updateData()));
41 connect(leFactor, SIGNAL(textChanged(QString)), this, SLOT(updateData()));
43 // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
44 // nothing will show up on the screen. :-)
46 parent->addWidget(this);
49 LibraryInsertOptions::~LibraryInsertOptions()
51 settings.beginGroup("LibraryInsert");
52 settings.setValue("LibraryInsertAngle", leAngle->text());
53 settings.setValue("LibraryInsertFactor", leFactor->text());
57 void LibraryInsertOptions::setAction(ActionInterface * a, bool update)
59 if (a != NULL && a->rtti() == RS2::ActionLibraryInsert)
61 action = (ActionLibraryInsert *)a;
68 sAngle = QString("%1").arg(Math::rad2deg(action->getAngle()));
69 sFactor = QString("%1").arg(action->getFactor());
73 settings.beginGroup("LibraryInsert");
74 sAngle = settings.value("LibraryInsertAngle", "0.0").toString();
75 sFactor = settings.value("LibraryInsertFactor", "1.0").toString();
79 leAngle->setText(sAngle);
80 leFactor->setText(sFactor);
84 DEBUG->print(Debug::D_ERROR, "LibraryInsertOptions::setAction: wrong action type");
89 void LibraryInsertOptions::updateData()
93 action->setAngle(Math::deg2rad(Math::eval(leAngle->text())));
94 action->setFactor(Math::eval(leFactor->text()));