]> Shamusworld >> Repos - architektonas/commitdiff
Added more missing forms, fixed missing header files in MdiWindow
authorShamus Hammons <jlhamm@acm.org>
Thu, 10 Jun 2010 16:36:49 +0000 (16:36 +0000)
committerShamus Hammons <jlhamm@acm.org>
Thu, 10 Jun 2010 16:36:49 +0000 (16:36 +0000)
16 files changed:
architektonas.pro
src/forms/arcoptions.cpp
src/forms/dimlinearoptions.cpp [new file with mode: 0644]
src/forms/dimlinearoptions.h [new file with mode: 0644]
src/forms/res/architektonas.qrc
src/forms/res/qg_dimdia.xpm [new file with mode: 0644]
src/forms/res/qg_dimtol1.xpm [new file with mode: 0644]
src/forms/res/qg_dimtol2.xpm [new file with mode: 0644]
src/forms/snapdistoptions.cpp [new file with mode: 0644]
src/forms/snapdistoptions.h [new file with mode: 0644]
src/forms/splineoptions.cpp [new file with mode: 0644]
src/forms/splineoptions.h [new file with mode: 0644]
src/forms/trimamountoptions.cpp [new file with mode: 0644]
src/forms/trimamountoptions.h [new file with mode: 0644]
src/mainapp/qc_mdiwindow.cpp
src/widgets/qg_dialogfactory.cpp

index 48889a5d21ae997e217deeab97be1fb22e86b6f7..b1d87fbca01f0179479b53a3b14ea38c4fd8391a 100644 (file)
@@ -425,6 +425,8 @@ HEADERS += \
        src/forms/circleoptions.h \
        src/forms/commandwidget.h \
        src/forms/coordinatewidget.h \
+       src/forms/dimlinearoptions.h \
+       src/forms/dimoptions.h \
        src/forms/dlgattributes.h \
        src/forms/dlgimageoptions.h \
        src/forms/dlginitial.h \
@@ -439,7 +441,9 @@ HEADERS += \
        src/forms/mousewidget.h \
        src/forms/printpreviewoptions.h \
        src/forms/selectionwidget.h \
+       src/forms/splineoptions.h \
        src/forms/textoptions.h \
+       src/forms/trimamountoptions.h \
        src/forms/widgetpen.h \
        src/widgets/qg_actionhandler.h \
        src/widgets/qg_blockwidget.h \
@@ -483,6 +487,8 @@ SOURCES += \
        src/forms/circleoptions.cpp \
        src/forms/commandwidget.cpp \
        src/forms/coordinatewidget.cpp \
+       src/forms/dimlinearoptions.cpp \
+       src/forms/dimoptions.cpp \
        src/forms/dlgattributes.cpp \
        src/forms/dlgimageoptions.cpp \
        src/forms/dlginitial.cpp \
@@ -497,7 +503,9 @@ SOURCES += \
        src/forms/mousewidget.cpp \
        src/forms/printpreviewoptions.cpp \
        src/forms/selectionwidget.cpp \
+       src/forms/splineoptions.cpp \
        src/forms/textoptions.cpp \
+       src/forms/trimamountoptions.cpp \
        src/forms/widgetpen.cpp \
        src/widgets/qg_actionhandler.cpp \
        src/widgets/qg_blockwidget.cpp \
@@ -520,8 +528,6 @@ SOURCES += \
 #The following line was changed from FORMS to FORMS3 by qt3to4
 #FORMS3 = \
 #      ui/qg_dimensionlabeleditor.ui \
-#      ui/qg_dimlinearoptions.ui \
-#      ui/qg_dimoptions.ui \
 #      ui/qg_dlghatch.ui \
 #      ui/qg_dlginsert.ui \
 #      ui/qg_dlgarc.ui \
@@ -550,11 +556,13 @@ SOURCES += \
 #      ui/qg_moverotateoptions.ui \
 #      ui/qg_roundoptions.ui \
 #      ui/qg_snapdistoptions.ui \
-#      ui/qg_splineoptions.ui \
-#      ui/qg_trimamountoptions.ui
 
 #      src/forms/arcoptions.ui \
 #      src/forms/arctangentialoptions.ui \
