1 // dimlinearoptions.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/09/2010 Created this file. :-)
15 #include "dimlinearoptions.h"
17 #include "actiondimlinear.h"
18 #include "actioninterface.h"
21 DimLinearOptions::DimLinearOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
22 QWidget(parent, flags),
23 lAngle(new QLabel(tr("Angle:"))),
24 leAngle(new QLineEdit(this)),
25 bHor(new QToolButton(this)),
26 bVer(new QToolButton(this))
28 QHBoxLayout * layout = new QHBoxLayout(this);
29 layout->setContentsMargins(0, 0, 0, 0);
31 leAngle->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
32 //still need to tweak this so it displays properly...
33 bHor->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding));
34 bHor->setIcon(QIcon(":/res/qg_dimhor"));
35 bVer->setIcon(QIcon(":/res/qg_dimver"));
37 layout->addWidget(lAngle);
38 layout->addWidget(leAngle);
39 layout->addWidget(bHor);
40 layout->addWidget(bVer);
42 connect(leAngle, SIGNAL(textChanged(QString)), this, SLOT(updateAngle(QString)));
43 connect(bHor, SIGNAL(clicked()), this, SLOT(setHor()));
44 connect(bVer, SIGNAL(clicked()), this, SLOT(setVer()));
46 // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
47 // nothing will show up on the screen. :-)
49 parent->addWidget(this);
52 DimLinearOptions::~DimLinearOptions()
54 settings.beginGroup("Dimension");
55 settings.setValue("Angle", leAngle->text());
59 void DimLinearOptions::setAction(ActionInterface * a, bool update)
61 if (a != NULL && a->rtti() == RS2::ActionDimLinear)
63 action = (ActionDimLinear *)a;
68 sa = QString("%1").arg(RS_Math::rad2deg(action->getAngle()));
71 settings.beginGroup("Dimension");
72 sa = settings.value("Angle", "0.0").toString();
79 RS_DEBUG->print(RS_Debug::D_ERROR, "DimLinearOptions::setAction: wrong action type");
84 void DimLinearOptions::updateAngle(const QString & a)
87 action->setAngle(RS_Math::deg2rad(RS_Math::eval(a)));
90 void DimLinearOptions::setHor()
92 leAngle->setText("0");
95 void DimLinearOptions::setVer()
97 leAngle->setText("90");