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"
24 DimOptions::DimOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
25 QWidget(parent, flags),
26 lLabel(new QLabel(tr("Label:"))),
27 bDiameter(new QToolButton(this)),
28 leLabel(new QLineEdit(this)),
29 cbSymbol(new QComboBox(this)),
31 leTol1(new QLineEdit(this)),
33 leTol2(new QLineEdit(this))
35 QHBoxLayout * layout = new QHBoxLayout(this);
36 layout->setContentsMargins(0, 0, 0, 0);
38 leLabel->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
39 leTol1->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
40 leTol2->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
41 bDiameter->setCheckable(true);
42 bDiameter->setIcon(QIcon(":/res/qg_dimdia"));
43 lTol1->setPixmap(QPixmap(":/res/qg_dimtol1"));
44 lTol2->setPixmap(QPixmap(":/res/qg_dimtol2"));
48 << QString::fromUtf8("\303\270")
49 << QString::fromUtf8("\302\260")
50 << QString::fromUtf8("\302\261")
51 << QString::fromUtf8("\302\266")
52 << QString::fromUtf8("\303\227")
53 << QString::fromUtf8("\303\267");
54 cbSymbol->addItems(symbols);
56 layout->addWidget(lLabel);
57 layout->addWidget(bDiameter);
58 layout->addWidget(leLabel);
59 layout->addWidget(cbSymbol);
60 layout->addWidget(lTol1);
61 layout->addWidget(leTol1);
62 layout->addWidget(lTol2);
63 layout->addWidget(leTol2);
65 connect(leLabel, SIGNAL(textChanged(QString)), this, SLOT(updateLabel()));
66 connect(bDiameter, SIGNAL(toggled(bool)), this, SLOT(updateLabel()));
67 connect(leTol1, SIGNAL(textChanged(QString)), this, SLOT(updateLabel()));
68 connect(leTol2, SIGNAL(textChanged(QString)), this, SLOT(updateLabel()));
69 connect(cbSymbol, SIGNAL(activated(QString)), this, SLOT(insertSign(QString)));
71 // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
72 // nothing will show up on the screen. :-)
74 parent->addWidget(this);
77 DimOptions::~DimOptions()
79 settings.beginGroup("Draw");
80 settings.setValue("DimLabel", leLabel->text());
81 settings.setValue("DimTol1", leTol1->text());
82 settings.setValue("DimTol2", leTol2->text());
86 void DimOptions::setAction(ActionInterface * a, bool update)
88 if (a != NULL && ActionDimension::isDimensionAction(a->rtti()))
90 action = (ActionDimension *)a;
99 st = action->getLabel();
100 stol1 = action->getTol1();
101 stol2 = action->getTol2();
102 diam = action->getDiameter();
106 settings.beginGroup("Draw");
107 st = settings.value("DimLabel", "").toString();
108 stol1 = settings.value("DimTol1", "").toString();
109 stol2 = settings.value("DimTol2", "").toString();
110 diam = settings.value("DimDiameter", false).toBool();
114 leLabel->setText(st);
115 leTol1->setText(stol1);
116 leTol2->setText(stol2);
117 bDiameter->setChecked(diam);
121 DEBUG->print(Debug::D_ERROR, "DimensionOptions::setAction: wrong action type");
126 void DimOptions::updateLabel()
132 action->setLabel(leLabel->text());
133 action->setDiameter(bDiameter->isChecked());
134 action->setTol1(leTol1->text());
135 action->setTol2(leTol2->text());
136 action->setText(action->getText());
139 void DimOptions::insertSign(const QString & c)