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"
24 SplineOptions::SplineOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
25 QWidget(parent, flags),
26 lDegree(new QLabel(tr("Degree:"))),
27 cbDegree(new QComboBox(this)),
28 cbClosed(new QCheckBox(tr("Closed"))),
29 bUndo(new QToolButton(this))
31 QHBoxLayout * layout = new QHBoxLayout(this);
32 layout->setContentsMargins(0, 0, 0, 0);
34 // leDist->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
36 degrees << "1" << "2" << "3";
37 cbDegree->addItems(degrees);
38 bUndo->setText(tr("Undo"));
40 layout->addWidget(lDegree);
41 layout->addWidget(cbDegree);
42 layout->addWidget(cbClosed);
43 layout->addWidget(bUndo);
45 connect(cbDegree, SIGNAL(activated(QString)), this, SLOT(setDegree(QString)));
46 connect(cbClosed, SIGNAL(toggled(bool)), this, SLOT(setClosed(bool)));
47 connect(bUndo, SIGNAL(clicked()), this, SLOT(undo()));
49 // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
50 // nothing will show up on the screen. :-)
52 parent->addWidget(this);
55 SplineOptions::~SplineOptions()
57 settings.beginGroup("Draw");
58 settings.setValue("SplineDegree", cbDegree->currentText().toInt());
59 settings.setValue("SplineClosed", cbClosed->isChecked());
63 void SplineOptions::setAction(ActionInterface * a, bool update)
65 if (a != NULL && a->rtti() == RS2::ActionDrawSpline)
67 action = (ActionDrawSpline *)a;
74 degree = action->getDegree();
75 closed = action->isClosed();
79 settings.beginGroup("Draw");
80 degree = settings.value("SplineDegree", 3).toInt();
81 closed = settings.value("SplineClosed", false).toBool();
83 action->setDegree(degree);
84 action->setClosed(closed);
87 cbDegree->setCurrentIndex(cbDegree->findText(QString("%1").arg(degree)));
88 cbClosed->setChecked(closed);
92 DEBUG->print(Debug::D_ERROR, "SplineOptions::setAction: wrong action type");
97 void SplineOptions::setClosed(bool c)
100 action->setClosed(c);
103 void SplineOptions::undo()
109 void SplineOptions::setDegree(const QString & deg)
112 action->setDegree(deg.toInt());