]> Shamusworld >> Repos - architektonas/commitdiff
Fixed inconsistent tool states.
authorShamus Hammons <jlhamm@acm.org>
Sat, 4 Feb 2012 01:07:02 +0000 (01:07 +0000)
committerShamus Hammons <jlhamm@acm.org>
Sat, 4 Feb 2012 01:07:02 +0000 (01:07 +0000)
src/about.cpp
src/applicationwindow.cpp
src/applicationwindow.h
src/drawingview.cpp

index acf06163b87fe87b6dbdb967e716a4dee63a7a65..47bde97eadcc436bc154e0da10ab828442b86294 100644 (file)
@@ -78,7 +78,7 @@ AboutWindow::AboutWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog)
                "<ul>"
                "<li>The authors of <b>Inkscape</b>, whose incredible GUI was a huge inspiration for us</li>"
                "<li><b>QCad</b> for sucking so bad that we just <i>had</i> to write something better</li>"
-               "<li>Every other 2D CAD package out there that's mired in a legacy of the bad old days of pencil and paper, and all the attendant horrors that came along with that. We couldn't have done it without you!</li>"
+               "<li>Every other 2D CAD package out there that's mired in a legacy of the bad old days of pencil and paper, and all the attendant horrors that come along with that. We couldn't have done it without you!</li>"
                "</ul>"
                "</td>"
                "</tr>"
index c580cde948ab4b37535ec2b5f395600fe83cbb0d..36c256fb588fb789a7d968f39c84da871c34d8f0 100644 (file)
@@ -88,37 +88,36 @@ void ApplicationWindow::FixLength(void)
        Object::SetFixedLength(fixLengthAct->isChecked());
 }
 
+// We want certain tools to be exclusive, and this approach isn't working correctly...
 void ApplicationWindow::DeleteTool(void)
 {
-       Object::SetDeleteActive(deleteAct->isChecked());
+       
+       ClearUIToolStatesExcept(deleteAct);
+       SetInternalToolStates();
 }
 
 void ApplicationWindow::DimensionTool(void)
 {
-       Object::SetDimensionActive(addDimensionAct->isChecked());
+       ClearUIToolStatesExcept(addDimensionAct);
+       SetInternalToolStates();
 }
 
 void ApplicationWindow::RotateTool(void)
 {
-       drawing->SetRotateToolActive(rotateAct->isChecked());
+       ClearUIToolStatesExcept(rotateAct);
+       SetInternalToolStates();
 }
 
 void ApplicationWindow::AddLineTool(void)
 {
-       addCircleAct->setChecked(false);
-       addArcAct->setChecked(false);
-       rotateAct->setChecked(false);
-       RotateTool();
-       drawing->SetAddLineToolActive(addLineAct->isChecked());
+       ClearUIToolStatesExcept(addLineAct);
+       SetInternalToolStates();
 }
 
 void ApplicationWindow::AddCircleTool(void)
 {
-       addLineAct->setChecked(false);
-       addArcAct->setChecked(false);
-       rotateAct->setChecked(false);
-       RotateTool();
-       drawing->SetAddCircleToolActive(addCircleAct->isChecked());
+       ClearUIToolStatesExcept(addCircleAct);
+       SetInternalToolStates();
 }
 
 void ApplicationWindow::ZoomInTool(void)
@@ -184,6 +183,39 @@ x 2 = (-426, -301)
        drawing->update();
 }
 
+void ApplicationWindow::ClearUIToolStatesExcept(QAction * exception)
+{
+       if (exception != addArcAct)
+               addArcAct->setChecked(false);
+
+       if (exception != addCircleAct)
+               addCircleAct->setChecked(false);
+
+       if (exception != addDimensionAct)
+               addDimensionAct->setChecked(false);
+
+       if (exception != addLineAct)
+               addLineAct->setChecked(false);
+
+       if (exception != addPolygonAct)
+               addPolygonAct->setChecked(false);
+
+       if (exception != deleteAct)
+               deleteAct->setChecked(false);
+
+       if (exception != rotateAct)
+               rotateAct->setChecked(false);
+}
+
+void ApplicationWindow::SetInternalToolStates(void)
+{
+       Object::SetDeleteActive(deleteAct->isChecked());
+       Object::SetDimensionActive(addDimensionAct->isChecked());
+       drawing->SetRotateToolActive(rotateAct->isChecked());
+       drawing->SetAddLineToolActive(addLineAct->isChecked());
+       drawing->SetAddCircleToolActive(addCircleAct->isChecked());
+}
+
 void ApplicationWindow::HelpAbout(void)
 {
        aboutWin->show();
@@ -351,6 +383,7 @@ void ApplicationWindow::CreateToolbars(void)
        toolbar->addAction(addLineAct);
        toolbar->addAction(addCircleAct);
        toolbar->addAction(addArcAct);
+       toolbar->addAction(addPolygonAct);
        toolbar->addAction(addDimensionAct);
 }
 
index eca3c65657199321e90d3e3cd9aa6e5708b4dac8..e75c5fef364a83ef39ae333613308e7e47b932b8 100644 (file)
@@ -36,6 +36,8 @@ class ApplicationWindow: public QMainWindow
                void Settings(void);
 
        private:
+               void ClearUIToolStatesExcept(QAction *);
+               void SetInternalToolStates(void);
                void CreateActions(void);
                QAction * CreateAction(QString name, QString tooltip, QString statustip,
                        QIcon icon, QKeySequence key, bool checkable = false);
index f5ff2e35a5adaf917a0f3ec83ee15eb1d168a7b9..eccb0b170d2647c421d9269ae8701aad5aa199b5 100644 (file)
@@ -84,13 +84,17 @@ void DrawingView::SetRotateToolActive(bool state/*= true*/)
 
 void DrawingView::SetAddLineToolActive(bool state/*= true*/)
 {
-       if (state && toolAction == NULL)
+       if (state)// && toolAction == NULL)
        {
+               if (toolAction)
+                       delete toolAction;
+
+               addCircleTool = false;
                toolAction = new DrawLineAction();
                connect(toolAction, SIGNAL(ObjectReady(Object *)), this,
                        SLOT(AddNewObjectToDocument(Object *)));
        }
-       else if (!state && toolAction)
+       else if (!state && addLineTool && toolAction)
        {
                delete toolAction;
                toolAction = NULL;
@@ -103,13 +107,17 @@ void DrawingView::SetAddLineToolActive(bool state/*= true*/)
 
 void DrawingView::SetAddCircleToolActive(bool state/*= true*/)
 {
-       if (state && toolAction == NULL)
+       if (state)// && toolAction == NULL)
        {
+               if (toolAction)
+                       delete toolAction;
+
+               addLineTool = false;
                toolAction = new DrawCircleAction();
                connect(toolAction, SIGNAL(ObjectReady(Object *)), this,
                        SLOT(AddNewObjectToDocument(Object *)));
        }
-       else if (!state && toolAction)
+       else if (!state && addCircleTool && toolAction)
        {
                delete toolAction;
                toolAction = NULL;
@@ -117,7 +125,7 @@ void DrawingView::SetAddCircleToolActive(bool state/*= true*/)
 
        addCircleTool = state;
        update();
-//printf("DrawingView::SetAddLineToolActive(). toolAction=%08X\n", toolAction);
+//printf("DrawingView::SetAddCircleToolActive(). toolAction=%08X\n", toolAction);
 }
 
 void DrawingView::AddNewObjectToDocument(Object * object)