]> Shamusworld >> Repos - architektonas/blobdiff - src/applicationwindow.cpp
Fix incorrect object naming, keep hidden layers hidden when printing.
[architektonas] / src / applicationwindow.cpp
index 8c114c8d045c43723dbdd81d7e492a4d89f770e3..56b9735a70139d879ff9568cbe00a1bf27a7401e 100644 (file)
@@ -33,6 +33,7 @@
 #include "blockwidget.h"
 #include "commandprocessor.h"
 #include "consolewidget.h"
+#include "drawingsettingsdlg.h"
 #include "drawingview.h"
 #include "fileio.h"
 #include "generaltab.h"
@@ -317,7 +318,10 @@ void ApplicationWindow::HandlePrintRequest(QPrinter * printer)
 
        // Do object rendering...
        for(int i=0; i<Global::numLayers; i++)
-               drawing->RenderObjects(&painter, drawing->document.objects, i);
+       {
+               if (Global::layerHidden[i] == false)
+                       drawing->RenderObjects(&painter, drawing->document.objects, i);
+       }
 
        // Restore vars
        Global::origin = originSave;
@@ -596,7 +600,7 @@ void ApplicationWindow::SetInternalToolStates(void)
        else
                Global::tool = TTNone;
 
-       cw->SetToolPrompt();//cw->cmdline);
+       cw->SetToolPrompt();
        drawing->update();
 }
 
@@ -618,6 +622,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.
@@ -904,6 +927,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()));
 
@@ -1044,6 +1070,7 @@ void ApplicationWindow::CreateMenus(void)
        menu->addAction(addSplineAct);
        menu->addAction(addDimensionAct);
        menu->addSeparator();
+       menu->addAction(drawingSettingsAct);
        menu->addAction(settingsAct);
 
        menu = menuBar()->addMenu(tr("&Help"));
@@ -1116,7 +1143,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());