+#      src/forms/dimlinearoptions.ui \
+#      src/forms/dimoptions.ui \
+#      src/forms/splineoptions.ui \
+#      src/forms/trimamountoptions.ui
 #
 FORMS = \
        src/forms/blockdialog.ui \
index 0f794e7c3ce0d1272db9f8dcfdc20e75af16ff2a..2f95fb9f2d76cbbff6a24ed048af67f54fee89e6 100644 (file)
 #include "settings.h"
 
 ArcOptions::ArcOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
-       QWidget(parent, flags)
+       QWidget(parent, flags),
+       rbPos(new QRadioButton(this)),
+       rbNeg(new QRadioButton(this))
 {
        QHBoxLayout * layout = new QHBoxLayout(this);
        layout->setContentsMargins(0, 0, 0, 0);
 
-       rbPos = new QRadioButton(this);
-       rbNeg = new QRadioButton(this);
-
-       rbPos->setIcon(QIcon(":/res/qg_dirpos.xpm"));
-       rbNeg->setIcon(QIcon(":/res/qg_dirneg.xpm"));
+       rbPos->setIcon(QIcon(":/res/qg_dirpos"));
+       rbNeg->setIcon(QIcon(":/res/qg_dirneg"));
 
        layout->addWidget(rbPos);
        layout->addWidget(rbNeg);
diff --git a/src/forms/dimlinearoptions.cpp b/src/forms/dimlinearoptions.cpp
new file mode 100644 (file)
index 0000000..b221d11
--- /dev/null
@@ -0,0 +1,99 @@
+// dimlinearoptions.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/09/2010  Created this file. :-)
+//
+
+#include "dimlinearoptions.h"
+
+#include "rs_actiondimlinear.h"
+#include "rs_actioninterface.h"
+#include "settings.h"
+
+DimLinearOptions::DimLinearOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
+       QWidget(parent, flags),
+       lAngle(new QLabel(tr("Angle:"))),
+       leAngle(new QLineEdit(this)),
+       bHor(new QToolButton(this)),
+       bVer(new QToolButton(this))
+{
+       QHBoxLayout * layout = new QHBoxLayout(this);
+       layout->setContentsMargins(0, 0, 0, 0);
+
+       leAngle->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
+//still need to tweak this so it displays properly...
+       bHor->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding));
+       bHor->setIcon(QIcon(":/res/qg_dimhor"));
+       bVer->setIcon(QIcon(":/res/qg_dimver"));
+
+       layout->addWidget(lAngle);
+       layout->addWidget(leAngle);
+       layout->addWidget(bHor);
+       layout->addWidget(bVer);
+
+       connect(leAngle, SIGNAL(textChanged(QString)), this, SLOT(updateAngle(QString)));
+       connect(bHor, SIGNAL(clicked()), this, SLOT(setHor()));
+       connect(bVer, SIGNAL(clicked()), this, SLOT(setVer()));
+
+       // 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);
+}
+
+DimLinearOptions::~DimLinearOptions()
+{
+       settings.beginGroup("Dimension");
+       settings.setValue("Angle", leAngle->text());
+       settings.endGroup();
+}
+
+void DimLinearOptions::setAction(RS_ActionInterface * a, bool update)
+{
+       if (a != NULL && a->rtti() == RS2::ActionDimLinear)
+       {
+               action = (RS_ActionDimLinear *)a;
+
+               QString sa;
+
+               if (update)
+                       sa = QString("%1").arg(RS_Math::rad2deg(action->getAngle()));
+               else
+               {
+                       settings.beginGroup("Dimension");
+                       sa = settings.value("Angle", "0.0").toString();
+                       settings.endGroup();
+               }
+               leAngle->setText(sa);
+       }
+       else
+       {
+               RS_DEBUG->print(RS_Debug::D_ERROR, "DimLinearOptions::setAction: wrong action type");
+               action = NULL;
+       }
+}
+
+void DimLinearOptions::updateAngle(const QString & a)
+{
+       if (action != NULL)
+               action->setAngle(RS_Math::deg2rad(RS_Math::eval(a)));
+}
+
+void DimLinearOptions::setHor()
+{
+       leAngle->setText("0");
+}
+
+void DimLinearOptions::setVer()
+{
+       leAngle->setText("90");
+}
+
diff --git a/src/forms/dimlinearoptions.h b/src/forms/dimlinearoptions.h
new file mode 100644 (file)
index 0000000..e4e74ba
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef __DIMLINEAROPTIONS_H__
+#define __DIMLINEAROPTIONS_H__
+
+#include <QtGui>
+
+class RS_ActionDimLinear;
+class RS_ActionInterface;
+
+class DimLinearOptions: public QWidget
+{
+       Q_OBJECT
+
+       public:
+               DimLinearOptions(QToolBar * parent = 0, Qt::WindowFlags flags = 0);
+               ~DimLinearOptions();
+
+       public slots:
+               void setAction(RS_ActionInterface * a, bool update);
+               void updateAngle(const QString & a);
+               void setHor();
+               void setVer();
+
+       protected:
+               RS_ActionDimLinear * action;
+
+       private:
+               QLabel * lAngle;
+               QLineEdit * leAngle;
+               QToolButton * bHor;
+               QToolButton * bVer;
+};
+
+#endif  // __DIMLINEAROPTIONS_H__
index caca8884ef4f32f1054a19120904f9f83d1858b9..8f82e28cafcf76988c280c22b6118d94350a52eb 100644 (file)
                <file>qg_deselectwindow.xpm</file>
                <file>qg_dimaligned.xpm</file>
                <file>qg_dimangular.xpm</file>
