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/08/2010 Created this file. :-)
15 #include "beveloptions.h"
18 #include "rs_actioninterface.h"
19 #include "rs_actionmodifybevel.h"
22 BevelOptions::BevelOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
23 QWidget(parent, flags),
24 cbTrim(new QCheckBox(tr("Trim"))),
25 lLength1(new QLabel(tr("Length 1:"))),
26 lLength2(new QLabel(tr("Length 2:"))),
27 leLength1(new QLineEdit(this)),
28 leLength2(new QLineEdit(this)),
29 sep1(new QFrame(this))
31 QHBoxLayout * layout = new QHBoxLayout(this);
32 layout->setContentsMargins(0, 0, 0, 0);
34 leLength1->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
35 leLength2->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
36 sep1->setFrameShape(QFrame::VLine);
37 sep1->setFrameShadow(QFrame::Sunken);
39 layout->addWidget(cbTrim);
40 layout->addWidget(sep1);
41 layout->addWidget(lLength1);
42 layout->addWidget(leLength1);
43 layout->addWidget(lLength2);
44 layout->addWidget(leLength2);
46 connect(cbTrim, SIGNAL(toggled(bool)), this, SLOT(updateData()));
47 connect(leLength1, SIGNAL(textChanged(QString)), this, SLOT(updateData()));
48 connect(leLength2, SIGNAL(textChanged(QString)), this, SLOT(updateData()));
50 // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
51 // nothing will show up on the screen. :-)
53 parent->addWidget(this);
56 BevelOptions::~BevelOptions()
58 settings.beginGroup("Modify");
59 settings.setValue("BevelLength1", leLength1->text());
60 settings.setValue("BevelLength2", leLength2->text());
61 settings.setValue("BevelTrim", cbTrim->isChecked());
65 void BevelOptions::setAction(RS_ActionInterface * a, bool update)
67 if (a != NULL && a->rtti() == RS2::ActionModifyBevel)
69 action = (RS_ActionModifyBevel *)a;
77 sd1 = QString("%1").arg(action->getLength1());
78 sd2 = QString("%1").arg(action->getLength2());
79 st = action->isTrimOn();
83 settings.beginGroup("Modify");
84 sd1 = settings.value("BevelLength1", "1.0").toString();
85 sd2 = settings.value("BevelLength2", "1.0").toString();
86 st = settings.value("BevelTrim", true).toBool();
90 leLength1->setText(sd1);
91 leLength2->setText(sd2);
92 cbTrim->setChecked(st);
96 RS_DEBUG->print(RS_Debug::D_ERROR, "BevelOptions::setAction: wrong action type");
101 void BevelOptions::updateData()
105 action->setTrim(cbTrim->isChecked());
106 action->setLength1(RS_Math::eval(leLength1->text()));
107 action->setLength2(RS_Math::eval(leLength2->text()));