X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fapplicationwindow.cpp;h=66f9edc3b9a2a1845063b770d588c378c5ed8b5f;hb=9d5d4488ba75c407709556a7ed56b8d16e21834e;hp=8e7891c613ed8e7691fde9e30d905358f5a1040f;hpb=043ecf4d074909ba2f7f53237962f9eaa72f19c2;p=architektonas diff --git a/src/applicationwindow.cpp b/src/applicationwindow.cpp index 8e7891c..66f9edc 100644 --- a/src/applicationwindow.cpp +++ b/src/applicationwindow.cpp @@ -53,6 +53,8 @@ ApplicationWindow::ApplicationWindow(): settings("Underground Software", "Archit CreateToolbars(); // Create status bar + zoomIndicator = new QLabel("Zoom: 12.5%"); + statusBar()->addPermanentWidget(zoomIndicator); statusBar()->showMessage(tr("Ready")); ReadSettings(); @@ -88,37 +90,48 @@ 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::AddArcTool(void) +{ + ClearUIToolStatesExcept(addArcAct); + SetInternalToolStates(); +} + +void ApplicationWindow::AddPolygonTool(void) +{ + ClearUIToolStatesExcept(addPolygonAct); + SetInternalToolStates(); } void ApplicationWindow::ZoomInTool(void) @@ -149,6 +162,7 @@ when zooming in, new origin will be (xCenter - origin.x) / 2, (yCenter - origin. //printf("Zoom in... level going from %02f to ", Painter::zoom); // This just zooms leaving origin intact... should zoom in at the current center! [DONE] Painter::zoom *= zoomFactor; + zoomIndicator->setText(QString("Zoom: %1%").arg(Painter::zoom * 100.0 * SCREEN_ZOOM)); drawing->update(); } @@ -181,9 +195,43 @@ x 2 = (-426, -301) //printf("Zoom out...\n"); // This just zooms leaving origin intact... should zoom out at the current center! [DONE] Painter::zoom /= zoomFactor; + zoomIndicator->setText(QString("Zoom: %1%").arg(Painter::zoom * 100.0 * SCREEN_ZOOM)); 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(); @@ -216,24 +264,28 @@ void ApplicationWindow::CreateActions(void) QIcon(":/res/fix-length.png"), QKeySequence(tr("F,L")), true); connect(fixLengthAct, SIGNAL(triggered()), this, SLOT(FixLength())); - deleteAct = CreateAction(tr("&Delete"), tr("Delete Object"), tr("Deletes selected objects."), QIcon(":/res/generic-tool.png"), QKeySequence(), true); + deleteAct = CreateAction(tr("&Delete"), tr("Delete Object"), tr("Deletes selected objects."), QIcon(":/res/delete-tool.png"), QKeySequence(), true); connect(deleteAct, SIGNAL(triggered()), this, SLOT(DeleteTool())); addDimensionAct = CreateAction(tr("Add &Dimension"), tr("Add Dimension"), tr("Adds a dimension to the drawing."), QIcon(":/res/dimension-tool.png"), QKeySequence("D,I"), true); connect(addDimensionAct, SIGNAL(triggered()), this, SLOT(DimensionTool())); - addLineAct = CreateAction(tr("Add &Line"), tr("Add Line"), tr("Adds lines to the drawing."), QIcon(":/res/generic-tool.png"), QKeySequence("A,L"), true); + addLineAct = CreateAction(tr("Add &Line"), tr("Add Line"), tr("Adds lines to the drawing."), QIcon(":/res/add-line-tool.png"), QKeySequence("A,L"), true); connect(addLineAct, SIGNAL(triggered()), this, SLOT(AddLineTool())); - addCircleAct = CreateAction(tr("Add &Circle"), tr("Add Circle"), tr("Adds circles to the drawing."), QIcon(":/res/generic-tool.png"), QKeySequence("A,C"), true); + addCircleAct = CreateAction(tr("Add &Circle"), tr("Add Circle"), tr("Adds circles to the drawing."), QIcon(":/res/add-circle-tool.png"), QKeySequence("A,C"), true); connect(addCircleAct, SIGNAL(triggered()), this, SLOT(AddCircleTool())); - addArcAct = CreateAction(tr("Add &Arc"), tr("Add Arc"), tr("Adds arcs to the drawing."), QIcon(":/res/generic-tool.png"), QKeySequence("A,A"), true); + addArcAct = CreateAction(tr("Add &Arc"), tr("Add Arc"), tr("Adds arcs to the drawing."), QIcon(":/res/add-arc-tool.png"), QKeySequence("A,A"), true); + connect(addArcAct, SIGNAL(triggered()), this, SLOT(AddArcTool())); + + addPolygonAct = CreateAction(tr("Add &Polygon"), tr("Add Polygon"), tr("Add polygons to the drawing."), QIcon(":/res/add-polygon-tool.png"), QKeySequence("A,P"), true); + connect(addPolygonAct, SIGNAL(triggered()), this, SLOT(AddPolygonTool())); aboutAct = CreateAction(tr("About &Architektonas"), tr("About Architektonas"), tr("Gives information about this program."), QIcon(":/res/generic-tool.png"), QKeySequence()); connect(aboutAct, SIGNAL(triggered()), this, SLOT(HelpAbout())); - rotateAct = CreateAction(tr("&Rotate Objects"), tr("Rotate"), tr("Rotate object(s) around an arbitrary center."), QIcon(":/res/generic-tool.png"), QKeySequence(tr("R,O")), true); + rotateAct = CreateAction(tr("&Rotate Objects"), tr("Rotate"), tr("Rotate object(s) around an arbitrary center."), QIcon(":/res/rotate-tool.png"), QKeySequence(tr("R,O")), true); connect(rotateAct, SIGNAL(triggered()), this, SLOT(RotateTool())); zoomInAct = CreateAction(tr("Zoom &In"), tr("Zoom In"), tr("Zoom in on the document."), QIcon(":/res/zoom-in.png"), QKeySequence(tr("+")), QKeySequence(tr("="))); @@ -256,6 +308,7 @@ void ApplicationWindow::CreateActions(void) connect(settingsAct, SIGNAL(triggered()), this, SLOT(Settings())); //Hm. I think we'll have to have separate logic to do the "Radio Group Toolbar" thing... +// Yup, in order to turn them off, we'd have to have an "OFF" toolbar button. Ick. /* QActionGroup * group = new QActionGroup(this); group->addAction(deleteAct); group->addAction(addDimensionAct); @@ -323,6 +376,7 @@ void ApplicationWindow::CreateMenus(void) menu->addAction(addLineAct); menu->addAction(addCircleAct); menu->addAction(addArcAct); + menu->addAction(addPolygonAct); menu->addAction(addDimensionAct); menu->addSeparator(); menu->addAction(settingsAct); @@ -348,6 +402,7 @@ void ApplicationWindow::CreateToolbars(void) toolbar->addAction(addLineAct); toolbar->addAction(addCircleAct); toolbar->addAction(addArcAct); + toolbar->addAction(addPolygonAct); toolbar->addAction(addDimensionAct); }