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