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)
25 QHBoxLayout * layout = new QHBoxLayout(this);
26 layout->setContentsMargins(0, 0, 0, 0);
28 rbPos = new QRadioButton(this);
29 rbNeg = new QRadioButton(this);
31 rbPos->setIcon(QIcon(":/res/qg_dirpos.xpm"));
32 rbNeg->setIcon(QIcon(":/res/qg_dirneg.xpm"));
34 layout->addWidget(rbPos);
35 layout->addWidget(rbNeg);
37 connect(rbPos, SIGNAL(toggled(bool)), this, SLOT(updateDirection(bool)));
38 connect(rbNeg, SIGNAL(toggled(bool)), this, SLOT(updateDirection(bool)));
40 // We need to add the widget (this thing) to the toolbar passed in. Otherwise,
41 // nothing will show up on the screen. :-)
43 parent->addWidget(this);
46 ArcOptions::~ArcOptions()
48 settings.beginGroup("Draw");
49 settings.setValue("ArcReversed", rbNeg->isChecked());
53 void ArcOptions::setAction(RS_ActionInterface * a, bool update)
55 if (a != NULL && a->rtti() == RS2::ActionDrawArc)
57 action = (RS_ActionDrawArc *)a;
62 reversed = action->isReversed();
65 settings.beginGroup("Draw");
66 reversed = settings.value("ArcReversed", false).toBool();
68 action->setReversed(reversed);
71 rbNeg->setChecked(reversed);
75 RS_DEBUG->print(RS_Debug::D_ERROR, "QG_ArcOptions::setAction: wrong action type");
80 void ArcOptions::updateDirection(bool /*pos*/)
83 action->setReversed(rbNeg->isChecked());