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 // 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 "linebisectoroptions.h"
19 #include "actiondrawlinebisector.h"
22 LineBisectorOptions::LineBisectorOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
23 QWidget(parent, flags),
24 lLength(new QLabel(tr("Length:"))),
25 leLength(new QLineEdit(this)),
26 lNumber(new QLabel(tr("Number:"))),
27 sbNumber(new QSpinBox(this))
29 QHBoxLayout * layout = new QHBoxLayout(this);
30 layout->setContentsMargins(0, 0, 0, 0);
32 leLength->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
34 layout->addWidget(lLength);
35 layout->addWidget(leLength);
36 layout->addWidget(lNumber);
37 layout->addWidget(sbNumber);
39 connect(leLength, SIGNAL(textChanged(QString)), this, SLOT(updateLength(QString)));
40 connect(sbNumber, SIGNAL(valueChanged(int)), this, SLOT(updateNumber(int)));
42 // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
43 // nothing will show up on the screen. :-)
45 parent->addWidget(this);
48 LineBisectorOptions::~LineBisectorOptions()
50 settings.beginGroup("Draw");
51 settings.setValue("LineBisectorLength", leLength->text());
52 settings.setValue("LineBisectorNumber", sbNumber->text());
56 void LineBisectorOptions::setAction(ActionInterface * a, bool update)
58 if (a != NULL && a->rtti() == RS2::ActionDrawLineBisector)
60 action = (ActionDrawLineBisector *)a;
67 sl = QString("%1").arg(action->getLength());
68 sn = QString("%1").arg(action->getNumber());
72 settings.beginGroup("Draw");
73 sl = settings.value("LineBisectorLength", "1.0").toString();
74 sn = settings.value("LineBisectorNumber", "1").toString();
78 leLength->setText(sl);
79 sbNumber->setValue(sn.toInt());
83 RS_DEBUG->print(RS_Debug::D_ERROR, "LineBisectorOptions::setAction: wrong action type");
88 void LineBisectorOptions::updateLength(const QString & l)
91 action->setLength(RS_Math::eval(l));
94 void LineBisectorOptions::updateNumber(int n)