]> Shamusworld >> Repos - architektonas/blob - src/forms/arctangentialoptions.cpp
Start of bringing back missing forms/dialogs
[architektonas] / src / forms / arctangentialoptions.cpp
1 // arctangentialoptions.cpp
2 //
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
7 //
8 // JLH = James L. Hammons <jlhamm@acm.org>
9 //
10 // Who  When        What
11 // ---  ----------  -----------------------------------------------------------
12 // JLH  06/08/2010  Created this file. :-)
13 //
14
15 #include "arctangentialoptions.h"
16
17 #include "rs_actiondrawarctangential.h"
18 #include "settings.h"
19
20 ArcTangentialOptions::ArcTangentialOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
21         QWidget(parent, flags)
22 {
23 #if 1
24         QHBoxLayout * layout = new QHBoxLayout(this);
25         layout->setContentsMargins(0, 0, 0, 0);
26
27         lRadius = new QLabel(tr("Radius:"));
28         leRadius = new QLineEdit(this);
29         leRadius->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
30
31         layout->addWidget(lRadius);
32         layout->addWidget(leRadius);
33
34         connect(leRadius, SIGNAL(textChanged(QString)), this, SLOT(updateRadius(QString)));
35
36         // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
37         // nothing will show up on the screen. :-)
38         if (parent)
39                 parent->addWidget(this);
40 #else
41         if (objectName().isEmpty())
42                 setObjectName(QString::fromUtf8("ArcTangentialOptions"));
43
44         resize(160, 24);
45         QSizePolicy policy(QSizePolicy::Fixed, QSizePolicy::Fixed);
46         policy.setHorizontalStretch(0);
47         policy.setVerticalStretch(0);
48         policy.setHeightForWidth(sizePolicy().hasHeightForWidth());
49         setSizePolicy(policy);
50         setMinimumSize(QSize(160, 22));
51
52         QHBoxLayout * hboxLayout = new QHBoxLayout(this);
53         hboxLayout->setSpacing(6);
54         hboxLayout->setContentsMargins(0, 0, 0, 0);
55         hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
56         lRadius = new QLabel(this);
57         lRadius->setObjectName(QString::fromUtf8("lRadius"));
58         lRadius->setWordWrap(false);
59
60         hboxLayout->addWidget(lRadius);
61
62         leRadius = new QLineEdit(this);
63         leRadius->setObjectName(QString::fromUtf8("leRadius"));
64         QSizePolicy sizePolicy1(QSizePolicy::Ignored, QSizePolicy::Fixed);
65         sizePolicy1.setHorizontalStretch(0);
66         sizePolicy1.setVerticalStretch(0);
67         sizePolicy1.setHeightForWidth(leRadius->sizePolicy().hasHeightForWidth());
68         leRadius->setSizePolicy(sizePolicy1);
69
70         hboxLayout->addWidget(leRadius);
71
72         sep1 = new QFrame(this);
73         sep1->setObjectName(QString::fromUtf8("sep1"));
74         QSizePolicy sizePolicy2(QSizePolicy::Fixed, QSizePolicy::Minimum);
75         sizePolicy2.setHorizontalStretch(0);
76         sizePolicy2.setVerticalStretch(0);
77         sizePolicy2.setHeightForWidth(sep1->sizePolicy().hasHeightForWidth());
78         sep1->setSizePolicy(sizePolicy2);
79         sep1->setFrameShape(QFrame::VLine);
80         sep1->setFrameShadow(QFrame::Sunken);
81
82         hboxLayout->addWidget(sep1);
83
84 //      retranslateUi(ArcTangentialOptions);
85         QObject::connect(leRadius, SIGNAL(textChanged(QString)), this, SLOT(updateRadius(QString)));
86         QMetaObject::connectSlotsByName(this);
87 #endif
88 }
89
90 ArcTangentialOptions::~ArcTangentialOptions()
91 {
92         settings.beginGroup("Draw");
93         settings.setValue("ArcTangentialRadius", leRadius->text());
94         settings.endGroup();
95 }
96
97 void ArcTangentialOptions::setAction(RS_ActionInterface * a, bool update)
98 {
99         if (a != NULL && a->rtti() == RS2::ActionDrawArcTangential)
100         {
101                 action = (RS_ActionDrawArcTangential *)a;
102
103                 QString sr;
104
105                 if (update)
106                         sr = QString("%1").arg(action->getRadius());
107                 else
108                 {
109                         settings.beginGroup("Draw");
110                         sr = settings.value("ArcTangentialRadius", "1.0").toString();
111                         settings.endGroup();
112                         action->setRadius(sr.toDouble());
113                 }
114                 leRadius->setText(sr);
115         }
116         else
117         {
118                 RS_DEBUG->print(RS_Debug::D_ERROR,
119                         "ArcTangentialOptions::setAction: wrong action type");
120                 action = NULL;
121         }
122 }
123
124 /*void ArcTangentialOptions::init() {
125     data = NULL;
126     RS_SETTINGS->beginGroup("/Draw");
127     bool reversed = RS_SETTINGS->readNumEntry("/ArcReversed", 0);
128     RS_SETTINGS->endGroup();
129
130     rbNeg->setChecked(reversed);
131    }*/
132
133 /*void ArcTangentialOptions::setData(RS_ArcData* d) {
134     data = d;
135     updateDirection(false);
136    }*/
137
138 void ArcTangentialOptions::updateRadius(const QString & s)
139 {
140         if (action != NULL)
141                 action->setRadius(RS_Math::eval(s));
142 }
143