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 "dimoptions.h"
17 #include "rs_actiondimension.h"
18 #include "rs_actioninterface.h"
21 DimOptions::DimOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
22 QWidget(parent, flags),
23 lLabel(new QLabel(tr("Label:"))),
24 bDiameter(new QToolButton(this)),
25 leLabel(new QLineEdit(this)),
26 cbSymbol(new QComboBox(this)),
28 leTol1(new QLineEdit(this)),
30 leTol2(new QLineEdit(this))
32 QHBoxLayout * layout = new QHBoxLayout(this);
33 layout->setContentsMargins(0, 0, 0, 0);
35 leLabel->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
36 leTol1->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
37 leTol2->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
38 bDiameter->setCheckable(true);
39 bDiameter->setIcon(QIcon(":/res/qg_dimdia"));
40 lTol1->setPixmap(QPixmap(":/res/qg_dimtol1"));
41 lTol2->setPixmap(QPixmap(":/res/qg_dimtol2"));
45 << QString::fromUtf8("\303\270")
46 << QString::fromUtf8("\302\260")
47 << QString::fromUtf8("\302\261")
48 << QString::fromUtf8("\302\266")
49 << QString::fromUtf8("\303\227")
50 << QString::fromUtf8("\303\267");
51 cbSymbol->addItems(symbols);
53 layout->addWidget(lLabel);
54 layout->addWidget(bDiameter);
55 layout->addWidget(leLabel);
56 layout->addWidget(cbSymbol);
57 layout->addWidget(lTol1);
58 layout->addWidget(leTol1);
59 layout->addWidget(lTol2);
60 layout->addWidget(leTol2);
62 connect(leLabel, SIGNAL(textChanged(QString)), this, SLOT(updateLabel()));
63 connect(bDiameter, SIGNAL(toggled(bool)), this, SLOT(updateLabel()));
64 connect(leTol1, SIGNAL(textChanged(QString)), this, SLOT(updateLabel()));
65 connect(leTol2, SIGNAL(textChanged(QString)), this, SLOT(updateLabel()));
66 connect(cbSymbol, SIGNAL(activated(QString)), this, SLOT(insertSign(QString)));
68 // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
69 // nothing will show up on the screen. :-)
71 parent->addWidget(this);
74 DimOptions::~DimOptions()
76 settings.beginGroup("Draw");
77 settings.setValue("DimLabel", leLabel->text());
78 settings.setValue("DimTol1", leTol1->text());
79 settings.setValue("DimTol2", leTol2->text());
83 void DimOptions::setAction(RS_ActionInterface * a, bool update)
85 if (a != NULL && RS_ActionDimension::isDimensionAction(a->rtti()))
87 action = (RS_ActionDimension *)a;
96 st = action->getLabel();
97 stol1 = action->getTol1();
98 stol2 = action->getTol2();
99 diam = action->getDiameter();
103 settings.beginGroup("Draw");
104 st = settings.value("DimLabel", "").toString();
105 stol1 = settings.value("DimTol1", "").toString();
106 stol2 = settings.value("DimTol2", "").toString();
107 diam = settings.value("DimDiameter", false).toBool();
111 leLabel->setText(st);
112 leTol1->setText(stol1);
113 leTol2->setText(stol2);
114 bDiameter->setChecked(diam);
118 RS_DEBUG->print(RS_Debug::D_ERROR, "DimensionOptions::setAction: wrong action type");
123 void DimOptions::updateLabel()
129 action->setLabel(leLabel->text());
130 action->setDiameter(bDiameter->isChecked());
131 action->setTol1(leTol1->text());
132 action->setTol2(leTol2->text());
133 action->setText(action->getText());
136 void DimOptions::insertSign(const QString & c)