+               <file>qg_dimdia.xpm</file>
                <file>qg_dimdiametric.xpm</file>
                <file>qg_dimhor.xpm</file>
                <file>qg_dimleader.xpm</file>
                <file>qg_dimlinear.xpm</file>
                <file>qg_dimradial.xpm</file>
+               <file>qg_dimtol1.xpm</file>
+               <file>qg_dimtol2.xpm</file>
                <file>qg_dimver.xpm</file>
                <file>qg_dirneg.xpm</file>
                <file>qg_dirpos.xpm</file>
diff --git a/src/forms/res/qg_dimdia.xpm b/src/forms/res/qg_dimdia.xpm
new file mode 100644 (file)
index 0000000..bbe0bd9
--- /dev/null
@@ -0,0 +1,20 @@
+/* XPM */
+static char * qg_dimdia_xpm[] = {
+"15 15 2 1",
+". c None",
+"# c #000000",
+"...............",
+"...............",
+"...............",
+".....####.#....",
+"....#....#.....",
+"...#....#.#....",
+"...#...#..#....",
+"...#..#...#....",
+"...#.#....#....",
+"....#....#.....",
+"...#.####......",
+"...............",
+"...............",
+"...............",
+"..............."};
diff --git a/src/forms/res/qg_dimtol1.xpm b/src/forms/res/qg_dimtol1.xpm
new file mode 100644 (file)
index 0000000..56daa9a
--- /dev/null
@@ -0,0 +1,16 @@
+/* XPM */
+static char * qg_dimtol1_xpm[] = {
+"32 10 3 1",
+"# c None",
+". c #000000",
+"a c #ff0000",
+"..................##............",
+".################.##.aaaaaaaaaa.",
+".################.##.aaaaaaaaaa.",
+".################.##............",
+".################.##############",
+".################.##############",
+".################.##............",
+".################.##.##########.",
+".################.##.##########.",
+"..................##............"};
diff --git a/src/forms/res/qg_dimtol2.xpm b/src/forms/res/qg_dimtol2.xpm
new file mode 100644 (file)
index 0000000..ada0179
--- /dev/null
@@ -0,0 +1,16 @@
+/* XPM */
+static char * qg_dimtol2_xpm[] = {
+"32 10 3 1",
+"# c None",
+". c #000000",
+"a c #ff0000",
+"..................##............",
+".################.##.##########.",
+".################.##.##########.",
+".################.##............",
+".################.##############",
+".################.##############",
+".################.##............",
+".################.##.aaaaaaaaaa.",
+".################.##.aaaaaaaaaa.",
+"..................##............"};
diff --git a/src/forms/snapdistoptions.cpp b/src/forms/snapdistoptions.cpp
new file mode 100644 (file)
index 0000000..9f932cf
--- /dev/null
@@ -0,0 +1,33 @@
+/****************************************************************************
+** 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()
+{
+       RS_SETTINGS->beginGroup("/Snap");
+       RS_SETTINGS->writeEntry("/Distance", leDist->text());
+       RS_SETTINGS->endGroup();
+}
+
+void QG_SnapDistOptions::setDist(double * d)
+{
+       dist = d;
+
+       RS_SETTINGS->beginGroup("/Snap");
+       QString r = RS_SETTINGS->readEntry("/Distance", "1.0");
+       RS_SETTINGS->endGroup();
+
+       leDist->setText(r);
+}
+
+void QG_SnapDistOptions::updateDist(const QString & d)
+{
+       if (dist != NULL)
+               *dist = RS_Math::eval(d, 1.0);
+}
+
diff --git a/src/forms/snapdistoptions.h b/src/forms/snapdistoptions.h
new file mode 100644 (file)
index 0000000..e706998
--- /dev/null
@@ -0,0 +1,112 @@
+#ifndef QG_SNAPDISTOPTIONS_H
+#define QG_SNAPDISTOPTIONS_H
+
+#include <qvariant.h>
+
+#include <Qt3Support/Q3MimeSourceFactory>
+#include <QtCore/QVariant>
+#include <QtGui/QAction>
+#include <QtGui/QApplication>
+#include <QtGui/QButtonGroup>
+#include <QtGui/QFrame>
+#include <QtGui/QHBoxLayout>
+#include <QtGui/QHeaderView>
+#include <QtGui/QLabel>
+#include <QtGui/QLineEdit>
+#include <QtGui/QWidget>
+#include "rs_circle.h"
+#include "rs_settings.h"
+
+QT_BEGIN_NAMESPACE
+
+class Ui_QG_SnapDistOptions
+{
+       public:
+               QHBoxLayout *hboxLayout;
+               QLabel *lDist;
+               QLineEdit *leDist;
+               QFrame *sep1;
+
+               void setupUi(QWidget *QG_SnapDistOptions)
+               {
+                       if (QG_SnapDistOptions->objectName().isEmpty())
+                               QG_SnapDistOptions->setObjectName(QString::fromUtf8("QG_SnapDistOptions"));
+                       QG_SnapDistOptions->resize(150, 24);
+                       QSizePolicy sizePolicy(static_cast<QSizePolicy::Policy>(4), static_cast<QSizePolicy::Policy>(0));
+                       sizePolicy.setHorizontalStretch(0);
+                       sizePolicy.setVerticalStretch(0);
+                       sizePolicy.setHeightForWidth(QG_SnapDistOptions->sizePolicy().hasHeightForWidth());
+                       QG_SnapDistOptions->setSizePolicy(sizePolicy);
+                       QG_SnapDistOptions->setMinimumSize(QSize(130, 22));
+                       QG_SnapDistOptions->setMaximumSize(QSize(150, 32767));
+                       hboxLayout = new QHBoxLayout(QG_SnapDistOptions);
+                       hboxLayout->setSpacing(6);
+                       hboxLayout->setContentsMargins(1, 1, 1, 1);
+                       hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
+                       lDist = new QLabel(QG_SnapDistOptions);
+                       lDist->setObjectName(QString::fromUtf8("lDist"));
+                       lDist->setWordWrap(false);
+
+                       hboxLayout->addWidget(lDist);
+
+                       leDist = new QLineEdit(QG_SnapDistOptions);
+                       leDist->setObjectName(QString::fromUtf8("leDist"));
+
+                       hboxLayout->addWidget(leDist);
+
+                       sep1 = new QFrame(QG_SnapDistOptions);
+                       sep1->setObjectName(QString::fromUtf8("sep1"));
+                       QSizePolicy sizePolicy1(static_cast<QSizePolicy::Policy>(0), static_cast<QSizePolicy::Policy>(1));
+                       sizePolicy1.setHorizontalStretch(0);
+                       sizePolicy1.setVerticalStretch(0);
+                       sizePolicy1.setHeightForWidth(sep1->sizePolicy().hasHeightForWidth());
+                       sep1->setSizePolicy(sizePolicy1);
+                       sep1->setFrameShape(QFrame::VLine);
+                       sep1->setFrameShadow(QFrame::Sunken);
+
+                       hboxLayout->addWidget(sep1);
+
+                       retranslateUi(QG_SnapDistOptions);
+                       QObject::connect(leDist, SIGNAL(textChanged(QString)), QG_SnapDistOptions, SLOT(updateDist(QString)));
+
+                       QMetaObject::connectSlotsByName(QG_SnapDistOptions);
+               } // setupUi
+
+               void retranslateUi(QWidget *QG_SnapDistOptions)
+               {
+                       QG_SnapDistOptions->setWindowTitle(QApplication::translate("QG_SnapDistOptions", "Snap Distance Options", 0, QApplication::UnicodeUTF8));
+                       lDist->setText(QApplication::translate("QG_SnapDistOptions", "Distance:", 0, QApplication::UnicodeUTF8));
+               } // retranslateUi
+};
+
+namespace Ui {
+class QG_SnapDistOptions: public Ui_QG_SnapDistOptions
+{
+};
+} // namespace Ui
+
+QT_END_NAMESPACE
+
+class QG_SnapDistOptions: public QWidget, public Ui::QG_SnapDistOptions
+{
+       Q_OBJECT
+
+       public:
+               QG_SnapDistOptions(QWidget * parent = 0, const char * name = 0, Qt::WindowFlags fl = 0);
+               ~QG_SnapDistOptions();
+
+       public slots:
+               virtual void setDist(double * d);
+               virtual void updateDist(const QString & d);
+
+       protected:
+               double * dist;
+
+       protected slots:
+               virtual void languageChange();
+
+       private:
+               void destroy();
+};
+
+#endif // QG_SNAPDISTOPTIONS_H
diff --git a/src/forms/splineoptions.cpp b/src/forms/splineoptions.cpp
new file mode 100644 (file)
index 0000000..2d16301
--- /dev/null
@@ -0,0 +1,110 @@
+// splineoptions.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 "splineoptions.h"
+
+#include "rs_actiondrawspline.h"
+#include "rs_actioninterface.h"
+#include "settings.h"
+
+SplineOptions::SplineOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
+       QWidget(parent, flags),
+       lDegree(new QLabel(tr("Degree:"))),
+       cbDegree(new QComboBox(this)),
+       cbClosed(new QCheckBox(tr("Closed"))),
+       bUndo(new QToolButton(this))
+{
+       QHBoxLayout * layout = new QHBoxLayout(this);
+       layout->setContentsMargins(0, 0, 0, 0);
+
+//     leDist->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored));
+       QStringList degrees;
+       degrees << "1" << "2" << "3";
+       cbDegree->addItems(degrees);
+       bUndo->setText(tr("Undo"));
+
+       layout->addWidget(lDegree);
+       layout->addWidget(cbDegree);
+       layout->addWidget(cbClosed);
+       layout->addWidget(bUndo);
+
+       connect(cbDegree, SIGNAL(activated(QString)), this, SLOT(setDegree(QString)));
+       connect(cbClosed, SIGNAL(toggled(bool)), this, SLOT(setClosed(bool)));
+       connect(bUndo, SIGNAL(clicked()), this, SLOT(undo()));
+
+       // 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);
+}
+
+SplineOptions::~SplineOptions()
+{
+       settings.beginGroup("Draw");
+       settings.setValue("SplineDegree", cbDegree->currentText().toInt());
+       settings.setValue("SplineClosed", cbClosed->isChecked());
+       settings.endGroup();
+}
+
+void SplineOptions::setAction(RS_ActionInterface * a, bool update)
+{
+       if (a != NULL && a->rtti() == RS2::ActionDrawSpline)
+       {
+               action = (RS_ActionDrawSpline *)a;
+
+               int degree;
+               bool closed;
+
+               if (update)
+               {
+                       degree = action->getDegree();
+                       closed = action->isClosed();
+               }
+               else
+               {
+                       settings.beginGroup("Draw");
+                       degree = settings.value("SplineDegree", 3).toInt();
+                       closed = settings.value("SplineClosed", false).toBool();
+                       settings.endGroup();
+                       action->setDegree(degree);
+                       action->setClosed(closed);
+               }
+
+               cbDegree->setCurrentIndex(cbDegree->findText(QString("%1").arg(degree)));
+               cbClosed->setChecked(closed);
+       }
+       else
+       {
+               RS_DEBUG->print(RS_Debug::D_ERROR, "SplineOptions::setAction: wrong action type");
+               action = NULL;
+       }
+}
+
+void SplineOptions::setClosed(bool c)
+{
+       if (action != NULL)
+               action->setClosed(c);
+}
+
+void SplineOptions::undo()
+{
+       if (action != NULL)
+               action->undo();
+}
+
+void SplineOptions::setDegree(const QString & deg)
+{
+       if (action != NULL)
+               action->setDegree(deg.toInt());
+}
diff --git a/src/forms/splineoptions.h b/src/forms/splineoptions.h
new file mode 100644 (file)
index 0000000..77a4a4e
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef __SPLINEOPTIONS_H__
+#define __SPLINEOPTIONS_H__
+
+#include <QtGui>
+
+class RS_ActionDrawSpline;
+class RS_ActionInterface;
+
+class SplineOptions: public QWidget
+{
+       Q_OBJECT
+
+       public:
+               SplineOptions(QToolBar * parent = 0, Qt::WindowFlags fl = 0);
+               ~SplineOptions();
+
+       public slots:
+               void setAction(RS_ActionInterface * a, bool update);
+               void setClosed(bool c);
+               void undo();
+               void setDegree(const QString & deg);
+
+       protected:
+               RS_ActionDrawSpline * action;
+
+       private:
+               QLabel * lDegree;
+               QComboBox * cbDegree;
+               QCheckBox * cbClosed;
+               QToolButton * bUndo;
+};
+
+#endif  // __SPLINEOPTIONS_H__
diff --git a/src/forms/trimamountoptions.cpp b/src/forms/trimamountoptions.cpp
new file mode 100644 (file)
index 0000000..c48283d
--- /dev/null
@@ -0,0 +1,83 @@
+// trimamountoptions.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 "trimamountoptions.h"
+
+#include "rs_actionmodifytrimamount.h"
+#include "rs_actioninterface.h"
+#include "rs_debug.h"
+#include "rs_math.h"
+#include "settings.h"
+
+TrimAmountOptions::TrimAmountOptions(QToolBar * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/):
+       QWidget(parent, flags),
+       lDist(new QLabel(tr("Amount:"))),
+       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);
+}
+
+TrimAmountOptions::~TrimAmountOptions()
+{
+       settings.beginGroup("Modify");
+       settings.setValue("TrimAmount", leDist->text());
+       settings.endGroup();
+}
+
+void TrimAmountOptions::setAction(RS_ActionInterface * a, bool update)
+{
+       if (a != NULL && a->rtti() == RS2::ActionModifyTrimAmount)
+       {
+               action = (RS_ActionModifyTrimAmount *)a;
+
+               QString sd;
+
+               // settings from action:
+               if (update)
+                       sd = QString("%1").arg(action->getDistance());
+               // settings from config file:
+               else
+               {
+                       settings.beginGroup("Modify");
+                       sd = settings.value("TrimAmount", "1.0").toString();
+                       settings.endGroup();
+               }
+
+               leDist->setText(sd);
+       }
+       else
+       {
+               RS_DEBUG->print(RS_Debug::D_ERROR, "ModifyTrimAmountOptions::setAction: wrong action type");
+               this->action = NULL;
+       }
+}
+
+void TrimAmountOptions::updateDist(const QString & d)
+{
+       if (action != NULL)
+               action->setDistance(RS_Math::eval(d, 1.0));
+}
diff --git a/src/forms/trimamountoptions.h b/src/forms/trimamountoptions.h
new file mode 100644 (file)
index 0000000..a118fe9
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef __TRIMAMOUNTOPTIONS_H__
+#define __TRIMAMOUNTOPTIONS_H__
+
+#include <QtGui>
+
+class RS_ActionModifyTrimAmount;
+class RS_ActionInterface;
+
+class TrimAmountOptions: public QWidget
+{
+       Q_OBJECT
+
+       public:
+               TrimAmountOptions(QToolBar * parent = 0, Qt::WindowFlags fl = 0);
+               ~TrimAmountOptions();
+
+       public slots:
+               void setAction(RS_ActionInterface * a, bool update);
+               void updateDist(const QString & d);
+
+       protected:
+               RS_ActionModifyTrimAmount * action;
+
+       private:
+               QLabel * lDist;
+               QLineEdit * leDist;
+};
+
+#endif // __TRIMAMOUNTOPTIONS_H__
index f1173f86951026d93cdd52601dbc9308d9e7cc56..fa3c12f95d2210b0e62e4729cae5fa5dbb87da9a 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "qc_mdiwindow.h"
 
-#include "rs_application.h"
+#include "drawing.h"
 #include "rs_eventhandler.h"
 #include "exitdialog.h"
 #include "qg_filedialog.h"
index 632ce8dc174b21c78bfe7e92a1b79b77c58db9ea..1238d8e054e7dbb310fc2905ca6d04ecf63befeb 100644 (file)
@@ -33,8 +33,8 @@
        #include "ui/qg_circleoptions.h"
        #include "ui/qg_commandwidget.h"
        #include "ui/qg_coordinatewidget.h"
-#include "ui/qg_dimlinearoptions.h"
-#include "ui/qg_dimoptions.h"
+       #include "ui/qg_dimlinearoptions.h"
+       #include "ui/qg_dimoptions.h"
 #include "ui/qg_dlgarc.h"
        #include "ui/qg_dlgattributes.h"
 #include "ui/qg_dlgcircle.h"
@@ -73,9 +73,9 @@
 #include "ui/qg_roundoptions.h"
        #include "ui/qg_selectionwidget.h"
 #include "ui/qg_snapdistoptions.h"
-#include "ui/qg_splineoptions.h"
+       #include "ui/qg_splineoptions.h"
        #include "ui/qg_textoptions.h"
-#include "ui/qg_trimamountoptions.h"
+       #include "ui/qg_trimamountoptions.h"
 #endif
 #include "arcoptions.h"
 #include "arctangentialoptions.h"
@@ -85,6 +85,8 @@
 #include "circleoptions.h"
 #include "commandwidget.h"
 #include "coordinatewidget.h"
+#include "dimlinearoptions.h"
+#include "dimoptions.h"
 #include "dlgattributes.h"
 #include "dlgoptionsdrawing.h"
 #include "dlgoptionsgeneral.h"
@@ -95,7 +97,9 @@
 #include "mousewidget.h"
 #include "printpreviewoptions.h"
 #include "selectionwidget.h"
+#include "splineoptions.h"
 #include "textoptions.h"
+#include "trimamountoptions.h"
 
 #ifdef RS_PROF
 #include "qg_polylineoptions.h"
@@ -1080,26 +1084,6 @@ void QG_DialogFactory::requestLinePolygon2Options(RS_ActionInterface* action,
     }
 }
 
-/**
- * Shows a widget for spline options.
- */
-void QG_DialogFactory::requestSplineOptions(RS_ActionInterface* action,
-        bool on, bool update)
-{
-    static QG_SplineOptions* toolWidget = NULL;
-
-    if (optionWidget!=NULL) {
-        if (toolWidget!=NULL) {
-            delete toolWidget;
-            toolWidget = NULL;
-        }
-        if (on==true && toolWidget==NULL) {
-            toolWidget = new QG_SplineOptions(optionWidget);
-            toolWidget->setAction(action, update);
-        }
-    }
-}
-
 /**
  * Shows a widget for insert options.
  */
