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/08/2010 Created this file. :-)
13 // JLH 06/08/2010 Fixed problem with widget not showing up in toolbar.
16 #include "arcoptions.h"
18 #include "rs_actiondrawarc.h"
19 #include "rs_actioninterface.h"
22 ArcOptions::ArcOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
23 QWidget(parent, flags),
24 rbPos(new QRadioButton(this)),
25 rbNeg(new QRadioButton(this))
27 QHBoxLayout * layout = new QHBoxLayout(this);
28 layout->setContentsMargins(0, 0, 0, 0);
30 rbPos->setIcon(QIcon(":/res/qg_dirpos"));
31 rbNeg->setIcon(QIcon(":/res/qg_dirneg"));
33 layout->addWidget(rbPos);
34 layout->addWidget(rbNeg);
36 connect(rbPos, SIGNAL(toggled(bool)), this, SLOT(updateDirection(bool)));
37 connect(rbNeg, SIGNAL(toggled(bool)), this, SLOT(updateDirection(bool)));
39 // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
40 // nothing will show up on the screen. :-)
42 parent->addWidget(this);
45 ArcOptions::~ArcOptions()
47 settings.beginGroup("Draw");
48 settings.setValue("ArcReversed", rbNeg->isChecked());
52 void ArcOptions::setAction(RS_ActionInterface * a, bool update)
54 if (a != NULL && a->rtti() == RS2::ActionDrawArc)
56 action = (RS_ActionDrawArc *)a;
61 reversed = action->isReversed();
64 settings.beginGroup("Draw");
65 reversed = settings.value("ArcReversed", false).toBool();
67 action->setReversed(reversed);
70 rbNeg->setChecked(reversed);
74 RS_DEBUG->print(RS_Debug::D_ERROR, "QG_ArcOptions::setAction: wrong action type");
79 void ArcOptions::updateDirection(bool /*pos*/)
82 action->setReversed(rbNeg->isChecked());