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 "dimoptions.h"
19 #include "actiondimension.h"
20 #include "actioninterface.h"
23 DimOptions::DimOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
24 QWidget(parent, flags),
25 lLabel(new QLabel(tr("Label:"))),
26 bDiameter(new QToolButton(this)),
27 leLabel(new QLineEdit(this)),
28 cbSymbol(new QComboBox(this)),
30 leTol1(new QLineEdit(this)),
32 leTol2(new QLineEdit(this))
34 QHBoxLayout * layout = new QHBoxLayout(this);
35 layout->setContentsMargins(0, 0, 0, 0);
37 leLabel->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
38 leTol1->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
39 leTol2->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
40 bDiameter->setCheckable(true);
41 bDiameter->setIcon(QIcon(":/res/qg_dimdia"));
42 lTol1->setPixmap(QPixmap(":/res/qg_dimtol1"));
43 lTol2->setPixmap(QPixmap(":/res/qg_dimtol2"));
47 << QString::fromUtf8("\303\270")
48 << QString::fromUtf8("\302\260")
49 << QString::fromUtf8("\302\261")
50 << QString::fromUtf8("\302\266")
51 << QString::fromUtf8("\303\227")
52 << QString::fromUtf8("\303\267");
53 cbSymbol->addItems(symbols);
55 layout->addWidget(lLabel);
56 layout->addWidget(bDiameter);
57 layout->addWidget(leLabel);
58 layout->addWidget(cbSymbol);
59 layout->addWidget(lTol1);
60 layout->addWidget(leTol1);
61 layout->addWidget(lTol2);
62 layout->addWidget(leTol2);
64 connect(leLabel, SIGNAL(textChanged(QString)), this, SLOT(updateLabel()));
65 connect(bDiameter, SIGNAL(toggled(bool)), this, SLOT(updateLabel()));
66 connect(leTol1, SIGNAL(textChanged(QString)), this, SLOT(updateLabel()));
67 connect(leTol2, SIGNAL(textChanged(QString)), this, SLOT(updateLabel()));
68 connect(cbSymbol, SIGNAL(activated(QString)), this, SLOT(insertSign(QString)));
70 // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
71 // nothing will show up on the screen. :-)
73 parent->addWidget(this);
76 DimOptions::~DimOptions()
78 settings.beginGroup("Draw");
79 settings.setValue("DimLabel", leLabel->text());
80 settings.setValue("DimTol1", leTol1->text());
81 settings.setValue("DimTol2", leTol2->text());
85 void DimOptions::setAction(ActionInterface * a, bool update)
87 if (a != NULL && ActionDimension::isDimensionAction(a->rtti()))
89 action = (ActionDimension *)a;
98 st = action->getLabel();
99 stol1 = action->getTol1();
100 stol2 = action->getTol2();
101 diam = action->getDiameter();
105 settings.beginGroup("Draw");
106 st = settings.value("DimLabel", "").toString();
107 stol1 = settings.value("DimTol1", "").toString();
108 stol2 = settings.value("DimTol2", "").toString();
109 diam = settings.value("DimDiameter", false).toBool();
113 leLabel->setText(st);
114 leTol1->setText(stol1);
115 leTol2->setText(stol2);
116 bDiameter->setChecked(diam);
120 RS_DEBUG->print(RS_Debug::D_ERROR, "DimensionOptions::setAction: wrong action type");
125 void DimOptions::updateLabel()
131 action->setLabel(leLabel->text());
132 action->setDiameter(bDiameter->isChecked());
133 action->setTol1(leTol1->text());
134 action->setTol2(leTol2->text());
135 action->setText(action->getText());
138 void DimOptions::insertSign(const QString & c)