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 "splineoptions.h"
19 #include "actiondrawspline.h"
20 #include "actioninterface.h"
23 SplineOptions::SplineOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
24 QWidget(parent, flags),
25 lDegree(new QLabel(tr("Degree:"))),
26 cbDegree(new QComboBox(this)),
27 cbClosed(new QCheckBox(tr("Closed"))),
28 bUndo(new QToolButton(this))
30 QHBoxLayout * layout = new QHBoxLayout(this);
31 layout->setContentsMargins(0, 0, 0, 0);
33 // leDist->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
35 degrees << "1" << "2" << "3";
36 cbDegree->addItems(degrees);
37 bUndo->setText(tr("Undo"));
39 layout->addWidget(lDegree);
40 layout->addWidget(cbDegree);
41 layout->addWidget(cbClosed);
42 layout->addWidget(bUndo);
44 connect(cbDegree, SIGNAL(activated(QString)), this, SLOT(setDegree(QString)));
45 connect(cbClosed, SIGNAL(toggled(bool)), this, SLOT(setClosed(bool)));
46 connect(bUndo, SIGNAL(clicked()), this, SLOT(undo()));
48 // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
49 // nothing will show up on the screen. :-)
51 parent->addWidget(this);
54 SplineOptions::~SplineOptions()
56 settings.beginGroup("Draw");
57 settings.setValue("SplineDegree", cbDegree->currentText().toInt());
58 settings.setValue("SplineClosed", cbClosed->isChecked());
62 void SplineOptions::setAction(ActionInterface * a, bool update)
64 if (a != NULL && a->rtti() == RS2::ActionDrawSpline)
66 action = (ActionDrawSpline *)a;
73 degree = action->getDegree();
74 closed = action->isClosed();
78 settings.beginGroup("Draw");
79 degree = settings.value("SplineDegree", 3).toInt();
80 closed = settings.value("SplineClosed", false).toBool();
82 action->setDegree(degree);
83 action->setClosed(closed);
86 cbDegree->setCurrentIndex(cbDegree->findText(QString("%1").arg(degree)));
87 cbClosed->setChecked(closed);
91 RS_DEBUG->print(RS_Debug::D_ERROR, "SplineOptions::setAction: wrong action type");
96 void SplineOptions::setClosed(bool c)
102 void SplineOptions::undo()
108 void SplineOptions::setDegree(const QString & deg)
111 action->setDegree(deg.toInt());