]> Shamusworld >> Repos - architektonas/blobdiff - src/forms/snapdistoptions.cpp
Added more missing forms...
[architektonas] / src / forms / snapdistoptions.cpp
index 9f932cff4a57a6bd780f0a84330108fb85369fe5..7355ace52ba8e84d632d8c4ed337f10b98b21997 100644 (file)
@@ -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 <jlhamm@acm.org>
+//
+// Who  When        What
+// ---  ----------  -----------------------------------------------------------
+// JLH  06/10/2010  Created this file. :-)
+//
+
+#include "snapdistoptions.h"
+
+//#include "rs_actionmodifytrimamount.h"
+//#include "rs_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);