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"
24 DimLinearOptions::DimLinearOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
25 QWidget(parent, flags),
26 lAngle(new QLabel(tr("Angle:"))),
27 leAngle(new QLineEdit(this)),
28 bHor(new QToolButton(this)),
29 bVer(new QToolButton(this))
31 QHBoxLayout * layout = new QHBoxLayout(this);
32 layout->setContentsMargins(0, 0, 0, 0);
34 leAngle->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
35 //still need to tweak this so it displays properly...
36 bHor->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding));
37 bHor->setIcon(QIcon(":/res/qg_dimhor"));
38 bVer->setIcon(QIcon(":/res/qg_dimver"));
40 layout->addWidget(lAngle);
41 layout->addWidget(leAngle);
42 layout->addWidget(bHor);
43 layout->addWidget(bVer);
45 connect(leAngle, SIGNAL(textChanged(QString)), this, SLOT(updateAngle(QString)));
46 connect(bHor, SIGNAL(clicked()), this, SLOT(setHor()));
47 connect(bVer, SIGNAL(clicked()), this, SLOT(setVer()));
49 // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
50 // nothing will show up on the screen. :-)
52 parent->addWidget(this);
55 DimLinearOptions::~DimLinearOptions()
57 settings.beginGroup("Dimension");
58 settings.setValue("Angle", leAngle->text());
62 void DimLinearOptions::setAction(ActionInterface * a, bool update)
64 if (a != NULL && a->rtti() == RS2::ActionDimLinear)
66 action = (ActionDimLinear *)a;
71 sa = QString("%1").arg(Math::rad2deg(action->getAngle()));
74 settings.beginGroup("Dimension");
75 sa = settings.value("Angle", "0.0").toString();
82 DEBUG->print(Debug::D_ERROR, "DimLinearOptions::setAction: wrong action type");
87 void DimLinearOptions::updateAngle(const QString & a)
90 action->setAngle(Math::deg2rad(Math::eval(a)));
93 void DimLinearOptions::setHor()
95 leAngle->setText("0");
98 void DimLinearOptions::setVer()
100 leAngle->setText("90");