-/****************************************************************************
-** 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 <jlhamm@acm.org>
+//
+// 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);