]> Shamusworld >> Repos - architektonas/blobdiff - src/applicationwindow.cpp
More polyline upgrading: points and arcs are now editable with the GUI.
[architektonas] / src / applicationwindow.cpp
index ef77f8b4e961f916a889fbdef162cafee57178ee..b91177de80d0454b718c94bd51ce39ddf5d559a2 100644 (file)
@@ -31,7 +31,9 @@
 #include <QPrintPreviewDialog>
 #include "about.h"
 #include "blockwidget.h"
+#include "commandprocessor.h"
 #include "consolewidget.h"
+#include "drawingsettingsdlg.h"
 #include "drawingview.h"
 #include "fileio.h"
 #include "generaltab.h"
@@ -80,7 +82,7 @@ ApplicationWindow::ApplicationWindow():
        dock3->setWidget(ow);
        addDockWidget(Qt::RightDockWidgetArea, dock3);
        QDockWidget * dock4 = new QDockWidget(tr("Command"), this);
-       ConsoleWidget * cw = new ConsoleWidget;
+       cw = new ConsoleWidget;
        dock4->setWidget(cw);
        addDockWidget(Qt::BottomDockWidgetArea, dock4);
 
@@ -108,6 +110,8 @@ ApplicationWindow::ApplicationWindow():
 
        connect(drawing, SIGNAL(ObjectHovered(Object *)), ow, SLOT(ShowInfo(Object *)));
        connect(drawing, SIGNAL(NeedZoomUpdate()), this, SLOT(UpdateZoom()));
+
+       connect(cw->cmdProc, SIGNAL(UpdateNeeded()), this, SLOT(UpdateFromCommand()));
 }
 
 void ApplicationWindow::closeEvent(QCloseEvent * event)
@@ -362,6 +366,12 @@ void ApplicationWindow::MoveToLayer(void)
        drawing->update();
 }
 
+void ApplicationWindow::UpdateFromCommand(void)
+{
+       cw->SetToolPrompt();
+       drawing->update();
+}
+
 void ApplicationWindow::SnapToGridTool(void)
 {
        Global::snapToGrid = snapToGridAct->isChecked();
@@ -434,6 +444,7 @@ void ApplicationWindow::ParallelTool(void)
 {
        ClearUIToolStatesExcept(parallelAct);
        SetInternalToolStates();
+       Global::toolSuppressCrosshair = true;
 }
 
 void ApplicationWindow::TriangulateTool(void)
@@ -540,7 +551,7 @@ void ApplicationWindow::ClearUIToolStatesExcept(QAction * exception)
        QAction * actionList[] = {
                addArcAct, addLineAct, addCircleAct, addDimensionAct, addPolygonAct,
                addSplineAct, deleteAct, rotateAct, mirrorAct, trimAct,
-               triangulateAct, 0
+               triangulateAct, parallelAct, 0
        };
 
        for(int i=0; actionList[i]!=0; i++)
@@ -586,6 +597,7 @@ void ApplicationWindow::SetInternalToolStates(void)
        else
                Global::tool = TTNone;
 
+       cw->SetToolPrompt();
        drawing->update();
 }
 
@@ -607,6 +619,25 @@ void ApplicationWindow::Settings(void)
        WriteSettings();
 }
 
+void ApplicationWindow::DrawingSettings(void)
+{
+       DrawingSettingsDlg dlg(this);
+       dlg.baseUnit->setCurrentIndex(drawing->document.baseUnit);
+       dlg.unitStyle->setCurrentIndex(drawing->document.unitStyle);
+       dlg.decimalPrecision->setCurrentIndex(drawing->document.decimalPrecision);
+       dlg.fractionalPrecision->setCurrentIndex(drawing->document.fractionalPrecision);
+
+       if (dlg.exec() == false)
+               return;
+
+       // Deal with stuff here (since user hit "OK" button...)
+       drawing->document.baseUnit = dlg.baseUnit->currentIndex();
+       drawing->document.unitStyle = dlg.unitStyle->currentIndex();
+       drawing->document.decimalPrecision= dlg.decimalPrecision->currentIndex();
+       drawing->document.fractionalPrecision = dlg.fractionalPrecision->currentIndex();
+       drawing->update();
+}
+
 //
 // Group a bunch of selected objects (which can include other groups) together
 // or ungroup a selected group.
@@ -893,6 +924,9 @@ void ApplicationWindow::CreateActions(void)
        settingsAct = CreateAction(tr("&Settings"), tr("Settings"), tr("Change certain defaults for Architektonas."), QIcon(":/res/settings.png"), QKeySequence());
        connect(settingsAct, SIGNAL(triggered()), this, SLOT(Settings()));
 
+       drawingSettingsAct = CreateAction(tr("&Drawing Settings"), tr("Drawing settings"), tr("Change certain defaults for the current drawing."), QIcon(":/res/settings.png"), QKeySequence());
+       connect(drawingSettingsAct, SIGNAL(triggered()), this, SLOT(DrawingSettings()));
+
        groupAct = CreateAction(tr("&Group"), tr("Group"), tr("Group/ungroup selected objects."), QIcon(":/res/group-tool.png"), QKeySequence("g"));
        connect(groupAct, SIGNAL(triggered()), this, SLOT(HandleGrouping()));
 
@@ -908,7 +942,7 @@ void ApplicationWindow::CreateActions(void)
        trimAct = CreateAction(tr("&Trim"), tr("Trim"), tr("Trim extraneous lines from selected objects."), QIcon(":/res/trim-tool.png"), QKeySequence("t,r"), true);
        connect(trimAct, SIGNAL(triggered()), this, SLOT(TrimTool()));
 
-       parallelAct = CreateAction(tr("&Parallel"), tr("Parallel"), tr("Create copies of objects parallel to the original."), QIcon(":/res/parallel-tool.png"), QKeySequence("p,a"), true);
+       parallelAct = CreateAction(tr("&Parallel"), tr("Parallel"), tr("Create copies of objects parallel to the original."), QIcon(":/res/parallel-tool.png"), QKeySequence("p,l"), true);
        connect(parallelAct, SIGNAL(triggered()), this, SLOT(ParallelTool()));
 
        triangulateAct = CreateAction(tr("&Triangulate"), tr("Triangulate"), tr("Make triangles from selected lines, preserving their lengths."), QIcon(":/res/triangulate-tool.png"), QKeySequence("t,g"), true);
@@ -1033,6 +1067,7 @@ void ApplicationWindow::CreateMenus(void)
        menu->addAction(addSplineAct);
        menu->addAction(addDimensionAct);
        menu->addSeparator();
+       menu->addAction(drawingSettingsAct);
        menu->addAction(settingsAct);
 
        menu = menuBar()->addMenu(tr("&Help"));
@@ -1105,7 +1140,8 @@ void ApplicationWindow::ReadSettings(void)
        QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
        QSize size = settings.value("size", QSize(400, 400)).toSize();
        drawing->useAntialiasing = settings.value("useAntialiasing", true).toBool();
-       snapToGridAct->setChecked(settings.value("snapToGrid", true).toBool());
+       Global::snapToGrid = settings.value("snapToGrid", true).toBool();
+       snapToGridAct->setChecked(Global::snapToGrid);
        resize(size);
        move(pos);
        restoreState(settings.value("windowState").toByteArray());