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/08/2010 Created this file. :-)
17 #include "circleoptions.h"
20 #include "actioninterface.h"
21 #include "actiondrawcirclecr.h"
24 CircleOptions::CircleOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
25 QWidget(parent, flags)
27 QHBoxLayout * layout = new QHBoxLayout(this);
28 layout->setContentsMargins(0, 0, 0, 0);
30 lRadius = new QLabel(tr("Radius:"));
31 leRadius = new QLineEdit(this);
32 leRadius->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
34 layout->addWidget(lRadius);
35 layout->addWidget(leRadius);
37 connect(leRadius, SIGNAL(textChanged(QString)), this, SLOT(updateRadius(QString)));
39 // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
40 // nothing will show up on the screen. :-)
42 parent->addWidget(this);
45 CircleOptions::~CircleOptions()
47 settings.beginGroup("Draw");
48 settings.setValue("CircleRadius", leRadius->text());
52 void CircleOptions::setAction(ActionInterface * a, bool update)
54 if (a != NULL && a->rtti() == RS2::ActionDrawCircleCR)
56 action = (ActionDrawCircleCR *)a;
61 sr = QString("%1").arg(action->getRadius());
64 settings.beginGroup("Draw");
65 sr = settings.value("CircleRadius", "1.0").toString();
67 action->setRadius(sr.toDouble());
70 leRadius->setText(sr);
74 RS_DEBUG->print(RS_Debug::D_ERROR,
75 "CircleOptions::setAction: wrong action type");
80 void CircleOptions::updateRadius(const QString & r)
83 action->setRadius(RS_Math::eval(r));