1 // trimamountoptions.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 "trimamountoptions.h"
17 #include "rs_actionmodifytrimamount.h"
18 #include "rs_actioninterface.h"
23 TrimAmountOptions::TrimAmountOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
24 QWidget(parent, flags),
25 lDist(new QLabel(tr("Amount:"))),
26 leDist(new QLineEdit(this))
28 QHBoxLayout * layout = new QHBoxLayout(this);
29 layout->setContentsMargins(0, 0, 0, 0);
31 leDist->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
33 layout->addWidget(lDist);
34 layout->addWidget(leDist);
36 connect(leDist, SIGNAL(textChanged(QString)), this, SLOT(updateDist(QString)));
38 // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
39 // nothing will show up on the screen. :-)
41 parent->addWidget(this);
44 TrimAmountOptions::~TrimAmountOptions()
46 settings.beginGroup("Modify");
47 settings.setValue("TrimAmount", leDist->text());
51 void TrimAmountOptions::setAction(RS_ActionInterface * a, bool update)
53 if (a != NULL && a->rtti() == RS2::ActionModifyTrimAmount)
55 action = (RS_ActionModifyTrimAmount *)a;
59 // settings from action:
61 sd = QString("%1").arg(action->getDistance());
62 // settings from config file:
65 settings.beginGroup("Modify");
66 sd = settings.value("TrimAmount", "1.0").toString();
74 RS_DEBUG->print(RS_Debug::D_ERROR, "ModifyTrimAmountOptions::setAction: wrong action type");
79 void TrimAmountOptions::updateDist(const QString & d)
82 action->setDistance(RS_Math::eval(d, 1.0));