@@ -1140,48 +1124,6 @@ void QG_DialogFactory::requestImageOptions(RS_ActionInterface* action,
     }
 }
 
-/**
- * Shows a widget for dimension options.
- */
-void QG_DialogFactory::requestDimensionOptions(RS_ActionInterface* action,
-        bool on, bool update)
-{
-    //static QLabel* l = NULL;
-    static QG_DimOptions* toolWidget = NULL;
-
-    if (optionWidget!=NULL) {
-        if (toolWidget!=NULL) {
-            delete toolWidget;
-            toolWidget = NULL;
-        }
-        if (on==true && toolWidget==NULL) {
-            toolWidget = new QG_DimOptions(optionWidget);
-            toolWidget->setAction(action, update);
-        }
-    }
-}
-
-/**
- * Shows a widget for linear dimension options.
- */
-void QG_DialogFactory::requestDimLinearOptions(RS_ActionInterface* action,
-        bool on, bool update)
-{
-    //static QLabel* l = NULL;
-    static QG_DimLinearOptions* toolWidget = NULL;
-
-    if (optionWidget!=NULL) {
-        if (toolWidget!=NULL) {
-            delete toolWidget;
-            toolWidget = NULL;
-        }
-        if (on==true && toolWidget==NULL) {
-            toolWidget = new QG_DimLinearOptions(optionWidget);
-            toolWidget->setAction(action, update);
-        }
-    }
-}
-
 /**
  * Shows a widget for 'snap to a point with a given distance' options.
  */
