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 "splineoptions.h"
17 #include "actiondrawspline.h"
18 #include "actioninterface.h"
21 SplineOptions::SplineOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
22 QWidget(parent, flags),
23 lDegree(new QLabel(tr("Degree:"))),
24 cbDegree(new QComboBox(this)),
25 cbClosed(new QCheckBox(tr("Closed"))),
26 bUndo(new QToolButton(this))
28 QHBoxLayout * layout = new QHBoxLayout(this);
29 layout->setContentsMargins(0, 0, 0, 0);
31 // leDist->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
33 degrees << "1" << "2" << "3";
34 cbDegree->addItems(degrees);
35 bUndo->setText(tr("Undo"));
37 layout->addWidget(lDegree);
38 layout->addWidget(cbDegree);
39 layout->addWidget(cbClosed);
40 layout->addWidget(bUndo);
42 connect(cbDegree, SIGNAL(activated(QString)), this, SLOT(setDegree(QString)));
43 connect(cbClosed, SIGNAL(toggled(bool)), this, SLOT(setClosed(bool)));
44 connect(bUndo, SIGNAL(clicked()), this, SLOT(undo()));
46 // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
47 // nothing will show up on the screen. :-)
49 parent->addWidget(this);
52 SplineOptions::~SplineOptions()
54 settings.beginGroup("Draw");
55 settings.setValue("SplineDegree", cbDegree->currentText().toInt());
56 settings.setValue("SplineClosed", cbClosed->isChecked());
60 void SplineOptions::setAction(ActionInterface * a, bool update)
62 if (a != NULL && a->rtti() == RS2::ActionDrawSpline)
64 action = (ActionDrawSpline *)a;
71 degree = action->getDegree();
72 closed = action->isClosed();
76 settings.beginGroup("Draw");
77 degree = settings.value("SplineDegree", 3).toInt();
78 closed = settings.value("SplineClosed", false).toBool();
80 action->setDegree(degree);
81 action->setClosed(closed);
84 cbDegree->setCurrentIndex(cbDegree->findText(QString("%1").arg(degree)));
85 cbClosed->setChecked(closed);
89 RS_DEBUG->print(RS_Debug::D_ERROR, "SplineOptions::setAction: wrong action type");
94 void SplineOptions::setClosed(bool c)
100 void SplineOptions::undo()
106 void SplineOptions::setDegree(const QString & deg)
109 action->setDegree(deg.toInt());