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"
24 BevelOptions::BevelOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
25 QWidget(parent, flags),
26 cbTrim(new QCheckBox(tr("Trim"))),
27 lLength1(new QLabel(tr("Length 1:"))),
28 lLength2(new QLabel(tr("Length 2:"))),
29 leLength1(new QLineEdit(this)),
30 leLength2(new QLineEdit(this)),
31 sep1(new QFrame(this))
33 QHBoxLayout * layout = new QHBoxLayout(this);
34 layout->setContentsMargins(0, 0, 0, 0);
36 leLength1->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
37 leLength2->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
38 sep1->setFrameShape(QFrame::VLine);
39 sep1->setFrameShadow(QFrame::Sunken);
41 layout->addWidget(cbTrim);
42 layout->addWidget(sep1);
43 layout->addWidget(lLength1);
44 layout->addWidget(leLength1);
45 layout->addWidget(lLength2);
46 layout->addWidget(leLength2);
48 connect(cbTrim, SIGNAL(toggled(bool)), this, SLOT(updateData()));
49 connect(leLength1, SIGNAL(textChanged(QString)), this, SLOT(updateData()));
50 connect(leLength2, SIGNAL(textChanged(QString)), this, SLOT(updateData()));
52 // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
53 // nothing will show up on the screen. :-)
55 parent->addWidget(this);
58 BevelOptions::~BevelOptions()
60 settings.beginGroup("Modify");
61 settings.setValue("BevelLength1", leLength1->text());
62 settings.setValue("BevelLength2", leLength2->text());
63 settings.setValue("BevelTrim", cbTrim->isChecked());
67 void BevelOptions::setAction(ActionInterface * a, bool update)
69 if (a != NULL && a->rtti() == RS2::ActionModifyBevel)
71 action = (ActionModifyBevel *)a;
79 sd1 = QString("%1").arg(action->getLength1());
80 sd2 = QString("%1").arg(action->getLength2());
81 st = action->isTrimOn();
85 settings.beginGroup("Modify");
86 sd1 = settings.value("BevelLength1", "1.0").toString();
87 sd2 = settings.value("BevelLength2", "1.0").toString();
88 st = settings.value("BevelTrim", true).toBool();
92 leLength1->setText(sd1);
93 leLength2->setText(sd2);
94 cbTrim->setChecked(st);
98 RS_DEBUG->print(RS_Debug::D_ERROR, "BevelOptions::setAction: wrong action type");
103 void BevelOptions::updateData()
107 action->setTrim(cbTrim->isChecked());
108 action->setLength1(RS_Math::eval(leLength1->text()));
109 action->setLength2(RS_Math::eval(leLength2->text()));