]> Shamusworld >> Repos - architektonas/blob - src/forms/arcoptions.cpp
Added more missing forms, fixed missing header files in MdiWindow
[architektonas] / src / forms / arcoptions.cpp
1 // arcoptions.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 // JLH  06/08/2010  Fixed problem with widget not showing up in toolbar.
14 //
15
16 #include "arcoptions.h"
17
18 #include "rs_actiondrawarc.h"
19 #include "rs_actioninterface.h"
20 #include "settings.h"
21
22 ArcOptions::ArcOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
23         QWidget(parent, flags),
24         rbPos(new QRadioButton(this)),
25         rbNeg(new QRadioButton(this))
26 {
27         QHBoxLayout * layout = new QHBoxLayout(this);
28         layout->setContentsMargins(0, 0, 0, 0);
29
30         rbPos->setIcon(QIcon(":/res/qg_dirpos"));
31         rbNeg->setIcon(QIcon(":/res/qg_dirneg"));
32
33         layout->addWidget(rbPos);
34         layout->addWidget(rbNeg);
35
36         connect(rbPos, SIGNAL(toggled(bool)), this, SLOT(updateDirection(bool)));
37         connect(rbNeg, SIGNAL(toggled(bool)), this, SLOT(updateDirection(bool)));
38
39         // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
40         // nothing will show up on the screen. :-)
41         if (parent)
42                 parent->addWidget(this);
43 }
44
45 ArcOptions::~ArcOptions()
46 {
47         settings.beginGroup("Draw");
48         settings.setValue("ArcReversed", rbNeg->isChecked());
49         settings.endGroup();
50 }
51
52 void ArcOptions::setAction(RS_ActionInterface * a, bool update)
53 {
54         if (a != NULL && a->rtti() == RS2::ActionDrawArc)
55         {
56                 action = (RS_ActionDrawArc *)a;
57
58                 bool reversed;
59
60                 if (update)
61                         reversed = action->isReversed();
62                 else
63                 {
64                         settings.beginGroup("Draw");
65                         reversed = settings.value("ArcReversed", false).toBool();
66                         settings.endGroup();
67                         action->setReversed(reversed);
68                 }
69
70                 rbNeg->setChecked(reversed);
71         }
72         else
73         {
74                 RS_DEBUG->print(RS_Debug::D_ERROR, "QG_ArcOptions::setAction: wrong action type");
75                 action = NULL;
76         }
77 }
78
79 void ArcOptions::updateDirection(bool /*pos*/)
80 {
81         if (action != NULL)
82                 action->setReversed(rbNeg->isChecked());
83 }