@@ -1221,26 +1163,6 @@ void QG_DialogFactory::requestMoveRotateOptions(RS_ActionInterface* action,
     }
 }
 
-/**
- * Shows a widget for 'trim amount' options.
- */
-void QG_DialogFactory::requestTrimAmountOptions(RS_ActionInterface* action,
-        bool on, bool update)
-{
-    static QG_TrimAmountOptions* toolWidget = NULL;
-
-    if (optionWidget!=NULL) {
-        if (toolWidget!=NULL) {
-            delete toolWidget;
-            toolWidget = NULL;
-        }
-        if (on==true && toolWidget==NULL) {
-            toolWidget = new QG_TrimAmountOptions(optionWidget);
-            toolWidget->setAction(action, update);
-        }
-    }
-}
-
 /**
  * Shows a widget for rounding options.
  */
@@ -1380,8 +1302,23 @@ void QG_DialogFactory::requestCircleOptions(RS_ActionInterface * action, bool on
     }
 }
 
-void QG_DialogFactory::requestSplineOptions(RS_ActionInterface* action, bool on, bool update)
+/**
+ * Shows a widget for spline options.
+ */
+void QG_DialogFactory::requestSplineOptions(RS_ActionInterface * action, bool on, bool update)
 {
+       static SplineOptions * toolWidget = NULL;
+
+       if (optionWidget!=NULL) {
+               if (toolWidget!=NULL) {
+                       delete toolWidget;
+                       toolWidget = NULL;
+               }
+               if (on==true && toolWidget==NULL) {
+                       toolWidget = new SplineOptions(optionWidget);
+                       toolWidget->setAction(action, update);
+               }
+       }
 }
 
 /**
@@ -1415,12 +1352,46 @@ void QG_DialogFactory::requestImageOptions(RS_ActionInterface* action, bool on,
 {
 }
 
-void QG_DialogFactory::requestDimensionOptions(RS_ActionInterface* action, bool on, bool update)
+/**
+ * Shows a widget for dimension options.
+ */
+void QG_DialogFactory::requestDimensionOptions(RS_ActionInterface * action, bool on, bool update)
 {
+    static DimOptions * toolWidget = NULL;
+
+    if (optionWidget!=NULL) {
+        if (toolWidget!=NULL) {
+            delete toolWidget;
+            toolWidget = NULL;
+        }
+        if (on==true && toolWidget==NULL) {
+            toolWidget = new DimOptions(optionWidget);
+            toolWidget->setAction(action, update);
+        }
+    }
 }
 
