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/08/2010 Created this file. :-)
17 #include "beveloptions.h"
20 #include "actioninterface.h"
21 #include "actionmodifybevel.h"
25 BevelOptions::BevelOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
26 QWidget(parent, flags),
27 cbTrim(new QCheckBox(tr("Trim"))),
28 lLength1(new QLabel(tr("Length 1:"))),
29 lLength2(new QLabel(tr("Length 2:"))),
30 leLength1(new QLineEdit(this)),
31 leLength2(new QLineEdit(this)),
32 sep1(new QFrame(this))
34 QHBoxLayout * layout = new QHBoxLayout(this);
35 layout->setContentsMargins(0, 0, 0, 0);
37 leLength1->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
38 leLength2->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
39 sep1->setFrameShape(QFrame::VLine);
40 sep1->setFrameShadow(QFrame::Sunken);
42 layout->addWidget(cbTrim);
43 layout->addWidget(sep1);
44 layout->addWidget(lLength1);
45 layout->addWidget(leLength1);
46 layout->addWidget(lLength2);
47 layout->addWidget(leLength2);
49 connect(cbTrim, SIGNAL(toggled(bool)), this, SLOT(updateData()));
50 connect(leLength1, SIGNAL(textChanged(QString)), this, SLOT(updateData()));
51 connect(leLength2, SIGNAL(textChanged(QString)), this, SLOT(updateData()));
53 // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
54 // nothing will show up on the screen. :-)
56 parent->addWidget(this);
59 BevelOptions::~BevelOptions()
61 settings.beginGroup("Modify");
62 settings.setValue("BevelLength1", leLength1->text());
63 settings.setValue("BevelLength2", leLength2->text());
64 settings.setValue("BevelTrim", cbTrim->isChecked());
68 void BevelOptions::setAction(ActionInterface * a, bool update)
70 if (a != NULL && a->rtti() == RS2::ActionModifyBevel)
72 action = (ActionModifyBevel *)a;
80 sd1 = QString("%1").arg(action->getLength1());
81 sd2 = QString("%1").arg(action->getLength2());
82 st = action->isTrimOn();
86 settings.beginGroup("Modify");
87 sd1 = settings.value("BevelLength1", "1.0").toString();
88 sd2 = settings.value("BevelLength2", "1.0").toString();
89 st = settings.value("BevelTrim", true).toBool();
93 leLength1->setText(sd1);
94 leLength2->setText(sd2);
95 cbTrim->setChecked(st);
99 DEBUG->print(Debug::D_ERROR, "BevelOptions::setAction: wrong action type");
104 void BevelOptions::updateData()
108 action->setTrim(cbTrim->isChecked());
109 action->setLength1(Math::eval(leLength1->text()));
110 action->setLength2(Math::eval(leLength2->text()));