X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fforms%2Fsnapdistoptions.cpp;h=056b365cce3f7e3fcff5c79bd83ade6e9e9fa7ac;hb=d774c2655ba2c3657a565f325411144452392277;hp=9f932cff4a57a6bd780f0a84330108fb85369fe5;hpb=0e80da8b560e09124c527f3544859e0c31157ce4;p=architektonas diff --git a/src/forms/snapdistoptions.cpp b/src/forms/snapdistoptions.cpp index 9f932cf..056b365 100644 --- a/src/forms/snapdistoptions.cpp +++ b/src/forms/snapdistoptions.cpp @@ -1,31 +1,65 @@ -/**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. -** -** If you wish to add, delete or rename functions or slots use -** Qt Designer which will update this file, preserving your code. Create an -** init() function in place of a constructor, and a destroy() function in -** place of a destructor. -*****************************************************************************/ - -void QG_SnapDistOptions::destroy() +// snapdistoptions.cpp +// +// Part of the Architektonas Project +// Originally part of QCad Community Edition by Andrew Mustun +// Extensively rewritten and refactored by James L. Hammons +// (C) 2010 Underground Software +// +// JLH = James L. Hammons +// +// Who When What +// --- ---------- ----------------------------------------------------------- +// JLH 06/10/2010 Created this file. :-) +// + +#include "snapdistoptions.h" + +//#include "actionmodifytrimamount.h" +//#include "actioninterface.h" +//#include "rs_debug.h" +#include "rs_math.h" +#include "settings.h" + +SnapDistOptions::SnapDistOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/): + QWidget(parent, flags), + lDist(new QLabel(tr("Distance:"))), + leDist(new QLineEdit(this)) +{ + QHBoxLayout * layout = new QHBoxLayout(this); + layout->setContentsMargins(0, 0, 0, 0); + + leDist->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored)); + + layout->addWidget(lDist); + layout->addWidget(leDist); + + connect(leDist, SIGNAL(textChanged(QString)), this, SLOT(updateDist(QString))); + + // We need to add the widget (this thing) to the toolbar passed in. Otherwise, + // nothing will show up on the screen. :-) + if (parent) + parent->addWidget(this); +} + +SnapDistOptions::~SnapDistOptions() { - RS_SETTINGS->beginGroup("/Snap"); - RS_SETTINGS->writeEntry("/Distance", leDist->text()); - RS_SETTINGS->endGroup(); + settings.beginGroup("Snap"); + settings.setValue("Distance", leDist->text()); + settings.endGroup(); } -void QG_SnapDistOptions::setDist(double * d) +void SnapDistOptions::setDist(double * d) { dist = d; - RS_SETTINGS->beginGroup("/Snap"); - QString r = RS_SETTINGS->readEntry("/Distance", "1.0"); - RS_SETTINGS->endGroup(); + settings.beginGroup("Snap"); + QString r = settings.value("Distance", "1.0").toString(); + settings.endGroup(); leDist->setText(r); } -void QG_SnapDistOptions::updateDist(const QString & d) +void SnapDistOptions::updateDist(const QString & d) { if (dist != NULL) *dist = RS_Math::eval(d, 1.0);