1 // linebisectoroptions.cpp
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 "linebisectoroptions.h"
17 #include "actiondrawlinebisector.h"
20 LineBisectorOptions::LineBisectorOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
21 QWidget(parent, flags),
22 lLength(new QLabel(tr("Length:"))),
23 leLength(new QLineEdit(this)),
24 lNumber(new QLabel(tr("Number:"))),
25 sbNumber(new QSpinBox(this))
27 QHBoxLayout * layout = new QHBoxLayout(this);
28 layout->setContentsMargins(0, 0, 0, 0);
30 leLength->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
32 layout->addWidget(lLength);
33 layout->addWidget(leLength);
34 layout->addWidget(lNumber);
35 layout->addWidget(sbNumber);
37 connect(leLength, SIGNAL(textChanged(QString)), this, SLOT(updateLength(QString)));
38 connect(sbNumber, SIGNAL(valueChanged(int)), this, SLOT(updateNumber(int)));
40 // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
41 // nothing will show up on the screen. :-)
43 parent->addWidget(this);
46 LineBisectorOptions::~LineBisectorOptions()
48 settings.beginGroup("Draw");
49 settings.setValue("LineBisectorLength", leLength->text());
50 settings.setValue("LineBisectorNumber", sbNumber->text());
54 void LineBisectorOptions::setAction(ActionInterface * a, bool update)
56 if (a != NULL && a->rtti() == RS2::ActionDrawLineBisector)
58 action = (ActionDrawLineBisector *)a;
65 sl = QString("%1").arg(action->getLength());
66 sn = QString("%1").arg(action->getNumber());
70 settings.beginGroup("Draw");
71 sl = settings.value("LineBisectorLength", "1.0").toString();
72 sn = settings.value("LineBisectorNumber", "1").toString();
76 leLength->setText(sl);
77 sbNumber->setValue(sn.toInt());
81 RS_DEBUG->print(RS_Debug::D_ERROR, "LineBisectorOptions::setAction: wrong action type");
86 void LineBisectorOptions::updateLength(const QString & l)
89 action->setLength(RS_Math::eval(l));
92 void LineBisectorOptions::updateNumber(int n)