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 "roundoptions.h"
17 #include "rs_actionmodifyround.h"
20 RoundOptions::RoundOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
21 QWidget(parent, flags),
22 cbTrim(new QCheckBox(tr("Trim"))),
23 sep1(new QFrame(this)),
24 lRadius(new QLabel(tr("Radius:"))),
25 leRadius(new QLineEdit(this))
27 QHBoxLayout * layout = new QHBoxLayout(this);
28 layout->setContentsMargins(0, 0, 0, 0);
30 sep1->setFrameShape(QFrame::VLine);
31 sep1->setFrameShadow(QFrame::Sunken);
32 leRadius->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
34 layout->addWidget(cbTrim);
35 layout->addWidget(sep1);
36 layout->addWidget(lRadius);
37 layout->addWidget(leRadius);
39 connect(cbTrim, SIGNAL(toggled(bool)), this, SLOT(updateData()));
40 connect(leRadius, SIGNAL(textChanged(QString)), this, SLOT(updateData()));
42 // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
43 // nothing will show up on the screen. :-)
45 parent->addWidget(this);
48 RoundOptions::~RoundOptions()
50 settings.beginGroup("Modify");
51 settings.setValue("RoundRadius", leRadius->text());
52 settings.setValue("RoundTrim", cbTrim->isChecked());
56 void RoundOptions::setAction(RS_ActionInterface * a, bool update)
58 if (a != NULL && a->rtti() == RS2::ActionModifyRound)
60 action = (RS_ActionModifyRound *)a;
67 sr = QString("%1").arg(action->getRadius());
68 st = action->isTrimOn();
72 settings.beginGroup("Modify");
73 sr = settings.value("RoundRadius", "1.0").toString();
74 st = settings.value("RoundTrim", true).toBool();
78 leRadius->setText(sr);
79 cbTrim->setChecked(st);
83 RS_DEBUG->print(RS_Debug::D_ERROR, "LineParallelOptions::setAction: wrong action type");
88 void RoundOptions::updateData()
92 action->setTrim(cbTrim->isChecked());
93 action->setRadius(RS_Math::eval(leRadius->text()));