-void QG_DialogFactory::requestDimLinearOptions(RS_ActionInterface* action, bool on, bool update)
+/**
+ * Shows a widget for linear dimension options.
+ */
+void QG_DialogFactory::requestDimLinearOptions(RS_ActionInterface * action, bool on, bool update)
 {
+       static DimLinearOptions * toolWidget = NULL;
+
+       if (!optionWidget)
+               return;
+
+       if (toolWidget)
+       {
+               delete toolWidget;
+               toolWidget = NULL;
+       }
+
+       if (on)
+       {
+               toolWidget = new DimLinearOptions(optionWidget);
+               toolWidget->setAction(action, update);
+       }
 }
 
 void QG_DialogFactory::requestSnapDistOptions(double& dist, bool on)
@@ -1431,8 +1402,27 @@ void QG_DialogFactory::requestMoveRotateOptions(RS_ActionInterface* action, bool
 {
 }
 
-void QG_DialogFactory::requestTrimAmountOptions(RS_ActionInterface* action, bool on, bool update)
+/**
+ * Shows a widget for 'trim amount' options.
+ */
+void QG_DialogFactory::requestTrimAmountOptions(RS_ActionInterface * action, bool on, bool update)
 {
+       static TrimAmountOptions * toolWidget = NULL;
+
+       if (!optionWidget)
+               return;
+
+       if (toolWidget)
+       {
+               delete toolWidget;
+               toolWidget = NULL;
+       }
+
+       if (on)
+       {
+               toolWidget = new TrimAmountOptions(optionWidget);
+               toolWidget->setAction(action, update);
+       }
 }
 
 /**